root hace 3 años
padre
commit
8fbc75c621

+ 0 - 126
common/models/DecLevelLog.php

@@ -1,126 +0,0 @@
-<?php
-
-namespace common\models;
-
-use common\helpers\Date;
-use common\helpers\Form;
-use Exception;
-use Yii;
-
-/**
- * This is the model class for table "{{%DEC_LEVEL_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 DecLevelLog extends \common\components\ActiveRecord
-{
-    /**
-     * {@inheritdoc}
-     */
-    public static function tableName()
-    {
-        return '{{%DEC_LEVEL_LOG}}';
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function rules()
-    {
-        return [
-            [['USER_ID', 'FROM_ID', 'TO_ID', 'PERIOD_NUM', 'CALC_MONTH', 'CREATED_AT'], 'required'],
-            [['PERIOD_NUM', 'CALC_MONTH', 'STATUS', 'CREATED_AT'], 'integer'],
-            [['ID', 'USER_ID', 'FROM_ID', 'TO_ID', 'ADMIN_ID'], 'string', 'max' => 32],
-            [['REMARK'], 'string', 'max' => 4000],
-            [['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' => '创建时间',
-        ];
-    }
-
-    // 会员端升级报单操作,添加记录
-    public function frontendChange($data) {
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            // 恢复所传期数的和这个会员相关的其他调整
-            $period = Period::instance();
-            $periodNum = $nowPeriodNum = $period->getNowPeriodNum();
-            DecLevelLog::updateAll(
-                [
-                    'STATUS' => 0
-                ], 
-                    'USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM', 
-                [
-                    ':USER_ID' => $data['userId'], ':PERIOD_NUM' => $periodNum
-                ]
-            );
-            // 新增数据
-            $model = new DecLevelLog();
-            $model->USER_ID = $data['userId'];
-            $model->FROM_ID = $data['fromId'];
-            $model->TO_ID = $data['levelId'];
-            $model->PERIOD_NUM = 0;
-            $model->CALC_MONTH = 0;
-            $model->REMARK = isset($data['remark']) ? $data['remark'] : '';
-            $model->STATUS = 1;
-            $model->ADMIN_ID = $data['actionId'];
-            $model->CREATED_AT = Date::nowTime();
-            $model->DEC_TYPE = 2;
-            if (!$model->save()) {
-                throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-            }
-            //修改会员级别,如果是上期,则一起变化,如果不是,则只改变实时级别
-            
-            $nowTime = Date::nowTime();
-            User::updateAll(
-                [
-                    'LAST_DEC_LV' => $data['levelId'], 
-                    'DEC_LV' => $data['levelId'], 
-                    'DEC_LV_UPDATED_AT'=>$nowTime, 
-                    'DEC_LV_UPDATED_PERIOD'=>$nowPeriodNum, 
-                    'LAST_DEC_LV_UPDATED_AT'=>$nowTime, 
-                    'LAST_DEC_LV_UPDATED_PERIOD'=>$nowPeriodNum, 
-                    'ZG_UPGRADE_PV'=>$data['lvPv']
-                ], 
-                'ID=:ID', 
-                [
-                    ':ID' => $data['userId']
-                ]
-            );
-
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('adminChange', $e->getMessage());
-            return null;
-        }
-        return $model;
-    }
-}

+ 0 - 133
common/models/DeclarationPackage.php

@@ -1,133 +0,0 @@
-<?php
-
-namespace common\models;
-
-/**
- * This is the model class for table "{{%DECLARATION_PACKAGE}}".
- *
- * @property string $ID
- * @property string $PACKAGE_NAME 套餐名称
- * @property string $PACKAGE_NO 套餐编号
- * @property string $LEVEL_ID 所属报单级别ID
- * @property string $AMOUNT 套餐金额
- * @property string $PV 套餐PV
- * @property string $AMOUNT_STANDARD 标准金额
- * @property string $PACKAGE_CONTENT 套餐内容
- * @property string $STORE_NUMS 套餐库存
- * @property string $CREATED_AT 创建时间
- * @property string $CREATE_ADMIN 创建人
- * @property string $UPDATE_ADMIN 更新人
- * @property int $UPDATED_AT 更新时间
- * @property int $IS_DEL 是否删除
- * @property int $STATUS 状态
- * @property int $DELETED_AT 删除时间
- */
-class DeclarationPackage extends \common\components\ActiveRecord
-{
-    const STATUS_NAME = [
-        1 => '已上架',
-        0 => '已下架',
-    ];
-
-
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%DECLARATION_PACKAGE}}';
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['PACKAGE_NAME','PACKAGE_NO','LEVEL_ID', 'AMOUNT', 'PV', 'PACKAGE_CONTENT', 'CREATED_AT','CREATE_ADMIN','AMOUNT_STANDARD'], 'required'],
-            [['ID','LEVEL_ID','CREATE_ADMIN', 'UPDATE_ADMIN'], 'string', 'max' => 32],
-            [['PACKAGE_NAME'], 'string', 'max' => 48],
-            [['PACKAGE_NAME'], 'unique'],
-            [['AMOUNT', 'PV','STORE_NUMS'], 'number'],
-            [['ID'], 'unique'],
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function attributeLabels()
-    {
-        return [
-            'ID' => 'ID',
-            'PACKAGE_NAME' => '套餐名称',
-            'PACKAGE_NO' => '套餐编号',
-            'LEVEL_ID' => '所属报单级别ID',
-            'AMOUNT' => '套餐金额',
-            'AMOUNT_STANDARD' => 'US price',// 标准价格
-            'PV' => '套餐BV',
-            'PACKAGE_CONTENT' => '套餐内容',
-            'CREATED_AT' => '创建时间',
-            'CREATE_ADMIN' => '创建人',
-            'UPDATE_ADMIN' => '更新人',
-            'UPDATED_AT' => '更新时间',
-            'IS_DEL' => '是否删除',
-            'STATUS' => '是否上架',
-            'DELETED_AT' => '删除时间',
-			'STORE_NUMS' => '套餐库存',
-        ];
-    }
-
-    /**
-     * 判断上下架状态
-     * @param $nowStatus
-     * @param $toStatus
-     * @return string
-     */
-    public static function chkAuditStatus($nowStatus, $toStatus) {
-        $statusName = self::STATUS_NAME;
-        $msg = '当前套餐状态为【' . $statusName[$nowStatus] . '】,无法设置为【' . $statusName[$toStatus] . '】';
-        switch ($toStatus) {
-            // 下架
-            case 0:
-                if ($nowStatus == 1) {
-                    $msg = '';
-                }
-                break;
-            //上架
-            case 1:
-                if ($nowStatus == 0) {
-                    $msg = '';
-                }
-                break;
-            default:
-        }
-        return $msg;
-    }
-
-    /**
-     * @return array|\yii\db\ActiveRecord[]
-     */
-    public static function getAllData(){
-        return static::find()->where('IS_DEL=0 AND STATUS=1')->indexBy('ID')->orderBy('ID ASC')->asArray()->all();
-    }
-
-    /**
-     * 通过报单ID获取对应的报单套餐
-     * @param $levelId
-     * @return mixed
-     */
-    public static function getPackageFromLevelId($levelId){
-        return static::findAllAsArray('LEVEL_ID=:LEVEL_ID', [':LEVEL_ID'=>$levelId]);
-    }
-
-    /**
-     * 通过ID获取套餐所属报单级别ID
-     * @param $packageId
-     * @return mixed
-     */
-    public static function getLevelById($packageId){
-        $data = self::findOneAsArray('ID=:ID', [':ID'=>$packageId]);
-        return $data['LEVEL_ID'];
-    }
-}

