|
@@ -0,0 +1,118 @@
|
|
|
|
|
+package com.xingxi.api.service.impl;
|
|
|
|
|
+
|
|
|
|
|
+import com.xingxi.api.data.mapper.WxApiProductMapper;
|
|
|
|
|
+import com.xingxi.api.model.MercProdRequest;
|
|
|
|
|
+import com.xingxi.api.model.MercProdResponse;
|
|
|
|
|
+import com.xingxi.api.model.ProdAttrResponse;
|
|
|
|
|
+import com.xingxi.api.service.ProdServiceI;
|
|
|
|
|
+import com.xingxi.common.enums.EDelFlag;
|
|
|
|
|
+import com.xingxi.common.enums.ERoleKey;
|
|
|
|
|
+import com.xingxi.master.merchant.domain.MerchantProd;
|
|
|
|
|
+import com.xingxi.master.product.domain.*;
|
|
|
|
|
+import com.xingxi.master.product.service.IProdAttrJointService;
|
|
|
|
|
+import com.xingxi.master.product.service.IProdAttrPriceService;
|
|
|
|
|
+import com.xingxi.master.product.service.IProdAttrService;
|
|
|
|
|
+import com.xingxi.master.product.service.IProdPicService;
|
|
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
|
|
+@Slf4j
|
|
|
|
|
+@RequiredArgsConstructor
|
|
|
|
|
+@Service
|
|
|
|
|
+@Validated
|
|
|
|
|
+class ProdServiceImpl implements ProdServiceI {
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ WxApiProductMapper productMapper;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ IProdPicService prodPicService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ IProdAttrService prodAttrService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ IProdAttrPriceService prodAttrPriceService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ IProdAttrJointService prodAttrJointService;
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<MercProdResponse> selectMercProdList(MercProdRequest request) {
|
|
|
|
|
+ return productMapper.selectProductList(request);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public MercProdResponse selectMercProdById(Long mercProdId) {
|
|
|
|
|
+ MercProdResponse rtn = new MercProdResponse();
|
|
|
|
|
+
|
|
|
|
|
+ MerchantProd mercProd = productMapper.selectMerchantProdByMercProdId(mercProdId);
|
|
|
|
|
+
|
|
|
|
|
+ rtn.setMercProdId(mercProd.getMercProdId());
|
|
|
|
|
+ rtn.setMercId(mercProd.getMercId());
|
|
|
|
|
+ rtn.setProdId(mercProd.getProdId());
|
|
|
|
|
+ Prod prod = productMapper.selectProdById(mercProd.getProdId());
|
|
|
|
|
+ rtn.setProdClassId(prod.getProdClassId());
|
|
|
|
|
+ rtn.setProdName(prod.getProdName());
|
|
|
|
|
+ rtn.setIpId(prod.getIpId());
|
|
|
|
|
+ rtn.setDesignerId(prod.getDesignerId());
|
|
|
|
|
+ rtn.setDescription(prod.getDescription());
|
|
|
|
|
+ rtn.setThirdIdConfirmFlag(prod.getThirdIdConfirmFlag());
|
|
|
|
|
+ rtn.setProdStatus(prod.getProdStatus());
|
|
|
|
|
+
|
|
|
|
|
+ ProdPic condPic = new ProdPic();
|
|
|
|
|
+ condPic.setProdId(mercProd.getProdId());
|
|
|
|
|
+ condPic.setDelFlag(EDelFlag.NO.getVal());
|
|
|
|
|
+
|
|
|
|
|
+ List<ProdPic> prodPicList = prodPicService.selectProdPicList(condPic);
|
|
|
|
|
+ rtn.setProdPicList(prodPicList);
|
|
|
|
|
+
|
|
|
|
|
+ ProdAttr condAttr = new ProdAttr();
|
|
|
|
|
+ condAttr.setProdId(prod.getId());
|
|
|
|
|
+ condAttr.setDelFlag(EDelFlag.NO.getVal());
|
|
|
|
|
+
|
|
|
|
|
+ List<ProdAttr> prodAttrList = prodAttrService.selectProdAttrList(condAttr);
|
|
|
|
|
+
|
|
|
|
|
+ List<ProdAttrResponse> prodAttrResponseList = new ArrayList<>();
|
|
|
|
|
+
|
|
|
|
|
+ for (ProdAttr prodAttr : prodAttrList) {
|
|
|
|
|
+ ProdAttrResponse prodAttrResponse = new ProdAttrResponse();
|
|
|
|
|
+
|
|
|
|
|
+ prodAttrResponse.setProdAttrId(prodAttr.getProdAttrId());
|
|
|
|
|
+ prodAttrResponse.setProdId(prodAttr.getProdId());
|
|
|
|
|
+ prodAttrResponse.setAttrName(prodAttr.getAttrName());
|
|
|
|
|
+ prodAttrResponse.setAttrType(prodAttr.getAttrType());
|
|
|
|
|
+ prodAttrResponse.setDelFlag(prodAttr.getDelFlag());
|
|
|
|
|
+
|
|
|
|
|
+ ProdAttrPrice condPrice = new ProdAttrPrice();
|
|
|
|
|
+ condPrice.setProdAttrId(prodAttr.getProdAttrId());
|
|
|
|
|
+ condPrice.setProdId(prodAttr.getProdId());
|
|
|
|
|
+ condPrice.setDelFlag(EDelFlag.NO.getVal());
|
|
|
|
|
+ condPrice.setBuyerRoleKey(ERoleKey.CUSTOMER.getCode());
|
|
|
|
|
+ condPrice.setSellerId(mercProd.getMercId());
|
|
|
|
|
+
|
|
|
|
|
+ List<ProdAttrPrice> priceList = prodAttrPriceService.selectProdAttrPriceList(condPrice);
|
|
|
|
|
+ if (priceList != null && !priceList.isEmpty()) {
|
|
|
|
|
+ prodAttrResponse.setProdAttrPrice(priceList.get(0));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ ProdAttrJoint condJoint = new ProdAttrJoint();
|
|
|
|
|
+ condJoint.setDelFlag(EDelFlag.NO.getVal());
|
|
|
|
|
+ condJoint.setProdId(prodAttr.getProdId());
|
|
|
|
|
+ condJoint.setProdAttrId(prodAttr.getProdAttrId());
|
|
|
|
|
+
|
|
|
|
|
+ List<ProdAttrJoint> prodAttrJointList = prodAttrJointService.selectProdAttrJointList(condJoint);
|
|
|
|
|
+ prodAttrResponse.setProdAttrJointList(prodAttrJointList);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ rtn.setProdAttrList(prodAttrResponseList);
|
|
|
|
|
+
|
|
|
|
|
+ return rtn;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|