|
|
@@ -0,0 +1,48 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace pt\controllers;
|
|
|
+
|
|
|
+use biz\shop\classes\ShopClass;
|
|
|
+use bizGhs\custom\classes\CustomClass;
|
|
|
+use bizGhs\order\classes\OrderClass;
|
|
|
+use common\components\wxUtil;
|
|
|
+use Yii;
|
|
|
+
|
|
|
+class DebtController extends BaseController
|
|
|
+{
|
|
|
+ public $guestAccess = [];
|
|
|
+
|
|
|
+ // ./yii debt/init
|
|
|
+ public function actionInit()
|
|
|
+ {
|
|
|
+ $list = ShopClass::getAllByCondition(['ptStyle' => 2], null, '*', null, true);
|
|
|
+ if (!empty($list)) {
|
|
|
+ foreach ($list as $shop) {
|
|
|
+ $shopId = $shop->id ?? 0;
|
|
|
+ $mainId = $shop->mainId ?? 0;
|
|
|
+ $shopName = $shop->shopName ?? '';
|
|
|
+ $customList = CustomClass::getAllByCondition(['ownMainId' => $mainId], null, '*', null, true);
|
|
|
+ $customDebt = 0;
|
|
|
+ if (!empty($customList)) {
|
|
|
+ foreach ($customList as $custom) {
|
|
|
+ $debtAmount = $custom->debtAmount ?? 0;
|
|
|
+ $customDebt = bcadd($customDebt, $debtAmount, 2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $orderDebt = 0;
|
|
|
+ $orderList = OrderClass::getAllByCondition(['shopId' => $shopId], null, '*', null, true);
|
|
|
+ if (!empty($orderList)) {
|
|
|
+ foreach ($orderList as $order) {
|
|
|
+ $remainDebtPrice = $order->remainDebtPrice ?? 0;
|
|
|
+ $orderDebt = bcadd($remainDebtPrice, $orderDebt, 2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (floatval($customDebt) != floatval($orderDebt)) {
|
|
|
+ echo "门店:{$shopName} 订单和客户欠款不一致 \n";
|
|
|
+ }
|
|
|
+ //$lsShopId = $shop->lsShopId ?? 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|