/** * * @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(); }
public function update(Request $requests, $id) { $params = $requests->all(); $giftTokenSetting = GiftTokenSetting::find($id); if ($giftTokenSetting != null) { $giftTokenSetting->sum = $params['sum']; $giftTokenSetting->status = $params['status']; $giftTokenSetting->save(); $ret['meta']['code'] = 1; } return redirect()->action('Admin\\GiftTokenSettingController@show'); }
/** * * @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(); }
/** * * @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(); }