"username":"******", "score_add":720 } '; $input = json_decode($input, true); add_score($input); //try to get inserted rank data $query_param = ' { "func":"get_ranklist", "user":"******", "size":1 } '; $query_param = json_decode($query_param, true); $result = get_ranklist($query_param); echo 'result:'; print_r($result); echo 'verify result:'; //verify(); function verify($expected, $real, $matchtype = false) { try { foreach ($expected as $key => $expected_value) { if ($matchtype) { if ($real[$key] !== $expected_value) { return false; } } else { if ($real[$key] != $expected_value) { return false;
function sales_stats($start, $end) { $pwd_info = authority_judge(); if ($pwd_info['company_mgr']) { $platform_list = platform_list(); } $tidy_date = tidysql(); extract($tidy_date); //部门排行 if ($pwd_info['company_mgr'] || $pwd_info['statistic_part_mgr']) { $sql_role_ranklist = " GROUP BY platform "; $sales['role_ranklist'] = get_ranklist($sql_role_ranklist, 'role_ranklist', $start, $end); } //团队排行 if ($pwd_info['statistic_part_mgr']) { $sql_group_ranklist = " AND platform={$_SESSION['role_id']}"; } $sales['group_ranklist'] = get_ranklist($sql_group_ranklist, 'group_ranklist', $start, $end); //成交订单排行 if ($pwd_info['statistic_part_mgr']) { $sql_finish_order_ranklist = " AND platform={$_SESSION['role_id']} "; } elseif ($pwd_info['statistic_group_mgr']) { //$sql_finish_order_ranklist = " AND platform={$_SESSION['role_id']} AND group_id={$_SESSION['group_id']} "; $sql_finish_order_ranklist = " AND platform={$_SESSION['role_id']} AND group_id={$_SESSION['group_id']} GROUP BY admin_id "; } $sales['finish_order_ranklist'] = get_ranklist($sql_finish_order_ranklist, 'finish_order_ranklist', $start, $end); //个人排行 $sales['person_ranklist'] = get_ranklist($sql_person_ranklist, 'personal_ranklist', $start, $end); return $sales; }
$key = 'group_name'; $value = 'final_amount'; break; case 'hide_ordersum_ranklist': $sql_sub = tidysql('sql_finish_order_ranklist'); $result = get_ranklist($sql_sub, 'finish_order_ranklist', $date_start, $date_end); if ($_REQUEST['company_mgr']) { $key = 'role_name'; } else { $key = 'admin_name'; } $value = 'num'; break; case 'hide_person_ranklist': $sql_sub = tidysql('sql_person_ranklist'); $result = get_ranklist($sql_sub, 'personal_ranklist', $date_start, $date_end); $key = 'admin_name'; $value = 'final_amount'; break; case 'hide_service_ranklist': $result = stats_service($date_start, $date_end); $key = 'user_name'; $value = 'num_service'; break; } $table = array(); $rank_count = ceil(count($result) / 10); $off_width = $rank_count >= 3 ? 282 * 3 : 282 * $rank_count; for ($j = 0; $j < $rank_count; $j++) { $table[$j] = '<table style="float:left;margin-right:12px;" width="264px">'; for ($i = $j * 10; $i < $j * 10 + 10; $i++) {