| 
					
				 | 
			
			
				@@ -1,12 +1,18 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 package com.fs.kingbos.service.impl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.hutool.core.util.IdUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import cn.hutool.core.util.ObjectUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.hutool.http.HttpUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.hutool.json.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import cn.hutool.json.JSONUtil; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.alibaba.fastjson.JSON; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.alibaba.fastjson.PropertyNamingStrategy; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.alibaba.fastjson.parser.ParserConfig; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.common.config.FSSysConfig; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.common.exception.ServiceException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.common.utils.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.fs.erp.dto.ErpOrderResponse; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.fs.erp.dto.wdt.ErpWdtApiResponse; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.kingbos.domian.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.kingbos.enums.OrderStatusEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.fs.kingbos.service.K9OrderService; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -26,6 +32,7 @@ import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.transaction.annotation.Transactional; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.io.IOException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.math.BigDecimal; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.text.ParseException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.text.SimpleDateFormat; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -83,10 +90,44 @@ public class K9OrderServiceImpl implements K9OrderService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return response; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public ErpOrderResponse addOmsOrder(Long orderId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            KingbosOrderResponse response = this.createOmsOrder(orderId, NO_DELIVERED.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (response.getIsSuccess()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                log.info("订单推送成功: {}", response); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ErpOrderResponse erpOrderResponse = new ErpOrderResponse(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                erpOrderResponse.setCode(response.getCbilid()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return erpOrderResponse; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                throw new RuntimeException(String.format("订单推送失败,原因: %s",response.getErrmsg())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return new ErpOrderResponse(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @Transactional 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    public void createOmsOrder(Long orderId,String orderStatus){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public ErpOrderResponse refundOmsOrder(Long orderId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            KingbosOrderResponse response = this.createOmsOrder(orderId, CANCELLED.getCode()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (response.getIsSuccess()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                log.info("订单推送成功: {}", response); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                ErpOrderResponse erpOrderResponse = new ErpOrderResponse(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                erpOrderResponse.setCode(response.getCbilid()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                return erpOrderResponse; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                throw new RuntimeException(String.format("订单推送失败,原因: %s",response.getErrmsg())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return new ErpOrderResponse(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private KingbosOrderResponse createOmsOrder(Long orderId,String orderStatus){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         logger.info("【金博网络订单】开始创建订单,订单ID: {}", orderId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 1. 获取订单信息并验证 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -103,15 +144,16 @@ public class K9OrderServiceImpl implements K9OrderService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 4. 发送订单请求 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             KingbosOrderResponse response = sendOrderRequest(data, d1Datas); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (response.getIsSuccess()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                FsStoreOrder order1 = new FsStoreOrder(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                order1.setId(order.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                order1.setExtendOrderId(response.getCbilid()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                fsStoreOrderMapper.updateFsStoreOrder(order1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                logger.info("【金博网络订单】订单创建完成,订单ID: {}", orderId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                logger.error("【金博网络订单】创建订单失败,订单ID: {}, 错误信息: {}", orderId, response.getErrmsg()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return response; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            if (response.getIsSuccess()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                FsStoreOrder order1 = new FsStoreOrder(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                order1.setId(order.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                order1.setExtendOrderId(response.getCbilid()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                fsStoreOrderMapper.updateFsStoreOrder(order1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                logger.info("【金博网络订单】订单创建完成,订单ID: {}", orderId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//                logger.error("【金博网络订单】创建订单失败,订单ID: {}, 错误信息: {}", orderId, response.getErrmsg()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+//            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             logger.error("【金博网络订单】创建订单失败,订单ID: {}, 错误信息: {}", orderId, e.getMessage(), e); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             throw e; 
			 |