コード例 #1
0
 public function go_pay()
 {
     if (!$GLOBALS['user_info']) {
         app_redirect(url_wap("user#login"));
     }
     $id = intval($_REQUEST['id']);
     $paypassword = strim($_REQUEST['paypassword']);
     if ($paypassword == '') {
         showErr("请输入支付密码", 0);
     }
     if (md5($paypassword) != $GLOBALS['user_info']['paypassword']) {
         showErr("支付密码错误", 0);
     }
     $consignee_id = intval($_REQUEST['consignee_id']);
     $credit = floatval($_REQUEST['credit']);
     $pay_score = intval($_REQUEST['pay_score']);
     if ($pay_score > 0) {
         $score_array = score_to_money($pay_score);
         $pay_score_money = $score_array['score_money'];
         $pay_score = $score_array['score'];
     } else {
         $pay_score = 0;
         $pay_score_money = 0;
     }
     $is_tg = intval($_REQUEST['is_tg']);
     if ($is_tg) {
         if (!$GLOBALS['is_user_tg']) {
             $jump_url = get_domain() . APP_ROOT . "/wap/index.php?ctl=collocation&act=CreateNewAcct&user_type=0&user_id=" . $GLOBALS['user_info']['id'];
             //$jump_url = get_domain().url_wap("collocation#CreateNewAcct",array('user_type'=>0,'user_id'=>$GLOBALS['user_info']['id']));
             showErr("您未绑定第三方接口无法支付,点击确定后跳转到绑定页面", 0, $jump_url);
         }
     }
     $memo = strim($_REQUEST['memo']);
     $payment_id = intval($_REQUEST['payment']);
     $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());
     }
     //无私奉献
     if ($deal_item['type'] == 1) {
         $pay_money = floatval($_REQUEST['pay_money']);
         if ($pay_money <= 0) {
             showErr("您输入的金额错误", 0, url_wap("deal#show", array("id" => $deal_item['deal_id'])));
         }
         $deal_item['price'] = $pay_money;
         $order_info['type'] = 2;
     } else {
         $order_info['type'] = $deal_info['type'];
     }
     $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 ($deal_item['is_share'] == 1) {
         $order_info['share_fee'] = $deal_item['share_fee'];
         $order_info['share_status'] = 0;
     } else {
         $order_info['share_fee'] = 0;
     }
     /*
     $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;
     */
     if (!$is_tg) {
         $credit_score_money = $pay_score_money + $credit;
         if ($credit > $GLOBALS['user_info']['money']) {
             showErr("余额最多只能用" . format_price($GLOBALS['user_info']['money']), 0);
         }
         if ($pay_score > $GLOBALS['user_info']['score']) {
             showErr("积分最多只能用" . $GLOBALS['user_info']['score']);
         }
         if ($credit_score_money > $order_info['total_price']) {
             showErr("支付超出");
         }
         if (intval(($order_info['total_price'] - $credit_score_money) * 100) > 0 && $payment_id == 0) {
             showErr("请选择支付方式");
         }
     }
     if ($credit > 0 && $GLOBALS['user_info']['money'] >= $credit) {
         $order_info['credit_pay'] = $credit;
     }
     if ($pay_score > 0 && $GLOBALS['user_info']['score'] >= $pay_score) {
         $order_info['score'] = $pay_score;
         $order_info['score_money'] = $pay_score_money;
     }
     //		$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) {
             if ($is_tg) {
                 $sign = md5(md5($paypassword) . $order_id);
                 $url = get_domain() . APP_ROOT . "/wap/index.php?ctl=collocation&act=RegisterCreditor&order_id=" . $order_id . "&sign=" . $sign;
                 //showSuccess("",0,$url);
                 app_redirect($url);
             } else {
                 $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'];
                 do {
                     $payment_notice['notice_sn'] = to_date(NOW_TIME, "Ymdhi") . rand(10000, 99999);
                     $GLOBALS['db']->autoExecute(DB_PREFIX . "payment_notice", $payment_notice, "INSERT", "", "SILENT");
                     $notice_id = $GLOBALS['db']->insert_id();
                 } while ($notice_id == 0);
                 app_redirect(url_wap("cart#jump", 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());
     }
 }
