|
|
@@ -40,6 +40,9 @@ use common\models\CalcBonusYJ;
|
|
|
use common\models\CalcMonthBonusUser;
|
|
|
use common\models\Config;
|
|
|
use common\models\FlowDeductZR;
|
|
|
+use common\models\Order;
|
|
|
+use common\models\OrderGoods;
|
|
|
+use common\models\OrderShop;
|
|
|
use common\models\PerfCompany;
|
|
|
use common\models\PerfMonth;
|
|
|
use common\models\PerfPeriod;
|
|
|
@@ -51,6 +54,7 @@ use common\models\EmployLevel;
|
|
|
use common\models\FlowBonus;
|
|
|
use common\models\PerfActiveUser;
|
|
|
use common\models\ScoreMonth;
|
|
|
+use common\models\ShopGoods;
|
|
|
use common\models\StarCrownLevel;
|
|
|
use common\models\User;
|
|
|
use common\models\UserInfo;
|
|
|
@@ -4126,13 +4130,45 @@ class BonusCalc extends BaseObject {
|
|
|
return $fxPvStatus;
|
|
|
}
|
|
|
|
|
|
- // 判断会员是否活跃
|
|
|
+ // 判断会员是否活跃:1. 当月消费30BV. 2.任意水机+150粒的EKSP. (满足任意条件即可)
|
|
|
public function _isPerfActive($userId): bool
|
|
|
{
|
|
|
+ // 条件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'=>$this->_calcYearMonth, 'PERIOD_NUM'=>$this->_periodNum])
|
|
|
->SUM('PV_PCS');
|
|
|
|
|
|
- return $pv >= $this->_sysConfig['monthPcsPvFxCondition']['VALUE'];
|
|
|
+ if ($pv >= $this->_sysConfig['monthPcsPvFxCondition']['VALUE']) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $calcMonth = $this->_calcYear . ($this->_calcMonth == 1 ? '0' . $this->_calcMonth : $this->_calcMonth);
|
|
|
+
|
|
|
+ // 条件2: 任意水机+150粒的EKSP
|
|
|
+ $orderEKSP = Order::find()
|
|
|
+ ->alias('O')
|
|
|
+ ->join('INNER JOIN', OrderGoods::tableName() . ' AS G', 'O.SN = G.ORDER_SN')
|
|
|
+ ->where("O.IS_DELETE=0 AND O.USER_ID=:USER_ID AND LEFT(O.P_CALC_MONTH, 7)=:P_CALC_MONTH AND O.PERIOD_NUM<=:PERIOD_NUM AND G.SKU_CODE=:SKU_CODE",
|
|
|
+ ['USER_ID' => $userId, 'P_CALC_MONTH' => $calcMonth, 'PERIOD_NUM' => $this->_periodNum, ':SKU_CODE' => 'BA'])
|
|
|
+ ->count();
|
|
|
+ if (!$orderEKSP) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 所有分期商品
|
|
|
+ $instalmentShopGoods = ShopGoods::find()->where('INSTALMENT>0 AND STATUS=1')->select('GOODS_NO')->column();
|
|
|
+ $instalmentShopGoods = implode("','", $instalmentShopGoods);
|
|
|
+ $orderInstalment = Order::find()
|
|
|
+ ->alias('O')
|
|
|
+ ->join('INNER JOIN', OrderGoods::tableName() . ' AS G', 'O.SN = G.ORDER_SN')
|
|
|
+ ->where("O.IS_DELETE=0 AND O.USER_ID=:USER_ID AND LEFT(O.P_CALC_MONTH, 7)=:P_CALC_MONTH AND O.PERIOD_NUM<=:PERIOD_NUM AND G.SKU_CODE IN ('{$instalmentShopGoods}')",
|
|
|
+ ['USER_ID' => $userId, 'P_CALC_MONTH' => $calcMonth, 'PERIOD_NUM' => $this->_periodNum])
|
|
|
+ ->count();
|
|
|
+ if (!$orderInstalment) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
}
|
|
|
}
|