|
@@ -4,15 +4,14 @@ namespace console\controllers;
|
|
|
|
|
|
|
|
use biz\shop\classes\ShopClass;
|
|
use biz\shop\classes\ShopClass;
|
|
|
use bizGhs\order\classes\OrderClass;
|
|
use bizGhs\order\classes\OrderClass;
|
|
|
-use yii\console\Controller;
|
|
|
|
|
use Yii;
|
|
use Yii;
|
|
|
|
|
+use yii\console\Controller;
|
|
|
|
|
|
|
|
class GhsOrderController extends Controller
|
|
class GhsOrderController extends Controller
|
|
|
{
|
|
{
|
|
|
|
|
|
|
|
public function actionBcId()
|
|
public function actionBcId()
|
|
|
{
|
|
{
|
|
|
-
|
|
|
|
|
ini_set('memory_limit', '2045M');
|
|
ini_set('memory_limit', '2045M');
|
|
|
set_time_limit(0);
|
|
set_time_limit(0);
|
|
|
|
|
|
|
@@ -30,4 +29,65 @@ class GhsOrderController extends Controller
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 脚本一:每天 03:20 执行,处理付款时间 7~10 天前订单
|
|
|
|
|
+ public function actionAutoSetOrderToFinish()
|
|
|
|
|
+ {
|
|
|
|
|
+ $minPayTime = date('Y-m-d H:i:s', strtotime('-10 day'));
|
|
|
|
|
+ $maxPayTime = date('Y-m-d H:i:s', strtotime('-7 day'));
|
|
|
|
|
+ $condition = [
|
|
|
|
|
+ 'payStatus' => 1,
|
|
|
|
|
+ 'status' => ['in', [2, 3]],
|
|
|
|
|
+ 'payTime' => ['between', [$minPayTime, $maxPayTime]],
|
|
|
|
|
+ ];
|
|
|
|
|
+ $this->batchConfirmReachByMainId($condition);
|
|
|
|
|
+ Yii::info('批发订单自动完结脚本成功执行');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 脚本二:历史补偿,处理付款超过 10 天未完结订单
|
|
|
|
|
+ public function actionSetOldOrderToFinish()
|
|
|
|
|
+ {
|
|
|
|
|
+ $maxPayTime = date('Y-m-d H:i:s', strtotime('-10 day'));
|
|
|
|
|
+ $condition = [
|
|
|
|
|
+ 'payStatus' => 1,
|
|
|
|
|
+ 'status' => ['in', [2, 3]],
|
|
|
|
|
+ 'payTime <' => $maxPayTime,
|
|
|
|
|
+ ];
|
|
|
|
|
+ $this->batchConfirmReachByMainId($condition);
|
|
|
|
|
+ Yii::info('批发订单自动完结历史补偿脚本成功执行');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 按批发店 mainId 分批处理订单自动收货完结
|
|
|
|
|
+ * @param array $extraCondition
|
|
|
|
|
+ */
|
|
|
|
|
+ private function batchConfirmReachByMainId($extraCondition)
|
|
|
|
|
+ {
|
|
|
|
|
+ $ghsShops = ShopClass::getAllByCondition(['ptStyle' => 2, 'live' => 1], null, 'mainId');
|
|
|
|
|
+ if (empty($ghsShops)) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ $mainIds = array_unique(array_filter(array_column($ghsShops, 'mainId')));
|
|
|
|
|
+ if (empty($mainIds)) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ $params = ['staffId' => 0, 'staffName' => ''];
|
|
|
|
|
+ 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) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ OrderClass::confirmReach($order, $params);
|
|
|
|
|
+ } catch (\Exception $e) {
|
|
|
|
|
+ $orderId = $order->id ?? 0;
|
|
|
|
|
+ Yii::error(
|
|
|
|
|
+ "批发订单自动完结失败 mainId={$mainId}, orderId={$orderId}, message={$e->getMessage()}",
|
|
|
|
|
+ 'ghsOrderAutoFinish'
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|