コード例 #1
0
 /**
  *
  * @SWG\Api(
  *   path="/activity_page",
  *   description="约惠主页(有更新20160308)",
  *   @SWG\Operation(
  *     method="GET", summary="获得约惠主页内容", notes="获得约惠主页内容",
  *     type="ActivityPage",
  *     @SWG\ResponseMessage(code=0, message="成功"),
  *     @SWG\Parameter(
  *         name="user_id",
  *         description="用户id",
  *         paramType="query",
  *         required=false,
  *         allowMultiple=false,
  *         type="integer",
  *         defaultValue=-1
  *     )
  *   )
  * )
  */
 public function index(Request $request)
 {
     $user_id = $request->input('user_id', -1);
     $response = new BaseResponse();
     $ret = (object) null;
     $banners = Banner::where('banner_position', 1)->get();
     $ret->banners = $banners;
     //分类
     $activityClassification = ActivityClassification::all();
     $ret->activityClassification = $activityClassification;
     //包邮
     $freePost = FreePost::all();
     $ret->freePost = $freePost;
     //爆品
     $conversionGoods = ConversionGoods::all();
     //$conversionGoods=$conversionGoods->toArray();
     foreach ($conversionGoods as &$v) {
         $v->has_collection = 0;
         if ($user_id != -1) {
             $collection = Collection::where('user_id', $user_id)->where('type', 0)->where('item_id', $v->goods_id)->first();
             if ($collection != null) {
                 $v->has_collection = 1;
             }
         }
     }
     $ret->conversionGoods = $conversionGoods;
     $response->Data = $ret;
     return $response->toJson();
 }
コード例 #2
0
 /**
  *
  * @SWG\Api(
  *   path="/setting/gift_token_setting",
  *   @SWG\Operation(
  *     method="GET", summary="返回礼券获取开启状态", notes="返回礼券获取开启状态",type="GiftTokenSetting",
  *     @SWG\ResponseMessage(code=404, message="page not found"),
  *     @SWG\Parameter(
  *         name="id",
  *         description="1:注册领取 2:完善资料领取",
  *         paramType="query",
  *         required=true,
  *         allowMultiple=false,
  *         type="integer"
  *     )
  *
  *   )
  * )
  */
 public function index(Request $request)
 {
     $id = $request->input('id');
     $response = new BaseResponse();
     $status = GiftTokenSetting::find($id);
     $response->Data = $status;
     return $response->toJson();
 }
コード例 #3
0
ファイル: BootPageController.php プロジェクト: Lazybin/huisa
 /**
  *
  * @SWG\Api(
  *   path="/setting/boot_page",
  *   @SWG\Operation(
  *     method="GET", summary="取得启动页广告", notes="返回的为相对路径,使用时请在前面加上http://120.27.199.121/feise/public",
  *     @SWG\ResponseMessage(code=404, message="page not found")
  *
  *   )
  * )
  */
 public function index()
 {
     //
     $response = new BaseResponse();
     $path = BootPage::select('path')->find(1);
     $response->Data = $path;
     return $response->toJson();
 }
コード例 #4
0
ファイル: BannerController.php プロジェクト: Lazybin/huisa
 /**
  *
  * @SWG\Api(
  *   path="/setting/banner",
  *   description="系统设置(更新20160210)",
  *   @SWG\Operation(
  *     method="GET", type="Banner",summary="取得banner", notes="返回的为相对路径,使用时请在前面加上http://120.27.199.121/feise/public",
  *     @SWG\ResponseMessage(code=0, message=""),
  *     @SWG\Parameter(
  *         name="banner_position",
  *         description="banner位置 0-->首页,1-->约惠",
  *         paramType="query",
  *         required=false,
  *         allowMultiple=false,
  *         type="integer",
  *         defaultValue=1
  *     )
  *   )
  * )
  */
 public function index(Request $request)
 {
     $response = new BaseResponse();
     $banner_position = $request->input('banner_position', 0);
     $banners = Banner::where('banner_position', $banner_position);
     $response->rows = $banners->get();
     $response->total = $banners->count();
     return $response->toJson();
 }
