assign(compact('money_type')); $this->assign('count_plan', PointPlanModel::count()); return $this->fetch(); } /** * 获取vote表 * * @return void */ public function get_list() { $where = Util::getMore([ ['page', 1], ['limit', 20], ['title', ''], ['status', ''], ]); Json::successlayui(PointPlanModel::getList($where)); } /** * 创建form表单 * * @param int $id * @return string * @throws Exception * @throws FormBuilderException */ public function create($id = 0) { $money_type = sys_data('money_type'); $money_type_select = []; foreach ($money_type as $v) { $money_type_select[] = ['label' => $v['name'], 'value' => $v['code']]; } if ($id) $info = PointPlanModel::get($id); $field[] = Form::input('plan_name', '计划标题', isset($info) ? $info->plan_name : '')->col(Form::col(24))->required(); $field[] = Form::select('release_money_type', '释放币种', isset($info) ? $info->release_money_type : '')->options($money_type_select)->col(24)->required(); $field[] = Form::select('buy_money_type', '认购币种', isset($info) ? $info->buy_money_type : '')->options($money_type_select)->col(24)->required(); $field[] = Form::number('buy_num', '认购额度', isset($info) ? $info->buy_num : 0)->min(0)->col(24)->required(); $field[] = Form::number('buy_price', '认购价格', isset($info) ? $info->buy_price : 0)->step(0.00000001)->col(24)->required(); $field[] = Form::number('release_ratio', '收益倍数', isset($info) ? $info->release_ratio : 0)->min(0)->col(12)->step(0.01)->required(); $field[] = Form::number('num', '节点名额', isset($info) ? $info->num : 0)->min(0)->col(12)->required(); $field[] = Form::number('recommend_num', '考核推荐有效用户', isset($info) ? $info->recommend_num : 0)->min(0)->col(12)->required(); $field[] = Form::number('group_num', '考核团队有效人数', isset($info) ? $info->group_num : 0)->min(0)->col(12)->required(); $field[] = Form::number('exam_time', '考核期(天)', isset($info) ? $info->exam_time : 0)->min(0)->col(12)->required(); $field[] = Form::number('layer_award_ratio', '团队奖比例', isset($info) ? $info->layer_award_ratio : 0)->min(0)->col(12)->required(); $field[] = Form::number('layer_award_layer', '团队奖层数', isset($info) ? $info->layer_award_layer : 0)->min(0)->col(12)->required(); $field[] = Form::number('release_day', '释放天数', isset($info) ? $info->release_day : 0)->min(0)->col(12)->required(); $field[] = Form::dateTime('start_time', '开启认购时间', isset($info) ? date('Y-m-d H:i:s', $info->start_time) : '')->col(12); $form = Form::make_post_form('添加计划', $field, Url::buildUrl('save', ['id' => $id]), 2); $this->assign(compact('form')); return $this->fetch('public/form-builder'); } /** * 添加或者修改 * @param $id * @return void */ public function save($id = 0) { $data = UtilService::postMore([ ['plan_name', ''], ['release_money_type', ''], ['buy_money_type', ''], ['buy_num', 0], ['buy_price', 0], ['release_ratio', 0], ['num', 0], ['recommend_num', 0], ['group_num', 0], ['exam_time', 0], ['layer_award_ratio', 0], ['layer_award_layer', 0], ['release_day', ''], ['start_time', 0], ]); PointPlanModel::beginTrans(); if (!$data['start_time']) { JsonService::fail('开启认购时间'); } $data['start_time'] = strtotime($data['start_time']); try { //修改 if ($id) { if (PointPlanModel::edit($data, $id)) { PointPlanModel::commitTrans(); JsonService::successful('修改成功'); } else { PointPlanModel::rollbackTrans(); JsonService::fail('修改失败'); } } else { //新增 $data['add_time'] = time(); $res = PointPlanModel::create($data); if ($res) { PointPlanModel::commitTrans(); JsonService::successful('添加成功'); } else { PointPlanModel::rollbackTrans(); JsonService::fail('添加失败'); } } } catch (\Exception $e) { PointPlanModel::rollbackTrans(); JsonService::fail($e->getMessage()); } } /** * 会员详情 */ public function see($id = '') { $this->assign([ 'id' => $id, ]); return $this->fetch(); } // /** // * 创建form表单 // * // * @param int $id // * @return string // * @throws Exception // * @throws FormBuilderException // */ // public function create_sub($id = 0, $vid = 0) // { // if (!$id && !$vid) { // $this->failed('参数异常'); // } // if ($id) $info = VoteSub::get($id); // if (isset($info)) $vid = $info['vote_id']; //// var_dump($id); // $field[] = Form::hidden('vote_id', $vid); // $field[] = Form::input('vote_sub_name', '投票标题', isset($info) ? $info->vote_sub_name : '')->col(Form::col(24))->required(); // $field[] = Form::number('vote_num', '投票数量', isset($info) ? $info->vote_num : 0)->min(0)->col(12)->step(0.00000001)->required(); // $field[] = Form::number('max_vote_num', '个人投票上限', isset($info) ? $info->max_vote_num : 0)->min(0)->col(12)->step(0.00000001)->required(); // $field[] = Form::dateTime('start_time', '开始时间', isset($info) ? date('Y-m-d H:i:s', $info->start_time) : ''); // $field[] = Form::dateTime('end_time', '结束时间', isset($info) ? date('Y-m-d H:i:s', $info->end_time) : ''); // if ((isset($info) && $info['status'] != 2 && $info['status'] != 3) || !isset($info)) // $field[] = Form::radio('status', '状态', isset($info) ? $info->status : 0)->options([['label' => '开启', 'value' => 1], ['label' => '关闭', 'value' => 0]]); // $form = Form::make_post_form('添加子投票', $field, Url::buildUrl('save_sub', ['id' => $id]), 2); // $this->assign(compact('form')); // return $this->fetch('public/form-builder'); // } // /** // * 添加或者修改 // * @param $id // * @return void // */ // public function save_sub($id = 0) // { // $data = UtilService::postMore([ // ['vote_sub_name', ''], // ['vote_id', ''], // ['vote_num', ''], // ['max_vote_num', ''], // ['end_time', ''], // ['start_time', ''], // ['status', 0], // ]); // VoteSub::beginTrans(); // try { // if (!$data['vote_id']) JsonService::fail('请选择投票'); // if (!$data['start_time']) JsonService::fail('请输入开始时间'); // if (!$data['end_time']) JsonService::fail('请输入结束时间'); // $data['start_time'] = strtotime($data['start_time']); // $data['end_time'] = strtotime($data['end_time']); // if ($data['end_time'] <= $data['start_time']) JsonService::fail('结束时间要大于开始时间'); // if (!$id) $data['loop'] = VoteSub::where('vote_id', $data['vote_id'])->max('loop') + 1; // //修改 // if ($id) { // if (VoteSub::edit($data, $id)) { // VoteSub::commitTrans(); // JsonService::successful('修改成功'); // } else { // VoteSub::rollbackTrans(); // JsonService::fail('修改失败'); // } // } else { // //新增 // $data['add_time'] = time(); // $res = VoteSub::create($data); // if ($res) { // VoteModel::commitTrans(); // JsonService::successful('添加成功'); // } else { // VoteModel::rollbackTrans(); // JsonService::fail('添加失败'); // } // } // } catch (\Exception $e) { // VoteModel::rollbackTrans(); // JsonService::fail($e->getMessage()); // } // } // public function see_people($id = 0) // { // $this->assign([ // 'id' => $id, // ]); // return $this->fetch(); // } // // public function people_list() // { // $where = Util::getMore([ // ['page', 1], // ['limit', 20], // ['id', 0], // ]); // Json::successlayui(UserVote::getUserList($where)); // } /** * 获取voteSub表 * * @return void */ public function get_sub_list() { $where = Util::getMore([ ['page', 1], ['limit', 20], ['id', 0], ]); Json::successlayui(UserPointPlan::getList($where)); } }