You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
141 lines
4.9 KiB
141 lines
4.9 KiB
package com.example.demo.controller.cash;
|
|
|
|
import com.example.demo.Util.JWTUtil;
|
|
import com.example.demo.domain.entity.Admin;
|
|
import com.example.demo.domain.entity.CashRecord;
|
|
import com.example.demo.domain.entity.RechargeActivity;
|
|
import com.example.demo.domain.entity.User;
|
|
import com.example.demo.domain.vo.cash.CashCollection;
|
|
import com.example.demo.domain.vo.coin.Page;
|
|
import com.example.demo.domain.vo.coin.Result;
|
|
import com.example.demo.service.cash.CashCollectionService;
|
|
import com.github.pagehelper.PageInfo;
|
|
import jakarta.servlet.http.HttpServletRequest;
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.util.ObjectUtils;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.context.request.RequestContextHolder;
|
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
|
|
|
import java.util.Arrays;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* @program: gold-java
|
|
* @ClassName CashCollectionController
|
|
* @description:
|
|
* @author: Ethan
|
|
* @create: 2025−09-26 10:22
|
|
* @Version 1.0
|
|
**/
|
|
@RestController
|
|
@RequestMapping("/cashCollection")
|
|
@RequiredArgsConstructor
|
|
@Slf4j
|
|
@CrossOrigin
|
|
public class CashCollectionController {
|
|
@Autowired
|
|
private CashCollectionService cashCollectionService;
|
|
|
|
//根据精网号获取姓名和地区
|
|
@PostMapping("/getNameAndMarket")
|
|
public Result getNameAndMarket(@RequestBody Integer jwcode) {
|
|
try {
|
|
|
|
return Result.success(cashCollectionService.getNameAndMarket(jwcode));
|
|
} catch (Exception e) {
|
|
return Result.error(e.getMessage());
|
|
}
|
|
}
|
|
//获取收款活动列表
|
|
@PostMapping("/getActivityList")
|
|
public Result getActivityList()
|
|
{
|
|
List<RechargeActivity> list = cashCollectionService.getActivityList();
|
|
return Result.success(list);
|
|
}
|
|
//新增收款订单
|
|
@PostMapping("/add")
|
|
public Result add(@RequestBody CashCollection cashCollection) {
|
|
try {
|
|
|
|
return Result.success(cashCollectionService.add(cashCollection));
|
|
} catch (Exception e) {
|
|
return Result.error(e.getMessage());
|
|
}
|
|
}
|
|
//撤回未审核的收款订单
|
|
@PostMapping("/cancel")
|
|
public Result cancel(@RequestBody CashRecord cashRecord) {
|
|
try {
|
|
|
|
return Result.success( cashCollectionService.cancel(cashRecord.getOrderCode()));
|
|
}catch (Exception e){
|
|
return Result.error(e.getMessage());
|
|
}
|
|
}
|
|
//重新提交审核的收款订单
|
|
@PostMapping("/reSubmit")
|
|
public Result reSubmit(@RequestBody CashCollection cashRecord) {
|
|
try {
|
|
return Result.success(cashCollectionService.reSubmit(cashRecord));
|
|
}catch (Exception e){
|
|
return Result.error(e.getMessage());
|
|
}
|
|
}
|
|
//多条件查询收款订单列表
|
|
@PostMapping("/selectCollection")
|
|
public Result selcetAll(@RequestBody Page page){
|
|
try {
|
|
if (ObjectUtils.isEmpty(page.getPageNum())) {
|
|
return Result.error("页码数为空!");
|
|
}
|
|
if (ObjectUtils.isEmpty(page.getPageSize())) {
|
|
return Result.error("页大小为空!");
|
|
} else {
|
|
//解token权限
|
|
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
|
|
String token = request.getHeader("token");
|
|
Admin admin = (Admin) JWTUtil.getUserDetailsList(String.valueOf(token), Admin.class);
|
|
if (admin != null) {
|
|
List<String> list = Arrays.asList(admin.getMarkets().split(","));
|
|
page.getCashCollection().setMarkets(list);}
|
|
else{
|
|
return Result.error("角色为空");
|
|
}
|
|
|
|
return Result.success(cashCollectionService.selectCollection(page.getPageNum(), page.getPageSize(),page.getCashCollection()));
|
|
}} catch (Exception e) {
|
|
return Result.error(e.getMessage());
|
|
|
|
}}
|
|
//补全手续费等
|
|
@PostMapping("/complete")
|
|
public Result complete(@RequestBody CashCollection cashRecord) {
|
|
try {
|
|
return Result.success(cashCollectionService.complete(cashRecord));
|
|
}catch (Exception e){
|
|
return Result.error(e.getMessage());
|
|
}
|
|
}
|
|
//同步g_order订单到cash_record表
|
|
@PostMapping("/syncToCashRecord")
|
|
public Result syncToCashRecord() {
|
|
try {
|
|
return Result.success(cashCollectionService.syncToCashRecord());
|
|
}catch (Exception e){
|
|
return Result.error(e.getMessage());
|
|
}
|
|
}
|
|
//根据id查询收款订单
|
|
@PostMapping("/selectById")
|
|
public Result selectById(@RequestBody CashCollection cashCollection) {
|
|
try {
|
|
return Result.success(cashCollectionService.selectById(cashCollection));
|
|
}catch (Exception e){
|
|
return Result.error(e.getMessage());
|
|
}
|
|
}
|
|
}
|