Config.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. <?php
  2. namespace app\admin\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. /**
  6. * ============================================================================
  7. * DSMall多用户商城
  8. * ============================================================================
  9. * 版权所有 2014-2028 长沙德尚网络科技有限公司,并保留所有权利。
  10. * 网站地址: http://www.csdeshang.com
  11. * ----------------------------------------------------------------------------
  12. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
  13. * 不允许对程序代码以任何形式任何目的的再发布。
  14. * ============================================================================
  15. * 控制器
  16. */
  17. class Config extends AdminControl {
  18. public function initialize() {
  19. parent::initialize();
  20. Lang::load(base_path() . 'admin/lang/' . config('lang.default_lang') . '/config.lang.php');
  21. }
  22. public function base() {
  23. $config_model = model('config');
  24. if (!request()->isPost()) {
  25. $list_config = rkcache('config', true);
  26. View::assign('list_config', $list_config);
  27. /* 设置卖家当前栏目 */
  28. $this->setAdminCurItem('base');
  29. return View::fetch();
  30. } else {
  31. //上传文件保存路径
  32. if (!empty($_FILES['site_logo']['name'])) {
  33. $res=ds_upload_pic(ATTACH_COMMON,'site_logo', 'site_logo.png');
  34. if($res['code']){
  35. $file_name=$res['data']['file_name'];
  36. $upload['site_logo'] = $file_name;
  37. }else{
  38. $this->error($res['msg']);
  39. }
  40. }
  41. if (!empty($upload['site_logo'])) {
  42. $update_array['site_logo'] = $upload['site_logo'];
  43. }
  44. if (!empty($_FILES['member_logo']['name'])) {
  45. $res=ds_upload_pic(ATTACH_COMMON,'member_logo', 'member_logo.png');
  46. if($res['code']){
  47. $file_name=$res['data']['file_name'];
  48. $upload['member_logo'] = $file_name;
  49. }else{
  50. $this->error($res['msg']);
  51. }
  52. }
  53. if (!empty($upload['member_logo'])) {
  54. $update_array['member_logo'] = $upload['member_logo'];
  55. }
  56. if (!empty($_FILES['seller_center_logo']['name'])) {
  57. $res=ds_upload_pic(ATTACH_COMMON,'seller_center_logo', 'seller_center_logo.png');
  58. if($res['code']){
  59. $file_name=$res['data']['file_name'];
  60. $upload['seller_center_logo'] = $file_name;
  61. }else{
  62. $this->error($res['msg']);
  63. }
  64. }
  65. if (!empty($upload['seller_center_logo'])) {
  66. $update_array['seller_center_logo'] = $upload['seller_center_logo'];
  67. }
  68. if (!empty($_FILES['admin_backlogo']['name'])) {
  69. $res=ds_upload_pic('admin/common','admin_backlogo', 'backlogo.png');
  70. if($res['code']){
  71. $file_name=$res['data']['file_name'];
  72. $upload['admin_backlogo'] = $file_name;
  73. }else{
  74. $this->error($res['msg']);
  75. }
  76. }
  77. if (!empty($upload['admin_backlogo'])) {
  78. $update_array['admin_backlogo'] = $upload['admin_backlogo'];
  79. }
  80. if (!empty($_FILES['admin_logo']['name'])) {
  81. $res=ds_upload_pic('admin/common','admin_logo', 'logo.png');
  82. if($res['code']){
  83. $file_name=$res['data']['file_name'];
  84. $upload['admin_logo'] = $file_name;
  85. }else{
  86. $this->error($res['msg']);
  87. }
  88. }
  89. if (!empty($upload['admin_logo'])) {
  90. $update_array['admin_logo'] = $upload['admin_logo'];
  91. }
  92. if (!empty($_FILES['site_mobile_logo']['name'])) {
  93. $res=ds_upload_pic(ATTACH_COMMON,'site_mobile_logo', 'site_mobile_logo.png');
  94. if($res['code']){
  95. $file_name=$res['data']['file_name'];
  96. $upload['site_mobile_logo'] = $file_name;
  97. }else{
  98. $this->error($res['msg']);
  99. }
  100. }
  101. if (!empty($upload['site_mobile_logo'])) {
  102. $update_array['site_mobile_logo'] = $upload['site_mobile_logo'];
  103. }
  104. if (!empty($_FILES['site_logowx']['name'])) {
  105. $res=ds_upload_pic(ATTACH_COMMON,'site_logowx', 'site_logowx.png');
  106. if($res['code']){
  107. $file_name=$res['data']['file_name'];
  108. $upload['site_logowx'] = $file_name;
  109. }else{
  110. $this->error($res['msg']);
  111. }
  112. }
  113. if (!empty($upload['site_logowx'])) {
  114. $update_array['site_logowx'] = $upload['site_logowx'];
  115. }
  116. if (!empty($_FILES['business_licence']['name'])) {
  117. $res=ds_upload_pic(ATTACH_COMMON,'business_licence', 'business_licence.png');
  118. if($res['code']){
  119. $file_name=$res['data']['file_name'];
  120. $upload['business_licence'] = $file_name;
  121. }else{
  122. $this->error($res['msg']);
  123. }
  124. }
  125. if (!empty($upload['business_licence'])) {
  126. $update_array['business_licence'] = $upload['business_licence'];
  127. }
  128. //首页首次访问悬浮图片
  129. if (!empty($_FILES['fixed_suspension_img']['name'])) {
  130. $res=ds_upload_pic(ATTACH_COMMON,'fixed_suspension_img', 'fixed_suspension_img.png');
  131. if($res['code']){
  132. $file_name=$res['data']['file_name'];
  133. $upload['fixed_suspension_img'] = $file_name;
  134. }else{
  135. $this->error($res['msg']);
  136. }
  137. }
  138. if (!empty($upload['fixed_suspension_img'])) {
  139. $update_array['fixed_suspension_img'] = $upload['fixed_suspension_img'];
  140. }
  141. $update_array['baidu_ak'] = input('post.baidu_ak');
  142. $update_array['site_name'] = input('post.site_name');
  143. $update_array['icp_number'] = input('post.icp_number');
  144. $update_array['wab_number'] = input('post.wab_number');
  145. $update_array['site_phone'] = input('post.site_phone');
  146. $update_array['site_tel400'] = input('post.site_tel400');
  147. $update_array['site_email'] = input('post.site_email');
  148. $update_array['flow_static_code'] = input('post.flow_static_code');
  149. $update_array['site_state'] = intval(input('post.site_state'));
  150. $update_array['cache_open'] = intval(input('post.cache_open'));
  151. $update_array['closed_reason'] = input('post.closed_reason');
  152. $update_array['hot_search'] = input('post.hot_search');
  153. $update_array['h5_site_url'] = input('post.h5_site_url');
  154. $update_array['h5_force_redirect'] = input('post.h5_force_redirect');
  155. $update_array['fixed_suspension_state'] = input('post.fixed_suspension_state'); //首页首次访问悬浮状态
  156. $update_array['fixed_suspension_url'] = input('post.fixed_suspension_url');
  157. $result = $config_model->editConfig($update_array);
  158. if ($result) {
  159. $this->log(lang('ds_edit') . lang('web_set'), 1);
  160. $this->success(lang('ds_common_save_succ'), 'Config/base');
  161. } else {
  162. $this->log(lang('ds_edit') . lang('web_set'), 0);
  163. }
  164. }
  165. }
  166. /**
  167. * 敏感词过滤设置
  168. */
  169. public function word_filter() {
  170. $config_model = model('config');
  171. if (!request()->isPost()) {
  172. $list_config = rkcache('config', true);
  173. View::assign('list_config', $list_config);
  174. /* 设置卖家当前栏目 */
  175. $this->setAdminCurItem('word_filter');
  176. return View::fetch();
  177. } else {
  178. $update_array = array();
  179. $update_array['word_filter_open'] = intval(input('post.word_filter_open'));
  180. $update_array['word_filter_appid'] = trim(input('post.word_filter_appid'));
  181. $update_array['word_filter_secret'] = trim(input('post.word_filter_secret'));
  182. $result = $config_model->editConfig($update_array);
  183. if ($result === true) {
  184. $this->log(lang('ds_edit') . lang('word_filter_set'), 1);
  185. $this->success(lang('ds_common_save_succ'));
  186. } else {
  187. $this->log(lang('ds_edit') . lang('word_filter_set'), 0);
  188. $this->error(lang('ds_common_save_fail'));
  189. }
  190. }
  191. }
  192. /**
  193. * 防灌水设置
  194. */
  195. public function dump() {
  196. $config_model = model('config');
  197. if (!request()->isPost()) {
  198. $list_config = rkcache('config', true);
  199. View::assign('list_config', $list_config);
  200. /* 设置卖家当前栏目 */
  201. $this->setAdminCurItem('dump');
  202. return View::fetch();
  203. } else {
  204. $update_array = array();
  205. $update_array['guest_comment'] = intval(input('post.guest_comment'));
  206. $update_array['captcha_status_login'] = intval(input('post.captcha_status_login'));
  207. $update_array['captcha_status_register'] = intval(input('post.captcha_status_register'));
  208. $update_array['captcha_status_goodsqa'] = intval(input('post.captcha_status_goodsqa'));
  209. $update_array['captcha_status_storelogin'] = intval(input('post.captcha_status_storelogin'));
  210. $result = $config_model->editConfig($update_array);
  211. if ($result === true) {
  212. $this->log(lang('ds_edit') . lang('dis_dump'), 1);
  213. $this->success(lang('ds_common_save_succ'));
  214. } else {
  215. $this->log(lang('ds_edit') . lang('dis_dump'), 0);
  216. $this->error(lang('ds_common_save_fail'));
  217. }
  218. }
  219. }
  220. /*
  221. * 设置自动收货时间
  222. */
  223. public function auto() {
  224. $config_model = model('config');
  225. if (!request()->isPost()) {
  226. $list_config = rkcache('config', true);
  227. View::assign('list_config', $list_config);
  228. /* 设置卖家当前栏目 */
  229. $this->setAdminCurItem('auto');
  230. return View::fetch();
  231. } else {
  232. $order_auto_receive_day = intval(input('post.order_auto_receive_day'));
  233. $order_auto_cancel_day = intval(input('post.order_auto_cancel_day'));
  234. $code_invalid_refund = intval(input('post.code_invalid_refund'));
  235. $store_bill_cycle = intval(input('post.store_bill_cycle'));
  236. if ($order_auto_receive_day < 1 || $order_auto_receive_day > 100) {
  237. $this->error(lang('automatic_confirmation_receipt') . '1-100' . lang('numerical'));
  238. }
  239. if ($order_auto_cancel_day < 1 || $order_auto_cancel_day > 50) {
  240. $this->error(lang('automatic_confirmation_receipt') . '1-50' . lang('numerical'));
  241. }
  242. if ($code_invalid_refund < 1 || $code_invalid_refund > 100) {
  243. $this->error(lang('exchange_code_refunded_automatically') . '1-100' . lang('numerical'));
  244. }
  245. if ($store_bill_cycle < 7) {
  246. $this->error(lang('store_bill_cycle_error'));
  247. }
  248. $update_array['order_auto_receive_day'] = $order_auto_receive_day;
  249. $update_array['order_auto_cancel_day'] = $order_auto_cancel_day;
  250. $update_array['code_invalid_refund'] = $code_invalid_refund;
  251. $update_array['store_bill_cycle'] = $store_bill_cycle;
  252. $result = $config_model->editConfig($update_array);
  253. if ($result) {
  254. $this->log(lang('ds_edit') . lang('auto_set'), 1);
  255. $this->success(lang('ds_common_save_succ'), 'Config/auto');
  256. } else {
  257. $this->log(lang('ds_edit') . lang('auto_set'), 0);
  258. $this->error(lang('ds_common_save_fail'));
  259. }
  260. }
  261. }
  262. /**
  263. * 获取卖家栏目列表,针对控制器下的栏目
  264. */
  265. protected function getAdminItemList() {
  266. $menu_array = array(
  267. array(
  268. 'name' => 'base',
  269. 'text' => lang('ds_base'),
  270. 'url' => (string) url('Config/base')
  271. ),
  272. array(
  273. 'name' => 'dump',
  274. 'text' => lang('dis_dump'),
  275. 'url' => (string) url('Config/dump')
  276. ),
  277. array(
  278. 'name' => 'word_filter',
  279. 'text' => lang('word_filter_set'),
  280. 'url' => (string) url('Config/word_filter')
  281. ),
  282. array(
  283. 'name' => 'auto',
  284. 'text' => lang('automatic_execution_time_setting'),
  285. 'url' => (string) url('Config/auto')
  286. ),
  287. );
  288. return $menu_array;
  289. }
  290. }