root пре 3 година
родитељ
комит
10f4a8bb3f

+ 0 - 269
common/helpers/ChartData.php

@@ -1,269 +0,0 @@
-<?php
-/**
- * Created by PhpStorm.
- * User: leo
- * Date: 2018/6/12
- * Time: 下午2:11
- */
-
-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;
-
-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();
-        $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] = array_merge($calcMonths[$key], $this->_userMonthBonus($value['month'], $userId));
-        }
-        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){
-            return [
-                'BONUS_QY' => $bonus['BONUS_QY'],
-                'BONUS_YC' => $bonus['BONUS_YC'],
-                'BONUS_FX' => $bonus['BONUS_FX'],
-                'BONUS_LS' => $bonus['BONUS_LS'],
-                'BONUS_CF' => $bonus['BONUS_CF'],
-                'BONUS_LX' => $bonus['BONUS_LX'],
-                'BONUS_FL' => $bonus['BONUS_FL'],
-                'BONUS_BT' => $bonus['BONUS_BT'],
-                'BONUS_FW' => $bonus['BONUS_FW'],
-            ];
-        } else {
-            return [
-                'BONUS_QY' => 0,
-                'BONUS_YC' => 0,
-                'BONUS_FX' => 0,
-                'BONUS_LS' => 0,
-                'BONUS_CF' => 0,
-                'BONUS_LX' => 0,
-                'BONUS_FL' => 0,
-                'BONUS_BT' => 0,
-                'BONUS_FW' => 0,
-            ];
-        }
-    }
-
-
-}

+ 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 - 92
common/models/DecOrder.php

