fix
Helius
2021-07-19 5e4f1cba1d27b43aeef878ae3b4e77813a2870ff
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
package com.xzx.gc.user.controller;
 
 
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.github.pagehelper.PageInfo;
import com.xzx.gc.common.Result;
import com.xzx.gc.common.constant.CommonEnum;
import com.xzx.gc.common.constant.Constants;
import com.xzx.gc.common.dto.log.OperationAppLog;
import com.xzx.gc.common.request.BaseController;
import com.xzx.gc.entity.AccountInfo;
import com.xzx.gc.model.JsonResult;
import com.xzx.gc.model.admin.*;
import com.xzx.gc.user.mapper.AccountMapper;
import com.xzx.gc.user.service.AccountService;
import com.xzx.gc.user.service.CityPartnerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
@Api(tags = "账户信息")
@RestController
@Validated
public class AccountController extends BaseController {
 
    @Autowired
    private AccountMapper accountMapper;
 
    @Autowired
    private AccountService accountService;
 
    @Autowired
    private CityPartnerService cityPartnerService;
 
 
    @ApiOperation( value = "查询当前用户的账户信息")
    @PostMapping("/account/find")
    public Result<AccountInfo> find(HttpServletRequest request) {
        AccountInfo accountInfo1 = accountService.findByUserId(getUserId(request));
        if(accountInfo1==null){
            return  Result.error(-1,"账户不存在");
        }
        accountInfo1.setPayPassword(null);
        return Result.success(accountInfo1);
    }
 
