From 3c9cc4f7a8ce14ce07dec4032d163fbb654cbd3f Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期二, 14 一月 2025 19:08:04 +0800
Subject: [PATCH] 修改bug
---
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java | 2
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/WithdrawalRequests.java | 6 ++
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WithdrawalRequestsController.java | 37 +++++++++++++++++-
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/util/ExpressDeliveryUtil.java | 3 +
ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopWithdraw.java | 6 ++
ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml | 4 +-
ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopWithdrawController.java | 33 +++++++++++++++-
7 files changed, 79 insertions(+), 12 deletions(-)
diff --git a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/WithdrawalRequests.java b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/WithdrawalRequests.java
index c0a2a59..97a1805 100644
--- a/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/WithdrawalRequests.java
+++ b/ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/WithdrawalRequests.java
@@ -74,9 +74,13 @@
@TableField("audit_status")
private Integer auditStatus;
- @ApiModelProperty(value = "状态(1=处理中,2=成功)")
+ @ApiModelProperty(value = "状态(1=处理中,2=成功,3=失败)")
@TableField("status")
private Integer status;
+
+ @ApiModelProperty(value = "处理结果")
+ @TableField("remark")
+ private String remark;
@ApiModelProperty(value = "到账时间")
@TableField("arrival_time")
diff --git a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopWithdraw.java b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopWithdraw.java
index 8795234..6bda5f6 100644
--- a/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopWithdraw.java
+++ b/ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/ShopWithdraw.java
@@ -59,10 +59,14 @@
@TableField("audit_msg")
private String auditMsg;
- @ApiModelProperty(value = "状态(1=申请中,2=已到账)")
+ @ApiModelProperty(value = "状态(1=申请中,2=已到账,3=失败)")
@TableField("status")
private Integer status;
+ @ApiModelProperty(value = "处理结果")
+ @TableField("remark")
+ private String remark;
+
@ApiModelProperty(value = "到账时间")
@TableField("arrival_time")
private LocalDateTime arrivalTime;
diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WithdrawalRequestsController.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WithdrawalRequestsController.java
index bea2770..c792884 100644
--- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WithdrawalRequestsController.java
+++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WithdrawalRequestsController.java
@@ -158,9 +158,9 @@
@PostMapping("/withdrawalCallback")
public Object withdrawalCallback(@RequestBody SinglePayCallbackResult singlePayCallbackResult){
Integer status = singlePayCallbackResult.getStatus();
+ String merchantOrderNo = singlePayCallbackResult.getMerchantOrderNo();
+ WithdrawalRequests withdrawalRequests = withdrawalRequestsService.getById(merchantOrderNo);
if(203 == status || 205 == status){
- String merchantOrderNo = singlePayCallbackResult.getMerchantOrderNo();
- WithdrawalRequests withdrawalRequests = withdrawalRequestsService.getById(merchantOrderNo);
if(1 == withdrawalRequests.getStatus()){
withdrawalRequests.setStatus(2);
withdrawalRequests.setArrivalTime(LocalDateTime.now());
@@ -169,8 +169,39 @@
JSONObject jsonObject = new JSONObject();
jsonObject.put("statusCode", 2001);
return jsonObject;
+ }else{
+ //回退扣除的金额,添加明细记录
+ //修改用户的可提现金额
+ BigDecimal withdrawalAmount = withdrawalRequests.getWithdrawalAmount();
+ AppUser appUser = appUserService.getById(withdrawalRequests.getAppUserId());
+ BigDecimal withdrawableAmount = appUser.getWithdrawableAmount();
+ BigDecimal withdrawnAmount = appUser.getWithdrawnAmount();
+ BigDecimal balance = appUser.getBalance();
+ appUser.setWithdrawableAmount(withdrawableAmount.add(withdrawalAmount).setScale(2, RoundingMode.HALF_EVEN));
+ appUser.setWithdrawnAmount(withdrawnAmount.subtract(withdrawalAmount).setScale(2, RoundingMode.HALF_EVEN));
+ appUser.setBalance(appUser.getBalance().add(withdrawalAmount).setScale(2, RoundingMode.HALF_EVEN));
+ appUserService.updateById(appUser);
+ //添加变动明细
+ BalanceChangeRecord balanceChangeRecord = new BalanceChangeRecord();
+ balanceChangeRecord.setAppUserId(appUser.getId());
+ balanceChangeRecord.setVipId(appUser.getVipId());
+ balanceChangeRecord.setOrderId(withdrawalRequests.getId());
+ balanceChangeRecord.setChangeType(2);
+ balanceChangeRecord.setBeforeAmount(balance);
+ balanceChangeRecord.setChangeAmount(withdrawalAmount);
+ balanceChangeRecord.setAfterAmount(appUser.getBalance());
+ balanceChangeRecord.setDelFlag(0);
+ balanceChangeRecord.setCreateTime(LocalDateTime.now());
+ balanceChangeRecordService.save(balanceChangeRecord);
+
+ withdrawalRequests.setStatus(3);
+ withdrawalRequests.setRemark(singlePayCallbackResult.getErrorCodeDesc());
+ withdrawalRequestsService.updateById(withdrawalRequests);
+
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put("statusCode", 2001);
+ return jsonObject;
}
- return new JSONObject();
}
}
diff --git a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/util/ExpressDeliveryUtil.java b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/util/ExpressDeliveryUtil.java
index 75e2841..d4f35f7 100644
--- a/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/util/ExpressDeliveryUtil.java
+++ b/ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/util/ExpressDeliveryUtil.java
@@ -75,7 +75,8 @@
public static MapTrackKD100Vo kd100MapTrack(String com, String num, String from, String to){
QueryTrackReq queryTrackReq = new QueryTrackReq();
QueryTrackParam queryTrackParam = new QueryTrackParam();
- queryTrackParam.setCom(CompanyConstant.YD);
+// queryTrackParam.setCom(CompanyConstant.YD);
+ queryTrackParam.setCom(com);
queryTrackParam.setNum(num);
queryTrackParam.setFrom(from);
queryTrackParam.setTo(to);
diff --git a/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml b/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml
index 4be8e48..70f2159 100644
--- a/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml
+++ b/ruoyi-service/ruoyi-order/src/main/resources/mapper/order/OrderMapper.xml
@@ -62,7 +62,7 @@
point,
order_status as status,
distribution_mode as distributionMode
- from t_order where del_flag = 0 and pay_status = 2 and end_time is not null and distribution_mode != 2
+ from t_order where del_flag = 0 and pay_status = 2
<if test="null != item.code and '' != item.code">
and order_number like CONCAT('%', #{item.code}, '%')
</if>
@@ -85,7 +85,7 @@
and order_status in (4, 8)
</if>
<if test="null != item.shopId">
- and shop_id = #{item.shopId} and address_json is null
+ and shop_id = #{item.shopId} and distribution_mode != 2
</if>
order by create_time desc
</select>
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java
index 31c9504..d564c72 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopController.java
@@ -270,7 +270,7 @@
if (!shopService.cheUserByPhone(phone)) {
return R.fail("该手机号未注册");
}
- if (shop.getPid()!=null){
+ if (shop.getPid() != null && shop.getPid() != 0){
Shop shopP = shopService.getById(shop.getPid());
if (shopP.getPid()!=null&&shopP.getPid()!=0&& shopP.getPid().equals(shop.getId())){
return R.fail("门店之间不能互相作为上级门店");
diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopWithdrawController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopWithdrawController.java
index be86361..ad93c40 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopWithdrawController.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/ShopWithdrawController.java
@@ -263,9 +263,9 @@
@PostMapping("/withdrawalCallback")
public Object withdrawalCallback(@RequestBody SinglePayCallbackResult singlePayCallbackResult){
Integer status = singlePayCallbackResult.getStatus();
+ String merchantOrderNo = singlePayCallbackResult.getMerchantOrderNo();
+ ShopWithdraw shopWithdraw = shopWithdrawService.getById(merchantOrderNo);
if(203 == status || 205 == status){
- String merchantOrderNo = singlePayCallbackResult.getMerchantOrderNo();
- ShopWithdraw shopWithdraw = shopWithdrawService.getById(merchantOrderNo);
if(1 == shopWithdraw.getStatus()){
shopWithdraw.setStatus(2);
shopWithdraw.setArrivalTime(LocalDateTime.now());
@@ -274,8 +274,35 @@
JSONObject jsonObject = new JSONObject();
jsonObject.put("statusCode", 2001);
return jsonObject;
+ }else{
+ //回退金额和添加变动明细
+ Shop shop = shopService.getById(shopWithdraw.getShopId());
+ BigDecimal balance = shop.getBalance();
+ BigDecimal canWithdrawMoney = shop.getCanWithdrawMoney();
+ BigDecimal withdrawMoney = shop.getWithdrawMoney();
+ shop.setBalance(balance.add(shopWithdraw.getMoney()).setScale(2, RoundingMode.HALF_EVEN));
+ shop.setCanWithdrawMoney(canWithdrawMoney.add(shopWithdraw.getMoney()).setScale(2, RoundingMode.HALF_EVEN));
+ shop.setWithdrawMoney(withdrawMoney.subtract(shopWithdraw.getMoney()).setScale(2, RoundingMode.HALF_EVEN));
+ shopService.updateById(shop);
+ //添加门店变动明细
+ ShopBalanceStatement shopBalanceStatement = new ShopBalanceStatement();
+ shopBalanceStatement.setShopId(shop.getId());
+ shopBalanceStatement.setType(4);
+ shopBalanceStatement.setHistoricalBalance(balance);
+ shopBalanceStatement.setVariableAmount(shopWithdraw.getMoney());
+ shopBalanceStatement.setBalance(shop.getBalance());
+ shopBalanceStatement.setCreateUserId(shopWithdraw.getAuditUserId());
+ shopBalanceStatement.setCreateTime(LocalDateTime.now());
+ shopBalanceStatement.setObjectId(shopWithdraw.getId());
+ shopBalanceStatementService.save(shopBalanceStatement);
+ shopWithdraw.setStatus(3);
+ shopWithdraw.setRemark(singlePayCallbackResult.getErrorCodeDesc());
+ shopWithdrawService.updateById(shopWithdraw);
+
+ JSONObject jsonObject = new JSONObject();
+ jsonObject.put("statusCode", 2001);
+ return jsonObject;
}
- return new JSONObject();
}
}
--
Gitblit v1.7.1