Просмотр исходного кода

BA管理端增加会员列表,订单列表,会员端增加报单、升级等

theo 3 лет назад
Родитель
Сommit
14384b72da
29 измененных файлов с 4112 добавлено и 1438 удалено
  1. 3 13
      backendApi/config/menu.php
  2. 2 9
      backendApi/config/urlManagerRules.php
  3. 133 0
      backendApi/modules/v1/controllers/ShopController.php
  4. 0 399
      backendApi/modules/v1/models/lists/ba/OrderList.php
  5. 0 371
      backendApi/modules/v1/models/lists/ba/UserList.php
  6. 7 14
      backendEle/src/router/index.js
  7. 3 3
      backendEle/src/utils/config_trial.js
  8. 0 253
      backendEle/src/views/ba/order-list.vue
  9. 207 0
      backendEle/src/views/shop/ba-dec-order-list.vue
  10. 690 0
      backendEle/src/views/shop/ba-user-list.vue
  11. 12 0
      common/helpers/user/Info.php
  12. 92 0
      common/models/BaDecOrder.php
  13. 1 1
      common/models/BaUserInfo.php
  14. 218 0
      common/models/forms/BaApproachDeclarationLoopForm.php
  15. 482 0
      common/models/forms/BaDeclarationForm.php
  16. 220 0
      common/models/forms/BaDeclarationLoopForm.php
  17. 34 35
      common/models/forms/BaUserForm.php
  18. 1 1
      common/models/forms/DeclarationForm.php
  19. 2 0
      frontendApi/config/menu.php
  20. 3 0
      frontendApi/config/urlManagerRules.php
  21. 577 0
      frontendApi/modules/v1/controllers/BaController.php
  22. 63 0
      frontendApi/modules/v1/controllers/ShopController.php
  23. 2 0
      frontendApi/modules/v1/controllers/SiteController.php
  24. 126 7
      frontendApi/modules/v1/controllers/UserController.php
  25. 335 327
      frontendEle/src/router/index.js
  26. 2 2
      frontendEle/src/utils/config_trial.js
  27. 160 0
      frontendEle/src/views/shop/ba-dec-order-list.vue
  28. 700 0
      frontendEle/src/views/user/ba-dec.vue
  29. 37 3
      frontendEle/src/views/user/dec.vue

+ 3 - 13
backendApi/config/menu.php

@@ -55,22 +55,12 @@ return [
             ['name'=>'External mall order list', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'order-shop-list', 'routePath'=>'shop/order-shop-list', 'show'=>1,], // 外部商城订单列表
             ['name'=>'External mall entry list', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'order-dec-list', 'routePath'=>'shop/order-dec-list', 'show'=>1,], // 外部商城报单列表
             // ['name'=>'List of qualified orders of external mall', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'order-standard-list', 'routePath'=>'shop/order-standard-list', 'show'=>1,], // 外部商城达标订单列表
+            ['name'=>'Brand Ambassador List', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'ba-user-list', 'routePath'=>'shop/ba-user-list', 'show'=>1,], // 会员列表
+            ['name'=>'Brand Ambassador Order', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'ba-order-list', 'routePath'=>'shop/ba-order-list', 'show'=>1,], // 会员列表
+//            ['name'=>'Brand Ambassador Dec List', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'ba-dec-order-list', 'routePath'=>'shop/ba-dec-order-list', 'show'=>1,], // 会员列表
 
         ]
     ],
-    'ba' =>[
-        'name'=>'Brand Ambassador', // BA会员管理
-        'class' => '',
-        'icon'=>'el-icon-user',
-        'controller'=>'ba',
-        'action'=>'',
-        'routePath'=>'ba',
-        'show'=>1,
-        'child'=>[
-            ['name'=>'Brand Ambassador List', 'class'=>'', 'icon'=>'', 'controller'=>'ba', 'action'=>'user-list', 'routePath'=>'ba/user-list', 'show'=>1,], // 会员列表
-            ['name'=>'Brand Ambassador Order', 'class'=>'', 'icon'=>'', 'controller'=>'ba', 'action'=>'order-list', 'routePath'=>'ba/order-list', 'show'=>1,], // 会员列表
-        ]
-    ],
     'user'=>[
         'name'=>'Member management', // 会员管理
         'class' => '',

+ 2 - 9
backendApi/config/urlManagerRules.php

@@ -68,15 +68,8 @@ return [
             'GET dec-order-list-export-pdf/<orderSn>' => 'dec-order-list-export-pdf',
             'GET remain-pv' => 'remain-pv',
             'GET flow-remain-pv' => 'flow-remain-pv',
-        ],
-    ],
-    [
-        'class' => 'yii\rest\UrlRule',
-        'pluralize' => false,
-        'controller' => 'v1/ba',
-        'extraPatterns' => [
-            'GET user-list' => 'user-list',
-            'GET order-list' => 'order-list',
+            'GET ba-user-list' => 'ba-user-list',
+            'GET ba-order-list' => 'ba-order-list',
         ],
     ],
     [

+ 133 - 0
backendApi/modules/v1/controllers/ShopController.php

@@ -14,6 +14,8 @@ use backendApi\modules\v1\models\lists\shop\DecOrderList;
 use backendApi\modules\v1\models\lists\shop\GoodsList;
 use backendApi\modules\v1\models\lists\shop\OrderDecList;
 use backendApi\modules\v1\models\lists\shop\OrderList;
+use backendApi\modules\v1\models\lists\shop\BaOrderList;
+use backendApi\modules\v1\models\lists\shop\BaUserList;
 use backendApi\modules\v1\models\lists\shop\OrderShopList;
 use backendApi\modules\v1\models\lists\shop\OrderStandardList;
 use backendApi\modules\v1\models\lists\shop\PackageList;
@@ -769,4 +771,135 @@ class ShopController extends BaseController {
         $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
         return static::notice($data);
     }
+
+    /**
+     * BA订单表
+     * @return mixed
+     * @throws Exception
+     * @throws \yii\web\HttpException
+     */
+    public function actionBaOrderList() {
+        $filter = $this->filterCondition([
+            'SN'=> 'O.SN',
+            'USER_NAME'=> 'U.USER_NAME',
+            'MOBILE'=> 'O.MOBILE',
+            'PERIOD_NUM'=> 'O.PERIOD_NUM',
+            'CREATED_AT'=> 'O.CREATED_AT',
+            'ORDER_TYPE'=> 'O.ORDER_TYPE',
+            'STATUS' => 'O.STATUS',
+            'IS_AUTO' => 'O.IS_AUTO'
+        ]);
+        $condition = ' 1=1 ' . $filter['condition'];
+        $params = $filter['params'];
+        $condition .= $condition ? ' AND O.IS_DELETE=0' : ' O.IS_DELETE=0';
+        $listObj = new BaOrderList();
+        $data = $listObj->getList(['condition'=>$condition, 'params'=>$params]);
+        return static::notice($data);
+    }
+
+    /**
+     * BA会员列表
+     * @return mixed
+     * @throws Exception
+     * @throws \yii\web\HttpException
+     */
+    public function actionBaUserList() {
+        $filter = $this->filterCondition([
+            'USER_NAME' => 'U.USER_NAME',
+            'REAL_NAME' => 'U.REAL_NAME',
+            'STATUS' => 'U.STATUS',
+            'ALLOW_LOGIN' => 'U.ALLOW_LOGIN',
+            'CREATED_AT' => 'U.CREATED_AT',
+            'PERIOD_AT' => 'U.PERIOD_AT',
+//            'DEC_LV_NAME' => 'U.DEC_LV',
+//            'DEC_LV_UPDATED_AT' => 'U.DEC_LV_UPDATED_AT',
+//            'LAST_DEC_LV_NAME' => 'U.LAST_DEC_LV',
+//            'EMP_LV_NAME' => 'U.EMP_LV',
+            'REC_USER_NAME' => 'RU.USER_NAME',
+            'CON_USER_NAME' => 'CU.USER_NAME',
+            'ID_CARD' => 'U.ID_CARD',
+            'SPOUSE_NAME' => 'U.SPOUSE_NAME',
+//            'SPOUSE_IDCARD' => 'U.SPOUSE_IDCARD',
+            'SYSTEM_NAME' => 'U.SYSTEM_ID',
+            'MOBILE' => 'U.MOBILE',
+            'TEL' => 'U.TEL',
+            'DEC_USER_NAME' => 'DU.USER_NAME',
+//            'IS_DEC' => 'U.IS_DEC',
+//            'IS_STUDIO' => 'U.IS_STUDIO',
+//            'DEC_ROLE_NAME' => 'U.DEC_ROLE_ID',
+            'OPEN_BANK_NAME' => 'U.OPEN_BANK',
+            'BANK_AREA' => [
+                'FIELD' => ['U.BANK_PROVINCE', 'U.BANK_CITY', 'U.BANK_COUNTY'],
+                'BIND' => ['BANK_PROVINCE', 'BANK_CITY', 'BANK_COUNTY'],
+            ],
+            'BANK_ADDRESS' => 'U.BANK_ADDRESS',
+            'BANK_NO' => 'U.BANK_NO',
+            'SEX' => 'U.SEX',
+            'NATION_NAME' => 'U.NATION',
+            'AREA' => [
+                'FIELD' => ['U.PROVINCE', 'U.CITY', 'U.COUNTY'],
+                'BIND' => ['PROVINCE', 'CITY', 'COUNTY'],
+            ],
+            'ADDRESS' => 'U.ADDRESS',
+            'VERIFIED' => 'U.VERIFIED',
+            'VERIFIED_AT' => 'U.VERIFIED_AT',
+            'ALLOW_TRANSFER' => 'UI.ALLOW_TRANSFER',
+        ]);
+        $condition = $filter['condition'];
+        $params = $filter['params'];
+        $condition .= ' AND UI.DELETED=0 ';
+        $listObj = new BaUserList();
+        $data = $listObj->getList(['condition' => $condition, 'params' => $params]);
+        return static::notice($data);
+    }
+
+    public function actionBaUserListExport() {
+        $filter = $this->filterCondition([
+            'USER_NAME' => 'U.USER_NAME',
+            'REAL_NAME' => 'U.REAL_NAME',
+            'STATUS' => 'U.STATUS',
+            'ALLOW_LOGIN' => 'U.ALLOW_LOGIN',
+            'CREATED_AT' => 'U.CREATED_AT',
+            'PERIOD_AT' => 'U.PERIOD_AT',
+            'DEC_LV_NAME' => 'U.DEC_LV',
+            'DEC_LV_UPDATED_AT' => 'U.DEC_LV_UPDATED_AT',
+            'LAST_DEC_LV_NAME' => 'U.LAST_DEC_LV',
+            'EMP_LV_NAME' => 'U.EMP_LV',
+            'REC_USER_NAME' => 'RU.USER_NAME',
+            'CON_USER_NAME' => 'CU.USER_NAME',
+            'ID_CARD' => 'U.ID_CARD',
+            'SPOUSE_NAME' => 'U.SPOUSE_NAME',
+            'SPOUSE_IDCARD' => 'U.SPOUSE_IDCARD',
+            'SYSTEM_NAME' => 'U.SYSTEM_ID',
+            'MOBILE' => 'U.MOBILE',
+            'TEL' => 'U.TEL',
+            'DEC_USER_NAME' => 'DU.USER_NAME',
+            'IS_DEC' => 'U.IS_DEC',
+            'IS_STUDIO' => 'U.IS_STUDIO',
+            'DEC_ROLE_NAME' => 'U.DEC_ROLE_ID',
+            'OPEN_BANK_NAME' => 'U.OPEN_BANK',
+            'BANK_AREA' => [
+                'FIELD' => ['U.BANK_PROVINCE', 'U.BANK_CITY', 'U.BANK_COUNTY'],
+                'BIND' => ['BANK_PROVINCE', 'BANK_CITY', 'BANK_COUNTY'],
+            ],
+            'BANK_ADDRESS' => 'U.BANK_ADDRESS',
+            'BANK_NO' => 'U.BANK_NO',
+            'SEX' => 'U.SEX',
+            'NATION_NAME' => 'U.NATION',
+            'AREA' => [
+                'FIELD' => ['U.PROVINCE', 'U.CITY', 'U.COUNTY'],
+                'BIND' => ['PROVINCE', 'CITY', 'COUNTY'],
+            ],
+            'ADDRESS' => 'U.ADDRESS',
+            'VERIFIED' => 'U.VERIFIED',
+            'VERIFIED_AT' => 'U.VERIFIED_AT',
+            'ALLOW_TRANSFER' => 'UI.ALLOW_TRANSFER',
+        ]);
+        $form = new BaUserExportForm();
+        $result = $form->run($filter, 'Member_List');
+        if (!$result) {
+            return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
+        }
+        return static::notice('Starting exporting, please go to File Management - Export Files to view.'); // 导出开始,请到文件管理-导出文件查看
+    }
 }

+ 0 - 399
backendApi/modules/v1/models/lists/ba/OrderList.php

@@ -1,399 +0,0 @@
-<?php
-namespace backendApi\modules\v1\models\lists\ba;
-
-use common\helpers\Cache;
-use common\helpers\Tool;
-use common\helpers\user\Info;
-use common\libs\dataList\DataListInterface;
-
-use common\models\BaApproachOrder;
-use common\models\BaApproachOrderGoods;
-use common\models\BaOrder;
-use common\models\BaOrderGoods;
-
-use common\models\ShopGoods;
-use common\models\BaUser;
-use common\libs\dataList\column\DateTime;
-use yii\data\Pagination;
-use yii\db\Query;
-
-class OrderList extends \common\libs\dataList\DataList implements DataListInterface
-{
-    /**
-     * 列表名称
-     * @return string
-     */
-    public function getListName(){
-        return 'BA订单列表';
-    }
-
-    /**
-     * 列表筛选到的数据
-     */
-    public function dataHandle()
-    {
-        $orderQuery = BaOrder::find()
-            ->alias('O')
-            ->where($this->condition, $this->params)
-            ->select('O.*,U.REAL_NAME,U.DEC_ID,SG.CATEGORY_TYPE,OG.REAL_PRICE,OG.TAX_RATE,OG.BUY_NUMS,OG.SKU_CODE,OG.GOODS_TITLE,OG.REAL_PV')
-            ->join('LEFT JOIN', BaUser::tableName() . ' AS U', 'U.ID=O.USER_ID')
-            ->join('LEFT JOIN', BaOrderGoods::tableName() . ' AS OG', 'OG.ORDER_SN=O.SN')
-            ->join('LEFT JOIN', ShopGoods::tableName() . ' AS SG', 'SG.ID=OG.GOODS_ID')
-            ->orderBy('O.CREATED_AT DESC');
-
-        // 订单中间表只查询待支付和支付失败的订单
-        $this->params[':NOT_PAID'] = \Yii::$app->params['orderStatus']['notPaid']['value'];   // 待支付
-        $this->params[':FAIL_PAID'] = \Yii::$app->params['orderStatus']['failPaid']['value'];   // 支付失败
-        $orderStandardQuery = BaApproachOrder::find()
-            ->alias('O')
-            ->where($this->condition . ' AND (O.STATUS = :NOT_PAID OR O.STATUS = :FAIL_PAID)', $this->params)
-            ->select('O.*,U.REAL_NAME,U.DEC_ID,SG.CATEGORY_TYPE,OG.REAL_PRICE,OG.TAX_RATE,OG.BUY_NUMS,OG.SKU_CODE,OG.GOODS_TITLE,OG.REAL_PV')
-            ->join('LEFT JOIN', BaUser::tableName() . ' AS U', 'U.ID=O.USER_ID')
-            ->join('LEFT JOIN', BaApproachOrderGoods::tableName() . ' AS OG', 'OG.ORDER_SN=O.SN')
-            ->join('LEFT JOIN', ShopGoods::tableName() . ' AS SG', 'SG.ID=OG.GOODS_ID')
-            ->orderBy('O.CREATED_AT DESC');
-
-        $queryAll = $orderQuery->union($orderStandardQuery, true);
-        $query = (new Query())->from(['Q' => $queryAll])->select('Q.*')->distinct()->orderBy(['CREATED_AT' => SORT_DESC]);
-
-        $totalCount = $query->count();
-        $pagination = new Pagination(['totalCount' => $totalCount, 'pageSize' => \Yii::$app->request->get('pageSize')]);
-        $lists = $query->offset($pagination->offset)->limit($pagination->limit)->all();
-
-        $this->listData = [
-            'list' => $lists,
-            'currentPage'=>$pagination->page,
-            'totalPages'=>$pagination->pageCount,
-            'startNum' => $pagination->page * $pagination->pageSize + 1,
-            'totalCount' => $pagination->totalCount,
-            'pageSize' => $pagination->pageSize,
-        ];
-
-        foreach ($this->listData['list'] as $key => $value) {
-            $CREATE_USER_ID = Info::getUserIdByUserName($value['CREATE_USER']);
-            $this->listData['list'][$key]['DEC_USER_NAME'] = Info::getUserNameByUserId($value['DEC_ID']);
-            $this->listData['list'][$key]['CREATE_USER_NAME'] = Info::getUserRealNameByUserId($CREATE_USER_ID);
-//            $this->listData['list'][$key]['GOODS_NO'] = '';
-        }
-    }
-
-    /**
-     * 要展示和导出的所有字段
-     * @return array
-     */
-    public function getColumn(){
-        $regionConfig = Cache::getRegionConfig();
-        if(!$this->columns){
-            $this->columns = [
-                'ID' => null,
-                'DEC_SN' => null,
-                'USER_NAME' => [
-                    'header' => 'Member code',//会员编号
-                    'headerOther' => ['width' => '120'],
-                ],
-                'DEC_USER_NAME' => [
-                    'header' => 'Stockist', // 报单中心
-                    'headerOther' => ['width' => '120'],
-                ],
-                'CREATE_USER' => [
-                    'header' => 'Creator No',//创建人编号
-                    'headerOther' => ['width' => '120'],
-                ],
-                'CREATE_USER_NAME' => [
-                    'header' => 'Stockist Name',//创建人姓名
-                    'headerOther' => ['width' => '120'],
-                ],
-                'SN' => [
-                    'header' => 'Order code',//订单号
-                    'headerOther' => ['width' => '200'],
-                ],
-//                'STATUS' => null,
-                'STATUS' => [
-                    'header' => 'Status',//订单状态
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                    'value' => function ($row) {
-                        return \Yii::$app->params['orderStatus'][$row['STATUS']]['label'] ?? '';
-                    },
-                ],
-                'SKU_CODE' => [
-                    'header' => 'Product Code',//存货编码
-                    'headerOther' => ['width' => '150'],
-                ],
-                'GOODS_TITLE' => [
-                    'header' => 'Product Name', // 存货名称
-                    'headerOther' => ['width' => '200'],
-                ],
-                'BUY_NUMS' => [
-                    'header' => 'Qty',//数量
-                    'headerOther' => ['width' => '100'],
-                ],
-                'CONSIGNEE' => [
-                    'header' => 'Recipient',//收货人
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                ],
-                'MOBILE' => [
-                    'header' => 'Contact 1',//联系方式1
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                ],
-                'TEL' => [
-                    'header' => 'Contact 2',//联系方式2
-                ],
-                'PROVINCE' => [
-                    'header' => 'State', // 州
-                    'headerOther' => ['width' => '120'],
-                    'value' => function ($row) use($regionConfig) {
-                        return $regionConfig[$row['PROVINCE']]['REGION_NAME'] ?? '';
-                    },
-                ],
-                'CITY' => [
-                    'header' => 'Local Government Area', // 地方政府
-                    'headerOther' => ['width' => '120'],
-                    'value' => function ($row) use($regionConfig) {
-                        return $regionConfig[$row['CITY']]['REGION_NAME'] ?? '';
-                    },
-                ],
-                'COUNTY' => [
-                    'header' => 'City', // 区
-                    'headerOther' => ['width' => '120'],
-                    'value' => function ($row) use($regionConfig) {
-                        return $regionConfig[$row['COUNTY']]['REGION_NAME'] ?? '';
-                    },
-                ],
-//                'AREA' => [
-//                    'header' => '地区',
-//                    // 用于导出
-//                    'value' => function($row) use($regionConfig) {
-//                        $province = $regionConfig[$row['PROVINCE']]['REGION_NAME'] ?? '';
-//                        $city = $regionConfig[$row['CITY']]['REGION_NAME'] ?? '';
-//                        $county = $regionConfig[$row['COUNTY']]['REGION_NAME'] ?? '';
-//                        return $province.$city.$county;
-//                    },
-//                    // 用于前台显示
-//                    'showValue' => function($row) {
-//                        $province = $regionConfig[$row['PROVINCE']]['REGION_NAME'] ?? '';
-//                        $city = $regionConfig[$row['CITY']]['REGION_NAME'] ?? '';
-//                        $county = $regionConfig[$row['COUNTY']]['REGION_NAME'] ?? '';
-//                        return '<div class="addr" title='.$province.$city.$county.'>'.$province.$city.$county.'</div>';
-//                    },
-//                    'headerOther' => [
-//                        'width' => '200'
-//                    ],
-//                ],
-                'ADDRESS' => [
-                    'header' => 'Detailed address',//详细地址
-                    'headerOther' => [
-                        'width' => '300',
-                    ],
-                ],
-                'PERIOD_NUM' => [
-                    'header' => 'Period',//期数
-                ],
-                'ORDER_TYPE' => [
-                    'header' => 'Order type',//订单类型
-                    'headerOther' => ['width' => '120'],
-                    'value' => function ($row) {
-                        switch ($row['ORDER_TYPE']) {
-                            case 'ZC':
-                                return 'Welcome pack';
-                            case 'FX':
-                                return in_array($row['PAY_TYPE'], ['cash', 'pay_stack']) ? 'Reselling': 'Points'; //'重消' : '积分'
-                        }
-                    },
-                ],
-//                'WAREHOUSE' => [
-//                    'header' => 'Delivery warehouse',//发货仓
-//                ],
-                'CREATED_AT' => [
-                    'header' => 'Creation time',//创建时间
-                    'value' => function ($row) {
-                        return (new DateTime([
-                            'value' => $row['CREATED_AT'],
-                        ]))->result();
-                    },
-                    'headerOther' => ['width' => '190'],
-                ],
-                'PAY_TYPE' => [
-                    'header' => 'Pay type',// 支付方式
-                    'value' => function ($row) {
-                        return ShopGoods::payTypes()[$row['PAY_TYPE']]['name'] ?? ShopGoods::payTypes()['cash']['name'];
-                    },
-                    'headerOther' => ['width' => '190'],
-                ],
-                'PAY_AT' => [
-                    'header' => 'Payment time',//支付时间
-                    'value' => function ($row) {
-                        return (new DateTime([
-                            'value' => $row['PAY_AT'],
-                        ]))->result();
-                    },
-                    'headerOther' => ['width' => '190'],
-                ],
-                'DELIVERY_AT' => [
-                    'header' => 'Delivery time',//发货时间
-                    'value' => function ($row) {
-                        return (new DateTime([
-                            'value' => $row['DELIVERY_AT'],
-                        ]))->result();
-                    },
-                    'headerOther' => ['width' => '190'],
-                ],
-                'REAL_PRICE' => [
-                    'header' => 'Item Pricing',//商品单价
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function ($row) {
-                        return Tool::formatPrice($row['REAL_PRICE']);
-                    },
-                    'valueOther' => function ($row) {
-                        return [
-                            'tag' => ['type' => 'danger', 'size' => 'small', 'class' => 'no-border']
-                        ];
-                    },
-                ],
-                'REAL_PV' => [
-                    'header' => 'Commodity amount',//商品金额
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function ($row) {
-                        return Tool::formatPrice($row['REAL_PV']);
-                    },
-                    'valueOther' => function ($row) {
-                        return [
-                            'tag' => ['type' => 'danger', 'size' => 'small', 'class' => 'no-border']
-                        ];
-                    },
-                ],
-                'PAY_FREIGHT' => [
-                    'header' => 'Freight',//运费
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function ($row) {
-                        return Tool::formatPrice($row['FREIGHT']);
-                    },
-                    'valueOther' => function ($row) {
-                        return [
-                            'tag' => ['type' => 'danger', 'size' => 'small', 'class' => 'no-border']
-                        ];
-                    },
-                ],
-                'TAX_RATE' => [
-                    'header' => 'Tax Rate',//税率
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function ($row) {
-                        return Tool::formatPrice($row['TAX_RATE']);
-                    },
-                    'valueOther' => function ($row) {
-                        return [
-                            'tag' => ['type' => 'danger', 'size' => 'small', 'class' => 'no-border']
-                        ];
-                    },
-                ],
-                'TAX_AMOUNT' => [
-                    'header' => 'Tax',//税额
-                    'headerOther' => [
-                        'width' => '150',
-                    ],
-                    'value' => function ($row) {
-                        return Tool::formatPrice(($row['REAL_PRICE'] - $row['REAL_PRICE'] / (1 + $row['TAX_RATE'] / 100)));
-                    },
-                    'valueOther' => function ($row) {
-                        return [
-                            'tag' => ['type' => 'danger', 'size' => 'small', 'class' => 'no-border']
-                        ];
-                    },
-                ],
-                'EXPRESS_COMPANY' => [
-                    'header' => 'Courier Services Company',//快递公司
-                    'headerOther' => ['width' => '150'],
-                ],
-                'ORDER_TRACK_NO' => [
-                    'header' => 'Courier Number',//快递单号
-                    'headerOther' => ['width' => '200'],
-                ],
-                'EXPRESS_TYPE' => [
-                    'header' => 'Shipping Method',//发货方式
-                    'headerOther' => ['width' => '150'],
-                    'value' => function ($row) {
-                        return $row['EXPRESS_TYPE']==0 ? 'mailing ':' auto pick ';//'邮寄' : '自提'
-                    },
-                ],
-                'FRONT_REMARK' => [
-                    'header' => 'Member Notes',//会员备注
-                    'headerOther' => [
-                        'width' => '200',
-                    ],
-                    'value' => function ($row) {
-                        return $row['FRONT_REMARK'];
-                    },
-                    'showValue' => function ($row) {
-                        return '<div title="'.$row['FRONT_REMARK'].'" style="width:180px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">'.$row['FRONT_REMARK'].'</div>';
-                    },
-                ],
-                'DELIVERY_STATUS' => null,
-                'DELIVERY_STATUS_NAME' => [
-                    'header' => 'Shipment Status',//发货状态
-                    'headerOther' => [
-                        'width' => '110',
-                    ],
-                    'value' => function ($row) {
-                        return \Yii::$app->params['deliveryStatus'][$row['DELIVERY_STATUS']]['label'] ?? '';
-                    },
-                ],
-                'IS_AUTO' => [
-                    'header' => 'Is Auto', // 是否自动
-                    'value' => function ($row) {
-                        return $row['IS_AUTO'] == 1 ? 'Yes' : 'No';
-                    },
-                ],
-            ];
-        }
-        return $this->columns;
-    }
-
-    /**
-     * 前台用于筛选的类型集合
-     * @return mixed
-     */
-    public function getFilterTypes()
-    {
-        if(!$this->filterTypes){
-            $this->filterTypes = [
-                'SN'=> ['name'=> 'Order No'],//订单编号
-                'USER_NAME'=> ['name'=> 'Member code'],//会员编号
-                'MOBILE'=> ['name'=> 'Contact 1'],//联系方式1
-                'ORDER_TYPE'=> ['name'=> 'Order Type'],
-                'PERIOD_NUM'=> ['name'=> 'Number of periods'],//期数
-                'CREATED_AT'=> ['name'=> 'Creation time', 'other'=>'date'],//创建时间
-                'STATUS'=> [
-                    'name'=> 'Status',
-                    'other'=> 'select',
-                    'selectData'=> [
-                        ['id' => \Yii::$app->params['orderStatus']['paid']['value'], 'name' => \Yii::$app->params['orderStatus']['paid']['label']],
-                        ['id' => \Yii::$app->params['orderStatus']['notPaid']['value'], 'name' => \Yii::$app->params['orderStatus']['notPaid']['label']],
-                        ['id' => \Yii::$app->params['orderStatus']['failPaid']['value'], 'name' => \Yii::$app->params['orderStatus']['failPaid']['label']]
-                    ]
-                ],
-                'IS_AUTO' => [
-                    'name'=>'Is Auto',
-                    'other'=> 'select',
-                    'selectData'=> [
-                        ['id'=>1, 'name'=>'YES'],
-                        ['id'=>0, 'name'=>'NO'],
-                    ]
-                ]
-            ];
-        }
-        return $this->filterTypes;
-    }
-}

+ 0 - 371
backendApi/modules/v1/models/lists/ba/UserList.php

