Browse Source

短信代码迁移、隐私协议优化

yjwang 2 weeks ago
parent
commit
4c0abf9545

+ 3 - 1
fs-service/src/main/java/com/fs/common/service/impl/SmsServiceImpl.java

@@ -683,10 +683,12 @@ public class SmsServiceImpl implements ISmsService
         FsSmsConfig sms = JSON.parseObject(sysConfig.getConfigValue(), FsSmsConfig.class);
         if (sms.getType().equals("rf")) {
             try {
-                content = content.replace("${sms.sign}",sms.getRfSign());
+
                 if("1".equals(type)){
+                    content = content.replace("${sms.sign}",sms.getRfSign());
                     urls = sms.getRfUrl1() + "sms?action=send&account=" + sms.getRfAccount1() + "&password=" + sms.getRfPassword1() + "&mobile=" + phone + "&content=" + URLEncoder.encode(content, "UTF-8") + "&extno=" + sms.getRfCode1() + "&rt=json";
                 } else if("2".equals(type)){
+                    content = content.replace("${sms.sign}",sms.getRfSign3());
                     urls = sms.getRfUrl3() + "sms?action=send&account=" + sms.getRfAccount3() + "&password=" + sms.getRfPassword3() + "&mobile=" + phone + "&content=" + URLEncoder.encode(content, "UTF-8") + "&extno=" + sms.getRfCode3() + "&rt=json";
                 }
             } catch (UnsupportedEncodingException e) {

+ 1 - 0
fs-service/src/main/java/com/fs/his/config/AgreementConfig.java

@@ -8,6 +8,7 @@ import java.io.Serializable;
 public class AgreementConfig implements Serializable {
     String userRegister;
     String userPrivacy;
+    String userPrivacy2;
     String userHealth;
     String vipService;
     String vipAutomaticService;

+ 1 - 0
fs-service/src/main/java/com/fs/his/config/FsSmsConfig.java

@@ -23,6 +23,7 @@ public class FsSmsConfig {
     private String dhPassword1;
     private String dhAccount2;
     private String dhPassword2;
+    private String rfSign3;
     private String dhSign;
 
     private Integer isSmsVerification; //是否开启短信验证

+ 3 - 0
fs-service/src/main/java/com/fs/his/domain/FsUser.java

@@ -159,6 +159,9 @@ public class FsUser extends BaseEntity
      * **/
     private Long qwUserId;
 
+    /** app登录后不为null(表示是否下载app) */
+    private String historyApp;
+
     /**
      * 小程序appId,多个用逗号分隔
      */

+ 3 - 0
fs-service/src/main/java/com/fs/his/mapper/FsUserMapper.java

@@ -453,4 +453,7 @@ public interface FsUserMapper
     FsUser getUserLookAppIdByuserId(@Param("userId") Long userId);
 
     List<FsUser> selectFsUserListByPhone(String phone);
+
+    void updatePasswordByPhone(@Param("password")String password, @Param("encryptPhone")String encryptPhone);
+
 }

+ 3 - 0
fs-service/src/main/java/com/fs/his/service/IFsUserService.java

@@ -249,4 +249,7 @@ public interface IFsUserService
     R addUserAndSaleFriend(FsUser user,Long compayUserId, Long externalUserId);
 
     List<FsUser> selectFsUserListByPhone(String phone);
+
+    R updatePasswordByPhone(String password, String encryptPhone);
+
 }

+ 6 - 0
fs-service/src/main/java/com/fs/his/service/impl/FsUserServiceImpl.java

@@ -1485,4 +1485,10 @@ public class FsUserServiceImpl implements IFsUserService {
     public List<FsUser> selectFsUserListByPhone(String phone) {
         return fsUserMapper.selectFsUserListByPhone(phone);
     }
+
+    @Override
+    public R updatePasswordByPhone(String password, String encryptPhone) {
+        fsUserMapper.updatePasswordByPhone(password, encryptPhone);
+        return R.ok();
+    }
 }

+ 7 - 1
fs-service/src/main/resources/mapper/his/FsUserMapper.xml

@@ -49,10 +49,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="qwExtId"    column="qw_ext_id"    />
         <result property="qwUserId"    column="qw_user_id"    />
         <result property="appId"    column="app_id"    />
+        <result property="historyApp"    column="history_app"    />
     </resultMap>
 
     <sql id="selectFsUserVo">
-        select user_id,qw_ext_id,sex,is_buy,course_ma_open_id,is_push,is_add_qw,source,login_device,is_individuation_push,store_open_id,password,jpush_id, is_vip,vip_start_date,vip_end_date,vip_level,vip_status,nick_name,integral_status, avatar, phone, integral,sign_num, status, tui_user_id, tui_time, tui_user_count, ma_open_id, mp_open_id, union_id, is_del, user_code, remark, create_time, update_time, last_ip, balance,is_weixin_auth,parent_id,qw_user_id,company_id,company_user_id,app_id from fs_user
+        select user_id,qw_ext_id,sex,is_buy,course_ma_open_id,is_push,is_add_qw,source,history_app,login_device,is_individuation_push,store_open_id,password,jpush_id, is_vip,vip_start_date,vip_end_date,vip_level,vip_status,nick_name,integral_status, avatar, phone, integral,sign_num, status, tui_user_id, tui_time, tui_user_count, ma_open_id, mp_open_id, union_id, is_del, user_code, remark, create_time, update_time, last_ip, balance,is_weixin_auth,parent_id,qw_user_id,company_id,company_user_id,app_id from fs_user
     </sql>
 
     <select id="selectFsUserList" parameterType="FsUser" resultMap="FsUserResult">
@@ -652,6 +653,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="orderCount != null">order_count = #{orderCount},</if>
             <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
             <if test="appId != null">app_id = #{appId},</if>
+            <if test="historyApp != null">history_app = #{historyApp},</if>
         </trim>
         where user_id = #{userId}
     </update>
@@ -2309,4 +2311,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectFsUserListByPhone" resultType="com.fs.his.domain.FsUser">
         select * from fs_user where phone=#{phone}
     </select>
+
+    <update id="updatePasswordByPhone">
+        update fs_user set password = #{password} where phone = #{encryptPhone}
+    </update>
 </mapper>

+ 81 - 0
fs-user-app/src/main/java/com/fs/app/controller/AppLoginController.java

@@ -10,7 +10,10 @@ import com.fs.common.VerifyCodeUtil;
 import com.fs.common.annotation.RepeatSubmit;
 import com.fs.common.core.domain.R;
 import com.fs.common.core.redis.RedisCache;
+import com.fs.common.exception.ServiceException;
 import com.fs.common.service.ISmsService;
+import com.fs.common.utils.ServletUtils;
+import com.fs.common.utils.ip.IpUtils;
 import com.fs.common.utils.sign.Md5Utils;
 import com.fs.core.config.WxOpenProperties;
 import com.fs.his.config.FsSysConfig;
@@ -669,4 +672,82 @@ public class AppLoginController extends AppBaseController{
         }
     }
 
+    @PostMapping("/loginByPhone")
+    public R loginByPhone(@RequestBody Map<String,String> map){
+        String phone = map.get("phone");
+        String code = map.get("code");
+        String encryptPhone = encryptPhone(phone);
+        List<FsUser> user = userService.selectFsUserListByPhone(encryptPhone);
+        if (CollectionUtil.isEmpty(user)){
+            user = userService.selectFsUserListByPhone(encryptPhoneOldKey(phone));
+        }
+        if (CollectionUtil.isEmpty(user)){
+            return R.error("此电话号码未绑定用户");
+        }
+        if (user.size()>1){
+            //如果出现了一个手机号多个用户的情况,找出登陆过app的那个用户
+            user.removeIf(fsUser -> StringUtils.isEmpty(fsUser.getHistoryApp()));
+        }
+        String redisCode = redisCache.getCacheObject("sms:code:" + phone);
+        if (StringUtils.isEmpty(redisCode)){
+            return R.error("验证码已过期,请重新发送");
+        }
+        if (!redisCode.equals(code)) {
+            return R.error("验证码错误");
+        }
+        updateExistingUserJpushId(user.get(0), map.get("jpushId"));
+
+        // 更新登录设备信息
+        updateLoginDevice(user.get(0).getUserId(), map.get("loginDevice"), map.get("source"));
+
+        return generateTokenAndReturn(user.get(0));
+    }
+
+    @PostMapping("/resetPassword")
+    public R resetPassword(@RequestBody Map<String, String> body){
+        String phone = body.get("phone");
+        String code = body.get("code");
+        String newPassword = body.get("newPassword");
+        String confirmPassword = body.get("confirmPassword");
+        if (!newPassword.equals(confirmPassword)){
+            throw new ServiceException("两次输入密码不一致,请检查");
+        }
+        String encryptPhone = encryptPhone(phone);
+        List<FsUser> user = userService.selectFsUserListByPhone(encryptPhone);
+        if (CollectionUtil.isEmpty(user)){
+            user = userService.selectFsUserListByPhone(encryptPhoneOldKey(phone));
+        }
+        if (CollectionUtil.isEmpty(user)){
+            return R.error("此电话号码未绑定用户");
+        }
+        String redisCode = redisCache.getCacheObject("sms:code:" + phone);
+        if (StringUtils.isEmpty(redisCode)){
+            return R.error("验证码已过期,请重新发送");
+        }
+        if (!redisCode.equals(code)) {
+            return R.error("验证码错误");
+        }
+        String password = Md5Utils.hash(newPassword);
+        return userService.updatePasswordByPhone(password,encryptPhone);
+    }
+
+    /**
+     * 更新用户登录设备信息
+     * @param userId 用户ID
+     * @param loginDevice 登录设备
+     * @param source 来源
+     */
+    private void updateLoginDevice(Long userId, String loginDevice, String source) {
+        FsUser updateUser = new FsUser();
+        updateUser.setUserId(userId);
+        if (StringUtils.isNotBlank(loginDevice)) {
+            updateUser.setLoginDevice(loginDevice);
+        }
+        if (StringUtils.isNotBlank(source)) {
+            updateUser.setSource(source);
+        }
+        updateUser.setLastIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
+        userService.updateFsUser(updateUser);
+    }
+
 }

