diff --git a/hai-bweb/src/main/resources/dev/application.yml b/hai-bweb/src/main/resources/dev/application.yml index 59fb1869..11c2de93 100644 --- a/hai-bweb/src/main/resources/dev/application.yml +++ b/hai-bweb/src/main/resources/dev/application.yml @@ -9,7 +9,7 @@ debug: false #datasource数据源设置 spring: datasource: - url: jdbc:mysql://139.159.177.244:3306/hfkj?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false + url: jdbc:mysql://139.159.177.244:3306/hsg_pre?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false username: root password: HF123456. type: com.alibaba.druid.pool.DruidDataSource diff --git a/hai-cweb/src/main/resources/dev/application.yml b/hai-cweb/src/main/resources/dev/application.yml index 9d3beabf..d0dd0258 100644 --- a/hai-cweb/src/main/resources/dev/application.yml +++ b/hai-cweb/src/main/resources/dev/application.yml @@ -9,7 +9,7 @@ debug: false #datasource数据源设置 spring: datasource: - url: jdbc:mysql://139.159.177.244:3306/hfkj?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false + url: jdbc:mysql://139.159.177.244:3306/hsg_pre?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false username: root password: HF123456. type: com.alibaba.druid.pool.DruidDataSource diff --git a/hai-service/src/main/java/com/hai/common/utils/DateUtil.java b/hai-service/src/main/java/com/hai/common/utils/DateUtil.java index 09d9f1a4..9eb8d41a 100644 --- a/hai-service/src/main/java/com/hai/common/utils/DateUtil.java +++ b/hai-service/src/main/java/com/hai/common/utils/DateUtil.java @@ -785,4 +785,24 @@ public class DateUtil { System.out.println(getSecondDiff(new Date(), date)); } + /** + * @Author Sum1Dream + * @Name isNow + * @Description // 判断日期是是否是当天 + * @Date 14:33 2022/12/26 + * @Param [date] + * @Return boolean 是返回true,不是返回false + */ + public static boolean isNow(Date date) { + // 当前时间 + Date now = new Date(); + SimpleDateFormat sf = new SimpleDateFormat(Y_M_D); + //获取今天的日期 + String nowDay = sf.format(now); + //对比的时间 + String day = sf.format(date); + + return day.equals(nowDay); + } + } diff --git a/hai-service/src/main/java/com/hai/service/HighDiscountAgentCodeService.java b/hai-service/src/main/java/com/hai/service/HighDiscountAgentCodeService.java index b5e79ad0..ebafa680 100644 --- a/hai-service/src/main/java/com/hai/service/HighDiscountAgentCodeService.java +++ b/hai-service/src/main/java/com/hai/service/HighDiscountAgentCodeService.java @@ -51,7 +51,7 @@ public interface HighDiscountAgentCodeService { /** * @Author Sum1Dream * @name getDiscountCodeByDiscountAgentId.java - * @Description // 根据关系id 查询 未领取的卡券 + * @Description // 根据关系id 查询 已分配的优惠券 * @Date 14:20 2021/9/29 * @Param [discountAgentId] * @return java.util.List @@ -77,8 +77,6 @@ public interface HighDiscountAgentCodeService { HighDiscountAgentCode getCodeById(Long id); - - /** * 查询已分配的优惠券总数 * @param discountAgentId diff --git a/hai-service/src/main/java/com/hai/service/impl/HighActivityAwardServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighActivityAwardServiceImpl.java index 3d51f2fd..b0a8a75d 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighActivityAwardServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighActivityAwardServiceImpl.java @@ -76,8 +76,6 @@ public class HighActivityAwardServiceImpl implements HighActivityAwardService { highActivityPrizeMapper.insert(list); } - - HighActivityAwardSerialNum serialNum; HighActivityAwardActualPrize actualPrize; @@ -102,7 +100,7 @@ public class HighActivityAwardServiceImpl implements HighActivityAwardService { endNum += list.getPrizeNum(); HighDiscountAgentRel discountAgentRel = highDiscountAgentRelService.getRelByDiscountAgent(list.getPrizeId() , Long.valueOf(list.getExt1())); - List codeList = highDiscountAgentCodeService.getDiscountCodeByDiscountAgentId(discountAgentRel.getId()); + List codeList = highDiscountAgentCodeService.getDiscountCodeByStatus(discountAgentRel.getId() , 1); if (list.getPrizeNum() > codeList.size()) { throw ErrorHelp.genException(SysCode.System, ErrorCode.ADD_DATA_ERROR, ""); @@ -233,7 +231,7 @@ public class HighActivityAwardServiceImpl implements HighActivityAwardService { endNum += list.getPrizeNum(); HighDiscountAgentRel discountAgentRel = highDiscountAgentRelService.getRelByDiscountAgent(list.getPrizeId() , Long.valueOf(list.getExt1())); - List codeList = highDiscountAgentCodeService.getDiscountCodeByDiscountAgentId(discountAgentRel.getId()); + List codeList = highDiscountAgentCodeService.getDiscountCodeByStatus(discountAgentRel.getId() , 1); if (list.getPrizeNum() > codeList.size()) { throw ErrorHelp.genException(SysCode.System, ErrorCode.ADD_DATA_ERROR, ""); diff --git a/hai-service/src/main/java/com/hai/service/impl/HighActivityUserLotteryNumServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighActivityUserLotteryNumServiceImpl.java index 62638509..42e8c205 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighActivityUserLotteryNumServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighActivityUserLotteryNumServiceImpl.java @@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; +import com.hai.common.utils.DateUtil; import com.hai.dao.HighActivityUserLotteryNumMapper; import com.hai.entity.*; import com.hai.enum_type.ActivityInfoStatus; @@ -42,6 +43,9 @@ public class HighActivityUserLotteryNumServiceImpl implements HighActivityUserLo @Resource private HighDiscountUserRelService highDiscountUserRelService; + @Resource + private SecConfigService secConfigService; + @Override @Transactional(rollbackFor = Exception.class, propagation= Propagation.REQUIRES_NEW, @@ -110,6 +114,7 @@ public class HighActivityUserLotteryNumServiceImpl implements HighActivityUserLo } } + @Override public void minusLotteryNum(Long activityId, Long userId) { HighActivityUserLotteryNum detail = getDetail(activityId, userId); @@ -133,9 +138,31 @@ public class HighActivityUserLotteryNumServiceImpl implements HighActivityUserLo @Override public Integer getLotteryNum(Long activityId, Long userId) { HighActivityUserLotteryNum detail = getDetail(activityId, userId); - if (detail == null) { - return 0; + + // todo 临时代码 查询制定活动 + SecConfig secConfig = secConfigService.findByCodeType(activityId.toString()); + + // 判断是否有不购买活动 + if (secConfig != null) { + // 判断是否活动为空 + if (detail == null) { + addLotteryNum(activityId , userId , 3); + return 3; + } else { + if (!DateUtil.isNow(detail.getUpdateTime())) { + detail.setLotteryNum(3); + detail.setUpdateTime(new Date()); + highActivityUserLotteryNumMapper.updateByPrimaryKey(detail); + } + } + + } else { + if (detail == null) { + return 0; + } } + + return detail.getLotteryNum(); } diff --git a/hai-service/src/main/java/com/hai/service/impl/SecConfigServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/SecConfigServiceImpl.java index 9a732714..ec15975d 100644 --- a/hai-service/src/main/java/com/hai/service/impl/SecConfigServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/SecConfigServiceImpl.java @@ -46,7 +46,11 @@ public class SecConfigServiceImpl implements SecConfigService { public SecConfig findByCodeType(String codeType) { SecConfigExample example = new SecConfigExample(); example.createCriteria().andCodeTypeEqualTo(codeType); - return secConfigMapper.selectByExample(example).get(0); + List list = secConfigMapper.selectByExample(example); + if (list.size() > 0) { + return secConfigMapper.selectByExample(example).get(0); + } + return null; } @Override