8720856b52c908354321d074959bd8b9edbc38b1..d7819bb819cd897d5933ac98bdec7e3ccc70846c
2024-10-23 cloudroam
fix: 冲突
d7819b 对比 | 目录
2024-10-23 cloudroam
Merge remote-tracking branch 'origin/master-v4' into master-v4
b4aa24 对比 | 目录
2024-10-23 cloudroam
add:提现记录查询、审批
13ee40 对比 | 目录
已修改7个文件
已添加2个文件
252 ■■■■ 文件已修改
src/main/java/com/mzl/flower/dto/request/wallet/QueryWalletDTO.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mzl/flower/dto/request/wallet/WalletWithdrawRecordDTO.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mzl/flower/dto/response/wallet/WalletWithdrawRecordVO.java 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mzl/flower/mapper/wallet/WalletMapper.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mzl/flower/mapper/wallet/WalletWithdrawRecordMapper.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mzl/flower/service/impl/wallet/WalletWithdrawRecordServiceImpl.java 62 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mzl/flower/service/wallet/WalletWithdrawRecordService.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mzl/flower/web/v2/wallet/WalletWithdrawRecordController.java 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/wallet/WalletWithdrawRecordMapper.xml 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/mzl/flower/dto/request/wallet/QueryWalletDTO.java
@@ -1,7 +1,11 @@
package com.mzl.flower.dto.request.wallet;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDate;
@Data
public class QueryWalletDTO {
@@ -9,7 +13,28 @@
    @ApiModelProperty(value = "供应商Id")
    private String supplierId;
    @ApiModelProperty(value = "用户Id")
    private String userId;
    @ApiModelProperty(value = "供应商名称")
    private String supplierName;
    @ApiModelProperty(value = "提交日期-开始日期")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private LocalDate createStartDate;
    @ApiModelProperty(value = "提交日期-结束日期")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private LocalDate endEndDate;
    @ApiModelProperty(value = "审核时间-开始日期")
    @JsonFormat(pattern="yyyy-MM-dd" ,timezone="GMT+8")
    @DateTimeFormat(pattern="yyyy-MM-dd")
    private LocalDate approveStartDate;
    @ApiModelProperty(value = "审核时间-结束日期")
    @JsonFormat(pattern="yyyy-MM-dd" ,timezone="GMT+8")
    @DateTimeFormat(pattern="yyyy-MM-dd")
    private LocalDate approveEndDate;
}
src/main/java/com/mzl/flower/dto/request/wallet/WalletWithdrawRecordDTO.java
对比新文件
@@ -0,0 +1,15 @@
package com.mzl.flower.dto.request.wallet;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class WalletWithdrawRecordDTO {
    private Long id;
    @ApiModelProperty(value = "审核状态(待审核、已通过、已拒绝)")
    private Integer approveState;
    @ApiModelProperty(value = "不通过原因")
    private String rejectReason;
}
src/main/java/com/mzl/flower/dto/response/wallet/WalletWithdrawRecordVO.java
对比新文件
@@ -0,0 +1,55 @@
package com.mzl.flower.dto.response.wallet;
import com.mzl.flower.base.AbstractTransDTO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Data
public class WalletWithdrawRecordVO extends AbstractTransDTO {
    private Long id;
    @ApiModelProperty(value = "供应商Id")
    private Long supplierId;
    @ApiModelProperty(value = "供应商名称")
    private String supplierName;
    @ApiModelProperty(value = "钱包Id")
    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;
    @ApiModelProperty("创建日期")
    private LocalDateTime createTime;
    @ApiModelProperty("修改日期")
    private LocalDateTime updateTime;
    @ApiModelProperty("操作人")
    private String createName;
    @ApiModelProperty("更新人")
    private String updateBy;
}
src/main/java/com/mzl/flower/mapper/wallet/WalletMapper.java
@@ -17,6 +17,6 @@
public interface WalletMapper extends BaseMapper<WalletDO> {
    @Select("select total_amount as totalAmount from t_wallet where supplier_id =#{supplierId}")
    public BigDecimal getTotalAmount(String supplierId);
    @Select("select * from t_wallet where supplier_id =#{supplierId}")
    public WalletDO getTotalAmount(String supplierId);
}
src/main/java/com/mzl/flower/mapper/wallet/WalletWithdrawRecordMapper.java
@@ -1,7 +1,13 @@
package com.mzl.flower.mapper.wallet;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mzl.flower.dto.request.wallet.QueryWalletDTO;
import com.mzl.flower.dto.response.member.MemberVO;
import com.mzl.flower.dto.response.wallet.WalletWithdrawRecordVO;
import com.mzl.flower.entity.wallet.WalletWithdrawRecordDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import java.util.List;
/**
 * <p>
@@ -13,4 +19,5 @@
 */
