xiaoyu hace 3 años
padre
commit
84f4817fe5

+ 6 - 0
data/model/fetch_order.model.php

@@ -17,4 +17,10 @@ class fetch_orderModel extends Model
         if (empty($list)) return [];
         return $list;
     }
+
+    public function editFetchOrder($update,$condition)
+    {
+        return $this->where($condition)->update($update);
+    }
+
 }

+ 29 - 81
shop/control/store_refill_order.php

@@ -28,99 +28,47 @@ class store_refill_ordercontrol extends BaseSellerControl
     {
         $mod = Model('fetch_order');
 
+        $member_id = $_SESSION['member_id'];
         $condition['store_id'] = $_SESSION['store_id'];
         $condition['status'] = 1;
-        $order_list = $mod->getFetchOrderList($condition,50);
+        $total_fetch_order = $mod->where($condition)->count();
+
+        $condition['member_id'] = $member_id;
+        $order_list = $mod->getFetchOrderList($condition,20);
+
         Tpl::output('order_list', $order_list);
-        Tpl::output('order_num', count($order_list));
+        Tpl::output('total_fetch_order', $total_fetch_order);
         Tpl::output('show_page',$mod->showpage());
 
         Tpl::showpage('store_refill_order.index');
     }
 
-    /**
-     * 导出已支付订单
-     *
-     */
-    public function export_pay_orderOp()
+    public function fetch_orderOp()
     {
-        $orders = [];
-
-        $model_refill_order = Model('refill_order');
-
-        $condition['vr_order.store_id'] = $_SESSION['store_id'];
-        $condition['vr_order.order_state'] = ORDER_STATE_PAY;
-        $condition['refill_order.inner_status'] = 0;
-
-        $order_list = $model_refill_order->getMerchantOrderList($condition, '', 'refill_order.*,vr_order.order_state', 'refill_order.order_id asc');
-        foreach ($order_list as $order) {
-            $resp = $this->_order_send($order);
-            if ($resp['state'] === true) {
-                $tmp = [];
-                $tmp[] = ['data' => $order['order_id']];
-                $tmp[] = ['data' => $order['order_sn']];
-                $tmp[] = ['data' => $order['card_no']];
-                $tmp[] = ['data' => $order['refill_amount']];
-
-                $orders[] = $tmp;
+        if (chksubmit()) {
+            $num = intval($_GET['num']);
+            $mod = Model('fetch_order');
+            $condition['status'] = 1;
+            $fetch_order = $mod->where($condition)->order('add_time desc')->limit($num)->select();
+            if(empty($fetch_order)) {
+                showDialog('暂无可抢订单','index.php?act=store_refill_order&op=index','error');
+                echo json_encode(['status' => false, 'msg' => "暂无可抢订单"]);
             }
-        }
-
-        if (empty($orders)) {
-            return;
-        } else {
-            Language::read('export');
-            import('libraries.excel');
-            $excel = new Excel();
-            $excel->setStyle(['id' => 's_title', 'Font' => ['FontName' => '宋体', 'Size' => '12', 'Bold' => '1']]);
-
-            $headers = [['styleid' => 's_title', 'data' => '编号'],
-                ['styleid' => 's_title', 'data' => '订单号'],
-                ['styleid' => 's_title', 'data' => '卡号'],
-                ['styleid' => 's_title', 'data' => '充值金额']];
-
-            $table[] = $headers;
-            foreach ($orders as $order) {
-                $table[] = $order;
+            $order_ids = '';
+            foreach ($fetch_order as $order)
+            {
+                $order_ids .= "{$order['order_id']},";
             }
-
-            $table = $excel->charset($table, CHARSET);
-            $excel->addArray($table);
-            $excel->addWorksheet($excel->charset("充值——已支付未处理订单", CHARSET));
-
-            $len = count($orders);
-            $time = date('Y-m-d', time());
-            $start = $orders[0][0]['data'];
-            $table_name = "{$time} {$start}-{$len}";
-
-            $excel->generateXML($excel->charset($table_name, CHARSET));
-        }
-    }
-
-    public function batch_sendOp()
-    {
-        if (chksubmit()) {
-            $order_ids = trim($_GET['order_ids']);
-            $model_refill_order = Model('refill_order');
-
-            $condition['vr_order.order_id'] = ['in' , $order_ids];
-
-            $order_list = $model_refill_order->getMerchantOrderList($condition, '', 'refill_order.*,vr_order.order_state', 'refill_order.order_id asc');
-
-            foreach ($order_list as $key => $order_info){
-                $resp = $this->_order_send($order_info);
-                if($resp['state'] != true){
-                    if($key == 0){
-                        showDialog('处理失败','index.php?act=store_refill_order&op=index','error');
-                        echo json_encode(['status' => false, 'msg' => "处理失败"]);
-                    }else{
-                        showDialog("部分处理成功,成功数量:{$key}",'index.php?act=store_refill_order&op=index','error');
-                        echo json_encode(['status' => false, 'msg' => "部分处理成功,成功数量:{$key}"]);
-                    }
-                    exit;
-                }
+            $order_ids = rtrim($order_ids,',');
+            $member_id = $_SESSION['member_id'];
+            $update_cond['order_id'] = ['in' , $order_ids];
+            $update_cond['memeber_id'] = $member_id;
+            $res = $mod->editFetchOrder(['status' => 2, 'member_id' => $member_id], $update_cond);
+            if($res) {
+                showDialog('抢单成功','index.php?act=store_refill_order&op=index','succ');
+            } else {
+                showDialog('抢单失败','index.php?act=store_refill_order&op=index','error');
             }
-            showDialog('处理成功','index.php?act=store_refill_order&op=index','succ');
         } else {
             $this->indexOp();
         }

+ 45 - 4
shop/templates/default/seller/store_refill_order.index.php

@@ -1,13 +1,49 @@
+<style>
+    .rob {
+        font-size: 22px;
+        color: #000;
+        padding:0 10px;
+    }
+    .tabmenu {
+        margin-top: 20px;
+        display: flex;
+        justify-content: space-between;
+    }
+</style>
 <?php defined('InShopNC') or exit('Access Invalid!'); ?>
 
+
 <div class="tabmenu">
     <ul class="tab pngFix">
-        <li class="active"><a target="" href="<?php echo urlShop('store_refill_order', 'index'); ?>">已支付订单</a></li>
-        <li class="normal"><a target="" href="<?php echo urlShop('store_refill_order', 'batch_dispose'); ?>">处理待处理订单</a>
+        <li class="active"><a target="" href="<?php echo urlShop('store_refill_order', 'index'); ?>">待处理订单</a></li>
+        <li class="normal"><a target="" href="<?php echo urlShop('store_refill_order', 'batch_dispose'); ?>">已完成订单</a>
         </li>
     </ul>
-    <a href="#" class="ncsc-btn ncsc-btn-orange" style="right: 80px" onclick="hCopy(event)"><i class="icon-edit"></i>拷贝</a>
-    <a href="#" class="ncsc-btn ncsc-btn-blue" onclick="hDeal(event)"><i class="icon-edit"></i>处理</a>
+    <!-- <a href="#" class="ncsc-btn ncsc-btn-orange" style="right: 80px" onclick="hCopy(event)"><i class="icon-edit"></i>拷贝</a>
+    <a href="#" class="ncsc-btn ncsc-btn-blue" onclick="hDeal(event)"><i class="icon-edit"></i>处理</a> -->
+    
+</div>
+<div class="tabmenu">
+    <span>前方共有<span class="rob"></span>笔订单可抢</span>
+  <div>
+  <span>抢
+        <select name="" id="" class="querySelect">
+        <option value="">请选择</option>
+        <option value="1">1</option>
+        <option value="2">2</option>
+        <option value="3">3</option>
+        <option value="4">4</option>
+        <option value="5">5</option>
+        <option value="6">6</option>
+        <option value="7">7</option>
+        <option value="8">8</option>
+        <option value="9">9</option>
+        <option value="10">10</option>
+        </select>
+    单</span>
+    <a href="#" class="ncsc-btn ncsc-btn-blue" onclick="hRob(event)">抢1单</a>
+  </div>
+
 </div>
 
 <table class="ncsc-default-table order">
@@ -44,7 +80,11 @@
       href="<?php echo RESOURCE_SITE_URL; ?>/js/jquery-ui/themes/ui-lightness/jquery.ui.css"/>
 
 <script>
+    $(function () {
+        $('.rob').text("80")
+    })
     // 拷贝
+
     function hCopy(e) {
         let orderList = $('#order_num').val()
         if (orderList != 0) {
@@ -87,4 +127,5 @@
             e.target.href = 'index.php?act=store_refill_order&op=batch_send&form_submit=ok&order_ids=' + trStr
         }
     }
+    
 </script>