Selaa lähdekoodia

Merge branch 'master' into feature/new-backend-adaptation

# Conflicts:
#	common/models/forms/OrderForm.php
#	frontendApi/modules/v1/controllers/ShopController.php
kevin_zhangl 2 vuotta sitten
vanhempi
commit
b9bc5f87d9

+ 22 - 2
common/helpers/bonus/Calc/CalcConsole.php

@@ -165,14 +165,34 @@ class CalcConsole extends BaseBusiness
         $nowHour = date("H", $nowTs);
         $nowMin = date("i", $nowTs);
         $nowSec = date("s", $nowTs);
-        if($nowDate >1 && $nowDate <= 15 || (($nowMin!=0 || $nowSec >= 5 ) || Period::isPreparing($periodNum)) ){ // 当不是整点小时,当计算中,不计算
+
+        if(Period::isPreparing($periodNum)){ // 当计算中,则跳过
             return;
         }
 
-        if (($nowTs + 86400 < $currentPeriod['END_TIME']) && $nowHour > 0) {
+        if(($nowMin!=0 || $nowSec >= 5)){ // 如果不是整点小时,跳过
             return;
         }
 
+        if( 1 < $nowDate && 10 >= $nowDate ){ // 10号及以前,不是0点,则跳过
+            if( $nowHour != 0) {
+                return;
+            }
+        }
+
+        if( 15 < $nowDate && 25 >= $nowDate ){ // 下半月前10天,不是0点,则跳过
+            if( $nowHour != 0) {
+                return;
+            }
+        }
+//        if($nowDate >1 && $nowDate <= 15 || (($nowMin!=0 || $nowSec >= 5 ) || Period::isPreparing($periodNum)) ){ // 当不是整点小时,当计算中,不计算
+//            return;
+//        }
+//
+//        if (($nowTs + 86400 < $currentPeriod['END_TIME']) && $nowHour > 0) {
+//            return;
+//        }
+
         print_r($periodNum."该预结算".$nowMin.PHP_EOL.$nowSec);
 
         //设置计算进行中标识

+ 144 - 0
common/models/ApproachReconsumeOrder.php

@@ -0,0 +1,144 @@
+<?php
+
+namespace common\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "{{%ORDER}}".
+ *
+ * @property string $ID
+ * @property string $SN 订单号
+ * @property string $DEC_SN 报单编号
+ * @property string $USER_ID 用户ID
+ * @property string $USER_NAME 会员编号
+ * @property string $ORDER_TYPE 订货类型
+ * @property string $ORDER_AMOUNT 订单总价格
+ * @property string $PV 订货PV
+ * @property string $PAY_AMOUNT 支付价格
+ * @property string $PAY_PV 实付PV
+ * @property int $PAY_AT 支付时间
+ * @property string $PAY_TYPE 支付方式
+ * @property string $FREIGHT 运费
+ * @property string $PAY_FREIGHT 实付运费金额
+ * @property int $DELIVERY_STATUS 发货状态
+ * @property int $DELIVERY_PERIOD 发货期数
+ * @property int $DELIVERY_AT 发货时间
+ * @property string $EXPRESS_COMPANY 快递公司
+ * @property string $ORDER_TRACK_NO 快递单号
+ * @property int $EXPRESS_TYPE 发货方式
+ * @property string $FRONT_REMARK 前台备注
+ * @property string $REMARK 后台备注
+ * @property int $PERIOD_NUM 期数
+ * @property int $STATUS 订单状态
+ * @property string $CONSIGNEE 收货人
+ * @property string $MOBILE 收货人手机
+ * @property string $TEL 固定电话
+ * @property int $PROVINCE 省份名称
+ * @property int $CITY 城市名称
+ * @property int $COUNTY 县区
+ * @property string $ADDRESS 详细地址
+ * @property string $P_CALC_MONTH 分区日期
+ * @property int $CREATED_AT 订单创建时间
+ * @property string $CREATE_USER 订单创建人
+ * @property int $UPDATED_AT 修改时间
+ * @property string $UPDATER 修改人
+ * @property int $IS_DELETE 是否删除
+ * @property int $DELETED_AT 删除时间
+ * @property int $WAREHOUSE 发货仓
+ * @property string $EMAIL 邮箱
+ * @property string $NOTE 备注说明
+ * @property string $LGA_NAME LGA_NAME
+ * @property string $CITY_NAME 城市
+ * @property string $PAY_AMOUNT_STANDARD 支付价格
+ * @property string $ORDER_AMOUNT_STANDARD 订单总价格($)
+ * @property string $EXCHANGE_RATE 汇率
+ */
+class ApproachReconsumeOrder extends \common\components\ActiveRecord
+{
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return '{{%APPROACH_ORDER}}';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['USER_ID', 'USER_NAME', 'ORDER_TYPE', 'CREATE_USER'], 'required'],
+            [['ORDER_AMOUNT', 'PV', 'PAY_AMOUNT', 'PAY_PV', 'FREIGHT', 'PAY_FREIGHT'], 'number'],
+            [['PAY_AT', 'DELIVERY_STATUS', 'DELIVERY_PERIOD', 'DELIVERY_AT', 'EXPRESS_TYPE', 'PERIOD_NUM', 'STATUS', 'PROVINCE', 'CITY', 'COUNTY', 'CREATED_AT', 'UPDATED_AT', 'IS_DELETE', 'DELETED_AT'], 'integer'],
+            [['ID','SN', 'DEC_SN', 'USER_ID', 'ORDER_TRACK_NO','PAY_TYPE'], 'string', 'max' => 32],
+            [['USER_NAME', 'TEL', 'CREATE_USER', 'UPDATER', 'WAREHOUSE'], 'string', 'max' => 16],
+            [['ORDER_TYPE'], 'string', 'max' => 12],
+            [['EXPRESS_COMPANY'], 'string', 'max' => 128],
+            [['FRONT_REMARK'], 'string', 'max' => 1000],
+            [['REMARK', 'NOTE'], 'string', 'max' => 4000],
+            [['CONSIGNEE'], 'string', 'max' => 120],
+            [['MOBILE'], 'string', 'max' => 11],
+            [['ADDRESS'], 'string', 'max' => 255],
+            [['SN'], 'unique'],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'ID' => 'ID',
+            'SN' => '订单号',
+            'DEC_SN' => '报单编号',
+            'USER_ID' => '用户ID',
+            'USER_NAME' => '会员编号',
+            'ORDER_TYPE' => '订货类型',
+            'ORDER_AMOUNT' => '订单总价格',
+            'PV' => '订货BV',
+            'PAY_AMOUNT' => '支付价格',
+            'PAY_PV' => '实付BV',
+            'PAY_AT' => '支付时间',
+            'PAY_TYPE' => '支付方式',
+            'FREIGHT' => '运费',
+            'PAY_FREIGHT' => '实付运费金额',
+            'DELIVERY_STATUS' => '发货状态',
+            'DELIVERY_PERIOD' => '发货期数',
+            'DELIVERY_AT' => '发货时间',
+            'EXPRESS_COMPANY' => '快递公司',
+            'ORDER_TRACK_NO' => '快递单号',
+            'EXPRESS_TYPE' => '发货方式',
+            'FRONT_REMARK' => '前台备注',
+            'REMARK' => '后台备注',
+            'PERIOD_NUM' => '期数',
+            'STATUS' => '订单状态',
+            'CONSIGNEE' => '收货人',
+            'MOBILE' => '收货人手机',
+            'TEL' => '固定电话',
+            'PROVINCE' => '省份名称',
+            'CITY' => '城市名称',
+            'COUNTY' => '县区',
+            'LGA_NAME' => 'lga name',
+            'CITY_NAME' => 'City name',
+            'ADDRESS' => '详细地址',
+            'P_CALC_MONTH' => '分区日期',
+            'CREATED_AT' => '订单创建时间',
+            'CREATE_USER' => '订单创建人',
+            'UPDATED_AT' => '修改时间',
+            'UPDATER' => '修改人',
+            'IS_DELETE' => '是否删除',
+            'DELETED_AT' => '删除时间',
+            'WAREHOUSE' => '发货仓',
+            'EMAIL' => 'Email'
+        ];
+    }
+
+    public function getUserByUserId()
+    {
+        return $this->hasOne(User::class, ['ID' => 'USER_ID']);
+    }
+}

+ 373 - 372
common/models/forms/AdminAddUserForm.php

