public function getQuarterMinTime()
 {
     $now_year = fToDate(TIME_UTC, 'Y');
     $now_month = fToDate(TIME_UTC, 'n');
     $quarter = ceil($now_month / 3);
     $min_month = ($quarter - 1) * 3 + 1;
     return str2Time($now_year . '-' . $min_month . '-1 00:00:00');
 }
Ejemplo n.º 2
0
 public function medalFormat($uid, &$medals)
 {
     $uid = (int) $uid;
     if (!$uid) {
         return;
     }
     $statistic = FS('Statistics')->getUserStatistics($uid);
     $user = MedalService::getUserInfo($uid);
     $award_medals = explode(',', $user['medals']);
     $award_list = array();
     if (count($award_medals) > 0) {
         $award_list = MedalService::getAwardsByUid($uid);
     }
     $apply_list = MedalService::getApplysByUid($uid);
     foreach ($medals as $key => $medal) {
         $mid = $medal['mid'];
         if (isset($award_list[$mid])) {
             $medal['is_award'] = 1;
         } else {
             $medal['is_award'] = 0;
         }
         $medal['is_allow'] = 1;
         if ($medal['give_type'] == 1) {
             if ($medal['is_award'] == 1) {
                 $medal['award_time'] = fToDate($award_list[$mid]['create_time'], 'Y-m-d');
                 $medal['end_time'] = fToDate($award_list[$mid]['deadline'], 'Y-m-d');
             } else {
                 if (isset($apply_list[$mid])) {
                     $medal['is_apply'] = 1;
                 } else {
                     $medal['is_apply'] = 0;
                     if (!MedalService::checkAllowGroup($user['gid'], $medal['allow_group'])) {
                         $medal['is_allow'] = 0;
                     }
                 }
             }
         } else {
             $condition = $medal['conditions'];
             $is_continue = strpos($condition, 'continue');
             if ($medal['is_award'] == 1) {
                 if ($is_continue === false) {
                     $medal['tips1'] = sprintf(lang('medal', 'medal_award'), $medal['name']);
                 } else {
                     $medal['tips1'] = sprintf(lang('medal', $condition . '_1'), $medal['name'], (int) $statistic[$condition]);
                     $medal['tips2'] = sprintf(lang('medal', $condition . '_alert'));
                 }
             } else {
                 if ($is_continue === false) {
                     $medal['tips1'] = sprintf(lang('medal', 'auto_tip_' . $condition), (int) $medal['confine'] - (int) $user[$condition], (int) $user[$condition]);
                 } else {
                     $medal['tips1'] = sprintf(lang('medal', $condition . '_0'), (int) $medal['confine'] - (int) $statistic[$condition], (int) $statistic[$condition]);
                     $medal['tips2'] = sprintf(lang('medal', $condition . '_alert'));
                 }
             }
         }
         $medals[$key] = $medal;
     }
 }
    /**
     * 最新兑换
     */
    public function getOrderTop($num = 5)
    {
        $sql = 'SELECT o.data_name,o.uid,o.user_name,o.create_time,o.data_num  
				FROM ' . FDB::table('order') . ' AS o 
				INNER JOIN ' . FDB::table('exchange_goods') . ' AS eg ON eg.id = o.rec_id 
				ORDER BY o.id DESC LIMIT 0,' . $num;
        $list = array();
        $query = FDB::query($sql);
        while ($data = FDB::fetch($query)) {
            $data['create_time_format'] = fToDate($data['create_time'], 'H:i:s');
            $list[] = $data;
        }
        return $list;
    }
 public function getPrice($img)
 {
     $dir = './public/upload/temp/' . fToDate(NULL, 'Y/m/d/H');
     $file_name = md5(microtime(true)) . random('6') . '.png';
     makeDir(FANWE_ROOT . $dir);
     $file_path = FANWE_ROOT . $dir . "/" . $file_name;
     $img_data = getUrlContent($img);
     if (empty($img_data) || @file_put_contents($file_path, $img_data) == 0) {
         return false;
     }
     $xs_count = 2;
     $keys = array('7' => array('011111011000111100011110001111000111100011110001111000110111110' => 0, '000110001111000001100000110000011000001100000110000011000111111' => 1, '011111011000111100011000001100001100001100001100001100001111111' => 2, '011111011000111100011000001100011100000011110001111000110111110' => 3, '000011000011100010110010011010001101111111000011000001100000110' => 4, '011111101100000110000011111000000110000011110001111000110111110' => 5, '001111001100001100000111111011000111100011110001111000110111110' => 6, '111111100000110000011000011000001100001100000110000110000011000' => 7, '011111011000111100011110001101111101100011110001111000110111110' => 8, '011111011000111100011110001111000110111111000001100001100111100' => 9), '9' => array('001111100011000110110000011110000011110000011110000011110000011110000011110000011011000110001111100' => 0, '000011000001111000000011000000011000000011000000011000000011000000011000000011000000011000001111110' => 1, '011111100110000110110000011000000011000000110000001100000011000000110000001100000011000000111111111' => 2, '011111100110000110110000011000000011000000110000111100000000110000000011110000011110000110011111100' => 3, '000000110000001110000010110000100110001000110010000110100000110111111111000000110000000110000000110' => 4, '011111111011000000011000000011000000011111100000000110000000011000000011110000011110000110011111100' => 5, '000111110001100000011000000110000000110111100111000110110000011110000011110000011011000110001111100' => 6, '111111111000000011000000110000000110000001100000001100000011000000011000000110000000110000001100000' => 7, '001111100011000110110000011110000011011000110001111100011000110110000011110000011011000110001111100' => 8, '001111100011000110110000011110000011110000011011000111001111011000000011000000110000001100011111000' => 9));
     $configs = array('1' => array('word_width' => 9, 'offset_l' => 20, 'offset_t' => 4, 'word_spacing' => 2, 'd_width' => 5), '2' => array('word_width' => 7, 'offset_l' => 18, 'offset_t' => 4, 'word_spacing' => 2, 'd_width' => 5), '3' => array('word_width' => 7, 'offset_l' => 17, 'offset_t' => 3, 'word_spacing' => 2, 'd_width' => 4));
     $res = imagecreatefrompng($file_path);
     $size = getimagesize($file_path);
     $data = array();
     $offset_r = 0;
     for ($j = $size[0] - 1; $j >= 0; $j--) {
         $rgb = imagecolorat($res, $j, 6);
         $rgbarray = imagecolorsforindex($res, $rgb);
         if ($rgbarray['red'] < 125 || $rgbarray['green'] < 125 || $rgbarray['blue'] < 125) {
             break;
         } else {
             $offset_r++;
         }
     }
     $offset_b = 0;
     for ($i = $size[1] - 1; $i >= 0; $i--) {
         $rgb = imagecolorat($res, 9, $i);
         $rgbarray = imagecolorsforindex($res, $rgb);
         if ($rgbarray['red'] < 125 || $rgbarray['green'] < 125 || $rgbarray['blue'] < 125) {
             break;
         } else {
             $offset_b++;
         }
     }
     $img_width = $size[0];
     if ($offset_b == 9) {
         $config = $configs[2];
     } elseif ($offset_b == 10) {
         $config = $configs[3];
     } else {
         $config = $configs[1];
         $offset_b++;
     }
     $word_width = $config['word_width'];
     $key = $keys[$word_width];
     $offset_l = $config['offset_l'];
     $offset_t = $config['offset_t'];
     $word_spacing = $config['word_spacing'];
     $d_width = $config['d_width'];
     $no_l = $size[0] - ($xs_count * ($word_width + $word_spacing) + $d_width + $offset_r);
     $no_r = $no_l + $d_width;
     for ($i = $offset_t; $i < $size[1] - $offset_b; $i++) {
         $w = 0;
         for ($j = $offset_l; $j < $size[0] - $offset_r; $j++) {
             if ($j >= $no_l && $j < $no_r) {
                 continue;
             }
             $rgb = imagecolorat($res, $j, $i);
             $rgbarray = imagecolorsforindex($res, $rgb);
             if ($rgbarray['red'] < 125 || $rgbarray['green'] < 125 || $rgbarray['blue'] < 125) {
                 $data[$i - $offset_t][$w] = 1;
             } else {
                 $data[$i - $offset_t][$w] = 0;
             }
             $w++;
         }
     }
     $prices = array();
     $length = count($data[0]);
     $height = count($data);
     $count = ($length + $word_spacing) / ($word_width + $word_spacing);
     for ($i = 0; $i < $count; $i++) {
         $x = $i * ($word_width + $word_spacing);
         for ($h = 0; $h < $height; $h++) {
             $temp = '';
             for ($w = $x; $w < $x + $word_width; $w++) {
                 $prices[$i] .= $data[$h][$w];
             }
         }
     }
     $number = '';
     foreach ($prices as $price) {
         $number .= $key[$price];
     }
     @unlink($file_path);
     return (double) $number / 100;
 }
