diff --git a/application/admin/form/Paylog.php b/application/admin/form/Paylog.php index b6c040d8872a351877eb6ffd470d640c4b9caaa6..e59af9ff06b57613d5fb23592d951808d3d8d3c2 100644 --- a/application/admin/form/Paylog.php +++ b/application/admin/form/Paylog.php @@ -43,6 +43,7 @@ class Paylog 'key_field' => 'id', 'is_search' => 1, 'search_url' => MyUrl('admin/paylog/index'), + 'is_middle' => 0, ], // 表单配置 'form' => [ @@ -60,6 +61,15 @@ class Paylog 'placeholder' => '请输入用户名/昵称/手机/邮箱', ], ], + [ + 'label' => '支付单号', + 'view_type' => 'field', + 'view_key' => 'log_no', + 'search_config' => [ + 'form_type' => 'input', + 'where_type' => '=', + ], + ], [ 'label' => '支付方式', 'view_type' => 'module', @@ -89,6 +99,24 @@ class Paylog 'is_multiple' => 1, ], ], + [ + 'label' => '业务订单金额(元)', + 'view_type' => 'field', + 'view_key' => 'total_price', + 'search_config' => [ + 'form_type' => 'section', + 'is_point' => 1, + ], + ], + [ + 'label' => '支付金额(元)', + 'view_type' => 'field', + 'view_key' => 'pay_price', + 'search_config' => [ + 'form_type' => 'section', + 'is_point' => 1, + ], + ], [ 'label' => '业务类型', 'view_type' => 'field', @@ -115,24 +143,6 @@ class Paylog 'where_handle_custom' => 'WhereValueBusinessInfo', ], ], - [ - 'label' => '业务订单金额(元)', - 'view_type' => 'field', - 'view_key' => 'total_price', - 'search_config' => [ - 'form_type' => 'section', - 'is_point' => 1, - ], - ], - [ - 'label' => '支付金额(元)', - 'view_type' => 'field', - 'view_key' => 'pay_price', - 'search_config' => [ - 'form_type' => 'section', - 'is_point' => 1, - ], - ], [ 'label' => '支付平台交易号', 'view_type' => 'field', diff --git a/application/admin/view/default/paylog/module/business_list.html b/application/admin/view/default/paylog/module/business_list.html index ad9a1dd2cd81a52c209b8343c84da9ea30aabdd3..1ff5f5af0d71c180c944dd34d2905a08347c64ef 100644 --- a/application/admin/view/default/paylog/module/business_list.html +++ b/application/admin/view/default/paylog/module/business_list.html @@ -1,6 +1,6 @@ {{if !empty($module_data) and !empty($module_data['business_list']) and is_array($module_data['business_list'])}} -
+
{{foreach $module_data.business_list as $v}}
diff --git a/application/index/controller/Order.php b/application/index/controller/Order.php index 28f1159187b13632ebae2ff3efe7409bc587ac8f..192f82a9def053f79753529c1121d062a0c6b9cd 100755 --- a/application/index/controller/Order.php +++ b/application/index/controller/Order.php @@ -74,6 +74,9 @@ class Order extends Common ]; $ret = OrderService::OrderList($data_params); + // 发起支付 - 支付方式 + $this->assign('buy_payment_list', PaymentService::BuyPaymentList(['is_enable'=>1, 'is_open_user'=>1])); + // 加载百度地图api $this->assign('is_load_baidu_map_api', 1); @@ -100,7 +103,7 @@ class Order extends Common $data = $this->OrderFirst(); if(!empty($data)) { - // 发起支付 - 支付方式 + // 发起支付 - 支付方式 $this->assign('buy_payment_list', PaymentService::BuyPaymentList(['is_enable'=>1, 'is_open_user'=>1])); // 虚拟销售配置 @@ -111,7 +114,7 @@ class Order extends Common $this->assign('is_load_baidu_map_api', 1); // 浏览器名称 - $this->assign('home_seo_site_title', SeoService::BrowserSeoTitle('订单详情', 1)); + $this->assign('home_seo_site_title', SeoService::BrowserSeoTitle('订单详情', 1)); // 数据赋值 $this->assign('data', $data); @@ -212,7 +215,7 @@ class Order extends Common */ public function Pay() { - $params = input(); + $params = $this->data_request; $params['user'] = $this->user; $ret = OrderService::Pay($params); if($ret['code'] == 0) @@ -235,7 +238,7 @@ class Order extends Common public function Respond() { // 参数 - $params = input(); + $params = $this->data_request; // 是否自定义状态 if(isset($params['appoint_status'])) diff --git a/application/index/view/default/order/detail.html b/application/index/view/default/order/detail.html index 515bba0b139ccca4b5a0cad124cfd91920b31c26..839c8a35dc1fd516000487187ee094a7ea1ebaf2 100755 --- a/application/index/view/default/order/detail.html +++ b/application/index/view/default/order/detail.html @@ -219,7 +219,7 @@ {{/if}} {{if in_array($data['status'], [1])}} - + {{/if}} {{if in_array($data['status'], [3])}} @@ -321,7 +321,7 @@
{{$data.address_data.province_name}} {{$data.address_data.city_name}} {{$data.address_data.county_name}} {{$data.address_data.address}} - {{if $data.order_model eq 2 and $data.address_data.lng gt 0 and $data.address_data.lat gt 0}} + {{if $data.address_data.lng gt 0 and $data.address_data.lat gt 0}} {{/if}}
@@ -377,24 +377,19 @@ {{foreach $data.items as $goods}} - - -
+ + +
- {{$goods.title}} + -
- {{$goods.title}} - {{if !empty($goods.spec) or !empty($goods['model'])}} -
    - {{if !empty($goods['model'])}} -
  • 型号:{{$goods.model}}
  • - {{/if}} - {{if !empty($goods.spec)}} - {{foreach $goods.spec as $spec}} -
  • {{$spec.type}}:{{$spec.value}}
  • - {{/foreach}} - {{/if}} +
    + {{$goods.title}} + {{if !empty($goods.spec)}} +
      + {{foreach $goods.spec as $spec}} +
    • {{$spec.type}}:{{$spec.value}}
    • + {{/foreach}}
    {{/if}}
    @@ -403,7 +398,9 @@ {{if $goods['original_price'] gt 0}} {{$price_symbol}}{{$goods.original_price}} {{/if}} - {{$price_symbol}}{{$goods.price}} + + {{$price_symbol}}{{$goods.price}} + x{{$goods.buy_number}} {{if isset($goods['returned_quantity']) and $goods['returned_quantity'] gt 0}} 已退 {{$goods.returned_quantity}} @@ -422,7 +419,7 @@
    已退 {{$goods.returned_quantity}} {{/if}} - + {{$price_symbol}}{{$goods.total_price}} {{if isset($goods['refund_price']) and $goods['refund_price'] gt 0}}
    已退 {{$goods.refund_price}} @@ -491,43 +488,7 @@
-
-
-
-

支付

- × -
-
-
- -
-

选择支付

