Ver código fonte

优惠券业务变更

ssk 4 meses atrás
pai
commit
4ac6c3e30f

+ 16 - 0
alien-entity/src/main/java/shop/alien/entity/store/LifeCoupon.java

@@ -20,6 +20,22 @@ public class LifeCoupon {
     @TableId(value = "id", type = IdType.AUTO)
     private String id;
 
+    @ApiModelProperty(value = "数据类型: 0:正式数据, 1:草稿数据")
+    @TableField("data_type")
+    private Integer dataType;
+
+    @ApiModelProperty(value = "购买须知-使用开始时间")
+    @TableField("buy_use_start_time")
+    private String buyUseStartTime;
+
+    @ApiModelProperty(value = "购买须知-使用结束时间")
+    @TableField("buy_use_end_time")
+    private String buyUseEndTime;
+
+    @ApiModelProperty(value = "可用节假日")
+    @TableField("use_festival")
+    private String useFestival;
+
     @ApiModelProperty(value = "券id")
     @TableField("coupon_code")
     private String couponCode;

+ 27 - 31
alien-store/src/main/java/shop/alien/store/controller/LifeCouponController.java

@@ -36,21 +36,29 @@ public class LifeCouponController {
         return R.fail("失败");
     }
 
+    /**
+     * 修改库存数量
+     *
+     * @param id        主键
+     * @param singleQty 库存数量
+     * @return boolean
+     */
+    @ApiOperation("修改库存数量")
+    @GetMapping("/updateCouponSingleQty")
+    public R<Boolean> updateCouponSingleQty(@RequestParam("id") Integer id, @RequestParam("singleQty") Integer singleQty) {
+        log.info("LifeCouponController.updateCouponSingleQty?id={}&singleQty={}", id, singleQty);
+        if (lifeCouponService.updateCouponSingleQty(id, singleQty)) {
+            return R.success("成功");
+        }
+        return R.fail("失败");
+    }
+
     @ApiOperation("代金劵列表")
-    @ApiImplicitParams({@ApiImplicitParam(name = "page", value = "页数", dataType = "Integer", paramType = "query", required = true),
-            @ApiImplicitParam(name = "size", value = "页容", dataType = "Integer", paramType = "query", required = true),
-            @ApiImplicitParam(name = "storeId", value = "门店id", dataType = "Integer", paramType = "query", required = true),
-            @ApiImplicitParam(name = "status", value = "状态", dataType = "Integer", paramType = "query", required = true),
-            @ApiImplicitParam(name = "name", value = "名称", dataType = "Integer", paramType = "query", required = false)
-    })
+    @ApiImplicitParams({@ApiImplicitParam(name = "page", value = "页数", dataType = "Integer", paramType = "query", required = true), @ApiImplicitParam(name = "size", value = "页容", dataType = "Integer", paramType = "query", required = true), @ApiImplicitParam(name = "storeId", value = "门店id", dataType = "Integer", paramType = "query", required = true), @ApiImplicitParam(name = "status", value = "状态", dataType = "Integer", paramType = "query", required = true), @ApiImplicitParam(name = "name", value = "名称", dataType = "Integer", paramType = "query"), @ApiImplicitParam(name = "dataType", value = "数据类型: 0:正式数据, 1:草稿数据", dataType = "Integer", paramType = "query", defaultValue = "0")})
     @GetMapping("/getCouponList")
-    private R<IPage<LifeCoupon>> getCouponList(@RequestParam(value = "page", defaultValue = "1") int page,
-                                               @RequestParam(value = "size", defaultValue = "10") int size,
-                                               @RequestParam("storeId") String storeId,
-                                               @RequestParam("status") String status,
-                                               @RequestParam(value = "name",required = false) String name) {
-        log.info("LifeCouponController.getCouponList?page={},size={},storeId={},status={},name={}", page, size, storeId, status, name);
-        return R.data(lifeCouponService.getCouponList(page, size, storeId, status, name));
+    private R<IPage<LifeCoupon>> getCouponList(@RequestParam(value = "page", defaultValue = "1") int page, @RequestParam(value = "size", defaultValue = "10") int size, @RequestParam("storeId") String storeId, @RequestParam("status") String status, @RequestParam(value = "name", required = false) String name, @RequestParam(value = "dataType", defaultValue = "0") Integer dataType) {
+        log.info("LifeCouponController.getCouponList?page={},size={},storeId={},status={},name={},dataType={}", page, size, storeId, status, name, dataType);
+        return R.data(lifeCouponService.getCouponList(page, size, storeId, status, name, dataType));
     }
 
     @ApiOperation("暂停恢复优惠券")
@@ -71,8 +79,7 @@ public class LifeCouponController {
     }
 
     @ApiOperation("核销订单")
-    @ApiImplicitParams({@ApiImplicitParam(name = "storeId", value = "门店id", dataType = "Integer", paramType = "query", required = true),
-            @ApiImplicitParam(name = "quanCode", value = "券码", dataType = "Integer", paramType = "query", required = true)})
+    @ApiImplicitParams({@ApiImplicitParam(name = "storeId", value = "门店id", dataType = "Integer", paramType = "query", required = true), @ApiImplicitParam(name = "quanCode", value = "券码", dataType = "Integer", paramType = "query", required = true)})
     @GetMapping("/verify")
     public R<Map<String, String>> verify(@RequestParam("storeId") String storeId, @RequestParam("quanCode") String quanCode) {
         log.info("LifeCouponController.verify?storeId={},quanCode={}", storeId, quanCode);
@@ -82,9 +89,7 @@ public class LifeCouponController {
     @ApiOperation("获取优惠券状态")
     @ApiOperationSupport(order = 1)
     @GetMapping("/getCouponStatus")
-    @ApiImplicitParams({
-            @ApiImplicitParam(name = "couponId", value = "优惠券id", dataType = "String", paramType = "query", required = true),
-    })
+    @ApiImplicitParams({@ApiImplicitParam(name = "couponId", value = "优惠券id", dataType = "String", paramType = "query", required = true),})
     public R<LifeCouponStatusVo> getCouponStatus(@RequestParam(value = "couponId") String couponId) {
         log.info("LifeDiscountCouponController.getCouponStatus?couponId={}", couponId);
         try {
@@ -97,20 +102,11 @@ public class LifeCouponController {
     }
 
     @ApiOperation("节假日列表")
-    @ApiImplicitParams({@ApiImplicitParam(name = "page", value = "页数", dataType = "Integer", paramType = "query", required = true),
-            @ApiImplicitParam(name = "size", value = "页容", dataType = "Integer", paramType = "query", required = true),
-            @ApiImplicitParam(name = "year", value = "年份", dataType = "String", paramType = "query", required = false),
-            @ApiImplicitParam(name = "openFlag", value = "是否启用(0:未启用,1:已启用)", dataType = "String", paramType = "query", required = false),
-            @ApiImplicitParam(name = "holidayName", value = "节假日名称", dataType = "String", paramType = "query", required = false)
-    })
+    @ApiImplicitParams({@ApiImplicitParam(name = "page", value = "页数", dataType = "Integer", paramType = "query", required = true), @ApiImplicitParam(name = "size", value = "页容", dataType = "Integer", paramType = "query", required = true), @ApiImplicitParam(name = "year", value = "年份", dataType = "String", paramType = "query", required = false), @ApiImplicitParam(name = "openFlag", value = "是否启用(0:未启用,1:已启用)", dataType = "String", paramType = "query", required = false), @ApiImplicitParam(name = "holidayName", value = "节假日名称", dataType = "String", paramType = "query", required = false)})
     @GetMapping("/getHolidayList")
-    private R<IPage<EssentialHolidayComparison>> getHolidayList(@RequestParam(value = "page", defaultValue = "1") int page,
-                                                                @RequestParam(value = "size", defaultValue = "10") int size,
-                                                                @RequestParam("year") String year,
-                                                                @RequestParam("openFlag") String openFlag,
-                                                                @RequestParam("holidayName") String holidayName) {
-        log.info("LifeCouponController.getHolidayList?page={},size={},year={},openFlag={},holidayName={}", page, size, year,openFlag, holidayName);
-        return R.data(lifeCouponService.getHolidayList(page, size, year,openFlag, holidayName));
+    private R<IPage<EssentialHolidayComparison>> getHolidayList(@RequestParam(value = "page", defaultValue = "1") int page, @RequestParam(value = "size", defaultValue = "10") int size, @RequestParam("year") String year, @RequestParam("openFlag") String openFlag, @RequestParam("holidayName") String holidayName) {
+        log.info("LifeCouponController.getHolidayList?page={},size={},year={},openFlag={},holidayName={}", page, size, year, openFlag, holidayName);
+        return R.data(lifeCouponService.getHolidayList(page, size, year, openFlag, holidayName));
     }
 
     @ApiOperation("保存节假日")

+ 13 - 3
alien-store/src/main/java/shop/alien/store/service/LifeCouponService.java

@@ -2,6 +2,7 @@ package shop.alien.store.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
+import org.springframework.web.bind.annotation.RequestParam;
 import shop.alien.entity.store.EssentialHolidayComparison;
 import shop.alien.entity.store.LifeCoupon;
 import shop.alien.entity.store.vo.LifeCouponStatusVo;
@@ -15,18 +16,27 @@ public interface LifeCouponService extends IService<LifeCoupon> {
 
     boolean addOrUpdateCoupon(LifeCoupon lifeCoupon);
 
-    IPage<LifeCoupon> getCouponList(int page, int size, String storeId, String status, String name);
+    /**
+     * 修改库存数量
+     *
+     * @param id        主键
+     * @param singleQty 库存数量
+     * @return boolean
+     */
+    boolean updateCouponSingleQty(Integer id, Integer singleQty);
+
+    IPage<LifeCoupon> getCouponList(int page, int size, String storeId, String status, String name, Integer dataType);
 
     int updateCoupon(String id, Integer status);
 
-    Map<String,String> couponVerify(String storeId, String quanCode);
+    Map<String, String> couponVerify(String storeId, String quanCode);
 
     /**
      * 获取代金券状态
      */
     public LifeCouponStatusVo getCouponStatus(String couponId);
 
-    IPage<EssentialHolidayComparison> getHolidayList(int page, int size, String year,String openFlag, String holidayName);
+    IPage<EssentialHolidayComparison> getHolidayList(int page, int size, String year, String openFlag, String holidayName);
 
     boolean saveHoliday(EssentialHolidayComparison essentialHolidayComparison);
 

+ 23 - 8
alien-store/src/main/java/shop/alien/store/service/impl/LifeCouponServiceImpl.java

@@ -7,7 +7,6 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.RequiredArgsConstructor;
-import org.apache.http.client.utils.DateUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 import org.springframework.util.StringUtils;
@@ -94,13 +93,29 @@ public class LifeCouponServiceImpl extends ServiceImpl<LifeCouponMapper, LifeCou
         }
     }
 
+    /**
+     * 修改库存数量
+     *
+     * @param id        主键
+     * @param singleQty 库存数量
+     * @return boolean
+     */
     @Override
-    public IPage<LifeCoupon> getCouponList(int page, int size, String storeId, String status, String name) {
+    public boolean updateCouponSingleQty(Integer id, Integer singleQty) {
+        LifeCoupon lifeCoupon = new LifeCoupon();
+        lifeCoupon.setId(String.valueOf(id));
+        lifeCoupon.setSingleQty(singleQty);
+        return this.updateById(lifeCoupon);
+    }
+
+    @Override
+    public IPage<LifeCoupon> getCouponList(int page, int size, String storeId, String status, String name, Integer dataType) {
         LambdaUpdateWrapper<LifeCoupon> wrapper = new LambdaUpdateWrapper<>();
         wrapper.eq(storeId != null && !storeId.isEmpty(), LifeCoupon::getStoreId, storeId);
         wrapper.eq(status != null && !status.isEmpty(), LifeCoupon::getStatus, status);
         wrapper.like(name != null && !name.isEmpty(), LifeCoupon::getName, name);
         wrapper.eq(LifeCoupon::getType, 1);
+        wrapper.eq(LifeCoupon::getDataType, dataType);
         wrapper.orderByDesc(LifeCoupon::getCreatedTime);
         IPage<LifeCoupon> lifeCouponIPage = new Page<>(page, size);
         return lifeCouponMapper.selectPage(lifeCouponIPage, wrapper);
@@ -224,18 +239,18 @@ public class LifeCouponServiceImpl extends ServiceImpl<LifeCouponMapper, LifeCou
     }
 
     @Override
-    public IPage<EssentialHolidayComparison> getHolidayList(int page, int size, String year,String openFlag,String holidayName) {
+    public IPage<EssentialHolidayComparison> getHolidayList(int page, int size, String year, String openFlag, String holidayName) {
         if (StringUtils.isEmpty(year)) {
             LambdaQueryWrapper<EssentialHolidayComparison> essentialHolidayComparisonLambdaQueryWrapper = new LambdaQueryWrapper<>();
             essentialHolidayComparisonLambdaQueryWrapper.eq(EssentialHolidayComparison::getDelFlag, 0).groupBy(EssentialHolidayComparison::getParticularYear).orderByDesc(EssentialHolidayComparison::getParticularYear);
             IPage<EssentialHolidayComparison> essentialHolidayComparisonIPage = new Page<>(page, size);
             return essentialHolidayComparisonMapper.selectPage(essentialHolidayComparisonIPage, essentialHolidayComparisonLambdaQueryWrapper);
-        }else {
+        } else {
             LambdaQueryWrapper<EssentialHolidayComparison> essentialHolidayComparisonLambdaQueryWrapper = new LambdaQueryWrapper<>();
             essentialHolidayComparisonLambdaQueryWrapper.eq(EssentialHolidayComparison::getDelFlag, 0)
-                    .eq(com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotEmpty(year),EssentialHolidayComparison::getParticularYear,year)
-                    .eq(com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotEmpty(openFlag),EssentialHolidayComparison::getOpenFlag,openFlag)
-                    .like(com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotEmpty(holidayName),EssentialHolidayComparison::getFestivalName,holidayName)
+                    .eq(com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotEmpty(year), EssentialHolidayComparison::getParticularYear, year)
+                    .eq(com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotEmpty(openFlag), EssentialHolidayComparison::getOpenFlag, openFlag)
+                    .like(com.baomidou.mybatisplus.core.toolkit.StringUtils.isNotEmpty(holidayName), EssentialHolidayComparison::getFestivalName, holidayName)
                     .orderByAsc(EssentialHolidayComparison::getStartTime);
             IPage<EssentialHolidayComparison> essentialHolidayComparisonIPage = new Page<>(page, size);
             return essentialHolidayComparisonMapper.selectPage(essentialHolidayComparisonIPage, essentialHolidayComparisonLambdaQueryWrapper);
@@ -250,7 +265,7 @@ public class LifeCouponServiceImpl extends ServiceImpl<LifeCouponMapper, LifeCou
             }
             essentialHolidayComparisonMapper.updateById(essentialHolidayComparison);
             return true;
-        }else {
+        } else {
             if (ObjectUtils.isNotEmpty(essentialHolidayComparison.getStartTime())) {
                 essentialHolidayComparison.setFestivalDate(essentialHolidayComparison.getStartTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDate());
             }

+ 2 - 8
alien-store/src/main/java/shop/alien/store/service/impl/PlatformStoreCouponServiceImpl.java

@@ -10,11 +10,6 @@ import lombok.RequiredArgsConstructor;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
-import shop.alien.entity.store.LifeCoupon;
-import shop.alien.entity.store.LifeGroupBuyMain;
-import shop.alien.entity.store.StoreImg;
-import shop.alien.entity.store.StoreInfo;
-import shop.alien.entity.store.excelVo.LifeUserViolationExcelVO;
 import shop.alien.entity.store.*;
 import shop.alien.entity.store.excelVo.StoreCouponStatusVo;
 import shop.alien.entity.store.excelVo.util.ExcelGenerator;
@@ -66,6 +61,7 @@ public class PlatformStoreCouponServiceImpl implements PlatformStoreCouponServic
         wrapper.eq(StringUtils.isNotEmpty(status), "coupon.status", status);
         wrapper.eq(StringUtils.isNotEmpty(type), "coupon.type", type);
         wrapper.eq("coupon.delete_flag", 0);
+        wrapper.eq("coupon.data_type", 0);
         wrapper.eq("store.delete_flag", 0);
         wrapper.eq("user.delete_flag", 0);
         wrapper.like(StringUtils.isNotEmpty(createdTime), "coupon.created_time", createdTime);
@@ -81,7 +77,7 @@ public class PlatformStoreCouponServiceImpl implements PlatformStoreCouponServic
             } else {
                 item.setStatusName("已通过");
             }
-// expiredState 赋值逻辑(修正版)
+            // expiredState 赋值逻辑(修正版)
             LocalDateTime now = LocalDateTime.now(); // 获取当前时间
             Date endDate = item.getEndDate();
             if (endDate != null) {
@@ -507,8 +503,6 @@ public class PlatformStoreCouponServiceImpl implements PlatformStoreCouponServic
         LocalDateTime nowDate = LocalDateTime.now(); // 获取当前时间
 
         // 格式化日期
-        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
-        String formattedEndDate = "";
         LocalDateTime endDateTime = lifeGroupBuyMainVo.getEndTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
         // 调整结束时间为前一天的23:59:59
         endDateTime = endDateTime.minusDays(1).withHour(23).withMinute(59).withSecond(59);