Browse Source

fix:抽奖发货逻辑

super-yimizi 1 month ago
parent
commit
987dd62492

+ 4 - 4
application/admin/controller/lottery/DrawRecord.php

@@ -287,7 +287,7 @@ class DrawRecord extends Backend
      */
     public function deliver($ids = null)
     {
-        $winRecordId = $this->request->param('id');
+        $winRecordId = $this->request->param('win_record_id');
         $winRecord = \app\admin\model\lottery\WinRecord::get($winRecordId);
         if (!$winRecord) {
             $this->error('未找到中奖记录');
@@ -299,12 +299,12 @@ class DrawRecord extends Backend
             }
             $winRecord->express_company = $params['express_company'];
             $winRecord->express_number = $params['express_number'];
-            $winRecord->deliver_status = 1; // 假设1为已发货
+            $winRecord->deliver_status = LotteryEnum::DELIVER_STATUS_SUCCESS; // 假设1为已发货
             $winRecord->deliver_time = time();
             $winRecord->save();
             $this->success('发货成功');
         }
-        $this->view->assign('winRecord', $winRecord);
-        return $this->view->fetch('lottery/draw_record/deliver');
+        $this->view->assign('row', $winRecord);
+        return $this->view->fetch();
     }
 } 

+ 23 - 0
application/admin/view/lottery/draw_record/deliver.html

@@ -0,0 +1,23 @@
+<form id="deliver-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">快递公司:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-express_company" class="form-control selectpage" data-primary-key="name" data-rule="required" data-source="shop/shipper/index"  name="row[express_company]" type="text" value="">
+        </div>
+    </div>
+    <div class="form-group">
+        <label class="control-label col-xs-12 col-sm-2">快递单号:</label>
+        <div class="col-xs-12 col-sm-8">
+            <input id="c-express_number" data-rule="required" class="form-control" name="row[express_number]" type="text" placeholder="请输入快递单号">
+        </div>
+    </div>
+    <input type="hidden" name="row[win_record_id]" value="{$row.id}">
+    <div class="form-group layer-footer">
+        <label class="control-label col-xs-12 col-sm-2"></label>
+        <div class="col-xs-12 col-sm-8">
+            <button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
+            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
+        </div>
+    </div>
+</form>
+    

+ 6 - 6
public/assets/js/backend/lottery/draw_record.js

@@ -7,6 +7,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                 extend: {
                     index_url: 'lottery/draw_record/index' + location.search,
                     detail_url: 'lottery/draw_record/detail',
+                    deliver_url: 'lottery/draw_record/deliver',
                     del_url: 'lottery/draw_record/del',
                     multi_url: 'lottery/draw_record/multi',
                     export_url: 'lottery/draw_record/export',
@@ -162,17 +163,13 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                                     title: '发货',
                                     classname: 'btn btn-xs btn-success btn-dialog',
                                     icon: 'fa fa-truck',
-                                    url: 'lottery/draw_record/deliver',
+                                    url: 'lottery/draw_record/deliver?win_record_id={win_record_id}',
                                     visible: function(row) {
                                         return row.win_record_id > 0 && row.deliver_status == 0;
                                     },
-                                    extend: 'data-area="[\'600px\', \'400px\']"',
                                     callback: function (data) {
                                         // 可自定义回调
                                     },
-                                    params: function(row) {
-                                        return {id: row.win_record_id};
-                                    }
                                 }
                             ],
                             formatter: Table.api.formatter.operate
@@ -193,7 +190,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
             // // 初始化统计数据
             // Controller.api.loadStatistics();
         },
-        
+        deliver: function () {
+            Controller.api.bindevent();
+        },
         api: {
 
              // 解析Config中的JSON字符串的辅助函数
@@ -212,6 +211,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                 return configValue;
             },
             bindevent: function () {
+                Form.api.bindevent($("form[role=form]"));
                 // 统计按钮
                 // $(document).on('click', '.btn-statistics', function() {
                 //     $('a[href="#t-statistics"]').tab('show');

+ 1 - 1
public/assets/js/backend/shop/page.js

@@ -30,7 +30,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'id', sortable: true, title: __('Id')},
                         {field: 'type', title: __('Type'), formatter: Table.api.formatter.search, searchList: Config.typeList},
                         {field: 'title', title: __('Title'), operate: 'like'},
-                        {field: 'flag', title: __('Flag'), formatter: Table.api.formatter.flag},
+                        // {field: 'flag', title: __('Flag'), formatter: Table.api.formatter.flag},
                         {field: 'image', title: __('Image'), events: Table.api.events.image, formatter: Table.api.formatter.image},
                         {field: 'views', sortable: true, title: __('Views'), operate: 'BETWEEN'},
                         {