SmsRemind.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: 萤火科技 <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types = 1);
  12. namespace app\common\model;
  13. /**
  14. * 短信提醒模板
  15. * Class Delivery
  16. * @package app\common\model
  17. */
  18. class SmsRemind extends BaseModel
  19. {
  20. const FTYPE = [1=>'已下单待发货'];
  21. // 定义表名
  22. protected $name = 'sms_remind';
  23. protected $append = ['ftype_text','hours_text'];
  24. public function getFtypeTextAttr(){
  25. return SELF::FTYPE[$this->ftype]??'';
  26. }
  27. public function getHoursTextAttr(){
  28. $arr = explode(',', $this->hours);
  29. $newarr = [];
  30. foreach($arr as $r){
  31. $newarr[] = $r.":00";
  32. }
  33. return implode(",",$newarr);
  34. }
  35. // 定义主键
  36. protected $pk = 'id';
  37. //添加记录历史
  38. public function add($data){
  39. $his = [
  40. "create_time"=>time(),
  41. "update_time"=>time()
  42. ];
  43. $his = array_merge($his,$data);
  44. SmsRemind::create($his);
  45. return true;
  46. }
  47. public function getList(array $param = []){
  48. // 查询列表数据
  49. return $this->with([])->paginate(15);
  50. }
  51. /**
  52. * 更新记录
  53. * @param array $data
  54. * @return bool
  55. */
  56. public function edit(array $data)
  57. {
  58. $this->transaction(function () use ($data) {
  59. // 更新记录
  60. $this->save($data);
  61. });
  62. return true;
  63. }
  64. /**
  65. * 获取记录
  66. * @param int $id
  67. * @param array $with
  68. * @return static
  69. */
  70. public static function detail(int $id, array $with = [])
  71. {
  72. return static::get($id, $with);
  73. }
  74. }