@@ -1,371 +0,0 @@
-<?php
-namespace backendApi\modules\v1\models\lists\ba;
-
-use common\helpers\Cache;
-use common\helpers\http\BackendToFrontendApi;
-use common\helpers\user\Info;
-use common\libs\dataList\DataListInterface;
-use common\models\DecRole;
-use common\models\OpenBank;
-use common\models\Region;
-use common\models\BaUser;
-use common\models\BaUserInfo;
-use common\libs\dataList\column\DateTime;
-use common\libs\dataList\column\YesNo;
-use common\models\UserNetwork;
-use common\models\UserSystem;
-use Yii;
-
-class UserList extends \common\libs\dataList\DataList implements DataListInterface
-{
-    /**
-     * 列表名称
-     * @return string
-     */
-    public function getListName(){
-        return 'BA会员列表';
-    }
-
-    /**
-     * 列表筛选到的数据
-     */
-    public function dataHandle()
-    {
-//        $this->condition .= ' AND UN.USER_ID=UI.USER_ID AND UN.PARENT_UID=UI.CON_UID';
-        $this->listData = BaUser::lists($this->condition, $this->params, [
-            'select' => 'U.*,
-                UI.USER_ID, UI.ZC_PV, UI.CON_UID, UI.REC_UID, UI.CON_NUM, UI.REC_NUM, UI.NETWORK_DEEP, 
-                UI.RELATION_DEEP, UI.SYSTEM_ID, UI.IS_GROUP_LEADER, UI.IS_SYSTEM_LEADER, UI.IS_TEAM, UI.IS_BIND, 
-                UI.IS_TEAM_MAIN, UI.IS_BIND_MAIN, UI.IS_AUTO_WITHDRAW, UI.CLOSE_LOGIN, UI.REG_TYPE, UI.SHOULD_REG_TYPE, 
-                UI.REG_NAME, UI.CREDIT_CODE, UI.PREMISES, UI.LEGAL_PERSON, UI.REG_EXPIRES, UI.STORE_TYPE, UI.INVOICE_BALANCE, 
-                UI.HIGHEST_EMP_LV, UI.CLOSE_LOGIN_AT, UI.PULLED_AT, 
-                UI.GROUP_LEADER_AT, UI.ALLOW_TRANSFER, UI.ALLOW_RECONSUME_SMS, UI.ALLOW_RECONSUME_SMS_TO, 
-                UI.HIGHEST_EMP_LV_PERIOD, UI.TRANSFER_PROP, UI.LOGIN_NUMS, UI.FAIL_NUMS, UI.LAST_LOGIN_IP, 
-                CU.USER_NAME CON_USER_NAME,CU.REAL_NAME CON_REAL_NAME,
-                RU.USER_NAME REC_USER_NAME,RU.REAL_NAME REC_REAL_NAME,
-                DU.USER_NAME DEC_USER_NAME
-                ',
-            'orderBy' => 'UI.CREATED_AT DESC, UI.ID DESC',
-            'from' => BaUser::tableName() . ' AS U',
-            'join' => [
-                ['LEFT JOIN', BaUserInfo::tableName() . ' AS UI', 'UI.USER_ID=U.ID'],
-//                ['LEFT JOIN', UserNetwork::tableName() . ' AS UN', 'UI.USER_ID=UN.USER_ID'],
-                ['LEFT JOIN', BaUser::tableName() . ' AS CU', 'UI.CON_UID=CU.ID'],
-                ['LEFT JOIN', BaUser::tableName() . ' AS RU', 'UI.REC_UID=RU.ID'],
-                ['LEFT JOIN', BaUser::tableName() . ' AS DU', 'U.DEC_ID=DU.ID'],
-            ],
-            'page' => $this->page,
-            'pageSize' => $this->pageSize,
-        ]);
-        foreach ($this->listData['list'] as $key => $value) {
-            // 后台访问前台的请求参数
-            if (!$this->isExport && Yii::$app->user->validateAdminAction('user', 'login-to-frontend')) {
-                $urlParams = BackendToFrontendApi::paramsFormat(['id' => $value['USER_ID']]);
-                $urlParamStr = '';
-                foreach ($urlParams as $pKey => $pValue) {
-                    $urlParamStr .= $pKey . '=' . $pValue . '&';
-                }
-                $urlParamStr = substr($urlParamStr, 0, -1);
-                $this->listData['list'][$key]['BTF_URL'] = $urlParamStr;
-            } else {
-                $this->listData['list'][$key]['BTF_URL'] = null;
-            }
-        }
-    }
-
-    /**
-     * 要展示和导出的所有字段
-     * @return array
-     */
-    public function getColumn(){
-//        $decLevelConfig = Cache::getDecLevelConfig();
-//        $empLevelConfig = Cache::getEmpLevelConfig();
-//        $crownLevelConfig = Cache::getStarCrownLevelConfig();
-//        $decRoleConfig = DecRole::getAllData();
-//        $systemConfig = UserSystem::getAllSystems();
-        $openBankConfig = OpenBank::getAllOpenBank();
-        $regionConfig = Cache::getRegionConfig();
-        if(!$this->columns){
-            $this->columns = [
-                'USER_ID' => null, // 这种传输方式主要是用于索引,因为过滤后的字段可能没有这种ID,但是一些功能的操作还需要用这种ID去关联,例如前台会员列表中的勾选批量状态管理,这里需要的就是USER_ID
-                'BTF_URL' => null,
-                'USER_NAME' => [
-                    'header' => 'Member code',//会员编号
-                    'headerOther' => ['width' => '150'],
-                ],
-                'REAL_NAME' => [
-                    'header' => 'Member name',//会员姓名
-                    'headerOther' => [
-                        'width' => '120',
-                    ],
-                    'valueOther' => [
-                        'tag'=>['type'=>'success', 'size' => 'small', 'class'=>'no-border']
-                    ],
-                ],
-                'LOGIN_STATUS_NAME' => [
-                    'header' => 'Login status',//登录状态
-                    'value' => function($row) {
-                        return $row['ALLOW_LOGIN'] == 1 ? 'allow Login': 'prohibit Login';//'允许登录' : '禁止登录'
-                    },
-                    'headerOther' => ['width' => '110'],
-                ],
-                'STATUS' => [
-                    'header' => 'Status',//状态
-                    'value' => function($row) {
-                        return $row['STATUS'] == 1 ? 'activate': 'lock';//'激活' : '锁定'
-                    },
-                    'headerOther' => ['width' => '110'],
-                ],
-                'ALLOW_LOGIN' => ['header' => 'Filter allow login','hidden'=>true],//筛选允许登录
-                'CREATED_AT' => [
-                    'header' => 'Joining Date', // 加入日期
-                    'value' => function($row) {
-                        return (new DateTime([
-                            'value' => $row['CREATED_AT'],
-                        ]))->result();
-                    },
-                    'headerOther' => ['width' => '170'],
-                ],
-//                'PERIOD_AT' => [
-//                    'header' => 'Joining Period',//加入期数
-//                    'headerOther' => ['width' => '180'],
-//                ],
-//                'DEC_LV_NAME' => [
-//                    'header' => 'Real time membership level',//实时会员级别
-//                    'headerOther' => [
-//                        'width' => '120',
-//                    ],
-//                    'value' => function($row) use($decLevelConfig) {
-//                        return $decLevelConfig[$row['DEC_LV']]['LEVEL_NAME'];
-//                    },
-//                    'valueOther' => [
-//                        'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border']
-//                    ],
-//                ],
-//                'DEC_LV_UPDATED_AT' => [
-//                    'header' => 'Real time adjustment date',//实时调整日期
-//                    'value' => function($row) {
-//                        return (new DateTime([
-//                            'value' => $row['DEC_LV_UPDATED_AT'],
-//                        ]))->result();
-//                    },
-//                    'headerOther' => ['width' => '160'],
-//                ],
-//                'LAST_DEC_LV_NAME' => [
-//                    'header' => 'Member level at settlement',//结算时会员级别
-//                    'headerOther' => [
-//                        'width' => '120',
-//                    ],
-//                    'value' => function($row) use($decLevelConfig) {
-//                        if (!$row['LAST_DEC_LV']) {
-//                            return $decLevelConfig[$row['DEC_LV']]['LEVEL_NAME'];
-//                        } else {
-//                            return $decLevelConfig[$row['LAST_DEC_LV']]['LEVEL_NAME'];
-//                        }
-//                    },
-//                    'valueOther' => [
-//                        'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border']
-//                    ],
-//                ],
-//                'EMP_LV_NAME' => [
-//                    'header' => 'Real time employment',//实时聘级
-//                    'headerOther' => [
-//                        'width' => '130',
-//                    ],
-//                    'value' => function($row) use($empLevelConfig) {
-//                        return isset($empLevelConfig[$row['EMP_LV']])?$empLevelConfig[$row['EMP_LV']]['LEVEL_NAME']:'';
-//                    },
-//                    'valueOther' => [
-//                        'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border']
-//                    ],
-//                ],
-//                'CROWN_LV_NAME' => [
-//                    'header' => 'Real time crown', // 实时星级
-//                    'headerOther' => [
-//                        'width' => '130',
-//                    ],
-//                    'value' => function($row) use($crownLevelConfig) {
-//                        return isset($crownLevelConfig[$row['CROWN_LV']])?$crownLevelConfig[$row['CROWN_LV']]['LEVEL_NAME']:'';
-//                    },
-//                    'valueOther' => [
-//                        'tag'=>['type'=>'warning', 'size' => 'small', 'class'=>'no-border']
-//                    ],
-//                ],
-                'REC_USER_NAME' => [
-                    'header' => 'Recommendation No',//推荐编号
-                    'headerOther' => ['width' => '150'],
-                ],
-                'REC_REAL_NAME' => [
-                    'header' => 'Recommended name',//推荐姓名
-                    'headerOther' => ['width' => '100'],
-                ],
-//                'CON_USER_NAME' => [
-//                    'header' => 'Placement No',//安置编号
-//                    'headerOther' => ['width' => '150'],
-//                ],
-//                'CON_REAL_NAME' => [
-//                    'header' => 'Placement Name',//安置姓名
-//                    'headerOther' => ['width' => '100'],
-//                ],
-                'MOBILE' => [
-                    'header' => 'Phone Number',//手机号码
-                    'value' => function($row) {
-                        return "\t".$row['MOBILE'];
-                    },
-                    'headerOther' => ['width' => '120'],
-                ],
-                'TEL' => [
-                    'header' => 'Alternate Phone Number', // 备用手机号码
-                    'value' => function($row) {
-                        return "\t".$row['TEL'];
-                    },
-                    'headerOther' => ['width' => '120'],
-                ],
-                'DEC_USER_NAME' => [
-                    'header' => 'Stockist Code', // 所属报单中心编号
-                    'headerOther' => ['width' => '150'],
-                ],
-//                'IS_DEC' => [
-//                    'header' => 'Declaration center or not',//是否报单中心
-//                    'value' => function($row) {
-//                        return (new YesNo([
-//                            'value' => $row['IS_DEC'],
-//                        ]))->result();
-//                    },
-//                    'headerOther' => function($row) {
-//                        return [
-//                            'width' => '120',
-//                        ];
-//                    },
-//                    'valueOther' => function($row) {
-//                        return [
-//                            'tag'=>['type'=>(isset($row['IS_DEC']) && $row['IS_DEC'] )? 'success' : 'info', 'size' => 'small']
-//                        ];
-//                    },
-//                ],
-//                'IS_ATLAS' => [
-//                    'header' => 'Whether the atlas is displayed',//是否显示图谱
-//                    'value' => function($row) {
-//                        return (new YesNo([
-//                            'value' => $row['IS_ATLAS'],
-//                        ]))->result();
-//                    },
-//                    'headerOther' => function($row) {
-//                        return [
-//                            'width' => '120',
-//                        ];
-//                    },
-//                    'valueOther' => function($row) {
-//                        return [
-//                            'tag'=>['type'=>(isset($row['IS_ATLAS']) && $row['IS_ATLAS'] )? 'success' : 'info', 'size' => 'small']
-//                        ];
-//                    },
-//                ],
-//                'IS_RECHARGE' => [
-//                    'header' => 'Whether to display recharge',//是否显示充值
-//                    'value' => function($row) {
-//                        return (new YesNo([
-//                            'value' => $row['IS_RECHARGE'],
-//                        ]))->result();
-//                    },
-//                    'headerOther' => function($row) {
-//                        return [
-//                            'width' => '120',
-//                        ];
-//                    },
-//                    'valueOther' => function($row) {
-//                        return [
-//                            'tag'=>['type'=>(isset($row['IS_RECHARGE']) && $row['IS_RECHARGE'] )? 'success' : 'info', 'size' => 'small']
-//                        ];
-//                    },
-//                ],
-//                'DEC_ROLE_NAME' => [
-//                    'header' => 'Stockist Level',//报单中心级别
-//                    'headerOther' => ['width' => '110'],
-//                    'value' => function($row) use($decRoleConfig) {
-//                        return $decRoleConfig[$row['DEC_ROLE_ID']]['ROLE_NAME'] ?? '';
-//                    },
-//                ],
-                'OPEN_BANK_NAME' => [
-                    'header' => 'Bank Name',//开户银行
-                    'headerOther' => ['width' => '110'],
-                    'value' => function($row) use($openBankConfig) {
-                        return $openBankConfig[$row['OPEN_BANK']]['BANK_NAME'] ?? '';
-                    },
-                ],
-                'BANK_NO' => [
-                    'header' => 'Bank account number',//银行帐号
-                    'headerOther' => ['width' => '220'],
-                    'value' => function($row) {
-                        return "\t".$row['BANK_NO'];
-                    },
-                ],
-                'AREA' => [
-                    'header' => 'Common address',//常用地址
-                    'value' => function($row) use($regionConfig) {
-                        $province = $regionConfig[$row['PROVINCE']]['REGION_NAME'] ?? '';
-                        $city = $regionConfig[$row['CITY']]['REGION_NAME'] ?? '';
-                        $county = $regionConfig[$row['COUNTY']]['REGION_NAME'] ?? '';
-                        return $province.$city.$county;
-                    },
-                    'showValue' => function($row) {
-                        $province = $regionConfig[$row['PROVINCE']]['REGION_NAME'] ?? '';
-                        $city = $regionConfig[$row['CITY']]['REGION_NAME'] ?? '';
-                        $county = $regionConfig[$row['COUNTY']]['REGION_NAME'] ?? '';
-                        return '<div class="addr" title='.$province.$city.$county.'>'.$province.$city.$county.'</div>';
-                    },
-                    'headerOther' => [
-                        'width' => '200'
-                    ],
-                ],
-//                'ALLOW_TRANSFER' => [
-//                    'header' => 'Enable "Transfer"', // 转账功能开启
-//                    'value' => function($row) {
-//                        return $row['ALLOW_TRANSFER'] == 1 ? 'on': 'off';//'开启' : '关闭'
-//                    },
-//                    'headerOther' => function($row) {
-//                        return [
-//                            'width' => '120',
-//                        ];
-//                    },
-//                    'valueOther' => function($row) {
-//                        return [
-//                            'tag'=>['type'=>(isset($row['ALLOW_TRANSFER']) && $row['ALLOW_TRANSFER']) ? 'success' : 'info', 'size' => 'small']
-//                        ];
-//                    },
-//                ],
-            ];
-        }
-        return $this->columns;
-    }
-
-    /**
-     * 前台用于筛选的类型集合
-     * @return mixed
-     */
-    public function getFilterTypes()
-    {
-        if(!$this->filterTypes){
-            $this->filterTypes = [
-                'USER_NAME'=> ['name'=> 'Member code'], // 会员编号
-                'REAL_NAME'=> ['name'=> 'Member name'], // 会员姓名
-                'CREATED_AT'=> ['name'=> 'Joining Date', 'other'=> 'date'], // 加入日期
-                'PERIOD_AT'=> ['name'=> 'Joining Period'], // 加入期数
-                'DEC_LV_NAME'=> ['name'=> 'Real time membership level', 'other'=> 'decLevel'], // 实时会员级别
-                'EMP_LV_NAME'=> ['name'=> 'Real time employment', 'other'=> 'empLevel'], // 实时聘级
-                'CROWN_LV_NAME'=> ['name'=> 'Real time Crown', 'other'=> 'crownLevel'], // 实时聘级
-                'REC_USER_NAME'=> ['name'=> 'Recommendation No'],//推荐编号
-                'CON_USER_NAME'=> ['name'=> 'Placement No'],//安置编号
-                'ID_CARD'=> ['name'=> 'Identification Number'],//证件号码
-                'MOBILE'=> ['name'=> 'Phone Number'],//手机号码
-                'DEC_USER_NAME'=> ['name'=> 'Stockist Code'], // 所属报单中心编号
-                'IS_DEC'=> ['name'=> 'Declaration center or not', 'other'=> 'yesOrNo'],//是否报单中心
-                'IS_STUDIO'=> ['name'=> 'Studio or not', 'other'=> 'yesOrNo'],//是否工作室
-                'DEC_ROLE_NAME'=> ['name'=> 'Stockist Level', 'other'=> 'decRole'],//报单中心级别
-                'AREA'=> ['name'=> 'Common address', 'other'=> 'area'],//常用地址
-                'STATUS'=> ['name'=> 'Active status', 'other'=> 'select', 'selectData'=> [['id'=> 0, 'name'=> 'locking'],['id'=> 1, 'name'=> 'activation']]],
-            ];
-        }
-        return $this->filterTypes;
-    }
-}

+ 7 - 14
backendEle/src/router/index.js

@@ -177,17 +177,10 @@ export const constantRouterMap = [
           ],
         },
       },
