RechargeAmountCheck.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace App\Modules\OrangeSite\Services\CheckReport;
  3. use App\Modules\OrangeSite\Services\OrangeSiteRechargeReportCheckContext;
  4. use App\Modules\OrangeSite\Services\OrangeSiteReportSettingService;
  5. use Closure;
  6. use Log;
  7. class RechargeAmountCheck
  8. {
  9. /**
  10. * 判断金额回传区间
  11. * @param $context OrangeSiteRechargeReportCheckContext
  12. * @param Closure $next
  13. * @return mixed
  14. */
  15. public function handle($context, Closure $next)
  16. {
  17. $rechargeAmountRange = OrangeSiteReportSettingService::buildRechargeAmountRange($context->channelCallbackConfig);
  18. if (OrangeSiteReportSettingService::judgeRechargeAmountRange($context->order->price, $rechargeAmountRange)) {
  19. return $next($context);
  20. } else {
  21. Log::debug('[orangeSiteRechargeReport]充值金额不满足配置区间', [
  22. 'orderPrice' => $context->order->price,
  23. 'rechargeAmountRange' => $rechargeAmountRange,
  24. 'traceInfo' => $context->traceContext->getTraceInfo()]);
  25. $context->result = [
  26. 'type' => 'amount_filter',
  27. 'firstReason' => 'RechargeAmountCheck',
  28. 'result' => false,
  29. 'content' => "订单金额:{$context->order->price}元不满足回传金额上下限[{$rechargeAmountRange['minStr']} - {$rechargeAmountRange['maxStr']}]",
  30. ];
  31. return $context;
  32. }
  33. }
  34. }