SystemBannerLogic.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace app\admin\logic;
  3. use app\admin\model\dao\MoneyLog;
  4. use app\admin\model\dao\ScoreLog;
  5. use app\admin\model\dao\ShopOrder;
  6. use app\admin\model\dao\User;
  7. use app\common\model\BoxModel;
  8. use app\common\model\SystemBannerModel;
  9. use app\common\model\UserMoneyModel;
  10. use think\facade\Cache;
  11. use think\facade\Db;
  12. use utils\RedisCache;
  13. class SystemBannerLogic
  14. {
  15. public static function getList($page, $limit, $where, $sort)
  16. {
  17. $count = (new SystemBannerModel())
  18. ->where($where)
  19. ->count();
  20. $list = (new SystemBannerModel())
  21. ->where($where)
  22. ->withAttr('img_pic', function ($val, $data) {
  23. return __HTTPGETIMGADMIN($val);
  24. })
  25. ->page($page, $limit)
  26. ->order($sort)
  27. ->select();
  28. return [$count, $list];
  29. }
  30. public static function edit($post)
  31. {
  32. $row = new SystemBannerModel();
  33. try {
  34. $post['banner_desc'] = htmlspecialchars_decode($post['banner_desc']);
  35. $post['img_pic'] = __HTTPSAVEIMGADMIN($post['img_pic']);
  36. $save = $row->save($post);
  37. RedisCache::clear('getAppBanner' . $row['type']);
  38. return $save;
  39. } catch (\Exception $e) {
  40. return '保存失败';
  41. }
  42. }
  43. public static function add($data)
  44. {
  45. $data['img_pic'] = __HTTPSAVEIMGADMIN($data['img_pic']);
  46. $data['banner_desc'] = htmlspecialchars_decode($data['banner_desc']);
  47. $data['create_time'] = sr_getcurtime(time());
  48. unset($data['file']);
  49. $save = (new SystemBannerModel())->insert($data);
  50. RedisCache::clear('getAppBanner' . $data['type']);
  51. return $save;
  52. }
  53. }