src/main/java/com/mzl/flower/constant/Constants.java
@@ -589,6 +589,24 @@ return desc; } } public enum BILL_WITHDRAW_TYPE { start("发起提现"), fail("提现失败"), success("提现成功") ; BILL_WITHDRAW_TYPE(String desc) { this.desc = desc; } private String desc; public String getDesc() { return desc; } } public enum BILL_CHANGE_METHOD { add("增加"), reduce("减少"); src/main/java/com/mzl/flower/dto/request/wallet/CreateWalletWithdrawRecordDTO.java
@@ -26,7 +26,7 @@ */ @ApiModelProperty(value = "钱包Id") @NotNull(message = "提现金额不能为空") @DecimalMin(value = "0.0", message = "提现金额不能小于0") @DecimalMin(value = "0.01", message = "提现金额不能小于0.01") private BigDecimal amount; /** src/main/java/com/mzl/flower/dto/response/report/OrderDetailReportResultVO.java
@@ -77,7 +77,11 @@ @ApiModelProperty("总包干费") private BigDecimal partnerTotalFeeAmount; @ApiModelProperty("销售扎数") @ApiModelProperty("总销售扎数") private Integer orderNum; @ApiModelProperty("实际销售扎数") private Integer realSaleNum; @ApiModelProperty("利润") src/main/java/com/mzl/flower/dto/response/report/OrderReportResultVO.java
@@ -67,6 +67,9 @@ @ApiModelProperty("总包干费--暂无") private BigDecimal partnerTotalFeeAmount; @ApiModelProperty("总销售扎数") private Integer orderNum; @ApiModelProperty("实际销售扎数") private Integer realSaleNum; src/main/java/com/mzl/flower/dto/response/wallet/WalletBillRecordVO.java
@@ -24,6 +24,10 @@ @DictTrans(target = "typeName",codeType = "BILL_CHANGE_TYPE") private String type; @ApiModelProperty(value = "账单提现类型") @DictTrans(target = "withdrawTypeName",codeType = "BILL_WITHDRAW_TYPE") private String withdrawType; @ApiModelProperty(value = "类型明细") private String typeDetail; @@ -69,4 +73,7 @@ @ApiModelProperty(value = "变动方式(增加、减少") private String methodName; @ApiModelProperty(value = "账单提现类型名称(发起提现、提现失败、提现成功)") private String withdrawTypeName; } src/main/java/com/mzl/flower/entity/wallet/WalletBillRecordDO.java
@@ -28,6 +28,9 @@ @ApiModelProperty(value = "账单变动类型(提现,结算)") private String type; @ApiModelProperty(value = "账单变动提现类型") private String withdrawType; @ApiModelProperty(value = "类型明细") private String typeDetail; src/main/java/com/mzl/flower/service/impl/wallet/WalletServiceImpl.java
@@ -5,6 +5,7 @@ import com.mzl.flower.constant.LockConstants; import com.mzl.flower.dto.request.wallet.QueryWalletAmountDTO; import com.mzl.flower.dto.response.supplier.SupplierDTO; import com.mzl.flower.entity.supplier.Supplier; import com.mzl.flower.entity.wallet.WalletDO; import com.mzl.flower.enums.TrueOrFalseEnum; import com.mzl.flower.mapper.wallet.WalletMapper; @@ -17,6 +18,7 @@ import org.redisson.api.RedissonClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; import java.math.BigDecimal; import java.text.SimpleDateFormat; @@ -76,6 +78,8 @@ @Override public WalletDO getOrCreateBySupplierId(Long supplierId) { WalletDO walletDO=getBySupplierId(supplierId); if(null==walletDO){ RLock lock = redissonClient.getLock(String.format(LockConstants.WALLET_SUPPLIER_ID_KEY, supplierId)); @@ -84,9 +88,12 @@ try { walletDO=getBySupplierId(supplierId); if(null!=walletDO) return walletDO; final Supplier supplier = supplierService.getSupplierById(supplierId); // 创建一个钱包 walletDO =new WalletDO(); walletDO.setUserId(SecurityUtils.getUserId()); walletDO.setUserId(supplier.getUserId()); walletDO.setSupplierId(supplierId); walletDO.setTotalAmount(BigDecimal.ZERO); walletDO.setWithdrawableAmount(BigDecimal.ZERO); @@ -130,7 +137,10 @@ @Override public BigDecimal getWaittingSettlementAmount(WalletDO walletDO) { if(null!=walletDO && !StringUtils.isEmpty(walletDO.getSupplierId()) && StringUtils.isEmpty(walletDO.getUserId())){ final Supplier supplier = supplierService.getSupplierById(walletDO.getSupplierId()); walletDO.setUserId(supplier.getUserId()); } return baseMapper.getWaittingSettlementAmount(walletDO); } src/main/java/com/mzl/flower/service/impl/wallet/WalletWithdrawRecordServiceImpl.java
@@ -137,6 +137,25 @@ save(withdrawRecordDO); // 2.新增一条账单明细 WalletBillRecordDO walletBillRecordDO=new WalletBillRecordDO(); walletBillRecordDO.setId(UUIDGenerator.getUUID()); walletBillRecordDO.setSupplierId(supplierDTO.getId()); walletBillRecordDO.setWalletId(walletDO.getId()); walletBillRecordDO.setType(Constants.BILL_CHANGE_TYPE.withdraw.name()); // 发起提现 walletBillRecordDO.setWithdrawType(Constants.BILL_WITHDRAW_TYPE.start.name()); walletBillRecordDO.setMethod(Constants.BILL_CHANGE_METHOD.reduce.name()); walletBillRecordDO.setOriginalAmount(walletDO.getWithdrawableAmount()); walletBillRecordDO.setChangeAmount(dto.getAmount()); walletBillRecordDO.setBalance(walletDO.getWithdrawableAmount().subtract(dto.getAmount())); walletBillRecordDO.create(SecurityUtils.getUserId()); // 保存账单明细 walletBillRecordService.save(walletBillRecordDO); // 3. 钱包更新 // 钱包可提现的钱等于当前钱包可提现的钱-提现的钱 walletDO.setWithdrawableAmount(walletDO.getWithdrawableAmount().subtract(dto.getAmount())); src/main/java/com/mzl/flower/service/supplier/SupplierService.java
@@ -214,7 +214,7 @@ supplierMapper.updateById(supplier); } public Supplier getSupplierById(String supplierId) { public Supplier getSupplierById(Long supplierId) { return supplierMapper.selectById(supplierId); } } src/main/resources/mapper/report/OrderReportMapper.xml
@@ -111,6 +111,7 @@ o.create_time as orderDate, o.payment_time, o.status_backend as settleStatus, vor.order_num as order_num, vor.order_num-vor.order_lack_num as real_sale_num, vor.* from t_order o src/main/resources/mapper/wallet/WalletBillRecordMapper.xml
@@ -13,6 +13,9 @@ <result column="supplier_id" property="supplierId" /> <result column="wallet_id" property="walletId" /> <result column="type" property="type" /> <result column="withdraw_type" property="withdrawType" /> <result column="type_detail" property="typeDetail" /> <result column="transfer_id" property="transferId" /> <result column="method" property="method" />