陶杰
2024-10-22 61299cec43f35a9a8fd6d6a9840fdc44f1c24e9b
1.供应商-钱包查询接口
2.供应商-提现接口
已修改12个文件
已添加2个文件
317 ■■■■■ 文件已修改
src/main/java/com/mzl/flower/constant/Constants.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mzl/flower/dto/request/wallet/CreateWalletBillRecordDTO.java 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mzl/flower/dto/request/wallet/CreateWalletWithdrawRecordDTO.java 76 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mzl/flower/entity/wallet/WalletWithdrawRecordDO.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mzl/flower/service/impl/wallet/WalletBillRecordServiceImpl.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mzl/flower/service/impl/wallet/WalletServiceImpl.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mzl/flower/service/impl/wallet/WalletWithdrawRecordServiceImpl.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mzl/flower/service/supplier/SupplierService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mzl/flower/service/wallet/WalletBillRecordService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mzl/flower/service/wallet/WalletService.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mzl/flower/service/wallet/WalletWithdrawRecordService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mzl/flower/web/v2/wallet/WalletBillRecordController.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mzl/flower/web/v2/wallet/WalletController.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mzl/flower/web/v2/wallet/WalletWithdrawRecordController.java 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mzl/flower/constant/Constants.java
@@ -603,4 +603,32 @@
        }
    }
    public enum WALLET_WITHDRAW_STATE {
        WAITING("待审核"), APPROVE("已通过"),REJECT("已拒绝");
        WALLET_WITHDRAW_STATE(String desc) {
            this.desc = desc;
        }
        private String desc;
        public String getDesc() {
            return desc;
        }
    }
    public enum WALLET_WITHDRAW_METHOD {
        WEIXIN("微信");
        WALLET_WITHDRAW_METHOD(String desc) {
            this.desc = desc;
        }
        private String desc;
        public String getDesc() {
            return desc;
        }
    }
}
src/main/java/com/mzl/flower/dto/request/wallet/CreateWalletBillRecordDTO.java
对比新文件
@@ -0,0 +1,52 @@
package com.mzl.flower.dto.request.wallet;
import com.mzl.flower.entity.wallet.WalletBillRecordDO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
@Data
public class CreateWalletBillRecordDTO {
    @ApiModelProperty(value = "供应商Id")
    @NotEmpty(message = "供应商Id不能为空")
    private String supplierId;
    @ApiModelProperty(value = "钱包Id")
    @NotNull(message = "钱包Id不能为空")
    private Long walletId;
    @ApiModelProperty(value = "账单变动类型(提现,结算)")
    @NotEmpty(message = "账单变动类型不能为空")
    private String type;
    @ApiModelProperty(value = "类型明细")
    @NotEmpty(message = "类型明细不能为空")
    private String typeDetail;
//    @ApiModelProperty(value = "转账Id")
//    @NotEmpty(message = "转账Id不能为空")
//    private String transferId;
//    @ApiModelProperty(value = "变动方式(增加、减少)")
//    @NotEmpty(message = "变动方式(增加、减少)不能为空")
//    private String method;
    @ApiModelProperty(value = "原金额")
    @NotNull(message = "原金额")
    @DecimalMin(value = "0.0", message = "原金额不能小于0")
    private BigDecimal originalAmount;
    @ApiModelProperty(value = "变动金额")
    @DecimalMin(value = "0.0", message = "变动金额不能小于0")
    private BigDecimal changeAmount;
    @ApiModelProperty(value = "余额")
    @DecimalMin(value = "0.0", message = "余额不能小于0")
    private BigDecimal balance;
}
src/main/java/com/mzl/flower/dto/request/wallet/CreateWalletWithdrawRecordDTO.java
对比新文件
@@ -0,0 +1,76 @@
package com.mzl.flower.dto.request.wallet;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.DecimalMin;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
 * @description:  提现记录创建请求
 *
 */