コード例 #5
0
ファイル: AreaController.php プロジェクト: Lazybin/huisa
 /**
  *
  * @SWG\Api(
  *   path="/area",
  *   description="地区分类",
  *   @SWG\Operation(
  *     method="GET", summary="地区分类列表", notes="地区分类列表",
  *     type="Area",
  *     @SWG\ResponseMessage(code=0, message="成功"),
  *     @SWG\Parameter(
  *         name="pid",
  *         description="父id,默认为0---》获取省份",
  *         paramType="query",
  *         required=true,
  *         allowMultiple=false,
  *         type="integer",
  *         defaultValue=0
  *     )
  *   )
  * )
  */
 public function index(Request $request)
 {
     $pid = $request->input('pid', 0);
     $response = new BaseResponse();
     $area = Area::where('pid', $pid);
     $rows = $area->orderBy('id')->get()->toArray();
     $response->rows = $rows;
     $response->total = $area->count();
     return $response->toJson();
 }
コード例 #6
0
 /**
  *
  * @SWG\Api(
  *   path="/home_navigation",
  *   description="首页按钮和banner",
  *   @SWG\Operation(
  *     method="GET", summary="获得首页和banner按钮列表", notes="对于按钮列表点击详情时:当type=0的时候调用 APP WAP 页 中的导航按钮详情图片接口来访问详情,当type=1时,直接跳转action字段中的链接",
  *     type="HomeNavigationAndBanner",
  *     @SWG\ResponseMessage(code=0, message="成功")
  *   )
  * )
  */
 public function index(Request $request)
 {
     $response = new BaseResponse();
     $ret = (object) null;
     $button_list = HomeNavigation::orderBy('sort')->orderBy('id')->get();
     $banners = Banner::where('banner_position', 0)->get();
     $ret->button_list = $button_list;
     $ret->banner_list = $banners;
     $response->Data = $ret;
     return $response->toJson();
 }
コード例 #7
0
ファイル: FreePostController.php プロジェクト: Lazybin/huisa
 /**
  *
  * @SWG\Api(
  *   path="/free_post/{id}",
  *   description="包邮分类详情",
  *   @SWG\Operation(
  *     method="GET", summary="获得包邮分类详情", notes="获得包邮分类详情",
  *     type="FreePostDetail",
  *     @SWG\ResponseMessage(code=0, message="成功"),
  *     @SWG\Parameter(
  *         name="id",
  *         description="分类id",
  *         paramType="path",
  *         required=true,
  *         allowMultiple=false,
  *         type="integer",
  *     )
  *   )
  * )
  */
 public function show(Request $request, $id)
 {
     $response = new BaseResponse();
     $freePost = FreePost::find($id);
     $goods_list = FreePostGoods::where('free_posts_id', $id);
     $goods_list = $goods_list->orderBy('id', 'desc')->get();
     $ret = (object) null;
     $ret->free_post = $freePost;
     $ret->goods_list = $goods_list;
     $response->Data = $ret;
     return $response->toJson();
 }
コード例 #8
0
ファイル: SubjectController.php プロジェクト: Lazybin/huisa
 /**
  *
  * @SWG\Api(
  *   path="/subject/{id}",
  *   description="获取专题题详情",
  *   @SWG\Operation(
  *     method="GET", summary="获取专题题详情", notes="获取专题题详情",
  *     type="Subject",
  *     @SWG\ResponseMessage(code=0, message="成功"),
  *     @SWG\Parameter(
  *         name="id",
  *         description="id",
  *         paramType="path",
  *         required=true,
  *         allowMultiple=false,
  *         type="integer",
  *     )
  *   )
  * )
  */
 public function show($id)
 {
     $response = new BaseResponse();
     $subject = Subject::find($id)->toArray();
     $themes = $subject['themes'];
     $subjects['themes'] = [];
     foreach ($themes as $t) {
         array_push($subjects['themes'], $t['themes'][0]);
     }
     $ret['item'] = $subjects;
     $response->Data = $ret;
     return $response->toJson();
 }
