Auction.php 5.9 KB

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