From 421a63cdb3427136c297a17f6b38e22036ad20e9 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期二, 19 九月 2023 20:03:14 +0800
Subject: [PATCH] Merge branch 'dev' of http://139.186.142.91:10010/r/productDev/preselect into dev
---
server/service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java | 134 ++++++++++++++++++++++++--------------------
1 files changed, 73 insertions(+), 61 deletions(-)
diff --git a/server/service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java
index a805828..394b42a 100644
--- a/server/service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java
+++ b/server/service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java
@@ -21,6 +21,7 @@
import com.doumee.service.business.BaseDataService;
import com.doumee.service.business.GoodsService;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
+import io.swagger.v3.oas.annotations.callbacks.Callback;
import lombok.extern.java.Log;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.*;
@@ -130,6 +131,7 @@
return goods.getId();
}
@Override
+ @Transactional( rollbackFor = {Exception.class, BusinessException.class})
public Integer createPlat(GoodCreatePlatRequest param){
LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
if(!Constants.equalsInteger(user.getType(), Constants.UserType.COMPANY.getKey())){
@@ -198,6 +200,16 @@
if(!Objects.isNull(goodsParamList)&&goodsParamList.size()>0){
for (int i = 0; i < goodsParamList.size(); i++) {
BaseGoodsParam bgParam = goodsParamList.get(i);
+ //鏍规嵁骞冲彴鍟嗗搧閰嶇疆鐨勫钩鍙板弬鏁颁俊鎭煡璇紒涓氱粦瀹氱殑鍙傛暟淇℃伅 杩涜瀛樺偍鍒� 浼佷笟鍟嗗搧鍙傛暟鍐�
+ CateParam cateParam = cateParamMapper.selectOne(new QueryWrapper<CateParam>()
+ .eq("CATEGORY_ID",goods.getCategoryId())
+ .eq("BASE_CATE_PARAM_ID",bgParam.getPramaId())
+ .eq("ISDELETED",Constants.ZERO)
+ .eq("STATUS",Constants.ZERO)
+ .last(" limit 1 "));
+// if(Objects.isNull(cateParam)){
+// throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"浼佷笟鍒嗙被鏁版嵁鍚屾寮傚父璇疯仈绯荤鐞嗗憳");
+// }
GoodsParam goodsParam = new GoodsParam();
goodsParam.setCreator(user.getId());
goodsParam.setCreateDate(new Date());
@@ -207,6 +219,7 @@
goodsParam.setGoodsId(goods.getId());
goodsParam.setVal(bgParam.getVal());
goodsParam.setName(bgParam.getName());
+ goodsParam.setPramaId(Objects.isNull(cateParam)?null:cateParam.getId());
goodsParamMapper.insert(goodsParam);
}
}
@@ -216,6 +229,7 @@
Goods goods = new Goods();
goods.setIsdeleted(Constants.ZERO);
goods.setGoodsId(model.getId());
+ goods.setCompanyId(user.getCompanyId());
if(goodsMapper.selectCount(new QueryWrapper<>(goods))>0){
//濡傛灉宸茬粡鍚屾杩囷紝璺宠繃姝ゆ鍚屾
return null;
@@ -271,16 +285,16 @@
if(Constants.equalsInteger(Constants.ONE, param.getType())){
for(PlatGoodsParam p: param.getGoodsParamList()){
if(Constants.equalsInteger(model.getId(),p.getGoodsId())){
- return p.getPrice();
+ return p.getPrice().setScale(0,BigDecimal.ROUND_CEILING);
}
}
}
//濡傛灉娌℃湁閰嶇疆鍏ユ墜浠凤紝瀹夎鍔犱环绯绘暟鏉ヨ绠�
- if(model.getCateRatePrice()==null){
- model.setCateRatePrice(systemDictDataBiz.getGoodsPriceRate());
- }
- //杩斿洖
- return Constants.formatBigdecimal(model.getPrice()).multiply(model.getCateRatePrice()).multiply(param.getRate());
+// if(model.getCateRatePrice()==null){
+// model.setCateRatePrice(systemDictDataBiz.getGoodsPriceRate());
+// }
+ //杩斿洖 .multiply(model.getCateRatePrice())
+ return (Constants.formatBigdecimal(model.getPrice()).multiply(param.getRate())).setScale(0,BigDecimal.ROUND_CEILING);
}
@@ -316,6 +330,7 @@
multifile.setObjId(goods.getId());
multifile.setType(Constants.ZERO);
multifile.setObjType(Constants.ZERO);
+ multifile.setCompanyId(goods.getCompanyId());
multifileMapper.insert(multifile);
}
}
@@ -330,20 +345,6 @@
goodsParam.setSortnum(i+Constants.ONE);
goodsParam.setGoodsId(goods.getId());
goodsParamMapper.insert(goodsParam);
- //瀛樺偍 cate_param_select 鏌ヨ鏄惁宸插瓨鍦�
- if(cateParamSelectMapper.selectCount(new QueryWrapper<CateParamSelect>()
- .eq("PARAM_ID",goodsParam.getPramaId()).eq("NAME",goodsParam.getName()))<=Constants.ZERO){
- CateParamSelect cateParamSelect = new CateParamSelect();
- cateParamSelect.setCreator(user.getId());
- cateParamSelect.setCreateDate(new Date());
- cateParamSelect.setName(goodsParam.getVal());
- cateParamSelect.setIsdeleted(Constants.ZERO);
- cateParamSelect.setStatus(Constants.ZERO);
- cateParamSelect.setParamId(goodsParam.getPramaId());
- cateParamSelect.setCategoryId(goods.getCategoryId());
- cateParamSelect.setStatus(Constants.ZERO);
- cateParamSelectMapper.insert(cateParamSelect);
- };
}
}
return goods.getId();
@@ -428,7 +429,8 @@
}else{
throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"褰撳墠鐧诲綍鐢ㄦ埛绫诲埆閿欒锛屾棤娉曡繘琛岃鎿嶄綔");
}
- if(goodsMapper.selectCount(new QueryWrapper<Goods>().eq("COMPANY_ID",user.getCompanyId()).eq("ISDELETED",Constants.ZERO).ne("id",goods.getId()).eq("name",goods.getName()))>0){
+ if(goodsMapper.selectCount(new QueryWrapper<Goods>().eq("COMPANY_ID",user.getCompanyId())
+ .eq("ISDELETED",Constants.ZERO).ne("id",goods.getId()).eq("name",goods.getName()))>0){
throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"銆�"+goods.getName()+"銆戝凡瀛樺湪");
};
goods.setStatus(Constants.ZERO);
@@ -440,7 +442,8 @@
goods.setShortPinyin(PinYinUtil.getFirstSpell(goods.getName()));
goodsMapper.updateById(goods);
- multifileMapper.delete(new QueryWrapper<Multifile>().eq("OBJ_ID",goods.getId()));
+ multifileMapper.delete(new QueryWrapper<Multifile>().eq("OBJ_ID",goods.getId())
+ .eq("OBJ_TYPE",0).eq("COMPANY_ID",user.getCompanyId()));
List<Multifile> multifileList = goods.getMultifileList();
if(!Objects.isNull(multifileList)&&multifileList.size()>Constants.ZERO){
for (int i = 0; i < multifileList.size(); i++) {
@@ -451,6 +454,7 @@
multifile.setSortnum(i+Constants.ONE);
multifile.setObjId(goods.getId());
multifile.setType(Constants.ZERO);
+ multifile.setCompanyId(goods.getCompanyId());
multifile.setObjType(Constants.ZERO);
multifileMapper.insert(multifile);
}
@@ -468,19 +472,19 @@
goodsParam.setGoodsId(goods.getId());
goodsParamMapper.insert(goodsParam);
//瀛樺偍 cate_param_select 鏌ヨ鏄惁宸插瓨鍦�
- if(cateParamSelectMapper.selectCount(new QueryWrapper<CateParamSelect>()
- .eq("PARAM_ID",goodsParam.getPramaId()).eq("NAME",goodsParam.getName()))<=Constants.ZERO){
- CateParamSelect cateParamSelect = new CateParamSelect();
- cateParamSelect.setCreator(user.getId());
- cateParamSelect.setCreateDate(new Date());
- cateParamSelect.setName(goodsParam.getVal());
- cateParamSelect.setIsdeleted(Constants.ZERO);
- cateParamSelect.setStatus(Constants.ZERO);
- cateParamSelect.setParamId(goodsParam.getPramaId());
- cateParamSelect.setCategoryId(goods.getCategoryId());
- cateParamSelect.setStatus(Constants.ZERO);
- cateParamSelectMapper.insert(cateParamSelect);
- };
+// if(cateParamSelectMapper.selectCount(new QueryWrapper<CateParamSelect>()
+// .eq("PARAM_ID",goodsParam.getPramaId()).eq("NAME",goodsParam.getName()))<=Constants.ZERO){
+// CateParamSelect cateParamSelect = new CateParamSelect();
+// cateParamSelect.setCreator(user.getId());
+// cateParamSelect.setCreateDate(new Date());
+// cateParamSelect.setName(goodsParam.getVal());
+// cateParamSelect.setIsdeleted(Constants.ZERO);
+// cateParamSelect.setStatus(Constants.ZERO);
+// cateParamSelect.setParamId(goodsParam.getPramaId());
+// cateParamSelect.setCategoryId(goods.getCategoryId());
+// cateParamSelect.setStatus(Constants.ZERO);
+// cateParamSelectMapper.insert(cateParamSelect);
+// };
}
}
}
@@ -505,7 +509,7 @@
throw new BusinessException(ResponseStatus.DATA_EMPTY);
}
//鎷夊紡鍟嗗搧 涓� 涓婃灦鏃讹紝闇�瑕侀檺鍒� 骞冲彴鍟嗗搧鏄惁宸蹭笅鏋�
- if(dbGoods.getType().equals(Constants.goodsType.PULL)&&goods.getStatus().equals(Constants.ZERO)){
+ if(dbGoods.getType().equals(Constants.goodsType.PULL.getValue())&&goods.getStatus().equals(Constants.ZERO)){
BaseGoods baseGoods = baseGoodsMapper.selectById(dbGoods.getGoodsId());
if(Objects.isNull(baseGoods)){
throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈煡璇㈠埌骞冲彴鍟嗗搧淇℃伅");
@@ -543,7 +547,7 @@
continue;
}
//鎷夊紡鍟嗗搧 涓� 涓婃灦鏃讹紝闇�瑕侀檺鍒� 骞冲彴鍟嗗搧鏄惁宸蹭笅鏋�
- if(dbGoods.getType().equals(Constants.goodsType.PULL)&&batchDisableDTO.getStatus().equals(Constants.ZERO)){
+ if(dbGoods.getType().equals(Constants.goodsType.PULL.getValue())&&batchDisableDTO.getStatus().equals(Constants.ZERO)){
BaseGoods baseGoods = baseGoodsMapper.selectById(dbGoods.getGoodsId());
if(Objects.isNull(baseGoods)||!baseGoods.getStatus().equals(Constants.ZERO)){
errNum++;
@@ -648,7 +652,9 @@
if (pageWrap.getModel().getStatus() != null) {
queryWrapper.eq(Goods::getStatus, pageWrap.getModel().getStatus());
}
-
+ if (pageWrap.getModel().getType() != null) {
+ queryWrapper.eq(Goods::getType, pageWrap.getModel().getType());
+ }
if (pageWrap.getModel().getCategoryId() != null) {
queryWrapper.eq(Goods::getCategoryId, pageWrap.getModel().getCategoryId());
}
@@ -664,10 +670,6 @@
+ systemDictDataBiz.queryByCode(Constants.OSS, Constants.GOODS_IMG).getCode();
goodsIPage.getRecords().forEach(i->{
i.setPrefixUrl(prefixUrl);
- if(i.getType().equals(Constants.ONE)){
- i.setBasePrice(i.getBasePrice().multiply(i.getBasePriceRate()));
- }
-
});
return PageData.from(goodsIPage);
}
@@ -781,7 +783,7 @@
String proDir =systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.PROJECTS).getCode();
String path = systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.GOODS_IMG_DIR).getCode()
- + proDir;
+ + proDir + File.separator + user.getCompanyId();
if(StringUtils.isNotBlank(path)){
OssModel ossModel = baseDataService.initOssModel();
File dir =new File(path+File.separator+newModel.getRemark()+File.separator);
@@ -802,7 +804,7 @@
if(mulFiles==null){
mulFiles = new ArrayList<>();
}
- mulFiles.add(baseDataService.getOssImgurl(ossModel,ossModel.getGoodsFolder(),f));
+ mulFiles.add(baseDataService.getOssImgurl(ossModel,ossModel.getGoodsFolder(),mf));
}
}
}
@@ -846,19 +848,19 @@
//鎻掑叆浜у搧鍙傛暟鍏宠仈琛�
goodsParamMapper.insert(gp);
//瀛樺偍 cate_param_select 鏌ヨ鏄惁宸插瓨鍦�
- if(cateParamSelectMapper.selectCount(new QueryWrapper<CateParamSelect>()
- .eq("PARAM_ID",gp.getPramaId()).eq("NAME",gp.getName()))<=Constants.ZERO){
- CateParamSelect cateParamSelect = new CateParamSelect();
- cateParamSelect.setCreator(user.getId());
- cateParamSelect.setCreateDate(new Date());
- cateParamSelect.setName(gp.getVal());
- cateParamSelect.setIsdeleted(Constants.ZERO);
- cateParamSelect.setStatus(Constants.ZERO);
- cateParamSelect.setParamId(gp.getPramaId());
- cateParamSelect.setCategoryId(newModel.getCategoryId());
- cateParamSelect.setStatus(Constants.ZERO);
- cateParamSelectMapper.insert(cateParamSelect);
- };
+// if(cateParamSelectMapper.selectCount(new QueryWrapper<CateParamSelect>()
+// .eq("PARAM_ID",gp.getPramaId()).eq("NAME",gp.getName()))<=Constants.ZERO){
+// CateParamSelect cateParamSelect = new CateParamSelect();
+// cateParamSelect.setCreator(user.getId());
+// cateParamSelect.setCreateDate(new Date());
+// cateParamSelect.setName(gp.getVal());
+// cateParamSelect.setIsdeleted(Constants.ZERO);
+// cateParamSelect.setStatus(Constants.ZERO);
+// cateParamSelect.setParamId(gp.getPramaId());
+// cateParamSelect.setCategoryId(newModel.getCategoryId());
+// cateParamSelect.setStatus(Constants.ZERO);
+// cateParamSelectMapper.insert(cateParamSelect);
+// };
}
}
if(mulFiles !=null && mulFiles.size()>0){
@@ -873,6 +875,7 @@
f.setCreator(newModel.getCreator());
f.setIsdeleted(Constants.ZERO);
f.setSortnum(i);
+ f.setCompanyId(user.getCompanyId());
f.setFileurl(s);
multifileMapper.insert(f);
}
@@ -1047,8 +1050,12 @@
.or().like(Goods::getShortPinyin,pageWrap.getModel().getKeyword())
.or().like(Goods::getName,pageWrap.getModel().getKeyword())
)
- .apply(!Objects.isNull(pageWrap.getModel()) && !Objects.isNull(pageWrap.getModel().getAttrFirst()), " find_in_set('"+pageWrap.getModel().getAttrFirst()+"',t.ATTR_FIRST_IDS) ")
- .apply(!Objects.isNull(pageWrap.getModel()) && !Objects.isNull(pageWrap.getModel().getAttrSecond()), " find_in_set('"+pageWrap.getModel().getAttrSecond()+"',t.ATTR_SECOD_IDS) ")
+// .apply(!Objects.isNull(pageWrap.getModel()) && !Objects.isNull(pageWrap.getModel().getAttrFirst()), " find_in_set('"+pageWrap.getModel().getAttrFirst()+"',t.ATTR_FIRST_IDS) ")
+// .apply(!Objects.isNull(pageWrap.getModel()) && !Objects.isNull(pageWrap.getModel().getAttrSecond()), " find_in_set('"+pageWrap.getModel().getAttrSecond()+"',t.ATTR_SECOD_IDS) ")
+ .apply(!Objects.isNull(pageWrap.getModel()) && !Objects.isNull(pageWrap.getModel().getAttrFirst()), " t.id in ( SELECT gp.GOODS_ID FROM cate_param_select cps , goods_param gp where gp.PRAMA_ID = cps.PARAM_ID and gp.VAL = cps.`NAME` " +
+ " and cps.ID = '"+pageWrap.getModel().getAttrFirst()+"' ) ")
+ .apply(!Objects.isNull(pageWrap.getModel()) && !Objects.isNull(pageWrap.getModel().getAttrSecond()), " t.id in ( SELECT gp.GOODS_ID FROM cate_param_select cps , goods_param gp where gp.PRAMA_ID = cps.PARAM_ID and gp.VAL = cps.`NAME` " +
+ " and cps.ID = '"+pageWrap.getModel().getAttrSecond()+"' ) ")
.apply(!Objects.isNull(pageWrap.getModel()) && !Objects.isNull(pageWrap.getModel().getSPrice()), " t.PRICE >= "+pageWrap.getModel().getSPrice()+" ")
.apply(!Objects.isNull(pageWrap.getModel()) && !Objects.isNull(pageWrap.getModel().getEPrice()), " t.PRICE <= "+pageWrap.getModel().getEPrice()+" ");
queryWrapper.orderByDesc(Goods::getId);
@@ -1058,7 +1065,9 @@
goodsIPage.getRecords().forEach(i->{
i.setPrefixUrl(prefixUrl);
i.setMultifileList(multifileMapper.selectList(new QueryWrapper<Multifile>().eq("OBJ_ID",i.getId()).orderByAsc(" SORTNUM ")));
- i.setGoodsParamList(goodsParamMapper.selectList(new QueryWrapper<GoodsParam>().eq("GOODS_ID",i.getId()).orderByAsc(" SORTNUM ")));
+ i.setGoodsParamList(goodsParamMapper.selectList(new QueryWrapper<GoodsParam>()
+ .eq("GOODS_ID",i.getId())
+ .orderByAsc(" SORTNUM ")));
});
return PageData.from(goodsIPage);
}
@@ -1100,7 +1109,10 @@
goodsList.forEach(i->{
i.setPrefixUrl(prefixUrl);
i.setMultifileList(multifileMapper.selectList(new QueryWrapper<Multifile>().eq("OBJ_ID",i.getId()).orderByAsc(" SORTNUM ")));
- i.setGoodsParamList(goodsParamMapper.selectList(new QueryWrapper<GoodsParam>().eq("GOODS_ID",i.getId()).orderByAsc(" SORTNUM ")));
+ i.setGoodsParamList(goodsParamMapper.selectList(
+ new QueryWrapper<GoodsParam>().eq("GOODS_ID",i.getId())
+ .apply(" name in ( select cp.NAME from cate_param cp where cp.CATEGORY_ID = "+i.getCategoryId()+" and cp.ISSHOW = 1 and cp.ISDELETED = 0 and cp.STATUS = 0 ) ")
+ .orderByAsc(" SORTNUM ")));
});
return goodsList;
}
--
Gitblit v1.9.3