Pārlūkot izejas kodu

资金流水加导出

wu 1 gadu atpakaļ
vecāks
revīzija
38b811dbac
2 mainītis faili ar 88 papildinājumiem un 68 dzēšanām
  1. 40 65
      database/yspay_cash.php
  2. 48 3
      src/Api.php

+ 40 - 65
database/yspay_cash.php

@@ -1,13 +1,11 @@
 <?php
 
-$status = array
-(
-	1 => '未确认',
+$status = array(
+    1 => '未确认',
     2 => '已入账',
 );
 
-$fenzhang_status = array
-(
+$fenzhang_status = array(
     1 => '未分账',
     2 => '已分账',
     3 => '分账失败',
@@ -24,29 +22,29 @@ if ($merchant_id) {
     $info = Dever::load('pay/yspay/cash')->getInfo($merchant_id);
 
     if (Dever::load('manage/auth')->checkFunc('pay.account', 'huafu', '账户提现')) {
-        $button = array
-        (
+        $button = array(
             '账户提现' => array('fast', '', 'yspay_cash_tixian&search_option_merchant_id=' . $merchant_id),
         );
     }
 
     $button['账户日志'] = array('location', 'l=project/database/list&project=pay&table=yspay_merchant_log&search_option_state=1&search_option_account_id=' . $account_id . '&search_option_merchant_id=' . $merchant_id . '&[refer]');
+
+    $button['导出数据'] = array('oper', 'pay/api.buy_order?merchant_id=' . $merchant_id, '确认导出数据吗?');
 }
 
-return array
-(
+return array(
     # 表名
     'name' => 'yspay_cash',
     # 显示给用户看的名称
     'lang' => '银联资金记录表',
     'menu' => false,
     'info' => $info,
+    'status' => $status,
+    'fenzhang_status' => $fenzhang_status,
     # 数据结构
-    'struct' => array
-    (
-    
-        'id'        => array
-        (
+    'struct' => array(
+
+        'id'        => array(
             'type'      => 'int-11',
             'name'      => 'ID',
             'default'   => '',
@@ -57,8 +55,7 @@ return array
             //'list'        => true,
         ),
 
-        'account_id'      => array
-        (
+        'account_id'      => array(
             'type'      => 'int-11',
             'name'      => '账户id',
             'default'   => '',
@@ -69,8 +66,7 @@ return array
             'value'     => $account_id,
         ),
 
-        'merchant_id'      => array
-        (
+        'merchant_id'      => array(
             'type'      => 'int-11',
             'name'      => '商户id',
             'default'   => '',
@@ -83,8 +79,7 @@ return array
             'list'      => 'Dever::load("pay/yspay_merchant-one#name", "{merchant_id}")',
         ),
 
-        'order_num'      => array
-        (
+        'order_num'      => array(
             'type'      => 'varchar-800',
             'name'      => '流水号',
             'default'   => '',
@@ -92,11 +87,10 @@ return array
             'match'     => 'is_string',
             'update'    => 'text',
             'search'    => 'fulltext',
-            'list'		=> true,
+            'list'        => true,
         ),
 
-        'source_order_num'      => array
-        (
+        'source_order_num'      => array(
             'type'      => 'varchar-800',
             'name'      => '关联订单号',
             'default'   => '',
@@ -104,11 +98,10 @@ return array
             'match'     => 'is_string',
             'update'    => 'text',
             'search'    => 'fulltext',
-            'list'		=> true,
+            'list'        => true,
         ),
 
-        'ycash'      => array
-        (
+        'ycash'      => array(
             'type'      => 'int-11',
             'name'      => '交易金额',
             'default'   => '0',
@@ -117,8 +110,7 @@ return array
             'list'      => 'Dever::number({ycash}/100, 2)',
         ),
 
-        'yl_cash'      => array
-        (
+        'yl_cash'      => array(
             'type'      => 'int-11',
             'name'      => '银联手续费',
             'default'   => '0',
@@ -127,8 +119,7 @@ return array
             'list'      => 'Dever::number({yl_cash}/100, 2)',
         ),
 
-        'pt_cash'      => array
-        (
+        'pt_cash'      => array(
             'type'      => 'int-11',
             'name'      => '平台手续费',
             'default'   => '0',
@@ -137,8 +128,7 @@ return array
             'list'      => 'Dever::number({pt_cash}/100, 2)',
         ),
 
-        'cash'      => array
-        (
+        'cash'      => array(
             'type'      => 'int-11',
             'name'      => '实际金额',
             'default'   => '0',
@@ -147,30 +137,27 @@ return array
             'list'      => 'Dever::number({cash}/100, 2)',
         ),
 
-        'hf_cash'      => array
-        (
+        'hf_cash'      => array(
             'type'      => 'int-11',
             'name'      => '商户划付金额',
             'default'   => '0',
             'desc'      => '划付金额',
             'match'     => 'option',
             //'update'    => 'text',
-            'list'		=> 'Dever::number({hf_cash}/100, 2)',
+            'list'        => 'Dever::number({hf_cash}/100, 2)',
         ),
 
-        'fz_cash'      => array
-        (
+        'fz_cash'      => array(
             'type'      => 'int-11',
             'name'      => '平台分账金额',
             'default'   => '0',
             'desc'      => '分账金额',
             'match'     => 'option',
             //'update'    => 'text',
-            'list'		=> 'Dever::number({fz_cash}/100, 2)',
+            'list'        => 'Dever::number({fz_cash}/100, 2)',
         ),
 
-        'fdate'     => array
-        (
+        'fdate'     => array(
             'type'      => 'int-11',
             'name'      => '入账时间',
             'default'   => '',
@@ -181,8 +168,7 @@ return array
             'list_order' => 100,
         ),
 
-        'rdate'     => array
-        (
+        'rdate'     => array(
             'type'      => 'int-11',
             'name'      => '分账时间',
             'default'   => '',
@@ -193,8 +179,7 @@ return array
             'list_order' => 100,
         ),
 
-        'tdate'     => array
-        (
+        'tdate'     => array(
             'type'      => 'int-11',
             'name'      => '提现时间',
             'default'   => '',
@@ -205,8 +190,7 @@ return array
             //'list_order' => 101,
         ),
 
-        'status'        => array
-        (
+        'status'        => array(
             'type'      => 'tinyint-1',
             'name'      => '订单状态',
             'default'   => '1',
@@ -217,8 +201,7 @@ return array
             'list'      => true,
         ),
 
-        'fenzhang_status'        => array
-        (
+        'fenzhang_status'        => array(
             'type'      => 'tinyint-1',
             'name'      => '分账状态',
             'default'   => '1',
@@ -229,17 +212,15 @@ return array
             'list'      => true,
         ),
 
-        'state'     => array
-        (
+        'state'     => array(
             'type'      => 'tinyint-1',
             'name'      => '状态',
             'default'   => '1',
             'desc'      => '请选择状态',
             'match'     => 'is_numeric',
         ),
-        
-        'cdate'     => array
-        (
+
+        'cdate'     => array(
             'type'      => 'int-11',
             'name'      => '下单时间',
             'match'     => array('is_numeric', time()),
@@ -251,20 +232,16 @@ return array
         ),
     ),
 
-    'manage' => array
-    (
+    'manage' => array(
         'edit' => false,
         'insert' => false,
         'delete' => false,
         'button' => $button,
     ),
 
-    'request' => array
-    (
-        'getTotal' => array
-        (
-            'option' => array
-            (
+    'request' => array(
+        'getTotal' => array(
+            'option' => array(
                 'merchant_id' => 'yes',
                 'status' => array('yes', '>='),
                 'state' => 1,
@@ -273,10 +250,8 @@ return array
             'col' => 'sum(cash) as cash,sum(hf_cash) as hf_cash,sum(fz_cash) as fz_cash,sum(yl_cash) as yl_cash,sum(pt_cash) as pt_cash',
         ),
 
-        'getList' => array
-        (
-            'option' => array
-            (
+        'getList' => array(
+            'option' => array(
                 'start' => array('yes-cdate', '>='),
                 'end' => array('yes-cdate', '<='),
                 'fdate_start' => array('yes-fdate', '>='),

+ 48 - 3
src/Api.php

@@ -1,4 +1,6 @@
-<?php namespace Pay\Src;
+<?php
+
+namespace Pay\Src;
 
 use Dever;
 
@@ -288,7 +290,7 @@ class Api
 		if (!$pay || ($pay && $pay['state'] != 1)) {
 			Dever::alert('没有账户信息');
 		}
-		
+
 		if (!$pay['type']) {
 			Dever::alert('账户类型错误');
 		}
@@ -311,8 +313,51 @@ class Api
 		if (isset($this->ip) && $this->ip) {
 			$pay['ip'] = $this->ip;
 		}
-		
+
 		$this->method = new $method($pay);
 		return $this;
 	}
+
+	public function buy_order($data)
+	{
+		$id = Dever::input('merchant_id');
+		$data = Dever::db('pay/yspay_cash')->select(['merchant_id' => $id]);
+		if (!$data) {
+			Dever::alert('无导出数据');
+		}
+		$file = date('Y-m-d H:i:s') . '资金流水数据';
+
+
+		$header = array('商户名称', '流水号', '关联订单号', '交易金额', '银联手续费', '平台手续费', '实际金额', '商户划付金额', '平台分账金额', '订单状态', '分账状态', '下单时间', '入账时间', '分账时间');
+
+
+		$body = array();
+		$orderStatus = Dever::db('pay/yspay_cash')->config['status'];
+		$fenStatus = Dever::db('pay/yspay_cash')->config['fenzhang_status'];
+		$factory = Dever::db('pay/yspay_merchant')->all();
+		$factory = array_column($factory, 'name', 'id');
+
+		foreach ($data as $k => $v) {
+			$factory_name = isset($factory[$v['account_id']]) ? $factory[$v['account_id']] : '';
+			$d = array(
+				$factory_name,
+				$v['order_num'],
+				$v['source_order_num'],
+				$v['ycash'] / 100,
+				$v['yl_cash'] / 100,
+				$v['pt_cash'] / 100,
+				$v['cash'] / 100,
+				$v['hf_cash'] / 100,
+				$v['fz_cash'] / 100,
+				$orderStatus[$v['status']] ?? '',
+				$fenStatus[$v['fenzhang_status']] ?? '',
+				empty($v['cdate']) ? '' : date('Y-m-d H:i:s', $v['cdate']),
+				empty($v['rdate']) ? '' : date('Y-m-d H:i:s', $v['rdate']),
+				empty($v['fdate']) ? '' : date('Y-m-d H:i:s', $v['fdate']),
+			);
+
+			$body[] = $d;
+		};
+		return Dever::excelExport($body, $header, $file);
+	}
 }