Home CMS Tutorial ECShop Detailed explanation of the development of automatic confirmation of orders in the ecshop backend

Detailed explanation of the development of automatic confirmation of orders in the ecshop backend

Dec 28, 2020 pm 06:01 PM
ecshop

ecshop Column introduces ecshop background order automatic confirmation development

Detailed explanation of the development of automatic confirmation of orders in the ecshop backend

## Recommended ( Free): ecshop

Detailed explanation of the development of automatic confirmation of orders in the ecshop backend

CREATE TABLE `order_auto_confirm` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`order_id` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`order_sn` VARCHAR(20) NOT NULL,
`execute_time` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`order_status` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' COMMENT '0未确定,1已经确定',
`addtime` INT(10) UNSIGNED NOT NULL DEFAULT '0',
`update_time` INT(10) UNSIGNED NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
UNIQUE INDEX `order_id` (`order_id`),
INDEX `execute_time` (`execute_time`)
)
COMMENT='订单定期自动确定'
COLLATE='utf8_general_ci'
ENGINE=MyISAM;
Copy after login
1. Add the following code to

/admin/order.php:

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

Add in elseif($_REQUEST['act'] == 'info'):

//取自动确定订单信息
$sql = 'select order_status, execute_time, addtime, update_time from '.$ecs->table('order_auto_confirm').' where order_id='.$order['order_id'];
$cron= $db->getRow($sql);
if(!empty($cron)){
if($cron['order_status'] == 1)
$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);
Copy after login
3.

/includes/modules/cron/order_auto_confirm.php

if (!defined('IN_ECS'))
{
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) : 0;    /* 代码 */
$modules[$i]['code']    = basename(__FILE__, '.php');    /* 描述对应的语言项 */
$modules[$i]['desc']    = 'order_auto_confirm_desc';    /* 作者 */
$modules[$i]['author']  = 'wjzhhr';    /* 网址 */
$modules[$i]['website'] = 'http://www.wodeqingchun.com';    /* 版本号 */
$modules[$i]['version'] = '1.0.0';    /* 配置信息 */
$modules[$i]['config']  = array(
array('name' => 'order_auto_confirm_count', 'type' => 'select', 'value' => '10'),
);    return;
}
$time  = gmtime();
//$time  = local_gettime();
$limit = empty($cron['order_auto_confirm_count']) ? 5 : $cron['order_auto_confirm_count'];
$sql   = "SELECT * FROM " . $GLOBALS['ecs']->table('order_auto_confirm') . " WHERE execute_time getAll($sql);
$i     = 0;
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'] == '1' && $_CFG['stock_dec_time'] == SDT_PLACE)
{
change_order_goods_storage($order_id, true, SDT_PLACE);
}        if($update_status)
{
$i  += 1;
$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
//zuimoban.com
*/
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);
}
?>
Copy after login
Four,

/languages/zh_cn/admin/order.php Add:

$_LANG['order_auto_croned'] = '此订单于 %s 已被确认';
$_LANG['order_auto_cron']   = '此订单于 %s 进行定时确认';
$_LANG['order_auto']        = '将此订单加入自动定时确认';
$_LANG['order_auto_time']   = '自动确认时间:';
Copy after login
Five,

/admin/themes/order_info.htm Add: {$lang.base_info} Add at the end:

Detailed explanation of the development of automatic confirmation of orders in the ecshop backend

Add in the JS of this page:

function order_cron(order_id, act){    var order_cron_time = 0;    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 == 0)  {      alert('保存成功');  }  else  {      alert(res.message);  }  return false;}
Copy after login
and whether /themes/default/footer.dwt contains:


{insert name='query_info'}This sentence is more important. The predecessors removed this sentence, which caused the most templates to look for the reason everywhere. A total of 5 files are involved, two newly added

The above is the detailed content of Detailed explanation of the development of automatic confirmation of orders in the ecshop backend. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What is the architecture of ecshop? What is the architecture of ecshop? Feb 23, 2023 am 09:32 AM

