diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/payment/CasePaymentController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/payment/CasePaymentController.java index f8c256b..cba05bd 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/payment/CasePaymentController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/payment/CasePaymentController.java @@ -1,9 +1,11 @@ package com.ruoyi.web.controller.payment; - -import com.ruoyi.dto.PayRequest; -import com.ruoyi.system.service.ICasePaymentService; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.wisdomarbitrate.domain.CaseApplication; +import com.ruoyi.wisdomarbitrate.service.ICasePaymentService; +import com.ruoyi.wisdomarbitrate.domain.dto.CasePayDTO; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; /** @@ -17,34 +19,23 @@ public class CasePaymentController { public CasePaymentController(ICasePaymentService paymentService){ this.paymentService=paymentService; } - - /** - * 查询缴费列表 - */ - @GetMapping - public String queryPayList(){ - return paymentService.queryPayList(); - } - - /** - * 根据案件id查询缴费清单 - * @return - */ - @GetMapping - public String getPaymentListByCaseId(){ - return paymentService.getPaymentListByCaseId(); - } /** * 案件缴费 - * @param request - * @return + * @param casePayDTO 缴费传入参数 + * @return 统一响应结果 */ @PostMapping("/casePay") - public String casePay(PayRequest request) { - return paymentService.casePay(request); + public AjaxResult casePay(@Validated @RequestBody CasePayDTO casePayDTO) { + return paymentService.casePay(casePayDTO); } - @PutMapping - public String payConfirm(){ - return paymentService.payConfirm(); + + /** + * 缴费确认 + * @param caseApplication + * @return + */ + @PutMapping("/confirm") + public AjaxResult confirmPayment(@Validated @RequestBody CaseApplication caseApplication) { + return paymentService.confirmPayment(caseApplication); } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/CasePaymentMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/CasePaymentMapper.java deleted file mode 100644 index b7d80fc..0000000 --- a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/CasePaymentMapper.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.ruoyi.system.mapper; - -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface CasePaymentMapper { - void queryPayList(); -} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ICasePaymentService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ICasePaymentService.java deleted file mode 100644 index ffc81c8..0000000 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ICasePaymentService.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.ruoyi.system.service; - -import com.ruoyi.dto.PayRequest; - -public interface ICasePaymentService { - /** - * 案件缴费 - * @param request - * @return - */ - String casePay(PayRequest request); - /** - * 查询缴费列表 - */ - String queryPayList(); - - String getPaymentListByCaseId(); - - String payConfirm(); - -} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CasePaymentServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CasePaymentServiceImpl.java deleted file mode 100644 index 0a5c454..0000000 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CasePaymentServiceImpl.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.ruoyi.system.service.impl; - -import com.ruoyi.ElegentPay; -import com.ruoyi.constant.Platform; -import com.ruoyi.constant.TradeType; -import com.ruoyi.dto.PayRequest; -import com.ruoyi.dto.PayResponse; -import com.ruoyi.system.mapper.CasePaymentMapper; -import com.ruoyi.system.service.ICasePaymentService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -@Service -public class CasePaymentServiceImpl implements ICasePaymentService { - private final ElegentPay elegentPay; - private final CasePaymentMapper paymentMapper; - @Autowired - public CasePaymentServiceImpl(ElegentPay elegentPay,CasePaymentMapper paymentMapper ){ - this.elegentPay=elegentPay; - this.paymentMapper=paymentMapper; - } - @Override - public String casePay(PayRequest request) { - PayResponse payResponse = elegentPay.requestPay(request, TradeType.NATIVE, Platform.WX); - if (payResponse!=null){ - return payResponse.getCode_url(); - } - return null; - } - - @Override - public String queryPayList() { - paymentMapper.queryPayList(); - return null; - } - - @Override - public String getPaymentListByCaseId() { - return null; - } - - @Override - public String payConfirm() { - return null; - } -} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/dto/CasePayDTO.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/dto/CasePayDTO.java new file mode 100644 index 0000000..8f2f20d --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/dto/CasePayDTO.java @@ -0,0 +1,20 @@ +package com.ruoyi.wisdomarbitrate.domain.dto; + +import lombok.Data; + +/** + * 案件缴费传入参数 + */ +@Data +public class CasePayDTO { + private int totalFee; //订单金额 单位:分 + private String body;//商品描述 + /** + * 交易类型 native(扫码) / jsapi(小程序) / app / h5 + */ + private String tradeType; + /** + * 支付方式 wxpay(微信) alipay(支付宝) + */ + private String platform; +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/ICasePaymentService.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/ICasePaymentService.java new file mode 100644 index 0000000..fc2e24a --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/ICasePaymentService.java @@ -0,0 +1,15 @@ +package com.ruoyi.wisdomarbitrate.service; + +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.dto.PayRequest; +import com.ruoyi.wisdomarbitrate.domain.CaseApplication; +import com.ruoyi.wisdomarbitrate.domain.dto.CasePayDTO; + +public interface ICasePaymentService { + /** + * 案件缴费 + */ + AjaxResult casePay(CasePayDTO casePayDTO); + + AjaxResult confirmPayment(CaseApplication caseApplication); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CasePaymentServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CasePaymentServiceImpl.java new file mode 100644 index 0000000..598e979 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CasePaymentServiceImpl.java @@ -0,0 +1,48 @@ +package com.ruoyi.wisdomarbitrate.service.impl; + +import com.ruoyi.CallBackService; +import com.ruoyi.ElegentPay; +import com.ruoyi.common.constant.CaseApplicationConstants; +import com.ruoyi.common.core.domain.AjaxResult; + +import com.ruoyi.dto.PayRequest; +import com.ruoyi.dto.PayResponse; +import com.ruoyi.wisdomarbitrate.domain.CaseApplication; +import com.ruoyi.wisdomarbitrate.mapper.CaseApplicationMapper; +import com.ruoyi.wisdomarbitrate.service.ICasePaymentService; +import com.ruoyi.wisdomarbitrate.domain.dto.CasePayDTO; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class CasePaymentServiceImpl implements ICasePaymentService { + private final ElegentPay elegentPay; + private final CaseApplicationMapper caseApplicationMapper; + + @Autowired + public CasePaymentServiceImpl(ElegentPay elegentPay + , CaseApplicationMapper caseApplicationMapper) { + this.elegentPay = elegentPay; + this.caseApplicationMapper = caseApplicationMapper; + } + + @Override + public AjaxResult casePay(CasePayDTO casePayDTO) { + PayRequest payRequest = new PayRequest(); + payRequest.setBody(casePayDTO.getBody()); + payRequest.setOrderSn(System.currentTimeMillis() + ""); + payRequest.setTotalFee(casePayDTO.getTotalFee()); + PayResponse response = elegentPay.requestPay(payRequest, casePayDTO.getTradeType(), casePayDTO.getPlatform()); + return AjaxResult.success(response); + } + + @Override + public AjaxResult confirmPayment(CaseApplication caseApplication) { + caseApplication.setCaseStatus(CaseApplicationConstants.EVIDENCE_CONFREMED); + int i = caseApplicationMapper.updataCaseApplication(caseApplication); + if (i > 0) { + return AjaxResult.success(); + } + return AjaxResult.error("暂无需要确认的缴费清单"); + } +} diff --git a/ruoyi-system/src/main/resources/mapper/system/CasePaymentMapper.xml b/ruoyi-system/src/main/resources/mapper/system/CasePaymentMapper.xml deleted file mode 100644 index 6a77419..0000000 --- a/ruoyi-system/src/main/resources/mapper/system/CasePaymentMapper.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - \ No newline at end of file