|
@@ -64,6 +64,7 @@ import com.cyksj.model.manage.dto.GiftCardDto;
|
|
|
import com.cyksj.model.manage.request.ReqGoodsSkuSpec;
|
|
import com.cyksj.model.manage.request.ReqGoodsSkuSpec;
|
|
|
import com.cyksj.model.manage.views.GroupsRelationView;
|
|
import com.cyksj.model.manage.views.GroupsRelationView;
|
|
|
import com.cyksj.model.manage.views.OrderDonView;
|
|
import com.cyksj.model.manage.views.OrderDonView;
|
|
|
|
|
+import com.cyksj.model.manage.views.UpgradeOrderDetailView;
|
|
|
import com.cyksj.model.request.*;
|
|
import com.cyksj.model.request.*;
|
|
|
import com.cyksj.model.views.*;
|
|
import com.cyksj.model.views.*;
|
|
|
import com.cyksj.redis.RedisService;
|
|
import com.cyksj.redis.RedisService;
|
|
@@ -295,6 +296,12 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
|
|
|
|
|
private final WxCorpOps wxCorpOps;
|
|
private final WxCorpOps wxCorpOps;
|
|
|
|
|
|
|
|
|
|
+ private final UpgradePackageMapper upgradePackageMapper;
|
|
|
|
|
+
|
|
|
|
|
+ private final UpgradeOrderDonMapper upgradeOrderDonMapper;
|
|
|
|
|
+
|
|
|
|
|
+ private final MidjourneyUserMapper midjourneyUserMapper;
|
|
|
|
|
+
|
|
|
private final List<String> noChekGoodsTemp = List.of("Apple One", "Youtube", "Spotify");
|
|
private final List<String> noChekGoodsTemp = List.of("Apple One", "Youtube", "Spotify");
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Throwable.class)
|
|
@Transactional(rollbackFor = Throwable.class)
|
|
@@ -1246,6 +1253,27 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
unifiedHandlerOrderNotify(orderDon, goodsDon, sku);
|
|
unifiedHandlerOrderNotify(orderDon, goodsDon, sku);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void zeroUpgradeOrderConfirm(Long orderId) {
|
|
|
|
|
+ UpgradeOrderDon orderDon = upgradeOrderDonMapper.selectById(orderId);
|
|
|
|
|
+ if (orderDon == null) throw BusinessRuntimeException.getInstance("订单不存在");
|
|
|
|
|
+ if (orderDon.getMoney().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("订单异常");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (orderDon.getStatus() != UpgradeOrderDon.Status.noPayment) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("订单状态已修改");
|
|
|
|
|
+ }
|
|
|
|
|
+ UpgradePackage upgradePackage = null;
|
|
|
|
|
+ if (orderDon.getPackageId() != null) {
|
|
|
|
|
+ upgradePackage = upgradePackageMapper.selectById(orderDon.getPackageId());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (orderDon.getBalance().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
+ orderDon.setType(UpgradeOrderDon.Type.BALANCE);
|
|
|
|
|
+ orderDon.setPayTime(DateTime.now());
|
|
|
|
|
+ }
|
|
|
|
|
+ unifiedHandlerUpgradeOrderNotify(orderDon,upgradePackage);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public void updateCarParkAndSendMsg(GoodsDon goodsDon, GoodsDonSku sku, OrderDon order) {
|
|
public void updateCarParkAndSendMsg(GoodsDon goodsDon, GoodsDonSku sku, OrderDon order) {
|
|
|
if (goodsDon.getType() == 1) {
|
|
if (goodsDon.getType() == 1) {
|
|
|
//修改车位状态
|
|
//修改车位状态
|
|
@@ -3131,4 +3159,314 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public UpgradeOrderDon submitUpgrade(OrderPayRequest payRequest) {
|
|
|
|
|
+ User user = null;
|
|
|
|
|
+ Long userId = payRequest.getUserId();
|
|
|
|
|
+ if (userId != null) {
|
|
|
|
|
+ int noPayCount = upgradeOrderDonMapper.selectCount(Wrappers.lambdaQuery(UpgradeOrderDon.class).eq(UpgradeOrderDon::getUserId, userId).eq(UpgradeOrderDon::getPackageId, payRequest.getPackageId())
|
|
|
|
|
+ .eq(UpgradeOrderDon::getStatus, UpgradeOrderDon.Status.noPayment.toString()));
|
|
|
|
|
+ if (noPayCount > 0) {
|
|
|
|
|
+ throw new BusinessRuntimeException("您有未支付订单.");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ String orderPhone = payRequest.getPhone();
|
|
|
|
|
+ if (StrUtil.isNotBlank(orderPhone)) {
|
|
|
|
|
+ user = saveOrGetOrderPhoneUser(payRequest);
|
|
|
|
|
+ userId = user.getId();
|
|
|
|
|
+ payRequest.setUserId(userId);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (userId == null) {
|
|
|
|
|
+ user = new User();
|
|
|
|
|
+ user.setId(0l);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ user = userMapper.selectById(userId);
|
|
|
|
|
+ if (user == null) throw BusinessRuntimeException.getGatewayApiCode(GatewayApiCode.CMS_TOKEN_VALID);
|
|
|
|
|
+ if (user.getIsBlack()) throw BusinessRuntimeException.getInstance("系统检测操作异常,请稍后再试");
|
|
|
|
|
+ }
|
|
|
|
|
+ GroupsRelation groupsRelation = getGroupsRelation(payRequest.getUserId(), payRequest.getRelationId());
|
|
|
|
|
+ GroupsTrips groupsTrips = getGroupsTrips(groupsRelation);
|
|
|
|
|
+ GoodsDonSku goodsDonSku = goodsDonSkuMapper.selectById(groupsTrips.getSkuId());
|
|
|
|
|
+
|
|
|
|
|
+ if (goodsDonSku != null && goodsDonSku.getIsMirror()) {
|
|
|
|
|
+ UpgradePackage upgradePackage = upgradePackageMapper.selectById(payRequest.getPackageId());
|
|
|
|
|
+ if (upgradePackage == null) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("套餐包不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (upgradePackage.getPrice() == null || upgradePackage.getPrice().compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("下单商品价格异常");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (payRequest.getDonMoney().compareTo(upgradePackage.getPrice()) < 0) {
|
|
|
|
|
+ log.info("套餐包:{}支付金额:{}异常,调整用户userId:{}支付金额为:{}", upgradePackage.getName(), payRequest.getDonMoney(), user.getId(), upgradePackage.getPrice());
|
|
|
|
|
+ payRequest.setDonMoney(upgradePackage.getPrice());
|
|
|
|
|
+ }
|
|
|
|
|
+ MidjourneyUser midjourneyUser = midjourneyUserMapper.selectOne(Wrappers.lambdaQuery(MidjourneyUser.class).eq(MidjourneyUser::getRelationId, payRequest.getRelationId()));
|
|
|
|
|
+ if (midjourneyUser == null){
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("车票未激活Midjourney账号,请先激活");
|
|
|
|
|
+ }
|
|
|
|
|
+ String donNo = SEQUENCE.nextId().toString();
|
|
|
|
|
+ UpgradeOrderDon upgradeOrderDon = new UpgradeOrderDon();
|
|
|
|
|
+ upgradeOrderDon.setOrderNo(donNo);
|
|
|
|
|
+ upgradeOrderDon.setUserId(payRequest.getUserId());
|
|
|
|
|
+ upgradeOrderDon.setOriginalOrderId(payRequest.getOriginalOrderId());
|
|
|
|
|
+ upgradeOrderDon.setRelationId(payRequest.getRelationId());
|
|
|
|
|
+ upgradeOrderDon.setPackageId(payRequest.getPackageId());
|
|
|
|
|
+ upgradeOrderDon.setPrice(upgradePackage.getPrice());
|
|
|
|
|
+ upgradeOrderDon.setNum(upgradePackage.getNum());
|
|
|
|
|
+ upgradeOrderDon.setGoodsId(goodsDonSku.getGoodsId());
|
|
|
|
|
+ upgradeOrderDon.setMoney(payRequest.getDonMoney());
|
|
|
|
|
+ upgradeOrderDon.setStatus(UpgradeOrderDon.Status.noPayment);
|
|
|
|
|
+ upgradeOrderDon.setType(UpgradeOrderDon.Type.ALI_PAY);
|
|
|
|
|
+ upgradeOrderDonMapper.insert(upgradeOrderDon);
|
|
|
|
|
+
|
|
|
|
|
+ deductUpgradeBalancePayOrderMoney(upgradeOrderDon, payRequest.getBalance(),user );
|
|
|
|
|
+
|
|
|
|
|
+ if (upgradeOrderDon.getStatus() == UpgradeOrderDon.Status.noPayment) {
|
|
|
|
|
+ jobManager.addJob(EXPIRY_TIME, () -> {
|
|
|
|
|
+ closeUpgradeOrder(upgradeOrderDon.getId(), null);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ return upgradeOrderDon;
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public void deductUpgradeBalancePayOrderMoney(UpgradeOrderDon orderDon, BigDecimal balance, User user) {
|
|
|
|
|
+ //存在余额
|
|
|
|
|
+ if (balance != null && balance.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
+ BigDecimal money = orderDon.getMoney();
|
|
|
|
|
+ //去掉余额 多出的部分
|
|
|
|
|
+ BigDecimal subBalance = balance;
|
|
|
|
|
+ orderDon.setMoney(money.subtract(subBalance));
|
|
|
|
|
+ if (balance.compareTo(money) >= 0) {
|
|
|
|
|
+ orderDon.setMoney(BigDecimal.ZERO);
|
|
|
|
|
+ orderDon.setBalance(money);
|
|
|
|
|
+ subBalance = money;
|
|
|
|
|
+ orderDon.setType(UpgradeOrderDon.Type.BALANCE);
|
|
|
|
|
+ }
|
|
|
|
|
+ BigDecimal userBalance = user.getBalance();
|
|
|
|
|
+ //扣除余额 是否成功
|
|
|
|
|
+ Integer success = userMapper.deductBalance(user.getId(), subBalance, userBalance);
|
|
|
|
|
+ if (success != 1) throw BusinessRuntimeException.getInstance("您的余额不足!");
|
|
|
|
|
+ orderDon.setBalance(subBalance);
|
|
|
|
|
+ upgradeOrderDonMapper.updateById(orderDon);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取车位信息
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param userId
|
|
|
|
|
+ * @param relationId
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ private GroupsRelation getGroupsRelation(Long userId, Long relationId) {
|
|
|
|
|
+ List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
|
|
|
|
|
+ GroupsRelation groupsRelation = groupsRelationMapper.selectOne(Wrappers.lambdaQuery(GroupsRelation.class).in(GroupsRelation::getUserId, userIdList).eq(GroupsRelation::getId, relationId));
|
|
|
|
|
+ if (groupsRelation == null) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("车票不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ return groupsRelation;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取车队信息
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param groupsRelation
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ private GroupsTrips getGroupsTrips(GroupsRelation groupsRelation) {
|
|
|
|
|
+ GroupsTrips groupsTrips = groupsMapper.selectById(groupsRelation.getGroupsId());
|
|
|
|
|
+ if (groupsTrips == null) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("车队异常");
|
|
|
|
|
+ }
|
|
|
|
|
+ return groupsTrips;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public AliPayParams aliPayUpgrade(AlipayOrderDonReq re, String productCode, String qrPayMode) throws Exception {
|
|
|
|
|
+ return aliPayCommonService.unifiedPayUpgrade(re,productCode,qrPayMode);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional(rollbackFor = Throwable.class)
|
|
|
|
|
+ public void aliPayUpgradeNotify(Map<String, String> params) throws Exception {
|
|
|
|
|
+ //调用SDK验证签名
|
|
|
|
|
+ String body = Codec.DoBase64.custom().setData(params.get("body")).decodeAsText();
|
|
|
|
|
+ OrderAttach orderAttach = Jsons.parseObject(body, OrderAttach.class);
|
|
|
|
|
+ Long oderId = orderAttach.getO();
|
|
|
|
|
+ UpgradeOrderDon orderDon = upgradeOrderDonMapper.selectById(oderId);
|
|
|
|
|
+ if (null == orderDon) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("订单不存在.");
|
|
|
|
|
+ }
|
|
|
|
|
+ String appId = params.get("app_id");
|
|
|
|
|
+ boolean signVerified = AlipaySignature.rsaCheckV1(params, shopConfigMapper.getByAppId(appId).getPublicKey(), BaseZfbConfig.charset, BaseZfbConfig.signType);
|
|
|
|
|
+ if (!signVerified) {
|
|
|
|
|
+ log.error("支付宝回调校验签名错误,自定义入参:{}", params.get("body"));
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("支付宝回调校验签名错误");
|
|
|
|
|
+ }
|
|
|
|
|
+ String transactionId = params.get("trade_no");
|
|
|
|
|
+ String payTimeStr = params.get("gmt_payment");
|
|
|
|
|
+ //买家支付宝账号
|
|
|
|
|
+ String buyerId = params.get("buyer_id");
|
|
|
|
|
+ log.info("支付宝回调信息:{}", Jsons.toJson(params));
|
|
|
|
|
+ if (!orderDon.getStatus().equals(UpgradeOrderDon.Status.noPayment) && !orderDon.getStatus().equals(UpgradeOrderDon.Status.close)) {
|
|
|
|
|
+ log.info("支付宝已回调,重复修改状态 id:{}", orderDon.getId());
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ UpgradePackage upgradePackage = upgradePackageMapper.selectById(orderDon.getPackageId());
|
|
|
|
|
+ Date payTime = DateTime.now();
|
|
|
|
|
+ if (StringUtils.isNotBlank(payTimeStr)) {
|
|
|
|
|
+ payTime = DateUtil.parse(payTimeStr, "yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
+ }
|
|
|
|
|
+ // 更改订单状态
|
|
|
|
|
+ orderDon.setTransactionId(transactionId);
|
|
|
|
|
+ orderDon.setPayTime(payTime);
|
|
|
|
|
+ orderDon.setShopId(appId);
|
|
|
|
|
+ orderDon.setType(UpgradeOrderDon.Type.ALI_PAY);
|
|
|
|
|
+ orderDon.setBuyerId(buyerId);
|
|
|
|
|
+ upgradeOrderDonMapper.updateById(orderDon);
|
|
|
|
|
+ //该支付账号id 是否被后台拉黑
|
|
|
|
|
+ Integer count1 = userPayOrderBlockMapper.selectCount(Wrappers.lambdaQuery(UserPayOrderBlock.class)
|
|
|
|
|
+ .eq(UserPayOrderBlock::getBuyerId, buyerId));
|
|
|
|
|
+ if (count1 > 0) {
|
|
|
|
|
+ log.info("该支付账号id:{} 已被后台拉黑", buyerId);
|
|
|
|
|
+ //notifyRefundOrder(orderDon, goodsDon, sku);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //回调
|
|
|
|
|
+ unifiedHandlerUpgradeOrderNotify(orderDon,upgradePackage );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 统一订单信息回调
|
|
|
|
|
+ */
|
|
|
|
|
+ public void unifiedHandlerUpgradeOrderNotify(UpgradeOrderDon orderDon, UpgradePackage upgradePackage) {
|
|
|
|
|
+ orderDon.setStatus(UpgradeOrderDon.Status.complete);
|
|
|
|
|
+ int isSuccess = upgradeOrderDonMapper.update(null,Wrappers.lambdaUpdate(UpgradeOrderDon.class)
|
|
|
|
|
+ .set(UpgradeOrderDon::getStatus, orderDon.getStatus())
|
|
|
|
|
+ .in(UpgradeOrderDon::getStatus, List.of(UpgradeOrderDon.Status.noPayment, UpgradeOrderDon.Status.close))
|
|
|
|
|
+ .eq(UpgradeOrderDon::getId, orderDon.getId()));
|
|
|
|
|
+ if (isSuccess == 0) {
|
|
|
|
|
+ log.info("该订单{}状态已修改", orderDon.getOrderNo());
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //余额使用记录
|
|
|
|
|
+ if (orderDon.getBalance().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
+ userBenefitsService.recordBalanceBySource(orderDon.getUserId(), orderDon.getBalance().negate(), UserBalanceSourceRecord.Source.payment, orderDon.getId(), upgradePackage.getName() + UserBalanceSourceRecord.Source.payment.getDesc());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (upgradePackage.getGoodsId() == 26) {
|
|
|
|
|
+ MidjourneyUser midjourneyUser = midjourneyUserMapper.selectOne(Wrappers.lambdaQuery(MidjourneyUser.class).eq(MidjourneyUser::getRelationId, orderDon.getRelationId()));
|
|
|
|
|
+ if (midjourneyUser != null) {
|
|
|
|
|
+ int update = midjourneyUserMapper.update(null, Wrappers.lambdaUpdate(MidjourneyUser.class)
|
|
|
|
|
+ .set(MidjourneyUser::getMjFastNum, midjourneyUser.getMjFastNum() + upgradePackage.getNum()).eq(MidjourneyUser::getId, midjourneyUser.getId()));
|
|
|
|
|
+ if (update == 0) {
|
|
|
|
|
+ log.info("midjourneyUser 套餐包增值失败 id:{},orderId:{}", midjourneyUser.getId(), orderDon.getId());
|
|
|
|
|
+ }
|
|
|
|
|
+ Object fastNum = redisService.get(RedisService.key.MIDJOURNEY_FAST_LIMIT.getName() + midjourneyUser.getId());
|
|
|
|
|
+ if (fastNum == null) {
|
|
|
|
|
+ redisService.set(RedisService.key.MIDJOURNEY_FAST_LIMIT.getName() + midjourneyUser.getId(), midjourneyUser.getMjFastNum() + upgradePackage.getNum().longValue(), RedisService.key.MIDJOURNEY_FAST_LIMIT.getTimeout());
|
|
|
|
|
+ }else {
|
|
|
|
|
+ redisService.incr(RedisService.key.MIDJOURNEY_FAST_LIMIT.getName() + midjourneyUser.getId(), upgradePackage.getNum().longValue());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @Transactional(rollbackFor = Throwable.class)
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void closeUpgradeOrder(Long orderId, Long userId) {
|
|
|
|
|
+ String orderCloseKey = RedisService.key.CLOSE_UPGRADE_ORDER_TIME_KEY.getName() + orderId;
|
|
|
|
|
+ if (!redisService.setNx(orderCloseKey, orderId, RedisService.key.CLOSE_UPGRADE_ORDER_TIME_KEY.getTimeout())) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("订单正在关闭中..");
|
|
|
|
|
+ }
|
|
|
|
|
+ //关闭订单逻辑
|
|
|
|
|
+ UpgradeOrderDon orderDon = upgradeOrderDonMapper.selectById(orderId);
|
|
|
|
|
+ if (orderDon == null) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (userId != null) {
|
|
|
|
|
+ List<Long> relationUserIdList = userBindRelationService.getRelationUserIdList(userId, null);
|
|
|
|
|
+ if (!relationUserIdList.contains(orderDon.getUserId())) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ log.info("关闭订单 orderId:{}", orderId);
|
|
|
|
|
+ if (UpgradeOrderDon.Status.noPayment.equals(orderDon.getStatus())) {
|
|
|
|
|
+ //调用微信、支付宝第三方接口查询订单是否支付
|
|
|
|
|
+ UpgradeOrderDon.Status status = isHasPaid(orderDon);
|
|
|
|
|
+ if (status == UpgradeOrderDon.Status.noPayment) {
|
|
|
|
|
+ //查询微信支付是否已支付
|
|
|
|
|
+ orderDon.setStatus(UpgradeOrderDon.Status.close);
|
|
|
|
|
+ upgradeOrderDonMapper.updateById(orderDon);
|
|
|
|
|
+ //返还余额
|
|
|
|
|
+ if (orderDon.getBalance().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
+ userBenefitsService.addUserBalance(orderDon.getUserId(), orderDon.getBalance(), null, null, null, null, false);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 查询第三放接口订单是否已支付
|
|
|
|
|
+ */
|
|
|
|
|
+ public UpgradeOrderDon.Status isHasPaid(UpgradeOrderDon orderDon) {
|
|
|
|
|
+ UpgradePackage upgradePackage = upgradePackageMapper.selectById(orderDon.getPackageId());
|
|
|
|
|
+ if (orderDon.getType() == UpgradeOrderDon.Type.WeChat) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ Map<String, String> reMap = weChatService.getWxOrderDetail(orderDon.getShopId(), orderDon.getOrderNo());
|
|
|
|
|
+ if (reMap != null) {
|
|
|
|
|
+ String orderStatus = reMap.get("trade_state");
|
|
|
|
|
+ if ("SUCCESS".equals(orderStatus)) {
|
|
|
|
|
+ orderDon.setStatus(UpgradeOrderDon.Status.complete);
|
|
|
|
|
+ orderDon.setTransactionId(reMap.get("transaction_id"));
|
|
|
|
|
+ return updateUpgradeNoPayment(orderDon, upgradePackage);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if (orderDon.getType() == UpgradeOrderDon.Type.ALI_PAY) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ AlipayTradeQueryResponse zfbOrderDetail = getZfbOrderDetail(orderDon.getShopId(), orderDon.getOrderNo());
|
|
|
|
|
+ if (zfbOrderDetail != null) {
|
|
|
|
|
+ String tradeStatus = zfbOrderDetail.getTradeStatus();
|
|
|
|
|
+ if ("TRADE_SUCCESS".equals(tradeStatus)) {
|
|
|
|
|
+ orderDon.setStatus(UpgradeOrderDon.Status.complete);
|
|
|
|
|
+ orderDon.setTransactionId(zfbOrderDetail.getTradeNo());
|
|
|
|
|
+ return updateUpgradeNoPayment(orderDon, upgradePackage);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return orderDon.getStatus();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private UpgradeOrderDon.Status updateUpgradeNoPayment(UpgradeOrderDon orderDon,UpgradePackage upgradePackage) {
|
|
|
|
|
+ unifiedHandlerUpgradeOrderNotify(orderDon, upgradePackage);
|
|
|
|
|
+ return orderDon.getStatus();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public UpgradeOrderDetailView getUpgradeOrderDetail(Long orderId, Long userId) {
|
|
|
|
|
+ MapBuilder builder = MapUtils.builder()
|
|
|
|
|
+ .field(OrderDonView::getId, orderId)
|
|
|
|
|
+ .orderBy(OrderDonView::getId).desc();
|
|
|
|
|
+ if (userId != null) {
|
|
|
|
|
+ builder.field(UpgradeOrderDetailView::getUserId, userId);
|
|
|
|
|
+ }
|
|
|
|
|
+ return beanSearcher.searchFirst(UpgradeOrderDetailView.class, builder.build());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|