Ver código fonte

多店铺推送erp,分店铺推送

yfh 2 semanas atrás
pai
commit
cfda34610d

+ 13 - 1
fs-admin/src/main/java/com/fs/company/controller/CompanyController.java

@@ -1,6 +1,7 @@
 package com.fs.company.controller;
 
 import cn.hutool.core.util.IdUtil;
+import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.json.JSONUtil;
 import com.fs.common.annotation.Log;
 import com.fs.common.annotation.RepeatSubmit;
@@ -34,6 +35,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -157,7 +159,17 @@ public class CompanyController extends BaseController
         return toAjax(companyService.updateCompany(company));
     }
 
-
+    @PreAuthorize("@ss.hasPermi('company:company:bindShop')")
+    @Log(title = "绑定企业店铺", businessType = BusinessType.UPDATE)
+    @PutMapping("/bindShopCompany")
+    public AjaxResult bindShopCompany(@RequestBody Company company)
+    {
+        Company companyByStoreId = companyService.selectCompanyByStoreId(company.getStoreId());
+        if (ObjectUtil.isNotEmpty(companyByStoreId)){
+            throw new RuntimeException("此店铺已经绑定了【"+companyByStoreId.getCompanyName()+"】 公司");
+        }
+        return toAjax(companyService.updateCompany(company));
+    }
 
     /**
      * 删除企业

+ 5 - 0
fs-service/src/main/java/com/fs/company/domain/Company.java

@@ -136,4 +136,9 @@ public class Company extends BaseEntity
     /** 所属部门id */
     private Long deptId;
 
+    /**
+     * 店铺id
+     */
+    private Long storeId;
+
 }

+ 2 - 0
fs-service/src/main/java/com/fs/company/mapper/CompanyMapper.java

@@ -203,4 +203,6 @@ public interface CompanyMapper
      * 查询企微主体管理公司列表
      */
     List<OptionsVO> getCompanyListByCorpId(@Param("corpId") String corpId);
+
+    Company selectCompanyByStoreId(@Param("storeId") Long storeId);
 }

+ 2 - 0
fs-service/src/main/java/com/fs/company/service/ICompanyService.java

@@ -167,4 +167,6 @@ public interface ICompanyService
     List<OptionsVO> getCompanyListByCorpId(String corpId);
 
     void subtractCompanyMoneyHourse(BigDecimal money, Long companyId, LocalTime start, LocalTime end);
+
+    Company selectCompanyByStoreId(Long storeId);
 }

+ 5 - 0
fs-service/src/main/java/com/fs/company/service/impl/CompanyServiceImpl.java

@@ -1375,4 +1375,9 @@ public class CompanyServiceImpl implements ICompanyService
             }
         }
     }
+
+    @Override
+    public Company selectCompanyByStoreId(Long storeId) {
+        return companyMapper.selectCompanyByStoreId(storeId);
+    }
 }

+ 5 - 0
fs-service/src/main/java/com/fs/company/vo/CompanyVO.java

@@ -95,4 +95,9 @@ public class CompanyVO implements Serializable
     private Integer usedNum;
     /** 所属部门id */
     private Long deptId;
+
+ /**
+  * 店铺id
+  */
+    private Long storeId;
 }

+ 4 - 1
fs-service/src/main/java/com/fs/erp/domain/ErpOrder.java

@@ -32,6 +32,9 @@ public class ErpOrder {
 
     Integer isPackage;
     List<ErpOrderPayment> payments;
-
+    /**
+     * 多店铺 店铺编号(需对应erp店铺编号)【旺店通】
+     */
+    String shopNo;
     String buyer_account;
 }

+ 9 - 1
fs-service/src/main/java/com/fs/erp/service/impl/WdtErpOrderServiceImpl.java

@@ -290,7 +290,15 @@ public class WdtErpOrderServiceImpl implements IErpOrderService {
 
         FsErpConfig erpconfig = configUtil.getErpConfig();
         ErpWdtBusinessRequestParams erpWdtBusinessRequestParams = new ErpWdtBusinessRequestParams();
-        erpWdtBusinessRequestParams.setShopNo(erpconfig.getErpWdShopCode());
+        /**
+         * 根据公司绑定店铺,若shopNo为null还是走原有店铺
+         * 注意:该店铺编号需要与erp进行对应
+         */
+        if (StringUtils.isNotEmpty(order.getShopNo())){
+            erpWdtBusinessRequestParams.setShopNo(erpconfig.getErpWdShopCode());
+        }else {
+            erpWdtBusinessRequestParams.setShopNo(order.getShopNo());
+        }
         erpWdtBusinessRequestParams.setSwitchMode(0);
         ErpWdtTrade erpWdtTrade = new ErpWdtTrade();
         FsStoreOrderScrm fsStoreOrder = fsStoreOrderScrmService.selectFsStoreOrderByOrderCode(order.getPlatform_code());

+ 6 - 0
fs-service/src/main/java/com/fs/hisStore/domain/FsStoreScrm.java

@@ -194,4 +194,10 @@ public class FsStoreScrm extends BaseEntity
     /** 医疗机构执业许可证有效期结束 */
     private LocalDate medicalLicenseExpiryEnd;
 
+
+    /**
+     * 店铺编号
+     */
+    private String storeNo;
+
 }

