AuctionProducts.php 5.5 KB

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