Browse Source

user

master
ZLW-PC\Administrator 6 years ago
parent
commit
e4d3c89f4c
  1. 2
      app/Common/ReturnData.php
  2. 2
      app/Common/Token.php
  3. 56
      app/Http/Controllers/Api/CustomController.php
  4. 120
      app/Http/Controllers/Api/ImageController.php
  5. 2
      app/Http/Controllers/Api/QrcodeController.php
  6. 240
      app/Http/Controllers/Api/UserController.php
  7. 113
      app/Http/Controllers/Api/UserGoodsHistoryController.php
  8. 104
      app/Http/Controllers/Api/UserMessageController.php
  9. 91
      app/Http/Controllers/Api/UserMoneyController.php
  10. 89
      app/Http/Controllers/Api/UserPointController.php
  11. 115
      app/Http/Controllers/Api/UserRechargeController.php
  12. 118
      app/Http/Controllers/Api/UserWithdrawController.php
  13. 2
      app/Http/Controllers/Weixin/UserController.php
  14. 12
      app/Http/Logic/ArctypeLogic.php
  15. 12
      app/Http/Logic/ArticleLogic.php
  16. 13
      app/Http/Logic/BonusLogic.php
  17. 10
      app/Http/Logic/CartLogic.php
  18. 12
      app/Http/Logic/CollectGoodsLogic.php
  19. 12
      app/Http/Logic/CommentLogic.php
  20. 12
      app/Http/Logic/FeedbackLogic.php
  21. 12
      app/Http/Logic/FriendlinkLogic.php
  22. 12
      app/Http/Logic/GoodsBrandLogic.php
  23. 12
      app/Http/Logic/GoodsImgLogic.php
  24. 12
      app/Http/Logic/GoodsLogic.php
  25. 12
      app/Http/Logic/GoodsSearchwordLogic.php
  26. 12
      app/Http/Logic/GoodsTypeLogic.php
  27. 12
      app/Http/Logic/GuestbookLogic.php
  28. 12
      app/Http/Logic/KeywordLogic.php
  29. 12
      app/Http/Logic/KuaidiLogic.php
  30. 12
      app/Http/Logic/MenuLogic.php
  31. 12
      app/Http/Logic/OrderGoodsLogic.php
  32. 12
      app/Http/Logic/OrderLogic.php
  33. 12
      app/Http/Logic/PageLogic.php
  34. 12
      app/Http/Logic/PaymentLogic.php
  35. 12
      app/Http/Logic/RegionLogic.php
  36. 12
      app/Http/Logic/SearchwordLogic.php
  37. 12
      app/Http/Logic/SlideLogic.php
  38. 12
      app/Http/Logic/SmsLogLogic.php
  39. 12
      app/Http/Logic/SysconfigLogic.php
  40. 12
      app/Http/Logic/TagindexLogic.php
  41. 12
      app/Http/Logic/TaglistLogic.php
  42. 12
      app/Http/Logic/TokenLogic.php
  43. 12
      app/Http/Logic/UserAddressLogic.php
  44. 12
      app/Http/Logic/UserBonusLogic.php
  45. 23
      app/Http/Logic/UserGoodsHistoryLogic.php
  46. 114
      app/Http/Logic/UserLogic.php
  47. 14
      app/Http/Logic/UserMessageLogic.php
  48. 51
      app/Http/Logic/UserMoneyLogic.php
  49. 51
      app/Http/Logic/UserPointLogic.php
  50. 54
      app/Http/Logic/UserRechargeLogic.php
  51. 12
      app/Http/Logic/UserRoleLogic.php
  52. 80
      app/Http/Logic/UserWithdrawLogic.php
  53. 12
      app/Http/Logic/VerifyCodeLogic.php
  54. 12
      app/Http/Logic/WeixinMenuLogic.php
  55. 194
      app/Http/Model/User.php
  56. 96
      app/Http/Model/UserGoodsHistory.php
  57. 67
      app/Http/Model/UserMessage.php
  58. 76
      app/Http/Model/UserMoney.php
  59. 69
      app/Http/Model/UserPoint.php
  60. 71
      app/Http/Model/UserRecharge.php
  61. 102
      app/Http/Model/UserWithdraw.php
  62. 92
      app/Http/Requests/UserGoodsHistoryRequest.php
  63. 102
      app/Http/Requests/UserMessageRequest.php
  64. 101
      app/Http/Requests/UserMoneyRequest.php
  65. 101
      app/Http/Requests/UserPointRequest.php
  66. 110
      app/Http/Requests/UserRechargeRequest.php
  67. 1
      app/Http/Requests/UserRequest.php
  68. 113
      app/Http/Requests/UserWithdrawRequest.php
  69. 106
      app/Http/Service/AliyunOSS.php
  70. 2
      composer.json
  71. 262
      resources/org/OSS/Core/MimeTypes.php
  72. 54
      resources/org/OSS/Core/OssException.php
  73. 461
      resources/org/OSS/Core/OssUtil.php
  74. 25
      resources/org/OSS/Http/LICENSE
  75. 896
      resources/org/OSS/Http/RequestCore.php
  76. 8
      resources/org/OSS/Http/RequestCore_Exception.php
  77. 56
      resources/org/OSS/Http/ResponseCore.php
  78. 78
      resources/org/OSS/Model/BucketInfo.php
  79. 39
      resources/org/OSS/Model/BucketListInfo.php
  80. 99
      resources/org/OSS/Model/CnameConfig.php
  81. 113
      resources/org/OSS/Model/CorsConfig.php
  82. 150
      resources/org/OSS/Model/CorsRule.php
  83. 34
      resources/org/OSS/Model/GetLiveChannelHistory.php
  84. 68
      resources/org/OSS/Model/GetLiveChannelInfo.php
  85. 107
      resources/org/OSS/Model/GetLiveChannelStatus.php
  86. 88
      resources/org/OSS/Model/LifecycleAction.php
  87. 107
      resources/org/OSS/Model/LifecycleConfig.php
  88. 126
      resources/org/OSS/Model/LifecycleRule.php
  89. 134
      resources/org/OSS/Model/ListMultipartUploadInfo.php
  90. 97
      resources/org/OSS/Model/ListPartsInfo.php
  91. 121
      resources/org/OSS/Model/LiveChannelConfig.php
  92. 59
      resources/org/OSS/Model/LiveChannelHistory.php
  93. 107
      resources/org/OSS/Model/LiveChannelInfo.php
  94. 107
      resources/org/OSS/Model/LiveChannelListInfo.php
  95. 86
      resources/org/OSS/Model/LoggingConfig.php
  96. 93
      resources/org/OSS/Model/ObjectInfo.php
  97. 126
      resources/org/OSS/Model/ObjectListInfo.php
  98. 63
      resources/org/OSS/Model/PartInfo.php
  99. 36
      resources/org/OSS/Model/PrefixInfo.php
  100. 93
      resources/org/OSS/Model/RefererConfig.php

2
app/Common/ReturnData.php

@ -5,6 +5,7 @@ class ReturnData
{
//通用
const SUCCESS = 0; //操作成功
const FAIL = 1; //操作失败
const FORBIDDEN = 8001; //权限不足
const SYSTEM_FAIL = 8002; //系统错误,如数据写入失败之类的
const PARAMS_ERROR = 8003; //参数错误
@ -54,6 +55,7 @@ class ReturnData
//中文错误详情
public static $codeTexts = array(
0 => '操作成功',
1 => '操作失败',
8001 => '权限不足',
8002 => '系统错误,请联系管理员',
8003 => '参数错误',

2
app/Common/Token.php

@ -87,7 +87,7 @@ class Token
{
if($data == $token->data && strtotime($token->expired_at)>time())
{
return array('access_token'=>$token->token,'expired_at'=>$token->expired_at);
return array('access_token'=>$token->token,'expired_at'=>$token->expired_at,'uid'=>$token->uid,'type'=>$token->type);
}
}

56
app/Http/Controllers/Api/CustomController.php

@ -1,56 +0,0 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Api\CommonController;
use Illuminate\Http\Request;
use App\Common\ReturnData;
use App\Common\Token;
class CustomController extends CommonController
{
public function __construct()
{
parent::__construct();
}
public function userMoneyList(Request $request)
{
//参数
$data['limit'] = $request->input('limit', 10);
$data['offset'] = $request->input('offset', 0);
if($request->input('type', null) !== null){$data['type'] = $request->input('type');}
$res = UserMoney::getList($data);
if(!$res)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL);
}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//添加余额明细
public function userMoneyAdd(Request $request)
{
//参数
$data['type'] = $request->input('type',null);
$data['money'] = $request->input('money',null);
$data['des'] = $request->input('des',null);
if($request->input('user_money', null) !== null){$data['user_money'] = $request->input('user_money');}
$data['add_time'] = time();
$data['user_id'] = Token::$uid;
if($data['type']===null || $data['money']===null || $data['des']===null)
{
return ReturnData::create(ReturnData::PARAMS_ERROR);
}
$res = UserMoney::add($data);
if(!$res)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL);
}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
}

120
app/Http/Controllers/Api/ImageController.php

@ -1,7 +1,6 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Api\CommonController;
use Illuminate\Http\Request;
use App\Common\ReturnData;
use App\Common\Helper;
@ -68,6 +67,19 @@ class ImageController extends CommonController
return ReturnData::create(ReturnData::SUCCESS,$image_path);
}
//阿里云OSS图片上传
public function ossImageUpload()
{
$res = $this->aliyunOSSFileUpload($_FILES);
if($res['code'] == 1)
{
$this->success($res['data']);
}
$this->error($res['msg']);
}
/**
* 多文件上传,成功返回路径,不含域名
* 多文件上传格式:
@ -199,4 +211,110 @@ class ImageController extends CommonController
return ReturnData::create(ReturnData::SUCCESS,$res);
}
public function aliyunOSSFileUpload($files)
{
$res = [];
//$files = $_FILES;//得到传输的数据
$path = 'data/uploads/'.date('Y/m',time());
if($files)
{
// 对上传文件数组信息处理
$files = $this->dealFiles($files);
foreach($files as $key=>$file)
{
$type = strtolower(substr(strrchr($file["name"], '.'), 1)); //文件后缀
$image_path = $path.'/'.date('Ymdhis',time()).rand(1000,9999).'.'.$type;
$uploads_path = $path; //存储路径
$allow_type = array('jpg','jpeg','gif','png','doc','docx','txt','pdf'); //定义允许上传的类型
//判断文件类型是否被允许上传
if(!in_array($type, $allow_type))
{
//如果不被允许,则直接停止程序运行
//$this->error('文件格式不正确');
return ['code'=>0,'msg'=>'文件格式不正确','data'=>''];
}
//判断是否是通过HTTP POST上传的
if(!is_uploaded_file($file['tmp_name']))
{
//如果不是通过HTTP POST上传的
//$this->error('上传失败');
return ['code'=>0,'msg'=>'上传失败','data'=>''];
}
//文件小于1M
if ($file["size"] < 2048000)
{
if ($file["error"] > 0)
{
//$this->error($file["error"]);
return ['code'=>0,'msg'=>$file["error"],'data'=>''];
}
else
{
/* if(!file_exists(substr(ROOT_PATH, 0, -1).$uploads_path))
{
Helper::createDir(substr(ROOT_PATH, 0, -1).$uploads_path); //创建文件夹;
}
move_uploaded_file($file["tmp_name"], substr(ROOT_PATH, 0, -1).$image_path); */
$image = AliyunOSS::uploadFile($image_path, $file['tmp_name']);
if($image && $image['code']==1){}else{/* $this->error('系统错误'); */return ['code'=>0,'msg'=>'系统错误','data'=>''];}
}
}
else
{
//$this->error('文件不得超过2M');
return ['code'=>0,'msg'=>'文件不得超过2M','data'=>''];
}
$res[$key] = $image['data']['oss-request-url'];
}
}
else
{
//$this->error('参数错误');
return ['code'=>0,'msg'=>'参数错误','data'=>''];
}
return ['code'=>1,'msg'=>'操作成功','data'=>$res];
}
/**
* 转换上传文件数组变量为正确的方式
* @access public
* @param array $files 上传的文件变量
* @return array
*/
public function dealFiles($files)
{
$fileArray = [];
$n = 0;
foreach ($files as $key => $file) {
if (is_array($file['name'])) {
$keys = array_keys($file);
$count = count($file['name']);
for ($i = 0; $i < $count; $i++) {
$fileArray[$n]['key'] = $key;
foreach ($keys as $_key) {
$fileArray[$n][$_key] = $file[$_key][$i];
}
$n++;
}
} else {
$fileArray = $files;
break;
}
}
return $fileArray;
}
}

2
app/Http/Controllers/Api/QrcodeController.php

@ -1,7 +1,5 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Api\CommonController;
use Illuminate\Http\Request;
use App\Common\ReturnData;
use App\Common\Helper;

240
app/Http/Controllers/Api/UserController.php

@ -73,16 +73,32 @@ class UserController extends CommonController
//修改
public function userUpdate(Request $request)
{
if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$id = $request->input('id');
if(Helper::isPostRequest())
{
unset($_POST['id']);
$where['id'] = $id;
//$where['user_id'] = Token::$uid;
$where['id'] = Token::$uid;
//判断用户名是否已经存在
if($request->input('user_name', null)!==null)
{
if(model('User')->getOne([['user_name', '=', $request->input('user_name')],['id', '<>', Token::$uid]]))
{
return ReturnData::create(ReturnData::PARAMS_ERROR,null,'用户名已存在');
}
}
return $this->getLogic()->edit($_POST,$where);
if($request->input('email', null)!==null){$data['email'] = $request->input('email');}
if($request->input('sex', null)!==null){$data['sex'] = $request->input('sex');}
if($request->input('birthday', null)!==null){$data['birthday'] = $request->input('birthday');}
if($request->input('address_id', null)!==null){$data['address_id'] = $request->input('address_id');}
if($request->input('nickname', null)!==null){$data['nickname'] = $request->input('nickname');}
if($request->input('mobile', null)!==null){$data['mobile'] = $request->input('mobile');}
if($request->input('group_id', null)!==null){$data['group_id'] = $request->input('group_id');}
if($request->input('password', null)!==null){$data['password'] = $request->input('password');}
if($request->input('head_img', null)!==null){$data['head_img'] = $request->input('head_img');}
if($request->input('refund_account', null)!==null){$data['refund_account'] = $request->input('refund_account');}
if($request->input('refund_name', null)!==null){$data['refund_name'] = $request->input('refund_name');}
return $this->getLogic()->edit($data,$where);
}
}
@ -118,65 +134,6 @@ class UserController extends CommonController
return ReturnData::create(ReturnData::SUCCESS,$res);
}
/*
//修改用户信息
public function userInfoUpdate(Request $request)
{
if($request->input('user_name', null)!==null)
{
$data['user_name'] = $request->input('user_name');
if(User::getOneUser($data))
{
return ReturnData::create(ReturnData::PARAMS_ERROR,null,'用户名已存在');
}
}
if($request->input('email', null)!==null){$data['email'] = $request->input('email');}
if($request->input('sex', null)!==null){$data['sex'] = $request->input('sex');}
if($request->input('birthday', null)!==null){$data['birthday'] = $request->input('birthday');}
if($request->input('money', null)!==null){$data['money'] = $request->input('money');}
if($request->input('frozen_money', null)!==null){$data['frozen_money'] = $request->input('frozen_money');}
if($request->input('point', null)!==null){$data['point'] = $request->input('point');}
if($request->input('address_id', null)!==null){$data['address_id'] = $request->input('address_id');}
if($request->input('user_rank', null)!==null){$data['user_rank'] = $request->input('user_rank');}
if($request->input('parent_id', null)!==null){$data['parent_id'] = $request->input('parent_id');}
if($request->input('nickname', null)!==null){$data['nickname'] = $request->input('nickname');}
if($request->input('mobile', null)!==null){$data['mobile'] = $request->input('mobile');}
if($request->input('status', null)!==null){$data['status'] = $request->input('status');}
if($request->input('group_id', null)!==null){$data['group_id'] = $request->input('group_id');}
if($request->input('password', null)!==null){$data['password'] = $request->input('password');}
if($request->input('head_img', null)!==null){$data['head_img'] = $request->input('head_img');}
if($request->input('refund_account', null)!==null){$data['refund_account'] = $request->input('refund_account');}
if($request->input('refund_name', null)!==null){$data['refund_name'] = $request->input('refund_name');}
if (isset($data))
{
User::modify(array('id'=>Token::$uid),$data);
}
return ReturnData::create(ReturnData::SUCCESS);
}
//修改用户余额
public function userMoneyUpdate(Request $request)
{
$data['money'] = $request->input('money','');
if($data['money'] == '' || $data['money'] <= 0)
{
return ReturnData::create(ReturnData::PARAMS_ERROR);
}
$user = User::getOneUser(array('id'=>Token::$uid));
$data['money'] = $user['money'] - $data['money'];
if(User::modify(array('id'=>Token::$uid),$data))
{
return ReturnData::create(ReturnData::SUCCESS);
}
}
//修改用户密码、支付密码
public function userPasswordUpdate(Request $request)
{
@ -184,64 +141,27 @@ class UserController extends CommonController
{
$data['password'] = $request->input('password');
$data['old_password'] = $request->input('old_password');
if($data['password'] == $data['old_password']){return ReturnData::create(ReturnData::PARAMS_ERROR,null,'新旧密码相同');}
}
if($request->input('pay_password', '')!='')
{
$data['pay_password'] = $request->input('pay_password');
$data['old_pay_password'] = $request->input('old_pay_password','');
if($data['pay_password'] == $data['old_pay_password']){return ReturnData::create(ReturnData::PARAMS_ERROR,null,'新旧密码相同');}
}
if (isset($data))
{
$res = User::userPasswordUpdate(array('id'=>Token::$uid),$data);
if($res === false)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL,null,$res);
}
return ReturnData::create(ReturnData::SUCCESS);
if($data['pay_password'] == $data['old_pay_password']){return ReturnData::create(ReturnData::PARAMS_ERROR,null,'新旧支付密码相同');}
}
return ReturnData::create(ReturnData::PARAMS_ERROR);
}
//用户列表
public function userList(Request $request)
{
//参数
$data['limit'] = $request->input('limit', 10);
$data['offset'] = $request->input('offset', 0);
if($request->input('parent_id', '')!=''){$data['parent_id'] = $request->input('parent_id');}
if($request->input('group_id', '')!=''){$data['group_id'] = $request->input('group_id');}
if($request->input('sex', '')!=''){$data['sex'] = $request->input('sex');}
if(!isset($data)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$res = User::getList($data);
if(!$res)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL);
}
return ReturnData::create(ReturnData::SUCCESS,$res);
return $this->getLogic()->userPasswordUpdate($data, array('id'=>Token::$uid));
}
//签到
public function signin(Request $request)
{
$res = User::signin();
if($res !== true)
{
return ReturnData::create(ReturnData::PARAMS_ERROR,null,$res);
}
return ReturnData::create(ReturnData::SUCCESS);
return $this->getLogic()->signin(array('id'=>Token::$uid,'status'=>User::USER_NORMAL_STATUS));
}
//登录
@ -256,14 +176,7 @@ class UserController extends CommonController
return ReturnData::create(ReturnData::PARAMS_ERROR);
}
$res = User::wxLogin($data);
if ($res === false)
{
return ReturnData::create(ReturnData::PARAMS_ERROR,null,'账号或密码错误');
}
return ReturnData::create(ReturnData::SUCCESS,$res);
return $this->getLogic()->wxLogin($data);
}
//注册
@ -272,52 +185,47 @@ class UserController extends CommonController
$data['mobile'] = $request->input('mobile','');
$data['user_name'] = $request->input('user_name','');
$data['password'] = $request->input('password','');
$data['parent_id'] = $request->input('parent_id','');
$parent_mobile = $request->input('parent_mobile',null);
$data['parent_id'] = 0;if($request->input('parent_id',null)!=null){$data['parent_id'] = $request->input('parent_id');}
$parent_mobile = $request->input('parent_mobile','');
if (($data['mobile']=='' && $data['user_name']=='') || $data['password']=='')
{
return ReturnData::create(ReturnData::PARAMS_ERROR);
}
if ($parent_mobile!=null)
if ($parent_mobile!='')
{
if($user = User::getOneUser(array('mobile'=>$parent_mobile)))
if($user = model('User')->getOne(array('mobile'=>$parent_mobile)))
{
$data['parent_id'] = $user->id;
}
else
{
return ReturnData::create(ReturnData::PARAMS_ERROR,null,'推荐人手机号错误');
return ReturnData::create(ReturnData::PARAMS_ERROR,null,'推荐人不存在或推荐人手机号错误');
}
}
if (isset($data['mobile']) && !Helper::isValidMobile($data['mobile']))
if ($data['mobile']!='')
{
return ReturnData::create(ReturnData::MOBILE_FORMAT_FAIL);
//判断手机格式
if(!Helper::isValidMobile($data['mobile'])){return ReturnData::create(ReturnData::MOBILE_FORMAT_FAIL);}
//判断是否已经注册
if (model('User')->getOne(array('mobile'=>$data['mobile'])))
{
return ReturnData::create(ReturnData::MOBILE_EXIST);
}
}
//判断是否已经注册
if (User::getOneUser(array('mobile'=>$data['mobile'])))
if ($data['user_name']!='')
{
return ReturnData::create(ReturnData::MOBILE_EXIST);
}
if (User::getOneUser(array('user_name'=>$data['user_name'])))
{
return ReturnData::create(ReturnData::PARAMS_ERROR,null,'用户名已存在');
}
$data['add_time'] = time();
//添加用户
$res = User::wxRegister($data);
if($res == false)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL);
if (model('User')->getOne(array('user_name'=>$data['user_name'])))
{
return ReturnData::create(ReturnData::PARAMS_ERROR,null,'用户名已存在');
}
}
return ReturnData::create(ReturnData::SUCCESS,$res);
return $this->getLogic()->wxRegister($data);
}
//微信授权注册
@ -328,9 +236,7 @@ class UserController extends CommonController
$data['sex'] = $request->input('sex','');
$data['head_img'] = $request->input('head_img','');
$data['nickname'] = $request->input('nickname','');
$data['parent_id'] = $request->input('parent_id','');
$parent_mobile = $request->input('parent_mobile','');
$data['mobile'] = $request->input('mobile','');
$data['parent_id'] = 0;if($request->input('parent_id',null)!=null){$data['parent_id'] = $request->input('parent_id');}
$data['user_name'] = date('YmdHis').dechex(rand(1000,9999));
$data['password'] = md5('123456');
@ -339,47 +245,19 @@ class UserController extends CommonController
return ReturnData::create(ReturnData::PARAMS_ERROR);
}
if ($parent_mobile!='')
{
if($user = User::getOneUser(array('mobile'=>$parent_mobile)))
{
$data['parent_id'] = $user->id;
}
else
{
return ReturnData::create(ReturnData::PARAMS_ERROR,null,'推荐人手机号错误');
}
}
if (isset($data['mobile']) && !Helper::isValidMobile($data['mobile']))
if (model('User')->getOne(array('openid'=>$data['openid'])))
{
return ReturnData::create(ReturnData::MOBILE_FORMAT_FAIL);
}
//判断是否已经注册
if (User::getOneUser(array('mobile'=>$data['mobile'])))
{
return ReturnData::create(ReturnData::MOBILE_EXIST);
}
if (User::getOneUser(array('openid'=>$data['openid'])))
{
return ReturnData::create(ReturnData::SUCCESS,User::wxLogin(array('openid'=>$data['openid'])));
return $this->getLogic()->wxLogin(array('openid'=>$data['openid']));
}
//添加用户
$res = User::wxRegister($data);
if($res === false)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL);
}
$res = $this->getLogic()->wxRegister($data);
if($res['code'] != ReturnData::SUCCESS){return $res;}
//更新用户名user_name,微信登录没有用户名
$uid = DB::table('user')->where(array('openid'=>$data['openid']))->value('id');
if($uid){User::modify(array('openid'=>$data['openid']),array('user_name'=>'a'.$uid));}
model('User')->edit(array('user_name'=>'u'.$res['code']['data']['uid']),array('id'=>$res['code']['data']['uid']));
return ReturnData::create(ReturnData::SUCCESS,User::wxLogin(array('openid'=>$data['openid'])));
return $this->getLogic()->wxLogin(array('openid'=>$data['openid']));
}
//验证码登录
@ -577,5 +455,5 @@ class UserController extends CommonController
MallDataManager::tokenDelete(['uid'=>Token::$uid]);
return ReturnCode::create(ReturnCode::SUCCESS);
} */
}
}

