## 产品发布去掉产品基本信息关系;

This commit is contained in:
cabbage 2025-04-29 13:18:30 +08:00
parent 64f5612202
commit d671e5410f
8 changed files with 163 additions and 446 deletions

View File

@ -1,41 +0,0 @@
package com.hzs.scm.product;/**
* @Description:
* @Author: yuhui
* @Time: 2023/11/23 18:28
* @Classname: IBdProductBasSpecsServiceApi
* @PackageName: com.hzs.scm.product
*/
import com.hzs.common.core.domain.R;
import com.hzs.common.domain.sale.product.BdProductBas;
import com.hzs.common.domain.sale.product.BdProductBasSpecs;
import java.util.List;
/**
*@BelongsProject: hzs_cloud
*@BelongsPackage: com.hzs.scm.product
*@Author: yh
*@CreateTime: 2023-11-23 18:28
*@Description: TODO
*@Version: 1.0
*/
public interface IBdProductBasSpecsServiceApi {
/**
* 新增
* @param productBasSpecsList
* @return
*/
R<Boolean> saveAll(List<BdProductBasSpecs> productBasSpecsList);
/**
* 删除 根据pkProductBas删除
* @param pkProductBasList
* @return
*/
R<Boolean> removeByPkProductBasList(List<Integer> pkProductBasList);
}

View File

