TrainingController.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. <?php
  2. namespace app\workerapi\controller;
  3. use app\adminapi\logic\goods_category\GoodsCategoryLogic;
  4. use app\common\logic\MasterWorkerExamineLogic;
  5. use app\common\model\dict\DictData;
  6. use app\workerapi\lists\MasterWorkerLists;
  7. use app\workerapi\lists\ServiceWorkLists;
  8. use app\workerapi\lists\TeamServiceWorkLists;
  9. use app\workerapi\lists\TrainingCourseLists;
  10. use app\workerapi\logic\LoginLogic;
  11. use app\workerapi\logic\MasterWorkerInfoLogic;
  12. use app\workerapi\logic\MasterWorkerLogic;
  13. use app\workerapi\logic\MasterWorkerTeamLogic;
  14. use app\workerapi\logic\TenantAgreeLogic;
  15. use app\workerapi\logic\TrainingLogic;
  16. use app\workerapi\validate\BankAccountValidate;
  17. use app\workerapi\validate\MasterWokerInfoValidate;
  18. use app\workerapi\validate\MasterWokerTeamValidate;
  19. use app\workerapi\validate\MasterWokerValidate;
  20. use app\workerapi\validate\MasterWorkerAgreeValidate;
  21. class TrainingController extends BaseApiController
  22. {
  23. /**
  24. * 获取培训信息
  25. * @return \think\response\Json
  26. */
  27. public function getTrainingInfo()
  28. {
  29. $result = TrainingLogic::getDetail($this->userId);
  30. return $this->data($result);
  31. }
  32. /**
  33. * 获取免费的课程列表
  34. * @return \think\response\Json
  35. */
  36. public function getFreeCourseList()
  37. {
  38. return $this->dataLists(new TrainingCourseLists());
  39. }
  40. /**
  41. * 获取工程师的课程列表
  42. * @return \think\response\Json
  43. */
  44. public function getCourseList()
  45. {
  46. $params = request()->get();
  47. return $this->data(TrainingLogic::getCourseList($this->userId,$params));
  48. }
  49. /**
  50. * 获取工程师的课程详情
  51. * @return \think\response\Json
  52. */
  53. public function getCourseDetail()
  54. {
  55. $params = request()->get();
  56. return $this->data(TrainingLogic::getCourseDetail($this->userId,$params));
  57. }
  58. /**
  59. * 修改学习视频记录状态
  60. * @return \think\response\Json
  61. */
  62. public function upWorkerVideoCourse()
  63. {
  64. $params = request()->post();
  65. $result = TrainingLogic::upWorkerCourse($params);
  66. if($result === false){
  67. return $this->fail(TrainingLogic::getError());
  68. }
  69. return $this->success('', [], 1, 1);
  70. }
  71. /**
  72. * 获取考试列表(即开始考试)
  73. * @return \think\response\Json
  74. */
  75. public function getQuestionList()
  76. {
  77. try {
  78. $params = request()->get();
  79. $params['user_id'] = $this->userId;
  80. $params['user_info'] = $this->userInfo;
  81. $result = TrainingLogic::getQuestionList($params);
  82. return $this->data($result);
  83. } catch (\Exception $e) {
  84. return $this->fail($e->getMessage());
  85. }
  86. }
  87. /**
  88. * 提交考试(即结束考试)
  89. * @return \think\response\Json
  90. */
  91. public function submitExam()
  92. {
  93. $params = request()->post();
  94. $result = TrainingLogic::submitExam($params);
  95. if($result === false){
  96. return $this->fail(TrainingLogic::getError());
  97. }
  98. return $this->success('', [], 1, 1);
  99. }
  100. /**
  101. * 考试结果统计
  102. * @return \think\response\Json
  103. */
  104. public function examStatistics()
  105. {
  106. $params = request()->get();
  107. $result = TrainingLogic::examStatistics($params);
  108. return $this->data($result);
  109. }
  110. /**
  111. * 获取团队协议详情
  112. * @return \think\response\Json
  113. */
  114. public function agreement_detail()
  115. {
  116. $result = TenantAgreeLogic::getAgreeByType('tenant_cooperate',$this->userId);
  117. return $this->data($result);
  118. }
  119. /**
  120. * 签署团队协议
  121. * @return \think\response\Json
  122. */
  123. public function agreeSign()
  124. {
  125. $params = (new MasterWorkerAgreeValidate())->post()->goCheck('sign', [
  126. 'user_id' => $this->userId,
  127. 'user_info' => $this->userInfo
  128. ]);
  129. $result = TenantAgreeLogic::sign($params);
  130. if (false === $result) {
  131. return $this->fail(TenantAgreeLogic::getError());
  132. }
  133. return $this->success('签名成功', [], 1, 1);
  134. }
  135. /**
  136. * 获取所有分类
  137. * @return \think\response\Json
  138. */
  139. public function getCategory()
  140. {
  141. $result = GoodsCategoryLogic::getTreeData();
  142. return $this->data($result);
  143. }
  144. /**
  145. * 提交三级ID分类
  146. * @return \think\response\Json
  147. */
  148. public function submitCategory()
  149. {
  150. $params = request()->post();
  151. $params['user_id'] = $this->userId;
  152. $params['user_info'] = $this->userInfo;
  153. $result = TrainingLogic::submitCategory($params);
  154. if($result === false){
  155. return $this->fail(TrainingLogic::getError());
  156. }
  157. return $this->success('', [], 1, 1);
  158. }
  159. /**
  160. * 获取类目分类
  161. * @return \think\response\Json
  162. */
  163. public function getTrainingCategory()
  164. {
  165. $params = request()->get();
  166. $params['user_id'] = $this->userId;
  167. $params['user_info'] = $this->userInfo;
  168. $result = TrainingLogic::getTrainingCategory($params);
  169. return $this->data($result);
  170. }
  171. /**
  172. * 获取某类目课程列表任务ID
  173. * @return \think\response\Json
  174. */
  175. public function getCategoryTaskId()
  176. {
  177. $params = request()->get();
  178. $params['user_id'] = $this->userId;
  179. $params['user_info'] = $this->userInfo;
  180. $result = TrainingLogic::getCategoryCourse($params);
  181. if($result === false){
  182. return $this->fail(TrainingLogic::getError());
  183. }
  184. return $this->success('', ['training_task_id'=>$result], 1, 1);
  185. }
  186. }