[PHP] 纯文本查看 复制代码add_action( 'wp_ajax_erphp_task_win', 'erphp_task_win_callback');
function erphp_task_win_callback(){
global $current_user;
$status = 0;$msg = '操作失败';
$task_id = esc_sql($_POST['task_id']);
$bid_id = esc_sql($_POST['bid_id']);
if($task_id && $bid_id && erphp_task_active()){
$post = get_post($task_id);
if($post){
$task_status = get_post_meta($post->ID,'task_status',true);
$task_type = get_post_meta($post->ID,'task_type',true);
if($post->post_author == $current_user->ID && !$task_status){
if($task_type == '1'){
update_post_meta($post->ID,'task_status',1);
}else{
$task_people = get_post_meta($post->ID,'task_people',true);
$task_people_win = get_post_meta($post->ID,'task_people_win',true);
$task_people_win = $task_people_win?$task_people_win:0;
if($task_people){
if($task_people_win == $task_people - 1){
update_post_meta($post->ID,'task_status',1);
}
}
update_post_meta($post->ID,'task_people_win',$task_people_win+1);
}
update_comment_meta($bid_id,'bid_win',1);
if(function_exists("_mbt_add_notice")){
if(get_comment($bid_id)->user_id){
_mbt_add_notice(get_comment($bid_id)->user_id, '您好,您在任务《'.get_post($task_id)->post_title.'》的投标已中标。[url=]查看详情[/url]', 'task_win', $bid_id);
}
}
$status = 1;
$msg = '操作成功';
$task_budget_money = sprintf("%.2f",$task_budget_money );
$user_ids = $wpdb->get_results("select distinct(user_id) from $wpdb->comments where comment_post_ID='".$post->ID."' and comment_ID in (select comment_id from $wpdb->commentmeta where meta_key='bid_win' and meta_value='1')");
$price = (100-$erphp_task_fee2)*0.01*$task_budget_money;
$erphp_aff_money = get_option('erphp_aff_money');
if($erphp_aff_money && function_exists('addUserAff')){
addUserAff($user_id->user_id, $price);
}else{
addUserMoney($user_id->user_id, $price);
}
}else{
$msg = '抱歉,暂无权限操作';
}
}
}
$result = array(
'status' => $status,
'msg' => $msg
);
header('Content-type: application/json');
echo json_encode($result);
exit;
}
[color=]上面是中标代码
[color=]下面是任务完结给钱代码
[PHP] 纯文本查看 复制代码add_action( 'wp_ajax_erphp_task_done', 'erphp_task_done_callback');
function erphp_task_done_callback(){
global $wpdb,$current_user;
$status = 0;$msg = '操作失败';
$task_id = esc_sql($_POST['task_id']);
if($task_id && erphp_task_active()){
$post = get_post($task_id);
if($post){
$task_status = get_post_meta($post->ID,'task_status',true);
if($post->post_author == $current_user->ID && $task_status == '1'){
update_post_meta($post->ID,'task_status',2);
$status = 1;
$msg = '操作成功';
$task_paid = get_post_meta($post->ID,'task_paid',true);
if(erphp_task_erphpdown_active() && $task_paid){
$task_budget_money = get_post_meta($post->ID,'task_budget_money',true);
if($task_budget_money){
$task_type = get_post_meta($post->ID,'task_type',true);
$erphp_task_fee2 = get_option("erphp_task_fee2")?get_option("erphp_task_fee2"):'0';
if($task_type == '1'){
$user_ids = $wpdb->get_results("select distinct(user_id) from $wpdb->comments where comment_post_ID='".$post->ID."' and comment_ID in (select comment_id from $wpdb->commentmeta where meta_key='bid_win' and meta_value='1')");
if ( $user_ids ) {
foreach ( $user_ids as $user_id ) {
$price = (100-$erphp_task_fee2)*0.01*$task_budget_money;
$erphp_aff_money = get_option('erphp_aff_money');
if($erphp_aff_money && function_exists('addUserAff')){
addUserAff($user_id->user_id, $price);
}else{
addUserMoney($user_id->user_id, $price);
}
if(function_exists('addUserMoneyLog')){
addUserMoneyLog($user_id->user_id, $price, '任务奖励');
}
if(function_exists("_mbt_add_notice")){
if($user_id->user_id){
_mbt_add_notice($user_id->user_id, '您好,您在任务《'.get_post($task_id)->post_title.'》的投标已验收完成,赏金已自动打入您的账号。[url=]查看详情[/url]', 'task_done', $task_id);
}
}
}
}
}elseif($task_type == '2'){
$task_people = get_post_meta($post->ID,'task_people',true);
//$task_budget_money = sprintf("%.2f",$task_budget_money / intval($task_people));
$task_budget_money = sprintf("%.2f",$task_budget_money );
$user_ids = $wpdb->get_results("select distinct(user_id) from $wpdb->comments where comment_post_ID='".$post->ID."' and comment_ID in (select comment_id from $wpdb->commentmeta where meta_key='bid_win' and meta_value='1')");
if ( $user_ids ) {
foreach ( $user_ids as $user_id ) {
$price = (100-$erphp_task_fee2)*0.01*$task_budget_money;
$erphp_aff_money = get_option('erphp_aff_money');
if($erphp_aff_money && function_exists('addUserAff')){
addUserAff($user_id->user_id, $price);
}else{
addUserMoney($user_id->user_id, $price);
}
if(function_exists('addUserMoneyLog')){
addUserMoneyLog($user_id->user_id, $price, '任务奖励');
}
if(function_exists("_mbt_add_notice")){
if($user_id->user_id){
_mbt_add_notice($user_id->user_id, '您好,您在任务《'.get_post($task_id)->post_title.'》的投标已验收完成,赏金已自动打入您的账号。[url=]查看详情[/url]', 'task_done', $task_id);
}
}
}
}
}
}
}
}else{
$msg = '抱歉,暂无权限操作';
}
}
}
$result = array(
'status' => $status,
'msg' => $msg
);