Browse Source

cart

master
ZLW-PC\Administrator 6 years ago
parent
commit
7b482d9386
  1. 20
      app/Common/function.php
  2. 37
      app/Http/Controllers/Api/ArctypeController.php
  3. 33
      app/Http/Controllers/Api/ArticleController.php
  4. 155
      app/Http/Controllers/Api/BonusController.php
  5. 118
      app/Http/Controllers/Api/CartController.php
  6. 92
      app/Http/Controllers/Api/FeedBackController.php
  7. 89
      app/Http/Controllers/Api/GoodsBrandController.php
  8. 179
      app/Http/Controllers/Api/GoodsController.php
  9. 97
      app/Http/Controllers/Api/GoodsSearchwordController.php
  10. 78
      app/Http/Controllers/Api/GoodsTypeController.php
  11. 2
      app/Http/Controllers/Api/IndexController.php
  12. 98
      app/Http/Controllers/Api/PageController.php
  13. 90
      app/Http/Controllers/Api/PaymentController.php
  14. 92
      app/Http/Controllers/Api/RegionController.php
  15. 38
      app/Http/Controllers/Api/SlideController.php
  16. 1
      app/Http/Controllers/Api/VerifyCodeController.php
  17. 2
      app/Http/Logic/ArctypeLogic.php
  18. 8
      app/Http/Logic/ArticleLogic.php
  19. 13
      app/Http/Logic/BonusLogic.php
  20. 135
      app/Http/Logic/CartLogic.php
  21. 27
      app/Http/Logic/GoodsLogic.php
  22. 13
      app/Http/Model/Arctype.php
  23. 10
      app/Http/Model/Article.php
  24. 15
      app/Http/Model/BaseModel.php
  25. 19
      app/Http/Model/Bonus.php
  26. 84
      app/Http/Model/Cart.php
  27. 18
      app/Http/Model/CollectGoods.php
  28. 33
      app/Http/Model/Comment.php
  29. 18
      app/Http/Model/FeedBack.php
  30. 13
      app/Http/Model/Friendlink.php
  31. 242
      app/Http/Model/Goods.php
  32. 11
      app/Http/Model/GoodsBrand.php
  33. 14
      app/Http/Model/GoodsImg.php
  34. 19
      app/Http/Model/GoodsSearchword.php
  35. 18
      app/Http/Model/GoodsType.php
  36. 13
      app/Http/Model/Guestbook.php
  37. 13
      app/Http/Model/Keyword.php
  38. 13
      app/Http/Model/Kuaidi.php
  39. 13
      app/Http/Model/Menu.php
  40. 13
      app/Http/Model/Order.php
  41. 13
      app/Http/Model/OrderGoods.php
  42. 13
      app/Http/Model/Page.php
  43. 75
      app/Http/Model/Payment.php
  44. 36
      app/Http/Model/Region.php
  45. 13
      app/Http/Model/Searchword.php
  46. 37
      app/Http/Model/Slide.php
  47. 16
      app/Http/Model/SmsLog.php
  48. 17
      app/Http/Model/Sysconfig.php
  49. 13
      app/Http/Model/Tagindex.php
  50. 13
      app/Http/Model/Taglist.php
  51. 10
      app/Http/Model/User.php
  52. 9
      app/Http/Model/UserAddress.php
  53. 13
      app/Http/Model/UserBonus.php
  54. 13
      app/Http/Model/UserGoodsHistory.php
  55. 13
      app/Http/Model/UserMessage.php
  56. 13
      app/Http/Model/UserMoney.php
  57. 13
      app/Http/Model/UserPoint.php
  58. 13
      app/Http/Model/UserRecharge.php
  59. 13
      app/Http/Model/UserRole.php
  60. 13
      app/Http/Model/UserWithdraw.php
  61. 12
      app/Http/Model/VerifyCode.php
  62. 11
      app/Http/Model/WeixinMenu.php
  63. 2
      app/Http/Requests/AdminRequest.php
  64. 4
      app/Http/Requests/AdminRoleRequest.php
  65. 5
      app/Http/Requests/ArctypeRequest.php
  66. 2
      app/Http/Requests/ArticleRequest.php
  67. 9
      app/Http/Requests/BonusRequest.php
  68. 10
      app/Http/Requests/CartRequest.php
  69. 2
      app/Http/Requests/CollectGoodsRequest.php
  70. 8
      app/Http/Requests/CommentRequest.php
  71. 5
      app/Http/Requests/FeedbackRequest.php
  72. 4
      app/Http/Requests/FriendlinkRequest.php
  73. 4
      app/Http/Requests/GoodsBrandRequest.php
  74. 2
      app/Http/Requests/GoodsImgRequest.php
  75. 14
      app/Http/Requests/GoodsRequest.php
  76. 4
      app/Http/Requests/GoodsSearchwordRequest.php
  77. 2
      app/Http/Requests/GoodsTypeRequest.php
  78. 2
      app/Http/Requests/GuestbookRequest.php
  79. 2
      app/Http/Requests/KuaidiRequest.php
  80. 4
      app/Http/Requests/MenuRequest.php
  81. 14
      app/Http/Requests/OrderRequest.php
  82. 2
      app/Http/Requests/PageRequest.php
  83. 4
      app/Http/Requests/PaymentRequest.php
  84. 6
      app/Http/Requests/RegionRequest.php
  85. 2
      app/Http/Requests/SysconfigRequest.php
  86. 2
      app/Http/Requests/TokenRequest.php
  87. 4
      app/Http/Requests/VerifyCodeRequest.php
  88. 5
      routes/web.php

20
app/Common/function.php

@ -1204,8 +1204,10 @@ function service($name = '', $config = [])
$service = new $class($config);
$instance[$guid] = $service;
}
throw new Exception('class not exists:' . $class);
else
{
throw new Exception('class not exists:' . $class);
}
}
return $instance[$guid];
@ -1230,8 +1232,10 @@ function logic($name = '', $config = [])
$logic = new $class($config);
$instance[$guid] = $logic;
}
throw new Exception('class not exists:' . $class);
else
{
throw new Exception('class not exists:' . $class);
}
}
return $instance[$guid];
@ -1249,14 +1253,16 @@ function model($name = '', $config = [])
$guid = $name . 'Model';
if (!isset($instance[$guid]))
{
$class = 'App\\Http\\Model\\' . ucfirst($name);
$class = '\\App\\Http\\Model\\' . ucfirst($name);
if (class_exists($class))
{
$model = new $class($config);
$instance[$guid] = $model;
}
throw new Exception('class not exists:' . $class);
else
{
throw new Exception('class not exists:' . $class);
}
}
return $instance[$guid];

37
app/Http/Controllers/Api/ArctypeController.php

@ -1,10 +1,11 @@
<?php
namespace App\Http\Controllers\Api;
use Illuminate\Http\Request;
use Log;
use DB;
use Illuminate\Http\Request;
use App\Common\ReturnData;
use App\Common\Helper;
use App\Common\Token;
use App\Http\Model\Arctype;
use App\Http\Logic\ArctypeLogic;
@ -17,7 +18,7 @@ class ArctypeController extends CommonController
public function getLogic()
{
return new ArctypeLogic();
return logic('Arctype');
}
public function arctypeList(Request $request)
@ -29,35 +30,34 @@ class ArctypeController extends CommonController
$where['is_show'] = Arctype::IS_SHOW;
$res = $this->getLogic()->getList($where, array('listorder', 'asc'), '*', $offset, $limit);
if($res === false)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL);
}
foreach($res['list'] as $k=>$v)
if($res['count']>0)
{
$res['list'][$k]->addtime = date('Y-m-d H:i',$v->addtime);
$res['list'][$k]->category_list_url = route('weixin_article_category',array('id'=>$v->id));
foreach($res['list'] as $k=>$v)
{
$res['list'][$k]->addtime = date('Y-m-d H:i',$v->addtime);
$res['list'][$k]->category_list_url = route('weixin_article_category',array('id'=>$v->id));
}
}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::SUCCESS, $res);
}
public function arctypeDetail(Request $request)
{
//参数
$where['id'] = $request->input('id',null);
if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$id = $request->input('id');
$where['id'] = $id;
$where['is_show'] = Arctype::IS_SHOW;
if($where['id'] == null){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$res = $this->getLogic()->getOne($where);
if($res === false)
if(!$res)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL);
return ReturnData::create(ReturnData::RECORD_NOT_EXIST);
}
$res->addtime = date('Y-m-d H:i',$res->addtime);
return ReturnData::create(ReturnData::SUCCESS,$res);
}
@ -93,7 +93,6 @@ class ArctypeController extends CommonController
if(Helper::isPostRequest())
{
unset($_POST['id']);
$where['id'] = $id;
return $this->getLogic()->del($where);

33
app/Http/Controllers/Api/ArticleController.php

@ -1,11 +1,11 @@
<?php
namespace App\Http\Controllers\Api;
use Illuminate\Http\Request;
use Log;
use DB;
use Illuminate\Http\Request;
use App\Common\ReturnData;
use App\Common\Helper;
use App\Common\Token;
use App\Http\Model\Article;
use App\Http\Logic\ArticleLogic;
@ -15,12 +15,12 @@ class ArticleController extends CommonController
{
parent::__construct();
}
public function getLogic()
{
return new ArticleLogic();
return logic('Article');
}
public function articleList(Request $request)
{
//参数
@ -30,14 +30,13 @@ class ArticleController extends CommonController
$where['ischeck'] = Article::IS_CHECK;
$res = $this->getLogic()->getList($where, array('id', 'desc'), '*', $offset, $limit);
if($res === false)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL);
}
foreach($res['list'] as $k=>$v)
if($res['count']>0)
{
$res['list'][$k]->article_detail_url = route('weixin_article_detail',array('id'=>$v->id));
foreach($res['list'] as $k=>$v)
{
$res['list'][$k]->article_detail_url = route('weixin_article_detail',array('id'=>$v->id));
}
}
return ReturnData::create(ReturnData::SUCCESS,$res);
@ -46,14 +45,15 @@ class ArticleController extends CommonController
public function articleDetail(Request $request)
{
//参数
$where['id'] = $request->input('id',null);
if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$id = $request->input('id');
$where['id'] = $id;
$where['ischeck'] = Article::IS_CHECK;
if($where['id']==null){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$res = $this->getLogic()->getOne($where);
if($res === false)
if(!$res)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL);
return ReturnData::create(ReturnData::RECORD_NOT_EXIST);
}
//$res->pubdate = date('Y-m-d H:i',$res->pubdate);
@ -97,7 +97,6 @@ class ArticleController extends CommonController
if(Helper::isPostRequest())
{
unset($_POST['id']);
$where['id'] = $id;
//$where['user_id'] = Token::$uid;

155
app/Http/Controllers/Api/BonusController.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\Bonus;
use App\Http\Logic\BonusLogic;
use App\Http\Model\UserBonus;
class BonusController extends CommonController
@ -15,106 +17,101 @@ class BonusController extends CommonController
parent::__construct();
}
public function getLogic()
{
return logic('Bonus');
}
//可用获取的优惠券列表
public function bonusList(Request $request)
{
//参数
$data['limit'] = $request->input('limit', 10);
$data['offset'] = $request->input('offset', 0);
$limit = $request->input('limit', 10);
$offset = $request->input('offset', 0);
$where = function ($query) use ($request) {
$query->where('delete_time', 0);
$query->where('status', Bonus::STATUS);
$query->where('num', '=', -1)->orWhere('num', '>', 0);
$query->where('start_time', '<', date('Y-m-d H:i:s'))->where('end_time', '>', date('Y-m-d H:i:s'));
};
$res = Bonus::getList($data);
if(!$res)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL,null,$res);
}
$res = $this->getLogic()->getList($where, '', '*', $offset, $limit);
/* if($res['count']>0)
{
foreach($res['list'] as $k=>$v)
{
}
} */
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::SUCCESS, $res);
}
//添加优惠券
public function bonusAdd(Request $request)
public function bonusDetail(Request $request)
{
//参数
$data['name'] = $request->input('name',null);
$data['money'] = $request->input('money',null);
$data['min_amount'] = $request->input('min_amount',null);
$data['start_time'] = $request->input('start_time',null);
$data['end_time'] = $request->input('end_time',null);
if($request->input('point', null) !== null){$data['point'] = $request->input('point');}
if($request->input('status', null) !== null){$data['status'] = $request->input('status');}
$data['add_time'] = time();
if($data['name']===null || $data['money']===null || $data['min_amount']===null || $data['start_time']===null || $data['end_time']===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;
$where['status'] = Bonus::STATUS;
$where['delete_time'] = 0;
if($data['start_time'] >= $data['end_time'])
{
return ReturnData::create(ReturnData::PARAMS_ERROR,null,'有效期错误');
}
//正则验证时间格式,未作
$res = Bonus::add($data);
if($res !== true)
$res = $this->getLogic()->getOne($where);
if(!$res)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL,null,$res);
return ReturnData::create(ReturnData::RECORD_NOT_EXIST);
}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//修改优惠券
public function bonusUpdate(Request $request)
{
//参数
$id = $request->input('id',null);
$data['name'] = $request->input('name',null);
$data['money'] = $request->input('money',null);
$data['min_amount'] = $request->input('min_amount',null);
$data['start_time'] = $request->input('start_time',null);
$data['end_time'] = $request->input('end_time',null);
if($request->input('point', null) !== null){$data['point'] = $request->input('point');}
if($request->input('status', null) !== null){$data['status'] = $request->input('status');}
if($id===null || $data['name']===null || $data['money']===null || $data['min_amount']===null || $data['start_time']===null || $data['end_time']===null)
{
return ReturnData::create(ReturnData::PARAMS_ERROR);
//添加
public function bonusAdd(Request $request)
{
if(Helper::isPostRequest())
{
return $this->getLogic()->add($_POST);
}
}
//修改
public function bonusUpdate(Request $request)
{
if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$id = $request->input('id');
if($data['start_time'] >= $data['end_time'])
{
return ReturnData::create(ReturnData::PARAMS_ERROR,null,'有效期错误');
if(Helper::isPostRequest())
{
unset($_POST['id']);
$where['id'] = $id;
$where['status'] = Bonus::STATUS;
$where['delete_time'] = 0;
//$where['user_id'] = Token::$uid;
if($_POST['start_time'] >= $_POST['end_time'])
{
return ReturnData::create(ReturnData::PARAMS_ERROR,null,'有效期错误');
}
//正则验证时间格式,未作
return $this->getLogic()->edit($_POST,$where);
}
//正则验证时间格式,未作
$res = Bonus::modify(array('id'=>$id),$data);
if($res !== true)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL,null,$res);
}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//删除优惠券
//删除
public function bonusDelete(Request $request)
{
//参数
$id = $request->input('id',null);
if($id===null)
{
return ReturnData::create(ReturnData::PARAMS_ERROR);
}
$res = Bonus::remove($id);
if($res !== true)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL,null,$res);
}
{
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);
}
}
}

