123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259 |
- <?php
- namespace app\admin\controller\auction;
- use app\admin\controller\AuthController;
- use app\admin\controller\Union;
- use app\admin\model\user\User;
- use app\admin\model\user\UserBill;
- use crmeb\services\{ExpressService,
- JsonService,
- MiniProgramService,
- upload\Upload,
- WechatService,
- FormBuilder as Form,
- CacheService,
- UtilService as Util,
- JsonService as Json};
- use app\admin\model\system\{
- SystemAttachment as SystemAttachmentModel, SystemAttachmentCategory as Category
- };
- use app\admin\model\auction\AuctionBooking as model;
- use think\facade\Route as Url;
- /**
- * 竞拍管理
- * Class StoreOrder
- * @package app\admin\controller\store
- */
- class AuctionBooking extends AuthController
- {
- public function index()
- {
- $list = \app\admin\model\auction\Auction::select();
- $this->assign([
- 'year' => get_month(),
- 'auction'=> $list
- ]);
- return $this->fetch();
- }
- /**
- * 获取列表
- * @return void
- */
- public function list()
- {
- $where = Util::getMore([
- ['is_show', ''],
- ['page', 1],
- ['limit', 20],
- ['auction_id', ''],
- ['store_name', ''],
- ['data', '']
- ]);
- $data = model::list($where);
- foreach ($data['data'] as $key => $val){
- if ($data['data'][$key]['uid'] == 0) $data['data'][$key]['nickname'] = '管理';
- }
- return Json::successlayui($data);
- }
- public function auction_list()
- {
- $list = model::select()->toArray();
- Json::successful($list);
- }
- /**
- * 显示创建资源表单页.
- *
- * @return \think\Response
- */
- public function create($id = 0)
- {
- $data = \app\admin\model\auction\Auction::select()->toArray();
- $this->assign(['id' => $id, 'list' => $data]);
- return $this->fetch();
- }
- /**
- * 添加
- * @param $id
- * @return void
- */
- public function save($id)
- {
- $data = Util::postMore([
- 'name',
- 'is_show',
- 'image',
- 'price',
- 'deduct',
- 'rise',
- 'info',
- 'sort',
- 'auction_id'
- ]);
- $model = new model();
- $res = $model->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('删除失败');
- $res = model::where('id', $id)->delete();
- if ($res){
- return Json::success('删除成功!');
- }else{
- return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
- }
- }
- /**
- * 修改状态
- * @param $id
- * @param $status
- * @return void
- */
- public function set_status($id, $status)
- {
- if (empty($id)) Json::fail('修改失败');
- $res = model::update(['is_show' => $status, 'id' => $id]);
- if ($res){
- return Json::success('修改成功!');
- }else{
- return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
- }
- }
- /**
- * 编辑页面
- * @param $id
- * @return string
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function edit($id)
- {
- if (!$id) Json::fail('数据不存在');
- $data = \app\admin\model\auction\Auction::select()->toArray();
- $this->assign(['id' => $id, 'list' => $data]);
- return $this->fetch();
- }
- public function get_list($id)
- {
- if (!$id) Json::fail('数据不存在');
- $model = new model();
- $info = $model->find($id);
- return JsonService::successful($info);
- }
- /**
- * 修改
- * @param $id
- * @return void
- */
- public function update($id)
- {
- $data = Util::postMore([
- 'id',
- 'name',
- 'is_show',
- 'image',
- 'price',
- 'deduct',
- 'rise',
- 'info',
- 'sort',
- 'auction_id'
- ]);
- $res = model::update($data);
- if ($res){
- return Json::success('修改成功!');
- }else{
- return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
- }
- }
- /**
- * 退回广告值
- * @param $id
- * @return void
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function th($id)
- {
- if (!$id) Json::fail('没有数据');
- $data = model::find($id);
- if ($data['status'] < 1) Json::fail('已退回请勿重复提交');
- $userModel = new User();
- $user = $userModel->where('uid', $data['uid'])->find();
- if (!$user) Json::fail('没有数据');
- $user['anticipate'] = $user['anticipate']+ $data['anticipate'];
- $bill = UserBill::create([
- 'uid' => $user['uid'],
- 'pm' => 1,
- 'title' => '广告值退回',
- 'category' => 'anticipate',
- 'type' => 'add_anticipate',
- 'number' => $data['anticipate'],
- 'balance' => $user['anticipate'],
- 'mark' => '后台操作退回',
- 'add_time' => time(),
- ]);
- if ($bill){
- $res = $user->save();
- model::where('id', $id)->update(['status' => 0]);
- if ($res){
- Json::successful('退回成功');
- }else{
- Json::fail('退回失败');
- }
- }else{
- Json::fail('错误');
- }
- }
- }
|