PayServiceImpl.java 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package com.keao.edu.user.service.impl;
  2. import com.keao.edu.common.exception.BizException;
  3. import com.keao.edu.thirdparty.adapay.Payment;
  4. import com.keao.edu.thirdparty.yqpay.YqPayUtil;
  5. import com.keao.edu.user.dao.SysConfigDao;
  6. import com.keao.edu.user.service.PayService;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.stereotype.Service;
  9. import java.math.BigDecimal;
  10. import java.util.*;
  11. /**
  12. * 支付服务类
  13. */
  14. @Service
  15. public class PayServiceImpl implements PayService {
  16. @Autowired
  17. private SysConfigDao sysConfigDao;
  18. /**
  19. * 返回订单提交数据
  20. *
  21. * @param amount 金额
  22. * @param orderNo 订单编号
  23. * @param notifyUrl 异步通知地址
  24. * @param returnUrl 支付返回地址
  25. * @param orderSubject 订单标题
  26. * @param orderBody 订单内容
  27. * @return
  28. * @throws Exception
  29. */
  30. @Override
  31. public Map<String, Object> getPayMap(BigDecimal amount, String orderNo, String notifyUrl, String returnUrl, String orderSubject, String orderBody) throws Exception {
  32. //支付通道决策
  33. Map<String, Object> unionPay = new HashMap<>();
  34. Map<String, Object> payMap = null;
  35. String type = null;
  36. String routingMerNos = null;
  37. String paymentChannel = sysConfigDao.findConfigValue("payment_channel");
  38. if (paymentChannel.equals("YQPAY")) {
  39. payMap = YqPayUtil.getPayMap(amount, orderNo, notifyUrl, returnUrl, orderSubject, orderBody);
  40. type = "YQPAY";
  41. routingMerNos = (String) payMap.get("merNo");
  42. } else if (paymentChannel.equals("ADAPAY")) {
  43. payMap = Payment.getPayMap(amount, orderNo, notifyUrl, returnUrl, orderSubject, orderBody);
  44. type = "ADAPAY";
  45. routingMerNos = Payment.merNo;
  46. } else {
  47. throw new BizException("收款渠道配置错误");
  48. }
  49. unionPay.put("orderNo", orderNo);
  50. unionPay.put("type", type);
  51. unionPay.put("payMap", payMap);
  52. unionPay.put("routingMerNos", routingMerNos);
  53. return unionPay;
  54. }
  55. }