Bladeren bron

会员端BA会员功能

kevin_zhangl 3 jaren geleden
bovenliggende
commit
80fb1da213

+ 131 - 0
common/models/BaApproachOrder.php

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

+ 77 - 0
common/models/BaApproachOrderGoods.php

@@ -0,0 +1,77 @@
+<?php
+
+namespace common\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "{{%BA_APPROACH_ORDER_GOODS}}".
+ *
+ * @property string $ID
+ * @property string $ORDER_SN 订单ID
+ * @property string $GOODS_ID 商品ID
+ * @property string $GOODS_TITLE 商品名称
+ * @property string $PRICE 价格
+ * @property string $REAL_PRICE 实际价格
+ * @property string $PV 订货PV
+ * @property string $REAL_PV 实际PV
+ * @property string $TAX_RATE 税率
+ * @property string $POINT 兑换积分
+ * @property string $SKU_CODE 商品编码
+ * @property int $BUY_NUMS 购买数量
+ * @property string $P_CALC_MONTH 分区日期
+ * @property int CATEGORY_TYPE 商品分类
+ * @property int PAY_TYPE 支付方式
+ * @property string $EMAIL Email
+ */
+class BaApproachOrderGoods extends \common\components\ActiveRecord
+{
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return '{{%BA_APPROACH_ORDER_GOODS}}';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['ORDER_SN', 'GOODS_ID', 'GOODS_TITLE', 'SKU_CODE', 'CATEGORY_TYPE', 'PAY_TYPE', 'EMAIL'], 'required'],
+            [['PRICE', 'REAL_PRICE', 'PV', 'REAL_PV', 'POINT', 'CATEGORY_TYPE', 'PAY_TYPE', 'TAX_RATE'], 'number'],
+            [['BUY_NUMS'], 'integer'],
+            [['ID', 'ORDER_SN', 'GOODS_ID'], 'string', 'max' => 32],
+            [['GOODS_TITLE'], 'string', 'max' => 255],
+            [['SKU_CODE'], 'string', 'max' => 16],
+            [['ID'], 'unique'],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'ID' => 'ID',
+            'ORDER_SN' => '订单ID',
+            'GOODS_ID' => '商品ID',
+            'GOODS_TITLE' => '商品名称',
+            'PRICE' => '价格',
+            'REAL_PRICE' => '实际价格',
+            'PV' => '订货BV',
+            'REAL_PV' => '实际BV',
+            'TAX_RATE' => '税率',
+            'POINT' => '兑换积分',
+            'SKU_CODE' => '商品编码',
+            'BUY_NUMS' => '购买数量',
+            'P_CALC_MONTH' => '分区日期',
+            'CATEGORY_TYPE' => '商品分类',
+            'PAY_TYPE' => '支付方式',
+            'EMAIL' => 'Email'
+        ];
+    }
+}

+ 157 - 0
common/models/BaOrder.php

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

+ 77 - 0
common/models/BaOrderGoods.php

@@ -0,0 +1,77 @@
+<?php
+
+namespace common\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "{{%BA_ORDER_GOODS}}".
+ *
+ * @property string $ID
+ * @property string $ORDER_SN 订单ID
+ * @property string $GOODS_ID 商品ID
+ * @property string $GOODS_TITLE 商品名称
+ * @property string $PRICE 价格
+ * @property string $REAL_PRICE 实际价格
+ * @property string $PV 订货PV
+ * @property string $REAL_PV 实际PV
+ * @property string $TAX_RATE 税率
+ * @property string $POINT 兑换积分
+ * @property string $SKU_CODE 商品编码
+ * @property int $BUY_NUMS 购买数量
+ * @property string $P_CALC_MONTH 分区日期
+ * @property int CATEGORY_TYPE 商品分类
+ * @property int PAY_TYPE 支付方式
+ * @property string $EMAIL Email
+ */
+class BaOrderGoods extends \common\components\ActiveRecord
+{
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return '{{%BA_ORDER_GOODS}}';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['ORDER_SN', 'GOODS_ID', 'GOODS_TITLE', 'SKU_CODE', 'CATEGORY_TYPE', 'PAY_TYPE', 'EMAIL'], 'required'],
+            [['PRICE', 'REAL_PRICE', 'PV', 'REAL_PV', 'POINT', 'CATEGORY_TYPE', 'PAY_TYPE', 'TAX_RATE'], 'number'],
+            [['BUY_NUMS'], 'integer'],
+            [['ID', 'ORDER_SN', 'GOODS_ID'], 'string', 'max' => 32],
+            [['GOODS_TITLE'], 'string', 'max' => 255],
+            [['SKU_CODE'], 'string', 'max' => 16],
+            [['ID'], 'unique'],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'ID' => 'ID',
+            'ORDER_SN' => '订单ID',
+            'GOODS_ID' => '商品ID',
+            'GOODS_TITLE' => '商品名称',
+            'PRICE' => '价格',
+            'REAL_PRICE' => '实际价格',
+            'PV' => '订货BV',
+            'REAL_PV' => '实际BV',
+            'TAX_RATE' => 'TAX_RATE',
+            'POINT' => '兑换积分',
+            'SKU_CODE' => '商品编码',
+            'BUY_NUMS' => '购买数量',
+            'P_CALC_MONTH' => '分区日期',
+            'CATEGORY_TYPE' => '商品分类',
+            'PAY_TYPE' => '支付方式',
+            'EMAIL' => 'Email'
+        ];
+    }
+}

+ 79 - 0
common/models/BaReceiveAddress.php

@@ -0,0 +1,79 @@
+<?php
+
+namespace common\models;
+
+use Yii;
+
+/**
+ * This is the model class for table "{{%RECEIVE_ADDRESS}}".
+ *
+ * @property string $ID
+ * @property string $USER_ID 用户ID
+ * @property string $USER_NAME 用户编号
+ * @property string $CONSIGNEE 收货人
+ * @property string $MOBILE 收货人手机
+ * @property int $PROVINCE 省份名称
+ * @property int $CITY 城市名称
+ * @property int $COUNTY 县区名称
+ * @property string $LGA_NAME Lga
+ * @property string $CITY_NAME City
+ * @property string $ADDRESS 详细地址
+ * @property int $IS_DEFAULT 是否默认
+ * @property int $CREATED_AT 创建时间
+ * @property string $UPDATER 修改人
+ * @property int $UPDATED_AT 修改时间
+ */
+class BaReceiveAddress extends \common\components\ActiveRecord
+{
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return '{{%BA_RECEIVE_ADDRESS}}';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['USER_ID', 'USER_NAME', 'CONSIGNEE', 'MOBILE', 'PROVINCE', 'ADDRESS'], 'required'],
+            [['PROVINCE', 'IS_DEFAULT', 'CREATED_AT', 'UPDATED_AT'], 'integer'],
+            [['ID', 'USER_ID'], 'string', 'max' => 32],
+            [['USER_NAME'], 'string', 'max' => 16],
+            [['CONSIGNEE'], 'string', 'max' => 120],
+            [['MOBILE'], 'string', 'max' => 11],
+            [['ADDRESS'], 'string', 'max' => 255],
+            [['LGA_NAME'], 'string', 'max' => 50],
+            [['CITY_NAME'], 'string', 'max' => 50],
+            [['UPDATER'], 'string', 'max' => 10],
+            [['ID'], 'unique'],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'ID' => 'ID',
+            'USER_ID' => '用户ID',
+            'USER_NAME' => '用户编号',
+            'CONSIGNEE' => '收货人',
+            'MOBILE' => '收货人手机',
+            'PROVINCE' => '省份名称',
+            'CITY' => '城市名称',
+            'COUNTY' => '县区名称',
+            'LGA_NAME' => 'Lga Name',
+            'CITY_NAME' => 'City Name',
+            'ADDRESS' => '详细地址',
+            'IS_DEFAULT' => '是否默认',
+            'CREATED_AT' => '创建时间',
+            'UPDATER' => '修改人',
+            'UPDATED_AT' => '修改时间',
+        ];
+    }
+}

+ 494 - 0
common/models/forms/BaApproachOrderForm.php

