static public function Consume($coupon,$store_id,$doer_id,$verifytype=4) { if ( !$coupon['consume']=='N' ) return false; $u = array( 'ip' => Utility::GetRemoteIp(), 'consume_time' => time(), 'consume' => 'Y', 'verifytype'=>$verifytype, 'store_id'=>$store_id, 'doer_id'=>$doer_id, ); DB::Update('order',$coupon['order_id'],array('had_consume'=>1)); Table::UpdateCache('coupon', $coupon['id'], $u); //判断是否点评返利成功,点评并返利成功的订单的消费券可以继续返利 $orderdp=DB::LimitQuery('order_dp',array( 'condition'=>array('order_id'=>$coupon['order_id'],'has_return'=>1) )); if(!empty($orderdp)){ ZFlow::CreateFromCoupon($coupon); } ZCredit::CreateFromConsume($coupon); return true; }
public static function Create($user_row, $uc = true) { if (function_exists('zuitu_uc_register') && $uc) { $pp = $user_row['password']; $em = $user_row['email']; $un = $user_row['username']; $ret = zuitu_uc_register($em, $un, $pp); if (!$ret) { return false; } } $user_row['username'] = htmlspecialchars($user_row['username']); $user_row['password'] = self::GenPassword($user_row['password']); $user_row['create_time'] = $user_row['login_time'] = time(); $user_row['ip'] = Utility::GetRemoteIp(); $user_row['secret'] = md5(rand(1000000, 9999999) . time() . $user_row['email']); $user_row['id'] = DB::Insert('user', $user_row); $_rid = abs(intval(cookieget('_rid'))); if ($_rid && $user_row['id']) { $r_user = Table::Fetch('user', $_rid); if ($r_user) { ZInvite::Create($r_user, $user_row); ZCredit::Invite($r_user['id']); } } if ($user_row['id'] == 1) { Table::UpdateCache('user', $user_row['id'], array('manager' => 'Y', 'secret' => '')); } return $user_row['id']; }
static public function BuyOne($order) { $order = Table::FetchForce('order', $order['id']); $order_id = abs(intval($order['id'])); $team_id = abs(intval($order['team_id'])); $team = Table::FetchForce('team', $order['team_id']); $plus = $team['conduser']=='Y' ? 1 : $order['quantity']; $team['now_number'] += $plus; /* close time */ if ( $team['max_number']>0 && $team['now_number'] >= $team['max_number'] ) { $team['close_time'] = time(); } /* reach time */ if ( $team['now_number']>=$team['min_number'] && $team['reach_time'] == 0 ) { $team['reach_time'] = time(); } Table::UpdateCache('team', $team['id'], array( 'close_time' => $team['close_time'], 'reach_time' => $team['reach_time'], 'now_number' => array( "`now_number` + {$plus}", ), )); //UPDATE buy_id $SQL = "UPDATE `order` o,(SELECT max(buy_id)+1 AS c FROM `order` WHERE state = 'pay' and team_id = '{$team_id}') AS c SET o.buy_id = c.c, o.luky_id = 100000 + floor(rand()*100000) WHERE o.id = '{$order_id}' AND buy_id = 0;"; DB::Query($SQL); /* send sms Immediately */ if(option_yes('buycouponsms')) sms_buy($order); /* cash flow */ ZFlow::CreateFromOrder($order); /* order : send coupon ? */ ZCoupon::CheckOrder($order); /* order : send voucher ? */ ZVoucher::CheckOrder($order); /* order : send express sms ? */ ZExpress::CheckOrder($order); /* order : invite buy */ ZInvite::CheckInvite($order); ZCredit::UpdateFromOrder($order); }
public static function BuyOne($order) { $order = Table::FetchForce('order', $order['id']); $team = Table::FetchForce('team', $order['team_id']); $plus = $team['conduser'] == 'Y' ? 1 : $order['quantity']; $team['now_number'] += $plus; /* close time */ if ($team['max_number'] > 0 && $team['now_number'] >= $team['max_number']) { $team['close_time'] = time(); } /* reach time */ if ($team['now_number'] >= $team['min_number'] && $team['reach_time'] == 0) { $team['reach_time'] = time(); } Table::UpdateCache('team', $team['id'], array('close_time' => $team['close_time'], 'reach_time' => $team['reach_time'], 'lastbuy_time' => time(), 'now_number' => array("`now_number` + {$plus}"))); /* cash flow */ ZFlow::CreateFromOrder($order); /* order : send coupon ? */ ZCoupon::CheckOrder($order); /* order : invite buy */ ZInvite::CheckInvite($order); /* credit */ ZCredit::Buy($order['user_id'], $order); }
<?php /** * 统一送U币功能 * @author abei <*****@*****.**> */ require_once(dirname(dirname(dirname(__FILE__))) . '/app.php'); need_manager(); need_rbac_auth('credit_song'); if($_POST){ $date = $_POST['date']; $score = $_POST['score']; if(empty($date) or empty($score)){ Session::Set('error', '时间和积分不能为空'); }else{ ZCredit::SongMultiByDate($score, strtotime($date)); Session::Set('notice', '送分成功'); redirect( WEB_ROOT . "/manage/credit/song.php"); } } $cond = array( 'action'=>'multi', ); $logList = DB::LimitQuery('credit',array('condition'=>$cond,'order'=>'order by id desc')); include template('manage_credit_song'); ?>
$daytime = strtotime(date('Y-m-d')); //判断今天是否为1、3、5、7 $today = Utility::GetDate(); $weeks = array('星期一', '星期三', '星期五', '星期天'); if (in_array($today['week'], $weeks)) { json('今天不能签到', 'alert'); } $condition = array('user_id' => $user_id, 'create_time' => $daytime); $have = DB::GetTableRow('daysign', $condition); if ($have) { json(array(array('type' => 'eval', 'data' => 'jQuery("#sign_info").replaceWith(\'' . '<div class="signinfo">您已经签到过了</div>\');')), 'mix'); } $money = abs(strval($INI['system']['givemoney'])); $credit = abs(strval($INI['system']['givecredit'])); if (option_yes('givecredit')) { ZCredit::Create($credit, $user_id, 'daysign'); } if (option_yes('givemoney')) { ZFlow::CreateFromDaysign($user_id, $money); } if ($money == '0' && $credit == '0') { json('暂未设置签到赠送值', 'alert'); } $u = array('user_id' => $user_id, 'credit' => $credit, 'money' => $money, 'create_time' => $daytime); DB::Insert('daysign', $u); $today = Utility::GetDate(); $count = Table::Count('daysign', array('user_id' => $user_id)); $income_money = Table::Count('daysign', array('user_id' => $user_id), 'money'); $income_credit = Table::Count('daysign', array('user_id' => $user_id), 'credit'); json(array(array('type' => 'eval', 'data' => 'jQuery("#sign_info").replaceWith(\'' . '<div class="signinfo-tscg"><span>签到成功</span></div>' . '<div class="sign_info" id="sign_info_a"></div>\');'), array('type' => 'eval', 'data' => 'jQuery("#sign_info_a").replaceWith(\'<div class="sign_info" id="sign_info"></div>' . '<div class="signinfo-ljqd">累计签到' . $count . '次' . ' <a href="http://www.milituan.net/account/loginup.php" target="_blank">[查看]</a></div>\');' . 'jQuery("#nowsign").replaceWith(\'<div class="havesign" id="nowsign">' . '<div class="weekday">' . $today['week'] . '</div></div>\');' . 'jQuery("#showSignTips").replaceWith(\'<div class="signtip" id="showSignTips">今日已签到</div>\');')), 'mix'); }
$u['password'] = strval($_POST['password']); $u['email'] = strval($_POST['email']); $u['city_id'] = isset($_POST['city_id']) ? abs(intval($_POST['city_id'])) : abs(intval($city['id'])); if ($_POST['subscribe']) { ZSubscribe::Create($u['email'], abs(intval($u['city_id']))); } if (!Utility::ValidEmail($u['email'], true)) { Session::Set('error', 'Email地址为无效地址'); redirect(WEB_ROOT . '/account/loginup_qzone.php'); } if ($_POST['password']) { if (option_yes('emailverify')) { $u['enable'] = 'N'; } if ($user_id = ZUser::Create($u)) { ZCredit::Register($user_id); if (option_yes('emailverify')) { mail_sign_id($user_id); Session::Set('unemail', $_POST['email']); redirect(WEB_ROOT . '/account/signuped.php'); } else { ZLogin::Login($user_id); redirect(get_loginpage(WEB_ROOT . '/index.php')); } } else { $au = Table::Fetch('user', $_POST['email'], 'email'); if ($au) { Session::Set('error', '创建失败,Email已被使用'); redirect(WEB_ROOT . '/account/loginup_qzone.php'); } else { Session::Set('error', '创建失败,用户名已被使用');
<?php include template("header");?> <div class="layout"> <div class="team_main" style="overflow:hidden"> <div class="box-content"> <div class="dashboard" id="dashboard"><ul><?php echo current_account('/credit/score.php'); ?></ul> </div> <div class="left"> <div class="head-mymlt"> <h2></h2> <ul><?php echo current_credit_index('records'); ?></ul> </div> <div class="credit-title size14-black">当前的账户积分是:<strong class="size24-red"><?php echo moneyit($login_user['score']); ?></strong>分</div> <div class="sect" style="border: 1px solid #E5E5E5;"> <table id="order-list" cellspacing="0" cellpadding="0" border="0" class="coupons-table"> <tr><th width="150" height="36" align="left" bgcolor="#F8F7F7" class="b-bottom"><div class="left-10px">兑换时间</div></th><th width="398" align="center" bgcolor="#F8F7F7" class="b-bottom">详情</th><th width="150" align="center" bgcolor="#F8F7F7" class="b-bottom">状态</th></tr> <?php if(is_array($credits)){foreach($credits AS $index=>$one) { ?> <tr <?php echo $index%2?'':'class="alt"'; ?>><td height="32" style="text-align:left;" class="b-bottom"><div class="left-10px"><?php echo date('Y-m-d H:i', $one['create_time']); ?></div></td><td align="left" class="b-bottom"><?php echo ZCredit::Explain($one); ?></td><td align="center" class="b-bottom"><?php if(($one['state']=='unpay')){?>未发货<?php } else { ?>已发货<?php }?></td></tr> <?php }}?> <tr><td colspan="4"><div class="fanye"><?php echo $pagestring; ?></div></td></tr> </table> </div> </div> <div class="right"> <?php include template("block_side_score");?> </div> </div> </div> </div>
<h2></h2> <ul><?php echo current_credit_index('score'); ?></ul> </div> <div class="credit-title size14-black">当前的账户U币是:<strong class="size24-red"><?php echo moneyit($login_user['score']); ?></strong>个</div> <div class="sect" style="border: 1px solid #E5E5E5;"> <table id="order-list" cellspacing="1" cellpadding="0" border="0" class="coupons-table"> <tr><th width="150" height="36" align="left" bgcolor="#F8F7F7" class="b-bottom"><div class="left-10px">时间</div></th><th width="378" align="center" bgcolor="#F8F7F7" class="b-bottom">详情</th><th width="80" align="center" bgcolor="#F8F7F7" class="b-bottom">收支</th> <th width="90" align="center" bgcolor="#F8F7F7" class="b-bottom">U币</th></tr> <?php if(is_array($credits)){foreach($credits AS $index=>$one) { ?> <tr <?php echo $index%2?'':'class="alt"'; ?>><td height="32" align="left" class="b-bottom" ><div class="left-10px"><?php echo date('Y-m-d H:i', $one['create_time']); ?></div></td><td class="b-bottom" ><?php echo ZCredit::Explain($one); ?></td> <td align="center" class="<?php echo $one['direction']; ?> b-bottom" ><?php echo $one['score']>0?'增加':'减少'; ?></td><td align="center" class="b-bottom" ><?php echo moneyit($one['score']); ?></td></tr> <?php }}?> <tr><td colspan="4"><div class="fanye"><?php echo $pagestring; ?></div></td></tr> </table></div> </div> <div class="right"> <?php include template("block_side_score");?> </div>
<?php require_once "alipay.config.php"; require_once "lib/alipay_notify.class.php"; $alipayNotify = new AlipayNotify($aliapy_config); $verify_result = $alipayNotify->verifyReturn(); if ($verify_result) { $ali_user = ZUser::Check_alifast($_GET['user_id'], $_GET['real_name'], $_GET['email']); if ($ali_user) { Session::Set('user_id', $ali_user['id']); Session::Set('ali_token', $_GET['token']); ZCredit::Login($ali_user['id']); //etao专用 if ($_GET['target_url'] != "") { $url = $_GET['target_url']; echo "<script>window.location='{$url}';</script>"; exit; } redirect(get_loginpage(WEB_ROOT . '/index.php')); } else { Session::Set('error', '验证失败'); redirect(WEB_ROOT . '/index.php'); } } else { echo "验证失败"; } ?>
?> <br/><?php if ($users[$one['user_id']]['city_id']) { echo $allcities[$users[$one['user_id']]['city_id']]['name']; } else { ?> 其他<?php } ?> </td> <td><span class="currency"></span><?php echo moneyit($one['score']); ?> </td> <td><?php echo ZCredit::Explain($one); ?> </td> <td>操作</td> </tr> <?php } } ?> <tr><td colspan="8"><?php echo $pagestring; ?> </tr> </table> </div> </div>
$login_user = ZUser::GetLogin($_POST['email'], $_POST['password']); if (!$login_user) { Session::Set('error', '登录失败'); redirect(WEB_ROOT . '/account/login.php'); } else { if (option_yes('mobilecode') && $login_user['emailable'] == 'Y' && $login_user['enable'] == 'N') { $user['id'] = $login_user['id']; Session::Set('error', '请验证手机号'); die(include template('account_signmobile')); } else { if (option_yes('emailverify') && $login_user['emailable'] == 'N' && $login_user['enable'] == 'N' && $login_user['secret']) { Session::Set('unemail', $_POST['email']); redirect(WEB_ROOT . '/account/verify.php'); } else { Session::Set('user_id', $login_user['id']); if (abs(intval($_POST['auto_login']))) { ZLogin::Remember($login_user); } ZUser::SynLogin($login_user['username'], $_POST['password']); ZCredit::Login($login_user['id']); redirect(get_loginpage(WEB_ROOT . '/index.php')); } } } } $currefer = strval($_GET['r']); if ($currefer) { Session::Set('loginpage', udecode($currefer)); } $pagetitle = '登录'; include template('account_login');
$secretcode = trim(strval($_GET['secretcode'])); $condition = array('tools' => $mobile, 'enable' => 'N', 'user_id' => $user_id); //json($user_id, 'alert'); $sms = DB::GetTableRow('toolsbind', $condition); if (!$sms) { json(array(array('data' => '非法访问!', 'type' => 'alert'), array('data' => 'X.boxClose();', 'type' => 'eval')), 'mix'); } if ($sms['secret'] != $secretcode) { json('短信认证码不正确,请重新输入!', 'alert'); } else { ZToolsbind::Enable($mobile, true, $user_id); // 给ubi $user = Table::Fetch('user', $user_id); if ($user['is_mobile'] == 0) { // 开始送 ZCredit::Create(27, $user_id, 'register'); DB::Update('user', $user_id, array('is_mobile' => 1)); } json(array(array('data' => '绑定成功', 'type' => 'alert'), array('data' => 'X.boxClose();', 'type' => 'eval'), array('data' => 'null', 'type' => 'refresh')), 'mix'); } } else { if ('getverifycode1' == $action) { $mobile = strval($_GET['mobile']); if (!Utility::IsMobile($mobile)) { json('手机号码不正确', 'alert'); } else { $sendcount = Table::Count('verifycode', array('status' => 1, 'getip' => Utility::GetRemoteIp(), 'dateline > ' . (time() - 3600) . '')); if ($sendcount >= 1) { json('每IP每手机号每小时只能获取一次验证码', 'alert'); } else { $exists = Table::Count('user', array('mobile' => $mobile));
require_once(dirname(dirname(dirname(__FILE__))) . '/app.php'); need_manager(); need_rbac_auth('credit_setting'); if (is_post()){ $action = strval($_POST['action']); if ( 'charge' == $action ) { $username = strval($_POST['username']); $credit = intval($_POST['credit']); if (is_numeric($username)) $u = Table::Fetch('user', $username); elseif (strpos($username, '@')) $u = Table::Fetch('user', $username, 'email'); else $u = Table::Fetch('user', $username, 'username'); if ($u && $credit) { ZCredit::Create($credit, $u['id'], 'charge', 0); log_admin('credit', $u['username'].'用户积分充值',$u); redirect(null, '用户积分充值成功!'); } } else if ( 'settings' == $action ) { $INI['credit']['register'] = abs(intval($_POST['credit']['register'])); $INI['credit']['login'] = abs(intval($_POST['credit']['login'])); $INI['credit']['invite'] = abs(intval($_POST['credit']['invite'])); $INI['credit']['buy'] = abs(intval($_POST['credit']['buy'])); $INI['credit']['pay'] = 0 + ($_POST['credit']['pay']); $INI['credit']['charge'] = 0 + ($_POST['credit']['charge']); $INI['credit']['comment'] = abs(intval($_POST['credit']['comment'])); configure_save('credit'); log_admin('credit', '设置积分规则',$_POST); redirect(null, '设置积分规则成功!');
static public function CreateFromCharge($money,$user_id,$time,$service='alipay',$trade_no=''){ global $option_service; if (!$money || !$user_id || !$time) return 0; $pay_id = "charge-{$user_id}-{$time}"; $pay = Table::Fetch('pay', $pay_id); if ( $pay ) return 0; $order_id = ZOrder::CreateFromCharge($money,$user_id,$time,$service); if (!$order_id) return 0; //insert pay record $pay = array( 'id' => $pay_id, 'vid' => $trade_no, 'order_id' => $order_id, 'bank' => $option_service[$service], 'currency' => 'CNY', 'money' => $money, 'service' => $service, 'create_time' => $time, ); DB::Insert('pay', $pay); ZCredit::Charge($user_id, $money); //end// //update user money; $user = Table::Fetch('user', $user_id); Table::UpdateCache('user', $user_id, array( 'money' => array( "money + {$money}" ), )); $u = array( 'user_id' => $user_id, 'admin_id' => 0, 'money' => $money, 'direction' => 'income', 'action' => 'charge', 'detail_id' => $pay_id, 'create_time' => $time, ); return DB::Insert('flow', $u); }
json('非法访问', 'alert'); } if ('ordercomment' == $action) { if ($order['comment_time'] && time() - $order['comment_time'] > 7 * 86400) { json('点评时间已经超过一周,不能再次修改', 'alert'); } $team = Table::Fetch('team', $order['team_id']); $partner = Table::Fetch('partner', $team['partner_id']); $html = render('ajax_dialog_ordercomment'); json($html, 'dialog'); } elseif ('editcomment' == $action) { $team = Table::Fetch('team', $order['team_id']); $partner_id = abs(intval($team['partner_id'])); $order = Table::Fetch('order', $id); if (!$order['comment_content']) { ZCredit::Comment($order['user_id']); } $u = array('comment_grade' => strval($_GET['s']), 'comment_content' => strval($_GET['t']), 'comment_wantmore' => strval($_GET['w']), 'partner_id' => $partner_id); if (!$order['comment_time']) { $u['comment_time'] = time(); } Table::UpdateCache('order', $id, $u); /* update partner */ $c = array('partner_id' => $partner_id, 'state' => 'pay', 'comment_display' => 'Y', 'comment_time > 0'); $l = DB::LimitQuery('order', array('condition' => $c, 'select' => 'COUNT(1) AS count, comment_grade', 'order' => 'GROUP BY comment_grade')); $l = Utility::OptionArray($l, 'comment_grade', 'count'); $u = array('comment_good' => abs(intval($l['good'])), 'comment_none' => abs(intval($l['none'])), 'comment_bad' => abs(intval($l['bad']))); Table::UpdateCache('partner', $partner_id, $u); /* end update */ json(array(array('data' => '点评成功', 'type' => 'alert'), array('data' => 'X.boxClose();', 'type' => 'eval'), array('data' => 'null', 'type' => 'refresh')), 'mix'); }
<?php require_once dirname(dirname(__FILE__)) . '/app.php'; need_login(); $id = abs(intval($_GET['id'])); $action = strval($_GET['action']); if ($action == 'exchange') { $goods = Table::Fetch('goods', $id); if ($goods['consume'] >= $goods['number']) { json('本商品已兑换完毕', 'alert'); } if ($goods['score'] > $login_user['score']) { json('你的积分余额不足,兑换失败', 'alert'); } if (ZCredit::Create(0 - $goods['score'], $login_user_id, 'exchange', $id)) { Table::UpdateCache('goods', $id, array('consume' => array('`consume` + 1'))); $v = "兑换商品[{$goods['title']}]成功,消耗积分{$goods['score']}"; Session::Set('notice', "兑换商品[{$goods['title']}]成功,消耗积分{$goods['score']}"); redirect(WEB_ROOT . "/credit/goods.php"); } else { json('兑换失败', 'alert'); } }
$order = Table::Fetch('order', $id); $rid = strtolower(strval($_GET['rid'])); if ($rid == 'credit') { ZFlow::CreateFromRefund($order); } else { Table::UpdateCache('order', $id, array('service' => 'cash', 'rstate' => 'berefund', 'state' => 'unpay')); } /* team -- */ $team = Table::Fetch('team', $order['team_id']); team_state($team); if ($team['state'] != 'failure') { $minus = $team['conduser'] == 'Y' ? 1 : $order['quantity']; Table::UpdateCache('team', $team['id'], array('now_number' => array("now_number - {$minus}"))); } /* credit */ ZCredit::Refund($order['user_id'], $order); /* coupons */ if (in_array($team['delivery'], array('coupon', 'pickup'))) { $coupons = Table::Fetch('coupon', array($order['id']), 'order_id'); foreach ($coupons as $one) { Table::Delete('coupon', $one['id']); } } else { if ($team['delivery'] == 'voucher') { DB::Update('voucher', array('order_id' => $order['id']), array('order_id' => 0, 'user_id' => 0, 'sms' => 0)); } } /* order update */ Table::UpdateCache('order', $id, array('express_no' => '')); log_admin('order', '订单' . $order['id'] . '退款'); Session::Set('notice', '退款成功');
<h2>兑换记录</h2> <ul class="filter"> <li><a href="/manage/credit/ajax.php?action=edit" class="ajaxlink">新建兑换商品</a></li> <li class="current"><a href="/manage/credit/records.php">兑换记录</a></li> </ul> </div> <div class="sect"> <table id="orders-list" cellspacing="0" cellpadding="0" border="0" class="coupons-table"> <tr><th width="50">ID</th><th width="200">Email/用户名</th><th width="100" nowrap>收货人</th><th width="40">电话</th><th width="400">详情</th><th width="200">操作</th></tr> <?php if(is_array($credits)){foreach($credits AS $index=>$one) { ?> <tr <?php echo $index%2?'':'class="alt"'; ?> id="team-list-id-<?php echo $one['id']; ?>"> <td><?php echo $one['id']; ?></td> <td><?php echo $users[$one['user_id']]['email']; ?><br/><?php echo $users[$one['user_id']]['username']; ?><?php if(Utility::IsMobile($users[$one['user_id']]['mobile'])){?> » <a href="/ajax/misc.php?action=sms&v=<?php echo $users[$one['user_id']]['mobile']; ?>" class="ajaxlink">短信</a><?php }?></td> <td><?php echo $one['rname']; ?></td> <td><span class="currency"></span><?php echo $one['rmobile']; ?></td> <td><?php echo ZCredit::Explain($one); ?></td> <td><a href="/manage/credit/ajax.php?action=view&id=<?php echo $one['id']; ?>" class="ajaxlink">详情</a> | <?php if(($one['state']=='unpay')){?><a href="/manage/credit/ajax.php?action=checkexpress&id=<?php echo $one['id']; ?>" class="ajaxlink">未发货</a><?php } else { ?>已发货<?php }?></td> </tr> <?php }}?> <tr><td colspan="8"><?php echo $pagestring; ?></tr> </table> </div> </div> <div class="box-bottom"></div> </div> </div> </div> </div> <!-- bd end --> </div> <!-- bdw end --> <?php include template("manage_footer");?>