ShopDelivery.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. declare(strict_types=1);
  3. namespace app\common\model;
  4. use think\Model;
  5. class ShopDelivery Extends Model
  6. {
  7. // 自动写入时间戳字段
  8. protected $autoWriteTimestamp = true;
  9. protected $createTime = 'createtime';
  10. protected $updateTime = 'updatetime';
  11. protected $type = [
  12. 'createtime' => 'timestamp:Y-m-d H:i',
  13. 'updatetime' => 'timestamp:Y-m-d H:i',
  14. ];
  15. const StatusNormal = 1;
  16. const StatusSettlement = 2;
  17. const StatusRefund = 3;
  18. //待结算金额
  19. public static function getPendingSettlementAmount()
  20. {
  21. return self::where('status', self::StatusNormal)->sum('total_price');
  22. }
  23. //id,name
  24. public function user()
  25. {
  26. return $this->hasOne(User::class,'id','user_id')->field('id,nickname');
  27. }
  28. public function customer()
  29. {
  30. return $this->hasOne(Customer::class,'id','customer_id')->field('id,name');
  31. }
  32. public function shops()
  33. {
  34. return $this->hasOne(ShopList::class,'id','shop_id')->field('id,name');
  35. }
  36. public function variety()
  37. {
  38. return $this->hasOne(StockConfig::class,'id','variety_id')->field('id,title');
  39. }
  40. public function specs()
  41. {
  42. return $this->hasOne(ProductConfig::class,'id','spec_id')->field('id,title');
  43. }
  44. }