StoreOrder.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\common\model\store\order;
  12. use app\common\model\BaseModel;
  13. use app\common\model\store\product\ProductGroupUser;
  14. use app\common\model\store\service\StoreService;
  15. use app\common\model\system\merchant\Merchant;
  16. use app\common\model\user\User;
  17. use app\common\repositories\store\MerchantTakeRepository;
  18. class StoreOrder extends BaseModel
  19. {
  20. public static function tablePk(): ?string
  21. {
  22. return 'order_id';
  23. }
  24. public static function tableName(): string
  25. {
  26. return 'store_order';
  27. }
  28. public function orderProduct()
  29. {
  30. return $this->hasMany(StoreOrderProduct::class, 'order_id', 'order_id');
  31. }
  32. public function refundProduct()
  33. {
  34. return $this->orderProduct()->where('refund_num', '>', 0);
  35. }
  36. public function merchant()
  37. {
  38. return $this->hasOne(Merchant::class, 'mer_id', 'mer_id');
  39. }
  40. public function user()
  41. {
  42. return $this->hasOne(User::class, 'uid', 'uid');
  43. }
  44. public function groupOrder()
  45. {
  46. return $this->hasOne(StoreGroupOrder::class, 'group_order_id', 'group_order_id');
  47. }
  48. public function verifyService()
  49. {
  50. return $this->hasOne(StoreService::class, 'service_id', 'verify_service_id');
  51. }
  52. public function getTakeAttr()
  53. {
  54. return app()->make(MerchantTakeRepository::class)->get($this->mer_id);
  55. }
  56. public function searchDataAttr($query, $value)
  57. {
  58. return getModelTime($query, $value);
  59. }
  60. public function presellOrder()
  61. {
  62. return $this->hasOne(PresellOrder::class, 'order_id', 'order_id');
  63. }
  64. public function finalOrder()
  65. {
  66. return $this->hasOne(PresellOrder::class,'order_id','order_id');
  67. }
  68. public function groupUser()
  69. {
  70. return $this->hasOne(ProductGroupUser::class,'order_id','order_id');
  71. }
  72. }