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);
|
}
|
}
|