public interface WalletWithdrawRecordMapper extends BaseMapper<WalletWithdrawRecordDO> {
    List<WalletWithdrawRecordVO> queryPage(QueryWalletDTO queryWalletDTO, Page page);
}
src/main/java/com/mzl/flower/service/impl/wallet/WalletWithdrawRecordServiceImpl.java
@@ -1,62 +1,92 @@
package com.mzl.flower.service.impl.wallet;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
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.request.wallet.QueryWalletDTO;
import com.mzl.flower.dto.request.wallet.WalletWithdrawRecordDTO;
import com.mzl.flower.dto.response.supplier.SupplierDTO;
import com.mzl.flower.dto.response.wallet.WalletWithdrawRecordVO;
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 lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.time.LocalDateTime;
import java.util.List;
/**
 * <p>
 *  服务实现类
 * 服务实现类
 * </p>
 *
 * @author @TaoJie
 * @since 2024-10-22
 */
@Service
@Transactional
@RequiredArgsConstructor
public class WalletWithdrawRecordServiceImpl extends ServiceImpl<WalletWithdrawRecordMapper, WalletWithdrawRecordDO> implements WalletWithdrawRecordService {
    @Autowired
    private WalletService walletService;
    @Autowired
    private SupplierService supplierService;
    private final WalletWithdrawRecordMapper walletWithdrawRecordMapper;
    private final WalletService walletService;
    private final SupplierService supplierService;
    @Transactional
    @Override
    public boolean create(CreateWalletWithdrawRecordDTO dto) {
        SupplierDTO supplierDTO=supplierService.getCurrentSupplier();
        if(null==supplierDTO){
        SupplierDTO supplierDTO = supplierService.getCurrentSupplier();
        if (null == supplierDTO) {
            throw new ValidationException("供应商不能为空");
        }
        final WalletDO walletDO = walletService.getBySupplierId();
        if(null==walletDO){
        if (null == walletDO) {
            throw new ValidationException("钱包不能为空");
        }
        // 查看钱包的金额是不是大于要提现的金额
        if(null!=walletDO.getWithdrawableAmount() && null!=dto.getAmount()
                && walletDO.getWithdrawableAmount().compareTo(dto.getAmount())<0){
        if (null != walletDO.getWithdrawableAmount() && null != dto.getAmount() && walletDO.getWithdrawableAmount().compareTo(dto.getAmount()) < 0) {
            throw new ValidationException("钱包金额不足");
        }
        WalletWithdrawRecordDO withdrawRecordDO=new WalletWithdrawRecordDO();
        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);
    }
    @Override
    public Page<WalletWithdrawRecordVO> queryPage(QueryWalletDTO queryWalletDTO, Page page) {
        List<WalletWithdrawRecordVO> list = walletWithdrawRecordMapper.queryPage(queryWalletDTO, page);
        page.setRecords(list);
        return page;
    }
    @Override
    public void updateWallet(WalletWithdrawRecordDTO walletWithdrawRecordDTO) {
        WalletWithdrawRecordDO withdrawRecordDO = walletWithdrawRecordMapper.selectById(walletWithdrawRecordDTO.getId());
        if (withdrawRecordDO == null) {
            throw new ValidationException("提现记录信息不存在");
        }
        if (StringUtils.isEmpty(walletWithdrawRecordDTO.getApproveState())) {
            throw new ValidationException("审批状态不能为空");
        }
        BeanUtils.copyProperties(walletWithdrawRecordDTO, withdrawRecordDO);
        withdrawRecordDO.update(SecurityUtils.getUserId());
        withdrawRecordDO.setApproveBy(SecurityUtils.getUserId());
        withdrawRecordDO.setApproveTime(LocalDateTime.now());
        walletWithdrawRecordMapper.updateById(withdrawRecordDO);
    }
}
src/main/java/com/mzl/flower/service/wallet/WalletWithdrawRecordService.java
@@ -1,5 +1,9 @@
package com.mzl.flower.service.wallet;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mzl.flower.dto.request.wallet.QueryWalletDTO;
import com.mzl.flower.dto.request.wallet.WalletWithdrawRecordDTO;
import com.mzl.flower.dto.response.wallet.WalletWithdrawRecordVO;
import com.mzl.flower.dto.request.wallet.CreateWalletWithdrawRecordDTO;
import com.mzl.flower.entity.wallet.WalletWithdrawRecordDO;
import com.baomidou.mybatisplus.extension.service.IService;
@@ -13,6 +17,9 @@
 * @since 2024-10-22
 */
public interface WalletWithdrawRecordService extends IService<WalletWithdrawRecordDO> {
    Page<WalletWithdrawRecordVO> queryPage(QueryWalletDTO dto, Page page);
    void updateWallet(WalletWithdrawRecordDTO walletWithdrawRecordDTO);
    boolean create(CreateWalletWithdrawRecordDTO walletWithdrawRecordDTO);
}
src/main/java/com/mzl/flower/web/v2/wallet/WalletWithdrawRecordController.java
@@ -5,17 +5,20 @@
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.QueryWalletDTO;
import com.mzl.flower.dto.request.wallet.WalletWithdrawRecordDTO;
import com.mzl.flower.dto.response.wallet.WalletWithdrawRecordVO;
import com.mzl.flower.service.wallet.WalletWithdrawRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
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.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
@@ -29,29 +32,36 @@
import javax.validation.constraints.Max;
import javax.validation.constraints.Positive;
import org.springframework.web.bind.annotation.RestController;
/**
* @author @TaoJie
* @since 2024-10-22
*/
@Api(value = "提现记录", tags = "提现记录")
@RestController
@RequestMapping("/v2/withdraw-record")
@RequiredArgsConstructor
public class WalletWithdrawRecordController extends BaseController {
    @Autowired
    private WalletWithdrawRecordService walletWithdrawRecordService;
    private final WalletWithdrawRecordService walletWithdrawRecordService;
    @Autowired
    private WalletBillRecordService walletBillRecordService;
    private final WalletBillRecordService walletBillRecordService;
    @Autowired
    private SupplierService supplierService;
    private final SupplierService supplierService;
    @Autowired
    private WalletService walletService;
    @GetMapping("/list")
    @ApiOperation(value = "查询提现记录", httpMethod = "GET")
    public ResponseEntity<ReturnDataDTO<Page<WalletWithdrawRecordVO>>> getMemberList(Page page, QueryWalletDTO dto) {
        return returnData(R.SUCCESS.getCode(), walletWithdrawRecordService.queryPage(dto, page));
    }
    @PostMapping(value = "/edit")
    @ApiOperation(value = "修改", httpMethod = "POST")
    public ResponseEntity update(@RequestBody WalletWithdrawRecordDTO walletWithdrawRecordDTO) {
        walletWithdrawRecordService.updateWallet(walletWithdrawRecordDTO);
        return returnData(R.SUCCESS.getCode(), null);
    }
    @PostMapping("")
    public ResponseEntity<ReturnDataDTO> create(@Validated CreateWalletWithdrawRecordDTO walletWithdrawRecordDTO) {
src/main/resources/mapper/wallet/WalletWithdrawRecordMapper.xml
@@ -20,5 +20,38 @@
        <result column="approve_state" property="approveState" />
        <result column="reject_reason" property="rejectReason" />
    </resultMap>
    <select id="queryPage" resultType="com.mzl.flower.dto.response.wallet.WalletWithdrawRecordVO">
        select t.* ,s.name supplierName from t_wallet_withdraw_record t
        left join t_supplier_info s on t.supplier_id = s.id
        where t.deleted= 0
        <if test="dto.supplierName != null and dto.supplierName != ''">
            and s.name like concat('%', #{dto.supplierName}, '%')
        </if>
        <if test="dto.supplierId != null and dto.supplierId != ''">
            and t.supplier_id = #{dto.supplierId}
        </if>
        <if test="dto.createStartDate!=null ">
            <![CDATA[
               AND t.create_time >= #{dto.createStartDate}
            ]]>
        </if>
        <if test="dto.endEndDate!=null ">
            <![CDATA[
               AND t.create_time <= #{dto.endEndDate}
            ]]>
        </if>
        <if test="dto.approveStartDate!=null ">
            <![CDATA[
               AND t.approve_time >= #{dto.approveStartDate}
            ]]>
        </if>
        <if test="dto.approveEndDate!=null ">
            <![CDATA[
               AND t.approve_time <= #{dto.approveStartDate}
            ]]>
        </if>
        order by t.create_time
    </select>
</mapper>