BestKnowledge.php 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkAdmin
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2022 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: https://thinkadmin.top
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // | 免费声明 ( https://thinkadmin.top/disclaimer )
  11. // +----------------------------------------------------------------------
  12. // | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
  13. // | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
  14. // +----------------------------------------------------------------------
  15. namespace app\admin\controller;
  16. use app\data\model\DataBestKnowledge;
  17. use app\data\model\DataClassification;
  18. use app\data\model\DataPoolTalent;
  19. use app\data\model\DataUser;
  20. use app\data\model\DataZhicheng;
  21. use Carbon\Carbon;
  22. use think\admin\Controller;
  23. use app\data\model\SystemUser;
  24. use think\db\Query;
  25. /**
  26. * 百知文库管理
  27. * Class BestKnowledge
  28. * @package app\admin\controller
  29. */
  30. class BestKnowledge extends Controller
  31. {
  32. /**
  33. * 分类管理
  34. * @auth true
  35. * @menu true
  36. */
  37. public function class(){
  38. $this->title='分类管理';
  39. DataClassification::mQuery()
  40. ->show(1)
  41. ->like('name')
  42. ->order('id','desc')
  43. ->layTable();
  44. }
  45. /**
  46. * 分类编辑
  47. * @auth true
  48. * @menu true
  49. */
  50. public function class_edit($id){
  51. if($this->request->isPost()){
  52. if (DataClassification::mk()->where('id',$this->request->post('id'))->update(['name'=>$this->request->post('name'),'update_at'=>$this->request->post('update_at')])){
  53. $this->success('保存成功');
  54. }
  55. $this->error('失败');
  56. }else{
  57. $row=DataClassification::mk()->findOrFail($id);
  58. $this->assign('row',$row);
  59. $this->fetch('class_form');
  60. }
  61. }
  62. /**
  63. * 分类添加
  64. * @auth true
  65. * @menu true
  66. */
  67. public function class_add(){
  68. if($this->request->isPost()){
  69. if (DataClassification::mk()->insert(['name'=>$this->request->post('name')])){
  70. $this->success('保存成功');
  71. }
  72. $this->error('失败');
  73. }
  74. DataClassification::mForm('class_form');
  75. }
  76. /**
  77. * 分类删除
  78. * @auth true
  79. * @menu true
  80. */
  81. public function class_del($id){
  82. DataClassification::whereIn('id',$id)->save([
  83. 'is_del'=>0,
  84. ]);
  85. $this->success('删除成功');
  86. }
  87. /**
  88. * 百知文库申请管理
  89. * @auth true
  90. * @menu true
  91. */
  92. public function index(){
  93. $this->title='百知文库申请列表';
  94. $name=input('name');
  95. DataBestKnowledge::mQuery()
  96. ->when($name,function (Query $query) use ($name) {
  97. $query->hasWhere('user',function (Query $query) use ($name) {
  98. $query->whereLike('nickname',"%{$name}%");
  99. });
  100. })
  101. ->with(['user','classTo'])
  102. ->where('type',2)
  103. ->where('is_del',1)
  104. ->order('id','desc')
  105. ->layTable();
  106. }
  107. /**
  108. * 百知文库申请审核
  109. * @auth true
  110. * @menu true
  111. */
  112. public function audit($id){
  113. $this->title='百知文库申请审核';
  114. $row=DataBestKnowledge::mk()->findOrFail($id);
  115. // dump($row);
  116. if($this->request->isGet()){
  117. $this->assign('row',$row);
  118. $this->fetch();
  119. }else{
  120. if($row['audit']>1){
  121. $this->error('该记录已审核');
  122. }
  123. $data=$this->_vali([
  124. 'audit.require'=>'结果必须',
  125. 'audit.in:2,3'=>'结果有误',
  126. 'why.requireIf:audit,3'=>'原因必须',
  127. 'why.max:200'=>'原因有误',
  128. ]);
  129. $row['audit']=$data['audit'];
  130. $row['why']=$data['why']??'';
  131. $row['audit_at']=Carbon::now();
  132. $row->save();
  133. if ($data['audit']==2){
  134. if ($row['amount']>0){
  135. //用户加钱
  136. userMoneyChange($row['amount'],1,$row['uuid'],'百知文库通过',1,$row['id']);
  137. }
  138. }
  139. $this->success('审核成功');
  140. }
  141. }
  142. /**
  143. * 百知文库申请管理
  144. * @auth true
  145. * @menu true
  146. */
  147. public function index2(){
  148. $this->title='百知文库列表';
  149. $name=input('name');
  150. DataBestKnowledge::mQuery()
  151. ->when($name,function (Query $query) use ($name) {
  152. $query->hasWhere('user',function (Query $query) use ($name) {
  153. $query->whereLike('nickname',"%{$name}%");
  154. });
  155. })
  156. ->with(['user','classTo'])
  157. ->where('type',1)
  158. ->where('is_del',1)
  159. ->order('id','desc')
  160. ->layTable();
  161. }
  162. /**
  163. * 百知文库添加
  164. * @auth true
  165. * @menu true
  166. */
  167. public function add(){
  168. $this->assign('category',DataClassification::show(1)->select());
  169. DataBestKnowledge::mForm('form');
  170. }
  171. /**
  172. * 百知文库编辑
  173. * @auth true
  174. * @menu true
  175. */
  176. public function edit(){
  177. $this->assign('category',DataClassification::show(1)->select());
  178. DataBestKnowledge::mForm('form');
  179. }
  180. public function _form_filter($vo){
  181. if ($this->request->isGet()) {
  182. if (isset($vo['id'])){
  183. if (isset($vo['imgs'])){
  184. //$vo['imgs']= implode('|',explode(',',implode(',',$vo['imgs'])));
  185. }
  186. $this->assign('vo',$vo);
  187. $this->fetch('form');
  188. }
  189. }elseif ($this->request->isPost()){
  190. $vo['imgs'] = implode(',',explode('|',$vo['imgs']));
  191. $vo['audit'] =2;
  192. unset($vo['user']);
  193. isset($vo['id']) ? DataBestKnowledge::mk()->where('id',$vo['id'])->update($vo) : DataBestKnowledge::mk()->insert($vo);
  194. $this->success('数据更新成功');
  195. }
  196. }
  197. /**
  198. * 删除
  199. * @auth true
  200. * @menu true
  201. */
  202. public function del($id){
  203. DataBestKnowledge::whereIn('id',$id)->save([
  204. 'is_del'=>0,
  205. ]);
  206. $this->success('删除成功');
  207. }
  208. }