|
|
@@ -267,64 +267,6 @@ class User extends \common\components\ActiveRecord
|
|
|
Yii::$app->redis->hdel(Cache::USER_INFO_KEY, $userId);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 判断用户是否是观察期
|
|
|
- * 观望期:自加入算起2个月
|
|
|
- * 例子:2022年5月14日加入, 观望期至2022年7月31日。
|
|
|
- * true为是观察期用户 false为不是观察期用户
|
|
|
- * @param $addAt 用户的加入时间
|
|
|
- * @param $month 观察期月份限制 系统初始化为2个月
|
|
|
- */
|
|
|
- public static function checkIsObserve($addAt, $month) {
|
|
|
- if (empty($month)) {
|
|
|
- // 如果0 代表全站全额升级
|
|
|
- return false;
|
|
|
- }
|
|
|
- $appendMonth = date("Y-m", strtotime("first day of +$month month", $addAt)); // 指定月份
|
|
|
- $lastDay = date("t", strtotime($appendMonth)); // 获取指定月的最后一天
|
|
|
- $eTime = strtotime($appendMonth.'-'.$lastDay);
|
|
|
-
|
|
|
- return time() < $eTime ? true : false;
|
|
|
- }
|
|
|
-
|
|
|
- // 获取用户报单PV总和
|
|
|
- public static function sumDevPvByUserId($userId) {
|
|
|
- $decOrderPv = DecOrder::find()
|
|
|
- ->select('SUM(DEC_PV) AS PV_SUM')
|
|
|
- ->where('TO_USER_ID=:TO_USER_ID AND IS_DEL=0',
|
|
|
- ['TO_USER_ID'=>$userId]
|
|
|
- )
|
|
|
- ->asArray()
|
|
|
- ->one();
|
|
|
- $decOrderPv = isset($decOrderPv['PV_SUM']) ? $decOrderPv['PV_SUM'] : 0;
|
|
|
- $orderDecPv = OrderDec::find()
|
|
|
- ->select('SUM(PAY_PV) AS PV_SUM')
|
|
|
- ->where('USER_ID=:USER_ID AND IS_DELETE=0',
|
|
|
- [
|
|
|
- 'USER_ID'=>$userId,
|
|
|
-
|
|
|
- ]
|
|
|
- )
|
|
|
- ->asArray()
|
|
|
- ->one();
|
|
|
- $orderDecPv = isset($orderDecPv['PV_SUM']) ? $orderDecPv['PV_SUM'] : 0;
|
|
|
- // 还得加上用户在老系统中的所有报单PV之和
|
|
|
- $originPv = OriginDecPv::find()
|
|
|
- ->select('SUM(DEC_PV) AS PV_SUM')
|
|
|
- ->where('USER_ID=:USER_ID',
|
|
|
- [
|
|
|
- 'USER_ID'=>$userId,
|
|
|
-
|
|
|
- ]
|
|
|
- )
|
|
|
- ->asArray()
|
|
|
- ->one();
|
|
|
- $originPv = isset($originPv['PV_SUM']) ? $originPv['PV_SUM'] : 0;
|
|
|
- $total = $orderDecPv + $decOrderPv + $originPv;
|
|
|
-
|
|
|
- return $total;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 获取会员的部分信息并对敏感信息加密
|
|
|
* @param $userId
|
|
|
@@ -514,4 +456,18 @@ class User extends \common\components\ActiveRecord
|
|
|
];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 判断此期用户是否活跃
|
|
|
+ * @param varchar $userId 用户ID
|
|
|
+ * @param int $periodNum 业绩期
|
|
|
+ * @param varchar $calcYearMonth 结算年月
|
|
|
+ */
|
|
|
+ public static function isPerfActive($userId, $periodNum, $calcYearMonth): bool {
|
|
|
+ $sysConfig = Cache::getSystemConfig();
|
|
|
+ $pv = PerfPeriod::find()->where('USER_ID=:USER_ID AND CALC_MONTH=:CALC_MONTH AND PERIOD_NUM<=:PERIOD_NUM',
|
|
|
+ ['USER_ID'=>$userId, 'CALC_MONTH'=>$calcYearMonth, 'PERIOD_NUM'=>$periodNum])
|
|
|
+ ->SUM('PV_PCS');
|
|
|
+
|
|
|
+ return $pv >= $sysConfig['monthPcsPvFxCondition']['VALUE'];
|
|
|
+ }
|
|
|
}
|