113
app/Http/Controllers/Api/UserGoodsHistoryController.php

@ -1,13 +1,15 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Api\CommonController;
use Log;
use DB;
use Illuminate\Http\Request;
use App\Common\ReturnData;
use App\Common\Helper;
use App\Common\Token;
use App\Http\Model\UserGoodsHistory;
use App\Http\Logic\UserGoodsHistoryLogic;
//我的足迹
class UserGoodsHistoryController extends CommonController
{
public function __construct()
@ -15,72 +17,89 @@ class UserGoodsHistoryController extends CommonController
parent::__construct();
}
//我的足迹列表
public function getLogic()
{
return logic('UserGoodsHistory');
}
public function userGoodsHistoryList(Request $request)
{
//参数
$data['limit'] = $request->input('limit', 10);
$data['offset'] = $request->input('offset', 0);
$data['user_id'] = Token::$uid;
$res = UserGoodsHistory::getList($data);
if($res === false)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL);
}
$limit = $request->input('limit', 10);
$offset = $request->input('offset', 0);
$where['user_id'] = Token::$uid;
$res = $this->getLogic()->getList($where, array('id', 'desc'), '*', $offset, $limit);
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//我的足迹添加
public function userGoodsHistoryAdd(Request $request)
public function userGoodsHistoryDetail(Request $request)
{
//参数
$data['goods_id'] = $request->input('goods_id',null);
$data['user_id'] = Token::$uid;
if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$id = $request->input('id');
$where['id'] = $id;
if($data['goods_id']===null || $data['user_id']===null)
$res = $this->getLogic()->getOne($where);
if(!$res)
{
return ReturnData::create(ReturnData::PARAMS_ERROR);
}
$res = UserGoodsHistory::add($data);
if($res === false)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL);
return ReturnData::create(ReturnData::RECORD_NOT_EXIST);
}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//删除一条我的足迹
public function userGoodsHistoryDelete(Request $request)
{
//参数
$id = $request->input('id',null);
//添加
public function userGoodsHistoryAdd(Request $request)
{
if(Helper::isPostRequest())
{
$_POST['user_id'] = Token::$uid;
return $this->getLogic()->add($_POST);
}
}
//修改
public function userGoodsHistoryUpdate(Request $request)
{
if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$id = $request->input('id');
$res = UserGoodsHistory::remove($id,Token::$uid);
if($res === false)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL);
}
if(Helper::isPostRequest())
{
unset($_POST['id']);
$where['id'] = $id;
$where['user_id'] = Token::$uid;
return $this->getLogic()->edit($_POST,$where);
}
}
//删除
public function userGoodsHistoryDelete(Request $request)
{
if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$id = $request->input('id');
return ReturnData::create(ReturnData::SUCCESS,$res);
if(Helper::isPostRequest())
{
$where['id'] = $id;
$where['user_id'] = Token::$uid;
return $this->getLogic()->del($where);
}
}
//清空我的足迹
public function userGoodsHistoryClear(Request $request)
{
//参数
$user_id = Token::$uid;
$res = UserGoodsHistory::clear($user_id);
if($res === false)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL);
}
return ReturnData::create(ReturnData::SUCCESS,$res);
if(Helper::isPostRequest())
{
$where['user_id'] = Token::$uid;
return $this->getLogic()->del($where);
}
}
}

104
app/Http/Controllers/Api/UserMessageController.php

@ -1,11 +1,13 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Api\CommonController;
use Log;
use DB;
use Illuminate\Http\Request;
use App\Common\ReturnData;
use App\Common\Helper;
use App\Common\Token;
use App\Http\Model\UserMessage;
use App\Http\Logic\UserMessageLogic;
class UserMessageController extends CommonController
{
@ -14,69 +16,81 @@ class UserMessageController extends CommonController
parent::__construct();
}
//用户消息列表
public function getLogic()
{
return logic('UserMessage');
}
public function userMessageList(Request $request)
{
//参数
$data['limit'] = $request->input('limit', 10);
$data['offset'] = $request->input('offset', 0);
if($request->input('type', '') != ''){$data['type'] = $request->input('type');}
if($request->input('status', '') != ''){$data['status'] = $request->input('status');}
$data['user_id'] = Token::$uid;
$limit = $request->input('limit', 10);
$offset = $request->input('offset', 0);
if($request->input('type', null) != null){$where['type'] = $request->input('type');}
if($request->input('status', null) != null){$where['status'] = $request->input('status');}
$res = UserMessage::getList($data);
if(!$res)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL);
}
$where['user_id'] = Token::$uid;
$res = $this->getLogic()->getList($where, array('id', 'desc'), '*', $offset, $limit);
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//添加用户消息
public function userMessageAdd(Request $request)
public function userMessageDetail(Request $request)
{
//参数
$data['des'] = $request->input('des','');
if($request->input('type', '') != ''){$data['type'] = $request->input('type');}
if($request->input('title', '') != ''){$data['title'] = $request->input('title');}
if($request->input('litpic', '') != ''){$data['litpic'] = $request->input('litpic');}
$data['add_time'] = time();
$data['user_id'] = Token::$uid;
if($data['des']=='')
{
return ReturnData::create(ReturnData::PARAMS_ERROR);
}
if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$id = $request->input('id');
$where['id'] = $id;
$res = UserMessage::add($data);
$res = $this->getLogic()->getOne($where);
if(!$res)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL);
return ReturnData::create(ReturnData::RECORD_NOT_EXIST);
}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//修改用户消息
//添加
public function userMessageAdd(Request $request)
{
if(Helper::isPostRequest())
{
$_POST['user_id'] = Token::$uid;
return $this->getLogic()->add($_POST);
}
}
//修改
public function userMessageUpdate(Request $request)
{
//参数
if($request->input('des', '') != ''){$data['des'] = $request->input('des');}
if($request->input('type', '') != ''){$data['type'] = $request->input('type');}
if($request->input('title', '') != ''){$data['title'] = $request->input('title');}
if($request->input('litpic', '') != ''){$data['litpic'] = $request->input('litpic');}
if($request->input('status', '') != ''){$data['status'] = $request->input('status');}
$where['id'] = $request->input('id');
$where['user_id'] = Token::$uid;
{
if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$id = $request->input('id');
$res = UserMessage::modify($where,$data);
if($res === false)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL);
}
if(Helper::isPostRequest())
{
unset($_POST['id']);
$where['id'] = $id;
$where['user_id'] = Token::$uid;
return $this->getLogic()->edit($_POST,$where);
}
}
//删除
public function userMessageDelete(Request $request)
{
if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$id = $request->input('id');
return ReturnData::create(ReturnData::SUCCESS,$res);
if(Helper::isPostRequest())
{
$where['id'] = $id;
$where['user_id'] = Token::$uid;
return $this->getLogic()->del($where);
}
}
}

91
app/Http/Controllers/Api/UserMoneyController.php

@ -1,12 +1,15 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Api\CommonController;
use Log;
use DB;
use Illuminate\Http\Request;
use App\Common\ReturnData;
use App\Common\Helper;
use App\Common\Token;
use App\Http\Model\UserMoney;
use App\Http\Logic\UserMoneyLogic;
//余额明细
class UserMoneyController extends CommonController
{
public function __construct()
@ -14,46 +17,80 @@ class UserMoneyController extends CommonController
parent::__construct();
}
//余额明细列表
public function getLogic()
{
return logic('UserMoney');
}
public function userMoneyList(Request $request)
{
//参数
$data['limit'] = $request->input('limit', 10);
$data['offset'] = $request->input('offset', 0);
if($request->input('type', null) !== null){$data['type'] = $request->input('type');}
$data['user_id'] = Token::$uid;
$limit = $request->input('limit', 10);
$offset = $request->input('offset', 0);
if($request->input('type', null) != null){$data['type'] = $request->input('type');}
$res = UserMoney::getList($data);
if(!$res)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL);
}
$where['user_id'] = Token::$uid;
$res = $this->getLogic()->getList($where, array('id', 'desc'), '*', $offset, $limit);
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//添加余额明细
public function userMoneyAdd(Request $request)
public function userMoneyDetail(Request $request)
{
//参数
$data['type'] = $request->input('type',null);
$data['money'] = $request->input('money',null);
$data['des'] = $request->input('des',null);
if($request->input('user_money', null) !== null){$data['user_money'] = $request->input('user_money');}
$data['add_time'] = time();
$data['user_id'] = Token::$uid;
if($data['type']===null || $data['money']===null || $data['des']===null)
{
return ReturnData::create(ReturnData::PARAMS_ERROR);
}
if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$id = $request->input('id');
$where['id'] = $id;
$res = UserMoney::add($data);
$res = $this->getLogic()->getOne($where);
if(!$res)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL);
return ReturnData::create(ReturnData::RECORD_NOT_EXIST);
}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//添加
public function userMoneyAdd(Request $request)
{
if(Helper::isPostRequest())
{
$_POST['user_id'] = Token::$uid;
return $this->getLogic()->add($_POST);
}
}
//修改
public function userMoneyUpdate(Request $request)
{
if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$id = $request->input('id');
if(Helper::isPostRequest())
{
unset($_POST['id']);
$where['id'] = $id;
$where['user_id'] = Token::$uid;
return $this->getLogic()->edit($_POST,$where);
}
}
//删除
public function userMoneyDelete(Request $request)
{
if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$id = $request->input('id');
if(Helper::isPostRequest())
{
$where['id'] = $id;
$where['user_id'] = Token::$uid;
return $this->getLogic()->del($where);
}
}
}

89
app/Http/Controllers/Api/UserPointController.php

@ -1,11 +1,13 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Api\CommonController;
use Log;
use DB;
use Illuminate\Http\Request;
use App\Common\ReturnData;
use App\Common\Helper;
use App\Common\Token;
use App\Http\Model\UserPoint;
use App\Http\Logic\UserPointLogic;
class UserPointController extends CommonController
{
@ -14,45 +16,80 @@ class UserPointController extends CommonController
parent::__construct();
}
public function getLogic()
{
return logic('UserPoint');
}
public function userPointList(Request $request)
{
//参数
$data['limit'] = $request->input('limit', 10);
$data['offset'] = $request->input('offset', 0);
if($request->input('type', null) !== null){$data['type'] = $request->input('type');};
$data['user_id'] = Token::$uid;
$limit = $request->input('limit', 10);
$offset = $request->input('offset', 0);
if($request->input('type', null) != null){$data['type'] = $request->input('type');}
$res = UserPoint::getList($data);
if(!$res)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL);
}
$where['user_id'] = Token::$uid;
$res = $this->getLogic()->getList($where, array('id', 'desc'), '*', $offset, $limit);
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//添加积分明细
public function userPointAdd(Request $request)
public function userPointDetail(Request $request)
{
//参数
$data['type'] = $request->input('type',null);
$data['point'] = $request->input('point',null);
$data['des'] = $request->input('des',null);
if($request->input('user_point', null) !== null){$data['user_point'] = $request->input('user_point');}
$data['add_time'] = time();
$data['user_id'] = Token::$uid;
if($data['type']===null || $data['point']===null || $data['des']===null)
{
return ReturnData::create(ReturnData::PARAMS_ERROR);
}
if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$id = $request->input('id');
$where['id'] = $id;
$res = UserPoint::add($data);
$res = $this->getLogic()->getOne($where);
if(!$res)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL);
return ReturnData::create(ReturnData::RECORD_NOT_EXIST);
}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//添加
public function userPointAdd(Request $request)
{
if(Helper::isPostRequest())
{
$_POST['user_id'] = Token::$uid;
return $this->getLogic()->add($_POST);
}
}
//修改
public function userPointUpdate(Request $request)
{
if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$id = $request->input('id');
if(Helper::isPostRequest())
{
unset($_POST['id']);
$where['id'] = $id;
$where['user_id'] = Token::$uid;
return $this->getLogic()->edit($_POST,$where);
}
}
//删除
public function userPointDelete(Request $request)
{
if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$id = $request->input('id');
if(Helper::isPostRequest())
{
$where['id'] = $id;
$where['user_id'] = Token::$uid;
return $this->getLogic()->del($where);
}
}
}

115
app/Http/Controllers/Api/UserRechargeController.php

@ -1,11 +1,13 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Api\CommonController;
use Log;
use DB;
use Illuminate\Http\Request;
use App\Common\ReturnData;
use App\Common\Helper;
use App\Common\Token;
use App\Http\Model\UserRecharge;
use App\Http\Logic\UserRechargeLogic;
class UserRechargeController extends CommonController
{
@ -14,90 +16,79 @@ class UserRechargeController extends CommonController
parent::__construct();
}
//用户充值列表
public function getLogic()
{
return logic('UserRecharge');
}
public function userRechargeList(Request $request)
{
//参数
$data['limit'] = $request->input('limit', 10);
$data['offset'] = $request->input('offset', 0);
$data['status'] = $request->input('status', -1);
$data['user_id'] = Token::$uid;
$res = UserRecharge::getList($data);
if($res === false)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL);
}
$limit = $request->input('limit', 10);
$offset = $request->input('offset', 0);
if($request->input('status', null) != null && $request->input('status')!=-1){$where['status'] = $request->input('status');}
$where['user_id'] = Token::$uid;
$res = $this->getLogic()->getList($where, array('id', 'desc'), '*', $offset, $limit);
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//获取一条用户充值
public function userRechargeDetail(Request $request)
{
//参数
$data['id'] = $request->input('id', '');
if($data['id']=='')
{
return ReturnData::create(ReturnData::PARAMS_ERROR);
}
$data['user_id'] = Token::$uid;
if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$id = $request->input('id');
$where['id'] = $id;
$res = UserRecharge::getOne($data);
if($res === false)
$res = $this->getLogic()->getOne($where);
if(!$res)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL);
return ReturnData::create(ReturnData::RECORD_NOT_EXIST);
}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//添加充值记录
//添加
public function userRechargeAdd(Request $request)
{
//参数
$data['money'] = $request->input('money','');
$data['status'] = UserRecharge::UN_PAY; //0未处理,1已完成
$data['pay_type'] = $request->input('pay_type',''); //充值类型:1微信,2支付宝
$data['user_id'] = Token::$uid;
$data['created_at'] = time();
if($data['money']=='' || $data['pay_type']=='')
{
return ReturnData::create(ReturnData::PARAMS_ERROR);
{
if(Helper::isPostRequest())
{
$_POST['user_id'] = Token::$uid;
return $this->getLogic()->add($_POST);
}
$res = UserRecharge::add($data);
if($res === false)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL);
}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//修改充值记录
//修改
public function userRechargeUpdate(Request $request)
{
//参数
$id = $request->input('id','');
$data['trade_no'] = $request->input('trade_no','');
$data['pay_time'] = $request->input('pay_time','');
$data['status'] = UserRecharge::COMPLETE_PAY;
$data['updated_at'] = time();
{
if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$id = $request->input('id');
if($id=='' || $data['trade_no']=='' || $data['pay_time']=='')
{
return ReturnData::create(ReturnData::PARAMS_ERROR);
if(Helper::isPostRequest())
{
unset($_POST['id']);
$where['id'] = $id;
$where['user_id'] = Token::$uid;
return $this->getLogic()->edit($_POST,$where);
}
}
//删除
public function userRechargeDelete(Request $request)
{
if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$id = $request->input('id');
$res = UserRecharge::modify(array('id'=>$id,'user_id'=>Token::$uid),$data);
if($res === false)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL);
}
return ReturnData::create(ReturnData::SUCCESS);
if(Helper::isPostRequest())
{
$where['id'] = $id;
$where['user_id'] = Token::$uid;
return $this->getLogic()->del($where);
}
}
}

118
app/Http/Controllers/Api/UserWithdrawController.php

@ -1,11 +1,13 @@
<?php
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Api\CommonController;
use Log;
use DB;
use Illuminate\Http\Request;
use App\Common\ReturnData;
use App\Common\Helper;
use App\Common\Token;
use App\Http\Model\UserWithdraw;
use App\Http\Logic\UserWithdrawLogic;
class UserWithdrawController extends CommonController
{
@ -14,7 +16,100 @@ class UserWithdrawController extends CommonController
parent::__construct();
}
//用户提现列表
public function getLogic()
{
return logic('UserWithdraw');
}
public function userWithdrawList(Request $request)
{
//参数
$limit = $request->input('limit', 10);
$offset = $request->input('offset', 0);
if($request->input('status', null) != null){$where['status'] = $request->input('status');}
if($request->input('method', null) != null){$where['method'] = $request->input('method');}
$where['delete_time'] = UserWithdraw::UN_DELETE;
$where['user_id'] = Token::$uid;
$res = $this->getLogic()->getList($where, array('id', 'desc'), '*', $offset, $limit);
return ReturnData::create(ReturnData::SUCCESS,$res);
}
public function userWithdrawDetail(Request $request)
{
//参数
if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$id = $request->input('id');
$where['id'] = $id;
$where['delete_time'] = UserWithdraw::UN_DELETE;
$res = $this->getLogic()->getOne($where);
if(!$res)
{
return ReturnData::create(ReturnData::RECORD_NOT_EXIST);
}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//添加
public function userWithdrawAdd(Request $request)
{
if(Helper::isPostRequest())
{
$_POST['user_id'] = Token::$uid;
return $this->getLogic()->add($_POST);
}
}
//修改
public function userWithdrawUpdate(Request $request)
{
if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$id = $request->input('id');
if(Helper::isPostRequest())
{
unset($_POST['id']);
$where['id'] = $id;
$where['user_id'] = Token::$uid;
$where['delete_time'] = UserWithdraw::UN_DELETE;
return $this->getLogic()->edit($_POST,$where);
}
}
//删除
public function userWithdrawDelete(Request $request)
{
if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$id = $request->input('id');
if(Helper::isPostRequest())
{
$where['id'] = $id;
$where['user_id'] = Token::$uid;
return $this->getLogic()->del($where);
}
}
/* //用户提现列表
public function userWithdrawList(Request $request)
{
//参数
@ -91,20 +186,5 @@ class UserWithdrawController extends CommonController
}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//删除一条提现
public function userWithdrawDelete(Request $request)
{
//参数
$id = $request->input('id',null);
$res = UserWithdraw::remove($id,Token::$uid);
if($res === false)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL);
}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
} */
}

2
app/Http/Controllers/Weixin/UserController.php

@ -572,7 +572,7 @@ class UserController extends CommonController
'nickname' => $_SESSION['weixin_oauth']['userinfo']['nickname'],
'sex' => $_SESSION['weixin_oauth']['userinfo']['sex'],
'head_img' => $_SESSION['weixin_oauth']['userinfo']['headimgurl'],
'parent_id' => isset($_SESSION['weixin_user_invite_code']) ? $_SESSION['weixin_user_invite_code'] : '',
'parent_id' => isset($_SESSION['weixin_user_invite_code']) ? $_SESSION['weixin_user_invite_code'] : 0,
'parent_mobile' => '',
'mobile' => ''
);

12
app/Http/Logic/ArctypeLogic.php

@ -84,9 +84,9 @@ class ArctypeLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -98,9 +98,9 @@ class ArctypeLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -112,9 +112,9 @@ class ArctypeLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**

12
app/Http/Logic/ArticleLogic.php

@ -92,9 +92,9 @@ class ArticleLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -106,9 +106,9 @@ class ArticleLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -120,9 +120,9 @@ class ArticleLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**

13
app/Http/Logic/BonusLogic.php

