feat: 调整了商品佣金计算逻辑,增加了损耗计算,并更新了相关数据库字段。

This commit is contained in:
mkm 2024-09-19 11:17:27 +08:00
parent 3e794f47a2
commit 88c9fd557c
2 changed files with 15 additions and 9 deletions

View File

@ -72,9 +72,6 @@ class CommissionProductLogic22 extends BaseLogic
if ($product['rose'] >= 6) {
$platform_number = bcmul($total_price, 0.02, 2); //平台
}
if ($product['rose'] >= 12) {
$attrition_number = bcmul($total_price, 0.02, 2); //损耗
}
//零售-供货价
$number3 = bcsub($total_price, $purchase_price, 2);
//会员
@ -92,20 +89,28 @@ class CommissionProductLogic22 extends BaseLogic
$village_number = bcmul($total_price, 0.04, 2); //村长利润
$data[] =$this->village('零售村长', $order, $find, $village_uid, $price, $total_price, $village_number,0.04);
$number1 = bcadd($number1, $village_number, 2);
if ($product['rose'] >= 12) {
$attrition_number = bcmul($total_price, 0.02, 2); //损耗
$data[] =$this->attrition('零售损耗', $order, $find, $price, $total_price,$attrition_number);
}
} elseif ($user['user_ship'] == 3) {
$brigade_number = bcmul($total_price, 0.04, 2); //队长利润
$data[] = $this->brigade('零售队长', $order, $find, $brigade_uid, $price, $total_price, $brigade_number,0.04);
$number1 = bcadd($number1, $brigade_number, 2);
if ($product['rose'] >= 13 && $village_uid>0) {
if ($product['rose'] >= 12 && $village_uid>0) {
$village_number = bcmul($total_price, 0.01, 2); //村长利润
$data[] =$this->village('零售村长', $order, $find, $village_uid, $price, $total_price, $village_number,0.01);
$number1 = bcadd($number1, $village_number, 2);
}
if ($product['rose'] >= 15) {
$attrition_number = bcmul($total_price, 0.02, 2); //损耗
$data[] =$this->attrition('零售损耗', $order, $find, $price, $total_price,$attrition_number);
}
} elseif ($user['user_ship'] == 1) {
$vip_number = bcmul($total_price, 0.06, 2); //会员利润
$data[] = $this->vip_user('零售会员', $order, $find, $uid, $price, $total_price, $vip_number,0.06);
$number1 = bcadd($number1, $vip_number, 2);
if ($product['rose'] >= 13 && $village_uid>0) {
if ($product['rose'] >= 12 && $village_uid>0) {
$village_number = bcmul($total_price, 0.01, 2); //村长利润
$data[] =$this->village('零售村长', $order, $find, $village_uid, $price, $total_price, $village_number,0.01);
$number1 = bcadd($number1, $village_number, 2);
@ -115,6 +120,10 @@ class CommissionProductLogic22 extends BaseLogic
$data[] =$this->village('零售队长', $order, $find, $village_uid, $price, $total_price, $brigade_number,0.01);
$number1 = bcadd($number1, $brigade_number, 2);
}
if ($product['rose'] >= 15) {
$attrition_number = bcmul($total_price, 0.02, 2); //损耗
$data[] =$this->attrition('零售损耗', $order, $find, $price, $total_price,$attrition_number);
}
}
}
//门店利润
@ -134,9 +143,6 @@ class CommissionProductLogic22 extends BaseLogic
if ($product['rose'] >= 6) {
$data[] = $this->platform('零售平台', $order, $find, $price, $total_price,$platform_number);
}
if ($product['rose'] >= 12) {
$data[] =$this->attrition('零售损耗', $order, $find, $price, $total_price,$attrition_number);
}
(new StoreFinanceFlowProduct())->saveAll($data);
}

View File

@ -45,7 +45,7 @@ class StoreCashFinanceFlowLists extends BaseAdminDataLists implements ListsSearc
{
$this->searchWhere[]=['store_id','=',$this->adminInfo['store_id']];
return StoreCashFinanceFlow::where($this->searchWhere)
->field(['id', 'store_id', 'cash_price', 'receivable', 'receipts', 'admin_id', 'file', 'remark', 'status'])
->field(['id', 'store_id', 'cash_price', 'receivable', 'receipts', 'admin_id', 'file','create_time', 'remark', 'status'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()->each(function ($item) {