コード例 #1
0
ファイル: affiliate_user_dao.php プロジェクト: vazahat/dudex
 /**
  * Returns an instance of class.
  *
  * @return OCSAFFILIATES_BOL_AffiliateUserDao
  */
 public static function getInstance()
 {
     if (self::$classInstance === null) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
コード例 #2
0
ファイル: service.php プロジェクト: vazahat/dudex
 /**
  * @param $userId
  * @param $saleId
  * @param $amount
  * @return bool
  */
 public function trackSale($userId, $saleId, $amount)
 {
     if (!$userId || !$saleId || !$amount) {
         return false;
     }
     // get user affiliate
     $affUser = $this->affiliateUserDao->findByUserId($userId);
     if (!$affUser) {
         return false;
     }
     $affiliate = $this->affiliateDao->findById($affUser->affiliateId);
     if (!$affiliate || !$this->isAffiliateActive($affiliate->id)) {
         return false;
     }
     $commission = $this->getSaleCommission($amount);
     $sale = new OCSAFFILIATES_BOL_Sale();
     $sale->affiliateId = $affiliate->id;
     $sale->saleId = $saleId;
     $sale->saleAmount = $amount;
     $sale->bonusAmount = $commission;
     $sale->saleDate = time();
     $this->saleDao->save($sale);
     return true;
 }
コード例 #3
0
ファイル: sale_dao.php プロジェクト: vazahat/dudex
 /**
  * Returns list of sales that were not tracked by the affiliate system
  *
  * @param $limit
  * @return array
  */
 public function getUntrackedSales($limit)
 {
     $saleDao = BOL_BillingSaleDao::getInstance();
     $affiliateUserDao = OCSAFFILIATES_BOL_AffiliateUserDao::getInstance();
     $sql = "SELECT `bs`.* FROM `" . $saleDao->getTableName() . "` AS `bs`\n            INNER JOIN `" . $affiliateUserDao->getTableName() . "` AS `au` ON (`bs`.`userId` = `au`.`userId`)\n            LEFT JOIN `" . $this->getTableName() . "` AS `as` ON(`bs`.`id`=`as`.`saleId`)\n            WHERE `bs`.`status` = 'delivered' AND `as`.`id` IS NULL\n            ORDER BY `bs`.`timeStamp` ASC\n            LIMIT :limit";
     return $this->dbo->queryForObjectList($sql, BOL_BillingSaleDao::getInstance()->getDtoClassName(), array('limit' => $limit));
 }