02 | if ( time () - $this->M_LoginTime > 3600) |
04 | $dsql->ExecuteNoneQuery( "update `qm_member` set logintime='" . time (). "',loginip='" .GetIP(). "' where mid='" .$this->fields['mid ']."' ;"); |
05 | PutCookie( "DedeLoginTime" , time (),$this->M_KeepTime); |
07 | + $this->updateDownloadCredit(); |
10 | if ($this->M_Rank>10 && $this->M_HasDay>0) $sta .= " 剩余天数: <font color='red'>" .$this->M_HasDay. "</font> 天 " ; |
11 | elseif($this->M_Rank>10) $sta .= " <font color='red'>会员升级已经到期</font> " ; |
12 | + $sta .= sprintf( '月免费下载次数 %d/%d' , $this->M_DownloadCounter, $this->M_DownloadCredit); |
16 | $sta .= " 拥有金币:{$this->M_Money} 个, 积分:{$this->M_Scores} 分。" ; |
20 | + function updateDownloadCredit(){ |
22 | + $dc_month = date ( 'Ym' ); |
23 | + $rank = $dsql->GetOne( "Select membername,download_credit From `qm_arcrank` where rank='" .$this->M_Rank. "'" ); |
24 | + $this->M_DownloadCredit = $rank[ 'download_credit' ]; |
25 | + $this->M_DownloadMonth = $this->fields[ 'download_month' ]; |
26 | + if ($this->M_DownloadMonth < $dc_month){ |
27 | + $dsql->ExecuteNoneQuery("UPDATE `qm_member` |
28 | + SET download_month=$dc_month, |
29 | + download_credit = {$rank[ 'download_credit' ]} |
31 | + WHERE mid= '".$this->M_ID."' "); |
33 | + $this->M_DownloadCounter = $this->fields[ 'download_counter' ]; |
34 | + $this->M_DownloadMonth = $dc_month; |
38 | 下载时在扣除金币的时候和之前一样,如果已经购买不再重复购买和使用授信额度。当需要购买时,优先使用剩余的授信额度,如果授信额度用完才继续进入购买金币流程。 |
41 | @@ -196,25 +196,40 @@ else if ($ open ==2) |
46 | - if ( $needMoney > $cfg_ml->M_Money || $cfg_ml->M_Money== '' ) |
48 | - $msgtitle = "你没有权限下载软件:{$arctitle}!" ; |
49 | - $moremsg = "这个软件需要 <font color='red'>" .$needMoney. " 金币</font> 才能下载,你目前拥有金币:<font color='red'>" .$cfg_ml->M_Money. " 个</font> !" ; |
50 | - include_once(DEDETEMPLATE. '/plus/view_msg.htm' ); |
52 | + // 会员等级有相应的下载授信额度,则直接扣减额度,扣减完毕后才需要购买 |
53 | + if ($cfg_ml->M_Rank && $cfg_ml->M_DownloadCredit && $cfg_ml->M_DownloadCounter < $cfg_ml->M_DownloadCredit){ |
54 | + $inquery = "INSERT INTO `qm_member_operation`(mid,oldinfo,money,mtime,buyid,product,pname,sta) |
55 | + VALUES ( '".$cfg_ml->M_ID."' , '$arctitle' , '$needMoney' , '".time()."' , 'ARCHIVE".$id."' , 'archive' , '下载软件(授信)' , 2); "; |
57 | + if ( !$dsql->ExecuteNoneQuery($inquery) ) |
59 | + ShowMsg( '记录定单失败, 请返回' , '-1' ); |
63 | + $dsql->ExecuteNoneQuery( "UPDATE `qm_member` SET download_counter = download_counter + 1 WHERE mid='" .$cfg_ml->M_ID. "'" ); |
66 | - $inquery = "INSERT INTO `qm_member_operation`(mid,oldinfo,money,mtime,buyid,product,pname,sta) |
67 | - VALUES ( '".$cfg_ml->M_ID."' , '$arctitle' , '$needMoney' , '".time()."' , 'ARCHIVE".$id."' , 'archive' , '下载软件' , 2); "; |
69 | - if ( !$dsql->ExecuteNoneQuery($inquery) ) |
71 | - ShowMsg( '记录定单失败, 请返回' , '-1' ); |
75 | + if ( $needMoney > $cfg_ml->M_Money || $cfg_ml->M_Money== '' ) |
77 | + $msgtitle = "你没有权限下载软件:{$arctitle}!" ; |
78 | + $moremsg = "这个软件需要 <font color='red'>" .$needMoney. " 金币</font> 才能下载,你目前拥有金币:<font color='red'>" .$cfg_ml->M_Money. " 个</font> !" ; |
79 | + include_once(DEDETEMPLATE. '/plus/view_msg.htm' ); |
83 | + $inquery = "INSERT INTO `qm_member_operation`(mid,oldinfo,money,mtime,buyid,product,pname,sta) |
84 | + VALUES ( '".$cfg_ml->M_ID."' , '$arctitle' , '$needMoney' , '".time()."' , 'ARCHIVE".$id."' , 'archive' , '下载软件' , 2); "; |
86 | + if ( !$dsql->ExecuteNoneQuery($inquery) ) |
88 | + ShowMsg( '记录定单失败, 请返回' , '-1' ); |
92 | + $dsql->ExecuteNoneQuery( "UPDATE `qm_member` SET money = money - $needMoney WHERE mid='" .$cfg_ml->M_ID. "'" ); |
95 | - $dsql->ExecuteNoneQuery( "UPDATE `qm_member` SET money = money - $needMoney WHERE mid='" .$cfg_ml->M_ID. "'" ); |
|