|
@@ -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());
|