Config.php 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com
  8. * =========================================================
  9. */
  10. namespace app\shop\controller;
  11. use app\model\goods\Config as GoodsConfigModel;
  12. use app\model\system\Pay;
  13. use app\model\system\Servicer as ServicerModel;
  14. use app\model\web\Config as ConfigModel;
  15. use app\model\system\Api;
  16. use extend\RSA;
  17. use app\model\system\Upgrade;
  18. use app\model\system\Config as SystemConfig;
  19. /**
  20. * 设置 控制器
  21. */
  22. class Config extends BaseShop
  23. {
  24. public function copyright()
  25. {
  26. $upgrade_model = new Upgrade();
  27. $auth_info = $upgrade_model->authInfo();
  28. $config_model = new ConfigModel();
  29. $copyright = $config_model->getCopyright($this->site_id, $this->app_module);
  30. if (request()->isAjax()) {
  31. $logo = input('logo', '');
  32. $data = [
  33. 'icp' => input('icp', ''),
  34. 'gov_record' => input('gov_record', ''),
  35. 'gov_url' => input('gov_url', ''),
  36. 'market_supervision_url' => input('market_supervision_url', ''),
  37. 'logo' => '',
  38. 'company_name' => '',
  39. 'copyright_link' => '',
  40. 'copyright_desc' => ''
  41. ];
  42. if ($auth_info[ 'code' ] == 0) {
  43. $data[ 'logo' ] = input('logo', '');
  44. $data[ 'company_name' ] = input('company_name', '');
  45. $data[ 'copyright_link' ] = input('copyright_link', '');
  46. $data[ 'copyright_desc' ] = input('copyright_desc', '');
  47. }
  48. $this->addLog("修改版权配置");
  49. $res = $config_model->setCopyright($data, $this->site_id, $this->app_module);
  50. return $res;
  51. }
  52. $this->assign('is_auth', ( $auth_info[ 'code' ] >= 0 ? 1 : 0 ));
  53. $this->assign('copyright_config', $copyright[ 'data' ][ 'value' ]);
  54. return $this->fetch('config/copyright');
  55. }
  56. /**
  57. * 支付管理
  58. */
  59. public function pay()
  60. {
  61. if (request()->isAjax()) {
  62. $pay_model = new Pay();
  63. $list = $pay_model->getPayType([]);
  64. return $list;
  65. } else {
  66. return $this->fetch('config/pay');
  67. }
  68. }
  69. /**
  70. * 默认图设置
  71. */
  72. public function defaultPicture()
  73. {
  74. $upload_config_model = new ConfigModel();
  75. if (request()->isAjax()) {
  76. $data = array (
  77. "goods" => input("goods", ""),
  78. "head" => input("head", ""),
  79. "store" => input("store", ""),
  80. "article" => input("article", ""),
  81. );
  82. $this->addLog("修改默认图配置");
  83. $res = $upload_config_model->setDefaultImg($data, $this->site_id, $this->app_module);
  84. return $res;
  85. } else {
  86. $this->forthMenu();
  87. $upload_config_result = $upload_config_model->getDefaultImg($this->site_id, $this->app_module);
  88. $this->assign("default_img", $upload_config_result[ 'data' ][ 'value' ]);
  89. return $this->fetch('config/default_picture');
  90. }
  91. }
  92. /*
  93. * 售后保障
  94. */
  95. public function aftersale()
  96. {
  97. $goods_config_model = new GoodsConfigModel();
  98. if (request()->isAjax()) {
  99. $content = input('content', '');//售后保障协议
  100. $is_display = input('is_display', 1);//默认显
  101. return $goods_config_model->setAfterSaleConfig('售后保障', $content, $this->site_id, $is_display);
  102. } else {
  103. $this->forthMenu();
  104. $content = $goods_config_model->getAfterSaleConfig($this->site_id);
  105. $this->assign('content', $content[ 'data' ]);
  106. return $this->fetch('config/aftersale');
  107. }
  108. }
  109. /**
  110. * 验证码设置
  111. */
  112. public function captcha()
  113. {
  114. $config_model = new ConfigModel();
  115. if (request()->isAjax()) {
  116. $data = [
  117. 'shop_login' => input('shop_login', 0),//后台登陆验证码是否启用 1:启用 0:不启用
  118. 'shop_reception_login' => input('shop_reception_login', 0),//前台登陆验证码是否启用 1:启用 0:不启用
  119. ];
  120. return $config_model->setCaptchaConfig($data);
  121. } else {
  122. $this->forthMenu();
  123. $config_info = $config_model->getCaptchaConfig();
  124. $this->assign('config_info', $config_info[ 'data' ][ 'value' ]);
  125. return $this->fetch('config/captcha');
  126. }
  127. }
  128. /**
  129. * api安全
  130. */
  131. public function api()
  132. {
  133. $api_model = new Api();
  134. if (request()->isAjax()) {
  135. $is_use = input("is_use", 1);
  136. $public_key = input("public_key", "");
  137. $private_key = input("private_key", "");
  138. $long_time = input("long_time", "0");#限制时长 0位不限制 单位小时
  139. $data = array (
  140. "public_key" => $public_key,
  141. "private_key" => $private_key,
  142. "long_time" => $long_time
  143. );
  144. $result = $api_model->setApiConfig($data, $is_use);
  145. return $result;
  146. } else {
  147. $this->forthMenu();
  148. $config_result = $api_model->getApiConfig();
  149. $config = $config_result[ "data" ];
  150. $this->assign("config", $config);
  151. return $this->fetch('config/api');
  152. }
  153. }
  154. public function generateRSA()
  155. {
  156. if (request()->isAjax()) {
  157. return RSA::getSecretKey();
  158. }
  159. }
  160. /**
  161. * 地图配置
  162. * @return mixed
  163. */
  164. public function map()
  165. {
  166. $config_model = new ConfigModel();
  167. if (request()->isAjax()) {
  168. $tencent_map_key = input("tencent_map_key", "");
  169. $info = $config_model->checkQqMapKey($tencent_map_key, 1);
  170. if($info['status'] != 0){
  171. return $info;
  172. }
  173. $result = $config_model->setMapConfig([
  174. 'tencent_map_key' => $tencent_map_key
  175. ]);
  176. return $result;
  177. }
  178. $this->forthMenu();
  179. $config = $config_model->getMapConfig();
  180. $this->assign('info', $config[ 'data' ][ 'value' ]);
  181. return $this->fetch('config/map');
  182. }
  183. /**
  184. * 客服配置
  185. */
  186. public function servicer()
  187. {
  188. $servicer_model = new ServicerModel();
  189. if (request()->isAjax()) {
  190. $data = [
  191. 'h5' => input('h5', []),
  192. 'weapp' => input('weapp', []),
  193. 'pc' => input('pc', []),
  194. 'aliapp' => input('aliapp', []),
  195. ];
  196. return $servicer_model->setServicerConfig($data);
  197. } else {
  198. // $this->forthMenu();
  199. $config = $servicer_model->getServicerConfig()[ 'data' ] ?? [];
  200. $this->assign('config', $config[ 'value' ] ?? []);
  201. $this->assign('pc_is_exit', addon_is_exit('pc', $this->site_id));
  202. $this->assign('aliapp_is_exit', addon_is_exit('aliapp', $this->site_id));
  203. return $this->fetch('config/servicer');
  204. }
  205. }
  206. /**
  207. * 域名跳转配置
  208. */
  209. public function domainJumpConfig()
  210. {
  211. $config_model = new ConfigModel();
  212. if (request()->isAjax()) {
  213. $jump_type = input("jump_type", "1");
  214. $result = $config_model->setDomainJumpConfig([
  215. 'jump_type' => $jump_type
  216. ]);
  217. return $result;
  218. } else {
  219. // $this->forthMenu();
  220. $config = $config_model->getDomainJumpConfig();
  221. $this->assign('config', $config[ 'data' ][ 'value' ]);
  222. return $this->fetch('config/domain_jump_config');
  223. }
  224. }
  225. /**
  226. * 网站部署
  227. */
  228. public function siteDeploy()
  229. {
  230. //查询域名跳转
  231. $config_model = new ConfigModel();
  232. $jump_type = $config_model->getDomainJumpConfig();
  233. $this->assign('jump_type', $jump_type[ 'data' ][ 'value' ]);
  234. //查询不同端部署数据
  235. $site_deploy_data = event('SiteDeployData');
  236. $site_deploy_data = array_column($site_deploy_data, null, 'type');
  237. $this->assign('site_deploy_data', $site_deploy_data ?? []);
  238. //查询客服设置
  239. $servicer_model = new ServicerModel();
  240. $servicer_config = $servicer_model->getServicerConfig()[ 'data' ] ?? [];
  241. $servicer_config[ 'value' ][ 'pc_is_exit' ] = addon_is_exit('pc', $this->site_id);
  242. $this->assign('servicer_config', $servicer_config[ 'value' ] ?? []);
  243. return $this->fetch('config/site_deploy');
  244. }
  245. public function modifyConfigIsUse()
  246. {
  247. if (request()->isAjax()) {
  248. $is_use = input('is_use', 1);
  249. $config_key = input('config_key', '');
  250. return ( new SystemConfig() )->modifyConfigIsUse($is_use, [ [ 'site_id', '=', $this->site_id ], [ 'app_module', '=', $this->app_module ], [ 'config_key', '=', $config_key ] ]);
  251. }
  252. }
  253. }