@@ -1,372 +1,373 @@
-<?php
-
-namespace common\models\forms;
-
-use backendApi\modules\v1\models\Admin;
-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\libs\logging\operate\AdminOperate;
-use common\models\FlowBonus;
-use common\models\Period;
-use common\models\DeclarationLevel;
-use common\models\DecOrder;
-use common\models\EmployLevel;
-use common\models\User;
-use common\models\UserBind;
-use common\models\UserBonus;
-use common\models\UserInfo;
-use common\models\UserMove;
-use common\models\UserNetwork;
-use common\models\UserRelation;
-use common\models\UserSystem;
-use common\models\UserTeamwork;
-use yii\base\Exception;
-
-/**
- * Login form
- */
-class AdminAddUserForm extends Model {
-    public $userName;
-    public $nation;
-    public $realName;
-    public $idCard;
-    public $mobile;
-    public $address;
-    public $openBank;
-    public $bankAddress;
-    public $bankNo;
-    public $bankAreaSelected;
-    public $decLv;
-    public $areaSelected;
-    public $tel;
-    public $isDec;
-    public $decUserName;
-    public $birthday;
-    public $decRoleId;
-    public $conUserName;
-    public $recUserName;
-    public $location;
-    public $delUserName;
-
-    private $_decId;
-    private $_delUserId;
-
-    public function init() {
-        parent::init();
-        $this->adminOperateLogger = new AdminOperate([
-            'fetchClass' => User::class,
-        ]);
-    }
-
-    /**
-     * @inheritdoc
-     */
-    public function rules() {
-        return [
-            [['userName', 'nation', 'realName', /*'idCard',*/ 'mobile', 'address', 'openBank', 'bankAddress', 'bankNo', 'bankAreaSelected', 'decLv', 'areaSelected', 'tel', 'isDec', 'decUserName', 'birthday', 'decRoleId', 'conUserName', 'recUserName', 'location', 'delUserName'], 'trim'],
-            [['userName', 'realName', /*'idCard',*/ 'decLv', 'decUserName', 'conUserName', 'recUserName', 'location'], 'required'],
-            [['userName'], 'unique', 'targetClass' => UserInfo::class, 'targetAttribute' => 'USER_NAME'],
-            [['conUserName'], 'exist', 'targetClass' => UserInfo::class, 'targetAttribute' => 'USER_NAME'],
-            [['recUserName'], 'exist', 'targetClass' => UserInfo::class, 'targetAttribute' => 'USER_NAME'],
-            [['decLv'], 'exist', 'targetClass' => DeclarationLevel::class, 'targetAttribute' => 'ID'],
-            [['mobile'], 'mobile'],
-//            [['idCard'], 'simpleIdCard'],
-            [['bankNo'], 'string', 'max' => 19],
-            [['decUserName'], 'issetDec'],
-            [['isDec'], 'issetDecRoleId'],
-            [['location'], 'isLocation'],
-            [['delUserName'], 'isDelUserName'],
-            //[['userName'], 'userName'],
-            [['realName', 'address', 'bankAddress'], 'realName'],
-        ];
-    }
-
-    /**
-     * 指定校验场景
-     * @return array
-     */
-    public function scenarios() {
-        $parentScenarios = parent::scenarios();
-        $customScenarios = [
-            'add' => ['userName', 'nation', 'realName', /*'idCard',*/ 'mobile', 'address', 'openBank', 'bankAddress', 'bankNo', 'bankAreaSelected', 'decLv', 'areaSelected', 'tel', 'isDec', 'decUserName', 'birthday', 'decRoleId', 'conUserName', 'recUserName', 'location'],
-            'userDel' => ['delUserName'],
-        ];
-        return array_merge($parentScenarios, $customScenarios);
-    }
-
-    public function attributeLabels() {
-        return [
-            'userName' => 'Member Code',//会员编号
-            'nation' => 'Nation',//民族
-            'realName' => 'Member Name',//会员姓名
-//            'idCard' => 'ID',//身份证号
-            'mobile' => 'Phone Number',//手机号
-            'address' => 'Address',//地址
-            'openBank' => 'Bank Name',//开户行
-            'bankAddress' => 'Account opening sub branch',//开户支行
-            'bankNo' => 'bank account',//银行账号
-            'bankAreaSelected' => 'Banking region',//银行地区
-            'decLv' => 'Real time declaration level',//实时报单级别
-            'areaSelected' => 'Location',//所在地区
-            'tel' => 'Telephone',//电话
-            'isDec' => 'Stockist or not',//是否报单中心
-            'decUserName' => 'Stockist No', // 报单中心编号
-            'birthday' => 'birthday',//生日
-            'decRoleId' => 'Stockist Level',//报单中心级别
-            'conUserName' => 'Contact person Member No',//接点人会员编号
-            'recUserName' => 'Sponsor Member No',
-            'location' => 'Resettlement area',//安置区域
-        ];
-    }
-
-    /**
-     * 是否存在报单中心
-     * @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, 'Stockist does not exist');//报单中心不存在
-        } else {
-            $this->_decId = $decUser['ID'];
-        }
-    }
-
-    /**
-     * 校验是否填写报单中心级别
-     * @param $attribute
-     */
-    public function issetDecRoleId($attribute) {
-        if ($this->isDec && !$this->decRoleId) {
-            $this->addError($attribute, 'Stockist level cannot be empty');//报单中心级别不能为空
-        }
-    }
-
-    public function isLocation($attribute) {
-        if (!in_array($this->location, ['1', '2', '3'])) {
-            $this->addError($attribute, 'Location error');//区位错误
-        }
-    }
-
-    /**
-     * 校验删除的用户是否符合条件
-     * @param $attribute
-     */
-    public function isDelUserName($attribute) {
-        if (!$this->_delUserId = Info::getUserIdByUserName($this->delUserName)) {
-            $this->addError($attribute, 'user does not exist');//用户不存在
-        }
-        if (UserInfo::findOneAsArray('REC_UID=:REC_UID AND DELETED=0', [':REC_UID' => $this->_delUserId], 'USER_ID')) {
-            $this->addError($attribute, 'This member has developed other members and cannot be deleted');//此会员已开拓其它会员不可以删除
-        }
-        if (UserInfo::findOneAsArray('CON_UID=:CON_UID AND DELETED=0', [':CON_UID' => $this->_delUserId], 'USER_ID')) {
-            $this->addError($attribute, 'This member has been placed with other members and cannot be deleted');//此会员已安置其它会员不可以删除
-        }
-        if (User::findOneAsArray('DEC_ID=:DEC_ID AND DELETED=0', [':DEC_ID' => $this->_delUserId], 'ID')) {
-            $this->addError($attribute, 'This member has submitted a bill and other members cannot delete it');//此会员已报单其它会员不可以删除
-        }
-        if (DecOrder::findOneAsArray('USER_ID=:TO_USER_ID OR TO_USER_ID=:TO_USER_ID', [':TO_USER_ID' => $this->_delUserId], 'ID')) {
-            $this->addError($attribute, 'This member has submitted a bill and cannot be deleted');//此会员已报单不可以删除
-        }
-        $info = Info::baseInfoWithNet($this->_delUserId);
-        if ($info['REG_FROM'] == 1) {
-            $this->addError($attribute, 'This member is not empty and cannot be deleted');//此会员不是空单无法删除
-        }
-        $sentMaxPeriodNum = Period::sentMaxPeriodNum();
-        if ($info['PERIOD_AT'] <= $sentMaxPeriodNum) {
-            $this->addError($attribute, 'The number of enrollment periods of this member is less than or equal to the number of online periods');//此会员加入期数小于等于已挂网期数
-        }
-        if (User::find()->where('ID=:ID AND VERIFIED=1', [':ID' => $this->_delUserId])->exists()) {
-            $this->addError($attribute, 'This member has been authenticated by real name and cannot be deleted');//此会员已实名认证无法删除
-        }
-        if (User::find()->where('ID=:ID AND SUB_COM_LEADER=1', [':ID' => $this->_delUserId])->exists()) {
-            $this->addError($attribute, 'This member is a branch leader and cannot be deleted');//此会员是分公司领导人无法删除
-        }
-        if (UserInfo::find()->where('USER_ID=:USER_ID AND (IS_GROUP_LEADER=1 OR IS_SYSTEM_LEADER=1 OR IS_BIND=1 OR IS_TEAM=1)', [':USER_ID' => $this->_delUserId])->exists()) {
-            $this->addError($attribute, 'This member cannot be deleted due to the following conditions: Team Leader / system leader / point binding / point cooperation');//此会员存在以下情况无法删除,团队领导人/体系领导人/点位绑定/点位合作
-        }
-        if (Balance::hasBonus($this->_delUserId)) {
-            $this->addError($attribute, 'This member has balance and cannot be deleted');//此会员有余额无法删除
-        }
-        if (FlowBonus::findOneAsArray('USER_ID=:USER_ID', [':USER_ID' => $this->_delUserId], 'ID')) {
-            $this->addError($attribute, 'This member has generated a balance flow, which cannot be deleted');//该会员产生过余额流水无法删除
-        }
-        if (UserMove::findOneAsArray('USER_ID=:USER_ID', [':USER_ID' => $this->_delUserId], 'ID')) {
-            $this->addError($attribute, 'The member cannot be deleted due to network migration');//该会员发生过移网无法删除
-        }
-    }
-
-    /**
-     * 添加
-     * @return User|null
-     * @throws \yii\db\Exception
-     */
-    public function edit() {
-        $this->userName = strtoupper($this->userName);
-        if (!$this->validate()) {
-            return null;
-        }
-        $transactionShop = \Yii::$app->db->beginTransaction();
-        try {
-            $period = Period::instance();
-            // 商城表增加会员
-            $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 = 0;
-            $user->REAL_NAME = $this->realName;
-//            $user->ID_CARD = $this->idCard;
-            $user->MOBILE = $this->mobile;
-            $user->ADDRESS = $this->address ? $this->address : 'nothing';//无
-            $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 = $this->decLv;
-            $user->LAST_DEC_LV = $this->decLv;
-            $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->AVATAR = 'avatar/1.png';
-            $user->IS_DEC = $this->isDec ? $this->isDec : 0;
-            $user->DEC_ID = $this->_decId ?? null;
-            //$user->BIRTHDAY = Date::ociToDate($this->birthday, Date::OCI_TIME_FORMAT_DATE);
-            $user->DEC_ROLE_ID = $this->decRoleId ?? null;
-            $user->PERIOD_AT = $period->getNowPeriodNum();
-            $user->REG_FROM = 0;//空单标识
-            $user->IS_DIRECT_SELLER = 0;
-            $user->VERIFIED = 1;
-            $user->VERIFIED_AT = Date::nowTime();
-            $user->USER_CREATOR = Admin::getAdminNameById(\Yii::$app->user->id);
-            if (!$user->save()) {
-                throw new Exception(Form::formatErrorsForApi($user->getErrors()));
-            }
-            // 获取报单级别的设置
-            $decLevelConfig = Cache::getDecLevelConfig();
-            $decLevelPv = $decLevelConfig[$this->decLv]['PERF'];
-            $userForm = new UserForm();
-            $userForm->scenario = 'addByAdmin';
-            $userForm->userId = $user->ID;
-            $userForm->userName = $this->userName;
-            $userForm->zcAmount = $decLevelPv;
-            $userForm->zcPv = $decLevelPv;
-            $userForm->conUserName = $this->conUserName;
-            $userForm->recUserName = $this->recUserName;
-            $userForm->location = $this->location;
-            if (!$userForm->add()) {
-                throw new Exception(Form::formatErrorsForApi($userForm->getErrors()));
-            }
-            $transactionShop->commit();
-        } catch (Exception $e) {
-            $transactionShop->rollBack();
-            $this->addError('add', $e->getMessage());
-            return null;
-        }
-
-        $select = new \yii\db\Expression('ID,REAL_NAME,ID_CARD,MOBILE,ADDRESS,OPEN_BANK,BANK_ADDRESS,BANK_NO,BANK_PROVINCE,BANK_CITY,BANK_COUNTY,CREATED_AT,DEC_LV,EMP_LV,PROVINCE,CITY,COUNTY,TEL,SUB_COM_ID,IS_DEC,DEC_ID,DEC_ROLE_ID,PERIOD_AT,REG_FROM');
-        $this->adminOperateLogger->afterInsert($user->ID, 'ID', ['select'=>$select]);
-        $userData = $this->adminOperateLogger->saveAfterContent;
-        $this->adminOperateLogger->fetchClass = UserInfo::class;
-        $this->adminOperateLogger->afterInsert($user->ID, 'USER_ID', ['select'=>'USER_ID,CON_UID,REC_UID']);
-        $infoData = $this->adminOperateLogger->saveAfterContent;
-        $this->adminOperateLogger->saveAfterContent=array_merge($userData,$infoData);
-
-        $this->adminOperateLogger->clean()->save([
-            'optType' => 'Blank document entry',//空单录入
-            'userId' => $user->ID,
-            'userName' => $user->USER_NAME,
-        ]);
-
-        return $user;
-    }
-
-    /**
-     * 删除会员
-     * @return null
-     * @throws Exception
-     * @throws \yii\db\Exception
-     */
-    public function userDel() {
-        if (!$this->validate()) {
-            return null;
-        }
-
-        $select = new \yii\db\Expression('ID,REAL_NAME,ID_CARD,MOBILE,ADDRESS,OPEN_BANK,BANK_ADDRESS,BANK_NO,BANK_PROVINCE,BANK_CITY,BANK_COUNTY,CREATED_AT,DEC_LV,EMP_LV,PROVINCE,CITY,COUNTY,TEL,SUB_COM_ID,IS_DEC,DEC_ID,DEC_ROLE_ID,PERIOD_AT,REG_FROM');
-        $this->adminOperateLogger->beforeDelete($this->_delUserId, 'ID', ['select'=>$select]);
-        $userData = $this->adminOperateLogger->saveBeforeContent;
-        $this->adminOperateLogger->fetchClass = UserInfo::class;
-        $this->adminOperateLogger->beforeDelete($this->_delUserId, 'USER_ID', ['select'=>'USER_ID,CON_UID,REC_UID']);
-        $infoData = $this->adminOperateLogger->saveBeforeContent;
-        $this->adminOperateLogger->saveBeforeContent=array_merge($userData,$infoData);
-
-        $transaction = \Yii::$app->db->beginTransaction();
-        try {
-            /*$user=User::findOne(['ID'=>$this->_delUserId]);
-            $user->DELETED=1;
-            $user->DELETED_AT=Date::nowTime();
-            if(!$user->save()){
-                throw new Exception(Form::formatErrorsForApi($user->getErrors()));
-            }
-            $userInfo=UserInfo::findOne(['USER_ID'=>$this->_delUserId]);
-            $userInfo->DELETED=1;
-            $userInfo->DELETED_AT=Date::nowTime();
-            if(!$userInfo->save()){
-                throw new Exception(Form::formatErrorsForApi($userInfo->getErrors()));
-            }*/
-            //为释放用户名资源,彻底删除@190606
-            User::deleteAll('ID=:USER_ID', [':USER_ID' => $this->_delUserId]);
-
-            // 获取会员信息
-            $userInfo = UserInfo::findOneAsArray('USER_ID=:USER_ID', [':USER_ID'=>$this->_delUserId]);
-            // 调整上级会员的CON_NUM和REC_NUM
-            if(!UserInfo::updateAllCounters(['CON_NUM'=> -1], "USER_ID=:USER_ID", [':USER_ID'=>$userInfo['CON_UID']])){
-                throw new Exception('Failed to reduce the number of superior member contacts');//减少上级会员接点数量失败
-            }
-            if(!UserInfo::updateAllCounters(['REC_NUM'=> -1], "USER_ID=:USER_ID", [':USER_ID'=>$userInfo['REC_UID']])){
-                throw new Exception('Failed to reduce the number of recommended Sponsor');//减少开拓人推荐数量失败
-            }
-            // 删除会员信息
-            if(!UserInfo::deleteAll('USER_ID=:USER_ID', [':USER_ID' => $this->_delUserId])){
-                throw new Exception('Failed to delete member information');//删除会员信息失败
-            }
-            //删除安置
-            if(!UserNetwork::deleteAll('USER_ID=:USER_ID', [':USER_ID' => $this->_delUserId])){
-                throw new Exception('Failed to delete member placement data');//删除会员安置数据失败
-            }
-            //删除开拓
-            if(!UserRelation::deleteAll('USER_ID=:USER_ID', [':USER_ID' => $this->_delUserId])){
-                throw new Exception('Failed to delete member development data');//删除会员开拓数据失败
-            }
-            //删除点位绑定
-            UserBind::deleteAll('USER_ID=:USER_ID', [':USER_ID' => $this->_delUserId]);
-            //删除合作
-            UserTeamwork::deleteAll('USER_ID=:USER_ID', [':USER_ID' => $this->_delUserId]);
-            //删除奖金
-            UserBonus::deleteAll('USER_ID=:USER_ID', [':USER_ID' => $this->_delUserId]);
-
-            $transaction->commit();
-        } catch (Exception $e) {
-            $transaction->rollBack();
-            throw new Exception($e->getMessage());
-        }
-
-        $this->adminOperateLogger->clean()->save([
-            'optType' => 'Delete empty member',//删除空单会员
-        ]);
-        return $this->_delUserId;
-    }
-}
+<?php
+
+namespace common\models\forms;
+
+use backendApi\modules\v1\models\Admin;
+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\libs\logging\operate\AdminOperate;
+use common\models\FlowBonus;
+use common\models\Period;
+use common\models\DeclarationLevel;
+use common\models\DecOrder;
+use common\models\EmployLevel;
+use common\models\User;
+use common\models\UserBind;
+use common\models\UserBonus;
+use common\models\UserInfo;
+use common\models\UserMove;
+use common\models\UserNetwork;
+use common\models\UserRelation;
+use common\models\UserSystem;
+use common\models\UserTeamwork;
+use yii\base\Exception;
+
+/**
+ * Login form
+ */
+class AdminAddUserForm extends Model {
+    public $userName;
+    public $nation;
+    public $realName;
+    public $idCard;
+    public $mobile;
+    public $address;
+    public $openBank;
+    public $bankAddress;
+    public $bankNo;
+    public $bankAreaSelected;
+    public $decLv;
+    public $areaSelected;
+    public $tel;
+    public $isDec;
+    public $decUserName;
+    public $birthday;
+    public $decRoleId;
+    public $conUserName;
+    public $recUserName;
+    public $location;
+    public $delUserName;
+
+    private $_decId;
+    private $_delUserId;
+
+    public function init() {
+        parent::init();
+        $this->adminOperateLogger = new AdminOperate([
+            'fetchClass' => User::class,
+        ]);
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules() {
+        return [
+            [['userName', 'nation', 'realName', /*'idCard',*/ 'mobile', 'address', 'openBank', 'bankAddress', 'bankNo', 'bankAreaSelected', 'decLv', 'areaSelected', 'tel', 'isDec', 'decUserName', 'birthday', 'decRoleId', 'conUserName', 'recUserName', 'location', 'delUserName'], 'trim'],
+            [['userName', 'realName', /*'idCard',*/ 'decLv', 'decUserName', 'conUserName', 'recUserName', 'location'], 'required'],
+            [['userName'], 'unique', 'targetClass' => UserInfo::class, 'targetAttribute' => 'USER_NAME'],
+            [['conUserName'], 'exist', 'targetClass' => UserInfo::class, 'targetAttribute' => 'USER_NAME'],
+            [['recUserName'], 'exist', 'targetClass' => UserInfo::class, 'targetAttribute' => 'USER_NAME'],
+            [['decLv'], 'exist', 'targetClass' => DeclarationLevel::class, 'targetAttribute' => 'ID'],
+            [['mobile'], 'mobile'],
+//            [['idCard'], 'simpleIdCard'],
+            [['bankNo'], 'string', 'max' => 19],
+            [['decUserName'], 'issetDec'],
+            [['isDec'], 'issetDecRoleId'],
+            [['location'], 'isLocation'],
+            [['delUserName'], 'isDelUserName'],
+            //[['userName'], 'userName'],
+            [['realName', 'address', 'bankAddress'], 'realName'],
+        ];
+    }
+
+    /**
+     * 指定校验场景
+     * @return array
+     */
+    public function scenarios() {
+        $parentScenarios = parent::scenarios();
+        $customScenarios = [
+            'add' => ['userName', 'nation', 'realName', /*'idCard',*/ 'mobile', 'address', 'openBank', 'bankAddress', 'bankNo', 'bankAreaSelected', 'decLv', 'areaSelected', 'tel', 'isDec', 'decUserName', 'birthday', 'decRoleId', 'conUserName', 'recUserName', 'location'],
+            'userDel' => ['delUserName'],
+        ];
+        return array_merge($parentScenarios, $customScenarios);
+    }
+
+    public function attributeLabels() {
+        return [
+            'userName' => 'Member Code',//会员编号
+            'nation' => 'Nation',//民族
+            'realName' => 'Member Name',//会员姓名
+//            'idCard' => 'ID',//身份证号
+            'mobile' => 'Phone Number',//手机号
+            'address' => 'Address',//地址
+            'openBank' => 'Bank Name',//开户行
+            'bankAddress' => 'Account opening sub branch',//开户支行
+            'bankNo' => 'bank account',//银行账号
+            'bankAreaSelected' => 'Banking region',//银行地区
+            'decLv' => 'Real time declaration level',//实时报单级别
+            'areaSelected' => 'Location',//所在地区
+            'tel' => 'Telephone',//电话
+            'isDec' => 'Stockist or not',//是否报单中心
+            'decUserName' => 'Stockist No', // 报单中心编号
+            'birthday' => 'birthday',//生日
+            'decRoleId' => 'Stockist Level',//报单中心级别
+            'conUserName' => 'Contact person Member No',//接点人会员编号
+            'recUserName' => 'Sponsor Member No',
+            'location' => 'Resettlement area',//安置区域
+        ];
+    }
+
+    /**
+     * 是否存在报单中心
+     * @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, 'Stockist does not exist');//报单中心不存在
+        } else {
+            $this->_decId = $decUser['ID'];
+        }
+    }
+
+    /**
+     * 校验是否填写报单中心级别
+     * @param $attribute
+     */
+    public function issetDecRoleId($attribute) {
+        if ($this->isDec && !$this->decRoleId) {
+            $this->addError($attribute, 'Stockist level cannot be empty');//报单中心级别不能为空
+        }
+    }
+
+    public function isLocation($attribute) {
+        if (!in_array($this->location, ['1', '2', '3'])) {
+            $this->addError($attribute, 'Location error');//区位错误
+        }
+    }
+
+    /**
+     * 校验删除的用户是否符合条件
+     * @param $attribute
+     */
+    public function isDelUserName($attribute) {
+        if (!$this->_delUserId = Info::getUserIdByUserName($this->delUserName)) {
+            $this->addError($attribute, 'user does not exist');//用户不存在
+        }
+        if (UserInfo::findOneAsArray('REC_UID=:REC_UID AND DELETED=0', [':REC_UID' => $this->_delUserId], 'USER_ID')) {
+            $this->addError($attribute, 'This member has developed other members and cannot be deleted');//此会员已开拓其它会员不可以删除
+        }
+        if (UserInfo::findOneAsArray('CON_UID=:CON_UID AND DELETED=0', [':CON_UID' => $this->_delUserId], 'USER_ID')) {
+            $this->addError($attribute, 'This member has been placed with other members and cannot be deleted');//此会员已安置其它会员不可以删除
+        }
+        if (User::findOneAsArray('DEC_ID=:DEC_ID AND DELETED=0', [':DEC_ID' => $this->_delUserId], 'ID')) {
+            $this->addError($attribute, 'This member has submitted a bill and other members cannot delete it');//此会员已报单其它会员不可以删除
+        }
+        if (DecOrder::findOneAsArray('USER_ID=:TO_USER_ID OR TO_USER_ID=:TO_USER_ID', [':TO_USER_ID' => $this->_delUserId], 'ID')) {
+            $this->addError($attribute, 'This member has submitted a bill and cannot be deleted');//此会员已报单不可以删除
+        }
+        $info = Info::baseInfoWithNet($this->_delUserId);
+        if ($info['REG_FROM'] == 1) {
+            $this->addError($attribute, 'This member is not empty and cannot be deleted');//此会员不是空单无法删除
+        }
+        $sentMaxPeriodNum = Period::sentMaxPeriodNum();
+        if ($info['PERIOD_AT'] <= $sentMaxPeriodNum) {
+            $this->addError($attribute, 'The number of enrollment periods of this member is less than or equal to the number of online periods');//此会员加入期数小于等于已挂网期数
+        }
+        if (User::find()->where('ID=:ID AND VERIFIED=1', [':ID' => $this->_delUserId])->exists()) {
+            $this->addError($attribute, 'This member has been authenticated by real name and cannot be deleted');//此会员已实名认证无法删除
+        }
+        if (User::find()->where('ID=:ID AND SUB_COM_LEADER=1', [':ID' => $this->_delUserId])->exists()) {
+            $this->addError($attribute, 'This member is a branch leader and cannot be deleted');//此会员是分公司领导人无法删除
+        }
+        if (UserInfo::find()->where('USER_ID=:USER_ID AND (IS_GROUP_LEADER=1 OR IS_SYSTEM_LEADER=1 OR IS_BIND=1 OR IS_TEAM=1)', [':USER_ID' => $this->_delUserId])->exists()) {
+            $this->addError($attribute, 'This member cannot be deleted due to the following conditions: Team Leader / system leader / point binding / point cooperation');//此会员存在以下情况无法删除,团队领导人/体系领导人/点位绑定/点位合作
+        }
+        if (Balance::hasBonus($this->_delUserId)) {
+            $this->addError($attribute, 'This member has balance and cannot be deleted');//此会员有余额无法删除
+        }
+        if (FlowBonus::findOneAsArray('USER_ID=:USER_ID', [':USER_ID' => $this->_delUserId], 'ID')) {
+            $this->addError($attribute, 'This member has generated a balance flow, which cannot be deleted');//该会员产生过余额流水无法删除
+        }
+        if (UserMove::findOneAsArray('USER_ID=:USER_ID', [':USER_ID' => $this->_delUserId], 'ID')) {
+            $this->addError($attribute, 'The member cannot be deleted due to network migration');//该会员发生过移网无法删除
+        }
+    }
+
+    /**
+     * 添加
+     * @return User|null
+     * @throws \yii\db\Exception
+     */
+    public function edit() {
+        $this->userName = strtoupper($this->userName);
+        if (!$this->validate()) {
+            return null;
+        }
+        $transactionShop = \Yii::$app->db->beginTransaction();
+        try {
+            $period = Period::instance();
+            // 商城表增加会员
+            $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 = 0;
+            $user->REAL_NAME = $this->realName;
+//            $user->ID_CARD = $this->idCard;
+            $user->MOBILE = $this->mobile;
+            $user->ADDRESS = $this->address ? $this->address : 'nothing';//无
+            $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 = $this->decLv;
+            $user->LAST_DEC_LV = $this->decLv;
+            $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->AVATAR = 'avatar/1.png';
+            $user->IS_DEC = $this->isDec ? $this->isDec : 0;
+            $user->DEC_ID = $this->_decId ?? null;
+            //$user->BIRTHDAY = Date::ociToDate($this->birthday, Date::OCI_TIME_FORMAT_DATE);
+            $user->DEC_ROLE_ID = $this->decRoleId ?? null;
+            $user->PERIOD_AT = $period->getNowPeriodNum();
+            $user->REG_FROM = 0;//空单标识
+            $user->IS_DIRECT_SELLER = 0;
+            $user->VERIFIED = 1;
+            $user->VERIFIED_AT = Date::nowTime();
+            $user->USER_CREATOR = Admin::getAdminNameById(\Yii::$app->user->id);
+            $user->IS_RECHARGE = 1;
+            if (!$user->save()) {
+                throw new Exception(Form::formatErrorsForApi($user->getErrors()));
+            }
+            // 获取报单级别的设置
+            $decLevelConfig = Cache::getDecLevelConfig();
+            $decLevelPv = $decLevelConfig[$this->decLv]['PERF'];
+            $userForm = new UserForm();
+            $userForm->scenario = 'addByAdmin';
+            $userForm->userId = $user->ID;
+            $userForm->userName = $this->userName;
+            $userForm->zcAmount = $decLevelPv;
+            $userForm->zcPv = $decLevelPv;
+            $userForm->conUserName = $this->conUserName;
+            $userForm->recUserName = $this->recUserName;
+            $userForm->location = $this->location;
+            if (!$userForm->add()) {
+                throw new Exception(Form::formatErrorsForApi($userForm->getErrors()));
+            }
+            $transactionShop->commit();
+        } catch (Exception $e) {
+            $transactionShop->rollBack();
+            $this->addError('add', $e->getMessage());
+            return null;
+        }
+
+        $select = new \yii\db\Expression('ID,REAL_NAME,ID_CARD,MOBILE,ADDRESS,OPEN_BANK,BANK_ADDRESS,BANK_NO,BANK_PROVINCE,BANK_CITY,BANK_COUNTY,CREATED_AT,DEC_LV,EMP_LV,PROVINCE,CITY,COUNTY,TEL,SUB_COM_ID,IS_DEC,DEC_ID,DEC_ROLE_ID,PERIOD_AT,REG_FROM');
+        $this->adminOperateLogger->afterInsert($user->ID, 'ID', ['select'=>$select]);
+        $userData = $this->adminOperateLogger->saveAfterContent;
+        $this->adminOperateLogger->fetchClass = UserInfo::class;
+        $this->adminOperateLogger->afterInsert($user->ID, 'USER_ID', ['select'=>'USER_ID,CON_UID,REC_UID']);
+        $infoData = $this->adminOperateLogger->saveAfterContent;
+        $this->adminOperateLogger->saveAfterContent=array_merge($userData,$infoData);
+
+        $this->adminOperateLogger->clean()->save([
+            'optType' => 'Blank document entry',//空单录入
+            'userId' => $user->ID,
+            'userName' => $user->USER_NAME,
+        ]);
+
+        return $user;
+    }
+
+    /**
+     * 删除会员
+     * @return null
+     * @throws Exception
+     * @throws \yii\db\Exception
+     */
+    public function userDel() {
+        if (!$this->validate()) {
+            return null;
+        }
+
+        $select = new \yii\db\Expression('ID,REAL_NAME,ID_CARD,MOBILE,ADDRESS,OPEN_BANK,BANK_ADDRESS,BANK_NO,BANK_PROVINCE,BANK_CITY,BANK_COUNTY,CREATED_AT,DEC_LV,EMP_LV,PROVINCE,CITY,COUNTY,TEL,SUB_COM_ID,IS_DEC,DEC_ID,DEC_ROLE_ID,PERIOD_AT,REG_FROM');
+        $this->adminOperateLogger->beforeDelete($this->_delUserId, 'ID', ['select'=>$select]);
+        $userData = $this->adminOperateLogger->saveBeforeContent;
+        $this->adminOperateLogger->fetchClass = UserInfo::class;
+        $this->adminOperateLogger->beforeDelete($this->_delUserId, 'USER_ID', ['select'=>'USER_ID,CON_UID,REC_UID']);
+        $infoData = $this->adminOperateLogger->saveBeforeContent;
+        $this->adminOperateLogger->saveBeforeContent=array_merge($userData,$infoData);
+
+        $transaction = \Yii::$app->db->beginTransaction();
+        try {
+            /*$user=User::findOne(['ID'=>$this->_delUserId]);
+            $user->DELETED=1;
+            $user->DELETED_AT=Date::nowTime();
+            if(!$user->save()){
+                throw new Exception(Form::formatErrorsForApi($user->getErrors()));
+            }
+            $userInfo=UserInfo::findOne(['USER_ID'=>$this->_delUserId]);
+            $userInfo->DELETED=1;
+            $userInfo->DELETED_AT=Date::nowTime();
+            if(!$userInfo->save()){
+                throw new Exception(Form::formatErrorsForApi($userInfo->getErrors()));
+            }*/
+            //为释放用户名资源,彻底删除@190606
+            User::deleteAll('ID=:USER_ID', [':USER_ID' => $this->_delUserId]);
+
+            // 获取会员信息
+            $userInfo = UserInfo::findOneAsArray('USER_ID=:USER_ID', [':USER_ID'=>$this->_delUserId]);
+            // 调整上级会员的CON_NUM和REC_NUM
+            if(!UserInfo::updateAllCounters(['CON_NUM'=> -1], "USER_ID=:USER_ID", [':USER_ID'=>$userInfo['CON_UID']])){
+                throw new Exception('Failed to reduce the number of superior member contacts');//减少上级会员接点数量失败
+            }
+            if(!UserInfo::updateAllCounters(['REC_NUM'=> -1], "USER_ID=:USER_ID", [':USER_ID'=>$userInfo['REC_UID']])){
+                throw new Exception('Failed to reduce the number of recommended Sponsor');//减少开拓人推荐数量失败
+            }
+            // 删除会员信息
+            if(!UserInfo::deleteAll('USER_ID=:USER_ID', [':USER_ID' => $this->_delUserId])){
+                throw new Exception('Failed to delete member information');//删除会员信息失败
+            }
+            //删除安置
+            if(!UserNetwork::deleteAll('USER_ID=:USER_ID', [':USER_ID' => $this->_delUserId])){
+                throw new Exception('Failed to delete member placement data');//删除会员安置数据失败
+            }
+            //删除开拓
+            if(!UserRelation::deleteAll('USER_ID=:USER_ID', [':USER_ID' => $this->_delUserId])){
+                throw new Exception('Failed to delete member development data');//删除会员开拓数据失败
+            }
+            //删除点位绑定
+            UserBind::deleteAll('USER_ID=:USER_ID', [':USER_ID' => $this->_delUserId]);
+            //删除合作
+            UserTeamwork::deleteAll('USER_ID=:USER_ID', [':USER_ID' => $this->_delUserId]);
+            //删除奖金
+            UserBonus::deleteAll('USER_ID=:USER_ID', [':USER_ID' => $this->_delUserId]);
+
+            $transaction->commit();
+        } catch (Exception $e) {
+            $transaction->rollBack();
+            throw new Exception($e->getMessage());
+        }
+
+        $this->adminOperateLogger->clean()->save([
+            'optType' => 'Delete empty member',//删除空单会员
+        ]);
+        return $this->_delUserId;
+    }
+}

+ 1 - 0
common/models/forms/ApproachDeclarationForm.php

@@ -769,6 +769,7 @@ class ApproachDeclarationForm extends Model
         $user->IS_DIRECT_SELLER = 0;
         $user->VERIFIED = 1;
         $user->VERIFIED_AT = Date::nowTime();
+        $user->IS_RECHARGE = 1;
 
         if (!$user->save()) {
             throw new Exception(Form::formatErrorsForApi($user->getErrors()));

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

@@ -0,0 +1,625 @@
+<?php
+namespace common\models\forms;
+
+use common\helpers\Cache;
+use common\helpers\Date;
+use common\components\Model;
+use common\helpers\Form;
+use common\helpers\LoggerTool;
+use common\helpers\PayStack;
+use common\helpers\user\Balance;
+use common\helpers\user\Cash;
+use common\helpers\user\Info;
+use common\libs\logging\operate\AdminOperate;
+use common\models\ApproachDecOrder;
+use common\models\ApproachOrder;
+use common\models\ApproachReconsumeOrder;
+use common\models\ApproachOrderGoods;
+use common\models\BaUser;
+use common\models\DealType;
+use common\models\DecLevelLog;
+use common\models\DecOrder;
+use common\models\Order;
+use common\models\OrderGoods;
+use common\models\Period;
+use common\models\ReceiveAddress;
+use common\models\Region;
+use common\models\ShopGoods;
+use common\models\User;
+use common\models\UserNetwork;
+use common\models\Instalment;
+use Yii;
+use yii\base\Exception;
+
+/**
+ * Login form
+ */
+class ApproachReconsumeOrderForm extends Model
+{
+    public $sn;
+    public $expressCompany;
+    public $orderTrackNo;
+    public $status;
+    public $remark;
+    public $note;
+
+    public $type;
+    public $addressId;
+    public $payType;
+    public $goodsId;
+    public $goodsNum;
+    public $payPassword;
+    public $email;
+
+    public $userName;
+    public $consignee;
+    public $acceptMobile;
+    public $province;
+    public $city;
+    public $county;
+    public $lgaName;
+    public $cityName;
+    public $detailaddress;
+
+    private $_address;
+    private $_decAmount;
+    private $_decPv;
+    private $_freight;
+    private $_payAmount;
+    private $_orderGoods;
+    private $_standardAmount;
+    private $_decAmountStandard;
+
+    /**
+     * @var ApproachOrder
+     */
+    private $_model;
+
+    public function init() {
+        parent::init();
+        $this->adminOperateLogger = new AdminOperate([
+            'fetchClass' => ApproachOrder::class,
+        ]);
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['sn', 'expressCompany', 'orderTrackNo', 'status', 'remark','type','addressId','payType','goodsId','goodsNum', 'payPassword','userName','consignee','acceptMobile','province',/*'city','county',*/'lgaName','cityName','detailaddress','email'], 'trim'],
+            [['sn', 'expressCompany', 'orderTrackNo', 'status', 'remark','type','addressId','payType','goodsId','goodsNum', 'payPassword','userName','consignee','acceptMobile','province',/*'city','county',*/'detailaddress'/*,'email'*/], 'required'],
+            [['status'], 'isStatus'],
+            [['addressId'], 'isAddress'],
+            [['payType'], 'isPayType'],
+            [['payPassword'], 'validatePassword'],
+        ];
+    }
+
+    public function attributeLabels()
+    {
+        return [
+            'sn' => Yii::t('app', 'orderSn'),
+            'expressCompany' => Yii::t('app', 'expressCompany'),
+            'orderTrackNo' => Yii::t('app', 'orderTrackNo'),
+            'status' => Yii::t('app', 'state'),
+            'remark' => Yii::t('app', 'remark'),
+            'type' => Yii::t('app', 'orderType'),
+            'addressId' => Yii::t('app', 'shippingAddress'),
+            'payType' => Yii::t('app', 'payType'),
+            'goodsId' => Yii::t('app', 'productID'),
+            'goodsNum' => Yii::t('app', 'quantity'),
+            'userName' => Yii::t('app', 'repeatSalesMemberNo'),
+            'consignee' => Yii::t('app', 'consignee'),
+            'acceptMobile' => Yii::t('app', 'acceptMobile'),
+            'province' => Yii::t('app', 'province'),
+            'city' => Yii::t('app', 'city'),
+            'county' => Yii::t('app', 'county'),
+            'lgaName' =>Yii::t('app', 'lgaName'),
+            'cityName' => Yii::t('app', 'cityName'),
+            'detailaddress' => Yii::t('app', 'detailAddress'),
+            'email' => Yii::t('app', 'email'),
+        ];
+    }
+
+    /**
+     * 指定校验场景
+     * @return array
+     */
+    public function scenarios()
+    {
+        $parentScenarios =  parent::scenarios();
+        $customScenarios = [
+            // 管理员修改订单状态
+            'adminStatus' => ['sn', 'status'],
+            // 校验订单支付
+            'verifyPayStack' => ['sn', 'note', 'status'],
+            // 会员下单
+            'userOrder' => ['type','addressId', 'payType','goodsId','goodsNum', 'note', 'payPassword'],
+            // 为会员复消
+            'reconsumeOrder' => ['type','userName', 'payType','goodsId','goodsNum', 'remark', 'payPassword','consignee','acceptMobile','province','cityName','lgaName','detailaddress'],
+        ];
+        return array_merge($parentScenarios, $customScenarios);
+    }
+
+    /**
+     * 校验之前
+     * @return bool
+     */
+    public function beforeValidate()
+    {
+        $parentValidate = parent::beforeValidate();
+        if ($this->sn) {
+            $this->_model = ApproachOrder::findOne(['SN' => $this->sn]);
+            if (!$this->_model){
+                $this->addError('sn', Yii::t('app', 'orderDoesNotExist'));
+                return false;
+            }
+        }
+
+        if ($this->scenario == 'verifyPayStack'){
+            if ($this->_model->STATUS != \Yii::$app->params['orderStatus']['notPaid']['value']) {
+                $this->addError('sn', Yii::t('app', 'payTypeError'));
+                return false;
+            }
+        }
+
+        return $parentValidate;
+    }
+
+    /**
+     * 判断收货地址是否存在
+     * @param $attribute
+     */
+    public function isAddress($attribute){
+        if (!$receiveAddress = ReceiveAddress::find()->where(' ID=:ID', [':ID' => $this->addressId])->asArray()->one()) {
+            $this->addError($attribute, Yii::t('app', 'shippingDoesNotExist'));
+        } else {
+            $this->_address = $receiveAddress;
+        }
+    }
+
+    /**
+     * 校验支付密码
+     * @param $attribute
+     * @param $params
+     */
+    public function validatePassword($attribute, $params) {
+        if (!User::validatePayPassword(\Yii::$app->user->id, $this->payPassword)) {
+            $this->addError($attribute, Yii::t('app', 'paymentPasswordError'));
+        }
+    }
+
+    /**
+     * 判断支付方式
+     * @param $attribute
+     */
+    public function isPayType($attribute)
+    {
+        if ($this->payType != 'pay_stack'){
+            $this->addError($attribute, Yii::t('app', 'payTypeError'));
+            return;
+        }
+
+        // 一个订单只能包含一类商品
+        $goods = ShopGoods::find()->select('ID,CATEGORY_TYPE')->where(['in', 'ID', $this->goodsId])->andWhere(['STATUS' => 1])->asArray()->all();
+        if (!$goods) {
+            throw new Exception(Yii::t('app', 'orderCanNotContainMultipleProductCategories'));
+            return;
+        }
+        $goodsCategoryType = array_unique(array_column($goods, 'CATEGORY_TYPE'));
+        if (count($goodsCategoryType) > 1) {
+            $this->addError($attribute, Yii::t('app', 'orderCanNotHasMoreClassification'));
+            return;
+        }
+
+        // 购买方式
+        $sellTypeLabelMap = array_column(ShopGoods::SALE_TYPE, NULL, 'label');
+        if (!array_key_exists($this->payType, $sellTypeLabelMap)) {
+            $this->addError($attribute, Yii::t('app', 'payTypeError'));
+            return;
+        }
+
+        // 所选支付方式必须是商品分类支持的类型
+        $categoryType = array_column(ShopGoods::CATEGORY_TYPE, NULL, 'id');
+        // 商品类型
+        $currCategoryType = $goodsCategoryType[0];
+        if (!array_key_exists($currCategoryType, $categoryType)) {
+            $this->addError($attribute, Yii::t('app', 'shopGoodClassificationError'));
+            return;
+        }
+
+        $sellType = $categoryType[$currCategoryType]['sell_type'] ?? [];
+        if (!$sellType || !in_array($this->payType, array_column($sellType, 'label'))) {
+            $this->addError($attribute, Yii::t('app', 'payTypeError'));
+        }
+    }
+
+    /**
+     * 校验类型
+     * @param $attribute
+     */
+    public function isStatus($attribute){
+        if($this->type && !in_array($this->type, \Yii::$app->params['orderStatus'])){
+            $this->addError($attribute, Yii::t('app', 'orderStatusTypeError'));
+            return ;
+        }
+        if ($this->scenario == 'adminStatus'){
+            if ($this->status == $this->_model['STATUS']) {
+                $this->addError($attribute, Yii::t('app', 'orderStatusDoesNotChange'));
+                return ;
+            }
+            if($this->status == \Yii::$app->params['orderStatus']['notPaid'] && $this->_model['STATUS'] >= \Yii::$app->params['orderStatus']['delivery']) {
+                $this->addError($attribute, Yii::t('app', 'orderHasBeenLogisticsStatusDoesNotChangedUnpaid'));
+                return ;
+            }
+            elseif($this->status == \Yii::$app->params['orderStatus']['paid'] && $this->_model['STATUS'] >= \Yii::$app->params['orderStatus']['cancel']) {
+                $this->addError($attribute, Yii::t('app', 'orderHasBeenInvalidCanNotProcess'));
+                return ;
+            }
+            elseif($this->status == \Yii::$app->params['orderStatus']['delivery']) {
+                $this->addError($attribute, Yii::t('app', 'orderCanNotBeenChangedLogistics'));
+                return ;
+            }
+            elseif($this->status == \Yii::$app->params['orderStatus']['complete'] && $this->_model['STATUS'] > \Yii::$app->params['orderStatus']['cancel']) {
+                $this->addError($attribute, Yii::t('app', 'orderHasBeenInvalidCanNotProcess'));
+                return ;
+            }
+            elseif($this->status == \Yii::$app->params['orderStatus']['cancel']) {
+                if($this->_model['STATUS'] == \Yii::$app->params['orderStatus']['complete']) {
+                    $this->addError($attribute, Yii::t('app', 'orderHasBeenFinishedCanNotCancel'));
+                    return ;
+                }
+                if($this->_model['STATUS'] == \Yii::$app->params['orderStatus']['del']) {
+                    $this->addError($attribute, Yii::t('app', 'orderHasBeenDeletedCanNotCancel'));
+                    return ;
+                }
+            }
+            elseif($this->status == \Yii::$app->params['orderStatus']['del']) {
+                if($this->_model['STATUS'] == \Yii::$app->params['orderStatus']['complete']) {
+                    $this->addError($attribute, Yii::t('app', 'orderHasBeenFinishedCanNotDelete'));
+                    return ;
+                }
+            }
+        }
+
+    }
+
+    /**
+     * 校验PayStack支付,更新订单状态.同步到正式订单.
+     * @throws Exception
+     */
+    public function verifyPayStack(): ?ApproachOrder
+    {
+        if (!$this->validate()) {
+            return null;
+        }
+
+        // 调用PayStack支付校验
+        LoggerTool::info([$this->note['reference'], $this->note]);
+        $payload = PayStack::transactionVerify($this->note['reference']);
+        LoggerTool::info($payload);
+        if ($payload['status'] !== true) {
+            throw new Exception(Form::formatErrorsForApi($payload['message']));
+        }
+        if ($payload['data']['amount'] != $this->_model->PAY_AMOUNT * 100) {
+            throw new Exception(Form::formatErrorsForApi(Yii::t('app', 'payAmountNotEqualOrderAmount')));
+        }
+
+        // 订单类型:userOrder(会员订单)、userUpgrade(会员升级)、userDec(会员报单)
+        $orderType = $this->note['metadata']['custom_fields'][1]['value'] ?? false;
+
+        $db = \Yii::$app->db;
+        $transaction = $db->beginTransaction();
+        try {
+            // 更新准订单状态为已支付
+            $this->_model->STATUS = $this->status;
+            $this->_model->NOTE = json_encode($this->note);
+            $this->_model->PAY_AT = Date::utcToTime($this->note['paid_at']);
+            $this->_model->EMAIL = $this->note['email'];
+            if (!$this->_model->save()) {
+                throw new Exception(Form::formatErrorsForApi($this->_model->getErrors()));
+            }
+            // 更新订单商品的支付Email
+            ApproachOrderGoods::updateAll(['EMAIL' => $this->note['email']], 'ORDER_SN = :ORDER_SN', [':ORDER_SN' => $this->sn]);
+
+            // 同步准订单到正式订单
+            Order::insertOne($this->_model->toArray());
+            // 同步准订单商品到正式订单商品
+            $approachOrderGoods = ApproachOrderGoods::findAllAsArray('ORDER_SN = :ORDER_SN', [':ORDER_SN' => $this->sn]);
+            foreach ($approachOrderGoods as &$approachOrderGood) {
+                $approachOrderGood['EMAIL'] = $this->email;
+            }
+            OrderGoods::batchInsert($approachOrderGoods);
+
+            // 会员报单、BA升级
+            if (in_array($orderType, ['userDec', 'baUpgrade', 'userUpgrade'])) {
+                // 同步报单
+                $approachDecOrder = ApproachDecOrder::findOneAsArray('ORDER_SN = :ORDER_SN', [':ORDER_SN' => $this->sn]);
+                if ($approachDecOrder) {
+                    unset($approachDecOrder['STATUS']);
+
+                    // 同步报单
+                    DecOrder::insertOne($approachDecOrder);
+
+                    // 修改会员锁定状态
+                    if (in_array($orderType, ['userDec', 'baUpgrade'])) {
+                        if (!User::updateAll(['STATUS' => 1], 'ID=:USER_ID', [':USER_ID' => $approachDecOrder['TO_USER_ID']])) {
+                            throw new Exception(Form::formatErrorsForApi(Yii::t('app', 'changeUserStatusError')));
+                        }
+                    }
+                    // 修改BA会员升级状态
+                    if ($orderType === 'baUpgrade') {
+                        // 查询BA会员名
+                        $userInfo = User::findOneAsArray('ID=:USER_ID', [':USER_ID' => $approachDecOrder['TO_USER_ID']]);
+                        if (!BaUser::updateAll(['WHETHER_UPGRADE' => 1, 'BA_UPGRADE_AT' => time()], 'USER_NAME=:USER_NAME', [':USER_NAME' => $userInfo['USER_NAME']])) {
+                            throw new Exception(Form::formatErrorsForApi(Yii::t('app', 'brandAmbassadorUpgradeError')));
+                        }
+                    }
+
+                    // 正式会员-升级单
+                    if ($orderType === 'userUpgrade') {
+                        // 会员升级 报单类型:2会员升级单
+                        if ($approachDecOrder['DETAIL_TYPE'] == 2) {
+                            // 为被升级人进行升级操作
+                            $decLevelLog = new DecLevelLog();
+                            $decLog = [
+                                'userId' => $approachDecOrder['TO_USER_ID'],//会员ID
+                                'fromId' => $approachDecOrder['ORI_LV'], // 变动前的级别
+                                'levelId' => $approachDecOrder['UPGRADE_LV'],// 变动后的级别
+                                'actionId' => $approachDecOrder['USER_ID'],
+                                'remark' => $approachDecOrder['REMARK'],
+                                'lvPv' => $this->_model->PV,
+                            ];
+                            $modifyDecLv = $decLevelLog->frontendChange($decLog);
+                            if (empty($modifyDecLv)) {
+                                $transaction->rollBack();
+                                throw new Exception(Yii::t('app', 'failedToUpgrade'));
+                            }
+                        }
+                    }
+
+                    // 删除中间表
+                    ApproachDecOrder::deleteAll('ORDER_SN = :ORDER_SN', [':ORDER_SN' => $this->sn]);
+                }
+            }
+
+            // 删除中间表
+            ApproachOrder::deleteAll('SN = :SN', [':SN' => $this->sn]);
+            ApproachOrderGoods::deleteAll('ORDER_SN = :ORDER_SN', [':ORDER_SN' => $this->sn]);
+
+            $transaction->commit();
+        } catch (Exception $e) {
+            $transaction->rollBack();
+            $this->addError('edit', $e->getFile() . '  ' . $e->getMessage());
+            return null;
+        }
+
+        return $this->_model;
+    }
+
+    /**
+     * 复销
+     * @throws Exception
+     * @throws \yii\db\Exception
+     */
+    public function add(){
+        if(!$this->validate()){
+            return null;
+        }
+
+        $ids = $this->goodsId;
+        $totalAmount = 0;
+        $totalPv = 0;
+        $totalAmountStandard = 0;
+        $goodsType = ShopGoods::GOODS_TYPE;
+        $hasInstalment = 0;
+        $exchangeRate = floatval(Cache::getSystemConfig()['exchangeRate']['VALUE'] ?? 0); // 汇率
+        foreach ($this->goodsNum as $k => $v) {
+            if ($v) {
+                $goods = ShopGoods::findOneAsArray('ID=:ID AND STATUS=1',[':ID'=> $ids[$k]]);
+                if (!$goods) {
+                    throw new Exception(Yii::t('app', 'productsDoesSoldOut'));
+                }
+                if($goods['STORE_NUMS']>0){
+                    if ($goods['TYPE'] == 1 || $goods['TYPE'] == 2) {
+                        $discount = $goodsType[$goods['TYPE']]['discount'];
+                        $realPrice = $goods['SELL_PRICE'] * $discount/100;
+                        $realPv = $goods['PRICE_PV'] * $discount/100;
+                        $realPriceStandard = $goods['SELL_PRICE_STANDARD'] * $discount/100;
+                    } else {
+                        $discount = $goods['SELL_DISCOUNT'];
+                        $realPrice = $goods['SELL_PRICE'] * $discount;
+                        $realPv = $goods['PRICE_PV'] * $discount;
+                        $realPriceStandard = $goods['SELL_PRICE_STANDARD'] * $discount;
+                    }
+                    $totalAmount += $realPrice * intval($v);
+                    $totalPv += $realPv * intval($v);
+                    $totalAmountStandard += $realPriceStandard * intval($v);
+
+                    $this->_orderGoods[] = [
+                        'GOODS_ID' => $goods['ID'],
+                        'PRICE' => $goods['SELL_PRICE'],
+                        'PV' => $goods['PRICE_PV'],
+                        'REAL_PRICE' => $realPrice,
+                        'REAL_PV' => $realPv,
+                        'POINT' => $goods['POINT'],
+                        'BUY_NUMS' => intval($v),
+                        'TAX_RATE' => $goods['TAX_RATE'],
+                        'SKU_CODE' => $goods['GOODS_NO'],
+                        'GOODS_TITLE' => $goods['GOODS_NAME'],
+                        'CATEGORY_TYPE' => $goods['CATEGORY_TYPE'],
+                        'PAY_TYPE' => $this->payType,
+                        'EMAIL' => $this->email,
+                        'STANDARD_PRICE' => $goods['SELL_PRICE_STANDARD'],
+                        'REAL_STANDARD_PRICE' => $realPriceStandard,
+                        'EXCHANGE_RATE' => $exchangeRate,
+                    ];
+                }
+                if($goods['INSTALMENT']>0){ // 如果有分期付款商品,检查用户的分期付款状态
+                    if($v>1){ // 不可以购买多个
+                        throw new Exception(Yii::t('app', 'allowOnlyOne'));
+                    }
+                    $loginUserId = \Yii::$app->user->id;
+                    $userStage = Instalment::getStage($loginUserId);
+                    if ($userStage==0 || $userStage == 3){
+
+                    }else{
+                        if($userStage + 1 != $goods['INSTALMENT']){ // 若用户分期阶段+1不等于商品的分期阶段,则报异常
+                            throw new Exception(Yii::t('app', 'canNotBuy'));
+                        }
+                    }
+                    $hasInstalment = $goods['INSTALMENT'];
+                }
+            }
+        }
+
+        // 汇率
+        $exchangeRate = floatval(Cache::getSystemConfig()['exchangeRate']['VALUE'] ?? 0);
+        // 运费.奈拉
+        $freight = floatval(Cache::getSystemConfig()['freight']['VALUE'] ?? 0);
+        // 普通商品免运费阈值.奈拉
+        $freeShipping = floatval(Cache::getSystemConfig()['freeShipping']['VALUE'] ?? 0);
+
+        $this->_decAmount = $totalAmount;
+        $this->_decPv = $totalPv;
+        $this->_freight = ($totalAmount >= $freeShipping) ? 0 : $freight;
+
+        $this->_payAmount = $this->_decAmount + $this->_freight;
+        $this->_decAmountStandard = $totalAmountStandard;
+        $this->_standardAmount = $this->_decAmountStandard + $this->_freight;
+
+        $db = \Yii::$app->db;
+        $transaction = $db->beginTransaction();
+
+        try {
+            //写入订单
+            if (!$orderResult = $this->addOrder()) {
+                throw new Exception(Form::formatErrorsForApi($orderResult->getErrors()));
+            }
+            if ($hasInstalment){ // 如果有分期付款的商品,写入信息至分期付款表
+                $instalmentModel = Instalment::findOne(['USER_ID'=>$loginUserId]);
+                if(!$instalmentModel) {
+                    $instalmentModel = new Instalment();
+                }
+                $instalmentModel->USER_ID = $loginUserId;
+                $instalmentModel->STAGE = $hasInstalment;
+                $instalmentModel->UPDATE_TIME = time();
+                $instalmentModel->save();
+            }
+
+            $transaction->commit();
+
+            return $orderResult;
+        }catch (\Exception $e){
+            $transaction->rollBack();
+            $this->addError('add', $e->getMessage());
+            return null;
+        }
+    }
+
+    /**
+     * 复销订单
+     * @throws Exception
+     */
+    public function addOrder()
+    {
+        $periodObj = Period::instance();
+        $nowPeriodNum = $periodObj->getNowPeriodNum();
+        $nowCalcMonth = $periodObj->getYearMonth($nowPeriodNum);
+
+        $userId = \Yii::$app->user->id;
+
+        $userName = Info::getUserNameByUserId($userId);
+        $userRealName = Info::getUserRealNameByUserId($userId);
+        $userMobile = Info::getUserMobileByUserId($userId);
+        $userEmail = Info::getUserEmailByUserId($userId);
+        $exchangeRate = floatval(Cache::getSystemConfig()['exchangeRate']['VALUE'] ?? 0);
+        // 加入订单信息
+        $warehouse = '01';
+        $_hasPV = $this->_decPv;
+
+        $ordNo = $this->_generateSn();
+        $orderModel = new ApproachReconsumeOrder();
+        $orderModel->SN = 'OS' . $ordNo;
+        $orderModel->DEC_SN = 'DS' . $ordNo;
+        $orderModel->ORDER_TYPE = $this->type;
+        $orderModel->USER_ID = $userId;
+        $orderModel->USER_NAME = $userName;
+        $orderModel->ORDER_AMOUNT = $this->_decAmount;
+        $orderModel->PV = $_hasPV;
+        $orderModel->PAY_AMOUNT = $this->_payAmount;
+        $orderModel->PAY_PV = $_hasPV; // 兑换积分不能算业绩
+        $orderModel->PAY_AT = 0;
+        $orderModel->PAY_TYPE = $this->payType;
+        $orderModel->PERIOD_NUM = $nowPeriodNum;
+        $orderModel->P_CALC_MONTH = Date::ociToDate($nowCalcMonth, Date::OCI_TIME_FORMAT_SHORT_MONTH);
+        $orderModel->FREIGHT = $this->_freight;
+        $orderModel->PAY_FREIGHT = $this->_freight;
+        $orderModel->CONSIGNEE = $this->consignee;
+        $orderModel->MOBILE = $this->acceptMobile;
+        $orderModel->PROVINCE = $this->province[0];
+        $orderModel->LGA_NAME = $this->lgaName;
+        $orderModel->CITY_NAME = $this->cityName;
+        $orderModel->ADDRESS = $this->detailaddress;
+
+        $orderModel->FRONT_REMARK = $this->remark;
+        $orderModel->WAREHOUSE = $warehouse;
+        $orderModel->STATUS = \Yii::$app->params['orderStatus']['notPaid']['value'];
+        $orderModel->CREATED_AT = Date::nowTime();
+        $orderModel->CREATE_USER = $userName;
+        $orderModel->EMAIL = $userEmail?$userEmail:$userName.'@elken.net';
+        $orderModel->ORDER_AMOUNT_STANDARD = $this->_decAmountStandard;
+        $orderModel->PAY_AMOUNT_STANDARD = $this->_standardAmount;
+        $orderModel->EXCHANGE_RATE = $exchangeRate;
+//        if($this->_address['PROVINCE']==1){
+//            $orderModel->EXPRESS_TYPE = 1;
+//            $orderModel->CONSIGNEE = $userRealName;
+//            $orderModel->MOBILE = $userMobile;
+//            $orderModel->PROVINCE = 1;
+//            $orderModel->CITY = 1;
+//            $orderModel->COUNTY = 1;
+//            $orderModel->ADDRESS = '';
+//        }
+
+        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);
+        }
+        ApproachOrderGoods::batchInsert($this->_orderGoods);
+
+        // TODO: 记录流水
+
+        return $orderModel;
+    }
+
+    /**
+     * 生成流水号
+     * @return string
+     */
+    private function _generateSn() {
+        return 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;
+    }
+}

