Explorar o código

接入瀚智ERP代码提交

lmx hai 3 días
pai
achega
4c6d27d61d
Modificáronse 26 ficheiros con 1612 adicións e 222 borrados
  1. 120 0
      fs-admin/src/main/java/com/fs/his/controller/HzOMSErpApiController.java
  2. 1 0
      fs-framework/src/main/java/com/fs/framework/config/SecurityConfig.java
  3. 2 1
      fs-service/src/main/java/com/fs/erp/domain/ErpGoods.java
  4. 2 1
      fs-service/src/main/java/com/fs/erp/domain/ErpRefundOrder.java
  5. 1 0
      fs-service/src/main/java/com/fs/erp/dto/ErpRefundUpdateRequest.java
  6. 179 0
      fs-service/src/main/java/com/fs/erp/dto/sdk/HzOMS/api/HzOMSClient.java
  7. 91 0
      fs-service/src/main/java/com/fs/erp/dto/sdk/HzOMS/utils/HzOMSUtils.java
  8. 122 0
      fs-service/src/main/java/com/fs/erp/service/impl/HzOMSErpGoodsServiceImpl.java
  9. 383 0
      fs-service/src/main/java/com/fs/erp/service/impl/HzOMSErpOrderServiceImpl.java
  10. 6 1
      fs-service/src/main/java/com/fs/his/config/FsSysConfig.java
  11. 6 0
      fs-service/src/main/java/com/fs/his/mapper/FsStoreOrderMapper.java
  12. 9 0
      fs-service/src/main/java/com/fs/his/mapper/FsStoreProductAttrValueMapper.java
  13. 29 17
      fs-service/src/main/java/com/fs/his/mapper/FsStoreProductMapper.java
  14. 16 0
      fs-service/src/main/java/com/fs/his/param/HzOMSErpApiParam.java
  15. 37 0
      fs-service/src/main/java/com/fs/his/service/ErpApiService.java
  16. 4 0
      fs-service/src/main/java/com/fs/his/service/IFsStoreOrderService.java
  17. 6 0
      fs-service/src/main/java/com/fs/his/service/IFsStoreProductAttrValueService.java
  18. 3 0
      fs-service/src/main/java/com/fs/his/service/IFsStoreProductService.java
  19. 131 110
      fs-service/src/main/java/com/fs/his/service/impl/FsStoreAfterSalesServiceImpl.java
  20. 33 6
      fs-service/src/main/java/com/fs/his/service/impl/FsStoreOrderServiceImpl.java
  21. 15 0
      fs-service/src/main/java/com/fs/his/service/impl/FsStoreProductAttrValueServiceImpl.java
  22. 128 86
      fs-service/src/main/java/com/fs/his/service/impl/FsStoreProductServiceImpl.java
  23. 238 0
      fs-service/src/main/java/com/fs/his/service/impl/HzOMSErpApiServiceImpl.java
  24. 11 0
      fs-service/src/main/java/com/fs/his/vo/HzOMSErpResponseDetailVO.java
  25. 19 0
      fs-service/src/main/java/com/fs/his/vo/HzOMSErpResponseErrorItemVO.java
  26. 20 0
      fs-service/src/main/java/com/fs/his/vo/HzOMSErpResponseVO.java

+ 120 - 0
fs-admin/src/main/java/com/fs/his/controller/HzOMSErpApiController.java

@@ -0,0 +1,120 @@
+package com.fs.his.controller;
+
+
+import com.fs.erp.domain.ErpOrder;
+import com.fs.erp.dto.ErpOrderResponse;
+import com.fs.erp.dto.sdk.HzOMS.utils.HzOMSUtils;
+import com.fs.erp.service.IErpOrderService;
+import com.fs.his.domain.FsVessel;
+import com.fs.his.param.HzOMSErpApiParam;
+import com.fs.his.service.ErpApiService;
+import com.fs.his.vo.HzOMSErpResponseVO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * 瀚智OMS Erp系统推送平数据接口
+ */
+
+@RestController
+@RequestMapping("/erp/call")
+public class HzOMSErpApiController {
+
+    @Autowired
+    @Qualifier("hzOMSErpApiServiceImpl")
+    ErpApiService hzOMSErpApiService;
+
+    @Autowired
+    @Qualifier("hzOMSErpOrderServiceImpl")
+    IErpOrderService HzOMSErpOrderService;
+
+    /**
+     * 用于将瀚智商品库存同步到第三方
+     *
+     * @param appkey
+     * @param timestamp
+     * @param datapackage
+     * @param sign
+     * @return
+     */
+    @PostMapping("/ptgoods/stockSync")
+    public HzOMSErpResponseVO stockSync(String appkey, String timestamp, String datapackage, String sign) {
+        HzOMSErpApiParam param = new HzOMSErpApiParam();
+        param.setAppkey(appkey);
+        param.setSign(sign);
+        param.setTimestamp(timestamp);
+        param.setDatapakege(datapackage);
+        HzOMSErpResponseVO hzOMSErpResponseVO = new HzOMSErpResponseVO();
+        try {
+            hzOMSErpResponseVO = hzOMSErpApiService.stockSync(param);
+        } catch (Exception e) {
+            e.printStackTrace();
+            hzOMSErpResponseVO.setSuccess(Boolean.FALSE);
+            hzOMSErpResponseVO.setMessage("同步商品库存同步失败");
+        }
+        return hzOMSErpResponseVO;
+    }
+
+    /**
+     * 用于将瀚智商品库存同步到第三方
+     *
+     * @param appkey
+     * @param timestamp
+     * @param datapackage
+     * @param sign
+     * @return
+     */
+    @PostMapping("/ptgoods/skuStockSync")
+    public HzOMSErpResponseVO skuStockSync(String appkey, String timestamp, String datapackage, String sign) {
+        HzOMSErpApiParam param = new HzOMSErpApiParam();
+        param.setAppkey(appkey);
+        param.setSign(sign);
+        param.setTimestamp(timestamp);
+        param.setDatapakege(datapackage);
+        HzOMSErpResponseVO hzOMSErpResponseVO = new HzOMSErpResponseVO();
+        try {
+            hzOMSErpResponseVO = hzOMSErpApiService.skuStockSync(param);
+        } catch (Exception e) {
+            e.printStackTrace();
+            hzOMSErpResponseVO.setSuccess(Boolean.FALSE);
+            hzOMSErpResponseVO.setMessage("同步商品规格库存失败");
+        }
+        return hzOMSErpResponseVO;
+    }
+
+    /**
+     * 平台订单物流信息回传
+     *
+     * @param appkey
+     * @param timestamp
+     * @param datapackage
+     * @param sign
+     * @return
+     */
+    @PostMapping("/ptorder/logisticsAdd")
+    public HzOMSErpResponseVO logisticsAdd(String appkey, String timestamp, String datapackage, String sign) {
+        HzOMSErpApiParam param = new HzOMSErpApiParam();
+        param.setAppkey(appkey);
+        param.setSign(sign);
+        param.setTimestamp(timestamp);
+        param.setDatapakege(datapackage);
+        return  hzOMSErpApiService.logisticsAdd(param);
+    }
+
+    @PostMapping("/test/createOrder")
+    public HzOMSErpResponseVO createOrder(String appkey, String timestamp, String datapackage, String sign) {
+
+        ErpOrder order = new ErpOrder();
+        order.setPlatform_code(datapackage);
+
+        ErpOrderResponse erpOrderResponse = HzOMSErpOrderService.addOrder(order);
+        HzOMSErpResponseVO hzOMSErpResponseVO = new HzOMSErpResponseVO();
+        hzOMSErpResponseVO.setSuccess(true);
+        return hzOMSErpResponseVO;
+    }
+}

+ 1 - 0
fs-framework/src/main/java/com/fs/framework/config/SecurityConfig.java

@@ -143,6 +143,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
                 .antMatchers("/*/api-docs").anonymous()
                 .antMatchers("/druid/**").anonymous()
                 .antMatchers("/course/userVideo/videoTranscode").anonymous()
+                .antMatchers("/erp/call/**").anonymous()
                 // 除上面外的所有请求全部需要鉴权认证
                 .anyRequest().authenticated()
                 .and()

+ 2 - 1
fs-service/src/main/java/com/fs/erp/domain/ErpGoods.java

@@ -19,5 +19,6 @@ public class ErpGoods {
     String stock_status_code;
     List<ErpGoodsSku> skus;
     List<ErpCombineItem> combine_item;
-
+    //hzOMSErp 使用 商品id
+    Long storeProductId;
 }

+ 2 - 1
fs-service/src/main/java/com/fs/erp/domain/ErpRefundOrder.java

@@ -11,6 +11,7 @@ public class ErpRefundOrder {
     String vip_code;
     String trade_platform_code;
     List<ErpOrderItem> details;
-
+    String orderCode;
+    Long afterSalesId;
 
 }

+ 1 - 0
fs-service/src/main/java/com/fs/erp/dto/ErpRefundUpdateRequest.java

@@ -9,5 +9,6 @@ public class ErpRefundUpdateRequest implements Serializable {
     String tid;//平台单号
     String oid;//子订单号
     Integer refund_state;//0:未退款 1:退款完成 2:退款中
+    Long storeAfterSalesId;//售后id
 
 }

+ 179 - 0
fs-service/src/main/java/com/fs/erp/dto/sdk/HzOMS/api/HzOMSClient.java

@@ -0,0 +1,179 @@
+package com.fs.erp.dto.sdk.HzOMS.api;
+
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.http.HttpRequest;
+import com.alibaba.fastjson.JSONObject;
+import com.fs.common.core.redis.RedisCache;
+import com.fs.common.utils.StringUtils;
+import com.fs.his.config.FsSysConfig;
+import com.fs.his.utils.ConfigUtil;
+import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.http.Header;
+import org.apache.http.HttpEntity;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.client.methods.HttpPost;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
+
+@Component
+@Slf4j
+public class HzOMSClient {
+
+    @Autowired
+    private ConfigUtil configUtil;
+
+    @Autowired
+    private RedisCache redisCache;
+
+    private final String TOKEN_URL = "0";
+
+    private final String EXEC_RULE_URL = "1";
+
+    private final String HZOMS_TOKEN_KEY = "erp::hzoms::token";
+
+    /**
+     * 根据规则名称发送请求
+     *
+     * @param ruleName
+     * @return
+     */
+    public JSONObject send(String ruleName, JSONObject params) {
+        CloseableHttpClient client = null;
+        try {
+            client = HttpClients.createDefault();
+            HttpPost httpPost = new HttpPost(getRequestUrl(EXEC_RULE_URL));
+            JSONObject bodyObj = new JSONObject();
+            bodyObj.put("ruleName", ruleName);
+            bodyObj.put("dataPackage", params);
+            log.info("瀚智OMS请求参数打印:{}", bodyObj.toJSONString());
+            StringEntity entity = new StringEntity(bodyObj.toJSONString(),"UTF-8");
+            httpPost.setEntity(entity);
+//            httpPost.setHeader("Accept", "application/json");
+            httpPost.setHeader("Content-type", "application/json");
+            httpPost.setHeader("token", getToken());
+            httpPost.setHeader("itenantid", getItenantid());
+            HttpEntity response = client.execute(httpPost).getEntity();
+            String responseString = EntityUtils.toString(response);
+            log.info(" 执行动作," + ruleName + "瀚智OMS接口响应数据:{}", responseString);
+            JSONObject jsonObject = JSONObject.parseObject(responseString);
+            if(null != jsonObject && !jsonObject.isEmpty() && jsonObject.containsKey("code") && !"200".equals(jsonObject.getString("code"))){
+                log.info("瀚智OMS接口报错了,错误信息:{}", jsonObject.getString("message"));
+            }
+            return jsonObject;
+        } catch (UnsupportedEncodingException e) {
+            log.error("请求参数编码异常", e);
+            throw new RuntimeException("请求参数编码异常", e);
+        } catch (IOException e) {
+            log.error("HTTP请求执行异常", e);
+            throw new RuntimeException("HTTP请求执行异常, 执行动作" + ruleName, e);
+        } finally {
+            if (null != client) {
+                try {
+                    client.close();
+                } catch (IOException e) {
+                    throw new RuntimeException(e);
+                }
+            }
+        }
+    }
+
+    /**
+     * 获取token
+     *
+     * @return
+     */
+    public String getToken() {
+        try {
+            String token = redisCache.getCacheObject(HZOMS_TOKEN_KEY);
+            if (StringUtils.isNotBlank(token)) {
+                return token;
+            } else {
+                try {
+                    synchronized (HZOMS_TOKEN_KEY) {
+                        String tokenSec = redisCache.getCacheObject(HZOMS_TOKEN_KEY);
+                        if (StringUtils.isNotBlank(tokenSec)) {
+                            return tokenSec;
+                        }
+                        String requestUrl = getRequestUrl(TOKEN_URL);
+                        FsSysConfig sysConfig = configUtil.getSysConfig();
+                        HashMap headers = new HashMap<>();
+                        headers.put("Content-Type", "application/x-www-form-urlencoded");
+                        String body = HttpRequest.post(requestUrl)
+                                .addHeaders(headers)
+                                .form("appkey", sysConfig.getErpHzOMSAppKey())
+                                .form("secret", sysConfig.getErpHzOMSAppsecret()).execute().body();
+                        JSONObject jsonObject = JSONObject.parseObject(body);
+                        if (null != jsonObject && !jsonObject.isEmpty()) {
+                            String code = jsonObject.getString("code");
+                            if (null != code && "200".equals(code)) {
+                                log.info("瀚智OMS getTokenHTTP请求结果::" + jsonObject);
+                                JSONObject tokenData = jsonObject.getJSONObject("data");
+                                if (null != tokenData && !tokenData.isEmpty()) {
+                                    String tokenStr = tokenData.getString("token");
+                                    Long expires = tokenData.getLong("expires_in");
+                                    long currentTime = System.currentTimeMillis();
+                                    //提前过期
+                                    int intExact = Math.toIntExact((expires - currentTime - 180000) / 1000);
+                                    redisCache.setCacheObject(HZOMS_TOKEN_KEY, tokenStr, (int) intExact, TimeUnit.SECONDS);
+                                }
+                            }else{
+                                log.error("瀚智OMS getTokenHTTP请求失败::" + jsonObject);
+                                return "";
+                            }
+                        }
+                    }
+                } catch (ArithmeticException e) {
+                    System.out.println("时间转换溢出");
+                } catch (Exception ex) {
+                    ex.printStackTrace();
+                    log.error("瀚智OMS获取tokenHTTP请求失败", ex);
+                }
+                return getToken();
+            }
+        } catch (Exception ex) {
+            log.error("获取token异常", ex);
+            return "";
+        }
+    }
+
+    /**
+     * 获取瀚智租户id
+     *
+     * @return
+     */
+    public String getItenantid() {
+        FsSysConfig sysConfig = configUtil.getSysConfig();
+        String erpHzOMSItenantid = sysConfig.getErpHzOMSItenantid();
+        return erpHzOMSItenantid;
+    }
+
+    /**
+     * 根据type获取请求地址
+     *
+     * @param tpye
+     * @return
+     */
+    public String getRequestUrl(String tpye) {
+        FsSysConfig sysConfig = configUtil.getSysConfig();
+        String url = "";
+        if (TOKEN_URL.equals(tpye)) {
+            url = sysConfig.getErpHzOMTokenUrl();
+        } else if (EXEC_RULE_URL.equals(tpye)) {
+            url = sysConfig.getErpHzOMBaseUrl();
+        }
+        return url;
+    }
+
+}

