|
|
@@ -8,12 +8,20 @@ use common\helpers\Form;
|
|
|
use common\helpers\http\RemoteUploadApi;
|
|
|
use common\helpers\Tool;
|
|
|
use common\libs\dataList\DataList;
|
|
|
+use common\models\ApproachOrder;
|
|
|
+use common\models\ApproachOrderGoods;
|
|
|
use common\models\Export;
|
|
|
+use common\models\Order;
|
|
|
+use common\models\OrderGoods;
|
|
|
use common\models\Region;
|
|
|
+use common\models\ShopGoods;
|
|
|
+use common\models\User;
|
|
|
use Yii;
|
|
|
use yii\base\Exception;
|
|
|
use yii\base\StaticInstanceTrait;
|
|
|
use yii\base\Component;
|
|
|
+use yii\data\Pagination;
|
|
|
+use yii\db\Query;
|
|
|
|
|
|
class BaseExport extends Component {
|
|
|
use StaticInstanceTrait;
|
|
|
@@ -280,6 +288,56 @@ class BaseExport extends Component {
|
|
|
return 'finish';
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 循环写入数据
|
|
|
+ * @param $realFile
|
|
|
+ * @param $fileNameUpdated
|
|
|
+ * @param int $page
|
|
|
+ * @param int $counter
|
|
|
+ * @return string
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ private function _loopWriteDataOrder()
|
|
|
+ {
|
|
|
+ LoggerTool::info($this->params);
|
|
|
+
|
|
|
+ $orderQuery = Order::find()
|
|
|
+ ->alias('O')
|
|
|
+ ->where($this->params['condition'], $this->params['params'])
|
|
|
+ ->select('O.*,U.REAL_NAME,U.DEC_ID,SG.CATEGORY_TYPE,OG.REAL_PRICE,OG.TAX_RATE,OG.BUY_NUMS,OG.SKU_CODE,OG.GOODS_TITLE,OG.REAL_PV')
|
|
|
+ ->join('LEFT JOIN', User::tableName() . ' AS U', 'U.ID=O.USER_ID')
|
|
|
+ ->join('LEFT JOIN', OrderGoods::tableName() . ' AS OG', 'OG.ORDER_SN=O.SN')
|
|
|
+ ->join('LEFT JOIN', ShopGoods::tableName() . ' AS SG', 'SG.ID=OG.GOODS_ID')
|
|
|
+ ->orderBy('O.CREATED_AT DESC');
|
|
|
+
|
|
|
+ // 订单中间表只查询待支付和支付失败的订单
|
|
|
+ $this->params['params'][':NOT_PAID'] = \Yii::$app->params['orderStatus']['notPaid']['value']; // 待支付
|
|
|
+ $this->params['params'][':FAIL_PAID'] = \Yii::$app->params['orderStatus']['failPaid']['value']; // 支付失败
|
|
|
+ $orderStandardQuery = ApproachOrder::find()
|
|
|
+ ->alias('O')
|
|
|
+ ->where($this->params['condition'] . ' AND (O.STATUS = :NOT_PAID OR O.STATUS = :FAIL_PAID)', $this->params['params'])
|
|
|
+ ->select('O.*,U.REAL_NAME,U.DEC_ID,SG.CATEGORY_TYPE,OG.REAL_PRICE,OG.TAX_RATE,OG.BUY_NUMS,OG.SKU_CODE,OG.GOODS_TITLE,OG.REAL_PV')
|
|
|
+ ->join('LEFT JOIN', User::tableName() . ' AS U', 'U.ID=O.USER_ID')
|
|
|
+ ->join('LEFT JOIN', ApproachOrderGoods::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]);
|
|
|
+ $lists = $query->all();
|
|
|
+
|
|
|
+ if(!empty($lists)){
|
|
|
+ foreach($lists as $columnData){
|
|
|
+ fputcsv($this->_fp, Tool::arrTextConvert($columnData));
|
|
|
+ unset($percent, $columnData);
|
|
|
+ }
|
|
|
+ unset($list);
|
|
|
+ }
|
|
|
+
|
|
|
+ unset($list);
|
|
|
+ return 'finish';
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 完成
|
|
|
* @return bool
|
|
|
@@ -429,7 +487,301 @@ class BaseExport extends Component {
|
|
|
* @throws \yii\base\InvalidConfigException
|
|
|
* @throws \yii\httpclient\Exception
|
|
|
*/
|
|
|
- public function generatePDF() {
|
|
|
+ public function generateOrderExcel() {
|
|
|
+ $this->getParams();
|
|
|
+ if (!$this->params) {
|
|
|
+ throw new Exception('无法获取需要的参数');
|
|
|
+ }
|
|
|
+ $path = $this->getSaveBasePath() . __DS__ . $this->getSavePath();
|
|
|
+ $path = __DS__ . $path;
|
|
|
+ $realFile = $this->mkdir($path) . __DS__ . $this->getFileName();
|
|
|
+ $this->completed = false;
|
|
|
+ $this->getExportId();
|
|
|
+ $this->getUserId();
|
|
|
+ $fileNameUpdated = false;
|
|
|
+ $this->_fp = fopen($realFile, 'w');
|
|
|
+ @exec('chown -R www:www /'.$realFile);
|
|
|
+ @exec('chmod -R 777 /'.$realFile);
|
|
|
+ // 获取列表数据及表头
|
|
|
+ $this->_listModel = new $this->listModelClass();
|
|
|
+ $this->_listModel->isExport = true;
|
|
|
+ if(method_exists($this->_listModel, 'getExportHeaders')){
|
|
|
+ if(method_exists($this->_listModel, 'exportPrepare')) {//导出数据提前设置参数
|
|
|
+ $this->_listModel->exportPrepare(['condition' => $this->params['condition'], 'params' => $this->params['params'], 'others' => isset($this->params['others']) ? $this->params['others'] : [], 'page' => 0, 'pageSize' => $this->pageSize, 'userId' => $this->userId]);
|
|
|
+ }
|
|
|
+ $headers = $this->_listModel->getExportHeaders($this->userId);
|
|
|
+ fputcsv($this->_fp, $headers);
|
|
|
+ unset($headers);
|
|
|
+ $this->_updateFirst($realFile, 1);
|
|
|
+ } else {
|
|
|
+ throw new Exception($this->listModelClass.'的getExportHeaders方法不存在');
|
|
|
+ }
|
|
|
+ $this->_loopWriteDataOrder();
|
|
|
+ $this->complete();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成
|
|
|
+ * @return bool
|
|
|
+ * @throws Exception
|
|
|
+ * @throws \yii\base\InvalidConfigException
|
|
|
+ * @throws \yii\httpclient\Exception
|
|
|
+ */
|
|
|
+ public function generateOrderPDF() {
|
|
|
+ $this->getParams();
|
|
|
+ if (!$this->params) {
|
|
|
+ throw new Exception('无法获取需要的参数');
|
|
|
+ }
|
|
|
+ $path = __DS__ . $this->getSaveBasePath() . __DS__ . $this->getSavePath();
|
|
|
+ $realFile = $path . __DS__ . $this->getFileName('.pdf');
|
|
|
+
|
|
|
+ $this->completed = false;
|
|
|
+ $this->getExportId();
|
|
|
+ $this->getUserId();
|
|
|
+ $fileNameUpdated = false;
|
|
|
+
|
|
|
+ // 获取列表数据及表头
|
|
|
+ $this->_listModel = new $this->listModelClass();
|
|
|
+ $this->_listModel->isExport = true;
|
|
|
+
|
|
|
+ // 查询订单数据
|
|
|
+// $oderList = $this->_loopWriteDataPDF($realFile, $fileNameUpdated);
|
|
|
+ $orderQuery = Order::find()
|
|
|
+ ->alias('O')
|
|
|
+ ->where($this->params['condition'], $this->params['params'])
|
|
|
+ ->select('O.*,U.REAL_NAME,U.DEC_ID,SG.CATEGORY_TYPE,OG.REAL_PRICE,OG.TAX_RATE,OG.BUY_NUMS,OG.SKU_CODE,OG.GOODS_TITLE,OG.REAL_PV')
|
|
|
+ ->join('LEFT JOIN', User::tableName() . ' AS U', 'U.ID=O.USER_ID')
|
|
|
+ ->join('LEFT JOIN', OrderGoods::tableName() . ' AS OG', 'OG.ORDER_SN=O.SN')
|
|
|
+ ->join('LEFT JOIN', ShopGoods::tableName() . ' AS SG', 'SG.ID=OG.GOODS_ID')
|
|
|
+ ->orderBy('O.CREATED_AT DESC');
|
|
|
+
|
|
|
+ // 订单中间表只查询待支付和支付失败的订单
|
|
|
+ $this->params['params'][':NOT_PAID'] = \Yii::$app->params['orderStatus']['notPaid']['value']; // 待支付
|
|
|
+ $this->params['params'][':FAIL_PAID'] = \Yii::$app->params['orderStatus']['failPaid']['value']; // 支付失败
|
|
|
+ $orderStandardQuery = ApproachOrder::find()
|
|
|
+ ->alias('O')
|
|
|
+ ->where($this->params['condition'] . ' AND (O.STATUS = :NOT_PAID OR O.STATUS = :FAIL_PAID)', $this->params['params'])
|
|
|
+ ->select('O.*,U.REAL_NAME,U.DEC_ID,SG.CATEGORY_TYPE,OG.REAL_PRICE,OG.TAX_RATE,OG.BUY_NUMS,OG.SKU_CODE,OG.GOODS_TITLE,OG.REAL_PV')
|
|
|
+ ->join('LEFT JOIN', User::tableName() . ' AS U', 'U.ID=O.USER_ID')
|
|
|
+ ->join('LEFT JOIN', ApproachOrderGoods::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]);
|
|
|
+ $oderList = $query->all();
|
|
|
+
|
|
|
+ if ($oderList) {
|
|
|
+ $userId = '';
|
|
|
+ $userName = '';
|
|
|
+ $address = '';
|
|
|
+ $mobile = '';
|
|
|
+ $orderAt = '';
|
|
|
+ $orderDetails = '';
|
|
|
+ $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']) : '';
|
|
|
+ $countyName = $value['COUNTY'] ? Region::getCnName($value['COUNTY']) : '';
|
|
|
+
|
|
|
+ $userId = $value['USER_NAME'];
|
|
|
+ $userName = $value['REAL_NAME'];
|
|
|
+ $address = $provinceName . $cityName . $countyName . $value['ADDRESS'];
|
|
|
+ $mobile = $value['MOBILE'];
|
|
|
+ $orderAt = Date::convert($value['CREATED_AT'],'Y-m-d H:i:s');
|
|
|
+ $orderSn = $value['SN'];
|
|
|
+ // 总价
|
|
|
+ $totalAmount = $value['BUY_NUMS'] * $value['REAL_PRICE'];
|
|
|
+ $orderAmount += $totalAmount;
|
|
|
+ $orderNums += $value['BUY_NUMS'];
|
|
|
+ // 税额
|
|
|
+ $taxAmount = Tool::calculateTax($value['REAL_PRICE'], $value['TAX_RATE'], $value['BUY_NUMS']);
|
|
|
+ $totalTaxAmount += $taxAmount;
|
|
|
+ $taxAmount = Tool::formatAmount($taxAmount);
|
|
|
+ $totalAmount = Tool::formatAmount($totalAmount);
|
|
|
+ // 订单详情
|
|
|
+ $orderDetails .= <<<EOT
|
|
|
+ <tr>
|
|
|
+ <td>{$value['SKU_CODE']}</td>
|
|
|
+ <td>{$value['GOODS_TITLE']}</td>
|
|
|
+ <td style="text-align: right;">{$value['REAL_PRICE']}</td>
|
|
|
+ <td>{$value['BUY_NUMS']}</td>
|
|
|
+ <td style="text-align: right;">{$value['TAX_RATE']}</td>
|
|
|
+ <td style="text-align: right;">{$taxAmount}</td>
|
|
|
+ <td style="text-align: right;">{$totalAmount}</td>
|
|
|
+ </tr>
|
|
|
+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;">Member code</td>
|
|
|
+ <td width="70%">{$userId}</td>
|
|
|
+ </tr>
|
|
|
+ <tr>
|
|
|
+ <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;">Member address</td>
|
|
|
+ <td width="70%">{$address}</td>
|
|
|
+ </tr>
|
|
|
+ <tr>
|
|
|
+ <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;">Order code</td>
|
|
|
+ <td width="70%">{$orderSn}</td>
|
|
|
+ </tr>
|
|
|
+ <tr>
|
|
|
+ <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;">Order detail</td>
|
|
|
+ <td class="bg"></td>
|
|
|
+ </tr>
|
|
|
+ </table>
|
|
|
+ORDER;
|
|
|
+
|
|
|
+ $l['a_meta_charset'] = 'UTF-8';
|
|
|
+ $l['a_meta_dir'] = 'ltr';
|
|
|
+ $l['a_meta_language'] = 'zh';
|
|
|
+ $l['w_page'] = '页面';
|
|
|
+
|
|
|
+ $orderAmount = Tool::formatAmount($orderAmount);
|
|
|
+ $totalTaxAmount = Tool::formatAmount($totalTaxAmount);
|
|
|
+
|
|
|
+ $context = <<<ORDER
|
|
|
+ <!doctype html>
|
|
|
+ <html lang="en">
|
|
|
+ <head>
|
|
|
+ <meta charset="UTF-8" />
|
|
|
+ <title>Order detail</title>
|
|
|
+ <style>
|
|
|
+ table {
|
|
|
+ border-collapse: collapse;
|
|
|
+ }
|
|
|
+ table td, table th {
|
|
|
+ border: 1px solid #ccc;
|
|
|
+ padding: 5px 5px;
|
|
|
+ border-collapse: collapse;
|
|
|
+ }
|
|
|
+ /*td {*/
|
|
|
+ /* padding: 120px;*/
|
|
|
+ /*}*/
|
|
|
+ .bg {
|
|
|
+ background-color: #ccc;
|
|
|
+ }
|
|
|
+ </style>
|
|
|
+ </head>
|
|
|
+ <body>
|
|
|
+ <div class="content">
|
|
|
+ <p style="text-align: center; font-weight: bold; font-size: 22px;"><b>Order detail</b><br></p>
|
|
|
+ <div>
|
|
|
+ <div style="display: block; width: 100%;">
|
|
|
+ {$orderBase}
|
|
|
+
|
|
|
+ <table border="1" width="100%" style="padding: 10px 5px; text-align: center;">
|
|
|
+ <tr>
|
|
|
+ <th width="15%" style="font-size: 14px; font-weight: bold; text-align: center;">Product code</th>
|
|
|
+ <th width="25%" 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="10%" style="font-size: 14px; font-weight: bold; text-align: center;">Qty</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="3">Total</td>
|
|
|
+ <td>{$orderNums}</td>
|
|
|
+ <td></td>
|
|
|
+ <td style="text-align: right;">{$totalTaxAmount}</td>
|
|
|
+ <td style="text-align: right;">{$orderAmount}</td>
|
|
|
+ </tr>
|
|
|
+ </table>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div style="width: 100%; margin-top: 50px; height: 30px;">
|
|
|
+ <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;">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;">Date:</td>
|
|
|
+ </tr>
|
|
|
+ </table>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </body>
|
|
|
+ </html>
|
|
|
+ORDER;
|
|
|
+
|
|
|
+ require_once (\Yii::$app->vendorPath . '/tecnickcom/tcpdf/tcpdf.php');
|
|
|
+
|
|
|
+ $pdf = new \TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
|
|
|
+ // 设置打印模式
|
|
|
+ $pdf->SetCreator(PDF_CREATOR);
|
|
|
+ $pdf->SetAuthor('DaZe');
|
|
|
+ $pdf->SetTitle($orderSn);
|
|
|
+ $pdf->SetSubject('TCPDF Tutorial');
|
|
|
+ $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
|
|
|
+ // 是否显示页眉
|
|
|
+ $pdf->setPrintHeader(false);
|
|
|
+ // 设置页眉字体
|
|
|
+ $pdf->setHeaderFont(Array('dejavusans', '', '12'));
|
|
|
+ // 页眉距离顶部的距离
|
|
|
+ $pdf->SetHeaderMargin('5');
|
|
|
+ // 是否显示页脚
|
|
|
+ $pdf->setPrintFooter(false);
|
|
|
+ // 设置默认等宽字体
|
|
|
+ $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
|
|
|
+ // 设置行高
|
|
|
+ $pdf->setCellHeightRatio(1);
|
|
|
+ // 设置左、上、右的间距
|
|
|
+ $pdf->SetMargins('10', '10', '10');
|
|
|
+ // 设置是否自动分页 距离底部多少距离时分页
|
|
|
+ $pdf->SetAutoPageBreak(TRUE, '15');
|
|
|
+ // 设置图像比例因子
|
|
|
+ $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
|
|
|
+ if (@file_exists(\Yii::$app->vendorPath . 'tecnickcom/tcpdf/examples/lang/eng.php')) {
|
|
|
+ require_once(\Yii::$app->vendorPath . '/tecnickcom/tcpdf/examples/lang/eng.php');
|
|
|
+ $pdf->setLanguageArray($l);
|
|
|
+ }
|
|
|
+ $pdf->setFontSubsetting(true);
|
|
|
+ $pdf->AddPage();
|
|
|
+ // 设置字体
|
|
|
+ $pdf->SetFont('stsongstdlight', '', 10, '', true);
|
|
|
+ $pdf->writeHTML($context);
|
|
|
+ $pdf->Output($realFile, 'F');
|
|
|
+
|
|
|
+ $this->_updateFirst($realFile, 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->complete();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 生成
|
|
|
+ * @return bool
|
|
|
+ * @throws Exception
|
|
|
+ * @throws \yii\base\InvalidConfigException
|
|
|
+ * @throws \yii\httpclient\Exception
|
|
|
+ */
|
|
|
+ public function generateDecOrderPDF() {
|
|
|
$this->getParams();
|
|
|
if (!$this->params) {
|
|
|
throw new Exception('无法获取需要的参数');
|
|
|
@@ -447,7 +799,32 @@ class BaseExport extends Component {
|
|
|
$this->_listModel->isExport = true;
|
|
|
|
|
|
// 查询订单数据
|
|
|
- $oderList = $this->_loopWriteDataPDF($realFile, $fileNameUpdated);
|
|
|
+// $oderList = $this->_loopWriteDataPDF($realFile, $fileNameUpdated);
|
|
|
+ $orderQuery = Order::find()
|
|
|
+ ->alias('O')
|
|
|
+ ->where($this->params['condition'], $this->params['params'])
|
|
|
+ ->select('O.*,U.REAL_NAME,U.DEC_ID,SG.CATEGORY_TYPE,OG.REAL_PRICE,OG.TAX_RATE,OG.BUY_NUMS,OG.SKU_CODE,OG.GOODS_TITLE,OG.REAL_PV')
|
|
|
+ ->join('LEFT JOIN', User::tableName() . ' AS U', 'U.ID=O.USER_ID')
|
|
|
+ ->join('LEFT JOIN', OrderGoods::tableName() . ' AS OG', 'OG.ORDER_SN=O.SN')
|
|
|
+ ->join('LEFT JOIN', ShopGoods::tableName() . ' AS SG', 'SG.ID=OG.GOODS_ID')
|
|
|
+ ->orderBy('O.CREATED_AT DESC');
|
|
|
+
|
|
|
+ // 订单中间表只查询待支付和支付失败的订单
|
|
|
+ $this->params['params'][':NOT_PAID'] = \Yii::$app->params['orderStatus']['notPaid']['value']; // 待支付
|
|
|
+ $this->params['params'][':FAIL_PAID'] = \Yii::$app->params['orderStatus']['failPaid']['value']; // 支付失败
|
|
|
+ $orderStandardQuery = ApproachOrder::find()
|
|
|
+ ->alias('O')
|
|
|
+ ->where($this->params['condition'] . ' AND (O.STATUS = :NOT_PAID OR O.STATUS = :FAIL_PAID)', $this->params['params'])
|
|
|
+ ->select('O.*,U.REAL_NAME,U.DEC_ID,SG.CATEGORY_TYPE,OG.REAL_PRICE,OG.TAX_RATE,OG.BUY_NUMS,OG.SKU_CODE,OG.GOODS_TITLE,OG.REAL_PV')
|
|
|
+ ->join('LEFT JOIN', User::tableName() . ' AS U', 'U.ID=O.USER_ID')
|
|
|
+ ->join('LEFT JOIN', ApproachOrderGoods::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]);
|
|
|
+ $oderList = $query->all();
|
|
|
+
|
|
|
if ($oderList) {
|
|
|
$userId = '';
|
|
|
$userName = '';
|
|
|
@@ -466,17 +843,17 @@ class BaseExport extends Component {
|
|
|
$countyName = $value['COUNTY'] ? Region::getCnName($value['COUNTY']) : '';
|
|
|
|
|
|
$userId = $value['USER_NAME'];
|
|
|
- $userName = $value['CREATE_USER_NAME'];
|
|
|
+ $userName = $value['REAL_NAME'];
|
|
|
$address = $provinceName . $cityName . $countyName . $value['ADDRESS'];
|
|
|
$mobile = $value['MOBILE'];
|
|
|
- $orderAt = $value['PAY_AT'];
|
|
|
+ $orderAt = Date::convert($value['CREATED_AT'],'Y-m-d H:i:s');
|
|
|
$orderSn = $value['SN'];
|
|
|
// 总价
|
|
|
$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']));
|
|
|
+ $taxAmount = Tool::calculateTax($value['REAL_PRICE'], $value['TAX_RATE'], $value['BUY_NUMS']);
|
|
|
$totalTaxAmount += $taxAmount;
|
|
|
$taxAmount = Tool::formatAmount($taxAmount);
|
|
|
$totalAmount = Tool::formatAmount($totalAmount);
|
|
|
@@ -571,7 +948,7 @@ ORDER;
|
|
|
<th width="15%" style="font-size: 14px; font-weight: bold; text-align: center;">Product code</th>
|
|
|
<th width="25%" 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="10%" 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;">Qty</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>
|