Compare commits

...

2 Commits

  1. 2
      ruoyi-admin/src/main/resources/application.yml
  2. 37
      ruoyi-modules/ruoyi-job/src/main/java/org/dromara/job/snailjob/OrderJobExecutor.java
  3. 23
      ruoyi-modules/ruoyi-job/src/main/java/org/dromara/job/snailjob/TestAnnoJobExecutor.java
  4. 19
      ruoyi-modules/ruoyi-job/src/main/java/org/dromara/job/snailjob/TestClassJobExecutor.java
  5. 2
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/app/AppProductOrderExpressController.java
  6. 20
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/ProductOrder.java
  7. 6
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/SysWithdrawal.java
  8. 8
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/bo/ProductOrderBo.java
  9. 4
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/bo/SysWithdrawalBo.java
  10. 21
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/vo/ProductOrderVo.java
  11. 1
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/vo/SysBusinessBalanceRecordVo.java
  12. 5
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/vo/SysWithdrawalVo.java
  13. 7
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/IProductOrderService.java
  14. 2
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/ISysWithdrawalService.java
  15. 2
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/RefundService.java
  16. 17
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/calculate/impl/DeliveryOrderCalculateService.java
  17. 15
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/calculate/impl/ExpressDeliveryOrderCalculateService.java
  18. 27
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/calculate/impl/SelfPickUpOrderCalculateService.java
  19. 2
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/AllOrderServiceImpl.java
  20. 3
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/OrderServiceImpl.java
  21. 103
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/ProductOrderServiceImpl.java
  22. 100
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/RefundServiceImpl.java
  23. 24
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysBusinessBalanceServiceImpl.java
  24. 4
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysBusinessRecordServiceImpl.java
  25. 27
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysWithdrawalServiceImpl.java
  26. 8
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/task/BusinessJobExecutor.java
  27. 4
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/task/BusinessMonthStatisticsExecutor.java
  28. 2
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/task/BusinessStatsExecutor.java
  29. 2
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/task/CouponJobExecutor.java
  30. 63
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/task/OrderJobExecutor.java
  31. 51
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/task/SysWithdrawalExecutor.java
  32. 4
      ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/ProductOrderPriceMapper.xml
  33. 5
      ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysBusinessBalanceMapper.xml

2
ruoyi-admin/src/main/resources/application.yml

@ -100,7 +100,7 @@ sa-token:
# token名称 (同时也是cookie名称) # token名称 (同时也是cookie名称)
token-name: Authorization token-name: Authorization
# 是否允许同一账号并发登录 (为true时允许一起登录, 为false时新登录挤掉旧登录) # 是否允许同一账号并发登录 (为true时允许一起登录, 为false时新登录挤掉旧登录)
is-concurrent: false is-concurrent: true
# 在多人登录同一账号时,是否共用一个token (为true时所有登录共用一个token, 为false时每次登录新建一个token) # 在多人登录同一账号时,是否共用一个token (为true时所有登录共用一个token, 为false时每次登录新建一个token)
is-share: false is-share: false
# jwt秘钥 # jwt秘钥

37
ruoyi-modules/ruoyi-job/src/main/java/org/dromara/job/snailjob/OrderJobExecutor.java

@ -1,37 +0,0 @@
package org.dromara.job.snailjob;
import cn.hutool.core.date.DateUtil;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.dromara.system.domain.bo.AppMonthBillBo;
import org.dromara.system.service.IAppMonthBillService;
import org.dromara.system.service.IProductOrderService;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.Date;
@Component
@EnableScheduling
@Slf4j
public class OrderJobExecutor {
@Resource
private IProductOrderService productOrderService;
@Scheduled(cron = "0 * * * * ?")
public void run(){
log.info("定时处理支付过期...开始:{}", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
productOrderService.cancelByPayExpire();
log.info("定时处理支付过期...结束:{}", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
}
@Scheduled(cron = "0 0 * * * ?")
public void settlement(){
log.info("订单结算...开始:{}", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
productOrderService.settlement();
log.info("订单结算...结束:{}", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
}
}

23
ruoyi-modules/ruoyi-job/src/main/java/org/dromara/job/snailjob/TestAnnoJobExecutor.java

@ -1,23 +0,0 @@
package org.dromara.job.snailjob;
import com.aizuda.snailjob.client.job.core.annotation.JobExecutor;
import com.aizuda.snailjob.client.job.core.dto.JobArgs;
import com.aizuda.snailjob.client.model.ExecuteResult;
import com.aizuda.snailjob.common.core.util.JsonUtil;
import com.aizuda.snailjob.common.log.SnailJobLog;
import org.springframework.stereotype.Component;
/**
* @author opensnail
* @date 2024-05-17
*/
@Component
@JobExecutor(name = "testJobExecutor")
public class TestAnnoJobExecutor {
public ExecuteResult jobExecute(JobArgs jobArgs) {
SnailJobLog.LOCAL.info("testJobExecutor. jobArgs:{}", JsonUtil.toJsonString(jobArgs));
SnailJobLog.REMOTE.info("testJobExecutor. jobArgs:{}", JsonUtil.toJsonString(jobArgs));
return ExecuteResult.success("测试成功");
}
}

19
ruoyi-modules/ruoyi-job/src/main/java/org/dromara/job/snailjob/TestClassJobExecutor.java

@ -1,19 +0,0 @@
package org.dromara.job.snailjob;
import com.aizuda.snailjob.client.job.core.dto.JobArgs;
import com.aizuda.snailjob.client.job.core.executor.AbstractJobExecutor;
import com.aizuda.snailjob.client.model.ExecuteResult;
import org.springframework.stereotype.Component;
/**
* @author opensnail
* @date 2024-05-17
*/
@Component
public class TestClassJobExecutor extends AbstractJobExecutor {
@Override
protected ExecuteResult doJobExecute(JobArgs jobArgs) {
return ExecuteResult.success("TestJobExecutor测试成功");
}
}

2
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/app/AppProductOrderExpressController.java

@ -80,7 +80,7 @@ public class AppProductOrderExpressController extends BaseController {
} }
/** /**
* 根据orderId 快递订单好查询记录 * 根据快递单号 code 手机号查询快递信息
* @param expressNo * @param expressNo
* @param expressCode * @param expressCode
* @param mobile * @param mobile

20
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/ProductOrder.java

@ -176,5 +176,25 @@ public class ProductOrder extends BaseEntity {
private String showBusiness; private String showBusiness;
private String refundRemark;
private String refundImage;
private String businessRefund;
private String canRefund;
/**
* 0未付款1已付款
*/
private String isPay;
/**
* 发起退款时间
*/
private Date startRefundTime;
/**
* 退款失败时间
*/
private Date failRefundTime;
} }

6
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/SysWithdrawal.java

@ -7,6 +7,7 @@ import lombok.EqualsAndHashCode;
import java.io.Serial; import java.io.Serial;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date;
/** /**
* 系统提现对象 sys_withdrawal * 系统提现对象 sys_withdrawal
@ -113,5 +114,8 @@ public class SysWithdrawal extends BaseEntity {
private String transferInfo; private String transferInfo;
private String callback; private String callback;
/**
* 同意时间
*/
private Date agreeTime;
} }

8
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/bo/ProductOrderBo.java

@ -188,5 +188,13 @@ public class ProductOrderBo extends BaseEntity {
* 0无结算 1待结算 2已结算, 3无法结算 * 0无结算 1待结算 2已结算, 3无法结算
*/ */
private Long settlement; private Long settlement;
/**
* 发起退款时间
*/
private Date startRefundTime;
/**
* 退款失败时间
*/
private Date failRefundTime;
} }

4
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/bo/SysWithdrawalBo.java

@ -116,6 +116,10 @@ public class SysWithdrawalBo extends BaseEntity {
private String businessName; private String businessName;
/**
* 同意时间
*/
private Date agreeTime;
} }

21
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/vo/ProductOrderVo.java

