浏览代码

Merge branch 'dev'

prodstable
父节点
当前提交
16b98f05a7
共有 1 个文件被更改,包括 25 次插入22 次删除
  1. +25
    -22
      backend/controllers/CronController.php

+ 25
- 22
backend/controllers/CronController.php 查看文件

@@ -205,12 +205,13 @@ class CronController extends BackendController
* récap aux producteurs.
*
* @param string $key
* @param string $force_date
* @param string $forceDate
*/
public function actionProcessOrders($key = '', $forceDate = '')
{
if ($key == '64ac0bdab7e9f5e48c4d991ec5201d57') {
$hour = 20 ;
if(strlen($forceDate)) {
$date = $forceDate ;
}
@@ -230,10 +231,10 @@ class CronController extends BackendController
$distribution = Distribution::findOne([
'date' => $date,
'active' => 1,
'id_producer' => $producer['id'],
'id_producer' => $producer->id,
]);

if ($distribution && ($hour == $producer['order_deadline'] || strlen($forceDate))) {
if ($distribution && ($hour == $producer->order_deadline || strlen($forceDate))) {
/*
* Paiement des commandes (paiement automatique)
@@ -241,24 +242,26 @@ class CronController extends BackendController
$arrayOrders = Order::searchAll([
'distribution.date' => $date,
'distribution.id_producer' => $producer['id']
'distribution.id_producer' => $producer->id
], [
'conditions' => 'date_delete IS NULL'
]) ;

$configCredit = Producer::getConfig('credit', $producer['id']) ;
$configCredit = Producer::getConfig('credit', $producer->id) ;
foreach($arrayOrders as $order) {
if($order->payment_auto && $configCredit) {
if ($order->getAmount(Order::AMOUNT_REMAINING) > 0) {
$order->saveCreditHistory(
CreditHistory::TYPE_PAYMENT,
$order->getAmount(Order::AMOUNT_REMAINING),
$order->distribution->id_producer,
$order->id_user,
User::ID_USER_SYSTEM
);
if($arrayOrders && is_array($arrayOrders)) {
foreach($arrayOrders as $order) {
if($order->auto_payment && $configCredit) {

if ($order->getAmount(Order::AMOUNT_REMAINING) > 0) {
$order->saveCreditHistory(
CreditHistory::TYPE_PAYMENT,
$order->getAmount(Order::AMOUNT_REMAINING),
$order->distribution->id_producer,
$order->id_user,
User::ID_USER_SYSTEM
);
}
}
}
}
@@ -269,13 +272,13 @@ class CronController extends BackendController
if(!strlen($forceDate)) {
$arrayOrders = Order::searchAll([
'distribution.date' => $date,
'distribution.id_producer' => $producer['id']
'distribution.id_producer' => $producer->id
], [
'conditions' => 'date_delete IS NULL'
]) ;
$user = User::searchOne([
'id_producer' => $producer['id'],
'id_producer' => $producer->id,
'status' => User::STATUS_PRODUCER
]);

@@ -298,15 +301,15 @@ class CronController extends BackendController
Yii::$app->runAction('distribution/report-cron', [
'date' => $date,
'save' => true,
'idProducer' => $producer['id'],
'idProducer' => $producer->id,
'key' => '64ac0bdab7e9f5e48c4d991ec5201d57'
]);
$mail->attach(Yii::getAlias('@app/web/pdf/Orders-' . $date . '-' . $producer['id'] . '.pdf'));
$mail->attach(Yii::getAlias('@app/web/pdf/Orders-' . $date . '-' . $producer->id . '.pdf'));
} else {
$sujet = '[distrib] Aucune commande';
$subject = '[distrib] Aucune commande';
}

$mail->setSubject($sujet)
$mail->setSubject($subject)
->send();
}
}

正在加载...
取消
保存