+ 1 - 0
common/models/forms/DeclarationForm.php

@@ -799,6 +799,7 @@ class DeclarationForm extends Model
         $user->IS_DIRECT_SELLER = 0;
         $user->VERIFIED = 1;
         $user->VERIFIED_AT = Date::nowTime();
+        $user->IS_RECHARGE = 1;
 
         if (!$user->save()) {
             throw new Exception(Form::formatErrorsForApi($user->getErrors()));

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

@@ -49,6 +49,8 @@ class OrderForm extends Model
     public $acceptMobile;
     public $province;
     public $city;
+    public $lgaName;
+    public $cityName;
     public $county;
     public $detailaddress;
 
@@ -137,7 +139,7 @@ class OrderForm extends Model
             // 会员下单
             'userOrder' => ['type','addressId', 'payType','goodsId','goodsNum', 'remark', 'payPassword'],
             // 帮会员复消下单
-            'reconsumeOrder' => ['type','userName', 'payType','goodsId','goodsNum', 'remark', 'payPassword','consignee','acceptMobile','province',/*'city','county',*/'detailaddress'],
+            'reconsumeOrder' => ['type','userName', 'payType','goodsId','goodsNum', 'remark', 'payPassword','consignee','acceptMobile','province','cityName','lgaName','detailaddress'],
             // 管理员退款
             'adminRefund' => ['sn'],
         ];
