WxappPrepayId.php 885 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace app\api\model;
  3. use app\common\model\WxappPrepayId as WxappPrepayIdModel;
  4. use app\common\enum\OrderType as OrderTypeEnum;
  5. /**
  6. * 小程序prepay_id模型
  7. * Class WxappPrepayId
  8. * @package app\api\model
  9. */
  10. class WxappPrepayId extends WxappPrepayIdModel
  11. {
  12. /**
  13. * 新增记录
  14. * @param $prepayId
  15. * @param $orderId
  16. * @param $userId
  17. * @param int $orderType
  18. * @return false|int
  19. */
  20. public function add($prepayId, $orderId, $userId, $orderType = OrderTypeEnum::MASTER)
  21. {
  22. return $this->save([
  23. 'prepay_id' => $prepayId,
  24. 'order_id' => $orderId,
  25. 'order_type' => $orderType,
  26. 'user_id' => $userId,
  27. 'can_use_times' => 0,
  28. 'used_times' => 0,
  29. 'expiry_time' => time() + (7 * 86400),
  30. 'wxapp_id' => self::$wxapp_id,
  31. ]);
  32. }
  33. }