|
@@ -15,6 +15,7 @@ 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;
|
|
|
+import com.ym.mec.thirdparty.adapay.Payment;
|
|
|
import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
|
|
|
import com.ym.mec.util.date.DateUtil;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
@@ -181,14 +182,28 @@ public class MemberRankSettingServiceImpl extends BaseServiceImpl<Integer, Membe
|
|
|
if (!bucket.trySet(1, 2, TimeUnit.SECONDS)) {
|
|
|
throw new BizException("请勿频繁操作!");
|
|
|
}
|
|
|
+ //查询是否有待支付订单
|
|
|
+ List<StudentPaymentOrder> studentPaymentOrders = studentPaymentOrderService.queryByCondition(GroupType.MEMBER,
|
|
|
+ null, sysUser.getId(), DealStatusEnum.ING, OrderTypeEnum.MEMBER);
|
|
|
+ if (CollectionUtils.isNotEmpty(studentPaymentOrders)) {
|
|
|
+ return BaseController.failed(HttpStatus.CONTINUE, studentPaymentOrders.get(0), "您有待支付的订单,是否继续支付");
|
|
|
+ }
|
|
|
|
|
|
- //重新支付 需要传入订单号
|
|
|
+ //重新支付 需要传入订单号 并关闭订单 退余额 退优惠券
|
|
|
if (dto.getRepeatPay() && StringUtils.isNotBlank(dto.getOrderNo())) {
|
|
|
StudentPaymentOrder studentPaymentOrder = Optional.ofNullable(dto.getOrderNo())
|
|
|
.map(studentPaymentOrderService::findOrderByOrderNo)
|
|
|
.orElseThrow(() -> new BizException("未查询到继续支付的订单!"));
|
|
|
- Map<String, Object> result = studentPaymentOrderService.createOrder(studentPaymentOrder, null, "BUY_MEMBER");
|
|
|
- return BaseController.succeed(result);
|
|
|
+ //关闭订单 退余额 退优惠券
|
|
|
+ studentPaymentOrderService.quitCouponAndBalance(studentPaymentOrder);
|
|
|
+ //将订单关闭
|
|
|
+ studentPaymentOrder.setStatus(DealStatusEnum.CLOSE);
|
|
|
+ studentPaymentOrder.setUpdateTime(new Date());
|
|
|
+ studentPaymentOrderService.update(studentPaymentOrder);
|
|
|
+ //从缓存取出上次传入参数
|
|
|
+ RBucket<Object> cache = redissonClient.getBucket(BUY_2_QQHE_LOCK + studentPaymentOrder.getOrderNo());
|
|
|
+ Map<String, Object> cacheMap = (Map<String, Object>) cache.get();
|
|
|
+ dto = (MemberPayParamDto) cacheMap.get("dto");
|
|
|
}
|
|
|
|
|
|
int val = dto.getVal();
|
|
@@ -217,7 +232,10 @@ public class MemberRankSettingServiceImpl extends BaseServiceImpl<Integer, Membe
|
|
|
String orderNo = idGeneratorService.generatorId("payment") + "";
|
|
|
studentPaymentOrder.setOrderNo(orderNo);
|
|
|
RBucket<Object> cache = redissonClient.getBucket(BUY_2_QQHE_LOCK + orderNo);
|
|
|
- cache.set(totalMonth, 35, TimeUnit.MINUTES);
|
|
|
+ Map<String, Object> cacheMap = new HashMap<>();
|
|
|
+ cacheMap.put("totalMonth", totalMonth);
|
|
|
+ cacheMap.put("dto", dto);
|
|
|
+ cache.set(cacheMap, 40, TimeUnit.MINUTES);
|
|
|
//创建订单
|
|
|
Map<String, Object> result = getMap(dto.getAmount(), dto.getUseBalancePayment(), sysUser.getId(), sysUser.getOrganId(), studentPaymentOrder);
|
|
|
return BaseController.succeed(result);
|
|
@@ -239,12 +257,23 @@ public class MemberRankSettingServiceImpl extends BaseServiceImpl<Integer, Membe
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public HttpResponseResult closeBuy2Qqhe(String orderNo) {
|
|
|
+ public HttpResponseResult closeBuy2Qqhe(String orderNo) throws Exception {
|
|
|
StudentPaymentOrder orderByOrderNo = studentPaymentOrderService.findOrderByOrderNo(orderNo);
|
|
|
if (Objects.isNull(orderByOrderNo)) {
|
|
|
logger.info("closeBuy2Qqhe>>>>> 未找到 orderNo {}", orderNo);
|
|
|
return BaseController.succeed();
|
|
|
}
|
|
|
+
|
|
|
+ //订单是ing 并且有第三方支付编号的 要主动去查询一下
|
|
|
+ if (orderByOrderNo.getStatus().getCode().equals(DealStatusEnum.ING.getCode())
|
|
|
+ && StringUtils.isNotBlank(orderByOrderNo.getTransNo())) {
|
|
|
+ Map<String, Object> payment = Payment.queryPayment(orderByOrderNo.getTransNo());
|
|
|
+ String status = (String) payment.get("status");
|
|
|
+ if (status.equals("succeeded")) {
|
|
|
+ throw new BizException("该订单已经支付成功,无法关闭。");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//关闭订单 退余额 退优惠券
|
|
|
studentPaymentOrderService.quitCouponAndBalance(orderByOrderNo);
|
|
|
//将订单关闭
|
|
@@ -433,7 +462,8 @@ public class MemberRankSettingServiceImpl extends BaseServiceImpl<Integer, Membe
|
|
|
|
|
|
//齐齐哈尔会员活动
|
|
|
private void qqheMemberActivity(StudentPaymentOrder studentPaymentOrder, Student student, SysUser sysUser, RBucket<Object> cache) {
|
|
|
- BigDecimal totalMonth = (BigDecimal) cache.get();
|
|
|
+ Map<String, Object> cacheMap = (Map<String, Object>) cache.get();
|
|
|
+ BigDecimal totalMonth = (BigDecimal) cacheMap.get("totalMonth");
|
|
|
//写cloud order
|
|
|
LocalDate now = LocalDate.now();
|
|
|
CloudTeacherOrder cto = new CloudTeacherOrder();
|