ecshop支付宝自动发货接口

2016-09-07 22:02 来源:www.chinab4c.com 作者:ecshop专家

 

一、   数据库order_info中添加trade_no 字段
SQL语句:   ALTER TABLE `ec_order_info` ADD COLUMN `trade_no`  varchar(100) NOT NULL DEFAULT '' AFTER `pay_name`;
 
二、 修改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);
 
三、 修改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);
 
 
 
四、 修改admin/order.php文件

 



最近更新

常用插件