@ -1,5 +1,6 @@
<?php
namespace App\Http\Logic;
use App\Common\Token;
use App\Common\ReturnData;
use App\Http\Model\Bonus;
use App\Http\Requests\BonusRequest;
@ -93,9 +94,9 @@ class BonusLogic extends BaseLogic
//正则验证时间格式,未作
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -107,9 +108,9 @@ class BonusLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -121,9 +122,9 @@ class BonusLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit(['delete_time'=>time()],$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**

10
app/Http/Logic/CartLogic.php

@ -161,7 +161,7 @@ class CartLogic extends BaseLogic
if(isset($cart_id) && $cart_id){return ReturnData::create(ReturnData::SUCCESS,$cart_id,'购物车添加成功');}
return ReturnData::create(ReturnData::PARAMS_ERROR,null,'系统错误');
return ReturnData::create(ReturnData::SYSTEM_FAIL);
}
//修改
@ -173,9 +173,9 @@ class CartLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -184,9 +184,9 @@ class CartLogic extends BaseLogic
if(empty($where)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**

12
app/Http/Logic/CollectGoodsLogic.php

@ -91,9 +91,9 @@ class CollectGoodsLogic extends BaseLogic
if($this->getModel()->getOne(array('user_id'=>$data['user_id'],'goods_id'=>$data['goods_id']))){return '亲,您已经收藏啦!';}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -105,9 +105,9 @@ class CollectGoodsLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -121,9 +121,9 @@ class CollectGoodsLogic extends BaseLogic
if(!$this->getModel()->getOne(array('user_id'=>$where['user_id'],'goods_id'=>$where['goods_id']))){return '商品未收藏';}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**

12
app/Http/Logic/CommentLogic.php

@ -84,9 +84,9 @@ class CommentLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -98,9 +98,9 @@ class CommentLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -112,9 +112,9 @@ class CommentLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**

12
app/Http/Logic/FeedbackLogic.php

@ -84,9 +84,9 @@ class FeedBackLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -98,9 +98,9 @@ class FeedBackLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -112,9 +112,9 @@ class FeedBackLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**

12
app/Http/Logic/FriendlinkLogic.php

@ -84,9 +84,9 @@ class FriendlinkLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -98,9 +98,9 @@ class FriendlinkLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -112,9 +112,9 @@ class FriendlinkLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**

12
app/Http/Logic/GoodsBrandLogic.php

@ -84,9 +84,9 @@ class GoodsBrandLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -98,9 +98,9 @@ class GoodsBrandLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -112,9 +112,9 @@ class GoodsBrandLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**

12
app/Http/Logic/GoodsImgLogic.php

@ -84,9 +84,9 @@ class GoodsImgLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -98,9 +98,9 @@ class GoodsImgLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -112,9 +112,9 @@ class GoodsImgLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**

12
app/Http/Logic/GoodsLogic.php

@ -101,9 +101,9 @@ class GoodsLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -115,9 +115,9 @@ class GoodsLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -129,9 +129,9 @@ class GoodsLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**

12
app/Http/Logic/GoodsSearchwordLogic.php

@ -84,9 +84,9 @@ class GoodsSearchwordLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -98,9 +98,9 @@ class GoodsSearchwordLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -112,9 +112,9 @@ class GoodsSearchwordLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**

12
app/Http/Logic/GoodsTypeLogic.php

@ -84,9 +84,9 @@ class GoodsTypeLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -98,9 +98,9 @@ class GoodsTypeLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -112,9 +112,9 @@ class GoodsTypeLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**

12
app/Http/Logic/GuestbookLogic.php

@ -84,9 +84,9 @@ class GuestbookLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -98,9 +98,9 @@ class GuestbookLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -112,9 +112,9 @@ class GuestbookLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**

12
app/Http/Logic/KeywordLogic.php

@ -84,9 +84,9 @@ class KeywordLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -98,9 +98,9 @@ class KeywordLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -112,9 +112,9 @@ class KeywordLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**

12
app/Http/Logic/KuaidiLogic.php

@ -84,9 +84,9 @@ class KuaidiLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -98,9 +98,9 @@ class KuaidiLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -112,9 +112,9 @@ class KuaidiLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**

12
app/Http/Logic/MenuLogic.php

@ -84,9 +84,9 @@ class MenuLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -98,9 +98,9 @@ class MenuLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -112,9 +112,9 @@ class MenuLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**

12
app/Http/Logic/OrderGoodsLogic.php

@ -84,9 +84,9 @@ class OrderGoodsLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -98,9 +98,9 @@ class OrderGoodsLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -112,9 +112,9 @@ class OrderGoodsLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**

12
app/Http/Logic/OrderLogic.php

@ -84,9 +84,9 @@ class OrderLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -98,9 +98,9 @@ class OrderLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -112,9 +112,9 @@ class OrderLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**

12
app/Http/Logic/PageLogic.php

@ -84,9 +84,9 @@ class PageLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -98,9 +98,9 @@ class PageLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -112,9 +112,9 @@ class PageLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**

12
app/Http/Logic/PaymentLogic.php

@ -84,9 +84,9 @@ class PaymentLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -98,9 +98,9 @@ class PaymentLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -112,9 +112,9 @@ class PaymentLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**

12
app/Http/Logic/RegionLogic.php

@ -84,9 +84,9 @@ class RegionLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -98,9 +98,9 @@ class RegionLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -112,9 +112,9 @@ class RegionLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**

12
app/Http/Logic/SearchwordLogic.php

@ -84,9 +84,9 @@ class SearchwordLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -98,9 +98,9 @@ class SearchwordLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -112,9 +112,9 @@ class SearchwordLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**

12
app/Http/Logic/SlideLogic.php

@ -84,9 +84,9 @@ class SlideLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -98,9 +98,9 @@ class SlideLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -112,9 +112,9 @@ class SlideLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**

12
app/Http/Logic/SmsLogLogic.php

@ -84,9 +84,9 @@ class SmsLogLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -98,9 +98,9 @@ class SmsLogLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -112,9 +112,9 @@ class SmsLogLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**

12
app/Http/Logic/SysconfigLogic.php

@ -84,9 +84,9 @@ class SysconfigLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -98,9 +98,9 @@ class SysconfigLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -112,9 +112,9 @@ class SysconfigLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**

12
app/Http/Logic/TagindexLogic.php

@ -84,9 +84,9 @@ class TagindexLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -98,9 +98,9 @@ class TagindexLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -112,9 +112,9 @@ class TagindexLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**

12
app/Http/Logic/TaglistLogic.php

@ -84,9 +84,9 @@ class TaglistLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -98,9 +98,9 @@ class TaglistLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -112,9 +112,9 @@ class TaglistLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**

12
app/Http/Logic/TokenLogic.php

@ -84,9 +84,9 @@ class TokenLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -98,9 +98,9 @@ class TokenLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -112,9 +112,9 @@ class TokenLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**

12
app/Http/Logic/UserAddressLogic.php

@ -84,9 +84,9 @@ class UserAddressLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -98,9 +98,9 @@ class UserAddressLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -112,9 +112,9 @@ class UserAddressLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**

12
app/Http/Logic/UserBonusLogic.php

@ -84,9 +84,9 @@ class UserBonusLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -98,9 +98,9 @@ class UserBonusLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -112,9 +112,9 @@ class UserBonusLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**

23
app/Http/Logic/UserGoodsHistoryLogic.php

@ -34,6 +34,9 @@ class UserGoodsHistoryLogic extends BaseLogic
foreach($res['list'] as $k=>$v)
{
$res['list'][$k] = $this->getDataView($v);
$goods = logic('Goods')->getOne(array('id'=>$v->goods_id),array('id', 'typeid', 'tuijian', 'click', 'title', 'sn', 'price','litpic', 'pubdate', 'add_time', 'market_price', 'goods_number', 'sale', 'comments','promote_start_date','promote_price','promote_end_date','goods_img','spec','point'));
$res['list'][$k]->goods = $goods;
}
}
@ -83,10 +86,14 @@ class UserGoodsHistoryLogic extends BaseLogic
$validator = $this->getValidate($data, 'add');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
if($this->getModel()->getOne(['goods_id'=>$data['goods_id'],'user_id'=>$data['user_id']])){return ReturnData::create(ReturnData::PARAMS_ERROR,null,'亲,已经添加了');}
$data['add_time'] = time();
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -98,9 +105,9 @@ class UserGoodsHistoryLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -108,13 +115,13 @@ class UserGoodsHistoryLogic extends BaseLogic
{
if(empty($where)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$validator = $this->getValidate($where,'del');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
//$validator = $this->getValidate($where,'del');
//if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**

114
app/Http/Logic/UserLogic.php

@ -1,6 +1,7 @@
<?php
namespace App\Http\Logic;
use App\Common\ReturnData;
use App\Common\Token;
use App\Http\Model\User;
use App\Http\Requests\UserRequest;
use Validator;
@ -75,8 +76,8 @@ class UserLogic extends BaseLogic
$res = $this->getDataView($res);
$res->reciever_address = model('UserAddress')->getOne(['id'=>$res->address_id]);
$res->collect_goods_count = model('CollectGoods')->getDb()->where(['user_id'=>$where['id']])->count();
$res->bonus_count = model('UserBonus')->getDb()->where(array('user_id'=>$where['id'],'status'=>0))->count();
$res->collect_goods_count = model('CollectGoods')->getDb()->where(['user_id'=>$res->id])->count();
$res->bonus_count = model('UserBonus')->getDb()->where(array('user_id'=>$res->id,'status'=>0))->count();
return $res;
}
@ -90,9 +91,9 @@ class UserLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -104,9 +105,9 @@ class UserLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -118,9 +119,9 @@ class UserLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**
@ -133,11 +134,100 @@ class UserLogic extends BaseLogic
return getDataAttr($this->getModel(),$data);
}
//获取用户信息
public function getUserInfo($user_id)
//修改用户密码、支付密码
public function userPasswordUpdate($data, $where = array())
{
if(empty($data)){return ReturnData::create(ReturnData::SUCCESS);}
$user = $this->getModel()->getOne($where);
if(!$user){return ReturnData::create(ReturnData::PARAMS_ERROR, null, '用户不存在');}
//密码
if(isset($data['old_password']))
{
if($user->password && $data['old_password']!=$user->password)
{
return ReturnData::create(ReturnData::PARAMS_ERROR, null, '旧密码错误');
}
}
//支付密码
if(isset($data['pay_password']))
{
if($user->pay_password && $data['old_pay_password']!=$user->pay_password)
{
return ReturnData::create(ReturnData::PARAMS_ERROR, null, '旧支付密码错误');
}
}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//签到
public function signin($where)
{
$user = $this->getModel()->getOne($where);
if(!$user){return ReturnData::create(ReturnData::PARAMS_ERROR, null, '用户不存在');}
$signin_time='';
if(!empty($user->signin_time)){$signin_time = date('Ymd',strtotime($user->signin_time));} //签到时间
$today = date('Ymd',time()); //今日日期
if($signin_time==$today){return ReturnData::create(ReturnData::PARAMS_ERROR, null, '今日已签到');}
$signin_point = (int)sysconfig('CMS_SIGN_POINT'); //签到积分
$this->getModel()->edit(['point'=>($user->point+$signin_point),'signin_time'=>date('Y-m-d H:i:s')], ['id'=>$user->id]); //更新用户积分,及签到时间
model('UserPoint')->add(['type'=>1,'point'=>$signin_point,'des'=>'签到','user_id'=>$user->id]); //添加签到积分记录
return ReturnData::create(ReturnData::SUCCESS, null, '签到成功');
}
//用户登录
public function wxLogin($where)
{
$user = self::where('id', $user_id)->first();
if(!$user){return false;}
if(isset($where['openid']) && !empty($where['openid']))
{
$user = $this->getOne(array('openid'=>$where['openid']));
}
elseif(isset($where['user_name']) && !empty($where['user_name']))
{
$user = $this->getOne(function ($query) use ($where) {$query->where(['mobile'=>$where['user_name'],'password'=>$where['password']])->orWhere(['user_name'=>$where['user_name'],'password'=>$where['password']]);});
}
if(isset($user) && !$user){return ReturnData::create(ReturnData::PARAMS_ERROR, null, '用户不存在或者账号密码错误');}
$token = Token::getToken(Token::TYPE_WEIXIN, $user->id);
foreach($token as $k=>$v)
{
$user->$k = $v;
}
return ReturnData::create(ReturnData::SUCCESS, $user, '登录成功');
}
//注册
public function wxRegister($data)
{
if(empty($data)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$data['add_time'] = time();
$validator = $this->getValidate($data, 'wx_register');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
//生成token
$token = Token::getToken(Token::TYPE_WEIXIN, $res);
return ReturnData::create(ReturnData::SUCCESS,$token, '注册成功');
}
}

14
app/Http/Logic/UserMessageLogic.php

@ -83,10 +83,12 @@ class UserMessageLogic extends BaseLogic
$validator = $this->getValidate($data, 'add');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$data['add_time'] = time();
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -98,9 +100,9 @@ class UserMessageLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -112,9 +114,9 @@ class UserMessageLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**

51
app/Http/Logic/UserMoneyLogic.php

@ -1,5 +1,6 @@
<?php
namespace App\Http\Logic;
use DB;
use App\Common\ReturnData;
use App\Http\Model\UserMoney;
use App\Http\Requests\UserMoneyRequest;
@ -75,7 +76,14 @@ class UserMoneyLogic extends BaseLogic
return $res;
}
//添加
/**
* 添加一条记录,并增加或减少用户余额,会操作用户余额表,谨慎使用
* @param int $data['user_id'] 排序
* @param int $data['type'] 0增加,1减少
* @param float $data['money'] 金额
* @param string $data['des'] 描述
* @return array
*/
public function add($data = array(), $type=0)
{
if(empty($data)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
@ -83,10 +91,39 @@ class UserMoneyLogic extends BaseLogic
$validator = $this->getValidate($data, 'add');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
if($data['money']<=0){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$data['add_time'] = time();
DB::beginTransaction(); //启动事务
if($data['type'] == UserMoney::USER_MONEY_INCREMENT)
{
//增加用户余额
model('User')->getDb()->where(array('id'=>$data['user_id']))->increment('money', $data['money']);
}
elseif($data['type'] == UserMoney::USER_MONEY_DECREMENT)
{
//减少用户余额
model('User')->getDb()->where(array('id'=>$data['user_id']))->decrement('money', $data['money']);
}
else
{
DB::rollBack(); //事务回滚
return ReturnData::create(ReturnData::FAIL);
}
$user_money = model('User')->getDb()->where(array('id'=>$data['user_id']))->value('money'); //用户余额
$data['user_money'] = $user_money;
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res)
{
DB::commit(); //事务提交
return ReturnData::create(ReturnData::SUCCESS,$res);
}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -98,9 +135,9 @@ class UserMoneyLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -112,9 +149,9 @@ class UserMoneyLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**

51
app/Http/Logic/UserPointLogic.php

@ -1,5 +1,6 @@
<?php
namespace App\Http\Logic;
use DB;
use App\Common\ReturnData;
use App\Http\Model\UserPoint;
use App\Http\Requests\UserPointRequest;
@ -75,7 +76,14 @@ class UserPointLogic extends BaseLogic
return $res;
}
//添加
/**
* 添加一条记录,并增加或减少用户余额,会操作用户积分,谨慎使用
* @param int $data['user_id'] 排序
* @param int $data['type'] 0增加,1减少
* @param float $data['point'] 积分
* @param string $data['des'] 描述
* @return array
*/
public function add($data = array(), $type=0)
{
if(empty($data)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
@ -83,10 +91,39 @@ class UserPointLogic extends BaseLogic
$validator = $this->getValidate($data, 'add');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
if($data['point']<=0){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$data['add_time'] = time();
DB::beginTransaction(); //启动事务
if($data['type'] == UserPoint::USER_POINT_INCREMENT)
{
//增加用户余额
model('User')->getDb()->where(array('id'=>$data['user_id']))->increment('point', $data['point']);
}
elseif($data['type'] == UserPoint::USER_POINT_DECREMENT)
{
//减少用户余额
model('User')->getDb()->where(array('id'=>$data['user_id']))->decrement('point', $data['point']);
}
else
{
DB::rollBack(); //事务回滚
return ReturnData::create(ReturnData::FAIL);
}
$user_point = model('User')->getDb()->where(array('id'=>$data['user_id']))->value('point'); //用户余额
$data['user_point'] = $user_point;
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res)
{
DB::commit(); //事务提交
return ReturnData::create(ReturnData::SUCCESS,$res);
}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -98,9 +135,9 @@ class UserPointLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -112,9 +149,9 @@ class UserPointLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**

54
app/Http/Logic/UserRechargeLogic.php

@ -2,6 +2,7 @@
namespace App\Http\Logic;
use App\Common\ReturnData;
use App\Http\Model\UserRecharge;
use App\Http\Model\UserMoney;
use App\Http\Requests\UserRechargeRequest;
use Validator;
@ -80,13 +81,16 @@ class UserRechargeLogic extends BaseLogic
{
if(empty($data)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$data['recharge_sn'] = date('YmdHis').rand(1000,9999);
$data['created_at'] = time();
$validator = $this->getValidate($data, 'add');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -98,9 +102,9 @@ class UserRechargeLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -112,9 +116,9 @@ class UserRechargeLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**
@ -126,4 +130,42 @@ class UserRechargeLogic extends BaseLogic
{
return getDataAttr($this->getModel(),$data);
}
/**
* 充值成功之后修改记录信息,回调信息
* @param int $data['pay_time'] 实际充值时间
* @param int $data['pay_type'] 充值类型:1微信,2支付宝
* @param float $data['pay_money'] 充值金额
* @param string $data['trade_no'] 支付流水号
* @return array
*/
public function paySuccessChangeRechargeInfo($data, $where)
{
if(empty($where) || empty($data)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$user_recharge = $this->getModel()->getOne($where);
if(!$user_recharge){return false;}
DB::beginTransaction();
$data['updated_at'] = time();
$data['status'] = UserRecharge::COMPLETE_PAY;
$res = $this->getModel()->edit($data,$where);
if($res)
{
//添加用户余额记录并增加用户余额
$user_money_data['user_id'] = $user_recharge->user_id;
$user_money_data['type'] = UserMoney::USER_MONEY_INCREMENT;
$user_money_data['money'] = $data['pay_money'];
$user_money_data['des'] = UserRecharge::USER_RECHARGE_DES;
$user_money = logic('UserMoney')->add($user_money_data);
if($user_money['code'] != ReturnData::SUCCESS){DB::rollBack();return false;}
DB::commit();
return true;
}
DB::rollBack();
return false;
}
}

12
app/Http/Logic/UserRoleLogic.php

@ -84,9 +84,9 @@ class UserRoleLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -98,9 +98,9 @@ class UserRoleLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -112,9 +112,9 @@ class UserRoleLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**

80
app/Http/Logic/UserWithdrawLogic.php

@ -1,6 +1,8 @@
<?php
namespace App\Http\Logic;
use DB;
use App\Common\ReturnData;
use App\Http\Model\UserMoney;
use App\Http\Model\UserWithdraw;
use App\Http\Requests\UserWithdrawRequest;
use Validator;
@ -83,10 +85,37 @@ class UserWithdrawLogic extends BaseLogic
$validator = $this->getValidate($data, 'add');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
if(isset($data['pay_password']) && !empty($data['pay_password'])){}else{return ReturnData::create(ReturnData::PARAMS_ERROR,null,'请输入支付密码');}
$user = model('User')->getOne(array('id'=>$data['user_id'],'pay_password'=>$data['pay_password']));
if(!$user){return ReturnData::create(ReturnData::PARAMS_ERROR,null,'支付密码错误');}
unset($data['pay_password']);
$min_withdraw_money = sysconfig('CMS_MIN_WITHDRAWAL_MONEY'); //最低可提现金额
if($user->money<$data['money']){return ReturnData::create(ReturnData::PARAMS_ERROR,null,'余额不足');}
if($user->money<$min_withdraw_money){return ReturnData::create(ReturnData::PARAMS_ERROR,null,'用户金额小于最小提现金额');}
if($data['money']<$min_withdraw_money){return ReturnData::create(ReturnData::PARAMS_ERROR,null,'提现金额不得小于最小提现金额');}
DB::beginTransaction();
$data['add_time'] = time();
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res)
{
//添加用户余额记录并扣除用户余额
$user_money_data['user_id'] = $data['user_id'];
$user_money_data['type'] = UserMoney::USER_MONEY_DECREMENT;
$user_money_data['money'] = $data['money'];
$user_money_data['des'] = UserWithdraw::USER_WITHDRAW_DES;
$user_money = logic('UserMoney')->add($user_money_data);
if($user_money['code'] != ReturnData::SUCCESS){DB::rollBack();return false;}
DB::commit();
return ReturnData::create(ReturnData::SUCCESS,$res);
}
return ReturnData::create(ReturnData::SUCCESS,$res);
DB::rollBack();
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -98,9 +127,9 @@ class UserWithdrawLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -111,10 +140,10 @@ class UserWithdrawLogic extends BaseLogic
$validator = $this->getValidate($where,'del');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
$res = $this->getModel()->edit(['delete_time'=>time()],$where);
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**
@ -126,4 +155,41 @@ class UserWithdrawLogic extends BaseLogic
{
return getDataAttr($this->getModel(),$data);
}
/**
* 取消/拒绝提现
* @param int $where['id'] 提现id
* @param int $data['status'] status=3取消或status=4拒绝
* @param string $data['re_note'] 理由,选填
* @return array
*/
public function userWithdrawSuccessConfirm($data, $where)
{
if(empty($where) || empty($data)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
if($data['status']!=3 || $data['status']!=4){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$user_withdraw = $this->getModel()->getOne($where);
if(!$user_withdraw){return false;}
DB::beginTransaction();
$data['updated_at'] = time();
$res = $this->getModel()->edit($data,$where);
if($res)
{
//添加用户余额记录并增加用户余额
$user_money_data['user_id'] = $user_withdraw->user_id;
$user_money_data['type'] = UserMoney::USER_MONEY_INCREMENT;
$user_money_data['money'] = $user_withdraw->money;
$user_money_data['des'] = '提现退回';
$user_money = logic('UserMoney')->add($user_money_data);
if($user_money['code'] != ReturnData::SUCCESS){DB::rollBack();return false;}
DB::commit();
return true;
}
DB::rollBack();
return false;
}
}

12
app/Http/Logic/VerifyCodeLogic.php

@ -84,9 +84,9 @@ class VerifyCodeLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -98,9 +98,9 @@ class VerifyCodeLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -112,9 +112,9 @@ class VerifyCodeLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**

12
app/Http/Logic/WeixinMenuLogic.php

@ -84,9 +84,9 @@ class WeixinMenuLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//修改
@ -98,9 +98,9 @@ class WeixinMenuLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->edit($data,$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
//删除
@ -112,9 +112,9 @@ class WeixinMenuLogic extends BaseLogic
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
if($res){return ReturnData::create(ReturnData::SUCCESS,$res);}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::FAIL);
}
/**

194
app/Http/Model/User.php

@ -12,6 +12,8 @@ class User extends BaseModel
protected $hidden = array('password','pay_password');
protected $guarded = []; //$guarded包含你不想被赋值的字段数组。
const USER_NORMAL_STATUS = 1; //用户状态 0待审 1正常状态 2 删除至回收站 3锁定
public function getDb()
{
return DB::table($this->table);
@ -176,198 +178,6 @@ class User extends BaseModel
{
return $this->belongsTo(UserRole::class, 'role_id', 'id');
}
/*
//签到
public function signin()
{
$user = self::where(['id'=>Token::$uid])->first();
$signin_time='';
if(!empty($user->signin_time)){$signin_time = date('Ymd',strtotime($user->signin_time));} //签到时间
$today = date('Ymd',time()); //今日日期
if($signin_time==$today){return '今日已签到!';}
$signin_point = (int)Sysconfig::where(['varname'=>'CMS_SIGN_POINT'])->value('value'); //签到积分
User::where(['id'=>Token::$uid])->update(['point'=>($user->point+$signin_point),'signin_time'=>date('Y-m-d H:i:s')]); //更新用户积分,及签到时间
UserPoint::insert(['type'=>1,'point'=>$signin_point,'des'=>'签到','user_id'=>Token::$uid]); //添加签到积分记录
return true;
}
//获取列表
public static function getList(array $param)
{
extract($param); //参数:limit,offset
$limit = isset($limit) ? $limit : 10;
$offset = isset($offset) ? $offset : 0;
$model = new User;
if(isset($group_id)){$where['group_id'] = $group_id;}
if(isset($parent_id)){$where['parent_id'] = $parent_id;}
if(isset($where)){$model = $model->where($where);}
$res['count'] = $model->count();
$res['list'] = array();
if($res['count']>0)
{
$res['list'] = $model->select('id','user_name','email','sex','money','commission','point','mobile','nickname','head_img','add_time')->skip($offset)->take($limit)->orderBy('id','desc')->get();
foreach($res['list'] as $k=>$v)
{
$res['list'][$k]['user_name'] = !empty($res['list'][$k]['mobile']) ? $res['list'][$k]['mobile'] : $res['list'][$k]['user_name'];
}
}
else
{
return false;
}
return $res;
}
//获取一条用户信息
public static function getOne($id)
{
$user = self::where('id', $id)->first();
if(!$user){return false;}
$user['reciever_address'] = UserAddress::getOne($user->address_id);
return $user;
}
public static function add(array $data)
{
if ($id = self::insertGetId($data))
{
return $id;
}
return false;
}
public static function modify($where, array $data)
{
if (self::where($where)->update($data))
{
return true;
}
return false;
}
//删除一条记录
public static function remove($id)
{
if (!self::whereIn('id', explode(',', $id))->delete())
{
return false;
}
return true;
}
*/
//获取用户信息
public static function getUserInfo($user_id)
{
$user = self::where('id', $user_id)->first();
if(!$user){return false;}
$user->reciever_address = UserAddress::getOne($user->address_id);
$user->collect_goods_count = CollectGoods::where('user_id', $user_id)->count();
$user->bonus_count = UserBonus::where(array('user_id'=>$user_id,'status'=>0))->count();
$userinfo = $user->makeVisible(array('pay_password'))->toArray();
$user->pay_password = 0;
if($userinfo['pay_password']){$user->pay_password = 1;}
return $user;
}
//修改用户密码、支付密码
public static function userPasswordUpdate($where,array $param)
{
extract($param);
$data = '';
$user = self::where($where)->first();
if(!$user){return false;}
$user = $user->makeVisible(array('password','pay_password'))->toArray();
if(isset($old_password) && $old_password!=$user['password']){return false;} //旧密码错误
if(isset($password) && $password==''){return false;} //新密码为空
if(isset($old_pay_password) && $old_pay_password!=$user['pay_password']){return false;}
if(isset($pay_password) && $pay_password==''){return false;}
if(isset($password)){$data['password'] = $password;}
if(isset($pay_password)){$data['pay_password'] = $pay_password;}
if ($data != '' && self::where($where)->update($data))
{
return true;
}
return false;
}
//注册
public static function wxRegister(array $param)
{
extract($param); //参数
if(isset($user_name)){$data['user_name'] = $user_name;}
if(isset($mobile)){$data['mobile'] = $mobile;}
if(isset($password)){$data['password'] = $password;} //md5加密
if(isset($parent_id) && !empty($parent_id)){$data['parent_id'] = $parent_id;}
if(isset($openid)){$data['openid'] = $openid;}
if(isset($unionid)){$data['unionid'] = $unionid;}
if(isset($sex)){$data['sex'] = $sex;}
if(isset($head_img)){$data['head_img'] = $head_img;}
if(isset($nickname)){$data['nickname'] = $nickname;}
$data['add_time'] = time();
if (isset($data) && $id = self::add($data))
{
//生成token
return Token::getToken(Token::TYPE_WEIXIN, $id);
}
return false;
}
//用户登录
public static function wxLogin(array $param)
{
extract($param); //参数
if(isset($openid) && !empty($openid))
{
$user = self::where(array('openid'=>$openid))->first();
}
else
{
$user = self::where(array('mobile'=>$user_name,'password'=>$password))->orWhere(array('user_name'=>$user_name,'password'=>$password))->first();
}
if(!isset($user)){return false;}
$res = self::getUserInfo($user->id);
$token = Token::getToken(Token::TYPE_WEIXIN, $user->id);
foreach($token as $k=>$v)
{
$res->$k = $v;
}
return $res;
}
//性别1男2女
public function getSexAttr($data)

96
app/Http/Model/UserGoodsHistory.php

@ -168,100 +168,4 @@ class UserGoodsHistory extends BaseModel
return $res;
}
/*
//获取列表
public static function getList(array $param)
{
extract($param); //参数:limit,offset
$limit = isset($limit) ? $limit : 10;
$offset = isset($offset) ? $offset : 0;
$model = new UserGoodsHistory;
if(isset($user_id)){$where['user_id'] = $user_id;}
if(isset($goods_id)){$where['goods_id'] = $goods_id;}
if(isset($where)){$model = $model->where($where);}
$res['count'] = $model->count();
$res['list'] = array();
if($res['count']>0)
{
$res['list'] = $model->skip($offset)->take($limit)->orderBy('id','desc')->get();
if($res['list'])
{
foreach($res['list'] as $k=>$v)
{
$goods = Goods::getOne(array('id'=>$v['goods_id'],'field'=>array('id', 'typeid', 'tuijian', 'click', 'title', 'sn', 'price','litpic', 'pubdate', 'add_time', 'market_price', 'goods_number', 'sale', 'comments','promote_start_date','promote_price','promote_end_date','goods_img','spec','point')));
$res['list'][$k]['goods'] = $goods;
}
}
}
else
{
return false;
}
return $res;
}
public static function getOne(array $param)
{
extract($param); //参数
$where['id'] = $id;
return self::where($where)->first();
}
public static function add(array $data)
{
if(self::where($data)->first()){return false;}
if (!self::where($data)->first())
{
$data['add_time'] = time();
return self::insertGetId($data);
}
return false;
}
public static function modify($where, array $data)
{
if (self::where($where)->update($data) !== false)
{
return true;
}
return false;
}
//删除一条记录
public static function remove($id,$user_id)
{
if (self::whereIn('id', explode(',', $id))->where('user_id',$user_id)->delete() === false)
{
return false;
}
return true;
}
//清空我的足迹
public static function clear($user_id)
{
if (self::where('user_id',$user_id)->delete() === false)
{
return false;
}
return true;
}
*/
}

67
app/Http/Model/UserMessage.php

@ -168,71 +168,4 @@ class UserMessage extends BaseModel
return $res;
}
/*
//获取列表
public static function getList(array $param)
{
extract($param); //参数:limit,offset
$limit = isset($limit) ? $limit : 10;
$offset = isset($offset) ? $offset : 0;
$model = new self;
if(isset($type)){$where['type'] = $type;}
if(isset($status)){$where['status'] = $status;}
$model = $model->whereIn('user_id',array(0,$user_id));
if(isset($where)){$model = $model->where($where);}
$res['count'] = $model->count();
$res['list'] = array();
if($res['count']>0)
{
$res['list'] = $model->skip($offset)->take($limit)->orderBy('id','desc')->get();
}
else
{
return false;
}
return $res;
}
public static function getOne($where)
{
return self::where($where)->first();
}
public static function add(array $data)
{
if ($id = self::insertGetId($data))
{
return $id;
}
return false;
}
public static function modify($where, array $data)
{
if (self::where($where)->update($data))
{
return true;
}
return false;
}
//删除一条记录
public static function remove($id)
{
if (!self::whereIn('id', explode(',', $id))->delete())
{
return false;
}
return true;
} */
}

