修改库存不足

This commit is contained in:
2023-03-28 09:08:37 +08:00
parent f4d8428b9e
commit e7bff9c66d
8 changed files with 343 additions and 1 deletions
+36
View File
@@ -2,6 +2,7 @@
namespace App\Services;
use App\Amqp\Producer\CancelUnPayInquiryOrderDelayProducer;
use App\Amqp\Producer\CancelUnpayOrdersDelayDirectProducer;
use App\Constants\DoctorTitleCode;
use App\Constants\HttpEnumCode;
@@ -31,6 +32,7 @@ use App\Utils\PcreMatch;
use Extend\Wechat\WechatPay;
use Hyperf\Amqp\Producer;
use Hyperf\DbConnection\Db;
use Hyperf\Redis\Redis;
use Hyperf\Snowflake\IdGeneratorInterface;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
@@ -972,4 +974,38 @@ class InquiryService extends BaseService
return $order_inquiry->toArray();
}
/**
* 检测问诊订单执行退款次数
* @param string $order_inquiry_id
* @return bool
* @throws ContainerExceptionInterface
* @throws NotFoundExceptionInterface
*/
public function checkInquiryRefundCount(string $order_inquiry_id): bool
{
try {
$redis = $this->container->get(Redis::class);
$redis_key = "inquiryRefund" . $order_inquiry_id;
$redis_value = $redis->get($redis_key);
if(empty($redis_value)){
$redis->set($redis_key, 1,60 * 60 * 24 * 5);
return true;
}
// 问诊订单执行退款次数过多
if ($redis_value > 3) {
// 加入短信队列,通知管理员
return false;
}
$redis->incr($redis_key);
} catch (\Exception $e) {
throw new BusinessException("检测问诊订单执行退款次数失败:" . $e->getMessage());
}
return true;
}
}