BookOrderPaySuccess.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace App\Modules\Trade\Pay;
  3. use App\Modules\Book\Models\BookConfig;
  4. use App\Modules\Subscribe\Models\BookOrder;
  5. use App\Modules\Subscribe\Models\Order;
  6. class BookOrderPaySuccess extends PaySuccessAbstract
  7. {
  8. private $book_config;
  9. public function __construct(Order $order)
  10. {
  11. parent::__construct($order);
  12. $this->book_config = $this->getBookByProduct($order->product_id);
  13. }
  14. private function getBookByProduct($product_id)
  15. {
  16. return BookConfig::where('product_id', $product_id)->first();
  17. }
  18. protected function handlePayProcess()
  19. {
  20. $book_order = [];
  21. $book_order['bid'] = isset($this->book_config->bid) ? $this->book_config->bid : '';
  22. $book_order['book_name'] = isset($this->book_config->book_name) ? $this->book_config->book_name : '';
  23. $book_order['uid'] = $this->order->uid;
  24. $book_order['distribution_channel_id'] = $this->order->distribution_channel_id;
  25. $book_order['fee'] = $this->order->price;
  26. $book_order['send_order_id'] = $this->order->send_order_id;
  27. return BookOrder::firstOrCreate($book_order);
  28. }
  29. }