|
|
@@ -761,45 +761,29 @@ class CustomClass extends BaseClass
|
|
|
ini_set('memory_limit', '2045M');
|
|
|
set_time_limit(0);
|
|
|
|
|
|
- $arr['pf'] = ['debt' => 0, 'balance' => 0];
|
|
|
- $arr['ls'] = ['debt' => 0, 'balance' => 0];
|
|
|
+ $pfAmount = 0;
|
|
|
+ $lsAmount = 0;
|
|
|
if (!empty($pfShopId)) {
|
|
|
$custom = CustomClass::getAllByCondition(['ownShopId' => $pfShopId], null, '*', null, true);
|
|
|
- $pfDebt = 0;
|
|
|
- $pfBalance = 0;
|
|
|
if (!empty($custom)) {
|
|
|
foreach ($custom as $c) {
|
|
|
$balance = $c->balance ?? 0;
|
|
|
- if ($balance > 0) {
|
|
|
- $pfBalance = bcadd($pfBalance, $balance, 2);
|
|
|
- } else {
|
|
|
- $balance = abs($balance);
|
|
|
- $pfDebt = bcadd($pfDebt, $balance, 2);
|
|
|
- }
|
|
|
+ $debtAmount = $c->debtAmount ?? 0;
|
|
|
+ $new = bcsub($balance, $debtAmount, 2);
|
|
|
+ $pfAmount = bcadd($pfAmount, $new, 2);
|
|
|
}
|
|
|
}
|
|
|
- $arr['pf']['debt'] = floatval($pfDebt);
|
|
|
- $arr['pf']['balance'] = floatval($pfBalance);
|
|
|
}
|
|
|
- if (!empty($lsShop)) {
|
|
|
+ if (!empty($lsShopId)) {
|
|
|
$lsCustom = \bizHd\custom\classes\CustomClass::getAllByCondition(['shopId' => $lsShopId], null, '*', null, true);
|
|
|
- $lsDebt = 0;
|
|
|
- $lsBalance = 0;
|
|
|
if (!empty($lsCustom)) {
|
|
|
foreach ($lsCustom as $lc) {
|
|
|
$balance = $lc->balance ?? 0;
|
|
|
- if ($balance > 0) {
|
|
|
- $lsBalance = bcadd($lsBalance, $balance, 2);
|
|
|
- } else {
|
|
|
- $balance = abs($balance);
|
|
|
- $lsDebt = bcadd($lsDebt, $balance, 2);
|
|
|
- }
|
|
|
+ $lsAmount = bcadd($balance, $lsAmount, 2);
|
|
|
}
|
|
|
- $arr['ls']['debt'] = floatval($lsDebt);
|
|
|
- $arr['ls']['balance'] = floatval($lsBalance);
|
|
|
}
|
|
|
}
|
|
|
- return $arr;
|
|
|
+ return ['pfAmount' => $pfAmount, 'lsAmount' => $lsAmount];
|
|
|
}
|
|
|
|
|
|
}
|