Example #1
0
	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);
	}
Example #2
0
<?php

require_once dirname(dirname(__FILE__)) . '/app.php';
need_login();
$order_id = $id = strval(intval($_GET['id']));
if (!$order_id || !($order = Table::Fetch('order', $order_id))) {
    die('404 Not Found');
}
if ($order['user_id'] != $login_user['id']) {
    redirect(WEB_ROOT . "/team.php?id={$order['team_id']}");
}
if ($order['state'] == 'unpay') {
    redirect(WEB_ROOT . "/team.php?id={$order['team_id']}");
}
$team = Table::FetchForce('team', $order['team_id']);
$partner = Table::Fetch('partner', $order['partner_id']);
$express = $team['delivery'] == 'express';
if ($express) {
    $option_express = Utility::OptionArray(Table::Fetch('category', array('express'), 'zone'), 'id', 'name');
}
if ($team['delivery'] == 'coupon') {
    $cc = array('user_id' => $login_user['id'], 'team_id' => $order['team_id'], 'order_id' => $order['id']);
    $coupons = DB::LimitQuery('coupon', array('condition' => $cc));
} else {
    if ($team['delivery'] == 'voucher') {
        ZVoucher::Assign($order);
        $cc = array('user_id' => $login_user['id'], 'team_id' => $order['team_id'], 'order_id' => $order['id']);
        $vouchers = DB::LimitQuery('voucher', array('condition' => $cc));
    }
}
include template('order_view');
Example #3
0
require_once dirname(__FILE__) . '/current.php';
need_manager();
need_auth('team');
$id = abs(intval($_GET['id']));
$team = $eteam = Table::Fetch('team', $id);
if (is_get() && empty($team)) {
    redirect(WEB_ROOT . '/manage/team/edit.php');
} else {
    if (is_post()) {
        $content = file_get_contents($_FILES['upload_txt']['tmp_name']);
        $lines = preg_split('/([\\r\\n])+/', $content, -1, PREG_SPLIT_NO_EMPTY);
        foreach ($lines as $line) {
            $codes = preg_split('/([,;\\s])+/', $line, -1, PREG_SPLIT_NO_EMPTY);
            $codeone = strval($codes[0]);
            if ($codeone) {
                ZVoucher::Create($codeone, $id);
            }
        }
        $condition = array('team_id' => $id);
        $count = Table::Count('voucher', $condition);
        Table::UpdateCache('team', $id, array('max_number' => $count));
        Session::Set('notice', '上传商户券信息成功');
        redirect(WEB_ROOT . "/manage/team/editvoucher.php?id={$id}");
    }
}
/* voucher list */
$condition = array('team_id' => $id);
$count = Table::Count('voucher', $condition);
list($pagesize, $offset, $pagestring) = pagestring($count, 50);
$vouchers = DB::LimitQuery('voucher', array('condition' => $condition, 'order' => 'ORDER BY order_id DESC, id ASC', 'size' => $pagesize, 'offset' => $offset));
$users = Table::Fetch('user', Utility::GetColumn($vouchers, 'user_id'));