记得上下班打卡 | git大法好,push需谨慎

Commit 9def8731 authored by 张国柄's avatar 张国柄

~API:添加优惠券:当前时间时直接开始活动处理;

~API:添加优惠券:+时间校验;
parent 7795e953
......@@ -41,6 +41,7 @@ import javax.validation.constraints.NotNull;
import java.io.IOException;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.time.LocalDateTime;
import java.util.Iterator;
import java.util.List;
......@@ -207,6 +208,10 @@ public class GoblinStoreMgtCouponController {
storeCouponBasicVo.setDeduction(mgtCouponAddParam.getValMinus());
break;
}
LocalDateTime startTime = storeCouponBasicVo.getStartTime(), endTime = storeCouponBasicVo.getEndTime();
if (startTime.isEqual(endTime) || startTime.isAfter(endTime) || endTime.isBefore(LocalDateTime.now())) {
return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "活动开始、结束时间无效");
}
List<String> spuIdList = storeCouponBasicVo.getSpuIdList();
if (storeCouponBasicVo.getUseScope().equals("1") && !CollectionUtils.isEmpty(spuIdList)) {
......@@ -265,9 +270,17 @@ public class GoblinStoreMgtCouponController {
log.debug("商铺活动:优惠券编辑:[mgtCouponEditParam={}]", JsonUtils.toJson(mgtCouponEditParam));
}
GoblinStoreCouponBasicVo storeCouponBasicVo = mgtCouponEditParam.initStoreCouponBasicInfo();
LocalDateTime startTime = storeCouponBasicVo.getStartTime(), endTime = storeCouponBasicVo.getEndTime();
if (startTime.isEqual(endTime) || startTime.isAfter(endTime) || endTime.isBefore(LocalDateTime.now())) {
return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "活动开始、结束时间无效");
}
LocalDateTime befStartTime = storeCouponVo.getStartTime();
if (befStartTime.minusMinutes(10).isAfter(storeCouponBasicVo.getStartTime())) {
storeCouponBasicVo.setStartTime(startTime);
}
storeCouponBasicVo.setType(storeCouponVo.getType());
storeCouponBasicVo.setState(storeCouponVo.getState());
storeCouponBasicVo.setStartTime(storeCouponVo.getStartTime());
storeCouponBasicVo.setStock(storeCouponVo.getStock());// 这里库存不允许编辑修改,只可在列表页编辑'增减库存'
switch (storeCouponBasicVo.getType()) {
case "1":// 代金
......
......@@ -136,6 +136,9 @@ public class GoblinStoreMgtCouponServiceImpl implements IGoblinstoreMgtCouponSer
String storeCouponId = IDGenerator.nextMilliId();
LocalDateTime now = LocalDateTime.now();
boolean activityStartFlg = storeCouponBasicVo.getStartTime().isBefore(now);
storeCouponBasicVo.setState(activityStartFlg ? "1" : "0");
storeCouponBasicVo.setStoreCouponId(storeCouponId);
storeCouponBasicVo.setStoreCouponNo(storeCouponId);
storeCouponBasicVo.setDelFlg("0");
......@@ -148,6 +151,14 @@ public class GoblinStoreMgtCouponServiceImpl implements IGoblinstoreMgtCouponSer
goblinRedisUtils.setStoreCouponStock(storeCouponId, stock);
}
if (activityStartFlg) {// 活动已开始,处理店铺活动数据
GoblinStoreMarketDto storeMarketDto = GoblinStoreMarketDto.getNew();
storeMarketDto.setId(storeCouponId);
storeMarketDto.setType(1);
goblinRedisUtils.addStoreMarketDto(storeCouponBasicVo.getStoreId(), storeMarketDto);
}
LinkedList<String> toMqSqls = CollectionUtil.linkedListString();
toMqSqls.add(SqlMapping.get("goblin_store_coupon.insert"));
LinkedList<Object[]> initStoreCouponObjs = CollectionUtil.linkedListObjectArr();
......@@ -210,10 +221,21 @@ public class GoblinStoreMgtCouponServiceImpl implements IGoblinstoreMgtCouponSer
String storeCouponId = storeCouponBasicVo.getStoreCouponId();
LocalDateTime now = LocalDateTime.now();
boolean activityStopFlg = storeCouponBasicVo.getEndTime().isBefore(now);
storeCouponBasicVo.setState(activityStopFlg ? "2" : storeCouponBasicVo.getState());
storeCouponBasicVo.setUpdatedAt(now);
storeCouponBasicVo.setUpdatedBy(uid);
if (goblinMongoUtils.updateMgtStoreCouponBasicVo(storeCouponBasicVo)) {
if (activityStopFlg) {// 活动已结束,处理店铺活动数据
GoblinStoreMarketDto storeMarketDto = GoblinStoreMarketDto.getNew();
storeMarketDto.setId(storeCouponId);
storeMarketDto.setType(1);
goblinRedisUtils.delStoreMarketDto(storeCouponBasicVo.getStoreId(), storeMarketDto);
}
goblinRedisUtils.del(GoblinRedisConst.STORE_COUPON.concat(storeCouponId));// 删除REDIS缓存
goblinRedisUtils.del(GoblinRedisConst.STORE_COUPON_RULE.concat(storeCouponId));// 删除REDIS缓存
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment