Arliki

博客园 首页 新随笔 联系 订阅 管理

1.创建文件 includes/modules/auto_order_confirm.php

代码:(思路:对已经发货和已经付款的订单检索,对比发货时间与当前时间的间隔,达到设定时间则自动收货)

<?php
if (!defined('IN_ECS'))
{
    die('Hacking attempt');
}
$cron_lang = ROOT_PATH . 'languages/' .$GLOBALS['_CFG']['lang']. '/cron/auto_order_confirm.php';
require_once(ROOT_PATH . 'includes/lib_order.php');
if (file_exists($cron_lang)) {
    global $_LANG;
    include_once($cron_lang);
}
/* 模块的基本信息 */
if (isset($set_modules) && $set_modules == TRUE) {
    $i = isset($modules) ? count($modules) : 0;
    /* 代码 */
    $modules[$i]['code']    = basename(__FILE__, '.php');
    /* 描述对应的语言项 */
    $modules[$i]['desc']    = 'auto_order_desc';
    /* 作者 */
    $modules[$i]['author']  = 'Arliki';
    /* 网址 */
    $modules[$i]['website'] = 'http://www.baidu.com';
    /* 版本号 */
    $modules[$i]['version'] = '0.0.1';
    /* 配置信息 一般这一项通过serialize函数保存在cron表的中cron_config这个字段中*/
    $modules[$i]['config']  = array(
        array('name' => 'auto_order_days', 'type' => 'select', 'value' => 7)
    );
    //name:计划任务的名称,type:类型(text,textarea,select…),value:默认值
    return;
}
$now_time=gmtime();
$days = !empty($cron['auto_order_days']) ? $cron['auto_order_days'] : 7;
$select_sql = 'SELECT order_id, shipping_time,shipping_status FROM '.$ecs->table('order_info').' where shipping_status=1 and pay_status=2 ';
$order_val=$db->getAll($select_sql);
if (empty($order_val)) {
    return false;
}
foreach ($order_val as $key => $value) {
    if ($now_time-$value['shipping_time']>=$days*24*3600) {
        $order = order_info($value['order_id']);
        /* 标记订单为“收货确认”,如果是货到付款,同时修改订单为已付款 */
        $arr = array('shipping_status' => SS_RECEIVED);
        $payment = payment_info($order['pay_id']);
        if ($payment['is_cod'])
        {
            $arr['pay_status'] = PS_PAYED;
            $order['pay_status'] = PS_PAYED;
        }
        update_order($value['order_id'], $arr);
        /* 记录log */
        order_action($order['order_sn'], $order['order_status'], SS_RECEIVED, $order['pay_status'], $_LANG['action_note']);

    }
}
?>

 

2.创建文件:languages/zh_cn/cron/auto_order_condirm.php

代码:(文字描述以及时间设定)

<?php
global $_LANG;

$_LANG['auto_order_confirm']            = '自动收货';
$_LANG['auto_order_desc']       = '商家发货后一定天数自动确认收货';
$_LANG['auto_order_days']   = '最长等待时间';
$_LANG['action_note'] = '系统自动确认收货';
$_LANG['auto_order_days_range']['7'] = '7';
$_LANG['auto_order_days_range']['15'] = '15';
$_LANG['auto_order_days_range']['30'] = '30';
?>

3.如果需要,将另外两种语言的设置下即可(翻译第二个文件)。

 

 

posted on 2017-11-22 17:27  小程序源码下载  阅读(303)  评论(0编辑  收藏  举报