From cf9f52696767ec828c574fa0b983cf45313eafee Mon Sep 17 00:00:00 2001 From: chen-xin-zhi <3588068430@qq.com> Date: Thu, 20 Mar 2025 21:13:33 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=8A=E4=BC=A0https?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../heritage/constant/MqConstant.java | 6 +- .../constant/OrderStatusConstant.java | 1 - .../order/ClothesRentOrderController.java | 6 + .../controller/wx/WeChatPayController.java | 90 ++++++++- .../listener/ClothesRentPeriodListener.java | 69 +++++++ .../order/ClothesRentOrderService.java | 7 + .../impl/ClothesRentOrderServiceImpl.java | 22 ++- .../heritage/service/wx/WeChatService.java | 26 ++- .../service/wx/impl/WeChatServiceImpl.java | 187 +++++++++++++++++- src/main/resources/application.yml | 3 +- 10 files changed, 399 insertions(+), 18 deletions(-) create mode 100644 src/main/java/com/cultural/heritage/listener/ClothesRentPeriodListener.java diff --git a/src/main/java/com/cultural/heritage/constant/MqConstant.java b/src/main/java/com/cultural/heritage/constant/MqConstant.java index d2b0141..de09c5f 100644 --- a/src/main/java/com/cultural/heritage/constant/MqConstant.java +++ b/src/main/java/com/cultural/heritage/constant/MqConstant.java @@ -28,6 +28,10 @@ public interface MqConstant { String DELAY_CLOTHES_RENT_ORDER_QUEUE = "clothesRentOrder.delay.queue"; - String DELAY_CLOTHES_RENT_ORDER_ROUTING_KEY = "clothesRentOrder.delay.queue"; + String DELAY_CLOTHES_RENT_ORDER_ROUTING_KEY = "clothesRentOrder.key"; + + String DELAY_CLOTHES_RENT_PERIOD_QUEUE = "clothesRentPeriod.delay.queue"; + + String DELAY_CLOTHES_RENT_PERIOD_ROUTING_KEY = "clothesRentPeriod.key"; } diff --git a/src/main/java/com/cultural/heritage/constant/OrderStatusConstant.java b/src/main/java/com/cultural/heritage/constant/OrderStatusConstant.java index eeb9258..ffcdf3d 100644 --- a/src/main/java/com/cultural/heritage/constant/OrderStatusConstant.java +++ b/src/main/java/com/cultural/heritage/constant/OrderStatusConstant.java @@ -20,5 +20,4 @@ public interface OrderStatusConstant { String PAYMENT_REFUNDED = "已退款"; - } diff --git a/src/main/java/com/cultural/heritage/controller/order/ClothesRentOrderController.java b/src/main/java/com/cultural/heritage/controller/order/ClothesRentOrderController.java index d7aa647..06dfadc 100644 --- a/src/main/java/com/cultural/heritage/controller/order/ClothesRentOrderController.java +++ b/src/main/java/com/cultural/heritage/controller/order/ClothesRentOrderController.java @@ -266,6 +266,12 @@ public class ClothesRentOrderController { updateWrapper.set("orderStatus", orderStatus); boolean result = clothesRentOrderService.update(updateWrapper); ThrowUtils.throwIf(!result, ErrorCode.OPERATION_ERROR, "订单状态不存在或订单状态更新失败"); + + // 如果订单状态为待收货,就发送消息队列,开启服装租赁倒计时 + ClothesRentOrder clothesRentOrder = clothesRentOrderService.getById(id); + if (orderStatus.equals(OrderStatusConstant.PENDING_DELIVERY)) { + clothesRentOrderService.sendClothesRentPeriodMessage(id, clothesRentOrder.getRentDays()); + } return ResultUtils.success(true); } diff --git a/src/main/java/com/cultural/heritage/controller/wx/WeChatPayController.java b/src/main/java/com/cultural/heritage/controller/wx/WeChatPayController.java index 66fcd80..8402fba 100644 --- a/src/main/java/com/cultural/heritage/controller/wx/WeChatPayController.java +++ b/src/main/java/com/cultural/heritage/controller/wx/WeChatPayController.java @@ -10,11 +10,9 @@ import com.cultural.heritage.constant.UserConstant; import com.cultural.heritage.exception.BusinessException; import com.cultural.heritage.exception.ThrowUtils; import com.cultural.heritage.model.dto.CommonRequest; -import com.cultural.heritage.model.entity.AdvanceOrder; -import com.cultural.heritage.model.entity.Order; -import com.cultural.heritage.model.entity.OrderItems; -import com.cultural.heritage.model.entity.User; +import com.cultural.heritage.model.entity.*; import com.cultural.heritage.service.book.AdvanceOrderService; +import com.cultural.heritage.service.order.ClothesRentOrderService; import com.cultural.heritage.service.order.OrderItemService; import com.cultural.heritage.service.order.OrderService; import com.cultural.heritage.service.user.UserService; @@ -50,19 +48,28 @@ public class WeChatPayController { @Resource private UserService userService; + @Resource private OrderService ordersService; + @Resource private WeChatService weChatService; + @Resource private OrderItemService orderItemService; + @Resource private AdvanceOrderService advanceOrderService; + @Resource + private ClothesRentOrderService clothesRentOrderService; + + + /** * JSAPI 下单(商品类) @@ -306,13 +313,82 @@ public class WeChatPayController { + /** + * JSAPI 下单(服装租赁类) + */ + @PostMapping("/payment/clothesRent/create") + @Operation(summary = "JSAPI 下单(服装租赁)", description = "参数:订单id, 权限:所有人, 方法名:createClothesRentPayment") + public BaseResponse createClothesRentPayment(@RequestBody CommonRequest commonRequest, HttpServletRequest request) { + User loginUser = userService.getLoginUser(request); + String miniOpenId = loginUser.getMiniOpenId(); + ThrowUtils.throwIf(miniOpenId == null, ErrorCode.NOT_FOUND_ERROR, "不是小程序用户"); + Long orderId = commonRequest.getId(); + ClothesRentOrder clothesRentOrder = clothesRentOrderService.getById(orderId); + ThrowUtils.throwIf(clothesRentOrder == null, ErrorCode.NOT_FOUND_ERROR, "订单不存在"); + ThrowUtils.throwIf(!clothesRentOrder.getOrderStatus().equals(OrderStatusConstant.PENDING_PAYMENT), ErrorCode.OPERATION_ERROR, "订单状态错误"); + if (!loginUser.getId().equals(clothesRentOrder.getUserId())) { + throw new BusinessException(ErrorCode.NO_AUTH_ERROR, "你不是该订单用户!"); + } + PrepayWithRequestPaymentResponse response = weChatService.createClothesRentPayment(String.valueOf(orderId), miniOpenId, clothesRentOrder.getTotalAmount()); + return ResultUtils.success(response); + } + + + + /** + * JSAPI 下单回调(服装租赁类) + */ + @Hidden + @PostMapping("/payment/clothesRent/callback") + @Transactional(rollbackFor = Exception.class) + @Operation(summary = "JSAPI 下单回调(服装租赁)", description = "参数:订单id, 权限:所有人, 方法名:callbackClothesRentPayment") + public synchronized BaseResponse callbackClothesRentPayment(HttpServletRequest request) throws IOException { + // 获取下单信息 + Transaction transaction = weChatService.getTransactionInfo(request); + System.out.println("下单信息:" + transaction); + // 支付回调 + boolean result = weChatService.paymentClothesRentCallback(transaction); + ThrowUtils.throwIf(!result, ErrorCode.SYSTEM_ERROR, "微信支付回调失败"); + return ResultUtils.success(true); + } + + + + /** + * Web端管理员全额退款(服装租赁类) + * @param commonRequest 订单id + */ + @PostMapping("/refund/clothesRent/create") + @Operation(summary = "Web端管理员全额退款(服装租赁类)", description = "参数:订单id, 权限:web端管理员, 方法名:createClothesRentRefund") + @AuthCheck(mustRole = UserConstant.ADMIN_ROLE) + public BaseResponse createClothesRentRefund(@RequestBody CommonRequest commonRequest) { + if (commonRequest == null || commonRequest.getId() <= 0) { + throw new BusinessException(ErrorCode.PARAMS_ERROR); + } + Long orderId = commonRequest.getId(); + ClothesRentOrder clothesRentOrder = clothesRentOrderService.getById(orderId); + ThrowUtils.throwIf(clothesRentOrder == null, ErrorCode.NOT_FOUND_ERROR, "订单不存在"); + Refund refund = weChatService.refundClothesRentPayment(String.valueOf(orderId), clothesRentOrder.getTotalAmount()); + return ResultUtils.success(refund); + } - - - + /** + * 全额退款回调(服装租赁类) + */ + @Hidden + @PostMapping("/refund/clothesRent/callback") + @Operation(summary = "全额退款回调(服装租赁类)", description = "参数:订单id, 权限:web端管理员, 方法名:callbackClothesRentRefund") + public BaseResponse callbackClothesRentRefund(HttpServletRequest request) { + // 获取退款信息 + RefundNotification refundNotification = weChatService.getRefundInfo(request); + // 退款回调 + boolean result = weChatService.refundClothesRentCallback(refundNotification); + ThrowUtils.throwIf(!result, ErrorCode.SYSTEM_ERROR, "退款回调失败"); + return ResultUtils.success(true); + } diff --git a/src/main/java/com/cultural/heritage/listener/ClothesRentPeriodListener.java b/src/main/java/com/cultural/heritage/listener/ClothesRentPeriodListener.java new file mode 100644 index 0000000..0d642d5 --- /dev/null +++ b/src/main/java/com/cultural/heritage/listener/ClothesRentPeriodListener.java @@ -0,0 +1,69 @@ +package com.cultural.heritage.listener; + +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.cultural.heritage.common.ErrorCode; +import com.cultural.heritage.constant.MqConstant; +import com.cultural.heritage.constant.OrderStatusConstant; +import com.cultural.heritage.exception.ThrowUtils; +import com.cultural.heritage.model.entity.ClothesRentOrder; +import com.cultural.heritage.service.order.ClothesRentOrderService; +import com.cultural.heritage.utils.MultiDelayMessage; +import jakarta.annotation.Resource; +import org.springframework.amqp.rabbit.annotation.Exchange; +import org.springframework.amqp.rabbit.annotation.Queue; +import org.springframework.amqp.rabbit.annotation.QueueBinding; +import org.springframework.amqp.rabbit.annotation.RabbitListener; +import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.stereotype.Component; + + +@Component +public class ClothesRentPeriodListener { + + + @Resource + private ClothesRentOrderService clothesRentOrderService; + + + @Resource + private RabbitTemplate rabbitTemplate; + + + + @RabbitListener(bindings = @QueueBinding( + value = @Queue(MqConstant.DELAY_CLOTHES_RENT_PERIOD_QUEUE), + exchange = @Exchange(name = MqConstant.DELAY_EXCHANGE, delayed = "true"), + key = MqConstant.DELAY_CLOTHES_RENT_PERIOD_ROUTING_KEY + )) + public void listenDelayMessage(MultiDelayMessage msg) { + System.out.println("\n\n\n\n\nClothesRentPeriodListener.listenerDelayMessage msg-------------------------------->:" + msg); + + // 1.获取消息中的服装租赁订单id + Long orderId = msg.getData(); + // 2.查询订单,判断状态是否为待收货 + ClothesRentOrder clothesRentOrder = clothesRentOrderService.getById(orderId); + // 订单不存在或者订单状态不为待收货 + if (clothesRentOrder == null || !clothesRentOrder.getOrderStatus().equals(OrderStatusConstant.PENDING_DELIVERY)) { + return ; + } + // 3.订单处于待收货状态,判断是否还有剩余延时时间 + if (msg.hasNextDelay()) { + // 有延迟时间,需要重发延迟消息,先获取延迟时间的int值 + // 发送延时消息 + int delayValue = msg.removeNextDelay().intValue(); + rabbitTemplate.convertAndSend(MqConstant.DELAY_EXCHANGE, + MqConstant.DELAY_CLOTHES_RENT_PERIOD_ROUTING_KEY, msg, message -> { + // 添加延迟消息属性 + message.getMessageProperties().setDelay(delayValue * 1000); + return message; + }); + return ; + } + // 没有剩余延时时间,说明订单交易完成,需修改订单状态 + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + updateWrapper.eq("id", orderId).set("orderStatus", OrderStatusConstant.TRANSACTION_SUCCESSFUL); + boolean update = clothesRentOrderService.update(updateWrapper); + ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR, "订单状态更新失败"); + } + +} diff --git a/src/main/java/com/cultural/heritage/service/order/ClothesRentOrderService.java b/src/main/java/com/cultural/heritage/service/order/ClothesRentOrderService.java index 222386e..715cac8 100644 --- a/src/main/java/com/cultural/heritage/service/order/ClothesRentOrderService.java +++ b/src/main/java/com/cultural/heritage/service/order/ClothesRentOrderService.java @@ -26,4 +26,11 @@ public interface ClothesRentOrderService extends IService { * 向消息队列中发送订单创建的消息 */ void sendClothesRentOrderMessage(Long orderId); + + + + /** + * 向消息队列中发送服装租赁倒计时的消息 + */ + void sendClothesRentPeriodMessage(Long id, Integer days); } diff --git a/src/main/java/com/cultural/heritage/service/order/impl/ClothesRentOrderServiceImpl.java b/src/main/java/com/cultural/heritage/service/order/impl/ClothesRentOrderServiceImpl.java index e697502..2d073ca 100644 --- a/src/main/java/com/cultural/heritage/service/order/impl/ClothesRentOrderServiceImpl.java +++ b/src/main/java/com/cultural/heritage/service/order/impl/ClothesRentOrderServiceImpl.java @@ -6,11 +6,12 @@ import com.cultural.heritage.common.ErrorCode; import com.cultural.heritage.constant.MqConstant; import com.cultural.heritage.exception.ThrowUtils; import com.cultural.heritage.mapper.ClothesRentOrderMapper; -import com.cultural.heritage.model.dto.clothesRentOrder.ClothesRentOrderQueryRequest; import com.cultural.heritage.model.dto.clothesRentOrder.ClothesRentOrderAddRequest; +import com.cultural.heritage.model.dto.clothesRentOrder.ClothesRentOrderQueryRequest; import com.cultural.heritage.model.entity.ClothesRentOrder; import com.cultural.heritage.service.order.ClothesRentOrderService; import com.cultural.heritage.utils.MultiDelayMessage; +import com.cultural.heritage.utils.TimeSplitterUtils; import jakarta.annotation.Resource; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; @@ -78,4 +79,23 @@ public class ClothesRentOrderServiceImpl extends ServiceImpl splitTimeList = TimeSplitterUtils.splitTime(seconds); + // 延迟检查优惠券是否过期 + MultiDelayMessage msg = new MultiDelayMessage<>(id, splitTimeList); + int delayValue = msg.removeNextDelay().intValue(); + rabbitTemplate.convertAndSend(MqConstant.DELAY_EXCHANGE, + MqConstant.DELAY_CLOTHES_RENT_PERIOD_ROUTING_KEY, msg, message -> { + // 添加延迟消息属性 + message.getMessageProperties().setDelay(delayValue * 1000); + return message; + }); + } + + } diff --git a/src/main/java/com/cultural/heritage/service/wx/WeChatService.java b/src/main/java/com/cultural/heritage/service/wx/WeChatService.java index 4bdaa9e..58cec1b 100644 --- a/src/main/java/com/cultural/heritage/service/wx/WeChatService.java +++ b/src/main/java/com/cultural/heritage/service/wx/WeChatService.java @@ -25,6 +25,11 @@ public interface WeChatService { */ PrepayWithRequestPaymentResponse createPhotoProductsPayment(String orderId, String miniOpenId, BigDecimal amount); + /** + * 微信支付(服装租赁类) + */ + PrepayWithRequestPaymentResponse createClothesRentPayment(String valueOf, String miniOpenId, BigDecimal totalAmount); + /** * 获取支付回调信息 */ @@ -40,6 +45,11 @@ public interface WeChatService { */ boolean paymentPhotoProductsCallback(Transaction transaction) throws IOException; + /** + * 支付回调(服装租赁类) + */ + boolean paymentClothesRentCallback(Transaction transaction); + /** * 全额退款申请(商品类) */ @@ -50,6 +60,11 @@ public interface WeChatService { */ Refund refundPhotoProductsPayment(String orderId, BigDecimal amount); + /** + * 全额退款申请(服装租赁类) + */ + Refund refundClothesRentPayment(String orderId, BigDecimal totalAmount); + /** * 部分退款申请 */ @@ -65,16 +80,23 @@ public interface WeChatService { */ RefundNotification getRefundInfo(HttpServletRequest request); + + /** * 全额退款回调(商品类) */ boolean refundCallback(RefundNotification refundNotification); /** - * (写真预约类) + * 全额退款回调(写真预约类) */ boolean refundPhotoProductsCallback(RefundNotification refundNotification); + /** + * 全额退款回调(服装租赁类) + */ + boolean refundClothesRentCallback(RefundNotification refundNotification); + /** * 部分退款回调 */ @@ -87,6 +109,8 @@ public interface WeChatService { boolean refundRestCallback(RefundNotification refundNotification); + + // /** // * 发送订阅模板消息 // */ diff --git a/src/main/java/com/cultural/heritage/service/wx/impl/WeChatServiceImpl.java b/src/main/java/com/cultural/heritage/service/wx/impl/WeChatServiceImpl.java index 6e83961..c638172 100644 --- a/src/main/java/com/cultural/heritage/service/wx/impl/WeChatServiceImpl.java +++ b/src/main/java/com/cultural/heritage/service/wx/impl/WeChatServiceImpl.java @@ -15,10 +15,7 @@ import com.cultural.heritage.model.dto.snapshot.GoodSnapshot; import com.cultural.heritage.model.entity.*; import com.cultural.heritage.service.book.AdvanceOrderService; import com.cultural.heritage.service.good.GoodService; -import com.cultural.heritage.service.order.OrderItemService; -import com.cultural.heritage.service.order.OrderService; -import com.cultural.heritage.service.order.PendingServiceOrderService; -import com.cultural.heritage.service.order.RefundRecordService; +import com.cultural.heritage.service.order.*; import com.cultural.heritage.service.user.UserService; import com.cultural.heritage.service.wx.WeChatService; import com.cultural.heritage.utils.RefundUtils; @@ -58,30 +55,43 @@ public class WeChatServiceImpl implements WeChatService { @Resource private WxPayConfig wxPayConfig; + @Resource private WxOpenConfig wxOpenConfig; + @Resource private OrderService orderService; + @Resource private GoodService goodService; + @Resource private OrderItemService orderItemService; + @Resource private RefundRecordService refundRecordService; + @Resource private PendingServiceOrderService pendingServiceOrderService; + @Resource private AdvanceOrderService advanceOrderService; + @Resource private UserService userService; + + @Resource + private ClothesRentOrderService clothesRentOrderService; + + /** * 请求参数 */ @@ -157,6 +167,42 @@ public class WeChatServiceImpl implements WeChatService { } + + /** + * 微信支付(服装租赁类) + */ + @Override + public PrepayWithRequestPaymentResponse createClothesRentPayment(String orderId, String miniOpenId, BigDecimal amount) { + // request.setXxx(val)设置所需参数,具体参数可见Request定义 + PrepayRequest request = new PrepayRequest(); + // 金额 + Amount WxAmount = new Amount(); + WxAmount.setTotal(amount.movePointRight(2).intValue()); + WxAmount.setCurrency("CNY"); + request.setAmount(WxAmount); + // 公众号id + request.setAppid(wxPayConfig.getAppId()); + // 商户号 + request.setMchid(wxPayConfig.getMerchantId()); + // 支付者信息 + Payer payer = new Payer(); + payer.setOpenid(miniOpenId); + request.setPayer(payer); + // 获取订单号 + ClothesRentOrder clothesRentOrder = clothesRentOrderService.getById(orderId); + String orderNumber = clothesRentOrder.getOrderNumber(); + // 描述 + request.setDescription("订单号:" + orderNumber); + // 微信回调地址 + request.setNotifyUrl(wxPayConfig.getNotifyUrl() + "/api/wechat/payment/clothesRent/callback"); + // 商户订单号 + request.setOutTradeNo(orderNumber); + //返回数据,前端调起支付 + return wxPayConfig.getJsapiServiceExtension().prepayWithRequestPayment(request); + } + + + /** * 支付回调(商品类) */ @@ -207,6 +253,30 @@ public class WeChatServiceImpl implements WeChatService { + + /** + * 支付回调(服装租赁类) + */ + @Override + public boolean paymentClothesRentCallback(Transaction transaction) { + System.out.println("---------------------------微信支付回调(开始)-------------------------------"); + // 获取订单信息 + String orderNumber = transaction.getOutTradeNo(); + ClothesRentOrder clothesRentOrder = getClothesRentOrderInfoByOrderNumber(orderNumber); + + // 修改订单状态 + modifyClothesRentStatus(clothesRentOrder, OrderStatusConstant.PENDING_SHIPMENT); + + // 增加用户积分 + dealUserPointsByClothesRent(clothesRentOrder, true); + System.out.println("---------------------------微信支付回调(结束)-------------------------------"); + return true; + } + + + + + /** * 全额退款(商品类) */ @@ -278,6 +348,40 @@ public class WeChatServiceImpl implements WeChatService { + /** + * 全额退款(服装租赁类) + */ + @Override + public Refund refundClothesRentPayment(String orderId, BigDecimal amount) { + // 获取订单号 + ClothesRentOrder clothesRentOrder = clothesRentOrderService.getById(orderId); + ThrowUtils.throwIf(clothesRentOrder == null, ErrorCode.OPERATION_ERROR, "该订单不存在"); + String orderNumber = clothesRentOrder.getOrderNumber(); + // 退款请求 + CreateRequest createRequest = new CreateRequest(); + // 商户订单号 + createRequest.setOutTradeNo(orderNumber); + // 商户退款单号 + String outRefundNo = RefundUtils.generateRefundNo(); + createRequest.setOutRefundNo(outRefundNo); + // 退款结果回调 + createRequest.setNotifyUrl(wxPayConfig.getNotifyUrl() + "/api/wechat/refund/clothesRent/callback"); + // 退款金额 + AmountReq amountReq = new AmountReq(); + long refundAmount = amount.movePointRight(2).intValue(); + + amountReq.setRefund(refundAmount); + amountReq.setTotal(refundAmount); + amountReq.setCurrency("CNY"); + createRequest.setAmount(amountReq); + // 申请退款 + System.out.println("退款请求:" + createRequest); + Refund refund = wxPayConfig.getRefundService().create(createRequest); + System.out.println("退款申请结果:" + refund); + return refund; + } + + /** * 全额退款回调(商品类) */ @@ -335,6 +439,28 @@ public class WeChatServiceImpl implements WeChatService { + /** + * 全额退款回调(服装租赁类) + */ + @Override + public boolean refundClothesRentCallback(RefundNotification refundNotification) { + System.out.println("---------------------------微信退款回调(开始)-------------------------------"); + // 获取订单信息 + String orderNumber = refundNotification.getOutTradeNo(); + ClothesRentOrder clothesRentOrder = getClothesRentOrderInfoByOrderNumber(orderNumber); + + // 修改订单状态 + modifyClothesRentStatus(clothesRentOrder, OrderStatusConstant.PAYMENT_REFUNDED); + + // 生成退款记录 + createRefundRecord(refundNotification); + // 扣除用户积分 + dealUserPointsByClothesRent(clothesRentOrder, false); + System.out.println("---------------------------微信退款回调(结束)-------------------------------"); + return true; + } + + /** * 部分退款 @@ -514,6 +640,24 @@ public class WeChatServiceImpl implements WeChatService { + + + + + + + + + + + + + + + + + + @@ -527,7 +671,6 @@ public class WeChatServiceImpl implements WeChatService { BigDecimal conditionAmount = couponSnapshot.getConditionAmount(); totalAmount = totalAmount.add(conditionAmount); } -// totalAmount = totalAmount.multiply(new BigDecimal("100")); userService.addOrSubUserPoints(order.getUserId(), isAdd, totalAmount.intValue()); } @@ -537,12 +680,20 @@ public class WeChatServiceImpl implements WeChatService { */ private void dealUserPointsByPhoto(AdvanceOrder advanceOrder, boolean isAdd) { BigDecimal totalAmount = advanceOrder.getTotalAmount(); -// totalAmount = totalAmount.multiply(new BigDecimal("100")); userService.addOrSubUserPoints(advanceOrder.getUserId(), isAdd, totalAmount.intValue()); } + /** + * (写真预约类)更新用户 + */ + private void dealUserPointsByClothesRent(ClothesRentOrder clothesRentOrder, boolean isAdd) { + BigDecimal totalAmount = clothesRentOrder.getTotalAmount(); + userService.addOrSubUserPoints(clothesRentOrder.getUserId(), isAdd, totalAmount.intValue()); + } + + /** @@ -672,6 +823,18 @@ public class WeChatServiceImpl implements WeChatService { } + /** + * 根据订单号获取服装租赁类信息 + */ + private ClothesRentOrder getClothesRentOrderInfoByOrderNumber(String orderNumber) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("orderNumber", orderNumber); + ClothesRentOrder clothesRentOrder = clothesRentOrderService.getOne(queryWrapper); + ThrowUtils.throwIf(clothesRentOrder == null, ErrorCode.OPERATION_ERROR, "订单不存在"); + return clothesRentOrder; + } + + /** @@ -729,6 +892,18 @@ public class WeChatServiceImpl implements WeChatService { + /** + * 修改服装租赁订单状态 + */ + private void modifyClothesRentStatus(ClothesRentOrder clothesRentOrder, String orderStatus) { + clothesRentOrder.setOrderStatus(orderStatus); + clothesRentOrder.setUpdateTime(DateUtil.date()); + boolean update = clothesRentOrderService.updateById(clothesRentOrder); + ThrowUtils.throwIf(!update, ErrorCode.OPERATION_ERROR, "订单状态修改失败"); + } + + + /** * 恢复商品库存 */ diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index ab1d76b..4acdb56 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -93,7 +93,8 @@ mybatis-plus: mapper-locations: classpath:mapper/*.xml configuration: map-underscore-to-camel-case: false - log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl + # log-impl: org.apache.ibatis.logging.stdout.StdOutImpl global-config: db-config: logic-delete-field: isDelete #全局逻辑删除的实体字段名