feat(shop): 完善分销商提现功能
- 新增昵称、头像、手机号、真实姓名字段并支持关联查询 - 修改审核时间为LocalDateTime类型并格式化输出 - 添加上传支付凭证和备注字段 - 提现申请时扣除对应金额 - 驳回提现时退还金额- 已打款状态需上传凭证并记录审核时间 - 支持根据用户ID搜索提现记录- 优化事务
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.shop.entity.ShopDealerUser;
|
||||
import com.gxwebsoft.shop.service.ShopDealerUserService;
|
||||
import com.gxwebsoft.shop.service.ShopDealerWithdrawService;
|
||||
import com.gxwebsoft.shop.entity.ShopDealerWithdraw;
|
||||
import com.gxwebsoft.shop.param.ShopDealerWithdrawParam;
|
||||
@@ -13,9 +16,12 @@ import com.gxwebsoft.common.system.entity.User;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -30,6 +36,8 @@ import java.util.List;
|
||||
public class ShopDealerWithdrawController extends BaseController {
|
||||
@Resource
|
||||
private ShopDealerWithdrawService shopDealerWithdrawService;
|
||||
@Resource
|
||||
private ShopDealerUserService shopDealerUserService;
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:shopDealerWithdraw:list')")
|
||||
@Operation(summary = "分页查询分销商提现明细表")
|
||||
@@ -57,6 +65,7 @@ public class ShopDealerWithdrawController extends BaseController {
|
||||
|
||||
@PreAuthorize("hasAuthority('shop:shopDealerWithdraw:save')")
|
||||
@OperationLog
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
@Operation(summary = "添加分销商提现明细表")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody ShopDealerWithdraw shopDealerWithdraw) {
|
||||
@@ -64,10 +73,14 @@ public class ShopDealerWithdrawController extends BaseController {
|
||||
User loginUser = getLoginUser();
|
||||
if (loginUser != null) {
|
||||
shopDealerWithdraw.setUserId(loginUser.getUserId());
|
||||
}
|
||||
final ShopDealerUser dealerUser = shopDealerUserService.getByUserIdRel(loginUser.getUserId());
|
||||
// 扣除提现金额
|
||||
dealerUser.setMoney(dealerUser.getMoney().subtract(shopDealerWithdraw.getMoney()));
|
||||
shopDealerUserService.updateById(dealerUser);
|
||||
if (shopDealerWithdrawService.save(shopDealerWithdraw)) {
|
||||
return success("添加成功");
|
||||
}
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@@ -76,6 +89,19 @@ public class ShopDealerWithdrawController extends BaseController {
|
||||
@Operation(summary = "修改分销商提现明细表")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody ShopDealerWithdraw shopDealerWithdraw) {
|
||||
// 驳回操作,退回金额
|
||||
if(shopDealerWithdraw.getApplyStatus().equals(30)){
|
||||
final ShopDealerUser dealerUser = shopDealerUserService.getByUserIdRel(shopDealerWithdraw.getUserId());
|
||||
dealerUser.setMoney(dealerUser.getMoney().add(shopDealerWithdraw.getMoney()));
|
||||
shopDealerUserService.updateById(dealerUser);
|
||||
}
|
||||
// 已打款,要求上传凭证
|
||||
if(shopDealerWithdraw.getApplyStatus().equals(40)){
|
||||
shopDealerWithdraw.setAuditTime(LocalDateTime.now());
|
||||
if(StrUtil.isBlankIfStr(shopDealerWithdraw.getImage())){
|
||||
return fail("请上传打款凭证");
|
||||
}
|
||||
}
|
||||
if (shopDealerWithdrawService.updateById(shopDealerWithdraw)) {
|
||||
return success("修改成功");
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.gxwebsoft.shop.entity;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import java.time.LocalDateTime;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
@@ -29,6 +30,22 @@ public class ShopDealerWithdraw implements Serializable {
|
||||
@Schema(description = "分销商用户ID")
|
||||
private Integer userId;
|
||||
|
||||
@Schema(description = "昵称")
|
||||
@TableField(exist = false)
|
||||
private String nickName;
|
||||
|
||||
@Schema(description = "头像")
|
||||
@TableField(exist = false)
|
||||
private String avatar;
|
||||
|
||||
@Schema(description = "手机号")
|
||||
@TableField(exist = false)
|
||||
private String phone;
|
||||
|
||||
@Schema(description = "真实姓名")
|
||||
@TableField(exist = false)
|
||||
private String realName;
|
||||
|
||||
@Schema(description = "提现金额")
|
||||
private BigDecimal money;
|
||||
|
||||
@@ -54,11 +71,18 @@ public class ShopDealerWithdraw implements Serializable {
|
||||
private Integer applyStatus;
|
||||
|
||||
@Schema(description = "审核时间")
|
||||
private Integer auditTime;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime auditTime;
|
||||
|
||||
@Schema(description = "驳回原因")
|
||||
private String rejectReason;
|
||||
|
||||
@Schema(description = "上传支付凭证")
|
||||
private String image;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String comments;
|
||||
|
||||
@Schema(description = "来源客户端(APP、H5、小程序等)")
|
||||
private String platform;
|
||||
|
||||
|
||||
@@ -4,8 +4,10 @@
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*
|
||||
SELECT a.*, b.nickname, b.phone AS phone, b.avatar, c.real_name as realName
|
||||
FROM shop_dealer_withdraw a
|
||||
LEFT JOIN gxwebsoft_core.sys_user b ON a.user_id = b.user_id
|
||||
LEFT JOIN gxwebsoft_core.sys_user_verify c ON a.user_id = c.user_id AND c.status = 1
|
||||
<where>
|
||||
<if test="param.id != null">
|
||||
AND a.id = #{param.id}
|
||||
@@ -54,6 +56,7 @@
|
||||
</if>
|
||||
<if test="param.keywords != null">
|
||||
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
OR a.user_id = #{param.keywords}
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
|
||||
@@ -59,7 +59,7 @@ public class ShopDealerWithdrawParam extends BaseParam {
|
||||
|
||||
@Schema(description = "审核时间")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer auditTime;
|
||||
private String auditTime;
|
||||
|
||||
@Schema(description = "驳回原因")
|
||||
private String rejectReason;
|
||||
@@ -67,4 +67,10 @@ public class ShopDealerWithdrawParam extends BaseParam {
|
||||
@Schema(description = "来源客户端(APP、H5、小程序等)")
|
||||
private String platform;
|
||||
|
||||
@Schema(description = "备注")
|
||||
private String comments;
|
||||
|
||||
@Schema(description = "上传支付凭证")
|
||||
private String image;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user