Skip to content
Permalink
Browse files

上传ebpai模块

  • Loading branch information...
LiaoFeiweiaini committed May 16, 2019
1 parent 6d453ed commit e41e19571f3261154d9680a7324f9beba0d7ee3d
Showing with 6,580 additions and 0 deletions.
  1. +41 −0 application/ebapi/common.php
  2. +38 −0 application/ebapi/config.php
  3. +38 −0 application/ebapi/controller/ApiException.php
  4. +73 −0 application/ebapi/controller/ArticleApi.php
  5. +397 −0 application/ebapi/controller/AuthApi.php
  6. +18 −0 application/ebapi/controller/AuthController.php
  7. +170 −0 application/ebapi/controller/Basic.php
  8. +96 −0 application/ebapi/controller/CouponsApi.php
  9. +97 −0 application/ebapi/controller/Login.php
  10. +23 −0 application/ebapi/controller/Notify.php
  11. +313 −0 application/ebapi/controller/PublicApi.php
  12. +99 −0 application/ebapi/controller/SeckillApi.php
  13. +373 −0 application/ebapi/controller/StoreApi.php
  14. +810 −0 application/ebapi/controller/UserApi.php
  15. +88 −0 application/ebapi/model/article/Article.php
  16. +39 −0 application/ebapi/model/article/ArticleCategory.php
  17. +255 −0 application/ebapi/model/store/StoreCart.php
  18. +65 −0 application/ebapi/model/store/StoreCategory.php
  19. +17 −0 application/ebapi/model/store/StoreCoupon.php
  20. +78 −0 application/ebapi/model/store/StoreCouponIssue.php
  21. +22 −0 application/ebapi/model/store/StoreCouponIssueUser.php
  22. +152 −0 application/ebapi/model/store/StoreCouponUser.php
  23. +944 −0 application/ebapi/model/store/StoreOrder.php
  24. +48 −0 application/ebapi/model/store/StoreOrderCartInfo.php
  25. +28 −0 application/ebapi/model/store/StoreOrderStatus.php
  26. +569 −0 application/ebapi/model/store/StorePink.php
  27. +325 −0 application/ebapi/model/store/StoreProduct.php
  28. +75 −0 application/ebapi/model/store/StoreProductAttr.php
  29. +142 −0 application/ebapi/model/store/StoreProductRelation.php
  30. +133 −0 application/ebapi/model/store/StoreProductReply.php
  31. +147 −0 application/ebapi/model/store/StoreSeckill.php
  32. +17 −0 application/ebapi/model/store/StoreService.php
  33. +17 −0 application/ebapi/model/store/StoreServiceLog.php
  34. +294 −0 application/ebapi/model/user/User.php
  35. +55 −0 application/ebapi/model/user/UserAddress.php
  36. +150 −0 application/ebapi/model/user/UserExtract.php
  37. +57 −0 application/ebapi/model/user/UserNotice.php
  38. +65 −0 application/ebapi/model/user/UserRecharge.php
  39. +56 −0 application/ebapi/model/user/UserSign.php
  40. +127 −0 application/ebapi/model/user/WechatUser.php
  41. +29 −0 application/ebapi/tags.php