+ 91 - 0
fs-service/src/main/java/com/fs/erp/dto/sdk/HzOMS/utils/HzOMSUtils.java

@@ -0,0 +1,91 @@
+package com.fs.erp.dto.sdk.HzOMS.utils;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.security.GeneralSecurityException;
+import java.security.MessageDigest;
+
+public class HzOMSUtils {
+
+    public static String getHzOMSUrl(String url) {
+        return "http://hzoms.51fengshang.com" + url;
+    }
+
+
+    /**
+     * 验签 669b0134c045bb06bb55767e0bc0bf99 B0A162029069D9067D0137E3869ABAAA
+     * 数据签名,签名算法为MD5(timestamp+datapakege+secret)appkey与 secret是一对,由瀚智提供(MD5 加
+     * 密为 32 位大写)
+     *
+     * @return
+     */
+    public static Boolean signValidate(String timestamp, String datapackage, String secret, String sign) throws IOException {
+        StringBuilder sb  = new StringBuilder();
+        sb.append(timestamp).append(datapackage).append(secret);
+        String s = encryptMD5(sb.toString());
+        String upperCase = s.toUpperCase();
+        return upperCase.equals(sign);
+    }
+
+    private static String byte2hex(byte[] bytes) {
+        StringBuilder sign = new StringBuilder();
+        for (int i = 0; i < bytes.length; i++) {
+            String hex = Integer.toHexString(bytes[i] & 0xFF);
+            if (hex.length() == 1) {
+                //保证所有的16进制都是两位:00-ff,其中[80~ff]代表[-128,-1]
+                sign.append("0");
+            }
+            sign.append(hex);
+        }
+        return sign.toString();
+    }
+    private static String encryptMD5(String data) throws IOException {
+        String s = null;
+        byte[] bytes = null;
+        try {
+            MessageDigest md = MessageDigest.getInstance("MD5");
+            bytes = md.digest(data.getBytes("UTF-8"));
+            s = bytesToHex(bytes);
+        } catch (GeneralSecurityException gse) {
+            String msg = getStringFromException(gse);
+            throw new IOException(msg);
+        }
+        return s;
+    }
+
+    private static String getStringFromException(Throwable e) {
+        String result = "";
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        PrintStream ps = new PrintStream(bos);
+        e.printStackTrace(ps);
+        try {
+            result = bos.toString("UTF-8");
+        } catch (IOException ioe) {
+        }
+        return result;
+    }
+
+    /**
+     * 字节数组转十六进制字符串(优化版)
+     * @param bytes 字节数组
+     * @return 十六进制字符串
+     */
+    private static String bytesToHex(byte[] bytes) {
+        // 一个字节对应两个十六进制字符
+        char[] hexChars = new char[bytes.length * 2];
+        // 预定义十六进制字符
+        final char[] hexArray = "0123456789abcdef".toCharArray();
+
+        for (int i = 0; i < bytes.length; i++) {
+            // 取字节的高4位
+            int high = (bytes[i] & 0xF0) >>> 4;
+            // 取字节的低4位
+            int low = bytes[i] & 0x0F;
+            // 转换为对应的十六进制字符
+            hexChars[i * 2] = hexArray[high];
+            hexChars[i * 2 + 1] = hexArray[low];
+        }
+        return new String(hexChars);
+    }
+}

+ 122 - 0
fs-service/src/main/java/com/fs/erp/service/impl/HzOMSErpGoodsServiceImpl.java

@@ -0,0 +1,122 @@
+package com.fs.erp.service.impl;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.fs.erp.domain.ErpGoods;
+import com.fs.erp.dto.*;
+import com.fs.erp.dto.sdk.HzOMS.api.HzOMSClient;
+import com.fs.erp.service.IErpGoodsService;
+import com.fs.his.domain.FsStoreProduct;
+import com.fs.his.domain.FsStoreProductAttr;
+import com.fs.his.domain.FsStoreProductAttrValue;
+import com.fs.his.service.IFsStoreProductAttrService;
+import com.fs.his.service.IFsStoreProductAttrValueService;
+import com.fs.his.service.IFsStoreProductService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * @author MixLiu
+ * @date 2025/6/26 下午5:55)
+ */
+@Service
+public class HzOMSErpGoodsServiceImpl implements IErpGoodsService {
+
+
+    @Autowired
+    HzOMSClient hzOMSClient;
+
+    @Autowired
+    private IFsStoreProductService fsStoreProductService;
+
+    @Autowired
+    private IFsStoreProductAttrService fsStoreProductAttrService;
+
+    @Autowired
+    private IFsStoreProductAttrValueService fsStoreProductAttrValueService;
+
+    @Override
+    public BaseResponse addGoods(ErpGoods goods) {
+
+        Long storeProductId = goods.getStoreProductId();
+        JSONObject hzGoods = buildGoods(storeProductId);
+
+        hzOMSClient.send("oms_open_ptshopgoods_sync", hzGoods);
+
+        return null;
+    }
+
+    @Override
+    public ErpGoodsQueryResponse getGoods(ErpGoodsQueryRequert param) {
+        return null;
+    }
+
+    @Override
+    public ErpGoodsStockQueryResponse getGoodsStock(ErpGoodsStockQueryRequert param) {
+        return null;
+    }
+
+    /**
+     * 构建店铺商品上传的参数
+     *
+     * @param storeProductId
+     * @return
+     */
+    public JSONObject buildGoods(Long storeProductId) {
+
+        JSONObject res = new JSONObject();
+        //商品
+        FsStoreProduct fsStoreProduct = fsStoreProductService.selectFsStoreProductByProductId(storeProductId);
+
+        //平台店铺编码 todo 测试环境只能写死 110111 用于联调测试 fsStoreProduct.getStoreId()
+        res.put("cptshopcode", 110111);
+        JSONArray goodsList = new JSONArray();
+        //添加上传的商品
+        JSONObject goods = new JSONObject();
+        //平台商品编码
+        goods.put("cptgoodsid", fsStoreProduct.getProductId());
+        //平台商品名称
+        goods.put("cptgoodsname", fsStoreProduct.getProductName());
+        //平台商品价格 f
+        goods.put("fptprice", fsStoreProduct.getPrice());
+        //平台商品库存 f
+        goods.put("fptstock", fsStoreProduct.getStock());
+        //上架状态0 下架;1 上架 f
+        goods.put("isalestatus", fsStoreProduct.getIsShow());
+        //平台分类编码 f
+//        goods.put("cptgroupid", );
+        //平台分类名称 f
+//        goods.put("cptgroupname", );
+        goods.put("cptgoodsid", fsStoreProduct.getProductId());
+
+        //商品规格
+        JSONArray attrList = new JSONArray();
+        //商品规格List
+        List<FsStoreProductAttrValue> fsStoreProductAttrValues = fsStoreProductAttrValueService.selectFsStoreProductAttrValueListByProductId(fsStoreProduct.getProductId());
+        fsStoreProductAttrValues.forEach(attr->{
+            JSONObject attrObj = new JSONObject();
+            //平台规格名称
+            attrObj.put("cptspecname", attr.getSku());
+            //平台规格编码
+            attrObj.put("cptspeccode", attr.getId());
+            //自定义规格编码 f
+//            attrObj.put("ccustid", attr.getAttrName());
+            //规格库存
+            attrObj.put("fptstock", attr.getStock());
+            //规格价格
+            attrObj.put("fptprice", attr.getPrice());
+            //规格上架状态 0 下架;1 上架
+            attrObj.put("isalestatus", fsStoreProduct.getIsShow());
+            attrList.add(attrObj);
+        });
+
+        //规格信息 f
+        goods.put("skus",attrList);
+        goodsList.add(goods);
+        res.put("goodsList", goodsList);
+
+        return res;
+    }
+}

+ 383 - 0
fs-service/src/main/java/com/fs/erp/service/impl/HzOMSErpOrderServiceImpl.java

