{"id":31833,"date":"2024-11-25T11:44:46","date_gmt":"2024-11-25T03:44:46","guid":{"rendered":"https:\/\/fwq.ai\/blog\/31833\/"},"modified":"2024-11-25T11:44:46","modified_gmt":"2024-11-25T03:44:46","slug":"ecshop%e5%ae%9e%e7%8e%b0%e5%90%8e%e5%8f%b0%e8%ae%a2%e5%8d%95%e8%87%aa%e5%8a%a8%e7%a1%ae%e8%ae%a4%e5%bc%80%e5%8f%91%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/31833\/","title":{"rendered":"ecshop\u5b9e\u73b0\u540e\u53f0\u8ba2\u5355\u81ea\u52a8\u786e\u8ba4\u5f00\u53d1\u65b9\u6cd5"},"content":{"rendered":"<h2> \u680f\u76ee\u4ecb\u7ecd\u5b9e\u73b0\u540e\u53f0\u8ba2\u5355\u81ea\u52a8\u786e\u8ba4\u5f00\u53d1\u65b9\u6cd5<\/h2>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202012\/02\/2020120217104885715.jpg\" class=\"aligncenter\" title=\"ecshop\u5b9e\u73b0\u540e\u53f0\u8ba2\u5355\u81ea\u52a8\u786e\u8ba4\u5f00\u53d1\u65b9\u6cd5\u63d2\u56fe\" alt=\"ecshop\u5b9e\u73b0\u540e\u53f0\u8ba2\u5355\u81ea\u52a8\u786e\u8ba4\u5f00\u53d1\u65b9\u6cd5\u63d2\u56fe\" \/><\/p>\n<p><strong>\u63a8\u8350\uff08\u514d\u8d39\uff09\uff1a<\/strong><\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/image\/915\/465\/637\/1606900056724663.png\" class=\"aligncenter\" title=\"ecshop\u5b9e\u73b0\u540e\u53f0\u8ba2\u5355\u81ea\u52a8\u786e\u8ba4\u5f00\u53d1\u65b9\u6cd5\u63d2\u56fe1\" alt=\"ecshop\u5b9e\u73b0\u540e\u53f0\u8ba2\u5355\u81ea\u52a8\u786e\u8ba4\u5f00\u53d1\u65b9\u6cd5\u63d2\u56fe1\" \/><\/p>\n<pre>CREATE TABLE `order_auto_confirm` (\n\n`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,\n\n`order_id` INT(10) UNSIGNED NOT NULL DEFAULT '0',\n\n`order_sn` VARCHAR(20) NOT NULL,\n\n`execute_time` INT(10) UNSIGNED NOT NULL DEFAULT '0',\n\n`order_status` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' COMMENT '0\u672a\u786e\u5b9a\uff0c1\u5df2\u7ecf\u786e\u5b9a',\n\n`addtime` INT(10) UNSIGNED NOT NULL DEFAULT '0',\n\n`update_time` INT(10) UNSIGNED NOT NULL DEFAULT '0',\n\nPRIMARY KEY (`id`),\n\nUNIQUE INDEX `order_id` (`order_id`),\n\nINDEX `execute_time` (`execute_time`)\n\n)\n\nCOMMENT='\u8ba2\u5355\u5b9a\u671f\u81ea\u52a8\u786e\u5b9a'\n\nCOLLATE='utf8_general_ci'\n\nENGINE=MyISAM;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4e00\u3001<\/p>\n<p>\/admin\/order.php\u52a0\u5165\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre>elseif($_REQUEST['act'] == 'order_cron')\n\n{\n\n$act1 = empty($_POST['act1']) ? 0 : $_POST['act1'];\n\nif(empty($act1) || !in_array($act1, array('add', 'cancel'))) make_json_response('', -1, '\u672a\u77e5\u8bf7\u6c42act1');    $order_id = intval($_POST['order_id']);\n\n$order = order_info($order_id);\n\nif(empty($order)) make_json_response('', -2, '\u6ca1\u6709\u6b64\u8ba2\u5355ID');    if($order['order_status']) make_json_response('', -3, '\u6b64\u8ba2\u5355\u5df2\u7ecf\u786e\u8ba4\uff0c\u4e0d\u7528\u81ea\u52a8\u786e\u8ba4');    if($order['pay_status']) make_json_response('', -4, '\u6b64\u8ba2\u5355\u652f\u4ed8\u72b6\u6001\u5df2\u7ecf\u53d8\u52a8\uff0c\u65e0\u6cd5\u6dfb\u52a0\u4efb\u52a1');    if($act1 == 'add'){\n\n$order_cron_time = empty($_POST['order_cron_time']) ? 0 : $_POST['order_cron_time'];        if(empty($order_cron_time)) make_json_response('', -10, '\u8bf7\u6c42\u7684\u65f6\u95f4\u9519\u8bef');        $sql = 'select order_id from '.$ecs-&gt;table('order_auto_confirm').' where order_id='.$order_id;\n\n$rs  = $db-&gt;getRow($sql);\n\nif($rs['order_id'] == $order_id){\n\nmake_json_response('', -30, '\u6b64\u8ba2\u5355\u4efb\u52a1\u5df2\u7ecf\u5b58\u5728\uff0c\u4e0d\u80fd\u91cd\u590d\u6dfb\u52a0');\n\n}\n\n$execute_time = local_strtotime($order_cron_time);\n\n$sql    = \"insert into \".$ecs-&gt;table('order_auto_confirm').\"(order_id, order_sn, execute_time, order_status, addtime) values(\".$order_id.\",'\".$order['order_sn'].\"',\".$execute_time.\", 0, \".local_gettime().\")\";\n\n$result = $db-&gt;query($sql);\n\nif($result){\n\nmake_json_response('', 0, '');\n\n}\n\nmake_json_response('', -9, '\u6dfb\u52a0\u4efb\u52a1\u8ba1\u5212\u5931\u8d25');\n\n}elseif($act1 == 'cancel'){\n\n$sql = 'delete  from '.$ecs-&gt;table('order_auto_confirm').' where order_id='.$order_id.' and order_status=0 ';\n\n$db-&gt;query($sql);\n\nmake_json_response('', 0, '');\n\n}\n\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4e8c\u3001<\/p>\n<p>\u5728elseif($_REQUEST[&#8216;act&#8217;] == &#8216;info&#8217;)\u91cc\u52a0\u5165\uff1a<\/p>\n<pre>\/\/\u53d6\u81ea\u52a8\u786e\u5b9a\u8ba2\u5355\u4fe1\u606f\n\n$sql = 'select order_status, execute_time, addtime, update_time from '.$ecs-&gt;table('order_auto_confirm').' where order_id='.$order['order_id'];\n\n$cron= $db-&gt;getRow($sql);\n\nif(!empty($cron)){\n\nif($cron['order_status'] == 1)\n\n$cron['update_time'] = sprintf($_LANG['order_auto_croned'], local_date('Y-m-d H:i:s', $cron['update_time']));\n\nelse\n\n$cron['execute_time']= sprintf($_LANG['order_auto_cron'], local_date('Y-m-d H:i:s', $cron['execute_time']));\n\n}\n\n$smarty-&gt;assign('cron', $cron);<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4e09\u3001<\/p>\n<p>\/includes\/modules\/cron\/order_auto_confirm.php<\/p>\n<pre>if (!defined('IN_ECS'))\n\n{\n\ndie('Hacking attempt');\n\n}\n\nrequire_once(ROOT_PATH . 'includes\/lib_order.php');\n\n$cron_lang = ROOT_PATH . 'languages\/' .$GLOBALS['_CFG']['lang']. '\/cron\/order_auto_confirm.php';\n\nif (file_exists($cron_lang))\n\n{\n\nglobal $_LANG;    include_once($cron_lang);\n\n}\/* \u6a21\u5757\u7684\u57fa\u672c\u4fe1\u606f *\/\n\nif (isset($set_modules) &amp;&amp; $set_modules == TRUE)\n\n{\n\n$i = isset($modules) ? count($modules) : 0;    \/* \u4ee3\u7801 *\/\n\n$modules[$i]['code']    = basename(__FILE__, '.php');    \/* \u63cf\u8ff0\u5bf9\u5e94\u7684\u8bed\u8a00\u9879 *\/\n\n$modules[$i]['desc']    = 'order_auto_confirm_desc';    \/* \u4f5c\u8005 *\/\n\n$modules[$i]['author']  = 'wjzhhr';    \/* \u7f51\u5740 *\/\n\n$modules[$i]['website'] = 'http:\/\/www.wodeqingchun.com';    \/* \u7248\u672c\u53f7 *\/\n\n$modules[$i]['version'] = '1.0.0';    \/* \u914d\u7f6e\u4fe1\u606f *\/\n\n$modules[$i]['config']  = array(\n\narray('name' =&gt; 'order_auto_confirm_count', 'type' =&gt; 'select', 'value' =&gt; '10'),\n\n);    return;\n\n}\n\n$time  = gmtime();\n\n\/\/$time  = local_gettime();\n\n$limit = empty($cron['order_auto_confirm_count']) ? 5 : $cron['order_auto_confirm_count'];\n\n$sql   = \"SELECT * FROM \" . $GLOBALS['ecs']-&gt;table('order_auto_confirm') . \" WHERE execute_time &lt;= \".$time.\" and order_status=0 LIMIT $limit\";\n\n$autodb= $db-&gt;getAll($sql);\n\n$i     = 0;\n\nforeach ($autodb as $key =&gt; $val)\n\n{\n\n$order_id = $val['order_id'];\n\n$order_sn = $val['order_sn'];\n\n\/* \u6807\u8bb0\u8ba2\u5355\u4e3a\u5df2\u786e\u8ba4 *\/\n\n$update_status = update_order($order_id, array('order_status' =&gt; OS_CONFIRMED, 'confirm_time' =&gt; gmtime()));\n\nupdate_order_amount($order_id);        \/* \u8bb0\u5f55log *\/\n\n$action_note = \"\u8ba1\u5212\u4efb\u52a1\uff1a\u5b9a\u671f\u81ea\u52a8\u786e\u5b9a\u8ba2\u5355\uff0c\u8ba2\u5355\u53f7\uff1a\".$order_sn.\"\uff0c\u6267\u884c\u72b6\u6001\uff1a\".($update_status ? '\u6210\u529f' : '\u5931\u8d25');\n\norder_action($order_sn, OS_CONFIRMED, SS_UNSHIPPED, PS_UNPAYED, $action_note, 'system_cron');        \/* \u5982\u679c\u539f\u6765\u72b6\u6001\u4e0d\u662f\u201c\u672a\u786e\u8ba4\u201d\uff0c\u4e14\u4f7f\u7528\u5e93\u5b58\uff0c\u4e14\u4e0b\u8ba2\u5355\u65f6\u51cf\u5e93\u5b58\uff0c\u5219\u51cf\u5c11\u5e93\u5b58 *\/\n\nif ($val['order_status'] != OS_UNCONFIRMED &amp;&amp; $_CFG['use_storage'] == '1' &amp;&amp; $_CFG['stock_dec_time'] == SDT_PLACE)\n\n{\n\nchange_order_goods_storage($order_id, true, SDT_PLACE);\n\n}        if($update_status)\n\n{\n\n$i  += 1;\n\n$sql = \"update \" . $GLOBALS['ecs']-&gt;table('order_auto_confirm') . \" set order_status=1, update_time=\".$time.\" where order_id=\".$order_id;\n\n$db-&gt;query($sql);\n\n}\n\n}$string = '\u6b64\u6b21\u5171\u66f4\u65b0\uff1a'.$i.'\u6761\u6570\u636e';\n\necho $string;file_put_contents('.\/a.txt',  $time . '----' . date('Y-m-d H:i:s').$string.\"\r\n\", FILE_APPEND);\n\n\/**\n\n* \u66f4\u65b0\u8ba2\u5355\u603b\u91d1\u989d\n\n* @param   int     $order_id   \u8ba2\u5355id\n\n* @return  bool\n\n\/\/zuimoban.com\n\n*\/\n\nfunction update_order_amount($order_id)\n\n{\n\ninclude_once(ROOT_PATH . 'includes\/lib_order.php');\n\n\/\/\u66f4\u65b0\u8ba2\u5355\u603b\u91d1\u989d\n\n$sql = \"UPDATE \" . $GLOBALS['ecs']-&gt;table('order_info') .\n\n\" SET order_amount = \" . order_due_field() .\n\n\" WHERE order_id = '$order_id' LIMIT 1\";    return $GLOBALS['db']-&gt;query($sql);\n\n}\n\n?&gt;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u56db\u3001<\/p>\n<p>\/languages\/zh_cn\/admin\/order.php\u91cc\u52a0\u5165\uff1a<\/p>\n<pre>\/\/\n\n$_LANG['order_auto_croned'] = '\u6b64\u8ba2\u5355\u4e8e %s \u5df2\u88ab\u786e\u8ba4';\n\n$_LANG['order_auto_cron']   = '\u6b64\u8ba2\u5355\u4e8e %s \u8fdb\u884c\u5b9a\u65f6\u786e\u8ba4';\n\n$_LANG['order_auto']        = '\u5c06\u6b64\u8ba2\u5355\u52a0\u5165\u81ea\u52a8\u5b9a\u65f6\u786e\u8ba4';\n\n$_LANG['order_auto_time']   = '\u81ea\u52a8\u786e\u8ba4\u65f6\u95f4\uff1a';<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4e94\u3001<\/p>\n<p>\/admin\/themes\/order_info.htm\u5728\uff1a{$lang.base_info}\u540e\u9762\u52a0\u5165\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/image\/944\/250\/261\/1606900042855378.png\" class=\"aligncenter\" title=\"ecshop\u5b9e\u73b0\u540e\u53f0\u8ba2\u5355\u81ea\u52a8\u786e\u8ba4\u5f00\u53d1\u65b9\u6cd5\u63d2\u56fe2\" alt=\"ecshop\u5b9e\u73b0\u540e\u53f0\u8ba2\u5355\u81ea\u52a8\u786e\u8ba4\u5f00\u53d1\u65b9\u6cd5\u63d2\u56fe2\" \/><\/p>\n<p>\u5728\u6b64\u9875\u9762\u7684JS\u91cc\u9762\u52a0\u5165\uff1a<\/p>\n<pre>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('\u65e0\u6cd5\u83b7\u53d6\u65f6\u95f4');            return false;        }    }    Ajax.call('order.php?act=order_cron', 'order_id=' + order_id + '&amp;act1=' + act + '&amp;order_cron_time=' + order_cron_time, order_cron_response, 'POST', 'JSON');}function order_cron_response(res){  if (res.error == 0)  {      alert('\u4fdd\u5b58\u6210\u529f');  }  else  {      alert(res.message);  }  return false;}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd8\u6709\/themes\/default\/footer.dwt\u91cc\u662f\u5426\u542b\u6709\uff1a<br \/>{insert name=&#8217;query_info&#8217;}<br \/>\u8fd9\u4e00\u53e5\uff0c\u6bd4\u8f83\u91cd\u8981\uff0c\u524d\u4eba\u628a\u8fd9\u53e5\u53bb\u6389\u4e86\uff0c\u5bb3\u6700\u6a21\u677f\u5230\u5904\u627e\u539f\u56e0\u3002\u5171\u6d89\u53ca5\u4e2a\u6587\u4ef6\uff0c\u4e24\u4e2a\u65b0\u6dfb\u52a0\u7684<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fecshop\u5b9e\u73b0\u540e\u53f0\u8ba2\u5355\u81ea\u52a8\u786e\u8ba4\u5f00\u53d1\u65b9\u6cd5\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u680f\u76ee\u4ecb\u7ecd\u5b9e\u73b0\u540e\u53f0\u8ba2\u5355\u81ea\u52a8\u786e\u8ba4\u5f00\u53d1\u65b9\u6cd5 \u63a8\u8350\uff08\u514d\u8d39\uff09\uff1a CREATE TABLE `order_auto_confirm` ( `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, `order_id` INT(10) UNSIGNED NOT NULL DEFAULT &#8216;0&#8217;, `order_sn` VARCHAR(20) NOT NULL, `execute_time` INT(10) UNSIGNED NOT NULL DEFAULT &#8216;0&#8217;, `order_status` TINYINT(3) UNSIGNED NOT NULL DEFAULT &#8216;0&#8217; COMMENT &#8216;0\u672a\u786e\u5b9a\uff0c1\u5df2\u7ecf\u786e\u5b9a&#8217;, `addtime` INT(10) UNSIGNED NOT NULL DEFAULT &#8216;0&#8217;, `update_time` INT(10) UNSIGNED NOT NULL DEFAULT &#8216;0&#8217;, PRIMARY KEY [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-31833","post","type-post","status-publish","format-standard","hentry","category-cms"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/31833","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=31833"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/31833\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=31833"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=31833"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=31833"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}