本文整理汇总了PHP中coupon类的典型用法代码示例。如果您正苦于以下问题:PHP coupon类的具体用法?PHP coupon怎么用?PHP coupon使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了coupon类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateTempInvoice
function updateTempInvoice()
{
global $DB, $objComm, $lang;
include_once MODELS . '/member_model.php';
include_once MODELS_ADMIN . '/coupon_model.php';
$objMember = new member();
$InvRow = $this->getInvoice();
$memberid = $_SESSION['register']['member_id'];
$objCoupon = new coupon();
$rowCoupon = $objCoupon->getSessionCoupon();
if ($InvRow->id > 0 && $rowCoupon->id > 0) {
$row = $objMember->getMembers($memberid);
if ($rowCoupon->discount_price > 0) {
$discount = $rowCoupon->discount_price;
} else {
$discount = $row->amount_paid * $rowCoupon->discount_perc / 100;
}
$finalAmount = $row->amount_paid - $discount;
$arrData['coupon_code'] = $rowCoupon->coupon_code;
$arrData['coupon_id'] = $rowCoupon->id;
$arrData['discount_amt'] = $discount;
$arrData['final_total_amt'] = $finalAmount;
$arrData['payment_status'] = 'Pending';
$where = "`id` = '" . $InvRow->id . "'";
$DB->updateRecord('invoice', $arrData, $where, '');
return json_encode(array('discount' => '$' . number_format($discount, 2), 'final' => '$' . number_format($finalAmount, 2)));
} else {
$_SESSION['member_error'] = "coupon_code_error";
$objComm->redirect1("index.php?model=member&action=payment");
}
}
示例2: array
$whitelist = @iunserializer($whitelist);
}
if (checksubmit('submit')) {
if (!empty($_GPC['username'])) {
$data = array();
foreach ($_GPC['username'] as $da) {
$da = trim($da);
if (empty($da)) {
continue;
}
$i++;
$data[] = trim($da);
if ($i >= 10) {
break;
}
}
}
load()->classs('coupon');
$acc = new coupon($acid);
$post['username'] = $data;
$status = $acc->SetTestWhiteList($post);
if (is_error($status)) {
message($status['message'], '', 'error');
} else {
$data = iserializer($data);
pdo_update('coupon_setting', array('whitelist' => $data), array('uniacid' => $_W['uniacid'], 'acid' => $acid));
}
message('设置测试黑名单成功', referer(), 'success');
}
}
template('wechat/manage');
示例3: exit
$site->{$method}($ret);
$ret['from'] = 'return';
exit($site->{$method}($ret));
}
}
}
}
if ($type == 'delivery') {
$sql = 'SELECT * FROM ' . tablename('core_paylog') . ' WHERE `plid`=:plid';
$pars = array();
$pars[':plid'] = $ps['tid'];
$log = pdo_fetch($sql, $pars);
if (!empty($log) && $log['status'] == '0') {
if ($log['is_usecard'] == 1 && $log['card_type'] == 1 && !empty($log['encrypt_code']) && $_W['acid']) {
load()->classs('coupon');
$acc = new coupon($_W['acid']);
$codearr['encrypt_code'] = $log['encrypt_code'];
$codearr['module'] = $log['module'];
$codearr['card_id'] = $log['card_id'];
$acc->PayConsumeCode($codearr);
}
if ($log['is_usecard'] == 1 && $log['card_type'] == 2) {
$now = time();
$log['card_id'] = intval($log['card_id']);
pdo_query('UPDATE ' . tablename('activity_coupon_record') . " SET status = 2, usetime = {$now}, usemodule = '{$log['module']}' WHERE uniacid = :aid AND couponid = :cid AND uid = :uid AND status = 1 LIMIT 1", array(':aid' => $_W['uniacid'], ':uid' => $log['openid'], ':cid' => $log['card_id']));
}
$site = WeUtility::createModuleSite($log['module']);
if (!is_error($site)) {
$site->weid = $_W['weid'];
$site->uniacid = $_W['uniacid'];
$site->inMobile = true;
示例4: trim
$data['province'] = trim($_GPC['reside']['province']) ? urlencode(trim($_GPC['reside']['province'])) : message('请选择门店所在省');
$data['city'] = trim($_GPC['reside']['city']) ? urlencode(trim($_GPC['reside']['city'])) : message('请选择门店所在市');
$data['district'] = trim($_GPC['reside']['district']) ? urlencode(trim($_GPC['reside']['district'])) : message('请选择门店所在区');
$data['address'] = trim($_GPC['address']) ? urlencode(trim($_GPC['address'])) : message('门店详细地址不能为空');
$data['longitude'] = trim($_GPC['baidumap']['lng']) ? trim($_GPC['baidumap']['lng']) : message('请选择门店所在地理位置经度');
$data['latitude'] = trim($_GPC['baidumap']['lat']) ? trim($_GPC['baidumap']['lat']) : message('请选择门店所在地理位置维度');
$data['telephone'] = trim($_GPC['telephone']) ? trim($_GPC['telephone']) : message('门店电话不能为空');
$acid = intval($_GPC['acid']);
load()->model('coupon');
unset($data['acid']);
$post[] = $data;
$acc = new coupon($acid);
$status = $acc->LocationBatchAdd($post);
if (is_error($status)) {
message($status['message'], referer(), 'error');
}
$data['acid'] = $acid;
$data['uniacid'] = $_W['uniacid'];
//插入数据库
pdo_insert('coupon_location', $data);
$id = pdo_insertid();
message('添加门店成功', url('manage/location_list'), 'success');
}
}
if ($do == 'display') {
load()->model('coupon');
$acid = 269;
$acc = new coupon($acid);
$status = $acc->GetColors($post);
}
template('wechat/location');
示例5: coupon_qr
function coupon_qr($data)
{
global $_W;
$id = intval($data['id']);
$item = pdo_fetch('SELECT acid,id,card_id FROM ' . tablename('coupon') . ' WHERE uniacid = :aid AND id = :id', array(':aid' => $_W['uniacid'], ':id' => $id));
if (empty($item)) {
return error(-1, '卡券不存在或已经删除');
}
if (empty($item['card_id'])) {
return error(-1, '卡券id出错');
}
$coupon = new coupon($item['acid']);
$data = array('action_name' => 'QR_CARD', 'action_info' => array('card' => array('card_id' => $item['card_id'], 'code' => '', 'openid' => '', 'expire_seconds' => "{$data['expire_seconds']}", 'is_unique_code' => false, 'outer_id' => $data['outer_id'])));
$return = $coupon->QrCard($data);
return $return;
}
示例6: foreach
if (!empty($data)) {
foreach ($data as &$da) {
$da['date_info'] = @iunserializer($da['date_info']);
if ($da['date_info']['time_type'] == 1) {
$da['endtime'] = '有效期至:' . $da['date_info']['time_limit_end'];
} else {
$da['endtime'] = '领取后' . $da['date_info']['deadline'] . '天生效' . $da['date_info']['limit'] . '天内有效';
}
}
}
$pager = pagination($total, $pindex, $psize);
}
if ($do == 'detail') {
$id = intval($_GPC['id']);
load()->classs('coupon');
$acc = new coupon($_W['acid']);
$status = $acc->AddCard($id);
$out['errno'] = 0;
$out['error'] = '';
if (is_error($status)) {
$out['errno'] = 1;
$out['error'] = $status['message'];
exit(json_encode($out));
}
$out['error'] = $status;
exit(json_encode($out));
}
if ($do == 'use') {
$card_id = trim($_GPC['card_id']);
$encrypt_code = trim($_GPC['encrypt_code']);
$signature = trim($_GPC['signature']);
示例7: message
message('更改卡券领取状态成功', referer(), 'success');
}
if ($op == 'consume') {
$id = intval($_GPC['id']);
$record = pdo_fetch('SELECT code,status FROM ' . tablename('coupon_record') . ' WHERE acid = :acid AND id = :id', array(':acid' => $acid, ':id' => $id));
if (empty($record)) {
message('对应code码不存在', referer(), 'error');
}
$pwd = trim($_GPC['pdw']);
if (empty($pwd)) {
message('请输入店员密码', referer(), 'error');
}
$sql = 'SELECT * FROM ' . tablename('activity_coupon_password') . " WHERE `uniacid` = :uniacid AND `password` = :password";
$clerk = pdo_fetch($sql, array(':uniacid' => $_W['uniacid'], ':password' => $pwd));
if (empty($clerk)) {
message('店员密码错误', referer(), 'error');
}
if ($record['status'] == 1) {
load()->classs('coupon');
$acc = new coupon($acid);
$status = $acc->ConsumeCode(array('code' => $record['code']));
if (is_error($status)) {
message($status['message'], '', 'error');
} else {
pdo_update('coupon_record', array('status' => 3, 'clerk_name' => $clerk['name'], 'usetime' => TIMESTAMP), array('acid' => $acid, 'code' => $record['code'], 'id' => $id));
}
}
message('核销卡券成功', referer(), 'success');
}
template('wechat/consume');
}
示例8: pay
protected function pay($params = array(), $mine = array())
{
global $_W;
if (!$this->inMobile) {
message('支付功能只能在手机上使用');
}
if (empty($_W['member']['uid'])) {
checkauth();
}
$params['module'] = $this->module['name'];
$pars = array();
$pars[':uniacid'] = $_W['uniacid'];
$pars[':module'] = $params['module'];
$pars[':tid'] = $params['tid'];
if ($params['fee'] <= 0) {
$pars['from'] = 'return';
$pars['result'] = 'success';
$pars['type'] = 'alipay';
$pars['tid'] = $params['tid'];
$site = WeUtility::createModuleSite($pars[':module']);
$method = 'payResult';
if (method_exists($site, $method)) {
exit($site->{$method}($pars));
}
}
$sql = 'SELECT * FROM ' . tablename('core_paylog') . ' WHERE `uniacid`=:uniacid AND `module`=:module AND `tid`=:tid';
$log = pdo_fetch($sql, $pars);
if (!empty($log) && $log['status'] == '1') {
message('这个订单已经支付成功, 不需要重复支付.');
}
$setting = uni_setting($_W['uniacid'], array('payment', 'creditbehaviors'));
if (!is_array($setting['payment'])) {
message('没有有效的支付方式, 请联系网站管理员.');
}
$pay = $setting['payment'];
if (!empty($pay['credit']['switch'])) {
$credtis = mc_credit_fetch($_W['member']['uid']);
}
$you = 0;
if ($pay['card']['switch'] == 2) {
if ($_W['card_permission'] == 1 && !empty($params['module'])) {
$cards = pdo_fetchall('SELECT a.id,a.card_id,a.cid,b.type,b.title,b.extra,b.is_display,b.status,b.date_info FROM ' . tablename('coupon_modules') . ' AS a LEFT JOIN ' . tablename('coupon') . ' AS b ON a.cid = b.id WHERE a.acid = :acid AND a.module = :modu AND b.is_display = 1 AND b.status = 3 ORDER BY a.id DESC', array(':acid' => $_W['acid'], ':modu' => $params['module']));
$flag = 0;
if (!empty($cards)) {
foreach ($cards as $temp) {
$temp['date_info'] = iunserializer($temp['date_info']);
if ($temp['date_info']['time_type'] == 1) {
$starttime = strtotime($temp['date_info']['time_limit_start']);
$endtime = strtotime($temp['date_info']['time_limit_end']);
if (TIMESTAMP < $starttime || TIMESTAMP > $endtime) {
continue;
} else {
$param = array(':acid' => $_W['acid'], ':openid' => $_W['openid'], ':card_id' => $temp['card_id']);
$num = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('coupon_record') . ' WHERE acid = :acid AND openid = :openid AND card_id = :card_id AND status = 1', $param);
if ($num <= 0) {
continue;
} else {
$flag = 1;
$card = $temp;
break;
}
}
} else {
$deadline = intval($temp['date_info']['deadline']);
$limit = intval($temp['date_info']['limit']);
$param = array(':acid' => $_W['acid'], ':openid' => $_W['openid'], ':card_id' => $temp['card_id']);
$record = pdo_fetchall('SELECT addtime,id,code FROM ' . tablename('coupon_record') . ' WHERE acid = :acid AND openid = :openid AND card_id = :card_id AND status = 1', $param);
if (!empty($record)) {
foreach ($record as $li) {
$time = strtotime(date('Y-m-d', $li['addtime']));
$starttime = $time + $deadline * 86400;
$endtime = $time + $deadline * 86400 + $limit * 86400;
if (TIMESTAMP < $starttime || TIMESTAMP > $endtime) {
continue;
} else {
$flag = 1;
$card = $temp;
break;
}
}
}
if ($flag) {
break;
}
}
}
}
if ($flag) {
if ($card['type'] == 'discount') {
$you = 1;
$card['fee'] = sprintf("%.2f", $params['fee'] * ($card['extra'] / 100));
} elseif ($card['type'] == 'cash') {
$cash = iunserializer($card['extra']);
if ($params['fee'] >= $cash['least_cost']) {
$you = 1;
$card['fee'] = sprintf("%.2f", $params['fee'] - $cash['reduce_cost']);
}
}
load()->classs('coupon');
$acc = new coupon($_W['acid']);
//.........这里部分代码省略.........
示例9: explode
continue;
}
$arr = explode('=', $da);
$post[$arr[0]] = trim($arr[1]);
}
$out['errno'] = 1;
$out['error'] = '';
$post['logo_url'] = empty($post['logo_url']) ? $setting['logourl'] : trim($post['logo_url']);
$base = new Card('GENERAL_COUPON', $post);
if (is_error($base->general_coupon->base_info)) {
$out['errno'] = 0;
$out['error'] = $base->general_coupon->base_info['message'];
exit(json_encode($out));
}
$base->get_card()->set_default_detail(urlencode(trim($post['default_detail'])));
$acc = new coupon($acid);
$status = $acc->CreateCard($base->toJson());
if (is_error($status)) {
$out['errno'] = 0;
$out['error'] = $status['message'];
exit(json_encode($out));
}
$post['card_id'] = $status['card_id'];
$post['date_info'] = array('time_type' => $post['time_type'], 'time_limit_start' => $post['time_limit[start]'], 'time_limit_end' => $post['time_limit[end]'], 'deadline' => $post['deadline'], 'limit' => $post['limit']);
$post['date_info'] = iserializer($post['date_info']);
if (!empty($post['location-select'])) {
$location = explode('-', $post['location-select']);
$post['location_id_list'] = iserializer($location);
} else {
$post['location_id_list'] = iserializer(array());
}
示例10: foreach
<?php
if (isset($_POST['length'])) {
include 'class.coupon.php';
$no_of_coupons = $_POST['no_of_coupons'];
$length = $_POST['length'];
$prefix = $_POST['prefix'];
$suffix = $_POST['suffix'];
$numbers = $_POST['numbers'];
$letters = $_POST['letters'];
$symbols = $_POST['symbols'];
$random_register = $_POST['random_register'] == 'false' ? false : true;
$mask = $_POST['mask'] == '' ? false : $_POST['mask'];
$coupons = coupon::generate_coupons($no_of_coupons, $length, $prefix, $suffix, $numbers, $letters, $symbols, $random_register, $mask);
foreach ($coupons as $key => $value) {
echo $value . "\n ";
}
die;
}
?>
<!DOCTYPE html>
<html>
<head>
<title>PHP - Coupon Code Generator</title>
<!-- Bootstrap -->
<link href="bootstrap/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="row">
示例11: defined
/**
* [Weizan System] Copyright (c) 2014 wdlcms.com
* Weizan isNOT a free software, it under the license terms, visited http://www.wdlcms.com/ for more details.
*/
defined('IN_IA') or exit('Access Denied');
if (!empty($_W['uniacid'])) {
$sql = 'SELECT * FROM ' . tablename('core_queue') . ' WHERE `uniacid`=:uniacid AND type = 2 ORDER BY `qid` ASC LIMIT 15';
$pars = array();
$pars[':uniacid'] = $_W['uniacid'];
$cards = pdo_fetchall($sql, $pars);
if (!empty($cards)) {
load()->classs('coupon');
foreach ($cards as $li) {
if (!empty($li['acid']) && !empty($li['message'])) {
$acc = new coupon($li['acid']);
$code = $acc->DecryptCode(array('encrypt_code' => $li['message']));
if (is_error($code)) {
continue;
} else {
$sumecode = $acc->ConsumeCode(array('code' => $code['code']));
if (is_error($sumecode)) {
continue;
} else {
pdo_delete('core_queue', array('uniacid' => $_W['uniacid'], 'id' => $li['id']));
pdo_update('coupon_record', array('status' => 3), array('acid' => $li['acid'], 'code' => $code['code'], 'card_id' => $li['params']));
}
}
}
}
}
示例12: isset
$page = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : 1;
/* 获取用户留言的数量 */
$sql = "SELECT COUNT(*) FROM " . $ecs->table('comment') . " WHERE parent_id = 0 AND user_id = '{$user_id}'";
$record_count = $db->getOne($sql);
$pager = get_pager('user.php', array('act' => $action), $record_count, $page, 15);
$rank = get_rank_info();
$smarty->assign('info', get_user_default($user_id));
//用户信息
$smarty->assign('vip_name', $rank['rank_name']);
// 用户名
$smarty->assign('comment_list', get_comment_list($user_id, $pager['size'], $pager['start']));
$smarty->assign('pager', $pager);
$smarty->display('user_clips.dwt');
} elseif ($action == 'coupons') {
require_once 'includes/cls_coupon.php';
$couponsConditions = coupon::getCouponsConditions();
$coupons_list = array();
foreach ($couponsConditions as $key => $con) {
$coupons_list[$key] = get_coupons_list($user_id, $key, $con);
}
$smarty->assign('coupons_list', $coupons_list);
$smarty->display('user_clips.dwt');
} elseif ($action == 'return_goods') {
include_once ROOT_PATH . 'includes/lib_clips.php';
$page = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : 1;
/* 获取用户退款申请的总记录数 */
$sql = "SELECT COUNT(*) FROM " . $ecs->table('back_order') . " WHERE is_cancled=0 and user_id=" . $user_id;
$record_count = $db->getOne($sql);
$pager = get_pager('user.php', array('act' => $action), $record_count, $page, 5);
$rank = get_rank_info();
$smarty->assign('info', get_user_default($user_id));
示例13: defined
<?php
/**
* [WEIZAN System] Copyright (c) 2015 012WZ.COM
* WeiZan is NOT a free software, it under the license terms, visited http://www.012wz.com/ for more details.
*/
defined('IN_IA') or exit('Access Denied');
$dos = array('module', 'coupon', 'location', 'discount', 'display', 'del', 'sync', 'modifystock', 'toggle', 'qr', 'record', 'cash', 'gift', 'groupon', 'general_coupon');
$do = in_array($do, $dos) ? $do : 'post';
$op = trim($_GPC['op']) ? trim($_GPC['op']) : 'post';
$acid = intval($_W['acid']);
load()->classs('coupon');
if ($do == 'post') {
$data = array('card' => array('card_type' => 'MEMBER_CARD', 'member_card' => array('base_info' => array('logo_url' => urlencode('http://mmbiz.qpic.cn/mmbiz/qYicJhgpqsd37NCqJIqia4KF9o4fmq7NTgnQMd5vBSwn2ibBRQ4wCLr47ohUI6xicWUc7ibxoyJDubnNs3mxnfSXy2g/0'), 'brand_name' => urlencode('商家信息'), 'color' => 'Color080', 'title' => urlencode('折扣券标题'), 'sub_title' => urlencode('折扣券标题'), 'can_share' => true, 'can_give_friend' => true, 'code_type' => 'CODE_TYPE_TEXT', 'notice' => urlencode('操作提示操作提示'), 'description' => urlencode('使用须知使用须知'), 'service_phone' => urlencode('1000000'), 'get_limit' => 100, 'date_info' => array('type' => 'DATE_TYPE_FIX_TIME_RANGE', 'begin_timestamp' => '1439136000', 'end_timestamp' => '1444838400'), 'sku' => array('quantity' => 10000), 'custom_url_name' => urlencode('立即使用'), 'custom_url' => urlencode('http://bbs.012wz.com'), 'custom_url_sub_title' => urlencode('6个汉字tips'), 'promotion_url_name' => urlencode('营销入口1'), 'promotion_url' => urlencode('http://www.012wz.com')), 'supply_bonus' => true, 'supply_balance' => false, 'prerogative' => urlencode('会员卡特权说明'), 'custom_field1' => array('name_type' => 'FIELD_NAME_TYPE_LEVEL', 'url' => urlencode('http://www.012wz.com')), 'activate_url' => urlencode('http://bbs.012wz.com'), 'custom_cell1' => array('name' => urlencode('使用入口2'), 'tips' => urlencode('激活后显示'), 'url' => urlencode('http://bbs.012wz.com')))));
$acc = new coupon($acid);
$status = $acc->CreateCard(urldecode(json_encode($data)));
print_r($status);
}
if ($do == 'update') {
$data = array('init_bonus' => 100, 'init_balance' => 200, 'membership_number' => 12345678, 'code' => '', 'card_id' => 'pTKzFjtDm_SKwh2vbiLwD2cGO0Ik ', 'custom_field_value1' => '白金会员组');
}
示例14: die
$result['coupon_id'] = $coupon_id;
$result['info'] = '您已经成功领取。';
$result['action'] = ' 您还可以<a href="#">查看我的购物券</a> <a href="' . $staticPages['index'] . '">现在去购物</a>';
} else {
$result['error'] = 1;
$result['info'] = '未知错误。';
$result['action'] = ' 您可以尝试再次领取,或者联系客服!';
}
}
die(json_encode($result));
} elseif ('userCenterGotoPage' == $act) {
require_once 'includes/cls_coupon.php';
require_once 'includes/lib_clips.php';
$type = trim($_REQUEST['type']);
$page = intval(trim($_REQUEST['page']));
$couponCon = coupon::getCouponsConditions($type);
$coupons = get_coupons_list($_SESSION['user_id'], $type, $couponCon, $page);
$result = array('location' => 'coupons', 'type' => $type, 'coupons' => $coupons);
die(json_encode($result));
}
function get_coupons_sql()
{
$sql = "SELECT * FROM " . $GLOBALS['ecs']->table('coupons') . " WHERE is_display = 1 ORDER BY coupon_id DESC LIMIT 9";
return $sql;
}
function get_coupons()
{
$sql = get_coupons_sql();
$coupons = $GLOBALS['db']->getAll($sql);
foreach ($coupons as $key => $value) {
$coupons[$key]['validate_time'] = local_date("Y年m月d日", $value['validate_time']);
示例15: switchType
public function switchType()
{
$db = JFactory::getDBO();
$oldtype = $this->coupon->type;
// Duplicate Coupon at other table
$coupon = new coupon(!$oldtype);
$coupon->createNew($this->coupon->coupon_code, $this->coupon->created_date);
// Switch id over to new table max
$oldid = $this->coupon->id;
$this->coupon->delete();
$this->coupon = $coupon;
// Migrate usage entries
$query = 'UPDATE #__acctexp_couponsxuser' . ' SET `coupon_id` = \'' . $this->coupon->id . '\', `coupon_type` = \'' . $this->coupon->type . '\'' . ' WHERE `coupon_id` = \'' . $oldid . '\' AND `coupon_type` = \'' . $oldtype . '\'';
$db->setQuery($query);
$db->query();
}