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