zxiansheng 4 лет назад
Родитель
Сommit
263bc42e7f

+ 1 - 119
common/helpers/Cache.php

@@ -8,20 +8,13 @@
 
 namespace common\helpers;
 
-use backendApi\modules\v1\models\AdminRole;
+use Yii;
 use common\models\Config;
 use common\models\OcrApi;
 use common\models\DeclarationLevel;
 use common\models\EmployLevel;
 use common\models\Region;
-use common\models\SmsApi;
-use common\models\SmsTemplate;
 use common\models\User;
-use common\models\UserNetwork;
-use common\models\UserRelation;
-use common\models\WithdrawLevel;
-use Yii;
-use backendApi\modules\v1\models\Admin;
 use common\models\UserInfo;
 
 class Cache
@@ -80,7 +73,6 @@ class Cache
     }
 
     /**
-     * 获取会员的WebSocket的fd
      * @param $app
      * @param $userId
      * @return mixed
@@ -90,7 +82,6 @@ class Cache
     }
 
     /**
-     * 获取系统配置信息
      * @return array|mixed|\yii\db\ActiveRecord[]
      */
     public static function getSystemConfig(){
@@ -106,7 +97,6 @@ class Cache
     }
 
     /**
-     * 获取报单级别
      * @return array|mixed|\yii\db\ActiveRecord[]
      */
     public static function getDecLevelConfig(){
@@ -114,7 +104,6 @@ class Cache
     }
 
     /**
-     *  更新报单级别
      * @return array|\yii\db\ActiveRecord[]
      */
     public static function updateDecLevelConfig(){
@@ -122,7 +111,6 @@ class Cache
     }
 
     /**
-     * 获取地区
      * @return array|mixed|\yii\db\ActiveRecord[]
      */
     public static function getRegionConfig(){
@@ -130,7 +118,6 @@ class Cache
     }
 
     /**
-     *  更新地区
      * @return array|\yii\db\ActiveRecord[]
      */
     public static function updateRegionConfig(){
@@ -138,7 +125,6 @@ class Cache
     }
 
     /**
-     * 获取聘级
      * @return array|mixed|\yii\db\ActiveRecord[]
      */
     public static function getEmpLevelConfig(){
@@ -146,24 +132,6 @@ class Cache
     }
 
     /**
-     *  更新管理员角色
-     * @return array|\yii\db\ActiveRecord[]
-     */
-    public static function updateAdminRole(){
-        return AdminRole::updateToCache();
-    }
-
-
-    /**
-     * 获取管理员角色
-     * @return array|mixed|\yii\db\ActiveRecord[]
-     */
-    public static function getAdminRole(){
-        return AdminRole::getFromCache();
-    }
-
-    /**
-     *  更新聘级
      * @return array|\yii\db\ActiveRecord[]
      */
     public static function updateEmpLevelConfig(){
@@ -171,7 +139,6 @@ class Cache
     }
 
     /**
-     * 获取用户基本信息
      * @param $userId
      * @return array|null|\yii\db\ActiveRecord
      */
@@ -180,7 +147,6 @@ class Cache
     }
 
     /**
-     * 执行异步任务时往缓存中把要传递的参数都存起来,方便在异步方法中直接调用
      * @param $params
      * @return string
      * @throws \yii\base\Exception
@@ -193,7 +159,6 @@ class Cache
     }
 
     /**
-     * 获取异步参数
      * @param $taskKey
      * @return mixed
      */
@@ -236,31 +201,6 @@ class Cache
     }
 
     /**
-     * 获取短信模板通过报单级别
-     * @return array|mixed
-     */
-    public static function getSmsTemplateByDec(){
-        return SmsTemplate::getDecFromCache();
-    }
-
-    /**
-     * 获取短信模板通过聘级
-     * @return array|mixed
-     */
-    public static function getSmsTemplateByEmp(){
-        return SmsTemplate::getEmpFromCache();
-    }
-
-    /**
-     * 获取提现等级
-     * @return array|mixed|\yii\db\ActiveRecord[]
-     */
-    public static function getWithdrawLevel(){
-        return WithdrawLevel::getFromCache();
-    }
-
-    /**
-     * 获取报单级别
      * @return array|mixed|\yii\db\ActiveRecord[]
      */
     public static function getOcrApiConfig(){
@@ -268,67 +208,9 @@ class Cache
     }
 
     /**
-     *  更新报单级别
      * @return array|\yii\db\ActiveRecord[]
      */
     public static function updateOcrApiConfig(){
         return OcrApi::updateToCache();
     }
-
-    /**
-     * 获取短信接口设置
-     * @return array|mixed|\yii\db\ActiveRecord[]
-     */
-    public static function getSmsApiConfig(){
-        return SmsApi::getFromCache();
-    }
-
-    /**
-     *  更新短信接口设置
-     * @return array|\yii\db\ActiveRecord[]
-     */
-    public static function updateSmsApiConfig(){
-        return SmsApi::updateToCache();
-    }
-
-    /**
-     * 设置上传token
-     * @return string
-     * @throws \yii\base\Exception
-     */
-    public static function setUploadToken(){
-        $token = Yii::$app->security->generateRandomString(32);
-        Yii::$app->cache->set($token, 1, 5 * 60);
-        return $token;
-    }
-
-    /**
-     * 用上传token获取上传资格
-     * @param $token
-     * @return mixed
-     */
-    public static function getUploadToken($token){
-        $result = Yii::$app->cache->get($token);
-        Yii::$app->cache->delete($token);
-        return $result;
-    }
-
-    /**
-     * 获取全部安置网络上级
-     * @param $userId
-     * @return array|mixed
-     */
-    public static function getAllNetworkParents($userId){
-        return UserNetwork::getAllParentsFromRedis($userId);
-    }
-
-    /**
-     * 获取全部推荐网络的上级
-     * @param $userId
-     * @return array|mixed
-     */
-    public static function getAllRelationParents($userId){
-        return UserRelation::getAllParentsFromRedis($userId);
-    }
-
 }

+ 0 - 194
common/helpers/ChartData.php

@@ -8,12 +8,8 @@
 
 namespace common\helpers;
 
-
 use common\models\CalcBonus;
-use common\models\PerfCompany;
 use common\models\Period;
-use common\models\UserInfo;
-use common\models\Withdraw;
 use yii\base\BaseObject;
 use yii\base\StaticInstanceTrait;
 
@@ -21,159 +17,6 @@ class ChartData extends BaseObject
 {
     use StaticInstanceTrait;
 
-    /**
-     * 年度累计奖金
-     * @return int|mixed
-     */
-    public function totalBonus(){
-        return 0;
-        $nowYear = Date::nowYear();
-        $bonus = CalcBonus::findUseSlaves()->select('SUM(BONUS_QY) AS BONUS_QY_SUM, SUM(BONUS_YC) AS BONUS_YC_SUM, SUM(BONUS_FX) AS BONUS_FX_SUM, SUM(BONUS_LS) AS BONUS_LS_SUM, SUM(BONUS_CF) AS BONUS_CF_SUM, SUM(BONUS_LX) AS BONUS_LX_SUM, SUM(BONUS_FL) AS BONUS_FL_SUM, SUM(BONUS_BT) AS BONUS_BT_SUM, SUM(BONUS_FW) AS BONUS_FW_SUM')->where('CALC_YEAR=:CALC_YEAR AND IS_SENT=:IS_SENT', [':CALC_YEAR'=>$nowYear, ':IS_SENT'=>1])->asArray()->one();
-        if($bonus){
-            return $bonus['BONUS_QY_SUM'] + $bonus['BONUS_YC_SUM'] + $bonus['BONUS_FX_SUM'] + $bonus['BONUS_LS_SUM'] + $bonus['BONUS_CF_SUM'] + $bonus['BONUS_LX_SUM'] + $bonus['BONUS_FL_SUM'] + $bonus['BONUS_BT_SUM'] + $bonus['BONUS_FW_SUM'];
-        } else {
-            return 0;
-        }
-    }
-
-    /**
-     * 年度总业绩
-     * @return int|mixed
-     */
-    public function totalPerf(){
-        return 0;
-        $nowYear = Date::nowYear();
-        $perf = PerfCompany::findUseSlaves()->select('SUM(ZC_PV) AS ZC_PV_SUM, SUM(YH_PV) AS YH_PV_SUM, SUM(ZG_PV) AS ZG_PV_SUM, SUM(LS_PV) AS LS_PV_SUM, SUM(FX_PV) AS FX_PV_SUM')->where('CALC_YEAR=:CALC_YEAR', [':CALC_YEAR'=>$nowYear])->asArray()->one();
-        if($perf){
-            return $perf['ZC_PV_SUM'] + $perf['YH_PV_SUM'] + $perf['ZG_PV_SUM'] + $perf['LS_PV_SUM'] + $perf['FX_PV_SUM'];
-        } else {
-            return 0;
-        }
-    }
-
-    /**
-     * 总提现金额
-     * @return int|mixed
-     */
-    public function totalWithdraw(){
-        $withdraw = Withdraw::findUseSlaves()->select('SUM(AMOUNT) AS AMOUNT_SUM')->where('AUDIT_STATUS=:AUDIT_STATUS AND CREATED_AT > :START_TIME AND CREATED_AT < :END_TIME', [':AUDIT_STATUS' => Withdraw::STATUS_PAID, ':START_TIME' => Date::yearStart(), ':END_TIME' => Date::yearEnd()])->asArray()->one();
-        if($withdraw){
-            return $withdraw['AMOUNT_SUM'];
-        } else {
-            return 0;
-        }
-    }
-
-    /**
-     * 会员总数量
-     * @return int|string
-     */
-    public function totalUser(){
-        return UserInfo::findUseSlaves()->where('1=1')->count();
-    }
-
-    /**
-     * 获取会员注册量
-     * @return array
-     */
-    public function getUserData(){
-        $monthAgo = [
-            [
-                'start' => Date::monthStart(Date::nowTime()),
-                'end' => Date::monthEnd(Date::nowTime()),
-            ],
-            [
-                'start' => Date::monthStart(Date::lastNumMonth(1)),
-                'end' => Date::monthEnd(Date::lastNumMonth(1)),
-            ],
-            [
-                'start' => Date::monthStart(Date::lastNumMonth(2)),
-                'end' => Date::monthEnd(Date::lastNumMonth(2)),
-            ],
-            [
-                'start' => Date::monthStart(Date::lastNumMonth(3)),
-                'end' => Date::monthEnd(Date::lastNumMonth(3)),
-            ],
-            [
-                'start' => Date::monthStart(Date::lastNumMonth(4)),
-                'end' => Date::monthEnd(Date::lastNumMonth(4)),
-            ],
-        ];
-        $result = [];
-        foreach($monthAgo as $key => $value){
-            $result[$key]['month'] = date('n月', Date::lastNumMonth($key));
-            $result[$key]['num'] = $this->_monthUserRegNum($monthAgo[$key]['start'], $monthAgo[$key]['end']);
-        }
-        return array_reverse($result);
-    }
-
-    /**
-     * 获取奖金统计数据
-     * @return array
-     */
-    public function getBonusData(){
-        $period = Period::instance();
-        $calcMonth = $period->getNowYearMonth();
-        $formatCalcMonth = substr($calcMonth, 0, 4).'-'.substr($calcMonth, 4, 2).'-01';
-        $calcMonths = [
-            [
-                'month' => $calcMonth,
-            ],
-            [
-                'month' => Date::lastNumMonth(1, strtotime($formatCalcMonth), 'Ym'),
-            ],
-            [
-                'month' => Date::lastNumMonth(2, strtotime($formatCalcMonth), 'Ym'),
-            ],
-            [
-                'month' => Date::lastNumMonth(3, strtotime($formatCalcMonth), 'Ym'),
-            ],
-            [
-                'month' => Date::lastNumMonth(4, strtotime($formatCalcMonth), 'Ym'),
-            ],
-        ];
-        foreach($calcMonths as $key => $value){
-            $calcMonths[$key]['month'] = date('n月', Date::lastNumMonth($key));
-            $calcMonths[$key]['num'] = $this->_monthBonus($value['month']);
-        }
-        return array_reverse($calcMonths);
-    }
-
-    /**
-     * 获取提现量
-     * @return array
-     */
-    public function getWithdrawData(){
-        $monthAgo = [
-            [
-                'start' => Date::monthStart(Date::nowTime()),
-                'end' => Date::monthEnd(Date::nowTime()),
-            ],
-            [
-                'start' => Date::monthStart(Date::lastNumMonth(1)),
-                'end' => Date::monthEnd(Date::lastNumMonth(1)),
-            ],
-            [
-                'start' => Date::monthStart(Date::lastNumMonth(2)),
-                'end' => Date::monthEnd(Date::lastNumMonth(2)),
-            ],
-            [
-                'start' => Date::monthStart(Date::lastNumMonth(3)),
-                'end' => Date::monthEnd(Date::lastNumMonth(3)),
-            ],
-            [
-                'start' => Date::monthStart(Date::lastNumMonth(4)),
-                'end' => Date::monthEnd(Date::lastNumMonth(4)),
-            ],
-        ];
-        $result = [];
-        foreach($monthAgo as $key => $value){
-            $result[$key]['month'] = date('n月', Date::lastNumMonth($key));
-            $result[$key]['num'] = $this->_monthWithdrawNum($monthAgo[$key]['start'], $monthAgo[$key]['end']);
-        }
-        return array_reverse($result);
-    }
-
     public function userBonusData($userId){
         $period = Period::instance();
         $calcMonth = $period->getNowYearMonth();
@@ -201,41 +44,6 @@ class ChartData extends BaseObject
         return array_reverse($calcMonths);
     }
 
-    /**
-     * 某月会员注册量
-     * @param $monthStart
-     * @param $monthEnd
-     * @return int|string
-     */
-    private function _monthUserRegNum($monthStart, $monthEnd){
-        return UserInfo::findUseSlaves()->where('CREATED_AT>:START_TIME AND CREATED_AT<:END_TIME', [':START_TIME'=>$monthStart, ':END_TIME'=>$monthEnd])->count();
-    }
-
-    /**
-     * 月奖金和
-     * @param $calcMonth
-     * @return int|mixed
-     */
-    private function _monthBonus($calcMonth){
-        if($calcMonth){
-            $bonus = CalcBonus::findUseSlaves()->yearMonth($calcMonth)->select('SUM(BONUS_QY) AS BONUS_QY_SUM, SUM(BONUS_YC) AS BONUS_YC_SUM, SUM(BONUS_FX) AS BONUS_FX_SUM, SUM(BONUS_LS) AS BONUS_LS_SUM, SUM(BONUS_CF) AS BONUS_CF_SUM, SUM(BONUS_LX) AS BONUS_LX_SUM, SUM(BONUS_FL) AS BONUS_FL_SUM, SUM(BONUS_BT) AS BONUS_BT_SUM, SUM(BONUS_FW) AS BONUS_FW_SUM')->where('CALC_MONTH=:CALC_MONTH AND IS_SENT=1', [':CALC_MONTH'=>$calcMonth])->asArray()->one();
-            if($bonus){
-                return $bonus['BONUS_QY_SUM'] + $bonus['BONUS_YC_SUM'] + $bonus['BONUS_FX_SUM'] + $bonus['BONUS_LS_SUM'] + $bonus['BONUS_CF_SUM'] + $bonus['BONUS_LX_SUM'] + $bonus['BONUS_FL_SUM'] + $bonus['BONUS_BT_SUM'] + $bonus['BONUS_FW_SUM'];
-            }
-        }
-        return 0;
-    }
-
-    /**
-     * 月提现
-     * @param $monthStart
-     * @param $monthEnd
-     * @return string
-     */
-    private function _monthWithdrawNum($monthStart, $monthEnd){
-        return Tool::formatPrice(Withdraw::findUseSlaves()->where('CREATED_AT>:START_TIME AND CREATED_AT<:END_TIME AND AUDIT_STATUS=:AUDIT_STATUS', [':START_TIME'=>$monthStart, ':END_TIME'=>$monthEnd, ':AUDIT_STATUS'=>Withdraw::STATUS_PAID])->sum('AMOUNT'));
-    }
-
     private function _userMonthBonus($calcMonth, $userId){
         $bonus = CalcBonus::findUseSlaves()->yearMonth($calcMonth)->select('BONUS_QY, BONUS_YC, BONUS_FX, BONUS_LS, BONUS_CF, BONUS_LX, BONUS_FL, BONUS_BT, BONUS_FW')->where('CALC_MONTH=:CALC_MONTH AND IS_SENT=1 AND USER_ID=:USER_ID', [':CALC_MONTH'=>$calcMonth, ':USER_ID'=>$userId])->asArray()->one();
         if($bonus){
@@ -264,6 +72,4 @@ class ChartData extends BaseObject
             ];
         }
     }
