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