|
|
|
@ -478,29 +478,34 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void batchPay(BatchPayParam param, BatchPayData data) {
|
|
|
|
|
if (param.getParams().size() != 1) {
|
|
|
|
|
throw new RuntimeException("每次只能请求1个采购单");
|
|
|
|
|
List<String> purOrderIds = new ArrayList<>();
|
|
|
|
|
for (BatchPayParam.Param payParam: param.getParams()) {
|
|
|
|
|
purOrderIds.add(payParam.getPurOrderId());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String purOrderId = param.getParams().get(0).getPurOrderId();
|
|
|
|
|
PlatformPurchaseOrder platformPurchaseOrder = platformPurchaseOrderMapper.selectByPrimaryKey(param.getParams().get(0).getPurOrderId());
|
|
|
|
|
if (platformPurchaseOrder == null) {
|
|
|
|
|
List<PlatformPurchaseOrder> platformPurchaseOrders = platformPurchaseOrderMapper.getListByPurOrderIds(purOrderIds);
|
|
|
|
|
if (platformPurchaseOrders.isEmpty()) {
|
|
|
|
|
throw new RuntimeException("采购单不存在");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PurchaseOrder purchaseOrder = purchaseOrderMapper.getByPurOrderId(purOrderId);
|
|
|
|
|
List<PurchaseOrder> purchaseOrders = purchaseOrderMapper.getListByPurOrderIds(purOrderIds);
|
|
|
|
|
|
|
|
|
|
List<String> sourceOrderIds = new ArrayList<>();
|
|
|
|
|
for (PurchaseOrder purchaseOrder: purchaseOrders) {
|
|
|
|
|
sourceOrderIds.add(purchaseOrder.getPurchaseOrderSn());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Long shopId = param.getParams().get(0).getShopId();
|
|
|
|
|
GetPurchaseOrderPayUrlResponseDTO response1 = dsApiService.getPurchaseOrderPayUrl(shopId, sourceOrderIds, "PC");
|
|
|
|
|
GetPurchaseOrderPayUrlResponseDTO response2 = dsApiService.getPurchaseOrderPayUrl(shopId, sourceOrderIds, "WIRELESS");
|
|
|
|
|
if (!response1.isSuccess()) {
|
|
|
|
|
throw new RuntimeException(response1.getReason());
|
|
|
|
|
}
|
|
|
|
|
if (!response2.isSuccess()) {
|
|
|
|
|
throw new RuntimeException(response2.getReason());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<PaymentResult> paymentResults = new ArrayList<>();
|
|
|
|
|
for (BatchPayParam.Param p: param.getParams()) {
|
|
|
|
|
List<String> sourceOrderIds = Collections.singletonList(purchaseOrder.getPurchaseOrderSn());
|
|
|
|
|
GetPurchaseOrderPayUrlResponseDTO response1 = dsApiService.getPurchaseOrderPayUrl(p.getShopId(), sourceOrderIds, "PC");
|
|
|
|
|
GetPurchaseOrderPayUrlResponseDTO response2 = dsApiService.getPurchaseOrderPayUrl(p.getShopId(), sourceOrderIds, "WIRELESS");
|
|
|
|
|
if (!response1.isSuccess()) {
|
|
|
|
|
throw new RuntimeException(response1.getReason());
|
|
|
|
|
}
|
|
|
|
|
if (!response2.isSuccess()) {
|
|
|
|
|
throw new RuntimeException(response2.getReason());
|
|
|
|
|
}
|
|
|
|
|
PaymentResult paymentResult = new PaymentResult();
|
|
|
|
|
PaymentResult.PayUrl payUrl = new PaymentResult.PayUrl();
|
|
|
|
|
|
|
|
|
@ -510,11 +515,8 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
|
|
|
|
|
paymentResult.setPayUrl(payUrl);
|
|
|
|
|
paymentResult.setPurOrderId(p.getPurOrderId());
|
|
|
|
|
paymentResults.add(paymentResult);
|
|
|
|
|
|
|
|
|
|
platformPurchaseOrder.setPayPcUrl(response1.getPayUrl());
|
|
|
|
|
platformPurchaseOrder.setPayH5Url(response2.getPayUrl());
|
|
|
|
|
platformPurchaseOrderMapper.updateByPrimaryKeySelective(platformPurchaseOrder);
|
|
|
|
|
}
|
|
|
|
|
platformPurchaseOrderMapper.updatePayUrlByPurOrderIds(response1.getPayUrl(), response2.getPayUrl(), purOrderIds);
|
|
|
|
|
data.setPaymentResults(paymentResults);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|