|
|
@@ -4,6 +4,7 @@ namespace console\controllers;
|
|
|
|
|
|
use biz\shop\classes\ShopClass;
|
|
|
use bizGhs\order\classes\OrderClass;
|
|
|
+use common\components\noticeUtil;
|
|
|
use Yii;
|
|
|
use yii\console\Controller;
|
|
|
|
|
|
@@ -38,81 +39,52 @@ class GhsOrderController extends Controller
|
|
|
$minPayTime = date('Y-m-d H:i:s', strtotime('-10 day'));
|
|
|
$maxPayTime = date('Y-m-d H:i:s', strtotime('-7 day'));
|
|
|
$extraCondition = [
|
|
|
- 'payStatus' => 1,
|
|
|
'status' => ['in', [2, 3]],
|
|
|
'payTime' => ['between', [$minPayTime, $maxPayTime]],
|
|
|
];
|
|
|
-
|
|
|
- $ghsShops = ShopClass::getAllByCondition(['ptStyle' => 2, 'live' => 1], null, 'mainId');
|
|
|
- if (!empty($ghsShops)) {
|
|
|
- $mainIds = array_unique(array_filter(array_column($ghsShops, 'mainId')));
|
|
|
- if (!empty($mainIds)) {
|
|
|
- $params = ['staffId' => 0, 'staffName' => '系统', 'notice' => false]; // notice设置为 false,实现不发送发货通知
|
|
|
- foreach ($mainIds as $mainId) {
|
|
|
- $condition = array_merge(['mainId' => $mainId], $extraCondition);
|
|
|
- $orders = OrderClass::getAllByCondition($condition, 'id asc', '*', null, true);
|
|
|
- if (empty($orders)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- foreach ($orders as $order) {
|
|
|
- $connection = Yii::$app->db;
|
|
|
- $transaction = $connection->beginTransaction();
|
|
|
- try {
|
|
|
- OrderClass::confirmReach($order, $params);
|
|
|
- $transaction->commit();
|
|
|
- } catch (\Exception $e) {
|
|
|
- $transaction->rollBack();
|
|
|
- $orderId = $order->id ?? 0;
|
|
|
- Yii::error(
|
|
|
- "批发订单自动完结失败 mainId={$mainId}, orderId={$orderId}, message={$e->getMessage()}",
|
|
|
- 'ghsOrderAutoFinish'
|
|
|
- );
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ $params = ['staffId' => 0, 'staffName' => '系统', 'notice' => false]; // notice设置为 false,实现不发送发货通知
|
|
|
+ $orders = OrderClass::getAllByCondition($extraCondition, 'id asc', '*', null, true);
|
|
|
+ if (empty($orders)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ foreach ($orders as $order) {
|
|
|
+ $connection = Yii::$app->db;
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+ OrderClass::confirmReach($order, $params);
|
|
|
+ $transaction->commit();
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ $orderId = $order->id ?? 0;
|
|
|
+ noticeUtil::push("批发订单自动完结失败 orderId={$orderId}, message={$e->getMessage()}", '15280215347');
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
Yii::info('批发订单自动完结脚本成功执行');
|
|
|
}
|
|
|
|
|
|
// 脚本二:历史补偿,处理付款超过 10 天未完结订单
|
|
|
public function actionSetOldOrderToFinish()
|
|
|
{
|
|
|
- $maxPayTime = date('Y-m-d H:i:s', strtotime('-1 day'));
|
|
|
+ $maxPayTime = date('Y-m-d H:i:s', strtotime('-10 day'));
|
|
|
$extraCondition = [
|
|
|
- 'payStatus' => 1,
|
|
|
'status' => ['in', [2, 3]],
|
|
|
'payTime<' => $maxPayTime,
|
|
|
];
|
|
|
-
|
|
|
- $ghsShops = ShopClass::getAllByCondition(['ptStyle' => 2, 'live' => 1], null, 'mainId');
|
|
|
- if (!empty($ghsShops)) {
|
|
|
- $mainIds = array_unique(array_filter(array_column($ghsShops, 'mainId')));
|
|
|
- if (!empty($mainIds)) {
|
|
|
- $params = ['staffId' => 0, 'staffName' => '系统', 'notice' => false]; // notice设置为 false,实现不发送发货通知
|
|
|
- foreach ($mainIds as $mainId) {
|
|
|
- $condition = array_merge(['mainId' => $mainId], $extraCondition);
|
|
|
- $orders = OrderClass::getAllByCondition($condition, 'id asc', '*', null, true);
|
|
|
- if (empty($orders)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- foreach ($orders as $order) {
|
|
|
- $connection = Yii::$app->db;
|
|
|
- $transaction = $connection->beginTransaction();
|
|
|
- try {
|
|
|
- OrderClass::confirmReach($order, $params);
|
|
|
- $transaction->commit();
|
|
|
- } catch (\Exception $e) {
|
|
|
- $transaction->rollBack();
|
|
|
- $orderId = $order->id ?? 0;
|
|
|
- Yii::error(
|
|
|
- "批发订单自动完结失败 mainId={$mainId}, orderId={$orderId}, message={$e->getMessage()}",
|
|
|
- 'ghsOrderAutoFinish'
|
|
|
- );
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ $params = ['staffId' => 0, 'staffName' => '系统', 'notice' => false]; // notice设置为 false,实现不发送发货通知
|
|
|
+ $orders = OrderClass::getAllByCondition($extraCondition, 'id asc', '*', null, true);
|
|
|
+ if (empty($orders)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ foreach ($orders as $order) {
|
|
|
+ $connection = Yii::$app->db;
|
|
|
+ $transaction = $connection->beginTransaction();
|
|
|
+ try {
|
|
|
+ OrderClass::confirmReach($order, $params);
|
|
|
+ $transaction->commit();
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $transaction->rollBack();
|
|
|
+ $orderId = $order->id ?? 0;
|
|
|
+ noticeUtil::push("批发订单自动完结失败 orderId={$orderId}, message={$e->getMessage()}", '15280215347');
|
|
|
}
|
|
|
}
|
|
|
Yii::info('批发订单自动完结历史补偿脚本成功执行');
|