查看文件: order_day.php
大小: 2.65 KB
类型: application/octet-stream
#!/usr/local/bin/php -q <?php $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"); $date = new DateTime('-1 day'); $orderdate= $date->format('Y-m-d') ; $sql0=sprintf("delete from order_datamtmp where ddate='%s'",$orderdate); mysql_select_db($database_BE2, $BE2); mysql_query($sql0); $sql1=sprintf("insert into order_datamtmp(coid,duser,dcode,dmoney,dexpess,dall,dcash,dsky,ddate,dpaydate,dpay,dflag,dbank) select coid,duser,dcode,dmoney,dexpess,dall,dcash,dsky,ddate,dpaydate,dpay,dflag,dbank from order_datam where ddate='%s'",$orderdate); mysql_select_db($database_BE2, $BE2); mysql_query($sql1); //未付金額,數量 $sql2='update order_datamtmp as a,order_datas as b set a.ccid=b.ccid,a.demoney=b.p_demoney ,a.pcount=b.p_count where a.dcode=b.dcode AND a.cflag="N"'; mysql_select_db($database_BE2, $BE2); mysql_query($sql2); //發票 $sql3='update order_datamtmp as a,order_bill as b set a.billcode=b.billcode where a.dcode=b.dcode AND a.cflag="N"'; mysql_select_db($database_BE2, $BE2); mysql_query($sql3); // 獎金 $sql4='UPDATE order_datamtmp as a INNER JOIN ( SELECT ccid, SUM(pmoney) as total FROM order_percent GROUP BY ccid) as x ON a.ccid = x.ccid SET a.pmoney= x.total AND a.cflag="N"'; mysql_select_db($database_BE2, $BE2); mysql_query($sql4); // 雲點 $sql5='UPDATE order_datamtmp as a INNER JOIN( SELECT eccid, sum(if(e_flag="N",e_ival,0)) as total FROM order_point GROUP BY eccid) as x ON a.ccid = x.eccid SET a.ival= x.total AND a.cflag="N"'; mysql_select_db($database_BE2, $BE2); mysql_query($sql5); //所得稅10% 平台服務費5% 金流服務費2.8% 應付服務稅額加總 $sql6='UPDATE order_datamtmp set p10=dall*0.1,p05=dall*0.05,p02=dall*0.028,p17=(dall*0.178),cflag="Y" where cflag="N"'; mysql_select_db($database_BE2, $BE2); mysql_query($sql6); /* $y= date('Y',time()); $m= date('m',time())-1; if($m<1){ $m=12 ; $y=$y-1 ;} $idate = sprintf('%d-%02d-%02d',$y,$m,31);// strtotime($ndate.'-31'); //new DateTime($ndate.'-31'); mysql_select_db($database_BE2, $BE2); $updateSQL = sprintf("UPDATE order_point SET e_flag='Y' WHERE e_date <='%s'",$idate ); mysql_query($updateSQL, $BE2) or die(mysql_error()); // echo $updateSQL .'<br>'; */ ?>
保存
取消
返回文件列表