瀏覽代碼

Merge branch 'master' into feature/dev-frontend-ui

kevin_zhangl 3 年之前
父節點
當前提交
628ebd61ec

+ 3 - 0
backendApi/modules/v1/controllers/CalcController.php

@@ -69,6 +69,9 @@ class CalcController extends BaseController
         if (Period::isProcessing($periodNum)) {
             return static::notice('有操作正在进行中请稍后', 400);
         }
+        if (!Period::checkClose($periodNum)) { // 如果未封期
+            return static::notice('没有封期不能计算', 400);
+        }
         //设置计算进行中标识
         Period::updatePeriodIsProcessing($periodNum, Period::IS_PROCESSING);
         //设置自动计算标识

+ 14 - 2
backendApi/modules/v1/models/lists/bonus/PerfMonthList.php

@@ -3,6 +3,7 @@ namespace backendApi\modules\v1\models\lists\bonus;
 
 use common\helpers\Cache;
 use common\helpers\user\Info;
+use common\models\CalcBonusBSDefault;
 use common\models\PerfMonth;
 use common\models\User as modelUser;
 use common\libs\dataList\column\Price;
@@ -28,7 +29,7 @@ class PerfMonthList extends \common\libs\dataList\DataList implements DataListIn
     public function dataHandle()
     {
         $data = PerfMonth::lists($this->condition, $this->params, [
-            'select'=>'PM.*, U.USER_NAME, U.REAL_NAME,RU.USER_NAME REC_USER_NAME,RU.REAL_NAME REC_REAL_NAME,',
+            'select'=>'PM.*, U.USER_NAME, U.REAL_NAME,RU.USER_NAME REC_USER_NAME,RU.REAL_NAME REC_REAL_NAME',
             'from' => PerfMonth::tableName().' AS PM',
             'join' => [
                 ['LEFT JOIN', modelUser::tableName() . ' AS U', 'PM.USER_ID=U.ID'],
@@ -64,7 +65,7 @@ class PerfMonthList extends \common\libs\dataList\DataList implements DataListIn
                 'USER_NAME' => [
                     'header' => 'Member Code', // 会员编号
                     'headerOther' => [
-                        'width' => '110',
+                        'width' => '120',
                     ],
                 ],
                 'REAL_NAME' => [
@@ -108,6 +109,17 @@ class PerfMonthList extends \common\libs\dataList\DataList implements DataListIn
                         ]))->result();
                     },
                 ],
+                'PV_PGS' => [
+                    'header' => 'Director PGS Performance', // 管理奖个人小组业绩
+                    'headerOther' => [
+                        'width' => '190',
+                    ],
+                    'value' => function($row) {
+                        return (new Price([
+                            'value' => $row['DIRECTOR_BONUS_PGS'],
+                        ]))->result();
+                    },
+                ],
                 'VIP_PV_1L_ZC' => [
                     'header' => 'L. New Market Entry Performance', // 一市场新增报单业绩
                     'headerOther' => [

+ 10 - 1
backendApi/modules/v1/models/lists/bonus/PerfPeriodList.php

@@ -55,7 +55,7 @@ class PerfPeriodList extends \common\libs\dataList\DataList implements DataListI
                 'USER_NAME' => [
                     'header' => 'Member Code', // 会员编号
                     'headerOther' => [
-                        'width' => '110',
+                        'width' => '120',
                     ],
                 ],
                 'REAL_NAME' => [
@@ -75,6 +75,15 @@ class PerfPeriodList extends \common\libs\dataList\DataList implements DataListI
                         ]))->result();
                     },
                 ],
