|
@@ -1627,15 +1627,16 @@ function endTime($time){
|
|
|
if (function_exists('get_budget') == false) {
|
|
|
function get_budget(int $cat_id = 0, string $relaComNo = '', int $platform_id = 0,bool $is_show_more=false)
|
|
|
{
|
|
|
- $sale_rate_1 = Db::name('company_cat_profit')
|
|
|
- ->where(['is_del' => 0, 'cat_id' => $cat_id, 'companyNo' => $relaComNo])
|
|
|
- ->findOrEmpty();
|
|
|
-
|
|
|
- $sale_rate_2 = Db::name('company_platform_cat_profit')
|
|
|
- ->where(['is_del' => 0, 'companyNo' => $relaComNo, 'platform_id' => $platform_id, 'cat_id' => $cat_id, 'status' => 1])
|
|
|
- ->findOrEmpty();
|
|
|
+// $sale_rate_1 = (new \app\admin\model\CompanyCatProfit)->GetAllRate($relaComNo,$cat_id);
|
|
|
+// if($sale_rate_1->isEmpty()) throw new \think\Exception("该分类未找到有关毛利信息");
|
|
|
+// $sale_rate_2 = Db::name('company_platform_cat_profit')
|
|
|
+// ->where(['is_del' => 0, 'companyNo' => $relaComNo, 'platform_id' => $platform_id, 'cat_id' => $cat_id, 'status' => 1])
|
|
|
+// ->findOrEmpty();
|
|
|
|
|
|
if ($is_show_more) {
|
|
|
+ $sale_rate_1 = (new \app\admin\model\CompanyCatProfit)->GetAllRate($relaComNo,$cat_id);
|
|
|
+ if($sale_rate_1->isEmpty()) throw new \think\Exception('该分类未找到有关毛利信息');
|
|
|
+ $sale_rate_2 = (new \app\admin\model\CompanyPlatformCatProfit)->GetAllRate($relaComNo,$cat_id,$platform_id);
|
|
|
//返回多个字段的和
|
|
|
return [
|
|
|
'rate' => (($sale_rate_1['rate'] ?? 0) + ($sale_rate_2['rate'] ?? 0)) / 100,
|
|
@@ -1645,7 +1646,12 @@ if (function_exists('get_budget') == false) {
|
|
|
'sale_rate' => (($sale_rate_1['sale_rate'] ?? 0) + ($sale_rate_2['sale_rate'] ?? 0)) / 100,
|
|
|
'lower_rate'=>0,//boss利率,默认0,数据库没有这个值
|
|
|
];
|
|
|
- } else return (($sale_rate_1['sale_rate'] ?? 0) + ($sale_rate_2['sale_rate'] ?? 0)) / 100; //此时的毛利率要取两个毛利的和
|
|
|
+ } else {
|
|
|
+ $sale_rate_1 = (new \app\admin\model\CompanyCatProfit)->GetRate($relaComNo,$cat_id,"sale_rate");
|
|
|
+ if($sale_rate_1==0) throw new \think\Exception('该分类未找到有关毛利信息');
|
|
|
+ $sale_rate_2 = (new \app\admin\model\CompanyPlatformCatProfit)->GetRate($relaComNo,$cat_id,$platform_id,'sale_rate');
|
|
|
+ return ($sale_rate_1 + $sale_rate_2) / 100;
|
|
|
+ } //此时的毛利率要取两个毛利的和
|
|
|
|
|
|
}
|
|
|
}
|