From 9a24f2802a3d6fe3e82c05e52f2880d65ad04dcf Mon Sep 17 00:00:00 2001 From: yujian <yujian> Date: 星期一, 29 四月 2019 08:59:47 +0800 Subject: [PATCH] Merge branch 'div_develop' into master_develop --- fanli/src/main/java/com/yeshi/fanli/service/impl/goods/GoodsClassServiceImpl.java | 209 +++++++++++++++------------------------------------ 1 files changed, 63 insertions(+), 146 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/GoodsClassServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/GoodsClassServiceImpl.java index 0e39efe..903e4a1 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/GoodsClassServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/goods/GoodsClassServiceImpl.java @@ -9,11 +9,10 @@ import java.util.UUID; import javax.annotation.Resource; -import javax.transaction.Transactional; -import org.apache.commons.beanutils.PropertyUtils; 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; @@ -22,25 +21,16 @@ import com.yeshi.fanli.dao.mybatis.GoodsClassMapper; import com.yeshi.fanli.entity.bus.clazz.GoodsClass; import com.yeshi.fanli.entity.bus.clazz.GoodsSubClass; -import com.yeshi.fanli.entity.bus.su.clazz.SuperGoodsClass; -import com.yeshi.fanli.entity.system.BusinessSystem; +import com.yeshi.fanli.entity.bus.clazz.TaoBaoClass; import com.yeshi.fanli.exception.GoodsClassException; -import com.yeshi.fanli.service.inter.config.BusinessSystemService; import com.yeshi.fanli.service.inter.goods.GoodsClassService; import com.yeshi.fanli.service.inter.goods.GoodsSubClassService; -import com.yeshi.fanli.service.inter.goods.SuperGoodsClassService; +import com.yeshi.fanli.service.inter.goods.TaoBaoClassService; import com.yeshi.fanli.service.inter.lable.LabelClassService; import com.yeshi.fanli.util.StringUtil; -import com.yeshi.fanli.util.Utils; @Service public class GoodsClassServiceImpl implements GoodsClassService { - - @Resource - private BusinessSystemService businessSystemService; - - @Resource - private SuperGoodsClassService superGoodsClassService; @Resource private GoodsClassMapper goodsClassMapper; @@ -51,6 +41,9 @@ @Resource private LabelClassService labelClassService; + @Resource + private TaoBaoClassService taoBaoClassService; + public GoodsClass getGoodsClass(long id) { return goodsClassMapper.selectByPrimaryKey(id); @@ -91,66 +84,15 @@ @Override - public int getCount(String platform, String packages, final String key) { + public List<GoodsClass> listquery() throws Exception{ - Long systemId = null; - - platform = Utils.getMap().get(platform); - - BusinessSystem system = businessSystemService.getBusinessSystem(platform, packages); - if (system != null) { - systemId = system.getId(); - } - ; - return goodsClassMapper.countByName(key, systemId); - } + List<GoodsClass> list = goodsClassMapper.getGoodsClassAll(); + + if (list != null && list.size() == 0) { + return list; + } - - @Override - public List<GoodsClass> queryAll(String platform, String packages) throws Exception{ - - List<BusinessSystem> defultList = businessSystemService.getBusinessSystems(); - - platform = Utils.getMap().get(platform); - BusinessSystem system = businessSystemService.getBusinessSystem(platform, packages); - - List<GoodsClass> goodsClassList = new ArrayList<GoodsClass>(); - List<SuperGoodsClass> superGoodsClassList = null; - List<Long> gcIdList = new ArrayList<Long>(); - - if (system == null) { - - goodsClassList = goodsClassMapper.getGoodsClassAll(); - - if (goodsClassList == null || goodsClassList.size() == 0) { - return null; - } - - /* 瀛樻斁绫诲埆id闆嗗悎 */ - for (GoodsClass rs : goodsClassList) { - gcIdList.add(rs.getId()); - } - - } else if (system != null) { - superGoodsClassList = superGoodsClassService.getSuperGoodsClassBySystemId(system.getId()); - - if (goodsClassList == null || goodsClassList.size() == 0) { - return null; - } - - for (SuperGoodsClass superGoodsClass : superGoodsClassList) { - GoodsClass goodsClass = superGoodsClass.getGoodsClass(); - goodsClassList.add(goodsClass); - gcIdList.add(goodsClass.getId()); - } - - } - - /* 鏍规嵁绫诲埆 id 鏌ヨ鍏宠仈绯荤粺鏁版嵁 */ - superGoodsClassList = superGoodsClassService.getSuperGoodsClasss(gcIdList); - - for (GoodsClass gclass : goodsClassList) { - + for (GoodsClass gclass : list) { Long iosClick = gclass.getIosClick(); Long androidClick = gclass.getAndroidClick(); @@ -164,6 +106,7 @@ gclass.setCountClick(0l); } + // 鍙傛暟澶勭悊 String searchParam = gclass.getSearchParam(); if (searchParam == null) { gclass.setSearchParam(""); @@ -171,50 +114,28 @@ gclass.setSearchParam(searchParam); } - + // 鏍囩 int countlabel = labelClassService.getCountQueryByClassId(gclass.getId()); gclass.setCountlabel(countlabel); - - List<Long> gList = new ArrayList<Long>(); - if (superGoodsClassList != null && superGoodsClassList.size() > 0) { - for (SuperGoodsClass srs : superGoodsClassList) { - - long rsId = srs.getGoodsClass().getId(); - - if (gclass.getId() == rsId) { - BusinessSystem gsystem = srs.getSystem(); - gList.add(gsystem.getId()); - } + + + List<TaoBaoClass> listTB = taoBaoClassService.listBySystemCid(0, Integer.MAX_VALUE, gclass.getId()); + if (listTB == null || listTB.size() == 0) { + gclass.setTaobaoCids(""); + } else { + String taobaoCids = ""; + for (TaoBaoClass taoBaoClass: listTB) { + taobaoCids = taobaoCids + taoBaoClass.getCategoryName() + "-" + taoBaoClass.getCategoryId() + ","; } + + if (!StringUtil.isNullOrEmpty(taobaoCids)){ + taobaoCids = taobaoCids.substring(0, taobaoCids.length()-1); + } + gclass.setTaobaoCids(taobaoCids); } - List<BusinessSystem> newList = new ArrayList<BusinessSystem>(); - // 鏄惁鏈夊叧鑱旂郴缁熼�夐」 - for (BusinessSystem dsystem : defultList) { - - BusinessSystem newsystem = new BusinessSystem(); - - PropertyUtils.copyProperties(newsystem, dsystem); - newsystem.setCheck(0); - - if (gList != null && gList.size() > 0) { - Long did = newsystem.getId(); - for (Long gid : gList) { - if (gid == did) { - newsystem.setCheck(1); - } - } - } - - newList.add(newsystem); - } - - gclass.setSystemList(newList); - } - - return goodsClassList; - + return list; } public List<GoodsClass> getGoodsClassAll() { @@ -223,13 +144,13 @@ @Override + @Transactional public void saveObject(MultipartFile file, GoodsClass record) throws GoodsClassException, Exception{ String name = record.getName(); if (name == null || name.trim().length() == 0) { throw new GoodsClassException(1, "鍒嗙被鍚嶇О涓嶈兘涓虹┖"); } - // 鍥剧墖涓婁紶 String picture = null; @@ -238,10 +159,10 @@ } String params = record.getSearchParam(); - if (params== null || params.trim().length() == 0 || "null".equalsIgnoreCase(params)) { + if (params == null || params.trim().length() == 0 || "null".equalsIgnoreCase(params)) { record.setSearchParam(null); - } else { - record.setSearchParam(params); + } else if (!StringUtil.isJson(params)) { + throw new GoodsClassException(1, "绛涢�夋潯浠堕潪JSON鏍煎紡"); } @@ -251,8 +172,13 @@ record.setPicture(picture); record.setIosClick(0L); record.setAndroidClick(0L); - record.setCreatetime(java.lang.System.currentTimeMillis()); + + Integer state = record.getState(); + if (state == null) { + record.setState(0); + } + if (params== null || params.trim().length() == 0 || "null".equalsIgnoreCase(params)) { // 鎼滅储鏉′欢:鏈夊埜銆佸湪鍞环20-200銆佺墰鐨櫍杞诲井 @@ -264,17 +190,6 @@ record.setOrderby(maxOrder + 1); goodsClassMapper.insert(record); - - // 榛樿鎵�鏈夌郴缁熶娇鐢� - List<BusinessSystem> listSystems = businessSystemService.getBusinessSystems(); - if (listSystems != null && listSystems.size() > 0) { - for(BusinessSystem businessSystem: listSystems) { - SuperGoodsClass superGoodsClass = new SuperGoodsClass(); - superGoodsClass.setGoodsClass(record);; - superGoodsClass.setSystem(businessSystem); - superGoodsClassService.insertSelective(superGoodsClass); - } - } } else { // 淇敼 @@ -297,6 +212,12 @@ record.setAndroidClick(resultObj.getAndroidClick()); record.setCreatetime(resultObj.getCreatetime()); goodsClassMapper.updateByPrimaryKey(record); + } + + // 淇濆瓨娣樺疂鍟嗗搧鍒嗙被id + String taobaoCids = record.getTaobaoCids(); + if (!StringUtil.isNullOrEmpty(taobaoCids) && !"null".equalsIgnoreCase(taobaoCids)) { + taoBaoClassService.save(record.getId(), taobaoCids); } } @@ -332,9 +253,6 @@ COSManager.getInstance().deleteFile(picture); } } - - - @Override @@ -389,29 +307,17 @@ } @Override - @Cacheable(value="classCache",key="'getListClassCache-'+#systemId") - public List<GoodsClass> getListClassCache(Long systemId) throws Exception { - List<SuperGoodsClass> superGoodsClassList = superGoodsClassService.getSuperGoodsClassBySystemId(systemId); - - if (superGoodsClassList == null || superGoodsClassList.size() == 0) { - return null; - } - - List<GoodsClass> goodsClassList = new ArrayList<GoodsClass>(); - for (SuperGoodsClass superGoodsClass : superGoodsClassList) { - GoodsClass goodsClass = superGoodsClass.getGoodsClass(); - goodsClassList.add(goodsClass); - } - - return goodsClassList; + @Cacheable(value="classCache",key="'getEffectiveClassCache'") + public List<GoodsClass> getEffectiveClassCache() throws Exception { + return goodsClassMapper.getEffectiveClass(); } @Override - @Cacheable(value="classCache",key="'getClassListAllCache-'+#systemId") - public List<Map<String, Object>> getClassListAllCache(Long systemId) throws Exception { + @Cacheable(value="classCache",key="'getClassListAllCache'+#changePicture") + public List<Map<String, Object>> getClassListAllCache(boolean changePicture) throws Exception { - List<GoodsClass> goodsClassList = goodsClassMapper.listGoodsClassBySystemId(systemId); + List<GoodsClass> goodsClassList = goodsClassMapper.getEffectiveClass(); if (goodsClassList == null || goodsClassList.size() == 0) { return null; } @@ -436,10 +342,21 @@ GoodsSubClass goodsSubClass = iterator.next(); GoodsClass goodsClassInner = goodsSubClass.getRootClass(); if (goodsClass.getId() == goodsClassInner.getId()) { + + // 1.5.3鏂扮増鍥剧墖鏇挎崲 + if (changePicture) { + String pictureSecond = goodsSubClass.getPictureSecond(); + if (pictureSecond != null && pictureSecond.trim().length() > 0) { + goodsSubClass.setPicture(pictureSecond); + } + } + // 瀵瑰簲涓嬪瓙鍒嗙被 subClassList.add(goodsSubClass); iterator.remove(); } + + } } -- Gitblit v1.8.0