浏览代码

商城移植缺陷修复

chenguo 1 周之前
父节点
当前提交
e642cd6f1d

+ 1 - 1
fs-admin/src/main/resources/application.yml

@@ -4,7 +4,7 @@ server:
 # Spring配置
 spring:
   profiles:
-    active: druid-myhk-test
+    active: dev
 #    active: druid-hdt
 #    active: druid-yzt
 #    active: druid-sxjz

+ 35 - 0
fs-common/src/main/java/com/fs/common/utils/http/HttpUtils.java

@@ -16,6 +16,14 @@ import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLSession;
 import javax.net.ssl.TrustManager;
 import javax.net.ssl.X509TrustManager;
+
+import org.apache.http.HttpResponse;
+import org.apache.http.HttpStatus;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.util.EntityUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import com.fs.common.constant.Constants;
@@ -177,6 +185,33 @@ public class HttpUtils
         return result.toString();
     }
 
+    /**
+     * json request
+     *
+     * @param url
+     * @param json
+     * @return
+     */
+    public static String doPost(String url, String json) {
+        CloseableHttpClient httpclient = HttpClientBuilder.create().build();
+        HttpPost post = new HttpPost(url);
+        String response = null;
+        try {
+            StringEntity s = new StringEntity(json,"UTF-8");
+//			s.setContentEncoding("UTF-8");
+            // 发送json数据需要设置contentType
+            s.setContentType("application/json");
+            post.setEntity(s);
+            HttpResponse res = httpclient.execute(post);
+            if (res.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
+                response = EntityUtils.toString(res.getEntity());// 返回json格式:
+            }
+        } catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+        return response;
+    }
+
     public static String sendSSLPost(String url, String param)
     {
         StringBuilder result = new StringBuilder();

+ 90 - 0
fs-service/src/main/java/com/fs/erp/service/impl/K9StockScrmServiceImpl.java

@@ -0,0 +1,90 @@
+package com.fs.erp.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.fs.common.exception.CustomException;
+import com.fs.common.exception.ServiceException;
+import com.fs.common.utils.StringUtils;
+import com.fs.common.utils.http.HttpUtils;
+import com.fs.erp.domain.ErpGoods;
+import com.fs.erp.domain.ErpGoodsStock;
+import com.fs.erp.domain.KbStockRequest;
+import com.fs.erp.domain.KbStockResponse;
+import com.fs.erp.dto.*;
+import com.fs.erp.service.IErpGoodsService;
+import com.fs.erp.utils.ScrmStoreSignUtils;
+import com.fs.erp.utils.ScrmStoreUrlUtils;
+import com.fs.his.utils.ConfigUtil;
+import com.fs.hisStore.config.FsErpConfig;
+import lombok.AllArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+
+@Service
+@Slf4j
+@AllArgsConstructor
+public class K9StockScrmServiceImpl implements IErpGoodsService {
+
+    @Autowired
+    private ConfigUtil configUtil;
+
+    @Override
+    public BaseResponse addGoods(ErpGoods goods) {
+        return null;
+    }
+
+    @Override
+    public ErpGoodsQueryResponse getGoods(ErpGoodsQueryRequert param) {
+        return null;
+    }
+
+    @Override
+    public ErpGoodsStockQueryResponse getGoodsStock(ErpGoodsStockQueryRequert param) {
+        String barcode = param.getBarcode();
+        KbStockRequest request = KbStockRequest.builder().goodsCode(barcode).build();
+        KbStockResponse kbStockResponse = getStock(request);
+        ErpGoodsStockQueryResponse response = new ErpGoodsStockQueryResponse();
+
+        if(kbStockResponse.getSuccess()){
+            ArrayList<ErpGoodsStock> erpGoodsStocks = new ArrayList<>();
+            ErpGoodsStock erpGoodsStock = new ErpGoodsStock();
+            Integer stocks = kbStockResponse.getStock();
+            erpGoodsStock.setBarcode(barcode);
+            erpGoodsStock.setQty(stocks.toString());
+            erpGoodsStock.setSalable_qty(stocks.toString());
+            erpGoodsStocks.add(erpGoodsStock);
+            response.setStocks(erpGoodsStocks);
+        } else {
+            throw new CustomException("库存不足");
+        }
+        return response;
+    }
+
+    /**
+     * 查看库存
+     * @param request 参数
+     * @return  KbStockResponse
+     * @throws ServiceException 异常
+     */
+    private KbStockResponse getStock(KbStockRequest request) throws ServiceException {
+        FsErpConfig erpConfig = configUtil.getErpConfig();
+        // 构造参数
+        String timeStep = System.currentTimeMillis() + "";
+        if (StringUtils.isBlank(request.getStockCode())) {
+            request.setStockCode(erpConfig.getCwarehouseCode());
+        }
+        String json = JSON.toJSONString(request);
+        String sign = ScrmStoreSignUtils.sign(json, erpConfig.getKingbosSecret(), erpConfig.getKingbosan(), timeStep);
+        String url = erpConfig.getKingbosUrl().replace("do=k9save", "do=k9view");
+        url = ScrmStoreUrlUtils.getUrl(url, sign, timeStep);
+
+        // 发送请求
+        log.info("\n【金博网络】: getStock send request url: {}", url);
+        String result = HttpUtils.doPost(url, json);
+        log.info("\n【金博网络】: getStock res:{}", result);
+        return JSONObject.parseObject(result, KbStockResponse.class);
+    }
+}

+ 4 - 4
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreCartScrmServiceImpl.java

@@ -58,9 +58,9 @@ public class FsStoreCartScrmServiceImpl implements IFsStoreCartScrmService
     @Qualifier("wdtErpGoodsServiceImpl")
     private IErpGoodsService wdtErpGoodsService;
 
-    //@Autowired
-    //@Qualifier("k9StockServiceImpl")
-    //private IErpGoodsService k9StockService;
+    @Autowired
+    @Qualifier("k9StockScrmServiceImpl")
+    private IErpGoodsService k9StockService;
 
     @Autowired
     private ConfigUtil configUtil;
@@ -331,7 +331,7 @@ public class FsStoreCartScrmServiceImpl implements IFsStoreCartScrmService
                     goodsService = wdtErpGoodsService;
                 } else if (erpType == 3) {
                     //旺店通
-                    //goodsService = k9StockService;
+                    goodsService = k9StockService;
                 }
             }
         }