@Data
public class CreateWalletWithdrawRecordDTO {
//    /**
//     * 供应商ID
//     */
//    @ApiModelProperty(value = "供应商Id")
//    private String supplierId;
    /**
     * 提现金额
     */
    @ApiModelProperty(value = "钱包Id")
    @NotNull(message = "提现金额不能为空")
    @DecimalMin(value = "0.0", message = "提现金额不能小于0")
    private BigDecimal amount;
    /**
     * 单次可提现金额
     */
//    @ApiModelProperty(value = "提现金额")
//    private BigDecimal onceWithdrawAmount;
//    /**
//     * 提现状态
//     */
//    @ApiModelProperty(value = "提现状态(提现中、提现成功、提现失败)")
//    private Integer withdrawState;
//
//    /**
//     * 提现方式
//     */
//    @ApiModelProperty(value = "提现方式(微信)")
//    private String method;
//
//    /**
//     * 审核人
//     */
//    @ApiModelProperty(value = "审核人")
//    private String approveBy;
//
//    /**
//     * 审核时间
//     */
//    @ApiModelProperty(value = "审核时间")
//    private LocalDateTime approveTime;
//
//    /**
//     * 审核状态
//     */
//    @ApiModelProperty(value = "审核状态(待审核、审核通过、审核不通过)")
//    private Integer approveState;
//
//    /**
//     * 不通过原因
//     */
//    @ApiModelProperty(value = "不通过原因")
//    private String rejectReason;
}
src/main/java/com/mzl/flower/entity/wallet/WalletWithdrawRecordDO.java
@@ -43,7 +43,7 @@
     * 提现状态
     */
    @ApiModelProperty(value = "提现状态(提现中、提现成功、提现失败)")
    private Integer withdrawState;
    private String withdrawState;
    /**
     * 提现方式
src/main/java/com/mzl/flower/service/impl/wallet/WalletBillRecordServiceImpl.java
@@ -1,9 +1,18 @@
package com.mzl.flower.service.impl.wallet;
import com.mzl.flower.config.exception.ValidationException;
import com.mzl.flower.config.security.SecurityUtils;
import com.mzl.flower.constant.Constants;
import com.mzl.flower.dto.request.wallet.CreateWalletBillRecordDTO;
import com.mzl.flower.dto.response.supplier.SupplierDTO;
import com.mzl.flower.entity.wallet.WalletBillRecordDO;
import com.mzl.flower.entity.wallet.WalletDO;
import com.mzl.flower.mapper.wallet.WalletBillRecordMapper;
import com.mzl.flower.service.supplier.SupplierService;
import com.mzl.flower.service.wallet.WalletBillRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mzl.flower.service.wallet.WalletService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
@@ -17,4 +26,10 @@
@Service
public class WalletBillRecordServiceImpl extends ServiceImpl<WalletBillRecordMapper, WalletBillRecordDO> implements WalletBillRecordService {
    @Override
    public void create(CreateWalletBillRecordDTO dto) {
    }
}
src/main/java/com/mzl/flower/service/impl/wallet/WalletServiceImpl.java
@@ -1,6 +1,9 @@
package com.mzl.flower.service.impl.wallet;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.mzl.flower.entity.coupon.CouponTemplateDO;
import com.mzl.flower.entity.wallet.WalletDO;
import com.mzl.flower.enums.TrueOrFalseEnum;
import com.mzl.flower.mapper.wallet.WalletMapper;
import com.mzl.flower.service.wallet.WalletService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -17,4 +20,16 @@
@Service
public class WalletServiceImpl extends ServiceImpl<WalletMapper, WalletDO> implements WalletService {
    @Override
    public WalletDO getBySupplierId(Long supplierId) {
        // 根据供应商ID获取钱包信息
        if (supplierId != null) {
            // 查询的条件的deleted的字段得为0
            return getOne(new LambdaQueryWrapper<WalletDO>()
                    .eq(WalletDO::getDeleted, TrueOrFalseEnum.FALSE.isFlag())
                    .eq(WalletDO::getSupplierId, supplierId));
        }
        return null;
    }
}
src/main/java/com/mzl/flower/service/impl/wallet/WalletWithdrawRecordServiceImpl.java
@@ -1,10 +1,20 @@
package com.mzl.flower.service.impl.wallet;
import com.mzl.flower.config.exception.ValidationException;
import com.mzl.flower.config.security.SecurityUtils;
import com.mzl.flower.constant.Constants;
import com.mzl.flower.dto.request.wallet.CreateWalletWithdrawRecordDTO;
import com.mzl.flower.dto.response.supplier.SupplierDTO;
import com.mzl.flower.entity.wallet.WalletDO;
import com.mzl.flower.entity.wallet.WalletWithdrawRecordDO;
import com.mzl.flower.mapper.wallet.WalletWithdrawRecordMapper;
import com.mzl.flower.service.supplier.SupplierService;
import com.mzl.flower.service.wallet.WalletService;
import com.mzl.flower.service.wallet.WalletWithdrawRecordService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
 * <p>
@@ -16,5 +26,37 @@
 */
