本篇主要介紹php提成方案的資料庫設計及功能,有興趣的朋友參考下,希望對大家有幫助。
最近CRM專案中用到了遞歸提成的方案,分析如下:
SQL語句如下:
CREATE TABLE `crm_proxy_bonux_rule` ( `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '超过的部份提成规则ID', `bouns_rule_name` varchar(20) NOT NULL COMMENT '规则名称,如D套餐0-20范围', `rid` bigint(20) DEFAULT NULL COMMENT '为0,就是默认的全局设置', `start_rang` smallint(6) DEFAULT NULL COMMENT '开始范围', `end_rang` smallint(6) DEFAULT NULL COMMENT '结束范围', `bonus_rate` smallint(6) DEFAULT NULL COMMENT '提成率', `bonus_reward` decimal(8,2) DEFAULT NULL COMMENT '奖励现金', `chain_pre` int(11) DEFAULT NULL COMMENT '链表上一个值默认为0,表示根结点', `chain_next` int(11) DEFAULT NULL COMMENT '链表下一个值', `is_standard` enum('0','1') DEFAULT '0' COMMENT '是否是标准', PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8;
PHP實作程式碼如下:
private function bouns_recursion($range,$standard,&$rule_list,$amount){ $price = 1000; $max = $standard['end_rang'] ;//最大值 $min = $standard['start_rang'] ;//最小值 $bonus_rate = $standard['bonus_rate'];//分红率 if($range<$min){ return false; } $standard_amount = 0; $plus = 0; //是否是标准 第一个 if($standard['is_standard']==1){ $standard_amount = $price * $min * $bonus_rate / 100; //求提成 600 300 }else{ $plus = 1; //第二次要累加 } if($range > $max){ $number = ($max - $min) + $plus;//算出差值值 5 4-3 == 1 $amount = ($price * $number * $bonus_rate / 100); //求提成 200 }else{ $number = ($range - $min ) + $plus;//算出差值值 4 1 $amount = ($price * $number * $bonus_rate / 100); //求提成 } $amount = $amount + $standard_amount;//800 if(!empty($rule_list[$standard['chain_next']]) && $range > $max){ return $amount += $this->bouns_recursion($range, $rule_list[$standard['chain_next']], $rule_list,$amount); } return $amount; }
總結:以上就是本篇的全部內容,希望對大家的學習有所幫助。
相關推薦:
以上是php提成方案的資料庫設計與功能的詳細內容。更多資訊請關注PHP中文網其他相關文章!

aphpdepentioncontiveContainerIsatoolThatManagesClassDeptions,增強codemodocultion,可驗證性和Maintainability.itactsasaceCentralHubForeatingingIndections,因此reducingTightCightTightCoupOulplingIndeSingantInting。

選擇DependencyInjection(DI)用於大型應用,ServiceLocator適合小型項目或原型。 1)DI通過構造函數注入依賴,提高代碼的測試性和模塊化。 2)ServiceLocator通過中心註冊獲取服務,方便但可能導致代碼耦合度增加。

phpapplicationscanbeoptimizedForsPeedAndeffificeby:1)啟用cacheInphp.ini,2)使用preparedStatatementSwithPdoforDatabasequesies,3)3)替換loopswitharray_filtaray_filteraray_maparray_mapfordataprocrocessing,4)conformentnginxasaseproxy,5)

phpemailvalidation invoLvesthreesteps:1)格式化進行regulareXpressecthemailFormat; 2)dnsvalidationtoshethedomainhasavalidmxrecord; 3)

tomakephpapplicationsfaster,關注台詞:1)useopcodeCachingLikeLikeLikeLikeLikePachetoStorePreciledScompiledScriptbyTecode.2)MinimimiedAtabaseSqueriSegrieSqueriSegeriSybysequeryCachingandeffeftExting.3)Leveragephp7 leveragephp7 leveragephp7 leveragephpphp7功能forbettercodeefficy.4)

到ImprovephPapplicationspeed,關注台詞:1)啟用opcodeCachingwithapCutoredUcescriptexecutiontime.2)實現databasequerycachingingusingpdotominiminimizedatabasehits.3)usehttp/2tomultiplexrequlexrequestsandreduceconnection.4 limitesclection.4.4

依赖注入(DI)通过显式传递依赖关系,显著提升了PHP代码的可测试性。1)DI解耦类与具体实现,使测试和维护更灵活。2)三种类型中,构造函数注入明确表达依赖,保持状态一致。3)使用DI容器管理复杂依赖,提升代码质量和开发效率。

DatabasequeryoptimizationinPHPinvolvesseveralstrategiestoenhanceperformance.1)Selectonlynecessarycolumnstoreducedatatransfer.2)Useindexingtospeedupdataretrieval.3)Implementquerycachingtostoreresultsoffrequentqueries.4)Utilizepreparedstatementsforeffi


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

MantisBT
Mantis是一個易於部署的基於Web的缺陷追蹤工具,用於幫助產品缺陷追蹤。它需要PHP、MySQL和一個Web伺服器。請查看我們的演示和託管服務。

EditPlus 中文破解版
體積小,語法高亮,不支援程式碼提示功能

VSCode Windows 64位元 下載
微軟推出的免費、功能強大的一款IDE編輯器

ZendStudio 13.5.1 Mac
強大的PHP整合開發環境

PhpStorm Mac 版本
最新(2018.2.1 )專業的PHP整合開發工具