public static function OnlineIt($order_id, $pay_id, $money, $currency = 'CNY', $service = 'alipay', $bank = '支付宝', $trade_no = '') { list($_, $_, $quantity, $_) = explode('-', $pay_id); if (!$order_id || !$pay_id || $money <= 0) { return false; } $order = Table::Fetch('order', $order_id); $team = Table::Fetch('team', $order['team_id']); $user_id = abs(intval($order['user_id'])); team_state($team); if ($order['state'] == 'unpay') { $table = new Table('pay'); $table->id = $pay_id; $table->vid = $trade_no; $table->order_id = $order_id; $table->money = $money; $table->currency = $currency; $table->bank = $bank; $table->service = $service; $table->create_time = time(); $ia = array('id', 'vid', 'order_id', 'money', 'currency', 'service', 'create_time', 'bank'); if (Table::Fetch('pay', $pay_id) || !$table->insert($ia)) { return false; } //update user money; +money Table::UpdateCache('user', $user_id, array('money' => array("money + {$money}"))); $u = array('user_id' => $user_id, 'admin_id' => 0, 'money' => $money, 'direction' => 'income', 'action' => 'paycharge', 'detail_id' => $pay_id, 'create_time' => time()); DB::Insert('flow', $u); $user = Table::FetchForce('user', $user_id); //print_r($user);exit; if ($user['money'] < $order['origin']) { return false; } if (in_array($team['state'], array('soldout')) || $team['end_time'] < time()) { return false; } Table::UpdateCache('order', $order_id, array('pay_id' => $pay_id, 'money' => $money, 'state' => 'pay', 'trade_no' => $trade_no, 'service' => $service, 'quantity' => $quantity, 'pay_time' => time())); $order = Table::FetchForce('order', $order_id); if ($order['state'] == 'pay') { //TeamBuy Operation ZTeam::BuyOne($order); } } return true; }
if ( $team['team_type'] == 'seconds' && $team['begin_time'] >= $now ) { $diff_time = $left_time = $team['begin_time']-$now; } $left_day = floor($diff_time/86400); $left_time = $left_time % 86400; $left_hour = floor($left_time/3600); $left_time = $left_time % 3600; $left_minute = floor($left_time/60); $left_time = $left_time % 60; /* progress bar size */ $bar_size = ceil(190*($team['now_number']/$team['min_number'])); $bar_offset = ceil(5*($team['now_number']/$team['min_number'])); $partner = Table::Fetch('partner', $team['partner_id']); $team['state'] = team_state($team); /* your order */ if ($login_user_id && 0==$team['close_time'] ) { $order = DB::LimitQuery('order', array( 'condition' => array( 'team_id' => $id, 'user_id' => $login_user_id, 'state' => 'unpay', 'rstate' => 'normal', ), 'one' => true, )); } /* end order */
'offset' => $offset ) ); } else if ($selector == 'askrefund') { // 退款列表协议,修正最土退款订单列表问题 $condition [] = '(allowrefund = "Y" AND state = "pay") OR (state = "unpay" AND allowrefund = "Y" AND rstate = "berefund")'; $count = Table::Count ( 'order', $condition ); list ( $pagesize, $offset, $pagestring ) = pagestring ( $count, 10 ); $orders = DB::LimitQuery ( 'order', array ( 'condition' => $condition, 'order' => 'ORDER BY team_id DESC, id ASC', 'size' => $pagesize, 'offset' => $offset ) ); } $team_ids = Utility::GetColumn ( $orders, 'team_id' ); $teams = Table::Fetch ( 'team', $team_ids ); foreach ( $teams as $tid => $one ) { team_state ( $one ); $teams [$tid] = $one; } $apply_ids = Utility::GetColumn ( $orders, 'apply_id' ); $applys = Table::Fetch ( 'apply', $apply_ids ); // 标记是否可以点评 $orders = markOrderListDp ( $orders, $teams ); $pagetitle = '我的订单'; include template ( 'order_index' );
<?php } else { ?> <h2>进行中的团购项目</h2> <?php }?> <ul class="filter"> <li><?php echo !$team_type ? '全部' : '<a href="?">全部</a>'; ?></li> <li><?php echo $team_type=='normal' ? '团购' : '<a href="?team_type=normal">团购</a>'; ?></li> <li><?php echo $team_type=='seconds' ? '秒杀' : '<a href="?team_type=seconds">秒杀</a>'; ?></li> <li><?php echo $team_type=='goods' ? '商品' : '<a href="?team_type=goods">商品</a>'; ?></li> </ul> </div> <div class="sect"> <table id="orders-list" cellspacing="0" cellpadding="0" border="0" class="coupons-table"> <tr><th width="40">ID</th><th width="400">项目名称</th><th width="80" nowrap>类别</th><th width="100">日期</th><th width="50">成交</th><th width="60" nowrap>价格</th><th width="140">操作</th></tr> <?php if(is_array($teams)){foreach($teams AS $index=>$one) { ?> <?php $oldstate = $one['state']; ?> <?php $one['state'] = team_state($one); ?> <tr <?php echo $index%2?'':'class="alt"'; ?> id="team-list-id-<?php echo $one['id']; ?>"> <td>ID: <?php echo $one['id']; ?><br /> XH: <?php echo $one['sort_order']; ?></a></a></td> <td> <?php echo $one['team_type']=='normal' ? '[团购]' : ''; ?> <?php echo $one['team_type']=='seconds' ? '[秒杀]' : ''; ?> <?php echo $one['team_type']=='goods' ? '[商品]' : ''; ?> <a class="deal-title" href="/team.php?id=<?php echo $one['id']; ?>" target="_blank"><?php echo $one['title']; ?></a> </td> <td nowrap><?php echo $cities[$one['city_id']]['name']; ?><br/><?php echo $groups[$one['group_id']]['name']; ?></td> <td nowrap><?php echo date('Y-m-d',$one['begin_time']); ?><br/><?php echo date('Y-m-d',$one['end_time']); ?></td> <td nowrap><?php echo $one['now_number']; ?>/<?php echo $one['min_number']; ?></td> <td nowrap><span class="money"><?php echo $currency; ?></span><?php echo moneyit($one['team_price']); ?><br/><span class="money"><?php echo $currency; ?></span><?php echo moneyit($one['market_price']); ?></td>
function state_explain($team, $error = 'false') { $state = team_state($team); $state = strtolower($state); switch ($state) { case 'none': return '正在进行中'; case 'soldout': return '已售光'; case 'failure': if ($error) { return '团购失败'; } case 'success': return '团购成功'; default: return '已结束'; } }
} } elseif ($category['zone'] == 'public') { $tcount = Table::Count('topic', array('public_id' => $id)); if ($tcount) { json('本类下存在讨论区话题', 'alert'); } } Table::Delete('category', $id); option_category($category['zone']); Session::Set('notice', '删除分类成功'); json(null, 'refresh'); } else { if ('teamcoupon' == $action) { need_auth('team'); $team = Table::Fetch('team', $id); team_state($team); if ($team['now_number'] < $team['min_number']) { json('团购未结束或未达到最低成团人数', 'alert'); } /* all orders */ $all_orders = DB::LimitQuery('order', array('condition' => array('team_id' => $id, 'state' => 'pay'))); $all_orders = Utility::AssColumn($all_orders, 'id'); $all_order_ids = Utility::GetColumn($all_orders, 'id'); $all_order_ids = array_unique($all_order_ids); /* all coupon id */ $coupon_sql = "SELECT order_id, count(1) AS count FROM coupon WHERE team_id = '{$id}' GROUP BY order_id"; $coupon_res = DB::GetQueryResult($coupon_sql, false); $coupon_order_ids = Utility::GetColumn($coupon_res, 'order_id'); $coupon_order_ids = array_unique($coupon_order_ids); /* miss id */ $miss_ids = array_diff($all_order_ids, $coupon_order_ids);
?> " > <input type="submit" value="筛选" class="formbutton" style="padding:1px 6px;"/></p> <form> </div> <div class="sect"> <table id="orders-list" cellspacing="0" cellpadding="0" border="0" class="coupons-table"> <tr><th width="40">ID</th><th width="400">项目名称</th><th width="80" nowrap>类别</th><th width="100">日期</th><th width="50">成交</th><th width="60" nowrap>价格</th><th width="140">操作</th></tr> <?php if (is_array($teams)) { foreach ($teams as $index => $one) { ?> <?php $oldstate = $one['state']; ?> <?php $one['state'] = team_state($one); ?> <tr <?php echo $index % 2 ? '' : 'class="alt"'; ?> id="team-list-id-<?php echo $one['id']; ?> "> <td><?php echo $one['id']; ?> </a></td> <td> <?php echo $one['team_type'] == 'normal' ? '[团购]' : '';
} /***********************加入的代码:结束*********************************/ /***********************加入的代码:开始*********************************/ $condition = array( 'team_type in ("normal","seconds")', "begin_time < '{$anow}'", "end_time > '{$anow}'", 'big_index' => 'Y', ); $inter_teams = DB::LimitQuery('team', array( 'condition' => $condition, 'order' => 'ORDER BY `sort_order` DESC, `id` DESC', 'size' => 2, )); foreach($inter_teams AS $key=>$value){ $inter_teams[$key]['state'] = team_state($value); } /***********************加入的代码:结束*********************************/ /** * 热门商圈 */ $hot_area_cond = array(); $hot_area_cond['zone'] = 'bizarea'; $hot_area_cond[] = "fid > 0"; $hot_area_cond[] = "hot_order > 0"; $hotAreaBizList = DB::LimitQuery('category',array( 'condition'=>$hot_area_cond, 'size'=>11, 'order'=>'order by hot_order desc' ));