随机单下单后,24小时未接单,自动将订单进行退款
This commit is contained in:
@@ -51,7 +51,7 @@ public interface IPlayBalanceDetailsInfoService extends IService<PlayBalanceDeta
|
||||
* @param userId 用户ID
|
||||
* @param balanceBeforeOperation 操作前余额
|
||||
* @param balanceAfterOperation 操作后余额
|
||||
* @param operationType 操作类型(0:充值;1:消费)
|
||||
* @param operationType 操作类型(0:充值;1:消费,2:服务;3:退款)
|
||||
* @param operationAction 操作动作
|
||||
* @param balanceMoney 操作金额
|
||||
* @param giftAmount 赠送金额
|
||||
|
||||
@@ -108,7 +108,7 @@ public interface IPlayCustomUserInfoService extends IService<PlayCustomUserInfoE
|
||||
* @param userId 用户ID
|
||||
* @param balanceBeforeOperation 操作前余额
|
||||
* @param balanceAfterOperation 操作后余额
|
||||
* @param operationType 操作类型(0:充值;1:消费;2:服务)
|
||||
* @param operationType 操作类型(0:充值;1:消费;2:服务;3:退款)
|
||||
* @param operationAction 操作动作
|
||||
* @param balanceMoney 操作金额
|
||||
* @param giftAmount 赠送金额
|
||||
|
||||
@@ -275,7 +275,7 @@ public class PlayCustomUserInfoServiceImpl extends ServiceImpl<PlayCustomUserInf
|
||||
PlayCustomUserInfoEntity entity = new PlayCustomUserInfoEntity();
|
||||
entity.setId(userId);
|
||||
entity.setAccountBalance(balanceAfterOperation);
|
||||
entity.setAccountState(balanceAfterOperation.compareTo(new BigDecimal(0)) > 0 ? "`" : "0");
|
||||
entity.setAccountState(balanceAfterOperation.compareTo(new BigDecimal(0)) > 0 ? "1" : "0");
|
||||
this.baseMapper.updateById(entity);
|
||||
//记录余额变更记录
|
||||
playBalanceDetailsInfoService.insertBalanceDetailsInfo("1", userId, balanceBeforeOperation, balanceAfterOperation, operationType, operationAction, balanceMoney, giftAmount, orderId);
|
||||
|
||||
@@ -75,6 +75,9 @@ public class PlayOrderInfoServiceImpl extends ServiceImpl<PlayOrderInfoMapper, P
|
||||
@Resource
|
||||
private WxCustomMpService wxCustomMpService;
|
||||
|
||||
@Resource
|
||||
private IPlayCustomUserInfoService customUserInfoService;
|
||||
|
||||
|
||||
@Override
|
||||
public List<PlayOrderInfoEntity> getTotalOrderInfo(String tenantId) {
|
||||
@@ -722,31 +725,34 @@ public class PlayOrderInfoServiceImpl extends ServiceImpl<PlayOrderInfoMapper, P
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateStateTo4(String operatorByType, String operatorBy, String orderId, String refundReason, List<String> images) {
|
||||
PlayOrderInfoEntity entity = this.selectOrderInfoById(orderId);
|
||||
PlayOrderInfoEntity orderInfo = this.selectOrderInfoById(orderId);
|
||||
if ("0".equals(operatorByType)) {
|
||||
if (!entity.getPurchaserBy().equals(operatorBy)) {
|
||||
if (!orderInfo.getPurchaserBy().equals(operatorBy)) {
|
||||
throw new CustomException("只能操作本人订单");
|
||||
}
|
||||
}
|
||||
if ("1".equals(operatorByType)) {
|
||||
if (!entity.getAcceptBy().equals(operatorBy)) {
|
||||
if (!orderInfo.getAcceptBy().equals(operatorBy)) {
|
||||
throw new CustomException("只能操作本人订单");
|
||||
}
|
||||
}
|
||||
// 取消订单(必须订单未接单或者为开始状态)
|
||||
if (!entity.getOrderStatus().equals(OrderConstant.ORDER_STATUS_0) && !entity.getOrderStatus().equals(OrderConstant.ORDER_STATUS_1)) {
|
||||
if (!orderInfo.getOrderStatus().equals(OrderConstant.ORDER_STATUS_0) && !orderInfo.getOrderStatus().equals(OrderConstant.ORDER_STATUS_1)) {
|
||||
throw new CustomException("订单状态异常,无法取消");
|
||||
}
|
||||
// 修改订单状态
|
||||
this.baseMapper.updateById(new PlayOrderInfoEntity(orderId, OrderConstant.ORDER_STATUS_4));
|
||||
// 用户增加余额
|
||||
PlayCustomUserInfoEntity customUserInfo = customUserInfoService.getById(orderInfo.getPurchaserBy());
|
||||
customUserInfoService.updateAccountBalanceById(customUserInfo.getId(), customUserInfo.getAccountBalance(), customUserInfo.getAccountBalance().add(orderInfo.getOrderMoney()), "3", "订单退款", orderInfo.getOrderMoney(), BigDecimal.ZERO, orderId);
|
||||
// 取消订单后,记录退款信息
|
||||
PlayOrderRefundInfoEntity orderRefundInfo = new PlayOrderRefundInfoEntity();
|
||||
orderRefundInfo.setOrderId(orderId);
|
||||
orderRefundInfo.setCustomId(entity.getPurchaserBy());
|
||||
orderRefundInfo.setClerkId(entity.getAcceptBy());
|
||||
orderRefundInfo.setPayMethod(entity.getPayMethod());
|
||||
orderRefundInfo.setCustomId(orderInfo.getPurchaserBy());
|
||||
orderRefundInfo.setClerkId(orderInfo.getAcceptBy());
|
||||
orderRefundInfo.setPayMethod(orderInfo.getPayMethod());
|
||||
orderRefundInfo.setRefundType("0");
|
||||
orderRefundInfo.setRefundAmount(entity.getFinalAmount());
|
||||
orderRefundInfo.setRefundAmount(orderInfo.getFinalAmount());
|
||||
orderRefundInfo.setRefundReason(refundReason);
|
||||
orderRefundInfo.setRefundByType(operatorByType);
|
||||
orderRefundInfo.setRefundById(operatorBy);
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.starry.admin.common.aspect.CustomUserLogin;
|
||||
import com.starry.admin.common.conf.ThreadLocalRequestDetail;
|
||||
import com.starry.admin.common.exception.CustomException;
|
||||
import com.starry.admin.common.exception.ServiceException;
|
||||
import com.starry.admin.common.task.OverdueOrderHandlerTask;
|
||||
import com.starry.admin.modules.clerk.module.entity.PlayClerkUserInfoEntity;
|
||||
import com.starry.admin.modules.clerk.service.IPlayClerkCommodityService;
|
||||
import com.starry.admin.modules.clerk.service.IPlayClerkUserInfoService;
|
||||
@@ -48,6 +49,7 @@ import com.starry.admin.modules.weichat.entity.user.PlayCustomUserReturnDetailVo
|
||||
import com.starry.admin.modules.weichat.service.WxCustomMpService;
|
||||
import com.starry.admin.modules.weichat.service.WxCustomUserService;
|
||||
import com.starry.admin.utils.MoneyUtils;
|
||||
import com.starry.admin.utils.SecurityUtils;
|
||||
import com.starry.common.result.R;
|
||||
import com.starry.common.utils.ConvertUtil;
|
||||
import com.starry.common.utils.IdUtils;
|
||||
@@ -118,6 +120,9 @@ public class WxCustomController {
|
||||
@Resource
|
||||
private WxCustomMpService wxCustomMpService;
|
||||
|
||||
@Resource
|
||||
OverdueOrderHandlerTask overdueOrderHandlerTask;
|
||||
|
||||
|
||||
/**
|
||||
* 根据店员ID查询店员详细信息
|
||||
@@ -347,6 +352,8 @@ public class WxCustomController {
|
||||
// playOrderInfoService.createRandomOrder(orderId, customUserInfo.getId(), commodityInfo.getCommodityPrice(), String.valueOf(vo.getCommodityQuantity()), commodityInfo.getServiceDuration(), commodityInfo.getCommodityName(), money, money, customId, vo.getRemark(), vo.getWeiChatCode());
|
||||
// 顾客减少余额
|
||||
customUserInfoService.updateAccountBalanceById(customUserInfo.getId(), customUserInfo.getAccountBalance(), customUserInfo.getAccountBalance().subtract(money), "1", "下单-随机单", money, BigDecimal.ZERO, orderId);
|
||||
// 记录订单,指定指定未接单后,进行退款处理
|
||||
overdueOrderHandlerTask.enqueue(orderId + "_" + SecurityUtils.getTenantId());
|
||||
// 下单成功后,先根据用户条件进行随机分配
|
||||
return R.ok("下单成功");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user