feat: 修改了订单逻辑和商品佣金计算方式
This commit is contained in:
parent
bfecce2d38
commit
ed151b119f
@ -149,7 +149,7 @@ class OrderLogic extends BaseLogic
|
|||||||
|
|
||||||
//利润
|
//利润
|
||||||
// $cart_select[$k]['profit'] = bcmul($v['cart_num'], $onePrice, 2); //利润
|
// $cart_select[$k]['profit'] = bcmul($v['cart_num'], $onePrice, 2); //利润
|
||||||
$cart_select[$k]['purchase'] = bcmul($v['cart_num'], $find['purchase'], 2) ?? 0; //成本
|
$cart_select[$k]['total_purchase'] = bcmul($v['cart_num'], $find['purchase'], 2) ?? 0; //成本
|
||||||
$cart_select[$k]['pay_price'] = bcmul($v['cart_num'], $price, 2); //订单支付金额
|
$cart_select[$k]['pay_price'] = bcmul($v['cart_num'], $price, 2); //订单支付金额
|
||||||
$cart_select[$k]['store_price'] = bcmul($v['cart_num'], $find['cost'], 2) ?? 0; //商户价
|
$cart_select[$k]['store_price'] = bcmul($v['cart_num'], $find['cost'], 2) ?? 0; //商户价
|
||||||
$cart_select[$k]['vip_price'] = bcmul($v['cart_num'], $find['vip_price'], 2) ?? 0; //vip售价
|
$cart_select[$k]['vip_price'] = bcmul($v['cart_num'], $find['vip_price'], 2) ?? 0; //vip售价
|
||||||
@ -181,13 +181,14 @@ class OrderLogic extends BaseLogic
|
|||||||
$cart_select[$k]['cart_info'] = json_encode($cartInfo);
|
$cart_select[$k]['cart_info'] = json_encode($cartInfo);
|
||||||
//理论上每笔都是拆分了
|
//理论上每笔都是拆分了
|
||||||
$cart_select[$k]['name'] = $find['store_name'];
|
$cart_select[$k]['name'] = $find['store_name'];
|
||||||
|
$cart_select[$k]['purchase'] = $find['purchase'];
|
||||||
$cart_select[$k]['imgs'] = $find['image'];
|
$cart_select[$k]['imgs'] = $find['image'];
|
||||||
$cart_select[$k]['store_id'] = $params['store_id'] ?? 0;
|
$cart_select[$k]['store_id'] = $params['store_id'] ?? 0;
|
||||||
$cart_select[$k]['unit_name'] = StoreProductUnit::where(['id' => $find['unit']])->value('name');
|
$cart_select[$k]['unit_name'] = StoreProductUnit::where(['id' => $find['unit']])->value('name');
|
||||||
$cart_select[$k]['total_price'] = $cart_select[$k]['pay_price'];
|
$cart_select[$k]['total_price'] = $cart_select[$k]['pay_price'];
|
||||||
self::$total_price = bcadd(self::$total_price, $cart_select[$k]['total_price'], 2);
|
self::$total_price = bcadd(self::$total_price, $cart_select[$k]['total_price'], 2);
|
||||||
self::$pay_price = bcadd(self::$pay_price, $cart_select[$k]['pay_price'], 2);
|
self::$pay_price = bcadd(self::$pay_price, $cart_select[$k]['pay_price'], 2);
|
||||||
self::$cost = bcadd(self::$cost, $cart_select[$k]['purchase'], 2);
|
self::$cost = bcadd(self::$cost, $cart_select[$k]['total_purchase'], 2);
|
||||||
self::$store_price = bcadd(self::$store_price, $cart_select[$k]['store_price'], 2); //商户价
|
self::$store_price = bcadd(self::$store_price, $cart_select[$k]['store_price'], 2); //商户价
|
||||||
self::$deduction_price = bcadd(self::$deduction_price, $deduction_price, 2); //抵扣金额
|
self::$deduction_price = bcadd(self::$deduction_price, $deduction_price, 2); //抵扣金额
|
||||||
// self::$frozen_money = bcadd(self::$frozen_money, $cart_select[$k]['vip_frozen_price'], 2); //返还金额
|
// self::$frozen_money = bcadd(self::$frozen_money, $cart_select[$k]['vip_frozen_price'], 2); //返还金额
|
||||||
@ -344,7 +345,6 @@ class OrderLogic extends BaseLogic
|
|||||||
$goods_list[$k]['oid'] = $order->id;
|
$goods_list[$k]['oid'] = $order->id;
|
||||||
$goods_list[$k]['uid'] = $uid;
|
$goods_list[$k]['uid'] = $uid;
|
||||||
$goods_list[$k]['cart_id'] = implode(',', $cartId);
|
$goods_list[$k]['cart_id'] = implode(',', $cartId);
|
||||||
$goods_list[$k]['delivery_id'] = $params['store_id']; //商家id
|
|
||||||
}
|
}
|
||||||
(new StoreOrderCartInfo())->saveAll($goods_list);
|
(new StoreOrderCartInfo())->saveAll($goods_list);
|
||||||
$where = ['is_pay' => 0];
|
$where = ['is_pay' => 0];
|
||||||
|
@ -23,11 +23,9 @@ class CommissionProductLogic extends BaseLogic
|
|||||||
*/
|
*/
|
||||||
function calculate_product_flow($find, $order, $village_uid = 0, $brigade_uid = 0, $user_ship = 0, $spread_user_ship = 0)
|
function calculate_product_flow($find, $order, $village_uid = 0, $brigade_uid = 0, $user_ship = 0, $spread_user_ship = 0)
|
||||||
{
|
{
|
||||||
if(isset($order['source']) && $order['source'] == 2){
|
|
||||||
$product = StoreBranchProduct::where('product_id', $find['product_id'])->where('store_id', $order['store_id'])->find();
|
$product = StoreProduct::where('id', $find['product_id'])->find();
|
||||||
}else{
|
|
||||||
$product = StoreProduct::where('id', $find['product_id'])->find();
|
|
||||||
}
|
|
||||||
if ($product) {
|
if ($product) {
|
||||||
//活动商品
|
//活动商品
|
||||||
if ($product['product_type'] == 4) {
|
if ($product['product_type'] == 4) {
|
||||||
@ -64,11 +62,11 @@ class CommissionProductLogic extends BaseLogic
|
|||||||
public function a($find, $order, $village_uid, $brigade_uid, $user_ship, $product)
|
public function a($find, $order, $village_uid, $brigade_uid, $user_ship, $product)
|
||||||
{
|
{
|
||||||
$total_price = bcmul($find['price'], $find['cart_num'], 2);
|
$total_price = bcmul($find['price'], $find['cart_num'], 2);
|
||||||
$purchase_price = bcmul($product['purchase'], $find['cart_num'], 2);
|
$purchase_price = bcmul($find['purchase'], $find['cart_num'], 2);
|
||||||
$price = $find['price'];
|
$price = $find['price'];
|
||||||
|
|
||||||
$rose=0;
|
$rose=0;
|
||||||
$rose_price = bcsub($price, $product['purchase'], 2);
|
$rose_price = bcsub($price, $find['purchase'], 2);
|
||||||
if ($rose_price > 0) {
|
if ($rose_price > 0) {
|
||||||
//利润除于零售
|
//利润除于零售
|
||||||
$price_div = bcdiv($rose_price, $price, 2);
|
$price_div = bcdiv($rose_price, $price, 2);
|
||||||
@ -166,11 +164,11 @@ class CommissionProductLogic extends BaseLogic
|
|||||||
public function b($find, $order, $product, $user_ship)
|
public function b($find, $order, $product, $user_ship)
|
||||||
{
|
{
|
||||||
$total_price = bcmul($find['price'], $find['cart_num'], 2);
|
$total_price = bcmul($find['price'], $find['cart_num'], 2);
|
||||||
$purchase_price = bcmul($product['purchase'], $find['cart_num'], 2);
|
$purchase_price = bcmul($find['purchase'], $find['cart_num'], 2);
|
||||||
$price = $find['price'];
|
$price = $find['price'];
|
||||||
|
|
||||||
$rose=0;
|
$rose=0;
|
||||||
$rose_price = bcsub($price, $product['purchase'], 2);
|
$rose_price = bcsub($price, $find['purchase'], 2);
|
||||||
if ($rose_price > 0) {
|
if ($rose_price > 0) {
|
||||||
//利润除于零售
|
//利润除于零售
|
||||||
$price_div = bcdiv($rose_price, $price, 2);
|
$price_div = bcdiv($rose_price, $price, 2);
|
||||||
@ -215,11 +213,11 @@ class CommissionProductLogic extends BaseLogic
|
|||||||
public function c($find, $order,$product)
|
public function c($find, $order,$product)
|
||||||
{
|
{
|
||||||
$total_price = bcmul($find['price'], $find['cart_num'], 2);
|
$total_price = bcmul($find['price'], $find['cart_num'], 2);
|
||||||
$purchase_price = bcmul($product['purchase'], $find['cart_num'], 2);
|
$purchase_price = bcmul($find['purchase'], $find['cart_num'], 2);
|
||||||
$price = $find['price'];
|
$price = $find['price'];
|
||||||
|
|
||||||
$rose=0;
|
$rose=0;
|
||||||
$rose_price = bcsub($price, $product['purchase'], 2);
|
$rose_price = bcsub($price, $find['purchase'], 2);
|
||||||
if ($rose_price > 0) {
|
if ($rose_price > 0) {
|
||||||
//利润除于零售
|
//利润除于零售
|
||||||
$price_div = bcdiv($rose_price, $price, 2);
|
$price_div = bcdiv($rose_price, $price, 2);
|
||||||
|
@ -684,7 +684,7 @@ class PayNotifyLogic extends BaseLogic
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$info = StoreOrderCartInfo::where('oid', $order['id'])->field('store_id,product_id,price,cart_num')->select();
|
$info = StoreOrderCartInfo::where('oid', $order['id'])->field('store_id,product_id,purchase,price,total_price,cart_num')->select();
|
||||||
$comm = new CommissionProductLogic();
|
$comm = new CommissionProductLogic();
|
||||||
foreach ($info as $k => $v) {
|
foreach ($info as $k => $v) {
|
||||||
$comm->calculate_product_flow($v, $order, $village_uid, $brigade_uid, $user_ship);
|
$comm->calculate_product_flow($v, $order, $village_uid, $brigade_uid, $user_ship);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user