qifengquan 1 年之前
父節點
當前提交
21a009fc48

+ 49 - 5
application/admin/controller/pricing/Orderinvoice.php

@@ -3,6 +3,10 @@
 namespace app\admin\controller\pricing;
 
 use app\common\controller\Backend;
+use think\Db;
+use think\exception\DbException;
+use think\exception\PDOException;
+use think\exception\ValidateException;
 
 /**
  * 开票管理
@@ -25,13 +29,53 @@ class Orderinvoice extends Backend
 
     }
 
-
-
     /**
-     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
-     * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
-     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
+     * 编辑
+     *
+     * @param $ids
+     * @return string
+     * @throws DbException
+     * @throws \think\Exception
      */
+        public function edit($ids = null)
+        {
+            $row = $this->model->get($ids);
+            if (!$row) {
+                $this->error(__('No Results were found'));
+            }
+            $adminIds = $this->getDataLimitAdminIds();
+            if (is_array($adminIds) && !in_array($row[$this->dataLimitField], $adminIds)) {
+                $this->error(__('You have no permission'));
+            }
+            if (false === $this->request->isPost()) {
+                $this->view->assign('row', $row);
+                return $this->view->fetch();
+            }
+            $params = $this->request->post('row/a');
+            if (empty($params)) {
+                $this->error(__('Parameter %s can not be empty', ''));
+            }
+            $params = $this->preExcludeFields($params);
+            $result = false;
+            Db::startTrans();
+            try {
+                //是否采用模型验证
+                if ($this->modelValidate) {
+                    $name = str_replace("\\model\\", "\\validate\\", get_class($this->model));
+                    $validate = is_bool($this->modelValidate) ? ($this->modelSceneValidate ? $name . '.edit' : $name) : $this->modelValidate;
+                    $row->validateFailException()->validate($validate);
+                }
+                $result = $row->allowField(true)->save($params);
+                Db::commit();
+            } catch (ValidateException|PDOException|Exception $e) {
+                Db::rollback();
+                $this->error($e->getMessage());
+            }
+            if (false === $result) {
+                $this->error(__('No rows were updated'));
+            }
+            $this->success();
+        }
 
 
 }

+ 4 - 4
application/admin/lang/zh-cn/pricing/orderinvoice.php

