StoreCouponIssue.php 1.9 KB

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