+ 11 - 0
fs-user-app/src/main/java/com/fs/app/controller/H5Controller.java

@@ -41,6 +41,17 @@ public class H5Controller
         return mv;
     }
 
+    @GetMapping("/privacyPolicy2")
+    public ModelAndView privacyPolicy2()
+    {
+        String json=configService.selectConfigByKey("his.agreementConfig");
+        AgreementConfig config= JSONUtil.toBean(json, AgreementConfig.class);
+        ModelAndView mv=new ModelAndView();
+        mv.addObject("privacyPolicy", config.getUserPrivacy2());
+        mv.setViewName("privacyPolicy");
+        return mv;
+    }
+
     @GetMapping("/healthCustomerService")
     public ModelAndView healthCustomerService( )
     {

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

@@ -392,6 +392,9 @@ public class UserController extends  AppBaseController {
         return getDataTable(list);
     }
 
+    /**
+     * 更新historyApp
+     */
     /**
      * 更新historyApp
      */
@@ -401,7 +404,7 @@ public class UserController extends  AppBaseController {
         String userId = getUserId();
         FsUser fsUser = new FsUser();
         fsUser.setUserId(Long.parseLong(userId));
-//        fsUser.setHistoryApp(historyApp);
+        fsUser.setHistoryApp(historyApp);
         if (userService.updateFsUser(fsUser)>0) {
             return R.ok();
         } else {