|
|
@@ -71,6 +71,11 @@ use common\models\ProductOrder; |
|
|
|
*/ |
|
|
|
class Subscription extends ActiveRecordCommon |
|
|
|
{ |
|
|
|
const AUTO_PAYMENT_DEDUCTED = 1; |
|
|
|
const AUTO_PAYMENT_YES = 2; |
|
|
|
const AUTO_PAYMENT_NO = 0; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* @inheritdoc |
|
|
|
*/ |
|
|
@@ -216,22 +221,31 @@ class Subscription extends ActiveRecordCommon |
|
|
|
$creditFunctioning = $pointSale->getCreditFunctioning(); |
|
|
|
|
|
|
|
$order->auto_payment = 0; |
|
|
|
if ($order->id_user && Producer::getConfig('credit') && $pointSale->credit) { |
|
|
|
if ($creditFunctioning == Producer::CREDIT_FUNCTIONING_OPTIONAL) { |
|
|
|
$order->auto_payment = $this->auto_payment; |
|
|
|
} elseif ($creditFunctioning == Producer::CREDIT_FUNCTIONING_MANDATORY) { |
|
|
|
$order->auto_payment = 1; |
|
|
|
} elseif ($creditFunctioning == Producer::CREDIT_FUNCTIONING_USER) { |
|
|
|
$user = User::findOne($order->id_user); |
|
|
|
$userProducer = UserProducer::searchOne([ |
|
|
|
'id_user' => $order->id_user, |
|
|
|
'id_producer' => $distribution->id_producer |
|
|
|
]); |
|
|
|
if ($userProducer) { |
|
|
|
$order->auto_payment = $userProducer->credit_active; |
|
|
|
if($this->auto_payment == self::AUTO_PAYMENT_DEDUCTED) { |
|
|
|
if ($order->id_user && Producer::getConfig('credit') && $pointSale->credit) { |
|
|
|
if ($creditFunctioning == Producer::CREDIT_FUNCTIONING_OPTIONAL) { |
|
|
|
$order->auto_payment = 0; |
|
|
|
} elseif ($creditFunctioning == Producer::CREDIT_FUNCTIONING_MANDATORY) { |
|
|
|
$order->auto_payment = 1; |
|
|
|
} elseif ($creditFunctioning == Producer::CREDIT_FUNCTIONING_USER) { |
|
|
|
$user = User::findOne($order->id_user); |
|
|
|
$userProducer = UserProducer::searchOne([ |
|
|
|
'id_user' => $order->id_user, |
|
|
|
'id_producer' => $distribution->id_producer |
|
|
|
]); |
|
|
|
if ($userProducer) { |
|
|
|
$order->auto_payment = $userProducer->credit_active; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
elseif($this->auto_payment == self::AUTO_PAYMENT_YES) { |
|
|
|
$order->auto_payment = 1; |
|
|
|
} |
|
|
|
elseif($this->auto_payment == self::AUTO_PAYMENT_NO) { |
|
|
|
$order->auto_payment = 0; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$order->tiller_synchronization = $order->auto_payment; |
|
|
|
|