he2802 2 years ago
parent
commit
df4e0e4d47

+ 9 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/distribution/DistributionCashWithdrawalController.java

@@ -86,6 +86,13 @@ public class DistributionCashWithdrawalController extends BaseController {
         return toAjax(iDistributionCashWithdrawalService.payCash(bo) ? 1 : 0);
     }
 
+    @ApiOperation("重新发起打款")
+    @PreAuthorize("@ss.hasPermi('system:withdrawal:add')")
+    @Log(title = "打款", businessType = BusinessType.INSERT)
+    @PostMapping("/rePayCash")
+    public AjaxResult<Void> rePayCash(@RequestBody DistributionCheckQueryBo bo) {
+        return toAjax(iDistributionCashWithdrawalService.rePayCash(bo) ? 1 : 0);
+    }
 
     @ApiOperation("取消打款申请")
     @PreAuthorize("@ss.hasPermi('system:withdrawal:add')")
@@ -96,4 +103,6 @@ public class DistributionCashWithdrawalController extends BaseController {
         bo.setSellerId(loginUser.getUser().getSellerId());
         return toAjax(iDistributionCashWithdrawalService.cancelApply(bo) ? 1 : 0);
     }
+
+
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/distribution/service/IDistributionCashWithdrawalService.java

@@ -65,6 +65,8 @@ public interface IDistributionCashWithdrawalService extends IService<Distributio
 
 	boolean payCash(DistributionCheckQueryBo bo);
 
+	boolean rePayCash(DistributionCheckQueryBo bo);
+
 	boolean payCashCallBack(DistributionCashWithdrawalPayBo bo);
 
 	boolean cancelApply(DistributionCashWithdrawalEditBo bo);

+ 41 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/distribution/service/impl/DistributionCashWithdrawalServiceImpl.java

@@ -116,7 +116,10 @@ public class DistributionCashWithdrawalServiceImpl extends ServiceImpl<Distribut
     @Override
     public Boolean insertByAddBo(DistributionCashWithdrawalAddBo bo) {
         if(Validator.isEmpty(bo.getCash())||(bo.getCash().compareTo(BigDecimal.ZERO) == 0)){
-            throw new CustomException("金额需大于0");
+            throw new CustomException("金额需大于1");
+        }
+        if((bo.getCash().compareTo(new BigDecimal(1)) <0)||bo.getCash().compareTo(new BigDecimal(200)) >0){
+            throw new CustomException("金额需大于1小于200");
         }
         DistributionCashWithdrawal add = BeanUtil.toBean(bo, DistributionCashWithdrawal.class);
         DistributionSeller seller = iDistributionSellerService.getOne(new LambdaQueryWrapper<DistributionSeller>()
@@ -304,6 +307,43 @@ public class DistributionCashWithdrawalServiceImpl extends ServiceImpl<Distribut
         return true;
     }
 
+    @Override
+    public boolean rePayCash(DistributionCheckQueryBo bo) {
+        DistributionCashWithdrawal withdrawal = getOne(new LambdaQueryWrapper<DistributionCashWithdrawal>()
+                .eq(DistributionCashWithdrawal::getCwSn, bo.getCwSn()));
+        if(withdrawal.getCwStatus() != 6){
+            throw new CustomException("非法操作");
+        }
+        DistributionSeller seller = iDistributionSellerService.getOne(new LambdaQueryWrapper<DistributionSeller>()
+                .eq(DistributionSeller::getSellerId, withdrawal.getSellerId()).last("limit 1"));
+        if(Validator.isEmpty(seller)||Validator.isEmpty(seller.getGzhOpenId())){
+            throw new CustomException("非法业务员或不存在openID");
+        }
+
+        Map<String, String> params = new HashMap<>();
+        Long nowTime = DateUtils.getNowTime();
+        String sign = ToolsUtils.EncoderByMd5(withdrawal.getCwSn()+nowTime.toString()+"pubilc2022");
+        params.put("stamp", nowTime.toString());
+        params.put("sign", sign);
+        params.put("OpenId", seller.getGzhOpenId());
+        params.put("MchBillno", withdrawal.getCwSn());
+        params.put("Money", withdrawal.getCash().toString());
+        String respone = "";
+        try {
+            respone = HttpUtils.postFormBody(OLD_PAY_HOST, params);
+            log.info("分享红包打款结果"+respone+params.toString(),"");
+            if (!respone.contains("\"Status\":true")) {
+                throw new CustomException("打款请求错误"+respone);
+            }
+        } catch (IOException e) {
+            throw new CustomException("打款请求错误"+e.getMessage());
+        }
+        withdrawal.setUpdateTime(DateUtils.getNowTime());
+        withdrawal.setCwStatus(5);
+        updateById(withdrawal);
+        return true;
+    }
+
     @Override
     public boolean payCashCallBack(DistributionCashWithdrawalPayBo bo) {
         log.info("分享红包打款回调结果"+ JSON.toJSONString(bo),"");