StoreCouponIssue.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. *
  4. * @author: xaboy<365615158@qq.com>
  5. * @day: 2018/01/17
  6. */
  7. namespace app\admin\controller\ump;
  8. use app\admin\controller\AuthController;
  9. use think\facade\Route as Url;
  10. use crmeb\traits\CurdControllerTrait;
  11. use crmeb\services\{JsonService, FormBuilder as Form, UtilService as Util};
  12. use app\admin\model\ump\{StoreCouponIssue as CouponIssueModel, StoreCouponIssueUser};
  13. class StoreCouponIssue extends AuthController
  14. {
  15. use CurdControllerTrait;
  16. protected $bindModel = CouponIssueModel::class;
  17. public function index()
  18. {
  19. $where = Util::getMore([
  20. ['status', ''],
  21. ['coupon_title', ''],
  22. ['type','']
  23. ]);
  24. $this->assign(CouponIssueModel::stsypage($where));
  25. $this->assign('where', $where);
  26. return $this->fetch();
  27. }
  28. public function delete($id = '')
  29. {
  30. if (!$id) return JsonService::fail('参数有误!');
  31. if (CouponIssueModel::edit(['is_del' => 1], $id, 'id'))
  32. return JsonService::successful('删除成功!');
  33. else
  34. return JsonService::fail('删除失败!');
  35. }
  36. public function edit($id = '')
  37. {
  38. if (!$id) return JsonService::fail('参数有误!');
  39. $issueInfo = CouponIssueModel::get($id);
  40. if (-1 == $issueInfo['status'] || 1 == $issueInfo['is_del']) return $this->failed('状态错误,无法修改');
  41. $f = [Form::radio('status', '是否开启', $issueInfo['status'])->options([['label' => '开启', 'value' => 1], ['label' => '关闭', 'value' => 0]])];
  42. $form = Form::make_post_form('状态修改', $f, Url::buildUrl('change_field', array('id' => $id, 'field' => 'status')));
  43. $this->assign(compact('form'));
  44. return $this->fetch('public/form-builder');
  45. }
  46. public function issue_log($id = '')
  47. {
  48. if (!$id) return JsonService::fail('参数有误!');
  49. $this->assign(StoreCouponIssueUser::systemCouponIssuePage($id));
  50. return $this->fetch();
  51. }
  52. }