|
|
@@ -16,9 +16,7 @@
|
|
|
*/
|
|
|
package org.springblade.salesPart.shopping.controller;
|
|
|
|
|
|
-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.ObjectUtils;
|
|
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
|
|
@@ -27,40 +25,34 @@ import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springblade.common.enums.CommonEnum;
|
|
|
+import org.springblade.common.enums.NumberEnum;
|
|
|
import org.springblade.core.boot.ctrl.BladeController;
|
|
|
import org.springblade.core.mp.support.Condition;
|
|
|
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.Func;
|
|
|
import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
-import org.springblade.salesPart.brand.service.IBrandDescService;
|
|
|
-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.productLaunch.service.IProductLaunchFilesService;
|
|
|
+import org.springblade.salesPart.entity.PjProductLaunch;
|
|
|
+import org.springblade.salesPart.entity.PjStockDesc;
|
|
|
+import org.springblade.salesPart.productLaunch.service.IProductLaunchService;
|
|
|
import org.springblade.salesPart.share.entity.SharePutOnShelves;
|
|
|
import org.springblade.salesPart.share.service.ISharePutOnShelvesService;
|
|
|
import org.springblade.salesPart.shopping.entity.ShoppingMallDetail;
|
|
|
import org.springblade.salesPart.shopping.service.IShoppingMallDetailService;
|
|
|
import org.springblade.salesPart.shopping.vo.ShoppingMallDetailVO;
|
|
|
-import org.springblade.salesPart.stock.mapper.StockDescMapper;
|
|
|
-import org.springblade.salesPart.util.UserUtils;
|
|
|
-import org.springblade.salesPart.vo.WeChatDetailStockVo;
|
|
|
+import org.springblade.salesPart.shopping.vo.WeChatGoodsDetailInventoryVo;
|
|
|
import org.springblade.salesPart.vo.WeChatGoodsDetailStockVo;
|
|
|
import org.springblade.system.feign.ISysClient;
|
|
|
-import org.springframework.util.CollectionUtils;
|
|
|
-import org.springframework.util.StringUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.*;
|
|
|
-import java.util.stream.Collectors;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
/**
|
|
|
* VIEW 控制器
|
|
|
@@ -75,14 +67,8 @@ import java.util.stream.Collectors;
|
|
|
public class ShoppingMallDetailController extends BladeController {
|
|
|
|
|
|
private final IShoppingMallDetailService shoppingMallDetailService;
|
|
|
- private final IBrandFilesService brandFilesService;
|
|
|
- private final IBrandDescService brandDescService;
|
|
|
- private final IProductLaunchFilesService productLaunchFilesService;
|
|
|
- private final ICorpsAttnService corpsAttnService;//客户联系人
|
|
|
- private final ICorpsDescService corpsDescService;//客户
|
|
|
+ private final IProductLaunchService productLaunchService;
|
|
|
private final ISysClient iSysClient;
|
|
|
- private final IBrandFigureService brandFigureService;
|
|
|
- private final StockDescMapper stockDescMapper;
|
|
|
private final ISharePutOnShelvesService sharePutOnShelvesService;
|
|
|
|
|
|
/**
|
|
|
@@ -187,38 +173,45 @@ public class ShoppingMallDetailController extends BladeController {
|
|
|
*/
|
|
|
@GetMapping("/listShareV1")
|
|
|
@ApiOperationSupport(order = 2)
|
|
|
- public R<Map<String, Object>> listShareV1(PjStockDesc stockDesc) {
|
|
|
+ public R<WeChatGoodsDetailInventoryVo> listShareV1(PjStockDesc stockDesc) {
|
|
|
+ WeChatGoodsDetailInventoryVo weChatGoodsDetailInventoryVo = new WeChatGoodsDetailInventoryVo();
|
|
|
Map<String, Object> map = new HashMap<>(2);
|
|
|
if (ObjectUtils.isNull(stockDesc.getCode())) {
|
|
|
- map.put("storeInventory", CommonEnum.ZERO.info);
|
|
|
- map.put("storeInventoryShare", CommonEnum.ZERO.info);
|
|
|
- return R.data(map);
|
|
|
+ weChatGoodsDetailInventoryVo.isZero();
|
|
|
+ return R.data(weChatGoodsDetailInventoryVo);
|
|
|
}
|
|
|
// 根据当前登录人获得客户
|
|
|
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("未查到用户信息");
|
|
|
- }
|
|
|
- LambdaQueryWrapper<ShoppingMallDetail> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- lambdaQueryWrapper.eq(ShoppingMallDetail::getTenantId, bladeUser.getTenantId())
|
|
|
- .eq(ShoppingMallDetail::getIsDeleted, 0)
|
|
|
- .eq(ShoppingMallDetail::getBillType, 0);
|
|
|
- if (ObjectUtil.isNotEmpty(stockDesc.getId())) {
|
|
|
- lambdaQueryWrapper.eq(ShoppingMallDetail::getId, stockDesc.getId());
|
|
|
+ String isOpenShare = iSysClient.getParamService(CommonEnum.WHETHER_OPEN_SHARE.info);
|
|
|
+ String isZeroInventory = iSysClient.getParamService(CommonEnum.WHETHER_ZERO_INVENTORY.info);
|
|
|
+ if (CommonEnum.ONE.info.equals(isOpenShare)) {
|
|
|
+ LambdaQueryWrapper<ShoppingMallDetail> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ lambdaQueryWrapper.eq(ShoppingMallDetail::getTenantId, bladeUser.getTenantId())
|
|
|
+ .eq(ShoppingMallDetail::getIsDeleted, 0)
|
|
|
+ .eq(ShoppingMallDetail::getBillType, 0);
|
|
|
+ if (ObjectUtil.isNotEmpty(stockDesc.getId())) {
|
|
|
+ lambdaQueryWrapper.eq(ShoppingMallDetail::getId, stockDesc.getId());
|
|
|
+ } else {
|
|
|
+ lambdaQueryWrapper.eq(ShoppingMallDetail::getGoodsCode, stockDesc.getCode());
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNull(isZeroInventory) || CommonEnum.ZERO.info.equals(isZeroInventory)) {
|
|
|
+ lambdaQueryWrapper.gt(ShoppingMallDetail::getInventory, 0);
|
|
|
+ }
|
|
|
+ ShoppingMallDetail shoppingMallDetail = shoppingMallDetailService.getOne(lambdaQueryWrapper);
|
|
|
+ weChatGoodsDetailInventoryVo.setStoreInventory(shoppingMallDetail != null ? shoppingMallDetail.getInventory().longValue() : 0L);
|
|
|
} else {
|
|
|
- lambdaQueryWrapper.eq(ShoppingMallDetail::getGoodsCode, stockDesc.getCode());
|
|
|
+ LambdaQueryWrapper<PjProductLaunch> productLaunchLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ if (ObjectUtil.isNotEmpty(stockDesc.getId())) {
|
|
|
+ productLaunchLambdaQueryWrapper.eq(PjProductLaunch::getId, stockDesc.getId());
|
|
|
+ } else {
|
|
|
+ productLaunchLambdaQueryWrapper.eq(PjProductLaunch::getCode, stockDesc.getCode());
|
|
|
+ }
|
|
|
+ productLaunchLambdaQueryWrapper.eq(PjProductLaunch::getTenantId, bladeUser.getTenantId());
|
|
|
+ productLaunchLambdaQueryWrapper.eq(PjProductLaunch::getIsDeleted, NumberEnum.Zero.number);
|
|
|
+ productLaunchLambdaQueryWrapper.last("limit 1");
|
|
|
+ PjProductLaunch productLaunch = productLaunchService.getOne(productLaunchLambdaQueryWrapper);
|
|
|
+ weChatGoodsDetailInventoryVo.setStoreInventory(Objects.isNull(productLaunch) ? 0L : productLaunch.getInventory().longValue());
|
|
|
}
|
|
|
- String status1 = iSysClient.getParamService(CommonEnum.WHETHER_ZERO_INVENTORY.info);
|
|
|
- if (ObjectUtils.isNull(status1) || CommonEnum.ZERO.info.equals(status1)) {
|
|
|
- lambdaQueryWrapper.gt(ShoppingMallDetail::getInventory, 0);
|
|
|
- }
|
|
|
- ShoppingMallDetail shoppingMallDetail = shoppingMallDetailService.getOne(lambdaQueryWrapper);
|
|
|
- map.put("storeInventory", shoppingMallDetail != null ? shoppingMallDetail.getInventory() : CommonEnum.ZERO.info);
|
|
|
List<SharePutOnShelves> sharePutOnShelvesList = sharePutOnShelvesService.list(new LambdaQueryWrapper<SharePutOnShelves>()
|
|
|
.eq(SharePutOnShelves::getTenantId, bladeUser.getTenantId())
|
|
|
.eq(SharePutOnShelves::getIsDeleted, 0)
|
|
|
@@ -226,7 +219,7 @@ public class ShoppingMallDetailController extends BladeController {
|
|
|
.eq(SharePutOnShelves::getShareStatus, "已确认")
|
|
|
.eq(SharePutOnShelves::getGoodsCode, stockDesc.getCode()));
|
|
|
map.put("storeInventoryShare", !sharePutOnShelvesList.isEmpty() ? sharePutOnShelvesList.stream().map(SharePutOnShelves::getInventory).reduce(BigDecimal.ZERO, BigDecimal::add) : CommonEnum.ZERO.info);
|
|
|
- return R.data(map);
|
|
|
+ return R.data(weChatGoodsDetailInventoryVo);
|
|
|
}
|
|
|
|
|
|
|