增加docke部署
This commit is contained in:
27
codes/agent/game-docker/api/source/apis/HelloWorld.php
Normal file
27
codes/agent/game-docker/api/source/apis/HelloWorld.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
use phprs\ezsql\Sql;
|
||||
class Message{
|
||||
public function __construct($msg){
|
||||
$this->msg = $msg;
|
||||
}
|
||||
public $msg;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @author caoym
|
||||
* @path("/hw")
|
||||
*/
|
||||
class HelloWorld
|
||||
{
|
||||
/**
|
||||
* @route({"GET","/"})
|
||||
*/
|
||||
public function doSomething1() {
|
||||
return new Message('Hello World!');
|
||||
}
|
||||
|
||||
/**
|
||||
* @property({"default":"@db"}) 注入pdo实例
|
||||
*/
|
||||
//private $db;
|
||||
}
|
||||
291
codes/agent/game-docker/api/source/apis/Users.php
Normal file
291
codes/agent/game-docker/api/source/apis/Users.php
Normal file
@@ -0,0 +1,291 @@
|
||||
<?php
|
||||
/**
|
||||
* a sample for showing annotations
|
||||
*/
|
||||
use phprs\util\Verify;
|
||||
use phprs\util\exceptions\Forbidden;
|
||||
use phprs\util\Logger;
|
||||
use phprs\util\exceptions\NotFound;
|
||||
use phprs\ezsql\Sql;
|
||||
use phprs\util\exceptions\BadRequest;
|
||||
|
||||
/**
|
||||
* @author caoym
|
||||
*/
|
||||
class AliasConflict extends \Exception
|
||||
{
|
||||
}
|
||||
/**
|
||||
* @author caoym
|
||||
*/
|
||||
class AccountConflict extends \Exception
|
||||
{
|
||||
}
|
||||
/**
|
||||
*
|
||||
* users manager
|
||||
* @path("/users")
|
||||
*/
|
||||
class Users
|
||||
{
|
||||
|
||||
/**
|
||||
* create user
|
||||
* @route({"POST","/"})
|
||||
* @param({"account", "$._POST.mobile"}) cell-phone number, required
|
||||
* @param({"password", "$._POST.password"}) password, required
|
||||
* @param({"alias", "$._POST.alias"}) user's alias, required
|
||||
* @param({"avatar", "$._FILES.avatar.tmp_name"}) user's avatar, optional
|
||||
* @param({"token", "$._COOKIE.token"})
|
||||
*
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie invalid
|
||||
*
|
||||
* @throws({"AliasConflict","res", "409 Conflict",{"error":"AliasConflict"}}) alias conflict
|
||||
*
|
||||
* @throws({"AccountConflict","res", "409 Conflict",{"error":"AccountConflict"}}) account conflict
|
||||
*
|
||||
* @return({"cookie","uid","$uid","+365 days","/"}) uid
|
||||
* @return user's id
|
||||
* {"uid":"1233"}
|
||||
*/
|
||||
public function createUser(&$uid, $token, $account, $alias, $password, $avatar = null){
|
||||
$tokens = $this->factory->create('Tokens');
|
||||
$token = $tokens->getToken($token);
|
||||
Verify::isTrue(!$token['uid'], new BadRequest('invalid token'));
|
||||
Verify::isTrue($token['account'] == $account, new Forbidden('invalid mobile '.$account));
|
||||
|
||||
if($avatar){
|
||||
$avatar = $this->uploadAvatar($avatar);
|
||||
}else{
|
||||
$avatar = '';
|
||||
}
|
||||
$pdo = $this->db;
|
||||
$pdo->beginTransaction();
|
||||
try {
|
||||
//is account conflict
|
||||
$res = Sql::select('uid')->from('uc_members')->where(
|
||||
'username = ? OR email = ? OR mobile = ?', $account,$account,$account
|
||||
)->forUpdate()->get($pdo);
|
||||
Verify::isTrue(count($res) ==0, new AccountConflict("account $account conflict"));
|
||||
//is avatar conflict
|
||||
$res = Sql::select('uid')->from('pre_common_member_profile')->where('realname = ?', $alias)->forUpdate()->get($pdo);
|
||||
Verify::isTrue(count($res) ==0, new AliasConflict("alias $alias conflict"));
|
||||
|
||||
$uid = Sql::insertInto('uc_members')->values(['username'=>$account,
|
||||
'password'=>$password,
|
||||
'regdate'=>Sql::native('UNIX_TIMESTAMP(now())'),
|
||||
'salt'=>''
|
||||
])->exec($pdo)->lastInsertId();
|
||||
|
||||
Sql::insertInto('pre_common_member_profile')->values([
|
||||
'realname'=>$alias,
|
||||
'uid'=>$uid,
|
||||
'avatar'=>$avatar
|
||||
])->exec($pdo);
|
||||
|
||||
$pdo->commit();
|
||||
} catch (Exception $e) {
|
||||
Logger::warning("createUser($account) failed with ".$e->getMessage());
|
||||
$pdo->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
$token['uid'] = $uid;
|
||||
$tokens->updateToken($token, $token);
|
||||
return ['uid'=>$uid];
|
||||
}
|
||||
|
||||
/**
|
||||
* modify user's information
|
||||
* @route({"POST","/current"})
|
||||
*
|
||||
* @param({"password", "$._POST.password"}) modify password, optional
|
||||
* @param({"alias", "$._POST.alias"}) modify alias, optional
|
||||
* @param({"avatar", "$._FILES.avatar.tmp_name"}) modify avatar, optional
|
||||
* @param({"token", "$._COOKIE.token"}) used for auth
|
||||
*
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden", {"error":"Forbidden"}}) invalid cookie
|
||||
*
|
||||
* @throws({"AliasConflict","status", "409 Conflict", {"error":"AliasConflict"}}) alias conflict
|
||||
*
|
||||
*/
|
||||
public function updateUser($token, $alias=null, $password=null, $avatar=null ){
|
||||
|
||||
$token = $this->factory->create('Tokens')->getToken($token);
|
||||
Verify::isTrue(isset($token['uid']) && $token['uid']!=0, new Forbidden("invalid uid {$token['uid']}"));
|
||||
if($avatar){
|
||||
$avatar = $this->uploadAvatar($avatar);
|
||||
}
|
||||
$uid = $token['uid'];
|
||||
|
||||
$pdo = $this->db;
|
||||
$pdo->beginTransaction();
|
||||
try {
|
||||
if($alias || $avatar){
|
||||
$sets = array();
|
||||
$params = array();
|
||||
|
||||
if($alias){
|
||||
|
||||
$res = Sql::select('uid')->from('pre_common_member_profile')->where('realname = ? AND uid <> ?', $alias, $uid)->forUpdate()->get($pdo);
|
||||
Verify::isTrue(count($res) ==0, new AliasConflict("alias $alias conflict"));
|
||||
|
||||
$params['realname'] = $alias;
|
||||
}
|
||||
|
||||
if($avatar){
|
||||
$params['avatar'] = $avatar;
|
||||
}
|
||||
Sql::update('pre_common_member_profile')->setArgs($params)->where('uid = ?',$uid)->exec($pdo);
|
||||
}
|
||||
|
||||
if($password !== null){
|
||||
Sql::update('uc_members')->setArgs([
|
||||
'password'=>$password,
|
||||
'salt'=>''
|
||||
])->where('uid=?',$uid)->exec($pdo);
|
||||
|
||||
}
|
||||
|
||||
$pdo->commit();
|
||||
} catch (Exception $e) {
|
||||
Logger::warning("updateUser($uid) failed with ".$e->getMessage());
|
||||
$pdo->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* get users info
|
||||
* @route({"GET","/"})
|
||||
* @param({"uids","$._GET.uids"}) users id
|
||||
* @return("body")
|
||||
* response like this:
|
||||
* [
|
||||
* {
|
||||
* "uid":"id",
|
||||
* "avatar":"http://xxxxx/avatar.jpg",
|
||||
* "alias":"caoym",
|
||||
* }
|
||||
* ...
|
||||
* ]
|
||||
*/
|
||||
public function getUserByIds($uids, $asDict=false) {
|
||||
if(count($uids) == 0){
|
||||
return [];
|
||||
}
|
||||
|
||||
$res = Sql::select('uc_members.uid',
|
||||
'pre_common_member_profile.realname as alias',
|
||||
'pre_common_member_profile.avatar',
|
||||
'pre_common_member_profile.level',
|
||||
'pre_common_member_profile.ext')
|
||||
->from('uc_members')
|
||||
->leftJoin('pre_common_member_profile')
|
||||
->on('uc_members.uid=pre_common_member_profile.uid')
|
||||
->where('uc_members.uid IN (?)', $uids)
|
||||
->get($this->db ,$asDict?'uid':null);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* get current user info
|
||||
* @route({"GET","/current"})
|
||||
*
|
||||
* @param({"token", "$._COOKIE.token"})
|
||||
* @return("body")
|
||||
* response like this:
|
||||
* {
|
||||
* "uid":"id",
|
||||
* "avatar":"http://xxxxx/avatar.jpg",
|
||||
* "alias":"caoym"
|
||||
* }
|
||||
* ...
|
||||
*/
|
||||
public function getCurrentUser($token){
|
||||
$tokens = $this->factory->create('Tokens');
|
||||
$token = $tokens->getToken($token);
|
||||
$uid = $token['uid'];
|
||||
Verify::isTrue($token['uid'] , new Forbidden('invalid uid '.$uid));
|
||||
$res = $this->getUserByIds([$uid]);
|
||||
Verify::isTrue(count($res) !=0, new NotFound("user $uid not found"));
|
||||
return $res[0];
|
||||
}
|
||||
|
||||
public function getUserByAccount($account){
|
||||
return $this->getUser(['uc_members.username'=>$account]);
|
||||
}
|
||||
public function getUserByAlias($alias){
|
||||
return $this->getUser(['pre_common_member_profile.realname'=>$alias]);
|
||||
}
|
||||
|
||||
private function getUser($cond){
|
||||
$res = Sql::select('uc_members.uid',
|
||||
'pre_common_member_profile.realname as alias',
|
||||
'pre_common_member_profile.avatar',
|
||||
'pre_common_member_profile.level',
|
||||
'pre_common_member_profile.ext')
|
||||
->from('uc_members')
|
||||
->leftJoin('pre_common_member_profile')
|
||||
->on('uc_members.uid=pre_common_member_profile.uid')
|
||||
->whereArgs($cond)
|
||||
->get($this->db);
|
||||
if(count($res)){
|
||||
$ext = json_decode($res[0]['ext'],true);
|
||||
unset($res[0]['ext']);
|
||||
|
||||
if(isset($ext['education'])) $res[0]['education'] = $ext['education'];
|
||||
if(isset($ext['company'])) $res[0]['company'] = $ext['company'];
|
||||
if(isset($ext['fields'])) $res[0]['fields'] = $ext['fields'];
|
||||
}
|
||||
return count($res)>0 ? $res[0]:false;
|
||||
}
|
||||
|
||||
public function verifyPassword($account, $password){
|
||||
$res = Sql::select('uid, password, salt')->from('uc_members')
|
||||
->where('username = ? or email = ?', $account, $account)
|
||||
->get($this->db);
|
||||
|
||||
if(count($res) == 0){
|
||||
return false;
|
||||
}
|
||||
|
||||
if($res[0]['password'] == $password ){
|
||||
return $res[0]['uid'];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function deleteUserByAccount($account){
|
||||
$this->db->beginTransaction();
|
||||
try {
|
||||
$res = Sql::select('uid')->from('uc_members')->where('username=?',$account)->forUpdate()->get($this->db);
|
||||
if (count($res) == 0){
|
||||
$this->db->rollBack();
|
||||
return false;
|
||||
}
|
||||
$uid = $res[0]['uid'];
|
||||
Sql::deleteFrom('pre_common_member_profile')->where('uid=?',$uid)->exec($this->db);
|
||||
Sql::deleteFrom('uc_members')->where('uid=?',$uid)->exec($this->db);
|
||||
$this->db->commit();
|
||||
|
||||
} catch (Exception $e) {
|
||||
$this->db->rollBack();
|
||||
throw $e;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private function uploadAvatar($file){
|
||||
$name = md5_file($file);
|
||||
return $this->oss->upload("avatars", $name, $file);
|
||||
}
|
||||
/** @inject("ioc_factory") */
|
||||
private $factory;
|
||||
/**
|
||||
* @property({"default":"@db"})
|
||||
* @var PDO
|
||||
*/
|
||||
public $db;
|
||||
// 此处删除了代码
|
||||
}
|
||||
319
codes/agent/game-docker/api/source/apis/activity.php
Normal file
319
codes/agent/game-docker/api/source/apis/activity.php
Normal file
@@ -0,0 +1,319 @@
|
||||
<?php
|
||||
require_once dirname(dirname(dirname(__DIR__))) . '/env_config.php';
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, PATCH, DELETE");
|
||||
header("Access-Control-Allow-Headers: Content-Type, Authorization, Content-Length, X-Requested-With");
|
||||
header("Access-Control-Allow-Credentials: true");
|
||||
header("Content-Type: text/html; charset=utf-8");
|
||||
|
||||
/**
|
||||
* 门店相关活动
|
||||
*/
|
||||
use phprs\util\Verify;
|
||||
use phprs\util\exceptions\Forbidden;
|
||||
use phprs\util\Logger;
|
||||
use phprs\util\exceptions\NotFound;
|
||||
use phprs\ezsql\Sql;
|
||||
use phprs\util\exceptions\BadRequest;
|
||||
|
||||
require_once 'apiBase.php';
|
||||
|
||||
/**
|
||||
*
|
||||
* 门店相关活动
|
||||
* @path("/activity")
|
||||
*/
|
||||
class Activity extends apiBase {
|
||||
/**
|
||||
* 获取单个活动详细信息(错误代码:16000-16050)
|
||||
* @route({"POST","/"})
|
||||
* @param({"devkey","$._POST.devkey"}) 开发者key
|
||||
* @param({"market_key","$._POST.market_key"}) market_key
|
||||
* @param({"activity_key","$._POST.activity_key"}) activity_key
|
||||
* @param({"sign","$._POST.sign"}) sign
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
* @return("body")
|
||||
*/
|
||||
public function getActivity($devkey='',$market_key='',$activity_key='',$sign='') {
|
||||
$result = array();
|
||||
|
||||
$verify_result = $this->verifyMarketApi($devkey);
|
||||
if( is_error_api($verify_result) ){
|
||||
return $verify_result;
|
||||
}
|
||||
|
||||
if( empty($market_key) ) {
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 11001;
|
||||
$result["msg"] = "未传入market_key参数";
|
||||
return $result;
|
||||
}
|
||||
$marketList = Sql::select('a.*')
|
||||
->from('syweb_market a')
|
||||
->where('a.market_key=?',$market_key)
|
||||
->get($this->db ,null);
|
||||
if( empty($marketList) || count($marketList)<=0 ) {
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 11002;
|
||||
$result["msg"] = "market_key无效";
|
||||
return $result;
|
||||
}
|
||||
$marketList = $marketList[0];
|
||||
|
||||
if( empty($activity_key) ) {
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 16001;
|
||||
$result["msg"] = "未传入activity_key参数";
|
||||
return $result;
|
||||
}
|
||||
|
||||
$activityList = Sql::select('a.*')
|
||||
->from('syweb_business_activity a')
|
||||
->where('a.activity_key=?',$activity_key)
|
||||
->get($this->db ,null);
|
||||
if( empty($activityList) || count($activityList)<=0 ) {
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 16002;
|
||||
$result["msg"] = "指定的门店活动不存在或已经被删除!";
|
||||
return $result;
|
||||
}
|
||||
$activityList = $activityList[0];
|
||||
|
||||
if( !empty($activityList) ) {
|
||||
if( !empty($activityList["logo"]) ) {
|
||||
$activityList["logo"] = env('SITE_OPEN_URL', 'http://open.daoqijuyou77.cn').$activityList["logo"];
|
||||
}
|
||||
|
||||
if( !empty($activityList["url"]) ) {
|
||||
$activityList["url"] = str_replace("%market_key",$market_key,$activityList["url"]);
|
||||
$activityList["url"] = str_replace("%activity_key",$activity_key,$activityList["url"]);
|
||||
}
|
||||
|
||||
$activityList["titleimg_list"] = iunserializer($activityList["titleimg_list"]);
|
||||
|
||||
$titleImgList = array();
|
||||
if( !empty($activityList["titleimg_list"]) && count($activityList["titleimg_list"])>0 ) {
|
||||
foreach ($activityList["titleimg_list"] as $key => $value) {
|
||||
if( !empty($value) ) {
|
||||
$titleImgList[] = env('SITE_OPEN_URL', 'http://open.daoqijuyou77.cn').$value;
|
||||
}
|
||||
}
|
||||
}
|
||||
$activityList["titleimg_list"] = $titleImgList;
|
||||
}
|
||||
|
||||
$result["error"] = '0';
|
||||
$result["data"] = $activityList;
|
||||
$result["msg"] = "获取单个活动详细信息成功!";
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取活动分类信息(错误代码:16000-16050)
|
||||
* @route({"POST","/class"})
|
||||
* @param({"devkey","$._POST.devkey"}) 开发者key
|
||||
* @param({"market_key","$._POST.market_key"}) market_key
|
||||
* @param({"parent_key","$._POST.parent_key"}) parent_key
|
||||
* @param({"sign","$._POST.sign"}) sign
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
* @return("body")
|
||||
*/
|
||||
public function getClassList($devkey='',$market_key='',$parent_key='',$sign='') {
|
||||
$result = array();
|
||||
|
||||
$verify_result = $this->verifyMarketApi($devkey);
|
||||
if( is_error_api($verify_result) ){
|
||||
return $verify_result;
|
||||
}
|
||||
|
||||
if( empty($market_key) ) {
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 11001;
|
||||
$result["msg"] = "未传入market_key参数";
|
||||
return $result;
|
||||
}
|
||||
$marketList = Sql::select('a.*')
|
||||
->from('syweb_market a')
|
||||
->where('a.market_key=?',$market_key)
|
||||
->get($this->db ,null);
|
||||
if( empty($marketList) || count($marketList)<=0 ) {
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 11002;
|
||||
$result["msg"] = "market_key无效";
|
||||
return $result;
|
||||
}
|
||||
$marketList = $marketList[0];
|
||||
|
||||
if( empty($parent_key) ) {
|
||||
$parent_key = "";
|
||||
}
|
||||
|
||||
$class_list = $this->selectClass($parent_key,$marketList["business_key"]);
|
||||
$result["error"] = '0';
|
||||
$result["data"] = $class_list;
|
||||
$result["msg"] = "获取活动分类信息成功!";
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取活动信息列表(错误代码:16051-16100)
|
||||
* @route({"POST","/list"})
|
||||
* @param({"devkey","$._POST.devkey"}) 开发者key
|
||||
* @param({"market_key","$._POST.market_key"}) market_key
|
||||
* @param({"type","$._POST.type"}) type
|
||||
* @param({"class_key","$._POST.class_key"}) class_key
|
||||
* @param({"keywords","$._POST.keywords"}) keywords
|
||||
* @param({"pageno","$._POST.pageno"}) pageno
|
||||
* @param({"pagesize","$._POST.pagesize"}) pagesize
|
||||
* @param({"sign","$._POST.sign"}) sign
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
* @return("body")
|
||||
*/
|
||||
public function getActivityList($devkey='',$market_key='',$type=0,$class_key='',$keywords='',$pageno=0,$pagesize=0,$sign='') {
|
||||
$result = array();
|
||||
|
||||
$verify_result = $this->verifyMarketApi($devkey);
|
||||
|
||||
if( is_error_api($verify_result) ){
|
||||
return $verify_result;
|
||||
}
|
||||
|
||||
if( empty($market_key) ) {
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 11001;
|
||||
$result["msg"] = "未传入market_key参数";
|
||||
return $result;
|
||||
}
|
||||
$marketList = Sql::select('a.*')
|
||||
->from('syweb_market a')
|
||||
->where('a.market_key=?',$market_key)
|
||||
->get($this->db ,null);
|
||||
if( empty($marketList) || count($marketList)<=0 ) {
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 11002;
|
||||
$result["msg"] = "market_key无效";
|
||||
return $result;
|
||||
}
|
||||
$marketList = $marketList[0];
|
||||
|
||||
// 组装查询条件 begin
|
||||
$conditionStr = " activity_key in (select activity_key from syweb_business_activity_market where market_key='".$marketList["market_key"]."')";
|
||||
|
||||
$orderStr = " id desc ";
|
||||
if( !empty($type) && is_numeric($type) ){
|
||||
if( $type==1 ) {
|
||||
$orderStr = " access_count desc ";
|
||||
} else if( $type==3 ) {
|
||||
$orderStr = " id desc ";
|
||||
} else if( $type==3 ) {
|
||||
$conditionStr .= " and is_recommond=1 ";
|
||||
} else if( $type==4 ) {
|
||||
// 暂时未实现
|
||||
}
|
||||
}
|
||||
|
||||
if( !empty($class_key) ) {
|
||||
$conditionStr .= " and class_key='".$class_key."'";
|
||||
}
|
||||
|
||||
if( !empty($keywords) ) {
|
||||
$conditionStr .= " and activity_name like '%".$keywords."%'";
|
||||
}
|
||||
// 组装查询条件 end
|
||||
|
||||
// 分页 begin
|
||||
$pindex = max(1, intval($pageno));
|
||||
if($psize){
|
||||
$psize = intval($pagesize);
|
||||
} else {
|
||||
$psize = 20;
|
||||
}
|
||||
// 分页 end
|
||||
|
||||
$pdo = $this->db;
|
||||
$pdo->beginTransaction();
|
||||
|
||||
$total = Sql::select(' COUNT(id) as num ')
|
||||
->from('syweb_business_activity')
|
||||
->where($conditionStr)
|
||||
->get($this->db ,null);
|
||||
$list = array();
|
||||
if (!empty($total) && !empty($total[0]["num"])) {
|
||||
$list = Sql::select("*")
|
||||
->from('syweb_business_activity')
|
||||
->where($conditionStr)
|
||||
->orderBy($orderStr)
|
||||
->limit(($pindex - 1) * $psize,$psize)
|
||||
->get($this->db ,null);
|
||||
}
|
||||
$pdo->commit();
|
||||
|
||||
if( $list ){
|
||||
foreach ($list as &$item) {
|
||||
if( !empty($item["logo"]) ) {
|
||||
$item["logo"] = env('SITE_OPEN_URL', 'http://open.daoqijuyou77.cn').$item["logo"];
|
||||
}
|
||||
|
||||
$item["url"] = str_replace("%market_key",$market_key,$item["url"]);
|
||||
$item["url"] = str_replace("%activity_key",$item["activity_key"],$item["url"]);
|
||||
}
|
||||
|
||||
$page_count = 0;
|
||||
if( (int)$total[0]["num"] % $psize > 0 ) {
|
||||
$page_count = (int)$total[0]["num"] / $psize + 1;
|
||||
} else {
|
||||
$page_count = (int)$total[0]["num"];
|
||||
}
|
||||
$result["error"] = '0';
|
||||
$result["msg"] = '数据获取成功。';
|
||||
$result["data"]["content"] = $list;
|
||||
$result["data"]["pager"]["total"] = (int)$total[0]["num"];// 总记录数
|
||||
$result["data"]["pager"]["pindex"] = $pindex;// 当前页索引
|
||||
$result["data"]["pager"]["psize"] = $psize;// 每页记录条数
|
||||
$result["data"]["pager"]["page_count"] = $page_count;// 总共的页数
|
||||
return $result;
|
||||
} else {
|
||||
$list = array();
|
||||
$result["error"] = '0';
|
||||
$result["msg"] = '未查询到任何数据记录。';
|
||||
$result["data"]["content"] = $list;
|
||||
$result["data"]["pager"]["total"] = (int)$total[0]["num"];// 总记录数
|
||||
$result["data"]["pager"]["pindex"] = $pindex;// 当前页索引
|
||||
$result["data"]["pager"]["psize"] = $psize;// 每页记录条数
|
||||
$result["data"]["pager"]["page_count"] = 0;// 总共的页数
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用递归的方式查询分类
|
||||
*
|
||||
**/
|
||||
private function selectClass($parent_key,$business_key) {
|
||||
$class_list = Sql::select('a.*')
|
||||
->from('syweb_activity_class a')
|
||||
->where('a.parent_key=? and a.business_key=?',$parent_key,$business_key)
|
||||
->get($this->db ,null);
|
||||
if( !empty($class_list) && count($class_list)>0 ) {
|
||||
foreach ($class_list as &$classInfo) {
|
||||
$sub_class_list = $this->selectClass($classInfo["class_key"],$business_key);
|
||||
if( !empty($sub_class_list) && count($sub_class_list)>0 ) {
|
||||
$classInfo["has_sub"] = 1;
|
||||
$classInfo["sub_class_list"] = $sub_class_list;
|
||||
} else {
|
||||
$classInfo["has_sub"] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $class_list;
|
||||
}
|
||||
|
||||
/** @inject("ioc_factory") */
|
||||
private $factory;
|
||||
/**
|
||||
* @property({"default":"@db"})
|
||||
* @var PDO
|
||||
*/
|
||||
public $db;
|
||||
// 此处删除了代码
|
||||
}
|
||||
469
codes/agent/game-docker/api/source/apis/apiBase.php
Normal file
469
codes/agent/game-docker/api/source/apis/apiBase.php
Normal file
@@ -0,0 +1,469 @@
|
||||
<?php
|
||||
// 加载环境变量配置
|
||||
require_once dirname(dirname(dirname(__DIR__))) . '/env_config.php';
|
||||
|
||||
use phprs\util\Verify;
|
||||
use phprs\util\exceptions\Forbidden;
|
||||
use phprs\util\Logger;
|
||||
use phprs\util\exceptions\NotFound;
|
||||
use phprs\ezsql\Sql;
|
||||
use phprs\util\exceptions\BadRequest;
|
||||
|
||||
|
||||
/// 接口返回用的信息类
|
||||
class returnObject
|
||||
{
|
||||
public $error; /// 返回值: 0成功; 非0失败;
|
||||
public $error_code; /// 错误号
|
||||
public $msg; /// 错误信息
|
||||
public $data; /// 返回的数据
|
||||
|
||||
public function returnObject($error = 0, $error_code = 0, $msg = null, $data = null)
|
||||
{
|
||||
$this->error = $error;
|
||||
$this->error_code = $error_code;
|
||||
$this->msg = $msg;
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
public function to_array()
|
||||
{
|
||||
return (array)$this;
|
||||
}
|
||||
|
||||
public function to_string()
|
||||
{
|
||||
return json_encode($this, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
public function from_array($array)
|
||||
{
|
||||
foreach ($array as $key => $value)
|
||||
{
|
||||
if (property_exists($this, $key))
|
||||
{
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function from_string($string)
|
||||
{
|
||||
return $this->from_array((array)json_decode($string));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 错误码
|
||||
* 获取优惠券:12000--12050
|
||||
* 更新用户积分:13000-13050
|
||||
* 友乐牛牛用户登录:13100-13150
|
||||
* 基类
|
||||
* @path("/apiBase")
|
||||
*/
|
||||
class apiBase
|
||||
{
|
||||
public static $domain;
|
||||
//public static $domain = 'api.tscce.cn';
|
||||
public $appid; // 开发者应用ID
|
||||
|
||||
// 静态初始化 domain
|
||||
public static function initDomain() {
|
||||
if (empty(self::$domain)) {
|
||||
self::$domain = env('SITE_SDK_DOMAIN', 'sdk.tscce.cn');
|
||||
}
|
||||
}
|
||||
public $devkey; // 开发者Key
|
||||
public $businessid; // 商家ID
|
||||
public $sid; // 开发者SID
|
||||
public $scode; // 开发者SCODE
|
||||
public $market_key; // 门店Key
|
||||
|
||||
public $appInfo; // 开发者应用信息
|
||||
public $devInfo; // 开发者信息
|
||||
public $marketInfo; // 商家信息
|
||||
public $userInfo; // 全局用户信息
|
||||
public $businessInfo;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
protected function getLocaleUrl($always_http = false)
|
||||
{
|
||||
$is_https =
|
||||
(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ||
|
||||
(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') ||
|
||||
(isset($_SERVER['REQUEST_SCHEME']) && $_SERVER['REQUEST_SCHEME'] == 'https');
|
||||
|
||||
$request_scheme = $is_https ? 'https://' : 'http://';
|
||||
$hostname = $_SERVER['SERVER_NAME'];
|
||||
$hostport = (($is_https && '443' == $_SERVER['SERVER_PORT']) || (!$is_https && '80' == $_SERVER['SERVER_PORT'])) ? '' : ':' . intval($_SERVER['SERVER_PORT']);
|
||||
|
||||
if ($always_http)
|
||||
return 'http://' . $hostname . $hostport;
|
||||
else
|
||||
return $request_scheme . $hostname . $hostport;
|
||||
}
|
||||
|
||||
protected function getFullUrl($relatively_url, $always_http = false)
|
||||
{
|
||||
if (mb_strstr($relatively_url, '/', false, USEDCHARSET) == $relatively_url)
|
||||
return $this->getLocaleUrl($always_http) . $relatively_url;
|
||||
else
|
||||
return $this->getLocaleUrl($always_http) . '/' . $relatively_url;
|
||||
}
|
||||
|
||||
public function init($appid = '', $devkey = '', $sid = '', $scode = '', $market_key = '')
|
||||
{
|
||||
$this->appid = $appid;
|
||||
$this->devkey = $devkey;
|
||||
$this->sid = $sid;
|
||||
$this->scode = $scode;
|
||||
$this->market_key = $market_key;
|
||||
}
|
||||
|
||||
public function verifyMarketApi($devkey = '')
|
||||
{
|
||||
$this->devkey = $devkey;
|
||||
|
||||
if (empty($this->devkey))
|
||||
{
|
||||
return new returnObject(1, 10002, '未传入devkey参数');
|
||||
}
|
||||
$devList = Sql::select('syweb_admin.*')
|
||||
->from('syweb_admin')
|
||||
->where('syweb_admin.type=2 and syweb_admin.admin_key=? and syweb_admin.status=1', $this->devkey)
|
||||
->get($this->db, null);
|
||||
if (empty($devList) || count($devList) <= 0)
|
||||
{
|
||||
return new returnObject(1, 10003, 'devkey无效');
|
||||
}
|
||||
|
||||
$this->devInfo = $devList[0];
|
||||
|
||||
return new returnObject(0);
|
||||
}
|
||||
|
||||
/*******************************
|
||||
* name: verify
|
||||
* note: 验证参数是否有效
|
||||
*******************************/
|
||||
public function verify()
|
||||
{
|
||||
if (empty($this->appid))
|
||||
return new returnObject(1, 10001, '未传入appid参数');
|
||||
|
||||
if (empty($this->devkey))
|
||||
return new returnObject(1, 10002, '未传入devkey参数');
|
||||
$devList = Sql::select('a.*')
|
||||
->from('syweb_admin a')
|
||||
->where('a.type=2 and a.admin_key=? and a.status=1', $this->devkey)
|
||||
->get($this->db, null);
|
||||
if (empty($devList) || count($devList) <= 0)
|
||||
return new returnObject(1, 10003, 'devkey无效');
|
||||
$this->devInfo = $devList[0];
|
||||
/*
|
||||
$appBaseList = Sql::select('a.*')
|
||||
->from('syweb_app_base a')
|
||||
->where('a.ref_key=? and a.dev_key=? and a.status=10', $this->appid, $this->devInfo['admin_key'])
|
||||
->get($this->db, null);
|
||||
if (empty($appBaseList) || count($appBaseList) <= 0)
|
||||
{
|
||||
return new returnObject(1, 10004, '指定的应用不存在或未被审核');
|
||||
}
|
||||
$appBaseKey = $appBaseList[0]["app_key"];
|
||||
|
||||
$appList = Sql::select('a.*')
|
||||
->from('syweb_app a')
|
||||
->where('a.ref_key=? and a.dev_key=? and a.status=10', $appBaseKey, $this->devInfo['admin_key'])
|
||||
->get($this->db, null);
|
||||
if (empty($appList) || count($appList) <= 0)
|
||||
{
|
||||
return new returnObject(1, 10004, '指定的应用不存在或未被审核');
|
||||
}
|
||||
$this->appInfo = $appList[0];
|
||||
*/
|
||||
$appList = Sql::select('b.*')
|
||||
->from('syweb_app_base a, syweb_app b')
|
||||
->where('a.app_key = b.ref_key and a.status = b.status and a.dev_key = b.dev_key and a.ref_key = ? and a.dev_key = ? and a.status = 10', $this->appid, $this->devInfo['admin_key'])
|
||||
->get($this->db, null);
|
||||
if (empty($appList) || count($appList) <= 0)
|
||||
return new returnObject(1, 10004, '指定的应用不存在或未被审核');
|
||||
$this->appInfo = $appList[0];
|
||||
|
||||
if (empty($this->sid))
|
||||
return new returnObject(1, 10005, '请传入sid');
|
||||
if (empty($this->scode))
|
||||
return new returnObject(1, 10006, '请传入scode');
|
||||
|
||||
// 当前时间戳,通过sid和scode获取用户信息,必须保障sid未过期
|
||||
$nowTime = time();
|
||||
// 根据sid 查询用户信息
|
||||
$userList = Sql::select('a.*')
|
||||
->from('syweb_users a')
|
||||
->where('a.sid=? and a.scode=? and a.sid_expire_time>?', $this->sid, $this->scode, $nowTime)
|
||||
->get($this->db, null);
|
||||
if (!empty($userList) && count($userList) > 0)
|
||||
{
|
||||
$this->userInfo = $userList[0];
|
||||
|
||||
// 延长SID过期时间 begin
|
||||
$updateData = array();
|
||||
$sid_expire_time = time() + (2 * 24 * 60 * 60);
|
||||
$updateData['sid_expire_time'] = $sid_expire_time;
|
||||
$pdo = $this->db;
|
||||
$pdo->beginTransaction();
|
||||
Sql::update('syweb_users')->setArgs($updateData)->where('id=?', $this->userInfo['id'])->exec($pdo);
|
||||
$pdo->commit();
|
||||
// 延长SID过期时间 end
|
||||
|
||||
// 判断SID对应的门店Key和传入的门店Key是否一致
|
||||
if (!empty($market_key))
|
||||
{
|
||||
if ($this->userInfo['market_key'] != $market_key)
|
||||
return new returnObject(1, 10011, '指定的SID和market_key不符');
|
||||
}
|
||||
|
||||
$marketList = Sql::select('a.*')
|
||||
->from('syweb_market a')
|
||||
->where('a.market_key=?', $this->userInfo['market_key'])
|
||||
->get($this->db, null);
|
||||
if (empty($marketList) || count($marketList) <= 0)
|
||||
return new returnObject(1, 10007, '指定的门店Key不存在或未被审核');
|
||||
|
||||
$this->market_key = $this->userInfo['market_key'];
|
||||
$this->marketInfo = $marketList[0];
|
||||
|
||||
if (!empty($this->marketInfo) && !empty($this->marketInfo['templatemsg']))
|
||||
$this->marketInfo['templatemsg'] = iunserializer($this->marketInfo['templatemsg']);
|
||||
|
||||
switch ($this->userInfo['auth_type'])
|
||||
{
|
||||
case AUTHTYPE_WECHAT:
|
||||
{
|
||||
$weixin_user_list = Sql::select('syweb_users_weixin.*')
|
||||
->from('syweb_users_weixin')
|
||||
->where('syweb_users_weixin.uid=?', $this->userInfo["id"])
|
||||
->get($this->db, null);
|
||||
|
||||
if (!empty($weixin_user_list) && count($weixin_user_list) > 0)
|
||||
{
|
||||
$this->userInfo['weixin'] = $weixin_user_list[0];
|
||||
return new returnObject(0);
|
||||
}
|
||||
else
|
||||
return new returnObject(1, 10009, '未找到指定的微信用户信息');
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case AUTHTYPE_QQ:
|
||||
{
|
||||
$qq_user_list = Sql::select('syweb_users_qq.*')
|
||||
->from('syweb_users_qq')
|
||||
->where('syweb_users_qq.uid=?', $this->userInfo["id"])
|
||||
->get($this->db, null);
|
||||
|
||||
if (!empty($qq_user_list) && count($qq_user_list) > 0)
|
||||
{
|
||||
$this->userInfo['qq'] = $qq_user_list[0];
|
||||
return new returnObject(0);
|
||||
}
|
||||
else
|
||||
return new returnObject(1, 10010, '未找到指定的QQ用户信息');
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case AUTHTYPE_JKX:
|
||||
{
|
||||
$jkx_user_list = Sql::select('a.*')
|
||||
->from('syweb_users_jkx a')
|
||||
->where('a.uid=?', $this->userInfo["id"])
|
||||
->get($this->db, null);
|
||||
|
||||
if (!empty($jkx_user_list) && count($jkx_user_list) > 0)
|
||||
{
|
||||
$this->userInfo['jkx'] = $jkx_user_list[0];
|
||||
return new returnObject(0);
|
||||
}
|
||||
else
|
||||
return new returnObject(1, 10011, '未找到指定的聚开心用户信息');
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case AUTHTYPE_NIUNIUGAME:
|
||||
{
|
||||
$app_user_list = Sql::select('a.*')
|
||||
->from('syweb_users_ylnn a')
|
||||
->where('a.uid=?', $this->userInfo["id"])
|
||||
->get($this->db, null);
|
||||
|
||||
if (!empty($app_user_list) && count($app_user_list) > 0)
|
||||
{
|
||||
$this->userInfo['app'] = $app_user_list[0];
|
||||
return new returnObject(0);
|
||||
}
|
||||
else
|
||||
return new returnObject(1, 10011, '未找到指定的应用认证用户信息');
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
return new returnObject(1, 10012, '未知的用户认证方式' . $this->userInfo['auth_type']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return new returnObject(1, 10008, '用户未登录或登录信息过期');
|
||||
}
|
||||
}
|
||||
|
||||
public function ToUrlParams($paramers)
|
||||
{
|
||||
$buff = "";
|
||||
foreach ($paramers as $k => $v)
|
||||
{
|
||||
if ($k != "sign" && $v != "" && !is_array($v))
|
||||
{
|
||||
$buff .= $k . "=" . $v . "&";
|
||||
}
|
||||
}
|
||||
|
||||
$buff = trim($buff, "&");
|
||||
return $buff;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $market_key
|
||||
* @return array|null
|
||||
*/
|
||||
public function verify_admin($market_key)
|
||||
{
|
||||
if (empty($this->appid))
|
||||
return new returnObject(1, 10001, '未传入appid参数');
|
||||
|
||||
if (empty($this->devkey))
|
||||
return new returnObject(1, 10002, '未传入devkey参数');
|
||||
|
||||
if (empty($market_key))
|
||||
return new returnObject(1, 10011, '未传入market_key参数');
|
||||
|
||||
$devList = Sql::select('a.*')
|
||||
->from('syweb_admin a')
|
||||
->where('a.type=2 and a.admin_key=? and a.status=1', $this->devkey)
|
||||
->get($this->db, null);
|
||||
if (empty($devList) || count($devList) <= 0)
|
||||
return new returnObject(1, 10003, 'devkey无效');
|
||||
|
||||
$this->devInfo = $devList[0];
|
||||
/*
|
||||
$appBaseList = Sql::select('a.*')
|
||||
->from('syweb_app_base a')
|
||||
->where('a.ref_key=? and a.dev_key=? and a.status=10', $this->appid, $this->devInfo['admin_key'])
|
||||
->get($this->db, null);
|
||||
if (empty($appBaseList) || count($appBaseList) <= 0)
|
||||
{
|
||||
return new returnObject(1, 10004, '指定的应用不存在或未被审核');
|
||||
}
|
||||
$appBaseKey = $appBaseList[0]["app_key"];
|
||||
|
||||
$appList = Sql::select('a.*')
|
||||
->from('syweb_app a')
|
||||
->where('a.ref_key=? and a.dev_key=? and a.status=10', $appBaseKey, $this->devInfo['admin_key'])
|
||||
->get($this->db, null);
|
||||
if (empty($appList) || count($appList) <= 0)
|
||||
{
|
||||
return new returnObject(1, 10004, '指定的应用不存在或未被审核');
|
||||
}
|
||||
$this->appInfo = $appList[0];
|
||||
*/
|
||||
$appList = Sql::select('b.*')
|
||||
->from('syweb_app_base a, syweb_app b')
|
||||
->where('a.app_key = b.ref_key and a.status = b.status and a.dev_key = b.dev_key and a.ref_key = ? and a.dev_key = ? and a.status = 10', $this->appid, $this->devInfo['admin_key'])
|
||||
->get($this->db, null);
|
||||
if (empty($appList) || count($appList) <= 0)
|
||||
return new returnObject(1, 10004, '指定的应用不存在或未被审核');
|
||||
$this->appInfo = $appList[0];
|
||||
|
||||
$marketList = Sql::select('a.*')
|
||||
->from('syweb_market a')
|
||||
->where('a.market_key=?', $market_key)
|
||||
->get($this->db, null);
|
||||
if (empty($marketList) || count($marketList) <= 0)
|
||||
return new returnObject(1, 10007, '指定的门店Key不存在或未被审核');
|
||||
|
||||
$this->market_key = $market_key;
|
||||
$this->marketInfo = $marketList[0];
|
||||
|
||||
if (!empty($this->marketInfo) && !empty($this->marketInfo['templatemsg']))
|
||||
$this->marketInfo['templatemsg'] = iunserializer($this->marketInfo['templatemsg']);
|
||||
|
||||
return new returnObject(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @功能 带参数跳转到指定地址
|
||||
* @param string $forwardUrl
|
||||
* @param mixed $paramers
|
||||
**/
|
||||
public function forwardUrl($forwardUrl, $paramers)
|
||||
{
|
||||
$paramerStr = "";
|
||||
if (!empty($paramers) && count($paramers) > 0)
|
||||
{
|
||||
foreach ($paramers as $key => $value)
|
||||
{
|
||||
if (empty($paramerStr))
|
||||
{
|
||||
$paramerStr = $key . "=" . $value;
|
||||
}
|
||||
else
|
||||
{
|
||||
$paramerStr .= "&" . $key . "=" . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($paramerStr))
|
||||
{
|
||||
if (strstr($forwardUrl, '?'))
|
||||
{
|
||||
if (strstr($forwardUrl, '&'))
|
||||
{
|
||||
$forwardUrl .= '&' . $paramerStr;
|
||||
}
|
||||
else
|
||||
{
|
||||
$forwardUrl .= $paramerStr;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$forwardUrl .= '?' . $paramerStr;
|
||||
}
|
||||
}
|
||||
header('Location: ' . $forwardUrl);
|
||||
exit();
|
||||
}
|
||||
|
||||
/** @inject("ioc_factory") */
|
||||
private $factory;
|
||||
/**
|
||||
* @property({"default":"@db"})
|
||||
* @var PDO
|
||||
*/
|
||||
public $db;
|
||||
}
|
||||
// 类定义后立即初始化静态 domain
|
||||
apiBase::initDomain();
|
||||
90
codes/agent/game-docker/api/source/apis/appport.php
Normal file
90
codes/agent/game-docker/api/source/apis/appport.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
header('Access-Control-Allow-Origin:*');// 指定允许其他域名访问
|
||||
header('Access-Control-Allow-Methods:POST');// 响应类型
|
||||
header('Access-Control-Allow-Headers:x-requested-with,content-type');
|
||||
|
||||
/**
|
||||
* 获取信息接口
|
||||
*/
|
||||
use phprs\util\Verify;
|
||||
use phprs\util\exceptions\Forbidden;
|
||||
use phprs\util\Logger;
|
||||
use phprs\util\exceptions\NotFound;
|
||||
use phprs\ezsql\Sql;
|
||||
use phprs\util\exceptions\BadRequest;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* 获取信息接口
|
||||
* @path("/appport")
|
||||
*/
|
||||
class Appport
|
||||
{
|
||||
/**
|
||||
* 通过scode和sid获取AccessToken
|
||||
* @route({"GET","/token"})
|
||||
* @param({"scode","$._GET.scode"}) 客户端生成的Scode
|
||||
* @param({"sid","$._GET.sid"}) 服务器返回的sid
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
*/
|
||||
public function getAccessToken($scode,$sid) {
|
||||
// 当前时间戳,通过sid和scode获取用户信息,必须保障sid未过期
|
||||
$nowtime = time();
|
||||
|
||||
// 根据sid 查询用户信息
|
||||
$res = Sql::select('syweb_users_qq.access_id,syweb_users_qq.access_key')
|
||||
->from('syweb_users_qq')
|
||||
->where('syweb_users_qq.sid=? and syweb_users_qq.scode=? and syweb_users_qq.sid_expire_time>?', $sid,$scode,$nowtime)
|
||||
->get($this->db ,null);
|
||||
|
||||
if(count($res)>0){
|
||||
$result[0]["error"] = "0";
|
||||
$result[0]["access_id"] = $res[0]["access_id"];
|
||||
$result[0]["access_key"] = $res[0]["access_key"];
|
||||
}else{
|
||||
$result[0]["error"] = "0";
|
||||
$result[0]["error_code"] = 1; // 用户未登录或登录信息过期
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过AccessToken获取sid
|
||||
* @route({"GET","/token_login"})
|
||||
* @param({"access_id","$._GET.access_id"})
|
||||
* @param({"access_key","$._GET.access_key"})
|
||||
* @param({"scode","$._GET.scode"}) 客户端生成的Scode
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
*/
|
||||
public function token_login($access_id,$access_key,$scode) {
|
||||
// 当前时间戳,通过sid和scode获取用户信息,必须保障sid未过期
|
||||
$nowTime = time();
|
||||
|
||||
$res = Sql::select('syweb_users_qq.sid')
|
||||
->from('syweb_users_qq')
|
||||
->where('syweb_users_qq.access_id=? and syweb_users_qq.access_key=? and syweb_users_qq.scode=? and access_expire_time>?', $access_id,$access_key,$scode,$nowTime)
|
||||
->get($this->db ,null);
|
||||
|
||||
$result = array();
|
||||
if(count($res)>0){ // 存在对应的用户
|
||||
$result[0]["error"] = "0";
|
||||
$result[0]["sid"] = $res[0]['sid'];
|
||||
}else{
|
||||
$result[0]["error"] = "1";
|
||||
$result[0]["error_code"] = 1;// 无效的AccessToken
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/** @inject("ioc_factory") */
|
||||
private $factory;
|
||||
/**
|
||||
* @property({"default":"@db"})
|
||||
* @var PDO
|
||||
*/
|
||||
public $db;
|
||||
// 此处删除了代码
|
||||
}
|
||||
1184
codes/agent/game-docker/api/source/apis/cloud.php
Normal file
1184
codes/agent/game-docker/api/source/apis/cloud.php
Normal file
File diff suppressed because it is too large
Load Diff
85
codes/agent/game-docker/api/source/apis/commendpic.php
Normal file
85
codes/agent/game-docker/api/source/apis/commendpic.php
Normal file
@@ -0,0 +1,85 @@
|
||||
<?php
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, PATCH, DELETE");
|
||||
header("Access-Control-Allow-Headers: Content-Type, Authorization, Content-Length, X-Requested-With");
|
||||
header("Access-Control-Allow-Credentials: true");
|
||||
header("Content-Type: text/html; charset=utf-8");
|
||||
|
||||
/**
|
||||
* 门店幻灯相关接口
|
||||
*/
|
||||
use phprs\util\Verify;
|
||||
use phprs\util\exceptions\Forbidden;
|
||||
use phprs\util\Logger;
|
||||
use phprs\util\exceptions\NotFound;
|
||||
use phprs\ezsql\Sql;
|
||||
use phprs\util\exceptions\BadRequest;
|
||||
|
||||
require_once 'apiBase.php';
|
||||
|
||||
/**
|
||||
*
|
||||
* 幻灯片管理
|
||||
* @path("/commendpic")
|
||||
*/
|
||||
class Commendpic extends apiBase {
|
||||
/**
|
||||
* 获取门店幻灯片(错误代码:15051-15100)
|
||||
* @route({"POST","/list"})
|
||||
* @param({"devkey","$._POST.devkey"}) 开发者key
|
||||
* @param({"market_key","$._POST.market_key"}) market_key
|
||||
* @param({"sign","$._POST.sign"}) sign
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
* @return("body")
|
||||
*/
|
||||
public function getCommendPicList($devkey='',$market_key='',$sign='') {
|
||||
$result = array();
|
||||
|
||||
$verify_result = $this->verifyMarketApi($devkey);
|
||||
if( is_error_api($verify_result) ){
|
||||
return $verify_result;
|
||||
}
|
||||
|
||||
if( empty($market_key) ) {
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 11001;
|
||||
$result["msg"] = "未传入market_key参数";
|
||||
return $result;
|
||||
}
|
||||
$marketList = Sql::select('a.*')
|
||||
->from('syweb_market a')
|
||||
->where('a.market_key=?',$market_key)
|
||||
->get($this->db ,null);
|
||||
if( empty($marketList) || count($marketList)<=0 ) {
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 11002;
|
||||
$result["msg"] = "market_key无效";
|
||||
return $result;
|
||||
}
|
||||
$marketList = $marketList[0];
|
||||
|
||||
$commendpicList = Sql::select('a.*')
|
||||
->from('syweb_market_commend_pic a')
|
||||
->where('a.market_key=?',$marketList["market_key"])
|
||||
->get($this->db ,null);
|
||||
if( !empty($commendpicList) && count($commendpicList)>0 ) {
|
||||
foreach ($commendpicList as &$picInfo) {
|
||||
$picInfo["pic_path"] = env('SITE_OPEN_URL', 'http://open.tscce.cn').$picInfo["pic_path"];
|
||||
}
|
||||
}
|
||||
|
||||
$result["error"] = '0';
|
||||
$result["data"] = $commendpicList;
|
||||
$result["msg"] = "获取门店轮播信息成功!";
|
||||
return $result;
|
||||
}
|
||||
|
||||
/** @inject("ioc_factory") */
|
||||
private $factory;
|
||||
/**
|
||||
* @property({"default":"@db"})
|
||||
* @var PDO
|
||||
*/
|
||||
public $db;
|
||||
// 此处删除了代码
|
||||
}
|
||||
195
codes/agent/game-docker/api/source/apis/coupon.php
Normal file
195
codes/agent/game-docker/api/source/apis/coupon.php
Normal file
@@ -0,0 +1,195 @@
|
||||
<?php
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, PATCH, DELETE");
|
||||
header("Access-Control-Allow-Headers: Content-Type, Authorization, Content-Length, X-Requested-With");
|
||||
header("Access-Control-Allow-Credentials: true");
|
||||
header("Content-Type: text/html; charset=utf-8");
|
||||
|
||||
/**
|
||||
* 优惠券接口
|
||||
*/
|
||||
use phprs\util\Verify;
|
||||
use phprs\util\exceptions\Forbidden;
|
||||
use phprs\util\Logger;
|
||||
use phprs\util\exceptions\NotFound;
|
||||
use phprs\ezsql\Sql;
|
||||
use phprs\util\exceptions\BadRequest;
|
||||
|
||||
require_once 'apiBase.php';
|
||||
/**
|
||||
*
|
||||
* 优惠券接口
|
||||
* @path("/coupon")
|
||||
*/
|
||||
class Coupon extends apiBase{
|
||||
public $activityInfo; // 当前活动信息
|
||||
|
||||
public function commonVerify($appid,$devkey,$sid,$scode,$market_key,$activity_key) {
|
||||
$result = array();
|
||||
|
||||
// 验证公共参数是否合法
|
||||
parent::init($appid,$devkey,$sid,$scode,$market_key);
|
||||
$verify_result = parent::verify();
|
||||
|
||||
// 判断公共验证是否存在错误
|
||||
if( is_error_api($verify_result) ){
|
||||
return $verify_result;
|
||||
}
|
||||
|
||||
if( empty($activity_key) ) {
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 13000;
|
||||
$result["msg"] = "请传入对应的活动Key";
|
||||
return $result;
|
||||
}
|
||||
|
||||
$activityList = Sql::select('a.*')
|
||||
->from('syweb_business_activity a')
|
||||
->where('a.activity_key=?',$activity_key)
|
||||
->get($this->db ,null);
|
||||
if( empty($activityList) || count($activityList)<=0 ) {
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 13001;
|
||||
$result["msg"] = "指定的活动不存在或已经下架";
|
||||
return $result;
|
||||
}
|
||||
$this->activityInfo = $activityList[0];
|
||||
|
||||
$activityMarketList = Sql::select('a.*')
|
||||
->from('syweb_business_activity_market a')
|
||||
->where('a.activity_key=? and a.market_key=?',$activity_key,$market_key)
|
||||
->get($this->db ,null);
|
||||
if( empty($activityMarketList) || count($activityMarketList)<=0 ) {
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 13002;
|
||||
$result["msg"] = "当前门店未参与该活动!";
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取优惠券(错误代码:12000--12050)
|
||||
* @route({"POST","/exchange"})
|
||||
* @param({"appid","$._POST.appid"}) 所属应用
|
||||
* @param({"devkey","$._POST.devkey"}) 开发者Key
|
||||
* @param({"sid","$._POST.sid"}) 临时会员ID
|
||||
* @param({"scode","$._POST.scode"}) 客户端票据
|
||||
* @param({"market_key","$._POST.market_key"}) market_key
|
||||
* @param({"activity_key","$._POST.activity_key"}) activity_key
|
||||
* @param({"useprice","$._POST.useprice"}) useprice
|
||||
* @param({"price","$._POST.price"}) price
|
||||
* @param({"validDay","$._POST.validDay"}) validDay
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
*/
|
||||
public function exchange($appid='', $devkey='',$sid='',$scode='',$market_key='',$activity_key='',$useprice=0,$price=0,$validDay=0) {
|
||||
$result = array();
|
||||
$P = $_POST;
|
||||
|
||||
// 判断公共验证是否存在错误
|
||||
$verify_result = $this->commonVerify($appid,$devkey,$sid,$scode,$market_key,$activity_key);
|
||||
|
||||
if( is_error_api($verify_result) ){
|
||||
return json_encode($verify_result,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
if( $this->userInfo["auth_type"]==0 ) {
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12000;
|
||||
$result["msg"] = "创建优惠券失败";
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
} else if( $this->userInfo["auth_type"]==1 ) {
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12000;
|
||||
$result["msg"] = "创建优惠券失败";
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
} else if( $this->userInfo["auth_type"]==2 ) {
|
||||
if ( !is_numeric($useprice) ) {
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12001;
|
||||
$result["msg"] = "满多少可用必须为数字!";
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
if ( !is_numeric($price) ) {
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12002;
|
||||
$result["msg"] = "减免金额必须为数字!";
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
if ( !is_numeric($validDay) ) {
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12003;
|
||||
$result["msg"] = "有效天数必须为数字!";
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
$appid = "G3CI8FQF";
|
||||
$appkey = "28de5f4a54cbbb62b2264ab555ff7f62";
|
||||
|
||||
$url = "http://www.0792it.com/partnerApi/GetSpidFromUid.ashx";
|
||||
$url .= "?appid=".$appid;
|
||||
$url .= "&appkey=".$appkey;
|
||||
$url .= "&uid=".$this->userInfo["openid"];
|
||||
|
||||
$response = ihttp_get($url);
|
||||
if( empty($response) ) {
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12004;
|
||||
$result["msg"] = "获取授权信息错误,登录失败!";
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
$response = @json_decode($response['content'], true);
|
||||
|
||||
$spid = $response["spid"];
|
||||
$accessToken = $response["accessToken"];
|
||||
|
||||
// 开始获取用户信息
|
||||
$url = "http://www.0792it.com/partnerApi/CreatShopCoupon.ashx";
|
||||
$paramers = array();
|
||||
|
||||
$paramers["accessToken"] = $accessToken;
|
||||
$paramers["GameName"] = $this->activityInfo["activity_name"];
|
||||
$paramers["s_price"] = $price;
|
||||
$paramers["s_useprice"] = $useprice;
|
||||
$paramers["Shopid"] = $this->marketInfo["jkx_market_key"];
|
||||
$paramers["spid"] = $spid;
|
||||
$paramers["validDay"] = $validDay;
|
||||
$paramers["secret"] = "ecd10d48daf3138b88727bc65ca3e0bd";
|
||||
$paramerStr = $this->ToUrlParams($paramers);
|
||||
$sign = md5($paramerStr);
|
||||
|
||||
$paramerStr .= "&sign=".$sign;
|
||||
$url .= "?".$paramerStr;
|
||||
|
||||
|
||||
$response = ihttp_get($url);
|
||||
if( empty($response) ) {
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12005;
|
||||
$result["msg"] = "创建优惠券失败!";
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
$response = @json_decode($response['content'], true);
|
||||
|
||||
$retCode = $response["RetCode"];
|
||||
if( $retCode==1 || $retCode==3 || $retCode==5 ) {
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 12005;
|
||||
$result["msg"] = "创建优惠券失败,错误消息为:".$response["RetMsg"];
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
$result["error"] = '0';
|
||||
$result["msg"] = "创建优惠券成功!";
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
}
|
||||
|
||||
/** @inject("ioc_factory") */
|
||||
private $factory;
|
||||
/**
|
||||
* @property({"default":"@db"})
|
||||
* @var PDO
|
||||
*/
|
||||
public $db;
|
||||
// 此处删除了代码
|
||||
}
|
||||
215
codes/agent/game-docker/api/source/apis/jifen.php
Normal file
215
codes/agent/game-docker/api/source/apis/jifen.php
Normal file
@@ -0,0 +1,215 @@
|
||||
<?php
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, PATCH, DELETE");
|
||||
header("Access-Control-Allow-Headers: Content-Type, Authorization, Content-Length, X-Requested-With");
|
||||
header("Access-Control-Allow-Credentials: true");
|
||||
header("Content-Type: text/html; charset=utf-8");
|
||||
|
||||
/**
|
||||
* 用户积分接口
|
||||
*/
|
||||
use phprs\util\Verify;
|
||||
use phprs\util\exceptions\Forbidden;
|
||||
use phprs\util\Logger;
|
||||
use phprs\util\exceptions\NotFound;
|
||||
use phprs\ezsql\Sql;
|
||||
use phprs\util\exceptions\BadRequest;
|
||||
|
||||
require_once 'apiBase.php';
|
||||
/**
|
||||
*
|
||||
* 用户积分接口
|
||||
* @path("/jifen")
|
||||
*/
|
||||
class Jifen extends apiBase{
|
||||
/**
|
||||
* 更新用户积分(错误代码:13000-13050)
|
||||
* @route({"POST","/update"})
|
||||
* @param({"appid","$._POST.appid"}) 所属应用
|
||||
* @param({"devkey","$._POST.devkey"}) 开发者Key
|
||||
* @param({"sid","$._POST.sid"}) 临时会员ID
|
||||
* @param({"scode","$._POST.scode"}) 客户端票据
|
||||
* @param({"jifencount","$._POST.jifencount"}) 变更积分数量
|
||||
* @param({"content","$._POST.content"}) 操作说明
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
*/
|
||||
public function jifenUpdate($appid='', $devkey='',$sid='',$scode='',$jifencount='',$content='') {
|
||||
// 验证公共参数是否合法
|
||||
parent::init($appid,$devkey,$sid,$scode);
|
||||
$verify_result = parent::verify();
|
||||
|
||||
if( is_error_api($verify_result) ){
|
||||
return json_encode($verify_result,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
$result = array();
|
||||
|
||||
if ( !is_numeric($jifencount) ) {
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 13000;
|
||||
$result["msg"] = "请正确传入变更积分的数量";
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
$old_jifen = $this->userInfo["market_jifen"];
|
||||
if( empty($old_jifen) || !is_numeric($old_jifen) ){
|
||||
$old_jifen = 0;
|
||||
$this->userInfo["market_jifen"] = 0;
|
||||
}
|
||||
|
||||
$old_jifen = $old_jifen + $jifencount;
|
||||
$this->userInfo["market_jifen"] = $old_jifen;
|
||||
if( $old_jifen<0 ){
|
||||
$old_jifen = 0;
|
||||
$this->userInfo["market_jifen"] = 0;
|
||||
}
|
||||
|
||||
$updateSql = Sql::update('syweb_users');
|
||||
$updateSql->set("market_jifen",$old_jifen);
|
||||
$condition = array();
|
||||
$conditionStr = "";
|
||||
|
||||
if( empty($conditionStr) ){
|
||||
$conditionStr = " id= ".$this->userInfo["id"];
|
||||
}else{
|
||||
$conditionStr .= " and id= ".$this->userInfo["id"];
|
||||
}
|
||||
if(!empty($conditionStr)){
|
||||
$updateSql->where($conditionStr);
|
||||
}
|
||||
|
||||
$pdo = $this->db;
|
||||
$pdo->beginTransaction();
|
||||
$updateCount = $updateSql->exec($pdo);
|
||||
$pdo->commit();
|
||||
|
||||
// 假如是聚开心授权的话,还需要同步修改聚开心那边
|
||||
if( $this->userInfo["auth_type"]==2 ) {
|
||||
$appid = "G3CI8FQF";
|
||||
$appkey = "28de5f4a54cbbb62b2264ab555ff7f62";
|
||||
|
||||
$url = "http://www.0792it.com/partnerApi/GetSpidFromUid.ashx";
|
||||
$url .= "?appid=".$appid;
|
||||
$url .= "&appkey=".$appkey;
|
||||
$url .= "&uid=".$this->userInfo["openid"];
|
||||
|
||||
$response = ihttp_get($url);
|
||||
if( empty($response) ) {
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 13001;
|
||||
$result["msg"] = "获取授权信息错误,登录失败!";
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
$response = @json_decode($response['content'], true);
|
||||
|
||||
$spid = $response["spid"];
|
||||
$accessToken = $response["accessToken"];
|
||||
|
||||
|
||||
// 开始获取用户信息
|
||||
$url = "http://www.0792it.com/partnerApi/SetIntegral.ashx";
|
||||
$url .= "?spid=".$spid;
|
||||
$url .= "&accessToken=".$accessToken;
|
||||
$act = 1;
|
||||
if( $jifencount<0 ) {
|
||||
$jifencount = -$jifencount;
|
||||
$act = 2;
|
||||
}
|
||||
$url .= "&point=".$jifencount;
|
||||
$url .= "&act=".$act;
|
||||
$url .= "&content=".$content;
|
||||
|
||||
$sign = "accessToken=".$accessToken."&act=".$act."&content=".$content."&point=".$jifencount."&spid=".$spid."&secret=ecd10d48daf3138b88727bc65ca3e0bd";
|
||||
$sign = md5($sign);
|
||||
$url .= "&sign=".$sign;
|
||||
|
||||
$response = ihttp_get($url);
|
||||
if( empty($response) ) {
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 13001;
|
||||
$result["msg"] = "获取授权信息错误,登录失败!";
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
$response = @json_decode($response['content'], true);
|
||||
|
||||
$retCode = $response["RetCode"];
|
||||
if( $retCode==1 ) {
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 13002;
|
||||
$result["msg"] = "同步聚开心积分错误,错误消息为:" + $response["RetMsg"];
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
$jkxUserList = Sql::select('a.*')
|
||||
->from('syweb_users_jkx a')
|
||||
->where('a.uid=?',$this->userInfo["id"])
|
||||
->get($this->db ,null);
|
||||
if( empty($jkxUserList) || count($jkxUserList)<=0 ) {
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 13003;
|
||||
$result["msg"] = "子账户无效";
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
$jkxUserInfo = $jkxUserList[0];
|
||||
|
||||
$updateSql = Sql::update('syweb_users_jkx');
|
||||
if( $act==1 ) {
|
||||
$updateSql->set("integral",$jkxUserInfo["integral"] + $jifencount);
|
||||
} else {
|
||||
$updateSql->set("integral",$jkxUserInfo["integral"] - $jifencount);
|
||||
}
|
||||
$conditionStr = " id= ".$jkxUserInfo["id"];
|
||||
$updateSql->where($conditionStr);
|
||||
|
||||
$pdo = $this->db;
|
||||
$pdo->beginTransaction();
|
||||
$updateSql->exec($pdo);
|
||||
$pdo->commit();
|
||||
}
|
||||
|
||||
$result["error"] = '0';
|
||||
$result["message"] = '积分修改成功。';
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户积分余额(错误代码:11051-11100)
|
||||
* @route({"POST","/"})
|
||||
* @param({"appid","$._POST.appid"}) 应用appid
|
||||
* @param({"devkey","$._POST.devkey"}) 开发者key
|
||||
* @param({"sid","$._POST.sid"}) 服务器返回的sid
|
||||
* @param({"scode","$._POST.scode"}) 客户端生成的scode
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
*/
|
||||
public function queryUserJifen($appid="",$devkey="",$sid="",$scode="") {
|
||||
// 验证公共参数是否合法
|
||||
parent::init($appid,$devkey,$sid,$scode);
|
||||
$verify_result = parent::verify();
|
||||
|
||||
if( !is_error_api($verify_result) ){
|
||||
$result = array();
|
||||
|
||||
$jifen_count = $this->userInfo['jifen_account'];
|
||||
if( !empty($jifen_count) && is_numeric($jifen_count) ){
|
||||
$result["error"] = "0";
|
||||
$result["jifen_count"] = $jifen_count;
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
} else {
|
||||
$result["error"] = "0";
|
||||
$result["jifen_count"] = 0;
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
}else{
|
||||
return json_encode($verify_result,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
}
|
||||
|
||||
/** @inject("ioc_factory") */
|
||||
private $factory;
|
||||
/**
|
||||
* @property({"default":"@db"})
|
||||
* @var PDO
|
||||
*/
|
||||
public $db;
|
||||
// 此处删除了代码
|
||||
}
|
||||
1848
codes/agent/game-docker/api/source/apis/login.php
Normal file
1848
codes/agent/game-docker/api/source/apis/login.php
Normal file
File diff suppressed because it is too large
Load Diff
1861
codes/agent/game-docker/api/source/apis/login.php.bak
Normal file
1861
codes/agent/game-docker/api/source/apis/login.php.bak
Normal file
File diff suppressed because it is too large
Load Diff
55
codes/agent/game-docker/api/source/apis/loginBack.php
Normal file
55
codes/agent/game-docker/api/source/apis/loginBack.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, PATCH, DELETE");
|
||||
header("Access-Control-Allow-Headers: Content-Type, Authorization, Content-Length, X-Requested-With");
|
||||
header("Access-Control-Allow-Credentials: true");
|
||||
header("Content-Type: text/html; charset=utf-8");
|
||||
|
||||
/**
|
||||
* 登录相关接口
|
||||
*/
|
||||
use phprs\util\Verify;
|
||||
use phprs\util\exceptions\Forbidden;
|
||||
use phprs\util\Logger;
|
||||
use phprs\util\exceptions\NotFound;
|
||||
use phprs\ezsql\Sql;
|
||||
use phprs\util\exceptions\BadRequest;
|
||||
|
||||
require_once 'apiBase.php';
|
||||
|
||||
/**
|
||||
*
|
||||
* 登录管理
|
||||
* @path("/back_login")
|
||||
*/
|
||||
class LoginBack extends apiBase
|
||||
{
|
||||
/**
|
||||
* 获得登录方式
|
||||
* @route({"GET","/"})
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
* @return("body")
|
||||
*/
|
||||
public function getLoginType()
|
||||
{
|
||||
$result = array();
|
||||
$result[0]["name"] = "微信登录";
|
||||
$result[0]["url"] = $this->getFullUrl('/api/login/weixin');
|
||||
$result[0]["third"] = "weixin";
|
||||
//$result[1]["name"] = "QQ登录";
|
||||
//$result[1]["url"] = $this->getFullUrl('/api/login/qq');
|
||||
//$result[1]["third"] = "qq";
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/** @inject("ioc_factory") */
|
||||
private $factory;
|
||||
/**
|
||||
* @property({"default":"@db"})
|
||||
* @var PDO
|
||||
*/
|
||||
public $db;
|
||||
// 此处删除了代码
|
||||
}
|
||||
529
codes/agent/game-docker/api/source/apis/manager.php
Normal file
529
codes/agent/game-docker/api/source/apis/manager.php
Normal file
@@ -0,0 +1,529 @@
|
||||
<?php
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, PATCH, DELETE");
|
||||
header("Access-Control-Allow-Headers: Content-Type, Authorization, Content-Length, X-Requested-With");
|
||||
header("Access-Control-Allow-Credentials: true");
|
||||
header("Content-Type: text/html; charset=utf-8");
|
||||
|
||||
/**
|
||||
* 后台应用管理员登录
|
||||
*/
|
||||
use phprs\util\Verify;
|
||||
use phprs\util\exceptions\Forbidden;
|
||||
use phprs\util\Logger;
|
||||
use phprs\util\exceptions\NotFound;
|
||||
use phprs\ezsql\Sql;
|
||||
use phprs\util\exceptions\BadRequest;
|
||||
|
||||
/**
|
||||
*
|
||||
* 应用管理员登录接口
|
||||
* @path("/manager")
|
||||
*/
|
||||
class Manager {
|
||||
/**
|
||||
* 后台管理员通过账号密码登录
|
||||
* @route({"POST","/"})
|
||||
* @param({"appid","$._POST.appid"}) 应用appid
|
||||
* @param({"devkey","$._POST.devkey"}) 开发者key
|
||||
* @param({"username","$._POST.username"}) 用户名
|
||||
* @param({"password","$._POST.password"}) 用户密码
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
*/
|
||||
public function login($appid,$devkey,$username,$password) {
|
||||
if(empty($appid)){
|
||||
$result["status"] = '0';
|
||||
$result["message"] = '请传入appid参数。';
|
||||
return $result;
|
||||
}
|
||||
if(empty($devkey)){
|
||||
$result["status"] = '0';
|
||||
$result["message"] = '请传入devkey参数。';
|
||||
return $result;
|
||||
}
|
||||
if(empty($username)){
|
||||
$result["status"] = '0';
|
||||
$result["message"] = '请传入username参数。';
|
||||
return $result;
|
||||
}
|
||||
if(empty($password)){
|
||||
$result["status"] = '0';
|
||||
$result["message"] = '请传入password参数。';
|
||||
return $result;
|
||||
}
|
||||
// 加密管理员密码
|
||||
$password = md5($password);
|
||||
$res = Sql::select('syweb_admin.*')
|
||||
->from('syweb_admin,syweb_app')
|
||||
->where('syweb_admin.app_id=syweb_app.id and syweb_app.appid=? and syweb_admin.username=? and syweb_admin.password=? and syweb_admin.type=3', $appid,$username,$password)
|
||||
->get($this->db ,null);
|
||||
|
||||
if(count($res)>0){
|
||||
$result[0]["error"] = "0";
|
||||
$result[0]["data"] = $res[0];
|
||||
}else{
|
||||
$result[0]["error"] = "1";
|
||||
$result[0]["error_code"] = 1; // 用户名或密码不存在
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加应用管理员(错误代码:10200-10250)
|
||||
* @route({"POST","/add"})
|
||||
* @param({"appid","$._POST.appid"}) 应用appid
|
||||
* @param({"devkey","$._POST.devkey"}) 开发者key
|
||||
* @param({"username","$._POST.username"}) 用户名账号
|
||||
* @param({"nickname","$._POST.nickname"}) 用户昵称
|
||||
* @param({"password","$._POST.password"}) 用户密码
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
*/
|
||||
public function add($appid="",$devkey="",$username="",$nickname="",$password="") {
|
||||
$result = array();
|
||||
|
||||
$insertData = array();
|
||||
if( empty($appid) ){
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 10001;
|
||||
$result["msg"] = "未传入appid参数";
|
||||
return $result;
|
||||
}
|
||||
|
||||
if( empty($devkey) ){
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 10002;
|
||||
$result["msg"] = "未传入devkey参数";
|
||||
return $result;
|
||||
}
|
||||
$devList = Sql::select('syweb_admin.*')
|
||||
->from('syweb_admin')
|
||||
->where('syweb_admin.type=2 and syweb_admin.devkey=? and syweb_admin.status=1',$devkey)
|
||||
->get($this->db ,null);
|
||||
if( empty($devList) || count($devList)<=0 ){
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 10003;
|
||||
$result["msg"] = "devkey无效";
|
||||
return $result;
|
||||
}
|
||||
$devInfo = $devList[0];
|
||||
|
||||
$appList = Sql::select('syweb_app.*')
|
||||
->from('syweb_app')
|
||||
->where('syweb_app.appid=? and syweb_app.dev_id=? and status=1', $appid,$devInfo['id'])
|
||||
->get($this->db ,null);
|
||||
if( empty($appList) || count($appList)<=0 ){
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 10004;
|
||||
$result["msg"] = "指定的应用不存在或未被审核";
|
||||
return $result;
|
||||
}
|
||||
$appInfo = $appList[0];
|
||||
|
||||
$insertData['app_id'] = $appInfo["id"];
|
||||
if( empty($username) ){
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 10200;
|
||||
$result["msg"] = '请输入管理员账号。';
|
||||
return $result;
|
||||
}
|
||||
if( !checklen($username) ){
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 10201;
|
||||
$result["msg"] = '管理员用户名必须是大于5位小于15位!';
|
||||
return $result;
|
||||
}
|
||||
$managerInfo = Sql::select('syweb_admin.*')
|
||||
->from('syweb_admin')
|
||||
->where('syweb_admin.username=?', $username)
|
||||
->get($this->db ,null);
|
||||
if( !empty($managerInfo) && count($managerInfo)>0 ){
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 10202;
|
||||
$result["msg"] = '指定的管理员账号已经存在。';
|
||||
return $result;
|
||||
}
|
||||
$insertData['username'] = $username;
|
||||
|
||||
if( empty($password) ){
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 10203;
|
||||
$result["msg"] = '请传入管理员密码!';
|
||||
return $result;
|
||||
}
|
||||
if( !checklen($password) ){
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 10204;
|
||||
$result["msg"] = '管理员密码必须是大于8位小于16位!';
|
||||
return $result;
|
||||
}
|
||||
$insertData['password'] = md5($password);
|
||||
|
||||
if( empty($nickname) ){
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 10205;
|
||||
$result["msg"] = '请输入管理员昵称!';
|
||||
return $result;
|
||||
}
|
||||
$insertData['nickname'] = $nickname;
|
||||
$insertData['type'] = 3;
|
||||
$insertData['status'] = 1;
|
||||
$insertData['createtime'] = time();
|
||||
|
||||
$pdo = $this->db;
|
||||
$pdo->beginTransaction();
|
||||
$managerId = Sql::insertInto('syweb_admin')->values($insertData)->exec($pdo)->lastInsertId();
|
||||
$pdo->commit();
|
||||
if ( !empty($managerId) && is_numeric($managerId) && $managerId>0 ) {
|
||||
unset($insertData["password"]);
|
||||
unset($insertData["type"]);
|
||||
|
||||
$insertData["id"] = $managerId;
|
||||
$result["error"] = '0';
|
||||
$result["data"] = $insertData;
|
||||
$result["msg"] = "添加管理员成功。";
|
||||
return $result;
|
||||
}else{
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 10206;
|
||||
$result["msg"] = '添加管理员失败。';
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改应用管理员(错误代码:10200-10250)
|
||||
* @route({"POST","/edit"})
|
||||
* @param({"appid","$._POST.appid"}) 应用appid
|
||||
* @param({"devkey","$._POST.devkey"}) 开发者key
|
||||
* @param({"username","$._POST.username"}) 用户名账号
|
||||
* @param({"nickname","$._POST.nickname"}) 用户昵称
|
||||
* @param({"password","$._POST.password"}) 用户密码
|
||||
* @param({"oldpassword","$._POST.oldpassword"}) 用户原始密码
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
*/
|
||||
public function edit($appid="",$devkey="",$username="",$nickname="",$password="",$oldpassword="") {
|
||||
$result = array();
|
||||
|
||||
$updateData = array();
|
||||
if( empty($appid) ){
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 10001;
|
||||
$result["msg"] = "未传入appid参数";
|
||||
return $result;
|
||||
}
|
||||
|
||||
if( empty($devkey) ){
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 10002;
|
||||
$result["msg"] = "未传入devkey参数";
|
||||
return $result;
|
||||
}
|
||||
$devList = Sql::select('syweb_admin.*')
|
||||
->from('syweb_admin')
|
||||
->where('syweb_admin.type=2 and syweb_admin.devkey=? and syweb_admin.status=1',$devkey)
|
||||
->get($this->db ,null);
|
||||
if( empty($devList) || count($devList)<=0 ){
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 10003;
|
||||
$result["msg"] = "devkey无效";
|
||||
return $result;
|
||||
}
|
||||
$devInfo = $devList[0];
|
||||
|
||||
$appList = Sql::select('syweb_app.*')
|
||||
->from('syweb_app')
|
||||
->where('syweb_app.appid=? and syweb_app.dev_id=? and status=1', $appid,$devInfo['id'])
|
||||
->get($this->db ,null);
|
||||
if( empty($appList) || count($appList)<=0 ){
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 10004;
|
||||
$result["msg"] = "指定的应用不存在或未被审核";
|
||||
return $result;
|
||||
}
|
||||
$appInfo = $appList[0];
|
||||
|
||||
if( empty($username) ){
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 10200;
|
||||
$result["msg"] = '请输入要修改的管理员账号。';
|
||||
return $result;
|
||||
}
|
||||
$managerInfo = Sql::select('syweb_admin.*')
|
||||
->from('syweb_admin')
|
||||
->where('syweb_admin.username=?',$username)
|
||||
->get($this->db ,null);
|
||||
if( empty($managerInfo) || count($managerInfo)<0 ){
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 10201;
|
||||
$result["msg"] = '指定的管理员账号不存在。';
|
||||
return $result;
|
||||
}
|
||||
if( empty($password) && empty($nickname) ){
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 10202;
|
||||
$result["msg"] = '请指定修改昵称或是密码';
|
||||
return $result;
|
||||
}
|
||||
|
||||
if( !empty($password) && !checklen($password) ){
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 10203;
|
||||
$result["msg"] = '管理员密码必须是大于8位小于16位!';
|
||||
return $result;
|
||||
}
|
||||
|
||||
if( !empty($password) && empty($oldpassword) ){
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 10204;
|
||||
$result["msg"] = '要修改密码必须提供原密码。';
|
||||
return $result;
|
||||
}
|
||||
|
||||
if( !empty($password) ){
|
||||
$managerInfo = Sql::select('syweb_admin.*')
|
||||
->from('syweb_admin')
|
||||
->where('syweb_admin.username=? and syweb_admin.password=?',$username,md5($oldpassword))
|
||||
->get($this->db ,null);
|
||||
if( empty($managerInfo) || count($managerInfo)<0 ){
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 10205;
|
||||
$result["msg"] = '原始密码不符。';
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
$fieldsCount = 0;
|
||||
$updateSql = Sql::update('syweb_admin');
|
||||
if ( !empty($nickname) ) {
|
||||
$updateSql->set("nickname",$nickname);
|
||||
$fieldsCount = $fieldsCount +1;
|
||||
}
|
||||
if ( !empty($password) ) {
|
||||
$updateSql->set("password",md5($password));
|
||||
$fieldsCount = $fieldsCount +1;
|
||||
}
|
||||
|
||||
// 修改限定条件 begin
|
||||
$condition = array();
|
||||
$conditionStr = " username='".$username."'";
|
||||
if(!empty($conditionStr)){
|
||||
$updateSql->where($conditionStr);
|
||||
}
|
||||
// 修改限定条件 end
|
||||
|
||||
$pdo = $this->db;
|
||||
$pdo->beginTransaction();
|
||||
|
||||
if($fieldsCount>0){
|
||||
$updateCount = $updateSql->exec($pdo);
|
||||
}
|
||||
$pdo->commit();
|
||||
if( !$updateCount ){
|
||||
$result["error"] = '0';
|
||||
$result["msg"] = '数据修改成功。';
|
||||
return $result;
|
||||
}else{
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 10206;
|
||||
$result["msg"] = '数据修改失败。';
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加应用管理员(错误代码:10300-10350)
|
||||
* @route({"POST","/delete"})
|
||||
* @param({"appid","$._POST.appid"}) 应用appid
|
||||
* @param({"devkey","$._POST.devkey"}) 开发者key
|
||||
* @param({"username","$._POST.username"}) 用户名账号
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
*/
|
||||
public function delete($appid="",$devkey="",$username="") {
|
||||
$result = array();
|
||||
|
||||
$insertData = array();
|
||||
if( empty($appid) ){
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 10001;
|
||||
$result["msg"] = "未传入appid参数";
|
||||
return $result;
|
||||
}
|
||||
|
||||
if( empty($devkey) ){
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 10002;
|
||||
$result["msg"] = "未传入devkey参数";
|
||||
return $result;
|
||||
}
|
||||
$devList = Sql::select('syweb_admin.*')
|
||||
->from('syweb_admin')
|
||||
->where('syweb_admin.type=2 and syweb_admin.devkey=? and syweb_admin.status=1',$devkey)
|
||||
->get($this->db ,null);
|
||||
if( empty($devList) || count($devList)<=0 ){
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 10003;
|
||||
$result["msg"] = "devkey无效";
|
||||
return $result;
|
||||
}
|
||||
$devInfo = $devList[0];
|
||||
|
||||
$appList = Sql::select('syweb_app.*')
|
||||
->from('syweb_app')
|
||||
->where('syweb_app.appid=? and syweb_app.dev_id=? and status=1', $appid,$devInfo['id'])
|
||||
->get($this->db ,null);
|
||||
if( empty($appList) || count($appList)<=0 ){
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 10004;
|
||||
$result["msg"] = "指定的应用不存在或未被审核";
|
||||
return $result;
|
||||
}
|
||||
$appInfo = $appList[0];
|
||||
|
||||
$insertData['app_id'] = $appInfo["id"];
|
||||
if( empty($username) ){
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 10300;
|
||||
$result["msg"] = '请输入要删除的管理员账号。';
|
||||
return $result;
|
||||
}
|
||||
|
||||
$managerInfo = Sql::select('syweb_admin.*')
|
||||
->from('syweb_admin')
|
||||
->where('syweb_admin.username=?', $username)
|
||||
->get($this->db ,null);
|
||||
if( empty($managerInfo) || count($managerInfo)<=0 ){
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 10301;
|
||||
$result["msg"] = '指定的管理员账号不存在。';
|
||||
return $result;
|
||||
}
|
||||
|
||||
$condition .= " `username` = '".$username."'";
|
||||
$pdo = $this->db;
|
||||
$pdo->beginTransaction();
|
||||
$delResult = Sql::deleteFrom('syweb_admin')->where($condition)->exec($this->db);
|
||||
$pdo->commit();
|
||||
|
||||
$managerInfo = Sql::select('syweb_admin.*')
|
||||
->from('syweb_admin')
|
||||
->where('syweb_admin.username=?', $username)
|
||||
->get($this->db ,null);
|
||||
if( empty($managerInfo) || count($managerInfo)<=0 ){
|
||||
$result["error"] = '0';
|
||||
$result["msg"] = "删除管理员成功。";
|
||||
return $result;
|
||||
}else{
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 10302;
|
||||
$result["msg"] = '删除管理员失败。';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询指定应用中的管理员列表
|
||||
* @route({"POST","/list"})
|
||||
* @param({"appid","$._POST.appid"}) 应用appid
|
||||
* @param({"devkey","$._POST.devkey"}) 开发者key
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
*/
|
||||
public function queryList($appid="",$devkey="") {
|
||||
$fields = " syweb_admin.id,syweb_admin.username,syweb_admin.nickname,syweb_admin.app_id,syweb_admin.createtime ";
|
||||
|
||||
if( empty($appid) ){
|
||||
$result["status"] = '0';
|
||||
$result["message"] = '请传入appid参数。';
|
||||
return $result;
|
||||
}
|
||||
|
||||
$appInfo = Sql::select('syweb_app.*')
|
||||
->from('syweb_app')
|
||||
->where('syweb_app.appid=?', $appid)
|
||||
->get($this->db ,null);
|
||||
if(empty($appInfo) && count($appInfo)<=0){
|
||||
$result["status"] = '0';
|
||||
$result["message"] = '指定的应用不存在,请检查appid参数。';
|
||||
return $result;
|
||||
}
|
||||
|
||||
if(empty($devkey)){
|
||||
$result["status"] = '0';
|
||||
$result["message"] = '请传入devkey参数。';
|
||||
return $result;
|
||||
}
|
||||
|
||||
$managerList = Sql::select($fields)
|
||||
->from('syweb_admin,syweb_app')
|
||||
->where('syweb_admin.app_id=syweb_app.id and syweb_app.appid=? and syweb_admin.type=3', $appid)
|
||||
->get($this->db ,null);
|
||||
if(!empty($managerList) && count($managerList)>0){
|
||||
$result["status"] = '0';
|
||||
$result["data"] = $managerList;
|
||||
return $result;
|
||||
} else {
|
||||
$result["status"] = '0';
|
||||
$result["data"] = array();
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户名查询用户详细信息
|
||||
* @route({"POST","/query"})
|
||||
* @param({"appid","$._POST.appid"}) 应用appid
|
||||
* @param({"devkey","$._POST.devkey"}) 开发者key
|
||||
* @param({"username","$._POST.username"}) 用户名
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
*/
|
||||
public function query($appid,$devkey,$username) {
|
||||
if(empty($appid)){
|
||||
$result["status"] = '0';
|
||||
$result["message"] = '请传入appid参数。';
|
||||
return $result;
|
||||
}
|
||||
$appInfo = Sql::select('syweb_app.*')
|
||||
->from('syweb_app')
|
||||
->where('syweb_app.appid=?', $appid)
|
||||
->get($this->db ,null);
|
||||
if(empty($appInfo) || count($appInfo)<=0){
|
||||
$result["status"] = '0';
|
||||
$result["message"] = '指定的应用不存在,请检查appid参数。';
|
||||
return $result;
|
||||
}
|
||||
|
||||
if(empty($devkey)){
|
||||
$result["status"] = '0';
|
||||
$result["message"] = '请传入devkey参数。';
|
||||
return $result;
|
||||
}
|
||||
if(empty($username)){
|
||||
$result["status"] = '0';
|
||||
$result["message"] = '请传入username参数。';
|
||||
return $result;
|
||||
}
|
||||
|
||||
$res = Sql::select('syweb_admin.id,syweb_admin.username,syweb_admin.nickname,syweb_admin.app_id,syweb_admin.createtime')
|
||||
->from('syweb_admin,syweb_app')
|
||||
->where('syweb_admin.app_id=syweb_app.id and syweb_app.appid=? and syweb_admin.username=? and syweb_admin.type=3', $appid,$username)
|
||||
->get($this->db ,null);
|
||||
|
||||
if(count($res)>0){
|
||||
$result[0]["error"] = "0";
|
||||
$result[0]["data"] = $res[0];
|
||||
}else{
|
||||
$result[0]["error"] = "1";
|
||||
$result[0]["error_code"] = 1; // 指定的用户不存在
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/** @inject("ioc_factory") */
|
||||
private $factory;
|
||||
/**
|
||||
* @property({"default":"@db"})
|
||||
* @var PDO
|
||||
*/
|
||||
public $db;
|
||||
}
|
||||
82
codes/agent/game-docker/api/source/apis/market.php
Normal file
82
codes/agent/game-docker/api/source/apis/market.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, PATCH, DELETE");
|
||||
header("Access-Control-Allow-Headers: Content-Type, Authorization, Content-Length, X-Requested-With");
|
||||
header("Access-Control-Allow-Credentials: true");
|
||||
header("Content-Type: text/html; charset=utf-8");
|
||||
|
||||
/**
|
||||
* 门店相关接口
|
||||
*/
|
||||
use phprs\util\Verify;
|
||||
use phprs\util\exceptions\Forbidden;
|
||||
use phprs\util\Logger;
|
||||
use phprs\util\exceptions\NotFound;
|
||||
use phprs\ezsql\Sql;
|
||||
use phprs\util\exceptions\BadRequest;
|
||||
|
||||
require_once 'apiBase.php';
|
||||
|
||||
/**
|
||||
*
|
||||
* 登录管理
|
||||
* @path("/market")
|
||||
*/
|
||||
class Market extends apiBase {
|
||||
/**
|
||||
* 获取商户信息(错误代码:15000-15050)
|
||||
* @route({"POST","/"})
|
||||
* @param({"devkey","$._POST.devkey"}) 开发者key
|
||||
* @param({"market_key","$._POST.market_key"}) market_key
|
||||
* @param({"sign","$._POST.sign"}) sign
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
* @return("body")
|
||||
*/
|
||||
public function getMarketInfo($devkey='',$market_key='',$sign='') {
|
||||
$result = array();
|
||||
|
||||
$verify_result = $this->verifyMarketApi($devkey);
|
||||
if( is_error_api($verify_result) ){
|
||||
return $verify_result;
|
||||
}
|
||||
|
||||
if( empty($market_key) ) {
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 11001;
|
||||
$result["msg"] = "未传入market_key参数";
|
||||
return $result;
|
||||
}
|
||||
$marketList = Sql::select('syweb_market.*')
|
||||
->from('syweb_market')
|
||||
->where('syweb_market.market_key=?',$market_key)
|
||||
->get($this->db ,null);
|
||||
if( empty($marketList) || count($marketList)<=0 ) {
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 11002;
|
||||
$result["msg"] = "market_key无效";
|
||||
return $result;
|
||||
}
|
||||
$marketList = $marketList[0];
|
||||
|
||||
$data = array();
|
||||
$data["market_key"] = $marketList["market_key"];
|
||||
$data["market_name"] = $marketList["market_name"];
|
||||
if( !empty($marketList["head_image"]) ) {
|
||||
$data["head_image"] = env('SITE_OPEN_URL', 'http://open.tscce.cn').$marketList["head_image"];
|
||||
}
|
||||
|
||||
$result["error"] = '0';
|
||||
$result["data"] = $data;
|
||||
$result["msg"] = "获取门店信息成功!";
|
||||
return $result;
|
||||
}
|
||||
|
||||
/** @inject("ioc_factory") */
|
||||
private $factory;
|
||||
/**
|
||||
* @property({"default":"@db"})
|
||||
* @var PDO
|
||||
*/
|
||||
public $db;
|
||||
// 此处删除了代码
|
||||
}
|
||||
4337
codes/agent/game-docker/api/source/apis/newpay.bak
Normal file
4337
codes/agent/game-docker/api/source/apis/newpay.bak
Normal file
File diff suppressed because it is too large
Load Diff
4922
codes/agent/game-docker/api/source/apis/newpay.php
Normal file
4922
codes/agent/game-docker/api/source/apis/newpay.php
Normal file
File diff suppressed because it is too large
Load Diff
205
codes/agent/game-docker/api/source/apis/order.php
Normal file
205
codes/agent/game-docker/api/source/apis/order.php
Normal file
@@ -0,0 +1,205 @@
|
||||
<?php
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, PATCH, DELETE");
|
||||
header("Access-Control-Allow-Headers: Content-Type, Authorization, Content-Length, X-Requested-With");
|
||||
header("Access-Control-Allow-Credentials: true");
|
||||
header("Content-Type: text/html; charset=utf-8");
|
||||
|
||||
/**
|
||||
* 登录相关接口
|
||||
*/
|
||||
use phprs\util\Verify;
|
||||
use phprs\util\exceptions\Forbidden;
|
||||
use phprs\util\Logger;
|
||||
use phprs\util\exceptions\NotFound;
|
||||
use phprs\ezsql\Sql;
|
||||
use phprs\util\exceptions\BadRequest;
|
||||
|
||||
require_once 'apiBase.php';
|
||||
/**
|
||||
*
|
||||
* 订单管理
|
||||
* @path("/order")
|
||||
*/
|
||||
class Order extends apiBase{
|
||||
/**
|
||||
* 购买订单生成(错误代码:12701-12750)
|
||||
* @route({"POST","/add"})
|
||||
* @param({"appid","$._POST.appid"}) 所属公众号
|
||||
* @param({"devkey","$._POST.devkey"}) 外部应用ID
|
||||
* @param({"sid","$._POST.sid"}) 临时会员ID
|
||||
* @param({"scode","$._POST.scode"}) 客户端票据
|
||||
* @param({"goodsprice","$._POST.goodsprice"}) 商品费用
|
||||
* @param({"dispatchprice","$._POST.dispatchprice"}) 运费
|
||||
* @param({"title","$._POST.title"}) 支付主题
|
||||
* @param({"sendtype","$._POST.sendtype"}) 1为快递,2为自提
|
||||
* @param({"address","$._POST.address"}) 收货地址
|
||||
* @param({"goodstype","$._POST.goodstype"}) 商品类型(1:实体商品,2:虚拟商品)
|
||||
* @param({"remark","$._POST.remark"}) 订单留言
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
*/
|
||||
public function orderAdd($appid='', $devkey='',$sid='',$scode='',$goodsprice='',$dispatchprice='',$title='',$sendtype='',$address='{=NULL=}',$goodstype='',$remark='') {
|
||||
// 验证公共参数是否合法
|
||||
parent::init($appid,$devkey,$sid,$scode);
|
||||
$verify_result = parent::verify();
|
||||
|
||||
if( !is_error_api($verify_result) ){
|
||||
$result = array();
|
||||
|
||||
if ( !is_numeric($goodsprice) ) {
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12701;
|
||||
$result["msg"] = "请正确传入goodsprice";
|
||||
return $result;
|
||||
}
|
||||
if ( !is_numeric($dispatchprice) ) {
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12702;
|
||||
$result["msg"] = "请正确传入dispatchprice";
|
||||
return $result;
|
||||
}
|
||||
if(empty($title)){
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12703;
|
||||
$result["msg"] = "请传入title";
|
||||
return $result;
|
||||
}
|
||||
if( !is_numeric($sendtype) ){
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12704;
|
||||
$result["msg"] = "请正确传入sendtype";
|
||||
return $result;
|
||||
}
|
||||
if(intval($goodstype)==1 && intval($sendtype)==1){
|
||||
if ( $address=='{=NULL=}' ){
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12705;
|
||||
$result["msg"] = "请传入收货地址";
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
if( !is_numeric($goodstype) ){
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12706;
|
||||
$result["msg"] = "请正确传入goodstype";
|
||||
return $result;
|
||||
}
|
||||
|
||||
// 生成随机订单编号 begin
|
||||
$ordersn = date('ymd') . random(10, 1);//订单编号
|
||||
while(true){
|
||||
$order_list = Sql::select('syweb_order.*')
|
||||
->from('syweb_order')
|
||||
->where('syweb_order.ordersn=?', $ordersn)
|
||||
->get($this->db ,null);
|
||||
if (!empty($order_list) && count($order_list)>0) {
|
||||
$ordersn = date('ymd') . random(10, 1);//订单编号
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 生成随机订单编号 begin
|
||||
|
||||
if( $this->userInfo["auth_type"]==0 ){
|
||||
$openId = $this->userInfo["openid"]; // 微信用户的openId
|
||||
$data = array(
|
||||
'app_id' => $this->appInfo["id"],// 所属应用
|
||||
'business_id' => $this->businessInfo["id"],// 所属商家
|
||||
'from_user' => $openId,// 购买用户
|
||||
'ordersn' => $ordersn,//订单编号
|
||||
'title' => $title,//订单标题
|
||||
'price' => $goodsprice + $dispatchprice,//总价
|
||||
'status' => 0,//订单状态
|
||||
'sendtype' => intval($sendtype),// 1为快递,2为自提
|
||||
'paytype' => '0',
|
||||
'goodstype' => intval($goodstype),// 商品类型(1:实体商品,2:虚拟商品)
|
||||
'remark' => $remark,//留言
|
||||
'address' => $address,// 收货地址
|
||||
'goodsprice' => $goodsprice,//商品价格
|
||||
'dispatchprice' => $dispatchprice,//运费
|
||||
'paydetail' => '',
|
||||
'createtime' => TIMESTAMP//订单创建时间
|
||||
);
|
||||
|
||||
$pdo = $this->db;
|
||||
$pdo->beginTransaction();
|
||||
$orderid = Sql::insertInto('syweb_order')->values($data)->exec($pdo)->lastInsertId();
|
||||
$pdo->commit();
|
||||
|
||||
if (!empty($orderid)) {
|
||||
$result["error"] = "0";
|
||||
$result["order"] = $data;
|
||||
return $result;
|
||||
}else{
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12707; // 订单生成失败
|
||||
$result["msg"] = "订单生成失败";
|
||||
return $result;
|
||||
}
|
||||
}else{
|
||||
// QQ登录状态
|
||||
}
|
||||
}else{
|
||||
return $verify_result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据订单ID查询订单详情(错误代码:12751-12800)
|
||||
* @route({"POST","/"})
|
||||
* @param({"appid","$._POST.appid"}) 所属公众号
|
||||
* @param({"devkey","$._POST.devkey"}) 外部应用ID
|
||||
* @param({"sid","$._POST.sid"}) 临时会员ID
|
||||
* @param({"scode","$._POST.scode"}) 客户端票据
|
||||
* @param({"orderSN","$._POST.orderSN"}) 订单编号
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
*/
|
||||
public function getOrder($appid='',$devkey='',$sid='',$scode='',$orderSN='') {
|
||||
// 验证公共参数是否合法
|
||||
parent::init($appid,$devkey,$sid,$scode);
|
||||
$verify_result = parent::verify();
|
||||
|
||||
if( !is_error_api($verify_result) ){
|
||||
$result = array();
|
||||
|
||||
if ( empty($orderSN) ) {
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12751;
|
||||
$result["msg"] = "请传入orderSN";
|
||||
return $result;
|
||||
}
|
||||
|
||||
if( $this->userInfo["auth_type"]==0 ){
|
||||
$openId =$this->userInfo["openid"]; // 微信用户的openId
|
||||
$orderInfo = Sql::select('syweb_order.*')
|
||||
->from('syweb_order')
|
||||
->where('syweb_order.app_id=? and syweb_order.business_id=? and syweb_order.ordersn=?', $this->appInfo['id'],$this->businessInfo['id'],$orderSN)
|
||||
->get($this->db ,null);
|
||||
|
||||
if (!empty($orderInfo)) {
|
||||
$result["error"] = "0";
|
||||
$result["order"] = $orderInfo;
|
||||
return $result;
|
||||
}else{
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12752;
|
||||
$result["msg"] = "订单不存在或已经被删除。";
|
||||
return $result;
|
||||
}
|
||||
}else{
|
||||
// QQ登录状态
|
||||
}
|
||||
}else{
|
||||
return $verify_result;
|
||||
}
|
||||
}
|
||||
|
||||
/** @inject("ioc_factory") */
|
||||
private $factory;
|
||||
/**
|
||||
* @property({"default":"@db"})
|
||||
* @var PDO
|
||||
*/
|
||||
public $db;
|
||||
// 此处删除了代码
|
||||
}
|
||||
1361
codes/agent/game-docker/api/source/apis/pay.php
Normal file
1361
codes/agent/game-docker/api/source/apis/pay.php
Normal file
File diff suppressed because it is too large
Load Diff
149
codes/agent/game-docker/api/source/apis/permission.php
Normal file
149
codes/agent/game-docker/api/source/apis/permission.php
Normal file
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
header('Access-Control-Allow-Origin:*');// 指定允许其他域名访问
|
||||
header('Access-Control-Allow-Methods:POST');// 响应类型
|
||||
header('Access-Control-Allow-Headers:x-requested-with,content-type');
|
||||
|
||||
/**
|
||||
* 获取票据接口
|
||||
*/
|
||||
use phprs\util\Verify;
|
||||
use phprs\util\exceptions\Forbidden;
|
||||
use phprs\util\Logger;
|
||||
use phprs\util\exceptions\NotFound;
|
||||
use phprs\ezsql\Sql;
|
||||
use phprs\util\exceptions\BadRequest;
|
||||
|
||||
/**
|
||||
*
|
||||
* 获取信息接口
|
||||
* @path("/permission")
|
||||
*/
|
||||
class Permission {
|
||||
/**
|
||||
* 通过devkey和appid换取票据
|
||||
* @route({"POST","/ticket"})
|
||||
* @param({"appid","$._POST.appid"}) 应用appid
|
||||
* @param({"devkey","$._POST.devkey"}) 开发者key
|
||||
* @param({"domain","$._POST.domain"}) 域名
|
||||
* @param({"nocestr","$._POST.nocestr"}) 随机字符串
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
*/
|
||||
public function getTicket($appid,$devkey,$domain,$nocestr) {
|
||||
// 当前时间戳,通过sid和scode获取用户信息,必须保障sid未过期
|
||||
$nowtime = time();
|
||||
|
||||
$ticket = md5($appid.'=='.$devkey.'=='.$domain.'=='.$nocestr);
|
||||
|
||||
$insertData = array();
|
||||
|
||||
$insertData['appid'] = $appid;
|
||||
$insertData['devkey'] = $appid;
|
||||
$insertData['domain'] = $appid;
|
||||
$insertData['nocestr'] = $appid;
|
||||
$insertData['ticket'] = $appid;
|
||||
|
||||
$expire_time = time();
|
||||
$expire_date = date('H:i:s',strtotime("+20 minute"));
|
||||
$expire_time = strtotime($expire_date);
|
||||
|
||||
$insertData['expiretime'] = $expire_time; // 票据过期时间
|
||||
|
||||
$pdo = $this->db;
|
||||
$pdo->beginTransaction();
|
||||
$id = Sql::insertInto('syweb_ticket')->values($insertData)->exec($pdo)->lastInsertId();
|
||||
$pdo->commit();
|
||||
|
||||
// 根据sid 查询用户信息
|
||||
$res = Sql::select('syweb_ticket.*')
|
||||
->from('syweb_ticket')
|
||||
->where('syweb_ticket.id=?', $id)
|
||||
->get($this->db ,null);
|
||||
|
||||
if(count($res)>0){
|
||||
$result[0]["error"] = "0";
|
||||
$result[0]["ticket"] = $ticket;
|
||||
}else{
|
||||
$result[0]["error"] = "1";
|
||||
$result[0]["error_code"] = 1; // 获取授权票据失败
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证开发者权限
|
||||
* @route({"POST","/check_auth"})
|
||||
* @param({"appid","$._POST.appid"}) 应用appid
|
||||
* @param({"devkey","$._POST.devkey"}) 开发者key
|
||||
* @param({"ticket","$._POST.ticket"}) 服务器授予的票据
|
||||
* @param({"authcode","$._POST.authcode"}) 权限代码
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
*/
|
||||
public function checkPermission($appid="",$devkey="",$ticket="",$authcode="") {
|
||||
// 当前时间戳
|
||||
$nowtime = time();
|
||||
|
||||
$referer = $_SERVER["HTTP_REFERER"];// 客户端来源地址
|
||||
|
||||
if( empty($appid) ){
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = '1';
|
||||
$result["message"] = '请传入appid参数。';
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
$appInfo = Sql::select('syweb_app.*')
|
||||
->from('syweb_app')
|
||||
->where('syweb_app.appid=?', $appid)
|
||||
->get($this->db ,null);
|
||||
if(!empty($appInfo) && count($appInfo)>0){
|
||||
$insertData['app_id'] = $appInfo[0]["id"];
|
||||
} else {
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = '2';
|
||||
$result["message"] = '指定的应用不存在,请检查appid参数。';
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
if(empty($devkey)){
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = '3';
|
||||
$result["message"] = '请传入devkey参数。';
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
|
||||
// 根据sid 查询用户信息
|
||||
// $res = Sql::select('syweb_ticket.*')
|
||||
// ->from('syweb_ticket')
|
||||
// ->where('syweb_ticket.appid=? and syweb_ticket.devkey=? and syweb_ticket.ticket=? and syweb_ticket.expiretime>?',$appid,$devkey,$ticket,$nowtime)
|
||||
// ->get($this->db ,null);
|
||||
|
||||
//if(count($res)>0){
|
||||
$res = Sql::select('syweb_api_apply.*')
|
||||
->from('syweb_api_apply,syweb_interface')
|
||||
->where('syweb_api_apply.interface_id=syweb_interface.id and syweb_api_apply.status=1 and syweb_interface.interface_code =? and dev_id in (select id from syweb_admin where devkey=? and type=2)',$authcode,$devkey)
|
||||
->get($this->db ,null);
|
||||
if(count($res)>0){
|
||||
$result["error"] = '0';
|
||||
$result["message"] = "用户具备接口权限。";// 用户具备该接口权限
|
||||
}else{
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = '4';
|
||||
$result["message"] = "用户不具备接口权限。";// 用户无该接口权限
|
||||
}
|
||||
//}else{
|
||||
// $result[0]["error"] = "1";
|
||||
// $result[0]["error_code"] = 1; // 用户票据过去或未获得票据
|
||||
//}
|
||||
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
/** @inject("ioc_factory") */
|
||||
private $factory;
|
||||
/**
|
||||
* @property({"default":"@db"})
|
||||
* @var PDO
|
||||
*/
|
||||
public $db;
|
||||
}
|
||||
553
codes/agent/game-docker/api/source/apis/templateMessage.php
Normal file
553
codes/agent/game-docker/api/source/apis/templateMessage.php
Normal file
@@ -0,0 +1,553 @@
|
||||
<?php
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, PATCH, DELETE");
|
||||
header("Access-Control-Allow-Headers: Content-Type, Authorization, Content-Length, X-Requested-With");
|
||||
header("Access-Control-Allow-Credentials: true");
|
||||
header("Content-Type: text/html; charset=utf-8");
|
||||
|
||||
/**
|
||||
* 消息发送相关接口
|
||||
*/
|
||||
use phprs\util\Verify;
|
||||
use phprs\util\exceptions\Forbidden;
|
||||
use phprs\util\Logger;
|
||||
use phprs\util\exceptions\NotFound;
|
||||
use phprs\ezsql\Sql;
|
||||
use phprs\util\exceptions\BadRequest;
|
||||
|
||||
require_once 'templateMessageBase.php';
|
||||
|
||||
class DataItem
|
||||
{
|
||||
var $value;
|
||||
var $color;
|
||||
|
||||
public function __construct($value, $color = '#7B68EE')
|
||||
{
|
||||
$this->value = $value;
|
||||
$this->color = $color;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 消息管理
|
||||
* @path("/tplmessage")
|
||||
*/
|
||||
class templateMessage extends templateMessageBase
|
||||
{
|
||||
/**
|
||||
* 模板消息发送(错误代码:12500-12550)
|
||||
* @route({"POST","/rawsend"})
|
||||
* @param({"appid","$._POST.appid"}) 所属公众号
|
||||
* @param({"devkey","$._POST.devkey"}) 外部应用ID
|
||||
* @param({"market_key","$._POST.market_key"}) 门店key
|
||||
* @param({"touser","$._POST.touser"}) 接收人的openid
|
||||
* @param({"template_id","$._POST.tid"}) 模板编号
|
||||
* @param({"data","$._POST.data"}) 模板参数
|
||||
* @param({"url","$._POST.url"}) url
|
||||
* @return string
|
||||
*/
|
||||
public function rawsend($appid, $devkey, $market_key, $touser, $template_id, $data, $url)
|
||||
{
|
||||
/// 验证公共参数是否合法
|
||||
$this->init($appid, $devkey);
|
||||
$verify_result = $this->verify_admin($market_key);
|
||||
if (is_error_api($verify_result))
|
||||
{
|
||||
if ($verify_result instanceof returnObject)
|
||||
return $verify_result;
|
||||
|
||||
$return = new returnObject();
|
||||
$return->from_array((array)$verify_result);
|
||||
return $verify_result;
|
||||
}
|
||||
|
||||
/// 验证其他参数是否合法 begin
|
||||
if (empty($template_id)) {
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12501;
|
||||
$result["msg"] = "未传入tid参数";
|
||||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
// 验证其他参数是否合法 end
|
||||
|
||||
if (AUTHTYPE_WECHAT != $this->userInfo["auth_type"]) {
|
||||
// 非微信登录方式,无法发送模板消息
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12502;
|
||||
$result["msg"] = "非微信登录方式,无法发送模板消息";
|
||||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
/// 参数
|
||||
if (empty($data))
|
||||
$data = [];
|
||||
else
|
||||
$data = (array)json_decode($data);
|
||||
|
||||
$wechat = [
|
||||
'appid' => $this->marketInfo['weixin_appid'], /// 微信公众号APPID
|
||||
'secret' => $this->marketInfo['weixin_secret_appid'],
|
||||
'mchid' => $this->marketInfo['weixin_mchid'], /// 微信公众号商户号
|
||||
'signkey' => $this->marketInfo['weixin_paykey'], /// 支付秘钥
|
||||
];
|
||||
|
||||
/// 初始化微信信息
|
||||
parent::init_weixin($wechat['appid'], $wechat['secret']);
|
||||
/// openid
|
||||
$openid = $touser;
|
||||
/// 发送模板消息
|
||||
$sendResult = parent::SendMessage($openid, $template_id, $url, $data);
|
||||
|
||||
if (!is_error($sendResult)) {
|
||||
$result["error"] = "0";
|
||||
$result["msg"] = "发送模板消息成功。";
|
||||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
} else {
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12505; // 发送模板消息失败
|
||||
$result["msg"] = "发送模板消息失败";
|
||||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 购买订单模板消息发送(错误代码:12500-12550)
|
||||
* @route({"POST","/send"})
|
||||
* @param({"appid","$._POST.appid"}) 所属公众号
|
||||
* @param({"devkey","$._POST.devkey"}) 外部应用ID
|
||||
* @param({"sid","$._POST.sid"}) sid
|
||||
* @param({"scode","$._POST.scode"}) scode
|
||||
* @param({"template_id","$._POST.tid"}) 模板编号
|
||||
* @param({"data","$._POST.data"}) 模板参数
|
||||
* @param({"url","$._POST.url"}) url
|
||||
* @return string
|
||||
*/
|
||||
public function send($appid, $devkey, $sid, $scode, $template_id, $data, $url)
|
||||
{
|
||||
/// 验证公共参数是否合法
|
||||
parent::init($appid, $devkey, $sid, $scode);
|
||||
$verify_result = parent::verify();
|
||||
|
||||
if (is_error_api($verify_result))
|
||||
return json_encode($verify_result, JSON_UNESCAPED_UNICODE);
|
||||
|
||||
/// 验证其他参数是否合法 begin
|
||||
if (empty($template_id)) {
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12501;
|
||||
$result["msg"] = "未传入tid参数";
|
||||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
// 验证其他参数是否合法 end
|
||||
|
||||
if (AUTHTYPE_WECHAT != $this->userInfo["auth_type"]) {
|
||||
// 非微信登录方式,无法发送模板消息
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12502;
|
||||
$result["msg"] = "非微信登录方式,无法发送模板消息";
|
||||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
/// 参数
|
||||
if (empty($data))
|
||||
$data = [];
|
||||
else
|
||||
$data = (array)json_decode($data);
|
||||
|
||||
$wechat = [
|
||||
'appid' => $this->marketInfo['weixin_appid'], /// 微信公众号APPID
|
||||
'secret' => $this->marketInfo['weixin_secret_appid'],
|
||||
'mchid' => $this->marketInfo['weixin_mchid'], /// 微信公众号商户号
|
||||
'signkey' => $this->marketInfo['weixin_paykey'], /// 支付秘钥
|
||||
];
|
||||
|
||||
/// 初始化微信信息
|
||||
parent::init_weixin($wechat['appid'], $wechat['secret']);
|
||||
/// openid
|
||||
$openid = $this->userInfo['openid'];
|
||||
/// 发送模板消息
|
||||
$sendResult = parent::SendMessage($openid, $template_id, $url, $data);
|
||||
if (!is_error($sendResult)) {
|
||||
$result["error"] = "0";
|
||||
$result["msg"] = "发送模板消息成功。";
|
||||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
} else {
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12505; // 发送模板消息失败
|
||||
$result["msg"] = "发送模板消息失败";
|
||||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 购买订单模板消息发送(错误代码:12500-12550)
|
||||
* @route({"POST","/send/buy_succ_msg"})
|
||||
* @param({"appid","$._POST.appid"}) 所属公众号
|
||||
* @param({"devkey","$._POST.devkey"}) 外部应用ID
|
||||
* @param({"sid","$._POST.sid"}) sid
|
||||
* @param({"scode","$._POST.scode"}) scode
|
||||
* @param({"first","$._POST.first"}) 头部内容
|
||||
* @param({"productname","$._POST.productname"}) 产品名称
|
||||
* @param({"price","$._POST.price"}) 订单价格
|
||||
* @param({"time","$._POST.time"}) 时间
|
||||
* @param({"remark","$._POST.remark"}) 购买正文
|
||||
* @param({"target_url","$._POST.target_url"}) 跳转链接
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
*/
|
||||
public function sendBuySuccessMsg($appid = '', $devkey = '', $sid = '', $scode = '', $first = '', $productname = '', $price = '', $time = '', $remark = '', $target_url = '')
|
||||
{
|
||||
// 验证公共参数是否合法
|
||||
parent::init($appid, $devkey, $sid, $scode);
|
||||
$verify_result = parent::verify();
|
||||
|
||||
if (!is_error_api($verify_result)) {
|
||||
// 验证其他参数是否合法 begin
|
||||
if (empty($first)) {
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12500; // 未传入first参数
|
||||
$result["msg"] = "未传入first参数";
|
||||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
if (empty($productname)) {
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12501; // 未传入productname参数
|
||||
$result["msg"] = "未传入productname参数";
|
||||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
if (empty($price)) {
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12502; // 未传入price参数
|
||||
$result["msg"] = "未传入price参数";
|
||||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
if (empty($remark)) {
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12503; // 未传入remark参数
|
||||
$result["msg"] = "未传入remark参数";
|
||||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
// 验证其他参数是否合法 end
|
||||
|
||||
// 假如没有传入时间,则使用系统默认时间
|
||||
if (empty($time)) {
|
||||
$time = date('Y-m-d H:i', strtotime('now'));
|
||||
}
|
||||
|
||||
if ($this->userInfo["auth_type"] == 0) {
|
||||
$data = array(
|
||||
'first' => new DataItem($first, '#ff0000'),
|
||||
'product' => new DataItem($productname, '#ff0000'),
|
||||
'price' => new DataItem($price, '#ff0000'),
|
||||
'time' => new DataItem($time, '#ff0000'),
|
||||
'remark' => new DataItem($remark, '#ff0000'),
|
||||
);
|
||||
|
||||
// 初始化微信信息
|
||||
parent::init_weixin($this->businessInfo['weixin_appid'], $this->businessInfo['weixin_secret_appid']);
|
||||
// 发送模板消息
|
||||
$openid = $this->userInfo["weixin"]['openid'];
|
||||
$template_id = $this->businessInfo['templatemsg']['msg_buy_succ'];
|
||||
$sendResult = parent::do_send($openid, $template_id, $data, $target_url);
|
||||
if (!is_error($sendResult)) {
|
||||
$result["error"] = "0";
|
||||
$result["msg"] = "发送模板消息成功。";
|
||||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
} else {
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12505; // 发送模板消息失败
|
||||
$result["msg"] = "发送模板消息失败";
|
||||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
} else {
|
||||
// 非微信登录方式,无法发送模板消息
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12504;
|
||||
$result["msg"] = "非微信登录方式,无法发送模板消息";
|
||||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
} else {
|
||||
return json_encode($verify_result, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 配送处理模板消息发送(错误代码:12551-12600)
|
||||
* @route({"POST","/send/dispatch_process_msg"})
|
||||
* @param({"appid","$._POST.appid"}) 所属公众号
|
||||
* @param({"devkey","$._POST.devkey"}) 外部应用ID
|
||||
* @param({"sid","$._POST.sid"}) sid
|
||||
* @param({"scode","$._POST.scode"}) scode
|
||||
* @param({"first","$._POST.first"}) 头部内容
|
||||
* @param({"time","$._POST.time"}) 时间
|
||||
* @param({"ordersn","$._POST.ordersn"}) 订单号
|
||||
* @param({"remark","$._POST.remark"}) 正文
|
||||
* @param({"target_url","$._POST.target_url"}) 跳转链接
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
*/
|
||||
public function sendDispatchProcessMsg($appid = '', $devkey = '', $sid = '', $scode = '', $first = '', $time = '', $ordersn = '', $remark = '', $target_url = '')
|
||||
{
|
||||
// 验证公共参数是否合法
|
||||
parent::init($appid, $devkey, $sid, $scode);
|
||||
$verify_result = parent::verify();
|
||||
|
||||
if (!is_error_api($verify_result)) {
|
||||
// 验证其他参数是否合法 begin
|
||||
if (empty($first)) {
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12551; // 未传入first参数
|
||||
$result["msg"] = "未传入first参数";
|
||||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
if (empty($ordersn)) {
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12552; // 未传入ordersn参数
|
||||
$result["msg"] = "未传入ordersn参数";
|
||||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
if (empty($remark)) {
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12553; // 未传入remark参数
|
||||
$result["msg"] = "未传入remark参数";
|
||||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
// 验证其他参数是否合法 end
|
||||
|
||||
// 假如没有传入时间,则使用系统默认时间
|
||||
if (empty($time)) {
|
||||
$time = date('Y-m-d H:i', strtotime('now'));
|
||||
}
|
||||
|
||||
if ($this->userInfo["auth_type"] == 0) {
|
||||
$data = array(
|
||||
'first' => new DataItem($first, '#ff0000'),
|
||||
'keyword1' => new DataItem($time, '#ff0000'),
|
||||
'keyword2' => new DataItem($ordersn, '#ff0000'),
|
||||
'remark' => new DataItem($remark, '#ff0000'),
|
||||
);
|
||||
|
||||
// 初始化微信信息
|
||||
parent::init_weixin($this->businessInfo['weixin_appid'], $this->businessInfo['weixin_secret_appid']);
|
||||
// 发送模板消息
|
||||
$openid = $this->userInfo["weixin"]['openid'];
|
||||
$template_id = $this->businessInfo['templatemsg']['msg_dispatch_process'];
|
||||
$sendResult = parent::do_send($openid, $template_id, $data, $target_url);
|
||||
if (!is_error($sendResult)) {
|
||||
$result["error"] = "0";
|
||||
$result["msg"] = "发送模板消息成功。";
|
||||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
} else {
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12555; // 发送模板消息失败
|
||||
$result["msg"] = "发送模板消息失败";
|
||||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
} else {
|
||||
// 非微信登录方式,无法发送模板消息
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12554;
|
||||
$result["msg"] = "非微信登录方式,无法发送模板消息 ";
|
||||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
} else {
|
||||
return json_encode($verify_result, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 购买订单模板消息发送(错误代码:12500-12550)
|
||||
* @route({"POST","/send/admin/buy_succ_msg"})
|
||||
* @param({"appid","$._POST.appid"}) 所属公众号
|
||||
* @param({"devkey","$._POST.devkey"}) 外部应用ID
|
||||
* @param({"businessid","$._POST.businessid"}) 商户ID
|
||||
* @param({"openid","$._POST.openid"}) 微信openId
|
||||
* @param({"first","$._POST.first"}) 头部内容
|
||||
* @param({"productname","$._POST.productname"}) 产品名称
|
||||
* @param({"price","$._POST.price"}) 订单价格
|
||||
* @param({"time","$._POST.time"}) 时间
|
||||
* @param({"remark","$._POST.remark"}) 购买正文
|
||||
* @param({"target_url","$._POST.target_url"}) 跳转链接
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
*/
|
||||
public function sendBuySuccessMsgByAdmin($appid = '', $devkey = '', $businessid = '', $openid = '', $first = '', $productname = '', $price = '', $time = '', $remark = '', $target_url = '')
|
||||
{
|
||||
|
||||
// 验证公共参数是否合法
|
||||
parent::init($appid, $devkey, '', '');
|
||||
$verify_result = parent::verify_admin($businessid);
|
||||
|
||||
if (!is_error_api($verify_result)) {
|
||||
// 验证其他参数是否合法 begin
|
||||
if (empty($first)) {
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12500; // 未传入first参数
|
||||
$result["msg"] = "未传入first参数";
|
||||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
if (empty($productname)) {
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12501; // 未传入productname参数
|
||||
$result["msg"] = "未传入productname参数";
|
||||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
if (empty($price)) {
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12502; // 未传入price参数
|
||||
$result["msg"] = "未传入price参数";
|
||||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
if (empty($remark)) {
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12503; // 未传入remark参数
|
||||
$result["msg"] = "未传入remark参数";
|
||||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
if (empty($openid)) {
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12506; // 未传入openid参数
|
||||
$result["msg"] = "未传入openid参数";
|
||||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
// 验证其他参数是否合法 end
|
||||
|
||||
// 假如没有传入时间,则使用系统默认时间
|
||||
if (empty($time)) {
|
||||
$time = date('Y-m-d H:i', strtotime('now'));
|
||||
}
|
||||
|
||||
if ($this->userInfo["auth_type"] == 0) {
|
||||
$data = array(
|
||||
'first' => new DataItem($first, '#ff0000'),
|
||||
'product' => new DataItem($productname, '#ff0000'),
|
||||
'price' => new DataItem($price, '#ff0000'),
|
||||
'time' => new DataItem($time, '#ff0000'),
|
||||
'remark' => new DataItem($remark, '#ff0000'),
|
||||
);
|
||||
|
||||
// 初始化微信信息
|
||||
parent::init_weixin($this->businessInfo['weixin_appid'], $this->businessInfo['weixin_secret_appid']);
|
||||
// 发送模板消息
|
||||
$template_id = $this->businessInfo['templatemsg']['msg_buy_succ'];
|
||||
$sendResult = parent::do_send($openid, $template_id, $data, $target_url);
|
||||
if (!is_error($sendResult)) {
|
||||
$result["error"] = "0";
|
||||
$result["msg"] = "发送模板消息成功。";
|
||||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
} else {
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12505; // 发送模板消息失败
|
||||
$result["msg"] = "发送模板消息失败";
|
||||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
} else {
|
||||
// 非微信登录方式,无法发送模板消息
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12504;
|
||||
$result["msg"] = "非微信登录方式,无法发送模板消息";
|
||||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
} else {
|
||||
return json_encode($verify_result, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 配送处理模板消息发送(错误代码:12551-12600)
|
||||
* @route({"POST","/send/admin/dispatch_process_msg"})
|
||||
* @param({"appid","$._POST.appid"}) 所属公众号
|
||||
* @param({"devkey","$._POST.devkey"}) 外部应用ID
|
||||
* @param({"businessid","$._POST.businessid"}) 商户ID
|
||||
* @param({"openid","$._POST.openid"}) 微信openId
|
||||
* @param({"first","$._POST.first"}) 头部内容
|
||||
* @param({"time","$._POST.time"}) 时间
|
||||
* @param({"ordersn","$._POST.ordersn"}) 订单号
|
||||
* @param({"remark","$._POST.remark"}) 正文
|
||||
* @param({"target_url","$._POST.target_url"}) 跳转链接
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
*/
|
||||
public function sendDispatchProcessMsgByAdmin($appid = '', $devkey = '', $businessid = '', $openid = '', $first = '', $time = '', $ordersn = '', $remark = '', $target_url = '')
|
||||
{
|
||||
// 验证公共参数是否合法
|
||||
parent::init($appid, $devkey, '', '');
|
||||
$verify_result = parent::verify_admin($openid);
|
||||
|
||||
if (!is_error_api($verify_result)) {
|
||||
// 验证其他参数是否合法 begin
|
||||
if (empty($first)) {
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12551; // 未传入first参数
|
||||
$result["msg"] = "未传入first参数";
|
||||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
if (empty($ordersn)) {
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12552; // 未传入ordersn参数
|
||||
$result["msg"] = "未传入ordersn参数";
|
||||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
if (empty($remark)) {
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12553; // 未传入remark参数
|
||||
$result["msg"] = "未传入remark参数";
|
||||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
if (empty($openid)) {
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12556; // 未传入openid参数
|
||||
$result["msg"] = "未传入openid参数";
|
||||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
// 验证其他参数是否合法 end
|
||||
|
||||
// 假如没有传入时间,则使用系统默认时间
|
||||
if (empty($time)) {
|
||||
$time = date('Y-m-d H:i', strtotime('now'));
|
||||
}
|
||||
|
||||
if ($this->userInfo["auth_type"] == 0) {
|
||||
$data = array(
|
||||
'first' => new DataItem($first, '#ff0000'),
|
||||
'keyword1' => new DataItem($time, '#ff0000'),
|
||||
'keyword2' => new DataItem($ordersn, '#ff0000'),
|
||||
'remark' => new DataItem($remark, '#ff0000'),
|
||||
);
|
||||
|
||||
// 初始化微信信息
|
||||
parent::init_weixin($this->businessInfo['weixin_appid'], $this->businessInfo['weixin_secret_appid']);
|
||||
// 发送模板消息
|
||||
$template_id = $this->businessInfo['templatemsg']['msg_dispatch_process'];
|
||||
$sendResult = parent::do_send($openid, $template_id, $data, $target_url);
|
||||
if (!is_error($sendResult)) {
|
||||
$result["error"] = "0";
|
||||
$result["msg"] = "发送模板消息成功。";
|
||||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
} else {
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12555; // 发送模板消息失败
|
||||
$result["msg"] = "发送模板消息失败";
|
||||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
} else {
|
||||
// 非微信登录方式,无法发送模板消息
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12554;
|
||||
$result["msg"] = "非微信登录方式,无法发送模板消息 ";
|
||||
return json_encode($result, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
} else {
|
||||
return json_encode($verify_result, JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
}
|
||||
|
||||
/** @inject("ioc_factory") */
|
||||
private $factory;
|
||||
/**
|
||||
* @property({"default":"@db"})
|
||||
* @var PDO
|
||||
*/
|
||||
public $db;
|
||||
// 此处删除了代码
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
use phprs\util\Verify;
|
||||
use phprs\util\exceptions\Forbidden;
|
||||
use phprs\util\Logger;
|
||||
use phprs\util\exceptions\NotFound;
|
||||
use phprs\ezsql\Sql;
|
||||
use phprs\util\exceptions\BadRequest;
|
||||
|
||||
require_once 'apiBase.php';
|
||||
|
||||
/**
|
||||
*
|
||||
* 基类
|
||||
* @path("/templateMessageBase")
|
||||
*/
|
||||
class templateMessageBase extends apiBase{
|
||||
protected $weixin_appid; // 微信APPID
|
||||
protected $weixin_secret_appid; // 微信secret_appid
|
||||
/** @var WeiXinAccount */
|
||||
protected $weixinHandler; // 微信接口操作对象
|
||||
|
||||
public function __construct() {
|
||||
}
|
||||
|
||||
public function init_weixin($weixin_appid,$weixin_secret_appid) {
|
||||
$account = array();
|
||||
$account["key"] = $weixin_appid;
|
||||
$account["secret"] = $weixin_secret_appid;
|
||||
$this->weixinHandler = new WeiXinAccount($account);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送自定义的模板消息
|
||||
* @param string $touser 发送给谁(微信openId)
|
||||
* @param string $template_id 模板的id(通过微信后台或接口, 增加的模板产生的唯一id)
|
||||
* @param array $data 消息体数据
|
||||
* @param string $url 跳转地址
|
||||
* @param string $topcolor 颜色
|
||||
* @return array|bool true if the method call succeeded, false otherwise.
|
||||
*/
|
||||
public function do_send($touser, $template_id, $data, $url='',$topcolor = '#7B68EE') {
|
||||
$pdo = $this->db;
|
||||
return $this->weixinHandler->sendTplNotice($this->db,$pdo,$touser,$template_id,$data,$url,$topcolor);
|
||||
}
|
||||
|
||||
public function SendMessage($to_user, $template_id, $target_url, $parameter, $color = '#7b68ee') {
|
||||
$pdo = $this->db;
|
||||
return $this->weixinHandler->SendTemplateMessage($to_user, $template_id, $target_url, $parameter, $color, $this->db, $pdo);
|
||||
}
|
||||
|
||||
/** @inject("ioc_factory") */
|
||||
private $factory;
|
||||
/**
|
||||
* @property({"default":"@db"})
|
||||
* @var PDO
|
||||
*/
|
||||
public $db;
|
||||
}
|
||||
59
codes/agent/game-docker/api/source/apis/test.php
Normal file
59
codes/agent/game-docker/api/source/apis/test.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
header('Access-Control-Allow-Origin:*');// 指定允许其他域名访问
|
||||
header('Access-Control-Allow-Methods:POST');// 响应类型
|
||||
header('Access-Control-Allow-Headers:x-requested-with,content-type');
|
||||
|
||||
use phprs\util\Verify;
|
||||
use phprs\util\exceptions\Forbidden;
|
||||
use phprs\util\Logger;
|
||||
use phprs\util\exceptions\NotFound;
|
||||
use phprs\ezsql\Sql;
|
||||
use phprs\util\exceptions\BadRequest;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* 测试接口
|
||||
* @path("/test")
|
||||
*/
|
||||
class Test extends apiBase{
|
||||
/**
|
||||
* 支付回调
|
||||
* @route({"POST","/pay_notify"})
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
*/
|
||||
public function payNotify() {
|
||||
$input = file_get_contents('php://input');
|
||||
if ( !empty($input) ){
|
||||
$data = json_decode($input,true);
|
||||
$testLogDir = dirname(dirname(__DIR__)) . '/logs';
|
||||
if (!is_dir($testLogDir)) mkdir($testLogDir, 0777, true);
|
||||
file_put_contents($testLogDir . '/pay_test2.txt', count($data));
|
||||
file_put_contents($testLogDir . '/pay_test.txt', "接收到的参数为:".$data['orderNo']."===".$data['signkey']);
|
||||
$result = array();
|
||||
|
||||
// 处理业务逻辑 begin
|
||||
// 比如修改订单状态
|
||||
// 处理业务逻辑 end
|
||||
// 返回0表示已经完成了逻辑的处理,
|
||||
// 如果不返回0则系统会重新发起请求,连续8次
|
||||
$result["error"] = 0;
|
||||
echo json_encode($result);
|
||||
} else {
|
||||
$testLogDir = dirname(dirname(__DIR__)) . '/logs';
|
||||
if (!is_dir($testLogDir)) mkdir($testLogDir, 0777, true);
|
||||
file_put_contents($testLogDir . '/pay_test1.txt', "接收到的内容为空");
|
||||
$result["1"] = 0;
|
||||
echo json_encode($result);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** @inject("ioc_factory") */
|
||||
private $factory;
|
||||
/**
|
||||
* @property({"default":"@db"})
|
||||
* @var PDO
|
||||
*/
|
||||
public $db;
|
||||
}
|
||||
1787
codes/agent/game-docker/api/source/apis/transfer.php
Normal file
1787
codes/agent/game-docker/api/source/apis/transfer.php
Normal file
File diff suppressed because it is too large
Load Diff
417
codes/agent/game-docker/api/source/apis/user.php
Normal file
417
codes/agent/game-docker/api/source/apis/user.php
Normal file
@@ -0,0 +1,417 @@
|
||||
<?php
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, PATCH, DELETE");
|
||||
header("Access-Control-Allow-Headers: Content-Type, Authorization, Content-Length, X-Requested-With");
|
||||
header("Access-Control-Allow-Credentials: true");
|
||||
header("Content-Type: text/html; charset=utf-8");
|
||||
|
||||
/**
|
||||
* 获取用户信息接口
|
||||
*/
|
||||
use phprs\util\Verify;
|
||||
use phprs\util\exceptions\Forbidden;
|
||||
use phprs\util\Logger;
|
||||
use phprs\util\exceptions\NotFound;
|
||||
use phprs\ezsql\Sql;
|
||||
use phprs\util\exceptions\BadRequest;
|
||||
|
||||
require_once 'apiBase.php';
|
||||
|
||||
/**
|
||||
*
|
||||
* 获取用户信息接口
|
||||
* @path("/user")
|
||||
*/
|
||||
class User extends apiBase
|
||||
{
|
||||
/**
|
||||
* 通过scode和sid获取用户信息
|
||||
* @route({"GET","/"})
|
||||
* @param({"appid","$._GET.appid"}) 应用appid
|
||||
* @param({"devkey","$._GET.devkey"}) 开发者key
|
||||
* @param({"market_key","$._GET.market_key"}) 商家Key
|
||||
* @param({"sid","$._GET.sid"}) 服务器返回的sid
|
||||
* @param({"scode","$._GET.scode"}) 客户端生成的Scode
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
*/
|
||||
public function getUserBySid($appid = "", $devkey = "", $market_key = "", $sid = "", $scode = "")
|
||||
{
|
||||
// 验证公共参数是否合法
|
||||
parent::init($appid, $devkey, $sid, $scode, $market_key);
|
||||
$verify_result = parent::verify();
|
||||
if (!is_error_api($verify_result))
|
||||
{
|
||||
if (!empty($market_key))
|
||||
{
|
||||
if ($this->marketInfo["market_key"] != $market_key)
|
||||
{
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 10011;
|
||||
$result["msg"] = "指定的SID和market_key不符.";
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
switch ($this->userInfo["auth_type"])
|
||||
{
|
||||
case AUTHTYPE_WECHAT:
|
||||
{
|
||||
$userInfoBase = [
|
||||
'openid' => $this->userInfo['weixin']['openid'],
|
||||
'unionid' => $this->userInfo['weixin']['unionid'],
|
||||
'country' => $this->userInfo['weixin']['country'],
|
||||
'province' => $this->userInfo['weixin']['province'],
|
||||
'city' => $this->userInfo['weixin']['city'],
|
||||
'headImage' => $this->userInfo['weixin']['headimgurl'],
|
||||
'nickName' => $this->userInfo['weixin']['nickname'],
|
||||
'subscribe' => $this->userInfo['weixin']['subscribe'],
|
||||
'subscribe_time' => $this->userInfo['weixin']['subscribe_time'],
|
||||
'jifen' => $this->userInfo['jifen_account'],
|
||||
];
|
||||
|
||||
$result["usertype"] = $this->userInfo["auth_type"];
|
||||
$result["error"] = "0";
|
||||
$result["data"] = $userInfoBase;
|
||||
$result["dataContent"] = $this->userInfo["weixin"];
|
||||
return $result;
|
||||
}
|
||||
|
||||
case AUTHTYPE_QQ:
|
||||
{
|
||||
$userInfoBase = array();
|
||||
$userInfoBase["headImage"] = $this->userInfo["qq"]["figureurl_qq_2"];
|
||||
$userInfoBase["nickName"] = $this->userInfo["qq"]["nickname"];
|
||||
$userInfoBase["jifen"] = $this->userInfo["jifen_account"];
|
||||
$result["usertype"] = $this->userInfo["auth_type"];
|
||||
$result["error"] = "0";
|
||||
$result["data"] = $userInfoBase;
|
||||
$result["dataContent"] = $this->userInfo["qq"];
|
||||
return $result;
|
||||
}
|
||||
|
||||
case AUTHTYPE_JKX:
|
||||
{
|
||||
$userInfoBase = array();
|
||||
$userInfoBase["headImage"] = $this->userInfo["jkx"]["headimgurl"];
|
||||
$userInfoBase["nickName"] = $this->userInfo["jkx"]["realname"];
|
||||
$userInfoBase["jifen"] = $this->userInfo["jifen_account"];
|
||||
$result["usertype"] = $this->userInfo["auth_type"];
|
||||
$result["error"] = "0";
|
||||
$result["data"] = $userInfoBase;
|
||||
$result["dataContent"] = $this->userInfo["jkx"];
|
||||
return $result;
|
||||
}
|
||||
|
||||
//case AUTHTYPE_MEMBER:
|
||||
//case AUTHTYPE_NIUNIUGAME:
|
||||
default:
|
||||
{
|
||||
$result["usertype"] = $this->userInfo["auth_type"];
|
||||
$result["error"] = "0";
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return $verify_result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过scode和sid获取用户信息
|
||||
* @route({"POST","/"})
|
||||
* @param({"appid","$._POST.appid"}) 应用appid
|
||||
* @param({"devkey","$._POST.devkey"}) 开发者key
|
||||
* @param({"market_key","$._POST.market_key"}) 门店Key
|
||||
* @param({"sid","$._POST.sid"}) 服务器返回的sid
|
||||
* @param({"scode","$._POST.scode"}) 客户端生成的Scode
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
*/
|
||||
public function getUserByPostSid($appid = "", $devkey = "", $market_key = "", $sid = "", $scode = "")
|
||||
{
|
||||
// 验证公共参数是否合法
|
||||
parent::init($appid, $devkey, $sid, $scode, $market_key);
|
||||
$verify_result = parent::verify();
|
||||
if (!is_error_api($verify_result))
|
||||
{
|
||||
if (!empty($market_key))
|
||||
{
|
||||
if ($this->marketInfo["market_key"] != $market_key)
|
||||
{
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 10011;
|
||||
$result["msg"] = "指定的SID和market_key不符.";
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
switch ($this->userInfo["auth_type"])
|
||||
{
|
||||
case AUTHTYPE_WECHAT:
|
||||
{
|
||||
$userInfoBase = [
|
||||
'openid' => $this->userInfo['weixin']['openid'],
|
||||
'unionid' => $this->userInfo['weixin']['unionid'],
|
||||
'country' => $this->userInfo['weixin']['country'],
|
||||
'province' => $this->userInfo['weixin']['province'],
|
||||
'city' => $this->userInfo['weixin']['city'],
|
||||
'headImage' => $this->userInfo['weixin']['headimgurl'],
|
||||
'nickName' => $this->userInfo['weixin']['nickname'],
|
||||
'subscribe' => $this->userInfo['weixin']['subscribe'],
|
||||
'subscribe_time' => $this->userInfo['weixin']['subscribe_time'],
|
||||
'jifen' => $this->userInfo['jifen_account'],
|
||||
];
|
||||
|
||||
$result["usertype"] = $this->userInfo["auth_type"];
|
||||
$result["error"] = "0";
|
||||
$result["data"] = $userInfoBase;
|
||||
$result["dataContent"] = $this->userInfo["weixin"];
|
||||
return $result;
|
||||
}
|
||||
|
||||
case AUTHTYPE_QQ:
|
||||
{
|
||||
$userInfoBase = array();
|
||||
$userInfoBase["headImage"] = $this->userInfo["qq"]["figureurl_qq_2"];
|
||||
$userInfoBase["nickName"] = $this->userInfo["qq"]["nickname"];
|
||||
$userInfoBase["jifen"] = $this->userInfo["jifen_account"];
|
||||
$result["usertype"] = $this->userInfo["auth_type"];
|
||||
$result["error"] = "0";
|
||||
$result["data"] = $userInfoBase;
|
||||
$result["dataContent"] = $this->userInfo["qq"];
|
||||
return $result;
|
||||
}
|
||||
|
||||
case AUTHTYPE_JKX:
|
||||
{
|
||||
$userInfoBase = array();
|
||||
$userInfoBase["headImage"] = $this->userInfo["jkx"]["headimgurl"];
|
||||
$userInfoBase["nickName"] = $this->userInfo["jkx"]["realname"];
|
||||
$userInfoBase["jifen"] = $this->userInfo["jifen_account"];
|
||||
$result["usertype"] = $this->userInfo["auth_type"];
|
||||
$result["error"] = "0";
|
||||
$result["data"] = $userInfoBase;
|
||||
$result["dataContent"] = $this->userInfo["jkx"];
|
||||
return $result;
|
||||
}
|
||||
|
||||
//case AUTHTYPE_MEMBER:
|
||||
//case AUTHTYPE_NIUNIUGAME:
|
||||
default:
|
||||
{
|
||||
$result["usertype"] = $this->userInfo["auth_type"];
|
||||
$result["error"] = "0";
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return $verify_result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 直接绑定子账户到主账户
|
||||
* @route({"POST","/bind"})
|
||||
* @param({"devkey","$._POST.devkey"}) 开发者key
|
||||
* @param({"market_key","$._POST.market_key"}) 门店Key
|
||||
* @param({"sid","$._POST.sid"}) 服务器返回的sid
|
||||
* @param({"scode","$._POST.scode"}) 客户端生成的Scode
|
||||
* @param({"mobile_phone","$._POST.mobile_phone"}) 手机号码
|
||||
* @param({"email","$._POST.email"}) 邮箱
|
||||
* @param({"sign","$._POST.sign"}) 签名值
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
*/
|
||||
public function bindMainAccount($devkey = "", $market_key = "", $sid = "", $scode = "", $mobile_phone = "", $email = "", $sign = "")
|
||||
{
|
||||
// 验证公共参数是否合法
|
||||
parent::init($appid, $devkey, $sid, $scode);
|
||||
$verify_result = parent::verify();
|
||||
if (!is_error_api($verify_result))
|
||||
{
|
||||
if ($this->userInfo["auth_type"] == 0)
|
||||
{
|
||||
$userInfoBase = array();
|
||||
$userInfoBase["headImage"] = $this->userInfo["weixin"]["headimgurl"];
|
||||
$userInfoBase["nickName"] = $this->userInfo["weixin"]["nickname"];
|
||||
$userInfoBase["jifen"] = $this->userInfo["jifen_account"];
|
||||
$result["usertype"] = "0";
|
||||
$result["error"] = "0";
|
||||
$result["data"] = $userInfoBase;
|
||||
$result["dataContent"] = $this->userInfo["weixin"];
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$userInfoBase = array();
|
||||
$userInfoBase["headImage"] = $this->userInfo["qq"]["figureurl_qq_2"];
|
||||
$userInfoBase["nickName"] = $this->userInfo["qq"]["nickname"];
|
||||
$userInfoBase["jifen"] = $this->userInfo["jifen_account"];
|
||||
$result["usertype"] = "1";
|
||||
$result["error"] = "0";
|
||||
$result["data"] = $userInfoBase;
|
||||
$result["dataContent"] = $this->userInfo["qq"];
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return $verify_result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断用户是否已经绑定为主账户
|
||||
* @route({"POST","/bind/check"})
|
||||
* @param({"devkey","$._POST.devkey"}) 开发者key
|
||||
* @param({"market_key","$._POST.market_key"}) 门店Key
|
||||
* @param({"sid","$._POST.sid"}) 服务器返回的sid
|
||||
* @param({"scode","$._POST.scode"}) 客户端生成的Scode
|
||||
* @param({"sign","$._POST.sign"}) 签名值
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
*/
|
||||
public function isBindMainAccount($devkey = "", $market_key = "", $sid = "", $scode = "", $sign = "")
|
||||
{
|
||||
// 验证公共参数是否合法
|
||||
parent::init($appid, $devkey, $sid, $scode);
|
||||
$verify_result = parent::verify();
|
||||
if (!is_error_api($verify_result))
|
||||
{
|
||||
if ($this->userInfo["auth_type"] == 0)
|
||||
{
|
||||
$userInfoBase = array();
|
||||
$userInfoBase["headImage"] = $this->userInfo["weixin"]["headimgurl"];
|
||||
$userInfoBase["nickName"] = $this->userInfo["weixin"]["nickname"];
|
||||
$userInfoBase["jifen"] = $this->userInfo["jifen_account"];
|
||||
$result["usertype"] = "0";
|
||||
$result["error"] = "0";
|
||||
$result["data"] = $userInfoBase;
|
||||
$result["dataContent"] = $this->userInfo["weixin"];
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$userInfoBase = array();
|
||||
$userInfoBase["headImage"] = $this->userInfo["qq"]["figureurl_qq_2"];
|
||||
$userInfoBase["nickName"] = $this->userInfo["qq"]["nickname"];
|
||||
$userInfoBase["jifen"] = $this->userInfo["jifen_account"];
|
||||
$result["usertype"] = "1";
|
||||
$result["error"] = "0";
|
||||
$result["data"] = $userInfoBase;
|
||||
$result["dataContent"] = $this->userInfo["qq"];
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return $verify_result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将子账户从主账户中解绑
|
||||
* @route({"POST","/unbind"})
|
||||
* @param({"devkey","$._POST.devkey"}) 开发者key
|
||||
* @param({"market_key","$._POST.market_key"}) 门店Key
|
||||
* @param({"sid","$._POST.sid"}) 服务器返回的sid
|
||||
* @param({"scode","$._POST.scode"}) 客户端生成的Scode
|
||||
* @param({"sign","$._POST.sign"}) 签名值
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
*/
|
||||
public function unbindFromMainAccount($devkey = "", $market_key = "", $sid = "", $scode = "", $sign = "")
|
||||
{
|
||||
// 验证公共参数是否合法
|
||||
parent::init($appid, $devkey, $sid, $scode);
|
||||
$verify_result = parent::verify();
|
||||
if (!is_error_api($verify_result))
|
||||
{
|
||||
if ($this->userInfo["auth_type"] == 0)
|
||||
{
|
||||
$userInfoBase = array();
|
||||
$userInfoBase["headImage"] = $this->userInfo["weixin"]["headimgurl"];
|
||||
$userInfoBase["nickName"] = $this->userInfo["weixin"]["nickname"];
|
||||
$userInfoBase["jifen"] = $this->userInfo["jifen_account"];
|
||||
$result["usertype"] = "0";
|
||||
$result["error"] = "0";
|
||||
$result["data"] = $userInfoBase;
|
||||
$result["dataContent"] = $this->userInfo["weixin"];
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$userInfoBase = array();
|
||||
$userInfoBase["headImage"] = $this->userInfo["qq"]["figureurl_qq_2"];
|
||||
$userInfoBase["nickName"] = $this->userInfo["qq"]["nickname"];
|
||||
$userInfoBase["jifen"] = $this->userInfo["jifen_account"];
|
||||
$result["usertype"] = "1";
|
||||
$result["error"] = "0";
|
||||
$result["data"] = $userInfoBase;
|
||||
$result["dataContent"] = $this->userInfo["qq"];
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return $verify_result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取子账户的其他门店的账户信息,需要关联主账户
|
||||
* @route({"POST","/other"})
|
||||
* @param({"devkey","$._POST.devkey"}) 开发者key
|
||||
* @param({"market_key","$._POST.market_key"}) 门店Key
|
||||
* @param({"sid","$._POST.sid"}) 服务器返回的sid
|
||||
* @param({"scode","$._POST.scode"}) 客户端生成的Scode
|
||||
* @param({"sign","$._POST.sign"}) 签名值
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
*/
|
||||
public function getOtherMarket($devkey = "", $market_key = "", $sid = "", $scode = "", $sign = "")
|
||||
{
|
||||
// 验证公共参数是否合法
|
||||
parent::init($appid, $devkey, $sid, $scode);
|
||||
$verify_result = parent::verify();
|
||||
if (!is_error_api($verify_result))
|
||||
{
|
||||
if ($this->userInfo["auth_type"] == 0)
|
||||
{
|
||||
$userInfoBase = array();
|
||||
$userInfoBase["headImage"] = $this->userInfo["weixin"]["headimgurl"];
|
||||
$userInfoBase["nickName"] = $this->userInfo["weixin"]["nickname"];
|
||||
$userInfoBase["jifen"] = $this->userInfo["jifen_account"];
|
||||
$result["usertype"] = "0";
|
||||
$result["error"] = "0";
|
||||
$result["data"] = $userInfoBase;
|
||||
$result["dataContent"] = $this->userInfo["weixin"];
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$userInfoBase = array();
|
||||
$userInfoBase["headImage"] = $this->userInfo["qq"]["figureurl_qq_2"];
|
||||
$userInfoBase["nickName"] = $this->userInfo["qq"]["nickname"];
|
||||
$userInfoBase["jifen"] = $this->userInfo["jifen_account"];
|
||||
$result["usertype"] = "1";
|
||||
$result["error"] = "0";
|
||||
$result["data"] = $userInfoBase;
|
||||
$result["dataContent"] = $this->userInfo["qq"];
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return $verify_result;
|
||||
}
|
||||
}
|
||||
|
||||
/** @inject("ioc_factory") */
|
||||
private $factory;
|
||||
/**
|
||||
* @property({"default":"@db"})
|
||||
* @var PDO
|
||||
*/
|
||||
public $db;
|
||||
// 此处删除了代码
|
||||
}
|
||||
69
codes/agent/game-docker/api/source/apis/weixinTools.php
Normal file
69
codes/agent/game-docker/api/source/apis/weixinTools.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, PATCH, DELETE");
|
||||
header("Access-Control-Allow-Headers: Content-Type, Authorization, Content-Length, X-Requested-With");
|
||||
header("Access-Control-Allow-Credentials: true");
|
||||
header("Content-Type: text/html; charset=utf-8");
|
||||
|
||||
|
||||
use phprs\util\Verify;
|
||||
use phprs\util\exceptions\Forbidden;
|
||||
use phprs\util\Logger;
|
||||
use phprs\util\exceptions\NotFound;
|
||||
use phprs\ezsql\Sql;
|
||||
use phprs\util\exceptions\BadRequest;
|
||||
|
||||
require_once 'apiBase.php';
|
||||
|
||||
/**
|
||||
*
|
||||
* 微信相关接口
|
||||
* @path("/weixin")
|
||||
*/
|
||||
class weixinTools extends apiBase
|
||||
{
|
||||
/**
|
||||
* 获得微信分享参数信息(错误代码:12701-12750)
|
||||
* @route({"POST","/wx_share_info"})
|
||||
* @param({"appid","$._POST.appid"}) 所属公众号
|
||||
* @param({"devkey","$._POST.devkey"}) 外部应用ID
|
||||
* @param({"sid","$._POST.sid"}) 临时会员ID
|
||||
* @param({"scode","$._POST.scode"}) 客户端票据
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
*/
|
||||
public function getWeixinShareInfo($appid = '', $devkey = '', $sid = '', $scode = '')
|
||||
{
|
||||
// 验证公共参数是否合法
|
||||
parent::init($appid, $devkey, $sid, $scode);
|
||||
$verify_result = parent::verify();
|
||||
|
||||
if (!is_error_api($verify_result))
|
||||
{
|
||||
$refererUrl = $_SERVER['HTTP_REFERER'];
|
||||
if ($this->userInfo["auth_type"] == AUTHTYPE_WECHAT)
|
||||
{
|
||||
$account = array('key' => $this->marketInfo['weixin_appid']);
|
||||
$weixin = new WeiXinAccount($account);
|
||||
$share_config = $weixin->getAjaxJssdkConfig($refererUrl, $this->db, $this->db);
|
||||
if (!is_error($share_config) && !empty($share_config))
|
||||
return new returnObject(0, 0, '', $share_config);
|
||||
else
|
||||
return new returnObject(1, 12702, '获取微信分享参数失败。');
|
||||
}
|
||||
else
|
||||
return new returnObject(1, 12701, '只有微信登录状态下能进行分享。');
|
||||
}
|
||||
else
|
||||
return $verify_result;
|
||||
}
|
||||
|
||||
|
||||
/** @inject("ioc_factory") */
|
||||
private $factory;
|
||||
/**
|
||||
* @property({"default":"@db"})
|
||||
* @var PDO
|
||||
*/
|
||||
public $db;
|
||||
// 此处删除了代码
|
||||
}
|
||||
368
codes/agent/game-docker/api/source/apis/wholeCountryAddress.php
Normal file
368
codes/agent/game-docker/api/source/apis/wholeCountryAddress.php
Normal file
@@ -0,0 +1,368 @@
|
||||
<?php
|
||||
header("Access-Control-Allow-Origin: *");
|
||||
header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, PATCH, DELETE");
|
||||
header("Access-Control-Allow-Headers: Content-Type, Authorization, Content-Length, X-Requested-With");
|
||||
header("Access-Control-Allow-Credentials: true");
|
||||
header("Content-Type: text/html; charset=utf-8");
|
||||
|
||||
/**
|
||||
* 地区管理接口
|
||||
*/
|
||||
use phprs\util\Verify;
|
||||
use phprs\util\exceptions\Forbidden;
|
||||
use phprs\util\Logger;
|
||||
use phprs\util\exceptions\NotFound;
|
||||
use phprs\ezsql\Sql;
|
||||
use phprs\util\exceptions\BadRequest;
|
||||
|
||||
require_once 'apiBase.php';
|
||||
/**
|
||||
*
|
||||
* 地区管理
|
||||
* @path("/wcaddress")
|
||||
*/
|
||||
class WholeCountryAddress extends apiBase{
|
||||
/**
|
||||
* 根据上级地区Code查询下级地区列表
|
||||
* @route({"POST","/"})
|
||||
* @param({"appid","$._POST.appid"}) 应用appid
|
||||
* @param({"devkey","$._POST.devkey"}) 开发者key
|
||||
* @param({"parentcode","$._POST.parentcode"}) 地区指定代码parentcode
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
* @return("body")
|
||||
*/
|
||||
public function getAddressListByParentCode($appid = "",$devkey="",$parentcode="{=NULL=}"){
|
||||
$result = array();
|
||||
if( empty($appid) ){
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 10001; // 请传入APPID参数
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
$appInfo = Sql::select('syweb_app.*')
|
||||
->from('syweb_app')
|
||||
->where('syweb_app.appid=?', $appid)
|
||||
->get($this->db ,null);
|
||||
if( empty($appInfo) || count($appInfo)<=0 ){
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 10002; // 指定的应用不存在
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
if( empty($devkey) ){
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 10003; // 请传入DevKey参数
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
if ( $parentcode=='{=NULL=}' ) {
|
||||
$result[0]["error"] = "1";
|
||||
$result[0]["error_code"] = 10006; // 请传入地区父ID
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
$res = Sql::select('a.*')
|
||||
->from('syweb_whole_country_address a')
|
||||
->where('a.address_parent_code=?', $parentcode)
|
||||
->get($this->db ,null);
|
||||
if( !empty($res) && count($res)>0 ){
|
||||
$result[0]["error"] = "0";
|
||||
$result[0]["data"] = $res;
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
}else{
|
||||
$result[0]["error"] = "0";
|
||||
$result[0]["data"] = array();
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据数据存储会员收货地址(错误代码:12701-12750)
|
||||
* @route({"POST","/save"})
|
||||
* @param({"appid","$._POST.appid"}) 应用appid
|
||||
* @param({"devkey","$._POST.devkey"}) 开发者key
|
||||
* @param({"sid","$._POST.sid"}) 服务器返回的sid
|
||||
* @param({"scode","$._POST.scode"}) 客户端生成的Scode
|
||||
* @param({"id","$._POST.id"}) 收货地址系统编号
|
||||
* @param({"province_code","$._POST.province_code"}) 省份地区编号
|
||||
* @param({"city_code","$._POST.city_code"}) 城市编号
|
||||
* @param({"country_code","$._POST.country_code"}) 县区编号
|
||||
* @param({"street_code","$._POST.street_code"}) 街道编号
|
||||
* @param({"address_detail","$._POST.address_detail"}) 详细地址
|
||||
* @param({"realname","$._POST.realname"}) 收货人真实姓名
|
||||
* @param({"tel","$._POST.tel"}) 收货人电话
|
||||
* @param({"lng","$._POST.lng"}) 客户收货地址所在经度
|
||||
* @param({"lat","$._POST.lat"}) 客户收货地址所在纬度
|
||||
* @param({"isdefault","$._POST.isdefault"}) 是否设置为默认收货地址
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
* @return("body")
|
||||
*/
|
||||
public function postUserAddress($appid='',$devkey='',$sid="",$scode="",$id="",$province_code="",$city_code="",$country_code="",$street_code="",$address_detail='',$realname='',$tel='',$lng='',$lat='',$isdefault=''){
|
||||
// 验证公共参数是否合法
|
||||
parent::init($appid,$devkey,$sid,$scode);
|
||||
$verify_result = parent::verify();
|
||||
|
||||
if( !is_error_api($verify_result) ){
|
||||
if ( !empty($isdefault) && $isdefault=="1" ) {
|
||||
$isdefault = 1;
|
||||
}else{
|
||||
$isdefault = 0;
|
||||
}
|
||||
|
||||
if( !empty($id) && is_numeric($id) ){
|
||||
$updateSql = Sql::update('syweb_users_address');
|
||||
$updateSql->set("province_code",$province_code);// 省份地区Code
|
||||
$updateSql->set("city_code",$city_code);// 城市地区Code
|
||||
$updateSql->set("country_code",$country_code);// 县区Code
|
||||
$updateSql->set("street_code",$street_code);// 街道Code
|
||||
$updateSql->set("address_detail",$address_detail);// 详细地址
|
||||
$updateSql->set("realname",$realname);// 收货人姓名
|
||||
$updateSql->set("tel",$tel);// 收货人联系电话
|
||||
$updateSql->set("lng",$lng);// 经度
|
||||
$updateSql->set("lat",$lat);// 纬度
|
||||
$updateSql->where(" `id` = ".$id);
|
||||
|
||||
$pdo = $this->db;
|
||||
$pdo->beginTransaction();
|
||||
$updateCount = $updateSql->exec($pdo);
|
||||
if( $isdefault==1 ){
|
||||
// 修改会员默认收货地址 begin
|
||||
$setDefaultAddressSql = Sql::update('syweb_users');
|
||||
$setDefaultAddressSql->set("address_id",$id);
|
||||
$setDefaultAddressSql->where(" `id` = ".$this->userInfo['id']);
|
||||
$setDefaultAddressSql->exec($pdo);
|
||||
// 修改会员默认收货地址 end
|
||||
}
|
||||
$pdo->commit();
|
||||
$result["error"] = '0';
|
||||
$result["message"] = '收货地址修改成功。';
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
} else {
|
||||
$insertData = array();
|
||||
$insertData['uid'] = $this->userInfo['id'];// 会员用户ID
|
||||
$insertData['business_id'] = $this->businessInfo["id"];// 商户ID
|
||||
$insertData['province_code'] = $province_code;// 省份地区Code
|
||||
$insertData['city_code'] = $city_code;// 城市地区Code
|
||||
$insertData['country_code'] = $country_code;// 县区Code
|
||||
$insertData['street_code'] = $street_code;// 街道Code
|
||||
$insertData['address_detail'] = $address_detail;// 详细地址
|
||||
$insertData['realname'] = $realname;// 收货人姓名
|
||||
$insertData['tel'] = $tel;// 收货人联系电话
|
||||
$insertData['lng'] = $lng;// 经度
|
||||
$insertData['lat'] = $lat;// 纬度
|
||||
$insertData['createtime'] = TIMESTAMP;
|
||||
|
||||
$pdo = $this->db;
|
||||
$pdo->beginTransaction();
|
||||
$addressId = Sql::insertInto('syweb_users_address')->values($insertData)->exec($pdo)->lastInsertId();
|
||||
|
||||
if( $isdefault==1 ){
|
||||
// 修改会员默认收货地址 begin
|
||||
$setDefaultAddressSql = Sql::update('syweb_users');
|
||||
$setDefaultAddressSql->set("address_id",$addressId);
|
||||
$setDefaultAddressSql->where(" `id` = ".$this->userInfo['id']);
|
||||
$setDefaultAddressSql->exec($pdo);
|
||||
// 修改会员默认收货地址 end
|
||||
}
|
||||
$pdo->commit();
|
||||
|
||||
if ( !empty($addressId) ) {
|
||||
$result["error"] = '0';
|
||||
$result["id"] = $addressId;
|
||||
$result["message"] = '收货地址存储成功。';
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
}else{
|
||||
$result["status"] = '1';
|
||||
$result["error_code"] = 12701; // 用户收货地址存储失败
|
||||
$result["msg"] = "用户收货地址存储失败";
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
return json_encode($verify_result,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询当前登录会员的收货地址列表(错误代码:12751-12800)
|
||||
* @route({"POST","/list"})
|
||||
* @param({"appid","$._POST.appid"}) 应用appid
|
||||
* @param({"devkey","$._POST.devkey"}) 开发者key
|
||||
* @param({"sid","$._POST.sid"}) 服务器返回的sid
|
||||
* @param({"scode","$._POST.scode"}) 客户端生成的scode
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
*/
|
||||
public function queryUserAddressList($appid='',$devkey='',$sid='',$scode='') {
|
||||
// 验证公共参数是否合法
|
||||
parent::init($appid,$devkey,$sid,$scode);
|
||||
$verify_result = parent::verify();
|
||||
|
||||
if( !is_error_api($verify_result) ){
|
||||
$result = array();
|
||||
|
||||
$fields = "a.id,a.province_code,(select address_name from syweb_whole_country_address where address_code=a.province_code) as province_name,a.city_code,(select address_name from syweb_whole_country_address where address_code=a.city_code) as city_name,a.country_code,(select address_name from syweb_whole_country_address where address_code=a.country_code) as country_name,a.street_code,(select address_name from syweb_whole_country_address where address_code=a.street_code) as street_name,a.address_detail,a.realname,a.tel,a.lng,a.lat,a.createtime";
|
||||
$addressList = Sql::select($fields)
|
||||
->from('syweb_users_address a')
|
||||
->where('a.business_id=? and a.uid=?', $this->businessInfo['id'],$this->userInfo['id'])
|
||||
->get($this->db ,null);
|
||||
if(!empty($addressList) && count($addressList)>0){
|
||||
foreach ($addressList as $key => &$row) {
|
||||
if( $row['id']==$this->userInfo['address_id'] ){
|
||||
$row['isdefault'] = 1;
|
||||
}else{
|
||||
$row['isdefault'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$result["error"] = "0";
|
||||
$result["data"] = $addressList;
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
} else {
|
||||
$result["error"] = '0';
|
||||
$result["data"] = array();
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
}else{
|
||||
return json_encode($verify_result,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据收货地址的ID查询收货地址详细信息(错误代码:12801-12850)
|
||||
* @route({"POST","/info"})
|
||||
* @param({"appid","$._POST.appid"}) 应用appid
|
||||
* @param({"devkey","$._POST.devkey"}) 开发者key
|
||||
* @param({"sid","$._POST.sid"}) 服务器返回的sid
|
||||
* @param({"scode","$._POST.scode"}) 客户端生成的scode
|
||||
* @param({"id","$._POST.id"}) 收货地址ID
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
*/
|
||||
public function queryUserAddressInfo($appid='',$devkey='',$sid='',$scode='',$id='') {
|
||||
// 验证公共参数是否合法
|
||||
parent::init($appid,$devkey,$sid,$scode);
|
||||
$verify_result = parent::verify();
|
||||
|
||||
if( !is_error_api($verify_result) ){
|
||||
$result = array();
|
||||
|
||||
if(empty($id) || !is_numeric($id)){
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12801; // 请传入地址ID
|
||||
$result["msg"] = "请传入地址ID";
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
$fields = "a.id,a.province_code,(select address_name from syweb_whole_country_address where address_code=a.province_code) as province_name,a.city_code,(select address_name from syweb_whole_country_address where address_code=a.city_code) as city_name,a.country_code,(select address_name from syweb_whole_country_address where address_code=a.country_code) as country_name,a.street_code,(select address_name from syweb_whole_country_address where address_code=a.street_code) as street_name,a.address_detail,a.realname,a.tel,a.lng,a.lat,a.createtime";
|
||||
$addressInfo = Sql::select($fields)
|
||||
->from('syweb_users_address a')
|
||||
->where('a.business_id=? and a.uid=? and a.id=?', $this->businessInfo['id'],$this->userInfo['id'],$id)
|
||||
->get($this->db ,null);
|
||||
if(!empty($addressInfo) && count($addressInfo)>0){
|
||||
if( $addressInfo[0]['id']==$this->userInfo['address_id'] ){
|
||||
$addressInfo[0]['isdefault'] = 1;
|
||||
}else{
|
||||
$addressInfo[0]['isdefault'] = 0;
|
||||
}
|
||||
$result["error"] = "0";
|
||||
$result["data"] = $addressInfo[0];
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
} else {
|
||||
$result["error"] = '0';
|
||||
$result["data"] = array();
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
}else{
|
||||
return json_encode($verify_result,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户默认收货地址(错误代码:12851-12900)
|
||||
* @route({"POST","/defaddr"})
|
||||
* @param({"appid","$._POST.appid"}) 应用appid
|
||||
* @param({"devkey","$._POST.devkey"}) 开发者key
|
||||
* @param({"sid","$._POST.sid"}) 服务器返回的sid
|
||||
* @param({"scode","$._POST.scode"}) 客户端生成的scode
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
*/
|
||||
public function queryUserDefaultAddressDefault($appid='',$devkey='',$sid='',$scode='') {
|
||||
// 验证公共参数是否合法
|
||||
parent::init($appid,$devkey,$sid,$scode);
|
||||
$verify_result = parent::verify();
|
||||
|
||||
if( !is_error_api($verify_result) ){
|
||||
$result = array();
|
||||
|
||||
$defaultAddressId = $this->userInfo['address_id'];
|
||||
if( !empty($defaultAddressId) && is_numeric($defaultAddressId) ){
|
||||
$fields = "a.id,a.province_code,(select address_name from syweb_whole_country_address where address_code=a.province_code) as province_name,a.city_code,(select address_name from syweb_whole_country_address where address_code=a.city_code) as city_name,a.country_code,(select address_name from syweb_whole_country_address where address_code=a.country_code) as country_name,a.street_code,(select address_name from syweb_whole_country_address where address_code=a.street_code) as street_name,a.address_detail,a.realname,a.tel,a.lng,a.lat,a.createtime";
|
||||
$addressInfo = Sql::select($fields)
|
||||
->from('syweb_users_address a')
|
||||
->where('a.business_id=? and a.uid=? and a.id=?', $this->businessInfo['id'],$this->userInfo['id'],$defaultAddressId)
|
||||
->get($this->db ,null);
|
||||
if(!empty($addressInfo) && count($addressInfo)>0){
|
||||
$result[0]["error"] = "0";
|
||||
$result[0]["data"] = $addressInfo[0];
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
} else {
|
||||
$result["error"] = '0';
|
||||
$result["data"] = array();
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
} else {
|
||||
$result["error"] = '1';
|
||||
$result["error_code"] = 12851; // 没有设置默认地址
|
||||
$result["msg"] = "没有设置默认地址";
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
}else{
|
||||
return json_encode($verify_result,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件删除收货地址(错误代码:12901-12950)
|
||||
* @route({"POST","/delete"})
|
||||
* @param({"appid","$._POST.appid"}) 应用appid
|
||||
* @param({"devkey","$._POST.devkey"}) 开发者key
|
||||
* @param({"sid","$._POST.sid"}) 服务器返回的sid
|
||||
* @param({"scode","$._POST.scode"}) 客户端生成的scode
|
||||
* @param({"id","$._POST.id"}) 收货地址系统编号
|
||||
* @throws({"phprs\util\exceptions\Forbidden","res", "403 Forbidden",{"error":"Forbidden"}}) cookie不可用
|
||||
* @return("body")
|
||||
*/
|
||||
public function postDelData($appid='',$devkey='',$sid='',$scode='',$id=''){
|
||||
// 验证公共参数是否合法
|
||||
parent::init($appid,$devkey,$sid,$scode);
|
||||
$verify_result = parent::verify();
|
||||
|
||||
if( !is_error_api($verify_result) ){
|
||||
$result = array();
|
||||
|
||||
if( empty($id) || !is_numeric($id) ){
|
||||
$result["error"] = "1";
|
||||
$result["error_code"] = 12901; // 请传入收货地址编号
|
||||
$result["msg"] = "请传入收货地址编号";
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
$condition .= " `id` = ".$id;
|
||||
$pdo = $this->db;
|
||||
$pdo->beginTransaction();
|
||||
$delResult = Sql::deleteFrom('syweb_users_address')->where($condition)->exec($this->db);
|
||||
$this->db->commit();
|
||||
|
||||
$result["error"] = "0";
|
||||
$result["message"] = "删除收货地址成功!";
|
||||
return json_encode($result,JSON_UNESCAPED_UNICODE);
|
||||
}else{
|
||||
return json_encode($verify_result,JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
}
|
||||
|
||||
/** @inject("ioc_factory") */
|
||||
private $factory;
|
||||
/**
|
||||
* @property({"default":"@db"})
|
||||
* @var PDO
|
||||
*/
|
||||
public $db;
|
||||
// 此处删除了代码
|
||||
}
|
||||
Reference in New Issue
Block a user