From 0e7f25ad6e903c569fa7364e729ddfca6547a279 Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Fri, 23 Dec 2022 11:25:43 +0800
Subject: [PATCH] 20221221

---
 src/main/java/cc/mrbird/febs/mall/quartz/OrderOvertimeJob.java                    |    4 
 src/main/java/cc/mrbird/febs/mall/dto/WithdrawalDto.java                          |    7 --
 src/main/java/cc/mrbird/febs/mall/controller/ApiMallMemberController.java         |    4 
 src/main/java/cc/mrbird/febs/mall/service/impl/MallMemberWithdrawServiceImpl.java |   18 ++---
 src/main/java/cc/mrbird/febs/mall/vo/MemberBankListVo.java                        |   12 ----
 src/test/java/cc/mrbird/febs/ProfitTest.java                                      |   58 ++++++++++++++++++-
 src/main/java/cc/mrbird/febs/mall/dto/AddMemberBankDto.java                       |   12 ----
 src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallMemberServiceImpl.java    |   10 +-
 src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallMemberServiceImpl.java      |   14 ----
 9 files changed, 75 insertions(+), 64 deletions(-)

diff --git a/src/main/java/cc/mrbird/febs/mall/controller/ApiMallMemberController.java b/src/main/java/cc/mrbird/febs/mall/controller/ApiMallMemberController.java
index 26757bb..bd393a4 100644
--- a/src/main/java/cc/mrbird/febs/mall/controller/ApiMallMemberController.java
+++ b/src/main/java/cc/mrbird/febs/mall/controller/ApiMallMemberController.java
@@ -179,13 +179,13 @@
         return null;
     }
 
-    @ApiOperation(value = "新增银行卡")
+    @ApiOperation(value = "新增地址")
     @PostMapping(value = "/addMemberBank")
     public FebsResponse addMemberBank(@RequestBody AddMemberBankDto addMemberBankDto) {
         return memberService.addMemberBank(addMemberBankDto);
     }
 
-    @ApiOperation(value = "银行卡列表", notes = "银行卡列表")
+    @ApiOperation(value = "地址列表", notes = "地址列表")
     @ApiResponses({
             @ApiResponse(code = 200, message = "success", response = MemberBankListVo.class)
     })
diff --git a/src/main/java/cc/mrbird/febs/mall/dto/AddMemberBankDto.java b/src/main/java/cc/mrbird/febs/mall/dto/AddMemberBankDto.java
index d96d705..5c0e3ea 100644
--- a/src/main/java/cc/mrbird/febs/mall/dto/AddMemberBankDto.java
+++ b/src/main/java/cc/mrbird/febs/mall/dto/AddMemberBankDto.java
@@ -8,20 +8,8 @@
 @ApiModel(value = "AddMemberBankDto", description = "参数接收类")
 public class AddMemberBankDto {
 
-    // 姓名
-    @ApiModelProperty(value = "姓名")
-    private String name;
-    //证件类型
-    @ApiModelProperty(value = "证件类型")
-    private String idType;
-    //证件号码
-    @ApiModelProperty(value = "证件号码")
-    private String idCardNum;
     // 银行卡号
     @ApiModelProperty(value = "银行卡号")
     private String bankNo;
-    // 手机号
-    @ApiModelProperty(value = "手机号")
-    private String phone;
 
 }
diff --git a/src/main/java/cc/mrbird/febs/mall/dto/WithdrawalDto.java b/src/main/java/cc/mrbird/febs/mall/dto/WithdrawalDto.java
index e4af5b3..b987c11 100644
--- a/src/main/java/cc/mrbird/febs/mall/dto/WithdrawalDto.java
+++ b/src/main/java/cc/mrbird/febs/mall/dto/WithdrawalDto.java
@@ -26,13 +26,8 @@
     @ApiModelProperty(value = "交易密码")
     private String tradePwd;
 
+    @NotBlank(message = "参数不能为空")
     @ApiModelProperty(value = "银行卡号")
     private String bankNo;
 