+ 1 - 1
fs-service/src/main/resources/application-common.yml

@@ -36,7 +36,7 @@ server:
 # 日志配置
 logging:
   level:
-    com.fs: info
+    com.fs: DEBUG
     org.springframework: warn
 
 express:

+ 12 - 1
fs-service/src/main/resources/application-config-dev.yml

@@ -25,6 +25,11 @@ wx:
         token: Ncbnd7lJvkripVOpyTFAna6NAWCxCrvC
         aesKey: HlEiBB55eaWUaeBVAQO3cWKWPYv1vOVQSq7nFNICw4E
         msgDataFormat: JSON
+      - appid: wx29d26f63f836be7f  #中康智慧商城APP
+        secret: a85bfaf0d8e243817f265a321684f6ec
+        token: Ncbnd7lJvkripVOpyTFAna6NAWCxCrvC
+        aesKey: HlEiBB55eaWUaeBVAQO3cWKWPYv1vOVQSq7nFNICw4E
+        msgDataFormat: JSON
   cp:
     corpId: wwb2a1055fb6c9a7c2
     appConfigs:
@@ -85,7 +90,13 @@ headerImg:
   imgUrl: https://jz-cos-1356808054.cos.ap-chengdu.myqcloud.com/fs/20250515/0877754b59814ea8a428fa3697b20e68.png
 ipad:
   ipadUrl: http://ipad.cdwjyyh.com
-  aiApi:
+  aiApi: http://152.136.202.157:3000/api
 wx_miniapp_temp:
   pay_order_temp_id:
   inquiry_temp_id:
+# 聚水潭API配置
+jst:
+  app_key: a4b1fab173c84f67b3873857eea11d90 #聚水潭2025-07-25
+  app_secret: dfce1f8dc8a64ddc91212fc3fcdd9349 #聚水潭2025-07-25
+  authorization_code: 666666
+  shop_code: "18461733"

+ 17 - 17
fs-service/src/main/resources/mapper/hisStore/FsUserScrmMapper.xml

@@ -44,10 +44,10 @@
         <result property="isShow" column="is_show"/>
         <result property="qwExtId"    column="qw_ext_id"    />
         <result property="isAddQw"    column="is_add_qw"    />
-        <result property="qwRepeat" column="qw_repeat"/>
+        <!--<result property="qwRepeat" column="qw_repeat"/>
         <result property="userRepeat" column="user_repeat"/>
         <result property="payOrder" column="pay_order"/>
-        <result property="isBecomeMember" column="is_become_member"/>
+        <result property="isBecomeMember" column="is_become_member"/>-->
     </resultMap>
 
     <sql id="selectFsUserVo">
@@ -90,13 +90,13 @@
                register_date,
                register_code,
                source,
-               user_code,
-               qw_repeat,
-               user_repeat,
-               pay_order,
-               is_become_member
-        from fs_user
-    </sql>
+               user_code
+        <!--qw_repeat,
+        user_repeat,
+        pay_order,
+        is_become_member -->
+ from fs_user
+</sql>
 
     <select id="selectFsUserList" parameterType="FsUserScrm" resultMap="FsUserResult">
         <include refid="selectFsUserVo"/>
@@ -134,8 +134,8 @@
             <if test="registerCode != null   and registerCode != '' ">and register_code = #{registerCode}</if>
             <if test="source != null  and source != '' ">and source = #{source}</if>
             <if test="isShow != null  ">and is_show = #{isShow}</if>
