Commit a1507fc5 a1507fc56ee5aa85848e03ceca241a6e2de62859 by xianghan@topdraw.cn

update

1 parent f80260a0
...@@ -51,8 +51,6 @@ public class CouponOperationServiceImpl implements CouponOperationService { ...@@ -51,8 +51,6 @@ public class CouponOperationServiceImpl implements CouponOperationService {
51 // 过期阀值(默认一个月) 51 // 过期阀值(默认一个月)
52 private static final Integer EXPIRE_FACTOR_DAY = 30; 52 private static final Integer EXPIRE_FACTOR_DAY = 30;
53 53
54
55
56 @Override 54 @Override
57 public void grantCouponThroughTempCoupon(List<TempCoupon> tempCouponList) { 55 public void grantCouponThroughTempCoupon(List<TempCoupon> tempCouponList) {
58 // 优惠券领取、使用历史记录表 56 // 优惠券领取、使用历史记录表
......
1 package com.topdraw.business.process.service.impl; 1 package com.topdraw.business.process.service.impl;
2 2
3 import com.topdraw.business.basicdata.coupon.service.CouponService;
4 import com.topdraw.business.basicdata.coupon.service.dto.CouponDTO;
3 import com.topdraw.business.basicdata.rights.history.domain.RightsHistory; 5 import com.topdraw.business.basicdata.rights.history.domain.RightsHistory;
4 import com.topdraw.business.basicdata.rights.history.service.RightsHistoryService; 6 import com.topdraw.business.basicdata.rights.history.service.RightsHistoryService;
5 import com.topdraw.business.basicdata.rights.service.RightsService; 7 import com.topdraw.business.basicdata.rights.service.RightsService;
...@@ -19,8 +21,6 @@ import org.springframework.stereotype.Service; ...@@ -19,8 +21,6 @@ import org.springframework.stereotype.Service;
19 import org.springframework.util.CollectionUtils; 21 import org.springframework.util.CollectionUtils;
20 import org.springframework.util.StringUtils; 22 import org.springframework.util.StringUtils;
21 23
22 import javax.annotation.Resource;
23 import java.sql.Timestamp;
24 import java.util.*; 24 import java.util.*;
25 import java.util.concurrent.*; 25 import java.util.concurrent.*;
26 26
...@@ -46,6 +46,8 @@ public class RightsOperationServiceImpl implements RightsOperationService { ...@@ -46,6 +46,8 @@ public class RightsOperationServiceImpl implements RightsOperationService {
46 ExpOperationService expOperationService; 46 ExpOperationService expOperationService;
47 @Autowired 47 @Autowired
48 PointsOperationService pointsOperationService; 48 PointsOperationService pointsOperationService;
49 @Autowired
50 CouponService couponService;
49 51
50 // @Autowired 52 // @Autowired
51 // ThreadPoolTaskExecutor threadPoolTaskExecutor; 53 // ThreadPoolTaskExecutor threadPoolTaskExecutor;
...@@ -107,7 +109,6 @@ public class RightsOperationServiceImpl implements RightsOperationService { ...@@ -107,7 +109,6 @@ public class RightsOperationServiceImpl implements RightsOperationService {
107 return rightsHistoryList; 109 return rightsHistoryList;
108 } 110 }
109 111
110
111 /** 112 /**
112 * 成长值发放,基于已获得的权益 113 * 成长值发放,基于已获得的权益
113 * @param tempExpList 权益列表 114 * @param tempExpList 权益列表
...@@ -117,7 +118,6 @@ public class RightsOperationServiceImpl implements RightsOperationService { ...@@ -117,7 +118,6 @@ public class RightsOperationServiceImpl implements RightsOperationService {
117 this.expOperationService.grantPointsThroughTempExp(tempExpList); 118 this.expOperationService.grantPointsThroughTempExp(tempExpList);
118 } 119 }
119 120
120
121 /** 121 /**
122 * 发放积分,基于已获得的权益 122 * 发放积分,基于已获得的权益
123 * 123 *
...@@ -130,7 +130,6 @@ public class RightsOperationServiceImpl implements RightsOperationService { ...@@ -130,7 +130,6 @@ public class RightsOperationServiceImpl implements RightsOperationService {
130 this.pointsOperationService.grantPointsThroughTempRightsList(tempPointsList); 130 this.pointsOperationService.grantPointsThroughTempRightsList(tempPointsList);
131 } 131 }
132 132
133
134 /** 133 /**
135 * 发放优惠券,基于已获得的权益 134 * 发放优惠券,基于已获得的权益
136 * 135 *
...@@ -142,8 +141,6 @@ public class RightsOperationServiceImpl implements RightsOperationService { ...@@ -142,8 +141,6 @@ public class RightsOperationServiceImpl implements RightsOperationService {
142 this.couponOperationService.grantCouponThroughTempCoupon(tempCouponList); 141 this.couponOperationService.grantCouponThroughTempCoupon(tempCouponList);
143 } 142 }
144 143
145
146
147 /** 144 /**
148 * 权益发放 145 * 权益发放
149 * @param tempRightsMap 146 * @param tempRightsMap
...@@ -229,8 +226,6 @@ public class RightsOperationServiceImpl implements RightsOperationService { ...@@ -229,8 +226,6 @@ public class RightsOperationServiceImpl implements RightsOperationService {
229 226
230 // 优惠券 227 // 优惠券
231 List<TempCoupon> tempCouponList = new ArrayList<>(); 228 List<TempCoupon> tempCouponList = new ArrayList<>();
232 List<TempExp> tempExpList = new ArrayList<>();
233 List<TempPoints> tempPointsList = new ArrayList<>();
234 229
235 for (RightsHistory right : rightsList) { 230 for (RightsHistory right : rightsList) {
236 Long rightId = right.getRightsId(); 231 Long rightId = right.getRightsId();
...@@ -240,63 +235,55 @@ public class RightsOperationServiceImpl implements RightsOperationService { ...@@ -240,63 +235,55 @@ public class RightsOperationServiceImpl implements RightsOperationService {
240 RightsDTO rightsDTO = this.getRights(rightId); 235 RightsDTO rightsDTO = this.getRights(rightId);
241 // 权益的实体类型 1:积分;2成长值;3优惠券 236 // 权益的实体类型 1:积分;2成长值;3优惠券
242 String type = rightsDTO.getEntityType(); 237 String type = rightsDTO.getEntityType();
243 // String code = rightsDTO.getCode();
244 Long expireTime = rightsDTO.getExpireTime(); 238 Long expireTime = rightsDTO.getExpireTime();
245 // Timestamp validTime = rightsDTO.getValidTime();
246
247 239
248 switch (type) { 240 switch (type) {
249 // 优惠券 241 // 优惠券
250 case "3": 242 case "1":
243 Long entityId = rightsDTO.getEntityId();
244 CouponDTO couponDTO = this.findCouponById(entityId);
245 if (Objects.nonNull(couponDTO)) {
251 TempCoupon tempCoupon = new TempCoupon(); 246 TempCoupon tempCoupon = new TempCoupon();
252 tempCoupon.setId(rightId); 247 tempCoupon.setId(couponDTO.getId());
253 tempCoupon.setMemberId(memberId); 248 tempCoupon.setMemberId(memberId);
254 tempCoupon.setUserId(userId); 249 tempCoupon.setUserId(userId);
255 tempCoupon.setRightsAmount(1); 250 tempCoupon.setRightsAmount(1);
256 tempCoupon.setRightsSendStrategy(0); 251 tempCoupon.setRightsSendStrategy(0);
252 tempCoupon.setCode(couponDTO.getCode());
257 if (Objects.nonNull(expireTime)) 253 if (Objects.nonNull(expireTime))
258 tempCoupon.setExpireTime(TimestampUtil.long2Timestamp(expireTime)); 254 tempCoupon.setExpireTime(TimestampUtil.long2Timestamp(expireTime));
259 tempCouponList.add(tempCoupon); 255 tempCouponList.add(tempCoupon);
256 }
260 break; 257 break;
261 // 成长值 258 // 观影券
262 case "2": 259 case "2":
263 TempExp tempExp = new TempExp();
264 tempExp.setId(rightId);
265 tempExp.setMemberId(memberId);
266 tempExp.setUserId(userId);
267 tempExp.setRightsAmount(1);
268 tempExp.setRightsSendStrategy(0);
269 tempExpList.add(tempExp);
270 break; 260 break;
271 // 积分 261 // 活动参与机会
272 case "1": 262 case "3":
273 TempPoints tempPoints = new TempPoints(); 263 break;
274 tempPoints.setId(rightId); 264
275 tempPoints.setMemberId(memberId); 265 default:
276 tempPoints.setUserId(userId);
277 tempPoints.setRightsAmount(1);
278 tempPoints.setRightsSendStrategy(0);
279 tempPointsList.add(tempPoints);
280 break; 266 break;
281 } 267 }
282 } 268 }
283 269
284 // TODO 其他
285
286 // 优惠券 270 // 优惠券
287 if (!CollectionUtils.isEmpty(tempCouponList)) 271 if (!CollectionUtils.isEmpty(tempCouponList))
288 map.put(RightType.COUPON,tempCouponList); 272 map.put(RightType.COUPON,tempCouponList);
289 // 成长值
290 /* if (!CollectionUtils.isEmpty(tempExpList))
291 map.put(RightType.EXP,tempExpList);*/
292 // 积分
293 /* if (!CollectionUtils.isEmpty(tempPointsList))
294 map.put(RightType.POINTS,tempPointsList);
295 */
296 return map; 273 return map;
297 } 274 }
298 275
299 /** 276 /**
277 * 获取优惠券信息
278 * @param id
279 * @return
280 */
281 private CouponDTO findCouponById(Long id) {
282 CouponDTO couponDTO = this.couponService.findById(id);
283 return couponDTO;
284 }
285
286 /**
300 * 权益详情 287 * 权益详情
301 * @param rightsId 288 * @param rightsId
302 * @return 289 * @return
......
1 package com.topdraw.business.process.service.impl; 1 package com.topdraw.business.process.service.impl;
2 2
3 import com.alibaba.fastjson.JSONObject; 3 import com.alibaba.fastjson.JSONObject;
4 import com.topdraw.business.basicdata.coupon.service.CouponService;
5 import com.topdraw.business.basicdata.coupon.service.dto.CouponDTO;
4 import com.topdraw.business.basicdata.rights.permanentrights.service.PermanentRightsService; 6 import com.topdraw.business.basicdata.rights.permanentrights.service.PermanentRightsService;
5 import com.topdraw.business.basicdata.rights.permanentrights.service.dto.PermanentRightsDTO; 7 import com.topdraw.business.basicdata.rights.permanentrights.service.dto.PermanentRightsDTO;
6 import com.topdraw.business.basicdata.rights.service.RightsService; 8 import com.topdraw.business.basicdata.rights.service.RightsService;
...@@ -64,6 +66,8 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -64,6 +66,8 @@ public class TaskOperationServiceImpl implements TaskOperationService {
64 TrTaskProgressService trTaskProgressService; 66 TrTaskProgressService trTaskProgressService;
65 @Autowired 67 @Autowired
66 PermanentRightsService permanentRightsService; 68 PermanentRightsService permanentRightsService;
69 @Autowired
70 CouponService couponService;
67 71
68 private static final Integer TASK_FINISH_STATUS = 1; 72 private static final Integer TASK_FINISH_STATUS = 1;
69 private static final Integer TASK_UNFINISH_STATUS = 2; 73 private static final Integer TASK_UNFINISH_STATUS = 2;
...@@ -330,9 +334,10 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -330,9 +334,10 @@ public class TaskOperationServiceImpl implements TaskOperationService {
330 * @param rightsSendStrategy 334 * @param rightsSendStrategy
331 * @return 335 * @return
332 */ 336 */
333 private TempCoupon tempCouponBuild(Long memberId ,Integer rightsAmount,Integer rightsSendStrategy,TempRights tempRights,String nickname){ 337 private TempCoupon tempCouponBuild(Long memberId ,Integer rightsAmount,Integer rightsSendStrategy,CouponDTO couponDTO,String nickname){
334 TempCoupon tempCoupon = new TempCoupon(); 338 TempCoupon tempCoupon = new TempCoupon();
335 BeanUtils.copyProperties(tempRights,tempCoupon); 339 BeanUtils.copyProperties(couponDTO,tempCoupon);
340 tempCoupon.setCode(couponDTO.getCode());
336 tempCoupon.setMemberId(memberId); 341 tempCoupon.setMemberId(memberId);
337 tempCoupon.setRightsAmount(rightsAmount); 342 tempCoupon.setRightsAmount(rightsAmount);
338 tempCoupon.setRightsSendStrategy(Objects.isNull(rightsSendStrategy) ? 0 : rightsSendStrategy); 343 tempCoupon.setRightsSendStrategy(Objects.isNull(rightsSendStrategy) ? 0 : rightsSendStrategy);
...@@ -426,9 +431,15 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -426,9 +431,15 @@ public class TaskOperationServiceImpl implements TaskOperationService {
426 String type = rightsDTO.getEntityType(); 431 String type = rightsDTO.getEntityType();
427 switch (type) { 432 switch (type) {
428 case "1": 433 case "1":
434 Long entityId = rightsDTO.getEntityId();
435 if (Objects.nonNull(entityId)) {
436 CouponDTO couponDTO = this.findCouponById(entityId);
437 if (Objects.nonNull(couponDTO)) {
429 // 优惠券 438 // 优惠券
430 TempCoupon tempCoupon = this.tempCouponBuild(memberId,rightsAmount,rightsSendStrategy,tempRights,nickname); 439 TempCoupon tempCoupon = this.tempCouponBuild(memberId, rightsAmount, rightsSendStrategy, couponDTO, nickname);
431 tempCouponList.add(tempCoupon); 440 tempCouponList.add(tempCoupon);
441 }
442 }
432 break; 443 break;
433 default: 444 default:
434 break; 445 break;
...@@ -437,6 +448,16 @@ public class TaskOperationServiceImpl implements TaskOperationService { ...@@ -437,6 +448,16 @@ public class TaskOperationServiceImpl implements TaskOperationService {
437 } 448 }
438 449
439 /** 450 /**
451 * 获取优惠券信息
452 * @param id
453 * @return
454 */
455 private CouponDTO findCouponById(Long id) {
456 CouponDTO couponDTO = this.couponService.findById(id);
457 return couponDTO;
458 }
459
460 /**
440 * 461 *
441 * @param rightsId 462 * @param rightsId
442 * @return 463 * @return
......
...@@ -29,7 +29,7 @@ public class TaskOperationControllerTest extends BaseTest { ...@@ -29,7 +29,7 @@ public class TaskOperationControllerTest extends BaseTest {
29 DataSyncMsg dataSyncMsg = new DataSyncMsg(); 29 DataSyncMsg dataSyncMsg = new DataSyncMsg();
30 dataSyncMsg.setEventType(EventType.VIEWING.name()); 30 dataSyncMsg.setEventType(EventType.VIEWING.name());
31 DataSyncMsg.MsgData msgData = new DataSyncMsg.MsgData(); 31 DataSyncMsg.MsgData msgData = new DataSyncMsg.MsgData();
32 msgData.setEvent(2); 32 msgData.setEvent(6);
33 msgData.setRemarks("remark"); 33 msgData.setRemarks("remark");
34 msgData.setMemberId(3L); 34 msgData.setMemberId(3L);
35 msgData.setDeviceType(2); 35 msgData.setDeviceType(2);
......