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

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

~API;

parent 8faec223
package com.liquidnet.service.goblin.dto.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@ApiModel(value = "GoblinSelfGoodsCategoryVo", description = "平台分类信息")
@Data
public class GoblinSelfGoodsCategoryVo implements Serializable, Cloneable {
private static final long serialVersionUID = -2342407105969740471L;
@ApiModelProperty(position = 10, value = "分类ID")
private String cateId;
@ApiModelProperty(position = 11, value = "分类名称")
private String name;
@ApiModelProperty(position = 12, value = "分类图标")
private String icon;
@ApiModelProperty(position = 13, value = "排序[数值越小,排序越前]")
private Integer sort;
@ApiModelProperty(position = 14, value = "分类层级[1-一级|2-二级|3-三级]")
private String grade;
@ApiModelProperty(position = 15, value = "分类父ID")
private String catePid;
@ApiModelProperty(position = 16, value = "是否需要填写ISBN[0-否|1-是]")
private String neIsbn;
public GoblinSelfGoodsCategoryVo setSort(Integer sort) {
this.sort = sort;
return this;
}
private static final GoblinSelfGoodsCategoryVo obj = new GoblinSelfGoodsCategoryVo();
public static GoblinSelfGoodsCategoryVo getNew() {
try {
return (GoblinSelfGoodsCategoryVo) obj.clone();
} catch (CloneNotSupportedException e) {
return new GoblinSelfGoodsCategoryVo();
}
}
}
......@@ -76,23 +76,19 @@ public interface IGoblinstoreMgtGoodsService {
boolean goodsEditSkuBat(String spuId, String batField, String batFieldVal);
/**
* 商品管理:上架商品
* 商品管理:上架商品
*
* @param storeMgtGoodsActionParam GoblinStoreMgtGoodsActionParam
* @param uid UID
* @param shelvesFlg true:上架|false:下架
*/
void goodsOnshelves(GoblinStoreMgtGoodsActionParam storeMgtGoodsActionParam);
/**
* 商品管理:下架商品
*
* @param storeMgtGoodsActionParam GoblinStoreMgtGoodsActionParam
*/
void goodsUnshelves(GoblinStoreMgtGoodsActionParam storeMgtGoodsActionParam);
void goodsShelvesProcessing(GoblinStoreMgtGoodsActionParam storeMgtGoodsActionParam, String uid, boolean shelvesFlg);
/**
* 商品管理:删除商品
*
* @param storeMgtGoodsActionParam GoblinStoreMgtGoodsActionParam
* @param uid UID
*/
void goodsRemove(GoblinStoreMgtGoodsActionParam storeMgtGoodsActionParam);
void goodsRemove(GoblinStoreMgtGoodsActionParam storeMgtGoodsActionParam, String uid);
}
......@@ -25,7 +25,7 @@ public class GoblinSelfGoodsCategory implements Serializable {
private Long mid;
/**
* 商铺分类id
* 分类id
*/
private String cateId;
......@@ -34,6 +34,11 @@ public class GoblinSelfGoodsCategory implements Serializable {
*/
private String name;
/**
* 分类图标
*/
private String icon;
/**
* 排序[数值越小,排序越前]
*/
......
......@@ -73,6 +73,7 @@ create table goblin_self_goods_category
mid bigint auto_increment primary key,
cate_id varchar(30) not null comment '商铺分类id',
name varchar(50) not null comment '分类名称',
icon varchar(50) null comment '分类图标',
sort int default 0 comment '排序[数值越小,排序越前]',
grade char null comment '分类层级[1-一级|2-二级|3-三级]',
cate_pid varchar(30) null comment '分类父id',
......
......@@ -99,7 +99,8 @@ public class GoblinStoreMgtGoodsController {
@ApiOperation(value = "SPU管理")
@PostMapping("operate")
public ResponseDto<Object> action(@Valid @RequestBody GoblinStoreMgtGoodsActionParam storeMgtGoodsActionParam) {
if (!goblinRedisUtils.hasStoreId(CurrentUtil.getCurrentUid(), storeMgtGoodsActionParam.getStoreId())) {
String currentUid = CurrentUtil.getCurrentUid();
if (!goblinRedisUtils.hasStoreId(currentUid, storeMgtGoodsActionParam.getStoreId())) {
return ResponseDto.failure(ErrorMapping.get("149002"));
}
if (log.isDebugEnabled()) {
......@@ -109,13 +110,13 @@ public class GoblinStoreMgtGoodsController {
switch (storeMgtGoodsActionParam.getAction()) {
case "ONSHELVES":
goblinstoreMgtGoodsService.goodsOnshelves(storeMgtGoodsActionParam);
goblinstoreMgtGoodsService.goodsShelvesProcessing(storeMgtGoodsActionParam, currentUid, true);
break;
case "UNSHELVE":
goblinstoreMgtGoodsService.goodsUnshelves(storeMgtGoodsActionParam);
goblinstoreMgtGoodsService.goodsShelvesProcessing(storeMgtGoodsActionParam, currentUid, false);
break;
case "REMOVE":
goblinstoreMgtGoodsService.goodsRemove(storeMgtGoodsActionParam);
goblinstoreMgtGoodsService.goodsRemove(storeMgtGoodsActionParam, currentUid);
break;
default:
log.warn("Invalid operation[action={}]", storeMgtGoodsActionParam.getAction());
......
......@@ -231,17 +231,21 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi
}
@Override
public void goodsOnshelves(GoblinStoreMgtGoodsActionParam storeMgtGoodsActionParam) {
// TODO: 2021/12/28 zhanggb
}
public void goodsShelvesProcessing(GoblinStoreMgtGoodsActionParam storeMgtGoodsActionParam, String uid, boolean shelvesFlg) {
LocalDateTime now = LocalDateTime.now();
String storeId = storeMgtGoodsActionParam.getStoreId();
List<String> spuIdList = storeMgtGoodsActionParam.getSpuIdList();
@Override
public void goodsUnshelves(GoblinStoreMgtGoodsActionParam storeMgtGoodsActionParam) {
// TODO: 2021/12/28 zhanggb
goblinMongoUtils.updateGoodsInfoVoByShelves(storeId, spuIdList, shelvesFlg, uid, now);
// TODO: 2022/1/7 zhanggb redis+sql
}
@Override
public void goodsRemove(GoblinStoreMgtGoodsActionParam storeMgtGoodsActionParam) {
// TODO: 2021/12/28 zhanggb
public void goodsRemove(GoblinStoreMgtGoodsActionParam storeMgtGoodsActionParam, String uid) {
LocalDateTime now = LocalDateTime.now();
String storeId = storeMgtGoodsActionParam.getStoreId();
List<String> spuIdList = storeMgtGoodsActionParam.getSpuIdList();
goblinMongoUtils.delGoodsInfoVoBySpuIds(storeId, spuIdList, uid, now);
}
}
......@@ -118,6 +118,14 @@ public class GoblinMongoUtils {
GoblinGoodsInfoVo.class, GoblinGoodsInfoVo.class.getSimpleName()).getDeletedCount() > 0;
}
public boolean delGoodsInfoVoBySpuIds(String storeId, List<String> spuIdList, String uid, LocalDateTime time) {
return mongoTemplate.updateMulti(
Query.query(Criteria.where("store_id").is(storeId).and("spuId").in(spuIdList.toArray())),
Update.update("delFlg", 1).set("updatedBy", uid).set("updatedAt", time).set("deletedBy", uid).set("deletedAt", time),
GoblinGoodsInfoVo.class.getSimpleName()
).getModifiedCount() > 0;
}
public List<String> delGoodsInfoVoByStoreId(String storeId, String uid, LocalDateTime time) {
Query query = Query.query(Criteria.where("storeId").is(storeId).and("shelves_status").is("3"));
query.fields().include("spuId");
......@@ -170,7 +178,7 @@ public class GoblinMongoUtils {
if (null != filterParam.getPriceLe()) {
criteria.andOperator(Criteria.where("priceGe").lte(filterParam.getPriceLe()));
}
Query query = Query.query(criteria);
Query query = Query.query(criteria.and("delFlg").is("0"));
long count = mongoTemplate.count(query, GoblinGoodsInfoVo.class.getSimpleName());
......@@ -206,6 +214,12 @@ public class GoblinMongoUtils {
).getModifiedCount() > 0;
}
public boolean updateGoodsInfoVoByShelves(String storeId, List<String> spuIdList, boolean shelvesFlg, String uid, LocalDateTime time) {
return mongoTemplate.updateMulti(Query.query(Criteria.where("storeId").is(storeId).and("spuId").in(spuIdList.toArray())),
Update.update("shelvesStatus", shelvesFlg ? "3" : "1").set("shelvesAt", time).set("updatedBy", uid).set("updatedAt", time),
GoblinGoodsInfoVo.class.getSimpleName()).getModifiedCount() > 0;
}
// SKU信息
public GoblinGoodsSkuInfoVo setGoodsSkuInfoVo(GoblinGoodsSkuInfoVo vo) {
return mongoTemplate.insert(vo, GoblinGoodsSkuInfoVo.class.getSimpleName());
......
......@@ -63,6 +63,38 @@ public class GoblinRedisUtils {
return (int) redisUtil.decr(rk, stock);
}
/* ---------------------------------------- 其他数据源 ---------------------------------------- */
public List<GoblinSelfGoodsCategoryVo> getSelfGoodsCategoryVos() {
ArrayList<GoblinSelfGoodsCategoryVo> selfGoodsCategoryVoList = ObjectUtil.getGoblinSelfGoodsCategoryVoArrayList();
for (int i = 0; i < 3; i++) {
GoblinSelfGoodsCategoryVo vo = GoblinSelfGoodsCategoryVo.getNew();
vo.setCateId("10000");
vo.setName("分类一级");
vo.setSort(i);
vo.setCatePid("");
vo.setGrade(i + 1 + "");
vo.setNeIsbn("0");
vo.setIcon("https://img.zhengzai.tv/files/2020/08/31/5f4c75095e9bc.png");
if (i == 1) {
vo.setNeIsbn("1");
vo.setCateId("10100");
vo.setName("分类二级");
vo.setCatePid("10001");
vo.setIcon("https://img.zhengzai.tv/files/2020/08/31/5f4c75095e9bc.png");
}
if (i == 2) {
vo.setNeIsbn("0");
vo.setCateId("10101");
vo.setName("分类三级");
vo.setCatePid("10100");
vo.setIcon("https://img.zhengzai.tv/files/2020/08/31/5f4c75095e9bc.png");
}
selfGoodsCategoryVoList.add(vo);
}
return selfGoodsCategoryVoList;
}
/* ---------------------------------------- 店铺数据源 ---------------------------------------- */
private boolean setStoreIds(String uid, List<String> storeIds) {
......@@ -152,6 +184,8 @@ public class GoblinRedisUtils {
GoblinGoodsInfoVo vo = (GoblinGoodsInfoVo) redisUtil.get(rk);
if (null == vo && null != (vo = goblinMongoUtils.getGoodsInfoVo(spuId))) {
// redisUtil.set(rk, vo);// TODO: 2022/1/4 zhanggb:暂不设置
vo = !vo.getDelFlg().equals("0") ? null : vo;
}
return vo;
}
......@@ -184,6 +218,8 @@ public class GoblinRedisUtils {
GoblinGoodsSkuInfoVo vo = (GoblinGoodsSkuInfoVo) redisUtil.get(rk);
if (null == vo && null != (vo = goblinMongoUtils.getGoodsSkuInfoVo(skuId))) {
// redisUtil.set(rk, vo);// TODO: 2022/1/4 zhanggb:暂不设置
vo = !vo.getDelFlg().equals("0") ? null : vo;
}
return vo;
}
......
......@@ -28,6 +28,7 @@ public class ObjectUtil {
private static final ArrayList<GoblinServiceSupportVo> goblinServiceSupportVoArrayList = new ArrayList<>();
private static final ArrayList<GoblinSelfTagVo> goblinSelfTagVoArrayList = new ArrayList<>();
private static final ArrayList<GoblinGoodsTagVo> goblinGoodsTagVoArrayList = new ArrayList<>();
private static final ArrayList<GoblinSelfGoodsCategoryVo> goblinSelfGoodsCategoryVoArrayList = new ArrayList<>();
private static final ArrayList<GoblinGoodsExtagVo> goblinGoodsExtagVoArrayList = new ArrayList<>();
private static final ArrayList<GoblinGoodsSpecDto> goblinGoodsSpecDtoArrayList = new ArrayList<>();
private static final ArrayList<GoblinMarketSpuListVo> goblinMarketSpuListVoArrayList = new ArrayList<>();
......@@ -129,6 +130,10 @@ public class ObjectUtil {
return (ArrayList<GoblinGoodsTagVo>) goblinGoodsTagVoArrayList.clone();
}
public static ArrayList<GoblinSelfGoodsCategoryVo> getGoblinSelfGoodsCategoryVoArrayList() {
return (ArrayList<GoblinSelfGoodsCategoryVo>) goblinSelfGoodsCategoryVoArrayList.clone();
}
public static ArrayList<GoblinGoodsExtagVo> getGoblinGoodsExtagVoArrayList() {
return (ArrayList<GoblinGoodsExtagVo>) goblinGoodsExtagVoArrayList.clone();
}
......
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