From 6fdcc0c26dd33e87a024a69ed635d9aedb59cad6 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 07 一月 2020 12:02:50 +0800 Subject: [PATCH] 订单搜索引擎增量更新 --- fanli/src/main/java/com/yeshi/fanli/service/impl/user/integral/IntegralTaskRecordServiceImpl.java | 45 ++++++++++++++++++++------------------------- 1 files changed, 20 insertions(+), 25 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/integral/IntegralTaskRecordServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/integral/IntegralTaskRecordServiceImpl.java index 7351ed1..c56924e 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/integral/IntegralTaskRecordServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/integral/IntegralTaskRecordServiceImpl.java @@ -16,11 +16,8 @@ import org.springframework.transaction.annotation.Transactional; import org.yeshi.utils.DateUtil; -import com.aliyun.openservices.ons.api.Message; import com.aliyun.openservices.ons.api.Producer; import com.yeshi.fanli.dao.mybatis.integral.IntegralTaskRecordMapper; -import com.yeshi.fanli.dto.mq.user.UserTopicTagEnum; -import com.yeshi.fanli.dto.mq.user.body.IntegralTaskMQMsg; import com.yeshi.fanli.dto.msg.MsgOtherRewardIntegralDTO; import com.yeshi.fanli.entity.bus.user.UserInfoExtra; import com.yeshi.fanli.entity.integral.IntegralDetail; @@ -39,10 +36,9 @@ import com.yeshi.fanli.service.inter.user.integral.IntegralTaskClassService; import com.yeshi.fanli.service.inter.user.integral.IntegralTaskRecordService; import com.yeshi.fanli.service.inter.user.integral.IntegralTaskService; +import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.TimeUtil; -import com.yeshi.fanli.util.rocketmq.MQMsgBodyFactory; -import com.yeshi.fanli.util.rocketmq.MQTopicName; @Service public class IntegralTaskRecordServiceImpl implements IntegralTaskRecordService { @@ -82,6 +78,11 @@ return integralTaskRecordMapper.countFinished(uid, cid, dateType); } + @Override + public void invalidGoldCoin() { + integralTaskRecordMapper.invalidGoldCoin(); + } + @Override public void finishedTask(long uid, long cid, long taskId, int goldCoin) { IntegralTaskRecord taskRecord = new IntegralTaskRecord(); @@ -239,7 +240,7 @@ // 宸查鍙� Integer state = record.getState(); - if (state != null && state == 1) + if (state != null && state != 0) continue; if (addDetail(uid, record)) @@ -252,7 +253,7 @@ return totalGoldCoin + (userInfoExtra.getGoldCoin() == null ? 0 : userInfoExtra.getGoldCoin()); } - @Transactional + @Transactional(rollbackFor = Exception.class) public boolean addDetail(Long uid, IntegralTaskRecord record) throws IntegralTaskRecordException { Long uid2 = record.getUid(); if (uid2 == null || uid.longValue() != uid2.longValue()) @@ -350,7 +351,7 @@ return integralTaskRecordMapper.countGetCountByTaskIdAndDay(taskId, uid, minTime, maxTime); } - @Transactional + @Transactional(rollbackFor = Exception.class) @Override public IntegralTaskRecord addRecord(IntegralTaskRecord record) throws IntegralTaskRecordException { if (record == null) @@ -359,21 +360,16 @@ if (record.getCid() == null || record.getTaskId() == null || record.getGoldCoin() == null || record.getState() == null || record.getUid() == null) throw new IntegralTaskRecordException(2, "鏁版嵁涓嶅畬鎴�"); - + Date date = new Date(); if (record.getCreateTime() == null) - record.setCreateTime(new Date()); + record.setCreateTime(date); if (record.getUpdateTime() == null) - record.setUpdateTime(new Date()); + record.setUpdateTime(date); + + // 璁剧疆鏈夋晥鏈� + record.setEndTime(DateUtil.plusDayDate(Constant.GOLD_COIN_VALID_DAYS, date)); integralTaskRecordMapper.insertSelective(record); - long count = integralTaskRecordMapper.getTotalGoldCoinByUid(record.getUid()); - if (count >= 200) {// 澶т簬200鍙戦�佹秷鎭� - IntegralTaskMQMsg msg = new IntegralTaskMQMsg(record.getUid(), count, new Date()); - Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.integralTaskFinish, - msg); - producer.send(message); - } - return record; } @@ -394,10 +390,6 @@ return integralTaskRecordMapper.listByUidAndTaskId(uid, taskId, (page - 1) * count, count); } - @Override - public long getTotalGoldCoinByUid(Long uid) { - return integralTaskRecordMapper.getTotalGoldCoinByUid(uid); - } @Async() @Override @@ -506,8 +498,11 @@ msgOther.setSource("棣栫瑪鍒嗕韩璁㈠崟锛岀郴缁熷鍔遍噾甯� "); msgOther.setExplain("棣栫瑪鍒嗕韩璁㈠崟寰楀埌鐨勫閲戜笉瓒�0.01鍏冩椂濂栧姳 "); } else { - msgOther.setSource(level + "绾ч槦鍛橀娆′笅鍗曪紝绯荤粺濂栧姳閲戝竵 "); - msgOther.setExplain("浠呮柊閭�璇烽槦鍛橀涓嬪崟浣犲緱鍒扮殑濂栭噾涓嶈冻0.01鍏冩椂濂栧姳 "); + if (level.equalsIgnoreCase("涓�") || level.equalsIgnoreCase("1")) + msgOther.setSource("鐩存帴绮変笣棣栨涓嬪崟锛岀郴缁熷鍔遍噾甯� "); + else + msgOther.setSource("闂存帴绮変笣棣栨涓嬪崟锛岀郴缁熷鍔遍噾甯� "); + msgOther.setExplain("浠呮柊閭�璇风矇涓濋涓嬪崟浣犲緱鍒扮殑濂栭噾涓嶈冻0.01鍏冩椂濂栧姳 "); } userOtherMsgNotificationService.firstOrderRewardMsg(uid, null, msgOther); } -- Gitblit v1.8.0