123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239 |
- <?php
- /**
- *
- * @author: wuhaotian<442384644@qq.com>
- * @day: 2019/12/07
- */
- namespace app\admin\controller\ump;
- use app\admin\controller\AuthController;
- use app\admin\model\user\UserGroup as GroupModel;
- use app\models\lala\LalaPinkJoin;
- use app\models\lala\LalaPinkLog;
- use crmeb\services\JsonService;
- use crmeb\services\UtilService;
- use crmeb\services\FormBuilder as Form;
- use Exception;
- use think\facade\Route as Url;
- /**
- * Class UserGroup
- * @package app\admin\controller\user
- */
- class LalaPink extends AuthController
- {
- /**
- * 会员分组页面
- * @return string
- */
- public function index()
- {
- return $this->fetch();
- }
- /**
- * 分组列表
- */
- public function groupList()
- {
- $where = UtilService::getMore([
- ['page', 1],
- ['limit', 20],
- ]);
- JsonService::successlayui(\app\models\lala\LalaPink::getList([], $where['page'], $where['limit']));
- }
- /**
- * 添加/修改分组页面
- * @param int $id
- * @return string
- * @throws Exception
- */
- public function addGroup(int $id = 0): string
- {
- $group = \app\models\lala\LalaPink::get($id);
- $f = array();
- $money_type = function () {
- $array = init_money_type();
- $new = [];
- foreach ($array as $v => $k) {
- $new[] = ['value' => $v, 'label' => $k];
- }
- return $new;
- };
- $f[] = Form::input('name', '活动名称', $group ? $group->getData('name') : '');
- $f[] = Form::frameImageOne('image', '会员背景', Url::buildUrl('admin/widget.images/index', array('fodder' => 'image')), isset($group) ? $group->background_image : '')->icon('image')->width('100%')->height('500px');
- $f[] = Form::frameImages('imgs', '轮播图', Url::buildUrl('admin/widget.images/index', array('fodder' => 'imgs')), $group ? explode(',', $group->getData('imgs')) : [])->maxLength(5)->icon('image')->width('100%')->height('500px');
- $f[] = Form::number('cost', '支付', $group ? $group->getData('cost') : '')->min(0)->step(0.00000001);
- $f[] = Form::select('cost_money_type', '支付币种', $group ? $group->getData('cost_money_type') : '')->setOptions($money_type());
- $f[] = Form::number('cost_2', '币种2支付', $group ? $group->getData('cost_2') : '')->min(0)->step(0.00000001);
- $f[] = Form::select('cost_2_money_type', '支付币种2', $group ? $group->getData('cost_2_money_type') : '')->setOptions($money_type());
- $f[] = Form::number('bingo', '中奖', $group ? $group->getData('bingo') : '')->min(0)->step(0.00000001);
- $f[] = Form::select('bingo_money_type', '中奖币种', $group ? $group->getData('bingo_money_type') : '')->setOptions($money_type());
- $f[] = Form::number('ticket', '门票', $group ? $group->getData('ticket') : '')->min(0)->step(0.00000001);
- $f[] = Form::select('ticket_money_type', '门票币种', $group ? $group->getData('ticket_money_type') : '')->setOptions($money_type());
- $f[] = Form::number('join_award_ratio', '参与奖比例', $group ? $group->getData('join_award_ratio') : '')->min(0)->step(0.01);
- $f[] = Form::number('system_money_ratio', '系统奖池比例', $group ? $group->getData('system_money_ratio') : '')->min(0)->step(0.01);
- $f[] = Form::number('join_number', '参与人数', $group ? $group->getData('join_number') : '')->min(0)->step(1);
- $f[] = Form::number('bingo_number', '中奖人数', $group ? $group->getData('bingo_number') : '')->min(0)->step(1);
- $f[] = Form::number('join_limit', '每日参与次数限制', $group ? $group->getData('join_limit') : '')->min(0)->step(1);
- $f[] = Form::radio('status', '状态', $group ? (int)$group->getData('status') : 1)->setOptions([['label' => '关闭', 'value' => 0], ['label' => '开启', 'value' => 1]]);
- $f[] = Form::select('sp_exchange_origin', '特殊兑换源币种', $group ? $group->getData('sp_exchange_origin') : '')->setOptions($money_type());
- $f[] = Form::number('sp_exchange_origin_cost', '源值', $group ? $group->getData('sp_exchange_origin_cost') : '')->min(0)->step(0.00000001);
- $f[] = Form::select('sp_exchange_target', '特殊兑换目标币种', $group ? $group->getData('sp_exchange_target') : '')->setOptions($money_type());
- $f[] = Form::number('sp_exchange_target_get', '目标值', $group ? $group->getData('sp_exchange_target_get') : '')->min(0)->step(0.00000001);
- $f[] = Form::number('sp_exchange_bingo_time', '特殊兑换中奖次数', $group ? $group->getData('sp_exchange_bingo_time') : '')->min(0)->step(1);
- $f[] = Form::number('bingo_limit', '中奖前置拼团次数', $group ? $group->getData('bingo_limit') : '')->min(0)->step(1);
- $form = Form::make_post_form('添加活动', $f, Url::buildUrl('saveGroup', array('id' => $id)));
- $this->assign(compact('form'));
- return $this->fetch('public/form-builder');
- }
- /**
- * 添加/修改
- * @param int $id
- */
- public function saveGroup($id = 0)
- {
- // var_dump(111);
- $data = UtilService::postMore([
- ['name', ''],
- ['cost', ''],
- ['cost_2', ''],
- ['image', ''],
- ['cost_money_type', ''],
- ['cost_2_money_type', ''],
- ['bingo', ''],
- ['bingo_money_type', ''],
- ['ticket', ''],
- ['ticket_money_type', ''],
- ['join_award_ratio', ''],
- ['system_money_ratio', ''],
- ['join_number', ''],
- ['bingo_number', ''],
- ['join_limit', ''],
- ['status', 1],
- ['sp_exchange_origin', ''],
- ['sp_exchange_origin_cost', ''],
- ['sp_exchange_target', ''],
- ['sp_exchange_target_get', ''],
- ['sp_exchange_bingo_time', 0],
- ['bingo_limit', 0],
- ['imgs', []],
- ], $this->request);
- // var_dump($data);
- $data['background_image'] = $data['image'];
- unset($data['image']);
- $data['imgs'] = implode(',', $data['imgs']);
- if ($id) {
- if (\app\models\lala\LalaPink::where('id', $id)->update($data)) {
- JsonService::success('修改成功');
- } else {
- JsonService::fail('修改失败或者您没有修改什么!');
- }
- } else {
- $data['add_time'] = time();
- if ($res = \app\models\lala\LalaPink::create($data)) {
- JsonService::success('保存成功', ['id' => $res->id]);
- } else {
- JsonService::fail('保存失败!');
- }
- }
- }
- /**
- * @param $id
- * @return string|void
- * @throws \Exception
- */
- public function detail($id)
- {
- if (!$id) $this->failed('数据不存在');
- $info = \app\models\lala\LalaPink::get($id);
- if (!$info) $this->failed('数据不存在!');
- $this->assign([
- 'content' => htmlspecialchars_decode($info['detail']),
- 'field' => 'detail',
- 'action' => Url::buildUrl('change_field', ['id' => $id, 'field' => 'detail'])
- ]);
- return $this->fetch('public/edit_content');
- }
- /**
- * @param $id
- */
- public function change_field($id)
- {
- if (!$id) JsonService::fail('数据不存在');
- $seckill = \app\models\lala\LalaPink::get($id);
- if (!$seckill) JsonService::fail('数据不存在!');
- $data['detail'] = request()->post('detail');
- $res = \app\models\lala\LalaPink::edit($data, $id);
- if ($res)
- JsonService::successful('修改成功');
- else
- JsonService::fail('修改失败');
- }
- /**
- * 会员分组页面
- * @return string
- */
- public function join_index()
- {
- return $this->fetch();
- }
- /**
- * 分组列表
- */
- public function joinList()
- {
- $where = UtilService::getMore([
- ['id', ''],
- ['uid', ''],
- ['page', 1],
- ['limit', 20],
- ]);
- JsonService::successlayui(LalaPinkJoin::getListAdmin($where, $where['page'], $where['limit']));
- }
- /**
- * 添加/修改分组页面
- * @param int $id
- * @return string
- * @throws Exception
- */
- public function setStatus(int $id = 0): string
- {
- $group = LalaPinkJoin::get($id);
- if (!$group || !$id) $this->failed('找不到记录');
- if ($group['status'] != 0) $this->failed('记录已结算');
- $f = array();
- $f[] = Form::radio('set_status', '设置状态', $group['set_status'])->setOptions([['label' => '必中', 'value' => 1], ['label' => '失败', 'value' => 2], ['label' => '不设置', 'value' => 0]]);
- $form = Form::make_post_form('设置状态', $f, Url::buildUrl('saveStatus', array('id' => $id)));
- $this->assign(compact('form'));
- return $this->fetch('public/form-builder');
- }
- /**
- * 添加/修改
- * @param int $id
- */
- public function saveStatus($id = 0)
- {
- $data = UtilService::postMore([
- ['set_status', 1],
- ], $this->request);
- if ($id) {
- if (LalaPinkJoin::where('id', $id)->update($data)) {
- JsonService::success('修改成功');
- } else {
- JsonService::fail('修改失败或者您没有修改什么!');
- }
- } else {
- JsonService::fail('设置失败!');
- }
- }
- }
|