Bladeren bron

云教练活动

zouxuan 3 jaren geleden
bovenliggende
commit
d4fa404c50

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/MemberRankSettingService.java

@@ -48,5 +48,5 @@ public interface MemberRankSettingService extends BaseService<Integer, MemberRan
 	 */
 	boolean orderCallback(StudentPaymentOrder studentPaymentOrder);
 
-	Object ActiveBuy(Integer id, Integer memberRankId, PeriodEnum month, BigDecimal amount, boolean isUseBalance, Integer buyNum, int giveNum, int activeRemark, String remark) throws Exception;
+	Object ActiveBuy(Integer id, Integer memberRankId, PeriodEnum month, BigDecimal amount, boolean isUseBalance, Integer buyNum, int giveNum, int activeRemark, String remark,boolean repay) throws Exception;
 }

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MemberRankSettingServiceImpl.java

@@ -12,6 +12,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Isolation;
 import org.springframework.transaction.annotation.Propagation;
@@ -412,7 +413,7 @@ public class MemberRankSettingServiceImpl extends BaseServiceImpl<Integer, Membe
 
 	@Override
 	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class,isolation = Isolation.READ_COMMITTED)
-	public Object ActiveBuy(Integer userId, Integer memberRankId, PeriodEnum month, BigDecimal amount, boolean isUseBalance, Integer buyNum, int giveNum, int activeRemark, String remark) throws Exception {
+	public Object ActiveBuy(Integer userId, Integer memberRankId, PeriodEnum month, BigDecimal amount, boolean isUseBalance, Integer buyNum, int giveNum, int activeRemark, String remark,boolean repay) throws Exception {
 		//判断用户是否已存在订单
 		StudentPaymentOrder applyOrder = studentPaymentOrderService.findByUserAndActive(userId,202109,remark,"ING");
 		if (applyOrder != null) {

+ 16 - 3
mec-student/src/main/java/com/ym/mec/student/controller/MemberRankController.java

@@ -88,7 +88,7 @@ public class MemberRankController extends BaseController {
 
 	@ApiOperation(value = "2021-09活动购买会员")
 	@PostMapping("/activeBuy")
-	public Object ActiveBuy(Integer memberRankId, Integer buyNum, BigDecimal amount, boolean isUseBalance) throws Exception {
+	public Object ActiveBuy(Integer memberRankId, Integer buyNum, BigDecimal amount, boolean isUseBalance,boolean repay) throws Exception {
 		Date nowTime = new Date();
 		String startTimeStr = sysConfigDao.findConfigValue("cloud_teacher_active_start_time");
 		Date startTime = DateUtil.stringToDate(startTimeStr);
@@ -104,10 +104,23 @@ public class MemberRankController extends BaseController {
 		if (sysUser == null) {
 			return failed(HttpStatus.FORBIDDEN, "请登录");
 		}
-
 		//买2赠1、买3赠2
 		int giveNum = buyNum == 2?1:buyNum == 3?2:0;
 		String remark = buyNum == 2?"2赠1":buyNum == 3?"3赠2":buyNum == 1?"单月":"其他";
+		//判断用户是否已存在订单
+		StudentPaymentOrder applyOrder = studentPaymentOrderService.findByUserAndActive(sysUser.getId(),202109,remark,"ING");
+		if (applyOrder != null) {
+			// 查询订单状态
+			PayStatus payStatus = studentPaymentOrderService.queryPayStatus(applyOrder.getPaymentChannel(), applyOrder.getOrderNo(), applyOrder.getTransNo());
+			if(payStatus == PayStatus.SUCCESSED){
+				throw new BizException("订单已支付成功,请勿重复支付");
+			}else if(payStatus == PayStatus.PAYING){
+				throw new BizException("订单还在交易中,请稍后重试");
+			}
+			if(!repay){
+				return failed(HttpStatus.CONTINUE, "您有待支付的订单");
+			}
+		}
 		return succeed(memberRankSettingService.ActiveBuy(sysUser.getId(),
 				memberRankId,
 				PeriodEnum.MONTH,
@@ -115,7 +128,7 @@ public class MemberRankController extends BaseController {
 				isUseBalance,
 				buyNum,
 				giveNum,
-				202109,remark));
+				202109,remark,repay));
 	}
 	
     @ApiOperation(value = "查询订单列表")