|
|
@@ -25,6 +25,9 @@ use common\models\UserBonus;
|
|
|
use common\models\UserNetwork;
|
|
|
use common\models\UserPerf;
|
|
|
use common\models\UserRelation;
|
|
|
+use common\models\RemainPv;
|
|
|
+use common\models\Order;
|
|
|
+use common\models\forms\OrderForm;
|
|
|
use Yii;
|
|
|
use common\models\UserInfo;
|
|
|
use yii\helpers\Json;
|
|
|
@@ -224,9 +227,35 @@ class CalcCache {
|
|
|
*/
|
|
|
public static function addUsers($periodNum, $offset = 0, $limit = self::LIMIT) {
|
|
|
// echo sprintf("时间:[%s]缓存用户,当前offset为:【%s】" . PHP_EOL, date('Y-m-d H:i:s', time()) , $offset);
|
|
|
+ $userHaveRemain = RemainPv::findAllAsArray('REMAIN_PV >0');
|
|
|
+// print_r($userHaveRemain);exit;
|
|
|
+ $currentPeriod = Period::getInfoByPeriodNum($periodNum);
|
|
|
+
|
|
|
+// print_r($currentPeriod);exit;
|
|
|
+ if($currentPeriod['IS_MONTH']){
|
|
|
+ $periods = Period::getCurrentMonthPeriodByPeriodNum($periodNum);
|
|
|
+ //先清除本期的假订单
|
|
|
+ echo('首先,清除上次尝试生成业绩单时所创建的虚假订单'. date('Y-m-d H:i:s', time()) . PHP_EOL);
|
|
|
+ $delFOrder = Order::deleteAll(['ORDER_TYPE'=>'FO','PERIOD_NUM'=>$periodNum]);
|
|
|
+// print($delFOrder);exit;
|
|
|
+// print_r($periods);exit;
|
|
|
+ echo('检查有结余PV的用户,如果他当月PV不足30,则为其创建假订单'. PHP_EOL);
|
|
|
+ foreach($userHaveRemain as $uR){
|
|
|
+ $myPv = Order::find()->where(['PERIOD_NUM'=>$periods, 'USER_ID'=>$uR['USER_ID']])->SUM('PV');
|
|
|
+ if($myPv<30){
|
|
|
+ //制造虚拟订单
|
|
|
+ echo('不足30了,生成假订单' . PHP_EOL);
|
|
|
+ $newOrderForm = new OrderForm();
|
|
|
+ $newOrderForm->addFakeOrder($uR['USER_ID'],$periodNum);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ exit;
|
|
|
+// $userOrderArray = Order::findAll()
|
|
|
+ }
|
|
|
// 修复USER_INFO表里面已经没有PERIOD_NUM了
|
|
|
$allData = UserInfo::findUseDbCalc()->from(UserInfo::tableName(). 'AS UI')->select('UI.USER_ID,U.STATUS')->leftJoin(User::tableName() . 'AS U', 'U.ID=UI.USER_ID')->where('1=1')->orderBy('UI.RELATION_DEEP DESC,UI.ID DESC')->offset($offset)->limit($limit)->asArray()->all();
|
|
|
//$allData = User::findUseDbShopCalc()->select('ID AS USER_ID')->where('PERIOD_AT<=:PERIOD_AT AND IS_UNION=0 AND DELETED=0', [':PERIOD_AT' => $periodNum])->offset($offset)->limit($limit)->asArray()->all();
|
|
|
+// print_r($allData);
|
|
|
if ($allData) {
|
|
|
foreach ($allData as $data) {
|
|
|
// if(User::find()->where('ID=:ID',[':ID'=>$data['USER_ID']])->exists()) continue;
|