CustomerPayController.java 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. package com.ygj.yuemum.controller.pay;
  2. import com.google.zxing.WriterException;
  3. import com.ygj.yuemum.domain.pay.CustomerPay;
  4. import com.ygj.yuemum.service.pay.CustomerPayService;
  5. import io.swagger.annotations.Api;
  6. import io.swagger.models.auth.In;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.web.bind.annotation.*;
  9. import javax.servlet.http.HttpServletRequest;
  10. import javax.swing.plaf.IconUIResource;
  11. import java.awt.image.BufferedImage;
  12. import java.io.ByteArrayOutputStream;
  13. import java.io.IOException;
  14. import java.text.SimpleDateFormat;
  15. import java.util.Date;
  16. import java.util.List;
  17. import java.util.Map;
  18. @Api(tags = "支付订单相关接口")
  19. @RestController
  20. public class CustomerPayController {
  21. @Autowired
  22. private CustomerPayService customerPayService;
  23. @GetMapping("/selectCustomerPay")
  24. public List<CustomerPay> selectCustomerPay(@RequestParam("cp_orderno") String cp_orderno) {
  25. List<CustomerPay> customerPays = customerPayService.selectCustomerPay(cp_orderno);
  26. return customerPays;
  27. }
  28. @GetMapping("/queryCustomerPayAndVoucher")
  29. public List<CustomerPay> queryCustomerPayAndVoucher(@RequestParam("cp_orderno") String cp_orderno) {
  30. return customerPayService.queryCustomerPayAndVoucher(cp_orderno);
  31. }
  32. @PostMapping("/queryYSOrderPay")
  33. public CustomerPay queryYSOrderPay(@ModelAttribute CustomerPay customerPay){
  34. return customerPayService.queryYSOrderPay(customerPay);
  35. }
  36. @PostMapping("/insertCustomerPay")
  37. public int insertCustomerPay(@ModelAttribute CustomerPay customerPay) {
  38. return customerPayService.insertCustomerPay(customerPay);
  39. }
  40. @PostMapping("/insertYsOrderPay")
  41. public int insertYsOrderPay(@ModelAttribute CustomerPay customerPay) {
  42. return customerPayService.insertYsOrderPay(customerPay);
  43. }
  44. @PostMapping("/checkCustomerPay")
  45. public int checkCustomerPay(@ModelAttribute CustomerPay customerPay) {
  46. return customerPayService.checkCustomerPay(customerPay);
  47. }
  48. @RequestMapping(value = "/WxPayReturn", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
  49. @ResponseBody
  50. public int WxPayReturn(@RequestBody Map<String, String> params) {
  51. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  52. CustomerPay customerPay = new CustomerPay();
  53. String orderNo[] = params.get("orderNo").split("SEQ");
  54. customerPay.setCp_orderno(orderNo[0]);
  55. customerPay.setCp_date(simpleDateFormat.format(new Date()));
  56. customerPay.setCp_orderstatus(2);
  57. customerPay.setCp_ordertype(2);
  58. customerPay.setOut_trade_no(params.get("orderNo"));
  59. if (params.get("payType").equals("alipay")) {
  60. customerPay.setCp_paytype("2");
  61. } else if (params.get("payType").equals("wx")) {
  62. customerPay.setCp_paytype("1");
  63. } else {
  64. return 0;
  65. }
  66. customerPay.setPayment_steps(Integer.parseInt(orderNo[1]));
  67. customerPay.setCp_payamount(Double.parseDouble(params.get("totalFee")));
  68. return customerPayService.insertYsOrderPay(customerPay);
  69. }
  70. }