商品去除买家承担运费、卖家承担运费,配送模板增加选项:包邮

This commit is contained in:
lifenlong 2021-05-26 08:18:28 +08:00
parent a9ec03f0a4
commit b4240ae2c0
17 changed files with 71 additions and 39 deletions

View File

@ -60,4 +60,7 @@ public class Commodity extends BaseEntity {
@ApiModelProperty(value = "规格ID")
private String skuId;
@ApiModelProperty(value = "SKU库存")
private Integer quantity;
}

View File

@ -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<CommodityMapper, Commodity
@Autowired
private WechatLivePlayerUtil wechatLivePlayerUtil;
@Autowired
private GoodsSkuService goodsSkuService;
@Override
public boolean addCommodity(List<Commodity> 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<Commodity>().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);

View File

@ -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();

View File

@ -131,8 +131,6 @@ public class GoodsSku extends BaseEntity {
@ApiModelProperty(value = "运费模板id")
private String templateId;
@ApiModelProperty(value = " 谁承担运费 BUYER买家承担STORE卖家承担")
private String freightPayer;
/**
* @see GoodsAuthEnum
*/

View File

@ -306,7 +306,6 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
@Override
public Boolean freight(List<String> goodsIds, String freightPayer, String templateId) {
LambdaUpdateWrapper<Goods> lambdaUpdateWrapper = Wrappers.lambdaUpdate();
lambdaUpdateWrapper.set(Goods::getFreightPayer, freightPayer);
lambdaUpdateWrapper.set(Goods::getTemplateId, templateId);
lambdaUpdateWrapper.in(Goods::getId, goodsIds);
return this.update(lambdaUpdateWrapper);

View File

@ -544,8 +544,6 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> 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());

View File

@ -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());
}

View File

@ -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

View File

@ -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()) {

View File

@ -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;

View File

@ -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();

View File

@ -42,4 +42,10 @@ public class StoreEditDTO extends StoreDetail {
@ApiModelProperty(value = "详细地址")
private String storeAddressDetail;
@ApiModelProperty(value = "腾讯云智服唯一标识")
private String yzfSign;
@ApiModelProperty(value = "腾讯云智服小程序唯一标识")
private String yzfMpSign;
}

View File

@ -11,8 +11,9 @@ public enum FreightTemplateEnum {
/**
* 重量
* 件数
* 包邮
*/
WEIGHT, NUM
WEIGHT, NUM, FREE
}

View File

@ -42,4 +42,10 @@ public class StoreBasicInfoVO {
@ApiModelProperty(value = "是否自营")
private String selfOperated;
@ApiModelProperty(value = "腾讯云智服唯一标识")
private String yzfSign;
@ApiModelProperty(value = "腾讯云智服小程序唯一标识")
private String yzfMpSign;
}

View File

@ -23,15 +23,15 @@ import java.util.List;
*/
public interface StoreDetailMapper extends BaseMapper<StoreDetail> {
@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 " +

View File

@ -41,6 +41,7 @@ public interface FreightTemplateService extends IService<FreightTemplate> {
/**
* 添加商家运费模板
* 运费模板分为卖家包邮运费计算两种类型
*
* @param freightTemplateVO 运费模板
* @return 运费模板

View File

@ -108,12 +108,16 @@ public class FreightTemplateServiceImpl extends ServiceImpl<FreightTemplateMappe
this.save(freightTemplate);
//给子模板赋父模板的id
List<FreightTemplateChild> 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;