@ -270,4 +270,25 @@ public class ProductOrderVo implements Serializable {
private String showUser; private String showUser;
private String showBusiness; private String showBusiness;
private String refundRemark;
private String refundImage;
// @Translation(type = TransConstant.OSS_ID_TO_URL, mapper = "refundImage")
private String canRefund;
/**
* 0未付款1已付款
*/
private String isPay;
/**
* 发起退款时间
*/
private Date startRefundTime;
/**
*退款失败时间
*/
private Date failRefundTime;
} }

1
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/vo/SysBusinessBalanceRecordVo.java

@ -64,6 +64,7 @@ public class SysBusinessBalanceRecordVo implements Serializable {
@ExcelProperty(value = "") @ExcelProperty(value = "")
private String orderNo; private String orderNo;
private Long orderId;
/** /**
* 创建时间 * 创建时间
*/ */

5
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/vo/SysWithdrawalVo.java

@ -140,5 +140,8 @@ public class SysWithdrawalVo implements Serializable {
private String transferInfo; private String transferInfo;
private String callback; private String callback;
/**
* 同意时间
*/
private Date agreeTime;
} }

7
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/IProductOrderService.java

@ -194,4 +194,11 @@ public interface IProductOrderService {
void subExpressPrice(String freight, Long orderId); void subExpressPrice(String freight, Long orderId);
WxPayOrderQueryResult wxQueryOrder(String orderNo) throws WxPayException; WxPayOrderQueryResult wxQueryOrder(String orderNo) throws WxPayException;
void updateBusinessRemarkByOrderId(String recordMsg, Long id);
void updateCanRefundRemarkByOrderId(String canRefund, Long id);
void refundFailToFinish();
} }

2
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/ISysWithdrawalService.java

@ -94,4 +94,6 @@ public interface ISysWithdrawalService {
WxPayTransferCallbackResult parseWxPayTransferCallbackResult(String notifyData, SignatureHeader header) throws WxPayException; WxPayTransferCallbackResult parseWxPayTransferCallbackResult(String notifyData, SignatureHeader header) throws WxPayException;
void transferCallbackSuccess(WxPayTransferCallbackResult wxPayTransferCallbackResult); void transferCallbackSuccess(WxPayTransferCallbackResult wxPayTransferCallbackResult);
void cancelWxByAgreeTime();
} }

2
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/RefundService.java

@ -25,4 +25,6 @@ public interface RefundService {
void refundByVo(ProductOrderRefundVo productOrderRefundVo); void refundByVo(ProductOrderRefundVo productOrderRefundVo);
void wxRefundSuccess(WxPayRefundNotifyResult result); void wxRefundSuccess(WxPayRefundNotifyResult result);
void startRefund(Long id);
} }

17
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/calculate/impl/DeliveryOrderCalculateService.java

@ -190,6 +190,9 @@ public class DeliveryOrderCalculateService implements OrderCalculateService {
appBusinessProductMapper.addStock(productOrderItemsVo.getProductId(), productOrderVo.getNum()); appBusinessProductMapper.addStock(productOrderItemsVo.getProductId(), productOrderVo.getNum());
appProductAttrValueMapper.addStock(productOrderItemsVo.getProductId(), productOrderItemsVo.getProductAttrSn(), productOrderVo.getNum()); appProductAttrValueMapper.addStock(productOrderItemsVo.getProductId(), productOrderItemsVo.getProductAttrSn(), productOrderVo.getNum());
} }
productOrderVo.setStatus("3");
}else { }else {
BigDecimal subPrice = BigDecimal.ZERO; BigDecimal subPrice = BigDecimal.ZERO;
List<ProductOrderItemsVo> itemsList = productOrderVo.getItemsList(); List<ProductOrderItemsVo> itemsList = productOrderVo.getItemsList();
@ -197,6 +200,7 @@ public class DeliveryOrderCalculateService implements OrderCalculateService {
ProductOrderRefundVo productOrderRefundVo = new ProductOrderRefundVo().copy(productOrderVo, itemsRefundList); ProductOrderRefundVo productOrderRefundVo = new ProductOrderRefundVo().copy(productOrderVo, itemsRefundList);
productOrderVo.setSettlement(1L); productOrderVo.setSettlement(1L);
if (productOrderVo.getStatus().equals("1")) { if (productOrderVo.getStatus().equals("1")) {
productOrderVo.setStatus("3");
if (productOrderVo.getReason() == 2L) { if (productOrderVo.getReason() == 2L) {
ProductOrderPriceVo productOrderPriceVo = productOrderVo.getProductOrderPriceVo(); ProductOrderPriceVo productOrderPriceVo = productOrderVo.getProductOrderPriceVo();
BigDecimal currentPrice = productOrderPriceVo.getCurrentPrice(); BigDecimal currentPrice = productOrderPriceVo.getCurrentPrice();
@ -217,6 +221,8 @@ public class DeliveryOrderCalculateService implements OrderCalculateService {
refundService.refundByVo(productOrderRefundVo); refundService.refundByVo(productOrderRefundVo);
} }
}else if(productOrderVo.getStatus().equals("2") ) { }else if(productOrderVo.getStatus().equals("2") ) {
productOrderVo.setStatus("3");
if (productOrderVo.getReason() == 2L) { if (productOrderVo.getReason() == 2L) {
ProductOrderPriceVo productOrderPriceVo = productOrderVo.getProductOrderPriceVo(); ProductOrderPriceVo productOrderPriceVo = productOrderVo.getProductOrderPriceVo();
BigDecimal currentPrice = productOrderPriceVo.getCurrentPrice(); BigDecimal currentPrice = productOrderPriceVo.getCurrentPrice();
@ -255,14 +261,19 @@ public class DeliveryOrderCalculateService implements OrderCalculateService {
productOrderRefundVo.setImageList(bo.getImageList()); productOrderRefundVo.setImageList(bo.getImageList());
productOrderRefundVo.setRefundNo(OrderNoUtils.getOrderNo("R")); productOrderRefundVo.setRefundNo(OrderNoUtils.getOrderNo("R"));
//售后 //售后
productOrderMapper.updateStatusByOrderId("8", id); // refundService.insertByVo(productOrderRefundVo);
refundService.insertByVo(productOrderRefundVo);
// refundService.refundByVo(productOrderRefundVo); // refundService.refundByVo(productOrderRefundVo);
productOrderVo.setStartRefundTime(new Date());
productOrderVo.setStatus("8");
if (!productOrderVo.getCanRefund().equals("0")) {
throw new ServiceException("该订单不允许退款");
}
}else{ }else{
throw new ServiceException("订单状态错误,不支持退款"); throw new ServiceException("订单状态错误,不支持退款");
} }
} }
productOrderVo.setStatus("3");
} }

15
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/calculate/impl/ExpressDeliveryOrderCalculateService.java

@ -14,6 +14,7 @@ import org.dromara.system.service.*;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
@ -156,6 +157,7 @@ public class ExpressDeliveryOrderCalculateService implements OrderCalculateServi
appBusinessProductMapper.addStock(productOrderItemsVo.getProductId(), productOrderVo.getNum()); appBusinessProductMapper.addStock(productOrderItemsVo.getProductId(), productOrderVo.getNum());
appProductAttrValueMapper.addStock(productOrderItemsVo.getProductId(), productOrderItemsVo.getProductAttrSn(), productOrderVo.getNum()); appProductAttrValueMapper.addStock(productOrderItemsVo.getProductId(), productOrderItemsVo.getProductAttrSn(), productOrderVo.getNum());
} }
productOrderVo.setStatus("3");
}else { }else {
BigDecimal subPrice = BigDecimal.ZERO; BigDecimal subPrice = BigDecimal.ZERO;
List<ProductOrderItemsVo> itemsList = productOrderVo.getItemsList(); List<ProductOrderItemsVo> itemsList = productOrderVo.getItemsList();
@ -163,6 +165,8 @@ public class ExpressDeliveryOrderCalculateService implements OrderCalculateServi
ProductOrderRefundVo productOrderRefundVo = new ProductOrderRefundVo().copy(productOrderVo, itemsRefundList); ProductOrderRefundVo productOrderRefundVo = new ProductOrderRefundVo().copy(productOrderVo, itemsRefundList);
productOrderVo.setSettlement(1L); productOrderVo.setSettlement(1L);
if (productOrderVo.getStatus().equals("1")) { if (productOrderVo.getStatus().equals("1")) {
productOrderVo.setStatus("3");
if (productOrderVo.getReason() == 2L) { if (productOrderVo.getReason() == 2L) {
ProductOrderPriceVo productOrderPriceVo = productOrderVo.getProductOrderPriceVo(); ProductOrderPriceVo productOrderPriceVo = productOrderVo.getProductOrderPriceVo();
BigDecimal currentPrice = productOrderPriceVo.getCurrentPrice(); BigDecimal currentPrice = productOrderPriceVo.getCurrentPrice();
@ -185,6 +189,8 @@ public class ExpressDeliveryOrderCalculateService implements OrderCalculateServi
} }
}else if(productOrderVo.getStatus().equals("2")) { }else if(productOrderVo.getStatus().equals("2")) {
productOrderVo.setStatus("3");
if (productOrderVo.getReason() == 2L) { if (productOrderVo.getReason() == 2L) {
ProductOrderPriceVo productOrderPriceVo = productOrderVo.getProductOrderPriceVo(); ProductOrderPriceVo productOrderPriceVo = productOrderVo.getProductOrderPriceVo();
BigDecimal currentPrice = productOrderPriceVo.getCurrentPrice(); BigDecimal currentPrice = productOrderPriceVo.getCurrentPrice();
@ -217,20 +223,21 @@ public class ExpressDeliveryOrderCalculateService implements OrderCalculateServi
BigDecimal settlementPrice = productOrderPriceVo.getSettlementPrice(); BigDecimal settlementPrice = productOrderPriceVo.getSettlementPrice();
BigDecimal settlementCurrentPrice = productOrderPriceVo.getSettlementCurrentPrice(); BigDecimal settlementCurrentPrice = productOrderPriceVo.getSettlementCurrentPrice();
productOrderRefundVo.setRealPrice(payPrice); productOrderRefundVo.setRealPrice(payPrice);
// subPrice = productOrderPriceVo.getPackagePrice(); // subPrice = productOrderPriceVo.getPackagePrice();
subPrice(subPrice, productOrderRefundVo, productOrderPriceVo, currentPrice, payPrice, settlementPrice, settlementCurrentPrice); subPrice(subPrice, productOrderRefundVo, productOrderPriceVo, currentPrice, payPrice, settlementPrice, settlementCurrentPrice);
productOrderRefundVo.setStatus("0"); productOrderRefundVo.setStatus("0");
productOrderRefundVo.setRefundNo(OrderNoUtils.getOrderNo("R")); productOrderRefundVo.setRefundNo(OrderNoUtils.getOrderNo("R"));
productOrderMapper.updateStatusByOrderId("8", id);
productOrderRefundVo.setRefundMsg(bo.getRemark()); productOrderRefundVo.setRefundMsg(bo.getRemark());
productOrderRefundVo.setImageList(bo.getImageList()); productOrderRefundVo.setImageList(bo.getImageList());
productOrderVo.setStartRefundTime(new Date());
refundService.insertByVo(productOrderRefundVo); //refundService.insertByVo(productOrderRefundVo);
//refundService.refundByVo(productOrderRefundVo); //refundService.refundByVo(productOrderRefundVo);
productOrderVo.setStatus("8");
}else{ }else{
throw new ServiceException("订单状态错误,不支持退款"); throw new ServiceException("订单状态错误,不支持退款");
} }
productOrderVo.setStatus("3");
} }
} }

