123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246 |
- <?php
- namespace app\admin\controller\user;
- use app\admin\controller\AuthController;
- use app\admin\controller\Union;
- use app\admin\model\order\StoreOrder;
- use app\admin\model\User;
- use crmeb\services\{ExpressService,
- FormBuilder,
- JsonService,
- MiniProgramService,
- upload\Upload,
- WechatService,
- FormBuilder as Form,
- CacheService,
- UtilService as Util,
- JsonService as Json
- };
- use app\admin\model\system\{SystemAdmin,
- SystemAttachment as SystemAttachmentModel,
- SystemAttachmentCategory as Category
- };
- use think\Db;
- use think\facade\Route as Url;
- use think\facade\Validate;
- use app\admin\model\user\Out as model;
- class Out extends AuthController
- {
- public function index()
- {
- $this->assign('admin', $this->adminInfo);
- return $this->fetch();
- }
- public function list()
- {
- $where = Util::getMore([
- ['status', ''],
- ['page', 1],
- ['limit', 20],
- ['auction'],
- ['uid'],
- ['null']
- ]);
- $data = model::list($where);
- return Json::successlayui($data);
- }
- /**
- * 显示创建资源表单页.
- *
- * @return \think\Response
- */
- public function create($id = 0)
- {
- $f = [];
- $f[] = Form::input('name', '名称')->col(12);
- $f[] = Form::textarea('info', '简介');
- $f[] = Form::number('number', '达标额度')->col(12);
- $f[] = Form::frameImages('pics', '轮播图', Url::buildUrl('admin/widget.images/index', array('fodder' => 'pics')))->maxLength(5)->icon('image')->width('100%')->height('500px');
- $f[] = Form::radio('status', '状态', 1)->options([['label' => '开启', 'value' => 1], ['label' => '关闭', 'value' => 0]]);
- $form = Form::make_post_form('添加', $f, Url::buildUrl('save'));
- $this->assign(compact('form'));
- return $this->fetch('public/form-builder');
- }
- public function save()
- {
- $mode = new model;
- $data = Util::postMore([
- 'name',
- 'info',
- 'number',
- 'status',
- ['pics', []]
- ]);
- $validate = Validate::rule('name', 'require')->rule([
- 'name' => 'require',
- 'number' => 'require',
- ]);
- $validate->message([
- 'name.require' => '名称不能为空',
- 'number.require' => '达标额度不能为空',
- ]);
- $data['pics'] = implode(',', $data['pics']);
- if (!$validate->check($data)) {
- return Json::fail($validate->getError());
- }
- $res = $mode->save($data);
- if ($res) {
- return Json::success('添加成功!');
- } else {
- return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
- }
- }
- /**
- * 删除
- * @param $id
- * @return void
- * @throws \Exception
- */
- public function delete($id)
- {
- if (!$id) Json::fail('删除失败');
- $model = new model;
- $res = $model->where('id', $id)->delete();
- if ($res) {
- return Json::success('删除成功!');
- } else {
- return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
- }
- }
- public function set_status($id, $status)
- {
- if (empty($id)) return Json::fail('修改失败');
- $res = model::update(['status' => $status, 'id' => $id]);
- if ($res) {
- return Json::success('修改成功!');
- } else {
- return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
- }
- }
- public function edit($id)
- {
- if (!$id) Json::fail('数据不存在');
- $data = model::find($id);
- $f = [];
- $f[] = Form::input('name', '名称', $data->getData('name'))->col(12);
- $f[] = Form::textarea('info', '介绍', $data->getData('info'));
- $f[] = Form::frameImages('pics', '轮播图', Url::buildUrl('admin/widget.images/index', array('fodder' => 'pics')), explode(',', $data->getData('pics')))->maxLength(5)->icon('image')->width('100%')->height('500px');
- $f[] = Form::number('number', '达标额度', $data->getData('number'))->col(12);
- $f[] = Form::radio('status', '状态', $data->getData('status'))->options([['label' => '开启', 'value' => 1], ['label' => '关闭', 'value' => 0]]);
- $form = Form::make_post_form('修改', $f, Url::buildUrl('update', compact('id')));
- $this->assign(compact('form'));
- return $this->fetch('public/form-builder');
- }
- public function update()
- {
- $data = Util::postMore([
- 'id',
- 'name',
- 'info',
- 'status',
- 'number',
- ['pics', []]
- ]);
- $validate = Validate::rule('name', 'require')->rule([
- 'name' => 'require',
- 'number' => 'require',
- ]);
- $validate->message([
- 'name.require' => '名称不能为空',
- 'number.require' => '达标数量不能为空',
- ]);
- $data['pics'] = implode(',', $data['pics']);
- if (!$validate->check($data)) {
- return Json::fail($validate->getError());
- }
- $res = model::update($data);
- if ($res) {
- return Json::success('修改成功!');
- } else {
- return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
- }
- }
- public function edit_content($id)
- {
- if (!$id) return $this->failed('数据不存在');
- $seckill = model::get($id);
- if (!$seckill) return Json::fail('数据不存在!');
- $this->assign([
- 'content' => htmlspecialchars_decode($seckill['content']),
- 'field' => 'content',
- 'action' => Url::buildUrl('change_field', ['id' => $id, 'field' => 'content'])
- ]);
- return $this->fetch('public/edit_content');
- }
- public function change_field($id)
- {
- if (!$id) return $this->failed('数据不存在');
- $seckill = model::get($id);
- if (!$seckill) return Json::fail('数据不存在!');
- $data['content'] = request()->post('content');
- $res = model::edit($data, $id);
- if ($res)
- return Json::successful('添加成功');
- else
- return Json::fail('添加失败');
- }
- /**
- * 显示创建资源表单页.
- *
- * @return \think\Response
- */
- public function user_push($uid = 0)
- {
- return $this->fetch();
- }
- public function user_push_list()
- {
- $where = Util::getMore([
- ['status', ''],
- ['page', 1],
- ['limit', 20],
- ['auction'],
- ['uid'],
- ['spread_uid']
- ]);
- $data = StoreOrder::list($where);
- return Json::successlayui($data);
- }
- }
|