-    @ApiModelProperty(value = "姓名")
-    private String name;
-
-    @NotNull(message = "银行卡不能为空")
-    @ApiModelProperty(value = "用户银行卡ID")
-    private Long bankId;
 }
diff --git a/src/main/java/cc/mrbird/febs/mall/quartz/OrderOvertimeJob.java b/src/main/java/cc/mrbird/febs/mall/quartz/OrderOvertimeJob.java
index 5481d86..0828c17 100644
--- a/src/main/java/cc/mrbird/febs/mall/quartz/OrderOvertimeJob.java
+++ b/src/main/java/cc/mrbird/febs/mall/quartz/OrderOvertimeJob.java
@@ -101,9 +101,9 @@
                     DataDictionaryEnum.RETURN_PERCENT.getCode()
             );
             String returnPercentStr = returnPercentDic.getValue();
-            BigDecimal returnPercent = new BigDecimal(returnPercentStr).multiply(new BigDecimal(0.01));
+            BigDecimal returnPercent = new BigDecimal(returnPercentStr).multiply(new BigDecimal(0.01)).setScale(2,BigDecimal.ROUND_DOWN);
             //本次返还金额
-            BigDecimal returnAmount = amount.multiply(returnPercent);
+            BigDecimal returnAmount = amount.multiply(returnPercent).setScale(2,BigDecimal.ROUND_DOWN);
             /**
              * 如果本次返还金额大于剩余返还总金额
              */
diff --git a/src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallMemberServiceImpl.java b/src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallMemberServiceImpl.java
index 0ff708d..c99f741 100644
--- a/src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallMemberServiceImpl.java
+++ b/src/main/java/cc/mrbird/febs/mall/service/impl/AdminMallMemberServiceImpl.java
@@ -155,11 +155,11 @@
             return new FebsResponse().fail().message("当前状态不是提现中");
         }
 
-        Long wtihdrawTypeId = mallMemberWithdraw.getWtihdrawTypeId();
-        MallMemberBank mallMemberBank = mallMemberBankMapper.selectById(wtihdrawTypeId);
-        if(ObjectUtil.isEmpty(mallMemberBank)){
-            return new FebsResponse().fail().message("提现地址不存在");
-        }
+//        Long wtihdrawTypeId = mallMemberWithdraw.getWtihdrawTypeId();
+//        MallMemberBank mallMemberBank = mallMemberBankMapper.selectById(wtihdrawTypeId);
+//        if(ObjectUtil.isEmpty(mallMemberBank)){
+//            return new FebsResponse().fail().message("提现地址不存在");
+//        }
         //更新提现记录状态为成功
         mallMemberWithdrawMapper.updateStatusById(2,mallMemberWithdraw.getId());
         //更新提现流水记录为成功
diff --git a/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallMemberServiceImpl.java b/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallMemberServiceImpl.java
index 47de2a9..ccdc516 100644
--- a/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallMemberServiceImpl.java
+++ b/src/main/java/cc/mrbird/febs/mall/service/impl/ApiMallMemberServiceImpl.java
@@ -462,14 +462,8 @@
     public BigDecimal canMoney() {
         Long memberId = LoginUserUtil.getLoginUser().getId();
         MallMemberWallet wallet = mallMemberWalletMapper.selectWalletByMemberId(memberId);
-        BigDecimal profit = mallMoneyFlowMapper.selectProfitByDateAndMemberId(memberId);
-
-        BigDecimal canMoney = wallet.getCommission();
-        if (profit != null) {
-            if(canMoney.compareTo(BigDecimal.ZERO) > 0) {
-                canMoney = canMoney.subtract(profit);
-            }
-        }
+        BigDecimal canMoney = wallet.getBalance();
+        canMoney = canMoney.compareTo(BigDecimal.ZERO) > 0 ? canMoney : BigDecimal.ZERO;
         return canMoney;
     }
 
