ShopOrder.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace app\common\model;
  3. use app\common\model\ShopOrderGoodsModel as OrderGoods;
  4. use app\common\model\ShopOrderShippingModel as OrderShipping;
  5. use app\common\model\TimeModel;
  6. class ShopOrder extends TimeModel
  7. {
  8. protected $name = "shop_order";
  9. protected $deleteTime = false;
  10. public function user ()
  11. {
  12. return $this->belongsTo('user', 'user_id', 'id');
  13. }
  14. public function goods ()
  15. {
  16. return $this->hasMany('shopOrderGoods', 'order_id', 'order_id');
  17. }
  18. public function shipping ()
  19. {
  20. return $this->hasOne('shopOrderShipping', 'order_id', 'order_id');
  21. }
  22. /**
  23. * @return \think\model\relation\HasMany
  24. * 关联订单商品
  25. */
  26. public function withOrderGoods ()
  27. {
  28. return self::hasMany(OrderGoods::class, 'order_id', 'order_id')->field('goods_name,goods_id,goods_img,num,price,total_fee,spec_text,goods_spec_id');
  29. }
  30. /**
  31. * @return \think\model\relation\HasOne
  32. * 关联订单配送
  33. */
  34. public function withOrderShipping ()
  35. {
  36. return self::hasOne(OrderShipping::class, 'order_id', 'order_id')->field('sp_name,sp_mobile,sp_province,sp_city,sp_county,sp_remark,sp_mergename');
  37. }
  38. }