| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- <?php
- namespace app\common\model;
- use app\common\model\ShopOrderGoodsModel as OrderGoods;
- use app\common\model\ShopOrderShippingModel as OrderShipping;
- use app\common\model\TimeModel;
- class ShopOrder extends TimeModel
- {
- protected $name = "shop_order";
- protected $deleteTime = false;
- public function user ()
- {
- return $this->belongsTo('user', 'user_id', 'id');
- }
- public function goods ()
- {
- return $this->hasMany('shopOrderGoods', 'order_id', 'order_id')
- ->withAttr('goods_img',function($value){
- return getPreviewUrl($value);
- });
- }
- public function shipping ()
- {
- return $this->hasOne('shopOrderShipping', 'order_id', 'order_id');
- }
- /**
- * @return \think\model\relation\HasMany
- * 关联订单商品
- */
- public function withOrderGoods ()
- {
- 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')
- ->withAttr('goods_img', function($value){
- return getPreviewUrl($value);
- });
- }
- /**
- * @return \think\model\relation\HasOne
- * 关联订单配送
- */
- public function withOrderShipping ()
- {
- return self::hasOne(OrderShipping::class, 'order_id', 'order_id')->field('sp_name,sp_mobile,sp_province,sp_city,sp_county,sp_remark,sp_mergename');
- }
- }
|