    @PostMapping( "/admin/front/account/queryPartnerAccountLog.json")
    @ApiOperation(value="后台账户资金流转接口", notes="test: 仅0有正确返回")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query", name ="approverStatus", value = "审核状态(1为待审核,2为已审核,3为审核不通过)", required = true, dataType = "String"),
            @ApiImplicitParam(paramType="query", name = "page", value = "页码", required = true, dataType = "int"),
            @ApiImplicitParam(paramType="query", name = "limit", value = "数量", required = true, dataType = "int"),
            @ApiImplicitParam(paramType="query", name = "type", value = "类型", required = true, dataType = "String"),
            @ApiImplicitParam(paramType="query", name = "startTime", value = "开始时间", required = true, dataType = "String"),
            @ApiImplicitParam(paramType="query", name = "endTime", value = "结束时间", required = true, dataType = "String")
    })
    public JsonResult<Map<String,Object>> queryPartnerAccountLog(@RequestBody PartnerAccountLogModel model){
        Map<String,Object> map = cityPartnerService.queryPartnerAccountLog(model);
        return JsonResult.success(map);
    }
 
    @PostMapping("/admin/front/account/queryUserAccountLog.json")
    @ApiOperation(value="账户管理优化", notes="test: 仅0有正确返回")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query", name ="szType", value = "收支类型(空为全部,1:收2:支出)", required = true, dataType = "String"),
            @ApiImplicitParam(paramType="query", name = "page", value = "页码", required = true, dataType = "int"),
            @ApiImplicitParam(paramType="query", name = "limit", value = "数量", required = true, dataType = "int"),
            @ApiImplicitParam(paramType="query", name = "channelType", value = "操作渠道1:充值 2:提现 3:回收 4入库 5红包 6分享返利 7重量达标返利8额度申请 9 额度恢复 10 推广返利 11垫付合伙人", required = true, dataType = "String"),
            @ApiImplicitParam(paramType="query", name = "startTime", value = "开始时间", required = true, dataType = "String"),
            @ApiImplicitParam(paramType="query", name = "endTime", value = "结束时间", required = true, dataType = "String"),
            @ApiImplicitParam(paramType="query", name = "userName", value = "姓名手机号", required = true, dataType = "String"),
            @ApiImplicitParam(paramType="query", name = "roleType", value = "角色类型", required = true, dataType = "int")
 
    })
    public JsonResult<Map<String,Object>> queryUserAccountLog(@RequestBody AccountLogModel model){
        Map<String,Object> map = cityPartnerService.queryUserAccountLog(model);
        return JsonResult.success(map);
    }
 
    /**
     *
     * @param model
     * @return
     */
    @PostMapping("/admin/front/account/queryAccountMoney.json")
    @ApiOperation(value="账户余额", notes="test: 仅0有正确返回")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query", name = "page", value = "页码", required = true, dataType = "int"),
            @ApiImplicitParam(paramType="query", name = "limit", value = "数量", required = true, dataType = "int"),
            @ApiImplicitParam(paramType="query", name = "isProhibit", value = "冻结状态", required = true, dataType = "String"),
            @ApiImplicitParam(paramType="query", name = "roleType", value = "角色Type", required = true, dataType = "String"),
            @ApiImplicitParam(paramType="query", name = "partnerId", value = "合伙人ID", required = true, dataType = "String"),
            @ApiImplicitParam(paramType="query", name = "userName", value = "姓名手机号", required = true, dataType = "String")
    })
    public JsonResult<Map<String,Object>> queryAccountMoney(@RequestBody AccountMoneyModel model){
 
        if(StrUtil.isBlank(model.getPartnerId())){
            List<String> partnerIds = cityPartnerService.queryPartnerByCurrent();
            if(CollUtil.isNotEmpty(partnerIds)){
                model.setPartnerId(partnerIds.get(0));
            }
        }
        List<UserModel> userIds = new ArrayList<>();
        List<String> allUserIds = new ArrayList<>();
        boolean isNull = false;
        if(StrUtil.isNotBlank(model.getPartnerId())){
            //查询合伙人所有打包站的Id
            if(null!=model.getRoleType()&&!"".equals(model.getRoleType())){
                if(model.getRoleType().equals(CommonEnum.普通用户.getValue())){
//                    List<String> townIds = service.queryTownIdsByPartnerId(partnerIds.get(0));
//                    model.setTownIds(townIds);
                    userIds = cityPartnerService.queryUserNormal(model);
                }else{
                    List<String> packageStationList = cityPartnerService.queryPackageIdList(model.getPartnerId());
                    userIds = cityPartnerService.queryOtherUserByPid(model.getPartnerId(),model,packageStationList);
                    if(null!=userIds&&userIds.size()>0){
 
                    }else{
                        isNull=true;
                    }
                }
            }else{
                List<String> packageStationList = cityPartnerService.queryPackageIdList(model.getPartnerId());
                userIds = cityPartnerService.queryOtherUserByPid(model.getPartnerId(),model,packageStationList);
                //查询合伙人区域列表
//                List<String> townIds = service.queryTownIdsByPartnerId(partnerIds.get(0));
//                model.setTownIds(townIds);
                List<UserModel> nomalUserIds = cityPartnerService.queryUserNormal(model);
                userIds.addAll(nomalUserIds);
            }
 
        }else{
            if(null!=model.getRoleType()&&!"".equals(model.getRoleType())){
                if(model.getRoleType().equals("1")){
                    userIds = cityPartnerService.queryUserNormal(model);
                    model.setUserFlag(1);
                }else{
                    userIds = cityPartnerService.queryOtherUserByPid(null,model,null);
                    if(null!=userIds&&userIds.size()>0){
                    }else{
                        isNull=true;
                    }
                }
            }else{
                if(null!=model.getUserName()&&!"".equals(model.getUserName())){
                    userIds = cityPartnerService.queryUserNormal(model);
                    List<UserModel> userIdsOth  = cityPartnerService.queryOtherUserByPid(null,model,null);
                    if(null!=userIdsOth&&userIdsOth.size()>0){
                        for (UserModel ou:userIdsOth) {
                            userIds.add(ou);
                        }
                    }
                }
            }
        }
 
        List<String> uid = new ArrayList<>();
        if(null!=userIds&&userIds.size()>0){
            for (UserModel mm:userIds) {
                uid.add(mm.getUserId());
            }
        }else{
            if(!isNull){
                if(model.getRoleType().equals("8")){
                    uid.add("0");
                }else{
                    uid = null;
                }
            }else{
                uid.add("0");
            }
        }
 
        model.setUserIds(uid);
 
        PageInfo<AccountMoneyModel> pageInfo = cityPartnerService.queryAccountByUserIds(model);
        Map<String,Object> map = new HashMap<>();
        map.put("data",pageInfo.getList());
        map.put("count",pageInfo.getTotal());
        map.put("code",0);
        return JsonResult.success(map);
    }
 
    @PostMapping( "/admin/front/account/updateAccountLimit.json")
    @ApiOperation(value="调整额度", notes="test: 仅0有正确返回")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query", name ="accountId", value = "账户Id", required = true, dataType = "String"),
            @ApiImplicitParam(paramType="query", name = "fixedLimit", value = "固定额度", required = true, dataType = "int")
    })
    public JsonResult<String> updateAccountLimit(@RequestBody AccountMoneyModel model,HttpServletRequest request){
        int num = cityPartnerService.updateAccountLimit(model);
        if(num>0){
            OperationAppLog build = OperationAppLog.builder().appPrograme(CommonEnum.后台.getValue()).opreateName(getAdminName(request))
                    .methodName(Constants.ORDER_MODUL_NAME).operateAction("调整额度-"+model.getAccountId()).build();
            mqUtil.sendApp(build);
            return JsonResult.success("修改成功!");
        } else if (num == -1) {
            return JsonResult.failMessage("可用额度不足,调额失败!");
        }else if(num == -2){
            return JsonResult.failMessage("固定额度没有改变,调额失败!");
 
        }else {
            return JsonResult.failMessage("额度必须由合伙人修改,所以修改失败!");
        }
    }
 
 
    @PostMapping("/admin/front/account/updateAccountType.json")
    @ApiOperation(value="修改账户冻结状态", notes="test: 仅0有正确返回")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query", name ="accountId", value = "账户Id", required = true, dataType = "String"),
            @ApiImplicitParam(paramType="query", name = "isProhibit", value = "冻结状态 0:未冻结,1:冻结", required = true, dataType = "int")
    })
    public JsonResult<String> updateAccountType(@RequestBody AccountMoneyModel model,HttpServletRequest request){
        int num = cityPartnerService.updateAccountType(model);
        if(num>0){
            OperationAppLog build = OperationAppLog.builder().appPrograme(CommonEnum.后台.getValue()).opreateName(getAdminName(request))
                    .methodName(Constants.ORDER_MODUL_NAME).operateAction("修改账户冻结状态-"+model.getAccountId()).build();
            mqUtil.sendApp(build);
            return JsonResult.success("修改成功");
        }else{
            return JsonResult.success("修改失败");
        }
    }
 
    @PostMapping( "/admin/front/account/queryAllType.json")
    @ApiOperation(value="类型返回", notes="test: 仅0有正确返回")
    public JsonResult<Map<String,Object>> queryAllType(@RequestBody RoleTypeModel model){
        List<Map<String,Object>> list = cityPartnerService.queryAllType(model);
        Map<String,Object> map = new HashMap<>();
        map.put("data",list);
        map.put("code",0);
        return JsonResult.success(map);
    }
}