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

Commit 6059b44e authored by 胡佳晨's avatar 胡佳晨

Merge remote-tracking branch 'origin/dev_goblin' into dev_goblin

parents 20968b25 19edf425
......@@ -18,6 +18,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
......@@ -43,6 +44,7 @@ public class GoblinStoreMgtGoodsAddParam implements Serializable {
**/
@ApiModelProperty(position = 12, required = true, value = "商品名称[128]")
@NotBlank(message = "商品名称不能为空")
private String name;
@ApiModelProperty(position = 13, required = false, value = "商品名称[128]")
private String subtitle;
......@@ -50,6 +52,7 @@ public class GoblinStoreMgtGoodsAddParam implements Serializable {
private BigDecimal sellPrice;
@ApiModelProperty(position = 15, required = true, value = "商品一级分类ID[30]")
@NotBlank(message = "商品分类ID不能为空")
private String cateFid;
@ApiModelProperty(position = 16, required = true, value = "商品二级分类ID[30]")
private String cateSid;
......@@ -219,11 +222,6 @@ public class GoblinStoreMgtGoodsAddParam implements Serializable {
public void initGoodsSkuInfoVo(GoblinGoodsInfoVo goodsInfoVo, List<GoblinGoodsSkuInfoVo> vos,
List<GoblinGoodsSpecVo> goodsSpecVos) {
List<GoblinStoreMgtGoodsAddSkuParam> mgtGoodsAddSkuParamList = this.getSkuParamList();
if (CollectionUtils.isEmpty(mgtGoodsAddSkuParamList)) {
ErrorMapping.ErrorMessage errorMessage = ErrorMapping.get("149006");
throw new LiquidnetServiceException(errorMessage.getCode(), errorMessage.getMessage());
}
List<String> skuIdList = CollectionUtil.arrayListString();
BigDecimal priceGe = BigDecimal.ZERO, priceLe = BigDecimal.ZERO;
int size = mgtGoodsAddSkuParamList.size(), skuSpecSize = 0;
......@@ -304,8 +302,8 @@ public class GoblinStoreMgtGoodsAddParam implements Serializable {
List<String> skuSpecNListTmp = CollectionUtil.arrayListString();// 标记单个SKU的规格名称,用于校验
for (int j = 0; j < specSize; j++) {
GoblinGoodsSpecDto specDto = skuSpecList.get(j);
String specName = specDto.getSpecName();
String specVname = specDto.getSpecVname();
String specName = specDto.getSpecName().trim();
String specVname = specDto.getSpecVname().trim();
skuname = skuname.concat(specVname);
GoblinGoodsSpecValueVo specValueVo = GoblinGoodsSpecValueVo.getNew().setSpecVname(specVname).setSpecVsort(i);
......
......@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@ApiModel(value = "GoblinMgtCategorySpecVo", description = "分类关联的规格信息")
@Data
......@@ -12,12 +13,18 @@ public class GoblinMgtCategorySpecVo implements Serializable, Cloneable {
private static final long serialVersionUID = -1807588898644126000L;
@ApiModelProperty(position = 11, value = "分类ID")
private String cateId;
@ApiModelProperty(position = 12, value = "规格ID")
private String specId;
@ApiModelProperty(position = 13, value = "规格名称")
private String specName;
@ApiModelProperty(position = 14, value = "删除标记[0-未删除|1-删除")
private String delFlg;
@ApiModelProperty(position = 13, value = "规格名称List")
private List<String> specNameList;
public GoblinMgtCategorySpecVo setCateId(String cateId) {
this.cateId = cateId;
return this;
}
public GoblinMgtCategorySpecVo setSpecNameList(List<String> specNameList) {
this.specNameList = specNameList;
return this;
}
private static final GoblinMgtCategorySpecVo obj = new GoblinMgtCategorySpecVo();
public static GoblinMgtCategorySpecVo getNew() {
......
......@@ -110,51 +110,39 @@
// width: '80'
// },
{
field: 'bindType',
field: 'price',
title: '原价',
width: '100',
align: 'center',
formatter: function(value, row, index) {
return '299999999'
}
align: 'center'
},
{
field: 'bindType',
title: '其他活动占用库存',
width: '120',
align: 'center',
formatter: function(value, row, index) {
return '2021'
}
align: 'center'
},
{
field: 'bindType',
// title: `线下售价<a onclick="setPrice(1)">批量</a>`,
title: `线下售价`,
width: '150',
align: 'center',
formatter: function(value, row, index) {
return `<input id="price${index}" class='form-control' type='text' name='' value=''>`
}
align: 'center'
},
{
field: 'bindType',
field: 'buyLimit',
// title: '库存限量<a onclick="setPrice(2)">批量</a>',
title: '库存限量',
width: '150',
align: 'center',
formatter: function(value, row, index) {
return `<input id="goodsNum${index}" class='form-control' type='text' name='' value=''>`
}
align: 'center'
},
{
field: 'bindType',
field: 'buyRoster',
// title: '用户限购<a onclick="setPrice(3)">批量</a>',
title: '用户限购',
width: '150',
align: 'center',
formatter: function(value, row, index) {
return `<input id="purchasing${index}" class='form-control' type='text' name='' value=''>`
formatter: function (value, row) {
}
},
{
......@@ -180,10 +168,7 @@
let obj = {
field: '',
title: '',
align: 'center',
formatter: function(value, row) {
return '七彩湛蓝色'
}
align: 'center'
}
columnsData.forEach((item,index) => {
obj.field = 'specVname'+index+'';
......@@ -193,7 +178,7 @@
}
datas = data.map(item => {
item.skuSpecList.forEach((d,i) => [
item['specVname'+i+''] = d.specName
item['specVname'+i+''] = d.specVname
])
return item
})
......@@ -216,6 +201,7 @@
data: datas,
columns: column
};
console.log(options)
$.table.init(options);
}
......
......@@ -380,7 +380,7 @@ create table goblin_goods_spu_spec_value
comment varchar(255)
) engine = InnoDB comment '商品关联规格值';
create index idx_ggssv_spu_id on goblin_goods_spu_spec_value (spu_id);
create unique index uidx_ggssv_spu_s_s on goblin_goods_spu_spec_value (spu_id, spec_name, spec_vname);
# -- >>------------------------------------------------------------------------------------
drop table if exists goblin_goods_sku_spec_value;
create table goblin_goods_sku_spec_value
......@@ -395,7 +395,7 @@ create table goblin_goods_sku_spec_value
comment varchar(255)
) engine = InnoDB comment '单品关联规格值';
create index idx_ggssv_sku_id on goblin_goods_sku_spec_value (sku_id);
create unique index uidx_ggssv_s_s_s on goblin_goods_sku_spec_value (sku_id, spec_name, spec_vname);
# -- >>------------------------------------------------------------------------------------
# -- >>------------------------------------------------------------------------------------
drop table if exists goblin_goods_spec_value;
......
......@@ -43,9 +43,9 @@ public class GoblinFrontLoginController {
@GetMapping("getShopCartCount")
@ApiOperation("获取购物车数量")
public ResponseDto getShopCartCount() {
public ResponseDto getShopCartCount(@RequestParam(name = "type", required = false)Integer type) {
String userId=CurrentUtil.getCurrentUid();
return ResponseDto.success(goblinFrontService.getShopCartCount(userId));
return ResponseDto.success(goblinFrontService.getShopCartCount(userId,type));
}
@PostMapping("deleteShopCart")
@ApiOperation("删除购物车")
......@@ -69,9 +69,9 @@ public class GoblinFrontLoginController {
@GetMapping("getShopCart")
@ApiOperation("获得购物车列表")
public ResponseDto<GoblinShoppingCartVoo> getShopCart() {
public ResponseDto<GoblinShoppingCartVoo> getShopCart(@RequestParam(name = "type", required = false)Integer type) {
String userId=CurrentUtil.getCurrentUid();
return ResponseDto.success(goblinFrontService.getShoppCart(userId));
return ResponseDto.success(goblinFrontService.getShoppCart(userId,type));
}
......
......@@ -64,9 +64,9 @@ public class GoblinStoreMgtExtraController {
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "cateId", value = "分类ID"),
})
@GetMapping("sg_catespecs")
public ResponseDto<List<GoblinMgtCategorySpecVo>> categorySpecList(@RequestParam String cateId) {
public ResponseDto<GoblinMgtCategorySpecVo> categorySpecList(@RequestParam String cateId) {
if (StringUtils.isBlank(cateId)) return ResponseDto.success();
return ResponseDto.success(goblinMongoUtils.getCategorySpecVos(cateId));
return ResponseDto.success(goblinMongoUtils.getCategorySpecVo(cateId));
}
@ApiOperationSupport(order = 3)
......
......@@ -131,7 +131,9 @@ public class GoblinStoreMgtGoodsController {
if (log.isDebugEnabled()) {
log.debug("商品管理:SPU添加:[GoblinStoreMgtGoodsAddParam={}]", JsonUtils.toJson(storeMgtGoodsAddParam));
}
if (CollectionUtils.isEmpty(storeMgtGoodsAddParam.getSkuParamList())) {
return ResponseDto.failure(ErrorMapping.get("149006"));
}
LocalDateTime now = LocalDateTime.now();
GoblinGoodsInfoVo goodsInfoVo = storeMgtGoodsAddParam.initGoodsInfoVo();
goodsInfoVo.setCreatedBy(currentUid);
......@@ -170,6 +172,7 @@ public class GoblinStoreMgtGoodsController {
goodsInfoVo.setServiceSupportVoList(goblinMongoUtils.getServiceSupportVos(storeMgtGoodsAddParam.getSsidList()));
goblinstoreMgtGoodsService.goodsAdd(goodsInfoVo, goodsSkuInfoVoList);
return ResponseDto.success(goodsInfoVo.getSpuId());
}
......
......@@ -714,10 +714,10 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
return true;
}
public int getShopCartCount(String userId){
public int getShopCartCount(String userId,Integer type){
log.info("获取商品数量{}",userId);
int count=0;
GoblinShoppingCartVoo goblinShoppingCartVoo= (GoblinShoppingCartVoo) redisUtil.get(GoblinRedisConst.FRONT_SHOPCART.concat(userId));
GoblinShoppingCartVoo goblinShoppingCartVoo= (GoblinShoppingCartVoo) redisUtil.get(GoblinRedisConst.FRONT_SHOPCART.concat(userId).concat(type.toString()));
if(null!=goblinShoppingCartVoo){
List<GoblinShoppingCartVo> shopList=goblinShoppingCartVoo.getShopList();
for(GoblinShoppingCartVo goblinShoppingCartVo:shopList){
......@@ -772,7 +772,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
}
}
if(shopList.size()==0){
deleteRedisMongodbMysqlShop(goblinShoppingCartVoo,userId,skuIds);
deleteRedisMongodbMysqlShop(goblinShoppingCartVoo,userId,skuIds,type);
deleteMysql(userId,skuIds);
}else{
saveRedisMongodbMysqlShop(goblinShoppingCartVoo,userId,type);
......@@ -794,9 +794,9 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
* @Description: 获得购物车列表
* @date 2022/1/12 下午2:36
*/
public GoblinShoppingCartVoo getShoppCart(String userId){
public GoblinShoppingCartVoo getShoppCart(String userId,Integer type){
//判断该用户 redis里是否有购物车
GoblinShoppingCartVoo goblinShoppingCartVoo= (GoblinShoppingCartVoo) redisUtil.get(GoblinRedisConst.FRONT_SHOPCART.concat(userId));
GoblinShoppingCartVoo goblinShoppingCartVoo= (GoblinShoppingCartVoo) redisUtil.get(GoblinRedisConst.FRONT_SHOPCART.concat(userId).concat(type.toString()));
if(null==goblinShoppingCartVoo){
return null;
}
......@@ -811,7 +811,7 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
goblinShoppingCartVoDetail.setGoblinGoodsSkuInfoVo(goblinGoodsSkuInfoVo);
}
}
goblinShoppingCartVoo.setShoopingCount(this.getShopCartCount(userId));
goblinShoppingCartVoo.setShoopingCount(this.getShopCartCount(userId,type));
return goblinShoppingCartVoo;
}
public GoblinShoppingCartVoDetail setValue(String userId,String storeId,String spuId,String skuId,Integer number){
......@@ -846,9 +846,9 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
//mysql 消息队列
}
//删除redis 删除mongodb
public void deleteRedisMongodbMysqlShop(GoblinShoppingCartVoo goblinShoppingCartVoo,String userId,String[] skuIds){
public void deleteRedisMongodbMysqlShop(GoblinShoppingCartVoo goblinShoppingCartVoo,String userId,String[] skuIds,Integer type){
//redis存储
redisUtil.del(GoblinRedisConst.FRONT_SHOPCART.concat(userId));
redisUtil.del(GoblinRedisConst.FRONT_SHOPCART.concat(userId).concat(type.toString()));
//mongodb 删除
mongoTemplate.remove(Query.query(Criteria.where("goblinShoppingCartId").is(goblinShoppingCartVoo.getGoblinShoppingCartId())), GoblinShoppingCartVoo.class, GoblinShoppingCartVoo.class.getSimpleName());
//mysql 删除 按照 userid 、skuid
......
......@@ -52,11 +52,36 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi
goblinMongoUtils.setGoodsInfoVo(goodsInfoVo);
goblinMongoUtils.setGoodsSkuInfoVos(goodsSkuInfoVoList);
// TODO: 2022/1/18 zhanggb==
goodsSkuInfoVoList.forEach(r -> goblinRedisUtils.setSkuStock(null, r.getSkuId(), r.getSkuStock()));
String createdBy = goodsInfoVo.getCreatedBy();
LocalDateTime createdAt = goodsInfoVo.getCreatedAt();
String spuId = goodsInfoVo.getSpuId();
LinkedList<Object[]> initGoodsSkuObjs = CollectionUtil.linkedListObjectArr();
LinkedList<Object[]> initGoodsSkuSpecValueObjs = CollectionUtil.linkedListObjectArr();
// TODO: 2022/1/18 zhanggb==
int skuSize = goodsSkuInfoVoList.size();
for (int i = 0; i < skuSize; i++) {
GoblinGoodsSkuInfoVo skuInfoVo = goodsSkuInfoVoList.get(i);
String skuId = skuInfoVo.getSkuId();
goblinRedisUtils.setSkuStock(null, skuId, skuInfoVo.getSkuStock());
initGoodsSkuObjs.add(new Object[]{
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(),
skuInfoVo.getStatus(), skuInfoVo.getShelvesStatus(), skuInfoVo.getSkuAppear(), skuInfoVo.getShelvesAt(), skuInfoVo.getCreatedBy(),
skuInfoVo.getCreatedAt(), skuInfoVo.getLogisticsTemplate()
});
skuInfoVo.getSkuSpecList().forEach(skuSpecDto -> initGoodsSkuSpecValueObjs.add(new Object[]{
spuId, skuId, skuSpecDto.getSpecName(), skuSpecDto.getSpecVname()
}));
}
LinkedList<String> toMqSqls = CollectionUtil.linkedListString();
toMqSqls.add(SqlMapping.get("goblin_goods.insert"));
LinkedList<Object[]> initGoodsObjs = CollectionUtil.linkedListObjectArr();
......@@ -66,19 +91,18 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi
goodsInfoVo.getVideo(), goodsInfoVo.getSpecMode(), goodsInfoVo.getStoreId(), goodsInfoVo.getCateFid(), goodsInfoVo.getCateSid(),
goodsInfoVo.getCateTid(), goodsInfoVo.getStoreCateFid(), goodsInfoVo.getStoreCateSid(), goodsInfoVo.getStoreCateTid(), goodsInfoVo.getBrandId(),
goodsInfoVo.getShelvesHandle(), goodsInfoVo.getShelvesTime(), goodsInfoVo.getSpuValidity(), goodsInfoVo.getVirtualFlg(), goodsInfoVo.getStatus(),
goodsInfoVo.getShelvesStatus(), goodsInfoVo.getSpuAppear(), goodsInfoVo.getShelvesAt(), goodsInfoVo.getCreatedBy(), goodsInfoVo.getCreatedAt(),
goodsInfoVo.getShelvesStatus(), goodsInfoVo.getSpuAppear(), goodsInfoVo.getShelvesAt(), goodsInfoVo.getCreatedBy(), createdAt,
goodsInfoVo.getLogisticsTemplate()
});
toMqSqls.add(SqlMapping.get("goblin_goods_sku.insert"));
LinkedList<Object[]> initGoodsSkuObjs = CollectionUtil.linkedListObjectArr();
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()
}));
// 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())) {
......@@ -97,22 +121,50 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi
if (!CollectionUtils.isEmpty(goodsInfoVo.getServiceSupportVoList())) {
goodsInfoVo.getServiceSupportVoList().forEach(ssvo -> initGoodsServiceSupportObjs.add(new Object[]{spuId, ssvo.getSsid()}));
}
{// 规格记录
List<GoblinGoodsSpecVo> specVoList = goodsInfoVo.getSpecVoList();
String cateFid = goodsInfoVo.getCateFid();
String cateSid = goodsInfoVo.getCateSid();
String cateTid = goodsInfoVo.getCateTid();
String filterCateId = StringUtils.isBlank(cateTid) ? (StringUtils.isBlank(cateSid) ? cateFid : cateSid) : cateTid;
List<GoblinMgtCategorySpecVo> categorySpecVoList = goblinMongoUtils.getCategorySpecVos(filterCateId);
if (CollectionUtils.isEmpty(categorySpecVoList)) {// 根据分类ID未查取到规格信息,则新增
} else {// 根据分类ID查取到规格信息,则进一步比对判断是否新增
}
}
// toMqSqls.add(SqlMapping.get("goblin_goods_spec.insert_by_ignore"));
// toMqSqls.add(SqlMapping.get("goblin_goods_spec_value.insert_by_ignore"));
// LinkedList<Object[]> initGoodsSpecObjs = CollectionUtil.linkedListObjectArr();
// LinkedList<Object[]> initGoodsSpecValueObjs = CollectionUtil.linkedListObjectArr();
// toMqSqls.add(SqlMapping.get("goblin_goods_spu_spec_value.insert_by_ignore"));// SPU规格信息
// LinkedList<Object[]> initGoodsSpuSpecValueObjs = CollectionUtil.linkedListObjectArr();
// toMqSqls.add(SqlMapping.get("goblin_goods_sku_spec_value.insert_by_ignore"));// SKU规格信息
// {// 规格记录
// List<GoblinGoodsSpecVo> specVoList = goodsInfoVo.getSpecVoList();
// specVoList.forEach(s -> {
// initGoodsSpecObjs.add(new Object[]{s.getSpecName(), createdAt});
// s.getSpecValues().forEach(sv -> {
// initGoodsSpecValueObjs.add(new Object[]{s.getSpecName(), sv.getSpecVname(), createdAt});
// initGoodsSpuSpecValueObjs.add(new Object[]{spuId, s.getSpecName(), sv.getSpecVname(), sv.getSpecVsort()});
// });
// });
// }
// {// 分类规格记录
// String cateFid = goodsInfoVo.getCateFid(), cateSid = goodsInfoVo.getCateSid(), cateTid = goodsInfoVo.getCateTid();
// String filterCateId = StringUtils.isBlank(cateTid) ? (StringUtils.isBlank(cateSid) ? cateFid : cateSid) : cateTid;
// GoblinMgtCategorySpecVo mgtCategorySpecVoCache = goblinRedisUtils.getCategorySpec(filterCateId);// 分类绑定的规格信息
// List<String> addSpecNameList = goodsSkuInfoVoList.get(0).getSkuSpecList().stream().map(GoblinGoodsSpecDto::getSpecName).collect(Collectors.toList());
// if (null == mgtCategorySpecVoCache) {// 根据分类ID未查取到规格信息,则新增
// GoblinMgtCategorySpecVo initMgtCategorySpecVo = GoblinMgtCategorySpecVo.getNew().setCateId(filterCateId).setSpecNameList(addSpecNameList);
// // TODO: 2022/1/18 zhanggb==insert
// } else {// 根据分类ID查取到规格信息,则进一步比对判断是否新增
// List<String> confirmAddSpecNameList = addSpecNameList.stream().filter(r -> !mgtCategorySpecVoCache.getSpecNameList().contains(r)).collect(Collectors.toList());
// if (!CollectionUtils.isEmpty(confirmAddSpecNameList)) {// 不存在于`mgtCategorySpecVoCache`的,则更新
// mgtCategorySpecVoCache.getSpecNameList().addAll(confirmAddSpecNameList);
// // TODO: 2022/1/18 zhanggb==update
// }
// }
// }
//
// queueUtils.sendMsgByRedis(MQConst.GoblinQueue.SQL_GOODS.getKey(),
// SqlMapping.gets(toMqSqls, initGoodsObjs, initGoodsSkuObjs, initGoodsImageObjs,
// initGoodsTagObjs, initGoodsServiceSupportObjs, initGoodsSpecObjs, initGoodsSpecValueObjs,
// initGoodsSpecObjs, initGoodsSpecValueObjs, initGoodsSpuSpecValueObjs, initGoodsSkuSpecValueObjs)
// );
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.SQL_GOODS.getKey(),
SqlMapping.gets(toMqSqls, initGoodsObjs, initGoodsSkuObjs, initGoodsImageObjs, initGoodsTagObjs, initGoodsServiceSupportObjs));
SqlMapping.gets(toMqSqls, initGoodsObjs, initGoodsSkuObjs, initGoodsImageObjs,
initGoodsTagObjs, initGoodsServiceSupportObjs)
);
}
@Override
......
......@@ -48,8 +48,7 @@ public class GoblinMongoUtils {
/* ---------------------------------------- 平台分类数据源 ---------------------------------------- */
public List<GoblinSelfGoodsCategoryVo> getSelfGoodsCategoryVos() {
return mongoTemplate.find(Query.query(Criteria.where("delFlg").is("0")),
GoblinSelfGoodsCategoryVo.class, GoblinSelfGoodsCategoryVo.class.getSimpleName());
return mongoTemplate.findAll(GoblinSelfGoodsCategoryVo.class, GoblinSelfGoodsCategoryVo.class.getSimpleName());
}
/* ---------------------------------------- 店铺分类数据源 ---------------------------------------- */
......@@ -72,8 +71,8 @@ public class GoblinMongoUtils {
/* ---------------------------------------- 平台分类规格数据源 ---------------------------------------- */
public List<GoblinMgtCategorySpecVo> getCategorySpecVos(String cateId) {
return mongoTemplate.find(Query.query(Criteria.where("cateId").is(cateId).and("delFlg").is("0")),
public GoblinMgtCategorySpecVo getCategorySpecVo(String cateId) {
return mongoTemplate.findOne(Query.query(Criteria.where("cateId").is(cateId)),
GoblinMgtCategorySpecVo.class, GoblinMgtCategorySpecVo.class.getSimpleName());
}
......
......@@ -6,6 +6,7 @@ import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.commons.lang.util.RandomUtil;
import com.liquidnet.service.goblin.constant.GoblinRedisConst;
import com.liquidnet.service.goblin.dto.manage.vo.GoblinMgtCategorySpecVo;
import com.liquidnet.service.goblin.dto.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......@@ -138,6 +139,17 @@ public class GoblinRedisUtils {
return vos;
}
/* ---------------------------------------- 平台分类规格数据源 ---------------------------------------- */
public GoblinMgtCategorySpecVo getCategorySpec(String cateId) {
String rk = GoblinRedisConst.BASIC_SELF_GOODS_CATEGORY_SPEC.concat(cateId);
GoblinMgtCategorySpecVo vo = (GoblinMgtCategorySpecVo) redisUtil.get(rk);
if (null == vo && null != (vo = goblinMongoUtils.getCategorySpecVo(cateId))) {
// redisUtil.set(rk, vo);// TODO: 2022/1/18 zhanggb==
}
return vo;
}
/* ---------------------------------------- 服务支持数据源 ---------------------------------------- */
public List<GoblinServiceSupportVo> getServiceSupportVos() {
......
......@@ -20,6 +20,14 @@ goblin_store_notice.remove=UPDATE goblin_store_notice SET del_flg='1',updated_by
goblin_store_goods_category.insert=INSERT INTO goblin_store_goods_category (store_id,cate_id,name,sort,grade,cate_pid,ne_isbn,created_by,created_at)VALUES(?,?,?,?,?,?,?,?,?)
goblin_store_goods_category.update=UPDATE goblin_store_goods_category SET name=?,sort=?,updated_by=?,updated_at=? WHERE store_id=? AND cate_id=?
goblin_store_goods_category.remove=UPDATE goblin_store_goods_category SET del_flg='1',updated_by=?,updated_at=?,deleted_by=?,updated_at=? WHERE store_id=? AND cate_id=?
#---- 商品分类规格信息
#---- 商品规格信息
goblin_goods_spec.insert_by_ignore=INSERT IGNORE INTO goblin_goods_spec (spec_name,created_by,created_at)VALUES(?,'-',?)
goblin_goods_spec_value.insert_by_ignore=INSERT IGNORE INTO goblin_goods_spec_value (spec_name,spec_vname,created_by,created_at)VALUES(?,?,'-',?)
#---- 商品关联规格信息
goblin_goods_spu_spec_value.insert_by_ignore=INSERT IGNORE INTO goblin_goods_spu_spec_value (spu_id,spec_name,spec_vname,sort)VALUES(?,?,?,?)
goblin_goods_sku_spec_value.insert_by_ignore=INSERT IGNORE INTO goblin_goods_sku_spec_value (spu_id,sku_id,spec_name,spec_vname)VALUES(?,?,?,?)
#---- 商品信息
goblin_goods.insert=INSERT INTO goblin_goods (spu_id,spu_no,name,subtitle,sell_price, price_ge,price_le,intro,details,cover_pic, video,spec_mode,store_id,cate_fid,cate_sid, cate_tid,store_cate_fid,store_cate_sid,store_cate_tid,brand_id, shelves_handle,shelves_time,spu_validity,virtual_flg,status, shelves_status,spu_appear,shelves_at,created_by,created_at, logistics_template)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
goblin_goods.update_by_shelves=UPDATE goblin_goods SET shelves_status=?,shelves_at=?,updated_by=?,updated_at=? WHERE spu_id=? AND store_id=? AND spu_appear='0'
......
package com.liquidnet.service.platform.controller.goblin;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.platform.service.impl.goblin.SpuGoodsInfoImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 订单 前端控制器
* </p>
*
* @author liquidnet
* @since 2021-05-20
*/
@Api(tags = "商城-spu相关")
@RestController
@RequestMapping("spu/goblin")
@Validated
public class GoblinSpuController {
@Autowired
SpuGoodsInfoImpl spuGoodsInfo;
@PostMapping("setCount")
@ApiOperation("spu数量")
@ApiResponse(code = 200, message = "接口返回对象参数")
public ResponseDto<Boolean> checkOrderTime() {
return ResponseDto.success(spuGoodsInfo.setCount());
}
}
package com.liquidnet.service.platform.service.impl.goblin;
import com.liquidnet.service.goblin.dto.vo.GoblinGoodsInfoVo;
import com.liquidnet.service.platform.utils.GoblinRedisUtils;
import com.liquidnet.service.platform.utils.QueueUtils;
import com.mongodb.BasicDBObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.convert.MongoConverter;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 订单 服务实现类
* </p>
*
* @author liquidnet
* @since 2021-05-20
*/
@Service
@Slf4j
public class SpuGoodsInfoImpl {
@Autowired
private GoblinRedisUtils goblinRedisUtils;
@Autowired
private MongoTemplate mongoTemplate;
@Autowired
private MongoConverter mongoConverter;
@Autowired
private QueueUtils queueUtils;
/**
* 设置商品数量
*/
public boolean setCount(){
//mongoTemplate.findOne(Query.query(Criteria.where("spuId").is(spuId).and("delFlg").is("0").and("shelvesStatus").is("3")),
// GoblinGoodsInfoVo.class, GoblinGoodsInfoVo.class.getSimpleName()); shelvesStatus
List<GoblinGoodsInfoVo> voList = mongoTemplate.find(Query.query(Criteria.where("delFlg").is("0").and("shelvesStatus").is("3")),
GoblinGoodsInfoVo.class, GoblinGoodsInfoVo.class.getSimpleName());
for(GoblinGoodsInfoVo goblinGoodsInfoVo:voList){
//查询数量
Integer counts=goblinRedisUtils.getSpuSaleCount(goblinGoodsInfoVo.getSpuId());
if(counts==null){
goblinGoodsInfoVo.setCount(0);
}else{
goblinGoodsInfoVo.setCount(counts);
}
//修改mongodb
BasicDBObject obj = new BasicDBObject("$set", mongoConverter.convertToMongoType(goblinGoodsInfoVo));
mongoTemplate.getCollection(GoblinGoodsInfoVo.class.getSimpleName()).updateOne(
Query.query(Criteria.where("spuId").is(goblinGoodsInfoVo.getSpuId())).getQueryObject(),
obj);
}
log.info("执行完毕");
return true;
}
}
......@@ -42,6 +42,16 @@ public class GoblinRedisUtils {
return (GoblinOrderSkuVo) obj;
}
}
//获取 spu销量
public Integer getSpuSaleCount(String spuId) {
String redisKey = GoblinRedisConst.REDIS_GOBLIN_SALE_SPU_COUNT.concat(spuId);
Object obj = getRedis().get(redisKey);
if (obj == null) {
return null;
} else {
return (Integer) obj;
}
}
//获取 未支付的订单redis列表
public List<String> getUnPayGoblinOrderList(String randomKey) {
......
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