Browse Source

小版本

huangzhiguo 2 năm trước cách đây
mục cha
commit
2236056cfd

+ 4 - 0
src/main/java/com/caimei365/user/mapper/ClubMapper.java

@@ -371,4 +371,8 @@ public interface ClubMapper {
     List<CmClubRemarksVo> selRemarksList(CmPortraitDto cmPortrait);
 
     List<BehaviorRecodeVo> selBehaviorPageTypeList(CmPortraitDto cmPortrait);
+
+    String selSpLinkMan(Integer choseServiceId);
+
+    void inProvider(@Param("spId") Integer spId, @Param("clubId") Integer clubId, @Param("operator") String operator);
 }

+ 15 - 0
src/main/java/com/caimei365/user/mapper/RegisterMapper.java

@@ -161,4 +161,19 @@ public interface RegisterMapper {
      * @param club
      */
     void updateClub(ClubPo club);
+
+
+    /**
+     * 获取省Id
+     * @param regionPro
+     * @return
+     */
+    Integer selProvince(@Param("regionPro") String regionPro);
+
+    /**
+     * 获取市Id
+     * @param regionCity
+     * @return
+     */
+    Integer selCity(@Param("regionCity") String regionCity);
 }

+ 5 - 0
src/main/java/com/caimei365/user/service/impl/ClubServiceImpl.java

@@ -1033,6 +1033,11 @@ public class ClubServiceImpl implements ClubService {
         if (!spId.equals(choseServiceId)) {
             asyncService.sendChoseServiceMessage(1, clubId, spId, choseServiceId);
         }
+        // 添加协销更换记录
+        String linkMan = clubMapper.selSpLinkMan(choseServiceId);
+        if (StringUtils.isNotBlank(linkMan)) {
+            clubMapper.inProvider(spId, clubId, linkMan);
+        }
         return ResponseJson.success();
     }
 

+ 32 - 0
src/main/java/com/caimei365/user/service/impl/RegisterServiceImpl.java

@@ -138,8 +138,18 @@ public class RegisterServiceImpl implements RegisterService {
         }
         // 获取ip所在地
         String ipAddress = "";
+        Integer provinceId = null;
+        Integer cityId = null;
         try {
             ipAddress = IpUtil.recordIp(ip);
+            Map<String, String> map = IpUtil.recordAddress(ip);
+            // 省
+            String regionPro = map.get("regionPro");
+            provinceId = registerMapper.selProvince(regionPro);
+            // 市
+            String regionCity = map.get("regionCity");
+            cityId = registerMapper.selCity(regionCity);
+
         } catch (IOException e) {
             e.printStackTrace();
         }