コード例 #2
0
ファイル: cartModule.class.php プロジェクト: BruceJi/fanwe
 public function go_pay_()
 {
     if (!$GLOBALS['user_info']) {
         app_redirect(url("user#login"));
     }
     $id = intval($_REQUEST['id']);
     $pay_money = floatval($_REQUEST['pay_money']);
     $paypassword = strim($_REQUEST['paypassword']);
     if ($paypassword == '') {
         showErr("请输入支付密码", 0);
     }
     if (md5($paypassword) != $GLOBALS['user_info']['paypassword']) {
         showErr("支付密码错误", 0);
     }
     $credit = floatval($_REQUEST['credit']);
     $pay_score = intval($_REQUEST['pay_score']);
     if ($pay_score > 0) {
         $score_array = score_to_money($pay_score);
         $pay_score_money = $score_array['score_money'];
         $pay_score = $score_array['score'];
     } else {
         $pay_score_money = 0;
     }
     $is_tg = intval($_REQUEST['is_tg']);
     if ($is_tg) {
         if (!$GLOBALS['is_user_tg']) {
             $jump_url = APP_ROOT . "/index.php?ctl=collocation&act=CreateNewAcct&user_type=0&user_id=" . $GLOBALS['user_info']['id'];
             showErr("您未绑定第三方接口无法支付,点击确定后跳转到绑定页面", 0, $jump_url);
         }
     }
     $payment_id = intval($_REQUEST['payment']);
     $deal_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where is_delete = 0 and is_effect = 1 and id = " . $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("deal#show", array("id" => $deal_item['deal_id'])));
     }
     /*$buy_right_number = 0;
     		if($deal_info['type']==3||$deal_info['type']==4){//企业众筹和币创投
     			$rights = $GLOBALS['db']->getAll("select * from ".DB_PREFIX."user_right where deal_id = ".$deal_info["id"]." and user_id = ".intval($GLOBALS['user_info']['id'])."");
     			if(count($rights)>0){ 
     				foreach ($rights as $k=>$v){
     					$buy_right_number += $v["right_amount"] + $v["frozen_right_amount"];
     			}
     			}  
     		}*/
     $buy_right_number = get_zc_right_number($deal_info["id"], intval($GLOBALS['user_info']['id']));
     $zc_amount = $pay_money / $deal_info["price_per_right"];
     if ($deal_info["zc_amount_limit"] > 0 && $zc_amount + $buy_right_number > $deal_info["zc_amount_limit"]) {
         showErr("对不起,您众筹数字权益份额已经超过上限!", 0, url("deal#show", array("id" => $deal_info["id"])));
     }
     $zc_count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_order where deal_id = " . $deal_info["id"] . " and user_id = " . $GLOBALS['user_info']['id']);
     if ($deal_info["zc_count_limit"] != 0 and $zc_count >= $deal_info["zc_count_limit"]) {
         showErr("对不起,您参与次数超过上限,已经无法继续参与本项目!", 0, url("deal#show", array("id" => $deal_info["id"])));
     }
     $order_info['type'] = 0;
     //普通众筹
     $order_info['is_tg'] = $is_tg;
     $order_info['deal_id'] = $deal_info['id'];
     $order_info['deal_item_id'] = 0;
     $order_info['user_id'] = intval($GLOBALS['user_info']['id']);
     $order_info['user_name'] = $GLOBALS['user_info']['user_name'];
     $order_info['total_price'] = floatval($_REQUEST['pay_money']);
     $order_info['delivery_fee'] = 0;
     $order_info['deal_price'] = floatval($_REQUEST['pay_money']);
     //$order_info['support_memo'] = $memo;
     $order_info['payment_id'] = $payment_id;
     $order_info['bank_id'] = strim($_REQUEST['bank_id']);
     $order_info['share_fee'] = 0;
     if (!$is_tg) {
         $credit_score_money = $pay_score_money + $credit;
         if ($credit > $GLOBALS['user_info']['money']) {
             showErr("余额最多只能用" . format_price($GLOBALS['user_info']['money']), 0);
         }
         if ($pay_score > $GLOBALS['user_info']['score']) {
             showErr("积分最多只能用" . $GLOBALS['user_info']['score']);
         }
         if ($credit_score_money > $order_info['total_price']) {
             showErr("支付超出");
         }
         if (intval(($order_info['total_price'] - $credit_score_money) * 100) > 0 && $payment_id == 0) {
             showErr("请选择支付方式");
         }
     }
     if ($credit > 0) {
         $order_info['credit_pay'] = $credit;
     }
     if ($pay_score > 0) {
         $order_info['score'] = $pay_score;
         $order_info['score_money'] = $pay_score_money;
     }
     $order_info['online_pay'] = 0;
     $order_info['deal_name'] = $deal_info['name'];
     $order_info['order_status'] = 0;
     $order_info['create_time'] = NOW_TIME;
     $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 ($is_tg) {
             $sign = md5(md5($paypassword) . $order_id);
             $url = APP_ROOT . "/index.php?ctl=collocation&act=RegisterCreditor&order_id=" . $order_id . "&sign=" . $sign;
             //showSuccess("",0,$url);
             app_redirect($url);
         }
         $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'] = 0;
             $payment_notice['deal_name'] = $deal_info['name'];
             do {
                 $payment_notice['notice_sn'] = to_date(NOW_TIME, "Ymdhi") . rand(10000, 99999);
                 $GLOBALS['db']->autoExecute(DB_PREFIX . "payment_notice", $payment_notice, "INSERT", "", "SILENT");
                 $notice_id = $GLOBALS['db']->insert_id();
             } while ($notice_id == 0);
             app_redirect(url("cart#jump", array("id" => $notice_id)));
         } elseif ($result['status'] == 1 || $result['status'] == 2) {
             app_redirect(url("account#credit"));
         } elseif ($result['status'] == 5) {
             showErr("很遗憾,订单支付失败");
         } else {
             app_redirect(url("account"));
         }
     } else {
         showErr("下单失败", 0, get_gopreview());
     }
 }
