SaasGoods.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace app\model\saas;
  3. use app\extra\basic\Model;
  4. use think\model\relation\HasOne;
  5. /**
  6. * @property integer $id (主键)
  7. * @property integer $store_id 来客账户id
  8. * @property integer $agent_id 代理id
  9. * @property integer $product_id
  10. * @property string $product_name
  11. * @property string $express_name 面单打印名称
  12. * @property string $product_img
  13. * @property integer $product_price
  14. * @property integer $product_orgin 划线价
  15. * @property integer $out_id 来客商品ID
  16. * @property integer $status
  17. * @property mixed $create_at
  18. */
  19. class SaasGoods extends Model
  20. {
  21. /**
  22. * The connection name for the model.
  23. *
  24. * @var string|null
  25. */
  26. protected $connection = 'mysql';
  27. /**
  28. * The table associated with the model.
  29. *
  30. * @var string
  31. */
  32. protected string $table = "saas_goods";
  33. /**
  34. * The primary key associated with the table.
  35. *
  36. * @var string
  37. */
  38. protected string $primaryKey = "id";
  39. /**
  40. * Indicates if the model should be timestamped.
  41. *
  42. * @var bool
  43. */
  44. public bool $timestamps = false;
  45. public function getProductPriceAttr($data): string
  46. {
  47. if ($data == 0) return 0;
  48. return format_money($data/100);
  49. }
  50. public function getProductOriginAttr($data): string
  51. {
  52. if ($data == 0) return 0;
  53. return format_money($data/100);
  54. }
  55. public function agent(): HasOne
  56. {
  57. return $this->hasOne("app\model\saas\SaasAgent","agent_id","agent_id");
  58. }
  59. public function store(): HasOne
  60. {
  61. return $this->hasOne("app\model\saas\SaasStore","store_id","store_id");
  62. }
  63. public function print(): HasOne
  64. {
  65. return $this->hasOne("app\model\saas\SaasPrint","sn","print_id");
  66. }
  67. }