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

Commit 43a2c8f8 authored by 胡佳晨's avatar 胡佳晨

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

parents a03f925b de7323c5
......@@ -35,6 +35,7 @@ public class GoblinRedisConst {
public static final String FRONT_FRONT_SECKILL = PREFIX.concat("front_front_seckill"); //前端 首页秒杀
public static final String FRONT_SECKILL = PREFIX.concat("front_seckill"); //前端 秒杀列表
public static final String SELECT_GOODS = PREFIX.concat("select_goods"); //精选商品
public static final String MOUDLE_INDEX = PREFIX.concat("moudle_index"); //moudle_index 组件排序
/* ----------------------------------------------------------------- */
......
......@@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
@ApiModel(value = "GoblinGoodsSpecDto", description = "商品SKU规格")
......@@ -11,8 +13,10 @@ import java.io.Serializable;
public class GoblinGoodsSpecDto implements Serializable, Cloneable {
private static final long serialVersionUID = 8425727558228094904L;
@ApiModelProperty(position = 11, value = "规格名称")
@NotBlank(message = "规格名称不能为空")
private String specName;
@ApiModelProperty(position = 11, value = "规格值名称")
@NotBlank(message = "规格值不能为空")
private String specVname;
private static final GoblinGoodsSpecDto obj = new GoblinGoodsSpecDto();
......
......@@ -13,8 +13,8 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
......@@ -69,6 +69,8 @@ public class GoblinStoreMgtGoodsAddParam implements Serializable {
@ApiModelProperty(position = 23, required = true, value = "规格展现方式[1-常规|2-组合]", allowableValues = "1,2", example = "1")
private String specMode;
@ApiModelProperty(position = 24, required = true, value = "SKU规格信息")
@NotNull(message = "SKU规格信息不能为空")
@Valid
private List<GoblinStoreMgtGoodsAddSkuParam> skuParamList;
@ApiModelProperty(position = 25, required = true, value = "物流模版", example = "松鼠德邦")
private String logisticsTemplate;
......@@ -225,7 +227,7 @@ public class GoblinStoreMgtGoodsAddParam implements Serializable {
vo.setSkuId(skuId);
}
vo.setSpuId(goodsInfoVo.getSpuId());
vo.setSkuNo(goodsInfoVo.getSpuNo().concat("-").concat(String.valueOf(i)));
vo.setSkuNo(goodsInfoVo.getSpuNo());
vo.setName(goodsInfoVo.getName());
vo.setSubtitle(goodsInfoVo.getSubtitle());
vo.setSkuPic(addSkuParam.getSkuPic());
......@@ -247,7 +249,6 @@ public class GoblinStoreMgtGoodsAddParam implements Serializable {
// vo.setReason();
vo.setShelvesStatus("0");
vo.setSkuAppear(addSkuParam.getSkuAppear());
vo.setSkuNo("0");
// vo.setShelvesAt();
vo.setCreatedBy(goodsInfoVo.getCreatedBy());
vo.setCreatedAt(goodsInfoVo.getCreatedAt());
......
......@@ -6,6 +6,8 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.math.BigDecimal;
......@@ -20,6 +22,8 @@ public class GoblinStoreMgtGoodsAddSkuParam implements Serializable {
@ApiModelProperty(position = 11, required = true, value = "单品默认图片的url[256]")
private String skuPic;
@ApiModelProperty(position = 12, required = true, value = "单品规格信息")
@NotNull(message = "规格信息不能为空")
@Valid
private List<GoblinGoodsSpecDto> skuSpecList;
@ApiModelProperty(position = 13, required = false, value = "单品销售价-原价[20,2]")
private BigDecimal sellPrice;
......
......@@ -21,42 +21,44 @@ public class GoblinStoreMgtGoodsEditSkuParam implements Serializable {
@ApiModelProperty(position = 10, required = true, value = "店铺ID[64]")
@NotBlank(message = "店铺ID不能为空")
private String storeId;
@ApiModelProperty(position = 11, required = false, value = "单品ID[编辑时必传]")
@ApiModelProperty(position = 11, required = true, value = "商品ID[64]")
private String spuId;
@ApiModelProperty(position = 12, required = false, value = "单品ID[编辑时必传]")
private String skuId;
@ApiModelProperty(position = 12, required = true, value = "单品默认图片的url[256]")
@ApiModelProperty(position = 13, required = true, value = "单品默认图片的url[256]")
private String skuPic;
@ApiModelProperty(position = 13, required = true, value = "单品规格信息")
@ApiModelProperty(position = 14, required = true, value = "单品规格信息")
private List<GoblinGoodsSpecDto> skuSpecList;
@ApiModelProperty(position = 14, required = false, value = "单品销售价-原价[20,2]")
@ApiModelProperty(position = 15, required = false, value = "单品销售价-原价[20,2]")
private BigDecimal sellPrice;
@ApiModelProperty(position = 15, required = true, value = "单品现价[20,2]")
@ApiModelProperty(position = 16, required = true, value = "单品现价[20,2]")
private BigDecimal price;
@ApiModelProperty(position = 16, required = true, value = "单品会员价格[20,2]")
@ApiModelProperty(position = 17, required = true, value = "单品会员价格[20,2]")
private BigDecimal priceMember;
@ApiModelProperty(position = 17, required = false, value = "单品的重量[20,2]")
@ApiModelProperty(position = 18, required = false, value = "单品的重量[20,2]")
private BigDecimal weight;
@ApiModelProperty(position = 18, required = true, value = "总库存")
@ApiModelProperty(position = 19, required = true, value = "总库存")
private Integer stock;
@ApiModelProperty(position = 19, required = true, value = "SKU库存")
@ApiModelProperty(position = 20, required = true, value = "SKU库存")
private Integer skuStock;
@ApiModelProperty(position = 20, required = false, value = "预警库存")
@ApiModelProperty(position = 21, required = false, value = "预警库存")
private Integer warningStock;
@ApiModelProperty(position = 21, value = "自定义展示[0-默认展示|1-隐藏不可购买]")
@ApiModelProperty(position = 22, value = "自定义展示[0-默认展示|1-隐藏不可购买]")
private String skuAppear;
@ApiModelProperty(position = 22, required = false, value = "ISBN,针对CD/图书等[100]")
@ApiModelProperty(position = 23, required = false, value = "ISBN,针对CD/图书等[100]")
private String skuIsbn;
@ApiModelProperty(position = 23, required = true, value = "购买限制[0-全部用户|1-仅会员|2-指定用户]")
@ApiModelProperty(position = 24, required = true, value = "购买限制[0-全部用户|1-仅会员|2-指定用户]")
private String buyFactor;
@ApiModelProperty(position = 24, required = false, value = "购买限制人员名单[购买限制为2-指定用户时必填]")
@ApiModelProperty(position = 25, required = false, value = "购买限制人员名单[购买限制为2-指定用户时必填]")
private String buyRoster;
@ApiModelProperty(position = 25, required = false, value = "限量[0-无限制|X:限购数量]")
@ApiModelProperty(position = 26, required = false, value = "限量[0-无限制|X:限购数量]")
private Integer buyLimit;
@ApiModelProperty(position = 26, required = false, value = "单品有效期[yyyy-MM-dd HH:mm:ss]")
@ApiModelProperty(position = 27, required = false, value = "单品有效期[yyyy-MM-dd HH:mm:ss]")
@Pattern(regexp = LnsRegex.Valid.DATETIME_FULL, message = "单品有效期格式有误")
private String skuValidity;
@ApiModelProperty(position = 27, required = false, value = "加减库存")
@ApiModelProperty(position = 30, required = false, value = "加减库存")
private Integer operStock;
public GoblinGoodsSkuInfoVo initEditGoodsSkuInfoVo() {
......@@ -79,4 +81,24 @@ public class GoblinStoreMgtGoodsEditSkuParam implements Serializable {
vo.setSkuValidity(DateUtil.Formatter.yyyyMMddHHmmss.parse(this.getSkuValidity()));
return vo;
}
public GoblinGoodsSkuInfoVo initEditAddGoodsSkuInfoVo() {
GoblinGoodsSkuInfoVo vo = GoblinGoodsSkuInfoVo.getNew();
vo.setSkuPic(this.getSkuPic());
vo.setSkuIsbn(this.getSkuIsbn());
vo.setStock(this.getStock());
vo.setSkuStock(vo.getStock());
vo.setSellPrice(this.getSellPrice());
vo.setPrice(this.getPrice());
vo.setPriceMember(this.getPriceMember());
vo.setWeight(this.getWeight());
vo.setBuyFactor(this.getBuyFactor());
vo.setBuyRoster(this.getBuyRoster());
vo.setBuyLimit(this.getBuyLimit());
vo.setStoreId(this.getStoreId());
vo.setSkuValidity(DateUtil.Formatter.yyyyMMddHHmmss.parse(this.getSkuValidity()));
vo.setSkuAppear(this.getSkuAppear());
vo.setSkuSpecList(this.getSkuSpecList());
return vo;
}
}
......@@ -4,6 +4,7 @@ import com.liquidnet.service.base.PagedResult;
import com.liquidnet.service.goblin.dto.manage.*;
import com.liquidnet.service.goblin.dto.manage.vo.GoblinStoreMgtGoodsInfoVo;
import com.liquidnet.service.goblin.dto.manage.vo.GoblinStoreMgtGoodsListVo;
import com.liquidnet.service.goblin.dto.vo.GoblinGoodsInfoVo;
public interface IGoblinstoreMgtGoodsService {
/**
......@@ -50,17 +51,18 @@ public interface IGoblinstoreMgtGoodsService {
* 商品管理:商品编辑:SKU添加
*
* @param storeMgtGoodsEditSkuParam GoblinStoreMgtGoodsEditSkuParam
* @param goodsInfoVo GoblinGoodsInfoVo
*/
void goodsEditSkuAdd(GoblinStoreMgtGoodsEditSkuParam storeMgtGoodsEditSkuParam);
void goodsEditSkuAdd(GoblinStoreMgtGoodsEditSkuParam storeMgtGoodsEditSkuParam, GoblinGoodsInfoVo goodsInfoVo);
/**
* 商品管理:商品编辑:SKU删除
*
* @param storeId 店铺ID
* @param spuId 商品ID
* @param skuId 单品ID
* @return boolean
*/
boolean goodsEditSkuDel(String storeId, String skuId);
boolean goodsEditSkuDel(String spuId, String skuId);
/**
* 商品管理:商品编辑:SKU批改
......
package com.liquidnet.client.admin.web.controller.zhengzai.goblin;
import com.alibaba.fastjson.JSON;
import com.liquidnet.client.admin.common.core.controller.BaseController;
import com.liquidnet.client.admin.common.core.domain.AjaxResult;
import com.liquidnet.client.admin.zhengzai.goblin.service.impl.GoblinFrontMoudleIndexServiceImpl;
import com.liquidnet.service.goblin.entity.GoblinFrontMoudleIndex;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* <p>
* 组件排序 前端控制器
* </p>
*
* @author liquidnet
* @since 2022-01-06
*/
@Api(tags = "组件排序")
@RestController
@RequestMapping("/front-index")
public class GoblinFrontMoudleIndexController extends BaseController {
@Autowired
GoblinFrontMoudleIndexServiceImpl goblinFrontMoudleIndexService;
@PostMapping("update")
@ApiOperation(value = "修改组件")
@ResponseBody
public AjaxResult update(@RequestBody GoblinFrontMoudleIndex goblinFrontMoudleIndex) {
logger.info("修改组件{}", JSON.toJSONString(goblinFrontMoudleIndex));
boolean result=goblinFrontMoudleIndexService.upadteGoblinFrontMoudleIndex(goblinFrontMoudleIndex);
if (result ) {
return success("操作成功");
} else {
return error("操作失败");
}
}
/**
* @author zhangfuxin
* @Description:列表
* @date 2022/1/6 下午2:04
*/
@PostMapping("list")
@ApiOperation(value = "组件排序列表")
@ResponseBody
public AjaxResult list() {
return AjaxResult.success(goblinFrontMoudleIndexService.listGoblinFrontMoudleIndex());
}
}
package com.liquidnet.client.admin.zhengzai.goblin.service;
import com.liquidnet.service.goblin.entity.GoblinFrontMoudleIndex;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* <p>
* 组件排序 服务类
* </p>
*
* @author liquidnet
* @since 2022-01-06
*/
public interface IGoblinFrontMoudleIndexService extends IService<GoblinFrontMoudleIndex> {
List<GoblinFrontMoudleIndex> listGoblinFrontMoudleIndex();
boolean upadteGoblinFrontMoudleIndex(GoblinFrontMoudleIndex goblinFrontMoudleIndex);
}
package com.liquidnet.client.admin.zhengzai.goblin.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liquidnet.client.admin.zhengzai.goblin.service.IGoblinFrontMoudleIndexService;
import com.liquidnet.common.cache.redis.util.RedisDataSourceUtil;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.goblin.constant.GoblinRedisConst;
import com.liquidnet.service.goblin.entity.GoblinFrontMoudleIndex;
import com.liquidnet.service.goblin.mapper.GoblinFrontMoudleIndexMapper;
import com.mongodb.BasicDBObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
import java.util.List;
/**
* <p>
* 组件排序 服务实现类
* </p>
*
* @author liquidnet
* @since 2022-01-06
*/
@Service
public class GoblinFrontMoudleIndexServiceImpl extends ServiceImpl<GoblinFrontMoudleIndexMapper, GoblinFrontMoudleIndex> implements IGoblinFrontMoudleIndexService {
@Autowired
GoblinFrontMoudleIndexMapper goblinFrontMoudleIndexMapper;
@Autowired
private MongoTemplate mongoTemplate;
@Autowired
private RedisDataSourceUtil redisDataSourceUtil;
@Override
public List<GoblinFrontMoudleIndex> listGoblinFrontMoudleIndex() {
LambdaQueryWrapper<GoblinFrontMoudleIndex> queryWrapper = Wrappers.lambdaQuery(GoblinFrontMoudleIndex.class);
queryWrapper.orderByAsc(GoblinFrontMoudleIndex::getIndexs);
List<GoblinFrontMoudleIndex> list=goblinFrontMoudleIndexMapper.selectList(queryWrapper);
return list;
}
@Override
public boolean upadteGoblinFrontMoudleIndex(GoblinFrontMoudleIndex goblinFrontMoudleIndex) {
goblinFrontMoudleIndex.setUpdateTime(LocalDateTime.now());
goblinFrontMoudleIndexMapper.updateById(goblinFrontMoudleIndex);
return true;
}
public boolean online(){
//查出数据
List<GoblinFrontMoudleIndex> list=this.listGoblinFrontMoudleIndex();
// mongodb 放入
for(GoblinFrontMoudleIndex goblinFrontMoudleIndex:list){
GoblinFrontMoudleIndex goblinFrontMoudleIndex1=mongoTemplate.findOne(Query.query(Criteria.where("moudleIndexId").is(goblinFrontMoudleIndex.getMoudleIndexId())), GoblinFrontMoudleIndex.class, GoblinFrontMoudleIndex.class.getSimpleName());
if(null==goblinFrontMoudleIndex1){
mongoTemplate.save(goblinFrontMoudleIndex,GoblinFrontMoudleIndex.class.getSimpleName());
}else{
BasicDBObject orderObject = new BasicDBObject("$set", JSON.parse(JsonUtils.toJson(goblinFrontMoudleIndex)));
mongoTemplate.getCollection(GoblinFrontMoudleIndex.class.getSimpleName()).updateOne(
Query.query(Criteria.where("moudleIndexId").is(goblinFrontMoudleIndex.getMoudleIndexId())).getQueryObject(),
orderObject
);
}
}
// reids 存入
redisDataSourceUtil.getRedisGoblinUtil().set(GoblinRedisConst.MOUDLE_INDEX,list);
return true;
}
}
package com.liquidnet.service.goblin.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* <p>
* 组件排序
* </p>
*
* @author liquidnet
* @since 2022-01-06
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class GoblinFrontMoudleIndex implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "mid", type = IdType.AUTO)
private Long mid;
/**
* 组件排序id
*/
private String moudleIndexId;
/**
* 名字
*/
private String moudleName;
/**
* 顺序
*/
private Integer indexs;
/**
* 修改时间
*/
private LocalDateTime updateTime;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 0未删除1已删除
*/
private Integer delTag;
/**
* 0展示2不展示
*/
private Integer status;
}
package com.liquidnet.service.goblin.mapper;
import com.liquidnet.service.goblin.entity.GoblinFrontMoudleIndex;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 组件排序 Mapper 接口
* </p>
*
* @author liquidnet
* @since 2022-01-06
*/
public interface GoblinFrontMoudleIndexMapper extends BaseMapper<GoblinFrontMoudleIndex> {
}
......@@ -2,12 +2,12 @@ package com.liquidnet.service.goblin.controller.manage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.commons.lang.util.CurrentUtil;
import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.base.ErrorMapping;
import com.liquidnet.service.base.PagedResult;
import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.goblin.dto.GoblinGoodsSpecDto;
import com.liquidnet.service.goblin.dto.manage.GoblinStoreMgtGoodsActionParam;
import com.liquidnet.service.goblin.dto.manage.GoblinStoreMgtGoodsAddParam;
import com.liquidnet.service.goblin.dto.manage.GoblinStoreMgtGoodsEditSkuParam;
......@@ -32,6 +32,9 @@ import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
@ApiSupport(order = 149003)
@Api(tags = "商品管理")
......@@ -95,7 +98,7 @@ public class GoblinStoreMgtGoodsController {
return ResponseDto.failure(ErrorMapping.get("149002"));
}
if (log.isDebugEnabled()) {
log.debug("商品管理:管理SPU:[GoblinStoreMgtGoodsActionParam={}]", JsonUtils.toJson(storeMgtGoodsActionParam));
log.debug("商品管理:SPU管理:[GoblinStoreMgtGoodsActionParam={}]", JsonUtils.toJson(storeMgtGoodsActionParam));
}
// TODO: 2021/12/28 zhanggb 逻辑校验
......@@ -124,7 +127,7 @@ public class GoblinStoreMgtGoodsController {
return ResponseDto.failure(ErrorMapping.get("149002"));
}
if (log.isDebugEnabled()) {
log.debug("商品管理:添加SPU:[GoblinStoreMgtGoodsAddParam={}]", JsonUtils.toJson(storeMgtGoodsAddParam));
log.debug("商品管理:SPU添加:[GoblinStoreMgtGoodsAddParam={}]", JsonUtils.toJson(storeMgtGoodsAddParam));
}
goblinstoreMgtGoodsService.goodsAdd(storeMgtGoodsAddParam);
return ResponseDto.success();
......@@ -155,11 +158,11 @@ public class GoblinStoreMgtGoodsController {
if (!goblinRedisUtils.hasStoreId(CurrentUtil.getCurrentUid(), storeMgtGoodsAddParam.getStoreId())) {
return ResponseDto.failure(ErrorMapping.get("149002"));
}
if (StringUtils.isBlank(storeMgtGoodsAddParam.getSpuId()) || null == goblinRedisUtils.getGoodsInfoVo(storeMgtGoodsAddParam.getSpuId())) {
if (StringUtils.isBlank(storeMgtGoodsAddParam.getSpuId()) || null == goblinRedisUtils.getMgtGoodsInfoVo(storeMgtGoodsAddParam.getSpuId())) {
return ResponseDto.failure(ErrorMapping.get("149010"));
}
if (log.isDebugEnabled()) {
log.debug("商品管理:商品编辑:编辑SPU:[GoblinStoreMgtGoodsAddParam={}]", JsonUtils.toJson(storeMgtGoodsAddParam));
log.debug("商品管理:商品编辑:SPU编辑:[GoblinStoreMgtGoodsAddParam={}]", JsonUtils.toJson(storeMgtGoodsAddParam));
}
return ResponseDto.success(goblinstoreMgtGoodsService.goodsEditSpu(storeMgtGoodsAddParam));
}
......@@ -171,24 +174,25 @@ public class GoblinStoreMgtGoodsController {
if (!goblinRedisUtils.hasStoreId(CurrentUtil.getCurrentUid(), storeMgtGoodsEditSkuParam.getStoreId())) {
return ResponseDto.failure(ErrorMapping.get("149002"));
}
GoblinGoodsSkuInfoVo goodsSkuInfoVo = goblinRedisUtils.getGoodsSkuInfoVo(storeMgtGoodsEditSkuParam.getSkuId());
if (StringUtils.isBlank(storeMgtGoodsEditSkuParam.getSkuId()) || null == goodsSkuInfoVo) {
GoblinGoodsSkuInfoVo mgtGoodsSkuInfoVo = goblinRedisUtils.getMgtGoodsSkuInfoVo(storeMgtGoodsEditSkuParam.getSkuId());
if (StringUtils.isBlank(storeMgtGoodsEditSkuParam.getSkuId())
|| null == mgtGoodsSkuInfoVo || !mgtGoodsSkuInfoVo.getStoreId().equals(storeMgtGoodsEditSkuParam.getStoreId())) {
return ResponseDto.failure(ErrorMapping.get("149011"));
}
GoblinGoodsInfoVo goodsInfoVo = goblinRedisUtils.getGoodsInfoVo(goodsSkuInfoVo.getSpuId());
GoblinGoodsInfoVo goodsInfoVo = goblinRedisUtils.getMgtGoodsInfoVo(mgtGoodsSkuInfoVo.getSpuId());
// TODO: 2022/1/5 zhanggb +分类-ISBN校验
if (log.isDebugEnabled()) {
log.debug("商品管理:商品编辑:编辑SKU:[GoblinStoreMgtGoodsEditSkuParam={}]", JsonUtils.toJson(storeMgtGoodsEditSkuParam));
log.debug("商品管理:商品编辑:SKU编辑:[GoblinStoreMgtGoodsEditSkuParam={}]", JsonUtils.toJson(storeMgtGoodsEditSkuParam));
}
storeMgtGoodsEditSkuParam.setStock(goodsSkuInfoVo.getStock());
storeMgtGoodsEditSkuParam.setSkuStock(goodsSkuInfoVo.getSkuStock());
storeMgtGoodsEditSkuParam.setStock(mgtGoodsSkuInfoVo.getStock());
storeMgtGoodsEditSkuParam.setSkuStock(mgtGoodsSkuInfoVo.getSkuStock());
String skuId = storeMgtGoodsEditSkuParam.getSkuId();
Integer operStock = storeMgtGoodsEditSkuParam.getOperStock();
if (null != operStock && operStock != 0) {// 处理库存
int operStockVal = Math.abs(operStock);
Integer stock = goodsSkuInfoVo.getSkuStock();// 总库存
Integer skuStock = goodsSkuInfoVo.getSkuStock();// SKU总库存
Integer stock = mgtGoodsSkuInfoVo.getSkuStock();// 总库存
Integer skuStock = mgtGoodsSkuInfoVo.getSkuStock();// SKU总库存
int rtSkuStock = goblinRedisUtils.getSkuStock(null, skuId);// 当前剩余库存
if (operStock < 0 && rtSkuStock >= operStockVal) {// SKU实时库存充足时允许扣减
......@@ -206,7 +210,7 @@ public class GoblinStoreMgtGoodsController {
}
}
if (goblinstoreMgtGoodsService.goodsEditSku(storeMgtGoodsEditSkuParam)) {
return ResponseDto.success(goblinRedisUtils.getGoodsSkuInfoVo(storeMgtGoodsEditSkuParam.getSkuId()));
return ResponseDto.success(goblinRedisUtils.getMgtGoodsSkuInfoVo(storeMgtGoodsEditSkuParam.getSkuId()));
} else {
if (null != operStock && operStock != 0) {// 处理库存:回滚
int operStockVal = Math.abs(operStock);
......@@ -227,11 +231,31 @@ public class GoblinStoreMgtGoodsController {
if (!goblinRedisUtils.hasStoreId(CurrentUtil.getCurrentUid(), storeMgtGoodsEditSkuParam.getStoreId())) {
return ResponseDto.failure(ErrorMapping.get("149002"));
}
GoblinGoodsInfoVo goodsInfoVo = goblinRedisUtils.getMgtGoodsInfoVo(storeMgtGoodsEditSkuParam.getSpuId());
if (null == goodsInfoVo || !goodsInfoVo.getStoreId().equals(storeMgtGoodsEditSkuParam.getStoreId())) {
return ResponseDto.failure(ErrorMapping.get("149010"));
}
List<String> skuIdList = goodsInfoVo.getSkuIdList();
Map<String, String> paramSkuSpecMap = storeMgtGoodsEditSkuParam.getSkuSpecList()
.stream().collect(Collectors.toMap(GoblinGoodsSpecDto::getSpecName, GoblinGoodsSpecDto::getSpecVname, (k1, k2) -> k2));
for (String skuId : skuIdList) {// 比对所有SKU规格信息
GoblinGoodsSkuInfoVo mgtGoodsSkuInfoVo = goblinRedisUtils.getMgtGoodsSkuInfoVo(skuId);
Map<String, String> skuSpecMap = mgtGoodsSkuInfoVo.getSkuSpecList()
.stream().collect(Collectors.toMap(GoblinGoodsSpecDto::getSpecName, GoblinGoodsSpecDto::getSpecVname, (k1, k2) -> k2));
boolean existingFlg = false;
Set<Map.Entry<String, String>> paramSkuSpecSet = paramSkuSpecMap.entrySet();
for (Map.Entry<String, String> entry : paramSkuSpecSet) {
existingFlg = skuSpecMap.get(entry.getKey()).equals(entry.getValue());
}
if (existingFlg) {
log.warn("商品管理:商品编辑:SKU添加:重复的规格信息[skuSpecMap={},paramSkuSpecMap={}]", skuSpecMap, paramSkuSpecMap);
return ResponseDto.failure(ErrorMapping.get("149014"));
}
}
if (log.isDebugEnabled()) {
log.debug("商品管理:商品编辑:编辑SKU:[GoblinStoreMgtGoodsEditSkuParam={}]", JsonUtils.toJson(storeMgtGoodsEditSkuParam));
log.debug("商品管理:商品编辑:SKU添加:[GoblinStoreMgtGoodsEditSkuParam={}]", JsonUtils.toJson(storeMgtGoodsEditSkuParam));
}
goblinstoreMgtGoodsService.goodsEditSkuAdd(storeMgtGoodsEditSkuParam);
goblinstoreMgtGoodsService.goodsEditSkuAdd(storeMgtGoodsEditSkuParam, goodsInfoVo);
return ResponseDto.success();
}
......@@ -247,7 +271,11 @@ public class GoblinStoreMgtGoodsController {
if (!goblinRedisUtils.hasStoreId(CurrentUtil.getCurrentUid(), storeId)) {
return ResponseDto.failure(ErrorMapping.get("149002"));
}
return ResponseDto.success(goblinstoreMgtGoodsService.goodsEditSkuDel(storeId, skuId));
GoblinGoodsSkuInfoVo mgtGoodsSkuInfoVo = goblinRedisUtils.getMgtGoodsSkuInfoVo(skuId);
if (null == mgtGoodsSkuInfoVo || !mgtGoodsSkuInfoVo.getStoreId().equals(storeId)) {
return ResponseDto.failure(ErrorMapping.get("149011"));
}
return ResponseDto.success(goblinstoreMgtGoodsService.goodsEditSkuDel(mgtGoodsSkuInfoVo.getSpuId(), skuId));
}
@ApiOperationSupport(order = 10)
......
......@@ -15,6 +15,7 @@ import com.liquidnet.service.goblin.util.GoblinMongoUtils;
import com.liquidnet.service.goblin.util.GoblinRedisUtils;
import com.liquidnet.service.goblin.util.ObjectUtil;
import com.liquidnet.service.goblin.util.QueueUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
......@@ -143,14 +144,47 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi
}
@Override
public void goodsEditSkuAdd(GoblinStoreMgtGoodsEditSkuParam storeMgtGoodsEditSkuParam) {
// TODO: 2022/1/5 zhanggb
public void goodsEditSkuAdd(GoblinStoreMgtGoodsEditSkuParam storeMgtGoodsEditSkuParam, GoblinGoodsInfoVo goodsInfoVo) {
String spuId = storeMgtGoodsEditSkuParam.getSpuId();
String uid = CurrentUtil.getCurrentUid();
LocalDateTime now = LocalDateTime.now();
GoblinGoodsSkuInfoVo addGoodsSkuInfoVo = storeMgtGoodsEditSkuParam.initEditAddGoodsSkuInfoVo();
addGoodsSkuInfoVo.setSkuId(spuId.concat(StringUtils.right(String.valueOf(System.nanoTime()), 5)));
addGoodsSkuInfoVo.setSpuId(spuId);
addGoodsSkuInfoVo.setName(goodsInfoVo.getName());
addGoodsSkuInfoVo.setSubtitle(goodsInfoVo.getSubtitle());
addGoodsSkuInfoVo.setVirtualFlg(goodsInfoVo.getVirtualFlg());
addGoodsSkuInfoVo.setStatus("3");
addGoodsSkuInfoVo.setShelvesStatus(goodsInfoVo.getShelvesStatus());
addGoodsSkuInfoVo.setCreatedAt(now);
addGoodsSkuInfoVo.setCreatedBy(uid);
addGoodsSkuInfoVo.setLogisticsTemplate(goodsInfoVo.getLogisticsTemplate());
goblinMongoUtils.setGoodsSkuInfoVo(addGoodsSkuInfoVo);
List<String> skuIdList = goodsInfoVo.getSkuIdList();
skuIdList.add(addGoodsSkuInfoVo.getSkuId());
goodsInfoVo.setSkuIdList(skuIdList);
goblinMongoUtils.updateGoodsInfoVo(goodsInfoVo);
// TODO: 2022/1/5 zhanggb redis+sql
}
@Override
public boolean goodsEditSkuDel(String storeId, String skuId) {
// TODO: 2022/1/5 zhanggb
return false;
public boolean goodsEditSkuDel(String spuId, String skuId) {
goblinRedisUtils.delGoodsSkuInfoVo(skuId);
goblinMongoUtils.delGoodsSkuInfoVo(skuId);
GoblinGoodsInfoVo mgtGoodsInfoVo = goblinRedisUtils.getMgtGoodsInfoVo(spuId);
List<String> skuIdList = mgtGoodsInfoVo.getSkuIdList();
skuIdList.removeIf(r -> r.equals(skuId));
mgtGoodsInfoVo.setSkuIdList(skuIdList);
// TODO: 2022/1/5 zhanggb redis+sql
return goblinMongoUtils.updateGoodsInfoVo(mgtGoodsInfoVo);
}
@Override
......
......@@ -28,6 +28,7 @@
149011=SKU不存在,请核实
149012=SKU库存不足,请核实
149013=SKU编辑失败
149014=SKU添加失败,重复的规格信息
......
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