瀏覽代碼

税额税率 翻译 导出PDF

kevin_zhangl 3 年之前
父節點
當前提交
81e03863fc

+ 28 - 18
common/libs/export/BaseExport.php

@@ -458,6 +458,8 @@ class BaseExport extends Component {
             $orderSn = '';
             $orderAmount = 0;  // 合计总额
             $orderNums = 0; // 合计总数
+            $totalTaxAmount = 0; // 合计税额
+            $totalAmount = 0;
             foreach ($oderList as $key => $value) {
                 $provinceName = $value['PROVINCE'] ? Region::getCnName($value['PROVINCE']) : '';
                 $cityName = $value['CITY'] ? Region::getCnName($value['CITY']) : '';
@@ -473,14 +475,19 @@ class BaseExport extends Component {
                 $totalAmount = $value['BUY_NUMS'] * $value['REAL_PRICE'];
                 $orderAmount += $totalAmount;
                 $orderNums += $value['BUY_NUMS'];
+                // 税额
+                $taxAmount = floatval(Tool::formatPrice(($value['REAL_PRICE'] - ($value['REAL_PRICE'] / (1 + $value['TAX_RATE'] / 100))) * $value['BUY_NUMS']));
+                $totalTaxAmount += $taxAmount;
                 // 订单详情
                 $orderDetails .= <<<EOT
                     <tr>
                         <td>{$value['SKU_CODE']}</td>
                         <td>{$value['GOODS_TITLE']}</td>
-                        <td>{$value['BUY_NUMS']}</td>
                         <td>{$value['REAL_PRICE']}</td>
-                        <td>{$totalAmount}</td> 
+                        <td>{$value['BUY_NUMS']}</td>
+                        <td>{$value['TAX_RATE']}</td>
+                        <td>{$taxAmount}</td>
+                        <td>{$totalAmount}</td>
                     </tr>
 EOT;
             }
@@ -489,31 +496,31 @@ EOT;
             $orderBase = <<<ORDER
                 <table border="1" style="table-layout: fixed; padding: 10px 20px;" width="100%">
                     <tr>
-                        <td width="30%" style="font-weight: bold; text-align: center; font-size: 14px;">会员编号</td>
+                        <td width="30%" style="font-weight: bold; text-align: center; font-size: 14px;">Member code</td>
                         <td width="70%">{$userId}</td>
                     </tr>
                     <tr>
-                        <td width="30%" style="font-weight: bold; text-align: center; font-size: 14px;">会员名字</td>
+                        <td width="30%" style="font-weight: bold; text-align: center; font-size: 14px;">Member name</td>
                         <td width="70%">{$userName}</td>
                     </tr>
                     <tr>
-                        <td width="30%" style="font-weight: bold; text-align: center; font-size: 14px;">会员地址</td>
+                        <td width="30%" style="font-weight: bold; text-align: center; font-size: 14px;">Member address</td>
                         <td width="70%">{$address}</td>
                     </tr>
                     <tr>
-                        <td width="30%" style="font-weight: bold; text-align: center; font-size: 14px;">会员电话</td>
+                        <td width="30%" style="font-weight: bold; text-align: center; font-size: 14px;">Member phone</td>
                         <td width="70%">{$mobile}</td>
                     </tr>
                     <tr>
-                        <td width="30%" style="font-weight: bold; text-align: center; font-size: 14px;">订单编号</td>
+                        <td width="30%" style="font-weight: bold; text-align: center; font-size: 14px;">Order code</td>
                         <td width="70%">{$orderSn}</td>
                     </tr>
                     <tr>
-                        <td width="30%" style="font-weight: bold; text-align: center; font-size: 14px;">订单日期</td>
+                        <td width="30%" style="font-weight: bold; text-align: center; font-size: 14px;">Creation time</td>
                         <td width="70%">{$orderAt}</td>
                     </tr>
                     <tr>
-                        <td class="bg" style="font-weight: bold; font-size: 14px; text-align: center;">订单明细</td>
+                        <td class="bg" style="font-weight: bold; font-size: 14px; text-align: center;">Order detail</td>
                         <td class="bg"></td>
                     </tr>
                 </table>
@@ -529,7 +536,7 @@ ORDER;
                 <html lang="en">
                 <head>
                     <meta charset="UTF-8" />
-                    <title>订单详情</title>
+                    <title>Order detail</title>
                     <style>
                         table {
                             border-collapse: collapse;
@@ -556,17 +563,20 @@ ORDER;
                                 
                                 <table border="1" width="100%" style="padding: 10px 20px; text-align: center;">
                                     <tr>
-                                        <th width="20%" style="font-size: 14px; font-weight: bold; text-align: center;">商品编号</th>
-                                        <th width="30%" style="font-size: 14px; font-weight: bold; text-align: center;">商品名称</th>
-                                        <th width="15%" style="font-size: 14px; font-weight: bold; text-align: center;">数量</th>
-                                        <th width="15%" style="font-size: 14px; font-weight: bold; text-align: center;">单价</th>
-                                        <th width="20%" style="font-size: 14px; font-weight: bold; text-align: center;">总价</th>
+                                        <th width="15%" style="font-size: 14px; font-weight: bold; text-align: center;">Product code</th>
+                                        <th width="20%" style="font-size: 14px; font-weight: bold; text-align: center;">Product name</th>
+                                        <th width="13%" style="font-size: 14px; font-weight: bold; text-align: center;">Product price</th>
+                                        <th width="15%" style="font-size: 14px; font-weight: bold; text-align: center;">Quantity</th>
+                                        <th width="10%" style="font-size: 14px; font-weight: bold; text-align: center;">Tax rate</th>
+                                        <th width="12%" style="font-size: 14px; font-weight: bold; text-align: center;">Tax</th>
+                                        <th width="15%" style="font-size: 14px; font-weight: bold; text-align: center;">Total amount</th>
                                     </tr>
                                     {$orderDetails}
                                     <tr>
-                                        <td colspan="2">合计</td>
+                                        <td colspan="3">Total</td>
                                         <td>{$orderNums}</td>
                                         <td></td>
+                                        <td>{$totalTaxAmount}</td>
                                         <td>{$orderAmount}</td>
                                     </tr>
                                 </table>
@@ -576,11 +586,11 @@ ORDER;
                                 <table width="100%" style="border: none; padding: 10px 20px; text-align: center;">
                                     <tr style="border: none;">
                                         <td width="70%" style="border: none;"></td>
-                                        <td width="30%" style="font-weight: bold; text-align: left; font-size: 14px; border: none;">签名:</td>
+                                        <td width="30%" style="font-weight: bold; text-align: left; font-size: 14px; border: none;">Signature:</td>
                                     </tr>
                                     <tr style="border: none;">
                                         <td width="70%" style="border: none;"></td>
-                                        <td width="30%" style="font-weight: bold; text-align: left; font-size: 14px; border: none;">日期:</td>
+                                        <td width="30%" style="font-weight: bold; text-align: left; font-size: 14px; border: none;">Date:</td>
                                     </tr>
                                 </table>
                             </div>

+ 46 - 22
frontendApi/modules/v1/controllers/ShopController.php

@@ -257,6 +257,12 @@ class ShopController extends BaseController {
                 ['LEFT JOIN', OrderGoods::tableName() . ' AS OG', 'OG.ORDER_SN=DO.ORDER_SN'],
             ],
         ]);
+
+        foreach ($data['list'] as &$value) {
+            $taxRate = $value['TAX_RATE'] ?? 0;
+            $value['TAX_AMOUNT'] = Tool::formatPrice(($value['REAL_PRICE'] - $value['REAL_PRICE'] / (1 + $taxRate / 100)) * $value['BUY_NUMS']);
+        }
+
         return static::notice($data);
     }
 
