rabin před 2 roky
rodič
revize
93d7a760ee

+ 18 - 0
app/shop/database/info.php

@@ -841,6 +841,24 @@ return array
             'col' => $col . '|id',
         ),
 
+        'likeOne' => array
+        (
+            # 匹配的正则或函数 选填项
+            'option' => array
+            (
+                'name' => array('yes', 'like'),
+                'sid' => array('yes', 'like'),
+                'mid' => array('yes', 'like'),
+                'type' => array('yes', 'like'),
+                'id' => 'yes',
+                'status' => 1,
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'order' => array('reorder' => 'desc', 'id' => 'desc'),
+            'col' => $col,
+        ),
+
         'getAll' => array
         (
             # 匹配的正则或函数 选填项

+ 147 - 0
app/shop/database/yspay_account.php

@@ -0,0 +1,147 @@
+<?php
+
+return array
+(
+    # 表名
+    'name' => 'yspay_account',
+    # 显示给用户看的名称
+    'lang' => '银联账户信息',
+    'order' => -200,
+    'menu' => false,
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'update'    => 'hidden',
+            //'list'        => true,
+        ),
+
+        'shop_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '门店名称',
+            'default'   => '',
+            'desc'      => '所属门店',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            'search'    => array
+            (
+                'api' => 'shop/info-like',
+                'col' => 'name',
+                'result' => 'id',
+            ),
+            'list'		=> 'Dever::load("shop/info-one#name", {shop_id})',
+        ),
+
+        'mid'      => array
+        (
+            'type'      => 'varchar-50',
+            'name'      => '分账商户号',
+            'default'   => '',
+            'desc'      => '分账商户号',
+            'match'     => 'option',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'		=> true,
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '余额',
+            'default'   => '0',
+            'desc'      => '余额',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'      => 'round({cash}/100, 2)',
+        ),
+
+        'tx_cash'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '提现总金额',
+            'default'   => '0',
+            'desc'      => '提现总金额',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'		=> 'round({tx_cash}/100, 2)',
+        ),
+
+        'sdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '更新时间',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '',
+            'search'    => 'date',
+            'list'      => '"{sdate}" ? date("Y-m-d H:i", \'{sdate}\') : "-"',
+            'order'		=> 'desc',
+        ),
+
+        '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
+    (
+        'tx_inc' => array
+		(
+			'type' => 'update',
+			'where' => array
+			(
+				'id' => 'yes',
+			),
+			'set' => array
+			(
+				'tx_cash' => array('yes', '+='),
+			),
+		),
+
+		'dec' => array
+		(
+			'type' => 'update',
+			'where' => array
+			(
+				'id' => 'yes',
+			),
+			'set' => array
+			(
+				'cash' => array('yes', '-='),
+			),
+		),
+    ),
+);

+ 193 - 0
app/shop/database/yspay_tixian.php