- {{if !empty($buy_payment_list)}} -
    - {{foreach $buy_payment_list as $payment}} -
  • - {{if !empty($payment.logo)}} - - {{/if}} - {{$payment.name}} - -
  • - {{/foreach}} -
- {{/if}} - {{if empty($buy_payment_list)}} -
没有支付方式
- {{/if}} -
-
- - - -
-
-
-
-
+ {{include file="order/payment_popup" /}}
diff --git a/application/index/view/default/order/index.html b/application/index/view/default/order/index.html index bc0a035abc968f4f0a5f0926cc4a0b5a8a244d88..67378ba7e1931d240831cb21e1a0c546ffbdbcde 100755 --- a/application/index/view/default/order/index.html +++ b/application/index/view/default/order/index.html @@ -3,7 +3,13 @@ {{block name="form_operate_top"}} - + {__block__} +{{/block}} + + +{{block name="form_page_bottom"}} + + {{include file="order/payment_popup" /}} {{/block}} \ No newline at end of file diff --git a/application/index/view/default/order/module/operate.html b/application/index/view/default/order/module/operate.html index 30e4a238152473e40155c99d7c21fa9ae6d3f61f..70cf2ce202b83f0ea2d15e83e261d23a5ac5da80 100644 --- a/application/index/view/default/order/module/operate.html +++ b/application/index/view/default/order/module/operate.html @@ -11,10 +11,10 @@ {{/if}} {{if in_array($module_data['status'], [1])}} - + {{/if}} {{if in_array($module_data['status'], [3])}} + + + + + \ No newline at end of file diff --git a/application/index/view/default/public/module/user_form.html b/application/index/view/default/public/module/user_form.html index a790a628ecb07325f475c05f2f4219f88d31242f..fffc6632dd0998344f55520d4366ee9ce23d37f7 100644 --- a/application/index/view/default/public/module/user_form.html +++ b/application/index/view/default/public/module/user_form.html @@ -157,4 +157,7 @@ {{include file="public/footer" /}} - \ No newline at end of file + + + +{{block name="form_page_bottom"}}{{/block}} \ No newline at end of file diff --git a/application/service/OrderService.php b/application/service/OrderService.php index 9793527082ae7c78123220614f033c8a071f2a10..c00898b42928011d4b6ce07334fd6459434f794c 100755 --- a/application/service/OrderService.php +++ b/application/service/OrderService.php @@ -46,7 +46,7 @@ class OrderService $p = [ [ 'checked_type' => 'empty', - 'key_name' => 'id', + 'key_name' => 'ids', 'error_msg' => '订单id有误', ], [ @@ -61,28 +61,76 @@ class OrderService return DataReturn($ret, -1); } - // 获取订单信息 - $where = ['id'=>intval($params['id']), 'user_id' => $params['user']['id']]; - $order = Db::name('Order')->where($where)->find(); - if(empty($order)) - { - return DataReturn('资源不存在或已被删除', -1); - } - if($order['status'] != 1) + // 支付订单id + $ids = is_array($params['ids']) ? $params['ids'] : explode(',', urldecode($params['ids'])); + if(empty($ids)) { - $status_text = lang('common_order_user_status')[$order['status']]['name']; - return DataReturn('状态不可操作['.$status_text.']', -1); + return DataReturn('订单支付id有误', -1); } - // 订单支付前校验 - $ret = BuyService::OrderPayBeginCheck(['order_id'=>$order['id'], 'order_data'=>$order]); - if($ret['code'] != 0) + // 支付基础信息 + $order_payment_id = 0; + $client_type = ''; + $total_price = 0; + $success_count = 0; + $order_ids = []; + $order_nos = []; + + // 循环处理 + foreach($ids as $k=>$order_id) { - return $ret; + // 获取订单信息 + $where = ['id'=>intval($order_id), 'user_id' => $params['user']['id']]; + $order = Db::name('Order')->where($where)->find(); + if(empty($order)) + { + return DataReturn('资源不存在或已被删除', -1); + } + if($order['status'] != 1) + { + $status_text = lang('common_order_user_status')[$order['status']]['name']; + return DataReturn('状态不可操作['.$status_text.']'.$order['order_no'], -1); + } + + // 订单支付前校验 + $ret = BuyService::OrderPayBeginCheck(['order_id'=>$order['id'], 'order_data'=>$order]); + if($ret['code'] != 0) + { + return $ret; + } + + // 金额为0、走直接支付成功 + if($order['total_price'] <= 0.00) + { + $params['user']['user_name_view'] = '用户-'.$params['user']['user_name_view']; + $pay_result = self::OrderDirectSuccess([ + 'order' => $order, + 'payment' => $payment[0], + 'user' => $params['user'], + 'params' => $params, + ]); + if($pay_result['code'] == 0) + { + $success_count++; + } + return $pay_result; + } + + // 订单id/号集合 + $order_ids[] = $order['id']; + $order_nos[] = $order['order_no']; + $total_price += $order['total_price']; + + // 仅第一个订单获取的数据 + if($k == 0) + { + $client_type = $order['client_type']; + $order_payment_id = $order['payment_id']; + } } // 支付方式 - $payment_id = empty($params['payment_id']) ? $order['payment_id'] : intval($params['payment_id']); + $payment_id = empty($params['payment_id']) ? $order_payment_id : intval($params['payment_id']); $payment = PaymentService::PaymentList(['where'=>['id'=>$payment_id]]); if(empty($payment[0])) { @@ -90,30 +138,19 @@ class OrderService } // 更新订单支付方式信息 - if(!empty($params['payment_id']) && $params['payment_id'] != $order['payment_id']) + if($payment_id != $order_payment_id) { - Db::name('Order')->where(['id'=>$order['id']])->update([ + Db::name('Order')->where(['id'=>$ids])->update([ 'payment_id' => $payment_id, 'is_under_line' => in_array($payment[0]['payment'], config('shopxo.under_line_list')) ? 1 : 0, 'upd_time' => time(), ]); } - // 金额为0、走直接支付成功 - if($order['total_price'] <= 0.00) + // 是否直接跳转 + if($success_count > 0 && $success_count == count($ids)) { - $params['user']['user_name_view'] = '用户-'.$params['user']['user_name_view']; - $pay_result = self::OrderDirectSuccess([ - 'order' => $order, - 'payment' => $payment[0], - 'user' => $params['user'], - 'params' => $params, - ]); - if($pay_result['code'] == 0) - { - return DataReturn('支付成功', 0, ['data'=>MyUrl('index/order/respond', ['appoint_status'=>0])]); - } - return $pay_result; + return DataReturn('支付成功', 0, ['data'=>MyUrl('index/order/respond', ['appoint_status'=>0])]); } // 支付入口文件检查 @@ -148,18 +185,32 @@ class OrderService } } + // 新增支付日志 + $pay_log = self::OrderPayLogInsert([ + 'user_id' => $params['user']['id'], + 'business_ids' => $order_ids, + 'business_nos' => $order_nos, + 'total_price' => $total_price, + 'payment' => $payment[0]['payment'], + 'payment_name' => $payment[0]['name'], + ]); + if($pay_log['code'] != 0) + { + return $pay_log; + } + // 发起支付数据 $pay_data = array( 'user' => $params['user'], 'out_user' => md5($params['user']['id']), - 'order_id' => $order['id'], - 'order_no' => $order['order_no'], + 'order_id' => $pay_log['data']['id'], + 'order_no' => $pay_log['data']['log_no'], 'name' => '订单支付', - 'total_price' => $order['total_price'], - 'client_type' => $order['client_type'], + 'total_price' => $total_price, + 'client_type' => $client_type, 'notify_url' => $url.'_notify.php', 'call_back_url' => $call_back_url, - 'redirect_url' => MyUrl('index/order/detail', ['id'=>$order['id']]), + 'redirect_url' => MyUrl('index/order/index'), 'site_name' => MyC('home_site_name', 'ShopXO', true), 'ajax_url' => MyUrl('index/order/paycheck'), ); @@ -169,8 +220,7 @@ class OrderService $ret = HookReturnHandle(Hook::listen($hook_name, [ 'hook_name' => $hook_name, 'is_backend' => true, - 'order_id' => $order['id'], - 'order' => &$order, + 'order_ids' => $order_ids, 'params' => &$params, 'pay_data' => &$pay_data, ])); @@ -185,7 +235,21 @@ class OrderService if(!empty($_SERVER['HTTP_USER_AGENT']) && stripos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') !== false && empty($pay_data['user']['weixin_web_openid'])) { // 授权成功后回调订单详情页面重新自动发起支付 - $url = MyUrl('index/order/detail', ['id'=>$pay_data['order_id'], 'is_pay_auto'=>1, 'is_pay_submit'=>1]); + // 单个订单进入详情,则进入列表 + $weixin_params = [ + 'is_pay_auto' => 1, + 'is_pay_submit' => 1, + 'payment_id' => $payment_id, + ]; + if(count($order_ids) == 1) + { + $weixin_params['id'] = $order_ids[0]; + $weixin_params['ids'] = $order_ids[0]; + $url = MyUrl('index/order/detail', $weixin_params); + } else { + $weixin_params['ids'] = urldecode(implode(',', $order_ids)); + $url = MyUrl('index/order/index', $weixin_params); + } session('plugins_weixinwebauth_pay_callback_view_url', $url); } } @@ -221,6 +285,31 @@ class OrderService return DataReturn(empty($ret['msg']) ? '支付接口异常' : $ret['msg'], -1); } + /** + * 新增订单支付日志 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2020-07-28 + * @desc description + * @param [array] $params [输入参数] + */ + public static function OrderPayLogInsert($params = []) + { + $business_ids = isset($params['business_ids']) ? $params['business_ids'] : []; + $business_nos = isset($params['business_nos']) ? $params['business_nos'] : []; + return PayLogService::PayLogInsert([ + 'user_id' => isset($params['user_id']) ? intval($params['user_id']) : 0, + 'business_ids' => is_array($business_ids) ? $business_ids : [$business_ids], + 'business_nos' => is_array($business_nos) ? $business_nos : [$business_nos], + 'total_price' => isset($params['total_price']) ? PriceNumberFormat($params['total_price']) : 0.00, + 'subject' => '订单支付', + 'payment' => isset($params['payment']) ? $params['payment'] : '', + 'payment_name' => isset($params['payment_name']) ? $params['payment_name'] : '', + 'business_type' => '订单', + ]); + } + /** * 管理员订单支付 * @author Devil @@ -303,11 +392,29 @@ class OrderService { if($params['order']['total_price'] <= 0.00) { + // 新增支付日志 + $pay_log = self::OrderPayLogInsert([ + 'user_id' => $params['user']['id'], + 'business_ids' => $params['order']['id'], + 'business_nos' => $params['order']['order_no'], + 'total_price' => $params['order']['total_price'], + 'payment' => $params['payment']['payment'], + 'payment_name' => $params['payment']['name'], + ]); + if($pay_log['code'] != 0) + { + return $pay_log; + } + + // 新增日志订单 + $pay_log_data = []; + // 支付处理 $pay_params = [ - 'order' => $params['order'], - 'payment' => $params['payment'], - 'pay' => [ + 'order' => [$params['order']], + 'payment' => $params['payment'], + 'pay_log_data' => $pay_log['data'], + 'pay' => [ 'trade_no' => '', 'subject' => isset($params['params']['subject']) ? $params['params']['subject'] : '订单支付', 'buyer_user' => $params['user']['user_name_view'], @@ -336,11 +443,26 @@ class OrderService { if(in_array($params['payment']['payment'], config('shopxo.under_line_list'))) { + // 新增支付日志 + $pay_log = self::OrderPayLogInsert([ + 'user_id' => $params['user']['id'], + 'business_ids' => $params['order']['id'], + 'business_nos' => $params['order']['order_no'], + 'total_price' => $params['order']['total_price'], + 'payment' => $params['payment']['payment'], + 'payment_name' => $params['payment']['name'], + ]); + if($pay_log['code'] != 0) + { + return $pay_log; + } + // 支付处理 $pay_params = [ - 'order' => $params['order'], - 'payment' => $params['payment'], - 'pay' => [ + 'order' => $params['order'], + 'payment' => $params['payment'], + 'pay_log_data' => $pay_log['data'], + 'pay' => [ 'trade_no' => '', 'subject' => isset($params['params']['subject']) ? $params['params']['subject'] : '订单支付', 'buyer_user' => $params['user']['user_name_view'], @@ -433,31 +555,64 @@ class OrderService // 支付数据校验 $pay_name = 'payment\\'.PAYMENT_TYPE; - $ret = (new $pay_name($payment[0]['config']))->Respond(array_merge(input('get.'), input('post.'))); - if(!isset($ret['code']) || $ret['code'] != 0) + $pay_ret = (new $pay_name($payment[0]['config']))->Respond(array_merge(input('get.'), input('post.'))); + if(!isset($pay_ret['code']) || $pay_ret['code'] != 0) { - return $ret; + return $pay_ret; } - // 获取订单信息 - $where = ['order_no'=>$ret['data']['out_trade_no'], 'is_delete_time'=>0, 'user_is_delete_time'=>0]; - $order = Db::name('Order')->where($where)->find(); + // 获取支付日志订单 + $pay_log_data = Db::name('PayLog')->where([ + 'log_no' => $pay_ret['data']['out_trade_no'], + 'status' => 0, + ])->find(); + if(empty($pay_log_data)) + { + return DataReturn('日志订单有误', -1); + } + + // 获取关联信息 + $pay_log_value = Db::name('PayLogValue')->where(['pay_log_id'=>$pay_log_data['id']])->column('business_id'); + if(empty($pay_log_value)) + { + return DataReturn('日志订单关联信息有误', -1); + } + + // 获取订单 + $order_list = Db::name('Order')->where(['id'=>$pay_log_value, 'status'=>1])->select(); + if(empty($order_list)) + { + return DataReturn('订单信息有误', -1); + } + + // 订单数量是否一致 + if(count($order_list) != count($pay_log_value)) + { + return DataReturn('订单与日志记录数量不一致', -1); + } + + // 支付金额是否小于订单金额 + if($pay_ret['data']['pay_price'] < $pay_log_data['total_price']) + { + return DataReturn('支付金额小于日志订单金额', -1); + } // 支付处理 $pay_params = [ - 'order' => $order, - 'payment' => $payment[0], - 'pay' => [ - 'trade_no' => $ret['data']['trade_no'], - 'subject' => $ret['data']['subject'], - 'buyer_user' => $ret['data']['buyer_user'], - 'pay_price' => $ret['data']['pay_price'], + 'order' => $order, + 'payment' => $payment[0], + 'pay_log_data' => $pay_log_data, + 'pay' => [ + 'trade_no' => $pay_ret['data']['trade_no'], + 'subject' => $pay_ret['data']['subject'], + 'buyer_user' => $pay_ret['data']['buyer_user'], + 'pay_price' => $pay_ret['data']['pay_price'], ], ]; // 支付成功异步通知处理钩子 $hook_name = 'plugins_service_order_pay_notify_handle'; - $ret = HookReturnHandle(Hook::listen($hook_name, [ + $pay_ret = HookReturnHandle(Hook::listen($hook_name, [ 'hook_name' => $hook_name, 'is_backend' => true, 'payment' => $payment[0], @@ -474,24 +629,20 @@ class OrderService } /** - * [OrderPayHandle 订单支付处理] - * @author Devil - * @blog http://gong.gg/ - * @version 1.0.0 - * @datetime 2018-10-05T23:02:14+0800 - * @param [array] $params [输入参数] + * 订单支付处理 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2020-07-28 + * @desc description + * @param [array] $params [输入参数] */ public static function OrderPayHandle($params = []) { // 订单信息 - if(empty($params['order'])) - { - return DataReturn('资源不存在或已被删除', -1); - } - if($params['order']['status'] > 1) + if(empty($params['order']) || !is_array($params['order'])) { - $status_text = lang('common_order_user_status')[$params['order']['status']]['name']; - return DataReturn('状态不可操作['.$status_text.']', 0); + return DataReturn('订单数据不存在或类型有误', -1); } // 支付方式 @@ -500,104 +651,131 @@ class OrderService return DataReturn('支付方式有误', -1); } - // 订单支付成功处理前钩子 - $hook_name = 'plugins_service_order_pay_handle_begin'; - $ret = HookReturnHandle(Hook::listen($hook_name, [ - 'hook_name' => $hook_name, - 'is_backend' => true, - 'params' => &$params, - 'order_id' => $params['order']['id'] - ])); - if(isset($ret['code']) && $ret['code'] != 0) + // 日志订单 + if(empty($params['pay_log_data'])) { - return $ret; + return DataReturn('日志订单有误', -1); } - // 支付参数 - $pay_price = isset($params['pay']['pay_price']) ? $params['pay']['pay_price'] : 0; - - // 写入支付日志 - $pay_log_data = [ - 'user_id' => $params['order']['user_id'], - 'order_id' => $params['order']['id'], - 'total_price' => $params['order']['total_price'], - 'trade_no' => isset($params['pay']['trade_no']) ? $params['pay']['trade_no'] : '', - 'buyer_user' => isset($params['pay']['buyer_user']) ? $params['pay']['buyer_user'] : '', - 'pay_price' => $pay_price, - 'subject' => isset($params['pay']['subject']) ? $params['pay']['subject'] : '订单支付', - 'payment' => $params['payment']['payment'], - 'payment_name' => $params['payment']['name'], - 'business_type' => 1, - ]; - PayLogService::PayLogInsert($pay_log_data); - // 开启事务 Db::startTrans(); - // 消息通知 - $detail = '订单支付成功,金额'.PriceBeautify($params['order']['total_price']).'元'; - MessageService::MessageAdd($params['order']['user_id'], '订单支付', $detail, 1, $params['order']['id']); + // 循环处理 + foreach($params['order'] as $order) + { + if($order['status'] > 1) + { + // 事务回滚 + Db::rollback(); + $status_text = lang('common_order_user_status')[$order['status']]['name']; + return DataReturn('状态不可操作['.$status_text.']', 0); + } - // 订单更新数据 - $upd_data = [ - 'status' => 2, - 'pay_status' => 1, - 'pay_price' => $pay_price, - 'payment_id' => $params['payment']['id'], - 'pay_time' => time(), - 'upd_time' => time(), - ]; + // 订单支付成功处理前钩子 + $hook_name = 'plugins_service_order_pay_handle_begin'; + $ret = HookReturnHandle(Hook::listen($hook_name, [ + 'hook_name' => $hook_name, + 'is_backend' => true, + 'params' => &$params, + 'order_id' => $order['id'] + ])); + if(isset($ret['code']) && $ret['code'] != 0) + { + // 事务回滚 + Db::rollback(); + return $ret; + } - // 是否线下支付 - $upd_data['is_under_line'] = in_array($params['payment']['payment'], config('shopxo.under_line_list')) ? 1 : 0; + // 消息通知 + $detail = '订单支付成功,金额'.PriceBeautify($order['total_price']).'元'; + MessageService::MessageAdd($order['user_id'], '订单支付', $detail, 1, $order['id']); + + // 订单更新数据 + $upd_data = [ + 'status' => 2, + 'pay_status' => 1, + 'pay_price' => $order['total_price'], + 'payment_id' => $params['payment']['id'], + 'pay_time' => time(), + 'upd_time' => time(), + ]; - // 更新订单状态 - if(Db::name('Order')->where(['id'=>$params['order']['id']])->update($upd_data)) - { - // 添加状态日志 - if(self::OrderHistoryAdd($params['order']['id'], 2, $params['order']['status'], '支付', 0, '系统')) + // 是否线下支付 + $upd_data['is_under_line'] = in_array($params['payment']['payment'], config('shopxo.under_line_list')) ? 1 : 0; + + // 更新订单状态 + if(!Db::name('Order')->where(['id'=>$order['id']])->update($upd_data)) { - // 库存扣除 - $ret = BuyService::OrderInventoryDeduct(['order_id'=>$params['order']['id'], 'order_data'=>$upd_data]); - if($ret['code'] != 0) - { - // 事务回滚 - Db::rollback(); - return DataReturn($ret['msg'], -10); - } + // 事务回滚 + Db::rollback(); + return DataReturn('订单更新失败['.$order['id'].']', -10); + } - // 提交事务 - Db::commit(); + // 添加状态日志 + if(!self::OrderHistoryAdd($order['id'], 2, $order['status'], '支付', 0, '系统')) + { + // 事务回滚 + Db::rollback(); + return DataReturn('订单日志添加失败['.$order['id'].']', -10); + } - // 订单支付成功处理完毕钩子 - $hook_name = 'plugins_service_order_pay_success_handle_end'; - $ret = HookReturnHandle(Hook::listen($hook_name, [ - 'hook_name' => $hook_name, - 'is_backend' => true, - 'params' => $params, - 'order_id' => $params['order']['id'] - ])); + // 库存扣除 + $ret = BuyService::OrderInventoryDeduct(['order_id'=>$order['id'], 'order_data'=>$upd_data]); + if($ret['code'] != 0) + { + // 事务回滚 + Db::rollback(); + return DataReturn($ret['msg'], -10); + } - // 虚拟商品自动触发发货操作 - if($params['order']['order_model'] == 3) - { - self::OrderDelivery([ - 'id' => $params['order']['id'], - 'creator' => 0, - 'creator_name' => '系统', - 'user_id' => $params['order']['user_id'], - ]); - } + // 订单支付成功处理完毕钩子 + $hook_name = 'plugins_service_order_pay_success_handle_end'; + $ret = HookReturnHandle(Hook::listen($hook_name, [ + 'hook_name' => $hook_name, + 'is_backend' => true, + 'params' => $params, + 'order_id' => $order['id'] + ])); + if(isset($ret['code']) && $ret['code'] != 0) + { + // 事务回滚 + Db::rollback(); + return $ret; + } - return DataReturn('支付成功', 0); + // 虚拟商品自动触发发货操作 + if($order['order_model'] == 3) + { + self::OrderDelivery([ + 'id' => $order['id'], + 'creator' => 0, + 'creator_name' => '系统', + 'user_id' => $order['user_id'], + ]); } } - // 事务回滚 - Db::rollback(); + // 更新支付日志 + $pay_log_data = [ + 'log_id' => $params['pay_log_data']['id'], + 'trade_no' => isset($params['pay']['trade_no']) ? $params['pay']['trade_no'] : '', + 'buyer_user' => isset($params['pay']['buyer_user']) ? $params['pay']['buyer_user'] : '', + 'pay_price' => isset($params['pay']['pay_price']) ? $params['pay']['pay_price'] : 0, + 'subject' => isset($params['pay']['subject']) ? $params['pay']['subject'] : '订单支付', + 'payment' => $params['payment']['payment'], + 'payment_name' => $params['payment']['name'], + ]; + $ret = PayLogService::PayLogSuccess($pay_log_data); + if($ret['code'] != 0) + { + // 事务回滚 + Db::rollback(); + return $ret; + } - // 处理失败 - return DataReturn('处理失败', -100); + // 提交事务 + Db::commit(); + return DataReturn('支付成功', 0); } /** diff --git a/application/service/PayLogService.php b/application/service/PayLogService.php index 9a6465da082c6eeafa7df4ff8ec6c7fe0fb35e47..8543cbbd46a2725c85575d7948e65cf51d259d57 100755 --- a/application/service/PayLogService.php +++ b/application/service/PayLogService.php @@ -29,33 +29,132 @@ class PayLogService * @datetime 2019-05-07T00:57:36+0800 * @param [array] $params [输入参数] * @param [int] $user_id [用户id] - * @param [int] $order_id [业务订单id] + * @param [int] $business_ids [业务订单id] * @param [float] $total_price [业务订单实际金额] + * @param [string] $subject [业务订单名称] + * @param [int] $business_type [业务类型(0默认, 1订单, 2充值, ...)] + * @return [boolean] [成功true, 失败false] + */ + public static function PayLogInsert($params = []) + { + // 请求参数 + $p = [ + [ + 'checked_type' => 'empty', + 'key_name' => 'business_ids', + 'error_msg' => '业务id为空', + ], + [ + 'checked_type' => 'is_array', + 'key_name' => 'business_ids', + 'error_msg' => '业务id数据类型有误', + ], + [ + 'checked_type' => 'empty', + 'key_name' => 'user_id', + 'error_msg' => '用户id为空', + ], + [ + 'checked_type' => 'empty', + 'key_name' => 'business_type', + 'error_msg' => '业务类型为空', + ], + [ + 'checked_type' => 'empty', + 'key_name' => 'total_price', + 'error_msg' => '业务金额为空', + ], + [ + 'checked_type' => 'min', + 'key_name' => 'total_price', + 'checked_data' => 0.01, + 'error_msg' => '业务金额必须大于0', + ], + ]; + $ret = ParamsChecked($params, $p); + if($ret !== true) + { + return DataReturn($ret, -1); + } + + // 业务id + if(empty($params['business_ids'])) + { + return DataReturn('业务id为空', -1); + } + + // 日志主数据 + $data = [ + 'log_no' => date('YmdHis').GetNumberCode(6), + 'user_id' => intval($params['user_id']), + 'total_price' => PriceNumberFormat($params['total_price']), + 'business_type' => trim($params['business_type']), + 'subject' => isset($params['subject']) ? $params['subject'] : '', + 'payment' => isset($params['payment']) ? $params['payment'] : '', + 'payment_name' => isset($params['payment_name']) ? $params['payment_name'] : '', + 'add_time' => time(), + ]; + $pay_log_id = Db::name('PayLog')->insertGetId($data); + if($pay_log_id > 0) + { + $business_nos = isset($params['business_nos']) && is_array($params['business_nos']) ? $params['business_nos'] : []; + $value_data = []; + foreach($params['business_ids'] as $bk=>$bv) + { + $value_data[] = [ + 'pay_log_id' => $pay_log_id, + 'business_id' => $bv, + 'business_no' => isset($business_nos[$bk]) ? trim($business_nos[$bk]) : '', + 'add_time' => time(), + ]; + } + $res = Db::name('PayLogValue')->insertAll($value_data); + if($res >= count($params['business_ids'])) + { + $data['id'] = $pay_log_id; + return DataReturn('添加成功', 0, $data); + } + } + return DataReturn('支付订单添加失败', -100); + } + + /** + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2020-07-27 + * @desc description + * @param [int] $log_id [支付日志id] * @param [string] $trade_no [支付平台交易号] * @param [string] $buyer_user [支付平台用户帐号] * @param [float] $pay_price [支付金额] - * @param [string] $subject [业务订单名称] * @param [string] $payment [支付方式标记] * @param [string] $payment_name [支付方式名称] - * @param [int] $business_type [业务类型(0默认, 1订单, 2充值, ...)] - * @return [boolean] [成功true, 失败false] */ - public static function PayLogInsert($params = []) + public static function PayLogSuccess($params = []) { + // 参数 + if(empty($params['log_id'])) + { + return DataReturn('日志id有误', -100); + } + + // 更新数据 $data = [ - 'user_id' => isset($params['user_id']) ? intval($params['user_id']) : 0, - 'order_id' => isset($params['order_id']) ? intval($params['order_id']) : 0, - 'total_price' => isset($params['total_price']) ? PriceNumberFormat($params['total_price']) : 0.00, 'trade_no' => isset($params['trade_no']) ? $params['trade_no'] : '', 'buyer_user' => isset($params['buyer_user']) ? $params['buyer_user'] : '', 'pay_price' => isset($params['pay_price']) ? PriceNumberFormat($params['pay_price']) : 0.00, 'subject' => isset($params['subject']) ? $params['subject'] : '', 'payment' => isset($params['payment']) ? $params['payment'] : '', 'payment_name' => isset($params['payment_name']) ? $params['payment_name'] : '', - 'business_type' => isset($params['business_type']) ? intval($params['business_type']) : 0, - 'add_time' => time(), + 'status' => 1, + 'pay_time' => time(), ]; - return Db::name('PayLog')->insertGetId($data) > 0; + if(Db::name('PayLog')->where(['id'=>intval($params['log_id']), 'status'=>0])->update($data)) + { + return DataReturn('日志订单更新成功', 0); + } + return DataReturn('日志订单更新失败', -100); } /** diff --git a/public/static/common/css/common.css b/public/static/common/css/common.css index ec3049bc3b1380700b23da08d6abec29fc254444..bc01922f4ea3eb48668e0e9a4199cec1253d3fbc 100755 --- a/public/static/common/css/common.css +++ b/public/static/common/css/common.css @@ -16,6 +16,7 @@ ul { list-style: none; } .dl-content dd:not(:last-child) { border-bottom: 1px solid #efefef; } .dl-content dt, .dl-content dd { font-weight: normal !important; text-align: left; margin-top: 0px; line-height: 20px; min-height: 40px; padding-top: 10px; padding-bottom: 10px; } .dl-content-dd-only dd { padding-left: 0; } +.dl-content-dd-compact dd { line-height: 25px; min-height: 25px; padding: 0; } /** * 表单优化 diff --git a/public/static/common/js/common.js b/public/static/common/js/common.js index 1a66f488efa71dfe7e1eb293202bddba09c6dc62..5e899cf56a8afb5021831799f01110f0a4485792 100755 --- a/public/static/common/js/common.js +++ b/public/static/common/js/common.js @@ -1663,6 +1663,21 @@ function FromTableCheckedValues(form) return values; } +/** + * 判断变量是否为数组 + * @author Devil + * @blog http://gong.gg/ + * @version 1.0.0 + * @date 2020-07-28 + * @desc description + * @param {[mixed]} value [变量值] + */ +function IsArray(value) +{ + return Object.prototype.toString.call(value) == '[object Array]'; +} + + // 公共数据操作 $(function() diff --git a/public/static/index/default/css/order.css b/public/static/index/default/css/order.css index 1ffce7a22b8bae30f6efea90e573de7f187ecdc2..5950b6e9bb2b6b59fcdbe283bd8910909b16e290 100755 --- a/public/static/index/default/css/order.css +++ b/public/static/index/default/css/order.css @@ -1,79 +1,218 @@ /** - * 订单列表 + * 进度 */ -/* 列表 */ -table { width: 100%; } -table.data-list { margin-top: 10px; } -table.data-list-success, table.data-list-success td { border:1px solid #daf3ff; } -table.data-list { background:#FFF; border-radius:2px; -moz-border-radius:2px; -webkit-border-radius:2px; } -table.data-list * { font-size:12px; } -table.data-list td { padding:10px; vertical-align: top; } -.content-title th, table.data-list tr td+td { text-align:center; } - -.content img { width:80px; height:80px; } -.content p { margin:0px; } -.content a:hover { color:#F60; } -.row-content { min-width:102px; } -.content-checkbox-operate { padding:3px 5px; } -.submit-pay { margin-top: 5px; } -.wap-base, .base-operate { padding-top: 3px; } -.base-operate { margin-top: 3px; } -.content-hd td span { color: #666; } +ul.progress { + margin: 20px 0; +} +ul.progress li { + position: relative; + } +ul.progress li i.step { + display: block; + background-color: #e1e1e1; +} + +ul.progress li .digital { + background-color: #f7f7f7; + border-radius: 50px; + width: 36px; + height: 36px; + line-height: 26px; + text-align: center; + color: #e1e1e1; + font-weight: 700; + border: 6px solid #e1e1e1; +} + +ul.progress li .base .title { + font-weight: 500; + color: #666; +} + +ul.progress li .base .date { + color: #999; +} + +ul.progress li.steps-success .digital { + border: 6px solid #4CAF50; + color: #fff; +} +ul.progress li.steps-success .digital { + background-color: #82cc85; +} +ul.progress li.steps-success i.step { + background-color: #4CAF50; +} +ul.progress li.current .title { + color: #4CAF50; +} + +.base-right .icon-tips, .base-right .icon-success { + font-size: 50px; +} +.base-right .icon-tips { + color: #6980d0; +} +.base-right .icon-success { + color: #28801c; +} + @media only screen and (min-width: 641px) { - .row-content { width:25%; } - .row-price { width:15%; } - .row-number { width:10%; } - .row-goods-operate { width: 10%; } - .row-total-price { width:20%; } - .row-status { width:10%; } - .row-operate { width:10%; } + ul.progress { + overflow: hidden; + } + ul.progress li { + float: left; + width: 20%; + text-align: center; + } + ul.progress li i.step { + display: block; + height: 6px; + width: 100%; + position: absolute; + margin: 15px 0 0 -50%; + z-index: 1; + } + ul.progress li .digital { + position: absolute; + margin-left: calc(50% - 18px); + z-index: 2; + } + ul.progress li .base { + margin-top: 50px; + } } + @media only screen and (max-width: 641px) { - table.data-list td { padding: 5px; } - .row-content { width:40%; } - .row-goods-operate { width: 20%; } - .row-status { width:20%; } - .row-operate { width:20%; } + ul.progress li i.step { + height: 60px; + width: 6px; + margin-left: 15px; + } + + ul.progress li .base { + position: absolute; + left: 50px; + top: 0; + } + ul.progress li:not(:first-child) .base { + margin-top: 70px; + } } -/* 不在进行中 */ -table.data-list { border: 1px solid #eee; } -table.data-list td.row-number, table.data-list td.row-total-price, table.data-list td.row-status, table.data-list td.row-operate { border-right: 1px solid #eee; } -table.data-list td { border-bottom:1px solid #eee; } -table.data-list .content-hd td { background:#eee; border-bottom-color:#eee; } -table.data-list:hover { box-shadow:0 1px 1px #E4E4E4; background:#fbfbfb; } -table.data-list .base-operate { border-top: 1px dashed #eee; } +/** + * 文本列表 + */ +.items { + line-height: 30px; + overflow: hidden; +} +.items-detail { + color: #666; +} -/* 进行中 */ -table.data-ongoing { border: 1px solid #daf3ff; } -table.data-ongoing td.row-number, table.data-ongoing td.row-total-price, table.data-ongoing td.row-status, table.data-ongoing td.row-operate { border-right: 1px solid #daf3ff; } -table.data-ongoing td { border-bottom:1px solid #daf3ff; } -table.data-ongoing .content-hd td { background: #eaf8ff; border-bottom-color:#daf3ff; } -table.data-ongoing:hover { box-shadow:0 1px 1px #aed8ff; background:#f7fdff; } -table.data-ongoing .base-operate { border-top: 1px dashed #daf3ff; } +/** + * 订单详情基础 + */ +.order-base .am-panel { + -webkit-box-shadow: none; + box-shadow: none; +} +.order-base .am-panel-bd, .order-base .base-right { + padding: 5px 10px; +} +.order-base, .order-base .status { + overflow: hidden; +} +.order-base .status-name { + line-height: 80px; +} +.order-base .operation .am-btn { + margin-left: 15px; +} +.order-base .logistics { + margin-top: 10px; +} +.order-base .am-btn-block { + width: auto; + padding-left: 1em; + padding-right: 1em; +} +@media only screen and (min-width: 641px) { + .order-base .base-left, .order-base .base-right { + width: 50%; + float: left; + } + .order-base { + border: 1px solid #ddd; + } + .order-base .am-panel-default { + border-color: #fff; + } + .order-base .am-panel { + border: 0; + margin: 0; + } + .order-base .base-left { + border-right: 1px solid #ddd; + } + .order-base .base-right { + padding-top: 0; + } +} +@media only screen and (max-width: 641px) { + .order-base .base-right { + border: 1px solid #ddd; + } +} + + +/** + * 业务面板 + */ +.user-content-body .business-panel { + margin-top: 20px; + box-shadow: none; + -webkit-box-shadow: none; +} + + +/** + * 支付弹窗 + */ +.business-item h3 { border-bottom: 3px solid #e3e3e3; margin-top:5px; font-size: 14px;font-weight: 700; } +.business-item ul { padding: 10px 3px 5px 5px; overflow: hidden; } +.business-item ul li { border:1px solid transparent ;overflow: hidden; float: left; cursor: pointer; padding: 5px; border: 1px solid #eee; margin: 0 10px 10px 0; } +.business-item ul li img { width: 36px; height: 36px; } +.business-item ul li.selected { border-color: #d2364c ; position: relative; box-shadow: 0px 0 0px 1px #d2364c; } +.business-item ul li.selected i.icon-active { position: absolute; width: 10px; height: 10px; font-size: 0; line-height: 0; right: 0px; bottom: 0px; background: url(../images/sys-item-selected.gif) no-repeat right bottom; } +@media only screen and (min-width:640px) { + .business-item ul li {width:calc(33% - 5px); } + .business-item ul li:nth-child(3n) { margin-right: 0; } + .business-item ul li:hover { border: 1px solid #d2364c; box-shadow: 0px 0 0px 1px #d2364c; } +} +@media only screen and (max-width:640px) { + .business-item ul li { width: calc(50% - 5px); } + .business-item ul li:nth-child(2n) { margin-right: 0; } +} /** * 商品列表 */ -.goods-detail { position: relative; min-height: 80px; } -.goods-detail img { width: 80px; height: 80px; position: absolute; left: 0; top: 0; } -.goods-title { display: -webkit-box; max-height: 36px; overflow: hidden; text-overflow: ellipsis; -webkit-line-clamp: 2; -webkit-box-orient: vertical; } -.goods-title:hover { text-decoration: underline; } -.goods-base { float: left; top: 0; margin-left: 85px; } -.goods-attr { margin-top: 5px; } -.goods-attr li { color: #888; line-height: 16px; } -.original-price, .line-price, strong.total-price-content { font-family: Verdana,Tahoma,arial; } .original-price { color: #9c9c9c; text-decoration: line-through; } .line-price { color: #3c3c3c; } -.line-price, strong.total-price-content { font-weight: 700; } -strong.total-price-content { color: #d2364c; font-size: 14px; } -@media only screen and (max-width:640px) { - .goods-detail { min-height: 40px; } - .goods-detail .goods-images { display: none; } - .goods-base { margin-left: 0px; } - table.data-list td.row-status { border-left: 1px solid #eee; } - table.data-ongoing td.row-status { border-left: 1px solid #fff1f5; } + + +/** + * 虚拟销售 + */ +.fictitious-panel-container ul.am-list li:first-child { + border-top: 0; +} +.fictitious-panel-container ul.am-list li:last-child { + border-bottom: 0; } \ No newline at end of file diff --git a/public/static/index/default/css/order.detail.css b/public/static/index/default/css/order.detail.css deleted file mode 100755 index 95d34e40206ea31f0cebaa6f4dd7ab596bef5642..0000000000000000000000000000000000000000 --- a/public/static/index/default/css/order.detail.css +++ /dev/null @@ -1,253 +0,0 @@ -/** - * 进度 - */ -ul.progress { - margin: 20px 0; -} -ul.progress li { - position: relative; - } -ul.progress li i.step { - display: block; - background-color: #e1e1e1; -} - -ul.progress li .digital { - background-color: #f7f7f7; - border-radius: 50px; - width: 36px; - height: 36px; - line-height: 26px; - text-align: center; - color: #e1e1e1; - font-weight: 700; - border: 6px solid #e1e1e1; -} - -ul.progress li .base .title { - font-weight: 500; - color: #666; -} - -ul.progress li .base .date { - color: #999; -} - -ul.progress li.steps-success .digital { - border: 6px solid #4CAF50; - color: #fff; -} -ul.progress li.steps-success .digital { - background-color: #82cc85; -} -ul.progress li.steps-success i.step { - background-color: #4CAF50; -} -ul.progress li.current .title { - color: #4CAF50; -} - -.base-right .icon-tips, .base-right .icon-success { - font-size: 50px; -} -.base-right .icon-tips { - color: #6980d0; -} -.base-right .icon-success { - color: #28801c; -} - -@media only screen and (min-width: 641px) { - ul.progress { - overflow: hidden; - } - ul.progress li { - float: left; - width: 20%; - text-align: center; - } - ul.progress li i.step { - display: block; - height: 6px; - width: 100%; - position: absolute; - margin: 15px 0 0 -50%; - z-index: 1; - } - ul.progress li .digital { - position: absolute; - margin-left: calc(50% - 18px); - z-index: 2; - } - ul.progress li .base { - margin-top: 50px; - } -} - -@media only screen and (max-width: 641px) { - ul.progress li i.step { - height: 60px; - width: 6px; - margin-left: 15px; - } - - ul.progress li .base { - position: absolute; - left: 50px; - top: 0; - } - ul.progress li:not(:first-child) .base { - margin-top: 70px; - } -} - - -/** - * 文本列表 - */ -.items { - line-height: 30px; - overflow: hidden; -} -.items-detail { - color: #666; -} - - -/** - * 订单详情基础 - */ -.order-base .am-panel { - -webkit-box-shadow: none; - box-shadow: none; -} -.order-base .am-panel-bd, .order-base .base-right { - padding: 5px 10px; -} -.order-base, .order-base .status { - overflow: hidden; -} -.order-base .status-name { - line-height: 80px; -} -.order-base .operation .am-btn { - margin-left: 15px; -} -.order-base .logistics { - margin-top: 10px; -} -.order-base .am-btn-block { - width: auto; - padding-left: 1em; - padding-right: 1em; -} -@media only screen and (min-width: 641px) { - .order-base .base-left, .order-base .base-right { - width: 50%; - float: left; - } - .order-base { - border: 1px solid #ddd; - } - .order-base .am-panel-default { - border-color: #fff; - } - .order-base .am-panel { - border: 0; - margin: 0; - } - .order-base .base-left { - border-right: 1px solid #ddd; - } - .order-base .base-right { - padding-top: 0; - } -} -@media only screen and (max-width: 641px) { - .order-base .base-right { - border: 1px solid #ddd; - } -} - - -/** - * 业务面板 - */ -.user-content-body .business-panel { - margin-top: 20px; - box-shadow: none; - -webkit-box-shadow: none; -} - - -/** - * 支付弹窗 - */ -.business-item h3 { border-bottom: 3px solid #e3e3e3; margin-top:5px; font-size: 14px;font-weight: 700; } -.business-item ul { padding: 10px 3px 5px 5px; overflow: hidden; } -.business-item ul li { border:1px solid transparent ;overflow: hidden; float: left; cursor: pointer; padding: 5px; border: 1px solid #eee; margin: 0 10px 10px 0; } -.business-item ul li img { width: 36px; height: 36px; } -.business-item ul li.selected { border-color: #d2364c ; position: relative; box-shadow: 0px 0 0px 1px #d2364c; } -.business-item ul li.selected i.icon-active { position: absolute; width: 10px; height: 10px; font-size: 0; line-height: 0; right: 0px; bottom: 0px; background: url(../images/sys-item-selected.gif) no-repeat right bottom; } -@media only screen and (min-width:640px) { - .business-item ul li {width:calc(33% - 5px); } - .business-item ul li:nth-child(3n) { margin-right: 0; } - .business-item ul li:hover { border: 1px solid #d2364c; box-shadow: 0px 0 0px 1px #d2364c; } -} -@media only screen and (max-width:640px) { - .business-item ul li { width: calc(50% - 5px); } - .business-item ul li:nth-child(2n) { margin-right: 0; } -} - - -/** - * 商品列表 - */ -.order-goods { margin-top: 20px; } -.goods-detail img { width: 80px; height: 80px; position: absolute; left: 0; top: 0; } -.goods-detail { position: relative; min-height: 80px; } -.goods-title { display: block; max-height: 36px; overflow: hidden; text-overflow: ellipsis; } -.goods-title:hover { text-decoration: underline; } -.goods-base { float: left; top: 0; margin-left: 85px; } -.goods-attr li { color: #888; line-height: 16px; } -.original-price, .line-price { font-family: Verdana,Tahoma,arial; } -.original-price { color: #9c9c9c; text-decoration: line-through; } -.line-price { color: #3c3c3c; } -.line-price, strong.total-price-content, strong.total-price-content { font-weight: 700; font-family: Verdana,Tahoma,arial; } -strong.total-price-content { color: #d2364c; } -.am-table { margin-bottom: 10px; } -.am-table > tbody > tr > td { border-top: 1px solid #F5F5F5; } -.am-table > thead > tr > th { border-bottom: 1px solid #f7f7f7; } - -@media only screen and (min-width:640px) { - .cart-content table tr .base { width: 40%; } - .cart-content table tr .price { width: 20%; } - .cart-content table tr .number { width: 20%; } - .cart-content table tr .total-price { width: 20%; } - .cart-content { margin-top: 20px; } -} - - -/** - * 自提点地图 - */ -#popup-extraction-receive-map .am-popup-bd, -#map { - width: 100%; - height: 100%; - padding: 0; -} -#popup-extraction-receive-map .am-popup-hd { - border: 0; -} - - -/** - * 虚拟销售 - */ -.fictitious-panel-container ul.am-list li:first-child { - border-top: 0; -} -.fictitious-panel-container ul.am-list li:last-child { - border-bottom: 0; -} \ No newline at end of file diff --git a/public/static/index/default/js/order.js b/public/static/index/default/js/order.js index 402c38cae0c3983245905d4fe90a76ba169a2421..6da3a538b3b899815a35b282c34fc68f1766da67 100755 --- a/public/static/index/default/js/order.js +++ b/public/static/index/default/js/order.js @@ -1,11 +1,18 @@ $(function() { + // 支付窗口 + var $pay_popup = $('#order-pay-popup'); + // 支付窗口参数初始化 - function PayPopupParamsInit(e) + function PayPopupParamsInit(ids, payment_id) { - $('form.pay-form input[name=id]').val(e.data('id')); - var payment_id = e.data('payment-id') || 0; - if($('.payment-items-'+payment_id).length > 0) + // 数组则转成字符串 + if(IsArray(ids)) + { + ids = ids.join(','); + } + $('form.pay-form input[name=ids]').val(ids); + if((payment_id || null) != null && $('.payment-items-'+payment_id).length > 0) { $('form.pay-form input[name=payment_id]').val(payment_id); $('.payment-items-'+payment_id).addClass('selected').siblings('li').removeClass('selected'); @@ -17,7 +24,8 @@ $(function() // 支付操作 $('.submit-pay').on('click', function() { - PayPopupParamsInit($(this)); + PayPopupParamsInit($(this).data('id'), $(this).data('payment-id')); + $pay_popup.modal(); }); // 混合列表选择 @@ -36,8 +44,8 @@ $(function() // 支付表单 $('form.pay-form button[type=submit]').on('click', function() { - var id = $('form.pay-form input[name=id]').val() || 0; - if(id == 0) + var ids = $('form.pay-form input[name=ids]').val() || null; + if(ids == null) { PromptCenter('订单id有误'); return false; @@ -68,19 +76,18 @@ $(function() }); // 自动支付处理 - if($('.submit-pay').length > 0) + if($pay_popup.length > 0) { + // 是否自动打开支付窗口 + if($pay_popup.data('is-auto') == 1) + { + $pay_popup.modal(); + } + // 是否自动提交支付表单 - if($('.submit-pay').data('is-pay') == 1) + if($pay_popup.data('is-pay') == 1) { - PayPopupParamsInit($('.submit-pay')); - $('#order-pay-popup button[type="submit"]').trigger('click'); - } else { - // 是否自动打开支付窗口 - if($('.submit-pay').data('is-auto') == 1) - { - $('.submit-pay').trigger('click'); - } + $pay_popup.find('button[type="submit"]').trigger('click'); } } @@ -89,11 +96,25 @@ $(function() { // 是否有选择的数据 var values = FromTableCheckedValues('order_form_checkbox_value'); - console.log(values) if(values.length <= 0) { Prompt('请先选中数据'); return false; } + + // 支付url支付地址 + var url = $(this).data('url') || null; + if(url == null) + { + Prompt('支付url地址有误'); + return false; + } + + // 获取第一个订单支付方式 + var payment_id = $('#data-list-'+values[0]).find('.submit-pay').data('payment-id') || null; + + // 支付弹窗 + PayPopupParamsInit(values, payment_id); + $pay_popup.modal(); }); }); \ No newline at end of file