新版仿ok交易所-后端
1
zj
2026-02-03 c7c4c4eec809cfd5e399edab50fae9bf68681585
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
package com.yami.trading.api.controller;
 
import java.text.DecimalFormat;
 
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
 
import javax.servlet.http.HttpServletRequest;
 
import com.yami.trading.admin.controller.c2c.C2cUserController;
import com.yami.trading.bean.c2c.C2cAdvert;
import com.yami.trading.bean.c2c.C2cUser;
import com.yami.trading.bean.c2c.C2cUserParamBaseSet;
import com.yami.trading.bean.model.C2cPaymentMethodConfig;
import com.yami.trading.bean.model.C2cTranslate;
import com.yami.trading.bean.model.User;
import com.yami.trading.common.constants.Constants;
import com.yami.trading.common.exception.BusinessException;
import com.yami.trading.common.exception.YamiShopBindException;
import com.yami.trading.common.util.Arith;
import com.yami.trading.common.util.StringUtils;
import com.yami.trading.common.web.ResultObject;
import com.yami.trading.service.c2c.*;
import com.yami.trading.service.user.UserService;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
/**
 * C2C承兑商
 */
@RestController
@Slf4j
public class ApiC2cUserController {
 
    private Logger logger = LoggerFactory.getLogger(C2cUserController.class);
 
    @Autowired
    private C2cUserService c2cUserService;
    @Autowired
    private C2cUserParamBaseSetService c2cUserParamBaseSetService;
    @Autowired
    private C2cAdvertService c2cAdvertService;
    @Autowired
    private C2cPaymentMethodConfigService c2cPaymentMethodConfigService;
    @Autowired
    private C2cTranslateService c2cTranslateService;
    @Autowired
    UserService userService;
 
    private final String action = "/api/c2cUser!";
 