@@ -0,0 +1,494 @@
+<?php
+namespace common\models\forms;
+
+use common\helpers\Cache;
+use common\helpers\Date;
+use common\components\Model;
+use common\helpers\Form;
+use common\helpers\LoggerTool;
+use common\helpers\PayStack;
+use common\helpers\user\Balance;
+use common\helpers\user\Cash;
+use common\helpers\user\Info;
+use common\libs\logging\operate\AdminOperate;
+use common\models\ApproachDecOrder;
+use common\models\ApproachOrder;
+use common\models\ApproachOrderGoods;
+use common\models\BaApproachOrder;
+use common\models\BaApproachOrderGoods;
+use common\models\BaOrder;
+use common\models\BaOrderGoods;
+use common\models\BaReceiveAddress;
+use common\models\DealType;
+use common\models\DecLevelLog;
+use common\models\DecOrder;
+use common\models\Order;
+use common\models\OrderGoods;
+use common\models\Period;
+use common\models\ReceiveAddress;
+use common\models\Region;
+use common\models\ShopGoods;
+use common\models\User;
+use common\models\UserNetwork;
+use yii\base\Exception;
+
+/**
+ * BAApproachOrderForm
+ */
+class BaApproachOrderForm extends Model
+{
+    public $sn;
+    public $expressCompany;
+    public $orderTrackNo;
+    public $status;
+    public $remark;
+    public $note;
+
+    public $type;
+    public $addressId;
+    public $payType;
+    public $goodsId;
+    public $goodsNum;
+    public $payPassword;
+    public $email;
+
+    public $userName;
+    public $consignee;
+    public $acceptMobile;
+    public $province;
+    public $city;
+    public $county;
+    public $lgaName;
+    public $cityName;
+    public $detailaddress;
+
+    private $_address;
+    private $_decAmount;
+    private $_decPv;
+    private $_freight;
+    private $_payAmount;
+    private $_orderGoods;
+
+    private $_model;
+
+    public function init()
+    {
+        parent::init();
+        $this->adminOperateLogger = new AdminOperate([
+            'fetchClass' => BaApproachOrder::class,
+        ]);
+        $this->payType = ShopGoods::SALE_TYPE[7]['label'];
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules(): array
+    {
+        return [
+            [['sn', 'expressCompany', 'orderTrackNo', 'status', 'remark','type','addressId','payType','goodsId','goodsNum', 'payPassword','userName','consignee','acceptMobile','province','lgaName','cityName','detailaddress','email'], 'trim'],
+            [['sn', 'expressCompany', 'orderTrackNo', 'status', 'remark','type','addressId','payType','goodsId','goodsNum', 'payPassword','userName','consignee','acceptMobile','province','detailaddress'], 'required'],
+            [['status'], 'isStatus'],
+            [['addressId'], 'isAddress'],
+            [['payPassword'], 'validatePassword'],
+        ];
+    }
+
+    public function attributeLabels(): array
+    {
+        return [
+            'sn' => 'Order code',//订单号
+            'expressCompany' => 'Express Company',//快递公司
+            'orderTrackNo' => 'Track Code',//快递单号
+            'status' => 'Status',//状态
+            'remark' => 'Remark',//备注
+            'type' => 'Order Type',//订单类型
+            'addressId' => 'AddressId',//收货地址
+            'payType' => 'PayType',//支付方式
+            'goodsId' => 'Product ID',// 商品编号
+            'goodsNum' => 'Quantity',//
+            'userName' => 'UserName',//复消会员编号
+            'consignee' => 'Consignee',//收货人
+            'acceptMobile' => 'Accept Mobile',//收货电话
+            'lgaName' => 'LgaName',
+            'cityName' => 'CityName',
+            'detailaddress' => 'Detail Address',// 收货详细地址
+            'email' => 'Email',
+        ];
+    }
+
+    /**
+     * 指定校验场景
+     * @return array
+     */
+    public function scenarios(): array
+    {
+        $parentScenarios =  parent::scenarios();
+        $customScenarios = [
+            // 管理员修改订单状态
+            'adminStatus' => ['sn', 'status'],
+            // 校验订单支付
+            'verifyPayStack' => ['sn', 'note', 'status'],
+            // 会员下单
+            'userOrder' => ['type', 'addressId', 'goodsId', 'goodsNum', 'note', 'payPassword'],
+        ];
+        return array_merge($parentScenarios, $customScenarios);
+    }
+
+    /**
+     * 校验之前
+     * @return bool
+     */
+    public function beforeValidate()
+    {
+        $parentValidate = parent::beforeValidate();
+        if ($this->sn) {
+            $this->_model = BaApproachOrder::findOne(['SN' => $this->sn]);
+            if (!$this->_model){
+                $this->addError('sn', 'Order does not exist');// 订单不存在
+                return false;
+            }
+        }
+
+        if ($this->scenario == 'verifyPayStack'){
+            if ($this->_model->STATUS != \Yii::$app->params['orderStatus']['notPaid']['value']) {
+                $this->addError('sn', '订单支付状态错误');
+                return false;
+            }
+        }
+
+        return $parentValidate;
+    }
+
+    /**
+     * 判断收货地址是否存在
+     * @param $attribute
+     * @param $params
+     */
+    public function isAddress($attribute, $params)
+    {
+        if (!$receiveAddress = BaReceiveAddress::find()->where(' ID=:ID', [':ID' => $this->addressId])->asArray()->one()) {
+            $this->addError($attribute, 'Receive address does not exist'); // 收货地址不存在
+        } else {
+            $this->_address = $receiveAddress;
+        }
+    }
+
+    /**
+     * 校验支付密码
+     * @param $attribute
+     * @param $params
+     */
+    public function validatePassword($attribute, $params) {
+        // TODO
+        if (!User::validatePayPassword(\Yii::$app->user->id, $this->payPassword)) {
+            $this->addError($attribute, 'The payment password is incorrect');//支付密码不正确
+        }
+    }
+
+    /**
+     * 判断支付方式
+     * @param $attribute
+     */
+    public function isPayType($attribute)
+    {
+        if ($this->payType != 'pay_stack'){
+            $this->addError($attribute, '只允许PayStack方式支付');
+            return;
+        }
+
+        // 一个订单只能包含一类商品
+        $goods = ShopGoods::find()->select('ID,CATEGORY_TYPE')->where(['in', 'ID', $this->goodsId])->andWhere(['STATUS' => 1])->asArray()->all();
+        $goodsCategoryType = array_unique(array_column($goods, 'CATEGORY_TYPE'));
+        if (count($goodsCategoryType) != 1) {
+            $this->addError($attribute, 'Order cannot contain multiple product categories');//订单不能包含多种商品分类
+        }
+    }
+
+    /**
+     * 校验类型
+     * @param $attribute
+     */
+    public function isStatus($attribute)
+    {
+        if($this->type && !in_array($this->type, \Yii::$app->params['orderStatus'])){
+            $this->addError($attribute, '订单状态类型错误');
+            return ;
+        }
+        if ($this->scenario == 'adminStatus'){
+            if ($this->status == $this->_model['STATUS']) {
+                $this->addError($attribute, '订单状态没有改变');
+                return ;
+            }
+            if($this->status == \Yii::$app->params['orderStatus']['notPaid'] && $this->_model['STATUS'] >= \Yii::$app->params['orderStatus']['delivery']) {
+                $this->addError($attribute, '订单已经进入物流状态不能改为未支付');
+                return ;
+            }
+            elseif($this->status == \Yii::$app->params['orderStatus']['paid'] && $this->_model['STATUS'] >= \Yii::$app->params['orderStatus']['cancel']) {
+                $this->addError($attribute, '订单已失效不能处理');
+                return ;
+            }
+            elseif($this->status == \Yii::$app->params['orderStatus']['delivery']) {
+                $this->addError($attribute, '订单不能单独处理为物流状态');
+                return ;
+            }
+            elseif($this->status == \Yii::$app->params['orderStatus']['complete'] && $this->_model['STATUS'] > \Yii::$app->params['orderStatus']['cancel']) {
+                $this->addError($attribute, '订单已失效不能处理');
+                return ;
+            }
+            elseif($this->status == \Yii::$app->params['orderStatus']['cancel']) {
+                if($this->_model['STATUS'] == \Yii::$app->params['orderStatus']['complete']) {
+                    $this->addError($attribute, '订单已完成不能取消');
+                    return ;
+                }
+                if($this->_model['STATUS'] == \Yii::$app->params['orderStatus']['del']) {
+                    $this->addError($attribute, '订单已删除不能取消');
+                    return ;
+                }
+            }
+            elseif($this->status == \Yii::$app->params['orderStatus']['del']) {
+                if($this->_model['STATUS'] == \Yii::$app->params['orderStatus']['complete']) {
+                    $this->addError($attribute, '订单已完成不能删除');
+                    return ;
+                }
+            }
+        }
+
+    }
+
+    /**
+     * 校验PayStack支付,更新订单状态.同步到正式订单.
+     * @throws Exception
+     */
+    public function verifyPayStack(): ?ApproachOrder
+    {
+        if (!$this->validate()) {
+            return null;
+        }
+
+        // 调用PayStack支付校验
+        LoggerTool::info([$this->note['reference'], $this->note]);
+        $payload = PayStack::transactionVerify($this->note['reference']);
+        LoggerTool::info($payload);
+        if ($payload['status'] !== true) {
+            throw new Exception(Form::formatErrorsForApi($payload['message']));
+        }
+        if ($payload['data']['amount'] != $this->_model->PAY_AMOUNT * 100) {
+            throw new Exception(Form::formatErrorsForApi('支付金额与订单金额不符'));
+        }
+
+        $db = \Yii::$app->db;
+        $transaction = $db->beginTransaction();
+        try {
+            // 更新准订单状态为已支付
+            $this->_model->STATUS = $this->status;
+            $this->_model->NOTE = json_encode($this->note);
+            $this->_model->PAY_AT = Date::utcToTime($this->note['paid_at']);
+            $this->_model->EMAIL = $this->note['email'];
+            if (!$this->_model->save()) {
+                throw new Exception(Form::formatErrorsForApi($this->_model->getErrors()));
+            }
+            // 更新订单商品的支付Email
+            BaApproachOrderGoods::updateAll(['EMAIL' => $this->note['email']], 'ORDER_SN = :ORDER_SN', [':ORDER_SN' => $this->sn]);
+
+            // 同步准订单到正式订单
+            BaOrder::insertOne($this->_model->toArray());
+            // 同步准订单商品到正式订单商品
+            $approachOrderGoods = BaApproachOrderGoods::findAllAsArray('ORDER_SN = :ORDER_SN', [':ORDER_SN' => $this->sn]);
+            foreach ($approachOrderGoods as &$approachOrderGood) {
+                $approachOrderGood['EMAIL'] = $this->email;
+            }
+            BaOrderGoods::batchInsert($approachOrderGoods);
+
+            // 删除中间表
+            BaApproachOrder::deleteAll('SN = :SN', [':SN' => $this->sn]);
+            BaApproachOrderGoods::deleteAll('ORDER_SN = :ORDER_SN', [':ORDER_SN' => $this->sn]);
+
+            $transaction->commit();
+        } catch (Exception $e) {
+            $transaction->rollBack();
+            $this->addError('edit', $e->getFile() . '  ' . $e->getMessage());
+            return null;
+        }
+
+        return $this->_model;
+    }
+
+    /**
+     * 复销
+     */
+    public function add()
+    {
+        if(!$this->validate()){
+            return null;
+        }
+
+        $ids = $this->goodsId;
+        $totalAmount = 0;
+        $totalPv = 0;
+        $goodsType = ShopGoods::GOODS_TYPE;
+        foreach ($this->goodsNum as $k => $v) {
+            if ($v) {
+                $goods = ShopGoods::findOneAsArray('ID = :ID AND STATUS = 1', [':ID' => $ids[$k]]);
+                if ($goods['STORE_NUMS'] > 0) {
+                    if ($goods['TYPE'] == 1 || $goods['TYPE'] == 2) {
+                        $discount = $goodsType[$goods['TYPE']]['discount'];
+                        $realPrice = $goods['SELL_PRICE'] * $discount/100;
+                        $realPv = $goods['PRICE_PV'] * $discount/100;
+                    } else {
+                        $discount = $goods['SELL_DISCOUNT'];
+                        $realPrice = $goods['SELL_PRICE'] * $discount;
+                        $realPv = $goods['PRICE_PV'] * $discount;
+                    }
+                    $totalAmount += $realPrice * intval($v);
+                    $totalPv += $realPv * intval($v);
+
+                    $this->_orderGoods[] = [
+                        'GOODS_ID' => $goods['ID'],
+                        'PRICE' => $goods['SELL_PRICE'],
+                        'PV' => 0,
+                        'REAL_PRICE' => $realPrice,
+                        'REAL_PV' => 0,
+                        'POINT' => 0,
+                        'BUY_NUMS' => intval($v),
+                        'TAX_RATE' => $goods['TAX_RATE'],
+                        'SKU_CODE' => $goods['GOODS_NO'],
+                        'GOODS_TITLE' => $goods['GOODS_NAME'],
+                        'CATEGORY_TYPE' => $goods['CATEGORY_TYPE'],
+                        'PAY_TYPE' => $this->payType,
+                        'EMAIL' => $this->email,
+                    ];
+                }
+            }
+        }
+
+        // 运费.奈拉
+        $freight = floatval(Cache::getSystemConfig()['freight']['VALUE'] ?? 0);
+        // 普通商品免运费阈值.奈拉
+        $freeShipping = floatval(Cache::getSystemConfig()['freeShipping']['VALUE'] ?? 0);
+
+        $this->_decAmount = $totalAmount;
+        $this->_decPv = $totalPv;
+        $this->_freight = ($totalAmount >= $freeShipping) ? 0 : $freight;
+        $this->_payAmount = $this->_decAmount + $this->_freight;
+
+        $db = \Yii::$app->db;
+        $transaction = $db->beginTransaction();
+        try {
+            // 创建订单
+            $orderResult = $this->addOrder();
+            if (!$orderResult) {
+                throw new Exception(Form::formatErrorsForApi($orderResult->getErrors()));
+            }
+
+            $transaction->commit();
+
+            return $orderResult;
+        } catch (\Exception $e) {
+            $transaction->rollBack();
+            $this->addError('add', $e->getMessage());
+            return null;
+        }
+    }
+
+    /**
+     * 复销订单
+     * @throws Exception
+     */
+    public function addOrder()
+    {
+        $periodObj = Period::instance();
+        $nowPeriodNum = $periodObj->getNowPeriodNum();
+        $nowCalcMonth = $periodObj->getYearMonth($nowPeriodNum);
+
+        $userId = \Yii::$app->user->id;
+        $userName = Info::getUserNameByUserId($userId); // TODO
+        $userMobile = Info::getUserMobileByUserId($userId); // TODO
+        $userEmail = Info::getUserEmailByUserId($userId); // TODO
+
+        // 加入订单信息
+        if ($this->_address['PROVINCE'] != 1) {
+            $warehouse = Region::getWarehouseByCode($this->_address['PROVINCE']);//仓库
+            if (!$warehouse) {
+//                throw new Exception('地区2暂时不支持配送,具体联系客服');
+            }
+        }else{
+            $warehouse = '01';
+        }
+
+        $_hasPV = 0;
+
+        $ordNo = $this->_generateSn();
+        $orderModel = new BaApproachOrder();
+        $orderModel->SN = 'OS' . $ordNo;
+        $orderModel->DEC_SN = 'DS' . $ordNo;
+        $orderModel->ORDER_TYPE = $this->type;
+        $orderModel->USER_ID = $userId;
+        $orderModel->USER_NAME = $userName;
+        $orderModel->ORDER_AMOUNT = $this->_decAmount;
+        $orderModel->PV = $_hasPV;
+        $orderModel->PAY_AMOUNT = $this->_payAmount;
+        $orderModel->PAY_PV = 0;
+        $orderModel->PAY_AT = 0;
+        $orderModel->PAY_TYPE = $this->payType;
+        $orderModel->PERIOD_NUM = $nowPeriodNum;
+        $orderModel->P_CALC_MONTH = Date::ociToDate($nowCalcMonth, Date::OCI_TIME_FORMAT_SHORT_MONTH);
+        $orderModel->FREIGHT = $this->_freight;
+        $orderModel->PAY_FREIGHT = $this->_freight;
+        $orderModel->CONSIGNEE = $this->_address['CONSIGNEE'] ?: $userName;
+        $orderModel->MOBILE = $this->_address['MOBILE'] ?: $userMobile;
+        $orderModel->LGA_NAME = $this->_address['LGA_NAME'];
+        $orderModel->CITY_NAME = $this->_address['CITY_NAME'];
+        $orderModel->ADDRESS = $this->_address['ADDRESS'];
+        $orderModel->FRONT_REMARK = $this->remark;
+        $orderModel->WAREHOUSE = $warehouse;
+        $orderModel->STATUS = \Yii::$app->params['orderStatus']['notPaid']['value'];
+        $orderModel->CREATED_AT = Date::nowTime();
+        $orderModel->CREATE_USER = $userName;
+        $orderModel->EMAIL = $userEmail ?: $userName . '@elken.net';
+        $orderModel->EXPRESS_TYPE = 1;
+        $orderModel->PROVINCE = 1;
+        $orderModel->CITY = 1;
+        $orderModel->COUNTY = 1;
+        if (!$orderModel->save()) {
+            $this->addErrors($orderModel->getErrors());
+            return false;
+        }
+
+        // 加入商品到订单商品表
+        foreach($this->_orderGoods as $key => $value) {
+            $this->_orderGoods[$key]['ORDER_SN'] = $orderModel->SN;
+            $this->_orderGoods[$key]['P_CALC_MONTH'] = Date::ociToDate($nowCalcMonth, Date::OCI_TIME_FORMAT_SHORT_MONTH);
+        }
+        BaApproachOrderGoods::batchInsert($this->_orderGoods);
+
+        return $orderModel;
+    }
+
+    /**
+     * 生成订单流水号
+     * @return string
+     */
+    private function _generateSn(): string
+    {
+        return Date::today('Ymd') . $this->_random(10, 1);
+    }
+
+    /**
+     * 生成随机数
+     * @param $length
+     * @param int $numeric
+     * @return string
+     */
+    private function _random($length, int $numeric = 0): string
+    {
+        $seed = base_convert(md5(microtime() . $_SERVER['DOCUMENT_ROOT']), 16, $numeric ? 10 : 35);
+        $seed = $numeric ? (str_replace('0', '', $seed) . '012340567890') : ($seed . 'zZ' . strtoupper($seed));
+        $hash = '';
+        $max = strlen($seed) - 1;
+        for ($i = 0; $i < $length; $i++) {
+            $hash .= $seed[mt_rand(0, $max)];
+        }
+        return $hash;
+    }
+}

+ 197 - 0
common/models/forms/BaReceiveAddressForm.php

@@ -0,0 +1,197 @@
+<?php
+namespace common\models\forms;
+
+use common\helpers\Date;
+use common\components\Model;
+use common\helpers\Form;
+use common\helpers\user\Info;
+use common\libs\logging\operate\UserOperate;
+use common\models\Ad;
+use common\models\BaReceiveAddress;
+use common\models\ReceiveAddress;
+use common\models\Region;
+use common\models\User;
+use common\models\UserInfo;
+use yii\base\Exception;
+
+class BaReceiveAddressForm extends Model
+{
+    public $id;
+    public $consignee;
+    public $mobile;
+    public $province;
+    public $city;
+    public $county;
+    public $lgaName;
+    public $cityName;
+    public $address;
+    public $isDefault;
+
+    /**
+     * @var BaReceiveAddress
+     */
+    private $_model;
+
+
+    public function init() {
+        parent::init();
+        $this->adminOperateLogger = new UserOperate([
+            'fetchClass' => BaReceiveAddress::class,
+        ]);
+    }
+
+    /**
+     * @inheritdoc
+     */
+    public function rules()
+    {
+        return [
+            [['id', 'consignee', 'mobile', 'province', 'lgaName', 'cityName', 'address', 'isDefault'], 'trim'],
+            [['id', 'consignee', 'mobile', 'province', 'lgaName', 'cityName', 'address'], 'required'],
+            [['mobile'], 'mobile'],
+            [['province'], 'exist', 'targetClass' => Region::class, 'targetAttribute' => 'REGION_CODE'],
+        ];
+    }
+
+    public function attributeLabels()
+    {
+        return [
+            'consignee' => 'Consignee',
+            'mobile' => 'Phone',
+            'province' => 'State',
+            'lgaName' => 'Local Government Area',
+            'cityName' => 'City Name',
+            'address' => 'Address',
+        ];
+    }
+
+    /**
+     * 指定校验场景
+     * @return array
+     */
+    public function scenarios()
+    {
+        $parentScenarios =  parent::scenarios();
+        $customScenarios = [
+            'userAdd' => ['consignee', 'mobile', 'province', 'lgaName', 'cityName', 'address', 'isDefault'],
+            'userEdit' => ['id', 'consignee', 'mobile', 'province', 'lgaName', 'cityName', 'address', 'isDefault'],
+            'userIsDefault' => ['id', 'isDefault'],
+        ];
+        return array_merge($parentScenarios, $customScenarios);
+    }
+
+    /**
+     * 校验之前
+     * @return bool
+     */
+    public function beforeValidate()
+    {
+        $parentResult = parent::beforeValidate();
+        if ($this->scenario == 'userAdd' || $this->scenario == 'userEdit' || $this->scenario == 'userIsDefault') {
+            if ($this->scenario == 'userAdd') {
+                $count = BaReceiveAddress::find()->where('USER_ID=:USER_ID', [':USER_ID' => \Yii::$app->user->id])->count();
+                if ($count > 10) {
+                    $this->addError('id', '最多只能添加10个收货地址');
+                    return $parentResult;
+                }
+            }
+            if ($this->id) {
+                $this->_model = BaReceiveAddress::findOne(["ID" => $this->id]);
+                if (!$this->_model){
+                    $this->addError('id', '地址不存在');
+                    return $parentResult;
+                }
+                if ($this->_model['USER_ID'] != \Yii::$app->user->id){
+                    $this->addError('id', '无权修改此地址');
+                    return $parentResult;
+                }
+            } else {
+                $this->_model = new BaReceiveAddress();
+            }
+        }
+
+        return $parentResult;
+    }
+
+    /**
+     * 添加编辑
+     * @return BaReceiveAddress|null
+     * @throws \yii\db\Exception
+     */
+    public function edit(){
+        if(!$this->validate()){
+            return null;
+        }
+        $db = \Yii::$app->db;
+        $transaction = $db->beginTransaction();
+        try {
+            // 如果设置了此项为默认则清空所有默认
+            if ($this->isDefault) {
+                BaReceiveAddress::updateAll(['IS_DEFAULT' => 0], 'USER_ID=:USER_ID', [':USER_ID' => \Yii::$app->user->id]);
+            }
+
+            if($this->scenario == 'userAdd'){
+                $this->_model->USER_ID = \Yii::$app->user->id;
+                $this->_model->USER_NAME = Info::getUserNameByUserId(\Yii::$app->user->id); // TODO:
+                $this->_model->CONSIGNEE = $this->consignee;
+                $this->_model->MOBILE = $this->mobile;
+                $this->_model->PROVINCE = $this->province;
+                $this->_model->LGA_NAME = $this->lgaName;
+                $this->_model->CITY_NAME = $this->cityName;
+                $this->_model->ADDRESS = $this->address;
+                $this->_model->IS_DEFAULT = $this->isDefault ? 1 : 0;
+                $this->_model->CREATED_AT = Date::nowTime();
+            } elseif($this->scenario == 'userEdit') {
+                $this->_model->CONSIGNEE = $this->consignee;
+                $this->_model->MOBILE = $this->mobile;
+                $this->_model->PROVINCE = $this->province;
+                $this->_model->LGA_NAME = $this->lgaName;
+                $this->_model->CITY_NAME = $this->cityName;
+                $this->_model->ADDRESS = $this->address;
+                $this->_model->IS_DEFAULT = $this->isDefault ? 1 : 0;
+                $this->_model->UPDATED_AT = Date::nowTime();
+            } elseif($this->scenario == 'userIsDefault') {
+                $this->_model->IS_DEFAULT = $this->isDefault ? 1 : 0;
+            } else {
+                throw new Exception('提交场景不存在');
+            }
+            if(!$this->_model->save()){
+                throw new Exception(Form::formatErrorsForApi($this->_model->getErrors()));
+            }
+            $transaction->commit();
+        } catch (Exception $e) {
+            $transaction->rollBack();
+            $this->addError('edit', $e->getMessage());
+            return null;
+        }
+        if($this->scenario == 'adminAdd'){
+            $this->adminOperateLogger->afterInsert($this->_model)->clean()->save([
+                'optType' => '添加收货地址',
+            ]);
+        } elseif($this->scenario == 'adminEdit') {
+            $this->adminOperateLogger->afterUpdate($this->_model)->clean()->save([
+                'optType' => '编辑收货地址',
+            ]);
+        }
+        return $this->_model;
+    }
+
+    /**
+     * 删除前
+     * @param $selected
+     */
+    public function beforeDelete($selected) {
+        $this->adminOperateLogger->fetchClass = Ad::class;
+        $this->adminOperateLogger->setIsBatch(true)->beforeDelete($selected, 'ID');
+    }
+    /**
+     * 删除
+     * @param $selected
+     * @throws Exception
+     */
+    public function delete($selected) {
+        $this->adminOperateLogger->clean()->save([
+            'optType' => '删除收货地址',
+        ]);
+    }
+}

+ 10 - 2
frontendApi/config/menu.php

@@ -14,6 +14,7 @@ return [
         'action'=>'index',
         'routePath'=>'dashboard/index',
         'show'=>1,
+        'brandAmbassador' => 1,
         'child'=>[
             ['name'=>'月奖金量', 'class'=>'', 'icon'=>'', 'controller'=>'dashboard', 'action'=>'bonus-num', 'routePath'=>'dashboard/bonus-num', 'show'=>0,],
         ]
@@ -26,15 +27,17 @@ return [
         'action'=>'',
         'routePath'=>'shop',
         'show'=>1,
+        'brandAmbassador' => 1,
         'child'=>[
-            ['name'=>'Products list', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'index', 'routePath'=>'shop/index', 'show'=>1,],//商品列表
+            ['name'=>'Products list', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'index', 'routePath'=>'shop/index', 'show'=>1],//商品列表
             ['name'=>'Welcome Pack management', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'dec', 'routePath'=>'user/dec', 'show'=>1,'allow'=>'declarer',],
             ['name'=>'Welcome Pack Listing', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'dec-order-list', 'routePath'=>'shop/dec-order-list', 'show'=>1,],//报单列表
             ['name'=>'Upgrade management', 'class'=>'', 'icon'=>'', 'controller'=>'upgrade', 'action'=>'dec', 'routePath'=>'user/upgrade', 'show'=>1,'allow'=>'declarer',],//升级管理
 //            ['name'=>'Repeat sales products', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'reconsume', 'routePath'=>'shop/reconsume', 'show'=>1,'allow'=>'studio'],//复消商品
-
 //            ['name'=>'申请退货', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'order-backing-out', 'routePath'=>'shop/order-backing-out', 'show'=>1,],//申请退货
             ['name'=>'Order List', 'class'=>'', 'icon'=>'', 'controller'=>'shop', 'action'=>'order-list', 'routePath'=>'shop/order-list', 'show'=>1,],//订单列表
+            ['name'=>'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订单列表
         ]
     ],
     'user'=>[
@@ -45,6 +48,7 @@ return [
         'action'=>'',
         'routePath'=>'user',
         'show'=>1,
+        'brandAmbassador' => 1,
         'child'=>[
             ['name'=>'Personal info', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'index', 'routePath'=>'user/index', 'show'=>1,],//个人资料
             //['name'=>'上传身份证', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'id-card', 'routePath'=>'user/id-card', 'show'=>0,],
@@ -52,6 +56,9 @@ return [
 //            ['name'=>'点位绑定列表', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'bind', 'routePath'=>'user/bind', 'show'=>1,],
 //            ['name'=>'点位绑定编辑', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'bind-edit', 'routePath'=>'user/bind-edit', 'show'=>0,],
             ['name'=>'Reset Password', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'password', 'routePath'=>'user/password', 'show'=>1],
+
+            ['name'=>'Personal info', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'ba-info', 'routePath'=>'user/ba-info', 'show'=>1, 'brandAmbassador' => 1],//个人资料
+            ['name'=>'Reset Password', 'class'=>'', 'icon'=>'', 'controller'=>'user', 'action'=>'ba-password', 'routePath'=>'user/ba-password', 'show'=>1, 'brandAmbassador' => 1],
         ]
     ],
     'atlas'=>[
@@ -142,6 +149,7 @@ return [
         'child'=>[
 //            ['name'=>'个人设置', 'class'=>'', 'icon'=>'', 'controller'=>'config', 'action'=>'base', 'routePath'=>'config/base', 'show'=>1,],
             ['name'=>'Shipping Address', 'class'=>'', 'icon'=>'', 'controller'=>'config', 'action'=>'receive-address-list', 'routePath'=>'config/receive-address-list', 'show'=>1,],//收货地址管理
+            ['name'=>'Shipping Address', 'class'=>'', 'icon'=>'', 'controller'=>'config', 'action'=>'ba-receive-address-list', 'routePath'=>'config/ba-receive-address-list', 'show'=>1, 'brandAmbassador' => 1],//BA收货地址管理
         ]
     ],
 ];

+ 17 - 0
frontendApi/config/urlManagerRules.php

@@ -79,6 +79,11 @@ return [
             'POST delete-approach-order' => 'delete-approach-order',
             'POST verify-approach-order' => 'verify-approach-order',
             'GET order-backing-out' => 'order-backing-out',
+            'GET ba-order-list' => 'ba-order-list',
+            'GET ba-product-list' => 'ba-product-list',
+            'GET ba-shopping-cart' => 'ba-shopping-cart',
+            'POST ba-sure-approach-order' => 'ba-sure-approach-order',
+            'POST ba-delete-approach-order' => 'ba-delete-approach-order',
         ],
     ],
     [
@@ -101,6 +106,11 @@ return [
             'GET full-info' => 'full-info',
             'GET get-auto-place' => 'get-auto-place',
             'GET user-base-info' => 'user-base-info',
+
+            'GET ba-info' => 'ba-info',
+            'POST ba-edit' => 'ba-edit',
+            'POST ba-password' => 'ba-password',
+            'POST ba-pay-password' => 'ba-pay-password',
         ],
     ],
     [
@@ -172,6 +182,13 @@ return [
             'POST receive-address-edit' => 'receive-address-edit',
             'POST receive-address-default' => 'receive-address-default',
             'POST receive-address-delete' => 'receive-address-delete',
+
+            'GET ba-receive-address-list' => 'ba-receive-address-list',
+            'GET ba-receive-address-one/<id>' => 'ba-receive-address-one',
+            'POST ba-receive-address-add' => 'ba-receive-address-add',
+            'POST ba-receive-address-edit' => 'ba-receive-address-edit',
+            'POST ba-receive-address-default' => 'ba-receive-address-default',
+            'POST ba-receive-address-delete' => 'ba-receive-address-delete',
         ],
     ],
     [

+ 101 - 4
frontendApi/modules/v1/controllers/ConfigController.php

@@ -10,6 +10,8 @@ namespace frontendApi\modules\v1\controllers;
 use common\helpers\Cache;
 use common\helpers\Form;
 use common\helpers\snowflake\SnowFake;
+use common\models\BaReceiveAddress;
+use common\models\forms\BaReceiveAddressForm;
 use common\models\forms\ReceiveAddressForm;
 use common\models\forms\UserConfigForm;
 use common\models\ReceiveAddress;
@@ -122,7 +124,7 @@ class ConfigController extends BaseController
         if(\Yii::$app->request->isPost) {
             return parent::edit(ReceiveAddressForm::class, 'Added Successfully', 'userAdd', ['edit']);
         }
-        return static::notice('非法访问', 400);
+        return static::notice('Illegal request', 400); // 非法请求
     }
 
     /**
@@ -134,7 +136,7 @@ class ConfigController extends BaseController
         if(\Yii::$app->request->isPost) {
             return parent::edit(ReceiveAddressForm::class, 'Modified Successfully', 'userEdit', ['edit']);
         }
-        return static::notice('非法访问', 400);
+        return static::notice('Illegal request', 400); // 非法请求
     }
 
     /**
@@ -146,7 +148,7 @@ class ConfigController extends BaseController
         if(\Yii::$app->request->isPost) {
             return parent::edit(ReceiveAddressForm::class, '添加收货地址成功', 'userIsDefault', ['edit']);
         }
-        return static::notice('非法访问', 400);
+        return static::notice('Illegal request', 400); // 非法请求
     }
 
     /**
@@ -168,7 +170,102 @@ class ConfigController extends BaseController
                 }
             } , true);
         }
-        return static::notice('非法访问', 400);
+        return static::notice('Illegal request', 400); // 非法请求
     }
 
+    /**
+     * 收货地址列表
+     * @return mixed
+     * @throws \yii\web\HttpException
+     */
+    public function actionBaReceiveAddressList() {
+        $condition = ' AND USER_ID=:USER_ID';
+        $params[':USER_ID'] = \Yii::$app->user->id;
+        $data = BaReceiveAddress::lists($condition, $params, [
+            'SELECT' => 'ID,CONSIGNEE,MOBILE,PROVINCE,LGA_NAME,CITY_NAME,ADDRESS,IS_DEFAULT',
+            'orderBy' => 'IS_DEFAULT DESC,CREATED_AT DESC',
+            'useSlaves' => true,
+        ]);
+        if($data['list']){
+            foreach($data['list'] as $key=>$row){
+                $data['list'][$key]['PROVINCE_NAME'] = Region::getCnName($row['PROVINCE']);
+            }
+        }
+        return static::notice($data);
+    }
+
+    /**
+     * 获取一条收货地址
+     * @return mixed
+     * @throws \yii\web\HttpException
+     */
+    public function actionBaReceiveAddressOne() {
+        $data = BaReceiveAddress::findOneAsArray(
+            'USER_ID=:USER_ID AND ID=:ID',
+            [':USER_ID'=>\Yii::$app->user->id, ':ID' => \Yii::$app->request->get('id')]
+        );
+        return static::notice($data);
+    }
+
+    /**
+     * 添加收货地址
+     * @return mixed
+     * @throws \yii\web\HttpException
+     */
+    public function actionBaReceiveAddressAdd() {
+        Region::updateToCache();
+        if (\Yii::$app->request->isPost) {
+            return parent::edit(BaReceiveAddressForm::class, 'Added Successfully', 'userAdd', ['edit']);
+        }
+        return static::notice('Illegal request', 400); // 非法请求
+    }
+
+    /**
+     * 编辑收货地址
+     * @return mixed
+     * @throws \yii\web\HttpException
+     */
+    public function actionBaReceiveAddressEdit() {
+        if(\Yii::$app->request->isPost) {
+            return parent::edit(BaReceiveAddressForm::class, 'Modified Successfully', 'userEdit', ['edit']);
+        }
+        return static::notice('Illegal request', 400); // 非法请求
+    }
+
+    /**
+     * 设置取消默认收货地址
+     * @return mixed
+     * @throws \yii\web\HttpException
+     */
+    public function actionBaReceiveAddressDefault() {
+        if(\Yii::$app->request->isPost) {
+            return parent::edit(BaReceiveAddressForm::class, '添加收货地址成功', 'userIsDefault', ['edit']);
+        }
+        return static::notice('Illegal request', 400); // 非法请求
+    }
+
+    /**
+     * 删除
+     * @return mixed
+     * @throws \yii\db\Exception
+     * @throws \yii\web\HttpException
+     */
+    public function actionBaReceiveAddressDelete() {
+        if(\Yii::$app->request->isPost) {
+            return parent::delete(BaReceiveAddress::class, null, function() {
+                // 如果没有默认地址的话,就在设置一个默认地址
+                if (!BaReceiveAddress::find()->where('USER_ID=:USER_ID AND IS_DEFAULT=1', [':USER_ID' => \Yii::$app->user->id])->exists()) {
+                    $addressNumber = BaReceiveAddress::find()->where('USER_ID=:USER_ID', [':USER_ID' => \Yii::$app->user->id])->count();
+                    if ($addressNumber >= 1) {
+                        $model = BaReceiveAddress::find()->where('USER_ID=:USER_ID', [':USER_ID' => \Yii::$app->user->id])->one();
+                        $model->IS_DEFAULT = 1;
+                        if (!$model->save()) {
+                            throw new Exception('更新默认地址失败');
+                        }
+                    }
+                }
+            } , true);
+        }
+        return static::notice('Illegal request', 400); // 非法请求
+    }
 }

+ 1 - 1
frontendApi/modules/v1/controllers/OauthController.php

@@ -197,7 +197,7 @@ class OauthController extends BaseController
                 return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
             }
         }
-        return static::notice('非法访问', 400);
+        return static::notice('Illegal request', 400); // 非法请求
     }
 
 }

