|
|
@ -8,10 +8,12 @@ import com.qs.serve.common.model.dto.R; |
|
|
|
import com.qs.serve.common.model.enums.BizType; |
|
|
|
import com.qs.serve.common.model.enums.SystemModule; |
|
|
|
import com.qs.serve.common.util.*; |
|
|
|
import com.qs.serve.modules.erp.mapper.ErpDispatchDataMapper; |
|
|
|
import com.qs.serve.modules.goods.common.GoodsConst; |
|
|
|
import com.qs.serve.modules.goods.entity.*; |
|
|
|
import com.qs.serve.modules.goods.entity.bo.*; |
|
|
|
import com.qs.serve.modules.goods.entity.dto.InventoryCusPrice; |
|
|
|
import com.qs.serve.modules.goods.entity.so.GoodsHisOrderQuery; |
|
|
|
import com.qs.serve.modules.goods.entity.so.InventoryCusPriceQuery; |
|
|
|
import com.qs.serve.modules.goods.entity.vo.GoodsSpuVo; |
|
|
|
import com.qs.serve.modules.goods.service.*; |
|
|
@ -25,10 +27,12 @@ import com.qs.serve.modules.tbs.service.TbsBudgetConditionService; |
|
|
|
import io.netty.util.internal.StringUtil; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.jetbrains.annotations.NotNull; |
|
|
|
import org.springframework.security.access.prepost.PreAuthorize; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import javax.validation.Valid; |
|
|
|
import java.time.LocalDate; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Locale; |
|
|
@ -53,6 +57,7 @@ public class GoodsSpuController { |
|
|
|
private TbsBudgetConditionService budgetConditionService; |
|
|
|
private GoodsCategoryService goodsCategoryService; |
|
|
|
private SeeYonRequestBaseService seeYonRequestBaseService; |
|
|
|
private ErpDispatchDataMapper dispatchDataMapper; |
|
|
|
|
|
|
|
/** |
|
|
|
* 翻页搜索 |
|
|
@ -85,63 +90,35 @@ public class GoodsSpuController { |
|
|
|
@GetMapping("/shelfPageToSku") |
|
|
|
public R<PageVo<GoodsSpu>> shelfPageToSku(GoodsSpu param){ |
|
|
|
PageVo<GoodsSpu> result = this.getShelfPage(param).getData(); |
|
|
|
List<GoodsSpu> goodsSpuList = result.getList(); |
|
|
|
List<String> spuCodes = goodsSpuList.stream().map(GoodsSpu::getSpuCode).collect(Collectors.toList()); |
|
|
|
List<OmsSpuToSkuKey> toSkuKeys = goodsSpuService.getSpuToSkuInfo(GoodsConst.DEFAULT_PlaCE,spuCodes); |
|
|
|
|
|
|
|
List<InventoryCusPrice> inventoryCusPrices = null; |
|
|
|
try { |
|
|
|
String supplierCode = param.getSupplierCode(); |
|
|
|
List<String> skuCodes = toSkuKeys.stream().map(OmsSpuToSkuKey::getInvCode).collect(Collectors.toList()); |
|
|
|
if(skuCodes.size()>0){ |
|
|
|
InventoryCusPriceQuery query = new InventoryCusPriceQuery(); |
|
|
|
query.setCusCode(supplierCode); |
|
|
|
query.setInvCodes(skuCodes); |
|
|
|
R<String> res = seeYonRequestBaseService.postBase(TbsSeeYonConst.ERP_CUS_INV_PRICE,query,"查询客户特殊价"); |
|
|
|
if(res.getStatus().equals(200)){ |
|
|
|
inventoryCusPrices = JsonUtil.jsonToList(res.getData(), InventoryCusPrice.class); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("客户特殊价异常:{}",e.getMessage()); |
|
|
|
} |
|
|
|
|
|
|
|
for (GoodsSpu spu : goodsSpuList) { |
|
|
|
//兼容特殊sku
|
|
|
|
if(param.getSelectSpecialFlag()!=null&¶m.getSelectSpecialFlag().equals(1)){ |
|
|
|
if(!spu.getSpecialSkuId().equals(0L)){ |
|
|
|
GoodsSku goodsSku = goodsSkuService.getById(spu.getSpecialSkuId()); |
|
|
|
spu.setSkuCode(goodsSku.getSkuCode()); |
|
|
|
spu.setSkuPrice(goodsSku.getSalesPrice()); |
|
|
|
spu.setVolume(goodsSku.getVolume().toString()); |
|
|
|
spu.setWeight(goodsSku.getWeight().toString()); |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
for (OmsSpuToSkuKey skuKey : toSkuKeys) { |
|
|
|
if(spu.getSpuCode().equals(skuKey.getSkuCode())){ |
|
|
|
GoodsSku goodsSku = goodsSkuService.getByCode(skuKey.getInvCode()); |
|
|
|
spu.setSkuCode(goodsSku.getSkuCode()); |
|
|
|
spu.setSkuPrice(goodsSku.getSalesPrice()); |
|
|
|
spu.setVolume(goodsSku.getVolume().toString()); |
|
|
|
spu.setWeight(goodsSku.getWeight().toString()); |
|
|
|
if(inventoryCusPrices!=null){ |
|
|
|
for (InventoryCusPrice cusPrice : inventoryCusPrices) { |
|
|
|
if(cusPrice.getPrice()!=null&&cusPrice.getInvCode().equals(skuKey.getInvCode())){ |
|
|
|
spu.setSkuPrice(cusPrice.getPrice()); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
List<GoodsSpu> goodsSpuList = this.buildGoodsSpuInfo(param.getSupplierCode(),param.getSelectSpecialFlag(), result.getList()); |
|
|
|
result.setList(goodsSpuList); |
|
|
|
return R.ok(result); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result.setList(goodsSpuList); |
|
|
|
return R.ok(result); |
|
|
|
/** |
|
|
|
* 获取最近两个月发货spu |
|
|
|
* @param query |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@PostMapping("listLast2Month") |
|
|
|
public R<List<GoodsSpu>> listLast2Month(@RequestBody @Valid GoodsHisOrderQuery query){ |
|
|
|
LocalDate date = LocalDate.now().plusMonths(-2); |
|
|
|
List<String> invCodes = dispatchDataMapper.selectLast2MonthInvCode(date); |
|
|
|
|
|
|
|
if(CollectionUtil.isNotEmpty(invCodes)){ |
|
|
|
List<GoodsSku> goodsSkus = goodsSkuService.getByCodes(invCodes); |
|
|
|
List<Long> goodsSpuIds = goodsSkus.stream().map(GoodsSku::getSpuId).distinct().collect(Collectors.toList()); |
|
|
|
GoodsSpu param = new GoodsSpu(); |
|
|
|
param.setSelectIds(goodsSpuIds); |
|
|
|
param.setSelectCateIds(query.getCateIds()); |
|
|
|
param.setShelf(1); |
|
|
|
List<GoodsSpu> list = goodsSpuService.selectSpuList(param); |
|
|
|
List<GoodsSpu> goodsSpuList = this.buildGoodsSpuInfo(query.getSupplierCode(),0, list); |
|
|
|
return R.ok(goodsSpuList); |
|
|
|
} |
|
|
|
return R.ok(new ArrayList<>()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -436,5 +413,67 @@ public class GoodsSpuController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 封装通用的spu信息(客户特殊价,转换并关联开平产SKU) |
|
|
|
* @param supplierCode 客户编码 |
|
|
|
* @param selectSpecialFlag 兼容特殊sku |
|
|
|
* @param goodsSpuList |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@NotNull |
|
|
|
private List<GoodsSpu> buildGoodsSpuInfo(String supplierCode,Integer selectSpecialFlag, List<GoodsSpu> goodsSpuList) { |
|
|
|
List<String> spuCodes = goodsSpuList.stream().map(GoodsSpu::getSpuCode).collect(Collectors.toList()); |
|
|
|
List<OmsSpuToSkuKey> toSkuKeys = goodsSpuService.getSpuToSkuInfo(GoodsConst.DEFAULT_PlaCE,spuCodes); |
|
|
|
|
|
|
|
List<InventoryCusPrice> inventoryCusPrices = null; |
|
|
|
try { |
|
|
|
List<String> skuCodes = toSkuKeys.stream().map(OmsSpuToSkuKey::getInvCode).collect(Collectors.toList()); |
|
|
|
if(skuCodes.size()>0){ |
|
|
|
InventoryCusPriceQuery query = new InventoryCusPriceQuery(); |
|
|
|
query.setCusCode(supplierCode); |
|
|
|
query.setInvCodes(skuCodes); |
|
|
|
R<String> res = seeYonRequestBaseService.postBase(TbsSeeYonConst.ERP_CUS_INV_PRICE,query,"查询客户特殊价"); |
|
|
|
if(res.getStatus().equals(200)){ |
|
|
|
inventoryCusPrices = JsonUtil.jsonToList(res.getData(), InventoryCusPrice.class); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("客户特殊价异常:{}",e.getMessage()); |
|
|
|
} |
|
|
|
|
|
|
|
for (GoodsSpu spu : goodsSpuList) { |
|
|
|
//兼容特殊sku
|
|
|
|
if(selectSpecialFlag!=null&& selectSpecialFlag.equals(1)){ |
|
|
|
if(!spu.getSpecialSkuId().equals(0L)){ |
|
|
|
GoodsSku goodsSku = goodsSkuService.getById(spu.getSpecialSkuId()); |
|
|
|
spu.setSkuCode(goodsSku.getSkuCode()); |
|
|
|
spu.setSkuPrice(goodsSku.getSalesPrice()); |
|
|
|
spu.setVolume(goodsSku.getVolume().toString()); |
|
|
|
spu.setWeight(goodsSku.getWeight().toString()); |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
for (OmsSpuToSkuKey skuKey : toSkuKeys) { |
|
|
|
if(spu.getSpuCode().equals(skuKey.getSkuCode())){ |
|
|
|
GoodsSku goodsSku = goodsSkuService.getByCode(skuKey.getInvCode()); |
|
|
|
spu.setSkuCode(goodsSku.getSkuCode()); |
|
|
|
spu.setSkuPrice(goodsSku.getSalesPrice()); |
|
|
|
spu.setVolume(goodsSku.getVolume().toString()); |
|
|
|
spu.setWeight(goodsSku.getWeight().toString()); |
|
|
|
if(inventoryCusPrices!=null){ |
|
|
|
for (InventoryCusPrice cusPrice : inventoryCusPrices) { |
|
|
|
if(cusPrice.getPrice()!=null&&cusPrice.getInvCode().equals(skuKey.getInvCode())){ |
|
|
|
spu.setSkuPrice(cusPrice.getPrice()); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return goodsSpuList; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|