peter
2025-11-26 566a1b9fda0276e2cc4a35f7ba322c0e599a2c84
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
93
94
95
96
97
98
99
100
101
102
103
package com.nq.service.impl;
 
 
import com.nq.common.ServerResponse;
 
import com.nq.dao.AgentUserMapper;
import com.nq.dao.SiteInfoMapper;
 
import com.nq.pojo.AgentUser;
import com.nq.pojo.SiteInfo;
 
import com.nq.service.ISiteInfoService;
 
import java.util.List;
 
import org.apache.commons.lang3.StringUtils;
 
import org.springframework.beans.factory.annotation.Autowired;
 
import org.springframework.stereotype.Service;
 
 
@Service("iSiteInfoService")
 
public class SiteInfoServiceImpl implements ISiteInfoService {
    @Autowired
    SiteInfoMapper siteInfoMapper;
    @Autowired
    AgentUserMapper agentUserMapper;
 
 
    public ServerResponse get() {
 
        List<SiteInfo> siteInfos = this.siteInfoMapper.findAll();
        if (siteInfos.size() > 0) {
            SiteInfo siteInfo = (SiteInfo) siteInfos.get(0);
            return ServerResponse.createBySuccess(siteInfo);
        }
        return ServerResponse.createByErrorMsg("设置信息不存在");
 
    }
 
 
    public ServerResponse add(SiteInfo siteInfo) {
 
        List<SiteInfo> siteInfos = this.siteInfoMapper.findAll();
 
        if (siteInfos.size() > 0) {
            return ServerResponse.createByErrorMsg("不能重复添加");
        }
 
        if (StringUtils.isBlank(siteInfo.getSiteName()) ||
                StringUtils.isBlank(siteInfo.getSiteLogo()) ||
                StringUtils.isBlank(siteInfo.getSiteLogoSm())) {
            return ServerResponse.createByErrorMsg("名字和logo不能为空");
        }
 
        int insertCount = this.siteInfoMapper.insert(siteInfo);
        if (insertCount > 0) {
            return ServerResponse.createBySuccessMsg("添加成功");
        }
        return ServerResponse.createByErrorMsg("添加失败");
 
    }
 
 
    public ServerResponse update(SiteInfo siteInfo) {
 
        if (siteInfo.getId() == null) {
            return ServerResponse.createByErrorMsg("ID不能为空");
        }
 
        int updateCount = this.siteInfoMapper.updateByPrimaryKeySelective(siteInfo);
 
        if (updateCount > 0) {
            return ServerResponse.createBySuccessMsg("修改成功");
        }
        return ServerResponse.createByErrorMsg("修改失败");
    }
 
 
    public ServerResponse getInfo() {
 
        List<SiteInfo> siteInfos = this.siteInfoMapper.findAll();
 
        if (siteInfos.size() > 0) {
            SiteInfo siteInfo = (SiteInfo) siteInfos.get(0);
            AgentUser agentUser = agentUserMapper.findByPhone("18888888888");
            if(agentUser != null){
                siteInfo.setAgentCode(agentUser.getAgentCode());
            }
            /*if (!StringUtils.isEmpty(siteInfo.getTradeAgree())) {
                CmcPayOuterRequestUtil cmcPayOuterRequestUtil = new CmcPayOuterRequestUtil();
                String result = cmcPayOuterRequestUtil.sendGet(siteInfo.getTradeAgree());
                siteInfo.setTradeAgreeText(result);
            }*/
            return ServerResponse.createBySuccess(siteInfo);
        }
        return ServerResponse.createByErrorMsg("设置信息info不存在");
 
    }
 
}