+ 1 - 1
fs-service/src/main/java/com/fs/hisStore/mapper/FsStoreScrmMapper.java

@@ -86,6 +86,6 @@ public interface FsStoreScrmMapper
     List<FsStoreScrm> selectFsStoreListByProduct(FsStoreScrm fsStoreScrm);
 
 //    @Select("select store_id ,store_name,bus_no,bus_name  from fs_store_scrm ")
-    @Select("select store_id ,store_name  from fs_store_scrm ")
+    @Select("select store_id ,store_name  from fs_store_scrm  where is_audit =1 and status = 1 ")
     List<FsStoreScrmVO> selectFsAllStoreList();
 }

+ 7 - 0
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStoreOrderScrmServiceImpl.java

@@ -1754,6 +1754,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
     @Override
     public R createOmsOrder(Long orderId) throws ParseException {
         FsStoreOrderScrm order=fsStoreOrderMapper.selectFsStoreOrderById(orderId);
+
         FsSysConfig erpConfig = configUtil.generateStructConfigByKey(SysConfigEnum.HIS_CONFIG.getKey(), FsSysConfig.class);
         List<Long> noErpCompany = erpConfig.getNoErpCompany();
         if (noErpCompany != null && noErpCompany.contains(order.getCompanyId())) {
@@ -1772,6 +1773,12 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
         if(erpOrderService == jSTOrderService){
             erpOrder.setShop_code(erpConfig.getErpJstShopCode());
         }
+
+
+        //TODO 判定公司是否绑定店铺,绑定则赋值,不绑定则跳过
+
+        //查询出这个订单是哪个公司得,并且拿到绑定店铺id
+        Company company =companyMapper.selectCompanyById(order.getCompanyId());
         ErpOrderResponse response = erpOrderService.addOrderScrm(erpOrder);
 //        ErpOrderResponse response= k9OrderService.addOmsOrder(order.getId());
 

+ 10 - 0
fs-service/src/main/resources/mapper/company/CompanyMapper.xml

@@ -42,6 +42,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="groupName"    column="group_name"    />
         <result property="maxPadNum"    column="max_pad_num"    />
         <result property="deptId"   column="dept_id" />
+        <result property="storeId"   column="store_id" />
     </resultMap>
 
     <sql id="selectCompanyVo">
@@ -52,6 +53,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <include refid="selectCompanyVo"/>
         <where>
             <if test="companyId != null"> and company_id = #{companyId}</if>
+            <if test="storeId != null"> and store_id = #{storeId}</if>
             <if test="companyName != null  and companyName != ''"> and company_name like concat('%', #{companyName}, '%')</if>
             <if test="companyMobile != null  and companyMobile != ''"> and company_mobile = #{companyMobile}</if>
             <if test="companyAddress != null  and companyAddress != ''"> and company_address = #{companyAddress}</if>
@@ -89,6 +91,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         insert into company
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="companyName != null">company_name,</if>
+            <if test="storeId != null">store_id,</if>
             <if test="companyMobile != null">company_mobile,</if>
             <if test="companyAddress != null">company_address,</if>
             <if test="createTime != null">create_time,</if>
@@ -125,6 +128,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="companyName != null">#{companyName},</if>
+            <if test="storeId != null">#{storeId},</if>
             <if test="companyMobile != null">#{companyMobile},</if>
             <if test="companyAddress != null">#{companyAddress},</if>
             <if test="createTime != null">#{createTime},</if>
@@ -165,6 +169,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         update company
         <trim prefix="SET" suffixOverrides=",">
             <if test="companyName != null">company_name = #{companyName},</if>
+            <if test="storeId != null">store_id = #{storeId},</if>
             <if test="companyMobile != null">company_mobile = #{companyMobile},</if>
             <if test="companyAddress != null">company_address = #{companyAddress},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
@@ -262,4 +267,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         inner join qw_company qc on find_in_set(c.company_id, qc.company_ids)
         where c.is_del= 0 and qc.corp_id = #{corpId}
     </select>
+    <select id="selectCompanyByStoreId"  resultType="Company">
+        select *
+        from company
+        where is_del= 0 and store_id = #{storeId}
+    </select>
 </mapper>

+ 5 - 1
fs-service/src/main/resources/mapper/his/FsStoreMapper.xml

@@ -34,10 +34,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="refundConsignee"    column="refund_consignee"    />
         <result property="deliveryType"    column="delivery_type"    />
         <result property="sendPhone"    column="send_phone"    />
+        <result property="storeNo"    column="store_no"    />
     </resultMap>
 
     <sql id="selectFsStoreVo">
-        select store_id,full_name,delivery_type,send_phone, brokerage_rate,refund_phone,refund_address,refund_consignee,city_ids, store_name, descs, brokerage_type,logo_url, address, lng, lat, phone, license_images, product_count, status, create_time, update_time, sales_count, balance, total_money, is_audit, account, password, shipping_type from fs_store
+        select store_id,store_no,full_name,delivery_type,send_phone, brokerage_rate,refund_phone,refund_address,refund_consignee,city_ids, store_name, descs, brokerage_type,logo_url, address, lng, lat, phone, license_images, product_count, status, create_time, update_time, sales_count, balance, total_money, is_audit, account, password, shipping_type from fs_store
     </sql>
 
     <select id="selectFsStoreList" parameterType="FsStore" resultMap="FsStoreResult">
@@ -89,6 +90,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="refundConsignee != null">refund_consignee,</if>
             <if test="deliveryType != null">delivery_type,</if>
             <if test="sendPhone != null">send_phone,</if>
+            <if test="storeNo != null">store_no,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="cityIds != null">#{cityIds},</if>
@@ -119,6 +121,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="refundConsignee != null">#{refundConsignee},</if>
             <if test="deliveryType != null">#{deliveryType},</if>
             <if test="sendPhone != null">#{sendPhone},</if>
+            <if test="storeNo != null">#{storeNo},</if>
         </trim>
     </insert>
 
@@ -153,6 +156,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="refundConsignee != null">refund_consignee = #{refundConsignee},</if>
             <if test="deliveryType != null">delivery_type = #{deliveryType},</if>
             <if test="sendPhone != null">send_phone = #{sendPhone},</if>
+            <if test="storeNo != null">store_no = #{storeNo},</if>
         </trim>
         where store_id = #{storeId}
     </update>

+ 5 - 1
fs-service/src/main/resources/mapper/hisStore/FsStoreScrmMapper.xml

@@ -59,10 +59,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="medicalLicense"	column="medical_license" />
         <result property="medicalLicenseExpiryStart"	column="medical_license_expiry_start" />
         <result property="medicalLicenseExpiryEnd"	column="medical_license_expiry_end" />
+        <result property="storeNo"	column="store_no" />
     </resultMap>
 
     <sql id="selectFsStoreVo">
-        select store_id,full_name,delivery_type,send_phone, brokerage_rate,refund_phone,refund_address,refund_consignee,
+        select store_id,store_no,full_name,delivery_type,send_phone, brokerage_rate,refund_phone,refund_address,refund_consignee,
                city_ids, store_name, descs, brokerage_type,logo_url, address, lng, lat, phone, license_images, product_count,
                status, create_time, update_time, sales_count, balance, total_money, is_audit, account, password, shipping_type,
                enterprise_address,legal_person_name,unified_social_credit_code,
@@ -97,6 +98,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="cityIds != null">city_ids,</if>
             <if test="storeName != null">store_name,</if>
+            <if test="storeNo != null">store_no,</if>
             <if test="descs != null">descs,</if>
             <if test="logoUrl != null">logo_url,</if>
             <if test="address != null">address,</if>
@@ -152,6 +154,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="cityIds != null">#{cityIds},</if>
             <if test="storeName != null">#{storeName},</if>
+            <if test="storeNo != null">#{storeNo},</if>
             <if test="descs != null">#{descs},</if>
             <if test="logoUrl != null">#{logoUrl},</if>
             <if test="address != null">#{address},</if>
@@ -211,6 +214,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <trim prefix="SET" suffixOverrides=",">
             <if test="cityIds != null">city_ids = #{cityIds},</if>
             <if test="storeName != null">store_name = #{storeName},</if>
+            <if test="storeNo != null">store_no = #{storeNo},</if>
             <if test="descs != null">descs = #{descs},</if>
             <if test="logoUrl != null">logo_url = #{logoUrl},</if>
             <if test="address != null">address = #{address},</if>