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'); }
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; }
/** * 获取指定时间与当前时间的时间间隔 * * @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; }
<?php $id = intval($_FANWE['request']['id']); if ($id == 0) { exit; } if (!checkAuthority('second', 'edit')) { exit; } $manage_lock = checkIsManageLock('second', $id); if ($manage_lock !== false) { exit; } $sql = "select * from " . FDB::table("second_goods") . " where gid = " . $id; $old = FDB::fetchFirst($sql); if (empty($old)) { deleteManageLock('second', $id); exit; } $share_id = $old['share_id']; $update = array('name' => htmlspecialchars(trim($_FANWE['request']['name'])), 'content' => htmlspecialchars(trim($_FANWE['request']['content'])), 'sid' => (int) $_FANWE['request']['cid'], 'city_id' => (int) $_FANWE['request']['city_id'], 'num' => (int) $_FANWE['request']['num'], 'price' => (double) $_FANWE['request']['price'], 'transport_fee' => (double) $_FANWE['request']['transport_fee'], 'valid_time' => str2Time($_FANWE['request']['valid_time'])); FDB::update('second_goods', $update, 'gid = ' . $id); FS('Share')->updateShare($share_id, $update['title'], $update['content']); createManageLog('second', 'edit', $id, lang('manage', 'manage_edit_success')); deleteManageLock('second', $id); $msg = lang('manage', 'manage_edit_success'); include template('manage/tooltip'); display();