コード例 #9
0
 /**
  *
  * @SWG\Api(
  *   path="/user_levels/{user_id}",
  *   description="用户等级(新20160220)",
  *   @SWG\Operation(
  *     method="GET", summary="查询用户等级", notes="查询用户等级 level代表用户当前等级(1-5中的一个)sum代表用户消费总金额",
  *     @SWG\ResponseMessage(code=0, message="成功"),
  *     @SWG\Parameter(
  *         name="user_id",
  *         description="用户id",
  *         paramType="path",
  *         required=true,
  *         allowMultiple=false,
  *         type="integer",
  *     )
  *
  *   )
  * )
  */
 public function show($id)
 {
     $response = new BaseResponse();
     $sum = Order::select(DB::raw('SUM(total_fee) as total_pay'))->where('user_id', $id)->where('status', 4)->first()->toArray();
     if ($sum == null || $sum['total_pay'] == null) {
         $sum = 0;
     } else {
         $sum = $sum['total_pay'];
     }
     $level = UserLevel::where('sum_lowest', '<=', $sum)->where('sum_highest', '>', $sum)->first()->toArray();
     $ret['level'] = $level['id'];
     $ret['sum'] = $sum;
     $response->Data = $ret;
     return $response->toJson();
 }
コード例 #10
0
 /**
  *
  * @SWG\Api(
  *   path="/use_coupon_records",
  *   description="礼券使用记录(新20160225)",
  *   @SWG\Operation(
  *     method="GET", summary="获得用户礼券使用记录列表", notes="获得用户礼券使用记录列表",
  *     type="UseCouponRecords",
  *     @SWG\ResponseMessage(code=0, message="成功"),
  *     @SWG\Parameter(
  *         name="user_id",
  *         description="用户id",
  *         paramType="query",
  *         required=true,
  *         allowMultiple=false,
  *         type="integer"
  *     ),
  *     @SWG\Parameter(
  *         name="PageNum",
  *         description="分页开始位置",
  *         paramType="query",
  *         required=false,
  *         allowMultiple=false,
  *         type="integer",
  *         defaultValue=1
  *     ),@SWG\Parameter(
  *         name="PerPage",
  *         description="取得长度",
  *         paramType="query",
  *         required=false,
  *         allowMultiple=false,
  *         type="integer",
  *         defaultValue=10
  *     )
  *
  *   )
  * )
  */
 public function index(Request $request)
 {
     $start = $request->input('PageNum', 0);
     $length = $request->input('PerPage', 5);
     $user_id = $request->input('user_id');
     $start = ($start - 1) * $length;
     $response = new BaseResponse();
     $records = UseCouponRecords::where('user_id', $user_id)->where('status', 1);
     $rows = $records->skip($start)->take($length)->orderBy('id', 'desc')->get()->toArray();
     foreach ($rows as &$v) {
         foreach ($v['order']['goods_list'] as &$g) {
             $g['properties'] = json_decode($g['properties']);
         }
     }
     $response->rows = $rows;
     $response->total = $records->count();
     return $response->toJson();
 }
コード例 #11
0
ファイル: UserInfoController.php プロジェクト: Lazybin/huisa
 /**
  *
  * @SWG\Api(
  *   path="/user_info",
  *   description="用户信息(新20160304)",
  *   @SWG\Operation(
  *     method="POST", summary="添加,修改用户信息", notes="添加,修改用户信息",
  *     @SWG\ResponseMessage(code=0, message="成功"),
  *     @SWG\Parameter(
  *         name="user_info",
  *         description="用户id",
  *         paramType="body",
  *         required=true,
  *         type="UserInfo"
  *     )
  *   )
  * )
  */
 public function store(Request $request)
 {
     $response = new BaseResponse();
     $content = json_decode($request->getContent(false));
     if (!isset($content->id)) {
         $response->Code = BaseResponse::CODE_ERROR_CHECK;
         $response->Message = '用户id不能为空';
         return $response->toJson();
     }
     $userId = $content->id;
     $userAccount = $content->user_account;
     $nickName = $content->nick_name;
     $headIcon = $content->head_icon;
     $userInfo = UserInfo::findOrNew($userId);
     $userInfo->id = $userId;
     $userInfo->user_account = $userAccount;
     $userInfo->nick_name = $nickName;
     $userInfo->head_icon = $headIcon;
     $userInfo->save();
     return $response->toJson();
 }
