function LoginAction() { $User = array('esalonshop01' => 'salon01', 'esalonshop02' => 'salon02', 'esalonshop03' => 'salon03', 'esalonshop04' => 'salon04', 'esalonshop05' => 'salon05'); $UserName = \LfRequest::inStr("UserName"); $Password = \LfRequest::inStr("Password"); if (!isset($User[$UserName])) { $this->error("用户名或密码错误!"); exit; } if ($User[$UserName] != $Password) { $this->error("用户名或密码错误!"); exit; } session("used_shop", $UserName); cookie("used_shop", $UserName); $this->redirect("Coupon/Index"); }
public function useCoupon() { $id = \LfRequest::inNum('id'); $uid = \LfRequest::inNum('user_id'); $sid = \LfRequest::inNum('salon_id'); $address = \LfRequest::inStr('address'); // $password = \LfRequest::inStr('password'); // $hash = 'UESTC_ESALON_80'; // if(md5($password)!= md5($hash)) { // $this->error("密码错误,请重试!"); // exit(); // } $coupon = M('coupons')->find($id); if ($coupon['user_id'] != $uid) { $this->error('代金劵信息不符合,请确认'); } if ($coupon['salon_id'] != $sid) { $this->error('代金劵信息不符合,请确认'); } if ($coupon['is_used']) { $this->error('代金劵已经使用!'); } $data['is_used'] = 1; $data['used_at'] = time(); $data['used_where'] = $address; if (!empty(session('used_shop'))) { $used_shop = session('used_shop'); } if (!empty(cookie('used_shop'))) { $used_shop = cookie('used_shop'); } if (empty($used_shop)) { $this->error("商家未登录"); die; } $data['used_shop'] = $used_shop; $res = M('coupons')->where(['id' => $id])->save($data); if ($res) { $this->success("使用成功", U("Coupon/Index")); } }
function Summary() { //e_auth(); $isSalon = \LfRequest::inStr('salon'); if (IS_POST) { $e_id = \LfRequest::inNum('e_id'); $summary = M('e_summary'); $summary->user_id = session('user_id'); $summary->e_id = $e_id; $isSummary = M('e_summary')->where(array('e_id' => $e_id, 'is_iteam' => 0, 'user_id' => session('user_id')))->find(); if (!empty($isSummary)) { $this->error("你已总结该活动"); exit; } $summary->stars = \LfRequest::inNum('stars'); $summary->comment = \LfRequest::inStr('comment'); if (strlen($summary->comment) > 900) { $this->error('总结字数需在300字以内'); exit; } if ($isSalon == '1') { $summary->is_iteam = 0; } else { $summary->is_iteam = 1; } if ($_FILES['file']['size'] / (1024 * 1024) > 3) { $this->error('图片大小在3M以内'); exit; } $upload = new \LfUpload('/Picture'); $path = $upload->upload('file'); if (!$path) { $this->error("图片上传错误 " . $upload->getErr()); exit; } $summary->picture = '/Uploads' . $path; $res = $summary->add(); if ($res) { /* * 当所有人都总结后设置iteam为已总结 $SummaryNumber = $summary->where('e_id = '.$e_id)->count(); $iteam = M('e_iteam')->find($e_id); if($iteam['participated_number'] == $SummaryNumber) { M('e_iteam')->where('id ='.$e_id)->save(array('summary'=>1)); } */ /* * 暂定为有一人总结则该iteam为已总结 */ M('e_salon')->where('id =' . $e_id)->save(array('summary' => 1)); $url = addons_url('Salon://Salon/CheckSalon', array('id' => $e_id)); $this->success('总结成功,审核通过后可显示', $url); exit; } else { $this->error('总结失败'); exit; } } else { $id = \LfRequest::inNum('e_id'); $iteam = M('e_iteam')->find($id); $this->e_id = $id; $this->assign('iteam', $iteam); $this->title = "活动总结"; $this->display(); } }
public function deleteSummary() { $id = \LfRequest::inNum('id'); $res = M('e_summary')->delete($id); if ($res) { /* * TODO * 删除成功后发送短信通知重新提交 * sendMessage() */ $this->success("删除成功!"); } else { $this->error("删除失败,请重试"); } }
function e_auth() { if (!LfRequest::isWeixinBrowser()) { echo "请使用微信访问该页面"; die; } if (!empty(session('user_id'))) { $user = M('e_user')->where(array('id' => session('user_id')))->find(); if (empty($user)) { session_destroy(); redirect(addons_url('Auth://Auth/Auth')); } else { return; } } $appid = "wxadd0d2ec0a8fe9fe"; $appsecret = "f71b4c54f831bcde726a428caa46062c"; $callback = GetCurUrl(); $callback = urlencode($callback); if (isset($_GET['code'])) { $code = $_GET['code']; $url = 'https://api.weixin.qq.com/sns/oauth2/access_token?appid=' . $appid . '&secret=' . $appsecret . '&code=' . $code . '&grant_type=authorization_code'; $result = https_request($url); $result = json_decode($result); $openid = $result->openid; $user = M('e_user')->where(array('openid' => $openid))->find(); if (empty($user)) { redirect(addons_url('Auth://Auth/Auth')); } else { session('user_id', $user['id']); } } else { $url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid={$appid}&redirect_uri={$callback}&response_type=code&scope=snsapi_base&state=123#wechat_redirect"; redirect($url); } }
public function myCoupon() { e_auth(); $sid = \LfRequest::inNum('id'); $uid = session('user_id'); $coupon = M('coupons')->where(['salon_id' => $sid, 'user_id' => $uid])->find(); if (!$coupon) { $this->error("您还没有代金劵"); exit; } $user = M('e_user')->find($coupon['user_id']); $salon = M('e_salon')->find($coupon['salon_id']); if (!$user || !$salon) { $this->error("该代金劵信息有误,请核实!"); } $this->assign('coupon', $coupon); $this->assign('user', $user); $this->assign('salon', $salon); $this->assign('url', addons_url('Coupons://Coupons/showCoupon', ['code' => $coupon['code']])); $this->assign("coupon", $coupon); $this->display(); }