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

Commit 9e3024c8 authored by 胡佳晨's avatar 胡佳晨

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

# Conflicts:
#	liquidnet-bus-service/liquidnet-service-goblin/liquidnet-service-goblin-impl/src/main/java/com/liquidnet/service/goblin/util/GoblinRedisUtils.java
parents 91b97e69 57e83a52
...@@ -5,9 +5,9 @@ public class GoblinRedisConst { ...@@ -5,9 +5,9 @@ public class GoblinRedisConst {
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
/** /**
* 认证中店铺UID关系缓存 * 认证中店铺UID关系缓存
* {goblin:tmp_uid_store:${uid}, store_id} * {goblin:basic:ustore:${uid}, List<store_id>}
*/ */
public static final String TMP_UID_STORE = PREFIX.concat("tmp_uid_store:"); public static final String BASIC_USTORE = PREFIX.concat("basic:ustore:");
/** /**
* 店铺信息 * 店铺信息
* {goblin:basic:store:${store_id}, com.liquidnet.service.goblin.dto.vo.GoblinStoreInfoVo} * {goblin:basic:store:${store_id}, com.liquidnet.service.goblin.dto.vo.GoblinStoreInfoVo}
......
...@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModel; ...@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern; import javax.validation.constraints.Pattern;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
...@@ -12,6 +13,9 @@ import java.util.List; ...@@ -12,6 +13,9 @@ import java.util.List;
@Data @Data
public class GoblinStoreMgtGoodsActionParam implements Serializable { public class GoblinStoreMgtGoodsActionParam implements Serializable {
private static final long serialVersionUID = 6564996671833040261L; private static final long serialVersionUID = 6564996671833040261L;
@ApiModelProperty(position = 10, required = true, value = "店铺ID[64]")
@NotBlank(message = "店铺ID不能为空")
private String storeId;
@ApiModelProperty(position = 11, required = true, value = "操作类型[ONSHELVES-上架|UNSHELVE-下架|REMOVE-删除]") @ApiModelProperty(position = 11, required = true, value = "操作类型[ONSHELVES-上架|UNSHELVE-下架|REMOVE-删除]")
@Pattern(regexp = "\\b(ONSHELVES|UNSHELVE|REMOVE)\\b", message = "操作类型无效") @Pattern(regexp = "\\b(ONSHELVES|UNSHELVE|REMOVE)\\b", message = "操作类型无效")
private String action; private String action;
......
...@@ -15,6 +15,7 @@ import lombok.Data; ...@@ -15,6 +15,7 @@ import lombok.Data;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern; import javax.validation.constraints.Pattern;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -25,10 +26,11 @@ import java.util.List; ...@@ -25,10 +26,11 @@ import java.util.List;
@Data @Data
public class GoblinStoreMgtGoodsAddParam implements Serializable { public class GoblinStoreMgtGoodsAddParam implements Serializable {
private static final long serialVersionUID = -5101611616626164702L; private static final long serialVersionUID = -5101611616626164702L;
@ApiModelProperty(position = 10, required = false, value = "商品ID[编辑时必传]") @ApiModelProperty(position = 10, required = true, value = "店铺ID")
private String spuId; @NotNull(message = "店铺ID不能为空")
@ApiModelProperty(position = 11, required = true, value = "店铺ID")
private String storeId; private String storeId;
@ApiModelProperty(position = 11, required = false, value = "商品ID[编辑时必传]")
private String spuId;
/** /**
* ---------------------------- 基本信息 ---------------------------- * ---------------------------- 基本信息 ----------------------------
...@@ -38,7 +40,7 @@ public class GoblinStoreMgtGoodsAddParam implements Serializable { ...@@ -38,7 +40,7 @@ public class GoblinStoreMgtGoodsAddParam implements Serializable {
private String name; private String name;
@ApiModelProperty(position = 13, required = false, value = "商品名称[128]") @ApiModelProperty(position = 13, required = false, value = "商品名称[128]")
private String subtitle; private String subtitle;
@ApiModelProperty(position = 14, required = false, value = "商品销售价[20,2]") @ApiModelProperty(position = 14, required = false, value = "商品销售价-原价[20,2]")
private BigDecimal sellPrice; private BigDecimal sellPrice;
@ApiModelProperty(position = 15, required = true, value = "商品一级分类ID[30]") @ApiModelProperty(position = 15, required = true, value = "商品一级分类ID[30]")
...@@ -125,7 +127,7 @@ public class GoblinStoreMgtGoodsAddParam implements Serializable { ...@@ -125,7 +127,7 @@ public class GoblinStoreMgtGoodsAddParam implements Serializable {
vo.setSpuId(this.getSpuId()); vo.setSpuId(this.getSpuId());
} }
if (StringUtils.isBlank(this.getSpuNo())) { if (StringUtils.isBlank(this.getSpuNo())) {
vo.setSpuNo(IDGenerator.nextTimeId2()); vo.setSpuNo(vo.getSpuId());
} else { } else {
vo.setSpuNo(this.getSpuNo()); vo.setSpuNo(this.getSpuNo());
} }
...@@ -173,7 +175,7 @@ public class GoblinStoreMgtGoodsAddParam implements Serializable { ...@@ -173,7 +175,7 @@ public class GoblinStoreMgtGoodsAddParam implements Serializable {
* *
* @return GoblinGoodsInfoVo * @return GoblinGoodsInfoVo
*/ */
public GoblinGoodsInfoVo initEditGoodsSkuInfoVo() { public GoblinGoodsInfoVo initEditGoodsInfoVo() {
GoblinGoodsInfoVo vo = GoblinGoodsInfoVo.getNew(); GoblinGoodsInfoVo vo = GoblinGoodsInfoVo.getNew();
vo.setStoreId(this.getStoreId()); vo.setStoreId(this.getStoreId());
vo.setSpuId(this.getSpuId()); vo.setSpuId(this.getSpuId());
...@@ -223,7 +225,7 @@ public class GoblinStoreMgtGoodsAddParam implements Serializable { ...@@ -223,7 +225,7 @@ public class GoblinStoreMgtGoodsAddParam implements Serializable {
vo.setSkuId(skuId); vo.setSkuId(skuId);
} }
vo.setSpuId(goodsInfoVo.getSpuId()); vo.setSpuId(goodsInfoVo.getSpuId());
// vo.setSkuNo(goodsInfoVo.getSpuNo().concat("-").concat(String.valueOf(i))); vo.setSkuNo(goodsInfoVo.getSpuNo().concat("-").concat(String.valueOf(i)));
vo.setName(goodsInfoVo.getName()); vo.setName(goodsInfoVo.getName());
vo.setSubtitle(goodsInfoVo.getSubtitle()); vo.setSubtitle(goodsInfoVo.getSubtitle());
vo.setSkuPic(addSkuParam.getSkuPic()); vo.setSkuPic(addSkuParam.getSkuPic());
......
...@@ -21,9 +21,9 @@ public class GoblinStoreMgtGoodsAddSkuParam implements Serializable { ...@@ -21,9 +21,9 @@ public class GoblinStoreMgtGoodsAddSkuParam implements Serializable {
private String skuPic; private String skuPic;
@ApiModelProperty(position = 12, required = true, value = "单品规格信息") @ApiModelProperty(position = 12, required = true, value = "单品规格信息")
private List<GoblinGoodsSpecDto> skuSpecList; private List<GoblinGoodsSpecDto> skuSpecList;
@ApiModelProperty(position = 13, required = false, value = "单品销售价[20,2]") @ApiModelProperty(position = 13, required = false, value = "单品销售价-原价[20,2]")
private BigDecimal sellPrice; private BigDecimal sellPrice;
@ApiModelProperty(position = 14, required = true, value = "单品价格[20,2]") @ApiModelProperty(position = 14, required = true, value = "单品现价[20,2]")
private BigDecimal price; private BigDecimal price;
@ApiModelProperty(position = 15, required = true, value = "单品会员价格[20,2]") @ApiModelProperty(position = 15, required = true, value = "单品会员价格[20,2]")
private BigDecimal priceMember; private BigDecimal priceMember;
......
...@@ -8,6 +8,7 @@ import io.swagger.annotations.ApiModel; ...@@ -8,6 +8,7 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern; import javax.validation.constraints.Pattern;
import java.io.Serializable; import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
...@@ -18,6 +19,7 @@ import java.util.List; ...@@ -18,6 +19,7 @@ import java.util.List;
public class GoblinStoreMgtGoodsEditSkuParam implements Serializable { public class GoblinStoreMgtGoodsEditSkuParam implements Serializable {
private static final long serialVersionUID = 6657596593310537491L; private static final long serialVersionUID = 6657596593310537491L;
@ApiModelProperty(position = 10, required = true, value = "店铺ID[64]") @ApiModelProperty(position = 10, required = true, value = "店铺ID[64]")
@NotBlank(message = "店铺ID不能为空")
private String storeId; private String storeId;
@ApiModelProperty(position = 11, required = false, value = "单品ID[编辑时必传]") @ApiModelProperty(position = 11, required = false, value = "单品ID[编辑时必传]")
private String skuId; private String skuId;
...@@ -25,9 +27,9 @@ public class GoblinStoreMgtGoodsEditSkuParam implements Serializable { ...@@ -25,9 +27,9 @@ public class GoblinStoreMgtGoodsEditSkuParam implements Serializable {
private String skuPic; private String skuPic;
@ApiModelProperty(position = 13, required = true, value = "单品规格信息") @ApiModelProperty(position = 13, required = true, value = "单品规格信息")
private List<GoblinGoodsSpecDto> skuSpecList; private List<GoblinGoodsSpecDto> skuSpecList;
@ApiModelProperty(position = 14, required = false, value = "单品销售价[20,2]") @ApiModelProperty(position = 14, required = false, value = "单品销售价-原价[20,2]")
private BigDecimal sellPrice; private BigDecimal sellPrice;
@ApiModelProperty(position = 15, required = true, value = "单品价格[20,2]") @ApiModelProperty(position = 15, required = true, value = "单品现价[20,2]")
private BigDecimal price; private BigDecimal price;
@ApiModelProperty(position = 16, required = true, value = "单品会员价格[20,2]") @ApiModelProperty(position = 16, required = true, value = "单品会员价格[20,2]")
private BigDecimal priceMember; private BigDecimal priceMember;
......
...@@ -11,33 +11,35 @@ import java.math.BigDecimal; ...@@ -11,33 +11,35 @@ import java.math.BigDecimal;
@Data @Data
public class GoblinStoreMgtGoodsListVo implements Serializable, Cloneable { public class GoblinStoreMgtGoodsListVo implements Serializable, Cloneable {
private static final long serialVersionUID = -5926827517337445529L; private static final long serialVersionUID = -5926827517337445529L;
@ApiModelProperty(position = 10, value = "商品ID") @ApiModelProperty(position = 10, value = "店铺ID[64]")
private String storeId;
@ApiModelProperty(position = 11, value = "商品ID[64]")
private String spuId; private String spuId;
@ApiModelProperty(position = 11, value = "商品编码") @ApiModelProperty(position = 12, value = "商品编码[45]")
private String spuNo; private String spuNo;
@ApiModelProperty(position = 12, value = "封面图片地址") @ApiModelProperty(position = 13, value = "封面图片地址[256]")
private String coverPic; private String coverPic;
@ApiModelProperty(position = 13, value = "商品名称") @ApiModelProperty(position = 14, value = "商品名称[100]")
private String name; private String name;
@ApiModelProperty(position = 14, value = "商品一级分类ID[30]") @ApiModelProperty(position = 15, value = "商品一级分类ID[30]")
private String cateFid; private String cateFid;
@ApiModelProperty(position = 15, value = "商品二级分类ID[30]") @ApiModelProperty(position = 16, value = "商品二级分类ID[30]")
private String cateSid; private String cateSid;
@ApiModelProperty(position = 16, value = "商品三级分类ID[30]") @ApiModelProperty(position = 17, value = "商品三级分类ID[30]")
private String cateTid; private String cateTid;
@ApiModelProperty(position = 17, value = "价格区间MIN") @ApiModelProperty(position = 18, value = "价格区间MIN")
private BigDecimal priceGe; private BigDecimal priceGe;
@ApiModelProperty(position = 18, value = "价格区间MAX") @ApiModelProperty(position = 19, value = "价格区间MAX")
private BigDecimal priceLe; private BigDecimal priceLe;
@ApiModelProperty(position = 19, value = "审核状态[0-编辑中|1-审核中|2-审核不通过|3-审核通过]") @ApiModelProperty(position = 20, value = "审核状态[0-编辑中|1-审核中|2-审核不通过|3-审核通过]")
private String status; private String status;
@ApiModelProperty(position = 20, value = "审核拒绝原因") @ApiModelProperty(position = 21, value = "审核拒绝原因")
private String reason; private String reason;
@ApiModelProperty(position = 21, value = "商品上架状态[0-待上架|1-下架|2-违规|3-上架]") @ApiModelProperty(position = 22, value = "商品上架状态[0-待上架|1-下架|2-违规|3-上架]")
private String shelvesStatus; private String shelvesStatus;
@ApiModelProperty(position = 22, value = "总库存") @ApiModelProperty(position = 23, value = "总库存")
private Integer totalStock; private Integer totalStock;
@ApiModelProperty(position = 23, value = "剩余库存") @ApiModelProperty(position = 24, value = "剩余库存")
private Integer surplusStock; private Integer surplusStock;
} }
package com.liquidnet.service.goblin.dto.vo;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* <p>
* 轮播图
* </p>
*
* @author liquidnet
* @since 2021-12-27
*/
@ApiModel(value = "GoblinFrontBannerBuildParam", description = "轮播图param")
@Data
public class GoblinFrontGoodDetailVo implements Serializable {
//spu
GoblinGoodsInfoVo goblinGoodsInfoVo;
//sku
List<GoblinGoodsSkuInfoVo> goblinGoodsSkuInfoVolist;
private static final long serialVersionUID = 1L;
private static final GoblinFrontGoodDetailVo obj = new GoblinFrontGoodDetailVo();
public static GoblinFrontGoodDetailVo getNew() {
try {
return (GoblinFrontGoodDetailVo) obj.clone();
} catch (CloneNotSupportedException e) {
return new GoblinFrontGoodDetailVo();
}
}
}
...@@ -9,13 +9,13 @@ import java.util.List; ...@@ -9,13 +9,13 @@ import java.util.List;
/** /**
* <p> * <p>
* 轮播图 * 精选商品列表
* </p> * </p>
* *
* @author liquidnet * @author liquidnet
* @since 2021-12-27 * @since 2021-12-27
*/ */
@ApiModel(value = "GoblinFrontBannerBuildParam", description = "轮播图param") @ApiModel(value = "GoblinFrontSelectGoodVo", description = "精选商品列表")
@Data @Data
public class GoblinFrontSelectGoodVo implements Serializable { public class GoblinFrontSelectGoodVo implements Serializable {
/** /**
......
...@@ -27,7 +27,7 @@ public class GoblinGoodsInfoVo implements Serializable, Cloneable { ...@@ -27,7 +27,7 @@ public class GoblinGoodsInfoVo implements Serializable, Cloneable {
private String name; private String name;
@ApiModelProperty(position = 14, value = "商品副标题[128]") @ApiModelProperty(position = 14, value = "商品副标题[128]")
private String subtitle; private String subtitle;
@ApiModelProperty(position = 15, value = "销售价[20,2]") @ApiModelProperty(position = 15, value = "销售价-原价[20,2]")
private BigDecimal sellPrice; private BigDecimal sellPrice;
@ApiModelProperty(position = 16, value = "价格区间MIN[20,2]") @ApiModelProperty(position = 16, value = "价格区间MIN[20,2]")
private BigDecimal priceGe; private BigDecimal priceGe;
......
...@@ -39,9 +39,9 @@ public class GoblinGoodsSkuInfoVo implements Serializable, Cloneable { ...@@ -39,9 +39,9 @@ public class GoblinGoodsSkuInfoVo implements Serializable, Cloneable {
private Integer skuStock; private Integer skuStock;
@ApiModelProperty(position = 19, value = "预警库存") @ApiModelProperty(position = 19, value = "预警库存")
private Integer warningStock; private Integer warningStock;
@ApiModelProperty(position = 20, value = "单品销售价[20,2]") @ApiModelProperty(position = 20, value = "单品销售价-原价[20,2]")
private BigDecimal sellPrice; private BigDecimal sellPrice;
@ApiModelProperty(position = 21, value = "单品价格[20,2]") @ApiModelProperty(position = 21, value = "单品现价[20,2]")
private BigDecimal price; private BigDecimal price;
@ApiModelProperty(position = 22, value = "单品会员价格[20,2]") @ApiModelProperty(position = 22, value = "单品会员价格[20,2]")
private BigDecimal priceMember; private BigDecimal priceMember;
......
...@@ -24,10 +24,11 @@ public interface IGoblinstoreMgtGoodsService { ...@@ -24,10 +24,11 @@ public interface IGoblinstoreMgtGoodsService {
/** /**
* 商品管理:SPU详情 * 商品管理:SPU详情
* *
* @param storeId 店铺ID
* @param spuId 商品ID * @param spuId 商品ID
* @return GoblinStoreMgtGoodsInfoVo * @return GoblinStoreMgtGoodsInfoVo
*/ */
GoblinStoreMgtGoodsInfoVo goodsInfo(String spuId); GoblinStoreMgtGoodsInfoVo goodsInfo(String storeId, String spuId);
/** /**
* 商品管理:商品编辑:SPU编辑 * 商品管理:商品编辑:SPU编辑
...@@ -55,10 +56,11 @@ public interface IGoblinstoreMgtGoodsService { ...@@ -55,10 +56,11 @@ public interface IGoblinstoreMgtGoodsService {
/** /**
* 商品管理:商品编辑:SKU删除 * 商品管理:商品编辑:SKU删除
* *
* @param storeId 店铺ID
* @param skuId 单品ID * @param skuId 单品ID
* @return boolean * @return boolean
*/ */
boolean goodsEditSkuDel(String skuId); boolean goodsEditSkuDel(String storeId, String skuId);
/** /**
* 商品管理:商品编辑:SKU批改 * 商品管理:商品编辑:SKU批改
......
...@@ -49,7 +49,7 @@ public class GoblinGoods implements Serializable { ...@@ -49,7 +49,7 @@ public class GoblinGoods implements Serializable {
private String subtitle; private String subtitle;
/** /**
* 销售价 * 销售价-原价
*/ */
private BigDecimal sellPrice; private BigDecimal sellPrice;
......
...@@ -43,7 +43,7 @@ public class GoblinGoodsSku implements Serializable { ...@@ -43,7 +43,7 @@ public class GoblinGoodsSku implements Serializable {
private String subtitle; private String subtitle;
/** /**
* 单品销售价 * 单品销售价-原价
*/ */
private BigDecimal sellPrice; private BigDecimal sellPrice;
...@@ -73,7 +73,7 @@ public class GoblinGoodsSku implements Serializable { ...@@ -73,7 +73,7 @@ public class GoblinGoodsSku implements Serializable {
private Integer warningStock; private Integer warningStock;
/** /**
* 单品价格 * 单品现价
*/ */
private BigDecimal price; private BigDecimal price;
......
...@@ -252,7 +252,7 @@ create table goblin_goods ...@@ -252,7 +252,7 @@ create table goblin_goods
name varchar(100) not null comment '商品名称', name varchar(100) not null comment '商品名称',
subtitle varchar(128) null comment '商品副标题', subtitle varchar(128) null comment '商品副标题',
sell_price decimal(20, 2) null comment '销售价', sell_price decimal(20, 2) null comment '销售价-原价',
price_ge decimal(20, 2) null comment '价格区间MIN', price_ge decimal(20, 2) null comment '价格区间MIN',
price_le decimal(20, 2) null comment '价格区间MAX', price_le decimal(20, 2) null comment '价格区间MAX',
intro varchar(256) null comment '商品简介', intro varchar(256) null comment '商品简介',
...@@ -303,14 +303,14 @@ create table goblin_goods_sku ...@@ -303,14 +303,14 @@ create table goblin_goods_sku
sku_no varchar(45) not null comment '单品的编号', sku_no varchar(45) not null comment '单品的编号',
name varchar(100) not null comment '单品的名称', name varchar(100) not null comment '单品的名称',
subtitle varchar(128) null comment '单品的副标题', subtitle varchar(128) null comment '单品的副标题',
sell_price decimal(20, 2) null comment '单品销售价', sell_price decimal(20, 2) null comment '单品销售价-原价',
sku_pic varchar(256) null comment '单品默认图片的url', sku_pic varchar(256) null comment '单品默认图片的url',
sku_isbn varchar(50) null comment 'ISBN,针对CD/图书等', sku_isbn varchar(50) null comment 'ISBN,针对CD/图书等',
stock int not null comment '总库存', stock int not null comment '总库存',
sku_stock int not null comment '单品库存', sku_stock int not null comment '单品库存',
warning_stock int null comment '预警库存', warning_stock int null comment '预警库存',
price decimal(20, 2) not null comment '单品价格', price decimal(20, 2) not null comment '单品现价',
price_member decimal(20, 2) not null comment '单品会员价格', price_member decimal(20, 2) not null comment '单品会员价格',
weight decimal(20, 2) not null comment '单品的重量', weight decimal(20, 2) not null comment '单品的重量',
buy_factor char default '0' comment '购买限制[0-全部用户|1-仅会员|2-指定用户]', buy_factor char default '0' comment '购买限制[0-全部用户|1-仅会员|2-指定用户]',
......
...@@ -2,6 +2,7 @@ package com.liquidnet.service.goblin.controller; ...@@ -2,6 +2,7 @@ package com.liquidnet.service.goblin.controller;
import com.liquidnet.common.cache.redis.util.RedisUtil; import com.liquidnet.common.cache.redis.util.RedisUtil;
import com.liquidnet.service.base.ResponseDto; import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.goblin.dto.vo.GoblinFrontGoodDetailVo;
import com.liquidnet.service.goblin.service.impl.GoblinFrontServiceImpl; import com.liquidnet.service.goblin.service.impl.GoblinFrontServiceImpl;
import com.liquidnet.service.goblin.util.GoblinRedisUtils; import com.liquidnet.service.goblin.util.GoblinRedisUtils;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -57,6 +58,12 @@ public class GoblinFrontController { ...@@ -57,6 +58,12 @@ public class GoblinFrontController {
public ResponseDto getSelectGoods(@RequestParam(name = "pageSize", required = true) int pageSize, @RequestParam(name = "pageNumber", required = true)int pageNumber) throws ParseException { public ResponseDto getSelectGoods(@RequestParam(name = "pageSize", required = true) int pageSize, @RequestParam(name = "pageNumber", required = true)int pageNumber) throws ParseException {
return ResponseDto.success( goblinFrontService.getSelectGoods(pageNumber,pageSize)); return ResponseDto.success( goblinFrontService.getSelectGoods(pageNumber,pageSize));
} }
@GetMapping("getGoodsDetail")
@ApiOperation("获得商品详情")
public ResponseDto<GoblinFrontGoodDetailVo> getGoodsDetail(@RequestParam(name = "spuId", required = true) String spuId) throws ParseException {
return ResponseDto.success( goblinFrontService.getGoodsDetail(spuId));
}
......
...@@ -4,6 +4,7 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; ...@@ -4,6 +4,7 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport; import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import com.liquidnet.commons.lang.util.CurrentUtil; import com.liquidnet.commons.lang.util.CurrentUtil;
import com.liquidnet.commons.lang.util.JsonUtils; import com.liquidnet.commons.lang.util.JsonUtils;
import com.liquidnet.service.base.ErrorMapping;
import com.liquidnet.service.base.ResponseDto; import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.goblin.dto.manage.GoblinStoreMgtCertificationParam; import com.liquidnet.service.goblin.dto.manage.GoblinStoreMgtCertificationParam;
import com.liquidnet.service.goblin.dto.manage.GoblinStoreMgtCompleteParam; import com.liquidnet.service.goblin.dto.manage.GoblinStoreMgtCompleteParam;
...@@ -78,10 +79,13 @@ public class GoblinStoreMgtCertificationController { ...@@ -78,10 +79,13 @@ public class GoblinStoreMgtCertificationController {
@ApiOperation(value = "店铺认证编辑中:删除店铺") @ApiOperation(value = "店铺认证编辑中:删除店铺")
@PostMapping("cancel") @PostMapping("cancel")
public ResponseDto<Object> certificationCancel(String storeId) { public ResponseDto<Object> certificationCancel(String storeId) {
if (!goblinRedisUtils.hasStoreId(CurrentUtil.getCurrentUid(), storeId)) {
return ResponseDto.failure(ErrorMapping.get("149002"));
}
GoblinStoreInfoVo storeInfoVo = goblinRedisUtils.getStoreInfoVo(storeId); GoblinStoreInfoVo storeInfoVo = goblinRedisUtils.getStoreInfoVo(storeId);
if (null != storeInfoVo) { if (null != storeInfoVo) {
if (goblinMongoUtils.delStoreInfoVo(storeId)) { if (goblinMongoUtils.delStoreInfoVo(storeId)) {
goblinRedisUtils.delStoreIdByUid(CurrentUtil.getCurrentUid()); goblinRedisUtils.delStoreId(CurrentUtil.getCurrentUid(), storeId);
goblinRedisUtils.delStoreInfoVo(storeId); goblinRedisUtils.delStoreInfoVo(storeId);
} }
} }
......
...@@ -2,6 +2,8 @@ package com.liquidnet.service.goblin.controller.manage; ...@@ -2,6 +2,8 @@ package com.liquidnet.service.goblin.controller.manage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport; 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.commons.lang.util.JsonUtils;
import com.liquidnet.service.base.ErrorMapping; import com.liquidnet.service.base.ErrorMapping;
import com.liquidnet.service.base.PagedResult; import com.liquidnet.service.base.PagedResult;
...@@ -23,11 +25,13 @@ import io.swagger.annotations.ApiOperation; ...@@ -23,11 +25,13 @@ import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.validation.Valid; import javax.validation.Valid;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import java.util.List;
@ApiSupport(order = 149003) @ApiSupport(order = 149003)
@Api(tags = "商品管理") @Api(tags = "商品管理")
...@@ -45,9 +49,19 @@ public class GoblinStoreMgtGoodsController { ...@@ -45,9 +49,19 @@ public class GoblinStoreMgtGoodsController {
@ApiOperation(value = "SPU列表") @ApiOperation(value = "SPU列表")
@PostMapping("list") @PostMapping("list")
public ResponseDto<PagedResult<GoblinStoreMgtGoodsListVo>> list(@Valid @RequestBody GoblinStoreMgtGoodsFilterParam storeMgtGoodsFilterParam) { public ResponseDto<PagedResult<GoblinStoreMgtGoodsListVo>> list(@Valid @RequestBody GoblinStoreMgtGoodsFilterParam storeMgtGoodsFilterParam) {
List<String> storeIds = goblinRedisUtils.getStoreIds(CurrentUtil.getCurrentUid());
boolean storeIdIsBlank = StringUtils.isBlank(storeMgtGoodsFilterParam.getStoreId());
if (CollectionUtils.isEmpty(storeIds) || (
!storeIdIsBlank && !goblinRedisUtils.hasStoreId(CurrentUtil.getCurrentUid(), storeMgtGoodsFilterParam.getStoreId())
)) {
return ResponseDto.success();
}
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("商品管理:SPU列表:[GoblinStoreMgtGoodsFilterParam={}]", JsonUtils.toJson(storeMgtGoodsFilterParam)); log.debug("商品管理:SPU列表:[GoblinStoreMgtGoodsFilterParam={}]", JsonUtils.toJson(storeMgtGoodsFilterParam));
} }
if (storeIdIsBlank) {
storeMgtGoodsFilterParam.setStoreId(storeIds.get(0));
}
return ResponseDto.success(goblinstoreMgtGoodsService.goodsList(storeMgtGoodsFilterParam)); return ResponseDto.success(goblinstoreMgtGoodsService.goodsList(storeMgtGoodsFilterParam));
} }
...@@ -55,9 +69,20 @@ public class GoblinStoreMgtGoodsController { ...@@ -55,9 +69,20 @@ public class GoblinStoreMgtGoodsController {
@ApiOperation(value = "SPU导出") @ApiOperation(value = "SPU导出")
@PostMapping("export") @PostMapping("export")
public void export(@Valid @RequestBody GoblinStoreMgtGoodsFilterParam storeMgtGoodsFilterParam) { public void export(@Valid @RequestBody GoblinStoreMgtGoodsFilterParam storeMgtGoodsFilterParam) {
List<String> storeIds = goblinRedisUtils.getStoreIds(CurrentUtil.getCurrentUid());
boolean storeIdIsBlank = StringUtils.isBlank(storeMgtGoodsFilterParam.getStoreId());
if (CollectionUtils.isEmpty(storeIds) || (
!storeIdIsBlank && !goblinRedisUtils.hasStoreId(CurrentUtil.getCurrentUid(), storeMgtGoodsFilterParam.getStoreId())
)) {
return;
}
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("商品管理:SPU导出:[GoblinStoreMgtGoodsFilterParam={}]", JsonUtils.toJson(storeMgtGoodsFilterParam)); log.debug("商品管理:SPU导出:[GoblinStoreMgtGoodsFilterParam={}]", JsonUtils.toJson(storeMgtGoodsFilterParam));
} }
if (storeIdIsBlank) {
storeMgtGoodsFilterParam.setStoreId(storeIds.get(0));
}
log.info("商品管理:SPU导出..."); log.info("商品管理:SPU导出...");
// TODO: 2021/12/28 zhanggb // TODO: 2021/12/28 zhanggb
} }
...@@ -66,6 +91,9 @@ public class GoblinStoreMgtGoodsController { ...@@ -66,6 +91,9 @@ public class GoblinStoreMgtGoodsController {
@ApiOperation(value = "SPU管理") @ApiOperation(value = "SPU管理")
@PostMapping("operate") @PostMapping("operate")
public ResponseDto<Object> action(@Valid @RequestBody GoblinStoreMgtGoodsActionParam storeMgtGoodsActionParam) { public ResponseDto<Object> action(@Valid @RequestBody GoblinStoreMgtGoodsActionParam storeMgtGoodsActionParam) {
if (!goblinRedisUtils.hasStoreId(CurrentUtil.getCurrentUid(), storeMgtGoodsActionParam.getStoreId())) {
return ResponseDto.failure(ErrorMapping.get("149002"));
}
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("商品管理:管理SPU:[GoblinStoreMgtGoodsActionParam={}]", JsonUtils.toJson(storeMgtGoodsActionParam)); log.debug("商品管理:管理SPU:[GoblinStoreMgtGoodsActionParam={}]", JsonUtils.toJson(storeMgtGoodsActionParam));
} }
...@@ -92,6 +120,9 @@ public class GoblinStoreMgtGoodsController { ...@@ -92,6 +120,9 @@ public class GoblinStoreMgtGoodsController {
@ApiOperation(value = "SPU添加") @ApiOperation(value = "SPU添加")
@PutMapping("add") @PutMapping("add")
public ResponseDto<Object> add(@Valid @RequestBody GoblinStoreMgtGoodsAddParam storeMgtGoodsAddParam) { public ResponseDto<Object> add(@Valid @RequestBody GoblinStoreMgtGoodsAddParam storeMgtGoodsAddParam) {
if (!goblinRedisUtils.hasStoreId(CurrentUtil.getCurrentUid(), storeMgtGoodsAddParam.getStoreId())) {
return ResponseDto.failure(ErrorMapping.get("149002"));
}
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("商品管理:添加SPU:[GoblinStoreMgtGoodsAddParam={}]", JsonUtils.toJson(storeMgtGoodsAddParam)); log.debug("商品管理:添加SPU:[GoblinStoreMgtGoodsAddParam={}]", JsonUtils.toJson(storeMgtGoodsAddParam));
} }
...@@ -102,21 +133,26 @@ public class GoblinStoreMgtGoodsController { ...@@ -102,21 +133,26 @@ public class GoblinStoreMgtGoodsController {
@ApiOperationSupport(order = 5) @ApiOperationSupport(order = 5)
@ApiOperation(value = "SPU详情") @ApiOperation(value = "SPU详情")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "storeId", value = "店铺ID"),
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "spuId", value = "商品ID"), @ApiImplicitParam(type = "form", required = true, dataType = "String", name = "spuId", value = "商品ID"),
}) })
@GetMapping("info") @GetMapping("info")
public ResponseDto<GoblinStoreMgtGoodsInfoVo> info(String spuId) { public ResponseDto<GoblinStoreMgtGoodsInfoVo> info(@NotBlank(message = "店铺ID不能为空") @RequestParam String storeId,
@NotBlank(message = "商品ID不能为空") @RequestParam String spuId) {
if (!goblinRedisUtils.hasStoreId(CurrentUtil.getCurrentUid(), storeId)) {
return ResponseDto.failure(ErrorMapping.get("149002"));
}
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("商品管理:SPU详情:[spuId={}]", spuId); log.debug("商品管理:SPU详情:[spuId={}]", spuId);
} }
return ResponseDto.success(goblinstoreMgtGoodsService.goodsInfo(spuId)); return ResponseDto.success(goblinstoreMgtGoodsService.goodsInfo(storeId, spuId));
} }
@ApiOperationSupport(order = 6) @ApiOperationSupport(order = 6)
@ApiOperation(value = "商品编辑:SPU编辑", notes = "只修改商品信息,不包含规格相关信息") @ApiOperation(value = "商品编辑:SPU编辑", notes = "只修改商品信息,不包含规格相关信息")
@PostMapping("edit_spu") @PostMapping("edit_spu")
public ResponseDto<Object> editSpu(@Valid @RequestBody GoblinStoreMgtGoodsAddParam storeMgtGoodsAddParam) { public ResponseDto<Object> editSpu(@Valid @RequestBody GoblinStoreMgtGoodsAddParam storeMgtGoodsAddParam) {
if (StringUtils.isBlank(storeMgtGoodsAddParam.getStoreId())) { if (!goblinRedisUtils.hasStoreId(CurrentUtil.getCurrentUid(), storeMgtGoodsAddParam.getStoreId())) {
return ResponseDto.failure(ErrorMapping.get("149002")); return ResponseDto.failure(ErrorMapping.get("149002"));
} }
if (StringUtils.isBlank(storeMgtGoodsAddParam.getSpuId()) || null == goblinRedisUtils.getGoodsInfoVo(storeMgtGoodsAddParam.getSpuId())) { if (StringUtils.isBlank(storeMgtGoodsAddParam.getSpuId()) || null == goblinRedisUtils.getGoodsInfoVo(storeMgtGoodsAddParam.getSpuId())) {
...@@ -132,7 +168,7 @@ public class GoblinStoreMgtGoodsController { ...@@ -132,7 +168,7 @@ public class GoblinStoreMgtGoodsController {
@ApiOperation(value = "商品编辑:SKU编辑", notes = "只修改单品信息,不包含商品信息") @ApiOperation(value = "商品编辑:SKU编辑", notes = "只修改单品信息,不包含商品信息")
@PostMapping("edit_sku") @PostMapping("edit_sku")
public ResponseDto<Object> editSku(@Valid @RequestBody GoblinStoreMgtGoodsEditSkuParam storeMgtGoodsEditSkuParam) { public ResponseDto<Object> editSku(@Valid @RequestBody GoblinStoreMgtGoodsEditSkuParam storeMgtGoodsEditSkuParam) {
if (StringUtils.isBlank(storeMgtGoodsEditSkuParam.getStoreId())) { if (!goblinRedisUtils.hasStoreId(CurrentUtil.getCurrentUid(), storeMgtGoodsEditSkuParam.getStoreId())) {
return ResponseDto.failure(ErrorMapping.get("149002")); return ResponseDto.failure(ErrorMapping.get("149002"));
} }
GoblinGoodsSkuInfoVo goodsSkuInfoVo = goblinRedisUtils.getGoodsSkuInfoVo(storeMgtGoodsEditSkuParam.getSkuId()); GoblinGoodsSkuInfoVo goodsSkuInfoVo = goblinRedisUtils.getGoodsSkuInfoVo(storeMgtGoodsEditSkuParam.getSkuId());
...@@ -188,6 +224,9 @@ public class GoblinStoreMgtGoodsController { ...@@ -188,6 +224,9 @@ public class GoblinStoreMgtGoodsController {
@ApiOperation(value = "商品编辑:SKU添加") @ApiOperation(value = "商品编辑:SKU添加")
@PutMapping("edit_sku/add") @PutMapping("edit_sku/add")
public ResponseDto<Object> editSkuAdd(@Valid @RequestBody GoblinStoreMgtGoodsEditSkuParam storeMgtGoodsEditSkuParam) { public ResponseDto<Object> editSkuAdd(@Valid @RequestBody GoblinStoreMgtGoodsEditSkuParam storeMgtGoodsEditSkuParam) {
if (!goblinRedisUtils.hasStoreId(CurrentUtil.getCurrentUid(), storeMgtGoodsEditSkuParam.getStoreId())) {
return ResponseDto.failure(ErrorMapping.get("149002"));
}
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("商品管理:商品编辑:编辑SKU:[GoblinStoreMgtGoodsEditSkuParam={}]", JsonUtils.toJson(storeMgtGoodsEditSkuParam)); log.debug("商品管理:商品编辑:编辑SKU:[GoblinStoreMgtGoodsEditSkuParam={}]", JsonUtils.toJson(storeMgtGoodsEditSkuParam));
} }
...@@ -205,7 +244,10 @@ public class GoblinStoreMgtGoodsController { ...@@ -205,7 +244,10 @@ public class GoblinStoreMgtGoodsController {
@PostMapping("edit_sku/del") @PostMapping("edit_sku/del")
public ResponseDto<Object> editSkuDel(@NotBlank(message = "店铺ID不能为空") String storeId, public ResponseDto<Object> editSkuDel(@NotBlank(message = "店铺ID不能为空") String storeId,
@NotBlank(message = "单品ID不能为空") String skuId) { @NotBlank(message = "单品ID不能为空") String skuId) {
return ResponseDto.success(goblinstoreMgtGoodsService.goodsEditSkuDel(skuId)); if (!goblinRedisUtils.hasStoreId(CurrentUtil.getCurrentUid(), storeId)) {
return ResponseDto.failure(ErrorMapping.get("149002"));
}
return ResponseDto.success(goblinstoreMgtGoodsService.goodsEditSkuDel(storeId, skuId));
} }
@ApiOperationSupport(order = 10) @ApiOperationSupport(order = 10)
...@@ -221,6 +263,9 @@ public class GoblinStoreMgtGoodsController { ...@@ -221,6 +263,9 @@ public class GoblinStoreMgtGoodsController {
@NotBlank(message = "商品ID不能为空") String spuId, @NotBlank(message = "商品ID不能为空") String spuId,
@NotBlank(message = "批量修改属性不能为空") String batField, @NotBlank(message = "批量修改属性不能为空") String batField,
@NotBlank(message = "批量修改属性值不能为空") String batFieldVal) { @NotBlank(message = "批量修改属性值不能为空") String batFieldVal) {
if (!goblinRedisUtils.hasStoreId(CurrentUtil.getCurrentUid(), storeId)) {
return ResponseDto.failure(ErrorMapping.get("149002"));
}
return ResponseDto.success(goblinstoreMgtGoodsService.goodsEditSkuBat(spuId, batField, batFieldVal)); return ResponseDto.success(goblinstoreMgtGoodsService.goodsEditSkuBat(spuId, batField, batFieldVal));
} }
} }
...@@ -187,6 +187,16 @@ public class GoblinFrontServiceImpl implements GoblinFrontService { ...@@ -187,6 +187,16 @@ public class GoblinFrontServiceImpl implements GoblinFrontService {
} }
return goblinFrontSeckillVo; return goblinFrontSeckillVo;
} }
/**
* 获得商品详情
*/
public GoblinFrontGoodDetailVo getGoodsDetail(String spuId){
GoblinFrontGoodDetailVo goblinFrontGoodDetailVo=GoblinFrontGoodDetailVo.getNew();
GoblinGoodsInfoVo goblinGoodsInfoVo=goblinRedisUtils.getGoodsInfoVo(spuId);
goblinFrontGoodDetailVo.setGoblinGoodsInfoVo(goblinGoodsInfoVo);
return goblinFrontGoodDetailVo;
}
/** /**
* @author zhangfuxin * @author zhangfuxin
......
...@@ -3,7 +3,6 @@ package com.liquidnet.service.goblin.service.impl.manage; ...@@ -3,7 +3,6 @@ package com.liquidnet.service.goblin.service.impl.manage;
import com.liquidnet.commons.lang.util.CollectionUtil; import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.commons.lang.util.CurrentUtil; import com.liquidnet.commons.lang.util.CurrentUtil;
import com.liquidnet.service.base.PagedResult; import com.liquidnet.service.base.PagedResult;
import com.liquidnet.service.goblin.dto.GoblinGoodsSpecDto;
import com.liquidnet.service.goblin.dto.manage.GoblinStoreMgtGoodsActionParam; import com.liquidnet.service.goblin.dto.manage.GoblinStoreMgtGoodsActionParam;
import com.liquidnet.service.goblin.dto.manage.GoblinStoreMgtGoodsAddParam; import com.liquidnet.service.goblin.dto.manage.GoblinStoreMgtGoodsAddParam;
import com.liquidnet.service.goblin.dto.manage.GoblinStoreMgtGoodsEditSkuParam; import com.liquidnet.service.goblin.dto.manage.GoblinStoreMgtGoodsEditSkuParam;
...@@ -97,7 +96,7 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi ...@@ -97,7 +96,7 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi
} }
@Override @Override
public GoblinStoreMgtGoodsInfoVo goodsInfo(String spuId) { public GoblinStoreMgtGoodsInfoVo goodsInfo(String storeId, String spuId) {
GoblinStoreMgtGoodsInfoVo vo = GoblinStoreMgtGoodsInfoVo.getNew(); GoblinStoreMgtGoodsInfoVo vo = GoblinStoreMgtGoodsInfoVo.getNew();
GoblinGoodsInfoVo goodsInfoVo = goblinRedisUtils.getMgtGoodsInfoVo(spuId); GoblinGoodsInfoVo goodsInfoVo = goblinRedisUtils.getMgtGoodsInfoVo(spuId);
if (null != goodsInfoVo) { if (null != goodsInfoVo) {
...@@ -114,8 +113,17 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi ...@@ -114,8 +113,17 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi
@Override @Override
public boolean goodsEditSpu(GoblinStoreMgtGoodsAddParam storeMgtGoodsAddParam) { public boolean goodsEditSpu(GoblinStoreMgtGoodsAddParam storeMgtGoodsAddParam) {
GoblinGoodsInfoVo editGoodsSkuInfoVo = storeMgtGoodsAddParam.initEditGoodsSkuInfoVo(); GoblinGoodsInfoVo editGoodsSkuInfoVo = storeMgtGoodsAddParam.initEditGoodsInfoVo();
if (goblinMongoUtils.updateGoodsInfoVo(editGoodsSkuInfoVo)) { if (goblinMongoUtils.updateGoodsInfoVo(editGoodsSkuInfoVo)) {
GoblinGoodsSkuInfoVo updateSkuInfoVo = GoblinGoodsSkuInfoVo.getNew();
updateSkuInfoVo.setSpuId(editGoodsSkuInfoVo.getSpuId());
updateSkuInfoVo.setSkuNo(editGoodsSkuInfoVo.getSpuNo());
updateSkuInfoVo.setName(editGoodsSkuInfoVo.getName());
updateSkuInfoVo.setSubtitle(editGoodsSkuInfoVo.getSubtitle());
updateSkuInfoVo.setVirtualFlg(editGoodsSkuInfoVo.getVirtualFlg());
updateSkuInfoVo.setLogisticsTemplate(editGoodsSkuInfoVo.getLogisticsTemplate());
goblinMongoUtils.updateGoodsSkuInfoVoBySpuId(updateSkuInfoVo);
// TODO: 2022/1/5 zhanggb redis+sql // TODO: 2022/1/5 zhanggb redis+sql
return true; return true;
...@@ -140,7 +148,7 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi ...@@ -140,7 +148,7 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi
} }
@Override @Override
public boolean goodsEditSkuDel(String skuId) { public boolean goodsEditSkuDel(String storeId, String skuId) {
// TODO: 2022/1/5 zhanggb // TODO: 2022/1/5 zhanggb
return false; return false;
} }
......
...@@ -217,6 +217,14 @@ public class GoblinMongoUtils { ...@@ -217,6 +217,14 @@ public class GoblinMongoUtils {
).getModifiedCount() > 0; ).getModifiedCount() > 0;
} }
public boolean updateGoodsSkuInfoVoBySpuId(GoblinGoodsSkuInfoVo vo) {
return mongoTemplate.getCollection(GoblinGoodsSkuInfoVo.class.getSimpleName())
.updateOne(
Query.query(Criteria.where("spuId").is(vo.getSpuId())).getQueryObject(),
ObjectUtil.cloneBasicDBObject().append("$set", mongoConverter.convertToMongoType(vo))
).getModifiedCount() > 0;
}
/* ---------------------------------------- ---------------------------------------- */ /* ---------------------------------------- ---------------------------------------- */
/** /**
......
...@@ -2,16 +2,15 @@ package com.liquidnet.service.goblin.util; ...@@ -2,16 +2,15 @@ package com.liquidnet.service.goblin.util;
import com.liquidnet.common.cache.redis.util.RedisUtil; import com.liquidnet.common.cache.redis.util.RedisUtil;
import com.liquidnet.commons.lang.util.CollectionUtil; import com.liquidnet.commons.lang.util.CollectionUtil;
import com.liquidnet.commons.lang.util.DateUtil;
import com.liquidnet.commons.lang.util.RandomUtil; import com.liquidnet.commons.lang.util.RandomUtil;
import com.liquidnet.service.goblin.constant.GoblinRedisConst; import com.liquidnet.service.goblin.constant.GoblinRedisConst;
import com.liquidnet.service.goblin.dto.vo.*; import com.liquidnet.service.goblin.dto.vo.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
@Component @Component
...@@ -66,20 +65,39 @@ public class GoblinRedisUtils { ...@@ -66,20 +65,39 @@ public class GoblinRedisUtils {
/* ---------------------------------------- 店铺数据源 ---------------------------------------- */ /* ---------------------------------------- 店铺数据源 ---------------------------------------- */
private boolean setStoreIdByUid(String uid, String storeId) { private boolean setStoreIds(String uid, List<String> storeIds) {
return redisUtil.set(GoblinRedisConst.TMP_UID_STORE.concat(uid), storeId); return redisUtil.set(GoblinRedisConst.BASIC_USTORE.concat(uid), storeIds);
} }
public void delStoreIdByUid(String uid) { public void delStoreIds(String uid) {
redisUtil.del(GoblinRedisConst.TMP_UID_STORE.concat(uid)); redisUtil.del(GoblinRedisConst.BASIC_USTORE.concat(uid));
} }
private String getStoreIdByUid(String uid) { public void delStoreId(String uid, String storeId) {
return (String) redisUtil.get(GoblinRedisConst.TMP_UID_STORE.concat(uid)); List<String> storeIds = this.getStoreIds(uid);
if (!CollectionUtils.isEmpty(storeIds)) {
storeIds.removeIf(r -> r.equals(storeId));
this.setStoreIds(uid, storeIds);
}
}
public List<String> getStoreIds(String uid) {
// return (List<String>) redisUtil.get(GoblinRedisConst.BASIC_USTORE.concat(uid));
return Arrays.asList("1");// TODO: 2022/1/5 zhanggb
}
public boolean hasStoreId(String uid, String storeId) {
List<String> list = this.getStoreIds(uid);
return !CollectionUtils.isEmpty(list) && list.contains(storeId);
} }
public boolean setStoreInfoVo(GoblinStoreInfoVo vo) { public boolean setStoreInfoVo(GoblinStoreInfoVo vo) {
this.setStoreIdByUid(vo.getUid(), vo.getStoreId()); List<String> storeIds = this.getStoreIds(vo.getUid());
if (CollectionUtils.isEmpty(storeIds)) {
storeIds = CollectionUtil.arrayListString();
}
storeIds.add(vo.getStoreId());
this.setStoreIds(vo.getUid(), storeIds);
return redisUtil.set(GoblinRedisConst.BASIC_STORE.concat(vo.getStoreId()), vo); return redisUtil.set(GoblinRedisConst.BASIC_STORE.concat(vo.getStoreId()), vo);
} }
...@@ -97,8 +115,8 @@ public class GoblinRedisUtils { ...@@ -97,8 +115,8 @@ public class GoblinRedisUtils {
} }
public GoblinStoreInfoVo getStoreInfoVoByUid(String uid) { public GoblinStoreInfoVo getStoreInfoVoByUid(String uid) {
String storeId = this.getStoreIdByUid(uid); List<String> storeIds = this.getStoreIds(uid);
return null == storeId ? goblinMongoUtils.getStoreInfoVoByUid(uid) : this.getStoreInfoVo(storeId); return CollectionUtils.isEmpty(storeIds) ? goblinMongoUtils.getStoreInfoVoByUid(uid) : this.getStoreInfoVo(storeIds.get(0));
} }
/* ---------------------------------------- 商品数据源 ---------------------------------------- */ /* ---------------------------------------- 商品数据源 ---------------------------------------- */
......
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