阶段性更新

This commit is contained in:
2020-10-13 08:49:57 +08:00
parent 7cfd45bf99
commit d8cd8ae9a6
21 changed files with 420 additions and 423 deletions

View File

@@ -64,4 +64,26 @@ class ActivityCoupon extends Model
return $this->canRedemption();
}
/**
* Notes: 是否可以撤销
* @Author: 玄尘
* @Date : 2020/10/12 11:57
* @return bool
*/
public function canReversal()
{
return $this->status == self::STATUS_USED;
}
/**
* Notes: 撤销
* @Author: 玄尘
* @Date : 2020/10/12 13:56
*/
public function reversal()
{
$this->status = self::STATUS_INIT;
$this->save();
}
}

View File

@@ -37,6 +37,9 @@ class Coupon extends Model
case 4:
return '已分润';
break;
case 5:
return '已撤销';
break;
default:
return '未知状态';
break;
@@ -88,6 +91,27 @@ class Coupon extends Model
}
}
/**
* Notes: 撤销
* @Author: 玄尘
* @Date : 2020/10/12 13:56
*/
public function reversal()
{
$this->status = 5;
$this->remark = '撤销成功';
$this->save();
if ($this->profit > 0) {
return $this->user->account->rule('refreeze', -$this->profit, false, [
'coupon_id' => $this->id,
'redemptionCode' => $this->redemptionCode,
]);
} else {
return '不需要操作';
}
}
/**
* Notes: 撤销分润
* @Author: 玄尘

View File

@@ -10,6 +10,13 @@ class UnionpayLog extends Model
'out_source' => 'array',
];
const STATUS_SUCCESS = 1;
const STATUS_ERROR = 0;
const STATUS = [
self::STATUS_SUCCESS => '成功',
self::STATUS_ERROR => '失败',
];
public function coupon()
{
return $this->hasOne(Coupon::class, 'redemptionCode', 'mkt_code');