Pārlūkot izejas kodu

BA会员报单修改

kevin_zhangl 3 gadi atpakaļ
vecāks
revīzija
b542925b72

+ 1 - 1
common/models/ApproachDecOrder.php

@@ -51,7 +51,7 @@ class ApproachDecOrder extends \common\components\ActiveRecord
     public function rules()
     {
         return [
-            [['USER_ID', 'TO_USER_ID','REC_USER_ID','CON_USER_ID','DEC_ID', 'TYPE', 'PAID_WALLET', 'PERIOD_NUM', 'P_CALC_MONTH', 'CREATED_AT'], 'required'],
+            [['USER_ID', 'TO_USER_ID','REC_USER_ID',/*'CON_USER_ID','DEC_ID', */'TYPE', 'PAID_WALLET', 'PERIOD_NUM', 'P_CALC_MONTH', 'CREATED_AT'], 'required'],
             [['IS_ADMIN', 'IS_BATCH', 'PERIOD_NUM', 'CALC_MONTH', 'CREATED_AT', 'IS_DEL', 'DELETED_AT'], 'integer'],
             [['DEC_AMOUNT', 'DEC_PV'], 'number'],
             [['ID', 'DEC_SN', 'ORDER_SN', 'USER_ID', 'TO_USER_ID','REC_USER_ID','CON_USER_ID','DEC_ID', 'TYPE', 'UPDATER', 'UPDATED_AT'], 'string', 'max' => 32],

+ 1 - 1
common/models/BaApproachDecOrder.php

@@ -51,7 +51,7 @@ class BaApproachDecOrder extends \common\components\ActiveRecord
     public function rules()
     {
         return [
-            [['USER_ID', 'TO_USER_ID','REC_USER_ID','CON_USER_ID','DEC_ID', 'TYPE', 'PAID_WALLET', 'PERIOD_NUM', 'P_CALC_MONTH', 'CREATED_AT'], 'required'],
+            [['USER_ID', 'TO_USER_ID','REC_USER_ID',/*'CON_USER_ID','DEC_ID', */'TYPE', 'PAID_WALLET', 'PERIOD_NUM', 'P_CALC_MONTH', 'CREATED_AT'], 'required'],
             [['IS_ADMIN', 'IS_BATCH', 'PERIOD_NUM', 'CALC_MONTH', 'CREATED_AT', 'IS_DEL', 'DELETED_AT'], 'integer'],
             [['DEC_AMOUNT', 'DEC_PV'], 'number'],
             [['ID', 'DEC_SN', 'ORDER_SN', 'USER_ID', 'TO_USER_ID','REC_USER_ID','CON_USER_ID','DEC_ID', 'TYPE', 'UPDATER', 'UPDATED_AT'], 'string', 'max' => 32],

+ 563 - 0
common/models/forms/BaApproachDeclarationForm.php

@@ -0,0 +1,563 @@
+<?php
+namespace common\models\forms;
+
+use common\components\Model;
+use common\helpers\Cache;
+use common\helpers\Date;
+use common\helpers\Form;
+use common\helpers\LoggerTool;
+use common\helpers\user\Cash;
+use common\helpers\user\Reconsume;
+use common\helpers\user\Info;
+use common\models\ApproachDecOrder;
+use common\models\ApproachOrder;
+use common\models\ApproachOrderGoods;
+use common\models\BaApproachDecOrder;
+use common\models\BaApproachOrder;
+use common\models\BaApproachOrderGoods;
+use common\models\BaReceiveAddress;
+use common\models\BaUser;
+use common\models\DeclarationPackage;
+use common\models\DecOrder;
+use common\models\EmployLevel;
+use common\models\Order;
+use common\models\OrderGoods;
+use common\models\Period;
+use common\models\ReceiveAddress;
+use common\models\ReconsumePool;
+use common\models\ReconsumePoolFlow;
+use common\models\DeclarationLevel;
+use common\models\Region;
+use common\models\ShopGoods;
+use common\models\User;
+use common\models\UserInfo;
+use common\models\UserNetwork;
+use common\models\UserRelation;
+use yii\base\Exception;
+
+/**
+ * Login form
+ */
+class BaApproachDeclarationForm extends Model
+{
+    public $type;
+    public $decLv;
+    public $decWay;
+    public $packageId;
+    public $goodsId;
+    public $goodsNum;
+    public $insertUserName;
+    public $password;
+    public $payPassword;
+    public $realName;
+    public $insertUserIdCard;
+    public $mobile;
+    public $email;
+    public $address;
+    public $openBank;
+    public $bankAddress;
+    public $bankNo;
+    public $bankProvince;
+    public $bankCity;
+    public $bankCounty;
+    public $conUserName;
+    public $recUserName;
+    public $decUserName;
+    public $location;
+    public $consignee;
+    public $acceptMobile;
+    public $province;
+    public $city;
+    public $county;
+    public $cityName;
+    public $lgaName;
+    public $payType;
+
+    // 传过来的全部数据
+    public $allData;
+    private $_decId;
+    public $_insertUserId;
+    private $_decAmount;
+    private $_decPv;
+    private $_orderGoods;
+    private $_standardAmount;
+    private $_decAmountStandard;
+
+    // 批量报单时添加会员的REDIS里面缓存的添加的会员资料
+    const REDIS_WAIT_ADD_USER = 'user:dec:waitAdd';
+
+    const TYPE_ZC = 'ZC';
+//    const TYPE_YH = 'YH';
+    const TYPE_ZG = 'ZG';
+    const TYPE_LS = 'LS';
+    const TYPE_FX = 'FX';
+
+//    private $_modelClass = null;
+    private $_oneOrder = null;
+    private $_userForm = null;
+    // 全部的上级(安置网和开拓网)
+    private $_tempParentUser = [];
+    // 全部的安置网上级
+    private $_tempNetworkParentUser = [];
+    // 全部的开拓网上级
+    private $_tempRelationParentUser = [];
+    private $_types = [
+        self::TYPE_ZC => [
+            'name' => '首购单',
+        ],
+//        self::TYPE_YH => [
+//            'class' => DeclarationYH::class,
+//            'table' => '{{%DECLARATION_YH}}',
+//            'name' => '优惠单',
+//        ],
+        self::TYPE_ZG => [
+            'name' => '升级增购单',
+        ],
+        self::TYPE_LS => [
+            'name' => '零售单',
+        ],
+        self::TYPE_FX => [
+            'name' => '复销单',
+        ],
+    ];
+
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['type','decLv','decWay','packageId', 'insertUserName', 'realName',/* 'insertUserIdCard',*/ 'mobile', 'address', 'openBank', 'bankAddress', 'bankNo','bankProvince','bankCity','bankCounty','consignee','acceptMobile','province','city','county','cityName','lgaName','decUserName', 'conUserName', 'recUserName', 'location'], 'trim'],
+            [['type','decLv','decWay','insertUserName',/* 'insertUserIdCard',*/'password','payPassword','decUserName'], 'required'],
+        ];
+    }
+
+    public function attributeLabels()
+    {
+        return [
+            'type' => 'Entry type',//报单类型
+            'decLv' => 'Entry level',//报单级别
+            //'decPv' => '报单PV',
+            'decWay' => 'Entry method',//报单方式
+            'packageId' => 'Entry Package',//报单套餐
+            'goodsId' => 'product ID',//商品ID
+            'goodsNum' => 'Product quantity',//商品数量
+            //'addType' => '新增会员方式',
+            'insertUserName' => 'Member user name',//会员用户名
+            'password' => 'Login password',//登陆密码
+            'payPassword' => 'Payment password',//支付密码
+            'realName' => 'Member Name',//会员姓名
+            'insertUserIdCard' => 'ID',//身份证号
+            'mobile' => 'Phone Number',//手机号
+            'openBank' => 'openBank',//开户行
+            'bankAddress' => 'bankAddress',//开户支行
+            'bankNo' => 'bankNo',//银行账号
+            'bankProvince' => 'bankProvince',//银行省份
+            'bankCity' => 'bankCity',//银行城市
+            'bankCounty' => 'bankCounty',//银行县区
+            'conUserName' => 'Instructor user name',//指导老师用户名
+            'recUserName' => 'Developer user name',//开拓人用户名
+            'decUserName' => 'Stockist user name',//报单中心用户名
+            'conUid' => 'Instructor member ID',//指导老师会员ID
+            'recUid' => 'Sponsor member ID',//'开拓人会员ID
+            'location' => 'market',//市场
+            'consignee' => 'consignee',//收货人
+            'acceptMobile' => 'Recipient Phone Number',//收货人手机
+            'province' => 'Receiving Province',//收货省
+            'city' => 'Receiving City',//收货市
+            'county' => 'Receiving area / county',//收货区县
+            'address' => 'Receiving detailed address',//收货详细地址
+        ];
+    }
+
+    /**
+     * 指定场景
+     * @return array
+     */
+    public function scenarios()
+    {
+        $parentScenarios =  parent::scenarios();
+        $customScenarios = [
+            'userDec' => ['type','allData', /*'decLv','decWay',*/'insertUserName','password','payPassword', 'realName','mobile', 'address','consignee','acceptMobile','province','conUserName', /*'recUserName','decUserName',*/ 'location', 'email'],
+            'canDec' => ['type', 'insertUserName',/* 'insertUserIdCard',*/ 'conUserName', 'recUserName', 'location'],
+            'notFull' => ['type', 'insertUserName', 'conUserName', 'recUserName', 'location'],
+        ];
+        return array_merge($parentScenarios, $customScenarios);
+    }
+
+    /**
+     * 判断报单中心是否存在
+     * @param $attribute
+     * @return false|void
+     */
+    public function issetDec($attribute){
+        if (!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');//报单中心不存在
+            return false;
+        }
+        return true;
+    }
+
+
+    /**
+     * 判断开拓人
+     * @param $attribute
+     */
+    public function isRecUserName($attribute){
+        if($this->type == self::TYPE_ZC){
+            // 开拓人
+            if(!isset($this->_tempParentUser[$this->recUserName])){
+                $recUserTemp = UserInfo::findOneAsArray('USER_NAME=:USER_NAME', [':USER_NAME' => $this->recUserName]);
+                if(!$recUserTemp){
+                    if($this->insertUserName){
+                        //$this->addError($attribute, '为'.$this->insertUserName.'报单,开拓人'.$this->recUserName.'不存在');
+                        $this->addError($attribute, 'To'.$this->insertUserName.'Entry, Sponsor'.$this->recUserName.'not in exist');
+                    } else {
+                       // $this->addError($attribute, '开拓人'.$this->recUserName.'不存在');
+                        $this->addError($attribute, 'Sponsor'.$this->recUserName.'not in exist');
+                    }
+
+                    return ;
+                }
+                $recUserTemp['CON_NUM'] = UserNetwork::firstFloorChildNum($recUserTemp['USER_ID']);
+                $recUserTemp['REC_NUM'] = UserRelation::firstFloorChildNum($recUserTemp['USER_ID']);
+                $this->_tempParentUser[$this->recUserName] = [
+                    'USER_NAME' => $this->recUserName,
+                    'ZC_PV' => $recUserTemp['ZC_PV'],
+                    'CON_USER_NAME' => Info::getUserNameByUserId($recUserTemp['CON_UID']),
+                    'REC_USER_NAME' => Info::getUserNameByUserId($recUserTemp['REC_UID']),
+                    'CON_NUM' => $recUserTemp['CON_NUM'],
+                    'REC_NUM' => $recUserTemp['REC_NUM'],
+                    'SYSTEM_ID' => $recUserTemp['SYSTEM_ID'],
+                    'LOCATION' => UserNetwork::getLocation($recUserTemp['USER_ID'], $recUserTemp['CON_UID']),
+                ];
+                // 把该会员下面的5个区是否存在会员都付上
+                for($i=1;$i<=5;$i++){
+                    $this->_tempParentUser[$this->recUserName]["LOCATION$i"] = UserNetwork::issetUserInLocation($recUserTemp['USER_ID'], $i);
+                }
+            }
+            $recUser = $this->_tempParentUser[$this->recUserName];
+            $this->_tempParentUser[$this->recUserName]['REC_NUM'] += 1;
+
+            // 存在新加入会员时查看开拓人是否在新加入会员的安置网上级中
+            if($this->insertUserName) {
+                $this->loopFindParentToNetwork($this->insertUserName);
+                if (!$this->recUserIsInNetworkParent()) {
+                   // $this->addError($attribute, '为' . $this->insertUserName . '报单,开拓人' . $this->recUserName . '不在' . $this->insertUserName . '的安置网上级中');
+                    $this->addError($attribute, 'To' . $this->insertUserName . 'Entry, Sponsor' . $this->recUserName . 'not in exist' . $this->insertUserName . 'in the placement superiors');
+                    return ;
+                }
+            }
+
+            // 把自己加入到临时上级会员数组中
+            $this->_tempParentUser[$this->insertUserName] = [
+                'USER_NAME' => $this->insertUserName,
+                //'ZC_PV' => $this->decPv,
+                'CON_USER_NAME' => $this->conUserName,
+                'REC_USER_NAME' => $this->recUserName,
+                'CON_NUM' => 0,
+                'REC_NUM' => 0,
+                'SYSTEM_ID' => $recUser['SYSTEM_ID'],
+                'LOCATION' => $this->location,
+                'LOCATION1' => 0,
+                'LOCATION2' => 0,
+                'LOCATION3' => 0,
+                'LOCATION4' => 0,
+                'LOCATION5' => 0,
+            ];
+        }
+
+    }
+
+    /**
+     * 报单类型
+     * @param $attribute
+     * @param $params
+     */
+    public function isType($attribute, $params){
+        if(array_key_exists($this->type, $this->_types)){
+            if($this->type == self::TYPE_ZC){
+                if($this->scenario == 'userDec'){
+                    if(!$this->insertUserName) $this->addError($attribute, 'Membership number must be filled in for initial purchase');//首购必须填写加入会员编号
+                }
+                if(!$this->insertUserName) $this->addError($attribute, 'Membership number must be filled in for initial purchase');//首购必须填写加入会员编号
+                if(!$this->conUserName) $this->addError($attribute, 'For the first purchase, you must fill in the instructor number of the member');//首购必须填写加入会员的指导老师编号
+                if(!$this->recUserName) $this->addError($attribute, 'For the first purchase, the Sponsor number of the member must be filled in');//首购必须填写加入会员的开拓人编号
+                if(!$this->location) $this->addError($attribute, 'The first purchase must be filled in the market of the member');//首购必须填写加入会员的市场
+            }
+        } else {
+            $this->addError($attribute, 'Incorrect entry type');//报单类型不正确
+        }
+    }
+
+    /**
+     * 添加报单
+     * @param $allData
+     * @return array|bool|BaApproachOrder
+     * @throws Exception
+     */
+    public function add($allData){
+        if(!$this->validate()){
+            return $this->getErrors();
+        }
+        // 首购单,需要添加会员操作
+        if($this->type == self::TYPE_ZC) {
+            try {
+                if (preg_match("/[\x7f-\xff]/", $this->insertUserName)) {  //判断字符串中是否有中文
+                    throw new Exception('Member number cannot contain Chinese characters');//会员编号中不能含有汉字
+                }
+
+                if ($this->decWay == 1) {
+                    $decPackage = DeclarationPackage::findOneAsArray('ID=:ID', [':ID' => $this->packageId]);
+                    $this->_decAmount = $decPackage['AMOUNT'];
+                    $this->_decPv = $decPackage['PV'];
+                    $this->_orderGoods[] = [
+                        'GOODS_ID' => $this->packageId,
+                        'PRICE' => $this->_decAmount,
+                        'REAL_PRICE' => $this->_decAmount,
+                        'PV' => $this->_decPv,
+                        'REAL_PV' => $this->_decPv,
+                        'BUY_NUMS' => 1,
+                        'SKU_CODE' => $decPackage['PACKAGE_NO'],
+                        'GOODS_TITLE' => $decPackage['PACKAGE_NAME'],
+                        'EMAIL' => $this->email
+                    ];
+                } else {
+                    $ids = $this->goodsId;
+                    $totalAmount = 0;
+                    $totalAmountStandard = 0;
+                    $totalPv = 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['STORE_NUMS'] > 0) {
+                                $totalAmount += $goods['SELL_PRICE'] * intval($v);
+                                $totalAmountStandard += $goods['SELL_PRICE_STANDARD'] * intval($v);
+                                $realPriceStandard = $goods['SELL_PRICE_STANDARD'];
+                                $totalPv += $goods['PRICE_PV'] * intval($v);
+                                $this->_orderGoods[] = [
+                                    'GOODS_ID' => $goods['ID'],
+                                    'PRICE' => $goods['SELL_PRICE'],
+                                    'REAL_PRICE' => $goods['SELL_PRICE'],
+                                    'PV' => $goods['PRICE_PV'],
+                                    'REAL_PV' => $goods['PRICE_PV'],
+                                    'POINT' => $goods['POINT'],
+                                    'BUY_NUMS' => intval($v),
+                                    'SKU_CODE' => $goods['GOODS_NO'],
+                                    'GOODS_TITLE' => $goods['GOODS_NAME'],
+                                    'EMAIL' => $this->email,
+                                    'STANDARD_PRICE' => $goods['SELL_PRICE_STANDARD'],
+                                    'REAL_STANDARD_PRICE' => $realPriceStandard,
+                                    'EXCHANGE_RATE' => $exchangeRate,
+                                    'TAX_RATE' => $goods['TAX_RATE'],
+                                ];
+                            }
+                        }
+                    }
+
+                    $this->_decAmount = $totalAmount;
+                    $this->_decPv = $totalPv;
+                    $this->_decAmountStandard = $totalAmountStandard;
+                    $this->_standardAmount = $this->_decAmountStandard;
+                }
+
+                if (!($this->addUser($allData))) {
+                    throw new Exception(Form::formatErrorsForApi($this->_userForm->getErrors()));
+                }
+
+                $decResult = $this->addDecOrder();
+                if (!$decResult) {
+                    throw new Exception(Form::formatErrorsForApi($decResult->getErrors()));
+                }
+
+                return $decResult;
+            } catch (\Exception $e) {
+                throw new Exception(Form::formatErrorsForApi($e->getFile() . ' ' . $e->getLine() . ' ' . $e->getMessage()));
+            }
+        }
+        return true;
+    }
+
+    /**
+     * 添加会员
+     * @param $allData
+     * @return bool|UserInfo|null
+     * @throws \yii\db\Exception|Exception
+     */
+    public function addUser($allData){
+        $period = Period::instance();
+        // 增加会员
+        $user = new BaUser();
+        $user->USER_NAME = $this->insertUserName;
+        $user->PASSWORD_HASH = \Yii::$app->security->generatePasswordHash($this->password);
+        $user->PAY_PASSWORD = \Yii::$app->security->generatePasswordHash($this->payPassword);
+        $user->NATION = 0;
+        $user->REAL_NAME = $this->realName;
+        $user->ID_CARD = $this->mobile;
+        $user->MOBILE = $this->mobile;
+        $user->EMAIL = $this->email;
+        $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->bankProvince ?? 0;
+        $user->BANK_CITY = $this->bankCity ?? 0;
+        $user->BANK_COUNTY = $this->bankCounty ?? 0;
+        $user->CREATED_AT = Date::nowTime();
+        $user->STATUS = 1;
+        $user->DEC_LV = $this->decLv;
+        $user->LAST_DEC_LV = $this->decLv;
+        $user->EMP_LV = EmployLevel::getDefaultLevelId();
+        $user->PROVINCE = $this->province ?? 0;
+        $user->LGA_NAME = $this->lgaName;
+        $user->CITY_NAME = $this->cityName;
+//        $user->CITY = $this->city ?? 0;
+//        $user->COUNTY = intval($this->county) ?? 0;
+        $user->AVATAR = 'avatar/1.png';
+        $user->IS_DEC = 0;
+        $user->DEC_ID = $this->_decId ?? '';
+        $user->DEC_ROLE_ID = $this->decRoleId ?? '';
+        $user->PERIOD_AT = $period->getNowPeriodNum();
+        $user->IS_DIRECT_SELLER = 0;
+        $user->VERIFIED = 1;
+        $user->VERIFIED_AT = Date::nowTime();
+
+        if (!$user->save()) {
+            throw new Exception(Form::formatErrorsForApi($user->getErrors()));
+        }
+
+        $this->_insertUserId = $user->ID;
+        $userForm = new BaUserForm();
+        $this->_userForm = $userForm;
+        $userForm->scenario = 'addWithUserName';
+        $userForm->userId = $this->_insertUserId;
+        $userForm->userName = $this->insertUserName;
+        $userForm->zcPv = $this->_decPv;
+        $userForm->zcAmount = $this->_decAmount;
+        $userForm->conUserName = $this->conUserName;
+        $userForm->recUserName = $this->recUserName;
+        $userForm->location = $this->location;
+        $userForm->idCard = $this->mobile;
+        $userForm->allData = $allData;
+        if(!$userForm->validate()){
+            $this->addErrors($userForm->getErrors());
+            return false;
+        }
+        if($result = $userForm->add()){
+            return $result;
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * 添加报单订单
+     * @throws \yii\db\Exception
+     * @throws Exception
+     */
+    public function addDecOrder(){
+        $periodObj = Period::instance();
+        $nowPeriodNum = $periodObj->getNowPeriodNum();
+        $nowCalcMonth = $periodObj->getYearMonth($nowPeriodNum);
+
+        $ord = date('Ymd').substr(implode(NULL, array_map('ord', str_split(substr(uniqid(), 7, 13), 1))), 0, 10);
+        // 加入报单信息
+        $decOrderModel = new BaApproachDecOrder();
+        $decOrderModel->DEC_SN = 'DS' . $ord;
+        $decOrderModel->ORDER_SN = 'OS' . $ord;
+        $decOrderModel->TYPE = $this->type;
+        $decOrderModel->USER_ID = \Yii::$app->user->id;
+        $decOrderModel->TO_USER_ID = $this->_insertUserId;
+        $decOrderModel->DEC_AMOUNT = $this->_decAmount;
+        $decOrderModel->DEC_PV = $this->_decPv;
+        $decOrderModel->PERIOD_NUM = $nowPeriodNum;
+        $decOrderModel->CALC_MONTH = $nowCalcMonth;
+        $decOrderModel->P_CALC_MONTH = Date::ociToDate($nowCalcMonth, Date::OCI_TIME_FORMAT_SHORT_MONTH);
+        $decOrderModel->PAID_WALLET = $this->payType;
+        $decOrderModel->CON_USER_ID = Info::getUserIdByUserName($this->conUserName) ?? '';
+        $decOrderModel->REC_USER_ID = Info::getUserIdByUserName($this->recUserName) ?? '';
+        $decOrderModel->DEC_ID = $this->_decId ?? '';
+        $decOrderModel->IS_DEL = 0;
+        $decOrderModel->CREATED_AT = Date::nowTime();
+        if(!$decOrderModel->save()){
+            throw new Exception(Form::formatErrorsForApi($decOrderModel->getErrors()));
+        }
+
+        // 加入订单信息
+        if ($this->province!=1) {
+            // 仓库
+            $warehouse = Region::getWarehouseByCode($this->province);
+            if (!$warehouse) {
+                // 地区暂时不支持配送,具体联系客服
+                throw new Exception('Delivery is temporarily not supported in the region. Contact customer service for details');
+            }
+        } else {
+            $warehouse = '01';
+        }
+        $exchangeRate = floatval(Cache::getSystemConfig()['exchangeRate']['VALUE'] ?? 0);
+        $orderModel = new BaApproachOrder();
+        $orderModel->SN = 'OS' . $ord;
+        $orderModel->DEC_SN = 'DS' . $ord;
+        $orderModel->ORDER_TYPE = $this->type;
+        $orderModel->USER_ID = $this->_insertUserId;
+        $orderModel->USER_NAME = $this->insertUserName;
+        $orderModel->ORDER_AMOUNT = $this->_decAmount;
+        $orderModel->PV = $this->_decPv;
+        $orderModel->PAY_AMOUNT = $this->_decAmount;
+        $orderModel->PAY_PV = $this->_decPv;
+        $orderModel->PAY_AT = 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 = 0;
+        $orderModel->PAY_FREIGHT = 0;
+        $orderModel->CONSIGNEE = $this->consignee;
+        $orderModel->MOBILE = $this->acceptMobile;
+        $orderModel->EMAIL = $this->email ?: $this->insertUserName . '@elken.net';
+        $orderModel->PROVINCE = $this->province;
+        $orderModel->LGA_NAME = $this->lgaName;
+        $orderModel->CITY_NAME = $this->cityName;
+        $orderModel->ADDRESS = $this->address;
+        $orderModel->WAREHOUSE = $warehouse;
+        $orderModel->STATUS = \Yii::$app->params['orderStatus']['notPaid']['value'];
+        $orderModel->CREATED_AT = Date::nowTime();
+        $orderModel->CREATE_USER = Info::getUserNameByUserId(\Yii::$app->user->id);
+        $orderModel->ORDER_AMOUNT_STANDARD = $this->_decAmountStandard;
+        $orderModel->PAY_AMOUNT_STANDARD = $this->_standardAmount;
+        $orderModel->EXCHANGE_RATE = $exchangeRate;
+        if ($this->province==1) {
+            $orderModel->EXPRESS_TYPE = 1;
+        }
+        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);
+        }
+        BaApproachOrderGoods::batchInsert($this->_orderGoods);
+
+        // 写入收货地址信息,判断province字段,当不为1时,插入收货地址信息
+        $addressModel = new BaReceiveAddress();
+        if ($this->province != 1) {
+            $addressModel->USER_ID = $this->_insertUserId;
+            $addressModel->USER_NAME = $this->insertUserName;
+            $addressModel->CONSIGNEE = $this->consignee;
+            $addressModel->MOBILE = $this->acceptMobile;
+            $addressModel->PROVINCE = $this->province;
+            $addressModel->CITY_NAME = $this->cityName;
+            $addressModel->LGA_NAME = $this->lgaName;
+            $addressModel->ADDRESS = $this->address;
+            $addressModel->IS_DEFAULT = 1;
+            if (!$addressModel->save()) {
+                throw new Exception(Form::formatErrorsForApi($addressModel->getErrors()));
+            }
+        }
+
+        return $orderModel;
+    }
+}

