diff --git a/app/admin/controller/goods/Subsidy.php b/app/admin/controller/goods/Subsidy.php index f1f5928b..0d5024a9 100644 --- a/app/admin/controller/goods/Subsidy.php +++ b/app/admin/controller/goods/Subsidy.php @@ -16,7 +16,10 @@ class Subsidy extends AdminBase $get = $this->request->get(); return JsonServer::success('获取成功', SubsidyLogic::lists($get)); } - return view(); + + return view('', [ + 'config' => SubsidyLogic::getSubsidyConfig() + ]); } public function add() @@ -59,4 +62,17 @@ class Subsidy extends AdminBase return JsonServer::error(SubsidyLogic::getError() ?: '操作失败'); } } + + // 设置全局返补比例 + public function setSubsidyConfig() + { + if ($this->request->isAjax()) { + $post = $this->request->post(); + if (SubsidyLogic::setSubsidyConfig($post)) { + return JsonServer::success('操作成功'); + } + + return JsonServer::error(SubsidyLogic::getError() ?: '操作失败'); + } + } } \ No newline at end of file diff --git a/app/admin/logic/goods/SubsidyLogic.php b/app/admin/logic/goods/SubsidyLogic.php index 0a88a27d..f19e4855 100755 --- a/app/admin/logic/goods/SubsidyLogic.php +++ b/app/admin/logic/goods/SubsidyLogic.php @@ -5,6 +5,8 @@ namespace app\admin\logic\goods; use app\common\basics\Logic; use app\common\model\goods\GoodsBrand; use app\common\model\goods\GoodsSubsidy; +use app\common\server\ConfigServer; +use think\Exception; use think\facade\Db; /** @@ -55,6 +57,7 @@ class SubsidyLogic extends Logic Db::commit(); return true; } catch (\Exception $e) { + Db::rollback(); self::$error = $e->getMessage(); return false; } @@ -78,6 +81,7 @@ class SubsidyLogic extends Logic Db::commit(); return true; } catch (\Exception $e) { + Db::rollback(); self::$error = $e->getMessage(); return false; } @@ -88,4 +92,38 @@ class SubsidyLogic extends Logic { return GoodsSubsidy::update(['is_delete' => 1, 'delete_time' => time()], ['id' => $id]); } + + // 获取全局返补比例 + public static function getSubsidyConfig() + { + return [ + 'promote_user' => ConfigServer::get('subsidy', 'promote_user'), + 'promote_store' => ConfigServer::get('subsidy', 'promote_store'), + 'platform_services' => ConfigServer::get('subsidy', 'platform_services'), + 'no_level' => ConfigServer::get('subsidy', 'no_level'), + ]; + } + + // 设置全局返补比例 + public static function setSubsidyConfig($post) + { + try { + if (empty($post['promote_user']) && empty($post['promote_store']) && empty($post['platform_services']) && empty($post['no_level'])) { + self::$error = '所提交的字段内容不能为空'; + return false; + } + + Db::startTrans(); + ConfigServer::set('subsidy', 'promote_user', str_replace('%', '', $post['promote_user'])); + ConfigServer::set('subsidy', 'promote_store', str_replace('%', '', $post['promote_store'])); + ConfigServer::set('subsidy', 'platform_services', str_replace('%', '', $post['platform_services'])); + ConfigServer::set('subsidy', 'no_level', str_replace('%', '', $post['no_level'])); + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::$error = $e->getMessage(); + return false; + } + } } \ No newline at end of file diff --git a/app/admin/view/goods/subsidy/lists.html b/app/admin/view/goods/subsidy/lists.html index 1f3bb75c..ee3818c6 100755 --- a/app/admin/view/goods/subsidy/lists.html +++ b/app/admin/view/goods/subsidy/lists.html @@ -9,7 +9,9 @@ width: 120px; } - .w-300 { + .info { + display: flex; + align-items: center; width: 300px; } @@ -30,32 +32,40 @@
全平台 -
+
推广用户收益: -
- +
+ +

%

推广店铺收益: -
- +
+ +

%

平台服务费: -
- +
+ +

%

无级码费用: -
- +
+ +

%

+ +
+ +
@@ -229,5 +239,22 @@ , {fixed: 'right', title: '操作', align: 'center', width: 300, toolbar: '#subsidy-operation'} ]); + form.on('submit(submit)', function(data){ + like.ajax({ + url: '{:url("goods.subsidy/setSubsidyConfig")}', + data: data.field, + type: "post", + success: function (res) { + if (res.code == 1) { + layui.layer.msg(res.msg, { + offset: '15px' + , icon: 1 + , time: 1000 + }); + } + } + }); + return false + }); }); \ No newline at end of file