public function go_order_pay() { $id = intval($_REQUEST['order_id']); $order_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_order where id = " . $id . " and user_id = " . intval($GLOBALS['user_info']['id']) . " and order_status = 0"); if (!$order_info) { showErr("项目支持已支付", 0, get_gopreview_wap()); } else { $credit = doubleval($_REQUEST['credit']); $payment_id = intval($_REQUEST['payment_id']); if ($credit > 0) { $max_pay = $order_info['total_price'] - $order_info['credit_pay']; $max_credit = $max_pay < $GLOBALS['user_info']['money'] ? $max_pay : $GLOBALS['user_info']['money']; $credit = $credit > $max_credit ? $max_credit : $credit; if ($credit > 0) { $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order set credit_pay = credit_pay + " . $credit . " where id = " . $order_info['id']); //追加使用余额支付 require_once APP_ROOT_PATH . "system/libs/user.php"; modify_account(array("money" => "-" . $credit), intval($GLOBALS['user_info']['id']), "支持" . $order_info['deal_name'] . "项目支付"); } } $result = pay_order($order_info['id']); //print_r($order_info); if ($result['status'] == 0) { $money = $result['money']; $payment_notice['create_time'] = NOW_TIME; $payment_notice['user_id'] = intval($GLOBALS['user_info']['id']); $payment_notice['payment_id'] = $payment_id; $payment_notice['money'] = $money; $payment_notice['bank_id'] = strim($_REQUEST['bank_id']); $payment_notice['order_id'] = $order_info['id']; $payment_notice['memo'] = $order_info['support_memo']; $payment_notice['deal_id'] = $order_info['deal_id']; $payment_notice['deal_item_id'] = $order_info['deal_item_id']; $payment_notice['deal_name'] = $order_info['deal_name']; //积分商城项目增加积分方和积分兑换率 if ($order_info['is_ap'] == "1") { $payment_notice['partner_id'] = $order_info['ap_partner_id']; $payment_notice['ap_ratio'] = $order_info['ap_ratio']; } do { $payment_notice['notice_sn'] = to_date(NOW_TIME, "Ymd") . rand(100, 999); $GLOBALS['db']->autoExecute(DB_PREFIX . "payment_notice", $payment_notice, "INSERT", "", "SILENT"); $notice_id = $GLOBALS['db']->insert_id(); } while ($notice_id == 0); if ((int) $order_info['is_ap'] !== 0) { //调用积分支付方法类 require_once APP_ROOT_PATH . "system/payment/Appay_payment.php"; $o = new Appay_payment(); $res = $o->user_pay($notice_id); $data = array(); $data['deal_id'] = $order_info['deal_id']; $data['deal_item_id'] = $order_info['deal_item_id']; $data['order_id'] = $id; switch ($res) { case 1: $GLOBALS['tmpl']->assign('data', $data); $GLOBALS['tmpl']->display('pay_sucess.html'); break; case -1: $data['pay_info'] = '积分不足.'; // $GLOBALS['tmpl']->assign('msg','积分不足'); $GLOBALS['tmpl']->assign('data', $data); $GLOBALS['tmpl']->display('pay_error.html'); break; case 0: $data['pay_info'] = '订单为空.'; $GLOBALS['tmpl']->assign('data', $data); // $GLOBALS['tmpl']->assign('msg','订单为空'); $GLOBALS['tmpl']->display('pay_error.html'); break; } } else { app_redirect(url_wap("cart#jump", array("id" => $notice_id))); } } else { app_redirect(url_wap("account#view_order", array("id" => $order_info['id']))); } } }
public function go_pay() { if (es_session::get("confirm") == $_REQUEST['t']) { app_redirect(url_wap("index")); //支付过期时跳转回首页 // echo '网页过期'; exit; } if (!$GLOBALS['user_info']) { app_redirect(url_wap("user#login")); } $isap = $_REQUEST['isap']; $id = intval($_REQUEST['id']); $is_address = intval($_REQUEST['is_address']); $consignee_id = intval($_REQUEST['consignee_id']); if ($is_address == 1) { if (empty($consignee_id)) { $consignee = strim($_REQUEST['consignee']); $province = strim($_REQUEST['province']); $city = strim($_REQUEST['city']); $address = strim($_REQUEST['address']); $zip = strim($_REQUEST['zip']); $mobile = strim($_REQUEST['mobile']); $data = array(); $data['consignee'] = $consignee; $data['province'] = $province; $data['city'] = $city; $data['address'] = $address; $data['zip'] = $zip; $data['mobile'] = $mobile; $data['user_id'] = intval($GLOBALS['user_info']['id']); $GLOBALS['db']->autoExecute(DB_PREFIX . "user_consignee", $data); $consignee_id = $GLOBALS['db']->insert_id(); } } $credit = doubleval($_REQUEST['credit']); $memo = strim($_REQUEST['memo']); $payment_id = intval($_REQUEST['payment_id']); $deal_item = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_item where id = " . $id); if (!$deal_item) { app_redirect(url_wap("index")); } elseif ($deal_item['support_count'] >= $deal_item['limit_user'] && $deal_item['limit_user'] != 0) { app_redirect(url_wap("deal#show", array("id" => $deal_item['deal_id']))); } $deal_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where is_delete = 0 and is_effect = 1 and id = " . $deal_item['deal_id']); if (!$deal_info) { app_redirect(url_wap("index")); } elseif ($deal_info['begin_time'] > NOW_TIME || $deal_info['end_time'] < NOW_TIME && $deal_info['end_time'] != 0) { app_redirect(url_wap("deal#show", array("id" => $deal_item['deal_id']))); } if (intval($consignee_id) == 0 && $deal_item['is_delivery'] == 1) { showErr("请选择配送方式", 0, get_gopreview_wap()); } $order_info['deal_id'] = $deal_info['id']; $order_info['deal_item_id'] = $deal_item['id']; $order_info['user_id'] = intval($GLOBALS['user_info']['id']); $order_info['user_name'] = $GLOBALS['user_info']['user_name']; $order_info['total_price'] = $deal_item['price'] + $deal_item['delivery_fee']; $order_info['delivery_fee'] = $deal_item['delivery_fee']; $order_info['deal_price'] = $deal_item['price']; $order_info['support_memo'] = $memo; $order_info['payment_id'] = $payment_id; $order_info['bank_id'] = strim($_REQUEST['bank_id']); //积分商城项目增加积分方和积分兑换率 if ($isap == "1") { $order_info['is_ap'] = $isap; $order_info['ap_partner_id'] = 2; $order_info['ap_ratio'] = $deal_item['ap_ratio']; } $max_credit = $order_info['total_price'] < $GLOBALS['user_info']['money'] ? $order_info['total_price'] : $GLOBALS['user_info']['money']; $credit = $credit > $max_credit ? $max_credit : $credit; $order_info['credit_pay'] = $credit; $order_info['online_pay'] = 0; $order_info['deal_name'] = $deal_info['name']; $order_info['order_status'] = 0; $order_info['create_time'] = NOW_TIME; if ($consignee_id > 0) { $consignee_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_consignee where id = " . $consignee_id . " and user_id = " . intval($GLOBALS['user_info']['id'])); if (!$consignee_info && $deal_item['is_delivery'] == 1) { showErr("请选择配送方式", 0, get_gopreview_wap()); } $order_info['consignee'] = $consignee_info['consignee']; $order_info['zip'] = $consignee_info['zip']; $order_info['address'] = $consignee_info['address']; $order_info['province'] = $consignee_info['province']; $order_info['city'] = $consignee_info['city']; $order_info['mobile'] = $consignee_info['mobile']; } $order_info['is_success'] = $deal_info['is_success']; $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_order", $order_info); $order_id = $GLOBALS['db']->insert_id(); if ($order_id > 0) { if ($order_info['credit_pay'] > 0) { require_once APP_ROOT_PATH . "system/libs/user.php"; modify_account(array("money" => "-" . $order_info['credit_pay']), intval($GLOBALS['user_info']['id']), "支持" . $order_info['deal_name'] . "项目支付"); } $result = pay_order($order_id); if ($result['status'] == 0) { $money = $result['money']; $payment_notice['create_time'] = NOW_TIME; $payment_notice['user_id'] = intval($GLOBALS['user_info']['id']); $payment_notice['payment_id'] = $order_info['payment_id']; $payment_notice['money'] = $money; $payment_notice['order_id'] = $order_id; $payment_notice['memo'] = $order_info['memo']; $payment_notice['deal_id'] = $order_info['deal_id']; $payment_notice['deal_item_id'] = $order_info['deal_item_id']; $payment_notice['deal_name'] = $order_info['deal_name']; //积分商城项目增加积分方和积分兑换率 if ($isap == "1") { $payment_notice['partner_id'] = $order_info['ap_partner_id']; $payment_notice['ap_ratio'] = $order_info['ap_ratio']; } do { $payment_notice['notice_sn'] = to_date(NOW_TIME, "Ymd") . rand(100, 999); $GLOBALS['db']->autoExecute(DB_PREFIX . "payment_notice", $payment_notice, "INSERT", "", "SILENT"); $notice_id = $GLOBALS['db']->insert_id(); } while ($notice_id == 0); /*if($isap=="1"){ app_redirect(url("cart#ap_jump",array("notice_id"=>$notice_id,"order_id"=>$order_id))); }*/ if ($isap == "1") { //调用积分支付方法类 require_once APP_ROOT_PATH . "system/payment/Appay_payment.php"; $o = new Appay_payment(); $res = $o->user_pay($notice_id); $data = array(); $data['deal_id'] = $order_info['deal_id']; $data['deal_item_id'] = $order_info['deal_item_id']; $data['order_id'] = $order_id; // $_COOKIE["confirm"] = false; es_session::set("confirm", $_REQUEST['t']); switch ($res) { case 1: $GLOBALS['tmpl']->assign('data', $data); $GLOBALS['tmpl']->display('pay_sucess.html'); break; case -1: $data['pay_info'] = '积分不足.'; // $GLOBALS['tmpl']->assign('msg','积分不足'); $GLOBALS['tmpl']->assign('data', $data); $GLOBALS['tmpl']->display('pay_error.html'); break; case 0: $data['pay_info'] = '订单为空.'; $GLOBALS['tmpl']->assign('data', $data); // $GLOBALS['tmpl']->assign('msg','订单为空'); $GLOBALS['tmpl']->display('pay_error.html'); break; } exit; } // echo $payment_id; if ($_REQUEST['isqr'] !== '1') { app_redirect(url("cart#jump", array("id" => $notice_id))); } else { app_redirect(url("cart#jump_wxzf", array("id" => $notice_id))); } } elseif ($result['status'] == 1) { $data['pay_status'] = 0; $data['pay_info'] = '订单过期.'; $data['show_pay_btn'] = 0; $GLOBALS['tmpl']->assign('data', $data); $GLOBALS['tmpl']->display('pay_order_index.html'); } elseif ($result['status'] == 2) { $data['pay_status'] = 0; $data['pay_info'] = '订单无库存.'; $data['show_pay_btn'] = 0; $GLOBALS['tmpl']->assign('data', $data); $GLOBALS['tmpl']->display('pay_order_index.html'); } else { $data['pay_status'] = 1; $data['pay_info'] = '订单支付成功.'; $data['show_pay_btn'] = 0; $GLOBALS['tmpl']->assign('data', $data); $GLOBALS['tmpl']->display('pay_order_index.html'); } //app_redirect(url_wap("cart#pay_order",array("order_id"=>$order_id))); } else { showErr("下单失败", 0, get_gopreview_wap()); } }
public function go_pay() { if (!$GLOBALS['user_info']) { app_redirect(url("user#login")); } $id = intval($_REQUEST['id']); $consignee_id = intval($_REQUEST['consignee_id']); $memo = strim($_REQUEST['memo']); $payment_id = intval($_REQUEST['payment_id']); $deal_item = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_item where id = " . $id); if (!$deal_item) { app_redirect(url("index")); } elseif ($deal_item['support_count'] >= $deal_item['limit_user'] && $deal_item['limit_user'] != 0) { app_redirect(url("ap#show", array("id" => $deal_item['deal_id']))); } $deal_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where is_delete = 0 and is_effect = 1 and id = " . $deal_item['deal_id']); if (!$deal_info) { app_redirect(url("index")); } elseif ($deal_info['begin_time'] > NOW_TIME || $deal_info['end_time'] < NOW_TIME && $deal_info['end_time'] != 0) { app_redirect(url("ap#show", array("id" => $deal_item['deal_id']))); } if (intval($consignee_id) == 0 && $deal_item['is_delivery'] == 1) { showErr("请选择配送方式", 0, get_gopreview()); } $order_info['deal_id'] = $deal_info['id']; $order_info['deal_item_id'] = $deal_item['id']; $order_info['user_id'] = intval($GLOBALS['user_info']['id']); $order_info['user_name'] = $GLOBALS['user_info']['user_name']; $order_info['total_price'] = $deal_item['price'] + $deal_item['delivery_fee']; $order_info['delivery_fee'] = $deal_item['delivery_fee']; $order_info['deal_price'] = $deal_item['price']; $order_info['support_memo'] = $memo; $order_info['payment_id'] = $payment_id; $order_info['ap_partner_id'] = intval($_REQUEST['ap_partner_id']); $order_info['ap_ratio'] = $deal_item['ap_ratio']; $order_info['bank_id'] = strim($_REQUEST['bank_id']); $max_pay = intval($_REQUEST['max_pay']); $order_info['credit_pay'] = 0; $order_info['online_pay'] = 0; $order_info['ap_pay'] = 0; $order_info['deal_name'] = $deal_info['name']; $order_info['order_status'] = 0; $order_info['create_time'] = NOW_TIME; $order_info['is_ap'] = 1; if ($consignee_id > 0) { $consignee_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "user_consignee where id = " . $consignee_id . " and user_id = " . intval($GLOBALS['user_info']['id'])); if (!$consignee_info && $deal_item['is_delivery'] == 1) { showErr("请选择配送方式", 0, get_gopreview()); } $order_info['consignee'] = $consignee_info['consignee']; $order_info['zip'] = $consignee_info['zip']; $order_info['address'] = $consignee_info['address']; $order_info['province'] = $consignee_info['province']; $order_info['city'] = $consignee_info['city']; $order_info['mobile'] = $consignee_info['mobile']; } $order_info['is_success'] = $deal_info['is_success']; $GLOBALS['db']->autoExecute(DB_PREFIX . "deal_order", $order_info); $order_id = $GLOBALS['db']->insert_id(); if ($order_id > 0) { $result = pay_order($order_id); if ($result['status'] == 0) { $money = $result['money']; $payment_notice['create_time'] = NOW_TIME; $payment_notice['user_id'] = intval($GLOBALS['user_info']['id']); $payment_notice['payment_id'] = $payment_id; $payment_notice['money'] = $money; $payment_notice['bank_id'] = strim($_REQUEST['bank_id']); $payment_notice['order_id'] = $order_id; $payment_notice['memo'] = $memo; $payment_notice['deal_id'] = $deal_info['id']; $payment_notice['deal_item_id'] = $deal_item['id']; $payment_notice['deal_name'] = $deal_info['name']; $payment_notice['partner_id'] = $order_info['ap_partner_id']; $payment_notice['ap_ratio'] = $order_info['ap_ratio']; do { $payment_notice['notice_sn'] = to_date(NOW_TIME, "Ymd") . rand(100, 999); $GLOBALS['db']->autoExecute(DB_PREFIX . "payment_notice", $payment_notice, "INSERT", "", "SILENT"); $notice_id = $GLOBALS['db']->insert_id(); } while ($notice_id == 0); require_once APP_ROOT_PATH . "system/payment/Appay_payment.php"; $o = new Appay_payment(); //获取用户积分 $res = $o->user_pay($notice_id); if ($res) { app_redirect(url("account")); } else { app_redirect(url("account#credit")); } } elseif ($result['status'] == 1 || $result['status'] == 2) { app_redirect(url("account#credit")); } else { app_redirect(url("account")); } } else { showErr("下单失败", 0, get_gopreview()); } }
public function go_aporder_pay() { if (!$GLOBALS['user_info']) { app_redirect(url("user#login")); } $id = intval($_REQUEST['order_id']); $order_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_order where id = " . $id . " and user_id = " . intval($GLOBALS['user_info']['id']) . " and order_status = 0"); if (!$order_info) { showErr("项目支持已支付", 0, get_gopreview()); } else { $credit = doubleval($_REQUEST['credit']); $payment_id = intval($_REQUEST['payment']); if ($credit > 0) { $max_pay = $order_info['total_price'] - $order_info['credit_pay']; $max_credit = $max_pay < $GLOBALS['user_info']['money'] ? $max_pay : $GLOBALS['user_info']['money']; if ($max_credit < 0) { $max_credit = 0; } $credit = $credit > $max_credit ? $max_credit : $credit; if ($credit > 0) { require_once APP_ROOT_PATH . "system/libs/user.php"; $re = modify_account(array("money" => "-" . $credit), intval($GLOBALS['user_info']['id']), "支持" . $order_info['deal_name'] . "项目支付"); if ($re) { $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order set credit_pay = credit_pay + " . $credit . " where id = " . $order_info['id']); //追加使用余额支付 } } } $result = pay_order($order_info['id']); if ($result['status'] == 0) { $money = $result['money']; $payment_notice['create_time'] = NOW_TIME; $payment_notice['user_id'] = intval($GLOBALS['user_info']['id']); $payment_notice['payment_id'] = $payment_id; $payment_notice['money'] = $money; $payment_notice['bank_id'] = strim($_REQUEST['bank_id']); $payment_notice['order_id'] = $order_info['id']; $payment_notice['memo'] = $order_info['support_memo']; $payment_notice['deal_id'] = $order_info['deal_id']; $payment_notice['deal_item_id'] = $order_info['deal_item_id']; $payment_notice['deal_name'] = $order_info['deal_name']; $payment_notice['partner_id'] = $order_info['ap_partner_id']; $payment_notice['ap_ratio'] = $order_info['ap_ratio']; do { $payment_notice['notice_sn'] = to_date(NOW_TIME, "Ymd") . rand(100, 999); $GLOBALS['db']->autoExecute(DB_PREFIX . "payment_notice", $payment_notice, "INSERT", "", "SILENT"); $notice_id = $GLOBALS['db']->insert_id(); } while ($notice_id == 0); require_once APP_ROOT_PATH . "system/payment/Appay_payment.php"; $o = new Appay_payment(); //获取用户积分 $res = $o->user_pay($notice_id); if ($res) { app_redirect(url("account")); } else { app_redirect(url("account#credit")); } } else { app_redirect(url("account#apview_order", array("id" => $order_info['id']))); } } }