public function run()
 {
     if (BonusType::count() > 0) {
         return;
     }
     BonusType::create(array('key' => 'introducer-bonus', 'friendly_name' => 'Introducer Bonus', 'description' => 'This bonus is awarded when someone introduces a new stockist.'));
     BonusType::create(array('key' => 'restock-bonus', 'friendly_name' => 'Restock Bonus', 'description' => 'This bonus is awarded to someone when their restock meets the target.'));
     BonusType::create(array('key' => 'referral-restock-bonus', 'friendly_name' => 'Referral Restock Bonus', 'description' => 'This bonus is awarded to someone when their referral restock meets the target, and they meet the minimum restocking requirements.'));
 }
 private static function payIntroducerBonus(OrderItem $orderItem, User $user)
 {
     assert($orderItem->order->isApproved(), 'order is not accepted');
     //echo "FIRST ORDER => GIVE INTRODUCER BONUS\n";
     //echo "ORDER_USER " . $order->user . PHP_EOL;
     //echo "INTRODUCER " . $user . PHP_EOL;
     $bonus = Bonus::create(['created_at' => $orderItem->order->approved_at, 'updated_at' => $orderItem->order->updated_at, 'workflow_status' => 'ProcessedByReceiver', 'bonus_payout_id' => BonusPayout::IntroducerBonusPayoutCashOption()->id, 'bonus_type_id' => BonusType::IntroducerBonus()->id, 'awarded_by_user_id' => 2, 'awarded_to_user_id' => $user->id, 'order_item_id' => $orderItem->id]);
     $bonusNote = BonusNote::create(['notes' => 'method:' . __METHOD__, 'bonus_id' => $bonus->id]);
     //echo "BONUS_PAID " . $bonus . PHP_EOL;
 }