diff --git a/service/Application/Admin/Controller/PaymentController.class.php b/service/Application/Admin/Controller/PaymentController.class.php index abe623f48..4ea3c6f4c 100755 --- a/service/Application/Admin/Controller/PaymentController.class.php +++ b/service/Application/Admin/Controller/PaymentController.class.php @@ -14,6 +14,7 @@ use Service\ResourcesService; class PaymentController extends CommonController { private $payment_dir; + private $payment_business_type_all; /** * [_initialize 前置操作-继承公共前置方法] @@ -35,6 +36,9 @@ class PaymentController extends CommonController // 插件目录 $this->payment_dir = APP_PATH.'Library'.DS.'Payment'.DS; + + // 支付业务类型 + $this->payment_business_type_all = C('payment_business_type_all'); } /** @@ -279,6 +283,28 @@ class PaymentController extends CommonController } } + /** + * [PowerCheck 权限校验] + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @datetime 2018-09-29T00:01:49+0800 + */ + private function PowerCheck() + { + // 主目录权限 + if(!is_writable(ROOT_PATH)) + { + $this->ajaxReturn(L('common_is_writable_error').'['.ROOT_PATH.']', -3); + } + + // 插件权限 + if(!is_writable($this->payment_dir)) + { + $this->ajaxReturn(L('common_is_writable_error').'['.$this->payment_dir.']', -3); + } + } + /** * 安装 * @author Devil @@ -294,6 +320,9 @@ class PaymentController extends CommonController $this->error(L('common_unauthorized_access')); } + // 权限 + $this->PowerCheck(); + // 参数 if(empty($_POST['id'])) { @@ -317,6 +346,9 @@ class PaymentController extends CommonController { if($m->add($data)) { + // 入口文件生成 + $this->PaymentEntranceCreated($payment); + $this->ajaxReturn(L('common_install_success')); } else { $this->ajaxReturn(L('common_install_error'), -100); @@ -351,8 +383,12 @@ class PaymentController extends CommonController } // 开始卸载 - if(M('Payment')->where(['payment'=>I('id')])->delete()) + $payment = I('id'); + if(M('Payment')->where(['payment'=>$payment])->delete()) { + // 删除入口文件 + $this->PaymentEntranceDelete($payment); + $this->ajaxReturn(L('common_uninstall_success')); } else { $this->ajaxReturn(L('common_uninstall_error'), -100); @@ -374,6 +410,9 @@ class PaymentController extends CommonController $this->error(L('common_unauthorized_access')); } + // 权限 + $this->PowerCheck(); + // 参数 if(empty($_POST['id'])) { @@ -381,7 +420,8 @@ class PaymentController extends CommonController } // 是否存在 - $file = $this->payment_dir.I('id').'.class.php'; + $payment = I('id'); + $file = $this->payment_dir.$payment.'.class.php'; if(!file_exists($file)) { $this->ajaxReturn(L('common_data_no_exist_error'), -2); @@ -398,6 +438,9 @@ class PaymentController extends CommonController $this->ajaxReturn(L('common_operation_delete_error'), -100); } + // 删除入口文件 + $this->PaymentEntranceDelete($payment); + $this->ajaxReturn(L('common_operation_delete_success')); } @@ -417,6 +460,9 @@ class PaymentController extends CommonController $this->error(L('common_unauthorized_access')); } + // 权限 + $this->PowerCheck(); + // 文件上传校验 $error = FileUploadError('file'); if($error !== true) @@ -453,5 +499,98 @@ class PaymentController extends CommonController } $this->ajaxReturn(L('common_upload_success')); } + + /** + * [PaymentEntranceCreated 入口文件创建] + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @datetime 2018-09-28T23:38:52+0800 + * @param [string] $payment [支付唯一标记] + */ + private function PaymentEntranceCreated($payment) + { + // 批量创建 + foreach($this->payment_business_type_all as $v) + { +// 异步 +$notify=<< +php; + +// 同步 +$respond=<< +php; + $name = strtolower($v['name']); + @file_put_contents(ROOT_PATH.'payment_'.$name.'_'.strtolower($payment).'_notify.php', $notify); + @file_put_contents(ROOT_PATH.'payment_'.$name.'_'.strtolower($payment).'_respond.php', $respond); + } + } + + /** + * [PaymentEntranceDelete 入口文件删除] + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @datetime 2018-09-28T23:38:52+0800 + * @param [string] $payment [支付唯一标记] + */ + private function PaymentEntranceDelete($payment) + { + $payment = strtolower($payment); + foreach($this->payment_business_type_all as $v) + { + $name = strtolower($v['name']); + if(file_exists(ROOT_PATH.'payment_'.$name.'_'.$payment.'_notify.php')) + { + @unlink(ROOT_PATH.'payment_'.$name.'_'.$payment.'_notify.php'); + } + if(file_exists(ROOT_PATH.'payment_'.$name.'_'.$payment.'_respond.php')) + { + @unlink(ROOT_PATH.'payment_'.$name.'_'.$payment.'_respond.php'); + } + } + } } ?> \ No newline at end of file diff --git a/service/Application/Common/Conf/config.php b/service/Application/Common/Conf/config.php index 1dd3011f1..55e7f03cd 100755 --- a/service/Application/Common/Conf/config.php +++ b/service/Application/Common/Conf/config.php @@ -114,22 +114,19 @@ return array( // 图片host, 数据库图片地址以/Public/...开头 - 'IMAGE_HOST' => substr(__MY_URL__, 0, -1), + 'IMAGE_HOST' => substr(__MY_URL__, 0, -1), // 缓存路径 - 'data_cache_dir' => TEMP_PATH, + 'data_cache_dir' => TEMP_PATH, // 开启U带域名 - 'url_domain_deploy' => true, + 'url_domain_deploy' => true, // 支付宝appid - 'alipay_mini_appid' => '2018071160553916', + 'alipay_mini_appid' => '2018071160553916', - // 支付宝密钥 - 'alipay_key_secret' => - [ - 'id' => '2088131739974941', - 'key' => 'tbhpeal8zsqzxc0b5s6r2jrvzjoo74il', - 'name' => 'byjzglm@dingtalk.com', - ], + // 支付业务类型,支付插件根据业务类型自动生成支付入口文件 + 'payment_business_type_all' => [ + ['name' => 'Order', 'desc' => '订单'], + ], ); \ No newline at end of file diff --git a/service/Application/Home/Controller/BuyController.class.php b/service/Application/Home/Controller/BuyController.class.php old mode 100644 new mode 100755 diff --git a/service/Application/Home/Controller/CartController.class.php b/service/Application/Home/Controller/CartController.class.php old mode 100644 new mode 100755 diff --git a/service/Application/Home/Controller/CategoryController.class.php b/service/Application/Home/Controller/CategoryController.class.php old mode 100644 new mode 100755 diff --git a/service/Application/Home/Controller/OrderController.class.php b/service/Application/Home/Controller/OrderController.class.php old mode 100644 new mode 100755 diff --git a/service/Application/Home/Controller/RegionController.class.php b/service/Application/Home/Controller/RegionController.class.php old mode 100644 new mode 100755 diff --git a/service/Application/Home/Controller/UserAddressController.class.php b/service/Application/Home/Controller/UserAddressController.class.php old mode 100644 new mode 100755 diff --git a/service/Application/Home/Lang/zh-cn/buy.php b/service/Application/Home/Lang/zh-cn/buy.php old mode 100644 new mode 100755 diff --git a/service/Application/Home/Lang/zh-cn/useraddress.php b/service/Application/Home/Lang/zh-cn/useraddress.php old mode 100644 new mode 100755 diff --git a/service/Application/Home/View/Default/Buy/Index.html b/service/Application/Home/View/Default/Buy/Index.html old mode 100644 new mode 100755 diff --git a/service/Application/Home/View/Default/Cart/Index.html b/service/Application/Home/View/Default/Cart/Index.html old mode 100644 new mode 100755 diff --git a/service/Application/Home/View/Default/Category/Index.html b/service/Application/Home/View/Default/Category/Index.html old mode 100644 new mode 100755 diff --git a/service/Application/Home/View/Default/Lib/RegionLinkage.html b/service/Application/Home/View/Default/Lib/RegionLinkage.html old mode 100644 new mode 100755 diff --git a/service/Application/Home/View/Default/Order/Index.html b/service/Application/Home/View/Default/Order/Index.html old mode 100644 new mode 100755 diff --git a/service/Application/Home/View/Default/Public/PayError.html b/service/Application/Home/View/Default/Public/PayError.html old mode 100644 new mode 100755 diff --git a/service/Application/Home/View/Default/Public/PaySuccess.html b/service/Application/Home/View/Default/Public/PaySuccess.html old mode 100644 new mode 100755 diff --git a/service/Application/Home/View/Default/User/ModalLoginInfo.html b/service/Application/Home/View/Default/User/ModalLoginInfo.html old mode 100644 new mode 100755 diff --git a/service/Application/Home/View/Default/User/RegInfo.html b/service/Application/Home/View/Default/User/RegInfo.html old mode 100644 new mode 100755 diff --git a/service/Application/Home/View/Default/UserAddress/SaveInfo.html b/service/Application/Home/View/Default/UserAddress/SaveInfo.html old mode 100644 new mode 100755 diff --git a/service/Application/Library/Payment/Alipay.class.php b/service/Application/Library/Payment/Alipay.class.php old mode 100644 new mode 100755 diff --git a/service/Application/Runtime/Temp/8cde93cbd070139d84f31d26f8ea8f4d.php b/service/Application/Runtime/Temp/8cde93cbd070139d84f31d26f8ea8f4d.php old mode 100644 new mode 100755 diff --git a/service/Application/Runtime/Temp/a58f8070835be94249ea77f3601c6647.php b/service/Application/Runtime/Temp/a58f8070835be94249ea77f3601c6647.php old mode 100644 new mode 100755 diff --git a/service/Application/Service/BuyService.class.php b/service/Application/Service/BuyService.class.php old mode 100644 new mode 100755 diff --git a/service/Application/Service/OrderService.class.php b/service/Application/Service/OrderService.class.php old mode 100644 new mode 100755 index f0389660a..419fed9bd --- a/service/Application/Service/OrderService.class.php +++ b/service/Application/Service/OrderService.class.php @@ -69,13 +69,14 @@ class OrderService } // 发起支付 + $url = __MY_URL__.'payment_order_'.strtolower($payment[0]['payment']); $pay_data = array( 'out_user' => md5($params['user']['id']), 'order_sn' => date('YmdHis').$data['id'], 'name' => '订单支付', 'total_price' => $data['total_price'], - 'notify_url' => __MY_URL__.'notify_order.php', - 'call_back_url' => __MY_URL__.'respond_order.php', + 'notify_url' => $url.'_notify.php', + 'call_back_url' => $url.'_respond.php', ); $pay_name = '\Library\Payment\\'.$payment[0]['payment']; $ret = (new $pay_name($payment[0]['config']))->Pay($pay_data); @@ -106,11 +107,6 @@ class OrderService 'key_name' => 'user', 'error_msg' => '用户信息有误', ], - [ - 'checked_type' => 'empty', - 'key_name' => 'out_trade_no', - 'error_msg' => '支付回调参数缺失[out_trade_no]', - ], ]; $ret = params_checked($params, $p); if($ret !== true) @@ -118,28 +114,15 @@ class OrderService return DataReturn($ret, -1); } - // 获取订单信息 - $where = ['id'=>self::OutTradeNoParsing($params['out_trade_no']), 'user_id' => $params['user']['id']]; - $data = M('Order')->where($where)->field('id,status,payment_id')->find(); - if(empty($data)) - { - return DataReturn(L('common_data_no_exist_error'), -1); - } - if($data['status'] > 1) - { - $status_text = L('common_order_user_status')[$data['status']]['name']; - return DataReturn('状态不可操作['.$status_text.']', -1); - } - // 支付方式 - $payment = ResourcesService::PaymentList(['where'=>['id'=>$data['payment_id']]]); + $payment = ResourcesService::PaymentList(['where'=>['payment'=>PAYMENT_TYPE]]); if(empty($payment[0])) { return DataReturn('支付方式有误', -1); } // 支付数据校验 - $pay_name = '\Library\Payment\\'.$payment[0]['payment']; + $pay_name = '\Library\Payment\\'.PAYMENT_TYPE; return (new $pay_name($payment[0]['config']))->Respond(); } @@ -154,24 +137,24 @@ class OrderService */ public static function Notify($params = []) { - // 请求参数 - $p = [ - [ - 'checked_type' => 'empty', - 'key_name' => 'out_trade_no', - 'error_msg' => '支付回调参数缺失[out_trade_no]', - ], - ]; - $ret = params_checked($params, $p); - if($ret !== true) + // 支付方式 + $payment = ResourcesService::PaymentList(['where'=>['payment'=>PAYMENT_TYPE]]); + if(empty($payment[0])) { - file_put_contents('/data/www/project/shopxo/service/gggggg.txt', json_encode($_REQUEST)); - return DataReturn($ret, -1); + return DataReturn('支付方式有误', -1); + } + + // 支付数据校验 + $pay_name = '\Library\Payment\\'.PAYMENT_TYPE; + $ret = (new $pay_name($payment[0]['config']))->Respond(); + if(!isset($ret['code']) || $ret['code'] != 0) + { + return $ret; } // 获取订单信息 $m = M('Order'); - $where = ['id'=>self::OutTradeNoParsing($params['out_trade_no'])]; + $where = ['id'=>self::OutTradeNoParsing($ret['data']['out_trade_no'])]; $data = $m->where($where)->field('id,status,total_price,payment_id,user_id,shop_id')->find(); file_put_contents('/data/www/project/shopxo/service/dddddd.txt', json_encode($data)); if(empty($data)) @@ -184,22 +167,6 @@ class OrderService return DataReturn('状态不可操作['.$status_text.']', 0); } - // 支付方式 - $payment = ResourcesService::PaymentList(['where'=>['id'=>$data['payment_id']]]); - if(empty($payment[0])) - { - return DataReturn('支付方式有误', -1); - } - - // 支付数据校验 - $pay_name = '\Library\Payment\\'.$payment[0]['payment']; - $ret = (new $pay_name($payment[0]['config']))->Respond(); - if(!isset($ret['code']) || $ret['code'] != 0) - { - return $ret; - } - file_put_contents('/data/www/project/shopxo/service/rrrrrr.txt', json_encode($ret)); - // 兼容web版本支付参数 $buyer_email = isset($ret['data']['buyer_logon_id']) ? $ret['data']['buyer_logon_id'] : (isset($ret['data']['buyer_email']) ? $ret['data']['buyer_email'] : ''); $total_amount = isset($ret['data']['total_amount']) ? $ret['data']['total_amount'] : (isset($ret['data']['total_fee']) ? $ret['data']['total_fee'] : ''); @@ -217,7 +184,6 @@ class OrderService 'business_type' => 0, 'add_time' => time(), ]; - file_put_contents('/data/www/project/shopxo/service/llllll.txt', json_encode($pay_log_data)); M('PayLog')->add($pay_log_data); // 消息通知 @@ -235,7 +201,6 @@ class OrderService 'pay_time' => time(), 'upd_time' => time(), ); - file_put_contents('/data/www/project/shopxo/service/uuuuuu.txt', json_encode($upd_data)); if($m->where(['id'=>$data['id']])->save($upd_data)) { // 提交事务 diff --git a/service/Application/Service/ResourcesService.class.php b/service/Application/Service/ResourcesService.class.php old mode 100644 new mode 100755 diff --git a/service/Application/Service/SearchService.class.php b/service/Application/Service/SearchService.class.php old mode 100644 new mode 100755 diff --git a/service/Application/Service/UserService.class.php b/service/Application/Service/UserService.class.php old mode 100644 new mode 100755 diff --git a/service/Public/Home/Default/Css/Buy.css b/service/Public/Home/Default/Css/Buy.css old mode 100644 new mode 100755 diff --git a/service/Public/Home/Default/Css/Cart.css b/service/Public/Home/Default/Css/Cart.css old mode 100644 new mode 100755 diff --git a/service/Public/Home/Default/Css/Category.css b/service/Public/Home/Default/Css/Category.css old mode 100644 new mode 100755 diff --git a/service/Public/Home/Default/Css/Common.css b/service/Public/Home/Default/Css/Common.css index d190e8924..1d90f1511 100755 --- a/service/Public/Home/Default/Css/Common.css +++ b/service/Public/Home/Default/Css/Common.css @@ -416,7 +416,7 @@ background:url(../Images/ibar_sprites.png) no-repeat;background-position:0px -23 /* 公共错误提示页面 */ .tips-error, .tips-success { margin: 10% 0; } .tips-pay-success, .tips-pay-error { box-shadow: none; text-align: center; } -.tips-error i.am-icon-times-circle, .tips-success i.am-icon-check-circle { font-size: 32px; } +.tips-error i.am-icon-times-circle, .tips-success i.am-icon-check-circle { font-size: 26px; } .tips-error i.am-icon-times-circle { color: #F44336; } .tips-success i.am-icon-check-circle { color: #4CAF50; } .tips-error span.msg, .tips-success span.msg { font-size: 22px; margin-left: 10px; } diff --git a/service/Public/Home/Default/Css/UserAddress.css b/service/Public/Home/Default/Css/UserAddress.css old mode 100644 new mode 100755 diff --git a/service/Public/Home/Default/Js/Buy.js b/service/Public/Home/Default/Js/Buy.js old mode 100644 new mode 100755 diff --git a/service/Public/Home/Default/Js/Cart.js b/service/Public/Home/Default/Js/Cart.js old mode 100644 new mode 100755 diff --git a/service/Public/Upload/common/images/20180911134641_logo.png b/service/Public/Upload/common/images/20180911134641_logo.png old mode 100644 new mode 100755 diff --git a/service/Public/Upload/common/images/20180911144001_logo.png b/service/Public/Upload/common/images/20180911144001_logo.png old mode 100644 new mode 100755 diff --git a/service/notify_order.php b/service/payment_order_alipay_notify.php similarity index 81% rename from service/notify_order.php rename to service/payment_order_alipay_notify.php index 9703594bd..0d3fa78ce 100644 --- a/service/notify_order.php +++ b/service/payment_order_alipay_notify.php @@ -9,6 +9,9 @@ $_GET['m'] = 'Api'; $_GET['c'] = 'OrderNotify'; $_GET['a'] = 'Notify'; +// 支付模块标记 +define('PAYMENT_TYPE', 'Alipay'); + // 引入公共入口文件 require './core.php'; diff --git a/service/respond_order.php b/service/payment_order_alipay_respond.php similarity index 80% rename from service/respond_order.php rename to service/payment_order_alipay_respond.php index 64b22b089..198a1de1d 100644 --- a/service/respond_order.php +++ b/service/payment_order_alipay_respond.php @@ -9,6 +9,9 @@ $_GET['m'] = 'Home'; $_GET['c'] = 'Order'; $_GET['a'] = 'Respond'; +// 支付模块标记 +define('PAYMENT_TYPE', 'Alipay'); + // 引入公共入口文件 require './core.php';