From b3da9f82b7740d39742fef1a81a56c22fe1c8b9c Mon Sep 17 00:00:00 2001 From: yujian <yujian@163.com> Date: 星期一, 08 六月 2020 17:27:02 +0800 Subject: [PATCH] 券后价调整 --- fanli/src/main/java/com/yeshi/fanli/service/impl/lable/LabelServiceImpl.java | 89 ++++++++++++++++++++++++++++++++------------ 1 files changed, 65 insertions(+), 24 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/lable/LabelServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/lable/LabelServiceImpl.java index fcdaf4d..57a52f5 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/lable/LabelServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/lable/LabelServiceImpl.java @@ -1,6 +1,7 @@ package com.yeshi.fanli.service.impl.lable; import java.io.InputStream; +import java.util.ArrayList; import java.util.Date; import java.util.HashSet; import java.util.List; @@ -9,14 +10,12 @@ import java.util.UUID; import javax.annotation.Resource; -import javax.transaction.Transactional; - -import jxl.Sheet; -import jxl.Workbook; import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; +import org.yeshi.utils.tencentcloud.COSManager; import com.yeshi.fanli.dao.mybatis.lable.LabelClassMapper; import com.yeshi.fanli.dao.mybatis.lable.LabelGoodsMapper; @@ -24,19 +23,19 @@ import com.yeshi.fanli.entity.bus.lable.Label; import com.yeshi.fanli.entity.bus.lable.LabelGoods; import com.yeshi.fanli.entity.common.AdminUser; -import com.yeshi.fanli.exception.LabelException; -import com.yeshi.fanli.log.LogHelper; +import com.yeshi.fanli.exception.goods.quality.LabelException; import com.yeshi.fanli.service.inter.lable.LabelService; +import com.yeshi.fanli.util.FilePathEnum; import com.yeshi.fanli.util.StringUtil; -import org.yeshi.utils.tencentcloud.COSManager; + +import jxl.Sheet; +import jxl.Workbook; @Service public class LabelServiceImpl implements LabelService { @Resource private LabelMapper labelMapper; - @Resource - private LabelService labelService; @Resource private LabelGoodsMapper labelGoodsMapper; @@ -51,7 +50,7 @@ } @Override - @Transactional + @Transactional(rollbackFor=Exception.class) public void insertList(List<Label> records,AdminUser admin) throws LabelException{ if (records != null && records.size() > 0) { for (Label label : records) { @@ -91,14 +90,14 @@ // 涓婁紶鍥剧墖 if (file != null) { - labelService.uploadPicture(file, label); + uploadPicture(file, label); } } @Override - @Transactional + @Transactional(rollbackFor=Exception.class) public void updateList(List<Label> records) throws LabelException{ if (records != null && records.size() > 0) { for (Label label : records) { @@ -127,19 +126,19 @@ @Override - @Transactional + @Transactional(rollbackFor=Exception.class) public int deleteBatchById(long[] ids) throws LabelException{ return labelMapper.deleteBatchByPrimaryKey(ids); } @Override - @Transactional + @Transactional(rollbackFor=Exception.class) public void deleteBatchByPrimaryKey(List<Long> ids) throws LabelException { for (Long id : ids) { Label label = labelMapper.selectByPrimaryKey(id); if (label != null) { // 鍒犻櫎鍥剧墖 - labelService.deleteImg(label); + deleteImg(label); // 鍒犻櫎鏁版嵁淇℃伅 labelMapper.deleteByPrimaryKey(id); @@ -158,14 +157,21 @@ @Override public List<Label> selectByTitle(String title) throws LabelException{ - LogHelper.test("鏌ヨ鏍囩锛� "+title); return labelMapper.selectByTitle(title); } + @Override - @Cacheable(value = "labelCache",key="'selectByTitleCache-'+#labKey +'-'+#title") - public List<Label> selectByTitleCache(String labKey, String title) throws LabelException{ - return selectByTitle(title); + @Cacheable(value = "labelCache",key="'getByTitleCache-'+#labKey +'-'+#title") + public Label getByTitleCache(String labKey, String title) throws LabelException{ + return labelMapper.getByTitle(title); + } + + + @Override + @Cacheable(value = "labelCache",key="'listByTitlesCache-'+#list") + public List<Label> listByTitlesCache(List<String> list){ + return labelMapper.listByTitles(list); } @@ -214,7 +220,7 @@ for (String title : titles) { - List<Label> labels = labelService.selectByTitle(title.trim()); + List<Label> labels = selectByTitle(title.trim()); // 鑻ュ凡瀛樺湪鍒欎笉瀛樺叆鏁版嵁搴� if (labels == null || labels.size() == 0) { Label label = new Label(); @@ -225,7 +231,7 @@ label.setUpdatetime(nowTime); label.setCreateUser(admin); - labelService.insertSelective(label); + insertSelective(label); } } @@ -240,7 +246,7 @@ String contentType = file.getContentType(); String type = contentType.substring(contentType.indexOf("/") + 1); // 涓婁紶鏂囦欢鐩稿浣嶇疆 - String fileUrl="LableImg/"+UUID.randomUUID().toString().replace("-", "") + "." + type; + String fileUrl=FilePathEnum.lable.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + type; boolean deleteFile =true; @@ -265,7 +271,7 @@ label.setPicture(uploadFilePath); label.setUpdatetime(nowTime); - result = labelService.updateByPrimaryKeySelective(label); + result = updateByPrimaryKeySelective(label); } } @@ -294,7 +300,7 @@ label.setPicture(null); label.setUpdatetime(nowTime); // 鏇存柊鏁版嵁搴� - result = labelService.updateByPrimaryKey(label); + result = updateByPrimaryKey(label); } } @@ -353,5 +359,40 @@ return labelMapper.getByGoodsId(goodsId); } + @Override + public List<Label> addBatchByNames(String lableNames, AdminUser admin) throws LabelException{ + if (lableNames == null || lableNames.trim().length() == 0) { + return null; + } + + List<Label> listLabs = new ArrayList<Label>(); + // 绌烘牸闅斿紑 + String[] arrtitles = lableNames.split("\\s+"); + + for (String title : arrtitles) { + /* 閬嶅巻鏍囩鍚嶇О锛氭煡璇㈡暟鎹簱涓槸鍚﹀凡瀛樺湪 */ + List<Label> labels = selectByTitle(title.trim()); + if (labels != null && labels.size() > 0) { + Label label = labels.get(0); + listLabs.add(label); + } else { + // 鏂板 + Label label = new Label(); + label.setTitle(title);// 鍚嶇О + label.setEntrymode(Label.MODE_SYSTEM); // 鎵归噺褰曞叆 + label.setCreatetime(new Date()); + label.setUpdatetime(new Date()); + label.setCreateUser(admin); + label.setIosClick(0l); + label.setAndroidClick(0l); + insertSelective(label); + + listLabs.add(label); + } + } + + return listLabs; + } + } -- Gitblit v1.8.0