Commit 26b1bee5 by biao

1

parent 93d2e261
<?php ++ /dev/null
<?php
// 使用代金券
require_once ("../user_include.inc");
ErrorLogger::doOutput("Compass...ajax_get_organization_rule_text.php....Start.", 0);
//根据常量获取定义的值
$constName = "ORGNAZATION_RULE";
$constValue = "";
//检索数据库
$param['name'] = $constName;
$param['delete_flg'] = false;
$systemConstantDatList = SystemConstantDat::getList($param,'id','desc', 0, 1);
if(!empty($systemConstantDatList)) {
$constValue = $systemConstantDatList[0]->constant_value;
}
ErrorLogger::doOutput("Compass...ajax_get_organization_rule_text.php....constValue=" . $constValue, 0);
ErrorLogger::doOutput("Compass...ajax_get_organization_rule_text.php....End.", 0);
//如果为空说明未设定该参数的值
if(empty($constValue)) {
responseNG("系统设定错误!");
}
//返回结果
responseOK($constValue);
function responseNG($result) {
$result = array("status"=>"NG", "result"=>$result);
print json_encode($result);
exit;
}
function responseOK($result) {
$result = array("status"=>"OK", "result"=>$result);
print json_encode($result);
exit;
}
?>
\ No newline at end of file
<?php
// 发送短信验证码
require_once ("../user_include.inc");
//设置一个随机验证码
$verificationCode = PasswordMaker::numbers(4,4);
$_SESSION['verificationCode'] = $verificationCode;
//发送验证码给用户
responseOK($verificationCode);
function responseOK($verificationCode) {
$result = array("status"=>"OK", "code"=>$verificationCode);
print json_encode($result);
exit;
}
\ No newline at end of file
<?
// クラス、設定読み込み
//添加或者删除用户的收藏记录
require_once ("../user_include.inc");
ErrorLogger::doOutput("Koala...ajax_operate_favorite.php....Start.", 0);
$action_type = ParamUtil::getRequestString("action_type");//delete/add
$data_type = ParamUtil::getRequestString("data_type");//word/article
$data_id = ParamUtil::getRequestNumber("data_id", 0);
ErrorLogger::doOutput("Koala...ajax_operate_favorite.php....action_type=" . $action_type, 0);
ErrorLogger::doOutput("Koala...ajax_operate_favorite.php....data_type=" . $data_type, 0);
ErrorLogger::doOutput("Koala...ajax_operate_favorite.php....data_id=" . $data_id, 0);
//参数错误
if(empty($action_type) || ($action_type!="delete" && $action_type!="add")) {
responseNG("NG_PARAM", "参数错误!");
}
if(empty($data_type) || ($data_type!="word" && $data_type!="article")) {
responseNG("NG_PARAM", "参数错误!");
}
if(empty($data_id) || $data_id==0) {
responseNG("NG_PARAM", "参数错误!");
}
//判断用户登陆状态
$ta = new TemplateAction();
if(!$ta->isLogin()) {
responseNG("NG_LOGIN", "未登录!");
}
//检查数据是否存在
if($action_type == "add" && $data_type == "word") {
$word_dat = WordDat::getById($data_id);
if(empty($word_dat)) {
responseNG("NG_PARAM", "参数错误!");
}
}
if($action_type == "add" && $data_type == "article") {
$article_dat = ArticleDat::getById($data_id);
if(empty($article_dat)) {
responseNG("NG_PARAM", "参数错误!");
}
}
$user_id = $ta->user->id;
//是否重复登陆
if($action_type == "add") {
$param = array();
$param["user_id"] = $user_id;
$param["data_type"] = $data_type;
$param["data_id"] = $data_id;
$param["delete_flg"] = false;
$tmp_favorite_count = UserFavoriteDat::getListCount($param);
if ($tmp_favorite_count > 0) {
responseNG("NG_REPEAT", "重复添加!");
}
}
//数据操作
$sql = "";
if($action_type == "add") {
$sql = "INSERT INTO user_favorite_dat(user_id, data_type, data_id) values('{$user_id}', '{$data_type}', '{$data_id}')";
}
if($action_type == "delete") {
$sql = "DELETE FROM user_favorite_dat WHERE delete_flg=false and user_id='{$user_id}' and data_type='{$data_type}' and data_id='{$data_id}'";
}
ErrorLogger::doOutput("Koala...ajax_operate_favorite.php....sql=" . $sql, 0);
$db = &KoalaDBManager::getInstance();
$db->executeQuery($sql);
responseOK("操作成功!");
function responseNG($status, $message) {
$result = array("status"=>$status, "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");
ErrorLogger::doOutput("Koala...ajax_user_exchange_coupon.php....Start.", 0);
//代金券ID
$coupon_id = ParamUtil::getRequestNumber("coupon_id", 0);
$ta = new TemplateAction();
if(!$ta->isLogin()) {
responseNG("请先登录!");
}
//代金券是否存在
$coupon_dat = Coupon::getById($coupon_id);
if(empty($coupon_dat)) {
responseNG("数据错误!");
}
//积分整合性判断
//获取用户数据
$point_left = 0;
$param = array();
$param["user_id"] = $ta->user->id;
$param["status"] = "SUCCESS";
$param["delete_flg"] = false;
$user_point_list = UserPointLog::getList($param, "id", "desc", 0, 1);
if(!empty($user_point_list)) {
$point_left = $user_point_list[0]->point_left;
}
ErrorLogger::doOutput("Koala...ajax_user_exchange_coupon.php....point1=" . $ta->user->point, 0);
ErrorLogger::doOutput("Koala...ajax_user_exchange_coupon.php....point2=" . $point_left, 0);
if($ta->user->point != $point_left) {
responseNG("数据错误2!");
}
if($point_left < $coupon_dat->point) {
responseNG("积分不足!");
}
//开始兑换
//添加一条新的积分记录记录
$minus_point = $coupon_dat->point;
$user_point_log = new UserPointLog();
$user_point_log->user_id = $ta->user->id;
$user_point_log->action_type = 5;//兑换代金券
$user_point_log->point = (-1)*$minus_point;
$user_point_log->point_left = $point_left - $minus_point;
$user_point_log->status = "SUCCESS";
$user_point_log->save();
//添加代金券
$dead_time = time() + ($coupon_dat->valid_days)*24*3600;
$user_coupon_dat = new UserCouponDat();
$user_coupon_dat->user_id = $ta->user->id;
$user_coupon_dat->coupon_id = $coupon_id;
$user_coupon_dat->coupon_count = 1;
$user_coupon_dat->dead_time = date('y-m-d',$dead_time) . " 23:59:59";
$user_coupon_dat->transfer_count = 0;
$user_coupon_dat->save();
//更新用户表的point字段值
$ta->user->point = $user_point_log->point_left;
$ta->user->save();
ErrorLogger::doOutput("Koala...ajax_user_exchange_coupon.php....point_left=" . $point_left, 0);
ErrorLogger::doOutput("Koala...ajax_user_exchange_coupon.php....minus_point=" . $minus_point, 0);
//更新用户表的point字段值
$ta->user->point = $user_point_log->point_left;
$ta->user->save();
ErrorLogger::doOutput("Koala...ajax_user_exchange_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
<?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