コード例 #3
0
 public function view_order()
 {
     if (!$GLOBALS['user_info']) {
         app_redirect(url("user#login"));
     }
     $GLOBALS['tmpl']->assign("page_title", "支持的项目详情");
     $id = intval($_REQUEST['id']);
     $order_info = $GLOBALS['db']->getRow("select deo.*,d.transfer_share as transfer_share,d.limit_price as limit_price from " . DB_PREFIX . "deal_order as deo LEFT JOIN " . DB_PREFIX . "deal as d on deo.deal_id = d.id where deo.id = " . $id . " and deo.user_id = " . intval($GLOBALS['user_info']['id']));
     if (!$order_info) {
         showErr("无效的项目支持", 0, get_gopreview());
     }
     //========如果超过系统设置的时间,则自动设置收到回报 start
     if ($order_info['repay_make_time'] == 0) {
         $item = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_item where id=" . $order_info['deal_item_id']);
         $item_day = intval($item['repaid_day']);
         if ($item_day > 0) {
             $left_date = $item_day;
         } else {
             $left_date = intval(app_conf("REPAY_MAKE"));
         }
         $repay_make_date = $order_info['repay_time'] + $left_date * 24 * 3600;
         $order_info['repay_left_time'] = $repay_make_date - $order_info['repay_time'];
         if ($repay_make_date > get_gmtime() && $order_info['repay_time'] > 0) {
             $order_info['repay_make_date'] = date('Y-m-d H:i:s', $repay_make_date);
         } else {
             $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order set repay_make_time =  " . get_gmtime() . " where id = " . $id);
             $order_info['repay_make_time'] = get_gmtime();
         }
     }
     if ($order_info['type'] == 1) {
         //用户所占股份
         $order_info['user_stock'] = number_format($order_info['total_price'] / $order_info['limit_price'] * $order_info['transfer_share'], 2);
         //项目金额
         $order_info['stock_value'] = number_format($order_info['limit_price'], 2);
         //应付金额
         //$order_info['total_price'] =number_format($order_info['total_price'],2);
     }
     //=============如果超过系统设置的时间,则自动设置收到回报 end
     $GLOBALS['tmpl']->assign("order_info", $order_info);
     //print_r($order_info);exit;
     $deal_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id = " . $order_info['deal_id'] . " and is_delete = 0 and is_effect = 1");
     $GLOBALS['tmpl']->assign("deal_info", $deal_info);
     if ($order_info['order_status'] == 0) {
         $payment_list = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "payment where is_effect = 1 and online_pay=1 order by sort asc ");
         $payment_html = "";
         foreach ($payment_list as $k => $v) {
             $class_name = $v['class_name'] . "_payment";
             require_once APP_ROOT_PATH . "system/payment/" . $class_name . ".php";
             $o = new $class_name();
             $payment_html .= "<div>" . $o->get_display_code() . "<div class='blank'></div></div>";
         }
         $GLOBALS['tmpl']->assign("payment_html", $payment_html);
         $max_pay = $order_info['total_price'];
         $GLOBALS['tmpl']->assign("max_pay", $max_pay);
         $order_sm = array('credit_pay' => 0, 'score' => 0, 'score_money' => 0);
         if ($order_info['credit_pay'] > 0) {
             $order_sm['credit_pay'] = $order_info['credit_pay'] <= $GLOBALS['user_info']['money'] ? $order_info['credit_pay'] : $GLOBALS['user_info']['money'];
         }
         if ($order_info['score'] > 0) {
             if ($order_info['score'] <= $GLOBALS['user_info']['score']) {
                 $order_sm['score'] = $order_info['score'];
                 $order_sm['score_money'] = $order_info['score_money'];
             } else {
                 $order_sm['score'] = $GLOBALS['user_info']['score'];
                 $score_array = score_to_money($GLOBALS['user_info']['score']);
                 $order_sm['score_money'] = $score_array['score_money'];
                 $order_sm['score'] = $score_array['score'];
             }
         }
         $GLOBALS['tmpl']->assign("order_sm", json_encode($order_sm));
     }
     $GLOBALS['tmpl']->assign("coll", is_tg(true));
     $GLOBALS['tmpl']->display("account_view_order.html");
 }
