Apijd.php
3.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
/**
* tpshop
* ============================================================================
* 版权所有 2015-2027 深圳搜豹网络科技有限公司,并保留所有权利。
* 网站地址: http://www.tp-shop.cn
* ----------------------------------------------------------------------------
* 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用 .
* 不允许对程序代码以任何形式任何目的的再发布。
* ============================================================================
* Author: JY
* Date: 2015-09-23
*/
namespace app\home\controller;
use app\home\logic\UsersLogic;
use think\Db;
use think\Exception;
use think\Session;
use think\Controller;
use think\Verify;
use think\Cookie;
use think\Page;
class Apijd extends Controller
{
public function _initialize()
{
Session::start();
}
/*更新第三方平台token*/
public function callback()
{
$postStr = file_get_contents("php://input");
if (empty($postStr)) {
$postStr = isset($GLOBALS["HTTP_RAW_POST_DATA"]) ? $GLOBALS["HTTP_RAW_POST_DATA"] : "";
}
$getcode=I('code');
$gettoken=I('token');
// $gettoken="{\"token\":\"08887fc3-5270-494a-95bb-e3702a7e29cd\",\"expires_in\":\"31104000\",\"time\":\"1543301262378\",\"user_nick\":\"seasib\",\"venderId\":\"334040\"}";
if ($gettoken) {
$gettoken1 = json_decode($gettoken, true);
$data['token'] = $gettoken1['token'];
$data['expires_in'] = $gettoken1['expires_in'];
$data['time'] = $gettoken1['time'];
$data['user_nick'] = $gettoken1['user_nick'];
$res = M('jd_store')->where(array('venderId' => $gettoken1['venderId']))->find();
if ($res) {
M('jd_store')->where(array('venderId' => $gettoken1['venderId']))->save($data);
} else {
$data['venderId'] = $gettoken1['venderId'];
M('jd_store')->save($data);
}
$jsonres["code"] = 0;
$jsonres["msg"] = "success";
$jsonres["data"] = "";
return json_encode($jsonres);
}
}
//根据账套
public function jdstoreinfo()
{
$postStr = file_get_contents("php://input");
if (empty($postStr)) {
$postStr = isset($GLOBALS["HTTP_RAW_POST_DATA"]) ? $GLOBALS["HTTP_RAW_POST_DATA"] : "";
}
// $postStr="{\"accdb\":\"ppt\"}";
if (empty($postStr))
{
$jsonres["code"] = -1;
$jsonres["msg"] = "无法获取入参";
$jsonres["data"] = "";
return json_encode($jsonres);
}
$postStr=json_decode($postStr,true);
$res=M('jd_store')->where(array('accdb'=>$postStr['accdb']))->find();
if (empty($res))
{
$jsonres["code"] = -1;
$jsonres["msg"] = "该账套未授权";
$jsonres["data"] = "";
return json_encode($jsonres);
}
$jsonres["code"] = 0;
$jsonres["msg"] = "ok";
$jsonres["data"] = json_encode($res);
return json_encode($jsonres);
}
}