|
|
@@ -16,6 +16,7 @@
|
|
|
*/
|
|
|
package org.springblade.salesPart.goods.controller;
|
|
|
|
|
|
+import com.alibaba.csp.sentinel.util.StringUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
@@ -29,6 +30,8 @@ import lombok.AllArgsConstructor;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.Valid;
|
|
|
|
|
|
+import org.springblade.client.entity.GoodsDesc;
|
|
|
+import org.springblade.client.entity.GoodsType;
|
|
|
import org.springblade.core.excel.util.ExcelUtil;
|
|
|
import org.springblade.core.mp.support.Condition;
|
|
|
import org.springblade.core.mp.support.Query;
|
|
|
@@ -37,12 +40,16 @@ import org.springblade.core.secure.utils.SecureUtil;
|
|
|
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.entity.PjBrandDesc;
|
|
|
import org.springblade.salesPart.entity.PjGoodsType;
|
|
|
+import org.springblade.salesPart.entity.PjShoppingCart;
|
|
|
import org.springblade.salesPart.excel.CorpsDescExportExcel;
|
|
|
import org.springblade.salesPart.excel.GoodsDescExportExcel;
|
|
|
import org.springblade.salesPart.excel.GoodsExcel;
|
|
|
import org.springblade.salesPart.goods.service.IGoodsTypeService;
|
|
|
+import org.springblade.system.entity.Dept;
|
|
|
+import org.springblade.system.feign.ISysClient;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import org.springblade.salesPart.entity.PjGoodsDesc;
|
|
|
@@ -72,6 +79,8 @@ public class GoodsDescController extends BladeController {
|
|
|
private final IGoodsTypeService goodsDescType;
|
|
|
private final IGoodsDescService goodsDescService;
|
|
|
|
|
|
+ private final ISysClient iSysClient;
|
|
|
+
|
|
|
/**
|
|
|
* 详情
|
|
|
*/
|
|
|
@@ -92,6 +101,17 @@ public class GoodsDescController extends BladeController {
|
|
|
@ApiOperation(value = "分页", notes = "传入goods")
|
|
|
public R<IPage<PjGoodsDesc>> list(PjGoodsDesc goods, Query query) {
|
|
|
LambdaQueryWrapper<PjGoodsDesc> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+
|
|
|
+ //指定分类为一级分类,查询此分类所有二级分类的商品
|
|
|
+ if (StringUtils.isNotBlank(goods.getGoodsTypeId())) {
|
|
|
+ Long goodsId = Long.parseLong(goods.getGoodsTypeId());
|
|
|
+ List<Long> goodsIdList = new ArrayList<>();
|
|
|
+ selectChildById(goodsId, goodsIdList);
|
|
|
+ goodsIdList.add(goodsId);
|
|
|
+
|
|
|
+ lambdaQueryWrapper.in(PjGoodsDesc::getGoodsTypeId, goodsIdList);
|
|
|
+ }
|
|
|
+
|
|
|
lambdaQueryWrapper.eq(PjGoodsDesc::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(PjGoodsDesc::getIsDeleted, 0)
|
|
|
.like(StringUtils.isNotBlank(goods.getSpecificationAndModel()), PjGoodsDesc::getSpecificationAndModel, goods.getSpecificationAndModel())//规格型号
|
|
|
@@ -103,6 +123,7 @@ public class GoodsDescController extends BladeController {
|
|
|
.eq(ObjectUtils.isNotEmpty(goods.getWhether()), PjGoodsDesc::getWhether, goods.getWhether())//是否管理到批次号
|
|
|
.eq(ObjectUtils.isNotEmpty(goods.getExplosionProof()), PjGoodsDesc::getExplosionProof, goods.getExplosionProof());//是否防爆
|
|
|
IPage<PjGoodsDesc> pages = goodsService.page(Condition.getPage(query),lambdaQueryWrapper);
|
|
|
+
|
|
|
pages.getRecords().forEach(e -> {
|
|
|
String typeId = e.getGoodsTypeId();
|
|
|
String[] split = typeId.split(",");
|
|
|
@@ -114,6 +135,17 @@ public class GoodsDescController extends BladeController {
|
|
|
List<String> typeStr = types.stream().map(PjGoodsType::getCname).collect(Collectors.toList());
|
|
|
e.setGoodsTypeName(typeStr.toString().replace("[", "").replace("]", ""));
|
|
|
}
|
|
|
+
|
|
|
+ //获得所属公司
|
|
|
+ if (StringUtil.isNotBlank(e.getSalesCompanyName())) {
|
|
|
+ R<Dept> dept = iSysClient.getDept(e.getSalesCompanyId());
|
|
|
+ if (ObjectUtil.isNotEmpty(dept)) {
|
|
|
+ e.setSalesCompanyName(dept.getData().getDeptName());
|
|
|
+ } else {
|
|
|
+ throw new SecurityException("请输入正确的所属公司");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
});
|
|
|
return R.data(pages);
|
|
|
}
|
|
|
@@ -226,6 +258,17 @@ public class GoodsDescController extends BladeController {
|
|
|
@ApiOperation(value = "导出商品", notes = "传入goods")
|
|
|
public void exportGoodsList(PjGoodsDesc goods, HttpServletResponse response) {
|
|
|
LambdaQueryWrapper<PjGoodsDesc> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+
|
|
|
+ //指定分类为一级分类,查询此分类所有二级分类的商品
|
|
|
+ if (StringUtils.isNotBlank(goods.getGoodsTypeId())) {
|
|
|
+ Long goodsId = Long.parseLong(goods.getGoodsTypeId());
|
|
|
+ List<Long> goodsIdList = new ArrayList<>();
|
|
|
+ selectChildById(goodsId, goodsIdList);
|
|
|
+ goodsIdList.add(goodsId);
|
|
|
+
|
|
|
+ lambdaQueryWrapper.in(PjGoodsDesc::getGoodsTypeId, goodsIdList);
|
|
|
+ }
|
|
|
+
|
|
|
lambdaQueryWrapper.eq(PjGoodsDesc::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(PjGoodsDesc::getIsDeleted, 0)
|
|
|
.like(StringUtils.isNotBlank(goods.getSpecificationAndModel()), PjGoodsDesc::getSpecificationAndModel, goods.getSpecificationAndModel())//规格型号
|
|
|
@@ -236,6 +279,7 @@ public class GoodsDescController extends BladeController {
|
|
|
.eq(ObjectUtils.isNotEmpty(goods.getSalesCompanyId()), PjGoodsDesc::getSalesCompanyId, goods.getSalesCompanyId())//所属公司
|
|
|
.eq(ObjectUtils.isNotEmpty(goods.getWhether()), PjGoodsDesc::getWhether, goods.getWhether())//是否管理到批次号
|
|
|
.eq(ObjectUtils.isNotEmpty(goods.getExplosionProof()), PjGoodsDesc::getExplosionProof, goods.getExplosionProof());//是否防爆
|
|
|
+
|
|
|
List<PjGoodsDesc> list = goodsService.list(lambdaQueryWrapper);
|
|
|
list.forEach(e -> {
|
|
|
String typeId = e.getGoodsTypeId();
|
|
|
@@ -256,7 +300,7 @@ public class GoodsDescController extends BladeController {
|
|
|
* 启用禁用
|
|
|
*/
|
|
|
@GetMapping("/updateEnableOrNot")
|
|
|
- @ApiOperationSupport(order = 9)
|
|
|
+ @ApiOperationSupport(order = 11)
|
|
|
@ApiOperation(value = "启用禁用", notes = "传入goodsDesc")
|
|
|
public R updateEnableOrNot(PjGoodsDesc goodsDesc){
|
|
|
if (goodsDesc.getId() == null){
|
|
|
@@ -265,4 +309,34 @@ public class GoodsDescController extends BladeController {
|
|
|
boolean status = goodsDescService.updateById(goodsDesc);
|
|
|
return R.status(status);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 商品下拉 配件批发商品表
|
|
|
+ */
|
|
|
+ @GetMapping("/goodsListAll")
|
|
|
+ @ApiOperationSupport(order = 12)
|
|
|
+ @ApiOperation(value = "商品下拉", notes = "传入goods")
|
|
|
+ public R<List<PjGoodsDesc>> goodsListAll(PjGoodsDesc goods) {
|
|
|
+ LambdaQueryWrapper<PjGoodsDesc> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ lambdaQueryWrapper.eq(PjGoodsDesc::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PjGoodsDesc::getIsDeleted, 0)
|
|
|
+ .like(StringUtils.isNotBlank(goods.getCname()), PjGoodsDesc::getCname, goods.getCname());//商品名称
|
|
|
+ List<PjGoodsDesc> list = goodsService.list(lambdaQueryWrapper);
|
|
|
+
|
|
|
+ return R.data(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 递归查询ID
|
|
|
+ */
|
|
|
+ private void selectChildById(Long id, List<Long> idList) {
|
|
|
+ LambdaQueryWrapper<PjGoodsType> idListWrapper = new LambdaQueryWrapper<>();
|
|
|
+ idListWrapper.select(PjGoodsType::getId);
|
|
|
+ idListWrapper.eq(PjGoodsType::getParentId, id);
|
|
|
+ List<PjGoodsType> childIdList = goodsDescType.list(idListWrapper);
|
|
|
+ childIdList.forEach(item -> {
|
|
|
+ idList.add(item.getId());
|
|
|
+ this.selectChildById(item.getId(), idList);
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|