记得上下班打卡 | 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 '商铺营销-优惠券规则';
......
......@@ -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