76
app/Http/Model/UserMoney.php

@ -12,6 +12,9 @@ class UserMoney extends BaseModel
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
const USER_MONEY_INCREMENT = 0; //用户余额0增加,1减少
const USER_MONEY_DECREMENT = 1;
public function getDb()
{
return DB::table($this->table);
@ -168,77 +171,4 @@ class UserMoney extends BaseModel
return $res;
}
/*
//获取列表
public static function getList(array $param)
{
extract($param); //参数:limit,offset
$where['user_id'] = $user_id;
$limit = isset($limit) ? $limit : 10;
$offset = isset($offset) ? $offset : 0;
$model = new UserMoney;
if(isset($type)){$where['type'] = $type;}
$model = $model->where($where);
$res['count'] = $model->count();
$res['list'] = array();
if($res['count']>0)
{
$res['list'] = $model->skip($offset)->take($limit)->orderBy('id','desc')->get();
}
else
{
return false;
}
return $res;
}
public static function getOne($id)
{
return self::where('id', $id)->first();
}
public static function add(array $data)
{
if ($id = self::insertGetId($data))
{
return $id;
}
return false;
}
public static function modify($where, array $data)
{
if (self::where($where)->update($data))
{
return true;
}
return false;
}
//删除一条记录
public static function remove($id)
{
if (!self::whereIn('id', explode(',', $id))->delete())
{
return false;
}
return true;
}
*/
//描述-文字
public function getDesAttr($data)
{
$arr = [0 => '不限', 1 => '黑色', 2 => '白色', 3 => '银色', 4 => '橙色', 5 => '绿色', 6 => '红色', 7 => '蓝色', 8 => '紫色', 9 => '黄色', 10 => '香槟色', 11 => '咖啡色'];
return $arr[$data['des']];
}
}

69
app/Http/Model/UserPoint.php

@ -12,6 +12,9 @@ class UserPoint extends BaseModel
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
const USER_POINT_INCREMENT = 0; //用户积分0增加,1减少
const USER_POINT_DECREMENT = 1;
public function getDb()
{
return DB::table($this->table);
@ -168,70 +171,4 @@ class UserPoint extends BaseModel
return $res;
}
/*
//获取列表
public static function getList(array $param)
{
extract($param); //参数:limit,offset
$where['user_id'] = $user_id;
$limit = isset($limit) ? $limit : 10;
$offset = isset($offset) ? $offset : 0;
$model = new UserPoint;
if(isset($type)){$where['type'] = $type;}
$model = $model->where($where);
$res['count'] = $model->count();
$res['list'] = array();
if($res['count']>0)
{
$res['list'] = $model->skip($offset)->take($limit)->orderBy('id','desc')->get();
}
else
{
return false;
}
return $res;
}
public static function getOne($id)
{
return self::where('id', $id)->first();
}
public static function add(array $data)
{
if ($id = self::insertGetId($data))
{
return $id;
}
return false;
}
public static function modify($where, array $data)
{
if (self::where($where)->update($data))
{
return true;
}
return false;
}
//删除一条记录
public static function remove($id)
{
if (!self::whereIn('id', explode(',', $id))->delete())
{
return false;
}
return true;
} */
}

71
app/Http/Model/UserRecharge.php

@ -5,15 +5,16 @@ use Log;
class UserRecharge extends BaseModel
{
//用户余额明细
//用户充值
protected $table = 'user_recharge';
public $timestamps = false;
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
const UN_PAY = 0;
const COMPLETE_PAY = 1;
const UN_PAY = 0; //未支付状态
const COMPLETE_PAY = 1; //充值成功
const USER_RECHARGE_DES = '充值';
public function getDb()
{
@ -171,68 +172,4 @@ class UserRecharge extends BaseModel
return $res;
}
/*
//获取列表
public static function getList(array $param)
{
extract($param); //参数:limit,offset
$where['user_id'] = $user_id;
$limit = isset($limit) ? $limit : 10;
$offset = isset($offset) ? $offset : 0;
$model = new self();
if(isset($status) && $status!=-1){$where['status'] = $status;} //-1表示获取所有
$model = $model->where($where);
$res['count'] = $model->count();
$res['list'] = array();
if($res['count']>0)
{
$res['list'] = $model->skip($offset)->take($limit)->orderBy('id','desc')->get();
}
return $res;
}
public static function getOne($where)
{
return self::where($where)->first();
}
public static function add(array $data)
{
$data['recharge_sn'] = date('YmdHis').rand(1000,9999);
if ($id = self::insertGetId($data))
{
return $id;
}
return false;
}
public static function modify($where, array $data)
{
if (self::where($where)->update($data) === false)
{
return false;
}
return true;
}
//删除一条记录
public static function remove($id)
{
if (!self::whereIn('id', explode(',', $id))->delete())
{
return false;
}
return true;
} */
}

102
app/Http/Model/UserWithdraw.php

@ -12,6 +12,9 @@ class UserWithdraw extends BaseModel
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
const UN_DELETE = 0; //未删除
const USER_WITHDRAW_DES = '提现';
public function getDb()
{
return DB::table($this->table);
@ -168,54 +171,16 @@ class UserWithdraw extends BaseModel
return $res;
}
/*
//获取列表
public static function getList(array $param)
{
extract($param); //参数:limit,offset
$limit = isset($limit) ? $limit : 10;
$offset = isset($offset) ? $offset : 0;
$where['user_id'] = $user_id;
$where['is_delete'] = 0;
$model = new self;
if(isset($status) && !empty($status)){if($status==-1){}else{$where['status'] = $status;}}
if(isset($method)){$where['method'] = $method;}
$model = $model->where($where);
$res['count'] = $model->count();
$res['list'] = array();
if($res['count']>0)
{
$res['list'] = $model->skip($offset)->take($limit)->orderBy('id','desc')->get();
foreach($res['list'] as $k=>$v)
{
$res['list'][$k]['status_text'] = self::getStatusText($v);
}
}
else
{
return false;
}
return $res;
}
public static function getOne(array $param)
//获取提现状态文字:0未处理,1处理中,2成功,3取消,4拒绝
public function getStatusAttr($data)
{
extract($param);
$where['id'] = $id;
$where['is_delete'] = 0;
return self::where($where)->first();
$arr = array(0 => '未处理', 1 => '处理中', 2 => '成功', 3 => '取消', 4 => '拒绝');
return $arr[$data->status];
}
/*
public static function add(array $data)
{
$user = User::where(array('id'=>$data['user_id'],'pay_password'=>$data['pay_password']))->first();
@ -240,52 +205,5 @@ class UserWithdraw extends BaseModel
return ReturnData::create(ReturnData::SYSTEM_FAIL);
}
public static function modify($where, array $data)
{
if (self::where($where)->update($data))
{
return true;
}
return false;
}
//删除一条记录
public static function remove($id,$user_id)
{
if (!self::whereIn('id', explode(',', $id))->where('user_id',$user_id)->update(array('is_delete'=>1)))
{
return false;
}
return true;
}
//获取提现状态文字:0未处理,1处理中,2成功,3取消,4拒绝
public static function getStatusText($where)
{
$res = '';
if($where['status'] == 0)
{
$res = '未处理';
}
elseif($where['status'] == 1)
{
$res = '处理中';
}
elseif($where['status'] == 2)
{
$res = '成功';
}
elseif($where['status'] == 3)
{
$res = '取消';
}
elseif($where['status'] == 4)
{
$res = '拒绝';
}
return $res;
} */
*/
}

92
app/Http/Requests/UserGoodsHistoryRequest.php

@ -0,0 +1,92 @@
<?php
namespace App\Http\Requests;
class UserGoodsHistoryRequest extends BaseRequest
{
//总的验证规则
protected $rules = [
'id' => 'required|integer',
'goods_id' => 'required|integer',
'user_id' => 'required|integer',
'add_time' => 'required|integer',
];
//总的自定义错误信息
protected $messages = [
'id.required' => 'ID必填',
'id.integer' => 'ID必须为数字',
'goods_id.required' => '商品ID必填',
'goods_id.integer' => '商品ID必须为数字',
'user_id.required' => '用户ID必填',
'user_id.integer' => '用户ID必须为数字',
'add_time.required' => '时间必填',
'add_time.integer' => '时间格式不正确',
];
//场景验证规则
protected $scene = [
'add' => ['goods_id', 'user_id'],
'edit' => ['goods_id'],
'del' => ['id'],
];
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true; //修改为true
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return $this->rules;
}
/**
* 获取被定义验证规则的错误消息.
*
* @return array
*/
public function messages()
{
return $this->messages;
}
//获取场景验证规则
public function getSceneRules($name, $fields = null)
{
$res = array();
if(!isset($this->scene[$name]))
{
return false;
}
$scene = $this->scene[$name];
if($fields != null && is_array($fields))
{
$scene = $fields;
}
foreach($scene as $k=>$v)
{
if(isset($this->rules[$v])){$res[$v] = $this->rules[$v];}
}
return $res;
}
//获取场景验证规则自定义错误信息
public function getSceneRulesMessages()
{
return $this->messages;
}
}

102
app/Http/Requests/UserMessageRequest.php

@ -0,0 +1,102 @@
<?php
namespace App\Http\Requests;
class UserMessageRequest extends BaseRequest
{
//总的验证规则
protected $rules = [
'id' => 'required|integer',
'user_id' => 'required|integer',
'type' => 'integer|between:0,9',
'status' => 'integer|between:0,9',
'title' => 'max:150',
'des' => 'required|max:250',
'litpic' => 'max:100',
'add_time' => 'required|integer',
];
//总的自定义错误信息
protected $messages = [
'id.required' => 'ID必填',
'id.integer' => 'ID必须为数字',
'user_id.required' => '用户ID必填',
'user_id.integer' => '用户ID必须为数字',
'type.integer' => '消息类型必须为数字',
'type.between' => '系统消息0,活动消息1',
'status.integer' => '查看状态必须为数字',
'status.between' => '查看状态:0未查看,1已查看',
'title.max' => '标题不能超过150个字符',
'des.required' => '描述必填',
'des.max' => '描述不能超过150个字符',
'litpic.max' => '缩略图不能超过100个字符',
'add_time.required' => '时间必填',
'add_time.integer' => '时间格式不正确',
];
//场景验证规则
protected $scene = [
'add' => ['user_id', 'type', 'title', 'des', 'litpic'],
'edit' => ['title', 'des'],
'del' => ['id'],
];
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true; //修改为true
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return $this->rules;
}
/**
* 获取被定义验证规则的错误消息.
*
* @return array
*/
public function messages()
{
return $this->messages;
}
//获取场景验证规则
public function getSceneRules($name, $fields = null)
{
$res = array();
if(!isset($this->scene[$name]))
{
return false;
}
$scene = $this->scene[$name];
if($fields != null && is_array($fields))
{
$scene = $fields;
}
foreach($scene as $k=>$v)
{
if(isset($this->rules[$v])){$res[$v] = $this->rules[$v];}
}
return $res;
}
//获取场景验证规则自定义错误信息
public function getSceneRulesMessages()
{
return $this->messages;
}
}

101
app/Http/Requests/UserMoneyRequest.php

@ -0,0 +1,101 @@
<?php
namespace App\Http\Requests;
class UserMoneyRequest extends BaseRequest
{
//总的验证规则
protected $rules = [
'id' => 'required|integer',
'user_id' => 'required|integer',
'type' => 'integer|between:0,9',
'money' => ['required','regex:/^\d{0,10}(\.\d{0,2})?$/'],
'add_time' => 'required|integer',
'des' => 'required|max:100',
'user_money' => ['required','regex:/^\d{0,10}(\.\d{0,2})?$/'],
];
//总的自定义错误信息
protected $messages = [
'id.required' => 'ID必填',
'id.integer' => 'ID必须为数字',
'user_id.required' => '用户ID必填',
'user_id.integer' => '用户ID必须为数字',
'type.integer' => '类型必须为数字',
'type.between' => '0增加,1减少',
'money.required' => '金额必填',
'money.regex' => '金额格式不正确,只能带2位小数的数字',
'add_time.required' => '时间必填',
'add_time.integer' => '时间格式不正确',
'des.required' => '描述必填',
'des.max' => '描述不能超过100个字符',
'user_money.required' => '余额必填',
'user_money.regex' => '余额格式不正确,只能带2位小数的数字',
];
//场景验证规则
protected $scene = [
'add' => ['user_id', 'type', 'money', 'des'],
'edit' => ['user_id', 'type', 'money', 'des'],
'del' => ['id'],
];
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true; //修改为true
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return $this->rules;
}
/**
* 获取被定义验证规则的错误消息.
*
* @return array
*/
public function messages()
{
return $this->messages;
}
//获取场景验证规则
public function getSceneRules($name, $fields = null)
{
$res = array();
if(!isset($this->scene[$name]))
{
return false;
}
$scene = $this->scene[$name];
if($fields != null && is_array($fields))
{
$scene = $fields;
}
foreach($scene as $k=>$v)
{
if(isset($this->rules[$v])){$res[$v] = $this->rules[$v];}
}
return $res;
}
//获取场景验证规则自定义错误信息
public function getSceneRulesMessages()
{
return $this->messages;
}
}

101
app/Http/Requests/UserPointRequest.php

@ -0,0 +1,101 @@
<?php
namespace App\Http\Requests;
class UserPointRequest extends BaseRequest
{
//总的验证规则
protected $rules = [
'id' => 'required|integer',
'user_id' => 'required|integer',
'type' => 'integer|between:0,9',
'point' => 'required|integer',
'add_time' => 'required|integer',
'des' => 'required|max:100',
'user_money' => 'required|integer',
];
//总的自定义错误信息
protected $messages = [
'id.required' => 'ID必填',
'id.integer' => 'ID必须为数字',
'user_id.required' => '用户ID必填',
'user_id.integer' => '用户ID必须为数字',
'type.integer' => '类型必须为数字',
'type.between' => '0增加,1减少',
'point.required' => '积分必填',
'point.integer' => '积分格式不正确,只能带2位小数的数字',
'add_time.required' => '时间必填',
'add_time.integer' => '时间格式不正确',
'des.required' => '描述必填',
'des.max' => '描述不能超过100个字符',
'user_point.required' => '剩余积分必填',
'user_point.integer' => '剩余积分格式不正确,只能带2位小数的数字',
];
//场景验证规则
protected $scene = [
'add' => ['user_id', 'type', 'point', 'des'],
'edit' => ['user_id', 'type', 'point', 'des'],
'del' => ['id'],
];
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true; //修改为true
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return $this->rules;
}
/**
* 获取被定义验证规则的错误消息.
*
* @return array
*/
public function messages()
{
return $this->messages;
}
//获取场景验证规则
public function getSceneRules($name, $fields = null)
{
$res = array();
if(!isset($this->scene[$name]))
{
return false;
}
$scene = $this->scene[$name];
if($fields != null && is_array($fields))
{
$scene = $fields;
}
foreach($scene as $k=>$v)
{
if(isset($this->rules[$v])){$res[$v] = $this->rules[$v];}
}
return $res;
}
//获取场景验证规则自定义错误信息
public function getSceneRulesMessages()
{
return $this->messages;
}
}

110
app/Http/Requests/UserRechargeRequest.php

@ -0,0 +1,110 @@
<?php
namespace App\Http\Requests;
class UserRechargeRequest extends BaseRequest
{
//总的验证规则
protected $rules = [
'id' => 'required|integer',
'user_id' => 'required|integer',
'money' => ['required','regex:/^\d{0,10}(\.\d{0,2})?$/'],
'pay_time' => 'required|integer',
'pay_type' => 'integer|between:0,3',
'pay_money' => ['regex:/^\d{0,10}(\.\d{0,2})?$/'],
'trade_no' => 'max:30',
'status' => 'integer|between:0,3',
'created_at' => 'required|integer',
'updated_at' => 'integer',
'recharge_sn' => 'required|max:60',
];
//总的自定义错误信息
protected $messages = [
'id.required' => 'ID必填',
'id.integer' => 'ID必须为数字',
'user_id.required' => '用户ID必填',
'user_id.integer' => '用户ID必须为数字',
'money.required' => '充值金额必填',
'money.regex' => '充值金额格式不正确,只能带2位小数的数字',
'pay_time.required' => '充值时间必填',
'pay_time.integer' => '充值时间格式不正确',
'pay_type.integer' => '充值类型必须为数字',
'pay_type.between' => '充值类型:1微信,2支付宝',
'pay_money.regex' => '实付金额格式不正确,只能带2位小数的数字',
'trade_no.max' => '支付流水号不能超过30个字符',
'status.integer' => '充值状态必须为数字',
'status.between' => '充值状态:0未处理,1已完成,2失败',
'created_at.required' => '添加时间必填',
'created_at.integer' => '添加时间格式不正确',
'updated_at.integer' => '更新时间格式不正确',
'recharge_sn.required' => '支付订单号必填',
'recharge_sn.max' => '支付订单号不能超过60个字符',
];
//场景验证规则
protected $scene = [
'add' => ['user_id', 'money', 'recharge_sn', 'des'],
'edit' => ['user_id', 'money', 'recharge_sn', 'des'],
'del' => ['id'],
];
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true; //修改为true
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return $this->rules;
}
/**
* 获取被定义验证规则的错误消息.
*
* @return array
*/
public function messages()
{
return $this->messages;
}
//获取场景验证规则
public function getSceneRules($name, $fields = null)
{
$res = array();
if(!isset($this->scene[$name]))
{
return false;
}
$scene = $this->scene[$name];
if($fields != null && is_array($fields))
{
$scene = $fields;
}
foreach($scene as $k=>$v)
{
if(isset($this->rules[$v])){$res[$v] = $this->rules[$v];}
}
return $res;
}
//获取场景验证规则自定义错误信息
public function getSceneRulesMessages()
{
return $this->messages;
}
}

1
app/Http/Requests/UserRequest.php

@ -80,6 +80,7 @@ class UserRequest extends BaseRequest
protected $scene = [
'add' => ['email', 'user_name', 'password', 'pay_password', 'head_img', 'sex', 'birthday', 'commission', 'money', 'frozen_money', 'point', 'rank_points', 'address_id', 'add_time', 'user_rank', 'parent_id', 'nickname', 'mobile', 'status', 'group_id', 'updated_at', 'signin_time', 'openid', 'unionid', 'push_id', 'refund_account', 'refund_name', 'consumption_money'],
'edit' => ['email', 'user_name', 'password', 'pay_password', 'head_img', 'sex', 'birthday', 'commission', 'money', 'frozen_money', 'point', 'rank_points', 'address_id', 'add_time', 'user_rank', 'parent_id', 'nickname', 'mobile', 'status', 'group_id', 'updated_at', 'signin_time', 'openid', 'unionid', 'push_id', 'refund_account', 'refund_name', 'consumption_money'],
'wx_register' => ['email', 'user_name', 'password', 'pay_password', 'head_img', 'add_time', 'parent_id', 'nickname', 'mobile', 'group_id', 'openid', 'unionid', 'push_id'],
'del' => ['id'],
];

113
app/Http/Requests/UserWithdrawRequest.php