ecshop is a "B2C" architecture; ecshop is a B2C independent online store system, suitable for enterprises and individuals to quickly build personalized online stores; the system is a cross-platform open source program developed based on PHP language and MYSQL database architecture.

What are the methods for sorting ecshop articles? What are the methods for sorting ecshop articles? Jun 16, 2023 am 11:30 AM

How to sort ecshop articles: 1. Sort by publication time, you can control the order of articles in the list by modifying the publication time of the article; 2. Sort by clicks, you can achieve this sorting by installing the "Article Click Ranking" plug-in Function, this plug-in can count the number of clicks on articles; 3. Sort by the number of comments, you can implement this sorting function by installing the "Article Comment Ranking" plug-in, which can count the number of comments on articles; 4. Sort by relevance, This sorting function can be achieved by installing the "Search Ranking" plug-in.

What are the characteristics of ecshop? What are the characteristics of ecshop? Feb 13, 2023 am 09:43 AM

Features: 1. Open source system with flexibility, customizability and high scalability; 2. Support independent secondary development; 3. Rich templates and plug-ins; 4. Strong industry adaptability; 5. Avoid being constrained by software vendors; 6. Stronger reliability and stability; 7. Mobile H5 framework upgrade, based on VUE comprehensive replacement, more flexible and open; 8. Multi-level rebate function, supporting QR codes, posters and other promotion methods, unlimited fission development of distributors ; 8. The visual interaction of the management terminal is completely renewed, the UI is simple and beautiful, and the operating experience is upgraded; 9. Supports PHP7.2, and the performance is doubled.

What program is ecshop? What program is ecshop? Feb 16, 2023 am 10:38 AM

ECShop is a B2C independent online store system. It is a cross-platform open source program developed based on PHP language and MYSQL database architecture. It is suitable for enterprises and individuals to quickly build personalized online stores. The characteristics of the ecshop mall system: 1. Support independent secondary development; 2. Rich templates and plug-ins; 3. Strong industry adaptability; 4. Avoid being constrained by software vendors; 5. Stronger reliability and stability.

Ecshop product management advanced: learn how to add fields Ecshop product management advanced: learn how to add fields Mar 12, 2024 pm 02:06 PM

Ecshop Product Management Advanced: Learn how to add fields, you need specific code examples. When using Ecshop for product management, you often encounter situations where you need to add some custom fields to meet specific needs. By adding fields, more precise product management and better user experience can be achieved. This article will introduce how to add fields in Ecshop and provide specific code examples. First, we need to clarify the need to add fields. For example, we need to add a "production date" field to the product details page to

What is the model of ecshop? What is the model of ecshop? Feb 22, 2023 am 09:37 AM

ecshop is a B2C model. ECShop is a B2C independent online store system, suitable for enterprises and individuals to quickly build personalized online stores. B2C refers to a model of e-commerce, and it is also a retail model that sells products and services directly to consumers; the payment method of B2C e-commerce is a combination of cash on delivery and online payment, and most companies choose logistics outsourcing for delivery. to save operating costs.

How to remove copyright at the bottom of ecshop How to remove copyright at the bottom of ecshop Aug 08, 2023 pm 02:42 PM

Method to remove the copyright at the bottom of ecshop: 1. Modify the template file, the specific location is: themes/your_theme directory, find the footer.html file in this directory, open it with a text editor, find the code segment containing the copyright information, delete it or Comment out. Just save the file and close it; 2. To use the plug-in, log in to the backend, click plug-in management, search for copyright and other related keywords at the bottom, select a suitable plug-in to install and enable it; 3. To purchase a theme, purchase it on the official website of ECShop etc.

How to cancel delivery method in ecshop How to cancel delivery method in ecshop Mar 03, 2023 am 09:56 AM

How to cancel the shipping method in ecshop: 1. Find and open the "flow.dwt" file, and then delete "<!--{if $total.real_goods_count neq 0}-->...<!-- {/if} - ->" code; 2. Change "checkOrderForm(frm)" in "js/shopping_flow.js" to "if (document.getElementById(...)".

See all articles