diff --git a/admin/src/api/sub_merchant.ts b/admin/src/api/sub_merchant.ts new file mode 100644 index 0000000..31df8d4 --- /dev/null +++ b/admin/src/api/sub_merchant.ts @@ -0,0 +1,26 @@ +import request from '@/utils/request' + +// 微信支付子商户表列表 +export function apiSubMerchantLists(params: any) { + return request.get({ url: '/sub_merchant/lists', params }) +} + +// 添加微信支付子商户表 +export function apiSubMerchantAdd(params: any) { + return request.post({ url: '/sub_merchant/add', params }) +} + +// 编辑微信支付子商户表 +export function apiSubMerchantEdit(params: any) { + return request.post({ url: '/sub_merchant/edit', params }) +} + +// 删除微信支付子商户表 +export function apiSubMerchantDelete(params: any) { + return request.post({ url: '/sub_merchant/delete', params }) +} + +// 微信支付子商户表详情 +export function apiSubMerchantDetail(params: any) { + return request.get({ url: '/sub_merchant/detail', params }) +} \ No newline at end of file diff --git a/admin/src/views/sub_merchant/edit.vue b/admin/src/views/sub_merchant/edit.vue new file mode 100644 index 0000000..f5140a1 --- /dev/null +++ b/admin/src/views/sub_merchant/edit.vue @@ -0,0 +1,163 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/admin/src/views/sub_merchant/index.vue b/admin/src/views/sub_merchant/index.vue new file mode 100644 index 0000000..aa63907 --- /dev/null +++ b/admin/src/views/sub_merchant/index.vue @@ -0,0 +1,155 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + 查询 + 重置 + + + + + + + + + 新增 + + + 删除 + + + + + + + + + + + + + + + 编辑 + + + 删除 + + + + + + + + + + + + + + + diff --git a/server/.example.env b/server/.example.env deleted file mode 100755 index 8b88998..0000000 --- a/server/.example.env +++ /dev/null @@ -1 +0,0 @@ -APP_DEBUG = true [APP] DEFAULT_TIMEZONE = Asia/Shanghai [DATABASE] TYPE = mysql HOSTNAME = 127.0.0.1 DATABASE = test USERNAME = username PASSWORD = password HOSTPORT = 3306 CHARSET = utf8 DEBUG = true PREFIX = la_ [LANG] default_lang = zh-cn [PROJECT] UNIQUE_IDENTIFICATION = likeadmin # 演示环境 DEMO_ENV = false \ No newline at end of file diff --git a/server/app/adminapi/controller/SubMerchantController.php b/server/app/adminapi/controller/SubMerchantController.php new file mode 100644 index 0000000..635b111 --- /dev/null +++ b/server/app/adminapi/controller/SubMerchantController.php @@ -0,0 +1,108 @@ +dataLists(new SubMerchantLists()); + } + + + /** + * @notes 添加 + * @return \think\response\Json + * @author likeadmin + * @date 2023/11/10 09:54 + */ + public function add() + { + $params = (new SubMerchantValidate())->post()->goCheck('add'); + $result = SubMerchantLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(SubMerchantLogic::getError()); + } + + + /** + * @notes 编辑 + * @return \think\response\Json + * @author likeadmin + * @date 2023/11/10 09:54 + */ + public function edit() + { + $params = (new SubMerchantValidate())->post()->goCheck('edit'); + $result = SubMerchantLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(SubMerchantLogic::getError()); + } + + + /** + * @notes 删除 + * @return \think\response\Json + * @author likeadmin + * @date 2023/11/10 09:54 + */ + public function delete() + { + $params = (new SubMerchantValidate())->post()->goCheck('delete'); + SubMerchantLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/11/10 09:54 + */ + public function detail() + { + $params = (new SubMerchantValidate())->goCheck('detail'); + $result = SubMerchantLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/server/app/adminapi/lists/SubMerchantLists.php b/server/app/adminapi/lists/SubMerchantLists.php new file mode 100644 index 0000000..db11d40 --- /dev/null +++ b/server/app/adminapi/lists/SubMerchantLists.php @@ -0,0 +1,77 @@ + ['sub_merchant_name', 'sub_mch_id', 'province', 'city', 'area', 'street', 'village'], + ]; + } + + + /** + * @notes 获取列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2023/11/10 09:54 + */ + public function lists(): array + { + return SubMerchant::where($this->searchWhere) + ->field(['id', 'sub_merchant_name', 'sub_mch_id', 'province', 'city', 'area', 'street', 'village']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取数量 + * @return int + * @author likeadmin + * @date 2023/11/10 09:54 + */ + public function count(): int + { + return SubMerchant::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/server/app/adminapi/logic/SubMerchantLogic.php b/server/app/adminapi/logic/SubMerchantLogic.php new file mode 100644 index 0000000..1d94d4e --- /dev/null +++ b/server/app/adminapi/logic/SubMerchantLogic.php @@ -0,0 +1,118 @@ + $params['sub_merchant_name'], + 'sub_mch_id' => $params['sub_mch_id'], + 'province' => $params['province'], + 'city' => $params['city'], + 'area' => $params['area'], + 'street' => $params['street'], + 'village' => $params['village'], + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑 + * @param array $params + * @return bool + * @author likeadmin + * @date 2023/11/10 09:54 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + SubMerchant::where('id', $params['id'])->update([ + 'sub_merchant_name' => $params['sub_merchant_name'], + 'sub_mch_id' => $params['sub_mch_id'], + 'province' => $params['province'], + 'city' => $params['city'], + 'area' => $params['area'], + 'street' => $params['street'], + 'village' => $params['village'], + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除 + * @param array $params + * @return bool + * @author likeadmin + * @date 2023/11/10 09:54 + */ + public static function delete(array $params): bool + { + return SubMerchant::destroy($params['id']); + } + + + /** + * @notes 获取详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/11/10 09:54 + */ + public static function detail($params): array + { + return SubMerchant::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/server/app/adminapi/validate/SubMerchantValidate.php b/server/app/adminapi/validate/SubMerchantValidate.php new file mode 100644 index 0000000..32aab4d --- /dev/null +++ b/server/app/adminapi/validate/SubMerchantValidate.php @@ -0,0 +1,108 @@ + 'require', + 'sub_merchant_name' => 'require', + 'sub_mch_id' => 'require', + 'province' => 'require', + 'city' => 'require', + 'area' => 'require', + 'street' => 'require', + 'village' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'sub_merchant_name' => '子商户名', + 'sub_mch_id' => '子商户号', + 'province' => '省', + 'city' => '市', + 'area' => '区/县', + 'street' => '镇', + 'village' => '村', + ]; + + + /** + * @notes 添加场景 + * @return SubMerchantValidate + * @author likeadmin + * @date 2023/11/10 09:54 + */ + public function sceneAdd() + { + return $this->only(['sub_merchant_name','sub_mch_id','province','city','area','street','village']); + } + + + /** + * @notes 编辑场景 + * @return SubMerchantValidate + * @author likeadmin + * @date 2023/11/10 09:54 + */ + public function sceneEdit() + { + return $this->only(['id','sub_merchant_name','sub_mch_id','province','city','area','street','village']); + } + + + /** + * @notes 删除场景 + * @return SubMerchantValidate + * @author likeadmin + * @date 2023/11/10 09:54 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return SubMerchantValidate + * @author likeadmin + * @date 2023/11/10 09:54 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file