查看文件: premoon.php
大小: 3.55 KB
类型: application/octet-stream
<?php // require('system/login.php'); ?> <?php require_once('../Connections/BE2.php'); ?> <?php $mm= -1;//date('Y-m') if( isset($_POST['d'])){ $mm=$_POST['d']; } $sdate=$mm; $sdate0=$sdate.'-15'; $y=substr($sdate0,0,4); $m=substr($sdate0,5,2); $sdateu=date("Y-m", mktime(0,0,0,$m-1,1,$y)); $query_Rt0 =sprintf("Select * From order_permoon WHERE pmoon='%s'",$mm); mysql_select_db($database_BE2, $BE2); echo $query_Rt0."<br><br><br>" ; mysql_query($query_Rt0, $BE2) or die(mysql_error()); $Rt0 = mysql_query($query_Rt0, $BE2) or die(mysql_error()); $row_Rt0 = mysql_fetch_assoc($Rt0); $totalRows_Rt0 = mysql_num_rows($Rt0); if($totalRows_Rt0>0){ $query_Rt0 =sprintf("delete From order_permoon WHERE pmoon>='%s'",$mm); mysql_select_db($database_BE2, $BE2); mysql_query($query_Rt0, $BE2) or die(mysql_error()); } $query_Rt1 =sprintf("update order_permoon SET pall=pmoney+pnow WHERE pmoon='%s'",$sdateu); mysql_select_db($database_BE2, $BE2); echo $query_Rt1."<br><br><br>" ; mysql_query($query_Rt1, $BE2) or die(mysql_error()); $query_Rt2 =sprintf("INSERT Into order_permoon(pmoon,puid,pnow) SELECT substring(a.pdate,1,7) as pdate, a.puid,sum(a.pmoney-a.depmoney) as pmoney from order_percent as a, member as d where a.puid=d.mem_auto AND a.pdate like '%s' group by a.puid ORDER BY a.pdate",$mm."%"); mysql_select_db($database_BE2, $BE2); echo $query_Rt2."<br><br><br>" ; mysql_query($query_Rt2, $BE2) or die(mysql_error()); //222 //$query_Rt3 =sprintf("INSERT Into order_permoon(pmoon,puid,pmoney) SELECT concat('%s'),t1.puid,t1.pall FROM order_permoon as t1 LEFT JOIN order_permoon as t2 ON t1.puid = t2.puid AND t2.pmoon='%s' WHERE t1.pmoon='%s' AND t2.puid Is Null",$mm,$mm,$sdateu); $query_Rt3 =sprintf("INSERT Into order_permoon(pmoon,puid,pmoney,pupay) SELECT concat('%s'),t1.puid,t1.pall,t1.pmpay FROM order_permoon as t1 LEFT JOIN order_permoon as t2 ON t1.puid = t2.puid AND t2.pmoon='%s' WHERE t1.pmoon='%s' AND t2.puid Is Null",$mm,$mm,$sdateu); mysql_select_db($database_BE2, $BE2); echo $query_Rt3."<br><br><br>"; mysql_query($query_Rt3, $BE2) or die(mysql_error()); // SELECT * FROM order_permoon as t1 LEFT JOIN order_permoon as t2 ON t1.puid = t2.puid AND t2.pmoon='2024-03' WHERE t1.pmoon='2024-02' AND t2.puid Is Null $query_Rt4 =sprintf("update order_permoon as a,order_permoon as b SET a.pmoney=(b.pmoney+b.pnow) where a.pmoon='%s' AND b.pmoon='%s' AND a.puid=b.puid",$mm,$sdateu); echo $query_Rt4."<br>"; mysql_select_db($database_BE2, $BE2); mysql_query($query_Rt4, $BE2) or die(mysql_error()); //已付款 歸零 $query_Rt5 =sprintf("update order_permoon SET pmoney=0 where pupay='Y' AND pmoon='%s'",$mm); echo $query_Rt5."<br>"; mysql_select_db($database_BE2, $BE2); mysql_query($query_Rt5, $BE2) or die(mysql_error()); //加總 $query_Rt6 =sprintf("update order_permoon SET pall=pmoney+pnow WHERE pmoon='%s'",$mm); mysql_select_db($database_BE2, $BE2); echo $query_Rt6."<br><br><br>" ; mysql_query($query_Rt6, $BE2) or die(mysql_error()); /* SELECT * FROM order_permoon as t1 LEFT JOIN order_permoon as t2 ON t1.puid = t2.puid AND t2.pmoon='2024-03' WHERE t1.pmoon='2024-02' AND t2.puid Is Null */ //do { // } while ($row_Rt2 = mysql_fetch_assoc($Rt2)); //$query_Rt4 = sprintf("INSERT Into order_permoon(pmoon,puid,pmoney) SELECT substring(a.pdate,1,7), a.puid,sum(a.pmoney-a.depmoney) from order_percent as a, member as d where a.puid=d.mem_auto AND a.pdate like '2024-04%' group by a.puid ORDER BY a.pdate"); ?>
保存
取消
返回文件列表