Bladeren bron

导出到壹号专线

zhangdehua 1 jaar geleden
bovenliggende
commit
e5fbb4c48c

+ 2 - 1
app/common/model/OrderAddress.php

@@ -50,7 +50,8 @@ class OrderAddress extends BaseModel
         return [
             'province' => RegionModel::getNameById($data['province_id']),
             'city' => RegionModel::getNameById($data['city_id']),
-            'region' => RegionModel::getNameById($data['region_id'])
+            'region' => RegionModel::getNameById($data['region_id']),
+            'code' => RegionModel::getCodeById($data['region_id'])
         ];
     }
 

+ 10 - 1
app/common/model/Region.php

@@ -62,6 +62,15 @@ class Region extends BaseModel
         return isset($data[$id]) ? $data[$id]['name'] : '其他';
     }
 
+    public static function getCodeById(int $id = 0)
+    {
+        if ($id == 0) {
+            return '';
+        }
+        $data = self::getCacheAll();
+        return isset($data[$id]) ? trim($data[$id]['code']) : '';
+    }
+
     /**
      * 获取所有地区(树状结构)
      * @return array|mixed
@@ -213,7 +222,7 @@ class Region extends BaseModel
     private function getAllList()
     {
         $list = self::withoutGlobalScope()
-            ->field('id, pid, name, level')
+            ->field('id, pid, name, code,level')
             ->select()
             ->toArray();
         return helper::arrayColumn2Key($list, 'id');

+ 3 - 1
app/index/controller/Cart.php

@@ -67,6 +67,7 @@ class Cart extends Controller
         $res['phone'] = '';
         $res['email'] = '';
         $res['regionId'] = 0;
+        $res['city'] = '';
         $res['detail'] = '';
 
         $regList = RegionModel::getCacheAll();
@@ -77,7 +78,7 @@ class Cart extends Controller
             $addr = UserAddress::detail($user['address_id']);
             if ($addr) {
                 $res['addressId'] = $addr['address_id'];
-                $res['full'] = $addr['detail'] . ',' . $addr['region']['region'] . '(' . $addr['zip_code'] . '),US';
+                $res['full'] = $addr['detail'] . ',' . $addr['city'] . ',' . $addr['region']['region'] . '(' . $addr['zip_code'] . '),US';
                 $res['zipCode'] = $addr['zip_code'];
                 $res['name'] = $addr['name'];
                 $res['lastName'] = $addr['last_name'];
@@ -85,6 +86,7 @@ class Cart extends Controller
                 $res['phone'] = $addr['phone'];
                 $res['email'] = $addr['email'];
                 $res['regionId'] = $addr['region_id'];
+                $res['city'] = $addr['city'];
                 $res['detail'] = $addr['detail'];
             }
         }

+ 3 - 1
app/index/model/UserAddress.php

@@ -83,6 +83,7 @@ class UserAddress extends UserAddressModel
                 'province_id' => $data['province_id'],
                 'city_id' => $data['city_id'],
                 'region_id' => $data['region_id'],
+                'city' => $data['city'],
                 'detail' => $data['detail'],
                 'user_id' => $user['user_id'],
                 'zip_code' => $data['zip_code'],
@@ -96,7 +97,7 @@ class UserAddress extends UserAddressModel
             $reg = Region::get($data['region_id']);
             return [
                 'address_id' => $this['address_id'],
-                'full' => $data['detail'] . ',' . $reg['name'] . '(' . $data['zip_code'] . '),US',
+                'full' => $data['detail'] . ',' . $data['city'] . ',' . $reg['name'] . '(' . $data['zip_code'] . '),US',
                 'zip_code' => $data['zip_code'],
                 'name' => $data['name'],
                 'last_name' => $data['last_name'],
@@ -142,6 +143,7 @@ class UserAddress extends UserAddressModel
                 'province_id' => $data['province_id'],
                 'city_id' => $data['city_id'],
                 'region_id' => $data['region_id'],
+                'city' => $data['city'],
                 'detail' => $data['detail']
             ]) !== false;
     }

+ 1 - 0
app/index/service/order/Checkout.php

@@ -863,6 +863,7 @@ class Checkout extends BaseService
             'province_id' => $address['province_id'],
             'city_id' => $address['city_id'],
             'region_id' => $address['region_id'],
+            'city' => $address['city'],
             'detail' => $address['detail'],
         ]);
     }

+ 28 - 7
app/index/view/cart/shoppingCart.html

@@ -116,6 +116,11 @@
                         {/foreach}
                     </select>
                 </div>
+                <!-- 城市 -->
+                <div class="addressItem">
+                    <p class="addItmeTitle">City:</p>
+                    <input class="addInput" id="city" type="text" placeholder="City">
+                </div>
                 <!-- 详情地址 -->
                 <div class="addressItem">
                     <p class="addItmeTitle">Address:</p>
@@ -211,6 +216,7 @@
             lastName: "{$lastName}",
             phoneNumber: "{$phone}",
             areaSelect: "{$regionId}",
+            city: "{$city}",
             address: "{$detail}",
             mailbox: "{$email}",
             postalCode: "{$zipCode}"
@@ -237,11 +243,21 @@
 
         //初始化表单
         function initAddressForm() {
-            const {userName, lastName, phoneNumber, areaSelect, address, mailbox, postalCode} = defaultAddressInfo || {}
+            const {
+                userName,
+                lastName,
+                phoneNumber,
+                areaSelect,
+                city,
+                address,
+                mailbox,
+                postalCode
+            } = defaultAddressInfo || {}
             userName && $("#userName").val(userName)
             lastName && $("#lastName").val(lastName)
             phoneNumber && $("#phoneNumber").val(phoneNumber)
             areaSelect && $("#areaSelect").val(areaSelect)
+            city && $("#city").val(city)
             address && $("#address").val(address)
             mailbox && $("#mailbox").val(mailbox)
             postalCode && $("#postalCode").val(postalCode)
@@ -294,6 +310,7 @@
             const lastNameEle = $("#lastName")
             const phoneNumberEle = $("#phoneNumber")
             const areaSelectEle = $("#areaSelect")
+            const cityEle = $("#city")
             const addressEle = $("#address")
             const mailboxEle = $("#mailbox")
             const postalCodeEle = $("#postalCode")
@@ -306,6 +323,8 @@
             // 地区
             const areaSelect = areaSelectEle.val()
             // 详情地址
+            const city = cityEle.val()
+            // 详情地址
             const address = addressEle.val()
             // 邮箱
             const mailbox = mailboxEle.val()
@@ -324,6 +343,10 @@
                 areaSelectEle.focus()
                 return
             }
+            if (!city || city === "") {
+                cityEle.focus()
+                return
+            }
             if (!address || address === "") {
                 addressEle.focus()
                 return
@@ -335,7 +358,7 @@
                     phone: phoneNumber,
                     email: mailbox,
                     region: [{label: '', value: 1}, {label: '', value: 2}, {label: areaSelect, value: areaSelect}],
-                    //mailbox,
+                    city: city,
                     detail: address,
                     zip_code: postalCode
                 }
@@ -619,7 +642,7 @@
         });
 
         //当前选中的地址id
-        let currentAddressId = 1
+        let currentAddressId = 0
         //删除地址记录id
         let deleteAddressId
 
@@ -634,10 +657,8 @@
 
         //收起地址
         $("#selSave").on(tap, function () {
-            console.log(currentAddressId)
-
             addressId = currentAddressId.address_id
-            $("#addressText").text(currentAddressId.detail + "," + currentAddressId.region.region + "(" + currentAddressId.zip_code + ")" + ",US")
+            $("#addressText").text(currentAddressId.detail + "," + currentAddressId.city + "," + currentAddressId.region.region + "(" + currentAddressId.zip_code + ")" + ",US")
             $("#fullNameText").text(currentAddressId.name + " " + currentAddressId.last_name)
             $("#contactNumberText").text(currentAddressId.phone)
             $("#emailText").text(currentAddressId.email)
@@ -666,7 +687,7 @@
                         <img class="sel" src="/assets/index/asstes/icon/sel.png" alt="">
                         </div>
                         <p class="itAddInfo">
-                        ${item.name} ${item.last_name},To:${item.detail}, ${item.region.region} (US)
+                        ${item.name} ${item.last_name},To:${item.detail}, ${item.city},${item.region.region} (US)
                         </p>
                         <div class="addressDelete">
                         <p>Delete</p>

+ 56 - 7
app/store/service/order/Export.php

@@ -72,8 +72,37 @@ class Export extends BaseService
     {
         // 根据条件查询订单列表
         $orderList = $this->getDeliveryOrderList($param);
+        $orderListArr = $orderList->toArray();
+        $orderForExcelArr = [];
+        foreach ($orderListArr as $item) {
+            $orderForExcelArr[] = [
+                '包裹',
+                'YH1049',
+                $item['order_no'],
+                '收货渠道',
+                '美国',
+                '1',
+                '500g',
+                $item['address']['region']['code'],
+                $item['address']['city'],
+                $item['address']['zip_code'],
+                '壹号专线',
+                $item['address']['name'] . ' ' . $item['address']['last_name'],
+                $item['address']['phone'],
+                $item['address']['detail'],
+                '包裹',
+                '其他',
+                '电子眼',
+                'ele eye',
+                'SEACODE',
+                '1',
+                'dollar',
+                $item['total_price'],
+                $item['total_price'],
+            ];
+        }
         // 格式化生成表格数据
-        $columns = [
+/*        $columns = [
             'order_id',
             'order_no',
             'goods_detail',
@@ -97,12 +126,12 @@ class Export extends BaseService
             'receipt_time',
             'order_status',
             'order_source'
-        ];;
-        $excelList = $this->getExcelList($orderList->toArray(), $columns);
+        ];*/
+        //$excelList = $this->getExcelList($orderList->toArray(), $columns);
         // 获取导出的记录列名集
         //$columns = $this->getColumns($param['columns']);
         // 输出并写入到excel文件
