ConfController.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * 重庆赤晓店信息科技有限公司
  4. * https://www.chixiaodian.com
  5. * Copyright (c) 2023 赤店商城 All rights reserved.
  6. */
  7. namespace app\modules\admin\controllers\wechat_mp;
  8. use app\models\Option;
  9. use app\constants\OptionSetting;
  10. class ConfController extends BaseController
  11. {
  12. public $need_mp = false;
  13. public function actionConf(){
  14. $conf = Option::get(OptionSetting::WECHAT_MP, 0, 'saas')['value'];
  15. if($conf){
  16. $conf = json_decode($conf, true);
  17. }else{
  18. $conf = [
  19. 'app_id' => '',
  20. 'secret' => '',
  21. 'token' => '',
  22. 'aes_key' => '',
  23. ];
  24. }
  25. return $this->asJson([
  26. 'code'=>0,
  27. 'msg'=>'ok',
  28. 'data' => $conf,
  29. 'callback' => \Yii::$app->request->hostInfo . '/index.php/wechat_mp/push',
  30. ]);
  31. }
  32. public function actionConfSave(){
  33. $conf = input_params('conf');
  34. if(!is_array($conf)){
  35. $conf = json_decode($conf, true);
  36. }
  37. Option::set(OptionSetting::WECHAT_MP, json_encode($conf), 0, 'saas');
  38. return $this->asJson([
  39. 'code'=>0,
  40. 'msg'=>'保存成功'
  41. ]);
  42. }
  43. }