-
Notifications
You must be signed in to change notification settings - Fork 70
/
getBuyNums.php
46 lines (32 loc) · 1.48 KB
/
getBuyNums.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
require_once('config.inc.php');
require_once('include/utils/utils.php');
require_once('include/database/PearDatabase.php');
global $adb,$current_user;
$today = date("Y-m-d");
$oneweek = date("Y-m-d",strtotime("-1 week"))." 00:00:00";
$onemonth = date("Y-m-d",strtotime("-1 month"))." 00:00:00";
$threemonth = date("Y-m-d",strtotime("-3 month"))." 00:00:00";
$query = "select accountid from ec_account where deleted=0 and smownerid='".$current_user->id."'";
$result = $adb->query($query);
$nums = $adb->num_rows($result);
if($nums > 0){
for($i=0;$i<$nums;$i++){
$accountid = $adb->query_result($result,$i,'accountid');
$query1 = "select count(*) as num from ec_salesorder where accountid=$accountid and createdtime > '$oneweek'";
$result1 = $adb->query($query1);
$row1 = $adb->fetch_array($result1);
$oneweekbuynum = $row1['num'];
$query2 = "select count(*) as num from ec_salesorder where accountid=$accountid and createdtime > '$onemonth'";
$result2 = $adb->query($query2);
$row2 = $adb->fetch_array($result2);
$onemonthbuynum = $row2['num'];
$query3 = "select count(*) as num from ec_salesorder where accountid=$accountid and createdtime > '$threemonth'";
$result3 = $adb->query($query3);
$row3 = $adb->fetch_array($result3);
$threemonthbuynum = $row3['num'];
$updatesql = "update ec_account set oneweekbuy=$oneweekbuynum,onemonthbuy=$onemonthbuynum,threemonthbuy=$threemonthbuynum where accountid=$accountid";
$adb->query($updatesql);
}
}
?>