public function __construct() { require_once APP_ROOT_PATH . "system/payment/Appay_payment.php"; $o = new Appay_payment(); //获取用户积分 $user_ap = $o->get_user_ap($GLOBALS['user_info']['id']); $GLOBALS['tmpl']->assign("user_ap", $user_ap); }
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 (!$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_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 show() { if (!$GLOBALS['user_info']) { app_redirect(url("user#login")); } get_mortgate(); //获取项目的ID $id = intval($_REQUEST['id']); $deal_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id = " . $id . " and is_delete = 0 and (is_effect = 1 or (is_effect = 0 and user_id = " . intval($GLOBALS['user_info']['id']) . "))"); $deal_info['deal_type'] = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "deal_cate where id=" . $deal_info['cate_id']); $deal_info['login_time'] = $GLOBALS['db']->getOne("select login_time from " . DB_PREFIX . "user where id=" . $deal_info['user_id']); if (!$deal_info) { app_redirect(url("index")); } $deal_img_array = array(); $deal_img_array[] = $deal_info['image']; for ($i = 0; $i < 9; $i++) { if ($deal_info['imghead_' . $i]) { $deal_img_array[] = $deal_info['imghead_' . $i]; } } $GLOBALS['tmpl']->assign('deal_img_array', $deal_img_array); //获取当前用户支持当前项目状态 $deal_sup_num = $GLOBALS['db']->getOne("select count(*) as num from " . DB_PREFIX . "deal_order where deal_id = " . $id . " and user_id = " . intval($GLOBALS['user_info']['id']) . " and order_status=3"); $GLOBALS['tmpl']->assign('deal_sup_num', $deal_sup_num); //获取当前用户关注当前项目状态 $deal_focus_num = $GLOBALS['db']->getOne("select count(*) as num from " . DB_PREFIX . "deal_focus_log where deal_id = " . $id . " and user_id = " . intval($GLOBALS['user_info']['id'])); $GLOBALS['tmpl']->assign('deal_focus_num', $deal_focus_num); if ($deal_info['is_effect'] == 1) { log_deal_visit($deal_info['id']); } if ($deal_info['type'] == 1) { //跟投人数 $gen_num = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "investment_list where type=2 and deal_id=" . $id); $GLOBALS['tmpl']->assign('gen_num', intval($gen_num)); //询价人数 $xun_num = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "investment_list where type=0 and deal_id=" . $id); $GLOBALS['tmpl']->assign('xun_num', intval($xun_num)); } $deal_info = cache_deal_extra($deal_info); $deal_info['ap_amount'] = $deal_info['support_amount'] * $deal_info['ap_ratio']; $deal_info['limit_ap'] = $deal_info['limit_price'] * $deal_info['ap_ratio']; $page_size = DEAL_COMMENT_PAGE_SIZE; $page = intval($_REQUEST['p']); if ($page == 0) { $page = 1; } $limit = ($page - 1) * $page_size . "," . $page_size; $comment_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "deal_comment where deal_id = " . $id . " and log_id = 0 and status=1 order by create_time desc limit " . $limit); $GLOBALS['tmpl']->assign('comment_list', $comment_list); $comment_count = count($comment_list); $GLOBALS['tmpl']->assign('comment_count', $comment_count); $page = '<ul>'; if ($p > 1) { $page .= '<li><a href="/index.php?ctl=ap&act=show&id=' . $id . '&p=' . ($p - 1) . '" class="last">上一页</a></li>'; } $allPNum = ceil($comment_count / $page_size); for ($i = 1; $i <= $allPNum; $i++) { $page .= '<li class="fy2_no"><a href="/index.php?ctl=ap&act=show&id=' . $id . '&p=' . $i . '" class="last">' . $i . '</a></li>'; } if ($p < $allPNum) { $page .= '<li><a href="/index.php?ctl=ap&act=show&id=' . $id . '&p=' . ($p + 1) . '" class="next">下一页</a></li>'; } $page .= '</ul>'; $GLOBALS['tmpl']->assign('page', $page); $this->init_deal_page(@$deal_info); if (app_conf("INVEST_STATUS") == 2 && $deal_info['type'] == 0) { showErr("产品众筹已经关闭"); } if ($deal_info['type'] == 1) { $GLOBALS['tmpl']->assign('deal_type', 'gq_type'); } else { $GLOBALS['tmpl']->assign('deal_type', 'product_type'); } require_once APP_ROOT_PATH . "system/payment/Appay_payment.php"; $o = new Appay_payment(); //获取用户积分 $user_ap = $o->get_user_ap($GLOBALS['user_info']['id']); $GLOBALS['tmpl']->assign('user_ap', $user_ap); //普通众筹 $GLOBALS['tmpl']->display("ap_show.html"); }
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']))); } } }