查看文件: moon_rep_cron.php
大小: 3.7 KB
类型: application/octet-stream
<?php ///////////////////#!/usr/local/bin/php -q $hostname_BE2 = "localhost"; $database_BE2 = "newskybni"; $username_BE2 = "root"; $password_BE2 = "loskyoc"; $BE2 = mysql_pconnect($hostname_BE2, $username_BE2, $password_BE2) or trigger_error(mysql_error(),E_USER_ERROR); ini_set('date.timezone','Asia/Taipei'); ini_set('max_execution_time', 300); //300 seconds = 5 minutes ini_set('set_time_limit',0); ini_set('memory_limit', '512M'); mysql_select_db($database_BE2, $BE2); mysql_query("SET NAMES UTF8"); $rmoon=isset($_GET['m'])?$_GET['m']:'2023-07'; $date = date("Y-m-d"); //new DateTime('-1 day'); //$rmoon= '2024-08';//date("Y-m"); //$sql0=sprintf("delete from rep_mtmp where rmoon='%s'",$orderdate); //mysql_select_db($database_BE2, $BE2); //mysql_query($sql0); $sql0=sprintf("select * from rep_mtmp where rmoon='%s'",$rmoon); mysql_select_db($database_BE2, $BE2); $Rt10 =mysql_query($sql0); $totalRows_Rt10 = mysql_num_rows($Rt10); if($totalRows_Rt10>0){ echo "exists..."; exit; } $moonarr=array('2023-07','2023-08','2023-09','2023-10','2024-02','2024-03','2024-04','2024-05','2024-06', '2024-07','2024-08','2024-09','2024-10','2025-01'); $rmoon=$moonarr[0]; /* CREATE TABLE IF NOT EXISTS `rep_mtmp` ( `r0` int(7) NOT NULL, `rmoon` varchar(7) DEFAULT NULL COMMENT '月份', `coid` int(7) DEFAULT '0' COMMENT '商家名稱', `rsc1` int(7) DEFAULT '0' COMMENT '訂單數量', `rsc2` int(7) DEFAULT '0' COMMENT '商品淨銷售總額', `rsc3` int(7) DEFAULT '0' COMMENT '使用點數折抵金額', `rsc31` int(7) DEFAULT '0' COMMENT '物流金額', `rsc4` int(7) DEFAULT '0' COMMENT '實際結算金額', `rsc5` int(7) DEFAULT '0' COMMENT '平台抽成金額10', `rsc6` int(7) DEFAULT '0' COMMENT '交易手續費 2.8', `rsc7` int(7) DEFAULT '0' COMMENT '手續費5/筆', `rsc8` int(7) DEFAULT '0' COMMENT '營業稅5%', `rsc9` int(7) DEFAULT '0' COMMENT '淨結算金額', `rsc10` int(7) DEFAULT '0' COMMENT '銷售獎金', `rsc11` int(7) DEFAULT '0' COMMENT '經銷獎金', `rsc12` int(7) DEFAULT '0' COMMENT '加盟回饋金放', `rsc13` int(7) DEFAULT '0' COMMENT '點數發', `lastday` date DEFAULT NULL COMMENT '最後報表日' ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='月報表-商家結算'; */ //select coid,duser,dcode,dmoney,dexpess,dall,dcash,dsky,ddate,dpaydate,dpay,dflag,dbank from order_datam where ddate='%s' // //$sql1=sprintf("insert into rep_mtmp(coid,rmoon,rsc1,rsc2,rsc3,rsc31,rsc9) select coid,concat('%s'),count(coid),sum(dmoney),sum(dsky),sum(dexpess),sum(dall) from order_datam where ddate like '%s' group by coid",$rmoon,$rmoon.'%'); // /* 訂單數量 銷售總額 點數 實際金額 p_percent 推廣獎金 p_percent2 開發獎金 p_percent3 首次開店獎金 */ for($i=0;$i<count($moonarr);$i++){ $rmoon=$moonarr[$i]; $sql1=sprintf("insert into rep_mtmp(coid,rmoon,rsc1,rsc2,rsc3,rsc31,rsc4,rsc10,rsc11) select a.coid,concat('%s'),count(a.coid),sum(a.dmoney),sum(a.dsky),sum(a.dexpess),sum(a.dall),sum(b.p_percent),sum(b.p_percent2) from order_datam as a,order_datas as b where a.ddate like '%s' AND a.dcode=b.dcode group by a.coid",$rmoon,$rmoon.'%'); mysql_select_db($database_BE2, $BE2); mysql_query($sql1); echo $sql1.'<br><br>'; //未付金額,數量 $sql2=sprintf("update rep_mtmp set rsc5=rsc4*0.1,rsc6=rsc4*0.028,rsc7=5,rsc8=rsc4*0.05 where rmoon='%s'",$rmoon); mysql_select_db($database_BE2, $BE2); mysql_query($sql2); $sql3=sprintf("update rep_mtmp set rsc9=rsc4-rsc5-rsc6-rsc7-rsc8 where rmoon='%s'",$rmoon); mysql_select_db($database_BE2, $BE2); mysql_query($sql3); } //echo $sql1; ?>
保存
取消
返回文件列表