rabin 2 years ago
parent
commit
1eccf1849c
4 changed files with 77 additions and 10 deletions
  1. 10 4
      app/mshop/lib/Buy.php
  2. 49 0
      app/shop/lib/Cron.php
  3. 17 5
      app/shop/src/Yspay.php
  4. 1 1
      service/option/lib/Import.php

+ 10 - 4
app/mshop/lib/Buy.php

@@ -1681,7 +1681,7 @@ class Buy
 
             $shop = Dever::db('shop/info')->find($info['type_id']);
 
-            if ($audit == 2) {
+            if ($audit == 2 && $goods) {
                 Dever::db('shop/buy_order')->update(array('where_id' => $info['id'], 'audit' => $audit, 'audit_desc' => $audit_text));
                 # 成功
                 if (strstr($info['order_num'], '_')) {
@@ -1723,10 +1723,16 @@ class Buy
 
                 $this->audit_action($data, $other, $info, $shop, 1);
             } else {
-                Dever::db('shop/buy_order')->update(array('where_id' => $info['id'], 'audit' => $audit, 'audit_desc' => $audit_text));
+                
                 # 退款
-                $shop = Dever::db('shop/info')->find($info['type_id']);
-                Dever::load('shop/lib/refund')->set('buy')->apply(1, $shop['id'], $id, false, 3, 0, '未通过审核');
+                if ($goods) {
+                    Dever::db('shop/buy_order')->update(array('where_id' => $info['id'], 'audit' => $audit, 'audit_desc' => $audit_text));
+
+                    $shop = Dever::db('shop/info')->find($info['type_id']);
+                    Dever::load('shop/lib/refund')->set('buy')->apply(1, $shop['id'], $id, false, 3, 0, '未通过审核');
+                } else {
+                    Dever::db('shop/buy_order')->update(array('where_id' => $info['id'], 'audit' => $audit, 'audit_desc' => $audit_text, 'status' => 7));
+                }
             }
         }
 

+ 49 - 0
app/shop/lib/Cron.php

@@ -6,6 +6,55 @@ use Dever;
 
 class Cron
 {
+    # 定时获取银联提现信息
+    public function yspay_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;
+        }
+        $shop_id = Dever::input('shop_id');
+        if ($shop_id) {
+            $where['id'] = $shop_id;
+        }
+        $test = Dever::input('test');
+        $shop = Dever::db('shop/info')->select($where);
+        foreach ($shop as $k => $v) {
+            if ($v['mid']) {
+                $data = Dever::load('shop/yspay')->record_action($v['mid'], $start, $end);
+                if ($data) {
+                    if ($test == 1) {
+                        print_r($data);die;
+                    }
+                    foreach ($data as $k1 => $v1) {
+                        $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'];
+
+                        $info = Dever::db('shop/yspay_tixian')->one($update);
+                        if (!$info) {
+                            Dever::db('shop/yspay_tixian')->insert($update);
+                        }
+                    }
+                }
+            }
+        }
+        return 'ok';
+    }
+
     # 定时更新店铺经纬度
     public function geo_api()
     {

+ 17 - 5
app/shop/src/Yspay.php

@@ -46,6 +46,14 @@ bfdc6069eaeb89ec0c4295f5230c13820a578f13ef0086d15a720ea2712ff2040f3ae09a8d3b8f12
         $sid = Dever::input('sid');
         $start = Dever::input('start');
         $end = Dever::input('end');
+        $log = $this->record_action($sid, $start, $end);
+
+        return $log;
+    }
+
+    public function record_action($sid, $start, $end)
+    {
+        $class = new Chinaums();
         $log = $class->record($sid, $start, $end);
 
         return $log;
@@ -163,7 +171,7 @@ class Chinaums
     }
 
     # 查询提现记录
-    public function record($mid, $start, $end)
+    public function record($mid, $start, $end, $page = '1')
     {
         $url = $this->host() . 'uisouterfront/withdraw/qryWithDrawLog';
 
@@ -173,7 +181,7 @@ class Chinaums
             'sysId' => $this->sys_id,
             'mchntNo' => $mid,
             'timestamp' => date('YmdHis'),
-            'page' => '1',
+            'page' =>  '"' . $page . '"',
             'beginDate' => $start,
             'endDate' => $end,
         ];
@@ -182,9 +190,13 @@ class Chinaums
         $result = Dever::curl($url, $body, 'post');
         $result = Dever::json_decode($result);
         $decryptData = $this->privateDecrypt($result['result']);
-        print_r($decryptData);die;
-
-        return 0;
+        if (isset($decryptData['recordList']) && $decryptData['recordList']) {
+            if ($page < $decryptData['totalPage']) {
+                return $this->record($mid, $start, $end, $page+1);
+            }
+            return Dever::json_decode($decryptData['recordList']);
+        }
+        return array();
     }
 
     # 提现

+ 1 - 1
service/option/lib/Import.php

@@ -11,7 +11,7 @@ class Import
 {
     private $path = '/www/churen/data/';
     //private $path = '/data/www/churen/data/';
-    private $name = 'qiquan_2022_09_14.xlsx';
+    private $name = 'qiquan_2022_09_28.xlsx';
     # 导入账户
     public function get_api()
     {