@@ -0,0 +1,193 @@
+<?php
+$status = array
+(
+    4 => array('name' => '提现完成', 'style' => 'font-weight:bold;color:green'),
+    5 => array('name' => '提现失败', 'style' => 'font-weight:bold;color:#CD3700'),
+);
+
+$mid = Dever::input('search_fulltext_mid');
+$shop_name = Dever::input('search_api_shop_id');
+$shop = array();
+if ($shop_name) {
+    $shop = Dever::db('shop/info')->likeOne(array('name' => $shop_name));
+} elseif ($mid) {
+    $shop = Dever::db('shop/info')->likeOne(array('mid' => $mid));
+}
+$button = array();
+$info = '';
+if ($shop) {
+    # 申请提现和查看提现日志
+    $account = Dever::db('shop/yspay_account')->find(array('shop_id' => $shop['id']));
+    $info = $shop['name'] . ',当前余额:' . round($account['cash']/100, 2) . '元,总提现金额:' . round($account['tx_cash']/100, 2) . '元';
+
+    if ($shop['type'] == 10) {
+        $button['手动申请提现'] = array('fast', 1,'yspay_tixian_apply&shop_id=' . $shop['id']);
+        $button['提现申请记录'] = array('location', 'l=project/database/list&project=shop&table=yspay_tixian_log&search_option_state=1&search_option_shop_id='.$shop['id'].'&oper_table=yspay_tixian&search_fulltext_mid=' . $mid . '&search_api_shop_id=' . $shop_name);
+    }
+}
+
+return array
+(
+    # 表名
+    'name' => 'yspay_tixian',
+    # 显示给用户看的名称
+    'lang' => '银联提现列表',
+    'order' => -200,
+    'info' => $info,
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'update'    => 'hidden',
+            //'list'        => true,
+        ),
+
+        'shop_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '门店名称',
+            'default'   => '',
+            'desc'      => '所属门店',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            'search'    => array
+            (
+                'api' => 'shop/info-like',
+                'col' => 'name',
+                'result' => 'id',
+            ),
+            'list'		=> 'Dever::load("shop/info-one#name", {shop_id})',
+        ),
+
+        'mid'      => array
+        (
+            'type'      => 'varchar-50',
+            'name'      => '分账商户号',
+            'default'   => '',
+            'desc'      => '分账商户号',
+            'match'     => 'option',
+            'update'    => 'text',
+            'search'    => 'fulltext',
+            'list'		=> true,
+        ),
+
+        'order_num'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '订单号',
+            'default'   => '',
+            'desc'      => '订单号',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'list'		=> true,
+        ),
+
+        'type'      => array
+        (
+            'type'      => 'varchar-10',
+            'name'      => '类型',
+            'default'   => '',
+            'desc'      => '类型',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '提现金额',
+            'default'   => '0',
+            'desc'      => '提现金额',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'      => 'round({cash}/100, 2)',
+        ),
+
+        'cardNo'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '到账银行卡号',
+            'default'   => '',
+            'desc'      => '到账银行卡号',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            //'list'		=> true,
+        ),
+
+        'tdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '提现到账时间',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '',
+            'search'    => 'date',
+            'list'      => '"{tdate}" ? date("Y-m-d H:i", \'{tdate}\') : "-"',
+            'order'		=> 'desc',
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '提现状态',
+            'default'   => '1',
+            'desc'      => '提现状态',
+            'match'     => 'is_numeric',
+            'option'    => $status,
+            'search'    => 'select',
+            'list'      => true,
+        ),
+
+        '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,
+        'button' => $button,
+    ),
+
+    'request' => array
+    (
+        'getTotal' => array
+        (
+            'option' => array
+            (
+                'shop_id' => 'yes',
+                'status' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'one',
+            'col' => 'sum(cash) as cash',
+        ),
+    ),
+);

+ 111 - 0
app/shop/database/yspay_tixian_apply.php

@@ -0,0 +1,111 @@
+<?php
+
+return array
+(
+    # 表名
+    'name' => 'yspay_tixian_apply',
+    # 显示给用户看的名称
+    'lang' => '申请提现',
+    'order' => -200,
+    'menu' => false,
+    'start' => array
+    (
+        'insert' => 'shop/lib/yspay.insert',
+    ),
+    'end' => array
+    (
+    	'insert' => 'shop/lib/yspay.update', 
+    	'update' => 'shop/lib/yspay.update',
+    ),
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'update'    => 'hidden',
+            //'list'        => true,
+        ),
+
+        'shop_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '门店名称',
+            'default'   => '',
+            'desc'      => '所属门店',
+            'match'     => 'is_numeric',
+            'update'    => 'hidden',
+            'value'		=> Dever::input('shop_id'),
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '提现金额',
+            'default'   => '0',
+            'desc'      => '提现金额',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'      => 'round({cash}/100, 2)',
+        ),
+
+        'desc'      => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '备注',
+            'default'   => '',
+            'desc'      => '备注',
+            'match'     => 'is_numeric',
+            'update'    => 'textarea',
+            'list'      => true,
+        ),
+
+        '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
+    (
+        'getAll' => array
+        (
+            'option' => array
+            (
+                'shop_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'col' => '*|store_id',
+        ),
+    ),
+);

