StoreOrderReceipt.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2024 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\system\merchant\Merchant;
  14. use app\common\model\user\User;
  15. class StoreOrderReceipt extends BaseModel
  16. {
  17. public static function tablePk(): ?string
  18. {
  19. return 'order_receipt_id';
  20. }
  21. public static function tableName(): string
  22. {
  23. return 'store_order_receipt';
  24. }
  25. public function getReceiptInfoAttr($value)
  26. {
  27. return json_decode($value);
  28. }
  29. public function getDeliveryInfoAttr($value)
  30. {
  31. return json_decode($value);
  32. }
  33. public function storeOrder()
  34. {
  35. return $this->hasOne(StoreOrder::class,'order_id','order_id');
  36. }
  37. public function user()
  38. {
  39. return $this->hasOne(User::class,'uid','uid');
  40. }
  41. public function merchant()
  42. {
  43. return $this->hasOne(Merchant::class,'mer_id','mer_id');
  44. }
  45. public function searchOrderReceiptIdsAttr($query,$value)
  46. {
  47. $query->whereIn('order_receipt_id',$value);
  48. }
  49. public function searchMerIdAttr($query,$value)
  50. {
  51. $query->where('mer_id',$value);
  52. }
  53. public function searchOrderReceiptIdAttr($query,$value)
  54. {
  55. $query->where('order_receipt_id',$value);
  56. }
  57. }