-
-
 }

+ 0 - 134
common/helpers/DataBak.php

@@ -1,134 +0,0 @@
-<?php
-/**
- * Created by PhpStorm.
- * User: leo
- * Date: 2018/4/28
- * Time: 下午6:38
- */
-
-namespace common\helpers;
-
-
-use common\components\ActiveRecord;
-use common\models\User;
-use common\models\UserInfo;
-use common\models\UserNetwork;
-use common\models\UserRelation;
-use yii\base\Exception;
-
-class DataBak
-{
-    const LIMIT = 100;
-
-    /**
-     * 备份数据
-     * @param $periodNum
-     * @throws \yii\db\Exception
-     */
-    public static function backup($periodNum) {
-        // 删除并创建会员表
-        self::dropBakTable('USER_ALL', $periodNum);
-        self::createdBakTable('USER_ALL', $periodNum);
-        // 删除并创建接点表
-        self::dropBakTable('USER_NETWORK', $periodNum);
-        self::createdBakTable('USER_NETWORK', $periodNum);
-        // 删除并创建推荐表
-        self::dropBakTable('USER_RELATION', $periodNum);
-        self::createdBakTable('USER_RELATION', $periodNum);
-        // 备份会员数据
-        self::backupUserTableData($periodNum);
-//        self::backupNetTableData('network', $periodNum);
-//        self::backupNetTableData('relation', $periodNum);
-    }
-
-    /**
-     * 备份会员表
-     * @param $periodNum
-     * @param int $offset
-     * @throws \yii\db\Exception
-     */
-    public static function backupUserTableData($periodNum, $offset = 0) {
-        $allUserData = User::findUseDbCalc()->where('1=1')->offset($offset)->limit(self::LIMIT)->asArray()->all();
-        if($allUserData){
-            $insertData = [];
-            foreach($allUserData as $data){
-                unset($data['ROWNUMID'], $data['PARTITION_DATE'], $data['PAY_PASSWORD'], $data['PASSWORD_HASH']);
-                $userInfoData = UserInfo::findUseDbCalc()->where('USER_ID=:USER_ID', [':USER_ID' => $data['ID']])->asArray()->one();
-                if($userInfoData){
-                    unset($userInfoData['ROWNUMID']);
-                } else {
-                    continue;
-                }
-                $insertData[] = array_merge($data, $userInfoData);
-            }
-            ActiveRecord::batchInsert($insertData, '{{%USER_ALL_'.$periodNum.'}}', 'dbNetPoint');
-            unset($allUserData, $insertData);
-            self::backupUserTableData($periodNum, $offset + self::LIMIT);
-        }
-    }
-
-    /**
-     * 备份网络数据
-     * @param $netType
-     * @param $periodNum
-     * @param int $offset
-     * @throws \yii\db\Exception
-     */
-    public static function backupNetTableData($netType, $periodNum, $offset = 0){
-        if($netType == 'network'){
-            $modelClass = UserNetwork::class;
-            $tableName = '{{%USER_NETWORK_'.$periodNum.'}}';
-        } else {
-            $modelClass = UserRelation::class;
-            $tableName = '{{%USER_RELATION_'.$periodNum.'}}';
-        }
-        $allData = $modelClass::findUseDbCalc()->where('1=1')->offset($offset)->limit(self::LIMIT)->asArray()->all();
-        if($allData){
-            $insertData = [];
-            foreach($allData as $data){
-                unset($data['ROWNUMID']);
-                $insertData[] = $data;
-            }
-                ActiveRecord::batchInsert($insertData, $tableName, 'dbNetPoint');
-            unset($allData, $insertData);
-            self::backupNetTableData($netType, $periodNum, $offset + self::LIMIT);
-        }
-    }
-
-    /**
-     * 创建备份表
-     * @param $tableName
-     * 不含 AR_
-     * @param $periodNum
-     * 取数
-     */
-    public static function createdBakTable($tableName, $periodNum) {
-        if($tableName == 'USER_ALL') {
-            $fromTableName = '{{%USER_ALL_TEMPLATE}}';
-            $fromDb = 'dbNetPoint';
-        } else {
-            $fromTableName = '{{%'.$tableName.'}}';
-            $fromDb = 'db';
-        }
-        $createTableName = '{{%'.$tableName.'_'.$periodNum.'}}';
-        if(!ActiveRecord::isExistsTable($createTableName, 'dbNetPoint')){
-            // 创建表
-            ActiveRecord::createTableFromTable($createTableName, $fromTableName, [], 'dbNetPoint', $fromDb);
-        }
-    }
-
-    /**
-     * 删除备份的表
-     * @param $tableName
-     * 不含 AR_
-     * @param $periodNum
-     * 取数
-     */
-    public static function dropBakTable($tableName, $periodNum){
-        $dropTableName =  '{{%'.$tableName.'_'.$periodNum.'}}';
-        if(ActiveRecord::isExistsTable($dropTableName, 'dbNetPoint')){
-            ActiveRecord::deleteTable($dropTableName, 'dbNetPoint');
-        }
-    }
-
-}

+ 0 - 15
common/helpers/Date.php

@@ -32,7 +32,6 @@ class Date {
     }
 
     /**
-     * 获取当前时间,主要用于console里面获取当前时间,方便日后系统日期在这里面修改
      * @param int $days
      * @return int|mixed
      */
