|
@@ -1,6 +1,7 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.ym.mec.auth.api.entity.SysUser;
|
|
|
import com.ym.mec.biz.dal.dao.*;
|
|
|
import com.ym.mec.biz.dal.dto.*;
|
|
@@ -10,7 +11,6 @@ import com.ym.mec.biz.dal.page.ActivityStudentQueryInfo;
|
|
|
import com.ym.mec.biz.dal.page.DoubleEleven2021QueryInfo;
|
|
|
import com.ym.mec.biz.dal.page.VipGroupActivityQueryInfo;
|
|
|
import com.ym.mec.biz.service.*;
|
|
|
-import com.ym.mec.common.constant.CommonConstants;
|
|
|
import com.ym.mec.common.controller.BaseController;
|
|
|
import com.ym.mec.common.dal.BaseDAO;
|
|
|
import com.ym.mec.common.entity.HttpResponseResult;
|
|
@@ -21,6 +21,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;
|
|
@@ -30,11 +31,12 @@ import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
+import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.ym.mec.biz.dal.enums.SysUserRoleEnum.ORGAN_MANAGER;
|
|
|
-import static java.math.BigDecimal.ROUND_DOWN;
|
|
|
import static java.math.BigDecimal.ROUND_UP;
|
|
|
+import static java.math.BigDecimal.ZERO;
|
|
|
|
|
|
@Service
|
|
|
public class VipGroupActivityServiceImpl extends BaseServiceImpl<Integer, VipGroupActivity> implements VipGroupActivityService {
|
|
@@ -79,6 +81,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() {
|
|
@@ -284,21 +290,57 @@ public class VipGroupActivityServiceImpl extends BaseServiceImpl<Integer, VipGro
|
|
|
return pageInfo;
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
+ @Override
|
|
|
+ public List<DoubleEleven2021Dto> organDoubleEleven2022Statis(OrganDoubleEleven2021StatisDto queryInfo) {
|
|
|
+ List<DoubleEleven2021Dto> doubleEleven2022Dtos = vipGroupActivityDao.countOrganDoubleEleven2022Statis(queryInfo.getOrganId());
|
|
|
+ return this.sumDoubleEleven(doubleEleven2022Dtos,queryInfo,
|
|
|
+ vipGroupActivityDao::countOrgan2022ActivityStatis,
|
|
|
+ null);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public DoubleEleven2021Dto doubleEleven2022Statis() {
|
|
|
+ DoubleEleven2021Dto doubleEleven2022Dto = vipGroupActivityDao.countDoubleEleven2022Statis();
|
|
|
+ if(doubleEleven2022Dto.getTotalBuyAmount().compareTo(ZERO) > 0){
|
|
|
+ doubleEleven2022Dto.setAvgBuyAmount(
|
|
|
+ doubleEleven2022Dto.getTotalBuyAmount().divide(new BigDecimal(doubleEleven2022Dto.getTotalBuyNum()),2,BigDecimal.ROUND_CEILING));
|
|
|
+ }
|
|
|
+ //获取活动成交数据
|
|
|
+ this.groupTypeConvert(vipGroupActivityDao.count2022ActivityStatis(),doubleEleven2022Dto);
|
|
|
+ //获取赠送会员数
|
|
|
+ Integer giveMemberNum = tempBuyDoubleElevenUserLogDao.countGiveNum(null);
|
|
|
+ doubleEleven2022Dto.setGiveMemberNum(giveMemberNum==null?0l:giveMemberNum.longValue());
|
|
|
+ return doubleEleven2022Dto;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public List<DoubleEleven2021Dto> organDoubleEleven2021Statis(OrganDoubleEleven2021StatisDto statisDto) {
|
|
|
- String order = statisDto.getOrder();
|
|
|
- String sort = statisDto.getSort();
|
|
|
List<DoubleEleven2021Dto> doubleEleven2021Dtos = vipGroupActivityDao.countOrganDoubleEleven2021Statis(statisDto.getOrganId());
|
|
|
- if(doubleEleven2021Dtos != null && doubleEleven2021Dtos.size() > 0){
|
|
|
+ return this.sumDoubleEleven(doubleEleven2021Dtos,statisDto,
|
|
|
+ vipGroupActivityDao::countOrganActivityStatis,
|
|
|
+ vipGroupActivityDao::countOrganGiveMemberNum);
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<DoubleEleven2021Dto> sumDoubleEleven(List<DoubleEleven2021Dto> doubleEleven2021Dtos,
|
|
|
+ OrganDoubleEleven2021StatisDto statisDto,
|
|
|
+ Function<List<Integer>,List<DoubleEleven2021ActivityDto>> funOne,
|
|
|
+ Function<List<Integer>,List<Map<Long,Long>>> funTwo){
|
|
|
+ if(!CollectionUtils.isEmpty(doubleEleven2021Dtos)){
|
|
|
+ String order = statisDto.getOrder();
|
|
|
+ String sort = statisDto.getSort();
|
|
|
List<Integer> organIdList = doubleEleven2021Dtos.stream().map(e -> e.getOrganId()).collect(Collectors.toList());
|
|
|
- List<DoubleEleven2021ActivityDto> activityDtoList = vipGroupActivityDao.countOrganActivityStatis(organIdList);
|
|
|
+
|
|
|
+ List<DoubleEleven2021ActivityDto> activityDtoList = funOne.apply(organIdList);;
|
|
|
Map<Integer, List<DoubleEleven2021ActivityDto>> collect = new HashMap<>();
|
|
|
if(activityDtoList != null && activityDtoList.size() > 0){
|
|
|
collect = activityDtoList.stream().collect(Collectors.groupingBy(DoubleEleven2021ActivityDto::getOrganId));
|
|
|
}
|
|
|
- Map<Long, Long> maps = MapUtil.convertIntegerMap(vipGroupActivityDao.countOrganGiveMemberNum(organIdList));
|
|
|
+ Map<Long, Long> maps = new HashMap<>();
|
|
|
+ if(funTwo != null){
|
|
|
+ maps = MapUtil.convertIntegerMap(funTwo.apply(organIdList));
|
|
|
+ }
|
|
|
for (DoubleEleven2021Dto doubleEleven2021Dto : doubleEleven2021Dtos) {
|
|
|
- if(doubleEleven2021Dto.getTotalBuyAmount().compareTo(BigDecimal.ZERO) > 0){
|
|
|
+ if(doubleEleven2021Dto.getTotalBuyAmount().compareTo(ZERO) > 0){
|
|
|
doubleEleven2021Dto.setAvgBuyAmount(
|
|
|
doubleEleven2021Dto.getTotalBuyAmount().divide(new BigDecimal(doubleEleven2021Dto.getTotalBuyNum()),2,BigDecimal.ROUND_CEILING));
|
|
|
}
|
|
@@ -413,19 +455,26 @@ public class VipGroupActivityServiceImpl extends BaseServiceImpl<Integer, VipGro
|
|
|
}
|
|
|
}
|
|
|
return doubleEleven2021Dtos;
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
- public Object doubleEleven2021Statis() {
|
|
|
+ public DoubleEleven2021Dto doubleEleven2021Statis() {
|
|
|
//获取总成交数据
|
|
|
DoubleEleven2021Dto doubleEleven2021Dto = vipGroupActivityDao.countDoubleEleven2021Statis();
|
|
|
- if(doubleEleven2021Dto.getTotalBuyAmount().compareTo(BigDecimal.ZERO) > 0){
|
|
|
+ if(doubleEleven2021Dto.getTotalBuyAmount().compareTo(ZERO) > 0){
|
|
|
doubleEleven2021Dto.setAvgBuyAmount(
|
|
|
doubleEleven2021Dto.getTotalBuyAmount().divide(new BigDecimal(doubleEleven2021Dto.getTotalBuyNum()),2,BigDecimal.ROUND_CEILING));
|
|
|
}
|
|
|
//获取活动成交数据
|
|
|
- List<DoubleEleven2021ActivityDto> activityDtos = vipGroupActivityDao.countActivityStatis();
|
|
|
- if(activityDtos != null && activityDtos.size() > 0){
|
|
|
+ this.groupTypeConvert(vipGroupActivityDao.countActivityStatis(),doubleEleven2021Dto);
|
|
|
+ //获取赠送会员数
|
|
|
+ Integer giveMemberNum = vipGroupActivityDao.countGiveMemberNum();
|
|
|
+ doubleEleven2021Dto.setGiveMemberNum(giveMemberNum==null?0l:giveMemberNum.longValue());
|
|
|
+ return doubleEleven2021Dto;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void groupTypeConvert(List<DoubleEleven2021ActivityDto> activityDtos,DoubleEleven2021Dto doubleEleven2021Dto){
|
|
|
+ if(!CollectionUtils.isEmpty(activityDtos)){
|
|
|
for (DoubleEleven2021ActivityDto activityDto : activityDtos) {
|
|
|
if(activityDto.getType() == 1){
|
|
|
doubleEleven2021Dto.setVip1V120Amount(activityDto.getBuyAmount());
|
|
@@ -445,10 +494,6 @@ public class VipGroupActivityServiceImpl extends BaseServiceImpl<Integer, VipGro
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- //获取赠送会员数
|
|
|
- Integer giveMemberNum = vipGroupActivityDao.countGiveMemberNum();
|
|
|
- doubleEleven2021Dto.setGiveMemberNum(giveMemberNum==null?0l:giveMemberNum.longValue());
|
|
|
- return doubleEleven2021Dto;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -560,17 +605,16 @@ public class VipGroupActivityServiceImpl extends BaseServiceImpl<Integer, VipGro
|
|
|
}
|
|
|
|
|
|
BigDecimal amount = studentPaymentOrder.getActualAmount();
|
|
|
- BigDecimal balance = BigDecimal.ZERO;
|
|
|
String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
|
|
|
//分类费用 course,instrument,accessories,other
|
|
|
Map<String, BigDecimal> classFee = new HashMap<>();
|
|
|
classFee.put("course", amount);
|
|
|
- classFee.put("instrument", BigDecimal.ZERO);
|
|
|
- classFee.put("accessories", BigDecimal.ZERO);
|
|
|
- classFee.put("other", BigDecimal.ZERO);
|
|
|
+ classFee.put("instrument", ZERO);
|
|
|
+ classFee.put("accessories", ZERO);
|
|
|
+ classFee.put("other", ZERO);
|
|
|
Map<String, Object> payMap = payService.getPayMap(
|
|
|
amount,
|
|
|
- balance,
|
|
|
+ studentPaymentOrder.getBalancePaymentAmount(),
|
|
|
orderNo,
|
|
|
baseApiUrl + "/api-student/studentOrder/callback",
|
|
|
baseApiUrl + "/api-student/studentOrder/paymentResult?orderNo=" + orderNo,
|
|
@@ -597,15 +641,18 @@ public class VipGroupActivityServiceImpl extends BaseServiceImpl<Integer, VipGro
|
|
|
}
|
|
|
if (studentPaymentOrder.getStatus() == DealStatusEnum.SUCCESS) {
|
|
|
Student student = studentDao.get(studentPaymentOrder.getUserId());
|
|
|
- //活动赠送
|
|
|
- studentPaymentOrderService.activityGive(Integer.parseInt(studentPaymentOrder.getActivityId()), studentPaymentOrder,
|
|
|
- null, null, student.getTeacherId());
|
|
|
+ //处理双十一活动特殊赠送
|
|
|
+ boolean elevenFlag = this.doubleElevenGive(studentPaymentOrder, student.getTeacherId());
|
|
|
+ if(!elevenFlag){
|
|
|
+ studentPaymentOrderService.activityGive(Integer.parseInt(studentPaymentOrder.getActivityId()), studentPaymentOrder,
|
|
|
+ null, null, student.getTeacherId());
|
|
|
+ }
|
|
|
//保存账户信息
|
|
|
sysUserCashAccountDetailService.saveSysUserCashAccountDetail(studentPaymentOrder,studentPaymentOrder.getMemo());
|
|
|
//发送短信
|
|
|
this.sendSuccessMsg(studentPaymentOrder);
|
|
|
}else {
|
|
|
- if (Objects.nonNull(studentPaymentOrder.getBalancePaymentAmount()) && studentPaymentOrder.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ if (Objects.nonNull(studentPaymentOrder.getBalancePaymentAmount()) && studentPaymentOrder.getBalancePaymentAmount().compareTo(ZERO) > 0) {
|
|
|
sysUserCashAccountService.updateBalance(studentPaymentOrder.getUserId(), studentPaymentOrder.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, studentPaymentOrder.getMemo() + "支付失败,退还余额");
|
|
|
}
|
|
|
sysCouponCodeService.quit(studentPaymentOrder.getCouponCodeId());
|
|
@@ -613,6 +660,56 @@ public class VipGroupActivityServiceImpl extends BaseServiceImpl<Integer, VipGro
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //处理双十一活动特殊赠送
|
|
|
+ private boolean doubleElevenGive(StudentPaymentOrder studentPaymentOrder,Integer teacherId){
|
|
|
+ String[] split = studentPaymentOrder.getActivityId().split(",");
|
|
|
+ String activeConfig = sysConfigDao.findConfigValue("2022_double_eleven_give_config");
|
|
|
+ String giveStartTime = sysConfigDao.findConfigValue("2021_double_eleven_give_member_start_time");
|
|
|
+ String giveEndTime = sysConfigDao.findConfigValue("2021_double_eleven_give_member_end_time");
|
|
|
+ Boolean doubleElevenFlag = false;
|
|
|
+ for (String activityId : split) {
|
|
|
+ List<SysConfigJsonDto> cloud2022ActivityDtos = JSONArray.parseArray(activeConfig, SysConfigJsonDto.class);
|
|
|
+ List<SysConfigJsonDto> activityDtos = cloud2022ActivityDtos.stream().
|
|
|
+ filter(e -> Arrays.stream(e.getKey().split(",")).collect(Collectors.toList()).
|
|
|
+ contains(activityId)).collect(Collectors.toList());
|
|
|
+ if(!CollectionUtils.isEmpty(activityDtos)){
|
|
|
+ doubleElevenFlag = true;
|
|
|
+ SysConfigJsonDto jsonDto = activityDtos.get(0);
|
|
|
+ //处理双十一活动特殊处理
|
|
|
+ Date now = new Date();
|
|
|
+ TempBuyDoubleElevenUserLog doubleElevenUserLog = new TempBuyDoubleElevenUserLog();
|
|
|
+ doubleElevenUserLog.setOrderId(studentPaymentOrder.getId());
|
|
|
+ doubleElevenUserLog.setUserId(studentPaymentOrder.getUserId());
|
|
|
+ doubleElevenUserLog.setCreateTime(now);
|
|
|
+ doubleElevenUserLog.setOrganId(studentPaymentOrder.getOrganId());
|
|
|
+ //杭州不送保养套装
|
|
|
+ if(studentPaymentOrder.getOrganId().equals(4)){
|
|
|
+ if(DateUtil.contents(giveStartTime,giveEndTime,now)){
|
|
|
+ //赠送抽奖机会
|
|
|
+ luckDrawCountService.freeGive(studentPaymentOrder.getUserId().longValue(),Integer.parseInt(jsonDto.getValue()),4);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if(DateUtil.contents(giveStartTime,giveEndTime,now)){
|
|
|
+ Integer giveNum = tempBuyDoubleElevenUserLogDao.countGiveNum(studentPaymentOrder.getUserId());
|
|
|
+ if(giveNum == null || giveNum == 0){
|
|
|
+ //符合赠送条件,赠送乐保套装
|
|
|
+ doubleElevenUserLog.setGiveFlag(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //赠送抽奖机会
|
|
|
+ luckDrawCountService.freeGive(studentPaymentOrder.getUserId().longValue(),Integer.parseInt(jsonDto.getValue()),3);
|
|
|
+ }
|
|
|
+ tempBuyDoubleElevenUserLogDao.insert(doubleElevenUserLog);
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (doubleElevenFlag){
|
|
|
+ //处理活动特殊排课资格
|
|
|
+ activityUserMapperService.saveToOrder(studentPaymentOrder,teacherId);
|
|
|
+ }
|
|
|
+ return doubleElevenFlag;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void setActivityType(VipGroupActivity activity) {
|
|
|
//如果是会员活动
|
|
@@ -639,47 +736,113 @@ public class VipGroupActivityServiceImpl extends BaseServiceImpl<Integer, VipGro
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void sendSuccessMsg(StudentPaymentOrder studentPaymentOrder){
|
|
|
- Integer userId = studentPaymentOrder.getUserId();
|
|
|
- VipGroupActivity vipGroupActivity = vipGroupActivityDao.get(Integer.parseInt(studentPaymentOrder.getActivityId()));
|
|
|
- String activityName = vipGroupActivity.getName();
|
|
|
- if(vipGroupActivity.getActivityType().equals(0)) {
|
|
|
- SysUser user = teacherDao.getUser(userId);
|
|
|
- String username = StringUtils.isEmpty(user.getUsername()) ? user.getRealName() : user.getUsername();
|
|
|
- Map<Integer, String> map = new HashMap<>(1);
|
|
|
- map.put(userId, userId.toString());
|
|
|
- sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.PUSH_STUDENT_BUY_ACTIVITY, map, null, 0, null, "STUDENT",
|
|
|
- activityName);
|
|
|
- //获取乐团主管
|
|
|
- Map<Integer, String> eduMap = MapUtil.convertMybatisMap(studentRegistrationDao.queryStudentEduMap(userId));
|
|
|
- if (CollectionUtils.isEmpty(eduMap)) {
|
|
|
- Set<Integer> integers = employeePositionService.queryUserIdByRoleId(new SysUserRoleEnum[]{ORGAN_MANAGER}, studentPaymentOrder.getOrganId());
|
|
|
- eduMap = new HashMap<>(integers.size());
|
|
|
- if (!CollectionUtils.isEmpty(integers)) {
|
|
|
- for (Integer integer : integers) {
|
|
|
- eduMap.put(integer, integer.toString());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (!CollectionUtils.isEmpty(eduMap)) {
|
|
|
- sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.PUSH_SYSTEM_ACTIVITY_COURSE,
|
|
|
- eduMap, null, 0, null, "SYSTEM", username, activityName);
|
|
|
+ @Override
|
|
|
+ @Transactional( rollbackFor = Exception.class,isolation = Isolation.READ_COMMITTED)
|
|
|
+ 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 (VipGroupActivity activity : vipGroupActivities) {
|
|
|
+ //校验活动购买条件
|
|
|
+ this.checkActivity(activity,payParam.getUserId(),payParam.getOrganId());
|
|
|
+ activityFee = activityFee.add(activity.getMarketPrice());
|
|
|
+ }
|
|
|
+ // 判断是否存在支付中的记录
|
|
|
+ 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);
|
|
|
+ //校验重复支付
|
|
|
+ HttpResponseResult result = studentPaymentOrderService.checkRepeatPay(applyOrder, payParam.getRepeatPay());
|
|
|
+ if (result.getCode() != 200) {
|
|
|
+ return result;
|
|
|
}
|
|
|
- Student student = studentDao.get(userId);
|
|
|
- if (Objects.nonNull(student) && student.getTeacherId() != null) {
|
|
|
- Map<Integer, String> teacherMap = new HashMap<>(1);
|
|
|
- teacherMap.put(student.getTeacherId(), student.getTeacherId().toString());
|
|
|
- sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.PUSH_TEACHER_ACTIVITY_COURSE,
|
|
|
- teacherMap, null, 0, null, "TEACHER", username, activityName);
|
|
|
+ }
|
|
|
+
|
|
|
+ //计算订单金额
|
|
|
+ StudentPaymentOrder studentPaymentOrder = sysCouponCodeService.use(payParam.getCouponIdList(), activityFee, true);
|
|
|
+ if (studentPaymentOrder.getActualAmount().compareTo(payParam.getAmount()) != 0) {
|
|
|
+ throw new BizException("非法请求");
|
|
|
+ }
|
|
|
+ String orderNo = idGeneratorService.generatorId("payment") + "";
|
|
|
+ studentPaymentOrder.setMemo("2022双十一活动购买");
|
|
|
+ studentPaymentOrder.setPaymentChannel("BALANCE");
|
|
|
+ studentPaymentOrder.setUserId(student.getUserId());
|
|
|
+ studentPaymentOrder.setGroupType(GroupType.ACTIVITY);
|
|
|
+ studentPaymentOrder.setOrderNo(orderNo);
|
|
|
+ studentPaymentOrder.setType(OrderTypeEnum.SMALL_CLASS_TO_BUY);
|
|
|
+ studentPaymentOrder.setStatus(DealStatusEnum.ING);
|
|
|
+ studentPaymentOrder.setRemitFee(ZERO);
|
|
|
+ studentPaymentOrder.setCourseRemitFee(ZERO);
|
|
|
+ studentPaymentOrder.setOrganId(payParam.getOrganId());
|
|
|
+ studentPaymentOrder.setRoutingOrganId(payParam.getOrganId());
|
|
|
+ studentPaymentOrder.setActivityId(activityIdList);
|
|
|
+ studentPaymentOrder.setMusicGroupId(activityIdList);
|
|
|
+ studentPaymentOrder.setVersion(0);
|
|
|
+ studentPaymentOrderService.insert(studentPaymentOrder);
|
|
|
+
|
|
|
+ //消耗余额
|
|
|
+ Boolean success = sysUserCashAccountService.use(payParam,studentPaymentOrder);
|
|
|
+ if(success){
|
|
|
+ this.orderCallback(studentPaymentOrder);
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ result.put("orderNo", studentPaymentOrder.getOrderNo());
|
|
|
+ return BaseController.succeed(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ String orderSubject = "2022双十一活动";
|
|
|
+ String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
|
|
|
+ Map payMap = payService.getPayMap(
|
|
|
+ studentPaymentOrder.getActualAmount(),
|
|
|
+ studentPaymentOrder.getBalancePaymentAmount(),
|
|
|
+ orderNo,
|
|
|
+ baseApiUrl + "/api-student/studentOrder/notify",
|
|
|
+ baseApiUrl + "/api-student/studentOrder/paymentResult?orderNo=" + orderNo,
|
|
|
+ orderSubject,
|
|
|
+ orderSubject,
|
|
|
+ studentPaymentOrder.getOrganId(),
|
|
|
+ "vip"
|
|
|
+ );
|
|
|
+
|
|
|
+ studentPaymentOrder.setOrganId(studentPaymentOrder.getOrganId());
|
|
|
+ studentPaymentOrder.setMerNos((String) payMap.get("routingMerNos"));
|
|
|
+ studentPaymentOrder.setPaymentChannel((String) payMap.get("type"));
|
|
|
+ studentPaymentOrderService.update(studentPaymentOrder);
|
|
|
+ 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);
|
|
|
}
|
|
|
- }else {
|
|
|
- SysUser user = teacherDao.getUser(userId);
|
|
|
- String username = StringUtils.isEmpty(user.getUsername()) ? user.getRealName() : user.getUsername();
|
|
|
- Map<Integer, String> map = new HashMap<>(1);
|
|
|
- map.put(userId, userId.toString());
|
|
|
- sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.PUSH_STUDENT_BUY_MEMBER_ACTIVITY, map, null, 0, null, "STUDENT",
|
|
|
- activityName);
|
|
|
- if(!tenantConfigService.autoActivationFlag(user.getTenantId())){
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void sendSuccessMsg(StudentPaymentOrder studentPaymentOrder){
|
|
|
+ Integer userId = studentPaymentOrder.getUserId();
|
|
|
+ String[] split = studentPaymentOrder.getActivityId().split(",");
|
|
|
+ for (String activityId : split) {
|
|
|
+ VipGroupActivity vipGroupActivity = vipGroupActivityDao.get(Integer.parseInt(activityId));
|
|
|
+ String activityName = vipGroupActivity.getName();
|
|
|
+ if(vipGroupActivity.getActivityType().equals(0)) {
|
|
|
+ SysUser user = teacherDao.getUser(userId);
|
|
|
+ String username = StringUtils.isEmpty(user.getUsername()) ? user.getRealName() : user.getUsername();
|
|
|
+ Map<Integer, String> map = new HashMap<>(1);
|
|
|
+ map.put(userId, userId.toString());
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.PUSH_STUDENT_BUY_ACTIVITY, map, null, 0, null, "STUDENT",
|
|
|
+ activityName);
|
|
|
//获取乐团主管
|
|
|
Map<Integer, String> eduMap = MapUtil.convertMybatisMap(studentRegistrationDao.queryStudentEduMap(userId));
|
|
|
if (CollectionUtils.isEmpty(eduMap)) {
|
|
@@ -692,9 +855,40 @@ public class VipGroupActivityServiceImpl extends BaseServiceImpl<Integer, VipGro
|
|
|
}
|
|
|
}
|
|
|
if (!CollectionUtils.isEmpty(eduMap)) {
|
|
|
- sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.PUSH_SYSTEM_ACTIVITY_MEMBER,
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.PUSH_SYSTEM_ACTIVITY_COURSE,
|
|
|
eduMap, null, 0, null, "SYSTEM", username, activityName);
|
|
|
}
|
|
|
+ Student student = studentDao.get(userId);
|
|
|
+ if (Objects.nonNull(student) && student.getTeacherId() != null) {
|
|
|
+ Map<Integer, String> teacherMap = new HashMap<>(1);
|
|
|
+ teacherMap.put(student.getTeacherId(), student.getTeacherId().toString());
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.PUSH_TEACHER_ACTIVITY_COURSE,
|
|
|
+ teacherMap, null, 0, null, "TEACHER", username, activityName);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ SysUser user = teacherDao.getUser(userId);
|
|
|
+ String username = StringUtils.isEmpty(user.getUsername()) ? user.getRealName() : user.getUsername();
|
|
|
+ Map<Integer, String> map = new HashMap<>(1);
|
|
|
+ map.put(userId, userId.toString());
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.PUSH_STUDENT_BUY_MEMBER_ACTIVITY, map, null, 0, null, "STUDENT",
|
|
|
+ activityName);
|
|
|
+ if(!tenantConfigService.autoActivationFlag(user.getTenantId())){
|
|
|
+ //获取乐团主管
|
|
|
+ Map<Integer, String> eduMap = MapUtil.convertMybatisMap(studentRegistrationDao.queryStudentEduMap(userId));
|
|
|
+ if (CollectionUtils.isEmpty(eduMap)) {
|
|
|
+ Set<Integer> integers = employeePositionService.queryUserIdByRoleId(new SysUserRoleEnum[]{ORGAN_MANAGER}, studentPaymentOrder.getOrganId());
|
|
|
+ eduMap = new HashMap<>(integers.size());
|
|
|
+ if (!CollectionUtils.isEmpty(integers)) {
|
|
|
+ for (Integer integer : integers) {
|
|
|
+ eduMap.put(integer, integer.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!CollectionUtils.isEmpty(eduMap)) {
|
|
|
+ sysMessageService.batchSendMessage(MessageSenderPluginContext.MessageSender.JIGUANG, MessageTypeEnum.PUSH_SYSTEM_ACTIVITY_MEMBER,
|
|
|
+ eduMap, null, 0, null, "SYSTEM", username, activityName);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|