|
|
@@ -2,8 +2,6 @@
|
|
|
|
|
|
namespace console\controllers;
|
|
|
|
|
|
-use biz\admin\classes\AdminClass;
|
|
|
-use biz\item\classes\UnitClass;
|
|
|
use biz\product\classes\ProductClass;
|
|
|
use biz\shop\classes\ShopClass;
|
|
|
use bizGhs\custom\classes\CustomClass;
|
|
|
@@ -17,11 +15,96 @@ use bizGhs\stock\classes\OnStockRecordClass;
|
|
|
use bizHd\purchase\classes\PurchaseClass;
|
|
|
use bizHd\purchase\classes\PurchaseItemClass;
|
|
|
use yii\console\Controller;
|
|
|
+use bizGhs\custom\models\Custom;
|
|
|
+use bizGhs\order\classes\OrderClass;
|
|
|
+use common\components\noticeUtil;
|
|
|
+use common\components\util;
|
|
|
use Yii;
|
|
|
|
|
|
class InitController extends Controller
|
|
|
{
|
|
|
|
|
|
+ public function actionAdjustDebt()
|
|
|
+ {
|
|
|
+ $shopList = ShopClass::getAllByCondition(['id' => 11094], null, '*', null, true);
|
|
|
+ if (empty($shopList)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ foreach ($shopList as $key => $shop) {
|
|
|
+
|
|
|
+ $shopId = $shop->id ?? 0;
|
|
|
+
|
|
|
+ $query = new \yii\db\Query();
|
|
|
+
|
|
|
+ $query->from(Custom::tableName());
|
|
|
+
|
|
|
+ $query->where(['ownShopId' => $shopId]);
|
|
|
+ $query->orderBy('addTime ASC');
|
|
|
+
|
|
|
+ foreach ($query->batch(50) as $customList) {
|
|
|
+ if (!empty($customList)) {
|
|
|
+ foreach ($customList as $custom) {
|
|
|
+ $customId = $custom['id'] ?? 0;
|
|
|
+ $where = ['customId' => $customId, 'debt' => 1];
|
|
|
+ $orderList = OrderClass::getAllByCondition($where, 'addTime DESC', '*');
|
|
|
+ $ghsOrderDebtAmount = 0;
|
|
|
+ if (!empty($orderList)) {
|
|
|
+ foreach ($orderList as $order) {
|
|
|
+ $actPrice = $order['remainDebtPrice'] ?? 0;
|
|
|
+ $ghsOrderDebtAmount = bcadd($ghsOrderDebtAmount, $actPrice, 2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $ghsId = $custom['ghsId'] ?? 0;
|
|
|
+
|
|
|
+ $ghs = \bizHd\ghs\classes\GhsClass::getById($ghsId);
|
|
|
+
|
|
|
+ $where = ['ghsId' => $ghsId, 'debt' => PurchaseClass::DEBT_YES];
|
|
|
+ $cgList = PurchaseClass::getAllByCondition($where, 'addTime DESC', '*');
|
|
|
+ $hdCgOrderDebtAmount = 0;
|
|
|
+ if (!empty($cgList)) {
|
|
|
+ foreach ($cgList as $cg) {
|
|
|
+ $actPrice = $cg['remainDebtPrice'] ?? 0;
|
|
|
+ $hdCgOrderDebtAmount = bcadd($hdCgOrderDebtAmount, $actPrice, 2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ($ghsOrderDebtAmount < 0 || $hdCgOrderDebtAmount < 0) {
|
|
|
+ noticeUtil::push("!!!!!!!供货商 {$ghsId} 客户id {$customId} 出现负数 $ghsOrderDebtAmount $hdCgOrderDebtAmount", '15280215347');
|
|
|
+ echo "@@@@@@@@@@@@@供货商 {$ghsId} 客户id {$customId} 出现负数 $ghsOrderDebtAmount $hdCgOrderDebtAmount \n";
|
|
|
+ }
|
|
|
+ $ghsOrderDebtAmount = floatval($ghsOrderDebtAmount);
|
|
|
+ $hdCgOrderDebtAmount = floatval($hdCgOrderDebtAmount);
|
|
|
+
|
|
|
+ if ($ghsOrderDebtAmount != $hdCgOrderDebtAmount) {
|
|
|
+ noticeUtil::push("!!!!!!!供货商 {$ghsId} 客户id {$customId} 二边欠款单总金额不一致", '15280215347');
|
|
|
+ echo "---------供货商 {$ghsId} 客户id {$customId} 二边 欠款单 总金额 不一致 {$ghsOrderDebtAmount} {$hdCgOrderDebtAmount} \n";
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ $customSaveDebtAmount = $custom['debtAmount'] ? floatval($custom['debtAmount']) : 0;
|
|
|
+ $ghsSaveDebtAmount = $ghs['debtAmount'] ? floatval($ghs['debtAmount']) : 0;
|
|
|
+
|
|
|
+ if ($customSaveDebtAmount != $ghsOrderDebtAmount) {
|
|
|
+ echo "*********客户 {$customId} 欠款 和 订单总额 不一致 $customSaveDebtAmount $ghsOrderDebtAmount \n";
|
|
|
+ noticeUtil::push("*********客户 {$customId} 欠款总金额 和 订单总合 不一致 $customSaveDebtAmount $ghsOrderDebtAmount ", '15280215347');
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if ($ghsSaveDebtAmount != $hdCgOrderDebtAmount) {
|
|
|
+ echo "#########欠供货商 {$ghsId} 和 订单总额 不一致 $ghsSaveDebtAmount $hdCgOrderDebtAmount \n";
|
|
|
+ noticeUtil::push("#########欠供货商 {$ghsId} 金额 和 订单总合 不一致 $ghsSaveDebtAmount $hdCgOrderDebtAmount ", '15280215347');
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
//在路上库存 ssh 20231218
|
|
|
public function actionOnStock()
|
|
|
{
|