diff --git a/.user.ini b/.user.ini index 3cf8c107..f5585d4b 100644 --- a/.user.ini +++ b/.user.ini @@ -1 +1 @@ -open_basedir=/www/wwwroot/www.ideaketang.com/:/tmp/ \ No newline at end of file +open_basedir=/server/wwwroot/zhishifufei_php/:/tmp/ \ No newline at end of file diff --git a/application/wap/controller/Invoice.php b/application/wap/controller/Invoice.php new file mode 100644 index 00000000..b380d990 --- /dev/null +++ b/application/wap/controller/Invoice.php @@ -0,0 +1,210 @@ +invoiceModel = new \app\wap\model\wap\Invoice(); + $this->invoiceRecordsModel = new InvoiceRecords(); + } + + /** + * 白名单 + * */ + public static function WhiteList() + { + return [ + ]; + } + + /** + * 开票记录 + * @param Request $request + * @return null + */ + public function records(Request $request) + { + $page = $request->get('page', 1); // 当前页码 + $limit = $request->get('limit', 20); // 每页显示的记录数 + + $invoiceList = $this->invoiceRecordsModel->order('id', 'desc')->paginate($limit, false, ['page' => $page]); + $totalCount = $invoiceList->total(); + + $data = [ + 'page' => $page, + 'total' => $totalCount, + 'list' => $invoiceList->items(), + ]; + return JsonService::successful($data); + } + + /** + * 开发票 + * @param Request $request + * @return null + */ + public function make(Request $request) + { + $postData = $request->post(); + $rule = [ + 'order_number' => 'require', + 'invoice_amount' => 'require|float', + 'header_type' => 'require|in:1,2', + 'invoice_header' => 'require', + 'tax_number' => 'require', + 'address' => 'require', + 'bank' => 'require' + ]; + $validate = new Validate($rule); + + $validate->rule([ + 'tax_number' => 'requireIf:header_type,2', + 'address' => 'requireIf:header_type,2', + 'bank' => 'requireIf:header_type,2' + ]); + + if (!$validate->check($postData)) { + JsonService::fail($validate->getError()); + } + + $postData['uid'] = $this->uid; + $invoice = $this->invoiceRecordsModel->create($postData); + + return JsonService::successful($invoice); + } + + + /** + * 抬头列表 + * @param Request $request + * @return null + */ + public function list(Request $request) + { + $page = $request->get('page', 1); // 当前页码 + $limit = $request->get('limit', 20); // 每页显示的记录数 + + $invoiceList = $this->invoiceModel->order('id', 'desc')->paginate($limit, false, ['page' => $page]); + $totalCount = $invoiceList->total(); + + $data = [ + 'page' => $page, + 'total' => $totalCount, + 'list' => $invoiceList->items(), + ]; + return JsonService::successful($data); + } + + /** + * 添加抬头 + * @param Request $request + * @return null + */ + public function add(Request $request) + { + $postData = $request->post(); + if (isset($postData['id'])) { + unset($postData['id']); + } + + $this->_validate($postData); + + $postData['uid'] = $this->uid; + $invoice = $this->invoiceModel->create($postData); + + return JsonService::successful($invoice); + } + + /** + * 修改抬头 + * @param Request $request + * @return null + */ + public function edit(Request $request) + { + $postData = $request->post(); + + $this->_validate($postData, true); + + $invoice = $this->invoiceModel->find($postData['id']); + + if (!$invoice) { + return JsonService::fail('没有发票信息'); + } + + $postData['uid'] = $this->uid; + $invoice->save($postData); + return JsonService::successful($invoice); + } + + /** + * 删除抬头 + * @param Request $request + * @return null + */ + public function delete(Request $request) + { + + $postData = $request->post(); + + $invoice = $this->invoiceModel->find($postData['id']); + + if (!$invoice) { + return JsonService::fail('没有发票信息'); + } + + $invoice->delete(); + + return JsonService::successful(); + } + + + private function _validate($postData, $edit = false) + { + $rule = [ + 'header_type' => 'require|in:1,2', + 'invoice_header' => 'require', + 'tax_number' => 'require', + 'address' => 'require', + 'bank' => 'require' + ]; + if ($edit) { + $rule['id'] = 'require'; + } + $validate = new Validate($rule); + + $validate->rule([ + 'tax_number' => 'requireIf:header_type,2', + 'address' => 'requireIf:header_type,2', + 'bank' => 'requireIf:header_type,2' + ]); + + if (!$validate->check($postData)) { + JsonService::fail($validate->getError()); + } + } +} diff --git a/application/wap/model/special/Special.php b/application/wap/model/special/Special.php index 86a90b0f..e8b55c0a 100755 --- a/application/wap/model/special/Special.php +++ b/application/wap/model/special/Special.php @@ -370,7 +370,7 @@ class Special extends ModelBasic if ($where['search']) { $model = $model->where('title|abstract', 'LIKE', "%$where[search]%"); } - if (!$where['is_member']) $model = $model->where(['is_mer_visible' => 0]); + if (isset($where['is_member']) && !$where['is_member']) $model = $model->where(['is_mer_visible' => 0]); return $model->order('sort desc,id desc'); } } diff --git a/application/wap/model/wap/Invoice.php b/application/wap/model/wap/Invoice.php new file mode 100644 index 00000000..6dd2db6c --- /dev/null +++ b/application/wap/model/wap/Invoice.php @@ -0,0 +1,25 @@ +