202508151822
This commit is contained in:
parent
bae71b2015
commit
9f3b9a55eb
|
|
@ -1,53 +0,0 @@
|
|||
import request from '@/utils/request'
|
||||
|
||||
// 查询wechat_transfer列表
|
||||
export function listTransfer(query) {
|
||||
return request({
|
||||
url: '/system/transfer/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询wechat_transfer详细
|
||||
export function getTransfer(id) {
|
||||
return request({
|
||||
url: '/system/transfer/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
// 查询wechat_transfer详细
|
||||
export function getUserDataList() {
|
||||
return request({
|
||||
url: '/system/transfer/getUsersDataList',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 新增wechat_transfer
|
||||
export function addTransfer(data) {
|
||||
return request({
|
||||
url: '/system/transfer',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改wechat_transfer
|
||||
export function updateTransfer(data) {
|
||||
return request({
|
||||
url: '/system/transfer',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除wechat_transfer
|
||||
export function delTransfer(id) {
|
||||
return request({
|
||||
url: '/system/transfer/' + id,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
import request from '@/utils/request'
|
||||
|
||||
// 查询wechat_transfer列表
|
||||
export function listTransfer(query) {
|
||||
return request({
|
||||
url: '/system/transfer/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询wechat_transfer详细
|
||||
export function getTransfer(id) {
|
||||
return request({
|
||||
url: '/system/transfer/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
getUserDataList () {
|
||||
getUserDataList().then(response => {
|
||||
this.userDataList = response.data
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
|
||||
// 新增wechat_transfer
|
||||
export function addTransfer(data) {
|
||||
return request({
|
||||
url: '/system/transfer',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改wechat_transfer
|
||||
export function updateTransfer(data) {
|
||||
return request({
|
||||
url: '/system/transfer',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除wechat_transfer
|
||||
export function delTransfer(id) {
|
||||
return request({
|
||||
url: '/system/transfer/' + id,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
15
pom.xml
15
pom.xml
|
|
@ -151,11 +151,26 @@
|
|||
</dependency>
|
||||
|
||||
<!-- excel工具 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-scratchpad</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.xmlbeans</groupId>
|
||||
<artifactId>xmlbeans</artifactId>
|
||||
<version>3.1.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- velocity代码生成使用模板 -->
|
||||
<dependency>
|
||||
|
|
|
|||
|
|
@ -60,18 +60,23 @@
|
|||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>5.2.3</version>
|
||||
<version>4.1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>5.2.3</version>
|
||||
<version>4.1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml-schemas</artifactId>
|
||||
<artifactId>poi-scratchpad</artifactId>
|
||||
<version>4.1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.xmlbeans</groupId>
|
||||
<artifactId>xmlbeans</artifactId>
|
||||
<version>3.1.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
|
|
|||
|
|
@ -4310,10 +4310,17 @@ public class AppleOrderController extends BaseController {
|
|||
if (goodsOrder.getStatus() != 3L) {
|
||||
return AppletControllerUtil.appletError("订单状态不正确,无法确认收货");
|
||||
}
|
||||
|
||||
// 6. 更新订单状态为已收货
|
||||
int updateResult=0;
|
||||
GoodsOrder goodsOrder1=new GoodsOrder();
|
||||
goodsOrder1.setMainOrderId(goodsOrder.getMainOrderId());
|
||||
List<GoodsOrder> list=goodsOrderService.selectGoodsOrderList(goodsOrder1);
|
||||
for (GoodsOrder goodsOrder2 : list) {
|
||||
goodsOrder.setStatus(4L);
|
||||
int updateResult = goodsOrderService.updateGoodsOrder(goodsOrder);
|
||||
updateResult += goodsOrderService.updateGoodsOrder(goodsOrder);
|
||||
}
|
||||
// 6. 更新订单状态为已收货
|
||||
// goodsOrder.setStatus(4L);
|
||||
// int updateResult = goodsOrderService.updateGoodsOrder(goodsOrder);
|
||||
|
||||
if (updateResult > 0) {
|
||||
// 7. 添加订单日志
|
||||
|
|
@ -4753,20 +4760,21 @@ public class AppleOrderController extends BaseController {
|
|||
// return AppletControllerUtil.appletError("订单状态不正确,无法申请退货");
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
||||
UsersPayBefor usersPayBefor = usersPayBeforService.selectUsersPayBeforByOrderId(goodsOrder.getMainOrderId());
|
||||
// 6. 验证退款金额不能超过支付金额
|
||||
BigDecimal payPrice = goodsOrder.getPayPrice() != null ? goodsOrder.getPayPrice() : BigDecimal.ZERO;
|
||||
BigDecimal payPrice = usersPayBefor.getAllmoney() != null ? usersPayBefor.getAllmoney() : BigDecimal.ZERO;
|
||||
if (refundAmount.compareTo(payPrice) > 0) {
|
||||
return AppletControllerUtil.appletError("退款金额不能超过支付金额");
|
||||
}
|
||||
|
||||
// 7. 更新订单退货信息
|
||||
goodsOrder.setReturntype(Long.valueOf(refundType));
|
||||
goodsOrder.setReturnreason(refundReason);
|
||||
goodsOrder.setReturnfiledata(voucher);
|
||||
goodsOrder.setStatus(20L); // 设置为退货状态
|
||||
goodsOrder.setReturntime(new Date());
|
||||
goodsOrder.setReturnstatus(1L);
|
||||
goodsOrder.setReturnmoney(refundAmount);
|
||||
//修改状态
|
||||
int updateResult=0;
|
||||
GoodsOrder goodsOrder1=new GoodsOrder();
|
||||
goodsOrder1.setMainOrderId(usersPayBefor.getOrderid());
|
||||
List<GoodsOrder> goodsOrders = goodsOrderService.selectGoodsOrderList(goodsOrder1);
|
||||
for (GoodsOrder goodsOrder2 : goodsOrders) {
|
||||
// 构建退货日志JSON数组
|
||||
JSONArray returnJsonArray = new JSONArray();
|
||||
JSONObject returnJsonObject = new JSONObject();
|
||||
|
|
@ -4778,11 +4786,25 @@ public class AppleOrderController extends BaseController {
|
|||
JSONObject returnJsonObject2 = new JSONObject();
|
||||
returnJsonObject2.put("title","退款中");
|
||||
returnJsonObject2.put("content","平台将在72小时为您处理,请耐心等待!");
|
||||
goodsOrder.setReturnshow(returnJsonObject2.toJSONString());
|
||||
goodsOrder.setReturnjson(returnJsonArray.toJSONString());
|
||||
goodsOrder2.setReturntype(Long.valueOf(refundType));
|
||||
goodsOrder2.setReturnreason(refundReason);
|
||||
goodsOrder2.setReturnfiledata(voucher);
|
||||
goodsOrder2.setStatus(20L); // 设置为退货状态
|
||||
goodsOrder2.setReturntime(new Date());
|
||||
goodsOrder2.setReturnstatus(1L);
|
||||
goodsOrder2.setReturnmoney(refundAmount);
|
||||
goodsOrder2.setReturnshow(returnJsonObject2.toJSONString());
|
||||
goodsOrder2.setReturnjson(returnJsonArray.toJSONString());
|
||||
|
||||
// 8. 更新订单
|
||||
int updateResult = goodsOrderService.updateGoodsOrder(goodsOrder);
|
||||
updateResult += goodsOrderService.updateGoodsOrder(goodsOrder2);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// 7. 更新订单退货信息
|
||||
|
||||
|
||||
|
||||
if (updateResult > 0) {
|
||||
// 9. 添加订单日志
|
||||
|
|
|
|||
|
|
@ -1171,11 +1171,20 @@ public class ApplePayController extends BaseController {
|
|||
// 微信支付
|
||||
if (wxMoney.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
// 金额为0,直接走后续逻辑
|
||||
payBefor.setStatus(2L); // 已支付
|
||||
payBefor.setPaytime(new Date());
|
||||
usersPayBeforService.updateUsersPayBefor(payBefor);
|
||||
// payBefor.setStatus(2L); // 已支付
|
||||
// payBefor.setPaytime(new Date());
|
||||
// usersPayBeforService.updateUsersPayBefor(payBefor);
|
||||
//扣减消费金服务金
|
||||
BenefitPointsUtil.deductServiceAndConsumption(payBefor.getOid(), user, payBefor.getServicemoney(), payBefor.getShopmoney());
|
||||
int flg= BenefitPointsUtil.creatServerOrderData(payBefor);
|
||||
if (flg==0){
|
||||
UsersPayBefor newpayBefor = usersPayBeforService.selectUsersPayBeforByOrderId(orderNo);
|
||||
if (newpayBefor!=null){
|
||||
// 创建订单
|
||||
newpayBefor.setStatus(2L);
|
||||
usersPayBeforService.updateUsersPayBefor(newpayBefor);
|
||||
}
|
||||
}
|
||||
//BenefitPointsUtil.deductServiceAndConsumption(payBefor.getOid(), user, payBefor.getServicemoney(), payBefor.getShopmoney());
|
||||
//回调方法用来处理订单相关数据
|
||||
OrderUtil.prepayCallback(payBefor, user);
|
||||
payResult.put("istowx", 1);
|
||||
|
|
@ -1199,11 +1208,20 @@ public class ApplePayController extends BaseController {
|
|||
// 余额支付
|
||||
if (yeMoney.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
// 金额为0,直接走后续逻辑
|
||||
payBefor.setStatus(2L); // 已支付
|
||||
payBefor.setPaytime(new Date());
|
||||
usersPayBeforService.updateUsersPayBefor(payBefor);
|
||||
// payBefor.setStatus(2L); // 已支付
|
||||
// payBefor.setPaytime(new Date());
|
||||
// usersPayBeforService.updateUsersPayBefor(payBefor);
|
||||
//扣减消费金服务金
|
||||
BenefitPointsUtil.deductServiceAndConsumption(payBefor.getOid(), user, payBefor.getServicemoney(), payBefor.getShopmoney());
|
||||
// BenefitPointsUtil.deductServiceAndConsumption(payBefor.getOid(), user, payBefor.getServicemoney(), payBefor.getShopmoney());
|
||||
int flg= BenefitPointsUtil.creatServerOrderData(payBefor);
|
||||
if (flg==0){
|
||||
UsersPayBefor newpayBefor = usersPayBeforService.selectUsersPayBeforByOrderId(orderNo);
|
||||
if (newpayBefor!=null){
|
||||
// 创建订单
|
||||
newpayBefor.setStatus(2L);
|
||||
usersPayBeforService.updateUsersPayBefor(newpayBefor);
|
||||
}
|
||||
}
|
||||
//回调方法用来处理订单相关数据
|
||||
OrderUtil.prepayCallback(payBefor, user);
|
||||
|
||||
|
|
@ -1219,12 +1237,21 @@ public class ApplePayController extends BaseController {
|
|||
);
|
||||
if (balanceResult != null && Boolean.TRUE.equals(balanceResult.get("success"))) {
|
||||
// 更新预支付记录状态
|
||||
payBefor.setStatus(2L); // 已支付
|
||||
payBefor.setPaytime(new Date());
|
||||
usersPayBeforService.updateUsersPayBefor(payBefor);
|
||||
// payBefor.setStatus(2L); // 已支付
|
||||
// payBefor.setPaytime(new Date());
|
||||
// usersPayBeforService.updateUsersPayBefor(payBefor);
|
||||
OrderUtil.prepayCallback(payBefor, user);
|
||||
//扣减消费金服务金
|
||||
BenefitPointsUtil.deductServiceAndConsumption(payBefor.getOid(), user, payBefor.getServicemoney(), payBefor.getShopmoney());
|
||||
int flg= BenefitPointsUtil.creatServerOrderData(payBefor);
|
||||
if (flg==0){
|
||||
UsersPayBefor newpayBefor = usersPayBeforService.selectUsersPayBeforByOrderId(orderNo);
|
||||
if (newpayBefor!=null){
|
||||
// 创建订单
|
||||
newpayBefor.setStatus(2L);
|
||||
usersPayBeforService.updateUsersPayBefor(newpayBefor);
|
||||
}
|
||||
}
|
||||
//BenefitPointsUtil.deductServiceAndConsumption(payBefor.getOid(), user, payBefor.getServicemoney(), payBefor.getShopmoney());
|
||||
//IntegralAndBenefitUtil.processIntegralAndBenefit(payBefor.getAllmoney(), payBefor.getOrderid(), user.getId(), payBefor.getId());
|
||||
// IntegralAndBenefitUtil.paymentPostProcess(payBefor, user.getId());
|
||||
payResult.put("istowx", 2);
|
||||
|
|
@ -1242,8 +1269,17 @@ public class ApplePayController extends BaseController {
|
|||
usersPayBeforService.updateUsersPayBefor(payBefor);
|
||||
OrderUtil.prepayCallback(payBefor, user);
|
||||
//扣减消费金服务金
|
||||
BenefitPointsUtil.deductServiceAndConsumption(payBefor.getOid(), user, payBefor.getServicemoney(), payBefor.getShopmoney());
|
||||
// BenefitPointsUtil.deductServiceAndConsumption(payBefor.getOid(), user, payBefor.getServicemoney(), payBefor.getShopmoney());
|
||||
// IntegralAndBenefitUtil.paymentPostProcess(payBefor, user.getId());
|
||||
int flg= BenefitPointsUtil.creatServerOrderData(payBefor);
|
||||
if (flg==0){
|
||||
UsersPayBefor newpayBefor = usersPayBeforService.selectUsersPayBeforByOrderId(orderNo);
|
||||
if (newpayBefor!=null){
|
||||
// 创建订单
|
||||
newpayBefor.setStatus(2L);
|
||||
usersPayBeforService.updateUsersPayBefor(newpayBefor);
|
||||
}
|
||||
}
|
||||
payResult.put("istowx", 1);
|
||||
return AppletControllerUtil.appletSuccess("支付成功");
|
||||
}
|
||||
|
|
@ -1276,7 +1312,16 @@ public class ApplePayController extends BaseController {
|
|||
usersPayBeforService.updateUsersPayBefor(payBefor);
|
||||
OrderUtil.prepayCallback(payBefor, user);
|
||||
//扣减消费金服务金
|
||||
BenefitPointsUtil.deductServiceAndConsumption(payBefor.getOid(), user, payBefor.getServicemoney(), payBefor.getShopmoney());
|
||||
int flg= BenefitPointsUtil.creatServerOrderData(payBefor);
|
||||
if (flg==0){
|
||||
UsersPayBefor newpayBefor = usersPayBeforService.selectUsersPayBeforByOrderId(orderNo);
|
||||
if (newpayBefor!=null){
|
||||
// 创建订单
|
||||
newpayBefor.setStatus(2L);
|
||||
usersPayBeforService.updateUsersPayBefor(newpayBefor);
|
||||
}
|
||||
}
|
||||
//BenefitPointsUtil.deductServiceAndConsumption(payBefor.getOid(), user, payBefor.getServicemoney(), payBefor.getShopmoney());
|
||||
// IntegralAndBenefitUtil.processIntegralAndBenefit(payBefor.getAllmoney(), payBefor.getOrderid(), user.getId(), payBefor.getId());
|
||||
// IntegralAndBenefitUtil.paymentPostProcess(payBefor, user.getId());
|
||||
payResult.put("istowx", 2);
|
||||
|
|
@ -1501,16 +1546,6 @@ public class ApplePayController extends BaseController {
|
|||
return AppletControllerUtil.appletWarning("次卡使用记录不存在");
|
||||
}
|
||||
|
||||
// // 4. 验证权限(只能退款自己的次卡)
|
||||
// if (!useCard.getUid().equals(user.getId())) {
|
||||
// return AppletControllerUtil.appletWarning("无权操作该次卡记录");
|
||||
// }
|
||||
|
||||
// // 5. 验证退款状态
|
||||
// if (useCard.getStatus() == null || useCard.getStatus() != 2L) {
|
||||
// return AppletControllerUtil.appletWarning("该次卡记录状态不允许退款,只有已支付的次卡才能退款");
|
||||
// }
|
||||
|
||||
// 6. 验证是否已有退款记录
|
||||
if (useCard.getStatus() == 3L) {
|
||||
return AppletControllerUtil.appletWarning("该次卡已申请退款,请勿重复操作");
|
||||
|
|
@ -1521,43 +1556,17 @@ public class ApplePayController extends BaseController {
|
|||
1,
|
||||
1,
|
||||
"次卡退款",
|
||||
WechatPayUtil.PAY_FH + "/api/secondary/card/refund/notify"
|
||||
WechatPayUtil.PAY_FH + "/api/worker/cika/notify"
|
||||
);
|
||||
// 7. 调用微信退款接口
|
||||
// Map<String, Object> refundResult = wechatPayV3Util.refund(
|
||||
// useCard.getOrderid(), // 原订单号
|
||||
// useCard.getPaymoney(), // 退款金额
|
||||
// "次卡退款" // 退款原因
|
||||
// );
|
||||
|
||||
// 8. 处理退款结果
|
||||
if (refundResult != null && Boolean.TRUE.equals(refundResult.get("success"))) {
|
||||
// 9. 更新次卡使用记录状态为退款状态
|
||||
useCard.setStatus(3L); // 3=退款状态
|
||||
useCard.setRemark("退款成功,退款时间:" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
|
||||
|
||||
int updateResult = userUseSecondaryCardService.updateUserUseSecondaryCard(useCard);
|
||||
if (updateResult > 0) {
|
||||
Map<String, Object> responseData = new HashMap<>();
|
||||
responseData.put("orderid", useCard.getOrderid());
|
||||
responseData.put("refundAmount", useCard.getPaymoney());
|
||||
responseData.put("refundTime", new Date());
|
||||
responseData.put("message", "退款申请成功");
|
||||
|
||||
logger.info("次卡退款成功 - 用户ID: {}, 次卡使用记录ID: {}, 退款金额: {}",
|
||||
user.getId(), useCardId, useCard.getPaymoney());
|
||||
|
||||
return AppletControllerUtil.appletSuccess(responseData);
|
||||
return AppletControllerUtil.appletSuccess("操作成功");
|
||||
} else {
|
||||
return AppletControllerUtil.appletWarning("退款状态更新失败");
|
||||
}
|
||||
} else {
|
||||
String errorMsg = refundResult != null ? (String) refundResult.get("message") : "微信退款失败";
|
||||
logger.error("次卡退款失败 - 用户ID: {}, 次卡使用记录ID: {}, 错误信息: {}",
|
||||
user.getId(), useCardId, errorMsg);
|
||||
return AppletControllerUtil.appletWarning("退款申请失败:" + errorMsg);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("次卡退款异常 - 用户ID: {}, 参数: {}, 异常: {}",
|
||||
request.getHeader("token"), params, e.getMessage());
|
||||
|
|
|
|||
|
|
@ -4056,15 +4056,11 @@ public class AppletController extends BaseController {
|
|||
}
|
||||
|
||||
}
|
||||
// // 5. 验证订单状态是否可以取消
|
||||
// if (order.getStatus() != 1L) {
|
||||
// return AppletControllerUtil.appletWarning("当前订单状态不可取消");
|
||||
// }
|
||||
|
||||
// 6. 更新订单状态为已取消(5)
|
||||
Order updateOrder = new Order();
|
||||
updateOrder.setId(orderId);
|
||||
|
||||
//设置订单支付的金额为0,防止开票
|
||||
updateOrder.setPayPrice(new BigDecimal(0));
|
||||
updateOrder.setStatus(5L);
|
||||
int result = orderService.updateOrder(updateOrder);
|
||||
if (result > 0) {
|
||||
|
|
@ -4088,14 +4084,20 @@ public class AppletController extends BaseController {
|
|||
//如果有支付信息就要进行退款
|
||||
System.out.println("=== 开始退款处理,订单号: " + order.getOrderId() + " ===");
|
||||
if (usersPayBefor != null) {
|
||||
|
||||
//退回其他对应支付时产生的金额和积分
|
||||
BenefitPointsUtil.refundServiceAndConsumption(order.getId(), user, usersPayBefor.getServicemoney(),usersPayBefor.getShopmoney());
|
||||
System.out.println("=== 开始退款处理,2222222222订单号: " + usersPayBefor.getStatus() + " ===");
|
||||
// if (usersPayBefor.getStatus() == 2){
|
||||
System.out.println("=== 开始退款处理,2222222222订单号: " + order.getOrderId() + " ===");
|
||||
refundUtil.refundOrder(order.getOrderId());
|
||||
// }
|
||||
int flg= BenefitPointsUtil.refundServerOrderData(usersPayBefor);
|
||||
if(flg==0){
|
||||
UsersPayBefor newusersPayBefor = usersPayBeforService.selectUsersPayBeforByOrderId(order.getOrderId());
|
||||
//退款里面金额退款结束,就开始回滚订单状态,添加日志
|
||||
newusersPayBefor.setStatus(3L); // 设置为已退款状态
|
||||
usersPayBeforService.updateUsersPayBefor(newusersPayBefor);
|
||||
}
|
||||
// BenefitPointsUtil.refundServiceAndConsumption(order.getId(), user, usersPayBefor.getServicemoney(),usersPayBefor.getShopmoney());
|
||||
// System.out.println("=== 开始退款处理,2222222222订单号: " + usersPayBefor.getStatus() + " ===");
|
||||
// // if (usersPayBefor.getStatus() == 2){
|
||||
// System.out.println("=== 开始退款处理,2222222222订单号: " + order.getOrderId() + " ===");
|
||||
// refundUtil.refundOrder(order.getOrderId());
|
||||
// // }
|
||||
}
|
||||
|
||||
return AppletControllerUtil.appletSuccess("取消成功");
|
||||
|
|
@ -7527,7 +7529,7 @@ public class AppletController extends BaseController {
|
|||
System.out.println("快速提现成功"+result);
|
||||
WechatTransfer wechatTransfer = new WechatTransfer();
|
||||
wechatTransfer.setUid(user.getId());
|
||||
wechatTransfer.setMoney(moneyBigDecimal);
|
||||
wechatTransfer.setMoney(moneyBigDecimal);//
|
||||
wechatTransfer.setUname(user.getName());
|
||||
wechatTransfer.setOrderId(orderId);
|
||||
wechatTransfer.setStatus(1L);
|
||||
|
|
|
|||
|
|
@ -31,11 +31,13 @@ import com.ruoyi.common.utils.poi.ExcelUtil;
|
|||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
|
@ -47,8 +49,7 @@ import org.slf4j.LoggerFactory;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/system/GoodsOrder")
|
||||
public class GoodsOrderController extends BaseController
|
||||
{
|
||||
public class GoodsOrderController extends BaseController {
|
||||
private static final Logger log = LoggerFactory.getLogger(GoodsOrderController.class);
|
||||
|
||||
@Autowired
|
||||
|
|
@ -61,6 +62,8 @@ public class GoodsOrderController extends BaseController
|
|||
private IUserAddressService userAddressService;
|
||||
@Autowired
|
||||
private ISiteDeliveryService siteDeliveryService;
|
||||
@Autowired
|
||||
private IUsersPayBeforService usersPayBeforService;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -68,26 +71,30 @@ public class GoodsOrderController extends BaseController
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:GoodsOrder:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(GoodsOrder goodsOrder)
|
||||
{
|
||||
public TableDataInfo list(GoodsOrder goodsOrder) {
|
||||
startPage();
|
||||
List<GoodsOrder> list = goodsOrderService.selectGoodsOrdergrouBymAIDList(goodsOrder);
|
||||
for(GoodsOrder goodsOrderdata:list){
|
||||
for (GoodsOrder goodsOrderdata : list) {
|
||||
goodsOrderdata.setOrderId(goodsOrderdata.getMainOrderId());
|
||||
ServiceGoods serviceGoods=serviceGoodsService.selectServiceGoodsById(goodsOrderdata.getProductId());
|
||||
if(serviceGoods!=null){
|
||||
ServiceGoods serviceGoods = serviceGoodsService.selectServiceGoodsById(goodsOrderdata.getProductId());
|
||||
if (serviceGoods != null) {
|
||||
goodsOrderdata.setProductName(serviceGoods.getTitle());
|
||||
}
|
||||
if(goodsOrderdata.getAddressId()!=null){
|
||||
UserAddress userAddress=userAddressService.selectUserAddressById(goodsOrderdata.getAddressId());
|
||||
if (userAddress != null){
|
||||
UsersPayBefor usersPayBefor = usersPayBeforService.selectUsersPayBeforByOrderId(goodsOrderdata.getMainOrderId());
|
||||
if (usersPayBefor != null) {
|
||||
goodsOrderdata.setTotalPrice(usersPayBefor.getAllmoney());
|
||||
goodsOrderdata.setPayPrice(usersPayBefor.getAllmoney().subtract(usersPayBefor.getReturnmoney()));
|
||||
}
|
||||
if (goodsOrderdata.getAddressId() != null) {
|
||||
UserAddress userAddress = userAddressService.selectUserAddressById(goodsOrderdata.getAddressId());
|
||||
if (userAddress != null) {
|
||||
goodsOrderdata.setLatitude(userAddress.getLatitude());
|
||||
goodsOrderdata.setLongitude(userAddress.getLongitude());
|
||||
goodsOrderdata.setAdressinfo(userAddress.getAddressInfo()+userAddress.getInfo());
|
||||
goodsOrderdata.setAdressinfo(userAddress.getAddressInfo() + userAddress.getInfo());
|
||||
}
|
||||
}
|
||||
Users users=usersService.selectUsersById(goodsOrderdata.getUid());
|
||||
if(users !=null){
|
||||
}
|
||||
Users users = usersService.selectUsersById(goodsOrderdata.getUid());
|
||||
if (users != null) {
|
||||
goodsOrderdata.setUname(users.getName());
|
||||
goodsOrderdata.setUphone(users.getPhone());
|
||||
}
|
||||
|
|
@ -96,6 +103,7 @@ public class GoodsOrderController extends BaseController
|
|||
}
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@GetMapping("/getByMainOrderId/{mainOrderId}")
|
||||
public AjaxResult getGoodsOrderByMainOrderId(@PathVariable String mainOrderId) {
|
||||
try {
|
||||
|
|
@ -187,8 +195,7 @@ public class GoodsOrderController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:GoodsOrder:export')")
|
||||
@Log(title = "商品订单", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, GoodsOrder goodsOrder)
|
||||
{
|
||||
public void export(HttpServletResponse response, GoodsOrder goodsOrder) {
|
||||
List<GoodsOrder> list = goodsOrderService.selectGoodsOrderList(goodsOrder);
|
||||
ExcelUtil<GoodsOrder> util = new ExcelUtil<GoodsOrder>(GoodsOrder.class);
|
||||
util.exportExcel(response, list, "商品订单数据");
|
||||
|
|
@ -199,26 +206,25 @@ public class GoodsOrderController extends BaseController
|
|||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:GoodsOrder:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||||
{
|
||||
GoodsOrder goodsOrderdata =goodsOrderService.selectGoodsOrderById(id);
|
||||
if(goodsOrderdata.getAddressId()!=null){
|
||||
UserAddress userAddress=userAddressService.selectUserAddressById(goodsOrderdata.getAddressId());
|
||||
if (userAddress != null){
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||
GoodsOrder goodsOrderdata = goodsOrderService.selectGoodsOrderById(id);
|
||||
if (goodsOrderdata.getAddressId() != null) {
|
||||
UserAddress userAddress = userAddressService.selectUserAddressById(goodsOrderdata.getAddressId());
|
||||
if (userAddress != null) {
|
||||
goodsOrderdata.setLatitude(userAddress.getLatitude());
|
||||
goodsOrderdata.setLongitude(userAddress.getLongitude());
|
||||
goodsOrderdata.setAdressinfo(userAddress.getAddressInfo()+userAddress.getInfo());
|
||||
goodsOrderdata.setAdressinfo(userAddress.getAddressInfo() + userAddress.getInfo());
|
||||
}
|
||||
//ISiteDeliveryService siteDeliveryService;
|
||||
if (goodsOrderdata.getDeliveryId()!=null){
|
||||
SiteDelivery siteDelivery=siteDeliveryService.selectSiteDeliveryById(goodsOrderdata.getDeliveryId());
|
||||
if(siteDelivery!=null){
|
||||
if (goodsOrderdata.getDeliveryId() != null) {
|
||||
SiteDelivery siteDelivery = siteDeliveryService.selectSiteDeliveryById(goodsOrderdata.getDeliveryId());
|
||||
if (siteDelivery != null) {
|
||||
goodsOrderdata.setDeliveryName(siteDelivery.getTitle());
|
||||
}
|
||||
}
|
||||
|
||||
Users users=usersService.selectUsersById(goodsOrderdata.getUid());
|
||||
if(users !=null){
|
||||
Users users = usersService.selectUsersById(goodsOrderdata.getUid());
|
||||
if (users != null) {
|
||||
goodsOrderdata.setUname(users.getName());
|
||||
goodsOrderdata.setUphone(users.getPhone());
|
||||
}
|
||||
|
|
@ -233,11 +239,10 @@ public class GoodsOrderController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:GoodsOrder:add')")
|
||||
@Log(title = "商品订单", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody GoodsOrder goodsOrder)
|
||||
{
|
||||
if (goodsOrder.getAddressId()!=null){
|
||||
UserAddress userAddress=userAddressService.selectUserAddressById(goodsOrder.getAddressId());
|
||||
if (userAddress!=null){
|
||||
public AjaxResult add(@RequestBody GoodsOrder goodsOrder) {
|
||||
if (goodsOrder.getAddressId() != null) {
|
||||
UserAddress userAddress = userAddressService.selectUserAddressById(goodsOrder.getAddressId());
|
||||
if (userAddress != null) {
|
||||
goodsOrder.setName(userAddress.getName());
|
||||
goodsOrder.setPhone(userAddress.getPhone());
|
||||
|
||||
|
|
@ -245,9 +250,9 @@ public class GoodsOrderController extends BaseController
|
|||
}
|
||||
|
||||
}
|
||||
if (goodsOrder.getProductId()!=null){
|
||||
ServiceGoods serviceGoods=serviceGoodsService.selectServiceGoodsById(goodsOrder.getProductId());
|
||||
if (serviceGoods!=null){
|
||||
if (goodsOrder.getProductId() != null) {
|
||||
ServiceGoods serviceGoods = serviceGoodsService.selectServiceGoodsById(goodsOrder.getProductId());
|
||||
if (serviceGoods != null) {
|
||||
|
||||
goodsOrder.setGoodPrice(serviceGoods.getPrice());
|
||||
}
|
||||
|
|
@ -262,16 +267,15 @@ public class GoodsOrderController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:GoodsOrder:edit')")
|
||||
@Log(title = "商品订单", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody GoodsOrder goodsOrder)
|
||||
{
|
||||
GoodsOrder goodsOrderdata=goodsOrderService.selectGoodsOrderById(goodsOrder.getId());
|
||||
if (goodsOrderdata.getStatus()==2L&&goodsOrder.getStatus()==3L){
|
||||
SiteDelivery siteDelivery=siteDeliveryService.selectSiteDeliveryById(goodsOrder.getDeliveryId());
|
||||
if (siteDelivery!=null){
|
||||
JSONObject jsonObject= new JSONObject();
|
||||
jsonObject.put("wlgs",siteDelivery.getTitle());
|
||||
jsonObject.put("wldh",goodsOrder.getDeliveryNum());
|
||||
OrderUtil.addgoodsorderlog(goodsOrder.getId(),goodsOrder.getOrderId(),"订单已发货","2",jsonObject,2L);
|
||||
public AjaxResult edit(@RequestBody GoodsOrder goodsOrder) {
|
||||
GoodsOrder goodsOrderdata = goodsOrderService.selectGoodsOrderById(goodsOrder.getId());
|
||||
if (goodsOrderdata.getStatus() == 2L && goodsOrder.getStatus() == 3L) {
|
||||
SiteDelivery siteDelivery = siteDeliveryService.selectSiteDeliveryById(goodsOrder.getDeliveryId());
|
||||
if (siteDelivery != null) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("wlgs", siteDelivery.getTitle());
|
||||
jsonObject.put("wldh", goodsOrder.getDeliveryNum());
|
||||
OrderUtil.addgoodsorderlog(goodsOrder.getId(), goodsOrder.getOrderId(), "订单已发货", "2", jsonObject, 2L);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -284,8 +288,7 @@ public class GoodsOrderController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:GoodsOrder:remove')")
|
||||
@Log(title = "商品订单", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids)
|
||||
{
|
||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||
return toAjax(goodsOrderService.deleteGoodsOrderByIds(ids));
|
||||
}
|
||||
|
||||
|
|
@ -295,8 +298,7 @@ public class GoodsOrderController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:GoodsOrder:edit')")
|
||||
@Log(title = "售后申请处理", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/processAfterSale")
|
||||
public AjaxResult processAfterSale(@RequestBody JSONObject params)
|
||||
{
|
||||
public AjaxResult processAfterSale(@RequestBody JSONObject params) {
|
||||
try {
|
||||
java.text.SimpleDateFormat dateFormat = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Long id = params.getLong("id");
|
||||
|
|
@ -345,8 +347,8 @@ public class GoodsOrderController extends BaseController
|
|||
// 驳回申请
|
||||
newStatus = 6L;
|
||||
logMessage = "拒绝退款";
|
||||
returnJsonObject2.put("title","拒绝退款");
|
||||
returnJsonObject2.put("content","拒绝原因"+reamk);
|
||||
returnJsonObject2.put("title", "拒绝退款");
|
||||
returnJsonObject2.put("content", "拒绝原因" + reamk);
|
||||
} else if ("approve".equals(action)) {
|
||||
// 同意申请
|
||||
if (goodsOrder.getReturntype() != null) {
|
||||
|
|
@ -354,15 +356,15 @@ public class GoodsOrderController extends BaseController
|
|||
// 仅退款
|
||||
newStatus = 2L;
|
||||
logMessage = "同意退款";
|
||||
content="商家已同意申请,72小时内完成您的退款操作";
|
||||
returnJsonObject2.put("title","退款成功");
|
||||
returnJsonObject2.put("content","平台以退款"+reamk);
|
||||
content = "商家已同意申请,72小时内完成您的退款操作";
|
||||
returnJsonObject2.put("title", "退款成功");
|
||||
returnJsonObject2.put("content", "平台以退款" + reamk);
|
||||
} else if (goodsOrder.getReturntype() == 2) {
|
||||
// 退货退款
|
||||
newStatus = 3L;
|
||||
logMessage = "商品寄回";
|
||||
returnJsonObject2.put("title","请寄回物品");
|
||||
returnJsonObject2.put("content","平台将在收到货物72小时为您处理,请耐心等待!");
|
||||
returnJsonObject2.put("title", "请寄回物品");
|
||||
returnJsonObject2.put("content", "平台将在收到货物72小时为您处理,请耐心等待!");
|
||||
} else {
|
||||
return error("售后类型错误");
|
||||
}
|
||||
|
|
@ -376,8 +378,8 @@ public class GoodsOrderController extends BaseController
|
|||
}
|
||||
newStatus = 6L;
|
||||
logMessage = "驳回退款";
|
||||
returnJsonObject2.put("title","拒绝退款");
|
||||
returnJsonObject2.put("content","拒绝原因"+reamk);
|
||||
returnJsonObject2.put("title", "拒绝退款");
|
||||
returnJsonObject2.put("content", "拒绝原因" + reamk);
|
||||
} else if ("approve_refund".equals(action)) {
|
||||
// 同意退款(平台收货后)
|
||||
if (goodsOrder.getReturnstatus() != 4) {
|
||||
|
|
@ -411,7 +413,7 @@ public class GoodsOrderController extends BaseController
|
|||
|
||||
newStatus = 5L;
|
||||
logMessage = "同意退款";
|
||||
returnJsonObject2.put("title","退款成功");
|
||||
returnJsonObject2.put("title", "退款成功");
|
||||
returnJsonObject2.put("content", refundContent);
|
||||
|
||||
} catch (NumberFormatException e) {
|
||||
|
|
@ -461,8 +463,7 @@ public class GoodsOrderController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:GoodsOrder:edit')")
|
||||
@Log(title = "订单发货", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/shipOrder")
|
||||
public AjaxResult shipOrder(@RequestBody GoodsOrder goodsOrder)
|
||||
{
|
||||
public AjaxResult shipOrder(@RequestBody GoodsOrder goodsOrder) {
|
||||
try {
|
||||
// 验证订单是否存在
|
||||
GoodsOrder existingOrder = goodsOrderService.selectGoodsOrderById(goodsOrder.getId());
|
||||
|
|
@ -510,7 +511,7 @@ public class GoodsOrderController extends BaseController
|
|||
goodsOrderdata.setSendTime(goodsOrder.getSendTime());
|
||||
goodsOrderdata.setMark(goodsOrder.getMark());
|
||||
goodsOrderdata.setStatus(3L); // 设置为已发货状态
|
||||
count+= goodsOrderService.updateGoodsOrder(goodsOrderdata);
|
||||
count += goodsOrderService.updateGoodsOrder(goodsOrderdata);
|
||||
}
|
||||
// 更新订单
|
||||
|
||||
|
|
@ -546,8 +547,7 @@ public class GoodsOrderController extends BaseController
|
|||
@PreAuthorize("@ss.hasPermi('system:GoodsOrder:edit')")
|
||||
@Log(title = "Excel导入批量发货", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/batchShipByExcel")
|
||||
public AjaxResult batchShipByExcel(@RequestParam("file") MultipartFile file)
|
||||
{
|
||||
public AjaxResult batchShipByExcel(@RequestParam("file") MultipartFile file) {
|
||||
try {
|
||||
if (file.isEmpty()) {
|
||||
return error("请选择要上传的Excel文件");
|
||||
|
|
|
|||
|
|
@ -46,6 +46,21 @@ public class OrderLogController extends BaseController
|
|||
return getDataTable(list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询订单服务记录列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:OrderLog:list')")
|
||||
@GetMapping("/getAllList")
|
||||
public AjaxResult getAllList(OrderLog orderLog)
|
||||
{
|
||||
|
||||
List<OrderLog> list = orderLogService.selectOrderLogList(orderLog);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 导出订单服务记录列表
|
||||
*/
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -444,29 +444,6 @@ public class UsersPayBeforController extends BaseController
|
|||
if (paymentInfo == null) {
|
||||
return error("未找到支付记录");
|
||||
}
|
||||
|
||||
// 根据servicetype查询对应订单
|
||||
Order order = null;
|
||||
if (paymentInfo.getServicetype() != null) {
|
||||
if (paymentInfo.getServicetype() == 1) {
|
||||
// 服务类型为1,调用orderService根据orderid查询订单
|
||||
order = orderService.selectOrderByOrderId(orderId);
|
||||
} else if (paymentInfo.getServicetype() == 2) {
|
||||
// 服务类型为2,调用goodsOrderService根据mainOrderId查询订单
|
||||
GoodsOrder goodsOrder = new GoodsOrder();
|
||||
goodsOrder.setMainOrderId(orderId);
|
||||
List<GoodsOrder> goodsOrders = goodsOrderService.selectGoodsOrderList(goodsOrder);
|
||||
if (goodsOrders != null && !goodsOrders.isEmpty()) {
|
||||
// 使用第一个商品订单的orderId查询订单
|
||||
//order = orderService.selectOrderByOrderId(goodsOrders.get(0).getOrderId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if (order == null) {
|
||||
// return error("订单不存在");
|
||||
// }
|
||||
|
||||
List<UsersPayBefor> payRecords = usersPayBeforService.selectPayDetailsByOrderId(orderId);
|
||||
System.out.println("000%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"+payRecords.size());
|
||||
if (payRecords == null || payRecords.isEmpty()) {
|
||||
|
|
@ -610,337 +587,53 @@ public class UsersPayBeforController extends BaseController
|
|||
BigDecimal remainingServiceGoldRefund = serviceGoldRefund;
|
||||
BigDecimal remainingCouponRefund = couponRefund;
|
||||
|
||||
|
||||
// 修复:确保BigDecimal转换正确,处理可能的null值和类型问题
|
||||
// BigDecimal wechatRefund = BigDecimal.ZERO;
|
||||
// BigDecimal balanceRefund = BigDecimal.ZERO;
|
||||
// BigDecimal shoppingGoldRefund = BigDecimal.ZERO;
|
||||
// BigDecimal serviceGoldRefund = BigDecimal.ZERO;
|
||||
// BigDecimal memberDiscountRefund = BigDecimal.ZERO;
|
||||
// BigDecimal couponRefund = BigDecimal.ZERO;
|
||||
|
||||
// 修复:正确计算各项支付方式的退款金额
|
||||
for (UsersPayBefor record : payRecords) {
|
||||
BigDecimal currentRefunded = record.getReturnmoney() != null ? record.getReturnmoney() : BigDecimal.ZERO;
|
||||
|
||||
// 计算本次退款中该记录应承担的退款金额
|
||||
BigDecimal recordRefundAmount = BigDecimal.ZERO;
|
||||
|
||||
// 根据该记录的支付方式分配退款金额
|
||||
if (record.getWxmoney() != null && record.getWxmoney().compareTo(BigDecimal.ZERO) > 0) {
|
||||
// 修复:计算该记录微信支付的剩余可退款金额
|
||||
BigDecimal wxRemaining = record.getWxmoney().subtract(currentRefunded);
|
||||
if (wxRemaining.compareTo(BigDecimal.ZERO) > 0 && remainingWechatRefund.compareTo(BigDecimal.ZERO) > 0) {
|
||||
record.setWxmoney(record.getWxmoney().subtract(currentRefunded));
|
||||
if (remainingWechatRefund.compareTo(BigDecimal.ZERO) > 0) {
|
||||
BenefitPointsUtil.theWXmoneyChangeResult(record, remainingWechatRefund, "微信支付退款成功");
|
||||
}
|
||||
// BigDecimal wxRemaining = record.getWxmoney().subtract(currentRefunded);
|
||||
// if (wxRemaining.compareTo(BigDecimal.ZERO) > 0 && remainingWechatRefund.compareTo(BigDecimal.ZERO) > 0) {
|
||||
// record.setWxmoney(wxRemaining);
|
||||
// BigDecimal wxRefund = remainingWechatRefund.min(wxRemaining);
|
||||
// recordRefundAmount = recordRefundAmount.add(wxRefund);
|
||||
// remainingWechatRefund = remainingWechatRefund.subtract(wxRefund);
|
||||
// }
|
||||
}
|
||||
//余额
|
||||
if (record.getYemoney() != null && record.getYemoney().compareTo(BigDecimal.ZERO) > 0) {
|
||||
// 修复:计算该记录余额支付的剩余可退款金额
|
||||
BigDecimal yeRemaining = record.getYemoney().subtract(currentRefunded);
|
||||
if (yeRemaining.compareTo(BigDecimal.ZERO) > 0 && remainingBalanceRefund.compareTo(BigDecimal.ZERO) > 0) {
|
||||
record.setYemoney(record.getYemoney().subtract(remainingBalanceRefund));
|
||||
// System.out.println("=== 调用退款工具方法前的参数验证 yeRemaining======================================================"+yeRemaining);
|
||||
// System.out.println("=== 调用退款工具方法前的参数验证 record.getYemoney()======================================================"+record.getYemoney());
|
||||
// System.out.println("=== 调用退款工具方法前的参数验证 currentRefunded======================================================"+currentRefunded);
|
||||
//
|
||||
// record.setYemoney(yeRemaining);
|
||||
// BigDecimal yeRefund = remainingBalanceRefund.min(yeRemaining);
|
||||
// recordRefundAmount = recordRefundAmount.add(yeRefund);
|
||||
// remainingBalanceRefund = remainingBalanceRefund.subtract(yeRefund);
|
||||
if (remainingBalanceRefund.compareTo(BigDecimal.ZERO) > 0) {
|
||||
BenefitPointsUtil.theYueChangeResult(record, remainingBalanceRefund, 1, "余额支付退款");
|
||||
}
|
||||
}
|
||||
|
||||
if (record.getShopmoney() != null && record.getShopmoney().compareTo(BigDecimal.ZERO) > 0) {
|
||||
// 修复:计算该记录购物金的剩余可退款金额
|
||||
BigDecimal shopRemaining = record.getShopmoney().subtract(currentRefunded);
|
||||
if (shopRemaining.compareTo(BigDecimal.ZERO) > 0 && remainingShoppingGoldRefund.compareTo(BigDecimal.ZERO) > 0) {
|
||||
|
||||
// record.setShopmoney(shopRemaining);
|
||||
// BigDecimal shopRefund = remainingShoppingGoldRefund.min(shopRemaining);
|
||||
// recordRefundAmount = recordRefundAmount.add(shopRefund);
|
||||
// remainingShoppingGoldRefund = remainingShoppingGoldRefund.subtract(shopRefund);
|
||||
if (remainingShoppingGoldRefund.compareTo(BigDecimal.ZERO) > 0) {
|
||||
BenefitPointsUtil.theBenefitPointsGoodsMoneyChangeResult(record, remainingShoppingGoldRefund, 1, "订单退款");
|
||||
}
|
||||
}
|
||||
|
||||
if (record.getServicemoney() != null && record.getServicemoney().compareTo(BigDecimal.ZERO) > 0) {
|
||||
// 修复:计算该记录服务金的剩余可退款金额
|
||||
BigDecimal serviceRemaining = record.getServicemoney().subtract(currentRefunded);
|
||||
if (serviceRemaining.compareTo(BigDecimal.ZERO) > 0 && remainingServiceGoldRefund.compareTo(BigDecimal.ZERO) > 0) {
|
||||
|
||||
if (remainingServiceGoldRefund.compareTo(BigDecimal.ZERO) > 0) {
|
||||
BenefitPointsUtil.theBenefitPointsServiceMoneyChangeResult(record,remainingServiceGoldRefund,1,"订单退款");
|
||||
}
|
||||
}
|
||||
|
||||
if (record.getCouponmoney() != null && record.getCouponmoney().compareTo(BigDecimal.ZERO) > 0) {
|
||||
// 修复:计算该记录优惠券的剩余可退款金额
|
||||
BigDecimal couponRemaining = record.getCouponmoney().subtract(currentRefunded);
|
||||
if (couponRemaining.compareTo(BigDecimal.ZERO) > 0 && remainingCouponRefund.compareTo(BigDecimal.ZERO) > 0) {
|
||||
BenefitPointsUtil.theBenefitPointsGoodsMoneyChangeResult(record,remainingShoppingGoldRefund,1,"订单退款");
|
||||
|
||||
if (remainingCouponRefund.compareTo(BigDecimal.ZERO) > 0) {
|
||||
BenefitPointsUtil.theyouhuimoneyChangeResult(record,1);
|
||||
}
|
||||
}
|
||||
|
||||
// 如果该记录有退款金额,则更新
|
||||
if (recordRefundAmount.compareTo(BigDecimal.ZERO) > 0) {
|
||||
BigDecimal newTotalRefunded = currentRefunded.add(recordRefundAmount);
|
||||
|
||||
// 如果累计退款金额等于或超过支付金额,设置为已退款状态
|
||||
if (newTotalRefunded.compareTo(record.getAllmoney()) >= 0) {
|
||||
record.setStatus(3L); // 完全退款
|
||||
} else {
|
||||
record.setStatus(2L); // 部分退款
|
||||
}
|
||||
|
||||
record.setReturnmoney(newTotalRefunded);
|
||||
usersPayBeforService.updateUsersPayBefor(record);
|
||||
|
||||
System.out.println("更新支付记录: ID=" + record.getId() +
|
||||
", 原退款金额=" + currentRefunded +
|
||||
", 本次退款=" + recordRefundAmount +
|
||||
", 新总退款=" + newTotalRefunded +
|
||||
", 状态=" + record.getStatus());
|
||||
}
|
||||
}
|
||||
|
||||
// 调用退款工具方法实现真实的业务退款与金额变动
|
||||
// 使用原始参数,而不是被修改的副本
|
||||
System.out.println("=== 调用退款工具方法前的参数验证 ===");
|
||||
System.out.println("原始退款参数:");
|
||||
System.out.println(" orderId: " + orderId);
|
||||
System.out.println(" wechatRefund: " + wechatRefund);
|
||||
System.out.println(" balanceRefund: " + balanceRefund);
|
||||
System.out.println(" shoppingGoldRefund: " + shoppingGoldRefund);
|
||||
System.out.println(" serviceGoldRefund: " + serviceGoldRefund);
|
||||
System.out.println(" memberDiscountRefund: " + memberDiscountRefund);
|
||||
System.out.println(" couponRefund: " + couponRefund);
|
||||
System.out.println(" refundRemark: " + refundRemark);
|
||||
|
||||
// 验证参数类型和值
|
||||
System.out.println("参数类型检查:");
|
||||
System.out.println(" balanceRefund类型: " + balanceRefund.getClass().getName());
|
||||
System.out.println(" balanceRefund值: " + balanceRefund);
|
||||
System.out.println(" balanceRefund比较0: " + balanceRefund.compareTo(BigDecimal.ZERO));
|
||||
|
||||
// Map<String, Object> refundResult = refundUtil.processUnifiedRefund(
|
||||
// orderId, wechatRefund, balanceRefund, shoppingGoldRefund,
|
||||
// serviceGoldRefund, memberDiscountRefund, couponRefund, refundRemark
|
||||
// );
|
||||
return success("退款成功");
|
||||
// if (refundResult != null && (Boolean) refundResult.get("success")) {
|
||||
// return success("退款成功");
|
||||
// } else {
|
||||
// String errorMsg = (String) refundResult.get("message");
|
||||
// return error(errorMsg != null ? errorMsg : "退款处理失败");
|
||||
// }
|
||||
|
||||
} catch (Exception e) {
|
||||
return error("退款失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
// /**
|
||||
// * 统一退款方法 - 核心逻辑:直接修改预支付表金额
|
||||
// */
|
||||
// @Log(title = "统一退款", businessType = BusinessType.UPDATE)
|
||||
// @PostMapping("/unifiedRefund")
|
||||
// public AjaxResult unifiedRefund(@RequestBody Map<String, Object> params)
|
||||
// {
|
||||
// try {
|
||||
// System.out.println("=== 开始统一退款 ===");
|
||||
// System.out.println("接收到的参数: " + params);
|
||||
//
|
||||
// // 1. 获取订单ID
|
||||
// String orderId = params.get("orderId") == null ? null : params.get("orderId").toString();
|
||||
// if (orderId == null || orderId.trim().isEmpty()) {
|
||||
// return error("订单ID不能为空");
|
||||
// }
|
||||
//
|
||||
// // 2. 获取各项退款金额
|
||||
// BigDecimal wechatRefund = parseBigDecimalSafely(params.get("wechatRefund"));
|
||||
// BigDecimal balanceRefund = parseBigDecimalSafely(params.get("balanceRefund"));
|
||||
// BigDecimal shoppingGoldRefund = parseBigDecimalSafely(params.get("shoppingGoldRefund"));
|
||||
// BigDecimal serviceGoldRefund = parseBigDecimalSafely(params.get("serviceGoldRefund"));
|
||||
// BigDecimal couponRefund = parseBigDecimalSafely(params.get("couponRefund"));
|
||||
// String refundRemark = params.get("refundRemark") == null ? "" : params.get("refundRemark").toString();
|
||||
//
|
||||
// // 3. 计算总退款金额
|
||||
// BigDecimal totalRefund = wechatRefund.add(balanceRefund).add(shoppingGoldRefund)
|
||||
// .add(serviceGoldRefund).add(couponRefund);
|
||||
//
|
||||
// if (totalRefund.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
// return error("退款金额必须大于0");
|
||||
// }
|
||||
//
|
||||
// System.out.println("=== 退款金额 ===");
|
||||
// System.out.println("微信退款: " + wechatRefund + "元");
|
||||
// System.out.println("余额退款: " + balanceRefund + "元");
|
||||
// System.out.println("购物金退款: " + shoppingGoldRefund + "元");
|
||||
// System.out.println("服务金退款: " + serviceGoldRefund + "元");
|
||||
// System.out.println("优惠券退款: " + couponRefund + "元");
|
||||
// System.out.println("总退款金额: " + totalRefund + "元");
|
||||
//
|
||||
// // 4. 核心逻辑:调用IUsersPayBeforService查询orderid获取预支付数据
|
||||
// UsersPayBefor paymentInfo = usersPayBeforService.selectUsersPayBeforByOrderId(orderId);
|
||||
// if (paymentInfo == null) {
|
||||
// return error("未找到支付记录");
|
||||
// }
|
||||
//
|
||||
// // 5. 获取原始金额
|
||||
// BigDecimal originalWxMoney = paymentInfo.getWxmoney() != null ? paymentInfo.getWxmoney() : BigDecimal.ZERO;
|
||||
// BigDecimal originalYeMoney = paymentInfo.getYemoney() != null ? paymentInfo.getYemoney() : BigDecimal.ZERO;
|
||||
// BigDecimal originalShopMoney = paymentInfo.getShopmoney() != null ? paymentInfo.getShopmoney() : BigDecimal.ZERO;
|
||||
// BigDecimal originalServiceMoney = paymentInfo.getServicemoney() != null ? paymentInfo.getServicemoney() : BigDecimal.ZERO;
|
||||
// BigDecimal originalCouponMoney = paymentInfo.getCouponmoney() != null ? paymentInfo.getCouponmoney() : BigDecimal.ZERO;
|
||||
// BigDecimal originalMemberMoney = paymentInfo.getMembermoney() != null ? paymentInfo.getMembermoney() : BigDecimal.ZERO;
|
||||
//
|
||||
// System.out.println("=== 原始金额 ===");
|
||||
// System.out.println("微信支付: " + originalWxMoney + "元");
|
||||
// System.out.println("余额支付: " + originalYeMoney + "元");
|
||||
// System.out.println("购物金: " + originalShopMoney + "元");
|
||||
// System.out.println("服务金: " + originalServiceMoney + "元");
|
||||
// System.out.println("优惠券: " + originalCouponMoney + "元");
|
||||
// System.out.println("会员优惠: " + originalMemberMoney + "元");
|
||||
//
|
||||
// // 6. 验证退款金额不超过原始金额
|
||||
// if (wechatRefund.compareTo(originalWxMoney) > 0) {
|
||||
// return error("微信退款金额不能超过微信支付金额");
|
||||
// }
|
||||
// if (balanceRefund.compareTo(originalYeMoney) > 0) {
|
||||
// return error("余额退款金额不能超过余额支付金额");
|
||||
// }
|
||||
// if (shoppingGoldRefund.compareTo(originalShopMoney) > 0) {
|
||||
// return error("购物金退款金额不能超过购物金金额");
|
||||
// }
|
||||
// if (serviceGoldRefund.compareTo(originalServiceMoney) > 0) {
|
||||
// return error("服务金退款金额不能超过服务金金额");
|
||||
// }
|
||||
// // 优惠券只能全额退:要么退0,要么等于原优惠券金额
|
||||
// if (couponRefund.compareTo(BigDecimal.ZERO) > 0) {
|
||||
// if (originalCouponMoney.compareTo(BigDecimal.ZERO) == 0) {
|
||||
// return error("无可退的优惠券金额");
|
||||
// }
|
||||
// if (couponRefund.compareTo(originalCouponMoney) != 0) {
|
||||
// return error("优惠券只能全额退,原金额:¥" + originalCouponMoney + ",本次退款:¥" + couponRefund);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 7. 核心逻辑:根据各个项目的退款进行修改上面的金额
|
||||
// BigDecimal newWxMoney = originalWxMoney.subtract(wechatRefund);
|
||||
// BigDecimal newYeMoney = originalYeMoney.subtract(balanceRefund);
|
||||
// BigDecimal newShopMoney = originalShopMoney.subtract(shoppingGoldRefund);
|
||||
// BigDecimal newServiceMoney = originalServiceMoney.subtract(serviceGoldRefund);
|
||||
// BigDecimal newCouponMoney = originalCouponMoney.subtract(couponRefund);
|
||||
//
|
||||
// // 确保金额不为负数
|
||||
// if (newWxMoney.compareTo(BigDecimal.ZERO) < 0) newWxMoney = BigDecimal.ZERO;
|
||||
// if (newYeMoney.compareTo(BigDecimal.ZERO) < 0) newYeMoney = BigDecimal.ZERO;
|
||||
// if (newShopMoney.compareTo(BigDecimal.ZERO) < 0) newShopMoney = BigDecimal.ZERO;
|
||||
// if (newServiceMoney.compareTo(BigDecimal.ZERO) < 0) newServiceMoney = BigDecimal.ZERO;
|
||||
// if (newCouponMoney.compareTo(BigDecimal.ZERO) < 0) newCouponMoney = BigDecimal.ZERO;
|
||||
//
|
||||
// // 8. 计算新的总金额(不包括会员优惠)
|
||||
// BigDecimal newTotalAmount = newWxMoney.add(newYeMoney).add(newShopMoney)
|
||||
// .add(newServiceMoney).add(newCouponMoney);
|
||||
//
|
||||
// // 9. 获取当前已退款金额并计算新的总退款金额
|
||||
// BigDecimal currentRefunded = paymentInfo.getReturnmoney() != null ? paymentInfo.getReturnmoney() : BigDecimal.ZERO;
|
||||
// BigDecimal newTotalRefunded = currentRefunded.add(totalRefund);
|
||||
//
|
||||
// System.out.println("=== 修改后的金额 ===");
|
||||
// System.out.println("微信支付: " + newWxMoney + "元 (原: " + originalWxMoney + " - 退: " + wechatRefund + ")");
|
||||
// System.out.println("余额支付: " + newYeMoney + "元 (原: " + originalYeMoney + " - 退: " + balanceRefund + ")");
|
||||
// System.out.println("购物金: " + newShopMoney + "元 (原: " + originalShopMoney + " - 退: " + shoppingGoldRefund + ")");
|
||||
// System.out.println("服务金: " + newServiceMoney + "元 (原: " + originalServiceMoney + " - 退: " + serviceGoldRefund + ")");
|
||||
// System.out.println("优惠券: " + newCouponMoney + "元 (原: " + originalCouponMoney + " - 退: " + couponRefund + ")");
|
||||
// System.out.println("会员优惠: " + originalMemberMoney + "元 (不参与退款)");
|
||||
// System.out.println("新总金额: " + newTotalAmount + "元");
|
||||
// System.out.println("累计退款: " + newTotalRefunded + "元");
|
||||
//
|
||||
// // 10. 更新预支付表数据
|
||||
// paymentInfo.setWxmoney(newWxMoney);
|
||||
// paymentInfo.setYemoney(newYeMoney);
|
||||
// paymentInfo.setShopmoney(newShopMoney);
|
||||
// paymentInfo.setServicemoney(newServiceMoney);
|
||||
// paymentInfo.setCouponmoney(newCouponMoney);
|
||||
// paymentInfo.setAllmoney(newTotalAmount);
|
||||
// paymentInfo.setReturnmoney(newTotalRefunded);
|
||||
//
|
||||
// // 设置状态
|
||||
// if (newTotalRefunded.compareTo(newTotalAmount) >= 0) {
|
||||
// paymentInfo.setStatus(3L); // 完全退款
|
||||
// } else {
|
||||
// paymentInfo.setStatus(2L); // 部分退款
|
||||
// }
|
||||
//
|
||||
// // 11. 保存更新
|
||||
// int updateResult = usersPayBeforService.updateUsersPayBefor(paymentInfo);
|
||||
// if (updateResult <= 0) {
|
||||
// return error("支付记录更新失败");
|
||||
// }
|
||||
//
|
||||
// // 12. 记录退款日志
|
||||
// OrderLog orderLog = new OrderLog();
|
||||
// orderLog.setOrderId(orderId);
|
||||
// orderLog.setOid(999L);
|
||||
// orderLog.setTitle("退款");
|
||||
// orderLog.setOrdertype(paymentInfo.getServicetype());
|
||||
// orderLog.setType(new BigDecimal(11));
|
||||
//
|
||||
// // 构建退款说明
|
||||
// StringBuilder refundDesc = new StringBuilder("统一退款:");
|
||||
// if (wechatRefund.compareTo(BigDecimal.ZERO) > 0) {
|
||||
// refundDesc.append("微信支付退款¥").append(wechatRefund).append(",");
|
||||
// }
|
||||
// if (balanceRefund.compareTo(BigDecimal.ZERO) > 0) {
|
||||
// refundDesc.append("余额退款¥").append(balanceRefund).append(",");
|
||||
// }
|
||||
// if (shoppingGoldRefund.compareTo(BigDecimal.ZERO) > 0) {
|
||||
// refundDesc.append("购物金退款¥").append(shoppingGoldRefund).append(",");
|
||||
// }
|
||||
// if (serviceGoldRefund.compareTo(BigDecimal.ZERO) > 0) {
|
||||
// refundDesc.append("服务金退款¥").append(serviceGoldRefund).append(",");
|
||||
// }
|
||||
// if (couponRefund.compareTo(BigDecimal.ZERO) > 0) {
|
||||
// refundDesc.append("优惠券退款¥").append(couponRefund).append(",");
|
||||
// }
|
||||
//
|
||||
// if (refundDesc.charAt(refundDesc.length() - 1) == ',') {
|
||||
// refundDesc.setLength(refundDesc.length() - 1);
|
||||
// }
|
||||
//
|
||||
// refundDesc.append(",本次退款金额:¥").append(totalRefund);
|
||||
// refundDesc.append(",累计已退款:¥").append(newTotalRefunded);
|
||||
// refundDesc.append(",剩余可退款:¥").append(newTotalAmount);
|
||||
// refundDesc.append("(会员优惠¥").append(originalMemberMoney).append("不参与退款)");
|
||||
//
|
||||
// orderLog.setContent(refundDesc.toString());
|
||||
// orderLogService.insertOrderLog(orderLog);
|
||||
//
|
||||
// // 13. 调用退款工具方法处理业务逻辑
|
||||
// System.out.println("=== 调用退款工具方法 ===");
|
||||
// Map<String, Object> refundResult = refundUtil.processUnifiedRefund(
|
||||
// orderId, wechatRefund, balanceRefund, shoppingGoldRefund,
|
||||
// serviceGoldRefund, BigDecimal.ZERO, couponRefund, refundRemark
|
||||
// );
|
||||
//
|
||||
// if (refundResult != null && (Boolean) refundResult.get("success")) {
|
||||
// System.out.println("✅ 退款处理成功");
|
||||
// return success("退款成功");
|
||||
// } else {
|
||||
// String errorMsg = (String) refundResult.get("message");
|
||||
// return error(errorMsg != null ? errorMsg : "退款处理失败");
|
||||
// }
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// System.err.println("❌ 退款处理异常: " + e.getMessage());
|
||||
// e.printStackTrace();
|
||||
// return error("退款失败:" + e.getMessage());
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,6 +75,16 @@ public class WechatTransferController extends BaseController
|
|||
}
|
||||
return success(usersService.selectUsersList(users));
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计汇总:总申请金额、已到账金额、处理中金额(不含状态3)
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:transfer:list')")
|
||||
@GetMapping("/summary")
|
||||
public AjaxResult summary(WechatTransfer wechatTransfer)
|
||||
{
|
||||
return success(wechatTransferService.selectWechatTransferSummary(wechatTransfer));
|
||||
}
|
||||
/**
|
||||
* 导出wechat_transfer列表
|
||||
*/
|
||||
|
|
@ -84,6 +94,32 @@ public class WechatTransferController extends BaseController
|
|||
public void export(HttpServletResponse response, WechatTransfer wechatTransfer)
|
||||
{
|
||||
List<WechatTransfer> list = wechatTransferService.selectWechatTransferList(wechatTransfer);
|
||||
for(WechatTransfer dd: list){
|
||||
Users users=usersService.selectUsersById(dd.getUid());
|
||||
if (users!=null){
|
||||
dd.setUname(users.getName());
|
||||
}
|
||||
if (dd.getPaid()!=null){
|
||||
if (dd.getPaid()==1){
|
||||
dd.setPaname("已到账");
|
||||
}else{
|
||||
dd.setPaname("未到账");
|
||||
}
|
||||
}else{
|
||||
dd.setPaname("未到账");
|
||||
}
|
||||
if (dd.getStatus()!=null){
|
||||
if (dd.getStatus()==1){
|
||||
dd.setStatusname("待处理");
|
||||
}
|
||||
if (dd.getStatus()==2){
|
||||
dd.setStatusname("处理完成");
|
||||
}
|
||||
if (dd.getStatus()==3){
|
||||
dd.setStatusname("驳回");
|
||||
}
|
||||
}
|
||||
}
|
||||
ExcelUtil<WechatTransfer> util = new ExcelUtil<WechatTransfer>(WechatTransfer.class);
|
||||
util.exportExcel(response, list, "wechat_transfer数据");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public class BenefitPointsUtil {
|
|||
private static final IUsersPayBeforService usersPayBeforService = SpringUtils.getBean(IUsersPayBeforService.class);
|
||||
private static final IUserMemnerConsumptionLogService userMemnerConsumptionLogService = SpringUtils.getBean(IUserMemnerConsumptionLogService.class);
|
||||
private static final IPayMoneyLogService payMoneyLogService = SpringUtils.getBean(IPayMoneyLogService.class);
|
||||
|
||||
private static final ICouponUserService couponUserService = SpringUtils.getBean(ICouponUserService.class);
|
||||
|
||||
|
||||
// 配置常量
|
||||
|
|
@ -102,6 +102,10 @@ public class BenefitPointsUtil {
|
|||
log.error("【错误】订单不存在,订单ID: {}", orderId);
|
||||
return new BenefitPointsResult(false, "订单不存在", null);
|
||||
}
|
||||
UsersPayBefor payBefor = usersPayBeforService.selectUsersPayBeforByOrderId(order.getMainOrderId());
|
||||
if (payBefor == null){
|
||||
return new BenefitPointsResult(false, "订单不存在", null);
|
||||
}
|
||||
// 2. 获取用户信息
|
||||
Users user = usersService.selectUsersById(order.getUid());
|
||||
if (user == null) {
|
||||
|
|
@ -115,7 +119,7 @@ public class BenefitPointsUtil {
|
|||
return new BenefitPointsResult(false, "系统配置获取失败", null);
|
||||
}
|
||||
//处理积分
|
||||
IntegralAndBenefitUtil.processIntegralAndBenefit(money, order.getOrderId(), order.getUid());
|
||||
IntegralAndBenefitUtil.processIntegralAndBenefit(payBefor.getAllmoney(), payBefor.getOrderid(), payBefor.getUid());
|
||||
// //处理库存及销量
|
||||
// OrderUtil.updateInventoryAndSales(order.getOrderId(), 2);
|
||||
|
||||
|
|
@ -443,6 +447,10 @@ public class BenefitPointsUtil {
|
|||
if (userDb != null && userDb.getServicefee() != null && userDb.getServicefee().compareTo(ZERO) > 0) {
|
||||
BigDecimal serviceRate = serviceDeductionRatio.divide(new BigDecimal("100"), 4, ROUND_HALF_UP);
|
||||
serviceMoney = userDb.getServicefee().multiply(serviceRate);
|
||||
//判断一下如果服务抵扣金额大于总金额amount就表示服务金全部抵扣,如果小于就抵扣一部分
|
||||
if (serviceMoney.compareTo(amount) > 0) {
|
||||
serviceMoney=amount;
|
||||
}
|
||||
log.info("【服务金抵扣】用户ID: {}, 服务金余额: {}, 抵扣比例: {}, 抵扣金额: {}",
|
||||
user.getId(), userDb.getServicefee(), serviceDeductionRatio, serviceMoney);
|
||||
}
|
||||
|
|
@ -456,6 +464,9 @@ public class BenefitPointsUtil {
|
|||
if (userDb != null && userDb.getConsumption() != null && userDb.getConsumption().compareTo(ZERO) > 0) {
|
||||
BigDecimal consumptionRate = consumptionDeductionRatio.divide(new BigDecimal("100"), 4, ROUND_HALF_UP);
|
||||
shopMoney = userDb.getConsumption().multiply(consumptionRate);
|
||||
if (shopMoney.compareTo(amount) > 0) {
|
||||
shopMoney=amount;
|
||||
}
|
||||
log.info("【消费金抵扣】用户ID: {}, 消费金余额: {}, 抵扣比例: {}, 抵扣金额: {}",
|
||||
user.getId(), userDb.getConsumption(), consumptionDeductionRatio, shopMoney);
|
||||
}
|
||||
|
|
@ -1166,6 +1177,70 @@ public class BenefitPointsUtil {
|
|||
public UserBenefitPoints getLog() { return log; }
|
||||
public void setLog(UserBenefitPoints log) { this.log = log; }
|
||||
}
|
||||
//这是用户创建订单和退款的时候的调用 减少各类数据
|
||||
|
||||
public static int creatServerOrderData(UsersPayBefor usersPayBefor) {
|
||||
UsersPayBefor usersPayBeforData=usersPayBeforService.selectUsersPayBeforById(usersPayBefor.getId());
|
||||
if(usersPayBeforData!=null){
|
||||
if (usersPayBeforData.getStatus()==1){
|
||||
//微信支付比较特殊在回调里面直接处理就可以,回调里面添加流水修改订单状态即可
|
||||
// if (usersPayBeforData.getWxmoney()!=null&&usersPayBeforData.getWxmoney().compareTo(BigDecimal.ZERO)>0){
|
||||
// theWXmoneyChangeResult(usersPayBeforData,usersPayBeforData.getWxmoney(),"");
|
||||
// }
|
||||
//余额退款
|
||||
if (usersPayBeforData.getYemoney()!=null&&usersPayBeforData.getYemoney().compareTo(BigDecimal.ZERO)>0){
|
||||
theYueChangeResult(usersPayBeforData,usersPayBeforData.getYemoney(),2,"创建订单消费");
|
||||
}
|
||||
//购物金退款
|
||||
if (usersPayBeforData.getShopmoney()!=null&&usersPayBeforData.getShopmoney().compareTo(BigDecimal.ZERO)>0){
|
||||
theBenefitPointsGoodsMoneyChangeResult(usersPayBeforData,usersPayBeforData.getShopmoney(),2,"创建订单消费");
|
||||
}
|
||||
//服务金退款
|
||||
if (usersPayBeforData.getServicemoney()!=null&&usersPayBeforData.getServicemoney().compareTo(BigDecimal.ZERO)>0){
|
||||
theBenefitPointsServiceMoneyChangeResult(usersPayBeforData,usersPayBeforData.getServicemoney(),2,"创建订单消费");
|
||||
}
|
||||
//优惠券退款
|
||||
if (usersPayBeforData.getCouponmoney()!=null&&usersPayBeforData.getCouponmoney().compareTo(BigDecimal.ZERO)>0){
|
||||
theyouhuimoneyChangeResult(usersPayBeforData,2);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
//这是用户取消订单和退款的时候的调用 添加各类数据
|
||||
public static int refundServerOrderData(UsersPayBefor usersPayBefor) {
|
||||
UsersPayBefor usersPayBeforData=usersPayBeforService.selectUsersPayBeforById(usersPayBefor.getId());
|
||||
if(usersPayBeforData!=null) {
|
||||
if (usersPayBeforData.getStatus()==2){
|
||||
//微信退款
|
||||
if (usersPayBeforData.getWxmoney()!=null&&usersPayBeforData.getWxmoney().compareTo(BigDecimal.ZERO)>0){
|
||||
theWXmoneyChangeResult(usersPayBeforData,usersPayBeforData.getWxmoney(),"");
|
||||
}
|
||||
//余额退款
|
||||
if (usersPayBeforData.getYemoney()!=null&&usersPayBeforData.getYemoney().compareTo(BigDecimal.ZERO)>0){
|
||||
theYueChangeResult(usersPayBeforData,usersPayBeforData.getYemoney(),1,"用户取消订单退款");
|
||||
}
|
||||
//购物金退款
|
||||
if (usersPayBeforData.getShopmoney()!=null&&usersPayBeforData.getShopmoney().compareTo(BigDecimal.ZERO)>0){
|
||||
theBenefitPointsGoodsMoneyChangeResult(usersPayBeforData,usersPayBeforData.getShopmoney(),1,"用户取消订单退款");
|
||||
}
|
||||
//服务金退款
|
||||
if (usersPayBeforData.getServicemoney()!=null&&usersPayBeforData.getServicemoney().compareTo(BigDecimal.ZERO)>0){
|
||||
theBenefitPointsServiceMoneyChangeResult(usersPayBeforData,usersPayBeforData.getServicemoney(),1,"用户取消订单退款");
|
||||
}
|
||||
//优惠券退款
|
||||
if (usersPayBeforData.getCouponmoney()!=null&&usersPayBeforData.getCouponmoney().compareTo(BigDecimal.ZERO)>0){
|
||||
theyouhuimoneyChangeResult(usersPayBeforData,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
//服务金变更
|
||||
// private IUsersPayBeforService usersPayBeforService;
|
||||
|
|
@ -1174,14 +1249,24 @@ public class BenefitPointsUtil {
|
|||
Map<String, Object> remap=new HashMap<>();
|
||||
Map<String, Object> config = getSystemConfig();
|
||||
BigDecimal servicefeeRatio = getConfigValue(config, SERVICEFEE_KEY, new BigDecimal("0"));
|
||||
BigDecimal amountService = servicemoney.multiply(servicefeeRatio).divide(new BigDecimal("100"));
|
||||
// BigDecimal amountService = servicemoney.multiply(servicefeeRatio).divide(new BigDecimal("100"));
|
||||
BigDecimal amountService = BigDecimal.ZERO;
|
||||
if (servicefeeRatio.compareTo(BigDecimal.ZERO) > 0) {
|
||||
// 将百分比转换为小数(如10% -> 0.1)
|
||||
BigDecimal ratioDecimal = servicefeeRatio.divide(new BigDecimal("100"), 4, RoundingMode.HALF_UP);
|
||||
// 计算退回金额:Goodsmoney / ratioDecimal
|
||||
amountService = servicemoney.divide(ratioDecimal, 2, RoundingMode.HALF_UP);
|
||||
}
|
||||
Users user = usersService.selectUsersById(usersPayBefor.getUid());
|
||||
UsersPayBefor usersPayBeforData=usersPayBeforService.selectUsersPayBeforById(usersPayBefor.getId());
|
||||
if(usersPayBeforData.getReturnmoney()==null){
|
||||
usersPayBeforData.setReturnmoney(BigDecimal.ZERO);
|
||||
}
|
||||
if (user==null){
|
||||
remap.put("code",2);
|
||||
return remap;
|
||||
}
|
||||
//type 1增加 0减少
|
||||
//type 1增加(用户增加,就是退款的时候用) 0减少
|
||||
if(type==1){
|
||||
user.setServicefee(user.getServicefee().add(amountService));
|
||||
UserBenefitPoints benefitLog = new UserBenefitPoints();
|
||||
|
|
@ -1198,8 +1283,11 @@ public class BenefitPointsUtil {
|
|||
userBenefitPointsService.insertUserBenefitPoints(benefitLog);
|
||||
usersService.updateUsers(user);
|
||||
//增加用户服务金金就是减少预支付的服务金
|
||||
usersPayBeforData.setReturnmoney(usersPayBeforData.getReturnmoney().add(servicemoney));
|
||||
usersPayBeforData.setServicemoney(usersPayBeforData.getServicemoney().subtract(servicemoney));
|
||||
usersPayBeforService.updateUsersPayBefor(usersPayBeforData);
|
||||
//退款的时候就要添加退款金额累加的
|
||||
|
||||
remap.put("code",1);
|
||||
return remap;
|
||||
|
||||
|
|
@ -1219,23 +1307,27 @@ public class BenefitPointsUtil {
|
|||
userBenefitPointsService.insertUserBenefitPoints(benefitLog);
|
||||
usersService.updateUsers(user);
|
||||
//减少用户服务金金就是增加预支付的服务金
|
||||
usersPayBeforData.setServicemoney(usersPayBeforData.getServicemoney().add(servicemoney));
|
||||
usersPayBeforService.updateUsersPayBefor(usersPayBeforData);
|
||||
// usersPayBeforData.setServicemoney(usersPayBeforData.getServicemoney().add(servicemoney));
|
||||
// usersPayBeforService.updateUsersPayBefor(usersPayBeforData);
|
||||
remap.put("code",1);
|
||||
return remap;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//余额变动
|
||||
//余额变动//type 1增加(用户增加,就是退款的时候用) 0减少
|
||||
public static Map<String, Object> theYueChangeResult(UsersPayBefor usersPayBefor,BigDecimal money,int type,String reamk) {
|
||||
Map<String, Object> remap=new HashMap<>();
|
||||
System.out.println("余额变动-------"+money);
|
||||
//余额变动
|
||||
Users user = usersService.selectUsersById(usersPayBefor.getUid());
|
||||
UsersPayBefor usersPayBeforData=usersPayBeforService.selectUsersPayBeforById(usersPayBefor.getId());
|
||||
if(usersPayBeforData.getReturnmoney()==null){
|
||||
usersPayBeforData.setReturnmoney(BigDecimal.ZERO);
|
||||
}
|
||||
if(type==1){
|
||||
user.setBalance(user.getBalance().add(money));
|
||||
usersPayBeforData.setYemoney(usersPayBeforData.getYemoney().subtract(money));
|
||||
|
||||
UserMemnerConsumptionLog userMemnerConsumptionLog=new UserMemnerConsumptionLog();
|
||||
userMemnerConsumptionLog.setUid(Math.toIntExact(user.getId()));
|
||||
userMemnerConsumptionLog.setConsumptiontype(2);
|
||||
|
|
@ -1249,11 +1341,14 @@ public class BenefitPointsUtil {
|
|||
userMemnerConsumptionLog.setOrderid(usersPayBefor.getOrderid());
|
||||
userMemnerConsumptionLogService.insertUserMemnerConsumptionLog(userMemnerConsumptionLog);
|
||||
usersService.updateUsers(user);
|
||||
usersPayBeforData.setYemoney(usersPayBeforData.getYemoney().subtract(money));
|
||||
usersPayBeforData.setReturnmoney(usersPayBeforData.getReturnmoney().add(money));
|
||||
System.out.println("11余额变动-------"+usersPayBeforData.getYemoney());
|
||||
usersPayBeforService.updateUsersPayBefor(usersPayBeforData);
|
||||
remap.put("code",1);
|
||||
}else{
|
||||
user.setBalance(user.getBalance().subtract(money));
|
||||
usersPayBeforData.setYemoney(usersPayBeforData.getYemoney().add(money));
|
||||
// usersPayBeforData.setYemoney(money);
|
||||
UserMemnerConsumptionLog userMemnerConsumptionLog=new UserMemnerConsumptionLog();
|
||||
userMemnerConsumptionLog.setUid(Math.toIntExact(user.getId()));
|
||||
userMemnerConsumptionLog.setConsumptiontype(2);
|
||||
|
|
@ -1267,21 +1362,34 @@ public class BenefitPointsUtil {
|
|||
userMemnerConsumptionLog.setOrderid(usersPayBefor.getOrderid());
|
||||
userMemnerConsumptionLogService.insertUserMemnerConsumptionLog(userMemnerConsumptionLog);
|
||||
usersService.updateUsers(user);
|
||||
usersPayBeforService.updateUsersPayBefor(usersPayBeforData);
|
||||
// usersPayBeforService.updateUsersPayBefor(usersPayBeforData);
|
||||
remap.put("code",1);
|
||||
}
|
||||
|
||||
return remap;
|
||||
}
|
||||
|
||||
//购物金变更
|
||||
//购物金变更//type 1增加(用户增加,就是退款的时候用) 0减少
|
||||
public static Map<String, Object> theBenefitPointsGoodsMoneyChangeResult(UsersPayBefor usersPayBefor,BigDecimal Goodsmoney,int type,String reamk) {
|
||||
//第一步获取系统维护的服务金比例
|
||||
//第一步获取系统维护的购物金比例
|
||||
Map<String, Object> remap=new HashMap<>();
|
||||
Map<String, Object> config = getSystemConfig();
|
||||
BigDecimal goodsfeeRatio = getConfigValue(config, CONSUMPTION_KEY, new BigDecimal("0"));
|
||||
BigDecimal amountService = Goodsmoney.multiply(goodsfeeRatio).divide(new BigDecimal("100"));
|
||||
System.out.println("换算比例-------"+goodsfeeRatio);
|
||||
// 修改计算逻辑:amountGoodsmoney = Goodsmoney / goodsfeeRatio
|
||||
// 例如:goodsfeeRatio=10表示10%,Goodsmoney=5,则amountGoodsmoney=5/0.1=50
|
||||
BigDecimal amountGoodsmoney = BigDecimal.ZERO;
|
||||
if (goodsfeeRatio.compareTo(BigDecimal.ZERO) > 0) {
|
||||
// 将百分比转换为小数(如10% -> 0.1)
|
||||
BigDecimal ratioDecimal = goodsfeeRatio.divide(new BigDecimal("100"), 4, RoundingMode.HALF_UP);
|
||||
// 计算退回金额:Goodsmoney / ratioDecimal
|
||||
amountGoodsmoney = Goodsmoney.divide(ratioDecimal, 2, RoundingMode.HALF_UP);
|
||||
}
|
||||
System.out.println("抵扣金额-------"+amountGoodsmoney);
|
||||
UsersPayBefor usersPayBeforData=usersPayBeforService.selectUsersPayBeforById(usersPayBefor.getId());
|
||||
if(usersPayBeforData.getReturnmoney()==null){
|
||||
usersPayBeforData.setReturnmoney(BigDecimal.ZERO);
|
||||
}
|
||||
Users user = usersService.selectUsersById(usersPayBefor.getUid());
|
||||
if (user==null){
|
||||
remap.put("code",2);
|
||||
|
|
@ -1289,42 +1397,46 @@ public class BenefitPointsUtil {
|
|||
}
|
||||
//type 1增加 0减少
|
||||
if(type==1){
|
||||
user.setConsumption(user.getConsumption().add(amountService));
|
||||
user.setConsumption(user.getConsumption().add(amountGoodsmoney));
|
||||
UserBenefitPoints benefitLog = new UserBenefitPoints();
|
||||
benefitLog.setOrderid(usersPayBefor.getId());
|
||||
benefitLog.setUid(usersPayBefor.getUid());
|
||||
benefitLog.setType(2L);//类别 1服务金 2消费金
|
||||
benefitLog.setOrdertype(1L); //数据类别 1收入 2支出
|
||||
benefitLog.setOrdermoney(usersPayBefor.getAllmoney());
|
||||
benefitLog.setMoney(amountService);
|
||||
benefitLog.setBeformoney(user.getConsumption().subtract(amountService));
|
||||
benefitLog.setMoney(amountGoodsmoney);
|
||||
benefitLog.setBeformoney(user.getConsumption().subtract(amountGoodsmoney));
|
||||
benefitLog.setAftremoney(user.getConsumption());
|
||||
benefitLog.setReamk(reamk);
|
||||
benefitLog.setDotime(new Date());
|
||||
userBenefitPointsService.insertUserBenefitPoints(benefitLog);
|
||||
usersService.updateUsers(user);
|
||||
usersPayBeforData.setReturnmoney(usersPayBeforData.getReturnmoney().add(Goodsmoney));
|
||||
usersPayBeforData.setShopmoney(usersPayBeforData.getShopmoney().subtract(Goodsmoney));
|
||||
usersPayBeforService.updateUsersPayBefor(usersPayBeforData);
|
||||
|
||||
remap.put("code",1);
|
||||
return remap;
|
||||
|
||||
}else{
|
||||
user.setConsumption(user.getConsumption().subtract(amountService));
|
||||
System.out.println("抵扣区间-------"+user.getConsumption().subtract(amountGoodsmoney));
|
||||
user.setConsumption(user.getConsumption().subtract(amountGoodsmoney));
|
||||
UserBenefitPoints benefitLog = new UserBenefitPoints();
|
||||
benefitLog.setOrderid(usersPayBefor.getId());
|
||||
benefitLog.setUid(usersPayBefor.getUid());
|
||||
benefitLog.setType(2L);//类别 1服务金 2消费金
|
||||
benefitLog.setOrdertype(2L); //数据类别 1收入 2支出
|
||||
benefitLog.setOrdermoney(usersPayBefor.getAllmoney());
|
||||
benefitLog.setMoney(amountService);
|
||||
benefitLog.setBeformoney(user.getConsumption().add(amountService));
|
||||
benefitLog.setMoney(amountGoodsmoney);
|
||||
benefitLog.setBeformoney(user.getConsumption().add(amountGoodsmoney));
|
||||
benefitLog.setAftremoney(user.getConsumption());
|
||||
benefitLog.setReamk(reamk);
|
||||
benefitLog.setDotime(new Date());
|
||||
userBenefitPointsService.insertUserBenefitPoints(benefitLog);
|
||||
usersService.updateUsers(user);
|
||||
usersPayBeforData.setShopmoney(usersPayBeforData.getShopmoney().add(Goodsmoney));
|
||||
usersPayBeforService.updateUsersPayBefor(usersPayBeforData);
|
||||
System.out.println("抵扣完成-------"+benefitLog.getId());
|
||||
// usersPayBeforData.setShopmoney(usersPayBeforData.getShopmoney().add(Goodsmoney));
|
||||
// usersPayBeforService.updateUsersPayBefor(usersPayBeforData);
|
||||
remap.put("code",1);
|
||||
return remap;
|
||||
|
||||
|
|
@ -1332,75 +1444,82 @@ public class BenefitPointsUtil {
|
|||
}
|
||||
|
||||
|
||||
//微信支付变动
|
||||
public static Map<String, Object> theWXmoneyChangeResult(UsersPayBefor usersPayBefor,BigDecimal money,int type,String reamk) {
|
||||
//微信支付变动,只有退款
|
||||
public static Map<String, Object> theWXmoneyChangeResult(UsersPayBefor usersPayBefor,BigDecimal money,String reamk) {
|
||||
Map<String, Object> remap=new HashMap<>();
|
||||
//余额变动
|
||||
Users user = usersService.selectUsersById(usersPayBefor.getUid());
|
||||
UsersPayBefor usersPayBeforData=usersPayBeforService.selectUsersPayBeforById(usersPayBefor.getId());
|
||||
if(usersPayBeforData.getReturnmoney()==null){
|
||||
usersPayBeforData.setReturnmoney(BigDecimal.ZERO);
|
||||
}
|
||||
int allmoney=usersPayBefor.getWxmoney().multiply(new BigDecimal(100)).intValue();
|
||||
int tkmoney=money.multiply(new BigDecimal(100)).intValue();
|
||||
WechatPayV3Util WW=new WechatPayV3Util();
|
||||
// 7. 调用微信退款接口
|
||||
Map<String, Object> refundResult = WW.refund(usersPayBeforData.getOrderid(),
|
||||
Map<String, Object> refundResult = WW.refund(
|
||||
usersPayBeforData.getOrderid(),
|
||||
String.valueOf(usersPayBeforData.getId()),
|
||||
allmoney,
|
||||
tkmoney,
|
||||
"订单退款",
|
||||
WechatPayUtil.PAY_FH + "/api/secondary/card/refund/notify"
|
||||
WechatPayUtil.PAY_FH + "/api/secondary/tuikuan/refund/notify"
|
||||
);
|
||||
|
||||
PayMoneyLog payMoneyLog = new PayMoneyLog();
|
||||
if (usersPayBefor != null) {
|
||||
payMoneyLog.setOid(usersPayBefor.getId());
|
||||
if (refundResult != null && Boolean.TRUE.equals(refundResult.get("success"))) {
|
||||
remap.put("success", true);
|
||||
return remap;
|
||||
}
|
||||
payMoneyLog.setOrderId(usersPayBefor.getOrderid());
|
||||
payMoneyLog.setUid(usersPayBefor.getUid());
|
||||
if (user != null) {
|
||||
payMoneyLog.setUname(user.getName());
|
||||
}
|
||||
payMoneyLog.setPrice(money);
|
||||
payMoneyLog.setMark("订单退款");
|
||||
payMoneyLog.setPayTime(new Date());
|
||||
payMoneyLogService.insertPayMoneyLog(payMoneyLog);
|
||||
|
||||
// if(type==1){
|
||||
// user.setBalance(user.getBalance().add(money));
|
||||
// usersPayBeforData.setYemoney(usersPayBeforData.getYemoney().subtract(money));
|
||||
// UserMemnerConsumptionLog userMemnerConsumptionLog=new UserMemnerConsumptionLog();
|
||||
// userMemnerConsumptionLog.setUid(Math.toIntExact(user.getId()));
|
||||
// userMemnerConsumptionLog.setConsumptiontype(2);
|
||||
// userMemnerConsumptionLog.setConsumptiontime(new Date());
|
||||
// userMemnerConsumptionLog.setConsumptionmoney(money);
|
||||
// userMemnerConsumptionLog.setReamk(reamk);
|
||||
// userMemnerConsumptionLog.setBeformoney(user.getBalance().subtract(money));
|
||||
// userMemnerConsumptionLog.setAftermoney(user.getBalance());
|
||||
// userMemnerConsumptionLog.setNowmoney(user.getBalance());
|
||||
// userMemnerConsumptionLog.setType(1);
|
||||
// userMemnerConsumptionLog.setOrderid(usersPayBefor.getOrderid());
|
||||
// userMemnerConsumptionLogService.insertUserMemnerConsumptionLog(userMemnerConsumptionLog);
|
||||
// usersService.updateUsers(user);
|
||||
// usersPayBeforService.updateUsersPayBefor(usersPayBeforData);
|
||||
// remap.put("code",1);
|
||||
// }else{
|
||||
// user.setBalance(user.getBalance().subtract(money));
|
||||
// usersPayBeforData.setYemoney(usersPayBeforData.getYemoney().add(money));
|
||||
// UserMemnerConsumptionLog userMemnerConsumptionLog=new UserMemnerConsumptionLog();
|
||||
// userMemnerConsumptionLog.setUid(Math.toIntExact(user.getId()));
|
||||
// userMemnerConsumptionLog.setConsumptiontype(2);
|
||||
// userMemnerConsumptionLog.setConsumptiontime(new Date());
|
||||
// userMemnerConsumptionLog.setConsumptionmoney(money);
|
||||
// userMemnerConsumptionLog.setReamk(reamk);
|
||||
// userMemnerConsumptionLog.setBeformoney(user.getBalance().add(money));
|
||||
// userMemnerConsumptionLog.setAftermoney(user.getBalance());
|
||||
// userMemnerConsumptionLog.setNowmoney(user.getBalance());
|
||||
// userMemnerConsumptionLog.setType(2);
|
||||
// userMemnerConsumptionLog.setOrderid(usersPayBefor.getOrderid());
|
||||
// userMemnerConsumptionLogService.insertUserMemnerConsumptionLog(userMemnerConsumptionLog);
|
||||
// usersService.updateUsers(user);
|
||||
// usersPayBeforService.updateUsersPayBefor(usersPayBeforData);
|
||||
// remap.put("code",1);
|
||||
// PayMoneyLog payMoneyLog = new PayMoneyLog();
|
||||
// if (usersPayBefor != null) {
|
||||
// payMoneyLog.setOid(usersPayBefor.getId());
|
||||
// }
|
||||
// payMoneyLog.setOrderId(usersPayBefor.getOrderid());
|
||||
// payMoneyLog.setUid(usersPayBefor.getUid());
|
||||
// if (user != null) {
|
||||
// payMoneyLog.setUname(user.getName());
|
||||
// }
|
||||
// payMoneyLog.setPrice(money);
|
||||
// payMoneyLog.setMark(reamk);
|
||||
// payMoneyLog.setPayTime(new Date());
|
||||
// payMoneyLogService.insertPayMoneyLog(payMoneyLog);
|
||||
// usersPayBeforData.setReturnmoney(usersPayBeforData.getReturnmoney().add(money));
|
||||
// usersPayBeforData.setWxmoney(usersPayBefor.getWxmoney().subtract(money));
|
||||
// usersPayBeforService.updateUsersPayBefor(usersPayBeforData);
|
||||
|
||||
return remap;
|
||||
}
|
||||
|
||||
|
||||
//优惠券回款,直接退回优惠券就可以
|
||||
public static Map<String, Object> theyouhuimoneyChangeResult(UsersPayBefor usersPayBefor,int type) {
|
||||
Map<String, Object> remap=new HashMap<>();
|
||||
//余额变动
|
||||
Users user = usersService.selectUsersById(usersPayBefor.getUid());
|
||||
UsersPayBefor usersPayBeforData=usersPayBeforService.selectUsersPayBeforById(usersPayBefor.getId());
|
||||
if(usersPayBeforData.getReturnmoney()==null){
|
||||
usersPayBeforData.setReturnmoney(BigDecimal.ZERO);
|
||||
}
|
||||
//1为退款的时候回滚优惠券
|
||||
if (type==1){
|
||||
CouponUser couponUser=couponUserService.selectCouponUserById(usersPayBefor.getCouponid());
|
||||
if(couponUser!=null){
|
||||
couponUser.setStatus(1L);
|
||||
couponUserService.updateCouponUser(couponUser);
|
||||
}
|
||||
usersPayBeforData.setCouponid( null);
|
||||
usersPayBeforData.setReturnmoney(usersPayBeforData.getReturnmoney().add(usersPayBeforData.getCouponmoney()));
|
||||
usersPayBeforData.setCouponmoney(new BigDecimal("0"));
|
||||
usersPayBeforService.updateUsersPayBefor(usersPayBeforData);
|
||||
}else{
|
||||
CouponUser couponUser=couponUserService.selectCouponUserById(usersPayBefor.getCouponid());
|
||||
if(couponUser!=null){
|
||||
couponUser.setStatus(2L);
|
||||
couponUserService.updateCouponUser(couponUser);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return remap;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ public class WechatPayUtil {
|
|||
|
||||
|
||||
// public static final String PAY_FH = "https://www.huafurenjia.cn/";
|
||||
public static final String PAY_FH = "https://api.huafurenjia.cn/";
|
||||
public static final String PAY_FH = "https://552e105d.r3.cpolar.top/";
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public class WechatTransfer extends BaseEntity
|
|||
private BigDecimal priceMax;
|
||||
|
||||
/** 状态 */
|
||||
@Excel(name = "状态")
|
||||
|
||||
private Long status;
|
||||
|
||||
/** 订单号 */
|
||||
|
|
@ -51,19 +51,28 @@ public class WechatTransfer extends BaseEntity
|
|||
private String openid;
|
||||
|
||||
/** 0:未到账 */
|
||||
@Excel(name = "0:未到账")
|
||||
|
||||
private Long paid;
|
||||
|
||||
/** 0:未到账 */
|
||||
@Excel(name = "是否到账")
|
||||
private String paname;
|
||||
|
||||
/** 0:未到账 */
|
||||
@Excel(name = "申请状态")
|
||||
private String statusname;
|
||||
|
||||
/** 到账时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "到账时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date payTime;
|
||||
|
||||
/** 操作时间 */
|
||||
@Excel(name = "操作时间")
|
||||
|
||||
private Long time;
|
||||
|
||||
/** $column.columnComment */
|
||||
/** 操作时间 */
|
||||
@Excel(name = "操作时间",width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date createdAt;
|
||||
|
||||
/** $column.columnComment */
|
||||
|
|
@ -213,6 +222,23 @@ public class WechatTransfer extends BaseEntity
|
|||
this.priceMax = priceMax;
|
||||
}
|
||||
|
||||
|
||||
public String getStatusname() {
|
||||
return statusname;
|
||||
}
|
||||
|
||||
public void setStatusname(String statusname) {
|
||||
this.statusname = statusname;
|
||||
}
|
||||
|
||||
public String getPaname() {
|
||||
return paname;
|
||||
}
|
||||
|
||||
public void setPaname(String paname) {
|
||||
this.paname = paname;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
|
|
|
|||
|
|
@ -58,4 +58,9 @@ public interface WechatTransferMapper
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteWechatTransferByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 统计汇总:总申请金额、已到账金额、处理中金额(不计入状态3)
|
||||
*/
|
||||
public java.util.Map<String, java.math.BigDecimal> selectWechatTransferSummary(WechatTransfer wechatTransfer);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,4 +58,9 @@ public interface IWechatTransferService
|
|||
* @return 结果
|
||||
*/
|
||||
public int deleteWechatTransferById(Long id);
|
||||
|
||||
/**
|
||||
* 统计汇总:总申请金额、已到账金额、处理中金额(不含状态3)
|
||||
*/
|
||||
public java.util.Map<String, java.math.BigDecimal> selectWechatTransferSummary(WechatTransfer wechatTransfer);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,4 +90,13 @@ public class WechatTransferServiceImpl implements IWechatTransferService
|
|||
{
|
||||
return wechatTransferMapper.deleteWechatTransferById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 统计汇总
|
||||
*/
|
||||
@Override
|
||||
public java.util.Map<String, java.math.BigDecimal> selectWechatTransferSummary(WechatTransfer wechatTransfer)
|
||||
{
|
||||
return wechatTransferMapper.selectWechatTransferSummary(wechatTransfer);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,4 +100,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- 统计汇总:总申请金额、已到账金额、处理中金额(不含状态3) -->
|
||||
<select id="selectWechatTransferSummary" parameterType="WechatTransfer" resultType="java.util.HashMap">
|
||||
select
|
||||
COALESCE(SUM(money),0) as totalApply,
|
||||
COALESCE(SUM(CASE WHEN status = 2 THEN money ELSE 0 END),0) as totalPaid,
|
||||
COALESCE(SUM(CASE WHEN status = 1 THEN money ELSE 0 END),0) as totalProcessing
|
||||
from wechat_transfer
|
||||
<where>
|
||||
<if test="uid != null "> and uid = #{uid} </if>
|
||||
<if test="batchId != null and batchId != ''"> and batch_id like concat('%', #{batchId}, '%')</if>
|
||||
<if test="priceMin != null and priceMax != null">
|
||||
and money BETWEEN #{priceMin} AND #{priceMax}
|
||||
</if>
|
||||
<if test="params.beginPayTime != null and params.beginPayTime != '' and params.endPayTime != null and params.endPayTime != ''"> and pay_time between #{params.beginPayTime} and #{params.endPayTime}</if>
|
||||
<if test="params.beginTime != null and params.beginTime != '' and params.endTime != null and params.endTime != ''"> and time between #{params.beginTime} and #{params.endTime}</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
@ -52,7 +52,7 @@ export function delOrderLog(id) {
|
|||
// 查询退款历史记录
|
||||
export function getRefundHistory(orderId) {
|
||||
return request({
|
||||
url: '/system/OrderLog/list',
|
||||
url: '/system/OrderLog/getAllList',
|
||||
method: 'get',
|
||||
params: {
|
||||
orderId: orderId,
|
||||
|
|
|
|||
|
|
@ -9,6 +9,15 @@ export function listTransfer(query) {
|
|||
})
|
||||
}
|
||||
|
||||
// 查询统计汇总
|
||||
export function getTransferSummary(query) {
|
||||
return request({
|
||||
url: '/system/transfer/summary',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询wechat_transfer详细
|
||||
export function getTransfer(id) {
|
||||
return request({
|
||||
|
|
|
|||
|
|
@ -89,12 +89,25 @@
|
|||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- 统一退款对话框 -->
|
||||
<UnifiedRefundDialog
|
||||
:visible.sync="unifiedRefundDialogVisible"
|
||||
:orderId="currentAfterSaleOrder ? currentAfterSaleOrder.mainOrderId || currentAfterSaleOrder.orderId : ''"
|
||||
:paymentData="currentRefundPaymentData"
|
||||
@success="handleRefundSuccess"
|
||||
/>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import UnifiedRefundDialog from './UnifiedRefundDialog.vue'
|
||||
|
||||
export default {
|
||||
name: "AfterSaleDialog",
|
||||
components: {
|
||||
UnifiedRefundDialog
|
||||
},
|
||||
props: {
|
||||
visible: {
|
||||
type: Boolean,
|
||||
|
|
@ -119,7 +132,9 @@ export default {
|
|||
},
|
||||
data() {
|
||||
return {
|
||||
localVisible: this.visible
|
||||
localVisible: this.visible,
|
||||
unifiedRefundDialogVisible: false,
|
||||
currentRefundPaymentData: null
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
|
@ -153,7 +168,22 @@ export default {
|
|||
this.$emit('reject-refund');
|
||||
},
|
||||
handleApproveRefund() {
|
||||
this.$emit('approve-refund');
|
||||
// 当同意退款时,打开统一退款页面
|
||||
this.currentRefundPaymentData = {
|
||||
wxmoney: this.currentAfterSaleOrder.payPrice || 0,
|
||||
yemoney: 0,
|
||||
shopmoney: 0,
|
||||
servicemoney: 0,
|
||||
membermoney: 0,
|
||||
couponmoney: 0
|
||||
};
|
||||
this.unifiedRefundDialogVisible = true;
|
||||
},
|
||||
handleRefundSuccess() {
|
||||
// 退款成功后关闭统一退款对话框,并通知父组件刷新
|
||||
this.unifiedRefundDialogVisible = false;
|
||||
this.$emit('refund-success');
|
||||
this.$emit('close');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -33,6 +33,9 @@
|
|||
<el-descriptions-item label="美团抵扣金额">
|
||||
<span style="color: #67C23A;">¥{{ prePaymentData.mtmoney ? prePaymentData.mtmoney.toFixed(2) : '0.00' }}</span>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="退款金额">
|
||||
<span style="color: #67C23A;">¥{{ prePaymentData.returnmoney ? prePaymentData.returnmoney.toFixed(2) : '0.00' }}</span>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</div>
|
||||
<div v-else>
|
||||
|
|
|
|||
|
|
@ -44,11 +44,18 @@
|
|||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<!-- 会员优惠单独显示(仅当不为0时) -->
|
||||
<div v-if="actualPaymentData.membermoney && parseFloat(actualPaymentData.membermoney) > 0" class="member-discount-row">
|
||||
<div class="member-discount-item">
|
||||
<span class="member-discount-label">会员优惠:¥{{ formatAmount(actualPaymentData.membermoney) }}</span>
|
||||
<span class="member-discount-note">(平台承担,不参与退款)</span>
|
||||
<!-- 会员优惠和邮费显示在同一行 -->
|
||||
<div class="discount-postage-row">
|
||||
<!-- 会员优惠(仅当不为0时显示) -->
|
||||
<div v-if="actualPaymentData.membermoney && parseFloat(actualPaymentData.membermoney) > 0" class="discount-postage-item">
|
||||
<span class="discount-postage-label">会员优惠:¥{{ formatAmount(actualPaymentData.membermoney) }}</span>
|
||||
<span class="discount-postage-note">(平台承担,不参与退款)</span>
|
||||
</div>
|
||||
|
||||
<!-- 邮费(仅当存在时显示) -->
|
||||
<div v-if="actualPaymentData.postage && parseFloat(actualPaymentData.postage) > 0" class="discount-postage-item">
|
||||
<span class="discount-postage-label">邮费:¥{{ formatAmount(actualPaymentData.postage) }}</span>
|
||||
<span class="discount-postage-note">(此订单邮费{{ formatAmount(actualPaymentData.postage) }}元已计算在订单支付信息内)</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="total-amount">
|
||||
|
|
@ -60,6 +67,7 @@
|
|||
<div class="refund-summary" v-if="refundHistory.length > 0">
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
支付信息
|
||||
<div class="summary-item">
|
||||
<label>累计已退款:</label>
|
||||
<span class="amount refunded">¥{{ formatAmount(totalRefundedAmount) }}</span>
|
||||
|
|
@ -72,24 +80,24 @@
|
|||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<div class="summary-note">
|
||||
<span class="note-text">💡 退款信息</span>
|
||||
<div class="refund-details">
|
||||
<div class="detail-row compact">
|
||||
<span class="detail-label">订单总额:</span>
|
||||
<span class="detail-value">¥{{ formatAmount(actualPaymentData.allmoney) }}</span>
|
||||
<span class="detail-separator">|</span>
|
||||
<span class="detail-label">会员优惠:</span>
|
||||
<span class="detail-value">¥{{ formatAmount(actualPaymentData.membermoney || 0) }}</span>
|
||||
<span class="detail-separator">|</span>
|
||||
<span class="detail-label">累计退款:</span>
|
||||
<span class="detail-value">¥{{ formatAmount(totalRefundedAmount) }}</span>
|
||||
<span class="detail-separator">|</span>
|
||||
<span class="detail-label">剩余可退:</span>
|
||||
<span class="detail-value total-value">¥{{ formatAmount(remainingRefundableAmountComputed) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="summary-note">-->
|
||||
<!-- <span class="note-text">💡 退款信息</span>-->
|
||||
<!-- <div class="refund-details">-->
|
||||
<!-- <div class="detail-row compact">-->
|
||||
<!-- <span class="detail-label">订单总额:</span>-->
|
||||
<!-- <span class="detail-value">¥{{ formatAmount(actualPaymentData.allmoney) }}</span>-->
|
||||
<!-- <span class="detail-separator">|</span>-->
|
||||
<!-- <span class="detail-label">会员优惠:</span>-->
|
||||
<!-- <span class="detail-value">¥{{ formatAmount(actualPaymentData.membermoney || 0) }}</span>-->
|
||||
<!-- <span class="detail-separator">|</span>-->
|
||||
<!-- <span class="detail-label">累计退款:</span>-->
|
||||
<!-- <span class="detail-value">¥{{ formatAmount(totalRefundedAmount) }}</span>-->
|
||||
<!-- <span class="detail-separator">|</span>-->
|
||||
<!-- <span class="detail-label">剩余可退:</span>-->
|
||||
<!-- <span class="detail-value total-value">¥{{ formatAmount(remainingRefundableAmountComputed) }}</span>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -258,7 +266,11 @@
|
|||
<div class="timeline-header">
|
||||
<div class="header-title">
|
||||
<span class="title-text">退款记录 #{{ index + 1 }}</span>
|
||||
<span class="title-time"> {{ formatTime(item.createTime) }}</span>
|
||||
<!-- <span class="title-time"> {{ formatTime(item.createdAt) }}</span>-->
|
||||
</div>
|
||||
<div class="header-date">
|
||||
<span class="date-label">操作时间:</span>
|
||||
<span class="date-value">{{ formatDateTime(item.createdAt) }}</span>
|
||||
</div>
|
||||
<!-- <div class="header-actions">-->
|
||||
<!-- <el-button-->
|
||||
|
|
@ -586,9 +598,9 @@ export default {
|
|||
const response = await getRefundHistory(this.orderId);
|
||||
console.log('退款历史接口响应:', response);
|
||||
|
||||
if (response.code === 200 && response.rows) {
|
||||
if (response.code === 200 && response.data) {
|
||||
// 按创建时间倒序排列,最新的在前面
|
||||
this.refundHistory = response.rows.sort((a, b) => {
|
||||
this.refundHistory = response.data.sort((a, b) => {
|
||||
const timeA = new Date(a.createTime || 0);
|
||||
const timeB = new Date(b.createTime || 0);
|
||||
return timeB - timeA;
|
||||
|
|
@ -892,6 +904,13 @@ export default {
|
|||
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')} ${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}`;
|
||||
},
|
||||
|
||||
// 格式化日期时间到秒
|
||||
formatDateTime(timeStr) {
|
||||
if (!timeStr) return '';
|
||||
const date = new Date(timeStr);
|
||||
return `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')} ${String(date.getHours()).padStart(2, '0')}:${String(date.getMinutes()).padStart(2, '0')}:${String(date.getSeconds()).padStart(2, '0')}`;
|
||||
},
|
||||
|
||||
// 格式化金额显示
|
||||
formatAmount(amount) {
|
||||
if (!amount || isNaN(amount)) return '0.00';
|
||||
|
|
@ -1139,9 +1158,19 @@ export default {
|
|||
width: 100%;
|
||||
}
|
||||
|
||||
/* 会员优惠单独行样式 */
|
||||
.member-discount-row {
|
||||
/* 会员优惠和邮费同行显示样式 */
|
||||
.discount-postage-row {
|
||||
margin-top: 10px;
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
justify-content: center;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.discount-postage-item {
|
||||
flex: 1;
|
||||
min-width: 200px;
|
||||
max-width: 300px;
|
||||
padding: 8px 12px;
|
||||
background-color: #f0f9ff;
|
||||
border: 1px solid #b3d8ff;
|
||||
|
|
@ -1149,23 +1178,20 @@ export default {
|
|||
text-align: center;
|
||||
}
|
||||
|
||||
.member-discount-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.member-discount-label {
|
||||
.discount-postage-label {
|
||||
font-size: 13px;
|
||||
font-weight: 500;
|
||||
color: #409EFF;
|
||||
display: block;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.member-discount-note {
|
||||
.discount-postage-note {
|
||||
font-size: 11px;
|
||||
color: #909399;
|
||||
font-style: italic;
|
||||
display: block;
|
||||
line-height: 1.3;
|
||||
}
|
||||
.amount { font-weight: 600; color: #E6A23C; }
|
||||
.amount.total { font-size: 18px; color: #409EFF; }
|
||||
|
|
@ -1587,14 +1613,33 @@ export default {
|
|||
}
|
||||
|
||||
.timeline-header {
|
||||
|
||||
margin-bottom: 10px;
|
||||
padding-bottom: 10px;
|
||||
border-bottom: 1px solid #ebeef5;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
.header-title{
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.header-date {
|
||||
text-align: right;
|
||||
|
||||
.date-label {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.date-value {
|
||||
font-size: 12px;
|
||||
color: #409EFF;
|
||||
font-weight: 500;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.timeline-title {
|
||||
|
|
|
|||
|
|
@ -279,7 +279,7 @@
|
|||
<!-- v-if="scope.row.status >= 15"-->
|
||||
<!-- 统一退款按钮 -->
|
||||
<el-button
|
||||
|
||||
v-if="scope.row.status >= 15"
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-money"
|
||||
|
|
@ -336,7 +336,7 @@
|
|||
@reject-after-sale="handleRejectAfterSale"
|
||||
@approve-after-sale="handleApproveAfterSale"
|
||||
@reject-refund="handleRejectRefund"
|
||||
@approve-refund="handleApproveRefund"
|
||||
@refund-success="handleRefundSuccess"
|
||||
/>
|
||||
|
||||
<!-- 驳回理由输入对话框 -->
|
||||
|
|
@ -886,21 +886,31 @@ export default {
|
|||
|
||||
/** 同意售后申请 */
|
||||
handleApproveAfterSale() {
|
||||
// 根据售后类型和状态决定是否需要输入退款金额
|
||||
// 根据售后类型和状态决定是否需要退款
|
||||
const { returntype, returnstatus } = this.currentAfterSaleOrder;
|
||||
|
||||
if (returntype === 1 && returnstatus === 1) {
|
||||
// 仅退款且是初始申请状态,需要立即输入退款金额
|
||||
this.refundAmountForm.orderAmount = this.currentAfterSaleOrder.payPrice ? this.currentAfterSaleOrder.payPrice.toFixed(2) : '0.00';
|
||||
this.refundAmountForm.returnrealmoney = '';
|
||||
this.refundAmountForm.refundRemark = '';
|
||||
this.refundAmountDialogVisible = true;
|
||||
// 仅退款且是初始申请状态,需要立即退款 - 打开统一退款页面
|
||||
this.currentRefundPaymentData = {
|
||||
wxmoney: this.currentAfterSaleOrder.payPrice || 0,
|
||||
yemoney: 0,
|
||||
shopmoney: 0,
|
||||
servicemoney: 0,
|
||||
membermoney: 0,
|
||||
couponmoney: 0
|
||||
};
|
||||
this.unifiedRefundDialogVisible = true;
|
||||
} else if (returntype === 2 && returnstatus === 4) {
|
||||
// 退货退款且平台已收货,需要输入退款金额
|
||||
this.refundAmountForm.orderAmount = this.currentAfterSaleOrder.payPrice ? this.currentAfterSaleOrder.payPrice.toFixed(2) : '0.00';
|
||||
this.refundAmountForm.returnrealmoney = '';
|
||||
this.refundAmountForm.refundRemark = '';
|
||||
this.refundAmountDialogVisible = true;
|
||||
// 退货退款且平台已收货,需要退款 - 打开统一退款页面
|
||||
this.currentRefundPaymentData = {
|
||||
wxmoney: this.currentAfterSaleOrder.payPrice || 0,
|
||||
yemoney: 0,
|
||||
shopmoney: 0,
|
||||
servicemoney: 0,
|
||||
membermoney: 0,
|
||||
couponmoney: 0
|
||||
};
|
||||
this.unifiedRefundDialogVisible = true;
|
||||
} else if (returntype === 2 && returnstatus === 1) {
|
||||
// 退货退款且是初始申请状态,直接同意申请,不输入退款金额
|
||||
this.$modal.confirm('确认同意该退货退款申请吗?客户需要先寄回商品。').then(() => {
|
||||
|
|
@ -928,13 +938,11 @@ export default {
|
|||
this.rejectReasonDialogVisible = true;
|
||||
},
|
||||
|
||||
/** 同意退款 */
|
||||
handleApproveRefund() {
|
||||
// 这个按钮只在平台收货后显示(returnstatus === 4),此时需要输入退款金额
|
||||
this.refundAmountForm.orderAmount = this.currentAfterSaleOrder.payPrice ? this.currentAfterSaleOrder.payPrice.toFixed(2) : '0.00';
|
||||
this.refundAmountForm.returnrealmoney = '';
|
||||
this.refundAmountForm.refundRemark = '';
|
||||
this.refundAmountDialogVisible = true;
|
||||
/** 处理退款成功 */
|
||||
handleRefundSuccess() {
|
||||
// 退款成功后刷新列表
|
||||
this.getList();
|
||||
this.$modal.msgSuccess('退款成功');
|
||||
},
|
||||
|
||||
/** 提交驳回理由 */
|
||||
|
|
|
|||
|
|
@ -1792,10 +1792,11 @@
|
|||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="退款金额" align="right" prop="returnmoney" width="100">
|
||||
<el-table-column label="退款金额" align="center" prop="returnmoney" width="100">
|
||||
<template slot-scope="scope">
|
||||
<span class="refund-amount">
|
||||
¥{{ (scope.row.returnmoney || 0).toFixed(2) }}
|
||||
|
||||
¥{{ parseFloat(scope.row.returnmoney || 0).toFixed(2) }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
|
@ -1806,7 +1807,7 @@
|
|||
size="mini"
|
||||
type="warning"
|
||||
@click="handleRefund(scope.row)"
|
||||
:disabled="scope.row.allmoney <= (scope.row.returnmoney || 0)"
|
||||
:disabled="parseFloat(scope.row.allmoney || 0) <= parseFloat(scope.row.returnmoney || 0)"
|
||||
>
|
||||
退款
|
||||
</el-button>
|
||||
|
|
@ -1839,6 +1840,14 @@
|
|||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 统一退款对话框 -->
|
||||
<UnifiedRefundDialog
|
||||
:visible.sync="unifiedRefundDialogVisible"
|
||||
:orderId="currentRefundOrderId"
|
||||
:paymentData="currentRefundPaymentData"
|
||||
@success="handleUnifiedRefundSuccess"
|
||||
/>
|
||||
|
||||
<!-- 退款弹窗 -->
|
||||
<el-dialog
|
||||
title="退款申请"
|
||||
|
|
@ -2076,6 +2085,7 @@ import {
|
|||
startService,
|
||||
projectQuote
|
||||
} from "@/api/system/Order"
|
||||
import { getRefundHistory } from "@/api/system/OrderLog"
|
||||
import CallRecord from './components/CallRecord'
|
||||
import AudioRecord from './components/AudioRecord'
|
||||
import ReceiveRecord from './components/ReceiveRecord'
|
||||
|
|
@ -2083,6 +2093,7 @@ import NotifyRecord from './components/NotifyRecord'
|
|||
import CommentRecord from './components/CommentRecord'
|
||||
import EditInfo from './components/EditInfo'
|
||||
import Pagination from '@/components/Pagination'
|
||||
import UnifiedRefundDialog from '../GoodsOrder/UnifiedRefundDialog'
|
||||
|
||||
export default {
|
||||
name: "Order",
|
||||
|
|
@ -2094,7 +2105,8 @@ export default {
|
|||
NotifyRecord,
|
||||
CommentRecord,
|
||||
EditInfo,
|
||||
Pagination
|
||||
Pagination,
|
||||
UnifiedRefundDialog
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
|
@ -2452,6 +2464,7 @@ export default {
|
|||
paymentDetailsLoading: false, // 支付明细加载状态
|
||||
currentPaymentOrder: {}, // 当前查看支付明细的订单
|
||||
paymentDetailsList: [], // 支付明细列表
|
||||
refundHistoryList: [], // 退款历史列表
|
||||
|
||||
// 退款相关
|
||||
refundDialogVisible: false, // 退款弹窗可见性
|
||||
|
|
@ -2466,6 +2479,11 @@ export default {
|
|||
refundReason: '',
|
||||
orderid: null // 添加订单ID字段
|
||||
},
|
||||
|
||||
// 统一退款相关
|
||||
unifiedRefundDialogVisible: false, // 统一退款弹窗可见性
|
||||
currentRefundOrderId: '', // 当前退款订单ID
|
||||
currentRefundPaymentData: {}, // 当前退款支付数据
|
||||
refundRules: {
|
||||
refundAmount: [
|
||||
{ required: true, message: '请输入退款金额', trigger: 'blur' },
|
||||
|
|
@ -4293,17 +4311,95 @@ export default {
|
|||
},
|
||||
|
||||
// 获取支付明细数据
|
||||
getPaymentDetailsData(orderId) {
|
||||
async getPaymentDetailsData(orderId) {
|
||||
this.paymentDetailsLoading = true;
|
||||
getPaymentDetails(orderId).then(response => {
|
||||
this.paymentDetailsList = response.data || [];
|
||||
try {
|
||||
// 获取支付明细
|
||||
const paymentResponse = await getPaymentDetails(orderId);
|
||||
this.paymentDetailsList = paymentResponse.data || [];
|
||||
|
||||
// 调试:打印支付明细数据结构
|
||||
console.log('支付明细数据结构:', this.paymentDetailsList);
|
||||
if (this.paymentDetailsList.length > 0) {
|
||||
console.log('第一行支付明细数据:', this.paymentDetailsList[0]);
|
||||
console.log('第一行数据的所有字段:', Object.keys(this.paymentDetailsList[0]));
|
||||
}
|
||||
|
||||
// 获取退款历史
|
||||
const refundResponse = await getRefundHistory(orderId);
|
||||
this.refundHistoryList = refundResponse.data || [];
|
||||
|
||||
// 调试:打印退款历史数据结构
|
||||
console.log('退款历史数据结构:', this.refundHistoryList);
|
||||
if (this.refundHistoryList.length > 0) {
|
||||
console.log('第一条退款记录:', this.refundHistoryList[0]);
|
||||
console.log('退款记录的所有字段:', Object.keys(this.refundHistoryList[0]));
|
||||
}
|
||||
|
||||
// 根据退款历史更新每行的退款金额
|
||||
this.updateRefundAmounts();
|
||||
|
||||
// 如果没有退款历史,确保每行的returnmoney字段都有默认值
|
||||
// if (!this.refundHistoryList || this.refundHistoryList.length === 0) {
|
||||
// this.paymentDetailsList.forEach(item => {
|
||||
// if (item.returnmoney === undefined || item.returnmoney === null) {
|
||||
// this.$set(item, 'returnmoney', '0.00');
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
this.paymentDetailsLoading = false;
|
||||
}).catch(error => {
|
||||
} catch (error) {
|
||||
console.error('获取支付明细失败:', error);
|
||||
this.$modal.msgError('获取支付明细失败');
|
||||
this.paymentDetailsList = [];
|
||||
this.refundHistoryList = [];
|
||||
this.paymentDetailsLoading = false;
|
||||
}
|
||||
},
|
||||
|
||||
// 根据退款历史更新每行的退款金额
|
||||
updateRefundAmounts() {
|
||||
if (!this.paymentDetailsList || !this.refundHistoryList) return;
|
||||
|
||||
console.log('开始更新退款金额,支付明细数量:', this.paymentDetailsList.length, '退款历史数量:', this.refundHistoryList.length);
|
||||
|
||||
// 根据退款历史数据计算每行的退款金额
|
||||
this.paymentDetailsList.forEach((item, index) => {
|
||||
// 查找该支付记录对应的退款历史
|
||||
let totalRefundAmount = 0;
|
||||
|
||||
console.log(`处理第${index + 1}行支付记录:`, item);
|
||||
|
||||
// 通过多种方式匹配退款记录
|
||||
this.refundHistoryList.forEach(refund => {
|
||||
console.log('检查退款记录:', refund);
|
||||
|
||||
// 匹配条件:订单ID、支付时间、支付金额等
|
||||
if (refund.orderid === item.orderid ||
|
||||
refund.orderid === item.id ||
|
||||
refund.orderid === item.paytime ||
|
||||
(refund.amount && Math.abs(parseFloat(refund.amount) - parseFloat(item.allmoney)) < 0.01)) {
|
||||
console.log('找到匹配的退款记录,金额:', refund.amount);
|
||||
totalRefundAmount += parseFloat(refund.amount || 0);
|
||||
}
|
||||
});
|
||||
|
||||
console.log(`第${index + 1}行总退款金额:`, totalRefundAmount);
|
||||
|
||||
// 设置退款金额
|
||||
// this.$set(item, 'returnmoney', totalRefundAmount.toFixed(2));
|
||||
});
|
||||
},
|
||||
|
||||
// 获取已退金额总和(直接在模板中调用)
|
||||
getTotalRefundedAmount() {
|
||||
// 根据实际数据计算总和
|
||||
const total = this.paymentDetailsList.reduce((sum, item) => {
|
||||
return sum + (parseFloat(item.returnmoney || 0));
|
||||
}, 0);
|
||||
|
||||
return total;
|
||||
},
|
||||
|
||||
// 获取支付类型标签样式
|
||||
|
|
@ -4406,23 +4502,48 @@ export default {
|
|||
|
||||
// 处理退款
|
||||
handleRefund(row) {
|
||||
this.refundForm = {
|
||||
id: row.id,
|
||||
paytime: row.paytime,
|
||||
status: row.status,
|
||||
// 调试:打印当前行的数据结构
|
||||
console.log('退款行数据:', row);
|
||||
console.log('退款行数据的所有字段:', Object.keys(row));
|
||||
console.log('orderid字段值:', row.orderid);
|
||||
console.log('orderId字段值:', row.orderId);
|
||||
|
||||
// 设置统一退款所需的数据
|
||||
// 优先使用该行支付数据中的orderid,如果不存在则使用其他标识符
|
||||
this.currentRefundOrderId = row.orderid || row.id || row.paytime || this.currentPaymentOrder.orderId;
|
||||
this.currentRefundPaymentData = {
|
||||
wxmoney: row.wxmoney || 0,
|
||||
yemoney: row.yemoney || 0,
|
||||
shopmoney: row.shopmoney || 0,
|
||||
servicemoney: row.servicemoney || 0,
|
||||
membermoney: row.membermoney || 0,
|
||||
couponmoney: row.couponmoney || 0,
|
||||
allmoney: row.allmoney || 0,
|
||||
returnmoney: row.returnmoney || 0,
|
||||
refundAmount: null,
|
||||
refundReason: '',
|
||||
orderid: this.currentPaymentOrder.orderId // 添加订单ID
|
||||
returnmoney: row.returnmoney || 0
|
||||
};
|
||||
this.refundDialogVisible = true;
|
||||
this.$nextTick(() => {
|
||||
this.$refs.refundForm.clearValidate();
|
||||
});
|
||||
|
||||
console.log('设置的退款订单ID:', this.currentRefundOrderId);
|
||||
console.log('设置的退款支付数据:', this.currentRefundPaymentData);
|
||||
|
||||
// 打开统一退款页面
|
||||
this.unifiedRefundDialogVisible = true;
|
||||
},
|
||||
|
||||
// 提交退款
|
||||
// 统一退款成功后的处理
|
||||
handleUnifiedRefundSuccess() {
|
||||
// 关闭统一退款对话框
|
||||
this.unifiedRefundDialogVisible = false;
|
||||
|
||||
// 刷新支付明细列表和退款历史
|
||||
if (this.currentPaymentOrder && this.currentPaymentOrder.orderId) {
|
||||
this.getPaymentDetailsData(this.currentPaymentOrder.orderId);
|
||||
}
|
||||
|
||||
// 显示成功消息
|
||||
this.$modal.msgSuccess('退款成功');
|
||||
},
|
||||
|
||||
// 提交退款(保留原有方法,但不再使用)
|
||||
submitRefund() {
|
||||
this.$refs.refundForm.validate(valid => {
|
||||
if (valid) {
|
||||
|
|
@ -4992,9 +5113,16 @@ export default {
|
|||
|
||||
// 计算已退金额(所有退款金额的总和)
|
||||
totalRefundedAmount() {
|
||||
return this.paymentDetailsList.reduce((total, item) => {
|
||||
return total + (parseFloat(item.returnmoney) || 0);
|
||||
const total = this.paymentDetailsList.reduce((total, item) => {
|
||||
// 使用更新后的退款金额
|
||||
console.log(`计算汇总 - 行退款金额: ${item}, 累计: ${item}`);
|
||||
const refundAmount = parseFloat(item.returnmoney) || 0;
|
||||
console.log(`计算汇总 - 行退款金额: ${refundAmount}, 累计: ${total + refundAmount}`);
|
||||
return total + refundAmount;
|
||||
}, 0);
|
||||
|
||||
console.log(`已退金额汇总计算完成: ${total}`);
|
||||
return total;
|
||||
},
|
||||
|
||||
// 计算未付金额(应付总额 - 已付金额)
|
||||
|
|
|
|||
|
|
@ -49,39 +49,39 @@
|
|||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<!-- <el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['system:transfer:add']"
|
||||
>新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
icon="el-icon-edit"
|
||||
size="mini"
|
||||
:disabled="single"
|
||||
@click="handleUpdate"
|
||||
v-hasPermi="['system:transfer:edit']"
|
||||
>修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
icon="el-icon-delete"
|
||||
size="mini"
|
||||
:disabled="multiple"
|
||||
@click="handleDelete"
|
||||
v-hasPermi="['system:transfer:remove']"
|
||||
>删除</el-button>
|
||||
</el-col>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<!-- <el-col :span="1.5">-->
|
||||
<!-- <el-button-->
|
||||
<!-- type="primary"-->
|
||||
<!-- plain-->
|
||||
<!-- icon="el-icon-plus"-->
|
||||
<!-- size="mini"-->
|
||||
<!-- @click="handleAdd"-->
|
||||
<!-- v-hasPermi="['system:transfer:add']"-->
|
||||
<!-- >新增</el-button>-->
|
||||
<!-- </el-col>-->
|
||||
<!-- <el-col :span="1.5">-->
|
||||
<!-- <el-button-->
|
||||
<!-- type="success"-->
|
||||
<!-- plain-->
|
||||
<!-- icon="el-icon-edit"-->
|
||||
<!-- size="mini"-->
|
||||
<!-- :disabled="single"-->
|
||||
<!-- @click="handleUpdate"-->
|
||||
<!-- v-hasPermi="['system:transfer:edit']"-->
|
||||
<!-- >修改</el-button>-->
|
||||
<!-- </el-col>-->
|
||||
<!-- <el-col :span="1.5">-->
|
||||
<!-- <el-button-->
|
||||
<!-- type="danger"-->
|
||||
<!-- plain-->
|
||||
<!-- icon="el-icon-delete"-->
|
||||
<!-- size="mini"-->
|
||||
<!-- :disabled="multiple"-->
|
||||
<!-- @click="handleDelete"-->
|
||||
<!-- v-hasPermi="['system:transfer:remove']"-->
|
||||
<!-- >删除</el-button>-->
|
||||
<!-- </el-col>-->
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
|
|
@ -93,7 +93,25 @@
|
|||
>导出</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row> -->
|
||||
</el-row>
|
||||
|
||||
<!-- 统计汇总 -->
|
||||
<el-card shadow="never" style="margin-bottom: 10px;">
|
||||
<div style="display:flex;gap:24px;flex-wrap:wrap;">
|
||||
<div>
|
||||
<span>总计申请:</span>
|
||||
<b style="color:#303133;">¥ {{ formatMoney(summary.totalApply) }}</b>
|
||||
</div>
|
||||
<div>
|
||||
<span>提现到账:</span>
|
||||
<b style="color:#67C23A;">¥ {{ formatMoney(summary.totalPaid) }}</b>
|
||||
</div>
|
||||
<div>
|
||||
<span>处理中:</span>
|
||||
<b style="color:#E6A23C;">¥ {{ formatMoney(summary.totalProcessing) }}</b>
|
||||
</div>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
<el-table v-loading="loading" :data="transferList" @selection-change="handleSelectionChange" border>
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
|
|
@ -118,9 +136,9 @@
|
|||
<span>{{ parseTime(scope.row.payTime, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="发起时间" align="center" prop="payTime" width="180">
|
||||
<el-table-column label="发起时间" align="center" prop="createdAt" width="180">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.time, '{y}-{m}-{d}') }}</span>
|
||||
<span>{{ parseTime(scope.row.createdAt, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
|
|
@ -221,7 +239,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import { listTransfer, getTransfer, delTransfer, addTransfer, updateTransfer} from "@/api/system/transfer"
|
||||
import { listTransfer, getTransfer, delTransfer, addTransfer, updateTransfer, getTransferSummary} from "@/api/system/transfer"
|
||||
export default {
|
||||
name: "Transfer",
|
||||
dicts: ['money_status'],
|
||||
|
|
@ -241,6 +259,9 @@ export default {
|
|||
total: 0,
|
||||
|
||||
|
||||
// 统计汇总
|
||||
summary: { totalApply: 0, totalPaid: 0, totalProcessing: 0 },
|
||||
|
||||
// wechat_transfer表格数据
|
||||
transferList: [],
|
||||
// 弹出层标题
|
||||
|
|
@ -302,6 +323,14 @@ export default {
|
|||
this.transferList = response.rows
|
||||
this.total = response.total
|
||||
this.loading = false
|
||||
// 同步刷新统计
|
||||
this.loadSummary()
|
||||
})
|
||||
},
|
||||
// 加载统计汇总
|
||||
loadSummary() {
|
||||
getTransferSummary(this.queryParams).then(res => {
|
||||
this.summary = res.data || { totalApply: 0, totalPaid: 0, totalProcessing: 0 }
|
||||
})
|
||||
},
|
||||
// 取消按钮
|
||||
|
|
|
|||
Loading…
Reference in New Issue