bihuisong 5 mēneši atpakaļ
vecāks
revīzija
1a5ec19811

+ 2 - 2
qmjszx-admin/src/main/resources/application.yml

@@ -150,11 +150,11 @@ rsa:
 # 微信支付配置 notifyUrl:微信支付异步回调地址
 wx:
   pay:
-    appId: #应用id
+    appId: wxe44c64c20fa20d69
     apiV3Key: #商户私钥key
     notifyUrl: #支付回调地址
     merchantId: #商户id
-    appSecret: #小程序密钥
+    appSecret: bbaaa2292da0bcc3336dc2a0f2f8493a
     privateKeyPath: #证书认证是生成文件
     merchantserialNumber: #证书序列号
 

+ 2 - 18
qmjszx-admin/src/main/resources/templates/system/member/member.html

@@ -11,8 +11,8 @@
                 <div class="select-list">
                     <ul>
                         <li>
-                            <label>真实姓名:</label>
-                            <input type="text" name="realName"/>
+                            <label>用户账户:</label>
+                            <input type="text" name="username"/>
                         </li>
                         <li>
                             <label>手机号码:</label>
@@ -76,22 +76,6 @@
                     title: '用户账户'
                 },
                 {
-                    field: 'realName',
-                    title: '真实姓名'
-                },
-                {
-                    field: 'sex',
-                    title: '性别'
-                },
-                {
-                    field: 'birthday',
-                    title: '生日'
-                },
-                {
-                    field: 'cardId',
-                    title: '身份证号码'
-                },
-                {
                     field: 'mobile',
                     title: '手机号码'
                 },

+ 6 - 3
qmjszx-business/src/main/java/beilv/applogin/controller/AppAuthController.java

@@ -1,13 +1,16 @@
 package beilv.applogin.controller;
 
 import beilv.applogin.domain.vo.AppAuthWeixinMiniAppLoginReqVO;
-import beilv.common.core.domain.AjaxResult;
 import beilv.applogin.service.IAppAuthService;
+import beilv.common.core.domain.AjaxResult;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
 import javax.annotation.Resource;
 import javax.validation.Valid;
@@ -23,11 +26,11 @@ public class AppAuthController {
     @Resource
     private IAppAuthService appAuthService;
 
-
     @PostMapping("/login")
     @Operation(summary = "微信小程序的一键登录")
     public AjaxResult weixinMiniAppLogin(@RequestBody @Valid AppAuthWeixinMiniAppLoginReqVO reqVO) throws Exception {
         return AjaxResult.success(appAuthService.weixinMiniAppLogin(reqVO));
     }
 
+
 }

+ 3 - 0
qmjszx-business/src/main/java/beilv/applogin/domain/vo/AppAuthLoginRespVO.java

@@ -24,4 +24,7 @@ public class AppAuthLoginRespVO {
     private String accessToken;
 
 
+    private String sessionKey;
+
+
 }

+ 6 - 3
qmjszx-business/src/main/java/beilv/applogin/domain/vo/AppAuthWeixinMiniAppLoginReqVO.java

@@ -13,10 +13,13 @@ import javax.validation.constraints.NotEmpty;
 @Builder
 public class AppAuthWeixinMiniAppLoginReqVO {
 
-    @NotEmpty(message = "手机 code 不能为空")
-    private String phoneCode;
-
     @NotEmpty(message = "登录 code 不能为空")
     private String loginCode;
 
+    private String encryptedData;
+
+    private String iv;
+
+    private String telephoneCode;
+
 }

+ 234 - 37
qmjszx-business/src/main/java/beilv/applogin/service/impl/AppAuthServiceImpl.java

@@ -8,20 +8,23 @@ import beilv.common.utils.rsa.RsaUtil;
 import beilv.system.domain.SysMember;
 import beilv.system.mapper.SysMemberMapper;
 import cn.binarywang.wx.miniapp.api.WxMaService;
