StoreOrderStatus.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. /**
  3. *
  4. * @author: xaboy<365615158@qq.com>
  5. * @day: 2017/12/28
  6. */
  7. namespace app\models\store;
  8. use crmeb\basic\BaseModel;
  9. use crmeb\traits\ModelTrait;
  10. /**
  11. * TODO 订单修改状态记录Model
  12. * Class StoreOrderStatus
  13. * @package app\models\store
  14. */
  15. class StoreOrderStatus extends BaseModel
  16. {
  17. /**
  18. * 模型名称
  19. * @var string
  20. */
  21. protected $name = 'store_order_status';
  22. use ModelTrait;
  23. /**
  24. * 格式化时间
  25. * @param $name
  26. * @return false|string
  27. */
  28. public function getChangeTimeAttr($name)
  29. {
  30. return date('Y-m-d H:i:s',$name);
  31. }
  32. /**
  33. * 更新订单状态
  34. * @param $oid
  35. * @param $change_type
  36. * @param $change_message
  37. * @param null $change_time
  38. * @return StoreOrderStatus|\think\Model
  39. */
  40. public static function status($oid,$change_type,$change_message,$change_time = null)
  41. {
  42. if($change_time == null) $change_time = time();
  43. return self::create(compact('oid','change_type','change_message','change_time'));
  44. }
  45. /**
  46. * status 方法别名
  47. * @param $oid
  48. * @param $change_type
  49. * @param $change_message
  50. * @param null $change_time
  51. * @return StoreOrderStatus|\think\Model
  52. */
  53. public static function setStatus($oid,$change_type,$change_message,$change_time = null)
  54. {
  55. return self::status($oid,$change_type,$change_message,$change_time);
  56. }
  57. /**
  58. * @param $oid
  59. * @param $change_type
  60. * @return mixed
  61. */
  62. public static function getTime($oid,$change_type)
  63. {
  64. return self::where('oid',$oid)->where('change_type',$change_type)->value('change_time');
  65. }
  66. /**
  67. * 获取订单状态列表
  68. * @param $id
  69. * @param $page
  70. * @param $limit
  71. * @return array
  72. */
  73. public static function getOrderList($id,$page,$limit)
  74. {
  75. $list = self::where('oid',$id)->page($page,$limit)->select();
  76. return $list ? $list->toArray() : [];
  77. }
  78. }