Merge branch 'master' into dev_20190130_import
Showing
8 changed files
with
171 additions
and
1 deletions
1 | +package com.yoho.ufo.restapi; | ||
2 | + | ||
3 | +import com.yoho.quartz.job.YhJob; | ||
4 | +import com.yoho.ufo.service.model.*; | ||
5 | +import com.yoho.ufo.service.model.ApiResponse; | ||
6 | +import org.springframework.beans.BeansException; | ||
7 | +import org.springframework.context.ApplicationContext; | ||
8 | +import org.springframework.context.ApplicationContextAware; | ||
9 | +import org.springframework.stereotype.Controller; | ||
10 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
11 | +import org.springframework.web.bind.annotation.RequestParam; | ||
12 | +import org.springframework.web.bind.annotation.ResponseBody; | ||
13 | + | ||
14 | +/** | ||
15 | + * Created by li.ma on 2019/2/1. | ||
16 | + */ | ||
17 | +@Controller | ||
18 | +@RequestMapping("/scheduled") | ||
19 | +public class ScheduledManualController implements ApplicationContextAware{ | ||
20 | + private ApplicationContext applicationContext; | ||
21 | + | ||
22 | + @Override | ||
23 | + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { | ||
24 | + this.applicationContext = applicationContext; | ||
25 | + } | ||
26 | + | ||
27 | + @RequestMapping(value = "/scheduledManual") | ||
28 | + @ResponseBody | ||
29 | + public ApiResponse scheduledManual(@RequestParam(name = "scheduledName",required = true) String scheduledName) { | ||
30 | + | ||
31 | + YhJob jobObject = applicationContext.getBean(scheduledName, YhJob.class); | ||
32 | + jobObject.process(null); | ||
33 | + return new ApiResponse(200, "处理成功", null); | ||
34 | + } | ||
35 | +} |
@@ -4,6 +4,7 @@ import java.util.List; | @@ -4,6 +4,7 @@ import java.util.List; | ||
4 | 4 | ||
5 | import org.apache.ibatis.annotations.Param; | 5 | import org.apache.ibatis.annotations.Param; |
6 | 6 | ||
7 | +import com.yoho.ufo.dal.model.HiddenSkup; | ||
7 | import com.yoho.ufo.dal.model.StoragePrice; | 8 | import com.yoho.ufo.dal.model.StoragePrice; |
8 | 9 | ||
9 | public interface StoragePriceMapper { | 10 | public interface StoragePriceMapper { |
@@ -56,4 +57,6 @@ public interface StoragePriceMapper { | @@ -56,4 +57,6 @@ public interface StoragePriceMapper { | ||
56 | int selectStoragePriceCountBySellerUid(@Param("storagePrice") StoragePrice storagePrice, @Param("list") List<Integer> sellerUid); | 57 | int selectStoragePriceCountBySellerUid(@Param("storagePrice") StoragePrice storagePrice, @Param("list") List<Integer> sellerUid); |
57 | 58 | ||
58 | List<StoragePrice> selectStoragePriceListBySellerUid(@Param("storagePrice") StoragePrice storagePrice, @Param("start") int startIndex, @Param("rows") int rows, @Param("list") List<Integer> sellerUid); | 59 | List<StoragePrice> selectStoragePriceListBySellerUid(@Param("storagePrice") StoragePrice storagePrice, @Param("start") int startIndex, @Param("rows") int rows, @Param("list") List<Integer> sellerUid); |
60 | + | ||
61 | + List<HiddenSkup> selectHiddenSkup(); | ||
59 | } | 62 | } |
1 | +package com.yoho.ufo.dal.model; | ||
2 | + | ||
3 | +import com.alibaba.fastjson.JSONObject; | ||
4 | + | ||
5 | +public class HiddenSkup { | ||
6 | + | ||
7 | + private Integer sellerUid; | ||
8 | + | ||
9 | + private int skupNum; | ||
10 | + | ||
11 | + public Integer getSellerUid() { | ||
12 | + return sellerUid; | ||
13 | + } | ||
14 | + | ||
15 | + public void setSellerUid(Integer sellerUid) { | ||
16 | + this.sellerUid = sellerUid; | ||
17 | + } | ||
18 | + | ||
19 | + public int getSkupNum() { | ||
20 | + return skupNum; | ||
21 | + } | ||
22 | + | ||
23 | + public void setSkupNum(int skupNum) { | ||
24 | + this.skupNum = skupNum; | ||
25 | + } | ||
26 | + | ||
27 | + @Override | ||
28 | + public String toString() { | ||
29 | + return JSONObject.toJSONString(this); | ||
30 | + } | ||
31 | +} |
@@ -257,5 +257,17 @@ | @@ -257,5 +257,17 @@ | ||
257 | </foreach> | 257 | </foreach> |
258 | order by sp.id desc limit #{start},#{rows} | 258 | order by sp.id desc limit #{start},#{rows} |
259 | </select> | 259 | </select> |
260 | + | ||
261 | + <resultMap id="HiddenSkupMap" type="com.yoho.ufo.dal.model.HiddenSkup"> | ||
262 | + <result column="seller_uid" jdbcType="INTEGER" property="sellerUid"/> | ||
263 | + <result column="skup_num" jdbcType="INTEGER" property="skupNum"/> | ||
264 | + </resultMap> | ||
265 | + | ||
266 | + <select id="selectHiddenSkup" resultMap="HiddenSkupMap"> | ||
267 | + select t2.seller_uid as seller_uid, count(t2.skup) as skup_num from storage t1, storage_price t2 | ||
268 | + where t1.id=t2.storage_id and t2.status=1 and t1.suggest_high_price is not null and t2.price > t1.suggest_high_price | ||
269 | + group by t2.seller_uid | ||
270 | + having skup_num >0; | ||
271 | + </select> | ||
260 | 272 | ||
261 | </mapper> | 273 | </mapper> |
@@ -51,5 +51,10 @@ | @@ -51,5 +51,10 @@ | ||
51 | <groupId>org.mybatis</groupId> | 51 | <groupId>org.mybatis</groupId> |
52 | <artifactId>mybatis-spring</artifactId> | 52 | <artifactId>mybatis-spring</artifactId> |
53 | </dependency> | 53 | </dependency> |
54 | + <dependency> | ||
55 | + <groupId>com.yoho.dsf</groupId> | ||
56 | + <artifactId>yoho-message-sdk</artifactId> | ||
57 | + <version>1.1.2-SNAPSHOT</version> | ||
58 | + </dependency> | ||
54 | </dependencies> | 59 | </dependencies> |
55 | </project> | 60 | </project> |
@@ -15,4 +15,6 @@ public interface IChannelSkuCompareService { | @@ -15,4 +15,6 @@ public interface IChannelSkuCompareService { | ||
15 | int updateSuggestRate(ChannelSkuCompareReq req); | 15 | int updateSuggestRate(ChannelSkuCompareReq req); |
16 | 16 | ||
17 | void synChannelSkuCompare(); | 17 | void synChannelSkuCompare(); |
18 | + | ||
19 | + void noticeSellerHiddenSkup(); | ||
18 | } | 20 | } |
@@ -16,8 +16,10 @@ import org.springframework.stereotype.Service; | @@ -16,8 +16,10 @@ import org.springframework.stereotype.Service; | ||
16 | 16 | ||
17 | import com.alibaba.fastjson.JSONException; | 17 | import com.alibaba.fastjson.JSONException; |
18 | import com.alibaba.fastjson.JSONObject; | 18 | import com.alibaba.fastjson.JSONObject; |
19 | -import com.yoho.core.common.utils.DateUtil; | 19 | +import com.yoho.core.config.ConfigReader; |
20 | import com.yoho.error.exception.ServiceException; | 20 | import com.yoho.error.exception.ServiceException; |
21 | +import com.yoho.message.sdk.common.model.SendMessageRspBo; | ||
22 | +import com.yoho.message.sdk.service.ufo.IUFOSendService; | ||
21 | import com.yoho.ufo.dal.ChannelSkuCompareMapper; | 23 | import com.yoho.ufo.dal.ChannelSkuCompareMapper; |
22 | import com.yoho.ufo.dal.GoodsMapper; | 24 | import com.yoho.ufo.dal.GoodsMapper; |
23 | import com.yoho.ufo.dal.ProductMapper; | 25 | import com.yoho.ufo.dal.ProductMapper; |
@@ -25,6 +27,7 @@ import com.yoho.ufo.dal.StorageMapper; | @@ -25,6 +27,7 @@ import com.yoho.ufo.dal.StorageMapper; | ||
25 | import com.yoho.ufo.dal.StoragePriceMapper; | 27 | import com.yoho.ufo.dal.StoragePriceMapper; |
26 | import com.yoho.ufo.dal.UfoSizeMapper; | 28 | import com.yoho.ufo.dal.UfoSizeMapper; |
27 | import com.yoho.ufo.dal.model.Goods; | 29 | import com.yoho.ufo.dal.model.Goods; |
30 | +import com.yoho.ufo.dal.model.HiddenSkup; | ||
28 | import com.yoho.ufo.dal.model.Product; | 31 | import com.yoho.ufo.dal.model.Product; |
29 | import com.yoho.ufo.dal.model.Storage; | 32 | import com.yoho.ufo.dal.model.Storage; |
30 | import com.yoho.ufo.dal.model.StoragePrice; | 33 | import com.yoho.ufo.dal.model.StoragePrice; |
@@ -65,6 +68,12 @@ public class ChannelSkuCompareServiceImpl implements IChannelSkuCompareService, | @@ -65,6 +68,12 @@ public class ChannelSkuCompareServiceImpl implements IChannelSkuCompareService, | ||
65 | @Autowired | 68 | @Autowired |
66 | private GoodsMapper goodsMapper; | 69 | private GoodsMapper goodsMapper; |
67 | 70 | ||
71 | + @Autowired | ||
72 | + private ConfigReader configReader; | ||
73 | + | ||
74 | + @Autowired | ||
75 | + private IUFOSendService ufoSendService; | ||
76 | + | ||
68 | private static final int CHANNEL_SKU_COMPARE_ABNORMAL = 1; | 77 | private static final int CHANNEL_SKU_COMPARE_ABNORMAL = 1; |
69 | 78 | ||
70 | private static final int CHANNEL_SKU_COMPARE_NORMAL = 0; | 79 | private static final int CHANNEL_SKU_COMPARE_NORMAL = 0; |
@@ -198,6 +207,41 @@ public class ChannelSkuCompareServiceImpl implements IChannelSkuCompareService, | @@ -198,6 +207,41 @@ public class ChannelSkuCompareServiceImpl implements IChannelSkuCompareService, | ||
198 | LOGGER.info("synChannelSkuCompare end"); | 207 | LOGGER.info("synChannelSkuCompare end"); |
199 | } | 208 | } |
200 | 209 | ||
210 | + @Override | ||
211 | + public void noticeSellerHiddenSkup() { | ||
212 | + List<HiddenSkup> list = storagePriceMapper.selectHiddenSkup(); | ||
213 | + List<Integer> uidList = list.stream().map(HiddenSkup::getSellerUid).collect(Collectors.toList()); | ||
214 | + if(CollectionUtils.isEmpty(uidList)) { | ||
215 | + return; | ||
216 | + } | ||
217 | + //去除不需要PUSH的uid | ||
218 | + List<Integer> noPushUidList = getNoPushUidList(); | ||
219 | + uidList.removeAll(noPushUidList); | ||
220 | + | ||
221 | + Map<Integer, Integer> sellerUidSkupNumMap = list.stream().collect(Collectors.toMap(HiddenSkup::getSellerUid, HiddenSkup::getSkupNum)); | ||
222 | + //PUSH消息 | ||
223 | + for(Integer uid : uidList) { | ||
224 | + SendMessageRspBo bo = ufoSendService.sendAdjustPrice(String.valueOf(uid), sellerUidSkupNumMap.get(uid)); | ||
225 | + LOGGER.info("push uid is {}, skupNum is {}, result is {}", uid, sellerUidSkupNumMap.get(uid), bo); | ||
226 | + } | ||
227 | + } | ||
228 | + | ||
229 | + private List<Integer> getNoPushUidList(){ | ||
230 | + String noPushUidStr = configReader.getString("ufo.hiddenSkup.noPushUid", ""); | ||
231 | + LOGGER.info("noPushUid is {}", noPushUidStr); | ||
232 | + if(StringUtils.isEmpty(noPushUidStr)) { | ||
233 | + return Lists.newArrayList(); | ||
234 | + } | ||
235 | + | ||
236 | + String[] noPushUidArray = noPushUidStr.split(","); | ||
237 | + List<Integer> noPushUidList = Lists.newArrayList(); | ||
238 | + for(int i=0; i < noPushUidArray.length; i++) { | ||
239 | + noPushUidList.add(Integer.parseInt(noPushUidArray[i])); | ||
240 | + } | ||
241 | + | ||
242 | + return noPushUidList; | ||
243 | + } | ||
244 | + | ||
201 | private void dealSynChannelSkuCompareData(ChannelSkuCompareReq req) { | 245 | private void dealSynChannelSkuCompareData(ChannelSkuCompareReq req) { |
202 | List<ChannelSkuCompare> cscList = channelSkuCompareMapper.selectByCondition(req); | 246 | List<ChannelSkuCompare> cscList = channelSkuCompareMapper.selectByCondition(req); |
203 | List<Integer> productIdList = CollectionUtil.map(cscList, ChannelSkuCompare::getProductId); | 247 | List<Integer> productIdList = CollectionUtil.map(cscList, ChannelSkuCompare::getProductId); |
product/src/main/java/com/yoho/ufo/service/scheduled/ScheduledNoticeSellerHiddenSkup.java
0 → 100644
1 | +package com.yoho.ufo.service.scheduled; | ||
2 | + | ||
3 | +import org.slf4j.Logger; | ||
4 | +import org.slf4j.LoggerFactory; | ||
5 | +import org.springframework.beans.factory.annotation.Autowired; | ||
6 | +import org.springframework.stereotype.Service; | ||
7 | + | ||
8 | +import com.yoho.quartz.annotation.JobType; | ||
9 | +import com.yoho.quartz.annotation.MisfiredPolicy; | ||
10 | +import com.yoho.quartz.annotation.YhJobDef; | ||
11 | +import com.yoho.quartz.domain.JobProcessResult; | ||
12 | +import com.yoho.quartz.domain.JobResultCode; | ||
13 | +import com.yoho.quartz.job.YhJob; | ||
14 | +import com.yoho.ufo.service.IChannelSkuCompareService; | ||
15 | + | ||
16 | +/** | ||
17 | + * 通知卖家有隐藏的Skup | ||
18 | + * @author caoyan | ||
19 | + * | ||
20 | + */ | ||
21 | +@Service(value="scheduledNoticeSellerHiddenSkup") | ||
22 | +@YhJobDef(desc = "定时通知卖家有隐藏skup", jobName = "scheduledNoticeSellerHiddenSkup", cron = "0 0 12,20 * * ?", misfiredPolicy = MisfiredPolicy.CRON_DO_NOTHING, | ||
23 | +jobType = JobType.CRON, jobGroup = "ufoPlatform", needUpdate=true) | ||
24 | +public class ScheduledNoticeSellerHiddenSkup implements YhJob{ | ||
25 | + private static final Logger LOGGER = LoggerFactory.getLogger("scheduledLog"); | ||
26 | + | ||
27 | + @Autowired | ||
28 | + private IChannelSkuCompareService channelSkuCompareService; | ||
29 | + | ||
30 | + public JobProcessResult process(String jobContext) { | ||
31 | + LOGGER.info("scheduledNoticeSellerHiddenSkup begin."); | ||
32 | + JobProcessResult result = new JobProcessResult(); | ||
33 | + channelSkuCompareService.noticeSellerHiddenSkup(); | ||
34 | + result.setJobResultCode(JobResultCode.SUCCESS); | ||
35 | + return result; | ||
36 | + } | ||
37 | + | ||
38 | +} |
-
Please register or login to post a comment