@@ -3,9 +3,9 @@
 return [
     'Uid'            => '用户id',
     'Order_no'       => '订单编号',
-    'Invoice_type'   => '发票类型 1普通发票2增值税发票',
-    'Invoice_shape'  => '发票形式 1纸质发票2电子发票',
-    'Type'           => '类型 1个人2企业',
+    'Invoice_type'   => '发票类型',
+    'Invoice_shape'  => '发票形式',
+    'Type'           => '类型',
     'Name'           => '抬头名称',
     'Duty_paragraph' => '单位税号',
     'Address'        => '注册地址',
@@ -17,5 +17,5 @@ return [
     'Postcode'       => '邮编',
     'Emial'          => '邮箱',
     'Apply_time'     => '申请时间',
-    'Status'         => '开票状态1待开票2已寄出3已完成'
+    'Status'         => '开票状态'
 ];

+ 106 - 100
application/admin/view/pricing/orderinvoice/edit.html

@@ -1,105 +1,111 @@
 <form id="edit-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">{:__('Uid')}:</label>
-        <div class="col-xs-12 col-sm-8">
-            <input id="c-uid" class="form-control" name="row[uid]" type="number" value="{$row.uid|htmlentities}">
-        </div>
-    </div>
-    <div class="form-group">
-        <label class="control-label col-xs-12 col-sm-2">{:__('Order_no')}:</label>
-        <div class="col-xs-12 col-sm-8">
-            <input id="c-order_no" class="form-control" name="row[order_no]" type="text" value="{$row.order_no|htmlentities}">
-        </div>
-    </div>
-    <div class="form-group">
-        <label class="control-label col-xs-12 col-sm-2">{:__('Invoice_type')}:</label>
-        <div class="col-xs-12 col-sm-8">
-            <input id="c-invoice_type" class="form-control" name="row[invoice_type]" type="number" value="{$row.invoice_type|htmlentities}">
-        </div>
-    </div>
-    <div class="form-group">
-        <label class="control-label col-xs-12 col-sm-2">{:__('Invoice_shape')}:</label>
-        <div class="col-xs-12 col-sm-8">
-            <input id="c-invoice_shape" class="form-control" name="row[invoice_shape]" type="number" value="{$row.invoice_shape|htmlentities}">
-        </div>
-    </div>
-    <div class="form-group">
-        <label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>
-        <div class="col-xs-12 col-sm-8">
-            <input id="c-type" class="form-control" name="row[type]" type="number" value="{$row.type|htmlentities}">
-        </div>
-    </div>
-    <div class="form-group">
-        <label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>
-        <div class="col-xs-12 col-sm-8">
-            <input id="c-name" class="form-control" name="row[name]" type="text" value="{$row.name|htmlentities}">
-        </div>
-    </div>
-    <div class="form-group">
-        <label class="control-label col-xs-12 col-sm-2">{:__('Duty_paragraph')}:</label>
-        <div class="col-xs-12 col-sm-8">
-            <input id="c-duty_paragraph" class="form-control" name="row[duty_paragraph]" type="number" value="{$row.duty_paragraph|htmlentities}">
-        </div>
-    </div>
-    <div class="form-group">
-        <label class="control-label col-xs-12 col-sm-2">{:__('Address')}:</label>
-        <div class="col-xs-12 col-sm-8">
-            <input id="c-address" class="form-control" name="row[address]" type="text" value="{$row.address|htmlentities}">
-        </div>
-    </div>
-    <div class="form-group">
-        <label class="control-label col-xs-12 col-sm-2">{:__('Company_phone')}:</label>
-        <div class="col-xs-12 col-sm-8">
-            <input id="c-company_phone" class="form-control" name="row[company_phone]" type="number" value="{$row.company_phone|htmlentities}">
-        </div>
-    </div>
-    <div class="form-group">
-        <label class="control-label col-xs-12 col-sm-2">{:__('Bank')}:</label>
-        <div class="col-xs-12 col-sm-8">
-            <input id="c-bank" class="form-control" name="row[bank]" type="text" value="{$row.bank|htmlentities}">
-        </div>
-    </div>
-    <div class="form-group">
-        <label class="control-label col-xs-12 col-sm-2">{:__('Compellation')}:</label>
-        <div class="col-xs-12 col-sm-8">
-            <input id="c-compellation" class="form-control" name="row[compellation]" type="text" value="{$row.compellation|htmlentities}">
-        </div>
-    </div>
-    <div class="form-group">
-        <label class="control-label col-xs-12 col-sm-2">{:__('Phone')}:</label>
-        <div class="col-xs-12 col-sm-8">
-            <input id="c-phone" class="form-control" name="row[phone]" type="number" value="{$row.phone|htmlentities}">
-        </div>
-    </div>
-    <div class="form-group">
-        <label class="control-label col-xs-12 col-sm-2">{:__('Location')}:</label>
-        <div class="col-xs-12 col-sm-8">
-            <input id="c-location" class="form-control" name="row[location]" type="text" value="{$row.location|htmlentities}">
-        </div>
-    </div>
-    <div class="form-group">
-        <label class="control-label col-xs-12 col-sm-2">{:__('Postcode')}:</label>
-        <div class="col-xs-12 col-sm-8">
-            <input id="c-postcode" class="form-control" name="row[postcode]" type="text" value="{$row.postcode|htmlentities}">
-        </div>
-    </div>
-    <div class="form-group">
-        <label class="control-label col-xs-12 col-sm-2">{:__('Emial')}:</label>
-        <div class="col-xs-12 col-sm-8">
-            <input id="c-emial" class="form-control" name="row[emial]" type="text" value="{$row.emial|htmlentities}">
-        </div>
-    </div>
-    <div class="form-group">
-        <label class="control-label col-xs-12 col-sm-2">{:__('Apply_time')}:</label>
-        <div class="col-xs-12 col-sm-8">
-            <input id="c-apply_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[apply_time]" type="text" value="{$row.apply_time}">
-        </div>
-    </div>
-    <div class="form-group">
-        <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>
-        <div class="col-xs-12 col-sm-8">
-            <input id="c-status" class="form-control" name="row[status]" type="number" value="{$row.status|htmlentities}">
+<!--    <div class="form-group">-->
+<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Uid')}:</label>-->
+<!--        <div class="col-xs-12 col-sm-8">-->
+<!--            <input id="c-uid" class="form-control" name="row[uid]" type="number" value="{$row.uid|htmlentities}">-->
+<!--        </div>-->
+<!--    </div>-->
+<!--    <div class="form-group">-->
+<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Order_no')}:</label>-->
+<!--        <div class="col-xs-12 col-sm-8">-->
+<!--            <input id="c-order_no" class="form-control" name="row[order_no]" type="text" value="{$row.order_no|htmlentities}">-->
+<!--        </div>-->
+<!--    </div>-->
+<!--    <div class="form-group">-->
+<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Invoice_type')}:</label>-->
+<!--        <div class="col-xs-12 col-sm-8">-->
+<!--            <input id="c-invoice_type" class="form-control" name="row[invoice_type]" type="number" value="{$row.invoice_type|htmlentities}">-->
+<!--        </div>-->
+<!--    </div>-->
+<!--    <div class="form-group">-->
+<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Invoice_shape')}:</label>-->
+<!--        <div class="col-xs-12 col-sm-8">-->
+<!--            <input id="c-invoice_shape" class="form-control" name="row[invoice_shape]" type="number" value="{$row.invoice_shape|htmlentities}">-->
+<!--        </div>-->
+<!--    </div>-->
+<!--    <div class="form-group">-->
+<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Type')}:</label>-->
+<!--        <div class="col-xs-12 col-sm-8">-->
+<!--            <input id="c-type" class="form-control" name="row[type]" type="number" value="{$row.type|htmlentities}">-->
+<!--        </div>-->
+<!--    </div>-->
+<!--    <div class="form-group">-->
+<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Name')}:</label>-->
+<!--        <div class="col-xs-12 col-sm-8">-->
+<!--            <input id="c-name" class="form-control" name="row[name]" type="text" value="{$row.name|htmlentities}">-->
+<!--        </div>-->
+<!--    </div>-->
+<!--    <div class="form-group">-->
+<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Duty_paragraph')}:</label>-->
+<!--        <div class="col-xs-12 col-sm-8">-->
+<!--            <input id="c-duty_paragraph" class="form-control" name="row[duty_paragraph]" type="number" value="{$row.duty_paragraph|htmlentities}">-->
+<!--        </div>-->
+<!--    </div>-->
+<!--    <div class="form-group">-->
+<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Address')}:</label>-->
+<!--        <div class="col-xs-12 col-sm-8">-->
+<!--            <input id="c-address" class="form-control" name="row[address]" type="text" value="{$row.address|htmlentities}">-->
+<!--        </div>-->
+<!--    </div>-->
+<!--    <div class="form-group">-->
+<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Company_phone')}:</label>-->
+<!--        <div class="col-xs-12 col-sm-8">-->
+<!--            <input id="c-company_phone" class="form-control" name="row[company_phone]" type="number" value="{$row.company_phone|htmlentities}">-->
+<!--        </div>-->
+<!--    </div>-->
+<!--    <div class="form-group">-->
+<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Bank')}:</label>-->
+<!--        <div class="col-xs-12 col-sm-8">-->
+<!--            <input id="c-bank" class="form-control" name="row[bank]" type="text" value="{$row.bank|htmlentities}">-->
+<!--        </div>-->
+<!--    </div>-->
+<!--    <div class="form-group">-->
+<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Compellation')}:</label>-->
+<!--        <div class="col-xs-12 col-sm-8">-->
+<!--            <input id="c-compellation" class="form-control" name="row[compellation]" type="text" value="{$row.compellation|htmlentities}">-->
+<!--        </div>-->
+<!--    </div>-->
+<!--    <div class="form-group">-->
+<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Phone')}:</label>-->
+<!--        <div class="col-xs-12 col-sm-8">-->
+<!--            <input id="c-phone" class="form-control" name="row[phone]" type="number" value="{$row.phone|htmlentities}">-->
+<!--        </div>-->
+<!--    </div>-->
+<!--    <div class="form-group">-->
+<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Location')}:</label>-->
+<!--        <div class="col-xs-12 col-sm-8">-->
+<!--            <input id="c-location" class="form-control" name="row[location]" type="text" value="{$row.location|htmlentities}">-->
+<!--        </div>-->
+<!--    </div>-->
+<!--    <div class="form-group">-->
+<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Postcode')}:</label>-->
+<!--        <div class="col-xs-12 col-sm-8">-->
+<!--            <input id="c-postcode" class="form-control" name="row[postcode]" type="text" value="{$row.postcode|htmlentities}">-->
+<!--        </div>-->
+<!--    </div>-->
+<!--    <div class="form-group">-->
+<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Emial')}:</label>-->
+<!--        <div class="col-xs-12 col-sm-8">-->
+<!--            <input id="c-emial" class="form-control" name="row[emial]" type="text" value="{$row.emial|htmlentities}">-->
+<!--        </div>-->
+<!--    </div>-->
+<!--    <div class="form-group">-->
+<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Apply_time')}:</label>-->
+<!--        <div class="col-xs-12 col-sm-8">-->
+<!--            <input id="c-apply_time" class="form-control datetimepicker" data-date-format="YYYY-MM-DD HH:mm:ss" data-use-current="true" name="row[apply_time]" type="text" value="{$row.apply_time}">-->
+<!--        </div>-->
+<!--    </div>-->
+<!--    <div class="form-group">-->
+<!--        <label class="control-label col-xs-12 col-sm-2">{:__('Status')}:</label>-->
+<!--        <div class="col-xs-12 col-sm-8">-->
+<!--            <input id="c-status" class="form-control" name="row[status]" type="number" value="{$row.status|htmlentities}">-->
+<!--        </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-tracking_number" class="form-control" name="row[status]" type="number" value="{$row.tracking_number|htmlentities}">
         </div>
     </div>
     <div class="form-group layer-footer">

+ 1 - 1
application/admin/view/pricing/orderinvoice/index.html

@@ -7,7 +7,7 @@
                 <div class="widget-body no-padding">
                     <div id="toolbar" class="toolbar">
                         <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
-                        <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('pricing/orderinvoice/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
+                        <a href="javascript:;" class="btn btn-success btn-add disabled{:$auth->check('pricing/orderinvoice/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
                         <a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('pricing/orderinvoice/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
                         <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('pricing/orderinvoice/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>
                         

+ 2 - 2
application/api/controller/User.php

@@ -586,13 +586,13 @@ class User extends Api
         $data = $this->_validate($rule);
         $data['uid'] = $uid;
         $data['order_no'] = pay_no($uid);
-        if(!empty(Order::where('order_no', $data['order_no'])->value('billing_status'))){
+        if(!empty(Order::where('order_no', $data['cp_order_no'])->value('billing_status'))){
             $this->error('订单已申请发票');
         }
         DB::startTrans();
         try {
             $OrderInvoice = OrderInvoice::create($data);
-            Order::where('order_no', $data['order_no'])->update(['billing_status' => 1]);
+            Order::where('order_no', $data['cp_order_no'])->update(['billing_status' => 1]);
             Db::commit();
             $this->success('申请成功',$OrderInvoice);
         }catch (Exception $exception){

+ 30 - 4
public/assets/js/backend/pricing/orderinvoice.js

@@ -30,9 +30,27 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'id', title: __('Id')},
                         {field: 'uid', title: __('Uid')},
                         {field: 'order_no', title: __('Order_no'), operate: 'LIKE'},
-                        {field: 'invoice_type', title: __('Invoice_type')},
-                        {field: 'invoice_shape', title: __('Invoice_shape')},
-                        {field: 'type', title: __('Type')},
+                        {field: 'invoice_type', title: __('Invoice_type'),formatter: function (d){
+                                if(d==1){
+                                    return '普通发票';
+                                }else {
+                                    return '增值税发票';
+                                }
+                            }},
+                        {field: 'invoice_shape', title: __('Invoice_shape'),formatter: function (d){
+                                if(d==1){
+                                    return '纸质发票';
+                                }else {
+                                    return '电子发票';
+                                }
+                            }},
+                        {field: 'type', title: __('Type'),formatter: function (d){
+                                if(d==1){
+                                    return '个人';
+                                }else {
+                                    return '企业';
+                                }
+                            }},
                         {field: 'name', title: __('Name'), operate: 'LIKE'},
                         {field: 'duty_paragraph', title: __('Duty_paragraph')},
                         {field: 'address', title: __('Address'), operate: 'LIKE'},
@@ -44,7 +62,15 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
                         {field: 'postcode', title: __('Postcode'), operate: 'LIKE'},
                         {field: 'emial', title: __('Emial'), operate: 'LIKE'},
                         {field: 'apply_time', title: __('Apply_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
-                        {field: 'status', title: __('Status')},
+                        {field: 'status', title: __('Status'),formatter: function (d){
+                                if(d==1){
+                                    return '待开票';
+                                }else if(d==2){
+                                    return '已寄出';
+                                }else {
+                                    return '已完成';
+                                }
+                            }},
                         {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                     ]
                 ]