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;
//计算支付手续费用
$payment_info['pay_fee'] = pay_fee($surplus['payment_id'], $order['surplus_amount'], 0);
//计算此次预付款需要支付的总金额
$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,这里把这个设置成2去边是积分充值。
/* 调用相应的支付方式文件 */
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,在第三部中用到函数insert_user_account这个函数需要修改为如下
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,修改支付回调函数
{
/* 取得支付编号 */
$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)
{
/* 修改此次支付操作的状态为已付款 */
$sql = 'UPDATE ' . $GLOBALS['ecs']->table('pay_log') .
" SET is_paid = '1' WHERE log_id = '$log_id'";
$GLOBALS['db']->query($sql);
/* 根据记录类型做相应处理 */
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'];
/* 修改订单状态为已付款 */
$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']);
/* 如果需要,发短信 */
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'];
}
/* 如果订单没有配送方式,自动完成发货操作 */
if ($order['shipping_id'] == -1)
{
/* 将订单标识为已发货状态,并记录发货记录 */
$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))
{
/* 更新会员预付款的到款状态 */
$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);
/* 取得添加预付款的用户以及金额 */
$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))
{
/* 更新会员预付款的到款状态 */
$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);
/* 取得添加预付款的用户以及金额 */
$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
{
/* 取得已发货的虚拟商品信息 */
$post_virtual_goods = get_virtual_goods($pay_log['order_id'], true);
/* 有已发货的虚拟商品 */
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;
}
/* 取得未发货虚拟商品 */
$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,后台管理员确认设置
后台管理员可以直接确认充值成功,在此处理程序就不做详细解释。
总结:此次二次开发主要是处理在线接口完成支付回调信息的处理。
版权声明:
本站资源均来自互联网或会员发布,如果侵犯了您的权益请与我们联系,我们将在24小时内删除!谢谢!
转载请注明:
ecshop积分充值可充值等级积分余消费积分教程
相关文章
-
11-21
(自适应手机端)中英文双语外贸网站汽车配件模板 汽车周边产品pbootcms网站源码下载
-
11-21
ps cs6软件 Photoshop软件 ps制图软件
-
11-21
易优CMS relevarticle 相关文档 调用
-
11-21
易优CMS插件 相关文档标签
-
11-21
易优CMS 插件使用教程
-
11-21
易优CMS QQ一键登录 原版 免授权
-
11-21
易优系统助手 原版 免授权
-
11-20
Windows电脑查看自己的系统版本
-
11-20
Windows PS软件AI PR AE LR ID AU 安装教程
-
11-20
ps软件 Photoshop2024软件 win/mac苹果版本ps制图软件
-
11-17
(自适应手机端)电子产品外贸企业网站pbootcms模板 - 机械电子设备英文网站源码带下载功能
-
11-14
(自适应手机端)响应式珠宝首饰pbootcms网站模板 奢侈品金店网站源码下载
-
11-10
(自适应手机端)电影解说文案网站模板 word资源剧情介绍网站源码下载
-
11-08
(带手机)工程造价财务审计网站模板 企业管理网站源码pbootcms下载
-
11-07
(自适应手机端)响应式图片展示pbootcms网站模板 图片素材网美女图片网站源码下载
-
11-06
(自适应手机端)无人机英文外贸网站源码下载 pbootcms电子产品企业网站模板下载
-
11-04
(自适应手机端)企业咨询管理网站pbootcms模板 金融服务机构业务咨询网站源码下载
-
11-03
(自适应手机端)响应式电脑手机维修类网站模版 电脑组装维修pbootcms网站源码下载
-
10-29
(PC+WAP)五金机械设备营销型网站模板 轴承电子挖掘机pbootcms源码下载
-
10-27
(自适应手机版)响应式五金外贸英文网站模板 机械电子重工业出口英文源码pbootcms下载