AuctionProducts.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  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 app\admin\model\auction\AuctionProduct as model;
  18. use think\facade\Route as Url;
  19. /**
  20. * 竞拍管理
  21. * Class StoreOrder
  22. * @package app\admin\controller\store
  23. */
  24. class AuctionProducts extends AuthController
  25. {
  26. public function index()
  27. {
  28. $list = \app\admin\model\auction\Auction::order('id DESC')->select();
  29. $this->assign('auction', $list);
  30. return $this->fetch();
  31. }
  32. public function list()
  33. {
  34. $where = Util::getMore([
  35. ['is_show', ''],
  36. ['page', 1],
  37. ['limit', 20],
  38. ['auction_id', ''],
  39. ['store_name', '']
  40. ]);
  41. $data = model::list($where);
  42. foreach ($data['data'] as $key => $val){
  43. if ($data['data'][$key]['uid'] == 0) $data['data'][$key]['nickname'] = '管理';
  44. $data['data'][$key]['gs_time'] = date('Y-m-d H:i:s', $val['gs_time']);
  45. }
  46. return Json::successlayui($data);
  47. }
  48. public function auction_list()
  49. {
  50. $list = model::select()->toArray();
  51. Json::successful($list);
  52. }
  53. /**
  54. * 显示创建资源表单页.
  55. *
  56. * @return \think\Response
  57. */
  58. public function create($id = 0)
  59. {
  60. $data = \app\admin\model\auction\Auction::select()->toArray();
  61. $this->assign(['id' => $id, 'list' => $data]);
  62. return $this->fetch();
  63. }
  64. public function save($id)
  65. {
  66. $data = Util::postMore([
  67. 'name',
  68. 'is_show',
  69. 'image',
  70. 'price',
  71. 'info',
  72. 'sort',
  73. 'auction_id',
  74. 'hanging_price',
  75. 'slider_image',
  76. 'description'
  77. ]);
  78. $data['slider_image'] = json_encode($data['slider_image']);
  79. $data['description'] = htmlspecialchars($data['description']);
  80. $model = new model();
  81. $res = $model->save($data);
  82. if ($res){
  83. return Json::success('添加成功!');
  84. }else{
  85. return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
  86. }
  87. }
  88. /**
  89. * 删除
  90. * @param $id
  91. * @return void
  92. * @throws \Exception
  93. */
  94. public function delete($id)
  95. {
  96. if (!$id)return Json::fail('删除失败');
  97. $res = model::where('id', $id)->delete();
  98. if ($res){
  99. return Json::success('删除成功!');
  100. }else{
  101. return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
  102. }
  103. }
  104. public function set_status($id, $status)
  105. {
  106. if (empty($id))return Json::fail('修改失败');
  107. $res = model::update(['is_show' => $status, 'id' => $id]);
  108. if ($res){
  109. return Json::success('修改成功!');
  110. }else{
  111. return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
  112. }
  113. }
  114. public function edit($id)
  115. {
  116. if (!$id) Json::fail('数据不存在');
  117. $data = \app\admin\model\auction\Auction::select()->toArray();
  118. $this->assign(['id' => $id, 'list' => $data]);
  119. return $this->fetch();
  120. }
  121. public function get_list($id)
  122. {
  123. if (!$id) Json::fail('数据不存在');
  124. $model = new model();
  125. $info = $model->find($id);
  126. $info['slider_image'] = is_string($info['slider_image']) ? json_decode($info['slider_image'], true) : [];
  127. $info['description'] = htmlspecialchars_decode($info['description']);
  128. $data['productInfo'] = $info;
  129. return JsonService::successful($data);
  130. }
  131. public function update($id)
  132. {
  133. $data = Util::postMore([
  134. 'id',
  135. 'name',
  136. 'image',
  137. 'price',
  138. 'info',
  139. 'sort',
  140. 'auction_id',
  141. 'hanging_price',
  142. 'slider_image',
  143. 'description'
  144. ]);
  145. $data['slider_image'] = json_encode($data['slider_image']);
  146. $data['description'] = htmlspecialchars($data['description']);
  147. $res = model::update($data);
  148. if ($res){
  149. return Json::success('修改成功!');
  150. }else{
  151. return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
  152. }
  153. }
  154. // public function edit($id)
  155. // {
  156. // if (!$id) Json::fail('数据不存在');
  157. //
  158. //
  159. // $list = \app\admin\model\auction\Auction::get($id);
  160. // if (!$list) Json::fail('数据不存在');
  161. //
  162. // $f = array();
  163. // $f[] = Form::input('id', 'ID', $list->getData('id'))->disabled(1);
  164. // $f[] = Form::input('nickname', '名称', $list->getData('nickname'));
  165. // $f[] = Form::uploadImageOne('image', '图片','/index.php/admin/widget.images/upload',$list->getData('image'));
  166. // $f[] = Form::radio('is_promoter', '推广员',$list->getData('status'))->options([['value' => 1, 'label' => '启用'], ['value' => 0, 'label' => '禁用']]);
  167. // $f[] = Form::dateTime('time', '推广员',$list->getData('add_time'));
  168. //
  169. // $form = Form::make_post_form('添加用户通知', $f, Url::buildUrl('update', array('uid' => $id)), 5);
  170. // $this->assign(compact('form'));
  171. // return $this->fetch('public/form-builder');
  172. // }
  173. }