调整活动

This commit is contained in:
2023-05-16 11:23:35 +08:00
parent 44de095f40
commit 538306bb4f
8 changed files with 2920 additions and 1084 deletions

View File

@@ -4,6 +4,7 @@ namespace App\Models;
use App\Models\Traits\BelongsToOutlet;
use App\Models\Traits\BelongsToUser;
use Illuminate\Database\Eloquent\Relations\HasOne;
class Coupon extends Model
{
@@ -22,7 +23,7 @@ class Coupon extends Model
];
//状态
public function getStatusTextAttribute()
public function getStatusTextAttribute(): string
{
switch ($this->status) {
case 0:
@@ -46,7 +47,7 @@ class Coupon extends Model
}
}
public function getProfitTextAttribute()
public function getProfitTextAttribute(): string
{
switch ($this->is_profit) {
case 0:
@@ -63,23 +64,25 @@ class Coupon extends Model
/**
* 是否可以分润
* @author 玄尘 2020-03-13
*
* @return bool [type] [description]
* @author 玄尘 2020-03-13
*/
public function canProfit()
public function canProfit(): bool
{
return ($this->is_profit === 0 && $this->status == 2);
}
/**
* 分润
* @author 玄尘 2020-03-13
*
* @return bool|string [type] [description]
* @author 玄尘 2020-03-13
*/
public function profit()
{
$log = AccountLog::where('source->coupon_id', $this->id)->first();
if (!$log && $this->user && $this->profit) {
if (! $log && $this->user && $this->profit) {
return $this->user->account->rule('freeze', $this->profit, false, [
'coupon_id' => $this->id,
'redemptionCode' => $this->redemptionCode,
@@ -93,6 +96,7 @@ class Coupon extends Model
/**
* Notes: 撤销
*
* @Author: 玄尘
* @Date : 2020/10/12 13:56
*/
@@ -114,6 +118,7 @@ class Coupon extends Model
/**
* Notes: 撤销分润
*
* @Author: 玄尘
* @Date : 2020/10/9 14:07
*/
@@ -132,8 +137,9 @@ class Coupon extends Model
/**
* 打款
* @author 玄尘 2020-03-13
*
* @return bool|string [type] [description]
* @author 玄尘 2020-03-13
*/
public function sendMoney()
{
@@ -160,6 +166,7 @@ class Coupon extends Model
/**
* Notes: 格式化时间 年-月-日
*
* @Author: 玄尘
* @Date : 2020/4/7 16:24
* @return mixed
@@ -169,4 +176,12 @@ class Coupon extends Model
return $this->created_at->format('Y-m-d');
}
/*
* 关联自有券
*/
public function activityCoupon(): HasOne
{
return $this->hasOne(ActivityCoupon::class, 'code', 'redemptionCode');
}
}