AisInfoOrder.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2017 https://www.sapixx.com All rights reserved.
  4. * @license Licensed (http://www.apache.org/licenses/LICENSE-2.0).
  5. * @author pillar<ltmn@qq.com>
  6. * 订单数据
  7. */
  8. namespace app\ais\model;
  9. use think\Model;
  10. class AisInfoOrder extends Model{
  11. protected $pk = 'id';
  12. /**
  13. * @return \think\model\relation\HasOne
  14. * 商品
  15. */
  16. public function info(){
  17. return $this->hasOne('AisInfo','id','info_id');
  18. }
  19. /**
  20. * @return \think\model\relation\HasOne
  21. * 用户
  22. */
  23. public function user(){
  24. return $this->hasOne('app\common\model\SystemUser','id','uid');
  25. }
  26. /**
  27. * @param $data
  28. * @param $order_no
  29. * 购买商品生成订单数据
  30. */
  31. public static function insertOrder($param,$order_no){
  32. $order = [
  33. 'order_no' => $order_no,
  34. 'info_id' => $param['id'],
  35. 'info_uid' => $param['info_uid'],
  36. 'member_miniapp_id' => $param['member_miniapp_id'],
  37. 'phone' => $param['telphone'],
  38. 'message' => $param['message'],
  39. 'uid' => $param['uid'],
  40. 'amount' => $param['amount'],
  41. 'cache' => $param['cache'],
  42. 'fields' => $param['fields'],
  43. 'status' => 0,
  44. 'is_del' => 0,
  45. 'paid_at' => 0,
  46. 'create_time' => time()
  47. ];
  48. return self::create($order);
  49. }
  50. }