DefaultController.php 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. <?php
  2. namespace addons\ShortVideo\backend\controllers;
  3. use addons\OperatingNote\common\models\AddonsOperatingNoteComment;
  4. use addons\ShortVideo\common\enums\AddonsShortVideoEnum;
  5. use addons\ShortVideo\common\models\ShortVideo;
  6. use addons\ShortVideo\common\models\ShortVideoBrowseAward;
  7. use addons\ShortVideo\common\models\ShortVideoComment;
  8. use addons\ShortVideo\common\models\ShortVideoCommissionItemSetting;
  9. use addons\ShortVideo\common\models\ShortVideoConfig;
  10. use addons\ShortVideo\common\models\ShortVideoOrderAward;
  11. use addons\ShortVideo\common\models\ShortVideoTag;
  12. use common\enums\AddonsEnum;
  13. use common\enums\StatusEnum;
  14. use common\models\goods\Goods;
  15. use common\models\order\Order;
  16. use common\models\user\User;
  17. /**
  18. * 默认控制器
  19. *
  20. * Class DefaultController
  21. * @package addons\ShortVideo\backend\controllers
  22. */
  23. class DefaultController extends BaseController
  24. {
  25. /**
  26. * 首页
  27. *
  28. * @return string
  29. */
  30. public function actionIndex()
  31. {
  32. if (\Yii::$app->request->isAjax) {
  33. if (\Yii::$app->request->isGet) {
  34. $page = \Yii::$app->request->get('page', 1);
  35. $limit = \Yii::$app->request->get('limit', $this->pageSize);
  36. $related_type = \Yii::$app->request->get('related_type', 0);
  37. $video_title = \Yii::$app->request->get('video_title');
  38. $user_nickname = \Yii::$app->request->get('user_nickname');
  39. $start_time = \Yii::$app->request->get('start_time');
  40. $end_time = \Yii::$app->request->get('end_time');
  41. $list_type = \Yii::$app->request->get('list_type', 1);
  42. $params = compact('page', 'limit', 'related_type', 'video_title', 'user_nickname', 'start_time', 'end_time');
  43. try {
  44. $video_list = ShortVideo::getList($this->mall_id, $list_type, $params);
  45. // dd($video_list);
  46. return $this->success('success', $video_list);
  47. } catch (\Exception $e) {
  48. return $this->error($e->getMessage());
  49. }
  50. }
  51. } else {
  52. return $this->render('index');
  53. }
  54. }
  55. public function actionBasicSetting()
  56. {
  57. if (\Yii::$app->request->isAjax) {
  58. if (\Yii::$app->request->isGet) {
  59. $config = ShortVideoConfig::find()
  60. ->where(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED])
  61. ->orderBy('updated_at desc')
  62. ->asArray()
  63. ->limit(1)
  64. ->one();
  65. $sensitive_config = \Yii::$app->services->setting->mall->get($this->mall_id, 'sensitive');
  66. $is_can_use_sensitive = true;
  67. if (empty($sensitive_config['api_key']) || empty($sensitive_config['secret_key'])) $is_can_use_sensitive = false;
  68. if (1 == $config['purchase_goods_status'] && !empty($config['purchase_goods_id'])) {
  69. $good = Goods::find()
  70. ->select('id,goods_name,price,cover_pic')
  71. ->where(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED, 'mch_id' => $this->admin->mch_id, 'is_on_sale' => 1, 'id' => (int)$config['purchase_goods_id']])
  72. ->asArray()
  73. ->all();
  74. } else {
  75. $good = [];
  76. }
  77. $group = 'basic';
  78. $basic_data = \Yii::$app->services->setting->addons->get($this->mall_id, AddonsEnum::ADDONS_NAME_SHORT_VIDEO, $group);
  79. $config['is_show_at_center'] = 1;
  80. if (isset($basic_data['is_show_at_center'])) {
  81. $config['is_show_at_center'] = $basic_data['is_show_at_center'];
  82. }
  83. if (!isset($config['award_status'])) {
  84. $config['award_status'] = 0;
  85. $config['award_type'] = 0;
  86. }
  87. $config['is_shuffle'] = $basic_data['is_shuffle'] ?? 0;
  88. return $this->success('success', ['config' => $config, 'is_can_use_sensitive' => $is_can_use_sensitive, 'good' => $good]);
  89. } else {
  90. $post = \Yii::$app->request->post('form');
  91. $post['mall_id'] = $this->mall_id;
  92. $is_show_at_center = $post['is_show_at_center'];
  93. $is_shuffle = $post['is_shuffle'];
  94. unset($post['is_show_at_center']);
  95. unset($post['is_shuffle']);
  96. unset($post['is_can_use_sensitive']);
  97. $model = new ShortVideoConfig();
  98. if (!$model->load($post, '') || false === $model->validate()) {
  99. $errors = $model->errors;
  100. $error_str = '';
  101. foreach ($errors as $error) {
  102. $error_str .= implode(',', $error) . ',';
  103. }
  104. $error_str = trim($error_str, ',');
  105. return $this->error($error_str);
  106. }
  107. $res = ShortVideoConfig::setData($this->mall_id, $post);
  108. if (false === $res) return $this->error('保存配置失败');
  109. \Yii::$app->services->setting->addons->set($this->mall_id, AddonsEnum::ADDONS_NAME_SHORT_VIDEO, ['basic' => ['mall_id' => $this->mall_id, 'is_show_at_center' => $is_show_at_center, 'is_shuffle' => $is_shuffle]]);
  110. return $this->success('保存成功');
  111. }
  112. } else {
  113. return $this->render('/config/index');
  114. }
  115. }
  116. public function actionVideoDetail()
  117. {
  118. if (\Yii::$app->request->isAjax) {
  119. if (\Yii::$app->request->isGet) {
  120. $id = \Yii::$app->request->get('id');
  121. if (empty($id)) return $this->error('参数错误');
  122. $video_info = ShortVideo::find()
  123. ->select('id,title,content,video_url,first_frame,user_id,created_at,check_time,duration_str,duration_seconds,related_type,related_goods_id,related_store_id,related_lon,related_lat,tag_id,is_blacklist,check_status,max_integral,max_money,surplus_money,surplus_integral,open_integral_award,watch_integral_sum,watch_integral,watch_integral_one,watch_integral_two,open_money_award,watch_money_sum,watch_money,watch_money_one,watch_money_two')
  124. ->where(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED, 'id' => $id])
  125. ->asArray()
  126. ->one();
  127. if (empty($video_info)) return $this->error('视频不存在');
  128. $user = User::find()
  129. ->select('id,nickname,mobile,username,avatar_url')
  130. ->where(['id' => $video_info['user_id'], 'status' => StatusEnum::ENABLED])
  131. ->one();
  132. $video_info['nickname'] = $user->nickname ?: $user->mobile;
  133. $video_info['avatar_url'] = $user->avatar_url ?: \Yii::$app->request->hostInfo . '/resources/img/common/default-avatar.png';
  134. if (1 == $video_info['is_blacklist']) {
  135. $video_info['status'] = '黑名单';
  136. } else {
  137. if (0 == $video_info['check_status']) {
  138. $video_info['status'] = '待审核';
  139. } elseif (1 == $video_info['check_status']) {
  140. $video_info['status'] = '审核通过';
  141. } else {
  142. $video_info['status'] = '审核不通过';
  143. }
  144. }
  145. if (empty($video_info['tag_id'])) {
  146. $video_info['label_list'] = [];
  147. } else {
  148. $tag_ids = explode(',', $video_info['tag_id']);
  149. $video_info['label_list'] = ShortVideoTag::find()
  150. ->where(['mall_id' => $this->mall_id, 'id' => $tag_ids, 'status' => StatusEnum::ENABLED])
  151. ->asArray()
  152. ->all();
  153. }
  154. if ($video_info['related_type'] == AddonsShortVideoEnum::VIDEO_RELATE_TYPE1) {
  155. // 关联商品
  156. if (empty($video_info['related_goods_id'])) {
  157. $video_info['goods'] = [];
  158. } else {
  159. $good = Goods::find()
  160. ->select('id,goods_name as name,cover_pic,price')
  161. ->where(['mall_id' => $this->mall_id, 'id' => $video_info['related_goods_id'], 'status' => StatusEnum::ENABLED])
  162. ->asArray()
  163. ->one();
  164. $video_info['goods'] = !empty($good) ? $good : [];
  165. }
  166. // dd($video_info['related_goods_id'], $video_info['goods']);
  167. } elseif ($video_info['related_type'] == AddonsShortVideoEnum::VIDEO_RELATE_TYPE2) {
  168. // 关联店铺
  169. // TODO: 店铺暂时不做
  170. $video_info['store'] = [];
  171. } else {
  172. $video_info['related_type'] == 4;
  173. }
  174. // 分红比例
  175. $item_id = $video_info['related_goods_id'] ?? 0;
  176. $item_setting = ShortVideoCommissionItemSetting::find()
  177. ->where(['mall_id' => $this->mall_id, 'is_enable' => 1, 'status' => StatusEnum::ENABLED, 'item_type' => 'goods', 'id' => $item_id])
  178. ->one();
  179. if (empty($item_setting)) {
  180. // 非独立设置商品分红
  181. $config = ShortVideoConfig::findOne(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED]);
  182. $goodsAward = [
  183. 'share_type' => $config->award_status == 0 ? 0 : $config->award_type,
  184. 'percentage' => $config->award_status == 0 ? 0 : $config->award_percentage,
  185. 'fixed_value' => $config->award_status == 0 ? 0 : $config->award_money
  186. ];
  187. } else {
  188. $setting_detail = $item_setting->detail;
  189. // dd($setting_detail);
  190. $goodsAward = [
  191. 'share_type' => $setting_detail->calculate_type,
  192. 'percentage' => $setting_detail->value,
  193. 'fixed_value' => $setting_detail->value,
  194. ];
  195. }
  196. $video_info['share'] = $goodsAward;
  197. return $this->success('success', $video_info);
  198. } else {
  199. $post = \Yii::$app->request->post('form');
  200. // dd($post);
  201. if (empty($post['id'])) return $this->error('参数错误');
  202. $video = ShortVideo::findOne(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED, 'id' => $post['id'], 'check_status' => AddonsShortVideoEnum::VIDEO_AUDIT_STATUS1, 'is_blacklist' => 0]);
  203. if (empty($video)) return $this->error('视频不存在或者不能修改配置');
  204. if (!empty($video['max_integral']) && !empty($post['operation_integral'])) {
  205. $max_integral = $video['max_integral'] + $post['operation_integral'];
  206. $post['max_integral'] = $max_integral >= 0 ? $max_integral : 0;
  207. $surplus_integral = $video['surplus_integral'] + $post['operation_integral'];
  208. $post['surplus_integral'] = $surplus_integral >= 0 ? $surplus_integral : 0;
  209. }
  210. if (!empty($video['max_money']) && !empty($post['operation_money'])) {
  211. $max_money = $video['max_money'] + $post['operation_money'];
  212. $post['max_money'] = $max_money >= 0 ? $max_money : 0;
  213. $surplus_money = $video['surplus_money'] + $post['operation_money'];
  214. $post['surplus_money'] = $surplus_money >= 0 ? $surplus_money : 0;
  215. }
  216. unset($post['operation_money'], $post['operation_integral'], $post['_csrf']);
  217. $post['duration_seconds'] = ceil($post['duration_seconds']) ?? 0;
  218. try {
  219. $res = ShortVideo::setData($this->mall_id, $post);
  220. if (false === $res) {
  221. return $this->error('操作失败');
  222. } else {
  223. return $this->success('操作成功');
  224. }
  225. } catch (\Exception $e) {
  226. return $this->error($e->getMessage());
  227. }
  228. }
  229. } else {
  230. return $this->render('details');
  231. }
  232. }
  233. public function actionAuditList()
  234. {
  235. return $this->render('/audit/index');
  236. }
  237. public function actionBlackList()
  238. {
  239. return $this->render('/blacklist/index');
  240. }
  241. public function actionTagList()
  242. {
  243. if (\Yii::$app->request->isAjax) {
  244. if (\Yii::$app->request->isGet) {
  245. $create_type = \Yii::$app->request->get('create_type');
  246. $id = \Yii::$app->request->get('id');
  247. $name = \Yii::$app->request->get('name');
  248. $start_time = \Yii::$app->request->get('start_time');
  249. $end_time = \Yii::$app->request->get('end_time');
  250. $page = \Yii::$app->request->get('page', 1);
  251. $limit = \Yii::$app->request->get('limit', $this->pageSize);
  252. $is_recommend = \Yii::$app->request->get('is_recommend');
  253. $wheres[] = ['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED];
  254. if (!empty($create_type)) $wheres[] = ['create_type' => $create_type];
  255. if (!empty($id)) $wheres[] = ['id' => $id];
  256. if (!empty($name)) $wheres[] = ['like', 'name', $name];
  257. if (!empty($start_time)) $wheres[] = ['>=', 'created_at', strtotime($start_time . ' 00:00:00')];
  258. if (!empty($end_time)) $wheres[] = ['>=', 'created_at', strtotime($end_time . ' 23:59:59')];
  259. if (!empty($is_recommend)) $wheres[] = ['is_recommend' => $is_recommend];
  260. $params = [
  261. 'where' => $wheres,
  262. 'order' => 'id desc',
  263. 'page' => $page,
  264. 'limit' => $limit,
  265. ];
  266. $tag_list = ShortVideoTag::listPage($params);
  267. if (!empty($tag_list['list'])) {
  268. $video_count = ShortVideo::find()->where(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED, 'check_status' => AddonsShortVideoEnum::VIDEO_AUDIT_STATUS1, 'is_blacklist' => 0])->count();
  269. // dd($video_count);
  270. foreach ($tag_list['list'] as &$tag) {
  271. if (empty($video_count)) {
  272. $tag['frequency'] = 0;
  273. continue;
  274. }
  275. $tag['frequency'] = floatval(round($tag['usage_num'] / $video_count * 100, 2));
  276. }
  277. }
  278. return $this->success('success', $tag_list);
  279. }
  280. } else {
  281. return $this->render('/tag/index');
  282. }
  283. }
  284. public function actionShareBenefits()
  285. {
  286. if (\Yii::$app->request->isAjax) {
  287. if (\Yii::$app->request->isGet) {
  288. $page = \Yii::$app->request->get('page', 1);
  289. $limit = \Yii::$app->request->get('limit', $this->pageSize);
  290. $start_time = \Yii::$app->request->get('start_time');
  291. $end_time = \Yii::$app->request->get('end_time');
  292. $nickname = \Yii::$app->request->get('nickname');
  293. $video_id = \Yii::$app->request->get('video_id');
  294. $order_no = \Yii::$app->request->get('order_no');
  295. $wheres[] = ['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED];
  296. if (!empty($start_time)) $wheres[] = ['>=', 'created_at', strtotime($start_time . ' 00:00:00')];
  297. if (!empty($end_time)) $wheres[] = ['<=', 'created_at', strtotime($end_time . ' 23:59:59')];
  298. if (!empty($nickname)) {
  299. $users = User::find()
  300. ->select('id,nickname,mobile,avatar_url')
  301. ->where(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED])
  302. ->andWhere(['like', 'nickname', $nickname])
  303. ->asArray()
  304. ->indexBy('id')
  305. ->all();
  306. if (!empty($users)) {
  307. $user_ids = array_column($users, 'id');
  308. $wheres[] = ['user_id' => $user_ids];
  309. }
  310. }
  311. if (!empty($video_id)) $wheres[] = ['video_id' => $video_id];
  312. if (!empty($order_no)) {
  313. $orders = Order::find()
  314. ->select('id,order_no,pay_money')
  315. ->where(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED])
  316. ->andWhere(['like', 'order_no', $order_no])
  317. ->asArray()
  318. ->indexBy('id')
  319. ->all();
  320. $order_ids = array_column($orders, 'id');
  321. $wheres[] = ['order_id' => $order_ids];
  322. }
  323. $params = [
  324. 'select' => 'id,order_id,user_id,created_at,video_id,goods_id,award_type,goods_price,award_percentage,award_money,is_settlement',
  325. 'where' => $wheres,
  326. 'order' => 'created_at desc,id desc',
  327. 'page' => $page,
  328. 'limit' => $limit
  329. ];
  330. $order_awards = ShortVideoOrderAward::listPage($params);
  331. // dd($order_awards);
  332. // $order_awards = ShortVideoOrderAward::getStaticError();
  333. // dd($order_awards);
  334. if (empty($order_awards['list'])) {
  335. if (is_array($order_awards['list'])) {
  336. return $this->success('success', $order_awards);
  337. } else {
  338. return $this->error(ShortVideoOrderAward::getStaticError());
  339. }
  340. }
  341. if (empty($users)) {
  342. $user_ids = array_column($order_awards['list'], 'user_id');
  343. $users = User::find()
  344. ->select('id,nickname,mobile,avatar_url')
  345. ->where(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED, 'id' => $user_ids])
  346. ->asArray()
  347. ->indexBy('id')
  348. ->all();
  349. }
  350. $good_ids = array_column($order_awards['list'], 'goods_id');
  351. $goods = Goods::find()
  352. ->select('id,goods_name,cover_pic,price')
  353. ->where(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED, 'id' => $good_ids])
  354. ->asArray()
  355. ->indexBy('id')
  356. ->all();
  357. if (empty($orders)) {
  358. $order_ids = array_column($order_awards['list'], 'order_id');
  359. $orders = Order::find()
  360. ->select('id,order_no,pay_money')
  361. ->where(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED, 'id' => $order_ids])
  362. ->asArray()
  363. ->indexBy('id')
  364. ->all();
  365. }
  366. foreach ($order_awards['list'] as &$award) {
  367. $user = $users[$award['user_id']] ?? [];
  368. $award['nickname'] = $user['nickname'] ?? '';
  369. $award['mobile'] = $user['mobile'] ?? '';
  370. $award['avatar_url'] = $user['avatar_url'] ?? \Yii::$app->request->hostInfo . '/resources/img/common/default-avatar.png';
  371. $award['goods_name'] = $goods[$award['goods_id']]['goods_name'] ?? '';
  372. $award['cover_pic'] = $goods[$award['goods_id']]['cover_pic'] ?? '';
  373. $award['price'] = $goods[$award['goods_id']]['price'] ?? 0;
  374. $award['order_no'] = $orders[$award['order_id']]['order_no'] ?? '';
  375. $award['total_pay_price'] = $orders[$award['order_id']]['pay_money'] ?? 0;
  376. }
  377. return $this->success('success', $order_awards);
  378. }
  379. } else {
  380. return $this->render('/share-benefits/index');
  381. }
  382. }
  383. public function actionBrowseRewardList()
  384. {
  385. if (\Yii::$app->request->isAjax) {
  386. if (\Yii::$app->request->isGet) {
  387. $page = \Yii::$app->request->get('page', 1);
  388. $limit = \Yii::$app->request->get('limit', $this->pageSize);
  389. $video_id = \Yii::$app->request->get('video_id');
  390. $nickname = \Yii::$app->request->get('nickname');
  391. $start_time = \Yii::$app->request->get('start_time');
  392. $end_time = \Yii::$app->request->get('end_time');
  393. $wheres[] = ['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED];
  394. if (!empty($video_id)) $wheres[] = ['video_id' => $video_id];
  395. if (!empty($start_time)) $wheres[] = ['>=', 'created_at', strtotime($start_time . ' 00:00:00')];
  396. if (!empty($end_time)) $wheres[] = ['<=', 'created_at', strtotime($end_time . ' 23:59:59')];
  397. if (!empty($nickname)) {
  398. $users = User::find()
  399. ->select('id,nickname,mobile,avatar_url')
  400. ->where(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED])
  401. ->andWhere(['like', 'nickname', $nickname])
  402. ->asArray()
  403. ->indexBy('id')
  404. ->all();
  405. if (!empty($users)) {
  406. $user_ids = array_column($users, 'id');
  407. $wheres[] = ['user_id' => $user_ids];
  408. }
  409. }
  410. $params = [
  411. 'select' => 'id,created_at,video_id,user_id,user_type,award_type,award_integral,award_money',
  412. 'where' => $wheres,
  413. 'order' => 'created_at desc,id desc',
  414. 'page' => $page,
  415. 'limit' => $limit,
  416. ];
  417. $rewards = ShortVideoBrowseAward::listPage($params);
  418. if (empty($rewards['list'])) {
  419. if (is_array($rewards['list'])) {
  420. return $this->success('success', $rewards);
  421. } else {
  422. return $this->error(ShortVideoBrowseAward::getStaticError());
  423. }
  424. }
  425. if (empty($users)) {
  426. $user_ids = array_column($rewards['list'], 'user_id');
  427. $users = User::find()
  428. ->select('id,nickname,mobile,avatar_url')
  429. ->where(['mall_id' => $this->mall_id, 'status' => StatusEnum::ENABLED, 'id' => $user_ids])
  430. ->asArray()
  431. ->indexBy('id')
  432. ->all();
  433. if (empty($users)) $users = [];
  434. }
  435. foreach ($rewards['list'] as &$reward) {
  436. $reward['nickname'] = ($users[$reward['user_id']]['nickname'] ?? $users[$reward['user_id']]['mobile']) ?? '';
  437. $reward['mobile'] = $users[$reward['user_id']]['mobile'] ?? '';
  438. $reward['avatar_url'] = $users[$reward['user_id']]['avatar_url'] ?? \Yii::$app->request->hostInfo . '/resources/img/common/default-avatar.png';
  439. }
  440. return $this->success('success', $rewards);
  441. }
  442. } else {
  443. return $this->render('/watch-reward/index');
  444. }
  445. }
  446. public function actionCommentList()
  447. {
  448. if (\Yii::$app->request->isAjax) {
  449. if (\Yii::$app->request->isGet) {
  450. $params = \Yii::$app->request->get();
  451. $where[] = ['mall_id' => $this->mall_id, 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]];
  452. !empty($params['user_id']) && $where[] = ['=', 'user_id', $params['user_id']];
  453. if (!empty($params['mobile'])) {
  454. $user_id = User::find()->select('id')->where(['mall_id' => $this->mall_id, 'mobile' => $params['mobile'], 'status' => StatusEnum::ENABLED])->scalar() ?? 0;
  455. $where[] = ['=', 'user_id', $user_id];
  456. }
  457. if (!empty($params['start_at']) && !empty($params['end_at'])) {
  458. $where[] = ['between', 'created_at', strtotime($params['start_at']), strtotime($params['end_at'])];
  459. }
  460. if(!empty($params['content'])){
  461. $where[] = ['like', 'content', $params['content']];
  462. }
  463. $params['where'] = $where;
  464. $params['order'] = 'id desc';
  465. $params['with'] = ['user'];
  466. $comment_list = ShortVideoComment::listPage($params);
  467. if($comment_list==false) return $this->error(AddonsOperatingNoteComment::getStaticError());
  468. if (!empty($comment_list['list'])) {
  469. }
  470. return $this->success('success', $comment_list);
  471. }
  472. } else {
  473. return $this->render('comment-list');
  474. }
  475. }
  476. public function actionCommentDel()
  477. {
  478. $request = \Yii::$app->request;
  479. if ($request->isAjax && $request->isPost) {
  480. // 检查提交的参数
  481. $post = $request->post();
  482. $res = \Yii::$app->services->validate->validate($post, [
  483. [['id'], 'required'],
  484. ]);
  485. if ($res === false) return $this->error(\Yii::$app->services->validate->getErrorMessage());
  486. $post['mall_id'] = $this->mall_id;
  487. $post['attributes'] = ['status'=>StatusEnum::DELETE];
  488. ShortVideoComment::updateData($post);
  489. return $this->success('成功');
  490. }
  491. }
  492. public function actionCommentUpTop()
  493. {
  494. $request = \Yii::$app->request;
  495. if ($request->isAjax && $request->isPost) {
  496. // 检查提交的参数
  497. $post = $request->post();
  498. $res = \Yii::$app->services->validate->validate($post, [
  499. [['id','is_top'], 'required'],
  500. ['is_top', 'integer', 'min' => 0, 'max' => 1],
  501. ]);
  502. if ($res === false) return $this->error(\Yii::$app->services->validate->getErrorMessage());
  503. $post['mall_id'] = $this->mall_id;
  504. $post['attributes'] = ['is_top'=>$post['is_top']];
  505. ShortVideoComment::updateData($post);
  506. return $this->success('成功');
  507. }
  508. }
  509. public function actionCommentChangeStatus()
  510. {
  511. $request = \Yii::$app->request;
  512. if ($request->isAjax && $request->isPost) {
  513. // 检查提交的参数
  514. $post = $request->post();
  515. $res = \Yii::$app->services->validate->validate($post, [
  516. [['id','status'], 'required'],
  517. ['status', 'integer', 'min' => 0, 'max' => 1],
  518. ]);
  519. if ($res == false) return $this->error(\Yii::$app->services->validate->getErrorMessage());
  520. $post['mall_id'] = $this->mall_id;
  521. $post['attributes'] = ['status'=> $post['status']];
  522. ShortVideoComment::updateData($post);
  523. return $this->success('成功');
  524. }
  525. }
  526. public function actionRepair()
  527. {
  528. $request = \Yii::$app->request;
  529. if ($request->isAjax && $request->isGet) {
  530. try {
  531. $list = ShortVideo::lists([
  532. 'where' => [
  533. ['mall_id' => $this->mall_id],
  534. ['status' => 1],
  535. ['duration_seconds' => 0],
  536. ['check_status' => 1],
  537. ['is_blacklist' => 0]
  538. ],
  539. 'order' => 'id desc',
  540. ]);
  541. return $this->success('获取成功', $list);
  542. } catch (\Exception $e) {
  543. return $this->error($e->getMessage());
  544. }
  545. }
  546. return $this->render('repair');
  547. }
  548. }