| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <?php
- // +----------------------------------------------------------------------
- // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
- // +----------------------------------------------------------------------
- // | 版权所有 2017~2021 LARAVEL研发中心
- // +----------------------------------------------------------------------
- // | 官方网站: http://www.laravel.cn
- // +----------------------------------------------------------------------
- // | Author: laravel开发员 <laravel.qq.com>
- // +----------------------------------------------------------------------
- namespace App\Models;
- /**
- * 订单管理-模型
- * @author laravel开发员
- * @since 2020/11/11
- * @package App\Models
- */
- class OrderModel extends BaseModel
- {
- // 设置数据表
- protected $table = 'orders';
- // 发票
- public function getTicketImgAttribute($value)
- {
- $value = $value ? get_image_url($value) : '';
- return $value;
- }
- public function setTicketImgAttribute($value)
- {
- return $value ? get_image_path($value) : '';
- }
- /**
- * 下单用户
- * @return \Illuminate\Database\Eloquent\Relations\HasOne
- */
- public function user()
- {
- return $this->hasOne(MemberModel::class, 'id', 'user_id')
- ->select(['id','openid', 'mobile', 'nickname','balance', 'realname', 'status']);
- }
- /**
- * 订单商品关联
- * 通过 order_no 字段关联订单商品表
- * @return \Illuminate\Database\Eloquent\Relations\HasMany
- */
- public function orderGoods()
- {
- return $this->hasMany(OrderGoodsModel::class, 'order_no', 'order_no')
- ->with(['category'])
- ->leftJoin('goods_skus as b','b.id','=','orders_goods.sku_id')
- ->where('orders_goods.mark', 1)->select(['orders_goods.*','b.sku_name']);
- }
- /**
- * 店铺
- * @return \Illuminate\Database\Eloquent\Relations\HasOne
- */
- public function store()
- {
- return $this->hasOne(StoreModel::class, 'id', 'store_id')
- ->select(['id', 'nickname as name', 'avatar as logo']);
- }
- /**
- * 关联会议
- * @return \Illuminate\Database\Eloquent\Relations\HasOne
- */
- public function meeting()
- {
- return $this->hasOne(MeetingModel::class, 'id', 'meeting_id')
- ->select(['id', 'title', 'thumb','company','bonus_rate']);
- }
- /**
- * 经手人
- * @return \Illuminate\Database\Eloquent\Relations\HasOne
- */
- public function adminUser()
- {
- return $this->hasOne(UserModel::class, 'id', 'confirm_admin_id')
- ->select(['id', 'nickname', 'mobile', 'realname', 'status']);
- }
- /**
- * 已审核
- * @return \Illuminate\Database\Eloquent\Relations\HasOne
- */
- public function confirm()
- {
- return $this->hasOne(OrderModel::class, 'goods_id', 'goods_id')
- ->with(['user'])
- ->whereIn('status', [2, 3])
- ->where(['mark' => 1])
- ->select(['id', 'order_no', 'goods_id', 'confirm_at', 'status']);
- }
- }
|