+                'IS_ACTIVE' => [
+                    'header' => 'Whether Active', // 是否活跃
+                    'headerOther' => [
+                        'width' => '120',
+                    ],
+                    'value' => function($row) {
+                        return $row['IS_ACTIVE'] == 1 ? 'Yes' : 'No';
+                    },
+                ],
                 'PV_PCS_ZC' => [
                     'header' => 'Declaration Performance', // 报单业绩
                     'headerOther' => [

+ 17 - 12
common/helpers/bonus/BonusSend.php

@@ -131,16 +131,19 @@ class BonusSend extends BaseObject {
      */
     public function putFakeOrder() {
         echo('开始处理-假订单' . PHP_EOL);
+        $sysConfig = Cache::getSystemConfig();
+        $mesureUpCondition =  $sysConfig['monthPcsPvFxCondition']['VALUE']; // 月达标条件 NG默认30
         $fakeOrder= Order::find()->where(['PERIOD_NUM'=>$this->_periodNum, 'IS_AUTO'=>'1'])->asArray()->all();
         foreach($fakeOrder as $fOrder){
             $oRemainPv=RemainPv::findOne(["USER_ID"=>$fOrder['USER_ID']]);
             $transactionRemain = \Yii::$app->db->beginTransaction();
             try{
+                $fakeOrderPv = $oRemainPv->REMAIN_PV>=$mesureUpCondition?$mesureUpCondition:$oRemainPv->REMAIN_PV;
                 $flowRemainPvModel = new FlowRemainPv();
                 $flowRemainPvModel->ID = $this->_generateSn();
                 $flowRemainPvModel->USER_ID = $fOrder['USER_ID'];
-                $flowRemainPvModel->REMAIN_PV_FLOW = -30;
-                $flowRemainPvModel->REMAIN_PV_TOTAL = $oRemainPv->REMAIN_PV - 30;
+                $flowRemainPvModel->REMAIN_PV_FLOW = 0 - $fakeOrderPv;
+                $flowRemainPvModel->REMAIN_PV_TOTAL = $oRemainPv->REMAIN_PV - $fakeOrderPv;
                 $flowRemainPvModel->PERIOD_NUM = $this->_periodNum;
                 $flowRemainPvModel->UPDATED_AT = Date::nowTime();
                 $flowRemainPvModel->ORDER_SN = $fOrder['SN'];
@@ -148,7 +151,7 @@ class BonusSend extends BaseObject {
                     $this->addErrors($flowRemainPvModel->getErrors());
                     return false;
                 }
-                $oRemainPv->updateCounters(['REMAIN_PV'=>-30]);
+                $oRemainPv->updateCounters(['REMAIN_PV'=>0-$fakeOrderPv]);
                 $transactionRemain->commit();
             } catch (Exception $e) {
                 $transactionRemain->rollBack();
@@ -246,7 +249,7 @@ class BonusSend extends BaseObject {
             // $this->_updatePercent(95);
             // $t9 = microtime(true);
             // echo('更新会员累计月业绩完成,耗时:' . round($t9 - $t8, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
-            
+
             // 开启子进程去完成下面的循环发放和循环改聘级和循环更新累计业绩
             /*$process = new Process('sendBonus', 3);
             $process->run(function($workId, $pmid){
@@ -278,17 +281,19 @@ class BonusSend extends BaseObject {
      *
      */
     private function _calcRemainPv(){
-        $orders = Order::find()->where('PERIOD_NUM=:PERIOD_NUM AND REMAIN_PV>0',[':PERIOD_NUM'=>$this->_periodNum])->asArray()->all();
+        $sysConfig = Cache::getSystemConfig();
+        $mesureUpCondition =  $sysConfig['monthPcsPvFxCondition']['VALUE']; // 月达标条件 NG默认30
+        $orders = Order::find()->where('PERIOD_NUM=:PERIOD_NUM AND REMAIN_PV>0 AND IS_DELETE=0',[':PERIOD_NUM'=>$this->_periodNum])->asArray()->all();
         foreach($orders as $order){
             $oRemainPv = RemainPv::find()->where(['USER_ID' => $order['USER_ID']])->one();
-
+            $myRemainPv = $oRemainPv?$oRemainPv['REMAIN_PV']:0;
             $transactionRemain = \Yii::$app->db->beginTransaction();
             try{
                 $flowRemainPvModel = new FlowRemainPv();
                 $flowRemainPvModel->ID = $this->_generateSn();
                 $flowRemainPvModel->USER_ID = $order['USER_ID'];
                 $flowRemainPvModel->REMAIN_PV_FLOW = $order['REMAIN_PV'];
-                $flowRemainPvModel->REMAIN_PV_TOTAL = $oRemainPv['REMAIN_PV'] + $order['REMAIN_PV'];
+                $flowRemainPvModel->REMAIN_PV_TOTAL = $myRemainPv + $order['REMAIN_PV'];
                 $flowRemainPvModel->PERIOD_NUM = $this->_periodNum;
                 $flowRemainPvModel->UPDATED_AT = Date::nowTime();
                 $flowRemainPvModel->ORDER_SN = $order['SN'];
@@ -417,7 +422,7 @@ class BonusSend extends BaseObject {
         $allData = CalcBonus::find()
         ->yearMonth($this->_calcYearMonth)
         ->where(
-            '(IS_SENT=0 OR IS_SENT=2) AND CALC_MONTH=:CALC_MONTH AND PERIOD_NUM=:PERIOD_NUM', 
+            '(IS_SENT=0 OR IS_SENT=2) AND CALC_MONTH=:CALC_MONTH AND PERIOD_NUM=:PERIOD_NUM',
             [':CALC_MONTH' => $this->_calcYearMonth, ':PERIOD_NUM' => $periodNum]
         )
         ->limit($this->_limit)
@@ -569,7 +574,7 @@ class BonusSend extends BaseObject {
             $allData = CalcBonusBS::find()
             ->yearMonth($this->_calcYearMonth)
             ->where(
-                'CALC_MONTH=:CALC_MONTH AND PERIOD_NUM=:PERIOD_NUM', 
+                'CALC_MONTH=:CALC_MONTH AND PERIOD_NUM=:PERIOD_NUM',
                 [
                     ':CALC_MONTH' => $this->_calcYearMonth,
                     ':PERIOD_NUM' =>$this->_periodNum
@@ -750,8 +755,8 @@ class BonusSend extends BaseObject {
     public function updateActiveUser() {
         try {
             $ret = PerfActiveUser::updateAll(
-                ['IS_SENT' => 1], 
-                'PERIOD_NUM=:PERIOD_NUM AND IS_SENT=:IS_SENT', 
+                ['IS_SENT' => 1],
+                'PERIOD_NUM=:PERIOD_NUM AND IS_SENT=:IS_SENT',
                 ['IS_SENT'=>0, 'PERIOD_NUM'=>$this->_periodNum]
             );
 
@@ -1195,4 +1200,4 @@ class BonusSend extends BaseObject {
         unset($allData);
         return true;
     }
-}
+}

+ 5 - 0
common/helpers/bonus/Calc/CalcConsole.php

@@ -48,6 +48,11 @@ class CalcConsole extends BaseBusiness
             return true;
         }
 
+        if ($businessPeriod['IS_CLOSED']==0) {
+            // 如果没有封期 则直接返回
+            return true;
+        }
+
         //用户选择是否自动执行
         $autoExec             = $businessPeriod['AUTO_EXEC'] > Period::MANUAL_EXEC_CALC;
         $businessIsCalculated = $businessPeriod['IS_CALCULATED'] == Period::CALCULATE_FINISH;

+ 14 - 10
common/helpers/bonus/PerfCalc.php

@@ -190,20 +190,24 @@ class PerfCalc {
      */
     public static function _createFakeOrder($periodNum){
         echo('假假假'.$periodNum. PHP_EOL);
-        $userHaveRemain = RemainPv::findAllAsArray('REMAIN_PV >0');
+        $sysConfig = Cache::getSystemConfig();
+        $mesureUpCondition =  $sysConfig['monthPcsPvFxCondition']['VALUE']; // 月达标条件 NG默认30
+        $userHaveRemain = RemainPv::findAllAsArray('REMAIN_PV >=:MESURE_UP',[':MESURE_UP'=>$mesureUpCondition]);
         $currentPeriod = Period::getInfoByPeriodNum($periodNum);
+        $sysConfig = Cache::getSystemConfig();
+        $mesureUpCondition =  $sysConfig['monthPcsPvFxCondition']['VALUE']; // 月达标条件 NG默认30
         if($currentPeriod['IS_MONTH']){
             print_r('是月结点'.PHP_EOL);
             $periods = Period::getCurrentMonthPeriodByPeriodNum($periodNum);
             //先清除本期的假订单
             echo('首先,清除上次尝试生成业绩单时所创建的虚假订单'. date('Y-m-d  H:i:s', time()) . PHP_EOL);
             $delFOrder = Order::deleteAll(['IS_AUTO'=>'1','PERIOD_NUM'=>$periodNum]);
-            echo('检查有结余PV的用户,如果他当月PV不足30,则为其创建假订单'. PHP_EOL);
+            echo('检查有结余PV的用户,如果他当月PV不足'.$mesureUpCondition.',则为其创建假订单'. PHP_EOL);
             foreach($userHaveRemain as $uR){
                 $myPv = Order::find()->where(['PERIOD_NUM'=>$periods, 'USER_ID'=>$uR['USER_ID']])->SUM('PV');
-                if($myPv<30){
+                if($myPv < $mesureUpCondition){
                     //制造虚拟订单
-                    echo('不足30了,生成假订单' . PHP_EOL);
+                    echo('不足'.$mesureUpCondition.'了,生成假订单' . PHP_EOL);
                     $newOrderForm = new OrderForm();
                     $newOrderForm->addFakeOrder($uR['USER_ID'],$periodNum);
                 }
@@ -296,7 +300,7 @@ class PerfCalc {
             echo('本月业绩入库完成,耗时:' . round($t9 - $t7, 3) . ',内存使用:' . (round(memory_get_usage() / 1024 / 1024, 3)) . 'MB' . PHP_EOL);
             $this->_updatePercent(95);
 
-            
+
             // 通过插入到perforder中的业绩订单数据,生成此业绩期活跃用户数据
             // $this->loopWriteActiveUser();
             $this->_updatePercent(100);
@@ -440,7 +444,7 @@ class PerfCalc {
                 ->orderBy('ORDER_CREATED_AT DESC')
                 ->asArray()
                 ->all();
-               
+
                 if($allData) {
                     $this->weekMonthOrder($allData);
 
@@ -449,7 +453,7 @@ class PerfCalc {
 
                 unset($allData);
             }
-            
+
             unset($data);
             return $this->loopWriteActiveUser($offset + $this->_limit);
         }
@@ -504,7 +508,7 @@ class PerfCalc {
             }
         }
         PerfActiveUser::batchInsert($insert);
-        
+
         unset($insert);
 
         return true;
@@ -1072,7 +1076,7 @@ class PerfCalc {
                 $periodPerf = CalcCache::nowPeriodPerf($userId, $this->_periodNum);
 
                 $userBaseInfo = CalcCache::getUserInfo($userId, $this->_periodNum);
-                
+
                 $nowMonthPerf = [
                     'USER_ID' => $userId,
                     'FX_AMOUNT_CASH' => $everyData['FX_AMOUNT_CASH_SUM'],
@@ -1678,4 +1682,4 @@ class PerfCalc {
         \Yii::$app->swooleAsyncTimer->pushAsyncPercentToAdmin($percent, ['MODEL' => 'PERIOD', 'ID' => $this->_periodId, 'FIELD' => 'PERF_PERCENT']);
     }
 
-}
+}

+ 45 - 0
common/models/CalcBonusBSDefault.php

@@ -0,0 +1,45 @@
+<?php
+
+namespace common\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "{{%CALC_BONUS_BS_DETAIL}}".
+ *
+ * @property string $ID ID
+ * @property string $USER_ID 会员ID
+ * @property string $GPV10 个人小组业绩
+ */
+class CalcBonusBSDefault extends \common\components\ActiveRecord
+{
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%CALC_BONUS_BS_DETAIL}}';
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['ID'], 'unique'],
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'ID' => 'ID',
+            'USER_ID' => '会员ID',
+            'GPV10' => '个人小组业绩',
+        ];
+    }
+}

+ 8 - 0
common/models/Period.php

@@ -931,4 +931,12 @@ class Period extends \common\components\ActiveRecord
 
         return false;
     }
+
+    public static function checkClose($periodNum){
+        $period = static::findOneAsArray(['PERIOD_NUM' => $periodNum]);
+        if ($period['IS_CLOSED'] == 1) {
+            return true;
+        }
+        return false;
+    }
 }

+ 18 - 14
common/models/forms/OrderForm.php

@@ -426,8 +426,10 @@ class OrderForm extends Model
      *
      */
     private function _pvSplit($oPv){
-        if($oPv>60){
-            $currentPv = $oPv % 30 + 30;
+        $sysConfig = Cache::getSystemConfig();
+        $mesureUpCondition =  $sysConfig['monthPcsPvFxCondition']['VALUE'];
+        if($oPv>$mesureUpCondition){
+            $currentPv = $oPv % $mesureUpCondition + $mesureUpCondition;
             $remainPv = $oPv - $currentPv;
         }else{
             $currentPv = $oPv;
@@ -849,9 +851,9 @@ class OrderForm extends Model
                     throw new Exception('复消积分不足,无法购买商品');
                 }
             }
-			
-			
-			
+
+
+
 			/**
 			             * 2022-04-28
 			             * York
@@ -870,19 +872,19 @@ class OrderForm extends Model
 			                            $data->STATUS = 0;
 			                            $data->UPDATED_AT = Date::nowTime();
 			                            $data->update();
-			
+
 			                        }
 			                    }else{
 			                        throw new Exception($goods['GOODS_NAME'].'库存不足,无法购买商品');
-			
+
 			                    }
-			
-			
+
+
 			                }
 			            }
 			//                exit();
-			
-			
+
+
             //写入订单
             if (!$orderResult = $this->addUserOrder()) {
                 throw new Exception(Form::formatErrorsForApi($orderResult->getErrors()));
@@ -995,6 +997,8 @@ class OrderForm extends Model
 
     public function addFakeOrder($userId, $periodNum){
         $userName = Info::getUserNameByUserId($userId);
+        $sysConfig = Cache::getSystemConfig();
+        $mesureUpCondition =  $sysConfig['monthPcsPvFxCondition']['VALUE']; // 月达标条件 NG默认30
         $ordNo = $this->_generateSn();
         $orderModel = new Order();
         $orderModel->SN = 'OS'.$ordNo;
@@ -1002,11 +1006,11 @@ class OrderForm extends Model
         $orderModel->USER_ID = $userId;
         $orderModel->USER_NAME = $userName;
         $orderModel->PERIOD_NUM = $periodNum;
-        $orderModel->CREATE_USER = 'FAKE';
+        $orderModel->CREATE_USER = 'AUTO';
         $orderModel->ORDER_TYPE = 'FX';
         $orderModel->STATUS = 1;
-        $orderModel->PV = 30;
-        $orderModel->PAY_PV = 30;
+        $orderModel->PV = $mesureUpCondition;
+        $orderModel->PAY_PV = $mesureUpCondition;
         $orderModel->P_CALC_MONTH = '1970-01-01';
         $orderModel->CREATED_AT = Date::nowTime();
         $orderModel->EXPRESS_TYPE = 1;

+ 8 - 1
frontendApi/modules/v1/controllers/BonusController.php

@@ -16,6 +16,7 @@ use common\helpers\Tool;
 use common\helpers\user\Info;
 use common\helpers\user\Perf;
 use common\models\CalcBonus;
+use common\models\CalcBonusBSDefault;
 use common\models\CalcBonusBT;
 use common\models\CalcBonusFL;
 use common\models\DealType;
@@ -28,6 +29,7 @@ use common\models\FlowTourismPoints;
 use common\models\FlowVillaPoints;
 use common\models\FlowWallet;
 use common\models\PerfMonth;
+use common\models\PerfPeriod;
 use common\models\Period;
 use common\models\DecRole;
 use common\models\EmployLevel;
@@ -415,7 +417,12 @@ class BonusController extends BaseController {
             $data['SURPLUS_2L'] = ['name' => '二市场结余业绩', 'value' => Tool::formatFrontPerf($calcBonus['SURPLUS_2L'])];
 //            $data['SURPLUS_3L'] = ['name' => '三市场结余业绩', 'value' => Tool::formatFrontPerf($calcBonus['SURPLUS_3L'])];
 
-
+            // 是否活跃
+            $perfPeriod = PerfPeriod::find()->where('USER_ID=:USER_ID AND PERIOD_NUM = :PERIOD_NUM', [':USER_ID' => \Yii::$app->user->id, ':PERIOD_NUM' => $periodNum])->asArray()->one();
+            $data['IS_ACTIVE'] = ['name' => '是否活跃', 'value' => ($perfPeriod['IS_ACTIVE'] ? intval($perfPeriod['IS_ACTIVE']) : 0)];
+            // 管理奖个人小组业绩
+            $calcBonusBS = CalcBonusBSDefault::findOneAsArray('USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM', [':USER_ID' => \Yii::$app->user->id, ':PERIOD_NUM' => $periodNum], 'GPV10');
+            $data['DIRECTOR_BONUS_PGS'] = ['name' => '个人小组业绩', 'value' => ($calcBonusBS['GPV10'] ?? 0)];
 
             // if ($sysConfig['openYC']['VALUE']) {
             //     $data[] = ['name' => '荣衔奖', 'value' => Tool::formatPrice($calcBonus['ORI_BONUS_YC'])];

+ 3 - 1
frontendEle/src/views/bonus/other.vue

@@ -30,11 +30,13 @@
           <el-descriptions-item class="bonus-item" label="Member Code">{{newData.USER_NAME.value}}</el-descriptions-item><!-- 用户编号 -->
           <el-descriptions-item class="bonus-item" label="Pay Cycle">{{newData.PERIOD_NUM.value}}</el-descriptions-item><!-- 期数 -->
           <el-descriptions-item class="bonus-item" label="Member Level">{{newData.LAST_DEC_LV.value}}</el-descriptions-item><!-- 会员等级 -->
+          <el-descriptions-item class="bonus-item" label="Whether Active">{{ newData.IS_ACTIVE.value === 1 ? 'Yes' : 'No' }}</el-descriptions-item><!-- 是否活跃 -->
           <el-descriptions-item class="bonus-item" label="Latest Director">{{newData.LAST_EMP_LV.value}}</el-descriptions-item><!-- 会员管理星级 -->
           <el-descriptions-item class="bonus-item" label="Latest Crown">{{newData.LAST_CROWN_LV.value}}</el-descriptions-item><!-- 会员皇冠星级 -->
+          <el-descriptions-item class="bonus-item" label="Director PGS Performance">{{newData.DIRECTOR_BONUS_PGS.value}}</el-descriptions-item><!-- 管理奖个人小组业绩 -->
+          <el-descriptions-item class="bonus-item" label="Director Bonus">{{newData.ORI_BONUS_BS.value}}</el-descriptions-item><!-- 蓝星奖金/管理奖 -->
           <el-descriptions-item class="bonus-item" label="Welcome Bonus" v-if="newData.ORI_BONUS_TG_SWITCH === 1">{{newData.ORI_BONUS_TG.value}}</el-descriptions-item><!-- 销售奖金 -->
           <el-descriptions-item class="bonus-item" label="Team Bonus" v-if="newData.ORI_BONUS_QY_SWITCH === 1">{{newData.ORI_BONUS_QY.value}}</el-descriptions-item><!-- 绩效奖 -->
-          <el-descriptions-item class="bonus-item" label="Director Bonus">{{newData.ORI_BONUS_BS.value}}</el-descriptions-item><!-- 蓝星奖金/管理奖 -->
           <el-descriptions-item class="bonus-item" label="Quarterly Bonus">{{newData.ORI_BONUS_QUARTER.value}}</el-descriptions-item><!-- 季度分红 -->
           <el-descriptions-item class="bonus-item" label="Stockist Commission" v-if="newData.BONUS_BD_SWITCH === 1">{{newData.BONUS_BD.value}}</el-descriptions-item><!-- 服务中心 -->
           <el-descriptions-item class="bonus-item" label="Total Bonus">{{newData.BONUS_TOTAL.value}}</el-descriptions-item><!-- 合计 -->