feat(commission): 优化分润计算逻辑,移除冗余代码,提高可读性和性能

This commit is contained in:
mkm 2024-08-26 23:09:35 +08:00
parent df9ed597fc
commit 63c90c8bbf

View File

@ -677,67 +677,28 @@ class PayNotifyLogic extends BaseLogic
}
$info = StoreOrderCartInfo::where('oid', $order['id'])->field('store_id,product_id,cart_num')->select();
$comm = new CommissionProductLogic();
foreach ($info as $k => $v) {
$comm->calculate_product_flow($v, $order, $village_uid, $brigade_uid, $user_ship);
}
CommissionnLogic::setStore($order, $village_uid, $brigade_uid, $transaction_id);
return true;
if (isset($user) && $order['store_id'] == getenv('ACTIVITY_STORE_ID') && !in_array($user['user_ship'], [4, 6, 7])) {
try {
$info = StoreOrderCartInfo::where('oid', $order['id'])->field('store_id,product_id,cart_num')->select();
$comm = new CommissionProductLogic();
foreach ($info as $k => $v) {
$comm->calculate_product_flow($v, $order, $village_uid, $brigade_uid, $user_ship);
}
CommissionnLogic::setStore($order, $village_uid, $brigade_uid, $transaction_id);
return true;
} catch (\Exception $e) {
Log::error('活动分润报错' . $e->getMessage());
return false;
try {
foreach ($info as $k => $v) {
$comm->calculate_product_flow($v, $order, $village_uid, $brigade_uid, $user_ship);
}
}
switch ($user_ship) {
case 1: // 厨师
//case 4: // 商户
//case 5: // 种养殖
// case 6: // 酒店
// case 7: // 食堂
case 8: // 一条龙
CommissionLogic::setCook($order, $village_uid, $brigade_uid, $transaction_id);
break;
case 2: // 村长
CommissionLogic::setVillage($order, $village_uid, $brigade_uid, $transaction_id);
break;
case 3: // 队长
CommissionLogic::setBrigade($order, $village_uid, $brigade_uid, $transaction_id);
break;
default:
CommissionLogic::setStore($order, $transaction_id);
break;
CommissionnLogic::setStore($order, $village_uid, $brigade_uid, $transaction_id);
} catch (\Throwable $e) {
Log::error('分润报错' . $e->getMessage());
return false;
}
} else {
$info = StoreOrderCartInfo::where('oid', $order['id'])->field('store_id,product_id,cart_num')->select();
$comm = new CommissionProductLogic();
foreach ($info as $k => $v) {
$comm->calculate_product_flow($v, $order, $village_uid, $brigade_uid, $user_ship);
}
CommissionnLogic::setStore($order, $village_uid, $brigade_uid, $transaction_id);
return true;
if (isset($user) && $order['store_id'] == getenv('ACTIVITY_STORE_ID') && !in_array($user['user_ship'], [4, 6, 7])) {
try {
$info = StoreOrderCartInfo::where('oid', $order['id'])->field('store_id,product_id,cart_num')->select();
$comm = new CommissionProductLogic();
foreach ($info as $k => $v) {
$comm->calculate_product_flow($v, $order, $village_uid, $brigade_uid, $user_ship);
}
CommissionnLogic::setStore($order, $village_uid, $brigade_uid, $transaction_id);
return true;
} catch (\Exception $e) {
Log::error('活动分润报错' . $e->getMessage());
return false;
try {
$info = StoreOrderCartInfo::where('oid', $order['id'])->field('store_id,product_id,cart_num')->select();
$comm = new CommissionProductLogic();
foreach ($info as $k => $v) {
$comm->calculate_product_flow($v, $order, $village_uid, $brigade_uid, $user_ship);
}
CommissionnLogic::setStore($order, $village_uid, $brigade_uid, $transaction_id);
} catch (\Throwable $e) {
Log::error('分润报错' . $e->getMessage());
return false;
}
CommissionLogic::setStore($order, $transaction_id);
return true;
}
}