+ 180 - 20
frontendApi/modules/v1/controllers/ShopController.php

@@ -8,7 +8,6 @@
 
 namespace frontendApi\modules\v1\controllers;
 
-use Codeception\PHPUnit\ResultPrinter\HTML;
 use common\helpers\Cache;
 use common\helpers\Date;
 use common\helpers\Form;
@@ -18,17 +17,18 @@ use common\helpers\user\Info;
 use common\models\ApproachDecOrder;
 use common\models\ApproachOrder;
 use common\models\ApproachOrderGoods;
-use common\models\DealType;
+use common\models\BaApproachOrder;
+use common\models\BaApproachOrderGoods;
+use common\models\BaOrder;
+use common\models\BaOrderGoods;
+use common\models\BaReceiveAddress;
 use common\models\DecOrder;
 use common\models\forms\ApproachOrderForm;
+use common\models\forms\BaApproachOrderForm;
 use common\models\forms\DeclarationForm;
 use common\models\forms\OrderForm;
 use common\models\Order;
-use common\models\OrderDec;
 use common\models\OrderGoods;
-use common\models\OrderGoodsDec;
-use common\models\OrderStandard;
-use common\models\OrderStandardGoods;
 use common\models\ReceiveAddress;
 use common\models\Region;
 use common\models\ShopGoods;