+ 195 - 0
app/shop/database/yspay_tixian_log.php

@@ -0,0 +1,195 @@
+<?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'),
+);
+
+$mtype = array
+(
+	1 => '自动提现',
+	2 => '手动提现',
+);
+return array
+(
+    # 表名
+    'name' => 'yspay_tixian_log',
+    # 显示给用户看的名称
+    'lang' => '银联提现日志列表',
+    'order' => -200,
+    'menu' => false,
+    # 数据结构
+    'struct' => array
+    (
+    
+        'id'        => array
+        (
+            'type'      => 'int-11',
+            'name'      => 'ID',
+            'default'   => '',
+            'desc'      => '',
+            'match'     => 'is_numeric',
+            'search'    => 'order',
+            'update'    => 'hidden',
+            //'list'        => true,
+        ),
+
+        'shop_id'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '门店名称',
+            'default'   => '',
+            'desc'      => '所属门店',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            'searchs'    => array
+            (
+                'api' => 'shop/info-like',
+                'col' => 'name',
+                'result' => 'id',
+            ),
+            'list'		=> 'Dever::load("shop/info-one#name", {shop_id})',
+        ),
+
+        'mid'      => array
+        (
+            'type'      => 'varchar-50',
+            'name'      => '分账商户号',
+            'default'   => '',
+            'desc'      => '分账商户号',
+            'match'     => 'option',
+            'update'    => 'text',
+            'searchs'    => 'fulltext',
+            'list'		=> true,
+        ),
+
+        'order_num'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '订单号',
+            'default'   => '',
+            'desc'      => '订单号',
+            'match'     => 'is_string',
+            'update'    => 'text',
+            'list'		=> true,
+        ),
+
+        'type'      => array
+        (
+            'type'      => 'varchar-10',
+            'name'      => '类型',
+            'default'   => '',
+            'desc'      => '类型',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+        ),
+
+        'cash'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '提现金额',
+            'default'   => '0',
+            'desc'      => '提现金额',
+            'match'     => 'option',
+            'update'    => 'text',
+            'list'      => 'round({cash}/100, 2)',
+        ),
+
+        'tdate'     => array
+        (
+            'type'      => 'int-11',
+            'name'      => '提现时间',
+            'default'   => '',
+            'match'     => 'is_numeric',
+            'desc'      => '',
+            'search'    => 'date',
+            'list'      => '"{tdate}" ? date("Y-m-d H:i", \'{tdate}\') : "-"',
+            'order'		=> 'desc',
+        ),
+
+        'mtype'      => array
+        (
+            'type'      => 'int-11',
+            'name'      => '提现类型',
+            'default'   => '1',
+            'desc'      => '提现类型',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+        ),
+
+        'status'        => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '提现状态',
+            'default'   => '1',
+            'desc'      => '提现状态',
+            'match'     => 'is_numeric',
+            'option'    => $status,
+            'search'    => 'select',
+            'list'      => true,
+        ),
+
+        'desc'      => array
+        (
+            'type'      => 'varchar-800',
+            'name'      => '备注',
+            'default'   => '-',
+            'desc'      => '备注',
+            'match'     => 'is_numeric',
+            'update'    => 'text',
+            'list'      => true,
+        ),
+
+        'response'        => array
+        (
+            'type'      => 'text-255',
+            'name'      => '回调响应数据',
+            'default'   => '',
+            'desc'      => '回调响应数据',
+            'match'     => 'is_string',
+        ),
+
+        '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
+    (
+        'getAll' => array
+        (
+            'option' => array
+            (
+                'shop_id' => 'yes',
+                'state' => 1,
+            ),
+            'type' => 'all',
+            'col' => '*|store_id',
+        ),
+    ),
+);

+ 75 - 3
app/shop/lib/Cron.php

