新增了添加快结束服务包订单至服务包结束队列命令行。
This commit is contained in:
parent
62f86a1397
commit
7ff94df4c5
109
app/Command/AddServicePackageFinishQueueCommand.php
Normal file
109
app/Command/AddServicePackageFinishQueueCommand.php
Normal file
@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use App\Model\OrderServicePackage;
|
||||
use Hyperf\Command\Command as HyperfCommand;
|
||||
use Hyperf\Command\Annotation\Command;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
#[Command]
|
||||
class AddServicePackageFinishQueueCommand extends HyperfCommand
|
||||
{
|
||||
public function __construct(protected ContainerInterface $container)
|
||||
{
|
||||
parent::__construct('addServicePackageFinishQueue');
|
||||
}
|
||||
|
||||
public function configure(): void
|
||||
{
|
||||
parent::configure();
|
||||
$this->setDescription('添加快结束服务包订单至服务包结束队列');
|
||||
}
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$this->line('开始');
|
||||
|
||||
try {
|
||||
// 获取需执行的订单
|
||||
$order_service_packages = $this->getExecOrder();
|
||||
if (empty($order_service_packages)){
|
||||
$this->line("结束,无订单可执行");
|
||||
return;
|
||||
}
|
||||
}catch (\Throwable $e){
|
||||
$this->line($e->getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($order_service_packages as $order_service_package){
|
||||
Db::beginTransaction();
|
||||
try {
|
||||
// 修改订单成功执行
|
||||
$this->putAddFinishStatus($order_service_package['order_service_id'],1);
|
||||
|
||||
// 添加服务包订单完成延迟队列
|
||||
|
||||
Db::commit();
|
||||
}catch (\Throwable $e){
|
||||
// 修改订单执行失败
|
||||
Db::rollBack();
|
||||
$this->line($e->getMessage());
|
||||
$this->putAddFinishStatus($order_service_package['order_service_id'],2,$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
$this->line("全部结束");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取需执行的订单
|
||||
* @return array
|
||||
*/
|
||||
public function getExecOrder(): array
|
||||
{
|
||||
// 获取三天后结束时间
|
||||
$three_day_finish_time = date('Y-m-d H:i:s',strtotime('+3 days', time()));
|
||||
$finish_time_params = [date('Y-m-d H:i:s',time()),$three_day_finish_time];
|
||||
|
||||
$params = array();
|
||||
$params['order_service_status'] = 3; // 订单状态(1:待支付 2:未开始 3:服务中 4:服务完成 5:服务取消)
|
||||
$params['pay_status'] = 2; // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||
$params['refund_status'] = 0; // 商品订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常)
|
||||
$params['add_finish_status'] = 0; // 添加完成订单延迟队列状态(0:未添加 1:已添加 2:添加失败)
|
||||
|
||||
|
||||
$order_service_packages = OrderServicePackage::getInquiryWithFinishTime($params,$finish_time_params);
|
||||
if (empty($order_service_packages)){
|
||||
return [];
|
||||
}
|
||||
|
||||
return $order_service_packages->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改订单状态
|
||||
* @param string $order_service_id
|
||||
* @param int $add_finish_status
|
||||
* @param string $add_finish_fail_reason
|
||||
* @return void
|
||||
*/
|
||||
public function putAddFinishStatus(string $order_service_id,int $add_finish_status,string $add_finish_fail_reason = ""): void
|
||||
{
|
||||
$params = array();
|
||||
$params['order_service_id'] = $order_service_id;
|
||||
|
||||
$data = array();
|
||||
$data['add_finish_status'] = $add_finish_status;
|
||||
$data['add_finish_time'] = date('Y-m-d H:i:s',time());
|
||||
if (!empty($add_finish_fail_reason)){
|
||||
$data['add_finish_fail_reason'] = $add_finish_fail_reason;
|
||||
}
|
||||
|
||||
OrderServicePackage::edit($params,$data);
|
||||
}
|
||||
}
|
||||
@ -13,6 +13,9 @@ use Hyperf\Command\Annotation\Command;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
/**
|
||||
* 发放优惠卷
|
||||
*/
|
||||
#[Command]
|
||||
class GrantUserCouponCommand extends HyperfCommand
|
||||
{
|
||||
|
||||
@ -21,7 +21,7 @@ use Hyperf\DbConnection\Db;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
/**
|
||||
* 迁移订单
|
||||
* 迁移订单 v1.3使用
|
||||
*/
|
||||
#[Command]
|
||||
class MoveOrderCommand extends HyperfCommand
|
||||
|
||||
@ -12,6 +12,9 @@ use Hyperf\Command\Annotation\Command;
|
||||
use Hyperf\DbConnection\Db;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
/**
|
||||
* 废弃
|
||||
*/
|
||||
#[Command]
|
||||
class editDoctorInquiryConfigCommand extends HyperfCommand
|
||||
{
|
||||
|
||||
@ -11,6 +11,9 @@ use Hyperf\Command\Command as HyperfCommand;
|
||||
use Hyperf\Command\Annotation\Command;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
/**
|
||||
* 废弃
|
||||
*/
|
||||
#[Command]
|
||||
class editDoctorQrCodeCommand extends HyperfCommand
|
||||
{
|
||||
|
||||
@ -34,12 +34,16 @@ use Hyperf\Snowflake\Concern\Snowflake;
|
||||
* @property string $finish_time 结束服务时间
|
||||
* @property string $cancel_time 订单取消时间
|
||||
* @property string $cancel_remarks 取消订单备注
|
||||
* @property int $add_finish_status 添加完成订单延迟队列状态(0:未添加 1:已添加 2:添加失败)
|
||||
* @property string $add_finish_time 添加完成订单延迟队列时间
|
||||
* @property string $add_finish_fail_reason 添加完成订单延迟队列失败原因
|
||||
* @property string $patient_name 患者姓名-就诊人
|
||||
* @property string $patient_name_mask 患者姓名-就诊人(掩码)
|
||||
* @property int $patient_sex 患者性别-就诊人(0:未知 1:男 2:女)
|
||||
* @property int $patient_age 患者年龄-就诊人
|
||||
* @property Carbon $created_at 创建时间
|
||||
* @property Carbon $updated_at 修改时间
|
||||
* @property \Carbon\Carbon $created_at 创建时间
|
||||
* @property \Carbon\Carbon $updated_at 修改时间
|
||||
* @property-read OrderServicePackageCase|null $OrderServicePackageCase
|
||||
*/
|
||||
class OrderServicePackage extends Model
|
||||
{
|
||||
@ -53,7 +57,7 @@ class OrderServicePackage extends Model
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*/
|
||||
protected array $fillable = ['order_service_id', 'order_id', 'user_id', 'patient_id', 'doctor_id', 'family_id', 'order_service_type', 'order_service_status', 'is_delete', 'refund_status', 'pay_channel', 'pay_status', 'order_service_no', 'escrow_trade_no', 'amount_total', 'coupon_amount_total', 'payment_amount_total', 'pay_time', 'start_time', 'finish_time', 'cancel_time', 'cancel_remarks', 'patient_name', 'patient_name_mask', 'patient_sex', 'patient_age', 'created_at', 'updated_at'];
|
||||
protected array $fillable = ['order_service_id', 'order_id', 'user_id', 'patient_id', 'doctor_id', 'family_id', 'order_service_type', 'order_service_status', 'is_delete', 'refund_status', 'pay_channel', 'pay_status', 'order_service_no', 'escrow_trade_no', 'amount_total', 'coupon_amount_total', 'payment_amount_total', 'pay_time', 'start_time', 'finish_time', 'cancel_time', 'cancel_remarks', 'add_finish_status', 'add_finish_time', 'add_finish_fail_reason', 'patient_name', 'patient_name_mask', 'patient_sex', 'patient_age', 'created_at', 'updated_at'];
|
||||
|
||||
protected string $primaryKey = "order_service_id";
|
||||
|
||||
@ -136,7 +140,7 @@ class OrderServicePackage extends Model
|
||||
/**
|
||||
* 获取服务包订单-分页
|
||||
* @param array $params
|
||||
* @param array $order_service_status
|
||||
* @param array $order_service_status_params
|
||||
* @param array $fields
|
||||
* @param int|null $page
|
||||
* @param int|null $per_page
|
||||
@ -163,4 +167,18 @@ class OrderServicePackage extends Model
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某一时间段服务包订单-结束时间
|
||||
* @param array $params
|
||||
* @param array $finish_time_params 接诊时间区间
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getInquiryWithFinishTime(array $params, array $finish_time_params): Collection|array
|
||||
{
|
||||
return self::where($params)
|
||||
->whereBetween('finish_time', $finish_time_params)
|
||||
->orderBy('finish_time')
|
||||
->get();
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user