任务统计提交

This commit is contained in:
2025-12-18 16:30:46 +08:00
parent 3c3c332d05
commit e9eaedd14d
4 changed files with 290 additions and 10 deletions

View File

@@ -252,4 +252,29 @@ class Activities extends Model
}
}
//获取礼包总价值
public static function get_gift_bag_total_price($gift_bag_id){
$gift_bag_detail = Db::name('vs_gift_bag_detail')->where(['gift_bag_id'=>$gift_bag_id])->select();
$total_price = 0;
foreach ($gift_bag_detail as $k=>$v){
switch ($v['type']) {
case 1: //金币
$total_price += $v['quantity']*$v['gold'];
break;
case 2: //礼物 方法2添加到用户礼物背包
$gift_price = db::name('vs_gift')->where(['gid'=>$v['foreign_id']])->value('gift_price');
$total_price += $gift_price * $v['quantity'];
break;
case 3: //坐骑 方法3添加到用户装扮
$decorate_price = db::name('vs_decorate_price')->where(['id'=>$v['foreign_id']])->value('price');
$total_price += $decorate_price * $v['quantity'];
break;
case 4: //道具 方法5钻石
$total_price += $v['quantity']*$v['gold'];
break;
}
}
return $total_price;
}
}