|
@@ -1,8 +1,13 @@
|
|
|
package com.seamew.lottery.infrastructure.repository;
|
|
|
|
|
|
+import com.seamew.lottery.common.Constants;
|
|
|
+import com.seamew.lottery.domain.activity.model.vo.DrawOrderVO;
|
|
|
+import com.seamew.lottery.domain.activity.model.vo.UserTakeActivityVO;
|
|
|
import com.seamew.lottery.domain.activity.repository.IUserTakeActivityRepository;
|
|
|
+import com.seamew.lottery.infrastructure.dao.IUserStrategyExportDao;
|
|
|
import com.seamew.lottery.infrastructure.dao.IUserTakeActivityCountDao;
|
|
|
import com.seamew.lottery.infrastructure.dao.IUserTakeActivityDao;
|
|
|
+import com.seamew.lottery.infrastructure.po.UserStrategyExport;
|
|
|
import com.seamew.lottery.infrastructure.po.UserTakeActivity;
|
|
|
import com.seamew.lottery.infrastructure.po.UserTakeActivityCount;
|
|
|
import org.springframework.stereotype.Component;
|
|
@@ -26,6 +31,9 @@ public class UserTakeActivityRepository implements IUserTakeActivityRepository {
|
|
|
@Resource
|
|
|
private IUserTakeActivityDao userTakeActivityDao;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private IUserStrategyExportDao userStrategyExportDao;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public int subtractionLeftCount(Long activityId, String activityName, Integer takeCount, Integer userTakeLeftCount, String uId, Date partakeDate) {
|
|
@@ -46,7 +54,7 @@ public class UserTakeActivityRepository implements IUserTakeActivityRepository {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void takeActivity(Long activityId, String activityName, Integer takeCount, Integer userTakeLeftCount, String uId, Date takeDate, Long takeId) {
|
|
|
+ public void takeActivity(Long activityId, String activityName, Long strategyId, Integer takeCount, Integer userTakeLeftCount, String uId, Date takeDate, Long takeId) {
|
|
|
UserTakeActivity userTakeActivity = new UserTakeActivity();
|
|
|
userTakeActivity.setUId(uId);
|
|
|
userTakeActivity.setTakeId(takeId);
|
|
@@ -58,10 +66,63 @@ public class UserTakeActivityRepository implements IUserTakeActivityRepository {
|
|
|
} else {
|
|
|
userTakeActivity.setTakeCount(takeCount - userTakeLeftCount + 1);
|
|
|
}
|
|
|
+ userTakeActivity.setStrategyId(strategyId);
|
|
|
+ userTakeActivity.setState(Constants.TaskState.NO_USED.getCode());
|
|
|
String uuid = uId + "_" + activityId + "_" + userTakeActivity.getTakeCount();
|
|
|
userTakeActivity.setUuid(uuid);
|
|
|
|
|
|
userTakeActivityDao.insert(userTakeActivity);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public int lockTackActivity(String uId, Long activityId, Long takeId) {
|
|
|
+ UserTakeActivity userTakeActivity = new UserTakeActivity();
|
|
|
+ userTakeActivity.setUId(uId);
|
|
|
+ userTakeActivity.setActivityId(activityId);
|
|
|
+ userTakeActivity.setTakeId(takeId);
|
|
|
+ return userTakeActivityDao.lockTackActivity(userTakeActivity);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void saveUserStrategyExport(DrawOrderVO drawOrder) {
|
|
|
+ UserStrategyExport userStrategyExport = new UserStrategyExport();
|
|
|
+ userStrategyExport.setUId(drawOrder.getUId());
|
|
|
+ userStrategyExport.setActivityId(drawOrder.getActivityId());
|
|
|
+ userStrategyExport.setOrderId(drawOrder.getOrderId());
|
|
|
+ userStrategyExport.setStrategyId(drawOrder.getStrategyId());
|
|
|
+ userStrategyExport.setStrategyMode(drawOrder.getStrategyMode());
|
|
|
+ userStrategyExport.setGrantType(drawOrder.getGrantType());
|
|
|
+ userStrategyExport.setGrantDate(drawOrder.getGrantDate());
|
|
|
+ userStrategyExport.setGrantState(drawOrder.getGrantState());
|
|
|
+ userStrategyExport.setAwardId(drawOrder.getAwardId());
|
|
|
+ userStrategyExport.setAwardType(drawOrder.getAwardType());
|
|
|
+ userStrategyExport.setAwardName(drawOrder.getAwardName());
|
|
|
+ userStrategyExport.setAwardContent(drawOrder.getAwardContent());
|
|
|
+ userStrategyExport.setUuid(String.valueOf(drawOrder.getOrderId()));
|
|
|
+
|
|
|
+ userStrategyExportDao.insert(userStrategyExport);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public UserTakeActivityVO queryNoConsumedTakeActivityOrder(Long activityId, String uId) {
|
|
|
+
|
|
|
+ UserTakeActivity userTakeActivity = new UserTakeActivity();
|
|
|
+ userTakeActivity.setUId(uId);
|
|
|
+ userTakeActivity.setActivityId(activityId);
|
|
|
+ UserTakeActivity noConsumedTakeActivityOrder = userTakeActivityDao.queryNoConsumedTakeActivityOrder(userTakeActivity);
|
|
|
+
|
|
|
+ // 未查询到符合的领取单,直接返回 NULL
|
|
|
+ if (null == noConsumedTakeActivityOrder) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ UserTakeActivityVO userTakeActivityVO = new UserTakeActivityVO();
|
|
|
+ userTakeActivityVO.setActivityId(noConsumedTakeActivityOrder.getActivityId());
|
|
|
+ userTakeActivityVO.setTakeId(noConsumedTakeActivityOrder.getTakeId());
|
|
|
+ userTakeActivityVO.setStrategyId(noConsumedTakeActivityOrder.getStrategyId());
|
|
|
+ userTakeActivityVO.setState(noConsumedTakeActivityOrder.getState());
|
|
|
+
|
|
|
+ return userTakeActivityVO;
|
|
|
+ }
|
|
|
+
|
|
|
}
|