-    ],
-  },
-  {
-    path: '/ba',
-    component: layout,
-    redirect: '/ba/index',
-    children: [
       {
-        path: '/ba/user-list',
-        component: _import('ba/user-list'),
-        name: 'ba_user-list',
+        path: '/shop/ba-user-list',
+        component: _import('shop/ba-user-list'),
+        name: 'shop_ba-user-list',
         meta: {
           title: 'Brand Ambassador List', // 会员列表
           breadcrumb: [
@@ -197,9 +190,9 @@ export const constantRouterMap = [
         }
       },
       {
-        path: '/ba/order-list',
-        component: _import('ba/order-list'),
-        name: 'ba_order-list',
+        path: '/shop/ba-order-list',
+        component: _import('shop/ba-order-list'),
+        name: 'shop_ba-order-list',
         meta: {
           title: 'Brand Ambassador Order', // 订单列表
           breadcrumb: [
@@ -208,7 +201,7 @@ export const constantRouterMap = [
           ]
         }
       }
-    ]
+    ],
   },
   {
     path: '/user',

+ 3 - 3
backendEle/src/utils/config_trial.js

@@ -1,17 +1,17 @@
 const APP_NAME = 'Settlement system background'
 const SERVER_API_DOMAIN = '16.163.228.151'
 const SERVER_API_HTTP_TYPE = 'http://'
-const SERVER_API_PORT = ':8025'  // ':8102'
+const SERVER_API_PORT = ':8032'  // ':8102'
 const SERVER_API_VERSION = 'v1'
 const REQUEST_URL = `${SERVER_API_HTTP_TYPE}${SERVER_API_DOMAIN}${SERVER_API_PORT}/${SERVER_API_VERSION}/`
 const WEBSOCKET_HOST = 'ws://127.0.0.1:9513'
 const BONUS_WEBSOCKET_HOST = 'ws://127.0.0.1:9513'
 const DEVICE_TYPE = 'pc'
 const ACCESS_TOKEN_PREFIX = 'Bearer '
-const CDN_BASE_URL = 'http://16.163.228.151:8029'
+const CDN_BASE_URL = 'http://16.163.228.151:8036'
 const CDN_IMG_URL = `${CDN_BASE_URL}/cdn/`
 const PRICE_IS_ROUND = true
-const FRONTEND_SERVER = 'http://16.163.228.151:8028'
+const FRONTEND_SERVER = 'http://16.163.228.151:8033'
 const REGION_URL = `${CDN_BASE_URL}/cdn/jsdata/ar_region_data.js?ver=0.1`
 
 export {

+ 0 - 253
backendEle/src/views/ba/order-list.vue

@@ -1,253 +0,0 @@
-<template>
-  <div v-loading="loading">
-    <div class="white-box">
-      <div class="filter-box">
-        <filter-user :filter-types="filterTypes" @select-value="handleFilterUser"></filter-user>
-      </div>
-      <el-table class="table-box" ref="multipleTable" :data="tableData" stripe style="width: 100%;"
-                @selection-change="handleSelectionChange"
-                :height="tool.getTableHeight()">
-        <el-table-column type="selection" width="70" v-if="tableHeaders"></el-table-column>
-        <el-table-column v-for="(tableHeader, key) in tableHeaders" :key="key" :label="tableHeader.header" :width="tableHeader.other.width ? tableHeader.other.width : ''" :prop="tableHeader.other.prop ? tableHeader.other.prop : null">
-          <template slot-scope="scope">
-            <template v-if="scope.row[tableHeader.index].other.tag" >
-              <el-tag :type="scope.row[tableHeader.index].other.tag.type ? scope.row[tableHeader.index].other.tag.type : null" :size="scope.row[tableHeader.index].other.tag.size ? scope.row[tableHeader.index].other.tag.size : null" :class="scope.row[tableHeader.index].other.tag.class ? scope.row[tableHeader.index].other.tag.class : null" >{{scope.row[tableHeader.index].value}}</el-tag>
-            </template>
-            <template v-else>
-              <div v-html="scope.row[tableHeader.index].value"></div>
-            </template>
-          </template>
-        </el-table-column>
-        <el-table-column fixed="right" label="Action" width="180">&lt;!&ndash; 操作 &ndash;&gt;
-         <template slot-scope="scope">
-            <el-dropdown size="small" trigger="click">
-              <el-button type="primary" size="small" @click.stop="">
-                Action<i class="el-icon-arrow-down el-icon--right"></i>
-              </el-button>
-              <el-dropdown-menu slot="dropdown">
-                <el-dropdown-item command="edit" @click.native="handleDel(scope.row)" v-if="permission.hasPermission(`shop/edit`)">Delete order</el-dropdown-item>
-                <!-- <el-dropdown-item command="edit" @click.native="handleEdit(scope.row)" v-if="permission.hasPermission(`shop/edit`)">Edit order&lt;!&ndash; 编辑订单 &ndash;&gt;</el-dropdown-item>
-                <el-dropdown-item command="delivery" @click.native="handleShowDeliveryDialog(scope.row)" v-if="permission.hasPermission(`shop/order-delivery`) && scope.row['STATUS'] === '1' && scope.row['DELIVERY_STATUS'] === '0' ">deliver goods&lt;!&ndash; 发货 &ndash;&gt;</el-dropdown-item>
-                <el-dropdown-item command="refund" @click.native="handleRefund(scope.row.SN)" v-if="permission.hasPermission(`shop/order-delivery`) && scope.row['PAY_TYPE'] === 'pay_stack' && scope.row['STATUS'] === '1' && scope.row['DELIVERY_STATUS'] === '0' ">Refund&lt;!&ndash; 退款 &ndash;&gt;</el-dropdown-item> -->
-              </el-dropdown-menu>
-            </el-dropdown>
-          </template>
-        </el-table-column>
-      </el-table>
-      <div class="white-box-footer">
-        <el-button type="success" size="small" @click="handleExport" v-show="permission.hasPermission(`shop/order-list-export`)">Export Excel</el-button>
-        <el-button type="primary" size="small" @click="handleExportPDF" v-show="permission.hasPermission(`shop/order-list-export`)">Export PDF</el-button>
-        <pagination :total="totalCount" :page_size="pageSize" @size-change="handleSizeChange"
-                    @current-change="handleCurrentChange"></pagination>
-      </div>
-    </div>
-
-    <el-dialog title="deliver goods" :visible.sync="dialogDeliveryVisible"><!-- 发货 -->
-      <el-form :model="deliveryForm" label-width="150px" class="form-dialog">
-        <el-form-item label="Courier Services Company"><!-- 快递公司 -->
-          <el-input v-model="deliveryForm.expressCompany"></el-input>
-        </el-form-item>
-        <el-form-item label="courier number"><!-- 快递单号 -->
-          <el-input v-model="deliveryForm.orderTrackNo"></el-input>
-        </el-form-item>
-      </el-form>
-      <div slot="footer" class="dialog-footer">
-        <el-button @click="dialogDeliveryVisible = false">Cancel<!-- 取 消 --></el-button>
-        <el-button type="primary" @click.native="handleDelivery">deliver goods<!-- 发货 --></el-button>
-      </div>
-    </el-dialog>
-  </div>
-</template>
-
-<script>
-import network from '@/utils/network'
-import tool from '@/utils/tool'
-import baseInfo from '@/utils/baseInfo'
-import FilterUser from '@/components/FilterUser'
-import permission from '@/utils/permission'
-import Pagination from '@/components/Pagination'
-import filterHelper from '@/utils/filterHelper'
-
-export default {
-  name: 'shop_order-list',
-  components: {FilterUser, Pagination},
-  mounted () {
-    this.getData()
-  },
-  data () {
-    return {
-      tableHeaders: null,
-      tableData: null,
-      tableHeight: window.innerHeight - 310,
-      loading: true,
-      multipleSelection: [],
-      currentPage: 1,
-      totalPages: 1,
-      totalCount: 1,
-      pageSize: 20,
-      tool: tool,
-      permission: permission,
-      filterTypes: null,
-      filterModel: {},
-      dialogDeliveryVisible: false,
-      deliveryForm: {
-        sn: '',
-        expressCompany: '',
-        orderTrackNo: ''
-      }
-    }
-  },
-  methods: {
-    handleSelectionChange (val) {
-      this.multipleSelection = val
-    },
-    handleCurrentChange (page) {
-      this.getData(page, this.pageSize)
-    },
-    handleSizeChange (pageSize) {
-      this.getData(this.currentPage, pageSize)
-    },
-    handleFilterUser (filterData) {
-      filterHelper.handleFilterUser(this, filterData)
-    },
-    getData (page, pageSize) {
-      let filterData = this.filterModel
-      network.getPageData(this, 'ba/order-list', page, pageSize, filterData, response => {
-        this.filterTypes = response.filterTypes
-        this.allData = response
-      })
-    },
-    handleExport () {
-      this.$confirm(`Are you sure you want to export the current data?`, 'Hint', { // `确定要导出当前数据吗?`, '提示'
-        confirmButtonText: 'confirm', // 确定
-        cancelButtonText: 'cancel', // 取消
-        type: 'warning'
-      }).then(() => {
-        return network.getData(`shop/order-list-export`, this.filterModel)
-      }).then(response => {
-        this.$message({
-          message: response,
-          type: 'success'
-        })
-      }).catch(response => {
-
-      })
-    },
-    handleExportPDF () {
-      if (this.multipleSelection.length === 0) {
-        this.$message({
-          message: 'Please select an order to export', // 请选择一条订单导出
-          type: 'error'
-        })
-        return false
-      }
-
-      // 提取订单ID
-      let orderSnList = this.multipleSelection.map((item) => item.SN.value || '')
-      // 去重
-      let orderSnSet = Array.from(new Set(orderSnList))
-      if (orderSnSet.length !== 1) {
-        this.$message({
-          message: 'Only one order can be exported at a time', // 每次只能导出一条订单
-          type: 'error'
-        })
-        return false
-      }
-
-      this.$confirm(`Are you sure you want to export the current data?`, 'Hint', { // `确定要导出当前数据吗?`, '提示'
-        confirmButtonText: 'confirm', // 确定
-        cancelButtonText: 'cancel', // 取消
-        type: 'info'
-      }).then(() => {
-        // 导出时只需要订单ID即可
-        let orderSn = orderSnSet[0]
-        network.getData(`shop/order-list-export-pdf/${orderSn}`).then(response => {
-          this.$message({
-            message: response,
-            type: 'success'
-          })
-        })
-      }).catch(response => {
-        this.$message({
-          message: response,
-          type: 'error'
-        })
-      })
-    },
-    handleEdit () {
-      // 进入修改订单页面
-    },
-    handleDel (row) {
-      let orderSn = row.SN.value // order订单表的编号
-      this.$confirm(`确定要删除订单:${orderSn}吗?`, '提示', {
-        confirmButtonText: '确定',
-        cancelButtonText: '取消',
-        type: 'warning'
-      }).then(() => {
-        // 删除订单
-        let postData = {
-          orderSn
-        }
-        return network.postData('shop/delete-order', postData).then(response => {
-          console.log(response)
-          this.$message({
-            message: response,
-            type: 'success'
-          })
-          this.submitButtonStat = false
-          this.$router.go(0)
-        }).catch(() => {
-          this.submitButtonStat = false
-        })
-      }).then(response => {
-
-      }).catch(response => {
-
-      })
-    },
-    // 显示发货对话框
-    handleShowDeliveryDialog (row) {
-      this.dialogDeliveryVisible = true
-      this.deliveryForm.sn = row['SN'].value
-    },
-    // 发货
-    handleDelivery () {
-      network.postData('shop/order-delivery', this.deliveryForm).then(response => {
-        this.$message({
-          message: response,
-          type: 'success'
-        })
-        this.dialogDeliveryVisible = false
-        this.getData(this.currentPage, this.pageSize)
-      }).catch(response => {
-        this.dialogDeliveryVisible = false
-      })
-    },
-    // 退款
-    handleRefund (orderSn) {
-      this.$confirm(`Are you sure you want to refund this order?`, 'Hint', { // `确定要将此订单退款吗?`, '提示',
-        confirmButtonText: 'confirm', // 确定
-        cancelButtonText: 'cancel', // 取消
-        type: 'warning'
-      }).then(() => {
-        return network.postData(`shop/order-refund`, { sn: orderSn.value })
-      }).then(response => {
-        this.$message({
-          message: response,
-          type: 'success'
-        })
-        this.getData(this.currentPage, this.pageSize)
-      }).catch(response => {
-        this.$message({
-          message: response,
-          type: 'error'
-        })
-      })
-    }
-  }
-}
-
-</script>
-
-<style scoped>
-</style>

+ 207 - 0
backendEle/src/views/shop/ba-dec-order-list.vue

@@ -0,0 +1,207 @@
+<template>
+  <div v-loading="loading">
+    <div class="white-box">
+      <div class="filter-box">
+        <filter-user :filter-types="filterTypes" @select-value="handleFilterUser"></filter-user>
+      </div>
+      <el-table class="table-box" ref="multipleTable" :data="tableData" stripe style="width: 100%;"
+                @selection-change="handleSelectionChange"
+                :height="tool.getTableHeight()">
+        <el-table-column type="selection" width="70" v-if="tableHeaders"></el-table-column>
+        <el-table-column v-for="(tableHeader, key) in tableHeaders" :key="key" :label="tableHeader.header" :width="tableHeader.other.width ? tableHeader.other.width : ''" :prop="tableHeader.other.prop ? tableHeader.other.prop : null">
+          <template slot-scope="scope">
+            <template v-if="scope.row[tableHeader.index].other.tag" >
+              <el-tag :type="scope.row[tableHeader.index].other.tag.type ? scope.row[tableHeader.index].other.tag.type : null" :size="scope.row[tableHeader.index].other.tag.size ? scope.row[tableHeader.index].other.tag.size : null" :class="scope.row[tableHeader.index].other.tag.class ? scope.row[tableHeader.index].other.tag.class : null" >{{scope.row[tableHeader.index].value}}</el-tag>
+            </template>
+            <template v-else>
+              <div v-html="scope.row[tableHeader.index].value"></div>
+            </template>
+          </template>
+        </el-table-column>
+        <el-table-column fixed="right" label="操作" width="180">
+          <template slot-scope="scope">
+            <el-dropdown size="small" trigger="click">
+              <el-button type="primary" size="small" @click.stop="">
+                操作该数据<i class="el-icon-arrow-down el-icon--right"></i>
+              </el-button>
+              <el-dropdown-menu slot="dropdown">
+                <el-dropdown-item command="edit" @click.native="handleDel(scope.row)">Delete order</el-dropdown-item>
+              </el-dropdown-menu>
+            </el-dropdown>
+          </template>
+        </el-table-column>
+      </el-table>
+      <div class="white-box-footer">
+        <el-button type="success" size="small" @click="handleExport" v-show="permission.hasPermission(`shop/dec-order-list-export`)">Export Excel</el-button>
+        <el-button type="primary" size="small" @click="handleExportPDF" v-show="permission.hasPermission(`shop/dec-order-list-export`)">Export PDF</el-button>
+          <pagination :total="totalCount" :page_size="pageSize" @size-change="handleSizeChange"
+                    @current-change="handleCurrentChange"></pagination>
+      </div>
+    </div>
+  </div>
+</template>
+
+<script>
+  import network from '@/utils/network'
+  import tool from '@/utils/tool'
+  import baseInfo from '@/utils/baseInfo'
+  import FilterUser from '@/components/FilterUser'
+  import permission from '@/utils/permission'
+  import Pagination from '@/components/Pagination'
+  import filterHelper from '@/utils/filterHelper'
+
+  export default {
+    name: 'shop_dec-order-list',
+    components: {FilterUser, Pagination},
+    mounted() {
+      this.getData()
+    },
+    data() {
+      return {
+        tableHeaders: null,
+        tableData: null,
+        tableHeight: window.innerHeight - 310,
+        loading: true,
+        multipleSelection: [],
+        currentPage: 1,
+        totalPages: 1,
+        totalCount: 1,
+        pageSize: 20,
+        tool: tool,
+        permission: permission,
+        baseDecLevels: baseInfo.decLevels(),
+        baseEmpLevels: baseInfo.empLevels(),
+        filterTypes: null,
+        filterModel: {},
+        dialogVisible: false,
+        dialogLoading: false,
+        statuses: null,
+        form: {
+          selectedIds: [],
+          statusValue: [],
+          sendType: null,
+          remark: null,
+        },
+      }
+    },
+    methods: {
+      handleSelectionChange(val) {
+        this.multipleSelection = val
+      },
+      handleCurrentChange(page) {
+        this.getData(page, this.pageSize)
+      },
+      handleSizeChange(pageSize) {
+        this.getData(this.currentPage, pageSize)
+      },
+      handleFilterUser(filterData) {
+        filterHelper.handleFilterUser(this, filterData)
+      },
+      getData(page, pageSize) {
+        let filterData = this.filterModel
+        network.getPageData(this, 'shop/dec-order-list', page, pageSize, filterData, response => {
+            console.log(response)
+          this.filterTypes = response.filterTypes
+          this.allData = response
+        })
+      },
+      handleExport(){
+        this.$confirm(`Are you sure you want to export the current data?`, 'Hint', {//`确定要导出当前数据吗?`, '提示'
+          confirmButtonText: 'Confirm',//确认
+          cancelButtonText: 'Cancel',//取消
+          type: 'warning'
+        }).then(() => {
+          return network.getData(`shop/dec-order-list-export`, this.filterModel)
+        }).then(response => {
+          this.$message({
+            message: response,
+            type: 'success'
+          })
+        }).catch(response => {
+
+        })
+      },
+      handleShowDeliveryDialog(row) {
+        this.dialogDeliveryVisible = true
+        this.deliveryForm.sn = row['SN'].value
+      },
+      handleDel(row) {
+        let orderSn = row.ORDER_SN.value // order订单表的编号
+        let detailType = row.DETAIL_TYPE // 默认为1注册  2为升级
+        let upgradeType = row.UPGRADE_TYPE //默认0 1 补差额升级  2全额升级
+        this.$confirm(`确定要删除订单:${orderSn}吗?`, '提示', {
+          confirmButtonText: 'Confirm',
+          cancelButtonText: 'Cancel',
+          type: 'warning'
+        }).then(() => {
+          // 删除订单
+        let postData = {
+            orderSn,
+            detailType,
+            upgradeType
+          }
+          return network.postData('shop/delete-order', postData).then(response => {
+              console.log(response);
+              this.$message({
+                  message: response,
+                  type: 'success'
+              })
+              this.submitButtonStat = false
+              // this.$router.go(-1)
+          }).catch(() => {
+              this.submitButtonStat = false
+          })
+        }).then(response => {
+
+        }).catch(response => {
+
+        })
+      },
+        handleExportPDF() {
+            if (this.multipleSelection.length === 0) {
+                this.$message({
+                    message: 'Please select an order to export',//请选择一条订单导出
+                    type: 'error'
+                })
+                return false
+            }
+
+            // 提取订单ID
+            let orderSnList = this.multipleSelection.map((item) => item.SN.value || '');
+            // 去重
+            let orderSnSet = Array.from(new Set(orderSnList))
+            if (orderSnSet.length !== 1) {
+                this.$message({
+                    message: 'Only one order can be exported at a time',//每次只能导出一条订单
+                    type: 'error'
+                })
+                return false
+            }
+
+            this.$confirm(`Are you sure you want to export the current data?`, 'Hint', {//`确定要导出当前数据吗?`, '提示',
+                confirmButtonText: 'Confirm',//确认
+                cancelButtonText: 'Cancel',//取消
+                type: 'warning'
+            }).then(() => {
+                // 导出时只需要订单ID即可
+                let orderSn = orderSnSet[0]
+                network.getData(`shop/dec-order-list-export-pdf/${orderSn}`).then(response => {
+                    this.$message({
+                        message: response,
+                        type: 'success'
+                    })
+                })
+            }).catch(response => {
+                this.$message({
+                    message: response,
+                    type: 'error'
+                })
+            })
+        },
+    }
+  }
+
+</script>
+
+<style scoped>
+</style>

+ 690 - 0
backendEle/src/views/shop/ba-user-list.vue

@@ -0,0 +1,690 @@
+<template>
+  <div v-loading="loading">
+    <div class="white-box">
+      <div class="filter-box">
+        <filter-user :filter-types="filterTypes" @select-value="handleFilterUser"></filter-user>
+      </div>
+      <el-table ref="wrapper" :data="tableData" stripe style="width: 100%;" @selection-change="handleSelectionChange" :height="tool.getTableHeight()">
+        <el-table-column fixed type="selection" width="55" v-if="tableHeaders"></el-table-column>
+        <el-table-column v-for="(tableHeader, key) in tableHeaders" :key="key" :label="tableHeader.header"
+            :width="tableHeader.other.width ? tableHeader.other.width : ''" :fixed="tableHeader.index=='USER_NAME' || tableHeader.index=='REAL_NAME' ?true:false">
+          <template slot-scope="scope">
+            <template v-if="scope.row[tableHeader.index].other.tag">
+              <el-tag
+                  :type="scope.row[tableHeader.index].other.tag.type ? scope.row[tableHeader.index].other.tag.type : null"
+                  :size="scope.row[tableHeader.index].other.tag.size ? scope.row[tableHeader.index].other.tag.size : null"
+                  :class="scope.row[tableHeader.index].other.tag.class ? scope.row[tableHeader.index].other.tag.class : null">
+                {{scope.row[tableHeader.index].value}}
+              </el-tag>
+            </template>
+            <template v-else>
+              <template v-if="tableHeader.index === 'USER_NAME'">
+                <el-dropdown v-if="permission.hasPermission(`user/login-to-frontend`)">
+                  <span class="el-dropdown-link">
+                    {{scope.row.USER_NAME.value}} <i class="el-icon-arrow-down el-icon--right"></i>
+                  </span>
+                  <el-dropdown-menu slot="dropdown">
+                    <el-dropdown-item command="login" v-show="scope.row.BTF_URL !== null">
+                      <a :href="`${frontendServer}/#/login-by-backend?${scope.row.BTF_URL}`" target="_blank" style="color:#606266;">
+                        Quick logon<!-- 快速登录 -->
+                      </a>
+                    </el-dropdown-item>
+                  </el-dropdown-menu>
+                </el-dropdown>
+                <el-tag type="primary" size="small" class="no-border" v-if="!permission.hasPermission(`user/login-to-frontend`)">
+                  {{scope.row.USER_NAME.value}}
+                </el-tag>
+              </template>
+              <template v-else>
+                <div v-html="scope.row[tableHeader.index].value"></div>
+              </template>
+            </template>
+          </template>
+        </el-table-column>
+        <el-table-column fixed="right" label="Action" width="180"><!-- 操作 -->
+          <template slot-scope="scope">
+            <el-dropdown size="small" trigger="click">
+              <el-button type="primary" size="small" @click.stop="">
+                Action<!-- 操作该数据 --><i class="el-icon-arrow-down el-icon--right"></i>
+              </el-button>
+              <el-dropdown-menu slot="dropdown">
+                <el-dropdown-item @click.native="handleModifyPassword(scope.row)" v-if="permission.hasPermission(`user/modify-password`)">
+                  Change Password<!-- 修改密码 -->
+                </el-dropdown-item>
+                <el-dropdown-item @click.native="handleModifyProfile(scope.row)" v-if="permission.hasPermission(`user/modify-profile`)">
+                  Modify personal data<!-- 修改个人资料 -->
+                </el-dropdown-item>
+                <el-dropdown-item @click.native="handleStatusActive(scope.row)" v-if="permission.hasPermission(`user/modify-status`)">
+                  Status activation<!-- 状态激活 -->
+                </el-dropdown-item>
+                <el-dropdown-item @click.native="handleStatusLock(scope.row)" v-if="permission.hasPermission(`user/modify-status`)">
+                  Status lock<!-- 状态锁定 -->
+                </el-dropdown-item>
+                <el-dropdown-item @click.native="handleIsModifyPassword(scope.row, 1)" v-if="permission.hasPermission(`user/is-modify-password-status`)">
+                  Open password modification<!-- 开启密码修改 -->
+                </el-dropdown-item>
+                <el-dropdown-item @click.native="handleIsModifyPassword(scope.row, 0)" v-if="permission.hasPermission(`user/is-modify-password-status`)">
+                  Turn off password modification<!-- 关闭密码修改 -->
+                </el-dropdown-item>
+              </el-dropdown-menu>
+            </el-dropdown>
+          </template>
+        </el-table-column>
+      </el-table>
+      <div class="white-box-footer">
+        <el-button type="success" size="small" @click="handleExport" v-show="permission.hasPermission(`shop/ba-user-list`)">
+          Export Excel
+        </el-button>
+        <pagination :total="totalCount" :page_size="pageSize" @size-change="handleSizeChange" @current-change="handleCurrentChange"></pagination>
+      </div>
+    </div>
+    <el-dialog :title="formModifyPassword.typeName" :visible.sync="dialogModifyPasswordVisible" width="50%">
+      <el-form ref="form" :model="formModifyPassword" label-width="120px" class="form-dialog">
+        <el-form-item label="type"><!-- 类型 -->
+          <el-select v-model="formModifyPassword.passwordType" placeholder="Please select a type"><!-- 请选择类型 -->
+            <el-option v-for="(item,key) in passwordType" :label="item.label" :value="item.type" :key="key"></el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item label="password"><!-- 密码 -->
+          <el-input placeholder="password" v-model="formModifyPassword.password"><!-- 密码 --></el-input>
+        </el-form-item>
+        <el-form-item>
+          <el-button type="primary" @click="handleModifyPasswordSubmit" :loading="submitPasswordButtonStat">Submit<!-- 提交 --></el-button>
+        </el-form-item>
+      </el-form>
+    </el-dialog>
+
+    <el-dialog :title="formModifyProfile.typeName" :visible.sync="dialogModifyProfileVisible" width="50%">
+      <el-form ref="form" :model="formModifyProfile" label-width="150px" class="form-dialog">
+        <el-form-item label="Member name"><!-- 会员姓名 -->
+          <el-input v-model="formModifyProfile.realName"></el-input>
+        </el-form-item>
+        <el-form-item label="Identity No."><!-- 身份证号 -->
+          <el-input v-model="formModifyProfile.idCard"></el-input>
+        </el-form-item>
+        <el-form-item label="Phone Number"><!-- 手机号 -->
+          <el-input v-model="formModifyProfile.mobile"></el-input>
+        </el-form-item>
+        <el-form-item label="Bank name"><!-- 银行名称 -->
+          <el-select v-model="formModifyProfile.openBank" placeholder="Please select a bank name"><!-- 请选择银行名称 -->
+            <el-option v-for="(item,index) in allOpenBank" :key="index" :label="item.BANK_NAME" :value="item.BANK_CODE"></el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item label="Bank Address"><!-- 开户行地址 -->
+          <el-input v-model="formModifyProfile.bankAddress"></el-input>
+        </el-form-item>
+        <el-form-item label="Bank account number"><!-- 银行帐号 -->
+          <el-input v-model="formModifyProfile.bankNo"></el-input>
+        </el-form-item>
+        <el-form-item>
+          <el-button type="primary" @click="handleModifyProfileSubmit" :loading="submitProfileButtonStat">
+            Submit<!-- 提交 -->
+          </el-button>
+        </el-form-item>
+      </el-form>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import network from './../../utils/network'
+import tool from './../../utils/tool'
+import {FRONTEND_SERVER} from '@/utils/config'
+import baseInfo from '@/utils/baseInfo'
+import FilterUser from '../../components/FilterUser'
+import store from './../../utils/vuexStore'
+import permission from '@/utils/permission'
+import Pagination from '@/components/Pagination'
+import filterHelper from '../../utils/filterHelper'
+
+export default {
+  name: 'user_index',
+  components: {FilterUser, Pagination},
+  mounted () {
+    let _this = this
+    _this.getData()
+    store.state.socket.onMessageCallback = this.onMessageCallback
+  },
+  data () {
+    return {
+      tableHeaders: null,
+      tableData: null,
+      loading: true,
+      multipleSelection: [],
+      currentPage: 1,
+      totalPages: 1,
+      totalCount: 1,
+      pageSize: 20,
+      frontendServer: FRONTEND_SERVER,
+      baseDecLevels: baseInfo.decLevels(),
+      baseEmpLevels: baseInfo.empLevels(),
+      tool: tool,
+      permission: permission,
+      filterTypes: null,
+      filterModel: {},
+      dialogVisible: false,
+      formCloseLogin: {
+        userName: null,
+        typeName: 'Login management', // 登录管理
+        type: null,
+        isClose: 0,
+        remark: '',
+        areaSelected: null
+      },
+      regionDataPlus: store.state.regionInfo.regionData,
+      apps: null,
+      closeSwitch: null,
+      submitButtonStat: false,
+      dialogDecVisible: false,
+      dialogModifyPasswordVisible: false,
+      dialogModifyProfileVisible: false,
+      formCloseDec: {
+        userName: null,
+        typeName: 'Manage entry', // 管理报单
+        type: null,
+        isClose: 0,
+        remark: '',
+        areaSelected: null
+      },
+      formModifyPassword: {
+        userId: '',
+        password: '',
+        typeName: 'Change Password', // 修改密码
+        passwordType: 'password'
+        // remark: '',
+      },
+      formModifyProfile: {
+        userId: '',
+        typeName: 'Modify personal data', // 修改个人资料
+        nation: '',
+        realName: '',
+        idCard: '',
+        mobile: '',
+        openBank: '',
+        bankAddress: '',
+        bankNo: ''
+      },
+      passwordType: [
+        {
+          type: 'password',
+          label: 'login password' // 登录密码
+        },
+        {
+          type: 'payPassword',
+          label: 'Payment password' // 支付密码
+        }
+      ],
+      allOpenBank: null,
+      allNation: null,
+      submitDecButtonStat: false,
+      submitPasswordButtonStat: false,
+      submitProfileButtonStat: false,
+      transferPropForm: {
+        userIds: [],
+        allowTransfer: true,
+        transferProp: 100,
+        withdrawProp: 0,
+        remark: ''
+      },
+      closeUserData: null
+    }
+  },
+  methods: {
+    handleSelectionChange (val) {
+      this.multipleSelection = val
+    },
+    handleCurrentChange (page) {
+      this.getData(page, this.pageSize)
+    },
+    handleSizeChange (pageSize) {
+      this.getData(this.currentPage, pageSize)
+    },
+    handleAdd () {
+      this.$router.push('/user/user-add')
+    },
+    handleFilterUser (filterData) {
+      filterHelper.handleFilterUser(this, filterData)
+    },
+    handleFilter () {
+      this.getData()
+    },
+    getData (page, pageSize, isLoading = true) {
+      network.getPageData(this, 'shop/ba-user-list', page, pageSize, this.filterModel, response => {
+        this.filterTypes = response.filterTypes
+      }, isLoading)
+    },
+    handleGroupManage (isGroup) {
+      if (this.multipleSelection.length < 1) {
+        this.$message({
+          message: 'Please check the member to be operated', // 请勾选要操作的会员
+          type: 'warning'
+        })
+        return
+      }
+      let groupTip = isGroup === true ? 'Set as team leader' : 'Cancel team leader' // '设为团队领导人' : '取消团队领导人'
+      this.$confirm(`Are you sure you want to【${groupTip}】?`, 'Hint', { // `确定要对所选会员【${groupTip}】吗?`, '提示'
+        confirmButtonText: 'confirm', // 确定
+        cancelButtonText: 'cancel', // 取消
+        type: 'warning'
+      }).then(() => {
+        let selectedIds = []
+        for (let val of this.multipleSelection) {
+          selectedIds.push(val.USER_ID)
+        }
+        return network.postData(`user/is-group`, {userIds: selectedIds, isGroup: isGroup})
+      }).then(response => {
+        this.$message({
+          message: response,
+          type: 'success'
+        })
+        this.getData(this.currentPage, this.pageSize)
+      }).catch(response => {
+
+      })
+    },
+    handleIsDecManage (isDec) {
+      if (this.multipleSelection.length < 1) {
+        this.$message({
+          message: 'Please check the member to be operated', // 请勾选要操作的会员
+          type: 'warning'
+        })
+        return
+      }
+      let isDecTip = isDec === true ? 'Set as declaration Center' : 'Cancel Stockist' // '设为报单中心' : '取消报单中心'
+      this.$confirm(`Are you sure you want to【${isDecTip}】?`, 'Hint', { // 确定要对所选会员【${isDecTip}】吗?`, '提示'
+        confirmButtonText: 'confirm', // 确定
+        cancelButtonText: 'cancel', // 取消
+        type: 'warning'
+      }).then(() => {
+        let selectedIds = []
+        for (let val of this.multipleSelection) {
+          selectedIds.push(val.USER_ID)
+        }
+        return network.postData(`user/is-dec`, {userIds: selectedIds, isDec: isDec})
+      }).then(response => {
+        this.$message({
+          message: response,
+          type: 'success'
+        })
+        this.getData(this.currentPage, this.pageSize)
+      }).catch(response => {
+
+      })
+    },
+    handleIsStudioManage (isStudio) {
+      if (this.multipleSelection.length < 1) {
+        this.$message({
+          message: 'Please check the member to be operated', // 请勾选要操作的会员
+          type: 'warning'
+        })
+        return
+      }
+      let isStudioTip = isStudio === true ? 'Set as studio' : 'Cancel room' // '设为工作室' : '取消工作室'
+      this.$confirm(`Are you sure you want to【${isStudioTip}】?`, 'Hint', {
+        confirmButtonText: 'confirm', // 确定
+        cancelButtonText: 'cancel', // 取消
+        type: 'warning'
+      }).then(() => {
+        let selectedIds = []
+        for (let val of this.multipleSelection) {
+          selectedIds.push(val.USER_ID)
+        }
+        return network.postData(`user/is-studio`, {userIds: selectedIds, isStudio: isStudio})
+      }).then(response => {
+        this.$message({
+          message: response,
+          type: 'success'
+        })
+        this.getData(this.currentPage, this.pageSize)
+      }).catch(response => {
+
+      })
+    },
+    handleIsAtlasManage (isAtlas) {
+      if (this.multipleSelection.length < 1) {
+        this.$message({
+          message: 'Please check the member to be operated', // 请勾选要操作的会员
+          type: 'warning'
+        })
+        return
+      }
+      let isAtlasTip = isAtlas === true ? 'Display Atlas' : 'Hidden Atlas' // '显示图谱' : '隐藏图谱'
+      this.$confirm(`Are you sure you want to【${isAtlasTip}】?`, 'Hint', { // `确定要对所选会员【${isAtlasTip}】吗?`, '提示'
+        confirmButtonText: 'confirm', // 确定
+        cancelButtonText: 'cancel', // 取消
+        type: 'warning'
+      }).then(() => {
+        let selectedIds = []
+        for (let val of this.multipleSelection) {
+          selectedIds.push(val.USER_ID)
+        }
+        return network.postData(`user/is-atlas`, {userIds: selectedIds, isAtlas: isAtlas})
+      }).then(response => {
+        this.$message({
+          message: response,
+          type: 'success'
+        })
+        this.getData(this.currentPage, this.pageSize)
+      }).catch(response => {
+
+      })
+    },
+    handleIsRechargeManage (isRecharge) {
+      if (this.multipleSelection.length < 1) {
+        this.$message({
+          message: 'Please check the member to be operated', // 请勾选要操作的会员
+          type: 'warning'
+        })
+        return
+      }
+      let isRechargeTip = isRecharge === true ? 'Display recharge' : 'Hide recharge' // '显示充值' : '隐藏充值'
+      this.$confirm(`Are you sure you want to【${isRechargeTip}】?`, 'Hint', { // `确定要对所选会员【${isRechargeTip}】吗?`, '提示'
+        confirmButtonText: 'confirm', // 确定
+        cancelButtonText: 'cancel', // 取消
+        type: 'warning'
+      }).then(() => {
+        let selectedIds = []
+        for (let val of this.multipleSelection) {
+          selectedIds.push(val.USER_ID)
+        }
+        return network.postData(`user/is-recharge`, {userIds: selectedIds, isRecharge: isRecharge})
+      }).then(response => {
+        this.$message({
+          message: response,
+          type: 'success'
+        })
+        this.getData(this.currentPage, this.pageSize)
+      }).catch(response => {
+
+      })
+    },
+    getTypeName (type) {
+      switch (type) {
+        case 1:
+          return 'By designated member' // 按指定会员
+        case 2:
+          return 'Expand network by' // 按开拓网络
+        case 3:
+          return 'By placement network' // 按安置网络
+        case 4:
+          return 'By membership system' // 按会员体系
+        case 5:
+          return 'By province and region' // 按省份地区
+        default:
+          return ''
+      }
+    },
+    handleLoginManage (type) {
+      if (type === 2 || type === 3 || type === 4) {
+        if (this.multipleSelection.length > 1) {
+          this.$message({
+            message: 'Multiple members are not allowed to be checked in this login management', // 此登录管理不允许勾选多名会员
+            type: 'warning'
+          })
+          return
+        } else if (this.multipleSelection.length < 1) {
+          this.$message({
+            message: 'Please select a member number', // 请选择会员编号
+            type: 'warning'
+          })
+          return
+        }
+      }
+      if (type === 1 && this.multipleSelection.length <= 0) {
+        this.$message({
+          message: 'Please select a member number', // 请选择会员编号
+          type: 'warning'
+        })
+        return
+      }
+      if (type === 5 && this.multipleSelection.length > 0) {
+        this.$message({
+          message: 'Closing login by region without checking member', // 按照地区关闭登录无需勾选会员
+          type: 'warning'
+        })
+        return
+      }
+      this.formCloseLogin = {
+        userName: null,
+        typeName: 'Login management', // 登录管理
+        type: null,
+        isClose: 0,
+        remark: '',
+        areaSelected: null
+      }
+      this.formCloseLogin.typeName = this.getTypeName(type) + 'Manage logins' // 管理登录
+      this.formCloseLogin.type = type
+      this.dialogVisible = true
+    },
+    handleCloseLoginSubmit () {
+      this.submitButtonStat = true
+      // 获取所购选的会员,如果是批量关闭指定会员,则走批量关闭方法
+      if (this.formCloseLogin.type === 1) {
+        this.handleCloseLogin(this.formCloseLogin.isClose, this.formCloseLogin.remark)
+      } else {
+        for (let val of this.multipleSelection) {
+          this.formCloseLogin.userName = val.USER_NAME.value
+        }
+        let path = 'user/close-login'
+        if (this.formCloseLogin.type === 5) {
+          path = 'user/close-area-login'
+        }
+        network.postData(path, this.formCloseLogin).then(response => {
+          this.$message({
+            message: response,
+            type: 'success'
+          })
+          this.getData(this.currentPage, this.pageSize)
+          this.submitButtonStat = false
+          this.dialogVisible = false
+        }).catch(response => {
+          this.submitButtonStat = false
+        })
+      }
+    },
+    handleCloseLogin (isClose, remark = '') {
+      let selectedIds = []
+      for (let val of this.multipleSelection) {
+        selectedIds.push(val.USER_ID)
+      }
+      console.log(selectedIds)
+      network.postData(`user/batch-close-login`, {
+        userIds: selectedIds,
+        isClose: isClose,
+        remark: remark,
+        type: 1
+      }).then(response => {
+        this.$message({
+          message: response,
+          type: 'success'
+        })
+        this.getData(this.currentPage, this.pageSize)
+        this.submitButtonStat = false
+        this.dialogVisible = false
+      }).catch(response => {
+        this.submitButtonStat = false
+      })
+    },
+    handleExport () {
+      this.$confirm(`Are you sure you want to export the current data?`, 'Hint', { // (`确定要导出当前数据吗?`, '提示',
+        confirmButtonText: 'confirm', // 确定
+        cancelButtonText: 'cancel', // 取消
+        type: 'warning'
+      }).then(() => {
+        return network.getData(`shop/ba-user-list-export`, this.filterModel)
+      }).then(response => {
+        this.$message({
+          message: response,
+          type: 'success'
+        })
+      }).catch(response => {
+
+      })
+    },
+    onMessageCallback (data) {
+      // this.getData(this.currentPage, this.pageSize, false)
+    },
+    handleDecManage (type) {
+      if (type === 2 || type === 3 || type === 4) {
+        if (this.multipleSelection.length > 1) {
+          this.$message({
+            message: 'Multiple members are not allowed to be checked in this entry management', // 此报单管理不允许勾选多名会员
+            type: 'warning'
+          })
+          return
+        } else if (this.multipleSelection.length < 1) {
+          this.$message({
+            message: 'Please check the member to manage the entry', // 请勾选要管理报单的会员
+            type: 'warning'
+          })
+          return
+        }
+      }
+      if (type === 1 && this.multipleSelection.length <= 0) {
+        this.$message({
+          message: 'Please check the member to manage the entry', // 请勾选要管理报单的会员
+          type: 'warning'
+        })
+        return
+      }
+      if (type === 5 && this.multipleSelection.length > 0) {
+        this.$message({
+          message: 'Closing entry by region without checking member', // 按照地区关闭报单无需勾选会员
+          type: 'warning'
+        })
+        return
+      }
+      this.formCloseDec = {
+        userName: null,
+        typeName: 'Manage entry', // 管理报单
+        type: null,
+        isClose: 0,
+        remark: '',
+        areaSelected: null
+      }
+      this.formCloseDec.typeName = this.getTypeName(type) + 'Manage entry' // 管理报单
+      this.formCloseDec.type = type
+      this.dialogDecVisible = true
+    },
+    handleModifyPassword (row) {
+      this.formModifyPassword.userId = row.USER_ID
+      this.dialogModifyPasswordVisible = true
+    },
+    handleModifyProfile (row) {
+      this.dialogModifyProfileVisible = true
+      let vueObj = this
+      network.getData('user/profile-get', {id: row.USER_ID}).then(response => {
+        vueObj.formModifyProfile = response.userInfo
+        vueObj.allOpenBank = response.allOpenBank
+        vueObj.allNation = response.allNation
+      })
+    },
+    handleCloseDecSubmit () {
+      this.submitDecButtonStat = true
+      // 获取所购选的会员,如果是批量关闭指定会员,则走批量关闭方法
+      if (this.formCloseDec.type === 1) {
+        this.handleCloseDec(this.formCloseDec.isClose, this.formCloseDec.remark)
+      } else {
+        for (let val of this.multipleSelection) {
+          this.formCloseDec.userName = val.USER_NAME.value
+        }
+        let path = 'user/close-dec'
+        if (this.formCloseDec.type === 5) {
+          path = 'user/close-area-dec'
+        }
+        network.postData(path, this.formCloseDec).then(response => {
+          this.$message({
+            message: response,
+            type: 'success'
+          })
+          this.getData(this.currentPage, this.pageSize)
+          this.submitDecButtonStat = false
+          this.dialogDecVisible = false
+        }).catch(response => {
+          this.submitDecButtonStat = false
+        })
+      }
+    },
+    handleCloseDec (isClose, remark = '') {
+      let selectedIds = []
+      for (let val of this.multipleSelection) {
+        selectedIds.push(val.USER_ID)
+      }
+      network.postData(`user/batch-close-dec`, {
+        userIds: selectedIds,
+        isClose: isClose,
+        remark: remark,
+        type: 1,
+      }).then(response => {
+        this.$message({
+          message: response,
+          type: 'success'
+        })
+        this.getData(this.currentPage, this.pageSize)
+        this.submitDecButtonStat = false
+        this.dialogDecVisible = false
+      }).catch(response => {
+        this.submitDecButtonStat = false
+      })
+    },
+    handleStatusActive (row) {
+      network.postData('user/modify-status',{userId: row.USER_ID, status: 1}).then(response => {
+        this.$message({
+          message: response,
+          type: 'success'
+        })
+        this.getData(this.currentPage, this.pageSize)
+      })
+    },
+    handleStatusLock (row) {
+      network.postData('user/modify-status',{userId: row.USER_ID, status: 0}).then(response => {
+        this.$message({
+          message: response,
+          type: 'success'
+        })
+        this.getData(this.currentPage, this.pageSize)
+      })
+    },
+    handleIsModifyPassword (row, status) {
+      network.postData('user/is-modify-password-status',{userId: row.USER_ID, status: status}).then(response => {
+        this.$message({
+          message: response,
+          type: 'success'
+        })
+        this.getData(this.currentPage, this.pageSize)
+      })
+    },
+    handleModifyPasswordSubmit () {
+      this.submitPasswordButtonStat = true
+      let path = 'user/modify-password'
+      network.postData(path, this.formModifyPassword).then(response => {
+        this.$message({
+          message: response,
+          type: 'success'
+        })
+        this.getData(this.currentPage, this.pageSize)
+        this.submitPasswordButtonStat = false
+        this.dialogModifyPasswordVisible = false
+      }).catch(response => {
+        this.submitPasswordButtonStat = false
+      })
+    },
+    handleModifyProfileSubmit () {
+      this.submitProfileButtonStat = true
+      let path = 'user/modify-profile'
+      network.postData(path, this.formModifyProfile).then(response => {
+        this.$message({
+          message: response,
+          type: 'success'
+        })
+        this.getData(this.currentPage, this.pageSize)
+        this.submitProfileButtonStat = false
+        this.dialogModifyProfileVisible = false
+      }).catch(response => {
+        this.submitProfileButtonStat = false
+      })
+    }
+  }
+}
+
+</script>

+ 12 - 0
common/helpers/user/Info.php

@@ -31,6 +31,8 @@ use common\models\UserNetwork;
 use common\models\UserRelation;
 use common\models\UserSystem;
 use common\models\UserWallet;
+use common\models\BaUser;
+use common\models\BaUserInfo;
 use yii\base\Exception;
 
 class Info {
@@ -492,6 +494,9 @@ class Info {
         if (User::find()->where('USER_NAME=:USER_NAME', [':USER_NAME' => $result])->exists()) {
             return self::generateWebUserName($prefix, $length);
         }
+        if (BaUser::find()->where('USER_NAME=:USER_NAME', [':USER_NAME' => $result])->exists()) {
+            return self::generateWebUserName($prefix, $length);
+        }
         return $result;
     }
 
@@ -635,7 +640,11 @@ class Info {
     }
 
     /**
+<<<<<<< Updated upstream
      * 获取用户ID
+=======
+     * 获取Ba用户ID
+>>>>>>> Stashed changes
      * @param $userName
      * @return mixed
      */
@@ -643,6 +652,7 @@ class Info {
         $user = BaUserInfo::findOneAsArray('USER_NAME=:USER_NAME AND DELETED=0', [':USER_NAME' => $userName], 'USER_ID');
         return $user ? $user['USER_ID'] : null;
     }
+<<<<<<< Updated upstream
 
     /**
      * 获取会员名通过ID
@@ -711,4 +721,6 @@ class Info {
     public static function getBaBaseUserByUserName($username) {
         return BaUser::findOneAsArray('USER_NAME=:USER_NAME', [':USER_NAME' => $username]);
     }
+=======
+>>>>>>> Stashed changes
 }

+ 92 - 0
common/models/BaDecOrder.php

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

+ 1 - 1
common/models/BaUserInfo.php

@@ -174,7 +174,7 @@ class BaUserInfo extends \common\components\ActiveRecord
         return [
             'USER_ID' => '会员ID',
             'USER_NAME' => '会员名',
-            'ZC_PV' => '注册单PV',
+//            'ZC_PV' => '注册单PV',
             'CON_UID' => [
                 'label' => '接点人编号',
                 'type' => function($data){

+ 218 - 0
common/models/forms/BaApproachDeclarationLoopForm.php

@@ -0,0 +1,218 @@
+<?php
+namespace common\models\forms;
+
+use common\components\Model;
+use common\helpers\Form;
+use common\models\UserBind;
+use yii\base\Exception;
+use yii\helpers\Json;
+use common\models\DeclarationPackage;
+use common\helpers\Date;
+use common\models\ShopGoods;
+
+/**
+ * Login form
+ */
+class BaApproachDeclarationLoopForm extends Model
+{
+    public $data;
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['data'], 'required'],
+            [['data'], 'formatData'],
+            [['data'], 'isData', 'on'=>['canDec', 'notFull']],
+        ];
+    }
+
+    public function attributeLabels()
+    {
+        return [
+            'data' => 'Data',// 数据
+        ];
+    }
+
+    /**
+     * 指定场景
+     * @return array
+     */
+    public function scenarios()
+    {
+        $parentScenarios =  parent::scenarios();
+        $customScenarios = [
+            'userDec' => ['data'],
+            'canDec' => ['data'],
+            'notFull' => ['data'],
+        ];
+        return array_merge($parentScenarios, $customScenarios);
+    }
+
+    /**
+     * 格式化提交的数据
+     * @param $attribute
+     */
+    public function formatData($attribute){
+        //$this->data = Json::decode($this->data);
+        if(!is_array($this->data)){
+            $this->addError($attribute, 'Data format error');// 数据格式错误
+        }
+    }
+
+    /**
+     * 循环校验数据是否合格
+     * @param $attribute
+     */
+    public function isData($attribute){
+        $model = new DeclarationForm();
+        $model->scenario = $this->scenario;
+        $model->allData = $this->data;
+        foreach ($this->data as $value){
+            if(is_array($value)){
+                foreach($value as $key=>$decFormData){
+                    $model->$key = $decFormData;
+                }
+                if(!$model->validate()){
+                    $this->addErrors($model->getErrors());
+                }
+                $model->type = null;
+                $model->decSn = null;
+                $model->userId = null;
+                $model->toUserId = null;
+                $model->decPv = null;
+                $model->insertUserName = null;
+                $model->insertUserIdCard = null;
+                $model->conUserName = null;
+                $model->recUserName = null;
+                $model->location = null;
+            } else {
+                $this->addError($attribute, 'The format of the report data is incorrect');// 报单数据格式错误
+            }
+
+        }
+    }
+
+    /**
+     * 报单
+     * @return bool
+     * @throws \yii\db\Exception
+     */
+    public function add()
+    {
+        if(!$this->validate()){
+            return null;
+        }
+
+        $result = null;
+        $db = \Yii::$app->db;
+        $transaction = $db->beginTransaction();
+        try{
+            // 所有的首购单会员ID以备点位绑定使用
+            $zcUserIdCard = null;
+            $model = new ApproachDeclarationForm();
+            $model->scenario = $this->scenario;
+            $model->allData = $this->data;
+            foreach ($this->data as $value) {
+                // 套餐报单
+                if (isset($value['packageId']) && $value['packageId']){
+                    $packagedata = DeclarationPackage::findOneAsArray('ID=:ID', [':ID' => $value['packageId']]);
+                    if($packagedata['STORE_NUMS']>0){
+                        $data =  DeclarationPackage::find()->where(['ID'=> $packagedata['ID'] ])->one();
+                        $goods_store_nums = $data->STORE_NUMS - 1;
+                        $data->STORE_NUMS = $goods_store_nums;
+                        $data->update();
+
+                        //库存为0下架套餐
+                        if ($goods_store_nums <= 0){
+                            $data->STATUS = 0;
+                            $data->UPDATED_AT = Date::nowTime();
+                        }
+                    }else{
+                        throw new Exception($packagedata['PACKAGE_NAME'].'Insufficient inventory');// 库存不足
+                    }
+                }
+                // 普通商品报单
+                if (count($value['goodsId']) > 0 && (count($value['goodsId']) == count($value['goodsNum']))) {
+                    for ($i = 0; $i < count($value['goodsId']) ;$i++) {
+                        $goods = ShopGoods::findOneAsArray('ID=:ID',[':ID'=> $value['goodsId'][$i]]);
+                        if ($goods['STATUS'] == 1 ){
+                            if($goods['STORE_NUMS'] >= $value['goodsNum'][$i]) {
+                                // 减库存
+                                $data = ShopGoods::find()->where(['ID' => $value['goodsId'][$i]])->one();
+                                $goods_store_nums = $data->STORE_NUMS - $value['goodsNum'][$i];
+                                $data->STORE_NUMS = $goods_store_nums;
+                                $data->update();
+
+                                if($goods_store_nums <= 0){
+                                    $data->STATUS = 0;
+                                    $data->UPDATED_AT = Date::nowTime();
+                                    $data->update();
+                                }
+                            } else {
+                                throw new Exception($goods['GOODS_NAME'].'Insufficient inventory');// 商品库存不足
+                            }
+                        }else{
+                            throw new Exception($goods['GOODS_NAME'].'Sold out');// 商品已下架
+                        }
+
+                    }
+
+                }
+				
+                if (is_array($value)) {
+                    foreach($value as $key=>$decFormData){
+                        $model->$key = $decFormData;
+                    }
+                    // 把首购单的几个会员归集到一个数组里,将来绑定到一起
+                    if( $model->type == 'ZC'){
+                        if($zcUserIdCard != null){
+                            if($model->insertUserIdCard != $zcUserIdCard){
+                                throw new Exception('Bulk declaration member must be the same member');//批量报单会员必须是同一身份证
+                            }
+                        } else {
+                            $zcUserIdCard = $model->insertUserIdCard;
+                        }
+                    }
+
+                    $result = $model->add($this->data);
+                    if(!$result){
+                        throw new Exception(Form::formatErrorsForApi($model->getErrors()));
+                    }
+                } else {
+                    throw new Exception('The format of the report data is incorrect');// 报单数据格式错误
+                }
+            }
+
+            $transaction->commit();
+
+            return $result;
+        } catch (\Exception $e){
+            $transaction->rollBack();
+            $this->addError('add', $e->getFile() . ' ' . $e->getLine() . ' ' . $e->getMessage());
+            return null;
+        }
+    }
+
+    /**
+     * RPC服务校验数据
+     * @param $data
+     * @return array
+     */
+    public static function rpcIsData($data){
+        $result = [
+            'error' => false,
+            'message' => 'Data can be reported',//数据可报单
+        ];
+        $formModel = new self();
+        $formModel->scenario = 'canDec';
+        $formModel->data = $data;
+        if(!$formModel->validate()){
+            $result['error'] = true;
+            $result['message'] = Form::formatErrorsForApi($formModel->getErrors());
+        }
+        return $result;
+    }
+}

+ 482 - 0
common/models/forms/BaDeclarationForm.php

@@ -0,0 +1,482 @@
+<?php
+namespace common\models\forms;
+
+use common\components\Model;
+use common\helpers\Cache;
+use common\helpers\Date;
+use common\helpers\Form;
+use common\helpers\user\Cash;
+use common\helpers\user\Reconsume;
+use common\helpers\user\Info;
+use common\models\DeclarationPackage;
+use common\models\BaDecOrder;
+use common\models\EmployLevel;
+use common\models\BaOrder;
+use common\models\BaOrderGoods;
+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\BaUser;
+use common\models\BaUserInfo;
+use common\models\UserNetwork;
+use common\models\UserRelation;
+use yii\base\Exception;
+
+/**
+ * Login form
+ */
+class BaDeclarationForm 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 $allData;
+    private $_decId;
+    public $_insertUserId;
+    private $_decAmount;
+//    private $_decPv;
+    private $_orderGoods;
+
+    // 批量报单时添加会员的REDIS里面缓存的添加的会员资料
+    const REDIS_WAIT_ADD_USER = 'user:dec:waitAdd';
+
+    const TYPE_ZC = 'ZC';
+//    const TYPE_YH = 'YH';
+    const TYPE_ZG = 'ZG';
+    const TYPE_LS = 'LS';
+    const TYPE_FX = 'FX';
+
+//    private $_modelClass = null;
+    private $_oneOrder = null;
+    private $_userForm = null;
+    // 全部的上级(安置网和开拓网)
+    private $_tempParentUser = [];
+    // 全部的安置网上级
+    private $_tempNetworkParentUser = [];
+    // 全部的开拓网上级
+    private $_tempRelationParentUser = [];
+    private $_types = [
+        self::TYPE_ZC => [
+            'name' => '首购单',
+        ],
+//        self::TYPE_YH => [
+//            'class' => DeclarationYH::class,
+//            'table' => '{{%DECLARATION_YH}}',
+//            'name' => '优惠单',
+//        ],
+        self::TYPE_ZG => [
+            'name' => '升级增购单',
+        ],
+        self::TYPE_LS => [
+            'name' => '零售单',
+        ],
+        self::TYPE_FX => [
+            'name' => '复销单',
+        ],
+    ];
+
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['type','decLv','decWay','packageId', 'insertUserName', 'realName',/* 'insertUserIdCard',*/ 'mobile', 'address', 'openBank', 'bankAddress', 'bankNo','bankProvince','bankCity','bankCounty','consignee','acceptMobile','province','city','county','cityName','lgaName','decUserName', 'conUserName', 'recUserName', 'location'], 'trim'],
+            [['type','decWay','insertUserName',/* 'insertUserIdCard',*/'password','payPassword','decUserName'], 'required'],
+//            [['type'], 'isType', 'on'=>['userDec', 'canDec']],
+//            [['insertUserName'], 'isCanAddUser'],
+//            [['decUserName'], 'issetDec'],
+//            [['conUserName'], 'isConUserName'],
+//            [['recUserName'], 'isRecUserName'],
+//            [['location'], 'isLocation'],
+//            [['insertUserIdCard'], 'isSameSystem'],
+        ];
+    }
+
+    public function attributeLabels()
+    {
+        return [
+            'type' => 'Entry type', // 报单类型
+            'goodsId' => 'product ID', // 商品ID
+            'goodsNum' => 'Product quantity', // 商品数量
+            'insertUserName' => 'Member user name', // 会员用户名
+            'password' => 'Login password', // 登陆密码
+            'payPassword' => 'Payment password', // 支付密码
+            'realName' => 'Member name', // 会员姓名
+            'mobile' => 'Phone Number', // 手机号
+            'recUserName' => 'Developer user name', // 开拓人用户名
+            'decUserName' => 'Stockist user name', // 报单中心用户名
+            'conUid' => 'Instructor Member ID', // 指导老师会员ID
+            'recUid' => 'Sponsor Member ID', // 开拓人会员ID
+            'location' => 'market', // 市场
+            'consignee' => 'Recipient', // 收货人
+            'acceptMobile' => 'Recipient Phone Number', // 收货人手机
+            'province' => 'Receiving Province',//收货省
+            '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','decUserName', 'location', 'email'],
+        ];
+        return array_merge($parentScenarios, $customScenarios);
+    }
+
+    /**
+     * 判断报单中心是否存在
+     * @param $attribute
+     */
+    public function issetDec($attribute){
+        if (!$decUser = User::find()->select('ID')->where('IS_DEC=1 AND USER_NAME=:USER_NAME', [':USER_NAME' => $this->decUserName])->asArray()->one()) {
+            $this->addError($attribute, 'Stockist does not exist'); // 报单中心不存在
+            return false;
+        } else {
+            $this->_decId = $decUser['ID'];
+        }
+    }
+
+    /**
+     * 添加报单
+     * @param $allData
+     * @return bool|null
+     * @throws Exception
+     * @throws \yii\db\Exception
+     */
+    public function add($allData){
+        if(!$this->validate()){
+            return null;
+        }
+
+        // 首购单,需要添加会员操作
+        if($this->type == self::TYPE_ZC){
+            if (preg_match("/[\x7f-\xff]/", $this->insertUserName)) {  // 判断字符串中是否有中文
+                throw new Exception('Member number cannot contain Chinese characters'); // 会员编号中不能含有汉字
+            }
+//            //报单商品及PV判断
+//            $decLevelConfig = Cache::getDecLevelConfig();
+//            $decLevel = $decLevelConfig[$this->decLv];
+//            $toDecLevel = $this->decLv;
+//            if(!$this->decLv){
+//                throw new Exception('Please select the entry level'); // 请选择报单级别
+//            }
+            if($this->decWay==1) {
+//                $decPackage = BaDeclarationPackage::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;
+                $totalPv = 0;
+                foreach ($this->goodsNum as $k => $v) {
+                    if ($v) {
+                        $goods = ShopGoods::findOneAsArray('ID=:ID AND STATUS=1',[':ID'=> $ids[$k]]);
+                        if($goods['STORE_NUMS']>0){
+                            $totalAmount += $goods['SELL_PRICE'] * intval($v);
+                            $totalPv += $goods['PRICE_PV'] * intval($v);
+                            $this->_orderGoods[] = [
+                                'GOODS_ID' => $goods['ID'],
+                                'PRICE' => $goods['SELL_PRICE'],
+                                'REAL_PRICE' => $goods['SELL_PRICE'],
+                                'PV' => $goods['PRICE_PV'],
+                                'REAL_PV' => $goods['PRICE_PV'],
+                                'POINT' => $goods['POINT'],
+                                'BUY_NUMS' => intval($v),
+                                'SKU_CODE' => $goods['GOODS_NO'],
+                                'GOODS_TITLE' => $goods['GOODS_NAME'],
+                                'EMAIL' => $this->email,
+                                'TAX_RATE' => $goods['TAX_RATE'],
+                            ];
+                        }
+                    }
+                }
+//                if($totalPv<$decLevel['PERF']){
+//                    throw new Exception('The total BV of self selected goods cannot be less than the BV of the selected entry level');//自选商品总BV不能小于所选报单级别BV
+//                }
+//                foreach ($decLevelConfig as $key=>$val){
+//                    if($totalPv>=$val['PERF']){
+//                        $toDecLevel = $key;
+//                    }
+//                }
+//                if($this->decLv!=$toDecLevel){
+//                    throw new Exception('The total BV of self selected goods cannot exceed the BV value of the next level under the selected level');//自选商品总BV不能超过已选级别下一个级别的BV值
+//                }
+                $this->_decAmount = $totalAmount;
+//                $this->_decPv = $totalPv;
+            }
+            //看现金余额是否充足
+            $loginUserId = \Yii::$app->user->id;
+            if (Cash::getAvailableBalance($loginUserId) < $this->_decAmount){
+                throw new Exception('The applicant is short of cash and cannot complete the declaration');//报单人现金不足,无法完成报单
+            }
+
+            if(!($zcResult = $this->addBaUser($allData))) {
+                throw new Exception(Form::formatErrorsForApi($this->_userForm->getErrors()));
+            }
+            if(!($decResult = $this->addBaDecOrder())) {
+                throw new Exception(Form::formatErrorsForApi($decResult->getErrors()));
+            }
+        }
+        return true;
+    }
+
+    /**
+     * 添加会员
+     * @param $allData
+     * @return bool|UserInfo|null
+     * @throws \yii\db\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()));
+        }
+
+        $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;
+        }
+    }
+
+    /**
+     * 添加报单订单
+     * @return bool|UserInfo|null
+     * @throws \yii\db\Exception
+     */
+    public function addBaDecOrder(){
+        $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 BaDecOrder();
+        $decOrderModel->DEC_SN = 'DS'.$ord;
+        $decOrderModel->ORDER_SN = 'OS'.$ord;
+        $decOrderModel->TYPE = $this->type;
+        $decOrderModel->USER_ID = \Yii::$app->user->id;
+        $decOrderModel->TO_USER_ID = $this->_insertUserId;
+        $decOrderModel->DEC_AMOUNT = $this->_decAmount;
+        $decOrderModel->DEC_PV = $this->_decPv;
+        $decOrderModel->PERIOD_NUM = $nowPeriodNum;
+        $decOrderModel->CALC_MONTH = $nowCalcMonth;
+        $decOrderModel->P_CALC_MONTH = Date::ociToDate($nowCalcMonth, Date::OCI_TIME_FORMAT_SHORT_MONTH);
+        $decOrderModel->PAID_WALLET = 'cash';
+        $decOrderModel->CON_USER_ID = Info::getUserIdByUserName($this->conUserName);
+        $decOrderModel->REC_USER_ID = Info::getUserIdByUserName($this->recUserName);
+        $decOrderModel->DEC_ID = $this->_decId;
+        $decOrderModel->IS_DEL = 0;
+        $decOrderModel->CREATED_AT = Date::nowTime();
+        if(!$decOrderModel->save()){
+            throw new Exception(Form::formatErrorsForApi($decOrderModel->getErrors()));
+        }
+
+        // 加入订单信息
+        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';
+        }
+        $orderModel = new BaOrder();
+        $orderModel->SN = 'OS'.$ord;
+        $orderModel->DEC_SN = 'DS'.$ord;
+        $orderModel->ORDER_TYPE = $this->type;
+        $orderModel->USER_ID = $this->_insertUserId;
+        $orderModel->USER_NAME = $this->insertUserName;
+        $orderModel->ORDER_AMOUNT = $this->_decAmount;
+        $orderModel->PV = $this->_decPv;
+        $orderModel->PAY_AMOUNT = $this->_decAmount;
+        $orderModel->PAY_PV = $this->_decPv;
+        $orderModel->PAY_AT = Date::nowTime();
+        $orderModel->PAY_TYPE = 'cash';
+        $orderModel->PERIOD_NUM = $nowPeriodNum;
+        $orderModel->P_CALC_MONTH = Date::ociToDate($nowCalcMonth, Date::OCI_TIME_FORMAT_SHORT_MONTH);
+        $orderModel->FREIGHT = 0;
+        $orderModel->PAY_FREIGHT = 0;
+        $orderModel->CONSIGNEE = $this->consignee;
+        $orderModel->MOBILE = $this->acceptMobile;
+        $orderModel->EMAIL = $this->email;
+        $orderModel->PROVINCE = $this->province;
+        $orderModel->LGA_NAME = $this->lgaName;
+        $orderModel->CITY_NAME = $this->cityName;
+        $orderModel->ADDRESS = $this->address;
+        $orderModel->WAREHOUSE = $warehouse;
+        $orderModel->STATUS = 1;
+        $orderModel->CREATED_AT = Date::nowTime();
+        $orderModel->CREATE_USER = Info::getUserNameByUserId(\Yii::$app->user->id);
+        if($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);
+        }
+        BaOrderGoods::batchInsert($this->_orderGoods);
+
+        //写入收货地址信息,判断province字段,当不为1时,插入收货地址信息
+        if($this->province!=1){
+            $addressModel = new ReceiveAddress();
+            $addressModel->USER_ID = $this->_insertUserId;
+            $addressModel->USER_NAME = $this->insertUserName;
+            $addressModel->CONSIGNEE = $this->consignee;
+            $addressModel->MOBILE = $this->acceptMobile;
+            $addressModel->PROVINCE = $this->province;
+            $addressModel->CITY_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()));
+            }
+            //扣报单人现金钱包
+//            Cash::changeUserCash(\Yii::$app->user->id, 'CASH', -abs($this->_decAmount), ['REMARK' =>'为'.$this->insertUserName.'报单']);
+            Cash::changeUserCash(\Yii::$app->user->id, 'CASH', -abs($this->_decAmount), ['REMARK' =>'To'.$this->insertUserName.'Entry']);
+            return $addressModel;
+        }else{
+            $addressModel = new ReceiveAddress();
+            return $addressModel;
+        }
+    }
+
+    /**
+     * 删单
+     * @return bool
+     * @throws \yii\db\Exception
+     */
+    public function delete(){
+        if(!$this->validate()){
+            return false;
+        }
+        $transaction = \Yii::$app->db->beginTransaction();
+        try {
+            $oneOrder = $this->_oneOrder;
+            // 首购单要删除会员
+            if($this->type == self::TYPE_ZC){
+                BaUserInfo::deleteUser($oneOrder['TO_USER_ID']);
+            }
+            // 如果是复销单的话,还需要考虑给会员的复销池减去金额
+            elseif($this->type == self::TYPE_FX){
+//                Reconsume::changePoolPV($oneOrder['TO_USER_ID'], -abs($oneOrder['DEC_PV']), ['REMARK'=>'删单扣除', 'DEAL_TYPE'=>Reconsume::TYPE_AUDIT_PV]);
+                Reconsume::changePoolPV($oneOrder['TO_USER_ID'], -abs($oneOrder['DEC_PV']), ['REMARK'=>'Deletion deduction', 'DEAL_TYPE'=>Reconsume::TYPE_AUDIT_PV]);
+            }
+            $transaction->commit();
+        } catch (Exception $e) {
+            $transaction->rollBack();
+            $this->addError('delete', $e->getMessage());
+            return false;
+        }
+        return true;
+    }
+
+}

