WechatController.php 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616
  1. <?php
  2. /**
  3. * @link:http://www.gdqijianshi.com/
  4. * @copyright: Copyright (c) 2020 广东七件事集团
  5. * 微信公众号管理
  6. * Author: lun
  7. * Date: 2021-09-17
  8. * Time: 16:12
  9. */
  10. namespace backend\modules\mall\controllers;
  11. use api\modules\v1\forms\user\WechatForm;
  12. use backend\controllers\MallController;
  13. use common\enums\StatusEnum;
  14. use common\helpers\ApiCode;
  15. use common\helpers\FileHelper;
  16. use common\logic\wechat\WechatMaterialLogic;
  17. use common\models\wechat\Material;
  18. use common\models\wechat\MaterialArticle;
  19. use common\models\wechat\ReplyRule;
  20. use common\models\wechat\RuleKeyword;
  21. use EasyWeChat\Factory;
  22. use EasyWeChat\Kernel\Exceptions\HttpException;
  23. use EasyWeChat\Kernel\Messages\Article;
  24. use Yii;
  25. use function Clue\StreamFilter\fun;
  26. class WechatController extends MallController
  27. {
  28. public function init()
  29. {
  30. parent::init(); // TODO: Change the autogenerated stub
  31. $wechat = \Yii::$app->services->setting->mall->get($this->mall_id, 'wechat');
  32. // if ($wechat) {
  33. \Yii::$app->params['wechatConfig'] = [
  34. 'app_id' => $wechat['app_id'] ?? '',
  35. 'secret' => $wechat['secret'] ?? '',
  36. 'token' => $wechat['token'] ?? '',
  37. 'aes_key' => $wechat['aes_key'] ?? '',
  38. ];
  39. // }
  40. }
  41. /**
  42. *
  43. * 公众号设置
  44. * @return mixed|string|void
  45. */
  46. public function actionEdit()
  47. {
  48. $request = Yii::$app->request;
  49. if ($request->isAjax) {
  50. if ($request->isGet) {
  51. $wechat = Yii::$app->services->setting->mall->get($this->mall_id, 'wechat');
  52. // 服务器地址(URL)
  53. $api_url = Yii::$app->services->setting->platform->get('system.api_url');
  54. $web_url = $api_url . '/wechat/index?mall-sign=' . $this->mall['mall_sign'];
  55. $this->success('获取成功', compact('wechat', 'web_url'));
  56. } else {
  57. $params = Yii::$app->request->post('form');
  58. $res = Yii::$app->services->validate->validate($params, [
  59. [['app_id', 'secret', 'token'], 'required'],
  60. [['app_id', 'name'], 'string', 'max' => 45],
  61. [['secret', 'token', 'aes_key','wechat_js'], 'string', 'max' => 64],
  62. [['qrcode'], 'string', 'max' => 255],
  63. [['aes_key', 'qrcode','original_id'], 'safe']
  64. ]);
  65. if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
  66. // 保存数据
  67. $res = Yii::$app->services->setting->mall->set($this->mall_id, ['wechat' => $params]);
  68. if ($res === false) $this->error('保存失败');
  69. $this->success('保存成功');
  70. }
  71. }
  72. return $this->render($this->action->id);
  73. }
  74. /**
  75. * 自定义菜单
  76. * @return string
  77. * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
  78. * @throws \GuzzleHttp\Exception\GuzzleException
  79. */
  80. public function actionMenus()
  81. {
  82. /** @var \jianyan\easywechat\Wechat $wechat */
  83. $wechat = Yii::$app->wechat;
  84. $app = $wechat->app;
  85. $request = Yii::$app->request;
  86. if ($request->isAjax) {
  87. if ($request->isPost) {
  88. $buttons = $request->post('form');
  89. $web_url = Yii::$app->urlManager->createAbsoluteUrl('/h5/#/pages/index/index?mall_id=' . $this->mall_id);
  90. $web_url = str_replace("web/index.php?r=","",urldecode($web_url));
  91. foreach ($buttons["button"] as &$item){
  92. if(empty($item["sub_button"]) && empty($item['type'])) return $this->error('一级菜单如果没有子菜单,需要设置菜单内容');
  93. if(isset($item["type"]) && $item["type"] == "miniprogram"){
  94. $item["url"] = isset($item["url"]) ? $item["url"] : $web_url;
  95. }
  96. if(isset($item["sub_button"])){
  97. foreach ($item["sub_button"] as &$itemChild){
  98. if($itemChild["type"] == "miniprogram"){
  99. $itemChild["url"] = isset($item["url"]) ? $item["url"] : $web_url;
  100. }
  101. }
  102. }
  103. }
  104. $res = $app->menu->create($buttons['button']);
  105. if ($res['errcode'] == 0) {
  106. return $this->success('发布成功');
  107. }
  108. return $this->error('发布失败,错误码:' . $res['errmsg']);
  109. } else {
  110. try {
  111. $list = $app->menu->list();
  112. } catch (HttpException $e) {
  113. return $this->error("获取菜单失败,errcode:{$e->formattedResponse['errcode']},errmsg:{$e->formattedResponse['errmsg']}");
  114. }
  115. return $this->success('获取成功', $list);
  116. }
  117. }
  118. return $this->render($this->action->id);
  119. }
  120. /**
  121. * 自定义回复
  122. * @return mixed|string|void
  123. */
  124. public function actionReplyRule()
  125. {
  126. $request = Yii::$app->request;
  127. if ($request->isAjax) {
  128. if ($request->isGet) {
  129. $params = Yii::$app->request->get();
  130. $res = Yii::$app->services->validate->validate($params, [
  131. [['page', 'limit'], 'integer'],
  132. [['page', 'limit'], 'safe'],
  133. ]);
  134. if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
  135. $where = [];
  136. $where[] = ['=', 'mall_id', $this->mall_id];
  137. $where[] = ['<>', 'status', StatusEnum::DELETE];
  138. $where[] = ['=', 'is_follow_reply', 0];
  139. $with = ['ruleKeyword' => function($query){
  140. $query->select('rule_id,type,keyword')->andWhere(['<>', 'status', StatusEnum::DELETE]);
  141. }];
  142. $order = 'id desc';
  143. $select = ['id', 'status', 'name', 'reply_type', 'type', 'content'];
  144. $params = ['select' => $select, 'where' => $where, 'with' => $with, 'order' => $order];
  145. $data = ReplyRule::listPage($params, false, true);
  146. // 组合匹配关键词
  147. if (!empty($data['list'])) {
  148. foreach ($data['list'] as &$item) {
  149. $match_keywords = [];
  150. $include_keywords = [];
  151. foreach ($item['ruleKeyword'] as $keyword) {
  152. if ($keyword['type'] == RuleKeyword::TYPE_MATCH) {
  153. $match_keywords[] = $keyword['keyword'];
  154. } elseif ($keyword['type'] == RuleKeyword::TYPE_INCLUDE) {
  155. $include_keywords[] = $keyword['keyword'];
  156. }
  157. $item['match_keywords'] = $match_keywords;
  158. $item['include_keywords'] = $include_keywords;
  159. }
  160. }
  161. }
  162. $this->success('获取成功', $data);
  163. } else {
  164. $params = Yii::$app->request->post('form');
  165. $res = Yii::$app->services->validate->validate($params, [
  166. [['name', 'reply_type', 'content', 'status'], 'required'],
  167. [['name', 'reply_type', 'content'], 'string'],
  168. [['status', 'id'], 'integer'],
  169. [['id', 'match_keywords', 'include_keywords'], 'safe']
  170. ]);
  171. if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
  172. // 保存数据
  173. $res = ReplyRule::setData($this->mall_id, $params);
  174. if ($res == false) return $this->error('保存失败:'.ReplyRule::getStaticError());
  175. $this->success('保存成功');
  176. }
  177. }
  178. return $this->render($this->action->id);
  179. }
  180. /**
  181. * 自定义回复
  182. * @return mixed|string|void
  183. */
  184. public function actionFollowReplyRule()
  185. {
  186. $request = Yii::$app->request;
  187. if ($request->isAjax) {
  188. if ($request->isGet) {
  189. $params = Yii::$app->request->get();
  190. $res = Yii::$app->services->validate->validate($params, [
  191. [['page', 'limit'], 'integer'],
  192. [['page', 'limit'], 'safe'],
  193. ]);
  194. if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
  195. $where = [];
  196. $where[] = ['=', 'mall_id', $this->mall_id];
  197. $where[] = ['<>', 'status', StatusEnum::DELETE];
  198. $where[] = ['=', 'is_follow_reply', 1];
  199. $order = 'id desc';
  200. $select = ['id', 'status', 'name', 'reply_type', 'type', 'content','is_follow_reply'];
  201. $params = ['select' => $select, 'where' => $where, 'order' => $order];
  202. $data = ReplyRule::listPage($params, false, true);
  203. $this->success('获取成功', $data);
  204. } else {
  205. $params = Yii::$app->request->post('form');
  206. $res = Yii::$app->services->validate->validate($params, [
  207. [['name', 'reply_type', 'content', 'status'], 'required'],
  208. [['name', 'reply_type', 'content'], 'string'],
  209. [['status', 'id','is_follow_reply'], 'integer'],
  210. [['id', 'match_keywords', 'include_keywords'], 'safe']
  211. ]);
  212. if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
  213. $exist = ReplyRule::getOne([['mall_id'=>$this->mall_id,'status'=>StatusEnum::ENABLED,'is_follow_reply'=>1]]);
  214. if($exist && $params['id'] != $exist->id){
  215. return $this->error('当前已有记录,请修改已存在记录');
  216. }
  217. // 保存数据
  218. $res = ReplyRule::setData($this->mall_id, $params);
  219. if ($res == false) return $this->error('保存失败');
  220. $this->success('保存成功');
  221. }
  222. }
  223. return $this->render($this->action->id);
  224. }
  225. /**
  226. * 删除自动回复
  227. * @return mixed|void
  228. */
  229. public function actionReplyRuleDelete()
  230. {
  231. $request = Yii::$app->request;
  232. if ($request->isAjax && $request->isPost) {
  233. $params = $request->post('form');
  234. $res = Yii::$app->services->validate->validate($params, [[['id'], 'required'], [['id'], 'integer']]);
  235. if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
  236. try {
  237. // 删除数据
  238. ReplyRule::updateAll(['status' => StatusEnum::DELETE], ['id' => $params['id'], 'mall_id' => $this->mall_id]);
  239. RuleKeyword::updateAll(['status' => StatusEnum::DELETE], ['rule_id' => $params['id'], 'mall_id' => $this->mall_id]);
  240. $this->success('删除成功');
  241. } catch (\Exception $e) {
  242. return $this->error('删除失败' . $e->getMessage());
  243. }
  244. }
  245. }
  246. /**
  247. * 素材管理
  248. * @return mixed|string|void
  249. */
  250. public function actionMaterial()
  251. {
  252. $request = Yii::$app->request;
  253. if ($request->isAjax) {
  254. if ($request->isGet) {
  255. $params = Yii::$app->request->Post();
  256. $res = Yii::$app->services->validate->validate($params, [
  257. [['page', 'limit'], 'integer'],
  258. [['page', 'limit'], 'safe'],
  259. ]);
  260. if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
  261. $where = [];
  262. $where[] = ['=', 'mall_id', $this->mall_id];
  263. $where[] = ['<>', 'status', StatusEnum::DELETE];
  264. $order = 'id desc';
  265. $select = ['id', 'status', 'wechat_app_id', 'media_id', 'url', 'name', 'media_type', 'material_desc', 'updated_at'];
  266. $params = ['select' => $select, 'where' => $where, 'order' => $order];
  267. $data = Material::listPage($params, false, true);
  268. if (!empty($data['list'])) {
  269. foreach ($data['list'] as &$item) {
  270. $item['updated_at'] = date('Y-m-d H:i:s', $item['updated_at']);
  271. }
  272. }
  273. $this->success('获取成功', $data);
  274. } else {
  275. $params = $request->post('form');
  276. $res = Yii::$app->services->validate->validate($params, [
  277. [['name', 'media_type', 'file_path'], 'required'],
  278. [['name', 'media_type', 'file_path', 'material_desc'], 'string'],
  279. [['material_desc'], 'safe']
  280. ]);
  281. if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
  282. $wechat = Yii::$app->wechat;
  283. $app = $wechat->app;
  284. $file = FileHelper::downFile(Yii::getAlias('@backend').'/web/uploads',md5(time()),$params['file_path']);
  285. if(empty($file)) return $this->error('获取图片失败');
  286. switch ($params['media_type']) {
  287. case 'images':
  288. $result = $app->material->uploadImage($file);
  289. if ($result) {
  290. //存入数据库
  291. $params['url'] = $result['url'];
  292. $params['media_id'] = $result['media_id'];
  293. }
  294. break;
  295. case 'videos':
  296. $result = $app->material->uploadVideo($file, $params['name'], $params['material_desc']);
  297. if ($result) {
  298. //存入数据库
  299. $params['media_id'] = $result['media_id'];
  300. $params['url'] = $result['url'];
  301. }
  302. break;
  303. case 'thumb':
  304. $result = $app->material->uploadThumb($file);
  305. if ($result) {
  306. //存入数据库
  307. $params['media_id'] = $result['media_id'];
  308. $params['url'] = $result['url'];
  309. }
  310. break;
  311. case 'voices':
  312. $result = $app->material->uploadVoice($file);
  313. if ($result) {
  314. //存入数据库
  315. $params['media_id'] = $result['media_id'];
  316. $params['url'] = $result['url'];
  317. }
  318. break;
  319. }
  320. $params['wechat_app_id'] = \Yii::$app->params['wechatConfig']['app_id'];
  321. // 保存数据
  322. $res = Material::setData($this->mall_id, $params);
  323. if ($res == false) return $this->error('保存失败,msg:' . Material::getStaticError());
  324. unlink($file);
  325. $this->success('保存成功');
  326. }
  327. }
  328. return $this->render($this->action->id);
  329. }
  330. /**
  331. * 删除素材管理
  332. * @return mixed|void
  333. */
  334. public function actionMaterialDelete()
  335. {
  336. $request = Yii::$app->request;
  337. if ($request->isAjax && $request->isPost) {
  338. $params = $request->post('form');
  339. $res = Yii::$app->services->validate->validate($params, [[['id'], 'required'], [['id'], 'integer']]);
  340. if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
  341. try {
  342. // 删除数据
  343. Material::updateAll(['status' => StatusEnum::DELETE], ['id' => $params['id'], 'mall_id' => $this->mall_id]);
  344. $this->success('删除成功');
  345. } catch (\Exception $e) {
  346. return $this->error('删除失败' . $e->getMessage());
  347. }
  348. }
  349. }
  350. /**
  351. * 图文素材
  352. * @return mixed|string|void
  353. */
  354. public function actionArticle()
  355. {
  356. $request = Yii::$app->request;
  357. if ($request->isAjax) {
  358. if ($request->isGet) {
  359. $params = Yii::$app->request->Post();
  360. $res = Yii::$app->services->validate->validate($params, [
  361. [['page', 'limit'], 'integer'],
  362. [['page', 'limit'], 'safe'],
  363. ]);
  364. if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
  365. $where = [];
  366. $where[] = ['=', 'mall_id', $this->mall_id];
  367. $where[] = ['<>', 'status', StatusEnum::DELETE];
  368. $order = 'id desc';
  369. $select = ['id', 'status', 'title', 'cover_pic', 'show_cover', 'article_id', 'updated_at'];
  370. $params = ['select' => $select, 'where' => $where, 'order' => $order];
  371. $data = MaterialArticle::listPage($params, false, true);
  372. if (!empty($data['list'])) {
  373. foreach ($data['list'] as &$item) {
  374. $item['updated_at'] = date('Y-m-d H:i:s', $item['updated_at']);
  375. }
  376. }
  377. $this->success('获取成功', $data);
  378. } else {
  379. $params = $request->post('form');
  380. $res = Yii::$app->services->validate->validate($params, [
  381. [['title', 'cover_pic', 'url', 'source_url'], 'required'],
  382. [['title', 'cover_pic', 'url', 'source_url','article_desc'], 'string'],
  383. [['show_cover'], 'integer'],
  384. [['content','author'], 'safe'],
  385. ]);
  386. if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
  387. $file = FileHelper::downFile(Yii::getAlias('@backend').'/web/uploads',md5(time()),$params['cover_pic']);
  388. if(empty($file)) return $this->error('获取图片失败');
  389. /** @var \jianyan\easywechat\Wechat $wechat */
  390. $wechat = \Yii::$app->wechat;
  391. $app = $wechat->getApp();
  392. $result = $app->material->uploadImage($file);
  393. if ($result) {
  394. //存入数据库
  395. $params['thumb_media_id'] = $result['media_id'];
  396. $params['thumb_url'] = $params['cover_pic'];
  397. unlink($file);// 删除临时保存图片
  398. $content = (new WechatMaterialLogic())->handleMaterialImgs($params['content']);
  399. $article['articles'][] =[
  400. 'title' => $params['title'],
  401. 'author' => $params['author'], // 作者
  402. 'digest' => $params['article_desc'],
  403. 'content' => $content,
  404. 'content_source_url'=>'',
  405. 'thumb_media_id' => $params['thumb_media_id'],
  406. ];
  407. // 获取media_id
  408. $res = $app->material->httpPostJson('cgi-bin/draft/add',$article);
  409. if(isset($res['errcode'])){
  410. return $this->error('保存失败,微信接口报错:'.$res['errmsg']);
  411. }
  412. $media_id = $res['media_id'];
  413. $res = $app->material->httpPostJson('cgi-bin/freepublish/submit',['media_id'=>$media_id]);
  414. if(isset($res['errcode']) && $res["errcode"] != 0){
  415. return $this->error('保存失败,微信接口报错:'.$res['errmsg']);
  416. }
  417. \Yii::error('=====+++==:'.json_encode($res));
  418. $params['publish_id'] = $res['publish_id'];
  419. $params['media_id'] = $media_id;
  420. } else {
  421. return $this->error('封面图上传失败');
  422. }
  423. // 保存数据
  424. $res = MaterialArticle::setData($this->mall_id, $params);
  425. if ($res == false) return $this->error('保存失败,msg:' . MaterialArticle::getStaticError());
  426. $this->success('保存成功');
  427. }
  428. }
  429. return $this->render($this->action->id);
  430. }
  431. public function actionArticleMenuList()
  432. {
  433. $request = Yii::$app->request;
  434. if ($request->isGet) {
  435. $params = Yii::$app->request->get();
  436. $res = Yii::$app->services->validate->validate($params, [
  437. [['page', 'limit'], 'integer'],
  438. [['page', 'limit'], 'safe'],
  439. ]);
  440. if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
  441. $where = [];
  442. $where[] = ['=', 'mall_id', $this->mall_id];
  443. $where[] = ['<>', 'article_id', ''];
  444. $where[] = ['<>', 'status', StatusEnum::DELETE];
  445. $order = 'id desc';
  446. $select = ['id', 'status', 'title', 'cover_pic', 'show_cover', 'article_id', 'updated_at'];
  447. $params = ['select' => $select, 'where' => $where, 'order' => $order];
  448. $data = MaterialArticle::listPage($params, false, true);
  449. if (!empty($data['list'])) {
  450. foreach ($data['list'] as &$item) {
  451. $item['updated_at'] = date('Y-m-d H:i:s', $item['updated_at']);
  452. }
  453. }
  454. $this->success('获取成功', $data);
  455. }
  456. }
  457. /**
  458. * 删除图文素材
  459. * @return mixed|void
  460. */
  461. public function actionArticleDelete()
  462. {
  463. $request = Yii::$app->request;
  464. if ($request->isAjax && $request->isPost) {
  465. $params = $request->post('form');
  466. $res = Yii::$app->services->validate->validate($params, [[['id'], 'required'], [['id'], 'integer']]);
  467. if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
  468. try {
  469. // 删除数据
  470. // MaterialArticle::updateAll(['status' => StatusEnum::DELETE], ['id' => $params['id'], 'mall_id' => $this->mall_id]);
  471. $article = MaterialArticle::findOne(['id' => $params['id'],'mall_id' => $this->mall_id]);
  472. if (!$article) {
  473. return $this->asJson(['code' => ApiCode::CODE_FAIL, 'msg' => '所选内容不存在或已被删除!']);
  474. }
  475. $article->status = StatusEnum::DELETE;
  476. if ($article->save()) {
  477. $app = \Yii::$app->wechat->getApp();
  478. $res = $app->material->httpPostJson('cgi-bin/freepublish/get',['publish_id'=>$article->publish_id]);
  479. if($res['publish_status'] == 0 && isset($res['article_id'])){
  480. $app->material->httpPostJson('cgi-bin/freepublish/delete',['publish_id'=>$res['publish_id'],'index'=>1]);
  481. // $app->material->freepublishDelete($res['article_id']);
  482. }
  483. $this->success('删除成功');
  484. }
  485. $this->success('删除失败');
  486. } catch (\Exception $e) {
  487. return $this->error('删除失败' . $e->getMessage());
  488. }
  489. }
  490. }
  491. public function actionArticleQuery()
  492. {
  493. $request = Yii::$app->request;
  494. if ($request->isAjax && $request->isPost) {
  495. $params = $request->post('form');
  496. $res = Yii::$app->services->validate->validate($params, [[['id'], 'required'], [['id'], 'integer']]);
  497. if ($res === false) return $this->error(Yii::$app->services->validate->getErrorMessage());
  498. try {
  499. $article = MaterialArticle::findOne(['id' => $params['id'],'mall_id' => $this->mall_id]);
  500. if (empty($article)) return $this->error('所选内容不存在或已被删除');
  501. $app = \Yii::$app->wechat->getApp();
  502. $res = $app->material->httpPostJson('cgi-bin/freepublish/get',['publish_id'=>$article->publish_id]);
  503. //0:成功, 1:发布中,2:原创失败, 3: 常规失败, 4:平台审核不通过, 5:成功后用户删除所有文章, 6: 成功后系统封禁所有文章
  504. \Yii::error('----:'.json_encode($res));
  505. $msg = '';
  506. if(isset($res['publish_status'])){
  507. switch ($res['publish_status']){
  508. case 0:
  509. $msg = '成功';
  510. break;
  511. case 1:
  512. $msg ='发布中';
  513. break;
  514. case 2:
  515. $msg = '原创失败';
  516. break;
  517. case 3:
  518. $msg ='';
  519. break;
  520. case 4:
  521. $msg='平台审核不通过';
  522. break;
  523. case 5:
  524. $msg='成功后用户删除所有文章';
  525. break;
  526. case 6:
  527. $msg='成功后系统封禁所有文章';
  528. break;
  529. }
  530. if ($res['publish_status'] == 0) {
  531. $article->article_id = $res['article_id'];
  532. $article->save();
  533. $this->success($msg);
  534. } else {
  535. $this->error($msg);
  536. }
  537. }else{
  538. $this->error('查询异常');
  539. }
  540. } catch (\Exception $e) {
  541. return $this->error('查询异常' . $e->getMessage());
  542. }
  543. }
  544. }
  545. /**
  546. * 获取商城H5链接
  547. *
  548. * @return void
  549. */
  550. public function actionGetH5Url()
  551. {
  552. return $this->success(
  553. 'ok',
  554. [
  555. 'url' => Yii::$app->services->setting->platform->get('system.h5_url'),
  556. 'sign' => $this->mall['mall_sign'],
  557. ]
  558. );
  559. }
  560. }