提交抽奖代码

dev-discount
袁野 2 years ago
parent 36dd772b1c
commit fe0ac2dcf2
  1. 2
      hai-bweb/src/main/resources/dev/application.yml
  2. 2
      hai-cweb/src/main/resources/dev/application.yml
  3. 20
      hai-service/src/main/java/com/hai/common/utils/DateUtil.java
  4. 4
      hai-service/src/main/java/com/hai/service/HighDiscountAgentCodeService.java
  5. 6
      hai-service/src/main/java/com/hai/service/impl/HighActivityAwardServiceImpl.java
  6. 31
      hai-service/src/main/java/com/hai/service/impl/HighActivityUserLotteryNumServiceImpl.java
  7. 6
      hai-service/src/main/java/com/hai/service/impl/SecConfigServiceImpl.java

@ -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

@ -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

@ -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);
}
}

@ -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<com.hai.entity.HighDiscountAgentCode>
@ -77,8 +77,6 @@ public interface HighDiscountAgentCodeService {
HighDiscountAgentCode getCodeById(Long id);
/**
* 查询已分配的优惠券总数
* @param discountAgentId

@ -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<HighDiscountAgentCode> codeList = highDiscountAgentCodeService.getDiscountCodeByDiscountAgentId(discountAgentRel.getId());
List<HighDiscountAgentCode> 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<HighDiscountAgentCode> codeList = highDiscountAgentCodeService.getDiscountCodeByDiscountAgentId(discountAgentRel.getId());
List<HighDiscountAgentCode> codeList = highDiscountAgentCodeService.getDiscountCodeByStatus(discountAgentRel.getId() , 1);
if (list.getPrizeNum() > codeList.size()) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.ADD_DATA_ERROR, "");

@ -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();
}

@ -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<SecConfig> list = secConfigMapper.selectByExample(example);
if (list.size() > 0) {
return secConfigMapper.selectByExample(example).get(0);
}
return null;
}
@Override

Loading…
Cancel
Save