コード例 #4
0
 public function view_order()
 {
     $id = intval($_REQUEST['id']);
     $order_info = $GLOBALS['db']->getRow("select deo.*,d.transfer_share as transfer_share,d.limit_price as limit_price from " . DB_PREFIX . "deal_order as deo LEFT JOIN " . DB_PREFIX . "deal as d on deo.deal_id = d.id where deo.id = " . $id . " and deo.user_id = " . intval($GLOBALS['user_info']['id']));
     if (!$order_info) {
         showErr("无效的项目支持", 0, get_gopreview_wap());
     }
     //========如果超过系统设置的时间,则自动设置收到回报 start
     if ($order_info['repay_make_time'] == 0) {
         $item = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_item where id=" . $order_info['deal_item_id']);
         $item_day = intval($item['repaid_day']);
         if ($item_day > 0) {
             $left_date = $item_day;
         } else {
             $left_date = intval(app_conf("REPAY_MAKE"));
         }
         $repay_make_date = $order_info['repay_time'] + $left_date * 24 * 3600;
         if ($repay_make_date > get_gmtime() && $order_info['repay_time'] > 0) {
             $order_info['repay_make_date'] = date('Y-m-d H:i:s', $repay_make_date);
         } else {
             $GLOBALS['db']->query("update " . DB_PREFIX . "deal_order set repay_make_time =  " . get_gmtime() . " where id = " . $id);
             $order_info['repay_make_time'] = get_gmtime();
         }
     }
     if ($order_info['type'] == 1) {
         //用户所占股份
         $order_info['user_stock'] = number_format($order_info['total_price'] / $order_info['limit_price'] * $order_info['transfer_share'], 2);
         //项目金额
         $order_info['stock_value'] = number_format($order_info['limit_price'], 2);
         //应付金额
         //$order_info['total_price'] =number_format($order_info['total_price'],2);
     }
     //=============如果超过系统设置的时间,则自动设置收到回报 end
     $GLOBALS['tmpl']->assign("order_info", $order_info);
     $deal_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id = " . $order_info['deal_id'] . " and is_delete = 0 and is_effect = 1");
     $GLOBALS['tmpl']->assign("deal_info", $deal_info);
     if ($order_info['order_status'] == 0) {
         $payment_list = get_payment_list("wap");
         $GLOBALS['tmpl']->assign("payment_list", $payment_list);
         $max_pay = $order_info['total_price'];
         $GLOBALS['tmpl']->assign("max_pay", $max_pay);
         $order_sm = array('credit_pay' => 0, 'score' => 0, 'score_money' => 0);
         if ($order_info['credit_pay'] > 0) {
             $order_sm['credit_pay'] = $order_info['credit_pay'] <= $GLOBALS['user_info']['money'] ? $order_info['credit_pay'] : $GLOBALS['user_info']['money'];
         }
         if ($order_info['score'] > 0) {
             if ($order_info['score'] <= $GLOBALS['user_info']['score']) {
                 $order_sm['score'] = $order_info['score'];
                 $order_sm['score_money'] = $order_info['score_money'];
             } else {
                 $order_sm['score'] = $GLOBALS['user_info']['score'];
                 $score_array = score_to_money($GLOBALS['user_info']['score']);
                 $order_sm['score_money'] = $score_array['score_money'];
                 $order_sm['score'] = $score_array['score'];
             }
         }
         $GLOBALS['tmpl']->assign("order_sm", json_encode($order_sm));
         $GLOBALS['tmpl']->assign("page_title", "订单支付");
     } else {
         $GLOBALS['tmpl']->assign("page_title", "订单详情");
     }
     $GLOBALS['tmpl']->assign("coll", is_tg(true));
     $GLOBALS['tmpl']->display("account_view_order.html");
 }