+ 220 - 0
common/models/forms/BaDeclarationLoopForm.php

@@ -0,0 +1,220 @@
+<?php
+namespace common\models\forms;
+
+use common\components\Model;
+use common\helpers\Form;
+use common\models\UserBind;
+use yii\base\Exception;
+use yii\helpers\Json;
+use common\models\DeclarationPackage;
+use common\helpers\Date;
+use common\models\ShopGoods;
+
+/**
+ * Login form
+ */
+class BaDeclarationLoopForm extends Model
+{
+    public $data;
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['data'], 'required'],
+            [['data'], 'formatData'],
+            [['data'], 'isData', 'on'=>['canDec', 'notFull']],
+        ];
+    }
+
+    public function attributeLabels()
+    {
+        return [
+            'data' => 'Data',// 数据
+        ];
+    }
+
+    /**
+     * 指定场景
+     * @return array
+     */
+    public function scenarios()
+    {
+        $parentScenarios =  parent::scenarios();
+        $customScenarios = [
+            'userDec' => ['data'],
+            'canDec' => ['data'],
+            'notFull' => ['data'],
+        ];
+        return array_merge($parentScenarios, $customScenarios);
+    }
+
+    /**
+     * 格式化提交的数据
+     * @param $attribute
+     */
+    public function formatData($attribute){
+        //$this->data = Json::decode($this->data);
+        if(!is_array($this->data)){
+            $this->addError($attribute, 'Data format error');// 数据格式错误
+        }
+    }
+
+    /**
+     * 循环校验数据是否合格
+     * @param $attribute
+     */
+    public function isData($attribute){
+        $model = new BaDeclarationForm();
+        $model->scenario = $this->scenario;
+        $model->allData = $this->data;
+        foreach ($this->data as $value){
+            if(is_array($value)){
+                foreach($value as $key=>$decFormData){
+                    $model->$key = $decFormData;
+                }
+                if(!$model->validate()){
+                    $this->addErrors($model->getErrors());
+                }
+                $model->type = null;
+                $model->decSn = null;
+                $model->userId = null;
+                $model->toUserId = null;
+                $model->decPv = null;
+                $model->insertUserName = null;
+                $model->insertUserIdCard = null;
+                $model->conUserName = null;
+                $model->recUserName = null;
+                $model->location = null;
+            } else {
+                $this->addError($attribute, 'The format of the report data is incorrect');// 报单数据格式错误
+            }
+
+        }
+    }
+
+    /**
+     * 报单
+     * @return bool
+     * @throws \yii\db\Exception
+     */
+    public function add(){
+        $startTime = microtime(true);
+        if(!$this->validate()){
+            return null;
+        }
+        $db = \Yii::$app->db;
+        $transaction = $db->beginTransaction();
+        try{
+            // 所有的首购单会员ID以备点位绑定使用
+            $allZcUserIds = [];
+            $zcUserIdCard = null;
+            $model = new BaDeclarationForm();
+            $model->scenario = $this->scenario;
+            $model->allData = $this->data;
+            foreach ($this->data as $value){
+				/**
+                 * 2022-04-29
+                 * York
+                 * 获取商品套餐信息
+                 */
+//                if (isset($value['packageId']) && $value['packageId']){
+//                    $packagedata = DeclarationPackage::findOneAsArray('ID=:ID', [':ID' => $value['packageId']]);
+//                    //var_dump($packagedata['ID']);
+//                    if($packagedata['STORE_NUMS']>0){
+//                        $data =  DeclarationPackage::find()->where(['ID'=> $packagedata['ID'] ])->one();
+//                        $goods_store_nums = $data->STORE_NUMS - 1;
+//                        $data->STORE_NUMS = $goods_store_nums;
+//                        $data->update();
+////                        var_dump('输出一下数量');
+////                        var_dump($goods_store_nums);
+//                        //库存为0下架套餐
+//                        if ($goods_store_nums <= 0){
+//                            $data->STATUS = 0;
+//                            $data->UPDATED_AT = Date::nowTime();
+////                            var_dump('购买后套餐库存为0 下架拉');
+//                        }
+//
+//                    }else{
+//                        throw new Exception($packagedata['PACKAGE_NAME'].'Insufficient inventory');// 库存不足
+//                    }
+//
+//
+//                }
+
+                if (count($value['goodsId']) > 0 && (count($value['goodsId']) == count($value['goodsNum']))){
+                    for ($i=0;$i<count($value['goodsId']);$i++){
+                        $goods = ShopGoods::findOneAsArray('ID=:ID',[':ID'=> $value['goodsId'][$i]]);
+                        if ($goods['STATUS'] == 1 ){
+                            if($goods['STORE_NUMS'] >= $value['goodsNum'][$i]){
+                                $data = ShopGoods::find()->where(['ID' => $value['goodsId'][$i]])->one();
+                                $goods_store_nums = $data->STORE_NUMS - $value['goodsNum'][$i];
+                                $data->STORE_NUMS = $goods_store_nums;
+                                $data->update();
+                                if($goods_store_nums <= 0){
+                                    $data->STATUS = 0;
+                                    $data->UPDATED_AT = Date::nowTime();
+                                    $data->update();
+                                }
+                            }else{
+                                throw new Exception($goods['GOODS_NAME'].'Insufficient inventory');// 商品库存不足
+                            }
+                        }else{
+                            throw new Exception($goods['GOODS_NAME'].'Sold out');// 商品已下架
+                        }
+                    }
+                }
+
+                if(is_array($value)){
+                    foreach($value as $key=>$decFormData){
+                        $model->$key = $decFormData;
+                    }
+                    // 把首购单的几个会员归集到一个数组里,将来绑定到一起
+                    if( $model->type == 'ZC'){
+                        $allZcUserIds[] = null;
+                        if($zcUserIdCard != null){
+                            if($model->insertUserIdCard != $zcUserIdCard){
+                                throw new Exception('Bulk declaration member must be the same member'); // 批量报单会员必须是同一身份证
+                            }
+                        } else {
+                            $zcUserIdCard = $model->insertUserIdCard;
+                        }
+                    }
+                    if(!$model->add($this->data)){
+                        throw new Exception(Form::formatErrorsForApi($model->getErrors()));
+                    }
+                } else {
+                    throw new Exception('The format of the report data is incorrect');// 报单数据格式错误
+                }
+            }
+            $transaction->commit();
+        } catch (\Exception $e){
+            $transaction->rollBack();
+            $this->addError('add', $e->getMessage());
+            return null;
+        }
+        return true;
+    }
+
+    /**
+     * RPC服务校验数据
+     * @param $data
+     * @return array
+     */
+    public static function rpcIsData($data){
+        $result = [
+            'error' => false,
+            'message' => 'Data can be reported',//数据可报单
+        ];
+        $formModel = new self();
+        $formModel->scenario = 'canDec';
+        $formModel->data = $data;
+        if(!$formModel->validate()){
+            $result['error'] = true;
+            $result['message'] = Form::formatErrorsForApi($formModel->getErrors());
+        }
+        return $result;
+    }
+}

