Config.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <?php
  2. /**
  3. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  4. * =========================================================
  5. * Copy right 2019-2029 山西牛酷信息科技有限公司, 保留所有权利。
  6. * ----------------------------------------------
  7. * 官方网址: https://www.niushop.com.cn
  8. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
  9. * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
  10. * =========================================================
  11. */
  12. namespace app\admin\controller;
  13. use app\model\system\Api;
  14. use app\model\system\Pay;
  15. use app\model\web\Config as ConfigModel;
  16. use app\model\web\WebSite as WebsiteModel;
  17. use app\model\shop\Config as ShopConfigModel;
  18. use app\model\goods\Config as GoodsConfigModel;
  19. use extend\RSA;
  20. /**
  21. * 设置 控制器
  22. */
  23. class Config extends BaseAdmin
  24. {
  25. /**
  26. * 网站设置
  27. */
  28. public function webConfig()
  29. {
  30. if (request()->isAjax()) {
  31. $data = [
  32. 'title' => input('title', ''),//网站标题
  33. 'logo' => input('logo', ''),//网站logo 图片
  34. 'desc' => input('desc', ''),//网站描述
  35. 'keywords' => input('keywords', ''),//网站关键字
  36. 'web_address' => input('web_address', ''),//网站地址
  37. 'web_qrcode' => input('web_qrcode', ''),//网站公众号二维码 图片
  38. 'web_email' => input('web_email', ''),//网站邮箱
  39. 'web_phone' => input('web_phone', ''),//网站联系方式
  40. 'web_qq' => input('web_qq', ''),//网站qq
  41. 'web_weixin' => input('web_weixin', ''),//网站微信
  42. 'web_status' => input('web_status', 1),//pc端状态 1:开启 0:关闭
  43. 'wap_status' => input('wap_status', 1),//手机端状态 1:开启 0:关闭
  44. 'close_reason' => input('close_reason', ''),//网站关闭原因 textarea
  45. 'site_id' => 0,
  46. 'wap_domain' => input('wap_domain', '') // 手机端域名
  47. ];
  48. $website_model = new WebsiteModel();
  49. return $website_model->setWebSite($data, [ [ 'site_id', '=', 0 ] ]);
  50. } else {
  51. $website_model = new WebsiteModel();
  52. $website_info = $website_model->getWebSite([ [ 'site_id', '=', 0 ] ], '*');
  53. $this->assign('website_info', $website_info);
  54. return $this->fetch('config/web_config');
  55. }
  56. }
  57. public function copyright() {
  58. $config_model = new ConfigModel();
  59. $copyright = $config_model->getCopyright();
  60. if (request()->isAjax()) {
  61. $logo = input('logo', '');
  62. $data = [
  63. 'logo' => $logo ?: $copyright['data']['value']['logo'],
  64. 'company_name' => input('company_name', ''),
  65. 'copyright_link' => input('copyright_link', ''),
  66. 'copyright_desc' => input('copyright_desc', ''),
  67. 'icp' => input('icp', ''),
  68. 'gov_record' => $gov_record = input('gov_record', ''),
  69. 'gov_url' => input('gov_url', ''),
  70. ];
  71. $this->addLog("修改版权配置");
  72. $res = $config_model->setCopyright($data);
  73. return $res;
  74. }
  75. $this->assign('copyright', $copyright['data']['value']);
  76. return $this->fetch('config/copyright');
  77. }
  78. /**
  79. * 收款设置
  80. */
  81. public function receivable()
  82. {
  83. if (request()->isAjax()) {
  84. $data = [
  85. 'bank_account_name' => input('bank_account_name', ''),//银行开户名
  86. 'bank_account_no' => input('bank_account_no', ''),//银行账户
  87. 'bank_name' => input('bank_name', ''),//开户行名称
  88. 'bank_address' => input('bank_address', ''),//开户地址
  89. ];
  90. $shop_config_model = new ShopConfigModel();
  91. return $shop_config_model->setSystemBankAccount($data);
  92. } else {
  93. $shop_config_model = new ShopConfigModel();
  94. $receivable_config = $shop_config_model->getSystemBankAccount();
  95. $this->assign('receivable_config', $receivable_config);
  96. return $this->fetch('config/receivable');
  97. }
  98. }
  99. /*
  100. * 售后保障
  101. */
  102. public function aftersale()
  103. {
  104. $goods_config_model = new GoodsConfigModel();
  105. if (request()->isAjax()) {
  106. $content = input('content', '');//售后保障协议
  107. return $goods_config_model->setAfterSaleConfig('售后保障协议', $content);
  108. } else {
  109. $content = $goods_config_model->getAfterSaleConfig();
  110. $this->assign('content', $content);
  111. return $this->fetch('config/aftersale');
  112. }
  113. }
  114. /**
  115. * 验证码设置
  116. */
  117. public function captcha()
  118. {
  119. if (request()->isAjax()) {
  120. $data = [
  121. 'admin_login' => input('admin_login', 0),//平台登录是否启用 1:启用 0:不启用
  122. 'shop_login' => input('shop_login', 0),//商家登陆是否启用 1:启用 0:不启用
  123. ];
  124. $config_model = new ConfigModel();
  125. return $config_model->setCaptchaConfig($data);
  126. } else {
  127. $config_model = new ConfigModel();
  128. $config_info = $config_model->getCaptchaConfig();
  129. $this->assign('config_info', $config_info['data']['value']);
  130. return $this->fetch('config/captcha');
  131. }
  132. }
  133. /**
  134. * 支付管理
  135. */
  136. public function pay()
  137. {
  138. if (request()->isAjax()) {
  139. $pay_model = new Pay();
  140. $list = $pay_model->getPayType([]);
  141. return $list;
  142. } else {
  143. return $this->fetch('config/pay');
  144. }
  145. }
  146. /**
  147. * api安全
  148. */
  149. public function api()
  150. {
  151. $api_model = new Api();
  152. if (request()->isAjax()) {
  153. $is_use = input("is_use", 0);
  154. $public_key = input("public_key", "");
  155. $private_key = input("private_key", "");
  156. $data = array(
  157. "public_key" => $public_key,
  158. "private_key" => $private_key,
  159. );
  160. $result = $api_model->setApiConfig($data, $is_use);
  161. return $result;
  162. } else {
  163. $config_result = $api_model->getApiConfig();
  164. $config = $config_result["data"];
  165. $this->assign("config", $config);
  166. // var_dump(RSA::getSecretKey());
  167. return $this->fetch('config/api');
  168. }
  169. }
  170. public function generateRSA(){
  171. if(request()->isAjax()) {
  172. return RSA::getSecretKey();
  173. }
  174. }
  175. /**
  176. * 默认图设置
  177. */
  178. public function defaultPicture()
  179. {
  180. $upload_config_model = new ConfigModel();
  181. if (request()->isAjax()) {
  182. $data = array(
  183. "default_goods_img" => input("default_goods_img", ""),
  184. "default_headimg" => input("default_headimg", ""),
  185. "default_shop_img" => input("default_shop_img", ""),
  186. );
  187. $this->addLog("修改默认图配置");
  188. $res = $upload_config_model->setDefaultImg($data);
  189. return $res;
  190. } else {
  191. $upload_config_result = $upload_config_model->getDefaultImg();
  192. $this->assign("default_img", $upload_config_result['data']['value']);
  193. return $this->fetch('config/default_picture');
  194. }
  195. }
  196. }