package com.ygj.yuemum.controller.pay; import com.google.zxing.WriterException; import com.ygj.yuemum.domain.pay.CustomerPay; import com.ygj.yuemum.service.pay.CustomerPayService; import io.swagger.annotations.Api; import io.swagger.models.auth.In; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import javax.swing.plaf.IconUIResource; import java.awt.image.BufferedImage; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; import java.util.Map; @Api(tags = "支付订单相关接口") @RestController public class CustomerPayController { @Autowired private CustomerPayService customerPayService; @GetMapping("/selectCustomerPay") public List selectCustomerPay(@RequestParam("cp_orderno") String cp_orderno) { List customerPays = customerPayService.selectCustomerPay(cp_orderno); return customerPays; } @GetMapping("/queryCustomerPayAndVoucher") public List queryCustomerPayAndVoucher(@RequestParam("cp_orderno") String cp_orderno) { return customerPayService.queryCustomerPayAndVoucher(cp_orderno); } @PostMapping("/queryYSOrderPay") public CustomerPay queryYSOrderPay(@ModelAttribute CustomerPay customerPay){ return customerPayService.queryYSOrderPay(customerPay); } @PostMapping("/insertCustomerPay") public int insertCustomerPay(@ModelAttribute CustomerPay customerPay) { return customerPayService.insertCustomerPay(customerPay); } @PostMapping("/insertYsOrderPay") public int insertYsOrderPay(@ModelAttribute CustomerPay customerPay) { return customerPayService.insertYsOrderPay(customerPay); } @PostMapping("/checkCustomerPay") public int checkCustomerPay(@ModelAttribute CustomerPay customerPay) { return customerPayService.checkCustomerPay(customerPay); } @RequestMapping(value = "/WxPayReturn", method = RequestMethod.POST, produces = "application/json;charset=UTF-8") @ResponseBody public int WxPayReturn(@RequestBody Map params) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); CustomerPay customerPay = new CustomerPay(); String orderNo[] = params.get("orderNo").split("SEQ"); customerPay.setCp_orderno(orderNo[0]); customerPay.setCp_date(simpleDateFormat.format(new Date())); customerPay.setCp_orderstatus(2); customerPay.setCp_ordertype(2); customerPay.setOut_trade_no(params.get("orderNo")); if (params.get("payType").equals("alipay")) { customerPay.setCp_paytype("2"); } else if (params.get("payType").equals("wx")) { customerPay.setCp_paytype("1"); } else { return 0; } customerPay.setPayment_steps(Integer.parseInt(orderNo[1])); customerPay.setCp_payamount(Double.parseDouble(params.get("totalFee"))); return customerPayService.insertYsOrderPay(customerPay); } }