theo 3 жил өмнө
parent
commit
627b7d235b

+ 38 - 1
backendApi/modules/v1/models/lists/shop/DecOrderList.php

@@ -5,6 +5,7 @@ use common\helpers\Cache;
 use common\helpers\Tool;
 use common\libs\dataList\DataListInterface;
 use common\models\DecOrder;
+use common\models\Order;
 use common\models\User;
 use common\libs\dataList\column\DateTime;
 
@@ -24,7 +25,7 @@ class DecOrderList extends \common\libs\dataList\DataList implements DataListInt
     public function dataHandle()
     {
         $this->listData = DecOrder::lists($this->condition, $this->params, [
-            'select' => 'DO.*,U.USER_NAME USER_NAME,TU.USER_NAME TO_USER_NAME,TU.REAL_NAME,TU.ID_CARD,TU.MOBILE,TU.DEC_LV,DU.USER_NAME DEC_USER_NAME,DU.REAL_NAME DEC_REAL_NAME,RU.USER_NAME REC_USER_NAME,RU.REAL_NAME REC_REAL_NAME,CU.USER_NAME CON_USER_NAME,CU.REAL_NAME CON_REAL_NAME',
+            'select' => 'DO.*,U.USER_NAME USER_NAME,TU.USER_NAME TO_USER_NAME,TU.REAL_NAME,TU.ID_CARD,TU.MOBILE,TU.DEC_LV,DU.USER_NAME DEC_USER_NAME,DU.REAL_NAME DEC_REAL_NAME,RU.USER_NAME REC_USER_NAME,RU.REAL_NAME REC_REAL_NAME,CU.USER_NAME CON_USER_NAME,CU.REAL_NAME CON_REAL_NAME,O.*',
             'orderBy' => 'DO.CREATED_AT DESC, DO.ID DESC',
             'from' => DecOrder::tableName() . ' AS DO',
             'join' => [
@@ -33,6 +34,7 @@ class DecOrderList extends \common\libs\dataList\DataList implements DataListInt
                 ['LEFT JOIN', User::tableName() . ' AS DU', 'DO.DEC_ID=DU.ID'],
                 ['LEFT JOIN', User::tableName() . ' AS RU', 'DO.REC_USER_ID=RU.ID'],
                 ['LEFT JOIN', User::tableName() . ' AS CU', 'DO.CON_USER_ID=CU.ID'],
+                ['LEFT JOIN', Order::tableName() . ' AS O', 'DO.ORDER_SN=O.SN']
             ],
             'page' => $this->page,
             'pageSize' => $this->pageSize,
@@ -45,6 +47,7 @@ class DecOrderList extends \common\libs\dataList\DataList implements DataListInt
      */
     public function getColumn(){
         $decLevelConfig = Cache::getDecLevelConfig();
+        $regionConfig = Cache::getRegionConfig();
         if(!$this->columns){
             $this->columns = [
                 'ID' => null,
@@ -161,6 +164,40 @@ class DecOrderList extends \common\libs\dataList\DataList implements DataListInt
                     'header' => '报单时上级姓名',
                     'headerOther' => ['width' => '150'],
                 ],
+                'PROVINCE' => [
+                    'header' => '省',
+                    'headerOther' => ['width' => '120'],
+                    'value' => function ($row) use($regionConfig) {
+                        return $regionConfig[$row['PROVINCE']]['REGION_NAME'] ?? '';
+                    },
+                ],
+                'CITY' => [
+                    'header' => '市',
+                    'headerOther' => ['width' => '120'],
+                    'value' => function ($row) use($regionConfig) {
+                        return $regionConfig[$row['CITY']]['REGION_NAME'] ?? '';
+                    },
+                ],
+                'COUNTY' => [
+                    'header' => '区',
+                    'headerOther' => ['width' => '120'],
+                    'value' => function ($row) use($regionConfig) {
+                        return $regionConfig[$row['COUNTY']]['REGION_NAME'] ?? '';
+                    },
+                ],
+                'ADDRESS' => [
+                    'header' => '详细地址',
+                    'headerOther' => [
+                        'width' => '300',
+                    ],
+                ],
+                'EXPRESS_TYPE' => [
+                    'header' => '发货方式',
+                    'headerOther' => ['width' => '150'],
+                    'value' => function ($row) {
+                        return $row['EXPRESS_TYPE']==0 ? '邮寄' : '自提';
+                    },
+                ],
                 'PERIOD_NUM' => [
                     'header' => '期数',
                 ],

+ 31 - 20
common/models/forms/DeclarationForm.php

@@ -783,9 +783,13 @@ class DeclarationForm extends Model
         }
 
         // 加入订单信息
-        $warehouse = Region::getWarehouseByCode($this->province);//仓库
-        if(!$warehouse){
-            throw new Exception('地区暂时不支持配送,具体联系客服');
+        if($this->province!=1){
+            $warehouse = Region::getWarehouseByCode($this->province);//仓库
+            if(!$warehouse){
+                throw new Exception('地区暂时不支持配送,具体联系客服');
+            }
+        }else{
+            $warehouse = '01';
         }
         $orderModel = new Order();
         $orderModel->SN = 'OS'.$ord;
@@ -813,6 +817,9 @@ class DeclarationForm extends Model
         $orderModel->STATUS = 1;
         $orderModel->CREATED_AT = Date::nowTime();
         $orderModel->CREATE_USER = Info::getUserNameByUserId(\Yii::$app->user->id);
+        if($this->province==1){
+            $orderModel->EXPRESS_TYPE = 1;
+        }
         if(!$orderModel->save()){
             throw new Exception(Form::formatErrorsForApi($orderModel->getErrors()));
         }
@@ -823,24 +830,28 @@ class DeclarationForm extends Model
         }
         OrderGoods::batchInsert($this->_orderGoods);
 
-        //写入收货地址信息
-        $addressModel = new ReceiveAddress();
-        $addressModel->USER_ID = $this->_insertUserId;
-        $addressModel->USER_NAME = $this->insertUserName;
-        $addressModel->CONSIGNEE = $this->consignee;
-        $addressModel->MOBILE = $this->acceptMobile;
-        $addressModel->PROVINCE = $this->province;
-        $addressModel->CITY = $this->city;
-        $addressModel->COUNTY = intval($this->county) ?? 0;
-        $addressModel->ADDRESS = $this->address;
-        $addressModel->IS_DEFAULT = 1;
-        if(!$addressModel->save()){
-            throw new Exception(Form::formatErrorsForApi($addressModel->getErrors()));
+        //写入收货地址信息,判断province字段,当不为1时,插入收货地址信息
+        if($this->province!=1){
+            $addressModel = new ReceiveAddress();
+            $addressModel->USER_ID = $this->_insertUserId;
+            $addressModel->USER_NAME = $this->insertUserName;
+            $addressModel->CONSIGNEE = $this->consignee;
+            $addressModel->MOBILE = $this->acceptMobile;
+            $addressModel->PROVINCE = $this->province;
+            $addressModel->CITY = $this->city;
+            $addressModel->COUNTY = intval($this->county) ?? 0;
+            $addressModel->ADDRESS = $this->address;
+            $addressModel->IS_DEFAULT = 1;
+            if(!$addressModel->save()){
+                throw new Exception(Form::formatErrorsForApi($addressModel->getErrors()));
+            }
+            //扣报单人现金钱包
+            Cash::changeUserCash(\Yii::$app->user->id, 'CASH', -abs($this->_decAmount), ['REMARK' =>'为'.$this->insertUserName.'报单']);
+            return $addressModel;
+        }else{
+            $addressModel = new ReceiveAddress();
+            return $addressModel;
         }
-        //扣报单人现金钱包
-        Cash::changeUserCash(\Yii::$app->user->id, 'CASH', -abs($this->_decAmount), ['REMARK' =>'为'.$this->insertUserName.'报单']);
-
-        return $addressModel;
     }
 
 

+ 31 - 8
common/models/forms/OrderForm.php

@@ -360,6 +360,9 @@ class OrderForm extends Model
         $this->_decAmount = $totalAmount;
         $this->_decPv = $totalPv;
         $this->_freight = ($totalAmount>=300) ? 0 : 15;
+        if($this->_address['PROVINCE']==1){
+            $this->_freight = 0;
+        }
         $this->_payAmount = $this->_decAmount + $this->_freight;
 
         $db = \Yii::$app->db;
@@ -429,13 +432,17 @@ class OrderForm extends Model
         $userId = \Yii::$app->user->id;
 
         $userName = Info::getUserNameByUserId($userId);
-
+        $userRealName = Info::getUserRealNameByUserId($userId);
+        $userMobile = Info::getUserMobileByUserId($userId);
         // 加入订单信息
-        $warehouse = Region::getWarehouseByCode($this->_address['PROVINCE']);//仓库
-        if(!$warehouse){
-            throw new Exception('地区暂时不支持配送,具体联系客服');
+        if ($this->_address['PROVINCE'] != 1) {
+            $warehouse = Region::getWarehouseByCode($this->_address['PROVINCE']);//仓库
+            if (!$warehouse) {
+                throw new Exception('地区2暂时不支持配送,具体联系客服');
+            }
+        }else{
+            $warehouse = '01';
         }
-
         $_hasPV = in_array($this->payType, ['exchange', 'travel_points', 'car_points', 'house_points']) ? 0 : $this->_decPv;
 
         $ordNo = $this->_generateSn();
@@ -466,6 +473,15 @@ class OrderForm extends Model
         $orderModel->STATUS = 1;
         $orderModel->CREATED_AT = Date::nowTime();
         $orderModel->CREATE_USER = $userName;
+        if($this->_address['PROVINCE']==1){
+            $orderModel->EXPRESS_TYPE = 1;
+            $orderModel->CONSIGNEE = $userRealName;
+            $orderModel->MOBILE = $userMobile;
+            $orderModel->PROVINCE = 1;
+            $orderModel->CITY = 1;
+            $orderModel->COUNTY = 1;
+            $orderModel->ADDRESS = '';
+        }
         if(!$orderModel->save()){
             $this->addErrors($orderModel->getErrors());
             return false;
@@ -544,6 +560,9 @@ class OrderForm extends Model
         $this->_decAmount = $totalAmount;
         $this->_decPv = $totalPv;
         $this->_freight = ($totalAmount>=300) ? 0 : 15;
+        if($this->_address['PROVINCE']==1){
+            $this->_freight = 0;
+        }
         $this->_payAmount = $this->_decAmount + $this->_freight;
 
         $db = \Yii::$app->db;
@@ -597,9 +616,13 @@ class OrderForm extends Model
         $userId = Info::getUserIdByUserName($this->userName);
 
         // 加入订单信息
-        $warehouse = Region::getWarehouseByCode($this->province);//仓库
-        if(!$warehouse){
-            throw new Exception('地区暂时不支持配送,具体联系客服');
+        if($this->province!=1){
+            $warehouse = Region::getWarehouseByCode($this->province);//仓库
+            if(!$warehouse){
+                throw new Exception('地区1暂时不支持配送,具体联系客服');
+            }
+        }else{
+            $warehouse = '01';
         }
         $ordNo = $this->_generateSn();
         $orderModel = new Order();

+ 14 - 5
frontendApi/modules/v1/controllers/ShopController.php

@@ -158,7 +158,7 @@ class ShopController extends BaseController {
      * @throws \yii\web\HttpException
      */
     public function actionDecOrderList() {
-        $condition = ' AND DO.USER_ID=:USER_ID AND IS_DEL=0';
+        $condition = ' AND USER_ID=:USER_ID AND IS_DEL=0';
         $params[':USER_ID'] = \Yii::$app->user->id;
         $data = DecOrder::lists($condition, $params, [
             'select' => 'DO.*,U.USER_NAME USER_NAME,U.REAL_NAME REAL_NAME,RU.USER_NAME REC_USER_NAME,RU.REAL_NAME REC_REAL_NAME,CU.USER_NAME CON_USER_NAME,CU.REAL_NAME CON_REAL_NAME,OG.*',
@@ -184,21 +184,30 @@ class ShopController extends BaseController {
         $condition = " AND ORDER_TYPE='FX' AND (USER_ID=:USER_ID OR CREATE_USER='$uname')";
         $params[':USER_ID'] = \Yii::$app->user->id;
         $data = Order::lists($condition, $params, [
-            'select' => 'O.*,U.REAL_NAME,OG.*,OG.CATEGORY_TYPE',
+            'select' => 'O.*,U.REAL_NAME,OG.*,SG.CATEGORY_TYPE',
             'orderBy' => 'O.CREATED_AT DESC',
             'from' => Order::tableName() . ' AS O',
             'join' => [
                 ['LEFT JOIN', User::tableName() . ' AS U', 'U.ID=O.USER_ID'],
                 ['LEFT JOIN', OrderGoods::tableName() . ' AS OG', 'OG.ORDER_SN=O.SN'],
+                ['LEFT JOIN', ShopGoods::tableName() . ' AS SG', 'SG.ID=OG.GOODS_ID'],
             ],
         ]);
         foreach ($data['list'] as $key => $value) {
-            //$data['list'][$key]['PROVINCE_NAME'] = $value['PROVINCE'] ? Region::getCnName($value['PROVINCE']) : '';
-           //$data['list'][$key]['CITY_NAME'] = $value['CITY'] ? Region::getCnName($value['CITY']) : '';
-            //$data['list'][$key]['COUNTY_NAME'] = $value['COUNTY'] ? Region::getCnName($value['COUNTY']) : '';
             $data['list'][$key]['PAY_AT'] = Date::convert($value['PAY_AT'],'Y-m-d H:i:s');
             $data['list'][$key]['CATEGORY_TYPE'] = intval($value['CATEGORY_TYPE']);
             $data['list'][$key]['CATEGORY'] = array_column(ShopGoods::CATEGORY_TYPE, NULL, 'id')[$value['CATEGORY_TYPE']]['name'] ?? '普通商品';
+            $data['list'][$key]['FULL_ADDRESS'] = '';
+            if($value['PROVINCE']){
+                $data['list'][$key]['FULL_ADDRESS'] .= Region::getCnName($value['PROVINCE']);
+            }
+            if($value['CITY']){
+                $data['list'][$key]['FULL_ADDRESS'] .= Region::getCnName($value['CITY']);
+            }
+            if($value['COUNTY']){
+                $data['list'][$key]['FULL_ADDRESS'] .= Region::getCnName($value['COUNTY']);
+            }
+            $data['list'][$key]['FULL_ADDRESS'] .= $value['ADDRESS'];
         }
         return static::notice($data);
     }

+ 4 - 0
frontendApi/modules/v1/controllers/UserController.php

@@ -212,6 +212,10 @@ class UserController extends BaseController {
             $formModel->scenario = 'userDec';
             $post = \Yii::$app->request->post();
 
+            $post['province'] = $post['province'] ? :1;
+            $post['city'] = $post['city'] ? :1;
+            $post['county'] = $post['county'] ? :1;
+
             // 针对于会员编号的判断
             $insertUserName = strtoupper($post['insertUserName']);
             $getRedisUserName = $redis->get('key_'.$insertUserName);

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

@@ -11,6 +11,7 @@
                 <el-table-column label="订单编号" prop="ORDER_SN"></el-table-column>
                 <el-table-column label="会员编号" prop="USER_NAME"></el-table-column>
                 <el-table-column label="会员姓名" prop="REAL_NAME"></el-table-column>
+                <el-table-column label="收货地址" prop="ADDRESS"></el-table-column>
                 <el-table-column label="接点人编号" prop="CON_USER_NAME"></el-table-column>
                 <el-table-column label="创建时间">
                     <template slot-scope="scope">

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

@@ -22,6 +22,7 @@
                 <el-table-column label="会员姓名" prop="REAL_NAME"></el-table-column>
                 <el-table-column label="收货人" prop="CONSIGNEE"></el-table-column>
                 <el-table-column label="收货电话" prop="MOBILE"></el-table-column>
+                <el-table-column label="地址" prop="FULL_ADDRESS"></el-table-column>
                 <el-table-column label="支付时间" prop="PAY_AT"></el-table-column>
                 <el-table-column label="操作">
                   <template slot-scope="scope">

+ 13 - 2
frontendEle/src/views/shop/order.vue

@@ -55,6 +55,9 @@
                             手机号码:{{item.MOBILE}}
                         </el-radio>
                     </div>
+                    <div class="address">
+                      <el-radio label="100000000000000000">自提</el-radio>
+                    </div>
                 </el-radio-group>
             </div>
             <div class="address_box">
@@ -185,6 +188,11 @@
             }
         },
         methods:{
+            setFreight(){
+              if(this.addressId=='100000000000000000'){//如果地址为自提,则运费为0
+                this.pointFreight = this.freight = 0;
+              }
+            },
             getSummaries(param) {
               const { columns, data } = param;
               const sums = [];
@@ -303,6 +311,7 @@
                     }else{
                         this.pointFreight = this.freight = 15;
                     }
+                    this.setFreight();
                 }
                 // if(payPointAmount>=300){
                 //     this.pointFreight = 0;
@@ -312,6 +321,7 @@
                 //console.log('points_plus_sum',points_plus_sum);
                 //console.log('cash_plus_sum',cash_plus_sum);
                 // this.pointsSum=tool.formatPrice(tool.sum(points_plus_sum) + this.pointFreight);
+              console.log(this.freight)
               this.pointsSum = this.cashSum = tool.formatPrice(tool.sum(cash_plus_sum) + this.freight) ;
             },
             getShowCart(){
@@ -322,7 +332,7 @@
                     this.all_address = response.allAddress;
                     this.all_address.map((item,index)=>{
                         if(item.IS_DEFAULT==1){
-                            this.addressId=item.ID
+                            this.addressId = item.ID
                         }
                     })
                     // 账户
@@ -337,7 +347,7 @@
                     }
 
                     // 支付方式的第一项默认选中
-                    this.payType = this.payList[0].label
+                    this.payType = this.payList[0]
                 })
             },
             // 切换支付方式
@@ -345,6 +355,7 @@
                 this.payType = type
             },
             choseAddress(addressId){
+              this.getSumMoney()
                 // console.log(addressId);
             }
         }

+ 24 - 4
frontendEle/src/views/user/dec.vue

@@ -185,11 +185,21 @@
                     </template>
                     <el-input v-model="form.acceptMobile"></el-input>
                 </el-form-item>
+                <el-form-item>
+                    <template slot="label">
+                      收货方式
+                    </template>
+                    <el-radio-group v-model="form.way" @change="wayChange">
+                      <el-radio label="express">快递</el-radio>
+                      <el-radio label="pickup">自提</el-radio>
+                    </el-radio-group>
+                </el-form-item>
                 <el-form-item prop="areaSelected">
                     <template slot="label">
                         地区
                     </template>
                     <el-cascader
+                            :disabled="areaDisabled"
                             size="large"
                             :options="regionData"
                             v-model="form.areaSelected">
@@ -199,7 +209,7 @@
                     <template slot="label">
                         详细地址
                     </template>
-                    <el-input v-model="form.address"></el-input>
+                    <el-input :disabled="addressDisabled" v-model="form.address"></el-input>
                 </el-form-item>
 
                 <div class="hr-tip"><span>银行信息</span></div>
@@ -292,8 +302,7 @@
                     province:'',
                     city:'',
                     county:'',
-
-
+                    way:"express"
                 },
                 conRealName: '-',
                 recRealName: '-',
@@ -311,10 +320,21 @@
                 goodsNums:[],
                 numList: [],
                 sell_price_sum:0.00,
-                price_pv_sum:0.00
+                price_pv_sum:0.00,
+                areaDisabled: false,
+                addressDisabled: false
             }
         },
         methods: {
+            wayChange(){
+              if(this.form.way==='pickup'){
+                this.areaDisabled = true
+                this.addressDisabled = true
+              }else{
+                this.areaDisabled = false
+                this.addressDisabled = false
+              }
+            },
             getSum(){
                 let sell_price_sum=0,price_pv_sum=0;
                 this.multipleSelection.map((item,index)=>{