@@ -301,7 +307,7 @@ class ShopController extends BaseController {
 //            if($value['COUNTY']){
 //                $data['list'][$key]['FULL_ADDRESS'] .= Region::getCnName($value['COUNTY']);
 //            }
-            $data['list'][$key]['TAX_AMOUNT'] = Tool::formatPrice($value['REAL_PRICE'] - $value['REAL_PRICE'] / (1 + $value['TAX_RATE'] / 100));
+            $data['list'][$key]['TAX_AMOUNT'] = Tool::formatPrice(($value['REAL_PRICE'] - $value['REAL_PRICE'] / (1 + $value['TAX_RATE'] / 100)) * $value['BUY_NUMS']);
         }
         return static::notice($data);
     }
@@ -427,6 +433,8 @@ class ShopController extends BaseController {
         $orderDetails = '';
         $orderAmount = 0;  // 合计总额
         $orderNums = 0; // 合计总数
+        $totalTaxAmount = 0; // 合计税额
+        $totalAmount = 0;
         foreach ($data['list'] as $key => $value) {
             $provinceName = $value['PROVINCE'] ? Region::getCnName($value['PROVINCE']) : '';
             $cityName = $value['CITY'] ? Region::getCnName($value['CITY']) : '';
@@ -439,16 +447,21 @@ class ShopController extends BaseController {
             $orderAt = Date::convert($value['PAY_AT'],'Y-m-d H:i:s');
 
             // 总价
-            $totalAmount = $value['BUY_NUMS'] * $value['ORDER_AMOUNT'];
+            $totalAmount = $value['BUY_NUMS'] * $value['REAL_PRICE'];
             $orderAmount += $totalAmount;
             $orderNums += $value['BUY_NUMS'];
+            // 税额
+            $taxAmount = floatval(Tool::formatPrice(($value['REAL_PRICE'] - ($value['REAL_PRICE'] / (1 + $value['TAX_RATE'] / 100))) * $value['BUY_NUMS']));
+            $totalTaxAmount += $taxAmount;
             // 订单详情
             $orderDetails .= <<<EOT
                 <tr>
                     <td>{$value['SKU_CODE']}</td>
                     <td>{$value['GOODS_TITLE']}</td>
+                    <td>{$value['REAL_PRICE']}</td>
                     <td>{$value['BUY_NUMS']}</td>
-                    <td>{$value['ORDER_AMOUNT']}</td>
+                    <td>{$value['TAX_RATE']}</td>
+                    <td>{$taxAmount}</td>
                     <td>{$totalAmount}</td> 
                 </tr>
 EOT;
@@ -523,19 +536,22 @@ ORDER;
                         <div style="display: block; width: 100%;">
                             {$orderBase}
                             
-                            <table border="1" width="100%" style="padding: 10px 20px; text-align: center;">
+                            <table border="1" width="100%" style="padding: 10px 5px; text-align: center;">
                                 <tr>
-                                    <th width="20%" style="font-size: 14px; font-weight: bold; text-align: center;">Product code</th>
-                                    <th width="30%" style="font-size: 14px; font-weight: bold; text-align: center;">Product name</th>
-                                    <th width="15%" style="font-size: 14px; font-weight: bold; text-align: center;">Quantity</th>
+                                    <th width="15%" style="font-size: 14px; font-weight: bold; text-align: center;">Product code</th>
+                                    <th width="20%" style="font-size: 14px; font-weight: bold; text-align: center;">Product name</th>
                                     <th width="15%" style="font-size: 14px; font-weight: bold; text-align: center;">Product price</th>
-                                    <th width="20%" style="font-size: 14px; font-weight: bold; text-align: center;">Total amount</th>
+                                    <th width="15%" style="font-size: 14px; font-weight: bold; text-align: center;">Quantity</th>
+                                    <th width="10%" style="font-size: 14px; font-weight: bold; text-align: center;">Tax rate</th>
+                                    <th width="10%" style="font-size: 14px; font-weight: bold; text-align: center;">Tax</th>
+                                    <th width="15%" style="font-size: 14px; font-weight: bold; text-align: center;">Total amount</th>
                                 </tr>
                                 {$orderDetails}
                                 <tr>
-                                    <td colspan="2">Total</td>
+                                    <td colspan="3">Total</td>
                                     <td>{$orderNums}</td>
                                     <td></td>
+                                    <td>{$totalTaxAmount}</td>
                                     <td>{$orderAmount}</td>
                                 </tr>
                             </table>
@@ -610,7 +626,6 @@ ORDER;
      * 导出订单.
      * @return mixed
      * @throws \yii\web\HttpException
-     * @throws \Mpdf\MpdfException
      */
     public function actionDecOrderExport()
     {
@@ -642,6 +657,8 @@ ORDER;
         $orderDetails = '';
         $orderAmount = 0;  // 合计总额
         $orderNums = 0; // 合计总数
+        $totalTaxAmount = 0; // 合计税额
+        $totalAmount = 0;
         foreach ($data['list'] as $key => $value) {
             $provinceName = $value['PROVINCE'] ? Region::getCnName($value['PROVINCE']) : '';
             $cityName = $value['CITY'] ? Region::getCnName($value['CITY']) : '';
@@ -651,20 +668,24 @@ ORDER;
             $userName = $value['REAL_NAME'];
             $address = $provinceName . $cityName . $countyName . $value['ADDRESS'];
             $mobile = $value['MOBILE'];
-            $orderAt = Date::convert($value['PAY_AT'],'Y-m-d H:i:s');
+            $orderAt = Date::convert($value['PAY_AT'] ?? $value['CREATED_AT'],'Y-m-d H:i:s');
 
             // 总价
             $totalAmount = $value['BUY_NUMS'] * $value['REAL_PRICE'];
             $orderAmount += $totalAmount;
             $orderNums += $value['BUY_NUMS'];
-
+            // 税额
+            $taxAmount = floatval(Tool::formatPrice(($value['REAL_PRICE'] - ($value['REAL_PRICE'] / (1 + $value['TAX_RATE'] / 100))) * $value['BUY_NUMS']));
+            $totalTaxAmount += $taxAmount;
             // 订单详情
             $orderDetails .= <<<EOT
                 <tr>
                     <td>{$value['SKU_CODE']}</td>
                     <td>{$value['GOODS_TITLE']}</td>
-                    <td>{$value['BUY_NUMS']}</td>
                     <td>{$value['REAL_PRICE']}</td>
+                    <td>{$value['BUY_NUMS']}</td>
+                    <td>{$value['TAX_RATE']}</td>
+                    <td>{$taxAmount}</td>
                     <td>{$totalAmount}</td> 
                 </tr>
 EOT;
@@ -721,12 +742,12 @@ ORDER;
                     }
                     table td, table th {
                         border: 1px solid #ccc;
-                        padding: 10px 30px;
+                        padding: 5px 5px;
                         border-collapse: collapse;
                     }
-                    td {
-                        padding: 120px;
-                    }
+                    /*td {*/
+                    /*    padding: 120px;*/
+                    /*}*/
                     .bg {
                         background-color: #ccc;
                     }
@@ -741,17 +762,20 @@ ORDER;
                             
                             <table border="1" width="100%" style="padding: 10px 20px; text-align: center;">
                                 <tr>
-                                    <th width="20%" style="font-size: 14px; font-weight: bold; text-align: center;">Product code</th>
-                                    <th width="30%" style="font-size: 14px; font-weight: bold; text-align: center;">Product name</th>
-                                    <th width="15%" style="font-size: 14px; font-weight: bold; text-align: center;">Quantity</th>
+                                    <th width="15%" style="font-size: 14px; font-weight: bold; text-align: center;">Product code</th>
+                                    <th width="20%" style="font-size: 14px; font-weight: bold; text-align: center;">Product name</th>
                                     <th width="15%" style="font-size: 14px; font-weight: bold; text-align: center;">Product price</th>
-                                    <th width="20%" style="font-size: 14px; font-weight: bold; text-align: center;">Total amount价</th>
+                                    <th width="15%" style="font-size: 14px; font-weight: bold; text-align: center;">Quantity</th>
+                                    <th width="10%" style="font-size: 14px; font-weight: bold; text-align: center;">Tax rate</th>
+                                    <th width="10%" style="font-size: 14px; font-weight: bold; text-align: center;">Tax</th>
+                                    <th width="15%" style="font-size: 14px; font-weight: bold; text-align: center;">Total amount</th>
                                 </tr>
                                 {$orderDetails}
                                 <tr>
-                                    <td colspan="2">Total</td>
+                                    <td colspan="3">Total</td>
                                     <td>{$orderNums}</td>
                                     <td></td>
+                                    <td>{$totalTaxAmount}</td>
                                     <td>{$orderAmount}</td>
                                 </tr>
                             </table>

+ 9 - 6
frontendEle/src/views/shop/dec-order-list.vue

@@ -2,15 +2,17 @@
     <div v-loading="loading">
         <div class="white-box">
             <el-table class="withdraw-table" :data="tableData" 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 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="Quantity" prop="BUY_NUMS"></el-table-column><!--数量-->
                 <el-table-column width="120" label="Entry Price" prop="REAL_PRICE"></el-table-column><!--报单金额-->
-                <el-table-column label="Entry BV" prop="REAL_PV"></el-table-column><!--报单BV-->
+                <el-table-column width="120" label="Entry BV" prop="REAL_PV"></el-table-column><!--报单BV-->
+                <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="Entry code" prop="DEC_SN"></el-table-column><!--报单编号-->
                 <el-table-column width="120" label="Order code" prop="ORDER_SN"></el-table-column><!--订单编号-->
                 <el-table-column width="120" label="Member code" prop="USER_NAME"></el-table-column><!--会员编号-->
-                <el-table-column width="120" label="Menber name" prop="REAL_NAME"></el-table-column><!--会员姓名-->
+                <el-table-column width="120" label="Member name" prop="REAL_NAME"></el-table-column><!--会员姓名-->
                 <el-table-column width="150" label="Shipping Address" prop="ADDRESS"></el-table-column><!--收货地址-->
                 <el-table-column width="120" label="Sponsor code" prop="CON_USER_NAME"></el-table-column><!--接点人编号-->
                 <el-table-column width="150" label="Created time"><!--创建时间-->
@@ -67,13 +69,14 @@
       objectSpanMethod(obj) {
 
         if (
-          obj.columnIndex === 5 ||
-          obj.columnIndex === 6 ||
           obj.columnIndex === 7 ||
           obj.columnIndex === 8 ||
           obj.columnIndex === 9 ||
           obj.columnIndex === 10||
-          obj.columnIndex === 11
+          obj.columnIndex === 11||
+          obj.columnIndex === 12||
+          obj.columnIndex === 13||
+          obj.columnIndex === 14
         ) {
           // ⼆维数组存储的数据取出
           var _row = this.spanArr[obj.rowIndex];