|
@@ -132,4 +132,64 @@ class GiftCards extends Model implements GiftCardsContract
|
|
|
|
|
|
|
|
return $code;
|
|
return $code;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public function giftcards()
|
|
|
|
|
+ {
|
|
|
|
|
+ return [
|
|
|
|
|
+ 1 => [
|
|
|
|
|
+ 'name' => 'Gift Card 1',
|
|
|
|
|
+ 'amount' => 50.00,
|
|
|
|
|
+ 'points' => 0,
|
|
|
|
|
+ 'num' => 0,
|
|
|
|
|
+ 'expirationdate' => 30,
|
|
|
|
|
+ 'channel' => 'activity_26_04_21',
|
|
|
|
|
+ 'notes' => '拉新活动添加'
|
|
|
|
|
+ ],
|
|
|
|
|
+ 2 => [
|
|
|
|
|
+ 'name' => 'Gift Card 1',
|
|
|
|
|
+ 'amount' => 50.00,
|
|
|
|
|
+ 'points' => 0,
|
|
|
|
|
+ 'num' => 0,
|
|
|
|
|
+ 'expirationdate' => 30,
|
|
|
|
|
+ 'channel' => 'activity_26_04_21',
|
|
|
|
|
+ 'notes' => '拉新活动添加'
|
|
|
|
|
+ ],
|
|
|
|
|
+ 3 => [
|
|
|
|
|
+ 'name' => 'Gift Card 1',
|
|
|
|
|
+ 'amount' => 50.00,
|
|
|
|
|
+ 'points' => 0,
|
|
|
|
|
+ 'num' => 0,
|
|
|
|
|
+ 'expirationdate' => 30,
|
|
|
|
|
+ 'channel' => 'activity_26_04_21',
|
|
|
|
|
+ 'notes' => '拉新活动添加'
|
|
|
|
|
+ ],
|
|
|
|
|
+ 4 => [
|
|
|
|
|
+ 'name' => 'Gift Card 1',
|
|
|
|
|
+ 'amount' => 50.00,
|
|
|
|
|
+ 'points' => 0,
|
|
|
|
|
+ 'num' => 0,
|
|
|
|
|
+ 'expirationdate' => 30,
|
|
|
|
|
+ 'channel' => 'activity_26_04_21',
|
|
|
|
|
+ 'notes' => '拉新活动添加'
|
|
|
|
|
+ ],
|
|
|
|
|
+ ];
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function add($id)
|
|
|
|
|
+ {
|
|
|
|
|
+ $gifts = $this->giftcards();
|
|
|
|
|
+ $giftInfo = $gifts[$id] ?? null;
|
|
|
|
|
+ if ($giftInfo) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ DB::beginTransaction();
|
|
|
|
|
+ self::addGiftCard($id, $giftInfo['amount'], $giftInfo['num'], $giftInfo['expirationdate'], $giftInfo['channel'], $giftInfo['notes']);
|
|
|
|
|
+ DB::commit();
|
|
|
|
|
+ } catch (\Exception $e) {
|
|
|
|
|
+ DB::rollBack();
|
|
|
|
|
+ throw $e;
|
|
|
|
|
+ }
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|