コード例 #12
0
 /**
 *
 * @SWG\Api(
 *   path="/present_coupon",
 *   description="赠送礼券(新20160220)",
 *   @SWG\Operation(
 *     method="POST", summary="赠送礼券", notes="赠送礼券,sum值-1 是未填写收货地址 -2是已经赠送过 -3是关闭赠送  非负是 赠送成功
     ",
 *     @SWG\ResponseMessage(code=0, message="成功"),
 *     @SWG\Parameter(
 *         name="user_id",
 *         description="用户id",
 *         paramType="query",
 *         required=true,
 *         allowMultiple=false,
 *         type="integer"
 *     ),@SWG\Parameter(
 *         name="access_token",
 *         description="accessToken",
 *         paramType="query",
 *         required=true,
 *         allowMultiple=false,
 *         type="string"
 *     ),@SWG\Parameter(
 *         name="account",
 *         description="用户账号",
 *         paramType="query",
 *         required=true,
 *         allowMultiple=false,
 *         type="string"
 *     ),@SWG\Parameter(
 *         name="type",
 *         description="类型,1--》注册赠送礼券,2---》完善资料赠送",
 *         paramType="query",
 *         required=true,
 *         allowMultiple=false,
 *         type="string"
 *     )
 *   )
 * )
 */
 public function store(Request $request)
 {
     $response = new BaseResponse();
     $user_id = $request->input('user_id', -1);
     $account = $request->input('account');
     $type = $request->input('type');
     $accessToken = $request->input('access_token');
     if ($user_id != -1 || $user_id != 0) {
         //检测是否赠送过
         $hasRecords = PresentCouponRecords::where('user_id', $user_id)->where('type', $type)->first();
         $shippingAddress = ShippingAddress::where('user_id', $user_id)->first();
         if ($type == 2 && $shippingAddress == null) {
             //未填写收货地址
             $ret['sum'] = -1;
             $response->Data = $ret;
             return $response->toJson();
         }
         if ($hasRecords != null) {
             $ret['sum'] = -2;
             $response->Data = $ret;
             return $response->toJson();
         }
         $giftTokenSetting = GiftTokenSetting::find($type);
         if ($giftTokenSetting != null && $giftTokenSetting->status == 1) {
             //赠送礼券接口
             $apiParam = ['accessToken' => $accessToken, 'coupon' => $giftTokenSetting->sum, 'expiry' => date('Y-m-d H:i:s', strtotime('+3 month'))];
             $this->post($apiParam);
             //存储记录
             $couponRecrods = new PresentCouponRecords();
             $couponRecrods->user_id = $user_id;
             $couponRecrods->account = $account;
             $couponRecrods->sum = $giftTokenSetting->sum;
             $couponRecrods->type = $type;
             $couponRecrods->save();
             $ret['sum'] = $giftTokenSetting->sum;
             $response->Data = $ret;
         } else {
             $ret['sum'] = -3;
             $response->Data = $ret;
             return $response->toJson();
         }
     }
     return $response->toJson();
 }
コード例 #13
0
ファイル: CheckInController.php プロジェクト: Lazybin/huisa
 /**
  *
  * @SWG\Api(
  *   path="/check_in",
  *   description="普通签到(新20160218)",
  *   @SWG\Operation(
  *     method="POST", summary="签到", notes="签到,如果已经签过到或者没有登录,data=0,如果签到成功data=1",
  *     @SWG\ResponseMessage(code=0, message="成功"),
  *     @SWG\Parameter(
  *         name="user_id",
  *         description="用户id",
  *         paramType="query",
  *         required=true,
  *         allowMultiple=false,
  *         type="integer"
  *     ),@SWG\Parameter(
  *         name="access_token",
  *         description="accessToken",
  *         paramType="query",
  *         required=true,
  *         allowMultiple=false,
  *         type="string"
  *     ),@SWG\Parameter(
  *         name="account",
  *         description="用户账号",
  *         paramType="query",
  *         required=true,
  *         allowMultiple=false,
  *         type="string"
  *     )
  *   )
  * )
  */
 public function store(Request $request)
 {
     $response = new BaseResponse();
     $user_id = $request->input('user_id', -1);
     $account = $request->input('account');
     $accessToken = $request->input('access_token');
     $ret['result'] = 0;
     $response->Data = $ret;
     if ($user_id != -1 || $user_id != 0) {
         $t = time();
         $start = mktime(0, 0, 0, date("m", $t), date("d", $t), date("Y", $t));
         $end = mktime(23, 59, 59, date("m", $t), date("d", $t), date("Y", $t));
         $today = CheckInRecords::where('user_id', $user_id)->where('created_at', '>=', date('Y-m-d H:i:s', $start))->where('created_at', '<=', date('Y-m-d H:i:s', $end))->first();
         if ($today == null) {
             $records = new CheckInRecords();
             $records->user_id = $user_id;
             $records->save();
             $ret['result'] = 1;
             //签到成功,赠送礼券
             $giftTokenSetting = GiftTokenSetting::find(3);
             if ($giftTokenSetting != null && $giftTokenSetting->status == 1) {
                 //赠送礼券接口
                 $apiParam = ['accessToken' => $accessToken, 'coupon' => $giftTokenSetting->sum, 'expiry' => date('Y-m-d H:i:s', strtotime('+3 month'))];
                 $this->post($apiParam);
                 //存储记录
                 $couponRecrods = new PresentCouponRecords();
                 $couponRecrods->user_id = $user_id;
                 $couponRecrods->account = $account;
                 $couponRecrods->sum = $giftTokenSetting->sum;
                 $couponRecrods->type = 3;
                 $couponRecrods->save();
             }
             $response->Data = $ret;
         }
     }
     return $response->toJson();
 }