+ 53 - 0
common/models/DeductReconsume.php

@@ -0,0 +1,53 @@
+<?php
+
+namespace common\models;
+
+/**
+ * This is the model class for table "{{%DEDUCT_RECONSUME}}".
+ *
+ * @property string $ID
+ * @property int $USER_ID 用户ID
+ * @property int $CALC_MONTH 所在结算月
+ * @property int $RECONSUME_POINTS_SUM 此结算月累计已扣除的复消积分
+ * @property int $CREATED_AT 创建时间
+ */
+class DeductReconsume extends \common\components\ActiveRecord
+{
+    public function init()
+    {
+        parent::init();
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%DEDUCT_RECONSUME}}';
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['CALC_MONTH', 'USER_ID'], 'required'],
+            [['CALC_MONTH', 'CREATED_AT'], 'integer'],
+            [['ID'], 'unique'],
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'ID' => 'ID',
+            'CALC_MONTH' => '所在结算月',
+            'RECONSUME_POINTS_SUM' => '此结算月累计已扣除的复消积分',
+            'CREATED_AT' => '创建时间',
+        ];
+    }
+}

+ 0 - 62
common/models/EmployLevelLog.php

@@ -1,62 +0,0 @@
-<?php
-
-namespace common\models;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%EMPLOY_LEVEL_LOG}}".
- *
- * @property string $ID
- * @property string $USER_ID 会员ID
- * @property string $FROM_ID 变动前的级别
- * @property string $TO_ID 变动后的级别
- * @property int $PERIOD_NUM 变动时的期数
- * @property int $CALC_MONTH 变动时的结算月
- * @property string $P_CALC_MONTH 表分区标识
- * @property string $REMARK 备注
- * @property int $CREATED_AT 创建时间
- */
-class EmployLevelLog extends \common\components\ActiveRecord
-{
-    /**
-     * {@inheritdoc}
-     */
-    public static function tableName()
-    {
-        return '{{%EMPLOY_LEVEL_LOG}}';
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function rules()
-    {
-        return [
-            [['USER_ID', 'FROM_ID', 'TO_ID', 'PERIOD_NUM', 'CALC_MONTH', 'P_CALC_MONTH', 'CREATED_AT'], 'required'],
-            [['PERIOD_NUM', 'CALC_MONTH', 'CREATED_AT'], 'integer'],
-            [['ID', 'USER_ID', 'FROM_ID', 'TO_ID'], 'string', 'max' => 32],
-            [['P_CALC_MONTH'], 'safe'],
-            [['REMARK'], 'string', 'max' => 4000],
-            [['ID'], 'unique'],
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function attributeLabels()
-    {
-        return [
-            'ID' => 'ID',
-            'USER_ID' => '会员ID',
-            'FROM_ID' => '变动前的级别',
-            'TO_ID' => '变动后的级别',
-            'PERIOD_NUM' => '变动时的期数',
-            'CALC_MONTH' => '变动时的结算月',
-            'P_CALC_MONTH' => '表分区标识',
-            'REMARK' => '备注',
-            'CREATED_AT' => '创建时间',
-        ];
-    }
-}

+ 0 - 121
common/models/LogAdminHandle.php

@@ -1,121 +0,0 @@
-<?php
-
-namespace common\models;
-
-use common\components\MongoActiveRecord;
-use Yii;
-
-/**
- * This is the model class for collection "ar_bonus_admin_log".
- *
- * @property \MongoDB\BSON\ObjectID|string $_id
- * @property mixed $admin_id
- * @property mixed $admin_name
- * @property mixed $ip
- * @property mixed $created_at
- * @property mixed $request_route
- * @property mixed $opt_type
- * @property mixed $save_before_content
- * @property mixed $save_after_content
- * @property mixed $key_log
- * @property mixed $opt_obj_id
- * @property mixed $opt_obj_name
- * @property mixed $remark
- * @property mixed $user_agent
- * @property mixed $period_num
- * @property mixed $is_batch
- * @property mixed $device
- */
-class LogAdminHandle extends MongoActiveRecord
-{
-    /**
-     * {@inheritdoc}
-     */
-    public static function collectionName()
-    {
-        return 'ar_bonus_admin_log';
-    }
-
-    /**
-     * @return \yii\mongodb\Connection the MongoDB connection used by this AR class.
-     */
-    public static function getDb()
-    {
-        return Yii::$app->get('dbLog');
-    }
-
-    /**
-     * 获取id
-     * @return string
-     */
-    public function getId() {
-        return (string) $this->_id;
-    }
-    /**
-     * {@inheritdoc}
-     */
-    public function attributes()
-    {
-        return [
-            '_id',
-            'admin_id',
-            'admin_name',
-            'ip',
-            'created_at',
-            'request_route',
-            'opt_type',
-            'save_before_content',
-            'save_after_content',
-            'key_log',
-            'opt_obj_id',
-            'opt_obj_name',
-            'remark',
-            'user_agent',
-            'period_num',
-            'is_batch',
-            'device',
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function rules()
-    {
-        return [
-            [['admin_id', 'admin_name', 'ip', 'request_route', 'opt_type'], 'required'],
-            [['created_at', 'key_log', 'period_num', 'is_batch'], 'integer'],
-            [['admin_id', 'opt_obj_id'], 'string', 'max' => 32],
-            [['admin_name', 'ip', 'opt_obj_name'], 'string', 'max' => 16],
-            [['_id', 'opt_type', 'save_before_content', 'save_after_content', 'device'], 'safe'],
-            [['user_agent', 'request_route', 'remark'], 'string', 'max' => 1000],
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function attributeLabels()
-    {
-        return [
-            '_id' => 'ID',
-            'admin_id' => '操作人id',
-            'admin_name' => '操作人',
-            'ip' => '操作ip',
-            'created_at' => '创建时间',
-            'request_route' => '请求路由',
-            'opt_type' => '操作类型',
-            'save_before_content' => '保存前的内容',
-            'save_after_content' => '保存后的内容',
-            'key_log' => '关键日志',
-            'opt_obj_id' => '操作对象id',
-            'opt_obj_name' => '操作对象名称',
-            'remark' => '备注',
-            'user_agent' => '浏览器特征',
-            'period_num' => '期数',
-            'is_batch' => '批量保存',
-            'device' => '客户端',
-        ];
-    }
-
-}

+ 0 - 105
common/models/LogAdminLogin.php

@@ -1,105 +0,0 @@
-<?php
-
-namespace common\models;
-
-use common\components\MongoActiveRecord;
-use Yii;
-
-/**
- * This is the model class for collection "ar_bonus_admin_login".
- *
- * @property \MongoDB\BSON\ObjectID|string $_id
- * @property mixed $adm_name
- * @property mixed $opt_type
- * @property mixed $return_result
- * @property mixed $success_times
- * @property mixed $fail_times
- * @property mixed $device
- * @property mixed $request_route
- * @property mixed $ip
- * @property mixed $created_at
- * @property mixed $user_agent
- * @property mixed $period_num
- */
-class LogAdminLogin extends MongoActiveRecord
-{
-    /**
-     * {@inheritdoc}
-     */
-    public static function collectionName()
-    {
-        return 'ar_bonus_admin_login';
-    }
-
-    /**
-     * @return \yii\mongodb\Connection the MongoDB connection used by this AR class.
-     */
-    public static function getDb()
-    {
-        return Yii::$app->get('dbLog');
-    }
-
-    /**
-     * 获取id
-     * @return string
-     */
-    public function getId() {
-        return (string) $this->_id;
-    }
-    /**
-     * {@inheritdoc}
-     */
-    public function attributes()
-    {
-        return [
-            '_id',
-            'adm_name',
-            'ip',
-            'created_at',
-            'user_agent',
-            'period_num',
-            'opt_type',
-            'success_times',
-            'fail_times',
-            'device',
-            'request_route',
-            'return_result',
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function rules()
-    {
-        return [
-            [['adm_name', 'ip', 'request_route'], 'required'],
-            [['created_at', 'success_times', 'period_num', 'fail_times'], 'integer'],
-            [['adm_name', 'ip',  'opt_type'], 'string', 'max' => 16],
-            [['_id', 'return_result', 'device',], 'safe'],
-            [['user_agent', 'request_route'], 'string', 'max' => 1000],
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function attributeLabels()
-    {
-        return [
-            '_id' => 'ID',
-            'adm_name' => '对象编号',
-            'ip' => '操作ip',
-            'created_at' => '创建时间',
-            'user_agent' => '浏览器特征',
-            'period_num' => '期数',
-            'opt_type' => '操作类型',
-            'success_times' => '登陆成功次数',
-            'fail_times' => '登录失败次数',
-            'device' => '客户端',
-            'request_route' => '请求路径',
-            'return_result' => '返回内容',
-        ];
-    }
-
-}

+ 0 - 115
common/models/LogSystem.php

@@ -1,115 +0,0 @@
-<?php
-
-namespace common\models;
-
-use common\components\MongoActiveRecord;
-use Yii;
-
-/**
- * This is the model class for collection "ar_bonus_system_log".
- *
- * @property \MongoDB\BSON\ObjectID|string $_id
- * @property mixed $ip
- * @property mixed $created_at
- * @property mixed $request_route
- * @property mixed $opt_type
- * @property mixed $request_content
- * @property mixed $response_content
- * @property mixed $opt_obj_id
- * @property mixed $opt_obj_name
- * @property mixed $opt_target_name
- * @property mixed $opt_user
- * @property mixed $user_agent
- * @property mixed $period_num
- * @property mixed $is_batch
- * @property mixed $device
- */
-class LogSystem extends MongoActiveRecord
-{
-    /**
-     * {@inheritdoc}
-     */
-    public static function collectionName()
-    {
-        return 'ar_bonus_system_log';
-    }
-
-    /**
-     * @return \yii\mongodb\Connection the MongoDB connection used by this AR class.
-     */
-    public static function getDb()
-    {
-        return Yii::$app->get('dbLog');
-    }
-
-    /**
-     * 获取id
-     * @return string
-     */
-    public function getId() {
-        return (string) $this->_id;
-    }
-    /**
-     * {@inheritdoc}
-     */
-    public function attributes()
-    {
-        return [
-            '_id',
-            'ip',
-            'created_at',
-            'request_route',
-            'opt_type',
-            'request_content',
-            'response_content',
-            'opt_obj_id',
-            'opt_obj_name',
-            'opt_target_name',
-            'opt_user',
-            'user_agent',
-            'period_num',
-            'is_batch',
-            'device',
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function rules()
-    {
-        return [
-            [['request_route', 'opt_type'], 'required'],
-            [['created_at', 'period_num', 'is_batch'], 'integer'],
-            [['opt_obj_id'], 'string', 'max' => 32],
-            [['ip', 'opt_obj_name'], 'string', 'max' => 16],
-            [['_id', 'opt_type', 'request_content', 'response_content', 'device'], 'safe'],
-            [['user_agent', 'request_route'], 'string', 'max' => 1000],
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function attributeLabels()
-    {
-        return [
-            '_id' => 'ID',
-            'ip'=>'操作ip',
-            'created_at'=>'创建时间',
-            'request_route'=>'请求路由',
-            'opt_type'=>'操作类型',
-            'request_content'=>'请求内容',
-            'response_content'=>'响应内容',
-            'opt_obj_id'=>'操作对象id',
-            'opt_obj_name'=>'操作对象名称',
-            'opt_target_name'=>'操作对象',
-            'opt_user'=>'操作人',
-            'user_agent'=>'浏览器特征',
-            'period_num'=>'期数',
-            'is_batch'=>'批量保存',
-            'device'=>'客户端',
-        ];
-    }
-
-}

+ 0 - 121
common/models/LogUserHandle.php

@@ -1,121 +0,0 @@
-<?php
-
-namespace common\models;
-
-use common\components\MongoActiveRecord;
-use Yii;
-
-/**
- * This is the model class for collection "ar_shop_admin_log".
- *
- * @property \MongoDB\BSON\ObjectID|string $_id
- * @property mixed $user_id
- * @property mixed $user_name
- * @property mixed $ip
- * @property mixed $created_at
- * @property mixed $request_route
- * @property mixed $opt_type
- * @property mixed $save_before_content
- * @property mixed $save_after_content
- * @property mixed $key_log
- * @property mixed $opt_obj_id
- * @property mixed $opt_obj_name
- * @property mixed $remark
- * @property mixed $user_agent
- * @property mixed $period_num
- * @property mixed $is_batch
- * @property mixed $device
- */
-class LogUserHandle extends MongoActiveRecord
-{
-    /**
-     * {@inheritdoc}
-     */
-    public static function collectionName()
-    {
-        return 'ar_bonus_user_log';
-    }
-
-    /**
-     * @return \yii\mongodb\Connection the MongoDB connection used by this AR class.
-     */
-    public static function getDb()
-    {
-        return Yii::$app->get('dbLog');
-    }
-
-    /**
-     * 获取id
-     * @return string
-     */
-    public function getId() {
-        return (string) $this->_id;
-    }
-    /**
-     * {@inheritdoc}
-     */
-    public function attributes()
-    {
-        return [
-            '_id',
-            'user_id',
-            'user_name',
-            'ip',
-            'created_at',
-            'request_route',
-            'opt_type',
-            'save_before_content',
-            'save_after_content',
-            'key_log',
-            'opt_obj_id',
-            'opt_obj_name',
-            'remark',
-            'user_agent',
-            'period_num',
-            'is_batch',
-            'device',
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function rules()
-    {
-        return [
-            [['user_id', 'user_name', 'ip', 'request_route', 'opt_type'], 'required'],
-            [['created_at', 'key_log', 'period_num', 'is_batch'], 'integer'],
-            [['user_id', 'opt_obj_id'], 'string', 'max' => 32],
-            [['user_name', 'ip', 'opt_obj_name'], 'string', 'max' => 16],
-            [['_id', 'opt_type', 'save_before_content', 'save_after_content', 'device'], 'safe'],
-            [['user_agent', 'request_route', 'remark'], 'string', 'max' => 1000],
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function attributeLabels()
-    {
-        return [
-            '_id' => 'ID',
-            'user_id' => '操作人id',
-            'user_name' => '操作人',
-            'ip' => '操作ip',
-            'created_at' => '创建时间',
-            'request_route' => '请求路由',
-            'opt_type' => '操作类型',
-            'save_before_content' => '保存前的内容',
-            'save_after_content' => '保存后的内容',
-            'key_log' => '关键日志',
-            'opt_obj_id' => '操作对象id',
-            'opt_obj_name' => '操作对象名称',
-            'remark' => '备注',
-            'user_agent' => '浏览器特征',
-            'period_num' => '期数',
-            'is_batch' => '批量保存',
-            'device' => '客户端',
-        ];
-    }
-
-}

+ 0 - 105
common/models/LogUserLogin.php

@@ -1,105 +0,0 @@
-<?php
-
-namespace common\models;
-
-use common\components\MongoActiveRecord;
-use Yii;
-
-/**
- * This is the model class for collection "ar_bonus_admin_login".
- *
- * @property \MongoDB\BSON\ObjectID|string $_id
- * @property mixed $user_name
- * @property mixed $opt_type
- * @property mixed $return_result
- * @property mixed $success_times
- * @property mixed $fail_times
- * @property mixed $device
- * @property mixed $request_route
- * @property mixed $ip
- * @property mixed $created_at
- * @property mixed $user_agent
- * @property mixed $period_num
- */
-class LogUserLogin extends MongoActiveRecord
-{
-    /**
-     * {@inheritdoc}
-     */
-    public static function collectionName()
-    {
-        return 'ar_bonus_user_login';
-    }
-
-    /**
-     * @return \yii\mongodb\Connection the MongoDB connection used by this AR class.
-     */
-    public static function getDb()
-    {
-        return Yii::$app->get('dbLog');
-    }
-
-    /**
-     * 获取id
-     * @return string
-     */
-    public function getId() {
-        return (string) $this->_id;
-    }
-    /**
-     * {@inheritdoc}
-     */
-    public function attributes()
-    {
-        return [
-            '_id',
-            'user_name',
-            'ip',
-            'created_at',
-            'user_agent',
-            'period_num',
-            'opt_type',
-            'success_times',
-            'fail_times',
-            'device',
-            'request_route',
-            'return_result',
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function rules()
-    {
-        return [
-            [['user_name', 'ip', 'request_route'], 'required'],
-            [['created_at', 'success_times', 'period_num', 'fail_times'], 'integer'],
-            [['user_name', 'ip', 'opt_type'], 'string', 'max' => 16],
-            [['_id', 'return_result', 'device',], 'safe'],
-            [['user_agent', 'request_route'], 'string', 'max' => 1000],
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function attributeLabels()
-    {
-        return [
-            '_id' => 'ID',
-            'user_name' => '对象编号',
-            'ip' => '操作ip',
-            'created_at' => '创建时间',
-            'user_agent' => '浏览器特征',
-            'period_num' => '期数',
-            'opt_type' => '操作类型',
-            'success_times' => '登陆成功次数',
-            'fail_times' => '登录失败次数',
-            'device' => '客户端',
-            'request_route' => '请求路径',
-            'return_result' => '返回内容',
-        ];
-    }
-
-}

+ 0 - 20
console/controllers/DecController.php

@@ -1,20 +0,0 @@
-<?php
-/**
- * Created by PhpStorm.
- * User: leo
- * Date: 2018/3/9
- * Time: 上午11:56
- */
-namespace console\controllers;
-
-use common\helpers\Cache;
-use common\helpers\Form;
-use common\helpers\Log;
-use common\models\forms\DeclarationForm;
-use common\models\forms\OrderGoodsForm;
-use common\models\LogAsync;
-
-class DecController extends BaseController
-{
-
-}

+ 0 - 265
console/controllers/FixNetController.php

@@ -1,265 +0,0 @@
-<?php
-/**
- * Created by PhpStorm.
- * User: liang
- * Date: 2020/2/18
- * Time: 6:36 PM
- */
-namespace console\controllers;
-
-
-use common\models\UserInfo;
-use common\models\UserNetwork;
-use common\models\UserRelation;
-
-class FixNetController extends BaseController {
-
-    const LIMIT = 1000;
-    //顶点ID列表
-    const TOP_ID_LIST = [
-        '670B84FD7C216D4EE055736AECE8644D',
-        '80552117701578757',
-    ];
-    //PARENT_UIDS缓存键
-    const FIX_NET_CACHE_NETWORK_PARENT_UIDS_KEY = 'fixNet:cache:network:parentUids:key';
-    const FIX_NET_CACHE_RELATION_PARENT_UIDS_KEY = 'fixNet:cache:relation:parentUids:key';
-
-    const FIX_RELATION_DEEP_DEEP_USER_ID_KEY = 'fixRelationDeepDeepUserIdKey_%d';
-
-    /**
-     * 清空缓存
-     */
-    public function actionClearCache() {
-        $this->_clearNetworkParentUidsCache();
-        $this->_clearRelationParentUidsCache();
-        echo '缓存清理成功' . PHP_EOL;
-    }
-
-    /**
-     * 安置数据
-     * @param int $startPage
-     * @throws \yii\db\Exception
-     */
-    public function actionNetwork($startPage=1) {
-        $allCount = UserNetwork::find()->where('1=1')->orderBy('TOP_DEEP ASC,ID ASC')->count('ID');
-        $limit = self::LIMIT;
-        $pageCount = ceil($allCount/$limit);
-        unset($allCount);
-        for($page=$startPage;$page<=$pageCount;$page++) {
-            $userList = UserNetwork::find()->where('1=1')->orderBy('TOP_DEEP ASC,ID ASC')->limit($limit)->offset(($page-1)*$limit)->asArray()->all();
-            foreach ($userList as $everyUser) {
-                //顶点不处理
-                if( $everyUser['PARENT_UID'] == 0 ) continue;
-
-                $parentUidsCacheStr = $this->_getNetworkParentUidsCache($everyUser['PARENT_UID']);
-                if( $parentUidsCacheStr ) {
-                    $parentUidsStr = $parentUidsCacheStr . ',' . $everyUser['PARENT_UID'];
-                }else {
-                    if( $everyUser['TOP_DEEP'] == 1 ) {
-                        $parentUidsStr = $everyUser['PARENT_UID'];
-                    }else {
-                        echo sprintf('parentUids错误 userId:%s,parentUid:%s'.PHP_EOL, $everyUser['USER_ID'], $everyUser['PARENT_UID']);
-                        continue;
-                    }
-                }
-
-                $this->_addNetworkParentUidsCache($everyUser['USER_ID'], $parentUidsStr);
-
-                if( $parentUidsStr != $everyUser['PARENT_UIDS'] ) {
-                    UserNetwork::updateAll(['PARENT_UIDS'=>$parentUidsStr], 'ID=:ID', ['ID'=>$everyUser['ID']]);
-                    echo sprintf('parentUids成功 userId:%s,parentUid:%s'.PHP_EOL, $everyUser['USER_ID'], $everyUser['PARENT_UID']);
-                }
-                unset($everyUser, $parentUidsCacheStr, $parentUidsStr);
-            }
-            unset($userList);
-            echo sprintf("更新网体表数据,总页数【%s】,当前页数:【%s】更新成功".PHP_EOL, $pageCount, $page);
-        }
-
-        echo '更新网体表数据全部完成' . PHP_EOL;
-
-    }
-
-    /**
-     * 跑关系表中所有的深度
-     * @param int $deep
-     */
-    public function actionRelationTopDeep($deep=1) {
-        if( $deep === 1 ) $this->_cacheOneDeepInit();
-        //取deep的列表
-        $status = $this->_calcOneDeepList($deep);
-
-        if( $status ) $this->actionRelationTopDeep($deep+1);
-    }
-
-    /**
-     * 初始化0层的缓存
-     */
-    private function _cacheOneDeepInit() {
-        foreach (self::TOP_ID_LIST as $userId) {
-            self::_addRelationDeepUserIdCache(0, $userId);
-        }
-    }
-
-    /**
-     * 计算某一层深度的列表
-     * @param $deep
-     * @param int $offset
-     * @return bool
-     */
-    private function _calcOneDeepList($deep, $offset=0) {
-        echo sprintf("时间:[%s]推荐深度,当前deep为:【%d】,当前offset为:【%d】" . PHP_EOL, date('Y-m-d H:i:s', time()) , $deep, $offset);
-        $allData = self::_getRelationDeepList($deep-1, $offset, self::LIMIT);
-        if( $allData ) {
-            foreach ($allData as $userId) {
-                $childrenList = UserRelation::find()->where('PARENT_UID=:PARENT_UID', ['PARENT_UID'=>$userId])->asArray()->all();
-                foreach ($childrenList as $childData) {
-                    if( $childData['TOP_DEEP'] != $deep ) {
-                        UserRelation::updateAll([
-                            'TOP_DEEP' => $deep,
-                        ], 'USER_ID=:USER_ID', ['USER_ID'=>$childData['USER_ID']]);
-
-                        UserInfo::updateAll(['RELATION_DEEP'=>$deep], 'USER_ID=:USER_ID', ['USER_ID'=>$childData['USER_ID']]);
-                    }
-                    if( !in_array($childData['TOP_UID'], self::TOP_ID_LIST) ) {
-                        if( in_array($userId, self::TOP_ID_LIST) ) {
-                            UserRelation::updateAll([
-                                'TOP_UID' => $userId,
-                            ], 'USER_ID=:USER_ID', ['USER_ID'=>$childData['USER_ID']]);
-                        }else {
-                            $parentData = UserRelation::find()->where('USER_ID=:USER_ID', ['USER_ID'=>$userId])->asArray()->one();
-                            UserRelation::updateAll([
-                                'TOP_UID' => $parentData['TOP_UID'],
-                            ], 'USER_ID=:USER_ID', ['USER_ID'=>$childData['USER_ID']]);
-                            unset($parentData);
-                        }
-                    }
-
-                    self::_addRelationDeepUserIdCache($deep, $childData['USER_ID']);
-                }
-            }
-
-            return $this->_calcOneDeepList($deep, $offset + self::LIMIT);
-        }
-
-        unset($allData);
-        $this->_clearRelationDeepUserIdCache($deep-1);
-        if( $offset > 0 ) {
-            return true;
-        }else {
-            return false;
-        }
-    }
-
-    /**
-     * 推荐数据
-     * @param int $startPage
-     * @throws \yii\db\Exception
-     */
-    public function actionRelation($startPage=1) {
-        $allCount = UserRelation::find()->where('1=1')->orderBy('TOP_DEEP ASC,ID ASC')->count('ID');
-        $limit = self::LIMIT;
-        $pageCount = ceil($allCount/$limit);
-        unset($allCount);
-        for($page=$startPage;$page<=$pageCount;$page++) {
-            $userList = UserRelation::find()->where('1=1')->orderBy('TOP_DEEP ASC,ID ASC')->limit($limit)->offset(($page-1)*$limit)->asArray()->all();
-            foreach ($userList as $everyUser) {
-                //顶点不处理
-                if( $everyUser['PARENT_UID'] == 0 ) continue;
-
-                $parentUidsCacheStr = $this->_getRelationParentUidsCache($everyUser['PARENT_UID']);
-                if( $parentUidsCacheStr ) {
-                    $parentUidsStr = $parentUidsCacheStr . ',' . $everyUser['PARENT_UID'];
-                }else {
-                    if( $everyUser['TOP_DEEP'] == 1 ) {
-                        $parentUidsStr = $everyUser['PARENT_UID'];
-                    }else {
-                        echo sprintf('parentUids错误 userId:%s,parentUid:%s'.PHP_EOL, $everyUser['USER_ID'], $everyUser['PARENT_UID']);
-                        continue;
-                    }
-                }
-
-                $this->_addRelationParentUidsCache($everyUser['USER_ID'], $parentUidsStr);
-
-                if( $parentUidsStr != $everyUser['PARENT_UIDS'] ) {
-                    UserRelation::updateAll(['PARENT_UIDS'=>$parentUidsStr], 'ID=:ID', ['ID'=>$everyUser['ID']]);
-                    echo sprintf('parentUids成功 userId:%s,parentUid:%s'.PHP_EOL, $everyUser['USER_ID'], $everyUser['PARENT_UID']);
-                }
-                unset($everyUser, $parentUidsCacheStr, $parentUidsStr);
-            }
-            unset($userList);
-            echo sprintf("更新推荐表数据,总页数【%s】,当前页数:【%s】更新成功".PHP_EOL, $pageCount, $page);
-        }
-
-        echo '更新推荐表数据全部完成' . PHP_EOL;
-    }
-
-    /**
-     * 添加parent_uids Cache数据
-     * @param $userId
-     * @param $parentUidsStr
-     * @return mixed
-     */
-    private function _addNetworkParentUidsCache($userId, $parentUidsStr) {
-        return \Yii::$app->redis->hSet(self::FIX_NET_CACHE_NETWORK_PARENT_UIDS_KEY, $userId, $parentUidsStr);
-    }
-
-    /**
-     * 获取parent_uids Cache数据
-     * @param $userId
-     * @return mixed
-     */
-    private function _getNetworkParentUidsCache($userId) {
-        return \Yii::$app->redis->hGet(self::FIX_NET_CACHE_NETWORK_PARENT_UIDS_KEY, $userId);
-    }
-
-    /**
-     * 清空parent_uids Cache数据
-     * @return mixed
-     */
-    private function _clearNetworkParentUidsCache() {
-        return \Yii::$app->redis->del(self::FIX_NET_CACHE_NETWORK_PARENT_UIDS_KEY);
-    }
-
-    /**
-     * 添加parent_uids Cache数据
-     * @param $userId
-     * @param $parentUidsStr
-     * @return mixed
-     */
-    private function _addRelationParentUidsCache($userId, $parentUidsStr) {
-        return \Yii::$app->redis->hSet(self::FIX_NET_CACHE_RELATION_PARENT_UIDS_KEY, $userId, $parentUidsStr);
-    }
-
-    /**
-     * 获取parent_uids Cache数据
-     * @param $userId
-     * @return mixed
-     */
-    private function _getRelationParentUidsCache($userId) {
-        return \Yii::$app->redis->hGet(self::FIX_NET_CACHE_RELATION_PARENT_UIDS_KEY, $userId);
-    }
-
-    /**
-     * 清空parent_uids Cache数据
-     * @return mixed
-     */
-    private function _clearRelationParentUidsCache() {
-        return \Yii::$app->redis->del(self::FIX_NET_CACHE_RELATION_PARENT_UIDS_KEY);
-    }
-
-    private function _clearRelationDeepUserIdCache($deep) {
-        $key = sprintf(self::FIX_RELATION_DEEP_DEEP_USER_ID_KEY, $deep);
-        return \Yii::$app->redis->del($key);
-    }
-
-    private function _addRelationDeepUserIdCache($deep, $userId) {
-        $key = sprintf(self::FIX_RELATION_DEEP_DEEP_USER_ID_KEY, $deep);
-        return \Yii::$app->redis->rpush($key, $userId);
-    }
-
-    private function _getRelationDeepList($deep, $offset = 0, $limit = 1000) {
-        $key = sprintf(self::FIX_RELATION_DEEP_DEEP_USER_ID_KEY, $deep);
-        return \Yii::$app->redis->lrange($key, $offset, ($offset + $limit - 1));
-    }
-
-}

+ 0 - 184
console/controllers/UserController.php

@@ -1,184 +0,0 @@
-<?php
-/**
- * Created by PhpStorm.
- * User: leo
- * Date: 2018/3/9
- * Time: 上午11:56
- */
-namespace console\controllers;
-
-use backendApi\modules\v1\models\lists\bonus\PerfOrderList;
-use backendApi\modules\v1\models\lists\user\BindList;
-use backendApi\modules\v1\models\lists\user\GroupList;
-use backendApi\modules\v1\models\lists\user\IndexList;
-use backendApi\modules\v1\models\lists\user\MoveList;
-use backendApi\modules\v1\models\lists\user\StatusAuditList;
-use backendApi\modules\v1\models\lists\user\SystemList;
-use backendApi\modules\v1\models\lists\user\TeamworkList;
-use backendApi\modules\v1\models\lists\user\YearHighestEmpLvList;
-use common\helpers\Cache;
-use common\libs\export\BaseExport;
-use common\libs\export\module\BonusExport;
-use common\libs\export\module\UserExport;
-use common\models\forms\NetMoveForm;
-use common\helpers\Form;
-use Yii;
-use yii\db\Exception;
-
-class UserController extends BaseController
-{
-
-    /**
-     * 安置网络移网
-     * @param $taskKey
-     * @throws \Exception
-     */
-    public function actionMoveNetwork($taskKey){
-        $params = Cache::getAsyncParams($taskKey);
-        $formModel = new NetMoveForm();
-        $formModel->scenario = 'async';
-        $handleResult = false;
-        if($formModel->load($params, '') && $formModel->moveAsync()){
-            $handleResult = true;
-            echo sprintf("时间:[%s]移网, 会员安置网络【%s】移网成功".PHP_EOL, date('Y-m-d H:i:s', time()), $params['moveUserName']);
-            //\Yii::$app->swooleAsyncTimer->pushAsyncResultToAdmin($params['handleUserId'], "会员安置网络{$params['moveUserName']}移网成功");
-        } else {
-            echo sprintf("时间:[%s]移网, 会员安置网络【%s】移网失败".PHP_EOL, date('Y-m-d H:i:s', time()), $params['moveUserName']);
-            //\Yii::$app->swooleAsyncTimer->pushAsyncResultToAdmin($params['handleUserId'], "会员安置网络{$params['moveUserName']}移网失败,原因:".Form::formatErrorsForApi($formModel->getErrors()), false);
-        }
-        if(!$handleResult){
-            // Log::async([
-//                'type' => LogAsync::TYPE_USER,
-//                'route' => 'user/move-network',
-//                'title' => "会员安置网络{$params['moveUserName']}移网失败",
-//                'detail' => "会员安置网络{$params['moveUserName']}移网失败,原因:".Form::formatErrorsForApi($formModel->getErrors()),
-//                'status' => 0,
-//            ]);
-        }
-    }
-
-    /**
-     * 移开拓网络
-     * @param $taskKey
-     * @throws Exception
-     */
-    public function actionMoveRelation($taskKey){
-        $params = Cache::getAsyncParams($taskKey);
-        $formModel = new NetMoveForm();
-        $formModel->scenario = 'async';
-        $handleResult = false;
-        if($formModel->load($params, '') && $formModel->moveAsync()){
-            $handleResult = true;
-            echo sprintf("时间:[%s]移网, 会员开拓网络【%s】移网成功".PHP_EOL, date('Y-m-d H:i:s', time()), $params['moveUserName']);
-            //\Yii::$app->swooleAsyncTimer->pushAsyncResultToAdmin($params['handleUserId'], "会员开拓网络{$params['moveUserName']}移网成功");
-        } else {
-            echo sprintf("时间:[%s]移网, 会员开拓网络【%s】移网失败".PHP_EOL, date('Y-m-d H:i:s', time()), $params['moveUserName']);
-            //\Yii::$app->swooleAsyncTimer->pushAsyncResultToAdmin($params['handleUserId'], "会员开拓网络{$params['moveUserName']}移网失败,原因:".Form::formatErrorsForApi($formModel->getErrors()), false);
-        }
-        if(!$handleResult){
-            // Log::async([
-//                'type' => LogAsync::TYPE_USER,
-//                'route' => 'user/move-relation',
-//                'title' => "会员开拓网络{$params['moveUserName']}移网失败",
-//                'detail' => "会员开拓网络{$params['moveUserName']}移网失败,原因:".Form::formatErrorsForApi($formModel->getErrors()),
-//                'status' => 0,
-//            ]);
-        }
-    }
-
-    /**
-     * 会员列表导出
-     * @param $taskId
-     * @return bool
-     */
-    public function actionIndexExport($taskId){
-        return $this->_export($taskId, IndexList::class, 'Member_list');
-    }
-
-    /**
-     * 会员绑定列表导出
-     * @param $taskId
-     * @return bool
-     */
-    public function actionBindExport($taskId){
-        return $this->_export($taskId, BindList::class, '会员绑定列表');
-    }
-
-    /**
-     * 点位合作导出
-     * @param $taskId
-     * @return bool
-     */
-    public function actionTeamworkExport($taskId){
-        return $this->_export($taskId, TeamworkList::class, '点位合作');
-    }
-
-    /**
-     * 体系管理导出
-     * @param $taskId
-     * @return bool
-     */
-    public function actionSystemExport($taskId){
-        return $this->_export($taskId, SystemList::class, '体系管理');
-    }
-
-    /**
-     * 团队领导人列表导出
-     * @param $taskId
-     * @return bool
-     */
-    public function actionGroupExport($taskId){
-        return $this->_export($taskId, GroupList::class, '团队领导人列表');
-    }
-
-    /**
-     * 移网管理导出
-     * @param $taskId
-     * @return bool
-     */
-    public function actionMoveExport($taskId){
-        return $this->_export($taskId, MoveList::class, '移网管理');
-    }
-
-    /**
-     * 会员状态管理导出
-     * @param $taskId
-     * @return bool
-     */
-    public function actionStatusAuditExport($taskId){
-        return $this->_export($taskId, StatusAuditList::class, '会员状态管理');
-    }
-
-    /**
-     * 会员历史年度最高聘级表导出
-     * @param $taskId
-     * @return bool
-     */
-    public function actionYearHighestEmpLvExport($taskId){
-        return $this->_export($taskId, YearHighestEmpLvList::class, '会员历史年度最高聘级表');
-    }
-
-    /**
-     * 导出方法
-     * @param $taskId
-     * @param $className
-     * @param $listName
-     * @return bool
-     */
-    private function _export($taskId, $className, $listName){
-        $factory = UserExport::factory($taskId);
-        $factory->listModelClass = $className;
-        try {
-            if ($factory->generate()) {
-                \Yii::$app->swooleAsyncTimer->pushAsyncResultToAdmin($factory->getUserId(), $listName.'导出成功');
-            }
-            unset($factory, $taskId, $className, $listName);
-            return true;
-        } catch (\Exception $e) {
-            echo $listName.'导出失败。详情:' . $e->getMessage();
-            \Yii::$app->swooleAsyncTimer->pushAsyncResultToAdmin($factory->getUserId(), $listName.'导出失败。详情:' . $e->getMessage(), false);
-        }
-        unset($factory, $taskId, $className, $listName);
-        return false;
-    }
-}