引用:
2,特殊: 乙申请时,直接扣积分,不加到暂扣,暂扣字段此时加被查看的和被通过所需的积分,被查看时,再扣积分,通过后,再扣一次积分,查看和通过都需要也扣暂扣字段的积分。如乙撤销申请,则把暂扣积分加回去积分字段。
这话实在看得一头雾水,都不知道是扣什么从哪里扣,下面就以我所能理解的方式扣了
代码:
sub req { #申请(类型,用户名,扣除积分,所需积分) my $type = shift; my $name = shift; my $jifen = shift; my $req_jifen = shift; my $userinfo = getuserinfo($name); if($type == 1){ $userinfo->{'temp_jifen'} += $jifen; $userinfo->{'jifen'} -= $jifen; }elsif($type == 2){ $userinfo->{'temp_jifen'} += $req_jifen; $userinfo->{'jifen'} -= $jifen; } saveuserinfo($userinfo); return 1; }
sub dereq { #取消申请(用户名) my $name = shift; my $userinfo = getuserinfo($name); $userinfo->{'jifen'} += $userinfo->{'temp_jifen'}; saveuserinfo($userinfo); return 1; }
sub agn { #同意(类型,用户名,积分) my $type = shift; my $name = shift; my $jifen = shift; my $userinfo = getuserinfo($name); if($type == 1){ $userinfo->{'temp_jifen'} = 0; }elsif($type == 2){ $userinfo->{'temp_jifen'} -= $jifen; } saveuserinfo($userinfo); return 1; }
sub view { #查看(用户名,积分) my $name = shift; my $jifen = shift; my $userinfo = getuserinfo($name); $userinfo->{'temp_jifen'} -= $jifen; saveuserinfo($userinfo); return 1; }
|