118
app/Http/Controllers/Api/CartController.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\Cart;
use App\Http\Logic\CartLogic;
class CartController extends CommonController
{
@ -14,80 +16,108 @@ class CartController extends CommonController
parent::__construct();
}
//购物车列表
public function getLogic()
{
return logic('Cart');
}
public function cartList(Request $request)
{
//参数
$data['user_id'] = Token::$uid;
$res = Cart::getList($data);
$where['user_id'] = Token::$uid;
$res = $this->getLogic()->getList($where);
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//添加购物车
public function cartAdd(Request $request)
public function cartDetail(Request $request)
{
//参数
$data['goods_number'] = $request->input('goods_number','');
$data['goods_id'] = $request->input('goods_id','');
if($request->input('goods_attr', null) != null){$data['goods_attr'] = $request->input('goods_attr');}
if($request->input('shop_id', null) != null){$data['shop_id'] = $request->input('shop_id');}
$data['add_time'] = time();
$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_number']=='' || $data['goods_id']=='')
$res = $this->getLogic()->getOne($where);
if(!$res)
{
return ReturnData::create(ReturnData::PARAMS_ERROR);
return ReturnData::create(ReturnData::RECORD_NOT_EXIST);
}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
/**
* 添加商品到购物车
*
* @access public
* @param integer $goods_id 商品编号
* @param integer $goods_number 商品数量
* @param json $property 规格值对应的id json数组,预留
* @return boolean
*/
public function cartAdd(Request $request)
{
if(Helper::isPostRequest())
{
$_POST['user_id'] = Token::$uid;
return $this->getLogic()->add($_POST);
}
}
//修改
public function cartUpdate(Request $request)
{
if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$id = $request->input('id');
return Cart::cartAdd($data);
if(Helper::isPostRequest())
{
unset($_POST['id']);
$where['id'] = $id;
//$where['user_id'] = Token::$uid;
return $this->getLogic()->edit($_POST,$where);
}
}
//删除购物车
//删除
public function cartDelete(Request $request)
{
$id = $request->input('id','');
{
if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$id = $request->input('id');
if($id=='')
{
return ReturnData::create(ReturnData::PARAMS_ERROR);
if(Helper::isPostRequest())
{
$where['id'] = $id;
$where['user_id'] = Token::$uid;
return $this->getLogic()->del($where);
}
$res = Cart::remove($id,Token::$uid);
if($res === true)
{
return ReturnData::create(ReturnData::SUCCESS,$res);
}
return ReturnData::create(ReturnData::SYSTEM_FAIL);
}
//清空购物车
public function cartClear(Request $request)
{
$res = Cart::clearCart(Token::$uid);
if($res !== true)
{
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);
}
}
//购物车结算商品列表
public function cartCheckoutGoodsList(Request $request)
{
//参数
$data['ids'] = $request->input('ids','');
$data['user_id'] = Token::$uid;
$where['ids'] = $request->input('ids','');
$where['user_id'] = Token::$uid;
if($data['ids']=='')
if($where['ids']=='')
{
return ReturnData::create(ReturnData::PARAMS_ERROR);
}
return Cart::cartCheckoutGoodsList($data);
return $this->getLogic()->cartCheckoutGoodsList($where);
}
}

92
app/Http/Controllers/Api/FeedBackController.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\FeedBack;
use App\Http\Logic\FeedBackLogic;
class FeedBackController extends CommonController
{
@ -14,42 +16,88 @@ class FeedBackController extends CommonController
parent::__construct();
}
public function getLogic()
{
return logic('FeedBack');
}
public function feedbackList(Request $request)
{
//参数
$data['limit'] = $request->input('limit', 10);
$data['offset'] = $request->input('offset', 0);
$limit = $request->input('limit', 10);
$offset = $request->input('offset', 0);
$where['user_id'] = Token::$uid;
$res = FeedBack::getList($data);
if(!$res)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL);
}
$res = $this->getLogic()->getList($where, array('id', 'desc'), '*', $offset, $limit);
/* if($res['count']>0)
{
foreach($res['list'] as $k=>$v)
{
}
} */
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//添加意见反馈
public function feedbackAdd(Request $request)
public function feedbackDetail(Request $request)
{
//参数
$data['content'] = $request->input('content',null);
if($request->input('title', null) !== null){$data['title'] = $request->input('title');}
if($request->input('mobile', null) !== null){$data['mobile'] = $request->input('mobile');}
if($request->input('type', null) !== null){$data['type'] = $request->input('type');}
$data['user_id'] = Token::$uid;
if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$id = $request->input('id');
if($data['content']===null)
{
return ReturnData::create(ReturnData::PARAMS_ERROR);
}
$where['id'] = $id;
$res = FeedBack::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 feedbackAdd(Request $request)
{
if(Helper::isPostRequest())
{
$_POST['user_id'] = Token::$uid;
$_POST['add_time'] = time();
return $this->getLogic()->add($_POST);
}
}
//修改
public function feedbackUpdate(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 feedbackDelete(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/GoodsBrandController.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\GoodsBrand;
use App\Http\Logic\GoodsBrandLogic;
class GoodsBrandController extends CommonController
{
@ -14,26 +16,89 @@ class GoodsBrandController extends CommonController
parent::__construct();
}
public function goodsBrandDetail(Request $request)
public function getLogic()
{
return logic('GoodsBrand');
}
public function goodsBrandList(Request $request)
{
//参数
$data['id'] = $request->input('id','');
if($data['id']==''){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$limit = $request->input('limit', 10);
$offset = $request->input('offset', 0);
$where['status'] = GoodsBrand::IS_SHOW;
if($request->input('pid', null) != null){$where['pid'] = $request->input('pid');}
$res = GoodsBrand::getOne($data);
$res = $this->getLogic()->getList($where, array('listorder', 'asc'), '*', $offset, $limit);
/* if($res['count']>0)
{
foreach($res['list'] as $k=>$v)
{
}
} */
return ReturnData::create(ReturnData::SUCCESS,$res);
}
public function goodsBrandList(Request $request)
public function goodsBrandDetail(Request $request)
{
//参数
$data['limit'] = $request->input('limit', 10);
$data['offset'] = $request->input('offset', 0);
$data['status'] = GoodsBrand::IS_SHOW;
if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$id = $request->input('id');
$where['id'] = $id;
$where['status'] = GoodsBrand::IS_SHOW;
$res = $this->getLogic()->getOne($where);
if(!$res)
{
return ReturnData::create(ReturnData::RECORD_NOT_EXIST);
}
$res = GoodsBrand::getList($data);
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//添加
public function goodsBrandAdd(Request $request)
{
if(Helper::isPostRequest())
{
//$_POST['user_id'] = Token::$uid;
return $this->getLogic()->add($_POST);
}
}
//修改
public function goodsBrandUpdate(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 goodsBrandDelete(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);
}
}
}

179
app/Http/Controllers/Api/GoodsController.php

@ -1,12 +1,14 @@
<?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\Goods;
use App\Http\Model\GoodsSearchword;
use App\Http\Logic\GoodsLogic;
use App\Http\Logic\GoodsSearchwordLogic;
class GoodsController extends CommonController
{
@ -15,48 +17,157 @@ class GoodsController extends CommonController
parent::__construct();
}
public function goodsDetail(Request $request)
public function getLogic()
{
return logic('Goods');
}
public function goodsList(Request $request)
{
//参数
$data['id'] = $request->input('id','');
$user_id = $request->input('user_id','');
if($data['id']==''){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$limit = $request->input('limit', 10);
$offset = $request->input('offset', 0);
$where = function ($query) use ($request) {
$query->where('status', Goods::GOODS_NORMAL_STATUS);
if($request->input('typeid', null) != null && $request->input('typeid', '') != 0)
{
$query->where('typeid', $request->input('typeid'));
}
if($request->input('tuijian', null) != null)
{
$query->where('tuijian', $request->input('tuijian'));
}
if($request->input('keyword', null) != null)
{
$query->where('title', 'like', '%'.$request->input('keyword').'%')->orWhere('sn', 'like', '%'.$request->input('keyword').'%');
}
//价格区间搜索
if($request->input('min_price', null) != null && $request->input('max_price', null) != null)
{
$query->where('price', '>=', $request->input('min_price'))->where("price", "<=", $request->input('max_price'));
}
if($request->input('brand_id', null) != null)
{
$query->where('brand_id', $request->input('brand_id'));
}
//促销商品
if($request->input('is_promote', 0) == 1)
{
$timestamp = time();
$query->where("promote_start_date", "<=", $timestamp)->where('promote_end_date', '>=', $timestamp);
}
};
//关键词搜索
if($request->input('keyword', null) != null)
{
//添加搜索关键词
$goodssearchword = new GoodsSearchwordLogic();
$goodssearchword->add(array('name'=>$keyword));
}
$res = Goods::goodsDetail($data);
//排序
$orderby = '';
if($request->input('orderby', null) != null)
{
switch ($request->input('orderby'))
{
case 1:
$orderby = ['sale','desc']; //销量从高到低
break;
case 2:
$orderby = ['comments','desc']; //评论从高到低
break;
case 3:
$orderby = ['price','desc']; //价格从高到低
break;
case 4:
$orderby = ['price','asc']; //价格从低到高
break;
default:
$orderby = ['pubdate','desc']; //最新
}
}
$res = $this->getLogic()->getList($where, $orderby, model('Goods')->common_field, $offset, $limit);
if($user_id){$res->is_collect = \DB::table('collect_goods')->where(array('user_id'=>$user_id,'goods_id'=>$data['id']))->count();}
\DB::table('goods')->where(array('id'=>$data['id']))->increment('click', 1);
if($res['count']>0)
{
foreach($res['list'] as $k=>$v)
{
if(!empty($res['list'][$k]->litpic)){$res['list'][$k]->litpic = http_host().$res['list'][$k]->litpic;}
$res['list'][$k]->goods_detail_url = route('weixin_goods_detail',array('id'=>$v->id));
}
}
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::SUCCESS, $res);
}
public function goodsList(Request $request)
public function goodsDetail(Request $request)
{
//参数
$data['limit'] = $request->input('limit', 10);
$data['offset'] = $request->input('offset', 0);
if($request->input('typeid', null) != null && $request->input('typeid', '') != 0){$data['typeid'] = $request->input('typeid');}
if($request->input('tuijian', null) != null){$data['tuijian'] = $request->input('tuijian');}
if($request->input('status', null) != null){$data['status'] = $request->input('status');}
if($request->input('keyword', null) != null){$data['keyword'] = $request->input('keyword');}
if($request->input('min_price', null) != null){$data['min_price'] = $request->input('min_price');}
if($request->input('max_price', null) != null){$data['max_price'] = $request->input('max_price');}
if($request->input('orderby', null) != null){$data['orderby'] = $request->input('orderby');}
if($request->input('brand_id', null) != null){$data['brand_id'] = $request->input('brand_id');}
$res = Goods::getList($data);
return ReturnData::create(ReturnData::SUCCESS,$res);
if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$id = $request->input('id');
$where['id'] = $id;
$res = $this->getLogic()->getOne($where);
if(!$res)
{
return ReturnData::create(ReturnData::RECORD_NOT_EXIST);
}
$res->goods_detail_url = route('weixin_goods_detail',array('id'=>$res->id));
return ReturnData::create(ReturnData::SUCCESS, $res);
}
public function goodsSearchwordList(Request $request)
{
//参数
$data['limit'] = $request->input('limit', 10);
$data['offset'] = $request->input('offset', 0);
//添加
public function goodsAdd(Request $request)
{
if(Helper::isPostRequest())
{
$_POST['user_id'] = Token::$uid;
return $this->getLogic()->add($_POST);
}
}
//修改
public function goodsUpdate(Request $request)
{
if(!checkIsNumber(request('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$id = request('id');
$res = GoodsSearchword::getList($data);
return ReturnData::create(ReturnData::SUCCESS,$res);
if(Helper::isPostRequest())
{
unset($_POST['id']);
$where['id'] = $id;
//$where['user_id'] = Token::$uid;
return $this->getLogic()->edit($_POST,$where);
}
}
//删除
public function goodsDelete(Request $request)
{
if(!checkIsNumber(request('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$id = request('id');
if(Helper::isPostRequest())
{
$where['id'] = $id;
//$where['user_id'] = Token::$uid;
return $this->getLogic()->del($where);
}
}
}

97
app/Http/Controllers/Api/GoodsSearchwordController.php

@ -0,0 +1,97 @@
<?php
namespace App\Http\Controllers\Api;
use Log;
use DB;
use Illuminate\Http\Request;
use App\Common\ReturnData;
use App\Common\Helper;
use App\Common\Token;
use App\Http\Model\GoodsSearchword;
use App\Http\Logic\GoodsSearchwordLogic;
class GoodsSearchwordController extends CommonController
{
public function __construct()
{
parent::__construct();
}
public function getLogic()
{
return new GoodsSearchwordLogic();
}
public function goodsSearchwordList(Request $request)
{
//参数
$limit = $request->input('limit', 10);
$offset = $request->input('offset', 0);
$where['status'] = 0;
$res = $this->getLogic()->getList($where, [['click', 'desc'],['listorder', 'asc']], '*', $offset, $limit);
/* if($res['count'] > 0)
{
foreach($res['list'] as $k=>$v)
{
}
} */
return ReturnData::create(ReturnData::SUCCESS, $res);
}
public function goodsSearchwordDetail(Request $request)
{
//参数
if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$id = $request->input('id');
$where['id'] = $id;
$res = $this->getLogic()->getOne($where);
if(!$res)
{
return ReturnData::create(ReturnData::RECORD_NOT_EXIST);
}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//添加
public function goodsSearchwordAdd(Request $request)
{
if(Helper::isPostRequest())
{
return $this->getLogic()->add($_POST);
}
}
//修改
public function goodsSearchwordUpdate(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;
return $this->getLogic()->edit($_POST,$where);
}
}
//删除
public function goodsSearchwordDelete(Request $request)
{
if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$id = $request->input('id');
if(Helper::isPostRequest())
{
$where['id'] = $id;
return $this->getLogic()->del($where);
}
}
}

78
app/Http/Controllers/Api/GoodsTypeController.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\GoodsType;
use App\Http\Logic\GoodsTypeLogic;
class GoodsTypeController extends CommonController
{
@ -13,28 +15,78 @@ class GoodsTypeController extends CommonController
{
parent::__construct();
}
public function getLogic()
{
return logic('GoodsType');
}
public function goodsTypeDetail(Request $request)
public function goodsTypeList(Request $request)
{
//参数
$data['id'] = $request->input('id','');
if($data['id']==''){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$limit = $request->input('limit', 10);
$offset = $request->input('offset', 0);
$data['pid'] = $request->input('pid', 0);
$where['status'] = GoodsType::GOODSTYPE_SHOW;
$res = GoodsType::getOne($data);
$res = $this->getLogic()->getList($where, array('listorder', 'asc'), '*', $offset, $limit);
return ReturnData::create(ReturnData::SUCCESS,$res);
return ReturnData::create(ReturnData::SUCCESS, $res);
}
public function goodsTypeList(Request $request)
public function goodsTypeDetail(Request $request)
{
//参数
$data['limit'] = $request->input('limit', 10);
$data['offset'] = $request->input('offset', 0);
if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$id = $request->input('id');
$data['pid'] = $request->input('pid', 0);
$where['id'] = $id;
$where['status'] = GoodsType::GOODSTYPE_SHOW;
$res = $this->getLogic()->getOne($where);
if(!$res)
{
return ReturnData::create(ReturnData::RECORD_NOT_EXIST);
}
$res = GoodsType::getList($data);
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//添加
public function goodsTypeAdd(Request $request)
{
if(Helper::isPostRequest())
{
return $this->getLogic()->add($_POST);
}
}
//修改
public function goodsTypeUpdate(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;
return $this->getLogic()->edit($_POST,$where);
}
}
//删除
public function goodsTypeDelete(Request $request)
{
if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$id = $request->input('id');
if(Helper::isPostRequest())
{
$where['id'] = $id;
return $this->getLogic()->del($where);
}
}
}

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

@ -102,4 +102,4 @@ class IndexController extends CommonController
//return $res;
exit(json_encode($res));
}
}
}

98
app/Http/Controllers/Api/PageController.php

@ -0,0 +1,98 @@
<?php
namespace App\Http\Controllers\Api;
use Log;
use DB;
use Illuminate\Http\Request;
use App\Common\ReturnData;
use App\Common\Helper;
use App\Common\Token;
use App\Http\Model\Page;
use App\Http\Logic\PageLogic;
class PageController extends CommonController
{
public function __construct()
{
parent::__construct();
}
public function getLogic()
{
return logic('Page');
}
public function pageList(Request $request)
{
//参数
$limit = $request->input('limit', 10);
$offset = $request->input('offset', 0);
$res = $this->getLogic()->getList('', array('listorder', 'asc'), '*', $offset, $limit);
if($res['count']>0)
{
foreach($res['list'] as $k=>$v)
{
$res['list'][$k]->page_detail_url = route('weixin_singlepage',array('id'=>$v->filename));
}
}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
public function pageDetail(Request $request)
{
//参数
if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$id = $request->input('id');
$where['id'] = $id;
$res = $this->getLogic()->getOne($where);
if(!$res)
{
return ReturnData::create(ReturnData::RECORD_NOT_EXIST);
}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//添加
public function pageAdd(Request $request)
{
if(Helper::isPostRequest())
{
return $this->getLogic()->add($_POST);
}
}
//修改
public function pageUpdate(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 pageDelete(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);
}
}
}

90
app/Http/Controllers/Api/PaymentController.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\Payment;
use App\Http\Logic\PaymentLogic;
class PaymentController extends CommonController
{
@ -14,18 +16,88 @@ class PaymentController extends CommonController
parent::__construct();
}
//获取支付方式列表
public function getLogic()
{
return new PaymentLogic();
}
public function paymentList(Request $request)
{
//参数
$data['status'] = $request->input('status', -1);
$limit = $request->input('limit', 10);
$offset = $request->input('offset', 0);
$where['status'] = Payment::IS_SHOW;
$res = $this->getLogic()->getList($where, array('listorder', 'asc'), '*', $offset, $limit);
/* if($res['count']>0)
{
foreach($res['list'] as $k=>$v)
{
}
} */
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//详情
public function paymentDetail(Request $request)
{
//参数
if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$id = $request->input('id');
$where['status'] = Payment::IS_SHOW;
$where['id'] = $id;
$res = Payment::getList($data);
if(!$res)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL,null,$res);
}
$res = $this->getLogic()->getOne($where);
if(!$res){return ReturnData::create(ReturnData::RECORD_NOT_EXIST);}
return ReturnData::create(ReturnData::SUCCESS,$res);
}
//添加
public function paymentAdd(Request $request)
{
if(Helper::isPostRequest())
{
$res = $this->getLogic()->add($_POST);
return $res;
}
}
//修改
public function paymentUpdate(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;
$res = $this->getLogic()->edit($_POST,$where);
return $res;
}
}
//删除
public function paymentDelete(Request $request)
{
if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$id = $request->input('id');
if(Helper::isPostRequest())
{
$where['id'] = $id;
$res = $this->getLogic()->del($where);
return $res;
}
}
}

92
app/Http/Controllers/Api/RegionController.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\Region;
use App\Http\Logic\RegionLogic;
class RegionController extends CommonController
{
@ -14,39 +16,83 @@ class RegionController extends CommonController
parent::__construct();
}
public function regionList(Request $request)
public function getLogic()
{
return logic('Region');
}
public function regionList(Request $request)
{
//参数
$id = $request->input('id', null);
if ($id == null)
{
return ReturnData::create(ReturnData::PARAMS_ERROR);
}
$where['parent_id'] = $request->input('id', 86);
$res = Region::getList($id);
if(!$res)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL);
}
$res = $this->getLogic()->getAll($where);
/* if($res['count']>0)
{
foreach($res['list'] as $k=>$v)
{
}
} */
return ReturnData::create(ReturnData::SUCCESS,$res);
}
}
public function regionDetail(Request $request)
{
//参数
$id = $request->input('id', null);
if ($id == null)
{
return ReturnData::create(ReturnData::PARAMS_ERROR);
}
if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$id = $request->input('id');
$res = Region::getOne($id);
$where['id'] = $id;
$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 regionAdd(Request $request)
{
if(Helper::isPostRequest())
{
return $this->getLogic()->add($_POST);
}
}
//修改
public function regionUpdate(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 regionDelete(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);
}
}
}

38
app/Http/Controllers/Api/SlideController.php

@ -1,10 +1,11 @@
<?php
namespace App\Http\Controllers\Api;
use Log;
use DB;
use Illuminate\Http\Request;
use App\Common\ReturnData;
use App\Common\Helper;
use App\Common\Token;
use App\Http\Model\Slide;
use App\Http\Logic\SlideLogic;
@ -26,18 +27,18 @@ class SlideController extends CommonController
$where = array();
$limit = $request->input('limit', 10);
$offset = $request->input('offset', 0);
if($request->input('group_id', null) !== null){$where['group_id'] = $request->input('group_id');}
if($request->input('type', null) !== null){$where['type'] = $request->input('type');}
if($request->input('group_id', null) != null){$where['group_id'] = $request->input('group_id');}
if($request->input('type', null) != null){$where['type'] = $request->input('type');}
$where['is_show'] = Slide::IS_SHOW;
$res = $this->getLogic()->getList($where, array('id', 'desc'), '*', $offset, $limit);
if($res == false)
{
return ReturnData::create(ReturnData::SYSTEM_FAIL);
}
foreach($res['list'] as $k=>$v)
$res = $this->getLogic()->getList($where, array('listorder', 'asc'), '*', $offset, $limit);
if($res['count']>0)
{
if(!empty($res['list'][$k]->pic)){$res['list'][$k]->pic = http_host().$v->pic;}
foreach($res['list'] as $k=>$v)
{
if(!empty($res['list'][$k]->pic)){$res['list'][$k]->pic = http_host().$v->pic;}
}
}
return ReturnData::create(ReturnData::SUCCESS,$res);
@ -47,10 +48,12 @@ class SlideController extends CommonController
public function slideDetail(Request $request)
{
//参数
if(!checkIsNumber($request->input('id', 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 = $this->getLogic()->getOne($where);
if(!$res){return ReturnData::create(ReturnData::PARAMS_ERROR);}
if(!$res){return ReturnData::create(ReturnData::RECORD_NOT_EXIST);}
if(!empty($res->pic)){$res->pic = http_host().$res->pic;}
@ -71,7 +74,8 @@ class SlideController extends CommonController
//修改
public function slideUpdate(Request $request)
{
if(!checkIsNumber($request->input('id', null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
if(!checkIsNumber($request->input('id',null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$id = $request->input('id');
if(Helper::isPostRequest())
{
@ -87,11 +91,11 @@ class SlideController extends CommonController
//删除
public function slideDelete(Request $request)
{
if(!checkIsNumber($request->input('id', null))){return ReturnData::create(ReturnData::PARAMS_ERROR);}
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;
$res = $this->getLogic()->del($where);

1
app/Http/Controllers/Api/VerifyCodeController.php

@ -5,6 +5,7 @@ use App\Http\Controllers\Api\CommonController;
use Illuminate\Http\Request;
use App\Common\ReturnData;
use App\Common\Helper;
use App\Common\Token;
use App\Http\Model\VerifyCode;

2
app/Http/Logic/ArctypeLogic.php

@ -14,7 +14,7 @@ class ArctypeLogic extends BaseLogic
public function getModel()
{
return new Arctype();
return model('Arctype');
}
public function getValidate($data, $scene_name)

8
app/Http/Logic/ArticleLogic.php

@ -14,7 +14,7 @@ class ArticleLogic extends BaseLogic
public function getModel()
{
return new Article();
return model('Article');
}
public function getValidate($data, $scene_name)
@ -37,10 +37,6 @@ class ArticleLogic extends BaseLogic
$res['list'][$k]->typename = $this->getModel()->getTypenameAttr(array('typeid' => $v->typeid));
}
}
else
{
return false;
}
return $res;
}
@ -82,7 +78,7 @@ class ArticleLogic extends BaseLogic
$res = $this->getDataView($res);
$res->typename = $this->getModel()->getTypenameAttr(array('typeid'=>$res->typeid));
$this->getModel()->getDb()->where($where)->increment('click', 1);
$this->getModel()->getDb()->where($where)->increment('click', 1); //点击量+1
return $res;
}

13
app/Http/Logic/BonusLogic.php

@ -14,7 +14,7 @@ class BonusLogic extends BaseLogic
public function getModel()
{
return new Bonus();
return model('Bonus');
}
public function getValidate($data, $scene_name)
@ -80,9 +80,18 @@ class BonusLogic extends BaseLogic
{
if(empty($data)){return ReturnData::create(ReturnData::PARAMS_ERROR);}
$data['add_time'] = time();
$validator = $this->getValidate($data, 'add');
if ($validator->fails()){return ReturnData::create(ReturnData::PARAMS_ERROR, null, $validator->errors()->first());}
if($data['start_time'] >= $data['end_time'])
{
return ReturnData::create(ReturnData::PARAMS_ERROR,null,'有效期错误');
}
//正则验证时间格式,未作
$res = $this->getModel()->add($data,$type);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
@ -111,7 +120,7 @@ class BonusLogic 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);
$res = $this->getModel()->edit(['delete_time'=>time()],$where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
return ReturnData::create(ReturnData::SUCCESS,$res);

135
app/Http/Logic/CartLogic.php

@ -2,6 +2,7 @@
namespace App\Http\Logic;
use App\Common\ReturnData;
use App\Http\Model\Cart;
use App\Http\Model\Goods;
use App\Http\Requests\CartRequest;
use Validator;
@ -14,7 +15,7 @@ class CartLogic extends BaseLogic
public function getModel()
{
return new Cart();
return model('Cart');
}
public function getValidate($data, $scene_name)
@ -27,13 +28,35 @@ class CartLogic extends BaseLogic
//列表
public function getList($where = array(), $order = '', $field = '*', $offset = '', $limit = '')
{
$res = $this->getModel()->getList($where, $order, $field, $offset, $limit);
$model = $this->getModel()->getDb();
if($res['count'] > 0)
$model = $model->join('goods', 'goods.id', '=', 'cart.goods_id')
->where('cart.user_id', $where['user_id'])
->where('goods.status', Goods::GOODS_NORMAL_STATUS)
->select('cart.*','goods.id as goods_id','goods.title','goods.sn','goods.price as goods_price','goods.market_price','goods.litpic','goods.goods_number as stock','goods.promote_start_date','goods.promote_price','goods.promote_end_date');
$res['count'] = $model->count();
$res['list'] = array();
if($res['count']>0)
{
foreach($res['list'] as $k=>$v)
$res['list'] = $model->get();
foreach ($res['list'] as $k => $v)
{
$res['list'][$k] = $this->getDataView($v);
$res['list'][$k]->is_promote = 0;
if(model('Goods')->bargain_price($v->goods_price,$v->promote_start_date,$v->promote_end_date) > 0){$res['list'][$k]->is_promote = 1;}
//订货数量大于0
if ($v->goods_number > 0)
{
$goods_tmp = ['price'=>$v->goods_price,'promote_price'=>$v->promote_price,'promote_start_date'=>$v->promote_start_date,'promote_end_date'=>$v->promote_end_date];
$res['list'][$k]->final_price = model('Goods')->get_goods_final_price((object)$goods_tmp); //商品最终价格
$res['list'][$k]->goods_detail_url = route('weixin_goods_detail',array('id'=>$v->goods_id));
//更新购物车中的商品数量
//self::where('id', $v->id)->update(array('price' => $goods_price));
}
}
}
@ -83,10 +106,62 @@ class CartLogic extends BaseLogic
$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);}
//获取商品信息
$goods = model('Goods')->getDb()->where(['id' => $data['goods_id'], 'status' => Goods::GOODS_NORMAL_STATUS])->first();
return ReturnData::create(ReturnData::SUCCESS,$res);
if (!$goods)
{
return ReturnData::create(ReturnData::PARAMS_ERROR,null,'商品不存在');
}
//判断库存 是否足够
if($goods->goods_number<$data['goods_number'])
{
return ReturnData::create(ReturnData::PARAMS_ERROR,null,'库存不足');
}
//判断购物车商品数
if(Cart::where(['user_id'=>$data['user_id']])->count() >= 20)
{
return ReturnData::create(ReturnData::PARAMS_ERROR,null,'购物车商品最多20件');
}
//查看是否已经有购物车插入记录
$where = array(
'user_id' => $data['user_id'],
'goods_id' => $data['goods_id']
);
$cart = Cart::where($where)->first();
if($cart)
{
//更新购物车
$updateArr = array(
'goods_number' => $data['goods_number'],
'add_time' => time(),
);
Cart::where(array('id'=>$cart->id))->update($updateArr);
$cart_id = $cart->id;
}
else
{
//添加购物车
$cartInsert = array(
'user_id' => $data['user_id'],
'goods_id' => $data['goods_id'],
'goods_number' => $data['goods_number'],
'add_time' => time(),
);
$cart_id = Cart::insertGetId($cartInsert);
}
if(isset($cart_id) && $cart_id){return ReturnData::create(ReturnData::SUCCESS,$cart_id,'购物车添加成功');}
return ReturnData::create(ReturnData::PARAMS_ERROR,null,'系统错误');
}
//修改
@ -108,9 +183,6 @@ class CartLogic 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());}
$res = $this->getModel()->del($where);
if($res === false){return ReturnData::create(ReturnData::SYSTEM_FAIL);}
@ -126,4 +198,45 @@ class CartLogic extends BaseLogic
{
return getDataAttr($this->getModel(),$data);
}
//购物车结算商品列表
public function cartCheckoutGoodsList($where)
{
$cartIds = explode("_",$where['ids']);
// 获取购物车列表
$cartList = Cart::where(array('user_id'=>$where['user_id']))->whereIn('id', $cartIds)->get();
$total_price = 0; //商品总金额
$total_goods = 0; //商品总数量
if($cartList)
{
$resultList = array();
$checkArr = array();
foreach($cartList as $k=>$v)
{
$goods = Goods::where(array('id'=>$v['goods_id']))->first();
$cartList[$k]->is_promote = 0;
if(model('Goods')->bargain_price($goods->price,$goods->promote_start_date,$goods->promote_end_date) > 0){$cartList[$k]->is_promote = 1;}
$cartList[$k]->final_price = model('Goods')->get_goods_final_price($goods); //商品最终价格
$cartList[$k]->goods_detail_url = route('weixin_goods_detail',array('id'=>$v['goods_id']));
$cartList[$k]->title = $goods->title;
$cartList[$k]->litpic = $goods->litpic;
$cartList[$k]->market_price = $goods->market_price;
$cartList[$k]->goods_sn = $goods->sn;
$total_price = $total_price + $cartList[$k]->final_price*$cartList[$k]->goods_number;
$total_goods = $total_goods + $cartList[$k]->goods_number;
}
}
$res['list'] = $cartList;
$res['total_price'] = $total_price;
$res['total_goods'] = $total_goods;
return ReturnData::create(ReturnData::SUCCESS,$res);
}
}

27
app/Http/Logic/GoodsLogic.php

@ -4,6 +4,7 @@ use App\Common\ReturnData;
use App\Http\Model\Goods;
use App\Http\Requests\GoodsRequest;
use Validator;
use App\Http\Model\Comment;
class GoodsLogic extends BaseLogic
{
@ -14,7 +15,7 @@ class GoodsLogic extends BaseLogic
public function getModel()
{
return new Goods();
return model('Goods');
}
public function getValidate($data, $scene_name)
@ -34,6 +35,9 @@ class GoodsLogic extends BaseLogic
foreach($res['list'] as $k=>$v)
{
$res['list'][$k] = $this->getDataView($v);
$res['list'][$k]->price = $this->getModel()->get_goods_final_price($v);
$res['list'][$k]->is_promote_goods = $this->getModel()->bargain_price($v->promote_price,$v->promote_start_date,$v->promote_end_date); //is_promote_goods等于0,说明不是促销商品
}
}
@ -53,13 +57,16 @@ class GoodsLogic extends BaseLogic
{
$res = $this->getModel()->getAll($where, $order, $field, $limit);
/* if($res)
if($res['count'] > 0)
{
foreach($res as $k=>$v)
foreach($res['list'] as $k=>$v)
{
$res[$k] = $this->getDataView($v);
$res['list'][$k] = $this->getDataView($v);
$res['list'][$k]->price = $this->getModel()->get_goods_final_price($v); //商品最终价格
$res['list'][$k]->is_promote_goods = $this->getModel()->bargain_price($v->promote_price,$v->promote_start_date,$v->promote_end_date); //is_promote_goods等于0,说明不是促销商品
}
} */
}
return $res;
}
@ -71,6 +78,16 @@ class GoodsLogic extends BaseLogic
if(!$res){return false;}
$res = $this->getDataView($res);
$res->price = $this->getModel()->get_goods_final_price($res); //商品最终价格
$res->is_promote_goods = $this->getModel()->bargain_price($res->promote_price,$res->promote_start_date,$res->promote_end_date); //is_promote_goods等于0,说明不是促销商品
//商品评论数
$where2['comment_type'] = Comment::GOODS_COMMENT_TYPE;
$where2['status'] = Comment::SHOW_COMMENT;
$where2['id_value'] = $res->id;
$res->goods_comments_num = model('Comment')->getCount($where2);
$this->getModel()->getDb()->where($where)->increment('click', 1); //点击量+1
return $res;
}

13
app/Http/Model/Arctype.php

@ -13,9 +13,10 @@ class Arctype extends BaseModel
* @var string
*/
protected $table = 'arctype';
public $timestamps = false;
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
/**
* The connection name for the model.
* 默认情况下,所有的 Eloquent 模型使用应用配置中的默认数据库连接,如果你想要为模型指定不同的连接,可以通过 $connection 属性来设置
@ -95,17 +96,17 @@ class Arctype extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}

10
app/Http/Model/Article.php

@ -21,7 +21,7 @@ class Article extends BaseModel
* @var bool
*/
public $timestamps = false;
protected $hidden = array();
//protected $guarded = []; //$guarded包含你不想被赋值的字段数组。
//protected $fillable = ['name']; //定义哪些字段是可以进行赋值的,与$guarded相反
@ -112,17 +112,17 @@ class Article extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}

15
app/Http/Model/BaseModel.php

@ -14,19 +14,26 @@ class BaseModel extends Model
return Schema::getColumnListing($table);
}
//过滤不是某一表的字段
//过滤不是某一表的字段、过滤空值
public static function filterTableColumn($data, $table)
{
$table_column = Schema::getColumnListing($table);
if (!$table_column) {
if (!$table_column)
{
return $data;
}
foreach ($data as $k => $v) {
if (!in_array($k, $table_column)) {
foreach ($data as $k => $v)
{
if (!in_array($k, $table_column))
{
unset($data[$k]);
}
else
{
if($data[$k]==''){unset($data[$k]);} //过滤空值
}
}
return $data;

19
app/Http/Model/Bonus.php

@ -9,14 +9,9 @@ class Bonus extends BaseModel
protected $table = 'bonus';
public $timestamps = false;
/**
* 不能被批量赋值的属性
*
* @var array
*/
protected $guarded = [];
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
const STATUS = 0; // 优惠券可以
public function getDb()
@ -83,17 +78,17 @@ class Bonus extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}

84
app/Http/Model/Cart.php

@ -13,9 +13,10 @@ class Cart extends BaseModel
* @var string
*/
protected $table = 'cart';
public $timestamps = false;
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
//购物车商品类型
const CART_GENERAL_GOODS = 0; // 普通商品
const CART_GROUP_BUY_GOODS = 1; // 团购商品
@ -87,17 +88,17 @@ class Cart extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}
@ -266,17 +267,17 @@ class Cart extends BaseModel
* 添加商品到购物车
*
* @access public
* @param integer $goods_id 商品编号
* @param integer $num 商品数量
* @param json $property 规格值对应的id json数组
* @param integer $goods_id 商品编号
* @param integer $goods_number 商品数量
* @param json $property 规格值对应的id json数组
* @return boolean
*/
public static function cartAdd(array $attributes)
public function cartAdd(array $attributes)
{
extract($attributes);
//获取商品信息
$goods = Goods::where(['id' => $goods_id, 'status' => Goods::STATUS])->first();
$goods = Goods::where(['id' => $goods_id, 'status' => Goods::GOODS_NORMAL_STATUS])->first();
if (!$goods)
{
@ -332,61 +333,14 @@ class Cart extends BaseModel
}
/**
* 清空购物车
*
* @param int $type 类型:默认普通商品
* 用户购物车商品总数量
*
* @access public
* @param int $user_id 用户ID
* @return int
*/
public static function clearCart($user_id)
public function TotalGoodsCount($where)
{
return self::where('user_id',$user_id)->delete();
}
//购物车商品总数量
public static function TotalGoodsCount($user_id)
{
return self::where('user_id',$user_id)->sum('goods_number');
}
//购物车结算商品列表
public static function cartCheckoutGoodsList(array $param)
{
extract($param);
$cartIds = explode("_",$ids);
// 获取购物车列表
$cartList = self::where(array('user_id'=>$user_id))->whereIn('id', $cartIds)->get();
$total_price = 0; //商品总金额
$total_goods = 0; //商品总数量
if(!empty($cartList))
{
$resultList = array();
$checkArr = array();
foreach($cartList as $k=>$v)
{
$goods = Goods::where(array('id'=>$v['goods_id']))->first();
$cartList[$k]->is_promote = 0;
if(Goods::bargain_price($goods->price,$goods->promote_start_date,$goods->promote_end_date) > 0){$cartList[$k]->is_promote = 1;}
$cartList[$k]->final_price = Goods::get_final_price($v['goods_id']); //商品最终价格
$cartList[$k]->goods_detail_url = route('weixin_goods_detail',array('id'=>$v['goods_id']));
$cartList[$k]->title = $goods->title;
$cartList[$k]->litpic = $goods->litpic;
$cartList[$k]->market_price = $goods->market_price;
$cartList[$k]->goods_sn = $goods->sn;
$total_price = $total_price + $cartList[$k]->final_price*$cartList[$k]->goods_number;
$total_goods = $total_goods + $cartList[$k]->goods_number;
}
}
$res['list'] = $cartList;
$res['total_price'] = $total_price;
$res['total_goods'] = $total_goods;
return ReturnData::create(ReturnData::SUCCESS,$res);
return self::where($where)->sum('goods_number');
}
}

18
app/Http/Model/CollectGoods.php

@ -9,14 +9,8 @@ class CollectGoods extends BaseModel
protected $table = 'collect_goods';
public $timestamps = false;
/**
* 不能被批量赋值的属性
*
* @var array
*/
protected $guarded = [];
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
public function getDb()
{
@ -82,17 +76,17 @@ class CollectGoods extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}

33
app/Http/Model/Comment.php

@ -9,14 +9,9 @@ class Comment extends BaseModel
protected $table = 'comment';
public $timestamps = false;
/**
* 不能被批量赋值的属性
*
* @var array
*/
protected $guarded = [];
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
const UNSHOW_COMMENT = 0; //评论未批准显示
const SHOW_COMMENT = 1; //评论批准显示
const GOODS_COMMENT_TYPE = 0; //商品评论
@ -87,17 +82,17 @@ class Comment extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}
@ -179,6 +174,20 @@ class Comment extends BaseModel
return $res;
}
/**
* 统计
* @param array $where 条件
* @return bool
*/
public function getCount($where)
{
$res = $this->getDb();
$res = $res->where($where)->count();
return $res;
}
/*
//获取列表
public static function getList(array $param)

18
app/Http/Model/FeedBack.php

@ -9,14 +9,8 @@ class FeedBack extends BaseModel
protected $table = 'feedback';
public $timestamps = false;
/**
* 不能被批量赋值的属性
*
* @var array
*/
protected $guarded = [];
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
public function getDb()
{
@ -82,17 +76,17 @@ class FeedBack extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}

13
app/Http/Model/Friendlink.php

@ -9,8 +9,9 @@ class Friendlink extends BaseModel
protected $table = 'friendlink';
public $timestamps = false;
protected $guarded = []; //$guarded包含你不想被赋值的字段数组。
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
public function getDb()
{
return DB::table($this->table);
@ -75,17 +76,17 @@ class Friendlink extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}

242
app/Http/Model/Goods.php

@ -13,7 +13,7 @@ class Goods extends BaseModel
* @var string
*/
protected $table = 'goods';
/**
* 表明模型是否应该被打上时间戳
* 默认情况下,Eloquent 期望 created_at 和updated_at 已经存在于数据表中,如果你不想要这些 Laravel 自动管理的数据列,在模型类中设置 $timestamps 属性为 false
@ -21,7 +21,8 @@ class Goods extends BaseModel
* @var bool
*/
public $timestamps = false;
protected $hidden = array();
//protected $guarded = []; //$guarded包含你不想被赋值的字段数组。
//protected $fillable = ['name']; //定义哪些字段是可以进行赋值的,与$guarded相反
@ -33,11 +34,11 @@ class Goods extends BaseModel
//protected $connection = 'connection-name';
//常用字段
protected $common_field = array(
public $common_field = array(
'id', 'typeid', 'tuijian', 'click', 'title', 'description', 'sn', 'price','litpic', 'pubdate', 'add_time', 'market_price', 'goods_number', 'sale', 'comments','promote_start_date','promote_price','promote_end_date','goods_img','spec','point'
);
const STATUS = 0; //商品状态 0正常 1已删除 2下架 3申请上架
const GOODS_NORMAL_STATUS = 0; //商品状态 0正常 1已删除 2下架 3申请上架
/**
* 获取关联到产品的分类
@ -78,7 +79,7 @@ class Goods extends BaseModel
$res['list'] = $model->skip($offset)->take($limit)->get();
}
//return $model->toSql();//打印sql语句
return $res;
}
@ -111,17 +112,17 @@ class Goods extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}
@ -203,154 +204,7 @@ class Goods extends BaseModel
return $res;
}
/*
//获取列表
public static function getList(array $param)
{
extract($param); //参数:limit,offset
$where = '';
$limit = isset($limit) ? $limit : 10;
$offset = isset($offset) ? $offset : 0;
$model = new Goods;
if(isset($typeid)){$where['typeid'] = $typeid;}
if(isset($tuijian)){$where['tuijian'] = $tuijian;}
if(isset($status)){$where['status'] = $status;}else{$where['status'] = self::STATUS;}
if(isset($brand_id)){$where['brand_id'] = $brand_id;}
if($where !== '')
{
$model = $model->where($where);
}
//关键词搜索
if(isset($max_price) && isset($min_price)){$model = $model->where("price", ">=", $min_price)->where("price", "<=", $max_price);} //价格区间搜索
if(isset($keyword))
{
$model = $model->where(function ($query) use ($keyword) {$query->where("title", "like", "%$keyword%")->orWhere("sn", "like", "%$keyword%");});
//添加搜索关键词
GoodsSearchword::add(array('name'=>$keyword));
}
//return $model->toSql();//打印sql语句
$res['count'] = $model->count();
$res['list'] = array();
//排序
if(isset($orderby))
{
switch ($orderby)
{
case 1:
$model = $model->orderBy('sale','desc'); //销量从高到低
break;
case 2:
$model = $model->orderBy('comments','desc'); //评论从高到低
break;
case 3:
$model = $model->orderBy('price','desc'); //价格从高到低
break;
case 4:
$model = $model->orderBy('price','asc'); //价格从低到高
break;
case 5:
$timestamp = time();
$model = $model->where('promote_start_date','<=',$timestamp)->where('promote_end_date','>=',$timestamp); //促销商品
break;
default:
$model = $model->orderBy('pubdate','desc'); //最新
}
}
if($res['count']>0)
{
$res['list'] = $model->select(self::$common_field)->skip($offset)->take($limit)->orderBy('id','desc')->get();
if($res['list'])
{
foreach($res['list'] as $k=>$v)
{
$res['list'][$k]->goods_detail_url = route('weixin_goods_detail',array('id'=>$v->id));
$res['list'][$k]->price = self::get_goods_final_price($v);
if(!empty($res['list'][$k]->litpic)){$res['list'][$k]->litpic = http_host().$res['list'][$k]->litpic;}
$res['list'][$k]->is_promote_goods = self::bargain_price($v->promote_price,$v->promote_start_date,$v->promote_end_date); //is_promote_goods等于0,说明不是促销商品
}
}
}
return $res;
}
public static function getOne(array $param)
{
extract($param);
$model = new Goods;
$where['id'] = $id;
if(isset($where)){$model = $model->where($where);}
if(isset($field)){$model = $model->select($field);}
$goods = $model->first();
if($goods)
{
$goods['goods_detail_url'] = route('weixin_goods_detail',array('id'=>$goods->id));
$goods['price'] = self::get_goods_final_price($goods);
$goods['is_promote_goods'] = self::bargain_price($goods->promote_price,$goods->promote_start_date,$goods->promote_end_date); //is_promote_goods等于0,说明不是促销商品
}
return $goods;
}
public static function add(array $data)
{
$validator = Validator::make($data, [
'title' => 'required|unique:posts|max:255',
'body' => 'required',
]);
if ($validator->fails()) {
return redirect('post/create')
->withErrors($validator)
->withInput();
}
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;
}
*/
/**
* 取得商品最终使用价格
*
@ -359,20 +213,20 @@ class Goods extends BaseModel
*
* @return 商品最终购买价格
*/
public static function get_final_price($goods_id)
/* public function get_final_price($goods_id)
{
$final_price = '0'; //商品最终购买价格
$promote_price = '0'; //商品促销价格
$user_price = '0'; //商品会员价格,预留
//取得商品促销价格列表
$goods = Goods::where('id',$goods_id)->where('status',0)->first(['promote_price','promote_start_date','promote_end_date','price']);
$goods = Goods::where('id',$goods_id)->where('status', self::GOODS_NORMAL_STATUS)->first(['promote_price','promote_start_date','promote_end_date','price']);
$final_price = $goods->price;
// 计算商品的促销价格
if ($goods->promote_price > 0)
{
$promote_price = self::bargain_price($goods->promote_price, $goods->promote_start_date, $goods->promote_end_date);
$promote_price = $this->bargain_price($goods->promote_price, $goods->promote_start_date, $goods->promote_end_date);
}
else
{
@ -386,7 +240,7 @@ class Goods extends BaseModel
//返回商品最终购买价格
return $final_price;
}
} */
/**
* 取得商品最终使用价格
@ -396,7 +250,7 @@ class Goods extends BaseModel
*
* @return 商品最终购买价格
*/
public static function get_goods_final_price($goods)
public function get_goods_final_price($goods)
{
$final_price = '0'; //商品最终购买价格
$promote_price = '0'; //商品促销价格
@ -408,7 +262,7 @@ class Goods extends BaseModel
// 计算商品的促销价格
if ($goods->promote_price > 0)
{
$promote_price = self::bargain_price($goods->promote_price, $goods->promote_start_date, $goods->promote_end_date);
$promote_price = $this->bargain_price($goods->promote_price, $goods->promote_start_date, $goods->promote_end_date);
}
else
{
@ -433,7 +287,7 @@ class Goods extends BaseModel
* @param string $end 促销结束日期
* @return float 如果还在促销期则返回促销价,否则返回0
*/
public static function bargain_price($price, $start, $end)
public function bargain_price($price, $start, $end)
{
if ($price <= 0)
{
@ -454,60 +308,28 @@ class Goods extends BaseModel
}
}
//获取商品详情
public static function goodsDetail(array $param)
{
extract($param); //参数:limit,offset
$model = new Goods;
if(isset($id)){$where['id'] = $id;}
if(isset($where))
{
$model = $model->where($where);
}
else
{
return false;
}
$res = $model->first();
if($res)
{
$where2['comment_type'] = Comment::GOODS_COMMENT_TYPE;
$where2['status'] = Comment::SHOW_COMMENT;
$where2['id_value'] = $id;
$res->goods_comments_num = Comment::where($where2)->count();
$res->price = self::get_final_price($res->id); //商品最终价格
$res->is_promote_goods = self::bargain_price($res->promote_price,$res->promote_start_date,$res->promote_end_date); //is_promote_goods等于0,说明不是促销商品
}
return $res;
}
//增加或减少商品库存
public static function changeGoodsStock(array $param)
/**
* 增加或减少商品库存
*
* @access public
* @param int $id 商品ID
* @param int $type 1增加库存
* @return bool
*/
public function changeGoodsStock($where)
{
//$param['type']=1减库存
extract($param);
if(isset($type) && $type==1)
if($where['type']==1)
{
//增加库存
DB::table('goods')->where(array('id'=>$goods_id))->increment('goods_number', $goods_number);
}
else
{
//减少库存
DB::table('goods')->where(array('id'=>$goods_id))->decrement('goods_number', $goods_number);
return $this->getDb()->where($where)->increment('goods_number', $goods_number);
}
//减少库存
return $this->getDb()->where($where)->decrement('goods_number', $goods_number);
}
//获取栏目名称
public static function getTypenameAttr($data)
public function getTypenameAttr($data)
{
return DB::table('goods_type')->where(array('id'=>$data['typeid']))->value('name');
}

11
app/Http/Model/GoodsBrand.php

@ -9,7 +9,8 @@ class GoodsBrand extends BaseModel
protected $table = 'goods_brand';
public $timestamps = false;
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
const UN_SHOW = 1; // 不显示
const IS_SHOW = 0; // 显示
@ -78,17 +79,17 @@ class GoodsBrand extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}

14
app/Http/Model/GoodsImg.php

@ -5,11 +5,13 @@ use Log;
class GoodsImg extends BaseModel
{
//品图片
//品图片
protected $table = 'goods_img';
public $timestamps = false;
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
public function getDb()
{
return DB::table($this->table);
@ -74,17 +76,17 @@ class GoodsImg extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}

19
app/Http/Model/GoodsSearchword.php

@ -9,14 +9,9 @@ class GoodsSearchword extends BaseModel
protected $table = 'goods_searchword';
public $timestamps = false;
/**
* 不能被批量赋值的属性
*
* @var array
*/
protected $guarded = array();
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
public function getDb()
{
return DB::table($this->table);
@ -81,17 +76,17 @@ class GoodsSearchword extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}

18
app/Http/Model/GoodsType.php

@ -14,14 +14,10 @@ class GoodsType extends BaseModel
*/
protected $table = 'goods_type';
public $timestamps = false;
protected $hidden = array('content');
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
/**
* 不能被批量赋值的属性
*
* @var array
*/
protected $guarded = array();
protected $hidden = array('content');
const GOODSTYPE_SHOW = 1; //是否显示,1显示
/**
* 获取分类对应的产品
@ -95,17 +91,17 @@ class GoodsType extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}

13
app/Http/Model/Guestbook.php

@ -9,8 +9,9 @@ class Guestbook extends BaseModel
protected $table = 'guestbook';
public $timestamps = false;
protected $guarded = []; //$guarded包含你不想被赋值的字段数组。
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
public function getDb()
{
return DB::table($this->table);
@ -75,17 +76,17 @@ class Guestbook extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}

13
app/Http/Model/Keyword.php

@ -9,8 +9,9 @@ class Keyword extends BaseModel
protected $table = 'keyword';
public $timestamps = false;
protected $guarded = []; //$guarded包含你不想被赋值的字段数组。
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
public function getDb()
{
return DB::table($this->table);
@ -75,17 +76,17 @@ class Keyword extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}

13
app/Http/Model/Kuaidi.php

@ -9,8 +9,9 @@ class Kuaidi extends BaseModel
protected $table = 'kuaidi';
public $timestamps = false;
protected $guarded = []; //$guarded包含你不想被赋值的字段数组。
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
public function getDb()
{
return DB::table($this->table);
@ -75,17 +76,17 @@ class Kuaidi extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}

13
app/Http/Model/Menu.php

@ -7,8 +7,9 @@ class Menu extends BaseModel
{
protected $table = 'menu';
public $timestamps = false;
protected $guarded = []; //$guarded包含你不想被赋值的字段数组。
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
public function getDb()
{
return DB::table($this->table);
@ -73,17 +74,17 @@ class Menu extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}

13
app/Http/Model/Order.php

@ -9,8 +9,9 @@ class Order extends BaseModel
protected $table = 'order';
public $timestamps = false;
protected $guarded = []; //$guarded包含你不想被赋值的字段数组。
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
public function getDb()
{
return DB::table($this->table);
@ -75,17 +76,17 @@ class Order extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}

13
app/Http/Model/OrderGoods.php

@ -9,8 +9,9 @@ class OrderGoods extends BaseModel
protected $table = 'order_goods';
public $timestamps = false;
protected $guarded = []; //$guarded包含你不想被赋值的字段数组。
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
public function getDb()
{
return DB::table($this->table);
@ -75,17 +76,17 @@ class OrderGoods extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}

13
app/Http/Model/Page.php

@ -9,8 +9,9 @@ class Page extends BaseModel
protected $table = 'page';
public $timestamps = false;
protected $guarded = []; //$guarded包含你不想被赋值的字段数组。
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
public function getDb()
{
return DB::table($this->table);
@ -75,17 +76,17 @@ class Page extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}

75
app/Http/Model/Payment.php

@ -9,9 +9,10 @@ class Payment extends BaseModel
protected $table = 'payment';
public $timestamps = false;
protected $guarded = []; //$guarded包含你不想被赋值的字段数组。
const STATUS = 1; // 可用支付方式
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
const IS_SHOW = 1; // 可用支付方式
public function getDb()
{
@ -77,17 +78,17 @@ class Payment extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}
@ -169,64 +170,4 @@ class Payment extends BaseModel
return $res;
}
/*
//获取列表
public static function getList(array $param)
{
extract($param); //参数:limit,offset
$model = new Payment;
if(isset($status) && $status!=-1){$where['status'] = $status;} //-1表示获取所有
if(isset($where)){$model = $model->where($where);}
$res['count'] = $model->count();
$res['list'] = array();
if($res['count']>0)
{
$res['list'] = $model->orderBy('listorder','desc')->get();
}
return $res;
}
public static function getOne($where)
{
return self::where($where)->first();
}
public static function add(array $data)
{
if(self::where(array('pay_code'=>$data['pay_code']))->first()){return ReturnData::create(ReturnData::PARAMS_ERROR,null,'支付方式已存在');}
if ($id = self::insertGetId($data))
{
return ReturnData::create(ReturnData::SUCCESS,$id);
}
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)
{
if (!self::whereIn('id', explode(',', $id))->delete())
{
return false;
}
return true;
} */
}

36
app/Http/Model/Region.php

@ -9,24 +9,8 @@ class Region extends BaseModel
protected $table = 'region';
public $timestamps = false;
protected $guarded = []; //$guarded包含你不想被赋值的字段数组。
public static function getRegionName($id)
{
if(empty($id) || $id==0){return '';}
return self::where('id', $id)->value('name');
}
/* public static function getList($parent_id=86)
{
return self::where('parent_id', $parent_id)->get();
}
public static function getOne($id)
{
return self::where('id', $id)->first();
} */
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
public function getDb()
{
@ -92,17 +76,17 @@ class Region extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}
@ -184,4 +168,12 @@ class Region extends BaseModel
return $res;
}
//根据id获取地区中文名称
public static function getRegionName($id)
{
if(empty($id) || $id==0){return '';}
return self::where('id', $id)->value('name');
}
}

13
app/Http/Model/Searchword.php

@ -9,8 +9,9 @@ class Searchword extends BaseModel
protected $table = 'searchword';
public $timestamps = false;
protected $guarded = []; //$guarded包含你不想被赋值的字段数组。
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
public function getDb()
{
return DB::table($this->table);
@ -75,17 +76,17 @@ class Searchword extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}

37
app/Http/Model/Slide.php

@ -7,10 +7,10 @@ class Slide extends BaseModel
{
//轮播图
protected $table = 'slide';
public $timestamps = false;
protected $guarded = []; //$guarded包含你不想被赋值的字段数组。
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
const UN_SHOW = 1; // 不显示
const IS_SHOW = 0; // 显示
@ -78,17 +78,17 @@ class Slide extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}
@ -172,26 +172,9 @@ class Slide extends BaseModel
}
//获取显示平台文字:0pc,1weixin,2app,3wap
public function getTypeAttr($where)
public function getTypeAttr($data)
{
$res = '';
if($where['type'] === 0)
{
$res = 'pc';
}
elseif($where['type'] === 1)
{
$res = 'weixin';
}
elseif($where['type'] === 2)
{
$res = 'app';
}
elseif($where['type'] === 3)
{
$res = 'wap';
}
return $res;
$arr = array(0 => 'pc', 1 => 'weixin', 2 => 'app', 3 => 'wap');
return $arr[$data->type];
}
}

16
app/Http/Model/SmsLog.php

@ -6,12 +6,14 @@ use Log;
//短信发送记录
class SmsLog extends BaseModel
{
protected $table = 'sms_log';
public $timestamps = false;
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
const SUCCESS = 1;
const FAIL = 2;
protected $table = 'sms_log';
public $guarded = [];
public function getDb()
{
return DB::table($this->table);
@ -96,17 +98,17 @@ class SmsLog extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}

17
app/Http/Model/Sysconfig.php

@ -9,13 +9,8 @@ class Sysconfig extends BaseModel
protected $table = 'sysconfig';
public $timestamps = false;
/**
* 不能被批量赋值的属性
*
* @var array
*/
protected $guarded = [];
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
public function getDb()
{
@ -81,17 +76,17 @@ class Sysconfig extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}

13
app/Http/Model/Tagindex.php

@ -9,8 +9,9 @@ class Tagindex extends BaseModel
protected $table = 'tagindex';
public $timestamps = false;
protected $guarded = []; //$guarded包含你不想被赋值的字段数组。
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
public function getDb()
{
return DB::table($this->table);
@ -75,17 +76,17 @@ class Tagindex extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}

13
app/Http/Model/Taglist.php

@ -7,8 +7,9 @@ class Taglist extends BaseModel
{
protected $table = 'taglist';
public $timestamps = false;
protected $guarded = []; //$guarded包含你不想被赋值的字段数组。
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
public function getDb()
{
return DB::table($this->table);
@ -73,17 +74,17 @@ class Taglist extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}

10
app/Http/Model/User.php

@ -9,8 +9,8 @@ class User extends BaseModel
protected $table = 'user';
public $timestamps = false;
protected $guarded = []; //$guarded包含你不想被赋值的字段数组。
protected $hidden = array('password','pay_password');
protected $guarded = []; //$guarded包含你不想被赋值的字段数组。
public function getDb()
{
@ -76,17 +76,17 @@ class User extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}

9
app/Http/Model/UserAddress.php

@ -8,7 +8,6 @@ class UserAddress extends BaseModel
//用户收货地址
protected $table = 'user_address';
public $timestamps = false;
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
@ -79,17 +78,17 @@ class UserAddress extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}

13
app/Http/Model/UserBonus.php

@ -9,8 +9,9 @@ class UserBonus extends BaseModel
protected $table = 'user_bonus';
public $timestamps = false;
protected $guarded = []; //$guarded包含你不想被赋值的字段数组。
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
public function getDb()
{
return DB::table($this->table);
@ -75,17 +76,17 @@ class UserBonus extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}

13
app/Http/Model/UserGoodsHistory.php

@ -9,8 +9,9 @@ class UserGoodsHistory extends BaseModel
protected $table = 'user_goods_history';
public $timestamps = false;
protected $guarded = []; //$guarded包含你不想被赋值的字段数组。
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
public function getDb()
{
return DB::table($this->table);
@ -75,17 +76,17 @@ class UserGoodsHistory extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}

13
app/Http/Model/UserMessage.php

@ -9,8 +9,9 @@ class UserMessage extends BaseModel
protected $table = 'user_message';
public $timestamps = false;
protected $guarded = []; //$guarded包含你不想被赋值的字段数组。
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
public function getDb()
{
return DB::table($this->table);
@ -75,17 +76,17 @@ class UserMessage extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}

13
app/Http/Model/UserMoney.php

@ -9,8 +9,9 @@ class UserMoney extends BaseModel
protected $table = 'user_money';
public $timestamps = false;
protected $guarded = []; //$guarded包含你不想被赋值的字段数组。
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
public function getDb()
{
return DB::table($this->table);
@ -75,17 +76,17 @@ class UserMoney extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}

13
app/Http/Model/UserPoint.php

@ -9,8 +9,9 @@ class UserPoint extends BaseModel
protected $table = 'user_point';
public $timestamps = false;
protected $guarded = []; //$guarded包含你不想被赋值的字段数组。
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
public function getDb()
{
return DB::table($this->table);
@ -75,17 +76,17 @@ class UserPoint extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}

13
app/Http/Model/UserRecharge.php

@ -9,8 +9,9 @@ class UserRecharge extends BaseModel
protected $table = 'user_recharge';
public $timestamps = false;
protected $guarded = []; //$guarded包含你不想被赋值的字段数组。
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
const UN_PAY = 0;
const COMPLETE_PAY = 1;
@ -78,17 +79,17 @@ class UserRecharge extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}

13
app/Http/Model/UserRole.php

@ -9,8 +9,9 @@ class UserRole extends BaseModel
protected $table = 'user_role';
public $timestamps = false;
protected $guarded = []; //$guarded包含你不想被赋值的字段数组。
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
public function getDb()
{
return DB::table($this->table);
@ -75,17 +76,17 @@ class UserRole extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}

13
app/Http/Model/UserWithdraw.php

@ -9,8 +9,9 @@ class UserWithdraw extends BaseModel
protected $table = 'user_withdraw';
public $timestamps = false;
protected $guarded = []; //$guarded包含你不想被赋值的字段数组。
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
public function getDb()
{
return DB::table($this->table);
@ -75,17 +76,17 @@ class UserWithdraw extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}

12
app/Http/Model/VerifyCode.php

@ -11,7 +11,9 @@ class VerifyCode extends BaseModel
{
protected $table = 'verify_code';
public $timestamps = false;
protected $guarded = []; //$guarded包含你不想被赋值的字段数组。
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
const STATUS_UNUSE = 0;
const STATUS_USE = 1; //验证码已被使用
@ -87,17 +89,17 @@ class VerifyCode extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}

11
app/Http/Model/WeixinMenu.php

@ -13,7 +13,8 @@ class WeixinMenu extends BaseModel
{
protected $table = 'weixin_menu';
public $timestamps = false;
protected $guarded = []; //$guarded包含你不想被赋值的字段数组。
protected $hidden = array();
protected $guarded = array(); //$guarded包含你不想被赋值的字段数组。
const IS_SHOW = 0;
@ -81,17 +82,17 @@ class WeixinMenu extends BaseModel
* @param int $limit 取多少条
* @return array
*/
public function getAll($where = array(), $order = '', $field = '*', $limit = 10, $offset = 0)
public function getAll($where = array(), $order = '', $field = '*', $limit = '', $offset = '')
{
$res = $this->getDb();
if($where){$res = $res->where($where);}
if($field){if(is_array($field)){$res = $res->select($field);}else{$res = $res->select(\DB::raw($field));}}
if($order){$res = parent::getOrderByData($res, $order);}
if($offset){}else{$offset = 0;}
if($limit){}else{$limit = 10;}
if($offset){$res = $res->skip($offset);}
if($limit){$res = $res->take($limit);}
$res = $res->skip($offset)->take($limit)->get();
$res = $res->get();
return $res;
}

2
app/Http/Requests/AdminRequest.php

@ -11,7 +11,7 @@ class AdminRequest extends BaseRequest
'logintime' => 'integer',
'pwd' => 'required|max:32',
'role_id' => 'required|integer',
'status' => 'integer|between:[0,3]',
'status' => 'integer|between:0,3',
'mobile' => 'max:20',
'avatar' => 'max:150',
'create_at' => 'required|integer',

4
app/Http/Requests/AdminRoleRequest.php

@ -8,9 +8,9 @@ class AdminRoleRequest extends BaseRequest
'id' => 'required|integer',
'name' => 'required|max:30',
'des' => 'max:150',
'status' => 'integer|between:[0,2]',
'status' => 'integer|between:0,2',
'pid' => 'integer',
'listorder' => 'integer|between:[1,9999]',
'listorder' => 'integer|between:1,9999',
];
//总的自定义错误信息

5
app/Http/Requests/ArctypeRequest.php

@ -18,6 +18,7 @@ class ArctypeRequest extends BaseRequest
'temparticle' => 'max:50',
'litpic' => 'max:100',
'seokeyword' => 'max:50',
'is_show' => 'between:0,1',
];
//总的自定义错误信息
@ -39,11 +40,13 @@ class ArctypeRequest extends BaseRequest
'temparticle.max' => '文章页模板不能超过50个字符',
'litpic.max' => '封面或缩略图不能超过100个字符',
'seokeyword.max' => 'seokeyword不能超过50个字符',
'is_show.between' => '是否显示:默认0显示,1不显示',
];
//场景验证规则
protected $scene = [
'add' => ['name', 'typedir', 'pid', 'addtime', 'seotitle', 'keywords', 'description', 'listorder', 'templist', 'temparticle', 'litpic', 'seokeyword'],
'add' => ['name', 'typedir', 'pid', 'addtime', 'seotitle', 'keywords', 'description', 'listorder', 'templist', 'temparticle', 'litpic', 'seokeyword','is_show'],
'add' => ['name', 'typedir', 'pid', 'seotitle', 'keywords', 'description', 'listorder', 'templist', 'temparticle', 'litpic', 'seokeyword'],
'del' => ['id'],
];

