From 621acbbee622ec15019d846c1aea8892a1ccd3f0 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期二, 19 九月 2023 18:07:10 +0800
Subject: [PATCH] 修改
---
server/service/src/main/java/com/doumee/service/business/impl/GoodsServiceImpl.java | 247 +++++++++++++++++++++++--------------------------
1 files changed, 115 insertions(+), 132 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 4e04375..bb7ec36 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
@@ -17,12 +17,12 @@
import com.doumee.dao.business.*;
import com.doumee.dao.business.join.GoodsJoinMapper;
import com.doumee.dao.business.model.*;
-import com.doumee.dao.business.model.dto.BatchDisableDTO;
-import com.doumee.dao.business.model.dto.GoodCreatePlatRequest;
-import com.doumee.dao.business.model.dto.GoodsRequest;
-import com.doumee.dao.business.model.dto.PlatGoodsParam;
+import com.doumee.dao.business.model.dto.*;
+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.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
@@ -54,6 +54,9 @@
@Autowired
private GoodsMapper goodsMapper;
+ @Autowired
+ @Lazy
+ private BaseDataService baseDataService;
@Autowired
private BaseGoodsMapper baseGoodsMapper;
@Autowired
@@ -128,9 +131,10 @@
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())){
+ if(!Constants.equalsInteger(user.getType(), Constants.UserType.COMPANY.getKey())){
//闈炰紒涓氱敤鎴蜂笉鑳芥搷浣�
throw new BusinessException(ResponseStatus.NOT_ALLOWED);
}
@@ -143,7 +147,7 @@
throw new BusinessException(ResponseStatus.BAD_REQUEST);
}
Category category = categoryMapper.selectById(param.getCategoryId());
- if(category ==null ||Constants.equalsInteger(category.getIsdeleted(), Constants.ONE) ||Constants.equalsInteger(category.getCompanyId(), user.getCompanyId())){
+ if(category ==null ||Constants.equalsInteger(category.getIsdeleted(), Constants.ONE) ||!Constants.equalsInteger(category.getCompanyId(), user.getCompanyId())){
throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝绫诲埆淇℃伅涓嶆纭紝璇峰埛鏂伴噸璇曪紒");
}
if(category.getPlatCateId() == null){
@@ -160,11 +164,14 @@
if(p.getGoodsId() == null || p.getPrice() == null){
throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝璇锋纭�夋嫨骞冲彴鍟嗗搧骞堕厤缃叆鎵嬩环锛�");
}
+ if(ids == null){
+ ids = new ArrayList<>();
+ }
ids.add(p.getGoodsId());
}
}
goodsList = baseGoodsMapper.selectList(new QueryWrapper<>(bp).lambda().in((ids!=null && ids.size()>0),BaseGoods::getId,ids));
- if(Constants.equalsInteger(Constants.ONE, param.getType()) || goodsList==null || ids.size()!=goodsList.size()){
+ if(Constants.equalsInteger(Constants.ONE, param.getType()) &&( goodsList==null || ids.size()!=goodsList.size())){
// 濡傛灉閫夋嫨骞冲彴鍟嗗搧鍜屾煡璇㈢粨鏋滃涓嶄笂锛屾彁绀洪敊璇�
throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝璇锋纭�夋嫨骞冲彴鍟嗗搧锛�");
}
@@ -193,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());
@@ -202,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);
}
}
@@ -219,6 +237,7 @@
goods.setStatus(Constants.ZERO);
goods.setCreateDate(new Date());
goods.setCreator(user.getId());
+ goods.setCompanyId(user.getCompanyId());
goods.setIsdeleted(Constants.ZERO);
//澶勭悊鎷奸煶闂
goods.setPinyin(PinYinUtil.getFullSpell(goods.getName()));
@@ -325,19 +344,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);
+// };
}
}
return goods.getId();
@@ -434,7 +453,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++) {
@@ -462,19 +482,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);
+// };
}
}
}
@@ -559,8 +579,8 @@
@Override
public Goods findById(Integer id) {
Goods goods = goodsMapper.selectById(id);
- String prefixUrl = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.FILE_DIR).getCode()
- + systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.PROJECTS).getCode();
+ String prefixUrl = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode()
+ + systemDictDataBiz.queryByCode(Constants.OSS, Constants.GOODS_IMG).getCode();
goods.setPrefixUrl(prefixUrl);
Brand brand = brandMapper.selectById(goods.getBrandId());
if(!Objects.isNull(brand)){
@@ -603,8 +623,8 @@
Goods::getPrice,goods.getSPrice(),goods.getEPrice());
queryWrapper.orderByDesc(Goods::getId);
List<Goods> goodsList = goodsJoinMapper.selectJoinList(Goods.class,queryWrapper);
- String prefixUrl = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.FILE_DIR).getCode()
- + systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.PROJECTS).getCode();
+ String prefixUrl = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode()
+ + systemDictDataBiz.queryByCode(Constants.OSS, Constants.GOODS_IMG).getCode();
goodsList.forEach(i->{
i.setPrefixUrl(prefixUrl);
i.setMultifileList(multifileMapper.selectList(new QueryWrapper<Multifile>().eq("OBJ_ID",i.getId()).orderByAsc(" SORTNUM ")));
@@ -621,11 +641,16 @@
queryWrapper.selectAll(Goods.class);
queryWrapper.selectAs(Category::getName, Goods::getCategoryName);
+ queryWrapper.selectAs(BaseGoods::getZdPrice, Goods::getBaseZdPrice);
+ queryWrapper.selectAs(BaseGoods::getPrice, Goods::getBasePrice);
queryWrapper.selectAs(Brand::getName, Goods::getBrandName);
queryWrapper.selectAs(Category::getAttrFirst, Goods::getAttrFirst);
queryWrapper.selectAs(Category::getAttrSecond, Goods::getAttrSecond);
+ queryWrapper.selectAs(BaseCategory::getPriceRate,Goods::getBasePriceRate);
queryWrapper.leftJoin(Category.class, Category::getId, Goods::getCategoryId);
queryWrapper.leftJoin(Brand.class, Brand::getId, Goods::getBrandId);
+ queryWrapper.leftJoin(BaseGoods.class,BaseGoods::getId,Goods::getGoodsId);
+ queryWrapper.leftJoin(BaseCategory.class,BaseCategory::getId,BaseGoods::getCategoryId);
queryWrapper.eq(Goods::getIsdeleted, Constants.ZERO);
if (pageWrap.getModel().getId() != null) {
@@ -637,7 +662,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());
}
@@ -649,8 +676,8 @@
}
queryWrapper.orderByDesc(Goods::getId);
IPage<Goods> goodsIPage = goodsJoinMapper.selectJoinPage(page, Goods.class, queryWrapper);
- String prefixUrl = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.FILE_DIR).getCode()
- + systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.PROJECTS).getCode();
+ String prefixUrl = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode()
+ + systemDictDataBiz.queryByCode(Constants.OSS, Constants.GOODS_IMG).getCode();
goodsIPage.getRecords().forEach(i->{
i.setPrefixUrl(prefixUrl);
});
@@ -708,6 +735,7 @@
Goods g = new Goods();
g.setIsdeleted(Constants.ZERO);
g.setRemark(m.getId());
+ g.setCompanyId(user.getCompanyId());
//鍝佺被鏁版嵁
g = goodsMapper.selectOne(new QueryWrapper<>(g).last(" limit 1"));
if(g != null){
@@ -716,6 +744,7 @@
Category cate = new Category();
cate.setIsdeleted(Constants.ZERO);
cate.setName(m.getCategory());
+ cate.setCompanyId(user.getCompanyId());
//鍝佺被鏁版嵁
cate = categoryMapper.selectOne(new QueryWrapper<>(cate).last(" limit 1"));
if(cate == null){
@@ -725,7 +754,9 @@
brand.setIsdeleted(Constants.ZERO);
brand.setName(m.getBrand());
//鍝佺被鏁版嵁
- brand = brandMapper.selectOne(new QueryWrapper<>(brand).last(" limit 1"));
+ QueryWrapper<Brand> qwrapper = new QueryWrapper<>(brand);
+ qwrapper.lambda().and(wapper-> wapper.eq(Brand::getCompanyId ,user.getCompanyId()).or().eq(Brand::getType,Constants.ONE));
+ brand = brandMapper.selectOne(qwrapper.last(" limit 1"));
if(brand == null){
throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝绗��"+(num)+"銆戣鍟嗗搧鍝佺墝鏃犳晥锛岃妫�鏌ヨ緭鍏ワ紒");
}
@@ -738,6 +769,7 @@
newModel.setBrandId(brand.getId());
newModel.setIsdeleted(Constants.ZERO);
newModel.setCreator(user.getId());
+ newModel.setCompanyId(user.getCompanyId());
newModel.setCreateDate(new Date());
newModel.setName(m.getName());
newModel.setStatus(Constants.ZERO);
@@ -756,67 +788,14 @@
newModel.setPinyin(PinYinUtil.getFullSpell(m.getName()));
newModel.setShortPinyin(PinYinUtil.getFirstSpell(m.getName()));
- CateAttr ca = new CateAttr();
- ca.setCategoryId(cate.getId());
- ca.setIsdeleted(Constants.ZERO);
- //鏌ヨ鍏ㄩ儴灞炴��1鍜屽睘鎬�2瑙勬牸鍊�
- List<CateAttr> allAttr = cateAttrMapper.selectList(new QueryWrapper<>(ca));
- //灞炴��1闆嗗悎
-// String[] attrs = StringUtils.defaultString(m.getAttrFirstNames(),"").split("\n");
- //灞炴��2闆嗗悎
-// String[] attrs2 = StringUtils.defaultString(m.getAttrSecodNames(),"").split("\n");
- //浜у搧鍙傛暟闆嗗悎
String[] params = StringUtils.defaultString(m.getParamStr(),"").split("\n");
-// if(attrs.length > 0){
-// String attrids="" ,attrNames="";
-// for(String s : attrs){
-// if(StringUtils.isBlank(s)){
-// continue;
-// }
-// //鏌ヨ灞炴�ц鏍煎璞�
-// CateAttr ta = getCateAttrByName(s,Constants.ZERO,allAttr);
-// if(ta == null){
-// throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝绗��"+(num)+"銆戣灞炴��1涓��"+s+"銆戞棤鏁堬紝璇锋鏌ヨ緭鍏ワ紒");
-// }
-// if(StringUtils.isNotBlank(attrids)){
-// attrids += ",";
-// attrNames += ",";
-// }
-// attrids+= ta.getId();
-// attrNames+= ta.getName();
-// }
-// newModel.setAttrFirstIds(attrids);
-// newModel.setAttrFirstNames(attrNames);
-// }
-// if(attrs2.length > 0){
-// String attrids="" ,attrNames="";
-// for(String s : attrs2){
-// if(StringUtils.isBlank(s)){
-// continue;
-// }
-// //鏌ヨ灞炴�ц鏍煎璞�
-// CateAttr ta = getCateAttrByName(s,Constants.ONE,allAttr);
-// if(ta == null){
-// throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"瀵逛笉璧凤紝绗��"+(num)+"銆戣灞炴��1涓��"+s+"銆戞棤鏁堬紝璇锋鏌ヨ緭鍏ワ紒");
-// }
-// if(StringUtils.isNotBlank(attrids)){
-// attrids += ",";
-// attrNames += ",";
-// }
-// attrids+= ta.getId();
-// attrNames+= ta.getName();
-// }
-// newModel.setAttrSecodIds(attrids);
-// newModel.setAttrSecodNames(attrNames);
-//
-// }
List<String> mulFiles = null;
String proDir =systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.PROJECTS).getCode();
- String tf = proDir.substring(0,proDir.length()-1);
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);
if(dir!=null && dir.isDirectory()){
File[] files = dir.listFiles();
@@ -824,16 +803,8 @@
for(File f:files){
if(StringUtils.isBlank(newModel.getImgurl()) && isImgFile(f)){
//鍙栫涓�寮犲浘鐗囦綔涓哄垪琛ㄥ浘
- String imgdir =f.getPath().substring(f.getPath().indexOf(tf)+tf.length()+1);
- newModel.setImgurl(imgdir.replace(File.separator,"/"));
-// newModel.setImgurl(f.getPath().replace(path.replace(File.separator,"/"),""));
+ newModel.setImgurl(baseDataService.getOssImgurl(ossModel,ossModel.getGoodsFolder(),f));
}
-// else{
-// if(mulFiles==null){
-// mulFiles = new ArrayList<>();
-// }
-// mulFiles.add(f.getPath().replace(path.replace("/",File.separator),""));
-// }
if((mulFiles ==null || mulFiles.size() == 0) && f.isDirectory()){
//濡傛灉鏄枃浠跺す
File[] fs = f.listFiles();
@@ -843,12 +814,7 @@
if(mulFiles==null){
mulFiles = new ArrayList<>();
}
-
- String imgdir =mf.getPath().substring(mf.getPath().indexOf(tf)+tf.length()+1);
- mulFiles.add(imgdir.replace(File.separator,"/"));
-// newModel.setImgurl(imgdir);
-//// mulFiles.add(mf.getName());
-// mulFiles.add(mf.getPath().replace(path.replace(File.separator,"/"),""));
+ mulFiles.add(baseDataService.getOssImgurl(ossModel,ossModel.getGoodsFolder(),mf));
}
}
}
@@ -892,19 +858,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){
@@ -919,6 +885,7 @@
f.setCreator(newModel.getCreator());
f.setIsdeleted(Constants.ZERO);
f.setSortnum(i);
+ f.setCompanyId(user.getCompanyId());
f.setFileurl(s);
multifileMapper.insert(f);
}
@@ -928,6 +895,9 @@
return num;
}
+
+
+
private boolean isImgFile(File f) {
if(f!=null && f.isFile() ){
@@ -1014,6 +984,7 @@
@Override
public void export(HttpServletRequest request, HttpServletResponse response) throws Exception {
try {
+ LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
String fileName = "浜у搧瀵煎叆琛�"+System.currentTimeMillis()+".xlsx";
// 鑾峰彇鏂囦欢杈撳叆娴�
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("static/file/goodsExcelTemp.xlsx");
@@ -1027,7 +998,10 @@
// sheet.getPhysicalNumberOfRows()鑾峰彇鎬荤殑琛屾暟
// 寰幆璇诲彇姣忎竴琛�
Row row = sheet.createRow(1);
- List<Category> categoryList = categoryMapper.selectList(new QueryWrapper<Category>().eq("ISDELETED",0));
+ List<Category> categoryList = categoryMapper.selectList(
+ new QueryWrapper<Category>().eq("ISDELETED",0)
+ .eq("COMPANY_ID",loginUserInfo.getCompanyId())
+ );
categoryList.forEach(i->{
i.setParamList(cateParamMapper.selectList(new QueryWrapper<CateParam>().eq("ISDELETED",0).eq("CATEGORY_ID",i.getId())));
});
@@ -1086,14 +1060,18 @@
.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);
IPage<Goods> goodsIPage = goodsJoinMapper.selectJoinPage(page, Goods.class, queryWrapper);
- String prefixUrl = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.FILE_DIR).getCode()
- + systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.PROJECTS).getCode();
+ String prefixUrl = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode()
+ + systemDictDataBiz.queryByCode(Constants.OSS, Constants.GOODS_IMG).getCode();
goodsIPage.getRecords().forEach(i->{
i.setPrefixUrl(prefixUrl);
i.setMultifileList(multifileMapper.selectList(new QueryWrapper<Multifile>().eq("OBJ_ID",i.getId()).orderByAsc(" SORTNUM ")));
@@ -1105,6 +1083,10 @@
@Override
public List<Goods> findListForH5(GoodsRequest goodsRequest) {
+ LoginUserInfo loginUserInfo = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
+ if(!loginUserInfo.getType().equals(Constants.UserType.ZHUBO.getKey())){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"闈炰富鎾敤鎴锋棤娉曚娇鐢�");
+ }
MPJLambdaWrapper<Goods> queryWrapper = new MPJLambdaWrapper<>();
queryWrapper.selectAll(Goods.class);
queryWrapper.selectAs(Category::getName, Goods::getCategoryName);
@@ -1116,6 +1098,7 @@
queryWrapper.leftJoin(Brand.class, Brand::getId, Goods::getBrandId);
queryWrapper.eq(Goods::getStatus,Constants.ZERO);
queryWrapper.eq(Goods::getIsdeleted,Constants.ZERO);
+ queryWrapper.eq(Goods::getCompanyId,loginUserInfo.getCompanyId());
queryWrapper.eq(!Objects.isNull(goodsRequest) && !Objects.isNull(goodsRequest.getCategoryId()), Goods::getCategoryId, goodsRequest.getCategoryId())
.eq(!Objects.isNull(goodsRequest) && !Objects.isNull(goodsRequest.getBrandId()), Goods::getBrandId, goodsRequest.getBrandId())
.and(!Objects.isNull(goodsRequest) && StringUtils.isNotBlank(goodsRequest.getKeyword()),
@@ -1129,8 +1112,8 @@
.apply(!Objects.isNull(goodsRequest) && !Objects.isNull(goodsRequest.getEPrice()), " t.PRICE <= "+goodsRequest.getEPrice()+" ");
queryWrapper.orderByDesc(Goods::getId);
List<Goods> goodsList = goodsJoinMapper.selectJoinList(Goods.class,queryWrapper);
- String prefixUrl = systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.FILE_DIR).getCode()
- + systemDictDataBiz.queryByCode(Constants.SYSTEM, Constants.PROJECTS).getCode();
+ String prefixUrl = systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode()
+ + systemDictDataBiz.queryByCode(Constants.OSS, Constants.GOODS_IMG).getCode();
goodsList.forEach(i->{
i.setPrefixUrl(prefixUrl);
i.setMultifileList(multifileMapper.selectList(new QueryWrapper<Multifile>().eq("OBJ_ID",i.getId()).orderByAsc(" SORTNUM ")));
--
Gitblit v1.9.3