+ 34 - 35
common/models/forms/BaUserForm.php

@@ -74,8 +74,8 @@ class BaUserForm extends Model
     {
         return [
             [['userId', 'userName', 'zcPv', 'zcAmount', 'conUserName', 'recUserName','conUid', 'recUid', 'location','nation','realName', 'mobile','openBank','bankAddress','bankNo', 'email'], 'trim'],
-            [['userId', 'userName', 'zcPv', 'zcAmount', 'conUid', 'recUid', 'location'], 'required', 'on'=>'addWithUid'],
-            [['userId', 'userName', 'zcPv', 'zcAmount', 'conUserName', 'recUserName', 'location'], 'required', 'on'=>['addWithUserName', 'addByAdmin']],
+            [['userId', 'userName',/* 'zcPv', 'zcAmount',*/ 'conUid', 'recUid', 'location'], 'required', 'on'=>'addWithUid'],
+            [['userId', 'userName',/* 'zcPv', 'zcAmount', 'conUserName',*/ 'recUserName',/* 'location'*/], 'required', 'on'=>['addWithUserName', 'addByAdmin']],
             [['idCard', 'allData'], 'required', 'on'=>['addWithUserName']],
             [['userName'], 'required', 'on'=>['validateUser', 'noLoginModifyPassword']],
             [['conUid'], 'required', 'on'=>['validateCon', 'validateAddWithUid']],
@@ -103,8 +103,8 @@ class BaUserForm extends Model
             [['recUserName'], 'isRec', 'on' => ['addWithUserName', 'addWithUid', 'addByAdmin']],
             [['location'], 'isLocation', 'on' => ['addWithUserName', 'addWithUid', 'addByAdmin']],
             //[['idCard'], 'isSameNetwork'],
-            [['zcPv', 'zcAmount'], 'price', 'on' => ['addWithUserName', 'addWithUid', 'addByAdmin']],
-            [['zcPv'], 'isMinDecLevel', 'on' => ['addWithUserName', 'addWithUid', 'addByAdmin']],
+            [[/*'zcPv',*/ 'zcAmount'], 'price', 'on' => ['addWithUserName', 'addWithUid', 'addByAdmin']],
+//            [['zcPv'], 'isMinDecLevel', 'on' => ['addWithUserName', 'addWithUid', 'addByAdmin']],
         ];
     }
 
@@ -112,10 +112,10 @@ class BaUserForm extends Model
     {
         return [
             'userId' => '会员ID',
-            'conUserName' => '接点人账号',
+//            'conUserName' => '接点人账号',
             'recUserName' => '开拓人帐号',
-            'location' => '区位',
-            'nation' => '民族',
+//            'location' => '区位',
+//            'nation' => '民族',
             //'realName' => '真实姓名',
 //            'idCard' => '身份证号',
             //'mobile' => '手机号',
@@ -191,17 +191,6 @@ class BaUserForm extends Model
         $oneRecUserInfo = BaUser::findOneAsArray('USER_NAME=:USER_NAME', [':USER_NAME'=>$this->recUserName]);
         if($oneRecUserInfo && $oneRecUserInfo['STATUS']){
             $this->_recUid = $oneRecUserInfo['ID'];
-            // 取消开拓的第一人必须放在自己的安置网下左区的需求
-//            if($this->scenario != 'addByAdmin'){
-//                // 查看该开拓者推荐的第一层人的数量
-//                $childNum = UserRelation::firstFloorChildNum($this->_recUid);
-//                if($childNum === 0){
-//                    // 必须放在自己的左区
-//                    if($this->location != 1 && $this->scenario != 'validateRecName'){
-//                        $this->addError($attribute, '注册'.$this->userName.'时,开拓人'.$this->recUserName.'开拓的第一人必须放在自己的安置网络下的左区');
-//                    }
-//                }
-//            }
         } else {
             $this->addError($attribute, '注册'.$this->userName.'时,开拓人'.$this->recUserName.'帐号无效或未激活');
         }
@@ -292,10 +281,10 @@ class BaUserForm extends Model
         }
         $insertUid = $this->userId;
         $insertUserName = $this->userName;
-        $zcPv = $this->zcPv;
-        $conUid = $this->_conUid;
+//        $zcPv = $this->zcPv;
+//        $conUid = $this->_conUid;
         $recUid = $this->_recUid;
-        $location = $this->location;
+//        $location = $this->location;
 
 //        $db = \Yii::$app->db;
 //        $transaction = $db->beginTransaction();
@@ -303,37 +292,45 @@ class BaUserForm extends Model
             $periodObj = Period::instance();
             $nowPeriodNum = $periodObj->getNowPeriodNum();
             // 查找接点人的体系信息
-            $conUserInfo = UserInfo::find()->where('USER_ID=:USER_ID', [':USER_ID'=>$conUid])->asArray()->one();
+//            $conUserInfo = UserInfo::find()->where('USER_ID=:USER_ID', [':USER_ID'=>$conUid])->asArray()->one();
             // 加入会员信息
-            $userInfoModel = new UserInfo();
+            $userInfoModel = new BaUserInfo();
             $userInfoModel->USER_ID = $insertUid;
             $userInfoModel->USER_NAME = $insertUserName;
-            $userInfoModel->ZC_PV = $zcPv;
+//            $userInfoModel->ZC_PV = $zcPv;
             $userInfoModel->ZC_AMOUNT = $this->zcAmount;
-            $userInfoModel->CON_UID = $conUid;
+//            $userInfoModel->CON_UID = $conUid;
             $userInfoModel->REC_UID = $recUid;
-            $userInfoModel->SYSTEM_ID = $conUserInfo['SYSTEM_ID'];
+//            $userInfoModel->SYSTEM_ID = $conUserInfo['SYSTEM_ID'];
             //$userInfoModel->PERIOD_NUM = $nowPeriodNum;
             $userInfoModel->CREATED_AT = Date::nowTime();
-            $userInfoModel->HIGHEST_EMP_LV = EmployLevel::getDefaultLevelId();
+//            $userInfoModel->HIGHEST_EMP_LV = EmployLevel::getDefaultLevelId();
             $userInfoModel->ALLOW_TRANSFER = 1;
-            $userInfoModel->HIGHEST_EMP_LV_PERIOD = $nowPeriodNum;
+//            $userInfoModel->HIGHEST_EMP_LV_PERIOD = $nowPeriodNum;
             $userInfoModel->TRANSFER_PROP = 100.00;
             $userInfoModel->IS_GROUP_LEADER = 0;
             $userInfoModel->GROUP_LEADER_AT = 0;
+            try {
+                print_r($userInfoModel);
+                $userInfoModel->save();
+                print_r('save');
+            }catch (Exception $e){
+                print_r($e);
+            }
+            exit;
             if(!$userInfoModel->save()){
                 throw new Exception('会员信息更新失败');
             }
             // 安置关系
-            $this->_addToNetwork();
+//            $this->_addToNetwork();
             // 开拓关系
-            $this->_addToRelation();
+//            $this->_addToRelation();
             // 把会员的网络深度也追加上
-            $userInfoModel->NETWORK_DEEP = $this->_conTopDeep;
-            $userInfoModel->RELATION_DEEP = $this->_recTopDeep;
-            if(!$userInfoModel->save()){
-                throw new Exception('会员网络深度更新失败');
-            }
+//            $userInfoModel->NETWORK_DEEP = $this->_conTopDeep;
+//            $userInfoModel->RELATION_DEEP = $this->_recTopDeep;
+//            if(!$userInfoModel->save()){
+//                throw new Exception('会员网络深度更新失败');
+//            }
             // 清空安置网络和开拓网络的顶点和顶点深度的数值
             $this->_conTopUid = null;
             $this->_conTopDeep = null;
@@ -343,6 +340,8 @@ class BaUserForm extends Model
 //            $transaction->commit();
             return $userInfoModel;
         } catch (Exception $e){
+            print_r($e);exit;
+            throw new Exception('a a a a a');
 //            $transaction->rollBack();
             $this->addError('userId', $e->getMessage());
             //echo $e->getMessage().PHP_EOL;

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

@@ -187,7 +187,7 @@ class DeclarationForm extends Model
      */
     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');//报单中心不存在
+            $this->addError($attribute, 'Stockist does not exist'); // 报单中心不存在
             return false;
         } else {
             // 判断报单中心是否在新加入会员的安置网上级中

+ 2 - 0
frontendApi/config/menu.php

@@ -40,6 +40,8 @@ return [
             ['name'=>'Order List', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'order-list', 'routePath'=>'shop/order-list', 'show'=>1,],//订单列表
             ['name'=>'Products list', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'/ba-product-list', 'routePath'=>'shop/ba-product-list', 'show'=>1, 'brandAmbassador' => 1],//BA商品列表
             ['name'=>'Order List', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'ba-order-list', 'routePath'=>'shop/ba-order-list', 'show'=>1, 'brandAmbassador' => 1],//BA订单列表
+            ['name'=>'Welcome Brand Ambassador', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'ba-dec', 'routePath'=>'user/ba-dec', 'show'=>1,'allow'=>'declarer',],
+            ['name'=>'Welcome BA List', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'ba-dec-order-list', 'routePath'=>'shop/ba-dec-order-list', 'show'=>1,'allow'=>'declarer',],
         ]
     ],
     'user'=>[

+ 3 - 0
frontendApi/config/urlManagerRules.php

@@ -85,6 +85,7 @@ return [
             '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',
         ],
     ],
     [
@@ -112,6 +113,8 @@ return [
             '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',
         ],
     ],
     [

+ 577 - 0
frontendApi/modules/v1/controllers/BaController.php

@@ -0,0 +1,577 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: leo
+ * Date: 2018/2/24
+ * Time: 下午12:48
+ */
+
+namespace frontendApi\modules\v1\controllers;
+
+use common\helpers\Cache;
+use common\helpers\Form;
+use common\helpers\Tool;
+use common\helpers\user\Info;
+use common\models\Config;
+use common\models\DeclarationLevel;
+use common\models\DeclarationPackage;
+use common\models\DecOrder;
+use common\models\forms\ApproachDeclarationLoopForm;
+use common\models\forms\ApproachDeclarationUpgradeForm;
+use common\models\forms\DeclarationForm;
+use common\models\forms\DeclarationLoopForm;
+use common\models\forms\UploadForm;
+use common\models\forms\UserBindForm;
+use common\models\forms\UserForm;
+use common\models\OpenBank;
+use common\models\ReceiveAddress;
+use common\models\Region;
+use common\models\ShopGoods;
+use common\models\UpgradeType;
+use common\models\User;
+use common\models\UserBind;
+use common\models\UserInfo;
+use common\models\UserNetwork;
+use common\models\forms\DeclarationUpgradeForm;
+use yii\db\Exception;
+use yii\web\UploadedFile;
+
+class BaController extends BaseController {
+    public $modelClass = BaUserInfo::class;
+
+    /**
+     * 会员资料
+     * @return mixed
+     * @throws \yii\web\HttpException
+     */
+    public function actionIndex() {
+        $allNation = \Yii::$app->params['nation'];
+        $allOpenBank = OpenBank::findAllAsArray('STATUS=1');
+        $data['allNation'] = $allNation;
+        $data['allOpenBank'] = $allOpenBank;
+        $data['userInfo'] = User::getEnCodeInfo(\Yii::$app->user->id);
+        $data['userInfo']['NATION'] = $data['userInfo']['NATION_ID'];
+        return static::notice($data);
+    }
+
+    /**
+     * 编辑会员资料
+     * @return mixed
+     * @throws \yii\web\HttpException
+     */
+    public function actionEdit() {
+        if(\Yii::$app->request->isPost){
+            $form = new UserForm();
+            $post = \Yii::$app->request->post();
+            $form->scenario = 'modifyProfile';
+            if($form->load($post, '') && $result = $form->modifyProfile()){
+                return static::notice('Personal data modified successfully');//个人资料修改成功
+            } else {
+                return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
+            }
+        }
+        return static::notice('Illegal request', 400); // 非法请求
+    }
+
+    /**
+     * 修改登录密码
+     */
+    public function actionPassword(){
+        if(\Yii::$app->request->isPost){
+            $form = new UserForm();
+            $form->scenario = 'modifyPassword';
+            $post = \Yii::$app->request->post();
+            if($form->load($post, '') && $result = $form->modifyPassword()){
+                return static::notice('Password modified successfully');//密码修改成功
+            } else {
+                return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
+            }
+        }
+        return static::notice('Illegal request', 400); // 非法请求
+    }
+
+    /**
+     * 修改支付密码
+     */
+    public function actionPayPassword(){
+        if(\Yii::$app->request->isPost){
+            $form = new UserForm();
+            $form->scenario = 'modifyPasswordPay';
+            $post = \Yii::$app->request->post();
+            $form->userId = \Yii::$app->user->id;
+            if($form->load($post, '') && $result = $form->modifyPasswordPay()){
+                return static::notice('支付密码修改成功');
+            } else {
+                return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
+            }
+        }
+        return static::notice('Illegal request', 400); // 非法请求
+    }
+
+    /**
+     * 直推会员列表
+     * @return mixed
+     * @throws \yii\web\HttpException
+     */
+    public function actionRecUser() {
+        $allData = UserInfo::lists('AND REC_UID=:REC_UID', [':REC_UID' => \Yii::$app->user->id], ['useSlaves' => true, 'select'=>'USER_ID,CREATED_AT']);
+        foreach ($allData['list'] as $key => $data) {
+            $userBaseInfo = User::getEnCodeInfo($data['USER_ID']);
+            $userBaseInfo['NATION'] = \Yii::$app->params['nation'][$userBaseInfo['NATION']]['name'] ?? '';
+            $allData['list'][$key]['BASE_INFO'] = $userBaseInfo;
+        }
+        return static::notice($allData);
+    }
+
+    /**
+     * 上传身份证
+     * @return mixed
+     * @throws \yii\base\Exception
+     * @throws \yii\web\HttpException
+     */
+    public function actionIdCard() {
+        if (\Yii::$app->request->isPost) {
+            $formModel = new UploadForm();
+            $formModel->scenario = 'idCardFront';
+            $formModel->file = UploadedFile::getInstanceByName('file');
+            //$formModel->token = \Yii::$app->request->post('uploadToken');
+            $formModel->token = \Yii::$app->request->request('uploadToken');
+            if ($formModel->file && $formModel->upload()) {
+                return static::notice('Successful');
+            } else {
+                return static::notice(Form::formatErrorsForApi($formModel->getErrors()), 400);
+            }
+        }
+        // 查看该用户是否已经上传过身份证
+        $oneData = User::find()->select('ID_IMAGE')->where('ID=:ID', [':ID' => \Yii::$app->user->id])->asArray()->one();
+        if ($oneData['ID_IMAGE']) {
+            return static::notice($oneData);
+        } else {
+            $token = Cache::setUploadToken();
+            return static::notice($token);
+        }
+    }
+
+    /**
+     * 点位绑定
+     * @return mixed
+     * @throws \yii\base\Exception
+     * @throws \yii\web\HttpException
+     */
+    public function actionBind() {
+        $userBind = UserBind::findOneAsArray('USER_ID=:USER_ID AND IS_DEL=0', [':USER_ID' => \Yii::$app->user->id]);
+        $allData['list']=UserBind::findAllAsArray('MAIN_UID=:MAIN_UID AND IS_DEL=0', [':MAIN_UID' => $userBind['MAIN_UID']], 'ID,USER_ID,MAIN_UID,CREATED_AT,UPDATED_AT');
+        foreach ($allData['list'] as $key => $value) {
+            $baseInfo = Info::baseInfoZh($value['USER_ID']);
+            if ($baseInfo['STATUS'] != 1) {
+                unset($allData['list'][$key]);
+                continue;
+            }
+            $allData['list'][$key]['USER_NAME'] = $baseInfo['USER_NAME'];
+            $allData['list'][$key]['REAL_NAME'] = $baseInfo['REAL_NAME'];
+            $allData['list'][$key]['BANK_PROVINCE_NAME'] = $baseInfo['BANK_PROVINCE_NAME'];
+            $allData['list'][$key]['BANK_CITY_NAME'] = $baseInfo['BANK_CITY_NAME'];
+            $allData['list'][$key]['BANK_COUNTY_NAME'] = $baseInfo['BANK_COUNTY_NAME'];
+            $allData['list'][$key]['OPEN_BANK_NAME'] = $baseInfo['OPEN_BANK_NAME'];
+            $allData['list'][$key]['BANK_NO'] = $baseInfo['BANK_NO'];
+            $allData['list'][$key]['MAIN_USER_NAME'] =Info::getUserNameByUserId($value['MAIN_UID']);
+        }
+        $allData['list'] = array_values($allData['list']);
+        return static::notice($allData);
+    }
+
+    /**
+     * 编辑点位绑定
+     * @return mixed
+     * @throws \yii\web\HttpException
+     */
+    public function actionBindEdit(){
+        $id = \Yii::$app->request->get('id');
+        if(\Yii::$app->request->isPost) {
+            return parent::edit(UserBindForm::class, '修改主点位成功', 'frontEdit', ['frontEdit'], null, function($form, $result){
+                //log
+            });
+        }
+        // 获得当前会员的用户名等信息
+        $userBind = UserBind::findOneAsArray('ID=:ID AND IS_DEL=0', [':ID' => $id]);
+        $userBinds = UserBind::findAllAsArray('MAIN_UID=:MAIN_UID AND IS_DEL=0',[':MAIN_UID'=>$userBind['MAIN_UID']], 'ID,USER_ID,MAIN_UID,CREATED_AT,UPDATED_AT');
+        foreach($userBinds as $key=>$value){
+            $status = Info::getStatusByUserId($value['USER_ID']);
+            if ($status != 1) {
+                unset($userBinds[$key]);
+                continue;
+            }
+            $userBinds[$key]['USER_NAME'] = Info::getUserNameByUserId($value['USER_ID']);
+
+        }
+        $userBinds = array_values($userBinds);
+        return static::notice(['userBinds' => $userBinds,'mainUid'=>$userBind['MAIN_UID']]);
+    }
+
+    // 会员升级,通过会员的编号,获取会员信息
+    public function actionUpgradeInfo() {
+        $isSwitchUpgrade = Config::find()
+        ->where("CONFIG_NAME='isOpenUpgrade'")
+        ->asArray()
+        ->one();
+        $isOpen = !empty($isSwitchUpgrade) && isset($isSwitchUpgrade['VALUE']) ? $isSwitchUpgrade['VALUE'] : 0;
+        if ($isOpen < 1) {
+            return static::notice('The function is not available',400); // 功能暂未开放
+        }
+        $userNumber = \Yii::$app->request->request('userName');
+        $baseInfo = Info::baseInfoZhByUserName($userNumber);
+        if ($baseInfo['STATUS'] != 1) {
+            return static::notice('Inactive user. Please contact customer service.',400);// 非激活用户,请联系客服
+        }
+        // 1. 如果是最高级别,则只显示用户基本信息
+        // 2. 如果不是最高级别,如果用户累计报单数据是0, 或者用户累计报单业绩不符合级别信息,则提示 请联系客服核对业绩
+        $userId = $baseInfo['ID'];
+        $userDecId = $baseInfo['DEC_LV'];// 用户当前的级别
+        // 获取系统中的DEC 报单级别配置
+        $decConfig = Cache::getDecLevelConfig();
+        $userDecInfo = $decConfig[$userDecId]; // 会员的级别具体信息
+        $maxPerfInfo = DeclarationLevel::getMaxDecPref(); 
+        $maxDecId = $maxPerfInfo['ID']; // 级别配置中最高级别ID
+        $observe = Config::getConfigByType('observe'); // 获取观察期配置信息
+        $observeLimit = $observe['observePeriodLimit']['value']; // 月份限制
+        $isObserve = User::checkIsObserve($baseInfo['CREATED_AT'], $observeLimit); // 判断用户是否再观察期中
+        // 如果用户已经是最高级别,则只展示用户信息
+        $isMax = false;
+        if ($maxDecId == $userDecId) {
+            $isMax = true;
+        }
+        // 如果用户已经是最高级别,则只展示用户信息
+        $userInfo = [
+            'DEC_NAME' => $baseInfo['DEC_LV_NAME'], // 用户级别中文
+            'DEC_ID' => $userDecId, // 用户级别id
+            'REAL_NAME' => $baseInfo['REAL_NAME'], // 真实姓名
+            'ADD_AT' => date('Y-m-d', $baseInfo['CREATED_AT']), // 加入时间
+            'IS_OBSERVE' => $isObserve, // 是否是观察期  true为是观察期
+            'IS_MAX' => $isMax, // 是否已是最大级别 最大级别不需要判断报单总PV是多少 只展示基本信息
+        ];
+        
+        // 如果是最高级别了,则无需升级
+        if ($isMax) {
+            return static::notice(['baseInfo' => $userInfo]);
+        }
+
+        $levelPerf = $userDecInfo['PERF'];// 用户当前级别对应的业绩值
+        if (!$isMax) {
+            $userDecPvSum = User::sumDevPvByUserId($userId); // 用户所有报单PV总和
+            // // 如果总和小于级别业绩 去掉这校验直接补比如3000-980的差值
+            // if ($userDecPvSum < $levelPerf) {
+            //     return static::notice('请联系客服人员核对业绩',400);
+            // }
+            // 下一级业绩
+            $nextLevelPerf = DeclarationLevel::getNextDecPref($levelPerf)['PERF'];
+            // 如果总和超过了下一级业绩
+            if ($userDecPvSum >= $nextLevelPerf) {
+                return static::notice('Please contact customer service to check performance.',400);// 请联系客服人员核对业绩
+            }
+            $type = $isObserve ? 1 : 2;
+            $userInfo['UPGRADE_FUNC'] = $isObserve ? 'filling up of a deficit' : 'full payment';// 升级方式
+            $upgradeType = UpgradeType::getOneByType($type);
+            // 如果用户不是最大级别,则需要获取是否观察期,算出PV是否有问题,应该补多少,
+            $userInfo['UPGRADE_TYPE'] = $upgradeType;
+            $userInfo['NOW_PERF'] = $userDecPvSum;
+            $userInfo['NEXT_PERF'] =  $nextLevelPerf;
+            // 用户可选择的级别列表
+            $userInfo['LEVEL_LIST'] = DeclarationLevel::getNextAll($levelPerf);// 用户可选择的级别列表
+            // 循环列表,补充升级所需要的补差
+            foreach ($userInfo['LEVEL_LIST'] as &$v) {
+                $v['REPAIR_PV'] = $isObserve ? $v['PERF'] - $userInfo['NOW_PERF'] : $v['PERF'];
+            }   
+        }
+        
+        return static::notice(['baseInfo' => $userInfo]);
+    }
+    
+    // 会员升级管理
+    public function actionUpgrade() {
+        $isSwitchUpgrade = Config::find()
+        ->where("CONFIG_NAME='isOpenUpgrade'")
+        ->asArray()
+        ->one();
+        $isOpen = !empty($isSwitchUpgrade) && isset($isSwitchUpgrade['VALUE']) ? $isSwitchUpgrade['VALUE'] : 0;
+        if ($isOpen < 1) {
+            return static::notice('功能暂未开放',400);
+        }
+        // 开始升级
+        if (\Yii::$app->request->isPost) {
+            $post = \Yii::$app->request->post();
+            // 根据支付方式区分逻辑
+            $payMethod = \Yii::$app->request->post('payType', '');
+            if ($payMethod === 'pay_stack') {
+                $formModel = new ApproachDeclarationUpgradeForm();
+            } else {
+                unset($post['payType']);
+                $formModel = new DeclarationUpgradeForm();
+            }
+
+            $post['type'] = DeclarationForm::TYPE_ZC;
+            if ($formModel->load($post, '') && $result = $formModel->add($post)) {
+                return static::notice($result);// Upgrade declaration succeeded升级报单成功
+            } else {
+                return static::notice(Form::formatErrorsForApi($formModel->getErrors()),400);
+            }
+        }
+
+        //所有报单套餐
+        $allDecPackage = DeclarationPackage::getAllData();
+        $decLevels = Cache::getDecLevelConfig();
+        foreach ($allDecPackage as $k=>$v){
+            $levelName = $decLevels[$v['LEVEL_ID']]['LEVEL_NAME'] ?? '';
+            $allDecPackage[$k]['LEVEL_NAME'] = $levelName;
+        }
+        //所有自选商品
+        $isDecReg = Cache::getSystemConfig()['isDecReg']['VALUE'];
+        $isDec = User::getEnCodeInfo(\Yii::$app->user->id)['IS_DEC'];
+        $isStudio = User::getEnCodeInfo(\Yii::$app->user->id)['IS_STUDIO'];
+        $decUserName = User::getEnCodeInfo(\Yii::$app->user->id)['USER_NAME'];
+        $query_condition= " AND (1<>1";
+        if(!$isDecReg || ($isDecReg && $isDec==1)){
+            $query_condition = " AND (FIND_IN_SET(1,GIFT_TYPE)>0";
+        }
+        if($isStudio==1){
+            $query_condition.= " OR FIND_IN_SET(3,GIFT_TYPE)>0";
+        }
+        $query_condition.= ")";
+
+        $allGoods = ShopGoods::find()->where("STATUS=1 AND CATEGORY_TYPE=1 " . $query_condition)->orderBy('SORT ASC')->asArray()->all();
+        foreach ($allGoods as &$goods) {
+            $goods['TAX'] = Tool::calculateTax($goods['SELL_PRICE'], $goods['TAX_RATE']);
+        }
+
+        return static::notice([
+            'allDecPackage' => $allDecPackage,
+            'allGoods' => $allGoods,
+            'decUserName'=>$decUserName,
+            'payList' => ShopGoods::payTypes(),
+            'sellType' => ShopGoods::CATEGORY_TYPE,
+            'categoryType' => ShopGoods::CATEGORY_TYPE[0]['id'],
+        ]);
+    }
+
+    /**
+     * 报单管理
+     */
+    public function actionDec() {
+        // 生成随机码 , 初始化redis
+        $userName = Info::generateWebUserName('NG',9);
+        $redis = \Yii::$app->redis;
+        $post = \Yii::$app->request->post();
+
+        if (\Yii::$app->request->isPost) {
+            // 根据支付方式区分逻辑
+            $payMethod = \Yii::$app->request->post('payType', '');
+
+            if ($payMethod === 'pay_stack') {
+                $formModel = new ApproachDeclarationLoopForm();
+            } else {
+                unset($post['payType']);
+                $formModel = new DeclarationLoopForm();
+            }
+
+            $formModel->scenario = 'userDec';
+
+            $post['province'] = $post['province'] ? :1;
+            $post['city'] = $post['city'] ? :1;
+            $post['county'] = $post['county'] ? :1;
+            $post['conUserName'] = trim($post['conUserName']);
+            $post['recUserName'] = trim($post['recUserName']);
+            $post['cityName'] = trim($post['cityName']);
+            $post['lgaName'] = trim($post['lgaName']);
+
+            // 针对于会员编号的判断
+            $insertUserName = strtoupper($post['insertUserName']);
+            $getRedisUserName = $redis->get('key_' . $insertUserName);
+            if (!$getRedisUserName){
+                return static::notice('Membership number expired',400);//会员编号过期
+            }
+            if ($insertUserName != $getRedisUserName){
+                return static::notice('Member number does not conform to',400);//会员编号不符合
+            }
+
+            $post['insertUserName'] = $insertUserName;
+            $post['type'] = DeclarationForm::TYPE_ZC;
+            $allData['data'][] = $post;
+            if ($formModel->load($allData, '') && $result = $formModel->add()) {
+                return static::notice($result);//报单成功
+            } else {
+                return static::notice(Form::formatErrorsForApi($formModel->getErrors()),400);
+            }
+        }
+
+        //所有报单套餐
+        $allDecPackage = DeclarationPackage::getAllData();
+        $decLevels = Cache::getDecLevelConfig();
+        foreach ($allDecPackage as $k=>$v){
+            $levelName = $decLevels[$v['LEVEL_ID']]['LEVEL_NAME'] ?? '';
+            $allDecPackage[$k]['LEVEL_NAME'] = $levelName;
+        }
+        //所有自选商品
+        $isDecReg = Cache::getSystemConfig()['isDecReg']['VALUE'];
+        $isDec = User::getEnCodeInfo(\Yii::$app->user->id)['IS_DEC'];
+        $isStudio = User::getEnCodeInfo(\Yii::$app->user->id)['IS_STUDIO'];
+        $query_condition= " AND (1<>1";
+        if(!$isDecReg || ($isDecReg && $isDec==1)){
+            $query_condition = " AND (FIND_IN_SET(1,GIFT_TYPE)>0";
+        }
+        if($isStudio==1){
+            $query_condition.= " OR FIND_IN_SET(3,GIFT_TYPE)>0";
+        }
+        $query_condition.= ")";
+        // 只查询普通商品
+        $allGoods = ShopGoods::find()->where("STATUS=1 AND CATEGORY_TYPE=1".$query_condition)->orderBy('SORT ASC')->asArray()->all();
+
+        //$allGoods = ShopGoods::findAllAsArray('STATUS=1');
+        // 所有开户行
+        $allOpenBank = OpenBank::find()->where('STATUS=1')->orderBy('LIST_ORDER ASC')->asArray()->all();
+        if (!$userName) {
+            return static::notice('Failed to generate member number', 400);//会员编号生成失败
+        }
+        //随机码保存在redis中方便进行比对
+        $redis->setex('key_'.$userName , 3600 , $userName);
+
+        return static::notice([
+            'allDecPackage' => $allDecPackage,
+            'allGoods' => $allGoods,
+            'allOpenBank' => $allOpenBank,
+            'userName' => $userName,
+            'payList' => ShopGoods::payTypes(),
+            'sellType' => ShopGoods::CATEGORY_TYPE,
+            'categoryType' => ShopGoods::CATEGORY_TYPE[0]['id'],
+            ]);
+    }
+
+    /**
+     * 报单级别套餐
+     */
+    public function actionDecPackage() {
+        $decLv = \Yii::$app->request->get('id');
+        //所有报单级别套餐
+        $allDecPackage = DeclarationPackage::getPackageFromLevelId($decLv);
+        return static::notice(['allDecPackage' => $allDecPackage]);
+
+    }
+
+    /*
+     * 从会员名和左右,获取底部安置人
+     *
+     */
+    public function actionGetAutoPlace() {
+        $userName = \Yii::$app->request->get('userName');
+        $side = \Yii::$app->request->get('side');
+        $userId = Info::getUserIdByUserName($userName);
+//        print_r($userId);
+        $bottomPlace = UserNetwork::getBottomPlace($userId,'', $side);
+        $bottomUser = UserNetwork::find()->select('USER_ID')->where('LOCATION_TAG=:LOCATION_TAG', ['LOCATION_TAG' => $bottomPlace])->asArray()->one();
+        $bottomUser = User::findOneAsArray('ID=:ID', [':ID' => $bottomUser['USER_ID']], 'USER_NAME');
+//        print_r($bottomUser);
+        return static::notice($bottomUser);
+    }
+
+    /**
+     * 会员信息查询
+     * @return mixed
+     * @throws \yii\web\HttpException
+     */
+    public function actionFullInfo()
+    {
+        $userName = \Yii::$app->request->get('userName');
+        $userId = Info::getUserIdByUserName($userName);
+        $userInfo['REAL_NAME'] = '';
+        $user = User::findOneAsArray('ID=:ID', [':ID' => $userId], 'REAL_NAME');
+        if($user){
+            $userInfo['REAL_NAME'] = $user['REAL_NAME'];
+            $allChildUser = UserNetwork::getFirstFloorChildren($userId);
+            $isLocation = [1 => 'Left-', 2 => 'Right-'];
+            if($allChildUser) {
+                foreach ($allChildUser as $child) {
+                    if ($child['RELATIVE_LOCATION']<'3'){
+                        $isLocation[$child['RELATIVE_LOCATION']].= 'Full';
+                    }
+                }
+            }
+            $userInfo['isLocation'] = '('.implode(',',$isLocation).')';
+            return static::notice($userInfo);
+        }else{
+            return static::notice('Member number does not exist', 400);//会员编号不存在
+        }
+    }
+
+    /**
+     * 复消会员信息查询
+     * @return mixed
+     * @throws \yii\web\HttpException
+     */
+    public function actionUserBaseInfo()
+    {
+        $userName = \Yii::$app->request->get('userName');
+        $userId = Info::getUserIdByUserName($userName);
+        if($userId){
+            $allAddress = ReceiveAddress::findAllAsArray('USER_ID=:USER_ID', [':USER_ID'=>$userId]);
+            if($allAddress) {
+                foreach ($allAddress as $key => $row) {
+                    $allAddress[$key]['PROVINCE_NAME'] = Region::getCnName($row['PROVINCE']);
+                    $allAddress[$key]['CITY_NAME'] = Region::getCnName($row['CITY']);
+                    $allAddress[$key]['COUNTY_NAME'] = Region::getCnName($row['COUNTY']);
+                }
+            }
+
+            $userInfo = Info::baseInfoWithNet($userId);
+//            $decLevelConfig = Cache::getDecLevelConfig();
+//            $empLevelConfig = Cache::getEmpLevelConfig();
+
+            $arr = [
+                'REAL_NAME'=>$userInfo['REAL_NAME'],
+//                'DEC_LEVEL_NAME' => $decLevelConfig[$userInfo['DEC_LV']]['LEVEL_NAME'],
+//                'EMP_LEVEL_NAME'=>$empLevelConfig[$userInfo['EMP_LV']]['LEVEL_NAME'],
+//                'REC_UID'=>$userInfo['REC_USER_NAME'].'('.$userInfo['REC_REAL_NAME'].')',
+//                'CON_UID'=>$userInfo['CON_USER_NAME'].'('.$userInfo['CON_REAL_NAME'].')',
+                'allAddress'=>$allAddress
+            ];
+            return static::notice($arr);
+        }else{
+            return static::notice('Repeat sales Member No. does not exist', 400);//复消会员编号不存在
+        }
+    }
+
+    /**
+     * 会员资料
+     * @return mixed
+     * @throws \yii\web\HttpException
+     */
+    public function actionBaInfo()
+    {
+        $allNation = \Yii::$app->params['nation'];
+        $allOpenBank = OpenBank::findAllAsArray('STATUS=1');
+        $data['allNation'] = $allNation;
+        $data['allOpenBank'] = $allOpenBank;
+        $data['userInfo'] = User::getEnCodeInfo(\Yii::$app->user->id);  // TODO
+        $data['userInfo']['NATION'] = $data['userInfo']['NATION_ID'];
+        return static::notice($data);
+    }
+
+    /**
+     * 编辑会员资料
+     * @return mixed
+     * @throws \yii\web\HttpException
+     */
+    public function actionBaEdit()
+    {
+        if(\Yii::$app->request->isPost)
+        {
+            $form = new UserForm();
+            $post = \Yii::$app->request->post();
+            $form->scenario = 'modifyProfile';
+            if ($form->load($post, '') && $result = $form->modifyProfile()){
+                return static::notice('Personal data modified successfully');//个人资料修改成功
+            } else {
+                return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
+            }
+        }
+
+        return static::notice('Illegal request', 400); // 非法请求
+    }
+}

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

@@ -15,6 +15,7 @@ use common\helpers\LoggerTool;
 use common\helpers\Tool;
 use common\helpers\user\Info;
 use common\models\ApproachDecOrder;
+use common\models\BaApproachDecOrder;
 use common\models\ApproachOrder;
 use common\models\ApproachOrderGoods;
 use common\models\BaApproachOrder;
@@ -24,6 +25,7 @@ use common\models\BaOrderGoods;
 use common\models\BaReceiveAddress;
 use common\models\BaUser;
 use common\models\DecOrder;
+use common\models\BaDecOrder;
 use common\models\forms\ApproachOrderForm;
 use common\models\forms\BaApproachOrderForm;
 use common\models\forms\DeclarationForm;
@@ -1156,4 +1158,65 @@ ORDER;
 
         return static::notice($data);
     }
