|
|
@@ -5,6 +5,7 @@ import cn.hutool.core.date.DateUtil;
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.alipay.api.internal.util.AlipaySignature;
|
|
|
+import com.alipay.api.response.AlipayTradeQueryResponse;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.cyksj.common.constant.Constant;
|
|
|
import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
@@ -25,10 +26,12 @@ import com.cyksj.model.request.OrderAttach;
|
|
|
import com.cyksj.model.views.GoodsWholesaleOrderDonView;
|
|
|
import com.cyksj.model.views.GoodsWholesaleUserDepositView;
|
|
|
import com.cyksj.service.order.GoodsWholesalePayService;
|
|
|
+import com.cyksj.service.order.OrderDonService;
|
|
|
import com.cyksj.service.order.OrderRefundService;
|
|
|
import com.cyksj.service.pay.AliPayCommonService;
|
|
|
import com.cyksj.service.user.UserBenefitsService;
|
|
|
import com.cyksj.service.user.UserBindRelationService;
|
|
|
+import com.cyksj.service.wechat.WeChatService;
|
|
|
import com.ejlchina.searcher.BeanSearcher;
|
|
|
import com.ejlchina.searcher.param.Operator;
|
|
|
import com.ejlchina.searcher.util.MapUtils;
|
|
|
@@ -82,6 +85,10 @@ public class GoodsWholesalePayServiceImpl implements GoodsWholesalePayService {
|
|
|
|
|
|
private final BeanSearcher beanSearcher;
|
|
|
|
|
|
+ private final OrderDonService orderDonService;
|
|
|
+
|
|
|
+ private final WeChatService weChatService;
|
|
|
+
|
|
|
@Override
|
|
|
public GoodsWholesaleOrderDon unifiedPay(GoodsWholesaleOrderPayReq payReq) throws Exception {
|
|
|
Long userId = payReq.getUserId();
|
|
|
@@ -322,7 +329,7 @@ public class GoodsWholesalePayServiceImpl implements GoodsWholesalePayService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void closeWholesaleOrder(Long orderId, long userId) {
|
|
|
+ public void closeWholesaleOrder(Long orderId, long userId) throws Exception {
|
|
|
List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
|
|
|
GoodsWholesaleOrderDon orderDon = goodsWholesaleOrderDonMapper.selectOne(Wrappers.lambdaQuery(GoodsWholesaleOrderDon.class)
|
|
|
.eq(GoodsWholesaleOrderDon::getId, orderId)
|
|
|
@@ -335,6 +342,10 @@ public class GoodsWholesalePayServiceImpl implements GoodsWholesalePayService {
|
|
|
return;
|
|
|
}
|
|
|
orderDon.setStatus(GoodsWholesaleOrderDon.Status.close);
|
|
|
+ GoodsWholesaleOrderDon.Status hasPaid = isHasPaid(orderDon);
|
|
|
+ if (hasPaid == GoodsWholesaleOrderDon.Status.hasPayment) {
|
|
|
+ unifiedHandleGoodsWholesaleOrderDon(orderDon);
|
|
|
+ }
|
|
|
goodsWholesaleOrderDonMapper.updateById(orderDon);
|
|
|
}
|
|
|
|
|
|
@@ -474,4 +485,41 @@ public class GoodsWholesalePayServiceImpl implements GoodsWholesalePayService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public GoodsWholesaleOrderDon.Status isHasPaid(GoodsWholesaleOrderDon orderDon) {
|
|
|
+ if (orderDon.getType() == GoodsWholesaleOrderDon.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(GoodsWholesaleOrderDon.Status.hasPayment);
|
|
|
+ orderDon.setPayTime(DateTime.now());
|
|
|
+ orderDon.setTransactionId(reMap.get("transaction_id"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ } else if (orderDon.getType() == GoodsWholesaleOrderDon.Type.ALI_PAY) {
|
|
|
+ try {
|
|
|
+ AlipayTradeQueryResponse zfbOrderDetail = orderDonService.getZfbOrderDetail(orderDon.getShopId(), orderDon.getOrderNo());
|
|
|
+ if (zfbOrderDetail != null) {
|
|
|
+ String tradeStatus = zfbOrderDetail.getTradeStatus();
|
|
|
+ if ("TRADE_SUCCESS".equals(tradeStatus)) {
|
|
|
+ orderDon.setStatus(GoodsWholesaleOrderDon.Status.hasPayment);
|
|
|
+ orderDon.setTransactionId(zfbOrderDetail.getTradeNo());
|
|
|
+ Date sendPayDate = zfbOrderDetail.getSendPayDate();
|
|
|
+ orderDon.setPayTime(sendPayDate);
|
|
|
+ //买家支付宝账号
|
|
|
+ String buyerId = Optional.ofNullable(zfbOrderDetail.getBuyerUserId()).orElse(zfbOrderDetail.getBuyerOpenId());
|
|
|
+ orderDon.setBuyerId(buyerId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return orderDon.getStatus();
|
|
|
+ }
|
|
|
+
|
|
|
}
|