UserController.java 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. package com.ym.mec.collectfee.controller;
  2. import com.ym.mec.collectfee.common.web.BaseController;
  3. import com.ym.mec.collectfee.entity.ApplyInfo;
  4. import com.ym.mec.collectfee.entity.MusicTeamsPageInfo;
  5. import com.ym.mec.collectfee.entity.School;
  6. import com.ym.mec.collectfee.entity.StudentsQueryInfo;
  7. import com.ym.mec.collectfee.service.ApplyInfoService;
  8. import com.ym.mec.collectfee.service.CourseGroupInfoService;
  9. import com.ym.mec.collectfee.service.OrderService;
  10. import com.ym.mec.collectfee.service.SchoolService;
  11. import com.ym.mec.collectfee.utils.Constants;
  12. import org.apache.commons.lang3.StringUtils;
  13. import org.springframework.beans.factory.annotation.Autowired;
  14. import org.springframework.dao.DuplicateKeyException;
  15. import org.springframework.web.bind.annotation.*;
  16. import java.util.Date;
  17. @RestController()
  18. @RequestMapping("user")
  19. //@Api("用户服务")
  20. public class UserController extends BaseController {
  21. @Autowired
  22. private ApplyInfoService applyInfoService;
  23. @Autowired
  24. private SchoolService schoolService;
  25. @Autowired
  26. private OrderService orderService;
  27. @Autowired
  28. private CourseGroupInfoService courseGroupInfoService;
  29. /**
  30. * 查询用户详情
  31. * @param phone
  32. * @param clazzId
  33. * @return
  34. */
  35. @GetMapping("/getUserDetailByPhone")
  36. // @ApiOperation(value = "根据乐团编号、用户手机,查询用户详情")
  37. // @ApiImplicitParams({ @ApiImplicitParam(name = "phone", value = "用户手机", required = true, dataType = "String"),
  38. // @ApiImplicitParam(name = "clazzId", value = "乐团编号", required = true, dataType = "Integer")})
  39. public Object getUserDetailByPhone(String phone,Integer clazzId,Integer cityId){
  40. if(StringUtils.isEmpty(phone) || clazzId == null || cityId == null){
  41. return failed(Constants.PARAM_VERIFY_ERROR_MSG);
  42. }
  43. ApplyInfo userByPhone = applyInfoService.findUserByPhone(phone, null);
  44. if(userByPhone == null && applyInfoService.mecUserIsExist(phone)){
  45. return failed(Constants.PARAM_EXIST_ERROR_MSG);
  46. }
  47. if(userByPhone != null && !userByPhone.getClassId().equals(clazzId)){//如果改用户存在其他团中
  48. return failed(Constants.PARAM_EXIST_ERROR_MSG);
  49. }
  50. School school = schoolService.get(clazzId);
  51. if(school != null){
  52. if(school.getCityId() == null){
  53. school.setCityId(cityId);
  54. school.setUpdateTime(new Date());
  55. schoolService.update(school);
  56. }
  57. if(userByPhone != null){
  58. userByPhone.setPushStatus(school.getStatus());
  59. }
  60. }
  61. return succeed(userByPhone);
  62. }
  63. /**
  64. * 用户报名
  65. * @param applyInfo
  66. * @return
  67. */
  68. // @ApiOperation(value = "学生报名乐团")
  69. @PostMapping("/userApply")
  70. public Object userApply(ApplyInfo applyInfo){
  71. if(applyInfo != null){
  72. try {
  73. Date date = new Date();
  74. applyInfo.setCreateTime(date);
  75. applyInfo.setUpdateTime(date);
  76. applyInfoService.insert(applyInfo);
  77. School school = schoolService.get(applyInfo.getClassId());
  78. if(school == null){
  79. return failed("乐团数据不存在");
  80. }else {
  81. school.setSchoolId(applyInfo.getSchoolId());
  82. school.setUpdateTime(date);
  83. schoolService.update(school);
  84. }
  85. return succeed(applyInfo.getId());
  86. }catch (Exception e){
  87. e.printStackTrace();
  88. if(e instanceof DuplicateKeyException){
  89. return failed("该用户已存在");
  90. }
  91. return failed("报名失败");
  92. }
  93. }
  94. return failed(Constants.PARAM_VERIFY_ERROR_MSG);
  95. }
  96. /**
  97. * 根据乐团id获取乐团详情,查询乐团状态也通过该接口
  98. * @param clazzId
  99. * @return
  100. */
  101. // @ApiOperation(value = "根据乐团编号获取乐团详情,查询乐团状态也通过该接口")
  102. @PostMapping("/getClassDetail")
  103. // @ApiImplicitParams({ @ApiImplicitParam(name = "clazzId", value = "乐团编号", required = true, dataType = "Integer"),
  104. // @ApiImplicitParam(name = "schoolId", value = "学校编号", required = true, dataType = "Integer")})
  105. public Object getSchoolDetail(Integer schoolId,Integer clazzId){
  106. if(schoolId == null || clazzId == null){
  107. return failed(Constants.PARAM_VERIFY_ERROR_MSG);
  108. }
  109. return succeed(orderService.getSchoolDetail(schoolId,clazzId));
  110. }
  111. /**
  112. * 根据学生编号获取乐团注册页面数据
  113. * @param stuId
  114. * @return
  115. */
  116. // @ApiOperation(value = "根据学生编号获取乐团注册页面数据")
  117. @PostMapping("/getUserRegisterViewDetail")
  118. public Object getUserRegisterViewDetail(Integer stuId){
  119. if(stuId == null){
  120. return failed(Constants.PARAM_VERIFY_ERROR_MSG);
  121. }
  122. return succeed(applyInfoService.getUserRegisterViewDetail(stuId));
  123. }
  124. /**
  125. * 推送用户到mec注册
  126. * @return
  127. */
  128. /*@PostMapping("/userRegister")
  129. public Object userRegister(String phone){
  130. return succeed(applyInfoService.userRegister(phone));
  131. }*/
  132. /**
  133. * 获取乐团课程组列表
  134. * @return
  135. */
  136. @PostMapping("/getCourses")
  137. // @ApiOperation(value = "根据乐团编号,获取乐团课程组列表")
  138. // @ApiImplicitParams({ @ApiImplicitParam(name = "clazzId", value = "乐团编号", required = true, dataType = "Integer")})
  139. public Object getCourses(Integer clazzId){
  140. if(clazzId == null){
  141. return failed(Constants.PARAM_VERIFY_ERROR_MSG);
  142. }
  143. return succeed(courseGroupInfoService.getCourses(clazzId));
  144. }
  145. // @ApiOperation(value = "获取所有乐团列表")
  146. @PostMapping("/getMusicTeams")
  147. public Object getMusicTeams(MusicTeamsPageInfo pageInfo){
  148. return succeed(schoolService.queryPage(pageInfo));
  149. }
  150. // @ApiOperation(value = "根据乐团编号,获取学员列表")
  151. @PostMapping("/getMusicTeamStu")
  152. public Object getMusicTeamStu(StudentsQueryInfo queryInfo){
  153. return succeed(applyInfoService.queryUserPage(queryInfo));
  154. }
  155. // @ApiOperation(value = "获取所有分部列表")
  156. @GetMapping("/getBranches")
  157. public Object getBranches(){
  158. return succeed(applyInfoService.getBranches());
  159. }
  160. // @ApiOperation(value = "获取学校详情")
  161. @GetMapping("/getSchool")
  162. public Object getSchool(Integer schoolId){
  163. if(schoolId == null){
  164. return failed(Constants.PARAM_VERIFY_ERROR_MSG);
  165. }
  166. return succeed(applyInfoService.get(schoolId));
  167. }
  168. /**
  169. * 保存学校列表
  170. * @return
  171. */
  172. // @GetMapping("/saveSeminary")
  173. // public Object saveSeminary(){
  174. // applyInfoService.saveSeminary();
  175. // return succeed();
  176. // }
  177. /**
  178. * 修改乐团信息
  179. * @return
  180. */
  181. // @ApiOperation(value = "修改乐团信息")
  182. @PostMapping("/updateClass")
  183. public Object updateClass(School school){
  184. school.setUpdateTime(new Date());
  185. schoolService.update(school);
  186. return succeed();
  187. }
  188. /**
  189. * 开启乐团缴费功能
  190. * @return
  191. */
  192. // @ApiOperation(value = "开启乐团缴费功能")
  193. @PostMapping("/openClassPay")
  194. public Object openClassPay(Integer id){
  195. if(id == null){
  196. return failed(Constants.PARAM_VERIFY_ERROR_MSG);
  197. }
  198. schoolService.openClassPay(id);
  199. return succeed();
  200. }
  201. /**
  202. * 修改学生信息
  203. * @return
  204. */
  205. // @ApiOperation(value = "修改学生信息")
  206. @PostMapping("/updateUser")
  207. public Object updateUser(@ModelAttribute ApplyInfo applyInfo){
  208. applyInfo.setUpdateTime(new Date());
  209. applyInfoService.update(applyInfo);
  210. return succeed("修改成功");
  211. }
  212. /**
  213. * 修改学生信息
  214. * @return
  215. */
  216. // @ApiOperation(value = "批量调剂学员专业")
  217. @PostMapping("/updateUserSub")
  218. public Object updateUserSub(String userId,Integer subId,Integer courseId){
  219. if(StringUtils.isEmpty(userId) || subId == null || courseId == null){
  220. return failed(Constants.PARAM_VERIFY_ERROR_MSG);
  221. }
  222. applyInfoService.updateUserSub(userId,subId,courseId);
  223. return succeed("修改成功");
  224. }
  225. // @ApiOperation(value = "学员课程班查询,本接口用于查询指定学员报名的课程班(小课或乐团)列表")
  226. @PostMapping("/queryUserCourse")
  227. // @ApiImplicitParams({ @ApiImplicitParam(name = "userId", value = "用户编号", required = true, dataType = "Integer")})
  228. public Object queryUserCourse(Integer userId){
  229. if(userId == null){
  230. return failed(Constants.PARAM_VERIFY_ERROR_MSG);
  231. }
  232. return succeed(applyInfoService.queryUserCourse(userId));
  233. }
  234. /**
  235. * 推送学生续费成功的订单数据到mec
  236. * @return
  237. */
  238. // @PostMapping("/pushRenew")
  239. // public Object pushRenew(RenewBean renewBean){
  240. // applyInfoService.pushRenew(renewBean);
  241. // return succeed();
  242. // }
  243. /**
  244. * 查询mec用户信息
  245. * @return
  246. */
  247. @PostMapping("/findMecUser")
  248. public Object findMecUser(Integer userId){
  249. if(userId == null){
  250. return failed(Constants.PARAM_VERIFY_ERROR_MSG);
  251. }
  252. return succeed(applyInfoService.findMecUser(userId));
  253. }
  254. @PostMapping("/mecUserIsExist")
  255. public Object mecUserIsExist(String phone){
  256. return succeed(applyInfoService.mecUserIsExist(phone));
  257. }
  258. }