@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hzs.common.core.annotation.AccessPermissions;
import com.hzs.common.core.annotation.Log;
import com.hzs.common.core.constant.HttpStatus;
import com.hzs.common.core.constant.SystemFieldConstants;
import com.hzs.common.core.constant.msg.ProductMsgConstants;
import com.hzs.common.core.domain.R;
import com.hzs.common.core.enums.*;
@ -46,41 +45,34 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
/**
* @Description:
* @Author: yuhui
* @Time: 2022/9/1 14:14
* @Classname: BdProductController
* @PackageName: com.hzs.sale.product.controller.manage
*/
@Slf4j
@RestController
@RequestMapping("/manage/product")
public class BdProductController extends BaseController {
@Autowired
private IBdWaresDetailService waresDetailService;
private IBdWaresDetailService iBdWaresDetailService;
@Autowired
private IBdClassifyService classifyService;
private IBdClassifyService iBdClassifyService;
@Autowired
private IBdProductService productService;
private IBdProductService iBdProductService;
@Autowired
private IBdProductSpecsService productSpecsService;
private IBdProductSpecsService iBdProductSpecsService;
@Autowired
private IBdSpecsTypeService specsTypeService;
private IBdSpecsTypeService iBdSpecsTypeService;
@Autowired
private IBdSpecsService specsService;
private IBdSpecsService iBdSpecsService;
@Autowired
private IBdProductExtendService productExtendService;
private IBdProductExtendService iBdProductExtendService;
@Autowired
private ITransactionCommonService transactionCommonService;
private ITransactionCommonService iTransactionCommonService;
@Autowired
private UserTokenService userTokenService;
@DubboReference
ISystemConfigServiceApi systemConfigServiceApi;
ISystemConfigServiceApi iSystemConfigServiceApi;
@DubboReference
IProductBasServiceApi productBasServiceApi;
IProductBasServiceApi iProductBasServiceApi;
/**
* 查询商品列表
@ -106,11 +98,11 @@ public class BdProductController extends BaseController {
}
}
startPage();
productParams.setPkCountry(SecurityUtils.getPkCountry());
List<ProductVo> list = productService.selectByQueryList(productParams);
startPage();
List<ProductVo> list = iBdProductService.selectByQueryList(productParams);
for (ProductVo productVo : list) {
BdClassify classify = classifyService.getClassify(productVo.getPkClassify());
BdClassify classify = iBdClassifyService.getClassify(productVo.getPkClassify());
if (classify != null) {
productVo.setClassifyName(classify.getName());
}
@ -205,38 +197,22 @@ public class BdProductController extends BaseController {
// 新增商品信息
LoginUser loginUser = userTokenService.getLoginUser();
// if (loginUser == null){
// loginUser = new LoginUser();
// loginUser.setUserId(1l);
// loginUser.setDataCountry(1);
// }
// 排序重复校验
LambdaQueryWrapper<BdProductExtend> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(BdProductExtend::getSort, productParams.getSort());
int count = productExtendService.count(queryWrapper);
int count = iBdProductExtendService.count(queryWrapper);
if (count > 0) {
return AjaxResult.error(TransactionUtils.getContent(ProductMsgConstants.SORT_REPEAT));
}
// 校验编号重复
LambdaQueryWrapper<BdProduct> qw = new LambdaQueryWrapper<>();
qw.eq(BdProduct::getProductCode, productParams.getProductCode());
int productCount = productService.count(qw);
int productCount = iBdProductService.count(qw);
if (productCount > 0) {
return AjaxResult.error(TransactionUtils.getContent(ProductMsgConstants.PRODUCT_NUMBER_ALREADY_EXISTS));
}
if (productParams.getPkProductBas() != null) {
// 校验每个国家该产品bas只能有一款
LambdaQueryWrapper<BdProduct> qe = new LambdaQueryWrapper<>();
qe.eq(BdProduct::getPkProductBas, productParams.getPkProductBas());
qe.eq(BdProduct::getPkCountry, SecurityUtils.getPkCountry());
int ct = productService.count(qe);
if (ct > 0) {
return AjaxResult.error(TransactionUtils.getContent(ProductMsgConstants.PRODUCT_BAS_COUNTYR_FIRST));
}
}
productService.saveProduct(productParams, loginUser);
iBdProductService.saveProduct(productParams, loginUser);
return AjaxResult.success();
// return AjaxResult.success(productService.saveProductModifyRecord(productParams, loginUser,EModifyRecordType.PRODUCT_ADD.getValue()));
}
/**
@ -249,11 +225,11 @@ public class BdProductController extends BaseController {
@PostMapping("update")
public AjaxResult update(@RequestBody ProductParams productParams) {
// 查询订单编号是否重复
BdProduct product = productService.getById(productParams.getPkId());
BdProduct product = iBdProductService.getById(productParams.getPkId());
if (!product.getProductCode().equals(productParams.getProductCode())) {
LambdaQueryWrapper<BdProduct> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(BdProduct::getProductCode, productParams.getProductCode());
int count = productService.count(queryWrapper);
int count = iBdProductService.count(queryWrapper);
if (count > 0) {
return AjaxResult.error(TransactionUtils.getContent(ProductMsgConstants.PRODUCT_NUMBER_ALREADY_EXISTS));
}
@ -262,7 +238,7 @@ public class BdProductController extends BaseController {
LambdaQueryWrapper<BdProductExtend> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(BdProductExtend::getSort, productParams.getSort());
queryWrapper.notIn(BdProductExtend::getPkProduct, productParams.getPkId());
int count = productExtendService.count(queryWrapper);
int count = iBdProductExtendService.count(queryWrapper);
if (count > 0) {
return AjaxResult.error(TransactionUtils.getContent(ProductMsgConstants.SORT_REPEAT));
}
@ -271,24 +247,12 @@ public class BdProductController extends BaseController {
LambdaQueryWrapper<BdProduct> qe = new LambdaQueryWrapper<>();
qe.eq(BdProduct::getProductCode, productParams.getProductCode());
qe.notIn(BdProduct::getPkId, productParams.getPkId());
int productCount = productService.count(qe);
int productCount = iBdProductService.count(qe);
if (productCount > 0) {
return AjaxResult.error(TransactionUtils.getContent(ProductMsgConstants.PRODUCT_NUMBER_ALREADY_EXISTS));
}
if (productParams.getPkProductBas() != null) {
// 校验每个国家该产品bas只能有一款
LambdaQueryWrapper<BdProduct> qw = new LambdaQueryWrapper<>();
qw.eq(BdProduct::getPkProductBas, productParams.getPkProductBas());
qw.eq(BdProduct::getPkCountry, SecurityUtils.getPkCountry());
qw.notIn(BdProduct::getPkId, productParams.getPkId());
int ct = productService.count(qw);
if (ct > 0) {
return AjaxResult.error(TransactionUtils.getContent(ProductMsgConstants.PRODUCT_BAS_COUNTYR_FIRST));
}
}
// 修改商品信息
productService.updateProduct(productParams, loginUser);
// productService.saveProductModifyRecord(productParams, loginUser,EModifyRecordType.PRODUCT_ADD.getValue());
iBdProductService.updateProduct(productParams, loginUser);
return AjaxResult.success(productParams.getProductCode());
}
@ -303,12 +267,12 @@ public class BdProductController extends BaseController {
public AjaxResult delete(@PathVariable Integer pkId) {
LambdaQueryWrapper<BdWaresDetail> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(BdWaresDetail::getPkProduct, pkId);
int count = waresDetailService.count(queryWrapper);
int count = iBdWaresDetailService.count(queryWrapper);
if (count > 0) {
return AjaxResult.error(TransactionUtils.getContent(ProductMsgConstants.PRODUCT_OCCUPIED));
}
LoginUser loginUser = userTokenService.getLoginUser();
productService.removeProduct(pkId, loginUser);
iBdProductService.removeProduct(pkId, loginUser);
return AjaxResult.success();
}
@ -325,7 +289,7 @@ public class BdProductController extends BaseController {
BdProduct product = new BdProduct();
product.setPkId(pkId);
product.setEnableState(enable);
productService.updateById(product);
iBdProductService.updateById(product);
return AjaxResult.success();
}
@ -334,7 +298,7 @@ public class BdProductController extends BaseController {
* 查询产品规格
*/
@PostMapping("get-product-specs")
@PostMapping("/get-product-specs")
public AjaxResult getProductSpecs(@RequestBody ProductParams productParams) {
List<Integer> productIds = productParams.getProductIds();
if (productIds.size() == 0) {
@ -344,7 +308,7 @@ public class BdProductController extends BaseController {
List<ProductSpecsInfo> resultList = new ArrayList<>();
for (Integer productId : productParams.getProductIds()) {
ProductSpecsInfo productSpecsInfo = new ProductSpecsInfo();
BdProduct product = productService.getProduct(productId);
BdProduct product = iBdProductService.getProduct(productId);
if (product != null) {
productSpecsInfo.setProductId(productId);
productSpecsInfo.setProductName(product.getProductName());
@ -357,13 +321,13 @@ public class BdProductController extends BaseController {
queryWrapper.eq(BdProductSpecs::getPkProduct, productId);
//根据规格id 正序排列
queryWrapper.orderByAsc(BdProductSpecs::getPkId);
List<BdProductSpecs> list = productSpecsService.list(queryWrapper);
List<BdProductSpecs> list = iBdProductSpecsService.list(queryWrapper);
for (BdProductSpecs productSpecs : list) {
set.add(productSpecs.getPkSpecsType());
}
List<SpecsTypeParam> specsTypeParamList = new ArrayList<>();
for (Integer specsTypeId : set) {
BdSpecsType specsType = specsTypeService.getSpecsType(specsTypeId);
BdSpecsType specsType = iBdSpecsTypeService.getSpecsType(specsTypeId);
if (specsType != null) {
// 根据规格类型查询规格属性
SpecsTypeParam specsTypeParam = new SpecsTypeParam();
@ -371,7 +335,7 @@ public class BdProductController extends BaseController {
specsTypeParam.setTypeName(specsType.getTypeName());
LambdaQueryWrapper<BdSpecs> specsWrapper = new LambdaQueryWrapper<>();
specsWrapper.eq(BdSpecs::getPkSpecsType, specsTypeId);
List<BdSpecs> specsList = specsService.list(specsWrapper);
List<BdSpecs> specsList = iBdSpecsService.list(specsWrapper);
List<SpecsParam> resultSpecsList = new ArrayList<>();
for (BdSpecs bdSpecs : specsList) {
SpecsParam specsParam = new SpecsParam();
@ -383,13 +347,11 @@ public class BdProductController extends BaseController {
specsTypeParam.setSpecsList(resultSpecsList);
specsTypeParamList.add(specsTypeParam);
}
}
productSpecsInfo.setSpecsTypeData(specsTypeParamList);
}
resultList.add(productSpecsInfo);
}
return AjaxResult.success(resultList);
}
@ -397,7 +359,7 @@ public class BdProductController extends BaseController {
* 查询产品规格(带是否赠品)
*/
@PostMapping("get-product-specs-gift")
@PostMapping("/get-product-specs-gift")
public AjaxResult getProductSpecsGift(@RequestBody ProductParams productParams) {
List<ProductGiftParam> productGiftList = productParams.getProductGiftList();
if (productGiftList.size() == 0) {
@ -408,7 +370,7 @@ public class BdProductController extends BaseController {
for (ProductGiftParam productGiftParam : productParams.getProductGiftList()) {
ProductSpecsInfo productSpecsInfo = new ProductSpecsInfo();
Integer productId = productGiftParam.getPkProduct();
BdProduct product = productService.getProduct(productId);
BdProduct product = iBdProductService.getProduct(productId);
if (product != null) {
productSpecsInfo.setProductId(productId);
productSpecsInfo.setProductName(product.getProductName());
@ -423,13 +385,13 @@ public class BdProductController extends BaseController {
queryWrapper.eq(BdProductSpecs::getPkProduct, productId);
//根据规格id 正序排列
queryWrapper.orderByAsc(BdProductSpecs::getPkId);
List<BdProductSpecs> list = productSpecsService.list(queryWrapper);
List<BdProductSpecs> list = iBdProductSpecsService.list(queryWrapper);
for (BdProductSpecs productSpecs : list) {
set.add(productSpecs.getPkSpecsType());
}
List<SpecsTypeParam> specsTypeParamList = new ArrayList<>();
for (Integer specsTypeId : set) {
BdSpecsType specsType = specsTypeService.getSpecsType(specsTypeId);
BdSpecsType specsType = iBdSpecsTypeService.getSpecsType(specsTypeId);
if (specsType != null) {
// 根据规格类型查询规格属性
SpecsTypeParam specsTypeParam = new SpecsTypeParam();
@ -437,7 +399,7 @@ public class BdProductController extends BaseController {
specsTypeParam.setTypeName(specsType.getTypeName());
LambdaQueryWrapper<BdSpecs> specsWrapper = new LambdaQueryWrapper<>();
specsWrapper.eq(BdSpecs::getPkSpecsType, specsTypeId);
List<BdSpecs> specsList = specsService.list(specsWrapper);
List<BdSpecs> specsList = iBdSpecsService.list(specsWrapper);
List<SpecsParam> resultSpecsList = new ArrayList<>();
for (BdSpecs bdSpecs : specsList) {
SpecsParam specsParam = new SpecsParam();
@ -449,13 +411,11 @@ public class BdProductController extends BaseController {
specsTypeParam.setSpecsList(resultSpecsList);
specsTypeParamList.add(specsTypeParam);
}
}
productSpecsInfo.setSpecsTypeData(specsTypeParamList);
}
resultList.add(productSpecsInfo);
}
return AjaxResult.success(resultList);
}
@ -463,7 +423,7 @@ public class BdProductController extends BaseController {
* 查询产品规格
*/
@PostMapping("get-product-code-specs")
@PostMapping("/get-product-code-specs")
public AjaxResult getProductCodeSpecs(@RequestBody ProductParams productParams) {
List<String> productCodes = productParams.getProductCodes();
if (productCodes.size() == 0) {
@ -475,7 +435,7 @@ public class BdProductController extends BaseController {
ProductSpecsInfo productSpecsInfo = new ProductSpecsInfo();
LambdaQueryWrapper<BdProduct> qw = new LambdaQueryWrapper<>();
qw.eq(BdProduct::getProductCode, productCode);
BdProduct product = productService.getOne(qw);
BdProduct product = iBdProductService.getOne(qw);
if (product != null) {
productSpecsInfo.setProductId(product.getPkId());
productSpecsInfo.setProductName(product.getProductName());
@ -486,13 +446,13 @@ public class BdProductController extends BaseController {
LambdaQueryWrapper<BdProductSpecs> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(BdProductSpecs::getPkProduct, product.getPkId());
queryWrapper.orderByAsc(BdProductSpecs::getPkId);
List<BdProductSpecs> list = productSpecsService.list(queryWrapper);
List<BdProductSpecs> list = iBdProductSpecsService.list(queryWrapper);
for (BdProductSpecs productSpecs : list) {
set.add(productSpecs.getPkSpecsType());
}
List<SpecsTypeParam> specsTypeParamList = new ArrayList<>();
for (Integer specsTypeId : set) {
BdSpecsType specsType = specsTypeService.getSpecsType(specsTypeId);
BdSpecsType specsType = iBdSpecsTypeService.getSpecsType(specsTypeId);
if (specsType != null) {
// 根据规格类型查询规格属性
SpecsTypeParam specsTypeParam = new SpecsTypeParam();
@ -501,7 +461,7 @@ public class BdProductController extends BaseController {
LambdaQueryWrapper<BdSpecs> specsWrapper = new LambdaQueryWrapper<>();
specsWrapper.eq(BdSpecs::getPkSpecsType, specsTypeId);
specsWrapper.orderByAsc(BdSpecs::getPkId);
List<BdSpecs> specsList = specsService.list(specsWrapper);
List<BdSpecs> specsList = iBdSpecsService.list(specsWrapper);
List<SpecsParam> resultSpecsList = new ArrayList<>();
for (BdSpecs bdSpecs : specsList) {
SpecsParam specsParam = new SpecsParam();
@ -528,16 +488,16 @@ public class BdProductController extends BaseController {
*
* @return
*/
@GetMapping("detail")
@GetMapping("/detail")
public AjaxResult detail(Integer productId) {
ProductVo product = productService.getByProductId(productId);
ProductVo product = iBdProductService.getByProductId(productId);
if (product == null) {
return AjaxResult.error(TransactionUtils.getContent(ProductMsgConstants.PRODUCT_NOT_REQUIRED));
}
ProductParams productParams = BeanUtil.copyProperties(product, ProductParams.class);
productParams.setProductBasName(product.getProductBasName());
BdProductExtend productExtend = productExtendService.getOne(new LambdaQueryWrapper<BdProductExtend>().eq(BdProductExtend::getPkProduct, productId));
BdProductExtend productExtend = iBdProductExtendService.getOne(new LambdaQueryWrapper<BdProductExtend>().eq(BdProductExtend::getPkProduct, productId));
productParams.setIsPickUp(productExtend.getIsPickUp());
productParams.setIsPrize(productExtend.getIsPrize());
productParams.setIsBarCode(productExtend.getIsBarCode());
@ -552,12 +512,11 @@ public class BdProductController extends BaseController {
LambdaQueryWrapper<BdProductSpecs> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(BdProductSpecs::getPkProduct, productId);
List<Integer> pkSpecsType = new ArrayList<>();
List<BdProductSpecs> productSpecList = productSpecsService.list(queryWrapper);
List<BdProductSpecs> productSpecList = iBdProductSpecsService.list(queryWrapper);
for (BdProductSpecs bdProductSpecs : productSpecList) {
pkSpecsType.add(bdProductSpecs.getPkSpecsType());
}
productParams.setPkSpecsType(pkSpecsType);
productParams.setPkProductBas(product.getPkProductBas());
return AjaxResult.success(productParams);
}
@ -566,16 +525,16 @@ public class BdProductController extends BaseController {
*
* @return
*/
@GetMapping("product-bas-detail")
@GetMapping("/product-bas-detail")
public AjaxResult productBasDetail(Integer pkProductBas) {
R<ProductBasDTO> productBas = productBasServiceApi.getProductBasById(pkProductBas);
BdProduct product = productService.getOne(new LambdaQueryWrapper<BdProduct>().eq(BdProduct::getPkProductBas, pkProductBas).eq(BdProduct::getPkCountry, SecurityUtils.getPkCountry()));
R<ProductBasDTO> productBas = iProductBasServiceApi.getProductBasById(pkProductBas);
BdProduct product = iBdProductService.getOne(new LambdaQueryWrapper<BdProduct>().eq(BdProduct::getPkProductBas, pkProductBas).eq(BdProduct::getPkCountry, SecurityUtils.getPkCountry()));
if (productBas.getData() == null) {
return AjaxResult.error(TransactionUtils.getContent(ProductMsgConstants.PRODUCT_NOT_REQUIRED));
}
ProductParams productParams = BeanUtil.copyProperties(productBas.getData(), ProductParams.class);
BdProductExtend productExtend = productExtendService.getProductExtend(product.getPkId());
BdProductExtend productExtend = iBdProductExtendService.getProductExtend(product.getPkId());
productParams.setIsPickUp(productExtend.getIsPickUp());
productParams.setIsPrize(productExtend.getIsPrize());
productParams.setIsBarCode(productExtend.getIsBarCode());
@ -589,12 +548,11 @@ public class BdProductController extends BaseController {
LambdaQueryWrapper<BdProductSpecs> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(BdProductSpecs::getPkProduct, product.getPkId());
List<Integer> pkSpecsType = new ArrayList<>();
List<BdProductSpecs> productSpecList = productSpecsService.list(queryWrapper);
List<BdProductSpecs> productSpecList = iBdProductSpecsService.list(queryWrapper);
for (BdProductSpecs bdProductSpecs : productSpecList) {
pkSpecsType.add(bdProductSpecs.getPkSpecsType());
}
productParams.setPkSpecsType(pkSpecsType);
productParams.setPkProductBas(productBas.getData().getPkId());
return AjaxResult.success(productParams);
}
@ -602,8 +560,7 @@ public class BdProductController extends BaseController {
* @return
*/
@PostMapping("/export")
public void export(HttpServletResponse response,
ProductParams productParams) {
public void export(HttpServletResponse response, ProductParams productParams) {
if (productParams.getShippingType() != null) {
if (productParams.getShippingType() == 1) {
// 陆运
@ -619,18 +576,16 @@ public class BdProductController extends BaseController {
}
}
productParams.setPkCountry(SecurityUtils.getPkCountry());
Map<String, String> transactionMap = transactionCommonService.exportEnumTransaction(ETransportType.values(), EYesNo.values(), EShippingChannel.values(), EUnit.values());
List<ProductVo> list = productService.selectByQueryList(productParams);
Map<String, String> transactionMap = iTransactionCommonService.exportEnumTransaction(ETransportType.values(), EYesNo.values(), EShippingChannel.values(), EUnit.values());
List<ProductVo> list = iBdProductService.selectByQueryList(productParams);
for (ProductVo productVo : list) {
BdClassify classify = classifyService.getClassify(productVo.getPkClassify());
BdClassify classify = iBdClassifyService.getClassify(productVo.getPkClassify());
if (classify != null) {
productVo.setClassifyName(classify.getName());
}
// 发货类型翻译
productVo.setShippingChannelVal(transactionMap.get(EShippingChannel.getEnumByValue(productVo.getShippingChannel()).getKey()));
//单位翻译翻译
// productVo.setUnitVal(transactionMap.get(EUnit.getEnumByValue(productVo.getUnit()).getKey()));
// 产品属性翻译
if (productVo.getProductAttr() != null) {
productVo.setProductAttrVal(EProductAttrType.getEnumByValue(productVo.getProductAttr()).getLabel());
@ -663,8 +618,6 @@ public class BdProductController extends BaseController {
str.append(ETransportType.LAND.getLabel());
}
productVo.setTypeShippingMerge(str.toString());
// transactionServiceApi.readTransactionByCache(ETransactionKey.PRODUCT,product.getPkTransactionKey());
}
ExcelUtil<ProductVo> util = new ExcelUtil<>(ProductVo.class);
util.exportExcel(response, list, "产品信息导出");
@ -681,7 +634,7 @@ public class BdProductController extends BaseController {
public AjaxResult move(Integer productId, Integer productMoveType) {
// 新增商品信息
LoginUser loginUser = userTokenService.getLoginUser();
productService.productMove(productId, productMoveType, loginUser);
iBdProductService.productMove(productId, productMoveType, loginUser);
return AjaxResult.success();
}
@ -693,9 +646,8 @@ public class BdProductController extends BaseController {
*/
@GetMapping("floating-roof")
public AjaxResult floatingRoof(Integer productId) {
LoginUser loginUser = userTokenService.getLoginUser();
productService.floatingRoof(productId, loginUser);
iBdProductService.floatingRoof(productId, loginUser);
return AjaxResult.success();
}
@ -710,7 +662,7 @@ public class BdProductController extends BaseController {
if (null == pkCountry) {
pkCountry = SecurityUtils.getPkCountry();
}
return AjaxResult.success(productService.queryProductExistSpecs(pkCountry));
return AjaxResult.success(iBdProductService.queryProductExistSpecs(pkCountry));
}
/**
@ -719,18 +671,16 @@ public class BdProductController extends BaseController {
* @param pkProduct
* @return
*/
@GetMapping("get-product-specs")
@GetMapping("/get-product-specs")
public AjaxResult getProductSpecs(Integer pkProduct) {
List<ProductSpecsVo> productSpecsList = productSpecsService.selectByList(pkProduct);
List<ProductSpecsVo> productSpecsList = iBdProductSpecsService.selectByList(pkProduct);
for (ProductSpecsVo productSpecsVo : productSpecsList) {
LambdaQueryWrapper<BdSpecs> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(BdSpecs::getPkSpecsType, productSpecsVo.getPkSpecsType());
queryWrapper.orderByAsc(BdSpecs::getPkId);
List<BdSpecs> specsList = specsService.list(queryWrapper);
List<BdSpecs> specsList = iBdSpecsService.list(queryWrapper);
productSpecsVo.setSpecsList(specsList);
}
return AjaxResult.success(productSpecsList);
}
@ -740,12 +690,12 @@ public class BdProductController extends BaseController {
* @param productCode
* @return
*/
@GetMapping("get-product-code")
@GetMapping("/get-product-code")
public AjaxResult getProductCode(String productCode) {
LambdaQueryWrapper<BdProduct> queryWrapper = new LambdaQueryWrapper<>();
if (StringUtils.isNotEmpty(productCode)) {
queryWrapper.eq(BdProduct::getProductCode, productCode);
return AjaxResult.success(productService.getOne(queryWrapper));
return AjaxResult.success(iBdProductService.getOne(queryWrapper));
} else {
return AjaxResult.success();
}
@ -756,10 +706,10 @@ public class BdProductController extends BaseController {
*
* @return
*/
@GetMapping("create-product-code")
@GetMapping("/create-product-code")
public AjaxResult createProductCode() {
// 查询最末商品编号 生成商品编号
String productCode = CreateNormsCodeUtils.createProductCode(productService.getLastProductCode());
String productCode = CreateNormsCodeUtils.createProductCode(iBdProductService.getLastProductCode());
return AjaxResult.success(productCode);
}
@ -768,9 +718,9 @@ public class BdProductController extends BaseController {
*
* @return
*/
@GetMapping("get-max-sort")
@GetMapping("/get-max-sort")
public AjaxResult getMaxSort() {
Integer sort = productExtendService.getMaxProductSort();
Integer sort = iBdProductExtendService.getMaxProductSort();
if (sort == null) {
sort = 0;
}
@ -780,11 +730,11 @@ public class BdProductController extends BaseController {
/**
* 供应商产品统计
*/
@GetMapping("supplier-product-census")
@GetMapping("/supplier-product-census")
public TableDataInfo supplierProductCensus(SupplierProductCensusParam supplierProductCensusParam) {
startPage();
// 下面代码需要使用 坐等随工提交此方法 取消注释
R<BdCubasdocDTO> bdCubasdocDate = systemConfigServiceApi.queryBdCubasdocByUser(SecurityUtils.getUserId());
R<BdCubasdocDTO> bdCubasdocDate = iSystemConfigServiceApi.queryBdCubasdocByUser(SecurityUtils.getUserId());
Integer pkSupplier = null;
if (bdCubasdocDate.getCode() == HttpStatus.SUCCESS) {
BdCubasdocDTO bdCubasdoc = bdCubasdocDate.getData();
@ -793,9 +743,9 @@ public class BdProductController extends BaseController {
}
}
supplierProductCensusParam.setPkSupplier(pkSupplier);
List<SupplierProductCensusVo> supplierProductCensusVoList = productService.getSupplierProductCensus(supplierProductCensusParam);
List<SupplierProductCensusVo> supplierProductCensusVoList = iBdProductService.getSupplierProductCensus(supplierProductCensusParam);
for (SupplierProductCensusVo supplierProductCensusVo : supplierProductCensusVoList) {
BdClassify classify = classifyService.getClassify(supplierProductCensusVo.getPkClassify());
BdClassify classify = iBdClassifyService.getClassify(supplierProductCensusVo.getPkClassify());
if (classify != null) {
supplierProductCensusVo.setClassifyName(classify.getName());
}
@ -810,10 +760,10 @@ public class BdProductController extends BaseController {
/**
* @param supplierProductCensusParam
*/
@PostMapping("supplier-product-census-export")
@PostMapping("/supplier-product-census-export")
public void supplierProductCensusExport(HttpServletResponse response, SupplierProductCensusParam supplierProductCensusParam) {
// 下面代码需要使用 坐等随工提交此方法 取消注释
R<BdCubasdocDTO> bdCubasdocDate = systemConfigServiceApi.queryBdCubasdocByUser(SecurityUtils.getUserId());
R<BdCubasdocDTO> bdCubasdocDate = iSystemConfigServiceApi.queryBdCubasdocByUser(SecurityUtils.getUserId());
Integer pkSupplier = null;
if (bdCubasdocDate.getCode() == HttpStatus.SUCCESS) {
BdCubasdocDTO bdCubasdoc = bdCubasdocDate.getData();
@ -822,9 +772,9 @@ public class BdProductController extends BaseController {
}
}
supplierProductCensusParam.setPkSupplier(pkSupplier);
List<SupplierProductCensusVo> supplierProductCensusVoList = productService.getSupplierProductCensus(supplierProductCensusParam);
List<SupplierProductCensusVo> supplierProductCensusVoList = iBdProductService.getSupplierProductCensus(supplierProductCensusParam);
for (SupplierProductCensusVo supplierProductCensusVo : supplierProductCensusVoList) {
BdClassify classify = classifyService.getClassify(supplierProductCensusVo.getPkClassify());
BdClassify classify = iBdClassifyService.getClassify(supplierProductCensusVo.getPkClassify());
if (classify != null) {
supplierProductCensusVo.setClassifyName(classify.getName());
}
@ -835,4 +785,5 @@ public class BdProductController extends BaseController {
ExcelUtil<SupplierProductCensusVo> util = new ExcelUtil<>(SupplierProductCensusVo.class);
util.exportExcel(response, supplierProductCensusVoList, "供应商商品统计导出");
}
}

View File

@ -1,7 +1,5 @@
package com.hzs.sale.product.controller.manage.params;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import java.io.Serializable;
@ -9,13 +7,6 @@ import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
* @Description:
* @Author: yuhui
* @Time: 2022/9/1 15:48
* @Classname: Product
* @PackageName: com.hzs.sale.product.controller.manage.params
*/
@Data
public class ProductParams implements Serializable {

View File

@ -13,13 +13,6 @@ import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Set;
/**
* @Description: 邮费相关mapper
* @Author: yuhui
* @Time: 2022/8/29 10:59
* @Classname: BdProductMapper
* @PackageName: com.hzs.sale.product.mapper
*/
public interface BdProductMapper extends BaseMapper<BdProduct> {
/**
@ -39,18 +32,12 @@ public interface BdProductMapper extends BaseMapper<BdProduct> {
/*
* @description: 根据产品id查询产品
* @author: sui q
* @date: 2023/5/29 16:07
* @param: null null
**/
List<BdProductExt> queryProductExtById(@Param("productIdSet") Set<Integer> productIdSet, @Param("pkCountry") Integer pkCountry,
@Param("repurchaseType") Integer repurchaseType);
/*
* @description: 根据规格主键查询产品
* @author: sui q
* @date: 2023/11/27 15:52
* @param: null null
**/
List<BdProductExt> queryProductExtBySpecsId(@Param("productSpecsList") List<BdProductSpecs> productSpecsList, @Param("pkCountry") Integer pkCountry);

View File

@ -16,11 +16,7 @@ import java.util.Map;
import java.util.Set;
/**
* @Description: 产品相关服务
* @Author: yuhui
* @Time: 2022/8/29 10:59
* @Classname: IBdProductService
* @PackageName: com.hzs.sale.product.service
* 产品相关服务
*/
public interface IBdProductService extends IService<BdProduct> {
@ -28,25 +24,16 @@ public interface IBdProductService extends IService<BdProduct> {
* 根据产品主键获得产品
*
* @param pkProduct 主键
* @return: ProductParams
* @Author: sui q
* @Date: 2022/9/20 20:29
*/
BdProduct getProduct(Integer pkProduct);
/*
* @description: 根据产品id查询产品
* @author: sui q
* @date: 2023/5/29 16:07
* @param: null null
**/
List<BdProductExt> queryProductById(Set<Integer> productIdSet, Integer pkCountry, Integer repurchaseType);
/*
* @description: 根据规格主键查询产品
* @author: sui q
* @date: 2023/11/27 15:52
* @param: null null
**/
List<BdProductExt> queryProductExtById(List<BdProductSpecs> productSpecsList, Integer pkCountry);

View File

@ -2,12 +2,12 @@ package com.hzs.sale.product.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hzs.common.core.constant.CacheConstants;
import com.hzs.common.core.constant.RabbitMqConstants;
import com.hzs.common.core.constant.SystemFieldConstants;
import com.hzs.common.core.domain.R;
import com.hzs.common.core.enums.*;
import com.hzs.common.core.service.RedisService;
@ -28,8 +28,6 @@ import com.hzs.sale.product.vo.SupplierProductCensusVo;
import com.hzs.sale.product.vo.WaresDetailVo;
import com.hzs.sale.wares.service.IBdWaresDetailService;
import com.hzs.sale.wares.service.IBdWaresExtendService;
import com.hzs.scm.product.IBdProductBasSpecsServiceApi;
import com.hzs.system.base.ITransactionServiceApi;
import com.hzs.system.sys.ICubasdocApi;
import com.hzs.system.sys.dto.BusinessLogDTO;
import com.hzs.system.sys.dto.CubasdocDTO;
@ -45,50 +43,31 @@ import java.util.stream.Collectors;
/**
* 产品 服务实现类
*
* @author hzs
* @since 2022-09-01
*/
@Service
public class BdProductServiceImpl extends ServiceImpl<BdProductMapper, BdProduct> implements IBdProductService {
@Autowired
private IBdWaresExtendService waresExtendService;
private IBdWaresExtendService iBdWaresExtendService;
@Autowired
private IBdClassifyService classifyService;
private IBdClassifyService iBdClassifyService;
@Autowired
private IBdProductExtendService productExtendService;
private IBdProductExtendService iBdProductExtendService;
@Autowired
private IBdProductSpecsService iBdProductSpecsService;
@Autowired
private IBdSpecsTypeService iBdSpecsTypeService;
@Autowired
private IBdWaresDetailService iBdWaresDetailService;
@DubboReference
ICubasdocApi iCubasdocApi;
@Autowired
private RedisService redisService;
@Autowired
private RabbitTemplate rabbitTemplate;
@Autowired
private IBdProductSpecsService productSpecsService;
@Autowired
private IBdSpecsTypeService specsTypeService;
@Autowired
private IBdWaresDetailService waresDetailService;
@DubboReference
ICubasdocApi cubasdocApi;
@DubboReference
ITransactionServiceApi transactionServiceApi;
@DubboReference
IBdProductBasSpecsServiceApi productBasSpecsServiceApi;
private RedisService redisService;
@Autowired
public void setRedisService(RedisService redisService) {
this.redisService = redisService;
}
/**
* 根据产品主键获得产品
*
* @param pkProduct 主键
* @return: ProductParams
* @Author: sui q
* @Date: 2022/9/20 20:29
*/
@Override
public BdProduct getProduct(Integer pkProduct) {
return baseMapper.selectById(pkProduct);
@ -104,20 +83,13 @@ public class BdProductServiceImpl extends ServiceImpl<BdProductMapper, BdProduct
return baseMapper.queryProductExtBySpecsId(productSpecsList, pkCountry);
}
/**
* 新增商品信息
*
* @param productParams
*/
@Override
@Transactional(rollbackFor = Exception.class)
public String saveProduct(ProductParams productParams, LoginUser loginUser) {
String productCode = productParams.getProductCode();
BdProduct bdProduct = BeanUtil.copyProperties(productParams, BdProduct.class);
R<Integer> transaction = transactionServiceApi.createTransaction(loginUser.getDataCountry(), ETransactionKey.PRODUCT, productParams.getProductName(), EYesNo.NO, EYesNo.NO);
bdProduct.setProductCode(productCode);
bdProduct.setPkTransaction(transaction.getData());
bdProduct.setPkCreator(loginUser.getUserId());
bdProduct.setCreationTime(new Date());
bdProduct.setPkCreator(loginUser.getUserId());
@ -130,11 +102,8 @@ public class BdProductServiceImpl extends ServiceImpl<BdProductMapper, BdProduct
if (productParams.getIsPutOn().equals(EYesNo.NO.getIntValue())) {
bdProduct.setRemovalTime(DateUtils.currentDateTime());
}
// 创建产品bas
Integer pkProductBas = productParams.getPkProductBas();
bdProduct.setPkProductBas(pkProductBas);
if (productParams.getPkCubasdoc() != null) {
R<CubasdocDTO> cubasdocDTO = cubasdocApi.getCubasdoc(productParams.getPkCubasdoc());
R<CubasdocDTO> cubasdocDTO = iCubasdocApi.getCubasdoc(productParams.getPkCubasdoc());
CubasdocDTO cubasdoc = cubasdocDTO.getData();
if (cubasdoc != null) {
bdProduct.setPkCubasdoc(productParams.getPkCubasdoc());
@ -150,7 +119,7 @@ public class BdProductServiceImpl extends ServiceImpl<BdProductMapper, BdProduct
productExtend.setPkCountry(loginUser.getDataCountry());
productExtend.setDelFlag(EDelFlag.UN_DELETE.getValue());
productExtend.setIsPutOn(productParams.getIsPutOn());
productExtendService.save(productExtend);
iBdProductExtendService.save(productExtend);
// 生成规格明细
if (productParams.getPkSpecsType() != null) {
for (Integer id : productParams.getPkSpecsType()) {
@ -160,7 +129,7 @@ public class BdProductServiceImpl extends ServiceImpl<BdProductMapper, BdProduct
productSpecs.setPkCountry(loginUser.getDataCountry());
productSpecs.setPkCreator(loginUser.getUserId());
productSpecs.setCreationTime(new Date());
productSpecsService.save(productSpecs);
iBdProductSpecsService.save(productSpecs);
}
}
removeProductCache(bdProduct.getPkId());
@ -180,7 +149,7 @@ public class BdProductServiceImpl extends ServiceImpl<BdProductMapper, BdProduct
str.append("产品编号:").append(productParams.getProductCode());
str.append("产品名称:").append(productParams.getProductName());
if (productParams.getPkClassify() != null) {
BdClassify classify = classifyService.getClassify(productParams.getPkClassify());
BdClassify classify = iBdClassifyService.getClassify(productParams.getPkClassify());
str.append("所属分类名称:").append(classify.getName());
str.append("所属分类主键:").append(productParams.getPkClassify());
}
@ -230,7 +199,7 @@ public class BdProductServiceImpl extends ServiceImpl<BdProductMapper, BdProduct
}
// 产品规格类型
if (productParams.getPkSpecsType() != null && productParams.getPkSpecsType().size() > 0) {
List<BdSpecsType> specsTypeList = specsTypeService.list(new QueryWrapper<BdSpecsType>().in("PK_ID", productParams.getPkSpecsType()));
List<BdSpecsType> specsTypeList = iBdSpecsTypeService.list(new QueryWrapper<BdSpecsType>().in("PK_ID", productParams.getPkSpecsType()));
List<String> list = specsTypeList.stream().map(BdSpecsType::getTypeName).collect(Collectors.toList());
str.append("规格明细:").append(StringUtils.join(list, ","));
}
@ -252,16 +221,6 @@ public class BdProductServiceImpl extends ServiceImpl<BdProductMapper, BdProduct
}
}
/**
* 删除产品规格明细 bas
*
* @param pkProductBasList
* @return
*/
private void removeProductBasSpecs(List<Integer> pkProductBasList) {
productBasSpecsServiceApi.removeByPkProductBasList(pkProductBasList);
}
/**
* 删除产品相关缓存
*
@ -272,27 +231,13 @@ public class BdProductServiceImpl extends ServiceImpl<BdProductMapper, BdProduct
redisService.deleteObject(CacheConstants.BD_PRODUCT_EXTEND + productId);
}
/**
* 修改商品信息
*
* @param productParams
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void updateProduct(ProductParams productParams, LoginUser loginUser) {
BdProduct bdProduct = BeanUtil.copyProperties(productParams, BdProduct.class);
R<Integer> transaction = transactionServiceApi.createTransaction(loginUser.getDataCountry(), ETransactionKey.PRODUCT, productParams.getProductName(), EYesNo.NO, EYesNo.NO);
bdProduct.setPkId(productParams.getPkId());
bdProduct.setPkTransaction(transaction.getData());
bdProduct.setPkModified(loginUser.getUserId());
bdProduct.setModifiedTime(new Date());
// 产品bas
BdProductBas productBas = BeanUtil.copyProperties(bdProduct, BdProductBas.class);
if (productParams.getPkProductBas() == null) {
bdProduct.setPkProductBas(null);
} else {
bdProduct.setPkProductBas(productParams.getPkProductBas());
}
if (productParams.getIsPutOn().equals(EYesNo.YES.getIntValue())) {
bdProduct.setListingTime(DateUtils.currentDateTime());
}
@ -303,16 +248,16 @@ public class BdProductServiceImpl extends ServiceImpl<BdProductMapper, BdProduct
// 生成拓展表
BdProductExtend productExtend = BeanUtil.copyProperties(productParams, BdProductExtend.class);
productExtend.setPkProduct(bdProduct.getPkId());
QueryWrapper<BdProductExtend> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("PK_PRODUCT", productParams.getPkId());
productExtendService.update(productExtend, queryWrapper);
LambdaQueryWrapper<BdProductExtend> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(BdProductExtend::getPkProduct, productParams.getPkId());
iBdProductExtendService.update(productExtend, queryWrapper);
// 删除缓存
removeProductCache(productParams.getPkId());
// 生成规格明细
if (productParams.getPkSpecsType() != null) {
QueryWrapper<BdProductSpecs> removeWrapper = new QueryWrapper<>();
removeWrapper.eq("PK_PRODUCT", bdProduct.getPkId());
productSpecsService.remove(removeWrapper);
LambdaQueryWrapper<BdProductSpecs> removeWrapper = new LambdaQueryWrapper<>();
removeWrapper.eq(BdProductSpecs::getPkProduct, bdProduct.getPkId());
iBdProductSpecsService.remove(removeWrapper);
for (Integer id : productParams.getPkSpecsType()) {
BdProductSpecs productSpecs = new BdProductSpecs();
productSpecs.setPkProduct(bdProduct.getPkId());
@ -320,13 +265,7 @@ public class BdProductServiceImpl extends ServiceImpl<BdProductMapper, BdProduct
productSpecs.setPkCountry(loginUser.getDataCountry());
productSpecs.setPkCreator(loginUser.getUserId());
productSpecs.setCreationTime(new Date());
productSpecsService.save(productSpecs);
}
// 产品规格 specs
if (productBas.getPkId() != null) {
this.removeProductBasSpecs(Collections.singletonList(productBas.getPkId()));
iBdProductSpecsService.save(productSpecs);
}
}
productParams.setProductCode(productParams.getProductCode());
@ -338,27 +277,27 @@ public class BdProductServiceImpl extends ServiceImpl<BdProductMapper, BdProduct
@Transactional(rollbackFor = Exception.class)
public void removeProduct(Integer pkId, LoginUser loginUser) {
BdProduct product = this.getProduct(pkId);
UpdateWrapper<BdProduct> productWrapper = new UpdateWrapper<>();
productWrapper.eq("PK_ID", pkId);
productWrapper.set("PK_MODIFIED", SecurityUtils.getUserId());
productWrapper.set("MODIFIED_TIME", new Date());
productWrapper.set("DEL_FLAG", EDelFlag.DELETE.getValue());
LambdaUpdateWrapper<BdProduct> productWrapper = new LambdaUpdateWrapper<>();
productWrapper.eq(BdProduct::getPkId, pkId);
productWrapper.set(BdProduct::getPkModified, SecurityUtils.getUserId());
productWrapper.set(BdProduct::getModifiedTime, new Date());
productWrapper.set(BdProduct::getDelFlag, EDelFlag.DELETE.getValue());
this.update(productWrapper);
// 更新商品拓展表
UpdateWrapper<BdProductExtend> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("PK_PRODUCT", pkId);
updateWrapper.set("PK_MODIFIED", SecurityUtils.getUserId());
updateWrapper.set("MODIFIED_TIME", new Date());
updateWrapper.set("DEL_FLAG", EDelFlag.DELETE.getValue());
productExtendService.update(updateWrapper);
LambdaUpdateWrapper<BdProductExtend> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(BdProductExtend::getPkProduct, pkId);
updateWrapper.set(BdProductExtend::getPkModified, SecurityUtils.getUserId());
updateWrapper.set(BdProductExtend::getModifiedTime, new Date());
updateWrapper.set(BdProductExtend::getDelFlag, EDelFlag.DELETE.getValue());
iBdProductExtendService.update(updateWrapper);
// 逻辑删除规格明细表
BdProductSpecs bdProductSpecs = new BdProductSpecs();
bdProductSpecs.setDelFlag(EDelFlag.DELETE.getValue());
bdProductSpecs.setModifiedTime(new Date());
bdProductSpecs.setPkModified(SecurityUtils.getUserId());
QueryWrapper<BdProductSpecs> wrapper = new QueryWrapper<BdProductSpecs>();
wrapper.eq("PK_PRODUCT", pkId);
productSpecsService.update(bdProductSpecs, wrapper);
LambdaQueryWrapper<BdProductSpecs> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(BdProductSpecs::getPkProduct, pkId);
iBdProductSpecsService.update(bdProductSpecs, wrapper);
// 创建删除产品日志
if (product != null) {
createRemoveProductLog(product, loginUser, EApprovalBusiness.PRODUCT_REMOVE.getValue());
@ -387,14 +326,8 @@ public class BdProductServiceImpl extends ServiceImpl<BdProductMapper, BdProduct
rabbitTemplate.convertAndSend(RabbitMqConstants.BUSINESS_LOG_EXCHANGE, RabbitMqConstants.BUSINESS_LOG_KEY, log);
}
/**
* 查询最末商品编号
*
* @return
*/
@Override
public String getLastProductCode() {
return baseMapper.getLastProductCode();
}
@ -403,11 +336,6 @@ public class BdProductServiceImpl extends ServiceImpl<BdProductMapper, BdProduct
return baseMapper.selectByQueryList(productParams);
}
/**
* 产品移动上移/下移
*
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void productMove(Integer productId, Integer productMoveType, LoginUser loginUser) {
@ -415,25 +343,25 @@ public class BdProductServiceImpl extends ServiceImpl<BdProductMapper, BdProduct
// 产品上移
if (productMoveType == EProductMoveType.MOVEUP.getIntValue()) {
// 产品上移 根据当前商品查找当前商品排序之前一个序号 如是15 则查找 16 存不存在 如果存在 16 之前的全部+1
Integer sort = productExtendService.selectByMoveUpSort(productId);
Integer sort = iBdProductExtendService.selectByMoveUpSort(productId);
if (sort != null) {
Integer maxSort = sort + 1;
// 查询该排序号码是否重复
QueryWrapper<BdProductExtend> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("SORT", maxSort);
int count = productExtendService.count(queryWrapper);
LambdaQueryWrapper<BdProductExtend> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(BdProductExtend::getSort, maxSort);
int count = iBdProductExtendService.count(queryWrapper);
if (count > 0) {
// 表示该号码已存在 将该号码之前的全都上移一位 并且将产品修改为该号码
productExtendService.updateMoveUpBySort(maxSort);
UpdateWrapper<BdProductExtend> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("PK_PRODUCT", productId);
updateWrapper.set("SORT", maxSort);
productExtendService.update(updateWrapper);
iBdProductExtendService.updateMoveUpBySort(maxSort);
LambdaUpdateWrapper<BdProductExtend> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(BdProductExtend::getPkProduct, productId);
updateWrapper.set(BdProductExtend::getSort, maxSort);
iBdProductExtendService.update(updateWrapper);
} else {
UpdateWrapper<BdProductExtend> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("PK_PRODUCT", productId);
updateWrapper.set("SORT", maxSort);
productExtendService.update(updateWrapper);
LambdaUpdateWrapper<BdProductExtend> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(BdProductExtend::getPkProduct, productId);
updateWrapper.set(BdProductExtend::getSort, maxSort);
iBdProductExtendService.update(updateWrapper);
}
}
if (bdProduct != null) {
@ -442,25 +370,25 @@ public class BdProductServiceImpl extends ServiceImpl<BdProductMapper, BdProduct
} else if (productMoveType == EProductMoveType.MOVEDOWN.getIntValue()) {
// 产品下移
// 产品下移 根据当前商品查找当前商品排序之后一个序号 如是15 则查找 14 存不存在 如果存在 14 之前的全部-1
Integer sort = productExtendService.selectByMoveDownSort(productId);
Integer sort = iBdProductExtendService.selectByMoveDownSort(productId);
if (sort != null) {
Integer minSort = sort - 1;
// 查询该排序号码是否重复
QueryWrapper<BdProductExtend> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("SORT", minSort);
int count = productExtendService.count(queryWrapper);
LambdaQueryWrapper<BdProductExtend> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(BdProductExtend::getSort, minSort);
int count = iBdProductExtendService.count(queryWrapper);
if (count > 0) {
// 表示该号码已存在 将该号码之下的全都下移一位 并且将产品修改为该号码
productExtendService.updateMoveDownBySort(minSort);
UpdateWrapper<BdProductExtend> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("PK_PRODUCT", productId);
updateWrapper.set("SORT", minSort);
productExtendService.update(updateWrapper);
iBdProductExtendService.updateMoveDownBySort(minSort);
LambdaUpdateWrapper<BdProductExtend> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(BdProductExtend::getPkProduct, productId);
updateWrapper.set(BdProductExtend::getSort, minSort);
iBdProductExtendService.update(updateWrapper);
} else {
UpdateWrapper<BdProductExtend> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("PK_PRODUCT", productId);
updateWrapper.set("SORT", minSort);
productExtendService.update(updateWrapper);
LambdaUpdateWrapper<BdProductExtend> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(BdProductExtend::getPkProduct, productId);
updateWrapper.set(BdProductExtend::getSort, minSort);
iBdProductExtendService.update(updateWrapper);
}
}
if (bdProduct != null) {
@ -468,7 +396,6 @@ public class BdProductServiceImpl extends ServiceImpl<BdProductMapper, BdProduct
createProductMoveLog(bdProduct, productMoveType, loginUser, EApprovalBusiness.PRODUCT_MOVEDOWN.getValue());
}
}
}
/**
@ -498,22 +425,14 @@ public class BdProductServiceImpl extends ServiceImpl<BdProductMapper, BdProduct
rabbitTemplate.convertAndSend(RabbitMqConstants.BUSINESS_LOG_EXCHANGE, RabbitMqConstants.BUSINESS_LOG_KEY, log);
}
/**
* 置顶
*
* @param productId
*/
@Override
public void floatingRoof(Integer productId, LoginUser loginUser) {
BdProduct product = this.getProduct(productId);
/**
* 查询当前排序最大值
*/
Integer sort = productExtendService.getMaxProductSort();
UpdateWrapper<BdProductExtend> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("PK_PRODUCT", productId);
updateWrapper.set("SORT", sort + 1);
productExtendService.update(updateWrapper);
Integer sort = iBdProductExtendService.getMaxProductSort();
LambdaUpdateWrapper<BdProductExtend> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(BdProductExtend::getPkProduct, productId);
updateWrapper.set(BdProductExtend::getSort, sort + 1);
iBdProductExtendService.update(updateWrapper);
if (product != null) {
createFloatingRoofLog(product, loginUser, EApprovalBusiness.PRODUCT_TOP.getValue());
}
@ -543,10 +462,10 @@ public class BdProductServiceImpl extends ServiceImpl<BdProductMapper, BdProduct
public Map<Integer, BdProduct> queryProductMap(Collection<Integer> pkProductList, Integer pkCountry) {
Map<Integer, BdProduct> resultMap = new HashMap<>();
QueryWrapper<BdProduct> queryWrapper = new QueryWrapper<>();
queryWrapper.in(SystemFieldConstants.PK_ID, pkProductList);
LambdaQueryWrapper<BdProduct> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(BdProduct::getPkId, pkProductList);
if (null != pkCountry) {
queryWrapper.eq(SystemFieldConstants.PK_COUNTRY, pkCountry);
queryWrapper.eq(BdProduct::getPkCountry, pkCountry);
}
List<BdProduct> productList = this.list(queryWrapper);
if (CollectionUtil.isNotEmpty(productList)) {
@ -563,19 +482,13 @@ public class BdProductServiceImpl extends ServiceImpl<BdProductMapper, BdProduct
return baseMapper.queryProductExistSpecs(pkCountry);
}
/**
* 根据产品主键修改所关联商品是下架/预售
*
* @param productList
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean updateWaresPreSaleStatus(List<BdProduct> productList) {
List<Integer> list = productList.stream().map(BdProduct::getPkId).collect(Collectors.toList());
try {
List<WaresDetailVo> waresDetailVoList = waresDetailService.listByPkProduct(list);
List<WaresDetailVo> waresDetailVoList = iBdWaresDetailService.listByPkProduct(list);
// 缺货状态
List<Integer> waresOutStockList = new ArrayList<>();
//预售状态
@ -588,21 +501,20 @@ public class BdProductServiceImpl extends ServiceImpl<BdProductMapper, BdProduct
// 是预售 修改为预售状态
warespreSaleList.add(waresDetailVo.getPkWares());
}
}
// 更新缺货状态
if (waresOutStockList.size() > 0) {
UpdateWrapper<BdWaresExtend> updateWrapper = new UpdateWrapper<>();
updateWrapper.in("PK_WARES", waresOutStockList);
updateWrapper.set("PRE_SALE_STATUS", EPresaleStatus.OUT_STOCK.getValue());
waresExtendService.update(updateWrapper);
LambdaUpdateWrapper<BdWaresExtend> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.in(BdWaresExtend::getPkWares, waresOutStockList);
updateWrapper.set(BdWaresExtend::getPreSaleStatus, EPresaleStatus.OUT_STOCK.getValue());
iBdWaresExtendService.update(updateWrapper);
}
// 更新预售状态
if (warespreSaleList.size() > 0) {
UpdateWrapper<BdWaresExtend> updateWrapper = new UpdateWrapper<>();
updateWrapper.in("PK_WARES", warespreSaleList);
updateWrapper.set("PRE_SALE_STATUS", EPresaleStatus.PRESALE.getValue());
waresExtendService.update(updateWrapper);
LambdaUpdateWrapper<BdWaresExtend> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.in(BdWaresExtend::getPkWares, warespreSaleList);
updateWrapper.set(BdWaresExtend::getPreSaleStatus, EPresaleStatus.PRESALE.getValue());
iBdWaresExtendService.update(updateWrapper);
}
} catch (Exception e) {
return false;
@ -611,23 +523,11 @@ public class BdProductServiceImpl extends ServiceImpl<BdProductMapper, BdProduct
return true;
}
/**
* 供应商产品统计
*
* @param supplierProductCensusParam
* @return
*/
@Override
public List<SupplierProductCensusVo> getSupplierProductCensus(SupplierProductCensusParam supplierProductCensusParam) {
return baseMapper.getSupplierProductCensus(supplierProductCensusParam);
}
/**
* 查询产品信息
*
* @param productId
* @return
*/
@Override
public ProductVo getByProductId(Integer productId) {
return baseMapper.getByProductId(productId);

View File

@ -76,7 +76,6 @@
<result column="REMOVAL_TIME" property="removalTime"/>
</resultMap>
<select id="getLastProductCode" resultType="string">
select product_code
from (select t.product_code from BD_PRODUCT t where t.del_flag = 0 order by product_code desc)
@ -192,6 +191,7 @@
and pe.IS_PUT_ON = 0
order by bp.product_name
</select>
<select id="queryProductExtBySpecsId" resultMap="BdProduct">
<foreach collection="productSpecsList" item="item" separator=" union ">
select bp.pk_id,bp.product_code,bp.product_name,bp.pk_country,bp.cover,bc.pk_id
@ -209,7 +209,6 @@
</select>
<select id="getSupplierProductCensus" resultType="com.hzs.sale.product.vo.SupplierProductCensusVo">
select
bc.CUST_NAME custName ,bp.COVER cover,bp.PRODUCT_NAME productName,bp.PK_CLASSIFY pkClassify,bp.PRODUCT_CODE
productCode,
@ -220,7 +219,6 @@
left join BD_SPECS_TYPE st on st.PK_ID = ps.PK_SPECS_TYPE
where ps.PK_PRODUCT = bp.PK_ID and ps.DEL_FLAG = '0') productSpecType,
bp.PK_ID pkProduct,bp.RETAIL_PRICE retailPrice, bu.NAME unitVal,bp.CREATION_TIME creationTime
from bd_product bp
left join BD_UNIT bu on bu.PK_ID = bp.UNIT
left join BD_PRODUCT_EXTEND pe on pe.PK_PRODUCT = bp.pk_id
@ -236,17 +234,14 @@
<if test="productName != null and productName !='' ">
AND bp.PRODUCT_NAME like #{productName}||'%'
</if>
</select>
<select id="getByProductId" resultMap="ProductResultMap">
select bp.*, pb.PRODUCT_NAME productBasName
from bd_product bp
left join bd_product_bas pb on pb.pk_id = bp.PK_PRODUCT_BAS
where bp.del_flag = 0
and bp.pk_id = #{productId}
</select>
</mapper>

View File

@ -1,53 +0,0 @@
package com.hzs.ground.product.provider;/**
* @Description:
* @Author: yuhui
* @Time: 2023/11/23 18:27
* @Classname: IBdProductBasSpecsServiceProvider
* @PackageName: com.hzs.scm.product.provider
*/
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hzs.common.core.domain.R;
import com.hzs.common.domain.sale.product.BdProductBasSpecs;
import com.hzs.ground.product.service.IBdProductBasSpecsService;
import com.hzs.scm.product.IBdProductBasSpecsServiceApi;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
/**
*@BelongsProject: hzs_cloud
*@BelongsPackage: com.hzs.scm.product.provider
*@Author: yh
*@CreateTime: 2023-11-23 18:27
*@Description: TODO
*@Version: 1.0
*/
@Slf4j
@DubboService
public class IBdProductBasSpecsServiceProvider implements IBdProductBasSpecsServiceApi {
@Autowired
private IBdProductBasSpecsService productBasSpecsService;
/**
* 新增
* @param productBasSpecsList
* @return
*/
@Override
public R<Boolean> saveAll(List<BdProductBasSpecs> productBasSpecsList) {
return R.ok(productBasSpecsService.saveBatch(productBasSpecsList));
}
/**
* 删除 根据pkProductBas删除
* @param pkProductBasList
* @return
*/
@Override
public R<Boolean> removeByPkProductBasList(List<Integer> pkProductBasList) {
return R.ok(productBasSpecsService.remove(new QueryWrapper<BdProductBasSpecs>().in("PK_PRODUCT_BAS",pkProductBasList)));
}
}