@@ -223,6 +233,14 @@ public class RegisterServiceImpl implements RegisterService {
         club.setAddTime(current);
         // 状态设置上线
         club.setStatus(90);
+        if (4 == user.getUserIdentity()) {
+            if (null != provinceId) {
+                club.setProvinceId(provinceId);
+            }
+            if (null != cityId) {
+                club.setCityId(cityId);
+            }
+        }
         /*
             保存数据库 club
          */
@@ -534,8 +552,18 @@ public class RegisterServiceImpl implements RegisterService {
         String current = dateFormat.format(new Date());
         // 获取ip所在地
         String ipAddress = "";
+        Integer provinceId = null;
+        Integer cityId = null;
         try {
             ipAddress = IpUtil.recordIp(ip);
+            // 获取省市地址
+            Map<String, String> map = IpUtil.recordAddress(ip);
+            // 省
+            String regionPro = map.get("regionPro");
+            provinceId = registerMapper.selProvince(regionPro);
+            // 市
+            String regionCity = map.get("regionCity");
+            cityId = registerMapper.selCity(regionCity);
         } catch (IOException e) {
             e.printStackTrace();
         }
@@ -680,6 +708,10 @@ public class RegisterServiceImpl implements RegisterService {
             club.setShortName(clubTemporary.getLinkMan());
             // 状态设置上线
             club.setStatus(90);
+            if (4 == user.getUserIdentity()) {
+                club.setProvinceId(provinceId);
+                club.setCityId(cityId);
+            }
             if (confirmUserId == null) {
                 /*
                    保存数据库(普通机构) club

+ 49 - 0
src/main/java/com/caimei365/user/utils/IpUtil.java

@@ -8,6 +8,8 @@ import java.io.InputStreamReader;
 import java.net.HttpURLConnection;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * Description
@@ -56,4 +58,51 @@ public class IpUtil {
         return region;
     }
 
+
+    // 获取IP对应地址 省、市 ---- 太平洋
+    public static Map<String, String> recordAddress(String ip) throws IOException {
+        URL url = null;
+        HttpURLConnection connection = null;
+        String encoding = "gbk";
+        String text = "";
+        String line = "";
+        String regionPro = "";
+        String regionCity = "";
+        Map<String,String> map = new HashMap<>();
+        String urlStr = "http://whois.pconline.com.cn/ipJson.jsp?ip=" + ip + "&json=true";
+        try {
+            url = new URL(urlStr);
+            connection = (HttpURLConnection) url.openConnection();    //新建链接实例
+            connection.setConnectTimeout(20000);    //设置链接超时时间,单位毫秒
+            connection.setReadTimeout(20000);        //设置读取数据超时时间,单位毫秒
+            connection.setDoOutput(true);        //是否打开输出流true|false
+            connection.setDoInput(true);        //是否打开输入流true|false
+            connection.setRequestMethod("GET");        // 提交方式get|post
+            connection.setUseCaches(false);        // 是否加入缓存true|false
+            connection.connect();    //打开链接端口
+
+            BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), encoding));    // 往对端写完数据对端服务器返回数据。以BufferedReader流来读取
+
+            while ((line = reader.readLine()) != null) {
+                text += line + "\n";
+            }
+            reader.close();
+
+            JSONObject jsonObject = JSONObject.parseObject(text);
+            // 省份
+            regionPro = jsonObject.get("pro").toString();
+            map.put("regionPro", regionPro);
+            // 市区
+            regionCity = jsonObject.get("city").toString();
+            map.put("regionCity", regionCity);
+
+        } catch (MalformedURLException e) {
+            e.printStackTrace();
+        } finally {
+            if (connection != null) {
+                connection.disconnect();    //关闭连接
+            }
+        }
+        return map;
+    }
 }

+ 9 - 1
src/main/resources/mapper/ClubMapper.xml

@@ -793,7 +793,8 @@
             <if test="keyWord != null and keyWord !=''">
                 AND (ccr.remarks LIKE concat('%',#{keyWord},'%')
                 or ccr.questionMan LIKE CONCAT('%', #{keyWord}, '%')
-                or c.Name LIKE CONCAT('%', #{keyWord}, '%'))
+                or c.Name LIKE CONCAT('%', #{keyWord}, '%')
+                or c.contractMobile like concat('%', #{keyWord}, '%'))
             </if>
             <if test="leaderId != null and leaderId>0">
                 and csr.leaderId = #{leaderId}
@@ -1125,4 +1126,11 @@
         </where>
         GROUP BY cbr.pageType  ORDER BY COUNT(cbr.pageType) LIMIT 10
     </select>
+    <select id="selSpLinkMan" resultType="java.lang.String">
+        SELECT linkMan FROM serviceprovider WHERE serviceProviderID = #{choseServiceId}
+    </select>
+    <insert id="inProvider">
+        insert into cm_provider_record (spId, clubId, operator, createTime)
+        values (#{spId}, #{clubId}, #{operator}, now())
+    </insert>
 </mapper>

+ 8 - 2
src/main/resources/mapper/RegisterMapper.xml

@@ -14,8 +14,8 @@
             values(#{userID},"新增用户","一般挽留客户",0,1)
     </insert>
     <insert id="insertClub" parameterType="com.caimei365.user.model.po.ClubPo" keyProperty="clubId" useGeneratedKeys="true">
-        insert into club(`name`, `sname`, `contractMobile`, `linkMan`, `userID`, `addTime`, `status`, `spID`, `scanFlag`)
-                  values(#{name},#{shortName},#{contractMobile},#{linkMan},#{userId},#{addTime},#{status},#{serviceProviderId},#{scanFlag})
+        insert into club(`name`, `sname`, `contractMobile`, `linkMan`, `userID`, `addTime`, `status`, `spID`, `scanFlag`, provinceID, cityID)
+                  values(#{name},#{shortName},#{contractMobile},#{linkMan},#{userId},#{addTime},#{status},#{serviceProviderId},#{scanFlag},#{provinceId},#{cityId})
     </insert>
     <insert id="insertUpgradeClub" parameterType="com.caimei365.user.model.po.ClubPo" keyProperty="clubId" useGeneratedKeys="true">
         insert into club(`name`, `sname`,     `contractMobile`, `userID`, `addTime`, `status`, `spID`,              `scanFlag`,`contractEmail`,`linkMan`, `provinceID`, `cityID`,`townID`, `address`, `headpic`, `businessLicenseImage`,`socialCreditCode`,`firstClubType`,`secondClubType`,`department`,`medicalPracticeLicenseImg`,`mainpro`)
@@ -242,4 +242,10 @@
         WHERE
           userID = #{userId}
     </update>
+    <select id="selProvince" resultType="java.lang.Integer">
+        SELECT provinceID as provinceId FROM province WHERE NAME LIKE concat('%', #{regionPro} ,'%') limit 1
+    </select>
+    <select id="selCity" resultType="java.lang.Integer">
+        SELECT cityID as cityId FROM city WHERE NAME LIKE concat('%', #{regionCity} ,'%') AND validFlag = 1 limit 1
+    </select>
 </mapper>