Config.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. <?php
  2. namespace app\admin\controller;
  3. use think\facade\View;
  4. use think\facade\Lang;
  5. /**
  6. * ============================================================================
  7. *
  8. * ============================================================================
  9. * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
  10. * 网站地址: https://www.valimart.net/
  11. * ----------------------------------------------------------------------------
  12. *
  13. * ============================================================================
  14. * 控制器
  15. */
  16. class Config extends AdminControl {
  17. public function initialize() {
  18. parent::initialize();
  19. Lang::load(base_path() . 'admin/lang/' . config('lang.default_lang') . '/config.lang.php');
  20. }
  21. public function base() {
  22. $config_model = model('config');
  23. if (!request()->isPost()) {
  24. $list_config = rkcache('config', true);
  25. View::assign('list_config', $list_config);
  26. /* 设置卖家当前栏目 */
  27. $this->setAdminCurItem('base');
  28. return View::fetch();
  29. } else {
  30. $update_array = array();
  31. //首页首次访问悬浮图片
  32. if (!empty($_FILES['fixed_suspension_img']['name'])) {
  33. $res=ds_upload_pic(ATTACH_COMMON,'fixed_suspension_img', 'fixed_suspension_img.png');
  34. if($res['code']){
  35. $file_name=$res['data']['file_name'];
  36. $upload['fixed_suspension_img'] = $file_name;
  37. }else{
  38. $this->error($res['msg']);
  39. }
  40. }
  41. if (!empty($upload['fixed_suspension_img'])) {
  42. $update_array['fixed_suspension_img'] = $upload['fixed_suspension_img'];
  43. }
  44. $update_array['goods_verify'] = intval(input('post.goods_verify')) ;//店铺商品审核
  45. $update_array['goods_all_verify'] = intval(input('post.goods_all_verify')) ;//店铺所有商品是否通过审核
  46. $update_array['baidu_ak'] = input('post.baidu_ak');
  47. $update_array['baiduservice_ak'] = input('post.baiduservice_ak');
  48. $update_array['mapak_type'] = input('post.mapak_type');
  49. $update_array['gaode_ak'] = input('post.gaode_ak');
  50. $update_array['gaode_jscode'] = input('post.gaode_jscode');
  51. $update_array['site_name'] = input('post.site_name');
  52. $update_array['icp_number'] = input('post.icp_number');
  53. $update_array['wab_number'] = input('post.wab_number');
  54. $update_array['site_phone'] = input('post.site_phone');
  55. $update_array['site_tel400'] = input('post.site_tel400');
  56. $update_array['site_email'] = input('post.site_email');
  57. $update_array['flow_static_code'] = input('post.flow_static_code');
  58. $update_array['site_state'] = intval(input('post.site_state'));
  59. $update_array['cache_open'] = intval(input('post.cache_open'));
  60. $update_array['closed_reason'] = input('post.closed_reason');
  61. $update_array['hot_search'] = input('post.hot_search');
  62. $update_array['h5_site_url'] = input('post.h5_site_url');
  63. $update_array['h5_chain_site_url'] = input('post.h5_chain_site_url');
  64. $update_array['h5_store_site_url'] = input('post.h5_store_site_url');
  65. $update_array['h5_force_redirect'] = input('post.h5_force_redirect');
  66. $update_array['fixed_suspension_state'] = input('post.fixed_suspension_state'); //首页首次访问悬浮状态
  67. $update_array['fixed_suspension_url'] = input('post.fixed_suspension_url');
  68. $update_array['member_auth'] = input('post.member_auth');//会员实名认证
  69. $result = $config_model->editConfig($update_array);
  70. if ($result) {
  71. if($update_array['goods_verify']==0 && $update_array['goods_all_verify']==1){
  72. $goods_model = model('goods');
  73. $update = array();
  74. $update['goods_verify'] = 1;
  75. $where = array();
  76. $where[]=array('goods_commonid','>', 0);
  77. $goods_model->editProduces($where, $update);
  78. }
  79. $this->log(lang('ds_edit') . lang('web_set'), 1);
  80. $this->success(lang('ds_common_save_succ'), 'Config/base');
  81. } else {
  82. $this->log(lang('ds_edit') . lang('web_set'), 0);
  83. }
  84. }
  85. }
  86. public function logo() {
  87. $config_model = model('config');
  88. if (!request()->isPost()) {
  89. $list_config = rkcache('config', true);
  90. View::assign('list_config', $list_config);
  91. /* 设置卖家当前栏目 */
  92. $this->setAdminCurItem('logo');
  93. return View::fetch();
  94. } else {
  95. //上传文件保存路径
  96. if (!empty($_FILES['site_logo']['name'])) {
  97. $res=ds_upload_pic(ATTACH_COMMON,'site_logo', 'site_logo.png');
  98. if($res['code']){
  99. $file_name=$res['data']['file_name'];
  100. $upload['site_logo'] = $file_name;
  101. }else{
  102. $this->error($res['msg']);
  103. }
  104. }
  105. if (!empty($upload['site_logo'])) {
  106. $update_array['site_logo'] = $upload['site_logo'];
  107. }
  108. if (!empty($_FILES['member_logo']['name'])) {
  109. $res=ds_upload_pic(ATTACH_COMMON,'member_logo', 'member_logo.png');
  110. if($res['code']){
  111. $file_name=$res['data']['file_name'];
  112. $upload['member_logo'] = $file_name;
  113. }else{
  114. $this->error($res['msg']);
  115. }
  116. }
  117. if (!empty($upload['member_logo'])) {
  118. $update_array['member_logo'] = $upload['member_logo'];
  119. }
  120. if (!empty($_FILES['seller_center_logo']['name'])) {
  121. $res=ds_upload_pic(ATTACH_COMMON,'seller_center_logo', 'seller_center_logo.png');
  122. if($res['code']){
  123. $file_name=$res['data']['file_name'];
  124. $upload['seller_center_logo'] = $file_name;
  125. }else{
  126. $this->error($res['msg']);
  127. }
  128. }
  129. if (!empty($upload['seller_center_logo'])) {
  130. $update_array['seller_center_logo'] = $upload['seller_center_logo'];
  131. }
  132. if (!empty($_FILES['admin_backlogo']['name'])) {
  133. $res=ds_upload_pic('admin/common','admin_backlogo', 'backlogo.png');
  134. if($res['code']){
  135. $file_name=$res['data']['file_name'];
  136. $upload['admin_backlogo'] = $file_name;
  137. }else{
  138. $this->error($res['msg']);
  139. }
  140. }
  141. if (!empty($upload['admin_backlogo'])) {
  142. $update_array['admin_backlogo'] = $upload['admin_backlogo'];
  143. }
  144. if (!empty($_FILES['admin_logo']['name'])) {
  145. $res=ds_upload_pic('admin/common','admin_logo', 'logo.png');
  146. if($res['code']){
  147. $file_name=$res['data']['file_name'];
  148. $upload['admin_logo'] = $file_name;
  149. }else{
  150. $this->error($res['msg']);
  151. }
  152. }
  153. if (!empty($upload['admin_logo'])) {
  154. $update_array['admin_logo'] = $upload['admin_logo'];
  155. }
  156. if (!empty($_FILES['site_mobile_logo']['name'])) {
  157. $res=ds_upload_pic(ATTACH_COMMON,'site_mobile_logo', 'site_mobile_logo.png');
  158. if($res['code']){
  159. $file_name=$res['data']['file_name'];
  160. $upload['site_mobile_logo'] = $file_name;
  161. }else{
  162. $this->error($res['msg']);
  163. }
  164. }
  165. if (!empty($upload['site_mobile_logo'])) {
  166. $update_array['site_mobile_logo'] = $upload['site_mobile_logo'];
  167. }
  168. if (!empty($_FILES['site_logowx']['name'])) {
  169. $res=ds_upload_pic(ATTACH_COMMON,'site_logowx', 'site_logowx.png');
  170. if($res['code']){
  171. $file_name=$res['data']['file_name'];
  172. $upload['site_logowx'] = $file_name;
  173. }else{
  174. $this->error($res['msg']);
  175. }
  176. }
  177. if (!empty($upload['site_logowx'])) {
  178. $update_array['site_logowx'] = $upload['site_logowx'];
  179. }
  180. if (!empty($_FILES['business_licence']['name'])) {
  181. $res=ds_upload_pic(ATTACH_COMMON,'business_licence', 'business_licence.png');
  182. if($res['code']){
  183. $file_name=$res['data']['file_name'];
  184. $upload['business_licence'] = $file_name;
  185. }else{
  186. $this->error($res['msg']);
  187. }
  188. }
  189. if (!empty($upload['business_licence'])) {
  190. $update_array['business_licence'] = $upload['business_licence'];
  191. }
  192. $result = $config_model->editConfig($update_array);
  193. if ($result) {
  194. $this->log(lang('ds_edit') . lang('web_set'), 1);
  195. $this->success(lang('ds_common_save_succ'), 'Config/logo');
  196. } else {
  197. $this->log(lang('ds_edit') . lang('web_set'), 0);
  198. }
  199. }
  200. }
  201. /**
  202. * 敏感词过滤设置
  203. */
  204. public function word_filter() {
  205. $config_model = model('config');
  206. if (!request()->isPost()) {
  207. $list_config = rkcache('config', true);
  208. View::assign('list_config', $list_config);
  209. /* 设置卖家当前栏目 */
  210. $this->setAdminCurItem('word_filter');
  211. return View::fetch();
  212. } else {
  213. $update_array = array();
  214. $update_array['word_filter_open'] = intval(input('post.word_filter_open'));
  215. $update_array['word_filter_appid'] = trim(input('post.word_filter_appid'));
  216. $update_array['word_filter_secret'] = trim(input('post.word_filter_secret'));
  217. $result = $config_model->editConfig($update_array);
  218. if ($result === true) {
  219. $this->log(lang('ds_edit') . lang('word_filter_set'), 1);
  220. $this->success(lang('ds_common_save_succ'));
  221. } else {
  222. $this->log(lang('ds_edit') . lang('word_filter_set'), 0);
  223. $this->error(lang('ds_common_save_fail'));
  224. }
  225. }
  226. }
  227. /**
  228. * 防灌水设置
  229. */
  230. public function dump() {
  231. $config_model = model('config');
  232. if (!request()->isPost()) {
  233. $list_config = rkcache('config', true);
  234. View::assign('list_config', $list_config);
  235. /* 设置卖家当前栏目 */
  236. $this->setAdminCurItem('dump');
  237. return View::fetch();
  238. } else {
  239. $update_array = array();
  240. $update_array['guest_comment'] = intval(input('post.guest_comment'));
  241. $update_array['captcha_status_login'] = intval(input('post.captcha_status_login'));
  242. $update_array['captcha_status_register'] = intval(input('post.captcha_status_register'));
  243. $update_array['captcha_status_goodsqa'] = intval(input('post.captcha_status_goodsqa'));
  244. $update_array['captcha_status_storelogin'] = intval(input('post.captcha_status_storelogin'));
  245. $update_array['member_normal_register'] = intval(input('post.member_normal_register'));
  246. $result = $config_model->editConfig($update_array);
  247. if ($result === true) {
  248. $this->log(lang('ds_edit') . lang('dis_dump'), 1);
  249. $this->success(lang('ds_common_save_succ'));
  250. } else {
  251. $this->log(lang('ds_edit') . lang('dis_dump'), 0);
  252. $this->error(lang('ds_common_save_fail'));
  253. }
  254. }
  255. }
  256. /*
  257. * 设置自动收货时间
  258. */
  259. public function auto() {
  260. $config_model = model('config');
  261. if (!request()->isPost()) {
  262. $list_config = rkcache('config', true);
  263. View::assign('list_config', $list_config);
  264. /* 设置卖家当前栏目 */
  265. $this->setAdminCurItem('auto');
  266. return View::fetch();
  267. } else {
  268. $order_auto_receive_day = intval(input('post.order_auto_receive_day'));
  269. $order_auto_cancel_day = intval(input('post.order_auto_cancel_day'));
  270. $code_invalid_refund = intval(input('post.code_invalid_refund'));
  271. $store_bill_cycle = intval(input('post.store_bill_cycle'));
  272. if ($order_auto_receive_day < 1 || $order_auto_receive_day > 100) {
  273. $this->error(lang('automatic_confirmation_receipt') . '1-100' . lang('numerical'));
  274. }
  275. if ($order_auto_cancel_day < 1 || $order_auto_cancel_day > 50) {
  276. $this->error(lang('automatic_confirmation_receipt') . '1-50' . lang('numerical'));
  277. }
  278. if ($code_invalid_refund < 1 || $code_invalid_refund > 100) {
  279. $this->error(lang('exchange_code_refunded_automatically') . '1-100' . lang('numerical'));
  280. }
  281. if ($store_bill_cycle < 7) {
  282. $this->error(lang('store_bill_cycle_error'));
  283. }
  284. $update_array['order_auto_receive_day'] = $order_auto_receive_day;
  285. $update_array['order_auto_cancel_day'] = $order_auto_cancel_day;
  286. $update_array['code_invalid_refund'] = $code_invalid_refund;
  287. $update_array['store_bill_cycle'] = $store_bill_cycle;
  288. $result = $config_model->editConfig($update_array);
  289. if ($result) {
  290. $this->log(lang('ds_edit') . lang('auto_set'), 1);
  291. $this->success(lang('ds_common_save_succ'), 'Config/auto');
  292. } else {
  293. $this->log(lang('ds_edit') . lang('auto_set'), 0);
  294. $this->error(lang('ds_common_save_fail'));
  295. }
  296. }
  297. }
  298. /**
  299. * 获取卖家栏目列表,针对控制器下的栏目
  300. */
  301. protected function getAdminItemList() {
  302. $menu_array = array(
  303. array(
  304. 'name' => 'base',
  305. 'text' => lang('ds_base'),
  306. 'url' => (string) url('Config/base')
  307. ),
  308. array(
  309. 'name' => 'logo',
  310. 'text' => lang('ds_logo'),
  311. 'url' => (string) url('Config/logo')
  312. ),
  313. array(
  314. 'name' => 'dump',
  315. 'text' => lang('dis_dump'),
  316. 'url' => (string) url('Config/dump')
  317. ),
  318. array(
  319. 'name' => 'word_filter',
  320. 'text' => lang('word_filter_set'),
  321. 'url' => (string) url('Config/word_filter')
  322. ),
  323. array(
  324. 'name' => 'auto',
  325. 'text' => lang('automatic_execution_time_setting'),
  326. 'url' => (string) url('Config/auto')
  327. ),
  328. );
  329. return $menu_array;
  330. }
  331. }