充值订单跟普通订单的区别在于,普通订单有
public function incharge_done()
{
//获取支付方式
$payment_id = intval($_REQUEST['payment']);
//获取充值金额
$money = floatval($_REQUEST['money']);
//如果充值金额小于0,提示错误
if($money<=0)
{
showErr($GLOBALS['lang']['PLEASE_INPUT_CORRECT_INCHARGE']);
}
//去数据库查询是否支持该支付方式,没有则提示用户选择
$payment_info = $GLOBALS['db']->getRow("select * from ".DB_PREFIX."payment where id = ".$payment_id);
if(!$payment_info)
{
showErr($GLOBALS['lang']['PLEASE_SELECT_PAYMENT']);
}
//开始生成订单
$now = get_gmtime();
$order['type'] = 1; //充值单
$order['user_id'] = $GLOBALS['user_info']['id'];
$order['create_time'] = $now;
if($payment_info['fee_type'] == 0)
$order['total_price'] = $money + $payment_info['fee_amount'];
else
$order['total_price'] = $money + $payment_info['fee_amount']*$money;
$order['deal_total_price'] = $money;
$order['pay_amount'] = 0;
$order['pay_status'] = 0;
$order['delivery_status'] = 5;
$order['order_status'] = 0;
$order['payment_id'] = $payment_id;
//生成手续费
if($payment_info['fee_type'] == 0)
$order['payment_fee'] = $payment_info['fee_amount'];
else
$order['payment_fee'] = $payment_info['fee_amount']*$money;
$order['bank_id'] = addslashes(htmlspecialchars(trim($_REQUEST['bank_id'])));
//生成订单号,保证唯一性
do
{
$order['order_sn'] = to_date(get_gmtime(),"Ymdhis").rand(100,999);
$GLOBALS['db']->autoExecute(DB_PREFIX."deal_order",$order,'INSERT','','SILENT');
$order_id = intval($GLOBALS['db']->insert_id());
}while($order_id==0);
require_once APP_ROOT_PATH."system/libs/cart.php";
$payment_notice_id = make_payment_notice($order['total_price'],$order_id,$payment_info['id']);
//创建支付接口的付款单
$rs = order_paid($order_id);
if($rs)
{
app_redirect(url("shop","payment#incharge_done",array("id"=>$order_id))); //充值支付成功
}
else
{
app_redirect(url("shop","payment#pay",array("id"=>$payment_notice_id)));
}
}