1、运行sql代码,生成数据库

CREATE TABLE `ecs_order_auto_confirm` (
`id` INT() UNSIGNED NOT NULL AUTO_INCREMENT,
`order_id` INT() UNSIGNED NOT NULL DEFAULT '',
`order_sn` VARCHAR() NOT NULL,
`execute_time` INT() UNSIGNED NOT NULL DEFAULT '',
`order_status` TINYINT() UNSIGNED NOT NULL DEFAULT '' COMMENT '0未确定,1已经确定',
`addtime` INT() UNSIGNED NOT NULL DEFAULT '',
`update_time` INT() UNSIGNED NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
UNIQUE INDEX `order_id` (`order_id`),
INDEX `execute_time` (`execute_time`)
)
COMMENT='订单定期自动确定'
COLLATE='utf8_general_ci'
ENGINE=MyISAM;

2./admin/order.php加入以下代码:

elseif($_REQUEST['act'] == 'order_cron'){
$act1 = empty($_POST['act1']) ? : $_POST['act1'];
if(empty($act1) || !in_array($act1, array('add', 'cancel'))) make_json_response('', -, '未知请求act1'); $order_id = intval($_POST['order_id']);
$order = order_info($order_id);
if(empty($order)) make_json_response('', -, '没有此订单ID');
if($order['order_status']) make_json_response('', -, '此订单已经确认,不用自动确认');
if($order['pay_status']) make_json_response('', -, '此订单支付状态已经变动,无法添加任务');
if($act1 == 'add'){
$order_cron_time = empty($_POST['order_cron_time']) ? : $_POST['order_cron_time'];
if(empty($order_cron_time)) make_json_response('', -, '请求的时间错误');
$sql = 'select order_id from '.$GLOBALS['ecs']->table('order_auto_confirm').' where order_id='.$order_id;
$rs = $db->getRow($sql);
if($rs['order_id'] == $order_id){
make_json_response('', -, '此订单任务已经存在,不能重复添加');
}
$execute_time = local_strtotime($order_cron_time);
$sql = "insert into ".$GLOBALS['ecs']->table('order_auto_confirm')."(order_id, order_sn, execute_time, order_status, addtime) values(".$order_id.",'".$order['order_sn']."',".$execute_time.", 0, ".local_gettime().")";
$result = $db->query($sql);
if($result){
make_json_response('', , '');
}
make_json_response('', -, '添加任务计划失败');
}elseif($act1 == 'cancel'){
$sql = 'delete from '.$GLOBALS['ecs']->table('order_auto_confirm').' where order_id='.$order_id.' and order_status=0 ';
$db->query($sql);
make_json_response('', , '');
}
}

在elseif ($_REQUEST['act'] == 'info')里加入:

//取自动确定订单信息
$sql = 'select order_status, execute_time, addtime, update_time from '.$GLOBALS['ecs']->table('order_auto_confirm').' where order_id='.$order['order_id'];
$cron= $db->getRow($sql);
if(!empty($cron)){
if($cron['order_status'] == )
$cron['update_time'] = sprintf($_LANG['order_auto_croned'], local_date('Y-m-d H:i:s', $cron['update_time']));
else
$cron['execute_time']= sprintf($_LANG['order_auto_cron'], local_date('Y-m-d H:i:s', $cron['execute_time']));
}
$smarty->assign('cron', $cron);

2.新建php文件/includes/modules/cron/order_auto_confirm.php

<?php
if (!defined('IN_HAIMIYA')){
die('Hacking attempt');
}
require_once(ROOT_PATH . 'includes/lib_order.php');
$cron_lang = ROOT_PATH . 'languages/' .$GLOBALS['_CFG']['lang']. '/cron/order_auto_confirm.php';
if (file_exists($cron_lang)){
global $_LANG;
include_once($cron_lang);
}/* 模块的基本信息 */
if (isset($set_modules) && $set_modules == TRUE){
$i = isset($modules) ? count($modules) : ; /* 代码 */
$modules[$i]['code'] = basename(__FILE__, '.php'); /* 描述对应的语言项 */
$modules[$i]['desc'] = 'order_auto_confirm_desc'; /* 作者 */
$modules[$i]['author'] = ''; /* 网址 */
$modules[$i]['website'] = ''; /* 版本号 */
$modules[$i]['version'] = '1.0.0'; /* 配置信息 */
$modules[$i]['config'] = array(
array('name' => 'order_auto_confirm_count', 'type' => 'select', 'value' => ''),
);
return;
}
$time = gmtime();
$limit = empty($cron['order_auto_confirm_count']) ? : $cron['order_auto_confirm_count'];
$sql = "SELECT * FROM " . $GLOBALS['ecs']->table('order_auto_confirm') . " WHERE execute_time <= ".$time." and order_status=0 LIMIT $limit";
$autodb= $db->getAll($sql);
$i = ;
foreach ($autodb as $key => $val){
$order_id = $val['order_id'];
$order_sn = $val['order_sn'];
/* 标记订单为已确认 */
$update_status = update_order($order_id, array('order_status' => OS_CONFIRMED, 'confirm_time' => gmtime()));
update_order_amount($order_id); /* 记录log */
$action_note = "计划任务:定期自动确定订单,订单号:".$order_sn.",执行状态:".($update_status ? '成功' : '失败');
order_action($order_sn, OS_CONFIRMED, SS_UNSHIPPED, PS_UNPAYED, $action_note, 'system_cron'); /* 如果原来状态不是“未确认”,且使用库存,且下订单时减库存,则减少库存 */
if ($val['order_status'] != OS_UNCONFIRMED && $_CFG['use_storage'] == '' && $_CFG['stock_dec_time'] == SDT_PLACE){
change_order_goods_storage($order_id, true, SDT_PLACE);
}
if($update_status){
$i += ;
$sql = "update " . $GLOBALS['ecs']->table('order_auto_confirm') . " set order_status=1, update_time=".$time." where order_id=".$order_id;
$db->query($sql);
}
}
$string = '此次共更新:'.$i.'条数据';
echo $string;file_put_contents('./a.txt', $time . '----' . date('Y-m-d H:i:s').$string."\r\n", FILE_APPEND); /**
* 更新订单总金额
* @param int $order_id 订单id
* @return bool
*/
function update_order_amount($order_id){
include_once(ROOT_PATH . 'includes/lib_order.php');
//更新订单总金额
$sql = "UPDATE " . $GLOBALS['ecs']->table('order_info') . " SET order_amount = " . order_due_field() . " WHERE order_id = '$order_id' LIMIT 1"; return $GLOBALS['db']->query($sql);
}
?>

