123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- <?php
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- namespace app\admin\controller;
-
- use app\admin\validate\ExpressValidate;
- use app\common\basics\AdminBase;
- use app\common\server\ConfigServer;
- use app\common\logic\ExpressLogic;
- use app\common\server\JsonServer;
- use think\db;
- use think\exception\ValidateException;
-
- class Express extends AdminBase
- {
-
-
- public function lists()
- {
- if ($this->request->isAjax()) {
- $get = $this->request->get();
- return JsonServer::error('', ExpressLogic::lists($get));
- }
- }
-
-
-
- public function add()
- {
- if ($this->request->isAjax()) {
- $post = $this->request->post();
- $post['del'] = 0;
- try {
- validate(ExpressValidate::class)->scene('add')->check($post);
- $result = ExpressLogic::addExpress($post);
- if ($result) {
- return JsonServer::success('添加成功');
- }
- return JsonServer::error($result);
- } catch (ValidateException $e) {
- return JsonServer::error($e->getMessage());
- }
- }
- return view();
- }
-
-
-
- public function edit($id)
- {
- if ($this->request->isAjax()) {
- $post = $this->request->post();
- $post['del'] = 0;
- try {
- validate(ExpressValidate::class)->scene('edit')->check($post);
- $result = ExpressLogic::editExpress($post);
- if ($result) {
- return JsonServer::success('修改成功');
- }
- return JsonServer::error($result);
- } catch (ValidateException $e) {
- return JsonServer::error($e->getMessage());
- }
- }
- return view('', [
- 'info' => ExpressLogic::info($id)
- ]);
- }
-
-
-
-
- public function del($delData)
- {
- if ($this->request->isAjax()) {
- $result = ExpressLogic::delExpress($delData);
- if ($result) {
- return JsonServer::success('删除成功');
- }
- return JsonServer::error('删除失败');
- }
- }
-
-
- public function setExpress()
- {
- $post = $this->request->post();
- if ($post) {
- ConfigServer::set('express', 'way', $post['way']);
-
- ConfigServer::set('kd100', 'appkey', $post['kd100_appkey']);
- ConfigServer::set('kd100', 'appsecret', $post['kd100_customer']);
-
- ConfigServer::set('kdniao', 'appkey', $post['kdniao_appkey']);
- ConfigServer::set('kdniao', 'appsecret', $post['kdniao_ebussinessid']);
- ConfigServer::set('kdniao', 'type', $post['kdniao_type']);
- }
- return JsonServer::success('操作成功');
- }
- }
|