Beispiel #1
0
	/**
	 * Get first unused coupon
	 * @throws Gpf_DbEngine_NoRowException
	 * @return Pap_Db_Coupon
	 */
	public function getUnusedCoupon() {
		$select = $this->createCouponsSelect();
		$select->select->add(Pap_Db_Table_Coupons::ID);
		$select->limit->set(0, 1);

		$coupon = new Pap_Db_Coupon();
		$coupon->setPrimaryKeyValue($select->getOneRow()->get(Pap_Db_Table_Coupons::ID));
		$coupon->load();
		return $coupon;
	}
Beispiel #2
0
 public function increaseUseCount(Pap_Contexts_Action $context) {
     if ($context->getDoCommissionsSave() == false) {
         $context->debug('Coupon increase usecount: commissions were not saved. stopping');
         return;
     }
     $transaction = $context->getTransaction();
     $couponId = $transaction->getCouponID();
     if ($couponId == null || $couponId == '') {
         $context->debug('Coupon increase usecount: coupon is not used for this commission. stopping');
         return;
     }
     $coupon = new Pap_Db_Coupon();
     $coupon->setId($couponId);
     try {
         $coupon->load();
         $coupon->increaseUseCount();
         $context->debug('Coupon increase usecount: usecount for coupon '.$couponId.' is increased.');
     } catch (Gpf_Exception $e) {
         $context->debug('Coupon increase usecount: loading coupon: '.$couponId.' exception: ' . $e->getMessage());
     }
 }
 /**
  * @throws Gpf_DbEngine_NoRowException
  * @throws Gpf_DbEngine_TooManyRowsException
  */
 private function loadCoupon(Pap_Db_Coupon $coupon) {
     try {
         $coupon->load();
         return;
     } catch (Gpf_DbEngine_NoRowException $e) {
     }
     $coupon->loadFromCode();
 }