|
|
@@ -18,7 +18,11 @@ use common\models\ArticleCategory;
|
|
|
use common\models\BaUser;
|
|
|
use common\models\DecOrder;
|
|
|
use common\models\DecRole;
|
|
|
+use common\models\Order;
|
|
|
+use common\models\OrderGoods;
|
|
|
+use common\models\PerfPeriod;
|
|
|
use common\models\Period;
|
|
|
+use common\models\ShopGoods;
|
|
|
use Yii;
|
|
|
use frontendApi\modules\v1\models\User;
|
|
|
|
|
|
@@ -34,6 +38,48 @@ class SiteController extends BaseController
|
|
|
* @throws \yii\web\HttpException
|
|
|
*/
|
|
|
public function actionDaysDiff(){
|
|
|
+ $userId = '419322759496208384';
|
|
|
+
|
|
|
+ $sysConfig = Cache::getSystemConfig();
|
|
|
+ $mesureUpCondition = $sysConfig['monthPcsPvFxCondition']['VALUE']; // 月达标条件 NG默认30
|
|
|
+
|
|
|
+ $_calcYearMonth = '2022-10-08';
|
|
|
+ $_periodNum = 103;
|
|
|
+
|
|
|
+ // 条件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 >= $mesureUpCondition) {
|
|
|
+ return static::notice(['daysDiff'=>Yii::$app->params['daysDiff'], 'rs' => 1]);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 条件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 O.CALC_MONTH=:CALC_MONTH AND O.PERIOD_NUM<=:PERIOD_NUM AND G.SKU_CODE=:SKU_CODE",
|
|
|
+ ['USER_ID' => $userId, 'CALC_MONTH' => $_calcYearMonth, 'PERIOD_NUM' => $_periodNum, ':SKU_CODE' => 'BA'])
|
|
|
+ ->count();
|
|
|
+ if (!$orderEKSP) {
|
|
|
+ return static::notice(['daysDiff'=>Yii::$app->params['daysDiff'], 'rs' => 2]);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 所有分期商品
|
|
|
+ $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 O.CALC_MONTH=:CALC_MONTH AND O.PERIOD_NUM<=:PERIOD_NUM AND G.SKU_CODE IN ('{$instalmentShopGoods}')",
|
|
|
+ ['USER_ID' => $userId, 'CALC_MONTH' => $_calcYearMonth, 'PERIOD_NUM' => $_periodNum])
|
|
|
+ ->count();
|
|
|
+ if (!$orderInstalment) {
|
|
|
+ return static::notice(['daysDiff'=>Yii::$app->params['daysDiff'], 'rs' => 3]);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
return static::notice(['daysDiff'=>Yii::$app->params['daysDiff']]);
|
|
|
}
|
|
|
|