3.新建php文件/languages/zh_cn/cron/order_auto_confirm.php

<?php
global $_LANG;
$_LANG['order_auto_confirm'] = '订单定期自动确定';
$_LANG['order_auto_confirm_desc'] = '定期自动确定订单';
$_LANG['order_auto_confirm_count'] = '每次处理记录个数';
$_LANG['order_auto_confirm_count_range'][''] = '';
$_LANG['order_auto_confirm_count_range'][''] = '';
$_LANG['order_auto_confirm_count_range'][''] = '';
$_LANG['order_auto_confirm_count_range'][''] = '';
?>

4.在/languages/zh_cn/admin/order.php里加入:

/* 订单自动确认 */
$_LANG['order_auto_croned'] = '此订单于 %s 已被确认';
$_LANG['order_auto_cron'] = '此订单于 %s 进行定时确认';
$_LANG['order_auto'] = '<font color=red>将此订单加入自动定时确认</font>';
$_LANG['order_auto_time'] = '自动确认时间:';

5./admin/themes/order_info.htm 在:{$lang.base_info}后面加入:

在:{$lang.base_info}后面加入:

    <!--{if $order.status ==  && $order.pay_status ==  }-->
<script type="text/javascript" src="../js/calendar.php?lang={$cfg_lang}"></script>
<link href="../js/calendar/calendar.css" rel="stylesheet" type="text/css" />
<div id="order_auto_cron" style="display: inline-block; width: 300px;">
<!--{if !$cron}-->
<a href="javascript:;" id="ccd" onclick="document.getElementById('select_time').style.display=''; this.style.display='none';">{$lang.order_auto}</a>
<span id="select_time" style="display: none;">{$lang.order_auto_time}
<input type="text" class="button" id="order_cron_time" value="" onclick="return showCalendar('order_cron_time', '%Y-%m-%d %H:%M:%S', '24', false, 'order_cron_time');" name="order_cron_time">
<input type="button" value="保存" id="ccd_save" class="button" onclick="order_cron({$order.order_id}, 'add');">
<a href="javascript:;" onclick="document.getElementById('select_time').style.display='none'; document.getElementById('ccd').style.display='';">{$lang.op_cancel}</a>
</span>
<!--{elseif $cron.order_status == }-->
{$cron.execute_time}
<a href="javascript:;" onclick="if(confirm('确定要删除定时执行任务吗?')){order_cron({$order.order_id}, 'cancel');}else{return false;}">{$lang.op_cancel}</a>
<!--{else $cron.order_status == }-->
{$cron.update_time}
<!--{/if}-->
</div>
<!--{/if}-->

在此页面的JS里面加入:

function order_cron(order_id, act){
var order_cron_time = ;
if(act == 'add'){
order_cron_time = document.getElementById('order_cron_time').value;
if(!order_cron_time){
alert('无法获取时间');
return false;
}
}
Ajax.call('order.php?act=order_cron', 'order_id=' + order_id + '&act1=' + act + '&order_cron_time=' + order_cron_time, order_cron_response, 'POST', 'JSON');
}
function order_cron_response(res){
if (res.error == ){
alert('保存成功');
}
else{
alert(res.message);
}
return false;
}

6.需保证在themes\default\library\page_footer.lbi文件中存在

{insert name='query_info'}

7.到后台"系统设置"->"计划任务"点击安装

