|
|
@@ -1,33 +1,15 @@
|
|
|
-/*
|
|
|
- * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
|
|
- *
|
|
|
- * Redistribution and use in source and binary forms, with or without
|
|
|
- * modification, are permitted provided that the following conditions are met:
|
|
|
- *
|
|
|
- * Redistributions of source code must retain the above copyright notice,
|
|
|
- * this list of conditions and the following disclaimer.
|
|
|
- * Redistributions in binary form must reproduce the above copyright
|
|
|
- * notice, this list of conditions and the following disclaimer in the
|
|
|
- * documentation and/or other materials provided with the distribution.
|
|
|
- * Neither the name of the dreamlu.net developer nor the names of its
|
|
|
- * contributors may be used to endorse or promote products derived from
|
|
|
- * this software without specific prior written permission.
|
|
|
- * Author: Chill 庄骞 (smallchill@163.com)
|
|
|
- */
|
|
|
package org.springblade.salesPart.productLaunch.service.impl;
|
|
|
|
|
|
import com.alibaba.csp.sentinel.util.StringUtil;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
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;
|
|
|
@@ -40,8 +22,6 @@ 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;
|
|
|
@@ -51,12 +31,15 @@ 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.util.PageHelperUtil;
|
|
|
+import org.springblade.salesPart.util.UserUtils;
|
|
|
+import org.springblade.salesPart.util.WxParamUtil;
|
|
|
import org.springblade.salesPart.vo.ProductLaunchVO;
|
|
|
+import org.springblade.salesPart.vo.ResourceWarehouseVo;
|
|
|
import org.springblade.salesPart.vo.WxAppGoodsImgVo;
|
|
|
import org.springblade.salesPart.vo.WxAppGoodsParamsVo;
|
|
|
import org.springblade.system.entity.Dept;
|
|
|
@@ -1200,74 +1183,9 @@ public class ProductLaunchServiceImpl extends ServiceImpl<ProductLaunchMapper, P
|
|
|
|
|
|
@Override
|
|
|
public R<IPage<PjProductLaunch>> selectWxAppIndexPageList(PjProductLaunch productLaunch, Query query) {
|
|
|
+ PjCorpsDesc corpsDesc = UserUtils.getUserCorpsDesc();
|
|
|
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(chineseWords[0]);
|
|
|
- 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);
|
|
|
- }
|
|
|
+ WxAppGoodsParamsVo wxAppGoodsParamsVo = WxParamUtil.parseWxAppGoodsParamsVoByProductLaunch(productLaunch, bladeUser, corpsDesc, iSysClient);
|
|
|
PageHelper.startPage(query.getCurrent(), query.getSize());
|
|
|
List<PjProductLaunch> pjProductLaunchList = productLaunchMapper.selectWxAppIndexPageList(wxAppGoodsParamsVo);
|
|
|
if (!org.springframework.util.CollectionUtils.isEmpty(pjProductLaunchList)) {
|
|
|
@@ -1275,28 +1193,32 @@ public class ProductLaunchServiceImpl extends ServiceImpl<ProductLaunchMapper, P
|
|
|
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());
|
|
|
- }
|
|
|
+ WxParamUtil.findGoodsImg(pjProductLaunchList, wxAppGoodsImgVoList, corpsDesc.getPriceSystem());
|
|
|
+ }
|
|
|
+ return R.data(PageHelperUtil.getPageInfo(pjProductLaunchList));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R<IPage<ResourceWarehouseVo>> selectCloudWarehouseList(PjProductLaunch productLaunch, Query query) {
|
|
|
+ PjCorpsDesc corpsDesc = UserUtils.getUserCorpsDesc();
|
|
|
+ BladeUser bladeUser = AuthUtil.getUser();
|
|
|
+ productLaunch.setTenantId(corpsDesc.getTenantId());
|
|
|
+ WxAppGoodsParamsVo wxAppGoodsParamsVo = WxParamUtil.parseWxAppGoodsParamsVoByProductLaunch(productLaunch, bladeUser, corpsDesc, iSysClient);
|
|
|
+ if (StringUtils.hasText(corpsDesc.getResourceWarehouse())) {
|
|
|
+ List<Long> storageIdList = JSONArray.parseArray(corpsDesc.getResourceWarehouse(), Long.class);
|
|
|
+ wxAppGoodsParamsVo.setStorageIdList(storageIdList);
|
|
|
+ }
|
|
|
+ wxAppGoodsParamsVo.setStorageId(corpsDesc.getDeliveryWarehouseId());
|
|
|
+ PageHelper.startPage(query.getCurrent(), query.getSize());
|
|
|
+ List<ResourceWarehouseVo> resourceWarehouseVoList = productLaunchMapper.selectCloudWarehouseList(wxAppGoodsParamsVo);
|
|
|
+ if (!org.springframework.util.CollectionUtils.isEmpty(resourceWarehouseVoList)) {
|
|
|
+ List<Long> ids = resourceWarehouseVoList.stream().map(ResourceWarehouseVo::getId).collect(Collectors.toList());
|
|
|
+ List<Long> brandIds = resourceWarehouseVoList.stream().map(ResourceWarehouseVo::getBrandId).distinct().collect(Collectors.toList());
|
|
|
+ // 查询商品的所有图片并根据匹配度与优先级显示
|
|
|
+ List<WxAppGoodsImgVo> wxAppGoodsImgVoList = shoppingMallDetailMapper.selectWxAppGoodsImgVoList(ids, brandIds);
|
|
|
+ WxParamUtil.findResourceWarehouseImg(resourceWarehouseVoList, wxAppGoodsImgVoList, corpsDesc.getPriceSystem());
|
|
|
}
|
|
|
- // 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);
|
|
|
+ return R.data(PageHelperUtil.getPageInfo(resourceWarehouseVoList));
|
|
|
}
|
|
|
|
|
|
}
|