wlzboy
6 天以前 09e6dc3fb7266620fafb5e341808a8eb36e080a1
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
package com.ruoyi.web.controller.task;
 
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.vo.TaskPaymentInfoVO;
import com.ruoyi.system.domain.vo.TaskPaymentCreateVO;
import com.ruoyi.system.domain.vo.TaskPaymentResultVO;
import com.ruoyi.system.service.ISysTaskPaymentService;
 
/**
 * 任务支付Controller
 * 
 * @author ruoyi
 * @date 2025-01-15
 */
@RestController
@RequestMapping("/task/payment")
public class SysTaskPaymentController extends BaseController {
    
    @Autowired
    private ISysTaskPaymentService taskPaymentService;
    
    /**
     * 获取任务支付信息
     */
    @GetMapping("/info")
    public AjaxResult getPaymentInfo(@RequestParam Long taskId) {
        TaskPaymentInfoVO paymentInfo = taskPaymentService.getPaymentInfo(taskId);
        return success(paymentInfo);
    }
    
    /**
     * 新增附加费用
     */
    @Log(title = "新增附加费用", businessType = BusinessType.INSERT)
    @PostMapping("/additional-fee/add")
    public AjaxResult addAdditionalFee(@RequestBody Map<String, Object> params) {
        Long taskId = Long.valueOf(params.get("taskId").toString());
        String feeType = (String) params.get("feeType");
        String feeName = (String) params.get("feeName");
        BigDecimal unitAmount = new BigDecimal(params.get("unitAmount").toString());
        Integer quantity = Integer.valueOf(params.get("quantity").toString());
        String remark = params.get("remark") != null ? params.get("remark").toString() : null;
        
        BigDecimal additionalAmount = taskPaymentService.addAdditionalFee(
            taskId, feeType, feeName, unitAmount, quantity, remark
        );
        
        // 重新获取支付信息
        TaskPaymentInfoVO paymentInfo = taskPaymentService.getPaymentInfo(taskId);
        
        Map<String, Object> result = new HashMap<>();
        result.put("additionalAmount", additionalAmount);
        result.put("totalAmount", paymentInfo.getTotalAmount());
        
        return success(result);
    }
    
    /**
     * 删除附加费用
     */
    @Log(title = "删除附加费用", businessType = BusinessType.DELETE)
    @PostMapping("/additional-fee/remove")
    public AjaxResult removeAdditionalFee(@RequestBody Map<String, Object> params) {
        Long taskId = Long.valueOf(params.get("taskId").toString());
        Long feeId = Long.valueOf(params.get("feeId").toString());
        
        BigDecimal additionalAmount = taskPaymentService.removeAdditionalFee(taskId, feeId);
        
        // 重新获取支付信息
        TaskPaymentInfoVO paymentInfo = taskPaymentService.getPaymentInfo(taskId);
        
        Map<String, Object> result = new HashMap<>();
        result.put("additionalAmount", additionalAmount);
        result.put("totalAmount", paymentInfo.getTotalAmount());
        
        return success(result);
    }
    
    /**
     * 创建支付
     */
    @Log(title = "创建支付", businessType = BusinessType.INSERT)
    @PostMapping("/create")
    public AjaxResult createPayment(@RequestBody TaskPaymentCreateVO createVO) {
        TaskPaymentResultVO result = taskPaymentService.createPayment(createVO);
        return success(result);
    }
    
    /**
     * 查询支付状态
     */
    @GetMapping("/status")
    public AjaxResult getPaymentStatus(@RequestParam Long taskId, 
                                      @RequestParam(required = false) Long paymentId) {
        TaskPaymentResultVO result = taskPaymentService.getPaymentStatus(taskId, paymentId);
        return success(result);
    }
}