Re: [請益] 上下線抽佣金的系統設計?

看板PHP作者時間16年前 (2009/08/22 11:11), 編輯推噓1(101)
留言2則, 2人參與, 最新討論串2/2 (看更多)
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
$per[1],$per[3]的值顛倒了
08/22 17:40, 2F
文章代碼(AID): #1AZs7vVn (PHP)
討論串 (同標題文章)
文章代碼(AID): #1AZs7vVn (PHP)