@Service
public class WalletWithdrawRecordServiceImpl extends ServiceImpl<WalletWithdrawRecordMapper, WalletWithdrawRecordDO> implements WalletWithdrawRecordService {
    @Autowired
    private WalletService walletService;
    @Autowired
    private SupplierService supplierService;
    @Transactional
    @Override
    public boolean create(CreateWalletWithdrawRecordDTO dto) {
        SupplierDTO supplierDTO=supplierService.getCurrentSupplier();
        if(null==supplierDTO){
            throw new ValidationException("供应商不能为空");
        }
        final WalletDO walletDO = walletService.getBySupplierId(supplierDTO.getId());
        if(null==walletDO){
            throw new ValidationException("钱包不能为空");
        }
        // 查看钱包的金额是不是大于要提现的金额
        if(null!=walletDO.getWithdrawableAmount() && null!=dto.getAmount()
                && walletDO.getWithdrawableAmount().compareTo(dto.getAmount())<0){
            throw new ValidationException("钱包金额不足");
        }
        WalletWithdrawRecordDO withdrawRecordDO=new WalletWithdrawRecordDO();
        withdrawRecordDO.setAmount(dto.getAmount());
        withdrawRecordDO.setSupplierId(supplierDTO.getId());
        withdrawRecordDO.setWithdrawState(Constants.WALLET_WITHDRAW_STATE.WAITING.name());
        withdrawRecordDO.setMethod(Constants.WALLET_WITHDRAW_METHOD.WEIXIN.name());
        withdrawRecordDO.create(SecurityUtils.getUserId());
        return save(withdrawRecordDO);
    }
}
src/main/java/com/mzl/flower/service/supplier/SupplierService.java
@@ -213,4 +213,8 @@
        supplier.update(SecurityUtils.getUserId());
        supplierMapper.updateById(supplier);
    }
    public Supplier getSupplierById(String supplierId) {
        return supplierMapper.selectById(supplierId);
    }
}
src/main/java/com/mzl/flower/service/wallet/WalletBillRecordService.java
@@ -1,5 +1,6 @@
package com.mzl.flower.service.wallet;
import com.mzl.flower.dto.request.wallet.CreateWalletBillRecordDTO;
import com.mzl.flower.entity.wallet.WalletBillRecordDO;
import com.baomidou.mybatisplus.extension.service.IService;
@@ -13,4 +14,5 @@
 */
public interface WalletBillRecordService extends IService<WalletBillRecordDO> {
    void create(CreateWalletBillRecordDTO dto);
}
src/main/java/com/mzl/flower/service/wallet/WalletService.java
@@ -13,4 +13,5 @@
 */
public interface WalletService extends IService<WalletDO> {
    WalletDO getBySupplierId(Long supplierId);
}
src/main/java/com/mzl/flower/service/wallet/WalletWithdrawRecordService.java
@@ -1,5 +1,6 @@
package com.mzl.flower.service.wallet;
import com.mzl.flower.dto.request.wallet.CreateWalletWithdrawRecordDTO;
import com.mzl.flower.entity.wallet.WalletWithdrawRecordDO;
import com.baomidou.mybatisplus.extension.service.IService;
@@ -13,4 +14,5 @@
 */
