feat: 添加了根据毛利率计算产品流的功能
This commit is contained in:
parent
78aa37bb3b
commit
1ffd1193c1
@ -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;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
22
app/common/model/distribution/Distribution.php
Normal file
22
app/common/model/distribution/Distribution.php
Normal file
@ -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';
|
||||
|
||||
|
||||
}
|
@ -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';
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user