@@ -614,11 +608,7 @@
     public FebsResponse updateMemberBank(UpdateMemberBankDto updateMemberBankDto) {
         Long id = updateMemberBankDto.getId();
         MallMemberBank mallMemberBank = mallMemberBankMapper.selectById(id);
-        mallMemberBank.setName(updateMemberBankDto.getName());
-        mallMemberBank.setIdType(updateMemberBankDto.getIdType());
-        mallMemberBank.setIdCardNum(updateMemberBankDto.getIdCardNum());
         mallMemberBank.setBankNo(updateMemberBankDto.getBankNo());
-        mallMemberBank.setPhone(updateMemberBankDto.getPhone());
         mallMemberBankMapper.updateById(mallMemberBank);
         return new FebsResponse().success();
     }
diff --git a/src/main/java/cc/mrbird/febs/mall/service/impl/MallMemberWithdrawServiceImpl.java b/src/main/java/cc/mrbird/febs/mall/service/impl/MallMemberWithdrawServiceImpl.java
index 9ac3bc0..0053096 100644
--- a/src/main/java/cc/mrbird/febs/mall/service/impl/MallMemberWithdrawServiceImpl.java
+++ b/src/main/java/cc/mrbird/febs/mall/service/impl/MallMemberWithdrawServiceImpl.java
@@ -61,16 +61,14 @@
             cashOutSettingVo = JSONObject.parseObject(dic.getValue(), CashOutSettingVo.class);
         }
 
