|
@@ -29,6 +29,7 @@ import java.util.Objects;
|
|
|
import java.util.Set;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+import com.ym.mec.biz.service.*;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -146,27 +147,6 @@ import com.ym.mec.biz.dal.enums.YesOrNoEnum;
|
|
|
import com.ym.mec.biz.dal.page.PracticeGroupQueryInfo;
|
|
|
import com.ym.mec.biz.dal.page.StudentBuyPracticeQueryInfo;
|
|
|
import com.ym.mec.biz.dal.page.StudentQueryInfo;
|
|
|
-import com.ym.mec.biz.service.ActivityUserMapperService;
|
|
|
-import com.ym.mec.biz.service.ContractService;
|
|
|
-import com.ym.mec.biz.service.CourseScheduleService;
|
|
|
-import com.ym.mec.biz.service.CourseScheduleTeacherSalaryService;
|
|
|
-import com.ym.mec.biz.service.GroupClassService;
|
|
|
-import com.ym.mec.biz.service.ImUserFriendService;
|
|
|
-import com.ym.mec.biz.service.LuckDrawCountService;
|
|
|
-import com.ym.mec.biz.service.PayService;
|
|
|
-import com.ym.mec.biz.service.PracticeGroupService;
|
|
|
-import com.ym.mec.biz.service.StudentPaymentOrderService;
|
|
|
-import com.ym.mec.biz.service.StudentPaymentRouteOrderService;
|
|
|
-import com.ym.mec.biz.service.StudentService;
|
|
|
-import com.ym.mec.biz.service.SysConfigService;
|
|
|
-import com.ym.mec.biz.service.SysCouponCodeService;
|
|
|
-import com.ym.mec.biz.service.SysMessageService;
|
|
|
-import com.ym.mec.biz.service.SysTenantConfigService;
|
|
|
-import com.ym.mec.biz.service.SysUserCashAccountDetailService;
|
|
|
-import com.ym.mec.biz.service.SysUserCashAccountLogService;
|
|
|
-import com.ym.mec.biz.service.SysUserCashAccountService;
|
|
|
-import com.ym.mec.biz.service.TeacherCourseRewardService;
|
|
|
-import com.ym.mec.biz.service.TeacherService;
|
|
|
import com.ym.mec.common.constant.CommonConstants;
|
|
|
import com.ym.mec.common.controller.BaseController;
|
|
|
import com.ym.mec.common.dal.BaseDAO;
|
|
@@ -271,18 +251,8 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
@Autowired
|
|
|
private ActivityUserMapperService activityUserMapperService;
|
|
|
@Autowired
|
|
|
- private MemberFeeSettingDao memberFeeSettingDao;
|
|
|
- @Autowired
|
|
|
- private CloudTeacherOrderDao cloudTeacherOrderDao;
|
|
|
- @Autowired
|
|
|
- private StudentService studentService;
|
|
|
- @Autowired
|
|
|
private CourseScheduleTeacherSalaryService courseScheduleTeacherSalaryService;
|
|
|
@Autowired
|
|
|
- private RedisCache<String, Object> redisCache;
|
|
|
- @Autowired
|
|
|
- private LuckDrawCountService luckDrawCountService;
|
|
|
- @Autowired
|
|
|
private VipGroupDao vipGroupDao;
|
|
|
@Autowired
|
|
|
private VipGroupCategoryDao vipGroupCategoryDao;
|
|
@@ -306,8 +276,6 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
|
|
|
private static List<String> applyDayTimes = new ArrayList<>();
|
|
|
|
|
|
- private static final Set<Integer> ENABLE_APPLY_ORGANIDS = new HashSet<>(Arrays.asList(new Integer[]{28, 34, 37}));
|
|
|
-
|
|
|
static {
|
|
|
applyStartDay = DateUtil.stringToDate("2020-03-25 00:00:00");
|
|
|
activityStartDate = DateUtil.stringToDate("2020-03-25 00:00:00");
|
|
@@ -3540,305 +3508,6 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
|
|
|
- public void activityOrderCallback(StudentPaymentOrder studentPaymentOrder) {
|
|
|
- Integer userId = studentPaymentOrder.getUserId();
|
|
|
- StudentPaymentOrder order = studentPaymentOrderDao.lockOrder(studentPaymentOrder.getId());
|
|
|
- if (!order.getStatus().equals(DealStatusEnum.ING)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- //更新订单状态
|
|
|
- int updateCount = studentPaymentOrderService.update(studentPaymentOrder);
|
|
|
- if (updateCount <= 0) {
|
|
|
- throw new BizException("订单更新失败");
|
|
|
- }
|
|
|
- if (studentPaymentOrder.getStatus().equals(DealStatusEnum.SUCCESS)) {
|
|
|
- Date now = new Date();
|
|
|
- Student student = studentDao.get(order.getUserId());
|
|
|
- Integer activityId = Integer.parseInt(order.getActivityId());
|
|
|
- VipGroupActivity activity = vipGroupActivityDao.get(activityId);
|
|
|
- ActivityUserMapper activityUserMapper = new ActivityUserMapper();
|
|
|
- activityUserMapper.setActivityId(activityId);
|
|
|
- activityUserMapper.setUserId(order.getUserId());
|
|
|
- activityUserMapper.setPaymentOrderId(order.getId());
|
|
|
- activityUserMapper.setTeacherId(student.getTeacherId());
|
|
|
-
|
|
|
- if (activity.getActivityType() == 1) {
|
|
|
- //会员立即生效
|
|
|
- Integer cloudTeacherType;
|
|
|
- PeriodEnum periodEnum = activity.getPeriodEnum();
|
|
|
- Integer cloudTime = activity.getMemberTime();
|
|
|
- CloudTeacherOrder cloudTeacherOrder = new CloudTeacherOrder();
|
|
|
-// Date addDate = now;
|
|
|
-// if (student.getMemberRankSettingId() == null || now.after(student.getMembershipEndTime())) {
|
|
|
-// cloudTeacherOrder.setStartTime(now);
|
|
|
-// } else {
|
|
|
-// addDate = student.getMembershipEndTime();
|
|
|
-// cloudTeacherOrder.setStartTime(DateUtil.addDays(addDate, 1));
|
|
|
-// }
|
|
|
-// cloudTeacherOrder.setEndTime(studentService.getMembershipEndTime(periodEnum, addDate, cloudTime));
|
|
|
- cloudTeacherOrder.setRemark("营销活动购买会员");
|
|
|
- cloudTeacherOrder.setStatus(1);
|
|
|
- cloudTeacherOrder.setOrderId(order.getId());
|
|
|
- cloudTeacherOrder.setType(periodEnum);
|
|
|
- cloudTeacherOrder.setAmount(order.getActualAmount());
|
|
|
- cloudTeacherOrder.setLevel(activity.getMemberRankId());
|
|
|
- cloudTeacherOrder.setStudentId(userId);
|
|
|
- cloudTeacherOrder.setOrganId(order.getOrganId());
|
|
|
- cloudTeacherOrder.setTime(cloudTime);
|
|
|
- cloudTeacherOrderDao.insert(cloudTeacherOrder);
|
|
|
-// studentService.updateMemberRank(cloudTeacherOrder);
|
|
|
- activityUserMapper.setMemberFlag(2);
|
|
|
- activityUserMapper.setMemberOrderId(cloudTeacherOrder.getId());
|
|
|
- } else {
|
|
|
- if (activity.getCourseType().equals("VIP")) {
|
|
|
- activityUserMapper.setVipFlag(1);
|
|
|
- } else {
|
|
|
- activityUserMapper.setPracticeFlag(1);
|
|
|
- }
|
|
|
- if (activity.isPayToBalance()) {
|
|
|
- boolean appendCourseBalance = sysUserCashAccountService.appendCourseBalance(userId, studentPaymentOrder.getExpectAmount(), PlatformCashAccountDetailTypeEnum.RECHARGE, "通用营销活动购买");
|
|
|
- if (!appendCourseBalance) {
|
|
|
- throw new BizException("增加用户课程余额失败");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (activity.getFullMinusCourseTimes() != -1 && order.getActivityBuyNum() >= activity.getFullMinusCourseTimes()) {
|
|
|
- if (activity.getGiveMemberTime() > 0) {
|
|
|
- //会员立即生效
|
|
|
- Integer cloudTeacherType;
|
|
|
- PeriodEnum periodEnum = activity.getGivePeriodEnum();
|
|
|
- Integer cloudTime = activity.getGiveMemberTime();
|
|
|
- CloudTeacherOrder cloudTeacherOrder = new CloudTeacherOrder();
|
|
|
-// Date addDate = now;
|
|
|
-// if (student.getMemberRankSettingId() == null || now.after(student.getMembershipEndTime())) {
|
|
|
-// cloudTeacherOrder.setStartTime(now);
|
|
|
-// } else {
|
|
|
-// addDate = student.getMembershipEndTime();
|
|
|
-// cloudTeacherOrder.setStartTime(DateUtil.addDays(addDate, 1));
|
|
|
-// }
|
|
|
-// cloudTeacherOrder.setEndTime(studentService.getMembershipEndTime(periodEnum, addDate, cloudTime));
|
|
|
- cloudTeacherOrder.setRemark("营销活动赠送会员");
|
|
|
- cloudTeacherOrder.setStatus(1);
|
|
|
- cloudTeacherOrder.setOrderId(order.getId());
|
|
|
- cloudTeacherOrder.setType(periodEnum);
|
|
|
- cloudTeacherOrder.setAmount(BigDecimal.ZERO);
|
|
|
- cloudTeacherOrder.setLevel(activity.getGiveMemberRankId());
|
|
|
- cloudTeacherOrder.setStudentId(userId);
|
|
|
- cloudTeacherOrder.setOrganId(order.getOrganId());
|
|
|
- cloudTeacherOrder.setTime(cloudTime);
|
|
|
- cloudTeacherOrderDao.insert(cloudTeacherOrder);
|
|
|
-// studentService.updateMemberRank(cloudTeacherOrder);
|
|
|
- activityUserMapper.setGiveMemberFlag(2);
|
|
|
- activityUserMapper.setGiveMemberOrderId(cloudTeacherOrder.getId());
|
|
|
- } else if (activity.getGiveCourseNum() > 0) {
|
|
|
- if (activity.getGiveCourseType().equals("VIP")) {
|
|
|
- activityUserMapper.setGiveVipFlag(1);
|
|
|
- } else {
|
|
|
- activityUserMapper.setGivePracticeFlag(1);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- activityUserMapperService.insert(activityUserMapper);
|
|
|
- SysUserCashAccount sysUserCashAccount = sysUserCashAccountService.get(userId);
|
|
|
- //插入缴费明细
|
|
|
- //收入
|
|
|
- SysUserCashAccountDetail sysUserIncomeCashAccountDetail = new SysUserCashAccountDetail();
|
|
|
- sysUserIncomeCashAccountDetail.setUserId(order.getUserId());
|
|
|
- sysUserIncomeCashAccountDetail.setType(PlatformCashAccountDetailTypeEnum.RECHARGE);
|
|
|
- sysUserIncomeCashAccountDetail.setStatus(DealStatusEnum.SUCCESS);
|
|
|
- sysUserIncomeCashAccountDetail.setAmount(order.getActualAmount());
|
|
|
- sysUserIncomeCashAccountDetail.setBalance(sysUserCashAccount.getBalance().add(order.getActualAmount()));
|
|
|
- sysUserIncomeCashAccountDetail.setAttribute(order.getTransNo());
|
|
|
- sysUserIncomeCashAccountDetail.setChannel(studentPaymentOrder.getPaymentChannel());
|
|
|
- sysUserIncomeCashAccountDetail.setComAmount(studentPaymentOrder.getComAmount());
|
|
|
- sysUserIncomeCashAccountDetail.setPerAmount(studentPaymentOrder.getPerAmount());
|
|
|
- //支出
|
|
|
- SysUserCashAccountDetail sysUserExpendCashAccountDetail = new SysUserCashAccountDetail();
|
|
|
- sysUserExpendCashAccountDetail.setUserId(order.getUserId());
|
|
|
- sysUserExpendCashAccountDetail.setType(PlatformCashAccountDetailTypeEnum.PAY_FEE);
|
|
|
- sysUserExpendCashAccountDetail.setStatus(DealStatusEnum.SUCCESS);
|
|
|
- sysUserExpendCashAccountDetail.setAmount(order.getActualAmount().negate());
|
|
|
- sysUserExpendCashAccountDetail.setBalance(sysUserCashAccount.getBalance());
|
|
|
- sysUserExpendCashAccountDetail.setAttribute(order.getTransNo());
|
|
|
- sysUserExpendCashAccountDetail.setChannel(studentPaymentOrder.getPaymentChannel());
|
|
|
-
|
|
|
- if (studentPaymentOrder.getComAmount() != null) {
|
|
|
- sysUserIncomeCashAccountDetail.setComAmount(studentPaymentOrder.getComAmount().negate());
|
|
|
- }
|
|
|
- if (studentPaymentOrder.getPerAmount() != null) {
|
|
|
- sysUserExpendCashAccountDetail.setPerAmount(studentPaymentOrder.getPerAmount().negate());
|
|
|
- }
|
|
|
-
|
|
|
- sysUserCashAccountDetailService.insert(sysUserIncomeCashAccountDetail);
|
|
|
- sysUserCashAccountDetailService.insert(sysUserExpendCashAccountDetail);
|
|
|
-
|
|
|
-// try {
|
|
|
-// contractService.transferPracticeCoursesContract(order.getUserId(), classGroup.getTotalClassTimes(), practiceGroup.getCoursesStartDate(), practiceGroup.getCoursesExpireDate(), order.getExpectAmount());
|
|
|
-// } catch (Exception e) {
|
|
|
-// LOGGER.error(MessageFormatter.arrayFormat("网管课[{}]购买协议错误:{}", order.getMusicGroupId(), e.getMessage()), e);
|
|
|
-// }
|
|
|
- studentDao.updateStudentServiceTag(userId, null, YesOrNoEnum.YES.getCode());
|
|
|
- }
|
|
|
- if (studentPaymentOrder.getStatus().equals(DealStatusEnum.FAILED)) {
|
|
|
- if (studentPaymentOrder.getBalancePaymentAmount() != null && studentPaymentOrder.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- sysUserCashAccountService.updateBalance(studentPaymentOrder.getUserId(), studentPaymentOrder.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "报名缴费失败");
|
|
|
- }
|
|
|
- sysCouponCodeService.quit(studentPaymentOrder.getCouponCodeId());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
|
|
|
- public void doubleEleven2021OrderCallback(StudentPaymentOrder studentPaymentOrder) {
|
|
|
- Integer userId = studentPaymentOrder.getUserId();
|
|
|
- StudentPaymentOrder order = studentPaymentOrderDao.lockOrder(studentPaymentOrder.getId());
|
|
|
- if (!order.getStatus().equals(DealStatusEnum.ING)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- //更新订单状态
|
|
|
- int updateCount = studentPaymentOrderService.update(studentPaymentOrder);
|
|
|
- if (updateCount <= 0) {
|
|
|
- throw new BizException("订单更新失败");
|
|
|
- }
|
|
|
- if (studentPaymentOrder.getStatus().equals(DealStatusEnum.SUCCESS)) {
|
|
|
- Date now = new Date();
|
|
|
- Student student = studentDao.get(order.getUserId());
|
|
|
- List<VipGroupActivity> vipGroupActivities = vipGroupActivityDao.queryByIds(order.getActivityId());
|
|
|
- List<ActivityUserMapper> activityUserMappers = new ArrayList<>();
|
|
|
- Integer times = 0;
|
|
|
-
|
|
|
- BigDecimal couponRemitFee = order.getCouponRemitFee();
|
|
|
- BigDecimal subCouponRemitFee = couponRemitFee;
|
|
|
- BigDecimal totalMarketPrice = vipGroupActivities.stream().map(e -> e.getMarketPrice()).reduce(ZERO, BigDecimal::add);
|
|
|
-
|
|
|
- String startTimeStr = sysConfigDao.findConfigValue("2021_double_eleven_give_member_start_time");
|
|
|
- Date startTime = DateUtil.stringToDate(startTimeStr);
|
|
|
- String endTimeStr = sysConfigDao.findConfigValue("2021_double_eleven_give_member_end_time");
|
|
|
- Date endTime = DateUtil.stringToDate(endTimeStr);
|
|
|
- for (int i = 0; i < vipGroupActivities.size(); i++) {
|
|
|
- VipGroupActivity activity = vipGroupActivities.get(i);
|
|
|
- ActivityUserMapper activityUserMapper = new ActivityUserMapper();
|
|
|
- activityUserMapper.setActivityId(activity.getId());
|
|
|
- activityUserMapper.setUserId(order.getUserId());
|
|
|
- activityUserMapper.setPaymentOrderId(order.getId());
|
|
|
- activityUserMapper.setTeacherId(student.getTeacherId());
|
|
|
- activityUserMapper.setVipFlag(1);
|
|
|
- if (couponRemitFee.compareTo(ZERO) > 0) {
|
|
|
- if (i == vipGroupActivities.size() - 1) {
|
|
|
- activityUserMapper.setActualPrice(activity.getMarketPrice().subtract(subCouponRemitFee));
|
|
|
- } else {
|
|
|
- //获取比例
|
|
|
- BigDecimal ratioAmount = activity.getMarketPrice().divide(totalMarketPrice, 6, BigDecimal.ROUND_HALF_UP);
|
|
|
- //获取分配的减免金额
|
|
|
- BigDecimal multiply = ratioAmount.multiply(couponRemitFee).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
- subCouponRemitFee = subCouponRemitFee.subtract(multiply);
|
|
|
- activityUserMapper.setActualPrice(activity.getMarketPrice().subtract(multiply));
|
|
|
- }
|
|
|
- } else {
|
|
|
- activityUserMapper.setActualPrice(activity.getMarketPrice());
|
|
|
- }
|
|
|
- activityUserMappers.add(activityUserMapper);
|
|
|
- times = times + activity.getGivePrizeNum();
|
|
|
- //是否进入课程余额
|
|
|
- if (activity.isPayToBalance()) {
|
|
|
- boolean appendCourseBalance = sysUserCashAccountService.appendCourseBalance(userId, activityUserMapper.getActualPrice(), PlatformCashAccountDetailTypeEnum.PAY_FEE, "2021双11活动");
|
|
|
- if (!appendCourseBalance) {
|
|
|
- throw new BizException("增加用户课程余额失败");
|
|
|
- }
|
|
|
- }
|
|
|
- if (!activity.getCode().equals(5)) {
|
|
|
- if (order.getCreateTime().compareTo(startTime) >= 0 && order.getCreateTime().compareTo(endTime) <= 0) {
|
|
|
- //赠送一次抽奖机会
|
|
|
- luckDrawCountService.freeGive(order.getUserId().longValue(), 1, 2);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- //赠送抽奖机会
|
|
|
- if (times > 0) {
|
|
|
- luckDrawCountService.freeGive(order.getUserId().longValue(), times, 2);
|
|
|
- }
|
|
|
- activityUserMapperService.batchInsert(activityUserMappers);
|
|
|
-
|
|
|
- SysUserCashAccount sysUserCashAccount = sysUserCashAccountService.get(userId);
|
|
|
- //插入缴费明细
|
|
|
- //收入
|
|
|
- SysUserCashAccountDetail sysUserIncomeCashAccountDetail = new SysUserCashAccountDetail();
|
|
|
- sysUserIncomeCashAccountDetail.setUserId(order.getUserId());
|
|
|
- sysUserIncomeCashAccountDetail.setType(PlatformCashAccountDetailTypeEnum.RECHARGE);
|
|
|
- sysUserIncomeCashAccountDetail.setStatus(DealStatusEnum.SUCCESS);
|
|
|
- sysUserIncomeCashAccountDetail.setAmount(order.getActualAmount());
|
|
|
- sysUserIncomeCashAccountDetail.setBalance(sysUserCashAccount.getBalance().add(order.getActualAmount()));
|
|
|
- sysUserIncomeCashAccountDetail.setAttribute(order.getTransNo());
|
|
|
- sysUserIncomeCashAccountDetail.setChannel(studentPaymentOrder.getPaymentChannel());
|
|
|
- sysUserIncomeCashAccountDetail.setComAmount(studentPaymentOrder.getComAmount());
|
|
|
- sysUserIncomeCashAccountDetail.setPerAmount(studentPaymentOrder.getPerAmount());
|
|
|
- //支出
|
|
|
- SysUserCashAccountDetail sysUserExpendCashAccountDetail = new SysUserCashAccountDetail();
|
|
|
- sysUserExpendCashAccountDetail.setUserId(order.getUserId());
|
|
|
- sysUserExpendCashAccountDetail.setType(PlatformCashAccountDetailTypeEnum.PAY_FEE);
|
|
|
- sysUserExpendCashAccountDetail.setStatus(DealStatusEnum.SUCCESS);
|
|
|
- sysUserExpendCashAccountDetail.setAmount(order.getActualAmount().negate());
|
|
|
- sysUserExpendCashAccountDetail.setBalance(sysUserCashAccount.getBalance());
|
|
|
- sysUserExpendCashAccountDetail.setAttribute(order.getTransNo());
|
|
|
- sysUserExpendCashAccountDetail.setChannel(studentPaymentOrder.getPaymentChannel());
|
|
|
-
|
|
|
- if (studentPaymentOrder.getComAmount() != null) {
|
|
|
- sysUserIncomeCashAccountDetail.setComAmount(studentPaymentOrder.getComAmount().negate());
|
|
|
- }
|
|
|
- if (studentPaymentOrder.getPerAmount() != null) {
|
|
|
- sysUserExpendCashAccountDetail.setPerAmount(studentPaymentOrder.getPerAmount().negate());
|
|
|
- }
|
|
|
-
|
|
|
- sysUserCashAccountDetailService.insert(sysUserIncomeCashAccountDetail);
|
|
|
- sysUserCashAccountDetailService.insert(sysUserExpendCashAccountDetail);
|
|
|
-
|
|
|
- try {
|
|
|
- contractService.transferProduceContract(userId, null, null);
|
|
|
- } catch (Exception e) {
|
|
|
- LOGGER.error("产品协议生成失败", e);
|
|
|
- }
|
|
|
- studentDao.updateStudentServiceTag(userId, null, YesOrNoEnum.YES.getCode());
|
|
|
- //是否指定满足赠送会员的条件
|
|
|
- //是否赠送过会员
|
|
|
- String memberKey = "2021_double_eleven" + order.getUserId();
|
|
|
- Boolean aBoolean = redisCache.exists(memberKey);
|
|
|
- if (!aBoolean) {
|
|
|
- if (order.getCreateTime().compareTo(startTime) >= 0 && order.getCreateTime().compareTo(endTime) <= 0) {
|
|
|
- //赠送会员
|
|
|
- CloudTeacherOrder cloudTeacherOrder = new CloudTeacherOrder();
|
|
|
-// Date addDate = now;
|
|
|
-// if (student.getMemberRankSettingId() == null || now.after(student.getMembershipEndTime())) {
|
|
|
-// cloudTeacherOrder.setStartTime(now);
|
|
|
-// } else {
|
|
|
-// addDate = student.getMembershipEndTime();
|
|
|
-// cloudTeacherOrder.setStartTime(DateUtil.addDays(addDate, 1));
|
|
|
-// }
|
|
|
-// cloudTeacherOrder.setEndTime(DateUtil.addDays(DateUtil.addMonths(addDate, 1), 1));
|
|
|
- cloudTeacherOrder.setRemark("双十一活动赠送会员");
|
|
|
- cloudTeacherOrder.setStatus(1);
|
|
|
- cloudTeacherOrder.setOrderId(order.getId());
|
|
|
- cloudTeacherOrder.setType(PeriodEnum.MONTH);
|
|
|
- cloudTeacherOrder.setAmount(BigDecimal.ZERO);
|
|
|
- cloudTeacherOrder.setLevel(1);
|
|
|
- cloudTeacherOrder.setStudentId(userId);
|
|
|
- cloudTeacherOrder.setOrganId(order.getOrganId());
|
|
|
- cloudTeacherOrder.setTime(1);
|
|
|
- cloudTeacherOrderDao.insert(cloudTeacherOrder);
|
|
|
-// studentService.updateMemberRank(cloudTeacherOrder);
|
|
|
- redisCache.put(memberKey, userId);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if (studentPaymentOrder.getStatus().equals(DealStatusEnum.FAILED)) {
|
|
|
- if (studentPaymentOrder.getBalancePaymentAmount() != null && studentPaymentOrder.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- sysUserCashAccountService.updateBalance(studentPaymentOrder.getUserId(), studentPaymentOrder.getBalancePaymentAmount(), PlatformCashAccountDetailTypeEnum.REFUNDS, "报名缴费失败");
|
|
|
- }
|
|
|
- sysCouponCodeService.quit(studentPaymentOrder.getCouponCodeId());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
public List<PracticeCourseDto> findUserHistoryBuyPracticeGroups(Integer userId, Long groupId, PracticeGroupType type) {
|
|
|
List<PracticeCourseDto> userPracticeGroups;
|
|
|
if (Objects.nonNull(groupId)) {
|
|
@@ -5017,173 +4686,6 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
|
|
|
- public Object buyActivityPracticeGroup(PracticeGroupBuyParamsDto practiceGroupBuyParams) throws Exception {
|
|
|
- Integer activityId = practiceGroupBuyParams.getActivityId();
|
|
|
- VipGroupActivity activity = vipGroupActivityDao.get(activityId);
|
|
|
- Date now = new Date();
|
|
|
- Date startTime = activity.getStartTime();
|
|
|
- Date endTime = activity.getEndTime();
|
|
|
- if (startTime != null && startTime.compareTo(now) > 0) {
|
|
|
- throw new BizException("活动尚未开始,感谢您的关注");
|
|
|
- }
|
|
|
- if (endTime != null && endTime.compareTo(now) <= 0) {
|
|
|
- throw new BizException("活动已结束,感谢您的参与");
|
|
|
- }
|
|
|
- Student student = studentDao.getLocked(practiceGroupBuyParams.getUserId());
|
|
|
- Integer studentMaxUsedTimes = activity.getStudentMaxUsedTimes();
|
|
|
- if (studentMaxUsedTimes != -1) {
|
|
|
- //获取活动购买次数
|
|
|
- int activityBuyNum = activityUserMapperService.countActivityBuyNum(activityId, practiceGroupBuyParams.getUserId());
|
|
|
- if (activityBuyNum >= studentMaxUsedTimes) {
|
|
|
- throw new BizException("当前活动最多课购买{}次,感谢您的参与", studentMaxUsedTimes);
|
|
|
- }
|
|
|
- }
|
|
|
- GroupType groupType;
|
|
|
- Integer buyNum = activity.getMinCourseNum();
|
|
|
- if (activity.getActivityType() == 1) {
|
|
|
- buyNum = practiceGroupBuyParams.getBuyMemberNum();
|
|
|
- groupType = GroupType.MEMBER;
|
|
|
- } else {
|
|
|
- if (activity.getCourseType().equals("VIP")) {
|
|
|
- groupType = GroupType.VIP;
|
|
|
- } else {
|
|
|
- groupType = GroupType.PRACTICE;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //判断用户是否已存在订单
|
|
|
- // 判断是否存在支付中的记录
|
|
|
- List<StudentPaymentOrder> list = studentPaymentOrderService.queryByCondition(groupType, null, student.getUserId(), DealStatusEnum.ING, OrderTypeEnum.ACTIVITY);
|
|
|
- if (list.size() > 0) {
|
|
|
- StudentPaymentOrder order = list.get(0);
|
|
|
- // 查询订单状态
|
|
|
- PayStatus payStatus = studentPaymentOrderService.queryPayStatus(order.getPaymentChannel(), order.getOrderNo(), order.getTransNo());
|
|
|
- if (payStatus == PayStatus.SUCCESSED) {
|
|
|
- throw new BizException("订单已支付成功,请勿重复支付");
|
|
|
- }/*else if(payStatus == PayStatus.PAYING){
|
|
|
- throw new BizException("订单还在交易中,请稍后重试");
|
|
|
- }*/
|
|
|
- if (practiceGroupBuyParams.isRepeatPay()) {
|
|
|
- //处理关闭订单
|
|
|
- order.setStatus(DealStatusEnum.CLOSE);
|
|
|
- order.setMemo("关闭活动订单");
|
|
|
- if (order.getBalancePaymentAmount() != null && order.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- sysUserCashAccountService.updateBalance(order.getUserId(), order.getBalancePaymentAmount(),
|
|
|
- PlatformCashAccountDetailTypeEnum.REFUNDS, "购买活动支付失败");
|
|
|
- }
|
|
|
- studentPaymentOrderService.update(order);
|
|
|
- sysCouponCodeService.quit(order.getCouponCodeId());
|
|
|
- } else {
|
|
|
- return BaseController.failed(HttpStatus.CONTINUE, "您有待支付的订单");
|
|
|
- }
|
|
|
- }
|
|
|
- BigDecimal activityFee = activity.getMarketPrice();
|
|
|
- if (groupType == GroupType.MEMBER) {
|
|
|
- MemberFeeSetting memberFeeSetting = memberFeeSettingDao.findByRankIdAndOrganId(practiceGroupBuyParams.getOrganId(), 1);
|
|
|
- PeriodEnum periodEnum = activity.getPeriodEnum();
|
|
|
- switch (periodEnum) {
|
|
|
- case DAY:
|
|
|
- activityFee = memberFeeSetting.getCurrentDayFee().multiply(new BigDecimal(buyNum));
|
|
|
- break;
|
|
|
- case MONTH:
|
|
|
- activityFee = memberFeeSetting.getCurrentMonthFee().multiply(new BigDecimal(buyNum));
|
|
|
- break;
|
|
|
- case QUARTERLY:
|
|
|
- activityFee = memberFeeSetting.getCurrentQuarterlyFee().multiply(new BigDecimal(buyNum));
|
|
|
- break;
|
|
|
- case YEAR_HALF:
|
|
|
- activityFee = memberFeeSetting.getCurrentHalfYearFee().multiply(new BigDecimal(buyNum));
|
|
|
- break;
|
|
|
- case YEAR:
|
|
|
- activityFee = memberFeeSetting.getCurrentYearFee().multiply(new BigDecimal(buyNum));
|
|
|
- break;
|
|
|
- default:
|
|
|
- throw new BizException("错误的会员周期");
|
|
|
- }
|
|
|
- activityFee = activityFee.multiply(activity.getDiscount()).divide(new BigDecimal(100), CommonConstants.DECIMAL_PLACE, ROUND_DOWN);
|
|
|
- }
|
|
|
- //计算订单金额
|
|
|
- StudentPaymentOrder studentPaymentOrder = sysCouponCodeService.use(practiceGroupBuyParams.getCouponIdList(), activityFee, true);
|
|
|
- activityFee = studentPaymentOrder.getActualAmount();
|
|
|
- if (practiceGroupBuyParams.getAmount().compareTo(activityFee) != 0) {
|
|
|
- throw new BizException("非法访问");
|
|
|
- }
|
|
|
-
|
|
|
- String channelType = "";
|
|
|
- Date nowDate = new Date();
|
|
|
-
|
|
|
- BigDecimal balance = BigDecimal.ZERO;
|
|
|
- if (practiceGroupBuyParams.isUseBalancePayment() && activityFee.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(student.getUserId());
|
|
|
- if (userCashAccount == null) {
|
|
|
- throw new BizException("用户账户找不到");
|
|
|
- }
|
|
|
- if (userCashAccount.getBalance() != null && userCashAccount.getBalance().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- balance = activityFee.compareTo(userCashAccount.getBalance()) >= 0 ? userCashAccount.getBalance() : activityFee;
|
|
|
- activityFee = activityFee.subtract(balance);
|
|
|
- studentPaymentOrder.setActualAmount(activityFee);
|
|
|
- studentPaymentOrder.setBalancePaymentAmount(balance);
|
|
|
- sysUserCashAccountService.updateBalance(student.getUserId(), balance.negate(), PlatformCashAccountDetailTypeEnum.PAY_FEE, "营销活动购买");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- String orderNo = idGeneratorService.generatorId("payment") + "";
|
|
|
-
|
|
|
- studentPaymentOrder.setPaymentChannel("BALANCE");
|
|
|
- studentPaymentOrder.setUserId(student.getUserId());
|
|
|
- studentPaymentOrder.setGroupType(groupType);
|
|
|
- studentPaymentOrder.setOrderNo(orderNo);
|
|
|
- studentPaymentOrder.setType(OrderTypeEnum.ACTIVITY);
|
|
|
- studentPaymentOrder.setStatus(DealStatusEnum.ING);
|
|
|
- studentPaymentOrder.setRemitFee(BigDecimal.ZERO);
|
|
|
- studentPaymentOrder.setCourseRemitFee(BigDecimal.ZERO);
|
|
|
- studentPaymentOrder.setOrganId(practiceGroupBuyParams.getOrganId());
|
|
|
- studentPaymentOrder.setRoutingOrganId(practiceGroupBuyParams.getOrganId());
|
|
|
- studentPaymentOrder.setCreateTime(nowDate);
|
|
|
- studentPaymentOrder.setUpdateTime(nowDate);
|
|
|
- studentPaymentOrder.setActivityId(activityId.toString());
|
|
|
- studentPaymentOrder.setActivityBuyNum(buyNum);
|
|
|
- studentPaymentOrderService.insert(studentPaymentOrder);
|
|
|
-
|
|
|
- studentPaymentOrder.setVersion(0);
|
|
|
- if (activityFee.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
- studentPaymentRouteOrderService.addRouteOrder(orderNo, practiceGroupBuyParams.getOrganId(), balance);
|
|
|
- Map<String, String> notifyMap = new HashMap<>();
|
|
|
- notifyMap.put("tradeState", "1");
|
|
|
- notifyMap.put("merOrderNo", studentPaymentOrder.getOrderNo());
|
|
|
- notifyMap.put("channelType", channelType);
|
|
|
- notifyMap.put("orderNo", "");
|
|
|
- studentPaymentOrderService.updateOrder(notifyMap);
|
|
|
- return notifyMap;
|
|
|
- }
|
|
|
-
|
|
|
- String orderSubject = "营销活动";
|
|
|
- String receiver = "activity";
|
|
|
-
|
|
|
- String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
|
|
|
-
|
|
|
- Map payMap = payService.getPayMap(
|
|
|
- activityFee,
|
|
|
- balance,
|
|
|
- orderNo,
|
|
|
- baseApiUrl + "/api-student/studentOrder/notify",
|
|
|
- baseApiUrl + "/api-student/studentOrder/paymentResult?orderNo=" + orderNo,
|
|
|
- orderSubject,
|
|
|
- orderSubject,
|
|
|
- studentPaymentOrder.getOrganId(),
|
|
|
- receiver
|
|
|
- );
|
|
|
-
|
|
|
- studentPaymentOrder.setOrganId(studentPaymentOrder.getOrganId());
|
|
|
- studentPaymentOrder.setMerNos((String) payMap.get("routingMerNos"));
|
|
|
- studentPaymentOrder.setPaymentChannel((String) payMap.get("type"));
|
|
|
- studentPaymentOrder.setUpdateTime(nowDate);
|
|
|
- studentPaymentOrderService.update(studentPaymentOrder);
|
|
|
- return payMap;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
public StudentVipGroupDetailDto getPracticeGroupDetail(Long groupId) {
|
|
|
return practiceGroupDao.getPracticeGroupDetail(groupId);
|
|
|
}
|
|
@@ -5213,137 +4715,6 @@ public class PracticeGroupServiceImpl extends BaseServiceImpl<Long, PracticeGrou
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
|
|
|
- public HttpResponseResult buyDoubleEleven2021(BuyDoubleEleven2021Dto buyDoubleEleven2021Dto) throws Exception {
|
|
|
- String activityIdList = buyDoubleEleven2021Dto.getActivityIdList();
|
|
|
- List<VipGroupActivity> vipGroupActivities = vipGroupActivityDao.queryByIds(activityIdList);
|
|
|
- Date now = new Date();
|
|
|
- Student student = studentDao.getLocked(buyDoubleEleven2021Dto.getUserId());
|
|
|
- BigDecimal activityFee = ZERO;
|
|
|
- for (int i = 0; i < vipGroupActivities.size(); i++) {
|
|
|
- VipGroupActivity activity = vipGroupActivities.get(i);
|
|
|
- Date startTime = activity.getStartTime();
|
|
|
- Date endTime = activity.getEndTime();
|
|
|
- if (startTime != null && startTime.compareTo(now) > 0) {
|
|
|
- throw new BizException("活动尚未开始,感谢您的关注");
|
|
|
- }
|
|
|
- if (endTime != null && endTime.compareTo(now) <= 0) {
|
|
|
- throw new BizException("活动已结束,感谢您的参与");
|
|
|
- }
|
|
|
- Integer studentMaxUsedTimes = activity.getStudentMaxUsedTimes();
|
|
|
- if (studentMaxUsedTimes != -1) {
|
|
|
- //获取活动购买次数
|
|
|
- int activityBuyNum = activityUserMapperService.countActivityBuyNum(activity.getId(), buyDoubleEleven2021Dto.getUserId());
|
|
|
- if (activityBuyNum >= studentMaxUsedTimes) {
|
|
|
- throw new BizException("{}活动最多课购买{}次,感谢您的参与", activity.getName(), studentMaxUsedTimes);
|
|
|
- }
|
|
|
- }
|
|
|
- activityFee = activityFee.add(activity.getMarketPrice());
|
|
|
- }
|
|
|
-
|
|
|
- //判断用户是否已存在订单
|
|
|
- // 判断是否存在支付中的记录
|
|
|
- List<StudentPaymentOrder> list = studentPaymentOrderService.queryByCondition(GroupType.ACTIVITY, null, student.getUserId(), DealStatusEnum.ING, OrderTypeEnum.DOUBLE_ELEVEN2021);
|
|
|
- if (list.size() > 0) {
|
|
|
- StudentPaymentOrder order = list.get(0);
|
|
|
- // 查询订单状态
|
|
|
- PayStatus payStatus = studentPaymentOrderService.queryPayStatus(order.getPaymentChannel(), order.getOrderNo(), order.getTransNo());
|
|
|
- if (payStatus == PayStatus.SUCCESSED) {
|
|
|
- throw new BizException("订单已支付成功,请勿重复支付");
|
|
|
- }/*else if(payStatus == PayStatus.PAYING){
|
|
|
- throw new BizException("订单还在交易中,请稍后重试");
|
|
|
- }*/
|
|
|
- if (buyDoubleEleven2021Dto.isRepeatPay()) {
|
|
|
- //处理关闭订单
|
|
|
- order.setStatus(DealStatusEnum.CLOSE);
|
|
|
- order.setMemo("关闭2021双十一活动订单");
|
|
|
- if (order.getBalancePaymentAmount() != null && order.getBalancePaymentAmount().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- sysUserCashAccountService.updateBalance(order.getUserId(), order.getBalancePaymentAmount(),
|
|
|
- PlatformCashAccountDetailTypeEnum.REFUNDS, "2021双十一活动支付失败");
|
|
|
- }
|
|
|
- studentPaymentOrderService.update(order);
|
|
|
- sysCouponCodeService.quit(order.getCouponCodeId());
|
|
|
- } else {
|
|
|
- return BaseController.failed(HttpStatus.CONTINUE, "您有待支付的订单,是否继续支付");
|
|
|
- }
|
|
|
- }
|
|
|
- //计算订单金额
|
|
|
- StudentPaymentOrder studentPaymentOrder = sysCouponCodeService.use(buyDoubleEleven2021Dto.getCouponIdList(), activityFee, true);
|
|
|
- activityFee = studentPaymentOrder.getActualAmount();
|
|
|
-
|
|
|
- String channelType = "";
|
|
|
- Date nowDate = new Date();
|
|
|
-
|
|
|
- BigDecimal balance = BigDecimal.ZERO;
|
|
|
- if (buyDoubleEleven2021Dto.isUseBalancePayment() && activityFee.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(student.getUserId());
|
|
|
- if (userCashAccount == null) {
|
|
|
- throw new BizException("用户账户找不到");
|
|
|
- }
|
|
|
- if (userCashAccount.getBalance() != null && userCashAccount.getBalance().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- balance = activityFee.compareTo(userCashAccount.getBalance()) >= 0 ? userCashAccount.getBalance() : activityFee;
|
|
|
- activityFee = activityFee.subtract(balance);
|
|
|
- studentPaymentOrder.setActualAmount(activityFee);
|
|
|
- studentPaymentOrder.setBalancePaymentAmount(balance);
|
|
|
- sysUserCashAccountService.updateBalance(student.getUserId(), balance.negate(), PlatformCashAccountDetailTypeEnum.PAY_FEE, "2021双十一活动购买");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- String orderNo = idGeneratorService.generatorId("payment") + "";
|
|
|
-
|
|
|
- studentPaymentOrder.setPaymentChannel("BALANCE");
|
|
|
- studentPaymentOrder.setUserId(student.getUserId());
|
|
|
- studentPaymentOrder.setGroupType(GroupType.ACTIVITY);
|
|
|
- studentPaymentOrder.setOrderNo(orderNo);
|
|
|
- studentPaymentOrder.setType(OrderTypeEnum.DOUBLE_ELEVEN2021);
|
|
|
- studentPaymentOrder.setStatus(DealStatusEnum.ING);
|
|
|
- studentPaymentOrder.setRemitFee(BigDecimal.ZERO);
|
|
|
- studentPaymentOrder.setCourseRemitFee(BigDecimal.ZERO);
|
|
|
- studentPaymentOrder.setOrganId(buyDoubleEleven2021Dto.getOrganId());
|
|
|
- studentPaymentOrder.setRoutingOrganId(buyDoubleEleven2021Dto.getOrganId());
|
|
|
- studentPaymentOrder.setActivityId(activityIdList);
|
|
|
- studentPaymentOrder.setCreateTime(nowDate);
|
|
|
- studentPaymentOrder.setUpdateTime(nowDate);
|
|
|
- studentPaymentOrderService.insert(studentPaymentOrder);
|
|
|
-
|
|
|
- studentPaymentOrder.setVersion(0);
|
|
|
- if (activityFee.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
- studentPaymentRouteOrderService.addRouteOrder(orderNo, buyDoubleEleven2021Dto.getOrganId(), balance);
|
|
|
- Map<String, String> notifyMap = new HashMap<>();
|
|
|
- notifyMap.put("tradeState", "1");
|
|
|
- notifyMap.put("merOrderNo", studentPaymentOrder.getOrderNo());
|
|
|
- notifyMap.put("channelType", channelType);
|
|
|
- notifyMap.put("orderNo", "");
|
|
|
- studentPaymentOrderService.updateOrder(notifyMap);
|
|
|
- return BaseController.failed(HttpStatus.CREATED, notifyMap, "恭喜您,购买成功!");
|
|
|
- }
|
|
|
-
|
|
|
- String orderSubject = "2021双十一活动";
|
|
|
- String receiver = "vip";
|
|
|
-
|
|
|
- String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
|
|
|
-
|
|
|
- Map payMap = payService.getPayMap(
|
|
|
- activityFee,
|
|
|
- balance,
|
|
|
- orderNo,
|
|
|
- baseApiUrl + "/api-student/studentOrder/notify",
|
|
|
- baseApiUrl + "/api-student/studentOrder/paymentResult?orderNo=" + orderNo,
|
|
|
- orderSubject,
|
|
|
- orderSubject,
|
|
|
- studentPaymentOrder.getOrganId(),
|
|
|
- receiver
|
|
|
- );
|
|
|
-
|
|
|
- studentPaymentOrder.setOrganId(studentPaymentOrder.getOrganId());
|
|
|
- studentPaymentOrder.setMerNos((String) payMap.get("routingMerNos"));
|
|
|
- studentPaymentOrder.setPaymentChannel((String) payMap.get("type"));
|
|
|
- studentPaymentOrder.setUpdateTime(nowDate);
|
|
|
- studentPaymentOrderService.update(studentPaymentOrder);
|
|
|
- return BaseController.succeed(payMap);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
public Map<String, BigDecimal> getStudentSurplusCourseFee(Long practiceGroupId) {
|
|
|
if (Objects.isNull(practiceGroupId)) {
|
|
|
throw new BizException("请指定课程");
|