From b6c37e4bc38db88a360d0f2c6099183f9bb75bdc Mon Sep 17 00:00:00 2001 From: yujian <yujian> Date: 星期一, 22 四月 2019 14:31:59 +0800 Subject: [PATCH] 券推送插入 --- fanli/src/main/java/com/yeshi/fanli/service/impl/goods/GoodsClassServiceImpl.java | 187 +++++++++------------------------------------- 1 files changed, 37 insertions(+), 150 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..4758c7c 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,14 @@ 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.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.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; @@ -91,66 +79,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 +101,7 @@ gclass.setCountClick(0l); } + // 鍙傛暟澶勭悊 String searchParam = gclass.getSearchParam(); if (searchParam == null) { gclass.setSearchParam(""); @@ -171,50 +109,11 @@ 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<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() { @@ -230,7 +129,6 @@ throw new GoodsClassException(1, "鍒嗙被鍚嶇О涓嶈兘涓虹┖"); } - // 鍥剧墖涓婁紶 String picture = null; if (file != null) { @@ -238,12 +136,11 @@ } 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鏍煎紡"); } - Long id = record.getId(); @@ -251,8 +148,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 +166,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 { // 淇敼 @@ -334,9 +225,6 @@ } - - - @Override public void uploadPicture(GoodsClass record, MultipartFile file) throws Exception { @@ -389,29 +277,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 +312,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