花魁直播高品质美女在线视频互动社区 - 花魁直播官方版

 歡迎來到素材無憂網(wǎng),按 + 收藏我們
登錄 注冊 退出 找回密碼

ecshop積分充值可充值等級積分余消費積分教程

時間: 2024-02-25 10:43 閱讀: 作者:素材無憂網(wǎng)

隨著實體店與網(wǎng)店的結(jié)合 很多實體店開始開發(fā)屬于自己的網(wǎng)上商城,網(wǎng)絡(luò)商城經(jīng)常有一個做法就是不人名幣轉(zhuǎn)換成商城自己的表示方式,在此就叫做積分。ecshop有一個功能是在線充值人名幣,現(xiàn)在我用此功能來實現(xiàn)人名幣充值積分。
1,充值頁面
ecshop用戶中心user.php下‘a(chǎn)ccount_deposit’下的程序與user_transaction.dwt下account_deposit的模版信息作為蟲子積分的充值程序與模版文件。
2,數(shù)據(jù)庫處理。
在數(shù)據(jù)庫user_account中添加字段pay_points用于存取充值換算下來的積分。
3,充值提交程序處理
ecshop默認充值程序包括了退款與沖值的兩個過程,在此我把簡化好的程序貼出 供大家研究
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ù)
支付回調(diào)函數(shù)在lib_payment.php中的order_paid,現(xiàn)在添加回調(diào)的處理。
{
/* 取得支付編號 */
$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)文章
推薦文章
模板推薦