From 41aedac31eb4c5b9f7b98bacec18c45b3926d69c Mon Sep 17 00:00:00 2001 From: yujian <yujian@123.com> Date: 星期五, 27 九月 2019 16:57:54 +0800 Subject: [PATCH] 京东商品 券bug --- fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandInfoServiceImpl.java | 27 ++++++++++++++++++++++++--- 1 files changed, 24 insertions(+), 3 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandInfoServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandInfoServiceImpl.java index 513f76e..4c974af 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandInfoServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/brand/BrandInfoServiceImpl.java @@ -10,6 +10,7 @@ import javax.annotation.Resource; import org.springframework.cache.annotation.Cacheable; +import org.springframework.core.task.TaskExecutor; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; import org.yeshi.utils.tencentcloud.COSManager; @@ -68,12 +69,20 @@ @Resource private BrandShopCaheService brandShopCaheService; + @Resource(name = "taskExecutor") + private TaskExecutor executor; + + @Override public void saveObject(MultipartFile file, BrandInfo record) throws BrandInfoException { String name = record.getName(); - if (name == null || name.trim().length() == 0) + if (StringUtil.isNullOrEmpty(name)) throw new BrandInfoException(1, "鍚嶇О涓嶈兘涓虹┖"); + String searchKey = record.getSearchKey(); + if (StringUtil.isNullOrEmpty(searchKey)) + record.setSearchKey(name); + Integer state = record.getState(); if (state == null) record.setState(0); @@ -113,6 +122,17 @@ record.setCreateTime(resultObj.getCreateTime()); record.setUpdateTime(new Date()); brandInfoMapper.updateByPrimaryKey(record); + } + + if (state == 1) { + executor.execute(new Runnable() { + @Override + public void run() { + int goodsTotal = brandGoodsCaheService.addBrandGoods(record); + record.setGoodsTotal(goodsTotal); + brandInfoMapper.updateByPrimaryKeySelective(record); + } + }); } } @@ -212,8 +232,9 @@ return; for (BrandInfo brandInfo : list) { - String key = brandInfo.getName(); - if (StringUtil.isNullOrEmpty(key)) + String name = brandInfo.getName(); + String searchKey = brandInfo.getSearchKey(); + if (StringUtil.isNullOrEmpty(name) && StringUtil.isNullOrEmpty(searchKey)) continue; // 娣诲姞鍟嗗搧 -- Gitblit v1.8.0