Explorar el Código

定时结算-修改平台订单结算方法

sunxbiao hace 5 meses
padre
commit
6023d6002b
Se han modificado 1 ficheros con 28 adiciones y 6 borrados
  1. 28 6
      app/command/PensionTasks.php

+ 28 - 6
app/command/PensionTasks.php

@@ -3,16 +3,19 @@ declare (strict_types=1);
3 3
 
4 4
 namespace app\command;
5 5
 
6
+use app\common\enum\CommonEnum;
6 7
 use app\common\model\merchant\order\OrderMerchant;
7 8
 use app\common\model\store\order\StoreOrder;
8 9
 use app\common\model\user\User;
9 10
 use app\common\model\user\UserCertification;
10 11
 use app\common\repositories\merchant\order\OrderGzcRepository;
11 12
 use app\common\repositories\merchant\order\OrderMerchantRepository;
13
+use app\common\repositories\shared\SharedProsperityUserRepository;
12 14
 use app\common\repositories\store\order\StoreOrderStatusRepository;
13 15
 use app\common\repositories\store\product\ProductRepository;
14 16
 use app\common\repositories\user\UserBillRepository;
15 17
 use app\common\repositories\user\UserRepository;
18
+use app\entity\data\shared\SharedProsperityUserEntity;
16 19
 use app\traits\GzcApiRequest;
17 20
 use Carbon\Carbon;
18 21
 use think\console\Command;
@@ -1570,15 +1573,34 @@ class PensionTasks extends Command
1570 1573
     {
1571 1574
         // 普通订单
1572 1575
         $order_data = Db::name('store_order')->where('paid', 1)->where('is_settlement', 0)->where('pay_type', 'in', '0,1,2,4')->where([['status','in','2,3']])->select();
1573
-        $StoreOrderStatusRepository = app()->make(StoreOrderStatusRepository::class);
1574 1576
         if($order_data) {
1575 1577
             $order_data = $order_data->toArray();
1578
+            // foreach ($order_data as $online) {
1579
+            //     $date = date('Y-m-d H:i:s', strtotime('-' . $timeLimit . ' days'));
1580
+            //     if($date < $online['create_time']) continue;
1581
+            //     Db::transaction(function () use ($online) {
1582
+            //         $this->settleAward($online,0);
1583
+            //         Db::name('store_order')->where('order_id', $online['order_id'])->update(['is_settlement' => 1 ,'settlement_time' => date('Y-m-d H:i:s')]);
1584
+            //     });
1585
+            // }
1586
+            $orderIdList = [];
1587
+            $date = date('Y-m-d H:i:s', strtotime('-' . $timeLimit . ' days'));
1576 1588
             foreach ($order_data as $online) {
1577
-                $date = date('Y-m-d H:i:s', strtotime('-' . $timeLimit . ' days'));
1578
-                if($date < $online['create_time']) continue;
1579
-                Db::transaction(function () use ($online) {
1580
-                    $this->settleAward($online,0);
1581
-                    Db::name('store_order')->where('order_id', $online['order_id'])->update(['is_settlement' => 1 ,'settlement_time' => date('Y-m-d H:i:s')]);
1589
+                if (strtotime($online['create_time']) < strtotime($date)) {
1590
+                    $orderIdList[] = $online['order_id'];
1591
+                } else if ($order_data['mer_id'] == CommonEnum::DESIGN_MERCHANT_ID['SharedProsperity']['code']) {
1592
+                    if (strtotime($online['create_time']) < strtotime(date('Y-m-d 00:00:00'))) {
1593
+                        $orderIdList[] = $online['order_id'];
1594
+                    }
1595
+                }
1596
+            }
1597
+            if (!empty($orderIdList)) {
1598
+                Db::transaction(function () use ($orderIdList) {
1599
+                    // 系统订单 走新的 结算方法
1600
+                    /** @var StoreOrderRepository $storeOrderRepository */
1601
+                    $storeOrderRepository = app()->make(StoreOrderRepository::class);
1602
+                    $storeOrderRepository->settlementOrderByOrderIdList($orderIdList);
1603
+
1582 1604
                 });
1583 1605
             }
1584 1606
         }