VoucherPaymentService.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. namespace app\data\service\payment;
  3. use app\data\model\ShopOrder;
  4. use app\data\service\PaymentService;
  5. use think\admin\Exception;
  6. use think\admin\extend\CodeExtend;
  7. /**
  8. * 单据凭证支付
  9. * Class VoucherPaymentService
  10. * @package app\data\service\payment
  11. */
  12. class VoucherPaymentService extends PaymentService
  13. {
  14. /**
  15. * 订单数据查询
  16. * @param string $orderNo
  17. * @return array
  18. */
  19. public function query(string $orderNo): array
  20. {
  21. return [];
  22. }
  23. /**
  24. * 支付通知处理
  25. * @return string
  26. */
  27. public function notify(): string
  28. {
  29. return 'success';
  30. }
  31. /**
  32. * 创建订单支付参数
  33. * @param string $openid 用户OPENID
  34. * @param string $orderNo 交易订单单号
  35. * @param string $payAmount 交易订单金额(元)
  36. * @param string $payTitle 交易订单名称
  37. * @param string $payRemark 订单订单描述
  38. * @param string $payReturn 完成回跳地址
  39. * @param string $payImage 支付凭证图片
  40. * @return array
  41. * @throws \think\admin\Exception
  42. * @throws \think\db\exception\DataNotFoundException
  43. * @throws \think\db\exception\DbException
  44. * @throws \think\db\exception\ModelNotFoundException
  45. */
  46. public function create(string $openid, string $orderNo, string $payAmount, string $payTitle, string $payRemark, string $payReturn = '', string $payImage = ''): array
  47. {
  48. $order = ShopOrder::mk()->where(['order_no' => $orderNo])->find();
  49. if (empty($order)) throw new Exception("订单不存在");
  50. if ($order['status'] !== 2) throw new Exception("不可发起支付");
  51. if (empty($payImage)) throw new Exception('支付凭证不能为空');
  52. $this->updatePaymentOrder($orderNo, CodeExtend::uniqidDate(20), $payAmount, '单据凭证支付', $payImage);
  53. return ['code' => 1, 'info' => '支付凭证上传成功!'];
  54. }
  55. }