commit
3e33f9b363
@ -44,3 +44,5 @@ CREATE TABLE `li_wholesale`
|
|||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin COMMENT '批发规则表';
|
) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_bin COMMENT '批发规则表';
|
||||||
|
|
||||||
|
ALTER TABLE li_wholesale
|
||||||
|
ADD template_id bigint DEFAULT NULL COMMENT '商品模版id';
|
||||||
|
@ -36,7 +36,8 @@ public class MemberCouponExecute implements OrderStatusChangeEvent {
|
|||||||
Order order = orderService.getBySn(orderMessage.getOrderSn());
|
Order order = orderService.getBySn(orderMessage.getOrderSn());
|
||||||
if (CharSequenceUtil.isNotEmpty(order.getUseStoreMemberCouponIds())) {
|
if (CharSequenceUtil.isNotEmpty(order.getUseStoreMemberCouponIds())) {
|
||||||
memberCouponService.recoveryMemberCoupon(ListUtil.toList(order.getUseStoreMemberCouponIds().split(",")));
|
memberCouponService.recoveryMemberCoupon(ListUtil.toList(order.getUseStoreMemberCouponIds().split(",")));
|
||||||
} else if (CharSequenceUtil.isNotEmpty(order.getUsePlatformMemberCouponId())) {
|
}
|
||||||
|
if (CharSequenceUtil.isNotEmpty(order.getUsePlatformMemberCouponId())) {
|
||||||
memberCouponService.recoveryMemberCoupon(ListUtil.toList(order.getUsePlatformMemberCouponId().split(",")));
|
memberCouponService.recoveryMemberCoupon(ListUtil.toList(order.getUsePlatformMemberCouponId().split(",")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ public class DraftGoods extends BaseEntity {
|
|||||||
private String goodsVideo;
|
private String goodsVideo;
|
||||||
|
|
||||||
@ApiModelProperty(value = "是否为推荐商品")
|
@ApiModelProperty(value = "是否为推荐商品")
|
||||||
private boolean recommend;
|
private Boolean recommend;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see cn.lili.modules.goods.entity.enums.GoodsSalesModeEnum
|
* @see cn.lili.modules.goods.entity.enums.GoodsSalesModeEnum
|
||||||
|
@ -6,6 +6,7 @@ import cn.hutool.http.HtmlUtil;
|
|||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import cn.lili.common.enums.ResultCode;
|
import cn.lili.common.enums.ResultCode;
|
||||||
import cn.lili.common.exception.ServiceException;
|
import cn.lili.common.exception.ServiceException;
|
||||||
|
import cn.lili.modules.goods.entity.dto.DraftGoodsDTO;
|
||||||
import cn.lili.modules.goods.entity.dto.GoodsOperationDTO;
|
import cn.lili.modules.goods.entity.dto.GoodsOperationDTO;
|
||||||
import cn.lili.modules.goods.entity.enums.GoodsAuthEnum;
|
import cn.lili.modules.goods.entity.enums.GoodsAuthEnum;
|
||||||
import cn.lili.modules.goods.entity.enums.GoodsSalesModeEnum;
|
import cn.lili.modules.goods.entity.enums.GoodsSalesModeEnum;
|
||||||
@ -204,6 +205,30 @@ public class Goods extends BaseEntity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Goods(DraftGoodsDTO goodsDTO) {
|
||||||
|
this.goodsName = goodsDTO.getGoodsName();
|
||||||
|
this.categoryPath = goodsDTO.getCategoryPath();
|
||||||
|
this.storeCategoryPath = goodsDTO.getStoreCategoryPath();
|
||||||
|
this.brandId = goodsDTO.getBrandId();
|
||||||
|
this.templateId = goodsDTO.getTemplateId();
|
||||||
|
this.recommend = goodsDTO.getRecommend();
|
||||||
|
this.sellingPoint = goodsDTO.getSellingPoint();
|
||||||
|
this.salesModel = goodsDTO.getSalesModel();
|
||||||
|
this.goodsUnit = goodsDTO.getGoodsUnit();
|
||||||
|
this.intro = goodsDTO.getIntro();
|
||||||
|
this.mobileIntro = goodsDTO.getMobileIntro();
|
||||||
|
this.goodsVideo = goodsDTO.getGoodsVideo();
|
||||||
|
this.price = goodsDTO.getPrice();
|
||||||
|
if (goodsDTO.getGoodsParamsDTOList() != null && goodsDTO.getGoodsParamsDTOList().isEmpty()) {
|
||||||
|
this.params = JSONUtil.toJsonStr(goodsDTO.getGoodsParamsDTOList());
|
||||||
|
}
|
||||||
|
//如果立即上架则
|
||||||
|
this.marketEnable = GoodsStatusEnum.DOWN.name();
|
||||||
|
this.goodsType = goodsDTO.getGoodsType();
|
||||||
|
this.grade = 100D;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public String getIntro() {
|
public String getIntro() {
|
||||||
if (CharSequenceUtil.isNotEmpty(intro)) {
|
if (CharSequenceUtil.isNotEmpty(intro)) {
|
||||||
return HtmlUtil.unescape(intro);
|
return HtmlUtil.unescape(intro);
|
||||||
|
@ -23,6 +23,8 @@ public class Wholesale extends BaseIdEntity {
|
|||||||
private String goodsId;
|
private String goodsId;
|
||||||
@ApiModelProperty(value = "SkuID")
|
@ApiModelProperty(value = "SkuID")
|
||||||
private String skuId;
|
private String skuId;
|
||||||
|
@ApiModelProperty(value = "模版id")
|
||||||
|
private String templateId;
|
||||||
@ApiModelProperty(value = "数量")
|
@ApiModelProperty(value = "数量")
|
||||||
private Integer num;
|
private Integer num;
|
||||||
@ApiModelProperty(value = "金额")
|
@ApiModelProperty(value = "金额")
|
||||||
|
@ -30,4 +30,10 @@ public class DraftGoodsDTO extends DraftGoods {
|
|||||||
@Valid
|
@Valid
|
||||||
private List<Map<String, Object>> skuList;
|
private List<Map<String, Object>> skuList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批发商品规则
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "批发商品规则")
|
||||||
|
private List<WholesaleDTO> wholesaleList;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package cn.lili.modules.goods.entity.dto;
|
package cn.lili.modules.goods.entity.dto;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import cn.lili.modules.goods.entity.enums.DraftGoodsSaveType;
|
import cn.lili.modules.goods.entity.enums.DraftGoodsSaveType;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
@ -26,7 +26,7 @@ public class DraftGoodsSearchParams extends GoodsSearchParams {
|
|||||||
@Override
|
@Override
|
||||||
public <T> QueryWrapper<T> queryWrapper() {
|
public <T> QueryWrapper<T> queryWrapper() {
|
||||||
QueryWrapper<T> queryWrapper = super.queryWrapper();
|
QueryWrapper<T> queryWrapper = super.queryWrapper();
|
||||||
if (StrUtil.isNotEmpty(saveType)) {
|
if (CharSequenceUtil.isNotEmpty(saveType)) {
|
||||||
queryWrapper.eq("save_type", saveType);
|
queryWrapper.eq("save_type", saveType);
|
||||||
}
|
}
|
||||||
return queryWrapper;
|
return queryWrapper;
|
||||||
|
@ -2,8 +2,7 @@ package cn.lili.modules.goods.entity.dto;
|
|||||||
|
|
||||||
import cn.lili.common.validation.EnumValue;
|
import cn.lili.common.validation.EnumValue;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.*;
|
||||||
import lombok.ToString;
|
|
||||||
import org.hibernate.validator.constraints.Length;
|
import org.hibernate.validator.constraints.Length;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
@ -20,6 +19,9 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
@ToString
|
@ToString
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
public class GoodsOperationDTO implements Serializable {
|
public class GoodsOperationDTO implements Serializable {
|
||||||
|
|
||||||
private static final long serialVersionUID = -509667581371776913L;
|
private static final long serialVersionUID = -509667581371776913L;
|
||||||
@ -116,6 +118,8 @@ public class GoodsOperationDTO implements Serializable {
|
|||||||
@Valid
|
@Valid
|
||||||
private List<Map<String, Object>> skuList;
|
private List<Map<String, Object>> skuList;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否为商品模版")
|
||||||
|
private Boolean goodsTemplateFlag = false;
|
||||||
/**
|
/**
|
||||||
* 批发商品规则
|
* 批发商品规则
|
||||||
*/
|
*/
|
||||||
|
@ -6,8 +6,7 @@ import cn.lili.modules.goods.entity.enums.GoodsAuthEnum;
|
|||||||
import cn.lili.modules.goods.entity.enums.GoodsStatusEnum;
|
import cn.lili.modules.goods.entity.enums.GoodsStatusEnum;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.*;
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
@ -19,6 +18,9 @@ import java.util.Arrays;
|
|||||||
*/
|
*/
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Data
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
public class GoodsSearchParams extends PageVO {
|
public class GoodsSearchParams extends PageVO {
|
||||||
|
|
||||||
private static final long serialVersionUID = 2544015852728566887L;
|
private static final long serialVersionUID = 2544015852728566887L;
|
||||||
|
@ -3,6 +3,8 @@ package cn.lili.modules.goods.entity.dto;
|
|||||||
import cn.lili.modules.goods.entity.dos.Wholesale;
|
import cn.lili.modules.goods.entity.dos.Wholesale;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author paulG
|
* @author paulG
|
||||||
@ -10,7 +12,12 @@ import lombok.EqualsAndHashCode;
|
|||||||
**/
|
**/
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@NoArgsConstructor
|
||||||
public class WholesaleDTO extends Wholesale {
|
public class WholesaleDTO extends Wholesale {
|
||||||
|
|
||||||
private static final long serialVersionUID = 853297561151783335L;
|
private static final long serialVersionUID = 853297561151783335L;
|
||||||
|
|
||||||
|
public WholesaleDTO(Wholesale wholesale) {
|
||||||
|
BeanUtils.copyProperties(wholesale, this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package cn.lili.modules.goods.entity.vos;
|
package cn.lili.modules.goods.entity.vos;
|
||||||
|
|
||||||
import cn.lili.modules.goods.entity.dos.DraftGoods;
|
import cn.lili.modules.goods.entity.dos.DraftGoods;
|
||||||
|
import cn.lili.modules.goods.entity.dos.Wholesale;
|
||||||
import cn.lili.modules.goods.entity.dto.GoodsParamsDTO;
|
import cn.lili.modules.goods.entity.dto.GoodsParamsDTO;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -29,4 +30,10 @@ public class DraftGoodsVO extends DraftGoods {
|
|||||||
|
|
||||||
@ApiModelProperty(value = "sku列表")
|
@ApiModelProperty(value = "sku列表")
|
||||||
private List<GoodsSkuVO> skuList;
|
private List<GoodsSkuVO> skuList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批发商品规则
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "批发商品规则")
|
||||||
|
private List<Wholesale> wholesaleList;
|
||||||
}
|
}
|
||||||
|
@ -241,4 +241,12 @@ public interface GoodsSkuService extends IService<GoodsSku> {
|
|||||||
* @return sku总数
|
* @return sku总数
|
||||||
*/
|
*/
|
||||||
Long countSkuNum(String storeId);
|
Long countSkuNum(String storeId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量渲染商品sku
|
||||||
|
*
|
||||||
|
* @param goodsSkuList SKU基础数据列表
|
||||||
|
* @param goodsOperationDTO 商品操作信息
|
||||||
|
*/
|
||||||
|
void renderGoodsSkuList(List<GoodsSku> goodsSkuList, GoodsOperationDTO goodsOperationDTO);
|
||||||
}
|
}
|
@ -14,8 +14,13 @@ public interface WholesaleService extends IService<Wholesale> {
|
|||||||
|
|
||||||
List<Wholesale> findByGoodsId(String goodsId);
|
List<Wholesale> findByGoodsId(String goodsId);
|
||||||
|
|
||||||
|
List<Wholesale> findByTemplateId(String templateId);
|
||||||
|
|
||||||
Boolean removeByGoodsId(String goodsId);
|
Boolean removeByGoodsId(String goodsId);
|
||||||
|
|
||||||
|
|
||||||
|
Boolean removeByTemplateId(String templateId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 匹配批发规则
|
* 匹配批发规则
|
||||||
*
|
*
|
||||||
|
@ -1,29 +1,27 @@
|
|||||||
package cn.lili.modules.goods.serviceimpl;
|
package cn.lili.modules.goods.serviceimpl;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.json.JSONArray;
|
import cn.hutool.json.JSONArray;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import cn.lili.modules.goods.entity.dos.Category;
|
import cn.lili.modules.goods.entity.dos.*;
|
||||||
import cn.lili.modules.goods.entity.dos.DraftGoods;
|
|
||||||
import cn.lili.modules.goods.entity.dos.GoodsGallery;
|
|
||||||
import cn.lili.modules.goods.entity.dos.GoodsSku;
|
|
||||||
import cn.lili.modules.goods.entity.dto.DraftGoodsDTO;
|
import cn.lili.modules.goods.entity.dto.DraftGoodsDTO;
|
||||||
import cn.lili.modules.goods.entity.dto.DraftGoodsSearchParams;
|
import cn.lili.modules.goods.entity.dto.DraftGoodsSearchParams;
|
||||||
|
import cn.lili.modules.goods.entity.dto.GoodsOperationDTO;
|
||||||
import cn.lili.modules.goods.entity.dto.GoodsParamsDTO;
|
import cn.lili.modules.goods.entity.dto.GoodsParamsDTO;
|
||||||
import cn.lili.modules.goods.entity.vos.DraftGoodsVO;
|
import cn.lili.modules.goods.entity.vos.DraftGoodsVO;
|
||||||
import cn.lili.modules.goods.mapper.DraftGoodsMapper;
|
import cn.lili.modules.goods.mapper.DraftGoodsMapper;
|
||||||
import cn.lili.modules.goods.service.CategoryService;
|
import cn.lili.modules.goods.service.*;
|
||||||
import cn.lili.modules.goods.service.DraftGoodsService;
|
import cn.lili.modules.goods.sku.GoodsSkuBuilder;
|
||||||
import cn.lili.modules.goods.service.GoodsGalleryService;
|
|
||||||
import cn.lili.modules.goods.service.GoodsSkuService;
|
|
||||||
import cn.lili.mybatis.util.PageUtil;
|
import cn.lili.mybatis.util.PageUtil;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 草稿商品业务层实现
|
* 草稿商品业务层实现
|
||||||
@ -49,6 +47,9 @@ public class DraftGoodsServiceImpl extends ServiceImpl<DraftGoodsMapper, DraftGo
|
|||||||
@Autowired
|
@Autowired
|
||||||
private GoodsSkuService goodsSkuService;
|
private GoodsSkuService goodsSkuService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private WholesaleService wholesaleService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean addGoodsDraft(DraftGoodsDTO draftGoods) {
|
public boolean addGoodsDraft(DraftGoodsDTO draftGoods) {
|
||||||
draftGoods.setGoodsGalleryListJson(JSONUtil.toJsonStr(draftGoods.getGoodsGalleryList()));
|
draftGoods.setGoodsGalleryListJson(JSONUtil.toJsonStr(draftGoods.getGoodsGalleryList()));
|
||||||
@ -75,7 +76,10 @@ public class DraftGoodsServiceImpl extends ServiceImpl<DraftGoodsMapper, DraftGo
|
|||||||
draftGoods.setThumbnail(goodsGallery.getThumbnail());
|
draftGoods.setThumbnail(goodsGallery.getThumbnail());
|
||||||
}
|
}
|
||||||
draftGoods.setGoodsGalleryListJson(JSONUtil.toJsonStr(draftGoods.getGoodsGalleryList()));
|
draftGoods.setGoodsGalleryListJson(JSONUtil.toJsonStr(draftGoods.getGoodsGalleryList()));
|
||||||
draftGoods.setSkuListJson(JSONUtil.toJsonStr(this.getGoodsSkuList(draftGoods.getSkuList())));
|
// 检查是否需要生成索引
|
||||||
|
List<GoodsSku> goodsSkus = GoodsSkuBuilder.buildBatch(new Goods(draftGoods), draftGoods.getSkuList());
|
||||||
|
goodsSkuService.renderGoodsSkuList(goodsSkus, GoodsOperationDTO.builder().goodsTemplateFlag(true).wholesaleList(draftGoods.getWholesaleList()).salesModel(draftGoods.getSalesModel()).build());
|
||||||
|
draftGoods.setSkuListJson(JSONUtil.toJsonStr(goodsSkus));
|
||||||
draftGoods.setGoodsParamsListJson(JSONUtil.toJsonStr(draftGoods.getGoodsParamsDTOList()));
|
draftGoods.setGoodsParamsListJson(JSONUtil.toJsonStr(draftGoods.getGoodsParamsDTOList()));
|
||||||
this.saveOrUpdate(draftGoods);
|
this.saveOrUpdate(draftGoods);
|
||||||
}
|
}
|
||||||
@ -83,6 +87,7 @@ public class DraftGoodsServiceImpl extends ServiceImpl<DraftGoodsMapper, DraftGo
|
|||||||
@Override
|
@Override
|
||||||
public void deleteGoodsDraft(String id) {
|
public void deleteGoodsDraft(String id) {
|
||||||
this.removeById(id);
|
this.removeById(id);
|
||||||
|
this.wholesaleService.removeByTemplateId(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -104,6 +109,10 @@ public class DraftGoodsServiceImpl extends ServiceImpl<DraftGoodsMapper, DraftGo
|
|||||||
JSONArray jsonArray = JSONUtil.parseArray(draftGoods.getSkuListJson());
|
JSONArray jsonArray = JSONUtil.parseArray(draftGoods.getSkuListJson());
|
||||||
List<GoodsSku> list = JSONUtil.toList(jsonArray, GoodsSku.class);
|
List<GoodsSku> list = JSONUtil.toList(jsonArray, GoodsSku.class);
|
||||||
draftGoodsVO.setSkuList(goodsSkuService.getGoodsSkuVOList(list));
|
draftGoodsVO.setSkuList(goodsSkuService.getGoodsSkuVOList(list));
|
||||||
|
List<Wholesale> wholesaleList = wholesaleService.findByTemplateId(draftGoods.getId());
|
||||||
|
if (CollUtil.isNotEmpty(wholesaleList)) {
|
||||||
|
draftGoodsVO.setWholesaleList(wholesaleList);
|
||||||
|
}
|
||||||
return draftGoodsVO;
|
return draftGoodsVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,48 +121,4 @@ public class DraftGoodsServiceImpl extends ServiceImpl<DraftGoodsMapper, DraftGo
|
|||||||
return this.page(PageUtil.initPage(searchParams), searchParams.queryWrapper());
|
return this.page(PageUtil.initPage(searchParams), searchParams.queryWrapper());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取sku集合
|
|
||||||
*
|
|
||||||
* @param skuList sku列表
|
|
||||||
* @return sku集合
|
|
||||||
*/
|
|
||||||
private List<GoodsSku> getGoodsSkuList(List<Map<String, Object>> skuList) {
|
|
||||||
List<GoodsSku> skus = new ArrayList<>();
|
|
||||||
for (Map<String, Object> skuVO : skuList) {
|
|
||||||
GoodsSku add = this.add(skuVO);
|
|
||||||
skus.add(add);
|
|
||||||
}
|
|
||||||
return skus;
|
|
||||||
}
|
|
||||||
|
|
||||||
private GoodsSku add(Map<String, Object> map) {
|
|
||||||
Map<String, Object> specMap = new LinkedHashMap<>();
|
|
||||||
GoodsSku sku = new GoodsSku();
|
|
||||||
for (Map.Entry<String, Object> m : map.entrySet()) {
|
|
||||||
switch (m.getKey()) {
|
|
||||||
case "sn":
|
|
||||||
sku.setSn(m.getValue() != null ? m.getValue().toString() : "");
|
|
||||||
break;
|
|
||||||
case "cost":
|
|
||||||
sku.setCost(Convert.toDouble(m.getValue()));
|
|
||||||
break;
|
|
||||||
case "price":
|
|
||||||
sku.setPrice(Convert.toDouble(m.getValue()));
|
|
||||||
break;
|
|
||||||
case "quantity":
|
|
||||||
sku.setQuantity(Convert.toInt(m.getValue()));
|
|
||||||
break;
|
|
||||||
case "weight":
|
|
||||||
sku.setWeight(Convert.toDouble(m.getValue()));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
specMap.put(m.getKey(), m.getValue());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sku.setSpecs(JSONUtil.toJsonStr(specMap));
|
|
||||||
return sku;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
|||||||
throw new ServiceException(ResultCode.MUST_HAVE_GOODS_SKU);
|
throw new ServiceException(ResultCode.MUST_HAVE_GOODS_SKU);
|
||||||
}
|
}
|
||||||
// 检查是否需要生成索引
|
// 检查是否需要生成索引
|
||||||
List<GoodsSku> goodsSkus = GoodsSkuBuilder.buildBatch(goods, goodsOperationDTO);
|
List<GoodsSku> goodsSkus = GoodsSkuBuilder.buildBatch(goods, goodsOperationDTO.getSkuList());
|
||||||
renderGoodsSkuList(goodsSkus, goodsOperationDTO);
|
renderGoodsSkuList(goodsSkus, goodsOperationDTO);
|
||||||
|
|
||||||
if (!goodsSkus.isEmpty()) {
|
if (!goodsSkus.isEmpty()) {
|
||||||
@ -151,7 +151,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
|||||||
List<GoodsSku> skuList;
|
List<GoodsSku> skuList;
|
||||||
//删除旧的sku信息
|
//删除旧的sku信息
|
||||||
if (Boolean.TRUE.equals(goodsOperationDTO.getRegeneratorSkuFlag())) {
|
if (Boolean.TRUE.equals(goodsOperationDTO.getRegeneratorSkuFlag())) {
|
||||||
skuList = GoodsSkuBuilder.buildBatch(goods, goodsOperationDTO);
|
skuList = GoodsSkuBuilder.buildBatch(goods, goodsOperationDTO.getSkuList());
|
||||||
renderGoodsSkuList(skuList, goodsOperationDTO);
|
renderGoodsSkuList(skuList, goodsOperationDTO);
|
||||||
List<GoodsSkuVO> goodsListByGoodsId = getGoodsListByGoodsId(goods.getId());
|
List<GoodsSkuVO> goodsListByGoodsId = getGoodsListByGoodsId(goods.getId());
|
||||||
List<String> oldSkuIds = new ArrayList<>();
|
List<String> oldSkuIds = new ArrayList<>();
|
||||||
@ -170,7 +170,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
|||||||
} else {
|
} else {
|
||||||
skuList = new ArrayList<>();
|
skuList = new ArrayList<>();
|
||||||
for (Map<String, Object> map : goodsOperationDTO.getSkuList()) {
|
for (Map<String, Object> map : goodsOperationDTO.getSkuList()) {
|
||||||
GoodsSku sku = GoodsSkuBuilder.build(goods, map, goodsOperationDTO);
|
GoodsSku sku = GoodsSkuBuilder.build(goods, map);
|
||||||
renderGoodsSku(sku, goodsOperationDTO);
|
renderGoodsSku(sku, goodsOperationDTO);
|
||||||
skuList.add(sku);
|
skuList.add(sku);
|
||||||
//如果商品状态值不对,则es索引移除
|
//如果商品状态值不对,则es索引移除
|
||||||
@ -639,7 +639,8 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
|||||||
* @param goodsSkuList sku集合
|
* @param goodsSkuList sku集合
|
||||||
* @param goodsOperationDTO 商品操作DTO
|
* @param goodsOperationDTO 商品操作DTO
|
||||||
*/
|
*/
|
||||||
void renderGoodsSkuList(List<GoodsSku> goodsSkuList, GoodsOperationDTO goodsOperationDTO) {
|
@Override
|
||||||
|
public void renderGoodsSkuList(List<GoodsSku> goodsSkuList, GoodsOperationDTO goodsOperationDTO) {
|
||||||
// 商品销售模式渲染器
|
// 商品销售模式渲染器
|
||||||
salesModelRenders.stream().filter(i -> i.getSalesMode().equals(goodsOperationDTO.getSalesModel())).findFirst().ifPresent(i -> i.renderBatch(goodsSkuList, goodsOperationDTO));
|
salesModelRenders.stream().filter(i -> i.getSalesMode().equals(goodsOperationDTO.getSalesModel())).findFirst().ifPresent(i -> i.renderBatch(goodsSkuList, goodsOperationDTO));
|
||||||
for (GoodsSku goodsSku : goodsSkuList) {
|
for (GoodsSku goodsSku : goodsSkuList) {
|
||||||
|
@ -58,6 +58,7 @@ public class StoreGoodsLabelServiceImpl extends ServiceImpl<StoreGoodsLabelMappe
|
|||||||
list.stream()
|
list.stream()
|
||||||
.filter(label -> label.getParentId() != null && label.getParentId().equals(storeGoodsLabel.getId()))
|
.filter(label -> label.getParentId() != null && label.getParentId().equals(storeGoodsLabel.getId()))
|
||||||
.forEach(storeGoodsLabelChild -> storeGoodsLabelVOChildList.add(new StoreGoodsLabelVO(storeGoodsLabelChild.getId(), storeGoodsLabelChild.getLabelName(), storeGoodsLabelChild.getLevel(), storeGoodsLabelChild.getSortOrder())));
|
.forEach(storeGoodsLabelChild -> storeGoodsLabelVOChildList.add(new StoreGoodsLabelVO(storeGoodsLabelChild.getId(), storeGoodsLabelChild.getLabelName(), storeGoodsLabelChild.getLevel(), storeGoodsLabelChild.getSortOrder())));
|
||||||
|
storeGoodsLabelVOChildList.sort(Comparator.comparing(StoreGoodsLabelVO::getSortOrder));
|
||||||
storeGoodsLabelVO.setChildren(storeGoodsLabelVOChildList);
|
storeGoodsLabelVO.setChildren(storeGoodsLabelVOChildList);
|
||||||
storeGoodsLabelVOList.add(storeGoodsLabelVO);
|
storeGoodsLabelVOList.add(storeGoodsLabelVO);
|
||||||
});
|
});
|
||||||
|
@ -36,6 +36,23 @@ public class WholesaleServiceImpl extends ServiceImpl<WholesaleMapper, Wholesale
|
|||||||
return this.list(queryWrapper).stream().sorted(Comparator.comparing(Wholesale::getNum)).collect(Collectors.toList());
|
return this.list(queryWrapper).stream().sorted(Comparator.comparing(Wholesale::getNum)).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Cacheable(key = "#templateId+'_template'")
|
||||||
|
public List<Wholesale> findByTemplateId(String templateId) {
|
||||||
|
LambdaQueryWrapper<Wholesale> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(Wholesale::getTemplateId, templateId);
|
||||||
|
return this.list(queryWrapper).stream().sorted(Comparator.comparing(Wholesale::getNum)).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@CacheEvict(key = "#templateId+'_template'")
|
||||||
|
public Boolean removeByTemplateId(String templateId) {
|
||||||
|
LambdaQueryWrapper<Wholesale> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(Wholesale::getTemplateId, templateId);
|
||||||
|
cache.remove("{wholesale}_" + templateId + "_template");
|
||||||
|
return this.remove(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@CacheEvict(key = "#goodsId")
|
@CacheEvict(key = "#goodsId")
|
||||||
public Boolean removeByGoodsId(String goodsId) {
|
public Boolean removeByGoodsId(String goodsId) {
|
||||||
|
@ -6,7 +6,6 @@ import cn.hutool.core.lang.Assert;
|
|||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import cn.lili.modules.goods.entity.dos.Goods;
|
import cn.lili.modules.goods.entity.dos.Goods;
|
||||||
import cn.lili.modules.goods.entity.dos.GoodsSku;
|
import cn.lili.modules.goods.entity.dos.GoodsSku;
|
||||||
import cn.lili.modules.goods.entity.dto.GoodsOperationDTO;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -25,48 +24,42 @@ public class GoodsSkuBuilder {
|
|||||||
/**
|
/**
|
||||||
* 构建商品sku
|
* 构建商品sku
|
||||||
*
|
*
|
||||||
* @param goods 商品
|
* @param goods 商品
|
||||||
* @param skuInfo sku信息列表
|
* @param skuInfo sku信息列表
|
||||||
* @param goodsOperationDTO 商品操作信息(如需处理额外信息传递,不需可传空)
|
|
||||||
* @return 商品sku
|
* @return 商品sku
|
||||||
*/
|
*/
|
||||||
public static GoodsSku build(Goods goods, Map<String, Object> skuInfo, GoodsOperationDTO goodsOperationDTO) {
|
public static GoodsSku build(Goods goods, Map<String, Object> skuInfo) {
|
||||||
GoodsSku goodsSku = new GoodsSku(goods);
|
GoodsSku goodsSku = new GoodsSku(goods);
|
||||||
builderSingle(goodsSku, skuInfo, goodsOperationDTO);
|
builderSingle(goodsSku, skuInfo);
|
||||||
return goodsSku;
|
return goodsSku;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量构建商品sku
|
* 批量构建商品sku
|
||||||
*
|
*
|
||||||
* @param goods 商品
|
* @param goods 商品
|
||||||
* @param goodsOperationDTO 商品操作信息
|
|
||||||
* @return 商品sku
|
* @return 商品sku
|
||||||
*/
|
*/
|
||||||
public static List<GoodsSku> buildBatch(Goods goods, GoodsOperationDTO goodsOperationDTO) {
|
public static List<GoodsSku> buildBatch(Goods goods, List<Map<String, Object>> skuList) {
|
||||||
return builderBatch(goods, goodsOperationDTO);
|
Assert.notEmpty(skuList, "skuList不能为空");
|
||||||
|
Assert.notNull(goods, "goods不能为空");
|
||||||
|
List<GoodsSku> goodsSkus = new ArrayList<>();
|
||||||
|
for (Map<String, Object> skuInfo : skuList) {
|
||||||
|
GoodsSku goodsSku = new GoodsSku(goods);
|
||||||
|
builderSingle(goodsSku, skuInfo);
|
||||||
|
goodsSkus.add(goodsSku);
|
||||||
|
}
|
||||||
|
return goodsSkus;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 从已有的商品sku中构建商品sku
|
|
||||||
*
|
|
||||||
* @param goodsSku 原商品sku
|
|
||||||
* @param skuInfo sku信息列表
|
|
||||||
* @param goodsOperationDTO 商品操作信息(如需处理额外信息传递,不需可传空)
|
|
||||||
* @return 商品sku
|
|
||||||
*/
|
|
||||||
public static GoodsSku build(GoodsSku goodsSku, Map<String, Object> skuInfo, GoodsOperationDTO goodsOperationDTO) {
|
|
||||||
builderSingle(goodsSku, skuInfo, goodsOperationDTO);
|
|
||||||
return goodsSku;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void builderSingle(GoodsSku goodsSku, Map<String, Object> skuInfo, GoodsOperationDTO goodsOperationDTO) {
|
private static void builderSingle(GoodsSku goodsSku, Map<String, Object> skuInfo) {
|
||||||
Assert.notNull(goodsSku, "goodsSku不能为空");
|
Assert.notNull(goodsSku, "goodsSku不能为空");
|
||||||
Assert.notEmpty(skuInfo, "skuInfo不能为空");
|
Assert.notEmpty(skuInfo, "skuInfo不能为空");
|
||||||
//规格简短信息
|
//规格简短信息
|
||||||
StringBuilder simpleSpecs = new StringBuilder();
|
StringBuilder simpleSpecs = new StringBuilder();
|
||||||
//商品名称
|
//商品名称
|
||||||
StringBuilder goodsName = new StringBuilder(goodsOperationDTO.getGoodsName());
|
StringBuilder goodsName = new StringBuilder(goodsSku.getGoodsName());
|
||||||
//规格值
|
//规格值
|
||||||
Map<String, Object> specMap = new LinkedHashMap<>();
|
Map<String, Object> specMap = new LinkedHashMap<>();
|
||||||
|
|
||||||
@ -100,17 +93,5 @@ public class GoodsSkuBuilder {
|
|||||||
goodsSku.setSimpleSpecs(simpleSpecs.toString());
|
goodsSku.setSimpleSpecs(simpleSpecs.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<GoodsSku> builderBatch(Goods goods, GoodsOperationDTO goodsOperationDTO) {
|
|
||||||
Assert.notEmpty(goodsOperationDTO.getSkuList(), "goodsOperationDTO.getSkuList()不能为空");
|
|
||||||
Assert.notNull(goods, "goods不能为空");
|
|
||||||
List<GoodsSku> goodsSkus = new ArrayList<>();
|
|
||||||
for (Map<String, Object> skuInfo : goodsOperationDTO.getSkuList()) {
|
|
||||||
GoodsSku goodsSku = new GoodsSku(goods);
|
|
||||||
builderSingle(goodsSku, skuInfo, goodsOperationDTO);
|
|
||||||
goodsSkus.add(goodsSku);
|
|
||||||
}
|
|
||||||
return goodsSkus;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,9 @@ public class WholesaleSaleModelRenderImpl implements SalesModelRender {
|
|||||||
skus.setPrice(collect.get(0).getPrice());
|
skus.setPrice(collect.get(0).getPrice());
|
||||||
skus.setCost(collect.get(0).getPrice());
|
skus.setCost(collect.get(0).getPrice());
|
||||||
}
|
}
|
||||||
wholesaleService.removeByGoodsId(goodsSkus.get(0).getGoodsId());
|
if (Boolean.FALSE.equals(goodsOperationDTO.getGoodsTemplateFlag())) {
|
||||||
|
wholesaleService.removeByGoodsId(goodsSkus.get(0).getGoodsId());
|
||||||
|
}
|
||||||
wholesaleService.saveOrUpdateBatch(collect);
|
wholesaleService.saveOrUpdateBatch(collect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,4 +27,11 @@ public @interface AfterSaleLogPoint {
|
|||||||
*/
|
*/
|
||||||
String sn();
|
String sn();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return 售后状态
|
||||||
|
*/
|
||||||
|
String serviceStatus() default "";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package cn.lili.modules.order.aftersale.aop;
|
package cn.lili.modules.order.aftersale.aop;
|
||||||
|
|
||||||
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import cn.lili.common.security.AuthUser;
|
import cn.lili.common.security.AuthUser;
|
||||||
import cn.lili.common.security.context.UserContext;
|
import cn.lili.common.security.context.UserContext;
|
||||||
import cn.lili.common.security.enums.UserEnums;
|
import cn.lili.common.security.enums.UserEnums;
|
||||||
@ -7,6 +8,7 @@ import cn.lili.common.utils.SpelUtil;
|
|||||||
import cn.lili.common.utils.ThreadPoolUtil;
|
import cn.lili.common.utils.ThreadPoolUtil;
|
||||||
import cn.lili.modules.order.aftersale.entity.dos.AfterSaleLog;
|
import cn.lili.modules.order.aftersale.entity.dos.AfterSaleLog;
|
||||||
import cn.lili.modules.order.aftersale.service.AfterSaleLogService;
|
import cn.lili.modules.order.aftersale.service.AfterSaleLogService;
|
||||||
|
import cn.lili.modules.order.trade.entity.enums.AfterSaleStatusEnum;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.aspectj.lang.JoinPoint;
|
import org.aspectj.lang.JoinPoint;
|
||||||
import org.aspectj.lang.annotation.AfterReturning;
|
import org.aspectj.lang.annotation.AfterReturning;
|
||||||
@ -67,6 +69,9 @@ public class AfterSaleOperationLogAspect {
|
|||||||
AfterSaleLogPoint afterSaleLogPoint = signature.getMethod().getAnnotation(AfterSaleLogPoint.class);
|
AfterSaleLogPoint afterSaleLogPoint = signature.getMethod().getAnnotation(AfterSaleLogPoint.class);
|
||||||
String description = SpelUtil.compileParams(joinPoint, rvt, afterSaleLogPoint.description());
|
String description = SpelUtil.compileParams(joinPoint, rvt, afterSaleLogPoint.description());
|
||||||
String sn = SpelUtil.compileParams(joinPoint, rvt, afterSaleLogPoint.sn());
|
String sn = SpelUtil.compileParams(joinPoint, rvt, afterSaleLogPoint.sn());
|
||||||
|
if (CharSequenceUtil.isNotEmpty(afterSaleLogPoint.serviceStatus())) {
|
||||||
|
description += AfterSaleStatusEnum.valueOf(SpelUtil.compileParams(joinPoint, rvt, afterSaleLogPoint.serviceStatus())).description();
|
||||||
|
}
|
||||||
result.put("description", description);
|
result.put("description", description);
|
||||||
result.put("sn", sn);
|
result.put("sn", sn);
|
||||||
return result;
|
return result;
|
||||||
|
@ -179,7 +179,7 @@ public class AfterSaleServiceImpl extends ServiceImpl<AfterSaleMapper, AfterSale
|
|||||||
return addAfterSale(afterSaleDTO);
|
return addAfterSale(afterSaleDTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterSaleLogPoint(sn = "#afterSaleSn", description = "'审核售后:售后编号['+#afterSaleSn+'],'+ #serviceStatus")
|
@AfterSaleLogPoint(sn = "#afterSaleSn", description = "'审核售后:售后编号['+#afterSaleSn+']' ", serviceStatus = "#serviceStatus")
|
||||||
@SystemLogPoint(description = "售后-审核售后", customerLog = "'审核售后:售后编号['+#afterSaleSn+'],'+ #serviceStatus")
|
@SystemLogPoint(description = "售后-审核售后", customerLog = "'审核售后:售后编号['+#afterSaleSn+'],'+ #serviceStatus")
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@Override
|
@Override
|
||||||
|
@ -74,20 +74,30 @@ public class SeckillApplyServiceImpl extends ServiceImpl<SeckillApplyMapper, Sec
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SeckillTimelineVO> getSeckillTimeline() {
|
public List<SeckillTimelineVO> getSeckillTimeline() {
|
||||||
//秒杀活动缓存key
|
try {
|
||||||
return getSeckillTimelineInfo();
|
//秒杀活动缓存key
|
||||||
|
return getSeckillTimelineInfo();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("获取秒杀时间轴失败", e);
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SeckillGoodsVO> getSeckillGoods(Integer timeline) {
|
public List<SeckillGoodsVO> getSeckillGoods(Integer timeline) {
|
||||||
List<SeckillGoodsVO> seckillGoodsVoS = new ArrayList<>();
|
try {
|
||||||
//获取
|
List<SeckillGoodsVO> seckillGoodsVoS = new ArrayList<>();
|
||||||
List<SeckillTimelineVO> seckillTimelineToCache = getSeckillTimelineInfo();
|
//获取
|
||||||
Optional<SeckillTimelineVO> first = seckillTimelineToCache.stream().filter(i -> i.getTimeLine().equals(timeline)).findFirst();
|
List<SeckillTimelineVO> seckillTimelineToCache = getSeckillTimelineInfo();
|
||||||
if (first.isPresent()) {
|
Optional<SeckillTimelineVO> first = seckillTimelineToCache.stream().filter(i -> i.getTimeLine().equals(timeline)).findFirst();
|
||||||
seckillGoodsVoS = first.get().getSeckillGoodsList();
|
if (first.isPresent()) {
|
||||||
|
seckillGoodsVoS = first.get().getSeckillGoodsList();
|
||||||
|
}
|
||||||
|
return seckillGoodsVoS;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("获取秒杀商品失败", e);
|
||||||
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
return seckillGoodsVoS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user