rabin 1 jaar geleden
bovenliggende
commit
7b7bab1537
3 gewijzigde bestanden met toevoegingen van 62 en 39 verwijderingen
  1. 28 18
      database/yspay_cash.php
  2. 28 18
      yspay/Cash.php
  3. 6 3
      yspay/Multi.php

+ 28 - 18
database/yspay_cash.php

@@ -3,20 +3,18 @@
 $status = array
 (
 	1 => '未确认',
-    2 => '待入账',
-	3 => '已入账',
-	4 => '申请提现',
-    5 => '已提现',
-    6 => '提现失败',
+    2 => '已确认',
 );
+
+$fenzhang_status = array
+(
+    1 => '未分账',
+    2 => '已分账',
+    3 => '分账失败',
+);
+
 $button = array();
 
-if (Dever::load('manage/auth')->checkFunc('pay.account', 'huafu', '资金划付')) {
-    $button = array
-    (
-        '资金划付' => array('oper', 'pay/yspay/cash.huafu_commit?account_id=' . Dever::input('search_option_account_id') . '&merchant_id=' . Dever::input('search_option_merchant_id')),
-    );
-}
 return array
 (
     # 表名
@@ -153,7 +151,7 @@ return array
         'rdate'     => array
         (
             'type'      => 'int-11',
-            'name'      => '账时间',
+            'name'      => '账时间',
             'default'   => '',
             'match'     => 'is_numeric',
             'desc'      => '',
@@ -169,23 +167,35 @@ return array
             'default'   => '',
             'match'     => 'is_numeric',
             'desc'      => '',
-            'search'    => 'date',
-            'list'      => '"{tdate}" ? date("Y-m-d H:i", \'{tdate}\') : "-"',
-            'list_order' => 101,
+            //'search'    => 'date',
+            //'list'      => '"{tdate}" ? date("Y-m-d H:i", \'{tdate}\') : "-"',
+            //'list_order' => 101,
         ),
 
         'status'        => array
         (
             'type'      => 'tinyint-1',
-            'name'      => '状态',
+            'name'      => '订单状态',
             'default'   => '1',
-            'desc'      => '状态',
+            'desc'      => '订单状态',
             'match'     => 'is_numeric',
             'option'    => $status,
             'search'    => 'select',
             'list'      => true,
         ),
 
+        'fenzhang_status'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '分账状态',
+            'default'   => '1',
+            'desc'      => '分账状态',
+            'match'     => 'is_numeric',
+            'option'    => $fenzhang_status,
+            'search'    => 'select',
+            'list'      => true,
+        ),
+
         'state'     => array
         (
             'type'      => 'tinyint-1',
@@ -198,7 +208,7 @@ return array
         'cdate'     => array
         (
             'type'      => 'int-11',
-            'name'      => '创建时间',
+            'name'      => '下单时间',
             'match'     => array('is_numeric', time()),
             'desc'      => '',
             # 只有insert时才生效

+ 28 - 18
yspay/Cash.php

@@ -48,31 +48,28 @@ class Cash
     		$merchant = Dever::db('pay/yspay_merchant')->one($info['merchant_id']);
     		if ($merchant) {
     			$update = array('status' => $status, 'where_id' => $info['id']);
-	    		if ($status == 3) {
-	    			# 开始划付
-	    			$state = $this->huafu_act($info);
-	    			if ($state != 'ok') {
-	    				return false;
+	    		if ($status == 2) {
+	    			if ($amount && $amount > 0 && $info['ycash'] != $amount) {
+		        		$this->getCash($amount, $merchant, $update, $fenzhang);
 	    			}
-	    			$update['rdate'] = time();
-	    		} elseif ($status == 4) {
-	    			# 开始提现
-	    			$state = $this->tixian_act($info);
-	    			if ($state != 'ok') {
-	    				return false;
-	    			}
-	    			$update['tdate'] = time();
-	    		} elseif ($status == 2 && $amount && $amount > 0 && $info['ycash'] != $amount) {
-	    			# 待入账 可以修改金额
-		        	$this->getCash($amount, $merchant, $update, $fenzhang);
 		        }
 	    		$state = Dever::db('pay/yspay_cash')->update($update);
 	    		if ($state) {
-	    			if ($status == 3) {
-	    				$total = Dever::db('pay/yspay_cash')->getTotal(array('status' => 3, 'merchant_id' => $info['merchant_id']));
+	    			if ($status == 2) {
+	    				$total = Dever::db('pay/yspay_cash')->getTotal(array('status' => 2, 'merchant_id' => $info['merchant_id']));
 	    				if ($total) {
 	    					Dever::db('pay/yspay_merchant')->update(array('where_id' => $info['merchant_id'], 'cash' => $total['cash'], 'hf_cash' => $total['hf_cash'], 'fz_cash' => $total['fz_cash']));
 	    				}
+	    				$info = Dever::db('pay/yspay_cash')->find(array('id' => $info['id'], 'clear' => true));
+	    				$state = $this->fenzhang_act($info);
+	    				$update = array();
+	    				$update['where_id'] = $info['id'];
+	    				if ($state == 1) {
+	    					$update['fenzhang_status'] = 2;
+	    				} else {
+	    					$update['fenzhang_status'] = 3;
+	    				}
+	    				Dever::db('pay/yspay_cash')->update($update);
 	    			}
 	    			return $state;
 	    		}
@@ -141,6 +138,19 @@ class Cash
     	return false;
     }
 
+    private function fenzhang_act($info)
+    {
+    	$merchant = Dever::db('pay/yspay_merchant')->one($info['merchant_id']);
+    	if ($merchant) {
+    		$config = Dever::db('pay/yspay')->one(array('account_id' => $merchant['account_id']));
+    		if ($config) {
+    			return Dever::load('pay/yspay/multi')->fenzhang($config, $merchant, $info);
+    		}
+    	}
+
+    	return false;
+    }
+
     private function tixian_act($info)
     {
     	$merchant = Dever::db('pay/yspay_merchant')->one($info['merchant_id']);

+ 6 - 3
yspay/Multi.php

@@ -6,6 +6,7 @@ class Multi
 {
 	static $host = 'https://im.chinaums.com/channel/Business/UnifyMulti/';
 
+    /*
     public function act($config, $merchant, $info, $auto = 1)
     {
         $result = $this->huafu($config, $merchant, $info);
@@ -14,10 +15,10 @@ class Multi
         }
         
         return $result;
-    }
+    }*/
 
 	# 划付
-    protected function huafu($config, $merchant, $info, $auto = 1)
+    public function huafu($config, $merchant, $info, $auto = 1)
     {
     	$this->config = $config;
 
@@ -55,7 +56,7 @@ class Multi
     }
 
     # 分账
-    protected function fenzhang($config, $merchant, $info, $auto = 1)
+    public function fenzhang($config, $merchant, $info, $auto = 1)
     {
     	$this->config = $config;
 
@@ -92,6 +93,8 @@ class Multi
         $data['desc'] = $content['ps'];
         $data['auto'] = $auto;
         Dever::db('pay/yspay_cash_log')->insert($data);
+
+        return $data['status'];
     }
 
     # 查询余额