MallOrder.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace app\common\model;
  3. use think\Model;
  4. use think\model\concern\SoftDelete;
  5. class MallOrder extends Model
  6. {
  7. // 设置字段信息
  8. protected $schema = [
  9. 'id' => 'int',
  10. 'userid' => 'int',
  11. 'ordersn' => 'string',
  12. 'goodsid' => 'int',
  13. 'title' => 'string',
  14. 'tilpic' => 'string',
  15. 'gintegral' => 'int',
  16. 'gpaymoney' => 'float',
  17. 'buynumber' => 'int',
  18. 'integral' => 'int',
  19. 'paymoney' => 'float',
  20. 'payinfo' => 'string',
  21. 'status' => 'tinyint',
  22. 'username' => 'string',
  23. 'usermobile' => 'string',
  24. 'province' => 'string',
  25. 'city' => 'string',
  26. 'county' => 'string',
  27. 'detailinfo' => 'string',
  28. 'remark' => 'string',
  29. 'createtime' => 'int',
  30. 'deletetime' => 'int'
  31. ];
  32. use SoftDelete;
  33. protected $deleteTime = 'deletetime';
  34. protected $defaultSoftDelete = 0;
  35. // 设置字段自动转换类型
  36. protected $type = [
  37. 'payinfo' => 'json',
  38. 'createtime' => 'timestamp:Y-m-d H:i:s',
  39. 'deletetime' => 'timestamp:Y-m-d H:i:s'
  40. ];
  41. // 设置JSON数据返回数组
  42. protected $jsonAssoc = true;
  43. public function getStatusTextAttr($value,$data)
  44. {
  45. $status = [1=>'已取消', 2=>'已扣分', 3=>'已支付', 4=>'已完成', 5=>'已退单'];
  46. return $status[$data['status']];
  47. }
  48. // 关联User
  49. public function user()
  50. {
  51. return $this->hasOne(User::class, "id", "userid");
  52. }
  53. // 关联MallGoods
  54. public function mallGoods()
  55. {
  56. return $this->hasOne(MallGoods::class, "id", "goodsid");
  57. }
  58. }