Просмотр исходного кода

feature/NG-27: Qualified bonus regulations 奖金合格制度:活动期间购买指定商品,BV≥27即可维持活跃度(活动停止).

kevin 1 год назад
Родитель
Сommit
5df336ebde
2 измененных файлов с 67 добавлено и 74 удалено
  1. 2 9
      common/models/ShopGoods.php
  2. 65 65
      common/models/User.php

+ 2 - 9
common/models/ShopGoods.php

@@ -17,11 +17,8 @@ namespace common\models;
  * @property string $COVER 商品封面
  * @property int $IMAGES 商品图片
  * @property string $CONTENT 商品内容
- * @property string $SELL_PRICE 销售价格
  * @property string $SELL_PRICE_STANDARD 标准价格
- * @property string $MARKET_PRICE 市场价格
  * @property int $PRICE_PV 价格PV
- * @property string $TAX_RATE 税率
  * @property int $POINT 兑换积分
  * @property int $STORE_NUMS 库存
  * @property int $IS_DEL 是否删除
@@ -106,9 +103,9 @@ class ShopGoods extends \common\components\ActiveRecord
     public function rules()
     {
         return [
-            [['SELL_DISCOUNT','GOODS_NAME', 'CATE_ID','GIFT_TYPE', 'GOODS_NO', 'SELL_PRICE','MARKET_PRICE','PRICE_PV','STORE_NUMS', 'SELL_TYPE', 'CATEGORY_TYPE', 'SELL_PRICE_STANDARD', 'TAX_RATE'], 'required'],
+            [['SELL_DISCOUNT','GOODS_NAME', 'CATE_ID','GIFT_TYPE', 'GOODS_NO', 'PRICE_PV','STORE_NUMS', 'SELL_TYPE', 'CATEGORY_TYPE', 'SELL_PRICE_STANDARD'], 'required'],
             [['STORE_NUMS'], 'integer'],
-            [['SELL_PRICE','MARKET_PRICE','PRICE_PV','POINT',/* 'SELL_TYPE',*/ 'CATEGORY_TYPE' ,'SELL_PRICE_STANDARD', 'TAX_RATE'], 'number'],
+            [['PRICE_PV','POINT',/* 'SELL_TYPE',*/ 'CATEGORY_TYPE' ,'SELL_PRICE_STANDARD'], 'number'],
             [['ID','CATE_ID', 'GOODS_NO','GIFT_TYPE'], 'string', 'max' => 32],
             [['UNIT'], 'string', 'max' => 16],
             [['COVER', 'GOODS_NAME'], 'string', 'max' => 255],
@@ -137,12 +134,8 @@ class ShopGoods extends \common\components\ActiveRecord
             'COVER' => '商品封面',
             'IMAGES' => '商品图片',
             'CONTENT' => '商品内容',
-            'SELL_PRICE' => '销售价格',
             'SELL_PRICE_STANDARD' => 'US price($)',
-            'MARKET_PRICE' => '市场价格',
             'PRICE_PV' => '价格PV',
-            'TAX_RATE' => '税率',
-            'TAX_AMOUNT' => '税额',
 //            'POINT' => '兑换积分',
             'STORE_NUMS' => '库存',
             'STATUS' => '是否上架',

+ 65 - 65
common/models/User.php

@@ -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;
+//    }
 }