|
|
@@ -182,10 +182,11 @@ class PerfCalc {
|
|
|
//echo('本月业绩入库完成,耗时:' . round($t8 - $t7, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
$this->_updatePercent(95);
|
|
|
|
|
|
- $t10 = microtime(true);
|
|
|
+
|
|
|
// 通过插入到perforder中的业绩订单数据,生成此业绩期活跃用户数据
|
|
|
$this->loopWriteActiveUser();
|
|
|
$this->_updatePercent(100);
|
|
|
+ $t10 = microtime(true);
|
|
|
|
|
|
echo('结算全部完成,共耗时:' . round($t10 - $t9, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
|
|
|
} catch (\Exception $e) {
|
|
|
@@ -318,18 +319,14 @@ class PerfCalc {
|
|
|
// 判断用户每周是否是活跃用户
|
|
|
$allData = PerfOrder::findUseDbCalc()
|
|
|
->select('USER_ID,PV,DEC_AMOUNT,PERIOD_NUM,CALC_MONTH,P_CALC_MONTH, DEC_SN,ORDER_CREATED_AT')
|
|
|
- ->where('PERIOD_NUM=:PERIOD_NUM',[
|
|
|
- ':PERIOD_NUM' => $this->_periodNum
|
|
|
- ])
|
|
|
- ->where('USER_ID=:USER_ID',[
|
|
|
+ ->where('PERIOD_NUM=:PERIOD_NUM AND USER_ID=:USER_ID',[
|
|
|
+ ':PERIOD_NUM' => $this->_periodNum,
|
|
|
':USER_ID' => $userId
|
|
|
])
|
|
|
- ->where('IS_SENT=:IS_SENT',[
|
|
|
- ':IS_SENT' => 0
|
|
|
- ])
|
|
|
->orderBy('ORDER_CREATED_AT DESC')
|
|
|
->asArray()
|
|
|
->all();
|
|
|
+
|
|
|
if($allData) {
|
|
|
$this->weekMonthOrder($allData);
|
|
|
|
|
|
@@ -358,9 +355,10 @@ class PerfCalc {
|
|
|
$format = date('Y-m-d', $orders['ORDER_CREATED_AT']);
|
|
|
$orderDayStart = strtotime($format.' 0:0:0');
|
|
|
$orderDayEnd = strtotime($format.' 23:59:59');
|
|
|
- $caluc = 7-$weekDay;
|
|
|
- $calucWeekStart = $orderDayStart - $caluc*$one;
|
|
|
- $calucWeekEnd = $orderDayEnd + $caluc*$one;
|
|
|
+ $startCaluc = $weekDay-1;
|
|
|
+ $endCaluc = 7-$weekDay;
|
|
|
+ $calucWeekStart = $orderDayStart - $startCaluc*$one;
|
|
|
+ $calucWeekEnd = $orderDayEnd + $endCaluc*$one;
|
|
|
if (!isset($time_arr[$calucWeekStart])) {
|
|
|
$time_arr[$calucWeekStart] = array_merge($orders, [
|
|
|
'temp_start' => $calucWeekStart,
|