rabin 9 months ago
parent
commit
0d616009da
6 changed files with 186 additions and 11 deletions
  1. 26 2
      database/yspay_cash.php
  2. 3 3
      database/yspay_cash_log.php
  3. 103 0
      database/yspay_cash_tixian.php
  4. 26 2
      database/yspay_merchant.php
  5. 24 1
      yspay/Cash.php
  6. 4 3
      yspay/Multi.php

+ 26 - 2
database/yspay_cash.php

@@ -15,6 +15,27 @@ $fenzhang_status = array
 
 $button = array();
 
+$merchant_id = Dever::input('search_option_merchant_id');
+
+$info = '';
+
+if ($merchant_id) {
+    $merchant = Dever::db('pay/yspay_merchant')->one($merchant_id);
+    $yue = $merchant['hf_cash'] - $merchant['hf_tx_cash'];
+    $yue = $yue/100;
+    $beifujin = 0;
+    if ($yue >= 100) {
+        $beifujin = 100;
+    }
+    $tixian = $yue - $beifujin;
+    $info = '当前账户余额:¥' . Dever::number($yue) . '    备付金:¥'.Dever::number($beifujin).'    可提现余额:¥' . Dever::number($tixian);
+
+    $button = array
+    (
+        '账户提现' => array('fast', '', 'yspay_cash_tixian&search_option_merchant_id=' . $merchant_id),
+    );
+}
+
 return array
 (
     # 表名
@@ -22,6 +43,7 @@ return array
     # 显示给用户看的名称
     'lang' => '银联资金记录表',
     'menu' => false,
+    'info' => $info,
     # 数据结构
     'struct' => array
     (
@@ -59,7 +81,7 @@ return array
             'match'     => 'option',
             'search'    => 'hidden',
             'update'    => 'hidden',
-            'value'     => Dever::input('search_option_merchant_id'),
+            'value'     => $merchant_id,
             'list_name' => '商户名称',
             'list'      => 'Dever::load("pay/yspay_merchant-one#name", "{merchant_id}")',
         ),
@@ -72,6 +94,7 @@ return array
             'desc'      => '流水号',
             'match'     => 'is_string',
             'update'    => 'text',
+            'search'    => 'fulltext',
             'list'		=> true,
         ),
 
@@ -83,6 +106,7 @@ return array
             'desc'      => '关联订单号',
             'match'     => 'is_string',
             'update'    => 'text',
+            'search'    => 'fulltext',
             'list'		=> true,
         ),
 
@@ -213,7 +237,7 @@ return array
             'desc'      => '',
             # 只有insert时才生效
             //'insert'    => true,
-            //'search'    => 'date',
+            'search'    => 'date',
             'list'      => 'date("Y-m-d H:i:s", {cdate})',
         ),
     ),

+ 3 - 3
database/yspay_cash_log.php

@@ -129,8 +129,8 @@ return array
             'desc'      => '提现状态',
             'match'     => 'is_numeric',
             'option'    => $status,
-            'search'    => 'select',
-            'list'      => true,
+            //'search'    => 'select',
+            //'list'      => true,
         ),
 
         'error'      => array
@@ -151,7 +151,7 @@ return array
             'desc'      => '备注',
             'match'     => 'is_numeric',
             'update'    => 'text',
-            'list'      => true,
+            //'list'      => true,
         ),
 
         'response'        => array

+ 103 - 0
database/yspay_cash_tixian.php

@@ -0,0 +1,103 @@
+<?php
+$status = array
+(
+    1 => array('name' => '申请中', 'style' => 'font-weight:bold;color:blue'),
+    2 => array('name' => '受理成功', 'style' => 'font-weight:bold;color:green'),
+    3 => array('name' => '受理失败', 'style' => 'font-weight:bold;color:#CD3700'),
+);
+
+$type = array
+(
+	1 => '划付',
+	2 => '分账',
+);
+
+$auto = array
+(
+	1 => '自动',
+	2 => '手动',
+);
+return array
+(
+    # 表名
+    'name' => 'yspay_cash_tixian',
+    # 显示给用户看的名称
+    'lang' => '银联资金提现',
+    'order' => -200,
+    'menu' => false,
+    'start' => array
+    (
+    	'insert' => 'pay/yspay/cash.tixian', 
+    	'update' => 'pay/yspay/cash.tixian',
+    ),
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'update'    => 'hidden',
+            //'list'        => true,
+        ),
+
+        'merchant_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '商户id',
+            'default'   => '',
+            'desc'      => '商户id',
+            'match'     => 'option',
+            'update'    => 'hidden',
+            'value'     => Dever::input('search_option_merchant_id'),
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '提现金额',
+            'default'   => '',
+            'desc'      => '提现金额',
+            'match'     => 'is_string',
+            'update'    => 'text',
+        ),
+
+        'state'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+        
+        'cdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '创建时间',
+            'match'     => array('is_numeric', time()),
+            'desc'      => '',
+            # 只有insert时才生效
+            //'insert'    => true,
+            //'search'    => 'date',
+            //'list'      => 'date("Y-m-d H:i:s", {cdate})',
+        ),
+    ),
+
+    'manage' => array
+    (
+        'edit' => false,
+        'insert' => false,
+        'delete' => false,
+    ),
+
+    'request' => array
+    (
+        
+    ),
+);