@@ -865,14 +867,33 @@ class OrderForm extends Model
                         'GOODS_TITLE' => $goods['GOODS_NAME']
                     ];
                 }
+                if($goods['INSTALMENT']>0){ // 如果有分期付款商品,检查用户的分期付款状态
+                    if($v>1){ // 不可以购买多个
+                        throw new Exception(Yii::t('app', 'allowOnlyOne'));
+                    }
+                    $userId = Info::getUserIdByUserName($this->userName);
+                    $userStage = Instalment::getStage($userId);
+                    $userInstalmentInfo = Instalment::getInfo($userId);
+                    if ($userStage == 3){
+
+                    }else{
+                        if($userInstalmentInfo){
+                            if($userInstalmentInfo['STAGE']>0 && $userInstalmentInfo['ORDER_TYPE']!='FX'){
+                                throw new Exception(Yii::t('app', 'canNotBuy'));
+                            }
+                        }
+                        if($userStage + 1 != $goods['INSTALMENT']){ // 若用户分期阶段+1不等于商品的分期阶段,则报异常
+                            throw new Exception(Yii::t('app', 'canNotBuy'));
+                        }
+                    }
+                    $hasInstalment = $goods['INSTALMENT'];
+                }
             }
         }
         $this->_decAmount = $totalAmount;
         $this->_decPv = $totalPv;
         $this->_freight = ($totalAmount>=300) ? 0 : 15;
