Priceadjust.php 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. <?php
  2. declare(strict_types=1);
  3. namespace app\finance\controller;
  4. use app\base\BaseController;
  5. use app\finance\model\PriceAdjust as PriceAdjustModel;
  6. use app\finance\model\PriceAdjustCate;
  7. use app\finance\validate\PriceAdjustValidate;
  8. use think\exception\ValidateException;
  9. use think\facade\Db;
  10. use think\facade\View;
  11. class Priceadjust extends BaseController
  12. {
  13. protected $model;
  14. public function __construct()
  15. {
  16. parent::__construct();
  17. $this->model = new PriceAdjustModel();
  18. }
  19. public function datalist()
  20. {
  21. $param = get_params();
  22. if (request()->isAjax()) {
  23. $uid = $this->uid;
  24. $where = [];
  25. $whereOr = [];
  26. $where[] = ['delete_time', '=', 0];
  27. $tab = isset($param['tab']) ? (int) $param['tab'] : 0;
  28. if ($tab === 0) {
  29. $whereOr[] = ['admin_id', '=', $uid];
  30. $whereOr[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',check_uids)")];
  31. $whereOr[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',check_history_uids)")];
  32. $whereOr[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',check_copy_uids)")];
  33. } elseif ($tab === 1) {
  34. $where[] = ['admin_id', '=', $uid];
  35. } elseif ($tab === 2) {
  36. $where[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',check_uids)")];
  37. } elseif ($tab === 3) {
  38. $where[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',check_history_uids)")];
  39. } elseif ($tab === 4) {
  40. $where[] = ['', 'exp', Db::raw("FIND_IN_SET('{$uid}',check_copy_uids)")];
  41. }
  42. if (!empty($param['keywords'])) {
  43. $where[] = ['customer_id', 'like', '%' . $param['keywords'] . '%'];
  44. }
  45. if (isset($param['check_status']) && $param['check_status'] !== '') {
  46. $where[] = ['check_status', '=', $param['check_status']];
  47. }
  48. if (!empty($param['diff_time'])) {
  49. $diff = explode('~', $param['diff_time']);
  50. $where[] = ['create_time', 'between', [strtotime(urldecode($diff[0])), strtotime(urldecode($diff[1] . ' 23:59:59'))]];
  51. }
  52. $list = $this->model->datalist($param, $where, $whereOr);
  53. return table_assign(0, '', $list);
  54. }
  55. return view();
  56. }
  57. public function add()
  58. {
  59. $param = get_params();
  60. if (request()->isAjax()) {
  61. if (!empty($param['id']) && $param['id'] > 0) {
  62. try {
  63. validate(PriceAdjustValidate::class)->scene('edit')->check($param);
  64. } catch (ValidateException $e) {
  65. return to_assign(1, $e->getError());
  66. }
  67. $this->model->edit($param);
  68. } else {
  69. try {
  70. validate(PriceAdjustValidate::class)->scene('add')->check($param);
  71. } catch (ValidateException $e) {
  72. return to_assign(1, $e->getError());
  73. }
  74. $param['admin_id'] = $this->uid;
  75. $param['did'] = $this->did;
  76. $this->model->add($param);
  77. }
  78. } else {
  79. $id = isset($param['id']) ? (int) $param['id'] : 0;
  80. $detail = [
  81. 'id' => 0,
  82. 'customer_id' => '',
  83. 'history_fee_deduct' => 1,
  84. 'trade_scene' => 0,
  85. 'trade_scene_remark' => '',
  86. 'card_bin' => 0,
  87. 'card_bin_remark' => '',
  88. 'card_type' => 0,
  89. 'fee_recharge' => '',
  90. 'fee_card_open' => '',
  91. 'fee_other' => '',
  92. 'monthly_trade_vol' => '',
  93. 'estimated_trade_vol' => '',
  94. 'competitor_info' => '',
  95. 'remark' => '',
  96. 'file_ids' => '',
  97. 'check_status' => 0,
  98. 'check_flow_id' => 0,
  99. ];
  100. if ($id > 0) {
  101. $detail = $this->model->getById($id);
  102. }
  103. View::assign('detail', $detail);
  104. View::assign('trade_scenes', PriceAdjustCate::getByType(1));
  105. View::assign('card_bins', PriceAdjustCate::getByType(2));
  106. View::assign('card_types', PriceAdjustCate::getByType(3));
  107. return view();
  108. }
  109. }
  110. public function view($id)
  111. {
  112. $detail = $this->model->getById($id);
  113. if (!empty($detail)) {
  114. View::assign('create_user', get_admin($detail['admin_id']));
  115. View::assign('detail', $detail);
  116. return view();
  117. }
  118. return view(EEEOR_REPORTING, ['code' => 404, 'warning' => '找不到页面']);
  119. }
  120. public function del()
  121. {
  122. // 删除功能暂未开放,已禁用
  123. return to_assign(1, '删除功能暂未开放');
  124. /*
  125. $param = get_params();
  126. $id = isset($param['id']) ? (int) $param['id'] : 0;
  127. if (request()->isDelete()) {
  128. return $this->model->delById($id);
  129. }
  130. return to_assign(1, '错误的请求');
  131. */
  132. }
  133. }