27
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/calculate/impl/SelfPickUpOrderCalculateService.java

@ -13,6 +13,7 @@ import org.dromara.system.service.*;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
@ -89,12 +90,12 @@ public class SelfPickUpOrderCalculateService implements OrderCalculateService {
@Override @Override
public void buildAddress(ProductOrderBo bo, SysBusinessVo sysBusinessVo) { public void buildAddress(ProductOrderBo bo, SysBusinessVo sysBusinessVo) {
bo.setUserName(bo.getUserName()); bo.setUserName(bo.getUserName());
bo.setMobile(bo.getMobile()); bo.setMobile(bo.getMobile());
bo.setArea(sysBusinessVo.getArea()); bo.setArea(sysBusinessVo.getArea());
bo.setAddress(sysBusinessVo.getAddress()); bo.setAddress(sysBusinessVo.getAddress());
bo.setLat(sysBusinessVo.getLat()); bo.setLat(sysBusinessVo.getLat());
bo.setLng(sysBusinessVo.getLng()); bo.setLng(sysBusinessVo.getLng());
} }
@Override @Override
@ -110,6 +111,9 @@ public class SelfPickUpOrderCalculateService implements OrderCalculateService {
appBusinessProductMapper.addStock(productOrderItemsVo.getProductId(), productOrderVo.getNum()); appBusinessProductMapper.addStock(productOrderItemsVo.getProductId(), productOrderVo.getNum());
appProductAttrValueMapper.addStock(productOrderItemsVo.getProductId(), productOrderItemsVo.getProductAttrSn(), productOrderVo.getNum()); appProductAttrValueMapper.addStock(productOrderItemsVo.getProductId(), productOrderItemsVo.getProductAttrSn(), productOrderVo.getNum());
} }
productOrderMapper.updateStatusByOrderId("3", id);
productOrderVo.setStatus("3");
}else { }else {
BigDecimal subPrice = BigDecimal.ZERO; BigDecimal subPrice = BigDecimal.ZERO;
List<ProductOrderItemsVo> itemsList = productOrderVo.getItemsList(); List<ProductOrderItemsVo> itemsList = productOrderVo.getItemsList();
@ -117,7 +121,6 @@ public class SelfPickUpOrderCalculateService implements OrderCalculateService {
ProductOrderRefundVo productOrderRefundVo = new ProductOrderRefundVo().copy(productOrderVo, itemsRefundList); ProductOrderRefundVo productOrderRefundVo = new ProductOrderRefundVo().copy(productOrderVo, itemsRefundList);
productOrderVo.setSettlement(1L); productOrderVo.setSettlement(1L);
if (productOrderVo.getStatus().equals("1") || productOrderVo.getStatus().equals("2") ) { if (productOrderVo.getStatus().equals("1") || productOrderVo.getStatus().equals("2") ) {
ProductOrderPriceVo productOrderPriceVo = productOrderVo.getProductOrderPriceVo(); ProductOrderPriceVo productOrderPriceVo = productOrderVo.getProductOrderPriceVo();
BigDecimal currentPrice = productOrderPriceVo.getCurrentPrice(); BigDecimal currentPrice = productOrderPriceVo.getCurrentPrice();
BigDecimal payPrice = productOrderPriceVo.getPayPrice(); BigDecimal payPrice = productOrderPriceVo.getPayPrice();
@ -127,6 +130,7 @@ public class SelfPickUpOrderCalculateService implements OrderCalculateService {
subPrice(subPrice, productOrderRefundVo, productOrderPriceVo, currentPrice, payPrice, settlementPrice, settlementCurrentPrice); subPrice(subPrice, productOrderRefundVo, productOrderPriceVo, currentPrice, payPrice, settlementPrice, settlementCurrentPrice);
productOrderRefundVo.setStatus("1"); productOrderRefundVo.setStatus("1");
productOrderRefundVo.setRefundNo(OrderNoUtils.getOrderNo("R")); productOrderRefundVo.setRefundNo(OrderNoUtils.getOrderNo("R"));
productOrderVo.setStatus("3");
refundService.refundByVo(productOrderRefundVo); refundService.refundByVo(productOrderRefundVo);
}else if(productOrderVo.getStatus().equals("4")){ }else if(productOrderVo.getStatus().equals("4")){
ProductOrderPriceVo productOrderPriceVo = productOrderVo.getProductOrderPriceVo(); ProductOrderPriceVo productOrderPriceVo = productOrderVo.getProductOrderPriceVo();
@ -139,15 +143,18 @@ public class SelfPickUpOrderCalculateService implements OrderCalculateService {
subPrice(subPrice, productOrderRefundVo, productOrderPriceVo, currentPrice, payPrice, settlementPrice, settlementCurrentPrice); subPrice(subPrice, productOrderRefundVo, productOrderPriceVo, currentPrice, payPrice, settlementPrice, settlementCurrentPrice);
productOrderRefundVo.setStatus("0"); productOrderRefundVo.setStatus("0");
productOrderRefundVo.setRefundNo(OrderNoUtils.getOrderNo("R")); productOrderRefundVo.setRefundNo(OrderNoUtils.getOrderNo("R"));
productOrderMapper.updateStatusByOrderId("8", id);
productOrderRefundVo.setRefundMsg(bo.getRemark()); productOrderRefundVo.setRefundMsg(bo.getRemark());
productOrderRefundVo.setImageList(bo.getImageList()); productOrderRefundVo.setImageList(bo.getImageList());
refundService.insertByVo(productOrderRefundVo); // refundService.insertByVo(productOrderRefundVo);
productOrderVo.setStatus("8");
productOrderVo.setStartRefundTime(new Date());
}else{ }else{
throw new ServiceException("订单状态错误,不支持退款"); throw new ServiceException("订单状态错误,不支持退款");
} }
productOrderMapper.updateStatusByOrderId("8", id);
} }
productOrderVo.setStatus("3");
} }

