private function _transferToCustomer($custId, $value)
 {
     $req = new RequestTransferCreditToCustomer();
     $req->setConditionForceAll(true);
     $req->setToCustomerId($custId);
     $req->setValue($value);
     $resp = $this->_callTransfer->creditToCustomer($req);
     $this->assertTrue($resp->isSucceed());
 }
 /**
  * Add PV to every customer. PV amount is equal to (350 - 25 * customer #) (in the tree, not Magento ID!).
  *
  * @param $dsBegin string date stamp for first day of the period (YYYYMMDD).
  */
 private function _addPvToCustomers($dsBegin)
 {
     $PV_STEP = 25;
     $PV_MAX = 350;
     $dsToday = $dsBegin;
     $reqAddPv = new PvTransferCreditToCustomerRequest();
     foreach ($this->_mapCustomerMageIdByIndex as $ref => $custId) {
         $pvToAdd = $PV_MAX - $ref * $PV_STEP;
         $ts = $this->_toolPeriod->getTimestampTo($dsToday);
         $reqAddPv->setData(PvTransferCreditToCustomerRequest::TO_CUSTOMER_ID, $custId);
         $reqAddPv->setData(PvTransferCreditToCustomerRequest::VALUE, $pvToAdd);
         $reqAddPv->setData(PvTransferCreditToCustomerRequest::DATE_APPLIED, $ts);
         $respAddPv = $this->_callPvTransfer->creditToCustomer($reqAddPv);
         if ($respAddPv->isSucceed()) {
             $this->_logger->debug("'{$pvToAdd}' PV have been added to customer #{$ref} (mageID: {$custId}).");
         } else {
             $this->_logger->debug("Cannot add '{$pvToAdd}' PV to customer #{$ref} (mageID: {$custId}).");
         }
         $dsToday = $this->_toolPeriod->getPeriodNext($dsToday);
     }
 }
 private function _createPvBalances()
 {
     $csv = $this->_readCsvFile($path = __DIR__ . '/data/pv_balances.csv');
     $reqAddPv = new PvTransferCreditToCustomerRequest();
     $ts = $this->_toolPeriod->getTimestampTo(self::DS_CUSTOMER_ADDED);
     $reqAddPv->setData(PvTransferCreditToCustomerRequest::DATE_APPLIED, $ts);
     foreach ($csv as $item) {
         $mlmId = $item[0];
         $pv = $this->_formatCsvNum($item[1]);
         $custNdx = $this->_mapCustomerIndexByMlmId[$mlmId];
         if (is_null($custNdx)) {
             $this->_logger->error("Cannot find customer index for MLM ID {$mlmId}.");
         }
         $custId = $this->_mapCustomerMageIdByIndex[$custNdx];
         $reqAddPv->setData(PvTransferCreditToCustomerRequest::TO_CUSTOMER_ID, $custId);
         $reqAddPv->setData(PvTransferCreditToCustomerRequest::VALUE, $pv);
         $respAddPv = $this->_callPvTransfer->creditToCustomer($reqAddPv);
         if ($respAddPv->isSucceed()) {
             $this->_logger->debug("'{$pv}' PV have been added to customer #{$mlmId} (mageID: #{$custId}).");
         } else {
             $this->_logger->debug("Cannot add '{$pv}' PV to customer #{$mlmId} (mageID: #{$custId}).");
         }
     }
 }