作者 何书鹏
1 个管道 的构建 通过 耗费 1 秒

充值积分每分需多少元

@@ -66,7 +66,7 @@ class Company extends Backend @@ -66,7 +66,7 @@ class Company extends Backend
66 foreach ($list as $row) { 66 foreach ($list as $row) {
67 $row->visible(['id','user_id','name','address','license','legal_person','invite_code','status']); 67 $row->visible(['id','user_id','name','address','license','legal_person','invite_code','status']);
68 $row->visible(['user']); 68 $row->visible(['user']);
69 - $row->getRelation('user')->visible(['nickname']); 69 + $row->getRelation('user')->visible(['group_id','nickname']);
70 } 70 }
71 $list = collection($list)->toArray(); 71 $list = collection($list)->toArray();
72 $result = array("total" => $total, "rows" => $list); 72 $result = array("total" => $total, "rows" => $list);
@@ -143,4 +143,53 @@ class Company extends Backend @@ -143,4 +143,53 @@ class Company extends Backend
143 $this->success($msg); 143 $this->success($msg);
144 } 144 }
145 } 145 }
  146 +
  147 + /**
  148 + * 设置角色
  149 + */
  150 + public function setgroup($ids = null)
  151 + {
  152 + if($ids) {
  153 + $row = $this->model->get($ids);
  154 + if (!$row) {
  155 + $this->error(__('No Results were found'));
  156 + }
  157 + $adminIds = $this->getDataLimitAdminIds();
  158 + if (is_array($adminIds)) {
  159 + if (!in_array($row[$this->dataLimitField], $adminIds)) {
  160 + $this->error(__('You have no permission'));
  161 + }
  162 + }
  163 + $params = $this->request->param();
  164 + if ($params['group_id'] == 1) {
  165 + if ($row->user->group_id == 1) {
  166 + $this->error('该用户已经是企业管理员了');
  167 + }
  168 + }
  169 + if ($params['group_id'] == 0) {
  170 + if ($row->user->group_id == 0) {
  171 + $this->error('该企业管理员已经是普通用户了');
  172 + }
  173 + }
  174 + $row->user->group_id = $params['group_id'];
  175 + Db::startTrans();
  176 + try {
  177 + $result = $row->user->save();
  178 + Db::commit();
  179 + } catch (ValidateException $e) {
  180 + Db::rollback();
  181 + $this->error($e->getMessage());
  182 + } catch (PDOException $e) {
  183 + Db::rollback();
  184 + $this->error($e->getMessage());
  185 + } catch (\think\Exception $e) {
  186 + Db::rollback();
  187 + $this->error($e->getMessage());
  188 + }
  189 + if(!$result) {
  190 + $this->error('操作失败');
  191 + }
  192 + $this->success('操作成功');
  193 + }
  194 + }
146 } 195 }
@@ -117,7 +117,7 @@ @@ -117,7 +117,7 @@
117 </div> 117 </div>
118 </div> 118 </div>
119 <div class="form-group"> 119 <div class="form-group">
120 - <label class="control-label col-xs-12 col-sm-2">每积分可抵多少元:</label> 120 + <label class="control-label col-xs-12 col-sm-2">每积分可抵多少元:</label>
121 <div class="col-xs-12 col-sm-8"> 121 <div class="col-xs-12 col-sm-8">
122 <input id="c-score_price" class="form-control" name="row[score_price]" type="number" value="{$row.score_price}"> 122 <input id="c-score_price" class="form-control" name="row[score_price]" type="number" value="{$row.score_price}">
123 </div> 123 </div>
@@ -14,6 +14,11 @@ @@ -14,6 +14,11 @@
14 <!--<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>--> 14 <!--<li><a class="btn btn-link btn-multi btn-disabled disabled" href="javascript:;" data-params="status=hidden"><i class="fa fa-eye-slash"></i> {:__('Set to hidden')}</a></li>-->
15 <!--</ul>--> 15 <!--</ul>-->
16 <!--</div>--> 16 <!--</div>-->
  17 + <a href="javascript:;" class="btn btn-default" style="font-size:14px;color:dodgerblue;">
  18 + <span class="extend">
  19 + 用户数量:<span id="total">0</span>
  20 + </span>
  21 + </a>
