Преглед изворни кода

fix:技师拒绝接单,如果使用了优惠卷,记录余额退款,恢复优惠卷

wrj пре 3 недеља
родитељ
комит
af696507d2

+ 7 - 3
nightFragrance-admin/src/main/java/com/ylx/web/controller/massage/TConsumptionLogController.java

@@ -3,7 +3,9 @@ package com.ylx.web.controller.massage;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ylx.common.annotation.Log;
 import com.ylx.common.core.controller.BaseController;
+import com.ylx.common.enums.BusinessType;
 import com.ylx.massage.domain.TConsumptionLog;
 import com.ylx.massage.service.TConsumptionLogService;
 import io.swagger.annotations.Api;
@@ -37,12 +39,14 @@ public class TConsumptionLogController extends BaseController {
      * @param tConsumptionLog 查询实体
      * @return 所有数据
      */
-    @GetMapping
+    @GetMapping("selectAll")
     @ApiOperation("分页查询数据")
-    public R selectAll(Page<TConsumptionLog> page, TConsumptionLog tConsumptionLog) {
+    @Log(title = "分页查询数据", businessType = BusinessType.OTHER)
+    public R<Page<TConsumptionLog>> selectAll(Page<TConsumptionLog> page, TConsumptionLog tConsumptionLog) {
         LambdaQueryWrapper<TConsumptionLog> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.eq(TConsumptionLog::getOpenId, tConsumptionLog.getOpenId())
-                .eq(tConsumptionLog.getBillType() != null,TConsumptionLog::getBillType, tConsumptionLog.getBillType());
+                .eq(tConsumptionLog.getBillType() != null,TConsumptionLog::getBillType, tConsumptionLog.getBillType())
+                .orderByDesc(TConsumptionLog::getCreateTime);
         return R.ok(this.tConsumptionLogService.page(page, queryWrapper));
     }
 

+ 8 - 1
nightFragrance-massage/src/main/java/com/ylx/massage/service/impl/TOrderServiceImpl.java

@@ -519,11 +519,12 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
             paramUser.setdBalance(user.getdBalance().add(orderNew.getTotalPrice()));
             // 余额记录
             TConsumptionLog tConsumptionLog = new TConsumptionLog();
-            tConsumptionLog.setAmount(orderNew.getTotalPrice().negate());
+            tConsumptionLog.setAmount(orderNew.getTotalPrice());
             tConsumptionLog.setBillNo(orderNew.getOrderNo());
             tConsumptionLog.setOpenId(orderNew.getcOpenId());
             tConsumptionLog.setBillType(BillTypeEnum.REFUSE_ACCEPT_REFUND.getCode());
             tConsumptionLog.setNote("拒绝接单退款到余额");
+            consumptionLogService.save(tConsumptionLog);
         } else {
             // 微信支付
             // 生成退款单退款
@@ -538,6 +539,12 @@ public class TOrderServiceImpl extends ServiceImpl<TOrderMapper, TOrder> impleme
             // 微信退款原路返回
             rechargeService.refund(refundVoucher.getRefundNo(), null, orderNew.getOrderNo(), orderNew.getTotalPrice());
         }
+        //退优惠卷
+        if (StringUtils.isNotBlank(orderNew.getCouponReceiveId())) {
+            CouponReceive couponReceive = couponReceiveService.getById(orderNew.getCouponReceiveId());
+            couponReceive.setUseState(MassageConstants.INTEGER_ZERO);
+            couponReceiveService.updateById(couponReceive);
+        }
         log.info("余额支付退款user:{}", user);
 
         // 消费金额对应减少