2
app/Http/Requests/ArticleRequest.php

@ -18,7 +18,7 @@ class ArticleRequest extends BaseRequest
'keywords' => 'max:60',
'seotitle' => 'max:150',
'description' => 'max:250',
'ischeck' => 'between:[0,2]',
'ischeck' => 'between:0,2',
'user_id' => 'integer',
];

9
app/Http/Requests/BonusRequest.php

@ -10,11 +10,11 @@ class BonusRequest extends BaseRequest
'money' => ['required','regex:/^\d{0,10}(\.\d{0,2})?$/'],
'min_amount' => ['required','regex:/^\d{0,10}(\.\d{0,2})?$/'],
'start_time' => 'required|date_format:"Y-m-d H:i:s"',
'end_time' => 'required|date_format:"Y-m-d H:i:s"',
'point' => 'integer|between:[1,9999]',
'status' => 'integer|between:[0,1]',
'end_time' => 'required|date_format:"Y-m-d H:i:s"|after:start_time',
'point' => 'integer|between:1,9999',
'status' => 'integer|between:0,1',
'add_time' => 'required|integer',
'num' => 'integer|between:[-1,999999]',
'num' => 'integer|between:-1,999999',
];
//总的自定义错误信息
@ -31,6 +31,7 @@ class BonusRequest extends BaseRequest
'start_time.date_format' => '开始时间格式不正确,格式:1990-01-01 00:00:00',
'end_time.required' => '结束时间必填',
'end_time.date_format' => '结束时间格式不正确,格式:1990-01-01 00:00:00',
'end_time.after' => '结束时间必须大于开始时间',
'point.integer' => '兑换优惠券所需积分必须是数字',
'point.between' => '兑换优惠券所需积分只能1-9999',
'status.integer' => '兑换优惠券所需积分必须是数字',

