Explorar o código

Merge remote-tracking branch 'origin/developerD' into developer

huangzhiguo %!s(int64=2) %!d(string=hai) anos
pai
achega
decea466c1

+ 4 - 0
src/main/java/com/caimei365/user/model/po/UserPo.java

@@ -100,6 +100,10 @@ public class UserPo implements Serializable {
      * 注册ip
      */
     private String registerIp;
+    /**
+     * 注册ip所在地
+     */
+    private String ipAddress;
     /**
      * 用户状态,1正常,0冻结
      */

+ 8 - 0
src/main/java/com/caimei365/user/model/vo/ClubVo.java

@@ -191,5 +191,13 @@ public class ClubVo implements Serializable {
      *  客户价值
      */
     private String customerValue;
+    /**
+     * 新拼接机构Id
+     */
+    private String newClubId;
+    /**
+     * 注册ip所在地
+     */
+    private String ipAddress;
 
 }

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

@@ -11,10 +11,7 @@ import com.caimei365.user.model.po.*;
 import com.caimei365.user.model.vo.*;
 import com.caimei365.user.service.RegisterService;
 import com.caimei365.user.service.RemoteCallService;
-import com.caimei365.user.utils.CodeUtil;
-import com.caimei365.user.utils.Md5Util;
-import com.caimei365.user.utils.RandomCodeGenerator;
-import com.caimei365.user.utils.ValidateUtil;
+import com.caimei365.user.utils.*;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Value;
@@ -24,6 +21,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import java.io.IOException;
 import java.math.BigDecimal;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
@@ -138,6 +136,14 @@ public class RegisterServiceImpl implements RegisterService {
         if (passResult != null) {
             return ResponseJson.error(passResult);
         }
+        // 获取ip所在地
+        String ipAddress = "";
+        try {
+            ipAddress = IpUtil.recordIp(ip);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        log.info("ip所在地====》"+ipAddress);
         /*
             组装用户数据 user
          */
@@ -150,6 +156,8 @@ public class RegisterServiceImpl implements RegisterService {
         user.setRegisterTime(current);
         // 注册IP
         user.setRegisterIp(ip);
+        // 注册IP所在地
+        user.setIpAddress(ipAddress);
         // 注册来源: 0网站 1小程序
         user.setSource(clubRegisterDto.getSource());
         // 用户类型,供应商1,会员机构3,普通机构4
@@ -524,6 +532,14 @@ public class RegisterServiceImpl implements RegisterService {
         // 设置日期时间格式
         SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         String current = dateFormat.format(new Date());
+        // 获取ip所在地
+        String ipAddress = "";
+        try {
+            ipAddress = IpUtil.recordIp(ip);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        log.info("ip所在地====》"+ipAddress);
         /*
             组装用户数据 user
          */
@@ -532,6 +548,8 @@ public class RegisterServiceImpl implements RegisterService {
         user.setRegisterTime(current);
         // 机构拉上线统称为此IP方便后面直接标记为协销代注册
         user.setRegisterIp("192.168.1.10");
+        // 注册IP所在地
+        user.setIpAddress(ipAddress);
         // 注册来源: 0网站 1小程序(拉机构上线小程序注册)
         user.setSource(1);
         // 采美默认组织机构0
@@ -805,6 +823,14 @@ public class RegisterServiceImpl implements RegisterService {
         if (null == isAgreed || 1 != isAgreed) {
             return ResponseJson.error("请勾选同意协议");
         }
+        // 获取ip所在地
+        String ipAddress = "";
+        try {
+            ipAddress = IpUtil.recordIp(ip);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        log.info("ip所在地====》"+ipAddress);
         /*
             组装用户数据 user
          */
@@ -816,6 +842,8 @@ public class RegisterServiceImpl implements RegisterService {
         user.setRegisterTime(current);
         // 注册IP
         user.setRegisterIp(ip);
+        // 注册IP所在地
+        user.setIpAddress(ipAddress);
         // 注册来源: 0网站 1小程序
         user.setSource(shopRegisterDto.getSource());
         // 采美默认组织机构0

+ 9 - 0
src/main/java/com/caimei365/user/service/impl/SellerServiceImpl.java

@@ -99,6 +99,15 @@ public class SellerServiceImpl implements SellerService {
             } else {
                 club.setVipFlag(0);
             }
+            String newClubId = club.getClubId().toString();
+            int maxLen = 6;
+            int len = newClubId.length();
+            if (len < maxLen) {
+                for (int i = 0;i < (maxLen - len); i++) {
+                    newClubId = "0" + newClubId;
+                }
+            }
+            club.setNewClubId(newClubId);
         }
         PageInfo<ClubVo> pageData = new PageInfo<>(clubList);
         return ResponseJson.success(pageData);

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

@@ -0,0 +1,59 @@
+package com.caimei365.user.utils;
+
+import com.alibaba.fastjson.JSONObject;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2023/2/22
+ */
+public class IpUtil {
+
+    // 获取IP对应地址 ---- 太平洋
+    public static String recordIp(String ip) throws IOException {
+        URL url = null;
+        HttpURLConnection connection = null;
+        String encoding = "gbk";
+        String text = "";
+        String line = "";
+        String region = "";
+        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);
+            region = jsonObject.get("addr").toString();
+        } catch (MalformedURLException e) {
+            e.printStackTrace();
+        } finally {
+            if (connection != null) {
+                connection.disconnect();	//关闭连接
+            }
+        }
+        return region;
+    }
+
+}

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

@@ -873,6 +873,7 @@
                c.fax,
                c.info                                    as profile,
                c.spID                                    as serviceProviderId,
+               u.ipAddress                               as ipAddress,
                c.addTime,
                c.status,
                c.lastCheckOrderDate,

+ 5 - 4
src/main/resources/mapper/RegisterMapper.xml

@@ -2,8 +2,8 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.caimei365.user.mapper.RegisterMapper">
     <insert id="insertClubUser" parameterType="com.caimei365.user.model.po.UserPo" keyProperty="userId" useGeneratedKeys="true">
-        insert into user(`userOrganizeID`,`registerTime`,`registerIP`, `source`, `registerUserTypeID`, `name`, `userName`, `bindMobile`, `email`, `userIdentity`, `userPermission`,`guideFlag`,`clubStatus`, `password`, `agreeFlag`, `validFlag`, `serviceProviderID`, `serviceProviderStatus`, userBeans)
-                  values(#{organizeId},#{registerTime},#{registerIp},#{source},#{registerUserTypeId},#{name},#{userName},#{bindMobile},#{email},#{userIdentity},#{userPermission},#{guideFlag},#{clubStatus},#{password},#{agreeFlag},#{validFlag},#{serviceProviderId},#{serviceProviderStatus}, #{userBeans})
+        insert into user(`userOrganizeID`,`registerTime`,`registerIP`, `ipAddress`, `source`, `registerUserTypeID`, `name`, `userName`, `bindMobile`, `email`, `userIdentity`, `userPermission`,`guideFlag`,`clubStatus`, `password`, `agreeFlag`, `validFlag`, `serviceProviderID`, `serviceProviderStatus`, userBeans)
+                  values(#{organizeId},#{registerTime},#{registerIp},#{ipAddress},#{source},#{registerUserTypeId},#{name},#{userName},#{bindMobile},#{email},#{userIdentity},#{userPermission},#{guideFlag},#{clubStatus},#{password},#{agreeFlag},#{validFlag},#{serviceProviderId},#{serviceProviderStatus}, #{userBeans})
     </insert>
     <select id="selUser" resultType="com.caimei365.user.model.po.UserPo">
         select * from user where registerTime = #{registerTime}
@@ -26,8 +26,8 @@
                                     values(#{userId},#{clubId},#{shopId},#{organizeId},#{linkName},#{nickName},#{avatarUrl},#{userType},#{mobile} ,#{status},#{unionId},#{openId},#{pcOpenId},#{addTime},#{updateTime},#{bindTime},#{delFlag})
     </insert>
     <insert id="insertShopUser" parameterType="com.caimei365.user.model.po.UserPo" keyProperty="userId" useGeneratedKeys="true">
-        insert into user(`userOrganizeID`,`registerTime`, `registerIP`, `source`, `registerUserTypeID`, `name`, `userName`, `bindMobile`, `email`, `userIdentity`, `userPermission`, `manufacturerStatus` , `password`, `agreeFlag`, `validFlag`)
-        values(#{organizeId},#{registerTime},#{registerIp},#{source},#{registerUserTypeId},#{name},#{userName},#{bindMobile},#{email},#{userIdentity},#{userPermission},#{manufacturerStatus},#{password},#{agreeFlag},#{validFlag})
+        insert into user(`userOrganizeID`,`registerTime`, `registerIP`, `ipAddress`, `source`, `registerUserTypeID`, `name`, `userName`, `bindMobile`, `email`, `userIdentity`, `userPermission`, `manufacturerStatus` , `password`, `agreeFlag`, `validFlag`)
+        values(#{organizeId},#{registerTime},#{registerIp},#{ipAddress},#{source},#{registerUserTypeId},#{name},#{userName},#{bindMobile},#{email},#{userIdentity},#{userPermission},#{manufacturerStatus},#{password},#{agreeFlag},#{validFlag})
     </insert>
     <insert id="insertShop" parameterType="com.caimei365.user.model.po.ShopPo" keyProperty="shopId" useGeneratedKeys="true">
         insert into shop(`userID`, `name`, `sname`, `linkMan`, `contractMobile`, `contractEmail`, `provinceID`, `cityID`, `townID`, `address`, `socialCreditCode`, `businessLicenseImage`, `firstShopType`, `secondShopType`, `mainpro`, `productDesc`, `info`, `website`, `wxOfficialAccount`, `wxApplets`, `addTime`, `validFlag`, `status`,medicalPracticeLicenseImg1)
@@ -203,6 +203,7 @@
           name = #{name},
           registerTime = #{registerTime},
           registerIP = #{registerIp},
+          ipAddress = #{ipAddress},
           clubStatus = #{clubStatus},
           serviceProviderStatus = #{serviceProviderStatus},
           serviceProviderID = #{serviceProviderId},