|
|
@@ -27,9 +27,11 @@ import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import org.springblade.common.enums.CommonEnum;
|
|
|
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;
|
|
|
@@ -182,52 +184,40 @@ public class ShoppingMallDetailController extends BladeController {
|
|
|
@GetMapping("/listShareV1")
|
|
|
@ApiOperationSupport(order = 2)
|
|
|
public R<Map<String, Object>> listShareV1(PjStockDesc stockDesc) {
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
+ Map<String, Object> map = new HashMap<>(2);
|
|
|
if (ObjectUtils.isNull(stockDesc.getCode())) {
|
|
|
- map.put("storeInventory", "0");
|
|
|
- map.put("storeInventoryShare", "0");
|
|
|
+ map.put("storeInventory", CommonEnum.ZERO.info);
|
|
|
+ map.put("storeInventoryShare", CommonEnum.ZERO.info);
|
|
|
return R.data(map);
|
|
|
}
|
|
|
- PjCorpsDesc corpsDesc = null;
|
|
|
- //根据当前登录人获得客户
|
|
|
- PjCorpsAttn corpsAttn = corpsAttnService.getAttn(AuthUtil.getUserId());
|
|
|
- if (ObjectUtil.isNotEmpty(corpsAttn)) {
|
|
|
- corpsDesc = corpsDescService.getCorpsDesc(corpsAttn.getPid());
|
|
|
- if (ObjectUtil.isEmpty(corpsDesc)) {
|
|
|
- throw new RuntimeException("未查到用户信息");
|
|
|
- }
|
|
|
- } else {
|
|
|
+ // 根据当前登录人获得客户
|
|
|
+ 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, AuthUtil.getTenantId())
|
|
|
+ lambdaQueryWrapper.eq(ShoppingMallDetail::getTenantId, bladeUser.getTenantId())
|
|
|
.eq(ShoppingMallDetail::getIsDeleted, 0)
|
|
|
.eq(ShoppingMallDetail::getBillType, 0)
|
|
|
- .eq(ObjectUtils.isNotEmpty(stockDesc.getCode()), ShoppingMallDetail::getGoodsCode, stockDesc.getCode());
|
|
|
- String status1 = iSysClient.getParamService("whether.zero.inventory");
|
|
|
- if (ObjectUtils.isNull(status1) || "0".equals(status1)) {
|
|
|
+ .eq(ShoppingMallDetail::getId, stockDesc.getId());
|
|
|
+ String status1 = iSysClient.getParamService(CommonEnum.WHETHER_ZERO_INVENTORY.info);
|
|
|
+ if (ObjectUtils.isNull(status1) || CommonEnum.ZERO.info.equals(status1)) {
|
|
|
lambdaQueryWrapper.gt(ShoppingMallDetail::getInventory, 0);
|
|
|
}
|
|
|
- lambdaQueryWrapper.orderByAsc(ShoppingMallDetail::getCnameInt);
|
|
|
- lambdaQueryWrapper.orderByDesc(ShoppingMallDetail::getInventory);
|
|
|
ShoppingMallDetail shoppingMallDetail = shoppingMallDetailService.getOne(lambdaQueryWrapper);
|
|
|
-
|
|
|
- if (shoppingMallDetail != null) {
|
|
|
- map.put("storeInventory", shoppingMallDetail.getInventory());
|
|
|
- } else {
|
|
|
- map.put("storeInventory", "0");
|
|
|
- }
|
|
|
+ map.put("storeInventory", shoppingMallDetail != null ? shoppingMallDetail.getInventory() : CommonEnum.ZERO.info);
|
|
|
List<SharePutOnShelves> sharePutOnShelvesList = sharePutOnShelvesService.list(new LambdaQueryWrapper<SharePutOnShelves>()
|
|
|
- .eq(SharePutOnShelves::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(SharePutOnShelves::getTenantId, bladeUser.getTenantId())
|
|
|
.eq(SharePutOnShelves::getIsDeleted, 0)
|
|
|
.eq(SharePutOnShelves::getBillType, 1)
|
|
|
.eq(SharePutOnShelves::getShareStatus, "已确认")
|
|
|
.eq(SharePutOnShelves::getGoodsCode, stockDesc.getCode()));
|
|
|
- if (!sharePutOnShelvesList.isEmpty()) {
|
|
|
- map.put("storeInventoryShare", sharePutOnShelvesList.stream().map(SharePutOnShelves::getInventory).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
- } else {
|
|
|
- map.put("storeInventoryShare", "0");
|
|
|
- }
|
|
|
+ map.put("storeInventoryShare", !sharePutOnShelvesList.isEmpty() ? sharePutOnShelvesList.stream().map(SharePutOnShelves::getInventory).reduce(BigDecimal.ZERO, BigDecimal::add): CommonEnum.ZERO.info);
|
|
|
return R.data(map);
|
|
|
}
|
|
|
|