nili
7 months ago
23 changed files with 273 additions and 29 deletions
@ -0,0 +1,35 @@ |
|||
package awesome.group.game.service.bo.matrix; |
|||
|
|||
import awesome.group.game.dao.bean.MatrixMoneyRecord; |
|||
import awesome.group.game.dao.bean.MatrixUser; |
|||
import awesome.group.game.service.bo.citrus.UserBo; |
|||
|
|||
public class MoneyBo { |
|||
public UserBo user; |
|||
public Integer id; |
|||
public Integer cent; |
|||
public String aliPayAccount; |
|||
public String name; |
|||
public String reason; |
|||
public Integer status;//0发起申请,1审批成功,2转账中,3转账成功,-1转账失败
|
|||
public long createdAt; |
|||
|
|||
public MoneyBo() { |
|||
} |
|||
|
|||
public MoneyBo(MatrixUser user, MatrixMoneyRecord r, boolean encypt) { |
|||
this.user = new UserBo(user, encypt); |
|||
this.id = r.getId(); |
|||
this.cent = r.getCent(); |
|||
this.aliPayAccount = r.getAliPayAccount(); |
|||
this.name = r.getName(); |
|||
this.reason = r.getReason(); |
|||
this.status = r.getStatus(); |
|||
this.createdAt = r.getCreatedAt().getTime(); |
|||
|
|||
if (encypt) { |
|||
this.aliPayAccount = UserBo.replaceWithX(this.aliPayAccount); |
|||
this.name = UserBo.replaceWithX(this.name); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,8 @@ |
|||
package awesome.group.game.service.bo.matrix; |
|||
|
|||
import awesome.group.game.service.bo.PageParam; |
|||
|
|||
public class MoneyQuery extends PageParam { |
|||
public String appCode; |
|||
public Integer status; |
|||
} |
@ -0,0 +1,8 @@ |
|||
package awesome.group.game.service.bo.matrix; |
|||
|
|||
import awesome.group.game.service.bo.PageParam; |
|||
|
|||
public class UserQuery extends PageParam { |
|||
public String appCode; |
|||
|
|||
} |
@ -1,4 +1,4 @@ |
|||
package awesome.group.game.service; |
|||
package awesome.group.game.service.citrus; |
|||
|
|||
import awesome.group.game.dao.bean.MatrixMoneyRecord; |
|||
import awesome.group.game.dao.mapper.MatrixMoneyRecordMapper; |
@ -1,4 +1,4 @@ |
|||
package awesome.group.game.service; |
|||
package awesome.group.game.service.matrix; |
|||
|
|||
import awesome.group.game.dao.bean.*; |
|||
import awesome.group.game.dao.mapper.*; |
@ -1,4 +1,4 @@ |
|||
package awesome.group.game.service; |
|||
package awesome.group.game.service.matrix; |
|||
|
|||
import awesome.group.game.dao.bean.*; |
|||
import awesome.group.game.dao.mapper.*; |
@ -1,4 +1,4 @@ |
|||
package awesome.group.game.service; |
|||
package awesome.group.game.service.matrix; |
|||
|
|||
import awesome.group.game.dao.bean.MatrixAdvAggregation; |
|||
import awesome.group.game.dao.mapper.MatrixAdvAggregationMapper; |
@ -1,4 +1,4 @@ |
|||
package awesome.group.game.service; |
|||
package awesome.group.game.service.matrix; |
|||
|
|||
import awesome.group.game.dao.bean.MatrixAdvAggregationSub; |
|||
import awesome.group.game.dao.mapper.MatrixAdvAggregationSubMapper; |
@ -0,0 +1,73 @@ |
|||
package awesome.group.game.service.matrix; |
|||
|
|||
import awesome.group.game.dao.bean.MatrixApp; |
|||
import awesome.group.game.dao.bean.MatrixMoneyRecord; |
|||
import awesome.group.game.dao.bean.MatrixUser; |
|||
import awesome.group.game.dao.mapper.MatrixAppMapper; |
|||
import awesome.group.game.dao.mapper.MatrixMoneyRecordMapper; |
|||
import awesome.group.game.dao.mapper.MatrixUserMapper; |
|||
import awesome.group.game.service.bo.PageResult; |
|||
import awesome.group.game.service.bo.citrus.UserBo; |
|||
import awesome.group.game.service.bo.matrix.MoneyBo; |
|||
import awesome.group.game.service.bo.matrix.MoneyQuery; |
|||
import awesome.group.game.service.common.exception.PaganiException; |
|||
import awesome.group.game.service.common.exception.PaganiExceptionCode; |
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.util.Assert; |
|||
|
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
@Service |
|||
public class MatrixMoneyService { |
|||
|
|||
@Autowired |
|||
private MatrixMoneyRecordMapper moneyRecordMapper; |
|||
|
|||
@Autowired |
|||
private MatrixAppMapper appMapper; |
|||
|
|||
@Autowired |
|||
private MatrixUserService matrixUserService; |
|||
|
|||
@Autowired |
|||
private AdminService adminService; |
|||
|
|||
public static final int AUDIT_FAIL= -2; |
|||
public static final int AUDIT_SUCCESS= -1; |
|||
|
|||
public PageResult<MoneyBo> list(MoneyQuery query) { |
|||
MatrixApp app = appMapper.queryByCode(query.appCode); |
|||
LambdaQueryWrapper<MatrixMoneyRecord> wrapper = new LambdaQueryWrapper<>(); |
|||
wrapper.eq(MatrixMoneyRecord::getAppId, app.getId()); |
|||
if (query.status != null) { |
|||
wrapper.eq(MatrixMoneyRecord::getStatus, query.status); |
|||
} |
|||
wrapper.orderByDesc(MatrixMoneyRecord::getId); |
|||
int page = query.current; |
|||
int pageSize = query.pageSize; |
|||
IPage<MatrixMoneyRecord> iPage = moneyRecordMapper.selectPage(new Page<>(page, pageSize), wrapper); |
|||
PageResult<MoneyBo> res = new PageResult<>(); |
|||
res.total = iPage.getTotal(); |
|||
List<MatrixMoneyRecord> records = iPage.getRecords(); |
|||
List<Integer> uids = records.stream().map(MatrixMoneyRecord::getUserId).toList(); |
|||
Map<Integer, MatrixUser> uMap = matrixUserService.getUser(uids); |
|||
res.data = records.stream().map(r -> new MoneyBo(uMap.get(r.getUserId()), r, true)).toList(); |
|||
return res; |
|||
} |
|||
|
|||
public void setStatus(Integer id, int status, String reason, Integer adminId) { |
|||
Assert.isTrue(Arrays.asList(AUDIT_FAIL, AUDIT_SUCCESS).contains(status), "非法请求"); |
|||
MatrixMoneyRecord record = moneyRecordMapper.selectById(id); |
|||
List<Integer> appIds = adminService.getAdminAppIds(adminId); |
|||
if (!appIds.contains(record.getAppId())) { |
|||
throw new PaganiException(PaganiExceptionCode.GENERAL_ERROR, "非法请求,多次操作将被封号"); |
|||
} |
|||
moneyRecordMapper.updateStatusAndReason(id, status, reason); |
|||
} |
|||
} |
@ -0,0 +1,54 @@ |
|||
package awesome.group.game.service.matrix; |
|||
|
|||
import awesome.group.game.dao.bean.MatrixApp; |
|||
import awesome.group.game.dao.bean.MatrixUser; |
|||
import awesome.group.game.dao.mapper.MatrixAppMapper; |
|||
import awesome.group.game.dao.mapper.MatrixUserMapper; |
|||
import awesome.group.game.service.bo.PageResult; |
|||
import awesome.group.game.service.bo.citrus.UserBo; |
|||
import awesome.group.game.service.bo.matrix.UserQuery; |
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.util.CollectionUtils; |
|||
|
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.stream.Collectors; |
|||
|
|||
@Service |
|||
public class MatrixUserService { |
|||
@Autowired |
|||
private MatrixUserMapper userMapper; |
|||
|
|||
@Autowired |
|||
private MatrixAppMapper appMapper; |
|||
|
|||
public PageResult<UserBo> list(UserQuery query) { |
|||
MatrixApp app = appMapper.queryByCode(query.appCode); |
|||
LambdaQueryWrapper<MatrixUser> wrapper = new LambdaQueryWrapper<>(); |
|||
wrapper.eq(MatrixUser::getAppId, app.getId()); |
|||
|
|||
int page = query.current; |
|||
int pageSize = query.pageSize; |
|||
wrapper.orderByDesc(MatrixUser::getId); |
|||
IPage<MatrixUser> iPage = userMapper.selectPage(new Page<>(page, pageSize), wrapper); |
|||
PageResult<UserBo> res = new PageResult<>(); |
|||
res.total = iPage.getTotal(); |
|||
res.data = iPage.getRecords().stream().map(u -> new UserBo(u, true)).toList(); |
|||
return res; |
|||
} |
|||
|
|||
public Map<Integer, MatrixUser> getUser(List<Integer> uidList) { |
|||
if (CollectionUtils.isEmpty(uidList)) { |
|||
return new HashMap<>(); |
|||
} |
|||
LambdaQueryWrapper<MatrixUser> wrapper = new LambdaQueryWrapper<>(); |
|||
wrapper.in(MatrixUser::getId, uidList); |
|||
List<MatrixUser> list = userMapper.selectList(wrapper); |
|||
return list.stream().collect(Collectors.toMap(MatrixUser::getId, x -> x)); |
|||
} |
|||
} |
@ -1,4 +1,4 @@ |
|||
package awesome.group.game.service; |
|||
package awesome.group.game.service.matrix; |
|||
|
|||
import awesome.group.game.service.bo.STSInfo; |
|||
import awesome.group.game.service.cache.CacheKey; |
@ -0,0 +1,34 @@ |
|||
package awesome.group.game.web.rest.matrix; |
|||
|
|||
import awesome.group.game.service.bo.PageResult; |
|||
import awesome.group.game.service.bo.matrix.MoneyBo; |
|||
import awesome.group.game.service.bo.matrix.MoneyQuery; |
|||
import awesome.group.game.service.common.response.R; |
|||
import awesome.group.game.service.matrix.MatrixMoneyService; |
|||
import awesome.group.game.web.RequestContext; |
|||
import awesome.group.game.web.aop.RestApi; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
@RestController |
|||
@RequestMapping("/api/admin/money") |
|||
public class MatrixMoneyController { |
|||
@Autowired |
|||
private MatrixMoneyService matrixMoneyService; |
|||
|
|||
@PostMapping("/list") |
|||
@RestApi |
|||
public R<PageResult<MoneyBo>> moneyApplyList(@RequestBody MoneyQuery query) { |
|||
return new R<>(matrixMoneyService.list(query)); |
|||
} |
|||
|
|||
@PostMapping("/audit") |
|||
@RestApi |
|||
public R<Void> audit(@RequestBody MoneyBo moneyBo) { |
|||
matrixMoneyService.setStatus(moneyBo.id, moneyBo.status, moneyBo.reason, RequestContext.getAdminID()); |
|||
return new R<>(null); |
|||
} |
|||
} |
@ -0,0 +1,23 @@ |
|||
package awesome.group.game.web.rest.matrix; |
|||
|
|||
import awesome.group.game.service.bo.PageResult; |
|||
import awesome.group.game.service.bo.citrus.UserBo; |
|||
import awesome.group.game.service.bo.matrix.UserQuery; |
|||
import awesome.group.game.service.common.response.R; |
|||
import awesome.group.game.service.matrix.MatrixUserService; |
|||
import awesome.group.game.web.aop.RestApi; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
@RestController |
|||
@RequestMapping("/api/admin/user") |
|||
public class MatrixUserController { |
|||
@Autowired |
|||
private MatrixUserService userService; |
|||
|
|||
@PostMapping("/list") |
|||
@RestApi |
|||
public R<PageResult<UserBo>> list(@RequestBody UserQuery query) { |
|||
return new R<>(userService.list(query)); |
|||
} |
|||
} |
Loading…
Reference in new issue