-            <if test="qwRepeat != null  ">and qw_repeat = #{qwRepeat}</if>
-            <if test="userRepeat != null  ">and user_repeat = #{userRepeat}</if>
+            <!--<if test="qwRepeat != null  ">and qw_repeat = #{qwRepeat}</if>
+            <if test="userRepeat != null  ">and user_repeat = #{userRepeat}</if>-->
             <if test="payOrder != null  ">and pay_order = #{payOrder}</if>
         </where>
         order by user_id desc
@@ -185,9 +185,9 @@
                 <if test="phone != null  and phone != ''">or phone like concat('%',#{phone},'%')</if>
                 )
             </if>
-            <if test="qwRepeat != null  ">and qw_repeat = #{qwRepeat}</if>
+            <!--<if test="qwRepeat != null  ">and qw_repeat = #{qwRepeat}</if>
             <if test="userRepeat != null  ">and user_repeat = #{userRepeat}</if>
-            <if test="payOrder != null  ">and pay_order = #{payOrder}</if>
+            <if test="payOrder != null  ">and pay_order = #{payOrder}</if>-->
         </where>
         order by user_id desc
         limit 10
@@ -443,10 +443,10 @@
             <if test="isShow != null">is_show,</if>
             <if test="qwExtId != null">qw_ext_id,</if>
             <if test="isAddQw != null">is_add_qw,</if>
-            <if test="qwRepeat != null">qw_repeat,</if>
+            <!--<if test="qwRepeat != null">qw_repeat,</if>
             <if test="userRepeat != null">user_repeat,</if>
             <if test="payOrder != null">pay_order,</if>
-            <if test="isBecomeMember != null">is_become_member,</if>
+            <if test="isBecomeMember != null">is_become_member,</if>-->
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="username != null">#{username},</if>
@@ -537,10 +537,10 @@
             <if test="isShow != null">is_show = #{isShow},</if>
             <if test="qwExtId != null">qw_ext_id = #{qwExtId},</if>
             <if test="isAddQw != null">is_add_qw = #{isAddQw},</if>
-            <if test="qwRepeat != null">qw_repeat = #{qwRepeat},</if>
+            <!--<if test="qwRepeat != null">qw_repeat = #{qwRepeat},</if>
             <if test="userRepeat != null">user_repeat = #{userRepeat},</if>
             <if test="payOrder != null">pay_order = #{payOrder},</if>
-            <if test="isBecomeMember != null">is_become_member = #{isBecomeMember},</if>
+            <if test="isBecomeMember != null">is_become_member = #{isBecomeMember},</if>-->
         </trim>
         where user_id = #{userId}
     </update>

+ 1 - 1
fs-user-app/src/main/java/com/fs/app/config/WebMvcConfig.java

@@ -19,7 +19,7 @@ public class WebMvcConfig implements WebMvcConfigurer {
 
     @Override
     public void addInterceptors(InterceptorRegistry registry) {
-        registry.addInterceptor(authorizationInterceptor).addPathPatterns("/app/**");
+        registry.addInterceptor(authorizationInterceptor).addPathPatterns("/app/**").addPathPatterns("/store/app/**");
     }
 //
 //    @Override

+ 1 - 1
fs-user-app/src/main/java/com/fs/app/controller/AppBaseController.java

@@ -24,7 +24,7 @@ import java.util.List;
 
 public class AppBaseController {
 	@Autowired
-	JwtUtils jwtUtils;
+	public JwtUtils jwtUtils;
 	@Autowired
     public RedisCache redisCache;
 

+ 3 - 3
fs-user-app/src/main/java/com/fs/app/controller/store/CommonScrmController.java

@@ -112,9 +112,9 @@ public class CommonScrmController extends AppBaseController {
     @Autowired
     @Qualifier("dfOrderServiceImpl")
     private IErpOrderService dfOrderService;
-//    @Autowired
-//    @Qualifier("k9StockServiceImpl")
-//    private IErpGoodsService k9StockService;
+    @Autowired
+    @Qualifier("k9StockScrmServiceImpl")
+    private IErpGoodsService k9StockService;
 
     @Autowired
     private RedisTemplate redisTemplate;

+ 2 - 1
fs-user-app/src/main/java/com/fs/app/controller/store/WxUserScrmController.java

@@ -253,7 +253,7 @@ public class WxUserScrmController extends AppBaseController {
         if (StringUtils.isBlank(param.getCode())) {
             return R.error("code不存在");
         }
-        final WxMaService wxService = WxMaConfiguration.getMaService(maProperties.getConfigs().get(0).getAppid());
+        final WxMaService wxService = WxMaConfiguration.getMaService(maProperties.getConfigs().get(3).getAppid());
         try {
             WxMaJscode2SessionResult session = wxService.getUserService().getSessionInfo(param.getCode());
             // 解密
@@ -270,6 +270,7 @@ public class WxUserScrmController extends AppBaseController {
                     userMap.setUserId(user.getUserId());
                     userMap.setPhone(phoneNoInfo.getPhoneNumber());
                     userMap.setUpdateTime(new DateTime());
+                    userMap.setIsShow(0);
                     user.setMaOpenId(session.getOpenid());
                     if(StringUtils.isNotEmpty(session.getUnionid())){
                         user.setUnionId(session.getUnionid());