|
@@ -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);
|
|
|
- //处理双十一活动特殊处理
|
|
|
-// if(){
|
|
|
-//
|
|
|
-// }
|
|
|
- //赠送抽奖机会
|
|
|
- }
|
|
|
+ //处理双十一活动特殊赠送
|
|
|
+ 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()));
|