include_once(ROOT_PATH . 'includes/lib_clips.php');
include_once(ROOT_PATH . 'includes/lib_order.php');
$amount = isset($_POST['amount']) ? floatval($_POST['amount']) : 0;
if ($amount <= 0)
{
show_message($_LANG['amount_gt_zero']);
}
/* 變量初始化 */
$surplus = array(
'user_id' ? ? ?=> $user_id,
'rec_id' ? ? ? => !empty($_POST['rec_id']) ? ? ?? intval($_POST['rec_id']) ? ? ? : 0,
'process_type' => isset($_POST['surplus_type']) ? intval($_POST['surplus_type']) : 0,
'payment_id' ? => isset($_POST['payment_id']) ? ? intval($_POST['payment_id']) ? : 0,
'user_note' ? ?=> isset($_POST['user_note']) ? ?? trim($_POST['user_note']) ? ? ?: '',
'amount' ? ? ? => $amount,
'pay_points' ?=>$amount*100/$_CFG['integral_scale']//通過后臺積分有換算比例算出充值的積分
);
if ($surplus['payment_id'] <= 0)
{
show_message($_LANG['select_payment_pls']);
}
include_once(ROOT_PATH .'includes/lib_payment.php');
//獲取支付方式名稱
$payment_info = array();
$payment_info = payment_info($surplus['payment_id']);
$surplus['payment'] = $payment_info['pay_name'];
if ($surplus['rec_id'] > 0)
{
//更新會員賬目明細
$surplus['rec_id'] = update_user_account($surplus);
}
else
{
//插入會員賬目明細
$surplus['rec_id'] = insert_user_account($surplus, $amount);
}
//取得支付信息,生成支付代碼
$payment = unserialize_config($payment_info['pay_config']);
//生成偽訂單號, 不足的時候補0
$order = array();
$order['order_sn'] ? ? ? = $surplus['rec_id'];
$order['user_name'] ? ? ?= $_SESSION['user_name'];
$order['surplus_amount'] = $amount;
//計算支付手續(xù)費用
$payment_info['pay_fee'] = pay_fee($surplus['payment_id'], $order['surplus_amount'], 0);
//計算此次預(yù)付款需要支付的總金額
$order['order_amount'] ? = $amount + $payment_info['pay_fee'];
//記錄支付log
$order['log_id'] = insert_pay_log($surplus['rec_id'], $order['order_amount'], $type=2, 0);//需要主意這的支付類型,ecshop默認的有兩個0和1,這里把這個設(shè)置成2去邊是積分充值。
/* 調(diào)用相應(yīng)的支付方式文件 */
include_once(ROOT_PATH . 'includes/modules/payment/' . $payment_info['pay_code'] . '.php');
/* 取得在線支付方式的支付按鈕 */
$pay_obj = new $payment_info['pay_code'];
$payment_info['pay_button'] = $pay_obj->get_code($order, $payment);
/* 模板賦值 */
$smarty->assign('payment', $payment_info);
$smarty->assign('pay_fee', price_format($payment_info['pay_fee'], false));
$smarty->assign('amount', ?price_format($amount, false));
$smarty->assign('order', ? $order);
$smarty->display('');//掉需要的模版,也可以在user_transaction.dwt中操作,模版信息就 act_account的模版直接使用,在其中可以添加一行說明充值了多少積分,在這就不說明了,如果有需要的朋友可以給我留言。
4,在第三部中用到函數(shù)insert_user_account這個函數(shù)需要修改為如下
function insert_user_account($surplus, $amount)
{
$sql = 'INSERT INTO ' .$GLOBALS['ecs']->table('user_account').
' (user_id, admin_user, amount, add_time, paid_time, admin_note, user_note, process_type, payment, is_paid,pay_points)'.
" VALUES ('$surplus[user_id]', '', '$amount', '".gmtime()."', 0, '', '$surplus[user_note]', '$surplus[process_type]', '$surplus[payment]', 0,'$surplus[pay_points]')";
$GLOBALS['db']->query($sql);
return $GLOBALS['db']->insert_id();
}
5,修改支付回調(diào)函數(shù)
{
/* 取得支付編號 */
$log_id = intval($log_id);
if ($log_id > 0)
{
/* 取得要修改的支付記錄信息 */
$sql = "SELECT * FROM " . $GLOBALS['ecs']->table('pay_log') .
" WHERE log_id = '$log_id'";
$pay_log = $GLOBALS['db']->getRow($sql);
if ($pay_log && $pay_log['is_paid'] == 0)
{
/* 修改此次支付操作的狀態(tài)為已付款 */
$sql = 'UPDATE ' . $GLOBALS['ecs']->table('pay_log') .
" SET is_paid = '1' WHERE log_id = '$log_id'";
$GLOBALS['db']->query($sql);
/* 根據(jù)記錄類型做相應(yīng)處理 */
if ($pay_log['order_type'] == PAY_ORDER)
{
/* 取得訂單信息 */
$sql = 'SELECT order_id, user_id, order_sn, consignee, address, tel, shipping_id, extension_code, extension_id, goods_amount ' .
'FROM ' . $GLOBALS['ecs']->table('order_info') .
" WHERE order_id = '$pay_log[order_id]'";
$order ? ?= $GLOBALS['db']->getRow($sql);
$order_id = $order['order_id'];
$order_sn = $order['order_sn'];
/* 修改訂單狀態(tài)為已付款 */
$sql = 'UPDATE ' . $GLOBALS['ecs']->table('order_info') .
" SET order_status = '" . OS_CONFIRMED . "', " .
" confirm_time = '" . gmtime() . "', " .
" pay_status = '$pay_status', " .
" pay_time = '".gmtime()."', " .
" money_paid = order_amount," .
" order_amount = 0 ".
"WHERE order_id = '$order_id'";
$GLOBALS['db']->query($sql);
/* 記錄訂單操作記錄 */
order_action($order_sn, OS_CONFIRMED, SS_UNSHIPPED, $pay_status, $note, $GLOBALS['_LANG']['buyer']);
/* 如果需要,發(fā)短信 */
if ($GLOBALS['_CFG']['sms_order_payed'] == '1' && $GLOBALS['_CFG']['sms_shop_mobile'] != '')
{
include_once(ROOT_PATH.'includes/cls_sms.php');
$sms = new sms();
$sms->send($GLOBALS['_CFG']['sms_shop_mobile'],
sprintf($GLOBALS['_LANG']['order_payed_sms'], $order_sn, $order['consignee'], $order['tel']),'', 13,1);
}
/* 對虛擬商品的支持 */
$virtual_goods = get_virtual_goods($order_id);
if (!empty($virtual_goods))
{
$msg = '';
if (!virtual_goods_ship($virtual_goods, $msg, $order_sn, true))
{
$GLOBALS['_LANG']['pay_success'] .= ''.$msg.''.$GLOBALS['_LANG']['virtual_goods_ship_fail'];
}
/* 如果訂單沒有配送方式,自動完成發(fā)貨操作 */
if ($order['shipping_id'] == -1)
{
/* 將訂單標識為已發(fā)貨狀態(tài),并記錄發(fā)貨記錄 */
$sql = 'UPDATE ' . $GLOBALS['ecs']->table('order_info') .
" SET shipping_status = '" . SS_SHIPPED . "', shipping_time = '" . gmtime() . "'" .
" WHERE order_id = '$order_id'";
$GLOBALS['db']->query($sql);
/* 記錄訂單操作記錄 */
order_action($order_sn, OS_CONFIRMED, SS_SHIPPED, $pay_status, $note, $GLOBALS['_LANG']['buyer']);
$integral = integral_to_give($order);
log_account_change($order['user_id'], 0, 0, intval($integral['rank_points']), intval($integral['custom_points']), sprintf($GLOBALS['_LANG']['order_gift_integral'], $order['order_sn']));
}
}
}
elseif ($pay_log['order_type'] == PAY_SURPLUS)
{
$sql = 'SELECT `id` FROM ' . $GLOBALS['ecs']->table('user_account') . ?" WHERE `id` = '$pay_log[order_id]' AND `is_paid` = 1 ?LIMIT 1";
$res_id=$GLOBALS['db']->getOne($sql);
if(empty($res_id))
{
/* 更新會員預(yù)付款的到款狀態(tài) */
$sql = 'UPDATE ' . $GLOBALS['ecs']->table('user_account') .
" SET paid_time = '" .gmtime(). "', is_paid = 1" .
" WHERE id = '$pay_log[order_id]' LIMIT 1";
$GLOBALS['db']->query($sql);
/* 取得添加預(yù)付款的用戶以及金額 */
$sql = "SELECT user_id, amount FROM " . $GLOBALS['ecs']->table('user_account') .
" WHERE id = '$pay_log[order_id]'";
$arr = $GLOBALS['db']->getRow($sql);
/* 修改會員帳戶金額 */
$_LANG = array();
include_once(ROOT_PATH . 'languages/' . $GLOBALS['_CFG']['lang'] . '/user.php');
log_account_change($arr['user_id'], $arr['amount'], 0, 0, 0, $_LANG['surplus_type_0'], ACT_SAVING);
}
}
/*處理積分充值的過程*/
elseif ($pay_log['order_type'] == 2)
{
$sql = 'SELECT `id` FROM ' . $GLOBALS['ecs']->table('user_account') . ?" WHERE `id` = '$pay_log[order_id]' AND `is_paid` = 1 ?LIMIT 1";
$res_id=$GLOBALS['db']->getOne($sql);
if(empty($res_id))
{
/* 更新會員預(yù)付款的到款狀態(tài) */
$sql = 'UPDATE ' . $GLOBALS['ecs']->table('user_account') .
" SET paid_time = '" .gmtime(). "', is_paid = 1" .
" WHERE id = '$pay_log[order_id]' LIMIT 1";
$GLOBALS['db']->query($sql);
/* 取得添加預(yù)付款的用戶以及金額 */
$sql = "SELECT user_id, amount,pay_points FROM " . $GLOBALS['ecs']->table('user_account') .
" WHERE id = '$pay_log[order_id]'";
$arr = $GLOBALS['db']->getRow($sql);
/* 修改會員帳戶金額 */
log_account_change($arr['user_id'], 0, 0, 0, $arr['pay_points'], '積分充值', ACT_SAVING);//積分充值
}
}
}
else
{
/* 取得已發(fā)貨的虛擬商品信息 */
$post_virtual_goods = get_virtual_goods($pay_log['order_id'], true);
/* 有已發(fā)貨的虛擬商品 */
if (!empty($post_virtual_goods))
{
$msg = '';
/* 檢查兩次刷新時間有無超過12小時 */
$sql = 'SELECT pay_time, order_sn FROM ' . $GLOBALS['ecs']->table('order_info') . " WHERE order_id = '$pay_log[order_id]'";
$row = $GLOBALS['db']->getRow($sql);
$intval_time = gmtime() - $row['pay_time'];
if ($intval_time >= 0 && $intval_time < 3600 * 12)
{
$virtual_card = array();
foreach ($post_virtual_goods as $code => $goods_list)
{
/* 只處理虛擬卡 */
if ($code == 'virtual_card')
{
foreach ($goods_list as $goods)
{
if ($info = virtual_card_result($row['order_sn'], $goods))
{
$virtual_card[] = array('goods_id'=>$goods['goods_id'], 'goods_name'=>$goods['goods_name'], 'info'=>$info);
}
}
$GLOBALS['smarty']->assign('virtual_card', ? ? ?$virtual_card);
}
}
}
else
{
$msg = '' . ?$GLOBALS['_LANG']['please_view_order_detail'] . '
';
}
$GLOBALS['_LANG']['pay_success'] .= $msg;
}
/* 取得未發(fā)貨虛擬商品 */
$virtual_goods = get_virtual_goods($pay_log['order_id'], false);
if (!empty($virtual_goods))
{
$GLOBALS['_LANG']['pay_success'] .= '
' . $GLOBALS['_LANG']['virtual_goods_ship_fail'];
}
}
}
}
6,后臺管理員確認設(shè)置
后臺管理員可以直接確認充值成功,在此處理程序就不做詳細解釋。
總結(jié):此次二次開發(fā)主要是處理在線接口完成支付回調(diào)信息的處理。
版權(quán)聲明:
本站資源均來自互聯(lián)網(wǎng)或會員發(fā)布,如果侵犯了您的權(quán)益請與我們聯(lián)系,我們將在24小時內(nèi)刪除!謝謝!
轉(zhuǎn)載請注明:
ecshop積分充值可充值等級積分余消費積分教程
標簽:
ecshop積分
相關(guān)文章
-
12-17
(自適應(yīng)手機端)響應(yīng)式合同申請書網(wǎng)站模板 word文檔pbootcms網(wǎng)站源碼下載
-
12-14
(自適應(yīng)手機端)圖書期刊繪本網(wǎng)站模板 畫報期刊雜志pbootcms網(wǎng)站源碼下載
-
12-10
(自適應(yīng)手機)牙科診所網(wǎng)站pbootcms模板 牙科醫(yī)院網(wǎng)站源碼下載
-
12-07
(自適應(yīng)手機端)響應(yīng)式電子設(shè)備網(wǎng)站模板 - 數(shù)碼科技企業(yè)產(chǎn)品pbootcms源碼帶下載功能
-
12-04
(自適應(yīng)手機)響應(yīng)式個人博客網(wǎng)站模版 美文博客pbootcms源碼下載 - 帶評論功能
-
11-30
(自適應(yīng)手機)響應(yīng)式機械風(fēng)機設(shè)備網(wǎng)站模板 五金設(shè)備制造儀器易優(yōu)CMS源碼下載
-
12-01
(自適應(yīng)手機)高爾夫球場pbootcms網(wǎng)站模板 體育運動場網(wǎng)站源碼下載
-
11-29
(自適應(yīng)手機)電子產(chǎn)品網(wǎng)站pbootcms模板 智能手表數(shù)碼相機網(wǎng)站源碼下載
-
11-28
易優(yōu)問答插件
-
11-27
PhpStorm 2020.1【PHP編程軟件】中文破解版下載
-
11-25
(自適應(yīng)手機)童裝外貿(mào)網(wǎng)站pbootcms模板 中英文童裝雙語網(wǎng)站源碼下載
-
11-22
易優(yōu)CMS多余圖片清理插件
-
11-23
易優(yōu)CMS文檔定時發(fā)布插件
-
11-21
(自適應(yīng)手機端)中英文雙語外貿(mào)網(wǎng)站汽車配件模板 汽車周邊產(chǎn)品pbootcms網(wǎng)站源碼下載
-
11-21
ps cs6軟件 Photoshop軟件 ps制圖軟件
-
11-21
易優(yōu)CMS relevarticle 相關(guān)文檔 調(diào)用
-
11-21
易優(yōu)CMS插件 相關(guān)文檔標簽
-
11-21
易優(yōu)CMS 插件使用教程
-
11-21
易優(yōu)CMS QQ一鍵登錄插件
-
11-21
易優(yōu)系統(tǒng)助手插件