+
+    /**
+     * 我的BA报单
+     * @return mixed
+     * @throws HttpException
+     */
+    public function actionBaDecOrderList() {
+        $condition = ' DO.USER_ID=:USER_ID AND DO.IS_DEL=0';
+        $params[':USER_ID'] = \Yii::$app->user->id;
+
+        $orderQuery = BaDecOrder::find()
+            ->alias('DO')
+            ->where($condition, $params)
+            ->select('DO.*,O.STATUS,U.USER_NAME USER_NAME,U.REAL_NAME REAL_NAME,RU.USER_NAME REC_USER_NAME,RU.REAL_NAME REC_REAL_NAME,CU.USER_NAME CON_USER_NAME,CU.REAL_NAME CON_REAL_NAME,OG.SKU_CODE,OG.GOODS_TITLE,OG.BUY_NUMS,OG.REAL_PRICE,OG.REAL_PV,OG.TAX_RATE')
+            ->join('LEFT JOIN', BaUser::tableName() . ' AS U', 'DO.TO_USER_ID=U.ID')
+            ->join('LEFT JOIN', BaUser::tableName() . ' AS RU', 'DO.REC_USER_ID=RU.ID')
+            ->join('LEFT JOIN', BaUser::tableName() . ' AS CU', 'DO.CON_USER_ID=CU.ID')
+            ->join('LEFT JOIN', BaOrderGoods::tableName() . ' AS OG', 'OG.ORDER_SN=DO.ORDER_SN')
+            ->join('LEFT JOIN', BaOrder::tableName() . ' AS O', 'O.SN=DO.ORDER_SN')
+            ->orderBy('DO.CREATED_AT DESC');
+
+        // 订单中间表只查询待支付和支付失败的订单
+        $params[':NOT_PAID'] = \Yii::$app->params['orderStatus']['notPaid']['value'];   // 待支付
+        $params[':FAIL_PAID'] = \Yii::$app->params['orderStatus']['failPaid']['value'];   // 支付失败
+        $orderStandardQuery = BaApproachDecOrder::find()
+            ->alias('DO')
+            ->where($condition . ' AND (O.STATUS = :NOT_PAID OR O.STATUS = :FAIL_PAID)', $params)
+            ->select('DO.*,O.STATUS,U.USER_NAME USER_NAME,U.REAL_NAME REAL_NAME,RU.USER_NAME REC_USER_NAME,RU.REAL_NAME REC_REAL_NAME,CU.USER_NAME CON_USER_NAME,CU.REAL_NAME CON_REAL_NAME,OG.SKU_CODE,OG.GOODS_TITLE,OG.BUY_NUMS,OG.REAL_PRICE,OG.REAL_PV,OG.TAX_RATE')
+            ->join('LEFT JOIN', BaUser::tableName() . ' AS U', 'DO.TO_USER_ID=U.ID')
+            ->join('LEFT JOIN', BaUser::tableName() . ' AS RU', 'DO.REC_USER_ID=RU.ID')
+            ->join('LEFT JOIN', BaUser::tableName() . ' AS CU', 'DO.CON_USER_ID=CU.ID')
+            ->join('LEFT JOIN', BaApproachOrderGoods::tableName() . ' AS OG', 'OG.ORDER_SN=DO.ORDER_SN')
+            ->join('LEFT JOIN', BaApproachOrder::tableName() . ' AS O', 'O.SN=DO.ORDER_SN')
+            ->orderBy('DO.CREATED_AT DESC');
+
+        $queryAll = $orderQuery->union($orderStandardQuery, true);
+        $query = (new Query())->from(['Q' => $queryAll])->select('Q.*')->distinct()->orderBy(['CREATED_AT' => SORT_DESC]);
+
+        $totalCount = $query->count();
+        $pagination = new Pagination(['totalCount' => $totalCount, 'pageSize' => \Yii::$app->request->get('pageSize')]);
+        $lists = $query->offset($pagination->offset)->limit($pagination->limit)->all();
+
+        $data = [
+            'list' => $lists,
+            'currentPage'=>$pagination->page,
+            'totalPages'=>$pagination->pageCount,
+            'startNum' => $pagination->page * $pagination->pageSize + 1,
+            'totalCount' => $pagination->totalCount,
+            'pageSize' => $pagination->pageSize,
+        ];
+
+        foreach ($data['list'] as &$value) {
+            $value['TAX_AMOUNT'] = Tool::calculateTax($value['REAL_PRICE'], floatval($value['TAX_RATE']), intval($value['BUY_NUMS']));
+            $value['STATUS'] = \Yii::$app->params['orderStatus'][$value['STATUS']]['label'] ?? '';
+            $value['CREATED_AT'] = $value['CREATED_AT'] ? Date::convert($value['CREATED_AT'],'Y-m-d H:i:s') : '';
+            $value['REAL_PV'] = Tool::formatPrice($value['REAL_PV'] * $value['BUY_NUMS']);
+            $value['TOTAL_AMOUNT'] = Tool::formatPrice($value['REAL_PRICE'] * $value['BUY_NUMS']);
+        }
+
+        return static::notice($data);
+    }
 }

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

@@ -195,6 +195,8 @@ class SiteController extends BaseController
      * 是否BA会员: 未转正 && 在BA用户表有存在
      */
     private function _whetherBA() {
+
+//        return true;
         // 是否正式会员
         if (User::find()->where('ID = :USER_ID', [':USER_ID' => \Yii::$app->user->id])->exists()) {
             return false;

+ 126 - 7
frontendApi/modules/v1/controllers/UserController.php

@@ -18,10 +18,13 @@ use common\models\DeclarationLevel;
 use common\models\DeclarationPackage;
 use common\models\DecOrder;
 use common\models\forms\ApproachDeclarationLoopForm;
+use common\models\forms\BaApproachDeclarationLoopForm;
 use common\models\forms\ApproachDeclarationUpgradeForm;
 use common\models\forms\BaUserForm;
 use common\models\forms\DeclarationForm;
+use common\models\forms\BaDeclarationForm;
 use common\models\forms\DeclarationLoopForm;
+use common\models\forms\BaDeclarationLoopForm;
 use common\models\forms\UploadForm;
 use common\models\forms\UserBindForm;
 use common\models\forms\UserForm;
@@ -33,6 +36,7 @@ use common\models\UpgradeType;
 use common\models\User;
 use common\models\UserBind;
 use common\models\UserInfo;
+use common\models\BaUserInfo;
 use common\models\UserNetwork;
 use common\models\forms\DeclarationUpgradeForm;
 use yii\db\Exception;
@@ -385,17 +389,23 @@ class UserController extends BaseController {
             $post['lgaName'] = trim($post['lgaName']);
 
             // 针对于会员编号的判断
-            $insertUserName = strtoupper($post['insertUserName']);
-            $getRedisUserName = $redis->get('key_' . $insertUserName);
-            if (!$getRedisUserName){
-                return static::notice('Membership number expired',400);//会员编号过期
-            }
-            if ($insertUserName != $getRedisUserName){
-                return static::notice('Member number does not conform to',400);//会员编号不符合
+            if($post['decType']=='normal'){ // 普通报单,判断Redis中的用户名是否一致
+                $insertUserName = strtoupper($post['insertUserName']);
+                $getRedisUserName = $redis->get('key_' . $insertUserName);
+                if (!$getRedisUserName){
+                    return static::notice('Membership number expired',400);//会员编号过期
+                }
+                if ($insertUserName != $getRedisUserName){
+                    return static::notice('Member number does not conform to',400);//会员编号不符合
+                }
+            }else{ // BA升级,需要判断BA用户是否存在
+                $insertUserName = $post['insertUserName'];
             }
 
             $post['insertUserName'] = $insertUserName;
             $post['type'] = DeclarationForm::TYPE_ZC;
+
+            unset($post['decType']);
             $allData['data'][] = $post;
             if ($formModel->load($allData, '') && $result = $formModel->add()) {
                 return static::notice($result);//报单成功
@@ -611,4 +621,113 @@ class UserController extends BaseController {
         }
         return static::notice('Illegal request', 400); // 非法请求
     }
+    
+    /**
+     * BA报单管理
+     */
+    public function actionBaDec() {
+        // 生成随机码 , 初始化redis
+        $userName = Info::generateWebUserName('NG',9);
+        $redis = \Yii::$app->redis;
+        $post = \Yii::$app->request->post();
+
+        if (\Yii::$app->request->isPost) {
+            // 根据支付方式区分逻辑
+            $payMethod = \Yii::$app->request->post('payType', '');
+
+            if ($payMethod === 'pay_stack') {
+                $formModel = new BaApproachDeclarationLoopForm();
+            } else {
+                unset($post['payType']);
+                $formModel = new BaDeclarationLoopForm();
+            }
+
+            $formModel->scenario = 'userDec';
+
+            $post['province'] = $post['province'] ? :1;
+            $post['city'] = $post['city'] ? :1;
+            $post['county'] = $post['county'] ? :1;
+//            $post['conUserName'] = trim($post['conUserName']);
+            $post['recUserName'] = trim($post['recUserName']);
+            $post['cityName'] = trim($post['cityName']);
+            $post['lgaName'] = trim($post['lgaName']);
+
+            // 针对于会员编号的判断
+            $insertUserName = strtoupper($post['insertUserName']);
+            $getRedisUserName = $redis->get('key_' . $insertUserName);
+            if (!$getRedisUserName){
+                return static::notice('Membership number expired',400); // 会员编号过期
+            }
+            if ($insertUserName != $getRedisUserName){
+                return static::notice('Member number does not conform to',400); // 会员编号不符合
+            }
+
+            $post['insertUserName'] = $insertUserName;
+            $post['type'] = BaDeclarationForm::TYPE_ZC;
+            $allData['data'][] = $post;
+            if ($formModel->load($allData, '') && $result = $formModel->add()) {
+                return static::notice($result); // 报单成功
+            } else {
+                return static::notice(Form::formatErrorsForApi($formModel->getErrors()),400);
+            }
+        }
+
+        //所有自选商品
+        $isDecReg = Cache::getSystemConfig()['isDecReg']['VALUE'];
+        $isDec = User::getEnCodeInfo(\Yii::$app->user->id)['IS_DEC'];
+        $isStudio = User::getEnCodeInfo(\Yii::$app->user->id)['IS_STUDIO'];
+        $query_condition= " AND (1<>1";
+        if(!$isDecReg || ($isDecReg && $isDec==1)){
+            $query_condition = " AND (FIND_IN_SET(1,GIFT_TYPE)>0";
+        }
+        if($isStudio==1){
+            $query_condition.= " OR FIND_IN_SET(3,GIFT_TYPE)>0";
+        }
+        $query_condition.= ")";
+        // 只查询普通商品
+        $allGoods = ShopGoods::find()->where("STATUS=1 AND CATEGORY_TYPE=1 AND ID='399659569762144384'".$query_condition)->orderBy('SORT ASC')->asArray()->all();
+
+        //$allGoods = ShopGoods::findAllAsArray('STATUS=1');
+        // 所有开户行
+//        $allOpenBank = OpenBank::find()->where('STATUS=1')->orderBy('LIST_ORDER ASC')->asArray()->all();
+        if (!$userName) {
+            return static::notice('Failed to generate member number', 400); // 会员编号生成失败
+        }
+        //随机码保存在redis中方便进行比对
+        $redis->setex('key_'.$userName , 3600 , $userName);
+
+        return static::notice([
+//            'allDecPackage' => $allDecPackage,
+            'allGoods' => $allGoods,
+//            'allOpenBank' => $allOpenBank,
+            'userName' => $userName,
+            'payList' => ShopGoods::payTypes(),
+            'sellType' => ShopGoods::CATEGORY_TYPE,
+            'categoryType' => ShopGoods::CATEGORY_TYPE[0]['id'],
+        ]);
+    }
+
+    /**
+     * BA会员信息
+     * @return mixed
+     * @throws \yii\web\HttpException
+     */
+    public function actionBaUserInfo()
+    {
+        $userName = \Yii::$app->request->get('userName');
+        $userId = Info::getBaUserIdByUserName($userName);
+        $userInfo['REAL_NAME'] = '';
+        $user = BaUser::findOneAsArray('ID=:ID', [':ID' => $userId], 'REAL_NAME');
+        $uInfo = BaUserInfo::findOneAsArray('USER_ID=:USER_ID', [':USER_ID' => $userId], 'REC_UID');
+//        print_r($user);exit;
+        $rec_user = UserInfo::findOneAsArray('USER_ID=:USER_ID',[':USER_ID' => $uInfo['REC_UID']], 'USER_ID, USER_NAME');
+        if($user){
+            $userInfo['REAL_NAME'] = $user['REAL_NAME'];
+            $userInfo['REC_USER_ID'] = $rec_user['USER_ID'];
+            $userInfo['REC_USER_NAME'] = $rec_user['USER_NAME'];
+            return static::notice($userInfo);
+        }else{
+            return static::notice('Member number does not exist', 400);//会员编号不存在
+        }
+    }
 }

+ 335 - 327
frontendEle/src/router/index.js

@@ -4,9 +4,9 @@ import layout from '../views/layout/layout'
 
 const _import = require('./_import_' + process.env.NODE_ENV)
 
-if(Router.version >= '3.1.0'){
+if (Router.version >= '3.1.0') {
   const originalPush = Router.prototype.push
-  Router.prototype.push = function push(location) {
+  Router.prototype.push = function push (location) {
     return originalPush.call(this, location).catch(err => err)
   }
 }
@@ -30,168 +30,164 @@ export const constantRouterMap = [
       component: _import('dashboard/index'),
       name: 'dashboard_index',
       meta: {
-        title: 'Dashboard',//控制台
+        title: 'Dashboard', // 控制台
         breadcrumb: [
-          {title: 'Dashboard', path: '/dashboard/index'},//首页
-        ],
-      },
+          {title: 'Dashboard', path: '/dashboard/index'} // 首页
+        ]
+      }
     }]
   },
   {
-    path: '/dashboard/ba-index',
+    path: '/shop',
     component: layout,
-    redirect: '/dashboard/ba-index',
-    children: [{
-      path: '/dashboard/ba-index',
-      component: _import('dashboard/ba-index'),
-      name: 'dashboard_ba_index',
-      meta: {
-        title: 'Dashboard',//控制台
-        breadcrumb: [
-          {title: 'Dashboard', path: '/dashboard/ba-index'},//首页
-        ],
+    redirect: '/shop/dec-order-list',
+    children: [
+      {
+        path: '/shop/dec-order-list',
+        component: _import('shop/dec-order-list'),
+        name: 'shop_dec-order-list',
+        meta: {
+          title: 'Welcome Pack Listing', // 报单列表
+          breadcrumb: [
+            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
+            {title: 'Shopping Mall', path: '/shop/dec-order-list'} // 商城管理
+          ]
+        }
       },
-    }]
+      {
+        path: '/shop/order-list',
+        component: _import('shop/order-list'),
+        name: 'shop_order-list',
+        meta: {
+          title: 'Order List', // 订单列表
+          breadcrumb: [
+            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
+            {title: 'Shopping Mall', path: '/shop/dec-order-list'} // 商城管理
+          ]
+        }
+      },
+      {
+        path: '/shop/index',
+        component: _import('shop/index'),
+        name: 'shop_index',
+        meta: {
+          title: 'Products list', // 商品列表
+          breadcrumb: [
+            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
+            {title: 'Shopping Mall', path: '/shop/dec-order-list'} // 商城管理
+          ]
+        }
+      },
+      {
+        path: '/shop/order-backing-out',
+        component: _import('shop/order-backing-out'),
+        name: 'shop_order-list',
+        meta: {
+          title: '订单退货', // 订单退货
+          breadcrumb: [
+            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
+            {title: 'Shopping Mall', path: '/shop/dec-order-list'} // 商城管理
+          ]
+        }
+      },
+      {
+        path: '/shop/order',
+        component: _import('shop/order'),
+        name: 'shop_order',
+        meta: {
+          title: 'Products settlement',
+          breadcrumb: [
+            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
+            {title: 'Shopping Mall', path: '/shop/dec-order-list'}// 商城管理
+          ]
+        }
+      },
+      {
+        path: '/shop/goods-detail/:id',
+        component: _import('shop/goods-detail'),
+        name: 'shop_goods-detail',
+        meta: {
+          title: '商品详情',
+          breadcrumb: [
+            {title: 'Dashboard', path: '/dashboard/index'},
+            {title: 'Shopping Mall', path: '/shop/dec-order-list'}
+          ]
+        }
+      },
+      {
+        path: '/shop/ba-product-list',
+        component: _import('shop/ba-product-list'),
+        name: 'ba_product_list',
+        meta: {
+          title: 'Products list', // BA商品列表
+          breadcrumb: [
+            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
+            {title: 'Shopping Mall', path: '/shop/ba-order-list'} // 商城管理
+          ]
+        }
+      },
+      {
+        path: '/shop/ba-shopping-cart',
+        component: _import('shop/ba-shopping-cart'),
+        name: 'ba-shopping-cart',
+        meta: {
+          title: 'Products settlement', // 购物车
+          breadcrumb: [
+            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
+            {title: 'Shopping Mall', path: '/shop/ba-shopping-cart'}// 商城管理
+          ]
+        }
+      },
+      {
+        path: '/shop/ba-order-list',
+        component: _import('shop/ba-order-list'),
+        name: 'ba_order_list',
+        meta: {
+          title: 'BA Order List', // BA订单列表
+          breadcrumb: [
+            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
+            {title: 'Shopping Mall', path: '/shop/ba-order-list'}// 商城管理
+          ]
+        }
+      },
+      {
+        path: '/shop/ba-dec-order-list',
+        component: _import('shop/ba-dec-order-list'),
+        name: 'shop_ba-dec-order-list',
+        meta: {
+          title: 'Welcome BA Listing', // BA报单列表
+          breadcrumb: [
+            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
+            {title: 'Shopping Mall', path: '/shop/dec-order-list'} // 商城管理
+          ]
+        }
+      }
+      // {
+      //     path: '/shop/reconsume',
+      //     component: _import('shop/reconsume'),
+      //     name: 'shop_reconsume',
+      //     meta: {
+      //         title: '复消商品',
+      //         breadcrumb: [
+      //             {title: '首页', path: '/dashboard/index'},
+      //             {title: '商城管理', path: '/shop/dec-order-list'},
+      //         ],
+      //     },
+      // },
+      // {
+      //     path: '/shop/reconsume-order',
+      //     component: _import('shop/reconsume-order'),
+      //     name: 'reconsume-order',
+      //     meta: {
+      //         title: '复消商品结算',
+      //         breadcrumb: [
+      //             {title: '首页', path: '/dashboard/index'},
+      //             {title: '商城管理', path: '/shop/dec-order-list'}
+      //         ],
+      //     },
+      // },
+    ]
   },
-  {
-        path: '/shop',
-        component: layout,
-        redirect: '/shop/dec-order-list',
-        children: [
-            {
-                path: '/shop/dec-order-list',
-                component: _import('shop/dec-order-list'),
-                name: 'shop_dec-order-list',
-                meta: {
-                    title: 'Welcome Pack Listing',//报单列表
-                    breadcrumb: [
-                        {title: 'Dashboard', path: '/dashboard/index'},//首页
-                        {title: 'Shopping Mall', path: '/shop/dec-order-list'},//商城管理
-                    ],
-                },
-            },
-            {
-                path: '/shop/order-list',
-                component: _import('shop/order-list'),
-                name: 'shop_order-list',
-                meta: {
-                    title: 'Order List',//订单列表
-                    breadcrumb: [
-                        {title: 'Dashboard', path: '/dashboard/index'},//首页
-                        {title: 'Shopping Mall', path: '/shop/dec-order-list'},//商城管理
-                    ],
-                },
-            },
-            {
-                path: '/shop/index',
-                component: _import('shop/index'),
-                name: 'shop_index',
-                meta: {
-                    title: 'Products list',//商品列表
-                    breadcrumb: [
-                        {title: 'Dashboard', path: '/dashboard/index'},//首页
-                        {title: 'Shopping Mall', path: '/shop/dec-order-list'},//商城管理
-                    ],
-                },
-            },
-            {
-              path: '/shop/order-backing-out',
-              component: _import('shop/order-backing-out'),
-              name: 'shop_order-list',
-              meta: {
-                  title: '订单退货',//订单退货
-                  breadcrumb: [
-                      {title: 'Dashboard', path: '/dashboard/index'},//首页
-                      {title: 'Shopping Mall', path: '/shop/dec-order-list'},//商城管理
-                  ],
-              }
-            },
-            {
-                path: '/shop/order',
-                component: _import('shop/order'),
-                name: 'shop_order',
-                meta: {
-                    title: 'Products settlement',
-                    breadcrumb: [
-                        {title: 'Dashboard', path: '/dashboard/index'},//首页
-                        {title: 'Shopping Mall', path: '/shop/dec-order-list'}//商城管理
-                    ],
-                },
-            },
-            {
-                path: '/shop/goods-detail/:id',
-                component: _import('shop/goods-detail'),
-                name: 'shop_goods-detail',
-                meta: {
-                    title: '商品详情',
-                    breadcrumb: [
-                        {title: 'Dashboard', path: '/dashboard/index'},
-                        {title: 'Shopping Mall', path: '/shop/dec-order-list'},
-                    ],
-                },
-            },
-            {
-                path: '/shop/ba-product-list',
-                component: _import('shop/ba-product-list'),
-                name: 'ba_product_list',
-                meta: {
-                    title: 'Products list',//BA商品列表
-                    breadcrumb: [
-                        {title: 'Dashboard', path: '/dashboard/index'},//首页
-                        {title: 'Shopping Mall', path: '/shop/ba-product-list'},//商城管理
-                    ],
-                },
-            },
-            {
-              path: '/shop/ba-shopping-cart',
-              component: _import('shop/ba-shopping-cart'),
-              name: 'ba-shopping-cart',
-              meta: {
-                title: 'Products settlement', // 购物车
-                breadcrumb: [
-                  {title: 'Dashboard', path: '/dashboard/index'},//首页
-                  {title: 'Shopping Mall', path: '/shop/ba-product-list'}//商城管理
-                ],
-              },
-            },
-            {
-                path: '/shop/ba-order-list',
-                component: _import('shop/ba-order-list'),
-                name: 'ba_order_list',
-                meta: {
-                    title: 'Order List',  // BA订单列表
-                    breadcrumb: [
-                        {title: 'Dashboard', path: '/dashboard/index'},//首页
-                        {title: 'Shopping Mall', path: '/shop/ba-product-list'}//商城管理
-                    ],
-                },
-            },
-            // {
-            //     path: '/shop/reconsume',
-            //     component: _import('shop/reconsume'),
-            //     name: 'shop_reconsume',
-            //     meta: {
-            //         title: '复消商品',
-            //         breadcrumb: [
-            //             {title: '首页', path: '/dashboard/index'},
-            //             {title: '商城管理', path: '/shop/dec-order-list'},
-            //         ],
-            //     },
-            // },
-            // {
-            //     path: '/shop/reconsume-order',
-            //     component: _import('shop/reconsume-order'),
-            //     name: 'reconsume-order',
-            //     meta: {
-            //         title: '复消商品结算',
-            //         breadcrumb: [
-            //             {title: '首页', path: '/dashboard/index'},
-            //             {title: '商城管理', path: '/shop/dec-order-list'}
-            //         ],
-            //     },
-            // },
-        ],
-    },
   {
     path: '/user',
     component: layout,
@@ -202,24 +198,24 @@ export const constantRouterMap = [
         component: _import('user/index'),
         name: 'user_index',
         meta: {
-          title: 'Personal info',//个人资料
+          title: 'Personal info', // 个人资料
           breadcrumb: [
-            {title: 'Dashboard', path: '/dashboard/index'},//首页
-            {title: 'Member management', path: '/user/index'},//会员管理
-          ],
-        },
+            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
+            {title: 'Member management', path: '/user/index'} // 会员管理
+          ]
+        }
       },
       {
-          path: '/user/password',
-          component: _import('user/password'),
-          name: 'user_password',
-          meta: {
-              title: 'Reset Password',//重置密码
-              breadcrumb: [
-                  {title: 'Dashboard', path: '/dashboard/index'},//首页
-                  {title: 'Member management', path: '/user/index'},//会员管理
-              ],
-          },
+        path: '/user/password',
+        component: _import('user/password'),
+        name: 'user_password',
+        meta: {
+          title: 'Reset Password', // 重置密码
+          breadcrumb: [
+            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
+            {title: 'Member management', path: '/user/index'} // 会员管理
+          ]
+        }
       },
       {
         path: '/user/id-card',
@@ -229,9 +225,9 @@ export const constantRouterMap = [
           title: '上传身份证',
           breadcrumb: [
             {title: 'Dashboard', path: '/dashboard/index'},
-            {title: 'Member management', path: '/user/index'},
-          ],
-        },
+            {title: 'Member management', path: '/user/index'}
+          ]
+        }
       },
       {
         path: '/user/rec-user',
@@ -241,9 +237,9 @@ export const constantRouterMap = [
           title: '开拓会员列表',
           breadcrumb: [
             {title: 'Dashboard', path: '/dashboard/index'},
-            {title: 'Member management', path: '/user/index'},
-          ],
-        },
+            {title: 'Member management', path: '/user/index'}
+          ]
+        }
       },
       {
         path: '/user/bind',
@@ -253,9 +249,9 @@ export const constantRouterMap = [
           title: '点位绑定列表',
           breadcrumb: [
             {title: 'Dashboard', path: '/dashboard/index'},
-            {title: 'Member management', path: '/user/index'},
-          ],
-        },
+            {title: 'Member management', path: '/user/index'}
+          ]
+        }
       },
       {
         path: '/user/bind-edit/:id',
@@ -267,80 +263,92 @@ export const constantRouterMap = [
           breadcrumb: [
             {title: 'Dashboard', path: '/dashboard/index'},
             {title: 'Member management', path: '/user/index'},
-            {title: '点位绑定列表', path: '/user/bind'},
-          ],
-        },
+            {title: '点位绑定列表', path: '/user/bind'}
+          ]
+        }
       },
       {
         path: '/user/dec',
         component: _import('user/dec'),
         name: 'user_dec',
         meta: {
-          title: 'Welcome Pack management',//报单管理
+          title: 'Welcome Pack management', // 报单管理
           breadcrumb: [
-            {title: 'Dashboard', path: '/dashboard/index'},//首页
-            {title: 'Member management', path: '/user/index'},//会员管理
-          ],
-        },
+            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
+            {title: 'Member management', path: '/user/index'} // 会员管理
+          ]
+        }
       },
       {
         path: '/user/upgrade',
         component: _import('user/upgrade'),
         name: 'user_upgrade',
         meta: {
-          title: 'Upgrade management',//升级管理
+          title: 'Upgrade management', // 升级管理
           highLight: '/user/bind',
           breadcrumb: [
-            {title: 'Dashboard', path: '/dashboard/index'},//首页
-            {title: 'Member management', path: '/user/index'},//会员管理
-          ],
-        },
+            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
+            {title: 'Member management', path: '/user/index'} // 会员管理
+          ]
+        }
+      },
+      {
+        path: '/user/ba-dec',
+        component: _import('user/ba-dec'),
+        name: 'user_ba-dec',
+        meta: {
+          title: 'Welcome BA', // 个人资料
+          breadcrumb: [
+            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
+            {title: 'Member management', path: '/user/index'} // 会员管理
+          ]
+        }
       },
       {
         path: '/user/ba-info',
         component: _import('user/ba-info'),
         name: 'ba-info',
         meta: {
-          title: 'Personal Info',//个人资料
+          title: 'Personal info', // 个人资料
           breadcrumb: [
-            {title: 'Dashboard', path: '/dashboard/index'},//首页
-            {title: 'Member management', path: '/user/ba-info'},//会员管理
-          ],
-        },
+            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
+            {title: 'Member management', path: '/user/index'} // 会员管理
+          ]
+        }
       },
       {
         path: '/user/ba-password',
         component: _import('user/ba-password'),
         name: 'ba-password',
         meta: {
-          title: 'Reset Password',//重置密码
+          title: 'Reset Password', // 重置密码
           breadcrumb: [
-            {title: 'Dashboard', path: '/dashboard/index'},//首页
-            {title: 'Member management', path: '/user/ba-info'},//会员管理
-          ],
-        },
-      },
+            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
+            {title: 'Member management', path: '/user/index'} // 会员管理
+          ]
+        }
+      }
+    ]
+  },
+  {
+    path: '/atlas',
+    component: layout,
+    redirect: '/atlas/network',
+    children: [
+      {
+        path: '/atlas/network',
+        component: _import('atlas/network'),
+        name: 'atlas_network',
+        meta: {
+          title: 'Placement network',
+          breadcrumb: [
+            {title: 'Dashboard', path: '/dashboard/index'},
+            {title: 'Network Chart', path: '/atlas/network'}
+          ]
+        }
+      }
     ]
   },
