Browse Source

用户退款48小时内处理订单

master
wengding 4 days ago
parent
commit
4fcc2de2bb
  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. 8
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/bo/ProductOrderBo.java
  8. 21
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/vo/ProductOrderVo.java
  9. 1
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/vo/SysBusinessBalanceRecordVo.java
  10. 7
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/IProductOrderService.java
  11. 2
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/ISysWithdrawalService.java
  12. 2
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/RefundService.java
  13. 17
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/calculate/impl/DeliveryOrderCalculateService.java
  14. 15
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/calculate/impl/ExpressDeliveryOrderCalculateService.java
  15. 27
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/calculate/impl/SelfPickUpOrderCalculateService.java
  16. 2
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/AllOrderServiceImpl.java
  17. 3
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/OrderServiceImpl.java
  18. 103
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/ProductOrderServiceImpl.java
  19. 100
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/RefundServiceImpl.java
  20. 24
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysBusinessBalanceServiceImpl.java
  21. 4
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/SysBusinessRecordServiceImpl.java
  22. 8
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/task/BusinessJobExecutor.java
  23. 4
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/task/BusinessMonthStatisticsExecutor.java
  24. 2
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/task/BusinessStatsExecutor.java
  25. 2
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/task/CouponJobExecutor.java
  26. 63
      ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/task/OrderJobExecutor.java
  27. 4
      ruoyi-modules/ruoyi-system/src/main/resources/mapper/system/ProductOrderPriceMapper.xml
  28. 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-name: Authorization
