SaasOrder.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. namespace app\model\saas;
  3. use app\extra\basic\Model;
  4. use app\extra\tools\SceneData;
  5. use think\model\relation\HasOne;
  6. /**
  7. * @property integer $id (主键)
  8. * @property mixed $order_sn
  9. * @property mixed $openid
  10. * @property mixed $product_id
  11. * @property mixed $sku_id
  12. * @property integer $number
  13. * @property string $img
  14. * @property integer $price
  15. * @property integer $line_price
  16. * @property string $sku_name
  17. * @property mixed $poi_id
  18. * @property mixed $mobile
  19. */
  20. class SaasOrder extends Model
  21. {
  22. /**
  23. * The connection name for the model.
  24. *
  25. * @var string|null
  26. */
  27. protected $connection = 'mysql';
  28. /**
  29. * The table associated with the model.
  30. *
  31. * @var string
  32. */
  33. protected string $table = "saas_order";
  34. /**
  35. * The primary key associated with the table.
  36. *
  37. * @var string
  38. */
  39. protected string $primaryKey = "id";
  40. /**
  41. * Indicates if the model should be timestamped.
  42. *
  43. * @var bool
  44. */
  45. public bool $timestamps = false;
  46. public function getSceneAttr($value)
  47. {
  48. return (new SceneData)->getScene($value);
  49. }
  50. public function getLifeFeeAttr($value,$data): string
  51. {
  52. return $data['sys_fee']+$value;
  53. }
  54. public function product(): HasOne
  55. {
  56. return $this->hasOne(SaasGoods::class,"product_id","product_id");
  57. }
  58. public function poi(): HasOne
  59. {
  60. return $this->hasOne(SaasStore::class,"poi_id","poi_id");
  61. }
  62. public function user(): HasOne
  63. {
  64. return $this->hasOne(SaasUserOpen::class,"openid","openid");
  65. }
  66. public function address(): HasOne
  67. {
  68. return $this->hasOne(SaasOrderAddress::class,"order_sn","out_order_no");
  69. }
  70. public function express(): HasOne
  71. {
  72. return $this->hasOne(SaasOrderExpress::class,"order_sn","order_sn");
  73. }
  74. public function star(): HasOne
  75. {
  76. return $this->hasOne(SaasStar::class,"unique_id","douyin_uid");
  77. }
  78. }