PaymentController.class.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. /**
  3. * lionfish 商城系统
  4. *
  5. * ==========================================================================
  6. * @link http://www.liofis.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license http://www.liofis.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Admin\Controller;
  15. class PaymentController extends CommonController{
  16. protected function _initialize(){
  17. parent::_initialize();
  18. $this->breadcrumb1='系统';
  19. $this->breadcrumb2='支付方式';
  20. }
  21. public function index(){
  22. $this->list=M('payment')->field('payment_code,payment_name,payment_state')->select();
  23. $this->display();
  24. }
  25. function edit(){
  26. $code=I('code');
  27. if(IS_POST){
  28. $data = array();
  29. $data['payment_state'] = intval($_POST["payment_state"]);
  30. $payment_id = intval($_POST["payment_id"]);
  31. $payment_config = '';
  32. $config_array = explode(',',$_POST["config_name"]);//配置参数
  33. if(is_array($config_array) && !empty($config_array)) {
  34. $config_info = array();
  35. foreach ($config_array as $k) {
  36. $config_info[$k] = trim($_POST[$k]);
  37. }
  38. $payment_config = serialize($config_info);
  39. }
  40. $data['payment_config'] = $payment_config;
  41. $r=M('payment')->where(array('payment_id'=>$payment_id))->save($data);
  42. if($r){
  43. $this->success('编辑成功',U('Payment/index'));
  44. }else{
  45. $this->error('编辑失败');
  46. }
  47. die;
  48. }
  49. $this->action=U('Payment/edit');
  50. $payment = M('payment')->where(array('payment_code'=>$code))->find();
  51. $this->config_array=array(
  52. 'id'=>$payment['payment_id'],
  53. 'config'=>empty($payment['payment_config'])?'':unserialize($payment['payment_config']),
  54. 'payment_state'=>$payment['payment_state']
  55. );
  56. switch ($code) {
  57. case 'alipay':
  58. $crumbs='支付宝';
  59. break;
  60. }
  61. $this->crumbs=$crumbs;
  62. $this->display($code);
  63. }
  64. }
  65. ?>