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

Commit a2412705 authored by 张国柄's avatar 张国柄

~API:商铺活动:优惠券编辑、管理;

parent 33fea9bc
......@@ -130,6 +130,10 @@ public class GoblinRedisConst {
* {goblin:s_coupon_r:${store_coupon_id}, JsonUtils.toJson(List<String:spu_id>)}
*/
public static final String STORE_COUPON_RULE = PREFIX.concat("s_coupon_r:");
/**
* 商铺活动:优惠券剩余库存
*/
public static final String STORE_COUPON_STOCK = PREFIX.concat("s_coupon_stock:");
/* ----------------------------------------------------------------- */
......
......@@ -119,7 +119,7 @@ public class GoblinStoreMgtCouponAddParam implements Serializable {
storeCouponBasicVo.setState("0");// 等待开始
storeCouponBasicVo.setStartTime(DateUtil.Formatter.yyyyMMddHHmmss.parse(this.getStartDt()));
storeCouponBasicVo.setEndTime(DateUtil.Formatter.yyyyMMddHHmmss.parse(this.getEndDt()));
storeCouponBasicVo.setSpuIdList(this.getSpuIdList());
storeCouponBasicVo.setSpuIdList(this.getUseScope().equals("1") ? this.getSpuIdList() : null);
return storeCouponBasicVo;
}
}
package com.liquidnet.service.goblin.service.manage;
import com.liquidnet.service.base.PagedResult;
import com.liquidnet.service.goblin.dto.manage.GoblinStoreMgtCouponActionParam;
import com.liquidnet.service.goblin.dto.manage.GoblinStoreMgtCouponFilterParam;
import com.liquidnet.service.goblin.dto.manage.vo.GoblinStoreMgtCouponInfoVo;
import com.liquidnet.service.goblin.dto.manage.vo.GoblinStoreMgtCouponListVo;
import com.liquidnet.service.goblin.dto.vo.GoblinStoreCouponBasicVo;
import com.liquidnet.service.goblin.dto.vo.GoblinStoreCouponVo;
import java.util.List;
public interface IGoblinstoreMgtCouponService {
/**
......@@ -31,43 +35,40 @@ public interface IGoblinstoreMgtCouponService {
* @return GoblinStoreMgtCouponInfoVo
*/
GoblinStoreMgtCouponInfoVo couponInfo(String storeId, String storeCouponId);
//
// /**
// * 商铺活动:商品编辑:优惠券编辑
// *
// * @param uid UID
// * @param storeMgtGoodsAddParam GoblinStoreMgtGoodsAddParam
// * @return boolean
// */
// boolean goodsEdit(String uid, GoblinStoreMgtGoodsAddParam storeMgtGoodsAddParam);
//
// /**
// * 商铺活动:商品编辑:SKU编辑
// *
// * @param uid UID
// * @param storeMgtGoodsEditSkuParam GoblinStoreMgtGoodsEditSkuParam
// * @param goodsInfoVo GoblinGoodsInfoVo
// * @param del优惠券SpecMap Map<String, String>
// * @param beUpdate优惠券SpecFlg boolean
// * @return boolean
// */
// boolean goodsEditStock(String uid, GoblinStoreMgtGoodsEditSkuParam storeMgtGoodsEditSkuParam,
// GoblinGoodsInfoVo goodsInfoVo, Map<String, String> del优惠券SpecMap, boolean beUpdate优惠券SpecFlg);
//
// /**
// * 商铺活动:上下架商品
// *
// * @param storeMgtGoodsActionParam GoblinStoreMgtGoodsActionParam
// * @param uid UID
// * @param shelvesFlg true:上架|false:下架
// */
// void goodsShelvesProcessing(GoblinStoreMgtGoodsActionParam storeMgtGoodsActionParam, String uid, boolean shelvesFlg);
//
// /**
// * 商铺活动:删除商品
// *
// * @param storeMgtGoodsActionParam GoblinStoreMgtGoodsActionParam
// * @param uid UID
// */
// void goodsRemove(GoblinStoreMgtGoodsActionParam storeMgtGoodsActionParam, String uid);
/**
* 商铺活动:优惠券编辑
*
* @param uid UID
* @param storeCouponBasicVo GoblinStoreCouponBasicVo
* @param beforeSpuIdList List<String>
* @return boolean
*/
boolean couponEdit(String uid, GoblinStoreCouponBasicVo storeCouponBasicVo, List<String> beforeSpuIdList);
/**
* 商铺活动:优惠券库存编辑
*
* @param storeCouponVo GoblinStoreCouponVo
* @param uid UID
* @param operStock int
* @return boolean
*/
boolean couponEditStock(GoblinStoreCouponVo storeCouponVo, String uid, int operStock);
/**
* 商铺活动:优惠券启用/停用
*
* @param mgtCouponActionParam GoblinStoreMgtCouponActionParam
* @param uid UID
*/
void couponActivityProcessing(GoblinStoreMgtCouponActionParam mgtCouponActionParam, String uid);
/**
* 商铺活动:删除优惠券
*
* @param mgtCouponActionParam GoblinStoreMgtCouponActionParam
* @param uid UID
*/
void couponRemove(GoblinStoreMgtCouponActionParam mgtCouponActionParam, String uid);
}
......@@ -52,10 +52,6 @@ public class GoblinStoreCouponRule implements Serializable {
private LocalDateTime updatedAt;
private String deletedBy;
private LocalDateTime deletedAt;
private String comment;
......
......@@ -1011,8 +1011,6 @@ create table goblin_store_coupon_rule
created_at datetime(3) not null,
updated_by varchar(64) null,
updated_at datetime(3) null,
deleted_by varchar(64) null,
deleted_at datetime(3) null,
comment text
) engine = InnoDB comment '商铺营销-优惠券规则';
......
......@@ -2,6 +2,7 @@ package com.liquidnet.service.goblin.controller.manage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.liquidnet.common.exception.constant.ErrorCode;
import com.liquidnet.commons.lang.util.CurrentUtil;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.base.ErrorMapping;
......@@ -13,6 +14,7 @@ import com.liquidnet.service.goblin.dto.manage.GoblinStoreMgtCouponFilterParam;
import com.liquidnet.service.goblin.dto.manage.vo.GoblinStoreMgtCouponInfoVo;
import com.liquidnet.service.goblin.dto.manage.vo.GoblinStoreMgtCouponListVo;
import com.liquidnet.service.goblin.dto.vo.GoblinStoreCouponBasicVo;
import com.liquidnet.service.goblin.dto.vo.GoblinStoreCouponVo;
import com.liquidnet.service.goblin.service.manage.IGoblinstoreMgtCouponService;
import com.liquidnet.service.goblin.util.GoblinMongoUtils;
import com.liquidnet.service.goblin.util.GoblinRedisUtils;
......@@ -21,13 +23,16 @@ import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;
@ApiSupport(order = 149006)
@Api(tags = "商铺活动:优惠券管理")
......@@ -74,19 +79,20 @@ public class GoblinStoreMgtCouponController {
if (!goblinRedisUtils.hasStoreId(currentUid, mgtCouponActionParam.getStoreId())) {
return ResponseDto.failure(ErrorMapping.get("149002"));
}
if (CollectionUtils.isEmpty(mgtCouponActionParam.getStoreCouponIdList())) {
return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "请选择优惠券操作");
}
if (log.isDebugEnabled()) {
log.debug("商铺活动:优惠券管理:[GoblinStoreMgtCouponActionParam={}]", JsonUtils.toJson(mgtCouponActionParam));
}
switch (mgtCouponActionParam.getAction()) {
case "ONSHELVES":
// mgtCouponActionParam.goodsShelvesProcessing(mgtCouponActionParam, currentUid, true);
break;
case "UNSHELVE":
// mgtCouponActionParam.goodsShelvesProcessing(mgtCouponActionParam, currentUid, false);
switch (mgtCouponActionParam.getAction()) {//ENABLED|DISABLED|REMOVE
case "ENABLED":
case "DISABLED":
goblinstoreMgtCouponService.couponActivityProcessing(mgtCouponActionParam, currentUid);
break;
case "REMOVE":
// mgtCouponActionParam.goodsRemove(mgtCouponActionParam, currentUid);
goblinstoreMgtCouponService.couponRemove(mgtCouponActionParam, currentUid);
break;
default:
log.warn("商铺活动:优惠券管理:Invalid operation[UID={},storeMgtGoodsActionParam={}]", currentUid, JsonUtils.toJson(mgtCouponActionParam));
......@@ -99,8 +105,7 @@ public class GoblinStoreMgtCouponController {
@ApiOperation(value = "新增优惠券")
@PutMapping("add")
public ResponseDto<Object> add(@Valid @RequestBody GoblinStoreMgtCouponAddParam mgtCouponAddParam) {
String currentUid = CurrentUtil.getCurrentUid();
String storeId = mgtCouponAddParam.getStoreId();
String currentUid = CurrentUtil.getCurrentUid(), storeId = mgtCouponAddParam.getStoreId();
if (!goblinRedisUtils.hasStoreId(currentUid, storeId)) {
return ResponseDto.failure(ErrorMapping.get("149002"));
}
......@@ -124,6 +129,12 @@ public class GoblinStoreMgtCouponController {
break;
}
List<String> spuIdList = storeCouponBasicVo.getSpuIdList();
if (storeCouponBasicVo.getUseScope().equals("1") && !CollectionUtils.isEmpty(spuIdList)) {
spuIdList.removeIf(spuId -> null == goblinRedisUtils.getGoodsInfoVo(spuId));
storeCouponBasicVo.setSpuIdList(spuIdList);
}
goblinstoreMgtCouponService.couponAdd(currentUid, storeCouponBasicVo);
return ResponseDto.success(storeCouponBasicVo.getStoreCouponId());
......@@ -151,8 +162,52 @@ public class GoblinStoreMgtCouponController {
@ApiOperation(value = "优惠券编辑", notes = "只修改基本信息,不包含发放设置修改")
@PostMapping("edit")
public ResponseDto<Object> edit(@Valid @RequestBody GoblinStoreMgtCouponAddParam mgtCouponEditParam) {
log.info("商铺活动:优惠券编辑:[mgtCouponEditParam={}]", JsonUtils.toJson(mgtCouponEditParam));
return ResponseDto.success();
String currentUid = CurrentUtil.getCurrentUid(), storeId = mgtCouponEditParam.getStoreId();
if (!goblinRedisUtils.hasStoreId(currentUid, storeId)) {
return ResponseDto.failure(ErrorMapping.get("149002"));
}
String storeCouponId = mgtCouponEditParam.getStoreCouponId();
GoblinStoreCouponVo storeCouponVo;
if (StringUtils.isBlank(storeCouponId)
|| null == (storeCouponVo = goblinRedisUtils.getStoreCouponVo(storeCouponId))) {
return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "参数无效:优惠券ID");
}
if (!storeId.equals(storeCouponVo.getStoreId())) {
return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "参数有误:无权编辑优惠券");
}
if (log.isDebugEnabled()) {
log.debug("商铺活动:优惠券编辑:[mgtCouponEditParam={}]", JsonUtils.toJson(mgtCouponEditParam));
}
GoblinStoreCouponBasicVo storeCouponBasicVo = mgtCouponEditParam.initStoreCouponBasicInfo();
storeCouponBasicVo.setStock(storeCouponVo.getStock());// 这里库存不允许编辑修改,只可在列表页编辑'增减库存'
switch (storeCouponBasicVo.getType()) {
case "1":// 代金
storeCouponBasicVo.setValFace(mgtCouponEditParam.getValFace());
break;
case "2":// 折扣
storeCouponBasicVo.setDiscount(mgtCouponEditParam.getDiscount());
storeCouponBasicVo.setDeduction(mgtCouponEditParam.getDeduction());
break;
case "3":// 满减
storeCouponBasicVo.setValOver(mgtCouponEditParam.getValOver());
storeCouponBasicVo.setValMinus(mgtCouponEditParam.getValMinus());
storeCouponBasicVo.setDeduction(mgtCouponEditParam.getDeduction());
break;
}
storeCouponBasicVo.setStoreCouponId(storeCouponId);
storeCouponBasicVo.setStoreCouponNo(storeCouponVo.getStoreCouponNo());
List<String> spuIdList = storeCouponBasicVo.getSpuIdList();
if (storeCouponBasicVo.getUseScope().equals("1") && !CollectionUtils.isEmpty(spuIdList)) {
spuIdList.removeIf(spuId -> null == goblinRedisUtils.getGoodsInfoVo(spuId));
storeCouponBasicVo.setSpuIdList(spuIdList);
}
List<String> beforeSpuIdList = null;
if (storeCouponVo.getUseScope().equals("1")) {
beforeSpuIdList = goblinRedisUtils.getStoreCouponSpuIds(storeCouponId);
}
return ResponseDto.success(goblinstoreMgtCouponService.couponEdit(currentUid, storeCouponBasicVo, beforeSpuIdList));
}
@ApiOperationSupport(order = 7)
......@@ -160,13 +215,32 @@ public class GoblinStoreMgtCouponController {
@ApiImplicitParams({
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "storeId", value = "店铺ID"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "storeCouponId", value = "优惠券ID"),
@ApiImplicitParam(type = "form", required = true, dataType = "Integer", name = "stock", value = "增减库存"),
@ApiImplicitParam(type = "form", required = true, dataType = "Integer", name = "operStock", value = "增减库存"),
})
@PostMapping("edit_stock")
public ResponseDto<Object> editStock(@NotBlank(message = "店铺ID不能为空") @RequestParam String storeId,
@NotBlank(message = "优惠券ID不能为空") @RequestParam String storeCouponId,
@NotNull(message = "增减库存值不能为空") @RequestParam Integer stock) {
log.info("商铺活动:优惠券库存编辑:[storeId={},storeCouponId={},stock={}]", storeId, storeCouponId, stock);
@NotNull(message = "增减库存值不能为空") @RequestParam Integer operStock) {
String currentUid = CurrentUtil.getCurrentUid();
if (!goblinRedisUtils.hasStoreId(currentUid, storeId)) {
return ResponseDto.failure(ErrorMapping.get("149002"));
}
GoblinStoreCouponVo storeCouponVo;
if (null == (storeCouponVo = goblinRedisUtils.getStoreCouponVo(storeCouponId))) {
return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "参数无效:优惠券ID");
}
if (!storeId.equals(storeCouponVo.getStoreId())) {
return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "参数有误:无权编辑优惠券");
}
if (operStock == 0) {
return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "参数无效:增减库存不能为0");
}
int operStockVal = Math.abs(operStock), surplusStock = goblinRedisUtils.getStoreCouponStock(storeCouponId);
if (operStock < 0 && operStockVal > surplusStock) {
return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "参数无效:该优惠券当前剩余库存为" + surplusStock);
}
log.info("商铺活动:优惠券库存编辑:[storeId={},storeCouponId={},operStock={},uid={}]", storeId, storeCouponId, operStock, currentUid);
return ResponseDto.success();
}
}
......@@ -5,6 +5,9 @@ import com.liquidnet.commons.lang.util.IDGenerator;
import com.liquidnet.service.base.PagedResult;
import com.liquidnet.service.base.SqlMapping;
import com.liquidnet.service.base.constant.MQConst;
import com.liquidnet.service.goblin.constant.GoblinRedisConst;
import com.liquidnet.service.goblin.dto.GoblinStoreMarketDto;
import com.liquidnet.service.goblin.dto.manage.GoblinStoreMgtCouponActionParam;
import com.liquidnet.service.goblin.dto.manage.GoblinStoreMgtCouponFilterParam;
import com.liquidnet.service.goblin.dto.manage.vo.GoblinStoreMgtCouponInfoVo;
import com.liquidnet.service.goblin.dto.manage.vo.GoblinStoreMgtCouponListVo;
......@@ -67,6 +70,7 @@ public class GoblinStoreMgtCouponServiceImpl implements IGoblinstoreMgtCouponSer
goblinMongoUtils.setMgtStoreCouponBasicVo(storeCouponBasicVo);
LinkedList<String> toMqSqls = CollectionUtil.linkedListString();
toMqSqls.add(SqlMapping.get("goblin_store_coupon.insert"));
LinkedList<Object[]> initStoreCouponObjs = CollectionUtil.linkedListObjectArr();
......@@ -94,7 +98,7 @@ public class GoblinStoreMgtCouponServiceImpl implements IGoblinstoreMgtCouponSer
public GoblinStoreMgtCouponInfoVo couponInfo(String storeId, String storeCouponId) {
GoblinStoreMgtCouponInfoVo mgtCouponInfoVo = GoblinStoreMgtCouponInfoVo.getNew();
GoblinStoreCouponVo couponVo = goblinRedisUtils.getStoreCouponVo(storeCouponId);
if (null != couponVo) {
if (null != couponVo && couponVo.getStoreId().equals(storeId)) {
mgtCouponInfoVo.setCouponVo(couponVo);
if ("1".equals(couponVo.getUseScope())) {
List<String> spuIds = goblinRedisUtils.getStoreCouponSpuIds(storeCouponId);
......@@ -111,4 +115,101 @@ public class GoblinStoreMgtCouponServiceImpl implements IGoblinstoreMgtCouponSer
}
return mgtCouponInfoVo;
}
@Override
public boolean couponEdit(String uid, GoblinStoreCouponBasicVo storeCouponBasicVo, List<String> beforeSpuIdList) {
String storeCouponId = storeCouponBasicVo.getStoreCouponId();
LocalDateTime now = LocalDateTime.now();
storeCouponBasicVo.setUpdatedAt(now);
storeCouponBasicVo.setUpdatedBy(uid);
if (goblinMongoUtils.updateMgtStoreCouponBasicVo(storeCouponBasicVo)) {
goblinRedisUtils.del(GoblinRedisConst.STORE_COUPON.concat(storeCouponId));// 删除REDIS缓存
LinkedList<String> toMqSqls = CollectionUtil.linkedListString();
toMqSqls.add(SqlMapping.get("goblin_store_coupon.update"));
LinkedList<Object[]> updateStoreCouponObjs = CollectionUtil.linkedListObjectArr();
updateStoreCouponObjs.add(new Object[]{
storeCouponBasicVo.getTitle(), storeCouponBasicVo.getLabel(), storeCouponBasicVo.getNotice(),
storeCouponBasicVo.getType(), storeCouponBasicVo.getTriggers(), storeCouponBasicVo.getValFace(),
storeCouponBasicVo.getDiscount(), storeCouponBasicVo.getValOver(),storeCouponBasicVo.getValMinus(),
storeCouponBasicVo.getDeduction(), storeCouponBasicVo.getReceiveLimit(),storeCouponBasicVo.getReceiveCurb(),
storeCouponBasicVo.getUseScope(), storeCouponBasicVo.getStartTime(), storeCouponBasicVo.getEndTime(),
storeCouponBasicVo.getUpdatedBy(), storeCouponBasicVo.getUpdatedAt()
});
toMqSqls.add(SqlMapping.get("goblin_store_coupon_rule.update_del"));
LinkedList<Object[]> delStoreCouponRuleObjs = CollectionUtil.linkedListObjectArr();
delStoreCouponRuleObjs.add(new Object[]{uid, now, storeCouponId});
toMqSqls.add(SqlMapping.get("goblin_store_coupon_rule.insert"));
LinkedList<Object[]> initStoreCouponRuleObjs = CollectionUtil.linkedListObjectArr();
if ("1".equals(storeCouponBasicVo.getUseScope()) && !CollectionUtils.isEmpty(storeCouponBasicVo.getSpuIdList())) {// 部分商品
storeCouponBasicVo.getSpuIdList().forEach(spuId -> initStoreCouponRuleObjs.add(new Object[]{storeCouponId, spuId, uid, now}));
}
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.SQL_STORE.getKey(),
SqlMapping.gets(toMqSqls, updateStoreCouponObjs, delStoreCouponRuleObjs, initStoreCouponRuleObjs));
return true;
}
return false;
}
@Override
public boolean couponEditStock(GoblinStoreCouponVo storeCouponVo, String uid, int operStock) {
return false;
}
@Override
public void couponActivityProcessing(GoblinStoreMgtCouponActionParam mgtCouponActionParam, String uid) {
LocalDateTime now = LocalDateTime.now();
String storeId = mgtCouponActionParam.getStoreId();
String state = mgtCouponActionParam.getAction().equals("DISABLED") ? "3" : "0";
List<String> storeCouponIdList = mgtCouponActionParam.getStoreCouponIdList();
if (goblinMongoUtils.activityMgtStoreCouponBasicVo(uid, now, state, storeCouponIdList)) {
storeCouponIdList.forEach(storeCouponId -> goblinRedisUtils.del(GoblinRedisConst.STORE_COUPON.concat(storeCouponId)));// 删除REDIS缓存
List<GoblinStoreMarketDto> storeMarketDtos = goblinRedisUtils.getStoreMarketDtos(storeId);
if (!CollectionUtils.isEmpty(storeMarketDtos)) {
int beforeSize = storeMarketDtos.size();
storeMarketDtos.removeIf(dto -> (dto.getType() == 1 && storeCouponIdList.contains(dto.getId())));
if (beforeSize > storeMarketDtos.size()) {
goblinRedisUtils.setStoreMarketDtos(storeId, storeMarketDtos);
}
}
LinkedList<Object[]> activityStoreCouponObjs = CollectionUtil.linkedListObjectArr();
storeCouponIdList.forEach(storeCouponId -> activityStoreCouponObjs.add(new Object[]{state, uid, now, storeCouponId}));
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.SQL_STORE.getKey(),
SqlMapping.get("goblin_store_coupon.activity", activityStoreCouponObjs));
}
}
@Override
public void couponRemove(GoblinStoreMgtCouponActionParam mgtCouponActionParam, String uid) {
LocalDateTime now = LocalDateTime.now();
String storeId = mgtCouponActionParam.getStoreId();
List<String> storeCouponIdList = mgtCouponActionParam.getStoreCouponIdList();
if (goblinMongoUtils.delMgtStoreCouponBasicVos(storeCouponIdList, uid, now)) {
storeCouponIdList.forEach(storeCouponId -> goblinRedisUtils.del(GoblinRedisConst.STORE_COUPON.concat(storeCouponId)));// 删除REDIS缓存
List<GoblinStoreMarketDto> storeMarketDtos = goblinRedisUtils.getStoreMarketDtos(storeId);
if (!CollectionUtils.isEmpty(storeMarketDtos)) {
int beforeSize = storeMarketDtos.size();
storeMarketDtos.removeIf(dto -> (dto.getType() == 1 && storeCouponIdList.contains(dto.getId())));
if (beforeSize > storeMarketDtos.size()) {
goblinRedisUtils.setStoreMarketDtos(storeId, storeMarketDtos);
}
}
LinkedList<Object[]> deleteStoreCouponObjs = CollectionUtil.linkedListObjectArr();
storeCouponIdList.forEach(storeCouponId -> deleteStoreCouponObjs.add(new Object[]{uid, now, storeCouponId}));
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.SQL_STORE.getKey(),
SqlMapping.get("goblin_store_coupon.delete", deleteStoreCouponObjs));
}
}
}
......@@ -934,10 +934,32 @@ public class GoblinMongoUtils {
return mongoTemplate.insert(vo, GoblinStoreCouponBasicVo.class.getSimpleName());
}
public boolean updateMgtStoreCouponBasicVo(GoblinStoreCouponBasicVo vo) {
return mongoTemplate.getCollection(GoblinStoreCouponBasicVo.class.getSimpleName()).updateOne(
Query.query(Criteria.where("storeCouponId").is(vo.getStoreCouponId()).and("delFlg").is("0")).getQueryObject(),
ObjectUtil.cloneBasicDBObject().append("$set", mongoConverter.convertToMongoType(vo))
).getModifiedCount() > 0;
}
public boolean activityMgtStoreCouponBasicVo(String uid, LocalDateTime time, String state, List<String> storeCouponIds) {
return mongoTemplate.getCollection(GoblinStoreCouponBasicVo.class.getSimpleName()).updateOne(
Query.query(Criteria.where("storeCouponId").in(storeCouponIds).and("delFlg").is("0")).getQueryObject(),
Update.update("state", state).set("updatedBy", uid).set("updatedAt", time).getUpdateObject()
).getModifiedCount() > 0;
}
public boolean delMgtStoreCouponBasicVo(String storeCouponId, String uid, LocalDateTime time) {
return mongoTemplate.updateFirst(
Query.query(Criteria.where("storeCouponId").is(storeCouponId).and("delFlg").is("0")),
Update.update("delFlg", "1").set("updatedBy", uid).set("updatedAt", time).set("deletedBy", uid).set("deletedAt", time),
Update.update("delFlg", "1").set("deletedBy", uid).set("deletedAt", time),
GoblinStoreCouponBasicVo.class.getSimpleName()
).getModifiedCount() > 0;
}
public boolean delMgtStoreCouponBasicVos(List<String> storeCouponIds, String uid, LocalDateTime time) {
return mongoTemplate.updateFirst(
Query.query(Criteria.where("storeCouponId").in(storeCouponIds).and("delFlg").is("0")),
Update.update("delFlg", "1").set("deletedBy", uid).set("deletedAt", time),
GoblinStoreCouponBasicVo.class.getSimpleName()
).getModifiedCount() > 0;
}
......
......@@ -31,6 +31,9 @@ public class GoblinRedisUtils {
private int randomMax = 10;
public void del(String... keys) {
redisUtil.del(keys);
}
/* ---------------------------------------- sku库存相关 ---------------------------------------- */
public void setSkuStock(String marketPre, String skuId, Integer stock) {
......@@ -978,8 +981,31 @@ public class GoblinRedisUtils {
return strs;
}
/* ---------------------------------------- 商铺活动:优惠券剩余库存 ---------------------------------------- */
public boolean setStoreCouponStock(String storeCouponId, Integer stock) {
return redisUtil.set(GoblinRedisConst.STORE_COUPON_STOCK.concat(storeCouponId), stock);
}
public int getStoreCouponStock(String storeCouponId) {
Object valObj = redisUtil.get(GoblinRedisConst.STORE_COUPON_STOCK.concat(storeCouponId));
return null == valObj ? 0 : (int) valObj;
}
public int incrStoreCouponStock(String storeCouponId, Integer operStock) {
return (int) redisUtil.incr(GoblinRedisConst.STORE_COUPON_STOCK.concat(storeCouponId), operStock);
}
public int decrStoreCouponStock(String storeCouponId, Integer operStock) {
return (int) redisUtil.decr(GoblinRedisConst.STORE_COUPON_STOCK.concat(storeCouponId), operStock);
}
/* ---------------------------------------- 商铺活动 ---------------------------------------- */
public boolean setStoreMarketDtos(String storeId, List<GoblinStoreMarketDto> dtos) {
return redisUtil.set(GoblinRedisConst.STORE_MARKETS.concat(storeId), JsonUtils.toJson(dtos));
}
public List<GoblinStoreMarketDto> getStoreMarketDtos(String storeId) {
String rk = GoblinRedisConst.STORE_MARKETS.concat(storeId);
String valStr = (String) redisUtil.get(rk);
......
......@@ -110,5 +110,9 @@ goblin_shop.cart.update = update goblin_shopping_cart set `number` = ? where car
#---- 商铺活动:优惠券
goblin_store_coupon.insert=INSERT INTO goblin_store_coupon (store_coupon_id,store_coupon_no,store_id,title,label, notice,type,stock,triggers,val_face, discount,val_over,val_minus,deduction,receive_limit, receive_curb,use_scope,state,start_time,end_time, created_by,created_at)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
goblin_store_coupon.update=UPDATE goblin_store_coupon SET title=?,label=?,notice=?,type=?,triggers=?,val_face=?,discount=?,val_over=?,val_minus=?,deduction=?,receive_limit=?,receive_curb=?,use_scope=?,start_time=?,end_time=?,updated_by=?,updated_at=? WHERE store_coupon_id=? AND del_flg='0'
goblin_store_coupon.activity=UPDATE goblin_store_coupon SET state=?,updated_by=?,updated_at=? WHERE store_coupon_id=? AND del_flg='0'
goblin_store_coupon.delete=UPDATE goblin_store_coupon SET del_flg='1',deleted_by=?,deleted_at=? WHERE store_coupon_id=? AND del_flg='0'
goblin_store_coupon_rule.insert=INSERT INTO dev_ln_scene.goblin_store_coupon_rule (store_coupon_id,spu_id,created_by,created_at)VALUES(?,?,?,?)
\ No newline at end of file
goblin_store_coupon_rule.insert=INSERT INTO goblin_store_coupon_rule (store_coupon_id,spu_id,created_by,created_at)VALUES(?,?,?,?)
goblin_store_coupon_rule.update_del=UPDATE goblin_store_coupon_rule SET del_flg='1',updated_by=?,updated_at=? WHERE store_coupon_id=? AND del_flg='0'
\ No newline at end of file
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