Re: [請益] 上下線抽佣金的系統設計?
table
id parent money
A null 0
B A 0
D B 0
$per[1]=0.03;//global or static
$per[2]=0.1;
$per[3]=0.15;
function children_money($ids,$level=1){
global $db,$per;
if(empty($per[$level])) return 0;//level don't start from 0
$m=$db->get_var("select sum(money) from table where id in (".implode($ids,",").")");
$m*=$per[$level];
$children=$db->get_results("select id from table
where parent in (".implode($ids,",").")");
return $m+children_money($children,$level+1);
}
我想應該是這樣吧
※ 引述《jami520 (我的生命因你而發光)》之銘言:
: 假設有三層會員關係
: A - 3%
: B C - 10%
: D E F G - 15%
: 假設A底下有B與C下線,B與C個別有D和E以及F與G下線
: 當G消費的時候,G可以拿到回饋金15%,C可以拿到G消費金額的10%
: A可以拿到消費金額的3%
: 而F消費一樣可以拿到回饋金,C與A也可以拿到F消費金額的10%與3%
: 像這樣子的架構,資料表要怎樣設計呢?
: 而拿到回饋金的時候,怎樣更新上線以及上上線的佣金呢? 謝謝~
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 58.114.192.119
※ 編輯: KiroKu 來自: 58.114.192.119 (08/22 11:12)
※ 編輯: KiroKu 來自: 58.114.192.119 (08/22 11:22)
推
08/22 11:37, , 1F
08/22 11:37, 1F
→
08/22 17:40, , 2F
08/22 17:40, 2F
討論串 (同標題文章)
PHP 近期熱門文章
PTT數位生活區 即時熱門文章