Sfoglia il codice sorgente

公证处入账明细-增加导出

sunxbiao 1 anno fa
parent
commit
8db820a92f

+ 68 - 0
app/common/repositories/merchant/order/OrderGzcRepository.php

@@ -15,6 +15,7 @@ use app\common\model\merchant\order\OrderGzc;
15 15
 use app\common\repositories\BaseRepository;
16 16
 use app\traits\GzcApiRequest;
17 17
 use Carbon\Carbon;
18
+use crmeb\services\SpreadsheetExcelService;
18 19
 use FormBuilder\Factory\Elm;
19 20
 use think\facade\Log;
20 21
 use think\facade\Route;
@@ -46,6 +47,42 @@ class OrderGzcRepository extends BaseRepository
46 47
     public function getList(array $where, $page, $limit)
47 48
     {
48 49
         $query = $this->dao->search($where);
50
+        // 导出
51
+        $is_excel = request()->param('is_excel', 0);
52
+        if ($is_excel == 1) {
53
+            $data = $query->with('user')->select();
54
+            $arr = [];
55
+            foreach ($data as $item) {
56
+                $arr[] = [
57
+                    $item['id'],
58
+                    $item['platform_no'],
59
+                    $item['user']['nickname'],
60
+                    $item['user']['account'],
61
+                    $item['user_name'],
62
+                    $item['mobile'],
63
+                    $item['user_card'],
64
+                    $item['bank_name'],
65
+                    $item['branch_name'],
66
+                    $item['bank_account'],
67
+                    $item['bank_no'],
68
+                    $item['alipay_account'],
69
+                    $item['alipay_no'],
70
+                    $item['wxpay_account'],
71
+                    $item['wxpay_no'],
72
+                    $item['out_trade_no'],
73
+                    $item['pension'],
74
+                    $item['gzc'] == 1 ? '已发起' : '待发起',
75
+                    $item['gzc_deposit_no'],
76
+                    $item['gzc_confirm_result'],
77
+                    $item['create_time'],
78
+                    $item['update_time']
79
+                ];
80
+            }
81
+            return $this->getStatisticsExcel([
82
+                'ID', '平台申请单号', '用户昵称', '用户账号', '实名认证姓名', '实名认证电话', '实名认证证件号', '银行名称', '银行名称', '开户账号', '转账流水号', '支付宝账号', '支付宝流水号', '微信账号', '微信流水号', '关联订单', '养老金', '处理状态', '公证处入账编号', '公证处入账结果', '创建时间', '更新时间'
83
+            ], $arr, '公证处入账明细');
84
+        }
85
+
49 86
         $query1 = $this->dao->search($where);
50 87
         $query2 = $this->dao->search($where);
51 88
         $field1 = $query1->field('sum(pension) as count3, count(*) as count1')->where('gzc', 0)->find();
@@ -81,6 +118,37 @@ class OrderGzcRepository extends BaseRepository
81 118
         return compact('count', 'list', 'stat', 'where');
82 119
     }
83 120
 
121
+    /**
122
+     * 获取统计导出
123
+     */
124
+    public function getStatisticsExcel($header,$arr,$title)
125
+    {
126
+        $filename = $title.'_'.date('YmdHis').'_'.rand(10000,99999);
127
+        $name = $filename;
128
+        $info = '生成时间:' . date('Y-m-d H:i:s',time());
129
+        $suffix='xlsx';
130
+        $path='extract';
131
+        unset($_instance);
132
+
133
+        $_instance = SpreadsheetExcelService::instance_xin();
134
+
135
+        $_path =$_instance
136
+            ->createOrActive()
137
+            ->setExcelHeader($header)
138
+            ->setExcelTile($title, $name, $info)
139
+            ->setExcelContent($arr)
140
+            ->excelSave($filename, $suffix, $path);
141
+
142
+        $domain = request()->domain();
143
+        $data= [
144
+            'name' => $filename.'.'.$suffix,
145
+            'status' => 1,
146
+            'path' => $domain.'/'.$_path
147
+        ];
148
+
149
+        return $data;
150
+    }
151
+
84 152
     public function inForm()
85 153
     {
86 154
         $info1 = OrderGzc::getInstance()->where('account_type', 1)->where('pension', '>', 0)->find();