CommonLogic.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace app\mobile\logic;
  3. use app\model\AccountModel;
  4. use app\model\CommonModel;
  5. use app\model\ThemeModel;
  6. use app\model\VideoModel;
  7. use think\facade\Db;
  8. use think\response\Json;
  9. //公共
  10. class CommonLogic extends BaseLogic
  11. {
  12. //视频列表
  13. public static function getVideoList(array $data = []): Json
  14. {
  15. $rs = AccountModel::field('id,video_ids')
  16. ->where(['id' => self::$aid, 'is_del' => CommonModel::$del_normal])
  17. ->findOrEmpty()
  18. ->toArray();
  19. if (empty($rs)) return json_show(CommonModel::$error_param, '该账户不存在');
  20. $db = VideoModel::where(['is_del' => CommonModel::$del_normal, 'status' => CommonModel::$status_normal])
  21. ->whereIn('id', $rs['video_ids']);
  22. $count = $db->count('id');
  23. $list = $db
  24. ->field('id,video_sn,video_name,video_url,video_img')
  25. ->page($data['page'], $data['size'])
  26. ->order(['weight' => 'desc', 'id' => 'desc'])
  27. ->select()
  28. ->toArray();
  29. return json_show(CommonModel::$success, '获取视频列表成功', ['count' => $count, 'list' => $list]);
  30. }
  31. //手机主题
  32. public static function theme(): Json
  33. {
  34. $rs = ThemeModel::field('id,code')
  35. ->where(['is_del' => CommonModel::$del_normal, 'group_id' => self::$group_id, 'status' => CommonModel::$status_normal])
  36. ->append(['modular'])
  37. ->withAttr('modular', function ($val, $data) {
  38. return Db::name('theme_modular')
  39. ->field('id,title,type')
  40. ->where(['is_del' => CommonModel::$del_normal, 'theme_id' => $data['id'], 'status' => CommonModel::$status_normal])
  41. ->order(['addtime' => 'desc', 'id' => 'desc'])
  42. ->append(['data'])
  43. ->withAttr('data', function ($v, $d) {
  44. return Db::name('theme_modular_data')
  45. ->field('id,img,jump_type,jump_param,good_name,good_id,style_type')
  46. ->where(['is_del' => CommonModel::$del_normal, 'theme_modular_id' => $d['id']])
  47. ->order(['addtime' => 'desc', 'id' => 'desc'])
  48. ->select()
  49. ->toArray();
  50. })
  51. ->select()
  52. ->toArray();
  53. })
  54. ->findOrEmpty()
  55. ->toArray();
  56. return empty($rs) ? json_show(CommonModel::$error_param, '该手机主题不存在') : json_show(CommonModel::$success, '获取手机主题成功', $rs);
  57. }
  58. }