-    {
-        path: '/atlas',
-        component: layout,
-        redirect: '/atlas/network',
-        children: [
-            {
-                path: '/atlas/network',
-                component: _import('atlas/network'),
-                name: 'atlas_network',
-                meta: {
-                    title: 'Placement network',
-                    breadcrumb: [
-                        {title: 'Dashboard', path: '/dashboard/index'},
-                        {title: 'Network Chart', path: '/atlas/network'},
-                    ],
-                },
-            },
-        ]
-    },
   {
     path: '/bonus',
     component: layout,
@@ -351,12 +359,12 @@ export const constantRouterMap = [
         component: _import('bonus/index'),
         name: 'bonus_index',
         meta: {
-          title: 'My account',//我的账户
+          title: 'My account', // 我的账户
           breadcrumb: [
-            {title: 'Dashboard', path: '/dashboard/index'},//首页
-            {title: 'Bonus management', path: '/bonus/index'},//奖金管理
-          ],
-        },
+            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
+            {title: 'Bonus management', path: '/bonus/index'} // 奖金管理
+          ]
+        }
       },
       {
         path: '/bonus/new',
@@ -366,33 +374,33 @@ export const constantRouterMap = [
           title: '最新奖金',
           breadcrumb: [
             {title: 'Dashboard', path: '/dashboard/index'},
-            {title: 'Bonus management', path: '/bonus/index'},
-          ],
-        },
+            {title: 'Bonus management', path: '/bonus/index'}
+          ]
+        }
       },
       {
         path: '/bonus/other',
         component: _import('bonus/other'),
         name: 'bonus_other',
         meta: {
-          title: 'Previous bonus',//往期奖金
+          title: 'Previous bonus', // 往期奖金
           breadcrumb: [
-            {title: 'Dashboard', path: '/dashboard/index'},//Dashboard
-            {title: 'Bonus management', path: '/bonus/index'},//奖金管理
-          ],
-        },
+            {title: 'Dashboard', path: '/dashboard/index'}, // Dashboard
+            {title: 'Bonus management', path: '/bonus/index'} // 奖金管理
+          ]
+        }
       },
       {
         path: '/bonus/historical-cumulative-bonus',
         component: _import('bonus/historical-cumulative-bonus'),
         name: 'historical-cumulative-bonus',
         meta: {
-          title: 'Historical cumulative bonus',//往期历史奖金累积
+          title: 'Historical cumulative bonus', // 往期历史奖金累积
           breadcrumb: [
-            {title: 'Dashboard', path: '/dashboard/index'},//Dashboard
-            {title: 'Bonus management', path: '/bonus/index'},//奖金管理
-          ],
-        },
+            {title: 'Dashboard', path: '/dashboard/index'}, // Dashboard
+            {title: 'Bonus management', path: '/bonus/index'} // 奖金管理
+          ]
+        }
       },
       {
         path: '/bonus/real-time-perf',
@@ -402,9 +410,9 @@ export const constantRouterMap = [
           title: '实时业绩',
           breadcrumb: [
             {title: 'Dashboard', path: '/dashboard/index'},
-            {title: 'Bonus management', path: '/bonus/index'},
-          ],
-        },
+            {title: 'Bonus management', path: '/bonus/index'}
+          ]
+        }
       },
       {
         path: '/bonus/fc-point',
@@ -414,10 +422,10 @@ export const constantRouterMap = [
           title: '房产积分',
           breadcrumb: [
             {title: 'Dashboard', path: '/dashboard/index'},
-            {title: 'Bonus management', path: '/bonus/index'},
-          ],
-        },
-      },
+            {title: 'Bonus management', path: '/bonus/index'}
+          ]
+        }
+      }
 
     ]
   },
@@ -434,9 +442,9 @@ export const constantRouterMap = [
           title: 'Article List',
           breadcrumb: [
             {title: 'Dashboard', path: '/dashboard/index'},
-            {title: 'Article Management', path: '/article/list'},
-          ],
-        },
+            {title: 'Article Management', path: '/article/list'}
+          ]
+        }
       },
       {
         path: '/article/detail/:id',
@@ -446,10 +454,10 @@ export const constantRouterMap = [
           title: 'Article Detail',
           breadcrumb: [
             {title: 'Dashboard', path: '/dashboard/index'},
-            {title: 'Article Management', path: '/article/list'},
-          ],
-        },
-      },
+            {title: 'Article Management', path: '/article/list'}
+          ]
+        }
+      }
     ]
   },
   {
@@ -465,9 +473,9 @@ export const constantRouterMap = [
           title: '站内信列表',
           breadcrumb: [
             {title: 'Dashboard', path: '/dashboard/index'},
-            {title: '站内信', path: '/message/list'},
-          ],
-        },
+            {title: '站内信', path: '/message/list'}
+          ]
+        }
       },
       {
         path: '/message/detail/:id',
@@ -477,10 +485,10 @@ export const constantRouterMap = [
           title: '站内信详情',
           breadcrumb: [
             {title: 'Dashboard', path: '/dashboard/index'},
-            {title: '站内信', path: '/message/list'},
-          ],
-        },
-      },
+            {title: '站内信', path: '/message/list'}
+          ]
+        }
+      }
     ]
   },
   {
@@ -496,35 +504,35 @@ export const constantRouterMap = [
           title: '会员复销池余额流水',
           breadcrumb: [
             {title: 'Dashboard', path: '/dashboard/index'},
-            {title: 'Financial management', path: '/finance/withdraw'},
-          ],
-        },
+            {title: 'Financial management', path: '/finance/withdraw'}
+          ]
+        }
       },
       {
         path: '/finance/withdraw',
         component: _import('finance/withdraw'),
         name: 'finance_withdraw',
         meta: {
-          title: 'Withdrawal details',//提现明细
+          title: 'Withdrawal details', // 提现明细
           breadcrumb: [
-            {title: 'Dashboard', path: '/dashboard/index'},//首页
-            {title: 'Financial management', path: '/finance/index'},//财务管理
-          ],
-        },
+            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
+            {title: 'Financial management', path: '/finance/index'} // 财务管理
+          ]
+        }
       },
       {
         path: '/finance/withdraw-add',
         component: _import('finance/withdraw-add'),
         name: 'finance_withdraw-add',
         meta: {
-          title: 'Withdraw',//我要提现
+          title: 'Withdraw', // 我要提现
           highLight: '/finance/withdraw',
           breadcrumb: [
-            {title: 'Dashboard', path: '/dashboard/index'},//首页
-            {title: 'Financial management', path: '/finance/index'},//财务管理
-            {title: 'Withdrawal details', path: '/finance/withdraw'},//提现明细
-          ],
-        },
+            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
+            {title: 'Financial management', path: '/finance/index'}, // 财务管理
+            {title: 'Withdrawal details', path: '/finance/withdraw'} // 提现明细
+          ]
+        }
       },
       {
         path: '/finance/dec-list',
@@ -534,9 +542,9 @@ export const constantRouterMap = [
           title: '报单订货单列表',
           breadcrumb: [
             {title: 'Dashboard', path: '/dashboard/index'},
-            {title: 'Financial management', path: '/finance/index'},
-          ],
-        },
+            {title: 'Financial management', path: '/finance/index'}
+          ]
+        }
       },
       {
         path: '/finance/transfer-list',
@@ -546,9 +554,9 @@ export const constantRouterMap = [
           title: 'Transfer',
           breadcrumb: [
             {title: 'Dashboard', path: '/dashboard/index'},
-            {title: 'Financial management', path: '/finance/index'},
-          ],
-        },
+            {title: 'Financial management', path: '/finance/index'}
+          ]
+        }
       },
       {
         path: '/finance/transfer-add',
@@ -559,9 +567,9 @@ export const constantRouterMap = [
           highLight: '/finance/transfer-list',
           breadcrumb: [
             {title: 'Dashboard', path: '/dashboard/index'},
-            {title: 'Financial management', path: '/finance/index'},
-          ],
-        },
+            {title: 'Financial management', path: '/finance/index'}
+          ]
+        }
       },
       {
         path: '/finance/recharge',
@@ -571,9 +579,9 @@ export const constantRouterMap = [
           title: 'Recharge details', // 充值明细
           breadcrumb: [
             {title: 'Dashboard', path: '/dashboard/index'}, // 首页
-            {title: 'financial management', path: '/finance/index'}, // 财务管理
-          ],
-        },
+            {title: 'financial management', path: '/finance/index'} // 财务管理
+          ]
+        }
       },
       {
         path: '/finance/recharge-add',
@@ -585,10 +593,10 @@ export const constantRouterMap = [
           breadcrumb: [
             {title: 'Dashboard', path: '/dashboard/index'}, // 首页
             {title: 'financial management', path: '/finance/index'}, // 财务管理
-            {title: 'Recharge details', path: '/finance/recharge'},
-          ],
-        },
-      },
+            {title: 'Recharge details', path: '/finance/recharge'}
+          ]
+        }
+      }
     ]
   },
   {
@@ -601,26 +609,26 @@ export const constantRouterMap = [
         component: _import('config/receive-address-list'),
         name: 'config_receive-address-list',
         meta: {
-          title: 'Shipping Address',//收货地址管理
+          title: 'Shipping Address', // 收货地址管理
           breadcrumb: [
-            {title: 'Dashboard', path: '/dashboard/index'},//首页
-            {title: 'Setting', path: '/config/base'},//设置
-          ],
-        },
+            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
+            {title: 'Setting', path: '/config/base'} // 设置
+          ]
+        }
       },
       {
         path: '/config/receive-address-add',
         component: _import('config/receive-address-edit'),
         name: 'config_receive-address-add',
         meta: {
-          title: 'Add shipping address',//添加收货地址
+          title: 'Add shipping address', // 添加收货地址
           highLight: '/config/receive-address-list',
           breadcrumb: [
-            {title: 'Dashboard', path: '/dashboard/index'},//首页
-            {title: 'Setting', path: '/config/base'},//设置
-            {title: 'Shipping Address', path: '/config/receive-address-list'},//收货地址管理
-          ],
-        },
+            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
+            {title: 'Setting', path: '/config/base'}, // 设置
+            {title: 'Shipping Address', path: '/config/receive-address-list'} // 收货地址管理
+          ]
+        }
       },
       {
         path: '/config/receive-address-edit/:id',
@@ -630,11 +638,11 @@ export const constantRouterMap = [
           title: 'Edit address',
           highLight: '/config/receive-address-list',
           breadcrumb: [
-            {title: 'Dashboard', path: '/dashboard/index'},//首页
-            {title: 'Setting', path: '/config/base'},//设置
-            {title: 'Shipping Address', path: '/config/receive-address-list'},//收货地址管理
-          ],
-        },
+            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
+            {title: 'Setting', path: '/config/base'}, // 设置
+            {title: 'Shipping Address', path: '/config/receive-address-list'} // 收货地址管理
+          ]
+        }
       },
 
       {
@@ -642,26 +650,26 @@ export const constantRouterMap = [
         component: _import('config/ba-receive-address-list'),
         name: 'ba-receive-address-list',
         meta: {
-          title: 'Shipping Address',//收货地址管理
+          title: 'Shipping Address', // 收货地址管理
           breadcrumb: [
-            {title: 'Dashboard', path: '/dashboard/index'},//首页
-            {title: 'Setting', path: '/config/ba-receive-address-list'},//设置
-          ],
-        },
+            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
+            {title: 'Setting', path: '/config/base'} // 设置
+          ]
+        }
       },
       {
         path: '/config/ba-receive-address-add',
         component: _import('config/ba-receive-address-edit'),
         name: 'ba-receive-address-add',
         meta: {
-          title: 'Add Shipping Address',//添加收货地址
+          title: 'Add Shipping Address', // 添加收货地址
           highLight: '/config/ba-receive-address-list',
           breadcrumb: [
-            {title: 'Dashboard', path: '/dashboard/index'},//首页
-            {title: 'Setting', path: '/config/ba-receive-address-list'},//设置
-            {title: 'Shipping Address', path: '/config/ba-receive-address-list'},//收货地址管理
-          ],
-        },
+            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
+            {title: 'Setting', path: '/config/base'}, // 设置
+            {title: 'Shipping Address', path: '/config/ba-receive-address-list'} // 收货地址管理
+          ]
+        }
       },
       {
         path: '/config/ba-receive-address-edit/:id',
@@ -671,14 +679,14 @@ export const constantRouterMap = [
           title: 'Edit Address',
           highLight: '/config/ba-receive-address-list',
           breadcrumb: [
-            {title: 'Dashboard', path: '/dashboard/index'},//首页
-            {title: 'Setting', path: '/config/ba-receive-address-list'},//设置
-            {title: 'Shipping Address', path: '/config/ba-receive-address-list'},//收货地址管理
-          ],
-        },
-      },
+            {title: 'Dashboard', path: '/dashboard/index'}, // 首页
+            {title: 'Setting', path: '/config/base'}, // 设置
+            {title: 'Shipping Address', path: '/config/ba-receive-address-list'} // 收货地址管理
+          ]
+        }
+      }
     ]
