| xqd
@@ -15,6 +15,9 @@ use App\Models\AlbumReviewModel;
|
|
|
use App\Models\AlbumUserModel;
|
|
|
use App\Models\FurnitureFormidModel;
|
|
|
use App\Models\FurnitureGoodsModel;
|
|
|
+use App\Models\FurnitureNewgoodsBookingModel;
|
|
|
+use App\Models\FurnitureNewgoodsCommentModel;
|
|
|
+use App\Models\FurnitureNewgoodsInfoModel;
|
|
|
use App\Models\UserInfoModel;
|
|
|
use Carbon\Carbon;
|
|
|
use Illuminate\Http\Request;
|
| xqd
@@ -572,6 +575,334 @@ class FurnitureController extends Controller
|
|
|
return $this->api(compact('comments', 'comments_replys'));
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @api {get} /api/furniture/newgoods_list 新品发布列表
|
|
|
+ * @apiDescription 获取新品发布列表(news_list)
|
|
|
+ * @apiGroup Furniture
|
|
|
+ * @apiPermission none
|
|
|
+ * @apiVersion 0.1.0
|
|
|
+ * @apiParam {int} store_id 商户id 模拟值为1
|
|
|
+ * @apiSuccessExample {json} Success-Response:
|
|
|
+ * {
|
|
|
+ * "status": true,
|
|
|
+ * "status_code": 0,
|
|
|
+ * "message": "",
|
|
|
+ * "data": {
|
|
|
+ * "current_page": 1,
|
|
|
+ * "data": [
|
|
|
+ * {
|
|
|
+ * "id": 1, //id
|
|
|
+ * "title": "新品测试1", //标题
|
|
|
+ * "thumb": "https://t6.9026.com/upload/img/20181119/4ee5baa103921e9d40e1c291d3c64f29.jpg", //缩略图
|
|
|
+ * "content": "<p>这是一个新品测试</p>", //详情
|
|
|
+ * "comments_field_1": "外观", //用户自定义的评价字段
|
|
|
+ * "comments_field_2": "实用性",
|
|
|
+ * "comments_field_3": "质感",
|
|
|
+ * "comments_field_4": "舒适度",
|
|
|
+ * "sort": 100,
|
|
|
+ * "created_at": "2018-12-20 10:13:14",
|
|
|
+ * "updated_at": "2018-12-20 10:13:14",
|
|
|
+ * "store_id": 1,
|
|
|
+ * "comments_total": 2, //评价总量
|
|
|
+ * }
|
|
|
+ * ],
|
|
|
+ * "first_page_url": "http://local.furniture.com/api/furniture/newgoods_list?page=1",
|
|
|
+ * "from": 1,
|
|
|
+ * "last_page": 1,
|
|
|
+ * "last_page_url": "http://local.furniture.com/api/furniture/newgoods_list?page=1",
|
|
|
+ * "next_page_url": null,
|
|
|
+ * "path": "http://local.furniture.com/api/furniture/newgoods_list",
|
|
|
+ * "per_page": 10,
|
|
|
+ * "prev_page_url": null,
|
|
|
+ * "to": 1,
|
|
|
+ * "total": 1
|
|
|
+ * }
|
|
|
+ * }
|
|
|
+ * @apiErrorExample {json} Error-Response:
|
|
|
+ * HTTP/1.1 400 Bad Request
|
|
|
+ * {
|
|
|
+ * "state": false,
|
|
|
+ * "code": 1000,
|
|
|
+ * "message": "传入参数不正确",
|
|
|
+ * "data": null or []
|
|
|
+ * }
|
|
|
+ * 可能出现的错误代码:
|
|
|
+ * 1000 CLIENT_WRONG_PARAMS 传入参数不正确
|
|
|
+ */
|
|
|
+ public function newgoods_list(Request $request)
|
|
|
+ {
|
|
|
+ $validator = Validator::make($request->all(), [
|
|
|
+ 'store_id' => 'required',
|
|
|
+ ], [
|
|
|
+ 'store_id.required' => '店铺信息未知',
|
|
|
+ ]);
|
|
|
+ if ($validator->fails()) {
|
|
|
+ return $this->validatorError($validator->messages()->all(), ErrorCode::CLIENT_WRONG_PARAMS, '');
|
|
|
+ }
|
|
|
+
|
|
|
+ $store_id = $request->store_id;
|
|
|
+
|
|
|
+ $list = FurnitureNewgoodsInfoModel::where('store_id', $store_id)->orderBy('sort', 'desc')->paginate(10);
|
|
|
+ foreach ($list as $item) {
|
|
|
+ $item->comments_total = $item->comments->count();
|
|
|
+ }
|
|
|
+ return $this->api($list);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @api {get} /api/furniture/newgoods_index 新品发布详情
|
|
|
+ * @apiDescription 获取新品发布详情(news_index)
|
|
|
+ * @apiGroup Furniture
|
|
|
+ * @apiPermission none
|
|
|
+ * @apiVersion 0.1.0
|
|
|
+ * @apiParam {int} store_id 商户id 模拟值为1
|
|
|
+ * @apiParam {int} id 新品id 模拟值为1
|
|
|
+ * @apiSuccessExample {json} Success-Response:
|
|
|
+ * {
|
|
|
+ * "status": true,
|
|
|
+ * "status_code": 0,
|
|
|
+ * "message": "",
|
|
|
+ * "data": {
|
|
|
+ * "newgoods": {
|
|
|
+ * "id": 1,
|
|
|
+ * "title": "新品测试1", //标题
|
|
|
+ * "thumb": "https://t6.9026.com/upload/img/20181119/4ee5baa103921e9d40e1c291d3c64f29.jpg", //缩略图
|
|
|
+ * "content": "<p>这是一个新品测试</p>", //详情
|
|
|
+ * "comments_field_1": "外观", //评价1字段名称
|
|
|
+ * "comments_field_2": "实用性",
|
|
|
+ * "comments_field_3": "质感",
|
|
|
+ * "comments_field_4": "舒适度",
|
|
|
+ * "sort": 100,
|
|
|
+ * "created_at": "2018-12-20 10:13:14",
|
|
|
+ * "updated_at": "2018-12-20 10:13:14",
|
|
|
+ * "store_id": 1,
|
|
|
+ * "comments_avg_1": "5.0000", //字段1平均分
|
|
|
+ * "comments_avg_2": "4.0000",
|
|
|
+ * "comments_avg_3": "3.0000",
|
|
|
+ * "comments_avg_4": "3.0000"
|
|
|
+ * },
|
|
|
+ * "comments": [
|
|
|
+ * {
|
|
|
+ * "id": 2,
|
|
|
+ * "user_id": 152,
|
|
|
+ * "newgoods_id": 1,
|
|
|
+ * "comments_field_1": 5, //字段1评分
|
|
|
+ * "comments_field_2": 4,
|
|
|
+ * "comments_field_3": 3,
|
|
|
+ * "comments_field_4": 3,
|
|
|
+ * "content": "第一条评价", //评价详情
|
|
|
+ * "created_at": null,
|
|
|
+ * "updated_at": null,
|
|
|
+ * "store_id": 1,
|
|
|
+ * "username": "哈哈哈", //用户姓名
|
|
|
+ * "avatar": "https://wx.qlogo.cn/mmopen/vi_32/yx8xw9O4WzvbGFLlqyRRNiciaNKM8V2wiasXrPCGUdB26D060FXUeIwiaAVzoOMibXUE9jhPkLsUz1UIpaTv71mYM4A/132" //用户头像
|
|
|
+ * }
|
|
|
+ * ]
|
|
|
+ * }
|
|
|
+ * }
|
|
|
+ * @apiErrorExample {json} Error-Response:
|
|
|
+ * HTTP/1.1 400 Bad Request
|
|
|
+ * {
|
|
|
+ * "state": false,
|
|
|
+ * "code": 1000,
|
|
|
+ * "message": "传入参数不正确",
|
|
|
+ * "data": null or []
|
|
|
+ * }
|
|
|
+ * 可能出现的错误代码:
|
|
|
+ * 1000 CLIENT_WRONG_PARAMS 传入参数不正确
|
|
|
+ */
|
|
|
+ public function newgoods_index(Request $request)
|
|
|
+ {
|
|
|
+ $validator = Validator::make($request->all(), [
|
|
|
+ 'store_id' => 'required',
|
|
|
+ 'id' => 'required'
|
|
|
+ ], [
|
|
|
+ 'store_id.required' => '店铺信息未知',
|
|
|
+ 'id.required' => '新品ID未知',
|
|
|
+ ]);
|
|
|
+
|
|
|
+ if ($validator->fails()) {
|
|
|
+ return $this->validatorError($validator->messages()->all(), ErrorCode::CLIENT_WRONG_PARAMS, '');
|
|
|
+ }
|
|
|
+
|
|
|
+ $newgoods = FurnitureNewgoodsInfoModel::find($request->get('id'));
|
|
|
+ $comments = $newgoods->comments()->paginate(10);
|
|
|
+ foreach ($comments as $item) {
|
|
|
+ $item->username = $item->user->username;
|
|
|
+ $item->avatar = $item->user->avatar;
|
|
|
+ unset($item->user);
|
|
|
+ }
|
|
|
+
|
|
|
+ $newgoods->comments_avg_1 = FurnitureNewgoodsCommentModel::where('newgoods_id', $request->get('id'))->select(\DB::raw('AVG(comments_field_1) as field'))->first()->field;
|
|
|
+ $newgoods->comments_avg_2 = FurnitureNewgoodsCommentModel::where('newgoods_id', $request->get('id'))->select(\DB::raw('AVG(comments_field_2) as field'))->first()->field;
|
|
|
+ $newgoods->comments_avg_3 = FurnitureNewgoodsCommentModel::where('newgoods_id', $request->get('id'))->select(\DB::raw('AVG(comments_field_3) as field'))->first()->field;
|
|
|
+ $newgoods->comments_avg_4 = FurnitureNewgoodsCommentModel::where('newgoods_id', $request->get('id'))->select(\DB::raw('AVG(comments_field_4) as field'))->first()->field;
|
|
|
+ return $this->api(compact('newgoods', 'comments'));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @api {post} /api/furniture/newgoods_addcomment 添加评论
|
|
|
+ * @apiDescription 添加评论(newgoods_addcomment)
|
|
|
+ * @apiGroup Furniture
|
|
|
+ * @apiPermission none
|
|
|
+ * @apiVersion 0.1.0
|
|
|
+ * @apiParam {int} store_id 商户id 模拟值为1
|
|
|
+ * @apiParam {int} newgoods_id 新品id 模拟值为1
|
|
|
+ * @apiParam {int} comments_field_1 字段1评分 1-5
|
|
|
+ * @apiParam {int} comments_field_2 字段1评分 1-5
|
|
|
+ * @apiParam {int} comments_field_3 字段1评分 1-5
|
|
|
+ * @apiParam {int} comments_field_4 字段1评分 1-5
|
|
|
+ * @apiParam {string} [content] 评论详情
|
|
|
+ * @apiParam {array} [picture] 图片
|
|
|
+ * @apiSuccessExample {json} Success-Response:
|
|
|
+ * {
|
|
|
+ * "status": true,
|
|
|
+ * "status_code": 0,
|
|
|
+ * "message": "",
|
|
|
+ * "data": {
|
|
|
+ * "store_id": "1",
|
|
|
+ * "newgoods_id": "1",
|
|
|
+ * "comments_field_1": "3",
|
|
|
+ * "comments_field_2": "4",
|
|
|
+ * "comments_field_3": "5",
|
|
|
+ * "comments_field_4": "2",
|
|
|
+ * "user_id": 151,
|
|
|
+ * "updated_at": "2018-12-20 16:56:46",
|
|
|
+ * "created_at": "2018-12-20 16:56:46",
|
|
|
+ * "id": 3
|
|
|
+ * }
|
|
|
+ * }
|
|
|
+ * @apiErrorExample {json} Error-Response:
|
|
|
+ * HTTP/1.1 400 Bad Request
|
|
|
+ * {
|
|
|
+ * "state": false,
|
|
|
+ * "code": 1000,
|
|
|
+ * "message": "传入参数不正确",
|
|
|
+ * "data": null or []
|
|
|
+ * }
|
|
|
+ * 可能出现的错误代码:
|
|
|
+ * 1000 CLIENT_WRONG_PARAMS 传入参数不正确
|
|
|
+ */
|
|
|
+ public function newgoods_addcomment(Request $request)
|
|
|
+ {
|
|
|
+ $user = Auth('api')->user();
|
|
|
+ if (!$user) {
|
|
|
+ $data = [
|
|
|
+ 'code' => 401,
|
|
|
+ 'msg' => 'token已过期,请重新登录'
|
|
|
+ ];
|
|
|
+ return $this->api($data);
|
|
|
+ }
|
|
|
+ $validator = Validator::make($request->all(), [
|
|
|
+ 'store_id' => 'required',
|
|
|
+ 'newgoods_id' => 'required',
|
|
|
+ 'comments_field_1' => 'required',
|
|
|
+ 'comments_field_2' => 'required',
|
|
|
+ 'comments_field_3' => 'required',
|
|
|
+ 'comments_field_4' => 'required',
|
|
|
+ ], [
|
|
|
+ 'store_id.required' => '店铺信息未知',
|
|
|
+ 'newgoods_id.required' => '新品ID未知',
|
|
|
+ 'comments_field_1.required' => '字段1不能为空',
|
|
|
+ 'comments_field_2.required' => '字段2不能为空',
|
|
|
+ 'comments_field_3.required' => '字段3不能为空',
|
|
|
+ 'comments_field_4.required' => '字段4不能为空',
|
|
|
+ ]);
|
|
|
+
|
|
|
+ if ($validator->fails()) {
|
|
|
+ return $this->validatorError($validator->messages()->all(), ErrorCode::CLIENT_WRONG_PARAMS, '');
|
|
|
+ }
|
|
|
+ $data = $request->all();
|
|
|
+
|
|
|
+ if (isset($data['picture'])) {
|
|
|
+ $data['picture'] = implode(',', $data['picture']);
|
|
|
+ }
|
|
|
+ $data['user_id'] = $user->id;
|
|
|
+
|
|
|
+ $res = FurnitureNewgoodsCommentModel::create($data);
|
|
|
+
|
|
|
+ return $this->api($res);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @api {post} /api/furniture/newgoods_addbooking 添加预售
|
|
|
+ * @apiDescription 添加预售(newgoods_addbooking)
|
|
|
+ * @apiGroup Furniture
|
|
|
+ * @apiPermission none
|
|
|
+ * @apiVersion 0.1.0
|
|
|
+ * @apiParam {int} store_id 商户id 模拟值为1
|
|
|
+ * @apiParam {int} newgoods_id 新品id 模拟值为1
|
|
|
+ * @apiParam {int} phone 电话
|
|
|
+ * @apiParam {string} receiver_name 姓名
|
|
|
+ * @apiParam {string} receiver_address 地址
|
|
|
+ * @apiSuccessExample {json} Success-Response:
|
|
|
+ * {
|
|
|
+ * "status": true,
|
|
|
+ * "status_code": 0,
|
|
|
+ * "message": "",
|
|
|
+ * "data": {
|
|
|
+ * "store_id": "1",
|
|
|
+ * "newgoods_id": "1",
|
|
|
+ * "phone": 15178654534,
|
|
|
+ * "receiver_name": '陈',
|
|
|
+ * "receiver_address": '丽都路700好',
|
|
|
+ * "updated_at": "2018-12-20 16:56:46",
|
|
|
+ * "created_at": "2018-12-20 16:56:46",
|
|
|
+ * "id": 3
|
|
|
+ * }
|
|
|
+ * }
|
|
|
+ * @apiErrorExample {json} Error-Response:
|
|
|
+ * HTTP/1.1 400 Bad Request
|
|
|
+ * {
|
|
|
+ * "state": false,
|
|
|
+ * "code": 1000,
|
|
|
+ * "message": "传入参数不正确",
|
|
|
+ * "data": null or []
|
|
|
+ * }
|
|
|
+ * 可能出现的错误代码:
|
|
|
+ * 1000 CLIENT_WRONG_PARAMS 传入参数不正确
|
|
|
+ */
|
|
|
+ public function newgoods_addbooking(Request $request)
|
|
|
+ {
|
|
|
+ $user = Auth('api')->user();
|
|
|
+ if (!$user) {
|
|
|
+ $data = [
|
|
|
+ 'code' => 401,
|
|
|
+ 'msg' => 'token已过期,请重新登录'
|
|
|
+ ];
|
|
|
+ return $this->api($data);
|
|
|
+ }
|
|
|
+
|
|
|
+ $validator = Validator::make($request->all(), [
|
|
|
+ 'store_id' => 'required',
|
|
|
+ 'newgoods_id' => 'required',
|
|
|
+ 'phone' => 'required',
|
|
|
+ 'receiver_name' => 'required',
|
|
|
+ 'receiver_address' => 'required',
|
|
|
+
|
|
|
+ ], [
|
|
|
+ 'store_id.required' => '店铺信息未知',
|
|
|
+ 'newgoods_id.required' => '新品ID未知',
|
|
|
+ 'phone.required' => '电话号码不能为空',
|
|
|
+ 'receiver_name.required' => '收货人不能为空',
|
|
|
+ 'receiver_address.required' => '收货地址不能为空',
|
|
|
+
|
|
|
+ ]);
|
|
|
+
|
|
|
+ if ($validator->fails()) {
|
|
|
+ return $this->validatorError($validator->messages()->all(), ErrorCode::CLIENT_WRONG_PARAMS, '');
|
|
|
+ }
|
|
|
+ $data = $request->all();
|
|
|
+ $data['user_id'] = $user->id;
|
|
|
+
|
|
|
+ $res = FurnitureNewgoodsBookingModel::create($data);
|
|
|
+
|
|
|
+ return $this->api($res);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @api {get} /api/furniture/goods_list 获取产品列表
|
|
|
* @apiDescription 获取产品列表(goods_list)
|
| xqd
@@ -1977,7 +2308,7 @@ class FurnitureController extends Controller
|
|
|
if (count($parts)) {
|
|
|
$content .= "配件:";
|
|
|
foreach ($parts as $part) {
|
|
|
- $content .= "<C>".$part->name.'------'.$part->count . "</C><BR>";
|
|
|
+ $content .= "<C>" . $part->name . '------' . $part->count . "</C><BR>";
|
|
|
};
|
|
|
}
|
|
|
}
|
| xqd
@@ -2001,7 +2332,7 @@ class FurnitureController extends Controller
|
|
|
if (count($parts)) {
|
|
|
$content .= "配件:";
|
|
|
foreach ($parts as $part) {
|
|
|
- $content .= "<C>".$part->name.'------'.$part->count . "</C><BR>";
|
|
|
+ $content .= "<C>" . $part->name . '------' . $part->count . "</C><BR>";
|
|
|
};
|
|
|
}
|
|
|
$content .= "逾期时间:" . $order->expected_time . "<BR>";
|