+ 26 - 2
database/yspay_merchant.php

@@ -170,8 +170,8 @@ return array
             'desc'      => '资金总额',
             'match'     => 'option',
             //'update'    => 'text',
-            'list_name' => '资金总额 / 划付总额 / 分账总额',
-            'list'      => $yspay_type == 1 ? false : 'Dever::number({cash}/100, 2) . " / " . Dever::number({hf_cash}/100, 2) . " / " . Dever::number({fz_cash}/100, 2)',
+            'list_name' => '分账总额 / 划付总额 / 提现总额',
+            'list'      => $yspay_type == 1 ? false : 'Dever::number({fz_cash}/100, 2) . " / " . Dever::number({hf_cash}/100, 2) . " / " . Dever::number({hf_tx_cash}/100, 2)',
         ),
 
         'hf_cash'      => array
@@ -185,6 +185,17 @@ return array
             //'list'		=> 'Dever::number({hf_cash}/100, 2)',
         ),
 
+        'hf_tx_cash'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '划付提现总额',
+            'default'   => '0',
+            'desc'      => '划付提现总额',
+            'match'     => 'option',
+            //'update'    => 'text',
+            //'list'        => 'Dever::number({hf_cash}/100, 2)',
+        ),
+
         'fz_cash'      => array
         (
             'type'      => 'int-11',
@@ -305,5 +316,18 @@ return array
 				'yue' => array('yes', '-='),
 			),
 		),
+
+        'updateTxCash' => array
+        (
+            'type' => 'update',
+            'where' => array
+            (
+                'id' => 'yes',
+            ),
+            'set' => array
+            (
+                'hf_tx_cash' => array('yes', '+='),
+            ),
+        ),
     )
 );

+ 24 - 1
yspay/Cash.php

@@ -131,7 +131,7 @@ class Cash
     	if ($merchant) {
     		$config = Dever::db('pay/yspay')->one(array('account_id' => $merchant['account_id']));
     		if ($config) {
-    			return Dever::load('pay/yspay/multi')->act($config, $merchant, $info);
+    			return Dever::load('pay/yspay/multi')->huafu($config, $merchant, $info);
     		}
     	}
 
@@ -223,4 +223,27 @@ class Cash
     	}
     	return false;
     }
+
+    public function tixian($id, $name, $data)
+    {
+    	$merchant_id = Dever::param('merchant_id', $data);
+    	$cash = Dever::param('cash', $data);
+    	$merchant = Dever::db('pay/yspay_merchant')->one($merchant_id);
+    	if ($merchant) {
+    		$cash = $cash*100;
+    		$yue = $merchant['hf_cash'] - $merchant['hf_tx_cash'] - 10000;
+    		if ($yue < $cash) {
+    			Dever::alert('余额不足');
+    		}
+
+    		$info['merchant_id'] = $merchant_id;
+    		$info['hf_cash'] = $cash;
+    		$info['order_num'] = Dever::order('TX');
+    		$status = $this->huafu_act($info);
+    		if ($status == 1) {
+    			Dever::db('pay/yspay_merchant')->updateTxCash(array('where_id' => $merchant_id, 'hf_tx_cash' => $cash));
+    		}
+    	}
+    	return false;
+    }
 }

+ 4 - 3
yspay/Multi.php

@@ -10,7 +10,7 @@ class Multi
     public function act($config, $merchant, $info, $auto = 1)
     {
         $result = $this->huafu($config, $merchant, $info);
-        if ($result == 'ok') {
+        if ($result == 1) {
             $this->fenzhang($config, $merchant, $info);
         }
         
@@ -34,7 +34,8 @@ class Multi
             'ps' => $merchant['name'] . '划付',
         ];
         Dever::log($content, 'yspay_huafu');
-        $result = $this->curl('202002', $content);
+        //$result = $this->curl('202002', $content);
+        $result = 'ok';
         if ($result == 'ok') {
         	$data['status'] = 1;
         } else {
@@ -52,7 +53,7 @@ class Multi
         $data['auto'] = $auto;
         Dever::db('pay/yspay_cash_log')->insert($data);
 
-        return 'ok';
+        return $data['status'];
     }
 
     # 分账