From b4240ae2c070136154fc060a879218a346b1a3cf Mon Sep 17 00:00:00 2001 From: lifenlong Date: Wed, 26 May 2021 08:18:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=93=81=E5=8E=BB=E9=99=A4=E4=B9=B0?= =?UTF-8?q?=E5=AE=B6=E6=89=BF=E6=8B=85=E8=BF=90=E8=B4=B9=E3=80=81=E5=8D=96?= =?UTF-8?q?=E5=AE=B6=E6=89=BF=E6=8B=85=E8=BF=90=E8=B4=B9=EF=BC=8C=E9=85=8D?= =?UTF-8?q?=E9=80=81=E6=A8=A1=E6=9D=BF=E5=A2=9E=E5=8A=A0=E9=80=89=E9=A1=B9?= =?UTF-8?q?=EF=BC=9A=E5=8C=85=E9=82=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../broadcast/entity/dos/Commodity.java | 3 +++ .../serviceimpl/CommodityServiceImpl.java | 26 +++++++++++++++++-- .../lili/modules/goods/entity/dos/Goods.java | 6 ----- .../modules/goods/entity/dos/GoodsSku.java | 2 -- .../goods/serviceimpl/GoodsServiceImpl.java | 1 - .../serviceimpl/GoodsSkuServiceImpl.java | 2 -- .../order/cart/entity/vo/CartSkuVO.java | 5 ---- .../cart/render/impl/SkuFreightRender.java | 10 +++---- .../order/cart/service/CartServiceImpl.java | 9 ++++--- .../store/entity/dos/FreightTemplate.java | 4 +-- .../lili/modules/store/entity/dos/Store.java | 6 +++++ .../store/entity/dto/StoreEditDTO.java | 6 +++++ .../entity/enums/FreightTemplateEnum.java | 3 ++- .../store/entity/vos/StoreBasicInfoVO.java | 6 +++++ .../store/mapper/StoreDetailMapper.java | 6 ++--- .../store/service/FreightTemplateService.java | 1 + .../FreightTemplateServiceImpl.java | 14 ++++++---- 17 files changed, 71 insertions(+), 39 deletions(-) diff --git a/framework/src/main/java/cn/lili/modules/broadcast/entity/dos/Commodity.java b/framework/src/main/java/cn/lili/modules/broadcast/entity/dos/Commodity.java index b4aa4a7e..725b2b94 100644 --- a/framework/src/main/java/cn/lili/modules/broadcast/entity/dos/Commodity.java +++ b/framework/src/main/java/cn/lili/modules/broadcast/entity/dos/Commodity.java @@ -60,4 +60,7 @@ public class Commodity extends BaseEntity { @ApiModelProperty(value = "规格ID") private String skuId; + + @ApiModelProperty(value = "SKU库存") + private Integer quantity; } diff --git a/framework/src/main/java/cn/lili/modules/broadcast/serviceimpl/CommodityServiceImpl.java b/framework/src/main/java/cn/lili/modules/broadcast/serviceimpl/CommodityServiceImpl.java index 4fb61043..92863542 100644 --- a/framework/src/main/java/cn/lili/modules/broadcast/serviceimpl/CommodityServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/broadcast/serviceimpl/CommodityServiceImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.convert.Convert; import cn.hutool.json.JSONArray; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; +import cn.lili.common.exception.ServiceException; import cn.lili.common.security.context.UserContext; import cn.lili.common.utils.PageUtil; import cn.lili.common.vo.PageVO; @@ -12,6 +13,9 @@ import cn.lili.modules.broadcast.entity.dto.CommodityDTO; import cn.lili.modules.broadcast.mapper.CommodityMapper; import cn.lili.modules.broadcast.service.CommodityService; import cn.lili.modules.broadcast.util.WechatLivePlayerUtil; +import cn.lili.modules.goods.entity.dos.GoodsSku; +import cn.lili.modules.goods.entity.enums.GoodsAuthEnum; +import cn.lili.modules.goods.service.GoodsSkuService; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -32,18 +36,36 @@ public class CommodityServiceImpl extends ServiceImpl commodityList) { for (Commodity commodity : commodityList) { + //检测直播商品 + checkCommodity(commodity); + //添加直播商品 JSONObject json = wechatLivePlayerUtil.addGoods(commodity); commodity.setLiveGoodsId(Convert.toInt(json.getStr("goodsId"))); commodity.setAuditId(json.getStr("auditId")); commodity.setStoreId(UserContext.getCurrentUser().getStoreId()); + //默认为待审核状态 + commodity.setAuditStatus("0"); + this.save(commodity); + } + return true; + } + private void checkCommodity(Commodity commodity){ + //商品是否审核通过 + GoodsSku goodsSku=goodsSkuService.getById(commodity.getSkuId()); + if(!goodsSku.getIsAuth().equals(GoodsAuthEnum.PASS)){ + throw new ServiceException(goodsSku.getGoodsName()+" 未审核通过,不能添加直播商品"); + } + //是否已添加规格商品 + if(this.count(new LambdaQueryWrapper().eq(Commodity::getSkuId,commodity.getSkuId()))>0){ + throw new ServiceException(goodsSku.getGoodsName()+" 已添加规格商品,无法重复增加"); } - return this.saveBatch(commodityList); } - @Override public boolean deleteCommodity(String goodsId) { JSONObject json = wechatLivePlayerUtil.deleteGoods(goodsId); diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java b/framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java index c0e50d69..c7ba9d46 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dos/Goods.java @@ -142,11 +142,6 @@ public class Goods extends BaseEntity { */ @ApiModelProperty(value = "运费模板id") private String templateId; - /** - * 谁承担运费 BUYER:买家承担,STORE:卖家承担 - */ - @ApiModelProperty(value = " 谁承担运费 BUYER:买家承担,STORE:卖家承担") - private String freightPayer; /** * 审核状态 * @@ -198,7 +193,6 @@ public class Goods extends BaseEntity { this.sn = goodsOperationDTO.getSn(); this.price = goodsOperationDTO.getPrice(); this.weight = goodsOperationDTO.getWeight(); - this.freightPayer = goodsOperationDTO.getFreightPayer(); this.templateId = goodsOperationDTO.getTemplateId(); this.recommend = goodsOperationDTO.isRecommend(); this.sellingPoint = goodsOperationDTO.getSellingPoint(); diff --git a/framework/src/main/java/cn/lili/modules/goods/entity/dos/GoodsSku.java b/framework/src/main/java/cn/lili/modules/goods/entity/dos/GoodsSku.java index 96b6ead7..830ed3ff 100644 --- a/framework/src/main/java/cn/lili/modules/goods/entity/dos/GoodsSku.java +++ b/framework/src/main/java/cn/lili/modules/goods/entity/dos/GoodsSku.java @@ -131,8 +131,6 @@ public class GoodsSku extends BaseEntity { @ApiModelProperty(value = "运费模板id") private String templateId; - @ApiModelProperty(value = " 谁承担运费 BUYER:买家承担,STORE:卖家承担") - private String freightPayer; /** * @see GoodsAuthEnum */ diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java index 355d06e0..6f25a75b 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsServiceImpl.java @@ -306,7 +306,6 @@ public class GoodsServiceImpl extends ServiceImpl implements @Override public Boolean freight(List goodsIds, String freightPayer, String templateId) { LambdaUpdateWrapper lambdaUpdateWrapper = Wrappers.lambdaUpdate(); - lambdaUpdateWrapper.set(Goods::getFreightPayer, freightPayer); lambdaUpdateWrapper.set(Goods::getTemplateId, templateId); lambdaUpdateWrapper.in(Goods::getId, goodsIds); return this.update(lambdaUpdateWrapper); diff --git a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java index 8823ee9c..d2e0e856 100644 --- a/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/goods/serviceimpl/GoodsSkuServiceImpl.java @@ -544,8 +544,6 @@ public class GoodsSkuServiceImpl extends ServiceImpl i sku.setIntro(goods.getIntro()); sku.setMobileIntro(goods.getMobileIntro()); sku.setGoodsUnit(goods.getGoodsUnit()); - //运费 - sku.setFreightPayer(goods.getFreightPayer()); //商品状态 sku.setIsAuth(goods.getIsAuth()); sku.setSalesModel(goods.getSalesModel()); diff --git a/framework/src/main/java/cn/lili/modules/order/cart/entity/vo/CartSkuVO.java b/framework/src/main/java/cn/lili/modules/order/cart/entity/vo/CartSkuVO.java index 2a0ff507..7671d446 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/entity/vo/CartSkuVO.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/entity/vo/CartSkuVO.java @@ -51,10 +51,6 @@ public class CartSkuVO extends CartBase implements Serializable { @ApiModelProperty(value = "是否选中,要去结算") private Boolean checked; - - @ApiModelProperty(value = " 谁承担运费 BUYER:买家承担,STORE:卖家承担") - private String freightPayer; - @ApiModelProperty(value = "是否免运费") private Boolean isFreeFreight; @@ -100,7 +96,6 @@ public class CartSkuVO extends CartBase implements Serializable { this.isShip = true; this.purchasePrice = goodsSku.getIsPromotion() != null && goodsSku.getIsPromotion() ? goodsSku.getPromotionPrice() : goodsSku.getPrice(); this.isFreeFreight = false; - this.freightPayer = goodsSku.getFreightPayer(); this.setStoreId(goodsSku.getStoreId()); this.setStoreName(goodsSku.getStoreName()); } diff --git a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuFreightRender.java b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuFreightRender.java index afadb005..b159eee0 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuFreightRender.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/render/impl/SkuFreightRender.java @@ -11,7 +11,6 @@ import cn.lili.modules.store.entity.dto.FreightTemplateChildDTO; import cn.lili.modules.store.entity.enums.FreightTemplateEnum; import cn.lili.modules.store.entity.vos.FreightTemplateVO; import cn.lili.modules.store.service.FreightTemplateService; -import com.xkcoding.http.util.StringUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Service; @@ -44,10 +43,6 @@ public class SkuFreightRender implements CartRenderStep { forSku: for (CartSkuVO cartSkuVO : cartSkuVOS) { String freightTemplateId = cartSkuVO.getGoodsSku().getFreightTemplateId(); - //如果商品设置卖家承担运费,或者没设置运费,则跳出此商品运费计算 - if (StringUtil.isEmpty(cartSkuVO.getFreightPayer())||cartSkuVO.getFreightPayer().equals("STORE")) { - continue; - } //免运费则跳出运费计算 if (Boolean.TRUE.equals(cartSkuVO.getIsFreeFreight()) || freightTemplateId == null) { @@ -57,7 +52,10 @@ public class SkuFreightRender implements CartRenderStep { //寻找对应对商品运费计算模版 FreightTemplateVO freightTemplate = freightTemplateService.getFreightTemplate(freightTemplateId); if (freightTemplate != null && freightTemplate.getFreightTemplateChildList() != null && !freightTemplate.getFreightTemplateChildList().isEmpty()) { - + //店铺支付运费则跳过 + if(freightTemplate.getPricingMethod().equals(FreightTemplateEnum.FREE.name())){ + break; + } FreightTemplateChild freightTemplateChild = null; //获取市级别id diff --git a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java index 55808273..9a2d8dc2 100644 --- a/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/order/cart/service/CartServiceImpl.java @@ -34,6 +34,7 @@ import cn.lili.modules.promotion.service.PromotionGoodsService; import cn.lili.modules.search.entity.dos.EsGoodsIndex; import cn.lili.modules.search.service.EsGoodsSearchService; import cn.lili.modules.store.entity.dos.FreightTemplateChild; +import cn.lili.modules.store.entity.enums.FreightTemplateEnum; import cn.lili.modules.store.entity.vos.FreightTemplateVO; import cn.lili.modules.store.service.FreightTemplateService; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -524,12 +525,12 @@ public class CartServiceImpl implements CartService { throw new ServiceException(ResultCode.MEMBER_ADDRESS_NOT_EXIST); } for (CartSkuVO cartSkuVO : skuList) { - //店铺支付运费则跳过 - if (cartSkuVO.getFreightPayer().equals("STORE")) { - break; - } String freightTemplateId = cartSkuVO.getGoodsSku().getFreightTemplateId(); FreightTemplateVO freightTemplate = freightTemplateService.getFreightTemplate(freightTemplateId); + //店铺支付运费则跳过 + if(freightTemplate.getPricingMethod().equals(FreightTemplateEnum.FREE.name())){ + break; + } //收货地址判定 forTemplates: if (freightTemplate != null && freightTemplate.getFreightTemplateChildList() != null && !freightTemplate.getFreightTemplateChildList().isEmpty()) { diff --git a/framework/src/main/java/cn/lili/modules/store/entity/dos/FreightTemplate.java b/framework/src/main/java/cn/lili/modules/store/entity/dos/FreightTemplate.java index 98058968..ffdbc8b0 100644 --- a/framework/src/main/java/cn/lili/modules/store/entity/dos/FreightTemplate.java +++ b/framework/src/main/java/cn/lili/modules/store/entity/dos/FreightTemplate.java @@ -13,9 +13,9 @@ import javax.validation.constraints.NotEmpty; /** * 运费模板 + * * @author Chopper * @date 2020/11/17 4:27 下午 - * */ @Data @Entity @@ -35,7 +35,7 @@ public class FreightTemplate extends BaseEntity { * @see FreightTemplateEnum */ @NotEmpty(message = "计价方式不能为空") - @ApiModelProperty(value = "计价方式:按件、按重量", allowableValues = "WEIGHT, NUM") + @ApiModelProperty(value = "计价方式:按件、按重量", allowableValues = "WEIGHT,NUM,FREE") private String pricingMethod; diff --git a/framework/src/main/java/cn/lili/modules/store/entity/dos/Store.java b/framework/src/main/java/cn/lili/modules/store/entity/dos/Store.java index c271a186..27c2c9be 100644 --- a/framework/src/main/java/cn/lili/modules/store/entity/dos/Store.java +++ b/framework/src/main/java/cn/lili/modules/store/entity/dos/Store.java @@ -95,6 +95,12 @@ public class Store extends BaseEntity { @ApiModelProperty(value = "收藏数量") private Integer collectionNum; + @ApiModelProperty(value = "腾讯云智服唯一标识") + private String yzfSign; + + @ApiModelProperty(value = "腾讯云智服小程序唯一标识") + private String yzfMpSign; + public Store(Member member) { this.memberId = member.getId(); this.memberName = member.getUsername(); diff --git a/framework/src/main/java/cn/lili/modules/store/entity/dto/StoreEditDTO.java b/framework/src/main/java/cn/lili/modules/store/entity/dto/StoreEditDTO.java index 33616b57..6b6bfe50 100644 --- a/framework/src/main/java/cn/lili/modules/store/entity/dto/StoreEditDTO.java +++ b/framework/src/main/java/cn/lili/modules/store/entity/dto/StoreEditDTO.java @@ -42,4 +42,10 @@ public class StoreEditDTO extends StoreDetail { @ApiModelProperty(value = "详细地址") private String storeAddressDetail; + @ApiModelProperty(value = "腾讯云智服唯一标识") + private String yzfSign; + + @ApiModelProperty(value = "腾讯云智服小程序唯一标识") + private String yzfMpSign; + } diff --git a/framework/src/main/java/cn/lili/modules/store/entity/enums/FreightTemplateEnum.java b/framework/src/main/java/cn/lili/modules/store/entity/enums/FreightTemplateEnum.java index d4a3c720..e1a1a404 100644 --- a/framework/src/main/java/cn/lili/modules/store/entity/enums/FreightTemplateEnum.java +++ b/framework/src/main/java/cn/lili/modules/store/entity/enums/FreightTemplateEnum.java @@ -11,8 +11,9 @@ public enum FreightTemplateEnum { /** * 重量 * 件数 + * 包邮 */ - WEIGHT, NUM + WEIGHT, NUM, FREE } diff --git a/framework/src/main/java/cn/lili/modules/store/entity/vos/StoreBasicInfoVO.java b/framework/src/main/java/cn/lili/modules/store/entity/vos/StoreBasicInfoVO.java index ffbcae0c..af85fc2b 100644 --- a/framework/src/main/java/cn/lili/modules/store/entity/vos/StoreBasicInfoVO.java +++ b/framework/src/main/java/cn/lili/modules/store/entity/vos/StoreBasicInfoVO.java @@ -42,4 +42,10 @@ public class StoreBasicInfoVO { @ApiModelProperty(value = "是否自营") private String selfOperated; + + @ApiModelProperty(value = "腾讯云智服唯一标识") + private String yzfSign; + + @ApiModelProperty(value = "腾讯云智服小程序唯一标识") + private String yzfMpSign; } diff --git a/framework/src/main/java/cn/lili/modules/store/mapper/StoreDetailMapper.java b/framework/src/main/java/cn/lili/modules/store/mapper/StoreDetailMapper.java index 0b91d1fe..1478fea8 100644 --- a/framework/src/main/java/cn/lili/modules/store/mapper/StoreDetailMapper.java +++ b/framework/src/main/java/cn/lili/modules/store/mapper/StoreDetailMapper.java @@ -23,15 +23,15 @@ import java.util.List; */ public interface StoreDetailMapper extends BaseMapper { - @Select("select s.store_logo,s.member_name,s.store_name,s.store_disable,s.self_operated,s.store_address_detail,s.store_address_path,s.store_address_id_path,s.store_center,s.store_desc,d.* " + - "from li_store s inner join li_store_detail d on s.id=d.store_id where s.id=#{storeId}") + @Select("select s.store_logo,s.member_name,s.store_name,s.store_disable,s.self_operated,s.store_address_detail,s.store_address_path,s.store_address_id_path,s.store_center,s.store_desc,s.yzf_sign," + + "d.* from li_store s inner join li_store_detail d on s.id=d.store_id where s.id=#{storeId}") StoreDetailVO getStoreDetail(String storeId); @Select("select s.member_name,s.store_name,s.store_disable,s.self_operated,s.store_center,s.store_logo,s.store_desc,d.* " + "from li_store s inner join li_store_detail d on s.id=d.store_id where s.member_id=#{memberId}") StoreDetailVO getStoreDetailByMemberId(String memberId); - @Select("SELECT s.id as storeId,s.* FROM li_store s LEFT JOIN li_store_detail sd ON s.id=sd.store_id WHERE s.id=#{storeId}") + @Select("SELECT s.id as storeId,s.* FROM li_store s WHERE s.id=#{storeId}") StoreBasicInfoVO getStoreBasicInfoDTO(String storeId); @Select("select s.sales_consignee_name,s.sales_consignee_mobile,s.sales_consignee_address_id,s.sales_consignee_address_path,s.sales_consignee_detail " + diff --git a/framework/src/main/java/cn/lili/modules/store/service/FreightTemplateService.java b/framework/src/main/java/cn/lili/modules/store/service/FreightTemplateService.java index cecc0ba2..c4b82724 100644 --- a/framework/src/main/java/cn/lili/modules/store/service/FreightTemplateService.java +++ b/framework/src/main/java/cn/lili/modules/store/service/FreightTemplateService.java @@ -41,6 +41,7 @@ public interface FreightTemplateService extends IService { /** * 添加商家运费模板 + * 运费模板分为卖家包邮、运费计算两种类型 * * @param freightTemplateVO 运费模板 * @return 运费模板 diff --git a/framework/src/main/java/cn/lili/modules/store/serviceimpl/FreightTemplateServiceImpl.java b/framework/src/main/java/cn/lili/modules/store/serviceimpl/FreightTemplateServiceImpl.java index 11e1b0bc..a239e50e 100644 --- a/framework/src/main/java/cn/lili/modules/store/serviceimpl/FreightTemplateServiceImpl.java +++ b/framework/src/main/java/cn/lili/modules/store/serviceimpl/FreightTemplateServiceImpl.java @@ -108,12 +108,16 @@ public class FreightTemplateServiceImpl extends ServiceImpl list = new ArrayList<>(); - for (FreightTemplateChild freightTemplateChild : freightTemplateVO.getFreightTemplateChildList()) { - freightTemplateChild.setFreightTemplateId(freightTemplate.getId()); - list.add(freightTemplateChild); + //如果子运费模板不为空则进行新增 + if(freightTemplateVO.getFreightTemplateChildList()!=null){ + for (FreightTemplateChild freightTemplateChild : freightTemplateVO.getFreightTemplateChildList()) { + freightTemplateChild.setFreightTemplateId(freightTemplate.getId()); + list.add(freightTemplateChild); + } + //添加运费模板子内容 + freightTemplateChildService.addFreightTemplateChild(list); } - //添加运费模板子内容 - freightTemplateChildService.addFreightTemplateChild(list); + //更新缓存 cache.remove(CachePrefix.SHIP_TEMPLATE.getPrefix() + tokenUser.getStoreId()); return freightTemplateVO;