Commit 42ee081a by biao

1

parent 576edb3b
<?php <?php
// 使用代金券 // 检查用户是否已经是注册用户
require_once ("../user_include.inc"); require_once ("../user_include.inc");
ErrorLogger::doOutput("Compass...ajax_check_user_registed.php....Start.", 0); ErrorLogger::doOutput("Compass...ajax_check_user_registed.php....Start.", 0);
......
<?php
// 发送短信验证码
require_once ("../user_include.inc");
// 参数取得
$mobile = ParamUtil::getRequestString("mobile");
$sms_type = ParamUtil::getRequestString("sms_type");
if($sms_type != "verify") {
responseNG("非法访问");
}
$ip = @ $_SERVER["REMOTE_ADDR"];
//一个IP一天最多10次,
$param = array();
$param['delete_flg'] = false;
$param['registration_date_MIN'] = date("Y-m-d 00:00:00");
$param['registration_date_MAX'] = date("Y-m-d 23:59:59");
$param['ip'] = $ip;
$ip_sms_list = SmsVerficationDat::getList($param);
if(count($ip_sms_list) >= 10){
//responseNG("短信发送IP次数超限");
}
//一个手机一天最多5次,
unset($param['ip']);
$param['phone'] = $mobile;
$phone_sms_list = SmsVerficationDat::getList($param,'registration_date','desc');
if(count($phone_sms_list) >= 5){
responseNG("手机号发送短信次数超限");
}
if(count($phone_sms_list) > 1){
//一个手机两次间隔不得少于120秒
$last_one_time = $phone_sms_list[0]->registration_date;
if(strtotime(date('Y-m-d H:i:s')) - strtotime($last_one_time) < 120){
responseNG("发送短信过于频发,请稍后重发");
}
//更新过期的短信为已使用
foreach($phone_sms_list as $sms){
$sms->is_used = true;
$sms->save();
}
}
//已经是注册用户,不发送
$tmp_user = UserHandler::getUserByMobile($mobile);
if(!empty($tmp_user)) {
responseNG("已经是注册用户,请直接登陆!");
}
// 发送短信
$code = PasswordMaker::numbers(4);
$sms_verfication_dat = new SmsVerficationDat();
$sms_verfication_dat->phone = $mobile;
$sms_verfication_dat->ip = $ip;
$sms_verfication_dat->code = $code;
$sms_verfication_dat->is_used = false;
$sms_verfication_dat->ok_flg = true;
$sms_verfication_dat->save();
// 需要发送短信的手机号码
$phoneNumbers = [$mobile];
$templateId = 441379;
$smsSign = "考拉在线";
try {
$ssender = new SmsSingleSender(SMS_APP_ID, SMS_APP_KEY);
$params[] = $code;
$result = $ssender->sendWithParam("86", $phoneNumbers[0], $templateId, $params, $smsSign, "", "");
$rsp = json_decode($result);
echo $result;
} catch(\Exception $e) {
echo var_dump($e);
}
//发送验证码给用户
responseOK("短信已发送,请查收。");
function responseNG($message) {
$result = array("status"=>"NG", "message"=>$message);
header("Access-Control-Allow-Origin: *");
print json_encode($result);
exit;
}
function responseOK($message) {
$result = array("status"=>"OK", "message"=>$message);
header("Access-Control-Allow-Origin: *");
print json_encode($result);
exit;
}
\ No newline at end of file
<?php
// 更新用户孩子年龄段
require_once ("../user_include.inc");
$unionId = ParamUtil::getRequestString("unionId", 0);
$age = ParamUtil::getRequestNumber("age", 1);
ErrorLogger::doOutput("Compass...ajax_update_user_age.php....Start.", 0);
ErrorLogger::doOutput("Compass...ajax_update_user_age.php....unionId=" . $unionId, 0);
ErrorLogger::doOutput("Compass...ajax_update_user_age.php....age=" . $age, 0);
//参数验证
if(empty($unionId)) {
responseNG("参数错误!");
}
//年龄段参数
$tmpObj = ChildAgeRange::getById($age);
if(empty($tmpObj)) {
responseNG("参数错误!");
}
//检索用户是否存在
$param['unionid'] = $unionId;
$param['delete_flg'] = false;
$tmpUserMstList = UserMst::getList($param,'id','desc', 0, 1);
if(empty($tmpUserMstList)) {
responseNG("参数错误!");
}
$user = $tmpUserMstList[0];
$user->child_age = $age;
$user->save();
ErrorLogger::doOutput("Compass...ajax_update_user_age.php....End.", 0);
responseOK("更新成功!");
function responseNG($message) {
$result = array("status"=>"NG", "message"=>$message);
print json_encode($result);
exit;
}
function responseOK($message) {
$result = array("status"=>"OK", "message"=>$message);
print json_encode($result);
exit;
}
?>
\ No newline at end of file
<?php
// 使用代金券
require_once ("../user_include.inc");
$user_coupon_dat_id = ParamUtil::getRequestNumber("user_coupon_dat_id", 0);
$coupon_id = ParamUtil::getRequestNumber("coupon_id", 0);
ErrorLogger::doOutput("Koala...ajax_user_use_coupon.php....Start.", 0);
$ta = new TemplateAction();
if(!$ta->isLogin()) {
responseNG("请先登录!");
}
//优惠券是否存在
$coupon_dat = Coupon::getById($coupon_id);
if(empty($coupon_dat)) {
responseNG("参数错误!");
}
$user_coupon_dat = UserCouponDat::getById($user_coupon_dat_id);
if(empty($user_coupon_dat)) {
responseNG("参数错误!");
}
if($user_coupon_dat->user_id != $ta->user->id || $user_coupon_dat->coupon_id != $coupon_id){
responseNG("参数错误!");
}
if($user_coupon_dat->coupon_count <= 0) {
responseNG("代金券数量不足!");
}
//有效期
$dead_time = $user_coupon_dat->dead_time;
if(date("Y-m-d H:i:s") > $dead_time) {
responseNG("已过有效期!");
}
//一个代金券只能使用一次
$param = array();
$param["user_id"] = $ta->user->id;
$param["coupon_id"] = $coupon_id;
$param["status_NOT"] = "BACK";
$param["delete_flg"] = false;
$user_use_coupon_list = UserUseCouponDat::getList($param);
if(!empty($user_use_coupon_list)) {
responseNG("每次只能使用一张代金券!");
}
//使用代金券
$user_coupon_dat->coupon_count = 0;
$user_coupon_dat->save();
$user_use_coupon_dat = new UserUseCouponDat();
$user_use_coupon_dat->user_id = $ta->user->id;
$user_use_coupon_dat->coupon_id = $coupon_id;
$user_use_coupon_dat->status = "APPLY";
$user_use_coupon_dat->save();
ErrorLogger::doOutput("Koala...ajax_user_use_coupon.php....End.", 0);
responseOK("申请成功!请等待课程顾问老师联系您!");
function responseNG($message) {
$result = array("status"=>"NG", "message"=>$message);
header("Access-Control-Allow-Origin: *");
print json_encode($result);
exit;
}
function responseOK($message) {
$result = array("status"=>"OK", "message"=>$message);
header("Access-Control-Allow-Origin: *");
print json_encode($result);
exit;
}
?>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment