xuhy
2024-05-28 5470d21a35286abe41fafc25a7deaabefd7c55da
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package com.stylefeng.guns.modular.system.service.impl;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.stylefeng.guns.core.util.ToolUtil;
import com.stylefeng.guns.modular.system.dao.PhoneMapper;
import com.stylefeng.guns.modular.system.dao.SysReformistMapper;
import com.stylefeng.guns.modular.system.model.Driver;
import com.stylefeng.guns.modular.system.model.Phone;
import com.stylefeng.guns.modular.system.model.SysReformist;
import com.stylefeng.guns.modular.system.service.IPhoneService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
 
@Service
public class PhoneServiceImpl extends ServiceImpl<PhoneMapper, Phone> implements IPhoneService {
 
    @Resource
    private PhoneMapper phoneMapper;
    @Autowired
    private SysReformistMapper sysReformistMapper;
 
    /**
     * 获取所有系统电话
     * @return
     * @throws Exception
     */
    @Override
    public List<Phone> queryPhones(String code) throws Exception {
        if(ToolUtil.isEmpty(code)){
            return new ArrayList<>();
        }
        String province = code.substring(0, 2) + "0000";
        String city = code.substring(0, 4) + "00";
 
        List<Phone> list = phoneMapper.queryPhones(province, city, code);
        if(list.size() == 0){
            list = phoneMapper.queryPhones(province, city, null);
        }
        if(list.size() == 0){
            list = phoneMapper.queryPhones(province, null, null);
        }
        return list;
    }
 
 
    /**
     * 获取客服电话(个人中心)
     * @param code
     * @return
     * @throws Exception
     */
    @Override
    public Map<String, Object> queryCustomerPhone(String code) throws Exception {
        String province = code.substring(0, 2) + "0000";
        String city = code.substring(0, 4) + "00";
 
        Map<String, Object> map = new HashMap<>();
        //平台电话
        Phone query = phoneMapper.query(2, 1, null, null, null);
        map.put("platform", null != query ? query.getPhone() : "");
 
        //公司
        query = phoneMapper.query(2, 2, province, city, code);
        if(query == null){
            query = phoneMapper.query(2, 2, province, city, null);
        }
        if(query == null){
            query = phoneMapper.query(2, 2, province, null, null);
        }
        map.put("company", null != query ? query.getPhone() : "");
        try {
            String wechat = "";
            List<SysReformist> companyId = sysReformistMapper.selectList(new EntityWrapper<SysReformist>().eq("companyId", query==null?1:query.getCompanyId()));
            for (SysReformist sysReformist : companyId) {
                wechat = sysReformist.getUserQrCode();
            }
            map.put("wechatUrl",wechat);
        }catch (Exception e){
            e.printStackTrace();
        }
 
        return map;
    }
}