AuctionProduct.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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 AuctionProduct extends AuthController
  25. {
  26. public function index()
  27. {
  28. $list = \app\admin\model\auction\Auction::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. 'deduct',
  71. 'rise',
  72. 'info',
  73. 'sort',
  74. 'auction_id',
  75. 'hanging_price'
  76. ]);
  77. $model = new model();
  78. $res = $model->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. $res = model::where('id', $id)->useSoftDelete('delete_time',time())->delete();
  95. if ($res){
  96. return Json::success('删除成功!');
  97. }else{
  98. return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
  99. }
  100. }
  101. public function set_status($id, $status)
  102. {
  103. if (empty($id)) Json::fail('修改失败');
  104. $res = model::update(['is_show' => $status, 'id' => $id]);
  105. if ($res){
  106. return Json::success('修改成功!');
  107. }else{
  108. return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
  109. }
  110. }
  111. public function edit($id)
  112. {
  113. if (!$id) Json::fail('数据不存在');
  114. $data = \app\admin\model\auction\Auction::select()->toArray();
  115. $this->assign(['id' => $id, 'list' => $data]);
  116. return $this->fetch();
  117. }
  118. public function get_list($id)
  119. {
  120. if (!$id) Json::fail('数据不存在');
  121. $model = new model();
  122. $info = $model->find($id);
  123. return JsonService::successful($info);
  124. }
  125. public function update($id)
  126. {
  127. $data = Util::postMore([
  128. 'id',
  129. 'name',
  130. 'is_show',
  131. 'image',
  132. 'price',
  133. 'deduct',
  134. 'rise',
  135. 'info',
  136. 'sort',
  137. 'auction_id',
  138. 'hanging_price'
  139. ]);
  140. $res = model::update($data);
  141. if ($res){
  142. return Json::success('修改成功!');
  143. }else{
  144. return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
  145. }
  146. }
  147. // public function edit($id)
  148. // {
  149. // if (!$id) Json::fail('数据不存在');
  150. //
  151. //
  152. // $list = \app\admin\model\auction\Auction::get($id);
  153. // if (!$list) Json::fail('数据不存在');
  154. //
  155. // $f = array();
  156. // $f[] = Form::input('id', 'ID', $list->getData('id'))->disabled(1);
  157. // $f[] = Form::input('nickname', '名称', $list->getData('nickname'));
  158. // $f[] = Form::uploadImageOne('image', '图片','/index.php/admin/widget.images/upload',$list->getData('image'));
  159. // $f[] = Form::radio('is_promoter', '推广员',$list->getData('status'))->options([['value' => 1, 'label' => '启用'], ['value' => 0, 'label' => '禁用']]);
  160. // $f[] = Form::dateTime('time', '推广员',$list->getData('add_time'));
  161. //
  162. // $form = Form::make_post_form('添加用户通知', $f, Url::buildUrl('update', array('uid' => $id)), 5);
  163. // $this->assign(compact('form'));
  164. // return $this->fetch('public/form-builder');
  165. // }
  166. }