2
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/AllOrderServiceImpl.java

@ -189,7 +189,7 @@ public class AllOrderServiceImpl implements IAllOrderService {
public AllOrderVo queryByProductOrderId(Long id){ public AllOrderVo queryByProductOrderId(Long id){
QueryWrapper<AllOrder> wrapper = new QueryWrapper<>(); QueryWrapper<AllOrder> wrapper = new QueryWrapper<>();
wrapper.eq("order_id", id); wrapper.eq("order_id", id);
wrapper.eq("order_type", 1L); wrapper.eq("order_type", "01");
return baseMapper.selectVoOne(wrapper); return baseMapper.selectVoOne(wrapper);
} }

3
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/OrderServiceImpl.java

@ -91,6 +91,9 @@ public class OrderServiceImpl implements OrderService {
//取消配送 //取消配送
orderDeliveryService.cancelDeliveryOrder(cancelDeliveryOrderBo); orderDeliveryService.cancelDeliveryOrder(cancelDeliveryOrderBo);
} }
productOrderVo.setRefundRemark(bo.getRemark());
productOrderVo.setRefundImage(bo.getImageList());
productOrderService.updateByVo(productOrderVo); productOrderService.updateByVo(productOrderVo);
} }

103
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/ProductOrderServiceImpl.java

