rabin 1 vuosi sitten
vanhempi
commit
92641cc915
1 muutettua tiedostoa jossa 91 lisäystä ja 0 poistoa
  1. 91 0
      yspay/Cron.php

+ 91 - 0
yspay/Cron.php

@@ -0,0 +1,91 @@
+<?php namespace Pay\Yspay;
+
+use Dever;
+
+class Cron
+{
+    # 定时更新银联账户余额信息
+    public function account_api()
+    {
+        # 获取有银联商户号的门店
+        $where = array();
+        $mid = Dever::input('mid');
+        if ($mid) {
+            $where['mid'] = $mid;
+        }
+        $test = Dever::input('test');
+        $merchant = Dever::db('pay/yspay_merchant')->select($where);
+        if (!$merchant) {
+            return 'error';
+        }
+        foreach ($merchant as $k => $v) {
+            if ($v['mid']) {
+                $data = Dever::load('pay/yspay/account')->query($v['mid']);
+                if ($test == 1) {
+                    print_r($data);die;
+                }
+                $update['where_id'] = $v['id'];
+                $update['yue'] = $data;
+                Dever::db('pay/yspay_merchant')->update($update);
+            }
+        }
+        return 'ok';
+    }
+
+    # 定时获取银联提现信息
+    public function tixian_api()
+    {
+        $num = Dever::input('num', 1);
+        
+        $start = Dever::input('start', date('Ymd', strtotime('-'.$num.' day')));
+        $end = Dever::input('end', date('Ymd'));
+
+        # 获取有银联商户号的门店
+        $where = array();
+        $mid = Dever::input('mid');
+        if ($mid) {
+            $where['mid'] = $mid;
+        }
+        $test = Dever::input('test');
+        $merchant = Dever::db('pay/yspay_merchant')->select($where);
+        if (!$merchant) {
+            return 'error';
+        }
+        foreach ($merchant as $k => $v) {
+            if ($v['mid']) {
+                $data = Dever::load('pay/yspay/account')->record($v['mid'], $start, $end);
+                if ($data) {
+                    if ($test == 1) {
+                        print_r($data);die;
+                    }
+                    foreach ($data as $k1 => $v1) {
+                        $update = array();
+                        $update['merchant_id'] = $v['id'];
+                        $update['type'] = $v1['trxTypeDtl'];
+                        $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('pay/yspay_tixian')->one($update);
+                        $update['cash'] = $v1['transAmt'];
+                        if (!$info) {
+                            Dever::db('pay/yspay_tixian')->insert($update);
+                        } else {
+                            $update['where_id'] = $info['id'];
+                            Dever::db('pay/yspay_tixian')->update($update);
+                        }
+                        $total = Dever::db('pay/yspay_tixian')->getTotal(array('shop_id' => $v['id'], 'status' => 4));
+                        if ($total) {
+                            $account_data['tx_cash'] = $total['cash'];
+                            $account_data['where_id'] = $v['id'];
+                            Dever::db('pay/yspay_merchant')->update($account_data);
+                        }
+                    }
+                }
+            }
+        }
+        return 'ok';
+    }
+}