|
|
@@ -22,17 +22,26 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import org.springblade.common.enums.CommonEnum;
|
|
|
+import org.springblade.core.mp.support.Query;
|
|
|
+import org.springblade.core.secure.BladeUser;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.BeanUtil;
|
|
|
import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
+import org.springblade.salesPart.brand.mapper.BrandDescMapper;
|
|
|
import org.springblade.salesPart.brand.service.IBrandFigureService;
|
|
|
import org.springblade.salesPart.brand.service.IBrandFilesService;
|
|
|
import org.springblade.salesPart.corps.service.ICorpsAttnService;
|
|
|
import org.springblade.salesPart.corps.service.ICorpsDescService;
|
|
|
import org.springblade.salesPart.entity.*;
|
|
|
+import org.springblade.salesPart.enums.PriceSystem;
|
|
|
+import org.springblade.salesPart.enums.ProductLaunchPriceSystem;
|
|
|
import org.springblade.salesPart.excel.PjShipStockDetails;
|
|
|
import org.springblade.salesPart.excel.ProductLaunchImportCodeExcel;
|
|
|
import org.springblade.salesPart.excel.ProductLaunchImportExcel;
|
|
|
@@ -42,16 +51,21 @@ import org.springblade.salesPart.productLaunch.mapper.ProductLaunchMapper;
|
|
|
import org.springblade.salesPart.productLaunch.service.IProductLaunchFilesService;
|
|
|
import org.springblade.salesPart.productLaunch.service.IProductLaunchService;
|
|
|
import org.springblade.salesPart.serial.service.IPjpfSerialService;
|
|
|
+import org.springblade.salesPart.shopping.entity.ShoppingMallDetail;
|
|
|
+import org.springblade.salesPart.shopping.mapper.ShoppingMallDetailMapper;
|
|
|
import org.springblade.salesPart.shoppingCart.mapper.ShoppingCartMapper;
|
|
|
import org.springblade.salesPart.stock.mapper.StockDescMapper;
|
|
|
import org.springblade.salesPart.stock.service.IStockDescService;
|
|
|
import org.springblade.salesPart.vo.ProductLaunchVO;
|
|
|
+import org.springblade.salesPart.vo.WxAppGoodsImgVo;
|
|
|
+import org.springblade.salesPart.vo.WxAppGoodsParamsVo;
|
|
|
import org.springblade.system.entity.Dept;
|
|
|
import org.springblade.system.feign.ISysClient;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
@@ -80,6 +94,15 @@ public class ProductLaunchServiceImpl extends ServiceImpl<ProductLaunchMapper, P
|
|
|
private final IBrandFigureService brandFigureService;
|
|
|
private final StockDescMapper stockDescMapper;
|
|
|
|
|
|
+
|
|
|
+ private final BrandDescMapper brandDescMapper;
|
|
|
+
|
|
|
+
|
|
|
+ private final ProductLaunchMapper productLaunchMapper;
|
|
|
+
|
|
|
+
|
|
|
+ private final ShoppingMallDetailMapper shoppingMallDetailMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 获取详情
|
|
|
*
|
|
|
@@ -1172,4 +1195,105 @@ public class ProductLaunchServiceImpl extends ServiceImpl<ProductLaunchMapper, P
|
|
|
return baseMapper.updateProductLaunch(item);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public R<IPage<PjProductLaunch>> selectWxAppIndexPageList(PjProductLaunch productLaunch, Query query) {
|
|
|
+ BladeUser bladeUser = AuthUtil.getUser();
|
|
|
+ PjCorpsAttn corpsAttn = corpsAttnService.getAttn(bladeUser.getUserId());
|
|
|
+ if (ObjectUtil.isEmpty(corpsAttn)) {
|
|
|
+ throw new RuntimeException("未查到用户信息");
|
|
|
+ }
|
|
|
+ PjCorpsDesc corpsDesc = corpsDescService.getCorpsDesc(corpsAttn.getPid());
|
|
|
+ if (ObjectUtil.isEmpty(corpsDesc)) {
|
|
|
+ throw new RuntimeException("未查到用户信息");
|
|
|
+ }
|
|
|
+ WxAppGoodsParamsVo wxAppGoodsParamsVo = new WxAppGoodsParamsVo();
|
|
|
+ wxAppGoodsParamsVo.setTenantId(bladeUser.getTenantId());
|
|
|
+ wxAppGoodsParamsVo.setSalesCompanyId(bladeUser.getDeptId());
|
|
|
+ wxAppGoodsParamsVo.setBrandId(productLaunch.getBrandId());
|
|
|
+ brandIf:if (ObjectUtils.isNull(productLaunch.getBrandId())) {
|
|
|
+ // 如果
|
|
|
+ List<PjBrandDesc> pjBrandDescList = brandDescMapper.selectList(new LambdaQueryWrapper<PjBrandDesc>()
|
|
|
+ .eq(PjBrandDesc::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PjBrandDesc::getIsDeleted, 0)
|
|
|
+ .eq(PjBrandDesc::getType, "PP")
|
|
|
+ .eq(PjBrandDesc::getEnableOrNot, 1)
|
|
|
+ .apply("find_in_set(id,'" + corpsDesc.getBrandId() + "')"));
|
|
|
+ if (pjBrandDescList.isEmpty()) {
|
|
|
+ break brandIf;
|
|
|
+ }
|
|
|
+ wxAppGoodsParamsVo.setUserBrandIdList(pjBrandDescList.stream().map(PjBrandDesc::getId).distinct().collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ wxAppGoodsParamsVo.setExplosionProof(productLaunch.getExplosionProof());
|
|
|
+ wxAppGoodsParamsVo.setOriginalFactory(productLaunch.getOriginalFactory());
|
|
|
+ wxAppGoodsParamsVo.setSelfRecovery(productLaunch.getSelfRecovery());
|
|
|
+ cNameIf:if (ObjectUtil.isNotEmpty(productLaunch.getCname())) {
|
|
|
+ if (productLaunch.getCname().contains(",")) {
|
|
|
+ int index = productLaunch.getCname().indexOf(",");
|
|
|
+ String brandName = productLaunch.getCname().substring(0, index);
|
|
|
+ String cname = productLaunch.getCname().substring(index + 1);
|
|
|
+ wxAppGoodsParamsVo.setCname(cname);
|
|
|
+ wxAppGoodsParamsVo.setBrandName(brandName);
|
|
|
+ wxAppGoodsParamsVo.setCnameStatus(1);
|
|
|
+ break cNameIf;
|
|
|
+ }
|
|
|
+ String[] chineseWords = productLaunch.getCname().split("[^一-龥]");
|
|
|
+ if (chineseWords.length > 0) {
|
|
|
+ String cname = productLaunch.getCname().substring(chineseWords[0].length());
|
|
|
+ wxAppGoodsParamsVo.setCname(ObjectUtils.isNotNull(cname) ? cname : productLaunch.getCname());
|
|
|
+ wxAppGoodsParamsVo.setBrandName(ObjectUtils.isNull(cname) ? chineseWords[0]: null);
|
|
|
+ wxAppGoodsParamsVo.setCnameStatus(ObjectUtils.isNotNull(cname) ? 1 : 2);
|
|
|
+ break cNameIf;
|
|
|
+ }
|
|
|
+ wxAppGoodsParamsVo.setCname(productLaunch.getCname());
|
|
|
+ wxAppGoodsParamsVo.setCnameStatus(3);
|
|
|
+ }
|
|
|
+ wxAppGoodsParamsVo.setWhetherIntegral(productLaunch.getWhetherIntegral());
|
|
|
+ if (!CommonEnum.ONE.info.equals(productLaunch.getWhetherIntegral())) {
|
|
|
+ String status = iSysClient.getParamService(CommonEnum.WHETHER_BRANCH_MANAGEMENT.info);
|
|
|
+ managementIf: if (CommonEnum.ONE.info.equals(status) && ObjectUtils.isNotNull(corpsDesc.getDeliveryWarehouseId())) {
|
|
|
+ List<PjStockDesc> stockDescList = stockDescMapper.selectList(new LambdaQueryWrapper<PjStockDesc>()
|
|
|
+ .eq(PjStockDesc::getTenantId, bladeUser.getTenantId())
|
|
|
+ .eq(PjStockDesc::getIsDeleted, 0)
|
|
|
+ .eq(PjStockDesc::getStorageId, corpsDesc.getDeliveryWarehouseId()));
|
|
|
+ if (stockDescList.isEmpty()) {
|
|
|
+ break managementIf;
|
|
|
+ }
|
|
|
+ wxAppGoodsParamsVo.setGoodsIds(stockDescList.stream().map(PjStockDesc::getGoodsId).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String inventoryStatus = iSysClient.getParamService(CommonEnum.WHETHER_ZERO_INVENTORY.info);
|
|
|
+ if (ObjectUtils.isNull(inventoryStatus) || CommonEnum.ZERO.info.equals(inventoryStatus)) {
|
|
|
+ wxAppGoodsParamsVo.setInventoryStatus(0);
|
|
|
+ }
|
|
|
+ PageHelper.startPage(query.getCurrent(), query.getSize());
|
|
|
+ List<PjProductLaunch> pjProductLaunchList = productLaunchMapper.selectWxAppIndexPageList(wxAppGoodsParamsVo);
|
|
|
+ if (!org.springframework.util.CollectionUtils.isEmpty(pjProductLaunchList)) {
|
|
|
+ List<Long> ids = pjProductLaunchList.stream().map(PjProductLaunch::getId).collect(Collectors.toList());
|
|
|
+ List<Long> brandIds = pjProductLaunchList.stream().map(PjProductLaunch::getBrandId).distinct().collect(Collectors.toList());
|
|
|
+ // 查询商品的所有图片并根据匹配度与优先级显示
|
|
|
+ List<WxAppGoodsImgVo> wxAppGoodsImgVoList = shoppingMallDetailMapper.selectWxAppGoodsImgVoList(ids, brandIds);
|
|
|
+ for (PjProductLaunch item : pjProductLaunchList) {
|
|
|
+ ProductLaunchPriceSystem priceSystem = ProductLaunchPriceSystem.fromValue(corpsDesc.getPriceSystem());
|
|
|
+ priceSystem.setMallPrice(item);
|
|
|
+ WxAppGoodsImgVo wxAppGoodsImgVo = wxAppGoodsImgVoList.stream().filter(wxImg ->
|
|
|
+ 1 == wxImg.getType() && wxImg.getPid().equals(item.getId()) ||
|
|
|
+ 2 == wxImg.getType() && wxImg.getPid().equals(item.getBrandId()) && StringUtils.hasText(wxImg.getBrandItem()) && wxImg.getBrandItem().equals(item.getBrandItem()) ||
|
|
|
+ 3 == wxImg.getType() && wxImg.getPid().equals(item.getBrandId())
|
|
|
+ ).min(Comparator.comparing(WxAppGoodsImgVo::getType)).orElse(null);
|
|
|
+ if (wxAppGoodsImgVo == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ item.setUrl(wxAppGoodsImgVo.getUrl());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // TODO: 此处可优化
|
|
|
+ PageInfo<PjProductLaunch> pageInfo = new PageInfo<>(pjProductLaunchList);
|
|
|
+ IPage<PjProductLaunch> page = new Page<>();
|
|
|
+ page.setRecords(pageInfo.getList());
|
|
|
+ page.setTotal(pageInfo.getTotal());
|
|
|
+ page.setCurrent(pageInfo.getPageNum());
|
|
|
+ page.setSize(pageInfo.getPageSize());
|
|
|
+ return R.data(page);
|
|
|
+ }
|
|
|
+
|
|
|
}
|