Ejemplo n.º 5
0
 public function exchange()
 {
     global $_FANWE;
     $home_uid = $_FANWE['uid'];
     $home_user = FS('User')->getUserById($home_uid);
     $current_menu = 'exchange';
     $args = array();
     $where = " AND uid = " . $_FANWE['uid'];
     $goods_status = (int) $_FANWE['request']['status'];
     if ($goods_status > 0) {
         $where .= " AND goods_status = " . ($goods_status - 1);
         $args['status'] = $goods_status;
     }
     $count = FDB::resultFirst('SELECT COUNT(id) FROM ' . FDB::table('order') . ' WHERE status < 2 ' . $where);
     $pager = buildPage('u/exchange', $args, $count, $_FANWE['page'], 15);
     $sql = 'SELECT * FROM ' . FDB::table('order') . ' WHERE status < 2 ' . $where . ' GROUP BY id ORDER BY id DESC LIMIT ' . $pager['limit'];
     $res = FDB::query($sql);
     $order_list = array();
     while ($order = FDB::fetch($res)) {
         $order['goods_status'] = lang('exchange', 'order_goods_status_' . $order['goods_status']);
         $order['create_time'] = fToDate($order['create_time']);
         $order_list[] = $order;
     }
     include template('page/u/u_exchange');
     display();
 }
