| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- declare(strict_types=1);
- namespace app\common\model;
- use think\Model;
- class ShopDelivery Extends Model
- {
- // 自动写入时间戳字段
- protected $autoWriteTimestamp = true;
- protected $createTime = 'createtime';
- protected $updateTime = 'updatetime';
- protected $type = [
- 'createtime' => 'timestamp:Y-m-d H:i',
- 'updatetime' => 'timestamp:Y-m-d H:i',
- ];
- const StatusNormal = 1;
- const StatusSettlement = 2;
- const StatusRefund = 3;
- //待结算金额
- public static function getPendingSettlementAmount()
- {
- return self::where('status', self::StatusNormal)->sum('total_price');
- }
- //id,name
- public function user()
- {
- return $this->hasOne(User::class,'id','user_id')->field('id,nickname');
- }
- public function customer()
- {
- return $this->hasOne(Customer::class,'id','customer_id')->field('id,name');
- }
-
- public function shops()
- {
- return $this->hasOne(ShopList::class,'id','shop_id')->field('id,name');
- }
-
- public function variety()
- {
- return $this->hasOne(StockConfig::class,'id','variety_id')->field('id,title');
- }
-
- public function specs()
- {
- return $this->hasOne(ProductConfig::class,'id','spec_id')->field('id,title');
- }
-
-
- }
|