diff --git a/addons/.htaccess b/addons/.htaccess new file mode 100755 index 0000000..3418e55 --- /dev/null +++ b/addons/.htaccess @@ -0,0 +1 @@ +deny from all \ No newline at end of file diff --git a/application/admin/controller/Order.php b/application/admin/controller/Order.php index c46de6f..7917673 100644 --- a/application/admin/controller/Order.php +++ b/application/admin/controller/Order.php @@ -11,6 +11,7 @@ use app\common\controller\Backend; use app\common\Logic\OrderLogic; use fast\Tree; use think\Db; +use think\exception\DbException; use think\exception\PDOException; use think\exception\ValidateException; use think\Hook; @@ -572,4 +573,46 @@ class Order extends Backend // 重新索引数组 return array_values($filtered_codes); } + /** + * 编辑 + * + * @param $ids + * @return string + * @throws DbException + * @throws \think\Exception + */ + public function invoice($ids = null){ + if (false === $this->request->isPost()) { + $order = model('order')->get($ids); + return $this->fetch('order/invoice/add',['row' => $order]); + } + $params = $this->request->post('row/a'); + if (empty($params)) { + $this->error(__('Parameter %s can not be empty', '')); + } + $params = $this->preExcludeFields($params); + + if ($this->dataLimit && $this->dataLimitFieldAutoFill) { + $params[$this->dataLimitField] = $this->auth->id; + } + $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 . '.add' : $name) : $this->modelValidate; + $this->model->validateFailException()->validate($validate); + } + $result = $this->model->allowField(true)->save($params); + Db::commit(); + } catch (ValidateException|PDOException|Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if ($result === false) { + $this->error(__('No rows were inserted')); + } + $this->success(); + } } diff --git a/application/admin/controller/order/Invoice.php b/application/admin/controller/order/Invoice.php new file mode 100644 index 0000000..e84e689 --- /dev/null +++ b/application/admin/controller/order/Invoice.php @@ -0,0 +1,74 @@ +model = new \app\admin\model\order\Invoice; + + } + + + + /** + * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法 + * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑 + * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改 + */ + + public function add() + { + if (false === $this->request->isPost()) { + 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); + + if ($this->dataLimit && $this->dataLimitFieldAutoFill) { + $params[$this->dataLimitField] = $this->auth->id; + } + $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 . '.add' : $name) : $this->modelValidate; + $this->model->validateFailException()->validate($validate); + } + $result = $this->model->allowField(true)->save($params); + Db::commit(); + } catch (ValidateException|PDOException|Exception $e) { + Db::rollback(); + $this->error($e->getMessage()); + } + if ($result === false) { + $this->error(__('No rows were inserted')); + } + $this->success(); + } + +} diff --git a/application/admin/lang/zh-cn/order/invoice.php b/application/admin/lang/zh-cn/order/invoice.php new file mode 100644 index 0000000..b108580 --- /dev/null +++ b/application/admin/lang/zh-cn/order/invoice.php @@ -0,0 +1,22 @@ + '发票ID', + 'Order_id' => '订单ID', + 'Invoice_type' => '发票类型', + 'Title' => '发票抬头', + 'Tax_number' => '纳税人识别号', + 'Amount' => '发票金额', + 'Invoice_method' => '发票方式', + 'Recipient_email' => '接收邮箱(电子)', + 'Company_address' => '公司注册地址', + 'Company_phone' => '公司注册电话', + 'Bank_name' => '开户行名称', + 'Bank_account' => '银行账号', + 'Recipient_address' => '收件地址(纸质)', + 'Recipient_name' => '收件人姓名', + 'Recipient_phone' => '收件人电话', + 'Issued_at' => '开票时间', + 'Status' => '开票状态', + 'Remark' => '备注' +]; diff --git a/application/admin/model/order/Invoice.php b/application/admin/model/order/Invoice.php new file mode 100644 index 0000000..45a367c --- /dev/null +++ b/application/admin/model/order/Invoice.php @@ -0,0 +1,40 @@ + [], + 'edit' => [], + ]; + +} diff --git a/application/admin/view/order/invoice/add.html b/application/admin/view/order/invoice/add.html new file mode 100644 index 0000000..22acc19 --- /dev/null +++ b/application/admin/view/order/invoice/add.html @@ -0,0 +1,101 @@ +
+ +
+ +
+ +
+
+ + +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+
+ +
diff --git a/application/admin/view/order/invoice/edit.html b/application/admin/view/order/invoice/edit.html new file mode 100644 index 0000000..92638e8 --- /dev/null +++ b/application/admin/view/order/invoice/edit.html @@ -0,0 +1,123 @@ +
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ +
diff --git a/application/admin/view/order/invoice/index.html b/application/admin/view/order/invoice/index.html new file mode 100644 index 0000000..9bf7104 --- /dev/null +++ b/application/admin/view/order/invoice/index.html @@ -0,0 +1,29 @@ +
+ {:build_heading()} + +
+
+
+ +
+ +
+
+
diff --git a/public/assets/js/backend/order.js b/public/assets/js/backend/order.js index 44aaeb8..84c8744 100644 --- a/public/assets/js/backend/order.js +++ b/public/assets/js/backend/order.js @@ -267,6 +267,22 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'cascader'], function return false; }, }, + { + name: 'invoice', + text: '申请开票', + title: '申请开票', + classname: 'btn btn-xs button-cancel btn-dialog', + icon: 'fa fa-send', + url: 'order/invoice/', + dropdown: "更多", + + visible: function (row) { + if (row.status >= 0) { + return true; + } + return false; + }, + }, ], } ] diff --git a/public/assets/js/backend/order/invoice.js b/public/assets/js/backend/order/invoice.js new file mode 100644 index 0000000..58211cb --- /dev/null +++ b/public/assets/js/backend/order/invoice.js @@ -0,0 +1,70 @@ +define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { + + var Controller = { + index: function () { + // 初始化表格参数配置 + Table.api.init({ + extend: { + index_url: 'order.invoice/index' + location.search, + add_url: 'order.invoice/add', + edit_url: 'order.invoice/edit', + del_url: 'order.invoice/del', + multi_url: 'order.invoice/multi', + import_url: 'order.invoice/import', + table: 'order_invoice', + } + }); + + var table = $("#table"); + + // 初始化表格 + table.bootstrapTable({ + url: $.fn.bootstrapTable.defaults.extend.index_url, + pk: 'id', + sortName: 'id', + fixedColumns: true, + fixedRightNumber: 1, + columns: [ + [ + {checkbox: true}, + {field: 'id', title: __('Id')}, + {field: 'order_id', title: __('Order_id')}, + {field: 'invoice_type', title: __('Invoice_type')}, + {field: 'title', title: __('Title'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + {field: 'tax_number', title: __('Tax_number'), operate: 'LIKE'}, + {field: 'amount', title: __('Amount'), operate:'BETWEEN'}, + {field: 'invoice_method', title: __('Invoice_method')}, + {field: 'recipient_email', title: __('Recipient_email'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + {field: 'company_address', title: __('Company_address'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + {field: 'company_phone', title: __('Company_phone'), operate: 'LIKE'}, + {field: 'bank_name', title: __('Bank_name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + {field: 'bank_account', title: __('Bank_account'), operate: 'LIKE'}, + {field: 'recipient_address', title: __('Recipient_address'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, + {field: 'recipient_name', title: __('Recipient_name'), operate: 'LIKE'}, + {field: 'recipient_phone', title: __('Recipient_phone'), operate: 'LIKE'}, + {field: 'issued_at', title: __('Issued_at'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, + {field: 'status', title: __('Status')}, + {field: 'created_at', title: __('Created_at'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, + {field: 'updated_at', title: __('Updated_at'), operate:'RANGE', addclass:'datetimerange', autocomplete:false}, + {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} + ] + ] + }); + + // 为表格绑定事件 + Table.api.bindevent(table); + }, + add: function () { + Controller.api.bindevent(); + }, + edit: function () { + Controller.api.bindevent(); + }, + api: { + bindevent: function () { + Form.api.bindevent($("form[role=form]")); + } + } + }; + return Controller; +}); diff --git a/vendor.zip b/vendor.zip new file mode 100644 index 0000000..e7b9fda Binary files /dev/null and b/vendor.zip differ