17 </div> 22 </div>
18 <table id="table" class="table table-striped table-bordered table-hover" 23 <table id="table" class="table table-striped table-bordered table-hover"
19 data-operate-edit="{:$auth->check('user/user/edit')}" 24 data-operate-edit="{:$auth->check('user/user/edit')}"
@@ -416,6 +416,24 @@ class Course extends Api @@ -416,6 +416,24 @@ class Course extends Api
416 } 416 }
417 417
418 /** 418 /**
  419 + * @ApiTitle (每积分可抵扣多少元)
  420 + * @ApiSummary (每积分可抵扣多少元)
  421 + * @ApiMethod (POST)
  422 + *
  423 + * @ApiReturn({
  424 + "code": 1,
  425 + "msg": "成功",
  426 + "time": "1599046220",
  427 + "data": 0.01 //每积分可抵扣多少元
  428 + })
  429 + */
  430 + public function scorePrice()
  431 + {
  432 + $content = Db::name('mobile_config')->where('id',1)->value('score_price');
  433 + $this->success('成功', $content);
  434 + }
  435 +
  436 + /**
419 * @ApiTitle (购买预览) 437 * @ApiTitle (购买预览)
420 * @ApiSummary (购买预览) 438 * @ApiSummary (购买预览)
421 * @ApiMethod (POST) 439 * @ApiMethod (POST)
@@ -1175,6 +1175,25 @@ class User extends Api @@ -1175,6 +1175,25 @@ class User extends Api
1175 } 1175 }
1176 1176
1177 /** 1177 /**
  1178 + * @ApiWeigh (56)
  1179 + * @ApiTitle (充值积分每分需多少元)
  1180 + * @ApiSummary (充值积分每分需多少元)
  1181 + * @ApiMethod (POST)
  1182 + *
  1183 + * @ApiReturn({
  1184 + "code": 1,
  1185 + "msg": "成功",
  1186 + "time": "1599046220",
  1187 + "data": 0.01 //充值积分每分需多少元
  1188 + })
  1189 + */
  1190 + public function scorePrice()
  1191 + {
  1192 + $content = Db::name('mobile_config')->where('id',1)->value('score_recharge_price');
  1193 + $this->success('成功', $content);
  1194 + }
  1195 +
  1196 + /**
1178 * @ApiWeigh (55) 1197 * @ApiWeigh (55)
1179 * @ApiTitle (积分充值预览) 1198 * @ApiTitle (积分充值预览)
1180 * @ApiSummary (积分充值预览) 1199 * @ApiSummary (积分充值预览)
@@ -99,6 +99,40 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin @@ -99,6 +99,40 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
99 return true; 99 return true;
100 } 100 }
101 }, 101 },
  102 + },
  103 + {
  104 + name: 'setuser',
  105 + text: '设为普通用户',
  106 + title: '设为普通用户',
  107 + classname: 'btn btn-xs btn-primary btn-ajax',
  108 + icon: '',
  109 + url: 'mobile/company/setgroup?group_id=0',
  110 + confirm: '是否确认拒绝审核?',
  111 + visible:function (row) {
  112 + if(row.user.group_id == 1){
  113 + return true;
  114 + }
  115 + },
  116 + success: function (data) {
  117 + table.bootstrapTable('refresh');
  118 + }
  119 + },
  120 + {
  121 + name: 'setuser',
  122 + text: '设为企业管理员',
  123 + title: '设为企业管理员',
  124 + classname: 'btn btn-xs btn-primary btn-ajax',
  125 + icon: '',
  126 + url: 'mobile/company/setgroup?group_id=1',
  127 + confirm: '是否确认拒绝审核?',
  128 + visible:function (row) {
  129 + if(row.user.group_id == 0){
  130 + return true;
  131 + }
  132 + },
  133 + success: function (data) {
  134 + table.bootstrapTable('refresh');
  135 + }
102 } 136 }
103 ], formatter: Table.api.formatter.operate, 137 ], formatter: Table.api.formatter.operate,
104 } 138 }
@@ -16,6 +16,14 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin @@ -16,6 +16,14 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
16 16
17 var table = $("#table"); 17 var table = $("#table");
18 18
  19 + //当表格数据加载完成时
  20 + table.on('load-success.bs.table', function (e, data) {
  21 + //这里可以获取从服务端获取的JSON数据
  22 + console.log(data);
  23 + //这里我们手动设置底部的值
  24 + $("#total").text(data.total);
  25 + });
  26 +
19 // 初始化表格 27 // 初始化表格
20 table.bootstrapTable({ 28 table.bootstrapTable({
21 url: $.fn.bootstrapTable.defaults.extend.index_url, 29 url: $.fn.bootstrapTable.defaults.extend.index_url,
此 diff 太大无法显示。