|
@@ -316,14 +316,14 @@ class HomeController extends Controller
|
|
* @apiGroup Photo
|
|
* @apiGroup Photo
|
|
* @apiPermission None
|
|
* @apiPermission None
|
|
* @apiVersion 0.1.0
|
|
* @apiVersion 0.1.0
|
|
- * @apiParam {string} user_id user_id
|
|
|
|
- * @apiParam {string} store_id 预约得店铺ID
|
|
|
|
- * @apiParam {string} product_id 产品规格ID
|
|
|
|
|
|
+ * @apiParam {int} user_id user_id
|
|
|
|
+ * @apiParam {int} store_id 预约店铺ID
|
|
|
|
+ * @apiParam {int} product_id 产品规格ID
|
|
* @apiParam {string} schedule_time 预约时间
|
|
* @apiParam {string} schedule_time 预约时间
|
|
* @apiParam {string} username 到店人姓名
|
|
* @apiParam {string} username 到店人姓名
|
|
* @apiParam {string} phone 联系方式
|
|
* @apiParam {string} phone 联系方式
|
|
* @apiParam {string} email 邮箱(接受照片用)
|
|
* @apiParam {string} email 邮箱(接受照片用)
|
|
- * @apiParam {string} sex 性别
|
|
|
|
|
|
+ * @apiParam {int} sex 性别 (0:男;1:女)
|
|
* @apiParam {string} [comment] 备注
|
|
* @apiParam {string} [comment] 备注
|
|
* @apiSuccessExample {json} Success-Response:
|
|
* @apiSuccessExample {json} Success-Response:
|
|
* HTTP/1.1 200 OK
|
|
* HTTP/1.1 200 OK
|
|
@@ -347,6 +347,7 @@ class HomeController extends Controller
|
|
* "price": 199, //应付金额
|
|
* "price": 199, //应付金额
|
|
* "deposit": 100 //定金
|
|
* "deposit": 100 //定金
|
|
* }
|
|
* }
|
|
|
|
+ * }
|
|
*
|
|
*
|
|
* }
|
|
* }
|
|
* @apiErrorExample {json} Error-Response:
|
|
* @apiErrorExample {json} Error-Response:
|
|
@@ -420,6 +421,158 @@ class HomeController extends Controller
|
|
return $this->api(compact('order'));
|
|
return $this->api(compact('order'));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * @api {get} /api/home/myorders 我的订单
|
|
|
|
+ * @apiDescription 我的订单
|
|
|
|
+ * @apiGroup Photo
|
|
|
|
+ * @apiPermission None
|
|
|
|
+ * @apiVersion 0.1.0
|
|
|
|
+ * @apiParam {int} user_id user_id
|
|
|
|
+ * @apiParam {int} [status] 订单状态:1:已付款,未完成拍摄;2:拍摄完成;3:已取消
|
|
|
|
+ * @apiSuccessExample {json} Success-Response:
|
|
|
|
+ * HTTP/1.1 200 OK
|
|
|
|
+ * {
|
|
|
|
+ * "state": true,
|
|
|
|
+ * "code": 0,
|
|
|
|
+ * "message": "",
|
|
|
|
+ * "data": {
|
|
|
|
+ * "orders": [
|
|
|
|
+ * {
|
|
|
|
+ * "id": 6,
|
|
|
|
+ * "out_trade_no": "s10006", //订单号
|
|
|
|
+ * "username": "lee",
|
|
|
|
+ * "schedule_time": "2018-07-19 11:00:00", //预约时间
|
|
|
|
+ * "product_id": 1,
|
|
|
|
+ * "status": 1, //订单状态
|
|
|
|
+ * "store_id": "1",
|
|
|
|
+ * "storename": "青羊店", //店铺名称
|
|
|
|
+ * "product_name": "证件照" //产品名称
|
|
|
|
+ * },
|
|
|
|
+ * {
|
|
|
|
+ * "id": 7,
|
|
|
|
+ * "out_trade_no": "s10007",
|
|
|
|
+ * "username": "lee",
|
|
|
|
+ * "schedule_time": "2018-07-19 11:00:00",
|
|
|
|
+ * "product_id": 1,
|
|
|
|
+ * "status": 3,
|
|
|
|
+ * "store_id": "1",
|
|
|
|
+ * "storename": "青羊店",
|
|
|
|
+ * "product_name": "证件照"
|
|
|
|
+ * }
|
|
|
|
+ * ]
|
|
|
|
+ * }
|
|
|
|
+ * }
|
|
|
|
+ * @apiErrorExample {json} Error-Response:
|
|
|
|
+ * HTTP/1.1 400 Bad Request
|
|
|
|
+ * {
|
|
|
|
+ * "state": false,
|
|
|
|
+ * "code": 1000,
|
|
|
|
+ * "message": "传入参数不正确",
|
|
|
|
+ * "data": null or []
|
|
|
|
+ * }
|
|
|
|
+ */
|
|
|
|
+ public function myOrders(Request $request)
|
|
|
|
+ {
|
|
|
|
+ $validator = Validator::make($request->all(),
|
|
|
|
+ [
|
|
|
|
+ 'user_id' => 'required',
|
|
|
|
+ ],
|
|
|
|
+ [
|
|
|
|
+ 'user_id.required' => 'user_id不能为空!',
|
|
|
|
+ ]
|
|
|
|
+ );
|
|
|
|
+ if ($validator->fails()) {
|
|
|
|
+ return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (request('status')) {
|
|
|
|
+ $orders = OrderInfoModel::where('user_id', request('user_id'))->where('status', request('status'))->get(['id', 'out_trade_no', 'username', 'schedule_time', 'product_id', 'status', 'store_id']);
|
|
|
|
+ } else {
|
|
|
|
+ $orders = OrderInfoModel::where('user_id', request('user_id'))->where('status', '>', 0)->get();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ foreach ($orders as $order) {
|
|
|
|
+ $store = $order->store();
|
|
|
|
+ $product = ProductInfoModel::find($order->product_id);
|
|
|
|
+
|
|
|
|
+ $order['storename'] = $store;
|
|
|
|
+ $order['product_name'] = $product->name;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ return $this->api(compact('orders'));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @api {get} /api/home/order 获取订单详情
|
|
|
|
+ * @apiDescription 获取订单详情
|
|
|
|
+ * @apiGroup Photo
|
|
|
|
+ * @apiPermission None
|
|
|
|
+ * @apiVersion 0.1.0
|
|
|
|
+ * @apiParam {int} user_id user_id
|
|
|
|
+ * @apiParam {int} order_id 订单ID
|
|
|
|
+ * @apiSuccessExample {json} Success-Response:
|
|
|
|
+ * HTTP/1.1 200 OK
|
|
|
|
+ * {
|
|
|
|
+ * "state": true,
|
|
|
|
+ * "code": 0,
|
|
|
|
+ * "message": "",
|
|
|
|
+ * "data": {
|
|
|
|
+ * "order": {
|
|
|
|
+ * "id": 27,
|
|
|
|
+ * "out_trade_no": "xxg1531993028", //订单编号
|
|
|
|
+ * "username": "lee", //联系人
|
|
|
|
+ * "phone": "13407570876", //联系电话
|
|
|
|
+ * "email": "154@qq.com", //邮箱
|
|
|
|
+ * "schedule_time": "2018-07-19 11:00:00", //预约时间
|
|
|
|
+ * "status": 0,
|
|
|
|
+ * "store_id": "1",
|
|
|
|
+ * "storename": "青羊店", //店铺名称
|
|
|
|
+ * "product_name": "证件照", //产品名称
|
|
|
|
+ * "service_time": "约120分钟", //服务时长
|
|
|
|
+ * "price": 199, //应付金额
|
|
|
|
+ * "deposit": 100 //定金
|
|
|
|
+ * }
|
|
|
|
+ * }
|
|
|
|
+ *
|
|
|
|
+ * }
|
|
|
|
+ * @apiErrorExample {json} Error-Response:
|
|
|
|
+ * HTTP/1.1 400 Bad Request
|
|
|
|
+ * {
|
|
|
|
+ * "state": false,
|
|
|
|
+ * "code": 1000,
|
|
|
|
+ * "message": "传入参数不正确",
|
|
|
|
+ * "data": null or []
|
|
|
|
+ * }
|
|
|
|
+ */
|
|
|
|
+ public function orderDetail(Request $request){
|
|
|
|
+ $validator = Validator::make($request->all(),
|
|
|
|
+ [
|
|
|
|
+ 'user_id' => 'required',
|
|
|
|
+ 'order_id' => 'required',
|
|
|
|
+ ],
|
|
|
|
+ [
|
|
|
|
+ 'user_id.required' => 'user_id不能为空!',
|
|
|
|
+ 'order_id.required' => 'user_id不能为空!',
|
|
|
|
+ ]
|
|
|
|
+ );
|
|
|
|
+ if ($validator->fails()) {
|
|
|
|
+ return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $order = OrderInfoModel::select(['id', 'out_trade_no', 'username', 'phone', 'email', 'schedule_time', 'status', 'store_id', 'price', 'deposit'])->find(request('order_id'));
|
|
|
|
+ $store = $order->store();
|
|
|
|
+ $product = ProductInfoModel::find(request($order->product_id))->first();
|
|
|
|
+
|
|
|
|
+ $order['storename'] = $store;
|
|
|
|
+ $order['product_name'] = $product->name;
|
|
|
|
+ $order['service_time'] = $product->service_time;
|
|
|
|
+
|
|
|
|
+ return $this->api(compact('order'));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @api {post} /api/home/pay 获取微信支付签名信息
|
|
* @api {post} /api/home/pay 获取微信支付签名信息
|
|
* @apiDescription 获取微信支付签名信息
|
|
* @apiDescription 获取微信支付签名信息
|
|
@@ -484,7 +637,7 @@ class HomeController extends Controller
|
|
$app = Factory::payment($this->options());
|
|
$app = Factory::payment($this->options());
|
|
|
|
|
|
$result = $app->order->unify([
|
|
$result = $app->order->unify([
|
|
- 'body' => '高考志愿助手 - 付费查询',
|
|
|
|
|
|
+ 'body' => '',
|
|
'out_trade_no' => $order->out_trade_no,
|
|
'out_trade_no' => $order->out_trade_no,
|
|
'total_fee' => $money * 100,
|
|
'total_fee' => $money * 100,
|
|
'trade_type' => 'JSAPI',
|
|
'trade_type' => 'JSAPI',
|
|
@@ -769,6 +922,177 @@ class HomeController extends Controller
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @api {get} /api/home/usablecoupon 获取订单可用的优惠券
|
|
|
|
+ * @apiDescription 获取订单可用的优惠券
|
|
|
|
+ * @apiGroup Photo
|
|
|
|
+ * @apiPermission none
|
|
|
|
+ * @apiVersion 0.1.0
|
|
|
|
+ * @apiParam {int} user_id 用户ID
|
|
|
|
+ * @apiParam {int} product_id 产品规格ID,订单中获取
|
|
|
|
+ * @apiSuccessExample {json} Success-Response:
|
|
|
|
+ * HTTP/1.1 200 OK
|
|
|
|
+ * {
|
|
|
|
+ * "status": true,
|
|
|
|
+ * "status_code": 0,
|
|
|
|
+ * "message": "",
|
|
|
|
+ * "data": {
|
|
|
|
+ * "usablecoupons": [
|
|
|
|
+ * {
|
|
|
|
+ * "id": 1,
|
|
|
|
+ * "coupon_id": 1,
|
|
|
|
+ * "user_id": 1,
|
|
|
|
+ * "coupon": {
|
|
|
|
+ * "id": 1,
|
|
|
|
+ * "name": "证件照七折优惠",
|
|
|
|
+ * "type": "1",
|
|
|
|
+ * "min_price": 100,
|
|
|
|
+ * "discount": "7",
|
|
|
|
+ * "discount_price": null,
|
|
|
|
+ * "product_id": "1,2",
|
|
|
|
+ * "count": 7,
|
|
|
|
+ * "end_time": "2018-07-31",
|
|
|
|
+ * "created_at": "2018-07-13 07:29:27",
|
|
|
|
+ * "updated_at": "2018-07-21 07:41:59"
|
|
|
|
+ * }
|
|
|
|
+ * }
|
|
|
|
+ * ]
|
|
|
|
+ * }
|
|
|
|
+ * }
|
|
|
|
+ * @apiErrorExample {json} Error-Response:
|
|
|
|
+ * HTTP/1.1 400 Bad Request
|
|
|
|
+ * {
|
|
|
|
+ * "state": false,
|
|
|
|
+ * "code": 1000,
|
|
|
|
+ * "message": "传入参数不正确",
|
|
|
|
+ * "data": null or []
|
|
|
|
+ * }
|
|
|
|
+ * 可能出现的错误代码:
|
|
|
|
+ * 1000 CLIENT_WRONG_PARAMS 传入参数不正确
|
|
|
|
+ */
|
|
|
|
+ public function usableCoupon(Request $request)
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ $validator = Validator::make($request->all(),
|
|
|
|
+ [
|
|
|
|
+ 'user_id' => 'required',
|
|
|
|
+ 'product_id' => 'required'
|
|
|
|
+
|
|
|
|
+ ],
|
|
|
|
+ [
|
|
|
|
+ 'user_id.required' => 'user_id不能为空!',
|
|
|
|
+ 'product_id.required' => 'product_id不能为空!'
|
|
|
|
+ ]
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ if ($validator->fails()) {
|
|
|
|
+ return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $mycoupons = UserCouponRelationModel::where('user_id', request('user_id'))->with('coupon')->orderBy('created_at', 'desc')->get();
|
|
|
|
+ $usablecoupons = $mycoupons->filter(function ($value) {
|
|
|
|
+ $flag = false;
|
|
|
|
+
|
|
|
|
+ $product = ProductInfoModel::find(request('product_id'));
|
|
|
|
+ $products = explode(',', $value->coupon->product_id);
|
|
|
|
+
|
|
|
|
+ if ((strtotime($value->coupon->end_time) > strtotime(Carbon::now('Asia/Shanghai'))) && in_array($product->category_id, $products)) {
|
|
|
|
+ $flag = true;
|
|
|
|
+ } else {
|
|
|
|
+ $flag = false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return $flag;
|
|
|
|
+
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ return $this->api(compact('usablecoupons'));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @api {get} /api/home/refund 申请退款
|
|
|
|
+ * @apiDescription 申请退款
|
|
|
|
+ * @apiGroup Photo
|
|
|
|
+ * @apiPermission none
|
|
|
|
+ * @apiVersion 0.1.0
|
|
|
|
+ * @apiParam {int} user_id 用户ID
|
|
|
|
+ * @apiParam {int} order_id 产品规格ID,订单中获取
|
|
|
|
+ * @apiSuccessExample {json} Success-Response:
|
|
|
|
+ * HTTP/1.1 200 OK
|
|
|
|
+ * {
|
|
|
|
+ * "status": true,
|
|
|
|
+ * "status_code": 0,
|
|
|
|
+ * "message": "",
|
|
|
|
+ * "data": {
|
|
|
|
+ * "code": 200,
|
|
|
|
+ * "msg": "退款已申请,请等待商家审核!"
|
|
|
|
+ * }
|
|
|
|
+ * }
|
|
|
|
+ * @apiErrorExample {json} Error-Response:
|
|
|
|
+ * HTTP/1.1 400 Bad Request
|
|
|
|
+ * {
|
|
|
|
+ * "state": false,
|
|
|
|
+ * "code": 1000,
|
|
|
|
+ * "message": "传入参数不正确",
|
|
|
|
+ * "data": null or []
|
|
|
|
+ * }
|
|
|
|
+ *
|
|
|
|
+ * {
|
|
|
|
+ * "status": true,
|
|
|
|
+ * "status_code": 0,
|
|
|
|
+ * "message": "",
|
|
|
|
+ * "data": {
|
|
|
|
+ * "code": 10003,
|
|
|
|
+ * "msg": "该订单不能退款,如有疑问,请联系商家!"
|
|
|
|
+ * }
|
|
|
|
+ * }
|
|
|
|
+ * 可能出现的错误代码:
|
|
|
|
+ * 1000 CLIENT_WRONG_PARAMS 传入参数不正确
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+ public function refund(Request $request)
|
|
|
|
+ {
|
|
|
|
+ $validator = Validator::make($request->all(),
|
|
|
|
+ [
|
|
|
|
+ 'user_id' => 'required',
|
|
|
|
+ 'order_id' => 'required'
|
|
|
|
+
|
|
|
|
+ ],
|
|
|
|
+ [
|
|
|
|
+ 'user_id.required' => 'user_id不能为空!',
|
|
|
|
+ 'order_id.required' => 'order_id不能为空!'
|
|
|
|
+ ]
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ if ($validator->fails()) {
|
|
|
|
+ return $this->error(ErrorCode::CLIENT_WRONG_PARAMS, '传入参数不正确!', $validator->messages());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $order = OrderInfoModel::find(request('order_id'));
|
|
|
|
+ if ($order->status != 1) {
|
|
|
|
+ $data = [
|
|
|
|
+ 'code' => 10003,
|
|
|
|
+ 'msg' => '该订单不能退款,如有疑问,请联系商家!'
|
|
|
|
+ ];
|
|
|
|
+ return $this->api($data);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $order->status = 3;
|
|
|
|
+ $ok = $order->save();
|
|
|
|
+ if ($ok) {
|
|
|
|
+ $data = [
|
|
|
|
+ 'code' => 200,
|
|
|
|
+ 'msg' => '退款已申请,请等待商家审核!'
|
|
|
|
+ ];
|
|
|
|
+ return $this->api($data);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
//格式化排期
|
|
//格式化排期
|
|
function cut_time_part($start, $end, $min = 30, $format = true)
|
|
function cut_time_part($start, $end, $min = 30, $format = true)
|
|
{
|
|
{
|