feat: 修改了订单逻辑和佣金产品逻辑,增加了对商品的库存检查,并优化了支付通知逻辑。

This commit is contained in:
mkm 2024-07-30 16:47:22 +08:00
parent 522af410cd
commit 17464ff077
3 changed files with 11 additions and 9 deletions

View File

@ -83,14 +83,12 @@ class OrderLogic extends BaseLogic
self::$fresh_price = 0; //生鲜金额
/** 计算价格 */
$off_activity = Config::where('name', 'off_activity')->value('value');
$field = 'id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase,product_id,top_cate_id,store_info,rose';
foreach ($cart_select as $k => $v) {
$find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field($field)->find();
$find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])
->field('id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase,product_id,top_cate_id,store_info,rose')->find();
if (!$find) {
// unset($cart_select[$k]);
// continue;
$field = 'id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase, id product_id,cate_id,store_info,rose';
$find = StoreProduct::where(['id' => $v['product_id']])->field($field)->find();
$find = StoreProduct::where(['id' => $v['product_id']])
->field('store_name,image,unit,price,vip_price,cost,purchase, id product_id,cate_id,store_info,rose')->find();
if ($find) {
$cate_id = StoreCategory::where('id', $find['cate_id'])->value('pid');
if ($cate_id > 0) {
@ -103,7 +101,6 @@ class OrderLogic extends BaseLogic
}
}
}
$cart_select[$k]['status'] = 1; //缺货标识
}
unset($cart_select[$k]['id']);
$cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价
@ -152,7 +149,7 @@ class OrderLogic extends BaseLogic
$cartInfo['name'] = $find['store_name'];
$cartInfo['image'] = $find['image'];
$cart_select[$k]['cart_info'] = json_encode($cartInfo);
$cart_select[$k]['branch_product_id'] = $find['branch_product_id'];
$cart_select[$k]['branch_product_id'] = $find['branch_product_id']??0;
//理论上每笔都是拆分了
$cart_select[$k]['name'] = $find['store_name'];
$cart_select[$k]['imgs'] = $find['image'];

View File

@ -55,6 +55,7 @@ class CommissionProductLogic extends BaseLogic
$data[] = [
'store_id' => $order['store_id'],
'product_id' => $find['product_id'],
'other_uid'=>0,
'number' => bcmul($total_price, $Distribution['store'], 2),
'oid' => $order['id'],
'type' => 1,
@ -64,6 +65,7 @@ class CommissionProductLogic extends BaseLogic
$data[] = [
'store_id' => $order['store_id'],
'product_id' => $find['product_id'],
'other_uid'=>0,
'number' => bcmul($total_price, $Distribution['platform'], 2),
'oid' => $order['id'],
'type' => 2,
@ -139,6 +141,7 @@ class CommissionProductLogic extends BaseLogic
$data = [
'store_id' => $order['store_id'],
'product_id' => $find['product_id'],
'other_uid'=>0,
'number' => $total,
'oid' => $order['id'],
'type' => 1,
@ -150,6 +153,7 @@ class CommissionProductLogic extends BaseLogic
$data[] = [
'store_id' => $order['store_id'],
'product_id' => $find['product_id'],
'other_uid'=>0,
'number' => $number,
'oid' => $order['id'],
'type' => 1,
@ -159,6 +163,7 @@ class CommissionProductLogic extends BaseLogic
$data[] = [
'store_id' => $order['store_id'],
'product_id' => $find['product_id'],
'other_uid'=>0,
'number' => $commission,
'oid' => $order['id'],
'type' => 2,

View File

@ -646,7 +646,7 @@ class PayNotifyLogic extends BaseLogic
}
$info = StoreOrderCartInfo::where('oid', $order['id'])->field('store_id,product_id,cart_num')->select();
$comm = new CommissionProductLogic();
foreach ($info as $v) {
foreach ($info as $k=>$v) {
$comm->calculate_product_flow($v, $order, $village_uid, $brigade_uid,$user_ship,$spread_user_ship);
}
CommissionLogic::setStore($order,$village_uid, $brigade_uid, $transaction_id);