public interface WalletWithdrawRecordService extends IService<WalletWithdrawRecordDO> {
    boolean create(CreateWalletWithdrawRecordDTO walletWithdrawRecordDTO);
}
src/main/java/com/mzl/flower/web/v2/wallet/WalletBillRecordController.java
@@ -6,22 +6,24 @@
import com.mzl.flower.base.R;
import com.mzl.flower.base.ReturnDataDTO;
import com.mzl.flower.config.exception.ValidationException;
import com.mzl.flower.dto.request.wallet.CreateWalletBillRecordDTO;
import com.mzl.flower.entity.supplier.Supplier;
import com.mzl.flower.entity.wallet.WalletDO;
import com.mzl.flower.mapper.supplier.SupplierMapper;
import com.mzl.flower.service.supplier.SupplierService;
import com.mzl.flower.service.wallet.WalletBillRecordService;
import com.mzl.flower.service.wallet.WalletService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.mzl.flower.entity.wallet.WalletBillRecordDO;
import javax.validation.constraints.Min;
import javax.validation.constraints.Max;
import javax.validation.constraints.Positive;
import org.springframework.web.bind.annotation.RestController;
/**
* @author @TaoJie
@@ -31,8 +33,14 @@
@RequestMapping("/v2/wallet-bill-record")
public class WalletBillRecordController extends BaseController {
    @Autowired
    private WalletBillRecordService walletBillRecordService;
    @PostMapping("")
    public ResponseEntity<ReturnDataDTO> create() {
    public ResponseEntity<ReturnDataDTO> create(@Validated @RequestBody CreateWalletBillRecordDTO dto) {
        return returnData(R.SUCCESS.getCode(), null);
    }
src/main/java/com/mzl/flower/web/v2/wallet/WalletController.java
@@ -5,9 +5,13 @@
import com.mzl.flower.base.BaseController;
import com.mzl.flower.base.R;
import com.mzl.flower.base.ReturnDataDTO;
import com.mzl.flower.config.exception.ValidationException;
import com.mzl.flower.dto.request.wallet.QueryWalletDTO;
import com.mzl.flower.dto.response.supplier.SupplierDTO;
import com.mzl.flower.entity.wallet.WalletBillRecordDO;
import com.mzl.flower.service.supplier.SupplierService;
import com.mzl.flower.service.wallet.WalletService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@@ -27,6 +31,9 @@
    @Autowired
    private WalletService walletService;
    @Autowired
    private SupplierService supplierService;
    @PostMapping("")
    public ResponseEntity<ReturnDataDTO> create() {
@@ -50,10 +57,21 @@
        return null;
    }
    @GetMapping("/supplier")
    @ApiOperation(value = "获取供应商钱包", notes = "获取供应商钱包")
    public WalletDO getWalletBySupplierId() {
        // 判断供应商是否存在
        final SupplierDTO currentSupplier = supplierService.getCurrentSupplier();
        if(null==currentSupplier){
            throw new ValidationException("供应商不能为空");
        }
        return walletService.getBySupplierId(currentSupplier.getId());
    }
    @GetMapping("/page")
    public ResponseEntity<ReturnDataDTO<Page<WalletDO>>> page(@RequestBody QueryWalletDTO dto
    ) {
        // 帮我写分页查询
        return null;
    }
src/main/java/com/mzl/flower/web/v2/wallet/WalletWithdrawRecordController.java
@@ -5,7 +5,18 @@
import com.mzl.flower.base.BaseController;
import com.mzl.flower.base.R;
import com.mzl.flower.base.ReturnDataDTO;
import com.mzl.flower.config.exception.ValidationException;
import com.mzl.flower.config.security.SecurityUtils;
import com.mzl.flower.dto.request.wallet.CreateWalletWithdrawRecordDTO;
import com.mzl.flower.dto.response.supplier.SupplierDTO;
import com.mzl.flower.entity.wallet.WalletDO;
import com.mzl.flower.service.supplier.SupplierService;
import com.mzl.flower.service.wallet.WalletBillRecordService;
import com.mzl.flower.service.wallet.WalletService;
import com.mzl.flower.service.wallet.WalletWithdrawRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
@@ -28,8 +39,25 @@
@RequestMapping("/v2/withdraw-record")
public class WalletWithdrawRecordController extends BaseController {
    @Autowired
    private WalletWithdrawRecordService walletWithdrawRecordService;
    @Autowired
    private WalletBillRecordService walletBillRecordService;
    @Autowired
    private SupplierService supplierService;
    @Autowired
    private WalletService walletService;
    @PostMapping("")
    public ResponseEntity<ReturnDataDTO> create() {
    public ResponseEntity<ReturnDataDTO> create(@Validated CreateWalletWithdrawRecordDTO walletWithdrawRecordDTO) {
        walletWithdrawRecordService.create(walletWithdrawRecordDTO);
        return returnData(R.SUCCESS.getCode(), null);
    }