-import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
-import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
-import me.chanjar.weixin.common.error.WxErrorException;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-
-import static beilv.common.enums.ErrorCodeConstants.AUTH_WEIXIN_MINI_APP_PHONE_CODE_ERROR;
-import static beilv.common.enums.ErrorCodeConstants.MINI_AUTH_LOGIN_BAD;
-import static beilv.common.servlet.ServletUtils.getClientIP;
-import static beilv.common.utils.ExceptionUtil.exception;
+import javax.crypto.Cipher;
+import javax.crypto.spec.IvParameterSpec;
+import javax.crypto.spec.SecretKeySpec;
+import java.io.*;
+import java.math.BigDecimal;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.*;
 
 
 /**
@@ -39,48 +42,242 @@ public class AppAuthServiceImpl implements IAppAuthService {
     private SysMemberMapper sysMemberMapper;
     @Value("${rsa.publicKey}")
     private String publicKey;
-
+    @Value("${wx.pay.appId}")
+    private String appId;
+    @Value("${wx.pay.appSecret}")
+    private String appSecret;
 
     @Override
     public AppAuthLoginRespVO weixinMiniAppLogin(AppAuthWeixinMiniAppLoginReqVO reqVO) throws Exception {
-        // 获得对应的手机号信息
-        WxMaPhoneNumberInfo phoneNumberInfo;
-        try {
-            phoneNumberInfo = wxMaService.getUserService().getNewPhoneNoInfo(reqVO.getPhoneCode());
-        } catch (Exception exception) {
-            log.error(exception.getMessage());
-            throw exception(AUTH_WEIXIN_MINI_APP_PHONE_CODE_ERROR);
-        }
-        WxMaJscode2SessionResult session;
-        try {
-            session = wxMaService.getUserService().getSessionInfo(reqVO.getLoginCode());
-        } catch (WxErrorException e) {
-            log.error(e.getMessage());
-            throw exception(MINI_AUTH_LOGIN_BAD);
-        }
+        JSONObject responseMap = getSessionKeyOropenid(reqVO.getLoginCode());
+        String openId = (String) responseMap.get("openid");
+        String sessionKey = (String) responseMap.get("session_key");
+        //获取用户信息
+        SysMember sysMember = getUserInfo(sessionKey, reqVO.getEncryptedData(), reqVO.getIv(), reqVO.getTelephoneCode());
         // 用户已经存在
-        SysMember memberUserDO = sysMemberMapper.selectByMobile(phoneNumberInfo.getPhoneNumber());
+        SysMember memberUserDO = sysMemberMapper.selectByMobile(sysMember.getMobile());
         if (memberUserDO == null) {
             // 获得获得注册用户
-            memberUserDO = sysMemberMapper.createUserIfAbsent(phoneNumberInfo.getPhoneNumber(), getClientIP(),
-                    LoginTypeEnum.WXAPP.getValue());
-            memberUserDO.setRealName("用户_" + memberUserDO.getId());
-
+            SysMember userIfAbsent = sysMemberMapper.createUserIfAbsent(sysMember);
         }
-        // 使用 sessionKey 和 openid 进行用户登录
-        String openId = session.getOpenid();
-        String sessionKey = session.getSessionKey();
-
-        memberUserDO.setOpenId(session.getOpenid());
-        sysMemberMapper.updateSysMember(memberUserDO);
-
         //加密
         String accessToken = RsaUtil.encrypt(memberUserDO.getId().toString(), publicKey);
-
         AppAuthLoginRespVO userInfo = new AppAuthLoginRespVO();
         userInfo.setAccessToken(accessToken);
         userInfo.setOpenId(openId);
+        userInfo.setSessionKey(sessionKey);
         return userInfo;
     }
 
+    /**
+     * 获取用户信息
+     *
+     * @param sessionKey    sessionKey
+     * @param encryptedData encryptedData
+     * @param iv            iv
+     * @param telephoneCode telephoneCode
+     * @return 手机号
+     */
+    public SysMember getUserInfo(String sessionKey, String encryptedData, String iv, String telephoneCode) {
+        SysMember sysMember = new SysMember();
+        Date date = new Date();
+        try {
+            // 1. 解密用户信息
+            byte[] result = decrypt(encryptedData, sessionKey, iv);
+            JSONObject json = JSONObject.parseObject(new String(result));
+            // 2. 处理解密后的手机号信息
+            String userPhone = getUserPhone(telephoneCode);
+            sysMember.setMobile(userPhone);
+            sysMember.setOpenId(json.get("openId").toString());
+            sysMember.setUsername(json.get("nickName").toString() + "_" + userPhone);
+            sysMember.setIntegral(BigDecimal.ZERO);
+            sysMember.setCreateTime(date);
+            return sysMember;
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null; // 处理异常
+        }
+    }
+
+    /**
+     * 获取用户手机号
+     *
+     * @param telephoneCode telephoneCode
+     * @return 手机号
+     */
+    public String getUserPhone(String telephoneCode) {
+        String accessToken = getAccessToken();
+
+        try {
+            // 构建 URL
+            String url = "https://api.weixin.qq.com/wxa/business/getuserphonenumber?access_token=" + accessToken;
+            URL obj = new URL(url);
+            HttpURLConnection con = (HttpURLConnection) obj.openConnection();
+            // 设置请求方法为 POST
+            con.setRequestMethod("POST");
+            con.setRequestProperty("Content-Type", "application/json");
+            // 发送 POST 请求
+            con.setDoOutput(true);
+            String jsonInputString = "{\"code\":\"" + telephoneCode + "\"}";
+            try (DataOutputStream wr = new DataOutputStream(con.getOutputStream())) {
+                wr.writeBytes(jsonInputString);
+                wr.flush();
+            }
+            // 获取响应
+            int responseCode = con.getResponseCode();
+            BufferedReader in;
+            if (responseCode == HttpURLConnection.HTTP_OK) {
+                in = new BufferedReader(new InputStreamReader(con.getInputStream()));
+            } else {
+                in = new BufferedReader(new InputStreamReader(con.getErrorStream()));
+            }
+            String inputLine;
+            StringBuilder response = new StringBuilder();
+            while ((inputLine = in.readLine()) != null) {
+                response.append(inputLine);
+            }
+            in.close();
+            JSONObject json = JSONObject.parseObject(response.toString());
+            if (json.get("errcode").equals(0)) {
+                JSONObject phoneObject = JSONObject.parseObject(json.get("phone_info").toString());
+                return phoneObject.get("phoneNumber").toString();
+            } else {
+                return null;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+            return null; // 处理异常
+        }
+    }
+
+
+    /**
+     * 获取微信小程序 session_key 和 openid
+     * 用户端
+     *
+     * @param code 调用微信登陆返回的Code
+     * @return
+     * @author zhuping
+     */
+    public JSONObject getSessionKeyOropenid(String code) {
+        //微信端登录code值
+        String wxCode = code;
+        String requestUrl = "https://api.weixin.qq.com/sns/jscode2session";    //请求地址
+        Map<String, String> requestUrlParam = new HashMap<String, String>();
+        requestUrlParam.put("appid", appId);    //开发者设置中的appId
+        requestUrlParam.put("secret", appSecret);    //开发者设置中的appSecret
+        requestUrlParam.put("js_code", wxCode);    //小程序调用wx.login返回的code
+        requestUrlParam.put("grant_type", "authorization_code");    //默认参数
+        //发送post请求读取调用微信 https://api.weixin.qq.com/sns/jscode2session 接口获取openid用户唯一标识
+        JSONObject jsonObject = JSON.parseObject(sendPost(requestUrl, requestUrlParam, null));
+        return jsonObject;
+    }
+
+
+    /**
+     * 获取微信小程序access_token
+     * 用户端
+     *
+     * @return
+     * @author zhuping
+     */
+    public String getAccessToken() {
+        //微信端登录code值
+        String requestUrl = "https://api.weixin.qq.com/cgi-bin/token";    //请求地址
+        Map<String, String> requestUrlParam = new HashMap<String, String>();
+        requestUrlParam.put("appid", appId);    //开发者设置中的appId
+        requestUrlParam.put("secret", appSecret);    //开发者设置中的appSecret
+        requestUrlParam.put("grant_type", "client_credential");    //小程序调用wx.login返回的code
+        //发送post请求读取调用微信 https://api.weixin.qq.com/sns/jscode2session 接口获取openid用户唯一标识
+        JSONObject jsonObject = JSON.parseObject(sendPost(requestUrl, requestUrlParam, null));
+        System.out.println("----------:" + jsonObject.getString("access_token"));
+        return jsonObject.getString("access_token");
+    }
+
+    /**
+     * 向指定 URL 发送POST方法的请求
+     *
+     * @param url 发送请求的 URL
+     * @param
+     * @return 所代表远程资源的响应结果
+     */
+    public static String sendPost(String url, Map<String, ?> paramMap, String headerToken) {
+        PrintWriter out = null;
+        BufferedReader in = null;
+        String result = "";
+        String param = "";
+        Iterator<String> it = paramMap.keySet().iterator();
+        while (it.hasNext()) {
+            String key = it.next();
+            param += key + "=" + paramMap.get(key) + "&";
+        }
+        try {
+            URL realUrl = new URL(url);
+            // 打开和URL之间的连接
+            URLConnection conn = realUrl.openConnection();
+            // 设置通用的请求属性
+            conn.setRequestProperty("accept", "*/*");
+            conn.setRequestProperty("connection", "Keep-Alive");
+            conn.setRequestProperty("Accept-Charset", "utf-8");
+            conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
+            if (headerToken != null) {
+                conn.setRequestProperty("access_token", headerToken);
+            }
+            // 发送POST请求必须设置如下两行
+            conn.setDoOutput(true);
+            conn.setDoInput(true);
+            // 获取URLConnection对象对应的输出流
+            out = new PrintWriter(conn.getOutputStream());
+            // 发送请求参数
+            out.print(param);
+            // flush输出流的缓冲
+            out.flush();
+            // 定义BufferedReader输入流来读取URL的响应
+            in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
+            String line;
+            while ((line = in.readLine()) != null) {
+                result += line;
+            }
+        } catch (Exception e) {
+            //log.error(e.getMessage(), e);
+        }
+        //使用finally块来关闭输出流、输入流
+        finally {
+            try {
+                if (out != null) {
+                    out.close();
+                }
+                if (in != null) {
+                    in.close();
+                }
+            } catch (IOException ex) {
+                ex.printStackTrace();
+            }
+        }
+
+        return result;
+    }
+
+
+    /**
+     * 解密用户信息
+     */
+    private byte[] decrypt(String encryptedData, String sessionKey, String iv) throws Exception {
+        // Base64解码
+        byte[] dataByte = Base64.getDecoder().decode(encryptedData);
+        byte[] keyByte = Base64.getDecoder().decode(sessionKey);
+        byte[] ivByte = Base64.getDecoder().decode(iv);
+
+        // 如果密钥不足16位,就补足为16位
+        byte[] key = new byte[16];
+        System.arraycopy(keyByte, 0, key, 0, Math.min(keyByte.length, key.length));
+
+        // 解密
+        Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
+        SecretKeySpec secretKeySpec = new SecretKeySpec(key, "AES");
+        IvParameterSpec ivParameterSpec = new IvParameterSpec(ivByte);
+        cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, ivParameterSpec);
+        return cipher.doFinal(dataByte);
+    }
+
 }

