1、 在數據庫order_info中添加trade_no 字段
SQL語句: ALTER TABLE `ec_order_info` ADD COLUMN `trade_no` varchar(100) NOT NULL DEFAULT '' AFTER `pay_name`;
2、 修改includes/modules/payment/alipay.php文件
查找:$order_sn = trim($order_sn);
代碼之下添加:$trade_no = trim($_GET['trade_no']);//獲取支付寶交易號
查找:
if ($_GET['trade_status'] == 'WAIT_SELLER_SEND_GOODS')
{
/* 改變訂單狀態 */
order_paid($order_sn, 2);
修改:
if ($_GET['trade_status'] == 'WAIT_SELLER_SEND_GOODS')
{
/* 改變訂單狀態 */
order_paid($order_sn, 2,'',$trade_no);
3、 修改includes/lib_payment.php文件原文件118行開始
/**
* 修改訂單的支付狀態
*
* @access public
* @param string $log_id 支付編號
* @param integer $pay_status 狀態
* @param string $note 備註
* @param string $trade_no 支付寶交易號
* @return void
*/
function order_paid($log_id, $pay_status = PS_PAYED, $note = '',$trade_no = '')
{
/* 取得支付編號 */
$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, trade_no, 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'];
/*解決訂單修改後屢次付款發貨確認*/
$trade = $order['trade_no'];
if (!empty($trade))
{
$trade_no = $trade.",".$trade_no;
}
/* 修改訂單狀態爲已付款 */
$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," .
" trade_no = '$trade_no',".//更新支付寶交易號
" order_amount = 0 ".
"WHERE order_id = '$order_id'";
$GLOBALS['db']->query($sql);
4、 修改admin/order.php文件
查找:
$smarty->assign('action_list', $act_list);
/* 模板賦值 */
$smarty->assign('delivery_order', $delivery_order);
$smarty->assign('goods_list', $goods_list);
$smarty->assign('delivery_id', $delivery_id); // 發貨單id
代碼之上添加:
/*判斷支付方式是否支付寶*/
$alipay = false;
$order = order_info($delivery_order['order_id']); //根據訂單ID查詢訂單信息,返回數組$order
$payment = payment_info($order['pay_id']); //取得支付方式信息
if($payment['pay_code'] == "alipay" && $delivery_order['status'] == 2 && !empty($order['trade_no']))
{
$alipay = true;
}
$smarty->assign('alipay', $alipay);
5、 修改admin\templates\delivery_info.htm文件
查找: <form action="order.php" method="post" name="theForm">
替換:<form {if $alipay}onSubmit="this.target='_blank';this.action='alipay_delivery.php';
this.submit();this.target='_self';this.action='order.php'"{else}action="order.php"{/if} method="post" name="theForm">
6、 上傳alipay_delivery.php文件到admin 目錄下
alipay_delivery.php文件見附件php