@@ -0,0 +1,383 @@
+package com.fs.erp.service.impl;
+
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.fs.common.utils.StringUtils;
+import com.fs.erp.domain.ErpOrder;
+import com.fs.erp.domain.ErpRefundOrder;
+import com.fs.erp.dto.*;
+import com.fs.erp.dto.sdk.HzOMS.api.HzOMSClient;
+import com.fs.erp.service.IErpOrderService;
+
+import com.fs.his.domain.*;
+import com.fs.his.service.*;
+import com.fs.his.utils.PhoneUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+/**
+ * 瀚智OMS EPR订单对接服务实现类
+ */
+@Slf4j
+@Service
+public class HzOMSErpOrderServiceImpl implements IErpOrderService {
+
+    @Autowired
+    private IFsStoreOrderService fsStoreOrderService;
+
+    @Autowired
+    private IFsStoreOrderItemService fsStoreOrderItemService;
+
+    @Autowired
+    private IFsStoreProductService fsStoreProductService;
+
+    @Autowired
+    private IFsStoreProductAttrValueService fsStoreProductAttrValueService;
+
+    @Autowired
+    private IFsStoreAfterSalesService fsStoreAfterSalesService;
+
+    @Autowired
+    private IFsStoreService fsStoreService;
+
+    @Autowired
+    HzOMSClient hzOMSClient;
+
+    @Override
+    public ErpOrderResponse addOrder(ErpOrder order) {
+        try {
+            JSONObject hzOrder = buildHzOMSOrder(order.getPlatform_code());
+
+            JSONObject omsOpenPtorderCreate = hzOMSClient.send("oms_open_ptorder_create", hzOrder);
+            ErpOrderResponse res = new ErpOrderResponse();
+            res.setCode("hzomssuccess");
+            return res;
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+        return null;
+    }
+
+    @Override
+    public ErpOrderResponse refundOrder(ErpRefundOrder order) {
+        String orderCode = order.getOrderCode();
+        Long storeAfterSalesId = order.getAfterSalesId();
+        JSONObject jsonObject = buildRefundOrder(orderCode, storeAfterSalesId);
+        JSONObject omsOpenPtreturnorderCreate = hzOMSClient.send("oms_open_ptreturnorder_create", jsonObject);
+        return null;
+    }
+
+    @Override
+    public ErpDeliverysResponse getDeliver(ErpDeliverysRequest param) {
+        return null;
+    }
+
+    @Override
+    public ErpOrderQueryResponse getOrder(ErpOrderQueryRequert param) {
+        return null;
+    }
+
+    @Override
+    public BaseResponse refundUpdate(ErpRefundUpdateRequest param) {
+
+        String orderCode = param.getTid();
+        Long storeAfterSalesId = param.getStoreAfterSalesId();
+        FsStoreAfterSales fsStoreAfterSales = fsStoreAfterSalesService.selectFsStoreAfterSalesById(storeAfterSalesId);
+
+        FsStoreOrder fsStoreOrder = fsStoreOrderService.selectFsStoreOrderByOrderCode(orderCode);
+
+        JSONObject jsonObject = new JSONObject();
+        //平台店铺编码 todo 测试环境只能写死 110111 用于联调测试 fsStoreOrder.getStoreId()
+        jsonObject.put("cptshopcode", 110111);
+        //平台订单号
+        jsonObject.put("cptordercode", orderCode);
+        //平台售后单号
+        jsonObject.put("cptretruncode", fsStoreAfterSales.getId());
+        //申请退款金额
+        jsonObject.put("frefundamt", fsStoreAfterSales.getRefundAmount());
+
+        Integer iaftersalesstatus = null;
+        //退货退款
+        if (Integer.valueOf(1).equals(fsStoreAfterSales.getRefundType())) {
+            if (fsStoreAfterSales.getSalesStatus().equals(1)) {
+                //用户取消申请
+                iaftersalesstatus = 30;
+            } else if (fsStoreAfterSales.getSalesStatus().equals(2)) {
+                //商家拒绝
+                iaftersalesstatus = 50;
+            } else if (fsStoreAfterSales.getSalesStatus().equals(3) && fsStoreAfterSales.getStatus().equals(4)) {
+                //已完成&&退款成功
+                iaftersalesstatus = 60;
+            } else {
+                //售后中
+                //售后中对应erp依然是申请阶段不需要做任何操作
+                BaseResponse baseResponse = new BaseResponse();
+                baseResponse.setSuccess(true);
+                return baseResponse;
+            }
+        } else if (Integer.valueOf(0).equals(fsStoreAfterSales.getRefundType())) {
+            if (fsStoreAfterSales.getSalesStatus().equals(1)) {
+                //用户取消申请
+                iaftersalesstatus = 30;
+            } else if (fsStoreAfterSales.getSalesStatus().equals(2)) {
+                //商家拒绝
+                iaftersalesstatus = 35;
+            } else if (fsStoreAfterSales.getSalesStatus().equals(3) && fsStoreAfterSales.getStatus().equals(4)) {
+                //已完成&&退款成功
+                iaftersalesstatus = 25;
+            } else {
+                //售后中
+                //售后中对应erp依然是申请阶段不需要做任何操作
+                BaseResponse baseResponse = new BaseResponse();
+                baseResponse.setSuccess(true);
+                return baseResponse;
+            }
+        }
+        //售后状态 10 申请部分退款;15 申请全额退款;25 同意退款;30 取消申请;35 驳回退款;40 申请退货退款;45 同意退货退款;50 驳回退货退款;55 退货成功;60 退款成功
+        jsonObject.put("iaftersalesstatus", iaftersalesstatus);
+        JSONObject omsOpenPtreturnorderStatuschange = hzOMSClient.send("oms_open_ptreturnorder_statuschange", jsonObject);
+        BaseResponse res = new BaseResponse();
+        res.setSuccess(true);
+        return res;
+    }
+
+    @Override
+    public ErpOrderResponse finishOrder(ErpOrder order) {
+        return null;
+    }
+
+    /**
+     * 构建瀚智创建订单参数
+     *
+     * @param orderCode
+     * @return
+     */
+    private JSONObject buildHzOMSOrder(String orderCode) {
+        //通过订单号查询更多订单信息
+        FsStoreOrder fsOrder = fsStoreOrderService.selectFsStoreOrderByOrderCode(orderCode);
+        FsStore fsStore = fsStoreService.selectFsStoreByStoreId(fsOrder.getStoreId());
+
+        JSONObject obj = new JSONObject();
+        String iordertype = "";
+        if (Integer.valueOf(1).equals(fsOrder.getShippingType())) {
+            iordertype = "2";
+        } else if (Integer.valueOf(2).equals(fsOrder.getShippingType())) {
+            iordertype = "1";
+        }
+        //订单类型 0 O2O配送订单; 1 O2O 自提订单; 2 B2C 快递配送
+        obj.put("iordertype", iordertype);
+        //订单单号
+        obj.put("cptordercode", fsOrder.getOrderCode());
+        //平台店铺编码 todo 测试环境只能写死 110111 用于联调测试 fsOrder.getStoreId()
+        obj.put("cptshopcode", 110111);
+        //平台店铺名称
+        obj.put("cptshopname", fsStore.getStoreName());
+        Integer iorderstatus = null;
+        //自提且已经支付
+        if ("1".equals(iordertype) && Integer.valueOf(1).equals(fsOrder.getIsPay())) {
+            iorderstatus = 30;
+        } else {
+            if (Integer.valueOf(1).equals(fsOrder.getStatus())) {
+                iorderstatus = 0;
+            } else if (Integer.valueOf(2).equals(fsOrder.getStatus())) {
+                iorderstatus = 5;
+            }
+        }
+        //订单状态 0待接单 5待拣货 10待配送 15配送中 20已完成 25已取消 30待自提
+        obj.put("iorderstatus", iorderstatus);
+
+        String userAddress = fsOrder.getUserAddress();
+        String[] s = null;
+        if (StringUtils.isNotBlank(userAddress)) {
+            s = userAddress.split(" ");
+        } else {
+            throw new RuntimeException("用户收货地址有问题");
+        }
+
+        //收货省
+        obj.put("cprovince", s[0]);
+        //收货市
+        obj.put("ccity", s[1]);
+        //收货区
+        obj.put("carea", s[2]);
+        //收货城镇乡 f
+//        obj.put("ctown", "");
+        //收货人密文 无密文填写明文
+        obj.put("creceivers", fsOrder.getUserName());
+        //收货人联系电话密文 无密文填写明文
+        obj.put("creceiversphone", fsOrder.getUserPhone());
+        //收货人详细地址密文 无密文填写明文
+        obj.put("creceiversaddress", userAddress);
+        //收货人脱敏信息
+        obj.put("cdesenreceivers", fsOrder.getUserName());
+        //收货联系电话脱敏信息
+        obj.put("cdesenreceiversphone", PhoneUtil.decryptPhone(fsOrder.getUserPhone()));
+        //收货联系地址脱敏信息
+        obj.put("cdesenreceiversaddress", userAddress);
+        //订单总金额 单位元
+        obj.put("forderamount", fsOrder.getTotalPrice());
+        //支付金额 单位元
+        obj.put("fpayamount", fsOrder.getPayPrice());
+        //订单总优惠 单位元 f
+        obj.put("fdiscamount", fsOrder.getDiscountMoney());
+        //商家优惠 f
+//        obj.put("fpoidisc", "");
+        //平台优惠 f
+//        obj.put("fplatformdisc", "");
+        //运费优惠 f
+//        obj.put("ffreightdiscount", "");
+        //运费 f
+        obj.put("ffreight", fsOrder.getDeliveryPayMoney());
+        //下单时间 格式 yyyy-MM-dd hh:mm:ss 如:2025-01-01 00:11:22
+        obj.put("dorderstarttime", fsOrder.getCreateTime());
+        //是否处方 0 否 1 是 可选
+        obj.put("iisprescription", fsOrder.getIsPrescribe());
+        //买家备注 f
+        obj.put("corderremark", fsOrder.getRemark());
+        //商家备注 f
+//        obj.put("csellermessage", "");
+        //自提订单自提码 f
+//        obj.put("ctakecode", "");
+        //订单旗帜 1 红 2 黄 3 绿 4 蓝 5 紫 f
+//        obj.put("corderflag", "");
+        //支付时间  格式 yyyy-MM-dd hh:mm:ss 如:2025-01-01 00:11:22 f
+        obj.put("dpurchasetime", fsOrder.getPayTime());
+        //预计送达时间 格式 yyyy-MM-dd hh:mm:ss 如:2025-01-01 00:11:22 f
+//        obj.put("dpredeliverytime", "");
+        //实际送达时间  格式 yyyy-MM-dd hh:mm:ss 如:2025-01-01 00:11:22 f
+//        obj.put("dconfirmtime", "");
+        List<FsStoreOrderItem> fsStoreOrderItems = fsStoreOrderItemService.selectFsStoreOrderItemListByOrderId(fsOrder.getOrderId());
+        int totalOrderItemCount = fsStoreOrderItems.size();
+        BigDecimal divide = fsOrder.getDiscountMoney().divide(BigDecimal.valueOf(totalOrderItemCount), 2, BigDecimal.ROUND_HALF_UP);
+        JSONArray goodArr = new JSONArray();
+
+        fsStoreOrderItems.forEach(fsStoreOrderItem -> {
+            JSONObject goodItem = new JSONObject();
+            //商品编码
+            goodItem.put("cptgoodsid", fsStoreOrderItem.getProductId());
+            //商品规格编码 f
+            goodItem.put("cptspeccode", fsStoreOrderItem.getProductAttrValueId());
+
+            FsStoreProduct fsStoreProduct = fsStoreProductService.selectFsStoreProductById(fsStoreOrderItem.getProductId());
+            FsStoreProductAttrValue fsStoreProductAttrValue = new FsStoreProductAttrValue();
+            //判断是否含有商品规格信息 有则查询商品规格信息 没有取商品的价格
+            if(null != fsStoreOrderItem.getProductAttrValueId()){
+                fsStoreProductAttrValue = fsStoreProductAttrValueService.selectFsStoreProductAttrValueById(fsStoreOrderItem.getProductAttrValueId());
+            }else{
+                fsStoreProductAttrValue.setPrice(fsStoreProduct.getPrice());
+            }
+            //商品名称
+            goodItem.put("cgoodsname", fsStoreProduct.getProductName());
+            //商品规格名称 f
+//            goodItem.put("cspecname", );
+            //购买数量
+            goodItem.put("fqty", fsStoreOrderItem.getNum());
+            //原单价
+            goodItem.put("fnormprice", fsStoreProductAttrValue.getPrice());
+
+            //实售单价 优惠后的单价 单位元
+            goodItem.put("fprice", fsStoreProductAttrValue.getPrice().subtract(divide));
+            //商品优惠金额 f
+//            goodItem.put("fdiscprice", new BigDecimal(0));
+            //商品条码 f
+//            goodItem.put("cbarcode", "");
+            goodArr.add(goodItem);
+        });
+        //订单商品信息
+        obj.put("ptorder_goods_list", goodArr);
+
+        return obj;
+    }
+
+    /**
+     * 构建申请售后订单参数
+     *
+     * @param orderCode
+     * @return
+     */
+    private JSONObject buildRefundOrder(String orderCode, Long storeAfterSalesId) {
+        //通过订单号查询更多订单信息
+        FsStoreOrder fsOrder = fsStoreOrderService.selectFsStoreOrderByOrderCode(orderCode);
+
+        Long orderId = fsOrder.getOrderId();
+        FsStoreAfterSales fsStoreAfterSales = fsStoreAfterSalesService.selectFsStoreAfterSalesById(storeAfterSalesId);
+
+        JSONObject obj = new JSONObject();
+        //平台店铺编码 todo 测试环境只能写死 110111 用于联调测试 fsStoreAfterSales.getStoreId()
+        obj.put("cptshopcode", 110111);
+        //平台订单号
+        obj.put("cptordercode", orderCode);
+        //平台售后单号
+        obj.put("cptretruncode", fsStoreAfterSales.getId());
+        Integer iretruntype = null;
+        if (Integer.valueOf(0).equals(fsStoreAfterSales.getRefundType())) {
+            iretruntype = 5;
+        } else if (Integer.valueOf(1).equals(fsStoreAfterSales.getRefundType())) {
+            iretruntype = 1;
+        }
+        //售后类型 1 退货退款 5 仅退款
+        obj.put("iretruntype", iretruntype);
+        //申请类型 0 部分退款 1 全部退款
+        obj.put("iservicetype", Integer.valueOf(1));
+        Integer iaftersalesstatus = null;
+        //退货退款
+        if (iretruntype.equals(1)) {
+            if (fsStoreAfterSales.getStatus().equals(0)) {
+                //申请退货退款
+                iaftersalesstatus = 40;
+            }
+        } else if (iretruntype.equals(5)) {
+            if (fsStoreAfterSales.getStatus().equals(0)) {
+                //申请全额退款
+                iaftersalesstatus = 15;
+            }
+        }
+
+        //售后状态10 申请部分退款;15 申请全额退款 25 同意退款 30 取消申请 35 驳回退款申请 40 申请退货退款 45 同意退货退款 50 驳回退货退款申请 55 退货成功 60 退款成功
+        obj.put("iaftersalesstatus", iaftersalesstatus);
+        //申请退款金额
+        obj.put("frefundamt", fsStoreAfterSales.getRefundAmount());
+        //申请原因 f
+        obj.put("creason", fsStoreAfterSales.getReasons());
+        //售后图片url地址 f
+        obj.put("cimgurl", fsStoreAfterSales.getExplainImg());
+
+        JSONArray goodsList = new JSONArray();
+
+        List<FsStoreOrderItem> fsStoreOrderItems = fsStoreOrderItemService.selectFsStoreOrderItemListByOrderId(fsOrder.getOrderId());
+        int totalOrderItemCount = fsStoreOrderItems.size();
+        BigDecimal divide = fsOrder.getDiscountMoney().divide(BigDecimal.valueOf(totalOrderItemCount), 2, BigDecimal.ROUND_HALF_UP);
+        fsStoreOrderItems.forEach(fsStoreOrderItem -> {
+            JSONObject goodItem = new JSONObject();
+            //商品编码
+            goodItem.put("cptgoodsid", fsStoreOrderItem.getProductId());
+            //商品规格编码 f
+            goodItem.put("cptspeccode", fsStoreOrderItem.getProductAttrValueId());
+
+            FsStoreProduct fsStoreProduct = fsStoreProductService.selectFsStoreProductById(fsStoreOrderItem.getProductId());
+            FsStoreProductAttrValue fsStoreProductAttrValue = fsStoreProductAttrValueService.selectFsStoreProductAttrValueById(fsStoreOrderItem.getProductAttrValueId());
+            //商品名称
+            goodItem.put("cgoodsname", fsStoreProduct.getProductName());
+            //商品规格名称 f
+//            goodItem.put("cspecname", );
+            //本次申请数量
+            goodItem.put("fqty", fsStoreOrderItem.getNum());
+            //原单价
+            goodItem.put("fnormprice", fsStoreProductAttrValue.getPrice());
+            //本次申请退款单价 单位元
+            goodItem.put("fprice", fsStoreProductAttrValue.getPrice().subtract(divide));
+
+            goodsList.add(goodItem);
+        });
+        //售后商品信息
+        obj.put("ptreturnorder_goods_list", goodsList);
+
+        return obj;
+    }
+
+}

+ 6 - 1
fs-service/src/main/java/com/fs/his/config/FsSysConfig.java

@@ -28,7 +28,12 @@ public class FsSysConfig {
     String erpWdShopCode;
     String erpWdBaseUrl;
     String erpWarehouseCode;
-
+    //erp 瀚智OMS
+    String erpHzOMSAppKey;
+    String erpHzOMSAppsecret;
+    String erpHzOMSItenantid;
+    String erpHzOMTokenUrl;
+    String erpHzOMBaseUrl;
     //支付接口
     Integer payOpen;//是否开启
     String payPartnerId;

+ 6 - 0
fs-service/src/main/java/com/fs/his/mapper/FsStoreOrderMapper.java

@@ -1085,4 +1085,10 @@ public interface FsStoreOrderMapper
     @Select("select * from fs_store_order where  `status`=2 ")
     List<FsStoreOrder> selectWdtOmsOrderdeliveryOp();
 
+
+    @Select(" select * from fs_store_order where order_code=#{orderCode} and store_id=#{storeId}")
+    FsStoreOrder getOrderByOrderCodeAndStoreId(@Param("orderCode")String orderCode,@Param("storeId") Long storeId);
+
+    @Update("UPDATE fs_store_order SET delivery_code = #{order.deliveryCode} , delivery_name = #{order.deliveryName} , delivery_sn = #{order.deliverySn}   WHERE follow_doctor_id = #{order.orderId}")
+    int updateStoreOrderDeliveryInfo(@Param("order") FsStoreOrder order);
 }

+ 9 - 0
fs-service/src/main/java/com/fs/his/mapper/FsStoreProductAttrValueMapper.java

@@ -155,4 +155,13 @@ public interface FsStoreProductAttrValueMapper
     @Select("    select id,doctor_brokerage, product_id, sku, stock, sales, price, image, cost_price cost, bar_code, ot_price, weight, volume, brokerage, brokerage_two,brokerage_three,give_integral  from fs_store_product_attr_value\n" +
             "    where  product_id=#{productId}")
     List<FsStoreProductAttrValue> selectFsStoreProductAttrValueVOByProductId(Long productId);
+
+    @Select(" select * from fs_store_product_attr_value where id=#{id} and product_id=#{productId} ")
+    FsStoreProductAttrValue  selectFsStoreProductAttrValueByIdAndPruductId(@Param("id") Long id,@Param("productId") Long productId);
+
+    @Update(" update fs_store_product_attr_value set stock = #{stock} where id = #{id} ")
+    int updateStoreProductAttrValueStock(Long id,Integer stock);
+
+    @Select("select * from fs_store_product_attr_value where product_id = #{productId}")
+    List<FsStoreProductAttrValue> selectFsStoreProductAttrValueListByProductId(@Param("productId") Long productId);
 }

+ 29 - 17
fs-service/src/main/java/com/fs/his/mapper/FsStoreProductMapper.java

@@ -18,8 +18,7 @@ import java.util.List;
  * @author fs
  * @date 2023-06-08
  */
