Out.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494
  1. <<<<<<< HEAD
  2. <?php
  3. namespace app\admin\controller\user;
  4. use app\admin\controller\AuthController;
  5. use app\admin\controller\Union;
  6. use app\admin\model\order\StoreOrder;
  7. use app\admin\model\User;
  8. use crmeb\services\{ExpressService,
  9. FormBuilder,
  10. JsonService,
  11. MiniProgramService,
  12. upload\Upload,
  13. WechatService,
  14. FormBuilder as Form,
  15. CacheService,
  16. UtilService as Util,
  17. JsonService as Json
  18. };
  19. use app\admin\model\system\{SystemAdmin,
  20. SystemAttachment as SystemAttachmentModel,
  21. SystemAttachmentCategory as Category
  22. };
  23. use think\Db;
  24. use think\facade\Route as Url;
  25. use think\facade\Validate;
  26. use app\admin\model\user\Out as model;
  27. class Out extends AuthController
  28. {
  29. public function index()
  30. {
  31. $this->assign('admin', $this->adminInfo);
  32. return $this->fetch();
  33. }
  34. public function list()
  35. {
  36. $where = Util::getMore([
  37. ['status', ''],
  38. ['page', 1],
  39. ['limit', 20],
  40. ['auction'],
  41. ['uid'],
  42. ['null']
  43. ]);
  44. $data = model::list($where);
  45. return Json::successlayui($data);
  46. }
  47. /**
  48. * 显示创建资源表单页.
  49. *
  50. * @return \think\Response
  51. */
  52. public function create($id = 0)
  53. {
  54. $f = [];
  55. $f[] = Form::input('name', '名称')->col(12);
  56. $f[] = Form::textarea('info', '简介');
  57. $f[] = Form::number('number', '达标额度')->col(12);
  58. $f[] = Form::frameImages('pics', '轮播图', Url::buildUrl('admin/widget.images/index', array('fodder' => 'pics')))->maxLength(5)->icon('image')->width('100%')->height('500px');
  59. $f[] = Form::radio('status', '状态', 1)->options([['label' => '开启', 'value' => 1], ['label' => '关闭', 'value' => 0]]);
  60. $form = Form::make_post_form('添加', $f, Url::buildUrl('save'));
  61. $this->assign(compact('form'));
  62. return $this->fetch('public/form-builder');
  63. }
  64. public function save()
  65. {
  66. $mode = new model;
  67. $data = Util::postMore([
  68. 'name',
  69. 'info',
  70. 'number',
  71. 'status',
  72. ['pics', []]
  73. ]);
  74. $validate = Validate::rule('name', 'require')->rule([
  75. 'name' => 'require',
  76. 'number' => 'require',
  77. ]);
  78. $validate->message([
  79. 'name.require' => '名称不能为空',
  80. 'number.require' => '达标额度不能为空',
  81. ]);
  82. $data['pics'] = implode(',', $data['pics']);
  83. if (!$validate->check($data)) {
  84. return Json::fail($validate->getError());
  85. }
  86. $res = $mode->save($data);
  87. if ($res) {
  88. return Json::success('添加成功!');
  89. } else {
  90. return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
  91. }
  92. }
  93. /**
  94. * 删除
  95. * @param $id
  96. * @return void
  97. * @throws \Exception
  98. */
  99. public function delete($id)
  100. {
  101. if (!$id) Json::fail('删除失败');
  102. $model = new model;
  103. $res = $model->where('id', $id)->delete();
  104. if ($res) {
  105. return Json::success('删除成功!');
  106. } else {
  107. return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
  108. }
  109. }
  110. public function set_status($id, $status)
  111. {
  112. if (empty($id)) return Json::fail('修改失败');
  113. $res = model::update(['status' => $status, 'id' => $id]);
  114. if ($res) {
  115. return Json::success('修改成功!');
  116. } else {
  117. return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
  118. }
  119. }
  120. public function edit($id)
  121. {
  122. if (!$id) Json::fail('数据不存在');
  123. $data = model::find($id);
  124. $f = [];
  125. $f[] = Form::input('name', '名称', $data->getData('name'))->col(12);
  126. $f[] = Form::textarea('info', '介绍', $data->getData('info'));
  127. $f[] = Form::frameImages('pics', '轮播图', Url::buildUrl('admin/widget.images/index', array('fodder' => 'pics')), explode(',', $data->getData('pics')))->maxLength(5)->icon('image')->width('100%')->height('500px');
  128. $f[] = Form::number('number', '达标额度', $data->getData('number'))->col(12);
  129. $f[] = Form::radio('status', '状态', $data->getData('status'))->options([['label' => '开启', 'value' => 1], ['label' => '关闭', 'value' => 0]]);
  130. $form = Form::make_post_form('修改', $f, Url::buildUrl('update', compact('id')));
  131. $this->assign(compact('form'));
  132. return $this->fetch('public/form-builder');
  133. }
  134. public function update()
  135. {
  136. $data = Util::postMore([
  137. 'id',
  138. 'name',
  139. 'info',
  140. 'status',
  141. 'number',
  142. ['pics', []]
  143. ]);
  144. $validate = Validate::rule('name', 'require')->rule([
  145. 'name' => 'require',
  146. 'number' => 'require',
  147. ]);
  148. $validate->message([
  149. 'name.require' => '名称不能为空',
  150. 'number.require' => '达标数量不能为空',
  151. ]);
  152. $data['pics'] = implode(',', $data['pics']);
  153. if (!$validate->check($data)) {
  154. return Json::fail($validate->getError());
  155. }
  156. $res = model::update($data);
  157. if ($res) {
  158. return Json::success('修改成功!');
  159. } else {
  160. return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
  161. }
  162. }
  163. public function edit_content($id)
  164. {
  165. if (!$id) return $this->failed('数据不存在');
  166. $seckill = model::get($id);
  167. if (!$seckill) return Json::fail('数据不存在!');
  168. $this->assign([
  169. 'content' => htmlspecialchars_decode($seckill['content']),
  170. 'field' => 'content',
  171. 'action' => Url::buildUrl('change_field', ['id' => $id, 'field' => 'content'])
  172. ]);
  173. return $this->fetch('public/edit_content');
  174. }
  175. public function change_field($id)
  176. {
  177. if (!$id) return $this->failed('数据不存在');
  178. $seckill = model::get($id);
  179. if (!$seckill) return Json::fail('数据不存在!');
  180. $data['content'] = request()->post('content');
  181. $res = model::edit($data, $id);
  182. if ($res)
  183. return Json::successful('添加成功');
  184. else
  185. return Json::fail('添加失败');
  186. }
  187. /**
  188. * 显示创建资源表单页.
  189. *
  190. * @return \think\Response
  191. */
  192. public function user_push($uid = 0)
  193. {
  194. return $this->fetch();
  195. }
  196. public function user_push_list()
  197. {
  198. $where = Util::getMore([
  199. ['status', ''],
  200. ['page', 1],
  201. ['limit', 20],
  202. ['auction'],
  203. ['uid'],
  204. ['spread_uid']
  205. ]);
  206. $data = StoreOrder::list($where);
  207. return Json::successlayui($data);
  208. }
  209. =======
  210. <?php
  211. namespace app\admin\controller\user;
  212. use app\admin\controller\AuthController;
  213. use app\admin\controller\Union;
  214. use app\admin\model\order\StoreOrder;
  215. use app\admin\model\User;
  216. use crmeb\services\{ExpressService,
  217. FormBuilder,
  218. JsonService,
  219. MiniProgramService,
  220. upload\Upload,
  221. WechatService,
  222. FormBuilder as Form,
  223. CacheService,
  224. UtilService as Util,
  225. JsonService as Json
  226. };
  227. use app\admin\model\system\{SystemAdmin,
  228. SystemAttachment as SystemAttachmentModel,
  229. SystemAttachmentCategory as Category
  230. };
  231. use think\Db;
  232. use think\facade\Route as Url;
  233. use think\facade\Validate;
  234. use app\admin\model\user\Out as model;
  235. class Out extends AuthController
  236. {
  237. public function index()
  238. {
  239. $this->assign('admin', $this->adminInfo);
  240. return $this->fetch();
  241. }
  242. public function list()
  243. {
  244. $where = Util::getMore([
  245. ['status', ''],
  246. ['page', 1],
  247. ['limit', 20],
  248. ['auction'],
  249. ['uid'],
  250. ['null']
  251. ]);
  252. $data = model::list($where);
  253. return Json::successlayui($data);
  254. }
  255. /**
  256. * 显示创建资源表单页.
  257. *
  258. * @return \think\Response
  259. */
  260. public function create($id = 0)
  261. {
  262. $f = [];
  263. $f[] = Form::input('name', '名称')->col(12);
  264. $f[] = Form::textarea('info', '简介');
  265. $f[] = Form::number('number', '达标额度')->col(12);
  266. $f[] = Form::frameImages('pics', '轮播图', Url::buildUrl('admin/widget.images/index', array('fodder' => 'pics')))->maxLength(5)->icon('image')->width('100%')->height('500px');
  267. $f[] = Form::radio('status', '状态', 1)->options([['label' => '开启', 'value' => 1], ['label' => '关闭', 'value' => 0]]);
  268. $form = Form::make_post_form('添加', $f, Url::buildUrl('save'));
  269. $this->assign(compact('form'));
  270. return $this->fetch('public/form-builder');
  271. }
  272. public function save()
  273. {
  274. $mode = new model;
  275. $data = Util::postMore([
  276. 'name',
  277. 'info',
  278. 'number',
  279. 'status',
  280. ['pics', []]
  281. ]);
  282. $validate = Validate::rule('name', 'require')->rule([
  283. 'name' => 'require',
  284. 'number' => 'require',
  285. ]);
  286. $validate->message([
  287. 'name.require' => '名称不能为空',
  288. 'number.require' => '达标额度不能为空',
  289. ]);
  290. $data['pics'] = implode(',', $data['pics']);
  291. if (!$validate->check($data)) {
  292. return Json::fail($validate->getError());
  293. }
  294. $res = $mode->save($data);
  295. if ($res) {
  296. return Json::success('添加成功!');
  297. } else {
  298. return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
  299. }
  300. }
  301. /**
  302. * 删除
  303. * @param $id
  304. * @return void
  305. * @throws \Exception
  306. */
  307. public function delete($id)
  308. {
  309. if (!$id) Json::fail('删除失败');
  310. $model = new model;
  311. $res = $model->where('id', $id)->delete();
  312. if ($res) {
  313. return Json::success('删除成功!');
  314. } else {
  315. return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
  316. }
  317. }
  318. public function set_status($id, $status)
  319. {
  320. if (empty($id)) return Json::fail('修改失败');
  321. $res = model::update(['status' => $status, 'id' => $id]);
  322. if ($res) {
  323. return Json::success('修改成功!');
  324. } else {
  325. return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
  326. }
  327. }
  328. public function edit($id)
  329. {
  330. if (!$id) Json::fail('数据不存在');
  331. $data = model::find($id);
  332. $f = [];
  333. $f[] = Form::input('name', '名称', $data->getData('name'))->col(12);
  334. $f[] = Form::textarea('info', '介绍', $data->getData('info'));
  335. $f[] = Form::frameImages('pics', '轮播图', Url::buildUrl('admin/widget.images/index', array('fodder' => 'pics')), explode(',', $data->getData('pics')))->maxLength(5)->icon('image')->width('100%')->height('500px');
  336. $f[] = Form::number('number', '达标额度', $data->getData('number'))->col(12);
  337. $f[] = Form::radio('status', '状态', $data->getData('status'))->options([['label' => '开启', 'value' => 1], ['label' => '关闭', 'value' => 0]]);
  338. $form = Form::make_post_form('修改', $f, Url::buildUrl('update', compact('id')));
  339. $this->assign(compact('form'));
  340. return $this->fetch('public/form-builder');
  341. }
  342. public function update()
  343. {
  344. $data = Util::postMore([
  345. 'id',
  346. 'name',
  347. 'info',
  348. 'status',
  349. 'number',
  350. ['pics', []]
  351. ]);
  352. $validate = Validate::rule('name', 'require')->rule([
  353. 'name' => 'require',
  354. 'number' => 'require',
  355. ]);
  356. $validate->message([
  357. 'name.require' => '名称不能为空',
  358. 'number.require' => '达标数量不能为空',
  359. ]);
  360. $data['pics'] = implode(',', $data['pics']);
  361. if (!$validate->check($data)) {
  362. return Json::fail($validate->getError());
  363. }
  364. $res = model::update($data);
  365. if ($res) {
  366. return Json::success('修改成功!');
  367. } else {
  368. return Json::fail(\app\admin\model\auction\Auction::getErrorInfo());
  369. }
  370. }
  371. public function edit_content($id)
  372. {
  373. if (!$id) return $this->failed('数据不存在');
  374. $seckill = model::get($id);
  375. if (!$seckill) return Json::fail('数据不存在!');
  376. $this->assign([
  377. 'content' => htmlspecialchars_decode($seckill['content']),
  378. 'field' => 'content',
  379. 'action' => Url::buildUrl('change_field', ['id' => $id, 'field' => 'content'])
  380. ]);
  381. return $this->fetch('public/edit_content');
  382. }
  383. public function change_field($id)
  384. {
  385. if (!$id) return $this->failed('数据不存在');
  386. $seckill = model::get($id);
  387. if (!$seckill) return Json::fail('数据不存在!');
  388. $data['content'] = request()->post('content');
  389. $res = model::edit($data, $id);
  390. if ($res)
  391. return Json::successful('添加成功');
  392. else
  393. return Json::fail('添加失败');
  394. }
  395. /**
  396. * 显示创建资源表单页.
  397. *
  398. * @return \think\Response
  399. */
  400. public function user_push($uid = 0)
  401. {
  402. return $this->fetch();
  403. }
  404. public function user_push_list()
  405. {
  406. $where = Util::getMore([
  407. ['status', ''],
  408. ['page', 1],
  409. ['limit', 20],
  410. ['auction'],
  411. ['uid'],
  412. ['spread_uid']
  413. ]);
  414. $data = StoreOrder::list($where);
  415. return Json::successlayui($data);
  416. }
  417. >>>>>>> 386b37d33e5ba817cba00df29efaefbd692e4dd1
  418. }