{"id":199429,"date":"2025-05-03T12:19:52","date_gmt":"2025-05-03T04:19:52","guid":{"rendered":"https:\/\/server.hk\/cnblog\/199429\/"},"modified":"2025-05-03T12:19:52","modified_gmt":"2025-05-03T04:19:52","slug":"%e8%8e%b7%e5%8f%96ecshop%e6%9f%90%e4%b8%aa%e5%95%86%e5%93%81%e7%9a%84%e8%ae%a2%e5%8d%95%e4%bf%a1%e6%81%af%e6%88%96%e9%94%80%e9%87%8f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/199429\/","title":{"rendered":"\u83b7\u53d6ecshop\u67d0\u4e2a\u5546\u54c1\u7684\u8ba2\u5355\u4fe1\u606f\u6216\u9500\u91cf"},"content":{"rendered":"<p> \u83b7\u53d6ecshop\u67d0\u4e2a\u5546\u54c1\u7684\u8ba2\u5355\u4fe1\u606f\u6216\u9500\u91cf\uff0c\u628a\u4ee5\u4e0b\u4ee3\u7801\u653e\u5230 lib_main.php<\/p>\n<p> 1.\u7edf\u8ba1\u67d0\u4e2a\u4e0b\u5355\u5546\u54c1\u7684\u4eba\u6570<\/p>\n<pre>\r\nfunction get_goods_ordernum($goods_id){\r\n \r\n        $sql = \"select count(goods_number) from \" . $GLOBALS['ecs']-&gt;table('order_goods') . \" AS g ,\".$GLOBALS['ecs']-&gt;table('order_info') . \" AS o WHERE o.order_id=g.order_id and g.goods_id = \" . $goods_id . \" and o.order_status in(1,5) \" ;\/\/o.order_status=1 \u8868\u793a\u786e\u8ba4\u4e86\u7684\u8ba2\u5355\u624d\u7b97 \r\nreturn $GLOBALS['db']-&gt;getAll($sql); \r\n \r\n}<\/pre>\n<p> \u6ce8\u610f\uff1a\u5982\u679c\u67093\u4e2a\u4eba\u4e0b\u5355\uff0c\u6570\u91cf\u662f5 \uff0c\u90a3\u8fd4\u56de\u7ed3\u679c\u662f3<\/p>\n<p> 2.\u7edf\u8ba1\u67d0\u4e2a\u4e0b\u5355\u5546\u54c1\u7684\u9500\u91cf\uff0c<\/p>\n<pre>\r\nfunction get_goods_ordernum($goods_id){\r\n \r\n        $sql = \"select sum(goods_number) from \" . $GLOBALS['ecs']-&gt;table('order_goods') . \" AS g ,\".$GLOBALS['ecs']-&gt;table('order_info') . \" AS o WHERE o.order_id=g.order_id and g.goods_id = \" . $goods_id . \" and o.order_status in(1,5) \" ;\/\/o.order_status=1 \u8868\u793a\u786e\u8ba4\u4e86\u7684\u8ba2\u5355\u624d\u7b97 \r\nreturn $GLOBALS['db']-&gt;getAll($sql); \r\n \r\n}<\/pre>\n<p> \u6ce8\u610f\uff1a\u5982\u679c\u67093\u4e2a\u4eba\u4e0b\u5355\uff0c\u6570\u91cf\u662f5 \uff0c\u90a3\u8fd4\u56de\u7ed3\u679c\u662f5<\/p>\n<p> 3.\u7edf\u8ba1\u67d0\u4e2a\u5546\u54c1\u5546\u54c1\u8ba2\u5355\u7684\u8be6\u7ec6\u4fe1\u606f<\/p>\n<p>   &nbsp;  <\/p>\n<pre>\r\nfunction get_goods_ordernum($goods_id){\r\n \r\n        $sql = \"select * from \" . $GLOBALS['ecs']-&gt;table('order_goods') . \" AS g ,\".$GLOBALS['ecs']-&gt;table('order_info') . \" AS o WHERE o.order_id=g.order_id and g.goods_id = \" . $goods_id . \" and o.order_status in(1,5) \" ;\/\/o.order_status=1 \u8868\u793a\u786e\u8ba4\u4e86\u7684\u8ba2\u5355\u624d\u7b97 \r\nreturn $GLOBALS['db']-&gt;getAll($sql); \r\n \r\n}<\/pre>\n<p>  &nbsp;   <\/p>\n<pre>\r\norder_status in(1,5)   1\u8868\u793a\u53bb\u4eba\u8ba2\u5355\uff0c5\u8868\u793a\u5df2\u5206\u5355\r\n\r\n\r\n\u5b8c\u6574php\u4ee3\u7801<\/pre>\n<p>   &nbsp;  <\/p>\n<pre>\r\n\/*\u83b7\u53d6\u6709\u6548\u8ba2\u5355\u4fe1\u606f*\/\r\nfunction sales_goods_order($goods_id){    \r\n    $sql = \"select * from \" . $GLOBALS['ecs']-&gt;table('order_goods') . \" AS g ,\".$GLOBALS['ecs']-&gt;table('order_info') . \" AS o WHERE o.order_id=g.order_id and g.goods_id = \" . $goods_id . \" and o.order_status in(1,5) \" ;\/\/o.order_status=1 1\u8868\u793a\u786e\u8ba4\u8ba2\u5355\uff0c5\u5df2\u5206\u5355\r\nreturn $GLOBALS['db']-&gt;getAll($sql); \r\n}\r\n\/*\u83b7\u53d6\u67d0\u4e2a\u5546\u54c1\u6709\u6548\u8ba2\u5355  \u9500\u91cf\u7edf\u8ba1*\/\r\nfunction sales_goods_number($goods_id){    \r\n    $arr = sales_goods_order($goods_id);\r\n    \/\/return array_sum($arr['goods_number']);\r\n    foreach($arr as $k=&gt;$v){\r\n        $val[] = $v['goods_number'];    \r\n    }\r\n    $count = array_sum($val);\r\n    if(!empty($count)){\r\n        return $count;    \r\n    }else{\r\n        return '0';    \r\n    }\r\n}<\/pre>\n<p>  &nbsp;<br \/>\n <\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u83b7\u53d6ecshop\u67d0\u4e2a\u5546\u54c1\u7684\u8ba2\u5355\u4fe1&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-199429","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/199429","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=199429"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/199429\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=199429"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=199429"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=199429"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}