@@ -38,6 +38,7 @@ use common\models\UserWallet;
 use Yii;
 use yii\data\Pagination;
 use yii\db\Query;
+use yii\web\HttpException;
 
 
 class ShopController extends BaseController {
@@ -46,7 +47,7 @@ class ShopController extends BaseController {
     /**
      * 商品列表
      * @return mixed
-     * @throws \yii\web\HttpException
+     * @throws HttpException
      */
     public function actionIndex() {
         // 商品分类
@@ -78,7 +79,7 @@ class ShopController extends BaseController {
     /**
      * 获取商品详情
      * @return mixed
-     * @throws \yii\web\HttpException
+     * @throws HttpException
      */
     public function actionGoodsDetail(){
         $id = \Yii::$app->request->get('id');
@@ -91,7 +92,7 @@ class ShopController extends BaseController {
 
     /**
      * 购物车订单展示
-     * @throws \yii\web\HttpException
+     * @throws HttpException
      */
     public function actionShowCart(){
         $userId = \Yii::$app->user->id;
@@ -159,7 +160,7 @@ class ShopController extends BaseController {
 
     /**
      * 订单支付成功
-     * @throws \yii\web\HttpException
+     * @throws HttpException
      */
     public function actionPaySuccess(){
         $orderSn = \Yii::$app->request->get('orderSn');
@@ -190,7 +191,7 @@ class ShopController extends BaseController {
 
     /**
      * PayStack支付成功的webhook.
-     * @throws \yii\web\HttpException
+     * @throws HttpException
      * @throws \Exception
      */
     public function actionVerifyApproachOrder() {
@@ -206,10 +207,11 @@ class ShopController extends BaseController {
                 // 订单状态
                 $orderStatus = ($status == 'success') ? \Yii::$app->params['orderStatus']['paid']['value'] : \Yii::$app->params['orderStatus']['failPaid']['value'];
 
-                $customFields = $data['metadata']['custom_fields'][0] ?? [];
-                $oderSn = $customFields['value'] ?? '';
+                $customFields = $data['metadata']['custom_fields'] ?? [];
+                $oderSn = $customFields[0]['value'] ?? '';
+                $isBrandAmbassador = $customFields[1]['value'] ?? false;
 
-                $formModel = new ApproachOrderForm();
+                $formModel = !$isBrandAmbassador ? new ApproachOrderForm() : new BaApproachOrderForm();
                 $formModel->scenario = 'verifyPayStack';
                 $load = [
                     'sn' => $oderSn,
@@ -267,7 +269,7 @@ class ShopController extends BaseController {
     /**
      * 我的报单
      * @return mixed
-     * @throws \yii\web\HttpException
+     * @throws HttpException
      */
     public function actionDecOrderList() {
         $condition = ' DO.USER_ID=:USER_ID AND DO.IS_DEL=0';
@@ -328,7 +330,7 @@ class ShopController extends BaseController {
     /**
      * 我的订单
      * @return mixed
-     * @throws \yii\web\HttpException
+     * @throws HttpException
      */
     public function actionOrderList() {
         $uname = Info::getUserNameByUserId(\Yii::$app->user->id);
@@ -428,7 +430,7 @@ class ShopController extends BaseController {
 
     /**
      * 帮会员复消购物车
-     * @throws \yii\web\HttpException
+     * @throws HttpException
      */
     public function actionReconsumeCart(){
         $userId = \Yii::$app->user->id;
@@ -467,7 +469,7 @@ class ShopController extends BaseController {
     /**
      * 商品列表tabs分类
      * @return mixed
-     * @throws \yii\web\HttpException
+     * @throws HttpException
      */
     public function actionGoodsActive()
     {
@@ -499,7 +501,7 @@ class ShopController extends BaseController {
     /**
      * 导出订单.
      * @return mixed
-     * @throws \yii\web\HttpException
+     * @throws HttpException
      * @throws \Mpdf\MpdfException
      */
     public function actionOrderExport()
@@ -745,7 +747,7 @@ ORDER;
     /**
      * 导出订单.
      * @return mixed
-     * @throws \yii\web\HttpException
+     * @throws HttpException
      */
     public function actionDecOrderExport()
     {
@@ -995,4 +997,162 @@ ORDER;
         $file_name = 'orderBackingOut.xlsx';
         return static::notice(['fileUrl' => $file_name]);
     }
+
+    /**
+     * BA商品列表
+     * @return mixed
+     * @throws HttpException
+     */
+    public function actionBaProductList() {
+        // 商品分类
+        $categoryType = \Yii::$app->request->get('categoryType', 1);
+
+        $condition = ' AND STATUS=1 AND (FIND_IN_SET(2,GIFT_TYPE)>0';
+        $isStudio = User::getEnCodeInfo(\Yii::$app->user->id)['IS_STUDIO'];
+        if($isStudio==1){
+            $condition.= " OR FIND_IN_SET(4,GIFT_TYPE)>0";
+        }
+        $condition .= ") AND CATEGORY_TYPE = :CATEGORY_TYPE";
+        $params[':CATEGORY_TYPE'] = intval($categoryType);
+
+        $data = ShopGoods::lists($condition, $params, [
+            'orderBy' => 'SORT ASC,CREATED_AT DESC',
+            'from' => ShopGoods::tableName(),
+        ]);
+        foreach ($data['list'] as $key => $value) {
+            if ($value['TYPE'] == 1 || $value['TYPE'] == 2) {
+                $data['list'][$key]['DISCOUNT'] = ShopGoods::GOODS_TYPE[$value['TYPE']]['discount'];
+            } else {
+                $data['list'][$key]['DISCOUNT'] = $value['SELL_DISCOUNT']*100;
+            }
+        }
+        return static::notice($data);
+    }
+
+    /**
+     * BA购物车订单展示
+     * @throws HttpException
+     */
+    public function actionBaShoppingCart()
+    {
+        // 收货地址
+        $allAddress = BaReceiveAddress::findAllAsArray('USER_ID=:USER_ID', [':USER_ID' => \Yii::$app->user->id]);
+        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']);
+            }
+        }
+
+        // 运费.奈拉
+        $freight = floatval(Cache::getSystemConfig()['freight']['VALUE'] ?? 0);
+        // 普通商品免运费阈值.奈拉
+        $freeShipping = floatval(Cache::getSystemConfig()['freeShipping']['VALUE'] ?? 0);
+
+        return static::notice([
+            'freight'       => $freight,
+            'freeShipping'  => $freeShipping,
+            'allAddress'    => $allAddress,
+        ]);
+    }
+
+    /**
+     * 确认BA订单
+     * @throws HttpException|\yii\base\Exception
+     */
+    public function actionBaSureApproachOrder()
+    {
+        if (\Yii::$app->request->isPost) {
+            $formModel = new BaApproachOrderForm();
+            $formModel->scenario = 'userOrder';
+            $formModel->remark = '复销备注';
+            $post = \Yii::$app->request->post();
+            $post['type'] = DeclarationForm::TYPE_FX;
+            if ($formModel->load($post, '') && $order = $formModel->add()) {
+                return static::notice($order);
+            } else {
+                return static::notice(Form::formatErrorsForApi($formModel->getErrors()),400);
+            }
+        }
+    }
+
+    /**
+     * 删除BA准订单
+     * @throws HttpException
+     */
+    public function actionBaDeleteApproachOrder()
+    {
+        $orderSn = \Yii::$app->request->post('orderSn');
+        // 删除订单中间表
+        BaApproachOrder::deleteAll('SN = :SN', [':SN' => $orderSn]);
+        // 删除订单商品中间表
+        BaApproachOrderGoods::deleteAll('ORDER_SN = :ORDER_SN', [':ORDER_SN' => $orderSn]);
+
+        return static::notice('');
+    }
+
+    /**
+     * BA订单
+     * @return mixed
+     * @throws HttpException
+     */
+    public function actionBaOrderList()
+    {
+        $uname = Info::getUserNameByUserId(\Yii::$app->user->id);
+        $condition = " (USER_ID=:USER_ID OR CREATE_USER='$uname') AND O.IS_DELETE = 0";
+        $params[':USER_ID'] = \Yii::$app->user->id;
+        $orderQuery = BaOrder::find()
+            ->alias('O')
+            ->where($condition, $params)
+            ->select('O.*,U.REAL_NAME,SG.CATEGORY_TYPE,OG.REAL_PRICE,OG.TAX_RATE,OG.BUY_NUMS,OG.SKU_CODE,OG.GOODS_TITLE,OG.REAL_PV')
+            ->join('LEFT JOIN', User::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');
+
+        // 订单中间表只查询待支付和支付失败的订单
+        $params[':NOT_PAID'] = \Yii::$app->params['orderStatus']['notPaid']['value'];   // 待支付
+        $params[':FAIL_PAID'] = \Yii::$app->params['orderStatus']['failPaid']['value'];   // 支付失败
+        $orderStandardQuery = BaApproachOrder::find()
+            ->alias('O')
+            ->where($condition . ' AND (O.STATUS = :NOT_PAID OR O.STATUS = :FAIL_PAID)', $params)
+            ->select('O.*,U.REAL_NAME,SG.CATEGORY_TYPE,OG.REAL_PRICE,OG.TAX_RATE,OG.BUY_NUMS,OG.SKU_CODE,OG.GOODS_TITLE,OG.REAL_PV')
+            ->join('LEFT JOIN', User::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();
+
+        $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 $key => $value) {
+            $data['list'][$key]['ORDER_TYPE'] = 'Reselling';
+            $data['list'][$key]['PAY_AT'] = $value['PAY_AT'] ? Date::convert($value['PAY_AT'],'Y-m-d H:i:s') : '';
+            $data['list'][$key]['CREATED_AT'] = $value['CREATED_AT'] ? Date::convert($value['CREATED_AT'],'Y-m-d H:i:s') : '';
+            $data['list'][$key]['PAY_TYPE'] = array_column(ShopGoods::SALE_TYPE, NULL, 'label')[$value['PAY_TYPE']]['name'] ?? '';
+            $data['list'][$key]['STATUS'] = \Yii::$app->params['orderStatus'][$value['STATUS']]['label'] ?? '';
+            $data['list'][$key]['FULL_ADDRESS'] = $value['ADDRESS'];
+            $data['list'][$key]['TAX_AMOUNT'] = Tool::formatPrice(($value['REAL_PRICE'] - $value['REAL_PRICE'] / (1 + $value['TAX_RATE'] / 100)) * $value['BUY_NUMS']);
+            $data['list'][$key]['TOTAL_AMOUNT'] = Tool::formatPrice($value['REAL_PRICE'] * $value['BUY_NUMS']);
+            if ($value['LGA_NAME']) {
+                $data['list'][$key]['FULL_ADDRESS'] .= ', ' . $value['LGA_NAME'];
+            }
+        }
+
+        return static::notice($data);
+    }
 }

+ 41 - 3
frontendApi/modules/v1/controllers/UserController.php

@@ -70,7 +70,7 @@ class UserController extends BaseController {
                 return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
             }
         }
-        return static::notice('非法访问', 400);
+        return static::notice('Illegal request', 400); // 非法请求
     }
 
     /**
@@ -87,7 +87,7 @@ class UserController extends BaseController {
                 return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
             }
         }
-        return static::notice('非法访问', 400);
+        return static::notice('Illegal request', 400); // 非法请求
     }
 
     /**
@@ -105,7 +105,7 @@ class UserController extends BaseController {
                 return static::notice(Form::formatErrorsForApi($form->getErrors()), 400);
             }
         }
-        return static::notice('非法访问', 400);
+        return static::notice('Illegal request', 400); // 非法请求
     }
 
     /**
@@ -536,4 +536,42 @@ class UserController extends BaseController {
             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); // 非法请求
+    }
 }

+ 100 - 0
frontendEle/src/router/index.js

@@ -114,6 +114,42 @@ export const constantRouterMap = [
                     ],
                 },
             },
+            {
+                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: 'Order List',  // BA订单列表
+                    breadcrumb: [
+                        {title: 'Dashboard', path: '/dashboard/index'},//首页
+                        {title: 'Shopping Mall', path: '/shop/ba-order-list'}//商城管理
+                    ],
+                },
+            },
             // {
             //     path: '/shop/reconsume',
             //     component: _import('shop/reconsume'),
@@ -244,6 +280,30 @@ export const constantRouterMap = [
           ],
         },
       },
+      {
+        path: '/user/ba-info',
+        component: _import('user/ba-info'),
+        name: 'ba-info',
+        meta: {
+          title: 'Personal info',//个人资料
+          breadcrumb: [
+            {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',//重置密码
+          breadcrumb: [
+            {title: 'Dashboard', path: '/dashboard/index'},//首页
+            {title: 'Member management', path: '/user/index'},//会员管理
+          ],
+        },
+      },
     ]
   },
     {
@@ -561,6 +621,46 @@ export const constantRouterMap = [
         },
       },
 
+      {
+        path: '/config/ba-receive-address-list',
+        component: _import('config/ba-receive-address-list'),
+        name: 'ba-receive-address-list',
+        meta: {
+          title: 'Shipping Address',//收货地址管理
+          breadcrumb: [
+            {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',//添加收货地址
+          highLight: '/config/ba-receive-address-list',
+          breadcrumb: [
+            {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',
+        component: _import('config/ba-receive-address-edit'),
+        name: 'ba-receive-address-edit',
+        meta: {
+          title: 'Edit Address',
+          highLight: '/config/ba-receive-address-list',
+          breadcrumb: [
+            {title: 'Dashboard', path: '/dashboard/index'},//首页
+            {title: 'Setting', path: '/config/base'},//设置
+            {title: 'Shipping Address', path: '/config/ba-receive-address-list'},//收货地址管理
+          ],
+        },
+      },
     ]
   },
 ]

+ 149 - 0
frontendEle/src/views/config/ba-receive-address-edit.vue

@@ -0,0 +1,149 @@
+<template>
+  <div v-loading="loading">
+    <div class="white-box">
+      <el-form ref="form" :model="form" label-width="180px" style="width: 500px;">
+        <el-form-item>
+          <template slot="label">
+            <span class="text-danger">*</span>
+            Consignee<!-- 收货人 -->
+          </template>
+          <el-input v-model="form.consignee"></el-input>
+        </el-form-item>
+        <el-form-item>
+          <template slot="label">
+            <span class="text-danger">*</span>
+            Phone Number<!-- 手机号 -->
+          </template>
+          <el-input v-model="form.mobile"></el-input>
+        </el-form-item>
+        <el-form-item>
+          <template slot="label">
+            <span class="text-danger">*</span>
+            City
+          </template>
+          <el-input v-model="form.cityName"></el-input>
+        </el-form-item>
+        <el-form-item>
+          <template slot="label">
+            <span class="text-danger">*</span>
+            Local Government Area
+          </template>
+          <el-input v-model="form.lgaName"></el-input>
+        </el-form-item>
+        <el-form-item>
+          <template slot="label">
+            <span class="text-danger">*</span>
+            State<!-- 地区 -->
+          </template>
+          <el-select v-model="form.areaSelected">
+            <el-option v-for="(item,index) in regionData" :key="index" :label="item.label" :value="item.value"></el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item>
+          <template slot="label">
+            <span class="text-danger">*</span>
+            Detailed Address<!-- 详细地址 -->
+          </template>
+          <el-input v-model="form.address"></el-input>
+        </el-form-item>
+        <el-form-item>
+          <template slot="label">
+            Default<!-- 是否默认 -->
+          </template>
+          <el-switch v-model="form.isDefault" ></el-switch>
+        </el-form-item>
+        <el-form-item>
+          <el-button type="primary" @click="onSubmit" :loading="submitButtonStat">Confirm<!-- 确认 --></el-button>
+        </el-form-item>
+      </el-form>
+    </div>
+  </div>
+</template>
+
+<script>
+import store from '@/utils/vuexStore'
+import network from '@/utils/network'
+import tool from '@/utils/tool'
+import userInfo from '@/utils/userInfo'
+
+export default {
+  name: 'ba-receive-address-edit',
+  mounted () {
+    if (this.$route.name === 'ba-receive-address-add') {
+      this.loading = false
+    } else {
+      this.getData()
+    }
+  },
+  data () {
+    return {
+      regionData: store.state.regionInfo.regionData,
+      form: {
+        consignee: '',
+        mobile: '',
+        areaSelected: '',
+        lgaName: '',
+        cityName: '',
+        address: '',
+        isDefault: false,
+      },
+      loading: true,
+      submitButtonStat: false,
+    }
+  },
+  methods: {
+    onSubmit () {
+      this.submitButtonStat = true
+      let path = 'config/ba-receive-address-add'
+      let postData = {
+        consignee: this.form.consignee,
+        mobile: this.form.mobile,
+        province: this.form.areaSelected ? this.form.areaSelected : '',
+        lgaName: this.form.lgaName,
+        cityName: this.form.cityName,
+        address: this.form.address,
+        isDefault: this.form.isDefault,
+      }
+      if (this.$route.name === 'ba-receive-address-edit'){
+        path = 'config/ba-receive-address-edit'
+        postData = {
+          id: this.$route.params.id,
+          consignee: this.form.consignee,
+          mobile: this.form.mobile,
+          province: this.form.areaSelected ? this.form.areaSelected : '',
+          lgaName: this.form.lgaName,
+          cityName: this.form.cityName,
+          address: this.form.address,
+          isDefault: this.form.isDefault,
+        }
+      }
+      return network.postData(path, postData).then(response => {
+        this.$message({
+          message: response,
+          type: 'success'
+        })
+        this.submitButtonStat = false
+        this.$router.go(-1)
+      }).catch(() => {
+        this.submitButtonStat = false
+      })
+    },
+    getData () {
+      network.getData(`config/ba-receive-address-one/${this.$route.params.id}`).then(response => {
+        this.form.consignee = response.CONSIGNEE
+        this.form.mobile = response.MOBILE
+        this.form.areaSelected = response.PROVINCE
+        this.form.lgaName = response.LGA_NAME
+        this.form.cityName = response.CITY_NAME
+        this.form.address = response.ADDRESS
+        this.form.isDefault = response.IS_DEFAULT === '1'
+        this.loading = false
+      })
+    },
+  }
+}
+</script>
+
+<style scoped>
+
+</style>

+ 171 - 0
frontendEle/src/views/config/ba-receive-address-list.vue

@@ -0,0 +1,171 @@
+<template>
+    <div v-loading="loading">
+        <div class="white-box">
+            <el-table class="table-box" ref="multipleTable" :data="tableData" stripe style="width: 100%;">
+            <el-table-column label="Consignee" prop="CONSIGNEE" width="150"></el-table-column><!-- 收货人 -->
+            <el-table-column label="Phone Number" prop="MOBILE" width="150"></el-table-column><!-- 手机号码 -->
+            <el-table-column label="Address" prop="ADDRESS" ></el-table-column><!-- 详细地址 -->
+            <el-table-column label="City" prop="CITY_NAME" width="150"></el-table-column>
+            <el-table-column label="Local Government Area" prop="LGA_NAME" width="180"></el-table-column>
+            <el-table-column label="State" prop="PROVINCE_NAME" width="150"></el-table-column>
+            <el-table-column label="Default" width="100">
+                <template slot-scope="scope">
+                    {{scope.row.IS_DEFAULT === '1' ? 'YES' : 'NO'}}<!-- 是:否 -->
+                </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 command="edit" @click.native="handleUpdate(scope.row)">Edit</el-dropdown-item><!-- 编辑 -->
+                            <el-dropdown-item command="edit" @click.native="handleDelete(scope.row)">Delete</el-dropdown-item><!-- 删除 -->
+                        </el-dropdown-menu>
+                    </el-dropdown>
+                </template>
+            </el-table-column>
+            </el-table>
+            <div class="white-box-footer">
+                <el-button type="primary" size="small" @click="handleAdd">Add Shipping Address</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 Pagination from '@/components/Pagination'
+
+    export default {
+        name: 'ba-receive-address-list',
+        components: {
+            Pagination
+        },
+        mounted() {
+            this.loading = false;
+            this.getData();
+        },
+        data() {
+            return {
+                tableData: [],
+                loading: true,
+                multipleSelection: [],
+                currentPage: 1,
+                totalPages: 1,
+                totalCount: 1,
+                pageSize: 20,
+                tool: tool,
+                filterData: null,
+                filterStatus: 'ALL',
+                periodNum: null,
+                periodNums: null,
+                allType:{
+                    ORDER: '订货店补',
+                    TRANS: '转账店补',
+                    PROD: '产品补贴',
+                    TOOL: '工具流补贴'
+                },
+            }
+        },
+        methods: {
+            handleCurrentChange(page) {
+                this.getData(page, this.pageSize)
+            },
+            handleSizeChange(pageSize) {
+                this.getData(this.currentPage, pageSize)
+            },
+            getData(page, pageSize) {
+                let vueObj = this
+                network.getPageData(this, 'config/ba-receive-address-list', page, pageSize, {}, function (response) {
+                    vueObj.tableData = response.list
+                })
+            },
+            handleAdd() {
+                this.$router.push({path: `/config/ba-receive-address-add`})
+            },
+            handleUpdate (row) {
+                this.$router.push({path: `/config/ba-receive-address-edit/${row.ID}`})
+            },
+            handleDelete (row) {
+                this.$confirm(`Are you sure you want to delete the selected data?`, 'Hint', {//`确定要删除所选数据吗?`, '提示'
+                    confirmButtonText: 'Confirm',//确定
+                    cancelButtonText: 'Cancel',//取消
+                    type: 'warning'
+                }).then(() => {
+                    let selectedIds = [row.ID]
+                        return network.postData(`config/ba-receive-address-delete`, {selected: selectedIds})
+                }).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>
+  .leo-filter {
+    padding: 0 0 15px 0;
+  }
+
+  .leo-filter .filter-hidden {
+    display: none;
+  }
+
+  .filter-item {
+    margin-right: 10px;
+  }
+
+  @media (min-width: 768px) {
+    .leo-filter {
+    }
+
+    .leo-filter .filter-item {
+      display: inline-block;
+      max-width: 200px;
+    }
+
+    .leo-filter .filter-item.filter-date-month-picker {
+      display: inline-block;
+      max-width: 220px;
+    }
+
+    .leo-filter .filter-item.filter-date-range-picker {
+      display: inline-block;
+      max-width: 380px;
+    }
+
+    .leo-filter .filter-item.filter-filter-btn {
+      height: 38px;
+      width: 80px;
+    }
+
+    .leo-filter .filter-hidden {
+      display: none;
+    }
+  }
+
+  .table-box .el-form-item__label {
+    width: 100px;
+    color: #99a9bf;
+  }
+
+  .table-box .el-form-item {
+    width: 30%;
+    margin-right: 0;
+    margin-bottom: 0;
+  }
+</style>

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

@@ -0,0 +1,133 @@
+<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="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="Order Code" prop="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="130" label="Recipient name" prop="CONSIGNEE"></el-table-column><!--收货人-->
+                <el-table-column width="120" label="Phone Number" prop="MOBILE"></el-table-column><!--收货电话-->
+                <el-table-column width="150" label="Shipping Address" prop="FULL_ADDRESS"></el-table-column><!--收货地址-->
+                <el-table-column width="150" label="Payment" prop="PAY_TYPE"></el-table-column><!--支付方式-->
+                <el-table-column width="120" label="Created time" prop="CREATED_AT"></el-table-column><!--下单时间-->
+                <el-table-column width="120" label="Pay time" prop="PAY_AT"></el-table-column><!--支付时间-->
+                <el-table-column width="120" label="Pay Status" prop="STATUS"></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'
+
+export default {
+    name: "ba-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: {
+        handleCurrentChange (page) {
+            this.getData(page, this.pageSize)
+        },
+        handleSizeChange (pageSize) {
+            this.getData(this.currentPage, pageSize)
+        },
+        // 列表页合并
+        objectSpanMethod(obj) {
+            if (obj.columnIndex > 7) {
+                // ⼆维数组存储的数据取出
+                let _row = this.spanArr[obj.rowIndex];
+                let _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 (
+                        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].CONSIGNEE === orderList[index - 1].CONSIGNEE &&
+                        orderList[index].MOBILE === orderList[index - 1].MOBILE &&
+                        orderList[index].PAY_AT === orderList[index - 1].PAY_AT &&
+                        orderList[index].STATUS === orderList[index - 1].STATUS &&
+                        orderList[index].PAY_TYPE === orderList[index - 1].PAY_TYPE &&
+                        orderList[index].CREATED_AT === orderList[index - 1].CREATED_AT
+                    ) {
+                        // 查找到符合条件的数据时每次要把之前存储的数据+1
+                        this.spanArr[this.pos] += 1;
+                        this.spanArr.push(0);
+                    } else {
+                        // 没有符合的数据时,要记住当前的index
+                        this.spanArr.push(1);
+                        this.pos = index;
+                    }
+                }
+            });
+        },
+        // 查询列表数据
+        getData(page, pageSize) {
+            this.spanArr = [];
+            this.pos = 0;
+            let _this = this
+            network.getPageData(_this, 'shop/ba-order-list', page, pageSize, {type: this.type}, function (response) {
+                _this.loading = false;
+                _this.list = response.list;
+                let settingObj = _this.list;
+                _this.tableData = Object.keys(settingObj).map(item => {
+                    //把每个对象返回出去生成一个新的数组中相当于0:{id:1}
+                    return settingObj[item];
+                });
+                _this.getSpanArr(_this.tableData);
+            });
+        },
+    }
+}
+</script>
+<style scoped>
+
+</style>

+ 203 - 0
frontendEle/src/views/shop/ba-product-list.vue

@@ -0,0 +1,203 @@
+<template>
+    <div v-loading="loading">
+        <div class="white-box">
+            <el-table v-if="numList.length > 0" :max-height="maxHeight" class="withdraw-table" :data="tableData" stripe style="width: 100%;" ref="multipleTable" @selection-change="handleSelectionChange">
+              <el-table-column type="selection" width="55"></el-table-column>
+              <el-table-column label="Product Name" prop="GOODS_NAME"></el-table-column><!--商品名称-->
+              <el-table-column label="Product Picture"><!--图片-->
+                  <template slot-scope="scope">
+                      <el-image style="width: 100px; height: 100px" :src="tool.getArImage(scope.row.COVER, '/files/')" :preview-src-list="[tool.getArImage(scope.row.COVER, '/files/')]"></el-image>
+                  </template>
+              </el-table-column>
+
+              <el-table-column label="Product Price" prop="SELL_PRICE"><!--商品价格-->
+                  <template slot-scope="scope">
+                      <span>{{ Math.round(scope.row.SELL_PRICE * 100) / 100 }}</span>
+                  </template>
+              </el-table-column>
+
+              <el-table-column label="Tax rate" prop="TAX_RATE"><!--税率-->
+                  <template slot-scope="scope">
+                      <span>{{ Math.round(scope.row.TAX_RATE * 100) / 100 }}</span>
+                  </template>
+              </el-table-column>
+
+              <el-table-column label="Tax"><!--税额-->
+                  <template slot-scope="scope">
+                      <span>{{ Math.round((scope.row.SELL_PRICE - scope.row.SELL_PRICE / (1 + scope.row.TAX_RATE / 100)) * 100) / 100 }}</span>
+                  </template>
+              </el-table-column>
+
+              <el-table-column label="Inventory" prop="STORE_NUMS"></el-table-column><!--库存-->
+
+              <el-table-column label="Qty"  width="155"><!--数量-->
+                  <template slot-scope="scope">
+                      <el-input-number size="mini" v-model="numList[scope.$index]" :min="0" :max="Number(scope.row.STORE_NUMS)" @change="(val)=>{handleInputNumber(val, scope.row)}"></el-input-number>
+                  </template>
+              </el-table-column>
+            </el-table>
+
+            <div class="white-box-footer">
+                <el-button type="primary" size="small" @click="goToAccounts()">Check Out</el-button><!--去结算-->
+                <pagination :total="totalCount" :page_size="pageSize" @size-change="handleSizeChange" @current-change="handleCurrentChange"></pagination>
+            </div>
+            <div class='flex data' style="line-height: 35px; font-size: 14px;margin-top: 20px; border: 1px solid #dcdfe6; border-radius: 4px; padding: 0 15px;">
+              <div style="margin-right: 2rem;">Price:₦ {{ sell_price_sum }}</div><!--商品价格-->
+              <div>Tax:₦ {{ tax_sum }}</div><!--商品税额-->
+            </div>
+        </div>
+    </div>
+</template>
+
+<script>
+import network from '@/utils/network'
+import tool from '@/utils/tool'
+import Pagination from '@/components/Pagination'
+
+export default {
+    name: "ba-product-list",
+    components: {
+        Pagination
+    },
+    async created() {
+        await this.getData()
+    },
+    data() {
+        return {
+            loading: false,
+            num:1,
+            form:{},
+            tableData:[],
+            list: [],
+            tool: tool,
+            currentPage: 1,
+            totalPages: 1,
+            totalCount: 1,
+            pageSize: 20,
+            multipleSelection: [],
+            is_go_order: true,
+            numList: [],
+            selectLock: false,
+            maxHeight: tool.getTableHeight() - 35,
+            sell_price_sum: 0.00,
+            tax_sum: 0.00,
+        }
+    },
+    watch: {
+        '$route': function () {
+            this.getData()
+        },
+    },
+    methods: {
+        async getData (page, pageSize) {
+            let obj = this
+            await network.getPageData(this, `shop/ba-product-list`, page, pageSize, {}, function (response) {
+                obj.loading = false;
+                obj.currentPage = response.currentPage;
+                obj.list = response.list;
+                let settingObj=obj.list;
+                for (let i in settingObj) {
+                    obj.numList[i] = 1;
+                    settingObj[i].chose_num = 0;
+                }
+
+                obj.selectLock = true;
+                obj.tableData = Object.values(settingObj);
+                let pageList = obj.multipleSelection[obj.currentPage];
+                obj.$nextTick(function () {
+                    for(let i in obj.tableData){
+                        for( let j in  pageList) {
+                            if( pageList[j].ID === obj.tableData[i].ID ) {
+                                obj.numList[i] = pageList[j].chose_num;
+                                obj.tableData[i].chose_num = pageList[j].chose_num;
+                                break;
+                            }
+                        }
+                    }
+                    obj.selectLock = false;
+                })
+            })
+        },
+        goToAccounts() {
+            if (this.multipleSelection.length <= 0) {
+                this.$message.error('Please choose the products.')
+                return false
+            }
+
+            this.is_go_order = true;
+            setTimeout(() => {
+                if(this.is_go_order) {
+                    // 填充商品信息到购物车
+                    sessionStorage.setItem('order_goods', JSON.stringify(this.multipleSelection))
+                    this.$router.push({path: `/shop/ba-shopping-cart`});
+                }
+            })
+        },
+        handleSelectionChange(val) {
+            if( this.selectLock ) return;
+            let idx = -1,num;
+            for(let i in this.tableData){
+                for(let v in val){
+                    if(val[v].ID==this.tableData[i].ID){
+                        idx = i;
+                        num = this.numList[idx];
+                        val[v]["chose_num"] = num;
+                        break;
+                    }
+                }
+            }
+            this.multipleSelection[this.currentPage] = val;
+
+            // 计算统计
+            this.handleSureChange()
+        },
+        handleSureChange() {
+            if (this.multipleSelection.length > 0) {
+                let accumulatorSellPrice = 0, accumulatorPricePv = 0, accumulatorTax = 0;
+                this.multipleSelection.forEach(item => {
+                    item.forEach(accumulator => { accumulatorSellPrice += accumulator.SELL_PRICE * accumulator.chose_num * accumulator.DISCOUNT / 100; });
+                    item.forEach(accumulator => { accumulatorPricePv += Number(accumulator.PRICE_PV) * Number(accumulator.chose_num) * (Number(accumulator.DISCOUNT) / 100); });
+                    item.forEach(accumulator => { accumulatorTax += tool.calculateTax(Number(accumulator.SELL_PRICE), Number(accumulator.TAX_RATE), Number(accumulator.chose_num)); });
+                })
+
+                this.sell_price_sum = parseFloat(accumulatorSellPrice).toFixed(2);
+                this.price_pv_sum = parseFloat(accumulatorPricePv).toFixed(2);
+                this.tax_sum = parseFloat(accumulatorTax).toFixed(2);
+            } else {
+                this.sell_price_sum = 0.00;
+                this.price_pv_sum = 0.00;
+                this.tax_sum = 0.00;
+            }
+        },
+        handleInputNumber(val, row){
+            let pageList = this.multipleSelection[this.currentPage];
+            let selectStatus = false;
+            for(let i in pageList){
+                if( pageList[i].ID == row.ID ) {
+                    pageList[i].chose_num = val;
+                    selectStatus = true;
+                    break;
+                }
+            }
+
+            if( selectStatus ) {
+                this.multipleSelection[this.currentPage] = pageList;
+                // 计算统计
+                this.handleSureChange()
+            }
+        },
+        handleCurrentChange (page) {
+            this.getData(page, this.pageSize)
+        },
+        handleSizeChange (pageSize) {
+            this.getData(this.currentPage, pageSize)
+        },
+    }
+}
+</script>
+
+<style scoped>
+.flex{
+    display: flex;
+}
+</style>

+ 438 - 0
frontendEle/src/views/shop/ba-shopping-cart.vue

@@ -0,0 +1,438 @@
+<template>
+    <div v-loading="loading">
+        <div class="white-box">
+            <el-table :data="goods" style="width: 100%" show-summary :summary-method="getSummaries">
+                <el-table-column label="Product Name" prop="GOODS_NAME"></el-table-column><!--商品名称-->
+
+                <el-table-column label="Product Picture" ><!--图片-->
+                    <template slot-scope="scope">
+                        <el-image style="width: 100px; height: 100px" :src="tool.getArImage(scope.row.COVER, '/files/')" :preview-src-list="[tool.getArImage(scope.row.COVER, '/files/')]"></el-image>
+                    </template>
+                </el-table-column>
+
+                <el-table-column label="Product Price" prop="member_price"><!--商品价格-->
+                    <template slot-scope="scope">
+                        <span>{{ Math.round(scope.row.member_price * 100) / 100 }}</span>
+                    </template>
+                </el-table-column>
+
+                <el-table-column label="Tax Rate" prop="TAX_RATE"><!--税率-->
+                    <template slot-scope="scope">
+                        <span>{{ Math.round(scope.row.TAX_RATE * 100) / 100 }}</span>
+                    </template>
+                </el-table-column>
+
+                <el-table-column label="Tax" prop="tax_amount_plus"><!--税额-->
+                    <template slot-scope="scope">
+                        <span>{{ Math.round(scope.row.tax_amount_plus * 100) / 100 }}</span>
+                    </template>
+                </el-table-column>
+
+                <el-table-column label="Quantity" prop="chose_num"></el-table-column><!--数量-->
+
+                <el-table-column label="Total Amount" prop="member_price_plus"><!--合计金额-->
+                    <template slot-scope="scope">
+                        <span>{{ Math.round(scope.row.member_price_plus * 100) / 100 }}</span>
+                    </template>
+                </el-table-column>
+        </el-table>
+
+            <div class="address_box">
+                Please select the shipping address:	<!--  请选择收货地址 -->
+                <el-radio-group v-model="addressId" @change='choseAddress'>
+                    <div v-for="(item , index) in all_address" :key='index' class="address">
+                        <el-radio :label="item.ID" >
+                            Full Address:{{item.ADDRESS}}, {{item.CITY_NAME}}, {{item.LGA_NAME}}, {{item.PROVINCE_NAME}}<!-- 详细地址 -->
+                            Recipient Name:{{item.CONSIGNEE}}<!-- 收件人姓名 -->
+                            Phone Number:{{item.MOBILE}}<!-- 手机号码 -->
+                        </el-radio>
+                    </div>
+                    <div class="address">
+                        <el-radio label="100000000000000000">Self Pick-up</el-radio><!--自提-->
+                    </div>
+                </el-radio-group>
+            </div>
+
+            <div class="box address_box">
+                Total Orders:<!-- 订单合计 -->
+                <div class="sum">
+                    <div class="sum_box">
+                        <div>Freight</div><!-- 运费 -->
+                        <div>{{ pointFreight }} {{ unit }}</div>
+                    </div>
+                    <div class="sum_box">
+                        <div>Amount Paid</div><!-- 实付金额 -->
+                        <div>
+                            <span>{{ prefixSign }} {{ pointsSum }} {{ unit }}</span>
+                        </div>
+                    </div>
+                </div>
+          </div>
+
+            <div class="">
+                <el-button type="danger"  size="small" @click="cancelOrder()">Go Back</el-button>
+                <el-button type="primary" size="small" @click="goToAccounts()" :loading="submitButtonStat">Pay</el-button><!--去结算-->
+            </div>
+        </div>
+
+        <!-- payStack模态框 -->
+        <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="form">
+                            <el-form-item label="Email" label-width="100px" required>
+                                <el-input v-model="form.email" autocomplete="off"></el-input>
+                            </el-form-item>
+                            <el-form-item label="Amount" label-width="100px" required>
+                                <el-input v-model="form.amount" autocomplete="off" readonly></el-input>
+                            </el-form-item>
+                        </el-form>
+                    </div>
+                </div>
+            </section>
+            <paystack
+                :firstname="form.firstname"
+                :lastname="form.lastname"
+                :amount="form.amount * 100"
+                :email="form.email"
+                :metadata="form.metadata"
+                :currency="form.currency"
+                :paystackkey="form.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 network from '@/utils/network';
+import tool from '@/utils/tool';
+import userInfo from '@/utils/userInfo';
+import store from '@/utils/vuexStore';
+import { PAY_STACK_PUBLIC_KEY, PAY_STACK_CURRENCY } from '@/utils/config';
+import paystack from 'vue-paystack';
+
+export default{
+    name: 'ba-shopping-cart',
+    data: function () {
+        return {
+            tool: tool,
+            loading: true,
+            goods: [],
+            payList: [],
+            pointsSum: '',
+            cashSum: '',
+            freight: '',
+            pointFreight: '',
+            freeShipping: '',
+            goodsId: '',
+            goodsNum: '',
+            payPassword: '',
+            submitButtonStat: false,
+            prefixSign: '₦',
+            unit: 'NGN',
+            sn: '',
+            orderType: '',
+            payDialog: false,
+            countdown: 5,
+            visible: false,
+            payType: 'pay_stack',
+            payStackLoading: false,
+            channels: ["card", "bank", "ussd", "qr"], // eft(南非)  mobile_money(加纳)
+            form: {
+                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
+                        },
+                        {
+                            display_name: 'isBrandAmbassador',
+                            variable_name: 'isBrandAmbassador',
+                            value: true,
+                        },
+                    ]
+            },
+          },
+            regionData: store.state.regionInfo.regionData,
+            addressId: '100000000000000000',
+            all_address: [],
+        }
+    },
+    components: {
+        paystack
+    },
+    created() {
+        // 加载sessionStorage中推送的商品
+        let option = sessionStorage.getItem('order_goods');
+        // 加载购物车
+        this.getShowCart();
+        if (option) {
+            let pageGoodsList = JSON.parse(option);
+            let pageList;
+            for (let i in pageGoodsList) {
+                pageList = pageGoodsList[i];
+                if (!pageList) continue;
+
+                pageList.map((pageData, index) => {
+                    if (Number(pageData.chose_num) > 0) {
+                        let discount = pageData.DISCOUNT / 100;
+                        pageData.member_price = Math.round(pageData.SELL_PRICE * discount * 100) / 100;
+                        pageData.member_price_plus = Math.round(pageData.SELL_PRICE * Number(pageData.chose_num) * discount * 100) / 100;
+                        pageData.tax_amount_plus = Math.round((pageData.member_price - pageData.member_price / (1 + pageData.TAX_RATE / 100)) * pageData.chose_num * 100) / 100;
+                        this.goods.push(pageData)
+                    }
+                })
+            }
+            // 计算价格
+          this.getSumMoney();
+        }
+    },
+    computed: {
+        // PayStack混淆串
+        reference() {
+            let text = '';
+            let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
+            for (let i = 0; i < 10; i++) {
+                text += possible.charAt(Math.floor(Math.random() * possible.length));
+            }
+            return text;
+        }
+    },
+    methods: {
+        // 取消订单
+        cancelOrder() {
+            history.go(-1)
+        },
+        // 设置运费
+        setFreight() {
+            // 如果地址为自提,则运费为0
+            this.pointFreight = (this.addressId === '100000000000000000') ? Number(0) : Number(this.freight);
+        },
+        // 表格合并
+        getSummaries(param) {
+            const { columns, data } = param;
+            const sums = [];
+            columns.forEach((column, index) => {
+                if (index === 0) {
+                    sums[index] = 'Total'; // 合计
+                    return;
+                }
+                const values = data.map(item => Number(item[column.property]));
+                if ((!values.every(value => isNaN(value))) && [4, 5, 6].includes(index)) {
+                    sums[index] = values.reduce((prev, curr) => {
+                        const value = Number(curr);
+                        if (!isNaN(value)) {
+                            return Math.round((prev + curr) * 100) / 100;
+                        } else {
+                            return Math.round(prev * 100) / 100;
+                        }
+                    }, 0);
+                }
+            });
+
+            return sums;
+        },
+        // 支付
+        goToAccounts() {
+            this.submitButtonStat = true
+            this.$prompt('Please enter your payment password', 'Hint', { // '请输入支付密码', '提示'
+                confirmButtonText: 'Confirm', // 确定
+                cancelButtonText: 'Cancel', // 取消
+                inputType: 'password',
+                inputPattern: /\S+/,
+                inputErrorMessage: 'Please enter your payment password' // 请输入支付密码
+            }).then(({value}) => {
+                this.payPassword = value
+                let params = {
+                    goodsId: this.goodsId,
+                    goodsNum: this.goodsNum,
+                    payPassword: this.payPassword,
+                    email: this.form.email,
+                    addressId: this.addressId,
+                    address: this.address,
+                };
+
+                // PayStack支付
+                return network.postData('shop/ba-sure-approach-order', params).then(response => {
+                    this.submitButtonStat = false;
+                    this.form.orderSn = response.SN;
+                    this.form.amount = this.cashSum;
+                    this.form.metadata.custom_fields[0].value = response.SN;
+                    this.visible = true;
+                }).catch(_ => {
+                    this.submitButtonStat = false;
+                });
+            }).catch(_ => {
+                this.submitButtonStat = false;
+            });
+        },
+        // 计算价格
+        getSumMoney () {
+            let cash_plus_sum = [];
+            let goodsId = [];
+            let goodsNum = [];
+            let choseNum = 0;
+            this.goods.map(item => {
+                choseNum = Number(item.chose_num);
+                if (choseNum > 0) {
+                    cash_plus_sum.push(item.SELL_PRICE * choseNum * (item.DISCOUNT / 100));
+                    goodsId.push(item.ID);
+                    goodsNum.push(choseNum);
+                }
+            })
+            this.goodsNum = goodsNum;
+            this.goodsId = goodsId;
+            // 增加运费
+            let payAmount = tool.sum(cash_plus_sum);
+            // 设置运费
+            this.setFreight();
+            // 商品总价大于预定值,免运费
+            this.pointFreight = (this.pointFreight > 0) ? ((payAmount >= this.freeShipping) ? 0 : this.freight) : 0
+            // 计算总价
+            this.pointsSum = this.cashSum = this.form.amount = tool.formatPrice(tool.sum(cash_plus_sum) + this.pointFreight) ;
+        },
+        // 展示购物车信息
+        getShowCart () {
+            network.getData('shop/ba-shopping-cart', {}).then(response => {
+                this.loading = false;
+                // 免运费阈值
+                this.freeShipping = response.freeShipping;
+                // 运费
+                this.freight = response.freight;
+                // 收货地址
+                this.all_address = response.allAddress;
+                this.all_address.map((item, index) => {
+                    if (item.IS_DEFAULT === 1) {
+                        this.addressId = item.ID
+                    }
+                })
+            }).catch(_ => {
+                this.loading = false;
+            })
+        },
+        // 选择收货地址
+        choseAddress (addressId) {
+            this.addressId = addressId;
+            // 设置运费
+            this.setFreight()
+            // 计算价格
+            this.getSumMoney()
+        },
+        // 关闭支付回调
+        handleClose() {
+            let _this = this
+            _this.$confirm('Confirm to close?').then(_ => {
+                return network.postData('shop/ba-delete-approach-order', { orderSn: this.form.orderSn }).then(_ => {
+                    // 关闭支付模态框
+                    _this.visible = false
+                    // 关闭购物车页面,返回到订单列表页
+                    sessionStorage.setItem('order_goods', null)
+                    this.$router.push({path: `/shop/ba-product-list`})
+                })
+            }).catch(_ => {
+                // 关闭支付模态框
+                _this.visible = false
+                // 关闭购物车页面,返回到订单列表页
+                sessionStorage.setItem('order_goods', null)
+                this.$router.push({path: `/shop/ba-product-list`})
+            })
+        },
+        // 支付成功回调
+        processPayment() {
+            // 关闭支付页面
+            this.visible = false
+            this.payStackLoading = false
+            // 显示支付成功模态框
+            this.payDialog = true;
+            // 启动支付成功倒计时
+            this.handleCountdown()
+        },
+        // 关闭支付回调
+        processClose () {
+            // 关闭支付模态框
+            this.visible = false
+            // 关闭购物车页面,返回到订单列表页
+            sessionStorage.removeItem('order_goods')
+            this.$router.push({path: `/shop/ba-product-list`})
+        },
+        // 倒计时结束跳转
+        handleOrderList () {
+            this.$router.push({path: `/shop/ba-order-list`})
+        },
+        // 启动倒计时
+        handleCountdown () {
+            // 创建定时器
+            setInterval(() => {
+                // 每隔1秒把time的值减一,赋值给span标签
+                this.countdown--
+                if (this.countdown === 0) {
+                    // 倒计时结束,跳转到订单列表
+                    this.$router.push({path: `/shop/ba-order-list`});
+                }
+            }, 1000)
+        },
+    },
+}
+</script>
+
+<style scoped>
+.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>

+ 100 - 0
frontendEle/src/views/user/ba-info.vue

@@ -0,0 +1,100 @@
+<template>
+  <div v-loading="loading">
+    <div class="white-box">
+      <el-tabs v-model="tabActive" style="overflow: auto">
+        <el-tab-pane label="Essential Information" name="baseInfo" style="overflow: auto"><!-- 基本信息 -->
+          <el-form ref="form" :model="infoData" label-width="250px" class="form-page">
+            <el-form-item label="Member code"><!-- 会员编号 -->
+              <el-input v-model="infoData.USER_NAME" :disabled="true"></el-input>
+            </el-form-item>
+
+            <el-form-item label="Member name"><!-- 会员姓名 -->
+              <el-input v-model="infoData.REAL_NAME" :disabled="true"></el-input>
+            </el-form-item>
+
+            <el-form-item label="Phone Number"><!-- 手机号 -->
+              <el-input v-model="infoData.MOBILE" :disabled="true"></el-input>
+            </el-form-item>
+
+            <el-form-item label="Email"><!-- Email -->
+              <el-input v-model="infoData.EMAIL"></el-input>
+            </el-form-item>
+
+            <el-form-item>
+              <el-button type="primary" @click="handleSubmit" :loading="submitButtonStat">Confirm<!-- 保存 --></el-button>
+            </el-form-item>
+
+          </el-form>
+        </el-tab-pane>
+      </el-tabs>
+    </div>
+  </div>
+</template>
+
+<script>
+import network from './../../utils/network'
+
+export default {
+  name: 'ba-info',
+  mounted () {
+    this.getData()
+  },
+  data () {
+    return {
+      infoData: {
+        USER_NAME: '',
+        NATION: '',
+        REAL_NAME: '',
+        MOBILE: '',
+        OPEN_BANK: '',
+        BANK_ADDRESS: '',
+        BANK_NO: '',
+        EMAIL: '',
+      },
+      allOpenBank: null,
+      allNation: null,
+      tabActive: 'baseInfo',
+      loading: true,
+      submitButtonStat: false,
+    }
+  },
+  methods: {
+    getData () {
+      network.getData('user/ba-info').then(response => {
+        this.infoData = response.userInfo
+        this.allOpenBank = response.allOpenBank
+        this.allNation = response.allNation
+        this.loading = false
+      })
+    },
+    handleSubmit(){
+        this.submitButtonStat = true
+        let path = 'user/ba-edit'
+        let postData = {
+            nation: this.infoData.NATION,
+            realName: this.infoData.REAL_NAME,
+            mobile: this.infoData.MOBILE,
+            openBank: this.infoData.OPEN_BANK,
+            bankAddress: this.infoData.BANK_ADDRESS,
+            bankNo: this.infoData.BANK_NO,
+            email: this.infoData.EMAIL,
+        }
+        return network.postData(path, postData).then(response => {
+            this.$message({
+                message: response,
+                type: 'success'
+            })
+            this.submitButtonStat = false
+            this.getData();
+        }).catch(() => {
+            this.submitButtonStat = false
+        })
+    },
+  }
+}
+
+</script>
+
+<style scoped>
+
+</style>

+ 106 - 0
frontendEle/src/views/user/ba-password.vue

@@ -0,0 +1,106 @@
+<template>
+  <div v-loading="loading">
+    <div class="white-box">
+      <el-tabs v-model="tabActive" style="overflow: auto">
+        <el-tab-pane label="Login password" name="password" style="overflow: auto"><!--登录密码-->
+          <el-form ref="form" :model="passwordInfo" label-width="250px" class="form-page">
+            <el-form-item label="Original Login password"><!--原登录密码-->
+              <el-input v-model="passwordInfo.oldPassword" show-password></el-input>
+            </el-form-item>
+            <el-form-item label="New Login password"><!--新登录密码-->
+              <el-input v-model="passwordInfo.password" show-password></el-input>
+            </el-form-item>
+            <el-form-item label="Confirm new password"><!--确认新密码-->
+              <el-input v-model="passwordInfo.verifyPassword" show-password></el-input>
+            </el-form-item>
+            <el-form-item>
+              <el-button type="primary" @click="handlePasswordSubmit" :loading="passwordButtonStat">Confirm</el-button><!--确认-->
+            </el-form-item>
+          </el-form>
+        </el-tab-pane>
+
+        <el-tab-pane label="Payment password" name="payPassword" style="overflow: auto"><!--支付密码-->
+          <el-form ref="form" :model="payPasswordInfo" label-width="250px" class="form-page">
+            <el-form-item label="Original payment password"><!--原支付密码-->
+              <el-input v-model="payPasswordInfo.oldPassword" show-password></el-input>
+            </el-form-item>
+            <el-form-item label="New payment password"><!--新支付密码-->
+              <el-input v-model="payPasswordInfo.payPassword" show-password></el-input>
+            </el-form-item>
+            <el-form-item label="Confirm new password"><!--确认新密码-->
+              <el-input v-model="payPasswordInfo.verifyPassword" show-password></el-input>
+            </el-form-item>
+            <el-form-item>
+              <el-button type="primary" @click="handlePayPasswordSubmit" :loading="payPasswordButtonStat">Confirm</el-button><!--确认-->
+            </el-form-item>
+          </el-form>
+        </el-tab-pane>
+      </el-tabs>
+    </div>
+  </div>
+</template>
+
+<script>
+import network from './../../utils/network'
+
+export default {
+  name: 'ba-password',
+  mounted () {
+  },
+  data () {
+    return {
+      passwordInfo:{
+          oldPassword:'',
+          password:'',
+          verifyPassword:'',
+      },
+      payPasswordInfo:{
+          oldPassword:'',
+          payPassword:'',
+          verifyPassword:'',
+      },
+      tabActive: 'password',
+      loading: false,
+      passwordButtonStat:false,
+      payPasswordButtonStat:false,
+    }
+  },
+  methods: {
+    handlePasswordSubmit(){
+        this.passwordButtonStat = true
+        let path = 'user/ba-password'
+        return network.postData(path, this.passwordInfo).then(response => {
+
+            this.$message({
+                message: response,
+                type: 'success'
+            })
+            this.passwordButtonStat = false
+        }).catch(() => {
+            this.passwordButtonStat = false
+        })
+    },
+
+    handlePayPasswordSubmit(){
+        this.payPasswordButtonStat = true
+        let path = 'user/ba-pay-password'
+        return network.postData(path, this.payPasswordInfo).then(response => {
+
+            this.$message({
+                message: response,
+                type: 'success'
+            })
+            this.payPasswordButtonStat = false
+        }).catch(() => {
+            this.payPasswordButtonStat = false
+        })
+    },
+
+  }
+}
+
+</script>
+
+<style scoped>
+
+</style>

+ 228 - 0
sql/upgrade/1962.sql

@@ -0,0 +1,228 @@
+CREATE TABLE `AR_BA_APPROACH_ORDER_GOODS` (
+  `ID` varchar(32) COLLATE utf8mb4_bin NOT NULL,
+  `ORDER_SN` varchar(32) COLLATE utf8mb4_bin NOT NULL,
+  `GOODS_ID` varchar(32) COLLATE utf8mb4_bin NOT NULL,
+  `GOODS_TITLE` varchar(255) COLLATE utf8mb4_bin NOT NULL,
+  `PRICE` decimal(16,2) NOT NULL DEFAULT 0.00,
+  `REAL_PRICE` decimal(16,2) NOT NULL DEFAULT 0.00,
+  `PV` decimal(16,2) NOT NULL DEFAULT 0.00,
+  `REAL_PV` decimal(16,2) NOT NULL DEFAULT 0.00,
+  `STANDARD_PRICE` float(16,2) NOT NULL DEFAULT 0.00 COMMENT '标准价格',
+  `REAL_STANDARD_PRICE` float(16,2) NOT NULL DEFAULT 0.00 COMMENT '支付标准价格',
+  `EXCHANGE_RATE` float(10,4) NOT NULL DEFAULT 0.0000 COMMENT '汇率',
+  `TAX_RATE` float(16,2) NOT NULL DEFAULT 0.00 COMMENT '税率',
+  `SKU_CODE` varchar(16) COLLATE utf8mb4_bin NOT NULL,
+  `BUY_NUMS` int(10) NOT NULL DEFAULT 0,
+  `P_CALC_MONTH` date NOT NULL,
+  `POINT` smallint(5) unsigned NOT NULL DEFAULT 0,
+  `CATEGORY_TYPE` tinyint(1) unsigned NOT NULL DEFAULT 1 COMMENT '商品分类:1普通商品',
+  `PAY_TYPE` varchar(30) COLLATE utf8mb4_bin NOT NULL DEFAULT 'cash' COMMENT '支付方式:7-pay_stack',
+  `EMAIL` varchar(32) COLLATE utf8mb4_bin DEFAULT '' COMMENT '邮箱',
+  PRIMARY KEY (`ID`) USING BTREE,
+  KEY `GOODS_ID` (`GOODS_ID`) USING BTREE,
+  KEY `ORDER_SN` (`ORDER_SN`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC COMMENT='BA会员订单中包含的商品';
+
+
+CREATE TABLE `AR_BA_APPROACH_ORDER` (
+  `ID` varchar(32) COLLATE utf8mb4_bin NOT NULL,
+  `SN` varchar(32) COLLATE utf8mb4_bin NOT NULL DEFAULT '',
+  `DEC_SN` varchar(32) COLLATE utf8mb4_bin DEFAULT '',
+  `USER_ID` varchar(32) COLLATE utf8mb4_bin NOT NULL,
+  `USER_NAME` varchar(16) COLLATE utf8mb4_bin NOT NULL,
+  `ORDER_TYPE` varchar(12) COLLATE utf8mb4_bin NOT NULL,
+  `ORDER_AMOUNT` decimal(16,2) NOT NULL DEFAULT 0.00,
+  `PV` decimal(16,2) NOT NULL DEFAULT 0.00,
+  `PAY_AMOUNT` decimal(16,2) NOT NULL DEFAULT 0.00,
+  `PAY_PV` decimal(16,2) NOT NULL DEFAULT 0.00,
+  `ORDER_AMOUNT_STANDARD` float(16,2) NOT NULL DEFAULT 0.00 COMMENT '订单价格-标准价格',
+  `PAY_AMOUNT_STANDARD` float(16,2) NOT NULL DEFAULT 0.00 COMMENT '标准价格',
+  `EXCHANGE_RATE` float(10,4) NOT NULL DEFAULT 0.0000 COMMENT '汇率',
+  `PAY_AT` int(10) NOT NULL DEFAULT 0,
+  `FREIGHT` float(10,2) NOT NULL DEFAULT 0.00,
+  `PAY_FREIGHT` float(10,2) NOT NULL DEFAULT 0.00,
+  `DELIVERY_STATUS` tinyint(2) NOT NULL DEFAULT 0,
+  `DELIVERY_PERIOD` int(10) NOT NULL DEFAULT 0,
+  `DELIVERY_AT` int(10) NOT NULL DEFAULT 0,
+  `EXPRESS_COMPANY` varchar(128) COLLATE utf8mb4_bin DEFAULT '',
+  `ORDER_TRACK_NO` varchar(32) COLLATE utf8mb4_bin DEFAULT '',
+  `EXPRESS_TYPE` tinyint(1) NOT NULL DEFAULT 0,
+  `FRONT_REMARK` varchar(1000) COLLATE utf8mb4_bin DEFAULT '',
+  `REMARK` text COLLATE utf8mb4_bin DEFAULT NULL,
+  `NOTE` text COLLATE utf8mb4_bin DEFAULT NULL COMMENT '备注内容',
+  `PERIOD_NUM` int(10) NOT NULL DEFAULT 0,
+  `STATUS` int(3) NOT NULL DEFAULT 0,
+  `CONSIGNEE` varchar(120) COLLATE utf8mb4_bin DEFAULT '',
+  `MOBILE` varchar(11) COLLATE utf8mb4_bin DEFAULT '',
+  `TEL` varchar(16) COLLATE utf8mb4_bin DEFAULT '',
+  `PROVINCE` int(6) NOT NULL DEFAULT 0,
+  `CITY` int(6) DEFAULT 0,
+  `COUNTY` int(9) DEFAULT 0,
+  `LGA_NAME` varchar(50) COLLATE utf8mb4_bin DEFAULT NULL,
+  `CITY_NAME` varchar(50) COLLATE utf8mb4_bin DEFAULT NULL,
+  `ADDRESS` varchar(255) COLLATE utf8mb4_bin NOT NULL DEFAULT '',
+  `P_CALC_MONTH` date NOT NULL,
+  `CREATED_AT` int(10) NOT NULL DEFAULT 0,
+  `CREATE_USER` varchar(16) COLLATE utf8mb4_bin NOT NULL,
+  `UPDATED_AT` int(10) NOT NULL DEFAULT 0,
+  `UPDATER` varchar(16) COLLATE utf8mb4_bin DEFAULT '',
+  `IS_DELETE` int(10) NOT NULL DEFAULT 0,
+  `DELETED_AT` int(10) NOT NULL DEFAULT 0,
+  `PAY_TYPE` varchar(32) COLLATE utf8mb4_bin NOT NULL DEFAULT 'cash',
+  `WAREHOUSE` varchar(16) COLLATE utf8mb4_bin NOT NULL DEFAULT '01',
+  `EMAIL` varchar(32) COLLATE utf8mb4_bin DEFAULT '' COMMENT '邮箱',
+  `REMAIN_PV` decimal(16,2) NOT NULL DEFAULT 0.00 COMMENT '当期未计入的剩余PV',
+  `IS_AUTO` int(11) NOT NULL DEFAULT 0 COMMENT '假订单标志',
+  PRIMARY KEY (`ID`) USING BTREE,
+  KEY `SN` (`SN`) USING BTREE,
+  KEY `USER_ID` (`USER_ID`) USING BTREE,
+  KEY `USER_NAME` (`USER_NAME`) USING BTREE,
+  KEY `PERIOD_NUM` (`PERIOD_NUM`) USING BTREE,
+  KEY `IS_DELETE` (`IS_DELETE`) USING BTREE,
+  KEY `ORDER_TYPE` (`ORDER_TYPE`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC COMMENT='BA会员商品中间订单';
+
+CREATE TABLE `AR_BA_ORDER` (
+  `ID` varchar(32) COLLATE utf8mb4_bin NOT NULL,
+  `SN` varchar(32) COLLATE utf8mb4_bin NOT NULL DEFAULT '',
+  `DEC_SN` varchar(32) COLLATE utf8mb4_bin DEFAULT '',
+  `USER_ID` varchar(32) COLLATE utf8mb4_bin NOT NULL,
+  `USER_NAME` varchar(16) COLLATE utf8mb4_bin NOT NULL,
+  `ORDER_TYPE` varchar(12) COLLATE utf8mb4_bin NOT NULL,
+  `ORDER_AMOUNT` decimal(16,2) NOT NULL DEFAULT 0.00,
+  `PV` decimal(16,2) NOT NULL DEFAULT 0.00,
+  `PAY_AMOUNT` decimal(16,2) NOT NULL DEFAULT 0.00,
+  `PAY_PV` decimal(16,2) NOT NULL DEFAULT 0.00,
+  `ORDER_AMOUNT_STANDARD` float(16,2) NOT NULL DEFAULT 0.00 COMMENT '订单价格-标准价格',
+  `PAY_AMOUNT_STANDARD` float(16,2) NOT NULL DEFAULT 0.00 COMMENT '支付金额-标准价格',
+  `EXCHANGE_RATE` float(10,4) NOT NULL DEFAULT 0.0000 COMMENT '汇率',
+  `PAY_AT` int(10) NOT NULL DEFAULT 0,
+  `FREIGHT` float(10,2) NOT NULL DEFAULT 0.00,
+  `PAY_FREIGHT` float(10,2) NOT NULL DEFAULT 0.00,
+  `DELIVERY_STATUS` tinyint(2) NOT NULL DEFAULT 0,
+  `DELIVERY_PERIOD` int(10) NOT NULL DEFAULT 0,
+  `DELIVERY_AT` int(10) NOT NULL DEFAULT 0,
+  `EXPRESS_COMPANY` varchar(128) COLLATE utf8mb4_bin DEFAULT '',
+  `ORDER_TRACK_NO` varchar(32) COLLATE utf8mb4_bin DEFAULT '',
+  `EXPRESS_TYPE` tinyint(1) NOT NULL DEFAULT 0,
+  `FRONT_REMARK` varchar(1000) COLLATE utf8mb4_bin DEFAULT '',
+  `REMARK` text COLLATE utf8mb4_bin DEFAULT NULL,
+  `NOTE` text COLLATE utf8mb4_bin DEFAULT NULL COMMENT '备注内容',
+  `PERIOD_NUM` int(10) NOT NULL DEFAULT 0,
+  `STATUS` int(3) NOT NULL DEFAULT 0,
+  `CONSIGNEE` varchar(120) COLLATE utf8mb4_bin DEFAULT '',
+  `MOBILE` varchar(11) COLLATE utf8mb4_bin DEFAULT '',
+  `TEL` varchar(16) COLLATE utf8mb4_bin DEFAULT '',
+  `PROVINCE` int(6) NOT NULL DEFAULT 0,
+  `CITY` int(6) DEFAULT NULL,
+  `COUNTY` int(6) DEFAULT NULL,
+  `CITY_NAME` varchar(50) COLLATE utf8mb4_bin DEFAULT '' COMMENT '城市名(NG)',
+  `LGA_NAME` varchar(50) COLLATE utf8mb4_bin DEFAULT '' COMMENT 'Local Gov Area(NG)',
+  `ADDRESS` varchar(255) COLLATE utf8mb4_bin NOT NULL DEFAULT '',
+  `P_CALC_MONTH` date NOT NULL,
+  `CREATED_AT` int(10) NOT NULL DEFAULT 0,
+  `CREATE_USER` varchar(16) COLLATE utf8mb4_bin NOT NULL,
+  `UPDATED_AT` int(10) NOT NULL DEFAULT 0,
+  `UPDATER` varchar(16) COLLATE utf8mb4_bin DEFAULT '',
+  `IS_DELETE` int(10) NOT NULL DEFAULT 0,
+  `DELETED_AT` int(10) NOT NULL DEFAULT 0,
+  `PAY_TYPE` varchar(32) COLLATE utf8mb4_bin NOT NULL DEFAULT 'cash',
+  `WAREHOUSE` varchar(16) COLLATE utf8mb4_bin NOT NULL DEFAULT '01',
+  `EMAIL` varchar(32) COLLATE utf8mb4_bin DEFAULT '' COMMENT '邮箱',
+  `REMAIN_PV` decimal(16,2) NOT NULL DEFAULT 0.00 COMMENT '当期未计入的剩余PV',
+  `IS_AUTO` int(11) NOT NULL DEFAULT 0 COMMENT '假订单标志',
+  PRIMARY KEY (`ID`) USING BTREE,
+  KEY `SN` (`SN`) USING BTREE,
+  KEY `USER_ID` (`USER_ID`) USING BTREE,
+  KEY `USER_NAME` (`USER_NAME`) USING BTREE,
+  KEY `PERIOD_NUM` (`PERIOD_NUM`) USING BTREE,
+  KEY `IS_DELETE` (`IS_DELETE`) USING BTREE,
+  KEY `ORDER_TYPE` (`ORDER_TYPE`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC COMMENT='BA会员商品订单';
+
+
+CREATE TABLE `AR_BA_ORDER_GOODS` (
+  `ID` varchar(32) COLLATE utf8mb4_bin NOT NULL,
+  `ORDER_SN` varchar(32) COLLATE utf8mb4_bin NOT NULL,
+  `GOODS_ID` varchar(32) COLLATE utf8mb4_bin NOT NULL,
+  `GOODS_TITLE` varchar(255) COLLATE utf8mb4_bin NOT NULL,
+  `PRICE` decimal(16,2) NOT NULL DEFAULT 0.00,
+  `REAL_PRICE` decimal(16,2) NOT NULL DEFAULT 0.00,
+  `PV` decimal(16,2) NOT NULL DEFAULT 0.00,
+  `REAL_PV` decimal(16,2) NOT NULL DEFAULT 0.00,
+  `STANDARD_PRICE` float(16,2) NOT NULL DEFAULT 0.00 COMMENT '标准价格',
+  `EXCHANGE_RATE` float(10,4) NOT NULL DEFAULT 0.0000 COMMENT '汇率',
+  `TAX_RATE` float(16,2) NOT NULL DEFAULT 0.00 COMMENT '税率',
+  `REAL_STANDARD_PRICE` float(16,2) NOT NULL DEFAULT 0.00 COMMENT '支付标准价格',
+  `SKU_CODE` varchar(16) COLLATE utf8mb4_bin NOT NULL,
+  `BUY_NUMS` int(10) NOT NULL DEFAULT 0,
+  `P_CALC_MONTH` date NOT NULL,
+  `POINT` smallint(5) unsigned NOT NULL DEFAULT 0,
+  `EMAIL` varchar(32) COLLATE utf8mb4_bin DEFAULT '' COMMENT '邮箱',
+  `CATEGORY_TYPE` tinyint(1) NOT NULL DEFAULT 1,
+  `PAY_TYPE` varchar(30) COLLATE utf8mb4_bin DEFAULT 'cash',
+  `REMAIN_PV` decimal(16,2) NOT NULL DEFAULT 0.00 COMMENT '当期未计入的剩余PV',
+  PRIMARY KEY (`ID`) USING BTREE,
+  KEY `GOODS_ID` (`GOODS_ID`) USING BTREE,
+  KEY `ORDER_SN` (`ORDER_SN`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC COMMENT='BA会员订单中包含的商品';
+
+CREATE TABLE `AR_BA_APPROACH_DEC_ORDER` (
+  `ID` varchar(32) COLLATE utf8mb4_bin NOT NULL,
+  `DEC_SN` varchar(32) COLLATE utf8mb4_bin NOT NULL DEFAULT '',
+  `ORDER_SN` varchar(32) COLLATE utf8mb4_bin NOT NULL DEFAULT '',
+  `USER_ID` varchar(32) COLLATE utf8mb4_bin NOT NULL,
+  `TO_USER_ID` varchar(32) COLLATE utf8mb4_bin NOT NULL,
+  `TYPE` varchar(32) COLLATE utf8mb4_bin NOT NULL,
+  `IS_ADMIN` tinyint(1) NOT NULL DEFAULT 0,
+  `DEC_AMOUNT` decimal(16,3) NOT NULL DEFAULT 0.000,
+  `DEC_PV` decimal(16,3) NOT NULL DEFAULT 0.000,
+  `PAID_WALLET` varchar(48) COLLATE utf8mb4_bin NOT NULL,
+  `IS_BATCH` tinyint(1) NOT NULL DEFAULT 0,
+  `REMARK` text COLLATE utf8mb4_bin DEFAULT NULL,
+  `REC_USER_ID` varchar(32) COLLATE utf8mb4_bin DEFAULT '',
+  `CON_USER_ID` varchar(32) COLLATE utf8mb4_bin DEFAULT '',
+  `PERIOD_NUM` int(10) NOT NULL,
+  `P_CALC_MONTH` date NOT NULL,
+  `CALC_MONTH` int(8) NOT NULL DEFAULT 0,
+  `CREATED_AT` int(10) NOT NULL,
+  `UPDATER` varchar(32) COLLATE utf8mb4_bin DEFAULT '',
+  `UPDATED_AT` varchar(32) COLLATE utf8mb4_bin NOT NULL DEFAULT '0',
+  `IS_DEL` tinyint(1) NOT NULL DEFAULT 0,
+  `DELETED_AT` int(10) NOT NULL DEFAULT 0,
+  `DEC_ID` varchar(32) COLLATE utf8mb4_bin DEFAULT '',
+  `DETAIL_TYPE` tinyint(1) NOT NULL DEFAULT 1 COMMENT '默认为1注册 2为升级',
+  `UPGRADE_TYPE` tinyint(1) NOT NULL DEFAULT 0 COMMENT '1 补差额升级 2全额升级',
+  `ORI_LV` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '升级前的级别',
+  `UPGRADE_LV` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '升级后的级别',
+  PRIMARY KEY (`ID`) USING BTREE,
+  UNIQUE KEY `DEC_SN` (`DEC_SN`) USING BTREE,
+  KEY `USER_ID` (`USER_ID`) USING BTREE,
+  KEY `TYPE` (`TYPE`) USING BTREE,
+  KEY `PERIOD_NUM` (`PERIOD_NUM`) USING BTREE,
+  KEY `IS_DEL` (`IS_DEL`) USING BTREE,
+  KEY `ORDER_SN` (`ORDER_SN`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC COMMENT='报单中间表';
+
+CREATE TABLE `AR_BA_RECEIVE_ADDRESS` (
+  `ID` varchar(32) COLLATE utf8mb4_bin NOT NULL,
+  `USER_ID` varchar(32) COLLATE utf8mb4_bin NOT NULL,
+  `USER_NAME` varchar(16) COLLATE utf8mb4_bin NOT NULL,
+  `CONSIGNEE` varchar(120) COLLATE utf8mb4_bin NOT NULL,
+  `MOBILE` varchar(11) COLLATE utf8mb4_bin NOT NULL,
+  `PROVINCE` int(6) NOT NULL,
+  `CITY` int(6) DEFAULT NULL,
+  `COUNTY` int(6) DEFAULT NULL,
+  `CITY_NAME` varchar(50) COLLATE utf8mb4_bin DEFAULT '' COMMENT '城市名(NG)',
+  `LGA_NAME` varchar(50) COLLATE utf8mb4_bin DEFAULT '' COMMENT 'Local Gov Area(NG)',
+  `ADDRESS` varchar(255) COLLATE utf8mb4_bin NOT NULL,
+  `IS_DEFAULT` tinyint(1) NOT NULL DEFAULT 0,
+  `CREATED_AT` int(10) NOT NULL DEFAULT 0,
+  `UPDATER` varchar(10) COLLATE utf8mb4_bin DEFAULT '',
+  `UPDATED_AT` int(10) NOT NULL DEFAULT 0,
+  PRIMARY KEY (`ID`) USING BTREE,
+  KEY `USER_ID` (`USER_ID`) USING BTREE,
+  KEY `USER_NAME` (`USER_NAME`) USING BTREE
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=DYNAMIC COMMENT='BA会员收货地址';
+
+INSERT INTO `AR_BA_RECEIVE_ADDRESS` (`ID`, `USER_ID`, `USER_NAME`, `CONSIGNEE`, `MOBILE`, `PROVINCE`, `CITY`, `COUNTY`, `CITY_NAME`, `LGA_NAME`, `ADDRESS`, `IS_DEFAULT`, `CREATED_AT`, `UPDATER`, `UPDATED_AT`) VALUES ('100000000000000000', '300000000000000000', 'D', 'DCONSIGNEE_NAME', '18888888888', 1, 1, 1, '', '', '狮驼岭', 0, 1589064762, '', 0);