コード例 #14
0
ファイル: OrdersController.php プロジェクト: Lazybin/huisa
 /**
  *
  * @SWG\Api(
  *   path="/orders/{out_trade_no}",
  *   @SWG\Operation(
  *     method="DELETE", summary="删除订单", notes="删除订单",
  *     @SWG\ResponseMessage(code=0, message="成功"),
  *     @SWG\Parameter(
  *         name="out_trade_no",
  *         description="订单号",
  *         paramType="path",
  *         required=true,
  *         type="string"
  *     ),
  *   )
  * )
  */
 public function destroy($out_trade_no)
 {
     $response = new BaseResponse();
     $order = Order::where('out_trade_no', $out_trade_no)->first();
     if ($order != null) {
         $order->delete_at = date("Y-m-d H:i:s", time());
         $order->save();
     }
     return $response->toJson();
 }
コード例 #15
0
 /**
  *
  * @SWG\Api(
  *   path="/shipping_address/{id}",
  *   @SWG\Operation(
  *     method="DELETE", summary="删除地址", notes="删除地址",
  *     @SWG\ResponseMessage(code=0, message="成功"),
  *     @SWG\Parameter(
  *         name="id",
  *         description="地址id",
  *         paramType="path",
  *         required=true,
  *         type="integer"
  *     )
  *   )
  * )
  */
 public function destroy($id)
 {
     $response = new BaseResponse();
     $shoppingCart = ShippingAddress::find($id);
     if ($shoppingCart != null) {
         $shoppingCart->delete();
     }
     return $response->toJson();
 }
コード例 #16
0
 public function destroy($id)
 {
     $response = new BaseResponse();
     $order = Collection::find($id);
     if ($order != null) {
         $order->delete();
     }
     return $response->toJson();
 }
コード例 #17
0
ファイル: RefundsController.php プロジェクト: Lazybin/huisa
 /**
  *
  * @SWG\Api(
  *   path="/refunds/both_refund",
  *   @SWG\Operation(
  *     method="POST", summary="已发货退货退款", notes="申请退款",
  *     @SWG\ResponseMessage(code=0, message="成功"),
  *     @SWG\Parameter(
  *         name="refunds_info",
  *         description="提交的退款信息",
  *         paramType="body",
  *         required=true,
  *         type="Refund1"
  *     )
  *   )
  * )
  */
 public function bothRefund(Request $request)
 {
     $response = new BaseResponse();
     $content = json_decode($request->getContent(false));
     $this->dealImage($content);
     $content->type = 2;
     $refund = Refund::create((array) $content);
     if (!$this->dealOrder($content, $refund)) {
         return (new BaseResponse(BaseResponse::CODE_ERROR_BUSINESS, '订单状态错误'))->toJson();
     } else {
         return $response->toJson();
     }
 }
