This commit is contained in:
2023-03-13 13:49:31 +08:00
parent 802a5081fb
commit 6d2c0374a3
6 changed files with 245 additions and 6 deletions
+15
View File
@@ -134,4 +134,19 @@ class OrderPrescriptionProduct extends Model
{
return self::create($data);
}
/**
* 获取信息-单条
* @param array $params
* @param array $fields
* @return object|null
*/
public static function getWithProductList(array $params, array $fields = ['*']): object|null
{
return self::with([
'Product'
])
->where($params)->first($fields);
}
}
+93
View File
@@ -0,0 +1,93 @@
<?php
declare(strict_types=1);
namespace App\Model;
use Hyperf\Database\Model\Collection;
use Hyperf\Snowflake\Concern\Snowflake;
/**
* @property int $address_id 主键id
* @property int $user_id 用户id
* @property int $province_id 省份id
* @property string $province 省份
* @property int $city_id 城市id
* @property string $city 城市
* @property int $county_id 区县id
* @property string $county 区县
* @property int $consignee_town_id 镇id
* @property string $consignee_town 镇
* @property string $address 详细地址
* @property string $address_mask 详细地址(掩码)
* @property string $consignee_name 收货人姓名
* @property string $consignee_name_mask 收货人姓名(掩码)
* @property string $consignee_tel 收货人电话
* @property string $consignee_tel_mask 收货人电话(掩码)
* @property string $consignee_zip_code 收货邮编
* @property int $is_default 默认地址(0:否 1:是)
* @property int $tag 地址标签(1:家 2:公司 3:学校)
* @property \Carbon\Carbon $created_at 创建时间
* @property \Carbon\Carbon $updated_at 修改时间
*/
class UserShipAddress extends Model
{
use Snowflake;
/**
* The table associated with the model.
*/
protected ?string $table = 'user_ship_address';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = ['address_id', 'user_id', 'province_id', 'province', 'city_id', 'city', 'county_id', 'county', 'consignee_town_id', 'consignee_town', 'address', 'address_mask', 'consignee_name', 'consignee_name_mask', 'consignee_tel', 'consignee_tel_mask', 'consignee_zip_code', 'is_default', 'tag', 'created_at', 'updated_at'];
protected string $primaryKey = "address_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 $params
* @return bool
*/
public static function getExists(array $params): bool
{
return self::where($params)->exists();
}
/**
* 获取数量
* @param array $params
* @return int
*/
public static function getCount(array $params): int
{
return self::where($params)->count();
}
}