feat: 修正商品和订单金额计算逻辑
This commit is contained in:
parent
663defd80d
commit
e7687a25a5
@ -193,27 +193,31 @@ class CommissionProductLogic extends BaseLogic
|
|||||||
*/
|
*/
|
||||||
public function b($find, $order, $product,$user_ship)
|
public function b($find, $order, $product,$user_ship)
|
||||||
{
|
{
|
||||||
// $rose = bcdiv($product['rose'], 100, 2);
|
$total_price = bcmul($product['price'], $find['cart_num']);
|
||||||
$total_price = bcmul($product['cost'], $find['cart_num']);
|
$purchase_price = bcmul($product['purchase'], $find['cart_num']);
|
||||||
$price = $product['cost'];
|
$price=$product['purchase'];
|
||||||
//门店
|
|
||||||
|
$brigade_number = bcmul($purchase_price, 0.02, 2);//队长
|
||||||
|
$village_number = bcmul($brigade_number, 0.1, 2);//村长
|
||||||
|
$platform_number = bcmul($purchase_price, 0.02, 2);//平台
|
||||||
|
|
||||||
|
$number1 = bcadd($brigade_number, $village_number, 2);
|
||||||
|
$number2 = bcadd($number1, $platform_number, 2);
|
||||||
|
|
||||||
|
//零售-供货价
|
||||||
|
$number3 = bcsub($total_price, $purchase_price, 2);
|
||||||
|
|
||||||
|
//门店利润
|
||||||
|
if($number3<=0){
|
||||||
|
$store_number = 0;
|
||||||
|
}else{
|
||||||
|
$store_number = bcsub($number3, $number2, 2);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//队长
|
||||||
$data[] = [
|
$data[] = [
|
||||||
'nickname' => '门店',
|
'nickname' => '商户价队长预留',
|
||||||
'store_id' => $order['store_id'],
|
|
||||||
'product_id' => $find['product_id'],
|
|
||||||
'other_uid' => 0,
|
|
||||||
'price' => $price,
|
|
||||||
'total_price' => $total_price,
|
|
||||||
'cart_num' => $find['cart_num'],
|
|
||||||
'rate' => 0.05,
|
|
||||||
'number' => bcmul($total_price, 0.05, 2),
|
|
||||||
'oid' => $order['id'],
|
|
||||||
'type' => 1,
|
|
||||||
'status' => 1,
|
|
||||||
];
|
|
||||||
//平台
|
|
||||||
$data[] = [
|
|
||||||
'nickname' => '平台',
|
|
||||||
'store_id' => $order['store_id'],
|
'store_id' => $order['store_id'],
|
||||||
'product_id' => $find['product_id'],
|
'product_id' => $find['product_id'],
|
||||||
'other_uid' => 0,
|
'other_uid' => 0,
|
||||||
@ -221,11 +225,61 @@ class CommissionProductLogic extends BaseLogic
|
|||||||
'total_price' => $total_price,
|
'total_price' => $total_price,
|
||||||
'cart_num' => $find['cart_num'],
|
'cart_num' => $find['cart_num'],
|
||||||
'rate' => 0.02,
|
'rate' => 0.02,
|
||||||
'number' => bcmul($total_price, 0.02, 2),
|
'number' => $brigade_number,
|
||||||
|
'oid' => $order['id'],
|
||||||
|
'type' => 4,
|
||||||
|
'status' => 1,
|
||||||
|
'is_activity' => 1,
|
||||||
|
];
|
||||||
|
//村长
|
||||||
|
$data[] = [
|
||||||
|
'nickname' => '商户价村长预留',
|
||||||
|
'store_id' => $order['store_id'],
|
||||||
|
'product_id' => $find['product_id'],
|
||||||
|
'other_uid' => 0,
|
||||||
|
'price' => $price,
|
||||||
|
'total_price' => $brigade_number,
|
||||||
|
'cart_num' => 0,
|
||||||
|
'rate' => 0.01,
|
||||||
|
'number' => $village_number,
|
||||||
|
'oid' => $order['id'],
|
||||||
|
'type' => 3,
|
||||||
|
'status' => 1,
|
||||||
|
'is_activity' => 1,
|
||||||
|
];
|
||||||
|
//门店
|
||||||
|
$data[] = [
|
||||||
|
'nickname' => '商户价门店',
|
||||||
|
'store_id' => $order['store_id'],
|
||||||
|
'product_id' => $find['product_id'],
|
||||||
|
'other_uid' => 0,
|
||||||
|
'price' => $price,
|
||||||
|
'total_price' => $store_number,
|
||||||
|
'cart_num' => $find['cart_num'],
|
||||||
|
'rate' => 0,
|
||||||
|
'number' => $store_number,
|
||||||
|
'oid' => $order['id'],
|
||||||
|
'type' => 1,
|
||||||
|
'status' => 1,
|
||||||
|
'is_activity' => 1,
|
||||||
|
];
|
||||||
|
//平台
|
||||||
|
$data[] = [
|
||||||
|
'nickname' => '商户价平台',
|
||||||
|
'store_id' => $order['store_id'],
|
||||||
|
'product_id' => $find['product_id'],
|
||||||
|
'other_uid' => 0,
|
||||||
|
'price' => $price,
|
||||||
|
'total_price' => $platform_number,
|
||||||
|
'cart_num' => $find['cart_num'],
|
||||||
|
'rate' => 0.02,
|
||||||
|
'number' => $platform_number,
|
||||||
'oid' => $order['id'],
|
'oid' => $order['id'],
|
||||||
'type' => 2,
|
'type' => 2,
|
||||||
'status' => 1,
|
'status' => 1,
|
||||||
|
'is_activity' => 1,
|
||||||
];
|
];
|
||||||
|
|
||||||
$data[] = [
|
$data[] = [
|
||||||
'nickname' => '消耗',
|
'nickname' => '消耗',
|
||||||
'store_id' => $order['store_id'],
|
'store_id' => $order['store_id'],
|
||||||
|
@ -48,7 +48,6 @@ class StoreOrderLogic extends BaseLogic
|
|||||||
$cart_select = Cart::whereIn('id', $cartId)->where($where)->field('id,product_id,cart_num')->select()->toArray();
|
$cart_select = Cart::whereIn('id', $cartId)->where($where)->field('id,product_id,cart_num')->select()->toArray();
|
||||||
if (empty($cart_select)) {
|
if (empty($cart_select)) {
|
||||||
throw new BusinessException('购物车为空');
|
throw new BusinessException('购物车为空');
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
self::$total_price = 0;
|
self::$total_price = 0;
|
||||||
@ -238,7 +237,7 @@ class StoreOrderLogic extends BaseLogic
|
|||||||
$query->field(['id', 'oid', 'product_id', 'cart_info']);
|
$query->field(['id', 'oid', 'product_id', 'cart_info']);
|
||||||
}])->where($params)->find();
|
}])->where($params)->find();
|
||||||
if (empty($order)) {
|
if (empty($order)) {
|
||||||
throw new \Exception('订单不存在');
|
throw new BusinessException('订单不存在');
|
||||||
}
|
}
|
||||||
$order['pay_time'] = $order['pay_time'] > 0 ? date('Y-m-d H:i:s', $order['pay_time']) : '';
|
$order['pay_time'] = $order['pay_time'] > 0 ? date('Y-m-d H:i:s', $order['pay_time']) : '';
|
||||||
$order['status_name'] = OrderEnum::getOrderType($order['status']) ?? '';
|
$order['status_name'] = OrderEnum::getOrderType($order['status']) ?? '';
|
||||||
@ -372,7 +371,7 @@ class StoreOrderLogic extends BaseLogic
|
|||||||
return false;
|
return false;
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
\support\Log::info($e->extra['message'] ?? $e->getMessage());
|
\support\Log::info($e->extra['message'] ?? $e->getMessage());
|
||||||
throw new \Exception($e->extra['message'] ?? $e->getMessage());
|
throw new BusinessException($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -383,7 +382,7 @@ class StoreOrderLogic extends BaseLogic
|
|||||||
$code = generateRandomCode();
|
$code = generateRandomCode();
|
||||||
$phone = User::where('id',$param['uid'])->value('mobile');
|
$phone = User::where('id',$param['uid'])->value('mobile');
|
||||||
if(empty($phone)){
|
if(empty($phone)){
|
||||||
throw new \Exception('用户未设置手机号');
|
throw new BusinessException('用户未设置手机号');
|
||||||
}
|
}
|
||||||
$template = getenv('SMS_TEMPLATE');
|
$template = getenv('SMS_TEMPLATE');
|
||||||
$check =(new SmsService())->client($phone,$template,$code);
|
$check =(new SmsService())->client($phone,$template,$code);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user