    /**
     * 获取 承兑商 详情
     */
    @RequestMapping(action + "get.action")
    public Object get(HttpServletRequest request) {
        String c2c_user_id = request.getParameter("c2c_user_id");
        String language = request.getParameter("language");
 
        ResultObject resultObject = new ResultObject();
 
        try {
 
            Map<String, Object> result = new HashMap<String, Object>();
 
            C2cUser c2cUser = this.c2cUserService.getById(c2c_user_id);
            if (null == c2cUser) {
                throw new BusinessException("承兑商不存在");
            }
 
            C2cUserParamBaseSet paramBaseSet = this.c2cUserParamBaseSetService.getByPartyId(c2cUser.getC2cUserPartyId());
            if (null == paramBaseSet) {
                throw new BusinessException("承兑商参数基础设置不存在");
            }
 
            if (StringUtils.isNotEmpty(c2cUser.getHeadImg())) {
                String path = Constants.IMAGES_HTTP + c2cUser.getHeadImg();
                c2cUser.setHeadImg(path);
            }
 
            User party = userService.getById(c2cUser.getC2cUserPartyId());
            if (null == party) {
                throw new YamiShopBindException("承兑商的用户信息不存在");
            }
 
            DecimalFormat df = new DecimalFormat("#.########");
 
            c2cUser.setThirtyDaysOrder(paramBaseSet.getThirtyDaysOrder() + c2cUser.getThirtyDaysOrder());
            c2cUser.setThirtyDaysOrderRatio(0 != paramBaseSet.getThirtyDaysOrderRatio() ? paramBaseSet.getThirtyDaysOrderRatio() : c2cUser.getThirtyDaysOrderRatio());
            c2cUser.setThirtyDaysPassAverageTime(0 != paramBaseSet.getThirtyDaysPassAverageTime() ? paramBaseSet.getThirtyDaysPassAverageTime() : c2cUser.getThirtyDaysPassAverageTime());
            c2cUser.setThirtyDaysPayAverageTime(0 != paramBaseSet.getThirtyDaysPayAverageTime() ? paramBaseSet.getThirtyDaysPayAverageTime() : c2cUser.getThirtyDaysPayAverageTime());
            c2cUser.setThirtyDaysAmount(Double.valueOf(df.format(Arith.add(paramBaseSet.getThirtyDaysAmount(), c2cUser.getThirtyDaysAmount()))).doubleValue());
            c2cUser.setBuyAmount(Double.valueOf(df.format(Arith.add(paramBaseSet.getBuyAmount(), c2cUser.getBuyAmount()))).doubleValue());
            c2cUser.setSellAmount(Double.valueOf(df.format(Arith.add(paramBaseSet.getSellAmount(), c2cUser.getSellAmount()))).doubleValue());
            c2cUser.setTotalAmount(Double.valueOf(df.format(Arith.add(paramBaseSet.getTotalAmount(), c2cUser.getTotalAmount()))).doubleValue());
            c2cUser.setAccountCreateDays(paramBaseSet.getAccountCreateDays() + c2cUser.getAccountCreateDays());
            c2cUser.setFirstExchangeDays(paramBaseSet.getFirstExchangeDays() + c2cUser.getFirstExchangeDays());
            c2cUser.setExchangeUsers(paramBaseSet.getExchangeUsers() + c2cUser.getExchangeUsers());
            c2cUser.setBuySuccessOrders(paramBaseSet.getBuySuccessOrders() + c2cUser.getBuySuccessOrders());
            c2cUser.setSellSuccessOrders(paramBaseSet.getSellSuccessOrders() + c2cUser.getSellSuccessOrders());
            c2cUser.setTotalSuccessOrders(paramBaseSet.getTotalSuccessOrders() + c2cUser.getTotalSuccessOrders());
            c2cUser.setAppraiseGood(paramBaseSet.getAppraiseGood() + c2cUser.getAppraiseGood());
            c2cUser.setAppraiseBad(paramBaseSet.getAppraiseBad() + c2cUser.getAppraiseBad());
 
            c2cUser.setOrderMailNoticeOpen(1 == paramBaseSet.getOrderMailNoticeOpen() || 1 == c2cUser.getOrderMailNoticeOpen() ? 1 : 0);
            c2cUser.setOrderSmsNoticeOpen(1 == paramBaseSet.getOrderSmsNoticeOpen() || 1 == c2cUser.getOrderSmsNoticeOpen() ? 1 : 0);
            c2cUser.setOrderAppNoticeOpen(1 == paramBaseSet.getOrderAppNoticeOpen() || 1 == c2cUser.getOrderAppNoticeOpen() ? 1 : 0);
            c2cUser.setAppealMailNoticeOpen(1 == paramBaseSet.getAppealMailNoticeOpen() || 1 == c2cUser.getAppealMailNoticeOpen() ? 1 : 0);
            c2cUser.setAppealSmsNoticeOpen(1 == paramBaseSet.getAppealSmsNoticeOpen() || 1 == c2cUser.getAppealSmsNoticeOpen() ? 1 : 0);
            c2cUser.setAppealAppNoticeOpen(1 == paramBaseSet.getAppealAppNoticeOpen() || 1 == c2cUser.getAppealAppNoticeOpen() ? 1 : 0);
            c2cUser.setChatAppNoticeOpen(1 == paramBaseSet.getChatAppNoticeOpen() || 1 == c2cUser.getChatAppNoticeOpen() ? 1 : 0);
            c2cUser.setSecurityMailNoticeOpen(1 == paramBaseSet.getSecurityMailNoticeOpen() || 1 == c2cUser.getSecurityMailNoticeOpen() ? 1 : 0);
            c2cUser.setSecuritySmsNoticeOpen(1 == paramBaseSet.getSecuritySmsNoticeOpen() || 1 == c2cUser.getSecuritySmsNoticeOpen() ? 1 : 0);
            c2cUser.setSecurityAppNoticeOpen(1 == paramBaseSet.getSecurityAppNoticeOpen() || 1 == c2cUser.getSecurityAppNoticeOpen() ? 1 : 0);
 
            Map<String, Object> partyMap = new HashMap<String, Object>();
 
            partyMap.put("phoneAuthority", paramBaseSet.getPhoneAuthority());
            partyMap.put("emailAuthority", paramBaseSet.getEmailAuthority());
            partyMap.put("kycAuthority", paramBaseSet.getKycAuthority());
            partyMap.put("kycHighlevelAuthority", paramBaseSet.getKycHighlevelAuthority());
 
 
            List<C2cAdvert> adverts = this.c2cAdvertService.getByC2cUserId(c2c_user_id);
            for (int i = 0; i < adverts.size(); i++) {
                C2cAdvert adv = adverts.get(i);
                if (null != adv) {
 
                    if (StringUtils.isNotEmpty(adv.getPayType())) {
                        List<String> pay_type = new LinkedList<String>();
                        String[] types = adv.getPayType().split(",");
                        for (String type : types) {
                            C2cPaymentMethodConfig method = this.c2cPaymentMethodConfigService.get(type.trim());
                            if (null != method) {
                                C2cTranslate trans = this.c2cTranslateService.get(method.getMethodName(), language);
                                if (null != trans) {
                                    pay_type.add(trans.getTranslate());
                                } else {
                                    pay_type.add(method.getMethodName());
                                }
                            }
                        }
                        adv.setPayTypeName(String.join(",", pay_type));
                    }
                }
            }
 
            result.put("c2c_user", c2cUser);
            result.put("party", partyMap);
            result.put("advert", adverts);
 
            resultObject.setData(result);
 
        } catch (BusinessException e) {
            resultObject.setCode("1");
            resultObject.setMsg(e.getMessage());
        } catch (Throwable t) {
            resultObject.setCode("1");
            resultObject.setMsg("程序错误");
            logger.error("error:", t);
        }
        return resultObject;
    }
 
}