@ -0,0 +1,113 @@
<?php
namespace App\Http\Requests;
class UserWithdrawRequest extends BaseRequest
{
//总的验证规则
protected $rules = [
'id' => 'required|integer',
'user_id' => 'required|integer',
'add_time' => 'required|integer',
'money' => ['required','regex:/^\d{0,10}(\.\d{0,2})?$/'],
'name' => 'max:30',
'status' => 'integer|between:0,5',
'note' => 'max:250',
're_note' => 'max:250',
'bank_name' => 'max:30',
'bank_place' => 'max:150',
'account' => 'required|max:30',
'method' => 'required|max:20',
'delete_time' => 'integer',
];
//总的自定义错误信息
protected $messages = [
'id.required' => 'ID必填',
'id.integer' => 'ID必须为数字',
'user_id.required' => '用户ID必填',
'user_id.integer' => '用户ID必须为数字',
'add_time.required' => '添加时间必填',
'add_time.integer' => '添加时间格式不正确',
'money.required' => '提现金额必填',
'money.regex' => '提现金额格式不正确,只能带2位小数的数字',
'name.max' => '姓名不能超过30个字符',
'status.integer' => '状态必须是数字',
'status.between' => '状态 0未处理,1处理中,2成功,3取消,4拒绝',
'note.max' => '用户备注不能超过250个字符',
're_note.max' => '回复信息不能超过250个字符',
'bank_name.max' => '银行名称不能超过30个字符',
'bank_place.max' => '开户行不能超过150个字符',
'account.required' => '提现账号必填',
'account.max' => '支付宝账号或者银行卡号不能超过30个字符',
'method.required' => '提现方式必填',
'method.max' => '提现方式不能超过20个字符',
'delete_time.integer' => '删除时间格式不正确',
];
//场景验证规则
protected $scene = [
'add' => ['user_id', 'money', 'name', 'note', 'bank_name', 'bank_place', 'account', 'method'],
'edit' => ['user_id', 'money', 'name', 'note', 'bank_name', 'bank_place', 'account', 'method'],
'del' => ['id'],
];
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true; //修改为true
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return $this->rules;
}
/**
* 获取被定义验证规则的错误消息.
*
* @return array
*/
public function messages()
{
return $this->messages;
}
//获取场景验证规则
public function getSceneRules($name, $fields = null)
{
$res = array();
if(!isset($this->scene[$name]))
{
return false;
}
$scene = $this->scene[$name];
if($fields != null && is_array($fields))
{
$scene = $fields;
}
foreach($scene as $k=>$v)
{
if(isset($this->rules[$v])){$res[$v] = $this->rules[$v];}
}
return $res;
}
//获取场景验证规则自定义错误信息
public function getSceneRulesMessages()
{
return $this->messages;
}
}

106
app/Http/Service/AliyunOSS.php

@ -0,0 +1,106 @@
<?php
// +----------------------------------------------------------------------
// | 阿里云OSS服务
// +----------------------------------------------------------------------
namespace App\Http\Service;
require_once base_path('resources/org/OSS').'/OssClient.php';
require_once base_path('resources/org/OSS/Core').'/OssException.php';
use OSS\OssClient;
use OSS\Core\OssException;
class AliyunOSS
{
const OSS_ACCESS_ID = 'LTAIqMYGJYT5U7ij';
const OSS_ACCESS_KEY = 'yuQvyKywTaZ2ncx6hkSfr836GtETfd';
const OSS_ENDPOINT = 'oss-cn-shenzhen.aliyuncs.com';
const OSS_TEST_BUCKET = 'cheyoubao';
/**
* 根据Config配置,得到一个OssClient实例
*
* @return OssClient 一个OssClient实例
*/
public static function getOssClient()
{
try {
$ossClient = new \OssClient(self::OSS_ACCESS_ID, self::OSS_ACCESS_KEY, self::OSS_ENDPOINT, false);
} catch (\OssException $e) {
return ['code'=>1, 'msg'=>$e->getMessage(), 'data'=>''];
}
return $ossClient;
}
public static function getBucketName()
{
return self::OSS_TEST_BUCKET;
}
/**
* 工具方法,创建一个存储空间,如果发生异常直接exit
*/
public static function createBucket()
{
$ossClient = self::getOssClient();
if (is_null($ossClient)) exit(1);
$bucket = self::getBucketName();
$acl = OssClient::OSS_ACL_TYPE_PUBLIC_READ;
try {
$res = $ossClient->createBucket($bucket, $acl);
} catch (\OssException $e) {
return ['code'=>1, 'msg'=>$e->getMessage(), 'data'=>''];
}
return ['code'=>0, 'msg'=>'操作成功', 'data'=>$res];
}
/**
* 上传指定的本地文件内容
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @return null
*/
public static function uploadFile($object, $filePath)
{
//$object = "oss-php-sdk-test/upload-test-object-name.txt";
//$filePath = __FILE__;
$options = array();
$ossClient = self::getOssClient();
$bucket = self::getBucketName();
try {
//self::createBucket(); //如果没创建存储空间,先用这行执行创建存储空间
$res = $ossClient->uploadFile($bucket, $object, $filePath, $options);
} catch (\OssException $e) {
return ['code'=>1, 'msg'=>$e->getMessage(), 'data'=>''];
}
return ['code'=>0, 'msg'=>'操作成功', 'data'=>$res];
}
/**
* 把本地变量的内容到文件
*
* 简单上传,上传指定变量的内存值作为object的内容
*
* @param OssClient $ossClient OssClient实例
* @param string $bucket 存储空间名称
* @return null
*/
public static function putObject($object, $filePath)
{
//$object = "oss-php-sdk-test/upload-test-object-name.txt";
$content = file_get_contents($filePath);
$options = array();
$ossClient = self::getOssClient();
$bucket = self::getBucketName();
try {
$res = $ossClient->putObject($bucket, $object, $content, $options);
} catch (\OssException $e) {
return ['code'=>1, 'msg'=>$e->getMessage(), 'data'=>''];
}
return ['code'=>0, 'msg'=>'操作成功', 'data'=>$res];
}
}

2
composer.json

@ -57,4 +57,4 @@
"sort-packages": true,
"optimize-autoloader": true
}
}
}

262
resources/org/OSS/Core/MimeTypes.php

@ -0,0 +1,262 @@
<?php
namespace OSS\Core;
/**
* Class MimeTypes
*
* 在上传文件的时候,根据文件的缺省名,得到其对应的Content-type
*
* @package OSS\Core
*/
class MimeTypes
{
/**
* 根据文件名,获取http协议header中的content-type应该填写的数据
*
* @param string $name 缺省名
* @return string content-type
*/
public static function getMimetype($name)
{
$parts = explode('.', $name);
if (count($parts) > 1) {
$ext = strtolower(end($parts));
if (isset(self::$mime_types[$ext])) {
return self::$mime_types[$ext];
}
}
return null;
}
private static $mime_types = array(
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',
'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template',
'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',
'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide',
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',
'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12',
'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12',
'apk' => 'application/vnd.android.package-archive',
'hqx' => 'application/mac-binhex40',
'cpt' => 'application/mac-compactpro',
'doc' => 'application/msword',
'ogg' => 'audio/ogg',
'pdf' => 'application/pdf',
'rtf' => 'text/rtf',
'mif' => 'application/vnd.mif',
'xls' => 'application/vnd.ms-excel',
'ppt' => 'application/vnd.ms-powerpoint',
'odc' => 'application/vnd.oasis.opendocument.chart',
'odb' => 'application/vnd.oasis.opendocument.database',
'odf' => 'application/vnd.oasis.opendocument.formula',
'odg' => 'application/vnd.oasis.opendocument.graphics',
'otg' => 'application/vnd.oasis.opendocument.graphics-template',
'odi' => 'application/vnd.oasis.opendocument.image',
'odp' => 'application/vnd.oasis.opendocument.presentation',
'otp' => 'application/vnd.oasis.opendocument.presentation-template',
'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template',
'odt' => 'application/vnd.oasis.opendocument.text',
'odm' => 'application/vnd.oasis.opendocument.text-master',
'ott' => 'application/vnd.oasis.opendocument.text-template',
'oth' => 'application/vnd.oasis.opendocument.text-web',
'sxw' => 'application/vnd.sun.xml.writer',
'stw' => 'application/vnd.sun.xml.writer.template',
'sxc' => 'application/vnd.sun.xml.calc',
'stc' => 'application/vnd.sun.xml.calc.template',
'sxd' => 'application/vnd.sun.xml.draw',
'std' => 'application/vnd.sun.xml.draw.template',
'sxi' => 'application/vnd.sun.xml.impress',
'sti' => 'application/vnd.sun.xml.impress.template',
'sxg' => 'application/vnd.sun.xml.writer.global',
'sxm' => 'application/vnd.sun.xml.math',
'sis' => 'application/vnd.symbian.install',
'wbxml' => 'application/vnd.wap.wbxml',
'wmlc' => 'application/vnd.wap.wmlc',
'wmlsc' => 'application/vnd.wap.wmlscriptc',
'bcpio' => 'application/x-bcpio',
'torrent' => 'application/x-bittorrent',
'bz2' => 'application/x-bzip2',
'vcd' => 'application/x-cdlink',
'pgn' => 'application/x-chess-pgn',
'cpio' => 'application/x-cpio',
'csh' => 'application/x-csh',
'dvi' => 'application/x-dvi',
'spl' => 'application/x-futuresplash',
'gtar' => 'application/x-gtar',
'hdf' => 'application/x-hdf',
'jar' => 'application/java-archive',
'jnlp' => 'application/x-java-jnlp-file',
'js' => 'application/javascript',
'json' => 'application/json',
'ksp' => 'application/x-kspread',
'chrt' => 'application/x-kchart',
'kil' => 'application/x-killustrator',
'latex' => 'application/x-latex',
'rpm' => 'application/x-rpm',
'sh' => 'application/x-sh',
'shar' => 'application/x-shar',
'swf' => 'application/x-shockwave-flash',
'sit' => 'application/x-stuffit',
'sv4cpio' => 'application/x-sv4cpio',
'sv4crc' => 'application/x-sv4crc',
'tar' => 'application/x-tar',
'tcl' => 'application/x-tcl',
'tex' => 'application/x-tex',
'man' => 'application/x-troff-man',
'me' => 'application/x-troff-me',
'ms' => 'application/x-troff-ms',
'ustar' => 'application/x-ustar',
'src' => 'application/x-wais-source',
'zip' => 'application/zip',
'm3u' => 'audio/x-mpegurl',
'ra' => 'audio/x-pn-realaudio',
'wav' => 'audio/x-wav',
'wma' => 'audio/x-ms-wma',
'wax' => 'audio/x-ms-wax',
'pdb' => 'chemical/x-pdb',
'xyz' => 'chemical/x-xyz',
'bmp' => 'image/bmp',
'gif' => 'image/gif',
'ief' => 'image/ief',
'png' => 'image/png',
'wbmp' => 'image/vnd.wap.wbmp',
'ras' => 'image/x-cmu-raster',
'pnm' => 'image/x-portable-anymap',
'pbm' => 'image/x-portable-bitmap',
'pgm' => 'image/x-portable-graymap',
'ppm' => 'image/x-portable-pixmap',
'rgb' => 'image/x-rgb',
'xbm' => 'image/x-xbitmap',
'xpm' => 'image/x-xpixmap',
'xwd' => 'image/x-xwindowdump',
'css' => 'text/css',
'rtx' => 'text/richtext',
'tsv' => 'text/tab-separated-values',
'jad' => 'text/vnd.sun.j2me.app-descriptor',
'wml' => 'text/vnd.wap.wml',
'wmls' => 'text/vnd.wap.wmlscript',
'etx' => 'text/x-setext',
'mxu' => 'video/vnd.mpegurl',
'flv' => 'video/x-flv',
'wm' => 'video/x-ms-wm',
'wmv' => 'video/x-ms-wmv',
'wmx' => 'video/x-ms-wmx',
'wvx' => 'video/x-ms-wvx',
'avi' => 'video/x-msvideo',
'movie' => 'video/x-sgi-movie',
'ice' => 'x-conference/x-cooltalk',
'3gp' => 'video/3gpp',
'ai' => 'application/postscript',
'aif' => 'audio/x-aiff',
'aifc' => 'audio/x-aiff',
'aiff' => 'audio/x-aiff',
'asc' => 'text/plain',
'atom' => 'application/atom+xml',
'au' => 'audio/basic',
'bin' => 'application/octet-stream',
'cdf' => 'application/x-netcdf',
'cgm' => 'image/cgm',
'class' => 'application/octet-stream',
'dcr' => 'application/x-director',
'dif' => 'video/x-dv',
'dir' => 'application/x-director',
'djv' => 'image/vnd.djvu',
'djvu' => 'image/vnd.djvu',
'dll' => 'application/octet-stream',
'dmg' => 'application/octet-stream',
'dms' => 'application/octet-stream',
'dtd' => 'application/xml-dtd',
'dv' => 'video/x-dv',
'dxr' => 'application/x-director',
'eps' => 'application/postscript',
'exe' => 'application/octet-stream',
'ez' => 'application/andrew-inset',
'gram' => 'application/srgs',
'grxml' => 'application/srgs+xml',
'gz' => 'application/x-gzip',
'htm' => 'text/html',
'html' => 'text/html',
'ico' => 'image/x-icon',
'ics' => 'text/calendar',
'ifb' => 'text/calendar',
'iges' => 'model/iges',
'igs' => 'model/iges',
'jp2' => 'image/jp2',
'jpe' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'jpg' => 'image/jpeg',
'kar' => 'audio/midi',
'lha' => 'application/octet-stream',
'lzh' => 'application/octet-stream',
'm4a' => 'audio/mp4a-latm',
'm4p' => 'audio/mp4a-latm',
'm4u' => 'video/vnd.mpegurl',
'm4v' => 'video/x-m4v',
'mac' => 'image/x-macpaint',
'mathml' => 'application/mathml+xml',
'mesh' => 'model/mesh',
'mid' => 'audio/midi',
'midi' => 'audio/midi',
'mov' => 'video/quicktime',
'mp2' => 'audio/mpeg',
'mp3' => 'audio/mpeg',
'mp4' => 'video/mp4',
'mpe' => 'video/mpeg',
'mpeg' => 'video/mpeg',
'mpg' => 'video/mpeg',
'mpga' => 'audio/mpeg',
'msh' => 'model/mesh',
'nc' => 'application/x-netcdf',
'oda' => 'application/oda',
'ogv' => 'video/ogv',
'pct' => 'image/pict',
'pic' => 'image/pict',
'pict' => 'image/pict',
'pnt' => 'image/x-macpaint',
'pntg' => 'image/x-macpaint',
'ps' => 'application/postscript',
'qt' => 'video/quicktime',
'qti' => 'image/x-quicktime',
'qtif' => 'image/x-quicktime',
'ram' => 'audio/x-pn-realaudio',
'rdf' => 'application/rdf+xml',
'rm' => 'application/vnd.rn-realmedia',
'roff' => 'application/x-troff',
'sgm' => 'text/sgml',
'sgml' => 'text/sgml',
'silo' => 'model/mesh',
'skd' => 'application/x-koan',
'skm' => 'application/x-koan',
'skp' => 'application/x-koan',
'skt' => 'application/x-koan',
'smi' => 'application/smil',
'smil' => 'application/smil',
'snd' => 'audio/basic',
'so' => 'application/octet-stream',
'svg' => 'image/svg+xml',
't' => 'application/x-troff',
'texi' => 'application/x-texinfo',
'texinfo' => 'application/x-texinfo',
'tif' => 'image/tiff',
'tiff' => 'image/tiff',
'tr' => 'application/x-troff',
'txt' => 'text/plain',
'vrml' => 'model/vrml',
'vxml' => 'application/voicexml+xml',
'webm' => 'video/webm',
'webp' => 'image/webp',
'wrl' => 'model/vrml',
'xht' => 'application/xhtml+xml',
'xhtml' => 'application/xhtml+xml',
'xml' => 'application/xml',
'xsl' => 'application/xml',
'xslt' => 'application/xslt+xml',
'xul' => 'application/vnd.mozilla.xul+xml',
);
}

54
resources/org/OSS/Core/OssException.php

@ -0,0 +1,54 @@
<?php
namespace OSS\Core;
/**
* Class OssException
*
* OssClient在使用的时候,所抛出的异常,用户在使用OssClient的时候,要Try住相关代码,
* try的Exception应该是OssException,其中会得到相关异常原因
*
* @package OSS\Core
*/
class OssException extends \Exception
{
private $details = array();
function __construct($details)
{
if (is_array($details)) {
$message = $details['code'] . ': ' . $details['message']
. ' RequestId: ' . $details['request-id'];
parent::__construct($message);
$this->details = $details;
} else {
$message = $details;
parent::__construct($message);
}
}
public function getHTTPStatus()
{
return isset($this->details['status']) ? $this->details['status'] : '';
}
public function getRequestId()
{
return isset($this->details['request-id']) ? $this->details['request-id'] : '';
}
public function getErrorCode()
{
return isset($this->details['code']) ? $this->details['code'] : '';
}
public function getErrorMessage()
{
return isset($this->details['message']) ? $this->details['message'] : '';
}
public function getDetails()
{
return isset($this->details['body']) ? $this->details['body'] : '';
}
}

461
resources/org/OSS/Core/OssUtil.php

@ -0,0 +1,461 @@
<?php
namespace OSS\Core;
/**
* Class OssUtil
*
* Oss工具类,主要供OssClient使用,用户也可以使用本类进行返回结果的格式化
*
* @package OSS
*/
class OssUtil
{
const OSS_CONTENT = 'content';
const OSS_LENGTH = 'length';
const OSS_HEADERS = 'headers';
const OSS_MAX_OBJECT_GROUP_VALUE = 1000;
const OSS_MAX_PART_SIZE = 5368709120; // 5GB
const OSS_MID_PART_SIZE = 10485760; // 10MB
const OSS_MIN_PART_SIZE = 102400; // 100KB
/**
* 生成query params
*
* @param array $options 关联数组
* @return string 返回诸如 key1=value1&key2=value2
*/
public static function toQueryString($options = array())
{
$temp = array();
uksort($options, 'strnatcasecmp');
foreach ($options as $key => $value) {
if (is_string($key) && !is_array($value)) {
$temp[] = rawurlencode($key) . '=' . rawurlencode($value);
}
}
return implode('&', $temp);
}
/**
* 转义字符替换
*
* @param string $subject
* @return string
*/
public static function sReplace($subject)
{
$search = array('<', '>', '&', '\'', '"');
$replace = array('&lt;', '&gt;', '&amp;', '&apos;', '&quot;');
return str_replace($search, $replace, $subject);
}
/**
* 检查是否是中文编码
*
* @param $str
* @return int
*/
public static function chkChinese($str)
{
return preg_match('/[\x80-\xff]./', $str);
}
/**
* 检测是否GB2312编码
*
* @param string $str
* @return boolean false UTF-8编码 TRUE GB2312编码
*/
public static function isGb2312($str)
{
for ($i = 0; $i < strlen($str); $i++) {
$v = ord($str[$i]);
if ($v > 127) {
if (($v >= 228) && ($v <= 233)) {
if (($i + 2) >= (strlen($str) - 1)) return true; // not enough characters
$v1 = ord($str[$i + 1]);
$v2 = ord($str[$i + 2]);
if (($v1 >= 128) && ($v1 <= 191) && ($v2 >= 128) && ($v2 <= 191))
return false;
else
return true;
}
}
}
return false;
}
/**
* 检测是否GBK编码
*
* @param string $str
* @param boolean $gbk
* @return boolean
*/
public static function checkChar($str, $gbk = true)
{
for ($i = 0; $i < strlen($str); $i++) {
$v = ord($str[$i]);
if ($v > 127) {
if (($v >= 228) && ($v <= 233)) {
if (($i + 2) >= (strlen($str) - 1)) return $gbk ? true : FALSE; // not enough characters
$v1 = ord($str[$i + 1]);
$v2 = ord($str[$i + 2]);
if ($gbk) {
return (($v1 >= 128) && ($v1 <= 191) && ($v2 >= 128) && ($v2 <= 191)) ? FALSE : TRUE;//GBK
} else {
return (($v1 >= 128) && ($v1 <= 191) && ($v2 >= 128) && ($v2 <= 191)) ? TRUE : FALSE;
}
}
}
}
return $gbk ? TRUE : FALSE;
}
/**
* 检验bucket名称是否合法
* bucket的命名规范:
* 1. 只能包括小写字母,数字
* 2. 必须以小写字母或者数字开头
* 3. 长度必须在3-63字节之间
*
* @param string $bucket Bucket名称
* @return boolean
*/
public static function validateBucket($bucket)
{
$pattern = '/^[a-z0-9][a-z0-9-]{2,62}$/';
if (!preg_match($pattern, $bucket)) {
return false;
}
return true;
}
/**
* 检验object名称是否合法
* object命名规范:
* 1. 规则长度必须在1-1023字节之间
* 2. 使用UTF-8编码
* 3. 不能以 "/" "\\"开头
*
* @param string $object Object名称
* @return boolean
*/
public static function validateObject($object)
{
$pattern = '/^.{1,1023}$/';
if (empty($object) || !preg_match($pattern, $object) ||
self::startsWith($object, '/') || self::startsWith($object, '\\')
) {
return false;
}
return true;
}
/**
* 判断字符串$str是不是以$findMe开始
*
* @param string $str
* @param string $findMe
* @return bool
*/
public static function startsWith($str, $findMe)
{
if (strpos($str, $findMe) === 0) {
return true;
} else {
return false;
}
}
/**
* 生成createBucketXmlBody接口的xml消息
*
* @param string $storageClass
* @return string
*/
public static function createBucketXmlBody($storageClass)
{
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="UTF-8"?><CreateBucketConfiguration></CreateBucketConfiguration>');
$xml->addChild('StorageClass', $storageClass);
return $xml->asXML();
}
/**
* 检验$options
*
* @param array $options
* @throws OssException
* @return boolean
*/
public static function validateOptions($options)
{
//$options
if ($options != NULL && !is_array($options)) {
throw new OssException ($options . ':' . 'option must be array');
}
}
/**
* 检查上传文件的内容是否合法
*
* @param $content string
* @throws OssException
*/
public static function validateContent($content)
{
if (empty($content)) {
throw new OssException("http body content is invalid");
}
}
/**
* 校验BUCKET/OBJECT/OBJECT GROUP是否为空
*
* @param string $name
* @param string $errMsg
* @throws OssException
* @return void
*/
public static function throwOssExceptionWithMessageIfEmpty($name, $errMsg)
{
if (empty($name)) {
throw new OssException($errMsg);
}
}
/**
* 仅供测试使用的接口,请勿使用
*
* @param $filename
* @param $size
*/
public static function generateFile($filename, $size)
{
if (file_exists($filename) && $size == filesize($filename)) {
echo $filename . " already exists, no need to create again. ";
return;
}
$part_size = 1 * 1024 * 1024;
$fp = fopen($filename, "w");
$characters = <<<BBB
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
BBB;
$charactersLength = strlen($characters);
if ($fp) {
while ($size > 0) {
if ($size < $part_size) {
$write_size = $size;
} else {
$write_size = $part_size;
}
$size -= $write_size;
$a = $characters[rand(0, $charactersLength - 1)];
$content = str_repeat($a, $write_size);
$flag = fwrite($fp, $content);
if (!$flag) {
echo "write to " . $filename . " failed. <br>";
break;
}
}
} else {
echo "open " . $filename . " failed. <br>";
}
fclose($fp);
}
/**
* 得到文件的md5编码
*
* @param $filename
* @param $from_pos
* @param $to_pos
* @return string
*/
public static function getMd5SumForFile($filename, $from_pos, $to_pos)
{
$content_md5 = "";
if (($to_pos - $from_pos) > self::OSS_MAX_PART_SIZE) {
return $content_md5;
}
$filesize = filesize($filename);
if ($from_pos >= $filesize || $to_pos >= $filesize || $from_pos < 0 || $to_pos < 0) {
return $content_md5;
}
$total_length = $to_pos - $from_pos + 1;
$buffer = 8192;
$left_length = $total_length;
if (!file_exists($filename)) {
return $content_md5;
}
if (false === $fh = fopen($filename, 'rb')) {
return $content_md5;
}
fseek($fh, $from_pos);
$data = '';
while (!feof($fh)) {
if ($left_length >= $buffer) {
$read_length = $buffer;
} else {
$read_length = $left_length;
}
if ($read_length <= 0) {
break;
} else {
$data .= fread($fh, $read_length);
$left_length = $left_length - $read_length;
}
}
fclose($fh);
$content_md5 = base64_encode(md5($data, true));
return $content_md5;
}
/**
* 检测是否windows系统,因为windows系统默认编码为GBK
*
* @return bool
*/
public static function isWin()
{
return strtoupper(substr(PHP_OS, 0, 3)) == "WIN";
}
/**
* 主要是由于windows系统编码是gbk,遇到中文时候,如果不进行转换处理会出现找不到文件的问题
*
* @param $file_path
* @return string
*/
public static function encodePath($file_path)
{
if (self::chkChinese($file_path) && self::isWin()) {
$file_path = iconv('utf-8', 'gbk', $file_path);
}
return $file_path;
}
/**
* 判断用户输入的endpoint是否是 xxx.xxx.xxx.xxx:port 或者 xxx.xxx.xxx.xxx的ip格式
*
* @param string $endpoint 需要做判断的endpoint
* @return boolean
*/
public static function isIPFormat($endpoint)
{
$ip_array = explode(":", $endpoint);
$hostname = $ip_array[0];
$ret = filter_var($hostname, FILTER_VALIDATE_IP);
if (!$ret) {
return false;
} else {
return true;
}
}
/**
* 生成DeleteMultiObjects接口的xml消息
*
* @param string[] $objects
* @param bool $quiet
* @return string
*/
public static function createDeleteObjectsXmlBody($objects, $quiet)
{
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><Delete></Delete>');
$xml->addChild('Quiet', $quiet);
foreach ($objects as $object) {
$sub_object = $xml->addChild('Object');
$object = OssUtil::sReplace($object);
$sub_object->addChild('Key', $object);
}
return $xml->asXML();
}
/**
* 生成CompleteMultipartUpload接口的xml消息
*
* @param array[] $listParts
* @return string
*/
public static function createCompleteMultipartUploadXmlBody($listParts)
{
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><CompleteMultipartUpload></CompleteMultipartUpload>');
foreach ($listParts as $node) {
$part = $xml->addChild('Part');
$part->addChild('PartNumber', $node['PartNumber']);
$part->addChild('ETag', $node['ETag']);
}
return $xml->asXML();
}
/**
* 读取目录
*
* @param string $dir
* @param string $exclude
* @param bool $recursive
* @return string[]
*/
public static function readDir($dir, $exclude = ".|..|.svn|.git", $recursive = false)
{
$file_list_array = array();
$base_path = $dir;
$exclude_array = explode("|", $exclude);
$exclude_array = array_unique(array_merge($exclude_array, array('.', '..')));
if ($recursive) {
foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir)) as $new_file) {
if ($new_file->isDir()) continue;
$object = str_replace($base_path, '', $new_file);
if (!in_array(strtolower($object), $exclude_array)) {
$object = ltrim($object, '/');
if (is_file($new_file)) {
$key = md5($new_file . $object, false);
$file_list_array[$key] = array('path' => $new_file, 'file' => $object,);
}
}
}
} else if ($handle = opendir($dir)) {
while (false !== ($file = readdir($handle))) {
if (!in_array(strtolower($file), $exclude_array)) {
$new_file = $dir . '/' . $file;
$object = $file;
$object = ltrim($object, '/');
if (is_file($new_file)) {
$key = md5($new_file . $object, false);
$file_list_array[$key] = array('path' => $new_file, 'file' => $object,);
}
}
}
closedir($handle);
}
return $file_list_array;
}
/**
* Decode key based on the encoding type
*
* @param string $key
* @param string $encoding
* @return string
*/
public static function decodeKey($key, $encoding)
{
if ($encoding == "") {
return $key;
}
if ($encoding == "url") {
return rawurldecode($key);
} else {
throw new OssException("Unrecognized encoding type: " . $encoding);
}
}
}

