public static function Create($order) { $team = Table::Fetch('team', $order['team_id']); $partner = Table::Fetch('partner', $order['partner_id']); $ccon = array('order_id' => $order['id']); $count = Table::Count('coupon', $ccon); while ($count < $order['quantity']) { $id = Utility::GenSecret(8, Utility::CHAR_NUM); $cv = Table::Fetch('coupon', $id); if ($cv) { continue; } $coupon = array('id' => $id, 'user_id' => $order['user_id'], 'partner_id' => $team['partner_id'], 'order_id' => $order['id'], 'credit' => $team['credit'], 'team_id' => $order['team_id'], 'secret' => Utility::GenSecret(6, Utility::CHAR_WORD), 'expire_time' => $team['expire_time'], 'create_time' => time()); DB::Insert('coupon', $coupon); sms_coupon($coupon); $count = Table::Count('coupon', $ccon); } }
if ($count > 0) { json('商户有团购项目,删除失败', 'alert'); } json('商户删除失败', 'alert'); } else { if ('noticesms' == $action) { need_auth('team'); $nid = abs(intval($_GET['nid'])); $now = time(); $team = Table::Fetch('team', $id); $condition = array('team_id' => $id); $coups = DB::LimitQuery('coupon', array('condition' => $condition, 'order' => 'ORDER BY id ASC', 'offset' => $nid, 'size' => 1)); if ($coups) { foreach ($coups as $one) { $nid++; sms_coupon($one); } json("X.misc.noticesms({$id},{$nid});", 'eval'); } else { json($INI['system']['couponname'] . '发送完毕', 'alert'); } } else { if ('noticesmssubscribe' == $action) { need_auth('team'); $nid = abs(intval($_GET['nid'])); $team = Table::Fetch('team', $id); $condition = array('enable' => 'Y'); if (abs(intval($team['city_id']))) { $condition['city_id'] = abs(intval($team['city_id'])); } $subs = DB::LimitQuery('smssubscribe', array('condition' => $condition, 'order' => 'ORDER BY id ASC', 'offset' => $nid, 'size' => 10));
} $v = join('<br/>', $v); $d = array('html' => $v, 'id' => 'coupon-dialog-display-id'); json($d, 'updater'); } else { if ($action == 'sms') { $coupon = Table::Fetch('coupon', $sid); if ($coupon['sms'] >= 5 && !is_manager()) { json('短信发送' . $INI['system']['couponname'] . '最多5次, 如有任何疑问请联系客服!', 'alert'); } $interval = abs(intval($INI['sms']['interval'])); $lefttime = $interval + $coupon['sms_time'] - time(); if (!is_manager() && $lefttime > 0) { json("你好,请在{$lefttime}秒后,再次尝试短信发送优惠券" . $INI['system']['couponname'], 'alert'); } if (!$coupon || !is_login() || $coupon['user_id'] != ZLogin::GetLoginId() && !is_manager()) { json($cid, 'alert'); } $flag = sms_coupon($coupon); if ($flag === true) { json('手机短信发送成功,请及时查收', 'alert'); } else { if (is_string($flag)) { json($flag, 'alert'); } } json("手机短信发送失败,错误码:{$code}", 'alert'); } } } }
$sms_number = 5; } else { $sms_number = $INI['sms']['numbers']; } if ($coupon['sms'] >= $sms_number && !is_manager()) { json(array(array('data' => '短信发送优惠券最多' . $sms_number . '次', 'type' => 'alert'), array('data' => 'X.boxClose();', 'type' => 'eval')), 'mix'); } $interval = abs(intval($INI['sms']['interval'])); $lefttime = $interval + $coupon['sms_time'] - time(); if (!is_manager() && $lefttime > 0) { json("你好,请在{$lefttime}秒后,再次尝试短信发送优惠券", 'alert'); } if (!$coupon || !is_login() || $coupon['user_id'] != ZLogin::GetLoginId() && !is_manager()) { json('非法下载', 'alert'); } $flag = sms_coupon($coupon, $mobile); if ($flag === true) { json(array(array('data' => '手机短信发送成功,请及时查收', 'type' => 'alert'), array('data' => 'X.boxClose();', 'type' => 'eval')), 'mix'); } else { if (is_string($flag)) { json($flag, 'alert'); } } json("手机短信发送失败,错误码:{$code}", 'alert'); } else { if ($action == 'vouchersms') { $voucher = Table::Fetch('voucher', $cid); if ($voucher['sms'] >= 5 && !is_manager()) { json('短信发送商户券最多5次', 'alert'); } $interval = abs(intval($INI['sms']['interval']));