|
|
@@ -746,4 +746,50 @@ class CustomClass extends BaseClass
|
|
|
util::success(['file' => $fileUrl, 'shortFile' => $file]);
|
|
|
}
|
|
|
|
|
|
+ public static function showTotalBalance($pfShopId = 0, $lsShopId = 0)
|
|
|
+ {
|
|
|
+ ini_set('memory_limit', '2045M');
|
|
|
+ set_time_limit(0);
|
|
|
+
|
|
|
+ $arr['pf'] = ['debt' => 0, 'balance' => 0];
|
|
|
+ $arr['ls'] = ['debt' => 0, 'balance' => 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $arr['pf']['debt'] = $pfDebt;
|
|
|
+ $arr['pf']['balance'] = $pfBalance;
|
|
|
+ }
|
|
|
+ if (!empty($lsShop)) {
|
|
|
+ $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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $arr['ls']['debt'] = $lsDebt;
|
|
|
+ $arr['ls']['balance'] = $lsBalance;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return $arr;
|
|
|
+ }
|
|
|
+
|
|
|
}
|