1
This commit is contained in:
parent
ffbe54777d
commit
21d483cc14
50
app/Amqp/Consumer/PrescriptionExpiredDelayDirectConsumer.php
Normal file
50
app/Amqp/Consumer/PrescriptionExpiredDelayDirectConsumer.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Amqp\Consumer;
|
||||
|
||||
use App\Utils\Log;
|
||||
use Hyperf\Amqp\Message\ConsumerDelayedMessageTrait;
|
||||
use Hyperf\Amqp\Message\ProducerDelayedMessageTrait;
|
||||
use Hyperf\Amqp\Message\Type;
|
||||
use Hyperf\Amqp\Result;
|
||||
use Hyperf\Amqp\Annotation\Consumer;
|
||||
use Hyperf\Amqp\Message\ConsumerMessage;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use PhpAmqpLib\Message\AMQPMessage;
|
||||
|
||||
/**
|
||||
* 处方过期未使用
|
||||
*/
|
||||
#[Consumer(nums: 1)]
|
||||
class PrescriptionExpiredDelayDirectConsumer extends ConsumerMessage
|
||||
{
|
||||
use ProducerDelayedMessageTrait;
|
||||
use ConsumerDelayedMessageTrait;
|
||||
|
||||
protected string $exchange = 'amqp.delay.direct';
|
||||
|
||||
protected ?string $queue = 'prescription.expired.delay.queue';
|
||||
|
||||
protected string $type = Type::DIRECT; //Type::FANOUT;
|
||||
|
||||
protected string|array $routingKey = 'PrescriptionExpired';
|
||||
|
||||
public function consumeMessage($data, AMQPMessage $message): string
|
||||
{
|
||||
Log::getInstance()->error("开始执行 自动取消未使用处方 队列:" . json_encode($data, JSON_UNESCAPED_UNICODE));
|
||||
|
||||
Db::beginTransaction();
|
||||
try {
|
||||
|
||||
Db::commit();
|
||||
Log::getInstance()->info("自动取消未使用处方队列执行成功");
|
||||
return Result::ACK;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollBack();
|
||||
Log::getInstance()->error("自动完成问诊订单执行失败:" . $e->getMessage());
|
||||
return Result::ACK; // 重回队列
|
||||
}
|
||||
}
|
||||
}
|
||||
30
app/Amqp/Producer/PrescriptionExpiredDelayDirectProducer.php
Normal file
30
app/Amqp/Producer/PrescriptionExpiredDelayDirectProducer.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Amqp\Producer;
|
||||
|
||||
use Hyperf\Amqp\Annotation\Producer;
|
||||
use Hyperf\Amqp\Message\ProducerDelayedMessageTrait;
|
||||
use Hyperf\Amqp\Message\ProducerMessage;
|
||||
use Hyperf\Amqp\Message\Type;
|
||||
|
||||
/**
|
||||
* 处方过期未使用
|
||||
*/
|
||||
#[Producer]
|
||||
class PrescriptionExpiredDelayDirectProducer extends ProducerMessage
|
||||
{
|
||||
use ProducerDelayedMessageTrait;
|
||||
|
||||
protected string $exchange = 'amqp.delay.direct';
|
||||
|
||||
protected string $type = Type::DIRECT;
|
||||
|
||||
protected string|array $routingKey = 'PrescriptionExpired';
|
||||
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->payload = $data;
|
||||
}
|
||||
}
|
||||
@ -387,8 +387,8 @@ class DoctorAccountService extends BaseService
|
||||
$data['doctor_id'] = $user_info['client_user_id'];
|
||||
$data['bank_id'] = $doctor_bank_card['bank_id'];
|
||||
$data['account_name'] = $basic_bank['bank_name'];
|
||||
$data['bank_card_code'] = $basic_bank['bank_code'];
|
||||
$data['bank_card_code_four'] = substr($basic_bank['bank_code'], -4);;
|
||||
$data['bank_card_code'] = $doctor_bank_card['bank_card_code'];
|
||||
$data['bank_card_code_four'] = substr($doctor_bank_card['bank_card_code'], -4);;
|
||||
$data['applied_withdrawal_amount'] = $withdrawal_amount + $income_tax; // 提现金额
|
||||
$data['actual_withdrawal_amount'] = $withdrawal_amount; // 实际提现金额
|
||||
$data['income_tax'] = $income_tax; // 提现所得税金额
|
||||
@ -421,6 +421,15 @@ class DoctorAccountService extends BaseService
|
||||
OrderInquiry::edit($params,$data);
|
||||
}
|
||||
|
||||
// 账户表锁定
|
||||
$params = array();
|
||||
$params['doctor_id'] = $user_info['client_user_id'];
|
||||
DoctorAccount::dec($params,'balance_account',$amount_total);
|
||||
|
||||
DoctorAccount::inc($params,'applied_withdrawal_amount',$withdrawal_amount);
|
||||
|
||||
DoctorAccount::inc($params,'income_tax',$income_tax);
|
||||
|
||||
Db::commit();
|
||||
return success();
|
||||
} catch (\Exception $e) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user