xiaoyong931011
2021-11-10 fc1773400e95b39a7acd97074dd41a3fe9c302d4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package com.xzx.gc.pay.service;
 
import com.xzx.gc.common.constant.CommonEnum;
import com.xzx.gc.common.constant.Constants;
import com.xzx.gc.common.utils.BusinessUtil;
import com.xzx.gc.entity.OtherUserInfo;
import com.xzx.gc.entity.UserInfo;
import com.xzx.gc.pay.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import javax.servlet.http.HttpServletRequest;
 
@Service
@Transactional
public class UserService {
 
    @Autowired
    private UserMapper userMapper;
 
    @Autowired
    private OtherUserService otherUserService;
 
    @Autowired
    private HttpServletRequest request;
    @Autowired
    private BusinessUtil businessUtil;
 
    public UserInfo findByMobile(String mobilePhone){
        UserInfo userInfo = new UserInfo();
        userInfo.setMobilePhone(mobilePhone);
        userInfo.setDelFlag(Constants.DEL_NOT_FLAG);
        userInfo.setIsProhibit(false);
        UserInfo userInfo1 = userMapper.selectOne(userInfo);
        return userInfo1;
    }
 
    public UserInfo findById(String userId){
        UserInfo userInfo1 = userMapper.selectByPrimaryKey(userId);
        return userInfo1;
    }
 
    /**
     * 查询手机号码
     * @param userId
     * @param type    类型 0普通用户 1平台用户
     * @return
     */
    public String findOtherByUserId(String userId,int type){
        if (businessUtil.isApp(request.getHeader("clientType"))) {
            OtherUserInfo byId = otherUserService.findById(userId);
            if(byId!=null)return byId.getMobilePhone();
        }else{
            UserInfo byId = findById(userId);
            if(byId!=null)return byId.getMobilePhone();
        }
 
 
        return "未知";
 
    }
}