diff --git a/app/common/logic/CommissionProductLogic.php b/app/common/logic/CommissionProductLogic.php index eecff27f..d8a5db42 100644 --- a/app/common/logic/CommissionProductLogic.php +++ b/app/common/logic/CommissionProductLogic.php @@ -1,7 +1,9 @@ -<?php +<?php + namespace app\common\logic; use app\common\model\store_branch_product\StoreBranchProduct; +use app\common\model\store_finance_flow_product\StoreFinanceFlowProduct; use app\common\model\store_order_cart_info\StoreOrderCartInfo; /** @@ -14,21 +16,36 @@ class CommissionProductLogic extends BaseLogic /** * 根据毛利率计算 */ - function calculate_product_flow($oid,$store_id,$product_id,$village_uid=0, $brigade_uid=0){ - - $find=StoreOrderCartInfo::where($oid,$product_id)->field('price,cart_num,rose')->find(); - if($find && $find['rose']>0){ - $product= StoreBranchProduct::where('store_id',$store_id)->where('product_id',$product_id)->find(); - $price=bcmul($find['price'], $find['cart_num'], 2); - // $rose= bcdiv($find['rose'], 100, 2); + function calculate_product_flow($oid, $store_id, $product_id, $village_uid = 0, $brigade_uid = 0) + { + + $find = StoreOrderCartInfo::where($oid, $product_id)->field('price,cart_num,rose')->find(); + if ($find && $find['rose'] > 0) { + $product = StoreBranchProduct::where('store_id', $store_id)->where('product_id', $product_id)->find(); + if ($product) { + if ($product['rose'] >= 4 && $product['rose'] < 8) { + $rose = bcdiv($find['rose'], 100, 2); + $commission = bcmul($product['purchase'], $rose, 4); + StoreFinanceFlowProduct::create([ + 'store_id' => $store_id, + 'product_id' => $product_id, + 'number' => $commission, + 'oid' => $oid, + 'type' => 2, + 'status' => 1, + ]); + } elseif ($product['rose'] >= 8) { + + + } + } + $price = bcmul($find['price'], $find['cart_num'], 2); // $price=bcsub($price, $price - + // ) // bcsub($price, $find['rose'], 2); // return $price; } } - - -} \ No newline at end of file +} diff --git a/app/common/model/distribution/Distribution.php b/app/common/model/distribution/Distribution.php new file mode 100644 index 00000000..f63be4b9 --- /dev/null +++ b/app/common/model/distribution/Distribution.php @@ -0,0 +1,22 @@ +<?php + +namespace app\common\model\distribution; + + +use app\common\model\BaseModel; +use think\model\concern\SoftDelete; + + +/** + * 角色分润规则模型 + * Class distribution + * @package app\common\model\order + */ +class Distribution extends BaseModel +{ + use SoftDelete; + protected $name = 'distribution'; + protected $deleteTime = 'delete_time'; + + +} \ No newline at end of file diff --git a/app/common/model/store_finance_flow_product/StoreFinanceFlowProduct.php b/app/common/model/store_finance_flow_product/StoreFinanceFlowProduct.php new file mode 100644 index 00000000..f371f35b --- /dev/null +++ b/app/common/model/store_finance_flow_product/StoreFinanceFlowProduct.php @@ -0,0 +1,20 @@ +<?php + +namespace app\common\model\store_finance_flow_product; + + +use app\common\model\BaseModel; +use think\model\concern\SoftDelete; + + +/** + * 财务流水商品明细 + * Class StoreFinanceFlowProduct + * @package app\common\model\store_finance_flow_product + */ +class StoreFinanceFlowProduct extends BaseModel +{ + use SoftDelete; + protected $name = 'store_finance_flow_product'; + protected $deleteTime = 'delete_time'; +} \ No newline at end of file