feat: 3d模型
This commit is contained in:
+13
@@ -107,4 +107,17 @@ public class TourismFileController {
|
||||
}
|
||||
return Result.succeed(list, "操作成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据素材ID列表获取素材详情
|
||||
*/
|
||||
@Operation(summary = "根据素材ID列表获取素材详情")
|
||||
@GetMapping("/byIds")
|
||||
public Result<java.util.List<TourismFile>> listByIds(@RequestParam("ids") java.util.List<Long> ids) {
|
||||
if (ids == null || ids.isEmpty()) {
|
||||
return Result.succeed(java.util.Collections.emptyList(), "操作成功");
|
||||
}
|
||||
java.util.List<TourismFile> list = tourismFileService.findByIds(ids);
|
||||
return Result.succeed(list, "操作成功");
|
||||
}
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
package com.central.order.controller.guide;
|
||||
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.order.model.guide.GuideCommission;
|
||||
import com.central.order.model.vo.guide.CommissionOverviewVO;
|
||||
import com.central.order.service.guide.IGuideCommissionService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 导游佣金管理控制器
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Tag(name = "导游佣金管理")
|
||||
@RestController
|
||||
@RequestMapping("/guide/commission")
|
||||
@RequiredArgsConstructor
|
||||
public class GuideCommissionController {
|
||||
|
||||
private final IGuideCommissionService guideCommissionService;
|
||||
|
||||
@Operation(summary = "获取佣金概览")
|
||||
@GetMapping("/overview")
|
||||
public Result<CommissionOverviewVO> getOverview(
|
||||
@Parameter(description = "导游ID") @RequestParam Long guideId) {
|
||||
CommissionOverviewVO overview = guideCommissionService.getCommissionOverview(guideId);
|
||||
if (overview == null) {
|
||||
return Result.failed("导游不存在");
|
||||
}
|
||||
return Result.succeed(overview);
|
||||
}
|
||||
|
||||
@Operation(summary = "分页查询佣金明细")
|
||||
@GetMapping("/list")
|
||||
public Result<PageResult<GuideCommission>> list(@RequestParam Map<String, Object> params) {
|
||||
PageResult<GuideCommission> result = guideCommissionService.findList(params);
|
||||
return Result.succeed(result);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取佣金详情")
|
||||
@GetMapping("/{id}")
|
||||
public Result<GuideCommission> getById(@PathVariable("id") Long commissionId) {
|
||||
GuideCommission commission = guideCommissionService.getById(commissionId);
|
||||
if (commission == null) {
|
||||
return Result.failed("佣金记录不存在");
|
||||
}
|
||||
return Result.succeed(commission);
|
||||
}
|
||||
|
||||
@Operation(summary = "手动结算佣金")
|
||||
@PostMapping("/{id}/settle")
|
||||
public Result<Void> settleCommission(@PathVariable("id") Long commissionId) {
|
||||
guideCommissionService.settleCommission(commissionId);
|
||||
return Result.succeed(null, "结算成功");
|
||||
}
|
||||
|
||||
@Operation(summary = "批量结算佣金")
|
||||
@PostMapping("/batch-settle")
|
||||
public Result<Integer> batchSettle(
|
||||
@Parameter(description = "结算周期(天),默认7") @RequestParam(defaultValue = "7") Integer days) {
|
||||
int count = guideCommissionService.batchSettleCommissions(days);
|
||||
return Result.succeed(count, "批量结算完成");
|
||||
}
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
package com.central.order.controller.guide;
|
||||
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.order.model.dto.guide.GuideAuditDTO;
|
||||
import com.central.order.model.dto.guide.GuideCreateDTO;
|
||||
import com.central.order.model.guide.GuideProfile;
|
||||
import com.central.order.model.vo.guide.GuideInfoVO;
|
||||
import com.central.order.service.guide.IGuideService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 导游管理控制器
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Tag(name = "导游管理")
|
||||
@RestController
|
||||
@RequestMapping("/guide")
|
||||
@RequiredArgsConstructor
|
||||
public class GuideController {
|
||||
|
||||
private final IGuideService guideService;
|
||||
|
||||
@Operation(summary = "创建导游")
|
||||
@PostMapping
|
||||
public Result<Long> createGuide(@Valid @RequestBody GuideCreateDTO dto) {
|
||||
Long guideId = guideService.createGuide(dto);
|
||||
return Result.succeed(guideId, "创建成功");
|
||||
}
|
||||
|
||||
@Operation(summary = "获取导游信息")
|
||||
@GetMapping("/{id}")
|
||||
public Result<GuideInfoVO> getGuideInfo(@PathVariable("id") Long guideId) {
|
||||
GuideInfoVO info = guideService.getGuideInfo(guideId);
|
||||
if (info == null) {
|
||||
return Result.failed("导游不存在");
|
||||
}
|
||||
return Result.succeed(info);
|
||||
}
|
||||
|
||||
@Operation(summary = "分页查询导游列表")
|
||||
@GetMapping("/list")
|
||||
public Result<PageResult<GuideProfile>> list(@RequestParam Map<String, Object> params) {
|
||||
PageResult<GuideProfile> result = guideService.findList(params);
|
||||
return Result.succeed(result);
|
||||
}
|
||||
|
||||
@Operation(summary = "审核导游")
|
||||
@PutMapping("/{id}/audit")
|
||||
public Result<Void> auditGuide(
|
||||
@PathVariable("id") Long guideId,
|
||||
@Valid @RequestBody GuideAuditDTO dto) {
|
||||
guideService.auditGuide(guideId, dto);
|
||||
return Result.succeed(null, "审核完成");
|
||||
}
|
||||
|
||||
@Operation(summary = "更新导游状态")
|
||||
@PutMapping("/{id}/status")
|
||||
public Result<Void> updateStatus(
|
||||
@PathVariable("id") Long guideId,
|
||||
@Parameter(description = "状态: 1-正常 2-禁用") @RequestParam Integer status) {
|
||||
guideService.updateStatus(guideId, status);
|
||||
return Result.succeed(null, "状态更新成功");
|
||||
}
|
||||
|
||||
@Operation(summary = "设置佣金比例")
|
||||
@PutMapping("/{id}/commission-rate")
|
||||
public Result<Void> setCommissionRate(
|
||||
@PathVariable("id") Long guideId,
|
||||
@Parameter(description = "佣金比例(%)") @RequestParam BigDecimal commissionRate) {
|
||||
guideService.setCommissionRate(guideId, commissionRate);
|
||||
return Result.succeed(null, "设置成功");
|
||||
}
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
package com.central.order.controller.guide;
|
||||
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.order.model.dto.guide.WithdrawalApplyDTO;
|
||||
import com.central.order.model.dto.guide.WithdrawalAuditDTO;
|
||||
import com.central.order.model.guide.GuideWithdrawal;
|
||||
import com.central.order.service.guide.IGuideWithdrawalService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 导游提现管理控制器
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Tag(name = "导游提现管理")
|
||||
@RestController
|
||||
@RequestMapping("/guide/withdrawal")
|
||||
@RequiredArgsConstructor
|
||||
public class GuideWithdrawalController {
|
||||
|
||||
private final IGuideWithdrawalService guideWithdrawalService;
|
||||
|
||||
@Operation(summary = "申请提现")
|
||||
@PostMapping("/apply")
|
||||
public Result<String> applyWithdrawal(
|
||||
@Parameter(description = "导游ID") @RequestParam Long guideId,
|
||||
@Valid @RequestBody WithdrawalApplyDTO dto) {
|
||||
String withdrawNo = guideWithdrawalService.applyWithdrawal(guideId, dto);
|
||||
return Result.succeed(withdrawNo, "申请成功");
|
||||
}
|
||||
|
||||
@Operation(summary = "分页查询提现记录")
|
||||
@GetMapping("/list")
|
||||
public Result<PageResult<GuideWithdrawal>> list(@RequestParam Map<String, Object> params) {
|
||||
PageResult<GuideWithdrawal> result = guideWithdrawalService.findList(params);
|
||||
return Result.succeed(result);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取提现详情")
|
||||
@GetMapping("/{id}")
|
||||
public Result<GuideWithdrawal> getById(@PathVariable("id") Long withdrawalId) {
|
||||
GuideWithdrawal withdrawal = guideWithdrawalService.getById(withdrawalId);
|
||||
if (withdrawal == null) {
|
||||
return Result.failed("提现记录不存在");
|
||||
}
|
||||
return Result.succeed(withdrawal);
|
||||
}
|
||||
|
||||
@Operation(summary = "根据提现单号查询")
|
||||
@GetMapping("/no/{withdrawNo}")
|
||||
public Result<GuideWithdrawal> getByWithdrawNo(@PathVariable("withdrawNo") String withdrawNo) {
|
||||
GuideWithdrawal withdrawal = guideWithdrawalService.getByWithdrawNo(withdrawNo);
|
||||
if (withdrawal == null) {
|
||||
return Result.failed("提现记录不存在");
|
||||
}
|
||||
return Result.succeed(withdrawal);
|
||||
}
|
||||
|
||||
@Operation(summary = "审核提现")
|
||||
@PutMapping("/{id}/audit")
|
||||
public Result<Void> auditWithdrawal(
|
||||
@PathVariable("id") Long withdrawalId,
|
||||
@Parameter(description = "审核人ID") @RequestParam Long auditUserId,
|
||||
@Valid @RequestBody WithdrawalAuditDTO dto) {
|
||||
guideWithdrawalService.auditWithdrawal(withdrawalId, dto, auditUserId);
|
||||
return Result.succeed(null, "审核完成");
|
||||
}
|
||||
|
||||
@Operation(summary = "确认打款完成")
|
||||
@PutMapping("/{id}/transfer")
|
||||
public Result<Void> confirmTransfer(
|
||||
@PathVariable("id") Long withdrawalId,
|
||||
@Parameter(description = "转账单号") @RequestParam String transferNo) {
|
||||
guideWithdrawalService.confirmTransfer(withdrawalId, transferNo);
|
||||
return Result.succeed(null, "打款确认成功");
|
||||
}
|
||||
|
||||
@Operation(summary = "打款失败")
|
||||
@PutMapping("/{id}/transfer-failed")
|
||||
public Result<Void> transferFailed(
|
||||
@PathVariable("id") Long withdrawalId,
|
||||
@Parameter(description = "失败原因") @RequestParam String failReason) {
|
||||
guideWithdrawalService.transferFailed(withdrawalId, failReason);
|
||||
return Result.succeed(null, "已记录失败");
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package com.central.order.enums.guide;
|
||||
|
||||
import com.central.common.enums.ZltEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 佣金状态枚举
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Getter
|
||||
public enum CommissionStatusEnum implements ZltEnum {
|
||||
PENDING(0, "待结算"),
|
||||
SETTLED(1, "已结算"),
|
||||
REFUNDED(2, "已退款"),
|
||||
FAILED(3, "结算失败");
|
||||
|
||||
private final Integer id;
|
||||
private final String content;
|
||||
|
||||
CommissionStatusEnum(Integer id, String content) {
|
||||
this.id = id;
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public static CommissionStatusEnum getById(Integer id) {
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
for (CommissionStatusEnum status : values()) {
|
||||
if (status.getId().equals(id)) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package com.central.order.enums.guide;
|
||||
|
||||
import com.central.common.enums.ZltEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 导游状态枚举
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Getter
|
||||
public enum GuideStatusEnum implements ZltEnum {
|
||||
PENDING(0, "待审核"),
|
||||
NORMAL(1, "正常"),
|
||||
DISABLED(2, "禁用"),
|
||||
REJECTED(3, "审核拒绝");
|
||||
|
||||
private final Integer id;
|
||||
private final String content;
|
||||
|
||||
GuideStatusEnum(Integer id, String content) {
|
||||
this.id = id;
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public static GuideStatusEnum getById(Integer id) {
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
for (GuideStatusEnum status : values()) {
|
||||
if (status.getId().equals(id)) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.central.order.enums.guide;
|
||||
|
||||
import com.central.common.enums.ZltEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 景区/导游类型枚举
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Getter
|
||||
public enum TourismTypeEnum implements ZltEnum {
|
||||
SCENIC(1, "景区"),
|
||||
GUIDE(2, "导游");
|
||||
|
||||
private final Integer id;
|
||||
private final String content;
|
||||
|
||||
TourismTypeEnum(Integer id, String content) {
|
||||
this.id = id;
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public static TourismTypeEnum getById(Integer id) {
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
for (TourismTypeEnum type : values()) {
|
||||
if (type.getId().equals(id)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package com.central.order.enums.guide;
|
||||
|
||||
import com.central.common.enums.ZltEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 提现状态枚举
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Getter
|
||||
public enum WithdrawalStatusEnum implements ZltEnum {
|
||||
PENDING(0, "待审核"),
|
||||
APPROVED(1, "审核通过"),
|
||||
REJECTED(2, "审核拒绝"),
|
||||
TRANSFERRING(3, "打款中"),
|
||||
COMPLETED(4, "已到账"),
|
||||
FAILED(5, "打款失败");
|
||||
|
||||
private final Integer id;
|
||||
private final String content;
|
||||
|
||||
WithdrawalStatusEnum(Integer id, String content) {
|
||||
this.id = id;
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public static WithdrawalStatusEnum getById(Integer id) {
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
for (WithdrawalStatusEnum status : values()) {
|
||||
if (status.getId().equals(id)) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+5
@@ -29,4 +29,9 @@ public interface TourismFileMapper extends SuperMapper<TourismFile> {
|
||||
@Param("type") Integer type,
|
||||
@Param("status") Integer status,
|
||||
@Param("description") String description);
|
||||
|
||||
/**
|
||||
* 根据素材ID列表查询
|
||||
*/
|
||||
List<TourismFile> findByIds(@Param("ids") List<Long> ids);
|
||||
}
|
||||
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
package com.central.order.mapper.guide;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.central.order.model.guide.GuideCommission;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 导游佣金明细Mapper
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Mapper
|
||||
public interface GuideCommissionMapper extends BaseMapper<GuideCommission> {
|
||||
|
||||
/**
|
||||
* 根据订单号查询佣金记录
|
||||
*/
|
||||
GuideCommission selectByOrderNo(@Param("orderNo") String orderNo);
|
||||
|
||||
/**
|
||||
* 根据佣金单号查询
|
||||
*/
|
||||
GuideCommission selectByCommissionNo(@Param("commissionNo") String commissionNo);
|
||||
|
||||
/**
|
||||
* 分页查询佣金列表
|
||||
*/
|
||||
List<GuideCommission> findList(Page<GuideCommission> page, @Param("p") Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 查询待结算的佣金列表(创建时间早于指定时间)
|
||||
*/
|
||||
List<GuideCommission> selectPendingSettleList(@Param("beforeTime") LocalDateTime beforeTime, @Param("limit") Integer limit);
|
||||
|
||||
/**
|
||||
* 统计导游今日佣金
|
||||
*/
|
||||
Long sumTodayCommission(@Param("guideId") Long guideId);
|
||||
|
||||
/**
|
||||
* 统计导游本月佣金
|
||||
*/
|
||||
Long sumMonthCommission(@Param("guideId") Long guideId);
|
||||
|
||||
/**
|
||||
* 统计导游待结算笔数
|
||||
*/
|
||||
Integer countPendingSettle(@Param("guideId") Long guideId);
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
package com.central.order.mapper.guide;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.central.order.model.guide.GuideProfile;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 导游扩展信息Mapper
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Mapper
|
||||
public interface GuideProfileMapper extends BaseMapper<GuideProfile> {
|
||||
|
||||
/**
|
||||
* 根据tourism_id查询导游信息
|
||||
*/
|
||||
GuideProfile selectByTourismId(@Param("tourismId") Long tourismId);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询导游信息
|
||||
*/
|
||||
GuideProfile selectByUserId(@Param("userId") Long userId);
|
||||
|
||||
/**
|
||||
* 根据导游编号查询
|
||||
*/
|
||||
GuideProfile selectByGuideNo(@Param("guideNo") String guideNo);
|
||||
|
||||
/**
|
||||
* 分页查询导游列表
|
||||
*/
|
||||
List<GuideProfile> findList(Page<GuideProfile> page, @Param("p") Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 增加累计佣金
|
||||
*/
|
||||
int addTotalCommission(@Param("id") Long id, @Param("amount") Long amount);
|
||||
|
||||
/**
|
||||
* 增加可提现佣金
|
||||
*/
|
||||
int addAvailableCommission(@Param("id") Long id, @Param("amount") Long amount);
|
||||
|
||||
/**
|
||||
* 冻结佣金(从可提现转到冻结)
|
||||
*/
|
||||
int freezeCommission(@Param("id") Long id, @Param("amount") Long amount);
|
||||
|
||||
/**
|
||||
* 解冻佣金(从冻结转回可提现)
|
||||
*/
|
||||
int unfreezeCommission(@Param("id") Long id, @Param("amount") Long amount);
|
||||
|
||||
/**
|
||||
* 完成提现(从冻结转到已提现)
|
||||
*/
|
||||
int completeWithdrawal(@Param("id") Long id, @Param("amount") Long amount);
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package com.central.order.mapper.guide;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.central.order.model.guide.GuideWithdrawal;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 导游提现申请Mapper
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Mapper
|
||||
public interface GuideWithdrawalMapper extends BaseMapper<GuideWithdrawal> {
|
||||
|
||||
/**
|
||||
* 根据提现单号查询
|
||||
*/
|
||||
GuideWithdrawal selectByWithdrawNo(@Param("withdrawNo") String withdrawNo);
|
||||
|
||||
/**
|
||||
* 分页查询提现列表
|
||||
*/
|
||||
List<GuideWithdrawal> findList(Page<GuideWithdrawal> page, @Param("p") Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 查询审核通过待打款的列表
|
||||
*/
|
||||
List<GuideWithdrawal> selectApprovedList(@Param("limit") Integer limit);
|
||||
|
||||
/**
|
||||
* 统计导游今日提现次数
|
||||
*/
|
||||
Integer countTodayWithdrawal(@Param("guideId") Long guideId);
|
||||
}
|
||||
@@ -59,4 +59,10 @@ public class Tourism extends SuperEntity {
|
||||
* 是否在首页显示(0:不显示,1:显示)
|
||||
*/
|
||||
private Integer showInHomepage;
|
||||
|
||||
/**
|
||||
* 景区类型(1:景区,2:导游)
|
||||
* @see com.central.order.enums.guide.TourismTypeEnum
|
||||
*/
|
||||
private Integer tourismType;
|
||||
}
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package com.central.order.model.dto.guide;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 导游审核请求DTO
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "导游审核请求")
|
||||
public class GuideAuditDTO {
|
||||
|
||||
@NotNull(message = "审核结果不能为空")
|
||||
@Schema(description = "审核结果: true-通过 false-拒绝")
|
||||
private Boolean approved;
|
||||
|
||||
@Schema(description = "审核备注")
|
||||
private String remark;
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
package com.central.order.model.dto.guide;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 创建导游请求DTO
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "创建导游请求")
|
||||
public class GuideCreateDTO {
|
||||
|
||||
@NotBlank(message = "导游姓名不能为空")
|
||||
@Schema(description = "导游姓名")
|
||||
private String name;
|
||||
|
||||
@NotBlank(message = "手机号不能为空")
|
||||
@Schema(description = "手机号")
|
||||
private String phone;
|
||||
|
||||
@Schema(description = "身份证号")
|
||||
private String idCard;
|
||||
|
||||
@NotBlank(message = "租户ID不能为空")
|
||||
@Schema(description = "租户ID")
|
||||
private String tenantId;
|
||||
|
||||
@Schema(description = "用户ID")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "微信openid")
|
||||
private String openid;
|
||||
|
||||
@Schema(description = "头像URL")
|
||||
private String avatar;
|
||||
|
||||
@Schema(description = "佣金比例(%)")
|
||||
private BigDecimal commissionRate;
|
||||
|
||||
@Schema(description = "银行账户")
|
||||
private String bankAccount;
|
||||
|
||||
@Schema(description = "开户行")
|
||||
private String bankName;
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package com.central.order.model.dto.guide;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 提现申请请求DTO
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "提现申请请求")
|
||||
public class WithdrawalApplyDTO {
|
||||
|
||||
@NotNull(message = "提现金额不能为空")
|
||||
@Min(value = 1, message = "提现金额必须大于0")
|
||||
@Schema(description = "提现金额(分)")
|
||||
private Long amount;
|
||||
|
||||
@NotNull(message = "提现方式不能为空")
|
||||
@Schema(description = "提现方式: 1-微信零钱 2-银行卡")
|
||||
private Integer withdrawType;
|
||||
|
||||
@Schema(description = "收款账户信息(JSON)")
|
||||
private String accountInfo;
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package com.central.order.model.dto.guide;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 提现审核请求DTO
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "提现审核请求")
|
||||
public class WithdrawalAuditDTO {
|
||||
|
||||
@NotNull(message = "审核结果不能为空")
|
||||
@Schema(description = "审核结果: true-通过 false-拒绝")
|
||||
private Boolean approved;
|
||||
|
||||
@Schema(description = "审核备注")
|
||||
private String remark;
|
||||
}
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
package com.central.order.model.guide;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 导游佣金明细表
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Data
|
||||
@TableName("guide_commissions")
|
||||
public class GuideCommission implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 佣金单号
|
||||
*/
|
||||
private String commissionNo;
|
||||
|
||||
/**
|
||||
* 导游ID (tourisms.id)
|
||||
*/
|
||||
private Long guideId;
|
||||
|
||||
/**
|
||||
* 订单编号
|
||||
*/
|
||||
private String orderNo;
|
||||
|
||||
/**
|
||||
* 订单金额(分)
|
||||
*/
|
||||
private Long orderAmount;
|
||||
|
||||
/**
|
||||
* 佣金比例(%)
|
||||
*/
|
||||
private BigDecimal commissionRate;
|
||||
|
||||
/**
|
||||
* 佣金金额(分)
|
||||
*/
|
||||
private Long commissionAmount;
|
||||
|
||||
/**
|
||||
* 状态: 0-待结算 1-已结算 2-已退款 3-结算失败
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 结算时间
|
||||
*/
|
||||
private LocalDateTime settleTime;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 导游姓名 (关联查询)
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String guideName;
|
||||
|
||||
/**
|
||||
* 导游编号 (关联查询)
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String guideNo;
|
||||
}
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
package com.central.order.model.guide;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 导游扩展信息表
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Data
|
||||
@TableName("guide_profiles")
|
||||
public class GuideProfile implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 关联tourisms表ID (tourism_type=2)
|
||||
*/
|
||||
private Long tourismId;
|
||||
|
||||
/**
|
||||
* 关联用户ID (sys_user)
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 导游编号
|
||||
*/
|
||||
private String guideNo;
|
||||
|
||||
/**
|
||||
* 身份证号
|
||||
*/
|
||||
private String idCard;
|
||||
|
||||
/**
|
||||
* 微信openid (用于提现)
|
||||
*/
|
||||
private String openid;
|
||||
|
||||
/**
|
||||
* 银行账户
|
||||
*/
|
||||
private String bankAccount;
|
||||
|
||||
/**
|
||||
* 开户行
|
||||
*/
|
||||
private String bankName;
|
||||
|
||||
/**
|
||||
* 状态: 0-待审核 1-正常 2-禁用 3-审核拒绝
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 审核备注
|
||||
*/
|
||||
private String auditRemark;
|
||||
|
||||
/**
|
||||
* 默认佣金比例(%)
|
||||
*/
|
||||
private BigDecimal commissionRate;
|
||||
|
||||
/**
|
||||
* 累计佣金(分)
|
||||
*/
|
||||
private Long totalCommission;
|
||||
|
||||
/**
|
||||
* 可提现佣金(分)
|
||||
*/
|
||||
private Long availableCommission;
|
||||
|
||||
/**
|
||||
* 冻结佣金(分)
|
||||
*/
|
||||
private Long frozenCommission;
|
||||
|
||||
/**
|
||||
* 已提现佣金(分)
|
||||
*/
|
||||
private Long withdrawnCommission;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 导游姓名 (关联查询)
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String guideName;
|
||||
|
||||
/**
|
||||
* 导游手机 (关联查询)
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String guidePhone;
|
||||
}
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
package com.central.order.model.guide;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 导游提现申请表
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Data
|
||||
@TableName("guide_withdrawals")
|
||||
public class GuideWithdrawal implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 提现单号
|
||||
*/
|
||||
private String withdrawNo;
|
||||
|
||||
/**
|
||||
* 导游ID (tourisms.id)
|
||||
*/
|
||||
private Long guideId;
|
||||
|
||||
/**
|
||||
* 提现金额(分)
|
||||
*/
|
||||
private Long amount;
|
||||
|
||||
/**
|
||||
* 实际到账金额(分)
|
||||
*/
|
||||
private Long actualAmount;
|
||||
|
||||
/**
|
||||
* 手续费(分)
|
||||
*/
|
||||
private Long fee;
|
||||
|
||||
/**
|
||||
* 提现方式: 1-微信零钱 2-银行卡
|
||||
*/
|
||||
private Integer withdrawType;
|
||||
|
||||
/**
|
||||
* 收款账户信息(JSON)
|
||||
*/
|
||||
private String accountInfo;
|
||||
|
||||
/**
|
||||
* 状态: 0-待审核 1-审核通过 2-审核拒绝 3-打款中 4-已到账 5-打款失败
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 申请时间
|
||||
*/
|
||||
private LocalDateTime applyTime;
|
||||
|
||||
/**
|
||||
* 审核人ID
|
||||
*/
|
||||
private Long auditUserId;
|
||||
|
||||
/**
|
||||
* 审核时间
|
||||
*/
|
||||
private LocalDateTime auditTime;
|
||||
|
||||
/**
|
||||
* 审核备注
|
||||
*/
|
||||
private String auditRemark;
|
||||
|
||||
/**
|
||||
* 打款时间
|
||||
*/
|
||||
private LocalDateTime transferTime;
|
||||
|
||||
/**
|
||||
* 微信/银行转账单号
|
||||
*/
|
||||
private String transferNo;
|
||||
|
||||
/**
|
||||
* 失败原因
|
||||
*/
|
||||
private String failReason;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 导游姓名 (关联查询)
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String guideName;
|
||||
|
||||
/**
|
||||
* 导游编号 (关联查询)
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String guideNo;
|
||||
|
||||
/**
|
||||
* 导游手机 (关联查询)
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String guidePhone;
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.central.order.model.vo.guide;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 佣金概览VO
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "佣金概览")
|
||||
public class CommissionOverviewVO {
|
||||
|
||||
@Schema(description = "累计佣金(分)")
|
||||
private Long totalCommission;
|
||||
|
||||
@Schema(description = "可提现佣金(分)")
|
||||
private Long availableCommission;
|
||||
|
||||
@Schema(description = "冻结佣金(分)")
|
||||
private Long frozenCommission;
|
||||
|
||||
@Schema(description = "已提现佣金(分)")
|
||||
private Long withdrawnCommission;
|
||||
|
||||
@Schema(description = "今日佣金(分)")
|
||||
private Long todayCommission;
|
||||
|
||||
@Schema(description = "本月佣金(分)")
|
||||
private Long monthCommission;
|
||||
|
||||
@Schema(description = "待结算笔数")
|
||||
private Integer pendingSettleCount;
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package com.central.order.model.vo.guide;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 导游信息VO
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "导游信息")
|
||||
public class GuideInfoVO {
|
||||
|
||||
@Schema(description = "导游ID (tourisms.id)")
|
||||
private Long guideId;
|
||||
|
||||
@Schema(description = "导游编号")
|
||||
private String guideNo;
|
||||
|
||||
@Schema(description = "导游姓名")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "手机号")
|
||||
private String phone;
|
||||
|
||||
@Schema(description = "状态: 0-待审核 1-正常 2-禁用 3-审核拒绝")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "状态描述")
|
||||
private String statusDesc;
|
||||
|
||||
@Schema(description = "佣金比例(%)")
|
||||
private BigDecimal commissionRate;
|
||||
|
||||
@Schema(description = "累计佣金(分)")
|
||||
private Long totalCommission;
|
||||
|
||||
@Schema(description = "可提现佣金(分)")
|
||||
private Long availableCommission;
|
||||
|
||||
@Schema(description = "租户ID")
|
||||
private String tenantId;
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
package com.central.order.scheduler;
|
||||
|
||||
import com.central.common.context.TenantContextHolder;
|
||||
import com.central.order.service.guide.IGuideCommissionService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 导游佣金结算定时任务
|
||||
* 每天凌晨2点执行,结算T+N天前的待结算佣金
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class CommissionSettleScheduler {
|
||||
|
||||
private final IGuideCommissionService guideCommissionService;
|
||||
|
||||
/**
|
||||
* 结算周期(天),默认7天
|
||||
*/
|
||||
@Value("${guide.commission.settle-days:7}")
|
||||
private Integer settleDays;
|
||||
|
||||
/**
|
||||
* 是否启用自动结算
|
||||
*/
|
||||
@Value("${guide.commission.auto-settle:true}")
|
||||
private Boolean autoSettle;
|
||||
|
||||
/**
|
||||
* 每天凌晨2点执行佣金结算
|
||||
* cron表达式: 秒 分 时 日 月 周
|
||||
*/
|
||||
@Scheduled(cron = "${guide.commission.settle-cron:0 0 2 * * ?}")
|
||||
public void settleCommission() {
|
||||
if (!autoSettle) {
|
||||
log.debug("佣金自动结算已禁用,跳过执行");
|
||||
return;
|
||||
}
|
||||
|
||||
log.info("开始执行佣金结算定时任务, settleDays={}", settleDays);
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
try {
|
||||
TenantContextHolder.setTenant("webApp");
|
||||
int settledCount = guideCommissionService.batchSettleCommissions(settleDays);
|
||||
long costTime = System.currentTimeMillis() - startTime;
|
||||
log.info("佣金结算定时任务执行完成, 结算数量={}, 耗时={}ms", settledCount, costTime);
|
||||
} catch (Exception e) {
|
||||
log.error("佣金结算定时任务执行失败", e);
|
||||
} finally {
|
||||
TenantContextHolder.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
@@ -23,5 +23,10 @@ public interface ITourismFileService extends ISuperService<TourismFile> {
|
||||
|
||||
|
||||
PageResult<TourismFileGroupVO> findFilesGroupedByTenant(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 根据素材ID列表查询
|
||||
*/
|
||||
List<TourismFile> findByIds(List<Long> ids);
|
||||
}
|
||||
|
||||
|
||||
+71
@@ -0,0 +1,71 @@
|
||||
package com.central.order.service.guide;
|
||||
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.order.model.Order;
|
||||
import com.central.order.model.guide.GuideCommission;
|
||||
import com.central.order.model.vo.guide.CommissionOverviewVO;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 导游佣金服务接口
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
public interface IGuideCommissionService {
|
||||
|
||||
/**
|
||||
* 支付成功后检查并创建佣金明细
|
||||
* 在支付回调中调用此方法
|
||||
*
|
||||
* @param order 订单
|
||||
*/
|
||||
void createCommissionIfGuideOrder(Order order);
|
||||
|
||||
/**
|
||||
* 获取佣金概览
|
||||
*
|
||||
* @param guideId 导游ID
|
||||
* @return 佣金概览
|
||||
*/
|
||||
CommissionOverviewVO getCommissionOverview(Long guideId);
|
||||
|
||||
/**
|
||||
* 分页查询佣金明细
|
||||
*
|
||||
* @param params 查询参数
|
||||
* @return 分页结果
|
||||
*/
|
||||
PageResult<GuideCommission> findList(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 获取佣金详情
|
||||
*
|
||||
* @param commissionId 佣金ID
|
||||
* @return 佣金详情
|
||||
*/
|
||||
GuideCommission getById(Long commissionId);
|
||||
|
||||
/**
|
||||
* 结算佣金
|
||||
*
|
||||
* @param commissionId 佣金ID
|
||||
*/
|
||||
void settleCommission(Long commissionId);
|
||||
|
||||
/**
|
||||
* 批量结算待结算的佣金
|
||||
*
|
||||
* @param days 结算周期(天数)
|
||||
* @return 结算数量
|
||||
*/
|
||||
int batchSettleCommissions(int days);
|
||||
|
||||
/**
|
||||
* 退款时更新佣金状态
|
||||
*
|
||||
* @param orderNo 订单号
|
||||
*/
|
||||
void refundCommission(String orderNo);
|
||||
}
|
||||
+83
@@ -0,0 +1,83 @@
|
||||
package com.central.order.service.guide;
|
||||
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.order.model.dto.guide.GuideAuditDTO;
|
||||
import com.central.order.model.dto.guide.GuideCreateDTO;
|
||||
import com.central.order.model.guide.GuideProfile;
|
||||
import com.central.order.model.vo.guide.GuideInfoVO;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 导游服务接口
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
public interface IGuideService {
|
||||
|
||||
/**
|
||||
* 创建导游
|
||||
*
|
||||
* @param dto 创建请求
|
||||
* @return 导游ID (tourisms.id)
|
||||
*/
|
||||
Long createGuide(GuideCreateDTO dto);
|
||||
|
||||
/**
|
||||
* 获取导游信息
|
||||
*
|
||||
* @param guideId 导游ID (tourisms.id)
|
||||
* @return 导游信息
|
||||
*/
|
||||
GuideInfoVO getGuideInfo(Long guideId);
|
||||
|
||||
/**
|
||||
* 根据用户ID获取导游信息
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 导游信息
|
||||
*/
|
||||
GuideInfoVO getGuideInfoByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 获取导游扩展信息
|
||||
*
|
||||
* @param guideId 导游ID (tourisms.id)
|
||||
* @return 导游扩展信息
|
||||
*/
|
||||
GuideProfile getGuideProfile(Long guideId);
|
||||
|
||||
/**
|
||||
* 分页查询导游列表
|
||||
*
|
||||
* @param params 查询参数
|
||||
* @return 分页结果
|
||||
*/
|
||||
PageResult<GuideProfile> findList(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 审核导游
|
||||
*
|
||||
* @param guideId 导游ID
|
||||
* @param dto 审核请求
|
||||
*/
|
||||
void auditGuide(Long guideId, GuideAuditDTO dto);
|
||||
|
||||
/**
|
||||
* 更新导游状态
|
||||
*
|
||||
* @param guideId 导游ID
|
||||
* @param status 状态
|
||||
*/
|
||||
void updateStatus(Long guideId, Integer status);
|
||||
|
||||
/**
|
||||
* 设置佣金比例
|
||||
*
|
||||
* @param guideId 导游ID
|
||||
* @param commissionRate 佣金比例
|
||||
*/
|
||||
void setCommissionRate(Long guideId, BigDecimal commissionRate);
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
package com.central.order.service.guide;
|
||||
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.order.model.dto.guide.WithdrawalApplyDTO;
|
||||
import com.central.order.model.dto.guide.WithdrawalAuditDTO;
|
||||
import com.central.order.model.guide.GuideWithdrawal;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 导游提现服务接口
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
public interface IGuideWithdrawalService {
|
||||
|
||||
/**
|
||||
* 申请提现
|
||||
*
|
||||
* @param guideId 导游ID
|
||||
* @param dto 申请请求
|
||||
* @return 提现单号
|
||||
*/
|
||||
String applyWithdrawal(Long guideId, WithdrawalApplyDTO dto);
|
||||
|
||||
/**
|
||||
* 分页查询提现记录
|
||||
*
|
||||
* @param params 查询参数
|
||||
* @return 分页结果
|
||||
*/
|
||||
PageResult<GuideWithdrawal> findList(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 获取提现详情
|
||||
*
|
||||
* @param withdrawalId 提现ID
|
||||
* @return 提现详情
|
||||
*/
|
||||
GuideWithdrawal getById(Long withdrawalId);
|
||||
|
||||
/**
|
||||
* 根据提现单号获取详情
|
||||
*
|
||||
* @param withdrawNo 提现单号
|
||||
* @return 提现详情
|
||||
*/
|
||||
GuideWithdrawal getByWithdrawNo(String withdrawNo);
|
||||
|
||||
/**
|
||||
* 审核提现
|
||||
*
|
||||
* @param withdrawalId 提现ID
|
||||
* @param dto 审核请求
|
||||
* @param auditUserId 审核人ID
|
||||
*/
|
||||
void auditWithdrawal(Long withdrawalId, WithdrawalAuditDTO dto, Long auditUserId);
|
||||
|
||||
/**
|
||||
* 执行打款
|
||||
*
|
||||
* @param withdrawalId 提现ID
|
||||
*/
|
||||
void executeTransfer(Long withdrawalId);
|
||||
|
||||
/**
|
||||
* 确认打款完成
|
||||
*
|
||||
* @param withdrawalId 提现ID
|
||||
* @param transferNo 转账单号
|
||||
*/
|
||||
void confirmTransfer(Long withdrawalId, String transferNo);
|
||||
|
||||
/**
|
||||
* 打款失败
|
||||
*
|
||||
* @param withdrawalId 提现ID
|
||||
* @param failReason 失败原因
|
||||
*/
|
||||
void transferFailed(Long withdrawalId, String failReason);
|
||||
}
|
||||
+230
@@ -0,0 +1,230 @@
|
||||
package com.central.order.service.guide.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.order.enums.guide.CommissionStatusEnum;
|
||||
import com.central.order.enums.guide.GuideStatusEnum;
|
||||
import com.central.order.enums.guide.TourismTypeEnum;
|
||||
import com.central.order.mapper.TourismMapper;
|
||||
import com.central.order.mapper.guide.GuideCommissionMapper;
|
||||
import com.central.order.mapper.guide.GuideProfileMapper;
|
||||
import com.central.order.model.Order;
|
||||
import com.central.order.model.Tourism;
|
||||
import com.central.order.model.guide.GuideCommission;
|
||||
import com.central.order.model.guide.GuideProfile;
|
||||
import com.central.order.model.vo.guide.CommissionOverviewVO;
|
||||
import com.central.order.service.guide.IGuideCommissionService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* 导游佣金服务实现
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class GuideCommissionServiceImpl implements IGuideCommissionService {
|
||||
|
||||
private final TourismMapper tourismMapper;
|
||||
private final GuideProfileMapper guideProfileMapper;
|
||||
private final GuideCommissionMapper guideCommissionMapper;
|
||||
|
||||
private static final AtomicInteger COMMISSION_NO_COUNTER = new AtomicInteger(0);
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void createCommissionIfGuideOrder(Order order) {
|
||||
// 1. 查询订单关联的tourism
|
||||
Tourism tourism = tourismMapper.selectById(order.getTourismId());
|
||||
if (tourism == null) {
|
||||
log.debug("订单关联的tourism不存在: tourismId={}", order.getTourismId());
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. 判断是否为导游类型
|
||||
if (tourism.getTourismType() == null ||
|
||||
!tourism.getTourismType().equals(TourismTypeEnum.GUIDE.getId())) {
|
||||
// 不是导游订单,跳过
|
||||
log.debug("非导游订单,跳过佣金计算: tourismId={}, type={}",
|
||||
order.getTourismId(), tourism.getTourismType());
|
||||
return;
|
||||
}
|
||||
|
||||
// 3. 检查是否已存在佣金记录(防止重复创建)
|
||||
GuideCommission existingCommission = guideCommissionMapper.selectByOrderNo(order.getOrderNo());
|
||||
if (existingCommission != null) {
|
||||
log.warn("佣金记录已存在,跳过: orderNo={}", order.getOrderNo());
|
||||
return;
|
||||
}
|
||||
|
||||
// 4. 查询导游扩展信息
|
||||
GuideProfile profile = guideProfileMapper.selectByTourismId(tourism.getId());
|
||||
if (profile == null) {
|
||||
log.warn("导游扩展信息不存在: tourismId={}", tourism.getId());
|
||||
return;
|
||||
}
|
||||
if (!GuideStatusEnum.NORMAL.getId().equals(profile.getStatus())) {
|
||||
log.warn("导游状态异常,跳过佣金计算: tourismId={}, status={}", tourism.getId(), profile.getStatus());
|
||||
return;
|
||||
}
|
||||
|
||||
// 5. 计算佣金
|
||||
Long orderAmount = Long.parseLong(order.getOrderAmount());
|
||||
BigDecimal rate = profile.getCommissionRate();
|
||||
Long commissionAmount = new BigDecimal(orderAmount)
|
||||
.multiply(rate)
|
||||
.divide(new BigDecimal("100"), 0, RoundingMode.DOWN)
|
||||
.longValue();
|
||||
|
||||
// 6. 创建佣金记录
|
||||
GuideCommission commission = new GuideCommission();
|
||||
commission.setCommissionNo(generateCommissionNo());
|
||||
commission.setGuideId(tourism.getId());
|
||||
commission.setOrderNo(order.getOrderNo());
|
||||
commission.setOrderAmount(orderAmount);
|
||||
commission.setCommissionRate(rate);
|
||||
commission.setCommissionAmount(commissionAmount);
|
||||
commission.setStatus(CommissionStatusEnum.PENDING.getId());
|
||||
commission.setTenantId(order.getTenantId());
|
||||
|
||||
guideCommissionMapper.insert(commission);
|
||||
|
||||
// 7. 更新导游累计佣金
|
||||
guideProfileMapper.addTotalCommission(profile.getId(), commissionAmount);
|
||||
|
||||
log.info("创建导游佣金记录: guideId={}, orderNo={}, amount={}",
|
||||
tourism.getId(), order.getOrderNo(), commissionAmount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommissionOverviewVO getCommissionOverview(Long guideId) {
|
||||
GuideProfile profile = guideProfileMapper.selectByTourismId(guideId);
|
||||
if (profile == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
CommissionOverviewVO vo = new CommissionOverviewVO();
|
||||
vo.setTotalCommission(profile.getTotalCommission());
|
||||
vo.setAvailableCommission(profile.getAvailableCommission());
|
||||
vo.setFrozenCommission(profile.getFrozenCommission());
|
||||
vo.setWithdrawnCommission(profile.getWithdrawnCommission());
|
||||
vo.setTodayCommission(guideCommissionMapper.sumTodayCommission(guideId));
|
||||
vo.setMonthCommission(guideCommissionMapper.sumMonthCommission(guideId));
|
||||
vo.setPendingSettleCount(guideCommissionMapper.countPendingSettle(guideId));
|
||||
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<GuideCommission> findList(Map<String, Object> params) {
|
||||
Page<GuideCommission> page = new Page<>(
|
||||
Integer.parseInt(params.getOrDefault("page", "1").toString()),
|
||||
Integer.parseInt(params.getOrDefault("limit", "10").toString())
|
||||
);
|
||||
List<GuideCommission> list = guideCommissionMapper.findList(page, params);
|
||||
return PageResult.<GuideCommission>builder()
|
||||
.data(list)
|
||||
.count(page.getTotal())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuideCommission getById(Long commissionId) {
|
||||
return guideCommissionMapper.selectById(commissionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void settleCommission(Long commissionId) {
|
||||
GuideCommission commission = guideCommissionMapper.selectById(commissionId);
|
||||
if (commission == null) {
|
||||
log.warn("佣金记录不存在: commissionId={}", commissionId);
|
||||
return;
|
||||
}
|
||||
if (!CommissionStatusEnum.PENDING.getId().equals(commission.getStatus())) {
|
||||
log.warn("佣金状态非待结算,跳过: commissionId={}, status={}", commissionId, commission.getStatus());
|
||||
return;
|
||||
}
|
||||
|
||||
// 更新佣金状态为已结算
|
||||
commission.setStatus(CommissionStatusEnum.SETTLED.getId());
|
||||
commission.setSettleTime(LocalDateTime.now());
|
||||
guideCommissionMapper.updateById(commission);
|
||||
|
||||
// 更新导游可提现余额
|
||||
GuideProfile profile = guideProfileMapper.selectByTourismId(commission.getGuideId());
|
||||
if (profile != null) {
|
||||
guideProfileMapper.addAvailableCommission(profile.getId(), commission.getCommissionAmount());
|
||||
}
|
||||
|
||||
log.info("佣金结算成功: commissionId={}, amount={}", commissionId, commission.getCommissionAmount());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int batchSettleCommissions(int days) {
|
||||
LocalDateTime beforeTime = LocalDateTime.now().minusDays(days);
|
||||
List<GuideCommission> pendingList = guideCommissionMapper.selectPendingSettleList(beforeTime, 500);
|
||||
|
||||
int successCount = 0;
|
||||
for (GuideCommission commission : pendingList) {
|
||||
try {
|
||||
settleCommission(commission.getId());
|
||||
successCount++;
|
||||
} catch (Exception e) {
|
||||
log.error("佣金结算失败: commissionId={}", commission.getId(), e);
|
||||
}
|
||||
}
|
||||
|
||||
log.info("批量佣金结算完成: total={}, success={}", pendingList.size(), successCount);
|
||||
return successCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void refundCommission(String orderNo) {
|
||||
GuideCommission commission = guideCommissionMapper.selectByOrderNo(orderNo);
|
||||
if (commission == null) {
|
||||
log.debug("未找到订单对应的佣金记录: orderNo={}", orderNo);
|
||||
return;
|
||||
}
|
||||
|
||||
Integer oldStatus = commission.getStatus();
|
||||
commission.setStatus(CommissionStatusEnum.REFUNDED.getId());
|
||||
commission.setRemark("订单退款");
|
||||
guideCommissionMapper.updateById(commission);
|
||||
|
||||
// 如果是已结算的佣金,需要扣减可提现余额
|
||||
if (CommissionStatusEnum.SETTLED.getId().equals(oldStatus)) {
|
||||
GuideProfile profile = guideProfileMapper.selectByTourismId(commission.getGuideId());
|
||||
if (profile != null && profile.getAvailableCommission() >= commission.getCommissionAmount()) {
|
||||
guideProfileMapper.addAvailableCommission(profile.getId(), -commission.getCommissionAmount());
|
||||
}
|
||||
}
|
||||
|
||||
log.info("佣金已退款: orderNo={}, commissionId={}", orderNo, commission.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成佣金单号
|
||||
*/
|
||||
private String generateCommissionNo() {
|
||||
String dateStr = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
|
||||
int seq = COMMISSION_NO_COUNTER.incrementAndGet() % 1000000;
|
||||
return String.format("CM%s%06d", dateStr, seq);
|
||||
}
|
||||
}
|
||||
+207
@@ -0,0 +1,207 @@
|
||||
package com.central.order.service.guide.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.order.enums.guide.GuideStatusEnum;
|
||||
import com.central.order.enums.guide.TourismTypeEnum;
|
||||
import com.central.order.mapper.TourismMapper;
|
||||
import com.central.order.mapper.guide.GuideProfileMapper;
|
||||
import com.central.order.model.Tourism;
|
||||
import com.central.order.model.dto.guide.GuideAuditDTO;
|
||||
import com.central.order.model.dto.guide.GuideCreateDTO;
|
||||
import com.central.order.model.guide.GuideProfile;
|
||||
import com.central.order.model.vo.guide.GuideInfoVO;
|
||||
import com.central.order.service.guide.IGuideService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* 导游服务实现
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class GuideServiceImpl implements IGuideService {
|
||||
|
||||
private final TourismMapper tourismMapper;
|
||||
private final GuideProfileMapper guideProfileMapper;
|
||||
|
||||
private static final AtomicInteger GUIDE_NO_COUNTER = new AtomicInteger(0);
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long createGuide(GuideCreateDTO dto) {
|
||||
// 1. 在tourisms表创建导游记录
|
||||
Tourism guide = new Tourism();
|
||||
guide.setTourismName(dto.getName());
|
||||
guide.setTourismType(TourismTypeEnum.GUIDE.getId());
|
||||
guide.setTenantId(dto.getTenantId());
|
||||
guide.setTourismPhone(dto.getPhone());
|
||||
guide.setStatus(GuideStatusEnum.PENDING.getId());
|
||||
guide.setIsDel(0);
|
||||
tourismMapper.insert(guide);
|
||||
|
||||
// 2. 创建导游扩展信息
|
||||
GuideProfile profile = new GuideProfile();
|
||||
profile.setTourismId(guide.getId());
|
||||
profile.setUserId(dto.getUserId());
|
||||
profile.setGuideNo(generateGuideNo());
|
||||
profile.setIdCard(dto.getIdCard());
|
||||
profile.setOpenid(dto.getOpenid());
|
||||
profile.setBankAccount(dto.getBankAccount());
|
||||
profile.setBankName(dto.getBankName());
|
||||
profile.setCommissionRate(dto.getCommissionRate() != null ?
|
||||
dto.getCommissionRate() : new BigDecimal("10.00"));
|
||||
profile.setStatus(GuideStatusEnum.PENDING.getId());
|
||||
profile.setTotalCommission(0L);
|
||||
profile.setAvailableCommission(0L);
|
||||
profile.setFrozenCommission(0L);
|
||||
profile.setWithdrawnCommission(0L);
|
||||
profile.setTenantId(dto.getTenantId());
|
||||
guideProfileMapper.insert(profile);
|
||||
|
||||
log.info("创建导游成功: guideId={}, guideNo={}", guide.getId(), profile.getGuideNo());
|
||||
return guide.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuideInfoVO getGuideInfo(Long guideId) {
|
||||
GuideProfile profile = guideProfileMapper.selectByTourismId(guideId);
|
||||
if (profile == null) {
|
||||
return null;
|
||||
}
|
||||
return buildGuideInfoVO(profile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuideInfoVO getGuideInfoByUserId(Long userId) {
|
||||
GuideProfile profile = guideProfileMapper.selectByUserId(userId);
|
||||
if (profile == null) {
|
||||
return null;
|
||||
}
|
||||
return buildGuideInfoVO(profile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuideProfile getGuideProfile(Long guideId) {
|
||||
return guideProfileMapper.selectByTourismId(guideId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<GuideProfile> findList(Map<String, Object> params) {
|
||||
Page<GuideProfile> page = new Page<>(
|
||||
Integer.parseInt(params.getOrDefault("page", "1").toString()),
|
||||
Integer.parseInt(params.getOrDefault("limit", "10").toString())
|
||||
);
|
||||
List<GuideProfile> list = guideProfileMapper.findList(page, params);
|
||||
return PageResult.<GuideProfile>builder()
|
||||
.data(list)
|
||||
.count(page.getTotal())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void auditGuide(Long guideId, GuideAuditDTO dto) {
|
||||
GuideProfile profile = guideProfileMapper.selectByTourismId(guideId);
|
||||
if (profile == null) {
|
||||
throw new RuntimeException("导游不存在");
|
||||
}
|
||||
|
||||
Integer newStatus = dto.getApproved() ?
|
||||
GuideStatusEnum.NORMAL.getId() : GuideStatusEnum.REJECTED.getId();
|
||||
|
||||
// 更新导游扩展信息状态
|
||||
profile.setStatus(newStatus);
|
||||
profile.setAuditRemark(dto.getRemark());
|
||||
profile.setUpdateTime(LocalDateTime.now());
|
||||
guideProfileMapper.updateById(profile);
|
||||
|
||||
// 更新tourisms表状态
|
||||
Tourism tourism = tourismMapper.selectById(guideId);
|
||||
if (tourism != null) {
|
||||
tourism.setStatus(newStatus);
|
||||
tourismMapper.updateById(tourism);
|
||||
}
|
||||
|
||||
log.info("审核导游: guideId={}, approved={}, status={}", guideId, dto.getApproved(), newStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateStatus(Long guideId, Integer status) {
|
||||
GuideProfile profile = guideProfileMapper.selectByTourismId(guideId);
|
||||
if (profile == null) {
|
||||
throw new RuntimeException("导游不存在");
|
||||
}
|
||||
|
||||
profile.setStatus(status);
|
||||
profile.setUpdateTime(LocalDateTime.now());
|
||||
guideProfileMapper.updateById(profile);
|
||||
|
||||
// 同步更新tourisms表状态
|
||||
Tourism tourism = tourismMapper.selectById(guideId);
|
||||
if (tourism != null) {
|
||||
tourism.setStatus(status);
|
||||
tourismMapper.updateById(tourism);
|
||||
}
|
||||
|
||||
log.info("更新导游状态: guideId={}, status={}", guideId, status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCommissionRate(Long guideId, BigDecimal commissionRate) {
|
||||
GuideProfile profile = guideProfileMapper.selectByTourismId(guideId);
|
||||
if (profile == null) {
|
||||
throw new RuntimeException("导游不存在");
|
||||
}
|
||||
|
||||
profile.setCommissionRate(commissionRate);
|
||||
profile.setUpdateTime(LocalDateTime.now());
|
||||
guideProfileMapper.updateById(profile);
|
||||
|
||||
log.info("设置佣金比例: guideId={}, rate={}", guideId, commissionRate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成导游编号
|
||||
*/
|
||||
private String generateGuideNo() {
|
||||
String dateStr = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
|
||||
int seq = GUIDE_NO_COUNTER.incrementAndGet() % 10000;
|
||||
return String.format("G%s%04d", dateStr, seq);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建导游信息VO
|
||||
*/
|
||||
private GuideInfoVO buildGuideInfoVO(GuideProfile profile) {
|
||||
GuideInfoVO vo = new GuideInfoVO();
|
||||
vo.setGuideId(profile.getTourismId());
|
||||
vo.setGuideNo(profile.getGuideNo());
|
||||
vo.setName(profile.getGuideName());
|
||||
vo.setPhone(profile.getGuidePhone());
|
||||
vo.setStatus(profile.getStatus());
|
||||
vo.setStatusDesc(GuideStatusEnum.getById(profile.getStatus()) != null ?
|
||||
GuideStatusEnum.getById(profile.getStatus()).getContent() : "未知");
|
||||
vo.setCommissionRate(profile.getCommissionRate());
|
||||
vo.setTotalCommission(profile.getTotalCommission());
|
||||
vo.setAvailableCommission(profile.getAvailableCommission());
|
||||
vo.setTenantId(profile.getTenantId());
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
+247
@@ -0,0 +1,247 @@
|
||||
package com.central.order.service.guide.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.order.enums.guide.GuideStatusEnum;
|
||||
import com.central.order.enums.guide.WithdrawalStatusEnum;
|
||||
import com.central.order.mapper.guide.GuideProfileMapper;
|
||||
import com.central.order.mapper.guide.GuideWithdrawalMapper;
|
||||
import com.central.order.model.dto.guide.WithdrawalApplyDTO;
|
||||
import com.central.order.model.dto.guide.WithdrawalAuditDTO;
|
||||
import com.central.order.model.guide.GuideProfile;
|
||||
import com.central.order.model.guide.GuideWithdrawal;
|
||||
import com.central.order.service.guide.IGuideWithdrawalService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* 导游提现服务实现
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class GuideWithdrawalServiceImpl implements IGuideWithdrawalService {
|
||||
|
||||
private final GuideProfileMapper guideProfileMapper;
|
||||
private final GuideWithdrawalMapper guideWithdrawalMapper;
|
||||
|
||||
private static final AtomicInteger WITHDRAW_NO_COUNTER = new AtomicInteger(0);
|
||||
|
||||
@Value("${guide.withdrawal.min-amount:10000}")
|
||||
private Long minWithdrawAmount;
|
||||
|
||||
@Value("${guide.withdrawal.max-amount:500000}")
|
||||
private Long maxWithdrawAmount;
|
||||
|
||||
@Value("${guide.withdrawal.max-daily-count:3}")
|
||||
private Integer maxDailyCount;
|
||||
|
||||
@Value("${guide.withdrawal.fee-rate:0}")
|
||||
private Double feeRate;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String applyWithdrawal(Long guideId, WithdrawalApplyDTO dto) {
|
||||
// 1. 查询导游信息
|
||||
GuideProfile profile = guideProfileMapper.selectByTourismId(guideId);
|
||||
if (profile == null) {
|
||||
throw new RuntimeException("导游不存在");
|
||||
}
|
||||
if (!GuideStatusEnum.NORMAL.getId().equals(profile.getStatus())) {
|
||||
throw new RuntimeException("导游状态异常,无法提现");
|
||||
}
|
||||
|
||||
// 2. 校验提现金额
|
||||
Long amount = dto.getAmount();
|
||||
if (amount < minWithdrawAmount) {
|
||||
throw new RuntimeException("提现金额不能低于" + (minWithdrawAmount / 100) + "元");
|
||||
}
|
||||
if (amount > maxWithdrawAmount) {
|
||||
throw new RuntimeException("单次提现金额不能超过" + (maxWithdrawAmount / 100) + "元");
|
||||
}
|
||||
if (amount > profile.getAvailableCommission()) {
|
||||
throw new RuntimeException("可提现余额不足");
|
||||
}
|
||||
|
||||
// 3. 校验每日提现次数
|
||||
Integer todayCount = guideWithdrawalMapper.countTodayWithdrawal(guideId);
|
||||
if (todayCount >= maxDailyCount) {
|
||||
throw new RuntimeException("今日提现次数已达上限");
|
||||
}
|
||||
|
||||
// 4. 冻结提现金额
|
||||
int rows = guideProfileMapper.freezeCommission(profile.getId(), amount);
|
||||
if (rows == 0) {
|
||||
throw new RuntimeException("冻结余额失败,可能余额不足");
|
||||
}
|
||||
|
||||
// 5. 计算手续费
|
||||
Long fee = BigDecimal.valueOf(feeRate)
|
||||
.multiply(BigDecimal.valueOf(amount))
|
||||
.divide(BigDecimal.valueOf(100), 0, RoundingMode.UP)
|
||||
.longValue();
|
||||
Long actualAmount = amount - fee;
|
||||
|
||||
// 6. 创建提现申请
|
||||
GuideWithdrawal withdrawal = new GuideWithdrawal();
|
||||
withdrawal.setWithdrawNo(generateWithdrawNo());
|
||||
withdrawal.setGuideId(guideId);
|
||||
withdrawal.setAmount(amount);
|
||||
withdrawal.setActualAmount(actualAmount);
|
||||
withdrawal.setFee(fee);
|
||||
withdrawal.setWithdrawType(dto.getWithdrawType());
|
||||
withdrawal.setAccountInfo(dto.getAccountInfo());
|
||||
withdrawal.setStatus(WithdrawalStatusEnum.PENDING.getId());
|
||||
withdrawal.setApplyTime(LocalDateTime.now());
|
||||
withdrawal.setTenantId(profile.getTenantId());
|
||||
|
||||
guideWithdrawalMapper.insert(withdrawal);
|
||||
|
||||
log.info("提现申请已提交: guideId={}, withdrawNo={}, amount={}", guideId, withdrawal.getWithdrawNo(), amount);
|
||||
return withdrawal.getWithdrawNo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<GuideWithdrawal> findList(Map<String, Object> params) {
|
||||
Page<GuideWithdrawal> page = new Page<>(
|
||||
Integer.parseInt(params.getOrDefault("page", "1").toString()),
|
||||
Integer.parseInt(params.getOrDefault("limit", "10").toString())
|
||||
);
|
||||
List<GuideWithdrawal> list = guideWithdrawalMapper.findList(page, params);
|
||||
return PageResult.<GuideWithdrawal>builder()
|
||||
.data(list)
|
||||
.count(page.getTotal())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuideWithdrawal getById(Long withdrawalId) {
|
||||
return guideWithdrawalMapper.selectById(withdrawalId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuideWithdrawal getByWithdrawNo(String withdrawNo) {
|
||||
return guideWithdrawalMapper.selectByWithdrawNo(withdrawNo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void auditWithdrawal(Long withdrawalId, WithdrawalAuditDTO dto, Long auditUserId) {
|
||||
GuideWithdrawal withdrawal = guideWithdrawalMapper.selectById(withdrawalId);
|
||||
if (withdrawal == null) {
|
||||
throw new RuntimeException("提现申请不存在");
|
||||
}
|
||||
if (!WithdrawalStatusEnum.PENDING.getId().equals(withdrawal.getStatus())) {
|
||||
throw new RuntimeException("提现申请状态不允许审核");
|
||||
}
|
||||
|
||||
if (dto.getApproved()) {
|
||||
// 审核通过
|
||||
withdrawal.setStatus(WithdrawalStatusEnum.APPROVED.getId());
|
||||
} else {
|
||||
// 审核拒绝,解冻金额
|
||||
withdrawal.setStatus(WithdrawalStatusEnum.REJECTED.getId());
|
||||
GuideProfile profile = guideProfileMapper.selectByTourismId(withdrawal.getGuideId());
|
||||
if (profile != null) {
|
||||
guideProfileMapper.unfreezeCommission(profile.getId(), withdrawal.getAmount());
|
||||
}
|
||||
}
|
||||
|
||||
withdrawal.setAuditUserId(auditUserId);
|
||||
withdrawal.setAuditTime(LocalDateTime.now());
|
||||
withdrawal.setAuditRemark(dto.getRemark());
|
||||
guideWithdrawalMapper.updateById(withdrawal);
|
||||
|
||||
log.info("提现审核完成: withdrawalId={}, approved={}", withdrawalId, dto.getApproved());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void executeTransfer(Long withdrawalId) {
|
||||
GuideWithdrawal withdrawal = guideWithdrawalMapper.selectById(withdrawalId);
|
||||
if (withdrawal == null) {
|
||||
throw new RuntimeException("提现申请不存在");
|
||||
}
|
||||
if (!WithdrawalStatusEnum.APPROVED.getId().equals(withdrawal.getStatus())) {
|
||||
throw new RuntimeException("提现申请状态不允许打款");
|
||||
}
|
||||
|
||||
// 更新状态为打款中
|
||||
withdrawal.setStatus(WithdrawalStatusEnum.TRANSFERRING.getId());
|
||||
guideWithdrawalMapper.updateById(withdrawal);
|
||||
|
||||
// TODO: 调用微信企业付款API或银行转账API
|
||||
// 这里需要根据实际情况对接支付接口
|
||||
|
||||
log.info("开始执行打款: withdrawalId={}, amount={}", withdrawalId, withdrawal.getActualAmount());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void confirmTransfer(Long withdrawalId, String transferNo) {
|
||||
GuideWithdrawal withdrawal = guideWithdrawalMapper.selectById(withdrawalId);
|
||||
if (withdrawal == null) {
|
||||
throw new RuntimeException("提现申请不存在");
|
||||
}
|
||||
|
||||
// 更新状态为已到账
|
||||
withdrawal.setStatus(WithdrawalStatusEnum.COMPLETED.getId());
|
||||
withdrawal.setTransferTime(LocalDateTime.now());
|
||||
withdrawal.setTransferNo(transferNo);
|
||||
guideWithdrawalMapper.updateById(withdrawal);
|
||||
|
||||
// 完成提现:从冻结转到已提现
|
||||
GuideProfile profile = guideProfileMapper.selectByTourismId(withdrawal.getGuideId());
|
||||
if (profile != null) {
|
||||
guideProfileMapper.completeWithdrawal(profile.getId(), withdrawal.getAmount());
|
||||
}
|
||||
|
||||
log.info("打款完成: withdrawalId={}, transferNo={}", withdrawalId, transferNo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void transferFailed(Long withdrawalId, String failReason) {
|
||||
GuideWithdrawal withdrawal = guideWithdrawalMapper.selectById(withdrawalId);
|
||||
if (withdrawal == null) {
|
||||
throw new RuntimeException("提现申请不存在");
|
||||
}
|
||||
|
||||
// 更新状态为打款失败
|
||||
withdrawal.setStatus(WithdrawalStatusEnum.FAILED.getId());
|
||||
withdrawal.setFailReason(failReason);
|
||||
guideWithdrawalMapper.updateById(withdrawal);
|
||||
|
||||
// 解冻金额
|
||||
GuideProfile profile = guideProfileMapper.selectByTourismId(withdrawal.getGuideId());
|
||||
if (profile != null) {
|
||||
guideProfileMapper.unfreezeCommission(profile.getId(), withdrawal.getAmount());
|
||||
}
|
||||
|
||||
log.info("打款失败: withdrawalId={}, reason={}", withdrawalId, failReason);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成提现单号
|
||||
*/
|
||||
private String generateWithdrawNo() {
|
||||
String dateStr = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
|
||||
int seq = WITHDRAW_NO_COUNTER.incrementAndGet() % 100000;
|
||||
return String.format("W%s%05d", dateStr, seq);
|
||||
}
|
||||
}
|
||||
+19
@@ -134,5 +134,24 @@ public class TourismFileServiceImpl extends SuperServiceImpl<TourismFileMapper,
|
||||
|
||||
return PageResult.<TourismFileGroupVO>builder().data(result).resp_code(0).count(total).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TourismFile> findByIds(List<Long> ids) {
|
||||
if (ids == null || ids.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<TourismFile> files = baseMapper.findByIds(ids);
|
||||
// 转换图片URL
|
||||
if (files != null) {
|
||||
for (TourismFile f : files) {
|
||||
if (f != null && f.getImageUrl() != null) {
|
||||
try {
|
||||
f.setImageUrl(fileCenterService.getViewUrlByPath(f.getImageUrl()));
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
return files == null ? Collections.emptyList() : files;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,5 +37,16 @@
|
||||
</where>
|
||||
ORDER BY id DESC
|
||||
</select>
|
||||
|
||||
<!-- 根据素材ID列表查询 -->
|
||||
<select id="findByIds" resultType="com.central.order.model.TourismFile">
|
||||
SELECT * FROM tourisms_files
|
||||
WHERE id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
AND (is_del = 0 OR is_del IS NULL)
|
||||
ORDER BY id DESC
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.central.order.mapper.guide.GuideCommissionMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.central.order.model.guide.GuideCommission">
|
||||
<id column="id" property="id"/>
|
||||
<result column="commission_no" property="commissionNo"/>
|
||||
<result column="guide_id" property="guideId"/>
|
||||
<result column="order_no" property="orderNo"/>
|
||||
<result column="order_amount" property="orderAmount"/>
|
||||
<result column="commission_rate" property="commissionRate"/>
|
||||
<result column="commission_amount" property="commissionAmount"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="settle_time" property="settleTime"/>
|
||||
<result column="remark" property="remark"/>
|
||||
<result column="tenant_id" property="tenantId"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<result column="guide_name" property="guideName"/>
|
||||
<result column="guide_no" property="guideNo"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectByOrderNo" resultMap="BaseResultMap">
|
||||
SELECT gc.*, t.tourism_name as guide_name, gp.guide_no
|
||||
FROM guide_commissions gc
|
||||
LEFT JOIN tourisms t ON gc.guide_id = t.id
|
||||
LEFT JOIN guide_profiles gp ON gc.guide_id = gp.tourism_id
|
||||
WHERE gc.order_no = #{orderNo}
|
||||
</select>
|
||||
|
||||
<select id="selectByCommissionNo" resultMap="BaseResultMap">
|
||||
SELECT gc.*, t.tourism_name as guide_name, gp.guide_no
|
||||
FROM guide_commissions gc
|
||||
LEFT JOIN tourisms t ON gc.guide_id = t.id
|
||||
LEFT JOIN guide_profiles gp ON gc.guide_id = gp.tourism_id
|
||||
WHERE gc.commission_no = #{commissionNo}
|
||||
</select>
|
||||
|
||||
<select id="findList" resultMap="BaseResultMap">
|
||||
SELECT gc.*, t.tourism_name as guide_name, gp.guide_no
|
||||
FROM guide_commissions gc
|
||||
LEFT JOIN tourisms t ON gc.guide_id = t.id
|
||||
LEFT JOIN guide_profiles gp ON gc.guide_id = gp.tourism_id
|
||||
<where>
|
||||
<if test="p.tenantIds != null and p.tenantIds.size > 0">
|
||||
AND gc.tenant_id IN
|
||||
<foreach collection="p.tenantIds" item="tid" open="(" separator="," close=")">
|
||||
#{tid}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="(p.tenantIds == null or p.tenantIds.size == 0) and p.tenantId != null and p.tenantId != ''">
|
||||
AND gc.tenant_id = #{p.tenantId}
|
||||
</if>
|
||||
<if test="p.guideId != null">
|
||||
AND gc.guide_id = #{p.guideId}
|
||||
</if>
|
||||
<if test="p.status != null">
|
||||
AND gc.status = #{p.status}
|
||||
</if>
|
||||
<if test="p.orderNo != null and p.orderNo != ''">
|
||||
AND gc.order_no = #{p.orderNo}
|
||||
</if>
|
||||
<if test="p.commissionNo != null and p.commissionNo != ''">
|
||||
AND gc.commission_no = #{p.commissionNo}
|
||||
</if>
|
||||
<if test="p.startTime != null">
|
||||
AND gc.create_time >= #{p.startTime}
|
||||
</if>
|
||||
<if test="p.endTime != null">
|
||||
AND gc.create_time <= #{p.endTime}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY gc.id DESC
|
||||
</select>
|
||||
|
||||
<select id="selectPendingSettleList" resultMap="BaseResultMap">
|
||||
SELECT gc.*, t.tourism_name as guide_name, gp.guide_no
|
||||
FROM guide_commissions gc
|
||||
LEFT JOIN tourisms t ON gc.guide_id = t.id
|
||||
LEFT JOIN guide_profiles gp ON gc.guide_id = gp.tourism_id
|
||||
WHERE gc.status = 0
|
||||
AND gc.create_time <= #{beforeTime}
|
||||
ORDER BY gc.create_time ASC
|
||||
<if test="limit != null and limit > 0">
|
||||
LIMIT #{limit}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="sumTodayCommission" resultType="java.lang.Long">
|
||||
SELECT IFNULL(SUM(commission_amount), 0)
|
||||
FROM guide_commissions
|
||||
WHERE guide_id = #{guideId}
|
||||
AND DATE(create_time) = CURDATE()
|
||||
</select>
|
||||
|
||||
<select id="sumMonthCommission" resultType="java.lang.Long">
|
||||
SELECT IFNULL(SUM(commission_amount), 0)
|
||||
FROM guide_commissions
|
||||
WHERE guide_id = #{guideId}
|
||||
AND YEAR(create_time) = YEAR(CURDATE())
|
||||
AND MONTH(create_time) = MONTH(CURDATE())
|
||||
</select>
|
||||
|
||||
<select id="countPendingSettle" resultType="java.lang.Integer">
|
||||
SELECT COUNT(*)
|
||||
FROM guide_commissions
|
||||
WHERE guide_id = #{guideId}
|
||||
AND status = 0
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.central.order.mapper.guide.GuideProfileMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.central.order.model.guide.GuideProfile">
|
||||
<id column="id" property="id"/>
|
||||
<result column="tourism_id" property="tourismId"/>
|
||||
<result column="user_id" property="userId"/>
|
||||
<result column="guide_no" property="guideNo"/>
|
||||
<result column="id_card" property="idCard"/>
|
||||
<result column="openid" property="openid"/>
|
||||
<result column="bank_account" property="bankAccount"/>
|
||||
<result column="bank_name" property="bankName"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="audit_remark" property="auditRemark"/>
|
||||
<result column="commission_rate" property="commissionRate"/>
|
||||
<result column="total_commission" property="totalCommission"/>
|
||||
<result column="available_commission" property="availableCommission"/>
|
||||
<result column="frozen_commission" property="frozenCommission"/>
|
||||
<result column="withdrawn_commission" property="withdrawnCommission"/>
|
||||
<result column="tenant_id" property="tenantId"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<result column="guide_name" property="guideName"/>
|
||||
<result column="guide_phone" property="guidePhone"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectByTourismId" resultMap="BaseResultMap">
|
||||
SELECT gp.*, t.tourism_name as guide_name, t.tourism_phone as guide_phone
|
||||
FROM guide_profiles gp
|
||||
LEFT JOIN tourisms t ON gp.tourism_id = t.id
|
||||
WHERE gp.tourism_id = #{tourismId}
|
||||
</select>
|
||||
|
||||
<select id="selectByUserId" resultMap="BaseResultMap">
|
||||
SELECT gp.*, t.tourism_name as guide_name, t.tourism_phone as guide_phone
|
||||
FROM guide_profiles gp
|
||||
LEFT JOIN tourisms t ON gp.tourism_id = t.id
|
||||
WHERE gp.user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<select id="selectByGuideNo" resultMap="BaseResultMap">
|
||||
SELECT gp.*, t.tourism_name as guide_name, t.tourism_phone as guide_phone
|
||||
FROM guide_profiles gp
|
||||
LEFT JOIN tourisms t ON gp.tourism_id = t.id
|
||||
WHERE gp.guide_no = #{guideNo}
|
||||
</select>
|
||||
|
||||
<select id="findList" resultMap="BaseResultMap">
|
||||
SELECT gp.*, t.tourism_name as guide_name, t.tourism_phone as guide_phone
|
||||
FROM guide_profiles gp
|
||||
LEFT JOIN tourisms t ON gp.tourism_id = t.id
|
||||
WHERE t.tourism_type = 2
|
||||
<if test="p.tenantIds != null and p.tenantIds.size > 0">
|
||||
AND gp.tenant_id IN
|
||||
<foreach collection="p.tenantIds" item="tid" open="(" separator="," close=")">
|
||||
#{tid}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="(p.tenantIds == null or p.tenantIds.size == 0) and p.tenantId != null and p.tenantId != ''">
|
||||
AND gp.tenant_id = #{p.tenantId}
|
||||
</if>
|
||||
<if test="p.guideName != null and p.guideName != ''">
|
||||
AND t.tourism_name LIKE CONCAT('%', #{p.guideName}, '%')
|
||||
</if>
|
||||
<if test="p.guideNo != null and p.guideNo != ''">
|
||||
AND gp.guide_no = #{p.guideNo}
|
||||
</if>
|
||||
<if test="p.status != null">
|
||||
AND gp.status = #{p.status}
|
||||
</if>
|
||||
<if test="p.phone != null and p.phone != ''">
|
||||
AND t.tourism_phone = #{p.phone}
|
||||
</if>
|
||||
ORDER BY gp.id DESC
|
||||
</select>
|
||||
|
||||
<update id="addTotalCommission">
|
||||
UPDATE guide_profiles
|
||||
SET total_commission = total_commission + #{amount},
|
||||
update_time = NOW()
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="addAvailableCommission">
|
||||
UPDATE guide_profiles
|
||||
SET available_commission = available_commission + #{amount},
|
||||
update_time = NOW()
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="freezeCommission">
|
||||
UPDATE guide_profiles
|
||||
SET available_commission = available_commission - #{amount},
|
||||
frozen_commission = frozen_commission + #{amount},
|
||||
update_time = NOW()
|
||||
WHERE id = #{id}
|
||||
AND available_commission >= #{amount}
|
||||
</update>
|
||||
|
||||
<update id="unfreezeCommission">
|
||||
UPDATE guide_profiles
|
||||
SET available_commission = available_commission + #{amount},
|
||||
frozen_commission = frozen_commission - #{amount},
|
||||
update_time = NOW()
|
||||
WHERE id = #{id}
|
||||
AND frozen_commission >= #{amount}
|
||||
</update>
|
||||
|
||||
<update id="completeWithdrawal">
|
||||
UPDATE guide_profiles
|
||||
SET frozen_commission = frozen_commission - #{amount},
|
||||
withdrawn_commission = withdrawn_commission + #{amount},
|
||||
update_time = NOW()
|
||||
WHERE id = #{id}
|
||||
AND frozen_commission >= #{amount}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,93 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.central.order.mapper.guide.GuideWithdrawalMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.central.order.model.guide.GuideWithdrawal">
|
||||
<id column="id" property="id"/>
|
||||
<result column="withdraw_no" property="withdrawNo"/>
|
||||
<result column="guide_id" property="guideId"/>
|
||||
<result column="amount" property="amount"/>
|
||||
<result column="actual_amount" property="actualAmount"/>
|
||||
<result column="fee" property="fee"/>
|
||||
<result column="withdraw_type" property="withdrawType"/>
|
||||
<result column="account_info" property="accountInfo"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="apply_time" property="applyTime"/>
|
||||
<result column="audit_user_id" property="auditUserId"/>
|
||||
<result column="audit_time" property="auditTime"/>
|
||||
<result column="audit_remark" property="auditRemark"/>
|
||||
<result column="transfer_time" property="transferTime"/>
|
||||
<result column="transfer_no" property="transferNo"/>
|
||||
<result column="fail_reason" property="failReason"/>
|
||||
<result column="tenant_id" property="tenantId"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<result column="guide_name" property="guideName"/>
|
||||
<result column="guide_no" property="guideNo"/>
|
||||
<result column="guide_phone" property="guidePhone"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectByWithdrawNo" resultMap="BaseResultMap">
|
||||
SELECT gw.*, t.tourism_name as guide_name, t.tourism_phone as guide_phone, gp.guide_no
|
||||
FROM guide_withdrawals gw
|
||||
LEFT JOIN tourisms t ON gw.guide_id = t.id
|
||||
LEFT JOIN guide_profiles gp ON gw.guide_id = gp.tourism_id
|
||||
WHERE gw.withdraw_no = #{withdrawNo}
|
||||
</select>
|
||||
|
||||
<select id="findList" resultMap="BaseResultMap">
|
||||
SELECT gw.*, t.tourism_name as guide_name, t.tourism_phone as guide_phone, gp.guide_no
|
||||
FROM guide_withdrawals gw
|
||||
LEFT JOIN tourisms t ON gw.guide_id = t.id
|
||||
LEFT JOIN guide_profiles gp ON gw.guide_id = gp.tourism_id
|
||||
<where>
|
||||
<if test="p.tenantIds != null and p.tenantIds.size > 0">
|
||||
AND gw.tenant_id IN
|
||||
<foreach collection="p.tenantIds" item="tid" open="(" separator="," close=")">
|
||||
#{tid}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="(p.tenantIds == null or p.tenantIds.size == 0) and p.tenantId != null and p.tenantId != ''">
|
||||
AND gw.tenant_id = #{p.tenantId}
|
||||
</if>
|
||||
<if test="p.guideId != null">
|
||||
AND gw.guide_id = #{p.guideId}
|
||||
</if>
|
||||
<if test="p.status != null">
|
||||
AND gw.status = #{p.status}
|
||||
</if>
|
||||
<if test="p.withdrawNo != null and p.withdrawNo != ''">
|
||||
AND gw.withdraw_no = #{p.withdrawNo}
|
||||
</if>
|
||||
<if test="p.startTime != null">
|
||||
AND gw.apply_time >= #{p.startTime}
|
||||
</if>
|
||||
<if test="p.endTime != null">
|
||||
AND gw.apply_time <= #{p.endTime}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY gw.id DESC
|
||||
</select>
|
||||
|
||||
<select id="selectApprovedList" resultMap="BaseResultMap">
|
||||
SELECT gw.*, t.tourism_name as guide_name, t.tourism_phone as guide_phone, gp.guide_no
|
||||
FROM guide_withdrawals gw
|
||||
LEFT JOIN tourisms t ON gw.guide_id = t.id
|
||||
LEFT JOIN guide_profiles gp ON gw.guide_id = gp.tourism_id
|
||||
WHERE gw.status = 1
|
||||
ORDER BY gw.audit_time ASC
|
||||
<if test="limit != null and limit > 0">
|
||||
LIMIT #{limit}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="countTodayWithdrawal" resultType="java.lang.Integer">
|
||||
SELECT COUNT(*)
|
||||
FROM guide_withdrawals
|
||||
WHERE guide_id = #{guideId}
|
||||
AND DATE(apply_time) = CURDATE()
|
||||
AND status NOT IN (2, 5)
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user