rabin 1 tahun lalu
induk
melakukan
c319cca11d

+ 9 - 3
src/bao/connect/lib/Func/Base.php

@@ -25,7 +25,10 @@ class Base
                 $this->connect['set'][$v['key']] = $v['value'];
             }
         }
-        $this->info = Dever::db($this->type, 'connect')->find(array('type' => $type, 'cate_id' => $cate_id, 'connect_id' => $this->connect['id']));
+        $this->info = false;
+        if ($cate_id) {
+            $this->info = Dever::db($this->type, 'connect')->find(array('type' => $type, 'cate_id' => $cate_id, 'connect_id' => $this->connect['id']));
+        }
         if (!$this->info) {
             $this->info = Dever::db($this->type, 'connect')->find(array('type' => $type, 'connect_id' => $this->connect['id']));
             if (!$this->info) {
@@ -85,6 +88,8 @@ class Base
             echo Dever::json_encode($result);die;
         }
         //$response = '{"code":1,"info":"ok","data":{"order":"Q202401037683854738260576","account":"15810090845","status":1}}';
+        //$response = '{"status":0,"msg":"success","order_id":"24013117320741438be7f0b65a","product_id":20005,"price":104.1,"amount":100,"user_order":"C2024013193480488567061"}';
+        $response = '{"status":"0","msg":"success","balance":"100.0000","frozen_balance":"9.9800"}';
         $response = $this->response($response);
         $response['request'] = $body;
         return $response;
@@ -172,7 +177,8 @@ class Base
         }
         $msg = '';
         $status = 2;
-        if ($code = Dever::isset($response, $this->connect['response_code'])) {
+        if (isset($response[$this->connect['response_code']])) {
+            $code = $response[$this->connect['response_code']];
             $code = Dever::db('response_code', 'connect')->find(array('connect_id' => $this->connect['id'], 'value' => $code));
             if ($code && $code['type'] == 1) {
                 $status = 1;
@@ -192,7 +198,7 @@ class Base
             $temp = explode('.', $this->connect['response_data']);
             $data = isset($response[$temp[0]][$temp[1]]) ? $response[$temp[0]][$temp[1]] : (isset($response[$temp[0]]) ? $response[$temp[0]] : false);
         } else {
-            $data = $response[$this->connect['response_data']] ?? false;
+            $data = $response[$this->connect['response_data']] ?? $response;
         }
         if ($data) {
             if (method_exists($this, 'responseHandle')) {

+ 30 - 0
src/dai/channel/api/Task.php

@@ -0,0 +1,30 @@
+<?php namespace Channel\Api;
+use Dever;
+use \Dever\Helper\Redis;
+use \Dever\Helper\Str;
+class Task
+{
+    # 定时查询渠道的余额
+    public function yue()
+    {
+        $channel = Dever::db('info', 'channel')->select(array('type' => 1, 'status' => 1));
+        if ($channel) {
+            foreach ($channel as $k => $v) {
+                if ($v['connect_id']) {
+                    $connect = Dever::db('info', 'connect')->find($v['connect_id']);
+                    if ($connect) {
+                        $api = Dever::db('api', 'connect')->find(array('type' => 3, 'connect_id' => $connect['id']));
+                        if ($api) {
+                            # 获取余额
+                            $result = Dever::load('func/api', 'connect')->run(3, false, $v);
+                            if ($result['status'] == 1 && isset($result['data']['yue'])) {
+                                Dever::db('info', 'channel')->update($v['id'], array('cash' => $result['data']['yue']));
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        return 'ok';
+    }
+}

+ 6 - 0
src/dai/channel/table/info.php

@@ -54,6 +54,12 @@ return array
             'name'      => '默认折扣',
             'type'      => 'varchar(200)',
         ),
+
+        'cash'      => array
+        (
+            'type'      => 'varchar(200)',
+            'name'      => '余额',
+        ),
         
         'status' => array
         (

+ 1 - 0
src/dai/channel/table/manage/info.php

@@ -10,6 +10,7 @@ return array
             'type',
             //'connect_id',
             'host',
+            'cash',
             'status' => array
             (
                 'type' => 'switch',

+ 1 - 1
src/dai/seller/lib/Manage.php

@@ -59,7 +59,7 @@ class Manage extends Auth
     {
         if (isset($data['mobile']) && $data['mobile'] && isset($data['password']) && $data['password']) {
             $info = Dever::db('info', 'seller')->find($data['id']);
-            Dever::load('group', 'manage')->createUser('seller', $info['id'], $info['name'], $data['mobile'], $data['password']);
+            Dever::load('group', 'manage')->createUser('seller', $info['id'], $info['name'], $data['mobile'], $data['password'], true);
         }
         return $data;
     }