diff --git a/app/admin/controller/distribution/Member.php b/app/admin/controller/distribution/Member.php index 7652a3fa..fd063a7d 100755 --- a/app/admin/controller/distribution/Member.php +++ b/app/admin/controller/distribution/Member.php @@ -151,4 +151,20 @@ class Member extends AdminBase } } + public function treaty() + { + if ($this->request->isAjax()) { + $post = $this->request->post(); + $res = MemberLogic::setTreaty($post); + if ($res === false) { + $error = MemberLogic::getError() ?: '更新失败'; + return JsonServer::error($error); + } + return JsonServer::success('更新成功'); + } + + return view('', [ + 'detail' => MemberLogic::treaty() + ]); + } } \ No newline at end of file diff --git a/app/admin/logic/distribution/MemberLogic.php b/app/admin/logic/distribution/MemberLogic.php index 86606c40..ef95f57f 100755 --- a/app/admin/logic/distribution/MemberLogic.php +++ b/app/admin/logic/distribution/MemberLogic.php @@ -20,6 +20,8 @@ namespace app\admin\logic\distribution; use app\common\basics\Logic; +use app\common\enum\TreatyEnum; +use app\common\model\Treaty; use app\common\model\user\User; use app\common\model\user\UserLevel; use app\common\server\UrlServer; @@ -415,4 +417,42 @@ class MemberLogic extends Logic $apply->save(); return true; } + + // 设置佣金提现协议 + public static function setTreaty($post) + { + try { + $treaty = Treaty::where(['type'=>TreatyEnum::COMMISSION_WITHDRAWAL_TYPE])->findOrEmpty(); + $time = time(); + if($treaty->isEmpty()) { // 新增 + $addData = [ + 'name' => '佣金提现协议', + 'content' => $post['content'] ?? '', + 'type' => TreatyEnum::COMMISSION_WITHDRAWAL_TYPE, + 'create_time' => $time, + 'update_time' => $time + ]; + Treaty::create($addData); + }else{ // 更新 + Treaty::update([ + 'name' => '佣金提现协议', + 'content' => $post['content'] ?? '', + 'update_time' => $time + ], ['type' => TreatyEnum::COMMISSION_WITHDRAWAL_TYPE]); + } + return true; + } catch (\Exception $e) { + static::$error = $e->getMessage(); + return false; + } + } + + // 佣金提现协议 + public static function treaty() + { + $model = new Treaty(); + return $model->field(true) + ->where(['type' => TreatyEnum::COMMISSION_WITHDRAWAL_TYPE]) + ->findOrEmpty()->toArray(); + } } \ No newline at end of file diff --git a/app/admin/view/distribution/member/treaty.html b/app/admin/view/distribution/member/treaty.html new file mode 100644 index 00000000..f7116a9b --- /dev/null +++ b/app/admin/view/distribution/member/treaty.html @@ -0,0 +1,55 @@ +{layout name="layout1" /} + +
+
+ +
+
+
+ +
+

*设置佣金提现协议。

+

*您可以在下面的编辑框中,编辑更新协议内容。

+
+
+
+
+ + +
+
+ +
+
+ +
+
+ +
+
+ + \ No newline at end of file diff --git a/app/common/enum/TreatyEnum.php b/app/common/enum/TreatyEnum.php index a8c67790..85ced046 100755 --- a/app/common/enum/TreatyEnum.php +++ b/app/common/enum/TreatyEnum.php @@ -24,4 +24,5 @@ class TreatyEnum { const SHOP_ENTER_TYPE = 10; // 商城商家入驻协议 const LOCAL_STORE_ENTER_TYPE = 11; // 本地生活商家入驻协议 + const COMMISSION_WITHDRAWAL_TYPE = 12; // 佣金提现协议 } \ No newline at end of file