@@ -54,7 +53,6 @@ class Date {
      */
     public static function convert($value = null, $format = 'Y-m-d') {
         if (is_null($value)) $value = date($format, self::nowTime()); //相对于某一时间的昨天
-        //if (!self::validator($value)) $value = date($format, self::nowTime());
         if (Validator::validateQuickLy('chMonth', $value)) {
             return $value . '-01';
         }
@@ -65,8 +63,6 @@ class Date {
     }
 
     /**
-     * 今天
-     *
      * @param string $format
      * @return false|string
      */
@@ -75,8 +71,6 @@ class Date {
     }
 
     /**
-     * 今天的开始时间
-     *
      * @return false|int
      */
     public static function todayStart() {
@@ -85,8 +79,6 @@ class Date {
     }
 
     /**
-     * 今天的结束时间
-     *
      * @return false|int
      */
     public static function todayEnd() {
@@ -95,8 +87,6 @@ class Date {
     }
 
     /**
-     * 昨天
-     *
      * @param null $relative
      * @param string $format
      * @return false|int|string
@@ -122,8 +112,6 @@ class Date {
     }
 
     /**
-     * 昨天的结束时间[23:59:59]
-     *
      * @param null $relative
      * @return false|int
      */
@@ -133,8 +121,6 @@ class Date {
     }
 
     /**
-     * 上个月
-     *
      * @param null $relative
      * @param string $format
      * @return false|int|string
@@ -149,7 +135,6 @@ class Date {
     }
 
     /**
-     * 上几个月的时间
      * @param int $num
      * @param null $relative
      * @param null $format

+ 0 - 899
common/helpers/Excel.php

@@ -1,899 +0,0 @@
-<?php
-/**
- * Created by PhpStorm.
- * User: leo
- * Date: 2018/5/17
- * Time: 上午11:34
- */
-
-namespace common\helpers;
-
-use common\helpers\http\RemoteUploadApi;
-use common\models\ExcelAddUser;
-use common\models\ExcelChangeBalance;
-use common\models\ExcelImport;
-use common\models\ExcelRegInfo;
-use common\models\ExcelWithdrawPaidFalse;
-use common\models\Export;
-use common\models\ExportFile;
-use common\models\forms\AdminAddUserForm;
-use common\models\forms\ChangeBalanceForm;
-use common\models\forms\ExcelOrderDecForm;
-use common\models\forms\ExcelOrderShopForm;
-use common\models\forms\ExcelOrderStandardForm;
-use common\models\forms\RegInfoAuditForm;
-use common\models\forms\WithdrawForm;
-use common\models\Uploads;
-use common\models\UserNetwork;
-use yii\base\BaseObject;
-use yii\base\Exception;
-use yii\base\StaticInstanceTrait;
-
-class Excel extends BaseObject {
-    use StaticInstanceTrait;
-
-    const CHILD_PATH = 'excel_export';
-
-    public $isRemote = true;
-    public $uploadInfo;
-    public $exportInfo;
-
-    private $_errors = [];
-    const EXCEL_STRUCTURE = [
-        'addUser' => [
-            'formClass' => AdminAddUserForm::class,
-            'formScenario' => 'add',
-            'formAction' => 'edit',
-            'errorTipField' => 'USER_NAME',
-            'excelTableClass' => ExcelAddUser::class,
-            'excelTableField' => [
-                '序号' => 'SORT',
-                '会员编号' => 'USER_NAME',
-                '会员姓名' => 'REAL_NAME',
-                '会员级别' => 'DEC_LV',
-                '身份证' => 'ID_CARD',
-                '手机' => 'MOBILE',
-                '备用手机号' => 'TEL',
-                '省/市' => 'AREA_PROVINCE',
-                '市/区' => 'AREA_CITY',
-                '区/县' => 'AREA_COUNTY',
-                '身份证地址' => 'ADDRESS',
-                '开户银行' => 'OPEN_BANK',
-                '开户行地址' => 'BANK_ADDRESS',
-                '银行账号' => 'BANK_NO',
-                '银行 省/市' => 'BANK_PROVINCE',
-                '银行 市/区' => 'BANK_CITY',
-                '银行 区/县' => 'BANK_COUNTY',
-                '是否报单中心' => 'IS_DEC',
-                '报单中心级别' => 'DEC_ROLE',
-                '所属报单中心编号' => 'DEC_USER_NAME',
-                '生日' => 'BIRTHDAY',
-                '接点人' => 'CON_USER_NAME',
-                '开拓人' => 'REC_USER_NAME',
-                '区位' => 'LOCATION',
-            ],
-            'formField' => [
-                'USER_NAME' => [
-                    'name' => 'userName',
-                    'type' => 'common',
-                ],
-                'REAL_NAME' => [
-                    'name' => 'realName',
-                    'type' => 'common',
-                ],
-                'DEC_LV' => [
-                    'name' => 'decLv',
-                    'type' => 'table',
-                    'table' => 'DECLARATION_LEVEL',
-                    'field' => 'LEVEL_NAME',
-                    'select' => 'ID',
-                ],
-                'ID_CARD' => [
-                    'name' => 'idCard',
-                    'type' => 'common',
-                ],
-                'MOBILE' => [
-                    'name' => 'mobile',
-                    'type' => 'common',
-                ],
-                'TEL' => [
-                    'name' => 'tel',
-                    'type' => 'common',
-                ],
-                'AREA_PROVINCE' => [
-                    'name' => 'areaSelected',
-                    'isArray' => true,
-                    'type' => 'table',
-                    'table' => 'REGION',
-                    'field' => 'REGION_NAME',
-                    'where' => 'DEEP=2',
-                    'select' => 'REGION_CODE',
-                ],
-                'AREA_CITY' => [
-                    'name' => 'areaSelected',
-                    'isArray' => true,
-                    'type' => 'table',
-                    'table' => 'REGION',
-                    'field' => 'REGION_NAME',
-                    'where' => 'DEEP=3',
-                    'select' => 'REGION_CODE',
-                ],
-                'AREA_COUNTY' => [
-                    'name' => 'areaSelected',
-                    'isArray' => true,
-                    'type' => 'table',
-                    'table' => 'REGION',
-                    'field' => 'REGION_NAME',
-                    'where' => 'DEEP=4',
-                    'select' => 'REGION_CODE',
-                ],
-                'ADDRESS' => [
-                    'name' => 'address',
-                    'type' => 'common',
-                ],
-                'OPEN_BANK' => [
-                    'name' => 'openBank',
-                    'type' => 'table',
-                    'table' => 'OPEN_BANK',
-                    'field' => 'BANK_NAME',
-                    'select' => 'BANK_CODE',
-                ],
-                'BANK_ADDRESS' => [
-                    'name' => 'bankAddress',
-                    'type' => 'common',
-                ],
-                'BANK_NO' => [
-                    'name' => 'bankNo',
-                    'type' => 'common',
-                ],
-                'BANK_PROVINCE' => [
-                    'name' => 'bankAreaSelected',
-                    'isArray' => true,
-                    'type' => 'table',
-                    'table' => 'REGION',
-                    'field' => 'REGION_NAME',
-                    'where' => 'DEEP=2',
-                    'select' => 'REGION_CODE',
-                ],
-                'BANK_CITY' => [
-                    'name' => 'bankAreaSelected',
-                    'isArray' => true,
-                    'type' => 'table',
-                    'table' => 'REGION',
-                    'field' => 'REGION_NAME',
-                    'where' => 'DEEP=3',
-                    'select' => 'REGION_CODE',
-                ],
-                'BANK_COUNTY' => [
-                    'name' => 'bankAreaSelected',
-                    'isArray' => true,
-                    'type' => 'table',
-                    'table' => 'REGION',
-                    'field' => 'REGION_NAME',
-                    'where' => 'DEEP=4',
-                    'select' => 'REGION_CODE',
-                ],
-                'IS_DEC' => [
-                    'name' => 'isDec',
-                    'type' => 'bool',
-                ],
-                'DEC_ROLE' => [
-                    'name' => 'decRoleId',
-                    'type' => 'table',
-                    'table' => 'DEC_ROLE',
-                    'field' => 'ROLE_NAME',
-                    'select' => 'ID',
-                    'isAllowNull' => true,
-                ],
-                'DEC_USER_NAME' => [
-                    'name' => 'decUserName',
-                    'type' => 'common',
-                ],
-                'BIRTHDAY' => [
-                    'name' => 'birthday',
-                    'type' => 'common',
-                ],
-                'CON_USER_NAME' => [
-                    'name' => 'conUserName',
-                    'type' => 'common',
-                ],
-                'REC_USER_NAME' => [
-                    'name' => 'recUserName',
-                    'type' => 'common',
-                ],
-                'LOCATION' => [
-                    'name' => 'location',
-                    'type' => 'int',
-                ],
-            ]
-        ],
-        'withdrawPaidFalse' => [
-            'formClass' => WithdrawForm::class,
-            'formScenario' => 'excelPaidFalse',
-            'formAction' => 'excelPaidFalse',
-            'errorTipField' => 'SN',
-            'excelTableClass' => ExcelWithdrawPaidFalse::class,
-            'excelTableField' => [
-                '序号' => 'SORT',
-                '提现流水号' => 'SN',
-                '提现期数' => 'WITHDRAW_PERIOD_NUM',
-                '付款日期' => 'PAID_AT',
-                '付款失败原因' => 'PAID_FAIL_REMARK',
-                '会员编号' => 'USER_NAME',
-                '会员姓名' => 'REAL_NAME',
-                '实付金额' => 'AMOUNT',
-                '实时开户名' => 'BANK_REAL_NAME',
-                '实时银行账户' => 'BANK_NO',
-            ],
-            'formField' => [
-                'SN' => [
-                    'name' => 'sn',
-                    'type' => 'common',
-                ],
-                'WITHDRAW_PERIOD_NUM' => [
-                    'name' => 'withdrawPeriodNum',
-                    'type' => 'common',
-                ],
-                'PAID_AT' => [
-                    'name' => 'paidAt',
-                    'type' => 'common',
-                ],
-                'PAID_FAIL_REMARK' => [
-                    'name' => 'paidFailRemark',
-                    'type' => 'common',
-                ],
-                'USER_NAME' => [
-                    'name' => 'userName',
-                    'type' => 'common',
-                ],
-                'REAL_NAME' => [
-                    'name' => 'realName',
-                    'type' => 'common',
-                ],
-                'AMOUNT' => [
-                    'name' => 'amount',
-                    'type' => 'common',
-                ],
-                'BANK_REAL_NAME' => [
-                    'name' => 'bankRealName',
-                    'type' => 'common',
-                ],
-                'BANK_NO' => [
-                    'name' => 'bankNo',
-                    'type' => 'common',
-                ],
-            ]
-        ],
-        'changeBalance' => [
-            'formClass' => ChangeBalanceForm::class,
-            'formScenario' => 'excelChangeBalance',
-            'formAction' => 'excelChangeBalance',
-            'errorTipField' => 'USER_NAME',
-            'excelTableClass' => ExcelChangeBalance::class,
-            'excelTableField' => [
-                '序号' => 'SORT',
-                '会员编号' => 'USER_NAME',
-                '会员姓名' => 'REAL_NAME',
-                '账户类型' => 'TYPE',
-                '交易类型' => 'DEAL_TYPE',
-                '调整金额' => 'AMOUNT',
-                '备注' => 'REMARK',
-                '备注是否前台显示' => 'REMARK_IS_SHOW',
-            ],
-            'formField' => [
-                'USER_NAME' => [
-                    'name' => 'userName',
-                    'type' => 'common',
-                ],
-                'REAL_NAME' => [
-                    'name' => 'realName',
-                    'type' => 'common',
-                ],
-                'TYPE' => [
-                    'name' => 'type',
-                    'type' => 'param',
-                    'index' => 'bonusWalletType',
-                ],
-                'DEAL_TYPE' => [
-                    'name' => 'dealType',
-                    'type' => 'table',
-                    'db' => 'db',
-                    'table' => 'DEAL_TYPE',
-                    'field' => 'TYPE_NAME',
-                    'select' => 'ID',
-                ],
-                'AMOUNT' => [
-                    'name' => 'amount',
-                    'type' => 'common',
-                ],
-                'REMARK' => [
-                    'name' => 'remark',
-                    'type' => 'common',
-                ],
-                'REMARK_IS_SHOW' => [
-                    'name' => 'isShow',
-                    'type' => 'bool',
-                ],
-            ]
-        ],
-        'regInfo' => [
-            'formClass' => RegInfoAuditForm::class,
-            'formScenario' => 'excelAdd',
-            'formAction' => 'excelAdd',
-            'errorTipField' => 'USER_NAME',
-            'excelTableClass' => ExcelRegInfo::class,
-            'excelTableField' => [
-                '序号' => 'SORT',
-                '会员编号' => 'USER_NAME',
-                '会员姓名' => 'REAL_NAME',
-                '身份证' => 'ID_CARD',
-                '注册类型' => 'REG_TYPE',
-                '注册名称' => 'REG_NAME',
-                '统一社会信用代码' => 'CREDIT_CODE',
-                '经营场所' => 'PREMISES',
-                '注册有效期' => 'REG_EXPIRES',
-                '法人' => 'LEGAL_PERSON',
-                '企业开户名称' => 'OPEN_NAME',
-                '企业开户银行' => 'OPEN_BANK',
-                '企业开户行地址' => 'BANK_ADDRESS',
-                '企业银行账号' => 'BANK_NO',
-                '企业银行 省/市' => 'BANK_PROVINCE',
-                '企业银行 市/区' => 'BANK_CITY',
-                '企业银行 区/县' => 'BANK_COUNTY',
-                '备注' => 'REMARK',
-            ],
-            'formField' => [
-                'USER_NAME' => [
-                    'name' => 'userName',
-                    'type' => 'common',
-                ],
-                'REAL_NAME' => [
-                    'name' => 'realName',
-                    'type' => 'common',
-                ],
-                'ID_CARD' => [
-                    'name' => 'idCard',
-                    'type' => 'common',
-                ],
-                'REG_TYPE' => [
-                    'name' => 'type',
-                    'type' => 'table',
-                    'db' => 'db',
-                    'table' => 'REG_TYPE',
-                    'field' => 'TYPE_NAME',
-                    'select' => 'ID',
-                ],
-                'REG_NAME' => [
-                    'name' => 'regName',
-                    'type' => 'common',
-                ],
-                'CREDIT_CODE' => [
-                    'name' => 'creditCode',
-                    'type' => 'common',
-                ],
-                'PREMISES' => [
-                    'name' => 'premises',
-                    'type' => 'common',
-                ],
-                'REG_EXPIRES' => [
-                    'name' => 'regExpires',
-                    'type' => 'common',
-                ],
-                'LEGAL_PERSON' => [
-                    'name' => 'legalPerson',
-                    'type' => 'common',
-                ],
-                'OPEN_NAME' => [
-                    'name' => 'openName',
-                    'type' => 'common',
-                ],
-                'OPEN_BANK' => [
-                    'name' => 'openBank',
-                    'type' => 'table',
-                    'table' => 'OPEN_BANK',
-                    'field' => 'BANK_NAME',
-                    'select' => 'BANK_CODE',
-                    'isAllowNull' => true,
-                ],
-                'BANK_ADDRESS' => [
-                    'name' => 'bankAddress',
-                    'type' => 'common',
-                    'isAllowNull' => true,
-                ],
-                'BANK_NO' => [
-                    'name' => 'bankNo',
-                    'type' => 'common',
-                    'isAllowNull' => true,
-                ],
-                'BANK_PROVINCE' => [
-                    'name' => 'bankAreaSelected',
-                    'isArray' => true,
-                    'type' => 'table',
-                    'table' => 'REGION',
-                    'field' => 'REGION_NAME',
-                    'where' => 'DEEP=2',
-                    'select' => 'REGION_CODE',
-                    'isAllowNull' => true,
-                ],
-                'BANK_CITY' => [
-                    'name' => 'bankAreaSelected',
-                    'isArray' => true,
-                    'type' => 'table',
-                    'table' => 'REGION',
-                    'field' => 'REGION_NAME',
-                    'where' => 'DEEP=3',
-                    'select' => 'REGION_CODE',
-                    'isAllowNull' => true,
-                ],
-                'BANK_COUNTY' => [
-                    'name' => 'bankAreaSelected',
-                    'isArray' => true,
-                    'type' => 'table',
-                    'table' => 'REGION',
-                    'field' => 'REGION_NAME',
-                    'where' => 'DEEP=4',
-                    'select' => 'REGION_CODE',
-                    'isAllowNull' => true,
-                ],
-                'REMARK' => [
-                    'name' => 'createRemark',
-                    'type' => 'common',
-                ],
-            ]
-        ],
-        'orderShop' => [
-            'excelTableClass' => ExcelOrderShopForm::class,
-            'excelTableAction' => 'run',
-        ],
-        'orderDec' => [
-            'excelTableClass' => ExcelOrderDecForm::class,
-            'excelTableAction' => 'run',
-        ],
-        'orderShopStandard' => [
-            'excelTableClass' => ExcelOrderStandardForm::class,
-            'excelTableAction' => 'run',
-        ],
-    ];
-
-    public function init() {
-        parent::init();
-        $this->isRemote = \Yii::$app->params['isRemoteUpload'];
-    }
-
-    /**
-     * 加入错误错误
-     * @param $attr
-     * @param $error
-     */
-    public function addError($attr, $error) {
-        $this->_errors[$attr][] = $error;
-    }
-
-    /**
-     * 获取错误信息
-     * @return array
-     */
-    public function getErrors() {
-        return $this->_errors;
-    }
-
-    /**
-     * 导出到文件
-     * @param $exportId
-     * @param array $dataArr
-     * @param array $columns
-     * @param $fileName
-     * @param callable|null $callBack
-     * @return bool
-     */
-    public function exportToFile($exportId, array $dataArr, array $columns, $fileName, callable $callBack = null) {
-        $result = true;
-        $headers = $columns;
-        $columns = array_keys($columns);
-        $fileName = $fileName . '_export_' . date('YmdHis') . uniqid() . '.xlsx';
-        $path = \Yii::getAlias('@common/runtime/' . self::CHILD_PATH . '/');
-        if (!is_dir($path)) {
-            mkdir($path, 0755);
-        }
-        try {
-            \sunmoon\phpspreadsheet\Excel::export([
-                'models' => $dataArr,
-                'columns' => $columns,
-                'headers' => $headers,
-                'savePath' => $path,
-                'asAttachment' => false,
-                'format' => 'Xlsx',
-                'fileName' => $fileName,
-                'exit' => false,
-                'exportIterationCallback' => $callBack,
-            ]);
-            // 把导出的文件上传至静态文件服务器
-            if ($this->isRemote) {
-                $remoteUploadApi = RemoteUploadApi::instance();
-                if ($uploadResult = $remoteUploadApi->upload($path . $fileName)) {
-                    $this->exportInfo = [
-                        'fileName' => $uploadResult['name'],
-                        'url' => $uploadResult['url'],
-                        'fileSize' => $uploadResult['size'] ?? null,
-                        'md5' => $uploadResult['md5'] ?? null,
-                    ];
-                } else {
-                    throw new Exception('文件远程上传失败');
-                }
-                // 删除本地临时文件
-                unlink($path . $fileName);
-            } else {
-                $this->exportInfo = [
-                    'fileName' => $fileName,
-                    'url' => $path . $fileName,
-                    'fileSize' => null,
-                    'md5' => null,
-                ];
-            }
-            // 把文件对应的相关资料存入数据库中
-            $uploads = new ExportFile();
-            $uploads->FILE_NAME = $this->exportInfo['fileName'];
-            $uploads->EXPORT_ID = $exportId;
-            $uploads->URL = $this->exportInfo['url'];
-            $uploads->FILE_SIZE = $this->exportInfo['fileSize'] ?? null;
-            $uploads->MD5 = $this->exportInfo['md5'] ?? null;
-            $uploads->CREATED_AT = Date::nowTime();
-            if (!$uploads->save()) {
-                throw new Exception(Form::formatErrorsForApi($uploads->getErrors()));
-            }
-        } catch (\Exception $e) {
-            $this->addError('export', $e->getMessage());
-            $result = false;
-        }
-        return $result;
-    }
-
-    /**
-     * 过滤读取到的数据把空的未填写的行都删掉
-     * @param $data
-     * @return mixed
-     */
-    public static function filterData(&$data) {
-        foreach ($data as $key => $value) {
-            $isAllNull = true;
-            foreach ($value as $k => $v) {
-                if ($v !== null) {
-                    $isAllNull = false;
-                }
-            }
-            if ($isAllNull) {
-                unset($data[$key]);
-            }
-        }
-        return $data;
-    }
-
-    /**
-     * 分页导入数据
-     * @param $excelStructureKey
-     * @param $excelImportId
-     * @param int $rowCount
-     * @param int $startRow
-     * @param int $limit
-     * @return int
-     * @throws Exception
-     */
-    public function pageImportDataFromExcel($excelStructureKey, $excelImportId, $rowCount = 1000, $startRow = 1, $limit = 1000) {
-        if ($startRow > 1) {
-            $startRow = $startRow + 1;
-            $limit = $limit - 1;
-        }
-        $fileNameArray = ExcelImport::find()->select('U.FILE_NAME')->from(ExcelImport::tableName() . ' AS ET')->join('LEFT JOIN', Uploads::tableName() . ' AS U', 'ET.UPLOAD_ID=U.ID')->where('ET.ID=:ID', [':ID' => $excelImportId])->asArray()->one();
-        $filePath = \Yii::getAlias('@common/runtime/uploads/' . $fileNameArray['FILE_NAME']);
-        if ($startRow > $rowCount) {
-            return 0;
-        }
-        try {
-            // 临时文件不存在则创建
-            $tempFileName = \Yii::getAlias('@common/runtime/uploads/' . 'importTemp.txt');
-            if (!file_exists($tempFileName)) {
-                $fp = fopen($tempFileName, 'w+');
-                fclose($fp);
-            } else {
-                if ($startRow == 1) {
-                    file_put_contents($tempFileName, '');
-                }
-            }
-            $data = \sunmoon\phpspreadsheet\Excel::import($filePath, [
-                'setFirstRecordAsKeys' => true,
-                'readStartRow' => $startRow,
-                'readEndRow' => $startRow + $limit,
-                'storeFile' => $tempFileName,
-                'dropKeysRow' => $startRow == 1 ? false : true,
-            ]);
-        } catch (\Exception $e) {
-            throw new Exception($e->getMessage());
-        }
-        self::filterData($data);
-
-
-        if ($data) {
-
-//            if($startRow != 1){
-//                unset($data[0]);
-//            }
-//            if(!$data) return 0;
-//            self::filterData($data);
-            $this->importDataToExcelTable($excelStructureKey, $excelImportId, $data);
-            return 1;
-        } else {
-            return 0;
-        }
-    }
-
-    /**
-     * Excel数据导入到待导入的表中
-     * @param $excelStructureKey
-     * @param $excelImportId
-     * @param $excelData
-     */
-    public function importDataToExcelTable($excelStructureKey, $excelImportId, $excelData) {
-        $tableClass = self::EXCEL_STRUCTURE[$excelStructureKey]['excelTableClass'];
-        $tableIndex = self::EXCEL_STRUCTURE[$excelStructureKey]['excelTableField'];
-        $insertData = [];
-
-        foreach ($excelData as $data) {
-            $oneInsertData = [
-                'EXCEL_IMPORT_ID' => $excelImportId,
-                'CREATED_AT' => Date::nowTime(),
-            ];
-            foreach ($data as $key => $value) {
-                $oneInsertData[$tableIndex[$key]] = $value;
-            }
-            $insertData[] = $oneInsertData;
-        }
-        $tableClass::batchInsert($insertData);
-    }
-
-    /**
-     * 分页从待导入表中导入数据到真实数据中
-     * @param $excelStructureKey
-     * @param $excelImportId
-     * @param int $offset
-     * @param int $limit
-     * @return int
-     * @throws Exception
-     */
-    public function pageImportDataFromExcelTable($excelStructureKey, $excelImportId, $offset = 0, $limit = 1000) {
-        $tableClass = self::EXCEL_STRUCTURE[$excelStructureKey]['excelTableClass'];
-        // 获取1000条数据
-        $allData = $tableClass::find()->where('EXCEL_IMPORT_ID=:EXCEL_IMPORT_ID', [':EXCEL_IMPORT_ID' => $excelImportId])->orderBy('SORT ASC')->offset($offset)->limit($limit)->asArray()->all();
-        if ($allData) {
-            $this->importToDbWithForm($excelStructureKey, $allData);
-            return 1;
-        }
-        return 0;
-    }
-
-    /**
-     * 通过表单类导入
-     * @param $excelStructureKey
-     * @param $excelDatas
-     * @throws Exception
-     */
-    public function importToDbWithForm($excelStructureKey, $excelDatas) {
-        foreach ($excelDatas as $value) {
-            $formClassName = self::EXCEL_STRUCTURE[$excelStructureKey]['formClass'];
-            $formScenario = self::EXCEL_STRUCTURE[$excelStructureKey]['formScenario'];
-            $formAction = self::EXCEL_STRUCTURE[$excelStructureKey]['formAction'];
-            $formData = $this->excelDataToFormData($excelStructureKey, $value);
-            if ($formData) {
-                $form = new $formClassName();
-                $form->scenario = $formScenario;
-                foreach ($formData as $formKey => $formValue) {
-                    $form->$formKey = $formValue;
-                }
-                $errorTipField = self::EXCEL_STRUCTURE[$excelStructureKey]['errorTipField'];
-                $tableClass = self::EXCEL_STRUCTURE[$excelStructureKey]['excelTableClass'];
-
-                if (!$form->$formAction()) {
-
-                    // 失败信息写入到待导入数据库excel表中
-                    $tableClass::updateAll(['STATUS' => 2, 'ERROR_REMARK' => Form::formatErrorsForApi($form->getErrors())], 'ID=:ID', [':ID' => $value['ID']]);
-                    throw new Exception('错误序号【'.$value['SORT'].'】会员编号【'.$value['USER_NAME'].'】。导入' . $value[$errorTipField] . '发生错误,原因:' . Form::formatErrorsForApi($form->getErrors()));
-                } else {
-                    $tableClass::updateAll(['STATUS' => 1], 'ID=:ID', [':ID' => $value['ID']]);
-                }
-            }
-        }
-    }
-
-    /**
-     * excel数据转为表单可提交的数据
-     * @param $excelStructureKey
-     * @param $excelData
-     * @return array
-     * @throws Exception
-     */
-    public function excelDataToFormData($excelStructureKey, $excelData) {
-        $formFieldArr = self::EXCEL_STRUCTURE[$excelStructureKey]['formField'];
-        $excelTableField = self::EXCEL_STRUCTURE[$excelStructureKey]['excelTableField'];
-        $sort = $excelData['SORT'];
-        $result = [];
-        foreach ($excelData as $key => $value) {
-            if (in_array($key, ['ID', 'EXCEL_IMPORT_ID', 'STATUS', 'ERROR_REMARK', 'CREATED_AT', 'SORT', 'ROWNUMID'])) continue;
-            if (!array_key_exists($key, $formFieldArr)) {
-                throw new Exception('excel表格字段不符合要求,字段为:' . $key);
-            }
-            $resultKey = $formFieldArr[$key]['name'];
-            // 这里要判断是否允许为空值,如果允许则可以直接付空值
-            if (isset($formFieldArr[$key]['isAllowNull']) && $formFieldArr[$key]['isAllowNull'] && $value === null) {
-                $result[$resultKey] = $value;
-            } elseif ($formFieldArr[$key]['type'] === 'common') {
-                $result[$resultKey] = $value;
-            } elseif ($formFieldArr[$key]['type'] === 'bool') {
-                $result[$resultKey] = intval($value == '是');
-            } elseif ($formFieldArr[$key]['type'] === 'int') {
-                $result[$resultKey] = intval($value);
-            } elseif ($formFieldArr[$key]['type'] === 'param') {
-                // 从param的数据中获取
-                $tempArray = \Yii::$app->params[$formFieldArr[$key]['index']];
-                if ($formFieldArr[$key]['name'] === 'nation') {
-                    array_unshift($tempArray, [
-                        'id' => '0',
-                        'name' => '',
-                    ]);
-                    $nationsArray = array_column($tempArray, 'name');
-                    $tempResultIndex = array_search($value, $nationsArray);
-                    if ($tempResultIndex === false){
-                        if($errTableField = array_search($key, $excelTableField)){
-                            throw new Exception('序号' . $sort . '的表格【' . $errTableField . '】值填写有误,系统中未找到填写的"' . $value . '"');
-                        }else{
-                            throw new Exception('序号' . $sort . '的表格' . $key . '值填写有误,系统中未找到"' . $value . '"');
-                        }
-                    }
-                    $result[$resultKey] = $tempArray[$tempResultIndex]['id'];
-                } elseif ($formFieldArr[$key]['index'] === 'bonusWalletType') {
-                    $nationsArray = array_column($tempArray, 'name');
-                    $tempResultIndex = array_search($value, $nationsArray);
-                    if ($tempResultIndex === false){
-                        if($errTableField = array_search($key, $excelTableField)){
-                            throw new Exception('序号' . $sort . '的表格【' . $errTableField . '】值填写有误,系统中未找到填写的"' . $value . '"');
-                        }else{
-                            throw new Exception('序号' . $sort . '的表格' . $key . '值填写有误,系统中未找到"' . $value . '"');
-                        }
-                    }
-                    $result[$resultKey] = $nationsArray[$tempResultIndex];
-                }
-            } elseif ($formFieldArr[$key]['type'] === 'table') {
-                // 从数据库中获取对应的参数值
-                $db = $formFieldArr[$key]['db'] ?? 'db';
-                $field = $formFieldArr[$key]['field'];
-                $select = $formFieldArr[$key]['select'];
-                $table = $formFieldArr[$key]['table'];
-                $where = $field . '=:' . $field;
-                $where .= (isset($formFieldArr[$key]['where']) && $formFieldArr[$key]['where']) ? ' AND ' . $formFieldArr[$key]['where'] : '';
-                $bindValues = [$field => $value];
-                $tempResult = \Yii::$app->$db->createCommand("SELECT $select FROM {{%$table}} WHERE $where")->bindValues($bindValues)->queryOne();
-                if (!$tempResult){
-                    if($errTableField = array_search($key, $excelTableField)){
-                        throw new Exception('序号' . $sort . '的表格【' . $errTableField . '】值填写有误,系统中未找到填写的"' . $value . '"');
-                    }else{
-                        throw new Exception('序号' . $sort . '的表格' . $key . '值填写有误,系统中未找到"' . $value . '"');
-                    }
-                }
-                if (isset($formFieldArr[$key]['isArray']) && $formFieldArr[$key]['isArray']) {
-                    $result[$resultKey][] = $tempResult[$select];
-                } else {
-                    $result[$resultKey] = $tempResult[$select];
-                }
-
-            }
-        }
-        return $result;
-    }
-
-    /**
-     * 分页导入数据
-     * @param $excelStructureKey
-     * @param $excelImportId
-     * @param int $rowCount
-     * @param int $startRow
-     * @param int $limit
-     * @param int $orderDay
-     * @param int $orderType
-     * @return int
-     * @throws Exception
-     */
-    public function pageImportCustomDataFromExcel($excelStructureKey, $excelImportId, $rowCount, $startRow, $limit, $orderDay, $orderType = 'cash') {
-        if ($startRow > 1) {
-            $startRow = $startRow + 1;
-            $limit = $limit - 1;
-        }
-        $fileNameArray = ExcelImport::find()->select('U.FILE_NAME')->from(ExcelImport::tableName() . ' AS ET')->join('LEFT JOIN', Uploads::tableName() . ' AS U', 'ET.UPLOAD_ID=U.ID')->where('ET.ID=:ID', [':ID' => $excelImportId])->asArray()->one();
-        $filePath = \Yii::getAlias('@common/runtime/uploads/' . $fileNameArray['FILE_NAME']);
-        if ($startRow > $rowCount) {
-            return 0;
-        }
-        try {
-            // 临时文件不存在则创建
-            $tempFileName = \Yii::getAlias('@common/runtime/uploads/' . 'import'.$excelStructureKey.'Temp.txt');
-            if (!file_exists($tempFileName)) {
-                $fp = fopen($tempFileName, 'w+');
-                fclose($fp);
-            } else {
-                if ($startRow == 1) {
-                    file_put_contents($tempFileName, '');
-                }
-            }
-            $data = \sunmoon\phpspreadsheet\Excel::import($filePath, [
-                'setFirstRecordAsKeys' => true,
-                'readStartRow' => $startRow,
-                'readEndRow' => $startRow + $limit,
-                'storeFile' => $tempFileName,
-                'dropKeysRow' => $startRow == 1 ? false : true,
-            ]);
-        } catch (\Exception $e) {
-            throw new Exception($e->getMessage());
-        }
-        self::filterData($data);
-
-
-        if ($data) {
-            $tableClass = self::EXCEL_STRUCTURE[$excelStructureKey]['excelTableClass'];
-            $tableAction = self::EXCEL_STRUCTURE[$excelStructureKey]['excelTableAction'];
-            $form = new $tableClass();
-            if (!$form->$tableAction($data,$orderDay,$orderType)) {
-                return 0;
-            }
-            return 1;
-        } else {
-            return 0;
-        }
-    }
-
-    /**
-     * 分页导入数据
-     * @param string $fileName
-     * @param int $rowCount
-     * @param int $startRow
-     * @param int $limit
-     * @return array
-     * @throws Exception
-     */
-    public function pageImportDataByExcelFile($fileName, $rowCount = 1000, $startRow = 1, $limit = 1000) {
-        if ($startRow > 1) {
-            $startRow = $startRow + 1;
-            $limit = $limit - 1;
-        }
-        $filePath = \Yii::getAlias('@common/runtime/uploads/' . $fileName);
-        if ($startRow > $rowCount) {
-            return [];
-        }
-        try {
-            // 临时文件不存在则创建
-            $tempFileName = \Yii::getAlias('@common/runtime/uploads/' . 'importTemp.txt');
-            if (!file_exists($tempFileName)) {
-                $fp = fopen($tempFileName, 'w+');
-                fclose($fp);
-            } else {
-                if ($startRow == 1) {
-                    file_put_contents($tempFileName, '');
-                }
-            }
-            $data = \sunmoon\phpspreadsheet\Excel::import($filePath, [
-                'setFirstRecordAsKeys' => true,
-                'readStartRow' => $startRow,
-                'readEndRow' => $startRow + $limit,
-                'storeFile' => $tempFileName,
-                'dropKeysRow' => $startRow == 1 ? false : true,
-            ]);
-        } catch (\Exception $e) {
-            throw new Exception($e->getMessage());
-        }
-        self::filterData($data);
-
-
-        if ($data) {
-            return $data;
-        } else {
-            return [];
-        }
-    }
-
-}

+ 1 - 1
common/helpers/Level.php

@@ -1,6 +1,6 @@
 <?php
+
 /**
- * 级别管理类
  * Created by PhpStorm.
  * User: leo
  * Date: 2018/3/19

+ 0 - 122
common/helpers/Log.php

@@ -8,132 +8,10 @@
 
 namespace common\helpers;
 
-use common\models\LogAdminHandle;
-use common\models\LogAdminLogin;
-use common\models\LogApiNotice;
-use common\models\LogAsync;
-use common\models\Period;
 use Yii;
-use yii\helpers\Json;
 
 class Log
 {
-    /**
-     * 管理员操作日志
-     * @param $message
-     * @param int $isKey
-     * @param null $userId
-     * @param null $userName
-     * @param null $remark
-     */
-    public static function adminHandle($message, $isKey = 0, $userId = null, $userName = null, $remark = null){
-        if(Yii::$app->params['enableLog']){
-            $period = Period::instance();
-            $deviceInfo = Yii::$app->request->getDeviceInfo();
-            $userInfo = Yii::$app->user->getUserInfo();
-            $model = new LogAdminHandle();
-            $model->ADMIN_ID = $userInfo['id'];
-            $model->ADMIN_NAME = $userInfo['adminName'];
-            $model->IP = $userInfo['ip'];
-            $model->REQUEST_ROUTE = Yii::$app->controller->id.'/'.Yii::$app->controller->action->id;
-            $model->OPT_CONTENT = $message;
-            $model->KEY_LOG = $isKey;
-            $model->OPT_OBJ_ID = $userId;
-            $model->OPT_OBJ_NAME = $userName;
-            $model->REMARK = $remark;
-            $model->DEVICE_TYPE = Yii::$app->request->getDevice();
-            $model->DEVICE_SYSTEM = $deviceInfo ? $deviceInfo['system'] : null;
-            $model->DEVICE_VERSION = $deviceInfo ? $deviceInfo['version'] : null;
-            $model->DEVICE_NET = $deviceInfo ? $deviceInfo['networkType'] : null;
-            $model->DEVICE_UUID = $deviceInfo ? $deviceInfo['uuid'] : null;
-            $model->USER_AGENT = Yii::$app->request->getUserAgent();
-            $model->P_MONTH = Date::ociToDate();
-            $model->CREATED_AT = Date::nowTime();
-            $model->PERIOD_NUM = $period->getNowPeriodNum();
-            $model->save();
-        }
-    }
-
-    /**
-     * 管理员登录日志
-     */
-    public static function adminLogin(){
-        if(Yii::$app->params['enableLog']) {
-            $period = Period::instance();
-            $userInfo = Yii::$app->user->getUserInfo();
-            $deviceInfo = Yii::$app->request->getDeviceInfo();
-            $model = new LogAdminLogin();
-            $model->ADMIN_ID = $userInfo['id'];
-            $model->ADMIN_NAME = $userInfo['adminName'];
-            $model->IP = $userInfo['ip'];
-            $model->P_MONTH = Date::ociToDate();
-            $model->DEVICE_TYPE = Yii::$app->request->getDevice();
-            $model->DEVICE_SYSTEM = $deviceInfo ? $deviceInfo['system'] : null;
-            $model->DEVICE_VERSION = $deviceInfo ? $deviceInfo['version'] : null;
-            $model->DEVICE_NET = $deviceInfo ? $deviceInfo['networkType'] : null;
-            $model->DEVICE_UUID = $deviceInfo ? $deviceInfo['uuid'] : null;
-            $model->USER_AGENT = Yii::$app->request->getUserAgent();
-            $model->CREATED_AT = Date::nowTime();
-            $model->PERIOD_NUM = $period->getNowPeriodNum();
-            $model->save();
-        }
-    }
-
-    /**
-     * 接口异步通知日志
-     * @param $param
-     */
-    public static function apiNotice($param){
-        if(Yii::$app->params['enableLog']) {
-            [
-                'url' => $url,
-                'method' => $method,
-                'data' => $data,
-                'route' => $route,
-                'status' => $status,
-                'response' => $response,
-                'remark' => $remark,
-            ] = $param;
-            $model = new LogApiNotice();
-            $model->URL = $url;
-            $model->METHOD = $method;
-            $model->DATA = Json::encode($data);
-            $model->ROUTE = $route;
-            $model->STATUS = $status;
-            $model->RESPONSE = Json::encode($response);
-            $model->REMARK = $remark;
-            $model->P_MONTH = Date::ociToDate();
-            $model->CREATED_AT = Date::nowTime();
-            $model->save();
-        }
-    }
-
-    /**
-     * console中异步任务的执行日志
-     * @param $param
-     */
-    public static function async($param){
-//        file_put_contents(Yii::getAlias('@common/runtime/logs/asyncLog.log'), var_export($param, true));
-        if(Yii::$app->params['enableLog']) {
-            [
-                'type' => $type,
-                'route' => $route,
-                'title' => $title,
-                'detail' => $detail,
-                'status' => $status,
-            ] = $param;
-            $model = new LogAsync();
-            $model->TYPE = $type;
-            $model->ROUTE = $route;
-            $model->TITLE = $title;
-            $model->DETAIL = $detail;
-            $model->STATUS = $status;
-            $model->P_MONTH = Date::ociToDate();
-            $model->CREATED_AT = Date::nowTime();
-            $model->save();
-        }
-    }
-
     /**
      * 文件日志
      * @param $message

+ 0 - 582
common/helpers/NetPoint.php

@@ -1,582 +0,0 @@
-<?php
-/**
- * Created by PhpStorm.
- * User: leo
- * Date: 2018/4/28
- * Time: 下午6:38
- */
-
-namespace common\helpers;
-use common\components\ActiveRecord;
-use common\helpers\user\Info;
-use common\models\PerfMonth;
-use common\models\PerfPeriod;
-use common\models\Period;
-use common\models\DecOrder;
-use common\models\User;
-use common\models\UserInfo;
-use common\models\UserMove;
-use common\models\UserNetwork;
-use common\models\UserPerf;
-use common\models\UserRelation;
-use common\models\UserSystem;
-use yii\base\BaseObject;
-use yii\base\Exception;
-use yii\base\StaticInstanceTrait;
-use yii\db\Expression;
-use yii\helpers\Json;
-
-/**
- * Class NetPoint
- * 网络接点关系调整类
- * 1、点位A从点位B移动到点位C,首先寻找公共接点人,把非公共的点位全部删掉
- * 2、循环把自己和自己的所有下级相对这个公共点位的都修改深度+变化的深度,修改区域为点位A到点位C后相应的区位。
- * 3、循环查找会员移动到点位C后,所有的点位C及C的上级,并会员A及A的下级,都添加这些上级数据。
- * 4、修改user_info表,的接点人
- * @package common\helpers
- */
-class NetPoint extends BaseObject
-{
-    const NET_TYPE_NETWORK = 'network';
-    const NET_TYPE_RELATION = 'relation';
-
-    const REDIS_KEY_PREFIX_CHILD_USER = 'moveNetChildUser:NetType_%s:moveUserId_%s';
-
-    private $_limit = 100;
-    private $_errors = [];
-    private $_moveInfo;
-    public $moveId;
-    private $_moveUserId;
-    private $_moveUserInfo;
-    private $_toConUserId;
-    private $_toConUserInfo;
-    private $_fromConUserId;
-    private $_fromConUserInfo;
-    private $_fromLocation;
-    private $_location;
-    private $_commonParentUserId = null;
-    private $_commonDeepDiff;
-    //private $_commonNewParentLocation;
-    private $_tempCalcDeep = 0;
-    private $_isContinueFindParent = true; // 用于往上找父级,找到公共节点就不在找了
-
-    public static function factory($moveId) {
-        return new self([
-                'moveId' => $moveId
-            ]
-        );
-    }
-
-    public function init()
-    {
-        parent::init();
-    }
-
-    /**
-     * 加入错误错误
-     * @param $attr
-     * @param $error
-     */
-    public function addError($attr, $error){
-        $this->_errors[$attr][] = $error;
-    }
-
-    /**
-     * 获取错误信息
-     * @return array
-     */
-    public function getErrors(){
-        return $this->_errors;
-    }
-
-    /**
-     * 初始化移动
-     * @param $netType
-     * @param $moveUserId
-     * @param $toConUserId
-     * @param int $location
-     * @param int $fromLocation
-     * @throws \Exception
-     */
-    public function initMove($netType, $moveUserId, $toConUserId, $location=0, $fromLocation = 0){
-        $this->_moveInfo = UserMove::findOneAsArray(['ID'=>$this->moveId]);
-        $this->_moveUserId = $moveUserId;
-        $this->_moveUserInfo = Info::baseInfo($moveUserId);
-        if($netType == self::NET_TYPE_NETWORK){
-            $this->_fromConUserId = $this->_moveUserInfo['CON_UID'];
-        } else {
-            $this->_fromConUserId = $this->_moveUserInfo['REC_UID'];
-        }
-//        $this->_fromConUserInfo = UserInfo::findOneAsArray(['USER_ID'=>$this->_fromConUserId]);
-        $this->_toConUserId = $toConUserId;
-//        $this->_toConUserInfo = UserInfo::findOneAsArray(['USER_ID'=>$this->_toConUserId]);
-        $this->_location = $location;
-        $this->_fromLocation = $fromLocation;
-        $this->_errors = [];
-        $this->_clearChildUserFromRedis($netType);
-        $this->allChildUserToRedisList($netType);
-    }
-
-    /**
-     * 移动安置网络节点
-     * @param $moveUserId
-     * @param $toConUserId
-     * @param $location
-     * @param $fromLocation
-     * @return bool
-     * @throws \Exception
-     */
-    public function moveNetworkPoint($moveUserId, $toConUserId, $location, $fromLocation){
-        return $this->movePoint(self::NET_TYPE_NETWORK, $moveUserId, $toConUserId, $location, $fromLocation);
-    }
-
-    /**
-     * 移动开拓网络节点
-     * @param $moveUserId
-     * @param $toConUserId
-     * @return bool
-     * @throws \Exception
-     */
-    public function moveRelationPoint($moveUserId, $toConUserId){
-        return $this->movePoint(self::NET_TYPE_RELATION, $moveUserId, $toConUserId);
-    }
-
-    /**
-     * 移网
-     * @param $netType
-     * @param $moveUserId
-     * @param $toConUserId
-     * @param int $location
-     * @param int $fromLocation
-     * @return bool
-     * @throws \Exception
-     */
-    public function movePoint($netType, $moveUserId, $toConUserId, $location=0, $fromLocation = 0){
-        $transaction = \Yii::$app->db->beginTransaction();
-        try {
-            $this->initMove($netType, $moveUserId, $toConUserId, $location, $fromLocation);
-            echo sprintf("时间:[%s],用户ID:[%s]移网,初始化成功".PHP_EOL, date('Y-m-d H:i:s', time()), $moveUserId);
-
-            //修改移动会员以及子会员的深度、父ID、以及网体标记等
-            $this->_moveParentAndChildren($netType);
-            // 把userInfo表的数据也改掉
-            if($netType == self::NET_TYPE_NETWORK){
-                $conNumField = 'CON_NUM';
-            } else {
-                $conNumField = 'REC_NUM';
-            }
-            // 原上级接点数量减少,新上级接点数量增加
-            UserInfo::updateAllCounters([$conNumField => -1], 'USER_ID=:USER_ID', [':USER_ID'=>$this->_fromConUserId]);
-            UserInfo::updateAllCounters([$conNumField =>1], 'USER_ID=:USER_ID', [':USER_ID'=>$this->_toConUserId]);
-            // 清除redis
-            if ($netType == self::NET_TYPE_NETWORK) {
-                \Yii::$app->redis->del(Cache::USER_NETWORK_PARENTS);
-            } else {
-                \Yii::$app->redis->del(Cache::USER_RELATION_PARENTS);
-            }
-
-            $this->_endHandle();
-            $transaction->commit();
-        } catch (\Exception $e){
-            echo $e->getMessage() . PHP_EOL;
-            $transaction->rollBack();
-            $this->_errorHandle();
-            $this->addError($netType, $e->getMessage());
-            $this->_clearChildUserFromRedis($netType);
-            return false;
-        }
-
-        $this->_clearChildUserFromRedis($netType);
-        return true;
-    }
-
-    /**
-     * 删除备份的表
-     */
-    public function dropBakTable(){
-        $oneMove = $this->_moveInfo;
-        $createTableName =  $oneMove['NET_TABLE_NAME'];
-        if(ActiveRecord::isExistsTable('{{%'.$createTableName.'}}', 'dbNetPoint')){
-            ActiveRecord::deleteTable($createTableName, 'dbNetPoint');
-        }
-    }
-
-    /**
-     * 把所有子会员数据存入缓存中
-     * @param $netType
-     * @return bool
-     */
-    public function allChildUserToRedisList($netType){
-        return $this->_getChildUserToRedis($this->_moveUserId, $netType);
-    }
-
-    private function _getChildUserToRedis($parentUid, $netType) {
-        if($netType == self::NET_TYPE_NETWORK){
-            $field = 'CON_UID';
-        } else {
-            $field = 'REC_UID';
-        }
-        $childList = UserInfo::find()->select(['USER_ID'])->where("{$field}=:PARENT_UID", ['PARENT_UID'=>$parentUid])->asArray()->all();
-        if( !$childList ) {
-            unset($childList, $field, $parentUid, $netType);
-            return true;
-        }
-        foreach ($childList as $child) {
-            // 会员ID加入缓存
-            $this->_addChildUserToRedis($netType, $child['USER_ID']);
-
-            $this->_getChildUserToRedis($child['USER_ID'], $netType);
-        }
-
-        unset($childList, $field, $parentUid, $netType, $child);
-        return true;
-    }
-
-    /**
-     * 循环删除子节点对应的非公共节点的数据
-     * @param $netType
-     * @param $parentUserId
-     * @param int $offset
-     */
-    public function _loopChildDelUnCommonParent($netType, $parentUserId, int $offset=0){
-        // 分页从缓存中获取子会员
-        $allData = $this->_getChildUserFromRedis($netType, $offset, $this->_limit);
-        if($allData){
-            foreach($allData as $childUserId){
-                $modelClass = self::getModelClass($netType);
-                $modelClass::deleteAll('PARENT_UID=:PARENT_UID AND USER_ID=:USER_ID', [':PARENT_UID'=>$parentUserId, ':USER_ID'=>$childUserId]);
-            }
-            unset($allData);
-            $this->_loopChildDelUnCommonParent($netType, $parentUserId, $offset + $this->_limit);
-        }
-    }
-
-
-    /**
-     * 把移动的会员及子会员加入到直接新上级的节点数据
-     * @param $netType
-     */
-    private function _moveParentAndChildren($netType){
-        $modelClass = self::getModelClass($netType);
-        // 获取一条新上级的网络数据
-        $fromData = $modelClass::find()->where('USER_ID=:USER_ID', [':USER_ID'=>$this->_moveUserId])->asArray()->one();
-        $toParentData = $modelClass::find()->where('USER_ID=:USER_ID', [':USER_ID'=>$this->_toConUserId])->asArray()->one();
-
-        if( $toParentData['PARENT_UIDS'] ) {
-            $updateParentUids = $toParentData['PARENT_UIDS'] . ',' . $this->_toConUserId;
-        }else {
-            $updateParentUids = $this->_toConUserId;
-        }
-
-        $updateData = [
-            'PARENT_UID' => $this->_toConUserId,
-            'PARENT_UIDS' => $updateParentUids,
-            'TOP_UID' => $toParentData['TOP_UID'],
-            'TOP_DEEP' => $toParentData['TOP_DEEP'] + 1,
-            'UPDATED_AT' => Date::nowTime(),
-        ];
-        if($netType == self::NET_TYPE_NETWORK){
-            $updateData['RELATIVE_LOCATION'] = $this->_location;
-            $updateData['LOCATION_TAG'] = $toParentData['LOCATION_TAG'] . $this->_location;
-        }
-        $modelClass::updateAll($updateData, 'USER_ID=:USER_ID', [
-            'USER_ID' => $this->_moveUserId
-        ]);
-        unset($modelClass, $toParentData, $updateParentUids);
-
-        if($netType == self::NET_TYPE_NETWORK){
-            $conField = 'CON_UID';
-        } else {
-            $conField = 'REC_UID';
-        }
-        UserInfo::updateAll([
-            $conField => $this->_toConUserId,
-            strtoupper($netType).'_DEEP' => $updateData['TOP_DEEP'],
-        ], 'USER_ID=:USER_ID', [':USER_ID'=>$this->_moveUserId]);
-
-        $this->_updatePercent(30);
-
-        // 把子会员也更新、准备公共子会员需要的信息
-        $commonParentData = [
-            'toConUserId' => $this->_toConUserId,
-            'topUserId' => $updateData['TOP_UID'],
-            'commonDiffDeep' => $updateData['TOP_DEEP'] - $fromData['TOP_DEEP'],
-            'oldParentUids' => $fromData['PARENT_UIDS'],
-            'newParentUids' => $updateData['PARENT_UIDS'],
-        ];
-        if($netType == self::NET_TYPE_NETWORK){
-            $commonParentData['oldParentLocationTag'] = $fromData['LOCATION_TAG'];
-            $commonParentData['newParentLocationTag'] = $updateData['LOCATION_TAG'];
-        }
-        unset($fromData, $updateData);
-
-        $this->_updateChildData($netType, $commonParentData);
-
-        $this->_changeNetPerfData($netType, $commonParentData);
-
-        unset($netType, $commonParentData);
-    }
-
-    /**
-     * 分页循环给子会员增加相较于上级的数据
-     * @param $netType
-     * @param $params
-     *       [
-     *       'toConUserId' => $this->_toConUserId,
-     *       'topUserId' => $updateData['TOP_UID'],
-     *       'commonDiffDeep' => $updateData['TOP_DEEP'] - $fromData['TOP_DEEP'],
-     *       'oldParentUids' => $fromData['PARENT_UIDS'],
-     *       'newParentUids' => $updateData['PARENT_UIDS'],
-     *       ]
-     * @param int $offset
-     */
-    private function _updateChildData($netType, $params, int $offset = 0){
-        // 分页获取要移动的会员的子会员
-        $allData = $this->_getChildUserFromRedis($netType, $offset, $this->_limit);
-        if($allData){
-            $modelClass = self::getModelClass($netType);
-            foreach($allData as $childUserId){
-                $childData = $modelClass::find()->where('USER_ID=:USER_ID', [':USER_ID'=>$childUserId])->asArray()->one();
-                //原PARENT_UIDS、新PARENT_UIDS
-                $childParentUids = substr($childData['PARENT_UIDS'], strlen($params['oldParentUids']));
-                $childUpdateData = [
-                    'PARENT_UIDS' => $params['newParentUids'] . $childParentUids,//不变
-                    'TOP_UID' => $params['topUserId'],//和父的保持一致
-                    'TOP_DEEP' => $childData['TOP_DEEP'] + $params['commonDiffDeep'],//所有子会员变化深度一致
-                    'UPDATED_AT' => Date::nowTime(),
-                ];
-                if($netType == self::NET_TYPE_NETWORK){
-                    //RELATIVE_LOCATION不变
-                    //找到moveUser的 原来 locationTag 的length
-                    $childLocationTag = substr($childData['LOCATION_TAG'], strlen($params['oldParentLocationTag']));
-                    $childUpdateData['LOCATION_TAG'] = $params['newParentLocationTag'] . $childLocationTag;
-                    unset($childLocationTag);
-                }
-
-                $modelClass::updateAll($childUpdateData, 'USER_ID=:USER_ID', [
-                    'USER_ID' => $childUserId
-                ]);
-                UserInfo::updateAll([
-                    strtoupper($netType).'_DEEP' => $childUpdateData['TOP_DEEP'],
-                ], 'USER_ID=:USER_ID', [':USER_ID'=>$childUserId]);
-
-                unset($childUserId, $childData, $childParentUids, $childUpdateData);
-            }
-
-            unset($allData, $modelClass);
-            return $this->_updateChildData($netType, $params, $offset + $this->_limit);
-        }
-
-        unset($allData);
-        return true;
-    }
-
-    /**
-     * 移网业绩数据处理
-     * @param $netType
-     * @param $commonData
-     * @return bool
-     */
-    private function _changeNetPerfData($netType, $commonData) {
-        //获取未结算的月份
-        $noSentPeriod = Period::find()->where('IS_SENT=0')->orderBy('PERIOD_NUM ASC')->asArray()->one();
-        if( !$noSentPeriod ) return false;
-
-        $thisYearMonth = $noSentPeriod['CALC_YEAR'].Tool::numFix($noSentPeriod['CALC_MONTH'], 2);
-//        $lastYearMonth = Date::lastMonth($noSentPeriod['CALC_YEAR'].'-'.$noSentPeriod['CALC_MONTH'], 'Ym');
-        $thisYearMonthPerf=[];
-        if( $noSentPeriod['IS_MONTH'] == 1 ) {
-            $thisYearMonthPerf =  PerfMonth::find()->where('USER_ID=:USER_ID AND CALC_MONTH=:CALC_MONTH', ['USER_ID'=>$this->_moveUserId, 'CALC_MONTH'=>$thisYearMonth])->asArray()->one();
-        }
-        unset($noSentPeriod);
-        //查找移动点位这个人的上个月的累计业绩
-//        $lastYearMonthPerf = PerfMonth::find()->where('USER_ID=:USER_ID AND CALC_MONTH=:CALC_MONTH', ['USER_ID'=>$this->_moveUserId, 'CALC_MONTH'=>$lastYearMonth])->asArray()->one();
-        //本月的已结算业绩
-        $thisPerfPeriodList = PerfPeriod::find()->select(['PV_PCS', 'PV_PSS', 'PERIOD_NUM'])->where('USER_ID=:USER_ID AND CALC_MONTH=:CALC_MONTH', ['USER_ID'=>$this->_moveUserId, 'CALC_MONTH'=>$thisYearMonth])->asArray()->all();
-
-        //总的pss_total
-        $userPerf = UserPerf::find()->where('USER_ID=:USER_ID', ['USER_ID'=>$this->_moveUserId])->asArray()->one();
-
-        $oldParentUids = $commonData['oldParentUids'] ? explode(',', $commonData['oldParentUids']) : [];
-        $newParentUids = $commonData['newParentUids'] ? explode(',', $commonData['newParentUids']) : [];
-        if( $netType === self::NET_TYPE_RELATION ) {
-            //修改上个月的累计业绩
-//            if( $lastYearMonthPerf ) {
-//                $lastYearMonthPssTotal = $lastYearMonthPerf['PV_PCS'] + $lastYearMonthPerf['PV_PSS_TOTAL'];
-//                $lastYearMonthPss = $lastYearMonthPerf['PV_PCS'] + $lastYearMonthPerf['PV_PSS'];
-//                foreach ($oldParentUids as $oldParentUid) {//减
-//                    PerfMonth::updateAllCounters(['PV_PSS'=>(-1)*$lastYearMonthPss, 'PV_PSS_TOTAL'=>(-1)*$lastYearMonthPssTotal], 'USER_ID=:USER_ID AND CALC_MONTH=:CALC_MONTH', ['USER_ID'=>$oldParentUid, 'CALC_MONTH'=>$lastYearMonth]);
-//                    unset($oldParentUid);
-//                }
-//                foreach ($newParentUids as $newParentUid) {//加
-//                    PerfMonth::updateAllCounters(['PV_PSS'=>$lastYearMonthPss, 'PV_PSS_TOTAL'=>$lastYearMonthPssTotal], 'USER_ID=:USER_ID AND CALC_MONTH=:CALC_MONTH', ['USER_ID'=>$newParentUid, 'CALC_MONTH'=>$lastYearMonth]);
-//                    unset($newParentUid);
-//                }
-//                unset($lastYearMonthPssTotal, $lastYearMonthPss);
-//            }
-//            unset($lastYearMonthPerf, $lastYearMonth);
-
-            //修改本月的累计业绩
-            if( $thisYearMonthPerf ) {
-                $thisYearMonthPssTotal = $thisYearMonthPerf['PV_PCS'] + $thisYearMonthPerf['PV_PSS_TOTAL'];
-                $thisYearMonthPss = $thisYearMonthPerf['PV_PCS'] + $thisYearMonthPerf['PV_PSS'];
-                foreach ($oldParentUids as $oldParentUid) {//减
-                    $parentThisYearMonthPerf =  PerfMonth::find()->where('USER_ID=:USER_ID AND CALC_MONTH=:CALC_MONTH', ['USER_ID'=>$oldParentUid, 'CALC_MONTH'=>$thisYearMonth])->asArray()->one();
-                    if( $parentThisYearMonthPerf ) {
-                        if( $parentThisYearMonthPerf['PV_PSS_TOTAL'] < $thisYearMonthPssTotal ) {
-                            PerfMonth::updateAll(['PV_PSS'=>(-1)*$thisYearMonthPss, 'PV_PSS_TOTAL'=>0], 'USER_ID=:USER_ID AND CALC_MONTH=:CALC_MONTH', ['USER_ID'=>$oldParentUid, 'CALC_MONTH'=>$thisYearMonth]);
-                        }else {
-                            PerfMonth::updateAllCounters(['PV_PSS'=>(-1)*$thisYearMonthPss, 'PV_PSS_TOTAL'=>(-1)*$thisYearMonthPssTotal], 'USER_ID=:USER_ID AND CALC_MONTH=:CALC_MONTH', ['USER_ID'=>$oldParentUid, 'CALC_MONTH'=>$thisYearMonth]);
-
-                        }
-                    }
-                    unset($oldParentUid, $parentThisYearMonthPerf);
-                }
-                foreach ($newParentUids as $newParentUid) {//加
-                    PerfMonth::updateAllCounters(['PV_PSS'=>$thisYearMonthPss, 'PV_PSS_TOTAL'=>$thisYearMonthPssTotal], 'USER_ID=:USER_ID AND CALC_MONTH=:CALC_MONTH', ['USER_ID'=>$newParentUid, 'CALC_MONTH'=>$thisYearMonth]);
-                    unset($newParentUid);
-                }
-                unset($thisYearMonthPssTotal, $thisYearMonthPss);
-            }
-            unset($thisYearMonthPerf);
-
-            //修改本月的已结算业绩
-            foreach ($thisPerfPeriodList as $periodPerf) {
-                $periodPss = $periodPerf['PV_PCS'] + $periodPerf['PV_PSS'];
-                if( $periodPss <= 0 ) continue;
-
-                foreach ($oldParentUids as $oldParentUid) {//减
-                    PerfPeriod::updateAllCounters(['PV_PSS'=>(-1)*$periodPss], 'USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM', ['USER_ID'=>$oldParentUid, 'PERIOD_NUM'=>$periodPerf['PERIOD_NUM']]);
-                    unset($oldParentUid);
-                }
-                foreach ($newParentUids as $newParentUid) {//加
-                    PerfPeriod::updateAllCounters(['PV_PSS'=>$periodPss], 'USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM', ['USER_ID'=>$newParentUid, 'PERIOD_NUM'=>$periodPerf['PERIOD_NUM']]);
-                    unset($newParentUid);
-                }
-
-                unset($periodPerf, $periodPss);
-            }
-            unset($thisPerfPeriodList, $thisYearMonth);
-
-            if( $userPerf ) {
-                $userPerfPss = $userPerf['PV_PCS_ZC'] + $userPerf['PV_PCS_FX'] + $userPerf['PV_PSS'];
-                $userPerfPssTotal = $userPerf['PV_PCS_ZC'] + $userPerf['PV_PCS_FX'] + $userPerf['PV_PSS_TOTAL'];
-                foreach ($oldParentUids as $oldParentUid) {//减
-                    $parentPerf = UserPerf::find()->where('USER_ID=:USER_ID', ['USER_ID'=>$oldParentUid])->asArray()->one();
-                    if( $parentPerf ) {
-                        if( $parentPerf['PV_PSS_TOTAL'] < $userPerfPssTotal ) {
-                            UserPerf::updateAll(['PV_PSS'=>0, 'PV_PSS_TOTAL'=>0], 'USER_ID=:USER_ID', ['USER_ID'=>$oldParentUid]);
-                        }else {
-                            UserPerf::updateAllCounters(['PV_PSS'=>(-1)*$userPerfPss, 'PV_PSS_TOTAL'=>(-1)*$userPerfPssTotal], 'USER_ID=:USER_ID', ['USER_ID'=>$oldParentUid]);
-                        }
-                    }
-                    unset($oldParentUid, $parentPerf);
-                }
-                foreach ($newParentUids as $newParentUid) {//加
-                    UserPerf::updateAllCounters(['PV_PSS'=>$userPerfPss, 'PV_PSS_TOTAL'=>$userPerfPssTotal], 'USER_ID=:USER_ID', ['USER_ID'=>$newParentUid]);
-                    unset($newParentUid);
-                }
-                unset($userPerfPss, $userPerfPssTotal);
-            }
-            unset($userPerf);
-
-        }
-
-        if( $netType === self::NET_TYPE_NETWORK ) {
-            //@todo 团队奖相关的,对碰往期对碰剩余业绩是否修改
-        }
-
-        unset($oldParentUids, $newParentUids);
-
-    }
-
-    /**
-     * 结束操作
-     * @throws Exception
-     */
-    private function _endHandle(){
-        // 把移网申请记录的正在移网状态修改
-        $oneMove = UserMove::findOne(['ID'=>$this->moveId]);
-        $oneMove->IS_MOVING = 0;
-        $oneMove->AUDIT_STATUS = \Yii::$app->params['auditStatus']['true']['value'];
-        $oneMove->ENDED_AT = Date::nowTime();
-        if(!$oneMove->save()){
-            throw new Exception(Form::formatErrorsForApi($oneMove->getErrors()));
-        }
-        $this->_updatePercent(100);
-    }
-
-    /**
-     * 错误的时候,把移网状态改回原状
-     */
-    private function _errorHandle(){
-        // 把移网的审核状态回归
-        $oneMove = UserMove::findOne(['ID'=>$this->moveId]);
-        $oneMove->IS_MOVING = 0;
-        $oneMove->AUDIT_ADMIN_ID = null;
-        $oneMove->AUDITED_AT = 0;
-        $oneMove->AUDIT_STATUS = \Yii::$app->params['auditStatus']['false']['value'];
-        $oneMove->save();
-        // 删除创建的表
-        $this->dropBakTable();
-        $this->_updatePercent(0);
-    }
-
-    /**
-     * 更新百分比并发送
-     * @param $percent
-     */
-    private function _updatePercent($percent){
-        // 把数据写入数据库中
-        UserMove::updateAll(['MOVE_PERCENT'=>$percent], 'ID=:ID', [':ID'=>$this->moveId]);
-        \Yii::$app->swooleAsyncTimer->pushAsyncPercentToAdmin($percent, ['MODEL' => 'USER_MOVE' ,'ID' => $this->moveId, 'FIELD' => 'MOVE_PERCENT']);
-    }
-
-    /**
-     * 把子会员存入到缓存中
-     * @param $netType
-     * @param $userId
-     */
-    private function _addChildUserToRedis($netType, $userId){
-        $cacheKey = sprintf(self::REDIS_KEY_PREFIX_CHILD_USER, $netType, $this->_moveUserId);
-        \Yii::$app->redis->rpush($cacheKey, $userId);
-    }
-
-    /**
-     * 从缓存中获取子会员数据
-     * @param $netType
-     * @param $offset
-     * @param $limit
-     * @return mixed
-     */
-    private function _getChildUserFromRedis($netType, $offset, $limit){
-        $cacheKey = sprintf(self::REDIS_KEY_PREFIX_CHILD_USER, $netType, $this->_moveUserId);
-        return \Yii::$app->redis->lrange($cacheKey, $offset, ($offset + $limit - 1));
-    }
-
-    /**
-     * 清空子会员数据从缓存中
-     * @param $netType
-     * @return mixed
-     */
-    private function _clearChildUserFromRedis($netType){
-        $cacheKey = sprintf(self::REDIS_KEY_PREFIX_CHILD_USER, $netType, $this->_moveUserId);
-        return \Yii::$app->redis->del($cacheKey);
-    }
-
-    /**
-     * 获取model类
-     * @param $netType
-     * @return null|string
-     */
-    private static function getModelClass($netType){
-        if($netType == self::NET_TYPE_NETWORK){
-            return UserNetwork::class;
-        } elseif($netType == self::NET_TYPE_RELATION){
-            return UserRelation::class;
-        } else {
-            return null;
-        }
-    }
-
-}

+ 0 - 7
common/helpers/Tool.php

@@ -16,7 +16,6 @@ use yii\httpclient\Client;
 class Tool {
 
     /**
-     * 获取无限级树形分类
      * @param array $cate
      * @param int $pid
      * @param int $level
@@ -72,7 +71,6 @@ class Tool {
     }
 
     /**
-     * 前台业绩格式化
      * @param $perf
      * @param int $auto
      * @param int $zoom
@@ -89,7 +87,6 @@ class Tool {
     }
 
     /**
-     * 格式化结算奖金
      * @param $calcBonus
      * @return string
      */
@@ -98,7 +95,6 @@ class Tool {
     }
 
     /**
-     * 获得文件扩展名
      * @param $file
      * @return string
      */
@@ -108,7 +104,6 @@ class Tool {
     }
 
     /**
-     * 获取文件上传的地址
      * @return string
      */
     public static function getUploadUrl(){
@@ -222,7 +217,6 @@ class Tool {
     }
 
     /**
-     * 替换身份证为隐藏格式
      * @param $str
      * @return null|string|string[]
      */
@@ -231,7 +225,6 @@ class Tool {
     }
 
     /**
-     * 替换银行卡号隐藏格式
      * @param $str
      * @return null|string|string[]
      */

+ 90 - 0
common/helpers/user/Cash.php

@@ -9,9 +9,22 @@
 namespace common\helpers\user;
 
 use common\models\UserWallet;
+use common\libs\lock\RedisLock;
+use common\models\FlowWallet;
+use common\models\Period;
+use yii\base\Exception;
+use yii\db\Expression;
+use common\helpers\Date;
 
 class Cash {
 
+    const INCR_REDUCE = 0;      // 减少
+    const INCR_ADD = 1;         // 增加
+    const INCR_FREEZE = 2;      // 冻结
+    const INCR_UNFREEZE = 3;    // 解冻
+
+    const CASH_BALANCE_LOCK_KEY = 'Cash';
+
     /**
      * @param $userId
      * @return int|mixed
@@ -51,4 +64,81 @@ class Cash {
         $data[$userId]['value'] = '奖金'.self::getAvailableBalance($userId).',现金'.$userWallet['CASH'];
         return $data;
     }
+
+    /**
+     * @param $userId
+     * @param $type
+     * @param $amount
+     * @param array $params
+     * @param bool $allowMinus
+     * @return bool
+     * @throws Exception
+     * @throws \yii\db\Exception
+     */
+    public static function changeUserCash($userId, $type='CASH', $amount, $params = [], $allowMinus = false) {
+        if ($amount == 0) return true;
+        $period = Period::instance();
+        if (!isset($params['PERIOD_NUM'])) {
+            $periodNum = $period->getNowPeriodNum();
+        } else {
+            $periodNum = $params['PERIOD_NUM'];
+        }
+        $calcYearMonth = $period->getYearMonth($periodNum);
+        // redis加锁(防止并发余额数值不准确出错)
+        switch ($type) {
+            case 'CASH':
+                $lockKey = self::CASH_BALANCE_LOCK_KEY . $userId;
+                break;
+            default:
+                throw new Exception('流水类型错误');
+        }
+        if (RedisLock::instance()->lock($lockKey)) {
+            // 改变发奖
+            $paramData = [];
+            $oneUserBonusModel = UserWallet::findOne(['USER_ID' => $userId]);
+            if ($oneUserBonusModel) {
+                $paramData[$type] = new Expression($type.' + '.$amount);
+
+                $oneUserBonusModel->$type += $amount;
+                if ($oneUserBonusModel->$type < 0) {
+                    RedisLock::instance()->unlock($lockKey);
+                    throw new Exception('金额不足');
+                }
+                UserWallet::updateAll($paramData, 'USER_ID=:USER_ID', [':USER_ID' => $userId]);
+
+            } else {
+                $paramData = [
+                    'USER_ID'=>$userId,
+                    $type=>$amount,
+                    'UPDATED_AT'=>Date::nowTime()
+                ];
+                UserWallet::insertOne($paramData);
+            }
+
+            unset($oneUserBonusModel,$paramData);
+            $oneUserBonus = UserWallet::find()->where('USER_ID=:USER_ID', [':USER_ID' => $userId])->asArray()->one();
+            // 记录流水
+            $flowInsertData = [
+                'USER_ID' => $userId,
+                'CALC_ID' => $params['CALC_ID'] ?? null,
+                'AMOUNT' => $amount,
+                'TOTAL' => $oneUserBonus[$type],
+                'IS_INCR' => $amount > 0 ? FlowWallet::INCR_ADD : FlowWallet::INCR_REDUCE,
+                'REMARK' => $params['REMARK'] ?? null,
+                'PERIOD_NUM' => $params['PERIOD_NUM'] ?? $periodNum,
+                'CALC_MONTH' => $calcYearMonth,
+                'P_MONTH' => Date::ociToDate(),
+                'CREATED_AT' => $params['TIME'] ?? Date::nowTime(),
+                'ADMIN_NAME' => $params['ADMIN_NAME'] ?? 'system',
+                'SORT' => $params['SORT'] ?? 0,
+                'TRANSFER_SN' => $params['TRANSFER_SN'] ?? '',
+            ];
+            if (strtolower($type) == 'cash') FlowWallet::insertOne($flowInsertData);
+            unset($flowInsertData);
+            RedisLock::instance()->unlock($lockKey);
+        } else {
+            throw new Exception('流水产生错误');
+        }
+        return true;
+    }
 }

+ 0 - 1
common/libs/dataList/DataList.php

@@ -25,7 +25,6 @@ use yii\base\Exception;
  *          'headerOther' => ['width' => '150'],
  *      ],
  *      'IS_DEC' => [
- *          'header' => '是否报单中心',
  *          'value' => function($row) {
  *              return (new YesNo([
  *                  'value' => $row['IS_DEC'],

+ 63 - 63
common/libs/logging/operate/AdminOperate.php

@@ -1,64 +1,64 @@
-<?php
-/**
- * Created by PhpStorm.
- * User: sunmoon<i@liming.me>
- * Date: 2019/07/29
- * Time: 上午9:39
- */
-
-
-namespace common\libs\logging\operate;
-
-use common\models\forms\LogAdminHandleForm;
-use common\models\LogAdminHandle;
-use common\models\Period;
-use Yii;
-use common\helpers\Date;
-
-class AdminOperate extends AbstractOperate {
-    /**
-     * Factory constructor.
-     * @param array $config
-     */
-    public function __construct($config = []) {
-        parent::__construct($config);
-        if(!$this->logModel){
-            $this->logModel = LogAdminHandle::class;
-        }
-        if(!$this->logForm){
-            $this->logForm = LogAdminHandleForm::class;
-        }
-    }
-
-    /**
-     * set column
-     * @param array $params
-     * @return $this|bool
-     * @throws \Exception
-     */
-    public function setColumn(array $params = []){
-        if(!isset($params['optType'])){
-            throw new \Exception('请设置操作类型');
-        }
-        $period = Period::instance();
-        $periodNum = $period->getNowPeriodNum();
-        $this->columns[] = [
-            'user_agent' => Yii::$app->request->getUserAgent(),
-            'created_at' => intval(Date::nowTime()),
-            'period_num' => intval($periodNum),
-            'save_before_content' => $this->saveBeforeContent,
-            'save_after_content' => $this->saveAfterContent,
-            'admin_id' => Yii::$app->user->id,
-            'admin_name' => \Yii::$app->user->getUserInfo()['adminName'],
-            'ip' => Yii::$app->request->getUserIP(),
-            'request_route' => Yii::$app->requestedRoute,
-            'opt_type' => $params['optType'],
-            'opt_obj_id' => isset($params['userId']) ? $params['userId'] : null,
-            'opt_obj_name' => isset($params['userName']) ? $params['userName'] : 'System',
-            'remark' => isset($params['remark']) ? $params['remark'] : null,
-            'is_batch' => $this->_isBatch ? 1 : 0,
-            'device' => Yii::$app->request->getDevice(),
-        ];
-        return $this;
-    }
+<?php
+/**
+ * Created by PhpStorm.
+ * User: sunmoon<i@liming.me>
+ * Date: 2019/07/29
+ * Time: 上午9:39
+ */
+
+
+namespace common\libs\logging\operate;
+
+use common\models\forms\LogAdminHandleForm;
+use common\models\LogAdminHandle;
+use common\models\Period;
+use Yii;
+use common\helpers\Date;
+
+class AdminOperate extends AbstractOperate {
+    /**
+     * Factory constructor.
+     * @param array $config
+     */
+    public function __construct($config = []) {
+        parent::__construct($config);
+        if(!$this->logModel){
+            $this->logModel = LogAdminHandle::class;
+        }
+        if(!$this->logForm){
+            $this->logForm = LogAdminHandleForm::class;
+        }
+    }
+
+    /**
+     * set column
+     * @param array $params
+     * @return $this|bool
+     * @throws \Exception
+     */
+    public function setColumn(array $params = []){
+        if(!isset($params['optType'])){
+            throw new \Exception('请设置操作类型');
+        }
+        $period = Period::instance();
+        $periodNum = $period->getNowPeriodNum();
+        $this->columns[] = [
+            'user_agent' => Yii::$app->request->getUserAgent(),
+            'created_at' => intval(Date::nowTime()),
+            'period_num' => intval($periodNum),
+            'save_before_content' => $this->saveBeforeContent,
+            'save_after_content' => $this->saveAfterContent,
+            'admin_id' => Yii::$app->user->id,
+            'admin_name' => \Yii::$app->user->getUserInfo()['adminName'],
+            'ip' => Yii::$app->request->getUserIP(),
+            'request_route' => Yii::$app->requestedRoute,
+            'opt_type' => $params['optType'],
+            'opt_obj_id' => isset($params['userId']) ? $params['userId'] : null,
+            'opt_obj_name' => isset($params['userName']) ? $params['userName'] : 'System',
+            'remark' => isset($params['remark']) ? $params['remark'] : null,
+            'is_batch' => $this->_isBatch ? 1 : 0,
+            'device' => Yii::$app->request->getDevice(),
+        ];
+        return $this;
+    }
 }

+ 0 - 23
common/libs/logging/operate/valueType/ADMIN.php

@@ -1,23 +0,0 @@
-<?php
-/**
- * Created by PhpStorm.
- * User: sunmoon<i@liming.me>
- * Date: 2019/07/29
- * Time: 上午9:39
- */
-
-namespace common\libs\logging\operate\valueType;
-
-class ADMIN extends AbstractValueType {
-
-    /**
-     * @return mixed|string
-     */
-    public function result(){
-        $value = $this->getValue();
-        $result = \backendApi\modules\v1\models\Admin::findOneAsArray('ID=:ID', [':ID'=>$value], 'ADMIN_NAME');
-        return $result['ADMIN_NAME'];
-    }
-
-
-}

+ 0 - 2
common/libs/taskQueue/Queue.php

@@ -355,6 +355,4 @@ class Queue
             'nextAt' => $nextAt,
         ];
     }
-
-
 }

+ 0 - 31
common/libs/taskQueue/TaskFunc.php

@@ -3,39 +3,8 @@
 
 namespace common\libs\taskQueue;
 
-
-use common\helpers\Cache;
-use common\helpers\Date;
-use common\models\forms\HistoryBonusForm;
-use common\models\TaskQueue;
-use SebastianBergmann\CodeCoverage\Report\PHP;
-
 class TaskFunc
 {
-    /**
-     * 初始化自动备份余额任务
-     */
-    public static function initAutoBakBalance(){
-        // 查看数据库中是否存在未开始的备份奖金表的任务,如果没有就添加一个新任务
-        if(!TaskQueue::find()->where('TYPE=:TYPE AND CONTENT=:CONTENT AND STARTED_AT>:STARTED_AT', [':TYPE'=>Queue::TYPE_FUNC, ':CONTENT'=>TaskFunc::class.'::autoBakBonusTable', ':STARTED_AT'=>Date::nowTime()])->asArray()->exists()){
-            // 获取站点配置中的备份时间
-            $config = Cache::getSystemConfig();
-            $backupWeekDate = (int)$config['backupWeekDate']['VALUE'];
-            $backupTime = (int)$config['backupTime']['VALUE'];
-            Queue::instance()->addTask(Queue::TYPE_FUNC, TaskFunc::class.'::autoBakBonusTable', [], Queue::LOOP_TYPE_WEEK, $backupWeekDate.','.$backupTime.':00', 0);
-        }
-    }
-
-    /**
-     * 自动备份奖金表
-     * @throws \yii\base\InvalidConfigException
-     *
-     */
-    public static function autoBakBonusTable(){
-        $form = new HistoryBonusForm();
-        $form->taskAutoBackup();
-    }
-
     /**
      * 测试队列任务
      */

+ 0 - 64
common/models/forms/SmsTemplateForm.php

@@ -1,64 +0,0 @@
-<?php
-namespace common\models\forms;
-
-use common\components\Model;
-use common\helpers\Form;
-use common\models\SmsTemplate;
-
-/**
- * Login form
- */
-class SmsTemplateForm extends Model
-{
-    public $id;
-    public $content;
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['id', 'content'], 'trim'],
-            [['id', 'content'], 'required'],
-        ];
-    }
-
-    /**
-     * 指定校验场景
-     * @return array
-     */
-    public function scenarios()
-    {
-        $parentScenarios =  parent::scenarios();
-        $customScenarios = [
-            'edit' => ['content']
-        ];
-        return array_merge($parentScenarios, $customScenarios);
-    }
-
-    public function attributeLabels()
-    {
-        return [
-            'content' => '模板内容',
-        ];
-    }
-
-    /**
-     * 编辑短信模板
-     * @return null|static
-     */
-    public function edit(){
-        if(!$this->validate()){
-            return null;
-        }
-        $model = SmsTemplate::findOne($this->id);
-        $model->CONTENT = $this->content;
-        if(!$model->save()){
-            $this->addError('edit', Form::formatErrorsForApi($model->getErrors()));
-            return null;
-        }
-        return $model;
-    }
-
-}