|
|
@@ -161,281 +161,7 @@ public class ShoppingMallDetailController extends BladeController {
|
|
|
@ApiOperationSupport(order = 12)
|
|
|
@ApiOperation(value = "小程序配件批发产品上架", notes = "传入productLaunch")
|
|
|
public R<IPage<ShoppingMallDetail>> appList(PjProductLaunch productLaunch, Query query) {
|
|
|
- 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 {
|
|
|
- throw new RuntimeException("未查到用户信息");
|
|
|
- }
|
|
|
- LambdaQueryWrapper<ShoppingMallDetail> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- lambdaQueryWrapper.select(ShoppingMallDetail::getGoodsCode);
|
|
|
- lambdaQueryWrapper.eq(ShoppingMallDetail::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(ShoppingMallDetail::getIsDeleted, 0)
|
|
|
- .eq(ShoppingMallDetail::getSalesCompanyId, AuthUtil.getDeptId())//公司
|
|
|
- .eq(ObjectUtils.isNotEmpty(productLaunch.getBrandId()), ShoppingMallDetail::getBrandId, productLaunch.getBrandId());//品牌
|
|
|
- if (ObjectUtils.isNotNull(corpsDesc.getBrandId())) {
|
|
|
- List<PjBrandDesc> pjBrandDescList = brandDescService.list(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()) {
|
|
|
- lambdaQueryWrapper.in(ShoppingMallDetail::getBrandId, pjBrandDescList.stream().map(PjBrandDesc::getId).collect(Collectors.toList()));
|
|
|
- }
|
|
|
- }
|
|
|
- if (ObjectUtils.isNotEmpty(productLaunch.getExplosionProof())
|
|
|
- || ObjectUtils.isNotEmpty(productLaunch.getOriginalFactory())
|
|
|
- || ObjectUtils.isNotEmpty(productLaunch.getSelfRecovery())) {
|
|
|
- lambdaQueryWrapper.and(i -> i.eq(ObjectUtils.isNotEmpty(productLaunch.getExplosionProof()), ShoppingMallDetail::getExplosionProof, productLaunch.getExplosionProof())//防爆
|
|
|
- .or().eq(ObjectUtils.isNotEmpty(productLaunch.getOriginalFactory()), ShoppingMallDetail::getOriginalFactory, productLaunch.getOriginalFactory())//原厂
|
|
|
- .or().eq(ObjectUtils.isNotEmpty(productLaunch.getSelfRecovery()), ShoppingMallDetail::getSelfRecovery, productLaunch.getSelfRecovery())//自修补
|
|
|
- );
|
|
|
- }
|
|
|
- if (ObjectUtil.isNotEmpty(productLaunch.getCname())) {
|
|
|
- if (productLaunch.getCname().contains(",")) {
|
|
|
- String brandName = productLaunch.getCname().substring(0, productLaunch.getCname().indexOf(","));
|
|
|
- String cname = productLaunch.getCname().substring(productLaunch.getCname().indexOf(",") + 1);
|
|
|
- lambdaQueryWrapper.and(i -> i.like(ShoppingMallDetail::getGoodsName, cname)
|
|
|
- .or().like(ShoppingMallDetail::getCnameInt, cname)
|
|
|
- .or().like(ShoppingMallDetail::getBrandItem, cname)
|
|
|
- .or().like(ShoppingMallDetail::getSpecificationAndModel, cname)
|
|
|
- );
|
|
|
- lambdaQueryWrapper.like(ShoppingMallDetail::getBrandName, brandName);
|
|
|
- } else {
|
|
|
- String[] chineseWords = productLaunch.getCname().split("[^一-龥]");
|
|
|
- if (chineseWords.length > 0) {
|
|
|
- String cname = productLaunch.getCname().substring(chineseWords[0].length());
|
|
|
- if (ObjectUtils.isNotNull(cname)) {
|
|
|
- lambdaQueryWrapper.and(i -> i.like(ShoppingMallDetail::getGoodsName, cname)
|
|
|
- .or().like(ShoppingMallDetail::getCnameInt, cname)
|
|
|
- .or().like(ShoppingMallDetail::getBrandItem, cname)
|
|
|
- .or().like(ShoppingMallDetail::getSpecificationAndModel, cname)
|
|
|
- );
|
|
|
- lambdaQueryWrapper.like(ShoppingMallDetail::getBrandName, chineseWords[0]);
|
|
|
- } else {
|
|
|
- lambdaQueryWrapper.and(i -> i.like(ShoppingMallDetail::getGoodsName, productLaunch.getCname())
|
|
|
- .or().like(ShoppingMallDetail::getCnameInt, productLaunch.getCname())
|
|
|
- .or().like(ShoppingMallDetail::getBrandItem, productLaunch.getCname())
|
|
|
- .or().like(ShoppingMallDetail::getSpecificationAndModel, productLaunch.getCname())
|
|
|
- .or().like(ShoppingMallDetail::getBrandName, chineseWords[0])
|
|
|
- );
|
|
|
- }
|
|
|
- } else {
|
|
|
- lambdaQueryWrapper.and(i -> i.like(ShoppingMallDetail::getGoodsName, productLaunch.getCname())
|
|
|
- .or().like(ShoppingMallDetail::getCnameInt, productLaunch.getCname())
|
|
|
- .or().like(ShoppingMallDetail::getBrandItem, productLaunch.getCname())
|
|
|
- .or().like(ShoppingMallDetail::getSpecificationAndModel, productLaunch.getCname())
|
|
|
- );
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- List<PjStockDesc> stockDescList = new ArrayList<>();
|
|
|
- String status = iSysClient.getParamService("whether.branch.management");
|
|
|
- if (ObjectUtils.isNotNull(status) && "1".equals(status)) {
|
|
|
- if (ObjectUtils.isNotNull(corpsDesc.getDeliveryWarehouseId())) {
|
|
|
- stockDescList = stockDescMapper.selectList(new LambdaQueryWrapper<PjStockDesc>()
|
|
|
- .eq(PjStockDesc::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(PjStockDesc::getIsDeleted, 0)
|
|
|
- .eq(PjStockDesc::getStorageId, corpsDesc.getDeliveryWarehouseId()));
|
|
|
- if (!stockDescList.isEmpty()) {
|
|
|
- List<Long> goodsId = stockDescList.stream().map(PjStockDesc::getGoodsId).collect(Collectors.toList());
|
|
|
- lambdaQueryWrapper.in(ShoppingMallDetail::getGoodsId, goodsId);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- String status1 = iSysClient.getParamService("whether.zero.inventory");
|
|
|
- if (ObjectUtils.isNull(status1) || "0".equals(status1)) {
|
|
|
- lambdaQueryWrapper.gt(ShoppingMallDetail::getInventory, 0);
|
|
|
- }
|
|
|
- lambdaQueryWrapper.orderByAsc(ShoppingMallDetail::getBillType);
|
|
|
- lambdaQueryWrapper.orderByDesc(ShoppingMallDetail::getInventory);
|
|
|
- lambdaQueryWrapper.orderByAsc(ShoppingMallDetail::getCnameInt);
|
|
|
- lambdaQueryWrapper.groupBy(ShoppingMallDetail::getGoodsCode);
|
|
|
- IPage<ShoppingMallDetail> pages = shoppingMallDetailService.page(Condition.getPage(query), lambdaQueryWrapper);
|
|
|
-
|
|
|
- if (CollectionUtils.isNotEmpty(pages.getRecords())) {
|
|
|
- List<String> codeList = pages.getRecords().stream().map(ShoppingMallDetail::getGoodsCode).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
- List<ShoppingMallDetail> shoppingMallDetailList = new ArrayList<>();
|
|
|
- List<ShoppingMallDetail> shoppingMallDetailShareList = new ArrayList<>();
|
|
|
- if (!codeList.isEmpty()) {
|
|
|
- shoppingMallDetailList = shoppingMallDetailService.list(new LambdaQueryWrapper<ShoppingMallDetail>()
|
|
|
- .eq(ShoppingMallDetail::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(ShoppingMallDetail::getIsDeleted, 0)
|
|
|
- .eq(ShoppingMallDetail::getBillType, 0)
|
|
|
- .in(ShoppingMallDetail::getGoodsCode, codeList));
|
|
|
- shoppingMallDetailShareList = shoppingMallDetailService.list(new LambdaQueryWrapper<ShoppingMallDetail>()
|
|
|
- .eq(ShoppingMallDetail::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(ShoppingMallDetail::getIsDeleted, 0)
|
|
|
- .eq(ShoppingMallDetail::getBillType, 1)
|
|
|
- .in(ShoppingMallDetail::getGoodsCode, codeList));
|
|
|
- }
|
|
|
- List<ShoppingMallDetail> mallDetails = new ArrayList<>();
|
|
|
- for (ShoppingMallDetail item : pages.getRecords()) {
|
|
|
- if (!shoppingMallDetailList.isEmpty()) {
|
|
|
- ShoppingMallDetail shoppingMallDetail = shoppingMallDetailList.stream()
|
|
|
- .filter(e -> e.getGoodsCode().equals(item.getGoodsCode())).findFirst().orElse(null);
|
|
|
- if (shoppingMallDetail != null) {
|
|
|
- BeanUtil.copyProperties(shoppingMallDetail, item);
|
|
|
- item.setInventoryLocal(item.getInventory());
|
|
|
- if (!shoppingMallDetailShareList.isEmpty()) {
|
|
|
- BigDecimal inventory = shoppingMallDetailShareList.stream().filter(e -> e.getGoodsCode().equals(item.getGoodsCode()))
|
|
|
- .map(ShoppingMallDetail::getInventory).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- item.setInventory(item.getInventory().add(inventory));
|
|
|
- item.setInventoryShare(inventory);
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (!shoppingMallDetailShareList.isEmpty()) {
|
|
|
- ShoppingMallDetail shoppingMallShareDetail = shoppingMallDetailShareList.stream()
|
|
|
- .filter(e -> e.getGoodsCode().equals(item.getGoodsCode())).findFirst().orElse(null);
|
|
|
- if (shoppingMallShareDetail != null) {
|
|
|
- BeanUtil.copyProperties(shoppingMallShareDetail, item);
|
|
|
- item.setInventoryShare(item.getInventory());
|
|
|
- item.setInventoryLocal(new BigDecimal("0"));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (!shoppingMallDetailShareList.isEmpty()) {
|
|
|
- ShoppingMallDetail shoppingMallShareDetail = shoppingMallDetailShareList.stream()
|
|
|
- .filter(e -> e.getGoodsCode().equals(item.getGoodsCode())).findFirst().orElse(null);
|
|
|
- if (shoppingMallShareDetail != null) {
|
|
|
- BeanUtil.copyProperties(shoppingMallShareDetail, item);
|
|
|
- item.setInventoryShare(item.getInventory());
|
|
|
- item.setInventoryLocal(new BigDecimal("0"));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- item.setCname(item.getGoodsName());
|
|
|
- if (StringUtils.isNotBlank(corpsDesc.getPriceSystem())) {
|
|
|
- if ("售价1".equals(corpsDesc.getPriceSystem())) {
|
|
|
- item.setMallPrice(item.getPriceOne());
|
|
|
- } else if ("售价2".equals(corpsDesc.getPriceSystem())) {
|
|
|
- item.setMallPrice(item.getPriceTwo());
|
|
|
- } else if ("售价3".equals(corpsDesc.getPriceSystem())) {
|
|
|
- item.setMallPrice(item.getPriceThree());
|
|
|
- } else if ("售价4".equals(corpsDesc.getPriceSystem())) {
|
|
|
- item.setMallPrice(item.getPriceFour());
|
|
|
- } else {
|
|
|
- item.setMallPrice(item.getPriceOne());
|
|
|
- }
|
|
|
- } else {
|
|
|
- item.setMallPrice(item.getPriceOne());
|
|
|
- }
|
|
|
- mallDetails.add(item);
|
|
|
- }
|
|
|
- List<PjProductLaunchFiles> pjProductLaunchFilesList = new ArrayList<>();
|
|
|
- List<PjBrandFiles> pjBrandFilesList = new ArrayList<>();
|
|
|
- List<BrandFigure> brandFigureList = new ArrayList<>();
|
|
|
- List<Long> ids = shoppingMallDetailList.stream().map(ShoppingMallDetail::getId).collect(Collectors.toList());
|
|
|
- List<Long> brandIds = pages.getRecords().stream().map(ShoppingMallDetail::getBrandId).collect(Collectors.toList());
|
|
|
- if (!ids.isEmpty()) {
|
|
|
- pjProductLaunchFilesList = productLaunchFilesService.list(new QueryWrapper<PjProductLaunchFiles>()
|
|
|
- .in("pid", ids).eq("is_deleted", 0));
|
|
|
- }
|
|
|
- if (!brandIds.isEmpty()) {
|
|
|
- pjBrandFilesList = brandFilesService.list(new QueryWrapper<PjBrandFiles>()
|
|
|
- .in("pid", brandIds).eq("is_deleted", 0));
|
|
|
- brandFigureList = brandFigureService.list(new QueryWrapper<BrandFigure>()
|
|
|
- .in("pid", brandIds).eq("is_deleted", 0));
|
|
|
- }
|
|
|
- for (ShoppingMallDetail item : mallDetails) {
|
|
|
- if (ObjectUtils.isNotNull(item.getUrl())){
|
|
|
- List<PjProductLaunchFiles> filesList = new ArrayList<>();
|
|
|
- PjProductLaunchFiles files = new PjProductLaunchFiles();
|
|
|
- files.setUrl(item.getUrl());
|
|
|
- files.setVersion("0");
|
|
|
- filesList.add(files);
|
|
|
- item.setFilesList(filesList);
|
|
|
- }else{
|
|
|
- if (!pjProductLaunchFilesList.isEmpty()) {
|
|
|
- List<PjProductLaunchFiles> list = pjProductLaunchFilesList.stream().filter(e -> e.getPid().equals(item.getId())).collect(Collectors.toList());
|
|
|
- if (!list.isEmpty()) {
|
|
|
- item.setFilesList(list);
|
|
|
- } else {
|
|
|
- if (ObjectUtils.isNotNull(item.getBrandId())) {
|
|
|
- if (!brandFigureList.isEmpty()) {
|
|
|
- List<BrandFigure> brandFigureList1 = brandFigureList.stream()
|
|
|
- .filter(e -> e.getPid().equals(item.getBrandId()) && e.getFigure().equals(item.getBrandItem()))
|
|
|
- .collect(Collectors.toList());
|
|
|
- if (!brandFigureList1.isEmpty()) {
|
|
|
- item.setFilesList(BeanUtil.copy(brandFigureList1, PjProductLaunchFiles.class));
|
|
|
- } else {
|
|
|
- if (!pjBrandFilesList.isEmpty()) {
|
|
|
- List<PjBrandFiles> pjBarndFilesList1 = pjBrandFilesList.stream()
|
|
|
- .filter(e -> e.getPid().equals(item.getBrandId()))
|
|
|
- .collect(Collectors.toList());
|
|
|
- if (!pjBarndFilesList1.isEmpty()) {
|
|
|
- item.setFilesList(BeanUtil.copy(pjBarndFilesList1, PjProductLaunchFiles.class));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (!pjBrandFilesList.isEmpty()) {
|
|
|
- List<PjBrandFiles> pjBarndFilesList1 = pjBrandFilesList.stream()
|
|
|
- .filter(e -> e.getPid().equals(item.getBrandId()))
|
|
|
- .collect(Collectors.toList());
|
|
|
- if (!pjBarndFilesList1.isEmpty()) {
|
|
|
- item.setFilesList(BeanUtil.copy(pjBarndFilesList1, PjProductLaunchFiles.class));
|
|
|
- }
|
|
|
- } else {
|
|
|
- List<PjProductLaunchFiles> filesList = new ArrayList<>();
|
|
|
- PjProductLaunchFiles files = new PjProductLaunchFiles();
|
|
|
- files.setUrl(item.getUrl());
|
|
|
- files.setVersion("0");
|
|
|
- filesList.add(files);
|
|
|
- item.setFilesList(filesList);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (ObjectUtils.isNotNull(item.getBrandId())) {
|
|
|
- if (!brandFigureList.isEmpty()) {
|
|
|
- List<BrandFigure> brandFigureList1 = brandFigureList.stream()
|
|
|
- .filter(e -> e.getPid().equals(item.getBrandId()) && e.getFigure().equals(item.getBrandItem()))
|
|
|
- .collect(Collectors.toList());
|
|
|
- if (!brandFigureList1.isEmpty()) {
|
|
|
- item.setFilesList(BeanUtil.copy(brandFigureList1, PjProductLaunchFiles.class));
|
|
|
- } else {
|
|
|
- if (!pjBrandFilesList.isEmpty()) {
|
|
|
- List<PjBrandFiles> pjBarndFilesList1 = pjBrandFilesList.stream()
|
|
|
- .filter(e -> e.getPid().equals(item.getBrandId()))
|
|
|
- .collect(Collectors.toList());
|
|
|
- if (!pjBarndFilesList1.isEmpty()) {
|
|
|
- item.setFilesList(BeanUtil.copy(pjBarndFilesList1, PjProductLaunchFiles.class));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (!pjBrandFilesList.isEmpty()) {
|
|
|
- List<PjBrandFiles> pjBarndFilesList1 = pjBrandFilesList.stream()
|
|
|
- .filter(e -> e.getPid().equals(item.getBrandId()))
|
|
|
- .collect(Collectors.toList());
|
|
|
- if (!pjBarndFilesList1.isEmpty()) {
|
|
|
- item.setFilesList(BeanUtil.copy(pjBarndFilesList1, PjProductLaunchFiles.class));
|
|
|
- }
|
|
|
- }else {
|
|
|
- List<PjProductLaunchFiles> filesList = new ArrayList<>();
|
|
|
- PjProductLaunchFiles files = new PjProductLaunchFiles();
|
|
|
- files.setUrl(item.getUrl());
|
|
|
- files.setVersion("0");
|
|
|
- filesList.add(files);
|
|
|
- item.setFilesList(filesList);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- pages.setRecords(mallDetails);
|
|
|
- }
|
|
|
- return R.data(pages);
|
|
|
+ return shoppingMallDetailService.selectWxAppGoodsPageList(productLaunch, query);
|
|
|
}
|
|
|
|
|
|
/**
|