-  },
+  }
 ]
 
 export default new Router({

+ 2 - 2
frontendEle/src/utils/config_trial.js

@@ -1,13 +1,13 @@
 const APP_NAME = '奖金结算系统'
 const SERVER_API_DOMAIN = '16.163.228.151'
 const SERVER_API_HTTP_TYPE = 'http://'
-const SERVER_API_PORT = ':8026'  // ':8102'
+const SERVER_API_PORT = ':8033'  // ':8102'
 const SERVER_API_VERSION = 'v1'
 const REQUEST_URL = `${SERVER_API_HTTP_TYPE}${SERVER_API_DOMAIN}${SERVER_API_PORT}/${SERVER_API_VERSION}/`
 const WEBSOCKET_HOST = 'ws://127.0.0.1:9512'
 const DEVICE_TYPE = 'pc'
 const ACCESS_TOKEN_PREFIX = 'Bearer '
-const CDN_BASE_URL = 'http://16.163.228.151:8029'
+const CDN_BASE_URL = 'http://16.163.228.151:8036'
 const CDN_IMG_URL = `${CDN_BASE_URL}/cdn/`
 const PRICE_IS_ROUND = true
 const REGION_URL = `${CDN_BASE_URL}/cdn/jsdata/ar_region_data.js?ver=0.1`

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

@@ -0,0 +1,160 @@
+<template>
+  <div v-loading="loading">
+    <div class="white-box">
+      <el-table class="withdraw-table" :data="tableData" :max-height="maxHeight" style="width: 100%;" :span-method="objectSpanMethod">
+        <el-table-column width="120" label="Product code" prop="SKU_CODE"></el-table-column><!--商品编号-->
+        <el-table-column width="120" label="Product Name" prop="GOODS_TITLE"></el-table-column><!--商品名称-->
+        <el-table-column width="120" label="Product Price" prop="REAL_PRICE"></el-table-column><!--报单金额-->
+        <el-table-column width="120" label="Product BV" prop="REAL_PV"></el-table-column><!--报单BV-->
+        <el-table-column width="120" label="Qty" prop="BUY_NUMS"></el-table-column><!--数量-->
+        <el-table-column width="120" label="Tax rate" prop="TAX_RATE"></el-table-column><!--税率-->
+        <el-table-column width="120" label="Tax" prop="TAX_AMOUNT"></el-table-column><!--税额-->
+        <el-table-column width="120" label="Total Price" prop="TOTAL_AMOUNT"></el-table-column><!--总计金额-->
+        <el-table-column width="120" label="Code" prop="DEC_SN"></el-table-column><!--报单编号-->
+        <el-table-column width="120" label="Order code" prop="ORDER_SN"></el-table-column><!--订单编号-->
+        <el-table-column width="120" label="Member code" prop="USER_NAME"></el-table-column><!--会员编号-->
+        <el-table-column width="120" label="Member name" prop="REAL_NAME"></el-table-column><!--会员姓名-->
+        <el-table-column width="150" label="Shipping Address" prop="ADDRESS"></el-table-column><!--收货地址-->
+        <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>
+      <div class="white-box-footer">
+          <pagination :total="totalCount" :page_size="pageSize" @size-change="handleSizeChange" @current-change="handleCurrentChange"></pagination>
+      </div>
+    </div>
+  </div>
+</template>
+
+<script>
+import network from '@/utils/network'
+import tool from '@/utils/tool'
+import Pagination from '@/components/Pagination'
+import {SERVER_API_HTTP_TYPE, SERVER_API_DOMAIN,SERVER_API_PORT} from '@/utils/config'
+export default {
+  name: 'dec-order-list',
+  components: {Pagination},
+  mounted () {
+    this.getData()
+  },
+  data () {
+    return {
+      loading: false,
+      form: {
+
+      },
+      tableData: null,
+      list: null,
+      currentPage: 1,
+      totalPages: 1,
+      totalCount: 1,
+      pageSize: 20,
+      tool: tool,
+      // 订单号判断
+      spanArr: [], // 用于存放需要合并的行的个数
+      pos: 0, // 记录spanArr数组的下标
+      maxHeight: tool.getTableHeight()
+    }
+  },
+  methods: {
+
+    objectSpanMethod (obj) {
+      if (
+        obj.columnIndex === 7 ||
+        obj.columnIndex === 8 ||
+        obj.columnIndex === 9 ||
+        obj.columnIndex === 10 ||
+        obj.columnIndex === 11 ||
+        obj.columnIndex === 12 ||
+        obj.columnIndex === 13 ||
+        obj.columnIndex === 14
+      ) {
+      // ⼆维数组存储的数据取出
+        var _row = this.spanArr[obj.rowIndex]
+        var _col = _row > 0 ? 1 : 0
+        return {
+          rowspan: _row,
+          colspan: _col
+        }
+      } else {
+        return false
+      }
+    },
+    getSpanArr (orderList) { // 传⼊你的列表数据
+      this.pos = 0
+      orderList.forEach((item, index) => {
+        // 判断是否是第⼀项
+        if (index === 0) {
+          this.spanArr.push(1)
+          this.pos = 0
+        } else {
+          // 不是第⼀项时,就根据标识去存储
+          if ( // orderSn,createdAt...是你的第⼀个数据、第⼆个数据...
+            orderList[index].DEC_SN === orderList[index - 1].DEC_SN &&
+            orderList[index].ORDER_SN === orderList[index - 1].ORDER_SN &&
+            orderList[index].USER_NAME === orderList[index - 1].USER_NAME &&
+            orderList[index].REAL_NAME === orderList[index - 1].REAL_NAME &&
+            orderList[index].CON_USER_NAME === orderList[index - 1].CON_USER_NAME &&
+            orderList[index].P_CALC_MONTH === orderList[index - 1].P_CALC_MONTH
+          ) {
+            // 查找到符合条件的数据时每次要把之前存储的数据+1
+            this.spanArr[this.pos] += 1
+            this.spanArr.push(0)
+          } else {
+            // 没有符合的数据时,要记住当前的index
+            this.spanArr.push(1)
+            this.pos = index
+          }
+        }
+      })
+    },
+    handleCurrentChange (page) {
+      this.getData(page, this.pageSize)
+    },
+    handleSizeChange (pageSize) {
+      this.getData(this.currentPage, pageSize)
+    },
+    getData (page, pageSize) {
+      this.spanArr = []
+      this.pos = 0
+      let _this = this
+      network.getPageData(_this, 'shop/ba-dec-order-list', page, pageSize, {type: this.type}, function (response) {
+      // network.getData(`shop/dec-order-list`).then(response => {
+        _this.loading = false
+        _this.list = response.list
+        let settingObj = _this.list
+
+        let settingArr = Object.keys(settingObj).map(key => {
+          // console.log(key); // 为每个键名
+          return settingObj[key] // 把每个对象返回出去生成一个新的数组中相当于0:{id:1}
+        })
+
+        _this.tableData = settingArr
+        _this.getSpanArr(_this.tableData)
+      })
+    },
+    // 导出PDF订单
+    handleOrderExportPDF (orderSn) {
+      network.getData(`shop/dec-order-export/${orderSn}`).then(response => {
+        let { fileUrl, targetName } = response
+        let downloadElement = document.createElement('a')
+        downloadElement.target = '_blank'
+        downloadElement.href = SERVER_API_HTTP_TYPE + SERVER_API_DOMAIN + SERVER_API_PORT + '/' + fileUrl
+        // 下载后文件名
+        downloadElement.download = targetName
+        // 点击下载
+        downloadElement.click()
+      })
+    }
+  }
+}
+</script>
+
+<style scoped>
+
+</style>

+ 700 - 0
frontendEle/src/views/user/ba-dec.vue

@@ -0,0 +1,700 @@
+<template>
+  <div v-loading="loading">
+    <div class="white-box">
+      <el-form ref="form"  label-width="180px" class="form-page">
+        <div class="hr-tip"><span>Account Information<!--账号信息--></span></div>
+
+        <el-form-item label="New member code"><!--会员编号-->
+          <el-input v-model="form.insertUserName"></el-input>
+        </el-form-item>
+<!--        <el-form-item>-->
+<!--          <template slot="label">-->
+<!--            Entry level&lt;!&ndash;实时报单级别&ndash;&gt;-->
+<!--          </template>-->
+<!--          <el-select v-model="form.decLv" placeholder="Select entry level" @change="selectOne($event)">-->
+<!--            <el-option v-for="(item,index) in allDecLevel" :key="index" :label="item.LEVEL_NAME"-->
+<!--             :value="item.ID"></el-option>-->
+<!--          </el-select>&lt;!&ndash;请选择报单级别&ndash;&gt;-->
+<!--        </el-form-item>-->
+        <el-form-item label="Stockist Code"><!--报单中心编号-->
+          <el-input v-model="form.decUserName" readonly></el-input>
+        </el-form-item>
+
+        <el-form-item>
+          <template slot="label">
+            Select Welcome Pack<!--报单方式二选一-->
+          </template>
+          <el-tabs type="border-card" v-model="decWay" style="position: relative;width: 1200px;">
+            <el-tab-pane label="Product" name="2"><!-- 商品报单 -->
+              <el-table class="table-box" v-if="numList.length > 0" :data="tableDatas" stripe style="width: 100%;" highlight-current-row  @selection-change="handleSelectionChange">
+                <el-table-column
+                  type="selection"
+                  width="55">
+                </el-table-column>
+
+                <el-table-column label="Product Name" prop="GOODS_NAME" width="300"><!-- 商品名称 -->
+
+                </el-table-column>
+                <el-table-column label="Product code" prop="GOODS_NO" width="120"><!-- 商品编号 -->
+
+                </el-table-column>
+                <el-table-column label="Product price" prop="SELL_PRICE" width="120"><!-- 卖价 -->
+
+                </el-table-column>
+
+                <el-table-column label="Product BV" prop="PRICE_PV" width="100"><!-- BV价格 -->
+
+                </el-table-column>
+                <el-table-column label="Tax rate" prop="TAX_RATE" width="100">
+                  <template slot-scope="scope">
+                    {{ Math.round(scope.row.TAX_RATE * 100) / 100 }}
+                  </template>
+                </el-table-column>
+                <el-table-column label="Tax" width="100">
+                  <template slot-scope="scope">
+                    {{ Math.round((scope.row.SELL_PRICE - scope.row.SELL_PRICE / (1 + scope.row.TAX_RATE / 100)) * 100) / 100 }}
+                  </template>
+                </el-table-column>
+                <el-table-column label="Quantity" width="150"><!-- 数量 -->
+                  <template slot-scope="scope">
+                    <el-input-number size="mini" v-model="numList[scope.$index]"  :min="0" :max="Number(scope.row.STORE_NUMS)" @change="value=>{handleChange(value,scope.row.ID)}"></el-input-number>
+                  </template>
+                  <!-- <template slot-scope="scope">
+                    <el-input-number v-if="form.goodsId.some(item=>item==scope.row.ID)" v-model='scope.row.goodsNum' @change="value=>{handleChange(value,scope.row.ID)}" controls-position="right" style="width: 70px;" size="mini"></el-input-number>
+                  </template> -->
+                </el-table-column>
+              </el-table>
+              <div class="white-box-footer flex">
+                <el-button @click="getSum()">Total Calculation</el-button><!--计算合计-->
+                <div class='flex data' style="flex:1;justify-content: flex-end;">
+                  <div style="margin-right:2rem">Price:₦{{sell_price_sum}}</div><!--商品价格-->
+                  <div style="margin-right:2rem">BV:{{price_pv_sum}}</div><!--商品BV-->
+                  <div>Tax:₦{{tax_sum}}</div><!--商品BV-->
+                </div>
+              </div>
+
+            </el-tab-pane>
+          </el-tabs>
+        </el-form-item>
+
+        <div class="hr-tip"><span>Network Information</span></div><!--网络信息-->
+        <el-form-item label="Sponsor code"><!--推荐人编号-->
+          <el-input v-model="form.recUserName" @change="handleChkRecUser">
+            <template slot="append">【{{recRealName}}】</template>
+          </el-input>
+        </el-form-item>
+
+<!--        <el-form-item label="Placement code">&lt;!&ndash;接点人编号&ndash;&gt;-->
+<!--          <el-input v-model="form.conUserName" @change="handleChkConUser">-->
+<!--            <template slot="append">【{{conRealName}}】</template>-->
+<!--          </el-input>-->
+<!--        </el-form-item>-->
+
+<!--        <el-form-item label="Placement tree">&lt;!&ndash;安置区位&ndash;&gt;-->
+<!--          <el-radio-group v-model="form.location">-->
+<!--            <el-radio :label="1" >Left</el-radio>&lt;!&ndash;左区&ndash;&gt;-->
+<!--            <el-radio :label="2" >Right</el-radio>&lt;!&ndash;右区&ndash;&gt;-->
+<!--          </el-radio-group>-->
+<!--        </el-form-item>-->
+
+<!--        <el-form-item label="">&lt;!&ndash;自动安置区位&ndash;&gt;-->
+<!--          <el-button type="primary" @click="setAutoPlace('left')">Placement Auto Location: L</el-button>-->
+<!--          <el-button type="primary" @click="setAutoPlace('right')">Placement Auto Location: R</el-button>-->
+<!--        </el-form-item>-->
+
+        <div class="hr-tip"><span>Personal Information<!--个人信息--></span></div>
+        <el-form-item>
+          <template slot="label">
+            Member Name<!-- 会员姓名 -->
+          </template>
+          <el-input v-model="form.realName"></el-input>
+        </el-form-item>
+        <el-form-item>
+          <template slot="label">
+            Phone Number<!-- 会员手机 -->
+          </template>
+          <el-input v-model="form.mobile"></el-input>
+        </el-form-item>
+        <el-form-item>
+          <template slot="label">
+            Email
+          </template>
+          <el-input v-model="form.email"></el-input>
+        </el-form-item>
+
+        <el-form-item>
+          <template slot="label">
+            Login Password<!-- 登录密码 -->
+          </template>
+          <el-input v-model="form.password" maxlength="32" placeholder="Enter password"></el-input>
+        </el-form-item>
+        <el-form-item>
+          <template slot="label">
+            Payment Password<!-- 支付密码 -->
+          </template>
+          <el-input v-model="form.payPassword" maxlength="32" placeholder="Enter Payment password"></el-input>
+        </el-form-item>
+        <el-form-item>
+          <template slot="label">
+            Recipient Name<!-- 收货人 -->
+          </template>
+          <el-input v-model="form.consignee"></el-input>
+        </el-form-item>
+        <el-form-item>
+          <template slot="label">
+            Phone Number<!-- 收货人手机 -->
+          </template>
+          <el-input v-model="form.acceptMobile"></el-input>
+        </el-form-item>
+        <el-form-item>
+          <template slot="label">
+            Shipping<!-- 收货方式 -->
+          </template>
+          <el-radio-group v-model="form.way" @change="wayChange">
+            <el-radio label="express">Delivery</el-radio>
+            <el-radio label="pickup">Self Pick-up<!--自提--></el-radio>
+          </el-radio-group>
+        </el-form-item>
+        <el-form-item prop="areaSelected">
+          <template slot="label">
+            State<!-- 地区 -->
+          </template>
+          <el-cascader
+            :disabled="areaDisabled"
+            size="large"
+            :options="regionData"
+            v-model="form.areaSelected">
+          </el-cascader>
+        </el-form-item>
+        <el-form-item>
+          <template slot="label">
+            Full address<!-- 详细地址 -->
+          </template>
+          <el-input :disabled="addressDisabled" v-model="form.address"></el-input>
+        </el-form-item>
+        <el-form-item>
+          <template slot="label">
+            City<!-- 详细地址 -->
+          </template>
+          <el-input :disabled="addressDisabled" v-model="form.cityName"></el-input>
+        </el-form-item>
+        <el-form-item>
+          <template slot="label">
+            Local Government Area<!-- 详细地址 -->
+          </template>
+          <el-input :disabled="addressDisabled" v-model="form.lgaName"></el-input>
+        </el-form-item>
+
+<!--        <div class="hr-tip"><span>Bank Info&lt;!&ndash; 银行信息 &ndash;&gt;</span></div>-->
+
+<!--        <el-form-item label="Bank Name">&lt;!&ndash; 开户行 &ndash;&gt;-->
+<!--          <el-select v-model="form.openBank" placeholder="Select Bank">&lt;!&ndash; 请选择开户行 &ndash;&gt;-->
+<!--            <el-option v-for="(item,index) in allOpenBank" :key="index" :label="item.BANK_NAME"-->
+<!--             :value="item.BANK_CODE"></el-option>-->
+<!--          </el-select>-->
+
+<!--        </el-form-item>-->
+<!--        <el-form-item label="Account Name">&lt;!&ndash; 开户支行 &ndash;&gt;-->
+<!--          <el-input v-model="form.bankAddress"></el-input>-->
+<!--        </el-form-item>-->
+<!--        <el-form-item label="Account Number">&lt;!&ndash; 银行账号 &ndash;&gt;-->
+<!--          <el-input v-model="form.bankNo" maxlength="19"></el-input>-->
+<!--        </el-form-item>-->
+
+        <div class="hr-tip"><span>Pay Info<!-- 支付信息 --></span></div>
+        <el-form-item label="Payment method" required><!-- 支付方式 -->
+          <el-radio-group v-model="form.payType" @change="payMethodChange">
+            <el-radio v-for="(item, index) in payList" :key='index' :label="item.label">{{ item.name }}</el-radio>
+          </el-radio-group>
+        </el-form-item>
+
+        <el-form-item>
+          <el-button type="primary" @click="onSubmit" :loading="submitButtonStat">Save<!-- 保存 --></el-button>
+        </el-form-item>
+      </el-form>
+      </div>
+
+      <el-dialog title="Pay" v-if="visible" :visible.sync="visible" width="30%" v-loading="payStackLoading" :before-close="handleClose">
+        <section>
+          <div class="formcontainer">
+            <el-divider></el-divider>
+            <div class="container">
+              <el-form :model="PayStackForm">
+                <el-form-item label="Email" label-width="100px" required>
+                  <el-input v-model="PayStackForm.email" autocomplete="off"></el-input>
+                </el-form-item>
+                <el-form-item label="Amount" label-width="100px" required>
+                  <el-input v-model="PayStackForm.amount" autocomplete="off" readonly></el-input>
+                </el-form-item>
+              </el-form>
+            </div>
+          </div>
+        </section>
+
+        <paystack
+          :firstname="PayStackForm.firstname"
+          :lastname="PayStackForm.lastname"
+          :amount="PayStackForm.amount * 100"
+          :email="PayStackForm.email"
+          :metadata="PayStackForm.metadata"
+          :currency="PayStackForm.currency"
+          :paystackkey="PayStackForm.publicKey"
+          :reference="reference"
+          :channels="channels"
+          :callback="processPayment"
+          :close="processClose"
+        >
+          <el-button type="primary" size="small">Pay</el-button>
+
+        </paystack>
+        <el-button type="danger" size="small" class="cancelButton" @click="handleClose">Cancel</el-button>
+      </el-dialog>
+
+      <el-dialog title="Tips" :visible.sync="payDialog" :show-close="false" width="350px" :close="handleOrderList">
+        <el-result icon="success" title="the order is successful">
+          <template slot="extra">
+            <span style="color: #008efa; font-size: 30px;">{{ countdown }}</span>
+          </template>
+        </el-result>
+      </el-dialog>
+  </div>
+</template>
+
+<script>
+import Vue from 'vue'
+import network from '@/utils/network'
+import baseInfo from '@/utils/baseInfo'
+import store from '@/utils/vuexStore'
+import tool from '@/utils/tool'
+import userInfo from '@/utils/userInfo'
+import { PAY_STACK_PUBLIC_KEY, PAY_STACK_CURRENCY } from '@/utils/config'
+import paystack from 'vue-paystack'
+
+export default {
+  name: 'user_dec',
+  async created () {
+    await this.getData()
+  },
+  computed: {
+    // _tableData () {
+    //   if (this.tableData == null) {
+    //     return []
+    //   }
+    //   if (this.form.decLv === '') {
+    //     return this.tableData
+    //   }
+    //   return this.tableData.filter(item => {
+    //     return item.LEVEL_ID === this.form.decLv
+    //   })
+    // },
+    reference () {
+      let text = ''
+      let possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
+      for (let i = 0; i < 10; i++) {
+        text += possible.charAt(Math.floor(Math.random() * possible.length))
+      }
+      return text
+    }
+  },
+
+  data () {
+    return {
+      currentRow: null,
+      decWay: '2',
+      regionData: store.state.regionInfo.regionData,
+      form: {
+        realName: '',
+        decLv: '',
+        insertUserName: '',
+        decUserName: userInfo.userName(),
+        recUserName: '',
+        conUserName: '',
+        insertUserIdCard: '',
+        consignee: '',
+        acceptMobile: '',
+        areaSelected: [],
+        address: '',
+        openBank: '',
+        bankAddress: '',
+        bankProvince: '',
+        bankCity: '',
+        bankCounty: '',
+        bankNo: '',
+        bankAreaSelected: [],
+        password: '111111',
+        payPassword: '111111',
+        mobile: '',
+        email: '',
+        packageId: '',
+        goodsId: [],
+        goodsNum: [],
+        province: '',
+        cityName: '',
+        lgaName: '',
+        way: 'express',
+        payType: '',
+        autoPlace: '',
+        location: ''
+      },
+      conRealName: '-',
+      recRealName: '-',
+      num: 1,
+      // tableData: null,
+      tableDatas: null,
+      allOpenBank: null,
+      // allDecPackage: {},
+      allDecLevel: baseInfo.decLevels(),
+      loading: false,
+      submitButtonStat: false,
+      submitButton: false,
+      allGoods: [],
+      multipleSelection: [],
+      goodsNums: [],
+      numList: [],
+      sell_price_sum: 0.00,
+      price_pv_sum: 0.00,
+      tax_sum: 0.00,
+      areaDisabled: false,
+      addressDisabled: false,
+      category_type: '',
+      payList: [],
+      sn: '',
+      payDialog: false,
+      countdown: 5,
+      visible: false,
+      payStackLoading: false,
+      channels: ['card', 'bank', 'ussd', 'qr'], // eft(南非)  mobile_money(加纳)
+      PayStackForm: {
+        publicKey: PAY_STACK_PUBLIC_KEY,
+        currency: PAY_STACK_CURRENCY,
+        firstname: userInfo.userName(),
+        lastname: '',
+        email: userInfo.userEmail(),
+        amount: 0, // kobo
+        orderSn: '',
+        metadata: {
+          cart_id: this.sn,
+          custom_fields: [
+            {
+              display_name: 'orderSn',
+              variable_name: 'orderSn',
+              value: this.sn
+            }
+          ]
+        }
+      }
+    }
+  },
+  components: {
+    paystack
+  },
+  methods: {
+    wayChange () {
+      if (this.form.way === 'pickup') {
+        this.areaDisabled = true
+        this.addressDisabled = true
+      } else {
+        this.areaDisabled = false
+        this.addressDisabled = false
+      }
+    },
+    getSum () {
+      let sell_price_sum = 0, price_pv_sum = 0, tax_sum = 0
+      this.multipleSelection.map((item, index) => {
+        sell_price_sum += Number(item.SELL_PRICE) * item.goodsNum
+        price_pv_sum += Number(item.PRICE_PV) * item.goodsNum
+        tax_sum += Number(item.SELL_PRICE - item.SELL_PRICE / (1 + item.TAX_RATE / 100)) * item.goodsNum
+      })
+      this.sell_price_sum = tool.formatPrice(sell_price_sum)
+      this.price_pv_sum = tool.formatPrice(price_pv_sum)
+      this.tax_sum = tool.formatPrice(tax_sum)
+    },
+    async getData () {
+      await network.getData(`user/ba-dec`).then(response => {
+        this.loading = false
+        this.form.insertUserName = response.userName
+        // this.allOpenBank = response.allOpenBank
+        // this.allDecPackage = response.allDecPackage
+        this.allGoods = response.allGoods
+        this.categoryType = 1
+
+        // let settingObj = this.allDecPackage
+        // let settingArr = Object.keys(settingObj).map(key => {
+        //   return settingObj[key] // 把每个对象返回出去生成一个新的数组中相当于0:{id:1}
+        // })
+        // this.tableData = settingArr
+        let settingObj1 = this.allGoods
+        for (let i in settingObj1) {
+          this.numList[i] = 1
+          settingObj1[i].goodsNum = 1
+        }
+        this.tableDatas = settingObj1
+
+        // 支付方式
+        this.payList = response.sellType[0]['sell_type']
+        // 支付方式的第一项默认选中
+        this.form.payType = Object.values(this.payList)[1]['label']
+      })
+    },
+    handleCurrentChange (val) {
+      if (!val) { return }
+      this.currentRow = val
+      this.form.packageId = this.currentRow.ID
+    },
+    handleSelectionChange (val) {
+      let idx = -1, num
+      for (let i in this.tableDatas) {
+        for (let v in val) {
+          if (val[v].ID === this.tableDatas[i].ID) {
+            idx = i
+            num = this.numList[idx]
+            val[v]['goodsNum'] = num
+            break
+          }
+        }
+      }
+      this.multipleSelection = val
+    },
+    handleChange (value, ID) {
+      for (let i in this.multipleSelection) {
+        if (this.multipleSelection[i]['ID'] === ID) {
+          this.multipleSelection[i]['goodsNum'] = value
+        }
+      }
+    },
+    getGoods () {
+      this.form.goodsId = []
+      this.form.goodsNum = []
+      this.multipleSelection.map((item, index) => {
+        this.form.goodsId.push(item.ID)
+        this.form.goodsNum.push(item.goodsNum)
+      })
+    },
+    onSubmit () {
+      let _this = this
+      _this.getGoods()
+      _this.submitButtonStat = true
+      let path = 'user/ba-dec'
+      let postData = {
+        consignee: _this.form.consignee,
+        acceptMobile: _this.form.acceptMobile,
+        province: _this.form.areaSelected[0] ? _this.form.areaSelected[0] : '',
+        city: _this.form.areaSelected[1] ? _this.form.areaSelected[1] : '',
+        county: _this.form.areaSelected[2] ? _this.form.areaSelected[2] : '',
+        address: _this.form.address,
+        insertUserName: _this.form.insertUserName,
+        decLv: _this.form.decLv,
+        realName: _this.form.realName,
+        decUserName: _this.form.decUserName,
+        conUserName: _this.form.conUserName,
+        recUserName: _this.form.recUserName,
+        insertUserIdCard: _this.form.insertUserIdCard,
+        openBank: _this.form.openBank,
+        bankAddress: _this.form.bankAddress,
+        mobile: _this.form.mobile,
+        email: _this.form.email,
+        cityName: _this.form.cityName,
+        lgaName: _this.form.lgaName,
+
+        bankProvince: _this.form.bankAreaSelected[0] ? _this.form.bankAreaSelected[0] : '',
+        bankCity: _this.form.bankAreaSelected[1] ? _this.form.bankAreaSelected[1] : '',
+        bankCounty: _this.form.bankAreaSelected[2] ? _this.form.bankAreaSelected[2] : '',
+
+        bankNo: _this.form.bankNo,
+        password: _this.form.password,
+        payPassword: _this.form.payPassword,
+        packageId: _this.form.packageId,
+        goodsId: _this.form.goodsId,
+        goodsNum: _this.form.goodsNum,
+        location: _this.form.location,
+        decWay: _this.decWay,
+        payType: _this.form.payType
+      }
+
+      return network.postData(path, postData).then((response) => {
+        // 非PayStack支付
+        if (_this.form.payType !== 'pay_stack') {
+          console.log(response)
+          _this.$message({
+            message: response,
+            type: 'success'
+          })
+          _this.submitButtonStat = false
+          _this.$router.push({path: `/shop/ba-dec-order-list`})
+        } else {
+          // PayStack支付
+          _this.submitButtonStat = false
+          _this.PayStackForm.orderSn = response.SN
+          _this.PayStackForm.amount = response.ORDER_AMOUNT
+          _this.PayStackForm.metadata.custom_fields[0].value = response.SN
+          _this.visible = true
+        }
+      }).catch(response => {
+        _this.submitButtonStat = true
+        _this.$message({
+          message: response,
+          type: 'error'
+        })
+      })
+    },
+
+    selectOne (event, item) {
+      network.getData(`user/ba-dec`).then(response => {
+      })
+    },
+
+    handleChkConUser () {
+      if (this.form.conUserName) {
+        this.loading = true
+        network.getData('user/full-info', {userName: this.form.conUserName}).then(response => {
+          this.conRealName = response.REAL_NAME + response.isLocation
+          this.loading = false
+        }).catch(response => {
+          this.conRealName = '-'
+          this.loading = false
+        })
+      }
+    },
+
+    handleChkRecUser () {
+      this.form.conUserName = ''
+      this.conRealName = '-'
+      this.form.autoPlace = ''
+      if (this.form.recUserName) {
+        this.loading = true
+        network.getData('user/full-info', {userName: this.form.recUserName}).then(response => {
+          // console.log(response)
+          this.recRealName = response.REAL_NAME
+          this.loading = false
+        }).catch(response => {
+          this.recRealName = '-'
+          this.loading = false
+        })
+      }
+    },
+    // 切换支付方式
+    payMethodChange (type) {
+      this.form.payType = type
+    },
+    // 关闭支付回调
+    handleClose () {
+      let _this = this
+      _this.$confirm('Confirm to close?').then(() => {
+        return network.postData('shop/delete-approach-order', {orderSn: this.PayStackForm.orderSn}).then(() => {
+          // 关闭支付模态框
+          _this.visible = false
+        })
+      }).catch(() => {
+        // 关闭支付模态框
+        _this.visible = false
+      })
+    },
+    // 支付成功回调
+    processPayment (response) {
+      // 关闭支付页面
+      this.visible = false
+      this.payStackLoading = false
+
+      // 显示支付成功模态框
+      this.payDialog = true
+      this.handleCountdown()
+    },
+    // 关闭支付回调
+    processClose () {
+      // 关闭支付模态框
+      this.visible = false
+    },
+    // 支付tips结束,跳转到报单列表
+    handleOrderList () {
+      this.$router.push({path: `/shop/ba-dec-order-list`})
+    },
+    // 启动倒计时
+    handleCountdown () {
+      // 创建定时器
+      setInterval(() => {
+        // 每隔1秒把time的值减一,赋值给span标签
+        this.countdown--
+        if (this.countdown === 0) {
+          // 倒计时结束,跳转到报单列表
+          this.$router.push({path: `/shop/ba-dec-order-list`})
+        }
+      }, 1000)
+    }
+  }
+}
+</script>
+
+<style>
+  .hr-tip {
+    font-size: 12px;
+    position: relative;
+    text-align: center;
+    height: 30px;
+    line-height: 30px;
+    color: #999;
+    margin-bottom: 20px;
+  }
+
+  .hr-tip:before {
+    content: '';
+    display: block;
+    position: absolute;
+    left: 0;
+    right: 0;
+    top: 14px;
+    border-bottom: 1px dashed #ddd;
+    height: 1px;
+  }
+
+  .hr-tip span {
+    display: inline-block;
+    background: #fff;
+    position: relative;
+    padding: 0 10px;
+  }
+  .el-input-number--mini .el-input-number__decrease, .el-input-number--mini .el-input-number__increase{
+    width: 22px!important
+  }
+  .el-input-number.is-controls-right .el-input__inner{
+    padding-left: 10px;
+    padding-right: 30px;
+  }
+  .el-tabs--border-card{
+    position: relative;
+    width: 600px;
+  }
+  .flex{
+    display: flex;
+  }
+  .address{
+    /* height: 3rem; */
+    line-height: 3.5rem;
+  }
+  .address_box{
+    border-bottom: 1px solid #e3e3e3;
+  }
+  .sum{
+    display: inline-block;
+  }
+  .box{
+    margin: 1rem 0;
+    display: flex;
+    justify-content: flex-start;
+    align-items: center;
+    padding-bottom: 1rem;
+  }
+  .sum_box{
+    display: flex;
+    margin-left: 1rem;
+  }
+  .sum_box > div{
+    line-height: 2rem;
+  }
+  .sum_box > div:nth-child(1){
+    margin-right: 1rem;
+  }
+  .payButton {
+    border: none;
+    padding: 0;
+  }
+</style>

+ 37 - 3
frontendEle/src/views/user/dec.vue

@@ -2,10 +2,16 @@
   <div v-loading="loading">
     <div class="white-box">
       <el-form ref="form"  label-width="180px" class="form-page">
+        <el-form-item label="报单方式">
+          <el-radio-group v-model="form.decType" @change="decTypeChange()">
+            <el-radio label="normal" >Normal</el-radio>
+            <el-radio label="ba" >BA Upgrade</el-radio>
+          </el-radio-group>
+        </el-form-item>
         <div class="hr-tip"><span>Account Information<!--账号信息--></span></div>
 
         <el-form-item label="New member code"><!--会员编号-->
-          <el-input v-model="form.insertUserName"></el-input>
+          <el-input v-model="form.insertUserName" @blur="checkBaUser()"></el-input>
         </el-form-item>
         <el-form-item>
           <template slot="label">
@@ -125,7 +131,7 @@
 
         <div class="hr-tip"><span>Network Information</span></div><!--网络信息-->
         <el-form-item label="Sponsor code"><!--推荐人编号-->
-          <el-input v-model="form.recUserName" @change="handleChkRecUser">
+          <el-input v-model="form.recUserName" @change="handleChkRecUser" :readonly="recReadOnly">
             <template slot="append">【{{recRealName}}】</template>
           </el-input>
         </el-form-item>
@@ -356,7 +362,9 @@ export default {
       currentRow: null,
       decWay: '2',
       regionData: store.state.regionInfo.regionData,
+      recReadOnly: false,
       form: {
+        decType: 'normal',
         realName: '',
         decLv: '',
         insertUserName: '',
@@ -565,6 +573,7 @@ export default {
         city: _this.form.areaSelected[1] ? _this.form.areaSelected[1] : '',
         county: _this.form.areaSelected[2] ? _this.form.areaSelected[2] : '',
         address: _this.form.address,
+        decType: _this.form.decType,
         insertUserName: _this.form.insertUserName,
         decLv: _this.form.decLv,
         realName: _this.form.realName,
@@ -701,7 +710,32 @@ export default {
           this.$router.push({path: `/shop/dec-order-list`})
         }
       }, 1000)
-    }
+    },
+    decTypeChange () {
+      if (this.form.decType=='ba'){
+        this.form.insertUserName = ''
+      } else {
+        this.form.recUserName = ''
+        this.recRealName = '-'
+        this.recReadOnly = false
+        this.getData()
+      }
+    },
+    checkBaUser () {
+      if (this.form.decType === 'ba' && this.form.insertUserName !== '') {
+        this.loading = true
+        network.getData('user/ba-user-info', {userName: this.form.insertUserName}).then(response => {
+          // console.log(response.REAL_NAME)
+          this.form.recUserName = response.REC_USER_NAME
+          this.form.realName = response.REAL_NAME
+          this.handleChkRecUser()
+          this.recReadOnly = true
+          this.loading = false
+        }).catch(response => {
+          this.loading = false
+        })
+      }
+    },
   }
 }
 </script>