+ 1 - 1
common/models/forms/BaApproachDeclarationLoopForm.php

@@ -112,7 +112,7 @@ class BaApproachDeclarationLoopForm extends Model
         try{
             // 所有的首购单会员ID以备点位绑定使用
             $zcUserIdCard = null;
-            $model = new ApproachDeclarationForm();
+            $model = new BaApproachDeclarationForm();
             $model->scenario = $this->scenario;
             $model->allData = $this->data;
             foreach ($this->data as $value) {

+ 65 - 58
common/models/forms/BaDeclarationForm.php

@@ -335,69 +335,76 @@ class BaDeclarationForm extends Model
      * @param $allData
      * @return bool|UserInfo|null
      * @throws \yii\db\Exception
+     * @throws \Exception
      */
     public function addBaUser($allData){
         $period = Period::instance();
-        // 增加会员
-        $user = new BaUser();
-        $user->USER_NAME = $this->insertUserName;
-        $user->PASSWORD_HASH = \Yii::$app->security->generatePasswordHash($this->password);
-        $user->PAY_PASSWORD = \Yii::$app->security->generatePasswordHash($this->payPassword);
-        $user->NATION = 0;
-        $user->REAL_NAME = $this->realName;
-        $user->ID_CARD = $this->mobile;
-        $user->MOBILE = $this->mobile;
-        $user->EMAIL = $this->email;
-        $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->bankProvince ?? 0;
-//        $user->BANK_CITY = $this->bankCity ?? 0;
-//        $user->BANK_COUNTY = $this->bankCounty ?? 0;
-        $user->CREATED_AT = Date::nowTime();
-        $user->STATUS = 1;
-//        $user->DEC_LV = $this->decLv;
-//        $user->LAST_DEC_LV = $this->decLv;
-//        $user->EMP_LV = EmployLevel::getDefaultLevelId();
-        $user->PROVINCE = $this->province ?? 0;
-        $user->LGA_NAME = $this->lgaName;
-        $user->CITY_NAME = $this->cityName;
-        $user->AVATAR = 'avatar/1.png';
-        $user->IS_DEC = 0;
-        $user->DEC_ID = $this->_decId ?? null;
-        $user->DEC_ROLE_ID = $this->decRoleId ?? null;
-        $user->PERIOD_AT = $period->getNowPeriodNum();
-        $user->IS_DIRECT_SELLER = 0;
-        $user->VERIFIED = 1;
-        $user->VERIFIED_AT = Date::nowTime();
 
-        if (!$user->save()) {
-            throw new Exception(Form::formatErrorsForApi($user->getErrors()));
-        }
+        try {
+            // 增加会员
+            $user = new BaUser();
+            $user->USER_NAME = $this->insertUserName;
+            $user->PASSWORD_HASH = \Yii::$app->security->generatePasswordHash($this->password);
+            $user->PAY_PASSWORD = \Yii::$app->security->generatePasswordHash($this->payPassword);
+            $user->NATION = 0;
+            $user->REAL_NAME = $this->realName;
+            $user->ID_CARD = $this->mobile;
+            $user->MOBILE = $this->mobile;
+            $user->EMAIL = $this->email;
+            $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->bankProvince ?? 0;
+            //        $user->BANK_CITY = $this->bankCity ?? 0;
+            //        $user->BANK_COUNTY = $this->bankCounty ?? 0;
+            $user->CREATED_AT = Date::nowTime();
+            $user->STATUS = 1;
+            //        $user->DEC_LV = $this->decLv;
+            //        $user->LAST_DEC_LV = $this->decLv;
+            //        $user->EMP_LV = EmployLevel::getDefaultLevelId();
+            $user->PROVINCE = $this->province ?? 0;
+            $user->LGA_NAME = $this->lgaName;
+            $user->CITY_NAME = $this->cityName;
+            $user->AVATAR = 'avatar/1.png';
+            $user->IS_DEC = 0;
+            $user->DEC_ID = $this->_decId ?? '';
+            $user->DEC_ROLE_ID = $this->decRoleId ?? '';
+            $user->PERIOD_AT = $period->getNowPeriodNum();
+            $user->IS_DIRECT_SELLER = 0;
+            $user->VERIFIED = 1;
+            $user->VERIFIED_AT = Date::nowTime();
 
-        $this->_insertUserId = $user->ID;
-        $userForm = new BaUserForm();
-        $this->_userForm = $userForm;
-        $userForm->scenario = 'addWithUserName';
-        $userForm->userId = $this->_insertUserId;
-        $userForm->userName = $this->insertUserName;
-//        $userForm->zcPv = $this->_decPv;
-        $userForm->zcAmount = $this->_decAmount;
-//        $userForm->conUserName = $this->conUserName;
-        $userForm->recUserName = $this->recUserName;
-//        $userForm->location = $this->location;
-        $userForm->idCard = $this->mobile;
-        $userForm->allData = $allData;
-//        print_r($userForm);exit;
-        if(!$userForm->validate()){
-            $this->addErrors($userForm->getErrors());
-            return false;
-        }
-        if($result = $userForm->add()){
-            return $result;
-        } else {
-            return false;
+            if (!$user->save()) {
+                throw new Exception(Form::formatErrorsForApi($user->getErrors()));
+            }
+
+            $this->_insertUserId = $user->ID;
+            $userForm = new BaUserForm();
+            $this->_userForm = $userForm;
+            $userForm->scenario = 'addWithUserName';
+            $userForm->userId = $this->_insertUserId;
+            $userForm->userName = $this->insertUserName;
+            //        $userForm->zcPv = $this->_decPv;
+            $userForm->zcAmount = $this->_decAmount;
+            //        $userForm->conUserName = $this->conUserName;
+            $userForm->recUserName = $this->recUserName;
+            //        $userForm->location = $this->location;
+            $userForm->idCard = $this->mobile;
+            $userForm->allData = $allData;
+            //        print_r($userForm);exit;
+            if (!$userForm->validate()) {
+                $this->addErrors($userForm->getErrors());
+                return false;
+            }
+            if ($result = $userForm->add()) {
+                return $result;
+            } else {
+                return false;
+            }
+        } catch (\Exception $e) {
+            LoggerTool::info($e->getMessage());
+            throw new \Exception($e->getMessage());
         }
     }
 

+ 5 - 327
common/models/forms/BaUserForm.php

@@ -96,7 +96,7 @@ class BaUserForm extends Model
 //            [['conUid'], 'exist', 'targetClass'=>UserInfo::class, 'targetAttribute'=>'USER_ID', 'on' => ['addWithUserName', 'addWithUid', 'addByAdmin']],
             [['recUid'], 'exist', 'targetClass'=>UserInfo::class, 'targetAttribute'=>'USER_ID', 'on' => ['addWithUserName', 'addWithUid', 'addByAdmin']],
 //            [['conUid'], 'isConUid', 'on' => ['addWithUserName', 'addWithUid', 'addByAdmin']],
-            [['recUid'], 'isRecUid', 'on' => ['addWithUserName', 'addWithUid', 'addByAdmin']],
+//            [['recUid'], 'isRecUid', 'on' => ['addWithUserName', 'addWithUid', 'addByAdmin']],
 //            [['conUserName'], 'exist', 'targetClass'=>UserInfo::class, 'targetAttribute'=>'USER_NAME', 'on' => ['addWithUserName', 'addWithUid', 'addByAdmin']],
             [['recUserName'], 'exist', 'targetClass'=>UserInfo::class, 'targetAttribute'=>'USER_NAME', 'on' => ['addWithUserName', 'addWithUid', 'addByAdmin']],
 //            [['conUserName'], 'isCon', 'on' => ['addWithUserName', 'addWithUid', 'addByAdmin']],
@@ -130,57 +130,6 @@ class BaUserForm extends Model
         ];
     }
 
-    /**
-     * 接点人是否可以放置
-     * @param $attribute
-     * @param $params
-     */
-    public function isConUid($attribute, $params){
-        $this->_conUid = $this->conUid;
-        // 查看该接点人在安置网络中的推荐人数量是否达到上限
-        $childNum = UserNetwork::firstFloorChildNum($this->_conUid);
-        if($childNum >= 3){
-            $this->addError($attribute, '注册'.$this->userName.'时,接点人'.$this->conUserName.'点位已满无法继续添加');
-        }
-    }
-
-    /**
-     * 推荐人是否可用
-     * @param $attribute
-     * @param $params
-     */
-    public function isRecUid($attribute, $params){
-        $this->_recUid = $this->recUid;
-        // 查看该开拓者推荐的第一层人的数量
-//        $childNum = UserRelation::firstFloorChildNum($this->_recUid);
-//        if($childNum === 0){
-//            // 必须放在自己的左区
-//            if($this->location != 1){
-//                $this->addError($attribute, '开拓的第一人必须放在自己的一市场');
-//            }
-//        }
-    }
-
-    /**
-     * 接点人是否可以放置
-     * @param $attribute
-     * @param $params
-     */
-    public function isCon($attribute, $params){
-        // 根据账号找到接点人
-        $oneConUserInfo = BaUserInfo::findOneAsArray('USER_NAME=:USER_NAME', [':USER_NAME'=>$this->conUserName]);
-        if($oneConUserInfo){
-            $this->_conUid = $oneConUserInfo['USER_ID'];
-            // 查看该接点人在安置网络中的推荐人数量是否达到上限
-            $childNum = UserNetwork::firstFloorChildNum($this->_conUid);
-            if($childNum >= 3){
-                $this->addError($attribute, $this->userName.'的接点人'.$this->conUserName.'点位已满无法继续添加');
-            }
-        } else {
-            $this->addError($attribute, '注册'.$this->userName.'时,接点人'.$this->conUserName.'帐号无效');
-        }
-    }
-
     /**
      * 推荐人是否可用
      * @param $attribute
@@ -196,79 +145,6 @@ class BaUserForm extends Model
         }
     }
 
-    /**
-     * 区位是否可用
-     * @param $attribute
-     * @param $params
-     */
-    public function isLocation($attribute, $params){
-        // 查看该接点人下面所有的子会员
-        $allChildUser = UserNetwork::getFirstFloorChildren($this->_conUid);
-        if($allChildUser){
-            $isLocation = [1=>false, 2=>false, 3=>false];
-            foreach($allChildUser as $child){
-                $isLocation[$child['RELATIVE_LOCATION']] = true;
-                if($child['RELATIVE_LOCATION'] == $this->location){
-                    $this->addError($attribute, '注册'.$this->userName.'时,'.$this->conUserName.'的区位【'.$this->location.'】已经存在会员');
-                }
-            }
-            // 第二区不能空点,必须要有会员才能注册到第三区
-//            if($this->location == 3 && $isLocation[2] === false){
-//                $this->addError($attribute, '注册'.$this->userName.'到'.$this->conUserName.'的第三区时,'.$this->conUserName.'的第二区不能空点');
-//            }
-        } else {
-//            if($this->location != 1 && $this->scenario != 'addByAdmin'){
-//                $this->addError($attribute, '注册'.$this->userName.'时,接点人'.$this->conUserName.'下的第一个区位必须选择左区');
-//            }
-        }
-    }
-
-    /**
-     * 校验注册PV必须要大于最低级别要求
-     * @param $attribute
-     * @param $params
-     */
-    public function isMinDecLevel($attribute, $params){
-        // 获取排序为2的报单级别
-        $decLevel = DeclarationLevel::getLevelFromSort(2);
-        if($this->zcPv < $decLevel['PERF']){
-            $this->addError($attribute, '注册'.$this->userName.'时,注册PV低于最低级别要求,不能报首购单');
-        }
-    }
-
-    /**
-     * 同一身份证号是否在相同网络
-     * @param $attribute
-     */
-    public function isSameNetwork($attribute){
-        // 新加入会员的身份证号对应网内的其他会员
-        $otherUser = User::find()->where("ID_CARD=:ID_CARD AND ID<>:ID AND IS_UNION=0 AND DELETED=0 AND (ID_CARD_PREFIX IS NULL OR ID_CARD_PREFIX='')", [':ID_CARD'=>$this->idCard, ':ID'=>$this->userId])->select('ID')->asArray()->all();
-        // 拿到所有的批量报单数据
-        foreach($this->allData as $decData){
-            if($decData['insertUserIdCard'] == $this->idCard){
-                $otherUser[] = ['ID'=>$decData['toUserId']];
-            }
-        }
-        // 从多轨网络里面找到这些会员的最顶层会员
-        if($otherUser){
-            $otherUserIds = [];
-            foreach($otherUser as $userId){
-                $otherUserIds[] = $userId['ID'];
-            }
-            $otherUserIdsStr = implode("','", $otherUserIds);
-            $otherUserIdsStr = "'".$otherUserIdsStr."'";
-            $sameIdCardOtherTopUser = UserInfo::find()->where('USER_ID IN ('.$otherUserIdsStr.')')->orderBy('NETWORK_DEEP ASC')->asArray()->one();
-            if($sameIdCardOtherTopUser){
-                // 通过这个顶层会员查看新报单会员的接点人是不是他的下级
-                if(!UserNetwork::find()->where('PARENT_UID=:PARENT_UID AND USER_ID=:USER_ID', [':PARENT_UID'=>$sameIdCardOtherTopUser['USER_ID'], ':USER_ID'=>$this->_conUid])->exists()){
-                    // 如果不存在的话,就看这个接点人是不是这个顶层的会员
-                    if($this->_conUid != $sameIdCardOtherTopUser['USER_ID']){
-                        $this->addError($attribute, '注册'.$this->userName.'时,同一身份证号会员必须在同一网体内');
-                    }
-                }
-            }
-        }
-    }
 
     /**
      * 添加会员
@@ -284,8 +160,6 @@ class BaUserForm extends Model
 //        $zcPv = $this->zcPv;
 //        $conUid = $this->_conUid;
         $recUid = $this->_recUid;
-//        print_r('recUid:');
-//        print_r($recUid);
 //        $location = $this->location;
 
 //        $db = \Yii::$app->db;
@@ -301,8 +175,8 @@ class BaUserForm extends Model
             $userInfoModel->USER_NAME = $insertUserName;
 //            $userInfoModel->ZC_PV = $zcPv;
             $userInfoModel->ZC_AMOUNT = $this->zcAmount;
-//            $userInfoModel->CON_UID = $conUid;
-            $userInfoModel->REC_UID = $recUid;
+            $userInfoModel->CON_UID = '';
+            $userInfoModel->REC_UID = '';
 //            $userInfoModel->SYSTEM_ID = $conUserInfo['SYSTEM_ID'];
             //$userInfoModel->PERIOD_NUM = $nowPeriodNum;
             $userInfoModel->CREATED_AT = Date::nowTime();
@@ -315,11 +189,8 @@ class BaUserForm extends Model
 
             try {
                 $q = $userInfoModel->save();
-                print_r($q);
             }catch (Exception $e) {
-                print_r($e);
-                print_r('cccc');
-                throw new Exception('会员信更新失了败');
+                throw new Exception($e->getMessage());
             }
 //            print_r($userInfoModel);exit;
 //            if(!$userInfoModel->save()){
@@ -336,206 +207,13 @@ class BaUserForm extends Model
 //            $transaction->commit();
             return $userInfoModel;
         } catch (Exception $e){
-//            print_r($e);exit;
-            throw new Exception('a a a a a');
+            throw new Exception($e->getMessage());
 //            $transaction->rollBack();
             $this->addError('userId', $e->getMessage());
-            //echo $e->getMessage().PHP_EOL;
             return null;
         }
     }
 
-    /**
-     * 添加会员
-     * @param $nowPeriodNum
-     * @return boolean
-     */
-    public function addForImport($nowPeriodNum){
-        $insertUid = $this->userId;
-        $insertUserName = $this->userName;
-        $zcPv = $this->zcPv;
-        $conUid = $this->conUid;
-        $recUid = $this->recUid;
-        try{
-            // 查找接点人的体系信息
-            // 加入会员信息
-            $insertData = [
-                'USER_ID' => $insertUid,
-                'USER_NAME' => $insertUserName,
-                'ZC_PV' => $zcPv,
-                'ZC_AMOUNT' => $this->zcAmount,
-                'CON_UID' => $conUid,
-                'REC_UID' => $recUid,
-                'SYSTEM_ID' => "",
-                'CREATED_AT' => time(),
-                'HIGHEST_EMP_LV' => "",
-                'HIGHEST_EMP_LV_PERIOD' => $nowPeriodNum,
-                'TRANSFER_PROP' => 100.00,
-                'IS_GROUP_LEADER' => 0,
-                'GROUP_LEADER_AT' => 0,
-            ];
-            UserInfo::insertOne($insertData);
-            unset($insertData);
-            // 安置关系
-            $this->_addToNetworkForImport();
-            // 开拓关系
-            //$this->_addToRelationForImport();
-            // 把会员的网络深度也追加上
-            UserInfo::updateAll([
-                "NETWORK_DEEP" => $this->_conTopDeep,
-                //"RELATION_DEEP" => $this->_recTopDeep,
-            ], "USER_ID='{$insertUid}'");
-            // 清空安置网络和开拓网络的顶点和顶点深度的数值
-            $this->_conTopUid = null;
-            $this->_conTopDeep = null;
-            $this->_recTopUid = null;
-            $this->_recTopDeep = null;
-
-            unset($insertUid, $insertUserName, $conUid, $recUid);
-            return true;
-        } catch (Exception $e){
-            $this->addError('userId', $e->getMessage());
-            return false;
-        }
-    }
-
-    /**
-     * 加入安置网络
-     * @throws Exception
-     */
-    private function _addToNetworkForImport(){
-        //获取上级的点位信息
-        $conNetInfo = UserNetwork::findOneAsArray(['USER_ID'=>$this->conUid]);
-        if( !$conNetInfo ) {
-            throw new Exception('接点人信息不存在');
-        }
-        $this->_conTopUid = $conNetInfo['TOP_UID'];
-        $this->_conTopDeep = $conNetInfo['TOP_DEEP'] + 1;
-        // 加入安置网络关系
-        $insertData = [
-            'ID' => SnowFake::instance()->generateId(),
-            "USER_ID"  => $this->userId,
-            "PARENT_UID"  => $this->conUid,
-            "LOCATION_TAG"  => $conNetInfo['LOCATION_TAG'] . $this->location,
-            "RELATIVE_LOCATION"  => $this->location,
-            "TOP_UID"  => $conNetInfo['TOP_UID'],
-            "TOP_DEEP"  => $conNetInfo['TOP_DEEP'] + 1,
-            "PARENT_UIDS"  => $conNetInfo['PARENT_UIDS'] . ',' . $this->conUid,
-            "CREATED_AT"  => time(),
-        ];
-        UserNetwork::insertOne($insertData);
-
-        if(!UserInfo::updateAllCounters(['CON_NUM'=>1], "USER_ID=:USER_ID", [':USER_ID'=>$this->conUid])){
-            throw new Exception('会员安置关系下级节点数量更新失败');
-        }
-    }
-
-    /**
-     * 加入安置网络
-     * @throws Exception
-     */
-    private function _addToNetwork(){
-        //获取上级的点位信息
-        $conNetInfo = UserNetwork::findOneAsArray(['USER_ID'=>$this->_conUid]);
-        if( !$conNetInfo ) {
-            throw new Exception('接点人信息不存在');
-        }
-        $this->_conTopUid = $conNetInfo['TOP_UID'];
-        $this->_conTopDeep = $conNetInfo['TOP_DEEP'] + 1;
-        // 加入安置网络关系
-        if( $conNetInfo['PARENT_UIDS'] ) {
-            $parentUids = $conNetInfo['PARENT_UIDS'] . ',' . $this->_conUid;
-        }else {
-            $parentUids = $this->_conUid;
-        }
-        $insertData = [
-            'ID' => SnowFake::instance()->generateId(),
-            "USER_ID"  => $this->userId,
-            "PARENT_UID"  => $this->_conUid,
-            "LOCATION_TAG"  => $conNetInfo['LOCATION_TAG'] . $this->location,
-            "RELATIVE_LOCATION"  => $this->location,
-            "TOP_UID"  => $conNetInfo['TOP_UID'],
-            "TOP_DEEP"  => $conNetInfo['TOP_DEEP'] + 1,
-            "PARENT_UIDS"  => $parentUids,
-            "CREATED_AT"  => time(),
-        ];
-        UserNetwork::insertOne($insertData);
-
-        if(!UserInfo::updateAllCounters(['CON_NUM'=>1], "USER_ID=:USER_ID", [':USER_ID'=>$this->_conUid])){
-            throw new Exception('会员安置关系下级节点数量更新失败');
-        }
-    }
-
-    /**
-     * 加入开拓网络
-     * @throws Exception
-     */
-    private function _addToRelationForImport(){
-        //获取上级的推荐信息
-        $conRelationInfo = UserRelation::findOneAsArray(['USER_ID'=>$this->recUid]);
-        if( !$conRelationInfo ) {
-            throw new Exception('推荐人信息不存在');
-        }
-        $this->_recTopUid = $conRelationInfo['TOP_UID'];
-        $this->_recTopDeep = $conRelationInfo['TOP_DEEP'] + 1;
-        // 加入推荐网络关系
-        $insertData = [
-            'ID' => SnowFake::instance()->generateId(),
-            "USER_ID"  => $this->userId,
-            "PARENT_UID"  => $this->recUid,
-            "TOP_UID"  => $conRelationInfo['TOP_UID'],
-            "TOP_DEEP"  => $conRelationInfo['TOP_DEEP'] + 1,
-            "PARENT_UIDS"  => $conRelationInfo['PARENT_UIDS'] . ',' . $this->recUid,
-            "CREATED_AT"  => time(),
-        ];
-        UserRelation::insertOne($insertData);
-
-        if(!UserInfo::updateAllCounters(['REC_NUM'=>1], "USER_ID=:USER_ID", [':USER_ID'=>$this->recUid])){
-            throw new Exception('会员开拓关系下级节点数量更新失败');
-        }
-    }
-
-    /**
-     * 加入开拓网络
-     * @throws Exception
-     */
-    private function _addToRelation(){
-        //获取上级的推荐信息
-        $conRelationInfo = UserRelation::findOneAsArray(['USER_ID'=>$this->_recUid]);
-        if( !$conRelationInfo ) {
-            throw new Exception('推荐人信息不存在');
-        }
-        $this->_recTopUid = $conRelationInfo['TOP_UID'];
-        $this->_recTopDeep = $conRelationInfo['TOP_DEEP'] + 1;
-        if( $conRelationInfo['PARENT_UIDS'] ) {
-            $parentUids = $conRelationInfo['PARENT_UIDS'] . ',' . $this->_recUid;
-        }else {
-            $parentUids = $this->_recUid;
-        }
-        // 加入推荐网络关系
-        $insertData = [
-            'ID' => SnowFake::instance()->generateId(),
-            "USER_ID"  => $this->userId,
-            "PARENT_UID"  => $this->_recUid,
-            "TOP_UID"  => $conRelationInfo['TOP_UID'],
-            "TOP_DEEP"  => $conRelationInfo['TOP_DEEP'] + 1,
-            "PARENT_UIDS"  => $parentUids,
-            "CREATED_AT"  => time(),
-        ];
-        UserRelation::insertOne($insertData);
-
-        if(!UserInfo::updateAllCounters(['REC_NUM'=>1], "USER_ID=:USER_ID", [':USER_ID'=>$this->_recUid])){
-            throw new Exception('会员开拓关系下级节点数量更新失败');
-        }
-    }
-
-
-
-
-
-
-
-
     /**
      * 修改个人资料
      * @return User|null

+ 5 - 5
frontendEle/src/views/shop/ba-dec-order-list.vue

@@ -18,11 +18,11 @@
         <el-table-column width="120" label="Sponsor code" prop="CON_USER_NAME"></el-table-column><!--接点人编号-->
         <el-table-column width="120" label="Status" prop="STATUS"></el-table-column><!--状态-->
         <el-table-column width="150" label="Created time" prop="CREATED_AT"></el-table-column >
-        <el-table-column width="120" label="Action"><!--操作-->
-          <template slot-scope="scope">
-            <el-button type="primary" size="small" @click.native="handleOrderExportPDF(scope.row.ORDER_SN)">Export PDF</el-button><!--导出PDF-->
-          </template>
-        </el-table-column>
+<!--        <el-table-column width="120" label="Action">&lt;!&ndash;操作&ndash;&gt;-->
+<!--          <template slot-scope="scope">-->
+<!--            <el-button type="primary" size="small" @click.native="handleOrderExportPDF(scope.row.ORDER_SN)">Export PDF</el-button>&lt;!&ndash;导出PDF&ndash;&gt;-->
+<!--          </template>-->
+<!--        </el-table-column>-->
       </el-table>
       <div class="white-box-footer">
           <pagination :total="totalCount" :page_size="pageSize" @size-change="handleSizeChange" @current-change="handleCurrentChange"></pagination>

+ 7 - 2
frontendEle/src/views/user/ba-dec.vue

@@ -379,7 +379,12 @@ export default {
               display_name: 'orderSn',
               variable_name: 'orderSn',
               value: this.sn
-            }
+            },
+            {
+              display_name: 'isBrandAmbassador',
+              variable_name: 'isBrandAmbassador',
+              value: true,
+            },
           ]
         }
       }
@@ -530,7 +535,7 @@ export default {
           _this.visible = true
         }
       }).catch(response => {
-        _this.submitButtonStat = true
+        _this.submitButtonStat = false
         _this.$message({
           message: response,
           type: 'error'