ConfController.php 1.4 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\pospal;
  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::POSPAL, get_store_id(), 'store')['value'];
  15. if($conf){
  16. $conf = json_decode($conf, true);
  17. }else{
  18. $conf = [
  19. 'app_id' => '',
  20. 'app_key' => '',
  21. 'api_host' => 'https://area11-win.pospal.cn:443',
  22. ];
  23. }
  24. return $this->asJson([
  25. 'code'=>0,
  26. 'msg'=>'ok',
  27. 'data' => $conf,
  28. 'crontabLink' => \Yii::$app->request->hostInfo . '/index.php?r=common/task/yinbao-sync-orders',
  29. ]);
  30. }
  31. public function actionConfSave(){
  32. $conf = input_params('conf');
  33. if(!is_array($conf)){
  34. $conf = json_decode($conf, true);
  35. }
  36. $conf['api_host'] = trim($conf['api_host'], '/');
  37. Option::set(OptionSetting::POSPAL, json_encode($conf), get_store_id(), 'store');
  38. return $this->asJson([
  39. 'code'=>0,
  40. 'msg'=>'保存成功'
  41. ]);
  42. }
  43. }