ECSHOP订单自动确认的更多相关文章

  1. PHP电商订单自动确认收货redis队列

    一.场景 之前做的电商平台,用户在收到货之后,大部分都不会主动的点击确认收货,导致给商家结款的时候,商家各种投诉,于是就根据需求,要做一个订单在发货之后的x天自动确认收货.所谓的订单自动确认收货,就是 ...

  2. ecshop自动确认收货(无其他商家)

    1.创建文件 includes/modules/auto_order_confirm.php 代码:(思路:对已经发货和已经付款的订单检索,对比发货时间与当前时间的间隔,达到设定时间则自动收货) &l ...

  3. ecshop订单状态对应值详解

    ecshop的订单状态都是在ecs_order_info表中的字段里. 订单状态 未确认 取消 确认 已付款 配货中 已发货 已收货 退货 order_status 0 2 1 1 1 5 5 4 s ...

  4. ecshop订单打印页显示商品缩略图和序号

    ecshop订单打印页显示商品缩略图和序号 订单打印页显示商品缩略图,在论坛没找到适合2.7.2相关的文章,特意贴上来给大家研究一下.1.找到 $sql = "SELECT o.*, IF( ...

  5. SAP交货单过账自动生产采购订单、采购订单自动收货入库

    公司间需要买卖操作,由于发货和收货都是同一批人在操作,为了减少业务人员的工作量,提高工作效率,特实现以上功能 1.增强实现:增强点为交货单过账成功时触发,在提交前触发,如果遇到不可预知问题,可能造成数 ...

  6. 消息中间件系列三:使用RabbitMq原生Java客户端进行消息通信(消费者(接收方)自动确认模式、消费者(接收方)自行确认模式、生产者(发送方)确认模式)

    准备工作: 1)安装RabbitMQ,参考文章:消息中间件系列二:RabbitMQ入门(基本概念.RabbitMQ的安装和运行) 2.)分别新建名为OriginalRabbitMQProducer和O ...

  7. Atitit. 订单管理 收银单持久化 功能设计  基于ecshop订单结构

    Atitit. 订单管理 收银单持久化 功能设计  基于ecshop订单结构 1. 54.order_info  订单 数据结构1 2. Ecshop 的订单api1 2.1. 生成订单 code b ...

  8. 关于web开发中订单自动超时和自动收货的简单方法(window server)

    最近做一个订单自动超时和自动收货的功能,因为以前是用的mysql 存储过程和定时器来完成,这次的业务逻辑相对复杂用以前的方式就不太合适,本来是准备使用定时执行php脚本来实现的,后来发现业务逻辑中使用 ...

  9. iOS逆向实战与工具使用(微信添加好友自动确认)

    iOS逆向实战与工具使用(微信添加好友自动确认) 原文链接 源码地址 WeChatPlugin-iOS Mac OS 版微信小助手(远程控制.消息防撤回.自动回复.微信多开) 一.前言 本篇主要实现在 ...

随机推荐

  1. IOS开发 xcode报错之has been modified since the precompiled header was built

    转载的文章  很实用 IOS开发xcode报错之has been modified since the precompiled header was built 今天做百度地图的时候第一次发现下面错误 ...

  2. 菜菜菜鸟学习之JavaWeb 入门1(自己的学习理解,不对之处请大神们多多指教啊)

    一.相关基础知识 1.C/S(Client/Server)架构和B/S(Browser/Server)架构 首先说C/S架构,简单讲其实很常见,类似QQ等需要下载客户端的应用程序就是建立在C/S架构中 ...

  3. java cpu load

    $ps -Lp 179093 cu | more USER PID LWP %CPU NLWP %MEM VSZ RSS TTY STAT START TIME COMMAND admin 17909 ...

  4. 怒学三算法 POJ 2387 Til the Cows Come Home (Bellman_Ford || Dijkstra || SPFA)

    Til the Cows Come Home Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 33015   Accepted ...

  5. OpenShare新功能@2014年10月

    新功能@ Oct,2014 增强“应用中心”(就是“企业应用门户”功能):在Dock上增加“应用中心”图标,使得用户无论在任何页面,任何位置,永远都是点击一下即可进入任一企业应用,而无需回退到门户主页 ...

  6. 基础面试题——Javascript

    1.介绍js的基本数据类型 Undefined.Null.Boolean.Number.String 2.js有哪些内置对象? 数据封装类对象:Object.Array.Boolean.Number ...

  7. 简单的表单验证插件(Jquery)

    在做web开发的时候经常遇到表单验证问题,表单验证一般有客户端验证和服务器端验证,这个验证插件仅仅能满足我的项目中的基本需求的. Validate_Tools.js function Validate ...

  8. vSphere存储

    write by xiaoyang 配置iSCSI外部存储 1.      选择配置——硬件——存储 2.      在存储适配器里选择添加软件iSCSI适配器 3.      确认添加 4.     ...

  9. OSPF系列

    实验一.点对点链路上的OSPF 拓扑图 1. 首先配置好路由器R1接口地址和回环地址 2. 配置路由器R2的接口地址和回环地址 3. 配置路由器R3的接口地址和环回地址 4. 配置R1的OSPF协议 ...

  10. 找不到命名空间命名空间:System.Windows.Forms

    System.Windows.Forms在system.windows.forms.dll中.需要添加引用.在解决方案资源管理器中的引用上单击右键,选择添加引用.找到System.windows.fo ...