XcxHomeSetting.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. namespace app\store\model;
  3. use app\common\model\XcxHomeSetting as XcxHomeSettingModel;
  4. /**
  5. * 渠道销售统计模型
  6. * @package app\store\model
  7. */
  8. class XcxHomeSetting extends XcxHomeSettingModel
  9. {
  10. public static function openPage($id,$params){
  11. return static::where('id',$id)->update($params);
  12. }
  13. public function getStartTimeAttr($data){
  14. if ($data > 0){
  15. return date('Y-m-d H:i:s',$data);
  16. }
  17. return '';
  18. }
  19. public function getEndTimeAttr($data){
  20. if ($data > 0){
  21. return date('Y-m-d H:i:s',$data);
  22. }
  23. return '';
  24. }
  25. public static function lists()
  26. {
  27. $data = static::where('is_delete',0)->where('home_type',1)
  28. ->field('id,home_type,start_time,end_time,open_status')->find();
  29. if ($data && strtotime($data['start_time']) < time() && strtotime($data['end_time']) > time() && $data['open_status'] == 1){
  30. $data['real_open_status'] = 1;
  31. }else{
  32. $data['real_open_status'] = 0;
  33. }
  34. return ['act'=>$data];
  35. }
  36. public static function settingUpdate($settings){
  37. return static::where('id',1)->where('home_type',1)
  38. ->update(['setting'=>$settings]);
  39. }
  40. public function getSettingAttr($data){
  41. if ($data){
  42. return json_decode($data);
  43. }
  44. return null;
  45. }
  46. public static function getPage(){
  47. return self::where(['home_type'=>1])
  48. ->field('id,home_type,setting,file_id,open_status')
  49. ->find();
  50. }
  51. }