KKSU
2024-05-10 e921be363d2f5c5b552c8a0f456dac0bf6e1c06c
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
package cc.mrbird.febs.dapp.controller;
 
import cc.mrbird.febs.common.annotation.ControllerEndpoint;
import cc.mrbird.febs.common.controller.BaseController;
import cc.mrbird.febs.common.entity.FebsResponse;
import cc.mrbird.febs.common.entity.QueryRequest;
import cc.mrbird.febs.common.utils.FebsUtil;
import cc.mrbird.febs.dapp.entity.DappAccountMoneyChangeEntity;
import cc.mrbird.febs.dapp.entity.DappAchieve;
import cc.mrbird.febs.dapp.entity.DappFundFlowEntity;
import cc.mrbird.febs.dapp.mapper.DappFundFlowDao;
import cc.mrbird.febs.dapp.service.AsyncCjService;
import cc.mrbird.febs.dapp.service.DappWalletService;
import cc.mrbird.febs.system.entity.User;
import cn.hutool.core.util.StrUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import java.util.List;
import java.util.Map;
 
/**
 * @author 
 * @date 2022-03-22
 **/
@Slf4j
@Validated
@RestController
@RequiredArgsConstructor
@RequestMapping(value = "flow")
public class MemberMoneyFlowController extends BaseController {
 
    private final DappWalletService dappWalletService;
    private final DappFundFlowDao dappFundFlowDao;
    private final AsyncCjService asyncCjService;
 
    @GetMapping("/dappAchieveItem")
    public FebsResponse dappAchieveItem(QueryRequest request, DappAchieve dappAchieve, Integer parentId) {
        if (parentId == null) {
            ViewBannerController.zhiyaID = 0;
        }
        dappAchieve.setId(ViewBannerController.zhiyaID);
        Map<String, Object> dataTable = getDataTable(dappWalletService.dappAchieveItemInPage(dappAchieve, request));
        return new FebsResponse().success().data(dataTable);
    }
 
    @RequestMapping(value = "/dappAchieve")
    public FebsResponse dappAchieve(DappAchieve dappAchieve, QueryRequest request) {
        return new FebsResponse().success().data(getDataTable(dappWalletService.dappAchieveInPage(dappAchieve, request)));
    }
 
    @RequestMapping(value = "/fundFlow")
    public FebsResponse fundFlow(DappFundFlowEntity dappFundFlowEntity, QueryRequest request) {
        User currentUser = FebsUtil.getCurrentUser();
        if (currentUser.getDeptId() == null) {
            dappFundFlowEntity.setCurrentUser(currentUser.getUserId());
        }
        return new FebsResponse().success().data(getDataTable(dappWalletService.fundFlowInPage(dappFundFlowEntity, request)));
    }
 
    @GetMapping("confirmOrder")
    @ControllerEndpoint(operation = "批量转账", exceptionMessage = "操作失败")
    public FebsResponse confirmOrder(DappFundFlowEntity dappFundFlowIn){
        String orderIds = dappFundFlowIn.getOrderIds();
        List<String> ids = StrUtil.splitTrim(orderIds, ",");
        for(String id : ids){
            long orderId = Long.parseLong(id);
            DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectById(orderId);
            if(1 != dappFundFlowEntity.getStatus()){
                continue;
            }
            try {
                Thread.sleep(2000);
                asyncCjService.confirmOrder(dappFundFlowEntity);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        return new FebsResponse().success();
    }
 
    @GetMapping("confirmCancel")
    @ControllerEndpoint(operation = "取消", exceptionMessage = "操作失败")
    public FebsResponse confirmCancel(DappFundFlowEntity dappFundFlowIn){
        String orderIds = dappFundFlowIn.getOrderIds();
        List<String> ids = StrUtil.splitTrim(orderIds, ",");
        for(String id : ids){
            long orderId = Long.parseLong(id);
            DappFundFlowEntity dappFundFlowEntity = dappFundFlowDao.selectById(orderId);
            if(1 != dappFundFlowEntity.getStatus()){
                continue;
            }
            asyncCjService.confirmCancel(dappFundFlowEntity);
        }
        return new FebsResponse().success();
    }
 
    @PostMapping(value = "/withdrawAgree/{id}")
    public FebsResponse withdrawAgree(@PathVariable("id") Long id) {
        dappWalletService.withdrawAgreeOrNot(id, 1);
        return new FebsResponse().success();
    }
 
    @PostMapping(value = "/withdrawDisAgree/{id}")
    public FebsResponse withdrawDisAgree(@PathVariable("id") Long id) {
        dappWalletService.withdrawAgreeOrNot(id, 2);
        return new FebsResponse().success();
    }
 
    @RequestMapping(value = "accountMoneyChangeFlow")
    public FebsResponse accountMoneyChangeFlow(DappAccountMoneyChangeEntity record, QueryRequest request) {
        return new FebsResponse().success().data(getDataTable(dappWalletService.accountMoneyChangeInPage(record, request)));
    }
}