@@ -0,0 +1,41 @@
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------
/**
* 设置浏览信息
* @param $uid
* @param int $product_id
* @param int $cate
* @param string $type
* @param string $content
* @param int $min
*/
function setView($uid,$product_id=0,$cate=0,$type='',$content='',$min=20){
$Db=think\Db::name('store_visit');
$view=$Db->where(['uid'=>$uid,'product_id'=>$product_id])->field('count,add_time,id')->find();
if($view && $type!='search'){
$time=time();
if(($view['add_time']+$min)<$time){
$Db->where(['id'=>$view['id']])->update(['count'=>$view['count']+1,'add_time'=>time()]);
}
}else{
$cate = explode(',',$cate)[0];
$Db->insert([
'add_time'=>time(),
'count'=>1,
'product_id'=>$product_id,
'cate_id'=>$cate,
'type'=>$type,
'uid'=>$uid,
'content'=>$content
]);
}
}
@@ -0,0 +1,38 @@
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
return [
'session' => [
// SESSION 前缀
'prefix' => 'ebapi',
// 驱动方式 支持redis memcache memcached
'type' => '',
// 是否自动开启 SESSION
'auto_start' => true,
],
'exception_handle' => \app\ebapi\controller\ApiException::class,
// +----------------------------------------------------------------------
// | 缓存设置
// +----------------------------------------------------------------------
'cache' => [
// 驱动方式
'type' => 'File',
// 缓存保存目录
'path' => CACHE_PATH,
// 缓存前缀
'prefix' => 'ebapi',
// 缓存有效期 0表示永久缓存
'expire' => 1400,
],
];
@@ -0,0 +1,38 @@
<?php
namespace app\ebapi\controller;
use app\core\util\ApiLogs;
use Exception;
use service\JsonService;
use think\exception\Handle;
use think\exception\ValidateException;
use think\exception\PDOException;
use think\exception\ErrorException;
use think\exception\HttpException;
use think\exception\DbException;
use app\core\lib\BaseException;
class ApiException extends Handle
{
public function render(Exception $e){
//记录错误日志
if ($e instanceof \think\Exception) ApiLogs::recodeErrorLog($e);
//可以在此交由系统处理
if(\think\Config::get('app_debug')) return Handle::render($e);
//参数验证错误
if ($e instanceof ValidateException) return JsonService::fail($e->getError(),[], $e->getCode());
//数据库错误
if($e instanceof PDOException) return JsonService::fail($e->getMessage(),[],$e->getCode());
//Db错误
if($e instanceof DbException) return JsonService::fail($e->getMessage(),[],$e->getCode());
//HTTP相应错误
if($e instanceof HttpException) return JsonService::fail($e->getMessage(),[],$e->getCode());
//其他错误异常
if($e instanceof ErrorException) return JsonService::fail($e->getMessage(),[],$e->getCode());
//默认错误提示
$baseExcep=new BaseException();
return JsonService::fail($baseExcep->msg,[],$baseExcep->code);
}
}
@@ -0,0 +1,73 @@
<?php
namespace app\ebapi\controller;
use app\ebapi\model\article\Article AS ArticleModel;
use app\ebapi\model\article\ArticleCategory;
/**
* TODO 小程序文章api接口
* Class ArticleApi
* @package app\ebapi\controller
*/
class ArticleApi extends Basic
{
/**
* TODO 获取文章分类
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function get_article_cate(){
$cateInfo = ArticleCategory::getArticleCategory();
if($cateInfo) $cateInfo = $cateInfo->toArray();
else $cateInfo = [];
array_unshift($cateInfo,['id'=>0,'title'=>'热门']);
return $this->successful($cateInfo);
}
/**
* TODO 文章列表
* @param int $cid
* @param int $first
* @param int $limit
*/
public function get_cid_article($cid = 0,$first = 0,$limit = 8){
$list = ArticleModel::cidByArticleList($cid,$first,$limit,"id,title,image_input,visit,from_unixtime(add_time,'%Y-%m-%d %H:%i') as add_time,synopsis,url")?:[];
return $this->successful($list);
}
/**
* TODO 获取热门文章
* @return json
*/
public function get_article_hot()
{
return $this->successful(ArticleModel::getArticleListHot("id,title,image_input,visit,from_unixtime(add_time,'%Y-%m-%d %H:%i') as add_time,synopsis,url"));
}
/**
* TODO 获取热门banner文章
* @return json
*/
public function get_article_banner()
{
return $this->successful(ArticleModel::getArticleListBanner("id,title,image_input,visit,from_unixtime(add_time,'%Y-%m-%d %H:%i') as add_time,synopsis,url"));
}
/**
* TODO 获取文章详情
* @param int $id
* @return json
*/
public function visit($id = 0)
{
$content = ArticleModel::getArticleOne($id);
if(!$content || !$content["status"]) return $this->fail('此文章已经不存在!');
$content["visit"] = $content["visit"] + 1;
$content["cart_name"] = ArticleCategory::getArticleCategoryField($content['cid']);
$content['add_time'] = date('Y-m-d H:i:s',$content['add_time']);
ArticleModel::edit(['visit'=>$content["visit"]],$id);//增加浏览次数
return $this->successful($content);
}
}

0 comments on commit e41e195

Please sign in to comment.
You can’t perform that action at this time.