yonge 5 سال پیش
والد
کامیت
b28c7211db

+ 3 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/TenantPaymentOrderService.java

@@ -1,9 +1,8 @@
 package com.ym.mec.biz.service;
 
-import java.util.Map;
-
 import com.ym.mec.biz.dal.entity.TenantPaymentOrder;
 import com.ym.mec.biz.dal.page.TenantPaymentOrderQueryInfo;
+import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.service.BaseService;
 
 public interface TenantPaymentOrderService extends BaseService<Long, TenantPaymentOrder> {
@@ -12,9 +11,10 @@ public interface TenantPaymentOrderService extends BaseService<Long, TenantPayme
 	 * 下单
 	 * @param userId
 	 * @param activitiesId
+	 * @param isContinuePay 是否继续付款
 	 * @return
 	 */
-	public Map<String, Object> createOrder(Integer userId, Integer activitiesId);
+	public HttpResponseResult createOrder(Integer userId, Integer activitiesId, boolean isContinuePay);
 
 	/**
 	 * 回调

+ 30 - 18
mec-biz/src/main/java/com/ym/mec/biz/service/impl/TenantPaymentOrderServiceImpl.java

@@ -10,15 +10,10 @@ import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
 
-import com.ym.mec.biz.dal.dto.PageInfoOrder;
-import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
-import com.ym.mec.biz.dal.enums.PaymentChannelEnum;
-import com.ym.mec.biz.dal.page.TenantPaymentOrderQueryInfo;
-import com.ym.mec.common.page.PageInfo;
-import com.ym.mec.util.collection.MapUtil;
 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.Propagation;
 import org.springframework.transaction.annotation.Transactional;
@@ -29,6 +24,7 @@ import com.ym.mec.biz.dal.dao.SysConfigDao;
 import com.ym.mec.biz.dal.dao.TeacherDao;
 import com.ym.mec.biz.dal.dao.TenantEntryActivitiesDao;
 import com.ym.mec.biz.dal.dao.TenantPaymentOrderDao;
+import com.ym.mec.biz.dal.dto.PageInfoOrder;
 import com.ym.mec.biz.dal.entity.SysTenantAccountDetail.TransType;
 import com.ym.mec.biz.dal.entity.Teacher;
 import com.ym.mec.biz.dal.entity.TenantEntryActivities;
@@ -36,10 +32,13 @@ import com.ym.mec.biz.dal.entity.TenantEntryActivities.SuitableUser;
 import com.ym.mec.biz.dal.entity.TenantPaymentOrder;
 import com.ym.mec.biz.dal.entity.TenantPaymentOrder.TenantPaymentType;
 import com.ym.mec.biz.dal.enums.DealStatusEnum;
+import com.ym.mec.biz.dal.enums.PaymentChannelEnum;
+import com.ym.mec.biz.dal.page.TenantPaymentOrderQueryInfo;
 import com.ym.mec.biz.service.PayService;
 import com.ym.mec.biz.service.SysTenantAccountService;
 import com.ym.mec.biz.service.TenantPaymentOrderService;
 import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.service.IdGeneratorService;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
@@ -48,6 +47,7 @@ import com.ym.mec.thirdparty.yqpay.Msg;
 import com.ym.mec.thirdparty.yqpay.RsqMsg;
 import com.ym.mec.thirdparty.yqpay.YqPayFeignService;
 import com.ym.mec.thirdparty.yqpay.YqPayUtil;
+import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.date.DateUtil;
 
 @Service
@@ -86,7 +86,7 @@ public class TenantPaymentOrderServiceImpl extends BaseServiceImpl<Long, TenantP
 
 	@Override
 	@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
-	public Map<String, Object> createOrder(Integer userId, Integer activitiesId) {
+	public HttpResponseResult createOrder(Integer userId, Integer activitiesId, boolean isContinuePay) {
 
 		Teacher teacher = teacherDao.get(userId);
 		if (teacher == null) {
@@ -118,15 +118,26 @@ public class TenantPaymentOrderServiceImpl extends BaseServiceImpl<Long, TenantP
 			for (TenantPaymentOrder po : orderList) {
 				// 是否满足条件
 				if (tenantEntryActivities.getSuitableUser() == SuitableUser.NEW) {
+					if (po.getStatus() == DealStatusEnum.SUCCESS) {
+						throw new BizException("首充优惠活动每个用户限参与一次。");
+					}
+
 					if (po.getStatus() == DealStatusEnum.ING) {
 						int i = 35 - DateUtil.minutesBetween(po.getCreateTime(), date);
-						if(i <= 0){
-							throw new BizException("您的订单出现异常,请联系客服");
+						if (i <= 0) {
+							throw new BizException("您有支付中的订单出现异常,请联系客服");
+						}
+						// throw new BizException("您参加的首充活动正在处理中,预计于{}分钟后处理完毕,请稍后。", i);
+						if (isContinuePay == false) {
+							HttpResponseResult result = new HttpResponseResult(true, HttpStatus.CONTINUE, "您存在支付中的订单,是否重新付款?", null);
+							return result;
+						} else {
+							// 关闭原订单
+							po.setStatus(DealStatusEnum.CLOSE);
+							po.setMemo("用户主动关闭");
+							po.setUpdateTime(date);
+							tenantPaymentOrderDao.update(po);
 						}
-						throw new BizException("您参加的首充活动正在处理中,预计于{}分钟后处理完毕,请稍后。", i);
-					}
-					if (po.getStatus() == DealStatusEnum.SUCCESS) {
-						throw new BizException("首充优惠活动每个用户限参与一次。");
 					}
 				}
 			}
@@ -160,7 +171,7 @@ public class TenantPaymentOrderServiceImpl extends BaseServiceImpl<Long, TenantP
 
 			Map<String, Object> payMap = payService.getPayMap(tenantPaymentOrder.getExpectAmount(), tenantPaymentOrder.getOrderNo(), baseApiUrl
 					+ "/api-teacher/teacherOrder/notify", baseApiUrl + "/api-teacher/teacherOrder/paymentResult?orderNo=" + tenantPaymentOrder.getOrderNo(),
-					"商户入驻", "商户充值", userId, classFee, organId,"sdaya");
+					"商户入驻", "商户充值", userId, classFee, organId, "sdaya");
 
 			Map<String, BigDecimal> routingFee = (Map<String, BigDecimal>) payMap.get("routingFee");
 			tenantPaymentOrder.setComAmount(routingFee.get("COM"));
@@ -170,7 +181,8 @@ public class TenantPaymentOrderServiceImpl extends BaseServiceImpl<Long, TenantP
 			tenantPaymentOrder.setUpdateTime(date);
 			tenantPaymentOrderDao.update(tenantPaymentOrder);
 
-			return payMap;
+			HttpResponseResult result = new HttpResponseResult(true, HttpStatus.OK, payMap, null);
+			return result;
 		} catch (Exception e) {
 			throw new BizException("调用支付接口出错", e);
 		}
@@ -350,9 +362,9 @@ public class TenantPaymentOrderServiceImpl extends BaseServiceImpl<Long, TenantP
 		int count = this.findCount(params);
 		if (count > 0) {
 			TenantPaymentOrder orderMoneyAmount = tenantPaymentOrderDao.getOrderMoneyAmount(params);
-			if(orderMoneyAmount != null){
-				pageInfo.setTotalExpectAmount(orderMoneyAmount.getExpectAmount() !=null? orderMoneyAmount.getExpectAmount():BigDecimal.ZERO);
-				pageInfo.setTotalActualAmount(orderMoneyAmount.getActualAmount() !=null? orderMoneyAmount.getActualAmount():BigDecimal.ZERO);
+			if (orderMoneyAmount != null) {
+				pageInfo.setTotalExpectAmount(orderMoneyAmount.getExpectAmount() != null ? orderMoneyAmount.getExpectAmount() : BigDecimal.ZERO);
+				pageInfo.setTotalActualAmount(orderMoneyAmount.getActualAmount() != null ? orderMoneyAmount.getActualAmount() : BigDecimal.ZERO);
 			}
 			pageInfo.setTotal(count);
 			params.put("offset", pageInfo.getOffset());

+ 9 - 0
mec-common/common-core/src/main/java/com/ym/mec/common/entity/HttpResponseResult.java

@@ -1,5 +1,7 @@
 package com.ym.mec.common.entity;
 
+import org.springframework.http.HttpStatus;
+
 /**
  * HttpResponse 返回结果
  */
@@ -19,6 +21,13 @@ public class HttpResponseResult {
 		this.code = code;
 	}
 
+	public HttpResponseResult(boolean status, HttpStatus resultCode, Object data, String message) {
+		this.status = status;
+		this.msg = message;
+		this.data = data;
+		this.code = resultCode.value();
+	}
+
 	public HttpResponseResult() {
 	}
 

+ 43 - 40
mec-teacher/src/main/java/com/ym/mec/teacher/controller/TenantPaymentOrderController.java

@@ -23,48 +23,51 @@ import com.ym.mec.common.controller.BaseController;
 @RestController
 public class TenantPaymentOrderController extends BaseController {
 
-    @Autowired
-    private SysUserFeignService sysUserFeignService;
-    
-    @Autowired
-    private TenantPaymentOrderService tenantPaymentOrderService;
+	@Autowired
+	private SysUserFeignService sysUserFeignService;
 
-    @ApiOperation(value = "下单")
-    @PostMapping("/createOrder")
-    public Object createOrder(Integer activitiesId){
-        SysUser sysUser = sysUserFeignService.queryUserInfo();
-        if(Objects.isNull(sysUser)){
-            return failed(HttpStatus.FORBIDDEN,"请登录");
-        }
-        return succeed(tenantPaymentOrderService.createOrder(sysUser.getId(), activitiesId));
-    }
+	@Autowired
+	private TenantPaymentOrderService tenantPaymentOrderService;
 
-    @ApiOperation(value = "查询订单")
-    @GetMapping("/query")
-    public Object query(long id){
-        SysUser sysUser = sysUserFeignService.queryUserInfo();
-        if(Objects.isNull(sysUser)){
-            return failed(HttpStatus.FORBIDDEN,"请登录");
-        }
-        TenantPaymentOrder order = tenantPaymentOrderService.get(id);
-        if(order == null){
-        	return failed("订单不存在");
-        }
-        return succeed(order);
-    }
+	@ApiOperation(value = "下单")
+	@PostMapping("/createOrder")
+	public Object createOrder(Integer activitiesId, Boolean isContinuePay) {
+		SysUser sysUser = sysUserFeignService.queryUserInfo();
+		if (Objects.isNull(sysUser)) {
+			return failed(HttpStatus.FORBIDDEN, "请登录");
+		}
+		if (isContinuePay == null) {
+			isContinuePay = false;
+		}
+		return tenantPaymentOrderService.createOrder(sysUser.getId(), activitiesId, isContinuePay);
+	}
 
-    @ApiOperation(value = "查询订单")
-    @GetMapping("/queryByOrderNo")
-    public Object query(String orderNo){
-        SysUser sysUser = sysUserFeignService.queryUserInfo();
-        if(Objects.isNull(sysUser)){
-            return failed(HttpStatus.FORBIDDEN,"请登录");
-        }
-        TenantPaymentOrder order = tenantPaymentOrderService.queryByOrderNo(orderNo);
-        if(order == null){
-        	return failed("订单不存在");
-        }
-        return succeed(order);
-    }
+	@ApiOperation(value = "查询订单")
+	@GetMapping("/query")
+	public Object query(long id) {
+		SysUser sysUser = sysUserFeignService.queryUserInfo();
+		if (Objects.isNull(sysUser)) {
+			return failed(HttpStatus.FORBIDDEN, "请登录");
+		}
+		TenantPaymentOrder order = tenantPaymentOrderService.get(id);
+		if (order == null) {
+			return failed("订单不存在");
+		}
+		return succeed(order);
+	}
+
+	@ApiOperation(value = "查询订单")
+	@GetMapping("/queryByOrderNo")
+	public Object query(String orderNo) {
+		SysUser sysUser = sysUserFeignService.queryUserInfo();
+		if (Objects.isNull(sysUser)) {
+			return failed(HttpStatus.FORBIDDEN, "请登录");
+		}
+		TenantPaymentOrder order = tenantPaymentOrderService.queryByOrderNo(orderNo);
+		if (order == null) {
+			return failed("订单不存在");
+		}
+		return succeed(order);
+	}
 
 }