|
@@ -22,6 +22,7 @@ import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
import com.ym.mec.common.tenant.TenantContextHolder;
|
|
|
import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
|
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
|
+import com.ym.mec.util.date.DateUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -79,6 +80,10 @@ public class VipGroupActivityServiceImpl extends BaseServiceImpl<Integer, VipGro
|
|
|
private StudentDao studentDao;
|
|
|
@Autowired
|
|
|
private TenantConfigService tenantConfigService;
|
|
|
+ @Autowired
|
|
|
+ private LuckDrawCountService luckDrawCountService;
|
|
|
+ @Autowired
|
|
|
+ private TempBuyDoubleElevenUserLogDao tempBuyDoubleElevenUserLogDao;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Integer, VipGroupActivity> getDAO() {
|
|
@@ -596,20 +601,10 @@ public class VipGroupActivityServiceImpl extends BaseServiceImpl<Integer, VipGro
|
|
|
}
|
|
|
if (studentPaymentOrder.getStatus() == DealStatusEnum.SUCCESS) {
|
|
|
Student student = studentDao.get(studentPaymentOrder.getUserId());
|
|
|
- String activeConfig = sysConfigDao.findConfigValue("2022_double_eleven_give_config");
|
|
|
- List<SysConfigJsonDto> cloud2022ActivityDtos = JSONArray.parseArray(activeConfig, SysConfigJsonDto.class);
|
|
|
- List<SysConfigJsonDto> activityDtos = cloud2022ActivityDtos.stream().
|
|
|
- filter(e -> Arrays.stream(e.getKey().split(",")).collect(Collectors.toList()).
|
|
|
- contains(studentPaymentOrder.getActivityId())).collect(Collectors.toList());
|
|
|
- if(!CollectionUtils.isEmpty(activityDtos)){
|
|
|
- SysConfigJsonDto jsonDto = activityDtos.get(0);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
+
|
|
|
+ this.doubleElevenGive(studentPaymentOrder);
|
|
|
|
|
|
+
|
|
|
studentPaymentOrderService.activityGive(Integer.parseInt(studentPaymentOrder.getActivityId()), studentPaymentOrder,
|
|
|
null, null, student.getTeacherId());
|
|
|
|
|
@@ -625,6 +620,33 @@ public class VipGroupActivityServiceImpl extends BaseServiceImpl<Integer, VipGro
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ private void doubleElevenGive(StudentPaymentOrder studentPaymentOrder){
|
|
|
+ String activeConfig = sysConfigDao.findConfigValue("2022_double_eleven_give_config");
|
|
|
+ List<SysConfigJsonDto> cloud2022ActivityDtos = JSONArray.parseArray(activeConfig, SysConfigJsonDto.class);
|
|
|
+ List<SysConfigJsonDto> activityDtos = cloud2022ActivityDtos.stream().
|
|
|
+ filter(e -> Arrays.stream(e.getKey().split(",")).collect(Collectors.toList()).
|
|
|
+ contains(studentPaymentOrder.getActivityId())).collect(Collectors.toList());
|
|
|
+ if(!CollectionUtils.isEmpty(activityDtos)){
|
|
|
+ SysConfigJsonDto jsonDto = activityDtos.get(0);
|
|
|
+
|
|
|
+ String giveStartTime = sysConfigDao.findConfigValue("2021_double_eleven_give_member_start_time");
|
|
|
+ String giveEndTime = sysConfigDao.findConfigValue("2021_double_eleven_give_member_end_time");
|
|
|
+ Date now = new Date();
|
|
|
+ TempBuyDoubleElevenUserLog doubleElevenUserLog = new TempBuyDoubleElevenUserLog();
|
|
|
+ doubleElevenUserLog.setUserId(studentPaymentOrder.getUserId());
|
|
|
+ doubleElevenUserLog.setCreateTime(now);
|
|
|
+ doubleElevenUserLog.setOrganId(studentPaymentOrder.getOrganId());
|
|
|
+ if(DateUtil.contents(giveStartTime,giveEndTime,now)){
|
|
|
+
|
|
|
+ doubleElevenUserLog.setGiveFlag(true);
|
|
|
+ }
|
|
|
+ tempBuyDoubleElevenUserLogDao.insert(doubleElevenUserLog);
|
|
|
+
|
|
|
+ luckDrawCountService.freeGive(studentPaymentOrder.getUserId().longValue(),Integer.parseInt(jsonDto.getValue()),3);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void setActivityType(VipGroupActivity activity) {
|
|
|
|
|
@@ -653,33 +675,18 @@ public class VipGroupActivityServiceImpl extends BaseServiceImpl<Integer, VipGro
|
|
|
|
|
|
@Override
|
|
|
@Transactional( rollbackFor = Exception.class,isolation = Isolation.READ_COMMITTED)
|
|
|
- public HttpResponseResult buyDoubleEleven2022(BuyDoubleEleven2022Dto payParam) throws Exception {
|
|
|
+ public HttpResponseResult buyDoubleEleven(BuyDoubleEleven2022Dto payParam) throws Exception {
|
|
|
String activityIdList = payParam.getActivityIdList();
|
|
|
List<VipGroupActivity> vipGroupActivities = vipGroupActivityDao.queryByIds(activityIdList);
|
|
|
Student student = studentDao.getLocked(payParam.getUserId());
|
|
|
BigDecimal activityFee = ZERO;
|
|
|
- for (int i = 0; i < vipGroupActivities.size(); i++) {
|
|
|
- VipGroupActivity activity = vipGroupActivities.get(i);
|
|
|
-
|
|
|
- SysConfigService.checkActivityDate(activity.getStartTime(),activity.getEndTime());
|
|
|
- Integer studentMaxUsedTimes = activity.getStudentMaxUsedTimes();
|
|
|
- if(studentMaxUsedTimes != -1){
|
|
|
-
|
|
|
- int activityBuyNum = activityUserMapperService.countActivityBuyNum(activity.getId(), payParam.getUserId());
|
|
|
- if(activityBuyNum >= studentMaxUsedTimes){
|
|
|
- throw new BizException("{}活动最多课购买{}次,感谢您的参与",activity.getName(),studentMaxUsedTimes);
|
|
|
- }
|
|
|
- }
|
|
|
+ for (VipGroupActivity activity : vipGroupActivities) {
|
|
|
+
|
|
|
+ this.checkActivity(activity,payParam.getUserId(),payParam.getOrganId());
|
|
|
activityFee = activityFee.add(activity.getMarketPrice());
|
|
|
}
|
|
|
-
|
|
|
|
|
|
- List<StudentPaymentOrder> list = studentPaymentOrderService
|
|
|
- .queryByCondition(GroupType.ACTIVITY,
|
|
|
- payParam.getActivityIdList(),
|
|
|
- payParam.getUserId(),
|
|
|
- DealStatusEnum.ING,OrderTypeEnum.SMALL_CLASS_TO_BUY);
|
|
|
-
|
|
|
+ List<StudentPaymentOrder> list = studentPaymentOrderService.queryByCondition(GroupType.ACTIVITY,null,student.getUserId(),DealStatusEnum.ING,OrderTypeEnum.SMALL_CLASS_TO_BUY);
|
|
|
if (list.size() > 0) {
|
|
|
StudentPaymentOrder applyOrder = list.get(list.size() - 1);
|
|
|
|
|
@@ -743,6 +750,25 @@ public class VipGroupActivityServiceImpl extends BaseServiceImpl<Integer, VipGro
|
|
|
return BaseController.succeed(payMap);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void checkActivity(VipGroupActivity activity,Integer userId,Integer organId){
|
|
|
+
|
|
|
+ String activityOrganIds = activity.getOrganId();
|
|
|
+ if(StringUtils.isNotEmpty(activityOrganIds) && !activityOrganIds.contains(organId.toString())){
|
|
|
+ throw new BizException("当前分部暂不支持此活动");
|
|
|
+ }
|
|
|
+
|
|
|
+ SysConfigService.checkActivityDate(activity.getStartTime(),activity.getEndTime());
|
|
|
+ Integer studentMaxUsedTimes = activity.getStudentMaxUsedTimes();
|
|
|
+ if(studentMaxUsedTimes != -1){
|
|
|
+
|
|
|
+ int activityBuyNum = activityUserMapperService.countActivityBuyNum(activity.getId(),userId);
|
|
|
+ if(activityBuyNum >= studentMaxUsedTimes){
|
|
|
+ throw new BizException("{}活动最多课购买{}次,感谢您的参与",activity.getName(),studentMaxUsedTimes);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void sendSuccessMsg(StudentPaymentOrder studentPaymentOrder){
|
|
|
Integer userId = studentPaymentOrder.getUserId();
|
|
|
VipGroupActivity vipGroupActivity = vipGroupActivityDao.get(Integer.parseInt(studentPaymentOrder.getActivityId()));
|