# 是否允许同一账号并发登录 (为true时允许一起登录, 为false时新登录挤掉旧登录)
is-concurrent: false
is-concurrent: true
# 在多人登录同一账号时,是否共用一个token (为true时所有登录共用一个token, 为false时每次登录新建一个token)
is-share: false
# 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 expressCode
* @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 refundRemark;
private String refundImage;
private String businessRefund;
private String canRefund;
/**
* 0未付款1已付款
*/
private String isPay;
/**
* 发起退款时间
*/
private Date startRefundTime;
/**
* 退款失败时间
*/
private Date failRefundTime;
}

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无法结算
*/
private Long settlement;
/**
* 发起退款时间
*/
private Date startRefundTime;
/**
* 退款失败时间
*/
private Date failRefundTime;
}

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 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 = "")
private String orderNo;
private Long orderId;
/**
* 创建时间
*/

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);
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;
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 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());
appProductAttrValueMapper.addStock(productOrderItemsVo.getProductId(), productOrderItemsVo.getProductAttrSn(), productOrderVo.getNum());
}
productOrderVo.setStatus("3");
}else {
BigDecimal subPrice = BigDecimal.ZERO;
List<ProductOrderItemsVo> itemsList = productOrderVo.getItemsList();
@ -197,6 +200,7 @@ public class DeliveryOrderCalculateService implements OrderCalculateService {
ProductOrderRefundVo productOrderRefundVo = new ProductOrderRefundVo().copy(productOrderVo, itemsRefundList);
productOrderVo.setSettlement(1L);
if (productOrderVo.getStatus().equals("1")) {
productOrderVo.setStatus("3");
if (productOrderVo.getReason() == 2L) {
ProductOrderPriceVo productOrderPriceVo = productOrderVo.getProductOrderPriceVo();
BigDecimal currentPrice = productOrderPriceVo.getCurrentPrice();
@ -217,6 +221,8 @@ public class DeliveryOrderCalculateService implements OrderCalculateService {
refundService.refundByVo(productOrderRefundVo);
}
}else if(productOrderVo.getStatus().equals("2") ) {
productOrderVo.setStatus("3");
if (productOrderVo.getReason() == 2L) {
ProductOrderPriceVo productOrderPriceVo = productOrderVo.getProductOrderPriceVo();
BigDecimal currentPrice = productOrderPriceVo.getCurrentPrice();
@ -255,14 +261,19 @@ public class DeliveryOrderCalculateService implements OrderCalculateService {
productOrderRefundVo.setImageList(bo.getImageList());
productOrderRefundVo.setRefundNo(OrderNoUtils.getOrderNo("R"));
//售后
productOrderMapper.updateStatusByOrderId("8", id);
refundService.insertByVo(productOrderRefundVo);
// refundService.insertByVo(productOrderRefundVo);
// refundService.refundByVo(productOrderRefundVo);
productOrderVo.setStartRefundTime(new Date());
productOrderVo.setStatus("8");
if (!productOrderVo.getCanRefund().equals("0")) {
throw new ServiceException("该订单不允许退款");
}
}else{
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 java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
@ -156,6 +157,7 @@ public class ExpressDeliveryOrderCalculateService implements OrderCalculateServi
appBusinessProductMapper.addStock(productOrderItemsVo.getProductId(), productOrderVo.getNum());
appProductAttrValueMapper.addStock(productOrderItemsVo.getProductId(), productOrderItemsVo.getProductAttrSn(), productOrderVo.getNum());
}
productOrderVo.setStatus("3");
}else {
BigDecimal subPrice = BigDecimal.ZERO;
List<ProductOrderItemsVo> itemsList = productOrderVo.getItemsList();
@ -163,6 +165,8 @@ public class ExpressDeliveryOrderCalculateService implements OrderCalculateServi
ProductOrderRefundVo productOrderRefundVo = new ProductOrderRefundVo().copy(productOrderVo, itemsRefundList);
productOrderVo.setSettlement(1L);
if (productOrderVo.getStatus().equals("1")) {
productOrderVo.setStatus("3");
if (productOrderVo.getReason() == 2L) {
ProductOrderPriceVo productOrderPriceVo = productOrderVo.getProductOrderPriceVo();
BigDecimal currentPrice = productOrderPriceVo.getCurrentPrice();
@ -185,6 +189,8 @@ public class ExpressDeliveryOrderCalculateService implements OrderCalculateServi
}
}else if(productOrderVo.getStatus().equals("2")) {
productOrderVo.setStatus("3");
if (productOrderVo.getReason() == 2L) {
ProductOrderPriceVo productOrderPriceVo = productOrderVo.getProductOrderPriceVo();
BigDecimal currentPrice = productOrderPriceVo.getCurrentPrice();
@ -217,20 +223,21 @@ public class ExpressDeliveryOrderCalculateService implements OrderCalculateServi
BigDecimal settlementPrice = productOrderPriceVo.getSettlementPrice();
BigDecimal settlementCurrentPrice = productOrderPriceVo.getSettlementCurrentPrice();
productOrderRefundVo.setRealPrice(payPrice);
// subPrice = productOrderPriceVo.getPackagePrice();
// subPrice = productOrderPriceVo.getPackagePrice();
subPrice(subPrice, productOrderRefundVo, productOrderPriceVo, currentPrice, payPrice, settlementPrice, settlementCurrentPrice);
productOrderRefundVo.setStatus("0");
productOrderRefundVo.setRefundNo(OrderNoUtils.getOrderNo("R"));
productOrderMapper.updateStatusByOrderId("8", id);
productOrderRefundVo.setRefundMsg(bo.getRemark());
productOrderRefundVo.setImageList(bo.getImageList());
productOrderVo.setStartRefundTime(new Date());
refundService.insertByVo(productOrderRefundVo);
//refundService.insertByVo(productOrderRefundVo);
//refundService.refundByVo(productOrderRefundVo);
productOrderVo.setStatus("8");
}else{
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 java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
@ -89,12 +90,12 @@ public class SelfPickUpOrderCalculateService implements OrderCalculateService {
@Override
public void buildAddress(ProductOrderBo bo, SysBusinessVo sysBusinessVo) {
bo.setUserName(bo.getUserName());
bo.setMobile(bo.getMobile());
bo.setArea(sysBusinessVo.getArea());
bo.setAddress(sysBusinessVo.getAddress());
bo.setLat(sysBusinessVo.getLat());
bo.setLng(sysBusinessVo.getLng());
bo.setUserName(bo.getUserName());
bo.setMobile(bo.getMobile());
bo.setArea(sysBusinessVo.getArea());
bo.setAddress(sysBusinessVo.getAddress());
bo.setLat(sysBusinessVo.getLat());
bo.setLng(sysBusinessVo.getLng());
}
@Override
@ -110,6 +111,9 @@ public class SelfPickUpOrderCalculateService implements OrderCalculateService {
appBusinessProductMapper.addStock(productOrderItemsVo.getProductId(), productOrderVo.getNum());
appProductAttrValueMapper.addStock(productOrderItemsVo.getProductId(), productOrderItemsVo.getProductAttrSn(), productOrderVo.getNum());
}
productOrderMapper.updateStatusByOrderId("3", id);
productOrderVo.setStatus("3");
}else {
BigDecimal subPrice = BigDecimal.ZERO;
List<ProductOrderItemsVo> itemsList = productOrderVo.getItemsList();
@ -117,7 +121,6 @@ public class SelfPickUpOrderCalculateService implements OrderCalculateService {
ProductOrderRefundVo productOrderRefundVo = new ProductOrderRefundVo().copy(productOrderVo, itemsRefundList);
productOrderVo.setSettlement(1L);
if (productOrderVo.getStatus().equals("1") || productOrderVo.getStatus().equals("2") ) {
ProductOrderPriceVo productOrderPriceVo = productOrderVo.getProductOrderPriceVo();
BigDecimal currentPrice = productOrderPriceVo.getCurrentPrice();
BigDecimal payPrice = productOrderPriceVo.getPayPrice();
@ -127,6 +130,7 @@ public class SelfPickUpOrderCalculateService implements OrderCalculateService {
subPrice(subPrice, productOrderRefundVo, productOrderPriceVo, currentPrice, payPrice, settlementPrice, settlementCurrentPrice);
productOrderRefundVo.setStatus("1");
productOrderRefundVo.setRefundNo(OrderNoUtils.getOrderNo("R"));
productOrderVo.setStatus("3");
refundService.refundByVo(productOrderRefundVo);
}else if(productOrderVo.getStatus().equals("4")){
ProductOrderPriceVo productOrderPriceVo = productOrderVo.getProductOrderPriceVo();
@ -139,15 +143,18 @@ public class SelfPickUpOrderCalculateService implements OrderCalculateService {
subPrice(subPrice, productOrderRefundVo, productOrderPriceVo, currentPrice, payPrice, settlementPrice, settlementCurrentPrice);
productOrderRefundVo.setStatus("0");
productOrderRefundVo.setRefundNo(OrderNoUtils.getOrderNo("R"));
productOrderMapper.updateStatusByOrderId("8", id);
productOrderRefundVo.setRefundMsg(bo.getRemark());
productOrderRefundVo.setImageList(bo.getImageList());
refundService.insertByVo(productOrderRefundVo);
// refundService.insertByVo(productOrderRefundVo);
productOrderVo.setStatus("8");
productOrderVo.setStartRefundTime(new Date());
}else{
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){
QueryWrapper<AllOrder> wrapper = new QueryWrapper<>();
wrapper.eq("order_id", id);
wrapper.eq("order_type", 1L);
wrapper.eq("order_type", "01");
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);
}
productOrderVo.setRefundRemark(bo.getRemark());
productOrderVo.setRefundImage(bo.getImageList());
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(StringUtils.isNotBlank(bo.getStatus()), ProductOrder::getStatus, bo.getStatus());
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());
return lqw;
}
@ -590,6 +591,7 @@ public class ProductOrderServiceImpl implements IProductOrderService {
public void paySuccess(Long orderId, BigDecimal cashPrice) {
ProductOrderVo productOrderVo = queryById(orderId);
productOrderVo.setStatus("1");
productOrderVo.setIsPay("1");
productOrderVo.setPayTime(new Date());
productOrderPriceService.updateRealPriceByOrderId(cashPrice, orderId);
//修改订单数据
@ -753,7 +755,7 @@ public class ProductOrderServiceImpl implements IProductOrderService {
@Override
public Long getOrderCount() {
QueryWrapper<ProductOrder> queryWrapper = new QueryWrapper<>();
queryWrapper.in("status", "1", "2", "4", "5");
queryWrapper.eq("is_pay", "1");
return baseMapper.selectCount(queryWrapper);
}
@ -797,7 +799,7 @@ public class ProductOrderServiceImpl implements IProductOrderService {
@Override
public Long getOrderUserCount() {
QueryWrapper<ProductOrder> queryWrapper = new QueryWrapper<>();
queryWrapper.in("status", "1", "2", "4", "5");
queryWrapper.eq("is_pay", "1");
return baseMapper.selectCount(queryWrapper);
}
@ -805,7 +807,7 @@ public class ProductOrderServiceImpl implements IProductOrderService {
public Long getYesterdayOrderCount() {
Date jdkDate = DateUtil.offsetDay(new Date(), -1).toJdkDate();
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);
return baseMapper.selectCount(queryWrapper);
}
@ -815,7 +817,7 @@ public class ProductOrderServiceImpl implements IProductOrderService {
Date jdkDate = DateUtil.offsetDay(new Date(), -1).toJdkDate();
QueryWrapper<ProductOrderPrice> queryWrapper = new QueryWrapper<>();
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);
return productOrder == null ? BigDecimal.ZERO : productOrder.getPayPrice();
}
@ -824,7 +826,7 @@ public class ProductOrderServiceImpl implements IProductOrderService {
public BigDecimal getTotalAmount() {
QueryWrapper<ProductOrderPrice> queryWrapper = new QueryWrapper<>();
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);
return productOrder == null ? BigDecimal.ZERO : productOrder.getPayPrice();
}
@ -888,17 +890,27 @@ public class ProductOrderServiceImpl implements IProductOrderService {
updateWrapper.set(ProductOrder::getStatus, status);
ProductOrderVo productOrderVo = baseMapper.selectVoById(id);
if(status.equals("4")){
updateWrapper.set(ProductOrder::getFinishDate, new Date());
updateWrapper.set(ProductOrder::getSettlement, 1L);
updateWrapper.eq(ProductOrder::getSettlement, 0L);
ProductOrderPriceVo productOrderPriceVo = productOrderPriceMapper.selectVoById(id);
BigDecimal settlementCurrentPrice = productOrderPriceVo.getSettlementCurrentPrice();
if (productOrderVo.getSettlement() == 0L) {
sysBusinessBalanceService.addFrozenBalance(settlementCurrentPrice, productOrderVo.getBusinessId(),
"订单结算", id, "order");
//订单抽成
sysBalanceRecordService.insertByBo( new SysBalanceRecordBo(productOrderVo.getBusinessId(), "order", productOrderPriceVo.getServicePrice(), productOrderVo.getOrderNo()));
LambdaUpdateWrapper<ProductOrder> finshUW = new LambdaUpdateWrapper<>();
finshUW.eq(ProductOrder::getId, id);
finshUW.eq(ProductOrder::getSettlement, 0L);
finshUW.set(ProductOrder::getFinishDate, new Date());
finshUW.set(ProductOrder::getSettlement, 1L);
int update = baseMapper.update(finshUW);
if (update > 0) {
ProductOrderPriceVo productOrderPriceVo = productOrderPriceMapper.selectVoById(id);
BigDecimal settlementCurrentPrice = productOrderPriceVo.getSettlementCurrentPrice();
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);
@ -944,18 +956,21 @@ public class ProductOrderServiceImpl implements IProductOrderService {
lqw.eq("sb.del_flag", "0");
List<ProductOrderVo> productOrderVos = baseMapper.selectSettlementList(lqw);
productOrderVos.forEach(productOrderVo -> {
log.info("结算订单号:{}", productOrderVo.getId());
ProductOrderPriceVo productOrderPriceVo = productOrderPriceService.queryById(productOrderVo.getId());
BigDecimal settlementCurrentPrice = productOrderPriceVo.getSettlementCurrentPrice();
log.info("结算金额:{}", settlementCurrentPrice);
sysBusinessBalanceService.addBalance(settlementCurrentPrice, productOrderVo.getBusinessId(),
"冻结转入余额", productOrderVo.getId(), "order");
sysBusinessBalanceService.subFrozenBalance(settlementCurrentPrice, productOrderVo.getBusinessId(),
"结算扣除冻结金额", productOrderVo.getId(), "order");
LambdaUpdateWrapper<ProductOrder> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(ProductOrder::getId, productOrderVo.getId());
updateWrapper.set(ProductOrder::getSettlement, 2L);
updateWrapper.set(ProductOrder::getSettlementTime, new Date());
baseMapper.update(updateWrapper);
if (productOrderPriceVo != null) {
BigDecimal settlementCurrentPrice = productOrderPriceVo.getSettlementCurrentPrice();
log.info("结算金额:{}", settlementCurrentPrice);
sysBusinessBalanceService.addBalance(settlementCurrentPrice, productOrderVo.getBusinessId(),
"冻结转入余额", productOrderVo.getId(), "order");
sysBusinessBalanceService.subFrozenBalance(settlementCurrentPrice, productOrderVo.getBusinessId(),
"结算扣除冻结金额", productOrderVo.getId(), "order");
LambdaUpdateWrapper<ProductOrder> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(ProductOrder::getId, productOrderVo.getId());
updateWrapper.set(ProductOrder::getSettlement, 2L);
updateWrapper.set(ProductOrder::getSettlementTime, new Date());
baseMapper.update(updateWrapper);
}
});
}
@ -1043,6 +1058,42 @@ public class ProductOrderServiceImpl implements IProductOrderService {
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) {
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;
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.request.WxPayRefundRequest;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.service.WxPayService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.dromara.common.core.config.properties.WxPayConfiguration;
import org.dromara.common.core.exception.ServiceException;
import org.dromara.common.core.utils.OrderNoUtils;
import org.dromara.system.domain.ProductOrderRefund;
import org.dromara.system.domain.bo.*;
import org.dromara.system.domain.vo.*;
import org.dromara.system.mapper.ProductOrderRefundMapper;
import org.dromara.system.service.*;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -24,6 +22,7 @@ import java.util.Date;
import java.util.List;
@Service
@Slf4j
public class RefundServiceImpl implements RefundService {
@Resource
private IProductOrderService productOrderService;
@ -122,30 +121,56 @@ public class RefundServiceImpl implements RefundService {
@Override
@Transactional
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()) {
luw.set(ProductOrderRefund::getStatus, "1");
luw.set(ProductOrderRefund::getRefundMsg, "");
refundByVo(productOrderRefundVo);
//退款金额是否等于商家的冻结金额加余额余额
SysBusinessSubBalanceBo sysBusinessSubBalanceBo = sysBusinessBalanceService.checkFrozenBalance(productOrderRefundVo.getBusinessRefundPrice(), productOrderRefundVo.getBusinessId());
//商家先扣除冻结金额再扣除余额
sysBusinessBalanceService.subFrozenBalance(sysBusinessSubBalanceBo.getSubFrozenBalance(), productOrderRefundVo.getBusinessId(), "用户退款", productOrderRefundVo.getOrderId(), "refundOrder");
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);
BigDecimal subPrice = BigDecimal.ZERO;
ProductOrderVo productOrderVo = productOrderService.queryById(bo.getId());
List<ProductOrderItemsVo> itemsList = productOrderVo.getItemsList();
List<ProductOrderItemsRefundVo> itemsRefundList = itemsList.stream().map(item -> new ProductOrderItemsRefundVo().copy(item)).toList();
ProductOrderRefundVo productOrderRefundVo = new ProductOrderRefundVo().copy(productOrderVo, itemsRefundList);
// productOrderVo.setSettlement(1L);
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
public ProductOrderRefundVo checkByBo(ProductOrderRefundBo bo) {
return validEntityBeforeSave(bo);
@ -168,7 +193,7 @@ public class RefundServiceImpl implements RefundService {
BigDecimal refundPrice = productOrderRefundVo.getRefundPrice();
if(refundPrice.compareTo(BigDecimal.ZERO) > 0 && flag.equals("true")){
AllRefundBo allRefundBo = new AllRefundBo();
Long orderId = productOrderRefundVo.getId();
Long orderId = productOrderRefundVo.getOrderId();
AllOrderVo allOrderVo = allOrderService.queryByProductOrderId(orderId);
allRefundBo.setOrderId(productOrderRefundVo.getId());
allRefundBo.setAllOrderId(allOrderVo.getId());
@ -218,4 +243,33 @@ public class RefundServiceImpl implements RefundService {
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
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) {
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);
sysBusinessBalanceRecordService.insertByBo(bo);
@ -223,19 +221,15 @@ public class SysBusinessBalanceServiceImpl implements ISysBusinessBalanceService
BigDecimal balanceDeduction = BigDecimal.ZERO;
BigDecimal frozenBalanceDeduction = BigDecimal.ZERO;
if (frozenBalance.compareTo(fee) >= 0) {
// 冻结余额足够,直接从冻结余额中扣除费用
frozenBalanceDeduction = fee;
if (balance.compareTo(fee) >= 0) {
// 余额足够,直接从余额中扣除费用
balanceDeduction = fee;
} else {
// 冻结余额不足,先扣除全部冻结余额
frozenBalanceDeduction = frozenBalance;
BigDecimal remainingFee = fee.subtract(frozenBalance);
if (balance.compareTo(remainingFee) >= 0) {
// 余额足够支付剩余费用
balanceDeduction = remainingFee;
balance = balance.subtract(remainingFee);
}
balanceDeduction = balance;
BigDecimal remainingFee = fee.subtract(balance);
// 余额足够支付剩余费用
frozenBalanceDeduction = remainingFee;
}
sysBusinessSubBalanceBo.setSubBalance(balanceDeduction);
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.orderByDesc("create_time");
SysBusinessVo sysBusinessVo = sysBusinessMapper.selectVoOne(queryWrapper);
bo.setMobile(sysBusinessVo.getMobile());
if(sysBusinessVo != null){
bo.setMobile(sysBusinessVo.getMobile());
}
}
if(bo.getSignContractId() != null){

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 jakarta.annotation.Resource;
@ -6,7 +6,9 @@ import lombok.extern.slf4j.Slf4j;
import org.dromara.system.domain.bo.SysBusinessBo;
import org.dromara.system.domain.vo.SysBusinessVo;
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.Scheduled;
import org.springframework.stereotype.Component;
@ -36,7 +38,7 @@ public class BusinessJobExecutor {
}
@Scheduled(cron = "*/5 * * * * ?")
@Scheduled(cron = "*/10 * * * * ?")
public void createShop(){
SysBusinessBo bo = new SysBusinessBo();
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 jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.dromara.system.domain.bo.SysBusinessBo;
import org.dromara.system.domain.vo.SysBusinessVo;
import org.dromara.system.service.IBusinessCouponService;
import org.dromara.system.service.IBusinessMonthStatisticsService;
import org.dromara.system.service.IPromotionCouponService;
import org.dromara.system.service.ISysBusinessService;
import org.springframework.scheduling.annotation.EnableScheduling;
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
@EnableScheduling
@Slf4j
public class BusinessStatsTask {
public class BusinessStatsExecutor {
@Autowired
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 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"));
}
}

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

@ -16,7 +16,7 @@
<if test="businessId != null">
and business_id = #{businessId}
</if>
and status in ('1', '2', '4', '5', '9')
and is_pay = '1'
<if test="createTime != null and dateFormat != '' ">
and date_format(create_time, #{dateFormat}) = date_format(#{createTime}, #{dateFormat})
</if>
@ -33,7 +33,7 @@
<if test="businessId != null">
and business_id = #{businessId}
</if>
and status in ('9')
and status = 9 and is_pay = '1'
<if test="createTime != null and dateFormat != '' ">
and date_format(create_time, #{dateFormat}) = date_format(#{createTime}, #{dateFormat})
</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 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 id="subAmount">
update sys_business_balance set balance = balance - #{amount} where business_id = #{businessId} and balance >= #{amount}
</update>
<update id="addAmount">
update sys_business_balance set balance = balance + #{amount} where business_id = #{businessId}

Loading…
Cancel
Save