AllwinInfoOrder.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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\allwin\model;
  9. use think\Model;
  10. class AllwinInfoOrder extends Model{
  11. protected $pk = 'id';
  12. /**
  13. * @return \think\model\relation\HasOne
  14. * 商品
  15. */
  16. public function info(){
  17. return $this->hasOne('AllwinInfo','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. 'member_miniapp_id' => $param['member_miniapp_id'],
  36. 'phone' => $param['telphone'],
  37. 'message' => $param['message'],
  38. 'uid' => $param['uid'],
  39. 'amount' => $param['amount'],
  40. 'cache' => $param['cache'],
  41. 'fields' => $param['fields'],
  42. 'status' => 0,
  43. 'is_del' => 0,
  44. 'paid_at' => 0,
  45. 'create_time' => time()
  46. ];
  47. return self::create($order);
  48. }
  49. }