-        $filePath = $this->outputDeliveryExcel($excelList);
+        $filePath = $this->outputDeliveryExcel($orderForExcelArr);
         // 新增订单导出记录
         $this->record($param, $filePath);
         return true;
@@ -209,9 +238,29 @@ class Export extends BaseService
         // 写入内容数据
         foreach ($excelList as $key => $item) {
             $row = $key + 2;
-            foreach (array_values($item) as $k => $val) {
-                $sheet->setCellValueByColumnAndRow($k + 1, $row, $val);
-            }
+            $sheet->setCellValueByColumnAndRow(1, $row, $item[0]);
+            $sheet->setCellValueByColumnAndRow(2, $row, $item[1]);
+            $sheet->setCellValueByColumnAndRow(3, $row, $item[2]);
+            $sheet->setCellValueByColumnAndRow(4, $row, $item[3]);
+            $sheet->setCellValueByColumnAndRow(5, $row, $item[4]);
+            $sheet->setCellValueByColumnAndRow(6, $row, $item[5]);
+            $sheet->setCellValueByColumnAndRow(7, $row, $item[6]);
+            $sheet->setCellValueByColumnAndRow(14, $row, $item[7]);
+            $sheet->setCellValueByColumnAndRow(15, $row, $item[8]);
+            $sheet->setCellValueByColumnAndRow(16, $row, $item[9]);
+            $sheet->setCellValueByColumnAndRow(17, $row, $item[10]);
+            $sheet->setCellValueByColumnAndRow(18, $row, $item[11]);
+            $sheet->setCellValueByColumnAndRow(19, $row, $item[12]);
+            $sheet->setCellValueByColumnAndRow(20, $row, $item[13]);
+            $sheet->setCellValueByColumnAndRow(23, $row, $item[14]);
+            $sheet->setCellValueByColumnAndRow(24, $row, $item[15]);
+            $sheet->setCellValueByColumnAndRow(32, $row, $item[16]);
+            $sheet->setCellValueByColumnAndRow(33, $row, $item[17]);
+            $sheet->setCellValueByColumnAndRow(34, $row, $item[18]);
+            $sheet->setCellValueByColumnAndRow(36, $row, $item[19]);
+            $sheet->setCellValueByColumnAndRow(37, $row, $item[20]);
+            $sheet->setCellValueByColumnAndRow(38, $row, $item[21]);
+            $sheet->setCellValueByColumnAndRow(39, $row, $item[22]);
         }
         // 生成文件路径
         $fileName = 'order-' . time() . '.xlsx';

+ 2 - 0
public/install/data/install_struct.sql

@@ -373,6 +373,7 @@ CREATE TABLE `yoshop_order_address` (
   `province_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '省份ID',
   `city_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '城市ID',
   `region_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '区/县ID',
+  `city` varchar(255) NOT NULL DEFAULT '' COMMENT '城市',
   `detail` varchar(255) NOT NULL DEFAULT '' COMMENT '详细地址',
   `order_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '订单ID',
   `user_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户ID',
@@ -796,6 +797,7 @@ CREATE TABLE `yoshop_user_address` (
   `province_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '省份ID',
   `city_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '城市ID',
   `region_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '区/县ID',
+  `city` varchar(255) NOT NULL DEFAULT '' COMMENT '城市',
   `detail` varchar(255) NOT NULL DEFAULT '' COMMENT '详细地址',
   `user_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '用户ID',
   `is_delete` tinyint(3) unsigned NOT NULL DEFAULT '0' COMMENT '是否删除',