-        if($this->_address['PROVINCE']==1){
-            $this->_freight = 0;
-        }
+
         $this->_payAmount = $this->_decAmount + $this->_freight;
 
         $db = \Yii::$app->db;
@@ -934,6 +955,18 @@ class OrderForm extends Model
             if (!$orderResult = $this->addUserOrder()) {
                 throw new Exception(Form::formatErrorsForApi($orderResult->getErrors()));
             }
+            if ($hasInstalment){ // 如果有分期付款的商品,写入信息至分期付款表
+                $instalmentModel = Instalment::findOne(['USER_ID'=>$userId]);
+                if(!$instalmentModel) {
+                    $instalmentModel = new Instalment();
+                }
+                $instalmentModel->USER_ID = $userId;
+                $instalmentModel->STAGE = $hasInstalment;
+                $instalmentModel->ORDER_TYPE = 'FX';
+                $instalmentModel->UPDATE_TIME = time();
+                $instalmentModel->save();
+            }
+
             $transaction->commit();
         }catch (\Exception $e){
             $transaction->rollBack();
@@ -958,14 +991,14 @@ class OrderForm extends Model
         $email = Info::getEmailByUserId($this->userName);
 
         // 加入订单信息
-        if($this->province!=1){
-            $warehouse = Region::getWarehouseByCode($this->province);//仓库
-            if(!$warehouse){
-                throw new Exception(Yii::t('app', 'deliveryTemporarilyNotSupported'));
-            }
-        }else{
+//        if($this->province!=1){
+//            $warehouse = Region::getWarehouseByCode($this->province);//仓库
+//            if(!$warehouse){
+//                throw new Exception(Yii::t('app', 'deliveryTemporarilyNotSupported'));
+//            }
+//        }else{
             $warehouse = '01';
-        }
+//        }
         $ordNo = $this->_generateSn();
         $orderModel = new Order();
         $orderModel->SN = 'OS'.$ordNo;
@@ -985,9 +1018,9 @@ class OrderForm extends Model
         $orderModel->PAY_FREIGHT = $this->_freight;
         $orderModel->CONSIGNEE = $this->consignee;
         $orderModel->MOBILE = $this->acceptMobile;
-        $orderModel->PROVINCE = $this->province;
-//        $orderModel->CITY = $this->city;
-//        $orderModel->COUNTY = $this->county;
+        $orderModel->PROVINCE = $this->province[0];
+        $orderModel->LGA_NAME = $this->lgaName;
+        $orderModel->CITY_NAME = $this->cityName;
         $orderModel->ADDRESS = $this->detailaddress;
         $orderModel->FRONT_REMARK = $this->remark;
         $orderModel->WAREHOUSE = $warehouse;
@@ -996,8 +1029,7 @@ class OrderForm extends Model
         $orderModel->CREATE_USER = $loginUserName;
         $orderModel->EMAIL = $email;
         if(!$orderModel->save()){
-            $this->addErrors($orderModel->getErrors());
-            return false;
+            throw new Exception(Form::formatErrorsForApi($orderModel->getErrors()));
         }
         // 加入商品到订单商品表
         foreach($this->_orderGoods as $key=>$value){

+ 151 - 151
frontendApi/config/menu.php

@@ -1,151 +1,151 @@
-<?php
-/**
- * Created by PhpStorm.
- * User: Leo
- * Date: 2017/9/3
- * Time: 下午3:23
- */
-return [
-    'dashboard'=>[
-        'name'=>'Dashboard',//控制台
-        'class' => '',
-        'icon'=>'el-icon-guide',
-        'controller'=>'dashboard',
-        'action'=>'index',
-        'routePath'=>'dashboard/index',
-        'show'=>1,
-        'child'=>[
-            ['name'=>'月奖金量', 'class'=>'', 'icon'=>'', 'controller'=>'dashboard', 'action'=>'bonus-num', 'routePath'=>'dashboard/bonus-num', 'show'=>0,],
-        ]
-    ],
-    'shop'=>[
-        'name'=>'Shopping Mall',//商城管理
-        'class' => '',
-        'icon'=>'el-icon-goods',
-        'controller'=>'shop',
-        'action'=>'',
-        'routePath'=>'shop',
-        'show'=>1,
-        'child'=>[
-            ['name'=>'Products list', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'index', 'routePath'=>'shop/index', 'show'=>1],//商品列表
-            ['name'=>'Welcome Pack management', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'dec', 'routePath'=>'user/dec', 'show'=>1,'allow'=>'declarer',],
-            ['name'=>'Welcome Pack Listing', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'dec-order-list', 'routePath'=>'shop/dec-order-list', 'show'=>1,],//报单列表
-            ['name'=>'Upgrade management', 'class'=>'', 'icon'=>'', 'controller'=>'upgrade', 'action'=>'dec', 'routePath'=>'user/upgrade', 'show'=>1,'allow'=>'declarer',],//升级管理
-//            ['name'=>'Repeat sales products', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'reconsume', 'routePath'=>'shop/reconsume', 'show'=>1,'allow'=>'studio'],//复消商品
-//            ['name'=>'申请退货', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'order-backing-out', 'routePath'=>'shop/order-backing-out', 'show'=>1,],//申请退货
-            ['name'=>'Order List', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'order-list', 'routePath'=>'shop/order-list', 'show'=>1,],//订单列表
-//            ['name'=>'Brand Ambassador', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'ba-dec', 'routePath'=>'user/ba-dec', 'show'=>1,'allow'=>'declarer',],
-//            ['name'=>'BA Order List', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'ba-dec-order-list', 'routePath'=>'shop/ba-dec-order-list', 'show'=>1,'allow'=>'declarer',],
-        ]
-    ],
-    'user'=>[
-        'name'=>'Member Management',//会员管理
-        'class' => '',
-        'icon'=>'el-icon-user',
-        'controller'=>'user',
-        'action'=>'',
-        'routePath'=>'user',
-        'show'=>1,
-        'child'=>[
-            ['name'=>'Personal info', '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'=>'Reset Password', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'password', 'routePath'=>'user/password', 'show'=>1],
-        ]
-    ],
-    'atlas'=>[
-        'name'=>'Network Chart',
-        'class' => '',
-        'icon'=>'el-icon-data-line',
-        'controller'=>'atlas',
-        'action'=>'',
-        'routePath'=>'atlas',
-        'show'=>1,
-        'child'=>[
-            ['name'=>'Placement network', 'class'=>'', 'icon'=>'', 'controller'=>'atlas', 'action'=>'network', 'routePath'=>'atlas/network', 'show'=>1,],
-            ['name'=>'Sponsor network', 'class'=>'', 'icon'=>'', 'controller'=>'atlas', 'action'=>'relation', 'routePath'=>'atlas/relation', 'show'=>1,],
-//            ['name'=>'Brand Ambassador List', 'class'=>'', 'icon'=>'', 'controller'=>'atlas', 'action'=>'brand-ambassador-list', 'routePath'=>'atlas/brand-ambassador-list', 'show'=>1,],
-        ]
-    ],
-    'bonus'=>[
-        'name'=>'Bonus management',//奖金管理
-        'class' => '',
-        'icon'=>'el-icon-coin',
-        'controller'=>'bonus',
-        'action'=>'',
-        'routePath'=>'bonus',
-        'show'=>1,
-        'child'=>[
-            ['name'=>'My account', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'index', 'routePath'=>'bonus/index', 'show'=>1,],//我的账户
-//            ['name'=>'最新奖金', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'new', 'routePath'=>'bonus/new', 'show'=>1,'allow'=>'newBonusSwitch'],
-            ['name'=>'My bonus', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'other', 'routePath'=>'bonus/other', 'show'=>1,'allow'=>'pastBonusSwitch'],//往期奖金
-            ['name'=>'Team inquiry', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'teams', 'routePath'=>'bonus/teams', 'show'=>1,], // 团队查询
-            ['name'=>'Historical cumulative bonus', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'other', 'routePath'=>'bonus/historical-cumulative-bonus', 'show'=>1,'allow'=>'pastBonusSwitch'],//历史累积奖金
-            //['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,],
-            ['name'=>'Withdrawal details', 'class'=>'', 'icon'=>'', 'controller'=>'finance', 'action'=>'withdraw', 'routePath'=>'finance/withdraw', 'show'=>0,],//提现明细
-            ['name'=>'申请提现', 'class'=>'', 'icon'=>'', 'controller'=>'finance', 'action'=>'withdraw-add', 'routePath'=>'finance/withdraw-add', 'show'=>0,],
-            ['name'=>'Recharge details', 'class'=>'', 'icon'=>'', 'controller'=>'finance', 'action'=>'recharge', 'routePath'=>'finance/recharge', 'show'=>1,],//充值明细
-            ['name'=>'Apply for recharge', 'class'=>'', 'icon'=>'', 'controller'=>'finance', 'action'=>'recharge-add', 'routePath'=>'finance/recharge-add', 'show'=>0,], // 申请充值
-            ['name'=>'Transfer details', 'class'=>'', 'icon'=>'', 'controller'=>'finance', 'action'=>'transfer-list', 'routePath'=>'finance/transfer-list', 'show'=>1,'allow'=>'transferRecordSwitch'],
-            ['name'=>'Apply for Transfer', 'class'=>'', 'icon'=>'', 'controller'=>'finance', 'action'=>'transfer-add', 'routePath'=>'finance/transfer-add', 'show'=>0,'allow'=>'transferSwitch'], // 我要转账
-        ]
-    ],
-//    'finance'=>[
-//        'name'=>'Financial Management',//财务管理
-//        '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,'allow'=>'transferRecordSwitch'],
-////            ['name'=>'我要转账', 'class'=>'', 'icon'=>'', 'controller'=>'finance', 'action'=>'transfer-add', 'routePath'=>'finance/transfer-add', 'show'=>1,'allow'=>'transferSwitch'],
-////
-//        ]
-//    ],
-    'article'=>[
-        'name'=>'Article Management',//文章管理
-        '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'=>'Setting',//设置
-        'class' => '',
-        'icon'=>'el-icon-setting',
-        'controller'=>'config',
-        'action'=>'',
-        'routePath'=>'config',
-        'show'=>1,
-        'child'=>[
-//            ['name'=>'个人设置', 'class'=>'', 'icon'=>'', 'controller'=>'config', 'action'=>'base', 'routePath'=>'config/base', 'show'=>1,],
-            ['name'=>'Shipping Address', 'class'=>'', 'icon'=>'', 'controller'=>'config', 'action'=>'receive-address-list', 'routePath'=>'config/receive-address-list', 'show'=>1,],//收货地址管理
-        ]
-    ],
-];
+<?php
+/**
+ * Created by PhpStorm.
+ * User: Leo
+ * Date: 2017/9/3
+ * Time: 下午3:23
+ */
+return [
+    'dashboard'=>[
+        'name'=>'Dashboard',//控制台
+        'class' => '',
+        'icon'=>'el-icon-guide',
+        'controller'=>'dashboard',
+        'action'=>'index',
+        'routePath'=>'dashboard/index',
+        'show'=>1,
+        'child'=>[
+            ['name'=>'月奖金量', 'class'=>'', 'icon'=>'', 'controller'=>'dashboard', 'action'=>'bonus-num', 'routePath'=>'dashboard/bonus-num', 'show'=>0,],
+        ]
+    ],
+    'shop'=>[
+        'name'=>'Shopping Mall',//商城管理
+        'class' => '',
+        'icon'=>'el-icon-goods',
+        'controller'=>'shop',
+        'action'=>'',
+        'routePath'=>'shop',
+        'show'=>1,
+        'child'=>[
+            ['name'=>'Products list', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'index', 'routePath'=>'shop/index', 'show'=>1],//商品列表
+            ['name'=>'Welcome Pack management', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'dec', 'routePath'=>'user/dec', 'show'=>1,'allow'=>'declarer',],
+            ['name'=>'Welcome Pack Listing', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'dec-order-list', 'routePath'=>'shop/dec-order-list', 'show'=>1,],//报单列表
+            ['name'=>'Upgrade management', 'class'=>'', 'icon'=>'', 'controller'=>'upgrade', 'action'=>'dec', 'routePath'=>'user/upgrade', 'show'=>1,'allow'=>'declarer',],//升级管理
+            ['name'=>'Reconsume', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'reconsume', 'routePath'=>'shop/reconsume', 'show'=>1,'allow'=>'studio'],//复消商品
+//            ['name'=>'申请退货', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'order-backing-out', 'routePath'=>'shop/order-backing-out', 'show'=>1,],//申请退货
+            ['name'=>'Order List', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'order-list', 'routePath'=>'shop/order-list', 'show'=>1,],//订单列表
+//            ['name'=>'Brand Ambassador', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'ba-dec', 'routePath'=>'user/ba-dec', 'show'=>1,'allow'=>'declarer',],
+//            ['name'=>'BA Order List', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'ba-dec-order-list', 'routePath'=>'shop/ba-dec-order-list', 'show'=>1,'allow'=>'declarer',],
+        ]
+    ],
+    'user'=>[
+        'name'=>'Member Management',//会员管理
+        'class' => '',
+        'icon'=>'el-icon-user',
+        'controller'=>'user',
+        'action'=>'',
+        'routePath'=>'user',
+        'show'=>1,
+        'child'=>[
+            ['name'=>'Personal info', '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'=>'Reset Password', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'password', 'routePath'=>'user/password', 'show'=>1],
+        ]
+    ],
+    'atlas'=>[
+        'name'=>'Network Chart',
+        'class' => '',
+        'icon'=>'el-icon-data-line',
+        'controller'=>'atlas',
+        'action'=>'',
+        'routePath'=>'atlas',
+        'show'=>1,
+        'child'=>[
+            ['name'=>'Placement network', 'class'=>'', 'icon'=>'', 'controller'=>'atlas', 'action'=>'network', 'routePath'=>'atlas/network', 'show'=>1,],
+            ['name'=>'Sponsor network', 'class'=>'', 'icon'=>'', 'controller'=>'atlas', 'action'=>'relation', 'routePath'=>'atlas/relation', 'show'=>1,],
+//            ['name'=>'Brand Ambassador List', 'class'=>'', 'icon'=>'', 'controller'=>'atlas', 'action'=>'brand-ambassador-list', 'routePath'=>'atlas/brand-ambassador-list', 'show'=>1,],
+        ]
+    ],
+    'bonus'=>[
+        'name'=>'Bonus management',//奖金管理
+        'class' => '',
+        'icon'=>'el-icon-coin',
+        'controller'=>'bonus',
+        'action'=>'',
+        'routePath'=>'bonus',
+        'show'=>1,
+        'child'=>[
+            ['name'=>'My account', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'index', 'routePath'=>'bonus/index', 'show'=>1,],//我的账户
+//            ['name'=>'最新奖金', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'new', 'routePath'=>'bonus/new', 'show'=>1,'allow'=>'newBonusSwitch'],
+            ['name'=>'My bonus', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'other', 'routePath'=>'bonus/other', 'show'=>1,'allow'=>'pastBonusSwitch'],//往期奖金
+            ['name'=>'Team inquiry', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'teams', 'routePath'=>'bonus/teams', 'show'=>1,], // 团队查询
+            ['name'=>'Historical cumulative bonus', 'class'=>'', 'icon'=>'', 'controller'=>'bonus', 'action'=>'other', 'routePath'=>'bonus/historical-cumulative-bonus', 'show'=>1,'allow'=>'pastBonusSwitch'],//历史累积奖金
+            //['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,],
+            ['name'=>'Withdrawal details', 'class'=>'', 'icon'=>'', 'controller'=>'finance', 'action'=>'withdraw', 'routePath'=>'finance/withdraw', 'show'=>0,],//提现明细
+            ['name'=>'申请提现', 'class'=>'', 'icon'=>'', 'controller'=>'finance', 'action'=>'withdraw-add', 'routePath'=>'finance/withdraw-add', 'show'=>0,],
+            ['name'=>'Recharge details', 'class'=>'', 'icon'=>'', 'controller'=>'finance', 'action'=>'recharge', 'routePath'=>'finance/recharge', 'show'=>1,],//充值明细
+            ['name'=>'Apply for recharge', 'class'=>'', 'icon'=>'', 'controller'=>'finance', 'action'=>'recharge-add', 'routePath'=>'finance/recharge-add', 'show'=>0,], // 申请充值
+            ['name'=>'Transfer details', 'class'=>'', 'icon'=>'', 'controller'=>'finance', 'action'=>'transfer-list', 'routePath'=>'finance/transfer-list', 'show'=>1,'allow'=>'transferRecordSwitch'],
+            ['name'=>'Apply for Transfer', 'class'=>'', 'icon'=>'', 'controller'=>'finance', 'action'=>'transfer-add', 'routePath'=>'finance/transfer-add', 'show'=>0,'allow'=>'transferSwitch'], // 我要转账
+        ]
+    ],
+//    'finance'=>[
+//        'name'=>'Financial Management',//财务管理
+//        '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,'allow'=>'transferRecordSwitch'],
+////            ['name'=>'我要转账', 'class'=>'', 'icon'=>'', 'controller'=>'finance', 'action'=>'transfer-add', 'routePath'=>'finance/transfer-add', 'show'=>1,'allow'=>'transferSwitch'],
+////
+//        ]
+//    ],
+    'article'=>[
+        'name'=>'Article Management',//文章管理
+        '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'=>'Setting',//设置
+        'class' => '',
+        'icon'=>'el-icon-setting',
+        'controller'=>'config',
+        'action'=>'',
+        'routePath'=>'config',
+        'show'=>1,
+        'child'=>[
+//            ['name'=>'个人设置', 'class'=>'', 'icon'=>'', 'controller'=>'config', 'action'=>'base', 'routePath'=>'config/base', 'show'=>1,],
+            ['name'=>'Shipping Address', 'class'=>'', 'icon'=>'', 'controller'=>'config', 'action'=>'receive-address-list', 'routePath'=>'config/receive-address-list', 'show'=>1,],//收货地址管理
+        ]
+    ],
+];

+ 1 - 0
frontendApi/config/menuV2.php

@@ -29,6 +29,7 @@ return [
             ['name'=>'Welcome Pack', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'dec', 'routePath'=>'user/dec', 'show'=>1,'allow'=>'declarer', 'wiki' => 'welcomePack',], // 报单管理
             ['name'=>'Welcome Pack Listing', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'dec-order-list', 'routePath'=>'shop/dec-order-list', 'show'=>1, 'wiki' => 'welcomePackList',],//报单列表
             ['name'=>'Upgrade Management', 'class'=>'', 'icon'=>'', 'controller'=>'upgrade', 'action'=>'dec', 'routePath'=>'user/upgrade', 'show'=>1,'allow'=>'declarer', 'wiki' => 'memberUpgrade',],//升级管理
+            ['name'=>'Reconsume', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'reconsume', 'routePath'=>'shop/reconsume', 'show'=>1,'allow'=>'studio', 'wiki' => 'reconsume'],//复消商品
             ['name'=>'Order List', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'order-list', 'routePath'=>'shop/order-list', 'show'=>1, 'wiki' => 'orderList',],//订单列表
 //            ['name'=>'Brand Ambassador', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'ba-dec', 'routePath'=>'user/ba-dec', 'show'=>1,'allow'=>'declarer', 'wiki' => 'brandAmbassador',],// BA会员
 //            ['name'=>'BA Order List', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'ba-dec-order-list', 'routePath'=>'shop/ba-dec-order-list', 'show'=>1,'allow'=>'declarer', 'wiki' => 'BAOrderList',],// BA订单

+ 233 - 232
frontendApi/config/urlManagerRules.php

@@ -1,232 +1,233 @@
-<?php
-/**
- * Created by PhpStorm.
- * User: leo
- * Date: 2018/3/6
- * Time: 上午11:12
- */
-return [
-    [
-        'class' => 'yii\rest\UrlRule',
-        'pluralize' => false,
-        'controller' => 'v1/site',
-        'extraPatterns' => [
-            'GET base-info' => 'base-info',
-            'GET mobile-base-info' => 'mobile-base-info',
-            'GET days-diff' => 'days-diff',
-            'GET ad' => 'ad',
-            'GET doc' => 'doc',
-            'GET config' => 'config',
-            'GET page-data' => 'page-data',
-            'GET captcha' => 'captcha',
-            'GET ba-base-info' => 'ba-base-info',
-            'GET send-notice' => 'send-notice',
-        ],
-    ],
-    [
-        'class' => 'yii\rest\UrlRule',
-        'pluralize' => false,
-        'controller' => 'v1/file',
-        'extraPatterns' => [
-            'GET token' => 'token',
-        ],
-    ],
-    [
-        'class' => 'yii\rest\UrlRule',
-        'pluralize' => false,
-        'controller' => 'v1/oauth',
-        'extraPatterns' => [
-            'GET menu' => 'menu',
-            'POST is-login-verify' => 'is-login-verify',
-            'POST login' => 'login',
-            'GET index' => 'index',
-            'GET info' => 'info',
-            'GET refresh-token' => 'refresh-token',
-            'GET refresh-access-token' => 'refresh-access-token',
-            'GET refresh-refresh-token' => 'refresh-refresh-token',
-            'POST login-by-backend' => 'login-by-backend',
-            'POST no-login-modify-password' => 'no-login-modify-password',
-        ],
-    ],
-    [
-        'class' => 'yii\rest\UrlRule',
-        'pluralize' => false,
-        'controller' => 'v1/dashboard',
-        'extraPatterns' => [
-            'GET index' => 'index',
-            'GET my-index' => 'my-index',
-            'GET period-bonus' => 'period-bonus',
-            'GET bonus-num' => 'bonus-num',
-            'GET ba-index' => 'ba-index',
-        ],
-    ],
-    [
-        'class' => 'yii\rest\UrlRule',
-        'pluralize' => false,
-        'controller' => 'v1/shop',
-        'extraPatterns' => [
-            'GET index' => 'index',
-            'GET reconsume' => 'reconsume',
-            'GET goods-detail/<id>' => 'goods-detail',
-            'GET show-cart' => 'show-cart',
-            'GET reconsume-cart' => 'reconsume-cart',
-            'POST sure-order' => 'sure-order',
-            'POST reconsume-sure-order' => 'reconsume-sure-order',
-            'GET pay-success' => 'pay-success',
-            'GET order-list' => 'order-list',
-            'GET dec-order-list' => 'dec-order-list',
-            'GET goods-active' => 'goods-active',
-            'GET order-export/<orderSn>' => 'order-export',
-            'GET dec-order-export/<orderSn>' => 'dec-order-export',
-            'POST sure-approach-order' => 'sure-approach-order',
-            'POST delete-approach-order' => 'delete-approach-order',
-            'POST verify-approach-order' => 'verify-approach-order',
-            'GET order-backing-out' => 'order-backing-out',
-            'GET ba-order-list' => 'ba-order-list',
-            'GET ba-product-list' => 'ba-product-list',
-            'GET ba-shopping-cart' => 'ba-shopping-cart',
-            'POST ba-sure-approach-order' => 'ba-sure-approach-order',
-            'POST ba-delete-approach-order' => 'ba-delete-approach-order',
-            'GET ba-dec-order-list' => 'ba-dec-order-list',
-            'GET ba-dec-order-export/<orderSn>' => 'ba-dec-order-export',
-        ],
-    ],
-    [
-        'class' => 'yii\rest\UrlRule',
-        'pluralize' => false,
-        'controller' => 'v1/user',
-        'extraPatterns' => [
-            'GET index' => 'index',
-            'POST edit' => 'edit',
-            'POST password' => 'password',
-            'POST pay-password' => 'pay-password',
-            'GET,POST,PUT id-card' => 'id-card',
-            'GET rec-user' => 'rec-user',
-            'GET bind' => 'bind',
-            'GET,POST bind-edit/<id>' => 'bind-edit',
-            'GET,POST dec' => 'dec',
-            'GET,POST upgrade' => 'upgrade',
-            'POST upgrade-info' => 'upgrade-info',
-            'GET dec-package' => 'dec-package',
-            'GET full-info' => 'full-info',
-            'GET get-auto-place' => 'get-auto-place',
-            'GET user-base-info' => 'user-base-info',
-
-            'GET ba-info' => 'ba-info',
-            'POST ba-edit' => 'ba-edit',
-            'POST ba-password' => 'ba-password',
-            'POST ba-pay-password' => 'ba-pay-password',
-            'GET,POST ba-dec' => 'ba-dec',
-            'GET ba-user-info' => 'ba-user-info',
-        ],
-    ],
-    [
-        'class' => 'yii\rest\UrlRule',
-        'pluralize' => false,
-        'controller' => 'v1/atlas',
-        'extraPatterns' => [
-            'GET main-user-info' => 'main-user-info',
-            'GET network' => 'network',
-            'GET network-list' => 'network-list',
-            'GET relation' => 'relation',
-            'GET relation-list' => 'relation-list',
-            'GET get-period' => 'get-period',
-            'GET brand-ambassador-list' => 'brand-ambassador-list',
-        ],
-    ],
-    [
-        'class' => 'yii\rest\UrlRule',
-        'pluralize' => false,
-        'controller' => 'v1/bonus',
-        'extraPatterns' => [
-            'GET index' => 'index',
-            'GET wallet-flow' => 'wallet-flow',
-            'GET new' => 'new',
-            'GET teams' => 'teams',
-            'GET other' => 'other',
-            'GET real-time-perf' => 'real-time-perf',
-            'GET flow-bt' => 'flow-bt',
-            'GET trace-fl' => 'trace-fl',
-            'GET dec-period' => 'dec-period',
-            'GET fc-point' => 'fc-point',
-            'GET historical-cumulative-bonus' => 'historical-cumulative-bonus',
-        ],
-    ],
-    [
-        'class' => 'yii\rest\UrlRule',
-        'pluralize' => false,
-        'controller' => 'v1/finance',
-        'extraPatterns' => [
-            'GET reconsume-pool-flow' => 'reconsume-pool-flow',
-            'GET withdraw' => 'withdraw',
-            'POST withdraw-add' => 'withdraw-add',
-            'POST withdraw-back' => 'withdraw-back',
-            'GET,POST,PUT invoice-add/<id>' => 'invoice-add',
-            'GET invoice-before-add' => 'invoice-before-add',
-            'GET invoice-after-add' => 'invoice-after-add',
-            'GET chk-withdraw-user' => 'chk-withdraw-user',
-            'GET invoice-show' => 'invoice-show',
-            'GET collect-bind' => 'collect-bind',
-            'GET available-balance' => 'available-balance',
-            'GET dec-list' => 'dec-list',
-            'GET transfer-list' => 'transfer-list',
-            'POST transfer-add' => 'transfer-add',
-            'GET chk-transfer-user' => 'chk-transfer-user',
-            'GET recharge' => 'recharge',
-            'GET,POST recharge-add' => 'recharge-add',
-            'GET,POST prove-add' => 'prove-add',
-            'GET mult-point' => 'mult-point',
-            'GET wd-mult-point' => 'wd-mult-point',
-        ],
-    ],
-    [
-        'class' => 'yii\rest\UrlRule',
-        'pluralize' => false,
-        'controller' => 'v1/config',
-        'extraPatterns' => [
-            'GET base' => 'base',
-            'POST auto-withdraw' => 'auto-withdraw',
-//            'POST allow-reconsume-sms' => 'allow-reconsume-sms',
-            'GET receive-address-list' => 'receive-address-list',
-            'GET receive-address-one/<id>' => 'receive-address-one',
-            'POST receive-address-add' => 'receive-address-add',
-            'POST receive-address-edit' => 'receive-address-edit',
-            'POST receive-address-default' => 'receive-address-default',
-            'POST receive-address-delete' => 'receive-address-delete',
-
-            'GET ba-receive-address-list' => 'ba-receive-address-list',
-            'GET ba-receive-address-one/<id>' => 'ba-receive-address-one',
-            'POST ba-receive-address-add' => 'ba-receive-address-add',
-            'POST ba-receive-address-edit' => 'ba-receive-address-edit',
-            'POST ba-receive-address-default' => 'ba-receive-address-default',
-            'POST ba-receive-address-delete' => 'ba-receive-address-delete',
-        ],
-    ],
-    [
-        'class' => 'yii\rest\UrlRule',
-        'pluralize' => false,
-        'controller' => 'v1/article',
-        'extraPatterns' => [
-            'GET index' => 'index',
-            'GET category' => 'category',
-            'GET list/<cid>' => 'list',
-            'GET list' => 'list',
-            'GET detail/<id>' => 'detail',
-            'GET detail' => 'detail',
-            'GET get-new-article' => 'get-new-article',
-        ],
-    ],
-    [
-        'class' => 'yii\rest\UrlRule',
-        'pluralize' => false,
-        'controller' => 'v1/message',
-        'extraPatterns' => [
-            'GET list' => 'list',
-            'GET detail/<id>' => 'detail',
-            'GET detail' => 'detail',
-            'GET pull' => 'pull',
-            'GET unread-num' => 'unread-num',
-            'GET unread-text' => 'unread-text',
-        ],
-    ],
-];
+<?php
+/**
+ * Created by PhpStorm.
+ * User: leo
+ * Date: 2018/3/6
+ * Time: 上午11:12
+ */
+return [
+    [
+        'class' => 'yii\rest\UrlRule',
+        'pluralize' => false,
+        'controller' => 'v1/site',
+        'extraPatterns' => [
+            'GET base-info' => 'base-info',
+            'GET mobile-base-info' => 'mobile-base-info',
+            'GET days-diff' => 'days-diff',
+            'GET ad' => 'ad',
+            'GET doc' => 'doc',
+            'GET config' => 'config',
+            'GET page-data' => 'page-data',
+            'GET captcha' => 'captcha',
+            'GET ba-base-info' => 'ba-base-info',
+            'GET send-notice' => 'send-notice',
+        ],
+    ],
+    [
+        'class' => 'yii\rest\UrlRule',
+        'pluralize' => false,
+        'controller' => 'v1/file',
+        'extraPatterns' => [
+            'GET token' => 'token',
+        ],
+    ],
+    [
+        'class' => 'yii\rest\UrlRule',
+        'pluralize' => false,
+        'controller' => 'v1/oauth',
+        'extraPatterns' => [
+            'GET menu' => 'menu',
+            'POST is-login-verify' => 'is-login-verify',
+            'POST login' => 'login',
+            'GET index' => 'index',
+            'GET info' => 'info',
+            'GET refresh-token' => 'refresh-token',
+            'GET refresh-access-token' => 'refresh-access-token',
+            'GET refresh-refresh-token' => 'refresh-refresh-token',
+            'POST login-by-backend' => 'login-by-backend',
+            'POST no-login-modify-password' => 'no-login-modify-password',
+        ],
+    ],
+    [
+        'class' => 'yii\rest\UrlRule',
+        'pluralize' => false,
+        'controller' => 'v1/dashboard',
+        'extraPatterns' => [
+            'GET index' => 'index',
+            'GET my-index' => 'my-index',
+            'GET period-bonus' => 'period-bonus',
+            'GET bonus-num' => 'bonus-num',
+            'GET ba-index' => 'ba-index',
+        ],
+    ],
+    [
+        'class' => 'yii\rest\UrlRule',
+        'pluralize' => false,
+        'controller' => 'v1/shop',
+        'extraPatterns' => [
+            'GET index' => 'index',
+            'GET reconsume' => 'reconsume',
+            'GET goods-detail/<id>' => 'goods-detail',
+            'GET show-cart' => 'show-cart',
+            'GET reconsume-cart' => 'reconsume-cart',
+            'POST sure-order' => 'sure-order',
+            'POST reconsume-sure-order' => 'reconsume-sure-order',
+            'GET pay-success' => 'pay-success',
+            'GET order-list' => 'order-list',
+            'GET dec-order-list' => 'dec-order-list',
+            'GET goods-active' => 'goods-active',
+            'GET order-export/<orderSn>' => 'order-export',
+            'GET dec-order-export/<orderSn>' => 'dec-order-export',
+            'POST sure-approach-order' => 'sure-approach-order',
+            'POST delete-approach-order' => 'delete-approach-order',
+            'POST verify-approach-order' => 'verify-approach-order',
+            'GET order-backing-out' => 'order-backing-out',
+            'GET ba-order-list' => 'ba-order-list',
+            'GET ba-product-list' => 'ba-product-list',
+            'GET ba-shopping-cart' => 'ba-shopping-cart',
+            'POST ba-sure-approach-order' => 'ba-sure-approach-order',
+            'POST ba-delete-approach-order' => 'ba-delete-approach-order',
+            'GET ba-dec-order-list' => 'ba-dec-order-list',
+            'GET ba-dec-order-export/<orderSn>' => 'ba-dec-order-export',
+            'POST sure-approach-reconsume-order' => 'sure-approach-reconsume-order',
+        ],
+    ],
+    [
+        'class' => 'yii\rest\UrlRule',
+        'pluralize' => false,
+        'controller' => 'v1/user',
+        'extraPatterns' => [
+            'GET index' => 'index',
+            'POST edit' => 'edit',
+            'POST password' => 'password',
+            'POST pay-password' => 'pay-password',
+            'GET,POST,PUT id-card' => 'id-card',
+            'GET rec-user' => 'rec-user',
+            'GET bind' => 'bind',
+            'GET,POST bind-edit/<id>' => 'bind-edit',
+            'GET,POST dec' => 'dec',
+            'GET,POST upgrade' => 'upgrade',
+            'POST upgrade-info' => 'upgrade-info',
+            'GET dec-package' => 'dec-package',
+            'GET full-info' => 'full-info',
+            'GET get-auto-place' => 'get-auto-place',
+            'GET user-base-info' => 'user-base-info',
+
+            'GET ba-info' => 'ba-info',
+            'POST ba-edit' => 'ba-edit',
+            'POST ba-password' => 'ba-password',
+            'POST ba-pay-password' => 'ba-pay-password',
+            'GET,POST ba-dec' => 'ba-dec',
+            'GET ba-user-info' => 'ba-user-info',
+        ],
+    ],
+    [
+        'class' => 'yii\rest\UrlRule',
+        'pluralize' => false,
+        'controller' => 'v1/atlas',
+        'extraPatterns' => [
+            'GET main-user-info' => 'main-user-info',
+            'GET network' => 'network',
+            'GET network-list' => 'network-list',
+            'GET relation' => 'relation',
+            'GET relation-list' => 'relation-list',
+            'GET get-period' => 'get-period',
+            'GET brand-ambassador-list' => 'brand-ambassador-list',
+        ],
+    ],
+    [
+        'class' => 'yii\rest\UrlRule',
+        'pluralize' => false,
+        'controller' => 'v1/bonus',
+        'extraPatterns' => [
+            'GET index' => 'index',
+            'GET wallet-flow' => 'wallet-flow',
+            'GET new' => 'new',
+            'GET teams' => 'teams',
+            'GET other' => 'other',
+            'GET real-time-perf' => 'real-time-perf',
+            'GET flow-bt' => 'flow-bt',
+            'GET trace-fl' => 'trace-fl',
+            'GET dec-period' => 'dec-period',
+            'GET fc-point' => 'fc-point',
+            'GET historical-cumulative-bonus' => 'historical-cumulative-bonus',
+        ],
+    ],
+    [
+        'class' => 'yii\rest\UrlRule',
+        'pluralize' => false,
+        'controller' => 'v1/finance',
+        'extraPatterns' => [
+            'GET reconsume-pool-flow' => 'reconsume-pool-flow',
+            'GET withdraw' => 'withdraw',
+            'POST withdraw-add' => 'withdraw-add',
+            'POST withdraw-back' => 'withdraw-back',
+            'GET,POST,PUT invoice-add/<id>' => 'invoice-add',
+            'GET invoice-before-add' => 'invoice-before-add',
+            'GET invoice-after-add' => 'invoice-after-add',
+            'GET chk-withdraw-user' => 'chk-withdraw-user',
+            'GET invoice-show' => 'invoice-show',
+            'GET collect-bind' => 'collect-bind',
+            'GET available-balance' => 'available-balance',
+            'GET dec-list' => 'dec-list',
+            'GET transfer-list' => 'transfer-list',
+            'POST transfer-add' => 'transfer-add',
+            'GET chk-transfer-user' => 'chk-transfer-user',
+            'GET recharge' => 'recharge',
+            'GET,POST recharge-add' => 'recharge-add',
+            'GET,POST prove-add' => 'prove-add',
+            'GET mult-point' => 'mult-point',
+            'GET wd-mult-point' => 'wd-mult-point',
+        ],
+    ],
+    [
+        'class' => 'yii\rest\UrlRule',
+        'pluralize' => false,
+        'controller' => 'v1/config',
+        'extraPatterns' => [
+            'GET base' => 'base',
+            'POST auto-withdraw' => 'auto-withdraw',
+//            'POST allow-reconsume-sms' => 'allow-reconsume-sms',
+            'GET receive-address-list' => 'receive-address-list',
+            'GET receive-address-one/<id>' => 'receive-address-one',
+            'POST receive-address-add' => 'receive-address-add',
+            'POST receive-address-edit' => 'receive-address-edit',
+            'POST receive-address-default' => 'receive-address-default',
+            'POST receive-address-delete' => 'receive-address-delete',
+
+            'GET ba-receive-address-list' => 'ba-receive-address-list',
+            'GET ba-receive-address-one/<id>' => 'ba-receive-address-one',
+            'POST ba-receive-address-add' => 'ba-receive-address-add',
+            'POST ba-receive-address-edit' => 'ba-receive-address-edit',
+            'POST ba-receive-address-default' => 'ba-receive-address-default',
+            'POST ba-receive-address-delete' => 'ba-receive-address-delete',
+        ],
+    ],
+    [
+        'class' => 'yii\rest\UrlRule',
+        'pluralize' => false,
+        'controller' => 'v1/article',
+        'extraPatterns' => [
+            'GET index' => 'index',
+            'GET category' => 'category',
+            'GET list/<cid>' => 'list',
+            'GET list' => 'list',
+            'GET detail/<id>' => 'detail',
+            'GET detail' => 'detail',
+            'GET get-new-article' => 'get-new-article',
+        ],
+    ],
+    [
+        'class' => 'yii\rest\UrlRule',
+        'pluralize' => false,
+        'controller' => 'v1/message',
+        'extraPatterns' => [
+            'GET list' => 'list',
+            'GET detail/<id>' => 'detail',
+            'GET detail' => 'detail',
+            'GET pull' => 'pull',
+            'GET unread-num' => 'unread-num',
+            'GET unread-text' => 'unread-text',
+        ],
+    ],
+];

+ 19 - 0
frontendApi/modules/v1/controllers/ShopController.php

@@ -27,6 +27,7 @@ use common\models\BaUser;
 use common\models\DecOrder;
 use common\models\BaDecOrder;
 use common\models\forms\ApproachOrderForm;
+use common\models\forms\ApproachReconsumeOrderForm;
 use common\models\forms\BaApproachOrderForm;
 use common\models\forms\DeclarationForm;
 use common\models\forms\OrderForm;
@@ -194,6 +195,24 @@ class ShopController extends BaseController {
         }
     }
 
+    /**
+     * 确认复消订单
+     */
+    public function actionSureApproachReconsumeOrder(){
+        if (\Yii::$app->request->isPost) {
+            $formModel = new ApproachReconsumeOrderForm();
+            $formModel->scenario = 'reconsumeOrder';
+            $formModel->remark = '为用户复消';
+            $post = \Yii::$app->request->post();
+            $post['type'] = DeclarationForm::TYPE_FX;
+            if ($formModel->load($post, '') && $order = $formModel->add()) {
+                return static::notice($order);
+            } else {
+                return static::notice(Form::formatErrorsForApi($formModel->getErrors()),400);
+            }
+        }
+    }
+
     /**
      * PayStack支付成功的webhook.
      * @throws HttpException