-        if (withdrawalDto.getAmount().compareTo(cashOutSettingVo.getMinCashOut()) < 0) {
-            throw new FebsException("最小提现金额为"+cashOutSettingVo.getMinCashOut().setScale(2,BigDecimal.ROUND_DOWN));
+        if (withdrawalDto.getAmount().compareTo(BigDecimal.ZERO) <= 0) {
+            throw new FebsException("请输入正确的提现金额");
+        }
+        if(ObjectUtil.isEmpty(withdrawalDto.getBankNo())){
+            throw new FebsException("请输入地址");
         }
 
-        MallMemberBank mallMemberBank = mallMemberBankMapper.selectById(withdrawalDto.getBankId());
-        if(ObjectUtil.isEmpty(mallMemberBank)){
-            throw new FebsException("未找到地址信息");
-        }
-
-        BigDecimal serviceFee = cashOutSettingVo.getServiceFee().multiply(BigDecimal.valueOf(0.01));
+        BigDecimal serviceFee = cashOutSettingVo.getServiceFee();
         String orderNo = MallUtils.getOrderNum("W");
         //减少用户余额
         memberWalletService.reduce(withdrawalDto.getAmount(), memberId, "balance");
@@ -80,8 +78,8 @@
         withdraw.setMemberId(memberId);
         withdraw.setAmount(withdrawalDto.getAmount());
         withdraw.setStatus(1);
-        withdraw.setAmountFee(serviceFee.multiply(withdrawalDto.getAmount()));
-        withdraw.setWtihdrawTypeId(mallMemberBank.getId());
+        withdraw.setAmountFee(serviceFee);
+//        withdraw.setWtihdrawTypeId(mallMemberBank.getId());
         this.baseMapper.insert(withdraw);
         //生成提现流水记录
         Long subsidyAmountFlowId = mallMoneyFlowService.addMoneyFlow(
diff --git a/src/main/java/cc/mrbird/febs/mall/vo/MemberBankListVo.java b/src/main/java/cc/mrbird/febs/mall/vo/MemberBankListVo.java
index 5f708dc..6c6da5d 100644
--- a/src/main/java/cc/mrbird/febs/mall/vo/MemberBankListVo.java
+++ b/src/main/java/cc/mrbird/febs/mall/vo/MemberBankListVo.java
@@ -8,19 +8,7 @@
 @ApiModel(value = "MemberBankListVo", description = "信息返回类")
 public class MemberBankListVo {
     private Long id;
-    // 姓名
-    @ApiModelProperty(value = "姓名")
-    private String name;
-    //证件类型
-    @ApiModelProperty(value = "证件类型")
-    private String idType;
-    //证件号码
-    @ApiModelProperty(value = "证件号码")
-    private String idCardNum;
     // 银行卡号
     @ApiModelProperty(value = "银行卡号")
     private String bankNo;
-    // 手机号
-    @ApiModelProperty(value = "手机号")
-    private String phone;
 }
diff --git a/src/test/java/cc/mrbird/febs/ProfitTest.java b/src/test/java/cc/mrbird/febs/ProfitTest.java
index a988c2e..5bd823a 100644
--- a/src/test/java/cc/mrbird/febs/ProfitTest.java
+++ b/src/test/java/cc/mrbird/febs/ProfitTest.java
@@ -337,11 +337,63 @@
     @Autowired
     private IMallAchieveService mallAchieveService;
 
+    @Autowired
+    private MallMemberStarBuyMapper mallMemberStarBuyMapper;
+
     @Test
     public void achieveTest() {
-        List<MallOrderItem> items = mallOrderItemMapper.selectList(null);
-        for (MallOrderItem item : items) {
-            mallAchieveService.add(item.getId());
+        List<MallMemberStarBuy> mallMemberStarBuys = mallMemberStarBuyMapper.selectByStatus(1);
+        if(CollUtil.isEmpty(mallMemberStarBuys)){
+            return;
+        }
+        for(MallMemberStarBuy mallMemberStarBuy : mallMemberStarBuys){
+            Long memberId = mallMemberStarBuy.getMemberId();
+            MallMember mallMember = memberMapper.selectById(memberId);
+            //用户不存在跳出本次循环
+            if(ObjectUtil.isEmpty(mallMember)){
+                continue;
+            }
+            //返还总金额
+            BigDecimal amount = mallMemberStarBuy.getAmount();
+            //剩余返还总金额不足,跳出本次循环
+            BigDecimal avaAmount = mallMemberStarBuy.getAvaAmount();
+            if(avaAmount.compareTo(BigDecimal.ZERO) <= 0){
+                continue;
+            }
+            //每次返还比例
+            DataDictionaryCustom returnPercentDic = dataDictionaryCustomMapper.selectDicDataByTypeAndCode(
+                    DataDictionaryEnum.RETURN_PERCENT.getType(),
+                    DataDictionaryEnum.RETURN_PERCENT.getCode()
+            );
+            String returnPercentStr = returnPercentDic.getValue();
+            BigDecimal returnPercent = new BigDecimal(returnPercentStr).multiply(new BigDecimal(0.01)).setScale(2,BigDecimal.ROUND_DOWN);
+            //本次返还金额
+            BigDecimal returnAmount = amount.multiply(returnPercent).setScale(2,BigDecimal.ROUND_DOWN);
+            /**
+             * 如果本次返还金额大于剩余返还总金额
+             */
+            if(returnAmount.compareTo(avaAmount) >= 0){
+                returnAmount = avaAmount;
+                avaAmount = BigDecimal.ZERO;
+            }else{
+                avaAmount = avaAmount.subtract(returnAmount).setScale(2,BigDecimal.ROUND_DOWN);
+            }
+            //增加用户金额
+            memberWalletService.addBalance(returnAmount,mallMember.getId());
+            //生成流水记录
+            Long subsidyAmountFlowId = mallMoneyFlowService.addMoneyFlow(
+                    mallMember.getId(),
+                    mallMemberStarBuy.getBuyCode(),
+                    returnAmount,
+                    MallMoneyFlowTypeEnum.RETURN_MARKET_STAR.getCode(),
+                    MallMoneyFlow.STATUS_SUCCESS,
+                    MallMoneyFlow.IS_RETURN_Y,
+                    mallMember.getId(),
+                    FlowTypeEnum.BALANCE.getValue(),
+                    MallMoneyFlowTypeEnum.RETURN_MARKET_STAR.getName()
+            );
+            //更新记录
+            mallMemberStarBuyMapper.updateAvaAmountById(avaAmount,mallMemberStarBuy.getId());
         }
     }
 //

--
Gitblit v1.9.1