CustomController.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. if ($ghsOrderDebtAmount != $hdCgOrderDebtAmount) {
  62. noticeUtil::push("!!!!!!!供应商 {$ghsId} 客户id {$customId} 二边欠款单总金额不一致", '15280215347');
  63. echo "---------供应商 {$ghsId} 客户id {$customId} 二边 欠款单 总金额 不一致 {$ghsOrderDebtAmount} {$hdCgOrderDebtAmount} \n";
  64. continue;
  65. }
  66. $customSaveDebtAmount = $custom['debtAmount'] ? floatval($custom['debtAmount']) : 0;
  67. $ghsSaveDebtAmount = $ghs['debtAmount'] ? floatval($ghs['debtAmount']) : 0;
  68. if ($customSaveDebtAmount != $ghsOrderDebtAmount) {
  69. echo "**********客户 {$customId} 欠款总金额 和 订单总合 不一致 $customSaveDebtAmount $ghsOrderDebtAmount \n";
  70. }
  71. if ($ghsSaveDebtAmount != $hdCgOrderDebtAmount) {
  72. echo "########欠供应商 {$ghsId} 金额 和 订单总合 不一致 $ghsSaveDebtAmount $hdCgOrderDebtAmount \n";
  73. }
  74. }
  75. }
  76. }
  77. }
  78. }