25
resources/org/OSS/Http/LICENSE

@ -0,0 +1,25 @@
Copyright (c) 2006-2010 Ryan Parman, Foleeo Inc., and contributors. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list
of conditions and the following disclaimer in the documentation and/or other materials
provided with the distribution.
* Neither the name of Ryan Parman, Foleeo Inc. nor the names of its contributors may be used to
endorse or promote products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

896
resources/org/OSS/Http/RequestCore.php

@ -0,0 +1,896 @@
<?php
namespace OSS\Http;
/**
* Handles all HTTP requests using cURL and manages the responses.
*
* @version 2011.06.07
* @copyright 2006-2011 Ryan Parman
* @copyright 2006-2010 Foleeo Inc.
* @copyright 2010-2011 Amazon.com, Inc. or its affiliates.
* @copyright 2008-2011 Contributors
* @license http://opensource.org/licenses/bsd-license.php Simplified BSD License
*/
class RequestCore
{
/**
* The URL being requested.
*/
public $request_url;
/**
* The headers being sent in the request.
*/
public $request_headers;
/**
* The raw response callback headers
*/
public $response_raw_headers;
/**
* Response body when error occurs
*/
public $response_error_body;
/**
*The hander of write file
*/
public $write_file_handle;
/**
* The body being sent in the request.
*/
public $request_body;
/**
* The response returned by the request.
*/
public $response;
/**
* The headers returned by the request.
*/
public $response_headers;
/**
* The body returned by the request.
*/
public $response_body;
/**
* The HTTP status code returned by the request.
*/
public $response_code;
/**
* Additional response data.
*/
public $response_info;
/**
* The method by which the request is being made.
*/
public $method;
/**
* Stores the proxy settings to use for the request.
*/
public $proxy = null;
/**
* The username to use for the request.
*/
public $username = null;
/**
* The password to use for the request.
*/
public $password = null;
/**
* Custom CURLOPT settings.
*/
public $curlopts = null;
/**
* The state of debug mode.
*/
public $debug_mode = false;
/**
* The default class to use for HTTP Requests (defaults to <RequestCore>).
*/
public $request_class = 'OSS\Http\RequestCore';
/**
* The default class to use for HTTP Responses (defaults to <ResponseCore>).
*/
public $response_class = 'OSS\Http\ResponseCore';
/**
* Default useragent string to use.
*/
public $useragent = 'RequestCore/1.4.3';
/**
* File to read from while streaming up.
*/
public $read_file = null;
/**
* The resource to read from while streaming up.
*/
public $read_stream = null;
/**
* The size of the stream to read from.
*/
public $read_stream_size = null;
/**
* The length already read from the stream.
*/
public $read_stream_read = 0;
/**
* File to write to while streaming down.
*/
public $write_file = null;
/**
* The resource to write to while streaming down.
*/
public $write_stream = null;
/**
* Stores the intended starting seek position.
*/
public $seek_position = null;
/**
* The location of the cacert.pem file to use.
*/
public $cacert_location = false;
/**
* The state of SSL certificate verification.
*/
public $ssl_verification = true;
/**
* The user-defined callback function to call when a stream is read from.
*/
public $registered_streaming_read_callback = null;
/**
* The user-defined callback function to call when a stream is written to.
*/
public $registered_streaming_write_callback = null;
/**
* 请求超时时间, 默认是5184000秒,6天
*
* @var int
*/
public $timeout = 5184000;
/**
* 连接超时时间,默认是10秒
*
* @var int
*/
public $connect_timeout = 10;
/*%******************************************************************************************%*/
// CONSTANTS
/**
* GET HTTP Method
*/
const HTTP_GET = 'GET';
/**
* POST HTTP Method
*/
const HTTP_POST = 'POST';
/**
* PUT HTTP Method
*/
const HTTP_PUT = 'PUT';
/**
* DELETE HTTP Method
*/
const HTTP_DELETE = 'DELETE';
/**
* HEAD HTTP Method
*/
const HTTP_HEAD = 'HEAD';
/*%******************************************************************************************%*/
// CONSTRUCTOR/DESTRUCTOR
/**
* Constructs a new instance of this class.
*
* @param string $url (Optional) The URL to request or service endpoint to query.
* @param string $proxy (Optional) The faux-url to use for proxy settings. Takes the following format: `proxy://user:pass@hostname:port`
* @param array $helpers (Optional) An associative array of classnames to use for request, and response functionality. Gets passed in automatically by the calling class.
* @return $this A reference to the current instance.
*/
public function __construct($url = null, $proxy = null, $helpers = null)
{
// Set some default values.
$this->request_url = $url;
$this->method = self::HTTP_GET;
$this->request_headers = array();
$this->request_body = '';
// Set a new Request class if one was set.
if (isset($helpers['request']) && !empty($helpers['request'])) {
$this->request_class = $helpers['request'];
}
// Set a new Request class if one was set.
if (isset($helpers['response']) && !empty($helpers['response'])) {
$this->response_class = $helpers['response'];
}
if ($proxy) {
$this->set_proxy($proxy);
}
return $this;
}
/**
* Destructs the instance. Closes opened file handles.
*
* @return $this A reference to the current instance.
*/
public function __destruct()
{
if (isset($this->read_file) && isset($this->read_stream)) {
fclose($this->read_stream);
}
if (isset($this->write_file) && isset($this->write_stream)) {
fclose($this->write_stream);
}
return $this;
}
/*%******************************************************************************************%*/
// REQUEST METHODS
/**
* Sets the credentials to use for authentication.
*
* @param string $user (Required) The username to authenticate with.
* @param string $pass (Required) The password to authenticate with.
* @return $this A reference to the current instance.
*/
public function set_credentials($user, $pass)
{
$this->username = $user;
$this->password = $pass;
return $this;
}
/**
* Adds a custom HTTP header to the cURL request.
*
* @param string $key (Required) The custom HTTP header to set.
* @param mixed $value (Required) The value to assign to the custom HTTP header.
* @return $this A reference to the current instance.
*/
public function add_header($key, $value)
{
$this->request_headers[$key] = $value;
return $this;
}
/**
* Removes an HTTP header from the cURL request.
*
* @param string $key (Required) The custom HTTP header to set.
* @return $this A reference to the current instance.
*/
public function remove_header($key)
{
if (isset($this->request_headers[$key])) {
unset($this->request_headers[$key]);
}
return $this;
}
/**
* Set the method type for the request.
*
* @param string $method (Required) One of the following constants: <HTTP_GET>, <HTTP_POST>, <HTTP_PUT>, <HTTP_HEAD>, <HTTP_DELETE>.
* @return $this A reference to the current instance.
*/
public function set_method($method)
{
$this->method = strtoupper($method);
return $this;
}
/**
* Sets a custom useragent string for the class.
*
* @param string $ua (Required) The useragent string to use.
* @return $this A reference to the current instance.
*/
public function set_useragent($ua)
{
$this->useragent = $ua;
return $this;
}
/**
* Set the body to send in the request.
*
* @param string $body (Required) The textual content to send along in the body of the request.
* @return $this A reference to the current instance.
*/
public function set_body($body)
{
$this->request_body = $body;
return $this;
}
/**
* Set the URL to make the request to.
*
* @param string $url (Required) The URL to make the request to.
* @return $this A reference to the current instance.
*/
public function set_request_url($url)
{
$this->request_url = $url;
return $this;
}
/**
* Set additional CURLOPT settings. These will merge with the default settings, and override if
* there is a duplicate.
*
* @param array $curlopts (Optional) A set of key-value pairs that set `CURLOPT` options. These will merge with the existing CURLOPTs, and ones passed here will override the defaults. Keys should be the `CURLOPT_*` constants, not strings.
* @return $this A reference to the current instance.
*/
public function set_curlopts($curlopts)
{
$this->curlopts = $curlopts;
return $this;
}
/**
* Sets the length in bytes to read from the stream while streaming up.
*
* @param integer $size (Required) The length in bytes to read from the stream.
* @return $this A reference to the current instance.
*/
public function set_read_stream_size($size)
{
$this->read_stream_size = $size;
return $this;
}
/**
* Sets the resource to read from while streaming up. Reads the stream from its current position until
* EOF or `$size` bytes have been read. If `$size` is not given it will be determined by <php:fstat()> and
* <php:ftell()>.
*
* @param resource $resource (Required) The readable resource to read from.
* @param integer $size (Optional) The size of the stream to read.
* @return $this A reference to the current instance.
*/
public function set_read_stream($resource, $size = null)
{
if (!isset($size) || $size < 0) {
$stats = fstat($resource);
if ($stats && $stats['size'] >= 0) {
$position = ftell($resource);
if ($position !== false && $position >= 0) {
$size = $stats['size'] - $position;
}
}
}
$this->read_stream = $resource;
return $this->set_read_stream_size($size);
}
/**
* Sets the file to read from while streaming up.
*
* @param string $location (Required) The readable location to read from.
* @return $this A reference to the current instance.
*/
public function set_read_file($location)
{
$this->read_file = $location;
$read_file_handle = fopen($location, 'r');
return $this->set_read_stream($read_file_handle);
}
/**
* Sets the resource to write to while streaming down.
*
* @param resource $resource (Required) The writeable resource to write to.
* @return $this A reference to the current instance.
*/
public function set_write_stream($resource)
{
$this->write_stream = $resource;
return $this;
}
/**
* Sets the file to write to while streaming down.
*
* @param string $location (Required) The writeable location to write to.
* @return $this A reference to the current instance.
*/
public function set_write_file($location)
{
$this->write_file = $location;
}
/**
* Set the proxy to use for making requests.
*
* @param string $proxy (Required) The faux-url to use for proxy settings. Takes the following format: `proxy://user:pass@hostname:port`
* @return $this A reference to the current instance.
*/
public function set_proxy($proxy)
{
$proxy = parse_url($proxy);
$proxy['user'] = isset($proxy['user']) ? $proxy['user'] : null;
$proxy['pass'] = isset($proxy['pass']) ? $proxy['pass'] : null;
$proxy['port'] = isset($proxy['port']) ? $proxy['port'] : null;
$this->proxy = $proxy;
return $this;
}
/**
* Set the intended starting seek position.
*
* @param integer $position (Required) The byte-position of the stream to begin reading from.
* @return $this A reference to the current instance.
*/
public function set_seek_position($position)
{
$this->seek_position = isset($position) ? (integer)$position : null;
return $this;
}
/**
* A callback function that is invoked by cURL for streaming up.
*
* @param resource $curl_handle (Required) The cURL handle for the request.
* @param resource $header_content (Required) The header callback result.
* @return headers from a stream.
*/
public function streaming_header_callback($curl_handle, $header_content)
{
$code = curl_getinfo($curl_handle, CURLINFO_HTTP_CODE);
if (isset($this->write_file) && intval($code) / 100 == 2 && !isset($this->write_file_handle))
{
$this->write_file_handle = fopen($this->write_file, 'w');
$this->set_write_stream($this->write_file_handle);
}
$this->response_raw_headers .= $header_content;
return strlen($header_content);
}
/**
* Register a callback function to execute whenever a data stream is read from using
* <CFRequest::streaming_read_callback()>.
*
* The user-defined callback function should accept three arguments:
*
* <ul>
* <li><code>$curl_handle</code> - <code>resource</code> - Required - The cURL handle resource that represents the in-progress transfer.</li>
* <li><code>$file_handle</code> - <code>resource</code> - Required - The file handle resource that represents the file on the local file system.</li>
* <li><code>$length</code> - <code>integer</code> - Required - The length in kilobytes of the data chunk that was transferred.</li>
* </ul>
*
* @param string|array|function $callback (Required) The callback function is called by <php:call_user_func()>, so you can pass the following values: <ul>
* <li>The name of a global function to execute, passed as a string.</li>
* <li>A method to execute, passed as <code>array('ClassName', 'MethodName')</code>.</li>
* <li>An anonymous function (PHP 5.3+).</li></ul>
* @return $this A reference to the current instance.
*/
public function register_streaming_read_callback($callback)
{
$this->registered_streaming_read_callback = $callback;
return $this;
}
/**
* Register a callback function to execute whenever a data stream is written to using
* <CFRequest::streaming_write_callback()>.
*
* The user-defined callback function should accept two arguments:
*
* <ul>
* <li><code>$curl_handle</code> - <code>resource</code> - Required - The cURL handle resource that represents the in-progress transfer.</li>
* <li><code>$length</code> - <code>integer</code> - Required - The length in kilobytes of the data chunk that was transferred.</li>
* </ul>
*
* @param string|array|function $callback (Required) The callback function is called by <php:call_user_func()>, so you can pass the following values: <ul>
* <li>The name of a global function to execute, passed as a string.</li>
* <li>A method to execute, passed as <code>array('ClassName', 'MethodName')</code>.</li>
* <li>An anonymous function (PHP 5.3+).</li></ul>
* @return $this A reference to the current instance.
*/
public function register_streaming_write_callback($callback)
{
$this->registered_streaming_write_callback = $callback;
return $this;
}
/*%******************************************************************************************%*/
// PREPARE, SEND, AND PROCESS REQUEST
/**
* A callback function that is invoked by cURL for streaming up.
*
* @param resource $curl_handle (Required) The cURL handle for the request.
* @param resource $file_handle (Required) The open file handle resource.
* @param integer $length (Required) The maximum number of bytes to read.
* @return binary Binary data from a stream.
*/
public function streaming_read_callback($curl_handle, $file_handle, $length)
{
// Once we've sent as much as we're supposed to send...
if ($this->read_stream_read >= $this->read_stream_size) {
// Send EOF
return '';
}
// If we're at the beginning of an upload and need to seek...
if ($this->read_stream_read == 0 && isset($this->seek_position) && $this->seek_position !== ftell($this->read_stream)) {
if (fseek($this->read_stream, $this->seek_position) !== 0) {
throw new RequestCore_Exception('The stream does not support seeking and is either not at the requested position or the position is unknown.');
}
}
$read = fread($this->read_stream, min($this->read_stream_size - $this->read_stream_read, $length)); // Remaining upload data or cURL's requested chunk size
$this->read_stream_read += strlen($read);
$out = $read === false ? '' : $read;
// Execute callback function
if ($this->registered_streaming_read_callback) {
call_user_func($this->registered_streaming_read_callback, $curl_handle, $file_handle, $out);
}
return $out;
}
/**
* A callback function that is invoked by cURL for streaming down.
*
* @param resource $curl_handle (Required) The cURL handle for the request.
* @param binary $data (Required) The data to write.
* @return integer The number of bytes written.
*/
public function streaming_write_callback($curl_handle, $data)
{
$code = curl_getinfo($curl_handle, CURLINFO_HTTP_CODE);
if (intval($code) / 100 != 2)
{
$this->response_error_body .= $data;
return strlen($data);
}
$length = strlen($data);
$written_total = 0;
$written_last = 0;
while ($written_total < $length) {
$written_last = fwrite($this->write_stream, substr($data, $written_total));
if ($written_last === false) {
return $written_total;
}
$written_total += $written_last;
}
// Execute callback function
if ($this->registered_streaming_write_callback) {
call_user_func($this->registered_streaming_write_callback, $curl_handle, $written_total);
}
return $written_total;
}
/**
* Prepares and adds the details of the cURL request. This can be passed along to a <php:curl_multi_exec()>
* function.
*
* @return resource The handle for the cURL object.
*
*/
public function prep_request()
{
$curl_handle = curl_init();
// Set default options.
curl_setopt($curl_handle, CURLOPT_URL, $this->request_url);
curl_setopt($curl_handle, CURLOPT_FILETIME, true);
curl_setopt($curl_handle, CURLOPT_FRESH_CONNECT, false);
// curl_setopt($curl_handle, CURLOPT_CLOSEPOLICY, CURLCLOSEPOLICY_LEAST_RECENTLY_USED);
curl_setopt($curl_handle, CURLOPT_MAXREDIRS, 5);
curl_setopt($curl_handle, CURLOPT_HEADER, true);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_handle, CURLOPT_TIMEOUT, $this->timeout);
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, $this->connect_timeout);
curl_setopt($curl_handle, CURLOPT_NOSIGNAL, true);
curl_setopt($curl_handle, CURLOPT_REFERER, $this->request_url);
curl_setopt($curl_handle, CURLOPT_USERAGENT, $this->useragent);
curl_setopt($curl_handle, CURLOPT_HEADERFUNCTION, array($this, 'streaming_header_callback'));
curl_setopt($curl_handle, CURLOPT_READFUNCTION, array($this, 'streaming_read_callback'));
// Verification of the SSL cert
if ($this->ssl_verification) {
curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($curl_handle, CURLOPT_SSL_VERIFYHOST, 2);
} else {
curl_setopt($curl_handle, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_handle, CURLOPT_SSL_VERIFYHOST, false);
}
// chmod the file as 0755
if ($this->cacert_location === true) {
curl_setopt($curl_handle, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem');
} elseif (is_string($this->cacert_location)) {
curl_setopt($curl_handle, CURLOPT_CAINFO, $this->cacert_location);
}
// Debug mode
if ($this->debug_mode) {
curl_setopt($curl_handle, CURLOPT_VERBOSE, true);
}
// Handle open_basedir & safe mode
if (!ini_get('safe_mode') && !ini_get('open_basedir')) {
curl_setopt($curl_handle, CURLOPT_FOLLOWLOCATION, true);
}
// Enable a proxy connection if requested.
if ($this->proxy) {
$host = $this->proxy['host'];
$host .= ($this->proxy['port']) ? ':' . $this->proxy['port'] : '';
curl_setopt($curl_handle, CURLOPT_PROXY, $host);
if (isset($this->proxy['user']) && isset($this->proxy['pass'])) {
curl_setopt($curl_handle, CURLOPT_PROXYUSERPWD, $this->proxy['user'] . ':' . $this->proxy['pass']);
}
}
// Set credentials for HTTP Basic/Digest Authentication.
if ($this->username && $this->password) {
curl_setopt($curl_handle, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($curl_handle, CURLOPT_USERPWD, $this->username . ':' . $this->password);
}
// Handle the encoding if we can.
if (extension_loaded('zlib')) {
curl_setopt($curl_handle, CURLOPT_ENCODING, '');
}
// Process custom headers
if (isset($this->request_headers) && count($this->request_headers)) {
$temp_headers = array();
foreach ($this->request_headers as $k => $v) {
$temp_headers[] = $k . ': ' . $v;
}
curl_setopt($curl_handle, CURLOPT_HTTPHEADER, $temp_headers);
}
switch ($this->method) {
case self::HTTP_PUT:
//unset($this->read_stream);
curl_setopt($curl_handle, CURLOPT_CUSTOMREQUEST, 'PUT');
if (isset($this->read_stream)) {
if (!isset($this->read_stream_size) || $this->read_stream_size < 0) {
throw new RequestCore_Exception('The stream size for the streaming upload cannot be determined.');
}
curl_setopt($curl_handle, CURLOPT_INFILESIZE, $this->read_stream_size);
curl_setopt($curl_handle, CURLOPT_UPLOAD, true);
} else {
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $this->request_body);
}
break;
case self::HTTP_POST:
curl_setopt($curl_handle, CURLOPT_CUSTOMREQUEST, 'POST');
if (isset($this->read_stream)) {
if (!isset($this->read_stream_size) || $this->read_stream_size < 0) {
throw new RequestCore_Exception('The stream size for the streaming upload cannot be determined.');
}
curl_setopt($curl_handle, CURLOPT_INFILESIZE, $this->read_stream_size);
curl_setopt($curl_handle, CURLOPT_UPLOAD, true);
} else {
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $this->request_body);
}
break;
case self::HTTP_HEAD:
curl_setopt($curl_handle, CURLOPT_CUSTOMREQUEST, self::HTTP_HEAD);
curl_setopt($curl_handle, CURLOPT_NOBODY, 1);
break;
default: // Assumed GET
curl_setopt($curl_handle, CURLOPT_CUSTOMREQUEST, $this->method);
if (isset($this->write_stream) || isset($this->write_file)) {
curl_setopt($curl_handle, CURLOPT_WRITEFUNCTION, array($this, 'streaming_write_callback'));
curl_setopt($curl_handle, CURLOPT_HEADER, false);
} else {
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $this->request_body);
}
break;
}
// Merge in the CURLOPTs
if (isset($this->curlopts) && sizeof($this->curlopts) > 0) {
foreach ($this->curlopts as $k => $v) {
curl_setopt($curl_handle, $k, $v);
}
}
return $curl_handle;
}
/**
* Take the post-processed cURL data and break it down into useful header/body/info chunks. Uses the
* data stored in the `curl_handle` and `response` properties unless replacement data is passed in via
* parameters.
*
* @param resource $curl_handle (Optional) The reference to the already executed cURL request.
* @param string $response (Optional) The actual response content itself that needs to be parsed.
* @return ResponseCore A <ResponseCore> object containing a parsed HTTP response.
*/
public function process_response($curl_handle = null, $response = null)
{
// Accept a custom one if it's passed.
if ($curl_handle && $response) {
$this->response = $response;
}
// As long as this came back as a valid resource...
if (is_resource($curl_handle)) {
// Determine what's what.
$header_size = curl_getinfo($curl_handle, CURLINFO_HEADER_SIZE);
$this->response_headers = substr($this->response, 0, $header_size);
$this->response_body = substr($this->response, $header_size);
$this->response_code = curl_getinfo($curl_handle, CURLINFO_HTTP_CODE);
$this->response_info = curl_getinfo($curl_handle);
if (intval($this->response_code) / 100 != 2 && isset($this->write_file))
{
$this->response_headers = $this->response_raw_headers;
$this->response_body = $this->response_error_body;
}
// Parse out the headers
$this->response_headers = explode("\r\n\r\n", trim($this->response_headers));
$this->response_headers = array_pop($this->response_headers);
$this->response_headers = explode("\r\n", $this->response_headers);
array_shift($this->response_headers);
// Loop through and split up the headers.
$header_assoc = array();
foreach ($this->response_headers as $header) {
$kv = explode(': ', $header);
$header_assoc[strtolower($kv[0])] = isset($kv[1]) ? $kv[1] : '';
}
// Reset the headers to the appropriate property.
$this->response_headers = $header_assoc;
$this->response_headers['info'] = $this->response_info;
$this->response_headers['info']['method'] = $this->method;
if ($curl_handle && $response) {
return new ResponseCore($this->response_headers, $this->response_body, $this->response_code);
}
}
// Return false
return false;
}
/**
* Sends the request, calling necessary utility functions to update built-in properties.
*
* @param boolean $parse (Optional) Whether to parse the response with ResponseCore or not.
* @return string The resulting unparsed data from the request.
*/
public function send_request($parse = false)
{
set_time_limit(0);
$curl_handle = $this->prep_request();
$this->response = curl_exec($curl_handle);
if ($this->response === false) {
throw new RequestCore_Exception('cURL resource: ' . (string)$curl_handle . '; cURL error: ' . curl_error($curl_handle) . ' (' . curl_errno($curl_handle) . ')');
}
$parsed_response = $this->process_response($curl_handle, $this->response);
curl_close($curl_handle);
if ($parse) {
return $parsed_response;
}
return $this->response;
}
/*%******************************************************************************************%*/
// RESPONSE METHODS
/**
* Get the HTTP response headers from the request.
*
* @param string $header (Optional) A specific header value to return. Defaults to all headers.
* @return string|array All or selected header values.
*/
public function get_response_header($header = null)
{
if ($header) {
return $this->response_headers[strtolower($header)];
}
return $this->response_headers;
}
/**
* Get the HTTP response body from the request.
*
* @return string The response body.
*/
public function get_response_body()
{
return $this->response_body;
}
/**
* Get the HTTP response code from the request.
*
* @return string The HTTP response code.
*/
public function get_response_code()
{
return $this->response_code;
}
}