コード例 #18
0
ファイル: SearchController.php プロジェクト: Lazybin/huisa
 /**
  *
  * @SWG\Api(
  *   path="/search/get_search_records",
  *   @SWG\Operation(
  *     method="GET", summary="获得最近搜索记录", notes="获得最近搜索记录",
  *     type="SearchRecords",
  *     @SWG\ResponseMessage(code=0, message="成功"),
  *     @SWG\Parameter(
  *         name="user_id",
  *         description="用户id",
  *         paramType="query",
  *         required=false,
  *         allowMultiple=false,
  *         type="integer",
  *         defaultValue=-1
  *     ),@SWG\Parameter(
  *         name="device_token",
  *         description="设备号",
  *         paramType="query",
  *         required=true,
  *         allowMultiple=false,
  *         type="integer"
  *     )
  *   )
  * )
  */
 public function getSearchRecords(Request $request)
 {
     $user_id = $request->input('user_id', -1);
     $device_token = $request->input('device_token');
     $response = new BaseResponse();
     $ret = [];
     $ret['hot'] = SearchRecords::select(DB::raw('count(*) as search_times'), 'keywords')->groupBy('keywords')->orderBy('search_times', 'desc')->limit(8)->get();
     if ($user_id != -1 && $user_id != 0) {
         $ret['self_last'] = SearchRecords::where('user_id', $user_id)->select('keywords')->groupBy('keywords')->orderBy('created_at', 'desc')->limit(4)->get();
     } else {
         $ret['self_last'] = SearchRecords::where('device_token', $device_token)->select('keywords')->groupBy('keywords')->orderBy('created_at', 'desc')->limit(4)->get();
     }
     $response->Data = $ret;
     return $response->toJson();
 }
コード例 #19
0
 /**
  *
  * @SWG\Api(
  *   path="/shopping_cart/delete",
  *   @SWG\Operation(
  *     method="POST", summary="删除购物车", notes="删除购物车",
  *     @SWG\ResponseMessage(code=0, message="成功"),
  *     @SWG\Parameter(
  *         name="goods_list",
  *         description="要修改的商品列表",
  *         paramType="body",
  *         required=true,
  *         type="deleteShoppingCartParams"
  *     )
  *   )
  * )
  */
 public function delete(Request $request)
 {
     $response = new BaseResponse();
     $content = json_decode($request->getContent(false));
     $content = $content->goods_list;
     foreach ($content as $v) {
         $shoppingCart = ShoppingCart::find($v->id);
         if ($shoppingCart != null) {
             $shoppingCart->delete();
         }
     }
     return $response->toJson();
 }
コード例 #20
0
 /**
  *
  * @SWG\Api(
  *   path="/activity_classifications/{id}",
  *   @SWG\Operation(
  *     method="GET", summary="获得分类详情", notes="获得分类详情",
  *     type="array",
  *     @SWG\Items("ActivityClassificationGoods"),
  *     @SWG\ResponseMessage(code=0, message="成功"),
  *     @SWG\Parameter(
  *         name="id",
  *         description="分类id",
  *         paramType="path",
  *         required=true,
  *         allowMultiple=false,
  *         type="integer",
  *     ),@SWG\Parameter(
  *         name="PageNum",
  *         description="分页开始位置",
  *         paramType="query",
  *         required=false,
  *         allowMultiple=false,
  *         type="integer",
  *         defaultValue=1
  *     ),@SWG\Parameter(
  *         name="PerPage",
  *         description="取得长度",
  *         paramType="query",
  *         required=false,
  *         allowMultiple=false,
  *         type="integer",
  *         defaultValue=10
  *     )
  *
  *   )
  * )
  */
 public function show(Request $request, $id)
 {
     $start = $request->input('PageNum', 0);
     $length = $request->input('PerPage', 5);
     $start = ($start - 1) * $length;
     $response = new BaseResponse();
     $goods_list = ActivityClassificationGoods::where('activity_classification_id', $id);
     $total = $goods_list->count();
     $goods_list = $goods_list->skip($start)->take($length)->orderBy('id', 'desc');
     $response->rows = $goods_list->get();
     $response->total = $total;
     return $response->toJson();
 }
