PreOrderCoupon.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: shenyang
  5. * Date: 2018/12/25
  6. * Time: 9:15 PM
  7. */
  8. namespace app\common\modules\coupon\models;
  9. use app\common\models\Coupon;
  10. use app\common\models\Order;
  11. use app\common\models\order\OrderCoupon;
  12. class PreOrderCoupon extends OrderCoupon
  13. {
  14. /**
  15. * @var
  16. */
  17. private $amoutCalculator;
  18. /**
  19. * @var
  20. */
  21. private $useScope;
  22. /**
  23. * @var
  24. */
  25. private $timeLimit;
  26. /**
  27. * @var Order
  28. */
  29. private $order;
  30. /**
  31. * @var Coupon
  32. */
  33. private $coupon;
  34. public function init(Order $order, Coupon $coupon)
  35. {
  36. $this->order = $order;
  37. $this->coupon = $coupon;
  38. $this->initAttributes();
  39. }
  40. protected function initAttributes()
  41. {
  42. [
  43. 'amount' => $this->getAmount(),
  44. 'order_id' => $this->order->id,
  45. 'coupon_id' => $this->coupon->id,
  46. 'amount' => $this->getAmount(),
  47. ];
  48. }
  49. public function getAmount()
  50. {
  51. return 100;
  52. }
  53. }