Ejemplo n.º 6
0
} else {
    define('GOODS_ID', $id);
}
require "init.php";
$goods = FDB::fetchFirst('SELECT sg.*,s.cache_data FROM ' . FDB::table('second_goods') . ' AS sg 
	INNER JOIN ' . FDB::table('share') . ' AS s ON s.share_id =  sg.share_id 
	WHERE sg.gid = ' . GOODS_ID);
if ($goods) {
    header('Content-type: text/xml; charset=utf-8');
    $goods['cache_data'] = fStripslashes(unserialize($goods['cache_data']));
    FS('Share')->shareImageFormat($goods);
    unset($goods['cache_data']);
    $xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n";
    $xml .= "<goods>\r\n";
    $xml .= "<ID>" . GOODS_ID . "</ID>\r\n";
    $xml .= "<title><![CDATA[{$goods['name']}]]></title>\r\n";
    $xml .= "<description><![CDATA[{$goods['content']}]]></description>\r\n";
    $xml .= "<price>{$goods['price']}</price>\r\n";
    $xml .= "<totalNumber>{$goods['num']}</totalNumber>\r\n";
    $valid_time = fToDate($goods['valid_time'], 'Ymd') . '000000';
    $xml .= "<validTime>{$valid_time}</validTime>\r\n";
    $xml .= "<transportFee>{$goods['transport_fee']}</transportFee>\r\n";
    $xml .= "<picPath>\r\n";
    foreach ($goods['imgs'] as $img) {
        $xml .= "<path>" . str_replace('./', $_FANWE['site_url'], $img['img']) . "</path>\r\n";
    }
    $xml .= "</picPath>\r\n";
    $xml .= "<sign>{$goods['sign']}</sign>\r\n";
    $xml .= "</goods>";
    echo $xml;
}
Ejemplo n.º 7
0
<?php

$result = array('status' => 1, 'msg' => '');
$id = intval($_FANWE['request']['id']);
if ($id == 0) {
    $result['status'] = 0;
    outputJson($result);
}
if (!checkAuthority('album', 'best')) {
    $result['status'] = 0;
    outputJson($result);
}
$manage_lock = checkIsManageLock('album', $id);
if ($manage_lock !== false) {
    $result['status'] = 1;
    $result['msg'] = $manage_lock['user_name'] . ',' . sprintf(lang('manage', 'manage_lock'), fToDate($manage_lock['time']));
    outputJson($result);
}
$album = FS('Album')->getAlbumById($id, false);
if (empty($album)) {
    $result['status'] = 0;
    outputJson($result);
}
$result['status'] = 1;
if ($album['is_best'] == 0) {
    $result['msg'] = lang('manage', 'manage_best_success');
    $album['is_best'] = 1;
} else {
    $result['msg'] = lang('manage', 'manage_unbest_success');
    $album['is_best'] = 0;
}
Ejemplo n.º 8
0
function m_youhuiItem($item)
{
    global $_FANWE;
    $is_sc = intval($item['is_sc']);
    if ($is_sc > 0) {
        $is_sc = 1;
    }
    //1:已收藏; 0:未收藏
    if (intval($item['begin_time']) > 0 && intval($item['end_time'])) {
        $days = round(($item['end_time'] - $item['begin_time']) / 3600 / 24);
        if ($days < 0) {
            $ycq = fToDate($item['begin_time'], 'Y-m-d') . '至' . fToDate($item['end_time'], 'Y-m-d') . ',已过期';
        } else {
            $ycq = fToDate($item['begin_time'], 'Y-m-d') . '至' . fToDate($item['end_time'], 'Y-m-d') . ',还有' . $days . '天';
        }
    } else {
        $ycq = '';
    }
    return array("id" => $item['id'], "title" => $item['title'], "logo" => $_FANWE['site_url'] . $item['image_1'], "logo_1" => $_FANWE['site_url'] . $item['image_2'], "logo_2" => $_FANWE['site_url'] . $item['image_3'], "merchant_logo" => $_FANWE['site_url'] . $item['merchant_logo'], "create_time" => $item['create_time'], "create_time_format" => getBeforeTimelag($item['create_time']), "xpoint" => $item['merchant_xpoint'], "ypoint" => $item['merchant_ypoint'], "address" => $item['merchant_api_address'], "content" => $item['content'], "is_sc" => $is_sc, "comment_count" => intval($item['comment_count']), "merchant_id" => intval($item['merchant_id']), "begin_time_format" => fToDate($item['begin_time'], 'Y-m-d'), "end_time_format" => fToDate($item['end_time'], 'Y-m-d'), "ycq" => $ycq, "url" => $item['url'], "city_name" => $item['city_name']);
}
Ejemplo n.º 9
0
/**
*
* @param $origin_path 原始物理图片地址
* @param array $sizes 缩略图大小信息 为空则取后台设置
	 	可生成多个缩略图
		数组 参数1 为宽度,
			 参数2为高度,
			 参数3为处理方式:0(缩放,默认),1(剪裁),
			 参数4为是否水印 默认为 0(不生成水印)
	 	array(
			array(300,300,0,0),
			array(100,100,0,0),
			...
		),
* @param $path 存储的路径
* @param $file_name 保存的文件名
* @param $del_temp 是否删除临时文件
* @param $id 关联编号,将根据编号生成目录
*
* 返回 复制成功的信息,如为false则复制失败
* array(
* 	'path'	=>	xxx  //物理路径
*  'url'	=>	xxx  //相对路径
* );
*
* by fzmatthew
*/
function copyImage($origin_path, $sizes = array(), $path = 'share', $del_temp = true, $id = 0)
{
    global $_FANWE;
    static $size_setting = NULL, $image = NULL;
    if ($image === NULL) {
        include_once fimport('class/image');
        $image = new Image();
    }
    if ($path == 'temp') {
        $dir = './public/upload/temp/' . fToDate(NULL, 'Y/m/d/H');
    } else {
        if ($id > 0) {
            $dir = './public/upload/' . $path . '/' . getDirsById($id);
        } else {
            $dir = './public/upload/' . $path . '/' . fToDate(NULL, 'Y/m/d');
        }
    }
    makeDir(FANWE_ROOT . $dir);
    $file_name = md5(microtime(true)) . random('6') . '.jpg';
    $file_path = FANWE_ROOT . $dir . "/" . $file_name;
    $bln = false;
    if (file_exists($origin_path) && @copy($origin_path, $file_path)) {
        $bln = true;
    } else {
        $data = getUrlContent($origin_path);
        if (!empty($data) && @file_put_contents($file_path, $data) > 0) {
            $bln = true;
        }
    }
    if ($bln) {
        $info = $image->getImageInfo($file_path);
        if ($info['type'] != 'jpg' && $info['type'] != 'jpeg') {
            if (!$image->convertType($file_path, $file_path)) {
                return false;
            }
        }
        $water_image = $_FANWE['setting']['water_image'];
        if (!empty($water_image)) {
            $water_image = FANWE_ROOT . $water_image;
        }
        $water_mark = intval($_FANWE['setting']['water_mark']);
        $alpha = intval($_FANWE['setting']['water_alpha']);
        $place = intval($_FANWE['setting']['water_position']);
        if ($sizes !== false && empty($sizes)) {
            if ($size_setting === NULL) {
                if (!isset($_FANWE['cache']['image_sizes'])) {
                    FanweService::instance()->cache->loadCache('image_sizes');
                }
                $size_setting = $_FANWE['cache']['image_sizes'];
            }
            $sizes = $size_setting;
        }
        foreach ($sizes as $size) {
            if ($size[0] > 0 || $size[1] > 0) {
                $thumb_bln = false;
                $thumb_type = isset($size[2]) ? intval($size[2]) : 0;
                if ($thumb = $image->thumb($file_path, $size[0], $size[1], $thumb_type)) {
                    if (isset($size[3]) && intval($size[3]) > 0) {
                        $image->water($thumb['path'], $water_image, $alpha, $place);
                    }
                }
            }
        }
        if ($del_temp) {
            @unlink($origin_path);
        }
        return array('path' => $file_path, 'url' => $dir . "/" . $file_name, 'width' => $info[0], 'height' => $info[1]);
    } else {
        return false;
    }
}
Ejemplo n.º 10
0
    function forum()
    {
        global $_FANWE;
        $current_aid = intval($_FANWE['request']['aid']);
        $_FANWE['nav_title'] = lang('common', 'ask');
        FanweService::instance()->cache->loadCache('forums');
        $forum_list = array();
        foreach ($_FANWE['cache']['forums']['root'] as $forum_rootid) {
            $forum_list[] = $_FANWE['cache']['forums']['all'][$forum_rootid];
        }
        $type = !empty($_FANWE['request']['type']) ? $_FANWE['request']['type'] : "all";
        $asks = $_FANWE['cache']['asks'];
        $user_where = '';
        $page_args = array();
        $where = ' WHERE at.status = 1 ';
        if ($current_aid > 0) {
            $current_ask = $asks[$current_aid];
            if (!empty($current_ask)) {
                $_FANWE['nav_title'] = $current_ask['name'] . ' - ' . $_FANWE['nav_title'];
                $where .= ' AND at.aid = ' . $current_aid;
                $user_where .= ' AND at.aid = ' . $current_aid;
                $page_args['aid'] = $current_aid;
            } else {
                $current_aid = 0;
            }
        }
        switch ($type) {
            case 'best':
                $where .= ' AND at.is_best = 1';
                $best_type = 'current';
                $page_args['type'] = 'best';
                break;
            case 'over':
                $where .= ' AND at.is_solve = 1';
                $over_type = 'current';
                $page_args['type'] = 'over';
                break;
            case 'wait':
                $where .= ' AND at.is_solve = 0';
                $wait_type = 'current';
                $page_args['type'] = 'wait';
                break;
            case 'none':
                $where .= ' AND at.post_count = 0';
                $none_type = 'current';
                $page_args['type'] = 'none';
                break;
            default:
                $all_type = 'current';
                break;
        }
        //热门主题
        $hottopics = FS('Ask')->getHotAsk($current_aid);
        //本吧活跃分子
        $sql = 'SELECT u.uid,u.user_name
			FROM ' . FDB::table('ask_thread') . ' AS at
			LEFT JOIN ' . FDB::table('user_count') . ' AS uc ON uc.uid = at.uid
			LEFT JOIN ' . FDB::table('user') . ' AS u ON u.uid = at.uid
			WHERE at.status = 1 ' . $user_where . ' GROUP BY at.uid
			ORDER BY uc.ask_posts DESC,uc.uid ASC LIMIT 0,9';
        $hotusers = FDB::fetchAll($sql);
        $ask_count = FDB::resultFirst('SELECT count(at.tid) FROM ' . FDB::table('ask_thread') . ' AS at' . $where);
        $page_size = 30;
        $pager = buildPage('ask/' . ACTION_NAME, $page_args, $ask_count, $_FANWE['page'], $page_size);
        //获取数据列表
        $sql = 'SELECT at.tid,at.title,at.uid,at.is_solve,at.is_top,
			at.is_best,at.post_count,at.create_time,at.lastpost,at.lastposter,COUNT(ua.rec_id) AS follow_count
			FROM ' . FDB::table('ask_thread') . ' AS at
			LEFT JOIN ' . FDB::table('user_attention') . ' AS ua ON ua.rec_id = at.tid AND type = \'ask\'
			' . $where . ' GROUP BY at.tid
			ORDER BY at.is_top DESC,at.sort ASC,at.tid DESC LIMIT ' . $pager['limit'];
        $uids = array();
        $users = array();
        $lastposters = array();
        $res = FDB::query($sql);
        $ask_threads = array();
        while ($data = FDB::fetch($res)) {
            if (!empty($data['lastposter'])) {
                $data['last_time'] = fToDate($data['lastpost'], 'Y-m-d');
            }
            $data['time'] = fToDate($data['create_time'], 'Y-m-d');
            $ask_threads[$data['tid']] = $data;
        }
        include template('page/ask/ask_list');
        display();
    }
Ejemplo n.º 11
0
    public function collectReport($time, $page)
    {
        setTimeLimit(3600);
        global $_FANWE;
        if ($page <= 1) {
            FDB::query('TRUNCATE TABLE ' . FDB::table('taobaoke_report_temp'));
        }
        include_once FANWE_ROOT . 'sdks/taobao/TopClient.php';
        include_once FANWE_ROOT . 'sdks/taobao/request/TaobaokeReportGetRequest.php';
        Cache::getInstance()->loadCache('business');
        $client = new TopClient();
        $client->appkey = trim($_FANWE['cache']['business']['taobao']['app_key']);
        $client->secretKey = trim($_FANWE['cache']['business']['taobao']['app_secret']);
        $req = new TaobaokeReportGetRequest();
        $req->setFields("num_iid,outer_code,commission_rate,real_pay_fee,app_key,outer_code,pay_time,pay_price,commission,item_title,item_num,trade_id");
        $page_size = 100;
        $time = fToDate($time, 'Ymd');
        $req->setDate($time);
        $req->setPageNo($page);
        $req->setPageSize($page_size);
        $resp = (array) $client->execute($req, trim($_FANWE["cache"]["business"]["taobao"]["session_key"]));
        $is_complete = false;
        $total_results = 0;
        if (isset($resp['taobaoke_report'])) {
            $count = 0;
            $taobaoke_report = (array) $resp['taobaoke_report'];
            $total_results = (int) $taobaoke_report['total_results'];
            if ($total_results > 0) {
                $taobaoke_report_members = $taobaoke_report['taobaoke_report_members'];
                foreach ($taobaoke_report_members->taobaoke_report_member as $item) {
                    $item = (array) $item;
                    $item['pay_time'] = str2Time($item['pay_time']);
                    $item['outer_code'] = isset($item['outer_code']) ? $item['outer_code'] : '';
                    $pay_day = fToDate($item['pay_time'], 'Y-m-d 00:00:00');
                    $item['pay_day'] = str2Time($pay_day);
                    $item['commission_rate'] = $item['commission_rate'] * 100;
                    $item['item_title'] = addslashes($item['item_title']);
                    if (!empty($item['outer_code']) && preg_match("/^o\\d+\$/", $item['outer_code'])) {
                        $order_id = (double) substr($item['outer_code'], 1);
                        if ($order_id == 0) {
                            continue;
                        }
                        $bln = (int) FDB::resultFirst('SELECT COUNT(id) FROM ' . FDB::table('taobaoke_report') . " \n\t\t\t\t\t\t\tWHERE outer_code = '" . addslashes($item['outer_code']) . "' \n\t\t\t\t\t\t\t\tAND num_iid = '" . addslashes($item['num_iid']) . "' \n\t\t\t\t\t\t\t\tAND pay_time = '" . addslashes($item['pay_time']) . "'");
                        if ($bln > 0) {
                            continue;
                        }
                        $is_insert = false;
                        $res = FDB::query('SELECT * FROM ' . FDB::table('goods_order') . ' 
							WHERE order_id = ' . $order_id . ' AND keyid = \'taobao_' . $item['num_iid'] . '\' AND status = 0');
                        while ($order = FDB::fetch($res)) {
                            $commission = (double) $item['commission'] * ((double) $order['commission_rate'] / 100);
                            if ($_FANWE['setting']['goods_buy_score_type'] > 0 && $_FANWE['setting']['goods_buy_score_rate'] > 0) {
                                $score = 0;
                                $rate = (double) $_FANWE['setting']['goods_buy_score_rate'];
                                if ($_FANWE['setting']['goods_buy_score_type'] == 1) {
                                    $score = (double) $item['real_pay_fee'] * $rate;
                                } else {
                                    $score = (double) $item['commission'] * $rate;
                                }
                                $score = round($score);
                                if ($score > 0) {
                                    FS('User')->updateUserScore((int) $order['uid'], 'goods', 'commission', '成功购买商品 ' . $item['item_title'] . ' 获得积分', $order_id, $score);
                                }
                            }
                            FDB::query('UPDATE ' . FDB::table('goods_order') . ' SET status = 1,settlement_time = ' . TIME_UTC . ',commission = ' . $commission . ' WHERE order_id = ' . $order_id . ' AND uid = ' . (int) $order['uid']);
                            $is_insert = true;
                        }
                        if ($is_insert) {
                            FDB::insert('taobaoke_report_temp', $item);
                        }
                    }
                }
                if ($page * $page_size >= $total_results) {
                    FDB::query('INSERT INTO ' . FDB::table('taobaoke_report') . '(id,trade_id,num_iid,item_title,item_num,pay_price,real_pay_fee,commission_rate,commission,outer_code,app_key,pay_time,pay_day) SELECT NULL AS id,trade_id,num_iid,item_title,item_num,pay_price,real_pay_fee,commission_rate,commission,outer_code,app_key,pay_time,pay_day FROM ' . FDB::table('taobaoke_report_temp') . ' ORDER BY pay_time ASC,trade_id ASC');
                    return 1;
                } else {
                    return 0;
                }
            } else {
                return 1;
            }
        }
        return -1;
    }
Ejemplo n.º 12
0
 /**
  * 获取保存的路径
  * @param string $dir 指定的保存目录
  * @return string
  */
 function getTargetDir($dir)
 {
     if ($dir == 'temp') {
         $dir = './public/upload/temp/' . fToDate(NULL, 'Y/m/d/H');
     } else {
         $dir = './public/upload/' . $dir . '/' . fToDate(NULL, 'Y/m/d');
     }
     makeDir(FANWE_ROOT . $dir);
     return $dir;
 }
Ejemplo n.º 13
0
/**
 * 获取指定时间与当前时间的时间间隔
 *
 * @access  public
 * @param   integer      $time
 *
 * @return  string
 */
function getBeforeTimelag($time)
{
    if ($time == 0) {
        return "";
    }
    static $today_time = NULL, $before_lang = NULL, $beforeday_lang = NULL, $today_lang = NULL, $yesterday_lang = NULL, $hours_lang = NULL, $minutes_lang = NULL, $months_lang = NULL, $date_lang = NULL, $sdate = 86400;
    if ($today_time === NULL) {
        $today_time = fGmtTime();
        $before_lang = lang('time', 'before');
        $beforeday_lang = lang('time', 'beforeday');
        $today_lang = lang('time', 'today');
        $yesterday_lang = lang('time', 'yesterday');
        $hours_lang = lang('time', 'hours');
        $minutes_lang = lang('time', 'minutes');
        $months_lang = lang('time', 'months');
        $date_lang = lang('time', 'date');
    }
    $now_day = str2Time(fToDate($today_time, "Y-m-d"));
    //今天零点时间
    $pub_day = str2Time(fToDate($time, "Y-m-d"));
    //发布期零点时间
    $timelag = $now_day - $pub_day;
    $year_time = fToDate($time, 'Y');
    $today_year = fToDate($today_time, 'Y');
    if ($year_time < $today_year) {
        return fToDate($time, 'Y:m:d H:i');
    }
    $timelag_str = fToDate($time, ' H:i');
    $day_time = 0;
    if ($timelag / $sdate >= 1) {
        $day_time = floor($timelag / $sdate);
        $timelag = $timelag % $sdate;
    }
    switch ($day_time) {
        case '0':
            $timelag_str = $today_lang . $timelag_str;
            break;
        case '1':
            $timelag_str = $yesterday_lang . $timelag_str;
            break;
        case '2':
            $timelag_str = $beforeday_lang . $timelag_str;
            break;
        default:
            $timelag_str = fToDate($time, 'm' . $months_lang . 'd' . $date_lang . ' H:i');
            break;
    }
    return $timelag_str;
}
Ejemplo n.º 14
0
    $data['fix_phone'] = trim($_FANWE['request']['fix']);
    $data['qq'] = trim($_FANWE['request']['qq']);
    $consignment = $data;
    $consignment['uid'] = $_FANWE['uid'];
    if (!empty($consignment['address'])) {
        FDB::insert('user_consignee', $consignment, false, true);
    }
    $data['memo'] = trim($_FANWE['request']['memo']);
    $data['data_name'] = $goods['name'];
    $data['sn'] = fToDate(TIME_UTC, 'ymdHis') . mt_rand(0, 100);
    $data['goods_status'] = 0;
    $data['order_score'] = $goods['integral'];
    $data['data_num'] = 1;
    $data['uid'] = $_FANWE['uid'];
    $data['user_name'] = $_FANWE['user']['user_name'];
    $data['rec_id'] = $id;
    $data['create_time'] = TIME_UTC;
    $data['update_time'] = TIME_UTC;
    $order_id = FDB::insert('order', $data, true);
    while (intval($order_id) == 0) {
        $order['sn'] = fToDate(TIME_UTC, 'ymdHis') . mt_rand(0, 100);
        $order_id = FDB::insert('order', $data, true);
    }
    FDB::query('UPDATE ' . FDB::table('exchange_goods') . ' SET buy_count = buy_count + 1 WHERE id = ' . $id);
    FS("User")->updateUserScore($_FANWE['uid'], "exchange", "submit", addslashes($goods['name']), $order_id, 0 - intval($data['order_score']));
    $result['status'] = 1;
    $result['msg'] = lang('exchange', 'exchange_success');
} else {
    $result['msg'] = lang('exchange', 'goods_error');
}
outputJson($result);