+ 0 - 90
qmjszx-system/src/main/java/beilv/system/domain/SysMember.java

@@ -36,54 +36,18 @@ public class SysMember extends BaseEntity {
     private String username;
 
     /**
-     * 用户密码(跟pwd)
-     */
-    @Excel(name = "用户密码", readConverterExp = "跟=pwd")
-    private String password;
-
-    /**
-     * 真实姓名
-     */
-    @Excel(name = "真实姓名")
-    private String realName;
-
-    /**
      * 手机号码
      */
     @Excel(name = "手机号码")
     private String mobile;
 
     /**
-     * $column.columnComment
-     */
-    @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
-    private Date loginDate;
-
-    /**
-     * $column.columnComment
-     */
-    @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
-    private String loginIp;
-
-    /**
-     * 注册ip
-     */
-    @Excel(name = "注册ip")
-    private String registerIp;
-
-    /**
      * 用户剩余积分
      */
     @Excel(name = "用户剩余积分")
     private BigDecimal integral;
 
     /**
-     * 微信用户json信息
-     */
-    @Excel(name = "微信用户json信息")
-    private String wxProfile;
-
-    /**
      * 删除
      */
     private Integer delFlag;
@@ -106,22 +70,6 @@ public class SysMember extends BaseEntity {
         return username;
     }
 
-    public void setPassword(String password) {
-        this.password = password;
-    }
-
-    public String getPassword() {
-        return password;
-    }
-
-    public void setRealName(String realName) {
-        this.realName = realName;
-    }
-
-    public String getRealName() {
-        return realName;
-    }
-
     public void setMobile(String mobile) {
         this.mobile = mobile;
     }
@@ -130,30 +78,6 @@ public class SysMember extends BaseEntity {
         return mobile;
     }
 
-    public void setLoginDate(Date loginDate) {
-        this.loginDate = loginDate;
-    }
-
-    public Date getLoginDate() {
-        return loginDate;
-    }
-
-    public void setLoginIp(String loginIp) {
-        this.loginIp = loginIp;
-    }
-
-    public String getLoginIp() {
-        return loginIp;
-    }
-
-    public void setRegisterIp(String registerIp) {
-        this.registerIp = registerIp;
-    }
-
-    public String getRegisterIp() {
-        return registerIp;
-    }
-
     public void setIntegral(BigDecimal integral) {
         this.integral = integral;
     }
@@ -162,14 +86,6 @@ public class SysMember extends BaseEntity {
         return integral;
     }
 
-    public void setWxProfile(String wxProfile) {
-        this.wxProfile = wxProfile;
-    }
-
-    public String getWxProfile() {
-        return wxProfile;
-    }
-
     public void setDelFlag(Integer delFlag) {
         this.delFlag = delFlag;
     }
@@ -191,18 +107,12 @@ public class SysMember extends BaseEntity {
         return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                 .append("id", getId())
                 .append("username", getUsername())
-                .append("password", getPassword())
-                .append("realName", getRealName())
                 .append("mobile", getMobile())
-                .append("loginDate", getLoginDate())
-                .append("loginIp", getLoginIp())
-                .append("registerIp", getRegisterIp())
                 .append("createBy", getCreateBy())
                 .append("createTime", getCreateTime())
                 .append("updateBy", getUpdateBy())
                 .append("updateTime", getUpdateTime())
                 .append("integral", getIntegral())
-                .append("wxProfile", getWxProfile())
                 .append("delFlag", getDelFlag())
                 .append("openId", getOpenId())
                 .toString();

+ 1 - 1
qmjszx-system/src/main/java/beilv/system/mapper/SysMemberMapper.java

@@ -63,5 +63,5 @@ public interface SysMemberMapper {
 
     SysMember selectByMobile(String phoneNumber);
 
-    SysMember createUserIfAbsent(String phoneNumber, String clientIP, String value);
+    public SysMember createUserIfAbsent(SysMember memberUserDO);
 }

+ 28 - 26
qmjszx-system/src/main/resources/mapper/system/SysMemberMapper.xml

@@ -7,30 +7,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <resultMap type="SysMember" id="SysMemberResult">
         <result property="id"    column="id"    />
         <result property="username"    column="username"    />
-        <result property="password"    column="password"    />
-        <result property="realName"    column="real_name"    />
         <result property="mobile"    column="mobile"    />
-        <result property="loginDate"    column="login_date"    />
-        <result property="loginIp"    column="login_ip"    />
-        <result property="registerIp"    column="register_ip"    />
         <result property="createBy"    column="create_by"    />
         <result property="createTime"    column="create_time"    />
         <result property="updateBy"    column="update_by"    />
         <result property="updateTime"    column="update_time"    />
         <result property="integral"    column="integral"    />
-        <result property="wxProfile"    column="wx_profile"    />
         <result property="delFlag"    column="del_flag"    />
         <result property="openId"    column="open_id"    />
     </resultMap>
 
     <sql id="selectSysMemberVo">
-        select id, username, password, real_name, mobile, login_date, login_ip, register_ip, create_by, create_time, update_by, update_time, integral, wx_profile, del_flag, open_id from sys_member
+        select id, username, mobile, create_by, create_time, update_by, update_time, integral, del_flag, open_id from sys_member
     </sql>
 
     <select id="selectSysMemberList" parameterType="SysMember" resultMap="SysMemberResult">
         <include refid="selectSysMemberVo"/>
         <where>  
-            <if test="realName != null  and realName != ''"> and real_name like concat('%', #{realName}, '%')</if>
+            <if test="username != null  and username != ''"> and username like concat('%', #{username}, '%')</if>
             <if test="mobile != null  and mobile != ''"> and mobile like concat('%', #{mobile}, '%')</if>
         </where>
     </select>
@@ -44,35 +38,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         insert into sys_member
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="username != null">username,</if>
-            <if test="password != null">password,</if>
-            <if test="realName != null">real_name,</if>
             <if test="mobile != null">mobile,</if>
-            <if test="loginDate != null">login_date,</if>
-            <if test="loginIp != null">login_ip,</if>
-            <if test="registerIp != null">register_ip,</if>
             <if test="createBy != null">create_by,</if>
             <if test="createTime != null">create_time,</if>
             <if test="updateBy != null">update_by,</if>
             <if test="updateTime != null">update_time,</if>
             <if test="integral != null">integral,</if>
-            <if test="wxProfile != null">wx_profile,</if>
             <if test="delFlag != null">del_flag,</if>
             <if test="openId != null">open_id,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="username != null">#{username},</if>
-            <if test="password != null">#{password},</if>
-            <if test="realName != null">#{realName},</if>
             <if test="mobile != null">#{mobile},</if>
-            <if test="loginDate != null">#{loginDate},</if>
-            <if test="loginIp != null">#{loginIp},</if>
-            <if test="registerIp != null">#{registerIp},</if>
             <if test="createBy != null">#{createBy},</if>
             <if test="createTime != null">#{createTime},</if>
             <if test="updateBy != null">#{updateBy},</if>
             <if test="updateTime != null">#{updateTime},</if>
             <if test="integral != null">#{integral},</if>
-            <if test="wxProfile != null">#{wxProfile},</if>
             <if test="delFlag != null">#{delFlag},</if>
             <if test="openId != null">#{openId},</if>
          </trim>
@@ -82,18 +64,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         update sys_member
         <trim prefix="SET" suffixOverrides=",">
             <if test="username != null">username = #{username},</if>
-            <if test="password != null">password = #{password},</if>
-            <if test="realName != null">real_name = #{realName},</if>
             <if test="mobile != null">mobile = #{mobile},</if>
-            <if test="loginDate != null">login_date = #{loginDate},</if>
-            <if test="loginIp != null">login_ip = #{loginIp},</if>
-            <if test="registerIp != null">register_ip = #{registerIp},</if>
             <if test="createBy != null">create_by = #{createBy},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
             <if test="updateBy != null">update_by = #{updateBy},</if>
             <if test="updateTime != null">update_time = #{updateTime},</if>
             <if test="integral != null">integral = #{integral},</if>
-            <if test="wxProfile != null">wx_profile = #{wxProfile},</if>
             <if test="delFlag != null">del_flag = #{delFlag},</if>
             <if test="openId != null">open_id = #{openId},</if>
         </trim>
@@ -114,4 +90,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <include refid="selectSysMemberVo"/>
         where mobile = #{mobile} and del_flag = 0
     </select>
+
+    <insert id="createUserIfAbsent" parameterType="SysMember" useGeneratedKeys="true" keyProperty="id">
+        insert into sys_member
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="username != null">username,</if>
+            <if test="mobile != null">mobile,</if>
+            <if test="createBy != null">create_by,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateBy != null">update_by,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="integral != null">integral,</if>
+            <if test="delFlag != null">del_flag,</if>
+            <if test="openId != null">open_id,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="username != null">#{username},</if>
+            <if test="mobile != null">#{mobile},</if>
+            <if test="createBy != null">#{createBy},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateBy != null">#{updateBy},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="integral != null">#{integral},</if>
+            <if test="delFlag != null">#{delFlag},</if>
+            <if test="openId != null">#{openId},</if>
+        </trim>
+    </insert>
 </mapper>