|
@@ -1,20 +1,14 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
import com.ym.mec.auth.api.entity.SysUser;
|
|
|
-import com.ym.mec.biz.dal.dao.ChildrenDayReserveDao;
|
|
|
-import com.ym.mec.biz.dal.dao.DegreeLevelFeeDao;
|
|
|
-import com.ym.mec.biz.dal.dao.MusicGroupDao;
|
|
|
-import com.ym.mec.biz.dal.dto.ChildrenStatisticsDetailDto;
|
|
|
-import com.ym.mec.biz.dal.dto.ChildrenStatisticsDto;
|
|
|
-import com.ym.mec.biz.dal.dao.OrganizationDegreeCourseFeeDao;
|
|
|
-import com.ym.mec.biz.dal.dto.DegreeFeeDto;
|
|
|
-import com.ym.mec.biz.dal.entity.ChildrenDayReserve;
|
|
|
-import com.ym.mec.biz.dal.entity.DegreeLevelFee;
|
|
|
-import com.ym.mec.biz.dal.entity.MusicGroup;
|
|
|
-import com.ym.mec.biz.dal.entity.OrganizationDegreeCourseFee;
|
|
|
-import com.ym.mec.biz.dal.enums.YesOrNoEnum;
|
|
|
+import com.ym.mec.biz.dal.dao.*;
|
|
|
+import com.ym.mec.biz.dal.dto.*;
|
|
|
+import com.ym.mec.biz.dal.entity.*;
|
|
|
+import com.ym.mec.biz.dal.enums.*;
|
|
|
import com.ym.mec.biz.dal.page.ChildrenReserveQueryInfo;
|
|
|
+import com.ym.mec.biz.service.ChildrenDayDegreeDetailService;
|
|
|
import com.ym.mec.biz.service.ChildrenDayReserveService;
|
|
|
+import com.ym.mec.biz.service.StudentPaymentOrderService;
|
|
|
import com.ym.mec.common.dal.BaseDAO;
|
|
|
import com.ym.mec.common.exception.BizException;
|
|
|
import com.ym.mec.common.page.PageInfo;
|
|
@@ -22,13 +16,13 @@ import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.*;
|
|
|
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
|
public class ChildrenDayReserveServiceImpl extends BaseServiceImpl<Integer, ChildrenDayReserve> implements ChildrenDayReserveService {
|
|
@@ -41,6 +35,12 @@ public class ChildrenDayReserveServiceImpl extends BaseServiceImpl<Integer, Chil
|
|
|
private DegreeLevelFeeDao degreeLevelFeeDao;
|
|
|
@Autowired
|
|
|
private OrganizationDegreeCourseFeeDao organizationDegreeCourseFeeDao;
|
|
|
+ @Autowired
|
|
|
+ private StudentDao studentDao;
|
|
|
+ @Autowired
|
|
|
+ private ChildrenDayDegreeDetailService childrenDayDegreeDetailService;
|
|
|
+ @Autowired
|
|
|
+ private StudentPaymentOrderService studentPaymentOrderService;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Integer, ChildrenDayReserve> getDAO() {
|
|
@@ -78,7 +78,7 @@ public class ChildrenDayReserveServiceImpl extends BaseServiceImpl<Integer, Chil
|
|
|
MapUtil.populateMap(params, queryInfo);
|
|
|
|
|
|
List<ChildrenStatisticsDto> dataList = null;
|
|
|
- int count = childrenDayReserveDao.countChildrenStatistics(params);;
|
|
|
+ int count = childrenDayReserveDao.countChildrenStatistics(params);
|
|
|
if (count > 0) {
|
|
|
pageInfo.setTotal(count);
|
|
|
params.put("offset", pageInfo.getOffset());
|
|
@@ -108,7 +108,7 @@ public class ChildrenDayReserveServiceImpl extends BaseServiceImpl<Integer, Chil
|
|
|
MapUtil.populateMap(params, queryInfo);
|
|
|
|
|
|
List<ChildrenStatisticsDetailDto> dataList = null;
|
|
|
- int count = childrenDayReserveDao.countChildrenStatisticsDetail(params);;
|
|
|
+ int count = childrenDayReserveDao.countChildrenStatisticsDetail(params);
|
|
|
if (count > 0) {
|
|
|
pageInfo.setTotal(count);
|
|
|
params.put("offset", pageInfo.getOffset());
|
|
@@ -120,4 +120,137 @@ public class ChildrenDayReserveServiceImpl extends BaseServiceImpl<Integer, Chil
|
|
|
pageInfo.setRows(dataList);
|
|
|
return pageInfo;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Map pay(DegreePayDto degreePayDto) throws Exception {
|
|
|
+ studentDao.lockUser(degreePayDto.getUserId());
|
|
|
+
|
|
|
+ if (degreePayDto.getTheoryLevel() != null && !degreePayDto.getTheoryCourse()) {
|
|
|
+ throw new BizException("参加乐理考试,请选乐理考级专项训练课");
|
|
|
+ }
|
|
|
+
|
|
|
+ //检查进行中的订单
|
|
|
+ List<ChildrenDayDegreeDetail> details = childrenDayDegreeDetailService.getByUserIdAndStatus(degreePayDto.getUserId(), 1);
|
|
|
+
|
|
|
+ //处理关闭订单
|
|
|
+ if (details.size() > 0 && degreePayDto.getRePay()) {
|
|
|
+ Long orderId = details.get(0).getOrderId();
|
|
|
+ StudentPaymentOrder oldOrder = studentPaymentOrderService.get(orderId);
|
|
|
+ if (oldOrder != null) {
|
|
|
+ oldOrder.setStatus(DealStatusEnum.FAILED);
|
|
|
+ oldOrder.setMemo("用户手动关闭");
|
|
|
+ studentPaymentOrderService.callOrderCallBack(oldOrder);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //检查已经购买的课程(不能重复)
|
|
|
+ details = childrenDayDegreeDetailService.getByUserIdAndStatus(degreePayDto.getUserId(), 2);
|
|
|
+ Set<Integer> detailTypes = details.stream().map(ChildrenDayDegreeDetail::getType).collect(Collectors.toSet());
|
|
|
+ if (degreePayDto.getVip1v1() && detailTypes.contains(3)) {
|
|
|
+ throw new BizException("您已购买过VIP 1V1课程,请勿重复选择");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (degreePayDto.getVip1v2() && detailTypes.contains(4)) {
|
|
|
+ throw new BizException("您已购买过VIP 1V2课程,请勿重复选择");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (degreePayDto.getVip1v2() && detailTypes.contains(5)) {
|
|
|
+ throw new BizException("您已购买过乐理考级专项训练课,请勿重复选择");
|
|
|
+ }
|
|
|
+ //检查考级等级是否重复
|
|
|
+ if (degreePayDto.getMusicGradeLevel() != null) {
|
|
|
+
|
|
|
+ }
|
|
|
+ //获取课程的价格
|
|
|
+ OrganizationDegreeCourseFee courseFee = organizationDegreeCourseFeeDao.getByOrganId(degreePayDto.getOrganId());
|
|
|
+//
|
|
|
+//
|
|
|
+// Goods goods = goodsDao.get(replacementInstrumentActivity.getInstrumentsId());
|
|
|
+// BigDecimal orderAmount = goods.getGroupPurchasePrice();
|
|
|
+// BigDecimal amount = replacementPayDto.getAmount(); //扣除余额之前的金额
|
|
|
+// if (amount.compareTo(orderAmount) != 0) {
|
|
|
+// throw new BizException("商品价格不符");
|
|
|
+// }
|
|
|
+//
|
|
|
+// String channelType = "";
|
|
|
+// Date nowDate = new Date();
|
|
|
+//
|
|
|
+// BigDecimal balance = BigDecimal.ZERO;
|
|
|
+// if (replacementPayDto.getUseBalance() && amount.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+// SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(userId);
|
|
|
+// if (userCashAccount == null) {
|
|
|
+// throw new BizException("用户账户找不到");
|
|
|
+// }
|
|
|
+// if (userCashAccount.getBalance() != null && userCashAccount.getBalance().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+// balance = amount.compareTo(userCashAccount.getBalance()) >= 0 ? userCashAccount.getBalance() : amount;
|
|
|
+// amount = amount.subtract(balance);
|
|
|
+// sysUserCashAccountService.updateBalance(userId, balance.negate(), PlatformCashAccountDetailTypeEnum.PAY_FEE, "乐保购买");
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// CooperationOrgan cooperationOrgan = cooperationOrganDao.get(replacementInstrumentActivity.getCooperationOrganId());
|
|
|
+//
|
|
|
+// String orderNo = idGeneratorService.generatorId("payment") + "";
|
|
|
+// StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
|
|
|
+//
|
|
|
+// studentPaymentOrder.setPaymentChannel("BALANCE");
|
|
|
+// studentPaymentOrder.setUserId(userId);
|
|
|
+// studentPaymentOrder.setGroupType(GroupType.REPLACEMENT);
|
|
|
+// studentPaymentOrder.setOrderNo(orderNo);
|
|
|
+// studentPaymentOrder.setType(OrderTypeEnum.REPLACEMENT);
|
|
|
+// studentPaymentOrder.setExpectAmount(orderAmount);
|
|
|
+// studentPaymentOrder.setActualAmount(amount);
|
|
|
+// studentPaymentOrder.setBalancePaymentAmount(balance);
|
|
|
+// studentPaymentOrder.setStatus(DealStatusEnum.ING);
|
|
|
+// studentPaymentOrder.setMusicGroupId(replacementInstrumentActivity.getId().toString());
|
|
|
+// studentPaymentOrder.setRemitFee(BigDecimal.ZERO);
|
|
|
+// studentPaymentOrder.setCourseRemitFee(BigDecimal.ZERO);
|
|
|
+// studentPaymentOrder.setOrganId(cooperationOrgan.getOrganId());
|
|
|
+// studentPaymentOrder.setRoutingOrganId(cooperationOrgan.getOrganId());
|
|
|
+// studentPaymentOrder.setCreateTime(nowDate);
|
|
|
+// studentPaymentOrder.setUpdateTime(nowDate);
|
|
|
+// studentPaymentOrderService.insert(studentPaymentOrder);
|
|
|
+// //修改支付状态
|
|
|
+// replacementInstrumentActivity.setPayStatus(1);
|
|
|
+// replacementInstrumentActivity.setUpdateTime(nowDate);
|
|
|
+// replacementInstrumentActivityDao.update(replacementInstrumentActivity);
|
|
|
+//
|
|
|
+// studentPaymentOrder.setVersion(0);
|
|
|
+// if (amount.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+// studentPaymentRouteOrderService.addRouteOrder(orderNo, cooperationOrgan.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 = "replacement";
|
|
|
+//
|
|
|
+// String baseApiUrl = sysConfigDao.findConfigValue("base_api_url");
|
|
|
+//
|
|
|
+// Map payMap = payService.getPayMap(
|
|
|
+// amount,
|
|
|
+// balance,
|
|
|
+// orderNo,
|
|
|
+// baseApiUrl + "/api-student/studentOrder/notify",
|
|
|
+// baseApiUrl + "/api-student/studentOrder/paymentResult?orderNo=" + orderNo,
|
|
|
+// orderSubject,
|
|
|
+// orderSubject,
|
|
|
+// cooperationOrgan.getOrganId(),
|
|
|
+// receiver
|
|
|
+// );
|
|
|
+//
|
|
|
+// studentPaymentOrder.setOrganId(cooperationOrgan.getOrganId());
|
|
|
+// studentPaymentOrder.setMerNos((String) payMap.get("routingMerNos"));
|
|
|
+// studentPaymentOrder.setPaymentChannel((String) payMap.get("type"));
|
|
|
+// studentPaymentOrder.setUpdateTime(nowDate);
|
|
|
+// studentPaymentOrderService.update(studentPaymentOrder);
|
|
|
+ Map<Object, Object> payMap = new HashMap<>();
|
|
|
+ return payMap;
|
|
|
+ }
|
|
|
}
|