8
resources/org/OSS/Http/RequestCore_Exception.php

@ -0,0 +1,8 @@
<?php
namespace OSS\Http;
class RequestCore_Exception extends \Exception
{
}

56
resources/org/OSS/Http/ResponseCore.php

@ -0,0 +1,56 @@
<?php
namespace OSS\Http;
/**
* Container for all response-related methods.
*/
class ResponseCore
{
/**
* Stores the HTTP header information.
*/
public $header;
/**
* Stores the SimpleXML response.
*/
public $body;
/**
* Stores the HTTP response code.
*/
public $status;
/**
* Constructs a new instance of this class.
*
* @param array $header (Required) Associative array of HTTP headers (typically returned by <RequestCore::get_response_header()>).
* @param string $body (Required) XML-formatted response from AWS.
* @param integer $status (Optional) HTTP response status code from the request.
* @return Mixed Contains an <php:array> `header` property (HTTP headers as an associative array), a <php:SimpleXMLElement> or <php:string> `body` property, and an <php:integer> `status` code.
*/
public function __construct($header, $body, $status = null)
{
$this->header = $header;
$this->body = $body;
$this->status = $status;
return $this;
}
/**
* Did we receive the status code we expected?
*
* @param integer|array $codes (Optional) The status code(s) to expect. Pass an <php:integer> for a single acceptable value, or an <php:array> of integers for multiple acceptable values.
* @return boolean Whether we received the expected status code or not.
*/
public function isOK($codes = array(200, 201, 204, 206))
{
if (is_array($codes)) {
return in_array($this->status, $codes);
}
return $this->status === $codes;
}
}

78
resources/org/OSS/Model/BucketInfo.php

@ -0,0 +1,78 @@
<?php
namespace OSS\Model;
/**
* Bucket信息,ListBuckets接口返回数据
*
* Class BucketInfo
* @package OSS\Model
*/
class BucketInfo
{
/**
* BucketInfo constructor.
*
* @param string $location
* @param string $name
* @param string $createDate
*/
public function __construct($location, $name, $createDate)
{
$this->location = $location;
$this->name = $name;
$this->createDate = $createDate;
}
/**
* 得到bucket所在的region
*
* @return string
*/
public function getLocation()
{
return $this->location;
}
/**
* 得到bucket的名称
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* 得到bucket的创建时间
*
* @return string
*/
public function getCreateDate()
{
return $this->createDate;
}
/**
* bucket所在的region
*
* @var string
*/
private $location;
/**
* bucket的名称
*
* @var string
*/
private $name;
/**
* bucket的创建事件
*
* @var string
*/
private $createDate;
}

39
resources/org/OSS/Model/BucketListInfo.php

@ -0,0 +1,39 @@
<?php
namespace OSS\Model;
/**
* Class BucketListInfo
*
* ListBuckets接口返回的数据类型
*
* @package OSS\Model
*/
class BucketListInfo
{
/**
* BucketListInfo constructor.
* @param array $bucketList
*/
public function __construct(array $bucketList)
{
$this->bucketList = $bucketList;
}
/**
* 得到BucketInfo列表
*
* @return BucketInfo[]
*/
public function getBucketList()
{
return $this->bucketList;
}
/**
* BucketInfo信息列表
*
* @var array
*/
private $bucketList = array();
}

99
resources/org/OSS/Model/CnameConfig.php

@ -0,0 +1,99 @@
<?php
namespace OSS\Model;
use OSS\Core\OssException;
/**
* Class CnameConfig
* @package OSS\Model
*
* TODO: fix link
* @link http://help.aliyun.com/document_detail/oss/api-reference/cors/PutBucketcors.html
*/
class CnameConfig implements XmlConfig
{
public function __construct()
{
$this->cnameList = array();
}
/**
* @return array
* @example
* array(2) {
* [0]=>
* array(3) {
* ["Domain"]=>
* string(11) "www.foo.com"
* ["Status"]=>
* string(7) "enabled"
* ["LastModified"]=>
* string(8) "20150101"
* }
* [1]=>
* array(3) {
* ["Domain"]=>
* string(7) "bar.com"
* ["Status"]=>
* string(8) "disabled"
* ["LastModified"]=>
* string(8) "20160101"
* }
* }
*/
public function getCnames()
{
return $this->cnameList;
}
public function addCname($cname)
{
if (count($this->cnameList) >= self::OSS_MAX_RULES) {
throw new OssException(
"num of cname in the config exceeds self::OSS_MAX_RULES: " . strval(self::OSS_MAX_RULES));
}
$this->cnameList[] = array('Domain' => $cname);
}
public function parseFromXml($strXml)
{
$xml = simplexml_load_string($strXml);
if (!isset($xml->Cname)) return;
foreach ($xml->Cname as $entry) {
$cname = array();
foreach ($entry as $key => $value) {
$cname[strval($key)] = strval($value);
}
$this->cnameList[] = $cname;
}
}
public function serializeToXml()
{
$strXml = <<<EOF
<?xml version="1.0" encoding="utf-8"?>
<BucketCnameConfiguration>
</BucketCnameConfiguration>
EOF;
$xml = new \SimpleXMLElement($strXml);
foreach ($this->cnameList as $cname) {
$node = $xml->addChild('Cname');
foreach ($cname as $key => $value) {
$node->addChild($key, $value);
}
}
return $xml->asXML();
}
public function __toString()
{
return $this->serializeToXml();
}
const OSS_MAX_RULES = 10;
private $cnameList = array();
}

113
resources/org/OSS/Model/CorsConfig.php

@ -0,0 +1,113 @@
<?php
namespace OSS\Model;
use OSS\Core\OssException;
/**
* Class CorsConfig
* @package OSS\Model
*
* @link http://help.aliyun.com/document_detail/oss/api-reference/cors/PutBucketcors.html
*/
class CorsConfig implements XmlConfig
{
/**
* CorsConfig constructor.
*/
public function __construct()
{
$this->rules = array();
}
/**
* 得到CorsRule列表
*
* @return CorsRule[]
*/
public function getRules()
{
return $this->rules;
}
/**
* 添加一条CorsRule
*
* @param CorsRule $rule
* @throws OssException
*/
public function addRule($rule)
{
if (count($this->rules) >= self::OSS_MAX_RULES) {
throw new OssException("num of rules in the config exceeds self::OSS_MAX_RULES: " . strval(self::OSS_MAX_RULES));
}
$this->rules[] = $rule;
}
/**
* 从xml数据中解析出CorsConfig
*
* @param string $strXml
* @throws OssException
* @return null
*/
public function parseFromXml($strXml)
{
$xml = simplexml_load_string($strXml);
if (!isset($xml->CORSRule)) return;
foreach ($xml->CORSRule as $rule) {
$corsRule = new CorsRule();
foreach ($rule as $key => $value) {
if ($key === self::OSS_CORS_ALLOWED_HEADER) {
$corsRule->addAllowedHeader(strval($value));
} elseif ($key === self::OSS_CORS_ALLOWED_METHOD) {
$corsRule->addAllowedMethod(strval($value));
} elseif ($key === self::OSS_CORS_ALLOWED_ORIGIN) {
$corsRule->addAllowedOrigin(strval($value));
} elseif ($key === self::OSS_CORS_EXPOSE_HEADER) {
$corsRule->addExposeHeader(strval($value));
} elseif ($key === self::OSS_CORS_MAX_AGE_SECONDS) {
$corsRule->setMaxAgeSeconds(strval($value));
}
}
$this->addRule($corsRule);
}
return;
}
/**
* 生成xml字符串
*
* @return string
*/
public function serializeToXml()
{
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><CORSConfiguration></CORSConfiguration>');
foreach ($this->rules as $rule) {
$xmlRule = $xml->addChild('CORSRule');
$rule->appendToXml($xmlRule);
}
return $xml->asXML();
}
public function __toString()
{
return $this->serializeToXml();
}
const OSS_CORS_ALLOWED_ORIGIN = 'AllowedOrigin';
const OSS_CORS_ALLOWED_METHOD = 'AllowedMethod';
const OSS_CORS_ALLOWED_HEADER = 'AllowedHeader';
const OSS_CORS_EXPOSE_HEADER = 'ExposeHeader';
const OSS_CORS_MAX_AGE_SECONDS = 'MaxAgeSeconds';
const OSS_MAX_RULES = 10;
/**
* orsRule列表
*
* @var CorsRule[]
*/
private $rules = array();
}

150
resources/org/OSS/Model/CorsRule.php

@ -0,0 +1,150 @@
<?php
namespace OSS\Model;
use OSS\Core\OssException;
/**
* Class CorsRule
* @package OSS\Model
* @link http://help.aliyun.com/document_detail/oss/api-reference/cors/PutBucketcors.html
*/
class CorsRule
{
/**
* Rule中增加一条allowedOrigin
*
* @param string $allowedOrigin
*/
public function addAllowedOrigin($allowedOrigin)
{
if (!empty($allowedOrigin)) {
$this->allowedOrigins[] = $allowedOrigin;
}
}
/**
* Rule中增加一条allowedMethod
*
* @param string $allowedMethod
*/
public function addAllowedMethod($allowedMethod)
{
if (!empty($allowedMethod)) {
$this->allowedMethods[] = $allowedMethod;
}
}
/**
* Rule中增加一条allowedHeader
*
* @param string $allowedHeader
*/
public function addAllowedHeader($allowedHeader)
{
if (!empty($allowedHeader)) {
$this->allowedHeaders[] = $allowedHeader;
}
}
/**
* Rule中增加一条exposeHeader
*
* @param string $exposeHeader
*/
public function addExposeHeader($exposeHeader)
{
if (!empty($exposeHeader)) {
$this->exposeHeaders[] = $exposeHeader;
}
}
/**
* @return int
*/
public function getMaxAgeSeconds()
{
return $this->maxAgeSeconds;
}
/**
* @param int $maxAgeSeconds
*/
public function setMaxAgeSeconds($maxAgeSeconds)
{
$this->maxAgeSeconds = $maxAgeSeconds;
}
/**
* 得到AllowedHeaders列表
*
* @return string[]
*/
public function getAllowedHeaders()
{
return $this->allowedHeaders;
}
/**
* 得到AllowedOrigins列表
*
* @return string[]
*/
public function getAllowedOrigins()
{
return $this->allowedOrigins;
}
/**
* 得到AllowedMethods列表
*
* @return string[]
*/
public function getAllowedMethods()
{
return $this->allowedMethods;
}
/**
* 得到ExposeHeaders列表
*
* @return string[]
*/
public function getExposeHeaders()
{
return $this->exposeHeaders;
}
/**
* 根据提供的xmlRule, 把this按照一定的规则插入到$xmlRule中
*
* @param \SimpleXMLElement $xmlRule
* @throws OssException
*/
public function appendToXml(&$xmlRule)
{
if (!isset($this->maxAgeSeconds)) {
throw new OssException("maxAgeSeconds is not set in the Rule");
}
foreach ($this->allowedOrigins as $allowedOrigin) {
$xmlRule->addChild(CorsConfig::OSS_CORS_ALLOWED_ORIGIN, $allowedOrigin);
}
foreach ($this->allowedMethods as $allowedMethod) {
$xmlRule->addChild(CorsConfig::OSS_CORS_ALLOWED_METHOD, $allowedMethod);
}
foreach ($this->allowedHeaders as $allowedHeader) {
$xmlRule->addChild(CorsConfig::OSS_CORS_ALLOWED_HEADER, $allowedHeader);
}
foreach ($this->exposeHeaders as $exposeHeader) {
$xmlRule->addChild(CorsConfig::OSS_CORS_EXPOSE_HEADER, $exposeHeader);
}
$xmlRule->addChild(CorsConfig::OSS_CORS_MAX_AGE_SECONDS, strval($this->maxAgeSeconds));
}
private $allowedHeaders = array();
private $allowedOrigins = array();
private $allowedMethods = array();
private $exposeHeaders = array();
private $maxAgeSeconds = null;
}

34
resources/org/OSS/Model/GetLiveChannelHistory.php

@ -0,0 +1,34 @@
<?php
namespace OSS\Model;
/**
* Class GetLiveChannelHistory
* @package OSS\Model
*/
class GetLiveChannelHistory implements XmlConfig
{
public function getLiveRecordList()
{
return $this->liveRecordList;
}
public function parseFromXml($strXml)
{
$xml = simplexml_load_string($strXml);
if (isset($xml->LiveRecord)) {
foreach ($xml->LiveRecord as $record) {
$liveRecord = new LiveChannelHistory();
$liveRecord->parseFromXmlNode($record);
$this->liveRecordList[] = $liveRecord;
}
}
}
public function serializeToXml()
{
throw new OssException("Not implemented.");
}
private $liveRecordList = array();
}

68
resources/org/OSS/Model/GetLiveChannelInfo.php

@ -0,0 +1,68 @@
<?php
namespace OSS\Model;
/**
* Class GetLiveChannelInfo
* @package OSS\Model
*/
class GetLiveChannelInfo implements XmlConfig
{
public function getDescription()
{
return $this->description;
}
public function getStatus()
{
return $this->status;
}
public function getType()
{
return $this->type;
}
public function getFragDuration()
{
return $this->fragDuration;
}
public function getFragCount()
{
return $this->fragCount;
}
public function getPlayListName()
{
return $this->playlistName;
}
public function parseFromXml($strXml)
{
$xml = simplexml_load_string($strXml);
$this->description = strval($xml->Description);
$this->status = strval($xml->Status);
if (isset($xml->Target)) {
foreach ($xml->Target as $target) {
$this->type = strval($target->Type);
$this->fragDuration = strval($target->FragDuration);
$this->fragCount = strval($target->FragCount);
$this->playlistName = strval($target->PlaylistName);
}
}
}
public function serializeToXml()
{
throw new OssException("Not implemented.");
}
private $description;
private $status;
private $type;
private $fragDuration;
private $fragCount;
private $playlistName;
}

107
resources/org/OSS/Model/GetLiveChannelStatus.php

@ -0,0 +1,107 @@
<?php
namespace OSS\Model;
/**
* Class GetLiveChannelStatus
* @package OSS\Model
*/
class GetLiveChannelStatus implements XmlConfig
{
public function getStatus()
{
return $this->status;
}
public function getConnectedTime()
{
return $this->connectedTime;
}
public function getRemoteAddr()
{
return $this->remoteAddr;
}
public function getVideoWidth()
{
return $this->videoWidth;
}
public function getVideoHeight()
{
return $this->videoHeight;
}
public function getVideoFrameRate()
{
return $this->videoFrameRate;
}
public function getVideoBandwidth()
{
return $this->videoBandwidth;
}
public function getVideoCodec()
{
return $this->videoCodec;
}
public function getAudioBandwidth()
{
return $this->audioBandwidth;
}
public function getAudioSampleRate()
{
return $this->audioSampleRate;
}
public function getAudioCodec()
{
return $this->audioCodec;
}
public function parseFromXml($strXml)
{
$xml = simplexml_load_string($strXml);
$this->status = strval($xml->Status);
$this->connectedTime = strval($xml->ConnectedTime);
$this->remoteAddr = strval($xml->RemoteAddr);
if (isset($xml->Video)) {
foreach ($xml->Video as $video) {
$this->videoWidth = intval($video->Width);
$this->videoHeight = intval($video->Height);
$this->videoFrameRate = intval($video->FrameRate);
$this->videoBandwidth = intval($video->Bandwidth);
$this->videoCodec = strval($video->Codec);
}
}
if (isset($xml->Video)) {
foreach ($xml->Audio as $audio) {
$this->audioBandwidth = intval($audio->Bandwidth);
$this->audioSampleRate = intval($audio->SampleRate);
$this->audioCodec = strval($audio->Codec);
}
}
}
public function serializeToXml()
{
throw new OssException("Not implemented.");
}
private $status;
private $connectedTime;
private $remoteAddr;
private $videoWidth;
private $videoHeight;
private $videoFrameRate;
private $videoBandwidth;
private $videoCodec;
private $audioBandwidth;
private $audioSampleRate;
private $audioCodec;
}

88
resources/org/OSS/Model/LifecycleAction.php

@ -0,0 +1,88 @@
<?php
namespace OSS\Model;
/**
* Class LifecycleAction
* @package OSS\Model
* @link http://help.aliyun.com/document_detail/oss/api-reference/bucket/PutBucketLifecycle.html
*/
class LifecycleAction
{
/**
* LifecycleAction constructor.
* @param string $action
* @param string $timeSpec
* @param string $timeValue
*/
public function __construct($action, $timeSpec, $timeValue)
{
$this->action = $action;
$this->timeSpec = $timeSpec;
$this->timeValue = $timeValue;
}
/**
* @return LifecycleAction
*/
public function getAction()
{
return $this->action;
}
/**
* @param string $action
*/
public function setAction($action)
{
$this->action = $action;
}
/**
* @return string
*/
public function getTimeSpec()
{
return $this->timeSpec;
}
/**
* @param string $timeSpec
*/
public function setTimeSpec($timeSpec)
{
$this->timeSpec = $timeSpec;
}
/**
* @return string
*/
public function getTimeValue()
{
return $this->timeValue;
}
/**
* @param string $timeValue
*/
public function setTimeValue($timeValue)
{
$this->timeValue = $timeValue;
}
/**
* appendToXml 把actions插入到xml中
*
* @param \SimpleXMLElement $xmlRule
*/
public function appendToXml(&$xmlRule)
{
$xmlAction = $xmlRule->addChild($this->action);
$xmlAction->addChild($this->timeSpec, $this->timeValue);
}
private $action;
private $timeSpec;
private $timeValue;
}

107
resources/org/OSS/Model/LifecycleConfig.php

@ -0,0 +1,107 @@
<?php
namespace OSS\Model;
use OSS\Core\OssException;
/**
* Class BucketLifecycleConfig
* @package OSS\Model
* @link http://help.aliyun.com/document_detail/oss/api-reference/bucket/PutBucketLifecycle.html
*/
class LifecycleConfig implements XmlConfig
{
/**
* 从xml数据中解析出LifecycleConfig
*
* @param string $strXml
* @throws OssException
* @return null
*/
public function parseFromXml($strXml)
{
$this->rules = array();
$xml = simplexml_load_string($strXml);
if (!isset($xml->Rule)) return;
$this->rules = array();
foreach ($xml->Rule as $rule) {
$id = strval($rule->ID);
$prefix = strval($rule->Prefix);
$status = strval($rule->Status);
$actions = array();
foreach ($rule as $key => $value) {
if ($key === 'ID' || $key === 'Prefix' || $key === 'Status') continue;
$action = $key;
$timeSpec = null;
$timeValue = null;
foreach ($value as $timeSpecKey => $timeValueValue) {
$timeSpec = $timeSpecKey;
$timeValue = strval($timeValueValue);
}
$actions[] = new LifecycleAction($action, $timeSpec, $timeValue);
}
$this->rules[] = new LifecycleRule($id, $prefix, $status, $actions);
}
return;
}
/**
* 生成xml字符串
*
* @return string
*/
public function serializeToXml()
{
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><LifecycleConfiguration></LifecycleConfiguration>');
foreach ($this->rules as $rule) {
$xmlRule = $xml->addChild('Rule');
$rule->appendToXml($xmlRule);
}
return $xml->asXML();
}
/**
*
* 添加LifecycleRule
*
* @param LifecycleRule $lifecycleRule
* @throws OssException
*/
public function addRule($lifecycleRule)
{
if (!isset($lifecycleRule)) {
throw new OssException("lifecycleRule is null");
}
$this->rules[] = $lifecycleRule;
}
/**
* 将配置转换成字符串,便于用户查看
*
* @return string
*/
public function __toString()
{
return $this->serializeToXml();
}
/**
* 得到所有的生命周期规则
*
* @return LifecycleRule[]
*/
public function getRules()
{
return $this->rules;
}
/**
* @var LifecycleRule[]
*/
private $rules;
}

