CommonLogic.php 2.9 KB

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