コード例 #1
0
ファイル: biz_verify.php プロジェクト: macall/jsd
/**
 * 团购全超级验证的使用, 使用全的数量= 当前输入的券+随机取出的券
 * @param unknown_type $s_account_info
 * @param unknown_type $location_id
 * @param unknown_type $pwd
 * @param unknown_type $coupon_use_count
 * @return boolean
 */
function biz_super_use_coupon($s_account_info, $location_id, $pwd, $coupon_use_count)
{
    $now = NOW_TIME;
    require_once APP_ROOT_PATH . "system/model/biz_verify.php";
    $s_account_info = es_session::get("account_info");
    $location_id = intval($_REQUEST['location_id']);
    $pwd = strim($_REQUEST['coupon_pwd']);
    $result = biz_super_check_coupon($s_account_info, $pwd, $location_id);
    if ($result['count'] == 0) {
        $data['status'] = 0;
        $data['msg'] = "没有可以使用的团购券";
        ajax_return($data);
    }
    if ($coupon_use_count > $result['count']) {
        $data['status'] = 0;
        $data['msg'] = "超出使用条数";
        ajax_return($data);
    }
    $coupon_pwd_list = $GLOBALS['db']->getAll("select c.password as password from " . DB_PREFIX . "deal_coupon as c  where c.deal_id=" . $result['coupon_data']['deal_id'] . " and c.order_id=" . $result['coupon_data']['order_id'] . " and c.order_deal_id = " . $result['coupon_data']['order_deal_id'] . "  and c.is_valid = 1 and c.refund_status=0 and c.is_delete = 0 and c.confirm_time='' and c.begin_time <" . $now . " and (c.end_time = 0 or c.end_time>'" . $now . "') limit 0," . $coupon_use_count);
    require_once APP_ROOT_PATH . "system/model/deal_order.php";
    foreach ($coupon_pwd_list as $k => $v) {
        $f_coupon_pwd_list[] = $v['password'];
    }
    if (!in_array($pwd, $f_coupon_pwd_list)) {
        //输入验证的一定要使用
        $f_coupon_pwd_list = array_shift($f_coupon_pwd_list);
        $f_coupon_pwd_list = array_unshift($f_coupon_pwd_list, $pwd);
    }
    foreach ($f_coupon_pwd_list as $k => $v) {
        $temp['pwd'] = $v;
        $temp['send_status'] = use_coupon($v, $location_id, $s_account_info['id'], true, true);
        $send_log[] = $temp;
    }
    //已经成功执行
    $data['status'] = 1;
    $data['send_data'] = $send_log;
    return $data;
}
コード例 #2
0
ファイル: dealvModule.class.php プロジェクト: macall/jsd
 public function super_check()
 {
     require_once APP_ROOT_PATH . "system/model/biz_verify.php";
     $s_account_info = $GLOBALS['account_info'];
     $location_id = intval($_REQUEST['location_id']);
     $pwd = strim($_REQUEST['coupon_pwd']);
     $result = biz_super_check_coupon($s_account_info, $pwd, $location_id);
     $result['location_id'] = $location_id;
     $result['coupon_pwd'] = $pwd;
     $GLOBALS['tmpl']->assign("result", $result);
     $result['weebox_html'] = $GLOBALS['tmpl']->fetch("pages/verify/super_weebox.html");
     ajax_return($result);
 }