-public interface FsStoreProductMapper
-{
+public interface FsStoreProductMapper {
     /**
      * 查询商品
      *
@@ -58,9 +57,9 @@ public interface FsStoreProductMapper
             "<if test = 'maps.barCode != null    '> " +
             "and p.product_id in(SELECT product_id FROM fs_store_product_attr_value WHERE bar_code =#{maps.barCode}) " +
             "</if>" +
-            " order by p.product_id desc "+
+            " order by p.product_id desc " +
             "</script>"})
-    public List<FsStoreProductVO> selectFsStoreProductListVO(@Param("maps")FsStoreProduct fsStoreProduct);
+    public List<FsStoreProductVO> selectFsStoreProductListVO(@Param("maps") FsStoreProduct fsStoreProduct);
 
     @Select({"<script> " +
             "select p.*,pc.cate_name,st.store_name  from fs_store_product p left join fs_store_product_category pc on p.cate_id=pc.cate_id LEFT JOIN fs_store st ON st.store_id=p.store_id  " +
@@ -83,7 +82,7 @@ public interface FsStoreProductMapper
             "<if test = 'maps.barCode != null    '> " +
             "and p.product_id in(SELECT product_id FROM fs_store_product_attr_value WHERE bar_code =#{maps.barCode}) " +
             "</if>" +
-            " order by p.product_id desc "+
+            " order by p.product_id desc " +
             "</script>"})
     public List<FsStoreProductListSVO> selectFsStoreProductListSVO(@Param("maps") FsStoreProductListSParam fsStoreProduct);
 
@@ -124,12 +123,14 @@ public interface FsStoreProductMapper
 
     @Select("select * FROM fs_store_product_rule WHERE is_del=0")
     List<FsStoreProductRule> selectFsStoreProductRuleList();
+
     @Update("update fs_store_product_attr_value set stock=stock+#{num}, sales=sales-#{num}" +
             " where product_id=#{productId} and id=#{productAttrValueId}")
-    int incProductAttrStock(@Param("num")Long num,@Param("productId") Long productId,@Param("productAttrValueId") Long productAttrValueId);
+    int incProductAttrStock(@Param("num") Long num, @Param("productId") Long productId, @Param("productAttrValueId") Long productAttrValueId);
+
     @Update("update fs_store_product set stock=stock+#{num}, sales=sales-#{num}" +
             " where product_id=#{productId}")
-    int incStockDecSales( @Param("num")Long num, @Param("productId")Long productId);
+    int incStockDecSales(@Param("num") Long num, @Param("productId") Long productId);
 
 
     @Select({"<script> " +
@@ -153,17 +154,17 @@ public interface FsStoreProductMapper
             "<if test = 'maps.barCode != null    '> " +
             "and p.product_id in(SELECT product_id FROM fs_store_product_attr_value WHERE bar_code =#{maps.barCode}) " +
             "</if>" +
-            " order by p.product_id desc "+
+            " order by p.product_id desc " +
             "</script>"})
-    public List<Long> selectFsStoreProductIdList(@Param("maps")FsStoreProduct fsStoreProduct);
+    public List<Long> selectFsStoreProductIdList(@Param("maps") FsStoreProduct fsStoreProduct);
 
     @Update({"<script> " +
-            "UPDATE fs_store_product SET price=price*#{price} , ot_price=ot_price*#{price} WHERE product_id in"+
+            "UPDATE fs_store_product SET price=price*#{price} , ot_price=ot_price*#{price} WHERE product_id in" +
             "<foreach item=\"id\" collection=\"ids\" open=\"(\" separator=\",\" close=\")\">\n" +
             "            #{id}\n" +
-            "        </foreach>"+
+            "        </foreach>" +
             "</script>"})
-    int updateFsStoreProductPrice(@Param("ids")List<Long> ids,@Param("price") double price);
+    int updateFsStoreProductPrice(@Param("ids") List<Long> ids, @Param("price") double price);
 
     @Select({"<script> " +
             "select p.*,pc.cate_name,st.store_name  from fs_store_product p left join fs_store_product_category pc on p.cate_id=pc.cate_id LEFT JOIN fs_store st ON st.store_id=p.store_id  " +
@@ -186,9 +187,10 @@ public interface FsStoreProductMapper
             "<if test = 'maps.barCode != null    '> " +
             "and p.product_id in(SELECT product_id FROM fs_store_product_attr_value WHERE bar_code =#{maps.barCode}) " +
             "</if>" +
-            " order by p.product_id desc "+
+            " order by p.product_id desc " +
             "</script>"})
-    List<FsStoreProductExcelVO> selectFsStoreProductExcelVO(@Param("maps")FsStoreProduct fsStoreProduct);
+    List<FsStoreProductExcelVO> selectFsStoreProductExcelVO(@Param("maps") FsStoreProduct fsStoreProduct);
+
     @Select({"<script> " +
             "select v.*,p.product_name,p.product_type,p.is_drug,c.cate_name,store.store_name,p.prescribe_spec  from fs_store_product_attr_value v inner join fs_store_product p on p.product_id=v.product_id left join fs_store_product_category c on c.cate_id=p.cate_id LEFT JOIN fs_store store ON store.store_id=p.store_id      " +
             "where 1=1 and v.bar_code is not null " +
@@ -204,9 +206,9 @@ public interface FsStoreProductMapper
             "<if test = 'maps.cateId != null    '> " +
             "and (p.cate_id =#{maps.cateId} or c.pid=#{maps.cateId} )" +
             "</if>" +
-            " order by v.id desc "+
+            " order by v.id desc " +
             "</script>"})
-    List<FsStoreProductAttrValueVO> selectFsStoreProductAttrValueListVO(@Param("maps")FsProductAttrValueParam param);
+    List<FsStoreProductAttrValueVO> selectFsStoreProductAttrValueListVO(@Param("maps") FsProductAttrValueParam param);
 
     @Select("SELECT * FROM fs_store_product\n" +
             "WHERE images LIKE '%https://htj-1258038825.cos.ap-beijing.myqcloud.com%'; ")
@@ -218,6 +220,7 @@ public interface FsStoreProductMapper
 
     @Select("select * FROM fs_store_product where bar_code =#{barCode} and (store_id = 30 or store_id = 33)")
     List<FsStoreProduct> selectCode(String barCode);
+
     @Select("select v.*,p.product_name,p.product_type,p.is_drug,c.cate_name,store.store_name,p.prescribe_spec  from fs_store_product_attr_value v inner join fs_store_product p on p.product_id=v.product_id left join fs_store_product_category c on c.cate_id=p.cate_id LEFT JOIN fs_store store ON store.store_id=p.store_id\n" +
             "where 1=1 and v.product_id=#{productId} limit 1")
     FsStoreProductAttrValueVO selectFsStoreProductAttrValueVOByProdId(Long productId);
@@ -227,6 +230,7 @@ public interface FsStoreProductMapper
     FsStoreProductAttrVO selectFsStoreProductAttrVOByProdId(Long productId);
 
     FsStoreProduct selectFsStoreProductById(Long productId);
+
     @Select({"<script> " +
             "select count(1) from fs_store_product  " +
             "where 1=1 " +
@@ -237,7 +241,7 @@ public interface FsStoreProductMapper
             "and find_in_set(#{companyIds}, company_ids) " +
             "</if>" +
             "</script>"})
-    Long selectFsStoreProductCompanyCount(@Param("type") int type,@Param("companyIds") Long companyIds);
+    Long selectFsStoreProductCompanyCount(@Param("type") int type, @Param("companyIds") Long companyIds);
 
     @Select({"<script> " +
             "select count(1) from fs_store_product  " +
@@ -247,4 +251,12 @@ public interface FsStoreProductMapper
             "</if>" +
             "</script>"})
     Long selectFsStoreProductCount(int type);
+
+    @Select(" select * from fs_store_product where product_id = #{productId} and store_id = #{storeId}")
+    FsStoreProduct getStoreProductByProductIdAndStoreId(@Param("productId") Long productId, @Param("storeId") Long storeId);
+
+    @Update({"UPDATE fs_store_product SET stock=#{stock}  WHERE product_id = #{productId} "})
+    int updateStoreProductStock(@Param("productId") Long productId, @Param("stock") Integer stock);
+
+
 }

+ 16 - 0
fs-service/src/main/java/com/fs/his/param/HzOMSErpApiParam.java

@@ -0,0 +1,16 @@
+package com.fs.his.param;
+
+import lombok.Data;
+
+@Data
+public class HzOMSErpApiParam {
+
+    //瀚智分配的appkey
+    private String appkey;
+
+    private String timestamp;
+
+    private String datapakege;
+
+    private String sign;
+}

+ 37 - 0
fs-service/src/main/java/com/fs/his/service/ErpApiService.java

@@ -0,0 +1,37 @@
+package com.fs.his.service;
+
+import com.alibaba.fastjson.JSONObject;
+import com.fs.his.param.HzOMSErpApiParam;
+import com.fs.his.vo.HzOMSErpResponseVO;
+import org.apache.poi.ss.formula.functions.T;
+
+public interface ErpApiService {
+
+    /**
+     * hzoms 同步商品库存
+     * @param param
+     * @return
+     */
+    HzOMSErpResponseVO stockSync(HzOMSErpApiParam param);
+
+    /**
+     * hzoms 用于将瀚智商品库存同步到第三方
+     * @param param
+     * @return
+     */
+    HzOMSErpResponseVO  skuStockSync(HzOMSErpApiParam param);
+
+    /**
+     * hzoms 平台订单物流信息回传
+     * @param param
+     * @return
+     */
+    HzOMSErpResponseVO  logisticsAdd(HzOMSErpApiParam param);
+
+    /**
+     * hzoms 解码参数
+     * @param s
+     * @return
+     */
+    JSONObject getDecodeDataJSON(String s);
+}

+ 4 - 0
fs-service/src/main/java/com/fs/his/service/IFsStoreOrderService.java

@@ -211,4 +211,8 @@ public interface IFsStoreOrderService
     ErpOrder getErpOrder(FsStoreOrder order) throws ParseException;
 
     Integer selectFsStoreOrderCountByType(Long companyId, long l, int i);
+
+    FsStoreOrder getOrderByOrderCodeAndStoreId(String orderCode, Long storeId);
+
+    int updateStoreOrderDeliveryInfo(FsStoreOrder order);
 }

+ 6 - 0
fs-service/src/main/java/com/fs/his/service/IFsStoreProductAttrValueService.java

@@ -62,4 +62,10 @@ public interface IFsStoreProductAttrValueService
     public int deleteFsStoreProductAttrValueById(Long id);
 
     List<FsStoreProductAttrValueListDVO> selectFsStoreProductAttrValueListDVO(FsStoreProductAttrValueListDParam param);
+
+    FsStoreProductAttrValue selectFsStoreProductAttrValueByIdAndPruductId(Long id, Long productId);
+
+    int updateStoreProductAttrValueStock(Long id , Integer stock);
+
+    List<FsStoreProductAttrValue> selectFsStoreProductAttrValueListByProductId( Long productId);
 }

+ 3 - 0
fs-service/src/main/java/com/fs/his/service/IFsStoreProductService.java

@@ -94,4 +94,7 @@ public interface IFsStoreProductService
     Long selectFsStoreProductCount(int type, Long companyId);
     Long selectFsStoreProductCount(int type);
 
+    FsStoreProduct getStoreProductByProductIdAndStoreId(Long productId, Long storeId);
+
+    int updateStoreProductStock(Long productId, Integer num);
 }

+ 131 - 110
fs-service/src/main/java/com/fs/his/service/impl/FsStoreAfterSalesServiceImpl.java

@@ -22,6 +22,7 @@ import com.fs.company.service.ICompanyService;
 import com.fs.company.service.impl.CompanyServiceImpl;
 import com.fs.core.config.WxPayProperties;
 import com.fs.core.utils.OrderCodeUtils;
+import com.fs.his.config.FsSysConfig;
 import com.fs.his.config.StoreConfig;
 import com.fs.erp.dto.BaseResponse;
 import com.fs.erp.dto.ErpRefundUpdateRequest;
@@ -35,6 +36,7 @@ import com.fs.his.enums.FsStoreOrderStatusEnum;
 import com.fs.his.mapper.*;
 import com.fs.his.param.*;
 import com.fs.his.service.*;
+import com.fs.his.utils.ConfigUtil;
 import com.fs.his.vo.*;
 import com.fs.huifuPay.domain.HuiFuRefundResult;
 import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentScanpayRefundRequest;
@@ -62,6 +64,7 @@ import com.google.gson.Gson;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -93,6 +96,10 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
     private TzBankService tzBankService;
     @Autowired
     private IErpOrderService erpOrderService;
+    @Autowired
+    @Qualifier("hzOMSErpOrderServiceImpl")
+    private IErpOrderService hzOMSerpOrderService;
+
     @Autowired
     private FsStorePaymentMapper fsStorePaymentMapper;
     @Autowired
@@ -128,7 +135,8 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
     FsExportTaskMapper fsExportTaskMapper;
     @Autowired
     IFsStoreOrderBillLogService fsStoreOrderBillLogService;