@@ -6,6 +6,51 @@ use Dever;
 
 class Cron
 {
+    # 定时更新银联账户余额信息
+    public function yspay_account_api()
+    {
+        # 获取有银联商户号的门店
+        $where = array();
+        $mid = Dever::input('mid');
+        if ($mid) {
+            $where['mid'] = $mid;
+        }
+        $shop_id = Dever::input('shop_id');
+        if ($shop_id) {
+            $where['id'] = $shop_id;
+        }
+        $test = Dever::input('test');
+        $shop = Dever::db('shop/info')->select($where);
+        if (!$shop) {
+            return 'error';
+        }
+        foreach ($shop as $k => $v) {
+            if ($v['type'] == 10) {
+                $v['mid'] = '89810007372106N';
+            }
+            if ($v['mid']) {
+                $data = Dever::load('shop/yspay')->query_action($v['mid']);
+                if ($test == 1) {
+                    print_r($data);die;
+                }
+                $update = array();
+                $update['shop_id'] = $v['id'];
+                $update['clear'] = true;
+                $info = Dever::db('shop/yspay_account')->one($update);
+                $update['cash'] = $data;
+                $update['sdate'] = time();
+                $update['mid'] = $v['mid'];
+                if (!$info) {
+                    Dever::db('shop/yspay_account')->insert($update);
+                } else {
+                    $update['where_id'] = $info['id'];
+                    Dever::db('shop/yspay_account')->update($update);
+                }
+            }
+        }
+        return 'ok';
+    }
+
     # 定时获取银联提现信息
     public function yspay_tixian_api()
     {
@@ -26,7 +71,13 @@ class Cron
         }
         $test = Dever::input('test');
         $shop = Dever::db('shop/info')->select($where);
+        if (!$shop) {
+            return 'error';
+        }
         foreach ($shop as $k => $v) {
+            if ($v['type'] == 10) {
+                $v['mid'] = '89810007372106N';
+            }
             if ($v['mid']) {
                 $data = Dever::load('shop/yspay')->record_action($v['mid'], $start, $end);
                 if ($data) {
@@ -37,16 +88,35 @@ class Cron
                         $update = array();
                         $update['shop_id'] = $v['id'];
                         $update['type'] = $v1['trxTypeDtl'];
-                        $update['cash'] = round($v1['transAmt']/100, 2);
                         $update['tdate'] = Dever::maketime($v1['trxTime']);
                         $update['mid'] = $v1['mchntNo'];
                         $update['cardNo'] = $v1['cardNo'];
                         $update['order_num'] = $v1['sysOrderId'];
                         $update['status'] = $v1['status'];
-
+                        $update['clear'] = true;
                         $info = Dever::db('shop/yspay_tixian')->one($update);
+                        $update['cash'] = $v1['transAmt'];
                         if (!$info) {
                             Dever::db('shop/yspay_tixian')->insert($update);
+                        } else {
+                            $update['where_id'] = $info['id'];
+                            Dever::db('shop/yspay_tixian')->update($update);
+                        }
+
+                        $account_data = array();
+                        $account_data['shop_id'] = $v['id'];
+                        $account_data['clear'] = true;
+                        $account = Dever::db('shop/yspay_account')->one($account_data);
+                        $total = Dever::db('shop/yspay_tixian')->getTotal(array('shop_id' => $v['id'], 'status' => 4));
+                        if ($total) {
+                            $account_data['tx_cash'] = $total['cash'];
+                        }
+                        if (!$account) {
+                            $account_data['mid'] = $v1['mchntNo'];
+                            Dever::db('shop/yspay_account')->insert($account_data);
+                        } else {
+                            $account_data['where_id'] = $account['id'];
+                            Dever::db('shop/yspay_account')->update($account_data);
                         }
                     }
                 }
@@ -146,7 +216,9 @@ class Cron
             }
             if ($v['price'] > 0) {
                 $cash = $v['price'] * 100;//之后还要加上礼品卡的钱
-                Dever::load('shop/yspay')->action($shop['mid'], $v['order_num'], $v['id'], 2, $cash);
+                $v['desc'] = '系统自动提现';
+                $v['mtype'] = 1;
+                Dever::load('shop/yspay')->action($shop['mid'], $v['order_num'], $v['id'], 2, $cash, $v);
                 sleep(1);
             } else {
                 Dever::db('shop/sell_order')->update(array('where_id' => $v['id'], 'withdraw' => 2));

+ 62 - 0
app/shop/lib/Yspay.php

@@ -0,0 +1,62 @@
+<?php
+
+namespace Shop\Lib;
+
+use Dever;
+
+class Yspay
+{
+    #生成订单号
+    public function getOrderId()
+    {
+        $where['order_num'] = Dever::order('SD');
+        $where['clear'] = true;
+        $state = Dever::db('shop/yspay_tixian_log')->one($where);
+        if (!$state) {
+            return $where['order_num'];
+        } else {
+            return $this->getOrderId();
+        }
+    }
+
+    public function insert($id, $name, $data)
+    {
+        $shop_id = Dever::param('shop_id',$data);
+        $cash = Dever::param('cash',$data);
+        $desc = Dever::param('desc',$data);
+        $account = Dever::db('shop/yspay_account')->one(array('shop_id' => $shop_id));
+        if (!$account) {
+        	Dever::alert('账户不存在');
+        }
+        if ($cash <= 0) {
+        	Dever::alert('提现金额不能小于0');
+        }
+        $cash = $cash * 100;
+        if ($cash > $account['cash']) {
+        	Dever::alert('账户余额不足');
+        }
+    }
+
+    public function update($id, $name, $data)
+    {
+    	$shop_id = Dever::param('shop_id',$data);
+        $cash = Dever::param('cash',$data);
+        $desc = Dever::param('desc',$data);
+
+        $account = Dever::db('shop/yspay_account')->one(array('shop_id' => $shop_id));
+        if (!$account) {
+        	Dever::alert('账户不存在');
+        }
+        if ($cash <= 0) {
+        	Dever::alert('提现金额不能小于0');
+        }
+        $cash = $cash * 100;
+        if ($cash > $account['cash']) {
+        	Dever::alert('账户余额不足');
+        }
+        $order_num = $this->getOrderId();
+        $account['desc'] = $desc;
+        $account['mtype'] = 2;
+        Dever::load('shop/yspay')->action($account['mid'], $order_num, -1, 2, $cash, $account);
+    }
+}

+ 40 - 15
app/shop/src/Yspay.php

@@ -28,20 +28,22 @@ bfdc6069eaeb89ec0c4295f5230c13820a578f13ef0086d15a720ea2712ff2040f3ae09a8d3b8f12
 
 	public function query()
 	{
-		
-		$class = new Chinaums();
-
 		# 查看当前余额
         $sid = Dever::input('sid');
-		$cash = $class->query($sid);
+		$cash = $this->query_action($sid);
 		return $cash;
 	}
 
-    public function record()
+    public function query_action($sid)
     {
-        
         $class = new Chinaums();
+        $data = $class->query($sid);
+
+        return $data;
+    }
 
+    public function record()
+    {
         # 查看提现记录
         $sid = Dever::input('sid');
         $start = Dever::input('start');
@@ -68,13 +70,13 @@ bfdc6069eaeb89ec0c4295f5230c13820a578f13ef0086d15a720ea2712ff2040f3ae09a8d3b8f12
 		return $result;
 	}
 
-	public function action($mid, $order, $order_id, $type, $cash)
+	public function action($mid, $order, $order_id, $type, $cash, $order_info = array())
 	{
 		$class = new Chinaums();
 
 		$notify = Dever::url('yspay.notify?order=' . $order, 'shop');
 
-		$result = $class->act($mid, $order, $order_id, $type, $cash, $notify);
+		$result = $class->act($mid, $order, $order_id, $type, $cash, $notify, $order_info);
 
 		return $result;
 	}
@@ -97,8 +99,17 @@ bfdc6069eaeb89ec0c4295f5230c13820a578f13ef0086d15a720ea2712ff2040f3ae09a8d3b8f12
 
 			$content = $class->privateDecrypt($content);
 
+            $log = Dever::db('shop/yspay_tixian_log')->one(array('order_num' => $order, 'shop_id' => $order['shop_id']));
 			if ($content && isset($content['responseCode']) && ($content['responseCode'] == '000000' || $content['responseCode'] == '000001')) {
 				Dever::db('shop/sell_order')->update(array('where_id' => $order['id'], 'withdraw' => 2));
+                if ($log) {
+                    Dever::db('shop/yspay_tixian_log')->update(array('where_id' => $log['id'], 'status' => 2, 'response' => Dever::json_encode($content)));
+
+                    $account = Dever::db('shop/yspay_account')->one(array('shop_id' => $log['shop_id']));
+                    if ($account) {
+                        Dever::db('shop/yspay_account')->dec(array('where_id' => $account['id'], 'set_cash' => $log['cash']));
+                    }
+                }
                 echo 'SUCCESS';die;
 			} else {
 				Dever::load('shop/lib/cron')->yspayOne($order);
@@ -159,8 +170,6 @@ class Chinaums
         $result = Dever::curl($url, $body, 'post');
 
         $decryptData = $this->privateDecrypt($result);
-        print_r($decryptData);die;
-
         if (isset($decryptData['tzWithdrawAmtPublic'])) {
         	return $decryptData['tzWithdrawAmtPublic'];
         } elseif (isset($decryptData['t0WithdrawAmtPublic'])) {
@@ -181,7 +190,7 @@ class Chinaums
             'sysId' => $this->sys_id,
             'mchntNo' => $mid,
             'timestamp' => date('YmdHis'),
-            'page' =>  '"' . $page . '"',
+            'page' =>  (string) $page,
             'beginDate' => $start,
             'endDate' => $end,
         ];
@@ -191,16 +200,22 @@ class Chinaums
         $result = Dever::json_decode($result);
         $decryptData = $this->privateDecrypt($result['result']);
         if (isset($decryptData['recordList']) && $decryptData['recordList']) {
-            if ($page < $decryptData['totalPage']) {
-                return $this->record($mid, $start, $end, $page+1);
+            $data = Dever::json_decode($decryptData['recordList']);
+            if ($page == 1 && isset($decryptData['totalPage']) && $decryptData['totalPage'] > 1) {
+                for ($i = 2; $i <= $decryptData['totalPage']; $i++) {
+                    $temp = $this->record($mid, $start, $end, $i);
+                    if ($temp) {
+                        $data = array_merge($data, $temp);
+                    }
+                }
             }
-            return Dever::json_decode($decryptData['recordList']);
+            return $data;
         }
         return array();
     }
 
     # 提现
-    public function act($mid, $order, $order_id, $type = 2, $cash = 1, $notify = '')
+    public function act($mid, $order, $order_id, $type = 2, $cash = 1, $notify = '', $order_info = array())
     {
     	$url = $this->host() . 'uisouterfront/withdrawback/process';
 
@@ -219,6 +234,16 @@ class Chinaums
             'withdrawAmt' => $cash,
         ];
         Dever::log($content, 'yspay_act');
+        $data['shop_id'] = $order_info['shop_id'];
+        $data['mid'] = $mid;
+        $data['order_num'] = $order;
+        $data['type'] = $type;
+        $data['cash'] = $cash;
+        $data['tdate'] = time();
+        $data['status'] = 1;
+        $data['desc'] = $order_info['desc'];
+        $data['mtype'] = $order_info['mtype'];
+        Dever::db('shop/yspay_tixian_log')->insert($data);
         //设置签名并加密
         $body['content'] = $this->createSignature($content);
 

+ 1 - 1
service/agent/lib/Manage.php

@@ -1608,7 +1608,7 @@ class Manage
                 }
                 $v['title_name'] = '';
                 $member = Dever::db('agent/member')->find($v['mid']);
-                if ($member['title_id']) {
+                if ($member && $member['title_id']) {
                     $title = Dever::db('setting/title')->getDataByIds(array('id' => $member['title_id']));
                     if($title) {
                         $v['title_name'] = array();