コード例 #21
0
 /**
  *
  * @SWG\Api(
  *   path="/comments/{id}",
  *   @SWG\Operation(
  *     method="DELETE", summary="删除评论", notes="删除评论",
  *     @SWG\ResponseMessage(code=0, message="成功"),
  *     @SWG\Parameter(
  *         name="id",
  *         description="评论id",
  *         paramType="path",
  *         required=true,
  *         type="integer"
  *     )
  *   )
  * )
  */
 public function destroy($id)
 {
     $response = new BaseResponse();
     $comment = UserComment::find($id);
     if ($comment != null) {
         $comment->delete();
     }
     return $response->toJson();
 }
コード例 #22
0
ファイル: GoodsController.php プロジェクト: Lazybin/huisa
 /**
  *
  * @SWG\Api(
  *   path="/goods/{id}",
  *   @SWG\Operation(
  *     method="PUT", summary="更新分享次数", notes="更新分享次数",
  *     @SWG\ResponseMessage(code=0, message="成功"),
  *     @SWG\Parameter(
  *         name="id",
  *         description="商品id",
  *         paramType="path",
  *         required=true,
  *         type="string"
  *     )
  *   )
  * )
  */
 public function update(Request $request, $id)
 {
     $response = new BaseResponse();
     $goods = Goods::find($id);
     if ($goods != null) {
         $goods->share_times = $goods->share_times + 1;
         $goods->save();
     }
     return $response->toJson();
 }
コード例 #23
0
ファイル: HomeController.php プロジェクト: Lazybin/huisa
 /**
  *
  * @SWG\Api(
  *   path="/home/{id}",
  *   description="获取首页项详情",
  *   @SWG\Operation(
  *     method="GET", summary="获得主题详情", notes="获得主题详情",
  *     type="Home",
  *     @SWG\ResponseMessage(code=0, message="成功"),
  *     @SWG\Parameter(
  *         name="id",
  *         description="id",
  *         paramType="path",
  *         required=true,
  *         allowMultiple=false,
  *         type="integer",
  *     ),@SWG\Parameter(
  *         name="device_token",
  *         description="设备号",
  *         paramType="query",
  *         required=true,
  *         allowMultiple=false,
  *         type="integer"
  *     ),@SWG\Parameter(
  *         name="user_id",
  *         description="用户id",
  *         paramType="query",
  *         required=false,
  *         allowMultiple=false,
  *         type="integer",
  *         defaultValue=-1
  *     ),
  *
  *   )
  * )
  */
 public function show(Request $request, $id)
 {
     //
     $response = new BaseResponse();
     $user_id = $request->input('user_id', -1);
     $device_token = $request->input('device_token', '');
     $home = Home::find($id);
     if ($home == null) {
         $response->Code = BaseResponse::CODE_ERROR_BUSINESS;
         $response->Message = '数据不存在';
         return $response->toJson();
     }
     if ($device_token != '') {
         $readRecords = new ReadRecords();
         $readRecords->device_token = $device_token;
         $readRecords->home_id = $id;
         $readRecords->save();
     }
     $home = $home->toArray();
     if ($home['type'] == 1) {
         $home['has_collection'] = 0;
         if ($user_id != -1) {
             $collection = Collection::where('user_id', $user_id)->where('type', 1)->where('item_id', $home['item_id'])->first();
             if ($collection != null) {
                 $home['has_collection'] = 1;
             }
         }
         $comments = UserComment::select('user_comments.*', 'user_infos.nick_name', 'user_infos.head_icon')->leftJoin('user_infos', 'user_infos.id', '=', 'user_comments.user_id')->where('user_comments.type', 1)->where('user_comments.item_id', $home['item']['id']);
         $rows = $comments->skip(0)->take(10)->orderBy('id', 'desc')->get()->toArray();
         foreach ($rows as &$v) {
             //$v['']
             $sum = Order::select(DB::raw('SUM(total_fee) as total_pay'))->where('user_id', $v['user_id'])->where('status', 4)->first()->toArray();
             if ($sum == null || $sum['total_pay'] == null) {
                 $sum = 0;
             } else {
                 $sum = $sum['total_pay'];
             }
             $level = UserLevel::where('sum_lowest', '<=', $sum)->where('sum_highest', '>', $sum)->first()->toArray();
             //var_dump($level);exit;
             $v['level'] = $level['name'];
         }
         $home['comments'] = $rows;
     }
     $response->Data = $home;
     return $response->toJson();
 }