@@ -1,92 +0,0 @@
-<?php
-
-namespace common\models;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%DEC_ORDER}}".
- *
- * @property string $ID
- * @property string $DEC_SN 报单编号
- * @property string $ORDER_SN 订单编号
- * @property string $USER_ID 会员ID
- * @property string $TO_USER_ID 报单对象ID
- * @property string $TYPE 报单类型
- * @property int $IS_ADMIN 是否管理员操作
- * @property string $DEC_AMOUNT 报单金额
- * @property string $DEC_PV 报单PV
- * @property string $PAID_WALLET 支付钱包
- * @property int $IS_BATCH 是否批量报单
- * @property string $REMARK 备注
- * @property string $REC_USER_ID 推荐人ID
- * @property string $CON_USER_ID 接点人ID
- * @property string $DEC_ID 报单中心ID
- * @property int $PERIOD_NUM 报单期数
- * @property string $P_CALC_MONTH 分区结算月
- * @property int $CALC_MONTH 结算月
- * @property int $CREATED_AT 创建时间
- * @property string $UPDATER 操作人
- * @property string $UPDATED_AT 更新时间
- * @property int $IS_DEL 是否删除
- * @property int $DELETED_AT 删除时间
- */
-class DecOrder extends \common\components\ActiveRecord
-{
-    /**
-     * {@inheritdoc}
-     */
-    public static function tableName()
-    {
-        return '{{%DEC_ORDER}}';
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function rules()
-    {
-        return [
-            [['USER_ID', 'TO_USER_ID','REC_USER_ID','CON_USER_ID','DEC_ID', 'TYPE', 'PAID_WALLET', 'PERIOD_NUM', 'P_CALC_MONTH', 'CREATED_AT'], 'required'],
-            [['IS_ADMIN', 'IS_BATCH', 'PERIOD_NUM', 'CALC_MONTH', 'CREATED_AT', 'IS_DEL', 'DELETED_AT'], 'integer'],
-            [['DEC_AMOUNT', 'DEC_PV'], 'number'],
-            [['ID', 'DEC_SN', 'ORDER_SN', 'USER_ID', 'TO_USER_ID','REC_USER_ID','CON_USER_ID','DEC_ID', 'TYPE', 'UPDATER', 'UPDATED_AT'], 'string', 'max' => 32],
-            [['PAID_WALLET'], 'string', 'max' => 48],
-            [['REMARK'], 'string', 'max' => 4000],
-            [['DEC_SN'], 'unique'],
-            [['ID'], 'unique'],
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function attributeLabels()
-    {
-        return [
-            'ID' => 'ID',
-            'DEC_SN' => '报单编号',
-            'ORDER_SN' => '订单编号',
-            'USER_ID' => '会员ID',
-            'TO_USER_ID' => '报单对象ID',
-            'TYPE' => '报单类型',
-            'IS_ADMIN' => '是否管理员操作',
-            'DEC_AMOUNT' => '报单金额',
-            'DEC_PV' => '报单PV',
-            'PAID_WALLET' => '支付钱包',
-            'IS_BATCH' => '是否批量报单',
-            'REMARK' => '备注',
-            'REC_USER_ID' => '开拓人编号',
-            'CON_USER_ID' => '上级编号',
-            'DEC_ID' => '上级编号',
-            'PERIOD_NUM' => '报单期数',
-            'P_CALC_MONTH' => '分区结算月',
-            'CALC_MONTH' => '结算月',
-            'CREATED_AT' => '创建时间',
-            'UPDATER' => '操作人',
-            'UPDATED_AT' => '更新时间',
-            'IS_DEL' => '是否删除',
-            'DELETED_AT' => '删除时间',
-        ];
-    }
-}

+ 0 - 63
common/models/DecRoleLog.php

@@ -1,63 +0,0 @@
-<?php
-
-namespace common\models;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%DEC_ROLE_LOG}}".
- *
- * @property string $ID
- * @property string $USER_ID 会员ID
- * @property string $FROM_ID 变动前的级别
- * @property string $TO_ID 变动后的级别
- * @property string $ADMIN_ID admin id
- * @property int $PERIOD_NUM 变动的期数
- * @property int $CALC_MONTH 变动的结算月
- * @property string $REMARK 备注
- * @property int $STATUS 状态
- * @property int $CREATED_AT 创建时间
- */
-class DecRoleLog extends \common\components\ActiveRecord
-{
-    /**
-     * {@inheritdoc}
-     */
-    public static function tableName()
-    {
-        return '{{%DEC_ROLE_LOG}}';
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function rules()
-    {
-        return [
-            [['ID', 'USER_ID', 'FROM_ID', 'TO_ID', 'PERIOD_NUM', 'CALC_MONTH', 'REMARK', 'CREATED_AT'], 'required'],
-            [['PERIOD_NUM', 'CALC_MONTH', 'STATUS', 'CREATED_AT'], 'integer'],
-            [['REMARK'], 'string'],
-            [['ID', 'USER_ID', 'FROM_ID', 'TO_ID', 'ADMIN_ID'], 'string', 'max' => 32],
-            [['ID'], 'unique'],
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function attributeLabels()
-    {
-        return [
-            'ID' => 'ID',
-            'USER_ID' => '会员ID',
-            'FROM_ID' => '变动前的级别',
-            'TO_ID' => '变动后的级别',
-            'ADMIN_ID' => '管理员id',
-            'PERIOD_NUM' => '变动的期数',
-            'CALC_MONTH' => '变动的结算月',
-            'REMARK' => '备注',
-            'STATUS' => '状态',
-            'CREATED_AT' => '创建时间',
-        ];
-    }
-}

+ 0 - 77
common/models/PerfActiveUser.php

@@ -1,77 +0,0 @@
-<?php
-
-namespace common\models;
-
-use common\helpers\snowflake\SnowFake;
-use common\helpers\Tool;
-use Yii;
-use yii\base\Exception;
-
-/**
- * This is the model class for table "{{%PERF_ACTIVE_USER}}".
- *
- * 
- * 
- * @property string $ID
- * @property string $USER_ID 用户id
- * @property string $IS_ACTIVE 是否活跃 1活跃
- * @property string $IS_SENT 是否已挂网,已官网不能删除 1已挂网
- * @property int $PERIOD_NUM 业绩期,是第几期
- * @property string $CALC_MONTH 结算年月202110
- * @property string $P_CALC_MONTH 结算年月日2021-12-10
- * @property string $WHICH_WEEK 当月第几周
- * @property int $WHICH_MONTH 当年第几月
- * @property string $WHICH_YEAR 结算周期年份
- * @property int $CREATED_AT 创建时间
- */
-class PerfActiveUser extends \common\components\ActiveRecord
-{
-    /**
-     * {@inheritdoc}
-     */
-    public static function tableName()
-    {
-        return '{{%PERF_ACTIVE_USER}}';
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function rules()
-    {
-        return [
-            [['IS_ACTIVE', 'USER_ID', 'PERIOD_NUM', 'CALC_MONTH', 'P_CALC_MONTH', 'CREATED_AT', 'SRATR_AT', 'END_AT'], 'required'],
-            [['PERIOD_NUM', 'CALC_MONTH', 'CREATED_AT'], 'integer'],
-            [['ID', 'USER_ID'], 'string', 'max' => 32],
-            [['P_CALC_MONTH'], 'string', 'max' => 7],
-            [['ID'], 'unique'],
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function attributeLabels()
-    {
-        return [
-            'ID' => 'ID',
-            'USER_ID' => '用户ID',
-            'IS_ACTIVE' => '是否活跃',
-            'IS_SENT' => '是否已挂网',
-            'PERIOD_NUM' => '业绩期',
-            'CALC_MONTH' => '结算年月',
-            'P_CALC_MONTH' => '结算年月日',
-            'SRATR_AT' => '活跃开始时间',
-            'END_AT' => '活跃结束时间',
-            'CREATED_AT' => '创建时间'
-        ];
-    }
-
-    /**
-     * 生成sn
-     * @return string
-     */
-    public static function generateSN() {
-        return  SnowFake::instance()->generateId();
-    }
-}

+ 0 - 205
common/models/PerfAudit.php

@@ -1,205 +0,0 @@
-<?php
-
-namespace common\models;
-
-use backendApi\modules\v1\models\Admin;
-use common\helpers\user\Info;
-use common\libs\logging\operate\valueType\Config as ValueTypeConfig;
-use Yii;
-
-/**
- * This is the model class for table "{{%PERF_AUDIT}}".
- *
- * @property string $ID
- * @property string $USER_ID 会员ID
- * @property string $PV_1L 一市场累计
- * @property string $PV_2L 二市场累计
- * @property string $PV_3L 三市场累计
- * @property string $PV_4L 四市场累计
- * @property string $PV_5L 五市场累计
- * @property string $SURPLUS_1L 一市场结余
- * @property string $SURPLUS_2L 二市场结余
- * @property string $SURPLUS_3L 三市场结余
- * @property string $SURPLUS_4L 四市场结余
- * @property string $SURPLUS_5L 五市场结余
- * @property string $SURPLUS_LS 零售结余
- * @property int $PERF_TYPE 业绩类型
- * @property int $PERF_LOCATION 业绩区域
- * @property string $AMOUNT 调整金额
- * @property string $PERF_BEFORE 业绩调整前
- * @property string $PERF_AFTER 业绩调整后
- * @property int $PERIOD_NUM 调整期数
- * @property int $AUDIT_STATUS 审核状态
- * @property string $CREATE_ADMIN 创建管理员
- * @property string $REMARK 备注
- * @property string $AUDIT_ADMIN 审核管理员
- * @property int $CREATED_AT 创建时间
- * @property int $AUDITED_AT 审核时间
- */
-class PerfAudit extends \common\components\ActiveRecord
-{
-    const PERF_TYPE_PV=1;
-    const PERF_TYPE_SURPLUS=2;
-    const CHANGE_PERF_TYPE = [
-        self::PERF_TYPE_PV => '总网业绩',
-        self::PERF_TYPE_SURPLUS => '大区剩余'
-    ];
-    const PERF_LOCATION_NAME = [
-        1=>'一市场',
-        2=>'二市场',
-        3=>'三市场',
-        4=>'四市场',
-        5=>'五市场',
-        6=>'虚拟零售区',
-    ];
-
-    /**
-     * {@inheritdoc}
-     */
-    public static function tableName()
-    {
-        return '{{%PERF_AUDIT}}';
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function rules()
-    {
-        return [
-            [['USER_ID', 'CREATED_AT'], 'required'],
-            [['PV_1L', 'PV_2L', 'PV_3L', 'PV_4L', 'PV_5L', 'SURPLUS_1L', 'SURPLUS_2L', 'SURPLUS_3L', 'SURPLUS_4L', 'SURPLUS_5L', 'SURPLUS_LS', 'PERF_BEFORE', 'PERF_AFTER', 'AMOUNT'], 'number'],
-            [['PERF_TYPE', 'PERF_LOCATION', 'PERIOD_NUM', 'AUDIT_STATUS', 'CREATED_AT', 'AUDITED_AT'], 'integer'],
-            [['ID', 'USER_ID', 'CREATE_ADMIN', 'AUDIT_ADMIN'], 'string', 'max' => 32],
-            [['REMARK'], 'string', 'max' => 4000],
-            [['ID'], 'unique'],
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function attributeLabels()
-    {
-        return [
-            'ID' => 'ID',
-            'USER_ID' => '会员ID',
-            'PV_1L' => '一市场累计',
-            'PV_2L' => '二市场累计',
-            'PV_3L' => '三市场累计',
-            'PV_4L' => '四市场累计',
-            'PV_5L' => '五市场累计',
-            'SURPLUS_1L' => '一市场结余',
-            'SURPLUS_2L' => '二市场结余',
-            'SURPLUS_3L' => '三市场结余',
-            'SURPLUS_4L' => '四市场结余',
-            'SURPLUS_5L' => '五市场结余',
-            'SURPLUS_LS' => '零售结余',
-            'PERF_TYPE' => '业绩类型',
-            'PERF_LOCATION' => '业绩区域',
-            'AMOUNT' => '调整金额',
-            'PERF_BEFORE' => '业绩调整前',
-            'PERF_AFTER' => '业绩调整后',
-            'PERIOD_NUM' => '调整期数',
-            'AUDIT_STATUS' => '审核状态',
-            'CREATE_ADMIN' => '创建管理员',
-            'REMARK' => '备注',
-            'AUDIT_ADMIN' => '审核管理员',
-            'CREATED_AT' => '创建时间',
-            'AUDITED_AT' => '审核时间',
-        ];
-    }
-
-    /**
-     * 按期数获取会员总网业绩和大区剩余
-     * @param $userId
-     * @param $periodNum
-     * @return array
-     */
-    public static function getUserPerfAndPerfPeriod($userId,$periodNum){
-        $perfPeriod = PerfPeriod::findOneAsArray('USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM', [':USER_ID' => $userId, ':PERIOD_NUM' => $periodNum]);
-        $userPerf = UserPerf::findOneAsArray('USER_ID=:USER_ID', [':USER_ID' => $userId]);
-        return ['SURPLUS_1L' => $perfPeriod['SURPLUS_1L'] ?? 0, 'SURPLUS_2L' => $perfPeriod['SURPLUS_2L'] ?? 0, 'SURPLUS_3L' => $perfPeriod['SURPLUS_3L'] ?? 0, 'SURPLUS_4L' => $perfPeriod['SURPLUS_4L'] ?? 0, 'SURPLUS_5L' => $perfPeriod['SURPLUS_5L'] ?? 0, 'SURPLUS_LS' => $perfPeriod['SURPLUS_LS'] ?? 0, 'PV_1L' => $userPerf['PV_1L'] ?? 0, 'PV_2L' => $userPerf['PV_2L'] ?? 0, 'PV_3L' => $userPerf['PV_3L'] ?? 0, 'PV_4L' => $userPerf['PV_4L'] ?? 0, 'PV_5L' => $userPerf['PV_5L'] ?? 0];
-    }
-
-    /**
-     * 操作日志记录条件
-     * @return array
-     */
-    public function attrLabelsWithLogType(){
-        return [
-            'USER_ID' => '会员ID',
-            'PV_1L' => '一市场累计',
-            'PV_2L' => '二市场累计',
-            'PV_3L' => '三市场累计',
-            'PV_4L' => '四市场累计',
-            'PV_5L' => '五市场累计',
-            'SURPLUS_1L' => '一市场结余',
-            'SURPLUS_2L' => '二市场结余',
-            'SURPLUS_3L' => '三市场结余',
-            'SURPLUS_4L' => '四市场结余',
-            'SURPLUS_5L' => '五市场结余',
-            'SURPLUS_LS' => '零售结余',
-            'PERF_TYPE' => [
-                'label' => '业绩类型',
-                'type' => function($data){
-                    $value = $data['value'];
-                    return self::CHANGE_PERF_TYPE[$value];
-                },
-            ],
-            'PERF_LOCATION' => [
-                'label' => '业绩区域',
-                'type' => function($data){
-                    $value = $data['value'];
-                    return self::PERF_LOCATION_NAME[$value];
-                },
-            ],
-            'AMOUNT' => '调整金额',
-            'PERF_BEFORE' => '业绩调整前',
-            'PERF_AFTER' => '业绩调整后',
-            'PERIOD_NUM' => '调整期数',
-            'AUDIT_STATUS' => [
-                'label' => '审核状态',
-                'type' => function($data){
-                    $value = $data['value'];
-                    $result = '';
-                    if($value == 'un' || $value == \Yii::$app->params['auditStatus']['un']['value']){
-                        $result = \Yii::$app->params['auditStatus']['un']['label'];
-                    } elseif($value == 'true' || $value == \Yii::$app->params['auditStatus']['true']['value']) {
-                        $result = \Yii::$app->params['auditStatus']['true']['label'];
-                    } elseif($value == 'false' || $value == \Yii::$app->params['auditStatus']['false']['value']) {
-                        $result = \Yii::$app->params['auditStatus']['false']['label'];
-                    } elseif($value == 'reject' || $value == \Yii::$app->params['auditStatus']['reject']['value']) {
-                        $result = \Yii::$app->params['auditStatus']['reject']['label'];
-                    }
-                    return $result;
-                },
-            ],
-            'CREATE_ADMIN' => [
-                'label' => '创建管理员',
-                'type' => function($data){
-                    $value = is_array($data) && isset($data['value']) ? $data['value'] : '';
-                    $result = Admin::findOneAsArray('ID=:ID', [':ID'=>$value], 'ADMIN_NAME');
-                    return !empty($result) ? $result['ADMIN_NAME'] : '';
-                },
-            ],
-            'REMARK' => '备注',
-            'AUDIT_ADMIN' => [
-                'label' => '审核管理员',
-                'type' => function($data){
-                    $value = is_array($data) && isset($data['value']) ? $data['value'] : '';
-                    $result = Admin::findOneAsArray('ID=:ID', [':ID'=>$value], 'ADMIN_NAME');
-                    return !empty($result) ? $result['ADMIN_NAME'] : '';
-                },
-            ],
-            'CREATED_AT' => [
-                'label' => '创建时间',
-                'type' => ValueTypeConfig::DATE_TIME_TYPE,
-            ],
-            'AUDITED_AT' => [
-                'label' => '审核时间',
-                'type' => ValueTypeConfig::DATE_TIME_TYPE,
-            ],
-        ];
-    }
-}

+ 0 - 53
common/models/PerfCompany.php

@@ -1,53 +0,0 @@
-<?php
-
-namespace common\models;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%PERF_COMPANY}}".
- *
- * @property string $ID ID
- * @property string $PV 月总业绩
- * @property int $CALC_YEAR 结算年
- * @property int $CALC_MONTH 结算月
- * @property int $CREATED_AT 创建时间
- */
-class PerfCompany extends \common\components\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%PERF_COMPANY}}';
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['PV'], 'number'],
-            [['CALC_YEAR', 'CALC_MONTH', 'CREATED_AT'], 'required'],
-            [['CALC_YEAR', 'CALC_MONTH', 'CREATED_AT'], 'integer'],
-            [['ID'], 'string', 'max' => 32],
-            [['ID'], 'unique'],
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function attributeLabels()
-    {
-        return [
-            'ID' => 'ID',
-            'PV' => '月总业绩',
-            'CALC_YEAR' => '结算年',
-            'CALC_MONTH' => '结算月',
-            'CREATED_AT' => '创建时间',
-        ];
-    }
-}

+ 0 - 152
common/models/forms/DecRoleLogForm.php

@@ -1,152 +0,0 @@
-<?php
-namespace common\models\forms;
-
-use common\helpers\Date;
-use common\components\Model;
-use common\helpers\Form;
-use common\helpers\snowflake\SnowFake;
-use common\helpers\user\Info;
-use common\helpers\Validator;
-use common\libs\logging\operate\AdminOperate;
-use common\models\Ad;
-use common\models\AdLocation;
-use common\models\Article;
-use common\models\DecLevelLog;
-use common\models\DecRole;
-use common\models\DecRoleLog;
-use common\models\Period;
-use common\models\DeclarationLevel;
-use common\models\User;
-use common\models\UserInfo;
-use yii\base\Exception;
-use yii\validators\UrlValidator;
-
-/**
- * Login form
- */
-class DecRoleLogForm extends Model
-{
-    public $userName;
-    public $levelId;
-    public $remark;
-
-    private $_userId;
-    private $_fromId;
-
-    public function init() {
-        parent::init();
-        $this->adminOperateLogger = new AdminOperate([
-            'fetchClass' => User::class,
-        ]);
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['userName', 'levelId',  'remark'], 'trim'],
-            [['userName', 'levelId'], 'required'],
-            [['userName'], 'exist', 'targetClass'=>User::class, 'targetAttribute'=>'USER_NAME'],
-            [['levelId'], 'exist', 'targetClass'=>DecRole::class, 'targetAttribute'=>'ID'],
-            [['userName'], 'isUser'],
-            [['levelId'], 'isLevel'],
-        ];
-    }
-
-    public function attributeLabels()
-    {
-        return [
-            'userName' => '会员编号',
-            'levelId' => '级别',
-            'remark' => '期数',
-        ];
-    }
-
-    /**
-     * 指定校验场景
-     * @return array
-     */
-    public function scenarios()
-    {
-        $parentScenarios =  parent::scenarios();
-        $customScenarios = [
-            'adminChange' => ['userName', 'levelId', 'remark'],
-        ];
-        return array_merge($parentScenarios, $customScenarios);
-    }
-
-    /**
-     * 赋值UserId并校验会员是否存在
-     * @param $attribute
-     */
-    public function isUser($attribute){
-        $this->_userId = Info::getUserIdByUserName($this->userName);
-        if(!$this->_userId){
-            $this->addError($attribute, 'Member does not exist'); // 会员不存在
-        }
-    }
-
-    /**
-     * 查看级别是否有变化
-     * @param $attribute
-     */
-    public function isLevel($attribute){
-        $baseUserInfo = User::findOneAsArray('ID=:ID', [':ID' => $this->_userId], 'ID,USER_NAME,IS_DEC,DEC_ROLE_ID');
-        if( $baseUserInfo['IS_DEC'] == 0 ) {
-            $this->addError($attribute, '只有报单中心才能修改报单中心级别');
-            return false;
-        }
-        $this->_fromId = $baseUserInfo['DEC_ROLE_ID'] ?? '';
-        unset($baseUserInfo);
-        if($this->levelId == $this->_fromId){
-            $this->addError($attribute, '级别没有变化无需调整');
-        }
-    }
-
-    /**
-     * 报单中心级别调整操作
-     * @return boolean
-     * @throws \yii\db\Exception
-     */
-    public function adminChange(){
-        if(!$this->validate()){
-            return false;
-        }
-        $this->adminOperateLogger->beforeUpdate($this->_userId,'ID',['select'=>'ID,DEC_ROLE_ID']);
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            // 新增数据
-            DecRoleLog::insertOne([
-                'ID' => SnowFake::instance()->generateId(),
-                'USER_ID' => $this->_userId,
-                'FROM_ID' => $this->_fromId,
-                'TO_ID' => $this->levelId,
-                'PERIOD_NUM' => 0,
-                'CALC_MONTH' => 0,
-                'REMARK' => $this->remark,
-                'STATUS' => 1,
-                'ADMIN_ID' => \Yii::$app->user->id,
-                'CREATED_AT' => Date::nowTime(),
-            ]);
-            User::updateAll(['DEC_ROLE_ID' => $this->levelId], 'ID=:ID', [':ID' => $this->_userId]);
-
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('adminChange', $e->getMessage());
-            return false;
-        }
-        $this->adminOperateLogger->afterUpdate($this->_userId,'ID',['select'=>'ID,DEC_ROLE_ID'])->clean()->save([
-            'optType' => '修改报单中心级别',
-            'userId' => $this->_userId,
-            'userName' => Info::getUserNameByUserId($this->_userId),
-            'remark' => $this->remark
-        ]);
-        return true;
-    }
-
-
-}