Exemplo n.º 1
0
 public function send()
 {
     global_run();
     if (check_save_login() != LOGIN_STATUS_LOGINED) {
         $data['status'] = 1000;
         ajax_return($data);
     } else {
         $t = strim($_REQUEST['t']);
         $id = intval($_REQUEST['id']);
         $youhui_log = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "youhui_log where id = " . $id . " and user_id = " . $GLOBALS['user_info']['id']);
         $youhui_info = load_auto_cache("youhui", array("id" => $youhui_log['youhui_id']));
         if ($youhui_log) {
             if ($youhui_log['confirm_time'] > 0) {
                 $data['status'] = 0;
                 $data['info'] = "优惠券已使用";
                 ajax_return($data);
             } elseif ($youhui_log['expire_time'] > 0 && $youhui_log['expire_time'] < NOW_TIME) {
                 $data['status'] = 0;
                 $data['info'] = "优惠券已过期";
                 ajax_return($data);
             } else {
                 if ($t == "sms") {
                     if (app_conf("SMS_ON") == 0 || $youhui_info['is_sms'] == 0) {
                         $data['status'] = 0;
                         $data['info'] = "不支持短信发送";
                         ajax_return($data);
                     } elseif ($youhui_log['sms_count'] >= app_conf("SMS_COUPON_LIMIT")) {
                         $data['status'] = 0;
                         $data['info'] = "短信发送已超过" . app_conf("SMS_COUPON_LIMIT") . "次";
                         ajax_return($data);
                     } elseif ($GLOBALS['user_info']['mobile'] == "") {
                         $data['status'] = 0;
                         $data['info'] = "请先设置手机号";
                         $data['jump'] = url("index", "uc_account");
                         ajax_return($data);
                     } else {
                         send_youhui_log_sms($id);
                         $GLOBALS['db']->query("update " . DB_PREFIX . "youhui_log set sms_count = sms_count + 1 where id = " . $id);
                         $data['status'] = 1;
                         $data['info'] = "短信成功发送到" . $GLOBALS['user_info']['mobile'] . ",请注意查收。";
                         ajax_return($data);
                     }
                 } else {
                     $data['status'] = 0;
                     $data['info'] = "非法操作";
                     ajax_return($data);
                 }
             }
         } else {
             $data['status'] = 0;
             $data['info'] = "优惠券不存在";
             ajax_return($data);
         }
     }
 }
Exemplo n.º 2
0
 public function send_sms()
 {
     $ajax = intval($_REQUEST['ajax']);
     $log_id = intval($_REQUEST['id']);
     if (M("YouhuiLog")->where("id=" . $log_id)->count() > 0) {
         if (send_youhui_log_sms($log_id)) {
             $this->success(l("SEND_SUCCESS"), $ajax);
         } else {
             $this->error(l("SEND_FAILED"), $ajax);
         }
     } else {
         $this->error(l("INVALID_OPERATION"), $ajax);
     }
 }
Exemplo n.º 3
0
 public function index()
 {
     $mobile = strim($GLOBALS['request']['user_phoneNum']);
     //print_r($email);echo"<br />";print_r($pwd);exit;
     //检查用户,用户密码
     $user_return = $GLOBALS['user_info'];
     $user = $user_return;
     $user_id = intval($user['id']);
     //print_r($user_id);exit;
     if ($mobile == '') {
         $mobile = $user['mobile'];
     }
     if ($user_id == 0) {
         $root['status'] = 0;
         $root['user_login_status'] = 0;
     } else {
         $youhui_id = intval($GLOBALS['request']['id']);
         require_once APP_ROOT_PATH . "system/model/youhui.php";
         $youhui_info = get_youhui($youhui_id);
         $result = download_youhui(intval($youhui_info['id']), $user_id);
         if ($result['status'] >= 0) {
             if ($result['status'] == YOUHUI_OUT_OF_STOCK || $result['status'] == YOUHUI_USER_OUT_OF_STOCK) {
                 $root['status'] = 0;
                 $root['info'] = $result['info'];
             } else {
                 if ($result['status'] == YOUHUI_DOWNLOAD_SUCCESS) {
                     if (app_conf("SMS_ON") == 1 && $result['log']['mobile'] != "" && $youhui_info['is_sms'] == 1) {
                         //发送短信
                         send_youhui_log_sms($result['log']['id']);
                     }
                     $root['status'] = 1;
                     $root['info'] = $result['info'];
                 } else {
                     $root['status'] = 0;
                     $root['info'] = $result['info'];
                 }
             }
         } else {
             $root['status'] = 0;
             $root['info'] = $result['info'];
         }
     }
     output($root);
 }
