Merge branch 'dev'

This commit is contained in:
2024-06-19 16:08:32 +08:00
14 changed files with 479 additions and 108 deletions
+25
View File
@@ -123,4 +123,29 @@ class Coupon extends Model
->whereIn("distribution_object",[7])
->get();
}
/**
* 获取今日过期优惠卷
* @param array $params
* @param array $valid_end_time
* @param array $fields
* @return Collection|array
*/
public static function getTodayExpiredCoupon(array $params,array $valid_end_time,array $fields = ['*']): Collection|array
{
return self::where($params)
->whereBetween('valid_end_time', $valid_end_time)
->get($fields);
}
/**
* 修改
* @param array $params
* @param array $data
* @return int
*/
public static function edit(array $params = [], array $data = []): int
{
return self::where($params)->update($data);
}
}
+93
View File
@@ -0,0 +1,93 @@
<?php
declare(strict_types=1);
namespace App\Model;
use Carbon\Carbon;
use Hyperf\Database\Model\Collection;
/**
* @property int $grant_id 主键id
* @property int $coupon_id 优惠卷id
* @property int $grant_type 发放类型(1:具体用户 2:未拥有用户)
* @property int $user_id 用户id(发放类型为具体用户时存在)
* @property int $total_quantity 目标发放数量
* @property int $grant_quantity 已发放数量
* @property int $grant_result 发放结果(1:成功 2:发放中 3:失败)
* @property string $stop_reason 停止原因
* @property int $admin_user_id 后台操作用户id
* @property Carbon $created_at 创建时间
* @property Carbon $updated_at 修改时间
*/
class CouponGrant extends Model
{
/**
* The table associated with the model.
*/
protected ?string $table = 'coupon_grant';
/**
* The attributes that are mass assignable.
*/
protected array $fillable = ['grant_id', 'coupon_id', 'grant_type', 'user_id', 'total_quantity', 'grant_quantity', 'grant_result', 'stop_reason', 'admin_user_id', 'created_at', 'updated_at'];
protected string $primaryKey = "grant_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 \Hyperf\Database\Model\Model|CouponGrant
*/
public static function addCouponGrant(array $data): \Hyperf\Database\Model\Model|CouponGrant
{
return self::create($data);
}
/**
* 修改-批量
* @param array $params
* @param array $data
* @return int
*/
public static function editCouponGrant(array $params = [], array $data = []): int
{
return self::where($params)->update($data);
}
/**
* 自增
* @param array $params
* @param string $field
* @param float $numeral
* @return int
*/
public static function inc(array $params,string $field,float $numeral = 1): int
{
return self::where($params)->increment($field,$numeral);
}
}