zxiansheng před 4 roky
rodič
revize
521b7544f4
85 změnil soubory, kde provedl 305 přidání a 15779 odebrání
  1. 126 126
      common/models/Ad.php
  2. 0 72
      common/models/AdLocation.php
  3. 0 162
      common/models/BalanceAudit.php
  4. 0 102
      common/models/CFLXAudit.php
  5. 0 80
      common/models/CalcBonusBD.php
  6. 0 111
      common/models/CalcBonusBT.php
  7. 0 73
      common/models/CalcBonusCF.php
  8. 0 79
      common/models/CalcBonusFL.php
  9. 0 80
      common/models/CalcBonusFW.php
  10. 0 77
      common/models/CalcBonusFX.php
  11. 0 80
      common/models/CalcBonusGL.php
  12. 0 80
      common/models/CalcBonusGX.php
  13. 0 73
      common/models/CalcBonusLS.php
  14. 0 73
      common/models/CalcBonusLX.php
  15. 0 72
      common/models/CalcBonusQY.php
  16. 0 83
      common/models/CalcBonusStandard.php
  17. 0 80
      common/models/CalcBonusTG.php
  18. 0 80
      common/models/CalcBonusVIP.php
  19. 0 80
      common/models/CalcBonusXF.php
  20. 0 97
      common/models/CalcBonusYC.php
  21. 0 80
      common/models/CalcBonusYJ.php
  22. 0 51
      common/models/CalcMonthBonusUser.php
  23. 0 72
      common/models/CompanyBank.php
  24. 0 558
      common/models/forms/ChangePerfForm.php
  25. 0 135
      common/models/forms/ChangeShowEmpLvForm.php
  26. 0 147
      common/models/forms/ClearDataForm.php
  27. 0 216
      common/models/forms/CloseDecForm.php
  28. 0 217
      common/models/forms/CloseLoginForm.php
  29. 0 62
      common/models/forms/ConfigBonusForm.php
  30. 0 312
      common/models/forms/ConfigForm.php
  31. 0 165
      common/models/forms/ConfigPeriodForm.php
  32. 0 179
      common/models/forms/DealTypeForm.php
  33. 0 66
      common/models/forms/DecLevelForm.php
  34. 0 176
      common/models/forms/DecLevelLogForm.php
  35. 0 149
      common/models/forms/DecPackageForm.php
  36. 0 56
      common/models/forms/DecRoleForm.php
  37. 0 152
      common/models/forms/DecRoleLogForm.php
  38. 73 875
      common/models/forms/DeclarationForm.php
  39. 0 74
      common/models/forms/DeclarationLevelForm.php
  40. 0 181
      common/models/forms/DeclarationLoopForm.php
  41. 0 151
      common/models/forms/EmployLevelForm.php
  42. 0 241
      common/models/forms/ExcelOrderDecForm.php
  43. 0 258
      common/models/forms/ExcelOrderShopForm.php
  44. 0 169
      common/models/forms/ExcelOrderStandardForm.php
  45. 0 145
      common/models/forms/HistoryBonusForm.php
  46. 0 347
      common/models/forms/InvoiceAuditForm.php
  47. 0 231
      common/models/forms/InvoiceBalanceAuditForm.php
  48. 0 101
      common/models/forms/LogAdminHandleForm.php
  49. 0 124
      common/models/forms/LogAdminLoginForm.php
  50. 0 685
      common/models/forms/NetMoveForm.php
  51. 0 77
      common/models/forms/OcrApiForm.php
  52. 2 48
      common/models/forms/OrderForm.php
  53. 0 369
      common/models/forms/PeriodForm.php
  54. 0 290
      common/models/forms/RechargeForm.php
  55. 0 520
      common/models/forms/ReconsumeForm.php
  56. 0 485
      common/models/forms/RegInfoAuditForm.php
  57. 0 104
      common/models/forms/RegTypeForm.php
  58. 0 367
      common/models/forms/ResendQYForm.php
  59. 0 359
      common/models/forms/SendCFAndLXForm.php
  60. 0 79
      common/models/forms/SmsApiForm.php
  61. 0 102
      common/models/forms/TransferBonusForm.php
  62. 0 375
      common/models/forms/TransferForm.php
  63. 0 310
      common/models/forms/UploadForm.php
  64. 0 377
      common/models/forms/UserBindForm.php
  65. 0 269
      common/models/forms/UserCloseForm.php
  66. 0 191
      common/models/forms/UserConfigForm.php
  67. 0 158
      common/models/forms/UserDecForm.php
  68. 50 428
      common/models/forms/UserForm.php
  69. 0 91
      common/models/forms/UserGroupForm.php
  70. 0 625
      common/models/forms/UserStatusForm.php
  71. 0 246
      common/models/forms/UserSystemForm.php
  72. 0 201
      common/models/forms/UserTeamForm.php
  73. 0 429
      common/models/forms/UserTeamworkForm.php
  74. 0 99
      common/models/forms/UserTransferPropForm.php
  75. 0 702
      common/models/forms/WithdrawForm.php
  76. 0 116
      common/models/forms/WithdrawLevelForm.php
  77. 0 68
      frontendApi/config/menu.php
  78. 20 25
      frontendApi/modules/v1/controllers/BonusController.php
  79. 0 5
      frontendApi/modules/v1/controllers/SiteController.php
  80. 31 31
      frontendEle/src/router/index.js
  81. 0 33
      frontendEle/src/views/dashboard/index.vue
  82. 0 7
      frontendEle/src/views/shop/index.vue
  83. 1 9
      frontendEle/src/views/shop/order-list.vue
  84. 1 17
      frontendEle/src/views/shop/order.vue
  85. 1 32
      frontendEle/src/views/user/index.vue

+ 126 - 126
common/models/Ad.php

@@ -1,126 +1,126 @@
-<?php
-
-namespace common\models;
-
-use backendApi\modules\v1\models\Admin;
-use Yii;
-use common\libs\logging\operate\valueType\Config as ValueTypeConfig;
-
-/**
- * This is the model class for table "{{%AD}}".
- *
- * @property string $ID
- * @property string $TITLE 标题
- * @property string $IMAGE 图片地址
- * @property int $TYPE 类型
- * @property string $LID 广告位ID
- * @property string $CONTENT 内容
- * @property int $SORT 排序
- * @property int $STATUS 状态
- * @property string $CREATE_ADMIN 创建管理员
- * @property string $UPDATE_ADMIN 更新管理员
- * @property int $CREATED_AT 创建时间
- * @property int $UPDATED_AT 更新时间
- */
-class Ad extends \common\components\ActiveRecord
-{
-    const TYPE_LINK = 1;        // 外链
-    const TYPE_ARTICLE = 2;     // 文章
-
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%AD}}';
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['TITLE', 'IMAGE', 'TYPE', 'LID', 'CREATE_ADMIN', 'CREATED_AT'], 'required'],
-            [['TYPE', 'SORT', 'STATUS', 'CREATED_AT', 'UPDATED_AT'], 'integer'],
-            [['ID', 'LID', 'CREATE_ADMIN', 'UPDATE_ADMIN'], 'string', 'max' => 32],
-            [['TITLE'], 'string', 'max' => 48],
-            [['IMAGE', 'CONTENT'], 'string', 'max' => 1000],
-            [['TITLE'], 'unique'],
-            [['ID'], 'unique'],
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function attributeLabels()
-    {
-        return [
-            'ID' => 'ID',
-            'TITLE' => '标题',
-            'IMAGE' => '图片地址',
-            'TYPE' => '类型',
-            'LID' => '广告位ID',
-            'CONTENT' => '内容',
-            'SORT' => '排序',
-            'STATUS' => '状态',
-            'CREATE_ADMIN' => '创建管理员',
-            'UPDATE_ADMIN' => '更新管理员',
-            'CREATED_AT' => '创建时间',
-            'UPDATED_AT' => '更新时间',
-        ];
-    }
-
-    /**
-     * 操作日志记录条件
-     * @return array
-     */
-    public function attrLabelsWithLogType(){
-        return [
-            'TITLE' => '标题',
-            'IMAGE' => '图片地址',
-            'TYPE' => [
-                'label' => '类型',
-                'type' => function($data){
-                    $value = $data['value'];
-                    return $value==1?'外链':'文章';
-                },
-            ],
-            'LID' => [
-                'label' => '广告位',
-                'type' => function($data){
-                    $value = $data['value'];
-                    $adLocation = AdLocation::findOneAsArray('ID=:ID', [':ID'=>$value], 'LOCATION_NAME');
-                    return $adLocation['LOCATION_NAME'];
-                },
-            ],
-            'CONTENT' => '内容',
-            'SORT' => '排序',
-            'CREATE_ADMIN' => [
-                'label' => '创建人',
-                'type' => function($data){
-                    $value = $data['value'];
-                    $result = Admin::findOneAsArray('ID=:ID', [':ID'=>$value], 'ADMIN_NAME');
-                    return $result['ADMIN_NAME'];
-                },
-            ],
-            'UPDATE_ADMIN' => [
-                'label' => '修改人',
-                'type' => function($data){
-                    $value = $data['value'];
-                    $result = Admin::findOneAsArray('ID=:ID', [':ID'=>$value], 'ADMIN_NAME');
-                    return $result['ADMIN_NAME'];
-                },
-            ],
-            'CREATED_AT' => [
-                'label' => '创建时间',
-                'type' => ValueTypeConfig::DATE_TIME_TYPE,
-            ],
-            'UPDATED_AT' => [
-                'label' => '修改时间',
-                'type' => ValueTypeConfig::DATE_TIME_TYPE,
-            ],
-        ];
-    }
-}
+<?php
+
+namespace common\models;
+
+use backendApi\modules\v1\models\Admin;
+use Yii;
+use common\libs\logging\operate\valueType\Config as ValueTypeConfig;
+
+/**
+ * This is the model class for table "{{%AD}}".
+ *
+ * @property string $ID
+ * @property string $TITLE 标题
+ * @property string $IMAGE 图片地址
+ * @property int $TYPE 类型
+ * @property string $LID 广告位ID
+ * @property string $CONTENT 内容
+ * @property int $SORT 排序
+ * @property int $STATUS 状态
+ * @property string $CREATE_ADMIN 创建管理员
+ * @property string $UPDATE_ADMIN 更新管理员
+ * @property int $CREATED_AT 创建时间
+ * @property int $UPDATED_AT 更新时间
+ */
+class Ad extends \common\components\ActiveRecord
+{
+    const TYPE_LINK = 1;        // 外链
+    const TYPE_ARTICLE = 2;     // 文章
+
+    /**
+     * @inheritdoc
+     */
+    public static function tableName()
+    {
+        return '{{%AD}}';
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['TITLE', 'IMAGE', 'TYPE', 'LID', 'CREATE_ADMIN', 'CREATED_AT'], 'required'],
+            [['TYPE', 'SORT', 'STATUS', 'CREATED_AT', 'UPDATED_AT'], 'integer'],
+            [['ID', 'LID', 'CREATE_ADMIN', 'UPDATE_ADMIN'], 'string', 'max' => 32],
+            [['TITLE'], 'string', 'max' => 48],
+            [['IMAGE', 'CONTENT'], 'string', 'max' => 1000],
+            [['TITLE'], 'unique'],
+            [['ID'], 'unique'],
+        ];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function attributeLabels()
+    {
+        return [
+            'ID' => 'ID',
+            'TITLE' => '标题',
+            'IMAGE' => '图片地址',
+            'TYPE' => '类型',
+            'LID' => '广告位ID',
+            'CONTENT' => '内容',
+            'SORT' => '排序',
+            'STATUS' => '状态',
+            'CREATE_ADMIN' => '创建管理员',
+            'UPDATE_ADMIN' => '更新管理员',
+            'CREATED_AT' => '创建时间',
+            'UPDATED_AT' => '更新时间',
+        ];
+    }
+
+    /**
+     * 操作日志记录条件
+     * @return array
+     */
+    public function attrLabelsWithLogType(){
+        return [
+            'TITLE' => '标题',
+            'IMAGE' => '图片地址',
+            'TYPE' => [
+                'label' => '类型',
+                'type' => function($data){
+                    $value = $data['value'];
+                    return $value==1?'外链':'文章';
+                },
+            ],
+            'LID' => [
+                'label' => '广告位',
+                'type' => function($data){
+                    $value = $data['value'];
+                    $adLocation = AdLocation::findOneAsArray('ID=:ID', [':ID'=>$value], 'LOCATION_NAME');
+                    return $adLocation['LOCATION_NAME'];
+                },
+            ],
+            'CONTENT' => '内容',
+            'SORT' => '排序',
+            'CREATE_ADMIN' => [
+                'label' => '创建人',
+                'type' => function($data){
+                    $value = $data['value'];
+                    $result = Admin::findOneAsArray('ID=:ID', [':ID'=>$value], 'ADMIN_NAME');
+                    return $result['ADMIN_NAME'];
+                },
+            ],
+            'UPDATE_ADMIN' => [
+                'label' => '修改人',
+                'type' => function($data){
+                    $value = $data['value'];
+                    $result = Admin::findOneAsArray('ID=:ID', [':ID'=>$value], 'ADMIN_NAME');
+                    return $result['ADMIN_NAME'];
+                },
+            ],
+            'CREATED_AT' => [
+                'label' => '创建时间',
+                'type' => ValueTypeConfig::DATE_TIME_TYPE,
+            ],
+            'UPDATED_AT' => [
+                'label' => '修改时间',
+                'type' => ValueTypeConfig::DATE_TIME_TYPE,
+            ],
+        ];
+    }
+}

+ 0 - 72
common/models/AdLocation.php

@@ -1,72 +0,0 @@
-<?php
-
-namespace common\models;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%AD_LOCATION}}".
- *
- * @property string $ID
- * @property string $LOCATION_NAME 分类名
- * @property string $REMARK 状态
- * @property int $TYPE 类型
- * @property string $CREATE_ADMIN 创建管理员
- * @property string $UPDATE_ADMIN 更新管理员
- * @property int $CREATED_AT 创建时间
- * @property int $UPDATED_AT 更新时间
- */
-class AdLocation extends \common\components\ActiveRecord
-{
-    const TYPE_SLIDE = 1;
-    const TYPE_IMAGE = 2;
-
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%AD_LOCATION}}';
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['LOCATION_NAME', 'REMARK', 'TYPE', 'CREATE_ADMIN', 'CREATED_AT'], 'required'],
-            [['TYPE', 'CREATED_AT', 'UPDATED_AT'], 'integer'],
-            [['ID', 'CREATE_ADMIN', 'UPDATE_ADMIN'], 'string', 'max' => 32],
-            [['LOCATION_NAME'], 'string', 'max' => 48],
-            [['REMARK'], 'string', 'max' => 255],
-            [['LOCATION_NAME'], 'unique'],
-            [['ID'], 'unique'],
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function attributeLabels()
-    {
-        return [
-            'ID' => 'ID',
-            'LOCATION_NAME' => '分类名',
-            'REMARK' => '状态',
-            'TYPE' => '类型',
-            'CREATE_ADMIN' => '创建管理员',
-            'UPDATE_ADMIN' => '更新管理员',
-            'CREATED_AT' => '创建时间',
-            'UPDATED_AT' => '更新时间',
-        ];
-    }
-
-    /**
-     * 获取全部广告为
-     * @return array
-     */
-    public static function getAllLocation(){
-        return static::find()->where('1=1')->orderBy('CREATED_AT DESC')->indexBy('ID')->asArray()->all();
-    }
-}

+ 0 - 162
common/models/BalanceAudit.php

@@ -1,162 +0,0 @@
-<?php
-
-namespace common\models;
-
-use backendApi\modules\v1\models\Admin;
-use common\helpers\user\Info;
-use Yii;
-use common\libs\logging\operate\valueType\Config as ValueTypeConfig;
-
-/**
- * This is the model class for table "{{%BALANCE_AUDIT}}".
- *
- * @property string $ID
- * @property string $USER_ID 会员ID
- * @property string $LAST_DEC_LV 申请时会员级别
- * @property string $LAST_EMP_LV 申请时会员聘级
- * @property string $LAST_DEC_ROLE_ID 申请时报单中心级别
- * @property string $TYPE 余额类型
- * @property string $DEAL_TYPE 交易类型
- * @property string $AMOUNT 金额
- * @property int $AUDIT_STATUS 状态
- * @property string $UPDATE_ADMIN_ID 变更管理员
- * @property string $AUDIT_ADMIN_ID 审核管理员
- * @property string $CREATE_REMARK 创建备注
- * @property string $AUDIT_REMARK 审核备注
- * @property int $REMARK_IS_SHOW 前台是否展示
- * @property int $CREATED_AT 创建时间
- * @property int $AUDITED_AT  审核时间
- */
-class BalanceAudit extends \common\components\ActiveRecord
-{
-    const TYPE = [
-        'bonus' => [
-            'name' => 'bonus',
-            'label' => '会员账户奖金',
-        ],
-        'reconsume_points' => [
-            'name' => 'reconsume_points',
-            'label' => '复消积分',
-        ],
-        'cash' => [
-            'name' => 'cash',
-            'label' => '会员账户余额',
-        ],
-//        'cf' => [
-//            'name' => 'cf',
-//            'label' => '车房养老奖余额',
-//        ],
-//        'lx' => [
-//            'name' => 'lx',
-//            'label' => '领袖分红奖余额',
-//        ],
-    ];
-
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%BALANCE_AUDIT}}';
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function rules()
-    {
-        return [
-            [['USER_ID', 'TYPE', 'DEAL_TYPE', 'CREATED_AT'], 'required'],
-            [['AMOUNT'], 'number'],
-            [['AUDIT_STATUS', 'REMARK_IS_SHOW', 'CREATED_AT', 'AUDITED_AT'], 'integer'],
-            [['ID', 'USER_ID', 'LAST_DEC_LV', 'LAST_EMP_LV', 'LAST_DEC_ROLE_ID', 'DEAL_TYPE', 'UPDATE_ADMIN_ID', 'AUDIT_ADMIN_ID'], 'string', 'max' => 32],
-            [['TYPE'], 'string', 'max' => 48],
-            [['CREATE_REMARK', 'AUDIT_REMARK'], 'string', 'max' => 4000],
-            [['ID'], 'unique'],
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function attributeLabels()
-    {
-        return [
-            'ID' => 'ID',
-            'USER_ID' => '会员ID',
-            'LAST_DEC_LV' => '申请时会员级别',
-            'LAST_EMP_LV' => '申请时会员聘级',
-            'LAST_DEC_ROLE_ID' => '申请时报单中心级别',
-            'TYPE' => '余额类型',
-            'DEAL_TYPE' => '交易类型',
-            'AMOUNT' => '金额',
-            'AUDIT_STATUS' => '状态',
-            'UPDATE_ADMIN_ID' => '变更管理员',
-            'AUDIT_ADMIN_ID' => '审核管理员',
-            'CREATE_REMARK' => '创建备注',
-            'AUDIT_REMARK' => '审核备注',
-            'REMARK_IS_SHOW' => '前台是否展示',
-            'CREATED_AT' => '创建时间',
-            'AUDITED_AT' => ' 审核时间',
-        ];
-    }
-
-    /**
-     * 操作日志记录条件
-     * @return array
-     */
-    public function attrLabelsWithLogType(){
-        return [
-            'USER_ID' => '会员ID',
-            'TYPE' => [
-                'label' => '余额类型',
-                'type' => function($data){
-                    $value = $data['value'];
-                    return \Yii::$app->params['bonusWalletType'][$value]['label'];
-                },
-            ],
-            'DEAL_TYPE' => [
-                'label' => '交易类型',
-                'type' => function($data){
-                    $value = $data['value'];
-                    $dealType = DealType::findOneAsArray('ID=:ID', [':ID'=>$value], 'TYPE_NAME');
-                    return $dealType['TYPE_NAME'];
-                },
-            ],
-            'AMOUNT' => '金额',
-            'AUDIT_STATUS' => [
-                'label' => '审核状态',
-                'type' => ValueTypeConfig::AUDIT_STATUS_TYPE,
-            ],
-            'UPDATE_ADMIN_ID' => [
-                'label' => '变更管理员',
-                'type' => function($data){
-                    $value = $data['value'];
-                    $result = Admin::findOneAsArray('ID=:ID', [':ID'=>$value], 'ADMIN_NAME');
-                    return $result['ADMIN_NAME'];
-                },
-            ],
-            'AUDIT_ADMIN_ID' => [
-                'label' => '审核管理员',
-                'type' => function($data){
-                    $value = $data['value'];
-                    $result = Admin::findOneAsArray('ID=:ID', [':ID'=>$value], 'ADMIN_NAME');
-                    return $result['ADMIN_NAME'];
-                },
-            ],
-            'CREATE_REMARK' => '备注',
-            'REMARK_IS_SHOW' => [
-                'label' => '前台是否显示备注',
-                'type' => ValueTypeConfig::YES_NO_TYPE,
-            ],
-            'CREATED_AT' => [
-                'label' => '创建时间',
-                'type' => ValueTypeConfig::DATE_TIME_TYPE,
-            ],
-            'AUDITED_AT' => [
-                'label' => '审核时间',
-                'type' => ValueTypeConfig::DATE_TIME_TYPE,
-            ],
-        ];
-    }
-}

+ 0 - 102
common/models/CFLXAudit.php

@@ -1,102 +0,0 @@
-<?php
-
-namespace common\models;
-
-use Yii;
-use common\libs\logging\operate\valueType\Config as ValueTypeConfig;
-
-/**
- * This is the model class for table "{{%CF_LX_AUDIT}}".
- *
- * @property string $ID
- * @property string $USER_ID
- * @property string $CF 车房养老
- * @property string $LX 领袖分红
- * @property int $YEAR 类型
- * @property int $AUDIT_STATUS 审核状态
- * @property string $CREATE_ADMIN 创建管理员
- * @property string $AUDIT_ADMIN 审核管理员
- * @property string $CREATE_REMARK 申请备注
- * @property string $AUDIT_REMARK 审核备注
- * @property int $CREATED_AT 创建时间
- * @property int $AUDITED_AT 审核时间
- */
-class CFLXAudit extends \common\components\ActiveRecord
-{
-    /**
-     * {@inheritdoc}
-     */
-    public static function tableName()
-    {
-        return '{{%CF_LX_AUDIT}}';
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function rules()
-    {
-        return [
-            [['YEAR', 'AUDIT_STATUS', 'CREATED_AT', 'AUDITED_AT'], 'integer'],
-            [['CREATE_ADMIN', 'CREATED_AT', 'USER_ID'], 'required'],
-            [['CF','LX'], 'number'],
-            [['ID', 'USER_ID', 'CREATE_ADMIN', 'AUDIT_ADMIN'], 'string', 'max' => 32],
-            [['CREATE_REMARK', 'AUDIT_REMARK'], 'string', 'max' => 4000],
-            [['ID'], 'unique'],
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function attributeLabels()
-    {
-        return [
-            'ID' => 'ID',
-            'USER_ID' => '用户ID',
-            'LX' => '车房养老',
-            'CF' => '领袖分红',
-            'YEAR' => '年',
-            'AUDIT_STATUS' => '审核状态',
-            'CREATE_ADMIN' => '创建管理员',
-            'AUDIT_ADMIN' => '审核管理员',
-            'CREATE_REMARK' => '申请备注',
-            'AUDIT_REMARK' => '审核备注',
-            'CREATED_AT' => '创建时间',
-            'AUDITED_AT' => '审核时间',
-        ];
-    }
-
-    /**
-     * 操作日志记录条件
-     * @return array
-     */
-    public function attrLabelsWithLogType(){
-        return [
-            'USER_ID' => '会员ID',
-            'CF' => '车房养老',
-            'LX' => '领袖分红',
-            'AUDIT_STATUS' => [
-                'label' => '审核状态',
-                'type' => ValueTypeConfig::AUDIT_STATUS_TYPE,
-            ],
-            'CREATE_ADMIN' => [
-                'label' => '申请管理员',
-                'type' => ValueTypeConfig::ADMIN_TYPE,
-            ],
-            'AUDIT_ADMIN' => [
-                'label' => '审核管理员',
-                'type' => ValueTypeConfig::ADMIN_TYPE,
-            ],
-            'CREATE_REMARK' => '备注',
-            'CREATED_AT' => [
-                'label' => '申请时间',
-                'type' => ValueTypeConfig::DATE_TIME_TYPE,
-            ],
-            'AUDITED_AT' => [
-                'label' => '审核时间',
-                'type' => ValueTypeConfig::DATE_TIME_TYPE,
-            ],
-        ];
-    }
-}

+ 0 - 80
common/models/CalcBonusBD.php

@@ -1,80 +0,0 @@
-<?php
-
-namespace common\models;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%CALC_BONUS_BD}}".
- *
- * @property string $ID
- * @property string $USER_ID 会员ID
- * @property string $LAST_DEC_LV 结算时会员级别
- * @property string $LAST_EMP_LV 结算时会员聘级
- * @property int $LAST_STATUS 结算时状态
- * @property string $FROM_USER_ID 来源会员ID
- * @property string $LAST_FROM_DEC_LV 结算时来源会员级别
- * @property string $LAST_FROM_EMP_LV 结算时来源会员聘级
- * @property int $LAST_FROM_STATUS 结算时来源状态
- * @property string $AMOUNT 金额
- * @property int $PERIOD_NUM 结算期数
- * @property int $CALC_MONTH 所在结算月
- * @property int $CALCULATED_AT 结算时间
- * @property int $CREATED_AT 创建时间
- * @property string $LOGS 日志
- * @property $ORI_BONUS 原奖金
- * @property $RECONSUME_POINTS 重复消费积分
- * @property $MANAGE_TAX 管理费
- */
-class CalcBonusBD extends \common\components\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%CALC_BONUS_BD}}';
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['USER_ID', 'PERIOD_NUM', 'CALC_MONTH', 'CALCULATED_AT', 'CREATED_AT'], 'required'],
-            [['AMOUNT', 'ORI_BONUS', 'RECONSUME_POINTS', 'MANAGE_TAX'], 'number'],
-            [['LAST_STATUS', 'PERIOD_NUM', 'CALC_MONTH', 'CALCULATED_AT', 'CREATED_AT', 'LAST_FROM_STATUS'], 'integer'],
-            [['ID', 'USER_ID', 'LAST_DEC_LV', 'LAST_EMP_LV', 'FROM_USER_ID',  'LAST_FROM_DEC_LV', 'LAST_FROM_EMP_LV'], 'string', 'max' => 32],
-            [['LOGS'], 'string', 'max' => 2000],
-            [['ID'], 'unique'],
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function attributeLabels()
-    {
-        return [
-            'ID' => 'ID',
-            'USER_ID' => '会员ID',
-            'LAST_DEC_LV' => '结算时会员级别',
-            'LAST_EMP_LV' => '结算时会员聘级',
-            'LAST_STATUS' => '结算时状态',
-            'FROM_USER_ID' => '来源会员ID',
-            'LAST_FROM_DEC_LV' => '结算时来源会员级别',
-            'LAST_FROM_EMP_LV' => '结算时来源会员聘级',
-            'LAST_FROM_STATUS' => '结算时来源状态',
-            'AMOUNT' => '金额',
-            'PERIOD_NUM' => '结算期数',
-            'CALC_MONTH' => '所在结算月',
-            'CALCULATED_AT' => '结算时间',
-            'CREATED_AT' => '创建时间',
-            'LOGS' => '日志',
-            'ORI_BONUS' => '原奖金',
-            'RECONSUME_POINTS' => '重复消费积分',
-            'MANAGE_TAX' => '管理费',
-        ];
-    }
-}

+ 0 - 111
common/models/CalcBonusBT.php

@@ -1,111 +0,0 @@
-<?php
-
-namespace common\models;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%CALC_BONUS_BT}}".
- *
- * @property string $ID
- * @property string $USER_ID 会员ID
- * @property string $LAST_DEC_LV 结算时会员级别
- * @property string $LAST_EMP_LV 结算时会员聘级
- * @property int $LAST_STATUS 结算时会员状态
- * @property string $FROM_USER_ID 来源会员ID
- * @property string $LAST_FROM_DEC_LV 结算时来源会员级别
- * @property string $LAST_FROM_EMP_LV 结算时来源会员聘级
- * @property int $LAST_FROM_STATUS 结算时来源会员状态
- * @property string $LAST_DEC_ROLE_ID 结算时会员报单级别
- * @property string $BT_TYPE 补贴类型
- * @property string $FROM_ORDER_SN 来源订单编号
- * @property int $ORDER_TIME 订货时间
- * @property int $ORDER_PERIOD 订货期数
- * @property int $DELIVERY_AT 发货时间
- * @property int $DELIVERY_PERIOD 发货期数
- * @property string $PAY_AMOUNT 订货金额
- * @property string $PAY_PV 订货积分
- * @property string $TRANSFER_SN 转账记录流水号
- * @property string $TRANSFER_AMOUNT 转账金额
- * @property int $TRANSFER_AT 转账时间
- * @property int $TRANSFER_PERIOD 转账期数
- * @property string $AMOUNT 店补金额
- * @property string $LOGS 日志
- * @property int $PERIOD_NUM 结算期数
- * @property int $CALC_YEAR 所在结算年
- * @property int $CALC_MONTH 所在结算月
- * @property string $P_CALC_MONTH 表分区的日期索引
- * @property int $CREATED_AT 创建时间
- */
-class CalcBonusBT extends \common\components\ActiveRecord
-{
-    const TYPE_NAME = [
-        'ORDER' => '服务费',//'订货店补',
-        'TRANS' => '转账补助',//'转账店补',
-        'PROD' => '产品补贴',//'产品补贴',
-        'TOOL' => '工具流补贴',//'工具流补贴',
-    ];
-
-    /**
-     * {@inheritdoc}
-     */
-    public static function tableName()
-    {
-        return '{{%CALC_BONUS_BT}}';
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function rules()
-    {
-        return [
-            [['USER_ID', 'FROM_USER_ID', 'BT_TYPE', 'PERIOD_NUM', 'CALC_YEAR', 'CALC_MONTH', 'P_CALC_MONTH', 'CREATED_AT'], 'required'],
-            [['LAST_STATUS', 'LAST_FROM_STATUS', 'ORDER_TIME', 'ORDER_PERIOD', 'DELIVERY_AT', 'DELIVERY_PERIOD', 'TRANSFER_AT', 'TRANSFER_PERIOD', 'PERIOD_NUM', 'CALC_YEAR', 'CALC_MONTH', 'CREATED_AT'], 'integer'],
-            [['PAY_AMOUNT', 'PAY_PV', 'TRANSFER_AMOUNT', 'AMOUNT'], 'number'],
-            [['ID', 'USER_ID', 'LAST_DEC_LV', 'LAST_EMP_LV', 'FROM_USER_ID', 'LAST_FROM_DEC_LV', 'LAST_FROM_EMP_LV', 'LAST_DEC_ROLE_ID', 'FROM_ORDER_SN', 'TRANSFER_SN'], 'string', 'max' => 32],
-            [['BT_TYPE'], 'string', 'max' => 8],
-            [['LOGS'], 'string', 'max' => 2000],
-            [['P_CALC_MONTH'], 'string', 'max' => 7],
-            [['ID'], 'unique'],
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function attributeLabels()
-    {
-        return [
-            'ID' => 'ID',
-            'USER_ID' => '会员ID',
-            'LAST_DEC_LV' => '结算时会员级别',
-            'LAST_EMP_LV' => '结算时会员聘级',
-            'LAST_STATUS' => '结算时会员状态',
-            'FROM_USER_ID' => '来源会员ID',
-            'LAST_FROM_DEC_LV' => '结算时来源会员级别',
-            'LAST_FROM_EMP_LV' => '结算时来源会员聘级',
-            'LAST_FROM_STATUS' => '结算时来源会员状态',
-            'LAST_DEC_ROLE_ID' => '结算时会员报单级别',
-            'BT_TYPE' => '补贴类型',
-            'FROM_ORDER_SN' => '来源订单编号',
-            'ORDER_TIME' => '订货时间',
-            'ORDER_PERIOD' => '订货期数',
-            'DELIVERY_AT' => '发货时间',
-            'DELIVERY_PERIOD' => '发货期数',
-            'PAY_AMOUNT' => '订货金额',
-            'PAY_PV' => '订货积分',
-            'TRANSFER_SN' => '转账记录流水号',
-            'TRANSFER_AMOUNT' => '转账金额',
-            'TRANSFER_AT' => '转账时间',
-            'TRANSFER_PERIOD' => '转账期数',
-            'AMOUNT' => '店补金额',
-            'LOGS' => '日志',
-            'PERIOD_NUM' => '结算期数',
-            'CALC_YEAR' => '所在结算年',
-            'CALC_MONTH' => '所在结算月',
-            'P_CALC_MONTH' => '表分区的日期索引',
-            'CREATED_AT' => '创建时间',
-        ];
-    }
-}

+ 0 - 73
common/models/CalcBonusCF.php

@@ -1,73 +0,0 @@
-<?php
-
-namespace common\models;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%CALC_BONUS_CF}}".
- *
- * @property string $ID
- * @property string $USER_ID 会员ID
- * @property string $LAST_DEC_LV 结算时会员级别
- * @property string $LAST_EMP_LV 结算时会员聘级
- * @property int $LAST_STATUS 结算时状态
- * @property string $FROM_USER_ID 来源会员ID
- * @property string $FROM_DEC_SN 来源报单编号
- * @property string $AMOUNT 奖金金额
- * @property int $PERIOD_NUM 结算期数
- * @property int $CALC_YEAR 所在结算年
- * @property int $CALC_MONTH 所在结算月
- * @property string $P_CALC_MONTH 表分区的日期索引
- * @property string $LOGS 日志
- * @property int $CREATED_AT 创建时间
- */
-class CalcBonusCF extends \common\components\ActiveRecord
-{
-    /**
-     * {@inheritdoc}
-     */
-    public static function tableName()
-    {
-        return '{{%CALC_BONUS_CF}}';
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function rules()
-    {
-        return [
-            [['USER_ID', 'FROM_USER_ID', 'FROM_DEC_SN', 'PERIOD_NUM', 'CALC_YEAR', 'CALC_MONTH', 'P_CALC_MONTH', 'CREATED_AT'], 'required'],
-            [['AMOUNT'], 'number'],
-            [['LAST_STATUS', 'PERIOD_NUM', 'CALC_YEAR', 'CALC_MONTH', 'CREATED_AT'], 'integer'],
-            [['ID', 'USER_ID', 'FROM_USER_ID', 'FROM_DEC_SN', 'LAST_DEC_LV', 'LAST_EMP_LV'], 'string', 'max' => 32],
-            [['P_CALC_MONTH'], 'safe'],
-            [['LOGS'], 'string', 'max' => 2000],
-            [['ID'], 'unique'],
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function attributeLabels()
-    {
-        return [
-            'ID' => 'ID',
-            'USER_ID' => '会员ID',
-            'LAST_DEC_LV' => '结算时会员级别',
-            'LAST_EMP_LV' => '结算时会员聘级',
-            'LAST_STATUS' => '结算时状态',
-            'FROM_USER_ID' => '来源会员ID',
-            'FROM_DEC_SN' => '来源报单编号',
-            'AMOUNT' => '奖金金额',
-            'PERIOD_NUM' => '结算期数',
-            'CALC_YEAR' => '所在结算年',
-            'CALC_MONTH' => '所在结算月',
-            'P_CALC_MONTH' => '表分区的日期索引',
-            'LOGS' => '日志',
-            'CREATED_AT' => '创建时间',
-        ];
-    }
-}

+ 0 - 79
common/models/CalcBonusFL.php

@@ -1,79 +0,0 @@
-<?php
-
-namespace common\models;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%CALC_BONUS_FL}}".
- *
- * @property string $ID
- * @property string $USER_ID 会员ID
- * @property string $LAST_DEC_ROLE_ID 结算时报单级别
- * @property string $DEC_SN 报单编号
- * @property string $TO_USER_ID 被报单会员ID
- * @property int $DEC_AT 报单时间
- * @property int $DEC_PERIOD 报单期数
- * @property string $DEC_AMOUNT 报单金额
- * @property string $DEC_PV 报单PV
- * @property string $AMOUNT 奖金金额
- * @property int $PERIOD_NUM 结算期数
- * @property int $CALC_YEAR 所在结算年
- * @property int $CALC_MONTH 所在结算月
- * @property string $P_CALC_MONTH 表分区的日期索引
- * @property string $ORDER_PV 区域业绩
- * @property string $LOGS 日志
- * @property int $CREATED_AT 创建时间
- */
-class CalcBonusFL extends \common\components\ActiveRecord
-{
-    /**
-     * {@inheritdoc}
-     */
-    public static function tableName()
-    {
-        return '{{%CALC_BONUS_FL}}';
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function rules()
-    {
-        return [
-            [['USER_ID', 'LAST_DEC_ROLE_ID', 'DEC_SN', 'TO_USER_ID', 'PERIOD_NUM', 'CALC_YEAR', 'CALC_MONTH', 'P_CALC_MONTH', 'CREATED_AT'], 'required'],
-            [['DEC_AT', 'DEC_PERIOD', 'PERIOD_NUM', 'CALC_YEAR', 'CALC_MONTH', 'CREATED_AT'], 'integer'],
-            [['DEC_AMOUNT', 'DEC_PV', 'AMOUNT', 'ORDER_PV'], 'number'],
-            [['ID', 'USER_ID', 'LAST_DEC_ROLE_ID', 'DEC_SN', 'TO_USER_ID'], 'string', 'max' => 32],
-            [['P_CALC_MONTH'], 'string', 'max' => 7],
-            [['LOGS'], 'string', 'max' => 2000],
-            [['ID'], 'unique'],
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function attributeLabels()
-    {
-        return [
-            'ID' => 'ID',
-            'USER_ID' => '会员ID',
-            'LAST_DEC_ROLE_ID' => '结算时报单级别',
-            'DEC_SN' => '报单编号',
-            'TO_USER_ID' => '被报单会员ID',
-            'DEC_AT' => '报单时间',
-            'DEC_PERIOD' => '报单期数',
-            'DEC_AMOUNT' => '报单金额',
-            'DEC_PV' => '报单PV',
-            'AMOUNT' => '奖金金额',
-            'PERIOD_NUM' => '结算期数',
-            'CALC_YEAR' => '所在结算年',
-            'CALC_MONTH' => '所在结算月',
-            'P_CALC_MONTH' => '表分区的日期索引',
-            'ORDER_PV' => '区域业绩',
-            'LOGS' => '日志',
-            'CREATED_AT' => '创建时间',
-        ];
-    }
-}

+ 0 - 80
common/models/CalcBonusFW.php

@@ -1,80 +0,0 @@
-<?php
-
-namespace common\models;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%CALC_BONUS_FW}}".
- *
- * @property string $ID
- * @property string $USER_ID 会员ID
- * @property string $LAST_DEC_LV 结算时会员级别
- * @property string $LAST_EMP_LV 结算时会员聘级
- * @property int $LAST_STATUS 结算时状态
- * @property string $FROM_USER_ID 来源会员ID
- * @property string $LAST_FROM_DEC_LV 结算时来源会员级别
- * @property string $LAST_FROM_EMP_LV 结算时来源会员聘级
- * @property int $LAST_FROM_STATUS 结算时来源状态
- * @property string $AMOUNT 金额
- * @property int $PERIOD_NUM 结算期数
- * @property int $CALC_MONTH 所在结算月
- * @property int $CALCULATED_AT 结算时间
- * @property int $CREATED_AT 创建时间
- * @property string $LOGS 日志
- * @property $ORI_BONUS 原奖金
- * @property $RECONSUME_POINTS 重复消费积分
- * @property $MANAGE_TAX 管理费
- */
-class CalcBonusFW extends \common\components\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%CALC_BONUS_FW}}';
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['USER_ID', 'PERIOD_NUM', 'CALC_MONTH', 'CALCULATED_AT', 'CREATED_AT'], 'required'],
-            [['AMOUNT', 'ORI_BONUS', 'RECONSUME_POINTS', 'MANAGE_TAX'], 'number'],
-            [['LAST_STATUS', 'PERIOD_NUM', 'CALC_MONTH', 'CALCULATED_AT', 'CREATED_AT', 'LAST_FROM_STATUS'], 'integer'],
-            [['ID', 'USER_ID', 'LAST_DEC_LV', 'LAST_EMP_LV', 'FROM_USER_ID',  'LAST_FROM_DEC_LV', 'LAST_FROM_EMP_LV'], 'string', 'max' => 32],
-            [['LOGS'], 'string', 'max' => 2000],
-            [['ID'], 'unique'],
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function attributeLabels()
-    {
-        return [
-            'ID' => 'ID',
-            'USER_ID' => '会员ID',
-            'LAST_DEC_LV' => '结算时会员级别',
-            'LAST_EMP_LV' => '结算时会员聘级',
-            'LAST_STATUS' => '结算时状态',
-            'FROM_USER_ID' => '来源会员ID',
-            'LAST_FROM_DEC_LV' => '结算时来源会员级别',
-            'LAST_FROM_EMP_LV' => '结算时来源会员聘级',
-            'LAST_FROM_STATUS' => '结算时来源状态',
-            'AMOUNT' => '金额',
-            'PERIOD_NUM' => '结算期数',
-            'CALC_MONTH' => '所在结算月',
-            'CALCULATED_AT' => '结算时间',
-            'CREATED_AT' => '创建时间',
-            'LOGS' => '日志',
-            'ORI_BONUS' => '原奖金',
-            'RECONSUME_POINTS' => '重复消费积分',
-            'MANAGE_TAX' => '管理费',
-        ];
-    }
-}

+ 0 - 77
common/models/CalcBonusFX.php

@@ -1,77 +0,0 @@
-<?php
-
-namespace common\models;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%CALC_BONUS_FX}}".
- *
- * @property string $ID
- * @property string $USER_ID 会员ID
- * @property string $LAST_DEC_LV 结算时会员级别
- * @property string $LAST_EMP_LV 结算时会员聘级
- * @property int $LAST_STATUS 结算时状态
- * @property string $FROM_USER_ID 来源会员ID
- * @property string $LAST_FROM_DEC_LV 结算时来源会员级别
- * @property string $LAST_FROM_EMP_LV 结算时来源会员聘级
- * @property int $LAST_FROM_STATUS 结算时来源状态
- * @property int $DEEP 深度
- * @property string $AMOUNT 奖金金额
- * @property int $PERIOD_NUM 结算期数
- * @property int $CALC_MONTH 所在结算月
- * @property string $P_CALC_MONTH 表分区的日期索引
- * @property int $CREATED_AT 创建时间
- * @property string $LOGS 日志
- */
-class CalcBonusFX extends \common\components\ActiveRecord
-{
-    /**
-     * {@inheritdoc}
-     */
-    public static function tableName()
-    {
-        return '{{%CALC_BONUS_FX}}';
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function rules()
-    {
-        return [
-            [['USER_ID', 'FROM_USER_ID', 'DEEP', 'PERIOD_NUM', 'CALC_MONTH', 'P_CALC_MONTH', 'CREATED_AT'], 'required'],
-            [['LAST_STATUS', 'LAST_FROM_STATUS', 'DEEP', 'PERIOD_NUM', 'CALC_MONTH', 'CREATED_AT'], 'integer'],
-            [['AMOUNT'], 'number'],
-            [['ID', 'USER_ID', 'FROM_USER_ID', 'LAST_DEC_LV', 'LAST_EMP_LV', 'LAST_FROM_DEC_LV', 'LAST_FROM_EMP_LV'], 'string', 'max' => 32],
-            [['P_CALC_MONTH'], 'safe'],
-            [['LOGS'], 'string', 'max' => 2000],
-            [['ID'], 'unique'],
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function attributeLabels()
-    {
-        return [
-            'ID' => 'ID',
-            'USER_ID' => '会员ID',
-            'LAST_DEC_LV' => '结算时会员级别',
-            'LAST_EMP_LV' => '结算时会员聘级',
-            'LAST_STATUS' => '结算时状态',
-            'FROM_USER_ID' => '来源会员ID',
-            'LAST_FROM_DEC_LV' => '结算时来源会员级别',
-            'LAST_FROM_EMP_LV' => '结算时来源会员聘级',
-            'LAST_FROM_STATUS' => '结算时来源状态',
-            'DEEP' => '深度',
-            'AMOUNT' => '奖金金额',
-            'PERIOD_NUM' => '结算期数',
-            'CALC_MONTH' => '所在结算月',
-            'P_CALC_MONTH' => '表分区的日期索引',
-            'CREATED_AT' => '创建时间',
-            'LOGS' => '日志',
-        ];
-    }
-}

+ 0 - 80
common/models/CalcBonusGL.php

@@ -1,80 +0,0 @@
-<?php
-
-namespace common\models;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%CALC_BONUS_GL}}".
- *
- * @property string $ID
- * @property string $USER_ID 会员ID
- * @property string $LAST_DEC_LV 结算时会员级别
- * @property string $LAST_EMP_LV 结算时会员聘级
- * @property int $LAST_STATUS 结算时状态
- * @property string $FROM_USER_ID 来源会员ID
- * @property string $LAST_FROM_DEC_LV 结算时来源会员级别
- * @property string $LAST_FROM_EMP_LV 结算时来源会员聘级
- * @property int $LAST_FROM_STATUS 结算时来源状态
- * @property string $AMOUNT 金额
- * @property int $PERIOD_NUM 结算期数
- * @property int $CALC_MONTH 所在结算月
- * @property int $CALCULATED_AT 结算时间
- * @property int $CREATED_AT 创建时间
- * @property string $LOGS 日志
- * @property $ORI_BONUS 原奖金
- * @property $RECONSUME_POINTS 重复消费积分
- * @property $MANAGE_TAX 管理费
- */
-class CalcBonusGL extends \common\components\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%CALC_BONUS_GL}}';
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['USER_ID', 'PERIOD_NUM', 'CALC_MONTH', 'CALCULATED_AT', 'CREATED_AT'], 'required'],
-            [['AMOUNT', 'ORI_BONUS', 'RECONSUME_POINTS', 'MANAGE_TAX'], 'number'],
-            [['LAST_STATUS', 'PERIOD_NUM', 'CALC_MONTH', 'CALCULATED_AT', 'CREATED_AT', 'LAST_FROM_STATUS'], 'integer'],
-            [['ID', 'USER_ID', 'LAST_DEC_LV', 'LAST_EMP_LV', 'FROM_USER_ID',  'LAST_FROM_DEC_LV', 'LAST_FROM_EMP_LV'], 'string', 'max' => 32],
-            [['LOGS'], 'string', 'max' => 2000],
-            [['ID'], 'unique'],
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function attributeLabels()
-    {
-        return [
-            'ID' => 'ID',
-            'USER_ID' => '会员ID',
-            'LAST_DEC_LV' => '结算时会员级别',
-            'LAST_EMP_LV' => '结算时会员聘级',
-            'LAST_STATUS' => '结算时状态',
-            'FROM_USER_ID' => '来源会员ID',
-            'LAST_FROM_DEC_LV' => '结算时来源会员级别',
-            'LAST_FROM_EMP_LV' => '结算时来源会员聘级',
-            'LAST_FROM_STATUS' => '结算时来源状态',
-            'AMOUNT' => '金额',
-            'PERIOD_NUM' => '结算期数',
-            'CALC_MONTH' => '所在结算月',
-            'CALCULATED_AT' => '结算时间',
-            'CREATED_AT' => '创建时间',
-            'LOGS' => '日志',
-            'ORI_BONUS' => '原奖金',
-            'RECONSUME_POINTS' => '重复消费积分',
-            'MANAGE_TAX' => '管理费',
-        ];
-    }
-}

+ 0 - 80
common/models/CalcBonusGX.php

@@ -1,80 +0,0 @@
-<?php
-
-namespace common\models;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%CALC_BONUS_GX}}".
- *
- * @property string $ID
- * @property string $USER_ID 会员ID
- * @property string $LAST_DEC_LV 结算时会员级别
- * @property string $LAST_EMP_LV 结算时会员聘级
- * @property int $LAST_STATUS 结算时状态
- * @property string $FROM_USER_ID 来源会员ID
- * @property string $LAST_FROM_DEC_LV 结算时来源会员级别
- * @property string $LAST_FROM_EMP_LV 结算时来源会员聘级
- * @property int $LAST_FROM_STATUS 结算时来源状态
- * @property string $AMOUNT 金额
- * @property int $PERIOD_NUM 结算期数
- * @property int $CALC_MONTH 所在结算月
- * @property int $CALCULATED_AT 结算时间
- * @property int $CREATED_AT 创建时间
- * @property string $LOGS 日志
- * @property $ORI_BONUS 原奖金
- * @property $RECONSUME_POINTS 重复消费积分
- * @property $MANAGE_TAX 管理费
- */
-class CalcBonusGX extends \common\components\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%CALC_BONUS_GX}}';
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['USER_ID', 'PERIOD_NUM', 'CALC_MONTH', 'CALCULATED_AT', 'CREATED_AT'], 'required'],
-            [['AMOUNT', 'ORI_BONUS', 'RECONSUME_POINTS', 'MANAGE_TAX'], 'number'],
-            [['LAST_STATUS', 'PERIOD_NUM', 'CALC_MONTH', 'CALCULATED_AT', 'CREATED_AT', 'LAST_FROM_STATUS'], 'integer'],
-            [['ID', 'USER_ID', 'LAST_DEC_LV', 'LAST_EMP_LV', 'FROM_USER_ID',  'LAST_FROM_DEC_LV', 'LAST_FROM_EMP_LV'], 'string', 'max' => 32],
-            [['LOGS'], 'string', 'max' => 2000],
-            [['ID'], 'unique'],
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function attributeLabels()
-    {
-        return [
-            'ID' => 'ID',
-            'USER_ID' => '会员ID',
-            'LAST_DEC_LV' => '结算时会员级别',
-            'LAST_EMP_LV' => '结算时会员聘级',
-            'LAST_STATUS' => '结算时状态',
-            'FROM_USER_ID' => '来源会员ID',
-            'LAST_FROM_DEC_LV' => '结算时来源会员级别',
-            'LAST_FROM_EMP_LV' => '结算时来源会员聘级',
-            'LAST_FROM_STATUS' => '结算时来源状态',
-            'AMOUNT' => '金额',
-            'PERIOD_NUM' => '结算期数',
-            'CALC_MONTH' => '所在结算月',
-            'CALCULATED_AT' => '结算时间',
-            'CREATED_AT' => '创建时间',
-            'LOGS' => '日志',
-            'ORI_BONUS' => '原奖金',
-            'RECONSUME_POINTS' => '重复消费积分',
-            'MANAGE_TAX' => '管理费',
-        ];
-    }
-}

+ 0 - 73
common/models/CalcBonusLS.php

@@ -1,73 +0,0 @@
-<?php
-
-namespace common\models;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%CALC_BONUS_LS}}".
- *
- * @property string $ID
- * @property string $USER_ID 会员ID
- * @property string $LAST_DEC_LV 结算时会员级别
- * @property string $LAST_EMP_LV 结算时会员聘级
- * @property int $LAST_STATUS 结算时状态
- * @property string $FROM_USER_ID 来源会员ID
- * @property string $FROM_DEC_SN 来源报单编号
- * @property string $AMOUNT 奖金金额
- * @property int $PERIOD_NUM 结算期数
- * @property int $CALC_YEAR 所在结算年
- * @property int $CALC_MONTH 所在结算月
- * @property string $P_CALC_MONTH 表分区的日期索引
- * @property string $LOGS 日志
- * @property int $CREATED_AT 创建时间
- */
-class CalcBonusLS extends \common\components\ActiveRecord
-{
-    /**
-     * {@inheritdoc}
-     */
-    public static function tableName()
-    {
-        return '{{%CALC_BONUS_LS}}';
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function rules()
-    {
-        return [
-            [['USER_ID', 'FROM_USER_ID', 'FROM_DEC_SN', 'PERIOD_NUM', 'CALC_YEAR', 'CALC_MONTH', 'P_CALC_MONTH', 'CREATED_AT'], 'required'],
-            [['AMOUNT'], 'number'],
-            [['LAST_STATUS', 'PERIOD_NUM', 'CALC_YEAR', 'CALC_MONTH', 'CREATED_AT'], 'integer'],
-            [['ID', 'USER_ID', 'FROM_USER_ID', 'FROM_DEC_SN', 'LAST_DEC_LV', 'LAST_EMP_LV'], 'string', 'max' => 32],
-            [['P_CALC_MONTH'], 'safe'],
-            [['LOGS'], 'string', 'max' => 2000],
-            [['ID'], 'unique'],
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function attributeLabels()
-    {
-        return [
-            'ID' => 'ID',
-            'USER_ID' => '会员ID',
-            'LAST_DEC_LV' => '结算时会员级别',
-            'LAST_EMP_LV' => '结算时会员聘级',
-            'LAST_STATUS' => '结算时状态',
-            'FROM_USER_ID' => '来源会员ID',
-            'FROM_DEC_SN' => '来源报单编号',
-            'AMOUNT' => '奖金金额',
-            'PERIOD_NUM' => '结算期数',
-            'CALC_YEAR' => '所在结算年',
-            'CALC_MONTH' => '所在结算月',
-            'P_CALC_MONTH' => '表分区的日期索引',
-            'LOGS' => '日志',
-            'CREATED_AT' => '创建时间',
-        ];
-    }
-}

+ 0 - 73
common/models/CalcBonusLX.php

@@ -1,73 +0,0 @@
-<?php
-
-namespace common\models;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%CALC_BONUS_LX}}".
- *
- * @property string $ID
- * @property string $USER_ID 会员ID
- * @property string $LAST_DEC_LV 结算时会员级别
- * @property string $LAST_EMP_LV 结算时会员聘级
- * @property int $LAST_STATUS 结算时状态
- * @property string $FROM_USER_ID 来源会员ID
- * @property string $FROM_DEC_SN 来源报单编号
- * @property string $AMOUNT 奖金金额
- * @property int $PERIOD_NUM 结算期数
- * @property int $CALC_YEAR 所在结算年
- * @property int $CALC_MONTH 所在结算月
- * @property string $P_CALC_MONTH 表分区的日期索引
- * @property string $LOGS 日志
- * @property int $CREATED_AT 创建时间
- */
-class CalcBonusLX extends \common\components\ActiveRecord
-{
-    /**
-     * {@inheritdoc}
-     */
-    public static function tableName()
-    {
-        return '{{%CALC_BONUS_LX}}';
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function rules()
-    {
-        return [
-            [['USER_ID', 'FROM_USER_ID', 'FROM_DEC_SN', 'PERIOD_NUM', 'CALC_YEAR', 'CALC_MONTH', 'P_CALC_MONTH', 'CREATED_AT'], 'required'],
-            [['AMOUNT'], 'number'],
-            [['LAST_STATUS', 'PERIOD_NUM', 'CALC_YEAR', 'CALC_MONTH', 'CREATED_AT'], 'integer'],
-            [['ID', 'USER_ID', 'FROM_USER_ID', 'FROM_DEC_SN', 'LAST_DEC_LV', 'LAST_EMP_LV'], 'string', 'max' => 32],
-            [['P_CALC_MONTH'], 'safe'],
-            [['LOGS'], 'string', 'max' => 2000],
-            [['ID'], 'unique'],
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function attributeLabels()
-    {
-        return [
-            'ID' => 'ID',
-            'USER_ID' => '会员ID',
-            'LAST_DEC_LV' => '结算时会员级别',
-            'LAST_EMP_LV' => '结算时会员聘级',
-            'LAST_STATUS' => '结算时状态',
-            'FROM_USER_ID' => '来源会员ID',
-            'FROM_DEC_SN' => '来源报单编号',
-            'AMOUNT' => '奖金金额',
-            'PERIOD_NUM' => '结算期数',
-            'CALC_YEAR' => '所在结算年',
-            'CALC_MONTH' => '所在结算月',
-            'P_CALC_MONTH' => '表分区的日期索引',
-            'LOGS' => '日志',
-            'CREATED_AT' => '创建时间',
-        ];
-    }
-}

+ 0 - 72
common/models/CalcBonusQY.php

@@ -1,72 +0,0 @@
-<?php
-
-namespace common\models;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%CALC_BONUS_QY}}".
- *
- * @property string $ID
- * @property string $USER_ID 会员ID
- * @property string $LAST_DEC_LV 结算时会员级别
- * @property string $LAST_EMP_LV 结算时会员聘级
- * @property int $LAST_STATUS 结算时状态
- * @property string $AMOUNT 金额
- * @property int $PERIOD_NUM 结算期数
- * @property int $CALC_MONTH 所在结算月
- * @property int $CALCULATED_AT 结算时间
- * @property int $CREATED_AT 创建时间
- * @property string $LOGS 日志
- * @property $ORI_BONUS 原奖金
- * @property $RECONSUME_POINTS 重复消费积分
- * @property $MANAGE_TAX 管理费
- */
-class CalcBonusQY extends \common\components\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%CALC_BONUS_QY}}';
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['USER_ID', 'PERIOD_NUM', 'CALC_MONTH', 'CALCULATED_AT', 'CREATED_AT'], 'required'],
-            [['AMOUNT', 'ORI_BONUS', 'RECONSUME_POINTS', 'MANAGE_TAX'], 'number'],
-            [['LAST_STATUS', 'PERIOD_NUM', 'CALC_MONTH', 'CALCULATED_AT', 'CREATED_AT'], 'integer'],
-            [['ID', 'USER_ID', 'LAST_DEC_LV', 'LAST_EMP_LV'], 'string', 'max' => 32],
-            [['LOGS'], 'string', 'max' => 2000],
-            [['ID'], 'unique'],
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function attributeLabels()
-    {
-        return [
-            'ID' => 'ID',
-            'USER_ID' => '会员ID',
-            'LAST_DEC_LV' => '结算时会员级别',
-            'LAST_EMP_LV' => '结算时会员聘级',
-            'LAST_STATUS' => '结算时状态',
-            'AMOUNT' => '金额',
-            'PERIOD_NUM' => '结算期数',
-            'CALC_MONTH' => '所在结算月',
-            'CALCULATED_AT' => '结算时间',
-            'CREATED_AT' => '创建时间',
-            'LOGS' => '日志',
-            'ORI_BONUS' => '原奖金',
-            'RECONSUME_POINTS' => '重复消费积分',
-            'MANAGE_TAX' => '管理费',
-        ];
-    }
-}

+ 0 - 83
common/models/CalcBonusStandard.php

@@ -1,83 +0,0 @@
-<?php
-
-namespace common\models;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%CALC_BONUS_STANDARD}}".
- *
- * @property string $ID
- * @property string $USER_ID
- * @property string $LAST_DEC_LV
- * @property string $LAST_EMP_LV
- * @property int $LAST_STATUS
- * @property string $FROM_USER_ID
- * @property string $LAST_FROM_DEC_LV
- * @property string $LAST_FROM_EMP_LV
- * @property int $LAST_FROM_STATUS
- * @property string $AMOUNT
- * @property int $PERIOD_NUM
- * @property int $CALC_YEAR
- * @property int $CALC_MONTH
- * @property string $P_CALC_MONTH
- * @property string $LOGS
- * @property int $CREATED_AT
- * @property string $ORI_BONUS
- * @property string $RECONSUME_POINTS
- * @property string $MANAGE_TAX
- */
-class CalcBonusStandard extends \common\components\ActiveRecord
-{
-    /**
-     * {@inheritdoc}
-     */
-    public static function tableName()
-    {
-        return '{{%CALC_BONUS_STANDARD}}';
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function rules()
-    {
-        return [
-            [['ID', 'USER_ID', 'FROM_USER_ID', 'PERIOD_NUM', 'CALC_YEAR', 'CALC_MONTH', 'P_CALC_MONTH', 'CREATED_AT'], 'required'],
-            [['LAST_STATUS', 'LAST_FROM_STATUS', 'PERIOD_NUM', 'CALC_YEAR', 'CALC_MONTH', 'CREATED_AT'], 'integer'],
-            [['AMOUNT', 'ORI_BONUS', 'RECONSUME_POINTS', 'MANAGE_TAX'], 'number'],
-            [['P_CALC_MONTH'], 'safe'],
-            [['ID', 'USER_ID', 'LAST_DEC_LV', 'LAST_EMP_LV', 'FROM_USER_ID', 'LAST_FROM_DEC_LV', 'LAST_FROM_EMP_LV'], 'string', 'max' => 32],
-            [['LOGS'], 'string', 'max' => 2000],
-            [['ID'], 'unique'],
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function attributeLabels()
-    {
-        return [
-            'ID' => 'ID',
-            'USER_ID' => 'User  ID',
-            'LAST_DEC_LV' => 'Last  Dec  Lv',
-            'LAST_EMP_LV' => 'Last  Emp  Lv',
-            'LAST_STATUS' => 'Last  Status',
-            'FROM_USER_ID' => 'From  User  ID',
-            'LAST_FROM_DEC_LV' => 'Last  From  Dec  Lv',
-            'LAST_FROM_EMP_LV' => 'Last  From  Emp  Lv',
-            'LAST_FROM_STATUS' => 'Last  From  Status',
-            'AMOUNT' => 'Amount',
-            'PERIOD_NUM' => 'Period  Num',
-            'CALC_YEAR' => 'Calc  Year',
-            'CALC_MONTH' => 'Calc  Month',
-            'P_CALC_MONTH' => 'P  Calc  Month',
-            'LOGS' => 'Logs',
-            'CREATED_AT' => 'Created  At',
-            'ORI_BONUS' => 'Ori  Bonus',
-            'RECONSUME_POINTS' => 'Reconsume  Points',
-            'MANAGE_TAX' => 'Manage  Tax',
-        ];
-    }
-}

+ 0 - 80
common/models/CalcBonusTG.php

@@ -1,80 +0,0 @@
-<?php
-
-namespace common\models;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%CALC_BONUS_TG}}".
- *
- * @property string $ID
- * @property string $USER_ID 会员ID
- * @property string $LAST_DEC_LV 结算时会员级别
- * @property string $LAST_EMP_LV 结算时会员聘级
- * @property int $LAST_STATUS 结算时状态
- * @property string $FROM_USER_ID 来源会员ID
- * @property string $LAST_FROM_DEC_LV 结算时来源会员级别
- * @property string $LAST_FROM_EMP_LV 结算时来源会员聘级
- * @property int $LAST_FROM_STATUS 结算时来源状态
- * @property string $AMOUNT 金额
- * @property int $PERIOD_NUM 结算期数
- * @property int $CALC_MONTH 所在结算月
- * @property int $CALCULATED_AT 结算时间
- * @property int $CREATED_AT 创建时间
- * @property string $LOGS 日志
- * @property $ORI_BONUS 原奖金
- * @property $RECONSUME_POINTS 重复消费积分
- * @property $MANAGE_TAX 管理费
- */
-class CalcBonusTG extends \common\components\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%CALC_BONUS_TG}}';
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['USER_ID', 'PERIOD_NUM', 'CALC_MONTH', 'CALCULATED_AT', 'CREATED_AT'], 'required'],
-            [['AMOUNT', 'ORI_BONUS', 'RECONSUME_POINTS', 'MANAGE_TAX'], 'number'],
-            [['LAST_STATUS', 'PERIOD_NUM', 'CALC_MONTH', 'CALCULATED_AT', 'CREATED_AT', 'LAST_FROM_STATUS'], 'integer'],
-            [['ID', 'USER_ID', 'LAST_DEC_LV', 'LAST_EMP_LV', 'FROM_USER_ID',  'LAST_FROM_DEC_LV', 'LAST_FROM_EMP_LV'], 'string', 'max' => 32],
-            [['LOGS'], 'string', 'max' => 2000],
-            [['ID'], 'unique'],
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function attributeLabels()
-    {
-        return [
-            'ID' => 'ID',
-            'USER_ID' => '会员ID',
-            'LAST_DEC_LV' => '结算时会员级别',
-            'LAST_EMP_LV' => '结算时会员聘级',
-            'LAST_STATUS' => '结算时状态',
-            'FROM_USER_ID' => '来源会员ID',
-            'LAST_FROM_DEC_LV' => '结算时来源会员级别',
-            'LAST_FROM_EMP_LV' => '结算时来源会员聘级',
-            'LAST_FROM_STATUS' => '结算时来源状态',
-            'AMOUNT' => '金额',
-            'PERIOD_NUM' => '结算期数',
-            'CALC_MONTH' => '所在结算月',
-            'CALCULATED_AT' => '结算时间',
-            'CREATED_AT' => '创建时间',
-            'LOGS' => '日志',
-            'ORI_BONUS' => '原奖金',
-            'RECONSUME_POINTS' => '重复消费积分',
-            'MANAGE_TAX' => '管理费',
-        ];
-    }
-}

+ 0 - 80
common/models/CalcBonusVIP.php

@@ -1,80 +0,0 @@
-<?php
-
-namespace common\models;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%CALC_BONUS_VIP}}".
- *
- * @property string $ID
- * @property string $USER_ID 会员ID
- * @property string $LAST_DEC_LV 结算时会员级别
- * @property string $LAST_EMP_LV 结算时会员聘级
- * @property int $LAST_STATUS 结算时状态
- * @property string $FROM_USER_ID 来源会员ID
- * @property string $LAST_FROM_DEC_LV 结算时来源会员级别
- * @property string $LAST_FROM_EMP_LV 结算时来源会员聘级
- * @property int $LAST_FROM_STATUS 结算时来源状态
- * @property string $AMOUNT 金额
- * @property int $PERIOD_NUM 结算期数
- * @property int $CALC_MONTH 所在结算月
- * @property int $CALCULATED_AT 结算时间
- * @property int $CREATED_AT 创建时间
- * @property string $LOGS 日志
- * @property $ORI_BONUS 原奖金
- * @property $RECONSUME_POINTS 重复消费积分
- * @property $MANAGE_TAX 管理费
- */
-class CalcBonusVIP extends \common\components\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%CALC_BONUS_VIP}}';
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['USER_ID', 'PERIOD_NUM', 'CALC_MONTH', 'CALCULATED_AT', 'CREATED_AT'], 'required'],
-            [['AMOUNT', 'ORI_BONUS', 'RECONSUME_POINTS', 'MANAGE_TAX'], 'number'],
-            [['LAST_STATUS', 'PERIOD_NUM', 'CALC_MONTH', 'CALCULATED_AT', 'CREATED_AT', 'LAST_FROM_STATUS'], 'integer'],
-            [['ID', 'USER_ID', 'LAST_DEC_LV', 'LAST_EMP_LV', 'FROM_USER_ID',  'LAST_FROM_DEC_LV', 'LAST_FROM_EMP_LV'], 'string', 'max' => 32],
-            [['LOGS'], 'string', 'max' => 2000],
-            [['ID'], 'unique'],
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function attributeLabels()
-    {
-        return [
-            'ID' => 'ID',
-            'USER_ID' => '会员ID',
-            'LAST_DEC_LV' => '结算时会员级别',
-            'LAST_EMP_LV' => '结算时会员聘级',
-            'LAST_STATUS' => '结算时状态',
-            'FROM_USER_ID' => '来源会员ID',
-            'LAST_FROM_DEC_LV' => '结算时来源会员级别',
-            'LAST_FROM_EMP_LV' => '结算时来源会员聘级',
-            'LAST_FROM_STATUS' => '结算时来源状态',
-            'AMOUNT' => '金额',
-            'PERIOD_NUM' => '结算期数',
-            'CALC_MONTH' => '所在结算月',
-            'CALCULATED_AT' => '结算时间',
-            'CREATED_AT' => '创建时间',
-            'LOGS' => '日志',
-            'ORI_BONUS' => '原奖金',
-            'RECONSUME_POINTS' => '重复消费积分',
-            'MANAGE_TAX' => '管理费',
-        ];
-    }
-}

+ 0 - 80
common/models/CalcBonusXF.php

@@ -1,80 +0,0 @@
-<?php
-
-namespace common\models;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%CALC_BONUS_XF}}".
- *
- * @property string $ID
- * @property string $USER_ID 会员ID
- * @property string $LAST_DEC_LV 结算时会员级别
- * @property string $LAST_EMP_LV 结算时会员聘级
- * @property int $LAST_STATUS 结算时状态
- * @property string $FROM_USER_ID 来源会员ID
- * @property string $LAST_FROM_DEC_LV 结算时来源会员级别
- * @property string $LAST_FROM_EMP_LV 结算时来源会员聘级
- * @property int $LAST_FROM_STATUS 结算时来源状态
- * @property string $AMOUNT 金额
- * @property int $PERIOD_NUM 结算期数
- * @property int $CALC_MONTH 所在结算月
- * @property int $CALCULATED_AT 结算时间
- * @property int $CREATED_AT 创建时间
- * @property string $LOGS 日志
- * @property $ORI_BONUS 原奖金
- * @property $RECONSUME_POINTS 重复消费积分
- * @property $MANAGE_TAX 管理费
- */
-class CalcBonusXF extends \common\components\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%CALC_BONUS_XF}}';
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['USER_ID', 'PERIOD_NUM', 'CALC_MONTH', 'CALCULATED_AT', 'CREATED_AT'], 'required'],
-            [['AMOUNT', 'ORI_BONUS', 'RECONSUME_POINTS', 'MANAGE_TAX'], 'number'],
-            [['LAST_STATUS', 'PERIOD_NUM', 'CALC_MONTH', 'CALCULATED_AT', 'CREATED_AT', 'LAST_FROM_STATUS'], 'integer'],
-            [['ID', 'USER_ID', 'LAST_DEC_LV', 'LAST_EMP_LV', 'FROM_USER_ID',  'LAST_FROM_DEC_LV', 'LAST_FROM_EMP_LV'], 'string', 'max' => 32],
-            [['LOGS'], 'string', 'max' => 2000],
-            [['ID'], 'unique'],
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function attributeLabels()
-    {
-        return [
-            'ID' => 'ID',
-            'USER_ID' => '会员ID',
-            'LAST_DEC_LV' => '结算时会员级别',
-            'LAST_EMP_LV' => '结算时会员聘级',
-            'LAST_STATUS' => '结算时状态',
-            'FROM_USER_ID' => '来源会员ID',
-            'LAST_FROM_DEC_LV' => '结算时来源会员级别',
-            'LAST_FROM_EMP_LV' => '结算时来源会员聘级',
-            'LAST_FROM_STATUS' => '结算时来源状态',
-            'AMOUNT' => '金额',
-            'PERIOD_NUM' => '结算期数',
-            'CALC_MONTH' => '所在结算月',
-            'CALCULATED_AT' => '结算时间',
-            'CREATED_AT' => '创建时间',
-            'LOGS' => '日志',
-            'ORI_BONUS' => '原奖金',
-            'RECONSUME_POINTS' => '重复消费积分',
-            'MANAGE_TAX' => '管理费',
-        ];
-    }
-}

+ 0 - 97
common/models/CalcBonusYC.php

@@ -1,97 +0,0 @@
-<?php
-
-namespace common\models;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%CALC_BONUS_YC}}".
- *
- * @property string $ID
- * @property string $USER_ID 会员ID
- * @property string $LAST_DEC_LV 结算时会员级别
- * @property string $LAST_EMP_LV 结算时会员聘级
- * @property int $LAST_STATUS 结算时状态
- * @property string $FROM_USER_ID 来源会员ID
- * @property string $LAST_FROM_DEC_LV 结算时来源会员级别
- * @property string $LAST_FROM_EMP_LV 结算时来源会员聘级
- * @property int $LAST_FROM_STATUS 结算时来源状态
- * @property string $FROM_DEC_SN 来源报单编号
- * @property string $AMOUNT 奖金金额
- * @property int $PERIOD_NUM 结算期数
- * @property int $CALC_YEAR 所在结算年
- * @property int $CALC_MONTH 所在结算月
- * @property string $P_CALC_MONTH 表分区的日期索引
- * @property int $CREATED_AT 创建时间
- * @property string $LOGS 日志
- * @property $ORI_BONUS 原奖金
- * @property $RECONSUME_POINTS 重复消费积分
- * @property $MANAGE_TAX 管理费
- * @property $BONUS_TYPE 奖金类型
- */
-class CalcBonusYC extends \common\components\ActiveRecord
-{
-    const BONUS_TYPE_YC = 0;
-    const BONUS_TYPE_LEVEL_YC_ONE = 1;
-    const BONUS_TYPE_LEVEL_YC_TWO = 2;
-
-    const BONUS_TYPE_NAME = [
-        '普通荣衔',
-        '平级一代',
-        '平级二代',
-    ];
-
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%CALC_BONUS_YC}}';
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['USER_ID', 'FROM_USER_ID', 'FROM_DEC_SN', 'PERIOD_NUM', 'CALC_YEAR', 'CALC_MONTH', 'P_CALC_MONTH', 'CREATED_AT'], 'required'],
-            [['AMOUNT', 'ORI_BONUS', 'RECONSUME_POINTS', 'MANAGE_TAX'], 'number'],
-            [['LAST_STATUS', 'LAST_FROM_STATUS', 'PERIOD_NUM', 'CALC_YEAR', 'CALC_MONTH', 'CREATED_AT', 'BONUS_TYPE'], 'integer'],
-            [['ID', 'USER_ID', 'FROM_USER_ID', 'FROM_DEC_SN', 'LAST_DEC_LV', 'LAST_FROM_DEC_LV', 'LAST_FROM_EMP_LV'], 'string', 'max' => 32],
-            [['P_CALC_MONTH'], 'safe'],
-            [['LOGS'], 'string', 'max' => 2000],
-            [['ID'], 'unique'],
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function attributeLabels()
-    {
-        return [
-            'ID' => 'ID',
-            'USER_ID' => '会员ID',
-            'LAST_DEC_LV' => '结算时会员级别',
-            'LAST_EMP_LV' => '结算时会员聘级',
-            'LAST_STATUS' => '结算时状态',
-            'FROM_USER_ID' => '来源会员ID',
-            'LAST_FROM_DEC_LV' => '结算时来源会员级别',
-            'LAST_FROM_EMP_LV' => '结算时来源会员聘级',
-            'LAST_FROM_STATUS' => '结算时来源状态',
-            'FROM_DEC_SN' => '来源报单编号',
-            'AMOUNT' => '奖金金额',
-            'PERIOD_NUM' => '结算期数',
-            'CALC_YEAR' => '所在结算年',
-            'CALC_MONTH' => '所在结算月',
-            'P_CALC_MONTH' => '表分区的日期索引',
-            'CREATED_AT' => '创建时间',
-            'LOGS' => '日志',
-            'ORI_BONUS' => '原奖金',
-            'RECONSUME_POINTS' => '重复消费积分',
-            'MANAGE_TAX' => '管理费',
-            'BONUS_TYPE' => '奖金类型',
-        ];
-    }
-}

+ 0 - 80
common/models/CalcBonusYJ.php

@@ -1,80 +0,0 @@
-<?php
-
-namespace common\models;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%CALC_BONUS_YJ}}".
- *
- * @property string $ID
- * @property string $USER_ID 会员ID
- * @property string $LAST_DEC_LV 结算时会员级别
- * @property string $LAST_EMP_LV 结算时会员聘级
- * @property int $LAST_STATUS 结算时状态
- * @property string $FROM_USER_ID 来源会员ID
- * @property string $LAST_FROM_DEC_LV 结算时来源会员级别
- * @property string $LAST_FROM_EMP_LV 结算时来源会员聘级
- * @property int $LAST_FROM_STATUS 结算时来源状态
- * @property string $AMOUNT 金额
- * @property int $PERIOD_NUM 结算期数
- * @property int $CALC_MONTH 所在结算月
- * @property int $CALCULATED_AT 结算时间
- * @property int $CREATED_AT 创建时间
- * @property string $LOGS 日志
- * @property $ORI_BONUS 原奖金
- * @property $RECONSUME_POINTS 重复消费积分
- * @property $MANAGE_TAX 管理费
- */
-class CalcBonusYJ extends \common\components\ActiveRecord
-{
-    /**
-     * @inheritdoc
-     */
-    public static function tableName()
-    {
-        return '{{%CALC_BONUS_YJ}}';
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['USER_ID', 'PERIOD_NUM', 'CALC_MONTH', 'CALCULATED_AT', 'CREATED_AT'], 'required'],
-            [['AMOUNT', 'ORI_BONUS', 'RECONSUME_POINTS', 'MANAGE_TAX'], 'number'],
-            [['LAST_STATUS', 'PERIOD_NUM', 'CALC_MONTH', 'CALCULATED_AT', 'CREATED_AT', 'LAST_FROM_STATUS'], 'integer'],
-            [['ID', 'USER_ID', 'LAST_DEC_LV', 'LAST_EMP_LV', 'FROM_USER_ID',  'LAST_FROM_DEC_LV', 'LAST_FROM_EMP_LV'], 'string', 'max' => 32],
-            [['LOGS'], 'string', 'max' => 2000],
-            [['ID'], 'unique'],
-        ];
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function attributeLabels()
-    {
-        return [
-            'ID' => 'ID',
-            'USER_ID' => '会员ID',
-            'LAST_DEC_LV' => '结算时会员级别',
-            'LAST_EMP_LV' => '结算时会员聘级',
-            'LAST_STATUS' => '结算时状态',
-            'FROM_USER_ID' => '来源会员ID',
-            'LAST_FROM_DEC_LV' => '结算时来源会员级别',
-            'LAST_FROM_EMP_LV' => '结算时来源会员聘级',
-            'LAST_FROM_STATUS' => '结算时来源状态',
-            'AMOUNT' => '金额',
-            'PERIOD_NUM' => '结算期数',
-            'CALC_MONTH' => '所在结算月',
-            'CALCULATED_AT' => '结算时间',
-            'CREATED_AT' => '创建时间',
-            'LOGS' => '日志',
-            'ORI_BONUS' => '原奖金',
-            'RECONSUME_POINTS' => '重复消费积分',
-            'MANAGE_TAX' => '管理费',
-        ];
-    }
-}

+ 0 - 51
common/models/CalcMonthBonusUser.php

@@ -1,51 +0,0 @@
-<?php
-
-namespace common\models;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%CALC_MONTH_BONUS_USER}}".
- *
- * @property string $ID
- * @property string $USER_ID 用户ID
- * @property int $CALC_MONTH 结算月
- * @property int $CREATED_AT 创建时间
- */
-class CalcMonthBonusUser extends \common\components\ActiveRecord
-{
-    /**
-     * {@inheritdoc}
-     */
-    public static function tableName()
-    {
-        return '{{%CALC_MONTH_BONUS_USER}}';
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function rules()
-    {
-        return [
-            [['ID', 'USER_ID', 'CALC_MONTH', 'CREATED_AT'], 'required'],
-            [['CALC_MONTH', 'CREATED_AT'], 'integer'],
-            [['ID', 'USER_ID'], 'string', 'max' => 32],
-            [['CALC_MONTH', 'USER_ID'], 'unique', 'targetAttribute' => ['CALC_MONTH', 'USER_ID']],
-            [['ID'], 'unique'],
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function attributeLabels()
-    {
-        return [
-            'ID' => 'ID',
-            'USER_ID' => '用户ID',
-            'CALC_MONTH' => '结算月',
-            'CREATED_AT' => '创建时间',
-        ];
-    }
-}

+ 0 - 72
common/models/CompanyBank.php

@@ -1,72 +0,0 @@
-<?php
-
-namespace common\models;
-
-use Yii;
-
-/**
- * This is the model class for table "{{%COMPANY_BANK}}".
- *
- * @property string $ID
- * @property string $USER_ID 会员ID
- * @property string $OPEN_NAME 开户名
- * @property string $OPEN_BANK 开户行
- * @property string $BANK_ADDRESS 银行地址
- * @property string $BANK_NO 银行账号
- * @property string $CREATE_ADMIN 创建管理员
- * @property string $UPDATE_ADMIN 修改管理员
- * @property string $REMARK 备注
- * @property int $BANK_PROVINCE 银行省份
- * @property int $BANK_CITY 银行城市
- * @property int $BANK_COUNTY 银行地区
- * @property int $CREATED_AT 创建时间
- * @property int $UPDATED_AT 修改时间
- */
-class CompanyBank extends \common\components\ActiveRecord
-{
-    /**
-     * {@inheritdoc}
-     */
-    public static function tableName()
-    {
-        return '{{%COMPANY_BANK}}';
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function rules()
-    {
-        return [
-            [['USER_ID', 'OPEN_NAME', 'OPEN_BANK', 'BANK_ADDRESS', 'BANK_NO', 'BANK_PROVINCE', 'BANK_CITY', 'BANK_COUNTY', 'CREATED_AT'], 'required'],
-            [['BANK_PROVINCE', 'BANK_CITY', 'BANK_COUNTY', 'CREATED_AT', 'UPDATED_AT'], 'integer'],
-            [['ID', 'USER_ID', 'BANK_NO', 'CREATE_ADMIN', 'UPDATE_ADMIN'], 'string', 'max' => 32],
-            [['OPEN_NAME', 'OPEN_BANK', 'BANK_ADDRESS'], 'string', 'max' => 255],
-            [['REMARK'], 'string', 'max' => 4000],
-            [['ID'], 'unique'],
-        ];
-    }
-
-    /**
-     * {@inheritdoc}
-     */
-    public function attributeLabels()
-    {
-        return [
-            'ID' => 'ID',
-            'USER_ID' => '会员ID',
-            'OPEN_NAME' => '开户名',
-            'OPEN_BANK' => '开户行',
-            'BANK_ADDRESS' => '银行地址',
-            'BANK_NO' => '银行账号',
-            'BANK_PROVINCE' => '银行省份',
-            'BANK_CITY' => '银行城市',
-            'BANK_COUNTY' => '银行地区',
-            'CREATE_ADMIN' => '创建管理员',
-            'UPDATE_ADMIN' => '修改管理员',
-            'REMARK' => '备注',
-            'CREATED_AT' => '创建时间',
-            'UPDATED_AT' => '修改时间',
-        ];
-    }
-}

+ 0 - 558
common/models/forms/ChangePerfForm.php

@@ -1,558 +0,0 @@
-<?php
-
-namespace common\models\forms;
-
-use common\components\Model;
-use common\helpers\Date;
-use common\helpers\Form;
-use common\helpers\Tool;
-use common\helpers\user\Balance;
-use common\helpers\user\Info;
-use common\libs\logging\operate\AdminOperate;
-use common\models\BalanceAudit;
-use common\models\PerfAudit;
-use common\models\PerfMonth;
-use common\models\PerfPeriod;
-use common\models\Period;
-use common\models\User;
-use common\models\UserBonus;
-use common\models\UserInfo;
-use common\models\UserPerf;
-use common\models\Withdraw;
-use yii\base\Exception;
-use yii\db\Expression;
-
-/**
- * Login form
- */
-class ChangePerfForm extends Model {
-
-    public $id;
-    public $selected;
-    public $periodNum;
-    public $perfType;
-    public $userName;
-    public $location;
-    public $amount;
-    public $remark;
-    public $auditStatus;
-
-    private $_periodNum;
-    private $_userId;
-    private $_locationField;
-    private $_model;
-
-    public function init() {
-        parent::init();
-        $this->adminOperateLogger = new AdminOperate([
-            'fetchClass' => PerfAudit::class,
-        ]);
-    }
-    /**
-     * @inheritdoc
-     */
-    public function rules() {
-        return [
-            [['id', 'selected', 'userName', 'perfType', 'location', 'amount', 'remark', 'auditStatus'], 'trim'],
-            [['id', 'userName', 'perfType', 'location', 'amount', 'remark', 'auditStatus'], 'required'],
-            [['id'], 'exist', 'targetClass' => PerfAudit::class, 'targetAttribute' => 'ID', 'message' => '该申请不存在'],
-            [['id'], 'initModel'],
-            [['userName'], 'isUserName'],
-            //[['periodNum'], 'isPeriodNum'],
-            [['perfType'], 'isPerfType'],
-            [['location'], 'isLocation'],
-            [['amount'], 'fullPrice'],
-            [['amount'], 'isAmount'],
-            [['auditStatus'], 'isStatus'],
-            [['selected'], 'isSelected'],
-        ];
-    }
-
-    /**
-     * 指定场景
-     * @return array
-     */
-    public function scenarios() {
-        $parentScenarios = parent::scenarios();
-        $customScenarios = [
-            'add' => ['userName', 'perfType', 'location', 'amount', 'remark'],
-            'changeAudit' => ['selected', 'remark', 'auditStatus'],
-            'pass' => ['id', 'perfType', 'location', 'amount', 'remark', 'auditStatus'],
-        ];
-        return array_merge($parentScenarios, $customScenarios);
-    }
-
-    /**
-     * @return array
-     */
-    public function attributeLabels() {
-        return [
-            'id' => '申请的ID',
-            'userName' => '会员编号',
-            'location' => '区域',
-            'amount' => '变动数额',
-            'remark' => '备注',
-            'auditStatus' => '状态',
-        ];
-    }
-
-    /**
-     * 初始化model
-     */
-    public function initModel($attribute) {
-        $model = $this->_model = PerfAudit::findOne(['ID' => $this->id]);
-        $this->_userId = $model->USER_ID;
-        if ($model->AUDIT_STATUS > \Yii::$app->params['auditStatus']['un']['value']) {
-            $this->addError($attribute, '该申请已经被审核,不能重复审核');
-        }
-    }
-
-    /**
-     * 设置userId
-     * @param $attribute
-     */
-    public function isUserName($attribute) {
-        $this->_userId = Info::getUserIdByUserName($this->userName);
-        if ($this->_userId) {
-            // 如果该会员已经存在一个待审核的申请,直接提示错误
-            if (PerfAudit::find()->where('USER_ID=:USER_ID AND AUDIT_STATUS=:AUDIT_STATUS', [':USER_ID' => $this->_userId, ':AUDIT_STATUS' => \Yii::$app->params['auditStatus']['un']['value']])->exists()) {
-                $this->addError($attribute, '该会员审核列表中如果有待审记录,需等待待审核记录审核后才可提交');
-            }
-        } else {
-            $this->addError($attribute, '会员不存在');
-        }
-    }
-
-    /**
-     * 期数是否符合条件
-     * @param $attribute
-     */
-    public function isPeriodNum($attribute) {
-        $period = Period::instance();
-        if (!$period->isSent($this->periodNum)) {
-            $this->addError($attribute, '该期【' . $this->periodNum . '】未挂网,无法调整');
-        }
-        if (Period::find()->where('IS_SENT=:IS_SENT AND PERIOD_NUM>=:START_PERIOD_NUM AND PERIOD_NUM<=:END_PERIOD_NUM', [':IS_SENT' => Period::SEND_FINISH, ':START_PERIOD_NUM' => $this->periodNum + 1, ':END_PERIOD_NUM' => $this->periodNum + 1])->count() == 1) {
-            $this->addError($attribute, '下一期【' . ($this->periodNum + 1) . '】已挂网,该期无法调整');
-        }
-    }
-
-    /**
-     * 类型是否符合条件
-     * @param $attribute
-     */
-    public function isPerfType($attribute) {
-        if (!in_array($this->perfType, array_keys(PerfAudit::CHANGE_PERF_TYPE))) {
-            $this->addError($attribute, '调整类型不正确');
-        }
-        $this->_periodNum = Period::sentMaxPeriodNum();
-    }
-
-    /**
-     * 校验区域
-     * @param $attribute
-     */
-    public function isLocation($attribute) {
-        if ($this->perfType==PerfAudit::PERF_TYPE_PV && !in_array($this->location, [1, 2, 3, 4, 5])) {
-            $this->addError($attribute, '区位不正确');
-        }
-        if ($this->perfType==PerfAudit::PERF_TYPE_SURPLUS && !in_array($this->location, [1, 2, 3, 4, 5, 6])) {
-            $this->addError($attribute, '区位不正确');
-        }
-    }
-
-    /**
-     * 金额是否正确
-     * @param $attribute
-     */
-    public function isAmount($attribute) {
-        if ($this->amount == 0) $this->addError($attribute, '变动数额不能为0');
-        if ($this->perfType == PerfAudit::PERF_TYPE_PV) {
-            $userPerf = UserPerf::findOneAsArray('USER_ID=:USER_ID', [':USER_ID' => $this->_userId]);
-            if ($this->amount < 0 && (abs($this->amount) > $userPerf['PV_' . $this->location . 'L'])) {
-                $this->addError('scenario', '该会员该区域的数额不足');
-            }
-        } elseif ($this->perfType == PerfAudit::PERF_TYPE_SURPLUS) {
-            $perfPeriod = PerfPeriod::findOneAsArray('USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM', [':USER_ID' => $this->_userId, ':PERIOD_NUM' => $this->_periodNum]);
-            if($this->location==6){
-                if ($this->amount < 0 && (abs($this->amount) > $perfPeriod['SURPLUS_LS'])) {
-                    $this->addError('scenario', '该会员当期该区域剩余数额不足');
-                }
-            }else {
-                if ($this->amount < 0 && (abs($this->amount) > $perfPeriod['SURPLUS_' . $this->location . 'L'])) {
-                    $this->addError('scenario', '该会员当期该区域剩余数额不足');
-                }
-            }
-        }
-    }
-
-    /**
-     * 校验状态
-     * @param $attribute
-     */
-    public function isStatus($attribute) {
-        // 获取当前提现单的状态
-        $oneData = PerfAudit::findOneAsArray(['ID' => $this->id]);
-        switch ($this->auditStatus) {
-            case 'un':
-                $this->addError($attribute, '不能设置为待审核状态' . $this->auditStatus);
-                break;
-            case 'true':
-                if ($oneData['AUDIT_STATUS'] == \Yii::$app->params['auditStatus']['true']['value']) {
-                    $this->addError($attribute, '已经审核通过不能重复审核');
-                } elseif ($oneData['AUDIT_STATUS'] == \Yii::$app->params['auditStatus']['reject']['value']) {
-                    $this->addError($attribute, '已经审核拒绝不能重复审核');
-                }
-                break;
-            case 'reject':
-                if ($oneData['AUDIT_STATUS'] == \Yii::$app->params['auditStatus']['true']['value']) {
-                    $this->addError($attribute, '已经审核通过不能重复审核');
-                } elseif ($oneData['AUDIT_STATUS'] == \Yii::$app->params['auditStatus']['reject']['value']) {
-                    $this->addError($attribute, '已经审核拒绝不能重复审核');
-                }
-                break;
-            default:
-                $this->addError($attribute, '状态参数有误');
-        }
-    }
-
-    /**
-     * 批量数据
-     * @param $attributes
-     */
-    public function isSelected($attributes) {
-        if (!$this->selected) {
-            $this->addError($attributes, '必须选择一条数据');
-        }
-        if (!is_array($this->selected)) {
-            $this->selected = [$this->selected];
-        }
-    }
-
-    /**
-     * 添加变动申请
-     * @return BalanceAudit|null
-     * @throws \yii\db\Exception
-     */
-    public function add() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            // 添加申请
-            $model = new PerfAudit();
-            $model->USER_ID = $this->_userId;
-            $model->PERF_TYPE = $this->perfType;
-            $model->PERF_LOCATION = $this->location;
-            $model->PERIOD_NUM = $this->_periodNum;
-            $model->AMOUNT = $this->amount;
-            $model->AUDIT_STATUS = \Yii::$app->params['auditStatus']['un']['value'];
-            $model->CREATE_ADMIN = \Yii::$app->user->id;
-            $model->REMARK = $this->remark;
-            $model->CREATED_AT = Date::nowTime();
-            if (!$model->save()) {
-                throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('add', $e->getMessage());
-            return null;
-        }
-
-        // 记录日志
-        $this->adminOperateLogger->fetchClass = PerfAudit::class;
-        $this->adminOperateLogger->afterInsert($model)->clean()->save([
-            'optType' => '申请调整会员业绩',
-            'userId' => $model->USER_ID,
-            'userName' => Info::getUserNameByUserId($model->USER_ID),
-            'remark' => $model->REMARK,
-        ]);
-
-        return $model;
-    }
-
-    /**
-     * 管理员审核状态
-     * @return BalanceAudit|null
-     * @throws \yii\db\Exception
-     */
-    /*public function changeStatus() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            $model = $this->_model;
-            if ($this->auditStatus == 'reject') {
-                $model->AUDIT_STATUS = \Yii::$app->params['auditStatus']['reject']['value'];
-            } elseif ($this->auditStatus == 'true') {
-                $model->AUDIT_STATUS = \Yii::$app->params['auditStatus']['true']['value'];
-            }
-            $model->AUDIT_ADMIN = \Yii::$app->user->id;
-            $model->AUDITED_AT = Date::nowTime();
-            if (!$model->save()) {
-                throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-            }
-            // 如果是审核通过状态改变会员的业绩
-            if ($this->auditStatus == 'true') {
-                UserPerf::updateAllCounters([$this->_locationField => $this->amount], 'USER_ID=:USER_ID', [':USER_ID' => $model['USER_ID']]);
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('status', $e->getMessage());
-            return null;
-        }
-        return $model;
-    }*/
-
-    /**
-     * 审核通过
-     * @return null
-     * @throws \yii\db\Exception
-     */
-    public function pass() {
-        if (!$this->validate()) {
-            return null;
-        }
-
-        // 日志记录操作前的数据
-        $beforeData = UserPerf::getPvByUserId($this->_userId);
-        $this->adminOperateLogger->fetchClass = UserPerf::class;
-        $this->adminOperateLogger->beforeUpdate($beforeData);
-        $perfData = $this->adminOperateLogger->saveBeforeContent;
-        $beforeData = PerfPeriod::getPeriodSurplusPerf($this->_model->PERIOD_NUM,$this->_userId);
-        $this->adminOperateLogger->fetchClass = PerfPeriod::class;
-        $this->adminOperateLogger->beforeUpdate($beforeData);
-        $periodData = $this->adminOperateLogger->saveBeforeContent;
-        $this->adminOperateLogger->saveBeforeContent=array_merge($perfData,$periodData);
-
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            $model = $this->_model;
-            $model->AUDIT_STATUS = \Yii::$app->params['auditStatus'][$this->auditStatus]['value'];
-            $model->AUDIT_ADMIN = \Yii::$app->user->id;
-            $model->AMOUNT = $this->amount;
-            $model->REMARK = $this->remark;
-            $model->AUDITED_AT = Date::nowTime();
-
-            $perfModel = UserPerf::findOne(['USER_ID' => $model->USER_ID]);
-            $periodModel = PerfPeriod::findOne(['USER_ID' => $model->USER_ID, 'PERIOD_NUM' => $model->PERIOD_NUM]);
-
-            $perfBefore = 0;
-            $perfAfter = 0;
-            // 如果是审核通过状态
-            if ($this->auditStatus == 'true') {
-                if ($model->PERF_TYPE == PerfAudit::PERF_TYPE_PV) {
-                    //给上月累计
-                    $period = Period::instance();
-                    $lastMonth = $period->getLastMonth();
-                    PerfMonth::updateAll(['PV_' . $model->PERF_LOCATION . 'L_TOTAL'=> new Expression('PV_' . $model->PERF_LOCATION . 'L_TOTAL+'.$model->AMOUNT)],'USER_ID=:USER_ID AND CALC_MONTH=:CALC_MONTH',[':USER_ID'=>$model->USER_ID,':CALC_MONTH'=>$lastMonth['yearMonth']]);
-
-                    $locaionField = 'PV_' . $model->PERF_LOCATION . 'L';
-                    $perfBefore = $perfModel->$locaionField;
-                    $perfAfter = $perfModel->$locaionField + $model->AMOUNT;
-                    $perfModel->$locaionField = $perfAfter;
-                    if (!$perfModel->save()) {
-                        throw new Exception(Form::formatErrorsForApi($perfModel->getErrors()));
-                    }
-                } elseif ($model->PERF_TYPE == PerfAudit::PERF_TYPE_SURPLUS) {
-                    if($model->PERF_LOCATION==6){
-                        $locaionField = 'SURPLUS_LS';
-                    }else{
-                        $locaionField = 'SURPLUS_' . $model->PERF_LOCATION . 'L';
-                    }
-                    $perfBefore = $periodModel->$locaionField;
-                    $perfAfter = $periodModel->$locaionField + $model->AMOUNT;
-                    $periodModel->$locaionField = $perfAfter;
-                    if (!$periodModel->save()) {
-                        throw new Exception(Form::formatErrorsForApi($periodModel->getErrors()));
-                    }
-                }
-            }
-            $model->PV_1L = $perfModel->PV_1L;
-            $model->PV_2L = $perfModel->PV_2L;
-            $model->PV_3L = $perfModel->PV_3L;
-            $model->PV_4L = $perfModel->PV_4L;
-            $model->PV_5L = $perfModel->PV_5L;
-            $model->SURPLUS_1L = $periodModel->SURPLUS_1L;
-            $model->SURPLUS_2L = $periodModel->SURPLUS_2L;
-            $model->SURPLUS_3L = $periodModel->SURPLUS_3L;
-            $model->SURPLUS_4L = $periodModel->SURPLUS_4L;
-            $model->SURPLUS_5L = $periodModel->SURPLUS_5L;
-            $model->SURPLUS_LS = $periodModel->SURPLUS_LS;
-            $model->PERF_BEFORE = $perfBefore;
-            $model->PERF_AFTER = $perfAfter;
-            if (!$model->save()) {
-                throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('pass', $e->getMessage());
-            return null;
-        }
-
-        // 记录日志
-        $beforeData = UserPerf::getPvByUserId($this->_userId);
-        $this->adminOperateLogger->fetchClass = UserPerf::class;
-        $this->adminOperateLogger->afterUpdate($beforeData);
-        $perfData = $this->adminOperateLogger->saveAfterContent;
-        $beforeData = PerfPeriod::getPeriodSurplusPerf($this->_model->PERIOD_NUM,$this->_userId);
-        $this->adminOperateLogger->fetchClass = PerfPeriod::class;
-        $this->adminOperateLogger->afterUpdate($beforeData);
-        $periodData = $this->adminOperateLogger->saveAfterContent;
-        $this->adminOperateLogger->saveAfterContent=array_merge($perfData,$periodData);
-        $this->adminOperateLogger->clean()->save([
-            'optType' => '审核通过会员业绩',
-            'userId' => $model->USER_ID,
-            'userName' => Info::getUserNameByUserId($model->USER_ID),
-            'remark' => $model->REMARK,
-        ]);
-
-        return $model;
-    }
-
-    /**
-     * 修改审核状态
-     * @return array|null
-     * @throws \yii\db\Exception
-     */
-    public function changeAudit() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        $logs = [];
-        $uids=[];
-        if($this->auditStatus=='true'){
-            foreach ($this->selected as $select) {
-                $oneBalanceAudit = PerfAudit::findOneAsArray('ID=:ID',[':ID'=>$select],'USER_ID');
-                $uids[]=$oneBalanceAudit['USER_ID'];
-            }
-        }
-        try {
-            if($this->auditStatus=='true'){
-                $this->adminOperateLogger->fetchClass = UserPerf::class;
-                $this->adminOperateLogger->setIsBatch(true)->beforeUpdate($uids, 'USER_ID');
-                $perfData = $this->adminOperateLogger->saveBeforeContent;
-                $this->adminOperateLogger->fetchClass = PerfPeriod::class;
-                $this->adminOperateLogger->setIsBatch(true)->beforeUpdate($uids, 'USER_ID');
-                $periodData = $this->adminOperateLogger->saveBeforeContent;
-                $this->adminOperateLogger->saveBeforeContent=Tool::mergeArrayWithKey($perfData,$periodData);
-            }else{
-                $this->adminOperateLogger->fetchClass = PerfAudit::class;
-                $this->adminOperateLogger->setIsBatch(true)->beforeUpdate($this->selected, 'ID');
-            }
-            foreach ($this->selected as $select) {
-                $model = PerfAudit::findOne(['ID' => $select]);
-                if ($model->AUDIT_STATUS > \Yii::$app->params['auditStatus']['un']['value']) continue;
-                $model->AUDIT_STATUS = \Yii::$app->params['auditStatus'][$this->auditStatus]['value'];
-                $model->AUDIT_ADMIN = \Yii::$app->user->id;
-                $model->REMARK = $this->remark;
-                $model->AUDITED_AT = Date::nowTime();
-                $perfModel = UserPerf::findOne(['USER_ID' => $model->USER_ID]);
-                $periodModel = PerfPeriod::findOne(['USER_ID' => $model->USER_ID, 'PERIOD_NUM' => $model->PERIOD_NUM]);
-                $perfBefore = 0;
-                $perfAfter = 0;
-                if ($model->AUDIT_STATUS == \Yii::$app->params['auditStatus']['true']['value']) {
-                    if ($model->PERF_TYPE == PerfAudit::PERF_TYPE_PV) {
-                        //给上月累计
-                        $period = Period::instance();
-                        $lastMonth = $period->getLastMonth();
-                        PerfMonth::updateAll(['PV_' . $model->PERF_LOCATION . 'L_TOTAL'=> new Expression('PV_' . $model->PERF_LOCATION . 'L_TOTAL+'.$model->AMOUNT)],'USER_ID=:USER_ID AND CALC_MONTH=:CALC_MONTH',[':USER_ID'=>$model->USER_ID,':CALC_MONTH'=>$lastMonth['yearMonth']]);
-
-                        $locaionField = 'PV_' . $model->PERF_LOCATION . 'L';
-                        $perfBefore = $perfModel->$locaionField;
-                        $perfAfter = $perfModel->$locaionField + $model->AMOUNT;
-                        $perfModel->$locaionField = $perfAfter;
-                        if (!$perfModel->save()) {
-                            throw new Exception(Form::formatErrorsForApi($perfModel->getErrors()));
-                        }
-                    } elseif ($model->PERF_TYPE == PerfAudit::PERF_TYPE_SURPLUS) {
-                        if($model->PERF_LOCATION==6){
-                            $locaionField = 'SURPLUS_LS';
-                        }else{
-                            $locaionField = 'SURPLUS_' . $model->PERF_LOCATION . 'L';
-                        }
-                        $perfBefore = $periodModel->$locaionField;
-                        $perfAfter = $periodModel->$locaionField + $model->AMOUNT;
-                        $periodModel->$locaionField = $perfAfter;
-                        if (!$periodModel->save()) {
-                            throw new Exception(Form::formatErrorsForApi($periodModel->getErrors()));
-                        }
-                    }
-                }
-                $model->PV_1L = $perfModel->PV_1L;
-                $model->PV_2L = $perfModel->PV_2L;
-                $model->PV_3L = $perfModel->PV_3L;
-                $model->PV_4L = $perfModel->PV_4L;
-                $model->PV_5L = $perfModel->PV_5L;
-                $model->SURPLUS_1L = $periodModel->SURPLUS_1L;
-                $model->SURPLUS_2L = $periodModel->SURPLUS_2L;
-                $model->SURPLUS_3L = $periodModel->SURPLUS_3L;
-                $model->SURPLUS_4L = $periodModel->SURPLUS_4L;
-                $model->SURPLUS_5L = $periodModel->SURPLUS_5L;
-                $model->SURPLUS_LS = $periodModel->SURPLUS_LS;
-                $model->PERF_BEFORE = $perfBefore;
-                $model->PERF_AFTER = $perfAfter;
-                if (!$model->save()) {
-                    throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-                }
-                $logs[] = ['userId' => $select];
-            }
-
-            if($this->auditStatus=='true'){
-                $this->adminOperateLogger->fetchClass = UserPerf::class;
-                $this->adminOperateLogger->setIsBatch(true)->afterUpdate($uids, 'USER_ID');
-                $perfData = $this->adminOperateLogger->saveAfterContent;
-                $this->adminOperateLogger->fetchClass = PerfPeriod::class;
-                $this->adminOperateLogger->setIsBatch(true)->afterUpdate($uids, 'USER_ID');
-                $periodData = $this->adminOperateLogger->saveAfterContent;
-                $this->adminOperateLogger->saveAfterContent=Tool::mergeArrayWithKey($perfData,$periodData);
-                $this->adminOperateLogger->setBatchField('USER_ID')->setOptObjField('USER_ID')->clean()->save([
-                    'optType' => '审核会员业绩',
-                    'remark' => $this->remark,
-                ]);
-            }else{
-                $this->adminOperateLogger->fetchClass = PerfAudit::class;
-                $this->adminOperateLogger->setIsBatch(true)->afterUpdate($this->selected, 'ID')->clean()->save([
-                    'optType' => '审核会员业绩',
-                    'remark' => $this->remark,
-                ]);
-            }
-
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('changeAudit', $e->getMessage());
-            return null;
-        }
-        return $logs;
-    }
-
-    /**
-     * 删除前
-     * @param $selected
-     */
-    public function beforeDelete($selected) {
-        $this->adminOperateLogger->fetchClass = PerfAudit::class;
-        $this->adminOperateLogger->setIsBatch(true)->beforeDelete($selected, 'ID');
-    }
-    /**
-     * 删除
-     * @param $selected
-     * @throws Exception
-     */
-    public function delete($selected) {
-        $this->adminOperateLogger->clean()->save([
-            'optType' => '删除业绩调整待审核数据',
-        ]);
-    }
-}

+ 0 - 135
common/models/forms/ChangeShowEmpLvForm.php

@@ -1,135 +0,0 @@
-<?php
-namespace common\models\forms;
-
-use common\helpers\Date;
-use common\components\Model;
-use common\helpers\Form;
-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\Period;
-use common\models\DeclarationLevel;
-use common\models\EmployLevel;
-use common\models\User;
-use common\models\UserInfo;
-use yii\base\Exception;
-use yii\validators\UrlValidator;
-
-/**
- * Login form
- */
-class ChangeShowEmpLvForm extends Model
-{
-    public $userName;
-    public $levelId;
-    public $isReset;
-    public $remark;
-
-    private $_userId;
-
-    public function init() {
-        parent::init();
-        $this->adminOperateLogger = new AdminOperate([
-            'fetchClass' => UserInfo::class,
-        ]);
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['userName', 'levelId', 'remark', 'isReset'], 'trim'],
-            [['userName'], 'required'],
-            [['userName'], 'exist', 'targetClass'=>User::class, 'targetAttribute'=>'USER_NAME'],
-            [['levelId'], 'exist', 'targetClass'=>EmployLevel::class, 'targetAttribute'=>'ID'],
-            [['userName'], 'isUser'],
-            [['levelId'], 'isLevel'],
-        ];
-    }
-
-    public function attributeLabels()
-    {
-        return [
-            'userName' => '会员编号',
-            'levelId' => '级别',
-            'isReset' => '是否重置',
-            'remark' => '期数',
-        ];
-    }
-
-    /**
-     * 指定校验场景
-     * @return array
-     */
-    public function scenarios()
-    {
-        $parentScenarios =  parent::scenarios();
-        $customScenarios = [
-            'adminChange' => ['userName', 'levelId', 'isReset', '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, '会员不存在');
-        }
-    }
-
-    /**
-     * 查看级别是否有变化
-     * @param $attribute
-     */
-    public function isLevel($attribute){
-        $userInfo = UserInfo::findOneAsArray('USER_ID=:USER_ID',[':USER_ID'=>$this->_userId],'SHOW_EMP_LV');
-        if($this->levelId == $userInfo['SHOW_EMP_LV']){
-            $this->addError($attribute, '前台显示级别没有变化无需调整');
-        }
-    }
-
-    /**
-     * 修改会员前台显示级别
-     * @return bool|null
-     * @throws \yii\db\Exception
-     */
-    public function adminChange(){
-        if(!$this->validate()){
-            return null;
-        }
-        $this->adminOperateLogger->beforeUpdate($this->_userId,'USER_ID',['select'=>'SHOW_EMP_LV']);
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            if ($this->isReset) {
-                UserInfo::updateAll(['SHOW_EMP_LV' => NULL], 'USER_ID=:USER_ID', [':USER_ID' => $this->_userId]);
-            } else {
-                UserInfo::updateAll(['SHOW_EMP_LV' => $this->levelId], 'USER_ID=:USER_ID', [':USER_ID' => $this->_userId]);
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('adminChange', $e->getMessage());
-            return null;
-        }
-        $this->adminOperateLogger->afterUpdate($this->_userId,'USER_ID',['select'=>'SHOW_EMP_LV'])->clean()->save([
-            'optType' => '修改会员前台显示聘级',
-            'userId' => $this->_userId,
-            'userName' => Info::getUserNameByUserId($this->_userId),
-            'remark' => $this->remark
-        ]);
-        return true;
-    }
-
-
-}

+ 0 - 147
common/models/forms/ClearDataForm.php

@@ -1,147 +0,0 @@
-<?php
-namespace common\models\forms;
-
-use common\helpers\user\Perf;
-use common\models\CalcBonus;
-use common\models\CalcBonusFX;
-use common\models\CalcBonusQY;
-use common\models\CalcBonusYC;
-use common\models\CFLXAudit;
-use common\models\ExcelAddUser;
-use common\models\ExcelImport;
-use common\models\FlowBonus;
-use common\models\FlowCF;
-use common\models\FlowLX;
-use common\models\InvoiceAudit;
-use common\models\InvoiceBalanceAudit;
-use common\models\InvoiceFlow;
-use common\models\Message;
-use common\models\MessageText;
-use common\models\PerfAudit;
-use common\models\PerfCompany;
-use common\models\PerfMonth;
-use common\models\PerfOrder;
-use common\models\PerfPeriod;
-use common\models\ReconsumeAudit;
-use common\models\ReconsumePool;
-use common\models\ReconsumePoolFlow;
-use common\models\RegInfoAudit;
-use common\models\ResendQY;
-use common\models\DecOrder;
-use common\models\Transfer;
-use common\models\User;
-use common\models\UserBind;
-use common\models\UserBonus;
-use common\models\UserClose;
-use common\models\UserMove;
-use common\models\UserNetwork;
-use common\models\UserPerf;
-use common\models\UserPerfUpdate;
-use common\models\UserRelation;
-use common\models\UserStatusAudit;
-use common\models\UserSystem;
-use common\models\UserTeamwork;
-use common\models\UserToken;
-use common\models\Withdraw;
-use Yii;
-use common\components\Model;
-use common\models\Period;
-use common\models\UserInfo;
-
-/**
- * Login form
- */
-class ClearDataForm extends Model
-{
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-        ];
-    }
-
-
-    public function clear(){
-        $userAddSqls = [
-            "INSERT INTO AR_USER_INFO (USER_ID, USER_NAME, ZC_PV, CON_UID, REC_UID, CON_NUM, REC_NUM, NETWORK_DEEP, RELATION_DEEP, SYSTEM_ID, IS_TEAM, IS_BIND, IS_TEAM_MAIN, IS_BIND_MAIN, IS_AUTO_WITHDRAW, CLOSE_LOGIN, REG_TYPE, REG_NAME, CREDIT_CODE, PREMISES, LEGAL_PERSON, REG_EXPIRES, STORE_TYPE, INVOICE_BALANCE, PERIOD_NUM, CREATED_AT, UPDATED_AT, CLOSE_LOGIN_AT, PULLED_AT) VALUES ('670B84FD7C216D4EE055736AECE8644D', 'tester001', 600.000, '0', '0', 3, 3, 0, 0, null, 0, 0, 0, 0, 1, 0, '56D9181C0F5D428FA2DBD4CAB263BF2F', null, null, null, null, null, 2, 0.00, 100, 1520667339, 0, 0, 1548917447)",
-            "INSERT INTO AR_USER_INFO (USER_ID, USER_NAME, ZC_PV, CON_UID, REC_UID, CON_NUM, REC_NUM, NETWORK_DEEP, RELATION_DEEP, SYSTEM_ID, IS_TEAM, IS_BIND, IS_TEAM_MAIN, IS_BIND_MAIN, IS_AUTO_WITHDRAW, CLOSE_LOGIN, REG_TYPE, REG_NAME, CREDIT_CODE, PREMISES, LEGAL_PERSON, REG_EXPIRES, STORE_TYPE, INVOICE_BALANCE, PERIOD_NUM, CREATED_AT, UPDATED_AT, CLOSE_LOGIN_AT, PULLED_AT) VALUES ('B322C18F7E274A9D9FC5DADC3B385E8B', 'tester002', 101000.000, '670B84FD7C216D4EE055736AECE8644D', '670B84FD7C216D4EE055736AECE8644D', 0, 0, 1, 1, null, 0, 0, 0, 0, 0, 0, '56D9181C0F5D428FA2DBD4CAB263BF2F', null, null, null, null, null, 0, 0.00, 100, 1524560688, 0, 0, 1546569294)",
-            "INSERT INTO AR_USER_INFO (USER_ID, USER_NAME, ZC_PV, CON_UID, REC_UID, CON_NUM, REC_NUM, NETWORK_DEEP, RELATION_DEEP, SYSTEM_ID, IS_TEAM, IS_BIND, IS_TEAM_MAIN, IS_BIND_MAIN, IS_AUTO_WITHDRAW, CLOSE_LOGIN, REG_TYPE, REG_NAME, CREDIT_CODE, PREMISES, LEGAL_PERSON, REG_EXPIRES, STORE_TYPE, INVOICE_BALANCE, PERIOD_NUM, CREATED_AT, UPDATED_AT, CLOSE_LOGIN_AT, PULLED_AT) VALUES ('638A5A3B617F46C999C5E4D072EED369', 'tester003', 101000.000, '670B84FD7C216D4EE055736AECE8644D', '670B84FD7C216D4EE055736AECE8644D', 0, 0, 1, 1, null, 0, 0, 0, 0, 0, 0, '56D9181C0F5D428FA2DBD4CAB263BF2F', null, null, null, null, null, 0, 0.00, 100, 1524620621, 0, 0, 0)",
-            "INSERT INTO AR_USER_INFO (USER_ID, USER_NAME, ZC_PV, CON_UID, REC_UID, CON_NUM, REC_NUM, NETWORK_DEEP, RELATION_DEEP, SYSTEM_ID, IS_TEAM, IS_BIND, IS_TEAM_MAIN, IS_BIND_MAIN, IS_AUTO_WITHDRAW, CLOSE_LOGIN, REG_TYPE, REG_NAME, CREDIT_CODE, PREMISES, LEGAL_PERSON, REG_EXPIRES, STORE_TYPE, INVOICE_BALANCE, PERIOD_NUM, CREATED_AT, UPDATED_AT, CLOSE_LOGIN_AT, PULLED_AT) VALUES ('3C313C66D1724D658BF10B08194022BB', 'tester004', 101000.000, '670B84FD7C216D4EE055736AECE8644D', '670B84FD7C216D4EE055736AECE8644D', 0, 0, 1, 1, null, 0, 0, 0, 0, 0, 0, '56D9181C0F5D428FA2DBD4CAB263BF2F', null, null, null, null, null, 0, 0.00, 100, 1524621346, 0, 0, 0)"
-        ];
-        $userNetworkSqls = [
-            "INSERT INTO AR_USER_NETWORK (ID, USER_ID, PARENT_UID, LOCATION, TOP_UID, TOP_DEEP, PERIOD_NUM, CREATED_AT, UPDATED_AT) VALUES ('D2DCC45A9B3A414F80F4239521A9744A', '638A5A3B617F46C999C5E4D072EED369', '670B84FD7C216D4EE055736AECE8644D', 2, '670B84FD7C216D4EE055736AECE8644D', 1, 100, 1524620621, 0)",
-            "INSERT INTO AR_USER_NETWORK (ID, USER_ID, PARENT_UID, LOCATION, TOP_UID, TOP_DEEP, PERIOD_NUM, CREATED_AT, UPDATED_AT) VALUES ('E953B0CA08B74D9DB722813E9297BAF2', 'B322C18F7E274A9D9FC5DADC3B385E8B', '670B84FD7C216D4EE055736AECE8644D', 1, '670B84FD7C216D4EE055736AECE8644D', 1, 100, 1524560688, 0)",
-            "INSERT INTO AR_USER_NETWORK (ID, USER_ID, PARENT_UID, LOCATION, TOP_UID, TOP_DEEP, PERIOD_NUM, CREATED_AT, UPDATED_AT) VALUES ('8F793577F2A44947A5918852976AE290', '670B84FD7C216D4EE055736AECE8644D', '0', 0, '670B84FD7C216D4EE055736AECE8644D', 0, 100, 1522378282, 0)",
-            "INSERT INTO AR_USER_NETWORK (ID, USER_ID, PARENT_UID, LOCATION, TOP_UID, TOP_DEEP, PERIOD_NUM, CREATED_AT, UPDATED_AT) VALUES ('707F8F4ADEA14A4EA98ABC9A99999C7B', '3C313C66D1724D658BF10B08194022BB', '670B84FD7C216D4EE055736AECE8644D', 3, '670B84FD7C216D4EE055736AECE8644D', 1, 100, 1524621346, 1549072802)"
-        ];
-        $userRelationSqls = ["INSERT INTO AR_USER_RELATION (ID, USER_ID, PARENT_UID, TOP_UID, TOP_DEEP, PERIOD_NUM, CREATED_AT, UPDATED_AT) VALUES ('392F8963D2A4489F8854FC12A4D9E2F6', '638A5A3B617F46C999C5E4D072EED369', '670B84FD7C216D4EE055736AECE8644D', '670B84FD7C216D4EE055736AECE8644D', 1, 100, 1524620621, 0)",
-            "INSERT INTO AR_USER_RELATION (ID, USER_ID, PARENT_UID, TOP_UID, TOP_DEEP, PERIOD_NUM, CREATED_AT, UPDATED_AT) VALUES ('EBBD679E049C4B60993FFB751C7AF410', '3C313C66D1724D658BF10B08194022BB', '670B84FD7C216D4EE055736AECE8644D', '670B84FD7C216D4EE055736AECE8644D', 1, 100, 1524621346, 0)",
-            "INSERT INTO AR_USER_RELATION (ID, USER_ID, PARENT_UID, TOP_UID, TOP_DEEP, PERIOD_NUM, CREATED_AT, UPDATED_AT) VALUES ('585A9E67D922443698C09D99A32F33A9', 'B322C18F7E274A9D9FC5DADC3B385E8B', '670B84FD7C216D4EE055736AECE8644D', '670B84FD7C216D4EE055736AECE8644D', 1, 100, 1524560688, 0)",
-            "INSERT INTO AR_USER_RELATION (ID, USER_ID, PARENT_UID, TOP_UID, TOP_DEEP, PERIOD_NUM, CREATED_AT, UPDATED_AT) VALUES ('EF010C38C7144BD0844593A1FF8AC7AD', '670B84FD7C216D4EE055736AECE8644D', '0', '670B84FD7C216D4EE055736AECE8644D', 0, 100, 1522378282, 0)"
-        ];
-//        UserInfo::updateAll(['CON_NUM' => 3, 'REC_NUM' => 3, 'NETWORK_DEEP'=>0, 'RELATION_DEEP'=>0], 'USER_ID=:USER_ID', [':USER_ID'=>'670B84FD7C216D4EE055736AECE8644D']);
-//        UserInfo::deleteAll("USER_ID NOT IN ('638A5A3B617F46C999C5E4D072EED369', '3C313C66D1724D658BF10B08194022BB', 'B322C18F7E274A9D9FC5DADC3B385E8B', '670B84FD7C216D4EE055736AECE8644D')");
-//        UserNetwork::deleteAll("USER_ID NOT IN ('638A5A3B617F46C999C5E4D072EED369', '3C313C66D1724D658BF10B08194022BB', 'B322C18F7E274A9D9FC5DADC3B385E8B', '670B84FD7C216D4EE055736AECE8644D')");
-//        UserRelation::deleteAll("USER_ID NOT IN ('638A5A3B617F46C999C5E4D072EED369', '3C313C66D1724D658BF10B08194022BB', 'B322C18F7E274A9D9FC5DADC3B385E8B', '670B84FD7C216D4EE055736AECE8644D')");
-//        UserInfo::updateAll(['CON_NUM' => 0, 'REC_NUM' => 0, 'IS_TEAM'=>0, 'IS_BIND'=>0, 'IS_TEAM_MAIN'=>0, 'IS_BIND_MAIN'=>0, 'IS_AUTO_WITHDRAW'=>0, 'CLOSE_LOGIN'=>0, 'REG_TYPE'=>'56D9181C0F5D428FA2DBD4CAB263BF2F', 'REG_NAME'=>null], "USER_ID IN ('638A5A3B617F46C999C5E4D072EED369', '3C313C66D1724D658BF10B08194022BB', 'B322C18F7E274A9D9FC5DADC3B385E8B')");
-        UserInfo::deleteAll('1=1');
-        UserNetwork::deleteAll('1=1');
-        UserRelation::deleteAll('1=1');
-        foreach($userAddSqls as $value){
-            Yii::$app->db->createCommand($value)->query();
-        }
-        foreach($userNetworkSqls as $value){
-            Yii::$app->db->createCommand($value)->query();
-        }
-        foreach($userRelationSqls as $value){
-            Yii::$app->db->createCommand($value)->query();
-        }
-//        Period::updateAll(['IS_CLOSED'=>0, 'IS_CALCULATED'=>0, 'IS_SENT'=>0, 'IS_CALCING'=>0, 'CALCULATED_AT'=>null, ], '1=1');
-        CalcBonus::deleteAll('1=1');
-        CalcBonusFX::deleteAll('1=1');
-        CalcBonusQY::deleteAll('1=1');
-        CalcBonusYC::deleteAll('1=1');
-        CFLXAudit::deleteAll('1=1');
-        ExcelAddUser::deleteAll('1=1');
-        ExcelImport::deleteAll('1=1');
-        FlowBonus::deleteAll('1=1');
-        FlowCF::deleteAll('1=1');
-        FlowLX::deleteAll('1=1');
-        InvoiceAudit::deleteAll('1=1');
-        InvoiceBalanceAudit::deleteAll('1=1');
-        InvoiceFlow::deleteAll('1=1');
-        Message::deleteAll('1=1');
-        MessageText::deleteAll('1=1');
-        PerfAudit::deleteAll('1=1');
-        PerfCompany::deleteAll('1=1');
-        PerfMonth::deleteAll('1=1');
-        PerfOrder::deleteAll('1=1');
-        PerfPeriod::deleteAll('1=1');
-        ReconsumeAudit::deleteAll('1=1');
-        ReconsumePool::deleteAll('1=1');
-        ReconsumePoolFlow::deleteAll('1=1');
-        RegInfoAudit::deleteAll('1=1');
-        ResendQY::deleteAll('1=1');
-        Transfer::deleteAll('1=1');
-        UserBind::deleteAll('1=1');
-        UserBonus::deleteAll('1=1');
-        UserClose::deleteAll('1=1');
-        UserMove::deleteAll('1=1');
-        UserPerf::deleteAll('1=1');
-        UserPerfUpdate::deleteAll('1=1');
-        UserStatusAudit::deleteAll('1=1');
-        UserSystem::deleteAll('1=1');
-        UserTeamwork::deleteAll('1=1');
-        UserToken::deleteAll('1=1');
-        Withdraw::deleteAll('1=1');
-
-        // 商城表
-        User::deleteAll("ID NOT IN ('638A5A3B617F46C999C5E4D072EED369', '3C313C66D1724D658BF10B08194022BB', 'B322C18F7E274A9D9FC5DADC3B385E8B', '670B84FD7C216D4EE055736AECE8644D')");
-        DecOrder::deleteAll('1=1');
-
-        return true;
-    }
-}

+ 0 - 216
common/models/forms/CloseDecForm.php

@@ -1,216 +0,0 @@
-<?php
-namespace common\models\forms;
-
-use common\helpers\Date;
-use common\components\Model;
-use common\helpers\Form;
-use common\helpers\user\Info;
-use common\libs\logging\operate\AdminOperate;
-use common\models\Period;
-use common\models\Region;
-use common\models\User;
-use common\models\UserClose;
-use common\models\UserInfo;
-use common\models\UserNetwork;
-use common\models\UserRelation;
-use common\models\UserSystem;
-use yii\base\Exception;
-
-/**
- * Class CloseDecForm
- * @package common\models\forms
- */
-class CloseDecForm extends Model
-{
-    public $userIds;
-    public $userName;
-    public $remark;
-    public $type;  // 1:单独关闭个人,2:按推荐网络关闭,3:按安置网络关闭,4:按体系关闭
-    public $isClose; // 0: 允许报单, 1:禁止报单
-    public $areaSelected; //地区选择
-
-    private $_userId;
-    private $_userSystem;
-
-    public static $types = [
-        1 => '按指定会员',
-        2 => '按开拓网络',
-        3 => '按安置网络',
-        4 => '按体系',
-        5 => '按地区',
-    ];
-
-    public static $closeSwitch = [
-        0 => '允许报单',
-        1 => '禁止报单',
-    ];
-
-    public function init()
-    {
-        parent::init();
-        $this->adminOperateLogger = new AdminOperate([
-            'fetchClass' => User::class,
-        ]);
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['userIds', 'userName', 'type', 'isClose', 'areaSelected', 'remark'], 'trim'],
-            [['userIds', 'userName', 'type', 'isClose', 'areaSelected'], 'required'],
-            [['userName'], 'initUserId'],
-            [['type'], 'isType'],
-        ];
-    }
-
-    /**
-     * 指定校验场景
-     * @return array
-     */
-    public function scenarios()
-    {
-        $parentScenarios =  parent::scenarios();
-        $customScenarios = [
-            // 单独禁止报单
-            'single' => ['userName', 'type', 'isClose', 'remark'],
-            // 批量禁止
-            'batch' => ['userIds', 'type', 'isClose', 'remark'],
-            // 按地区关闭
-            'area' => ['isClose', 'type', 'areaSelected', 'remark'],
-        ];
-        return array_merge($parentScenarios, $customScenarios);
-    }
-
-    public function attributeLabels()
-    {
-        return [
-            'userName' => '会员编号',
-            'type' => '类型',
-            'remark' => '备注',
-        ];
-    }
-
-    /**
-     * 初始化会员ID
-     * @param $attribute
-     */
-    public function initUserId($attribute){
-        $this->_userId = Info::getUserIdByUserName($this->userName);
-        if(!$this->_userId){
-            $this->addError($attribute, '会员不存在');
-        }
-    }
-
-
-    /**
-     * 状态类型校验
-     * @param $attribute
-     */
-    public function isType($attribute){
-        if($this->type == 4){
-            $this->_userSystem = UserSystem::getSystemByUserId($this->_userId);
-            if($this->_userSystem){
-                if($this->_userSystem['LEADER_UID'] != $this->_userId){
-                    $this->addError($attribute, '按体系管理报单必须是体系领导人');
-                }
-            }  else {
-                $this->addError($attribute, '体系不存在');
-            }
-        }
-    }
-
-    /**
-     * 批量处理
-     * @return array|null
-     * @throws \yii\db\Exception
-     */
-    public function batch(){
-        if(!$this->validate()){
-            return null;
-        }
-        $this->adminOperateLogger->setIsBatch(true)->beforeUpdate($this->userIds, 'ID',['select'=>'ID,DEC_CLOSED,DEC_CLOSED_AT']);
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            if($this->isClose){
-                $closedAt = Date::nowTime();
-            } else {
-                $closedAt = 0;
-            }
-            $allUidIn = implode("','", $this->userIds);
-            User::updateAll(['DEC_CLOSED'=> $this->isClose ? $this->isClose : 0,'DEC_CLOSED_AT'=>$closedAt], "ID IN ('".$allUidIn."')");
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('batch', $e->getMessage());
-            return null;
-        }
-        $this->adminOperateLogger->setIsBatch(true)->afterUpdate($this->userIds, 'ID',['select'=>'ID,DEC_CLOSED,DEC_CLOSED_AT']);
-        $this->adminOperateLogger->setBatchField('ID')->setOptObjField('ID')->clean()->save([
-            'optType' => self::$types[$this->type].self::$closeSwitch[$this->isClose],
-            'remark' => $this->remark,
-        ]);
-        return $this->userIds;
-    }
-
-    /**
-     * 按照地区关闭
-     * @return bool|null
-     * @throws \yii\db\Exception
-     */
-    public function area(){
-        if(!$this->validate()){
-            return null;
-        }
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            if($this->isClose){
-                $closedAt = Date::nowTime();
-            } else {
-                $closedAt = 0;
-            }
-            $where = '';
-            $params = [];
-            if(isset($this->areaSelected[0]) && $this->areaSelected[0]){
-                $where .= 'PROVINCE=:PROVINCE';
-                $params[':PROVINCE'] = $this->areaSelected[0];
-            }
-            if(isset($this->areaSelected[1]) && $this->areaSelected[1]){
-                $where .= ' AND CITY=:CITY';
-                $params[':CITY'] = $this->areaSelected[1];
-            }
-            if(isset($this->areaSelected[2]) && $this->areaSelected[1]){
-                $where .= ' AND COUNTY=:COUNTY';
-                $params[':COUNTY'] = $this->areaSelected[2];
-            }
-
-            $allUser = User::findAllAsArray($where,$params,'ID');
-            $allUserIds = array_column($allUser, 'ID');
-            $this->adminOperateLogger->setIsBatch(true)->beforeUpdate($allUserIds, 'ID',['select'=>'ID,DEC_CLOSED,DEC_CLOSED_AT']);
-
-            User::updateAll(['DEC_CLOSED'=> $this->isClose ? $this->isClose : 0,'DEC_CLOSED_AT'=>$closedAt], $where,$params);
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('area', $e->getMessage());
-            return null;
-        }
-
-        $this->adminOperateLogger->setIsBatch(true)->afterUpdate($allUserIds, 'ID', ['select' => 'ID,DEC_CLOSED,DEC_CLOSED_AT']);
-        $province = isset($this->areaSelected[0]) ? Region::getCnName($this->areaSelected[0]) : '';
-        $city = isset($this->areaSelected[1]) ? Region::getCnName($this->areaSelected[1]) : '';
-        $county = isset($this->areaSelected[2]) ? Region::getCnName($this->areaSelected[2]) : '';
-        $this->adminOperateLogger->setBatchField('ID')->setOptObjField('ID')->clean()->save([
-            'optType' => self::$types[$this->type] . $province . $city . $county . self::$closeSwitch[$this->isClose],
-            'remark' => $this->remark,
-        ]);
-
-        return true;
-    }
-
-
-}

+ 0 - 217
common/models/forms/CloseLoginForm.php

@@ -1,217 +0,0 @@
-<?php
-namespace common\models\forms;
-
-use common\helpers\Date;
-use common\components\Model;
-use common\helpers\Form;
-use common\helpers\Tool;
-use common\helpers\user\Info;
-use common\libs\logging\operate\AdminOperate;
-use common\models\Period;
-use common\models\Region;
-use common\models\User;
-use common\models\UserClose;
-use common\models\UserInfo;
-use common\models\UserNetwork;
-use common\models\UserRelation;
-use common\models\UserSystem;
-use yii\base\Exception;
-
-/**
- * Login form
- */
-class CloseLoginForm extends Model
-{
-    public $userIds;
-    public $userName;
-    public $remark;
-    public $type;  // 1:单独关闭个人,2:按推荐网络关闭,3:按安置网络关闭,4:按体系关闭
-    public $isClose; // 0: 允许登录, 1:禁止登录
-    public $areaSelected; //地区选择
-
-    private $_userId;
-    private $_userSystem;
-
-    public static $types = [
-        1 => '按指定会员',
-        2 => '按开拓网络',
-        3 => '按安置网络',
-        4 => '按体系',
-        5 => '按地区',
-    ];
-
-    public static $closeSwitch = [
-        0 => '允许登录',
-        1 => '禁止登录',
-    ];
-
-    public function init()
-    {
-        parent::init();
-        $this->adminOperateLogger = new AdminOperate([
-            'fetchClass' => User::class,
-        ]);
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['userIds', 'userName', 'type', 'isClose', 'areaSelected', 'remark'], 'trim'],
-            [['userIds', 'userName', 'type', 'isClose', 'areaSelected'], 'required'],
-            [['userName'], 'initUserId'],
-            [['type'], 'isType'],
-        ];
-    }
-
-    /**
-     * 指定校验场景
-     * @return array
-     */
-    public function scenarios()
-    {
-        $parentScenarios =  parent::scenarios();
-        $customScenarios = [
-            // 单独禁止登录或加入黑名单
-            'single' => ['userName', 'type', 'isClose', 'remark'],
-            // 批量禁止
-            'batch' => ['userIds', 'type', 'isClose', 'remark'],
-            // 按地区关闭
-            'area' => ['type', 'isClose', 'areaSelected', 'remark'],
-        ];
-        return array_merge($parentScenarios, $customScenarios);
-    }
-
-    public function attributeLabels()
-    {
-        return [
-            'userName' => '会员编号',
-            'type' => '类型',
-            'remark' => '备注',
-        ];
-    }
-
-    /**
-     * 初始化会员ID
-     * @param $attribute
-     */
-    public function initUserId($attribute){
-        $this->_userId = Info::getUserIdByUserName($this->userName);
-        if(!$this->_userId){
-            $this->addError($attribute, '会员不存在');
-        }
-    }
-
-
-    /**
-     * 状态类型校验
-     * @param $attribute
-     */
-    public function isType($attribute){
-        if($this->type == 4){
-            $this->_userSystem = UserSystem::getSystemByUserId($this->_userId);
-            if($this->_userSystem){
-                if($this->_userSystem['LEADER_UID'] != $this->_userId){
-                    $this->addError($attribute, '按体系管理登录必须是体系领导人');
-                }
-            }  else {
-                $this->addError($attribute, '体系不存在');
-            }
-        }
-    }
-
-    /**
-     * 批量处理
-     * @return array|null
-     * @throws \yii\db\Exception
-     */
-    public function batch(){
-        if(!$this->validate()){
-            return null;
-        }
-        $this->adminOperateLogger->setIsBatch(true)->beforeUpdate($this->userIds, 'ID',['select'=>'ID,ALLOW_LOGIN']);
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            if($this->isClose){
-                $closedAt = Date::nowTime();
-            } else {
-                $closedAt = 0;
-            }
-            $allUidIn = implode("','", $this->userIds);
-            User::updateAll(['ALLOW_LOGIN'=>!$this->isClose], "ID IN ('".$allUidIn."')");
-
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('batch', $e->getMessage());
-            return null;
-        }
-        $this->adminOperateLogger->setIsBatch(true)->afterUpdate($this->userIds, 'ID',['select'=>'ID,ALLOW_LOGIN']);
-        $this->adminOperateLogger->setBatchField('ID')->setOptObjField('ID')->clean()->save([
-            'optType' => self::$types[$this->type].self::$closeSwitch[$this->isClose],
-            'remark' => $this->remark,
-        ]);
-
-        return $this->userIds;
-    }
-
-    /**
-     * 按照地区关闭
-     * @return bool|null
-     * @throws \yii\db\Exception
-     */
-    public function area(){
-        if(!$this->validate()){
-            return null;
-        }
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            if($this->isClose){
-                $closedAt = Date::nowTime();
-            } else {
-                $closedAt = 0;
-            }
-            $where = '';
-            $params = [];
-            if(isset($this->areaSelected[0]) && $this->areaSelected[0]){
-                $where .= 'PROVINCE=:PROVINCE';
-                $params[':PROVINCE'] = $this->areaSelected[0];
-            }
-            if(isset($this->areaSelected[1]) && $this->areaSelected[1]){
-                $where .= ' AND CITY=:CITY';
-                $params[':CITY'] = $this->areaSelected[1];
-            }
-            if(isset($this->areaSelected[2]) && $this->areaSelected[1]){
-                $where .= ' AND COUNTY=:COUNTY';
-                $params[':COUNTY'] = $this->areaSelected[2];
-            }
-
-            $allUser = User::findAllAsArray($where,$params,'ID');
-            $allUserIds = array_column($allUser, 'ID');
-            $this->adminOperateLogger->setIsBatch(true)->beforeUpdate($allUserIds, 'ID',['select'=>'ID,ALLOW_LOGIN']);
-
-            User::updateAll(['ALLOW_LOGIN'=>!$this->isClose], $where,$params);
-
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('area', $e->getMessage());
-            return null;
-        }
-        $this->adminOperateLogger->setIsBatch(true)->afterUpdate($allUserIds, 'ID', ['select' => 'ID,ALLOW_LOGIN']);
-        $province = isset($this->areaSelected[0]) ? Region::getCnName($this->areaSelected[0]) : '';
-        $city = isset($this->areaSelected[1]) ? Region::getCnName($this->areaSelected[1]) : '';
-        $county = isset($this->areaSelected[2]) ? Region::getCnName($this->areaSelected[2]) : '';
-        $this->adminOperateLogger->setBatchField('ID')->setOptObjField('ID')->clean()->save([
-            'optType' => self::$types[$this->type] . $province . $city . $county . self::$closeSwitch[$this->isClose],
-            'remark' => $this->remark,
-        ]);
-        return true;
-    }
-
-
-}

+ 0 - 62
common/models/forms/ConfigBonusForm.php

@@ -1,62 +0,0 @@
-<?php
-namespace common\models\forms;
-
-use common\components\Model;
-use common\helpers\Date;
-use common\models\Config;
-use yii\db\Exception;
-
-/**
- * Login form
- */
-class ConfigBonusForm extends Model
-{
-    public $retailPoolPercent;
-    public $retailPercent;
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['retailPoolPercent', 'retailPercent'], 'required'],
-            [['retailPoolPercent', 'retailPercent'], 'number', 'max'=>100, 'min'=>0],
-        ];
-    }
-
-    public function attributeLabels()
-    {
-        return [
-            'retailPoolPercent' => '进入零售池比例',
-            'retailPercent' => '零售奖比例',
-        ];
-    }
-
-    /**
-     * 更新配置
-     * @return bool|null
-     * @throws Exception
-     */
-    public function update(){
-        if(!$this->validate()){
-            return null;
-        }
-        $transaction = \Yii::$app->db->beginTransaction();
-        try{
-            if(!Config::updateAll(['VALUE'=>$this->retailPoolPercent, 'UPDATED_AT'=>Date::nowTime()], "CONFIG_NAME='retailPoolPercent'")){
-                throw new Exception('进入零售池比例更新失败');
-            }
-            if(!Config::updateAll(['VALUE'=>$this->retailPercent, 'UPDATED_AT'=>Date::nowTime()], "CONFIG_NAME='retailPercent'")){
-                throw new Exception('零售奖比例更新失败');
-            }
-            $transaction->commit();
-        } catch (Exception $e){
-            $transaction->rollBack();
-            $this->addError('retailPoolPercent', $e->getMessage());
-            return null;
-        }
-        return true;
-
-    }
-}

+ 0 - 312
common/models/forms/ConfigForm.php

@@ -1,312 +0,0 @@
-<?php
-namespace common\models\forms;
-
-use common\components\Model;
-use common\helpers\Date;
-use common\libs\logging\operate\AdminOperate;
-use common\models\Config;
-use yii\db\Exception;
-use yii\helpers\Json;
-
-/**
- * Login form
- */
-class ConfigForm extends Model
-{
-    const BONUS_TO_STRING_FIELD = [
-        //共享奖
-        'shareRecIncomeFrom',
-        'shareIncomeFrom',
-        //管理奖
-        'parentOddIncomeFrom_0',
-        'parentOddIncomeFrom_1',
-        'parentOddIncomeFrom_2',
-        'parentOddIncomeFrom_3',
-
-        //共享奖-复消
-        'fxShareRecIncomeFrom',
-        'fxShareIncomeFrom',
-        //管理奖
-        'fxParentOddIncomeFrom_0',
-        'fxParentOddIncomeFrom_1',
-        'fxParentOddIncomeFrom_2',
-        'fxParentOddIncomeFrom_3',
-        //服务奖
-        'decRoleBonusFrom',
-    ];
-
-    const BONUS_JSON_FIELD = [
-        'jxStandard'
-    ];
-
-    public function init() {
-        parent::init();
-        $this->adminOperateLogger = new AdminOperate([
-            'fetchClass' => Config::class,
-        ]);
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            //[['postData'], 'required'],
-        ];
-    }
-
-    public function attributeLabels()
-    {
-        return [
-            //'postData' => '传入数据',
-        ];
-    }
-
-    /**
-     * 更新配置
-     * @return bool|null
-     * @throws Exception
-     */
-    public function updateBase(){
-        if(!$this->validate()){
-            return null;
-        }
-        $configs = Config::find()->where("TYPE='base'")->orderBy('SORT ASC')->indexBy('CONFIG_NAME')->asArray()->all();
-        $configNames = [];
-        foreach ($configs as $value){
-            $configNames[] = $value['CONFIG_NAME'];
-        }
-        $beforeData = Config::getConfigByType('base');
-        $this->adminOperateLogger->saveBeforeContent=$beforeData;
-        $postData = \Yii::$app->request->post();
-        $transaction = \Yii::$app->db->beginTransaction();
-        try{
-            foreach ($configs as $key => $value) {
-                if (array_key_exists($key, $postData)) {
-                    if (!$postData[$key]) $postData[$key] = 0;
-                    Config::updateAll(['VALUE' => $postData[$key], 'UPDATED_AT' => Date::nowTime()], "CONFIG_NAME=:CONFIG_NAME", [':CONFIG_NAME' => $key]);
-                }
-            }
-            $transaction->commit();
-        } catch (Exception $e){
-            $transaction->rollBack();
-            $this->addError('updateBase', $e->getMessage());
-            return null;
-        }
-        $afterData = Config::getConfigByType('base');
-        $this->adminOperateLogger->saveAfterContent=$afterData;
-        unset($beforeData,$afterData);
-        $this->adminOperateLogger->clean()->save([
-            'optType' => '更新站点设置',
-        ]);
-        return true;
-    }
-
-    /**
-     * 更新奖金配置
-     * @return bool|null
-     * @throws Exception
-     */
-    public function updateBonus(){
-        if(!$this->validate()){
-            return null;
-        }
-        $configs = Config::find()->where("TYPE='bonus'")->orderBy('SORT ASC')->indexBy('CONFIG_NAME')->asArray()->all();
-        $configNames = [];
-        foreach ($configs as $value){
-            $configNames[] = $value['CONFIG_NAME'];
-        }
-        $beforeData = Config::getConfigByType('bonus');
-        $this->adminOperateLogger->saveBeforeContent=$beforeData;
-        $postData = \Yii::$app->request->post();
-        $transaction = \Yii::$app->db->beginTransaction();
-        try{
-            foreach ($configs as $key => $value) {
-                if (array_key_exists($key, $postData)) {
-                    if (!$postData[$key]) $postData[$key] = 0;
-                    if( in_array($key, self::BONUS_TO_STRING_FIELD) ) $postData[$key] = implode(",", $postData[$key]);
-                    if( in_array($key, self::BONUS_JSON_FIELD) ) $postData[$key] = JSON::encode($postData[$key]);
-
-                    Config::updateAll(['VALUE' => $postData[$key], 'UPDATED_AT' => Date::nowTime()], "CONFIG_NAME=:CONFIG_NAME", [':CONFIG_NAME' => $key]);
-                }
-            }
-            $transaction->commit();
-        } catch (Exception $e){
-            $transaction->rollBack();
-            $this->addError('updateBase', $e->getMessage());
-            return null;
-        }
-        $afterData = Config::getConfigByType('bonus');
-        $this->adminOperateLogger->saveAfterContent=$afterData;
-        unset($beforeData,$afterData);
-        $this->adminOperateLogger->clean()->save([
-            'optType' => '更新奖金配置',
-        ]);
-        return true;
-    }
-
-    /**
-     * 更新短信配置
-     * @return bool|null
-     * @throws Exception
-     */
-    public function updateSms(){
-        if(!$this->validate()){
-            return null;
-        }
-        $configs = Config::find()->where("TYPE='sms'")->orderBy('SORT ASC')->indexBy('CONFIG_NAME')->asArray()->all();
-        $configNames = [];
-        foreach ($configs as $value){
-            $configNames[] = $value['CONFIG_NAME'];
-        }
-        $beforeData = Config::getConfigByType('sms');
-        $this->adminOperateLogger->saveBeforeContent=$beforeData;
-        $postData = \Yii::$app->request->post();
-        $transaction = \Yii::$app->db->beginTransaction();
-        try{
-            foreach ($configs as $key => $value) {
-                if (array_key_exists($key, $postData)) {
-                    if (!$postData[$key]) $postData[$key] = 0;
-                    if(is_array($postData[$key])) $postData[$key] = implode(",", $postData[$key]);
-                    Config::updateAll(['VALUE' => $postData[$key], 'UPDATED_AT' => Date::nowTime()], "CONFIG_NAME=:CONFIG_NAME", [':CONFIG_NAME' => $key]);
-                }
-            }
-            $transaction->commit();
-        } catch (Exception $e){
-            $transaction->rollBack();
-            $this->addError('updateSms', $e->getMessage());
-            return null;
-        }
-        $afterData = Config::getConfigByType('sms');
-        $this->adminOperateLogger->saveAfterContent=$afterData;
-        unset($beforeData,$afterData);
-        $this->adminOperateLogger->clean()->save([
-            'optType' => '更新短信配置',
-        ]);
-        return true;
-    }
-
-    /**
-     * 更新转账配置
-     * @return bool|null
-     * @throws Exception
-     */
-    public function updateTransfer(){
-        if(!$this->validate()){
-            return null;
-        }
-        $configs = Config::find()->where("TYPE='transfer'")->orderBy('SORT ASC')->indexBy('CONFIG_NAME')->asArray()->all();
-        $configNames = [];
-        foreach ($configs as $value){
-            $configNames[] = $value['CONFIG_NAME'];
-        }
-        $beforeData = Config::getConfigByType('transfer');
-        $this->adminOperateLogger->saveBeforeContent=$beforeData;
-        $postData = \Yii::$app->request->post();
-        $transaction = \Yii::$app->db->beginTransaction();
-        try{
-            foreach ($configs as $key => $value) {
-                if (array_key_exists($key, $postData)) {
-                    if (!$postData[$key]) $postData[$key] = 0;
-                    if(is_array($postData[$key])) $postData[$key] = Json::encode($postData[$key]);
-                    Config::updateAll(['VALUE' => $postData[$key], 'UPDATED_AT' => Date::nowTime()], "CONFIG_NAME=:CONFIG_NAME", [':CONFIG_NAME' => $key]);
-                }
-            }
-            $transaction->commit();
-        } catch (Exception $e){
-            $transaction->rollBack();
-            $this->addError('updateTransfer', $e->getMessage());
-            return null;
-        }
-        $afterData = Config::getConfigByType('transfer');
-        $this->adminOperateLogger->saveAfterContent=$afterData;
-        unset($beforeData,$afterData);
-        $this->adminOperateLogger->clean()->save([
-            'optType' => '更新转账配置',
-        ]);
-        return true;
-    }
-
-    /**
-     * 更新分数配置
-     * @return bool|null
-     * @throws Exception
-     */
-    public function updateScore(){
-        if(!$this->validate()){
-            return null;
-        }
-        $configs = Config::find()->where("TYPE='score'")->orderBy('SORT ASC')->indexBy('CONFIG_NAME')->asArray()->all();
-        $configNames = [];
-        foreach ($configs as $value){
-            $configNames[] = $value['CONFIG_NAME'];
-        }
-        $beforeData = Config::getConfigByType('score');
-        $this->adminOperateLogger->saveBeforeContent=$beforeData;
-        $postData = \Yii::$app->request->post();
-        $transaction = \Yii::$app->db->beginTransaction();
-        try{
-            foreach ($configs as $key => $value) {
-                if (array_key_exists($key, $postData)) {
-                    if (!$postData[$key]) $postData[$key] = 0;
-                    if(is_array($postData[$key])) $postData[$key] = Json::encode($postData[$key]);
-                    Config::updateAll(['VALUE' => $postData[$key], 'UPDATED_AT' => Date::nowTime()], "CONFIG_NAME=:CONFIG_NAME", [':CONFIG_NAME' => $key]);
-                }
-            }
-            $transaction->commit();
-        } catch (Exception $e){
-            $transaction->rollBack();
-            $this->addError('updateScore', $e->getMessage());
-            return null;
-        }
-        $afterData = Config::getConfigByType('score');
-        $this->adminOperateLogger->saveAfterContent=$afterData;
-        unset($beforeData,$afterData);
-        $this->adminOperateLogger->clean()->save([
-            'optType' => '更新分数配置',
-        ]);
-        return true;
-    }
-
-    /**
-     * 更新其他配置
-     * @return bool|null
-     * @throws Exception
-     */
-    public function updateOther(){
-        if(!$this->validate()){
-            return null;
-        }
-        $configs = Config::find()->where("TYPE='other'")->orderBy('SORT ASC')->indexBy('CONFIG_NAME')->asArray()->all();
-        $configNames = [];
-        foreach ($configs as $value){
-            $configNames[] = $value['CONFIG_NAME'];
-        }
-        $beforeData = Config::getConfigByType('other');
-        $this->adminOperateLogger->saveBeforeContent=$beforeData;
-        $postData = \Yii::$app->request->post();
-        $transaction = \Yii::$app->db->beginTransaction();
-        try{
-            foreach ($configs as $key => $value) {
-                if (array_key_exists($key, $postData)) {
-                    if (!$postData[$key]) $postData[$key] = 0;
-                    if(is_array($postData[$key])) $postData[$key] = implode(",", $postData[$key]);
-                    Config::updateAll(['VALUE' => $postData[$key], 'UPDATED_AT' => Date::nowTime()], "CONFIG_NAME=:CONFIG_NAME", [':CONFIG_NAME' => $key]);
-                }
-            }
-            $transaction->commit();
-        } catch (Exception $e){
-            $transaction->rollBack();
-            $this->addError('updateOther', $e->getMessage());
-            return null;
-        }
-        $afterData = Config::getConfigByType('other');
-        $this->adminOperateLogger->saveAfterContent=$afterData;
-        unset($beforeData,$afterData);
-        $this->adminOperateLogger->clean()->save([
-            'optType' => '更新其他配置',
-        ]);
-        return true;
-    }
-}

+ 0 - 165
common/models/forms/ConfigPeriodForm.php

@@ -1,165 +0,0 @@
-<?php
-namespace common\models\forms;
-
-use common\components\Model;
-use common\helpers\Date;
-use common\helpers\Form;
-use common\libs\logging\operate\AdminOperate;
-use common\models\Config;
-use common\models\Period;
-use yii\db\Exception;
-
-/**
- * Login form
- */
-class ConfigPeriodForm extends Model
-{
-    public $calcYear;
-    public $closeWeekDate;
-    public $closeTime;
-
-    public function init() {
-        parent::init();
-        $this->adminOperateLogger = new AdminOperate([
-            'fetchClass' => Config::class,
-        ]);
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['calcYear', 'closeWeekDate', 'closeTime'], 'required'],
-            [['calcYear'], 'integer', 'max'=>2050, 'min'=>2018],
-            [['closeWeekDate'], 'match', 'pattern' => '/^[0-6]/', 'message' => '请填写有效的星期'],
-            [['closeTime'], 'time', 'format'=>'HH:mm'],
-        ];
-    }
-
-    public function attributeLabels()
-    {
-        return [
-            'calcYear' => '计算至年份',
-            'closeWeekDate' => '封期日期',
-            'closeTime' => '封期时间',
-        ];
-    }
-
-    /**
-     * 更新配置
-     * @return bool|null
-     * @throws Exception
-     */
-    public function update(){
-        if(!$this->validate()){
-            return null;
-        }
-        $configs = Config::find()->where("TYPE='period'")->orderBy('SORT ASC')->indexBy('CONFIG_NAME')->asArray()->all();
-        $configNames = [];
-        foreach ($configs as $value){
-            $configNames[] = $value['CONFIG_NAME'];
-        }
-        $beforeData = Config::getConfigByType('period');
-        $this->adminOperateLogger->saveBeforeContent=$beforeData;
-
-        $transaction = \Yii::$app->db->beginTransaction();
-        try{
-            if(!Config::updateAll(['VALUE'=>$this->calcYear, 'UPDATED_AT'=>Date::nowTime()], "CONFIG_NAME='calcYear'")){
-                throw new Exception('计算至年份更新失败');
-            }
-            if(!Config::updateAll(['VALUE'=>$this->closeWeekDate, 'UPDATED_AT'=>Date::nowTime()], "CONFIG_NAME='closeWeekDate'")){
-                throw new Exception('封期日期更新失败');
-            }
-            if(!Config::updateAll(['VALUE'=>$this->closeTime, 'UPDATED_AT'=>Date::nowTime()], "CONFIG_NAME='closeTime'")){
-                throw new Exception('封期时间更新失败');
-            }
-            // 异步处理添加任务
-            $taskKey = \Yii::$app->swooleAsyncTimer->asyncHandle('config/update-period', \Yii::$app->request->post());
-            if($taskKey === false){
-                throw new Exception('请求异步服务器失败');
-            }
-            $transaction->commit();
-        } catch (Exception $e){
-            $transaction->rollBack();
-            $this->addError('closeWeekDate', $e->getMessage());
-            return null;
-        }
-        $afterData = Config::getConfigByType('period');
-        $this->adminOperateLogger->saveAfterContent=$afterData;
-        unset($beforeData,$afterData);
-        $this->adminOperateLogger->clean()->save([
-            'optType' => '更新期数配置',
-        ]);
-        return true;
-    }
-
-    /**
-     * 异步更新期数表
-     * @return bool
-     * @throws Exception
-     */
-    public function updateAsync(){
-        if(!$this->validate()){
-            return false;
-        }
-        $period = Period::instance();
-        // 获取当前期数
-        $periodNum = $period->getNowPeriodNum();
-        // 把所有没封期的期数都删掉只保留当前期
-        Period::deleteAll('IS_CLOSED=0 AND PERIOD_NUM<>:PERIOD_NUM', [':PERIOD_NUM'=>$periodNum]);
-        //$nowPeriodStart = $period->getNowPeriodStart();
-        $periodEnd = $period->getNowPeriodEnd();
-        // 开始时间归到0点
-        $nowPeriodStart = $periodEnd + 1;
-        // 循环到2030年的所有日期
-        $nowPeriodNum = $periodNum + 1;
-        $startDateTemp = $nowPeriodStart;
-        $transaction = \Yii::$app->db->beginTransaction();
-        try{
-            for($startDate = $nowPeriodStart + 86400; $startDate < strtotime($this->calcYear.'-12-31'); $startDate += 86400 ){
-                if(Date::dateWeek(\date('Y-m-d',$startDate)) == $this->closeWeekDate){
-                    $periodModel = new Period();
-                    $periodModel->PERIOD_NUM = $nowPeriodNum;
-                    $periodModel->START_TIME = $startDateTemp;
-                    $periodModel->END_TIME = Date::dayMinute($startDate, $this->closeTime) - 1;
-                    $periodModel->CALC_MONTH = date('m', $periodModel->END_TIME);
-                    $periodModel->CALC_YEAR = date('Y', $periodModel->END_TIME);
-                    $periodModel->CREATED_AT = Date::nowTime();
-                    if(!$periodModel->save()){
-                        throw new Exception(Form::formatErrorsForApi($periodModel->getErrors()));
-                    };
-                    $startDateTemp = $periodModel->END_TIME+1;
-                    // 查看上一期的月份是否比本期的月份不等,则把上一期设置为月结点
-                    $lastPeriod = Period::findOne(['PERIOD_NUM'=>$nowPeriodNum-1]);
-                    if($lastPeriod){
-                        if($lastPeriod['CALC_MONTH'] != $periodModel->CALC_MONTH){
-                            $lastPeriod->IS_MONTH = 1;
-                        }
-                        // 查看上一期的年份是否比本期的不等,则把上一期的设置为年节点
-                        if($lastPeriod['CALC_YEAR'] != $periodModel->CALC_YEAR){
-                            $lastPeriod->IS_YEAR = 1;
-                        }
-                        if($lastPeriod->IS_MONTH || $lastPeriod->IS_YEAR){
-                            if(!$lastPeriod->save()){
-                                throw new Exception(Form::formatErrorsForApi($lastPeriod->getErrors()));
-                            }
-                        }
-                    }
-                    $periodModel = null;
-                    $lastPeriod = null;
-                    unset($periodModel, $lastPeriod);
-                    $nowPeriodNum += 1;
-                    //echo date('Y-m-d', $startDate).PHP_EOL;
-                }
-            }
-            $transaction->commit();
-        } catch (Exception $e){
-            $transaction->rollBack();
-            $this->addError('update', $e->getMessage());
-            return false;
-        }
-        return true;
-    }
-}

+ 0 - 179
common/models/forms/DealTypeForm.php

@@ -1,179 +0,0 @@
-<?php
-
-namespace common\models\forms;
-
-use common\helpers\Date;
-use common\components\Model;
-use common\helpers\Form;
-use common\libs\logging\operate\AdminOperate;
-use common\models\DealType;
-use yii\base\Exception;
-
-/**
- * 点位绑定表单
- */
-class DealTypeForm extends Model {
-    public $id;
-    public $typeName;
-    public $isEnable;
-    public $createRemark;
-    public $sort;
-
-    private $_model;
-
-    public function init() {
-        parent::init();
-        $this->adminOperateLogger = new AdminOperate([
-            'fetchClass' => DealType::class,
-        ]);
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules() {
-        return [
-            [['id', 'typeName', 'createRemark', 'sort', 'isEnable'], 'trim'],
-            [['id', 'typeName', 'sort'], 'required'],
-            [['typeName'], 'unique', 'on' => 'update', 'targetClass' => DealType::class, 'targetAttribute' => 'TYPE_NAME', 'when' => function ($model) {
-                return $model->isAttributeChanged('TYPE_NAME');
-            }],
-            [['id'], 'initModel'],
-            [['sort'], 'isSort'],
-        ];
-    }
-
-    /**
-     * 指定校验场景
-     * @return array
-     */
-    public function scenarios() {
-        $parentScenarios = parent::scenarios();
-        $customScenarios = [
-            'add' => ['typeName', 'createRemark','sort', 'isEnable'],
-            'edit' => ['id', 'typeName', 'createRemark','sort', 'isEnable'],
-        ];
-        return array_merge($parentScenarios, $customScenarios);
-    }
-
-    public function attributeLabels() {
-        return [
-            'typeName' => '类型名称',
-            'isEnable' => '是否启用',
-            'createRemark' => '创建备注',
-            'sort' => '排序',
-        ];
-    }
-
-    /**
-     * 初始化model
-     * @param $attributes
-     */
-    public function initModel($attributes) {
-        $this->_model = DealType::findOne(['ID' => $this->id]);
-        if (!$this->_model) {
-            $this->addError($attributes, '数据不存在');
-        }
-    }
-
-    /**
-     * 排序需大于等于1
-     * @param $attributes
-     */
-    public function isSort($attributes) {
-        if ($this->scenario == 'add' && $this->sort < 1) {
-            $this->addError($attributes, '排序请填写大于等于1的数字');
-        }
-        if ($this->scenario == 'edit') {
-            if ($this->_model->IS_PRESET != 1 && $this->sort < 1) {
-                $this->addError($attributes, '排序请填写大于等于1的数字');
-            }
-        }
-    }
-
-    /**
-     * 添加
-     * @return DealType|null
-     * @throws \yii\db\Exception
-     */
-    public function add() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $transaction = \Yii::$app->db->beginTransaction();
-        try {
-            // 添加会员合作点位
-            $model = new DealType();
-            $model->TYPE_NAME = $this->typeName;
-            $model->IS_ENABLE = $this->isEnable ? $this->isEnable : 0;
-            $model->IS_PRESET = 0;
-            $model->CREATE_ADMIN = \Yii::$app->user->id;
-            $model->CREATE_REMARK = $this->createRemark;
-            $model->CREATED_AT = Date::nowTime();
-            $model->SORT_ORDER = $this->sort;
-            if (!$model->save()) {
-                throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('add', $e->getMessage());
-            return null;
-        }
-
-        // 记录日志
-        $this->adminOperateLogger->afterInsert($model)->clean()->save([
-            'optType' => '添加交易类型',
-            'remark' => $model->CREATE_REMARK,
-        ]);
-
-        return $model;
-    }
-
-    /**
-     * 修改操作
-     * @return null
-     * @throws \yii\db\Exception
-     */
-    public function edit() {
-        if (!$this->validate()) {
-            return null;
-        }
-        // 记录日志
-        $this->adminOperateLogger->beforeUpdate($this->_model);
-        $transaction = \Yii::$app->db->beginTransaction();
-        try {
-            $model = $this->_model;
-            $model->TYPE_NAME = $this->typeName;
-            if($model->IS_PRESET!=1) {
-                $model->IS_ENABLE = $this->isEnable ? $this->isEnable : 0;
-                $model->IS_PRESET = 0;
-                $model->CREATE_REMARK = $this->createRemark;
-                $model->SORT_ORDER = $this->sort;
-            }
-            $model->UPDATE_ADMIN = \Yii::$app->user->id;
-            $model->UPDATED_AT = Date::nowTime();
-            if (!$model->save()) {
-                throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('edit', $e->getMessage());
-            return null;
-        }
-        // 记录日志
-        $this->adminOperateLogger->afterUpdate($model)->clean()->save([
-            'optType' => '修改交易类型',
-            'remark' => $model->CREATE_REMARK,
-        ]);
-        return $model;
-    }
-
-    /**
-     * 删除
-     * @param $selected
-     */
-    public static function delete($selected) {
-    }
-}

+ 0 - 66
common/models/forms/DecLevelForm.php

@@ -1,66 +0,0 @@
-<?php
-namespace common\models\forms;
-
-use backendApi\modules\v1\models\Admin;
-use common\components\Model;
-use common\helpers\Date;
-use common\helpers\Tool;
-use common\models\DeclarationLevel;
-
-/**
- * Login form
- */
-class DecLevelForm extends Model
-{
-    public $id;
-    public $levelName;
-    public $perf;
-    public $isAdjustGift;
-    public $isDec;
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['id', 'levelName', 'perf', 'isAdjustGift', 'isDec'], 'trim', 'on'=>['add', 'edit']],
-            [['id'], 'required', 'on'=>'edit'],
-            [['id'], 'exist', 'targetClass'=>DeclarationLevel::class, 'targetAttribute'=>'ID'],
-            [['levelName', 'perf', 'isAdjustGift', 'isDec'], 'required'],
-            [['perf'], 'price'],
-        ];
-    }
-
-    /**
-     * 编辑
-     * @return DeclarationLevel|null|static
-     */
-    public function edit(){
-        if(!$this->validate()){
-            return null;
-        }
-        if($this->scenario == 'add'){
-            $model = new DeclarationLevel();
-            $model->CREATE_ADMIN = Admin::getAdminNameById(\Yii::$app->user->id);
-            $model->CREATED_AT = Date::nowTime();
-        } elseif($this->scenario == 'edit') {
-            $model = DeclarationLevel::findOne(['ID'=>$this->id]);
-            $model->UPDATE_ADMIN = Admin::getAdminNameById(\Yii::$app->user->id);
-            $model->UPDATED_AT = Date::nowTime();
-        } else {
-            $this->addError('id', '提交场景不存在');
-            return null;
-        }
-        $model->LEVEL_NAME = $this->levelName;
-        $model->PERF = $this->perf;
-        $model->IS_ADJUST_GIFT = $this->isAdjustGift;
-        $model->IS_DEC = $this->isDec;
-        if($model->save()){
-            return $model;
-        } else {
-            $this->addErrors($model->getErrors());
-            return null;
-        }
-    }
-}

+ 0 - 176
common/models/forms/DecLevelLogForm.php

@@ -1,176 +0,0 @@
-<?php
-namespace common\models\forms;
-
-use common\helpers\Date;
-use common\components\Model;
-use common\helpers\Form;
-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\Period;
-use common\models\DeclarationLevel;
-use common\models\User;
-use common\models\UserInfo;
-use yii\base\Exception;
-use yii\validators\UrlValidator;
-
-/**
- * Login form
- */
-class DecLevelLogForm extends Model
-{
-    public $userName;
-    public $levelId;
-    public $periodNum;
-    public $remark;
-
-    private $_userId;
-    private $_fromId;
-    private $_lvPv;
-
-    public function init() {
-        parent::init();
-        $this->adminOperateLogger = new AdminOperate([
-            'fetchClass' => User::class,
-        ]);
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['userName', 'levelId', 'periodNum', 'remark'], 'trim'],
-            [['userName', 'levelId', 'periodNum'], 'required'],
-            [['userName'], 'exist', 'targetClass'=>User::class, 'targetAttribute'=>'USER_NAME'],
-            [['levelId'], 'exist', 'targetClass'=>DeclarationLevel::class, 'targetAttribute'=>'ID'],
-            [['userName'], 'isUser'],
-            [['levelId'], 'isLevel'],
-            [['periodNum'], 'integer'],
-            [['periodNum'], 'isPeriodNum'],
-        ];
-    }
-
-    public function attributeLabels()
-    {
-        return [
-            'userName' => '会员编号',
-            'levelId' => '级别',
-            'periodNum' => '期数',
-            '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, '会员不存在');
-        }
-    }
-
-    /**
-     * 查看级别是否有变化
-     * @param $attribute
-     */
-    public function isLevel($attribute){
-        $this->_fromId = Info::getDecLv($this->_userId);
-        if($this->levelId == $this->_fromId){
-            $this->addError($attribute, '级别没有变化无需调整');
-        }
-        $decLv = DeclarationLevel::findOneAsArray('ID=:ID',[':ID'=>$this->levelId],'PERF');
-        $this->_lvPv = $decLv['PERF'];
-    }
-
-    /**
-     * 期数是否满足要求
-     * @param $attribute
-     * @throws \yii\db\Exception
-     */
-    public function isPeriodNum($attribute) {
-        $period = Period::instance();
-        if ($period->isSent($this->periodNum)) {
-            $this->addError($attribute, '期数' . $this->periodNum . '已挂网');
-        }
-    }
-
-    /**
-     * 调价调整操作
-     * @return Ad|null
-     * @throws \yii\db\Exception
-     */
-    public function adminChange(){
-        if(!$this->validate()){
-            return null;
-        }
-        $this->adminOperateLogger->beforeUpdate($this->_userId,'ID',['select'=>'ID,LAST_DEC_LV,DEC_LV,DEC_LV_UPDATED_AT,DEC_LV_UPDATED_PERIOD,LAST_DEC_LV_UPDATED_PERIOD,LAST_DEC_LV_UPDATED_AT']);
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            // 恢复所传期数的和这个会员相关的其他调整
-            $period = Period::instance();
-            DecLevelLog::updateAll(['STATUS' => 0], 'USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM', [':USER_ID' => $this->_userId, ':PERIOD_NUM' => $this->periodNum]);
-            // 新增数据
-            $model = new DecLevelLog();
-            $model->USER_ID = $this->_userId;
-            $model->FROM_ID = $this->_fromId;
-            $model->TO_ID = $this->levelId;
-//            $model->PERIOD_NUM = $this->periodNum;
-//            $model->CALC_MONTH = $period->getYearMonth($this->periodNum);
-            $model->PERIOD_NUM = 0;
-            $model->CALC_MONTH = 0;
-            $model->REMARK = $this->remark;
-            $model->STATUS = 1;
-            $model->ADMIN_ID = \Yii::$app->user->id;
-            $model->CREATED_AT = Date::nowTime();
-            if (!$model->save()) {
-                throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-            }
-            //修改会员级别,如果是上期,则一起变化,如果不是,则只改变实时级别
-            $nowPeriodNum = $period->getNowPeriodNum();
-            //$changePeriodNum = $this->periodNum;
-            $nowTime = Date::nowTime();
-            //if ($changePeriodNum == $nowPeriodNum - 1) {
-                User::updateAll(['LAST_DEC_LV' => $this->levelId, 'DEC_LV' => $this->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'=>$this->_lvPv], 'ID=:ID', [':ID' => $this->_userId]);
-//            } else {
-//                User::updateAll(['DEC_LV' => $this->levelId, 'DEC_LV_UPDATED_AT'=>$nowTime, 'DEC_LV_UPDATED_PERIOD'=>$nowPeriodNum, 'ZG_UPGRADE_PV'=>$this->_lvPv], 'ID=:ID', [':ID' => $this->_userId]);
-//            }
-
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('adminChange', $e->getMessage());
-            return null;
-        }
-        $this->adminOperateLogger->afterUpdate($this->_userId,'ID',['select'=>'ID,LAST_DEC_LV,DEC_LV,DEC_LV_UPDATED_AT,DEC_LV_UPDATED_PERIOD,LAST_DEC_LV_UPDATED_PERIOD,LAST_DEC_LV_UPDATED_AT'])->clean()->save([
-            'optType' => '修改会员级别',
-            'userId' => $this->_userId,
-            'userName' => Info::getUserNameByUserId($this->_userId),
-            'remark' => $this->remark
-        ]);
-        return $model;
-    }
-
-
-}

+ 0 - 149
common/models/forms/DecPackageForm.php

@@ -1,149 +0,0 @@
-<?php
-namespace common\models\forms;
-
-use backendApi\modules\v1\models\Admin;
-use common\components\Model;
-use common\helpers\Date;
-use common\models\DeclarationPackage;
-use yii\base\Exception;
-
-/**
- * Login form
- */
-class DecPackageForm extends Model
-{
-    public $selectedIds;
-    public $id;
-    public $packageName;
-    public $packageNo;
-    public $amount;
-    public $amountPv;
-    public $levelId;
-    public $packageContent;
-    public $status;
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['id', 'packageName','packageNo', 'amount', 'amountPv', 'levelId','packageContent','status'], 'trim'],
-            [['packageName','packageNo', 'amount', 'amountPv', 'levelId','packageContent','status'], 'required'],
-            [['id'], 'required', 'on'=>'edit'],
-            [['id'], 'exist', 'targetClass'=>DeclarationPackage::class, 'targetAttribute'=>'ID'],
-            [['amount','amountPv'], 'price'],
-            [['selectedIds'], 'isSelected'],
-        ];
-    }
-
-    public function attributeLabels()
-    {
-        return [
-            'selectedIds' => '套餐IDs',
-            'id' => '套餐ID',
-            'packageName' => '套餐名称',
-            'packageNo' => '套餐编号',
-            'amount' => '套餐金额',
-            'amountPv' => '套餐PV',
-            'levelId' => '所属报单级别',
-            'packageContent' => '套餐详情',
-        ];
-    }
-
-    /**
-     * 指定场景
-     * @return array
-     */
-    public function scenarios()
-    {
-        $parentScenarios =  parent::scenarios();
-        $customScenarios = [
-            'add' => ['packageName','packageNo','amount','amountPv','levelId', 'packageContent'],
-            'edit' => ['id','packageName','packageNo','amount','amountPv', 'levelId', 'packageContent'],
-            'changeStatus' => ['selectedIds', 'status'],
-        ];
-        return array_merge($parentScenarios, $customScenarios);
-    }
-
-    /**
-     * 批量数据
-     * @param $attributes
-     */
-    public function isSelected($attributes) {
-        if (!$this->selectedIds) {
-            $this->addError($attributes, '必须选择一条数据');
-        }
-        if (!is_array($this->selectedIds)) {
-            $this->selectedIds = [$this->selectedIds];
-        }
-    }
-
-    /**
-     * 编辑
-     * @return DeclarationPackage|null|static
-     */
-    public function edit(){
-        if(!$this->validate()){
-            return null;
-        }
-        if($this->scenario == 'add'){
-            $model = new DeclarationPackage();
-            $model->CREATE_ADMIN = Admin::getAdminNameById(\Yii::$app->user->id);
-            $model->CREATED_AT = Date::nowTime();
-        } elseif($this->scenario == 'edit') {
-            $model = DeclarationPackage::findOne(['ID'=>$this->id]);
-            $model->UPDATE_ADMIN = Admin::getAdminNameById(\Yii::$app->user->id);
-            $model->UPDATED_AT = Date::nowTime();
-        } else {
-            $this->addError('id', '提交场景不存在');
-            return null;
-        }
-        $model->PACKAGE_NAME = $this->packageName;
-        $model->PACKAGE_NO = $this->packageNo;
-        $model->AMOUNT = $this->amount;
-        $model->PV = $this->amountPv;
-        $model->LEVEL_ID = $this->levelId;
-        $model->PACKAGE_CONTENT = $this->packageContent;
-        if($model->save()){
-            return $model;
-        } else {
-            $this->addErrors($model->getErrors());
-            return null;
-        }
-    }
-
-    /**
-     * 上下架
-     * @return null|static
-     * @throws \yii\db\Exception
-     */
-    public function changeStatus() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            foreach ($this->selectedIds as $select) {
-                $oneGoods = DeclarationPackage::findOne(['ID' => $select]);
-                //判断状态
-                if (($msg = DeclarationPackage::chkAuditStatus($oneGoods->STATUS, $this->status)) != '') {
-                    throw new Exception($msg);
-                }
-                $oneGoods->STATUS = $this->status;
-                $oneGoods->UPDATED_AT = Date::nowTime();
-                if (!$oneGoods->save()) {
-                    throw new Exception(Form::formatErrorsForApi($oneGoods->getErrors()));
-                }
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('changeStatus', $e->getMessage());
-            return null;
-        }
-        return ['status' => $this->status];
-    }
-
-}

+ 0 - 56
common/models/forms/DecRoleForm.php

@@ -1,56 +0,0 @@
-<?php
-namespace common\models\forms;
-
-use backendApi\modules\v1\models\Admin;
-use common\components\Model;
-use common\helpers\Date;
-use common\models\DecRole;
-
-/**
- * Login form
- */
-class DecRoleForm extends Model
-{
-    public $id;
-    public $roleName;
-    public $fwBonusPercent;
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['id', 'roleName', 'fwBonusPercent'], 'trim', 'on'=>['add', 'edit']],
-            [['id'], 'required', 'on'=>'edit'],
-            [['id'], 'exist', 'targetClass'=>DecRole::class, 'targetAttribute'=>'ID'],
-            [['roleName', 'fwBonusPercent'], 'required'],
-            [['fwBonusPercent'], 'price'],
-        ];
-    }
-
-    /**
-     * 编辑
-     */
-    public function edit(){
-        if(!$this->validate()){
-            return null;
-        }
-        if($this->scenario == 'edit') {
-            $model = DecRole::findOne(['ID'=>$this->id]);
-            $model->UPDATER = Admin::getAdminNameById(\Yii::$app->user->id);
-            $model->UPDATED_AT = Date::nowTime();
-        } else {
-            $this->addError('id', '提交场景不存在');
-            return null;
-        }
-        $model->ROLE_NAME = $this->roleName;
-        $model->FW_BONUS_PERCENT = $this->fwBonusPercent;
-        if($model->save()){
-            return $model;
-        } else {
-            $this->addErrors($model->getErrors());
-            return null;
-        }
-    }
-}

+ 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, '会员不存在');
-        }
-    }
-
-    /**
-     * 查看级别是否有变化
-     * @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;
-    }
-
-
-}

+ 73 - 875
common/models/forms/DeclarationForm.php

@@ -1,875 +1,73 @@
-<?php
-namespace common\models\forms;
-
-use common\components\Model;
-use common\helpers\Cache;
-use common\helpers\Date;
-use common\helpers\Form;
-use common\helpers\user\Cash;
-use common\helpers\user\Reconsume;
-use common\helpers\user\Info;
-use common\models\DeclarationPackage;
-use common\models\DecOrder;
-use common\models\EmployLevel;
-use common\models\Order;
-use common\models\OrderGoods;
-use common\models\Period;
-use common\models\ReceiveAddress;
-use common\models\ReconsumePool;
-use common\models\ReconsumePoolFlow;
-use common\models\DeclarationLevel;
-use common\models\Region;
-use common\models\ShopGoods;
-use common\models\User;
-use common\models\UserInfo;
-use common\models\UserNetwork;
-use common\models\UserRelation;
-use yii\base\Exception;
-
-/**
- * Login form
- */
-class DeclarationForm extends Model
-{
-    public $type;
-    public $decLv;
-    public $decWay;
-    public $packageId;
-    public $goodsId;
-    public $goodsNum;
-    public $insertUserName;
-    public $password;
-    public $payPassword;
-    public $realName;
-    public $insertUserIdCard;
-    public $mobile;
-    public $address;
-    public $openBank;
-    public $bankAddress;
-    public $bankNo;
-    public $bankProvince;
-    public $bankCity;
-    public $bankCounty;
-    public $conUserName;
-    public $recUserName;
-    public $decUserName;
-    public $location;
-    public $consignee;
-    public $acceptMobile;
-    public $province;
-    public $city;
-    public $county;
-
-    // 传过来的全部数据
-    public $allData;
-    private $_decId;
-    public $_insertUserId;
-    private $_decAmount;
-    private $_decPv;
-    private $_orderGoods;
-
-    // 批量报单时添加会员的REDIS里面缓存的添加的会员资料
-    const REDIS_WAIT_ADD_USER = 'user:dec:waitAdd';
-
-    const TYPE_ZC = 'ZC';
-//    const TYPE_YH = 'YH';
-    const TYPE_ZG = 'ZG';
-    const TYPE_LS = 'LS';
-    const TYPE_FX = 'FX';
-
-//    private $_modelClass = null;
-    private $_oneOrder = null;
-    private $_userForm = null;
-    // 全部的上级(安置网和开拓网)
-    private $_tempParentUser = [];
-    // 全部的安置网上级
-    private $_tempNetworkParentUser = [];
-    // 全部的开拓网上级
-    private $_tempRelationParentUser = [];
-    private $_types = [
-        self::TYPE_ZC => [
-            'name' => '首购单',
-        ],
-//        self::TYPE_YH => [
-//            'class' => DeclarationYH::class,
-//            'table' => '{{%DECLARATION_YH}}',
-//            'name' => '优惠单',
-//        ],
-        self::TYPE_ZG => [
-            'name' => '升级增购单',
-        ],
-        self::TYPE_LS => [
-            'name' => '零售单',
-        ],
-        self::TYPE_FX => [
-            'name' => '复销单',
-        ],
-    ];
-
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['type','decLv','decWay','packageId', 'insertUserName', 'realName', 'insertUserIdCard', 'mobile', 'address', 'openBank', 'bankAddress', 'bankNo','bankProvince','bankCity','bankCounty','consignee','acceptMobile','province','city','county','decUserName', 'conUserName', 'recUserName', 'location'], 'trim'],
-            [['type','decLv','decWay','insertUserName', 'insertUserIdCard','password','payPassword','decUserName'], 'required'],
-            [['type'], 'isType', 'on'=>['userDec', 'canDec']],
-            [['insertUserName'], 'isCanAddUser'],
-            [['decUserName'], 'issetDec'],
-            [['conUserName'], 'isConUserName'],
-            [['recUserName'], 'isRecUserName'],
-            [['location'], 'isLocation'],
-            [['insertUserIdCard'], 'isSameSystem'],
-        ];
-    }
-
-    public function attributeLabels()
-    {
-        return [
-            'type' => '报单类型',
-            'decLv' => '报单级别',
-            //'decPv' => '报单PV',
-            'decWay' => '报单方式',
-            'packageId' => '报单套餐',
-            'goodsId' => '商品ID',
-            'goodsNum' => '商品数量',
-            //'addType' => '新增会员方式',
-            'insertUserName' => '会员用户名',
-            'password' => '登陆密码',
-            'payPassword' => '支付密码',
-            'realName' => '会员姓名',
-            'insertUserIdCard' => '身份证号',
-            'mobile' => '手机号',
-            'address' => '地址',
-            'openBank' => '开户行',
-            'bankAddress' => '开户支行',
-            'bankNo' => '银行账号',
-            'bankProvince' => '银行省份',
-            'bankCity' => '银行城市',
-            'bankCounty' => '银行县区',
-            'conUserName' => '指导老师用户名',
-            'recUserName' => '开拓人用户名',
-            'decUserName' => '报单中心用户名',
-            'conUid' => '指导老师会员ID',
-            'recUid' => '开拓人会员ID',
-            'location' => '市场',
-            'consignee' => '收货人',
-            'acceptMobile' => '收货人手机',
-            'province' => '收货省',
-            'city' => '收货市',
-            'county' => '收货区县',
-            'address' => '收货详细地址',
-        ];
-    }
-
-    /**
-     * 指定场景
-     * @return array
-     */
-    public function scenarios()
-    {
-        $parentScenarios =  parent::scenarios();
-        $customScenarios = [
-            'userDec' => ['type','allData', 'decLv','decWay','insertUserName','password','payPassword', 'realName', 'insertUserIdCard', 'mobile', 'address', 'openBank', 'bankAddress', 'bankNo', 'bankProvince','bankCity','bankCounty', 'consignee','acceptMobile','province','city','county', 'conUserName', 'recUserName','decUserName', 'location'],
-            'canDec' => ['type', 'insertUserName', 'insertUserIdCard', 'conUserName', 'recUserName', 'location'],
-            'notFull' => ['type', 'insertUserName', 'conUserName', 'recUserName', 'location'],
-        ];
-        return array_merge($parentScenarios, $customScenarios);
-    }
-
-    /**
-     * 判断报单中心是否存在
-     * @param $attribute
-     */
-    public function issetDec($attribute){
-        if (!$decUser = User::find()->select('ID')->where('IS_DEC=1 AND USER_NAME=:USER_NAME', [':USER_NAME' => $this->decUserName])->asArray()->one()) {
-            $this->addError($attribute, '报单中心不存在');
-            return false;
-        } else {
-            // 判断报单中心是否在新加入会员的安置网上级中
-            $this->loopFindParentToNetwork($this->insertUserName);
-            //反转数组,in_array搜索错误
-            //in_array($this->decUserName, $this->_tempNetworkParentUser[$this->insertUserName]);
-            $flipParent = array_flip(array_filter($this->_tempNetworkParentUser[$this->insertUserName]));
-//            var_dump($flipParent);
-//            echo $this->insertUserName.'=='.$this->decUserName;
-//            exit;
-            if (!isset($flipParent[$this->decUserName])) {
-                $this->addError($attribute, '为' . $this->insertUserName . '报单,报单中心' . $this->decUserName . '不在' . $this->insertUserName . '的安置网上级中');
-                return ;
-            }
-            $this->_decId = $decUser['ID'];
-        }
-    }
-
-    /**
-     * 判断指导老师
-     * @param $attribute
-     */
-    public function isConUserName($attribute){
-        if($this->type == self::TYPE_ZC){
-            // 从数据库查看接点会员是否在
-            if(!isset($this->_tempParentUser[$this->conUserName])){
-                $conUserTemp = UserInfo::findOneAsArray('USER_NAME=:USER_NAME', [':USER_NAME' => $this->conUserName]);
-                if(!$conUserTemp){
-                    if($this->insertUserName){
-                        $this->addError($attribute, '为'.$this->insertUserName.'报单,指导老师'.$this->conUserName.'不存在');
-                    } else {
-                        $this->addError($attribute, '指导老师'.$this->conUserName.'不存在');
-                    }
-                    return ;
-                }
-                $conUserTemp['CON_NUM'] = UserNetwork::firstFloorChildNum($conUserTemp['USER_ID']);
-                $conUserTemp['REC_NUM'] = UserRelation::firstFloorChildNum($conUserTemp['USER_ID']);
-                $this->_tempParentUser[$this->conUserName] = [
-                    'USER_NAME' => $this->conUserName,
-                    'ZC_PV' => $conUserTemp['ZC_PV'],
-                    'CON_USER_NAME' => Info::getUserNameByUserId($conUserTemp['CON_UID']),
-                    'REC_USER_NAME' => Info::getUserNameByUserId($conUserTemp['REC_UID']),
-                    'CON_NUM' => $conUserTemp['CON_NUM'],
-                    'REC_NUM' => $conUserTemp['REC_NUM'],
-                    'SYSTEM_ID' => $conUserTemp['SYSTEM_ID'],
-                    'LOCATION' => UserNetwork::getLocation($conUserTemp['USER_ID'], $conUserTemp['CON_UID']),
-                ];
-                // 把该会员下面的5个区是否存在会员都付上
-                for($i=1;$i<=5;$i++){
-                    $this->_tempParentUser[$this->conUserName]["LOCATION$i"] = UserNetwork::issetUserInLocation($conUserTemp['USER_ID'], $i);
-                }
-            }
-            $conUser = $this->_tempParentUser[$this->conUserName];
-            // 判断接点会员的下级会员是否大于三个,如果大于三个则不允许
-            if($conUser['CON_NUM'] >= 3){
-                if($this->insertUserName){
-                    $this->addError($attribute, '为'.$this->insertUserName.'报单,指导老师'.$this->conUserName.'下级点位已满');
-                } else {
-                    $this->addError($attribute, '指导老师'.$this->conUserName.'下级点位已满');
-                }
-                return;
-            }
-            if($this->insertUserName){
-                // 把自己加入到临时上级会员数组中
-                $this->_tempParentUser[$this->insertUserName] = [
-                    'USER_NAME' => $this->insertUserName,
-                    //'ZC_PV' => $this->decPv,
-                    'CON_USER_NAME' => $this->conUserName,
-                    'REC_USER_NAME' => $this->recUserName,
-                    'CON_NUM' => 0,
-                    'REC_NUM' => 0,
-                    'SYSTEM_ID' => $conUser['SYSTEM_ID'],
-                    'LOCATION' => $this->location,
-                    'LOCATION1' => 0,
-                    'LOCATION2' => 0,
-                    'LOCATION3' => 0,
-                    'LOCATION4' => 0,
-                    'LOCATION5' => 0,
-                ];
-            }
-
-        }
-    }
-
-    /**
-     * 判断开拓人
-     * @param $attribute
-     */
-    public function isRecUserName($attribute){
-        if($this->type == self::TYPE_ZC){
-            // 开拓人
-            if(!isset($this->_tempParentUser[$this->recUserName])){
-                $recUserTemp = UserInfo::findOneAsArray('USER_NAME=:USER_NAME', [':USER_NAME' => $this->recUserName]);
-                if(!$recUserTemp){
-                    if($this->insertUserName){
-                        $this->addError($attribute, '为'.$this->insertUserName.'报单,开拓人'.$this->recUserName.'不存在');
-                    } else {
-                        $this->addError($attribute, '开拓人'.$this->recUserName.'不存在');
-                    }
-
-                    return ;
-                }
-                $recUserTemp['CON_NUM'] = UserNetwork::firstFloorChildNum($recUserTemp['USER_ID']);
-                $recUserTemp['REC_NUM'] = UserRelation::firstFloorChildNum($recUserTemp['USER_ID']);
-                $this->_tempParentUser[$this->recUserName] = [
-                    'USER_NAME' => $this->recUserName,
-                    'ZC_PV' => $recUserTemp['ZC_PV'],
-                    'CON_USER_NAME' => Info::getUserNameByUserId($recUserTemp['CON_UID']),
-                    'REC_USER_NAME' => Info::getUserNameByUserId($recUserTemp['REC_UID']),
-                    'CON_NUM' => $recUserTemp['CON_NUM'],
-                    'REC_NUM' => $recUserTemp['REC_NUM'],
-                    'SYSTEM_ID' => $recUserTemp['SYSTEM_ID'],
-                    'LOCATION' => UserNetwork::getLocation($recUserTemp['USER_ID'], $recUserTemp['CON_UID']),
-                ];
-                // 把该会员下面的5个区是否存在会员都付上
-                for($i=1;$i<=5;$i++){
-                    $this->_tempParentUser[$this->recUserName]["LOCATION$i"] = UserNetwork::issetUserInLocation($recUserTemp['USER_ID'], $i);
-                }
-            }
-            $recUser = $this->_tempParentUser[$this->recUserName];
-            $this->_tempParentUser[$this->recUserName]['REC_NUM'] += 1;
-
-            // 存在新加入会员时查看开拓人是否在新加入会员的安置网上级中
-            if($this->insertUserName) {
-                $this->loopFindParentToNetwork($this->insertUserName);
-                if (!$this->recUserIsInNetworkParent()) {
-                    $this->addError($attribute, '为' . $this->insertUserName . '报单,开拓人' . $this->recUserName . '不在' . $this->insertUserName . '的安置网上级中');
-                    return ;
-                }
-            }
-
-            // 把自己加入到临时上级会员数组中
-            $this->_tempParentUser[$this->insertUserName] = [
-                'USER_NAME' => $this->insertUserName,
-                //'ZC_PV' => $this->decPv,
-                'CON_USER_NAME' => $this->conUserName,
-                'REC_USER_NAME' => $this->recUserName,
-                'CON_NUM' => 0,
-                'REC_NUM' => 0,
-                'SYSTEM_ID' => $recUser['SYSTEM_ID'],
-                'LOCATION' => $this->location,
-                'LOCATION1' => 0,
-                'LOCATION2' => 0,
-                'LOCATION3' => 0,
-                'LOCATION4' => 0,
-                'LOCATION5' => 0,
-            ];
-        }
-
-    }
-
-    /**
-     * 循环把所有新加入的会员的上级加入到临时变量中
-     * @param null $conUserName
-     * @return bool
-     */
-    private function loopFindParentToNetwork($conUserName = null) {
-        if($conUserName == null ){
-            $conUserName = $this->insertUserName;
-        }
-        $findUserKey = array_search($conUserName, array_column($this->allData, 'insertUserName'));
-        // 如果有这个新加入的会员,则查找其上级接点
-        if($findUserKey !== false){
-            if(strtoupper($this->allData[$findUserKey]['type']) == 'ZC'){
-                $this->_tempNetworkParentUser[$this->insertUserName][] = $this->allData[$findUserKey]['conUserName'];
-                $this->loopFindParentToNetwork($this->allData[$findUserKey]['conUserName']);
-            }
-        }
-        // 如果没有这个新加入的接点,
-        else {
-            if($this->insertUserName == $conUserName){
-                $this->addError('recUserName', '新加入的会员不存在');
-                return false;
-            }
-            // 去数据库里查找这个会员的所有上级
-//            $allParentUser = UserNetwork::find()->select('PUI.USER_NAME')->where('UI.USER_NAME=:USER_NAME', [':USER_NAME'=>$conUserName])->from(UserNetwork::tableName().' AS UN')->join('LEFT JOIN', UserInfo::tableName().' AS UI', 'UN.USER_ID=UI.USER_ID')->join('LEFT JOIN', UserInfo::tableName().' AS PUI', 'UN.PARENT_UID=PUI.USER_ID')->orderBy('PUI.NETWORK_DEEP DESC')->asArray()->all();
-            $baseUser = Info::getBaseUserByUserName($conUserName);
-            $userNetworkInfo = UserNetwork::findOneAsArray('USER_ID=:USER_ID', [':USER_ID' => $baseUser['ID']]);
-            unset($baseUser);
-            $allParentUserIdsArr = explode(',', $userNetworkInfo['PARENT_UIDS']);
-            unset($userNetworkInfo);
-            $allParentUserIds = array_reverse($allParentUserIdsArr);
-            unset($allParentUserIdsArr);
-            if($allParentUserIds){
-                foreach($allParentUserIds as $parentUserId) {
-                    $parentBaseUser = Info::getBaseUserById($parentUserId);
-                    $this->_tempNetworkParentUser[$this->insertUserName][] = $parentBaseUser['USER_NAME'] ;
-
-                    unset($parentUserId, $parentBaseUser);
-                }
-            }
-            unset($allParentUserIds);
-        }
-        return true;
-    }
-
-    /**
-     * 开拓人是否在新加入会员的上级中
-     * @return bool
-     */
-    private function recUserIsInNetworkParent(){
-        return in_array($this->recUserName, $this->_tempNetworkParentUser[$this->insertUserName]);
-    }
-
-    /**
-     * 判断区域是否正确
-     * @param $attribute
-     */
-    public function isLocation($attribute){
-        if($this->type == self::TYPE_ZC){
-            if(!in_array($this->location, [1, 2, 3])){
-                $this->addError($attribute, '市场必须在第1市场、第2市场或第三3市场');
-            }
-            $conUser = $recUser = null;
-            if(isset($this->_tempParentUser[$this->conUserName])){
-                $conUser = $this->_tempParentUser[$this->conUserName];
-            }
-            if(isset($this->_tempParentUser[$this->recUserName])){
-                $recUser = $this->_tempParentUser[$this->recUserName];
-            }
-            if($conUser){
-                // 判断指导老师相应的区位是否已满
-                if($conUser['LOCATION'.$this->location]){
-                    if($this->insertUserName){
-                        $this->addError($attribute, '为'.$this->insertUserName.'报单,指导老师'.$this->conUserName.'的第'.$this->location.'市场已存在会员');
-                    } else {
-                        $this->addError($attribute, '指导老师'.$this->conUserName.'的第'.$this->location.'市场已存在会员');
-                    }
-                    return;
-                }
-                //市场顺序判断
-//                if($conUser['CON_NUM'] == 0 && $this->location != 1){
-//                    if($this->insertUserName){
-//                        $this->addError($attribute, '为'.$this->insertUserName.'报单,市场必须为指导老师'.$this->conUserName.'下第一市场');
-//                    } else {
-//                        $this->addError($attribute, '市场必须为指导老师'.$this->conUserName.'下第一市场');
-//                    }
-//                    return;
-//                }
-//                if($conUser['CON_NUM'] == 1 && $this->location == 3){
-//                    if($this->insertUserName){
-//                        $this->addError($attribute, '为'.$this->insertUserName.'报单,市场必须为指导老师'.$this->conUserName.'第二市场');
-//                    } else {
-//                        $this->addError($attribute, '市场必须为指导老师'.$this->conUserName.'第二市场');
-//                    }
-//                    return;
-//                }
-                $this->_tempParentUser[$this->conUserName]['CON_NUM'] += 1;
-                $this->_tempParentUser[$this->conUserName]['LOCATION'.$this->location] = true;
-            }
-        }
-    }
-
-    /**
-     * 判断会员是否可加入(通过redis结合数据库判断上级会员的情况)
-     * @param $attribute
-     */
-    public function isCanAddUser($attribute){
-        if($this->type == self::TYPE_ZC){
-            // 从数据库查看接点会员是否在
-            if(!isset($this->_tempParentUser[$this->conUserName])){
-                $conUserTemp = UserInfo::findOneAsArray('USER_NAME=:USER_NAME', [':USER_NAME' => $this->conUserName]);
-                if(!$conUserTemp){
-                    $this->addError($attribute, '为'.$this->insertUserName.'报单,指导老师'.$this->conUserName.'不存在');
-                    return ;
-                }
-                $conUserTemp['CON_NUM'] = UserNetwork::firstFloorChildNum($conUserTemp['USER_ID']);
-                $conUserTemp['REC_NUM'] = UserRelation::firstFloorChildNum($conUserTemp['USER_ID']);
-                $this->_tempParentUser[$this->conUserName] = [
-                    'USER_NAME' => $this->conUserName,
-                    //'ZC_PV' => $conUserTemp['ZC_PV'],
-                    'CON_USER_NAME' => Info::getUserNameByUserId($conUserTemp['CON_UID']),
-                    'REC_USER_NAME' => Info::getUserNameByUserId($conUserTemp['REC_UID']),
-                    'CON_NUM' => $conUserTemp['CON_NUM'],
-                    'REC_NUM' => $conUserTemp['REC_NUM'],
-                    'SYSTEM_ID' => $conUserTemp['SYSTEM_ID'],
-                    'LOCATION' => UserNetwork::getLocation($conUserTemp['USER_ID'], $conUserTemp['CON_UID']),
-                ];
-                // 把该会员下面的5个区是否存在会员都付上
-                for($i=1;$i<=5;$i++){
-                    $this->_tempParentUser[$this->conUserName]["LOCATION$i"] = UserNetwork::issetUserInLocation($conUserTemp['USER_ID'], $i);
-                }
-            }
-            $conUser = $this->_tempParentUser[$this->conUserName];
-
-            // 开拓人
-            if(!isset($this->_tempParentUser[$this->recUserName])){
-                $recUserTemp = UserInfo::findOneAsArray('USER_NAME=:USER_NAME', [':USER_NAME' => $this->recUserName]);
-                if(!$recUserTemp){
-                    $this->addError($attribute, '为'.$this->insertUserName.'报单,开拓人'.$this->recUserName.'不存在');
-                    return ;
-                }
-                $recUserTemp['CON_NUM'] = UserNetwork::firstFloorChildNum($recUserTemp['USER_ID']);
-                $recUserTemp['REC_NUM'] = UserRelation::firstFloorChildNum($recUserTemp['USER_ID']);
-                $this->_tempParentUser[$this->recUserName] = [
-                    'USER_NAME' => $this->recUserName,
-                    //'ZC_PV' => $recUserTemp['ZC_PV'],
-                    'CON_USER_NAME' => Info::getUserNameByUserId($recUserTemp['CON_UID']),
-                    'REC_USER_NAME' => Info::getUserNameByUserId($recUserTemp['REC_UID']),
-                    'CON_NUM' => $recUserTemp['CON_NUM'],
-                    'REC_NUM' => $recUserTemp['REC_NUM'],
-                    'SYSTEM_ID' => $recUserTemp['SYSTEM_ID'],
-                    'LOCATION' => UserNetwork::getLocation($recUserTemp['USER_ID'], $recUserTemp['CON_UID']),
-                ];
-                // 把该会员下面的5个区是否存在会员都付上
-                for($i=1;$i<=5;$i++){
-                    $this->_tempParentUser[$this->recUserName]["LOCATION$i"] = UserNetwork::issetUserInLocation($recUserTemp['USER_ID'], $i);
-                }
-            }
-            $recUser = $this->_tempParentUser[$this->recUserName];
-
-            // 判断接点会员的下级会员是否大于三个,如果大于三个则不允许
-            if($conUser['CON_NUM'] >= 3){
-                $this->addError($attribute, '为'.$this->insertUserName.'报单,指导老师'.$this->conUserName.'下级点位已满');
-                return;
-            }
-            // 判断指导老师相应的区位是否已满
-            if($conUser['LOCATION'.$this->location]){
-                $this->addError($attribute, '为'.$this->insertUserName.'报单,指导老师'.$this->conUserName.'该市场已存在会员');
-                return;
-            }
-//            if($conUser['CON_NUM'] == 0 && $this->location != 1){
-//                $this->addError($attribute, '为'.$this->insertUserName.'报单,市场必须为指导老师'.$this->conUserName.'下第一市场');
-//                return;
-//            }
-
-            // 把指导老师的变量的相关数量增加数量
-//            $this->_tempParentUser[$this->conUserName]['CON_NUM'] += 1;
-//            $this->_tempParentUser[$this->conUserName]['LOCATION'.$this->location] = true;
-//            $this->_tempParentUser[$this->recUserName]['REC_NUM'] += 1;
-
-            // 把自己加入到临时上级会员数组中
-            $this->_tempParentUser[$this->insertUserName] = [
-                'USER_NAME' => $this->insertUserName,
-                //'ZC_PV' => $this->decPv,
-                'CON_USER_NAME' => $this->conUserName,
-                'REC_USER_NAME' => $this->recUserName,
-                'CON_NUM' => 0,
-                'REC_NUM' => 0,
-                'SYSTEM_ID' => $recUser['SYSTEM_ID'],
-                'LOCATION' => $this->location,
-                'LOCATION1' => 0,
-                'LOCATION2' => 0,
-                'LOCATION3' => 0,
-                'LOCATION4' => 0,
-                'LOCATION5' => 0,
-            ];
-        }
-    }
-
-    /**
-     * 报单类型
-     * @param $attribute
-     * @param $params
-     */
-    public function isType($attribute, $params){
-        if(array_key_exists($this->type, $this->_types)){
-            if($this->type == self::TYPE_ZC){
-                if($this->scenario == 'userDec'){
-                    if(!$this->insertUserName) $this->addError($attribute, '首购必须填写加入会员编号');
-                }
-                if(!$this->insertUserName) $this->addError($attribute, '首购必须填写加入会员编号');
-                if(!$this->insertUserIdCard) $this->addError($attribute, '首购必须填写加入会员的身份证号');
-                if(!$this->conUserName) $this->addError($attribute, '首购必须填写加入会员的指导老师编号');
-                if(!$this->recUserName) $this->addError($attribute, '首购必须填写加入会员的开拓人编号');
-                if(!$this->location) $this->addError($attribute, '首购必须填写加入会员的市场');
-            }
-        } else {
-            $this->addError($attribute, '报单类型不正确');
-        }
-    }
-
-    /**
-     * 检验相同身份证 会员是否同一体系内(接点)
-     * @param $attribute
-     */
-    public function isSameSystem($attribute){
-        if(isset($this->_tempParentUser[$this->conUserName])){
-            // 新加入会员的身份证号对应网内的其他会员
-            $otherUser = User::findAllAsArray("ID_CARD=:ID_CARD AND IS_UNION=0 AND DELETED=0 AND (ID_CARD_PREFIX IS NULL OR ID_CARD_PREFIX='')", [':ID_CARD'=>$this->insertUserIdCard]);
-            if(count($otherUser)>=7){
-                $this->addError($attribute, '同一个身份证限制只能报7单');
-            }
-            if($otherUser){
-                $flipParent = array_flip(array_filter($this->_tempNetworkParentUser[$this->insertUserName]));
-                $isExsit = false;
-                foreach ($otherUser as $conUser){
-                    if(isset($flipParent[$conUser['USER_NAME']])){
-                        $isExsit = true;
-                        break;
-                    }
-                }
-                if (!$isExsit) {
-                    $this->addError($attribute, '为' . $this->insertUserName . '报单,身份证号码相同的会员'.$otherUser[0]['USER_NAME'].'不在' . $this->insertUserName . '的安置网上级中');
-                    return ;
-                }
-            }
-        } else {
-            $this->addError($attribute, '为'.$this->insertUserName.'报单,接点人'.$this->conUserName.'不存在');
-        }
-    }
-
-    /**
-     * 添加报单
-     * @param $allData
-     * @return bool|null
-     * @throws Exception
-     * @throws \yii\db\Exception
-     */
-    public function add($allData){
-        if(!$this->validate()){
-            return null;
-        }
-
-        // 首购单,需要添加会员操作
-        if($this->type == self::TYPE_ZC){
-            if (preg_match("/[\x7f-\xff]/", $this->insertUserName)) {  //判断字符串中是否有中文
-                throw new Exception('会员编号中不能含有汉字');
-            }
-            //报单商品及PV判断
-            $decLevelConfig = Cache::getDecLevelConfig();
-            $decLevel = $decLevelConfig[$this->decLv];
-            $toDecLevel = $this->decLv;
-            if(!$this->decLv){
-                throw new Exception('请选择报单级别');
-            }
-            if($this->decWay==1) {
-                $decPackage = DeclarationPackage::findOneAsArray('ID=:ID', [':ID'=>$this->packageId]);
-                $this->_decAmount = $decPackage['AMOUNT'];
-                $this->_decPv = $decPackage['PV'];
-                $this->_orderGoods[] = [
-                    'GOODS_ID' => $this->packageId,
-                    'PRICE' => $this->_decAmount,
-                    'REAL_PRICE' => $this->_decAmount,
-                    'PV' => $this->_decPv,
-                    'REAL_PV' => $this->_decPv,
-                    'BUY_NUMS' => 1,
-                    'SKU_CODE' => $decPackage['PACKAGE_NO'],
-                    'GOODS_TITLE' => $decPackage['PACKAGE_NAME']
-                ];
-            }else{
-                $ids = $this->goodsId;
-                $totalAmount = 0;
-                $totalPv = 0;
-                foreach ($this->goodsNum as $k => $v) {
-                    if ($v) {
-                        $goods = ShopGoods::findOneAsArray('ID=:ID AND STATUS=1',[':ID'=> $ids[$k]]);
-                        if($goods['STORE_NUMS']>0){
-                            $totalAmount += $goods['SELL_PRICE'] * intval($v);
-                            $totalPv += $goods['PRICE_PV'] * intval($v);
-                            $this->_orderGoods[] = [
-                                'GOODS_ID' => $goods['ID'],
-                                'PRICE' => $goods['SELL_PRICE'],
-                                'REAL_PRICE' => $goods['SELL_PRICE'],
-                                'PV' => $goods['PRICE_PV'],
-                                'REAL_PV' => $goods['PRICE_PV'],
-                                'POINT' => $goods['POINT'],
-                                'BUY_NUMS' => intval($v),
-                                'SKU_CODE' => $goods['GOODS_NO'],
-                                'GOODS_TITLE' => $goods['GOODS_NAME']
-                            ];
-                        }
-                    }
-                }
-                if($totalPv<$decLevel['PERF']){
-                    throw new Exception('自选商品总PV不能小于所选报单级别PV');
-                }
-                foreach ($decLevelConfig as $key=>$val){
-                    if($totalPv>=$val['PERF']){
-                        $toDecLevel = $key;
-                    }
-                }
-                if($this->decLv!=$toDecLevel){
-                    throw new Exception('自选商品总PV不能超过已选级别下一个级别的PV值');
-                }
-                $this->_decAmount = $totalAmount;
-                $this->_decPv = $totalPv;
-            }
-            //看现金余额是否充足
-            $loginUserId = \Yii::$app->user->id;
-            if (Cash::getAvailableBalance($loginUserId) < $this->_decAmount){
-                throw new Exception('报单人现金不足,无法完成报单');
-            }
-
-            if(!($zcResult = $this->addUser($allData))) {
-                throw new Exception(Form::formatErrorsForApi($this->_userForm->getErrors()));
-            }
-            if(!($decResult = $this->addDecOrder())) {
-                throw new Exception(Form::formatErrorsForApi($decResult->getErrors()));
-            }
-        }
-        return true;
-    }
-
-    /**
-     * 添加会员
-     * @param $allData
-     * @return bool|UserInfo|null
-     * @throws \yii\db\Exception
-     */
-    public function addUser($allData){
-        $period = Period::instance();
-        // 增加会员
-        $user = new User();
-        $user->USER_NAME = $this->insertUserName;
-        $user->PASSWORD_HASH = \Yii::$app->security->generatePasswordHash($this->password);
-        $user->PAY_PASSWORD = \Yii::$app->security->generatePasswordHash($this->payPassword);
-        $user->NATION = 0;
-        $user->REAL_NAME = $this->realName;
-        $user->ID_CARD = $this->insertUserIdCard;
-        $user->MOBILE = $this->mobile;
-        $user->ADDRESS = $this->address ? $this->address : '无';
-        $user->OPEN_BANK = $this->openBank;
-        $user->BANK_ADDRESS = $this->bankAddress;
-        $user->BANK_NO = $this->bankNo;
-        $user->BANK_PROVINCE = $this->bankProvince ?? '0';
-        $user->BANK_CITY = $this->bankCity ?? '0';
-        $user->BANK_COUNTY = $this->bankCounty ?? '0';
-        $user->CREATED_AT = Date::nowTime();
-        $user->STATUS = 1;
-        $user->DEC_LV = $this->decLv;
-        $user->LAST_DEC_LV = $this->decLv;
-        $user->EMP_LV = EmployLevel::getDefaultLevelId();
-        $user->PROVINCE = $this->province ?? '0';
-        $user->CITY = $this->city ?? '0';
-        $user->COUNTY = $this->county ?? '0';
-        $user->AVATAR = 'avatar/1.png';
-        $user->IS_DEC = 0;
-        $user->DEC_ID = $this->_decId ?? null;
-        $user->DEC_ROLE_ID = $this->decRoleId ?? null;
-        $user->PERIOD_AT = $period->getNowPeriodNum();
-        $user->IS_DIRECT_SELLER = 0;
-        $user->VERIFIED = 1;
-        $user->VERIFIED_AT = Date::nowTime();
-        if (!$user->save()) {
-            throw new Exception(Form::formatErrorsForApi($user->getErrors()));
-        }
-        $this->_insertUserId = $user->ID;
-        $userForm = new UserForm();
-        $this->_userForm = $userForm;
-        $userForm->scenario = 'addWithUserName';
-        $userForm->userId = $this->_insertUserId;
-        $userForm->userName = $this->insertUserName;
-        $userForm->zcPv = $this->_decPv;
-        $userForm->zcAmount = $this->_decAmount;
-        $userForm->conUserName = $this->conUserName;
-        $userForm->recUserName = $this->recUserName;
-        $userForm->location = $this->location;
-        $userForm->idCard = $this->insertUserIdCard;
-        $userForm->allData = $allData;
-        if(!$userForm->validate()){
-            $this->addErrors($userForm->getErrors());
-            return false;
-        }
-        if($result = $userForm->add()){
-            return $result;
-        } else {
-            return false;
-        }
-    }
-
-    /**
-     * 添加报单订单
-     * @return bool|UserInfo|null
-     * @throws \yii\db\Exception
-     */
-    public function addDecOrder(){
-        $periodObj = Period::instance();
-        $nowPeriodNum = $periodObj->getNowPeriodNum();
-        $nowCalcMonth = $periodObj->getYearMonth($nowPeriodNum);
-
-        $ord = date('Ymd').substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 10);
-        // 加入报单信息
-        $decOrderModel = new DecOrder();
-        $decOrderModel->DEC_SN = 'DS'.$ord;
-        $decOrderModel->ORDER_SN = 'OS'.$ord;
-        $decOrderModel->TYPE = $this->type;
-        $decOrderModel->USER_ID = \Yii::$app->user->id;
-        $decOrderModel->TO_USER_ID = $this->_insertUserId;
-        $decOrderModel->DEC_AMOUNT = $this->_decAmount;
-        $decOrderModel->DEC_PV = $this->_decPv;
-        $decOrderModel->PERIOD_NUM = $nowPeriodNum;
-        $decOrderModel->CALC_MONTH = $nowCalcMonth;
-        $decOrderModel->P_CALC_MONTH = Date::ociToDate($nowCalcMonth, Date::OCI_TIME_FORMAT_SHORT_MONTH);
-        $decOrderModel->PAID_WALLET = 'cash';
-        $decOrderModel->CON_USER_ID = Info::getUserIdByUserName($this->conUserName);
-        $decOrderModel->REC_USER_ID = Info::getUserIdByUserName($this->recUserName);
-        $decOrderModel->DEC_ID = $this->_decId;
-        $decOrderModel->IS_DEL = 0;
-        $decOrderModel->CREATED_AT = Date::nowTime();
-        if(!$decOrderModel->save()){
-            throw new Exception(Form::formatErrorsForApi($decOrderModel->getErrors()));
-        }
-
-        // 加入订单信息
-        $warehouse = Region::getWarehouseByCode($this->province);//仓库
-        if(!$warehouse){
-            throw new Exception('地区暂时不支持配送,具体联系客服');
-        }
-        $orderModel = new Order();
-        $orderModel->SN = 'OS'.$ord;
-        $orderModel->DEC_SN = 'DS'.$ord;
-        $orderModel->ORDER_TYPE = $this->type;
-        $orderModel->USER_ID = $this->_insertUserId;
-        $orderModel->USER_NAME = $this->insertUserName;
-        $orderModel->ORDER_AMOUNT = $this->_decAmount;
-        $orderModel->PV = $this->_decPv;
-        $orderModel->PAY_AMOUNT = $this->_decAmount;
-        $orderModel->PAY_PV = $this->_decPv;
-        $orderModel->PAY_AT = Date::nowTime();
-        $orderModel->PAY_TYPE = 'cash';
-        $orderModel->PERIOD_NUM = $nowPeriodNum;
-        $orderModel->P_CALC_MONTH = Date::ociToDate($nowCalcMonth, Date::OCI_TIME_FORMAT_SHORT_MONTH);
-        $orderModel->FREIGHT = 0;
-        $orderModel->PAY_FREIGHT = 0;
-        $orderModel->CONSIGNEE = $this->consignee;
-        $orderModel->MOBILE = $this->acceptMobile;
-        $orderModel->PROVINCE = $this->province;
-        $orderModel->CITY = $this->city;
-        $orderModel->COUNTY = $this->county;
-        $orderModel->ADDRESS = $this->address;
-        $orderModel->WAREHOUSE = $warehouse;
-        $orderModel->STATUS = 1;
-        $orderModel->CREATED_AT = Date::nowTime();
-        $orderModel->CREATE_USER = Info::getUserNameByUserId(\Yii::$app->user->id);
-        if(!$orderModel->save()){
-            throw new Exception(Form::formatErrorsForApi($orderModel->getErrors()));
-        }
-        // 加入商品到订单商品表
-        foreach($this->_orderGoods as $key=>$value){
-            $this->_orderGoods[$key]['ORDER_SN'] = $orderModel->SN;
-            $this->_orderGoods[$key]['P_CALC_MONTH'] = Date::ociToDate($nowCalcMonth, Date::OCI_TIME_FORMAT_SHORT_MONTH);
-        }
-        OrderGoods::batchInsert($this->_orderGoods);
-
-        //写入收货地址信息
-        $addressModel = new ReceiveAddress();
-        $addressModel->USER_ID = $this->_insertUserId;
-        $addressModel->USER_NAME = $this->insertUserName;
-        $addressModel->CONSIGNEE = $this->consignee;
-        $addressModel->MOBILE = $this->acceptMobile;
-        $addressModel->PROVINCE = $this->province;
-        $addressModel->CITY = $this->city;
-        $addressModel->COUNTY = $this->county;
-        $addressModel->ADDRESS = $this->address;
-        $addressModel->IS_DEFAULT = 1;
-        if(!$addressModel->save()){
-            throw new Exception(Form::formatErrorsForApi($addressModel->getErrors()));
-        }
-        //扣报单人现金钱包
-        Cash::changeUserCash(\Yii::$app->user->id, 'CASH', -abs($this->_decAmount), ['REMARK' =>'为'.$this->insertUserName.'报单']);
-
-        return $addressModel;
-    }
-
-
-
-    /**
-     * 删单
-     * @return bool
-     * @throws \yii\db\Exception
-     */
-    public function delete(){
-        if(!$this->validate()){
-            return false;
-        }
-        $transaction = \Yii::$app->db->beginTransaction();
-        try {
-            $oneOrder = $this->_oneOrder;
-            // 首购单要删除会员
-            if($this->type == self::TYPE_ZC){
-                UserInfo::deleteUser($oneOrder['TO_USER_ID']);
-            }
-            // 如果是复销单的话,还需要考虑给会员的复销池减去金额
-            elseif($this->type == self::TYPE_FX){
-                Reconsume::changePoolPV($oneOrder['TO_USER_ID'], -abs($oneOrder['DEC_PV']), ['REMARK'=>'删单扣除', 'DEAL_TYPE'=>Reconsume::TYPE_AUDIT_PV]);
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('delete', $e->getMessage());
-            return false;
-        }
-        return true;
-    }
-
-}
+<?php
+namespace common\models\forms;
+
+use common\components\Model;
+
+/**
+ * Login form
+ */
+class DeclarationForm extends Model
+{
+    public $type;
+    public $decLv;
+    public $decWay;
+    public $packageId;
+    public $goodsId;
+    public $goodsNum;
+    public $insertUserName;
+    public $password;
+    public $payPassword;
+    public $realName;
+    public $insertUserIdCard;
+    public $mobile;
+    public $address;
+    public $openBank;
+    public $bankAddress;
+    public $bankNo;
+    public $bankProvince;
+    public $bankCity;
+    public $bankCounty;
+    public $conUserName;
+    public $recUserName;
+    public $decUserName;
+    public $location;
+    public $consignee;
+    public $acceptMobile;
+    public $province;
+    public $city;
+    public $county;
+
+    // 传过来的全部数据
+    public $allData;
+    private $_decId;
+    public $_insertUserId;
+    private $_decAmount;
+    private $_decPv;
+    private $_orderGoods;
+
+    const TYPE_ZC = 'ZC';
+//    const TYPE_YH = 'YH';
+    const TYPE_ZG = 'ZG';
+    const TYPE_LS = 'LS';
+    const TYPE_FX = 'FX';
+
+//    private $_modelClass = null;
+    private $_oneOrder = null;
+    private $_userForm = null;
+    private $_tempParentUser = [];
+    private $_tempNetworkParentUser = [];
+    private $_tempRelationParentUser = [];
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+       
+    }
+
+    public function attributeLabels()
+    {
+        
+    }
+}

+ 0 - 74
common/models/forms/DeclarationLevelForm.php

@@ -1,74 +0,0 @@
-<?php
-
-namespace common\models\forms;
-
-use common\components\Model;
-use common\helpers\Form;
-use common\libs\logging\operate\AdminOperate;
-use common\models\DeclarationLevel;
-
-/**
- * Login form
- */
-class DeclarationLevelForm extends Model {
-
-    public function init() {
-        parent::init();
-        $this->adminOperateLogger = new AdminOperate([
-            'fetchClass' => DeclarationLevel::class,
-        ]);
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules() {
-        return [
-        ];
-    }
-
-    /**
-     * 更新级别奖金
-     * @return bool
-     * @throws \yii\db\Exception
-     */
-    public function updateBonus() {
-        $beforeData = DeclarationLevel::getBonusConfig();
-        $this->adminOperateLogger->saveBeforeContent=$beforeData;
-
-        $postData = \Yii::$app->request->post('data');
-        $transaction = \Yii::$app->db->beginTransaction();
-        try {
-            foreach ($postData as $value) {
-                $decLevelModel = DeclarationLevel::findOne(['ID' => $value['ID']]);
-                if ($decLevelModel) {
-                    $decLevelModel->QY_PERCENT = $value['QY_PERCENT'];
-                    $decLevelModel->QY_TOUCH_CAP = $value['QY_TOUCH_CAP'];
-                    $decLevelModel->QY_BIG_CAP = $value['QY_BIG_CAP'];
-                    $decLevelModel->FX_MIN_DEEP = $value['FX_MIN_DEEP'];
-                    $decLevelModel->FX_MAX_DEEP = $value['FX_MAX_DEEP'];
-                    $decLevelModel->FX_PERCENT = $value['FX_PERCENT'];
-                    $decLevelModel->GL_ODD_DEEP_ONE = $value['GL_ODD_DEEP_ONE'];
-                    $decLevelModel->GL_ODD_DEEP_TWO = $value['GL_ODD_DEEP_TWO'];
-                    $decLevelModel->GL_ODD_DEEP_THREE = $value['GL_ODD_DEEP_THREE'];
-                    if (!$decLevelModel->save()) {
-                        throw new \Exception(Form::formatErrorsForApi($decLevelModel->getErrors()));
-                    }
-                }
-            }
-            $transaction->commit();
-        } catch (\Exception $e) {
-            $transaction->rollBack();
-            $this->addError('updateBonus', $e->getMessage());
-            return null;
-        }
-
-        $afterData = DeclarationLevel::getBonusConfig();
-        $this->adminOperateLogger->saveAfterContent=$afterData;
-        unset($beforeData,$afterData);
-        $this->adminOperateLogger->clean()->save([
-            'optType' => '更新级别奖金配置',
-        ]);
-        return true;
-    }
-}

+ 0 - 181
common/models/forms/DeclarationLoopForm.php

@@ -1,181 +0,0 @@
-<?php
-namespace common\models\forms;
-
-use common\components\Model;
-use common\helpers\Form;
-use common\models\UserBind;
-use yii\base\Exception;
-use yii\helpers\Json;
-
-/**
- * Login form
- */
-class DeclarationLoopForm extends Model
-{
-    public $data;
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['data'], 'required'],
-            [['data'], 'formatData'],
-            [['data'], 'isData', 'on'=>['canDec', 'notFull']],
-        ];
-    }
-
-    public function attributeLabels()
-    {
-        return [
-            'data' => '数据',
-        ];
-    }
-
-    /**
-     * 指定场景
-     * @return array
-     */
-    public function scenarios()
-    {
-        $parentScenarios =  parent::scenarios();
-        $customScenarios = [
-            'userDec' => ['data'],
-            'canDec' => ['data'],
-            'notFull' => ['data'],
-        ];
-        return array_merge($parentScenarios, $customScenarios);
-    }
-
-    /**
-     * 格式化提交的数据
-     * @param $attribute
-     */
-    public function formatData($attribute){
-        //$this->data = Json::decode($this->data);
-        if(!is_array($this->data)){
-            $this->addError($attribute, '数据格式错误');
-        }
-    }
-
-    /**
-     * 循环校验数据是否合格
-     * @param $attribute
-     */
-    public function isData($attribute){
-        $model = new DeclarationForm();
-        $model->scenario = $this->scenario;
-        $model->allData = $this->data;
-        foreach ($this->data as $value){
-            if(is_array($value)){
-                foreach($value as $key=>$decFormData){
-                    $model->$key = $decFormData;
-                }
-                if(!$model->validate()){
-                    $this->addErrors($model->getErrors());
-                }
-                $model->type = null;
-                $model->decSn = null;
-                $model->userId = null;
-                $model->toUserId = null;
-                $model->decPv = null;
-                $model->insertUserName = null;
-                $model->insertUserIdCard = null;
-                $model->conUserName = null;
-                $model->recUserName = null;
-                $model->location = null;
-            } else {
-                $this->addError($attribute, '报单数据格式错误');
-            }
-
-        }
-    }
-
-    /**
-     * 报单
-     * @return bool
-     * @throws \yii\db\Exception
-     */
-    public function add(){
-        $startTime = microtime(true);
-        if(!$this->validate()){
-            return null;
-        }
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try{
-            // 所有的首购单会员ID以备点位绑定使用
-            $allZcUserIds = [];
-            $zcUserIdCard = null;
-            $model = new DeclarationForm();
-            $model->scenario = $this->scenario;
-            $model->allData = $this->data;
-            foreach ($this->data as $value){
-                if(is_array($value)){
-                    foreach($value as $key=>$decFormData){
-                        $model->$key = $decFormData;
-                    }
-                    // 把首购单的几个会员归集到一个数组里,将来绑定到一起
-                    if( $model->type == 'ZC'){
-                        $allZcUserIds[] = null;
-                        if($zcUserIdCard != null){
-                            if($model->insertUserIdCard != $zcUserIdCard){
-                                throw new Exception('批量报单会员必须是同一身份证');
-                            }
-                        } else {
-                            $zcUserIdCard = $model->insertUserIdCard;
-                        }
-                    }
-                    if(!$model->add($this->data)){
-                        throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-                    }
-//                    $model->type = null;
-//                    $model->decSn = null;
-//                    $model->userId = null;
-//                    $model->toUserId = null;
-//                    $model->decPv = null;
-//                    $model->insertUserName = null;
-//                    $model->insertUserIdCard = null;
-//                    $model->conUserName = null;
-//                    $model->recUserName = null;
-//                    $model->location = null;
-                } else {
-                    throw new Exception('报单数据格式错误');
-                }
-            }
-
-            // 把这几个首购单的注册用户点位绑定到一起
-//            UserBind::zcBind($allZcUserIds, $zcUserIdCard);
-//            if((microtime(true) - $startTime) >= 20)  {
-//                throw new Exception('服务端报单超时');
-//            }
-            $transaction->commit();
-        } catch (\Exception $e){
-            $transaction->rollBack();
-            $this->addError('add', $e->getMessage());
-            return null;
-        }
-        return true;
-    }
-
-    /**
-     * RPC服务校验数据
-     * @param $data
-     * @return array
-     */
-    public static function rpcIsData($data){
-        $result = [
-            'error' => false,
-            'message' => '数据可报单',
-        ];
-        $formModel = new self();
-        $formModel->scenario = 'canDec';
-        $formModel->data = $data;
-        if(!$formModel->validate()){
-            $result['error'] = true;
-            $result['message'] = Form::formatErrorsForApi($formModel->getErrors());
-        }
-        return $result;
-    }
-}

+ 0 - 151
common/models/forms/EmployLevelForm.php

@@ -1,151 +0,0 @@
-<?php
-
-namespace common\models\forms;
-
-use backendApi\modules\v1\models\Admin;
-use common\components\Model;
-use common\helpers\Date;
-use common\helpers\Form;
-use common\libs\logging\operate\AdminOperate;
-use common\models\EmployLevel;
-use yii\helpers\Json;
-
-/**
- * Login form
- */
-class EmployLevelForm extends Model {
-    public $id;
-    public $levelName;          // 级别名称
-    public $locationNum;        // 区域数量
-    public $locationPerf;       // 单区业绩
-    public $newPerf;            // 当区新增业绩
-    public $minEmployLevel;     // locationNum个区域内存在什么级别的会员
-    public $sort;               // 等级排序
-    public $iconType;               // 等级排序
-    public $iconNum;               // 等级排序
-    public $otherDepartPerf;       // 其它部门的累计推荐业绩
-
-    public function init() {
-        parent::init();
-        $this->adminOperateLogger = new AdminOperate([
-            'fetchClass' => EmployLevel::class,
-        ]);
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules() {
-        return [
-            [['id', 'levelName', 'locationNum', 'locationPerf', 'newPerf', 'minEmployLevel', 'sort', 'iconType', 'iconNum', 'otherDepartPerf'], 'trim', 'on' => ['add', 'edit']],
-            [['id'], 'required', 'on' => 'edit'],
-            [['id'], 'exist', 'targetClass' => EmployLevel::class, 'targetAttribute' => 'ID'],
-            [['levelName', 'locationNum', 'locationPerf', 'newPerf', 'sort'], 'required'],
-            [['minEmployLevel'], 'exist', 'targetClass' => EmployLevel::class, 'targetAttribute' => 'ID'],
-            [['locationNum', 'sort'], 'integer'],
-            [['locationPerf', 'newPerf', 'otherDepartPerf'], 'price'],
-            [['iconType', 'iconNum'], 'number', 'max' => 10, 'min' => 0, 'on' => 'edit'],
-            ['iconType', 'isIconType', 'on' => 'edit'],
-            ['iconNum', 'isIconNum', 'on' => 'edit'],
-        ];
-    }
-
-    /**
-     * 图标类型判断
-     * @param $attributes
-     */
-    public function isIconType($attributes) {
-        if (!in_array($this->iconType, [0, 1, 2, 3])) {
-            $this->addError($attributes, '请选择正确的图标');
-        }
-    }
-
-    public function isIconNum($attributes) {
-        if (!in_array($this->iconType, [0, 1, 2, 3])) {
-            $this->addError($attributes, '请选择正确的图标');
-        }
-    }
-
-    /**
-     * 编辑
-     * @return EmployLevel|null|static
-     */
-    public function edit() {
-        if (!$this->validate()) {
-            return null;
-        }
-        if ($this->scenario == 'add') {
-            $this->addError('id', '提交场景不存在');
-            return null;
-            $model = new EmployLevel();
-            $model->CREATE_ADMIN = Admin::getAdminNameById(\Yii::$app->user->id);
-            $model->CREATED_AT = Date::nowTime();
-        } elseif ($this->scenario == 'edit') {
-            $model = EmployLevel::findOne(['ID' => $this->id]);
-            $model->UPDATE_ADMIN = Admin::getAdminNameById(\Yii::$app->user->id);
-            $model->UPDATED_AT = Date::nowTime();
-        } else {
-            $this->addError('id', '提交场景不存在');
-            return null;
-        }
-        //$model->LEVEL_NAME = $this->levelName;
-        //$model->LOCATION_NUM = $this->locationNum;
-        //$model->LOCATION_PERF = $this->locationPerf;
-        //$model->NEW_PERF = $this->newPerf;
-        //$model->MIN_EMPLOY_LEVEL = $this->minEmployLevel;
-        //$model->SORT = $this->sort;
-        $model->ICON_TYPE = $this->iconType;
-        $model->ICON_NUM = $this->iconNum;
-        $model->OTHER_DEPART_PERF = $this->otherDepartPerf;
-        if ($model->save()) {
-            return $model;
-        } else {
-            $this->addErrors($model->getErrors());
-            return null;
-        }
-    }
-
-    /**
-     * 聘级奖金配置
-     * @return bool|null
-     * @throws \yii\db\Exception
-     */
-    public function updateBonus(){
-        $beforeData = EmployLevel::getBonusConfig();
-        $this->adminOperateLogger->saveBeforeContent=$beforeData;
-
-        $postData = \Yii::$app->request->post('data');
-        $transaction = \Yii::$app->db->beginTransaction();
-        try {
-            foreach ($postData as $value) {
-                $empLevelModel = EmployLevel::findOne(['ID' => $value['ID']]);
-                if ($empLevelModel) {
-                    $empLevelModel->YC_PERCENT_ARR = Json::encode($value['YC_PERCENT_ARR']);
-//                    $empLevelModel->CF_BASE_NUM = $value['CF_BASE_NUM'];
-//                    $empLevelModel->CF_PERCENT = $value['CF_PERCENT'];
-//                    $empLevelModel->LX_BASE_NUM = $value['LX_BASE_NUM'];
-//                    $empLevelModel->LX_PERCENT = $value['LX_PERCENT'];
-                    $empLevelModel->RX_PERCENT = $value['RX_PERCENT'];
-                    $empLevelModel->LEVEL_SCORE = $value['LEVEL_SCORE'];
-                    $empLevelModel->UPGRADE_SCORE = $value['UPGRADE_SCORE'];
-                    if (!$empLevelModel->save()) {
-                        throw new \Exception(Form::formatErrorsForApi($empLevelModel->getErrors()));
-                    }
-                }
-            }
-            $transaction->commit();
-        } catch (\Exception $e) {
-            $transaction->rollBack();
-            $this->addError('updateBonus', $e->getMessage());
-            return null;
-        }
-
-        $afterData = EmployLevel::getBonusConfig();
-        $this->adminOperateLogger->saveAfterContent=$afterData;
-        unset($beforeData,$afterData);
-        $this->adminOperateLogger->clean()->save([
-            'optType' => '更新聘级奖金配置',
-        ]);
-        return true;
-    }
-}

+ 0 - 241
common/models/forms/ExcelOrderDecForm.php

@@ -1,241 +0,0 @@
-<?php
-namespace common\models\forms;
-
-use common\helpers\Date;
-use common\helpers\snowflake\SnowFake;
-use common\models\ExcelOrderShop;
-use common\models\OrderDec;
-use common\models\OrderGoodsDec;
-use common\models\Period;
-use common\models\User;
-use common\models\UserInfo;
-use Yii;
-use yii\base\Exception;
-
-class ExcelOrderDecForm extends \common\components\ActiveRecord
-{
-    CONST EXCEL_ORDER_SHOP_FIELD = [
-        '会员编号' => 'USER_NAME',
-//        '报单中心' => 'DEC_USER_NAME',
-//        '订单号' => 'ORDER_SN',
-        '订单状态' => 'STATUS',
-        '收货人' => 'CONSIGNEE',
-        '联系方式1' => 'MOBILE',
-        '省' => 'PROVINCE',
-        '市' => 'CITY',
-        '区' => 'COUNTY',
-        '详细地址' => 'ADDRESS',
-        '期数' => 'PERIOD_NUM',
-        '订单类型' => 'ORDER_TYPE',
-        '创建时间' => 'CREATED_AT',
-        '支付时间' => 'PAY_AT',
-        '发货时间' => 'DELIVERY_AT',
-        '运费' => 'FREIGHT',
-        '快递公司' => 'EXPRESS_COMPANY',
-        '快递单号' => 'ORDER_TRACK_NO',
-        '发货方式' => 'EXPRESS_TYPE',
-        '会员备注' => 'FRONT_REMARK',
-        '发货仓' => 'WAREHOUSE',
-        '发货状态' => 'DELIVERY_STATUS',
-    ];
-
-    CONST EXCEL_ORDER_SHOP_GOODS_FIELD = [
-        '订单号' => 'ORDER_SN',
-//        '订单状态' => 'STATUS',
-        '存货编码' => 'SKU_CODE',
-        '存货名称' => 'GOODS_TITLE',
-        '数量' => 'BUY_NUMS',
-        '商品单价' => 'PRICE',
-        '商品金额' => 'REAL_PRICE',
-        '商品PV' => 'PV',
-        'PV合计' => 'REAL_PV',
-        '期数' => 'PERIOD_NUM',
-    ];
-
-    private $_isSentMaxPeriodNum = 0;
-
-    /**
-     * 初始化最小未挂网的期数
-     */
-    public function initNoClosedMinPeriodNum() {
-        $periodModel = Period::instance();
-        $this->_isSentMaxPeriodNum = $periodModel->getMaxIsSentPeriodNum();
-    }
-
-    /**
-     * 导入excel数据
-     * @param $excelData
-     * @param $orderDay
-     * @param $payType
-     * @return bool
-     * @throws \Exception
-     */
-    public function run($excelData,$orderDay,$payType) {
-        if( !$excelData ) return false;
-        $this->initNoClosedMinPeriodNum();
-
-        foreach ($excelData as $everyData) {
-            if( !$everyData ) continue;
-
-            $formatOrderData = [];
-            $formatOrderGoodsData = [];
-            foreach ($everyData as $key => $value) {
-                if(isset(self::EXCEL_ORDER_SHOP_FIELD[$key])) {
-                    $formatOrderData[self::EXCEL_ORDER_SHOP_FIELD[$key]] = $value;
-                }
-
-                if(isset(self::EXCEL_ORDER_SHOP_GOODS_FIELD[$key])) {
-                    $formatOrderGoodsData[self::EXCEL_ORDER_SHOP_GOODS_FIELD[$key]] = $value;
-                }
-            }
-
-            if( !isset($formatOrderGoodsData['ORDER_SN']) ) {
-                throw new \Exception('缺少订单编号字段');
-            }
-
-            if ( !isset($formatOrderData['PERIOD_NUM']) ) {
-                throw new \Exception('缺少期数字段');
-            }
-
-            if ( $formatOrderData['PERIOD_NUM'] <= $this->_isSentMaxPeriodNum ) {
-                throw new \Exception(sprintf('不可以导入已经挂网期数【%s】的数据', $formatOrderData['PERIOD_NUM']));
-            }
-
-            //判断商城订单是表中是否已经存在该订单
-            $one = OrderDec::find()->select(["USER_ID", "PERIOD_NUM", "SN", "ORDER_AMOUNT", "PV", "PAY_AMOUNT", "PAY_PV"])->where('SN=:SN', ['SN' => $formatOrderGoodsData['ORDER_SN']])->asArray()->one();
-            if ($one) {
-                if ( $one['PERIOD_NUM'] != $formatOrderData['PERIOD_NUM'] ) {
-                    throw new \Exception(sprintf('订单号【%s】重复不可以导入', $formatOrderGoodsData['ORDER_SN']));
-                }
-
-                OrderDec::updateAllCounters([
-                    'ORDER_AMOUNT' => $formatOrderGoodsData['REAL_PRICE'],
-                    'PV' => $formatOrderGoodsData['REAL_PV'],
-                    'PAY_AMOUNT' => $formatOrderGoodsData['REAL_PRICE'],
-                    'PAY_PV' => $formatOrderGoodsData['REAL_PV'],
-                ], 'SN=:SN', [
-                    'SN' => $formatOrderGoodsData['ORDER_SN']
-                ]);
-
-                //会员状态激活
-                $amount = $one['ORDER_AMOUNT'] + $formatOrderGoodsData['REAL_PRICE'];
-                if ($amount >= 300) {
-                    $userStatus = User::find()->select(["ID", "STATUS"])->where('ID=:ID', ['ID' => $one['USER_ID']])->asArray()->one();
-                    if ($userStatus && $userStatus['STATUS'] == 0) {
-                        User::updateAll(['STATUS' => 1], 'ID=:ID', ['ID' => $one['USER_ID']]);
-                    }
-                }
-                unset($amount, $userStatus);
-
-            } else {
-                $userInfoArr = UserInfo::findOneAsArray('USER_NAME=:USER_NAME', [':USER_NAME' => $formatOrderData['USER_NAME']], 'USER_ID');
-                if (!isset($userInfoArr['USER_ID']) || !$userInfoArr['USER_ID']) {
-//                    echo $formatOrderData['USER_NAME'] . PHP_EOL;
-                    continue;
-                }
-                //insertOrderDec
-                $orderShopInsertData = array_merge($formatOrderData, [
-                    'ID' => SnowFake::instance()->generateId(),
-                    'SN' => $formatOrderGoodsData['ORDER_SN'],
-                    'USER_ID' => $userInfoArr['USER_ID'],
-                    'ORDER_TYPE' => 'ZC',
-                    'ORDER_AMOUNT' => $formatOrderGoodsData['REAL_PRICE'],
-                    'PV' => $formatOrderGoodsData['REAL_PV'],
-                    'PAY_AMOUNT' => $formatOrderGoodsData['REAL_PRICE'],
-                    'PAY_PV' => $formatOrderGoodsData['REAL_PV'],
-                    'PAY_AT' => strtotime(self::excelTime($formatOrderData['PAY_AT'])),
-                    'DELIVERY_AT' => strtotime(self::excelTime($formatOrderData['DELIVERY_AT'])),
-                    'CREATED_AT' => strtotime(self::excelTime($formatOrderData['CREATED_AT'])),
-                    'CREATE_USER' => $formatOrderData['USER_NAME'],
-                    'PAY_TYPE' => $payType,//@todo
-                    'STATUS' => 1,
-                    'P_CALC_MONTH' => self::excelTime($formatOrderData['CREATED_AT'],'Y-m-d'),
-                    'DELIVERY_STATUS' => $formatOrderData['DELIVERY_STATUS'] === '已发货' ? 1 : 0,
-                    'ORDER_DAY' => $orderDay,
-                ]);
-                OrderDec::insertOne($orderShopInsertData);
-
-                //会员状态激活
-                if ($orderShopInsertData['ORDER_AMOUNT'] >= 300) {
-                    $userStatus = User::find()->select(["ID", "STATUS"])->where('ID=:ID', ['ID' => $userInfoArr['USER_ID']])->asArray()->one();
-                    if ($userStatus && $userStatus['STATUS'] == 0) {
-                        User::updateAll(['STATUS' => 1], 'ID=:ID', ['ID' => $userInfoArr['USER_ID']]);
-                    }
-                }
-                unset($orderShopInsertData, $userInfoArr, $userStatus);
-            }
-
-            $decGoodsInsertData[] = array_merge($formatOrderGoodsData, [
-                'ORDER_DAY' => $orderDay,
-                'P_CALC_MONTH' => self::excelTime($formatOrderData['CREATED_AT'],'Y-m-d')
-            ]);
-            unset($formatOrderData, $formatOrderGoodsData, $everyData);
-        }
-
-        if( isset($decGoodsInsertData) && $decGoodsInsertData ) OrderGoodsDec::batchInsert($decGoodsInsertData);
-        unset($newStartRow, $goodsInsertData,$decGoodsInsertData);
-
-        return true;
-    }
-
-    /**
-     * 检测导入状态
-     * @param $orderDay
-     * @throws Exception
-     * @throws \yii\db\Exception
-     */
-    public function checkStatus($orderDay) {
-//        if( !$periodNum ) {
-//            throw new Exception('期数不能为空');
-//        }
-        $periodData = Period::getPeriodFromTime(strtotime($orderDay));
-        if(!$periodData){
-            throw new Exception('期数有误');
-        }
-        $periodNum = $periodData['PERIOD_NUM'];
-        //检查是否已经导入过了
-        $excelPeriodData = ExcelOrderShop::find()->where("ORDER_DAY=:ORDER_DAY AND ORDER_TYPE='ZC'", [':ORDER_DAY'=>$orderDay])->asArray()->one();
-        if( !$excelPeriodData ) {
-            ExcelOrderShop::insertOne(
-                [
-                    'ID' => SnowFake::instance()->generateId(),
-                    'PERIOD_NUM' => $periodNum,
-                    'ORDER_DAY' => $orderDay,
-                    'ORDER_TYPE' => 'ZC',
-                    'STATUS' => 0,
-                    'CREATED_AT' => Date::nowTime(),
-                ]
-            );
-        }
-
-//        if( $excelPeriodData['STATUS'] == 1 ) {
-//            throw new Exception(sprintf('%s订单已经导入过了,不可以重复导入', $orderDay));
-//        }
-
-        //清空已经导入的数据
-        $this->_clearPeriodOrder($orderDay);
-    }
-
-    protected function _clearPeriodOrder($orderDay) {
-        OrderDec::pageDeleteAll("ORDER_DAY='".$orderDay."'");
-        OrderGoodsDec::pageDeleteAll("ORDER_DAY='".$orderDay."'");
-    }
-
-    public function finished($orderDay) {
-        if( !$orderDay ) return false;
-
-        ExcelOrderShop::updateAll(['STATUS' => 1], "ORDER_DAY=:ORDER_DAY AND ORDER_TYPE='ZC'", [':ORDER_DAY'=>$orderDay]);
-        return true;
-    }
-
-    public function excelTime($orderDay,$format='Y-m-d H:i:s') {
-        if(is_numeric($orderDay)){
-            $t1 = intval(($orderDay - 25569) * 3600 * 24);
-            $orderDay=gmdate($format,$t1);
-        }
-        return $orderDay;
-    }
-
-
-
-}

+ 0 - 258
common/models/forms/ExcelOrderShopForm.php

@@ -1,258 +0,0 @@
-<?php
-namespace common\models\forms;
-
-use common\helpers\Date;
-use common\helpers\snowflake\SnowFake;
-use common\models\ExcelOrderShop;
-use common\models\OrderGoodsShop;
-use common\models\OrderShop;
-use common\models\Period;
-use common\models\User;
-use common\models\UserInfo;
-use Yii;
-use yii\base\Exception;
-
-class ExcelOrderShopForm extends \common\components\ActiveRecord
-{
-    CONST EXCEL_ORDER_SHOP_FIELD = [
-        '会员编号' => 'USER_NAME',
-//        '报单中心' => 'DEC_USER_NAME',
-//        '订单号' => 'ORDER_SN',
-        '订单状态' => 'STATUS',
-        '收货人' => 'CONSIGNEE',
-        '联系方式1' => 'MOBILE',
-        '省' => 'PROVINCE',
-        '市' => 'CITY',
-        '区' => 'COUNTY',
-        '详细地址' => 'ADDRESS',
-        '期数' => 'PERIOD_NUM',
-        '订单类型' => 'ORDER_TYPE',
-        '创建时间' => 'CREATED_AT',
-        '支付时间' => 'PAY_AT',
-        '发货时间' => 'DELIVERY_AT',
-        '运费' => 'FREIGHT',
-        '快递公司' => 'EXPRESS_COMPANY',
-        '快递单号' => 'ORDER_TRACK_NO',
-        '发货方式' => 'EXPRESS_TYPE',
-        '会员备注' => 'FRONT_REMARK',
-        '发货仓' => 'WAREHOUSE',
-        '发货状态' => 'DELIVERY_STATUS',
-    ];
-
-    CONST EXCEL_ORDER_SHOP_GOODS_FIELD = [
-        '订单号' => 'ORDER_SN',
-//        '订单状态' => 'STATUS',
-        '存货编码' => 'SKU_CODE',
-        '存货名称' => 'GOODS_TITLE',
-        '数量' => 'BUY_NUMS',
-        '商品单价' => 'PRICE',
-        '商品金额' => 'REAL_PRICE',
-        '商品PV' => 'PV',
-        'PV合计' => 'REAL_PV',
-        '期数' => 'PERIOD_NUM',
-    ];
-
-    private $_isSentMaxPeriodNum = 0;
-
-    /**
-     * 初始化最小未挂网的期数
-     */
-    public function initNoClosedMinPeriodNum() {
-        $periodModel = Period::instance();
-        $this->_isSentMaxPeriodNum = $periodModel->getMaxIsSentPeriodNum();
-    }
-
-
-    /**
-     * 导入excel数据
-     * @param $excelData
-     * @param $orderDay
-     * @param $payType
-     * @return bool
-     * @throws \yii\db\Exception
-     */
-    public function run($excelData,$orderDay,$payType) {
-        if( !$excelData ) return false;
-        $this->initNoClosedMinPeriodNum();
-
-        foreach ($excelData as $everyData) {
-            if( !$everyData ) continue;
-
-            $formatOrderData = [];
-            $formatOrderGoodsData = [];
-            foreach ($everyData as $key => $value) {
-                if(isset(self::EXCEL_ORDER_SHOP_FIELD[$key])) {
-                    $formatOrderData[self::EXCEL_ORDER_SHOP_FIELD[$key]] = $value;
-                }
-
-                if(isset(self::EXCEL_ORDER_SHOP_GOODS_FIELD[$key])) {
-                    $formatOrderGoodsData[self::EXCEL_ORDER_SHOP_GOODS_FIELD[$key]] = $value;
-                }
-            }
-
-            if( !isset($formatOrderGoodsData['ORDER_SN']) ) {
-                throw new \Exception('缺少订单编号字段');
-            }
-
-            if ( !isset($formatOrderData['PERIOD_NUM']) ) {
-                throw new \Exception('缺少期数字段');
-            }
-
-            if ( $formatOrderData['PERIOD_NUM'] <= $this->_isSentMaxPeriodNum ) {
-                throw new \Exception(sprintf('不可以导入已经挂网期数【%s】的数据', $formatOrderData['PERIOD_NUM']));
-            }
-
-            //判断商城订单是表中是否已经存在该订单
-            $one = OrderShop::find()->select(["USER_ID", "PERIOD_NUM", "SN", "ORDER_AMOUNT", "PV", "PAY_AMOUNT", "PAY_PV"])->where('SN=:SN', ['SN' => $formatOrderGoodsData['ORDER_SN']])->asArray()->one();
-            if ($one) {
-
-                if ( $one['PERIOD_NUM'] != $formatOrderData['PERIOD_NUM'] ) {
-                    throw new \Exception(sprintf('订单号【%s】重复不可以导入', $formatOrderGoodsData['ORDER_SN']));
-                }
-
-                OrderShop::updateAllCounters([
-                    'ORDER_AMOUNT' => $formatOrderGoodsData['REAL_PRICE'],
-                    'PV' => $formatOrderGoodsData['REAL_PV'],
-                    'PAY_AMOUNT' => $formatOrderGoodsData['REAL_PRICE'],
-                    'PAY_PV' => $formatOrderGoodsData['REAL_PV'],
-                ], 'SN=:SN', [
-                    'SN' => $formatOrderGoodsData['ORDER_SN']
-                ]);
-
-                //会员状态激活
-                $amount = $one['ORDER_AMOUNT'] + $formatOrderGoodsData['REAL_PRICE'];
-                if ($amount >= 300) {
-                    $userStatus = User::find()->select(["ID", "STATUS"])->where('ID=:ID', ['ID' => $one['USER_ID']])->asArray()->one();
-                    if ($userStatus && $userStatus['STATUS'] == 0) {
-                        User::updateAll(['STATUS' => 1], 'ID=:ID', ['ID' => $one['USER_ID']]);
-                    }
-                }
-                unset($amount, $userStatus);
-
-            } else {
-                $userInfoArr = UserInfo::findOneAsArray('USER_NAME=:USER_NAME', [':USER_NAME' => $formatOrderData['USER_NAME']], 'USER_ID');
-                if (!isset($userInfoArr['USER_ID']) || !$userInfoArr['USER_ID']) {
-//                    echo $formatOrderData['USER_NAME'] . PHP_EOL;
-                    continue;
-                }
-
-                //insertOrderShop
-                $orderShopInsertData = array_merge($formatOrderData, [
-                    'ID' => SnowFake::instance()->generateId(),
-                    'SN' => $formatOrderGoodsData['ORDER_SN'],
-                    'USER_ID' => $userInfoArr['USER_ID'],
-                    'ORDER_TYPE' => 'FX',
-                    'ORDER_AMOUNT' => $formatOrderGoodsData['REAL_PRICE'],
-                    'PV' => $formatOrderGoodsData['REAL_PV'],
-                    'PAY_AMOUNT' => $formatOrderGoodsData['REAL_PRICE'],
-                    'PAY_PV' => $formatOrderGoodsData['REAL_PV'],
-                    'PAY_AT' => strtotime(self::excelTime($formatOrderData['PAY_AT'])),
-                    'DELIVERY_AT' => strtotime(self::excelTime($formatOrderData['DELIVERY_AT'])),
-                    'CREATED_AT' => strtotime(self::excelTime($formatOrderData['CREATED_AT'])),
-                    'CREATE_USER' => $formatOrderData['USER_NAME'],
-                    'PAY_TYPE' => $payType,//@todo
-                    'STATUS' => 1,
-                    'P_CALC_MONTH' => self::excelTime($formatOrderData['CREATED_AT'],'Y-m-d'),
-                    'DELIVERY_STATUS' => $formatOrderData['DELIVERY_STATUS'] === '已发货' ? 1 : 0,
-                    'ORDER_DAY' => $orderDay,
-                ]);
-                OrderShop::insertOne($orderShopInsertData);
-
-                //会员状态激活
-                if ($orderShopInsertData['ORDER_AMOUNT'] >= 300) {
-                    $userStatus = User::find()->select(["ID", "STATUS"])->where('ID=:ID', ['ID' => $userInfoArr['USER_ID']])->asArray()->one();
-                    if ($userStatus && $userStatus['STATUS'] == 0) {
-                        User::updateAll(['STATUS' => 1], 'ID=:ID', ['ID' => $userInfoArr['USER_ID']]);
-                    }
-                }
-
-                unset($orderShopInsertData, $userInfoArr, $userStatus);
-            }
-            $goodsInsertData[] = array_merge($formatOrderGoodsData, [
-                'ORDER_DAY' => $orderDay,
-                'PAY_TYPE' => $payType,
-                'P_CALC_MONTH' => self::excelTime($formatOrderData['CREATED_AT'],'Y-m-d')
-            ]);
-            unset($formatOrderData, $formatOrderGoodsData, $everyData);
-
-        }
-
-        if( isset($goodsInsertData) && $goodsInsertData ) OrderGoodsShop::batchInsert($goodsInsertData);
-        unset($newStartRow, $goodsInsertData,$decGoodsInsertData);
-
-        return true;
-    }
-
-    /**
-     * 检测导入状态
-     * @param $orderDay
-     * @param $orderType
-     * @throws Exception
-     * @throws \yii\db\Exception
-     */
-    public function checkStatus($orderDay,$orderType) {
-//        if( !$periodNum ) {
-//            throw new Exception('期数不能为空');
-//        }
-        $periodData = Period::getPeriodFromTime(strtotime($orderDay));
-        if(!$periodData){
-            throw new Exception('期数有误');
-        }
-        $periodNum = $periodData['PERIOD_NUM'];
-        //检查是否已经导入过了
-        //$excelPeriodData = ExcelOrderShop::find()->where('PERIOD_NUM=:PERIOD_NUM', [':PERIOD_NUM'=>$periodNum])->asArray()->one();
-        if($orderType=='cash'){
-            $ot = 'FX';
-        }else{
-            $ot = 'PT';
-        }
-        $excelPeriodData = ExcelOrderShop::find()->where("ORDER_DAY=:ORDER_DAY AND ORDER_TYPE=:ORDER_TYPE", [':ORDER_DAY'=>$orderDay,':ORDER_TYPE'=>$ot])->asArray()->one();
-        if( !$excelPeriodData ) {
-            ExcelOrderShop::insertOne(
-                [
-                    'ID' => SnowFake::instance()->generateId(),
-                    'PERIOD_NUM' => $periodNum,
-                    'ORDER_DAY' => $orderDay,
-                    'ORDER_TYPE' => $ot,
-                    'STATUS' => 0,
-                    'CREATED_AT' => Date::nowTime(),
-                ]
-            );
-        }
-//            if( $excelPeriodData['STATUS'] == 1 ) {
-//                throw new Exception(sprintf('%s订单已经导入过了,不可以重复导入', $orderDay));
-//            }
-
-
-        //清空已经导入的数据
-        $this->_clearPeriodOrder($orderDay,$orderType);
-    }
-
-    protected function _clearPeriodOrder($orderDay,$orderType) {
-        OrderShop::pageDeleteAll("ORDER_DAY='".$orderDay."' and PAY_TYPE='".$orderType."'");
-        OrderGoodsShop::pageDeleteAll("ORDER_DAY='".$orderDay."' and PAY_TYPE='".$orderType."'");
-    }
-
-    public function finished($orderDay,$orderType) {
-        if( !$orderDay ) return false;
-
-        if($orderType=='cash'){
-            $ot = 'FX';
-        }else{
-            $ot = 'PT';
-        }
-        ExcelOrderShop::updateAll(['STATUS' => 1], "ORDER_DAY=:ORDER_DAY AND ORDER_TYPE=:ORDER_TYPE", [':ORDER_DAY'=>$orderDay,':ORDER_TYPE'=>$ot]);
-        return true;
-    }
-
-    public function excelTime($orderDay,$format='Y-m-d H:i:s') {
-        if(is_numeric($orderDay)){
-            $t1 = intval(($orderDay - 25569) * 3600 * 24);
-            $orderDay=gmdate($format,$t1);
-        }
-        return $orderDay;
-    }
-
-
-
-}

+ 0 - 169
common/models/forms/ExcelOrderStandardForm.php

@@ -1,169 +0,0 @@
-<?php
-namespace common\models\forms;
-
-use common\helpers\Date;
-use common\helpers\snowflake\SnowFake;
-use common\models\ExcelOrderShop;
-use common\models\OrderGoodsShop;
-use common\models\OrderShop;
-use common\models\OrderStandard;
-use common\models\OrderStandardGoods;
-use common\models\Period;
-use common\models\User;
-use common\models\UserInfo;
-use Yii;
-use yii\base\Exception;
-
-class ExcelOrderStandardForm extends \common\components\ActiveRecord
-{
-    CONST EXCEL_ORDER_SHOP_FIELD = [
-        '会员编号' => 'USER_NAME',
-//        '报单中心' => 'DEC_USER_NAME',
-//        '订单号' => 'ORDER_SN',
-        '订单状态' => 'STATUS',
-        '收货人' => 'CONSIGNEE',
-        '联系方式1' => 'MOBILE',
-        '省' => 'PROVINCE',
-        '市' => 'CITY',
-        '区' => 'COUNTY',
-        '详细地址' => 'ADDRESS',
-        '期数' => 'PERIOD_NUM',
-        '订单类型' => 'ORDER_TYPE',
-        '创建时间' => 'CREATED_AT',
-        '支付时间' => 'PAY_AT',
-        '发货时间' => 'DELIVERY_AT',
-        '运费' => 'FREIGHT',
-        '快递公司' => 'EXPRESS_COMPANY',
-        '快递单号' => 'ORDER_TRACK_NO',
-        '发货方式' => 'EXPRESS_TYPE',
-        '会员备注' => 'FRONT_REMARK',
-        '发货仓' => 'WAREHOUSE',
-        '发货状态' => 'DELIVERY_STATUS',
-    ];
-
-    CONST EXCEL_ORDER_SHOP_GOODS_FIELD = [
-        '订单号' => 'ORDER_SN',
-//        '订单状态' => 'STATUS',
-        '存货编码' => 'SKU_CODE',
-        '存货名称' => 'GOODS_TITLE',
-        '数量' => 'BUY_NUMS',
-        '商品单价' => 'PRICE',
-        '商品金额' => 'REAL_PRICE',
-        '商品PV' => 'PV',
-        'PV合计' => 'REAL_PV',
-        '期数' => 'PERIOD_NUM',
-    ];
-
-    /**
-     * 导入excel数据
-     * @param $excelData
-     * @param $orderMonth
-     * @param $payType
-     * @return bool
-     * @throws \yii\db\Exception
-     */
-    public function run($excelData,$orderMonth,$payType) {
-        if( !$excelData ) return false;
-        foreach ($excelData as $everyData) {
-            if( !$everyData ) continue;
-
-            $formatOrderData = [];
-            $formatOrderGoodsData = [];
-            foreach ($everyData as $key => $value) {
-                if(isset(self::EXCEL_ORDER_SHOP_FIELD[$key])) {
-                    $formatOrderData[self::EXCEL_ORDER_SHOP_FIELD[$key]] = $value;
-                }
-
-                if(isset(self::EXCEL_ORDER_SHOP_GOODS_FIELD[$key])) {
-                    $formatOrderGoodsData[self::EXCEL_ORDER_SHOP_GOODS_FIELD[$key]] = $value;
-                }
-            }
-
-            if( !isset($formatOrderGoodsData['ORDER_SN']) ) continue;
-
-            //判断商城订单是表中是否已经存在该订单
-            $one = OrderStandard::find()->select(["USER_ID", "SN", "ORDER_AMOUNT", "PV", "PAY_AMOUNT", "PAY_PV"])->where('SN=:SN', ['SN' => $formatOrderGoodsData['ORDER_SN']])->asArray()->one();
-            if ($one) {
-                OrderStandard::updateAllCounters([
-                    'ORDER_AMOUNT' => $formatOrderGoodsData['REAL_PRICE'],
-                    'PV' => $formatOrderGoodsData['REAL_PV'],
-                    'PAY_AMOUNT' => $formatOrderGoodsData['REAL_PRICE'],
-                    'PAY_PV' => $formatOrderGoodsData['REAL_PV'],
-                ], 'SN=:SN', [
-                    'SN' => $formatOrderGoodsData['ORDER_SN']
-                ]);
-            } else {
-                $userInfoArr = UserInfo::findOneAsArray('USER_NAME=:USER_NAME', [':USER_NAME' => $formatOrderData['USER_NAME']], 'USER_ID');
-                if (!isset($userInfoArr['USER_ID']) || !$userInfoArr['USER_ID']) {
-//                    echo $formatOrderData['USER_NAME'] . PHP_EOL;
-                    continue;
-                }
-
-                //insertOrderShop
-                $orderShopInsertData = array_merge($formatOrderData, [
-                    'ID' => SnowFake::instance()->generateId(),
-                    'SN' => $formatOrderGoodsData['ORDER_SN'],
-                    'USER_ID' => $userInfoArr['USER_ID'],
-                    'ORDER_TYPE' => 'FX',
-                    'ORDER_AMOUNT' => $formatOrderGoodsData['REAL_PRICE'],
-                    'PV' => $formatOrderGoodsData['REAL_PV'],
-                    'PAY_AMOUNT' => $formatOrderGoodsData['REAL_PRICE'],
-                    'PAY_PV' => $formatOrderGoodsData['REAL_PV'],
-                    'PAY_AT' => strtotime(self::excelTime($formatOrderData['PAY_AT'])),
-                    'DELIVERY_AT' => strtotime(self::excelTime($formatOrderData['DELIVERY_AT'])),
-                    'CREATED_AT' => strtotime(self::excelTime($formatOrderData['CREATED_AT'])),
-                    'CREATE_USER' => $formatOrderData['USER_NAME'],
-                    'PAY_TYPE' => $payType,//@todo
-                    'STATUS' => 1,
-                    'DELIVERY_STATUS' => $formatOrderData['DELIVERY_STATUS'] === '已发货' ? 1 : 0,
-                    'CALC_MONTH' => $this->_getCalcMonth($orderMonth),
-                ]);
-                OrderStandard::insertOne($orderShopInsertData);
-            }
-            $goodsInsertData[] = array_merge($formatOrderGoodsData, [
-                'CALC_MONTH' => $this->_getCalcMonth($orderMonth),
-                'PAY_TYPE' => $payType,
-            ]);
-            unset($formatOrderData, $formatOrderGoodsData, $everyData);
-
-        }
-
-        if( isset($goodsInsertData) && $goodsInsertData ) OrderStandardGoods::batchInsert($goodsInsertData);
-        unset($newStartRow, $goodsInsertData,$decGoodsInsertData);
-
-        return true;
-    }
-
-    /**
-     * 检测导入状态
-     * @param $orderMonth
-     */
-    public function checkStatus($orderMonth) {
-        //清空已经导入的数据
-        $this->_clearPeriodOrder($orderMonth);
-    }
-
-    protected function _clearPeriodOrder($orderMonth) {
-        OrderStandard::pageDeleteAll("CALC_MONTH=".$this->_getCalcMonth($orderMonth));
-        OrderStandardGoods::pageDeleteAll("CALC_MONTH=".$this->_getCalcMonth($orderMonth));
-    }
-
-    protected function _getCalcMonth($orderMonth) {
-        return date('Ym', strtotime($orderMonth.'-01'));
-    }
-
-    public function excelTime($orderDay,$format='Y-m-d H:i:s') {
-        if(is_numeric($orderDay)){
-            $t1 = intval(($orderDay - 25569) * 3600 * 24);
-            $orderDay=gmdate($format,$t1);
-        }
-        return $orderDay;
-    }
-
-    public function finished($orderMonth) {
-        return true;
-    }
-
-
-
-}

+ 0 - 145
common/models/forms/HistoryBonusForm.php

@@ -1,145 +0,0 @@
-<?php
-
-namespace common\models\forms;
-
-use common\components\Model;
-use common\helpers\Cache;
-use common\helpers\Date;
-use common\helpers\user\Info;
-use common\models\HistoryBonus;
-use common\models\UserBonus;
-use common\models\Withdraw;
-
-/**
- * 历史奖金余额表单
- */
-class HistoryBonusForm extends Model {
-    private $_query;
-    private $_totalCount;
-    private $_limit = 100;
-    private $_backupCompleted = false;
-    /**
-     * 自动备份
-     * @return bool
-     * @throws \yii\base\InvalidConfigException
-     */
-    public function taskAutoBackup(){
-        //HistoryWalletHelper::setAutoBackupRunning();
-        $this->handleQuery();
-        try{
-            foreach($this->_query->batch($this->_limit) as $list){
-                if($list){
-                    $insert = [];
-                    foreach($list as $value){
-                        if(!$info = Info::baseInfoWithNet($value['USER_ID'])) continue;
-                        $insert[] = [
-                            'USER_ID' => $value['USER_ID'],
-                            'USER_NAME' => $info['USER_NAME'],
-                            'REAL_NAME' => $info['REAL_NAME'],
-                            'DEC_LV' => $info['DEC_LV'],
-                            'EMP_LV' => $info['EMP_LV'],
-                            'IS_DEC' => $info['IS_DEC'],
-                            'DEC_ROLE_ID' => $info['DEC_ROLE_ID'],
-                            'SYSTEM_NAME' => $info['SYSTEM_NAME'],
-                            'BONUS' => $value['BONUS'],
-                            'CF' => $value['CF'],
-                            'LX' => $value['LX'],
-                            'WITHDRAW' => Withdraw::getWithdrawTotal($value['USER_ID'], Withdraw::STATUS_WAIT_PAID),
-                            'WITHDRAW_TAX' => 0.00,//todo 待提现开发
-                            'WITHDRAW_DEDUCT' => 0.00,//todo 待提现开发
-                            'WITHDRAW_REAL' => 0.00,//todo 待提现开发
-                            'WITHDRAW_FAIL' => Withdraw::getWithdrawTotal($value['USER_ID'], Withdraw::STATUS_PAID_FALSE),
-                            'USER_STATUS' => $info['STATUS'],
-                            'USER_STATUS_AT' => $info['STATUS_AT'],
-                            'HIGHEST_EMP_LV' => $info['HIGHEST_EMP_LV'],
-                            'PERIOD_AT' => $info['PERIOD_AT'],
-                            'DEC_DEC_ROLE_ID' => $info['DEC_DEC_ROLE_ID'],
-                            'DEC_USER_NAME' => $info['DEC_USER_NAME'],
-                            'DEC_REAL_NAME' => $info['DEC_REAL_NAME'],
-                            'MOBILE' => $info['MOBILE'],
-                            'TEL' => $info['TEL'],
-                            'PROVINCE' => $info['PROVINCE'],
-                            'CITY' => $info['CITY'],
-                            'COUNTY' => $info['COUNTY'],
-                            'SUB_COM_ID' => $info['SUB_COM_ID'],
-                            'IS_DIRECT_SELLER' => $info['IS_DIRECT_SELLER'],
-                            'BACKUP_AT' => Date::nowTime(),
-                            'PARTITION_DATE' => Date::ociToDate(),
-                        ];
-                    }
-                    if($insert){
-                        HistoryBonus::batchInsert($insert);
-                    }
-                }
-            }
-            $this->backupCompleted();
-        }catch (\PDOException $e) {
-            $error = $e->getMessage();
-            // 说明数据读取完成了
-            if (strpos($error, 'fetch out of sequence') !== false) {
-                $this->backupCompleted();
-            } else {
-                //todo log
-                //Logger::error($this->getThrowMessage($e), 'historyBonus');
-            }
-        }catch(\Exception $e){
-            print_r($e->getMessage());
-            //todo log
-            //Logger::error($this->getThrowMessage($e), 'historyBonus');
-        }
-
-        // 开始删除
-        if($this->_backupCompleted){
-            try{
-                $this->_deleteHistoryByLimit();
-                return true;
-            }catch(\Exception $e){
-                //todo log
-                //Logger::error('[deleteHistoryByLimit]' . $this->getThrowMessage($e), 'historyBonus');
-                return false;
-            }
-        }
-        return true;
-    }
-
-    /**
-     * 完成
-     */
-    public function backupCompleted(){
-        // todo log
-        //Logger::error('备份完成[success]于 ' . date('Y-m-d H:i:s', Date::nowTime()), 'historyBonus');
-        $this->_backupCompleted = true;
-    }
-
-    /**
-     *
-     */
-    public function handleQuery(){
-        UserBonus::prepare();
-        $this->_query = UserBonus::$query;
-        $countQuery = clone $this->_query;
-        $this->_totalCount = $this->_query->count();
-        unset($countQuery);
-    }
-
-
-
-    /**
-     * 删除
-     */
-    private function _deleteHistoryByLimit(){
-        $config = Cache::getSystemConfig();
-        $historyBonusLimit = (int)$config['historyBonusLimit']['VALUE'];
-        if($historyBonusLimit > 0){
-            // 604800 = 7 * 86400
-            $limit = 604800 * $historyBonusLimit;
-            // 多少周以前
-            $timestamp = Date::nowTime() - $limit;
-            // todo logger
-            //Logger::error('开始删除于 ' . date('Y-m-d H:i:s', Date::nowTime()), 'historyBonus');
-            HistoryBonus::deleteAll("BACKUP_AT<=:BACKUP_AT", ['BACKUP_AT' => $timestamp]);
-            // todo logger
-            //Logger::error('删除结束于 ' . date('Y-m-d H:i:s', Date::nowTime()), 'historyBonus');
-        }
-    }
-}

+ 0 - 347
common/models/forms/InvoiceAuditForm.php

@@ -1,347 +0,0 @@
-<?php
-
-namespace common\models\forms;
-
-use common\helpers\Cache;
-use common\helpers\Date;
-use common\helpers\user\Balance;
-use common\helpers\user\Info;
-use common\helpers\user\Status;
-use common\components\Model;
-use common\helpers\Form;
-use common\models\InvoiceAudit;
-use common\models\Period;
-use common\models\RegInfoAudit;
-use common\models\User;
-use common\models\UserInfo;
-use common\models\Withdraw;
-use yii\base\Exception;
-
-/**
- * 点位绑定表单
- */
-class InvoiceAuditForm extends Model {
-    public $id;
-    public $withdrawId;
-    public $invoiceCode;
-    public $invoiceNum;
-    public $invoiceDate;
-    public $amount;
-    public $taxRate;
-    public $purchaserName;
-    public $purchaserRegisterNum;
-    public $purchaserAddress;
-    public $purchaserBank;
-    public $sellerName;
-    public $sellerRegisterNum;
-    public $sellerAddress;
-    public $sellerBank;
-    public $itemName;
-    public $invoiceRemark;
-    public $createRemark;
-    public $auditStatus;
-
-    private $_uid;
-    private $_model;
-    private $_withdrawModel;
-
-    /**
-     * @inheritdoc
-     */
-    public function rules() {
-        return [
-            [['id', 'withdrawId', 'invoiceCode', 'invoiceNum', 'invoiceDate', 'amount', 'taxRate', 'purchaserName', 'purchaserRegisterNum', 'purchaserAddress', 'purchaserBank', 'sellerName', 'sellerRegisterNum', 'sellerAddress', 'sellerBank', 'itemName', 'invoiceRemark', 'createRemark'], 'trim'],
-            [['id', 'withdrawId', 'invoiceCode', 'invoiceNum', 'invoiceDate', 'amount', 'purchaserName', 'purchaserRegisterNum', 'purchaserAddress', 'purchaserBank', 'sellerName', 'sellerRegisterNum', 'sellerAddress', 'sellerBank', 'itemName'], 'required'],
-            [['id'], 'initModel'],
-            [['withdrawId'], 'initWithdrawModel'],
-            [['itemName'], 'isItemName'],
-            //[['invoiceNum'], 'isInvoiceNum'],
-            [['auditStatus'], 'isAuditStatus'],
-
-        ];
-    }
-
-    /**
-     * 指定校验场景
-     * @return array
-     */
-    public function scenarios() {
-        $parentScenarios = parent::scenarios();
-        $customScenarios = [
-            'addByAdmin' => ['withdrawId', 'invoiceCode', 'invoiceNum', 'invoiceDate', 'amount', 'taxRate', 'purchaserName', 'purchaserRegisterNum', 'purchaserAddress', 'purchaserBank', 'sellerName', 'sellerRegisterNum', 'sellerAddress', 'sellerBank', 'itemName', 'invoiceRemark', 'createRemark'],
-            'editByAdmin' => ['id', 'withdrawId', 'invoiceCode', 'invoiceNum', 'invoiceDate', 'amount', 'taxRate', 'purchaserName', 'purchaserRegisterNum', 'purchaserAddress', 'purchaserBank', 'sellerName', 'sellerRegisterNum', 'sellerAddress', 'sellerBank', 'itemName', 'invoiceRemark', 'createRemark'],
-            'audit' => ['id', 'withdrawId', 'invoiceCode', 'invoiceNum', 'invoiceDate', 'amount', 'taxRate', 'purchaserName', 'purchaserRegisterNum', 'purchaserAddress', 'purchaserBank', 'sellerName', 'sellerRegisterNum', 'sellerAddress', 'sellerBank', 'itemName', 'invoiceRemark', 'createRemark', 'auditStatus'],
-        ];
-        return array_merge($parentScenarios, $customScenarios);
-    }
-
-    public function attributeLabels() {
-        return [
-            'id' => '发票id',
-            'withdrawId' => '提现id',
-            'invoiceCode' => '发票代码',
-            'invoiceNum' => '发票号码',
-            'invoiceDate' => '开票日期',
-            'amount' => '提现金额',
-            'taxRate' => '税率',
-            'purchaserName' => '购买方名称',
-            'purchaserRegisterNum' => '购买方纳税人识别号',
-            'purchaserAddress' => '购买方地址电话',
-            'purchaserBank' => '购买方开户行及账号',
-            'sellerName' => '销售方名称',
-            'sellerRegisterNum' => '销售方纳税人识别号',
-            'sellerAddress' => '销售方地址电话',
-            'sellerBank' => '销售方地址电话',
-            'itemName' => '货物或应税劳务服务名称',
-            'invoiceRemark' => '发票备注',
-            'createRemark' => '备注',
-        ];
-    }
-
-    /**
-     * 初始化model
-     * @param $attributes
-     */
-    public function initModel($attributes) {
-        $this->_model = InvoiceAudit::findOne(['ID' => $this->id]);
-        if (!$this->_model) {
-            $this->addError($attributes, '数据不存在');
-        }
-        if ($this->_model->AUDIT_STATUS != \Yii::$app->params['auditStatus']['un']['value']) {
-            $this->addError($attributes, '本数据已经被处理过了');
-        }
-    }
-
-    /**
-     * 初始化withdrawModel
-     * @param $attributes
-     */
-    public function initWithdrawModel($attributes) {
-        $this->_withdrawModel = Withdraw::findOne(['ID' => $this->withdrawId]);
-        if (!$this->_withdrawModel) {
-            $this->addError($attributes, '数据不存在');
-        }
-        if ($this->_withdrawModel->AUDIT_STATUS != Withdraw::STATUS_APPLIED) {
-            $this->addError($attributes, '已审核的提现无法修改发票信息');
-        }
-        if ($this->amount != $this->_withdrawModel->AMOUNT) {
-            $this->addError($attributes, '上传发票金额与提现金额不一致');
-        }
-        if (InvoiceAudit::find()->where('INVOICE_NUM=:INVOICE_NUM AND WITHDRAW_ID!=:WITHDRAW_ID AND AUDIT_STATUS=:AUDIT_STATUS', [':INVOICE_NUM' => $this->invoiceNum, ':WITHDRAW_ID' => $this->withdrawId, ':AUDIT_STATUS' => \Yii::$app->params['auditStatus']['true']['value']])->exists()) {
-            $this->addError($attributes, '该发票的发票号码【'.$this->invoiceNum.'】已被使用');
-        }
-    }
-
-    /**
-     * 审核状态是否正确
-     * @param $attributes
-     */
-    public function isAuditStatus($attributes) {
-        if (!array_key_exists($this->auditStatus, \Yii::$app->params['auditStatus'])) {
-            $this->addError($attributes, '无效的审核状态');
-        }
-    }
-
-    /**
-     * 货物或应税劳务服务名称是否正确
-     * @param $attributes
-     */
-    public function isItemName($attributes) {
-        $configName = Cache::getSystemConfig()['invoiceItemName']['VALUE'];
-        if ($this->itemName != $configName) {
-            $this->addError($attributes, '上传发票中货物或应税劳务服务名称与后台预置信息【' . $configName . '】不一致');
-        }
-    }
-
-    /**
-     * 添加
-     * @return RegInfoAudit|null
-     * @throws \yii\db\Exception
-     */
-    public function addByAdmin() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $transaction = \Yii::$app->db->beginTransaction();
-        try {
-            // 添加会员合作点位
-            $invoiceModel = new InvoiceAudit();
-            $invoiceModel->USER_ID = $this->_withdrawModel->USER_ID;
-            $invoiceModel->WITHDRAW_ID = $this->withdrawId;
-            $invoiceModel->INVOICE_CODE = $this->invoiceCode;
-            $invoiceModel->INVOICE_NUM = $this->invoiceNum;
-            $invoiceModel->INVOICE_DATE = $this->invoiceDate ? Date::convert(Date::utcToTime($this->invoiceDate), 'Y年m月d日') : 0;
-            $invoiceModel->AMOUNT = $this->amount;
-            $invoiceModel->TAX_RATE = $this->taxRate;
-            $invoiceModel->PURCHASER_NAME = $this->purchaserName;
-            $invoiceModel->PURCHASER_REGISTER_NUM = $this->purchaserRegisterNum;
-            $invoiceModel->PURCHASER_ADDRESS = $this->purchaserAddress;
-            $invoiceModel->PURCHASER_BANK = $this->purchaserBank;
-            $invoiceModel->SELLER_NAME = $this->sellerName;
-            $invoiceModel->SELLER_REGISTER_NUM = $this->sellerRegisterNum;
-            $invoiceModel->SELLER_ADDRESS = $this->sellerAddress;
-            $invoiceModel->SELLER_BANK = $this->sellerBank;
-            $invoiceModel->ITEM_NAME = $this->itemName;
-            $invoiceModel->INVOICE_REMARK = $this->invoiceRemark;
-            $invoiceModel->CREATE_REMARK = $this->createRemark;
-            $invoiceModel->CREATE_ADMIN = \Yii::$app->user->id;
-            $invoiceModel->CREATED_AT = Date::nowTime();
-            if (!$invoiceModel->save()) {
-                throw new Exception(Form::formatErrorsForApi($invoiceModel->getErrors()));
-            }
-            //写入提现表
-            $withdrawModel = $this->_withdrawModel;
-            $withdrawModel->INVOICE_ID = $invoiceModel->ID;
-            $withdrawModel->UPDATE_ADMIN = \Yii::$app->user->id;
-            $withdrawModel->UPDATED_AT = Date::nowTime();
-            if ($withdrawModel->AUDIT_STATUS == Withdraw::STATUS_APPLIED) {
-//                $withdrawModel->AUDIT_STATUS = Withdraw::STATUS_INVOICED;
-                $withdrawModel->AUDIT_ADMIN = \Yii::$app->user->id;
-                $withdrawModel->AUDITED_AT = Date::nowTime();
-            }
-            if (!$withdrawModel->save()) {
-                throw new Exception(Form::formatErrorsForApi($withdrawModel->getErrors()));
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('addByAdmin', $e->getMessage());
-            return null;
-        }
-        return $invoiceModel;
-    }
-
-    /**
-     * 修改操作
-     * @return null
-     * @throws \yii\db\Exception
-     */
-    public function editByAdmin() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $transaction = \Yii::$app->db->beginTransaction();
-        try {
-            $invoiceModel = $this->_model;
-            $invoiceModel->USER_ID = $this->_withdrawModel->USER_ID;
-            $invoiceModel->WITHDRAW_ID = $this->withdrawId;
-            $invoiceModel->INVOICE_CODE = $this->invoiceCode;
-            $invoiceModel->INVOICE_NUM = $this->invoiceNum;
-            $invoiceModel->INVOICE_DATE = $this->invoiceDate ? Date::convert(Date::utcToTime($this->invoiceDate), 'Y年m月d日') : 0;
-            $invoiceModel->AMOUNT = $this->amount;
-            $invoiceModel->TAX_RATE = $this->taxRate;
-            $invoiceModel->PURCHASER_NAME = $this->purchaserName;
-            $invoiceModel->PURCHASER_REGISTER_NUM = $this->purchaserRegisterNum;
-            $invoiceModel->PURCHASER_ADDRESS = $this->purchaserAddress;
-            $invoiceModel->PURCHASER_BANK = $this->purchaserBank;
-            $invoiceModel->SELLER_NAME = $this->sellerName;
-            $invoiceModel->SELLER_REGISTER_NUM = $this->sellerRegisterNum;
-            $invoiceModel->SELLER_ADDRESS = $this->sellerAddress;
-            $invoiceModel->SELLER_BANK = $this->sellerBank;
-            $invoiceModel->ITEM_NAME = $this->itemName;
-            $invoiceModel->INVOICE_REMARK = $this->invoiceRemark;
-            $invoiceModel->CREATE_REMARK = $this->createRemark;
-            $invoiceModel->CREATE_ADMIN = \Yii::$app->user->id;
-            $invoiceModel->CREATED_AT = Date::nowTime();
-            if (!$invoiceModel->save()) {
-                throw new Exception(Form::formatErrorsForApi($invoiceModel->getErrors()));
-            }
-            //写入提现表
-            $withdrawModel = $this->_withdrawModel;
-            $withdrawModel->INVOICE_ID = $invoiceModel->ID;
-            $withdrawModel->UPDATE_ADMIN = \Yii::$app->user->id;
-            $withdrawModel->UPDATED_AT = Date::nowTime();
-            if ($withdrawModel->AUDIT_STATUS == Withdraw::STATUS_APPLIED) {
-//                $withdrawModel->AUDIT_STATUS = Withdraw::STATUS_INVOICED;
-                $withdrawModel->AUDIT_ADMIN = \Yii::$app->user->id;
-                $withdrawModel->AUDITED_AT = Date::nowTime();
-            }
-            if (!$withdrawModel->save()) {
-                throw new Exception(Form::formatErrorsForApi($withdrawModel->getErrors()));
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('editByAdmin', $e->getMessage());
-            return null;
-        }
-        return $invoiceModel;
-    }
-
-    /**
-     * 审核操作
-     * @return null
-     * @throws \yii\db\Exception
-     */
-    public function audit() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $transaction = \Yii::$app->db->beginTransaction();
-        try {
-            $invoiceModel = $this->_model;
-            $withdrawModel = $this->_withdrawModel;
-            if ($this->auditStatus == 'reject') {
-                $invoiceModel->AUDIT_STATUS = \Yii::$app->params['auditStatus']['reject']['value'];
-
-                $withdrawModel->AUDIT_STATUS = Withdraw::STATUS_APPLIED;
-                $withdrawModel->AUDIT_ADMIN = \Yii::$app->user->id;
-                $withdrawModel->AUDITED_AT = Date::nowTime();
-            } elseif ($this->auditStatus == 'true') {
-                $invoiceModel->INVOICE_CODE = $this->invoiceCode;
-                $invoiceModel->INVOICE_NUM = $this->invoiceNum;
-                $invoiceModel->INVOICE_DATE = $this->invoiceDate ? Date::convert(Date::utcToTime($this->invoiceDate), 'Y年m月d日') : 0;
-                $invoiceModel->AMOUNT = $this->amount;
-                $invoiceModel->TAX_RATE = $this->taxRate;
-                $invoiceModel->PURCHASER_NAME = $this->purchaserName;
-                $invoiceModel->PURCHASER_REGISTER_NUM = $this->purchaserRegisterNum;
-                $invoiceModel->PURCHASER_ADDRESS = $this->purchaserAddress;
-                $invoiceModel->PURCHASER_BANK = $this->purchaserBank;
-                $invoiceModel->SELLER_NAME = $this->sellerName;
-                $invoiceModel->SELLER_REGISTER_NUM = $this->sellerRegisterNum;
-                $invoiceModel->SELLER_ADDRESS = $this->sellerAddress;
-                $invoiceModel->SELLER_BANK = $this->sellerBank;
-                $invoiceModel->ITEM_NAME = $this->itemName;
-                $invoiceModel->INVOICE_REMARK = $this->invoiceRemark;
-                $invoiceModel->AUDIT_STATUS = \Yii::$app->params['auditStatus']['true']['value'];
-                //能否自动流转
-                $userInfo = UserInfo::findOneAsArray('USER_ID=:USER_ID', [':USER_ID' => $withdrawModel->USER_ID], 'REG_TYPE,SHOULD_REG_TYPE');
-                if ($userInfo['REG_TYPE'] == $userInfo['SHOULD_REG_TYPE']) {
-                    $withdrawModel->AUDIT_STATUS = Withdraw::STATUS_AUDITED;
-                    $withdrawModel->AUDIT_ADMIN = \Yii::$app->user->id;
-                    $withdrawModel->AUDITED_AT = Date::nowTime();
-                }
-            }
-            $invoiceModel->AUDIT_ADMIN = \Yii::$app->user->id;
-            $invoiceModel->CREATE_REMARK = $this->createRemark;
-            $invoiceModel->AUDITED_AT = Date::nowTime();
-
-            if (!$invoiceModel->save()) {
-                throw new Exception(Form::formatErrorsForApi($invoiceModel->getErrors()));
-            }
-            if (!$withdrawModel->save()) {
-                throw new Exception(Form::formatErrorsForApi($withdrawModel->getErrors()));
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('audit', $e->getMessage());
-            return null;
-        }
-        return $invoiceModel;
-    }
-
-    /**
-     * 删除
-     * @param $selected
-     * @throws Exception
-     */
-    public static function delete($selected) {
-        foreach ($selected as $select) {
-            $withdraw = Withdraw::findOneAsArray('INVOICE_ID=:INVOICE_ID', [':INVOICE_ID' => $select], 'SN,AUDIT_STATUS');
-            if ($withdraw['AUDIT_STATUS'] != Withdraw::STATUS_APPLIED) {
-                throw new Exception('发票所属提现流水号' . $withdraw['SN'] . '非 未传发票/待审核 状态,无法删除');
-            }
-        }
-    }
-}

+ 0 - 231
common/models/forms/InvoiceBalanceAuditForm.php

@@ -1,231 +0,0 @@
-<?php
-
-namespace common\models\forms;
-
-use common\helpers\Date;
-use common\helpers\user\Balance;
-use common\helpers\user\Info;
-use common\helpers\user\Status;
-use common\components\Model;
-use common\helpers\Form;
-use common\models\InvoiceAudit;
-use common\models\InvoiceBalanceAudit;
-use common\models\Period;
-use common\models\RegInfoAudit;
-use common\models\User;
-use common\models\UserInfo;
-use yii\base\Exception;
-
-/**
- * 点位绑定表单
- */
-class InvoiceBalanceAuditForm extends Model {
-    public $id;
-    public $userName;
-    public $realName;
-    public $idCard;
-    public $regType;
-    public $amount;
-    public $createRemark;
-    public $auditRemark;
-    public $auditStatus;
-
-    private $_uid;
-    private $_model;
-
-    /**
-     * @inheritdoc
-     */
-    public function rules() {
-        return [
-            [['id', 'userName', 'realName', 'idCard', 'regType', 'amount', 'createRemark', 'auditRemark', 'auditStatus'], 'trim'],
-            [['id', 'userName', 'realName', 'idCard', 'regType', 'amount', 'auditStatus'], 'required'],
-            [['userName'], 'isUserName'],
-            [['id'], 'initModel'],
-            [['auditStatus'], 'isAuditStatus'],
-        ];
-    }
-
-    /**
-     * 指定校验场景
-     * @return array
-     */
-    public function scenarios() {
-        $parentScenarios = parent::scenarios();
-        $customScenarios = [
-            'add' => ['userName', 'realName', 'idCard', 'regType', 'amount', 'createRemark'],
-            'edit' => ['id', 'amount', 'createRemark'],
-            'audit' => ['id', 'amount', 'auditRemark', 'auditStatus'],
-        ];
-        return array_merge($parentScenarios, $customScenarios);
-    }
-
-    public function attributeLabels() {
-        return [
-            'userName' => '会员编号',
-            'realName' => '会员姓名',
-            'idCard' => '身份证号',
-            'regType' => '注册类型',
-            'amount' => '交易金额',
-            'createRemark' => '创建备注',
-            'auditRemark' => '审核备注',
-            'auditStatus' => '审核状态',
-        ];
-    }
-
-    /**
-     * 初始化model
-     * @param $attributes
-     */
-    public function initModel($attributes) {
-        $this->_model = InvoiceBalanceAudit::findOne(['ID' => $this->id]);
-        if (!$this->_model) {
-            $this->addError($attributes, '数据不存在');
-        }
-        if ($this->_model->AUDIT_STATUS != \Yii::$app->params['auditStatus']['un']['value']) {
-            $this->addError($attributes, '本数据已经被处理过了');
-        }
-    }
-
-    /**
-     * 用户名是否正确
-     * @param $attributes
-     */
-    public function isUserName($attributes) {
-        $userInfo = UserInfo::findOneAsArray(['USER_NAME' => $this->userName]);
-        if ($userInfo) {
-            $baseInfo = Info::baseInfoZh($userInfo['USER_ID']);
-            if ($baseInfo['REAL_NAME'] != $this->realName || $baseInfo['ID_CARD'] != $this->idCard) {
-                $this->addError($attributes, '输入的会员姓名或身份证号与系统不一致');
-            }
-            if ($userInfo['REG_TYPE'] != $this->regType) {
-                $this->addError($attributes, '选择的会员注册类型与系统不一致');
-            }
-            if (InvoiceBalanceAudit::find()->where('USER_ID=:USER_ID AND AUDIT_STATUS=0', [':USER_ID' => $userInfo['USER_ID']])->exists()) {
-                $this->addError($attributes, '填写的会员有待审核的发票调整');
-            }
-            $this->_uid = $userInfo['USER_ID'];
-        } else {
-            $this->addError($attributes, '会员不存在');
-        }
-    }
-
-    /**
-     * 审核状态是否正确
-     * @param $attributes
-     */
-    public function isAuditStatus($attributes) {
-        if (!array_key_exists($this->auditStatus, \Yii::$app->params['auditStatus'])) {
-            $this->addError($attributes, '无效的审核状态');
-        }
-    }
-
-    /**
-     * 添加
-     * @return RegInfoAudit|null
-     * @throws \yii\db\Exception
-     */
-    public function add() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $transaction = \Yii::$app->db->beginTransaction();
-        try {
-            // 添加会员合作点位
-            $model = new InvoiceBalanceAudit();
-            $model->USER_ID = $this->_uid;
-            $model->AMOUNT = $this->amount;
-            $model->AUDIT_STATUS = \Yii::$app->params['auditStatus']['un']['value'];
-            $model->CREATE_ADMIN = \Yii::$app->user->id;
-            $model->CREATE_REMARK = $this->createRemark;
-            $model->CREATED_AT = Date::nowTime();
-            if (!$model->save()) {
-                throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('add', $e->getMessage());
-            return null;
-        }
-        return $model;
-    }
-
-    /**
-     * 修改操作
-     * @return null
-     * @throws \yii\db\Exception
-     */
-    public function edit() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $transaction = \Yii::$app->db->beginTransaction();
-        try {
-            $model = $this->_model;
-            $model->AMOUNT = $this->amount;
-            $model->CREATE_REMARK = $this->createRemark;
-            if (!$model->save()) {
-                throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('edit', $e->getMessage());
-            return null;
-        }
-        return $model;
-    }
-
-    /**
-     * 审核操作
-     * @return null
-     * @throws \yii\db\Exception
-     */
-    public function audit() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $transaction = \Yii::$app->db->beginTransaction();
-        try {
-            $model = $this->_model;
-            if ($this->auditStatus == 'reject') {
-                $model->AUDIT_STATUS = \Yii::$app->params['auditStatus']['reject']['value'];
-            } elseif ($this->auditStatus == 'true') {
-                $model->AUDIT_STATUS = \Yii::$app->params['auditStatus']['true']['value'];
-                $model->AMOUNT = $this->amount;
-            }
-            $model->AUDIT_ADMIN = \Yii::$app->user->id;
-            $model->AUDIT_REMARK = $this->auditRemark;
-            $model->AUDITED_AT = Date::nowTime();
-            if (!$model->save()) {
-                throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-            }
-            //更新会员税款信息
-            if ($this->auditStatus == 'true') {
-                Balance::changeInvoice($model->USER_ID, $model->AMOUNT, [
-                    'REMARK' => '审核发票调整',
-                    'CREATE_ADMIN' => $model->CREATE_ADMIN,
-                    'CREATE_REMARK' => $model->CREATE_REMARK,
-                    'CREATE_TIME' => $model->CREATED_AT,
-                    'AUDIT_ADMIN' => $model->AUDIT_ADMIN,
-                    'AUDIT_REMARK' => $model->AUDIT_REMARK,
-                    'AUDIT_TIME' => $model->AUDITED_AT,
-                ]);
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('audit', $e->getMessage());
-            return null;
-        }
-        return $model;
-    }
-
-    /**
-     * 删除
-     * @param $selected
-     */
-    public static function delete($selected) {
-    }
-}

+ 0 - 101
common/models/forms/LogAdminHandleForm.php

@@ -1,101 +0,0 @@
-<?php
-
-namespace common\models\forms;
-
-use common\models\LogAdminHandle;
-use Yii;
-
-class LogAdminHandleForm extends \yii\base\Model
-{
-    public $_id;
-    public $admin_id;
-    public $admin_name;
-    public $ip;
-    public $created_at;
-    public $request_route;
-    public $opt_type;
-    public $save_before_content;
-    public $save_after_content;
-    public $key_log;
-    public $opt_obj_id;
-    public $opt_obj_name;
-    public $remark;
-    public $user_agent;
-    public $period_num;
-    public $is_batch;
-    public $device;
-
-    /**
-     * @inheritdoc
-     */
-    public function rules(){
-        return [
-            [['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'], 'trim'],
-            [['admin_id', 'admin_name', 'ip', 'request_route', 'opt_type'], 'required'],
-            [['created_at', 'key_log', 'is_batch', 'period_num'], 'filter', 'filter' => function($value){
-                return ($value) ? $value : 0;
-            }],
-            [['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' => '客户端',
-        ];
-    }
-
-    /**
-     * 添加
-     * @return LogAdminHandle|bool
-     */
-    public function add(){
-        if(!$this->validate()){
-            return false;
-        }
-        $model = new LogAdminHandle();
-        $model->admin_id = $this->admin_id;
-        $model->admin_name = $this->admin_name;
-        $model->ip = $this->ip;
-        $model->created_at = intval($this->created_at);
-        $model->request_route = $this->request_route;
-        $model->opt_type = $this->opt_type;
-        $model->save_before_content = $this->save_before_content;
-        $model->save_after_content = $this->save_after_content;
-        $model->key_log = $this->key_log;
-        $model->opt_obj_id = $this->opt_obj_id;
-        $model->opt_obj_name = $this->opt_obj_name;
-        $model->remark = $this->remark;
-        $model->user_agent = $this->user_agent;
-        $model->period_num = intval($this->period_num);
-        $model->is_batch = intval($this->is_batch);
-        $model->device = $this->device;
-
-        if(!$model->save()){
-            return false;
-        }
-        return $model;
-    }
-}

+ 0 - 124
common/models/forms/LogAdminLoginForm.php

@@ -1,124 +0,0 @@
-<?php
-
-namespace common\models\forms;
-
-use common\models\LogAdminLogin;
-use Yii;
-
-class LogAdminLoginForm extends \yii\base\Model
-{
-    const KEY_LOG_COLUMN = 'key_log';
-    public $_id;
-    public $adm_name;
-    public $ip;
-    public $created_at;
-    public $user_agent;
-    public $period_num;
-    public $opt_type;
-    public $success_times;
-    public $fail_times;
-    public $device;
-    public $request_route;
-    public $return_result;
-    /**
-     * DB
-     * @return \yii\db\Connection the database connection used by this AR class.
-     * @throws \yii\base\InvalidConfigException
-     */
-    public static function getDb()
-    {
-        return Yii::$app->get('mongodb');
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules(){
-        return [
-            [['adm_name', 'ip', 'request_route'], 'required'],
-            [['created_at', 'success_times', 'period_num',  'fail_times'], 'filter', 'filter' => function($value){
-                return ($value) ? $value : 0;
-            }],
-            [['adm_name', 'ip', 'opt_type'], 'string', 'max' => 16],
-            [['_id', 'return_result', 'device',], 'safe'],
-            [['user_agent', 'request_route'], 'string', 'max' => 1000],
-        ];
-    }
-    /**
-     * @inheritdoc
-     */
-    public function beforeValidate() {
-        return parent::beforeValidate();
-    }
-    /**
-     * @inheritdoc
-     */
-    public function scenarios() {
-        return parent::scenarios();
-    }
-    /**
-     * @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' => '返回内容',
-        ];
-    }
-
-    /**
-     * 添加
-     * @return bool|LogAdminLogin
-     */
-    public function add(){
-        if(!$this->validate()){
-            return false;
-        }
-        $model = new LogAdminLogin();
-        $model->adm_name = $this->adm_name;
-        $model->ip = $this->ip;
-        $model->created_at = intval($this->created_at);
-        $model->user_agent = $this->user_agent;
-        $model->period_num = intval($this->period_num);
-        $model->opt_type = $this->opt_type;
-        $model->success_times = intval($this->success_times);
-        $model->fail_times = intval($this->fail_times);
-        $model->device = $this->device;
-        $model->request_route = $this->request_route;
-        $model->return_result = $this->return_result;
-
-        if(!$model->save()){
-            return false;
-        }
-        return $model;
-    }
-
-    /**
-     * 删除
-     * @param $id
-     * @return array|bool|null|\yii\mongodb\ActiveRecord
-     * @throws \yii\db\StaleObjectException
-     */
-    public function delete($id){
-        $row = LogAdminLogin::find()->select(['adm_name'])->where(['_id'=>$id])->one();
-        if(!$row){
-            $this->setError('要删除的日志不存在');
-            return false;
-        }
-        if(!$row->delete()){
-            $this->setError('日志删除失败');
-        }
-        return $row;
-    }
-
-}

+ 0 - 685
common/models/forms/NetMoveForm.php

@@ -1,685 +0,0 @@
-<?php
-
-namespace common\models\forms;
-
-use common\components\Model;
-use common\helpers\Date;
-use common\helpers\Form;
-use common\helpers\NetPoint;
-use common\helpers\user\Info;
-use common\libs\logging\operate\AdminOperate;
-use common\models\Period;
-use common\models\UserBind;
-use common\models\UserInfo;
-use common\models\UserMove;
-use common\models\UserNetwork;
-use common\models\UserRelation;
-use yii\db\Exception;
-
-/**
- * Login form
- */
-class NetMoveForm extends Model {
-    public $moveId;
-    public $selected;
-    public $moveUserName;
-    public $toConUserName;
-    public $toConRealName;
-    public $location;
-    public $type;
-    public $remark;
-    public $auditStatus;
-
-    private $_model;
-    private $_moveUserId;
-    private $_toConUserId;
-    private $_moveUserInfo;
-    private $_fromConUserId;
-    private $_fromConUserInfo;
-    private $_fromLocation;
-
-    public function init() {
-        parent::init();
-        $this->adminOperateLogger = new AdminOperate([
-            'fetchClass' => UserMove::class,
-        ]);
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules() {
-        return [
-            [['moveId', 'moveUserName', 'toConUserName', 'toConRealName', 'location', 'type', 'remark', 'auditStatus'], 'trim'],
-            [['moveId', 'moveUserName', 'toConUserName', 'toConRealName', 'location', 'type', 'remark', 'auditStatus'], 'required'],
-            [['moveId'], 'exist', 'targetClass' => UserMove::class, 'targetAttribute' => 'ID', 'message' => '移网申请不存在'],
-            [['moveId'], 'initModel'],
-            [['moveUserName'], 'exist', 'targetClass' => UserInfo::class, 'targetAttribute' => 'USER_NAME', 'message' => '要移动的会员不存在'],
-            [['location'], 'integer'],
-            [['location'], 'isLocation'],
-            [['type'], 'isType'],
-            [['moveUserName'], 'isMoveUser'],
-            [['toConUserName'], 'isToUser'],
-            [['auditStatus'], 'isStatus'],
-        ];
-    }
-
-    /**
-     * 指定场景
-     * @return array
-     */
-    public function scenarios() {
-        $parentScenarios = parent::scenarios();
-        $customScenarios = [
-            'add' => ['moveUserName', 'toConUserName', 'toConRealName', 'location', 'type', 'remark'],
-            'changeAudit' => ['selected', 'remark', 'auditStatus'],
-            'edit' => ['moveId', 'moveUserName', 'toConUserName', 'toConRealName', 'location', 'type', 'remark'],
-            'pass' => ['moveId', 'moveUserName', 'toConUserName', 'toConRealName', 'location', 'type', 'remark'],
-            'async' => ['moveId', 'moveUserName', 'toConUserName', 'toConRealName', 'location', 'type'],
-        ];
-        return array_merge($parentScenarios, $customScenarios);
-    }
-
-    /**
-     * @return array
-     */
-    public function attributeLabels() {
-        return [
-            'moveId' => '移网申请Id',
-            'moveUserName' => '要移动的会员编号',
-            'toConUserName' => '移动到的会员编号',
-            'toConRealName' => '移动到的会员姓名',
-            'location' => '位置',
-            'type' => '移网类型',
-            'remark' => '备注',
-            'auditStatus' => '状态',
-        ];
-    }
-
-    /**
-     * 初始化model类
-     * @param $attribute
-     */
-    public function initModel($attribute) {
-        $model = $this->_model = UserMove::findOne(['ID' => $this->moveId]);
-        if ($model->AUDIT_STATUS > \Yii::$app->params['auditStatus']['un']['value']) {
-            $this->addError($attribute, '该申请已经被审核,不能重复审核');
-        }
-    }
-
-    /**
-     * 校验区位是否正确
-     * @param $attribute
-     */
-    public function isLocation($attribute) {
-        if ($this->type == NetPoint::NET_TYPE_NETWORK) {
-            if (!in_array($this->location, [1, 2, 3])) {
-                $this->addError($attribute, '区位不正确');
-            }
-        }
-    }
-
-    /**
-     * 移网类型校验
-     * @param $attribute
-     */
-    public function isType($attribute) {
-        if (!in_array($this->type, [NetPoint::NET_TYPE_NETWORK, NetPoint::NET_TYPE_RELATION])) {
-            $this->addError($attribute, '移网类型不正确');
-        }
-    }
-
-    /**
-     * 校验移点位的一些细节要求
-     * @param $attribute
-     * @param $params
-     * @throws Exception
-     * @throws \yii\base\Exception
-     */
-    public function isMoveUser($attribute, $params) {
-        if ($this->moveUserName == $this->toConUserName) {
-            $this->addError($attribute, '不能移动到自己点位下');
-        }
-        $this->_moveUserId = Info::getUserIdByUserName($this->moveUserName);
-        $this->_moveUserInfo = Info::baseInfo($this->_moveUserId);
-        if ($this->type == NetPoint::NET_TYPE_NETWORK) {
-            $this->_fromConUserId = $this->_moveUserInfo['CON_UID'];
-        } else {
-            $this->_fromConUserId = $this->_moveUserInfo['REC_UID'];
-        }
-        $this->_fromConUserInfo = Info::baseInfo($this->_fromConUserId);
-        $this->_toConUserId = Info::getUserIdByUserName($this->toConUserName);
-
-        if (!$this->_fromConUserInfo) {
-            $this->addError($attribute, '原节点会员不存在,可能该会员是顶层会员不可移动');
-        }
-        if ($this->type == NetPoint::NET_TYPE_NETWORK) {
-            $this->_fromLocation = UserNetwork::getLocation($this->_moveUserId, $this->_fromConUserId);
-        }
-        // 原接点和新接点是否同一个
-        if ($this->_fromConUserId == $this->_toConUserId) {
-            if($this->type == NetPoint::NET_TYPE_RELATION){
-                $this->addError($attribute, '节点位置没有发生变化');
-            }
-            elseif($this->type == NetPoint::NET_TYPE_NETWORK){
-                // 查看原区位
-                if($this->_fromLocation == $this->location){
-                    $this->addError($attribute, '节点位置没有发生变化');
-                }
-            }
-        }
-        // 要求开拓网新接点人必须是自己的上级(从自己的父级线中能找到新接点人)
-//        if ($this->type == NetPoint::NET_TYPE_RELATION) {
-//            if(!UserNetwork::isParentUser($this->_moveUserId, $this->_toConUserId)){
-//                $this->addError($attribute, '修改后的开拓者编号不在移动会员安置网所有上级编号中');
-//            }
-//            //此会员的上级必须在新开拓者的安置网下
-//            if(($this->_moveUserInfo['CON_UID']!=$this->_toConUserId)&&!UserNetwork::isParentUser($this->_moveUserInfo['CON_UID'],$this->_toConUserId)){
-//                $this->addError($attribute, '会员的上级必须在新开拓者的安置网下');
-//            }
-        if ($this->type == NetPoint::NET_TYPE_NETWORK) {
-            // 查看新节点的下面人数是否已经达到上限
-            $allChildUser = UserNetwork::getFirstFloorChildren($this->_toConUserId);
-            if ($allChildUser) {
-                $isLocation = [1 => false, 2 => false, 3 => false];
-                foreach ($allChildUser as $child) {
-                    $isLocation[$child['RELATIVE_LOCATION']] = true;
-                    if ($child['RELATIVE_LOCATION'] == $this->location) {
-                        $this->addError($attribute, '新接点人的此区位已经存在会员');
-                    }
-                }
-                // 第二区不能空点,必须要有会员才能注册到第三区
-                /*if($this->location == 3 && $isLocation[2] === false){
-                    $this->addError($attribute, '新接点人第二区没有安置会员,无法安置到第三区');
-                }*/
-            } else {
-                /*if($this->location != 1){
-                    $this->addError($attribute, '新接点人左区没有点位,必须放在其左区');
-                }*/
-            }
-        }
-        // 新节点不能是自己节点的下级
-        if ($this->type == NetPoint::NET_TYPE_NETWORK) {
-            $modelClass = UserNetwork::class;
-        } else {
-            $modelClass = UserRelation::class;
-        }
-        if ($modelClass::isParentUser($this->_toConUserId, $this->_moveUserId)) {
-            $this->addError($attribute, '不能移动到该会员的子会员点位下');
-        }
-    }
-
-    /**
-     * 移动到的会员账号姓名判断
-     * @param $attribute
-     * @throws \yii\base\Exception
-     */
-    public function isToUser($attribute) {
-        //移动到的节点会员不存在
-        $toUser = Info::baseInfo($this->_toConUserId);
-        if ($toUser['REAL_NAME'] != $this->toConRealName) {
-            $this->addError($attribute, '移动到的会员账号和姓名不匹配');
-        }
-    }
-
-    /**
-     * 校验状态
-     * @param $attribute
-     */
-    public function isStatus($attribute) {
-        // 获取当前提现单的状态
-        $oneData = UserMove::findOneAsArray(['ID' => $this->moveId]);
-        switch ($this->auditStatus) {
-            case 'un':
-                $this->addError($attribute, '不能设置为待审核状态' . $this->auditStatus);
-                break;
-            case 'true':
-                if ($oneData['AUDIT_STATUS'] == \Yii::$app->params['auditStatus']['true']['value']) {
-                    $this->addError($attribute, '已经审核通过不能重复审核');
-                } elseif ($oneData['AUDIT_STATUS'] == \Yii::$app->params['auditStatus']['reject']['value']) {
-                    $this->addError($attribute, '已经审核拒绝不能重复审核');
-                }
-                break;
-            case 'reject':
-                if ($oneData['AUDIT_STATUS'] == \Yii::$app->params['auditStatus']['true']['value']) {
-                    $this->addError($attribute, '已经审核通过不能重复审核');
-                } elseif ($oneData['AUDIT_STATUS'] == \Yii::$app->params['auditStatus']['reject']['value']) {
-                    $this->addError($attribute, '已经审核拒绝不能重复审核');
-                }
-                break;
-            default:
-                $this->addError($attribute, '状态参数有误');
-        }
-    }
-
-    /**
-     * 添加移网申请记录
-     * @return UserMove|null
-     * @throws Exception
-     */
-    public function add() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            $period = Period::instance();
-            $model = new UserMove();
-            $model->USER_ID = $this->_moveUserId;
-            $model->FROM_UID = $this->_fromConUserId;
-            $model->TO_UID = $this->_toConUserId;
-            $model->NET_TABLE_NAME = strtoupper($this->type) . '_' . \date('YmdHis', Date::nowTime()) . rand(100, 999);
-            if ($this->type == NetPoint::NET_TYPE_NETWORK) {
-                $model->TYPE = UserMove::TYPE_NETWORK;
-                $model->LOCATION = $this->location;
-            } elseif ($this->type == NetPoint::NET_TYPE_RELATION) {
-                $model->TYPE = UserMove::TYPE_RELATION;
-            } else {
-                throw new Exception('错误的移网类型');
-            }
-            $model->PERIOD_NUM = $period->getNowPeriodNum();
-            $model->MOVE_ADMIN_ID = \Yii::$app->user->id;
-            $model->CREATE_REMARK = $this->remark;
-            $model->CREATED_AT = Date::nowTime();
-            if (!$model->save()) {
-                throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('add', $e->getMessage());
-            return null;
-        }
-
-        $this->adminOperateLogger->afterInsert($model)->clean()->save([
-            'optType' => '申请移网',
-            'userId' => $model->USER_ID,
-            'userName' => Info::getUserNameByUserId($model->USER_ID),
-            'remark' => $this->remark
-        ]);
-
-        return $model;
-    }
-
-    /**
-     * 修改信息
-     * @return null
-     * @throws \yii\db\Exception
-     */
-    public function edit() {
-        //不再可以单独修改
-        return null;
-        if (!$this->validate()) {
-            return null;
-        }
-
-        if( !$this->_checkMovingData() ) {
-            return null;
-        }
-
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            $model = $this->_model;
-            if ($model->IS_MOVING == 1) {
-                throw new Exception('该申请正在移网操作,不能重复编辑');
-            }
-            $model->USER_ID = $this->_moveUserId;
-            $model->FROM_UID = $this->_fromConUserId;
-            $model->TO_UID = $this->_toConUserId;
-            if ($this->type == NetPoint::NET_TYPE_NETWORK) {
-                $model->TYPE = UserMove::TYPE_NETWORK;
-                $model->LOCATION = $this->location;
-            } elseif ($this->type == NetPoint::NET_TYPE_RELATION) {
-                $model->TYPE = UserMove::TYPE_RELATION;
-            } else {
-                throw new Exception('类型不存在');
-            }
-            $model->CREATE_REMARK = $this->remark;
-            if (!$model->save()) {
-                throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('edit', $e->getMessage());
-            return null;
-        }
-        return $model;
-    }
-
-    /**
-     * 审核通过
-     * @return null
-     * @throws \yii\db\Exception
-     */
-    public function pass() {
-        if (!$this->validate()) {
-            return null;
-        }
-
-        if( !$this->_checkMovingData() ) {
-            return null;
-        }
-
-        $this->adminOperateLogger->beforeUpdate($this->_model);
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            $model = $this->_model;
-            if ($model->IS_MOVING == 1) {
-                throw new Exception('该申请正在移网操作,不能重复审核');
-            }
-            $model->USER_ID = $this->_moveUserId;
-            $model->FROM_UID = $this->_fromConUserId;
-            $model->TO_UID = $this->_toConUserId;
-            if ($this->type == NetPoint::NET_TYPE_NETWORK) {
-                $model->TYPE = UserMove::TYPE_NETWORK;
-                $model->LOCATION = $this->location;
-            } elseif ($this->type == NetPoint::NET_TYPE_RELATION) {
-                $model->TYPE = UserMove::TYPE_RELATION;
-            } else {
-                throw new Exception('类型不存在');
-            }
-            if (!$model->save()) {
-                throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('edit', $e->getMessage());
-            return null;
-        }
-
-        $this->adminOperateLogger->afterUpdate($model)->clean()->save([
-            'optType' => '审核通过移网',
-            'userId' => $model->USER_ID,
-            'userName' => Info::getUserNameByUserId($model->USER_ID),
-            'remark' => $this->remark??''
-        ]);
-
-        $oneMove = UserMove::find()->select('UM.*, UMI.USER_NAME AS MOVE_USER_NAME, UTI.USER_NAME AS TO_USER_NAME')->from(UserMove::tableName() . ' AS UM')->join('LEFT JOIN', UserInfo::tableName() . ' AS UMI', 'UM.USER_ID=UMI.USER_ID')->join('LEFT JOIN', UserInfo::tableName() . ' AS UTI', 'UM.TO_UID=UTI.USER_ID')->where('UM.ID=:ID', [':ID' => $this->moveId])->asArray()->one();
-        if (!$oneMove) {
-            $this->addError('audit', '移网申请不存在');
-            return null;
-        }
-        if ($oneMove['AUDIT_STATUS'] > 0) {
-            $this->addError('audit', '已审核过,不能审核');
-            return null;
-        }
-        $this->moveUserName = $oneMove['MOVE_USER_NAME'];
-        $this->toConUserName = $oneMove['TO_USER_NAME'];
-        if ($oneMove['TYPE'] === UserMove::TYPE_NETWORK) {
-            $this->type = NetPoint::NET_TYPE_NETWORK;
-        } elseif ($oneMove['TYPE'] === UserMove::TYPE_RELATION) {
-            $this->type = NetPoint::NET_TYPE_RELATION;
-        }
-        $this->location = $oneMove['LOCATION'];
-        return $this->moveWebToAsync();
-    }
-
-
-    protected function _checkMovingData()
-    {
-        $oneData = UserMove::find()->where('IS_MOVING=:IS_MOVING AND AUDIT_STATUS=:AUDIT_STATUS', [
-            'IS_MOVING' => 1,
-            'AUDIT_STATUS' => \Yii::$app->params['auditStatus']['un']['value']
-        ])->asArray()->one();
-
-        if( $oneData ) {
-            $this->addError('edit', '有正在移网的数据,请稍后再操作。');
-            return false;
-        }
-
-        return true;
-    }
-
-    /**
-     * 审核移网
-     * @return null
-     * @throws \yii\db\Exception
-     */
-    public function changeAudit() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $this->adminOperateLogger->setIsBatch(true)->beforeUpdate($this->selected,'ID');
-        $period = Period::instance();
-        //拒绝审核
-        if ($this->auditStatus == 'reject') {
-            $db = \Yii::$app->db;
-            $transaction = $db->beginTransaction();
-            try {
-                foreach ($this->selected as $select) {
-                    $model = UserMove::findOne(['ID' => $select]);
-                    if ($model->AUDIT_STATUS > \Yii::$app->params['auditStatus']['un']['value']) continue;
-                    $model->AUDIT_STATUS = \Yii::$app->params['auditStatus'][$this->auditStatus]['value'];
-                    $model->AUDIT_ADMIN_ID = \Yii::$app->user->id;
-                    $model->CREATE_REMARK = $this->remark;
-                    $model->AUDIT_PERIOD_NUM = $period->getNowPeriodNum();
-                    $model->AUDITED_AT = Date::nowTime();
-                    if (!$model->save()) {
-                        throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-                    }
-                }
-                $transaction->commit();
-            } catch (Exception $e) {
-                $transaction->rollBack();
-                $this->addError('changeAudit', $e->getMessage());
-                return null;
-            }
-        } //审核通过
-        elseif ($this->auditStatus == 'true') {
-            foreach ($this->selected as $select) {
-                $model = UserMove::findOne(['ID' => $select]);
-                if ($model->AUDIT_STATUS > \Yii::$app->params['auditStatus']['un']['value']) continue;
-                $model->AUDIT_STATUS = \Yii::$app->params['auditStatus'][$this->auditStatus]['value'];
-                $model->AUDIT_ADMIN_ID = \Yii::$app->user->id;
-                $model->CREATE_REMARK = $this->remark;
-                $model->AUDIT_PERIOD_NUM = $period->getNowPeriodNum();
-                $model->AUDITED_AT = Date::nowTime();
-                if (!$model->save()) {
-                    throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-                }
-                $oneMove = UserMove::find()->select('UM.*, UMI.USER_NAME AS MOVE_USER_NAME, UTI.USER_NAME AS TO_USER_NAME')->from(UserMove::tableName() . ' AS UM')->join('LEFT JOIN', UserInfo::tableName() . ' AS UMI', 'UM.USER_ID=UMI.USER_ID')->join('LEFT JOIN', UserInfo::tableName() . ' AS UTI', 'UM.TO_UID=UTI.USER_ID')->where('UM.ID=:ID', [':ID' => $this->moveId])->asArray()->one();
-                if (!$oneMove) continue;
-                if ($oneMove['AUDIT_STATUS'] > 0) continue;
-                $this->moveUserName = $oneMove['MOVE_USER_NAME'];
-                $this->toConUserName = $oneMove['TO_USER_NAME'];
-                if ($oneMove['TYPE'] === UserMove::TYPE_NETWORK) {
-                    $this->type = NetPoint::NET_TYPE_NETWORK;
-                } elseif ($oneMove['TYPE'] === UserMove::TYPE_RELATION) {
-                    $this->type = NetPoint::NET_TYPE_RELATION;
-                }
-                $this->location = $oneMove['LOCATION'];
-                $this->moveWebToAsync();
-            }
-        } else {
-            $this->addError('audit', '错误的审核方式' . $this->auditStatus);
-        }
-        $this->adminOperateLogger->setIsBatch(true)->afterUpdate($this->selected,'ID')->clean()->save([
-            'optType' => '审核移网',
-            'remark' => $this->remark??'',
-        ]);
-        return true;
-    }
-
-
-    /**
-     * 拒绝审核
-     * @return null|static
-     * @throws \yii\db\Exception
-     */
-    /*public function reject() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            //todo 是否这么判断未审核的记录
-            if (!$model = UserMove::findOne(['ID' => $this->moveId, 'AUDIT_STATUS' => \Yii::$app->params['auditStatus']['un']['value']])) {
-                throw new Exception('移网记录不存在或已处理');
-            }
-            $model->AUDIT_ADMIN_ID = \Yii::$app->user->id;
-            $model->AUDIT_STATUS = \Yii::$app->params['auditStatus']['reject']['value'];
-            $model->AUDIT_REMARK = $this->remark;
-            $model->AUDITED_AT = Date::nowTime();
-            if (!$model->save()) {
-                throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError($e->getMessage());
-            return null;
-        }
-        return $model;
-    }*/
-
-    /**
-     * 审核移网
-     * @return null
-     */
-    /*public function moveAudit() {
-        $oneMove = UserMove::find()->select('UM.*, UMI.USER_NAME AS MOVE_USER_NAME, UTI.USER_NAME AS TO_USER_NAME')->from(UserMove::tableName() . ' AS UM')->join('LEFT JOIN', UserInfo::tableName() . ' AS UMI', 'UM.USER_ID=UMI.USER_ID')->join('LEFT JOIN', UserInfo::tableName() . ' AS UTI', 'UM.TO_UID=UTI.USER_ID')->where('UM.ID=:ID', [':ID' => $this->moveId])->asArray()->one();
-        if (!$oneMove) {
-            $this->addError('audit', '移网申请不存在');
-            return null;
-        }
-        if ($oneMove['AUDIT_STATUS'] > 0) {
-            $this->addError('audit', '已审核过,不能审核');
-            return null;
-        }
-        $this->moveUserName = $oneMove['MOVE_USER_NAME'];
-        $this->toConUserName = $oneMove['TO_USER_NAME'];
-        if ($oneMove['TYPE'] === UserMove::TYPE_NETWORK) {
-            $this->type = NetPoint::NET_TYPE_NETWORK;
-        } elseif ($oneMove['TYPE'] === UserMove::TYPE_RELATION) {
-            $this->type = NetPoint::NET_TYPE_RELATION;
-        }
-        $this->location = $oneMove['LOCATION'];
-        return $this->moveWebToAsync();
-    }*/
-
-    /**
-     * 页面端到异步的移网
-     * @return null
-     */
-    public function moveWebToAsync() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $period = Period::instance();
-        $moveModel = UserMove::findOne(['ID' => $this->moveId]);
-        if ($moveModel->IS_MOVING == 1) {
-            $this->addError('moveWebToAsync', '正在移动中请稍候');
-            return null;
-        }
-        $moveModel->IS_MOVING = 1;
-        $moveModel->AUDIT_ADMIN_ID = \Yii::$app->user->id;
-        $moveModel->CREATE_REMARK = $this->remark;
-        $moveModel->AUDIT_PERIOD_NUM = $period->getNowPeriodNum();
-        $moveModel->STARTED_AT = Date::nowTime();
-        $moveModel->AUDITED_AT = Date::nowTime();
-        if (!$moveModel->save()) {
-            $this->addError('scenario', Form::formatErrorsForApi($moveModel->getErrors()));
-            return null;
-        }
-        if ($moveModel->TYPE === NetPoint::NET_TYPE_NETWORK) {
-            $route = 'user/move-network';
-        } elseif ($moveModel->TYPE === NetPoint::NET_TYPE_RELATION) {
-            $route = 'user/move-relation';
-        } else {
-            $this->addError('scenario', '场景不存在');
-            return null;
-        }
-        // 异步处理添加任务
-        $params = [
-            'moveId' => $this->moveId,
-            'moveUserName' => $this->moveUserName,
-            'toConUserName' => $this->toConUserName,
-            'toConRealName' => $this->toConRealName,
-            'location' => $this->location,
-            'type' => $this->type,
-            'remark' => $this->remark,
-        ];
-        $taskKey = \Yii::$app->swooleAsyncTimer->asyncHandle($route, $params);
-        if ($taskKey === false) {
-            $this->errorHandle();
-            $this->addError('send', '请求失败');
-            return null;
-        }
-        return $moveModel;
-    }
-
-    /**
-     * 异步移网
-     * @return bool|null
-     * @throws \Exception
-     */
-    public function moveAsync() {
-        if (!$this->validate()) {
-            $this->errorHandle();
-            return false;
-        }
-        return $this->moveNet();
-    }
-
-    /**
-     * 移网
-     * @return bool
-     * @throws \Exception
-     */
-    public function moveNet() {
-        $netPoint = NetPoint::factory($this->moveId);
-        if ($this->type == NetPoint::NET_TYPE_NETWORK) {
-            $moveResult = $netPoint->moveNetworkPoint($this->_moveUserId, $this->_toConUserId, $this->location, $this->_fromLocation);
-        } elseif ($this->type == NetPoint::NET_TYPE_RELATION) {
-            $moveResult = $netPoint->moveRelationPoint($this->_moveUserId, $this->_toConUserId);
-        } else {
-            $this->addError('netType', '移网的网络类型错误');
-            unset($netPoint);
-            return null;
-        }
-        if ($moveResult) {
-            unset($netPoint, $moveResult);
-            return true;
-        } else {
-            $this->errorHandle();
-            $this->addErrors($netPoint->getErrors());
-            unset($netPoint, $moveResult);
-            return false;
-        }
-    }
-
-    public function errorHandle(){
-        // 把移网的审核状态回归
-        $oneMove = UserMove::findOne(['ID'=>$this->moveId]);
-        $oneMove->IS_MOVING = 0;
-        $oneMove->AUDIT_ADMIN_ID = null;
-        $oneMove->AUDITED_AT = 0;
-        $oneMove->AUDIT_STATUS = 0;
-        $oneMove->save();
-    }
-
-    /**
-     * 删除移网
-     * @param $selected
-     */
-    public function beforeDelete($selected) {
-        $this->adminOperateLogger->setIsBatch(true)->setOptObjField('USER_ID')->beforeDelete($selected, 'ID');
-    }
-
-    /**
-     * 删除
-     * @param $selected
-     * @throws Exception
-     */
-    public function delete($selected) {
-        $this->adminOperateLogger->clean()->save([
-            'optType' => '删除移网',
-        ]);
-    }
-}

+ 0 - 77
common/models/forms/OcrApiForm.php

@@ -1,77 +0,0 @@
-<?php
-namespace common\models\forms;
-
-use common\components\Model;
-use common\helpers\Date;
-use common\libs\logging\operate\AdminOperate;
-use common\models\OcrApi;
-use yii\helpers\Json;
-
-/**
- * Login form
- */
-class OcrApiForm extends Model
-{
-    public $id;
-    public $config;
-
-    public function init() {
-        parent::init();
-        $this->adminOperateLogger = new AdminOperate([
-            'fetchClass' => OcrApi::class,
-        ]);
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['id', 'config'], 'trim'],
-            [['id', 'config'], 'required'],
-            [['id'], 'exist', 'targetClass'=>OcrApi::class, 'targetAttribute'=>'ID'],
-        ];
-    }
-
-    /**
-     * 指定校验场景
-     * @return array
-     */
-    public function scenarios()
-    {
-        $parentScenarios =  parent::scenarios();
-        $customScenarios = [
-            'edit' => ['id', 'config']
-        ];
-        return array_merge($parentScenarios, $customScenarios);
-    }
-
-    /**
-     * 编辑
-     * @return null|static
-     */
-    public function edit(){
-        if(!$this->validate()){
-            return null;
-        }
-        $this->adminOperateLogger->saveBeforeContent = OcrApi::getConfigById($this->id);
-        if($this->scenario == 'edit') {
-            $model = OcrApi::findOne(['ID'=>$this->id]);
-            $model->UPDATE_ADMIN = \Yii::$app->user->id;
-            $model->UPDATED_AT = Date::nowTime();
-            $model->CONFIG = Json::encode($this->config);
-        } else {
-            $this->addError('edit', '提交场景不存在');
-            return null;
-        }
-        if(!$model->save()){$this->addErrors($model->getErrors());
-            return null;
-        }
-        $this->adminOperateLogger->saveAfterContent = OcrApi::getConfigById($this->id);
-        $this->adminOperateLogger->clean()->save([
-            'optType' => 'OcrApi配置成功',
-        ]);
-        return $model;
-    }
-}

+ 2 - 48
common/models/forms/OrderForm.php

@@ -220,37 +220,6 @@ class OrderForm extends Model
 
     }
 
-    /**
-     * 管理员发货
-     * @return Order|null
-     * @throws \yii\db\Exception
-     */
-    public function adminDelivery(){
-        if(!$this->validate()){
-            return null;
-        }
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            $period = Period::instance();
-            $this->_model->DELIVERY_STATUS = \Yii::$app->params['deliveryStatus']['delivered']['value'];
-            $this->_model->DELIVERY_PERIOD = $period->getNowPeriodNum();
-            $this->_model->DELIVERY_AT = Date::nowTime();
-            $this->_model->EXPRESS_COMPANY = $this->expressCompany;
-            $this->_model->ORDER_TRACK_NO = $this->orderTrackNo;
-            $this->_model->STATUS = \Yii::$app->params['orderStatus']['delivery']['value'];
-            if(!$this->_model->save()){
-                throw new Exception(Form::formatErrorsForApi($this->_model->getErrors()));
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('edit', $e->getMessage());
-            return null;
-        }
-        return $this->_model;
-    }
-
     /**
      * 复销
      * @return bool|null
@@ -273,19 +242,7 @@ class OrderForm extends Model
                     $realPrice = $goods['SELL_PRICE'] * $discount/100;
                     $realPv = $goods['PRICE_PV'] * $discount/100;
                     $totalAmount += $realPrice * intval($v);
-                    $totalPv += $realPv * intval($v);
-//                    if($this->payType=='cash') {
-//                        $discount = $goodsType[$goods['TYPE']]['discount'];
-//                        $realPrice = $goods['SELL_PRICE'] * $discount/100;
-//                        $realPv = $goods['PRICE_PV'] * $discount/100;
-//                        $totalAmount += $realPrice * intval($v);
-//                        $totalPv += $realPv * intval($v);
-//                    }else{
-//                        $realPrice = $goods['SELL_PRICE'];
-//                        $realPv = $goods['PRICE_PV'];
-//                        $totalAmount += $realPrice * intval($v);
-//                        $totalPv += $realPv * intval($v);
-//                    }
+                    $totalPv += $realPv * intval($v);                    
                     $this->_orderGoods[] = [
                         'GOODS_ID' => $goods['ID'],
                         'PRICE' => $goods['SELL_PRICE'],
@@ -333,9 +290,6 @@ class OrderForm extends Model
         return true;
     }
 
-    /**
-     * 复销订单
-     */
     public function addOrder(){
         $periodObj = Period::instance();
         $nowPeriodNum = $periodObj->getNowPeriodNum();
@@ -392,7 +346,7 @@ class OrderForm extends Model
         if($this->payType=='cash') {
             Cash::changeUserCash(\Yii::$app->user->id, 'CASH', -abs($this->_payAmount), ['REMARK' => '会员复销余额支付']);
         }else{
-            Balance::changeUserBonus(\Yii::$app->user->id,'reconsume_points', -abs($this->_payAmount),['DEAL_TYPE_ID' => DealType::RECONSUME_POINTS_EXCHANGE,'REMARK' => '会员复销积分兑换']);
+           
         }
         return $orderModel;
     }

+ 0 - 369
common/models/forms/PeriodForm.php

@@ -1,369 +0,0 @@
-<?php
-namespace common\models\forms;
-
-use common\helpers\bonus\BonusCalc;
-use common\helpers\bonus\BonusSend;
-use common\helpers\bonus\PerfCalc;
-use common\helpers\Cache;
-use common\helpers\Date;
-use common\components\Model;
-use common\helpers\Form;
-use common\models\Period;
-use common\models\UserWallet;
-use common\models\User;
-use common\models\UserStatusAudit;
-use common\models\Withdraw;
-use yii\base\Exception;
-
-/**
- * Login form
- */
-class PeriodForm extends Model
-{
-    public $periodNum;
-
-    private $_periodModel;
-    private $_limit = 1000;
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['periodNum'], 'trim'],
-            [['periodNum'], 'required'],
-            [['periodNum'], 'integer'],
-            [['periodNum'], 'isPeriod'],
-        ];
-    }
-
-    public function scenarios()
-    {
-        $parentScenarios =  parent::scenarios();
-        $customScenarios = [
-            'close' => ['periodNum'],
-            'perf' => ['periodNum'],
-            'calc' => ['periodNum'],
-            'send' => ['periodNum'],
-            'autoClose' => ['periodNum'],
-        ];
-        return array_merge($parentScenarios, $customScenarios);
-    }
-
-    public function attributeLabels()
-    {
-        return [
-            'periodNum' => '期数',
-        ];
-    }
-
-    public function isPeriod($attributes){
-        $periodObj = Period::instance();
-        $periodModel = Period::findOne(['PERIOD_NUM' => $this->periodNum]);
-        if(!$periodModel){
-            $this->addError($attributes, '所传期数不存在');
-        }
-        if($this->scenario == 'close') {
-            if(!$periodObj->isCanClose($this->periodNum)){
-                $this->addError($attributes, '所传期数不可封期');
-            }
-        }
-        elseif($this->scenario == 'perf') {
-            if(!$periodObj->isCanPerf($this->periodNum)){
-                $this->addError($attributes, '所传期数不可生成业绩单');
-            }
-        }
-        elseif($this->scenario == 'calc') {
-            if(!$periodObj->isCanCalc($this->periodNum)){
-                $this->addError($attributes, '所传期数不可结算');
-            }
-        }
-        elseif($this->scenario == 'send') {
-            if(!$periodObj->isCanSend($this->periodNum)){
-                $this->addError($attributes, '所传期数不可挂网');
-            }
-        }
-
-        $this->_periodModel = $periodModel;
-    }
-
-    /**
-     * 封期
-     * @return null
-     * @throws \yii\db\Exception
-     */
-    public function closePeriod(){
-        if(!$this->validate()){
-            return null;
-        }
-        $periodNum = $this->periodNum;
-        // 进行封期操作
-        $transaction = \Yii::$app->db->beginTransaction();
-        try {
-            $model = $this->_periodModel;
-            $model->IS_CLOSED = 1;
-            if(isset(\Yii::$app->user->id) && \Yii::$app->user->id){
-                $model->CLOSE_ADMIN_ID = \Yii::$app->user->id;
-            }
-            $model->CLOSED_AT = Date::nowTime();
-            if(!$model->save()){
-                throw new Exception('封期失败,请重试');
-            }
-
-            $settings = \Yii::$app->params['swooleAsyncTimer'];
-            $bonusSettings = \Yii::$app->params['swooleBonusConfig'];
-            $settings = array_merge($settings, $bonusSettings);
-            $taskKey = \Yii::$app->swooleAsyncTimer->asyncHandle('bonus/after-close', ['periodNum'=>$periodNum, 'closedAt'=>$model->CLOSED_AT], $settings);
-            if($taskKey === false){
-                $this->addError('send', '请求失败');
-                return null;
-            }
-
-            $transaction->commit();
-        } catch (Exception $e){
-            $transaction->rollBack();
-            $this->addError('close', $e->getMessage());
-            return null;
-        }
-
-        return $periodNum;
-    }
-
-    /**
-     * 自动封期
-     * @return null
-     * @throws \yii\db\Exception
-     */
-    public function autoClosePeriod(){
-        if(!$this->validate()){
-            return null;
-        }
-        $periodNum = $this->periodNum;
-        // 进行封期操作
-        $transaction = \Yii::$app->db->beginTransaction();
-        try {
-            $model = $this->_periodModel;
-            $model->IS_CLOSED = 1;
-            if(isset(\Yii::$app->user->id) && \Yii::$app->user->id){
-                $model->CLOSE_ADMIN_ID = \Yii::$app->user->id;
-            }
-            $model->CLOSED_AT = Date::nowTime();
-            if(!$model->save()){
-                throw new Exception('封期失败,请重试');
-            }
-
-            $transaction->commit();
-        } catch (Exception $e){
-            $transaction->rollBack();
-            $this->addError('close', $e->getMessage());
-            return null;
-        }
-
-        //封期后的操作(这句话放这里的目的是为了保障封期的时间不受其他后期工作的影响,封期之后再完成封期后的操作)
-        $this->afterCloseAsync($periodNum, $model->CLOSED_AT);
-
-        return $periodNum;
-    }
-
-    /**
-     * 给到期要加T的会员加T
-     * @param $periodNum
-     */
-    private function _periodChangeStatus($periodNum){
-        // 到期加T
-        $allAddTData = UserStatusAudit::find()->where('IS_PERIOD_ADD_T=1 AND ADD_T_PERIOD_NUM<=:NOW_PERIOD_NUM AND AUDIT_STATUS=:AUDIT_STATUS', [':NOW_PERIOD_NUM'=>$periodNum, ':AUDIT_STATUS'=>\Yii::$app->params['auditStatus']['true']['value']])->asArray()->all();
-        foreach($allAddTData as $data){
-            User::updateAll(['ID_CARD_PREFIX'=>'T'], 'ID=:ID', [':ID'=>$data['USER_ID']]);
-        }
-        // 到期开通
-        $allOpenData = UserStatusAudit::find()->where('IS_PERIOD_OPEN=1 AND OPEN_PERIOD_NUM<=:NOW_PERIOD_NUM AND AUDIT_STATUS=:AUDIT_STATUS', [':NOW_PERIOD_NUM'=>$periodNum, ':AUDIT_STATUS'=>\Yii::$app->params['auditStatus']['true']['value']])->asArray()->all();
-        foreach($allOpenData as $openData){
-            // 改变会员的状态 并取消身份证号加T,并设置首次开通标记
-            User::updateAll(['STATUS'=>$openData['STATUS_VALUE'], 'STATUS_AT'=>Date::nowTime(), 'ID_CARD_PREFIX'=>'', 'IS_FIRST_OPEN'=>1], 'ID=:ID', [':ID'=>$openData['USER_ID']]);
-            //从关停到开启
-            if ($openData['ORI_VALUE'] == UserStatusForm::STATUS_CLOSE) {
-                UserWallet::updateAll(['CLEAR_BY_CLOSED_AT' => 0], 'USER_ID=:USER_ID', [':USER_ID' => $openData['USER_ID']]);
-            }
-        }
-    }
-
-
-    /**
-     * 页面请求异步处理编辑
-     * @return string | null
-     */
-    public function calcWebToAsync(){
-        if(!$this->validate()){
-            return null;
-        }
-        // 把正在结算标记为真
-        $model = $this->_periodModel;
-        $model->IS_CALCING = 1;
-        $model->CALC_ADMIN_ID = \Yii::$app->user->id;
-        if(!$model->save()){
-            $this->addError('calc', Form::formatErrorsForApi($model->getErrors()));
-            return null;
-        }
-        // 异步处理添加任务
-        $settings = \Yii::$app->params['swooleAsyncTimer'];
-        $bonusSettings = \Yii::$app->params['swooleBonusConfig'];
-        $settings = array_merge($settings, $bonusSettings);
-        $taskKey = \Yii::$app->swooleAsyncTimer->asyncHandle('bonus/calc', \Yii::$app->request->get(), $settings);
-        if($taskKey === false){
-            $this->addError('send', '请求失败');
-            return null;
-        }
-        return $model;
-    }
-
-    /**
-     * 异步处理逻辑
-     * @param $handleUserId
-     * @return bool|null
-     * @throws Exception
-     * @throws \yii\db\Exception
-     */
-    public function calcAsync($handleUserId){
-        if(!$this->validate()){
-            return null;
-        }
-        $bonusCalc = BonusCalc::instance();
-        //$bonusCalc->init($this->periodNum, $handleUserId);
-        //$bonusCalc->setPeriodNum($this->periodNum);
-        $asyncResult = $bonusCalc->calcStep($this->periodNum, $handleUserId);
-        if($asyncResult){
-            $bonusCalc->endCalcTask();
-        } else {
-            $bonusCalc->errorCalcTask();
-            $this->addErrors($bonusCalc->getErrors());
-        }
-        return $asyncResult;
-    }
-
-    /**
-     * 页面请求异步处理生成业绩单
-     * @return string | null
-     */
-    public function perfWebToAsync(){
-        if(!$this->validate()){
-            return null;
-        }
-        // 把正在结算标记为真
-        $model = $this->_periodModel;
-        $model->IS_PERFING = 1;
-        $model->PERF_ADMIN_ID = \Yii::$app->user->id;
-        if(!$model->save()){
-            $this->addError('perf', Form::formatErrorsForApi($model->getErrors()));
-            return null;
-        }
-        // 异步处理添加任务
-        $settings = \Yii::$app->params['swooleAsyncTimer'];
-        $bonusSettings = \Yii::$app->params['swooleBonusConfig'];
-        $settings = array_merge($settings, $bonusSettings);
-        $taskKey = \Yii::$app->swooleAsyncTimer->asyncHandle('bonus/perf', \Yii::$app->request->get(), $settings);
-        if($taskKey === false){
-            $this->addError('perf', '请求失败');
-            return null;
-        }
-        return $model;
-    }
-
-    /**
-     * 异步处理逻辑
-     * @param $handleUserId
-     * @return bool|null
-     * @throws Exception
-     * @throws \yii\db\Exception
-     */
-    public function perfAsync($handleUserId){
-        if(!$this->validate()){
-            return null;
-        }
-        $bonusCalc = PerfCalc::instance();
-        //$bonusCalc->init($this->periodNum, $handleUserId);
-        //$bonusCalc->setPeriodNum($this->periodNum);
-        $asyncResult = $bonusCalc->calcStep($this->periodNum, $handleUserId);
-        if($asyncResult){
-            $bonusCalc->endCalcTask();
-        } else {
-            $bonusCalc->errorCalcTask();
-            $this->addErrors($bonusCalc->getErrors());
-        }
-        return $asyncResult;
-    }
-
-    /**
-     * 页面请求异步处理挂网
-     * @return string | null
-     */
-    public function sendWebToAsync(){
-        if(!$this->validate()){
-            return null;
-        }
-        // 把正在挂网标记设为真
-        $model = $this->_periodModel;
-        $model->IS_SENDING = 1;
-        $model->SENT_ADMIN_ID = \Yii::$app->user->id;
-        if(!$model->save()){
-            $this->addError('send', Form::formatErrorsForApi($model->getErrors()));
-            return null;
-        }
-        // 异步处理添加任务
-        $settings = \Yii::$app->params['swooleAsyncTimer'];
-        $bonusSettings = \Yii::$app->params['swooleBonusConfig'];
-        $settings = array_merge($settings, $bonusSettings);
-        $taskKey = \Yii::$app->swooleAsyncTimer->asyncHandle('bonus/send', \Yii::$app->request->get(), $settings);
-        if($taskKey === false){
-            $this->addError('send', '请求失败');
-            return null;
-        }
-        return $model;
-    }
-
-    /**
-     * 异步处理挂网逻辑
-     * @param $handleUserId
-     * @return bool|null
-     */
-    public function sendAsync($handleUserId){
-        if(!$this->validate()){
-            return null;
-        }
-        $bonusSend = BonusSend::instance();
-        $bonusSend->init($this->periodNum, $handleUserId);
-        $asyncResult = $bonusSend->sendStep();
-        if($asyncResult){
-            $bonusSend->endTask();
-        } else {
-            $bonusSend->errorTask();
-            $this->addErrors($bonusSend->getErrors());
-        }
-        return $asyncResult;
-    }
-
-    /**
-     * 异步处理封期后的操作
-     * @param $periodNum
-     * @return bool
-     * @throws \yii\db\Exception
-     */
-    public function afterCloseAsync($periodNum,$closedAt){
-        //如果自动结算
-//        if(boolval(Cache::getSystemConfig()['autoCalcPeriod']['VALUE'])){
-//            $period = Period::instance();
-//            if($period->isLastSent($periodNum)) {
-//                $bonusCalc = PerfCalc::instance();
-//                $asyncResult = $bonusCalc->calcStep($periodNum);
-//                if ($asyncResult) {
-//                    $bonusCalc->endCalcTask();
-//                } else {
-//                    $bonusCalc->errorCalcTask();
-//                    $this->addErrors($bonusCalc->getErrors());
-//                }
-//                return $asyncResult;
-//            }
-//        }
-    }
-
-}

+ 0 - 290
common/models/forms/RechargeForm.php

@@ -1,290 +0,0 @@
-<?php
-
-namespace common\models\forms;
-
-use common\components\Model;
-use common\helpers\Cache;
-use common\helpers\Date;
-use common\helpers\Form;
-use common\helpers\Tool;
-use common\helpers\user\Cash;
-use common\helpers\user\Info;
-use common\models\Recharge;
-use common\models\UserInfo;
-use yii\base\Exception;
-
-/**
- * Login form
- */
-class RechargeForm extends Model {
-    public $selectedIds;
-    public $auditStatus;
-    public $createRemark;
-
-    public $userName;
-    public $applyAmount;
-    public $openBank;
-    public $bankAddress;
-    public $bankNo;
-//    public $bankProvince;
-//    public $bankCity;
-//    public $bankCounty;
-
-    public $sn;
-    public $amount;
-    public $bankRealName;
-
-    private $_userId;
-
-    /**
-     * @inheritdoc
-     */
-    public function rules() {
-        return [
-            [['userName', 'idCard', 'applyAmount', 'auditStatus', 'remark', 'selectedIds', 'sn','amount', 'bankRealName', 'bankNo'], 'trim'],
-            [['selectedIds', 'auditStatus', 'userName','applyAmount','openBank','bankNo','bankAddress'], 'required'],
-            [['selectedIds'], 'exist', 'targetClass' => Recharge::class, 'targetAttribute' => 'ID', 'message' => '充值申请不存在'],
-            [['userName'], 'exist', 'targetClass' => UserInfo::class, 'targetAttribute' => 'USER_NAME', 'message' => '会员不存在'],
-            [['applyAmount'], 'price'],
-            [['applyAmount'], 'isApplyAmount'],
-            [['selectedIds'], 'isSelected'],
-            //[['sn'], 'isSn'],
-        ];
-    }
-
-    /**
-     * 指定场景
-     * @return array
-     */
-    public function scenarios() {
-        $parentScenarios = parent::scenarios();
-        $customScenarios = [
-            'addByAdmin' => ['userName', 'applyAmount'],
-            'addByUser' => ['applyAmount','openBank','bankNo','bankAddress'],
-            'statusByAdmin' => ['selectedIds', 'auditStatus', 'createRemark'],
-        ];
-        return array_merge($parentScenarios, $customScenarios);
-    }
-
-    /**
-     * @return array
-     */
-    public function attributeLabels() {
-        return [
-            'selectedIds' => '充值申请ID',
-            'userName' => '会员编号',
-            'applyAmount' => '申请充值的金额',
-            'openBank' => '汇款银行',
-            'bankNo' => '汇款账号',
-            'bankAddress' => '银行支行',
-//            'bankProvince' => '银行省',
-//            'bankCity' => '银行市',
-//            'bankCounty' => '银行县',
-        ];
-    }
-
-    /**
-     * 校验申请金额是否小于当前余额并符合配置中的设置
-     * @param $attribute
-     * @return bool
-     */
-    public function isApplyAmount($attribute) {
-        if ($this->applyAmount <= 0) {
-            $this->addError('scenario', '充值金额必须大于0');
-        }
-        if ((int)($this->applyAmount)!=$this->applyAmount) {
-            $this->addError('scenario', '充值金额必须是整数');
-        }
-        if ($this->scenario == 'addByUser') {
-            $this->_userId = \Yii::$app->user->id;
-        } elseif ($this->scenario == 'addByAdmin') {
-            $userInfo = UserInfo::findOneAsArray(['USER_NAME' => $this->userName]);
-            if (!$userInfo) {
-                $this->addError('scenario', $this->userName . '会员不存在');
-            }else{
-                $this->_userId = $userInfo['USER_ID'];
-            }
-        } else {
-            $this->addError($attribute, '场景不存在');
-            return false;
-        }
-    }
-
-    /**
-     * 批量数据
-     * @param $attributes
-     */
-    public function isSelected($attributes) {
-        if (!$this->selectedIds) {
-            $this->addError($attributes, '必须选择一条数据');
-        }
-//        if (!is_array($this->selectedIds)) {
-//            $this->selectedIds = [$this->selectedIds];
-//        }
-    }
-
-    /**
-     * 判断信息是否一致
-     * @param $attribute
-     * @throws Exception
-     */
-    public function isSn($attribute) {
-        $sn = $this->sn;
-        if (!$oneWithdraw = Recharge::findOneAsArray('SN=:SN AND AUDIT_STATUS=:AUDIT_STATUS', [':SN' => $sn, ':AUDIT_STATUS' => Recharge::STATUS_AUDITED])) {
-            $this->addError($attribute, '不存在充值流水号为' . $sn . '的已审核记录');
-        }
-        if ($oneWithdraw) {
-            $info = Info::baseInfo($oneWithdraw['USER_ID']);
-            if ($this->userName != $info['USER_NAME']) {
-                $this->addError($attribute, 'Excel中充值流水号' . $sn . '的用户名' . $this->userName . '与系统中的信息【' . $info['USER_NAME'] . '】不一致');
-            }
-            if ($this->amount != $oneWithdraw['AMOUNT']) {
-                $this->addError($attribute, 'Excel中充值流水号' . $sn . '的充值金额' . $this->amount . '与系统中的信息【' . $oneWithdraw['AMOUNT'] . '】不一致');
-            }
-            if ($this->bankRealName != $oneWithdraw['REAL_NAME']) {
-                $this->addError($attribute, 'Excel中充值流水号' . $sn . '的实时开户名' . $this->bankRealName . '与系统中的信息【' . $oneWithdraw['REAL_NAME'] . '】不一致');
-            }
-            if ($this->bankNo != $oneWithdraw['BANK_NO']) {
-                $this->addError($attribute, 'Excel中充值流水号' . $sn . '的实时银行账户' . $this->bankNo . '与系统中的信息【' . $oneWithdraw['BANK_NO'] . '】不一致');
-            }
-        }
-    }
-
-    /**
-     * 管理员充值
-     * @return null|string
-     * @throws \yii\db\Exception
-     */
-    public function recharge() {
-        if (!$this->validate()) {
-            return false;
-        }
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            Cash::changeUserCash($this->_userId, 'CASH', $this->applyAmount, ['REMARK' => '后台管理员充值']);
-
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('add', $e->getMessage());
-            return false;
-        }
-        return true;
-    }
-
-
-    /**
-     * 添加充值申请
-     * @return null|string
-     * @throws \yii\db\Exception
-     */
-    public function add() {
-        if (!$this->validate()) {
-            return false;
-        }
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            $nowTime = Date::nowTime();
-            $period = Recharge::getPeriod($nowTime);
-            //增加记录
-            $userInfo = Info::baseInfo($this->_userId);
-
-            $rechargeModel = new Recharge();
-            $rechargeModel->SN = $this->_generateSn();
-            $rechargeModel->USER_ID = $this->_userId;
-            $rechargeModel->REAL_NAME = Info::getUserRealNameByUserId($this->_userId);
-            $rechargeModel->ID_CARD = $userInfo['ID_CARD'];
-            $rechargeModel->RECHARGE_PERIOD_NUM = $period['nowPeriodNum'];
-            $rechargeModel->RECHARGE_YEAR = $period['nowYear'];
-            $rechargeModel->RECHARGE_MONTH = $period['nowMonth'];
-            $rechargeModel->AMOUNT = $this->applyAmount;
-            $rechargeModel->OPEN_BANK = $this->openBank;
-            $rechargeModel->BANK_ADDRESS = $this->bankAddress;
-            $rechargeModel->BANK_NO = $this->bankNo;
-//            $rechargeModel->BANK_PROVINCE = $this->bankProvince ?? 0;
-//            $rechargeModel->BANK_CITY = $this->bankCity ?? 0;
-//            $rechargeModel->BANK_COUNTY = $this->bankCounty ?? 0;
-            $rechargeModel->P_MONTH = Date::ociToDate($period['yearMonth'], Date::OCI_TIME_FORMAT_SHORT_MONTH);
-            $rechargeModel->AUDIT_STATUS = Recharge::STATUS_APPLIED;
-            $rechargeModel->CREATED_AT = $nowTime;
-            if (!$rechargeModel->save()) {
-                throw new Exception(Form::formatErrorsForApi($rechargeModel->getErrors()));
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('add', $e->getMessage());
-            return false;
-        }
-        return $rechargeModel;
-    }
-
-    /**
-     * 生成流水号
-     * @return string
-     */
-    private function _generateSn() {
-        return 'CZ' . Date::today('Ymd') . $this->_random(10, 1);
-    }
-
-    /**
-     * 生成随机数
-     *
-     * @param $length
-     * @param int $numeric
-     * @return string
-     */
-    private function _random($length, $numeric = 0) {
-        $seed = base_convert(md5(microtime() . $_SERVER['DOCUMENT_ROOT']), 16, $numeric ? 10 : 35);
-        $seed = $numeric ? (str_replace('0', '', $seed) . '012340567890') : ($seed . 'zZ' . strtoupper($seed));
-        $hash = '';
-        $max = strlen($seed) - 1;
-        for ($i = 0; $i < $length; $i++) {
-            $hash .= $seed{mt_rand(0, $max)};
-        }
-        return $hash;
-    }
-
-    /**
-     * 设置充值订单的状态
-     * @return null|static
-     * @throws \yii\db\Exception
-     */
-    public function changeStatus() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $logs = [];
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            $oneRecharge = Recharge::findOne(['ID' => $this->selectedIds]);
-            //判断状态
-            if (($msg = Recharge::chkAuditStatus($oneRecharge->SN, $oneRecharge->AUDIT_STATUS, $this->auditStatus)) != '') {
-                throw new Exception($msg);
-            }
-            //待审核->已审核 修改会员现金钱包
-            if ($this->auditStatus == Recharge::STATUS_AUDITED) {
-                Cash::changeUserCash($oneRecharge->USER_ID, 'CASH', abs($oneRecharge->AMOUNT), ['REMARK' => '会员充值申请审核']);
-            }
-            $oneRecharge->REMARK = $this->createRemark ?? '';
-            $oneRecharge->AUDIT_ADMIN = \Yii::$app->user->id;
-            $oneRecharge->AUDIT_STATUS = $this->auditStatus;
-            $oneRecharge->AUDITED_AT = Date::nowTime();
-            if (!$oneRecharge->save()) {
-                throw new Exception(Form::formatErrorsForApi($oneRecharge->getErrors()));
-            }
-            $logs[$this->selectedIds] = $oneRecharge->SN;
-
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('auditStatus', $e->getMessage());
-            return null;
-        }
-        return ['logs' => $logs, 'status' => $this->auditStatus];
-    }
-
-}

+ 0 - 520
common/models/forms/ReconsumeForm.php

@@ -1,520 +0,0 @@
-<?php
-
-namespace common\models\forms;
-
-use backendApi\modules\v1\models\Admin;
-use common\helpers\Cache;
-use common\helpers\Date;
-use common\components\Model;
-use common\helpers\Form;
-use common\helpers\user\Reconsume;
-use common\helpers\user\Info;
-use common\helpers\Validator;
-use common\libs\logging\operate\AdminOperate;
-use common\models\PerfMonth;
-use common\models\Period;
-use common\models\ReconsumeAudit;
-use common\models\ReconsumePool;
-use common\models\ReconsumePoolFlow;
-use common\models\UserInfo;
-use yii\base\Exception;
-use yii\validators\NumberValidator;
-
-/**
- * Login form
- */
-class ReconsumeForm extends Model {
-    public $id;
-    public $selected;
-    public $userName;
-    public $type;
-    public $changeAmount;
-    public $remark;
-    public $auditStatus;
-    public $calcYearMonth;
-    public $isPass;
-    public $isShow;
-
-    private $_model;
-    private $_userId;
-
-    const TYPE_BALANCE = 0;     // 变动余额
-    const TYPE_MONTH = 1;       // 变动月份
-
-    public function init() {
-        parent::init();
-        $this->adminOperateLogger = new AdminOperate([
-            'fetchClass' => ReconsumePool::class,
-        ]);
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules() {
-        return [
-            [['id', 'selected', 'userName', 'type', 'changeAmount', 'remark', 'auditStatus', 'calcYearMonth', 'isShow'], 'trim'],
-            [['id', 'userName', 'type', 'changeAmount', 'remark', 'auditStatus', 'calcYearMonth'], 'required'],
-            [['id'], 'exist', 'targetClass' => ReconsumeAudit::class, 'targetAttribute' => 'ID'],
-            [['id'], 'initModel'],
-            [['userName'], 'exist', 'targetClass' => UserInfo::class, 'targetAttribute' => 'USER_NAME'],
-            [['userName'], 'isUserName'],
-            [['calcYearMonth'], 'yearMonth'],
-            [['type'], 'isType'],
-            [['auditStatus'], 'isAuditStatus'],
-            [['selected'], 'isSelected'],
-            [['changeAmount'], 'isChangeAmount'],
-            [['calcYearMonth'], 'isCanDeduct'],
-        ];
-    }
-
-    public function attributeLabels() {
-        return [
-            'userName' => '会员编号',
-            'type' => '变动类型',
-            'changeAmount' => '变动数',
-            'remark' => '备注',
-            'auditStatus' => '审核状态',
-            'isShow' => '前台显示备注',
-            'calcYearMonth' => '结算年月',
-        ];
-    }
-
-    /**
-     * 指定校验场景
-     * @return array
-     */
-    public function scenarios() {
-        $parentScenarios = parent::scenarios();
-        $customScenarios = [
-            'changeAdd' => ['userName', 'type', 'changeAmount', 'remark', 'isShow'],
-            'changeAudit' => ['selected', 'remark', 'auditStatus'],
-            'edit' => ['id', 'type', 'changeAmount', 'remark', 'isShow'],
-            'pass' => ['id', 'type', 'changeAmount', 'remark', 'isShow'],
-            'deductReConsume' => ['userName', 'remark', 'isPass'],
-            'deductReConsumeAdd' => ['userName', 'calcYearMonth'],
-            'deductReConsumeAudit' => ['id', 'remark', 'isShow', 'auditStatus'],
-        ];
-        return array_merge($parentScenarios, $customScenarios);
-    }
-
-    /**
-     * 初始化广告model类
-     * @param $attribute
-     */
-    public function initModel($attribute) {
-        $model = $this->_model = ReconsumeAudit::findOne(['ID' => $this->id]);
-        $this->_userId = $model->USER_ID;
-        if ($model->AUDIT_STATUS > \Yii::$app->params['auditStatus']['un']['value']) {
-            $this->addError($attribute, '该申请已经被审核,不能重复审核');
-        }
-    }
-
-    /**
-     * 校验用户名
-     * @param $attribute
-     */
-    public function isUserName($attribute) {
-        // 如果该用户存在待审核状态的数据,如果有,则提示管理员先处理待审核的数据
-        $this->_userId = Info::getUserIdByUserName($this->userName);
-        /*$userId = $this->_userInfo['USER_ID'];
-        $type = '';
-        if ($this->scenario == 'changeAdd') {
-            $type = ReconsumeAudit::TYPE_CHANGE;
-        } elseif ($this->scenario == 'deductReConsumeAdd') {
-            $type = ReconsumeAudit::TYPE_RECONSUME;
-        }
-        if (ReconsumeAudit::find()->where('USER_ID=:USER_ID AND AUDIT_STATUS=:AUDIT_STATUS AND TYPE=:TYPE', [':USER_ID' => $userId, ':AUDIT_STATUS' => \Yii::$app->params['auditStatus']['un']['value'], ':TYPE' => $type])->exists()) {
-            $this->addError($attribute, '该会员存在一条待审核的记录,请等待待审核数据处理完毕');
-        }*/
-    }
-
-    /**
-     * 校验类型
-     * @param $attribute
-     */
-    public function isType($attribute) {
-        if (!in_array($this->type, [self::TYPE_BALANCE, self::TYPE_MONTH])) {
-            $this->addError($attribute, '调整类型错误');
-        }
-    }
-
-    /**
-     * 审核状态是否正确
-     * @param $attributes
-     */
-    public function isAuditStatus($attributes) {
-        if (!array_key_exists($this->auditStatus, \Yii::$app->params['auditStatus'])) {
-            $this->addError($attributes, '无效的审核状态');
-        }
-    }
-
-    /**
-     * 批量数据
-     * @param $attributes
-     */
-    public function isSelected($attributes) {
-        if (!$this->selected) {
-            $this->addError($attributes, '必须选择一条数据');
-        }
-        if (!is_array($this->selected)) {
-            $this->selected = [$this->selected];
-        }
-    }
-
-    /**
-     * 变动内容
-     * @param $attribute
-     * @throws \yii\db\Exception
-     */
-    public function isChangeAmount($attribute) {
-        if ($this->changeAmount == 0) {
-            $this->addError($attribute, '调整值不能等于0');
-        }
-        $reConsumePool = Reconsume::getUserReconsumePool($this->_userId);
-        if ($this->type == self::TYPE_BALANCE) {
-            if (!Validator::validateQuickLy('fullPrice', $this->changeAmount)) {
-                $this->addError($this->changeAmount, '调整金额不正确');
-            }
-            if(($reConsumePool['unusedPV']+$this->changeAmount)<0){
-                $this->addError($this->changeAmount, '可用余额不足');
-            }
-        } elseif ($this->type == self::TYPE_MONTH) {
-            $validator = Validator::createValidator(NumberValidator::class, $this, [['changeAmount'], 'integer']);
-            $this->validators->append($validator);
-            if(($reConsumePool['unusedMonth']+$this->changeAmount)<0){
-                $this->addError($this->changeAmount, '可用月数不足');
-            }
-        }
-    }
-
-    /**
-     * 是否能扣除复销
-     * @param $attribute
-     * @throws \yii\db\Exception
-     */
-    public function isCanDeduct($attribute) {
-
-        $userId = Info::getUserIdByUserName($this->userName);
-        if (!Reconsume::isCanDeduct($userId, $this->calcYearMonth)) {
-            $this->addError($attribute, '会员已合格不能再次扣除');
-        }
-        //未来的结算年和月不能手动扣除,即未结算的结算月不能扣除
-        if($periodPoint = Period::getPeriodPointFromMonth(substr($this->calcYearMonth, 0, 4), intval(substr($this->calcYearMonth, 4, 2)))){
-            if(boolval($periodPoint['IS_CALCULATED'] != Period::CALCULATE_FINISH)){
-                $this->addError($attribute, '所选结算月未结算不能扣除');
-            }
-        }
-    }
-
-    /**
-     * 添加申请
-     * @return ReconsumeAudit|null
-     * @throws \yii\db\Exception
-     */
-    public function changeAdd() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            $model = new ReconsumeAudit();
-            $model->CREATED_AT = Date::nowTime();
-            $model->USER_ID = Info::getUserIdByUserName($this->userName);
-            if ($this->type == self::TYPE_BALANCE) {
-                $model->CHANGE_PV = $this->changeAmount;
-            } elseif ($this->type == self::TYPE_MONTH) {
-                $model->CHANGE_MONTH = $this->changeAmount;
-            }
-            $model->TYPE = $this->type;//190715调整余额的类型
-            $model->CREATE_ADMIN = \Yii::$app->user->id;
-            $model->CREATE_REMARK = $this->remark;
-            $model->REMARK_IS_SHOW = $this->isShow;
-            if (!$model->save()) {
-                throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('changeAdd', $e->getMessage());
-            return null;
-        }
-        $this->adminOperateLogger->fetchClass= ReconsumeAudit::class;
-        $this->adminOperateLogger->afterInsert($model)->clean()->save([
-            'optType' => '申请调整复销池余额',
-            'userId' => $model->USER_ID,
-            'userName' => Info::getUserNameByUserId($model->USER_ID),
-            'remark' => $this->remark
-        ]);
-        return $model;
-    }
-
-    /**
-     * 修改信息
-     * @return null
-     * @throws \yii\db\Exception
-     */
-    public function edit() {
-        //取消编辑功能
-        return null;
-        if (!$this->validate()) {
-            return null;
-        }
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            $model = $this->_model;
-            if ($this->type == self::TYPE_BALANCE) {
-                $model->CHANGE_PV = $this->changeAmount;
-                $model->CHANGE_MONTH = 0;
-            } elseif ($this->type == self::TYPE_MONTH) {
-                $model->CHANGE_MONTH = $this->changeAmount;
-                $model->CHANGE_PV = 0;
-            }
-            $model->REMARK_IS_SHOW = $this->isShow;
-            $model->CREATE_REMARK = $this->remark;
-            if (!$model->save()) {
-                throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('edit', $e->getMessage());
-            return null;
-        }
-        return $model;
-    }
-
-    /**
-     * 审核通过
-     * @return null
-     * @throws \yii\db\Exception
-     */
-    public function pass() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $this->adminOperateLogger->beforeUpdate(ReconsumePool::findOne(['USER_ID'=>$this->_userId]));
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            $model = $this->_model;
-            if ($this->type == self::TYPE_BALANCE) {
-                $model->CHANGE_PV = $this->changeAmount;
-                $model->CHANGE_MONTH = 0;
-            } elseif ($this->type == self::TYPE_MONTH) {
-                $model->CHANGE_MONTH = $this->changeAmount;
-                $model->CHANGE_PV = 0;
-            }
-            $model->AUDIT_STATUS = \Yii::$app->params['auditStatus']['true']['value'];
-            $model->AUDIT_ADMIN = \Yii::$app->user->id;
-            $model->CREATE_REMARK = $this->remark;
-            $model->REMARK_IS_SHOW = $this->isShow;
-            $model->AUDITED_AT = Date::nowTime();
-            if (!$model->save()) {
-                throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-            }
-            // 查看该条记录中变化的是PV还是月数
-            if ($model->CHANGE_PV != 0) {
-                Reconsume::changePoolPV($model->USER_ID, $model->CHANGE_PV, [
-                    'DEAL_TYPE' => Reconsume::TYPE_AUDIT_PV,
-                    'REMARK' => $model->CREATE_REMARK,
-                    'REMARK_IS_SHOW' => $this->isShow,
-                    'ADMIN_NAME'=>Admin::getAdminNameById(\Yii::$app->user->id),
-                ]);
-            }
-            if ($model->CHANGE_MONTH != 0) {
-                Reconsume::changePoolMonthNum($model->USER_ID, $model->CHANGE_MONTH, ['DEAL_TYPE' => Reconsume::TYPE_AUDIT_MONTH, 'REMARK' => $model->CREATE_REMARK,'REMARK_IS_SHOW' => $this->isShow, 'ADMIN_NAME'=>Admin::getAdminNameById(\Yii::$app->user->id)]);
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('pass', $e->getMessage());
-            return null;
-        }
-        $this->adminOperateLogger->afterUpdate(ReconsumePool::findOne(['USER_ID'=>$this->_userId]))->clean()->save([
-            'optType' => '审核通过调整复销池余额',
-            'userId' => $model->USER_ID,
-            'userName' => Info::getUserNameByUserId($model->USER_ID),
-            'remark' => $this->remark
-        ]);
-        return $model;
-    }
-
-    /**
-     * 审核余额变动
-     * @return null
-     * @throws \yii\db\Exception
-     */
-    public function changeAudit() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $uids=[];
-        if($this->auditStatus=='true'){
-            foreach ($this->selected as $select) {
-                $oneBalanceAudit = ReconsumeAudit::findOneAsArray('ID=:ID',[':ID'=>$select],'USER_ID');
-                $uids[]=$oneBalanceAudit['USER_ID'];
-            }
-        }
-        if($this->auditStatus=='true'){
-            $this->adminOperateLogger->setIsBatch(true)->beforeUpdate($uids, 'USER_ID');
-        }else{
-            $this->adminOperateLogger->fetchClass = ReconsumeAudit::class;
-            $this->adminOperateLogger->setIsBatch(true)->beforeUpdate($this->selected, 'ID');
-        }
-        $model = new ReconsumeAudit();
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            foreach ($this->selected as $select) {
-                $model = ReconsumeAudit::findOne(['ID' => $select]);
-                if ($model->AUDIT_STATUS > \Yii::$app->params['auditStatus']['un']['value']) continue;
-                $model->AUDIT_STATUS = \Yii::$app->params['auditStatus'][$this->auditStatus]['value'];
-                $model->AUDIT_ADMIN = \Yii::$app->user->id;
-                $model->CREATE_REMARK = $this->remark;
-                $model->AUDITED_AT = Date::nowTime();
-                if (!$model->save()) {
-                    throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-                }
-                if ($model->AUDIT_STATUS == \Yii::$app->params['auditStatus']['true']['value']) {
-                    // 查看该条记录中变化的是PV还是月数
-                    if ($model->CHANGE_PV != 0) {
-                        Reconsume::changePoolPV($model->USER_ID, $model->CHANGE_PV, [
-                            'DEAL_TYPE' => Reconsume::TYPE_AUDIT_PV,
-                            'REMARK' => $model->CREATE_REMARK,
-                            'ADMIN_NAME'=>Admin::getAdminNameById(\Yii::$app->user->id)
-                        ]);
-                    }
-                    if ($model->CHANGE_MONTH != 0) {
-                        Reconsume::changePoolMonthNum($model->USER_ID, $model->CHANGE_MONTH, ['DEAL_TYPE' => Reconsume::TYPE_AUDIT_MONTH, 'REMARK' => $model->CREATE_REMARK, 'ADMIN_NAME'=>Admin::getAdminNameById(\Yii::$app->user->id)]);
-                    }
-                }
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('changeAudit', $e->getMessage());
-            return null;
-        }
-        if($this->auditStatus=='true'){
-            $this->adminOperateLogger->fetchClass = ReconsumePool::class;
-            $this->adminOperateLogger->setIsBatch(true)->afterUpdate($uids, 'USER_ID')->clean()->save([
-                'optType' => '批量审核调整复销池余额',
-                'remark' => $this->remark,
-            ]);
-        }else{
-            $this->adminOperateLogger->fetchClass = ReconsumeAudit::class;
-            $this->adminOperateLogger->setIsBatch(true)->afterUpdate($this->selected, 'ID')->clean()->save([
-                'optType' => '批量拒绝调整复销池余额',
-                'remark' => $this->remark,
-            ]);
-        }
-        return count($this->selected) == 1 ? $model : true;
-    }
-
-    /**
-     * 扣除复销(当月是否合格)
-     * @return null
-     * @throws \yii\db\Exception
-     */
-    public function deductReConsume() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            $userId = $this->_userId;
-            $period = Period::instance();
-            $yearMonth = $period->getNowYearMonth();
-            $periodNum = $period->getNowPeriodNum();
-            $lastYearMonth = $period->getLastMonth($periodNum);
-            $lastYearMonth = $lastYearMonth['yearMonth'];
-            if (!Reconsume::isCanDeduct($userId, $yearMonth)) {
-                throw new Exception('该月不能扣除复销');
-            }
-            if (Reconsume::isCanGetBonus($userId, $yearMonth)) {
-                throw new Exception('该月已有获奖资格,不能扣除');
-            }
-            $isPassText = $this->isPass ? '合格' : '不合格';
-            $remark = $this->remark ? $this->remark : '手动扣除本月复销并设置为' . $isPassText;
-            // 扣除复销
-            $sysConfig = Cache::getSystemConfig();
-            if (!Reconsume::deductFxByCalcMonth($userId, $yearMonth, ['DEAL_TYPE' => Reconsume::TYPE_MANUAL, 'REMARK' => $remark])) {
-                throw new Exception('复销扣除失败,请检查会员复销余额是否充足');
-            }
-            if ($this->isPass) {
-                // 把月业绩表中对应的该会员上个月的复销状态设置
-                PerfMonth::updateAll(['FX_STATUS' => 1], 'USER_ID=:USER_ID AND CALC_MONTH=:CALC_MONTH', [':USER_ID' => $userId, ':CALC_MONTH' => $lastYearMonth]);
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('deductReConsume', $e->getMessage());
-            return null;
-        }
-        return $this->_userId;
-    }
-
-    /**
-     * 审核扣除复销
-     * @return null
-     * @throws \yii\db\Exception
-     */
-    public function deductReConsumeAudit() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            $model = $this->_model;
-            $model->AUDIT_STATUS = \Yii::$app->params['auditStatus'][$this->auditStatus]['value'];
-            $model->AUDIT_ADMIN = \Yii::$app->user->id;
-            $model->CREATE_REMARK = $this->remark;
-            $model->AUDITED_AT = Date::nowTime();
-            if (!$model->save()) {
-                throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-            }
-            if ($model->AUDIT_STATUS == \Yii::$app->params['auditStatus']['true']['value']) {
-                if (!Reconsume::isCanDeduct($model->USER_ID, $model->CALC_MONTH)) {
-                    throw new Exception('该月不能扣除复销');
-                }
-                // 查看该条记录中变化的是PV还是月数
-                $sysConfig = Cache::getSystemConfig();
-                if (!Reconsume::deductFxByCalcMonth($model->USER_ID, $model->CALC_MONTH, ['DEAL_TYPE' => Reconsume::TYPE_MANUAL, 'REMARK' => $model->CREATE_REMARK, 'ADMIN_NAME'=>Admin::getAdminNameById(\Yii::$app->user->id)])) {
-                    throw new Exception('复销扣除失败,请检查会员复销余额是否充足');
-                }
-                // 把月业绩表中对应的该会员您的复销状态设置
-                PerfMonth::updateAll(['FX_STATUS' => 1], 'USER_ID=:USER_ID AND CALC_MONTH=:CALC_MONTH', [':USER_ID' => $model->USER_ID, ':CALC_MONTH' => $model->CALC_MONTH]);
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('changeAudit', $e->getMessage());
-            return null;
-        }
-        return $model;
-    }
-
-    /**
-     * 删除前
-     * @param $selected
-     */
-    public function beforeDelete($selected) {
-        $this->adminOperateLogger->fetchClass = ReconsumeAudit::class;
-        $this->adminOperateLogger->setIsBatch(true)->beforeDelete($selected, 'ID');
-    }
-    /**
-     * 删除
-     * @param $selected
-     * @throws Exception
-     */
-    public function delete($selected) {
-        $this->adminOperateLogger->clean()->save([
-            'optType' => '删除调整复销池余额待审核数据',
-        ]);
-    }
-}

+ 0 - 485
common/models/forms/RegInfoAuditForm.php

@@ -1,485 +0,0 @@
-<?php
-
-namespace common\models\forms;
-
-use common\helpers\Date;
-use common\helpers\user\Info;
-use common\helpers\user\Status;
-use common\components\Model;
-use common\helpers\Form;
-use common\models\CompanyBank;
-use common\models\Period;
-use common\models\RegInfoAudit;
-use common\models\RegType;
-use common\models\User;
-use common\models\UserInfo;
-use yii\base\Exception;
-
-/**
- * 注册信息表单
- */
-class RegInfoAuditForm extends Model {
-    public $id;
-    public $userId;
-    public $userName;
-    public $realName;
-    public $idCard;
-    public $type;
-    public $regName;
-    public $creditCode;
-    public $premises;
-    public $legalPerson;
-    public $regExpires;
-    public $createRemark;
-    public $auditRemark;
-    public $auditStatus;
-    public $companyBank;
-    public $openName;
-    public $openBank;
-    public $bankAddress;
-    public $bankNo;
-    public $bankAreaSelected;
-
-    private $_uid;
-    private $_model;
-
-    /**
-     * @inheritdoc
-     */
-    public function rules() {
-        return [
-            [['id', 'userId', 'userName', 'realName', 'idCard', 'type', 'regName', 'creditCode', 'premises', 'legalPerson', 'regExpires', 'createRemark', 'auditRemark', 'auditStatus', 'companyBank', 'openName', 'openBank', 'bankAddress', 'bankNo', 'bankAreaSelected'], 'trim'],
-            [['id', 'userName', 'realName', 'idCard', 'type', 'regName', 'creditCode', 'auditStatus'], 'required'],
-            [['userName'], 'isUserName'],
-            [['id'], 'initModel'],
-            [['auditStatus'], 'isAuditStatus'],
-            [['type'], 'isType'],
-        ];
-    }
-
-    /**
-     * 指定校验场景
-     * @return array
-     */
-    public function scenarios() {
-        $parentScenarios = parent::scenarios();
-        $customScenarios = [
-            'add' => ['userName', 'realName', 'idCard', 'type', 'regName', 'creditCode', 'premises', 'legalPerson', 'regExpires', 'createRemark', 'companyBank'],
-            'excelAdd' => ['userName', 'realName', 'idCard', 'type', 'regName', 'creditCode', 'premises', 'legalPerson', 'regExpires', 'createRemark', 'openName', 'openBank', 'bankAddress', 'bankNo', 'bankAreaSelected'],
-            'editRegInfo' => ['userId', 'type', 'regName', 'creditCode', 'premises', 'legalPerson', 'regExpires', 'createRemark', 'companyBank'],
-            'edit' => ['id', 'type', 'regName', 'creditCode', 'premises', 'legalPerson', 'regExpires', 'createRemark', 'companyBank'],
-            'audit' => ['id', 'type', 'regName', 'creditCode', 'premises', 'legalPerson', 'regExpires', 'createRemark', 'auditStatus', 'companyBank'],
-        ];
-        return array_merge($parentScenarios, $customScenarios);
-    }
-
-    public function attributeLabels() {
-        return [
-            'userId' => '会员ID',
-            'userName' => '会员编号',
-            'realName' => '会员姓名',
-            'idCard' => '身份证号',
-            'type' => '注册类型',
-            'regName' => '注册名称',
-            'creditCode' => '统一社会信用代码',
-            'premises' => '经营场所',
-            'legalPerson' => '经营者/法人',
-            'regExpires' => '注册有效期',
-            'createRemark' => '创建备注',
-            'auditRemark' => '审核备注',
-            'auditStatus' => '审核状态',
-        ];
-    }
-
-    /**
-     * 初始化model
-     * @param $attributes
-     */
-    public function initModel($attributes) {
-        $this->_model = RegInfoAudit::findOne(['ID' => $this->id]);
-        if (!$this->_model) {
-            $this->addError($attributes, '数据不存在');
-        }
-        if ($this->_model->AUDIT_STATUS != \Yii::$app->params['auditStatus']['un']['value']) {
-            $this->addError($attributes, '本数据已经被处理过了');
-        }
-    }
-
-    /**
-     * 用户名是否正确
-     * @param $attributes
-     */
-    public function isUserName($attributes) {
-        $userInfo = UserInfo::findOneAsArray(['USER_NAME' => $this->userName]);
-        if ($userInfo) {
-            $baseInfo = Info::baseInfoZh($userInfo['USER_ID']);
-            if ($baseInfo['REAL_NAME'] != $this->realName || $baseInfo['ID_CARD'] != $this->idCard) {
-                $this->addError($attributes, '输入的会员姓名或身份证号与系统不一致');
-            }
-            if (RegInfoAudit::find()->where('USER_ID=:USER_ID AND AUDIT_STATUS=0', [':USER_ID' => $userInfo['USER_ID']])->exists()) {
-                $this->addError($attributes, '填写的会员有待审核的注册信息');
-            }
-            $this->_uid = $userInfo['USER_ID'];
-        } else {
-            $this->addError($attributes, '会员不存在');
-        }
-
-    }
-
-    /**
-     * 注册类型检测
-     * @param $attributes
-     */
-    public function isType($attributes) {
-        $type = RegType::findOneAsArray('ID=:ID', [':ID' => $this->type], 'ID');
-        if ($type) {
-            //暂写死
-            if ($type['ID'] == '758BF69C25C3422AA7743936BC77EE64') {
-                if($this->scenario=='excelAdd'){
-                    if ($this->openName == '' || $this->openBank == '' || $this->bankAddress == '' || $this->bankNo == '' || $this->bankAreaSelected == []) {
-                        $this->addError($attributes, '请完善公司银行信息');
-                    }
-                }else {
-                    if ($this->companyBank['openBank'] == '' || $this->companyBank['bankAreaSelected'] == [] || $this->companyBank['bankAddress'] == '' || $this->companyBank['openName'] == '' || $this->companyBank['bankNo'] == '') {
-                        $this->addError($attributes, '请完善公司银行信息');
-                    }
-                }
-            }
-        } else {
-            $this->addError($attributes, '错误的注册类型');
-        }
-    }
-
-    /**
-     * 审核状态是否正确
-     * @param $attributes
-     */
-    public function isAuditStatus($attributes) {
-        if (!array_key_exists($this->auditStatus, \Yii::$app->params['auditStatus'])) {
-            $this->addError($attributes, '无效的审核状态');
-        }
-    }
-
-    /**
-     * 添加
-     * @return RegInfoAudit|null
-     * @throws \yii\db\Exception
-     */
-    public function add() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $transaction = \Yii::$app->db->beginTransaction();
-        try {
-            $period = Period::instance();
-            // 添加会员注册信息
-            $model = new RegInfoAudit();
-            $model->USER_ID = $this->_uid;
-            $model->REG_TYPE = $this->type;
-            $model->REG_NAME = $this->regName;
-            $model->CREDIT_CODE = $this->creditCode;
-            $model->PREMISES = $this->premises;
-            $model->LEGAL_PERSON = $this->legalPerson;
-            $model->REG_EXPIRES = $this->regExpires ? Date::utcToTime($this->regExpires) : 0;
-            $model->AUDIT_STATUS = \Yii::$app->params['auditStatus']['un']['value'];
-            $model->CREATE_ADMIN = \Yii::$app->user->id;
-            $model->CREATE_REMARK = $this->createRemark;
-            $model->CREATE_PERIOD = $period->getNowPeriodNum();
-            $model->CREATED_AT = Date::nowTime();
-            if (!$model->save()) {
-                throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-            }
-            //暂写死
-            if ($this->type == '758BF69C25C3422AA7743936BC77EE64') {
-                if (!CompanyBank::find()->where('USER_ID=:USER_ID', [':USER_ID' => $this->_uid])->exists()) {
-                    $companyBank = new CompanyBank();
-                    $companyBank->USER_ID = $this->_uid;
-                    $companyBank->CREATE_ADMIN = \Yii::$app->user->id;
-                    $companyBank->CREATED_AT = Date::nowTime();
-                } else {
-                    $companyBank = CompanyBank::findOne(['USER_ID' => $this->_uid]);
-                    $companyBank->UPDATE_ADMIN = \Yii::$app->user->id;
-                    $companyBank->UPDATED_AT = Date::nowTime();
-                }
-                $companyBank->OPEN_NAME = $this->companyBank['openName'];
-                $companyBank->OPEN_BANK = $this->companyBank['openBank'];
-                $companyBank->BANK_ADDRESS = $this->companyBank['bankAddress'];
-                $companyBank->BANK_NO = $this->companyBank['bankNo'];
-                $companyBank->BANK_PROVINCE = $this->companyBank['bankAreaSelected'][0] ?? '0';
-                $companyBank->BANK_CITY = $this->companyBank['bankAreaSelected'][1] ?? '0';
-                $companyBank->BANK_COUNTY = $this->companyBank['bankAreaSelected'][2] ?? '0';
-                $companyBank->REMARK = $this->createRemark;
-                if (!$companyBank->save()) {
-                    throw new Exception(Form::formatErrorsForApi($companyBank->getErrors()));
-                }
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('add', $e->getMessage());
-            return null;
-        }
-        return $model;
-    }
-
-    /**
-     * 批量导入注册信息
-     * @return RegInfoAudit|null
-     * @throws \yii\db\Exception
-     */
-    public function excelAdd() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $transaction = \Yii::$app->db->beginTransaction();
-        try {
-            $period = Period::instance();
-            // 添加会员注册信息
-            $model = new RegInfoAudit();
-            $model->USER_ID = $this->_uid;
-            $model->REG_TYPE = $this->type;
-            $model->REG_NAME = $this->regName;
-            $model->CREDIT_CODE = $this->creditCode;
-            $model->PREMISES = $this->premises;
-            $model->LEGAL_PERSON = $this->legalPerson;
-            $model->REG_EXPIRES = $this->regExpires ? Date::utcToTime($this->regExpires) : 0;
-            $model->AUDIT_STATUS = \Yii::$app->params['auditStatus']['un']['value'];
-            $model->CREATE_ADMIN = \Yii::$app->user->id;
-            $model->CREATE_REMARK = $this->createRemark;
-            $model->CREATE_PERIOD = $period->getNowPeriodNum();
-            $model->CREATED_AT = Date::nowTime();
-            if (!$model->save()) {
-                throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-            }
-            //暂写死
-            if ($this->type == '758BF69C25C3422AA7743936BC77EE64') {
-                if (!CompanyBank::find()->where('USER_ID=:USER_ID', [':USER_ID' => $this->_uid])->exists()) {
-                    $companyBank = new CompanyBank();
-                    $companyBank->USER_ID = $this->_uid;
-                    $companyBank->CREATE_ADMIN = \Yii::$app->user->id;
-                    $companyBank->CREATED_AT = Date::nowTime();
-                } else {
-                    $companyBank = CompanyBank::findOne(['USER_ID' => $this->_uid]);
-                    $companyBank->UPDATE_ADMIN = \Yii::$app->user->id;
-                    $companyBank->UPDATED_AT = Date::nowTime();
-                }
-                $companyBank->OPEN_NAME = $this->openName;
-                $companyBank->OPEN_BANK = $this->openBank;
-                $companyBank->BANK_ADDRESS = $this->bankAddress;
-                $companyBank->BANK_NO = $this->bankNo;
-                $companyBank->BANK_PROVINCE = $this->bankAreaSelected[0] ?? '0';
-                $companyBank->BANK_CITY = $this->bankAreaSelected[1] ?? '0';
-                $companyBank->BANK_COUNTY = $this->bankAreaSelected[2] ?? '0';
-                $companyBank->REMARK = $this->createRemark;
-                if (!$companyBank->save()) {
-                    throw new Exception(Form::formatErrorsForApi($companyBank->getErrors()));
-                }
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('excelAdd', $e->getMessage());
-            return null;
-        }
-        return $model;
-    }
-
-    /**
-     * 注册信息管理中提交修改注册信息
-     * @return RegInfoAudit|null
-     * @throws \yii\db\Exception
-     */
-    public function editRegInfo() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $transaction = \Yii::$app->db->beginTransaction();
-        try {
-            $period = Period::instance();
-            // 添加会员注册信息
-            $model = new RegInfoAudit();
-            $model->USER_ID = $this->userId;
-            $model->REG_TYPE = $this->type;
-            $model->REG_NAME = $this->regName;
-            $model->CREDIT_CODE = $this->creditCode;
-            $model->PREMISES = $this->premises;
-            $model->LEGAL_PERSON = $this->legalPerson;
-            $model->REG_EXPIRES = $this->regExpires ? Date::utcToTime($this->regExpires) : 0;
-            $model->AUDIT_STATUS = \Yii::$app->params['auditStatus']['un']['value'];
-            $model->CREATE_ADMIN = \Yii::$app->user->id;
-            $model->CREATE_REMARK = $this->createRemark;
-            $model->CREATE_PERIOD = $period->getNowPeriodNum();
-            $model->CREATED_AT = Date::nowTime();
-            if (!$model->save()) {
-                throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-            }
-            //暂写死
-            if ($this->type == '758BF69C25C3422AA7743936BC77EE64') {
-                if (!CompanyBank::find()->where('USER_ID=:USER_ID', [':USER_ID' => $this->userId])->exists()) {
-                    $companyBank = new CompanyBank();
-                    $companyBank->USER_ID = $this->userId;
-                    $companyBank->CREATE_ADMIN = \Yii::$app->user->id;
-                    $companyBank->CREATED_AT = Date::nowTime();
-                } else {
-                    $companyBank = CompanyBank::findOne(['USER_ID' => $this->userId]);
-                    $companyBank->UPDATE_ADMIN = \Yii::$app->user->id;
-                    $companyBank->UPDATED_AT = Date::nowTime();
-                }
-                $companyBank->OPEN_NAME = $this->companyBank['openName'];
-                $companyBank->OPEN_BANK = $this->companyBank['openBank'];
-                $companyBank->BANK_ADDRESS = $this->companyBank['bankAddress'];
-                $companyBank->BANK_NO = $this->companyBank['bankNo'];
-                $companyBank->BANK_PROVINCE = $this->companyBank['bankAreaSelected'][0] ?? '0';
-                $companyBank->BANK_CITY = $this->companyBank['bankAreaSelected'][1] ?? '0';
-                $companyBank->BANK_COUNTY = $this->companyBank['bankAreaSelected'][2] ?? '0';
-                $companyBank->REMARK = $this->createRemark;
-                if (!$companyBank->save()) {
-                    throw new Exception(Form::formatErrorsForApi($companyBank->getErrors()));
-                }
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('add', $e->getMessage());
-            return null;
-        }
-        return $model;
-    }
-
-    /**
-     * 修改操作
-     * @return null
-     * @throws \yii\db\Exception
-     */
-    public function edit() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $transaction = \Yii::$app->db->beginTransaction();
-        try {
-            $model = $this->_model;
-            $model->REG_TYPE = $this->type;
-            $model->REG_NAME = $this->regName;
-            $model->CREDIT_CODE = $this->creditCode;
-            $model->PREMISES = $this->premises;
-            $model->LEGAL_PERSON = $this->legalPerson;
-            $model->REG_EXPIRES = $this->regExpires ? Date::utcToTime($this->regExpires) : 0;
-            if (!$model->save()) {
-                throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-            }
-            //暂写死
-            if ($this->type == '758BF69C25C3422AA7743936BC77EE64') {
-                if (!CompanyBank::find()->where('USER_ID=:USER_ID', [':USER_ID' => $model->USER_ID])->exists()) {
-                    $companyBank = new CompanyBank();
-                    $companyBank->USER_ID = $model->USER_ID;
-                    $companyBank->CREATE_ADMIN = \Yii::$app->user->id;
-                    $companyBank->CREATED_AT = Date::nowTime();
-                } else {
-                    $companyBank = CompanyBank::findOne(['USER_ID' => $model->USER_ID]);
-                    $companyBank->UPDATE_ADMIN = \Yii::$app->user->id;
-                    $companyBank->UPDATED_AT = Date::nowTime();
-                }
-                $companyBank->OPEN_NAME = $this->companyBank['openName'];
-                $companyBank->OPEN_BANK = $this->companyBank['openBank'];
-                $companyBank->BANK_ADDRESS = $this->companyBank['bankAddress'];
-                $companyBank->BANK_NO = $this->companyBank['bankNo'];
-                $companyBank->BANK_PROVINCE = $this->companyBank['bankAreaSelected'][0] ?? '0';
-                $companyBank->BANK_CITY = $this->companyBank['bankAreaSelected'][1] ?? '0';
-                $companyBank->BANK_COUNTY = $this->companyBank['bankAreaSelected'][2] ?? '0';
-                $companyBank->REMARK = $this->createRemark;
-                if (!$companyBank->save()) {
-                    throw new Exception(Form::formatErrorsForApi($companyBank->getErrors()));
-                }
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('edit', $e->getMessage());
-            return null;
-        }
-        return $model;
-    }
-
-    /**
-     * 审核操作
-     * @return null
-     * @throws \yii\db\Exception
-     */
-    public function audit() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $transaction = \Yii::$app->db->beginTransaction();
-        try {
-            $period = Period::instance();
-            $model = $this->_model;
-            if ($this->auditStatus == 'reject') {
-                $model->AUDIT_STATUS = \Yii::$app->params['auditStatus']['reject']['value'];
-            } elseif ($this->auditStatus == 'true') {
-                $model->AUDIT_STATUS = \Yii::$app->params['auditStatus']['true']['value'];
-                $model->REG_TYPE = $this->type;
-                $model->REG_NAME = $this->regName;
-                $model->CREDIT_CODE = $this->creditCode;
-                $model->PREMISES = $this->premises;
-                $model->LEGAL_PERSON = $this->legalPerson;
-                $model->REG_EXPIRES = $this->regExpires ? Date::utcToTime($this->regExpires) : 0;
-            }
-            $model->AUDIT_ADMIN = \Yii::$app->user->id;
-            $model->CREATE_REMARK = $this->createRemark;
-            $model->AUDIT_PERIOD = $period->getNowPeriodNum();
-            $model->AUDITED_AT = Date::nowTime();
-            if (!$model->save()) {
-                throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-            }
-            //暂写死
-            if ($this->type == '758BF69C25C3422AA7743936BC77EE64') {
-                if (!CompanyBank::find()->where('USER_ID=:USER_ID', [':USER_ID' => $model->USER_ID])->exists()) {
-                    $companyBank = new CompanyBank();
-                    $companyBank->USER_ID = $model->USER_ID;
-                    $companyBank->CREATE_ADMIN = \Yii::$app->user->id;
-                    $companyBank->CREATED_AT = Date::nowTime();
-                    $companyBank->UPDATED_AT = Date::nowTime();
-                } else {
-                    $companyBank = CompanyBank::findOne(['USER_ID' => $model->USER_ID]);
-                    $companyBank->UPDATE_ADMIN = \Yii::$app->user->id;
-                    $companyBank->UPDATED_AT = Date::nowTime();
-                }
-                $companyBank->OPEN_NAME = $this->companyBank['openName'];
-                $companyBank->OPEN_BANK = $this->companyBank['openBank'];
-                $companyBank->BANK_ADDRESS = $this->companyBank['bankAddress'];
-                $companyBank->BANK_NO = $this->companyBank['bankNo'];
-                $companyBank->BANK_PROVINCE = $this->companyBank['bankAreaSelected'][0] ?? '0';
-                $companyBank->BANK_CITY = $this->companyBank['bankAreaSelected'][1] ?? '0';
-                $companyBank->BANK_COUNTY = $this->companyBank['bankAreaSelected'][2] ?? '0';
-                $companyBank->REMARK = $this->createRemark;
-                if (!$companyBank->save()) {
-                    throw new Exception(Form::formatErrorsForApi($companyBank->getErrors()));
-                }
-            }
-            //写入会员信息
-            if ($this->auditStatus == 'true') {
-                $baseInfo = Info::baseInfoZh($model->USER_ID);
-                //更改了注册类型
-                if ($baseInfo['REG_TYPE'] != $model->REG_TYPE) {
-                    UserInfo::updateAll(['REG_TYPE' => $model->REG_TYPE, 'SHOULD_REG_TYPE' => $model->REG_TYPE, 'REG_NAME' => $model->REG_NAME, 'CREDIT_CODE' => $model->CREDIT_CODE, 'PREMISES' => $model->PREMISES, 'LEGAL_PERSON' => $model->LEGAL_PERSON, 'REG_EXPIRES' => $model->REG_EXPIRES], 'USER_ID=:USER_ID', [':USER_ID' => $model->USER_ID]);
-                } else {
-                    UserInfo::updateAll(['REG_NAME' => $model->REG_NAME, 'REG_TYPE' => $model->REG_TYPE, 'CREDIT_CODE' => $model->CREDIT_CODE, 'PREMISES' => $model->PREMISES, 'LEGAL_PERSON' => $model->LEGAL_PERSON, 'REG_EXPIRES' => $model->REG_EXPIRES], 'USER_ID=:USER_ID', [':USER_ID' => $model->USER_ID]);
-                }
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('audit', $e->getMessage());
-            return null;
-        }
-        return $model;
-    }
-
-    /**
-     * 删除
-     * @param $selected
-     * @throws Exception
-     */
-    public static function delete($selected) {
-    }
-}

+ 0 - 104
common/models/forms/RegTypeForm.php

@@ -1,104 +0,0 @@
-<?php
-
-namespace common\models\forms;
-
-use backendApi\modules\v1\models\Admin;
-use common\components\Model;
-use common\helpers\Date;
-use common\models\RegType;
-
-/**
- * Login form
- */
-class RegTypeForm extends Model {
-    public $id;
-    public $typeName;          // 类型名称
-    public $isPact;        // 是否协议
-    public $monthAmount;       // 月提现
-    public $yearAmount;            // 年提现
-    public $remark;               // 备注
-
-    private $_model;
-
-    /**
-     * @inheritdoc
-     */
-    public function rules() {
-        return [
-            [['id', 'typeName', 'isPact', 'monthAmount', 'yearAmount', 'remark'], 'trim'],
-            [['id', 'isPact', 'monthAmount', 'yearAmount'], 'required'],
-            [['id'], 'initModel'],
-            [['isPact'], 'isPact'],
-        ];
-    }
-
-    /**
-     * 指定校验场景
-     * @return array
-     */
-    public function scenarios() {
-        $parentScenarios = parent::scenarios();
-        $customScenarios = [
-            'edit' => ['id', 'isPact', 'monthAmount', 'yearAmount', 'remark'],
-        ];
-        return array_merge($parentScenarios, $customScenarios);
-    }
-
-    public function attributeLabels() {
-        return [
-            'typeName' => '会员编号',
-            'isPact' => '是否启用注册协议',
-            'monthAmount' => '达到月提现金额更改应注册类型',
-            'yearAmount' => '达到年提现金额更改应注册类型',
-            'remark' => '备注',
-        ];
-    }
-
-    /**
-     * 初始化model
-     * @param $attributes
-     */
-    public function initModel($attributes) {
-        $this->_model = RegType::findOne(['ID' => $this->id]);
-        if (!$this->_model) {
-            $this->addError($attributes, '数据不存在');
-        }
-    }
-
-    /**
-     * 是否开启协议判断
-     * @param $attributes
-     */
-    public function isPact($attributes) {
-        if (!in_array($this->isPact, [0, 1])) {
-            $this->addError($attributes, '错误的是否开启协议');
-        }
-    }
-
-    /**
-     * 编辑
-     */
-    public function edit() {
-        if (!$this->validate()) {
-            return null;
-        }
-        if ($this->scenario == 'edit') {
-            $model = RegType::findOne(['ID' => $this->id]);
-            $model->IS_PACT = $this->isPact;
-            $model->MONTH_LIMIT_AMOUNT = $this->monthAmount;
-            $model->YEAR_LIMIT_AMOUNT = $this->yearAmount;
-            $model->REMARK = $this->remark;
-            $model->UPDATE_ADMIN = Admin::getAdminNameById(\Yii::$app->user->id);
-            $model->UPDATED_AT = Date::nowTime();
-        } else {
-            $this->addError('id', '提交场景不存在');
-            return null;
-        }
-        if ($model->save()) {
-            return $model;
-        } else {
-            $this->addErrors($model->getErrors());
-            return null;
-        }
-    }
-}

+ 0 - 367
common/models/forms/ResendQYForm.php

@@ -1,367 +0,0 @@
-<?php
-
-namespace common\models\forms;
-
-use common\helpers\Date;
-use common\components\Model;
-use common\helpers\Form;
-use common\helpers\Tool;
-use common\helpers\user\Balance;
-use common\helpers\user\Reconsume;
-use common\helpers\user\Info;
-use common\helpers\user\Status;
-use common\libs\logging\operate\AdminOperate;
-use common\models\Ad;
-use common\models\CalcBonus;
-use common\models\DealType;
-use common\models\PerfMonth;
-use common\models\Period;
-use common\models\ReconsumePool;
-use common\models\ReconsumePoolFlow;
-use common\models\ResendQY;
-use common\models\ResendQYAudit;
-use common\models\UserBonus;
-use common\models\UserInfo;
-use common\models\UserTeamwork;
-use yii\base\Exception;
-
-/**
- * Login form
- */
-class ResendQYForm extends Model {
-    public $id;
-    public $selectedIds;
-    public $userName;
-    public $periodNum;
-    public $remark;
-    public $auditStatus;
-
-    private $_model;
-    private $_userId;
-    private $_calcBonus;
-
-    public function init() {
-        parent::init();
-        $this->adminOperateLogger = new AdminOperate([
-            'fetchClass' => ResendQY::class,
-        ]);
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules() {
-        return [
-            [['id', 'userName', 'periodNum', 'remark', 'auditStatus', 'selectedIds'], 'trim'],
-            [['id', 'userName', 'periodNum', 'auditStatus'], 'required'],
-            ['id', 'initModel'],
-            ['userName', 'isUser'],
-            ['periodNum', 'isCanResend'],
-            ['auditStatus', 'isAuditStatus'],
-            [['selectedIds'], 'isSelected'],
-        ];
-    }
-
-    public function attributeLabels() {
-        return [
-            'userName' => '用户名',
-            'periodNum' => '期数',
-            'remark' => '备注',
-            'auditStatus' => '审核状态',
-        ];
-    }
-
-    /**
-     * 指定校验场景
-     * @return array
-     */
-    public function scenarios() {
-        $parentScenarios = parent::scenarios();
-        $customScenarios = [
-            'apply' => ['selectedIds', 'remark'],
-            'audit' => ['selectedIds', 'remark', 'auditStatus'],
-        ];
-        return array_merge($parentScenarios, $customScenarios);
-    }
-
-    /**
-     * 检查记录是否存在并初始化model
-     * @param $attribute
-     * @throws \yii\db\Exception
-     */
-    public function initModel($attribute) {
-        $model = ResendQY::findOne(['ID' => $this->id]);
-        if ($model) {
-            $this->_model = $model;
-            $period = Period::instance();
-            $yearMonth = $period->getYearMonth($model->PERIOD_NUM);
-            if (!$this->_calcBonus = CalcBonus::find()->yearMonth($yearMonth)->where('USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM AND BONUS_QY<=0 AND SHOULD_QY>0 AND IS_SENT=1', [':USER_ID' => $model->USER_ID, ':PERIOD_NUM' => $model->PERIOD_NUM])->one()) {
-                $this->addError($attribute, '该会员暂无可补发区域津贴');
-            }
-        } else {
-            $this->addError($attribute, '该数据不存在');
-        }
-
-    }
-
-    /**
-     * 会员是否存在
-     * @param $attribute
-     */
-    public function isUser($attribute) {
-        if (!$this->_userId = Info::getUserIdByUserName($this->userName)) {
-            $this->addError($attribute, '会员不存在');
-        }
-    }
-
-    /**
-     * 是否能补发
-     * @param $attribute
-     * @throws \yii\db\Exception
-     */
-    public function isCanResend($attribute) {
-        $period = Period::instance();
-        $yearMonth = $period->getYearMonth($this->periodNum);
-        // 查看会员对应的期数奖金结算表中是否有应发金额>0和实发金额=0
-        $this->_calcBonus = CalcBonus::find()->yearMonth($yearMonth)->where('USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM AND BONUS_QY<=0 AND SHOULD_QY>0 AND IS_SENT=1', [':USER_ID' => $this->_userId, ':PERIOD_NUM' => $this->periodNum])->asArray()->one();
-        if (!$this->_calcBonus) {
-            $this->addError($attribute, '该会员暂无可补发区域津贴');
-        }
-        // 如果有的话,再看看有没有补发记录,如果有补发记录则也不能补发
-        if (ResendQY::find()->where('USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM AND (AUDIT_STATUS=:AUDIT_STATUS_UN OR AUDIT_STATUS=:AUDIT_STATUS_TRUE)', [':USER_ID' => $this->_userId, ':PERIOD_NUM' => $this->periodNum,':AUDIT_STATUS_UN'=>\Yii::$app->params['auditStatus']['un']['value'], ':AUDIT_STATUS_TRUE'=>\Yii::$app->params['auditStatus']['true']['value']])->exists()) {
-            $this->addError($attribute, '该会员已经补发或申请补发指定期数的区域津贴');
-        }
-    }
-
-    /**
-     * 校验审核状态
-     * @param $attributes
-     */
-    public function isAuditStatus($attributes) {
-        if (!array_key_exists($this->auditStatus, \Yii::$app->params['auditStatus'])) {
-            $this->addError($attributes, '无效的审核状态');
-        }
-    }
-
-    /**
-     * 批量数据
-     * @param $attributes
-     */
-    public function isSelected($attributes) {
-        if (!$this->selectedIds) {
-            $this->addError($attributes, '必须选择一条数据');
-        }
-        if (!is_array($this->selectedIds)) {
-            $this->selectedIds = [$this->selectedIds];
-        }
-        if($this->scenario == 'apply') {
-            $this->selectedIds = array_unique($this->selectedIds);
-            //根据会员状态及审核状态筛选
-            foreach ($this->selectedIds as $key => $value) {
-                //有了复销活跃资格才能补发
-                if($resendQY = ResendQY::findOneAsArray('ID=:ID',[':ID'=>$value],'USER_ID,CALC_MONTH')){
-                    if(!ReconsumePoolFlow::find()->yearMonth($resendQY['CALC_MONTH'])->select('USER_ID')->where('USER_ID=:USER_ID AND CALC_MONTH=:CALC_MONTH AND IS_FX_DEDUCT=1', [':USER_ID' => $resendQY['USER_ID'], ':CALC_MONTH' => $resendQY['CALC_MONTH']])->exists()){
-                        unset($this->selectedIds[$key]);
-                    }
-                }else{
-                    unset($this->selectedIds[$key]);
-                }
-                //去掉已存在的待审核申请
-                if (ResendQYAudit::find()->where('RESEND_ID=:RESEND_ID AND AUDIT_STATUS =:AUDIT_STATUS', [':RESEND_ID' => $value, ':AUDIT_STATUS' => \Yii::$app->params['auditStatus']['un']['value']])->exists()) {
-                    unset($this->selectedIds[$key]);
-                }
-                //实发为0,应发大于0
-                if (!ResendQY::find()->where('ID=:ID AND BONUS_QY=0 AND SHOULD_QY>0', [':ID' => $value])->exists()) {
-                    unset($this->selectedIds[$key]);
-                }
-            }
-            $this->selectedIds = array_values($this->selectedIds);
-        }
-    }
-
-
-    /**
-     * 添加
-     * @return array|null
-     * @throws \yii\db\Exception
-     */
-    public function apply() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $logs = [];
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            if ($this->selectedIds) {
-                foreach ($this->selectedIds as $select) {
-                    $resend = ResendQY::findOneAsArray('ID=:ID', [':ID' => $select], 'USER_ID,SHOULD_QY,PERIOD_NUM');
-                    //是否已挂网
-                    $period = Period::instance();
-                    //if (!$period->isSent($resend['PERIOD_NUM'])) continue;
-                    //会员本月是否复销
-                    //if (!Status::fxGetBonusStatusByPeriodNum($resend['USER_ID'], $resend['PERIOD_NUM'])) continue;
-                    $resendAudit = new ResendQYAudit();
-                    $resendAudit->USER_ID = $resend['USER_ID'];
-                    $resendAudit->RESEND_ID = $select;
-                    $resendAudit->SHOULD_BONUS = $resend['SHOULD_QY'];
-                    $resendAudit->RESEND_BONUS = 0;
-                    $resendAudit->PERIOD_NUM = $resend['PERIOD_NUM'];
-                    $resendAudit->AUDIT_STATUS = \Yii::$app->params['auditStatus']['un']['value'];
-                    $resendAudit->RESEND_ADMIN_ID = \Yii::$app->user->id;
-                    $resendAudit->RESEND_REMARK = $this->remark;
-                    $resendAudit->CREATED_AT = Date::nowTime();
-                    if (!$resendAudit->save()) {
-                        throw new Exception(Form::formatErrorsForApi($resendAudit->getErrors()));
-                    }
-                    if (!ResendQY::updateAll(['RESEND_AUDIT_ID' => $resendAudit->ID, 'RESEND_AUDIT_STATUS' => \Yii::$app->params['auditStatus']['un']['value'], 'RESEND_STATUS' => ResendQY::STATUS_HAS], 'ID=:ID', [':ID' => $select])) {
-                        throw new Exception('更新申请状态失败');
-                    }
-                    $logs[] = $resend['USER_ID'];
-                }
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('apply', $e->getMessage());
-            return null;
-        }
-        if ($this->selectedIds) {
-            $this->adminOperateLogger->setIsBatch(true)->afterUpdate($this->selectedIds, 'ID')->setOptObjField('USER_ID')->clean()->save([
-                'optType' => '申请补发区域津贴',
-                'remark' => $this->remark,
-            ]);
-        }
-        return ['logs' => $logs];
-    }
-
-    /**
-     * 审核补发区域津贴
-     * @return null
-     * @throws \yii\db\Exception
-     */
-    public function audit() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $logs = [];
-        $ids = [];
-        foreach ($this->selectedIds as $key => $select) {
-            $resendId = ResendQYAudit::findOneAsArray('ID=:ID', [':ID' => $select], 'RESEND_ID');
-            $ids[] = $resendId['RESEND_ID'];
-        }
-        if($ids) {
-            $this->adminOperateLogger->setIsBatch(true)->beforeUpdate($ids, 'ID');
-        }
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            foreach ($this->selectedIds as $key=>$select) {
-                $model=ResendQYAudit::findOne(['ID'=>$select]);
-                $model->AUDIT_STATUS = \Yii::$app->params['auditStatus'][$this->auditStatus]['value'];
-                $model->RESEND_REMARK = $this->remark?$this->remark:$model->RESEND_REMARK;
-                $model->AUDIT_ADMIN_ID = \Yii::$app->user->id;
-                $model->AUDITED_AT = Date::nowTime();
-                if ($this->auditStatus == 'true') {
-                    Balance::changeUserBonus($model->USER_ID, 'bonus', $model->SHOULD_BONUS, [
-                        'REMARK' => '补发' . $model->PERIOD_NUM . '期薪资',
-                        'PERIOD_NUM' => $model->PERIOD_NUM,
-                        'QY' => $model->SHOULD_BONUS,
-                        'DEAL_TYPE_ID' => DealType::RESEND,
-                        'SORT' => $key * 10
-                    ]);
-                    //更新计算奖金
-                    $period = Period::instance();
-                    $yearMonth = $period->getYearMonth($model->PERIOD_NUM);
-                    if($calcBonusModel = CalcBonus::find()->where('USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM AND BONUS_QY<=0 AND SHOULD_QY>0 AND IS_SENT=1', [':USER_ID' => $model->USER_ID, ':PERIOD_NUM' => $model->PERIOD_NUM])->yearMonth($yearMonth)->one()){
-                        $calcBonusModel->BONUS_QY = $model->SHOULD_BONUS;
-                        $calcBonusModel->BONUS_TOTAL = $calcBonusModel->BONUS_TOTAL + $model->SHOULD_BONUS;
-                        $calcBonusModel->BONUS_INCOME = $calcBonusModel->BONUS_INCOME + $model->SHOULD_BONUS;
-                        $calcBonusModel->P_CALC_MONTH = Date::ociToDate($yearMonth, Date::OCI_TIME_FORMAT_SHORT_MONTH);
-                        if (!$calcBonusModel->save()) {
-                            throw new Exception(Form::formatErrorsForApi($calcBonusModel->getErrors()));
-                        }
-                    }
-                    //更新对应补发列表状态
-                    if (!ResendQY::updateAll(['BONUS_QY'=>$model->SHOULD_BONUS,'RESEND_AUDIT_STATUS' => \Yii::$app->params['auditStatus'][$this->auditStatus]['value']], 'ID=:ID', [':ID' => $model->RESEND_ID])) {
-                        throw new Exception('更新申请审核状态失败');
-                    }
-
-                    $this->_teamworkBonus($model->USER_ID,$model->SHOULD_BONUS,$key);
-
-                }elseif($this->auditStatus == 'reject'){
-                    //更新对应补发列表状态
-                    if (!ResendQY::updateAll(['RESEND_AUDIT_STATUS' => \Yii::$app->params['auditStatus'][$this->auditStatus]['value'], 'RESEND_STATUS' => ResendQY::STATUS_WAIT], 'ID=:ID', [':ID' => $model->RESEND_ID])) {
-                        throw new Exception('更新申请状态失败');
-                    }
-                }
-                if (!$model->save()) {
-                    throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-                }
-
-                $logs[] = $model->USER_ID;
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('audit', $e->getMessage());
-            return null;
-        }
-        if($ids) {
-            $this->adminOperateLogger->setIsBatch(true)->afterUpdate($ids, 'ID')->setOptObjField('USER_ID')->clean()->save([
-                'optType' => '审核补发区域津贴',
-                'remark' => $this->remark,
-            ]);
-        }
-        return ['logs' => $logs];
-    }
-
-    /**
-     * 删除前
-     * @param $selected
-     * @throws Exception
-     */
-    public function beforeDelete($selected) {
-        //恢复
-        foreach ($selected as $value){
-            if($resendAudit = ResendQYAudit::findOneAsArray('ID=:ID',[':ID'=>$value],'RESEND_ID')){
-                if (!ResendQY::updateAll(['RESEND_AUDIT_ID' => null,'RESEND_AUDIT_STATUS' => null, 'RESEND_STATUS' => ResendQY::STATUS_WAIT], 'ID=:ID', [':ID' => $resendAudit['RESEND_ID']])) {
-                    throw new Exception('更新申请状态失败');
-                }
-            }
-        }
-        $this->adminOperateLogger->fetchClass = ResendQYAudit::class;
-        $this->adminOperateLogger->setIsBatch(true)->beforeDelete($selected, 'ID');
-    }
-
-    /**
-     * 删除
-     * @param $selected
-     * @throws Exception
-     */
-    public function delete($selected) {
-        $this->adminOperateLogger->clean()->save([
-            'optType' => '删除补发区域津贴待审核数据',
-        ]);
-    }
-
-    /**
-     * 点位合作发放
-     * @param $userId
-     * @param $amount
-     * @return bool
-     * @throws Exception
-     * @throws \yii\db\Exception
-     */
-    private function _teamworkBonus($userId, $amount, $key) {
-        if (!$teamwork = UserTeamwork::findAllAsArray('USER_ID!=:MAIN_UID AND MAIN_UID=:MAIN_UID AND IS_DEL=0', [':MAIN_UID' => $userId], 'USER_ID,DIVIDE_PERCENT')) return false;
-        $fromUserName = Info::getUserNameByUserId($userId);
-        foreach ($teamwork as $value) {
-            $bonus = Tool::formatPrice($amount * $value['DIVIDE_PERCENT'] * 0.01);
-            if ($bonus <= 0) continue;
-            $toUserName = Info::getUserNameByUserId($value['USER_ID']);
-            Balance::changeUserBonus($userId, 'bonus', -abs($bonus), ['SORT' => $key*10+1, 'DEAL_TYPE_ID' => DealType::TEAMWORK_TRANSFER_OUT, 'REMARK' => 'To:' . $toUserName . ' Per:' . $value['DIVIDE_PERCENT'] . '%']);
-            Balance::changeUserBonus($value['USER_ID'], 'bonus', abs($bonus), ['SORT' => $key*10+2, 'DEAL_TYPE_ID' => DealType::TEAMWORK_TRANSFER_IN, 'REMARK' => 'From: ' . $fromUserName . ' Per:' . $value['DIVIDE_PERCENT'] . '%']);
-        }
-    }
-}

+ 0 - 359
common/models/forms/SendCFAndLXForm.php

@@ -1,359 +0,0 @@
-<?php
-
-namespace common\models\forms;
-
-use common\helpers\Date;
-use common\components\Model;
-use common\helpers\Form;
-use common\helpers\Tool;
-use common\helpers\user\Balance;
-use common\helpers\user\Info;
-use common\libs\logging\operate\AdminOperate;
-use common\models\CFLXAudit;
-use common\models\DealType;
-use common\models\UserBonus;
-use common\models\UserTeamwork;
-use yii\base\Exception;
-
-/**
- * Login form
- *
- * @private CFLXAudit $_model
- */
-class SendCFAndLXForm extends Model {
-    public $id;
-    //public $year;
-    public $selectedIds;
-    public $statusValue;
-    public $sendType;
-    public $remark;
-    public $auditStatus;
-
-    private $_model;
-
-    const SEND_TYPES = ['all' => '车房养老奖和领袖分红奖', 'cf' => '车房养老奖', 'lx' => '领袖分红奖'];
-
-    public function init() {
-        parent::init();
-        $this->adminOperateLogger = new AdminOperate([
-            'fetchClass' => UserBonus::class,
-        ]);
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules() {
-        return [
-            [['id', 'remark', 'auditStatus', 'selectedIds', 'sendType', 'statusValue'], 'trim'],
-            [['id', 'auditStatus', 'remark', 'sendType', 'statusValue'], 'required'],
-            [['sendType'], 'isType'],
-            [['statusValue'], 'isStatusValue'],
-            [['selectedIds'], 'isSelected'],
-            [['auditStatus'], 'isAuditStatus'],
-        ];
-    }
-
-    public function attributeLabels() {
-        return [
-            'id' => '审核表ID',
-            'sendType' => '发放类型',
-            'statusValue' => '包含会员状态',
-            //'year' => '发放年度',
-            'remark' => '备注',
-        ];
-    }
-
-    /**
-     * 指定校验场景
-     * @return array
-     */
-    public function scenarios() {
-        $parentScenarios = parent::scenarios();
-        $customScenarios = [
-            'apply' => ['selectedIds', 'sendType', 'statusValue', 'remark'],
-            'audit' => ['selectedIds', 'auditStatus', 'remark'],
-        ];
-        return array_merge($parentScenarios, $customScenarios);
-    }
-
-    /**
-     * 年份是否正确
-     * @param $attribute
-     */
-    public function isYear($attribute) {
-        if (CFLXAudit::find()->where('YEAR=:YEAR AND AUDIT_STATUS=:AUDIT_STATUS', [':YEAR' => $this->year, ':AUDIT_STATUS' => \Yii::$app->params['auditStatus']['true']['value']])->exists()) {
-            $this->addError($attribute, '本年度已经发放');
-        }
-    }
-
-    /**
-     * 发放类型
-     * @param $attribute
-     */
-    public function isType($attribute) {
-        if (!in_array($this->sendType, array_keys(self::SEND_TYPES))) {
-            $this->addError($attribute, '请选择正确的发放类型');
-        }
-    }
-
-    /**
-     * 状态类型校验
-     * @param $attribute
-     */
-    public function isStatusValue($attribute) {
-        foreach ($this->statusValue as $status) {
-            if (!array_key_exists($status, \Yii::$app->params['userStatus'])) {
-                $this->addError($attribute, '请选择正确的会员状态');
-                break;
-            }
-        }
-    }
-
-    /**
-     * 校验审核状态
-     * @param $attributes
-     */
-    public function isAuditStatus($attributes){
-        if (!array_key_exists($this->auditStatus, \Yii::$app->params['auditStatus'])) {
-            $this->addError($attributes, '无效的审核状态');
-        }
-    }
-
-    /**
-     * 批量数据
-     * @param $attributes
-     */
-    public function isSelected($attributes) {
-        if (!$this->selectedIds) {
-            $this->addError($attributes, '必须选择一条数据');
-        }
-        if (!is_array($this->selectedIds)) {
-            $this->selectedIds = [$this->selectedIds];
-        }
-        if($this->scenario=='apply') {
-            $this->selectedIds = array_unique($this->selectedIds);
-            //根据会员状态及审核状态筛选
-            foreach ($this->selectedIds as $key => $value) {
-                if ($status = Info::getStatusByUserId($value)) {
-                    if (!in_array($status, $this->statusValue)) {
-                        unset($this->selectedIds[$key]);
-                    }
-                }
-                if (CFLXAudit::find()->where('USER_ID=:USER_ID AND AUDIT_STATUS =:AUDIT_STATUS', [':USER_ID' => $value, ':AUDIT_STATUS' => \Yii::$app->params['auditStatus']['un']['value']])->exists()) {
-                    unset($this->selectedIds[$key]);
-                }
-            }
-            $this->selectedIds = array_values($this->selectedIds);
-        }
-    }
-
-    /**
-     * 申请
-     * @return CFLXAudit|null
-     * @throws \yii\db\Exception
-     */
-    public function add() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            $model = $this->_model;
-            $model->YEAR = Date::nowYear();
-            $model->AUDIT_STATUS = \Yii::$app->params['auditStatus']['un']['value'];
-            $model->CREATE_ADMIN = \Yii::$app->user->id;
-            $model->CREATE_REMARK = $this->remark;
-            $model->CREATED_AT = Date::nowTime();
-            if (!$model->save()) {
-                throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('add', $e->getMessage());
-            return null;
-        }
-        return $model;
-    }
-
-    /**
-     * 批量发放车房领袖
-     * @return array|null
-     * @throws \yii\db\Exception
-     */
-    public function apply() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $logs = [];
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            foreach ($this->selectedIds as $select) {
-                $model = new CFLXAudit();
-                if ($this->sendType == 'lx') {
-                    if (!$oneData = UserBonus::findOneAsArray('LX>0 AND USER_ID=:USER_ID', [':USER_ID' => $select])) continue;
-                    $model->LX = $oneData['LX'];
-                } elseif ($this->sendType == 'cf') {
-                    if (!$oneData = UserBonus::findOneAsArray('CF>0 AND USER_ID=:USER_ID', [':USER_ID' => $select])) continue;
-                    $model->CF = $oneData['CF'];
-                } else {
-                    if (!$oneData = UserBonus::findOneAsArray('(CF>0 OR LX>0) AND USER_ID=:USER_ID', [':USER_ID' => $select])) continue;
-                    $model->LX = $oneData['LX'];
-                    $model->CF = $oneData['CF'];
-                }
-                $model->USER_ID = $select;
-                $model->YEAR = Date::nowYear();
-                $model->AUDIT_STATUS = \Yii::$app->params['auditStatus']['un']['value'];
-                $model->CREATE_ADMIN = \Yii::$app->user->id;
-                $model->CREATE_REMARK = $this->remark;
-                $model->CREATED_AT = Date::nowTime();
-                if (!$model->save()) {
-                    throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-                }
-                /*if($model->LX>0){
-                    Balance::changeUserBonus($select, 'lx', -$model->LX, ['REMARK' => '年度领袖分红奖申请']);
-                }
-                if($model->CF>0){
-                    Balance::changeUserBonus($select, 'cf', -$model->CF, ['REMARK' => '年度车房养老奖申请']);
-                }*/
-                $logs[] = $model->ID;
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('apply', $e->getMessage());
-            return null;
-        }
-        $this->adminOperateLogger->fetchClass = CFLXAudit::class;
-        $this->adminOperateLogger->setIsBatch(true)->afterUpdate($logs, 'ID');
-        $this->adminOperateLogger->clean()->save([
-            'optType' => '年度奖申请发放',
-            'remark' => $this->remark,
-        ]);
-        return ['logs' => $logs, 'typeName' => self::SEND_TYPES[$this->sendType]];
-    }
-
-    /**
-     * 审核
-     * @return array|null
-     * @throws \yii\db\Exception
-     */
-    public function audit() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $logs = [];
-        $uids=[];
-        if($this->auditStatus=='true'){
-            foreach ($this->selectedIds as $select) {
-                $oneBalanceAudit = CFLXAudit::findOneAsArray('AUDIT_STATUS=0 AND ID=:ID',[':ID'=>$select],'USER_ID');
-                $uids[]=$oneBalanceAudit['USER_ID'];
-            }
-        }
-        if($this->auditStatus=='true'){
-            $this->adminOperateLogger->fetchClass = UserBonus::class;
-            $this->adminOperateLogger->setIsBatch(true)->beforeUpdate($uids, 'USER_ID');
-        }else{
-            $this->adminOperateLogger->fetchClass = CFLXAudit::class;
-            $this->adminOperateLogger->setIsBatch(true)->beforeUpdate($this->selectedIds, 'ID');
-        }
-
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            foreach ($this->selectedIds as $key => $select) {
-                $model=CFLXAudit::findOne(['ID'=>$select]);
-                $model->AUDIT_STATUS = \Yii::$app->params['auditStatus'][$this->auditStatus]['value'];
-                $model->CREATE_REMARK = $this->remark?$this->remark:$model->CREATE_REMARK;
-                $model->AUDIT_ADMIN = \Yii::$app->user->id;
-                $model->AUDITED_AT = Date::nowTime();
-                if ($this->auditStatus == 'true') {
-                    if ($model->CF > 0) {
-                        Balance::changeUserBonus($model->USER_ID, 'cf', -$model->CF, ['REMARK' => '车房养老转出至会员账户', 'DEAL_TYPE_ID' => DealType::CF_TRANSFER_OUT]);
-                        Balance::changeUserBonus($model->USER_ID, 'bonus', $model->CF, ['SORT' => $key *10, 'REMARK' => '车房养老转入至会员账户', 'DEAL_TYPE_ID' => DealType::CF_TRANSFER_IN]);
-                        $this->_teamworkBonus($model->USER_ID, $model->CF, 'cf', $key);
-                    }
-                    if ($model->LX > 0) {
-                        Balance::changeUserBonus($model->USER_ID, 'lx', -$model->LX, ['REMARK' => '领袖分红转出至会员账户', 'DEAL_TYPE_ID' => DealType::LX_TRANSFER_OUT]);
-                        Balance::changeUserBonus($model->USER_ID, 'bonus', $model->LX, ['SORT' => $key *10 + 5, 'REMARK' => '领袖分红转入至会员账户', 'DEAL_TYPE_ID' => DealType::LX_TRANSFER_IN]);
-                        $this->_teamworkBonus($model->USER_ID, $model->LX, 'lx', $key);
-                    }
-                }
-                if (!$model->save()) {
-                    throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-                }
-                $logs[] = $model->USER_ID;
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('audit', $e->getMessage());
-            return null;
-        }
-
-        if($this->auditStatus=='true'){
-            $this->adminOperateLogger->fetchClass = UserBonus::class;
-            $this->adminOperateLogger->setIsBatch(true)->afterUpdate($uids, 'USER_ID')->clean()->save([
-                'optType' => '审核年度奖申请',
-                'remark' => $this->remark,
-            ]);
-        }else{
-            $this->adminOperateLogger->fetchClass = CFLXAudit::class;
-            $this->adminOperateLogger->setIsBatch(true)->afterUpdate($this->selectedIds, 'ID')->clean()->save([
-                'optType' => '审核年度奖申请',
-                'remark' => $this->remark,
-            ]);
-        }
-
-        return ['logs' => $logs];
-    }
-
-    /**
-     * 点位合作时转账
-     * @param $userId
-     * @param $amount
-     * @param null $type
-     * @return bool
-     * @throws Exception
-     * @throws \yii\db\Exception
-     */
-    private function _teamworkBonus($userId, $amount, $type = null, $key) {
-        if (!$teamwork = UserTeamwork::findAllAsArray('USER_ID!=:MAIN_UID AND MAIN_UID=:MAIN_UID AND IS_DEL=0', [':MAIN_UID' => $userId], 'USER_ID,DIVIDE_PERCENT')) return false;
-        $fromUserName = Info::getUserNameByUserId($userId);
-        foreach ($teamwork as $value) {
-            $bonus = Tool::formatPrice($amount * $value['DIVIDE_PERCENT'] * 0.01);
-            if ($bonus <= 0) continue;
-            $toUserName = Info::getUserNameByUserId($value['USER_ID']);
-            if ($type == 'cf') {
-                Balance::changeUserBonus($userId, 'bonus', -abs($bonus), ['SORT' => $key*10+1, 'DEAL_TYPE_ID' => DealType::TEAMWORK_TRANSFER_OUT, 'REMARK' => 'To:' . $toUserName . ' Per:' . $value['DIVIDE_PERCENT'] . '%']);
-                Balance::changeUserBonus($value['USER_ID'], 'bonus', abs($bonus), ['SORT' => $key*10+1, 'DEAL_TYPE_ID' => DealType::TEAMWORK_TRANSFER_IN, 'REMARK' => 'From:' . $fromUserName . ' Per' . $value['DIVIDE_PERCENT'] . '%']);
-            } elseif ($type == 'lx') {
-                Balance::changeUserBonus($userId, 'bonus', -abs($bonus), ['SORT' => $key*10+2, 'DEAL_TYPE_ID' => DealType::TEAMWORK_TRANSFER_OUT, 'REMARK' => 'To:' . $toUserName . ' Per' . $value['DIVIDE_PERCENT'] . '%']);
-                Balance::changeUserBonus($value['USER_ID'], 'bonus', abs($bonus), ['SORT' => $key*10+2, 'DEAL_TYPE_ID' => DealType::TEAMWORK_TRANSFER_IN, 'REMARK' => 'From:' . $fromUserName . ' Per' . $value['DIVIDE_PERCENT'] . '%']);
-            }
-        }
-    }
-
-    /**
-     * 删除前
-     * @param $selected
-     */
-    public function beforeDelete($selected) {
-        $this->adminOperateLogger->fetchClass = CFLXAudit::class;
-        $this->adminOperateLogger->setIsBatch(true)->beforeDelete($selected, 'ID');
-    }
-    /**
-     * 删除
-     * @param $selected
-     * @throws Exception
-     */
-    public function delete($selected) {
-        $this->adminOperateLogger->clean()->save([
-            'optType' => '删除年度奖申请',
-        ]);
-    }
-
-}

+ 0 - 79
common/models/forms/SmsApiForm.php

@@ -1,79 +0,0 @@
-<?php
-namespace common\models\forms;
-
-use common\components\Model;
-use common\helpers\Date;
-use common\libs\logging\operate\AdminOperate;
-use common\models\OcrApi;
-use common\models\SmsApi;
-use yii\helpers\Json;
-
-/**
- * Login form
- */
-class SmsApiForm extends Model
-{
-    public $id;
-    public $config;
-
-    public function init() {
-        parent::init();
-        $this->adminOperateLogger = new AdminOperate([
-            'fetchClass' => SmsApi::class,
-        ]);
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['id', 'config'], 'trim'],
-            [['id', 'config'], 'required'],
-            [['id'], 'exist', 'targetClass'=>SmsApi::class, 'targetAttribute'=>'ID'],
-        ];
-    }
-
-    /**
-     * 指定校验场景
-     * @return array
-     */
-    public function scenarios()
-    {
-        $parentScenarios =  parent::scenarios();
-        $customScenarios = [
-            'edit' => ['id', 'config']
-        ];
-        return array_merge($parentScenarios, $customScenarios);
-    }
-
-    /**
-     * 编辑
-     * @return null|static
-     */
-    public function edit(){
-        if(!$this->validate()){
-            return null;
-        }
-        $this->adminOperateLogger->saveBeforeContent = SmsApi::getConfigById($this->id);
-        if($this->scenario == 'edit') {
-            $model = SmsApi::findOne(['ID'=>$this->id]);
-            $model->UPDATE_ADMIN = \Yii::$app->user->id;
-            $model->UPDATED_AT = Date::nowTime();
-            $model->CONFIG = Json::encode($this->config);
-        } else {
-            $this->addError('edit', '提交场景不存在');
-            return null;
-        }
-        if(!$model->save()){
-            $this->addErrors($model->getErrors());
-            return null;
-        }
-        $this->adminOperateLogger->saveAfterContent = SmsApi::getConfigById($this->id);
-        $this->adminOperateLogger->clean()->save([
-            'optType' => 'SmsApi配置成功',
-        ]);
-        return $model;
-    }
-}

+ 0 - 102
common/models/forms/TransferBonusForm.php

@@ -1,102 +0,0 @@
-<?php
-namespace common\models\forms;
-
-use common\helpers\Cache;
-use common\helpers\Date;
-use common\components\Model;
-use common\helpers\Form;
-use common\helpers\user\Balance;
-use common\models\Article;
-use common\models\ArticleCategory;
-use common\models\DealType;
-use common\models\Period;
-use common\models\Transfer;
-use common\models\User;
-use common\models\UserBind;
-use common\models\UserBonus;
-use common\models\UserInfo;
-use yii\base\Exception;
-
-/**
- * Login form
- */
-class TransferBonusForm extends Model
-{
-    public $toUserId;
-    public $amount;
-    public $fromUserId;
-
-    private $_fromUserInfo;
-    private $_toUserInfo;
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['toUserId', 'amount', 'fromUserId'], 'trim'],
-            [['toUserName', 'amount', 'fromUserId'], 'required'],
-            [['amount'], 'price'],
-            [['amount'], 'isAmount'],
-        ];
-    }
-
-    public function attributeLabels()
-    {
-        return [
-            'toUserId' => '转入会员编号',
-            'amount' => '金额',
-            'fromUserId' => '转出会员编号',
-        ];
-    }
-
-    /**
-     * 归集批量转账
-     * @param $main_uid
-     * @return Transfer|null
-     * @throws \yii\db\Exception
-     */
-    public function collectBind($main_uid){
-        $result = [];
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            $userBinds = UserBind::findAllAsArray('MAIN_UID=:MAIN_UID AND IS_DEL=0',[':MAIN_UID'=>$main_uid]);
-            if(!$userBinds){
-                throw new Exception('不存在点位绑定关系');
-            }
-            $period = Period::instance();
-            $totals=0;
-            foreach ($userBinds as $value){
-                if($value['USER_ID']==$main_uid) continue;
-                $bonus=Balance::getAvailableBalance($value['USER_ID']);
-                if($bonus<=0) continue;
-                $totals+=$bonus;
-                Balance::changeUserBonus($value['USER_ID'], 'bonus', -abs($bonus), ['DEAL_TYPE_ID' => DealType::BIND_TRANSFER_OUT, 'REMARK' => 'To:'.$main_uid]);
-                Balance::changeUserBonus($main_uid, 'bonus', abs($bonus), ['DEAL_TYPE_ID' => DealType::BIND_TRANSFER_IN, 'REMARK' => 'From:'.$value['USER_ID']]);
-                $array = [
-                    'FROM_UID'=>$value['USER_ID'],
-                    'TO_UID'=>$main_uid,
-                    'FROM_WALLET'=>'bonus',
-                    'IN_WALLET'=>'bonus',
-                    'AMOUNT'=>$bonus,
-                    'PERIOD_NUM'=>$period->getNowPeriodNum(),
-                    'CALC_MONTH'=>$period->getNowYearMonth(),
-                    'CREATED_AT'=>Date::nowTime(),
-                ];
-                $result[] = $array;
-            }
-            if($result) Transfer::batchInsert($result);
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('edit', $e->getMessage());
-            return null;
-        }
-        unset($parents ,$res ,$model);
-        return $totals;
-    }
-
-
-}

+ 0 - 375
common/models/forms/TransferForm.php

@@ -1,375 +0,0 @@
-<?php
-
-namespace common\models\forms;
-
-use common\helpers\Cache;
-use common\helpers\Date;
-use common\components\Model;
-use common\helpers\Form;
-use common\helpers\snowflake\SnowFake;
-use common\helpers\Tool;
-use common\helpers\user\Balance;
-use common\helpers\user\Cash;
-use common\helpers\user\Info;
-use common\libs\logging\operate\UserOperate;
-use common\models\Article;
-use common\models\ArticleCategory;
-use common\models\DealType;
-use common\models\DecOrder;
-use common\models\Order;
-use common\models\PerfPeriod;
-use common\models\Period;
-use common\models\Transfer;
-use common\models\User;
-use common\models\UserBind;
-use common\models\UserBonus;
-use common\models\UserInfo;
-use common\models\UserRelation;
-use common\models\UserSystem;
-use yii\base\Exception;
-use yii\helpers\Json;
-
-/**
- * Login form
- */
-class TransferForm extends Model {
-    const allowTransferType = [1, 2, 3];
-    const BONUS_TO_BALANCE = 1;
-    const BONUS_TO_BONUS = 2;
-    const BALANCE_TO_BALANCE = 3;
-
-    public $toUserName;
-    public $toRealName;
-    public $amount;
-    public $payPassword;
-    public $type;
-    public $remark;
-    public $transferCode;
-
-    private $_fromUserInfo;
-    private $_toUserInfo;
-    private $_transferProp;
-    private $_transferConfig;
-    private $_fee = 0;
-
-    public function init() {
-        parent::init();
-        $this->userOperateLogger = new UserOperate([
-            'fetchClass' => Transfer::class,
-        ]);
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules() {
-        return [
-            [['toUserName', 'toRealName', 'amount', 'type', 'remark'], 'trim'],
-            [['toUserName', 'toRealName', 'amount', 'type', 'payPassword', 'transferCode'], 'required'],
-            [['toUserName'], 'exist', 'targetClass' => UserInfo::class, 'targetAttribute' => 'USER_NAME'],
-            [['type'], 'isType'],
-            [['toUserName'], 'initUser'],
-            [['amount'], 'price'],
-            [['amount'], 'isAmount'],
-            [['transferCode'], 'validateCode'],
-            [['payPassword'], 'validatePassword'],
-        ];
-    }
-
-    /**
-     * 指定校验场景
-     * @return array
-     */
-    public function scenarios() {
-        $parentScenarios = parent::scenarios();
-        $customScenarios = [
-            'transfer' => ['type', 'toUserName', 'toRealName', 'amount', 'remark', 'payPassword', 'transferCode'],
-        ];
-        return array_merge($parentScenarios, $customScenarios);
-    }
-
-    public function attributeLabels() {
-        return [
-            'toUserName' => '转入会员编号',
-            'amount' => '金额',
-            'payPassword' => '支付密码',
-            'transferCode' => '转账校验码',
-        ];
-    }
-
-    /**
-     * 初始化转入转出用户信息
-     * @param $attribute
-     * @return null
-     * @throws Exception
-     */
-    public function initUser($attribute) {
-        // 转账记录
-        if(!$toUserId = Info::getUserIdByUserName($this->toUserName)){
-            $this->addError($attribute, '转入会员不存在');
-            return null;
-        }
-//        if(Info::getUserRealNameByUserId($toUserId)!=$this->toRealName){
-//            $this->addError($attribute, '转入会员会员姓名不正确');
-//            return null;
-//        }
-        $this->_toUserInfo = Info::baseInfo($toUserId);
-
-        $fromUserId = \Yii::$app->user->id;
-        $fromUser = Info::baseInfo($fromUserId);
-        if (!$fromUser) {
-            $this->addError($attribute, '转出会员不存在');
-            return null;
-        }
-        // 转账条件判断
-        $orderAmount = Order::find()->where('USER_ID=:USER_ID', [':USER_ID' => $fromUserId])->SUM('ORDER_AMOUNT');
-        $recNum = intval(DecOrder::find()->where('REC_USER_ID=:REC_USER_ID', [':REC_USER_ID' => $fromUserId])->count());
-        //$recNum = UserRelation::firstFloorChildNum($fromUserId);
-//        if ($orderAmount < 300 && $recNum==0) {
-//            $this->addError($attribute, '消费未满300元或未推荐新人,暂不能转账');
-//            return null;
-//        }
-        $this->_fromUserInfo = $fromUser;
-        //是否同体系转账
-//        if($this->_transferConfig['isSystem']==1){
-//            if($this->_toUserInfo['SYSTEM_ID']!=$this->_fromUserInfo['SYSTEM_ID']){
-//                $this->addError($attribute, '只能同一体系间转账');
-//                return null;
-//            }
-//        }
-
-        //是否点位绑定转账
-//        if ($this->_transferConfig['isBind'] == 1) {
-//            if (!UserBind::sameBind($this->_toUserInfo['ID'], $this->_fromUserInfo['ID'])) {
-//                $this->addError($attribute, '只能点位绑定在一起的会员之间转账');
-//                return null;
-//            }
-//        }
-
-
-
-        //奖金转奖金限同一身份证
-        /*if ($this->type == self::BONUS_TO_BONUS) {
-            $toIdCard = User::findOneAsArray('ID=:ID', [':ID' => $toUser['USER_ID']], 'ID_CARD');
-            $fromIdCard = User::findOneAsArray('ID=:ID', [':ID' => $fromUser['USER_ID']], 'ID_CARD');
-            if ($toIdCard['ID_CARD'] && ($toIdCard['ID_CARD'] != $fromIdCard['ID_CARD'])) {
-                $this->addError($attribute, '奖金转奖金只能在同一身份证下进行');
-                return null;
-            }
-        }*/
-        //奖金转现金限一周一次
-        /*if ($this->type == self::BONUS_TO_BALANCE) {
-            if (Transfer::hasThisWeekTransfer(\Yii::$app->user->id)) {
-                $this->addError($attribute, '转账失败,每周只可以转账一次');
-                return null;
-            }
-        }*/
-    }
-
-    /**
-     * 校验申请金额是否小于当前余额并符合配置中的设置
-     * @param $attribute
-     * @return null
-     */
-    public function isAmount($attribute) {
-        if(!$this->_fromUserInfo){
-            $this->addError($attribute, '会员信息未验证通过');
-            return null;
-        }
-        if ($this->amount <= 0) {
-            $this->addError($attribute, '转账金额必须大于0');
-        }
-        if ((int)$this->amount!=$this->amount) {
-            $this->addError('scenario', '转账金额必须是整数');
-        }
-        $minAmount = $this->_transferConfig['outMin'];
-        if ($this->amount < $minAmount) {
-            $this->addError($attribute, '转账金额低于转账下限');
-        }
-        $maxAmount = $this->_transferConfig['outMax'];
-        if ($maxAmount && $this->amount > $maxAmount) {
-            $this->addError($attribute, '转账金额高于转账上限');
-        }
-        //周转账上限
-        if($this->_transferConfig['weekMax']!=0){
-            if($this->amount+Transfer::weekTransfer($this->_fromUserInfo['ID'])>$this->_transferConfig['weekMax']){
-                $this->addError($attribute, '超出周转账上限');
-            }
-        }
-        //月转账上限
-        if($this->_transferConfig['monthMax']!=0){
-            if($this->amount+Transfer::monthTransfer($this->_fromUserInfo['ID'])>$this->_transferConfig['weekMax']){
-                $this->addError($attribute, '超出月转账上限');
-            }
-        }
-
-        // 获取当前用户的可用金额
-        if( $this->type == self::BALANCE_TO_BALANCE ) {
-            $haveBalance = Cash::getAvailableBalance($this->_fromUserInfo['ID']);
-        }else {
-            $haveBalance = Balance::getAvailableBalance($this->_fromUserInfo['ID']);
-        }
-        if ($this->amount > $haveBalance) {
-            $this->addError($attribute, '转账金额必须小于自己的可用余额');
-        }
-        // 转账比例
-        if ($this->type == self::BONUS_TO_BALANCE) {
-            $isCanTransferProp = Cache::getSystemConfig()['isCanTransferProp']['VALUE'];
-            if ($isCanTransferProp == 1) {
-                $maxAmount = Tool::formatPrice($this->_fromUserInfo['TRANSFER_PROP'] * Balance::getAvailableBalance($this->_fromUserInfo['ID']) * 0.01);
-                if ($this->amount > $maxAmount) {
-                    $this->addError($attribute, '转账金额超出转账比例限额');
-                }
-            }
-        }
-
-        //手续费
-        if($this->_transferConfig['fee']!=0){
-            $fee = Tool::formatPrice($this->amount * ($this->_transferConfig['fee']) * 0.01);
-            if($this->_transferConfig['feeMin']!=0&&$fee<$this->_transferConfig['feeMin']){
-                $fee = $this->_transferConfig['feeMin'];
-            }
-            if($this->_transferConfig['feeMax']!=0&&$fee>$this->_transferConfig['feeMax']){
-                $fee = $this->_transferConfig['feeMax'];
-            }
-            $this->_fee = $fee;
-        }
-    }
-
-    /**
-     * 转账类型判断
-     * @param $attribute
-     */
-    public function isType($attribute) {
-        if (!in_array($this->type, self::allowTransferType)) {
-            $this->addError($attribute, '不允许的转账类型');
-        }
-        //获取转账参数
-        if(!$this->_transferConfig = Json::decode(Cache::getSystemConfig()['allowWallet']['VALUE'])[$this->type-1]){
-            $this->addError($attribute, '错误的转账类型');
-        }
-        if(!$this->_transferConfig['isOpen']){
-            $this->addError($attribute, '不可用的转账类型');
-        }
-    }
-
-    /**
-     * 校验支付密码
-     * @param $attribute
-     * @param $params
-     */
-    public function validatePassword($attribute, $params) {
-        if (!User::validatePayPassword($this->_fromUserInfo['ID'], $this->payPassword)) {
-            $this->addError($attribute, '支付密码不正确');
-        }
-    }
-
-    public function validateCode($attribute, $params) {
-        $uid = \Yii::$app->user->id;
-        $redisCode = \Yii::$app->redis->getset('transferCode_'.$uid,'');
-        \Yii::$app->redis->del('transferCode_'.$uid);
-        if ($this->transferCode!=$redisCode) {
-            $this->addError($attribute, '转账校验失败'.$redisCode);
-        }
-    }
-    /**
-     * 生成随机数
-     * @param $length
-     * @param int $numeric
-     * @return string
-     */
-    public function random($length, $numeric = 0) {
-        $seed = base_convert(md5(microtime() . $_SERVER['DOCUMENT_ROOT']), 16, $numeric ? 10 : 35);
-        $seed = $numeric ? (str_replace('0', '', $seed) . '012340567890') : ($seed . 'zZ' . strtoupper($seed));
-        $hash = '';
-        $max = strlen($seed) - 1;
-        for ($i = 0; $i < $length; $i++) {
-            $hash .= $seed{mt_rand(0, $max)};
-        }
-        return $hash;
-    }
-
-    /**
-     * 转账
-     * @return Transfer|null
-     * @throws \Exception
-     */
-    public function transfer() {
-        if (!$this->validate()) {
-            return null;
-        }
-
-        $fromData = Balance::getLogData($this->_fromUserInfo['ID']);
-        $toData = Balance::getLogData($this->_toUserInfo['ID']);
-        $this->userOperateLogger->saveBeforeContent=array_merge($fromData,$toData);
-
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            $amount = Tool::formatPrice($this->amount - $this->_fee);
-            // 转账记录
-            $period = Period::instance();
-            $model = new Transfer();
-            $model->ID = SnowFake::instance()->generateId();
-            $model->TRANSFER_SN = Transfer::generateSN();
-            $model->OUT_UID = $this->_fromUserInfo['ID'];
-            $model->LAST_OUT_USER_NAME = $this->_fromUserInfo['USER_NAME'];
-            $model->LAST_OUT_REAL_NAME = $this->_fromUserInfo['REAL_NAME'];
-            $model->LAST_OUT_DEC_LV = $this->_fromUserInfo['DEC_LV'];
-            $model->LAST_OUT_DEC_ROLE_ID = $this->_fromUserInfo['DEC_ROLE_ID'];
-            $model->OUT_WALLET = $this->_transferConfig['out'];
-            $model->LAST_OUT_SYSTEM_ID = $this->_fromUserInfo['SYSTEM_ID'] ? $this->_fromUserInfo['SYSTEM_ID'] : '';
-            $model->IN_UID = $this->_toUserInfo['ID'];
-            $model->LAST_IN_USER_NAME = $this->_toUserInfo['USER_NAME'];
-            $model->LAST_IN_REAL_NAME = $this->_toUserInfo['REAL_NAME'];
-            $model->LAST_IN_DEC_LV = $this->_toUserInfo['DEC_LV'];
-            $model->IN_WALLET = $this->_transferConfig['in'];
-            $model->LAST_IN_SYSTEM_ID = $this->_toUserInfo['SYSTEM_ID'] ? $this->_toUserInfo['SYSTEM_ID'] : '';
-            $model->ORI_AMOUNT = $this->amount;
-            $model->FEE = $this->_fee;
-            $model->AMOUNT = $amount;
-            $model->REMARK = $this->remark;
-            $model->PERIOD_NUM = $period->getNowPeriodNum();
-            $model->CALC_MONTH = $period->getNowYearMonth();
-            $model->CREATED_AT = Date::nowTime();
-            if (!$model->save()) {
-                throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-            }
-            if ($this->type == self::BONUS_TO_BALANCE) {
-                // 会员金额减少
-                Balance::changeUserBonus($this->_fromUserInfo['ID'], 'bonus', -abs($this->amount), ['TRANSFER_SN' => $model->TRANSFER_SN, 'DEAL_TYPE_ID' => DealType::TRANSFER_OUT, 'REMARK' => 'To:' . $this->_toUserInfo['USER_NAME'] . ',' . $this->remark]);
-                Cash::changeUserCash($this->_toUserInfo['ID'], 'CASH', abs($amount), ['TRANSFER_SN' => $model->TRANSFER_SN,'DEAL_TYPE_ID' => DealType::TRANSFER_IN, 'REMARK' => 'From:' . $this->_fromUserInfo['USER_NAME'] . ',' . $this->remark]);
-            } elseif($this->type == self::BONUS_TO_BONUS) {
-                // 会员金额减少
-                Balance::changeUserBonus($this->_fromUserInfo['ID'], 'bonus', -abs($this->amount), ['TRANSFER_SN' => $model->TRANSFER_SN, 'DEAL_TYPE_ID' => DealType::TRANSFER_OUT, 'REMARK' => 'To:' . $this->_toUserInfo['USER_NAME'] . ',' . $this->remark]);
-                Balance::changeUserBonus($this->_toUserInfo['ID'], 'bonus', abs($amount), ['TRANSFER_SN' => $model->TRANSFER_SN, 'DEAL_TYPE_ID' => DealType::TRANSFER_IN, 'REMARK' => 'From:' . $this->_fromUserInfo['USER_NAME'] . ',' . $this->remark]);
-            }else if ($this->type == self::BALANCE_TO_BALANCE) {
-                // 会员金额减少
-                Cash::changeUserCash($this->_fromUserInfo['ID'], 'CASH', -abs($this->amount), ['TRANSFER_SN' => $model->TRANSFER_SN,'DEAL_TYPE_ID' => DealType::TRANSFER_OUT, 'REMARK' => 'To:' . $this->_toUserInfo['USER_NAME'] . ',' . $this->remark]);
-                Cash::changeUserCash($this->_toUserInfo['ID'], 'CASH', abs($amount), ['TRANSFER_SN' => $model->TRANSFER_SN,'DEAL_TYPE_ID' => DealType::TRANSFER_IN, 'REMARK' => 'From:' . $this->_fromUserInfo['USER_NAME'] . ',' . $this->remark]);
-            }else {
-                throw new \Exception('错误的交易类型');
-            }
-
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('edit', $e->getMessage());
-            return null;
-        }
-
-        $fromData = Balance::getLogData($this->_fromUserInfo['ID']);
-        $toData = Balance::getLogData($this->_toUserInfo['ID']);
-        $this->userOperateLogger->saveAfterContent=array_merge($fromData,$toData);
-        unset($fromData,$toData);
-        $this->userOperateLogger->clean()->save([
-            'optType' => '会员转账',
-            'userId' => \Yii::$app->user->id,
-            'userName' => Info::getUserNameByUserId(\Yii::$app->user->id),
-            'remark' => $this->remark,
-        ]);
-        return $model;
-    }
-
-
-}

+ 0 - 310
common/models/forms/UploadForm.php

@@ -1,310 +0,0 @@
-<?php
-
-namespace common\models\forms;
-
-use common\helpers\Cache;
-use common\components\Model;
-use common\helpers\Date;
-use common\helpers\Excel;
-use common\helpers\Form;
-use common\helpers\http\RemoteUploadApi;
-use common\helpers\ocr\OcrApi;
-use common\helpers\user\Info;
-use common\models\ExcelAddUser;
-use common\models\ExcelImport;
-use common\models\InvoiceAudit;
-use common\models\Recharge;
-use common\models\Uploads;
-use common\models\User;
-use common\models\Withdraw;
-use yii\base\Exception;
-
-/**
- * Login form
- */
-class UploadForm extends Model {
-    public $file;
-    public $excelOption; // 导入的excel文件用来干什么,存入excel导入表
-    public $token;
-    public $remark;
-    public $withdrawId;
-    public $rechargeId;
-
-    private $_ocrResult;
-    private $_remoteScenario = [
-        'idCardFront', 'idCardBack', 'ad', 'invoiceFront','proveFront','goodsImg'
-    ];
-
-    /**
-     * @inheritdoc
-     */
-    public function rules() {
-        return [
-            [['remark', 'withdrawId', 'rechargeId'], 'trim'],
-            [['file', 'token', 'excelOption'], 'required'],
-            [['token'], 'isToken'],
-            [['file'], 'file'],
-            [['file'], 'file', 'mimeTypes' => ['image/jpeg', 'image/png', 'image/x-png'], 'on' => ['idCardFront', 'idCardBack', 'ad']],
-            // todo 暂时屏蔽
-//            [['file'], 'file', 'mimeTypes'=>['application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/csv'], 'on'=>['excel']],
-            [['file'], 'isIdCardFront', 'on' => ['idCardFront']],
-            [['file'], 'isInvoiceFront', 'on' => ['invoiceFront']],
-            //[['file'], 'isIdCardBack', 'on'=>['idCardBack']],
-
-        ];
-    }
-
-    /**
-     * 指定校验场景
-     * @return array
-     */
-    public function scenarios() {
-        $parentScenarios = parent::scenarios();
-        $customScenarios = [
-            'idCardFront' => ['file', 'token'],
-            'idCardBack' => ['file', 'token'],
-            'invoiceFront' => ['file', 'token', 'remark', 'withdrawId'],
-            'proveFront' => ['file', 'token', 'rechargeId'],
-            'ad' => ['file', 'token'],
-            'excel' => ['file', 'token', 'excelOption'],
-            'goodsImg' => ['file', 'token'],
-        ];
-        return array_merge($parentScenarios, $customScenarios);
-    }
-
-
-    public function attributeLabels() {
-        return [
-            'file' => '文件',
-        ];
-    }
-
-    /**
-     * 校验上传token
-     * @param $attributes
-     */
-    public function isToken($attributes) {
-        if (!Cache::getUploadToken($this->token)) {
-            $this->addError($attributes, '上传token校验失败');
-        }
-    }
-
-    /**
-     * 是否是身份证
-     * @param $attributes
-     */
-    public function isIdCardFront($attributes) {
-        // 查看该用户是否已经上传过身份证照片
-        $oneData = User::find()->select('ID_IMAGE')->where('ID=:ID', [':ID' => \Yii::$app->user->id])->asArray()->one();
-        if ($oneData['ID_IMAGE']) {
-            $this->addError($attributes, '您已上传过身份证照片');
-        }
-        $this->_ocrResult = OcrApi::instance()->idCard($this->file->tempName);
-        if (!$this->_ocrResult['success']) {
-            $this->addError($attributes, $this->_ocrResult['message']);
-        }
-    }
-
-    /**
-     * 前台上传发票
-     * @param $attributes
-     */
-    public function isInvoiceFront($attributes) {
-        $this->_ocrResult = OcrApi::instance()->vatInvoice($this->file->tempName);
-        if (!$this->_ocrResult['success']) {
-            $this->addError($attributes, $this->_ocrResult['message']);
-        }
-    }
-
-
-    /**
-     * 上传
-     * @return bool
-     * @throws \yii\db\Exception
-     */
-    public function upload() {
-        if (!$this->validate()) {
-            return false;
-        }
-        $oneUser = User::findOne(['ID' => \Yii::$app->user->id]);
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            switch ($this->scenario) {
-                case 'invoiceFront':
-                    $uploadCategory = Uploads::CATEGORY_INVOICE;
-                    $uploadRemark = $this->remark;
-                    break;
-                case 'idCardFront':
-                    $uploadCategory = Uploads::CATEGORY_ID_CARD;
-                    $uploadRemark = $this->_ocrResult['realName'] . '身份证正面';
-                    break;
-                case 'idCardBack':
-                    $uploadCategory = Uploads::CATEGORY_ID_CARD;
-                    $uploadRemark = $oneUser['REAL_NAME'] . '身份证背面';
-                    break;
-                case 'ad':
-                    $uploadCategory = Uploads::CATEGORY_IMAGE;
-                    $uploadRemark = $this->file->baseName;
-                    break;
-                case 'excel':
-                    $uploadCategory = Uploads::CATEGORY_EXCEL;
-                    $uploadRemark = $this->file->baseName;
-                    break;
-                case 'proveFront':
-                    $uploadCategory = Uploads::CATEGORY_IMAGE;
-                    $uploadRemark = $this->file->baseName;
-                    break;
-                case 'goodsImg':
-                    $uploadCategory = Uploads::CATEGORY_IMAGE;
-                    $uploadRemark = $this->file->baseName;
-                    break;
-                default :
-                    $uploadCategory = Uploads::CATEGORY_UN_KNOW;
-                    $uploadRemark = $this->file->baseName;
-                    break;
-            }
-            // 上传图片到远程服务器
-            if (in_array($this->scenario, $this->_remoteScenario)) {
-                $remoteUploadApi = RemoteUploadApi::instance();
-                $uploadResult = $remoteUploadApi->upload($this->file->tempName);
-                if ($uploadResult) {
-                    $uploadInfo = [
-                        'fileName' => $uploadResult['name'],
-                        'category' => $uploadCategory,
-                        'url' => $uploadResult['url'],
-                        'fileSize' => $uploadResult['size'] ?? null,
-                        'md5' => $uploadResult['md5'] ?? null,
-                    ];
-                } else {
-                    throw new Exception('文件远程上传失败');
-                }
-                // 删除本地临时文件
-                unlink($this->file->tempName);
-            } else {
-                // 保存在本地
-                $localPath = \Yii::getAlias('@common/runtime/uploads/') . $this->file->baseName . '.' . $this->file->extension;
-                if (!$this->file->saveAs($localPath)) {
-                    throw new Exception('文件保存失败');
-                }
-                $uploadInfo = [
-                    'fileName' => $this->file->baseName . '.' . $this->file->extension,
-                    'category' => $uploadCategory,
-                    'url' => $localPath,
-                    'fileSize' => null,
-                    'md5' => null,
-                ];
-            }
-            // 把上传的文件写入数据库记录中
-            // 把文件对应的相关资料存入数据库中
-            $uploads = new Uploads();
-            $uploads->FILE_NAME = $uploadInfo['fileName'];
-            $uploads->CATEGORY = $uploadInfo['category'];
-            $uploads->URL = $uploadInfo['url'];
-            $uploads->FILE_SIZE = $uploadInfo['fileSize'] ?? null;
-            $uploads->MD5 = $uploadInfo['md5'] ?? null;
-            $uploads->REMARK = $uploadRemark;
-            $uploads->CREATED_AT = Date::nowTime();
-            if (!$uploads->save()) {
-                throw new Exception('上传文件信息保存失败');
-            }
-            // 如果是上传发票,更新发票信息,并绑定提现记录
-            if ($this->scenario == 'invoiceFront') {
-                $withdraw = Withdraw::findOne(['ID' => $this->withdrawId]);
-                //判断金额是否一致
-                if ($withdraw['AMOUNT'] != $this->_ocrResult['amount']) {
-                    throw new Exception('上传发票金额'.$this->_ocrResult['amount'].'与提现金额【'.$withdraw['AMOUNT'].'】不一致');
-                }
-                //发票内容是否与后台预置信息相符
-                $configName = Cache::getSystemConfig()['invoiceItemName']['VALUE'];
-                if (!in_array($this->_ocrResult['itemName'], explode("\n",$configName))) {
-                    throw new Exception('上传发票中货物或应税劳务服务名称与后台预置信息【' . $configName . '】不一致');
-                }
-                //写入发票数据
-                if (InvoiceAudit::find()->where('INVOICE_NUM=:INVOICE_NUM AND WITHDRAW_ID!=:WITHDRAW_ID AND AUDIT_STATUS!=:AUDIT_STATUS', [':INVOICE_NUM' => $this->_ocrResult['invoiceNum'], ':WITHDRAW_ID' => $this->withdrawId, ':AUDIT_STATUS' => \Yii::$app->params['auditStatus']['reject']['value']])->exists()) {
-                    throw new Exception('该发票已被使用');
-                }
-                if(!$invoiceModel = InvoiceAudit::findOne(['WITHDRAW_ID' => $this->withdrawId])){
-                    $invoiceModel = new InvoiceAudit();
-                }
-                $invoiceModel->USER_ID = $oneUser['ID'];
-                $invoiceModel->WITHDRAW_ID = $this->withdrawId;
-                $invoiceModel->INVOICE_CODE = $this->_ocrResult['invoiceCode'];
-                $invoiceModel->INVOICE_NUM = $this->_ocrResult['invoiceNum'];
-                $invoiceModel->INVOICE_DATE = $this->_ocrResult['invoiceDate'];
-                $invoiceModel->AMOUNT = $this->_ocrResult['amount'];
-                $invoiceModel->TAX_RATE = $this->_ocrResult['taxRate'];
-                $invoiceModel->PURCHASER_NAME = $this->_ocrResult['purchaserName'];
-                $invoiceModel->PURCHASER_REGISTER_NUM = $this->_ocrResult['purchaserRegisterNum'];
-                $invoiceModel->PURCHASER_ADDRESS = $this->_ocrResult['purchaserAddress'];
-                $invoiceModel->PURCHASER_BANK = $this->_ocrResult['purchaserBank'];
-                $invoiceModel->SELLER_NAME = $this->_ocrResult['sellerName'];
-                $invoiceModel->SELLER_REGISTER_NUM = $this->_ocrResult['sellerRegisterNum'];
-                $invoiceModel->SELLER_ADDRESS = $this->_ocrResult['sellerAddress'];
-                $invoiceModel->SELLER_BANK = $this->_ocrResult['sellerBank'];
-                $invoiceModel->ITEM_NAME = $this->_ocrResult['itemName'];
-                $invoiceModel->INVOICE_REMARK = $this->_ocrResult['invoiceRemark'];
-                $invoiceModel->UPLOAD_ID = $uploads->ID;
-                $invoiceModel->CREATED_AT = Date::nowTime();
-                if (!$invoiceModel->save()) {
-                    throw new Exception(Form::formatErrorsForApi($invoiceModel->getErrors()));
-                }
-                //写入提现表
-                $withdraw->INVOICE_ID = $invoiceModel->ID;
-                $withdraw->AUDIT_STATUS = Withdraw::STATUS_APPLIED;
-                $withdraw->UPDATED_AT = Date::nowTime();
-                if (!$withdraw->save()) {
-                    throw new Exception(Form::formatErrorsForApi($withdraw->getErrors()));
-                }
-            } // 如果是上传身份证正面的场景,则把识别出来的信息更新当前的会员信息
-            elseif ($this->scenario == 'idCardFront') {
-                // 修改用户基本信息
-                $oneUser->REAL_NAME = $this->_ocrResult['realName'];
-                $oneUser->ID_CARD = $this->_ocrResult['idCardNo'];
-                $oneUser->ADDRESS = $this->_ocrResult['address'];
-                $oneUser->NATION = Info::getNationCode($this->_ocrResult['nation']);
-                $oneUser->ID_IMAGE = $uploadInfo['url'];
-                if (!$oneUser->save()) {
-//                        throw new Exception('用户基本资料保存失败');
-                    throw new Exception(Form::formatErrorsForApi($oneUser->getErrors()));
-                }
-                // 更新会员信息缓存
-                User::updateBaseInfoToRedis($oneUser['ID']);
-            } elseif ($this->scenario == 'excel') {
-                $excelTableClass = Excel::EXCEL_STRUCTURE[$this->excelOption]['excelTableClass'];
-                // 把上传的文件写入到导入记录中
-                $excelImport = new ExcelImport();
-                $excelImport->OPTION_NAME = $this->excelOption;
-                $excelImport->TABLE_NAME = $excelTableClass::tableName();
-                $excelImport->UPLOAD_ID = $uploads->ID;
-                $excelImport->AUDIT_STATUS = \Yii::$app->params['auditStatus']['true']['value'];
-                $excelImport->IMPORT_ADMIN_ID = \Yii::$app->user->id;
-                $excelImport->AUDIT_ADMIN_ID = \Yii::$app->user->id;
-                $excelImport->CREATED_AT = Date::nowTime();
-                if (!$excelImport->save()) {
-                    throw new Exception(Form::formatErrorsForApi($excelImport->getErrors()));
-                }
-            }elseif ($this->scenario == 'proveFront') {
-                // 如果是上传充值凭证,绑定充值记录
-                    $recharge = Recharge::findOne(['ID' => $this->rechargeId]);
-                    if(!$recharge){
-                        throw new Exception("缺少参数ID");
-                    }
-                    //写入充值表
-                    $recharge->BANK_PROVE = $uploadInfo['url'];
-                    $recharge->AUDIT_STATUS = Recharge::STATUS_PROVED;
-                    if (!$recharge->save()) {
-                        throw new Exception(Form::formatErrorsForApi($recharge->getErrors()));
-                    }
-                }
-
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('upload', $e->getMessage());
-            return false;
-        }
-
-        return $uploads;
-    }
-}

+ 0 - 377
common/models/forms/UserBindForm.php

@@ -1,377 +0,0 @@
-<?php
-
-namespace common\models\forms;
-
-use common\helpers\Date;
-use common\helpers\user\Info;
-use common\helpers\user\Status;
-use common\components\Model;
-use common\helpers\Form;
-use common\libs\logging\operate\AdminOperate;
-use common\libs\logging\operate\UserOperate;
-use common\models\Period;
-use common\models\User;
-use common\models\UserBind;
-use common\models\UserInfo;
-use yii\base\Exception;
-
-/**
- * 点位绑定表单
- */
-class UserBindForm extends Model {
-    public $id;
-    public $userId;
-    public $mainUid;
-    public $userName;
-    public $mainUserName;
-
-    private $_uid;
-    private $_mainUid;
-    private $_model;
-    private $_userIdcard;
-
-    public function init() {
-        parent::init();
-        $this->adminOperateLogger = new AdminOperate([
-            'fetchClass' => UserBind::class,
-        ]);
-        $this->userOperateLogger = new UserOperate([
-            'fetchClass' => UserBind::class,
-        ]);
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules() {
-        return [
-            [['id', 'userName', 'mainUserName', 'mainUid', 'userId'], 'trim'],
-            [['id', 'userName', 'mainUserName'], 'required'],
-            [['userName'], 'isUserName'],
-            [['mainUserName'], 'isMainUserName'],
-            //[['mainUid'], 'isMainUid'],
-            //[['userId'], 'isUserId'],
-            [['id'], 'initModel'],
-        ];
-    }
-
-    /**
-     * 指定校验场景
-     * @return array
-     */
-    public function scenarios() {
-        $parentScenarios = parent::scenarios();
-        $customScenarios = [
-            'add' => ['userName', 'mainUserName'],
-            'edit' => ['id', 'mainUid'],
-            'frontEdit' => ['id', 'mainUid'],
-            'autoBind' => ['userId', 'mainUid'],
-        ];
-        return array_merge($parentScenarios, $customScenarios);
-    }
-
-    public function attributeLabels() {
-        return [
-            'userName' => '会员编号',
-            'mainUserName' => '主会员编号',
-        ];
-    }
-
-    /**
-     * 初始化model
-     * @param $attributes
-     */
-    public function initModel($attributes) {
-        $this->_model = UserBind::findOne(['ID' => $this->id]);
-        if (!$this->_model) {
-            $this->addError($attributes, '数据不存在');
-        }
-        if($this->scenario=='frontEdit'){
-            if (Info::getIdCardByUserId(\Yii::$app->user->id) != Info::getIdCardByUserId($this->_model['MAIN_UID'])) {
-                $this->addError($attributes, '无权限编辑');
-            }
-        }
-    }
-
-    /**
-     * 用户名是否正确
-     * @param $attributes
-     */
-    public function isUserName($attributes) {
-        if ($this->userName == $this->mainUserName) {
-            $this->addError($attributes, '同一会员不能绑定');
-        }
-        $userInfo = UserInfo::findOneAsArray(['USER_NAME' => $this->userName]);
-        if ($userInfo && Info::isVerified(($userInfo['USER_ID']))) {
-            if (UserBind::find()->where('USER_ID=:USER_ID AND IS_DEL=0', [':USER_ID' => $userInfo['USER_ID']])->exists()) {
-                $this->addError($attributes, '填写的会员已有绑定关系');
-            }
-            $this->_uid = $userInfo['USER_ID'];
-        } else {
-            $this->addError($attributes, '会员不存在或未完成实名认证');
-        }
-
-    }
-
-    /**
-     * 主会员编号
-     * @param $attributes
-     */
-    public function isMainUserName($attributes) {
-        $userInfo = UserInfo::findOneAsArray(['USER_NAME' => $this->mainUserName]);
-        if ($userInfo && Info::isVerified(($userInfo['USER_ID']))) {
-            if (UserBind::find()->where('USER_ID=:USER_ID AND IS_DEL=0 AND MAIN_UID!=:USER_ID', [':USER_ID' => $userInfo['USER_ID']])->exists()) {
-                $this->addError($attributes, '填写的主会员已被其他主会员绑定');
-            }
-            $this->_mainUid = $userInfo['USER_ID'];
-        } else {
-            $this->addError($attributes, '主会员不存在或未完成实名认证');
-            return false;
-        }
-        if (Info::getIdCardByUserId($this->_uid) != Info::getIdCardByUserId($this->_mainUid)) {
-            $this->addError($attributes, '两个会员身份证号不一致无法绑定');
-        }
-        $idCard = Info::getIdCardByUserId($this->_mainUid);
-        //是否有其他绑定关系
-        $hasUsers = User::find()->select('ID')->where('ID!=:ID AND ID!=:IDU AND VERIFIED=1 AND ID_CARD=:ID_CARD', [':ID' => $this->_mainUid, ':IDU'=>$this->_uid, ':ID_CARD' => $idCard])->orderBy('CREATED_AT ASC')->asArray()->all();
-        if($hasUsers){
-            foreach ($hasUsers as $u){
-                if (UserBind::find()->where('USER_ID=:USER_ID AND IS_DEL=0 AND MAIN_UID!=:MAIN_UID', [':USER_ID' => $u['ID'], ':MAIN_UID'=>$this->_mainUid])->exists()) {
-                    $this->addError($attributes, '身份证'.$idCard.'有其他的绑定关系,请查证');
-                    break;
-                }
-            }
-        }
-    }
-
-    public function isMainUid($attributes) {
-        if(!Info::isVerified($this->mainUid)){
-            $this->addError($attributes, '主会员未完成实名认证');
-            return false;
-        }
-    }
-
-    public function isUserId($attributes) {
-        if(!Info::isVerified($this->userId)){
-            $this->addError($attributes, '会员未完成实名认证');
-            return false;
-        }
-    }
-
-
-
-    /**
-     * 添加
-     * @return UserBind|null
-     * @throws \yii\base\Exception
-     */
-    public function add() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $transaction = \Yii::$app->db->beginTransaction();
-        try {
-            $period = Period::instance();
-
-            // 查看主点位是否已经存在
-            if (!UserBind::find()->where('USER_ID=:USER_ID AND MAIN_UID=:MAIN_UID AND IS_DEL=0', [':USER_ID' => $this->_mainUid, ':MAIN_UID' => $this->_mainUid])->exists()) {
-                UserBind::insertOne([
-                    'USER_ID' => $this->_mainUid,
-                    'MAIN_UID' => $this->_mainUid,
-                    'PERIOD_NUM' => $period->getNowPeriodNum(),
-                    'IS_DEL' => 0,
-                    'CREATE_ADMIN' => \Yii::$app->user->id,
-                    'CREATED_AT' => Date::nowTime(),
-                ]);
-            }
-            // 会员信息表添加点位合作标识
-            UserInfo::updateAll(['IS_BIND' => 1], 'USER_ID=:USER_ID', [':USER_ID' => $this->_uid]);
-            UserInfo::updateAll(['IS_BIND' => 1, 'IS_BIND_MAIN' => 1], 'USER_ID=:USER_ID', [':USER_ID' => $this->_mainUid]);
-            // 添加会员合作点位
-            $model = new UserBind();
-            $model->USER_ID = $this->_uid;
-            $model->MAIN_UID = $this->_mainUid;
-            $model->PERIOD_NUM = $period->getNowPeriodNum();
-            $model->IS_DEL = 0;
-            $model->CREATE_ADMIN = \Yii::$app->user->id;
-            $model->CREATED_AT = Date::nowTime();
-            if (!$model->save()) {
-                throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-            }
-
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('add', $e->getMessage());
-            return null;
-        }
-        $this->adminOperateLogger->afterInsert($model);
-        $this->adminOperateLogger->clean()->save([
-            'optType' => '添加点位绑定',
-            'userId' => $model->USER_ID,
-            'userName' => Info::getUserNameByUserId($model->USER_ID),
-        ]);
-        return $model;
-    }
-
-    /**
-     * 前台编辑主点位
-     * @return null
-     * @throws \yii\db\Exception
-     */
-    public function frontEdit() {
-        if (!$this->validate()) {
-            return null;
-        }
-
-        $this->userOperateLogger->beforeUpdate($this->_model->ID,'ID',['select'=>'USER_ID,MAIN_UID']);
-        $transaction = \Yii::$app->db->beginTransaction();
-        try {
-            $model = $this->_model;
-            if ($model->MAIN_UID == $this->mainUid) {
-                throw new Exception('未做任何修改');
-            }
-            //撤销主会员
-            UserInfo::updateAll(['IS_BIND_MAIN' => 0], 'USER_ID=:USER_ID', [':USER_ID' => $model->MAIN_UID]);
-            //设置主会员
-            UserInfo::updateAll(['IS_BIND_MAIN' => 1], 'USER_ID=:USER_ID', [':USER_ID' => $this->mainUid]);
-            //更新绑定表的主会员
-            UserBind::updateAll(['MAIN_UID' => $this->mainUid, 'UPDATED_AT' => Date::nowTime(), 'UPDATE_ADMIN' => \Yii::$app->user->id], 'MAIN_UID=:MAIN_UID AND IS_DEL=0', [':MAIN_UID' => $model->MAIN_UID]);
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('frontEdit', $e->getMessage());
-            return null;
-        }
-        $this->userOperateLogger->afterUpdate($this->_model->ID,'ID',['select'=>'USER_ID,MAIN_UID']);
-
-        $this->userOperateLogger->clean()->save([
-            'optType' => '修改主点位',
-            'userId' => $model->USER_ID,
-            'userName' => Info::getUserNameByUserId($model->USER_ID),
-        ]);
-        return $model;
-    }
-
-    /**
-     * 编辑主点位
-     * @return null
-     * @throws \yii\db\Exception
-     */
-    public function edit() {
-        if (!$this->validate()) {
-            return null;
-        }
-
-        $this->adminOperateLogger->beforeUpdate($this->_model);
-
-        $transaction = \Yii::$app->db->beginTransaction();
-        try {
-            $model = $this->_model;
-            if ($model->MAIN_UID == $this->mainUid) {
-                throw new Exception('未做任何修改');
-            }
-            //撤销主会员
-            UserInfo::updateAll(['IS_BIND_MAIN' => 0], 'USER_ID=:USER_ID', [':USER_ID' => $model->MAIN_UID]);
-            //设置主会员
-            UserInfo::updateAll(['IS_BIND_MAIN' => 1], 'USER_ID=:USER_ID', [':USER_ID' => $this->mainUid]);
-            //更新绑定表的主会员
-            UserBind::updateAll(['MAIN_UID' => $this->mainUid, 'UPDATED_AT' => Date::nowTime(), 'UPDATE_ADMIN' => \Yii::$app->user->id], 'MAIN_UID=:MAIN_UID AND IS_DEL=0', [':MAIN_UID' => $model->MAIN_UID]);
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('edit', $e->getMessage());
-            return null;
-        }
-        $this->adminOperateLogger->afterUpdate(UserBind::findOne(['ID' => $this->id]));
-        $this->adminOperateLogger->clean()->save([
-            'optType' => '编辑点位绑定',
-            'userId' => $model->USER_ID,
-            'userName' => Info::getUserNameByUserId($model->USER_ID),
-        ]);
-        return $model;
-    }
-
-    public function beforeDelete($selected){
-        $this->adminOperateLogger->setIsBatch(true)->beforeDelete($selected, 'ID');
-    }
-
-    /**
-     * 删除
-     * @param $selected
-     * @throws Exception
-     */
-    public function delete($selected) {
-        foreach ($selected as $select) {
-            $userBind = UserBind::findOneAsArray('ID=:ID', [':ID' => $select], 'USER_ID,MAIN_UID');
-            //无法删除有子会员的
-            if (UserBind::find()->where('MAIN_UID=:USER_ID AND IS_DEL=0 AND USER_ID!=:USER_ID', [':USER_ID' => $userBind['USER_ID']])->exists()) {
-                throw new Exception('该主会员有子会员,无法撤销');
-            }
-            UserInfo::updateAll(['IS_BIND' => 0, 'IS_BIND_MAIN' => 0], 'USER_ID=:USER_ID', [':USER_ID' => $userBind['USER_ID']]);
-            User::updateAll(['VERIFIED' => 0], 'ID=:USER_ID', [':USER_ID' => $userBind['USER_ID']]);
-            $bindNum = UserBind::findOneAsArray('IS_DEL=0 AND MAIN_UID=:MAIN_UID', [':MAIN_UID' => $userBind['MAIN_UID']],'COUNT(*) AS NUM');
-            if (isset($bindNum['NUM']) && $bindNum['NUM'] < 2) {
-                UserBind::updateAll(['IS_DEL' => 1], 'USER_ID=:USER_ID', [':USER_ID' => $userBind['MAIN_UID']]);
-                UserInfo::updateAll(['IS_BIND' => 0, 'IS_BIND_MAIN' => 0], 'USER_ID=:USER_ID', [':USER_ID' => $userBind['MAIN_UID']]);
-            }
-        }
-        $this->adminOperateLogger->clean()->save([
-            'optType' => '撤销点位绑定',
-        ]);
-    }
-
-    /**
-     * 自动绑定点位
-     * @return UserBind|null
-     * @throws \yii\db\Exception
-     */
-    public function autoBind() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $transaction = \Yii::$app->db->beginTransaction();
-        try {
-            //判断hz
-            if (Info::isUnion($this->mainUid) && !Info::isUnion($this->userId)) {
-                $userId = $this->mainUid;
-                $this->mainUid = $this->userId;
-                $this->userId = $userId;
-            }
-
-            $period = Period::instance();
-            // 查看主点位是否已经存在
-            if (!UserBind::find()->where('USER_ID=:USER_ID AND MAIN_UID=:MAIN_UID AND IS_DEL=0', [':USER_ID' => $this->mainUid, ':MAIN_UID' => $this->mainUid])->exists()) {
-                UserBind::insertOne([
-                    'USER_ID' => $this->mainUid,
-                    'MAIN_UID' => $this->mainUid,
-                    'PERIOD_NUM' => $period->getNowPeriodNum(),
-                    'IS_DEL' => 0,
-                    'CREATE_ADMIN' => \Yii::$app->id == 'app-backendApi' ? \Yii::$app->user->id : null,
-                    'CREATED_AT' => Date::nowTime(),
-                ]);
-            }
-            // 会员信息表添加点位合作标识
-            UserInfo::updateAll(['IS_BIND' => 1], 'USER_ID=:USER_ID', [':USER_ID' => $this->userId]);
-            UserInfo::updateAll(['IS_BIND' => 1, 'IS_BIND_MAIN' => 1], 'USER_ID=:USER_ID', [':USER_ID' => $this->mainUid]);
-            // 添加会员合作点位
-            $model = new UserBind();
-            $model->USER_ID = $this->userId;
-            $model->MAIN_UID = $this->mainUid;
-            $model->PERIOD_NUM = $period->getNowPeriodNum();
-            $model->IS_DEL = 0;
-            $model->CREATE_USER = $this->userId;
-            $model->CREATED_AT = Date::nowTime();
-            if (!$model->save()) {
-                throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('autoAdd', $e->getMessage());
-            return null;
-        }
-        return $model;
-    }
-
-}

+ 0 - 269
common/models/forms/UserCloseForm.php

@@ -1,269 +0,0 @@
-<?php
-
-namespace common\models\forms;
-
-use common\helpers\Date;
-use common\components\Model;
-use common\helpers\Form;
-use common\helpers\user\Status;
-use common\models\Period;
-use common\models\User;
-use common\models\UserClose;
-use common\models\UserInfo;
-use yii\base\Exception;
-
-/**
- * Login form
- */
-class UserCloseForm extends Model {
-    public $id;
-    public $userName;
-    public $type;
-    public $isClose;
-    public $remark;
-    public $auditStatus;
-
-    private $_userId;
-    private $_userCloseModel;
-    private $_periodNum;
-    private $_closeInfo = [
-        UserClose::TYPE_GT => '关停',
-        UserClose::TYPE_TF => '停发',
-    ];
-
-    /**
-     * @inheritdoc
-     */
-    public function rules() {
-        return [
-            [['id', 'userName', 'type', 'isClose', 'remark', 'auditStatus'], 'trim'],
-            [['id', 'userName', 'type', 'isClose'], 'required'],
-            [['userName'], 'exist', 'targetClass' => UserInfo::class, 'targetAttribute' => 'USER_NAME'],
-            [['id', 'userName'], 'initModel'],
-            [['id'], 'exist', 'targetClass' => UserClose::class, 'targetAttribute' => 'ID'],
-            [['type'], 'isType'],
-            [['isClose'], 'checkClose'],
-            [['auditStatus'], 'isAuditStatus'],
-        ];
-    }
-
-    /**
-     * 指定校验场景
-     * @return array
-     */
-    public function scenarios() {
-        $parentScenarios = parent::scenarios();
-        $customScenarios = [
-            // 手动申请
-            'add' => ['userName', 'type', 'isClose', 'remark'],
-            // 自动关停
-            'auto' => ['userName', 'type', 'isClose', 'remark'],
-            // 审核关停
-            'audit' => ['id', 'auditStatus']
-        ];
-        return array_merge($parentScenarios, $customScenarios);
-    }
-
-    public function attributeLabels() {
-        return [
-            'id' => 'ID',
-            'userName' => '会员编号',
-            'type' => '类型',
-            'isClose' => '是否关停',
-            'remark' => '备注',
-        ];
-    }
-
-    /**
-     * 初始化model和userId
-     * @param $attribute
-     */
-    public function initModel($attribute) {
-        $period = Period::instance();
-        $this->_periodNum = $period->getNowPeriodNum();
-        if ($this->scenario == 'audit') {
-            $this->_userCloseModel = UserClose::findOne(['ID' => $this->id]);
-            $this->_userId = $this->_userCloseModel->USER_ID;
-        } elseif ($this->scenario == 'add' || $this->scenario == 'auto') {
-            $this->_userCloseModel = new UserClose();
-            $oneUser = UserInfo::findOneAsArray(['USER_NAME' => $this->userName], [], 'USER_ID');
-            $this->_userId = $oneUser['USER_ID'];
-            // 查看数据库中是否已经存在了该会员的申请未审核
-            $oneUserClose = UserClose::findOne(['USER_ID' => $this->_userId, 'AUDIT_STATUS' => \Yii::$app->params['auditStatus']['un']['value'], 'TYPE' => $this->type]);
-            if ($oneUserClose && $this->scenario == 'add') {
-                // 不允许重复申请
-                $this->addError($attribute, '已经存在该会员的待审核数据,请等待审核后再申请');
-            } elseif ($oneUserClose && $this->scenario == 'auto') {
-                // 如果是自动关停时,如果遇上未审核的,直接审核拒绝,防止影响自动关停的进程
-                $oneUserClose->AUDIT_STATUS = \Yii::$app->params['auditStatus']['reject']['value'];
-                $oneUserClose->AUDITED_AT = Date::nowTime();
-                $oneUserClose->save();
-            }
-        } else {
-            $this->addError($attribute, '场景不正确');
-        }
-    }
-
-    /**
-     * 关停还是停发
-     * @param $attribute
-     */
-    public function isType($attribute) {
-        if (!in_array($this->type, [UserClose::TYPE_GT, UserClose::TYPE_TF])) {
-            $this->addError($attribute, '类型不正确');
-        }
-    }
-
-    /**
-     * 校验该用户是否已经被关闭
-     * @param $attribute
-     */
-    public function checkClose($attribute) {
-        if ($this->type == UserClose::TYPE_GT) {
-            if ($this->isClose == 1 && Status::isCloseAccount($this->_userId)) {
-                $this->addError($attribute, '该会员已经被关停');
-            } elseif ($this->isClose == 0 && !Status::isCloseAccount($this->_userId)) {
-                $this->addError($attribute, '该会员没有被关停');
-            }
-        } elseif ($this->type == UserClose::TYPE_TF) {
-            if ($this->isClose == 1 && Status::isCloseBonus($this->_userId)) {
-                $this->addError($attribute, '该会员已经被停发');
-            } elseif ($this->isClose == 0 && !Status::isCloseBonus($this->_userId)) {
-                $this->addError($attribute, '该会员没有被停发');
-            }
-        }
-    }
-
-    /**
-     * 审核状态是否正确
-     * @param $attributes
-     */
-    public function isAuditStatus($attributes) {
-        if (!array_key_exists($this->auditStatus, \Yii::$app->params['auditStatus'])) {
-            $this->addError($attributes, '无效的审核状态');
-        }
-    }
-
-    /**
-     * 申请
-     * @return null
-     * @throws \yii\db\Exception
-     */
-    public function edit() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            $model = $this->_userCloseModel;
-            $model->USER_ID = $this->_userId;
-            $model->TYPE = $this->type;
-            $model->PERIOD_NUM = $this->_periodNum;
-            $model->IS_CLOSE = $this->isClose;
-            $model->REMARK = $this->remark;
-            if ($this->scenario == 'add') {
-                $model->AUDIT_STATUS = \Yii::$app->params['auditStatus']['un']['value'];
-                $model->IS_MANUAL = 1;
-                $model->ADMIN_ID = \Yii::$app->user->id;
-            } elseif ($this->scenario == 'auto') {
-                $model->AUDIT_STATUS = \Yii::$app->params['auditStatus']['true']['value'];
-                $model->AUDITED_AT = Date::nowTime();
-            } else {
-                $this->addError('setClose', '场景不正确');
-            }
-            $model->CREATED_AT = Date::nowTime();
-            if (!$model->save()) {
-                throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-            }
-            // 把商城会员表的状态改为0
-            $isCloseShopUser = false;
-            $closeShopStatus = 0;
-            if ($this->scenario == 'auto' && $this->type == UserClose::TYPE_GT && $this->isClose == 1) {
-                $isCloseShopUser = true;
-                $closeShopStatus = 0;
-            } elseif ($this->scenario == 'auto' && $this->type == UserClose::TYPE_GT && $this->isClose == 0) {
-                $isCloseShopUser = true;
-                $closeShopStatus = 1;
-            }
-            if ($isCloseShopUser) {
-                $oneUser = User::findOne(['ID' => $this->_userId]);
-                $oneUser->STATUS = $closeShopStatus;
-                if (!$oneUser->save()) {
-                    throw new Exception(Form::formatErrorsForApi($oneUser->getErrors()));
-                }
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('edit', $e->getMessage());
-            return null;
-        }
-        return $model;
-
-    }
-
-    /**
-     * 审核
-     * @return null
-     * @throws \yii\db\Exception
-     */
-    public function audit() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            $model = $this->_userCloseModel;
-            if ($this->auditStatus == 'true') {
-                $model->AUDIT_ADMIN_ID = \Yii::$app->user->id;
-                $model->AUDIT_STATUS = \Yii::$app->params['auditStatus']['true']['value'];
-                $model->AUDITED_AT = Date::nowTime();
-                if (!$model->save()) {
-                    throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-                }
-                if ($model->IS_CLOSE) {
-                    $closedAt = Date::nowTime();
-                } else {
-                    $closedAt = 0;
-                }
-                // 修改结算系统会员表的状态
-                $closeField = UserClose::TYPE_GT ? 'CLOSE_ACCOUNT' : 'CLOSE_BONUS';
-                UserInfo::updateAll([$closeField => $model->IS_CLOSE, 'CLOSE_ACCOUNT_AT' => $closedAt], 'USER_ID=:USER_ID', [':USER_ID' => $this->_userId]);
-                // 把商城会员表的状态改为0
-                $isCloseShopUser = false;
-                $closeShopStatus = 0;
-                if ($model->TYPE == UserClose::TYPE_GT && $model->IS_CLOSE == 1) {
-                    $isCloseShopUser = true;
-                    $closeShopStatus = 0;
-                } elseif ($model->TYPE == UserClose::TYPE_GT && $model->IS_CLOSE == 0) {
-                    $isCloseShopUser = true;
-                    $closeShopStatus = 1;
-                }
-                if ($isCloseShopUser) {
-                    $oneUser = User::findOne(['ID' => $this->_userId]);
-                    $oneUser->STATUS = $closeShopStatus;
-                    if (!$oneUser->save()) {
-                        throw new Exception(Form::formatErrorsForApi($oneUser->getErrors()));
-                    }
-                }
-            } elseif ($this->auditStatus == 'reject') {
-                $model->AUDIT_ADMIN_ID = \Yii::$app->user->id;
-                $model->AUDIT_STATUS = \Yii::$app->params['auditStatus']['reject']['value'];
-                $model->AUDITED_AT = Date::nowTime();
-                if (!$model->save()) {
-                    throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-                }
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError($e->getMessage());
-            return null;
-        }
-        return $model;
-    }
-
-
-}

+ 0 - 191
common/models/forms/UserConfigForm.php

@@ -1,191 +0,0 @@
-<?php
-
-namespace common\models\forms;
-
-use common\components\Model;
-use common\helpers\Cache;
-use common\helpers\Date;
-use common\helpers\Tool;
-use common\helpers\user\Balance;
-use common\helpers\user\Info;
-use common\helpers\user\Status;
-use common\libs\logging\operate\UserOperate;
-use common\models\DealType;
-use common\models\Period;
-use common\models\User;
-use common\models\UserInfo;
-use yii\db\Exception;
-
-/**
- * Login form
- */
-class UserConfigForm extends Model {
-    public $isAutoWithdraw;
-    public $allowReconsumeSms;
-
-    private $_config;
-
-    public function init() {
-        parent::init();
-        $this->userOperateLogger = new UserOperate([
-            'fetchClass' => UserInfo::class,
-        ]);
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules() {
-        return [
-            [['isAutoWithdraw', 'allowReconsumeSms'], 'required'],
-            [['isAutoWithdraw', 'allowReconsumeSms'], 'boolean'],
-            [['isAutoWithdraw'], 'isCanAutoWithdraw'],
-            [['allowReconsumeSms'], 'isAllowReconsumeSms'],
-        ];
-    }
-
-    public function attributeLabels() {
-        return [
-            'isAutoWithdraw' => '是否自动提现',
-            'allowReconsumeSms' => '开启复销短信通知',
-        ];
-    }
-
-
-    /**
-     * 指定场景
-     * @return array
-     */
-    public function scenarios() {
-        $parentScenarios = parent::scenarios();
-        $customScenarios = [
-            'autoWithdraw' => ['isAutoWithdraw'],
-            'allowReconsumeSms' => ['allowReconsumeSms'],
-        ];
-        return array_merge($parentScenarios, $customScenarios);
-    }
-
-    /**
-     * 是否可以修改自动提现
-     * @param $attribute
-     */
-    public function isCanAutoWithdraw($attribute) {
-        if (!Info::isVerified(\Yii::$app->user->id)) {
-            $this->addError($attribute, '请先实名认证');
-        }
-        $this->_config = Cache::getSystemConfig();
-        if (!$this->_config['isCanAutoWithdraw']['VALUE'] && $this->isAutoWithdraw) {
-            $this->addError('scenario', '系统关闭了自动提现');
-        }
-    }
-
-    /**
-     * 是否可以开启复销短信通知
-     * @param $attribute
-     */
-    public function isAllowReconsumeSms($attribute) {
-        $this->_config = Cache::getSystemConfig();
-        if (!$this->_config['smsOpen']['VALUE'] && $this->isAutoWithdraw) {
-            $this->addError('scenario', '系统关闭了开启复销短信通知');
-        }
-    }
-
-    /**
-     * 更新自动提现
-     * @return bool|null
-     * @throws Exception
-     */
-    public function autoWithdraw() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $this->userOperateLogger->beforeUpdate(\Yii::$app->user->id,'USER_ID',['select'=>'IS_AUTO_WITHDRAW']);
-        $transaction = \Yii::$app->db->beginTransaction();
-        try {
-            if (!UserInfo::updateAll(['IS_AUTO_WITHDRAW' => $this->isAutoWithdraw], 'USER_ID=:USER_ID', [':USER_ID' => \Yii::$app->user->id])) {
-                throw new Exception('更新个人设置失败');
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('autoWithdraw', $e->getMessage());
-            return null;
-        }
-        $this->userOperateLogger->afterUpdate(\Yii::$app->user->id,'USER_ID',['select'=>'IS_AUTO_WITHDRAW']);
-        $this->userOperateLogger->clean()->save([
-            'optType' => '开启关闭自动提现',
-            'userId' => \Yii::$app->user->id,
-            'userName' => Info::getUserNameByUserId(\Yii::$app->user->id),
-        ]);
-        return true;
-    }
-
-    /**
-     * 更新复销短信提醒
-     * @return bool|null
-     * @throws Exception
-     * @throws \yii\base\Exception
-     */
-    public function allowReconsumeSms() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $this->userOperateLogger->beforeUpdate(\Yii::$app->user->id,'USER_ID',['select'=>'ALLOW_RECONSUME_SMS,ALLOW_RECONSUME_SMS_TO']);
-        $balanceData = Balance::getLogData(\Yii::$app->user->id);
-        $beforeData = $this->userOperateLogger->saveBeforeContent;
-        $this->userOperateLogger->saveBeforeContent = array_merge($beforeData,$balanceData);
-
-        $transaction = \Yii::$app->db->beginTransaction();
-        try {
-            $userId = \Yii::$app->user->id;
-            if (!UserInfo::updateAll(['ALLOW_RECONSUME_SMS' => $this->allowReconsumeSms?$this->allowReconsumeSms:0], 'USER_ID=:USER_ID', [':USER_ID' => $userId])) {
-                throw new Exception('更新个人设置失败');
-            }
-            //开启扣费
-            $smsTo = UserInfo::findOneAsArray('USER_ID=:USER_ID', [':USER_ID' => $userId], 'ALLOW_RECONSUME_SMS_TO');
-            //如果开启并且会员短信不在有效期
-            if ($this->allowReconsumeSms && $smsTo['ALLOW_RECONSUME_SMS_TO'] < Date::nowTime()) {
-                $smsWallet = explode(",", $this->_config['smsWallet']['VALUE']);
-                $smsFee = $this->_config['smsFee']['VALUE'];
-                //获取剩余月份
-                $period = Period::instance();
-                $year = $period->getNowYear();
-                $monthLeft = Period::getMonthLeft();
-                $smsFee = Tool::formatPrice($smsFee * $monthLeft);
-                $to = Date::yearEnd();
-                foreach ($smsWallet as $item) {
-                    //1奖金钱包2现金钱包
-                    if ($item == 1) {
-                        //看余额是否充足
-                        if (Balance::getAvailableBalance($userId) < $smsFee) continue;
-                        Balance::changeUserBonus($userId, 'bonus', -abs($smsFee), ['DEAL_TYPE_ID' => DealType::SMS, 'REMARK' => $year . '年复销提醒短信服务费']);
-                        if (!UserInfo::updateAll(['ALLOW_RECONSUME_SMS_TO' => $to], 'USER_ID=:USER_ID', [':USER_ID' => $userId])) {
-                            throw new Exception('更新个人短信有效期失败');
-                        }
-                        break;
-                    } elseif ($item == 2) {
-                        throw new Exception('不存在此方式');
-                        break;
-                    }
-                }
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('allowReconsumeSms', $e->getMessage());
-            return null;
-        }
-
-        $this->userOperateLogger->afterUpdate(\Yii::$app->user->id,'USER_ID',['select'=>'ALLOW_RECONSUME_SMS,ALLOW_RECONSUME_SMS_TO']);
-        $balanceData = Balance::getLogData(\Yii::$app->user->id);
-        $afterData = $this->userOperateLogger->saveAfterContent;
-        $this->userOperateLogger->saveAfterContent = array_merge($afterData,$balanceData);
-        unset($beforeData,$afterData);
-        $this->userOperateLogger->clean()->save([
-            'optType' => '开启关闭复销短信提醒',
-            'userId' => \Yii::$app->user->id,
-            'userName' => Info::getUserNameByUserId(\Yii::$app->user->id),
-        ]);
-        return true;
-    }
-}

+ 0 - 158
common/models/forms/UserDecForm.php

@@ -1,158 +0,0 @@
-<?php
-
-namespace common\models\forms;
-
-use common\components\Model;
-use common\helpers\Date;
-use common\libs\logging\operate\AdminOperate;
-use common\models\User;
-use common\models\UserInfo;
-use yii\base\Exception;
-
-/**
- * Login form
- */
-class UserDecForm extends Model {
-    public $userIds;
-    public $isDec;
-    public $isAtlas;
-    public $isRecharge;
-
-    public function init() {
-        parent::init();
-        $this->adminOperateLogger = new AdminOperate([
-            'fetchClass' => User::class,
-        ]);
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules() {
-        return [
-            [['userIds', 'isDec', 'isAtlas', 'isRecharge'], 'trim'],
-            [['userIds'], 'required'],
-        ];
-    }
-
-    /**
-     * 指定校验场景
-     * @return array
-     */
-    public function scenarios() {
-        $parentScenarios = parent::scenarios();
-        $customScenarios = [
-            'isDec' => ['userIds', 'isDec'],
-            'isAtlas' => ['userIds', 'isAtlas'],
-            'isRecharge' => ['userIds', 'isRecharge'],
-        ];
-        return array_merge($parentScenarios, $customScenarios);
-    }
-
-    public function attributeLabels() {
-        return [
-            'userIds' => '会员ID',
-            'isDec' => '是否报单中心',
-            'isAtlas' => '是否显示图谱',
-            'isRecharge' => '是否显示充值',
-        ];
-    }
-
-    public function beforeValidate() {
-        return parent::beforeValidate();
-    }
-
-    /**
-     * 是否报单中心
-     * @return null
-     * @throws \yii\db\Exception
-     */
-    public function isDec() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $this->adminOperateLogger->setIsBatch(true)->beforeUpdate($this->userIds, 'ID',['select'=>'ID,IS_DEC']);
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            $allUidIn = implode("','", $this->userIds);
-            if (!User::updateAll(['IS_DEC' => $this->isDec ? $this->isDec : 0], "ID IN ('" . $allUidIn . "')")) {
-                throw new Exception('设置报单中心更新失败');
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            return null;
-        }
-        $this->adminOperateLogger->setIsBatch(true)->afterUpdate($this->userIds, 'ID',['select'=>'ID,IS_DEC']);
-        $this->adminOperateLogger->setBatchField('USER_ID')->clean()->save([
-            'optType' => $this->isDec ? '设置报单中心' : '取消报单中心',
-        ]);
-
-
-
-        return $this->userIds;
-    }
-
-    /**
-     * 是否显示图谱
-     * @return null
-     * @throws \yii\db\Exception
-     */
-    public function isAtlas() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $this->adminOperateLogger->setIsBatch(true)->beforeUpdate($this->userIds, 'ID',['select'=>'ID,IS_ATLAS']);
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            $allUidIn = implode("','", $this->userIds);
-            if (!User::updateAll(['IS_ATLAS' => $this->isAtlas ? $this->isAtlas : 0], "ID IN ('" . $allUidIn . "')")) {
-                throw new Exception('设置图谱更新失败');
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            return null;
-        }
-        $this->adminOperateLogger->setIsBatch(true)->afterUpdate($this->userIds, 'ID',['select'=>'ID,IS_ATLAS']);
-        $this->adminOperateLogger->setBatchField('USER_ID')->clean()->save([
-            'optType' => $this->isAtlas ? '显示图谱' : '隐藏图谱',
-        ]);
-
-
-
-        return $this->userIds;
-    }
-
-    /**
-     * 是否显示充值
-     * @return null
-     * @throws \yii\db\Exception
-     */
-    public function isRecharge() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $this->adminOperateLogger->setIsBatch(true)->beforeUpdate($this->userIds, 'ID',['select'=>'ID,IS_RECHARGE']);
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            $allUidIn = implode("','", $this->userIds);
-            if (!User::updateAll(['IS_RECHARGE' => $this->isRecharge ? $this->isRecharge : 0], "ID IN ('" . $allUidIn . "')")) {
-                throw new Exception('充值管理设置更新失败');
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            return null;
-        }
-        $this->adminOperateLogger->setIsBatch(true)->afterUpdate($this->userIds, 'ID',['select'=>'ID,IS_RECHARGE']);
-        $this->adminOperateLogger->setBatchField('USER_ID')->clean()->save([
-            'optType' => $this->isRecharge ? '显示充值' : '隐藏充值',
-        ]);
-        return $this->userIds;
-    }
-
-}

+ 50 - 428
common/models/forms/UserForm.php

@@ -2,20 +2,11 @@
 namespace common\models\forms;
 
 use common\components\Model;
-use common\helpers\Date;
-use common\helpers\Form;
-use common\helpers\snowflake\SnowFake;
-use common\helpers\user\Balance;
 use common\helpers\user\Info;
 use common\libs\logging\operate\UserOperate;
-use common\models\Period;
 use common\models\DeclarationLevel;
-use common\models\EmployLevel;
 use common\models\User;
 use common\models\UserInfo;
-use common\models\UserNetwork;
-use common\models\UserRelation;
-use yii\db\Exception;
 
 /**
  * Login form
@@ -81,21 +72,14 @@ class UserForm extends Model
             [['conUid', 'location'], 'required', 'on'=>['validateLocation', 'validateAddWithUid']],
             [['conUserName', 'location'], 'required', 'on'=>['validateLocationConName', 'validateAddWithName']],
 
-            // [['nation','realName', 'mobile', 'idCard', 'openBank', 'bankAddress', 'bankNo'], 'required', 'on'=>'modifyProfile'],
             [['nation','realName'], 'required', 'on'=>'modifyProfile'],
             [['oldPassword','verifyPassword'], 'required','on' => ['modifyPassword', 'modifyPasswordPay', 'noLoginModifyPassword']],
             [['password'], 'required','on' => ['modifyPassword', 'noLoginModifyPassword']],
             [['payPassword'], 'required','on' => ['modifyPasswordPay']],
             ['verifyPassword', 'compare', 'compareAttribute' => 'password' ,'message'=>'两次登录密码输入不一致' ,'on' => ['modifyPassword', 'noLoginModifyPassword']],
             ['verifyPassword', 'compare', 'compareAttribute' => 'payPassword' ,'message'=>'两次支付密码输入不一致' ,'on' => ['modifyPasswordPay']],
-            [['userId'], 'unique', 'targetClass'=>UserInfo::class, 'targetAttribute'=>'USER_ID', 'on' => ['addWithUserName', 'addWithUid', 'addByAdmin']],
-            [['userName'], 'unique', 'targetClass'=>UserInfo::class, 'targetAttribute'=>'USER_NAME' , 'on' => ['addWithUserName', 'addWithUid', 'addByAdmin']],
-            [['conUid'], 'exist', 'targetClass'=>UserInfo::class, 'targetAttribute'=>'USER_ID', 'on' => ['addWithUserName', 'addWithUid', 'addByAdmin']],
-            [['recUid'], 'exist', 'targetClass'=>UserInfo::class, 'targetAttribute'=>'USER_ID', 'on' => ['addWithUserName', 'addWithUid', 'addByAdmin']],
             [['conUid'], 'isConUid', 'on' => ['addWithUserName', 'addWithUid', 'addByAdmin']],
             [['recUid'], 'isRecUid', 'on' => ['addWithUserName', 'addWithUid', 'addByAdmin']],
-            [['conUserName'], 'exist', 'targetClass'=>UserInfo::class, 'targetAttribute'=>'USER_NAME', 'on' => ['addWithUserName', 'addWithUid', 'addByAdmin']],
-            [['recUserName'], 'exist', 'targetClass'=>UserInfo::class, 'targetAttribute'=>'USER_NAME', 'on' => ['addWithUserName', 'addWithUid', 'addByAdmin']],
             [['conUserName'], 'isCon', 'on' => ['addWithUserName', 'addWithUid', 'addByAdmin']],
             [['recUserName'], 'isRec', 'on' => ['addWithUserName', 'addWithUid', 'addByAdmin']],
             [['location'], 'isLocation', 'on' => ['addWithUserName', 'addWithUid', 'addByAdmin']],
@@ -109,13 +93,8 @@ class UserForm extends Model
     {
         return [
             'userId' => '会员ID',
-            'conUserName' => '接点人账号',
-            'recUserName' => '开拓人帐号',
-            'location' => '区位',
             'nation' => '民族',
-            //'realName' => '真实姓名',
             'idCard' => '身份证号',
-            //'mobile' => '手机号',
             'openBank' => '银行名称',
             'bankAddress' => '开户支行',
             'bankNo' => '银行账号',
@@ -126,410 +105,6 @@ class UserForm extends Model
         ];
     }
 
-    /**
-     * 接点人是否可以放置
-     * @param $attribute
-     * @param $params
-     */
-    public function isConUid($attribute, $params){
-        $this->_conUid = $this->conUid;
-        // 查看该接点人在安置网络中的推荐人数量是否达到上限
-        $childNum = UserNetwork::firstFloorChildNum($this->_conUid);
-        if($childNum >= 3){
-            $this->addError($attribute, '注册'.$this->userName.'时,接点人'.$this->conUserName.'点位已满无法继续添加');
-        }
-    }
-
-    /**
-     * 推荐人是否可用
-     * @param $attribute
-     * @param $params
-     */
-    public function isRecUid($attribute, $params){
-        $this->_recUid = $this->recUid;
-        // 查看该开拓者推荐的第一层人的数量
-//        $childNum = UserRelation::firstFloorChildNum($this->_recUid);
-//        if($childNum === 0){
-//            // 必须放在自己的左区
-//            if($this->location != 1){
-//                $this->addError($attribute, '开拓的第一人必须放在自己的一市场');
-//            }
-//        }
-    }
-
-    /**
-     * 接点人是否可以放置
-     * @param $attribute
-     * @param $params
-     */
-    public function isCon($attribute, $params){
-        // 根据账号找到接点人
-        $oneConUserInfo = UserInfo::findOneAsArray('USER_NAME=:USER_NAME', [':USER_NAME'=>$this->conUserName]);
-        if($oneConUserInfo){
-            $this->_conUid = $oneConUserInfo['USER_ID'];
-            // 查看该接点人在安置网络中的推荐人数量是否达到上限
-            $childNum = UserNetwork::firstFloorChildNum($this->_conUid);
-            if($childNum >= 3){
-                $this->addError($attribute, $this->userName.'的接点人'.$this->conUserName.'点位已满无法继续添加');
-            }
-        } else {
-            $this->addError($attribute, '注册'.$this->userName.'时,接点人'.$this->conUserName.'帐号无效');
-        }
-    }
-
-    /**
-     * 推荐人是否可用
-     * @param $attribute
-     * @param $params
-     */
-    public function isRec($attribute, $params){
-        // 根据账号找到开拓人
-        $oneRecUserInfo = User::findOneAsArray('USER_NAME=:USER_NAME', [':USER_NAME'=>$this->recUserName]);
-        if($oneRecUserInfo && $oneRecUserInfo['STATUS']){
-            $this->_recUid = $oneRecUserInfo['ID'];
-            // 取消开拓的第一人必须放在自己的安置网下左区的需求
-//            if($this->scenario != 'addByAdmin'){
-//                // 查看该开拓者推荐的第一层人的数量
-//                $childNum = UserRelation::firstFloorChildNum($this->_recUid);
-//                if($childNum === 0){
-//                    // 必须放在自己的左区
-//                    if($this->location != 1 && $this->scenario != 'validateRecName'){
-//                        $this->addError($attribute, '注册'.$this->userName.'时,开拓人'.$this->recUserName.'开拓的第一人必须放在自己的安置网络下的左区');
-//                    }
-//                }
-//            }
-        } else {
-            $this->addError($attribute, '注册'.$this->userName.'时,开拓人'.$this->recUserName.'帐号无效或未激活');
-        }
-    }
-
-    /**
-     * 区位是否可用
-     * @param $attribute
-     * @param $params
-     */
-    public function isLocation($attribute, $params){
-        // 查看该接点人下面所有的子会员
-        $allChildUser = UserNetwork::getFirstFloorChildren($this->_conUid);
-        if($allChildUser){
-            $isLocation = [1=>false, 2=>false, 3=>false];
-            foreach($allChildUser as $child){
-                $isLocation[$child['RELATIVE_LOCATION']] = true;
-                if($child['RELATIVE_LOCATION'] == $this->location){
-                    $this->addError($attribute, '注册'.$this->userName.'时,'.$this->conUserName.'的区位【'.$this->location.'】已经存在会员');
-                }
-            }
-            // 第二区不能空点,必须要有会员才能注册到第三区
-//            if($this->location == 3 && $isLocation[2] === false){
-//                $this->addError($attribute, '注册'.$this->userName.'到'.$this->conUserName.'的第三区时,'.$this->conUserName.'的第二区不能空点');
-//            }
-        } else {
-//            if($this->location != 1 && $this->scenario != 'addByAdmin'){
-//                $this->addError($attribute, '注册'.$this->userName.'时,接点人'.$this->conUserName.'下的第一个区位必须选择左区');
-//            }
-        }
-    }
-
-    /**
-     * 校验注册PV必须要大于最低级别要求
-     * @param $attribute
-     * @param $params
-     */
-    public function isMinDecLevel($attribute, $params){
-        // 获取排序为2的报单级别
-        $decLevel = DeclarationLevel::getLevelFromSort(2);
-        if($this->zcPv < $decLevel['PERF']){
-            $this->addError($attribute, '注册'.$this->userName.'时,注册PV低于最低级别要求,不能报首购单');
-        }
-    }
-
-    /**
-     * 同一身份证号是否在相同网络
-     * @param $attribute
-     */
-    public function isSameNetwork($attribute){
-        // 新加入会员的身份证号对应网内的其他会员
-        $otherUser = User::find()->where("ID_CARD=:ID_CARD AND ID<>:ID AND IS_UNION=0 AND DELETED=0 AND (ID_CARD_PREFIX IS NULL OR ID_CARD_PREFIX='')", [':ID_CARD'=>$this->idCard, ':ID'=>$this->userId])->select('ID')->asArray()->all();
-        // 拿到所有的批量报单数据
-        foreach($this->allData as $decData){
-            if($decData['insertUserIdCard'] == $this->idCard){
-                $otherUser[] = ['ID'=>$decData['toUserId']];
-            }
-        }
-        // 从多轨网络里面找到这些会员的最顶层会员
-        if($otherUser){
-            $otherUserIds = [];
-            foreach($otherUser as $userId){
-                $otherUserIds[] = $userId['ID'];
-            }
-            $otherUserIdsStr = implode("','", $otherUserIds);
-            $otherUserIdsStr = "'".$otherUserIdsStr."'";
-            $sameIdCardOtherTopUser = UserInfo::find()->where('USER_ID IN ('.$otherUserIdsStr.')')->orderBy('NETWORK_DEEP ASC')->asArray()->one();
-            if($sameIdCardOtherTopUser){
-                // 通过这个顶层会员查看新报单会员的接点人是不是他的下级
-                if(!UserNetwork::find()->where('PARENT_UID=:PARENT_UID AND USER_ID=:USER_ID', [':PARENT_UID'=>$sameIdCardOtherTopUser['USER_ID'], ':USER_ID'=>$this->_conUid])->exists()){
-                    // 如果不存在的话,就看这个接点人是不是这个顶层的会员
-                    if($this->_conUid != $sameIdCardOtherTopUser['USER_ID']){
-                        $this->addError($attribute, '注册'.$this->userName.'时,同一身份证号会员必须在同一网体内');
-                    }
-                }
-            }
-        }
-    }
-
-    /**
-     * 添加会员
-     * @return UserInfo|null
-     * @throws Exception
-     */
-    public function add(){
-        if(!$this->validate()){
-            return null;
-        }
-        $insertUid = $this->userId;
-        $insertUserName = $this->userName;
-        $zcPv = $this->zcPv;
-        $conUid = $this->_conUid;
-        $recUid = $this->_recUid;
-        $location = $this->location;
-
-//        $db = \Yii::$app->db;
-//        $transaction = $db->beginTransaction();
-        try{
-            $periodObj = Period::instance();
-            $nowPeriodNum = $periodObj->getNowPeriodNum();
-            // 查找接点人的体系信息
-            $conUserInfo = UserInfo::find()->where('USER_ID=:USER_ID', [':USER_ID'=>$conUid])->asArray()->one();
-            // 加入会员信息
-            $userInfoModel = new UserInfo();
-            $userInfoModel->USER_ID = $insertUid;
-            $userInfoModel->USER_NAME = $insertUserName;
-            $userInfoModel->ZC_PV = $zcPv;
-            $userInfoModel->ZC_AMOUNT = $this->zcAmount;
-            $userInfoModel->CON_UID = $conUid;
-            $userInfoModel->REC_UID = $recUid;
-            $userInfoModel->SYSTEM_ID = $conUserInfo['SYSTEM_ID'];
-            //$userInfoModel->PERIOD_NUM = $nowPeriodNum;
-            $userInfoModel->CREATED_AT = Date::nowTime();
-            $userInfoModel->HIGHEST_EMP_LV = EmployLevel::getDefaultLevelId();
-            $userInfoModel->ALLOW_TRANSFER = 1;
-            $userInfoModel->HIGHEST_EMP_LV_PERIOD = $nowPeriodNum;
-            $userInfoModel->TRANSFER_PROP = 100.00;
-            $userInfoModel->IS_GROUP_LEADER = 0;
-            $userInfoModel->GROUP_LEADER_AT = 0;
-            if(!$userInfoModel->save()){
-                throw new Exception('会员信息更新失败');
-            }
-            // 安置关系
-            $this->_addToNetwork();
-            // 开拓关系
-            $this->_addToRelation();
-            // 把会员的网络深度也追加上
-            $userInfoModel->NETWORK_DEEP = $this->_conTopDeep;
-            $userInfoModel->RELATION_DEEP = $this->_recTopDeep;
-            if(!$userInfoModel->save()){
-                throw new Exception('会员网络深度更新失败');
-            }
-            // 清空安置网络和开拓网络的顶点和顶点深度的数值
-            $this->_conTopUid = null;
-            $this->_conTopDeep = null;
-            $this->_recTopUid = null;
-            $this->_recTopDeep = null;
-
-//            $transaction->commit();
-            return $userInfoModel;
-        } catch (Exception $e){
-//            $transaction->rollBack();
-            $this->addError('userId', $e->getMessage());
-            //echo $e->getMessage().PHP_EOL;
-            return null;
-        }
-    }
-
-    /**
-     * 添加会员
-     * @param $nowPeriodNum
-     * @return boolean
-     */
-    public function addForImport($nowPeriodNum){
-        $insertUid = $this->userId;
-        $insertUserName = $this->userName;
-        $zcPv = $this->zcPv;
-        $conUid = $this->conUid;
-        $recUid = $this->recUid;
-        try{
-            // 查找接点人的体系信息
-            // 加入会员信息
-            $insertData = [
-                'USER_ID' => $insertUid,
-                'USER_NAME' => $insertUserName,
-                'ZC_PV' => $zcPv,
-                'ZC_AMOUNT' => $this->zcAmount,
-                'CON_UID' => $conUid,
-                'REC_UID' => $recUid,
-                'SYSTEM_ID' => "",
-                'CREATED_AT' => time(),
-                'HIGHEST_EMP_LV' => "",
-                'HIGHEST_EMP_LV_PERIOD' => $nowPeriodNum,
-                'TRANSFER_PROP' => 100.00,
-                'IS_GROUP_LEADER' => 0,
-                'GROUP_LEADER_AT' => 0,
-            ];
-            UserInfo::insertOne($insertData);
-            unset($insertData);
-            // 安置关系
-            $this->_addToNetworkForImport();
-            // 开拓关系
-            //$this->_addToRelationForImport();
-            // 把会员的网络深度也追加上
-            UserInfo::updateAll([
-                "NETWORK_DEEP" => $this->_conTopDeep,
-                //"RELATION_DEEP" => $this->_recTopDeep,
-            ], "USER_ID='{$insertUid}'");
-            // 清空安置网络和开拓网络的顶点和顶点深度的数值
-            $this->_conTopUid = null;
-            $this->_conTopDeep = null;
-            $this->_recTopUid = null;
-            $this->_recTopDeep = null;
-
-            unset($insertUid, $insertUserName, $conUid, $recUid);
-            return true;
-        } catch (Exception $e){
-            $this->addError('userId', $e->getMessage());
-            return false;
-        }
-    }
-
-    /**
-     * 加入安置网络
-     * @throws Exception
-     */
-    private function _addToNetworkForImport(){
-        //获取上级的点位信息
-        $conNetInfo = UserNetwork::findOneAsArray(['USER_ID'=>$this->conUid]);
-        if( !$conNetInfo ) {
-            throw new Exception('接点人信息不存在');
-        }
-        $this->_conTopUid = $conNetInfo['TOP_UID'];
-        $this->_conTopDeep = $conNetInfo['TOP_DEEP'] + 1;
-        // 加入安置网络关系
-        $insertData = [
-            'ID' => SnowFake::instance()->generateId(),
-            "USER_ID"  => $this->userId,
-            "PARENT_UID"  => $this->conUid,
-            "LOCATION_TAG"  => $conNetInfo['LOCATION_TAG'] . $this->location,
-            "RELATIVE_LOCATION"  => $this->location,
-            "TOP_UID"  => $conNetInfo['TOP_UID'],
-            "TOP_DEEP"  => $conNetInfo['TOP_DEEP'] + 1,
-            "PARENT_UIDS"  => $conNetInfo['PARENT_UIDS'] . ',' . $this->conUid,
-            "CREATED_AT"  => time(),
-        ];
-        UserNetwork::insertOne($insertData);
-
-        if(!UserInfo::updateAllCounters(['CON_NUM'=>1], "USER_ID=:USER_ID", [':USER_ID'=>$this->conUid])){
-            throw new Exception('会员安置关系下级节点数量更新失败');
-        }
-    }
-
-    /**
-     * 加入安置网络
-     * @throws Exception
-     */
-    private function _addToNetwork(){
-        //获取上级的点位信息
-        $conNetInfo = UserNetwork::findOneAsArray(['USER_ID'=>$this->_conUid]);
-        if( !$conNetInfo ) {
-            throw new Exception('接点人信息不存在');
-        }
-        $this->_conTopUid = $conNetInfo['TOP_UID'];
-        $this->_conTopDeep = $conNetInfo['TOP_DEEP'] + 1;
-        // 加入安置网络关系
-        if( $conNetInfo['PARENT_UIDS'] ) {
-            $parentUids = $conNetInfo['PARENT_UIDS'] . ',' . $this->_conUid;
-        }else {
-            $parentUids = $this->_conUid;
-        }
-        $insertData = [
-            'ID' => SnowFake::instance()->generateId(),
-            "USER_ID"  => $this->userId,
-            "PARENT_UID"  => $this->_conUid,
-            "LOCATION_TAG"  => $conNetInfo['LOCATION_TAG'] . $this->location,
-            "RELATIVE_LOCATION"  => $this->location,
-            "TOP_UID"  => $conNetInfo['TOP_UID'],
-            "TOP_DEEP"  => $conNetInfo['TOP_DEEP'] + 1,
-            "PARENT_UIDS"  => $parentUids,
-            "CREATED_AT"  => time(),
-        ];
-        UserNetwork::insertOne($insertData);
-
-        if(!UserInfo::updateAllCounters(['CON_NUM'=>1], "USER_ID=:USER_ID", [':USER_ID'=>$this->_conUid])){
-            throw new Exception('会员安置关系下级节点数量更新失败');
-        }
-    }
-
-    /**
-     * 加入开拓网络
-     * @throws Exception
-     */
-    private function _addToRelationForImport(){
-        //获取上级的推荐信息
-        $conRelationInfo = UserRelation::findOneAsArray(['USER_ID'=>$this->recUid]);
-        if( !$conRelationInfo ) {
-            throw new Exception('推荐人信息不存在');
-        }
-        $this->_recTopUid = $conRelationInfo['TOP_UID'];
-        $this->_recTopDeep = $conRelationInfo['TOP_DEEP'] + 1;
-        // 加入推荐网络关系
-        $insertData = [
-            'ID' => SnowFake::instance()->generateId(),
-            "USER_ID"  => $this->userId,
-            "PARENT_UID"  => $this->recUid,
-            "TOP_UID"  => $conRelationInfo['TOP_UID'],
-            "TOP_DEEP"  => $conRelationInfo['TOP_DEEP'] + 1,
-            "PARENT_UIDS"  => $conRelationInfo['PARENT_UIDS'] . ',' . $this->recUid,
-            "CREATED_AT"  => time(),
-        ];
-        UserRelation::insertOne($insertData);
-
-        if(!UserInfo::updateAllCounters(['REC_NUM'=>1], "USER_ID=:USER_ID", [':USER_ID'=>$this->recUid])){
-            throw new Exception('会员开拓关系下级节点数量更新失败');
-        }
-    }
-
-    /**
-     * 加入开拓网络
-     * @throws Exception
-     */
-    private function _addToRelation(){
-        //获取上级的推荐信息
-        $conRelationInfo = UserRelation::findOneAsArray(['USER_ID'=>$this->_recUid]);
-        if( !$conRelationInfo ) {
-            throw new Exception('推荐人信息不存在');
-        }
-        $this->_recTopUid = $conRelationInfo['TOP_UID'];
-        $this->_recTopDeep = $conRelationInfo['TOP_DEEP'] + 1;
-        if( $conRelationInfo['PARENT_UIDS'] ) {
-            $parentUids = $conRelationInfo['PARENT_UIDS'] . ',' . $this->_recUid;
-        }else {
-            $parentUids = $this->_recUid;
-        }
-        // 加入推荐网络关系
-        $insertData = [
-            'ID' => SnowFake::instance()->generateId(),
-            "USER_ID"  => $this->userId,
-            "PARENT_UID"  => $this->_recUid,
-            "TOP_UID"  => $conRelationInfo['TOP_UID'],
-            "TOP_DEEP"  => $conRelationInfo['TOP_DEEP'] + 1,
-            "PARENT_UIDS"  => $parentUids,
-            "CREATED_AT"  => time(),
-        ];
-        UserRelation::insertOne($insertData);
-
-        if(!UserInfo::updateAllCounters(['REC_NUM'=>1], "USER_ID=:USER_ID", [':USER_ID'=>$this->_recUid])){
-            throw new Exception('会员开拓关系下级节点数量更新失败');
-        }
-    }
-
     /**
      * 修改个人资料
      * @return User|null
@@ -543,9 +118,6 @@ class UserForm extends Model
         $uid = \Yii::$app->user->id;
         $model = User::findOne(['ID'=>$uid]);
         $model->NATION = $this->nation;
-        //$model->REAL_NAME = $this->realName;
-        //$model->MOBILE = $this->mobile;
-        //$model->ID_CARD = $this->idCard;
         $model->OPEN_BANK = $this->openBank;
         $model->BANK_NO = $this->bankNo;
         $model->BANK_ADDRESS = $this->bankAddress;
@@ -631,4 +203,54 @@ class UserForm extends Model
         return true;
     }
 
+    /**
+     * @param $attribute
+     * @param $params
+     */
+    public function isConUid($attribute, $params){
+        $this->_conUid = $this->conUid;
+    }
+
+     /**
+     * @param $attribute
+     * @param $params
+     */
+    public function isRecUid($attribute, $params){
+
+        $this->_recUid = $this->recUid;
+    }
+
+    /**
+     * @param $attribute
+     * @param $params
+     */
+    public function isCon($attribute, $params){
+        
+    }
+
+    /**
+     * @param $attribute
+     * @param $params
+     */
+    public function isRec($attribute, $params){
+        $this->_recUid = $this->recUid;
+        
+    }
+
+    /**
+     * @param $attribute
+     * @param $params
+     */
+    public function isLocation($attribute, $params){
+        
+    }
+
+    /**
+     * 校验注册PV必须要大于最低级别要求
+     * @param $attribute
+     * @param $params
+     */
+    public function isMinDecLevel($attribute, $params){
+        
+    }
 }

+ 0 - 91
common/models/forms/UserGroupForm.php

@@ -1,91 +0,0 @@
-<?php
-
-namespace common\models\forms;
-
-use common\components\Model;
-use common\helpers\Date;
-use common\libs\logging\operate\AdminOperate;
-use common\models\User;
-use common\models\UserInfo;
-use yii\base\Exception;
-
-/**
- * Login form
- */
-class UserGroupForm extends Model {
-    public $userIds;
-    public $isGroup;
-
-    public function init() {
-        parent::init();
-        $this->adminOperateLogger = new AdminOperate([
-            'fetchClass' => UserInfo::class,
-        ]);
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules() {
-        return [
-            [['userIds', 'isGroup'], 'trim'],
-            [['userIds'], 'required'],
-        ];
-    }
-
-    /**
-     * 指定校验场景
-     * @return array
-     */
-    public function scenarios() {
-        $parentScenarios = parent::scenarios();
-        $customScenarios = [
-            'group' => ['userIds', 'isGroup'],
-        ];
-        return array_merge($parentScenarios, $customScenarios);
-    }
-
-    public function attributeLabels() {
-        return [
-            'userIds' => '会员ID',
-            'isGroup' => '是否团队领导人',
-        ];
-    }
-
-    public function beforeValidate() {
-        return parent::beforeValidate();
-    }
-
-    /**
-     * 是否团队领导人
-     * @return null
-     * @throws \yii\db\Exception
-     */
-    public function group() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $this->adminOperateLogger->setIsBatch(true)->beforeUpdate($this->userIds, 'USER_ID',['select'=>'USER_ID,IS_GROUP_LEADER,GROUP_LEADER_AT']);
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            $allUidIn = implode("','", $this->userIds);
-            if (!UserInfo::updateAll(['IS_GROUP_LEADER' => $this->isGroup ? $this->isGroup : 0, 'GROUP_LEADER_AT' => Date::nowTime()], "USER_ID IN ('" . $allUidIn . "')")) {
-                throw new Exception('团队领导人更新失败');
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            return null;
-        }
-        $this->adminOperateLogger->setIsBatch(true)->afterUpdate($this->userIds, 'USER_ID',['select'=>'USER_ID,IS_GROUP_LEADER,GROUP_LEADER_AT']);
-        $this->adminOperateLogger->setBatchField('USER_ID')->clean()->save([
-            'optType' => $this->isGroup ? '设置团队领导人' : '取消团队领导人',
-        ]);
-
-
-
-        return $this->userIds;
-    }
-
-}

+ 0 - 625
common/models/forms/UserStatusForm.php

@@ -1,625 +0,0 @@
-<?php
-
-namespace common\models\forms;
-
-use common\helpers\Cache;
-use common\helpers\Date;
-use common\components\Model;
-use common\helpers\Form;
-use common\helpers\Tool;
-use common\helpers\user\Balance;
-use common\helpers\user\Info;
-use common\helpers\user\Status;
-use common\libs\logging\operate\AdminOperate;
-use common\models\DealType;
-use common\models\PerfPeriod;
-use common\models\Period;
-use common\models\EmployLevel;
-use common\models\UserWallet;
-use common\models\User;
-use common\models\UserBind;
-use common\models\UserBonus;
-use common\models\UserClose;
-use common\models\UserInfo;
-use common\models\UserPerf;
-use common\models\UserStatusAudit;
-use common\models\Withdraw;
-use yii\base\Exception;
-
-/**
- * Login form
- */
-class UserStatusForm extends Model {
-    public $id;
-    public $userName;
-    public $statusValue;
-    public $remark;
-    public $auditStatus;
-    public $isPeriodAddT;
-    public $addTPeriodNum;
-    public $isPeriodOpen;
-    public $openPeriodNum;
-    public $userId;
-    public $periodNum;
-    public $userIds;
-    public $isOperating;
-
-    private $_userId;
-    private $_userStatusModel;
-    private $_userModel;
-    private $_periodNum;
-
-    const STATUS_NORMAL = 1;
-    const STATUS_LOGOUT = 2;//注销
-    const STATUS_BLACKLIST = 3;//黑名单
-    const STATUS_STOP_SEND = 4;//停发
-    const STATUS_CLOSE = 9;//永久关停
-
-    public function init()
-    {
-        parent::init();
-        $this->adminOperateLogger = new AdminOperate([
-            'fetchClass' => UserStatusAudit::class,
-        ]);
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules() {
-        return [
-            [['id', 'userName', 'statusValue', 'remark', 'auditStatus', 'isPeriodAddT', 'addTPeriodNum', 'isPeriodOpen', 'openPeriodNum', 'userIds', 'isOperating', 'userId', 'periodNum'], 'trim'],
-            [['id', 'userName', 'statusValue', 'auditStatus', 'userIds'], 'required'],
-            [['userName'], 'exist', 'targetClass' => UserInfo::class, 'targetAttribute' => 'USER_NAME'],
-            [['id'], 'exist', 'targetClass' => UserStatusAudit::class, 'targetAttribute' => 'ID'],
-            [['statusValue'], 'isStatus'],
-            [['auditStatus'], 'isAuditStatus'],
-        ];
-    }
-
-    /**
-     * 指定校验场景
-     * @return array
-     */
-    public function scenarios() {
-        $parentScenarios = parent::scenarios();
-        $customScenarios = [
-            // 手动申请
-            'add' => ['userName', 'statusValue', 'remark', 'isPeriodAddT', 'addTPeriodNum', 'isPeriodOpen', 'openPeriodNum'],
-            // 审核
-            'audit' => ['id', 'auditStatus', 'remark', 'isPeriodAddT', 'addTPeriodNum', 'isPeriodOpen', 'openPeriodNum'],
-            // 调整是否运作
-            'operating' => ['userIds', 'isOperating'],
-            'autoClose' => ['userId'],
-            'clearWallet' => ['remark'],
-        ];
-        return array_merge($parentScenarios, $customScenarios);
-    }
-
-    public function attributeLabels() {
-        return [
-            'id' => 'ID',
-            'userName' => '会员编号',
-            'statusValue' => '调整状态',
-            'remark' => '备注',
-            'auditStatus' => '审核状态',
-            'isPeriodAddT' => '是否立即加T',
-            'addTPeriodNum' => '加T的期数',
-            'isPeriodOpen' => '是否马上开通',
-            'openPeriodNum' => '开通的期数',
-            'userIds' => '会员ID',
-            'isOperating' => '是否运作',
-        ];
-    }
-
-    public function beforeValidate() {
-        // 调整是否运作不走初始化流程
-        if ($this->scenario == 'add' || $this->scenario == 'audit' || $this->scenario == 'autoClose' ) {
-            $this->initModel();
-        }
-        return parent::beforeValidate();
-    }
-
-    /**
-     * 初始化model和userId
-     */
-    public function initModel() {
-        $period = Period::instance();
-        $this->_periodNum = $period->getNowPeriodNum();
-        if ($this->scenario == 'audit') {
-            $this->_userStatusModel = UserStatusAudit::findOne(['ID' => $this->id]);
-            $this->_userId = $this->_userStatusModel->USER_ID;
-        } elseif ($this->scenario == 'add') {
-            $this->_userStatusModel = new UserStatusAudit();
-            $oneUser = UserInfo::findOneAsArray(['USER_NAME' => $this->userName], [], 'USER_ID');
-            $this->_userId = $oneUser['USER_ID'];
-            // 查看数据库中是否已经存在了该会员的申请未审核
-            $oneUserStatus = UserStatusAudit::findOne(['USER_ID' => $this->_userId, 'AUDIT_STATUS' => \Yii::$app->params['auditStatus']['un']['value']]);
-            if ($oneUserStatus && $this->scenario == 'add') {
-                // 不允许重复申请
-                $this->addError('initModel', '已经存在该会员的待审核数据,请等待审核后再申请');
-            }
-            // 查看,如果数据库中存在一条已审核,并且是关停转开通,并且是按照期数开通,并且是大于当前期数,则提示存在待开通状态,不能申请
-            if (UserStatusAudit::find()->where('USER_ID=:USER_ID AND IS_PERIOD_OPEN=1 AND OPEN_PERIOD_NUM>:NOW_PERIOD_NUM AND STATUS_VALUE=:STATUS_VALUE', [':USER_ID' => $this->_userId, ':NOW_PERIOD_NUM' => $this->_periodNum, ':STATUS_VALUE' => self::STATUS_NORMAL])->exists()) {
-                $this->addError('initModel', '该会员处于到期等待开通状态,不能修改其他状态');
-            }
-        } else {
-            $this->addError('initModel', '场景不正确');
-        }
-        $this->_userModel = User::findOne(['ID' => $this->_userId]);
-    }
-
-    /**
-     * 状态类型校验
-     * @param $attribute
-     */
-    public function isStatus($attribute) {
-        if (!array_key_exists($this->statusValue, \Yii::$app->params['userStatus'])) {
-            $this->addError($attribute, '类型不正确');
-        }
-        // 会员当前状态
-        if ($this->_userModel['STATUS'] == $this->statusValue) {
-            $this->addError($attribute, '调整状态与调整前状态一致,无需提交');
-        }
-        $period = Period::instance();
-        $nowPeriodNum = $period->getNowPeriodNum();
-        // 只有注销状态才需要校验是否立即加T
-        if ($this->statusValue == self::STATUS_LOGOUT || $this->statusValue == self::STATUS_STOP_SEND) {
-            if ($this->isPeriodAddT && $this->addTPeriodNum <= $nowPeriodNum) {
-                $this->addError($attribute, '加T的期数不能小于当前期数');
-            }
-        }
-        // 从关停状态改为正常状态需要判断开通期数不能小于当前期数
-        if ($this->_userModel['STATUS'] == self::STATUS_CLOSE && $this->statusValue == self::STATUS_NORMAL) {
-            if ($this->isPeriodOpen && $this->openPeriodNum <= $nowPeriodNum) {
-                $this->addError($attribute, '开通的期数不能小于当前的期数');
-            }
-        }
-    }
-
-    /**
-     * 审核状态是否正确
-     * @param $attributes
-     */
-    public function isAuditStatus($attributes) {
-        if (!array_key_exists($this->auditStatus, \Yii::$app->params['auditStatus'])) {
-            $this->addError($attributes, '无效的审核状态');
-        }
-    }
-
-    /**
-     * 申请
-     * @return null
-     * @throws \yii\db\Exception
-     */
-    public function add() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            // 获取会员当前的状态
-            $oriStatus = Status::getStatus($this->_userId);
-            $model = $this->_userStatusModel;
-            $model->USER_ID = $this->_userId;
-            $model->STATUS_VALUE = $this->statusValue;
-            $model->ORI_VALUE = $oriStatus;
-            $model->PERIOD_NUM = $this->_periodNum;
-            $model->AUDIT_STATUS = \Yii::$app->params['auditStatus']['un']['value'];
-            $model->IS_PERIOD_ADD_T = $this->isPeriodAddT ? $this->isPeriodAddT : 0;
-            $model->ADD_T_PERIOD_NUM = $this->addTPeriodNum;
-            $model->IS_PERIOD_OPEN = $this->isPeriodOpen ? $this->isPeriodOpen : 0;
-            $model->OPEN_PERIOD_NUM = $this->openPeriodNum;
-            $model->CREATE_REMARK = $this->remark;
-            $model->CREATE_ADMIN = \Yii::$app->user->id;
-            $model->CREATED_AT = Date::nowTime();
-            if (!$model->save()) {
-                throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('edit', $e->getMessage());
-            return null;
-        }
-
-        // 记录日志
-        $this->adminOperateLogger->afterInsert($model)->clean()->save([
-            'optType' => '申请修改会员状态',
-            'userId' => $model->USER_ID,
-            'userName' => Info::getUserNameByUserId($model->USER_ID),
-            'remark' => $model->CREATE_REMARK,
-        ]);
-
-        return $model;
-
-    }
-
-    /**
-     * 审核
-     * @return null
-     * @throws \yii\db\Exception
-     */
-    public function audit() {
-        if (!$this->validate()) {
-            return null;
-        }
-
-        // 日志记录操作前的数据
-        $this->adminOperateLogger->beforeUpdate($this->_userStatusModel);
-
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            $model = $this->_userStatusModel;
-            if ($this->auditStatus == 'true') {
-                // 获取该会员的当前的聘级和报单级别
-                $model->DEC_LV = Info::getDecLv($model->USER_ID);
-                $model->EMP_LV = Info::getEmpLv($model->USER_ID);
-                // 获取当前会员的各个区的业绩
-                $userPerf = UserPerf::findOneAsArray('USER_ID=:USER_ID', [':USER_ID' => $model->USER_ID]);
-                $model->PV_1L = $userPerf['PV_1L'];
-                $model->PV_2L = $userPerf['PV_2L'];
-                $model->PV_3L = $userPerf['PV_3L'];
-                $model->PV_4L = $userPerf['PV_4L'];
-                $model->PV_5L = $userPerf['PV_5L'];
-                // 获取当前会员的最新已挂网的会员的剩余业绩
-                $maxPeriodNum = Period::sentMaxPeriodNum();
-                $perfPeriod = PerfPeriod::findOne(['USER_ID' => $model->USER_ID, 'PERIOD_NUM' => $maxPeriodNum]);
-                $model->SURPLUS_1L = $perfPeriod['SURPLUS_1L'] ?? 0;
-                $model->SURPLUS_2L = $perfPeriod['SURPLUS_2L'] ?? 0;
-                $model->SURPLUS_3L = $perfPeriod['SURPLUS_3L'] ?? 0;
-                $model->SURPLUS_4L = $perfPeriod['SURPLUS_4L'] ?? 0;
-                $model->SURPLUS_5L = $perfPeriod['SURPLUS_5L'] ?? 0;
-                $model->IS_PERIOD_ADD_T = $this->isPeriodAddT ? $this->isPeriodAddT : 0;
-                $model->ADD_T_PERIOD_NUM = $this->addTPeriodNum ? $this->addTPeriodNum : null;
-                $model->IS_PERIOD_OPEN = $this->isPeriodOpen ? $this->isPeriodOpen : 0;
-                $model->OPEN_PERIOD_NUM = $this->openPeriodNum;
-                $model->CREATE_REMARK = $this->remark;
-                $model->AUDIT_ADMIN = \Yii::$app->user->id;
-                $model->AUDIT_STATUS = \Yii::$app->params['auditStatus']['true']['value'];
-                $model->AUDITED_AT = Date::nowTime();
-                if (!$model->save()) {
-                    throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-                }
-                // 把商城会员表的状态修改
-                // 如果是从关停修改为正常状态,并且不是马上开通的先不开通,等待封期时,到那一期再给会员开通,其他的情况现在就调整状态
-                $userModel = $this->_userModel;
-                $beforeStatus = $userModel->STATUS;
-                if (!($model->ORI_VALUE == self::STATUS_CLOSE && $model->STATUS_VALUE == self::STATUS_NORMAL && $model->IS_PERIOD_OPEN)) {
-                    $userModel->STATUS = $model->STATUS_VALUE;
-                    $userModel->STATUS_AT = Date::nowTime();
-                    if (!$userModel->save()) {
-                        throw new Exception(Form::formatErrorsForApi($userModel->getErrors()));
-                    }
-                }
-                if (!($model->ORI_VALUE == self::STATUS_CLOSE && $model->IS_PERIOD_OPEN)) {
-                    UserWallet::updateAll(['CLEAR_BY_CLOSED_AT'=> 0], 'USER_ID=:USER_ID', [':USER_ID' => $model->USER_ID]);
-                }
-                // 开始会员状态相关的后续功能
-                // 注销立即清空全部会员所有钱包余额、奖金余额、大区剩余业绩、和各区业绩,自动提现改为手动提现
-                // 注销需要设置立即加T,还是按照设定期数加T,(思路:假设115封期的时候先从会员状态审核表查看116期,批量更新116期需要加T的会员的身份证表前缀为字母T)
-                // 设置成黑名单后自动提现改为手动提现
-                // 停发立即加T,自动提现改为手动提现,清空的参照奖金需求
-                // 取消关停状态可以选择期数开通,到期自动开
-                // 老会员需要开通时选择报单级别
-                // 关停开通时,首次报复销单需要交足额的复销,这个在会员表有参数 IS_FIRST_OPEN
-                if ($model->STATUS_VALUE == self::STATUS_NORMAL) {
-                    if (!$this->isPeriodOpen) {
-                        // 身份证号取消加T
-                        User::updateAll(['ID_CARD_PREFIX' => ''], 'ID=:ID', [':ID' => $userModel->ID]);
-                        // 查看开通之前的状态是什么,如果是关停状态,就把会员表的首次开通的字段设标记
-                        if ($beforeStatus == self::STATUS_CLOSE) {
-                            User::updateAll(['IS_FIRST_OPEN' => 1], 'ID=:ID', [':ID' => $userModel->ID]);
-                        }
-                    }
-                }
-                //注销
-                elseif ($model->STATUS_VALUE == self::STATUS_LOGOUT) {
-                    if ($perfPeriod) {
-                        // 清空大区剩余业绩
-                        $perfPeriod->SURPLUS_1L = 0;
-                        $perfPeriod->SURPLUS_2L = 0;
-                        $perfPeriod->SURPLUS_3L = 0;
-                        $perfPeriod->SURPLUS_4L = 0;
-                        $perfPeriod->SURPLUS_5L = 0;
-                        if (!$perfPeriod->save()) {
-                            throw new Exception(Form::formatErrorsForApi($perfPeriod->getErrors()));
-                        }
-                    }
-                    // 清空各区业绩
-                    $userPerf = UserPerf::findOne(['USER_ID' => $userModel->ID]);
-                    if ($userPerf) {
-                        $userPerf->PV_1L = 0;
-                        $userPerf->PV_2L = 0;
-                        $userPerf->PV_3L = 0;
-                        $userPerf->PV_4L = 0;
-                        $userPerf->PV_5L = 0;
-                        if (!$userPerf->save()) {
-                            throw new Exception(Form::formatErrorsForApi($userPerf->getErrors()));
-                        }
-                    }
-                    // 清空所有奖金
-                    Balance::clearAllBonus($userModel->ID, ['REMARK' => '清空账户余额','DEAL_TYPE'=>DealType::DEDUCT_LOGOUT]);
-                    // 取消自动提现
-                    Withdraw::setAutoWithdraw($userModel->ID, 0);
-                    // 向下找新的主会员
-                    UserBind::setNewMainBind($userModel->ID);
-                    // 如果立即加T,否则到期数自动加T(从封期实现)
-                    if (!$this->isPeriodAddT) {
-                        User::updateAll(['ID_CARD_PREFIX' => 'T'], 'ID=:ID', [':ID' => $userModel->ID]);
-                    }
-                } elseif ($model->STATUS_VALUE == self::STATUS_BLACKLIST) {
-                    // 取消自动提现
-                    Withdraw::setAutoWithdraw($userModel->ID, 0);
-                    // 向下找新的主会员
-                    UserBind::setNewMainBind($userModel->ID);
-                } elseif ($model->STATUS_VALUE == self::STATUS_STOP_SEND) {
-                    // 取消自动提现
-                    Withdraw::setAutoWithdraw($userModel->ID, 0);
-                    // 向下找新的主会员
-                    UserBind::setNewMainBind($userModel->ID);
-                    // 如果立即加T,否则到期数自动加T(从封期实现)
-                    if (!$this->isPeriodAddT) {
-                        User::updateAll(['ID_CARD_PREFIX' => 'T'], 'ID=:ID', [':ID' => $userModel->ID]);
-                    }
-                }
-                //永久关停
-                elseif ($model->STATUS_VALUE == self::STATUS_CLOSE) {
-                    $this->_afterClose($userModel->ID,$perfPeriod);
-                }
-            } elseif ($this->auditStatus == 'reject') {
-                $model->CREATE_REMARK = $this->remark;
-                $model->AUDIT_ADMIN = \Yii::$app->user->id;
-                $model->AUDIT_STATUS = \Yii::$app->params['auditStatus']['reject']['value'];
-                $model->AUDITED_AT = Date::nowTime();
-                if (!$model->save()) {
-                    throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-                }
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('audit', $e->getMessage());
-            return null;
-        }
-
-        // 记录日志
-        $this->adminOperateLogger->afterUpdate($model)->clean()->save([
-            'optType' => '审核会员状态',
-            'userId' => $model->USER_ID,
-            'userName' => Info::getUserNameByUserId($model->USER_ID),
-            'remark' => $model->CREATE_REMARK,
-        ]);
-
-        return $model;
-    }
-
-    /**
-     * 调整是否运作
-     * @return User|null
-     */
-    public function operating() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $this->adminOperateLogger->fetchClass = User::class;
-        $this->adminOperateLogger->setIsBatch(true)->beforeUpdate($this->userIds, 'ID',['select'=>'ID,NOT_OPERATING']);
-
-        $allUidIn = implode("','", $this->userIds);
-        User::updateAll(['NOT_OPERATING' => !$this->isOperating], "ID IN ('" . $allUidIn . "')");
-
-        $this->adminOperateLogger->setIsBatch(true)->afterUpdate($this->userIds, 'ID',['select'=>'ID,NOT_OPERATING']);
-        $this->adminOperateLogger->setBatchField('ID')->setOptObjField('ID')->clean()->save([
-            'optType' => '调整会员运作状态【'.($this->isOperating ? '运作' : '不运作').'】',
-            'remark' => $this->remark,
-        ]);
-        return $this->userIds;
-    }
-
-    /**
-     * 自动关停
-     * @return UserStatusAudit|null
-     * @throws \yii\db\Exception
-     */
-    public function autoClose() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            // 获取会员当前的状态
-            $oriStatus = Status::getStatus($this->userId);
-            $model = new UserStatusAudit();
-            $model->USER_ID = $this->userId;
-            $model->STATUS_VALUE = self::STATUS_CLOSE;
-            $model->ORI_VALUE = $oriStatus;
-            $model->PERIOD_NUM = $this->periodNum;
-            $model->AUDIT_STATUS = \Yii::$app->params['auditStatus']['true']['value'];
-            $model->IS_PERIOD_ADD_T = 0;
-            $model->ADD_T_PERIOD_NUM = 0;
-            $model->IS_PERIOD_OPEN = 0;
-            $model->OPEN_PERIOD_NUM = 0;
-            $model->CREATE_REMARK = '自动关停';
-            $model->CREATE_ADMIN = 0;
-            $model->CREATED_AT = Date::nowTime();
-            if (!$model->save()) {
-                throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-            }
-            $userModel = User::findOne(['ID' => $this->userId]);
-            $userModel->STATUS = self::STATUS_CLOSE;
-            $userModel->STATUS_AT = Date::nowTime();
-            if (!$userModel->save()) {
-                throw new Exception(Form::formatErrorsForApi($userModel->getErrors()));
-            }
-            $this->_afterClose($this->userId);
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('autoClose', $e->getMessage());
-            return null;
-        }
-        return $model;
-    }
-
-    /**
-     * 关停后对会员操作
-     * @param $userId
-     * @param null $perfPeriod
-     * @throws Exception
-     * @throws \yii\db\Exception
-     */
-    private function _afterClose($userId,$perfPeriod=null){
-        if(!$perfPeriod) {
-            $maxPeriodNum = Period::sentMaxPeriodNum();
-            $perfPeriod = PerfPeriod::findOne(['USER_ID' => $userId, 'PERIOD_NUM' => $maxPeriodNum]);
-        }
-        // 清空大区剩余业绩
-        if ($perfPeriod) {
-            $perfPeriod->SURPLUS_1L = 0;
-            $perfPeriod->SURPLUS_2L = 0;
-            $perfPeriod->SURPLUS_3L = 0;
-            $perfPeriod->SURPLUS_4L = 0;
-            $perfPeriod->SURPLUS_5L = 0;
-            if (!$perfPeriod->save()) {
-                throw new Exception(Form::formatErrorsForApi($perfPeriod->getErrors()));
-            }
-        }
-        // 清空各区业绩
-        $userPerf = UserPerf::findOne(['USER_ID' => $userId]);
-        if ($userPerf) {
-            $userPerf->PV_1L = 0;
-            $userPerf->PV_2L = 0;
-            $userPerf->PV_3L = 0;
-            $userPerf->PV_4L = 0;
-            $userPerf->PV_5L = 0;
-            if (!$userPerf->save()) {
-                throw new Exception(Form::formatErrorsForApi($userPerf->getErrors()));
-            }
-        }
-        // 清空所有奖金 暂时不清奖金<19.10.1>@190730
-        // Balance::clearAllBonus($userId, ['REMARK' => '会员永久关停']);
-        // 取消自动提现
-        Withdraw::setAutoWithdraw($userId, 0);
-        // 身份证号立即加T,聘级将为无聘级
-        User::updateAll(['ID_CARD_PREFIX' => 'T', 'EMP_LV' => EmployLevel::getDefaultLevelId()], 'ID=:ID', [':ID' => $userId]);
-        // 向下找新的主会员
-        UserBind::setNewMainBind($userId);
-    }
-
-    /**
-     * 自动关停
-     * @param $periodNum
-     * @param int $closedAt
-     * @param $limit
-     * @param int $start
-     * @param null $closeInspectStart
-     * @param null $closeInspectPv
-     * @return bool
-     * @throws \yii\db\Exception
-     */
-    public static function autoChkClose($periodNum, $closedAt = 0, $limit, $start = 0, $closeInspectStart = null, $closeInspectPv = null) {
-        //初始化
-        if (!$closeInspectStart || !$closeInspectPv) {
-            $systemConfig = Cache::getSystemConfig();
-            $closeInspectMonth = $systemConfig['closeInspectMonth']['VALUE'];
-            $closeInspectStart = Date::lastNumMonth($closeInspectMonth, $closedAt);
-            $closeInspectPv = $systemConfig['closeInspectPv']['VALUE'];
-        }
-        //考察所有未注销未关停的会员 (修复UserInfo没有STATUS)
-        $allData = User::find()->where('STATUS!=:STATUS_CLOSE AND STATUS!=:STATUS_LOGOUT AND SUB_COM_LEADER!=1',[':STATUS_CLOSE'=>self::STATUS_CLOSE,':STATUS_LOGOUT'=>self::STATUS_LOGOUT])->select('ID')->offset($start)->limit($limit)->asArray()->all();
-        if ($allData) {
-            foreach ($allData as $data) {
-                // 修复绑定的START和END是关键字不允许作为绑定参数
-                $pvPcs = PerfPeriod::find()->where('CREATED_AT>:START_TIME AND CREATED_AT<:END_TIME', [':START_TIME' => $closeInspectStart, ':END_TIME' => $closedAt])->SUM('PV_PCS');
-                if ($pvPcs < $closeInspectPv) {
-                    //未达到业绩,封停会员
-                    $formModel = new UserStatusForm();
-                    $formModel->scenario = 'autoClose';
-                    $formModel->userId = $data['ID'];
-                    $formModel->periodNum = $periodNum;
-                    if (!$formModel->autoClose()) {
-                        continue;
-                    }
-                    unset($formModel);
-                }
-            }
-            unset($allData);
-            $start = $start + $limit;
-            return self::autoChkClose($periodNum, $closedAt, $limit, $start, $closeInspectStart, $closeInspectPv);
-        }
-        return true;
-    }
-
-    /**
-     * 删除前
-     * @param $selected
-     */
-    public function beforeDelete($selected) {
-        $this->adminOperateLogger->setIsBatch(true)->beforeDelete($selected, 'ID');
-    }
-    /**
-     * 删除
-     * @param $selected
-     * @throws Exception
-     */
-    public function delete($selected) {
-        $this->adminOperateLogger->clean()->save([
-            'optType' => '删除会员状态待审核数据',
-        ]);
-    }
-
-    /**
-     * 清空关停会员钱包
-     * @return array|null
-     * @throws Exception
-     * @throws \yii\db\Exception
-     */
-    public function clearWallet() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $uids = [];
-        $users = Status::getCloseUser();
-        if ($users) {
-            $uids = array_column($users, 'ID');
-            $this->adminOperateLogger->fetchClass = UserBonus::class;
-            $this->adminOperateLogger->setIsBatch(true)->beforeUpdate($uids, 'USER_ID');
-            $userBonus = $this->adminOperateLogger->saveBeforeContent;
-            $this->adminOperateLogger->fetchClass = UserWallet::class;
-            $this->adminOperateLogger->setIsBatch(true)->beforeUpdate($uids, 'USER_ID');
-            $shopWallet = $this->adminOperateLogger->saveBeforeContent;
-            $this->adminOperateLogger->saveBeforeContent=Tool::mergeArrayWithKey($userBonus,$shopWallet);
-
-            $db = \Yii::$app->db;
-            $transaction = $db->beginTransaction();
-            try {
-                foreach ($users as $u) {
-                    // 清空所有奖金
-                    Balance::clearAllBonus($u['ID'], ['REMARK' => '清空账户余额', 'DEAL_TYPE' => DealType::DEDUCT_CLOSE]);
-                }
-                $transaction->commit();
-            } catch (Exception $e) {
-                $transaction->rollBack();
-            }
-
-            $this->adminOperateLogger->fetchClass = UserBonus::class;
-            $this->adminOperateLogger->setIsBatch(true)->afterUpdate($uids, 'USER_ID');
-            $userBonus = $this->adminOperateLogger->saveAfterContent;
-            $this->adminOperateLogger->fetchClass = UserWallet::class;
-            $this->adminOperateLogger->setIsBatch(true)->afterUpdate($uids, 'USER_ID');
-            $shopWallet = $this->adminOperateLogger->saveAfterContent;
-            $this->adminOperateLogger->saveAfterContent=Tool::mergeArrayWithKey($userBonus,$shopWallet);
-            $this->adminOperateLogger->setBatchField('USER_ID')->setOptObjField('USER_ID')->clean()->save([
-                'optType' => '清空关停会员钱包',
-                'remark' => $this->remark,
-            ]);
-
-            return $uids;
-        } else {
-            throw new Exception('暂无符合条件的会员');
-        }
-    }
-}

+ 0 - 246
common/models/forms/UserSystemForm.php

@@ -1,246 +0,0 @@
-<?php
-
-namespace common\models\forms;
-
-use common\helpers\Date;
-use common\components\Model;
-use common\helpers\Form;
-use common\helpers\Log;
-use common\helpers\user\Info;
-use common\libs\logging\operate\AdminOperate;
-use common\models\BonusAsync;
-use common\models\Period;
-use common\models\UserInfo;
-use common\models\UserRelation;
-use common\models\UserSystem;
-use yii\base\Exception;
-
-/**
- * Login form
- */
-class UserSystemForm extends Model {
-    public $id;
-    public $systemName;
-    public $leaderUserName;
-    public $remark;
-
-    private $_leaderUid;
-    private $_tempSystemLeaders = [];  // 用于循环给下级设置体系的时候,临时设置子集领导的数组
-    private $_limit = 2;
-
-    public function init() {
-        parent::init();
-        $this->adminOperateLogger = new AdminOperate([
-            'fetchClass' => UserSystem::class,
-        ]);
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules() {
-        return [
-            [['id', 'systemName', 'leaderUserName', 'remark'], 'trim'],
-            [['id', 'systemName', 'leaderUserName'], 'required'],
-            [['systemName'], 'unique', 'on' => 'update', 'targetClass' => UserSystem::class, 'targetAttribute' => 'SYSTEM_NAME', 'when' => function ($model) {
-                return $model->isAttributeChanged('SYSTEM_NAME');
-            }],
-            [['leaderUserName'], 'exist', 'targetClass' => UserInfo::class, 'targetAttribute' => 'USER_NAME'],
-            [['id'], 'exist', 'targetClass' => UserSystem::class, 'targetAttribute' => 'ID', 'on'=>'renewSystem'],
-            [['leaderUserName'], 'isLeaderUser'],
-        ];
-    }
-
-    /**
-     * 指定校验场景
-     * @return array
-     */
-    public function scenarios() {
-        $parentScenarios = parent::scenarios();
-        $customScenarios = [
-            'add' => ['systemName', 'leaderUserName','remark'],
-            'edit' => ['systemName','leaderUserName', 'remark'],
-            'renewSystem' => ['id'],
-        ];
-        return array_merge($parentScenarios, $customScenarios);
-    }
-
-    public function attributeLabels() {
-        return [
-            'systemName' => '体系名称',
-            'leaderUserName' => '领导人会员编号',
-        ];
-    }
-
-    public function isLeaderUser($attributes) {
-        $leaderUserInfo = UserInfo::findOneAsArray(['USER_NAME' => $this->leaderUserName]);
-        if ($leaderUserInfo) {
-            $this->_leaderUid = $leaderUserInfo['USER_ID'];
-        }
-    }
-
-    /**
-     * 页面端编辑
-     * @return UserSystem|null|static
-     * @throws \yii\db\Exception
-     */
-    public function edit() {
-        if (!$this->validate()) {
-            return null;
-        }
-        return $this->_editHandle();
-    }
-
-    /**
-     * 恢复
-     * @return UserSystem|null
-     * @throws \yii\db\Exception
-     */
-    public function renewSystem(){
-        if (!$this->validate()) {
-            return null;
-        }
-        return $this->_editHandle();
-    }
-
-    /**
-     * 撤销体系前
-     * @param $selected
-     * @throws Exception
-     */
-    public function beforeDelete($selected) {
-        $this->adminOperateLogger->setIsBatch(true)->setOptObjField('LEADER_UID')->beforeDelete($selected, 'ID');
-        foreach ($selected as $id) {
-            $period = Period::instance();
-            $model = UserSystem::findOne(['ID' => $id]);
-            $model->UPDATED_AT = Date::nowTime();
-            $model->UPDATE_PERIOD_NUM = $period->getNowPeriodNum();
-            $model->UPDATE_ADMIN = \Yii::$app->user->id;
-            if (!$model->save()) {
-                throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-            }
-            $leaderUid = $model->LEADER_UID;
-            // 把该体系对应的领导人及下级所有是该体系的会员,全部改为上级的体系
-            // 获取该体系的上级会员所在的体系
-            $parentUserInfo = UserRelation::getFirstParentUserInfo($leaderUid);
-            if ($parentUserInfo) {
-                $newSystemId = $parentUserInfo['SYSTEM_ID'];
-            } else {
-                $newSystemId = null;
-            }
-            UserInfo::updateAll(['IS_SYSTEM_LEADER' => 0], 'USER_ID=:USER_ID', [':USER_ID' => $leaderUid]);
-            // 把该体系的所有体系都改成新体系
-            UserInfo::updateAll(['SYSTEM_ID' => $newSystemId], 'SYSTEM_ID=:SYSTEM_ID AND IS_SYSTEM_LEADER=0', [':SYSTEM_ID' => $id]);
-        }
-    }
-
-    /**
-     * 撤销体系
-     * @param $selected
-     */
-    public function delete($selected) {
-        $this->adminOperateLogger->clean()->save([
-            'optType' => '撤销体系',
-        ]);
-    }
-
-    /**
-     * 处理编辑
-     * @return UserSystem|null
-     * @throws \yii\db\Exception
-     */
-    private function _editHandle() {
-        if($this->scenario!='add'){
-            $this->adminOperateLogger->beforeUpdate(UserSystem::findOne(['ID' => $this->id]));
-        }
-        $transaction = \Yii::$app->db->beginTransaction();
-        try {
-            $period = Period::instance();
-            if ($this->scenario == 'add') {
-                $model = new UserSystem();
-                $model->SYSTEM_NAME = $this->systemName;
-                $model->LEADER_UID = $this->_leaderUid;
-                $model->PERIOD_NUM = $period->getNowPeriodNum();
-                $model->CREATE_REMARK = $this->remark;
-                $model->CREATE_ADMIN = \Yii::$app->user->id;
-                $model->CREATED_AT = Date::nowTime();
-            } elseif ($this->scenario == 'edit') {
-                $model = UserSystem::findOne(['ID' => $this->id]);
-                if($model->IS_DEL){
-                    $this->addError('id', '该体系已被撤销,不能编辑');
-                    return null;
-                }
-                $model->SYSTEM_NAME = $this->systemName;
-                $model->LEADER_UID = $this->_leaderUid;
-                $model->UPDATED_AT = Date::nowTime();
-                $model->UPDATE_PERIOD_NUM = $period->getNowPeriodNum();
-                $model->UPDATE_ADMIN = \Yii::$app->user->id;
-                $model->CREATE_REMARK = $this->remark;
-            } elseif ($this->scenario == 'renewSystem') {
-                $model = UserSystem::findOne(['ID' => $this->id]);
-                $model->IS_DEL = 0;
-                $model->UPDATED_AT = Date::nowTime();
-                $model->UPDATE_PERIOD_NUM = $period->getNowPeriodNum();
-                $model->UPDATE_ADMIN = \Yii::$app->user->id;
-                $this->_leaderUid = $model->LEADER_UID;
-            }else {
-                $this->addError('id', '提交场景不存在');
-                return null;
-            }
-            if (!$model->save()) {
-                throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-            }
-            // 下级会员全部变成该体系的会员
-            //if ($this->scenario == 'add') {
-                // 自己也变成该体系
-                UserInfo::updateAll(['SYSTEM_ID' => $model->ID, 'IS_SYSTEM_LEADER'=>1], 'USER_ID=:USER_ID', [':USER_ID' => $this->_leaderUid]);
-                $this->_childrenChangeSystem($this->_leaderUid, $model->ID);
-           //}
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('edit', $e->getMessage());
-            return null;
-        }
-        if($this->scenario!='add'){
-            $this->adminOperateLogger->afterUpdate($model);
-
-        }else{
-            $this->adminOperateLogger->afterInsert($model);
-        }
-        $optType = '添加体系';
-        if($this->scenario=='edit'){
-            $optType = '编辑体系';
-        }elseif ($this->scenario=='renewSystem'){
-            $optType = '恢复体系';
-        }
-        $this->adminOperateLogger->clean()->save([
-            'optType' => $optType,
-            'userId' => $model->LEADER_UID,
-            'userName' => Info::getUserNameByUserId($model->LEADER_UID),
-            'remark' => $this->remark??''
-        ]);
-        return $model;
-    }
-
-    /**
-     * 改变子会员的体系
-     * @param $userId
-     * @param $systemId
-     * @throws \yii\db\Exception
-     */
-    private function _childrenChangeSystem($userId, $systemId){
-        // 查询子会员里面是体系领导人的所有子会员
-        $allChildSystemLeader = UserRelation::find()->select('UR.*,UI.SYSTEM_ID')->from(UserRelation::tableName().' AS UR')->join('LEFT JOIN', UserInfo::tableName().' AS UI', 'UI.USER_ID=UR.USER_ID')->where('UR.PARENT_UID=:PARENT_UID AND UI.IS_SYSTEM_LEADER=1', [':PARENT_UID'=>$userId])->asArray()->all();
-        // 先把所有子会员的体系,全部改成新体系
-        $sql = "UPDATE {{%USER_INFO}} UI SET UI.SYSTEM_ID=:SYSTEM_ID WHERE EXISTS (SELECT UR.USER_ID FROM {{%USER_RELATION}} UR WHERE UI.USER_ID=UR.USER_ID AND UR.PARENT_UID=:PARENT_UID)";
-        \Yii::$app->db->createCommand($sql)->bindValues([':SYSTEM_ID'=>$systemId, ':PARENT_UID'=>$userId])->query();
-        // 循环把所有子会员的体系都设置了
-        foreach($allChildSystemLeader as $ChildSystemLeader){
-            UserInfo::updateAll(['SYSTEM_ID' => $ChildSystemLeader['SYSTEM_ID']], 'USER_ID=:USER_ID', [':USER_ID' => $ChildSystemLeader['USER_ID']]);
-            $sql = "UPDATE {{%USER_INFO}} UI SET UI.SYSTEM_ID=:SYSTEM_ID WHERE EXISTS (SELECT UR.USER_ID FROM {{%USER_RELATION}} UR WHERE UI.USER_ID=UR.USER_ID AND UR.PARENT_UID=:PARENT_UID)";
-            \Yii::$app->db->createCommand($sql)->bindValues([':SYSTEM_ID'=>$ChildSystemLeader['SYSTEM_ID'], ':PARENT_UID'=>$ChildSystemLeader['USER_ID']])->query();
-        }
-    }
-
-}

+ 0 - 201
common/models/forms/UserTeamForm.php

@@ -1,201 +0,0 @@
-<?php
-
-namespace common\models\forms;
-
-use common\helpers\Date;
-use common\components\Model;
-use common\helpers\Form;
-use common\helpers\Log;
-use common\models\BonusAsync;
-use common\models\Period;
-use common\models\UserInfo;
-use common\models\UserNetwork;
-use common\models\UserRelation;
-use common\models\UserTeam;
-use yii\base\Exception;
-
-/**
- * Login form
- */
-class UserTeamForm extends Model {
-    public $id;
-    public $teamName;
-    public $leaderUserName;
-    public $remark;
-
-    private $_leaderUid;
-    private $_tempTeamLeaders = [];  // 用于循环给下级设置团队的时候,临时设置子集领导的数组
-    private $_limit = 2;
-
-    /**
-     * @inheritdoc
-     */
-    public function rules() {
-        return [
-            [['id', 'teamName', 'leaderUserName', 'remark'], 'trim'],
-            [['id', 'teamName', 'leaderUserName'], 'required'],
-            [['leaderUserName'], 'unique', 'targetClass' => UserTeam::class, 'targetAttribute' => 'TEAM_NAME'],
-            [['leaderUserName'], 'exist', 'targetClass' => UserInfo::class, 'targetAttribute' => 'USER_NAME'],
-            [['id'], 'exist', 'targetClass' => UserTeam::class, 'targetAttribute' => 'ID', 'on'=>'renewTeam'],
-            [['leaderUserName'], 'isLeaderUser'],
-        ];
-    }
-
-    /**
-     * 指定校验场景
-     * @return array
-     */
-    public function scenarios() {
-        $parentScenarios = parent::scenarios();
-        $customScenarios = [
-            'add' => ['teamName', 'leaderUserName','remark'],
-            'edit' => ['teamName','leaderUserName', 'remark'],
-            'renewTeam' => ['id'],
-        ];
-        return array_merge($parentScenarios, $customScenarios);
-    }
-
-    public function attributeLabels() {
-        return [
-            'teamName' => '团队名称',
-            'leaderUserName' => '领导人会员编号',
-        ];
-    }
-
-    public function isLeaderUser($attributes) {
-        $leaderUserInfo = UserInfo::findOneAsArray(['USER_NAME' => $this->leaderUserName]);
-        if ($leaderUserInfo) {
-            $this->_leaderUid = $leaderUserInfo['USER_ID'];
-        }
-    }
-
-    /**
-     * 页面端编辑
-     * @return UserTeam|null|static
-     * @throws \yii\db\Exception
-     */
-    public function edit() {
-        if (!$this->validate()) {
-            return null;
-        }
-        return $this->_editHandle();
-    }
-
-    /**
-     * 恢复
-     * @return UserTeam|null
-     * @throws \yii\db\Exception
-     */
-    public function renewTeam(){
-        if (!$this->validate()) {
-            return null;
-        }
-        return $this->_editHandle();
-    }
-
-    /**
-     * 删除团队的
-     * @param $id
-     * @throws Exception
-     */
-    public function delete($id) {
-        $period = Period::instance();
-        $model = UserTeam::findOne(['ID' => $id]);
-        $model->UPDATED_AT = Date::nowTime();
-        $model->UPDATE_PERIOD_NUM = $period->getNowPeriodNum();
-        $model->UPDATE_ADMIN = \Yii::$app->user->id;
-        if (!$model->save()) {
-            throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-        }
-        $leaderUid = $model->LEADER_UID;
-        // 把该团队对应的领导人及下级所有是该团队的会员,全部改为上级的团队
-        // 获取该团队的上级会员所在的团队
-        $parentUserInfo = UserNetwork::getFirstParentUserInfo($leaderUid);
-        if ($parentUserInfo) {
-            $newTeamId = $parentUserInfo['TEAM_ID'];
-        } else {
-            $newTeamId = null;
-        }
-        // 把该团队的所有团队都改成新团队
-        UserInfo::updateAll(['TEAM_ID' => $newTeamId], 'TEAM_ID=:TEAM_ID AND IS_TEAM_LEADER=0', [':TEAM_ID' => $id]);
-    }
-
-    /**
-     * 处理编辑
-     * @return UserTeam|null
-     * @throws \yii\db\Exception
-     */
-    private function _editHandle() {
-        $transaction = \Yii::$app->db->beginTransaction();
-        try {
-            $period = Period::instance();
-            if ($this->scenario == 'add') {
-                $model = new UserTeam();
-                $model->TEAM_NAME = $this->teamName;
-                $model->LEADER_UID = $this->_leaderUid;
-                $model->PERIOD_NUM = $period->getNowPeriodNum();
-                $model->CREATE_REMARK = $this->remark;
-                $model->CREATE_ADMIN = \Yii::$app->user->id;
-                $model->CREATED_AT = Date::nowTime();
-            } elseif ($this->scenario == 'edit') {
-                $model = UserTeam::findOne(['ID' => $this->id]);
-                if($model->IS_DEL){
-                    $this->addError('id', '该团队已被撤销,不能编辑');
-                    return null;
-                }
-                $model->TEAM_NAME = $this->teamName;
-                $model->LEADER_UID = $this->_leaderUid;
-                $model->UPDATED_AT = Date::nowTime();
-                $model->UPDATE_PERIOD_NUM = $period->getNowPeriodNum();
-                $model->UPDATE_ADMIN = \Yii::$app->user->id;
-                $model->CREATE_REMARK = $this->remark;
-            } elseif ($this->scenario == 'renewTeam') {
-                $model = UserTeam::findOne(['ID' => $this->id]);
-                $model->IS_DEL = 0;
-                $model->UPDATED_AT = Date::nowTime();
-                $model->UPDATE_PERIOD_NUM = $period->getNowPeriodNum();
-                $model->UPDATE_ADMIN = \Yii::$app->user->id;
-                $this->_leaderUid = $model->LEADER_UID;
-            }else {
-                $this->addError('id', '提交场景不存在');
-                return null;
-            }
-            if (!$model->save()) {
-                throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-            }
-            // 下级会员全部变成该团队的会员
-            //if ($this->scenario == 'add') {
-                // 自己也变成该团队
-                UserInfo::updateAll(['TEAM_ID' => $model->ID, 'IS_TEAM_LEADER'=>1], 'USER_ID=:USER_ID', [':USER_ID' => $this->_leaderUid]);
-                $this->_childrenChangeTeam($this->_leaderUid, $model->ID);
-           //}
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('edit', $e->getMessage());
-            return null;
-        }
-        return $model;
-    }
-
-    /**
-     * 改变子会员的团队
-     * @param $userId
-     * @param $teamId
-     * @throws \yii\db\Exception
-     */
-    private function _childrenChangeTeam($userId, $teamId){
-        // 查询子会员里面是团队领导人的所有子会员
-        $allChildTeamLeader = UserNetwork::find()->select('UR.*,UI.TEAM_ID')->from(UserNetwork::tableName().' AS UR')->join('LEFT JOIN', UserInfo::tableName().' AS UI', 'UI.USER_ID=UR.USER_ID')->where('UR.PARENT_UID=:PARENT_UID AND UI.IS_TEAM_LEADER=1', [':PARENT_UID'=>$userId])->asArray()->all();
-        // 先把所有子会员的团队,全部改成新团队
-        $sql = "UPDATE {{%USER_INFO}} UI SET UI.TEAM_ID=:TEAM_ID WHERE EXISTS (SELECT UR.USER_ID FROM {{%USER_NETWORK}} UR WHERE UI.USER_ID=UR.USER_ID AND UR.PARENT_UID=:PARENT_UID)";
-        \Yii::$app->db->createCommand($sql)->bindValues([':TEAM_ID'=>$teamId, ':PARENT_UID'=>$userId])->query();
-        // 循环把所有子会员的团队都设置了
-        foreach($allChildTeamLeader as $ChildTeamLeader){
-            UserInfo::updateAll(['TEAM_ID' => $ChildTeamLeader['TEAM_ID']], 'USER_ID=:USER_ID', [':USER_ID' => $ChildTeamLeader['USER_ID']]);
-            $sql = "UPDATE {{%USER_INFO}} UI SET UI.TEAM_ID=:TEAM_ID WHERE EXISTS (SELECT UR.USER_ID FROM {{%USER_NETWORK}} UR WHERE UI.USER_ID=UR.USER_ID AND UR.PARENT_UID=:PARENT_UID)";
-            \Yii::$app->db->createCommand($sql)->bindValues([':TEAM_ID'=>$ChildTeamLeader['TEAM_ID'], ':PARENT_UID'=>$ChildTeamLeader['USER_ID']])->query();
-        }
-    }
-
-}

+ 0 - 429
common/models/forms/UserTeamworkForm.php

@@ -1,429 +0,0 @@
-<?php
-
-namespace common\models\forms;
-
-use common\helpers\Date;
-use common\components\Model;
-use common\helpers\Form;
-use common\helpers\user\Info;
-use common\libs\logging\operate\AdminOperate;
-use common\models\Period;
-use common\models\DeclarationLevel;
-use common\models\EmployLevel;
-use common\models\User;
-use common\models\UserBind;
-use common\models\UserInfo;
-use common\models\UserTeamwork;
-use yii\base\Exception;
-
-/**
- * 点位合作表单
- */
-class UserTeamworkForm extends Model {
-    public $id;
-    public $type;
-    public $userName;
-    public $mainUserName;
-    public $dividePercent;
-    public $divideArr;
-    public $nation;
-    public $realName;
-    public $idCard;
-    public $mobile;
-    public $address;
-    public $openBank;
-    public $bankAddress;
-    public $bankNo;
-    public $bankAreaSelected;
-    public $areaSelected;
-    public $tel;
-    public $remark;
-
-
-    const HAS_USER = 1;   // 在网站已有会员
-    const NOT_USER = 0;   // 在网站没有会员
-
-    private $_uid;
-    private $_mainUid;
-    private $_model;
-
-    public function init() {
-        parent::init();
-        $this->adminOperateLogger = new AdminOperate([
-            'fetchClass' => UserTeamwork::class,
-        ]);
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules() {
-        return [
-            [['id', 'type', 'userName', 'mainUserName', 'dividePercent', 'nation', 'realName', 'idCard', 'mobile', 'address', 'openBank', 'bankAddress', 'bankNo', 'bankAreaSelected', 'areaSelected', 'tel', 'remark'], 'trim'],
-            [['id', 'type', 'userName', 'mainUserName', 'dividePercent', 'idCard', 'realName'], 'required'],
-            [['dividePercent'], 'price', 'message' => '分成比例必须是整数或者两位小数'],
-            [['type'], 'boolean', 'message' => '添加类型格式不正确'],
-            [['userName'], 'isUserName'],
-            [['mobile', 'tel'], 'mobile'],
-            [['bankNo'], 'string', 'max' => 19],
-            [['mainUserName'], 'isMainUserName'],
-            [['dividePercent'], 'isDivide'],
-            [['divideArr'], 'isDivideArr'],
-            [['id'], 'initModel'],
-            [['userName'], 'userName'],
-            [['idCard'], 'isIdCard'],
-            [['realName','address','bankAddress'], 'realName'],
-        ];
-    }
-
-    /**
-     * 指定校验场景
-     * @return array
-     */
-    public function scenarios() {
-        $parentScenarios = parent::scenarios();
-        $customScenarios = [
-            'add' => ['type', 'userName', 'mainUserName', 'dividePercent', 'nation', 'realName', 'idCard', 'mobile', 'address', 'openBank', 'bankAddress', 'bankNo', 'bankAreaSelected', 'areaSelected', 'tel', 'remark'],
-            'changeDivide' => ['id', 'divideArr', 'remark'],
-        ];
-        return array_merge($parentScenarios, $customScenarios);
-    }
-
-    public function attributeLabels() {
-        return [
-            'type' => '添加类型',
-            'userName' => '会员编号',
-            'mainUserName' => '主会员编号',
-            'dividePercent' => '分成比例',
-            'nation' => '民族',
-            'realName' => '会员姓名',
-            'idCard' => '身份证',
-            'mobile' => '手机号',
-            'address' => '地址',
-            'openBank' => '开户行',
-            'bankAddress' => '银行地址',
-            'bankNo' => '银行账号',
-            'bankAreaSelected' => '银行地区',
-            'areaSelected' => '地区',
-            'tel' => '电话',
-            'remark' => '备注',
-        ];
-    }
-
-    /**
-     * 初始化model
-     * @param $attributes
-     */
-    public function initModel($attributes) {
-        $this->_model = UserTeamwork::findOne(['ID' => $this->id]);
-        if (!$this->_model) {
-            $this->addError($attributes, '数据不存在');
-        }
-    }
-
-    /**
-     * 用户名是否正确
-     * @param $attributes
-     * @throws Exception
-     */
-    public function isUserName($attributes) {
-        if ($this->userName == $this->mainUserName) {
-            $this->addError($attributes, '同一会员不能合作');
-        }
-        if ($this->type == self::HAS_USER) {
-            $userInfo = UserInfo::findOneAsArray(['USER_NAME' => $this->userName]);
-            if ($userInfo) {
-                $this->_uid = $userInfo['USER_ID'];
-                if ($userInfo['IS_TEAM_MAIN'] == 1) {
-                    $this->addError($attributes, '该会员是其他点位合作的主会员,无法添加');
-                }
-                $info = Info::baseInfo($this->_uid);
-                /*if ($info['STATUS'] == UserStatusForm::STATUS_LOGOUT || $info['STATUS'] == UserStatusForm::STATUS_CLOSE) {
-                    $this->addError($attributes, '注销或永久关停的会员不允许设置点位合作');
-                }*/
-                if ($info['STATUS'] != UserStatusForm::STATUS_NORMAL) {
-                    $this->addError($attributes, '非正常的会员不允许设置点位合作');
-                }
-            } else {
-                $this->addError($attributes, '会员不存在');
-            }
-        } else {
-            if (strpos(strtolower($this->userName), 'hz') !== 0) {
-                $this->addError($attributes, '无点位的会员编号必须是以hz开头');
-            }
-            if (!$this->realName || !$this->idCard) {
-                $this->addError($attributes, '请详细填写新增无点位会员的相关信息');
-            }
-        }
-
-    }
-
-    /**
-     * 主会员编号
-     * @param $attributes
-     * @throws Exception
-     */
-    public function isMainUserName($attributes) {
-        $userInfo = UserInfo::findOneAsArray(['USER_NAME' => $this->mainUserName]);
-        if ($userInfo) {
-            if (UserTeamwork::find()->where('USER_ID=:USER_ID AND MAIN_UID!=:USER_ID AND IS_DEL=0', [':USER_ID' => $userInfo['USER_ID']])->exists()) {
-                $this->addError($attributes, '主会员已在其他点位有合作情况');
-            }
-            $info = Info::baseInfo($userInfo['USER_ID']);
-            if ($info['STATUS'] != UserStatusForm::STATUS_NORMAL) {
-                $this->addError($attributes, '非正常的主会员不允许设置点位合作');
-            }
-            $this->_mainUid = $userInfo['USER_ID'];
-        } else {
-            $this->addError($attributes, '主会员不存在');
-        }
-    }
-
-    /**
-     * 校验分成比例
-     * @param $attributes
-     * @return bool
-     */
-    public function isDivide($attributes) {
-        /*$divideSum = UserTeamwork::findOneAsArray('USER_ID=:MAIN_UID AND MAIN_UID=:MAIN_UID AND IS_DEL=0', [':MAIN_UID' => $this->_mainUid], 'DIVIDE_PERCENT');
-        if ($divideSum && $divideSum['DIVIDE_PERCENT'] <= $this->dividePercent) {
-            $this->addError($attributes, '该合作者的分成比例不能超过主会员分成比例【' . $divideSum . '】');
-        }*/
-    }
-
-    /**
-     * 校验身份证号
-     * @param $attributes
-     * @return bool
-     */
-    public function isIdCard($attributes) {
-        if($user=User::findOneAsArray('ID_CARD=:ID_CARD',[':ID_CARD'=>$this->idCard],'REAL_NAME')){
-            if($user['REAL_NAME']!=$this->realName){
-                $this->addError($attributes, '填写的会员姓名与已经实名认证的会员姓名不一致');
-            }
-        }
-    }
-
-    /**
-     * 校验分成数组
-     * @param $attributes
-     * @return bool
-     */
-    public function isDivideArr($attributes) {
-        $sum = 0;
-        foreach ($this->divideArr as $value) {
-            if (!preg_match("/^[0-9]+([.]{1}[0-9]{1,2})?$/", $value['DIVIDE_PERCENT'])) {
-                $this->addError($attributes, '分成比例必须是整数或者两位小数');
-                return false;
-            }
-            $sum += $value['DIVIDE_PERCENT'];
-        }
-        if ($sum != 100) {
-            $this->addError($attributes, '确保总分成比例为100');
-        }
-    }
-
-    /**
-     * 添加
-     * @return UserTeamwork|null
-     * @throws \yii\base\Exception
-     */
-    public function add() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $transaction = \Yii::$app->db->beginTransaction();
-        try {
-            $period = Period::instance();
-            // 如果需要添加虚拟合作会员的,先新增会员
-            if ($this->type == self::NOT_USER) {
-                // 商城表增加会员
-                $user = new User();
-                $user->USER_NAME = $this->userName;
-                $pwd = Info::passwordGenerator($this->idCard,$user->USER_NAME);
-                $user->PASSWORD_HASH = \Yii::$app->security->generatePasswordHash($pwd);
-                $pwd = Info::passwordGenerator($this->idCard,$user->USER_NAME,true);
-                $user->PAY_PASSWORD = \Yii::$app->security->generatePasswordHash($pwd);
-                $user->NATION = $this->nation ? $this->nation : 1;
-                $user->REAL_NAME = $this->realName;
-                $user->ID_CARD = $this->idCard;
-                $user->MOBILE = $this->mobile;
-                $user->ADDRESS = $this->address ? $this->address : '无';
-                $user->ADDRESS = '无';
-                $user->OPEN_BANK = $this->openBank;
-                $user->BANK_ADDRESS = $this->bankAddress;
-                $user->BANK_NO = $this->bankNo;
-                $user->BANK_PROVINCE = $this->bankAreaSelected[0] ?? '0';
-                $user->BANK_CITY = $this->bankAreaSelected[1] ?? '0';
-                $user->BANK_COUNTY = $this->bankAreaSelected[2] ?? '0';
-                $user->CREATED_AT = Date::nowTime();
-                $user->STATUS = 1;
-                $user->DEC_LV = DeclarationLevel::getDefaultLevelId();
-                $user->EMP_LV = EmployLevel::getDefaultLevelId();
-                $user->PROVINCE = $this->areaSelected[0] ?? '0';
-                $user->CITY = $this->areaSelected[1] ?? '0';
-                $user->COUNTY = $this->areaSelected[2] ?? '0';
-                $user->TEL = $this->tel;
-                //$user->REG_IS_COMPLETED = 1;
-                $user->SUB_COM_ID = null;
-                $user->AVATAR = 'avatar/1.png';
-                $user->IS_DEC = 0;
-                $user->DEC_ID = \Yii::$app->params['mainUserId'];
-                $user->BIRTHDAY = null;
-                $user->DEC_ROLE_ID = null;
-                $user->PERIOD_AT = $period->getNowPeriodNum();
-                $user->IS_UNION = 1;//合作会员标识
-                $user->IS_DIRECT_SELLER = 0;
-                $user->VERIFIED = 1;
-                $user->VERIFIED_AT = Date::nowTime();;
-                if (!$user->save()) {
-                    throw new Exception(Form::formatErrorsForApi($user->getErrors()));
-                }
-                $this->_uid = $user->ID;
-                // 结算表用户表增加会员但不写入点位关系
-                $userInfoModel = new UserInfo();
-                $userInfoModel->USER_ID = $this->_uid;
-                $userInfoModel->USER_NAME = $this->userName;
-                $userInfoModel->CON_UID = '0';
-                $userInfoModel->REC_UID = '0';
-                $userInfoModel->IS_TEAM = 1;
-                //$userInfoModel->PERIOD_NUM = $period->getNowPeriodNum();
-                $userInfoModel->CREATED_AT = Date::nowTime();
-                $userInfoModel->HIGHEST_EMP_LV = EmployLevel::getDefaultLevelId();
-                $userInfoModel->ALLOW_TRANSFER = 1;
-                $userInfoModel->HIGHEST_EMP_LV_PERIOD = $period->getNowPeriodNum();
-                $userInfoModel->TRANSFER_PROP = 100.00;
-                $userInfoModel->IS_GROUP_LEADER = 0;
-                if (!$userInfoModel->save()) {
-                    throw new Exception(Form::formatErrorsForApi($userInfoModel->getErrors()));
-                }
-            }
-            // 查看主点位是否已经存在
-            if (!UserTeamwork::find()->where('USER_ID=:USER_ID AND MAIN_UID=:MAIN_UID AND IS_DEL=0', [':USER_ID' => $this->_mainUid, ':MAIN_UID' => $this->_mainUid])->exists()) {
-                UserTeamwork::insertOne([
-                    'USER_ID' => $this->_mainUid,
-                    'MAIN_UID' => $this->_mainUid,
-                    'DIVIDE_PERCENT' => 100 - $this->dividePercent,
-                    'PERIOD_NUM' => $period->getNowPeriodNum(),
-                    'IS_DEL' => 0,
-                    'CREATE_REMARK' => $this->remark,
-                    'CREATE_ADMIN' => \Yii::$app->user->id,
-                    'CREATED_AT' => Date::nowTime(),
-                ]);
-            } else {
-                $mainModel = UserTeamwork::findOne(['USER_ID' => $this->_mainUid]);
-                $mainModel->DIVIDE_PERCENT = $mainModel->DIVIDE_PERCENT - $this->dividePercent;
-                if (!$mainModel->save()) {
-                    throw new Exception(Form::formatErrorsForApi($mainModel->getErrors()));
-                }
-            }
-            // 会员信息表添加点位合作标识
-            UserInfo::updateAll(['IS_TEAM' => 1], 'USER_ID=:USER_ID', [':USER_ID' => $this->_uid]);
-            UserInfo::updateAll(['IS_TEAM' => 1, 'IS_TEAM_MAIN' => 1], 'USER_ID=:USER_ID', [':USER_ID' => $this->_mainUid]);
-            // 添加会员合作点位
-            $model = new UserTeamwork();
-            $model->USER_ID = $this->_uid;
-            $model->MAIN_UID = $this->_mainUid;
-            $model->DIVIDE_PERCENT = $this->dividePercent;
-            $model->PERIOD_NUM = $period->getNowPeriodNum();
-            $model->IS_DEL = 0;
-            $model->CREATE_REMARK = $this->remark;
-            $model->CREATE_ADMIN = \Yii::$app->user->id;
-            $model->CREATED_AT = Date::nowTime();
-            if (!$model->save()) {
-                throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-            }
-            //点位绑定
-            UserBind::autoBind($this->_uid,$this->idCard,1);
-
-
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            User::deleteAll(['ID'=>$this->_uid]);
-            $this->addError('add', $e->getMessage());
-            return null;
-        }
-        if ($this->type == self::NOT_USER) {
-            $this->adminOperateLogger->fetchClass = User::class;
-            $this->adminOperateLogger->afterInsert($this->_uid, 'ID', ['select' => 'ID,NATION,REAL_NAME,ID_CARD,ADDRESS,MOBILE,PROVINCE,CITY,COUNTY,OPEN_BANK,BANK_ADDRESS,BANK_NO,BANK_PROVINCE,BANK_CITY,BANK_COUNTY,TEL,CREATED_AT,IS_UNION']);
-            $userData = $this->adminOperateLogger->saveAfterContent;
-            $this->adminOperateLogger->fetchClass = UserTeamwork::class;
-            $this->adminOperateLogger->afterInsert($model);
-            $infoData = $this->adminOperateLogger->saveAfterContent;
-            $this->adminOperateLogger->saveAfterContent = array_merge($userData, $infoData);
-        }else{
-            $this->adminOperateLogger->afterInsert($model);
-        }
-        $this->adminOperateLogger->clean()->save([
-            'optType' => '添加合作点位',
-            'userId' => $model->USER_ID,
-            'userName' => Info::getUserNameByUserId($model->USER_ID),
-            'remark' => $this->remark
-        ]);
-        return $model;
-    }
-
-    /**
-     * 改变分成比例
-     * @return array|null
-     * @throws \yii\db\Exception
-     */
-    public function changeDivide() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $logs = [];
-
-        $ids = array_column($this->divideArr, 'ID');
-        $this->adminOperateLogger->setIsBatch(true)->beforeUpdate($ids,'ID');
-
-        $transaction = \Yii::$app->db->beginTransaction();
-        try {
-            $period = Period::instance();
-            foreach ($this->divideArr as $value) {
-                $model = UserTeamwork::findOne(['ID'=>$value['ID']]);
-                $model->DIVIDE_PERCENT = $value['DIVIDE_PERCENT'];
-                $model->UPDATE_ADMIN = \Yii::$app->user->id;
-                $model->CREATE_REMARK = $this->remark;
-                $model->UPDATED_PERIOD = $period->getNowPeriodNum();
-                $model->UPDATED_AT = Date::nowTime();
-                if (!$model->save()) {
-                    throw new Exception(Form::formatErrorsForApi($model->getErrors()));
-                }
-                $logs[$value['USER_ID']] = $value['DIVIDE_PERCENT'];
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('changeDivide', $e->getMessage());
-            return null;
-        }
-
-        $this->adminOperateLogger->setIsBatch(true)->afterUpdate($ids,'ID');
-        $this->adminOperateLogger->setOptObjField('USER_ID')->clean()->save([
-            'optType' => '编辑合作点位',
-            'remark' => $this->remark
-        ]);
-        return ['logs' => $logs];
-    }
-
-    /**
-     * 删除
-     * @param $selected
-     */
-    public static function delete($selected) {
-        foreach ($selected as $select) {
-            $userTeamwork = UserTeamwork::findOneAsArray('ID=:ID', [':ID' => $select], 'USER_ID');
-            UserInfo::updateAll(['IS_TEAM' => 0, 'IS_TEAM_MAIN' => 0], 'USER_ID=:USER_ID', [':USER_ID' => $userTeamwork['USER_ID']]);
-            // 如果是主合作者位取消了合作,那么子合作者也自动同时取消合作
-            if ($userTeamwork['USER_ID'] == $userTeamwork['MAIN_UID']) {
-                $allTeamUser = UserTeamwork::findAllAsArray('MAIN_UID=:MAIN_UID', [':MAIN_UID' => $userTeamwork['USER_ID']]);
-                foreach ($allTeamUser as $user) {
-                    UserInfo::updateAll(['IS_TEAM' => 0, 'IS_TEAM_MAIN' => 0], 'USER_ID=:USER_ID', [':USER_ID' => $user['USER_ID']]);
-                }
-                UserTeamwork::updateAll(['IS_DEL' => 1], 'MAIN_UID=:MAIN_UID', [':MAIN_UID' => $userTeamwork['USER_ID']]);
-            }
-        }
-    }
-}

+ 0 - 99
common/models/forms/UserTransferPropForm.php

@@ -1,99 +0,0 @@
-<?php
-
-namespace common\models\forms;
-
-use common\helpers\Cache;
-use common\helpers\Date;
-use common\components\Model;
-use common\helpers\Form;
-use common\helpers\user\Balance;
-use common\helpers\user\Info;
-use common\helpers\user\Status;
-use common\libs\logging\operate\AdminOperate;
-use common\models\PerfPeriod;
-use common\models\Period;
-use common\models\UserWallet;
-use common\models\User;
-use common\models\UserClose;
-use common\models\UserInfo;
-use common\models\UserPerf;
-use common\models\UserStatusAudit;
-use common\models\Withdraw;
-use yii\base\Exception;
-
-/**
- * Login form
- */
-class UserTransferPropForm extends Model {
-    public $userIds;
-    public $allowTransfer;
-    public $transferProp;
-    public $remark;
-
-    public function init() {
-        parent::init();
-        $this->adminOperateLogger = new AdminOperate([
-            'fetchClass' => UserInfo::class,
-        ]);
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules() {
-        return [
-            [['userIds', 'transferProp', 'allowTransfer', 'remark'], 'trim'],
-            [['transferProp', 'userIds'], 'required']
-        ];
-    }
-
-    /**
-     * 指定校验场景
-     * @return array
-     */
-    public function scenarios() {
-        $parentScenarios = parent::scenarios();
-        $customScenarios = [
-            'change' => ['userIds', 'transferProp', 'allowTransfer', 'remark'],
-        ];
-        return array_merge($parentScenarios, $customScenarios);
-    }
-
-    public function attributeLabels() {
-        return [
-            'userIds' => '会员ID',
-            'transferProp' => '转账比例',
-        ];
-    }
-
-    /**
-     * 调整比例
-     * @return null
-     * @throws \yii\db\Exception
-     */
-    public function change() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $this->adminOperateLogger->setIsBatch(true)->beforeUpdate($this->userIds, 'USER_ID',['select'=>'USER_ID,ALLOW_TRANSFER,TRANSFER_PROP']);
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            $allUidIn = implode("','", $this->userIds);
-            if(!UserInfo::updateAll(['ALLOW_TRANSFER'=>$this->allowTransfer?$this->allowTransfer:0,'TRANSFER_PROP' => $this->transferProp], "USER_ID IN ('" . $allUidIn . "')")){
-                throw new Exception('调整会员转账/提现比例失败');
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            return null;
-        }
-        $this->adminOperateLogger->setIsBatch(true)->afterUpdate($this->userIds, 'USER_ID',['select'=>'USER_ID,ALLOW_TRANSFER,TRANSFER_PROP']);
-        $this->adminOperateLogger->setBatchField('USER_ID')->clean()->save([
-            'optType' => '调整会员转账/提现比例',
-            'remark' => $this->remark,
-        ]);
-        return $this->userIds;
-    }
-
-}

+ 0 - 702
common/models/forms/WithdrawForm.php

@@ -1,702 +0,0 @@
-<?php
-
-namespace common\models\forms;
-
-use common\components\Model;
-use common\helpers\Cache;
-use common\helpers\Date;
-use common\helpers\Form;
-use common\helpers\Tool;
-use common\helpers\user\Balance;
-use common\helpers\user\Info;
-use common\helpers\user\Status;
-use common\libs\logging\operate\UserOperate;
-use common\models\CompanyBank;
-use common\models\DealType;
-use common\models\DecOrder;
-use common\models\InvoiceAudit;
-use common\models\Order;
-use common\models\PerfPeriod;
-use common\models\Period;
-use common\models\RegType;
-use common\models\User;
-use common\models\UserBonus;
-use common\models\UserInfo;
-use common\models\UserRelation;
-use common\models\UserTeamwork;
-use common\models\Withdraw;
-use common\models\WithdrawLevel;
-use common\helpers\http\LingYunGongApi;
-use yii\base\Exception;
-
-/**
- * Login form
- */
-class WithdrawForm extends Model {
-    public $id;
-    public $selectedIds;
-    public $userName;
-    public $realName;
-    public $idCard;
-    public $regType;
-    public $applyAmount;
-    public $payPassword;
-    public $auditStatus;
-    public $planPaidAt;
-    public $createdAt;
-    public $createRemark;
-    public $withdrawCode;
-    public $withdrawAudit;
-
-    public $sn;
-    public $withdrawPeriodNum;
-    public $paidAt;
-    public $paidFailRemark;
-    public $amount;
-    public $bankRealName;
-    public $bankNo;
-
-    private $_userId;
-
-    public function init() {
-        parent::init();
-        $this->userOperateLogger = new UserOperate([
-            'fetchClass' => Withdraw::class,
-        ]);
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules() {
-        return [
-            [['id', 'userName', 'realName', 'idCard', 'regType', 'applyAmount', 'payPassword', 'planPaidAt', 'auditStatus', 'createdAt', 'remark', 'createRemark', 'selectedIds', 'sn', 'withdrawPeriodNum', 'paidAt', 'paidFailRemark', 'amount', 'bankRealName', 'bankNo'], 'trim'],
-            [['id', 'userName', 'applyAmount', 'payPassword', 'auditStatus','withdrawCode','withdrawAudit'], 'required'],
-            [['id'], 'exist', 'targetClass' => Withdraw::class, 'targetAttribute' => 'ID', 'message' => '提现申请不存在'],
-            [['userName'], 'exist', 'targetClass' => UserInfo::class, 'targetAttribute' => 'USER_NAME', 'message' => '会员不存在'],
-            [['applyAmount'], 'price'],
-            [['applyAmount'], 'isApplyAmount'],
-            [['userName'], 'isUserName'],
-            [['payPassword'], 'validatePassword'],
-            [['withdrawCode'], 'validateCode'],
-            [['withdrawAudit'], 'validateAuditCode'],
-            [['planPaidAt'], 'isPlanPaidAt'],
-            [['selectedIds'], 'isSelected'],
-            [['sn'], 'isSn'],
-            //[['auditStatus'], 'isStatus'],
-        ];
-    }
-
-    /**
-     * 指定场景
-     * @return array
-     */
-    public function scenarios() {
-        $parentScenarios = parent::scenarios();
-        $customScenarios = [
-            'addByAdmin' => ['userName', 'realName', 'idCard', 'regType', 'applyAmount', 'createRemark'],
-            'addByUser' => ['applyAmount', 'payPassword','withdrawCode'],
-            'addByAuto' => ['userName', 'applyAmount'],
-            'statusByAdmin' => ['selectedIds', 'auditStatus', 'createRemark','planPaidAt', 'paidAt','withdrawAudit'],
-            'editByAdmin' => ['id', 'planPaidAt', 'createRemark'],
-            'backByUser' => ['id', 'createRemark'],
-            'excelPaidFalse' => ['sn', 'withdrawPeriodNum', 'paidAt', 'paidFailRemark', 'userName', 'realName', 'amount', 'bankRealName', 'bankNo'],
-        ];
-        return array_merge($parentScenarios, $customScenarios);
-    }
-
-    /**
-     * @return array
-     */
-    public function attributeLabels() {
-        return [
-            'id' => '提现申请ID',
-            'userName' => '会员编号',
-            'applyAmount' => '申请提现的金额',
-            'withdrawCode' => '申请提现校验码',
-            'withdrawAudit' => '提现审核校验码',
-        ];
-    }
-
-    /**
-     * 用户名是否正确
-     * @param $attributes
-     * @throws Exception
-     */
-    public function isUserName($attributes) {
-        $userInfo = UserInfo::findOneAsArray(['USER_NAME' => $this->userName]);
-        if ($userInfo) {
-            if ($this->scenario == 'addByAdmin') {
-                $baseInfo = Info::baseInfoZh($userInfo['USER_ID']);
-                if ($baseInfo['REAL_NAME'] != $this->realName || $baseInfo['ID_CARD'] != $this->idCard) {
-                    $this->addError($attributes, '输入的会员姓名或身份证号与系统不一致');
-                }
-                if ($userInfo['REG_TYPE'] != $this->regType) {
-                    $this->addError($attributes, '选择的会员注册类型与系统不一致');
-                }
-            }
-            $this->_userId = $userInfo['USER_ID'];
-        } else {
-            $this->addError($attributes, $this->userName . '会员不存在');
-        }
-    }
-
-    /**
-     * 校验申请金额是否小于当前余额并符合配置中的设置
-     * @param $attribute
-     * @return bool
-     */
-    public function isApplyAmount($attribute) {
-        $config = Cache::getSystemConfig();
-        if ($this->applyAmount <= 0) {
-            $this->addError('scenario', '提现金额必须大于0');
-        }
-        if ((int)($this->applyAmount)!=$this->applyAmount) {
-            $this->addError('scenario', '提现金额必须是整数');
-        }
-        $minAmount = 0;
-        $maxAmount = 0;
-        if ($this->scenario == 'addByUser') {
-            $minAmount = $config['manualWithdrawMinAmount']['VALUE'];
-//            $maxAmount = $config['manualWithdrawMaxAmount']['VALUE'];
-            $this->_userId = \Yii::$app->user->id;
-        } elseif ($this->scenario == 'addByAdmin') {
-            $userInfo = UserInfo::findOneAsArray(['USER_NAME' => $this->userName]);
-            $this->_userId = $userInfo['USER_ID'];
-        } else {
-            $this->addError($attribute, '场景不存在');
-            return false;
-        }
-        if ($minAmount != 0 && $this->applyAmount < $minAmount) {
-            $this->addError($attribute, '提现金额不能少于' . $minAmount . '元');
-        }
-        if ($maxAmount != 0 && $this->applyAmount > $maxAmount) {
-            $this->addError($attribute, '提现金额不能高于' . $maxAmount . '元');
-        }
-
-        // 提现条件判断
-        $orderAmount = Order::find()->where('USER_ID=:USER_ID', [':USER_ID' => $this->_userId])->SUM('ORDER_AMOUNT');
-        $recNum = intval(DecOrder::find()->where('REC_USER_ID=:REC_USER_ID', [':REC_USER_ID' => $this->_userId])->count());
-        //$recNum = UserRelation::firstFloorChildNum($this->_userId);
-//        if ($orderAmount < 300 && $recNum==0) {
-//            $this->addError($attribute, '奖金不能提现');
-//            return null;
-//        }
-        // 获取当前提现用户的金额
-        if ($this->applyAmount > Balance::getAvailableBalance($this->_userId)) {
-            $this->addError('scenario', '提现金额必须小于的可用余额');
-        }
-    }
-
-    /**
-     * 校验支付密码
-     * @param $attribute
-     * @param $params
-     */
-    public function validatePassword($attribute, $params) {
-        if (!User::validatePayPassword($this->_userId, $this->payPassword)) {
-            $this->addError($attribute, '支付密码不正确');
-        }
-    }
-
-    public function validateCode($attribute) {
-        $uid = \Yii::$app->user->id;
-        $redisCode = \Yii::$app->redis->getset('withdrawCode_'.$uid,'');
-        \Yii::$app->redis->del('withdrawCode_'.$uid);
-        if ($this->withdrawCode!=$redisCode) {
-            $this->addError($attribute, '申请提现校验失败');
-        }
-    }
-
-    public function validateAuditCode($attribute) {
-        $adminId = \Yii::$app->user->id;
-        $redisCode = \Yii::$app->redis->getset('withdrawAudit_'.$adminId,'');
-        if ($this->withdrawAudit!=$redisCode) {
-            $this->addError($attribute, '提现审核校验失败');
-        }
-    }
-
-    /**
-     * 批量数据
-     * @param $attributes
-     */
-    public function isSelected($attributes) {
-        if (!$this->selectedIds) {
-            $this->addError($attributes, '必须选择一条数据');
-        }
-        if (!is_array($this->selectedIds)) {
-            $this->selectedIds = [$this->selectedIds];
-        }
-    }
-
-    /**
-     * 校验状态
-     * @param $attribute
-     */
-    public function isStatus($attribute) {
-    }
-
-    /**
-     * 计划付款日期
-     * @param $attribute
-     */
-    public function isPlanPaidAt($attribute) {
-        if (Date::utcToTime($this->planPaidAt) < Date::nowTime()) {
-            $this->addError($attribute, '不能选择过去的日期');
-        }
-    }
-
-    /**
-     * 判断信息是否一致
-     * @param $attribute
-     * @throws Exception
-     */
-    public function isSn($attribute) {
-        $sn = $this->sn;
-        if (!$oneWithdraw = Withdraw::findOneAsArray('SN=:SN AND AUDIT_STATUS=:AUDIT_STATUS', [':SN' => $sn, ':AUDIT_STATUS' => Withdraw::STATUS_PAID])) {
-            $this->addError($attribute, '不存在提现流水号为' . $sn . '的已付款记录');
-        }
-        if ($oneWithdraw) {
-            $info = Info::baseInfo($oneWithdraw['USER_ID']);
-            if ($this->userName != $info['USER_NAME']) {
-                $this->addError($attribute, 'Excel中提现流水号' . $sn . '的用户名' . $this->userName . '与系统中的信息【' . $info['USER_NAME'] . '】不一致');
-            }
-            if ($this->realName != $info['REAL_NAME']) {
-                $this->addError($attribute, 'Excel中提现流水号' . $sn . '的会员姓名' . $this->realName . '与系统中的信息【' . $info['REAL_NAME'] . '】不一致');
-            }
-            if ($this->withdrawPeriodNum != $oneWithdraw['WITHDRAW_PERIOD_NUM']) {
-                $this->addError($attribute, 'Excel中提现流水号' . $sn . '的提现期数' . $this->withdrawPeriodNum . '与系统中的信息【' . $oneWithdraw['WITHDRAW_PERIOD_NUM'] . '】不一致');
-            }
-            if (Date::convert(Date::utcToTime($this->paidAt)) != Date::convert($oneWithdraw['PAID_AT'])) {
-                $this->addError($attribute, 'Excel中提现流水号' . $sn . '的付款日期' . Date::convert(Date::utcToTime($this->paidAt)) . '与系统中的信息【' . Date::convert($oneWithdraw['PAID_AT']) . '】不一致');
-            }
-            if ($this->amount != $oneWithdraw['AMOUNT']) {
-                $this->addError($attribute, 'Excel中提现流水号' . $sn . '的提现金额' . $this->amount . '与系统中的信息【' . $oneWithdraw['AMOUNT'] . '】不一致');
-            }
-            if ($this->bankRealName != $oneWithdraw['REAL_NAME']) {
-                $this->addError($attribute, 'Excel中提现流水号' . $sn . '的实时开户名' . $this->bankRealName . '与系统中的信息【' . $oneWithdraw['REAL_NAME'] . '】不一致');
-            }
-            if ($this->bankNo != $oneWithdraw['BANK_NO']) {
-                $this->addError($attribute, 'Excel中提现流水号' . $sn . '的实时银行账户' . $this->bankNo . '与系统中的信息【' . $oneWithdraw['BANK_NO'] . '】不一致');
-            }
-        }
-    }
-
-
-    /**
-     * 添加提现申请
-     * @return null|string
-     * @throws \yii\db\Exception
-     */
-    public function add() {
-        if (!$this->validate()) {
-            return false;
-        }
-
-        $beforeData = Balance::getLogData(\Yii::$app->user->id);
-        $this->userOperateLogger->saveBeforeContent=$beforeData;
-
-        $config = Cache::getSystemConfig();
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            $nowTime = $this->createdAt ? $this->createdAt : Date::nowTime();
-            $period = Withdraw::getPeriod($nowTime);
-            //扣除会员奖金
-            Balance::changeUserBonus($this->_userId, 'BONUS', -abs($this->applyAmount), ['DEAL_TYPE_ID'=>DealType::WITHDRAW,'REMARK' => $period['nowPeriodNum'].'期'.($this->scenario == 'addByAuto' ? '自动提现' : '手动提现'), 'TIME' => $nowTime]);
-            //增加记录
-            $userInfo = Info::baseInfo($this->_userId);
-
-            //手续费
-            $fees = $this->applyAmount * $config['withdrawFee']['VALUE']/100;
-            $fees = Tool::formatPrice($fees);
-            $realAmount = $this->applyAmount - $fees;
-            //判断付款类型
-            $payType = Withdraw::PAY_TYPE_NO_INVOICE;
-            $withdrawModel = new Withdraw();
-            $withdrawModel->SN = $this->_generateSn();
-            $withdrawModel->USER_ID = $this->_userId;
-            $withdrawModel->ID_CARD = $userInfo['ID_CARD'];
-            $withdrawModel->WITHDRAW_PERIOD_NUM = $period['nowPeriodNum'];
-            $withdrawModel->WITHDRAW_YEAR = $period['nowYear'];
-            $withdrawModel->WITHDRAW_MONTH = $period['nowMonth'];
-            $withdrawModel->PAY_TYPE = $payType;
-            $withdrawModel->IS_AUTO_WITHDRAW = $this->scenario == 'addByAuto' ? 1 : 0;
-            $withdrawModel->AMOUNT = $this->applyAmount;
-            $withdrawModel->FEES = $fees;
-            $withdrawModel->REAL_AMOUNT = $realAmount;
-            $withdrawModel->P_MONTH = Date::ociToDate($period['yearMonth'], Date::OCI_TIME_FORMAT_SHORT_MONTH);
-//            if ($payType == Withdraw::PAY_TYPE_NO_INVOICE) {
-//                $withdrawModel->AUDIT_STATUS = Withdraw::STATUS_AUDITED;
-//                $withdrawModel->AUDITED_AT = $nowTime;
-//            } else {
-            $withdrawModel->AUDIT_STATUS = Withdraw::STATUS_APPLIED;
-//            }
-            $withdrawModel->CREATED_AT = $nowTime;
-            //预计付款时间
-            $withdrawModel->PLAN_PAID_AT = $period['endTime'] + $config['withdrawFreezeDays']['VALUE'] * 3600 * 24;
-
-            if ($this->scenario == 'addByAdmin') {
-                $withdrawModel->UPDATE_ADMIN = \Yii::$app->user->id;
-                $withdrawModel->UPDATE_REMARK = $this->createRemark;
-            }
-            if (!$withdrawModel->save()) {
-                throw new Exception(Form::formatErrorsForApi($withdrawModel->getErrors()));
-            }
-            //考核会员注册类型
-//            RegType::chkRegType($this->_userId, $userInfo['SHOULD_REG_TYPE'], $period['nowYear'], $period['nowMonth']);
-
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('add', $e->getMessage());
-            return false;
-        }
-
-        $afterData = Balance::getLogData(\Yii::$app->user->id);
-        $this->userOperateLogger->saveAfterContent=$afterData;
-        unset($beforeData,$afterData);
-        $this->userOperateLogger->clean()->save([
-            'optType' => '会员提现申请',
-            'userId' => \Yii::$app->user->id,
-            'userName' => Info::getUserNameByUserId(\Yii::$app->user->id),
-            'remark' => $this->createRemark,
-        ]);
-        return $withdrawModel;
-    }
-
-    /**
-     * 检测是否上传身份证
-     * @return int
-     */
-    public function checkHasIdCardInfo() {
-        if ($this->scenario !== 'addByUser') return 0;
-        $userId = \Yii::$app->user->id;
-        $user = User::findOneAsArray('ID=:ID', [':ID' => $userId], 'ID,USER_NAME,ID_CARD');
-        if( !$user ) {
-            $this->addError('add', '不存在该用户');
-            return -1;
-        }
-        if( !$user['ID_CARD'] ) {
-            $this->addError('add', '完善身份信息后才可以提现');
-            return -1;
-        }
-
-        $response = LingYunGongApi::hasIdCardInfo($user['ID_CARD']);
-        if( !$response ) {
-            $this->addError('add', '接口网络错误');
-            return -1;
-        }
-
-        if( !isset($response['has']) ) {
-            $this->addError('add', '接口格式错误');
-            return -1;
-        }
-
-
-        if( $response['has'] === true ) {
-            return 0;
-        }else {
-            $this->addError('add', $response['err_msg']['msg']);
-            return -2;
-        }
-    }
-
-    /**
-     * 生成流水号
-     * @return string
-     */
-    private function _generateSn() {
-        return 'TX' . Date::today('Ymd') . $this->_random(10, 1);
-    }
-
-    /**
-     * 生成随机数
-     *
-     * @param $length
-     * @param int $numeric
-     * @return string
-     */
-    private function _random($length, $numeric = 0) {
-        $seed = base_convert(md5(microtime() . $_SERVER['DOCUMENT_ROOT']), 16, $numeric ? 10 : 35);
-        $seed = $numeric ? (str_replace('0', '', $seed) . '012340567890') : ($seed . 'zZ' . strtoupper($seed));
-        $hash = '';
-        $max = strlen($seed) - 1;
-        for ($i = 0; $i < $length; $i++) {
-            $hash .= $seed[mt_rand(0, $max)];
-        }
-        return $hash;
-    }
-
-    /**
-     * 生成随机数
-     * @param $length
-     * @param int $numeric
-     * @return string
-     */
-    public function wdcode($length, $numeric = 0) {
-        $seed = base_convert(md5(microtime() . $_SERVER['DOCUMENT_ROOT']), 16, $numeric ? 10 : 35);
-        $seed = $numeric ? (str_replace('0', '', $seed) . '012340567890') : ($seed . 'zZ' . strtoupper($seed));
-        $hash = '';
-        $max = strlen($seed) - 1;
-        for ($i = 0; $i < $length; $i++) {
-            $hash .= $seed[mt_rand(0, $max)];
-        }
-        return $hash;
-    }
-
-    /**
-     * 修改预计打款日期
-     * @return null|static
-     * @throws \yii\db\Exception
-     */
-    public function editByAdmin() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            $oneWithdraw = Withdraw::findOne(['ID' => $this->id]);
-            $oneWithdraw->UPDATE_ADMIN = \Yii::$app->user->id;
-            $oneWithdraw->REMARK = $this->createRemark;
-            $planPaidAt = Date::utcToTime($this->planPaidAt);
-            if ($oneWithdraw->PLAN_PAID_AT != $planPaidAt) {
-                $oneWithdraw->PLAN_PAID_AT = $planPaidAt;
-            }
-            if (!$oneWithdraw->save()) {
-                throw new Exception(Form::formatErrorsForApi($oneWithdraw->getErrors()));
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('status', $e->getMessage());
-            return null;
-        }
-        return $oneWithdraw;
-    }
-
-    /**
-     * 前台提现退回
-     * @return null|static
-     * @throws \yii\db\Exception
-     */
-    public function backByUser() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $oneWithdraw = Withdraw::findOne(['ID' => $this->id]);
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            if (Cache::getSystemConfig()['isCanWithdrawBack']['VALUE'] != 1) {
-                throw new Exception('提现退回已关闭');
-            }
-            if (!Withdraw::find()->where('USER_ID=:USER_ID AND ID=:ID AND AUDIT_STATUS=:AUDIT_STATUS_1', ['USER_ID' => \Yii::$app->user->id, ':ID' => $this->id, ':AUDIT_STATUS_1' => Withdraw::STATUS_APPLIED])->exists()) {
-                throw new Exception('符合退回的提现记录不存在');
-            }
-            $oneWithdraw->BACK_REMARK = $this->createRemark;
-            $oneWithdraw->BACK_FAIL_AT = Date::nowTime();
-            $oneWithdraw->AUDIT_STATUS = Withdraw::STATUS_RETURN;
-            Balance::changeUserBonus($oneWithdraw['USER_ID'], 'BONUS', abs($oneWithdraw['AMOUNT']), ['DEAL_TYPE_ID'=>DealType::WITHDRAW_RETURN,'REMARK' => $oneWithdraw->WITHDRAW_PERIOD_NUM.'期前台提现退回']);
-            if (!$oneWithdraw->save()) {
-                throw new Exception(Form::formatErrorsForApi($oneWithdraw->getErrors()));
-            }
-
-            //发票设置为审核拒绝
-//            if ($invoiceModel = InvoiceAudit::findOne(['ID' => $oneWithdraw->INVOICE_ID])) {
-//                $invoiceModel->AUDIT_STATUS = \Yii::$app->params['auditStatus']['reject']['value'];
-//                $invoiceModel->AUDIT_REMARK = '提现退回';
-//                $invoiceModel->AUDITED_AT = Date::nowTime();
-//                if (!$invoiceModel->save()) {
-//                    throw new Exception(Form::formatErrorsForApi($invoiceModel->getErrors()));
-//                }
-//            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('auditStatus', $e->getMessage());
-            return null;
-        }
-        return $oneWithdraw;
-    }
-
-    /**
-     * 设置提现订单的状态
-     * @return null|static
-     * @throws \yii\db\Exception
-     */
-    public function changeStatus() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $logs = [];
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            foreach ($this->selectedIds as $select) {
-                $oneWithdraw = Withdraw::findOne(['ID' => $select]);
-                //判断状态
-                if (($msg = Withdraw::chkAuditStatus($oneWithdraw->SN, $oneWithdraw->AUDIT_STATUS, $this->auditStatus)) != '') {
-                    throw new Exception($msg);
-                }
-                //待审核->已审核
-                if ($this->auditStatus == Withdraw::STATUS_AUDITED) {
-                    //同时审核发票
-                    if ($invoiceModel = InvoiceAudit::findOne(['ID' => $oneWithdraw['INVOICE_ID']])) {
-                        if (InvoiceAudit::find()->where('INVOICE_NUM=:INVOICE_NUM AND WITHDRAW_ID!=:WITHDRAW_ID AND AUDIT_STATUS=:AUDIT_STATUS', [':INVOICE_NUM' => $invoiceModel->INVOICE_NUM, ':WITHDRAW_ID' => $invoiceModel->WITHDRAW_ID, ':AUDIT_STATUS' => \Yii::$app->params['auditStatus']['true']['value']])->exists()) {
-                            throw new Exception('提现流水号' . $oneWithdraw->SN . '发票的发票号码【' . $invoiceModel->INVOICE_NUM . '】已被使用');
-                        }
-                        $invoiceModel->AUDIT_ADMIN = \Yii::$app->user->id;
-                        $invoiceModel->CREATE_REMARK = $this->createRemark ?? '';
-                        $invoiceModel->AUDITED_AT = Date::nowTime();
-                        if (!$invoiceModel->save()) {
-                            throw new Exception(Form::formatErrorsForApi($invoiceModel->getErrors()));
-                        }
-                    }
-                    $oneWithdraw->REMARK = $this->createRemark ?? '';
-                } //已审核->待付款
-                elseif ($this->auditStatus == Withdraw::STATUS_WAIT_PAID) {
-                    $oneWithdraw->PAID_FAIL_REMARK = '';
-                    $oneWithdraw->PAID_FAIL_AT = 0;
-                    $oneWithdraw->REMARK = $this->createRemark ?? '';
-                    $oneWithdraw->PLAN_PAID_AT = Date::utcToTime($this->planPaidAt);
-                } //待付款->已付款
-                elseif ($this->auditStatus == Withdraw::STATUS_PAID) {
-                    $oneWithdraw->PAID_AT = Date::utcToTime($this->paidAt);
-                    //记录付款信息
-                    $baseInfo = Info::baseInfo($oneWithdraw->USER_ID);
-                    if ($baseInfo['REG_TYPE'] == '758BF69C25C3422AA7743936BC77EE64') {
-                        $companyBank = CompanyBank::findOneAsArray('USER_ID=:USER_ID', [':USER_ID' => $baseInfo['ID']]);
-                        $oneWithdraw->REAL_NAME = $companyBank['OPEN_NAME'];
-                        $oneWithdraw->OPEN_BANK = $companyBank['OPEN_BANK'];
-                        $oneWithdraw->BANK_PROVINCE = $companyBank['BANK_PROVINCE'];
-                        $oneWithdraw->BANK_CITY = $companyBank['BANK_CITY'];
-                        $oneWithdraw->BANK_COUNTY = $companyBank['BANK_COUNTY'];
-                        $oneWithdraw->BANK_ADDRESS = $companyBank['BANK_ADDRESS'];
-                        $oneWithdraw->BANK_NO = $companyBank['BANK_NO'];
-                    } else {
-                        $oneWithdraw->REAL_NAME = $baseInfo['REAL_NAME'];
-                        $oneWithdraw->OPEN_BANK = $baseInfo['OPEN_BANK'];
-                        $oneWithdraw->BANK_PROVINCE = $baseInfo['BANK_PROVINCE'];
-                        $oneWithdraw->BANK_CITY = $baseInfo['BANK_CITY'];
-                        $oneWithdraw->BANK_COUNTY = $baseInfo['BANK_COUNTY'];
-                        $oneWithdraw->BANK_ADDRESS = $baseInfo['BANK_ADDRESS'];
-                        $oneWithdraw->BANK_NO = $baseInfo['BANK_NO'];
-                    }
-                    $oneWithdraw->REMARK = $this->createRemark ?? '';
-                } //已付款->付款失败
-                elseif ($this->auditStatus == Withdraw::STATUS_PAID_FALSE) {
-                    $oneWithdraw->PAID_FAIL_AT = Date::nowTime();
-                    $oneWithdraw->PAID_FAIL_REMARK = $this->createRemark ?? '';
-                } //提现退回
-                elseif ($this->auditStatus == Withdraw::STATUS_RETURN) {
-                    $oneWithdraw->BACK_REMARK = $this->createRemark ?? '';
-                    $oneWithdraw->BACK_FAIL_AT = Date::nowTime();
-                    Balance::changeUserBonus($oneWithdraw['USER_ID'], 'BONUS', abs($oneWithdraw['AMOUNT']), ['DEAL_TYPE_ID' => DealType::WITHDRAW_RETURN, 'REMARK' => $oneWithdraw->WITHDRAW_PERIOD_NUM . '期' . ($oneWithdraw->IS_AUTO_WITHDRAW ? '自动' : '手动') . '提现退回']);
-                    //发票设置为审核拒绝
-                    $invoiceModel = InvoiceAudit::findOne(['ID' => $oneWithdraw->INVOICE_ID]);
-                    if ($invoiceModel) {
-                        $invoiceModel->AUDIT_STATUS = \Yii::$app->params['auditStatus']['reject']['value'];
-                        $invoiceModel->AUDIT_ADMIN = \Yii::$app->user->id;
-                        $invoiceModel->AUDIT_REMARK = '提现退回';
-                        $invoiceModel->AUDITED_AT = Date::nowTime();
-                        if (!$invoiceModel->save()) {
-                            throw new Exception(Form::formatErrorsForApi($invoiceModel->getErrors()));
-                        }
-                    }
-                }
-                $oneWithdraw->UPDATE_ADMIN = \Yii::$app->user->id;
-                $oneWithdraw->AUDIT_STATUS = $this->auditStatus;
-                $oneWithdraw->AUDITED_AT = Date::nowTime();
-                if (!$oneWithdraw->save()) {
-                    throw new Exception(Form::formatErrorsForApi($oneWithdraw->getErrors()));
-                }
-                $logs[$select] = $oneWithdraw->SN;
-            }
-            $adminId = \Yii::$app->user->id;
-            \Yii::$app->redis->del('withdrawAudit_'.$adminId);
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('auditStatus', $e->getMessage());
-            return null;
-        }
-        return ['logs' => $logs, 'status' => $this->auditStatus];
-    }
-
-    /**
-     * 标记为付款失败
-     * @return null|static
-     * @throws \yii\db\Exception
-     */
-    public function excelPaidFalse() {
-        if (!$this->validate()) {
-            return null;
-        }
-        $db = \Yii::$app->db;
-        $transaction = $db->beginTransaction();
-        try {
-            $oneWithdraw = Withdraw::findOne(['SN' => $this->sn]);
-            $oneWithdraw->PAID_FAIL_AT = Date::nowTime();
-            $oneWithdraw->PAID_FAIL_REMARK = $this->paidFailRemark;
-            $oneWithdraw->UPDATE_ADMIN = \Yii::$app->user->id;
-            $oneWithdraw->AUDIT_STATUS = Withdraw::STATUS_PAID_FALSE;
-            $oneWithdraw->AUDITED_AT = Date::nowTime();
-            if (!$oneWithdraw->save()) {
-                throw new Exception(Form::formatErrorsForApi($oneWithdraw->getErrors()));
-            }
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            $this->addError('auditStatus', $e->getMessage());
-            return null;
-        }
-        return $oneWithdraw;
-    }
-
-
-    /**
-     * 循环自动提现
-     * @param $limit
-     * @param int $start
-     * @return bool
-     * @throws \yii\db\Exception
-     */
-    public static function autoLoopWithdraw($limit, $start = 0) {
-        // 获取设置自动提现的最低金额
-        $systemConfig = Cache::getSystemConfig();
-        $autoWithdrawMinAmount = $systemConfig['autoWithdrawMinAmount']['VALUE'];
-        $autoWithdrawMaxAmount = $systemConfig['autoWithdrawMaxAmount']['VALUE'];
-        // 获取全部设置了自动提现的会员的奖金大于这个数额的会员
-        $allData = UserInfo::find()->select('UI.USER_ID,UI.USER_NAME,UI.IS_BIND_MAIN,UB.BONUS,UB.BONUS_FREEZE')->from(UserInfo::tableName() . ' AS UI')->join('LEFT JOIN', UserBonus::tableName() . ' AS UB', 'UI.USER_ID=UB.USER_ID')->where('UI.IS_AUTO_WITHDRAW=1 AND (UI.IS_BIND_MAIN=1 OR (UB.BONUS - UB.BONUS_FREEZE >= :WITHDRAW_AMOUNT AND UI.IS_BIND=0))', [':WITHDRAW_AMOUNT' => $autoWithdrawMinAmount])->offset($start)->limit($limit)->asArray()->all();
-        if ($allData) {
-            foreach ($allData as $data) {
-                //本月提现过的忽略
-                if (Withdraw::hasThisMonthWithdraw($data['USER_ID'])) continue;
-                //汇总主点位
-                $collectBind = 0;
-                if ($data['IS_BIND_MAIN'] == 1) {
-                    $transferBonusForm = new TransferBonusForm();
-                    $collectBind = $transferBonusForm->collectBind($data['USER_ID']);
-                }
-                $totalAmount = $data['BONUS'] + $collectBind - $data['BONUS_FREEZE'];
-                if ($autoWithdrawMinAmount != 0 && $totalAmount < $autoWithdrawMinAmount) continue;
-                $formModel = new WithdrawForm();
-                $formModel->scenario = 'addByAuto';
-                $formModel->userName = $data['USER_NAME'];
-                //自动提现金额取整数
-                $formModel->applyAmount = floor(($autoWithdrawMaxAmount > 0 && $totalAmount > $autoWithdrawMaxAmount) ? $autoWithdrawMaxAmount : $totalAmount);
-                if (!$formModel->add()) {
-                    continue;
-                }
-                unset($formModel);
-            }
-            unset($allData);
-            $start = $start + $limit;
-            return self::autoLoopWithdraw($limit, $start);
-        }
-        return true;
-    }
-
-}

+ 0 - 116
common/models/forms/WithdrawLevelForm.php

@@ -1,116 +0,0 @@
-<?php
-namespace common\models\forms;
-
-use common\components\Model;
-use common\helpers\Date;
-use common\models\WithdrawLevel;
-
-/**
- * Login form
- */
-class WithdrawLevelForm extends Model
-{
-    public $id;
-    public $minAmount;
-    public $maxAmount;
-    public $taxPercent;
-
-    /**
-     * @inheritdoc
-     */
-    public function rules()
-    {
-        return [
-            [['minAmount', 'maxAmount', 'taxPercent'], 'trim'],
-            [['minAmount', 'taxPercent'], 'required'],
-            [['id'], 'exist', 'targetClass'=>WithdrawLevel::class, 'targetAttribute'=>'ID'],
-            [['minAmount', 'maxAmount', 'taxPercent'], 'price'],
-            [['minAmount', 'maxAmount'], 'isRightAmount'],
-        ];
-    }
-
-    /**
-     * 指定校验场景
-     * @return array
-     */
-    public function scenarios()
-    {
-        $parentScenarios =  parent::scenarios();
-        $customScenarios = [
-            'add' => ['minAmount', 'maxAmount', 'taxPercent'],
-            'edit' => ['id', 'minAmount', 'maxAmount', 'taxPercent'],
-        ];
-        return array_merge($parentScenarios, $customScenarios);
-    }
-
-    public function attributeLabels()
-    {
-        return [
-            'minAmount' => '最小提现金额',
-            'maxAmount' => '最高提现金额',
-            'taxPercent' => '扣税比率',
-        ];
-    }
-
-    /**
-     * 校验最小金额
-     * @param $attribute
-     */
-    public function isRightAmount($attribute){
-        if($this->maxAmount){
-            if($this->minAmount >= $this->maxAmount){
-                $this->addError($attribute, '最小提现金额比最高提现金额大');
-            }
-        }
-        $where = 'MIN_AMOUNT<=:AMOUNT AND MAX_AMOUNT>=:AMOUNT';
-        $params = [
-            ':AMOUNT'=>$this->$attribute
-        ];
-        if($this->scenario == 'edit'){
-            $where .= ' AND ID<>:ID';
-            $params[':ID'] = $this->id;
-        }
-        if(WithdrawLevel::find()->where($where, $params)->exists()){
-            $this->addError($attribute, $this->attributeLabels()[$attribute].'和其他设置有冲突');
-        }
-        $whereT = 'MIN_AMOUNT<=:AMOUNT AND MAX_AMOUNT IS NULL';
-        $paramsT = [
-            ':AMOUNT'=>floatval($this->$attribute)
-        ];
-        if($this->scenario == 'edit'){
-            $whereT .= ' AND ID<>:ID';
-            $paramsT[':ID'] = $this->id;
-        }
-        if(WithdrawLevel::find()->where($whereT, $paramsT)->exists()){
-            $this->addError($attribute, $this->attributeLabels()[$attribute].'和其他设置有冲突');
-        }
-    }
-
-    /**
-     * 编辑
-     * @return WithdrawLevel|null|static
-     */
-    public function edit(){
-        if(!$this->validate()){
-            return null;
-        }
-        if($this->scenario == 'add'){
-            $model = new WithdrawLevel();
-            $model->CREATED_AT = Date::nowTime();
-        } elseif($this->scenario == 'edit') {
-            $model = WithdrawLevel::findOne(['ID'=>$this->id]);
-        } else {
-            $this->addError('id', '提交场景不存在');
-            return null;
-        }
-        $model->MIN_AMOUNT = $this->minAmount;
-        $model->MAX_AMOUNT = $this->maxAmount;
-        $model->TAX_PERCENT = $this->taxPercent;
-        if($model->save()){
-            return $model;
-        } else {
-            $this->addErrors($model->getErrors());
-            return null;
-        }
-    }
-}

+ 0 - 68
frontendApi/config/menu.php

@@ -28,7 +28,6 @@ return [
         'show'=>1,
         'child'=>[
             ['name'=>'商品列表', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'index', 'routePath'=>'shop/index', 'show'=>1,],
-            //['name'=>'报单列表', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'dec-order-list', 'routePath'=>'shop/dec-order-list', 'show'=>1,],
             ['name'=>'订单列表', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'order-list', 'routePath'=>'shop/order-list', 'show'=>1,],
         ]
     ],
@@ -42,26 +41,9 @@ return [
         'show'=>1,
         'child'=>[
             ['name'=>'个人资料', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'index', 'routePath'=>'user/index', 'show'=>1,],
-            //['name'=>'上传身份证', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'id-card', 'routePath'=>'user/id-card', 'show'=>0,],
-            //['name'=>'开拓会员列表', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'rec-user', 'routePath'=>'user/rec-user', 'show'=>1,],
-//            ['name'=>'点位绑定列表', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'bind', 'routePath'=>'user/bind', 'show'=>1,],
-//            ['name'=>'点位绑定编辑', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'bind-edit', 'routePath'=>'user/bind-edit', 'show'=>0,],
             ['name'=>'重置密码', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'password', 'routePath'=>'user/password', 'show'=>1],
-            //['name'=>'报单管理', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'dec', 'routePath'=>'user/dec', 'show'=>1,'allow'=>'declarer',],
         ]
     ],
-    // 'atlas'=>[
-    //     'name'=>'网络图谱',
-    //     'class' => '',
-    //     'icon'=>'el-icon-data-line',
-    //     'controller'=>'atlas',
-    //     'action'=>'',
-    //     'routePath'=>'atlas',
-    //     'show'=>1,
-    //     'child'=>[
-    //         ['name'=>'安置网络图', 'class'=>'', 'icon'=>'', 'controller'=>'atlas', 'action'=>'network', 'routePath'=>'atlas/network', 'show'=>1,],
-    //     ]
-    // ],
     'bonus'=>[
         'name'=>'奖金管理',
         'class' => '',
@@ -71,58 +53,9 @@ return [
         'routePath'=>'bonus',
         'show'=>1,
         'child'=>[
-            //['name'=>'我的账户', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'index', 'routePath'=>'bonus/index', 'show'=>1,],
             ['name'=>'最新奖金', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'new', 'routePath'=>'bonus/new', 'show'=>1,],
-            //['name'=>'往期奖金', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'other', 'routePath'=>'bonus/other', 'show'=>1,],
-            //['name'=>'实时业绩', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'real-time-perf', 'routePath'=>'bonus/real-time-perf', 'show'=>1,],
-            //['name'=>'房产积分', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'fc-point', 'routePath'=>'bonus/fc-point', 'show'=>1,],
-//            ['name'=>'报单中心补助明细查询', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'flow-bt', 'routePath'=>'bonus/flow-bt', 'show'=>1,],
-//            ['name'=>'报单中心货补追溯', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'trace-fl', 'routePath'=>'bonus/trace-fl', 'show'=>1,],
         ]
     ],
-//     'finance'=>[
-//         'name'=>'财务管理',
-//         'class' => '',
-//         'icon'=>'el-icon-bank-card',
-//         'controller'=>'finance',
-//         'action'=>'',
-//         'routePath'=>'finance',
-//         'show'=>1,
-//         'child'=>[
-// //            ['name'=>'会员复销池余额流水', 'class'=>'', 'icon'=>'', 'controller'=>'finance', 'action'=>'reconsume-pool-flow', 'routePath'=>'finance/reconsume-pool-flow', 'show'=>1,],
-//             ['name'=>'转账记录', 'class'=>'', 'icon'=>'', 'controller'=>'finance', 'action'=>'transfer-list', 'routePath'=>'finance/transfer-list', 'show'=>1,],
-//             ['name'=>'转账', 'class'=>'', 'icon'=>'', 'controller'=>'finance', 'action'=>'transfer-add', 'routePath'=>'finance/transfer-add', 'show'=>0,],
-//             ['name'=>'提现明细', 'class'=>'', 'icon'=>'', 'controller'=>'finance', 'action'=>'withdraw', 'routePath'=>'finance/withdraw', 'show'=>1,],
-//             ['name'=>'申请提现', 'class'=>'', 'icon'=>'', 'controller'=>'finance', 'action'=>'withdraw-add', 'routePath'=>'finance/withdraw-add', 'show'=>0,],
-//             ['name'=>'充值明细', 'class'=>'', 'icon'=>'', 'controller'=>'finance', 'action'=>'recharge', 'routePath'=>'finance/recharge', 'show'=>1,],
-//             ['name'=>'申请充值', 'class'=>'', 'icon'=>'', 'controller'=>'finance', 'action'=>'recharge-add', 'routePath'=>'finance/recharge-add', 'show'=>0,],
-//         ]
-//     ],
-    'article'=>[
-        'name'=>'文章管理',
-        'class' => '',
-        'icon'=>'el-icon-document',
-        'controller'=>'article',
-        'action'=>'',
-        'routePath'=>'article',
-        'show'=>1,
-        'child'=>[
-
-        ]
-    ],
-//    'message'=>[
-//        'name'=>'站内信',
-//        'class' => '',
-//        'icon'=>'el-icon-message',
-//        'controller'=>'message',
-//        'action'=>'',
-//        'routePath'=>'message',
-//        'show'=>1,
-//        'child'=>[
-//            ['name'=>'站内信列表', 'class'=>'', 'icon'=>'', 'controller'=>'message', 'action'=>'index', 'routePath'=>'message/list', 'show'=>1,],
-//            ['name'=>'站内信详情', 'class'=>'', 'icon'=>'', 'controller'=>'message', 'action'=>'detail', 'routePath'=>'message/detail', 'show'=>0,],
-//        ]
-//    ],
     'config'=>[
         'name'=>'设置',
         'class' => '',
@@ -132,7 +65,6 @@ return [
         'routePath'=>'config',
         'show'=>1,
         'child'=>[
-//            ['name'=>'个人设置', 'class'=>'', 'icon'=>'', 'controller'=>'config', 'action'=>'base', 'routePath'=>'config/base', 'show'=>1,],
             ['name'=>'收货地址管理', 'class'=>'', 'icon'=>'', 'controller'=>'config', 'action'=>'receive-address-list', 'routePath'=>'config/receive-address-list', 'show'=>1,],
         ]
     ],

+ 20 - 25
frontendApi/modules/v1/controllers/BonusController.php

@@ -20,18 +20,13 @@ use common\models\CalcBonusBT;
 use common\models\CalcBonusFL;
 use common\models\DealType;
 use common\models\FlowBonus;
-use common\models\FlowCF;
-use common\models\FlowLX;
 use common\models\FlowReconsumePoints;
 use common\models\FlowWallet;
 use common\models\PerfMonth;
 use common\models\Period;
-use common\models\DecRole;
-use common\models\EmployLevel;
 use common\models\ScoreMonth;
 use common\models\UserBonus;
 use common\models\UserWallet;
-use frontendApi\modules\v1\models\User;
 
 class BonusController extends BaseController {
     public $modelClass = CalcBonus::class;
@@ -216,14 +211,14 @@ class BonusController extends BaseController {
         }
         //$t = CalcBonus::find()->yearMonth($yearMonth)->where('USER_ID=:USER_ID AND PERIOD_NUM=:PERIOD_NUM',[':USER_ID'=>\Yii::$app->user->id,':PERIOD_NUM'=>$periodNum])->createCommand()->getRawSql();
         $sysConfig = Cache::getSystemConfig();
-        $data[]=['name'=>'期数','value'=>$periodNum];
-        $data[]=['name'=>'级别','value'=>Cache::getDecLevelConfig()[$calcBonus['LAST_DEC_LV']]['LEVEL_NAME']];
-        $data[]=['name'=>'荣誉','value'=>Cache::getEmpLevelConfig()[$calcBonus['LAST_EMP_LV']]['LEVEL_NAME']];
+        // $data[]=['name'=>'期数','value'=>$periodNum];
+        // $data[]=['name'=>'级别','value'=>Cache::getDecLevelConfig()[$calcBonus['LAST_DEC_LV']]['LEVEL_NAME']];
+        // $data[]=['name'=>'荣誉','value'=>Cache::getEmpLevelConfig()[$calcBonus['LAST_EMP_LV']]['LEVEL_NAME']];
         if($sysConfig['openQY']['VALUE']){
             $data[]=['name'=>'团队奖','value'=>Tool::formatPrice($calcBonus['ORI_BONUS_QY'])];
         }
         if($sysConfig['openYC']['VALUE']) {
-            $data[] = ['name' => '荣奖', 'value' => Tool::formatPrice($calcBonus['ORI_BONUS_YC'])];
+            $data[] = ['name' => '荣奖', 'value' => Tool::formatPrice($calcBonus['ORI_BONUS_YC'])];
         }
         if($sysConfig['openVIP']['VALUE']) {
             $data[] = ['name' => 'VIP奖', 'value' => Tool::formatPrice($calcBonus['ORI_BONUS_VIP'])];
@@ -237,36 +232,36 @@ class BonusController extends BaseController {
         if($sysConfig['openXF']['VALUE']) {
             $data[] = ['name' => '消费奖', 'value' => Tool::formatPrice($calcBonus['ORI_BONUS_XF'])];
         }
-        if($sysConfig['openYJ']['VALUE']) {
-            $data[] = ['name' => '业绩奖', 'value' => Tool::formatPrice($calcBonus['ORI_BONUS_YJ'])];
-        }
+        // if($sysConfig['openYJ']['VALUE']) {
+        //     $data[] = ['name' => '业绩奖', 'value' => Tool::formatPrice($calcBonus['ORI_BONUS_YJ'])];
+        // }
         if($sysConfig['openGX']['VALUE']) {
             $data[] = ['name' => '共享奖', 'value' => Tool::formatPrice($calcBonus['ORI_BONUS_GX'])];
         }
         if($sysConfig['openGL']['VALUE']) {
             $data[] = ['name' => '管理奖', 'value' => Tool::formatPrice($calcBonus['ORI_BONUS_GL'])];
         }
-        if($sysConfig['openJXS']['VALUE']) {
-            $data[] = ['name' => '团队成长奖', 'value' => Tool::formatPrice($calcBonus['ORI_BONUS_STANDARD'])];
-        }
+        // if($sysConfig['openJXS']['VALUE']) {
+        //     $data[] = ['name' => '团队成长奖', 'value' => Tool::formatPrice($calcBonus['ORI_BONUS_STANDARD'])];
+        // }
 //        if($sysConfig['openLS']['VALUE']) {
 //            $data[] = ['name' => '零售奖', 'value' => Tool::formatPrice($calcBonus['BONUS_LS'])];
 //        }
 //        $data[]=['name'=>'责任业绩扣除','value'=>Tool::formatPrice($calcBonus['DEDUCT_ZR'])];
-        $data[]=['name'=>'总奖金','value'=>Tool::formatPrice($calcBonus['BONUS_TOTAL'])];
-        $data[]=['name'=>'管理费','value'=>Tool::formatPrice($calcBonus['MANAGE_TAX'])];
-        $data[]=['name'=>'实发奖金','value'=>Tool::formatPrice($calcBonus['BONUS_REAL'])];
+       // $data[]=['name'=>'总奖金','value'=>Tool::formatPrice($calcBonus['BONUS_TOTAL'])];
+        //$data[]=['name'=>'管理费','value'=>Tool::formatPrice($calcBonus['MANAGE_TAX'])];
+        //$data[]=['name'=>'实发奖金','value'=>Tool::formatPrice($calcBonus['BONUS_REAL'])];
 //        $data[]=['name'=>'总奖金','value'=>Tool::formatPrice($calcBonus['BONUS_TOTAL'])];
-        $data[] = ['name' => '复消积分', 'value' => Tool::formatPrice($calcBonus['RECONSUME_POINTS'])];
+        //$data[] = ['name' => '复消积分', 'value' => Tool::formatPrice($calcBonus['RECONSUME_POINTS'])];
 //        if($sysConfig['openLX']['VALUE']) {
 //            $data[] = ['name' => '福利积分二', 'value' => Tool::formatPrice($calcBonus['BONUS_LX'])];
 //        }
-        $data[]=['name'=>'一市场新增业绩','value'=>Tool::formatFrontPerf($calcBonus['PV_1L'])];
-        $data[]=['name'=>'二市场新增业绩','value'=>Tool::formatFrontPerf($calcBonus['PV_2L'])];
-        $data[]=['name'=>'三市场新增业绩','value'=>Tool::formatFrontPerf($calcBonus['PV_3L'])];
-        $data[]=['name'=>'一市场结余业绩','value'=>Tool::formatFrontPerf($calcBonus['SURPLUS_1L'])];
-        $data[]=['name'=>'二市场结余业绩','value'=>Tool::formatFrontPerf($calcBonus['SURPLUS_2L'])];
-        $data[]=['name'=>'三市场结余业绩','value'=>Tool::formatFrontPerf($calcBonus['SURPLUS_3L'])];
+        // $data[]=['name'=>'一市场新增业绩','value'=>Tool::formatFrontPerf($calcBonus['PV_1L'])];
+        // $data[]=['name'=>'二市场新增业绩','value'=>Tool::formatFrontPerf($calcBonus['PV_2L'])];
+        // $data[]=['name'=>'三市场新增业绩','value'=>Tool::formatFrontPerf($calcBonus['PV_3L'])];
+        // $data[]=['name'=>'一市场结余业绩','value'=>Tool::formatFrontPerf($calcBonus['SURPLUS_1L'])];
+        // $data[]=['name'=>'二市场结余业绩','value'=>Tool::formatFrontPerf($calcBonus['SURPLUS_2L'])];
+        // $data[]=['name'=>'三市场结余业绩','value'=>Tool::formatFrontPerf($calcBonus['SURPLUS_3L'])];
 //        $data[]=['name'=>'四市场新增业绩','value'=>Tool::formatFrontPerf($calcBonus['PV_4L'])];
 //        $data[]=['name'=>'五市场新增业绩','value'=>Tool::formatFrontPerf($calcBonus['PV_5L'])];
 //        $data[]=['name'=>'虚拟市场新增业绩','value'=>Tool::formatFrontPerf($calcBonus['PV_LS_TOUCH'])];

+ 0 - 5
frontendApi/modules/v1/controllers/SiteController.php

@@ -109,11 +109,6 @@ class SiteController extends BaseController
         $empLevels = Cache::getEmpLevelConfig();
         // 菜单
         $menu = require Yii::getAlias('@frontendApi/config/menu.php');
-        // 获取全部文章分类
-        $allArticleCategory = ArticleCategory::getAllCategory();
-        foreach($allArticleCategory as $category){
-            $menu['article']['child'][] = ['name'=>$category['CATE_NAME'], 'class'=>'', 'icon'=>'', 'controller'=>'article', 'action'=>'list', 'routePath'=>'article/list/'.$category['ID'], 'show'=>1,];
-        }
         $menu = $this->_childMenu($menu);
         // 时间差
         $daysDiff = Yii::$app->params['daysDiff'];

+ 31 - 31
frontendEle/src/router/index.js

@@ -285,37 +285,37 @@ export const constantRouterMap = [
 
     ]
   },
-  {
-    path: '/article',
-    component: layout,
-    redirect: '/article/list',
-    children: [
-      {
-        path: '/article/list/:cid',
-        component: _import('article/list'),
-        name: 'article_list',
-        meta: {
-          title: '文章列表',
-          breadcrumb: [
-            {title: '首页', path: '/dashboard/index'},
-            {title: '文章管理', path: '/article/list'},
-          ],
-        },
-      },
-      {
-        path: '/article/detail/:id',
-        component: _import('article/detail'),
-        name: 'article_detail',
-        meta: {
-          title: '文章详情',
-          breadcrumb: [
-            {title: '首页', path: '/dashboard/index'},
-            {title: '文章管理', path: '/article/list'},
-          ],
-        },
-      },
-    ]
-  },
+  // {
+  //   path: '/article',
+  //   component: layout,
+  //   redirect: '/article/list',
+  //   children: [
+  //     {
+  //       path: '/article/list/:cid',
+  //       component: _import('article/list'),
+  //       name: 'article_list',
+  //       meta: {
+  //         title: '文章列表',
+  //         breadcrumb: [
+  //           {title: '首页', path: '/dashboard/index'},
+  //           {title: '文章管理', path: '/article/list'},
+  //         ],
+  //       },
+  //     },
+  //     {
+  //       path: '/article/detail/:id',
+  //       component: _import('article/detail'),
+  //       name: 'article_detail',
+  //       meta: {
+  //         title: '文章详情',
+  //         breadcrumb: [
+  //           {title: '首页', path: '/dashboard/index'},
+  //           {title: '文章管理', path: '/article/list'},
+  //         ],
+  //       },
+  //     },
+  //   ]
+  // },
   {
     path: '/message',
     component: layout,

+ 0 - 33
frontendEle/src/views/dashboard/index.vue

@@ -3,31 +3,18 @@
     <div>
       <div class="welcome" :style="getEmpBg(myEmpLv['ICON_TYPE'])">
         <h1>欢迎您,{{userName}}
-
         <b v-if="verified==='0'" class="text-danger"> 您未实名认证,请登录商城系统完善会员资料并上传身份证</b>
         </h1>
         <el-row :gutter="0" class="wel-info">
           <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12">
             <el-row :gutter="10">
               <el-col :xs="24" :sm="24" :md="24" :lg="8" :xl="12">当前系统时间:{{nowDateTime}}</el-col>
-              <!-- <el-col :xs="24" :sm="24" :md="24" :lg="4" :xl="12">聘级:{{myEmpLv['LEVEL_NAME']!='无聘级'?myEmpLv['LEVEL_NAME']:''}}<span v-if="myEmpLv['ICON_TYPE']==0">无</span><img
-                  :src="getEmpIco(myEmpLv['ICON_TYPE'])" alt=""
-                  v-for="(o,key) in parseInt(myEmpLv['ICON_NUM'])"
-                  :key="key" v-if="myEmpLv['ICON_TYPE']>0">
-              </el-col> -->
-              <!-- <el-col :xs="24" :sm="24" :md="24" :lg="4" :xl="12">会员级别:{{decLvName}}</el-col> -->
-              <!-- <el-col :xs="24" :sm="24" :md="24" :lg="8" :xl="12">当前业绩期:{{periodNum}}</el-col> -->
             </el-row>
           </el-col>
         </el-row>
       </div>
       <div style="display: none;">
-<!--        <el-button type="primary" @click="go('/config/base')">个人设置</el-button>-->
         <el-button type="success" @click="go('/user/index')">个人资料</el-button>
-<!--        <el-button type="danger" @click="go('/user/rec-user')">开拓会员</el-button>-->
-        <el-button type="primary" @click="go('/finance/flow-bonus')">奖金流水</el-button>
-        <el-button type="warning" @click="go('/finance/withdraw')">提现明细</el-button>
-        <el-button type="success" @click="go('/finance/perf')">往期业绩</el-button>
       </div>
     </div>
     <el-carousel trigger="click" :height="bannerHeight+'px'">
@@ -42,24 +29,6 @@
         </template>
       </el-carousel-item>
     </el-carousel>
-
-    <el-row :gutter="10" class="news-c">
-      <el-col :xs="24" :sm="24" :md="12" :lg="8" :xl="8" v-for="(item,key) in news" :key="key">
-        <el-card class="box-card">
-          <div slot="header" class="clearfix">
-            <span>{{item.CATE_NAME}}</span>
-            <el-button type="text" class="box-card-more">
-              <router-link :to="`/article/list/${item.ID}`">more+</router-link>
-            </el-button>
-          </div>
-          <div v-for="(o,k) in item.LISTS" :key="k" class="text item" v-if="item.LISTS.length>0">
-            <router-link :to="`/article/detail/${o.ID}`" :title="o.TITLE">{{sub_str(o.TITLE)}}</router-link>
-            <span>{{tool.formatDate(o.CREATED_AT,false)}}</span>
-          </div>
-          <div v-if="item.LISTS.length==0">暂无内容</div>
-        </el-card>
-      </el-col>
-    </el-row>
   </div>
 </template>
 
@@ -82,7 +51,6 @@
         // this.myEmpLv.ICON_TYPE = this.baseEmpLevels[response.empLv]['ICON_TYPE']
         // this.myEmpLv.ICON_NUM = this.baseEmpLevels[response.empLv]['ICON_NUM']
         this.slides = response.slides
-        this.news = response.news
         this.periodNum = response.periodNum
         this.decLvName = response.decLvName
         this.loading = false
@@ -113,7 +81,6 @@
         baseEmpLevels: baseInfo.empLevels(),
         myEmpLv: {'ID': 0, 'LEVEL_NAME': null, 'ICON_TYPE': 0, 'ICON_NUM': 0},
         slides: [],
-        news: [],
         periodNum: '',
         decLvName: '',
         bannerHeight: ''

+ 0 - 7
frontendEle/src/views/shop/index.vue

@@ -7,11 +7,6 @@
                     type="selection"
                     width="55">
                 </el-table-column>
-                <!-- <el-table-column label="创建时间"> 
-                     <template slot-scope="scope">
-                        {{tool.formatDate(scope.row.CREATED_AT)}}
-                    </template> 
-                </el-table-column> -->
                 <el-table-column label="商品名称" prop="GOODS_NAME">
                    
                 </el-table-column>
@@ -24,8 +19,6 @@
 
                 <el-table-column label="商品价格" prop="SELL_PRICE">
                 </el-table-column>
-                <el-table-column label="价格PV" prop="PRICE_PV">
-                </el-table-column>
                 <el-table-column label="库存" prop="STORE_NUMS">
                 </el-table-column>
 

+ 1 - 9
frontendEle/src/views/shop/order-list.vue

@@ -9,17 +9,12 @@
                 </el-table-column>
                 <el-table-column label="订单编号" prop="SN">
                 </el-table-column>
-              <!--  <el-table-column label="会员ID" prop="USER_ID">
-
-                </el-table-column>-->
                 <el-table-column label="会员编号" prop="USER_NAME">
 
                 </el-table-column>
 
                 <el-table-column label="订单金额" prop="ORDER_AMOUNT">
                 </el-table-column>
-                <el-table-column label="订单PV" prop="PV">
-                </el-table-column>
                 <el-table-column label="收货人" prop="CONSIGNEE">
                 </el-table-column>
                 <el-table-column label="收货电话" prop="MOBILE">
@@ -68,18 +63,15 @@
             },
             getData(page, pageSize) {
                 network.getPageData(this, 'shop/order-list', page, pageSize, {type: this.type}, function (response) {
-                    console.log(response)
                     this.loading = false;
                     this.list = response.list;
                     let settingObj=this.list;
                     let settingArr = Object.keys(settingObj).map(key => {
                         //console.log(key); //为每个键名
                         return settingObj[key];  //把每个对象返回出去生成一个新的数组中相当于0:{id:1}
-                    } );
+                    });
                     this.tableData=settingArr;
                     console.log(this.tableData)
-
-
                 });
             },
         }

+ 1 - 17
frontendEle/src/views/shop/order.vue

@@ -16,8 +16,6 @@
 
                     <el-table-column label="商品价格" prop="SELL_PRICE">
                     </el-table-column>
-                    <el-table-column label="价格PV" prop="PRICE_PV">
-                    </el-table-column>
                     <el-table-column label="库存" prop="STORE_NUMS">
                     </el-table-column>
 
@@ -63,10 +61,6 @@
                         <div>实付金额</div>
                         <div>¥{{payType=="cash"?cashSum:pointsSum}}元</div>
                     </div>
-                    <!-- <div class="sum_box">
-                        <div>账户积分</div>
-                        <div>{{balance.points}}</div>
-                    </div> -->
                     <div class="sum_box">
                         <div>账户余额</div>
                         <div>¥{{balance.cash}}元</div>
@@ -155,9 +149,6 @@
                     })
 
                 })
-
-
-
             },
             getSumMoney(){
                 // let points_plus_sum=[];
@@ -185,14 +176,7 @@
                 }else{
                   this.pointFreight = this.freight = 15;
                 }
-                // if(payPointAmount>=300){
-                //     this.pointFreight = 0;
-                // }else{
-                //     this.pointFreight = 15;
-                // }
-                //console.log('points_plus_sum',points_plus_sum);
-                //console.log('cash_plus_sum',cash_plus_sum);
-                // this.pointsSum=tool.formatPrice(tool.sum(points_plus_sum) + this.pointFreight);
+                
               this.pointsSum = this.cashSum = tool.formatPrice(tool.sum(cash_plus_sum) + this.freight) ;
             },
             getShowCart(){

+ 1 - 32
frontendEle/src/views/user/index.vue

@@ -7,37 +7,9 @@
             <el-form-item label="会员编号">
               <el-input v-model="infoData.USER_NAME" :disabled="true"></el-input>
             </el-form-item>
-            <el-form-item label="民族">
-              <el-select v-model="infoData.NATION" placeholder="请选择民族">
-                <el-option v-for="(item,index) in allNation" :key="index" :label="item.name"
-                           :value="item.id"></el-option>
-              </el-select>
-            </el-form-item>
             <el-form-item label="会员姓名">
               <el-input v-model="infoData.REAL_NAME" :disabled="true"></el-input>
             </el-form-item>
-            <!-- <el-form-item label="身份证号">
-              <el-input v-model="infoData.ID_CARD" :disabled="true"></el-input>
-            </el-form-item>
-            <el-form-item label="手机号">
-              <el-input v-model="infoData.MOBILE" :disabled="true"></el-input>
-            </el-form-item>
-            <el-form-item label="银行名称">
-              <el-select v-model="infoData.OPEN_BANK" placeholder="请选择银行名称">
-                <el-option v-for="(item,index) in allOpenBank" :key="index" :label="item.BANK_NAME"
-                           :value="item.BANK_CODE"></el-option>
-              </el-select>
-
-            </el-form-item>
-            <el-form-item label="开户行地址">
-              <el-input v-model="infoData.BANK_ADDRESS"></el-input>
-            </el-form-item>
-            <el-form-item label="银行帐号">
-              <el-input v-model="infoData.BANK_NO"></el-input>
-            </el-form-item> -->
-            <el-form-item>
-              <el-button type="primary" @click="handleSubmit" :loading="submitButtonStat">保存</el-button>
-            </el-form-item>
           </el-form>
         </el-tab-pane>
       </el-tabs>
@@ -46,10 +18,7 @@
 </template>
 
 <script>
-import Vue from 'vue'
 import network from './../../utils/network'
-import tool from './../../utils/tool'
-import store from '@/utils/vuexStore'
 
 export default {
   name: 'user_index',
@@ -89,7 +58,7 @@ export default {
         this.submitButtonStat = true
         let path = 'user/edit'
         let postData = {
-            nation: this.infoData.NATION,
+            nation: 0,
             realName: this.infoData.REAL_NAME,
             idCard: this.infoData.ID_CARD,
             mobile: this.infoData.MOBILE,