-
+    @Autowired
+    private ConfigUtil configUtil;
 
     /**
      * 查询售后记录
@@ -222,29 +230,29 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
     @Override
     public int auditing(FsStoreAfterSales fsStoreAfterSales) {
         FsStoreAfterSales order = fsStoreAfterSalesMapper.selectFsStoreAfterSalesById(fsStoreAfterSales.getId());
-        if (order==null) {
+        if (order == null) {
 
-        throw new CustomException("订单不存在");
+            throw new CustomException("订单不存在");
         }
-        if (order.getSalesStatus()!=0){
+        if (order.getSalesStatus() != 0) {
             throw new CustomException("非法更改");
         }
-        Integer status=null;
+        Integer status = null;
         FsStoreAfterSales fs = new FsStoreAfterSales();
-        if (order.getOrderStatus()==2){
-            status=3;
-        }else if (order.getOrderStatus()==3){
+        if (order.getOrderStatus() == 2) {
+            status = 3;
+        } else if (order.getOrderStatus() == 3) {
             FsStore fsStore = fsStoreMapper.selectFsStoreByStoreId(order.getStoreId());
             fs.setPhoneNumber(fsStore.getRefundPhone());
             fs.setAddress(fsStore.getRefundAddress());
             fs.setConsignee(fsStore.getRefundConsignee());
-            status=2;
-        }else if (order.getOrderStatus()==4){
+            status = 2;
+        } else if (order.getOrderStatus() == 4) {
             FsStore fsStore = fsStoreMapper.selectFsStoreByStoreId(order.getStoreId());
             fs.setPhoneNumber(fsStore.getRefundPhone());
             fs.setAddress(fsStore.getRefundAddress());
             fs.setConsignee(fsStore.getRefundConsignee());
-            status=1;
+            status = 1;
         }
 
         fs.setId(fsStoreAfterSales.getId());
@@ -264,9 +272,13 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
     @Override
     public int noAuditing(FsStoreAfterSales fsStoreAfterSales) {
         FsStoreAfterSales order = fsStoreAfterSalesMapper.selectFsStoreAfterSalesById(fsStoreAfterSales.getId());
-        if (order==null)throw new CustomException("订单不存在");
-        if (order.getSalesStatus()!=0){throw new CustomException("非法更改");}
-        if (order.getStatus()==5){throw new CustomException("非法更改");}
+        if (order == null) throw new CustomException("订单不存在");
+        if (order.getSalesStatus() != 0) {
+            throw new CustomException("非法更改");
+        }
+        if (order.getStatus() == 5) {
+            throw new CustomException("非法更改");
+        }
         FsStoreAfterSales fs = new FsStoreAfterSales();
         fs.setId(fsStoreAfterSales.getId());
         fs.setSalesStatus(2);
@@ -276,7 +288,7 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
         logs.setChangeTime(new DateTime());
         logs.setChangeType(FsStoreAfterSalesStatusEnum.STATUS_6.getValue());
         logs.setStoreAfterSalesId(fsStoreAfterSales.getId());
-        logs.setChangeMessage(FsStoreAfterSalesStatusEnum.STATUS_6.getDesc()+" "+fsStoreAfterSales.getRemark());
+        logs.setChangeMessage(FsStoreAfterSalesStatusEnum.STATUS_6.getDesc() + " " + fsStoreAfterSales.getRemark());
         logs.setOperator(fsStoreAfterSales.getOperator());
         fsStoreAfterSalesLogsMapper.insertFsStoreAfterSalesLogs(logs);
 //        FsStoreOrderLogs Logs = new FsStoreOrderLogs();
@@ -289,33 +301,33 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
         or.setOrderId(order.getOrderId());
         or.setStatus(order.getOrderStatus());
         fsStoreOrderMapper.updateFsStoreOrder(or);
-        if (order.getOrderStatus()==2){
+        if (order.getOrderStatus() == 2) {
             FsStoreOrder fsStoreOrder = fsStoreOrderMapper.selectFsStoreOrderByOrderId(order.getOrderId());
-            String newOrderSn =  OrderCodeUtils.getOrderSn();
-            if(StringUtils.isEmpty(newOrderSn)){
-                newOrderSn =  OrderCodeUtils.getOrderSn();
+            String newOrderSn = OrderCodeUtils.getOrderSn();
+            if (StringUtils.isEmpty(newOrderSn)) {
+                newOrderSn = OrderCodeUtils.getOrderSn();
             }
             FsStoreOrder newOrder = new FsStoreOrder();
             newOrder.setOrderId(order.getOrderId());
             newOrder.setOrderCode(newOrderSn);
             fsStoreOrderMapper.updateFsStoreOrder(newOrder);
             or.setOrderCode(newOrderSn);
-            if (fsStoreOrder.getPackageOrderId()!=null){
+            if (fsStoreOrder.getPackageOrderId() != null) {
                 FsPackageOrder fsPackageOrder = new FsPackageOrder();
                 fsPackageOrder.setOrderId(fsStoreOrder.getPackageOrderId());
                 fsPackageOrder.setOrderSn(newOrderSn);
                 fsPackageOrderMapper.updateFsPackageOrder(fsPackageOrder);
             }
-            if (fsStoreOrder.getInquiryOrderId()!=null){
+            if (fsStoreOrder.getInquiryOrderId() != null) {
                 FsInquiryOrder fsInquiryOrder = new FsInquiryOrder();
                 fsInquiryOrder.setOrderSn(newOrderSn);
                 fsInquiryOrder.setOrderId(fsStoreOrder.getInquiryOrderId());
                 fsInquiryOrderMapper.updateFsInquiryOrder(fsInquiryOrder);
             }
 
-            List<FsStorePayment> payments = fsStorePaymentMapper.selectFsStorePaymentByPay(2,fsStoreOrder.getOrderId());
-            if (fsStoreOrder.getPackageOrderId()!=null){
-                payments = fsStorePaymentMapper.selectFsStorePaymentByPay(3,fsStoreOrder.getPackageOrderId());
+            List<FsStorePayment> payments = fsStorePaymentMapper.selectFsStorePaymentByPay(2, fsStoreOrder.getOrderId());
+            if (fsStoreOrder.getPackageOrderId() != null) {
+                payments = fsStorePaymentMapper.selectFsStorePaymentByPay(3, fsStoreOrder.getPackageOrderId());
             }
             for (FsStorePayment payment : payments) {
                 FsStorePayment fsStorePayment = new FsStorePayment();
@@ -333,10 +345,6 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
         }
 
 
-
-
-
-
         return 1;
     }
 
@@ -345,8 +353,8 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
     public int refundMoney(FsStoreAfterSales fsStoreAfterSales) {
         FsStoreAfterSales order = fsStoreAfterSalesMapper.selectFsStoreAfterSalesById(fsStoreAfterSales.getId());
         FsStoreOrder fsStoreOrder = fsStoreOrderMapper.selectFsStoreOrderByOrderId(order.getOrderId());
-        if (order==null)throw new CustomException("订单不存在");
-        if (order.getStatus()!=3)throw new CustomException("非法更改");
+        if (order == null) throw new CustomException("订单不存在");
+        if (order.getStatus() != 3) throw new CustomException("非法更改");
         //更改售后订单状态
         FsStoreAfterSales fs = new FsStoreAfterSales();
         fs.setId(fsStoreAfterSales.getId());
@@ -373,20 +381,20 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
         Logs.setChangeType(FsStoreOrderStatusEnum.REFUND_STATUS_2.getValue().toString());
         fsStoreOrderLogsMapper.insertFsStoreOrderLogs(Logs);
         BigDecimal reMoney = order.getRefundAmount();
-        String orderType="store";
+        String orderType = "store";
         // 开票冲红
         fsStoreOrderBillLogService.billBackByOrderId(fsStoreOrder.getOrderId());
 
 
-        if (fsStoreOrder.getPackageOrderId()!=null){
-            orderType="package";
+        if (fsStoreOrder.getPackageOrderId() != null) {
+            orderType = "package";
             FsPackageOrder fsPackageOrder = fsPackageOrderMapper.selectFsPackageOrderByOrderId(fsStoreOrder.getPackageOrderId());
-            if (fsPackageOrder!=null){
+            if (fsPackageOrder != null) {
                 fsPackageOrder.setStatus(-2);
                 fsPackageOrder.setRefundStatus(2);
                 fsPackageOrderMapper.updateFsPackageOrder(fsPackageOrder);
             }
-            if (fsPackageOrder.getInquiryOrderId()!=null){
+            if (fsPackageOrder.getInquiryOrderId() != null) {
                 FsInquiryOrder fsInquiryOrder = new FsInquiryOrder();
                 fsInquiryOrder.setOrderId(fsPackageOrder.getInquiryOrderId());
                 fsInquiryOrder.setStatus(-2);
@@ -404,7 +412,7 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
 //                productService.incProductStock(vo.getNum(), vo.getProductId(), vo.getProductAttrValueId());
 //            }
 //        }
-        if (order.getCompanyId()!=null){
+        if (order.getCompanyId() != null) {
             companyService.refundCompanyMoney(fsStoreOrder);
         }
 
@@ -414,15 +422,15 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
 //            fsUserService.subUserIntegral(fsStoreOrder.getUserId(),fsStoreOrder.getOrderId(),2);
 //        }
 
-        List<FsStorePayment> payments = fsStorePaymentMapper.selectFsStorePaymentByPay(2,fsStoreOrder.getOrderId());
-        if (fsStoreOrder.getPackageOrderId()!=null){
+        List<FsStorePayment> payments = fsStorePaymentMapper.selectFsStorePaymentByPay(2, fsStoreOrder.getOrderId());
+        if (fsStoreOrder.getPackageOrderId() != null) {
 
-            payments = fsStorePaymentMapper.selectFsStorePaymentByPay(3,fsStoreOrder.getPackageOrderId());
+            payments = fsStorePaymentMapper.selectFsStorePaymentByPay(3, fsStoreOrder.getPackageOrderId());
         }
-        if(payments!=null&&payments.size()>0){
-            FsStorePayment payment=payments.get(0);
-            String json=configService.selectConfigByKey("his.pay");
-            if(payment.getPayMode().equals("wx")){
+        if (payments != null && payments.size() > 0) {
+            FsStorePayment payment = payments.get(0);
+            String json = configService.selectConfigByKey("his.pay");
+            if (payment.getPayMode().equals("wx")) {
                 WxPayConfig payConfig = new WxPayConfig();
                 SysConfig sysConfig = sysConfigMapper.selectConfigByConfigKey("his.pay");
                 FsPayConfig fsPayConfig = new Gson().fromJson(sysConfig.getConfigValue(), FsPayConfig.class);
@@ -434,106 +442,111 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
                 payConfig.setSubMchId(org.apache.commons.lang3.StringUtils.trimToNull(null));
                 wxPayService.setConfig(payConfig);
                 WxPayRefundRequest refundRequest = new WxPayRefundRequest();
-                refundRequest.setOutTradeNo(orderType+"-"+payment.getPayCode());
-                refundRequest.setOutRefundNo(orderType+"-"+payment.getPayCode());
+                refundRequest.setOutTradeNo(orderType + "-" + payment.getPayCode());
+                refundRequest.setOutRefundNo(orderType + "-" + payment.getPayCode());
                 refundRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(payment.getPayMoney().toString()));
                 refundRequest.setRefundFee(WxPayUnifiedOrderRequest.yuanToFen(payment.getPayMoney().toString()));
                 try {
                     WxPayRefundResult refundResult = wxPayService.refund(refundRequest);
                     WxPayRefundQueryResult refundQueryResult = wxPayService.refundQuery("", refundResult.getOutTradeNo(), refundResult.getOutRefundNo(), refundResult.getRefundId());
-                    if(refundQueryResult!=null&&refundQueryResult.getResultCode().equals("SUCCESS")){
-                        FsStorePayment paymentMap=new FsStorePayment();
+                    if (refundQueryResult != null && refundQueryResult.getResultCode().equals("SUCCESS")) {
+                        FsStorePayment paymentMap = new FsStorePayment();
                         paymentMap.setPaymentId(payment.getPaymentId());
                         paymentMap.setStatus(-1);
                         paymentMap.setRefundTime(DateUtils.getNowDate());
                         paymentMap.setRefundMoney(payment.getPayMoney());
                         fsStorePaymentMapper.updateFsStorePayment(paymentMap);
-                    }
-                    else {
-                        throw new CustomException("退款请求失败"+refundQueryResult.getReturnMsg());
+                    } else {
+                        throw new CustomException("退款请求失败" + refundQueryResult.getReturnMsg());
                     }
                 } catch (WxPayException e) {
-                    throw new CustomException("退款请求失败"+e.getReturnMsg());
+                    throw new CustomException("退款请求失败" + e.getReturnMsg());
                 }
-            }
-            else if(payment.getPayMode().equals("yb")){
+            } else if (payment.getPayMode().equals("yb")) {
                 //易宝
-                RefundDTO refundDTO=new RefundDTO();
+                RefundDTO refundDTO = new RefundDTO();
                 refundDTO.setRefundMoney(payment.getPayMoney().toString());
-                refundDTO.setLowRefundNo(orderType+"-"+payment.getPayCode());
+                refundDTO.setLowRefundNo(orderType + "-" + payment.getPayCode());
                 refundDTO.setUpOrderId(payment.getTradeNo());
-                com.fs.ybPay.domain.RefundResult result=payService.refund(refundDTO);
-                logger.info("订单退款返回结果:退款订单id:"+order.getOrderId()+result);
-                if(result.getState().equals("5")){
-                    FsStorePayment paymentMap=new FsStorePayment();
+                com.fs.ybPay.domain.RefundResult result = payService.refund(refundDTO);
+                logger.info("订单退款返回结果:退款订单id:" + order.getOrderId() + result);
+                if (result.getState().equals("5")) {
+                    FsStorePayment paymentMap = new FsStorePayment();
                     paymentMap.setPaymentId(payment.getPaymentId());
                     paymentMap.setStatus(-1);
                     paymentMap.setRefundTime(DateUtils.getNowDate());
                     paymentMap.setRefundMoney(payment.getPayMoney());
                     fsStorePaymentMapper.updateFsStorePayment(paymentMap);
-                }else {
-                    throw new CustomException("退款请求失败"+result.getMessage());
+                } else {
+                    throw new CustomException("退款请求失败" + result.getMessage());
                 }
-            } else if(payment.getPayMode().equals("tz")){
+            } else if (payment.getPayMode().equals("tz")) {
                 RefundParam tzBankResult = new RefundParam();
                 // 使用set方法为对象的字段赋值
                 //商户原支付订单号
-                tzBankResult.setOldPayOutOrderNo(orderType+payment.getPayCode());
+                tzBankResult.setOldPayOutOrderNo(orderType + payment.getPayCode());
                 // 商户退款订单号 对接平台系统里自己生成的退款订单号
-                tzBankResult.setRefundOrderNo(orderType+payment.getPayCode());
+                tzBankResult.setRefundOrderNo(orderType + payment.getPayCode());
                 // 交易发送时间 yyyyMMddHHmmss
                 SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
                 tzBankResult.setTrxSendTime(sdf.format(new Date()));
                 // 退款金额
                 tzBankResult.setRefundOrdTransAmt(payment.getPayMoney().doubleValue());
                 TzBankResult<RefundResult> result = tzBankService.refund(tzBankResult);
-                logger.info("订单退款返回结果:退款订单id:"+order.getOrderId()+result);
-                if(result.getBody().getRefundOrdStatus().equals("90")||result.getBody().getRefundOrdStatus().equals("60")){
-                    FsStorePayment paymentMap=new FsStorePayment();
+                logger.info("订单退款返回结果:退款订单id:" + order.getOrderId() + result);
+                if (result.getBody().getRefundOrdStatus().equals("90") || result.getBody().getRefundOrdStatus().equals("60")) {
+                    FsStorePayment paymentMap = new FsStorePayment();
                     paymentMap.setPaymentId(payment.getPaymentId());
                     paymentMap.setStatus(-1);
                     paymentMap.setRefundTime(DateUtils.getNowDate());
                     paymentMap.setRefundMoney(payment.getPayMoney());
                     fsStorePaymentMapper.updateFsStorePayment(paymentMap);
-                }else {
-                    throw new CustomException("退款请求失败"+result.getRetMsg());
+                } else {
+                    throw new CustomException("退款请求失败" + result.getRetMsg());
                 }
-            }
-            else if(payment.getPayMode().equals("hf")){
+            } else if (payment.getPayMode().equals("hf")) {
                 V2TradePaymentScanpayRefundRequest request = new V2TradePaymentScanpayRefundRequest();
                 request.setOrdAmt(payment.getPayMoney().toString());
                 request.setOrgReqDate(new SimpleDateFormat("yyyyMMdd").format(payment.getCreateTime()));
-                request.setReqSeqId("refund-"+payment.getPayCode());
+                request.setReqSeqId("refund-" + payment.getPayCode());
                 Map<String, Object> extendInfoMap = new HashMap<>();
-                extendInfoMap.put("org_req_seq_id", orderType+"-"+payment.getPayCode());
+                extendInfoMap.put("org_req_seq_id", orderType + "-" + payment.getPayCode());
                 request.setExtendInfo(extendInfoMap);
                 HuiFuRefundResult refund = huiFuService.refund(request);
-                 logger.info("订单退款返回结果:退款订单id:"+order.getOrderId()+refund);
-                if((refund.getResp_code().equals("00000000")||refund.getResp_code().equals("00000100"))&&(refund.getTrans_stat().equals("S")||refund.getTrans_stat().equals("P"))){
-                    FsStorePayment paymentMap=new FsStorePayment();
+                logger.info("订单退款返回结果:退款订单id:" + order.getOrderId() + refund);
+                if ((refund.getResp_code().equals("00000000") || refund.getResp_code().equals("00000100")) && (refund.getTrans_stat().equals("S") || refund.getTrans_stat().equals("P"))) {
+                    FsStorePayment paymentMap = new FsStorePayment();
                     paymentMap.setPaymentId(payment.getPaymentId());
                     paymentMap.setStatus(-1);
                     paymentMap.setRefundTime(DateUtils.getNowDate());
                     paymentMap.setRefundMoney(payment.getPayMoney());
                     fsStorePaymentMapper.updateFsStorePayment(paymentMap);
-                }else {
-                    throw new CustomException("退款请求失败"+refund.getResp_desc());
+                } else {
+                    throw new CustomException("退款请求失败" + refund.getResp_desc());
                 }
             }
             //管易作废
-            if(StringUtils.isNotEmpty(fsStoreOrder.getExtendOrderId())){
-                if (!fsStoreOrder.getExtendOrderId().equals("HIS")){
-                    ErpRefundUpdateRequest request=new ErpRefundUpdateRequest();
+            if (StringUtils.isNotEmpty(fsStoreOrder.getExtendOrderId())) {
+                if (!fsStoreOrder.getExtendOrderId().equals("HIS")) {
+                    ErpRefundUpdateRequest request = new ErpRefundUpdateRequest();
                     request.setTid(fsStoreOrder.getOrderCode());
                     request.setOid(fsStoreOrder.getOrderCode());
                     request.setRefund_state(1);
-                    erpOrderService.refundUpdate(request);
+                    request.setStoreAfterSalesId(fsStoreAfterSales.getId());
+                    FsSysConfig sysConfig = configUtil.getSysConfig();
+                    Integer erpType = sysConfig.getErpType();
+                    if (erpType == 1) {
+                        erpOrderService.refundUpdate(request);
+                    } else if (erpType == 3) {
+                        //瀚智
+                        hzOMSerpOrderService.refundUpdate(request);
+                    }
                 }
             }
-        }else {
-            if (order.getRefundAmount().compareTo(BigDecimal.ZERO) == 0){
+        } else {
+            if (order.getRefundAmount().compareTo(BigDecimal.ZERO) == 0) {
 
-            }else {
+            } else {
                 throw new CustomException("未找的支付明细");
             }
         }
@@ -577,14 +590,14 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
         if (order.getStatus() == FsStoreOrderStatusEnum.STATUS_NE1.getValue()) {
             return R.error("已提交申请,等待处理");
         }
-        if (order.getPayType()==3&&order.getStatus()>=FsStoreOrderStatusEnum.STATUS_3.getValue() ){
-            return  R.error("货到付款已发货订单,不支持申请售后");
+        if (order.getPayType() == 3 && order.getStatus() >= FsStoreOrderStatusEnum.STATUS_3.getValue()) {
+            return R.error("货到付款已发货订单,不支持申请售后");
         }
 //        if(storeAfterSalesParam.getRefundAmount().compareTo(order.getPayPrice())==1){
 //            return R.error("退款金额不能大于支付金额");
 //        }
         //已完成订单七天后不能申请退款
-        if(order.getIsAfterSales()==0){
+        if (order.getIsAfterSales() == 0) {
             return R.error("此订单已超过售后时间,不能提交售后");
         }
 //        if (order.getStatus().equals(FsStoreOrderStatusEnum.STATUS_4.getValue())) {
@@ -670,13 +683,21 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
         logs.setStoreAfterSalesId(storeAfterSales.getId());
         logs.setChangeMessage(FsStoreAfterSalesStatusEnum.STATUS_0.getDesc());
         fsStoreAfterSalesLogsMapper.insertFsStoreAfterSalesLogs(logs);
-        if(order.getExtendOrderId()!=null){
+        if (order.getExtendOrderId() != null) {
             ErpRefundUpdateRequest request = new ErpRefundUpdateRequest();
             request.setTid(order.getOrderCode());
             request.setOid(order.getOrderCode());
             request.setRefund_state(1);
-            BaseResponse response = erpOrderService.refundUpdate(request);
-
+            request.setStoreAfterSalesId(storeAfterSales.getId());
+            FsSysConfig sysConfig = configUtil.getSysConfig();
+            Integer erpType = sysConfig.getErpType();
+            BaseResponse response = null;
+            if (erpType == 1) {
+                response =  erpOrderService.refundUpdate(request);
+            } else if (erpType == 3) {
+                //瀚智
+                response =  hzOMSerpOrderService.refundUpdate(request);
+            }
             if (response.getSuccess()) {
                 return R.ok();
             } else {
@@ -725,32 +746,32 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
         if (storeAfterSales.getOrderStatus().equals(FsStoreOrderStatusEnum.STATUS_2.getValue())) {
             if (StringUtils.isNotEmpty(order.getExtendOrderId())) {
                 //更新订单code
-                String orderSn =  OrderCodeUtils.getOrderSn();
-                if(StringUtils.isEmpty(orderSn)){
+                String orderSn = OrderCodeUtils.getOrderSn();
+                if (StringUtils.isEmpty(orderSn)) {
                     return R.error("订单生成失败,请重试");
                 }
-                FsStoreOrder orderMap=new FsStoreOrder();
+                FsStoreOrder orderMap = new FsStoreOrder();
                 orderMap.setOrderId(order.getOrderId());
                 orderMap.setOrderCode(orderSn);
                 fsStoreOrderMapper.updateFsStoreOrder(orderMap);
                 //生成新的订单
 
-                if (order.getPackageOrderId()!=null){
+                if (order.getPackageOrderId() != null) {
                     FsPackageOrder fsPackageOrder = new FsPackageOrder();
                     fsPackageOrder.setOrderId(order.getPackageOrderId());
                     fsPackageOrder.setOrderSn(orderSn);
                     fsPackageOrderMapper.updateFsPackageOrder(fsPackageOrder);
                 }
-                if (order.getInquiryOrderId()!=null){
+                if (order.getInquiryOrderId() != null) {
                     FsInquiryOrder fsInquiryOrder = new FsInquiryOrder();
                     fsInquiryOrder.setOrderSn(orderSn);
                     fsInquiryOrder.setOrderId(order.getInquiryOrderId());
                     fsInquiryOrderMapper.updateFsInquiryOrder(fsInquiryOrder);
                 }
 
-                List<FsStorePayment> payments = fsStorePaymentMapper.selectFsStorePaymentByPay(2,order.getOrderId());
-                if (order.getPackageOrderId()!=null){
-                    payments = fsStorePaymentMapper.selectFsStorePaymentByPay(3,order.getPackageOrderId());
+                List<FsStorePayment> payments = fsStorePaymentMapper.selectFsStorePaymentByPay(2, order.getOrderId());
+                if (order.getPackageOrderId() != null) {
+                    payments = fsStorePaymentMapper.selectFsStorePaymentByPay(3, order.getPackageOrderId());
                 }
                 for (FsStorePayment payment : payments) {
                     FsStorePayment fsStorePayment = new FsStorePayment();
@@ -762,8 +783,7 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
 
                 try {
                     fsStoreOrderService.createOmsOrder(order.getOrderId());
-                }
-                catch (Exception e){
+                } catch (Exception e) {
                 }
             }
         }
@@ -803,9 +823,9 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
     @Override
     public int depotAuditing(FsStoreAfterSales fsStoreAfterSales) {
         FsStoreAfterSales order = fsStoreAfterSalesMapper.selectFsStoreAfterSalesById(fsStoreAfterSales.getId());
-        if (order==null)throw new CustomException("订单不存在");
-        if (order.getSalesStatus()!=0)throw new CustomException("非法更改");
-        if (order.getStatus()!=2){
+        if (order == null) throw new CustomException("订单不存在");
+        if (order.getSalesStatus() != 0) throw new CustomException("非法更改");
+        if (order.getStatus() != 2) {
             throw new CustomException("非法更改");
         }
         FsStoreAfterSales fs = new FsStoreAfterSales();
@@ -824,14 +844,14 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
 
     @Override
     public List<FsStoreAfterSalesListUVO> selectFsStoreAfterSalesListUVO(FsStoreAfterSalesListUParam param) {
-        List<FsStoreAfterSalesListUVO>  list=fsStoreAfterSalesMapper.selectFsStoreAfterSalesListUVO(param);
-        for(FsStoreAfterSalesListUVO vo:list){
-            FsStoreAfterSalesItem map=new FsStoreAfterSalesItem();
+        List<FsStoreAfterSalesListUVO> list = fsStoreAfterSalesMapper.selectFsStoreAfterSalesListUVO(param);
+        for (FsStoreAfterSalesListUVO vo : list) {
+            FsStoreAfterSalesItem map = new FsStoreAfterSalesItem();
             map.setAfterSalesId(vo.getId());
-            List<FsStoreAfterSalesItem>  items=fsStoreAfterSalesItemMapper.selectFsStoreAfterSalesItemList(map);
+            List<FsStoreAfterSalesItem> items = fsStoreAfterSalesItemMapper.selectFsStoreAfterSalesItemList(map);
             vo.setItems(items);
         }
-        return  list;
+        return list;
     }
 
     @Override
@@ -865,6 +885,7 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
     public Long selectFsStoreAfterSalesExcelListVOCount(FsStoreAfterSalesParam fsStoreAfterSales) {
         return fsStoreAfterSalesMapper.selectFsStoreAfterSalesExcelListVOCount(fsStoreAfterSales);
     }
+
     @Async
     @Override
     public void exportData(FsStoreAfterSalesParam fsStoreAfterSales) {
@@ -872,7 +893,7 @@ public class FsStoreAfterSalesServiceImpl implements IFsStoreAfterSalesService {
 
         ExcelUtil<FsStoreAfterSalesExcelVO> util = new ExcelUtil<>(FsStoreAfterSalesExcelVO.class);
         AjaxResult result = util.exportExcel(list, "售后记录数据");
-        FsExportTask task=fsExportTaskMapper.selectFsExportTaskByTaskId(fsStoreAfterSales.getTaskId());
+        FsExportTask task = fsExportTaskMapper.selectFsExportTaskByTaskId(fsStoreAfterSales.getTaskId());
         task.setFinishTime(new Date());
         task.setStatus(1);
         task.setFileUrl(result.get("msg").toString());

+ 33 - 6
fs-service/src/main/java/com/fs/his/service/impl/FsStoreOrderServiceImpl.java

@@ -188,6 +188,11 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
     @Autowired
     @Qualifier("wdtErpOrderServiceImpl")
     private IErpOrderService wdtOrderService;
+
+    @Autowired
+    @Qualifier("hzOMSErpOrderServiceImpl")
+    private IErpOrderService hzOMSOrderService;
+
     @Autowired
     private IFsStoreAfterSalesService fsStoreAfterSalesService;
     @Autowired
@@ -1617,15 +1622,25 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
                 } else if (erpType == 2){
                     //旺店通
                     erpOrderService =  wdtOrderService;
+                } else if(erpType == 3){
+                    //瀚智
+                    erpOrderService = hzOMSOrderService;
                 }
                 //管易作废
                 if(erpOrderService!= null && StringUtils.isNotEmpty(order.getExtendOrderId())){
                     if (!order.getExtendOrderId().equals("HIS")){
-                        ErpRefundUpdateRequest request=new ErpRefundUpdateRequest();
-                        request.setTid(order.getOrderCode());
-                        request.setOid(order.getOrderCode());
-                        request.setRefund_state(1);
-                        erpOrderService.refundUpdate(request);
+                        if(erpType!=3){
+                            ErpRefundUpdateRequest request=new ErpRefundUpdateRequest();
+                            request.setTid(order.getOrderCode());
+                            request.setOid(order.getOrderCode());
+                            request.setRefund_state(1);
+                            erpOrderService.refundUpdate(request);
+                        }else{
+                            ErpRefundOrder param = new ErpRefundOrder();
+                            param.setOrderCode(order.getOrderCode());
+                            param.setAfterSalesId(fsStoreAfterSales.getId());
+                            erpOrderService.refundOrder(param);
+                        }
                     }
                 }
             }
@@ -1663,7 +1678,10 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
         } else if (erpType == 2){
             //旺店通
             erpOrderService =  wdtOrderService;
-        } else {
+        }  else if (erpType == 3){
+            //瀚智OMS
+            erpOrderService =  hzOMSOrderService;
+        }else {
             return;
         }
         FsStoreOrder order=fsStoreOrderMapper.selectFsStoreOrderByOrderId(orderId);
@@ -3172,5 +3190,14 @@ public class FsStoreOrderServiceImpl implements IFsStoreOrderService
         return found;
     }
 
+    @Override
+    public FsStoreOrder getOrderByOrderCodeAndStoreId(String orderCode, Long storeId){
+        return fsStoreOrderMapper.getOrderByOrderCodeAndStoreId(orderCode,storeId);
+    }
+
+    @Override
+    public int updateStoreOrderDeliveryInfo(FsStoreOrder order){
+        return fsStoreOrderMapper.updateStoreOrderDeliveryInfo(order);
+    }
 
 }

+ 15 - 0
fs-service/src/main/java/com/fs/his/service/impl/FsStoreProductAttrValueServiceImpl.java

@@ -98,4 +98,19 @@ public class FsStoreProductAttrValueServiceImpl implements IFsStoreProductAttrVa
     public List<FsStoreProductAttrValueListDVO> selectFsStoreProductAttrValueListDVO(FsStoreProductAttrValueListDParam param) {
         return fsStoreProductAttrValueMapper.selectFsStoreProductAttrValueListDVO(param);
     }
+
+    @Override
+    public FsStoreProductAttrValue selectFsStoreProductAttrValueByIdAndPruductId(Long id, Long productId){
+        return fsStoreProductAttrValueMapper.selectFsStoreProductAttrValueByIdAndPruductId(id,productId);
+    }
+
+    @Override
+    public int updateStoreProductAttrValueStock(Long id , Integer stock){
+        return fsStoreProductAttrValueMapper.updateStoreProductAttrValueStock(id,stock);
+    }
+
+    @Override
+    public List<FsStoreProductAttrValue> selectFsStoreProductAttrValueListByProductId( Long productId){
+        return fsStoreProductAttrValueMapper.selectFsStoreProductAttrValueListByProductId(productId);
+    }
 }

+ 128 - 86
fs-service/src/main/java/com/fs/his/service/impl/FsStoreProductServiceImpl.java

@@ -17,6 +17,9 @@ import com.fs.common.core.domain.R;
 import com.fs.common.exception.CustomException;
 import com.fs.common.exception.ServiceException;
 import com.fs.common.utils.DateUtils;
+import com.fs.erp.domain.ErpGoods;
+import com.fs.erp.service.IErpGoodsService;
+import com.fs.his.config.FsSysConfig;
 import com.fs.his.domain.*;
 import com.fs.his.dto.FsPackagePruductDTO;
 import com.fs.his.mapper.FsPackageOrderMapper;
@@ -28,10 +31,12 @@ import com.fs.his.mapper.FsStoreProductAttrMapper;
 import com.fs.his.mapper.FsStoreProductAttrValueMapper;
 import com.fs.his.param.FsStoreProductListSParam;
 import com.fs.his.service.IFsPackageService;
+import com.fs.his.utils.ConfigUtil;
 import com.fs.his.vo.*;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Service;
 import com.fs.his.mapper.FsStoreProductMapper;
 import com.fs.his.service.IFsStoreProductService;
@@ -44,8 +49,7 @@ import org.springframework.transaction.annotation.Transactional;
  * @date 2023-06-08
  */
 @Service