Exemplo n.º 4
0
 public function send_sms()
 {
     if (intval($GLOBALS['user_info']['id']) == 0) {
         $result['status'] = 0;
         $result['html'] = $GLOBALS['tmpl']->fetch("inc/login_form.html");
         ajax_return($result);
     } else {
         $result['status'] = 1;
         $user_id = intval($GLOBALS['user_info']['id']);
         $mobile = addslashes(htmlspecialchars(trim($_REQUEST['mobile'])));
         $now = get_gmtime();
         $today_begin = to_timespan(to_date($now, "Y-m-d"));
         $today_end = $today_begin + 24 * 3600;
         //手机号每日下载限额
         $tel_send_count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_msg_list where dest = " . $mobile . " and is_youhui = 1 and create_time between " . $today_begin . " and " . $today_end);
         //用户每日下载限额
         $count = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_msg_list where user_id = " . $user_id . " and is_youhui = 1 and create_time between " . $today_begin . " and " . $today_end);
         if ($count >= intval(app_conf("YOUHUI_SEND_LIMIT")) || $tel_send_count >= intval(app_conf("YOUHUI_SEND_TEL_LIMIT"))) {
             $result['info'] = $GLOBALS['lang']['SMS_LIMIT_OVER'];
             ajax_return($result);
         } else {
             $youhui_id = intval($_REQUEST['id']);
             $youhui_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "youhui where is_effect = 1 and id =" . $youhui_id);
             if (!$youhui_info) {
                 showErr($GLOBALS['lang']['YOUHUI_NO_EXIST'], 1);
             }
             if ($youhui_info['end_time'] > 0 && $youhui_info['end_time'] < get_gmtime()) {
                 showErr($GLOBALS['lang']['YOUHUI_END_TIME_OVER'], 1);
             }
             if ($youhui_info['is_sms'] == 0) {
                 showErr($GLOBALS['lang']['YOUHUI_NO_SUPPORT_SMS'], 1);
             }
             if ($youhui_info['send_type'] == 0) {
                 if (send_youhui_sms($youhui_id, $user_id, $mobile)) {
                     $result['info'] = $GLOBALS['lang']['SMS_SEND_SUCCESS'];
                     ajax_return($result);
                 } else {
                     $result['info'] = $GLOBALS['lang']['SMS_SEND_FAILED'];
                     ajax_return($result);
                 }
             } else {
                 //开始需要生成验证的券
                 $order_count = intval($_REQUEST['order_count']);
                 $is_private_room = intval($_REQUEST['is_private_room']);
                 $date_time = addslashes(trim(htmlspecialchars($_REQUEST['date_time']))) . " " . addslashes(trim(htmlspecialchars($_REQUEST['date_time_h']))) . ":" . addslashes(trim(htmlspecialchars($_REQUEST['date_time_m']))) . ":00";
                 $date_time = to_timespan($date_time);
                 $log_id = gen_verify_youhui($youhui_id, $mobile, $user_id, $order_count, $is_private_room, $date_time);
                 if ($log_id) {
                     if (send_youhui_log_sms($log_id)) {
                         $result['info'] = $GLOBALS['lang']['SMS_SEND_SUCCESS'];
                         ajax_return($result);
                     } else {
                         $result['info'] = $GLOBALS['lang']['SMS_SEND_FAILED'];
                         ajax_return($result);
                     }
                 } else {
                     $result['info'] = $GLOBALS['lang']['SMS_SEND_FAILED'];
                     ajax_return($result);
                 }
             }
         }
     }
 }
Exemplo n.º 5
0
 /**
  * 下载优惠券
  */
 public function download_youhui()
 {
     global_run();
     if (check_save_login() != LOGIN_STATUS_LOGINED) {
         $data['status'] = 1000;
         ajax_return($data);
     }
     $id = intval($_REQUEST['id']);
     require_once APP_ROOT_PATH . "system/model/youhui.php";
     $youhui_info = get_youhui($id);
     $result = download_youhui(intval($youhui_info['id']), $GLOBALS['user_info']['id']);
     if ($result['status'] >= 0) {
         if ($result['status'] == YOUHUI_OUT_OF_STOCK || $result['status'] == YOUHUI_USER_OUT_OF_STOCK) {
             $data['status'] = 0;
             $data['info'] = $result['info'];
             if ($result['log']) {
                 $data['jump'] = url("index", "uc_youhui");
             }
             ajax_return($data);
         } else {
             if ($result['status'] == YOUHUI_DOWNLOAD_SUCCESS) {
                 if (app_conf("SMS_ON") == 1 && $result['log']['mobile'] != "" && $youhui_info['is_sms'] == 1) {
                     //发送短信
                     send_youhui_log_sms($result['log']['id']);
                 }
                 $GLOBALS['tmpl']->assign("youhui_info", $youhui_info);
                 $GLOBALS['tmpl']->assign("result", $result);
                 $data['status'] = 1;
                 $data['info'] = $result['info'];
                 $data['html'] = $GLOBALS['tmpl']->fetch("inc/youhui_win.html");
                 ajax_return($data);
             } else {
                 $data['status'] = 0;
                 $data['info'] = $result['info'];
                 ajax_return($data);
             }
         }
     } else {
         $data['status'] = 0;
         $data['info'] = $result['info'];
         ajax_return($data);
     }
 }