浏览代码

同步修改代金券状态, 修改优惠券详情接口

ssk 3 月之前
父节点
当前提交
789975ff7d

+ 5 - 2
alien-store/src/main/java/shop/alien/store/controller/LifeCouponController.java

@@ -1,5 +1,6 @@
 package shop.alien.store.controller;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import io.swagger.annotations.*;
 import lombok.RequiredArgsConstructor;
@@ -30,7 +31,7 @@ public class LifeCouponController {
     @PostMapping("/addOrUpdateCoupon")
     public R<LifeCoupon> addOrUpdateCoupon(@RequestBody LifeCoupon lifeCoupon) {
         log.info("LifeCouponController.addOrUpdateCoupon?lifeCoupon={}", lifeCoupon.toString());
-        return  R.data(lifeCouponService.addOrUpdateCoupon(lifeCoupon));
+        return R.data(lifeCouponService.addOrUpdateCoupon(lifeCoupon));
     }
 
     /**
@@ -72,7 +73,9 @@ public class LifeCouponController {
     @GetMapping("/getCouponDetail")
     private R<LifeCoupon> getCouponDetail(@RequestParam("id") String id) {
         log.info("LifeCouponController.getCouponDetail?id={}", id);
-        return R.data(lifeCouponService.getById(id));
+        LambdaQueryWrapper<LifeCoupon> objectLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        objectLambdaQueryWrapper.eq(LifeCoupon::getId, id);
+        return R.data(lifeCouponService.getOne(objectLambdaQueryWrapper));
     }
 
     @ApiOperation("核销订单")

+ 9 - 11
alien-store/src/main/java/shop/alien/store/service/impl/PlatformStoreCouponServiceImpl.java

@@ -70,9 +70,9 @@ public class PlatformStoreCouponServiceImpl implements PlatformStoreCouponServic
         wrapper.orderByDesc("coupon.created_time");
         IPage<LifeCouponVo> lifeCouponVo = platformStoreCouponMapper.getCouponList(new Page<>(page, size), wrapper);
         lifeCouponVo.getRecords().forEach(item -> {
-            if (item.getStatus() == -1) {
+            if (item.getStatus() == 1) {
                 item.setStatusName("待审核");
-            } else if (item.getStatus() == -2) {
+            } else if (item.getStatus() == 3) {
                 item.setStatusName("已拒绝");
             } else {
                 item.setStatusName("已通过");
@@ -145,8 +145,6 @@ public class PlatformStoreCouponServiceImpl implements PlatformStoreCouponServic
     public IPage<LifeCouponVo> getCouponStatusList(Integer page, Integer size, String status, String expiredState) {
         IPage<LifeCouponVo> iPage = new Page<>(page, size);
         QueryWrapper<LifeCouponVo> wrapper = new QueryWrapper<>();
-        // 定义允许的状态值
-        List<String> allowedStatus = Arrays.asList("1", "2", "3");
         if ("-3".equals(status)) { // 已售罄(逻辑状态,状态为进行中但是余量为0的)
             wrapper.eq("coupon.status", "1");
             wrapper.eq("coupon.stock_qty", 0);
@@ -227,14 +225,14 @@ public class PlatformStoreCouponServiceImpl implements PlatformStoreCouponServic
 
     @Override
     public int approvalCoupon(Integer id, Integer status, String comment, String type) {
-        if (type.equals("0")) {
+        if (type.equals("1")) {
             LifeCoupon coupon = platformStoreCouponMapper.selectById(id);
             if (null == coupon) return 0;
 
             // 如果通过,且券有效时间在当前时间之前,则修改状态为进行中
             Date now = new Date();
-            if (status == 0 && coupon.getStartDate().before(now) && coupon.getEndDate().after(now)) {
-                status = 1;
+            if (status == 2 && coupon.getStartDate().before(now) && coupon.getEndDate().after(now)) {
+                status = 5;
             }
 
             coupon.setStatus(status);
@@ -291,13 +289,13 @@ public class PlatformStoreCouponServiceImpl implements PlatformStoreCouponServic
 
         List<LifeCouponVo> lifeCouponVo = platformStoreCouponMapper.getCouponList(wrapper);
         lifeCouponVo.forEach(item -> {
-            if (item.getStatus() == 1 && item.getStockQty() > 0) {
+            if (item.getStatus() == 5 && item.getStockQty() > 0) {
                 item.setCouponState("进行中");
-            } else if (item.getStatus() == 1 && item.getStockQty() == 0) {
+            } else if (item.getStatus() == 5 && item.getStockQty() == 0) {
                 item.setCouponState("已售罄");
-            } else if (item.getStatus() == 2) {
+            } else if (item.getStatus() == 6) {
                 item.setCouponState("已暂停");
-            } else if (item.getStatus() == 3) {
+            } else if (item.getStatus() == 7) {
                 item.setCouponState("已结束");
             }
             item.setCouponName(item.getName());