10
app/Http/Requests/CartRequest.php

@ -9,8 +9,8 @@ class CartRequest extends BaseRequest
'user_id' => 'required|integer',
'goods_id' => 'required|integer',
'shop_id' => 'integer',
'goods_number' => 'required|integer|between:[1,9999]',
'type' => 'integer|between:[0,3]',
'goods_number' => 'required|integer|between:1,9999',
'type' => 'integer|between:0,3',
'add_time' => 'required|integer',
];
@ -34,9 +34,9 @@ class CartRequest extends BaseRequest
//场景验证规则
protected $scene = [
'add' => ['user_id', 'goods_id', 'shop_id', 'goods_number', 'type', 'add_time'],
'edit' => ['user_id', 'goods_id', 'shop_id', 'goods_number', 'type', 'add_time'],
'del' => ['id'],
'add' => ['user_id', 'goods_id', 'goods_number', 'shop_id', 'type'],
'edit' => ['user_id', 'goods_id', 'shop_id', 'goods_number', 'type'],
'del' => ['id','user_id'],
];
/**

2
app/Http/Requests/CollectGoodsRequest.php

@ -9,7 +9,7 @@ class CollectGoodsRequest extends BaseRequest
'user_id' => 'required|integer',
'goods_id' => 'required|integer',
'add_time' => 'required|integer',
'is_attention' => 'integer|between:[0,1]',
'is_attention' => 'integer|between:0,1',
];
//总的自定义错误信息

8
app/Http/Requests/CommentRequest.php

@ -6,15 +6,15 @@ class CommentRequest extends BaseRequest
//总的验证规则
protected $rules = [
'id' => 'required|integer',
'comment_type' => 'required|integer|between:[0,1]',
'comment_type' => 'required|integer|between:0,1',
'id_value' => 'required|integer',
'comment_rank' => 'required|integer|between:[1,5]',
'comment_rank' => 'required|integer|between:1,5',
'add_time' => 'required|integer',
'ip_address' => 'max:20',
'status' => 'integer|between:[0,1]',
'status' => 'integer|between:0,1',
'parent_id' => 'integer',
'user_id' => 'required|integer',
'is_anonymous' => 'integer|between:[0,1]',
'is_anonymous' => 'integer|between:0,1',
];
//总的自定义错误信息

5
app/Http/Requests/FeedbackRequest.php

@ -9,7 +9,7 @@ class FeedbackRequest extends BaseRequest
'content' => 'required',
'add_time' => 'required|integer',
'title' => 'max:150',
'user_id' => 'integer',
'user_id' => 'required|integer',
'mobile' => 'max:20',
'type' => 'max:20',
];
@ -22,6 +22,7 @@ class FeedbackRequest extends BaseRequest
'add_time.required' => '添加时间必填',
'add_time.integer' => '添加时间必须为数字',
'title.max' => '标题不能超过150个字符',
'user_id.required' => '发布者ID必填',
'user_id.integer' => '发布者ID必须是数字',
'mobile.max' => '手机号码不能超过20个字符',
'type.max' => '意见反馈类型不能超过20个字符',
@ -30,7 +31,7 @@ class FeedbackRequest extends BaseRequest
//场景验证规则
protected $scene = [
'add' => ['content', 'add_time', 'title', 'user_id', 'mobile', 'type'],
'edit' => ['content', 'add_time', 'title', 'user_id', 'mobile', 'type'],
'edit' => ['content', 'title', 'mobile', 'type'],
'del' => ['id'],
];

4
app/Http/Requests/FriendlinkRequest.php

@ -8,8 +8,8 @@ class FriendlinkRequest extends BaseRequest
'id' => 'required|integer',
'webname' => 'required|max:60',
'url' => 'required|max:100',
'group_id' => 'integer|between:[1,99]',
'listorder' => 'integer|between:[1,9999]',
'group_id' => 'integer|between:1,99',
'listorder' => 'integer|between:1,9999',
];
//总的自定义错误信息

4
app/Http/Requests/GoodsBrandRequest.php

@ -13,8 +13,8 @@ class GoodsBrandRequest extends BaseRequest
'keywords' => 'max:60',
'description' => 'max:240',
'litpic' => 'max:100',
'status' => 'integer|between:[0,1]',
'listorder' => 'integer|between:[1,9999]',
'status' => 'integer|between:0,1',
'listorder' => 'integer|between:1,9999',
'cover_img' => 'max:100',
'click' => 'integer',
];

2
app/Http/Requests/GoodsImgRequest.php

@ -10,7 +10,7 @@ class GoodsImgRequest extends BaseRequest
'goods_id' => 'required|integer',
'add_time' => 'required|integer',
'des' => 'max:150',
'listorder' => 'integer|between:[1,9999]',
'listorder' => 'integer|between:1,9999',
];
//总的自定义错误信息

14
app/Http/Requests/GoodsRequest.php

@ -18,22 +18,22 @@ class GoodsRequest extends BaseRequest
'keywords' => 'max:60',
'seotitle' => 'max:150',
'description' => 'max:250',
'status' => 'integer|between:[0,5]',
'status' => 'integer|between:0,5',
'shipping_fee' => ['regex:/^\d{0,10}(\.\d{0,2})?$/'],
'market_price' => ['required','regex:/^\d{0,10}(\.\d{0,2})?$/'],
'goods_number' => 'required|integer|between:[1,99999]',
'goods_number' => 'required|integer|between:1,99999',
'user_id' => 'integer',
'sale' => 'integer|between:[1,99999]',
'sale' => 'integer|between:1,99999',
'cost_price' => ['regex:/^\d{0,10}(\.\d{0,2})?$/'],
'goods_weight' => ['regex:/^\d{0,10}(\.\d{0,2})?$/'],
'point' => 'integer|between:[1,99999]',
'comments' => 'integer|between:[1,99999]',
'point' => 'integer|between:1,99999',
'comments' => 'integer|between:1,99999',
'promote_start_date' => 'integer',
'promote_end_date' => 'integer',
'promote_price' => ['regex:/^\d{0,10}(\.\d{0,2})?$/'],
'goods_img' => 'max:250',
'warn_number' => 'integer|between:[1,99]',
'listorder' => 'integer|between:[1,9999]',
'warn_number' => 'integer|between:1,99',
'listorder' => 'integer|between:1,9999',
'brand_id' => 'integer',
];

4
app/Http/Requests/GoodsSearchwordRequest.php

@ -7,9 +7,9 @@ class GoodsSearchwordRequest extends BaseRequest
protected $rules = [
'id' => 'required|integer',
'name' => 'required|max:60',
'status' => 'integer|between:[0,5]',
'status' => 'integer|between:0,5',
'add_time' => 'required|integer',
'listorder' => 'integer|between:[1,9999]',
'listorder' => 'integer|between:1,9999',
'click' => 'integer',
];

2
app/Http/Requests/GoodsTypeRequest.php

@ -17,7 +17,7 @@ class GoodsTypeRequest extends BaseRequest
'temparticle' => 'max:50',
'litpic' => 'max:100',
'seokeyword' => 'max:50',
'status' => 'integer|between:[0,1]',
'status' => 'integer|between:0,1',
'listorder' => 'integer',
'cover_img' => 'max:100',
];

2
app/Http/Requests/GuestbookRequest.php

@ -9,7 +9,7 @@ class GuestbookRequest extends BaseRequest
'title' => 'required|max:150',
'addtime' => 'required|integer',
'msg' => 'required|max:250',
'status' => 'integer|between:[0,1]',
'status' => 'integer|between:0,1',
'name' => 'max:30',
'phone' => 'max:20',
'email' => 'max:60',

2
app/Http/Requests/KuaidiRequest.php

@ -13,7 +13,7 @@ class KuaidiRequest extends BaseRequest
'des' => 'max:150',
'tel' => 'max:60',
'website' => 'max:60',
'status' => 'integer|between:[0,1]',
'status' => 'integer|between:0,1',
'listorder' => 'integer',
];

4
app/Http/Requests/MenuRequest.php

@ -9,8 +9,8 @@ class MenuRequest extends BaseRequest
'pid' => 'integer',
'action' => 'required|max:50',
'data' => 'max:50',
'type' => 'integer|between:[0,1]',
'status' => 'integer|between:[0,1]',
'type' => 'integer|between:0,1',
'status' => 'integer|between:0,1',
'listorder' => 'integer',
'name' => 'required|max:50',
'icon' => 'max:50',

14
app/Http/Requests/OrderRequest.php

@ -18,22 +18,22 @@ class OrderRequest extends BaseRequest
'keywords' => 'max:60',
'seotitle' => 'max:150',
'description' => 'max:250',
'status' => 'integer|between:[0,5]',
'status' => 'integer|between:0,5',
'shipping_fee' => ['regex:/^\d{0,10}(\.\d{0,2})?$/'],
'market_price' => ['required','regex:/^\d{0,10}(\.\d{0,2})?$/'],
'goods_number' => 'required|integer|between:[1,99999]',
'goods_number' => 'required|integer|between:1,99999',
'user_id' => 'integer',
'sale' => 'integer|between:[1,99999]',
'sale' => 'integer|between:1,99999',
'cost_price' => ['regex:/^\d{0,10}(\.\d{0,2})?$/'],
'goods_weight' => ['regex:/^\d{0,10}(\.\d{0,2})?$/'],
'point' => 'integer|between:[1,99999]',
'comments' => 'integer|between:[1,99999]',
'point' => 'integer|between:1,99999',
'comments' => 'integer|between:1,99999',
'promote_start_date' => 'integer',
'promote_end_date' => 'integer',
'promote_price' => ['regex:/^\d{0,10}(\.\d{0,2})?$/'],
'goods_img' => 'max:250',
'warn_number' => 'integer|between:[1,99]',
'listorder' => 'integer|between:[1,9999]',
'warn_number' => 'integer|between:1,99',
'listorder' => 'integer|between:1,9999',
'brand_id' => 'integer',
];

2
app/Http/Requests/PageRequest.php

@ -15,7 +15,7 @@ class PageRequest extends BaseRequest
'filename' => 'required|max:60',
'litpic' => 'max:100',
'click' => 'integer',
'listorder' => 'integer|between:[1,9999]',
'listorder' => 'integer|between:1,9999',
];
//总的自定义错误信息

4
app/Http/Requests/PaymentRequest.php

@ -9,8 +9,8 @@ class PaymentRequest extends BaseRequest
'pay_code' => 'required|max:20',
'pay_name' => 'required|max:100',
'pay_fee' => ['required','regex:/^\d{0,10}(\.\d{0,1})?$/'],
'status' => 'integer|between:[0,1]',
'listorder' => 'integer|between:[1,9999]',
'status' => 'integer|between:0,1',
'listorder' => 'integer|between:1,9999',
];
//总的自定义错误信息

6
app/Http/Requests/RegionRequest.php

@ -8,11 +8,11 @@ class RegionRequest extends BaseRequest
'id' => 'required|integer',
'name' => 'required|max:64',
'parent_id' => 'integer',
'type' => 'integer|between:[0,3]',
'type' => 'integer|between:0,3',
'sort_name' => 'max:50',
'is_oversea' => 'integer|between:[0,1]',
'is_oversea' => 'integer|between:0,1',
'area_code' => 'max:10',
'status' => 'integer|between:[0,1]',
'status' => 'integer|between:0,1',
];
//总的自定义错误信息

2
app/Http/Requests/SysconfigRequest.php

@ -8,7 +8,7 @@ class SysconfigRequest extends BaseRequest
'id' => 'required|integer',
'varname' => 'required|max:100',
'info' => 'required|max:100',
'is_show' => 'integer|between:[0,5]',
'is_show' => 'integer|between:0,5',
];
//总的自定义错误信息

2
app/Http/Requests/TokenRequest.php

@ -7,7 +7,7 @@ class TokenRequest extends BaseRequest
protected $rules = [
'id' => 'required|integer',
'token' => 'required|max:128',
'type' => 'required|integer|between:[0,6]',
'type' => 'required|integer|between:0,6',
'uid' => 'required|integer',
'created_at' => 'required|date_format:"Y-m-d H:i:s"',
'expired_at' => 'required|date_format:"Y-m-d H:i:s"',

4
app/Http/Requests/VerifyCodeRequest.php

@ -7,9 +7,9 @@ class VerifyCodeRequest extends BaseRequest
protected $rules = [
'id' => 'required|integer',
'code' => 'required|max:10',
'type' => 'required|integer|between:[0,6]',
'type' => 'required|integer|between:0,6',
'mobile' => 'required|max:20',
'status' => 'integer|between:[0,1]',
'status' => 'integer|between:0,1',
'created_at' => 'required|date_format:"Y-m-d H:i:s"',
'expired_at' => 'required|date_format:"Y-m-d H:i:s"',
];

5
routes/web.php

@ -144,11 +144,14 @@ Route::group(['prefix' => 'dataapi', 'namespace' => 'Api', 'middleware' => ['web
Route::get('/article_detail', 'ArticleController@articleDetail');
Route::get('/arctype_list', 'ArctypeController@arctypeList');
Route::get('/arctype_detail', 'ArctypeController@arctypeDetail');
//单页
Route::get('/page_list', 'PageController@pageList');
Route::get('/page_detail', 'PageController@pageDetail');
//商品
Route::get('/goods_detail', 'GoodsController@goodsDetail'); //商品详情
Route::get('/goods_list', 'GoodsController@goodsList'); //商品列表
Route::get('/goodstype_list', 'GoodsTypeController@goodsTypeList'); //商品分类列表
Route::get('/goods_searchword_list', 'GoodsController@goodsSearchwordList'); //商品搜索词列表
Route::get('/goods_searchword_list', 'GoodsSearchwordController@goodsSearchwordList'); //商品搜索词列表
Route::get('/goodsbrand_detail', 'GoodsBrandController@goodsBrandDetail'); //商品品牌详情
Route::get('/goodsbrand_list', 'GoodsBrandController@goodsBrandList'); //商品品牌列表
//地区,省市区

Loading…
Cancel
Save