-public class FsStoreProductServiceImpl implements IFsStoreProductService
-{
+public class FsStoreProductServiceImpl implements IFsStoreProductService {
     @Autowired
     private FsStoreProductMapper fsStoreProductMapper;
 
@@ -60,6 +64,12 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService
 
     @Autowired
     IFsPackageService fsPackageService;
+    @Autowired
+    private ConfigUtil configUtil;
+
+    @Autowired
+    @Qualifier("hzOMSErpGoodsServiceImpl")
+    private IErpGoodsService hzOMSErpGoodsService;
 
     /**
      * 查询商品
@@ -68,8 +78,7 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService
      * @return 商品
      */
     @Override
-    public FsStoreProduct selectFsStoreProductByProductId(Long productId)
-    {
+    public FsStoreProduct selectFsStoreProductByProductId(Long productId) {
         return fsStoreProductMapper.selectFsStoreProductByProductId(productId);
     }
 
@@ -80,8 +89,7 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService
      * @return 商品
      */
     @Override
-    public List<FsStoreProduct> selectFsStoreProductList(FsStoreProduct fsStoreProduct)
-    {
+    public List<FsStoreProduct> selectFsStoreProductList(FsStoreProduct fsStoreProduct) {
         return fsStoreProductMapper.selectFsStoreProductList(fsStoreProduct);
     }
 
@@ -92,8 +100,7 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService
      * @return 结果
      */
     @Override
-    public int insertFsStoreProduct(FsStoreProduct fsStoreProduct)
-    {
+    public int insertFsStoreProduct(FsStoreProduct fsStoreProduct) {
         fsStoreProduct.setCreateTime(DateUtils.getNowDate());
 
         return fsStoreProductMapper.insertFsStoreProduct(fsStoreProduct);
@@ -106,8 +113,7 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService
      * @return 结果
      */
     @Override
-    public int updateFsStoreProduct(FsStoreProduct fsStoreProduct)
-    {
+    public int updateFsStoreProduct(FsStoreProduct fsStoreProduct) {
         fsStoreProduct.setUpdateTime(DateUtils.getNowDate());
         return fsStoreProductMapper.updateFsStoreProduct(fsStoreProduct);
     }
@@ -119,8 +125,7 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService
      * @return 结果
      */
     @Override
-    public int deleteFsStoreProductByProductIds(Long[] productIds)
-    {
+    public int deleteFsStoreProductByProductIds(Long[] productIds) {
         int i = fsStoreProductMapper.deleteFsStoreProductByProductIds(productIds);
         for (Long id : productIds) {
             fsStoreProductAttrMapper.clear(id);
@@ -137,8 +142,7 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService
      * @return 结果
      */
     @Override
-    public int deleteFsStoreProductByProductId(Long productId)
-    {
+    public int deleteFsStoreProductByProductId(Long productId) {
         return fsStoreProductMapper.deleteFsStoreProductByProductId(productId);
     }
 
@@ -151,6 +155,7 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService
     public List<FsStoreProductListSVO> selectFsStoreProductListSVO(FsStoreProductListSParam fsStoreProduct) {
         return fsStoreProductMapper.selectFsStoreProductListSVO(fsStoreProduct);
     }
+
     @Override
     public List<OptionsVO> selectFsStoreProductStoreList() {
         return fsStoreProductMapper.selectFsStoreProductStoreList();
@@ -217,20 +222,20 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService
             valueMap.put("groupBarCode", "");
             valueMap.put("weight", 0);
             valueMap.put("volume", 0);
-            valueMap.put("doctorBrokerage",0);
+            valueMap.put("doctorBrokerage", 0);
             valueMap.put("brokerage", 0);
 //            valueMap.put("brokerageTwo", 0);
 //            valueMap.put("brokerageThree", 0);
             valueMap.put("giveIntegral", 0);
             if (productId > 0) {
-                FsStoreProductAttrValue attrValueMap=new FsStoreProductAttrValue();
+                FsStoreProductAttrValue attrValueMap = new FsStoreProductAttrValue();
                 attrValueMap.setProductId(productId);
                 attrValueMap.setSku(sku);
                 List<FsStoreProductAttrValue> values = fsStoreProductAttrValueMapper.selectFsStoreProductAttrValueList(attrValueMap);
 
-                if (values != null&&values.size()==1) {
-                    valueMap.put("id",values.get(0).getId());
-                    valueMap.put("sku",values.get(0).getSku());
+                if (values != null && values.size() == 1) {
+                    valueMap.put("id", values.get(0).getId());
+                    valueMap.put("sku", values.get(0).getSku());
                     valueMap.put("image", values.get(0).getImage());
                     valueMap.put("price", values.get(0).getPrice());
                     valueMap.put("cost", values.get(0).getCost());
@@ -245,7 +250,7 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService
                     valueMap.put("brokerage", values.get(0).getBrokerage());
 //                    valueMap.put("brokerageTwo", values.get(0).getBrokerageTwo());
 //                    valueMap.put("brokerageThree", values.get(0).getBrokerageThree());
-                    System.out.println("积分 :"+values.get(0).getGiveIntegral());
+                    System.out.println("积分 :" + values.get(0).getGiveIntegral());
                     valueMap.put("giveIntegral", values.get(0).getGiveIntegral());
                 }
             }
@@ -366,7 +371,6 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService
     }
 
 
-
     private DetailVO attrFormat(List<ProductArrtDTO> fromatDetailDTOList) {
         List<String> data = new ArrayList<>();
         List<Map<String, Map<String, String>>> res = new ArrayList<>();
@@ -441,20 +445,21 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService
         detailDto.setRes(res);
         return detailDto;
     }
+
     @SuppressWarnings("all")
     @Override
     @Transactional
     public R addOrEdit(FsStoreProductAddEditParam param) {
-        ProductAttrCountDTO countDto=computedProductCount(param.getValues());
+        ProductAttrCountDTO countDto = computedProductCount(param.getValues());
 
-        if(param.getProductId()!=null){
-            FsStoreProduct product=new FsStoreProduct();
-            BeanUtils.copyProperties(param,product);
+        if (param.getProductId() != null) {
+            FsStoreProduct product = new FsStoreProduct();
+            BeanUtils.copyProperties(param, product);
             product.setPrice(countDto.getMinPrice());
             product.setOtPrice(countDto.getMinOtPrice());
             product.setCostPrice(countDto.getMinCost());
             product.setBarCode(param.getValues().get(0).getBarCode());
-           product.setGiveIntegral(  new BigDecimal(countDto.getMinIntegral()));
+            product.setGiveIntegral(new BigDecimal(countDto.getMinIntegral()));
             product.setStock(countDto.getStock());
             fsStoreProductMapper.updateFsStoreProduct(product);
             if (param.getSpecType().equals(0)) {
@@ -462,21 +467,21 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService
                         .value("规格")
                         .detail(ListUtil.toList("默认"))
                         .build();
-                List<ProductArrtDTO> items=new ArrayList<>();
+                List<ProductArrtDTO> items = new ArrayList<>();
                 items.add(fromatDetailDto);
                 param.getValues().get(0).setSku("默认");
-                addProductAttr(product.getProductId(),items,param.getValues());
+                addProductAttr(product.getProductId(), items, param.getValues());
             } else {
-                addProductAttr(product.getProductId(),param.getItems(),param.getValues());
+                addProductAttr(product.getProductId(), param.getItems(), param.getValues());
             }
-            List<FsPackage> fsPackage = fsPackageOrderMapper.selectFsPackageOrderListByProd("\"productId\""+":"+param.getProductId());
-            if (fsPackage!=null&&fsPackage.size()>0){
+            List<FsPackage> fsPackage = fsPackageOrderMapper.selectFsPackageOrderListByProd("\"productId\"" + ":" + param.getProductId());
+            if (fsPackage != null && fsPackage.size() > 0) {
                 for (FsPackage pack : fsPackage) {
                     JSONArray objects = JSONUtil.parseArray(pack.getProductJson());
-                    List<FsPackagePruductDTO> products=JSONUtil.toList(objects,FsPackagePruductDTO.class);
-                  for (FsPackagePruductDTO fsPackagePruductDTO : products) {
-                        if (fsPackagePruductDTO.getProductId()-param.getProductId()==0){
-                            FsStoreProductAttrValueVO vo=fsStoreProductMapper.selectFsStoreProductAttrValueVOByProdId(param.getProductId());
+                    List<FsPackagePruductDTO> products = JSONUtil.toList(objects, FsPackagePruductDTO.class);
+                    for (FsPackagePruductDTO fsPackagePruductDTO : products) {
+                        if (fsPackagePruductDTO.getProductId() - param.getProductId() == 0) {
+                            FsStoreProductAttrValueVO vo = fsStoreProductMapper.selectFsStoreProductAttrValueVOByProdId(param.getProductId());
                             fsPackagePruductDTO.setSku(vo.getSku());
                             fsPackagePruductDTO.setStock(vo.getStock());
                             fsPackagePruductDTO.setSales(vo.getSales());
@@ -501,10 +506,9 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService
                 }
 
             }
-        }
-        else{
-            FsStoreProduct product=new FsStoreProduct();
-            BeanUtils.copyProperties(param,product);
+        } else {
+            FsStoreProduct product = new FsStoreProduct();
+            BeanUtils.copyProperties(param, product);
             product.setPrice(countDto.getMinPrice());
             product.setOtPrice(countDto.getMinOtPrice());
             product.setCostPrice(countDto.getMinCost());
@@ -516,44 +520,64 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService
                         .value("规格")
                         .detail(ListUtil.toList("默认"))
                         .build();
-                List<ProductArrtDTO> items=new ArrayList<>();
+                List<ProductArrtDTO> items = new ArrayList<>();
                 items.add(fromatDetailDto);
                 param.getValues().get(0).setSku("默认");
-                addProductAttr(product.getProductId(),items,param.getValues());
+                addProductAttr(product.getProductId(), items, param.getValues());
+            } else {
+                addProductAttr(product.getProductId(), param.getItems(), param.getValues());
+            }
+            //todo 添加商品HzOMSerp调用
+            //判断是否开启erp
+            FsSysConfig sysConfig = configUtil.getSysConfig();
+            Integer erpOpen = sysConfig.getErpOpen();
+            if (erpOpen == null || erpOpen == 0) {
+                //不作操作
             } else {
-                addProductAttr(product.getProductId(),param.getItems(),param.getValues());
+                //判断erp类型
+                Integer erpType = sysConfig.getErpType();
+                if (erpType == null) {
+                    //不作操作
+                } else if (erpType == 3) {
+                    ErpGoods params = new ErpGoods();
+                    params.setStoreProductId(product.getProductId());
+                    //瀚智OMS 维护添加商品
+                    hzOMSErpGoodsService.addGoods(params);
+                }
             }
+
+
         }
         return R.ok();
     }
 
 
-    private void addProductAttr(Long productId, List<ProductArrtDTO> items, List<FsStoreProductAttrValue> values){
+    private void addProductAttr(Long productId, List<ProductArrtDTO> items, List<FsStoreProductAttrValue> values) {
         //清空attr
         fsStoreProductAttrMapper.clear(productId);
         //清空values
         //查出商品属性所有ID;
-        List<FsStoreProductAttrValue> attrValues=fsStoreProductAttrValueMapper.selectFsStoreProductAttrValueByProductId(productId);
+        List<FsStoreProductAttrValue> attrValues = fsStoreProductAttrValueMapper.selectFsStoreProductAttrValueByProductId(productId);
         fsStoreProductAttrValueMapper.deleteFsStoreProductAttrValueByProductId(productId);
         //写入attr
-        for(ProductArrtDTO vo:items){
-            FsStoreProductAttr attr=new FsStoreProductAttr();
+        for (ProductArrtDTO vo : items) {
+            FsStoreProductAttr attr = new FsStoreProductAttr();
             attr.setProductId(productId);
             attr.setAttrName(vo.getValue());
             attr.setAttrValues(StringUtils.join(vo.getDetail(), ","));
             fsStoreProductAttrMapper.insertFsStoreProductAttr(attr);
         }
-        Map<String,Object> map = new LinkedHashMap<>();
-        map.put("attr",items);
+        Map<String, Object> map = new LinkedHashMap<>();
+        map.put("attr", items);
         // map.put("value",values);
 
-        for(FsStoreProductAttrValue val: values){
+        for (FsStoreProductAttrValue val : values) {
             //更新套餐商品属性ID  获取套餐
-            Long id=val.getId();
-            if(val.getDetail()!=null){
+            Long id = val.getId();
+            if (val.getDetail() != null) {
                 List<String> stringList = new ArrayList<>(val.getDetail().values());
                 Collections.sort(stringList);
-                val.setSku(StrUtil.join(",",stringList));
+                val.setSku(StrUtil.join(",", stringList));
             }
             val.setProductId(productId);
             fsStoreProductAttrValueMapper.insertFsStoreProductAttrValue(val);
@@ -563,7 +587,7 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService
     }
 
     private ProductAttrCountDTO computedProductCount(List<FsStoreProductAttrValue> values) {
-        BigDecimal val=new BigDecimal(0);
+        BigDecimal val = new BigDecimal(0);
         //取最小价格
         BigDecimal minPrice = values
                 .stream()
@@ -610,7 +634,7 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService
     @Override
     public void incProductStock(Long num, Long productId, Long productAttrValueId) {
         //处理属性sku
-        if (productAttrValueId!=null) {
+        if (productAttrValueId != null) {
             fsStoreProductMapper.incProductAttrStock(num, productId, productAttrValueId);
         }
         //处理商品库存
@@ -620,8 +644,7 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService
 
     @Override
     public String importSrorePeoduct(List<FsStoreProductExcelVO> productList, boolean updateSupport) {
-        if (com.fs.common.utils.StringUtils.isNull(productList) || productList.size() == 0)
-        {
+        if (com.fs.common.utils.StringUtils.isNull(productList) || productList.size() == 0) {
             throw new ServiceException("导入商品数据不能为空!");
         }
         int successNum = 0;
@@ -629,10 +652,8 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService
         StringBuilder successMsg = new StringBuilder();
         StringBuilder failureMsg = new StringBuilder();
 
-        for (FsStoreProductExcelVO productVO : productList)
-        {
-            try
-            {
+        for (FsStoreProductExcelVO productVO : productList) {
+            try {
 
 //                if (1==1){
 //                    FsStoreProductAttrValue v = new FsStoreProductAttrValue();
@@ -652,7 +673,7 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService
 //                product.setProductType(1);
 //                product.setSpecType(0);
 //                productVO.setDoctorBrokerage(new BigDecimal(0));
-                if (product.getBarCode()==null || product.getBarCode()==""){
+                if (product.getBarCode() == null || product.getBarCode() == "") {
                     throw new CustomException("商品编号为空");
                 }
                 //
@@ -662,38 +683,38 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService
                         .value("规格")
                         .detail(ListUtil.toList("默认"))
                         .build();
-                List<ProductArrtDTO> items=new ArrayList<>();
+                List<ProductArrtDTO> items = new ArrayList<>();
                 items.add(fromatDetailDto);
                 FsStoreProductAttrValue p = new FsStoreProductAttrValue();
                 p.setProductId(product.getProductId());
                 p.setSku("默认");
                 p.setStock(product.getStock());
-                if (product.getStock()==null){
+                if (product.getStock() == null) {
                     p.setStock(0);
                 }
                 p.setSales(product.getSales());
-                if (product.getSales()==null){
+                if (product.getSales() == null) {
                     p.setStock(0);
                 }
                 p.setPrice(product.getPrice());
-                if (product.getPrice()==null){
+                if (product.getPrice() == null) {
                     p.setPrice(new BigDecimal(0));
                 }
                 p.setImage(product.getImgUrl());
                 p.setCost(product.getCostPrice());
-                if (product.getCostPrice()==null){
+                if (product.getCostPrice() == null) {
                     p.setCost(new BigDecimal(0));
                 }
                 p.setBarCode(product.getBarCode());
                 p.setGroupBarCode(product.getBarCode());
                 p.setOtPrice(product.getOtPrice());
-                if (product.getOtPrice()==null){
+                if (product.getOtPrice() == null) {
                     p.setOtPrice(new BigDecimal(0));
                 }
 
                 p.setDoctorBrokerage(productVO.getDoctorBrokerage());
                 p.setWeight(productVO.getWeight());
-                if (productVO.getWeight()==null){
+                if (productVO.getWeight() == null) {
                     p.setWeight(new BigDecimal(0));
                 }
 
@@ -701,9 +722,9 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService
                 p.setBrokerage(new BigDecimal(0));
                 p.setBrokerageTwo(new BigDecimal(0));
                 p.setBrokerageThree(new BigDecimal(0));
-                if (product.getGiveIntegral()==null){
+                if (product.getGiveIntegral() == null) {
                     p.setGiveIntegral(0);
-                }else {
+                } else {
                     p.setGiveIntegral(product.getGiveIntegral().intValue());
                 }
                 p.setAgentPrice(new BigDecimal(0));
@@ -715,25 +736,37 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService
                 attr.setAttrName("规格");
                 attr.setAttrValues("默认");
                 fsStoreProductAttrMapper.insertFsStoreProductAttr(attr);
-                    successNum++;
-                    successMsg.append("<br/>" + successNum + "、商品 " + product.getProductName() + " 导入成功");
-
-            }
-            catch (Exception e)
-            {
+                successNum++;
+                successMsg.append("<br/>" + successNum + "、商品 " + product.getProductName() + " 导入成功");
+                //todo 添加商品HzOMSerp调用
+                //判断是否开启erp
+                FsSysConfig sysConfig = configUtil.getSysConfig();
+                Integer erpOpen = sysConfig.getErpOpen();
+                if (erpOpen == null || erpOpen == 0) {
+                    //不作操作
+                } else{
+                    //判断erp类型
+                    Integer erpType = sysConfig.getErpType();
+                    if (erpType == null) {
+                        //不作操作
+                    }else if (erpType == 3) {
+                        ErpGoods params = new ErpGoods();
+                        params.setStoreProductId(product.getProductId());
+                        //瀚智OMS 维护添加商品
+                        hzOMSErpGoodsService.addGoods(params);
+                    }
+                }
+            } catch (Exception e) {
 
                 failureNum++;
-                String msg = "<br/>" + failureNum + "、商品 " + productVO.getProductName()  + " 导入失败:";
+                String msg = "<br/>" + failureNum + "、商品 " + productVO.getProductName() + " 导入失败:";
                 failureMsg.append(msg + e.getMessage());
             }
         }
-        if (failureNum > 0)
-        {
+        if (failureNum > 0) {
             failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
             throw new ServiceException(failureMsg.toString());
-        }
-        else
-        {
+        } else {
             successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
         }
         return successMsg.toString();
@@ -743,8 +776,8 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService
     public int updateFsStoreProductPrice(FsStoreProduct fsStoreProduct, Integer price) {
 
         List<Long> ids = fsStoreProductMapper.selectFsStoreProductIdList(fsStoreProduct);
-        fsStoreProductAttrValueMapper.updateFsStoreProductAttrValuePrice(ids,(100+price)/100.0);
-        return fsStoreProductMapper.updateFsStoreProductPrice(ids,(100+price)/100.0);
+        fsStoreProductAttrValueMapper.updateFsStoreProductAttrValuePrice(ids, (100 + price) / 100.0);
+        return fsStoreProductMapper.updateFsStoreProductPrice(ids, (100 + price) / 100.0);
     }
 
     @Override
@@ -754,7 +787,7 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService
             FsStoreProductAttrValue va = new FsStoreProductAttrValue();
             va.setProductId(vo.getProductId());
             List<FsStoreProductAttrValue> list = fsStoreProductAttrValueMapper.selectFsStoreProductAttrValueList(va);
-            if (!list.isEmpty()){
+            if (!list.isEmpty()) {
                 vo.setBrokerage(list.get(0).getBrokerage());
                 vo.setDoctorBrokerage(list.get(0).getDoctorBrokerage());
                 vo.setWeight(list.get(0).getWeight());
@@ -775,7 +808,7 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService
 
     @Override
     public Long selectFsStoreProductCount(int type, Long companyId) {
-        return fsStoreProductMapper.selectFsStoreProductCompanyCount(type,companyId);
+        return fsStoreProductMapper.selectFsStoreProductCompanyCount(type, companyId);
     }
 
     @Override
@@ -783,5 +816,14 @@ public class FsStoreProductServiceImpl implements IFsStoreProductService
         return fsStoreProductMapper.selectFsStoreProductCount(type);
     }
 
+    @Override
+    public FsStoreProduct getStoreProductByProductIdAndStoreId(Long productId, Long storeId) {
+        return fsStoreProductMapper.getStoreProductByProductIdAndStoreId(productId, storeId);
+    }
+
+    @Override
+    public int updateStoreProductStock(Long productId, Integer num) {
+        return fsStoreProductMapper.updateStoreProductStock(productId, num);
+    }
 
 }

+ 238 - 0
fs-service/src/main/java/com/fs/his/service/impl/HzOMSErpApiServiceImpl.java

@@ -0,0 +1,238 @@
+package com.fs.his.service.impl;
+
+import cn.hutool.core.codec.Base64Decoder;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.fs.erp.dto.sdk.HzOMS.utils.HzOMSUtils;
+import com.fs.his.config.FsSysConfig;
+import com.fs.his.domain.FsStoreOrder;
+import com.fs.his.domain.FsStoreProduct;
+import com.fs.his.domain.FsStoreProductAttrValue;
+import com.fs.his.param.HzOMSErpApiParam;
+import com.fs.his.service.ErpApiService;
+import com.fs.his.service.IFsStoreOrderService;
+import com.fs.his.service.IFsStoreProductAttrValueService;
+import com.fs.his.service.IFsStoreProductService;
+import com.fs.his.utils.ConfigUtil;
+import com.fs.his.vo.HzOMSErpResponseDetailVO;
+import com.fs.his.vo.HzOMSErpResponseErrorItemVO;
+import com.fs.his.vo.HzOMSErpResponseVO;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.Base64Utils;
+
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+public class HzOMSErpApiServiceImpl implements ErpApiService {
+
+    @Autowired
+    private ConfigUtil configUtil;
+
+    private final Integer HZOMS_ERP_TYPE = 3;
+
+    private final String CODE_SUCCESS = "200";
+
+    @Autowired
+    IFsStoreProductService fsStoreProductService;
+
+    @Autowired
+    IFsStoreProductAttrValueService fsStoreProductAttrValueService;
+
+    @Autowired
+    IFsStoreOrderService fsStoreOrderService;
+
+    /**
+     * 平台商品库存同步到第三方
+     *
+     * @param param
+     * @return
+     */
+    @Override
+    public HzOMSErpResponseVO stockSync(HzOMSErpApiParam param) {
+        HzOMSErpResponseVO res = new HzOMSErpResponseVO();
+        //校验数据合法性
+        String v = legitimateVerification(param);
+        if (!"".equals(v)) {
+            res.setSuccess(Boolean.FALSE);
+            res.setMessage(v);
+            return res;
+        }
+        //对方传输的datapacage是base64编码的 先解码得到 json
+        JSONObject dataObj = getDecodeDataJSON(param.getDatapakege());
+        res.setCode(CODE_SUCCESS);
+        res.setMessage(dataObj.toJSONString());
+        Long storeId = dataObj.getLong("cptshopcode");
+        JSONArray syncstocklist = dataObj.getJSONArray("syncstocklist");
+        List<HzOMSErpResponseErrorItemVO> errorlist = new ArrayList<>();
+        syncstocklist.forEach(item -> {
+            JSONObject o = (JSONObject) item;
+            //判断当前店铺是否存在此商品
+            FsStoreProduct fsStoreProduct = fsStoreProductService.getStoreProductByProductIdAndStoreId(o.getLong("cptgoodsid"), storeId);
+            if (fsStoreProduct != null) {
+                fsStoreProductService.updateStoreProductStock(o.getLong("cptgoodsid"), o.getInteger("fptstock"));
+            } else {
+                HzOMSErpResponseErrorItemVO errorItemVO = new HzOMSErpResponseErrorItemVO();
+                errorItemVO.setCptgoodsid(o.getLong("cptgoodsid").toString());
+                errorItemVO.setMsg("商品不存在");
+                errorlist.add(errorItemVO);
+            }
+        });
+        res.setSuccess(Boolean.TRUE);
+        HzOMSErpResponseDetailVO resData = new HzOMSErpResponseDetailVO();
+        resData.setErrorlist(errorlist);
+        res.setData(resData);
+        return res;
+    }
+
+    /**
+     * 用于将瀚智商品库存同步到第三方
+     * @param param
+     * @return
+     */
+    @Override
+    public HzOMSErpResponseVO skuStockSync(HzOMSErpApiParam param) {
+        HzOMSErpResponseVO res = new HzOMSErpResponseVO();
+
+        String v = legitimateVerification(param);
+        if (!"".equals(v)) {
+            res.setSuccess(Boolean.FALSE);
+            res.setMessage(v);
+            return res;
+        }
+        //对方传输的datapacage是base64编码的 先解码得到 json
+        JSONObject dataObj = getDecodeDataJSON(param.getDatapakege());
+        res.setCode(CODE_SUCCESS);
+        res.setMessage("同步商品规格库存成功");
+
+        Long storeId = dataObj.getLong("cptshopcode");
+        JSONArray syncstocklist = dataObj.getJSONArray("syncstocklist");
+        List<HzOMSErpResponseErrorItemVO> errorlist = new ArrayList<>();
+        syncstocklist.forEach(item -> {
+            //商品
+            JSONObject o = (JSONObject) item;
+            Long productId = o.getLong("cptgoodsid");
+            JSONArray skustocklist = o.getJSONArray("skustocklist");
+            //规格list
+            skustocklist.forEach(skuItem -> {
+                JSONObject skuO = (JSONObject) skuItem;
+                Long skuId = skuO.getLong("cptspeccode");
+                //判断当前店铺是否存在此商品规格
+                FsStoreProductAttrValue fsStoreProductAttrValue = fsStoreProductAttrValueService.selectFsStoreProductAttrValueByIdAndPruductId(productId, skuId);
+                if (fsStoreProductAttrValue != null) {
+                    fsStoreProductAttrValueService.updateStoreProductAttrValueStock(productId, o.getInteger("fptstock"));
+                } else {
+                    HzOMSErpResponseErrorItemVO errorItemVO = new HzOMSErpResponseErrorItemVO();
+                    errorItemVO.setCptgoodsid(productId.toString());
+                    errorItemVO.setCptspeccode(skuId.toString());
+                    errorItemVO.setMsg("规格不存在");
+                    errorlist.add(errorItemVO);
+                }
+            });
+        });
+        res.setSuccess(Boolean.TRUE);
+        HzOMSErpResponseDetailVO resData = new HzOMSErpResponseDetailVO();
+        resData.setErrorlist(errorlist);
+        res.setData(resData);
+        return res;
+    }
+
+    /**
+     * 平台订单物流信息回传
+     *
+     * @param param
+     * @return
+     */
+    @Override
+    public HzOMSErpResponseVO logisticsAdd(HzOMSErpApiParam param) {
+        HzOMSErpResponseVO res = new HzOMSErpResponseVO();
+        //校验方法调用合法性
+        String v = legitimateVerification(param);
+        if (!"".equals(v)) {
+            res.setSuccess(Boolean.FALSE);
+            res.setMessage(v);
+            return res;
+        }
+        //对方传输的datapacage是base64编码的 先解码得到 json
+        JSONArray dataArr = getDecodeDataJSONArr(param.getDatapakege());
+        List<HzOMSErpResponseErrorItemVO> errorlist = new ArrayList<>();
+        dataArr.forEach(oItem -> {
+            JSONObject item = (JSONObject) oItem;
+            //判断订单是否存在
+            FsStoreOrder fsOrder = fsStoreOrderService.getOrderByOrderCodeAndStoreId(item.getString("cptordercode"), item.getLong("cptshopcode"));
+            if (null != fsOrder) {
+                fsOrder.setDeliveryCode(item.getString("cexpresscode"));
+                fsOrder.setDeliveryName(item.getString("cexpressname"));
+                fsOrder.setDeliverySn(item.getString("clogisticsno"));
+                fsStoreOrderService.updateStoreOrderDeliveryInfo(fsOrder);
+            } else {
+                HzOMSErpResponseErrorItemVO addErrItem = new HzOMSErpResponseErrorItemVO();
+                addErrItem.setCptordercode(item.getString("cptordercode"));
+                addErrItem.setCptshopcode(item.getString("cptshopcode"));
+                addErrItem.setMsg("订单不存在");
+                errorlist.add(addErrItem);
+            }
+        });
+        res.setCode(CODE_SUCCESS);
+        res.setMessage("平台订单物流信息回传成功");
+        HzOMSErpResponseDetailVO resData = new HzOMSErpResponseDetailVO();
+        resData.setErrorlist(errorlist);
+        return res;
+    }
+
+    /**
+     * 校验方法调用合法性
+     *
+     * @param param
+     * @return
+     */
+    public String legitimateVerification(HzOMSErpApiParam param) {
+        FsSysConfig sysConfig = configUtil.getSysConfig();
+        Integer erpType = sysConfig.getErpType();
+        //校验系统配置
+        if (!HZOMS_ERP_TYPE.equals(erpType)) {
+            return "系统配置ERP不匹配,请联系管理员。";
+        }
+        String erpHzOMSAppKey = sysConfig.getErpHzOMSAppKey();
+        //校验传参appKey是否相符
+        if (!erpHzOMSAppKey.equals(param.getAppkey())) {
+            return "系统配置appKey不匹配,请联系管理员。";
+        }
+        //校验数据签名是否合法
+        try {
+            Boolean b = HzOMSUtils.signValidate(param.getTimestamp(), param.getDatapakege(), sysConfig.getErpHzOMSAppsecret(), param.getSign());
+            if (!b) {
+                return "非法数据,签名校验失败。";
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+            return "数据签名校验失败。";
+        }
+        return "";
+    }
+
+    /**
+     * 获取解码后的JSON数据
+     *
+     * @param s
+     * @return
+     */
+    public JSONObject getDecodeDataJSON(String s) {
+        JSONObject dataObj = JSONObject.parseObject(new String(Base64Utils.decode(s.getBytes(StandardCharsets.UTF_8))));
+        return dataObj;
+    }
+
+    /**
+     * 获取解码后的JSONArray数据
+     *
+     * @param s
+     * @return
+     */
+    public JSONArray getDecodeDataJSONArr(String s) {
+        JSONArray arr = JSONArray.parseArray(new String(Base64Utils.decode(s.getBytes(StandardCharsets.UTF_8))));
+        return arr;
+    }
+}

+ 11 - 0
fs-service/src/main/java/com/fs/his/vo/HzOMSErpResponseDetailVO.java

@@ -0,0 +1,11 @@
+package com.fs.his.vo;
+
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class HzOMSErpResponseDetailVO {
+
+    private List<HzOMSErpResponseErrorItemVO> errorlist;
+}

+ 19 - 0
fs-service/src/main/java/com/fs/his/vo/HzOMSErpResponseErrorItemVO.java

@@ -0,0 +1,19 @@
+package com.fs.his.vo;
+
+import lombok.Data;
+
+@Data
+public class HzOMSErpResponseErrorItemVO {
+
+    //平台商品编码
+    private String cptgoodsid;
+    //平台规格编码
+    private String cptspeccode;
+    //平台订单号
+    private String cptordercode;
+    //平台店铺编码
+    private String cptshopcode;
+    //错误描述
+    private String msg;
+
+}

+ 20 - 0
fs-service/src/main/java/com/fs/his/vo/HzOMSErpResponseVO.java

@@ -0,0 +1,20 @@
+package com.fs.his.vo;
+
+
+import lombok.Data;
+
+@Data
+public class HzOMSErpResponseVO {
+
+    private String code;
+
+    private HzOMSErpResponseDetailVO data;
+
+    private String message;
+
+    private String messageList;
+
+    private String requestId;
+
+    private Boolean success;
+}