OrderArousePayAbstract.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace App\Modules\Trade\Pay;
  3. use App\Modules\Subscribe\Models\Order;
  4. abstract class OrderArousePayAbstract
  5. {
  6. /**
  7. * 唤起支付
  8. */
  9. abstract public function arouse(array $data);
  10. protected $uid;
  11. public function __construct(int $uid)
  12. {
  13. $this->uid = $uid;
  14. }
  15. public function handle(array $data)
  16. {
  17. $this->createOrder($data);
  18. return $this->arouse($data);
  19. }
  20. public function createOrder(array $data)
  21. {
  22. $params = [
  23. 'uid' => $this->uid,
  24. 'product_id' => $data['product_id'],
  25. 'distribution_channel_id' => $data['distribution_channel_id'],
  26. 'trade_no' => $data['trade_no'],
  27. 'pay_merchant_id' => isset($data['pay_merchant_id']) ? $data['pay_merchant_id'] : 0,
  28. 'order_type' => $data['order_type'],
  29. 'create_ip' => $data['create_ip'],
  30. 'send_order_id' => $data['send_order_id'],
  31. 'from_type' => $data['from_type'],
  32. 'price' => $data['price'] / 100,
  33. 'status' => 'UNPAID',
  34. 'transaction_id' => '',
  35. 'pay_end_at' => '0000-00-00 00:00:00',
  36. 'pay_merchant_source' => '',
  37. 'send_order_name' => isset($data['send_order_name']) ? $data['send_order_name'] : '',
  38. 'pay_type' => isset($data['pay_type']) ? $data['pay_type'] : 1,
  39. 'from_bid' => isset($data['from_bid']) ? $data['from_bid'] : 0,
  40. 'activity_id' => isset($data['activity_id']) ? $data['activity_id'] : 0,
  41. 'inner_send_order_id' => isset($data['inner_send_order_id']) ? $data['inner_send_order_id'] : '',
  42. ];
  43. Order::firstOrCreate($params);
  44. }
  45. }