|
|
@@ -1,5 +1,6 @@
|
|
|
package org.springblade.salesPart.shopping.service.impl;
|
|
|
|
|
|
+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;
|
|
|
@@ -7,6 +8,7 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
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;
|
|
|
@@ -20,6 +22,8 @@ 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.goods.mapper.GoodsDescMapper;
|
|
|
+import org.springblade.salesPart.productLaunch.mapper.ProductLaunchMapper;
|
|
|
import org.springblade.salesPart.productLaunch.service.IProductLaunchFilesService;
|
|
|
import org.springblade.salesPart.shopping.entity.ShoppingMallDetail;
|
|
|
import org.springblade.salesPart.shopping.mapper.ShoppingMallDetailMapper;
|
|
|
@@ -28,8 +32,8 @@ import org.springblade.salesPart.shopping.vo.ShoppingMallDetailVO;
|
|
|
import org.springblade.salesPart.stock.mapper.StockDescMapper;
|
|
|
import org.springblade.salesPart.util.PageHelperUtil;
|
|
|
import org.springblade.salesPart.util.UserUtils;
|
|
|
-import org.springblade.salesPart.vo.WxAppGoodsImgVo;
|
|
|
-import org.springblade.salesPart.vo.WxAppGoodsParamsVo;
|
|
|
+import org.springblade.salesPart.util.WxParamUtil;
|
|
|
+import org.springblade.salesPart.vo.*;
|
|
|
import org.springblade.system.feign.ISysClient;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
@@ -60,6 +64,11 @@ public class ShoppingMallDetailServiceImpl extends ServiceImpl<ShoppingMallDetai
|
|
|
private final BrandDescMapper brandDescMapper;
|
|
|
private final ShoppingMallDetailMapper shoppingMallDetailMapper;
|
|
|
|
|
|
+ private final ProductLaunchMapper productLaunchMapper;
|
|
|
+
|
|
|
+ private final GoodsDescMapper goodsDescMapper;
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public IPage<ShoppingMallDetailVO> selectShoppingMallDetailPage(IPage<ShoppingMallDetailVO> page, ShoppingMallDetailVO shoppingMallDetail) {
|
|
|
return page.setRecords(baseMapper.selectShoppingMallDetailPage(page, shoppingMallDetail));
|
|
|
@@ -315,4 +324,88 @@ public class ShoppingMallDetailServiceImpl extends ServiceImpl<ShoppingMallDetai
|
|
|
return R.data(PageHelperUtil.getPageInfo(shoppingMallDetailList));
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public R<WeChatGoodsDetailStockVo> getGoodsDetailStockByCloud(Long id) {
|
|
|
+ PjCorpsDesc corpsDesc = UserUtils.getUserCorpsDesc();
|
|
|
+ if (org.springframework.util.ObjectUtils.isEmpty(corpsDesc.getDeliveryWarehouseId())) {
|
|
|
+ return R.fail("请联系业务员设置发货仓库");
|
|
|
+ }
|
|
|
+ List<Long> corpsStorageIdList = new ArrayList<>();
|
|
|
+ corpsStorageIdList.add(corpsDesc.getDeliveryWarehouseId());
|
|
|
+ if (StringUtils.hasText(corpsDesc.getResourceWarehouse())) {
|
|
|
+ try {
|
|
|
+ corpsStorageIdList.addAll(JSONArray.parseArray(corpsDesc.getResourceWarehouse(), Long.class));
|
|
|
+ } catch (Exception e) {
|
|
|
+ return R.fail("请联系业务员设置资源仓库");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ PjProductLaunch productLaunch = productLaunchMapper.selectById(id);
|
|
|
+ if (org.springframework.util.ObjectUtils.isEmpty(productLaunch)) {
|
|
|
+ return R.fail("商品不存在,请联系业务员");
|
|
|
+ }
|
|
|
+ WeChatGoodsDetailStockVo weChatGoodsDetailStockVo = new WeChatGoodsDetailStockVo();
|
|
|
+ List<PjStockDesc> stockDescList = stockDescMapper.selectList(new LambdaQueryWrapper<PjStockDesc>()
|
|
|
+ .eq(PjStockDesc::getTenantId, corpsDesc.getTenantId()).eq(PjStockDesc::getGoodsId, productLaunch.getGoodsId())
|
|
|
+ .ne(PjStockDesc::getBalanceQuantity, 0)
|
|
|
+ .eq(PjStockDesc::getIsDeleted, 0).in(PjStockDesc::getStorageId, corpsStorageIdList));
|
|
|
+ if (CollectionUtils.isEmpty(stockDescList)) {
|
|
|
+ return R.data(weChatGoodsDetailStockVo);
|
|
|
+ }
|
|
|
+ List<WeChatDetailStockVo> weChatDetailStockVoList = new ArrayList<>();
|
|
|
+ for (PjStockDesc stockDesc : stockDescList) {
|
|
|
+ WeChatDetailStockVo weChatDetailStockVo = new WeChatDetailStockVo();
|
|
|
+ weChatDetailStockVo.setStorageName(stockDesc.getStorageName());
|
|
|
+ weChatDetailStockVo.setStoreInventory(stockDesc.getBalanceQuantity());
|
|
|
+ if (stockDesc.getStorageId().equals(corpsDesc.getDeliveryWarehouseId())) {
|
|
|
+ weChatGoodsDetailStockVo.setStoreInventory(stockDesc.getBalanceQuantity());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ weChatGoodsDetailStockVo.setStoreInventoryShare(stockDesc.getBalanceQuantity().add(weChatGoodsDetailStockVo.getStoreInventoryShare()));
|
|
|
+ }
|
|
|
+ weChatGoodsDetailStockVo.setWeChatDetailStockVos(weChatDetailStockVoList);
|
|
|
+ return R.data(weChatGoodsDetailStockVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R<Map<String, Object>> getGoodsDetailByCloud(Long id) {
|
|
|
+ PjCorpsDesc corpsDesc = UserUtils.getUserCorpsDesc();
|
|
|
+ Map<String, Object> resultMap = new HashMap<>(3);
|
|
|
+ PjProductLaunch detail = productLaunchMapper.selectById(id);
|
|
|
+ if (org.springframework.util.ObjectUtils.isEmpty(detail)) {
|
|
|
+ return R.fail("商品不存在,请联系业务员");
|
|
|
+ }
|
|
|
+ detail.setGoodsNum(BigDecimal.ONE);
|
|
|
+ List<PjProductLaunch> pjProductLaunchList = new ArrayList<>();
|
|
|
+ pjProductLaunchList.add(detail);
|
|
|
+ List<Long> ids = Collections.singletonList(detail.getId());
|
|
|
+ List<Long> brandIds = Collections.singletonList(detail.getBrandId());
|
|
|
+ // 查询商品的所有图片并根据匹配度与优先级显示
|
|
|
+ List<WxAppGoodsImgVo> wxAppGoodsImgVoList = shoppingMallDetailMapper.selectWxAppGoodsImgVoList(ids, brandIds);
|
|
|
+ WxParamUtil.findGoodsImg(pjProductLaunchList, wxAppGoodsImgVoList, corpsDesc.getPriceSystem());
|
|
|
+ PjGoodsDesc goodsDesc = goodsDescMapper.selectById(detail.getGoodsId());
|
|
|
+ if (!org.springframework.util.ObjectUtils.isEmpty(goodsDesc)){
|
|
|
+ detail.setCode(goodsDesc.getCode());
|
|
|
+ }
|
|
|
+ List<Long> corpsStorageIdList = new ArrayList<>();
|
|
|
+ corpsStorageIdList.add(corpsDesc.getDeliveryWarehouseId());
|
|
|
+ if (StringUtils.hasText(corpsDesc.getResourceWarehouse())) {
|
|
|
+ try {
|
|
|
+ corpsStorageIdList.addAll(JSONArray.parseArray(corpsDesc.getResourceWarehouse(), Long.class));
|
|
|
+ } catch (Exception e) {
|
|
|
+ return R.fail("请联系业务员设置资源仓库");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<PjStockDesc> stockDescList = stockDescMapper.selectList(new LambdaQueryWrapper<PjStockDesc>()
|
|
|
+ .eq(PjStockDesc::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PjStockDesc::getIsDeleted, 0)
|
|
|
+ .in(PjStockDesc::getStorageId, corpsStorageIdList)
|
|
|
+ .eq(PjStockDesc::getGoodsId, detail.getGoodsId())
|
|
|
+ );
|
|
|
+ detail.setInventory(CollectionUtils.isEmpty(stockDescList) ? BigDecimal.ZERO :stockDescList.stream().map(PjStockDesc::getBalanceQuantity).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ resultMap.put("type", detail.getBillType());
|
|
|
+ resultMap.put("thisLocality", detail);
|
|
|
+ resultMap.put("offsite", null);
|
|
|
+ return R.data(resultMap);
|
|
|
+ }
|
|
|
+
|
|
|
}
|