From 6a54e8f23a70c052e1457defd38c7b265179c4eb Mon Sep 17 00:00:00 2001 From: wangw <1594593906@qq.com> Date: Thu, 7 Nov 2024 15:25:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E4=BA=AB=E5=A5=BD=E5=8F=8B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/TbShopShareController.java | 3 ++- .../cashierservice/entity/TbShopShare.java | 3 +++ .../service/impl/TbShopShareServiceImpl.java | 23 ++++++++----------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbShopShareController.java b/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbShopShareController.java index c3f139f..12bf3da 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbShopShareController.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/controller/TbShopShareController.java @@ -2,6 +2,7 @@ package com.chaozhanggui.system.cashierservice.controller; import com.chaozhanggui.system.cashierservice.service.TbShopShareService; import com.chaozhanggui.system.cashierservice.sign.Result; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -21,7 +22,7 @@ public class TbShopShareController { /** * 服务对象 */ - @Resource + @Autowired private TbShopShareService tbShopShareService; diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopShare.java b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopShare.java index e770a75..9c3021f 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopShare.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/entity/TbShopShare.java @@ -3,6 +3,7 @@ package com.chaozhanggui.system.cashierservice.entity; import cn.hutool.core.collection.CollectionUtil; import com.baomidou.mybatisplus.annotation.TableField; import com.chaozhanggui.system.cashierservice.util.JSONUtil; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import org.apache.commons.lang3.StringUtils; @@ -45,10 +46,12 @@ public class TbShopShare implements Serializable { /** * 活动开始时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date startTime; /** * 活动结束时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date endTime; /** * 新用户获得券 diff --git a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopShareServiceImpl.java b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopShareServiceImpl.java index 9ba35fc..156b121 100644 --- a/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopShareServiceImpl.java +++ b/src/main/java/com/chaozhanggui/system/cashierservice/service/impl/TbShopShareServiceImpl.java @@ -9,6 +9,7 @@ import com.chaozhanggui.system.cashierservice.entity.TbShopShare; import com.chaozhanggui.system.cashierservice.service.TbShopShareService; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Primary; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -20,26 +21,22 @@ import java.time.format.DateTimeFormatter; * @author ww * @since 2024-11-07 14:36:27 */ -@Service("tbShopShareService") +@Primary +@Service public class TbShopShareServiceImpl implements TbShopShareService { - @Resource + @Autowired private TbShopShareMapper tbShopShareMapper; @Autowired private TbShopCouponMapper couponMapper; @Autowired private TbCouponProductMapper couProductMapper; - /** - * 通过ID查询单条数据 - * - * @param id 主键 - * @return 实例对象 - */ + @Override - public TbShopShare queryByShopId(Integer id) { - TbShopShare tbShopShare = tbShopShareMapper.queryByShopId(id); + public TbShopShare queryByShopId(Integer shopId) { + TbShopShare tbShopShare = tbShopShareMapper.queryByShopId(shopId); if (tbShopShare != null) { - if(CollectionUtil.isNotEmpty(tbShopShare.getNewCoupons())){ + if (CollectionUtil.isNotEmpty(tbShopShare.getNewCoupons())) { for (TbShopShare.ShareCoupons newCoupon : tbShopShare.getNewCoupons()) { TbShopCoupon coupon = couponMapper.queryById(newCoupon.getCouponId()); if (coupon != null) { @@ -58,7 +55,7 @@ public class TbShopShareServiceImpl implements TbShopShareService { } } } - if(CollectionUtil.isNotEmpty(tbShopShare.getRewardCoupons())){ + if (CollectionUtil.isNotEmpty(tbShopShare.getRewardCoupons())) { for (TbShopShare.ShareCoupons rewardCoupon : tbShopShare.getRewardCoupons()) { TbShopCoupon coupon = couponMapper.queryById(rewardCoupon.getCouponId()); if (coupon != null) { @@ -91,7 +88,7 @@ public class TbShopShareServiceImpl implements TbShopShareService { } } - if (tbShopCoupon.getUseTimeType().equals("custom")) { + if (StringUtils.isNotBlank(tbShopCoupon.getUseTimeType()) && tbShopCoupon.getUseTimeType().equals("custom")) { useRestrictions.append( tbShopCoupon.getUseStartTime().format(formatter) + "-"