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

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

~商品指定用户限购名单调整;

parent 1a0c8a5b
......@@ -58,12 +58,16 @@ public class GoblinStoreMgtGoodsEditSkuParam implements Serializable {
@ApiModelProperty(position = 23, required = false, value = "ISBN,针对CD/图书等[100]")
private String skuIsbn;
@ApiModelProperty(position = 24, required = true, value = "购买限制[0-全部用户|1-仅会员|2-指定用户]")
@Pattern(regexp = "\\b(0|1|2)\\b", message = "购买限制参数无效")
private String buyFactor;
@ApiModelProperty(position = 25, required = false, value = "购买限制人员名单[购买限制为2-指定用户时必填]")
@ApiModelProperty(position = 25, required = false, value = "购买限制人员名单,购买限制为2-指定用户时必填")
private String buyRoster;
@ApiModelProperty(position = 26, required = false, value = "限量[0-无限制|X:限购数量]")
@ApiModelProperty(position = 26, required = false, value = "购买限制人员名单操作类型[1-添加|2-删除],购买限制为2-指定用户时有效")
@Pattern(regexp = "\\b(1|2)\\b", message = "购买限制人员名单操作类型参数无效")
private String buyRosterType;
@ApiModelProperty(position = 27, required = false, value = "限量[0-无限制|X:限购数量]")
private Integer buyLimit;
@ApiModelProperty(position = 27, required = false, value = "单品有效期[yyyy-MM-dd HH:mm:ss]")
@ApiModelProperty(position = 28, required = false, value = "单品有效期[yyyy-MM-dd HH:mm:ss]")
@Pattern(regexp = LnsRegex.Valid.DATETIME_FULL, message = "单品有效期格式有误")
private String skuValidity;
......
......@@ -4,8 +4,10 @@ import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.read.listener.PageReadListener;
import com.alibaba.fastjson.JSON;
import com.liquidnet.common.cache.redis.util.RedisUtil;
import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.consumer.goblin.dto.PhoneDto;
import com.liquidnet.service.consumer.goblin.service.IBaseDao;
import com.liquidnet.service.goblin.constant.GoblinRedisConst;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -15,14 +17,20 @@ import org.springframework.data.redis.stream.StreamListener;
import java.io.InputStream;
import java.net.URL;
import java.time.LocalDateTime;
import java.util.LinkedList;
@Slf4j
public abstract class AbstractXlsRedisReceiver implements StreamListener<String, MapRecord<String, String, String>> {
@Autowired
private IBaseDao baseDao;
@Autowired
StringRedisTemplate stringRedisTemplate;
@Autowired
private RedisUtil redisUtil;
private static final String SQL_INSERT_GOODS_BUY_ROSTER_LOG = "INSERT INTO goblin_goods_buy_roster_log (sku_id,buy_roster,buy_roster_type,parsing_result,created_at)VALUES(?,?,?,?,?)";
@Override
public void onMessage(MapRecord<String, String, String> message) {
log.debug("CONSUMER XLS [streamKey:{},messageId:{},stream:{},body:{}]",
......@@ -45,30 +53,40 @@ public abstract class AbstractXlsRedisReceiver implements StreamListener<String,
}
private boolean consumerSqlDaoHandler(String xlsPath, Integer type, String skuId) {
LinkedList<Object[]> objs = CollectionUtil.linkedListObjectArr();
Boolean aBoolean = false;
try {
URL url = new URL(xlsPath);
InputStream is = url.openStream();
EasyExcel.read(is, PhoneDto.class, new PageReadListener<PhoneDto>(dataList -> {
for (PhoneDto data : dataList) {
if(data.getMobile()==null){
if (data.getMobile() == null) {
continue;
}
String redisKey = GoblinRedisConst.REDIS_CAN_BUY.concat(skuId + ":").concat(data.getMobile());
if (type.equals(1)) {//添加
log.debug("添加 读取到一条数据{}", JSON.toJSONString(data));
if (log.isDebugEnabled()) {
log.debug("添加 读取到一条数据{}", JSON.toJSONString(data));
}
redisUtil.set(redisKey, 0);
} else {
log.debug("删除 读取到一条数据{}", JSON.toJSONString(data));
if (log.isDebugEnabled()) {
log.debug("删除 读取到一条数据{}", JSON.toJSONString(data));
}
redisUtil.del(redisKey);
}
}
})).sheet().doRead();
objs.add(new Object[]{skuId, xlsPath, type, 1, LocalDateTime.now()});
} catch (Exception e) {
objs.add(new Object[]{skuId, xlsPath, type, 2, LocalDateTime.now()});
aBoolean = false;
log.error("CONSUMER XLS FAIL ==> {}", e.getMessage(), e);
e.printStackTrace();
} finally {
try {
baseDao.batchSql(SQL_INSERT_GOODS_BUY_ROSTER_LOG, objs);
} catch (Exception e) {
}
// if (!aBoolean) {
// HashMap<String, String> map = CollectionUtil.mapStringString();
// map.put("message", xlsPath);
......
......@@ -368,6 +368,19 @@ create table goblin_goods_sku
create index idx_ggs_spu_id on goblin_goods_sku (spu_id);
create index idx_ggs_store_id on goblin_goods_sku (store_id);
# -- >>------------------------------------------------------------------------------------
drop table if exists goblin_goods_buy_roster_log;
create table goblin_goods_buy_roster_log
(
mid bigint auto_increment primary key,
sku_id varchar(64) not null comment '对应 goblin_goods_sku.sku_id',
buy_roster varchar(30) not null comment '限购名单',
buy_roster_type tinyint null comment '删除标记[1-添加|2-删除]',
parsing_result varchar(30) null comment '解析结果[1-成功|2-失败]',
operator varchar(64) null,
created_at datetime not null,
comment varchar(255)
) engine = InnoDB comment '商品限购名单处理记录';
# -- >>------------------------------------------------------------------------------------
drop table if exists goblin_goods_spu_spec_value;
create table goblin_goods_spu_spec_value
(
......
......@@ -126,8 +126,8 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi
int skuSize = goodsSkuInfoVoList.size();
for (int i = 0; i < skuSize; i++) {
GoblinGoodsSkuInfoVo skuInfoVo = goodsSkuInfoVoList.get(i);
String skuId = skuInfoVo.getSkuId();
String buyRoster = skuInfoVo.getBuyRoster();
goblinRedisUtils.setSkuStock(null, skuId, skuInfoVo.getSkuStock());
......@@ -135,7 +135,7 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi
skuId, skuInfoVo.getSpuId(), skuInfoVo.getSkuNo(), skuInfoVo.getName(), skuInfoVo.getSubtitle(),
skuInfoVo.getSellPrice(), skuInfoVo.getSkuPic(), skuInfoVo.getSkuIsbn(), skuInfoVo.getStock(), skuInfoVo.getSkuStock(),
skuInfoVo.getWarningStock(), skuInfoVo.getPrice(), skuInfoVo.getPriceMember(), skuInfoVo.getWeight(), skuInfoVo.getBuyFactor(),
skuInfoVo.getBuyRoster(), skuInfoVo.getBuyLimit(), skuInfoVo.getStoreId(), skuInfoVo.getSkuValidity(), skuInfoVo.getVirtualFlg(),
buyRoster, skuInfoVo.getBuyLimit(), skuInfoVo.getStoreId(), skuInfoVo.getSkuValidity(), skuInfoVo.getVirtualFlg(),
skuInfoVo.getStatus(), skuInfoVo.getShelvesStatus(), skuInfoVo.getSkuAppear(), skuInfoVo.getShelvesAt(), createdBy,
createdAt, skuInfoVo.getLogisticsTemplate()
});
......@@ -143,6 +143,9 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi
skuInfoVo.getSkuSpecList().forEach(skuSpecDto -> initGoodsSkuSpecValueObjs.add(new Object[]{
spuId, skuId, skuSpecDto.getSpecName(), skuSpecDto.getSpecVname()
}));
if (skuInfoVo.getBuyFactor().equals("2") && StringUtils.isNotBlank(buyRoster) && buyRoster.startsWith("http")) {
queueUtils.sendMsgByRedisXls(buyRoster, "1", skuId);
}
}
LinkedList<String> toMqSqls = CollectionUtil.linkedListString();
......@@ -158,14 +161,6 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi
goodsInfoVo.getLogisticsTemplate()
});
toMqSqls.add(SqlMapping.get("goblin_goods_sku.insert"));
// goodsSkuInfoVoList.forEach(skuInfoVo -> initGoodsSkuObjs.add(new Object[]{
// skuInfoVo.getSkuId(), skuInfoVo.getSpuId(), skuInfoVo.getSkuNo(), skuInfoVo.getName(), skuInfoVo.getSubtitle(),
// skuInfoVo.getSellPrice(), skuInfoVo.getSkuPic(), skuInfoVo.getSkuIsbn(), skuInfoVo.getStock(), skuInfoVo.getSkuStock(),
// skuInfoVo.getWarningStock(), skuInfoVo.getPrice(), skuInfoVo.getPriceMember(), skuInfoVo.getWeight(), skuInfoVo.getBuyFactor(),
// skuInfoVo.getBuyRoster(), skuInfoVo.getBuyLimit(), skuInfoVo.getStoreId(), skuInfoVo.getSkuValidity(), skuInfoVo.getVirtualFlg(),
// skuInfoVo.getStatus(), skuInfoVo.getShelvesStatus(), skuInfoVo.getSkuAppear(), skuInfoVo.getShelvesAt(), skuInfoVo.getCreatedBy(),
// skuInfoVo.getCreatedAt(), skuInfoVo.getLogisticsTemplate()
// }));
toMqSqls.add(SqlMapping.get("goblin_goods_image.insert"));
LinkedList<Object[]> initGoodsImageObjs = CollectionUtil.linkedListObjectArr();
if (CollectionUtils.isEmpty(goodsInfoVo.getImageList())) {
......@@ -208,11 +203,6 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi
initGoodsTagObjs, initGoodsServiceSupportObjs, initGoodsSpecObjs, initGoodsSpecValueObjs,
initGoodsSpuSpecValueObjs, initGoodsSkuSpecValueObjs, initGoodsCategorySpecObjs)
);
// queueUtils.sendMsgByRedis(MQConst.GoblinQueue.SQL_GOODS.getKey(),
// SqlMapping.gets(toMqSqls, initGoodsObjs, initGoodsSkuObjs, initGoodsImageObjs,
// initGoodsTagObjs, initGoodsServiceSupportObjs)
// );
}
@Override
......@@ -535,6 +525,10 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi
updateGoodsObjs.add(new Object[]{priceGe, priceLe, uid, now, spuId});
}
String buyRoster = storeMgtGoodsEditSkuParam.getBuyRoster();
if (storeMgtGoodsEditSkuParam.getBuyFactor().equals("2") && StringUtils.isNotBlank(buyRoster) && buyRoster.startsWith("http")) {
queueUtils.sendMsgByRedisXls(buyRoster, storeMgtGoodsEditSkuParam.getBuyRosterType(), skuId);
}
LinkedList<String> toMqSqls = CollectionUtil.linkedListString();
toMqSqls.add(SqlMapping.get("goblin_goods_sku.update_by_edit_for_market"));
......
......@@ -48,7 +48,7 @@ public class QueueUtils {
* @param skuId skuId
*/
public void sendMsgByRedisXls(String xlsPath, String type, String skuId) {
if (xlsPath.equals("") || xlsPath == null || type.equals("") || type == null || skuId.equals("") || skuId == null) {
if (xlsPath == null || xlsPath.equals("") || type == null || type.equals("") || skuId == null || skuId.equals("")) {
} else {
HashMap<String, String> map = CollectionUtil.mapStringString();
......
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