CustomController.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. namespace console\controllers;
  3. use biz\ghs\classes\GhsClass;
  4. use bizGhs\custom\classes\CustomClass;
  5. use bizGhs\custom\models\Custom;
  6. use bizGhs\order\classes\OrderClass;
  7. use bizHd\purchase\classes\PurchaseClass;
  8. use common\components\noticeUtil;
  9. use common\components\util;
  10. use yii\console\Controller;
  11. use Yii;
  12. class CustomController extends Controller
  13. {
  14. //黑名单设置 ./yii custom/black
  15. public function actionBlack()
  16. {
  17. $list = CustomClass::getAllByCondition(['black' => 2], null, '*', null, true);
  18. if (!empty($list)) {
  19. foreach ($list as $c) {
  20. $ghsId = $c->ghsId ?? 0;
  21. $ghs = GhsClass::getById($ghsId, true);
  22. if (!empty($ghs)) {
  23. $ghs->black = 2;
  24. $ghs->save();
  25. echo $ghs->name . " id:{$ghs->id} 已经黑了\n";
  26. }
  27. }
  28. }
  29. }
  30. //欠款信息不一致跟踪 shish 20220307 ./yii custom/adjust-debt
  31. public function actionAdjustDebt()
  32. {
  33. $query = new \yii\db\Query();
  34. $query->from(Custom::tableName());
  35. $query->orderBy('addTime ASC');
  36. foreach ($query->batch(50) as $customList) {
  37. if (!empty($customList)) {
  38. foreach ($customList as $custom) {
  39. $customId = $custom['id'] ?? 0;
  40. $where = ['customId' => $customId, 'debt' => 1];
  41. $orderList = OrderClass::getAllByCondition($where, 'addTime DESC', '*');
  42. if (empty($orderList)) {
  43. continue;
  44. }
  45. $ghsOrderDebtAmount = 0;
  46. foreach ($orderList as $order) {
  47. $actPrice = $order['actPrice'] ?? 0;
  48. $ghsOrderDebtAmount = bcadd($ghsOrderDebtAmount, $actPrice, 2);
  49. }
  50. $ghsId = $custom['ghsId'] ?? 0;
  51. $ghs = \bizHd\ghs\classes\GhsClass::getById($ghsId);
  52. $where = ['ghsId' => $ghsId, 'debt' => PurchaseClass::DEBT_YES];
  53. $cgList = PurchaseClass::getAllByCondition($where, 'addTime DESC', '*');
  54. $hdCgOrderDebtAmount = 0;
  55. foreach ($cgList as $cg) {
  56. $actPrice = $cg['actPrice'] ?? 0;
  57. $hdCgOrderDebtAmount = bcadd($hdCgOrderDebtAmount, $actPrice, 2);
  58. }
  59. $ghsOrderDebtAmount = floatval($ghsOrderDebtAmount);
  60. $hdCgOrderDebtAmount = floatval($hdCgOrderDebtAmount);
  61. echo "供应商 {$ghsId} 客户id {$customId} 二边欠款单总金额 {$ghsOrderDebtAmount} {$hdCgOrderDebtAmount} \n";
  62. if ($ghsOrderDebtAmount != $hdCgOrderDebtAmount) {
  63. noticeUtil::push("!!!!!!!供应商 {$ghsId} 客户id {$customId} 二边欠款单总金额不一致", '15280215347');
  64. echo "---------供应商 {$ghsId} 客户id {$customId} 二边欠款单总金额 {$ghsOrderDebtAmount} {$hdCgOrderDebtAmount} \n";
  65. continue;
  66. }
  67. $customSaveDebtAmount = $custom['debtAmount'] ? floatval($custom['debtAmount']) : 0;
  68. $ghsSaveDebtAmount = $ghs['debtAmount'] ? floatval($ghs['debtAmount']) : 0;
  69. if ($customSaveDebtAmount != $ghsOrderDebtAmount) {
  70. echo "**********客户 {$customId} 欠款总金额 和 订单总合 不一致 $customSaveDebtAmount $ghsOrderDebtAmount";
  71. noticeUtil::push("******客户 {$customId} 欠款总金额 和 订单总合 不一致 $customSaveDebtAmount $ghsOrderDebtAmount", '15280215347');
  72. }
  73. if ($ghsSaveDebtAmount != $hdCgOrderDebtAmount) {
  74. echo "########欠供应商 {$ghsId} 金额 和 订单总合 不一致 $ghsSaveDebtAmount $hdCgOrderDebtAmount";
  75. noticeUtil::push("########欠供应商 {$ghsId} 金额 和 订单总合 不一致 $ghsSaveDebtAmount $hdCgOrderDebtAmount", '15280215347');
  76. }
  77. }
  78. }
  79. }
  80. }
  81. }