@ -259,6 +259,7 @@ public class ProductOrderServiceImpl implements IProductOrderService {
lqw.eq(bo.getSettlement() != null, ProductOrder::getSettlement, bo.getSettlement()); lqw.eq(bo.getSettlement() != null, ProductOrder::getSettlement, bo.getSettlement());
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), ProductOrder::getStatus, bo.getStatus()); lqw.eq(StringUtils.isNotBlank(bo.getStatus()), ProductOrder::getStatus, bo.getStatus());
lqw.eq(StringUtils.isNotBlank(bo.getShowBusiness()), ProductOrder::getShowBusiness, bo.getShowBusiness()); lqw.eq(StringUtils.isNotBlank(bo.getShowBusiness()), ProductOrder::getShowBusiness, bo.getShowBusiness());
lqw.lt(bo.getStartRefundTime() != null, ProductOrder::getStartRefundTime, DateUtil.offsetDay(bo.getStartRefundTime(), -2).toJdkDate());
lqw.apply(StringUtils.isNotBlank(bo.getKeyworkds()), "locate({0}, order_no) > 0 or locate({0}, mobile) > 0 or locate({0}, product_name) > 0 ", bo.getKeyworkds()); lqw.apply(StringUtils.isNotBlank(bo.getKeyworkds()), "locate({0}, order_no) > 0 or locate({0}, mobile) > 0 or locate({0}, product_name) > 0 ", bo.getKeyworkds());
return lqw; return lqw;
} }
@ -590,6 +591,7 @@ public class ProductOrderServiceImpl implements IProductOrderService {
public void paySuccess(Long orderId, BigDecimal cashPrice) { public void paySuccess(Long orderId, BigDecimal cashPrice) {
ProductOrderVo productOrderVo = queryById(orderId); ProductOrderVo productOrderVo = queryById(orderId);
productOrderVo.setStatus("1"); productOrderVo.setStatus("1");
productOrderVo.setIsPay("1");
productOrderVo.setPayTime(new Date()); productOrderVo.setPayTime(new Date());
productOrderPriceService.updateRealPriceByOrderId(cashPrice, orderId); productOrderPriceService.updateRealPriceByOrderId(cashPrice, orderId);
//修改订单数据 //修改订单数据
@ -753,7 +755,7 @@ public class ProductOrderServiceImpl implements IProductOrderService {
@Override @Override
public Long getOrderCount() { public Long getOrderCount() {
QueryWrapper<ProductOrder> queryWrapper = new QueryWrapper<>(); QueryWrapper<ProductOrder> queryWrapper = new QueryWrapper<>();
queryWrapper.in("status", "1", "2", "4", "5"); queryWrapper.eq("is_pay", "1");
return baseMapper.selectCount(queryWrapper); return baseMapper.selectCount(queryWrapper);
} }
@ -797,7 +799,7 @@ public class ProductOrderServiceImpl implements IProductOrderService {
@Override @Override
public Long getOrderUserCount() { public Long getOrderUserCount() {
QueryWrapper<ProductOrder> queryWrapper = new QueryWrapper<>(); QueryWrapper<ProductOrder> queryWrapper = new QueryWrapper<>();
queryWrapper.in("status", "1", "2", "4", "5"); queryWrapper.eq("is_pay", "1");
return baseMapper.selectCount(queryWrapper); return baseMapper.selectCount(queryWrapper);
} }
@ -805,7 +807,7 @@ public class ProductOrderServiceImpl implements IProductOrderService {
public Long getYesterdayOrderCount() { public Long getYesterdayOrderCount() {
Date jdkDate = DateUtil.offsetDay(new Date(), -1).toJdkDate(); Date jdkDate = DateUtil.offsetDay(new Date(), -1).toJdkDate();
QueryWrapper<ProductOrder> queryWrapper = new QueryWrapper<>(); QueryWrapper<ProductOrder> queryWrapper = new QueryWrapper<>();
queryWrapper.in("status", "1", "2", "4", "5"); queryWrapper.eq("is_pay", "1");
queryWrapper.apply("cast(create_time as date) = cast({0} as date)", jdkDate); queryWrapper.apply("cast(create_time as date) = cast({0} as date)", jdkDate);
return baseMapper.selectCount(queryWrapper); return baseMapper.selectCount(queryWrapper);
} }
@ -815,7 +817,7 @@ public class ProductOrderServiceImpl implements IProductOrderService {
Date jdkDate = DateUtil.offsetDay(new Date(), -1).toJdkDate(); Date jdkDate = DateUtil.offsetDay(new Date(), -1).toJdkDate();
QueryWrapper<ProductOrderPrice> queryWrapper = new QueryWrapper<>(); QueryWrapper<ProductOrderPrice> queryWrapper = new QueryWrapper<>();
queryWrapper.select(" sum(pay_price ) as pay_price"); queryWrapper.select(" sum(pay_price ) as pay_price");
queryWrapper.apply(" order_id in ( select po.id from product_order po where po.status in ('1', '2', '4', '5', '6') and cast(po.create_time as date) = cast({0} as date) and po.del_flag = '0')", jdkDate); queryWrapper.apply(" order_id in ( select po.id from product_order po where po.is_pay = '1' and cast(po.create_time as date) = cast({0} as date) and po.del_flag = '0')", jdkDate);
ProductOrderPrice productOrder = productOrderPriceMapper.selectOne(queryWrapper); ProductOrderPrice productOrder = productOrderPriceMapper.selectOne(queryWrapper);
return productOrder == null ? BigDecimal.ZERO : productOrder.getPayPrice(); return productOrder == null ? BigDecimal.ZERO : productOrder.getPayPrice();
} }
@ -824,7 +826,7 @@ public class ProductOrderServiceImpl implements IProductOrderService {
public BigDecimal getTotalAmount() { public BigDecimal getTotalAmount() {
QueryWrapper<ProductOrderPrice> queryWrapper = new QueryWrapper<>(); QueryWrapper<ProductOrderPrice> queryWrapper = new QueryWrapper<>();
queryWrapper.select(" sum(pay_price ) as pay_price"); queryWrapper.select(" sum(pay_price ) as pay_price");
queryWrapper.apply(" order_id in( select po.id from product_order po where po.status in ('1', '2', '4', '5') ) "); queryWrapper.apply(" order_id in( select po.id from product_order po where po.is_pay = '1') ");
ProductOrderPrice productOrder = productOrderPriceMapper.selectOne(queryWrapper); ProductOrderPrice productOrder = productOrderPriceMapper.selectOne(queryWrapper);
return productOrder == null ? BigDecimal.ZERO : productOrder.getPayPrice(); return productOrder == null ? BigDecimal.ZERO : productOrder.getPayPrice();
} }
@ -888,17 +890,27 @@ public class ProductOrderServiceImpl implements IProductOrderService {
updateWrapper.set(ProductOrder::getStatus, status); updateWrapper.set(ProductOrder::getStatus, status);
ProductOrderVo productOrderVo = baseMapper.selectVoById(id); ProductOrderVo productOrderVo = baseMapper.selectVoById(id);
if(status.equals("4")){ if(status.equals("4")){
updateWrapper.set(ProductOrder::getFinishDate, new Date()); LambdaUpdateWrapper<ProductOrder> finshUW = new LambdaUpdateWrapper<>();
updateWrapper.set(ProductOrder::getSettlement, 1L); finshUW.eq(ProductOrder::getId, id);
updateWrapper.eq(ProductOrder::getSettlement, 0L); finshUW.eq(ProductOrder::getSettlement, 0L);
ProductOrderPriceVo productOrderPriceVo = productOrderPriceMapper.selectVoById(id); finshUW.set(ProductOrder::getFinishDate, new Date());
BigDecimal settlementCurrentPrice = productOrderPriceVo.getSettlementCurrentPrice(); finshUW.set(ProductOrder::getSettlement, 1L);
if (productOrderVo.getSettlement() == 0L) { int update = baseMapper.update(finshUW);
sysBusinessBalanceService.addFrozenBalance(settlementCurrentPrice, productOrderVo.getBusinessId(), if (update > 0) {
"订单结算", id, "order"); ProductOrderPriceVo productOrderPriceVo = productOrderPriceMapper.selectVoById(id);
//订单抽成 BigDecimal settlementCurrentPrice = productOrderPriceVo.getSettlementCurrentPrice();
sysBalanceRecordService.insertByBo( new SysBalanceRecordBo(productOrderVo.getBusinessId(), "order", productOrderPriceVo.getServicePrice(), productOrderVo.getOrderNo())); if (productOrderVo.getSettlement() == 0L) {
sysBusinessBalanceService.addFrozenBalance(settlementCurrentPrice, productOrderVo.getBusinessId(),
"订单结算", id, "order");
//订单抽成
sysBalanceRecordService.insertByBo( new SysBalanceRecordBo(productOrderVo.getBusinessId(), "order", productOrderPriceVo.getServicePrice(), productOrderVo.getOrderNo()));
}
} }
}else if (status.equals("11")){
updateWrapper.set(ProductOrder::getFailRefundTime, new Date());
}else if (status.equals("9")){
//不允许退款
updateWrapper.set(ProductOrder::getCanRefund, "1");
} }
baseMapper.update(updateWrapper); baseMapper.update(updateWrapper);
@ -944,18 +956,21 @@ public class ProductOrderServiceImpl implements IProductOrderService {
lqw.eq("sb.del_flag", "0"); lqw.eq("sb.del_flag", "0");
List<ProductOrderVo> productOrderVos = baseMapper.selectSettlementList(lqw); List<ProductOrderVo> productOrderVos = baseMapper.selectSettlementList(lqw);
productOrderVos.forEach(productOrderVo -> { productOrderVos.forEach(productOrderVo -> {
log.info("结算订单号:{}", productOrderVo.getId());
ProductOrderPriceVo productOrderPriceVo = productOrderPriceService.queryById(productOrderVo.getId()); ProductOrderPriceVo productOrderPriceVo = productOrderPriceService.queryById(productOrderVo.getId());
BigDecimal settlementCurrentPrice = productOrderPriceVo.getSettlementCurrentPrice(); if (productOrderPriceVo != null) {
log.info("结算金额:{}", settlementCurrentPrice); BigDecimal settlementCurrentPrice = productOrderPriceVo.getSettlementCurrentPrice();
sysBusinessBalanceService.addBalance(settlementCurrentPrice, productOrderVo.getBusinessId(), log.info("结算金额:{}", settlementCurrentPrice);
"冻结转入余额", productOrderVo.getId(), "order"); sysBusinessBalanceService.addBalance(settlementCurrentPrice, productOrderVo.getBusinessId(),
sysBusinessBalanceService.subFrozenBalance(settlementCurrentPrice, productOrderVo.getBusinessId(), "冻结转入余额", productOrderVo.getId(), "order");
"结算扣除冻结金额", productOrderVo.getId(), "order"); sysBusinessBalanceService.subFrozenBalance(settlementCurrentPrice, productOrderVo.getBusinessId(),
LambdaUpdateWrapper<ProductOrder> updateWrapper = new LambdaUpdateWrapper<>(); "结算扣除冻结金额", productOrderVo.getId(), "order");
updateWrapper.eq(ProductOrder::getId, productOrderVo.getId()); LambdaUpdateWrapper<ProductOrder> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.set(ProductOrder::getSettlement, 2L); updateWrapper.eq(ProductOrder::getId, productOrderVo.getId());
updateWrapper.set(ProductOrder::getSettlementTime, new Date()); updateWrapper.set(ProductOrder::getSettlement, 2L);
baseMapper.update(updateWrapper); updateWrapper.set(ProductOrder::getSettlementTime, new Date());
baseMapper.update(updateWrapper);
}
}); });
} }
@ -1043,6 +1058,42 @@ public class ProductOrderServiceImpl implements IProductOrderService {
return wxPayOrderQueryResult; return wxPayOrderQueryResult;
} }
@Override
public void updateBusinessRemarkByOrderId(String recordMsg, Long id) {
LambdaUpdateWrapper<ProductOrder> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(ProductOrder::getId, id);
updateWrapper.set(ProductOrder::getBusinessRefund, recordMsg);
baseMapper.update(updateWrapper);
}
@Override
public void updateCanRefundRemarkByOrderId(String canRefund, Long id) {
LambdaUpdateWrapper<ProductOrder> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(ProductOrder::getId, id);
updateWrapper.set(ProductOrder::getCanRefund, canRefund);
baseMapper.update(updateWrapper);
}
@Override
@Transactional
public void refundFailToFinish() {
QueryWrapper<ProductOrder> lqw = new QueryWrapper<>();
//待结算
// lqw.in(ProductOrder::getStatus, "4", "5");
//完成时间小于设定时间
lqw.lt("fail_refund_time", DateUtil.offsetDay(new Date(), -2).toJdkDate());
lqw.eq("is_pay", "1");
lqw.eq("status", "11");
List<ProductOrderVo> productOrderVos = baseMapper.selectVoList(lqw);
for (ProductOrderVo productOrderVo : productOrderVos) {
updateStatusByOrderId("4", productOrderVo.getId());
updateCanRefundRemarkByOrderId ("1", productOrderVo.getId());
}
}
private ProductOrderVo insertOrderByVo(ProductOrderVo vo) { private ProductOrderVo insertOrderByVo(ProductOrderVo vo) {
Set<String> names = new HashSet<>(); Set<String> names = new HashSet<>();

100
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/RefundServiceImpl.java

@ -1,19 +1,17 @@
package org.dromara.system.service.impl; package org.dromara.system.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult; import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult;
import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest; import com.github.binarywang.wxpay.bean.request.WxPayRefundRequest;
import com.github.binarywang.wxpay.exception.WxPayException; import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.service.WxPayService; import com.github.binarywang.wxpay.service.WxPayService;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.dromara.common.core.config.properties.WxPayConfiguration; import org.dromara.common.core.config.properties.WxPayConfiguration;
import org.dromara.common.core.exception.ServiceException; import org.dromara.common.core.exception.ServiceException;
import org.dromara.common.core.utils.OrderNoUtils; import org.dromara.common.core.utils.OrderNoUtils;
import org.dromara.system.domain.ProductOrderRefund;
import org.dromara.system.domain.bo.*; import org.dromara.system.domain.bo.*;
import org.dromara.system.domain.vo.*; import org.dromara.system.domain.vo.*;
import org.dromara.system.mapper.ProductOrderRefundMapper;
import org.dromara.system.service.*; import org.dromara.system.service.*;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -24,6 +22,7 @@ import java.util.Date;
import java.util.List; import java.util.List;
@Service @Service
@Slf4j
public class RefundServiceImpl implements RefundService { public class RefundServiceImpl implements RefundService {
@Resource @Resource
private IProductOrderService productOrderService; private IProductOrderService productOrderService;
@ -122,30 +121,56 @@ public class RefundServiceImpl implements RefundService {
@Override @Override
@Transactional @Transactional
public int examineByBo(ExamineBo bo) { public int examineByBo(ExamineBo bo) {
ProductOrderRefundVo productOrderRefundVo = productOrderRefundService.queryById(bo.getId());
LambdaUpdateWrapper<ProductOrderRefund> luw = new LambdaUpdateWrapper<>();
luw.eq(ProductOrderRefund::getId, bo.getId());
if (bo.isAgree()) { if (bo.isAgree()) {
luw.set(ProductOrderRefund::getStatus, "1");
luw.set(ProductOrderRefund::getRefundMsg, ""); BigDecimal subPrice = BigDecimal.ZERO;
refundByVo(productOrderRefundVo); ProductOrderVo productOrderVo = productOrderService.queryById(bo.getId());
//退款金额是否等于商家的冻结金额加余额余额 List<ProductOrderItemsVo> itemsList = productOrderVo.getItemsList();
SysBusinessSubBalanceBo sysBusinessSubBalanceBo = sysBusinessBalanceService.checkFrozenBalance(productOrderRefundVo.getBusinessRefundPrice(), productOrderRefundVo.getBusinessId()); List<ProductOrderItemsRefundVo> itemsRefundList = itemsList.stream().map(item -> new ProductOrderItemsRefundVo().copy(item)).toList();
//商家先扣除冻结金额再扣除余额 ProductOrderRefundVo productOrderRefundVo = new ProductOrderRefundVo().copy(productOrderVo, itemsRefundList);
sysBusinessBalanceService.subFrozenBalance(sysBusinessSubBalanceBo.getSubFrozenBalance(), productOrderRefundVo.getBusinessId(), "用户退款", productOrderRefundVo.getOrderId(), "refundOrder"); // productOrderVo.setSettlement(1L);
sysBusinessBalanceService.subBalance(sysBusinessSubBalanceBo.getSubBalance(), productOrderRefundVo.getBusinessId(), "用户退款", productOrderRefundVo.getOrderId(), "refundOrder");
}else{
luw.set(ProductOrderRefund::getRefundMsg, bo.getRecordMsg());
luw.set(ProductOrderRefund::getStatus, "3");
Long orderId = productOrderRefundVo.getOrderId();
ProductOrderVo productOrderVo = productOrderService.queryById(orderId);
if (productOrderVo.getStatus().equals("8")) { if (productOrderVo.getStatus().equals("8")) {
productOrderService.updateStatusByOrderId("4", orderId); ProductOrderPriceVo productOrderPriceVo = productOrderVo.getProductOrderPriceVo();
BigDecimal currentPrice = productOrderPriceVo.getCurrentPrice();
BigDecimal payPrice = productOrderPriceVo.getPayPrice();
BigDecimal settlementPrice = productOrderPriceVo.getSettlementPrice();
BigDecimal settlementCurrentPrice = productOrderPriceVo.getSettlementCurrentPrice();
productOrderRefundVo.setRealPrice(payPrice);
subPrice(subPrice, productOrderRefundVo, productOrderPriceVo, currentPrice, payPrice, settlementPrice, settlementCurrentPrice);
productOrderRefundVo.setStatus("0");
productOrderRefundVo.setRefundNo(OrderNoUtils.getOrderNo("R"));
refundByVo(productOrderRefundVo);
//退款金额是否等于商家的冻结金额加余额余额
SysBusinessSubBalanceBo sysBusinessSubBalanceBo = sysBusinessBalanceService.checkFrozenBalance(settlementCurrentPrice, productOrderRefundVo.getBusinessId());
//商家先扣除冻结金额再扣除余额
productOrderService.updateStatusByOrderId("10", bo.getId());
productOrderService.updateBusinessRemarkByOrderId(bo.getRecordMsg(), bo.getId());
sysBusinessBalanceService.subBalance(sysBusinessSubBalanceBo.getSubBalance(), productOrderRefundVo.getBusinessId(), "用户退款", productOrderRefundVo.getOrderId(), "refundOrder");
sysBusinessBalanceService.subFrozenBalance(sysBusinessSubBalanceBo.getSubFrozenBalance(), productOrderRefundVo.getBusinessId(), "用户退款", productOrderRefundVo.getOrderId(), "refundOrder");
return 1;
} else {
throw new ServiceException("订单状态错误,不支持退款");
} }
}else{
productOrderService.updateStatusByOrderId("11", bo.getId());
} }
return productOrderRefundService.updateWrapper(luw); productOrderService.updateBusinessRemarkByOrderId(bo.getRecordMsg(), bo.getId());
} // productOrderService.updateCanRefundRemarkByOrderId("1", bo.getId());
return 1;
}
public void subPrice(BigDecimal subPrice, ProductOrderRefundVo productOrderRefundVo, ProductOrderPriceVo productOrderPriceVo,
BigDecimal currentPrice, BigDecimal payPrice, BigDecimal settlementPrice, BigDecimal settlementCurrentPrice) {
productOrderRefundVo.setRefundPrice(payPrice.subtract(subPrice));
productOrderPriceVo.setCurrentPrice(currentPrice.subtract(subPrice));
productOrderPriceVo.setSettlementPrice(settlementPrice.subtract(subPrice));
productOrderPriceVo.setSettlementCurrentPrice(settlementCurrentPrice.subtract(subPrice));
productOrderPriceVo.setServicePrice(BigDecimal.ZERO);
productOrderRefundVo.setBusinessRefundPrice(productOrderPriceVo.getSettlementCurrentPrice());
}
@Override @Override
public ProductOrderRefundVo checkByBo(ProductOrderRefundBo bo) { public ProductOrderRefundVo checkByBo(ProductOrderRefundBo bo) {
return validEntityBeforeSave(bo); return validEntityBeforeSave(bo);
@ -168,7 +193,7 @@ public class RefundServiceImpl implements RefundService {
BigDecimal refundPrice = productOrderRefundVo.getRefundPrice(); BigDecimal refundPrice = productOrderRefundVo.getRefundPrice();
if(refundPrice.compareTo(BigDecimal.ZERO) > 0 && flag.equals("true")){ if(refundPrice.compareTo(BigDecimal.ZERO) > 0 && flag.equals("true")){
AllRefundBo allRefundBo = new AllRefundBo(); AllRefundBo allRefundBo = new AllRefundBo();
Long orderId = productOrderRefundVo.getId(); Long orderId = productOrderRefundVo.getOrderId();
AllOrderVo allOrderVo = allOrderService.queryByProductOrderId(orderId); AllOrderVo allOrderVo = allOrderService.queryByProductOrderId(orderId);
allRefundBo.setOrderId(productOrderRefundVo.getId()); allRefundBo.setOrderId(productOrderRefundVo.getId());
allRefundBo.setAllOrderId(allOrderVo.getId()); allRefundBo.setAllOrderId(allOrderVo.getId());
@ -218,4 +243,33 @@ public class RefundServiceImpl implements RefundService {
throw new ServiceException("退款失败"); throw new ServiceException("退款失败");
} }
} }
@Override
@Transactional
public void startRefund(Long id) {
BigDecimal subPrice = BigDecimal.ZERO;
ProductOrderVo productOrderVo = productOrderService.queryById(id);
List<ProductOrderItemsVo> itemsList = productOrderVo.getItemsList();
List<ProductOrderItemsRefundVo> itemsRefundList = itemsList.stream().map(item -> new ProductOrderItemsRefundVo().copy(item)).toList();
ProductOrderRefundVo productOrderRefundVo = new ProductOrderRefundVo().copy(productOrderVo, itemsRefundList);
ProductOrderPriceVo productOrderPriceVo = productOrderVo.getProductOrderPriceVo();
BigDecimal currentPrice = productOrderPriceVo.getCurrentPrice();
BigDecimal payPrice = productOrderPriceVo.getPayPrice();
BigDecimal settlementPrice = productOrderPriceVo.getSettlementPrice();
BigDecimal settlementCurrentPrice = productOrderPriceVo.getSettlementCurrentPrice();
productOrderRefundVo.setRealPrice(payPrice);
subPrice(subPrice, productOrderRefundVo, productOrderPriceVo, currentPrice, payPrice, settlementPrice, settlementCurrentPrice);
productOrderRefundVo.setStatus("0");
productOrderRefundVo.setRefundNo(OrderNoUtils.getOrderNo("R"));
refundByVo(productOrderRefundVo);
//退款金额是否等于商家的冻结金额加余额余额
SysBusinessSubBalanceBo sysBusinessSubBalanceBo = sysBusinessBalanceService.checkFrozenBalance(settlementCurrentPrice, productOrderRefundVo.getBusinessId());
//商家先扣除冻结金额再扣除余额
productOrderService.updateStatusByOrderId("10",id);
productOrderService.updateBusinessRemarkByOrderId("自动退款", id);
sysBusinessBalanceService.subBalance(sysBusinessSubBalanceBo.getSubBalance(), productOrderRefundVo.getBusinessId(), "用户退款", productOrderRefundVo.getOrderId(), "refundOrder");
sysBusinessBalanceService.subFrozenBalance(sysBusinessSubBalanceBo.getSubFrozenBalance(), productOrderRefundVo.getBusinessId(), "用户退款", productOrderRefundVo.getOrderId(), "refundOrder");
}
} }

24
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysBusinessBalanceServiceImpl.java

@ -198,12 +198,10 @@ public class SysBusinessBalanceServiceImpl implements ISysBusinessBalanceService
} }
@Override @Override
public void subFrozenBalance(BigDecimal amount, Long businessId, String remark, Long id, String orderType) { public void subFrozenBalance(BigDecimal amount, Long businessId, String remark, Long id, String orderType) {
if (amount.compareTo(BigDecimal.ZERO)> 0) { if (amount.compareTo(BigDecimal.ZERO)> 0) {
int update = baseMapper.subFrozenBalance(amount, businessId); int update = baseMapper.subFrozenBalance(amount, businessId);
if (update == 0) {
throw new ServiceException("运营余额不足!");
}
// 减速冻结金额记录 // 减速冻结金额记录
SysBusinessBalanceRecordBo bo = new SysBusinessBalanceRecordBo(businessId, "frozen_balance", BigDecimal.ZERO.subtract(amount), remark, id, orderType); SysBusinessBalanceRecordBo bo = new SysBusinessBalanceRecordBo(businessId, "frozen_balance", BigDecimal.ZERO.subtract(amount), remark, id, orderType);
sysBusinessBalanceRecordService.insertByBo(bo); sysBusinessBalanceRecordService.insertByBo(bo);
@ -223,19 +221,15 @@ public class SysBusinessBalanceServiceImpl implements ISysBusinessBalanceService
BigDecimal balanceDeduction = BigDecimal.ZERO; BigDecimal balanceDeduction = BigDecimal.ZERO;
BigDecimal frozenBalanceDeduction = BigDecimal.ZERO; BigDecimal frozenBalanceDeduction = BigDecimal.ZERO;
if (frozenBalance.compareTo(fee) >= 0) { if (balance.compareTo(fee) >= 0) {
// 冻结余额足够,直接从冻结余额中扣除费用 // 余额足够,直接从余额中扣除费用
frozenBalanceDeduction = fee; balanceDeduction = fee;
} else { } else {
// 冻结余额不足,先扣除全部冻结余额 // 冻结余额不足,先扣除全部冻结余额
frozenBalanceDeduction = frozenBalance; balanceDeduction = balance;
BigDecimal remainingFee = fee.subtract(frozenBalance); BigDecimal remainingFee = fee.subtract(balance);
// 余额足够支付剩余费用
if (balance.compareTo(remainingFee) >= 0) { frozenBalanceDeduction = remainingFee;
// 余额足够支付剩余费用
balanceDeduction = remainingFee;
balance = balance.subtract(remainingFee);
}
} }
sysBusinessSubBalanceBo.setSubBalance(balanceDeduction); sysBusinessSubBalanceBo.setSubBalance(balanceDeduction);
sysBusinessSubBalanceBo.setSubFrozenBalance(frozenBalanceDeduction); sysBusinessSubBalanceBo.setSubFrozenBalance(frozenBalanceDeduction);

4
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysBusinessRecordServiceImpl.java

@ -272,7 +272,9 @@ public class SysBusinessRecordServiceImpl implements ISysBusinessRecordService {
queryWrapper.last("limit 1"); queryWrapper.last("limit 1");
queryWrapper.orderByDesc("create_time"); queryWrapper.orderByDesc("create_time");
SysBusinessVo sysBusinessVo = sysBusinessMapper.selectVoOne(queryWrapper); SysBusinessVo sysBusinessVo = sysBusinessMapper.selectVoOne(queryWrapper);
bo.setMobile(sysBusinessVo.getMobile()); if(sysBusinessVo != null){
bo.setMobile(sysBusinessVo.getMobile());
}
} }
if(bo.getSignContractId() != null){ if(bo.getSignContractId() != null){

27
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysWithdrawalServiceImpl.java

@ -1,5 +1,6 @@
package org.dromara.system.service.impl; package org.dromara.system.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.UUID; import cn.hutool.core.lang.UUID;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@ -40,10 +41,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.security.cert.X509Certificate; import java.security.cert.X509Certificate;
import java.util.ArrayList; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Collection;
/** /**
@ -321,6 +319,7 @@ public class SysWithdrawalServiceImpl implements ISysWithdrawalService {
if (bo.isAgree()) { if (bo.isAgree()) {
updateWrapper.set("status", 1); updateWrapper.set("status", 1);
updateWrapper.set("remark", ""); updateWrapper.set("remark", "");
updateWrapper.set("agree_time", new Date());
Long type = sysWithdrawalVo.getType(); Long type = sysWithdrawalVo.getType();
//发起微信转账api //发起微信转账api
if(type == 2){ if(type == 2){
@ -437,4 +436,24 @@ public class SysWithdrawalServiceImpl implements ISysWithdrawalService {
} }
} }
} }
@Override
@Transactional
public void cancelWxByAgreeTime() {
LambdaQueryWrapper<SysWithdrawal> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SysWithdrawal::getStatus, 1);
queryWrapper.le(SysWithdrawal::getAgreeTime, DateUtil.offsetDay(new Date(), -1).toJdkDate());
queryWrapper.isNotNull(SysWithdrawal::getAgreeTime);
queryWrapper.eq(SysWithdrawal::getType, 1);
List<SysWithdrawalVo> sysWithdrawalVos = baseMapper.selectVoList(queryWrapper);
for (SysWithdrawalVo sysWithdrawalVo : sysWithdrawalVos) {
UpdateWrapper<SysWithdrawal> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("id", sysWithdrawalVo.getId());
updateWrapper.set("status", 2);
updateWrapper.set("remark", "长时间为确认,已取消");
//增加余额
sysBusinessBalanceService.addBalance(sysWithdrawalVo.getAmount(), sysWithdrawalVo.getBusinessId(), "提现驳回", sysWithdrawalVo.getId(),"withdrawal");
}
}
} }

8
ruoyi-modules/ruoyi-job/src/main/java/org/dromara/job/snailjob/BusinessJobExecutor.java → ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/task/BusinessJobExecutor.java

@ -1,4 +1,4 @@
package org.dromara.job.snailjob; package org.dromara.system.task;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
@ -6,7 +6,9 @@ import lombok.extern.slf4j.Slf4j;
import org.dromara.system.domain.bo.SysBusinessBo; import org.dromara.system.domain.bo.SysBusinessBo;
import org.dromara.system.domain.vo.SysBusinessVo; import org.dromara.system.domain.vo.SysBusinessVo;
import org.dromara.system.domain.vo.SysContractVo; import org.dromara.system.domain.vo.SysContractVo;
import org.dromara.system.service.*; import org.dromara.system.service.DeliveryShopService;
import org.dromara.system.service.ISysBusinessService;
import org.dromara.system.service.ISysContractService;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -36,7 +38,7 @@ public class BusinessJobExecutor {
} }
@Scheduled(cron = "*/5 * * * * ?") @Scheduled(cron = "*/10 * * * * ?")
public void createShop(){ public void createShop(){
SysBusinessBo bo = new SysBusinessBo(); SysBusinessBo bo = new SysBusinessBo();
bo.setCreateShopNo(true); bo.setCreateShopNo(true);

4
ruoyi-modules/ruoyi-job/src/main/java/org/dromara/job/snailjob/BusinessMonthStatisticsExecutor.java → ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/task/BusinessMonthStatisticsExecutor.java

@ -1,13 +1,11 @@
package org.dromara.job.snailjob; package org.dromara.system.task;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.dromara.system.domain.bo.SysBusinessBo; import org.dromara.system.domain.bo.SysBusinessBo;
import org.dromara.system.domain.vo.SysBusinessVo; import org.dromara.system.domain.vo.SysBusinessVo;
import org.dromara.system.service.IBusinessCouponService;
import org.dromara.system.service.IBusinessMonthStatisticsService; import org.dromara.system.service.IBusinessMonthStatisticsService;
import org.dromara.system.service.IPromotionCouponService;
import org.dromara.system.service.ISysBusinessService; import org.dromara.system.service.ISysBusinessService;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;

2
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/task/BusinessStatsTask.java → ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/task/BusinessStatsExecutor.java

@ -15,7 +15,7 @@ import java.util.Date;
@Component @Component
@EnableScheduling @EnableScheduling
@Slf4j @Slf4j
public class BusinessStatsTask { public class BusinessStatsExecutor {
@Autowired @Autowired
private RabbitTemplate rabbitTemplate; private RabbitTemplate rabbitTemplate;

2
ruoyi-modules/ruoyi-job/src/main/java/org/dromara/job/snailjob/CouponJobExecutor.java → ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/task/CouponJobExecutor.java

@ -1,4 +1,4 @@
package org.dromara.job.snailjob; package org.dromara.system.task;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;

63
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/task/OrderJobExecutor.java

@ -0,0 +1,63 @@
package org.dromara.system.task;
import cn.hutool.core.date.DateUtil;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.dromara.system.domain.bo.ProductOrderBo;
import org.dromara.system.domain.vo.ProductOrderVo;
import org.dromara.system.service.IProductOrderService;
import org.dromara.system.service.RefundService;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
@Component
@EnableScheduling
@Slf4j
public class OrderJobExecutor {
@Resource
private IProductOrderService productOrderService;
@Resource
private RefundService refundService;
@Scheduled(cron = "0 * * * * ?")
public void run(){
log.info("定时处理支付过期...开始:{}", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
productOrderService.cancelByPayExpire();
log.info("定时处理支付过期...结束:{}", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
}
@Scheduled(cron = "0 * * * * ?")
public void refundFailToFinish(){
log.info("退款失败订单转完成订单...开始:{}", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
productOrderService.refundFailToFinish();
log.info("退款失败订单转完成订单...结束:{}", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
log.info("退款中订单发起退款...开始:{}", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
ProductOrderBo bo = new ProductOrderBo();
bo.setStatus("8");
bo.setStartRefundTime(new Date());
List<ProductOrderVo> productOrderVos = productOrderService.queryList(bo);
for (ProductOrderVo productOrderVo : productOrderVos) {
try {
refundService.startRefund(productOrderVo.getId());
}catch (Exception e){
log.error("提现失败:", e);
}
}
log.info("退款中订单发起退款...结束:{}", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
}
@Scheduled(cron = "0 0 * * * ?")
public void settlement(){
log.info("订单结算...开始:{}", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
productOrderService.settlement();
log.info("订单结算...结束:{}", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
}
}

51
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/task/SysWithdrawalExecutor.java

@ -0,0 +1,51 @@
package org.dromara.system.task;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaIgnore;
import cn.hutool.core.date.DateUtil;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.extern.slf4j.Slf4j;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.excel.utils.ExcelUtil;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.web.core.BaseController;
import org.dromara.system.domain.bo.ExamineBo;
import org.dromara.system.domain.bo.SysWithdrawalBo;
import org.dromara.system.domain.vo.SysWithdrawalVo;
import org.dromara.system.service.ISysWithdrawalService;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List;
/**
* 系统提现
*
* @author William
* @date 2025-02-20
*/
@Component
@EnableScheduling
@Slf4j
public class SysWithdrawalExecutor extends BaseController {
@Resource
private ISysWithdrawalService sysWithdrawalService;
@Scheduled(cron = "0 * * * * ?")
public void run(){
log.info("定时处理同意未提现的订单...开始:{}", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
sysWithdrawalService.cancelWxByAgreeTime();
log.info("定时处理同意未提现的订单...结束:{}", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
}
}

4
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/ProductOrderPriceMapper.xml

@ -16,7 +16,7 @@
<if test="businessId != null"> <if test="businessId != null">
and business_id = #{businessId} and business_id = #{businessId}
</if> </if>
and status in ('1', '2', '4', '5', '9') and is_pay = '1'
<if test="createTime != null and dateFormat != '' "> <if test="createTime != null and dateFormat != '' ">
and date_format(create_time, #{dateFormat}) = date_format(#{createTime}, #{dateFormat}) and date_format(create_time, #{dateFormat}) = date_format(#{createTime}, #{dateFormat})
</if> </if>
@ -33,7 +33,7 @@
<if test="businessId != null"> <if test="businessId != null">
and business_id = #{businessId} and business_id = #{businessId}
</if> </if>
and status in ('9') and status = 9 and is_pay = '1'
<if test="createTime != null and dateFormat != '' "> <if test="createTime != null and dateFormat != '' ">
and date_format(create_time, #{dateFormat}) = date_format(#{createTime}, #{dateFormat}) and date_format(create_time, #{dateFormat}) = date_format(#{createTime}, #{dateFormat})
</if> </if>

5
ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/SysBusinessBalanceMapper.xml

@ -14,13 +14,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update> </update>
<update id="subFrozenBalance"> <update id="subFrozenBalance">
update sys_business_balance set frozen_balance = frozen_balance - #{amount} where business_id = #{businessId} and frozen_balance >= #{amount} update sys_business_balance set frozen_balance = frozen_balance - #{amount} where business_id = #{businessId}
</update> </update>
<update id="subAmount"> <update id="subAmount">
update sys_business_balance set balance = balance - #{amount} where business_id = #{businessId} and balance >= #{amount} update sys_business_balance set balance = balance - #{amount} where business_id = #{businessId} and balance >= #{amount}
</update> </update>
<update id="addAmount"> <update id="addAmount">
update sys_business_balance set balance = balance + #{amount} where business_id = #{businessId} update sys_business_balance set balance = balance + #{amount} where business_id = #{businessId}

Loading…
Cancel
Save