'未使用', self::STATUS_USED => '已使用', self::STATUS_CLOSE => '已作废', ]; /** * 默认加载的关联 * @var array */ protected $with = ['activity']; /** * Notes: 卡券状态 * @Author: 玄尘 * @Date : 2020/6/30 9:40 * @return string */ public function getStatusTextAttribute() { return self::STATUS[$this->status] ?? '未知'; } /** * Notes: 是否可以核销 * @Author: 玄尘 * @Date : 2020/6/30 9:41 * @return bool */ public function canRedemption() { return $this->status == ActivityCoupon::STATUS_INIT; } /** * Notes: 是否可以销毁 * @Author: 玄尘 * @Date : 2020/6/30 9:41 * @return bool */ public function canDestroy() { 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(); } }