|
@@ -24,6 +24,7 @@ import com.fs.store.vo.FsStoreOrderItemVO;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.lang3.StringEscapeUtils;
|
|
import org.apache.commons.lang3.StringEscapeUtils;
|
|
|
|
+import org.apache.http.client.utils.DateUtils;
|
|
import org.apache.http.util.Asserts;
|
|
import org.apache.http.util.Asserts;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -220,7 +221,52 @@ public class WdtErpOrderServiceImpl implements IErpOrderService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public BaseResponse refundUpdate(ErpRefundUpdateRequest param) {
|
|
public BaseResponse refundUpdate(ErpRefundUpdateRequest param) {
|
|
- return null;
|
|
|
|
|
|
+ WdtClient client = WdtClient.getInstance();
|
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ FsStoreOrder fsStoreOrder = fsStoreOrderService.selectFsStoreOrderByOrderCode(param.getTid());
|
|
|
|
+
|
|
|
|
+ Asserts.check(ObjectUtils.isNotNull(fsStoreOrder), "该订单不存在! 订单id: {} ", param.getTid());
|
|
|
|
+
|
|
|
|
+ List<FsStoreOrderItemVO> fsStoreOrderItemVOS = fsStoreOrderItemService.selectFsStoreOrderItemListByOrderId(fsStoreOrder.getId());
|
|
|
|
+ List<ErpWdtRefundOrder> refundOrders = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ for (FsStoreOrderItemVO item : fsStoreOrderItemVOS) {
|
|
|
|
+ refundOrders.add(ErpWdtRefundOrder.builder()
|
|
|
|
+ .oid(String.format("%s%s",item.getOrderCode(),item.getItemId()))
|
|
|
|
+ .num(BigDecimal.ONE)
|
|
|
|
+ .build());
|
|
|
|
+ }
|
|
|
|
+ List<ErpWdtApiRefund> erpWdtApiRefunds = Collections.singletonList(ErpWdtApiRefund.builder()
|
|
|
|
+ .platformId(127)
|
|
|
|
+ .shopNo(shopCode)
|
|
|
|
+ .tid(param.getTid())
|
|
|
|
+ .refundNo(param.getTid())
|
|
|
|
+ .type(RefundTypeEnum.REFUND_BEFORE_SHIPPING.getCode())
|
|
|
|
+ .status(AfterSaleStatusEnum.SUCCESS.getCode())
|
|
|
|
+ .refundTime(DateUtils.formatDate(new Date(), "yyyy-MM-dd HH:mm:ss"))
|
|
|
|
+ .orderList(refundOrders)
|
|
|
|
+ .build());
|
|
|
|
+
|
|
|
|
+ ErpWdtRefundRequest refundRequest = ErpWdtRefundRequest.builder()
|
|
|
|
+ .apiRefundList(erpWdtApiRefunds)
|
|
|
|
+ .build();
|
|
|
|
+
|
|
|
|
+ map.put("api_refund_list",JSON.toJSONString(refundRequest));
|
|
|
|
+ try {
|
|
|
|
+ String execute = client.execute("sales_refund_push.php", map);
|
|
|
|
+ ErpWdtApiResponse erpWdtApiResponse = JSON.parseObject(execute, ErpWdtApiResponse.class);
|
|
|
|
+ if(ObjectUtil.equal(0, erpWdtApiResponse.getCode())){
|
|
|
|
+ log.info("退款单更新成功: {}", erpWdtApiResponse);
|
|
|
|
+ return new BaseResponse();
|
|
|
|
+ } else {
|
|
|
|
+ log.info("退款单更新失败: {}", erpWdtApiResponse);
|
|
|
|
+ throw new RuntimeException(String.format("退款单更新失败, 原因: %s", erpWdtApiResponse.getMessage()));
|
|
|
|
+ }
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
public static String convertToSnakeCase(Object obj) {
|
|
public static String convertToSnakeCase(Object obj) {
|
|
SerializeConfig config = new SerializeConfig();
|
|
SerializeConfig config = new SerializeConfig();
|