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..9333ff1 100644
--- a/application/admin/controller/Order.php
+++ b/application/admin/controller/Order.php
@@ -4,6 +4,7 @@ namespace app\admin\controller;
use app\admin\addresmart\Address;
use app\admin\model\AuthGroupAccess;
+use app\admin\model\order\Invoice;
use app\admin\model\OrderDispatch;
use app\admin\model\Worker;
use app\admin\model\WorkerItem;
@@ -11,6 +12,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;
@@ -91,7 +93,6 @@ class Order extends Backend
->field(['id', 'nickname'])
->select();
- $this->view->assign("statusList", $this->model->getStatusList());
$this->view->assign("sources", $res);
$this->view->assign("coupons", $coupons);
$this->view->assign("items", $formattedTree);
@@ -572,4 +573,41 @@ 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 {
+ $params['invoice_method'] = 1;
+ $result = (new Invoice())->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/orders/Invoice.php b/application/admin/controller/orders/Invoice.php
new file mode 100644
index 0000000..b338bbd
--- /dev/null
+++ b/application/admin/controller/orders/Invoice.php
@@ -0,0 +1,126 @@
+model = new \app\admin\model\order\Invoice;
+ $this->view->assign("statusList", $this->model->getStatusList());
+
+ }
+
+
+
+ /**
+ * 默认生成的控制器所继承的父类中有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();
+ }
+
+ /**
+ * 编辑
+ *
+ * @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()) {
+ $order = model('order')->get($row['order_id']);
+ $this->view->assign('order', $order);
+ $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();
+ }
+
+}
diff --git a/application/admin/lang/zh-cn/orders/invoice.php b/application/admin/lang/zh-cn/orders/invoice.php
new file mode 100644
index 0000000..b108580
--- /dev/null
+++ b/application/admin/lang/zh-cn/orders/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..5c5d550
--- /dev/null
+++ b/application/admin/model/order/Invoice.php
@@ -0,0 +1,47 @@
+ '代处理',
+ '1' => '已开票',
+ '2' => '已完成',
+ ];
+ }
+
+
+
+
+
+
+
+
+}
diff --git a/application/admin/validate/order/Invoice.php b/application/admin/validate/order/Invoice.php
new file mode 100644
index 0000000..d60cfd3
--- /dev/null
+++ b/application/admin/validate/order/Invoice.php
@@ -0,0 +1,27 @@
+ [],
+ 'edit' => [],
+ ];
+
+}
diff --git a/application/admin/view/order/edit.html b/application/admin/view/order/edit.html
index 38d5473..a211ac9 100644
--- a/application/admin/view/order/edit.html
+++ b/application/admin/view/order/edit.html
@@ -120,7 +120,7 @@