|
|
@@ -456,75 +456,75 @@ 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'] ? 1 : 0;
|
|
|
-// }
|
|
|
-
|
|
|
/**
|
|
|
- * 判断会员是否活跃:1. 当月消费30BV. 2.任意水机+150粒的EKSP. (满足任意条件即可)
|
|
|
- * @throws Exception
|
|
|
+ * 判断此期用户是否活跃
|
|
|
+ * @param string $userId 用户ID
|
|
|
+ * @param int $periodNum 业绩期
|
|
|
+ * @param string $calcYearMonth 结算年月
|
|
|
*/
|
|
|
- public static function isPerfActive($userId, $periodNum, $calcYearMonth): int
|
|
|
- {
|
|
|
+ public static function isPerfActive($userId, $periodNum, $calcYearMonth): bool {
|
|
|
$sysConfig = Cache::getSystemConfig();
|
|
|
-
|
|
|
- // 条件1: 当月消费30BV
|
|
|
$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');
|
|
|
-
|
|
|
- if ($pv >= $sysConfig['monthPcsPvFxCondition']['VALUE']) {
|
|
|
- return 1;
|
|
|
- }
|
|
|
-
|
|
|
- $periodObj = Period::instance();
|
|
|
- $calcYear = $periodObj->getYear($periodNum);
|
|
|
- $calcMonth = $periodObj->getMonth($periodNum);
|
|
|
- $periodList = $periodObj->getYearMonthAllPeriod($calcYear, $calcMonth);
|
|
|
- $periodList = implode("','", $periodList);
|
|
|
-
|
|
|
- // 条件2: 任意水机分期+150粒的EKSP(HES150N)
|
|
|
- $orderEKSP = Order::find()
|
|
|
- ->alias('O')
|
|
|
- ->select('O.SN')
|
|
|
- ->join('INNER JOIN', OrderGoods::tableName() . ' AS G', 'O.SN = G.ORDER_SN')
|
|
|
- ->where("O.IS_DELETE=0 AND O.USER_ID=:USER_ID AND O.PERIOD_NUM IN ('{$periodList}') AND G.SKU_CODE=:SKU_CODE",
|
|
|
- ['USER_ID' => $userId, ':SKU_CODE' => 'HES150N'])
|
|
|
- ->asArray()
|
|
|
- ->all();
|
|
|
- if (!count($orderEKSP)) {
|
|
|
- LoggerTool::debug('isPerfActive-2: ' . $userId . ': ' . json_encode($orderEKSP));
|
|
|
- return 0;
|
|
|
- }
|
|
|
-
|
|
|
- // 所有分期商品
|
|
|
- $instalmentShopGoods = ShopGoods::find()->where('INSTALMENT>0 AND STATUS=1')->select('GOODS_NO')->column();
|
|
|
- $instalmentShopGoods = implode("','", $instalmentShopGoods);
|
|
|
-
|
|
|
- $orderInstalment = Order::find()
|
|
|
- ->alias('O')
|
|
|
- ->select('O.SN')
|
|
|
- ->join('INNER JOIN', OrderGoods::tableName() . ' AS G', 'O.SN = G.ORDER_SN')
|
|
|
- ->where("O.IS_DELETE=0 AND O.USER_ID=:USER_ID AND O.PERIOD_NUM IN ('{$periodList}') AND G.SKU_CODE IN ('{$instalmentShopGoods}')", ['USER_ID' => $userId])
|
|
|
- ->asArray()
|
|
|
- ->all();
|
|
|
- if (!count($orderInstalment)) {
|
|
|
- LoggerTool::debug('isPerfActive-3: ' . $userId . ': ' . json_encode($orderInstalment));
|
|
|
- return 0;
|
|
|
- }
|
|
|
+ ['USER_ID'=>$userId, 'CALC_MONTH'=>$calcYearMonth, 'PERIOD_NUM'=>$periodNum])
|
|
|
+ ->SUM('PV_PCS');
|
|
|
|
|
|
- LoggerTool::debug('isPerfActive-4: ' . $userId . ': ' . 10000000);
|
|
|
- return 1;
|
|
|
+ return $pv >= $sysConfig['monthPcsPvFxCondition']['VALUE'] ? 1 : 0;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 判断会员是否活跃:1. 当月消费30BV. 2.任意水机+150粒的EKSP. (满足任意条件即可)
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+// public static function isPerfActive($userId, $periodNum, $calcYearMonth): int
|
|
|
+// {
|
|
|
+// $sysConfig = Cache::getSystemConfig();
|
|
|
+//
|
|
|
+// // 条件1: 当月消费30BV
|
|
|
+// $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');
|
|
|
+//
|
|
|
+// if ($pv >= $sysConfig['monthPcsPvFxCondition']['VALUE']) {
|
|
|
+// return 1;
|
|
|
+// }
|
|
|
+//
|
|
|
+// $periodObj = Period::instance();
|
|
|
+// $calcYear = $periodObj->getYear($periodNum);
|
|
|
+// $calcMonth = $periodObj->getMonth($periodNum);
|
|
|
+// $periodList = $periodObj->getYearMonthAllPeriod($calcYear, $calcMonth);
|
|
|
+// $periodList = implode("','", $periodList);
|
|
|
+//
|
|
|
+// // 条件2: 任意水机分期+150粒的EKSP(HES150N)
|
|
|
+// $orderEKSP = Order::find()
|
|
|
+// ->alias('O')
|
|
|
+// ->select('O.SN')
|
|
|
+// ->join('INNER JOIN', OrderGoods::tableName() . ' AS G', 'O.SN = G.ORDER_SN')
|
|
|
+// ->where("O.IS_DELETE=0 AND O.USER_ID=:USER_ID AND O.PERIOD_NUM IN ('{$periodList}') AND G.SKU_CODE=:SKU_CODE",
|
|
|
+// ['USER_ID' => $userId, ':SKU_CODE' => 'HES150N'])
|
|
|
+// ->asArray()
|
|
|
+// ->all();
|
|
|
+// if (!count($orderEKSP)) {
|
|
|
+// LoggerTool::debug('isPerfActive-2: ' . $userId . ': ' . json_encode($orderEKSP));
|
|
|
+// return 0;
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 所有分期商品
|
|
|
+// $instalmentShopGoods = ShopGoods::find()->where('INSTALMENT>0 AND STATUS=1')->select('GOODS_NO')->column();
|
|
|
+// $instalmentShopGoods = implode("','", $instalmentShopGoods);
|
|
|
+//
|
|
|
+// $orderInstalment = Order::find()
|
|
|
+// ->alias('O')
|
|
|
+// ->select('O.SN')
|
|
|
+// ->join('INNER JOIN', OrderGoods::tableName() . ' AS G', 'O.SN = G.ORDER_SN')
|
|
|
+// ->where("O.IS_DELETE=0 AND O.USER_ID=:USER_ID AND O.PERIOD_NUM IN ('{$periodList}') AND G.SKU_CODE IN ('{$instalmentShopGoods}')", ['USER_ID' => $userId])
|
|
|
+// ->asArray()
|
|
|
+// ->all();
|
|
|
+// if (!count($orderInstalment)) {
|
|
|
+// LoggerTool::debug('isPerfActive-3: ' . $userId . ': ' . json_encode($orderInstalment));
|
|
|
+// return 0;
|
|
|
+// }
|
|
|
+//
|
|
|
+// LoggerTool::debug('isPerfActive-4: ' . $userId . ': ' . 10000000);
|
|
|
+// return 1;
|
|
|
+// }
|
|
|
}
|