136 lines
4.3 KiB
PHP
136 lines
4.3 KiB
PHP
<?php
|
||
|
||
declare(strict_types=1);
|
||
|
||
namespace App\Model;
|
||
|
||
|
||
|
||
use Hyperf\Database\Model\Builder;
|
||
use Hyperf\Database\Model\Collection;
|
||
use Hyperf\Snowflake\Concern\Snowflake;
|
||
|
||
/**
|
||
* @property int $report_regulatory_id 主键id
|
||
* @property int $order_inquiry_id 订单-问诊id
|
||
* @property int $order_prescription_id 订单-处方表id(无需上报处方时为null)
|
||
* @property int $order_product_id 订单-商品表id(无需上报处方时为null)
|
||
* @property int $report_inquiry_status 问诊上报状态(0:未上报 1:已上报 2:上报失败)
|
||
* @property int $report_inquiry_int 问诊上报次数
|
||
* @property int $report_inquiry_type 问诊上报类型(1:网络初诊 2:网络复诊)
|
||
* @property string $report_inquiry_time 问诊上报时间
|
||
* @property string $report_inquiry_fail_reason 问诊上报失败原因
|
||
* @property int $report_prescription_status 处方上报状态(0:未上报 1:已上报 2:上报失败)
|
||
* @property int $report_prescription_int 处方上报次数
|
||
* @property string $report_prescription_time 处方上报时间
|
||
* @property string $report_prescription_fail_reason 处方上报失败原因
|
||
* @property \Carbon\Carbon $created_at 创建时间
|
||
* @property \Carbon\Carbon $updated_at 修改时间
|
||
*/
|
||
class ReportRegulatory extends Model
|
||
{
|
||
use Snowflake;
|
||
|
||
/**
|
||
* The table associated with the model.
|
||
*/
|
||
protected ?string $table = 'report_regulatory';
|
||
|
||
/**
|
||
* The attributes that are mass assignable.
|
||
*/
|
||
protected array $fillable = ['report_regulatory_id', 'order_inquiry_id', 'order_prescription_id', 'order_product_id', 'report_inquiry_status', 'report_inquiry_int', 'report_inquiry_type', 'report_inquiry_time', 'report_inquiry_fail_reason', 'report_prescription_status', 'report_prescription_int', 'report_prescription_time', 'report_prescription_fail_reason', 'created_at', 'updated_at'];
|
||
|
||
protected string $primaryKey = "report_regulatory_id";
|
||
|
||
|
||
/**
|
||
* 获取信息-单条
|
||
* @param array $params
|
||
* @param array $fields
|
||
* @return object|null
|
||
*/
|
||
public static function getOne(array $params, array $fields = ['*']): object|null
|
||
{
|
||
return self::where($params)->first($fields);
|
||
}
|
||
|
||
/**
|
||
* 获取数据-多
|
||
* @param array $params
|
||
* @param array $fields
|
||
* @return Collection|array
|
||
*/
|
||
public static function getList(array $params = [], array $fields = ['*']): Collection|array
|
||
{
|
||
return self::where($params)->get($fields);
|
||
}
|
||
|
||
/**
|
||
* 新增
|
||
* @param array $data
|
||
* @return ReportRegulatory|\Hyperf\Database\Model\Model
|
||
*/
|
||
public static function addReportRegulatory(array $data): ReportRegulatory|\Hyperf\Database\Model\Model
|
||
{
|
||
return self::create($data);
|
||
}
|
||
|
||
/**
|
||
* 修改
|
||
* @param array $params
|
||
* @param array $data
|
||
* @return int
|
||
*/
|
||
public static function edit(array $params = [], array $data = []): int
|
||
{
|
||
return self::where($params)->update($data);
|
||
}
|
||
|
||
/**
|
||
* 数量
|
||
* @param array $params
|
||
* @param array $or_params
|
||
* @return int
|
||
*/
|
||
public static function getOrStatusCount(array $params = [],array $or_params = []): int
|
||
{
|
||
return self::where($params)->orWhere($or_params)->count();
|
||
}
|
||
|
||
/**
|
||
* 列表-限制数量
|
||
* @param array $params
|
||
* @param array $or_params
|
||
* @param array $fields
|
||
* @param int $offset
|
||
* @param int $limit
|
||
* @return Collection|array
|
||
*/
|
||
public static function getOrStatusLimit(array $params = [],array $or_params = [], array $fields = ["*"],int $offset = 0,int $limit = 10): Collection|array
|
||
{
|
||
return self::where($params)
|
||
->orWhere($or_params)
|
||
->offset($offset)
|
||
->limit($limit)
|
||
->get($fields);
|
||
}
|
||
|
||
/**
|
||
* 列表
|
||
* @param array $params
|
||
* @param array $or_params
|
||
* @param array $fields
|
||
* @return Collection|array
|
||
*/
|
||
public static function getNotReportList(array $params = [],array $fields = ["*"]): Collection|array
|
||
{
|
||
return self::where($params)
|
||
->Where(function ($query) {
|
||
$query->orWhere('report_inquiry_status','!=',1);
|
||
$query->orWhere('report_prescription_status','!=',1);
|
||
})
|
||
->get($fields);
|
||
}
|
||
}
|