Auction.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. <?php
  2. namespace app\admin\controller\auction;
  3. use app\admin\controller\AuthController;
  4. use app\admin\controller\Union;
  5. use crmeb\services\{ExpressService,
  6. JsonService,
  7. MiniProgramService,
  8. upload\Upload,
  9. WechatService,
  10. FormBuilder as Form,
  11. CacheService,
  12. UtilService as Util,
  13. JsonService as Json};
  14. use app\admin\model\system\{
  15. SystemAttachment as SystemAttachmentModel, SystemAttachmentCategory as Category
  16. };
  17. use think\facade\Route as Url;
  18. /**
  19. * 竞拍管理
  20. * Class StoreOrder
  21. * @package app\admin\controller\store
  22. */
  23. class Auction extends AuthController
  24. {
  25. public function index()
  26. {
  27. return $this->fetch();
  28. }
  29. public function list()
  30. {
  31. $where = Util::getMore([
  32. ['status', ''],
  33. ['page', 1],
  34. ['limit', 20],
  35. ['auction']
  36. ]);
  37. $data = \app\admin\model\auction\Auction::list($where);
  38. return Json::successlayui($data);
  39. }
  40. /**
  41. * 显示创建资源表单页.
  42. *
  43. * @return \think\Response
  44. */
  45. public function create($id = 0)
  46. {
  47. $data = [];
  48. if ($id > 0) $data = \app\admin\model\auction\Auction::find($id)->toArray();
  49. $this->assign(['id' => $id, 'dataList' => $data]);
  50. return $this->fetch();
  51. }
  52. public function save($id)
  53. {
  54. $mode = new \app\admin\model\auction\Auction();
  55. $data = Util::postMore([
  56. 'nickname',
  57. 'image',
  58. 'status',
  59. 'sort',
  60. 'time',
  61. 'rtime',
  62. 'info',
  63. 'anticipate'
  64. ]);
  65. $time = explode('-', $data['time']);
  66. $data['add_time'] = trim($time[0]);
  67. $data['end_time'] = trim($time[1]);
  68. $rtime = explode('-', $data['rtime']);
  69. $data['radd_time'] = trim($rtime[0]);
  70. $data['rend_time'] = trim($rtime[1]);
  71. if (strtotime($time[0]) > strtotime( $time[1])) Json::fail('预约时间选择错误');
  72. if (strtotime($time[0]) > strtotime( $time[1])) Json::fail('进场时间选择错误');
  73. $res = $mode->save($data);
  74. if ($res){
  75. return Json::success('添加成功!');
  76. }else{
  77. return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
  78. }
  79. }
  80. /**
  81. * 删除
  82. * @param $id
  83. * @return void
  84. * @throws \Exception
  85. */
  86. public function delete($id)
  87. {
  88. if (!$id) Json::fail('删除失败');
  89. $model = new \app\admin\model\auction\Auction();
  90. $res = $model->where('id', $id)->useSoftDelete('delete_time',time())->delete();
  91. if ($res){
  92. return Json::success('删除成功!');
  93. }else{
  94. return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
  95. }
  96. }
  97. public function set_status($id, $status)
  98. {
  99. if (empty($id)) Json::fail('修改失败');
  100. $res = \app\admin\model\auction\Auction::update(['status' => $status, 'id' => $id]);
  101. if ($res){
  102. return Json::success('修改成功!');
  103. }else{
  104. return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
  105. }
  106. }
  107. public function edit($id)
  108. {
  109. if (!$id) Json::fail('数据不存在');
  110. $data = [];
  111. if ($id > 0) $data = \app\admin\model\auction\Auction::find($id)->toArray();
  112. $this->assign(['id' => $id, 'dataList' => $data]);
  113. return $this->fetch();
  114. }
  115. public function get_auction($id)
  116. {
  117. if (!$id) Json::fail('数据不存在');
  118. $info = \app\admin\model\auction\Auction::find($id)->toArray();
  119. $data['productInfo'] = $info;
  120. return JsonService::successful($data);
  121. }
  122. public function update()
  123. {
  124. $data = Util::postMore([
  125. 'id',
  126. 'nickname',
  127. 'image',
  128. 'time',
  129. 'rtime',
  130. 'sort',
  131. 'info',
  132. 'anticipate'
  133. ]);
  134. $time = explode('-', $data['time']);
  135. $data['add_time'] = trim($time[0]);
  136. $data['end_time'] = trim($time[1]);
  137. $rtime = explode('-', $data['rtime']);
  138. $data['radd_time'] = trim($rtime[0]);
  139. $data['rend_time'] = trim($rtime[1]);
  140. if (strtotime($time[0]) > strtotime( $time[1])) Json::fail('预约时间选择错误');
  141. if (strtotime($time[0]) > strtotime( $time[1])) Json::fail('进场时间选择错误');
  142. $res = \app\admin\model\auction\Auction::update($data);
  143. if ($res){
  144. return Json::success('修改成功!');
  145. }else{
  146. return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
  147. }
  148. }
  149. // public function edit($id)
  150. // {
  151. // if (!$id) Json::fail('数据不存在');
  152. //
  153. //
  154. // $list = \app\admin\model\auction\Auction::get($id);
  155. // if (!$list) Json::fail('数据不存在');
  156. //
  157. // $f = array();
  158. // $f[] = Form::input('id', 'ID', $list->getData('id'))->disabled(1);
  159. // $f[] = Form::input('nickname', '名称', $list->getData('nickname'));
  160. // $f[] = Form::uploadImageOne('image', '图片','/index.php/admin/widget.images/upload',$list->getData('image'));
  161. // $f[] = Form::radio('is_promoter', '推广员',$list->getData('status'))->options([['value' => 1, 'label' => '启用'], ['value' => 0, 'label' => '禁用']]);
  162. // $f[] = Form::dateTime('time', '推广员',$list->getData('add_time'));
  163. //
  164. // $form = Form::make_post_form('添加用户通知', $f, Url::buildUrl('update', array('uid' => $id)), 5);
  165. // $this->assign(compact('form'));
  166. // return $this->fetch('public/form-builder');
  167. // }
  168. }