Explorar o código

orders buyback state

xiaoyu %!s(int64=3) %!d(string=hai) anos
pai
achega
cb03754960

+ 41 - 6
admin/control/refill_order_manual.php

@@ -65,7 +65,7 @@ class refill_order_manualControl extends SystemControl
     {
         $model_refill_order = Model('refill_order');
         $condition = [];
-        $order_list = [];
+        $orders = [];
         $_GET['query_start_time'] = $_GET['query_start_time'] ?? date("Y-m-d 00:00:00");
         if (in_array($_GET['order_state'], ['0', '10', '20', '30', '40']))
         {
@@ -114,12 +114,48 @@ class refill_order_manualControl extends SystemControl
                 $condition['refill_order.order_time'] = ['egt', $start];
                 $condition['vr_order.add_time'] = ['egt', $start];
             }
-            $order_list = $model_refill_order->getMerchantOrderList($condition, 400, 'refill_order.*,vr_order.order_state', 'refill_order.channel_name DESC ');
-            $order_list = $this->OrderDataFormat($order_list, $merchant_list);
+            $int_array = function ($sids) {
+                $result = [];
+                foreach ($sids as $sid) {
+                    $result[] = intval($sid);
+                }
+
+                return $result;
+            };
+
+            $unique_array = function ($ids)
+            {
+                $ids = array_unique($ids);
+                sort($ids);
+                return $ids;
+            };
+
+            $orders = $model_refill_order->getMerchantOrderList($condition, 400, 'refill_order.*,vr_order.order_state', 'refill_order.channel_name DESC ');
+            $orders = $this->OrderDataFormat($orders, $merchant_list);
+            $order_ids = array_column($orders,'order_id');
+            $order_ids = $unique_array($order_ids);
+            $refill_buyback_model = Model('refill_buyback');
+            $buybacks = $refill_buyback_model->getList(['order_id' => ['in',$order_ids]]);
+            $buyback_ids = array_column($buybacks, 'order_id');
+            $buyback_ids = $int_array($buyback_ids);
+            $buyback_ids = $unique_array($buyback_ids);
+            foreach ($orders as $key => $order)
+            {
+                if($order['order_state'] != ORDER_STATE_SUCCESS) {
+                    $order[$key]['buyback'] = false;
+                    continue;
+                }
+                $order_id = intval($order['order_id']);
+                if(algorithm::binary_search($buyback_ids,$order_id)) {
+                    $orders[$key]['buyback'] = true;
+                }else{
+                    $orders[$key]['buyback'] = false;
+                }
+            }
         }
         Tpl::output('merchant_list', $merchant_list);
         Tpl::output('provider_list', $provider_list);
-        Tpl::output('order_list', $order_list);
+        Tpl::output('order_list', $orders);
         Tpl::output('show_page', $model_refill_order->showpage());
         Tpl::showpage('refill.order.batch');
     }
@@ -145,8 +181,7 @@ class refill_order_manualControl extends SystemControl
         $oid_reader = function ($sids) use ($int_array,$unique_array) {
             $sids = explode(',',$sids);
             $ids = $int_array($sids);
-            $result = $unique_array($ids);
-            return $result;
+            return $unique_array($ids);
         };
 
         $oper_type = $_GET['type'];

+ 5 - 1
admin/templates/default/refill.order.batch.php

@@ -298,7 +298,8 @@
             <th class="align-right">下单日期</th>
             <th class="align-right">耗时</th>
             <th class="align-center">订单状态</th>
-            <th class="align-center">运营商流水号</th>
+            <th class="align-left">返销状态</th>
+            <th class="align-left">运营商流水号</th>
             <th class="align-center">通道质量</th>
             <th class="align-center">失败原因</th>
             <th class="align-center">商家单号</th>
@@ -344,6 +345,9 @@
                         <?php } ?>
                     </td>
                     <td class="align-center"><?php echo orderState($order); ?></td>
+                    <td class="align-left">
+                        <?php echo $order['buyback'] == true ? '已反销': '/';?>
+                    </td>
                     <td class="align-left"><?php echo $order['official_sn']; ?></td>
                     <td class="align-left"><?php echo $order['quality_text']; ?></td>
                     <td class="align-left"><?php echo $order['err_msg']; ?></td>