CashondeliveryController.class.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. /**
  3. * lionfish 商城系统
  4. *
  5. *
  6. * @author cy 2021-04-26
  7. * @desc 货到付款设置
  8. *
  9. */
  10. namespace Seller\Controller;
  11. class CashondeliveryController extends CommonController{
  12. protected $menu;
  13. protected function _initialize(){
  14. parent::_initialize();
  15. $menu = array(
  16. 'title' => '货到付款',
  17. 'subtitle' => '货到付款',
  18. 'route' => 'cashondelivery/config',
  19. 'items' => array(
  20. array('title' => '设置', 'route' => 'cashondelivery/config'), )
  21. );
  22. $perm_url = strtolower(CONTROLLER_NAME) .'/'. strtolower(ACTION_NAME);
  23. $this->assign('perm_url', $perm_url );
  24. //组件权限方法===begin
  25. if(SELLERUID != 1)
  26. {
  27. $seller_info = M('seller')->field('s_role_id')->where( array('s_id' => SELLERUID ) )->find();
  28. $perm_role = M('lionfish_comshop_perm_role')->where( array('id' => $seller_info['s_role_id']) )->find();
  29. $perms_str = $perm_role['perms2'];
  30. $items = [];
  31. $can_use_routearr = [];
  32. foreach( $menu['items'] as $val )
  33. {
  34. $val_route = str_replace('/','.', $val['route']);
  35. if( strpos($perms_str, '.'.$val_route) !== false )
  36. {
  37. $items[] = $val;
  38. $can_use_routearr[] = strtolower($val['route']);
  39. }
  40. }
  41. $menu['items'] = $items;
  42. if( empty($can_use_routearr) )
  43. {
  44. $this->redirect( 'application/index', [], 1,'您没有当前应用权限' );
  45. }else if( !in_array($perm_url , $can_use_routearr ) )
  46. {
  47. $this->redirect( $can_use_routearr[0] );
  48. }
  49. }
  50. //组件方法end
  51. $this->menu = $menu;
  52. $this->assign('menu', $menu );
  53. }
  54. public function config()
  55. {
  56. $_GPC = I('request.');
  57. if (IS_POST) {
  58. $data = ((is_array($_GPC['parameter']) ? $_GPC['parameter'] : array()));
  59. $data['isopen_cashondelivery'] = isset($data['isopen_cashondelivery']) ? $data['isopen_cashondelivery'] : 0;
  60. $data['isopen_cashondelivery_communityhead'] = isset($data['isopen_cashondelivery_communityhead']) ? $data['isopen_cashondelivery_communityhead'] : 0;
  61. $data['isopen_cashondelivery_express'] = isset($data['isopen_cashondelivery_express']) ? $data['isopen_cashondelivery_express'] : 0;
  62. $data['isopen_cashondelivery_localtown'] = isset($data['isopen_cashondelivery_localtown']) ? $data['isopen_cashondelivery_localtown'] : 0;
  63. $data['isopen_cashondelivery_hexiao'] = isset($data['isopen_cashondelivery_hexiao']) ? $data['isopen_cashondelivery_hexiao'] : 0;
  64. $data['isopen_cashondelivery_code'] = isset($data['isopen_cashondelivery_code']) ? $data['isopen_cashondelivery_code'] : 0;
  65. $data['cashondelivery_code_img'] = isset($data['cashondelivery_code_img']) ? $data['cashondelivery_code_img'] : '';
  66. D('Seller/Config')->update($data);
  67. show_json(1, array('url' => $_SERVER['HTTP_REFERER']) );
  68. die();
  69. }
  70. $data = D('Seller/Config')->get_all_config();
  71. $this->data = $data;
  72. $this->display();
  73. }
  74. }
  75. ?>