126
resources/org/OSS/Model/LifecycleRule.php

@ -0,0 +1,126 @@
<?php
namespace OSS\Model;
/**
* Class LifecycleRule
* @package OSS\Model
*
* @link http://help.aliyun.com/document_detail/oss/api-reference/bucket/PutBucketLifecycle.html
*/
class LifecycleRule
{
/**
* 得到规则ID
*
* @return string
*/
public function getId()
{
return $this->id;
}
/**
* @param string $id 规则ID
*/
public function setId($id)
{
$this->id = $id;
}
/**
* 得到文件前缀
*
* @return string
*/
public function getPrefix()
{
return $this->prefix;
}
/**
* 设置文件前缀
*
* @param string $prefix 文件前缀
*/
public function setPrefix($prefix)
{
$this->prefix = $prefix;
}
/**
* Lifecycle规则的状态
*
* @return string
*/
public function getStatus()
{
return $this->status;
}
/**
* 设置Lifecycle规则状态
*
* @param string $status
*/
public function setStatus($status)
{
$this->status = $status;
}
/**
*
* @return LifecycleAction[]
*/
public function getActions()
{
return $this->actions;
}
/**
* @param LifecycleAction[] $actions
*/
public function setActions($actions)
{
$this->actions = $actions;
}
/**
* LifecycleRule constructor.
*
* @param string $id 规则ID
* @param string $prefix 文件前缀
* @param string $status 规则状态,可选[self::LIFECYCLE_STATUS_ENABLED, self::LIFECYCLE_STATUS_DISABLED]
* @param LifecycleAction[] $actions
*/
public function __construct($id, $prefix, $status, $actions)
{
$this->id = $id;
$this->prefix = $prefix;
$this->status = $status;
$this->actions = $actions;
}
/**
* @param \SimpleXMLElement $xmlRule
*/
public function appendToXml(&$xmlRule)
{
$xmlRule->addChild('ID', $this->id);
$xmlRule->addChild('Prefix', $this->prefix);
$xmlRule->addChild('Status', $this->status);
foreach ($this->actions as $action) {
$action->appendToXml($xmlRule);
}
}
private $id;
private $prefix;
private $status;
private $actions = array();
const LIFECYCLE_STATUS_ENABLED = 'Enabled';
const LIFECYCLE_STATUS_DISABLED = 'Disabled';
}

134
resources/org/OSS/Model/ListMultipartUploadInfo.php

@ -0,0 +1,134 @@
<?php
namespace OSS\Model;
/**
* Class ListMultipartUploadInfo
* @package OSS\Model
*
* @link http://help.aliyun.com/document_detail/oss/api-reference/multipart-upload/ListMultipartUploads.html
*/
class ListMultipartUploadInfo
{
/**
* ListMultipartUploadInfo constructor.
*
* @param string $bucket
* @param string $keyMarker
* @param string $uploadIdMarker
* @param string $nextKeyMarker
* @param string $nextUploadIdMarker
* @param string $delimiter
* @param string $prefix
* @param int $maxUploads
* @param string $isTruncated
* @param array $uploads
*/
public function __construct($bucket, $keyMarker, $uploadIdMarker, $nextKeyMarker, $nextUploadIdMarker, $delimiter, $prefix, $maxUploads, $isTruncated, array $uploads)
{
$this->bucket = $bucket;
$this->keyMarker = $keyMarker;
$this->uploadIdMarker = $uploadIdMarker;
$this->nextKeyMarker = $nextKeyMarker;
$this->nextUploadIdMarker = $nextUploadIdMarker;
$this->delimiter = $delimiter;
$this->prefix = $prefix;
$this->maxUploads = $maxUploads;
$this->isTruncated = $isTruncated;
$this->uploads = $uploads;
}
/**
* 得到bucket名称
*
* @return string
*/
public function getBucket()
{
return $this->bucket;
}
/**
* @return string
*/
public function getKeyMarker()
{
return $this->keyMarker;
}
/**
*
* @return string
*/
public function getUploadIdMarker()
{
return $this->uploadIdMarker;
}
/**
* @return string
*/
public function getNextKeyMarker()
{
return $this->nextKeyMarker;
}
/**
* @return string
*/
public function getNextUploadIdMarker()
{
return $this->nextUploadIdMarker;
}
/**
* @return string
*/
public function getDelimiter()
{
return $this->delimiter;
}
/**
* @return string
*/
public function getPrefix()
{
return $this->prefix;
}
/**
* @return int
*/
public function getMaxUploads()
{
return $this->maxUploads;
}
/**
* @return string
*/
public function getIsTruncated()
{
return $this->isTruncated;
}
/**
* @return UploadInfo[]
*/
public function getUploads()
{
return $this->uploads;
}
private $bucket = "";
private $keyMarker = "";
private $uploadIdMarker = "";
private $nextKeyMarker = "";
private $nextUploadIdMarker = "";
private $delimiter = "";
private $prefix = "";
private $maxUploads = 0;
private $isTruncated = "false";
private $uploads = array();
}

97
resources/org/OSS/Model/ListPartsInfo.php

@ -0,0 +1,97 @@
<?php
namespace OSS\Model;
/**
* Class ListPartsInfo
* @package OSS\Model
* @link http://help.aliyun.com/document_detail/oss/api-reference/multipart-upload/ListParts.html
*/
class ListPartsInfo
{
/**
* ListPartsInfo constructor.
* @param string $bucket
* @param string $key
* @param string $uploadId
* @param int $nextPartNumberMarker
* @param int $maxParts
* @param string $isTruncated
* @param array $listPart
*/
public function __construct($bucket, $key, $uploadId, $nextPartNumberMarker, $maxParts, $isTruncated, array $listPart)
{
$this->bucket = $bucket;
$this->key = $key;
$this->uploadId = $uploadId;
$this->nextPartNumberMarker = $nextPartNumberMarker;
$this->maxParts = $maxParts;
$this->isTruncated = $isTruncated;
$this->listPart = $listPart;
}
/**
* @return string
*/
public function getBucket()
{
return $this->bucket;
}
/**
* @return string
*/
public function getKey()
{
return $this->key;
}
/**
* @return string
*/
public function getUploadId()
{
return $this->uploadId;
}
/**
* @return int
*/
public function getNextPartNumberMarker()
{
return $this->nextPartNumberMarker;
}
/**
* @return int
*/
public function getMaxParts()
{
return $this->maxParts;
}
/**
* @return string
*/
public function getIsTruncated()
{
return $this->isTruncated;
}
/**
* @return array
*/
public function getListPart()
{
return $this->listPart;
}
private $bucket = "";
private $key = "";
private $uploadId = "";
private $nextPartNumberMarker = 0;
private $maxParts = 0;
private $isTruncated = "";
private $listPart = array();
}

121
resources/org/OSS/Model/LiveChannelConfig.php

@ -0,0 +1,121 @@
<?php
namespace OSS\Model;
/**
* Class LiveChannelConfig
* @package OSS\Model
*/
class LiveChannelConfig implements XmlConfig
{
public function __construct($option = array())
{
if (isset($option['description'])) {
$this->description = $option['description'];
}
if (isset($option['status'])) {
$this->status = $option['status'];
}
if (isset($option['type'])) {
$this->type = $option['type'];
}
if (isset($option['fragDuration'])) {
$this->fragDuration = $option['fragDuration'];
}
if (isset($option['fragCount'])) {
$this->fragCount = $option['fragCount'];
}
if (isset($option['playListName'])) {
$this->playListName = $option['playListName'];
}
}
public function getDescription()
{
return $this->description;
}
public function getStatus()
{
return $this->status;
}
public function getType()
{
return $this->type;
}
public function getFragDuration()
{
return $this->fragDuration;
}
public function getFragCount()
{
return $this->fragCount;
}
public function getPlayListName()
{
return $this->playListName;
}
public function parseFromXml($strXml)
{
$xml = simplexml_load_string($strXml);
$this->description = strval($xml->Description);
$this->status = strval($xml->Status);
$target = $xml->Target;
$this->type = strval($target->Type);
$this->fragDuration = intval($target->FragDuration);
$this->fragCount = intval($target->FragCount);
$this->playListName = strval($target->PlayListName);
}
public function serializeToXml()
{
$strXml = <<<EOF
<?xml version="1.0" encoding="utf-8"?>
<LiveChannelConfiguration>
</LiveChannelConfiguration>
EOF;
$xml = new \SimpleXMLElement($strXml);
if (isset($this->description)) {
$xml->addChild('Description', $this->description);
}
if (isset($this->status)) {
$xml->addChild('Status', $this->status);
}
$node = $xml->addChild('Target');
$node->addChild('Type', $this->type);
if (isset($this->fragDuration)) {
$node->addChild('FragDuration', $this->fragDuration);
}
if (isset($this->fragCount)) {
$node->addChild('FragCount', $this->fragCount);
}
if (isset($this->playListName)) {
$node->addChild('PlayListName', $this->playListName);
}
return $xml->asXML();
}
public function __toString()
{
return $this->serializeToXml();
}
private $description;
private $status = "enabled";
private $type;
private $fragDuration = 5;
private $fragCount = 3;
private $playListName = "playlist.m3u8";
}

59
resources/org/OSS/Model/LiveChannelHistory.php

@ -0,0 +1,59 @@
<?php
namespace OSS\Model;
/**
* Class LiveChannelHistory
* @package OSS\Model
*
*/
class LiveChannelHistory implements XmlConfig
{
public function __construct()
{
}
public function getStartTime()
{
return $this->startTime;
}
public function getEndTime()
{
return $this->endTime;
}
public function getRemoteAddr()
{
return $this->remoteAddr;
}
public function parseFromXmlNode($xml)
{
if (isset($xml->StartTime)) {
$this->startTime = strval($xml->StartTime);
}
if (isset($xml->EndTime)) {
$this->endTime = strval($xml->EndTime);
}
if (isset($xml->RemoteAddr)) {
$this->remoteAddr = strval($xml->RemoteAddr);
}
}
public function parseFromXml($strXml)
{
$xml = simplexml_load_string($strXml);
$this->parseFromXmlNode($xml);
}
public function serializeToXml()
{
throw new OssException("Not implemented.");
}
private $startTime;
private $endTime;
private $remoteAddr;
}

107
resources/org/OSS/Model/LiveChannelInfo.php

@ -0,0 +1,107 @@
<?php
namespace OSS\Model;
/**
* Class LiveChannelInfo
* @package OSS\Model
*
*/
class LiveChannelInfo implements XmlConfig
{
public function __construct($name = null, $description = null)
{
$this->name = $name;
$this->description = $description;
$this->publishUrls = array();
$this->playUrls = array();
}
public function getName()
{
return $this->name;
}
public function setName($name)
{
$this->name = $name;
}
public function getPublishUrls()
{
return $this->publishUrls;
}
public function getPlayUrls()
{
return $this->playUrls;
}
public function getStatus()
{
return $this->status;
}
public function getLastModified()
{
return $this->lastModified;
}
public function getDescription()
{
return $this->description;
}
public function setDescription($description)
{
$this->description = $description;
}
public function parseFromXmlNode($xml)
{
if (isset($xml->Name)) {
$this->name = strval($xml->Name);
}
if (isset($xml->Description)) {
$this->description = strval($xml->Description);
}
if (isset($xml->Status)) {
$this->status = strval($xml->Status);
}
if (isset($xml->LastModified)) {
$this->lastModified = strval($xml->LastModified);
}
if (isset($xml->PublishUrls)) {
foreach ($xml->PublishUrls as $url) {
$this->publishUrls[] = strval($url->Url);
}
}
if (isset($xml->PlayUrls)) {
foreach ($xml->PlayUrls as $url) {
$this->playUrls[] = strval($url->Url);
}
}
}
public function parseFromXml($strXml)
{
$xml = simplexml_load_string($strXml);
$this->parseFromXmlNode($xml);
}
public function serializeToXml()
{
throw new OssException("Not implemented.");
}
private $name;
private $description;
private $publishUrls;
private $playUrls;
private $status;
private $lastModified;
}

107
resources/org/OSS/Model/LiveChannelListInfo.php

@ -0,0 +1,107 @@
<?php
namespace OSS\Model;
/**
* Class LiveChannelListInfo
*
* ListBucketLiveChannels接口返回数据
*
* @package OSS\Model
* @link http://help.aliyun.com/document_detail/oss/api-reference/bucket/GetBucket.html
*/
class LiveChannelListInfo implements XmlConfig
{
/**
* @return string
*/
public function getBucketName()
{
return $this->bucket;
}
public function setBucketName($name)
{
$this->bucket = $name;
}
/**
* @return string
*/
public function getPrefix()
{
return $this->prefix;
}
/**
* @return string
*/
public function getMarker()
{
return $this->marker;
}
/**
* @return int
*/
public function getMaxKeys()
{
return $this->maxKeys;
}
/**
* @return mixed
*/
public function getIsTruncated()
{
return $this->isTruncated;
}
/**
* @return LiveChannelInfo[]
*/
public function getChannelList()
{
return $this->channelList;
}
/**
* @return string
*/
public function getNextMarker()
{
return $this->nextMarker;
}
public function parseFromXml($strXml)
{
$xml = simplexml_load_string($strXml);
$this->prefix = strval($xml->Prefix);
$this->marker = strval($xml->Marker);
$this->maxKeys = intval($xml->MaxKeys);
$this->isTruncated = (strval($xml->IsTruncated) == 'true');
$this->nextMarker = strval($xml->NextMarker);
if (isset($xml->LiveChannel)) {
foreach ($xml->LiveChannel as $chan) {
$channel = new LiveChannelInfo();
$channel->parseFromXmlNode($chan);
$this->channelList[] = $channel;
}
}
}
public function serializeToXml()
{
throw new OssException("Not implemented.");
}
private $bucket = '';
private $prefix = '';
private $marker = '';
private $nextMarker = '';
private $maxKeys = 100;
private $isTruncated = 'false';
private $channelList = array();
}

86
resources/org/OSS/Model/LoggingConfig.php

@ -0,0 +1,86 @@
<?php
namespace OSS\Model;
/**
* Class LoggingConfig
* @package OSS\Model
* @link http://help.aliyun.com/document_detail/oss/api-reference/bucket/PutBucketLogging.html
*/
class LoggingConfig implements XmlConfig
{
/**
* LoggingConfig constructor.
* @param null $targetBucket
* @param null $targetPrefix
*/
public function __construct($targetBucket = null, $targetPrefix = null)
{
$this->targetBucket = $targetBucket;
$this->targetPrefix = $targetPrefix;
}
/**
* @param $strXml
* @return null
*/
public function parseFromXml($strXml)
{
$xml = simplexml_load_string($strXml);
if (!isset($xml->LoggingEnabled)) return;
foreach ($xml->LoggingEnabled as $status) {
foreach ($status as $key => $value) {
if ($key === 'TargetBucket') {
$this->targetBucket = strval($value);
} elseif ($key === 'TargetPrefix') {
$this->targetPrefix = strval($value);
}
}
break;
}
}
/**
* 序列化成xml字符串
*
*/
public function serializeToXml()
{
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><BucketLoggingStatus></BucketLoggingStatus>');
if (isset($this->targetBucket) && isset($this->targetPrefix)) {
$loggingEnabled = $xml->addChild('LoggingEnabled');
$loggingEnabled->addChild('TargetBucket', $this->targetBucket);
$loggingEnabled->addChild('TargetPrefix', $this->targetPrefix);
}
return $xml->asXML();
}
/**
* @return string
*/
public function __toString()
{
return $this->serializeToXml();
}
/**
* @return string
*/
public function getTargetBucket()
{
return $this->targetBucket;
}
/**
* @return string
*/
public function getTargetPrefix()
{
return $this->targetPrefix;
}
private $targetBucket = "";
private $targetPrefix = "";
}

93
resources/org/OSS/Model/ObjectInfo.php

@ -0,0 +1,93 @@
<?php
namespace OSS\Model;
/**
*
* Class ObjectInfo
*
* listObjects接口中返回的Object列表中的类
*
* listObjects接口返回数据中包含两个Array
* 一个是拿到的Object列表【可以理解成对应文件系统中的文件列表】
* 一个是拿到的Prefix列表【可以理解成对应文件系统中的目录列表】
*
* @package OSS\Model
*/
class ObjectInfo
{
/**
* ObjectInfo constructor.
*
* @param string $key
* @param string $lastModified
* @param string $eTag
* @param string $type
* @param int $size
* @param string $storageClass
*/
public function __construct($key, $lastModified, $eTag, $type, $size, $storageClass)
{
$this->key = $key;
$this->lastModified = $lastModified;
$this->eTag = $eTag;
$this->type = $type;
$this->size = $size;
$this->storageClass = $storageClass;
}
/**
* @return string
*/
public function getKey()
{
return $this->key;
}
/**
* @return string
*/
public function getLastModified()
{
return $this->lastModified;
}
/**
* @return string
*/
public function getETag()
{
return $this->eTag;
}
/**
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* @return int
*/
public function getSize()
{
return $this->size;
}
/**
* @return string
*/
public function getStorageClass()
{
return $this->storageClass;
}
private $key = "";
private $lastModified = "";
private $eTag = "";
private $type = "";
private $size = 0;
private $storageClass = "";
}

126
resources/org/OSS/Model/ObjectListInfo.php

@ -0,0 +1,126 @@
<?php
namespace OSS\Model;
/**
* Class ObjectListInfo
*
* ListObjects接口返回数据
*
* @package OSS\Model
* @link http://help.aliyun.com/document_detail/oss/api-reference/bucket/GetBucket.html
*/
class ObjectListInfo
{
/**
* ObjectListInfo constructor.
*
* @param string $bucketName
* @param string $prefix
* @param string $marker
* @param string $nextMarker
* @param string $maxKeys
* @param string $delimiter
* @param null $isTruncated
* @param array $objectList
* @param array $prefixList
*/
public function __construct($bucketName, $prefix, $marker, $nextMarker, $maxKeys, $delimiter, $isTruncated, array $objectList, array $prefixList)
{
$this->bucketName = $bucketName;
$this->prefix = $prefix;
$this->marker = $marker;
$this->nextMarker = $nextMarker;
$this->maxKeys = $maxKeys;
$this->delimiter = $delimiter;
$this->isTruncated = $isTruncated;
$this->objectList = $objectList;
$this->prefixList = $prefixList;
}
/**
* @return string
*/
public function getBucketName()
{
return $this->bucketName;
}
/**
* @return string
*/
public function getPrefix()
{
return $this->prefix;
}
/**
* @return string
*/
public function getMarker()
{
return $this->marker;
}
/**
* @return int
*/
public function getMaxKeys()
{
return $this->maxKeys;
}
/**
* @return string
*/
public function getDelimiter()
{
return $this->delimiter;
}
/**
* @return mixed
*/
public function getIsTruncated()
{
return $this->isTruncated;
}
/**
* 返回ListObjects接口返回数据中的ObjectInfo列表
*
* @return ObjectInfo[]
*/
public function getObjectList()
{
return $this->objectList;
}
/**
* 返回ListObjects接口返回数据中的PrefixInfo列表
*
* @return PrefixInfo[]
*/
public function getPrefixList()
{
return $this->prefixList;
}
/**
* @return string
*/
public function getNextMarker()
{
return $this->nextMarker;
}
private $bucketName = "";
private $prefix = "";
private $marker = "";
private $nextMarker = "";
private $maxKeys = 0;
private $delimiter = "";
private $isTruncated = null;
private $objectList = array();
private $prefixList = array();
}

63
resources/org/OSS/Model/PartInfo.php

@ -0,0 +1,63 @@
<?php
namespace OSS\Model;
/**
* Class PartInfo
* @package OSS\Model
*/
class PartInfo
{
/**
* PartInfo constructor.
*
* @param int $partNumber
* @param string $lastModified
* @param string $eTag
* @param int $size
*/
public function __construct($partNumber, $lastModified, $eTag, $size)
{
$this->partNumber = $partNumber;
$this->lastModified = $lastModified;
$this->eTag = $eTag;
$this->size = $size;
}
/**
* @return int
*/
public function getPartNumber()
{
return $this->partNumber;
}
/**
* @return string
*/
public function getLastModified()
{
return $this->lastModified;
}
/**
* @return string
*/
public function getETag()
{
return $this->eTag;
}
/**
* @return int
*/
public function getSize()
{
return $this->size;
}
private $partNumber = 0;
private $lastModified = "";
private $eTag = "";
private $size = 0;
}

36
resources/org/OSS/Model/PrefixInfo.php

@ -0,0 +1,36 @@
<?php
namespace OSS\Model;
/**
* Class PrefixInfo
*
* listObjects接口中返回的Prefix列表中的类
* listObjects接口返回数据中包含两个Array:
* 一个是拿到的Object列表【可以理解成对应文件系统中的文件列表】
* 一个是拿到的Prefix列表【可以理解成对应文件系统中的目录列表】
*
* @package OSS\Model
* @link http://help.aliyun.com/document_detail/oss/api-reference/bucket/GetBucket.html
*/
class PrefixInfo
{
/**
* PrefixInfo constructor.
* @param string $prefix
*/
public function __construct($prefix)
{
$this->prefix = $prefix;
}
/**
* @return string
*/
public function getPrefix()
{
return $this->prefix;
}
private $prefix;
}

93
resources/org/OSS/Model/RefererConfig.php

@ -0,0 +1,93 @@
<?php
namespace OSS\Model;
/**
* Class RefererConfig
*
* @package OSS\Model
* @link http://help.aliyun.com/document_detail/oss/api-reference/bucket/PutBucketReferer.html
*/
class RefererConfig implements XmlConfig
{
/**
* @param string $strXml
* @return null
*/
public function parseFromXml($strXml)
{
$xml = simplexml_load_string($strXml);
if (!isset($xml->AllowEmptyReferer)) return;
if (!isset($xml->RefererList)) return;
$this->allowEmptyReferer =
(strval($xml->AllowEmptyReferer) === 'TRUE' || strval($xml->AllowEmptyReferer) === 'true') ? true : false;
foreach ($xml->RefererList->Referer as $key => $refer) {
$this->refererList[] = strval($refer);
}
}
/**
* 把RefererConfig序列化成xml
*
* @return string
*/
public function serializeToXml()
{
$xml = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8"?><RefererConfiguration></RefererConfiguration>');
if ($this->allowEmptyReferer) {
$xml->addChild('AllowEmptyReferer', 'true');
} else {
$xml->addChild('AllowEmptyReferer', 'false');
}
$refererList = $xml->addChild('RefererList');
foreach ($this->refererList as $referer) {
$refererList->addChild('Referer', $referer);
}
return $xml->asXML();
}
/**
* @return string
*/
function __toString()
{
return $this->serializeToXml();
}
/**
* @param boolean $allowEmptyReferer
*/
public function setAllowEmptyReferer($allowEmptyReferer)
{
$this->allowEmptyReferer = $allowEmptyReferer;
}
/**
* @param string $referer
*/
public function addReferer($referer)
{
$this->refererList[] = $referer;
}
/**
* @return boolean
*/
public function isAllowEmptyReferer()
{
return $this->allowEmptyReferer;
}
/**
* @return array
*/
public function getRefererList()
{
return $this->refererList;
}
private $allowEmptyReferer = true;
private $refererList = array();
}

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save