diff --git a/ms-biz/src/main/java/com/ms/biz/service/impl/DistributionOrderServiceImpl.java b/ms-biz/src/main/java/com/ms/biz/service/impl/DistributionOrderServiceImpl.java index 3c9dcf3..2ec0a91 100644 --- a/ms-biz/src/main/java/com/ms/biz/service/impl/DistributionOrderServiceImpl.java +++ b/ms-biz/src/main/java/com/ms/biz/service/impl/DistributionOrderServiceImpl.java @@ -20,6 +20,7 @@ import com.ms.biz.dto.openspi.response.OrderResult; import com.ms.biz.dto.openspi.response.PaymentResult; import com.ms.biz.service.DistributionOrderService; import com.ms.biz.service.DsApiService; +import com.ms.biz.tool.SecurityTool; import com.ms.biz.util.DDApi; import com.ms.dal.entity.*; import com.ms.dal.mapper.*; @@ -159,6 +160,7 @@ public class DistributionOrderServiceImpl implements DistributionOrderService { item.setOrderId(Long.valueOf(purchaseOrderDTO.getPlatformOrderId())); item.setPurchaseNum(itemDTO.getPurchaseNum()); item.setSkuId(itemDTO.getSkuId()); + item.setSubItemId(itemDTO.getSubItemId() == null ? "" : itemDTO.getSubItemId()); item.setWareId(itemDTO.getWareId()); item.setPurchaseUrl(itemDTO.getPurchaseUrl() == null ? "" : itemDTO.getPurchaseUrl()); item.setPurchasePrice(BigDecimal.valueOf(0)); @@ -381,7 +383,7 @@ public class DistributionOrderServiceImpl implements DistributionOrderService { platformOrder.setSourceOrderBuyerRemark(""); platformOrder.setSourceOrderSellerMemo(""); platformOrder.setBuyerRemark(""); - platformOrder.setUserId(shopId.toString()); + platformOrder.setUserId(SecurityTool.encodeByAES(String.valueOf(shopId))); platformOrder.setConsigneeInfo(consigneeInfo); platformOrder.setEncryptOutOrderInfo(encryptOutOrderInfo); platformOrder.setItems(items); diff --git a/ms-biz/src/main/java/com/ms/biz/service/impl/DsMessageServiceImpl.java b/ms-biz/src/main/java/com/ms/biz/service/impl/DsMessageServiceImpl.java index 9d0d3e2..cbe5213 100644 --- a/ms-biz/src/main/java/com/ms/biz/service/impl/DsMessageServiceImpl.java +++ b/ms-biz/src/main/java/com/ms/biz/service/impl/DsMessageServiceImpl.java @@ -360,7 +360,7 @@ public class DsMessageServiceImpl implements DsMessageService { } else if (refundInfo.getOnlyRefund() == 1 && refundInfo.getStatus().equals(Refund1688Const.REFUND_STATUS_REFUND_CLOSE)) { operateType = 3; } else if (refundInfo.getStatus().equals(Refund1688Const.REFUND_STATUS_REFUND_CLOSE)) { - operateType = 3; + operateType = 5; } return operateType; } @@ -380,6 +380,7 @@ public class DsMessageServiceImpl implements DsMessageService { private void handlePurchaseOrderRelate(PurchaseOrderRelateMessageDTO messageDTO) { PurchaseOrderDTO purchaseOrderDTO = messageDTO.getPurchaseOrderInfo(); PurchaseOrder purchaseOrder = purchaseOrderMapper.getByPurchaseOrderSn(purchaseOrderDTO.getPurchaseOrderSn()); + List purchaseOrderItems = purchaseOrderItemMapper.getListByPurchaseOrderId(purchaseOrder.getPurchaseOrderId()); List platformPurchaseOrderSkus = platformPurchaseOrderSkuMapper.getListByPurOrderIds(Collections.singletonList(purchaseOrder.getPurOrderId())); Map skuIdAndPlatformPurchaseOrderSkuMap = platformPurchaseOrderSkus.stream().collect(Collectors.toMap(PlatformPurchaseOrderSku::getSkuId, x->x)); @@ -393,15 +394,24 @@ public class DsMessageServiceImpl implements DsMessageService { supplierOrderUrl.setPcUrl(url); param.setSupplierOrderUrl(supplierOrderUrl); List skuOrders = new ArrayList<>(); + Map skuIdAndSubItemIdMap = new HashMap<>(); for (PurchaseOrderItemDTO item: purchaseOrderDTO.getItems()) { PlatformPurchaseOrderSku platformPurchaseOrderSku = skuIdAndPlatformPurchaseOrderSkuMap.get(item.getSkuId()); SkuOrdersItem skuOrdersItem = new SkuOrdersItem(); skuOrdersItem.setPurSkuOrderId(platformPurchaseOrderSku.getPurSkuOrderId()); skuOrdersItem.setSupplierSkuOrderId(item.getSubItemId()); + skuIdAndSubItemIdMap.put(item.getSkuId(), item.getSubItemId()); skuOrders.add(skuOrdersItem); } param.setSkuOrders(skuOrders); + for (PurchaseOrderItem item: purchaseOrderItems) { + if (skuIdAndSubItemIdMap.containsKey(item.getSkuId())) { + item.setSubItemId(skuIdAndSubItemIdMap.get(item.getSkuId())); + purchaseOrderItemMapper.updateByPrimaryKeySelective(item); + } + } + DDApi.supplyCenterOrderSyncSupplierInfo(param); } } diff --git a/ms-biz/src/main/java/com/ms/biz/spi/callback/BatchCreateService.java b/ms-biz/src/main/java/com/ms/biz/spi/callback/BatchCreateService.java index 8bfb663..dd3fc9c 100644 --- a/ms-biz/src/main/java/com/ms/biz/spi/callback/BatchCreateService.java +++ b/ms-biz/src/main/java/com/ms/biz/spi/callback/BatchCreateService.java @@ -28,8 +28,11 @@ public class BatchCreateService extends SPIBaseService implements ExtensionServi BatchCreateData data = new BatchCreateData(); distributionOrderService.batchCreate(param, data); return BaseResponse.builder().success(true).message("success").code("0").data(JSON.parseObject(JSON.toJSONString(data))).build(); - } catch (Exception e) { + } catch (RuntimeException e) { return BaseResponse.builder().success(true).message(e.getMessage()).code("100003").build(); + } catch (Throwable e) { + log.error("batchCreate error", e); + return BaseResponse.builder().success(true).message("系统异常").code("100003").build(); } } } \ No newline at end of file diff --git a/ms-biz/src/main/java/com/ms/biz/spi/callback/BatchPayService.java b/ms-biz/src/main/java/com/ms/biz/spi/callback/BatchPayService.java index f274d41..7a64ed2 100644 --- a/ms-biz/src/main/java/com/ms/biz/spi/callback/BatchPayService.java +++ b/ms-biz/src/main/java/com/ms/biz/spi/callback/BatchPayService.java @@ -28,8 +28,11 @@ public class BatchPayService extends SPIBaseService implements ExtensionServiceH BatchPayData data = new BatchPayData(); distributionOrderService.batchPay(param, data); return BaseResponse.builder().success(true).message("success").code("0").data(JSON.parseObject(JSON.toJSONString(data))).build(); - } catch (Exception e) { + } catch (RuntimeException e) { return BaseResponse.builder().success(true).message(e.getMessage()).code("100003").build(); + } catch (Throwable e) { + log.error("batchPay error", e); + return BaseResponse.builder().success(true).message("系统异常").code("100003").build(); } } } \ No newline at end of file diff --git a/ms-biz/src/main/java/com/ms/biz/spi/callback/QuerySupplyPlatformAuthService.java b/ms-biz/src/main/java/com/ms/biz/spi/callback/QuerySupplyPlatformAuthService.java index d687bf8..4a7f097 100644 --- a/ms-biz/src/main/java/com/ms/biz/spi/callback/QuerySupplyPlatformAuthService.java +++ b/ms-biz/src/main/java/com/ms/biz/spi/callback/QuerySupplyPlatformAuthService.java @@ -27,8 +27,11 @@ public class QuerySupplyPlatformAuthService extends SPIBaseService implements Ex QuerySupplyPlatformAuthData data = new QuerySupplyPlatformAuthData(); shopService.querySupplyPlatformAuth(param, data); return BaseResponse.builder().success(true).message("success").code("0").data(JSON.parseObject(JSON.toJSONString(data))).build(); - } catch (Exception e) { + } catch (RuntimeException e) { return BaseResponse.builder().success(true).message(e.getMessage()).code("100003").build(); + } catch (Throwable e) { + log.error("querySupplyPlatformAuth error", e); + return BaseResponse.builder().success(true).message("系统异常").code("100003").build(); } } } \ No newline at end of file diff --git a/ms-dal/src/main/java/com/ms/dal/entity/PurchaseOrderItem.java b/ms-dal/src/main/java/com/ms/dal/entity/PurchaseOrderItem.java index a7b0ae8..2ba2f9b 100644 --- a/ms-dal/src/main/java/com/ms/dal/entity/PurchaseOrderItem.java +++ b/ms-dal/src/main/java/com/ms/dal/entity/PurchaseOrderItem.java @@ -28,6 +28,11 @@ public class PurchaseOrderItem implements Serializable { */ private String purOrderId; + /** + * 采购子单号 + */ + private String subItemId; + /** * 平台订单id */ diff --git a/ms-dal/src/main/java/com/ms/dal/mapper/PurchaseOrderItemMapper.java b/ms-dal/src/main/java/com/ms/dal/mapper/PurchaseOrderItemMapper.java index cf13273..51a010f 100644 --- a/ms-dal/src/main/java/com/ms/dal/mapper/PurchaseOrderItemMapper.java +++ b/ms-dal/src/main/java/com/ms/dal/mapper/PurchaseOrderItemMapper.java @@ -25,7 +25,10 @@ public interface PurchaseOrderItemMapper { int updateByPrimaryKeySelective(PurchaseOrderItem record); int updateByPrimaryKey(PurchaseOrderItem record); + int insertBatch(List list); int updateStatusByPurchaseOrderIds(@Param("status") String status, @Param("purchaseOrderIds") List purchaseOrderIds); + + List getListByPurchaseOrderId(@Param("purchaseOrderId") Long purchaseOrderId); } diff --git a/ms-dal/src/main/resources/mapper/PurchaseOrderItemMapper.xml b/ms-dal/src/main/resources/mapper/PurchaseOrderItemMapper.xml index 91a04cc..8371242 100644 --- a/ms-dal/src/main/resources/mapper/PurchaseOrderItemMapper.xml +++ b/ms-dal/src/main/resources/mapper/PurchaseOrderItemMapper.xml @@ -8,6 +8,7 @@ + @@ -21,7 +22,7 @@ purchase_order_item_id,purchase_order_id,pur_order_id, - order_id,ware_id,sku_id, + sub_item_id,order_id,ware_id,sku_id, purchase_url,purchase_price,purchase_num, status,gmt_create,gmt_modified @@ -32,6 +33,12 @@ from purchase_order_item where purchase_order_item_id = #{purchaseOrderItemId,jdbcType=BIGINT} + delete from purchase_order_item @@ -40,12 +47,12 @@ insert into purchase_order_item ( purchase_order_item_id,purchase_order_id,pur_order_id - ,order_id,ware_id,sku_id + ,sub_item_id,order_id,ware_id,sku_id ,purchase_url,purchase_price,purchase_num ,status,gmt_create,gmt_modified ) values (#{purchaseOrderItemId,jdbcType=BIGINT},#{purchaseOrderId,jdbcType=BIGINT},#{purOrderId,jdbcType=VARCHAR} - ,#{orderId,jdbcType=BIGINT},#{wareId,jdbcType=BIGINT},#{skuId,jdbcType=BIGINT} + ,#{subItemId,jdbcType=VARCHAR},#{orderId,jdbcType=BIGINT},#{wareId,jdbcType=BIGINT},#{skuId,jdbcType=BIGINT} ,#{purchaseUrl,jdbcType=VARCHAR},#{purchasePrice,jdbcType=DECIMAL},#{purchaseNum,jdbcType=SMALLINT} ,#{status,jdbcType=VARCHAR},#{gmtCreate,jdbcType=TIMESTAMP},#{gmtModified,jdbcType=TIMESTAMP} ) @@ -57,6 +64,7 @@ purchase_order_item_id, purchase_order_id, pur_order_id, + sub_item_id, order_id, ware_id, sku_id, @@ -71,6 +79,7 @@ #{purchaseOrderItemId,jdbcType=BIGINT}, #{purchaseOrderId,jdbcType=BIGINT}, #{purOrderId,jdbcType=VARCHAR}, + #{subItemId,jdbcType=VARCHAR}, #{orderId,jdbcType=BIGINT}, #{wareId,jdbcType=BIGINT}, #{skuId,jdbcType=BIGINT}, @@ -89,6 +98,9 @@ pur_order_id = #{purOrderId,jdbcType=VARCHAR}, + + sub_item_id = #{subItemId,jdbcType=VARCHAR}, + order_id = #{orderId,jdbcType=BIGINT}, @@ -124,6 +136,7 @@ purchase_order_item_id, purchase_order_id, pur_order_id, + sub_item_id, order_id, ware_id, sku_id, @@ -138,6 +151,7 @@ #{purchaseOrderItemId,jdbcType=BIGINT}, #{purchaseOrderId,jdbcType=BIGINT}, #{purOrderId,jdbcType=VARCHAR}, + #{subItemId,jdbcType=VARCHAR}, #{orderId,jdbcType=BIGINT}, #{wareId,jdbcType=BIGINT}, #{skuId,jdbcType=BIGINT}, @@ -158,6 +172,9 @@ pur_order_id = #{purOrderId,jdbcType=VARCHAR}, + + sub_item_id = #{subItemId,jdbcType=VARCHAR}, + order_id = #{orderId,jdbcType=BIGINT}, @@ -193,6 +210,7 @@ set purchase_order_id = #{purchaseOrderId,jdbcType=BIGINT}, pur_order_id = #{purOrderId,jdbcType=VARCHAR}, + sub_item_id = #{subItemId,jdbcType=VARCHAR}, order_id = #{orderId,jdbcType=BIGINT}, ware_id = #{wareId,jdbcType=BIGINT}, sku_id = #{skuId,jdbcType=BIGINT}, @@ -206,13 +224,13 @@ insert into purchase_order_item - (purchase_order_item_id,purchase_order_id,order_id - ,pur_order_id,ware_id,sku_id,purchase_url + (purchase_order_item_id,purchase_order_id,sub_item_id + ,order_id,pur_order_id,ware_id,sku_id,purchase_url ,purchase_price,purchase_num,status ,gmt_create,gmt_modified) values - (#{item.purchaseOrderItemId,jdbcType=BIGINT},#{item.purchaseOrderId,jdbcType=BIGINT},#{item.orderId,jdbcType=BIGINT} + (#{item.purchaseOrderItemId,jdbcType=BIGINT},#{item.purchaseOrderId,jdbcType=BIGINT},#{item.subItemId,jdbcType=VARCHAR},#{item.orderId,jdbcType=BIGINT} ,#{item.purOrderId,jdbcType=VARCHAR},#{item.wareId,jdbcType=BIGINT},#{item.skuId,jdbcType=BIGINT},#{item.purchaseUrl,jdbcType=VARCHAR} ,#{item.purchasePrice,jdbcType=DECIMAL},#{item.purchaseNum,jdbcType=SMALLINT},#{item.status,jdbcType=VARCHAR} ,#{item.gmtCreate,jdbcType=TIMESTAMP},#{item.gmtModified,jdbcType=TIMESTAMP}) diff --git a/ms-web/src/main/java/com/ms/web/controller/Test.java b/ms-web/src/main/java/com/ms/web/controller/Test.java index 6c285f1..f491542 100644 --- a/ms-web/src/main/java/com/ms/web/controller/Test.java +++ b/ms-web/src/main/java/com/ms/web/controller/Test.java @@ -226,8 +226,8 @@ public class Test { return ""; } - @RequestMapping("/ttt") - public String ttt() { + @RequestMapping("/batchCreate") + public String batchCreate() { String d = "{\"orders\":[{\"pur_order_id\":\"7299756498531418412\",\"order_id\":\"6917543139367389081\",\"post_address\":{\"province\":{\"id\":\"11\",\"name\":\"北京市\"},\"city\":{\"id\":\"110000\",\"name\":\"北京市\"},\"town\":{\"id\":\"110108\",\"name\":\"海淀区\"},\"street\":{\"id\":\"110108012\",\"name\":\"海淀街道\"},\"encrypt_detail\":\"MC8EEAjx7GdmeypB6WkV9DrpH9sEGWv8lSI1N1i9SaxcxKw1aW4waq481ueqVRcEAA==\",\"post_tel\":\"MCEEEDyPE4U3H7NDrnVhSgGOPzsEC9mVHEzJYMyY91uJBAA=\",\"post_receiver\":\"MCgEEHlttu0OuRqxJ3AaFAEvpr8EEjMU+9kRHPkU+MiXyD4zIkdVMgQA\"},\"mask_post_address\":{\"province\":{\"id\":\"11\",\"name\":\"北京市\"},\"city\":{\"id\":\"110000\",\"name\":\"北京市\"},\"town\":{\"id\":\"110108\",\"name\":\"海淀区\"},\"street\":{\"id\":\"110108012\",\"name\":\"海淀街道\"},\"detail\":\"互联*******\",\"post_tel\":\"1********00\",\"post_receiver\":\"电*****\"},\"sku_orders\":[{\"pur_sku_order_id\":\"7299756498531451180\",\"sku_order_id\":\"6917543139367389081\",\"cargo_id\":3649687424122130945,\"cargo_sku_id\":3659175936152832,\"product_id\":3649883085652281308,\"sku_id\":3659175955997568,\"num\":1,\"outer_product_id\":\"686872273204\",\"outer_sku_id\":\"4897420288982\"}]}],\"shop_id\":1111502210}"; BatchCreateParam param = JSON.parseObject(d, BatchCreateParam.class); BatchCreateData data = new BatchCreateData();