UserController.java 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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. if(applyInfoService.mecUserIsExist(phone)){
  44. return failed(Constants.PARAM_EXIST_ERROR_MSG);
  45. }
  46. ApplyInfo userByPhone = applyInfoService.findUserByPhone(phone, null);
  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. return succeed(applyInfo.getId());
  78. }catch (Exception e){
  79. e.printStackTrace();
  80. if(e instanceof DuplicateKeyException){
  81. return failed("该用户已存在");
  82. }
  83. return failed("报名失败");
  84. }
  85. }
  86. return failed(Constants.PARAM_VERIFY_ERROR_MSG);
  87. }
  88. /**
  89. * 根据乐团id获取乐团详情,查询乐团状态也通过该接口
  90. * @param clazzId
  91. * @return
  92. */
  93. // @ApiOperation(value = "根据乐团编号获取乐团详情,查询乐团状态也通过该接口")
  94. @PostMapping("/getClassDetail")
  95. // @ApiImplicitParams({ @ApiImplicitParam(name = "clazzId", value = "乐团编号", required = true, dataType = "Integer"),
  96. // @ApiImplicitParam(name = "schoolId", value = "学校编号", required = true, dataType = "Integer")})
  97. public Object getSchoolDetail(Integer schoolId,Integer clazzId){
  98. if(schoolId == null || clazzId == null){
  99. return failed(Constants.PARAM_VERIFY_ERROR_MSG);
  100. }
  101. return succeed(orderService.getSchoolDetail(schoolId,clazzId));
  102. }
  103. /**
  104. * 根据学生编号获取乐团注册页面数据
  105. * @param stuId
  106. * @return
  107. */
  108. // @ApiOperation(value = "根据学生编号获取乐团注册页面数据")
  109. @PostMapping("/getUserRegisterViewDetail")
  110. public Object getUserRegisterViewDetail(Integer stuId){
  111. if(stuId == null){
  112. return failed(Constants.PARAM_VERIFY_ERROR_MSG);
  113. }
  114. return succeed(applyInfoService.getUserRegisterViewDetail(stuId));
  115. }
  116. /**
  117. * 推送用户到mec注册
  118. * @return
  119. */
  120. /*@PostMapping("/userRegister")
  121. public Object userRegister(String phone){
  122. return succeed(applyInfoService.userRegister(phone));
  123. }*/
  124. /**
  125. * 获取乐团课程组列表
  126. * @return
  127. */
  128. @PostMapping("/getCourses")
  129. // @ApiOperation(value = "根据乐团编号,获取乐团课程组列表")
  130. // @ApiImplicitParams({ @ApiImplicitParam(name = "clazzId", value = "乐团编号", required = true, dataType = "Integer")})
  131. public Object getCourses(Integer clazzId){
  132. if(clazzId == null){
  133. return failed(Constants.PARAM_VERIFY_ERROR_MSG);
  134. }
  135. return succeed(courseGroupInfoService.getCourses(clazzId));
  136. }
  137. // @ApiOperation(value = "获取所有乐团列表")
  138. @PostMapping("/getMusicTeams")
  139. public Object getMusicTeams(MusicTeamsPageInfo pageInfo){
  140. return succeed(schoolService.queryPage(pageInfo));
  141. }
  142. // @ApiOperation(value = "根据乐团编号,获取学员列表")
  143. @PostMapping("/getMusicTeamStu")
  144. public Object getMusicTeamStu(StudentsQueryInfo queryInfo){
  145. return succeed(applyInfoService.queryUserPage(queryInfo));
  146. }
  147. // @ApiOperation(value = "获取所有分部列表")
  148. @GetMapping("/getBranches")
  149. public Object getBranches(){
  150. return succeed(applyInfoService.getBranches());
  151. }
  152. // @ApiOperation(value = "获取学校详情")
  153. @GetMapping("/getSchool")
  154. public Object getSchool(Integer schoolId){
  155. if(schoolId == null){
  156. return failed(Constants.PARAM_VERIFY_ERROR_MSG);
  157. }
  158. return succeed(applyInfoService.get(schoolId));
  159. }
  160. /**
  161. * 保存学校列表
  162. * @return
  163. */
  164. // @GetMapping("/saveSeminary")
  165. // public Object saveSeminary(){
  166. // applyInfoService.saveSeminary();
  167. // return succeed();
  168. // }
  169. /**
  170. * 修改乐团信息
  171. * @return
  172. */
  173. // @ApiOperation(value = "修改乐团信息")
  174. @PostMapping("/updateClass")
  175. public Object updateClass(School school){
  176. school.setUpdateTime(new Date());
  177. schoolService.update(school);
  178. return succeed();
  179. }
  180. /**
  181. * 开启乐团缴费功能
  182. * @return
  183. */
  184. // @ApiOperation(value = "开启乐团缴费功能")
  185. @PostMapping("/openClassPay")
  186. public Object openClassPay(Integer id){
  187. if(id == null){
  188. return failed(Constants.PARAM_VERIFY_ERROR_MSG);
  189. }
  190. schoolService.openClassPay(id);
  191. return succeed();
  192. }
  193. /**
  194. * 修改学生信息
  195. * @return
  196. */
  197. // @ApiOperation(value = "修改学生信息")
  198. @PostMapping("/updateUser")
  199. public Object updateUser(@ModelAttribute ApplyInfo applyInfo){
  200. applyInfo.setUpdateTime(new Date());
  201. applyInfoService.update(applyInfo);
  202. return succeed("修改成功");
  203. }
  204. /**
  205. * 修改学生信息
  206. * @return
  207. */
  208. // @ApiOperation(value = "批量调剂学员专业")
  209. @PostMapping("/updateUserSub")
  210. public Object updateUserSub(String userId,Integer subId,Integer courseId){
  211. if(StringUtils.isEmpty(userId) || subId == null || courseId == null){
  212. return failed(Constants.PARAM_VERIFY_ERROR_MSG);
  213. }
  214. applyInfoService.updateUserSub(userId,subId,courseId);
  215. return succeed("修改成功");
  216. }
  217. // @ApiOperation(value = "学员课程班查询,本接口用于查询指定学员报名的课程班(小课或乐团)列表")
  218. @PostMapping("/queryUserCourse")
  219. // @ApiImplicitParams({ @ApiImplicitParam(name = "userId", value = "用户编号", required = true, dataType = "Integer")})
  220. public Object queryUserCourse(Integer userId){
  221. if(userId == null){
  222. return failed(Constants.PARAM_VERIFY_ERROR_MSG);
  223. }
  224. return succeed(applyInfoService.queryUserCourse(userId));
  225. }
  226. /**
  227. * 推送学生续费成功的订单数据到mec
  228. * @return
  229. */
  230. // @PostMapping("/pushRenew")
  231. // public Object pushRenew(RenewBean renewBean){
  232. // applyInfoService.pushRenew(renewBean);
  233. // return succeed();
  234. // }
  235. /**
  236. * 查询mec用户信息
  237. * @return
  238. */
  239. @PostMapping("/findMecUser")
  240. public Object findMecUser(Integer userId){
  241. if(userId == null){
  242. return failed(Constants.PARAM_VERIFY_ERROR_MSG);
  243. }
  244. return succeed(applyInfoService.findMecUser(userId));
  245. }
  246. @PostMapping("/mecUserIsExist")
  247. public Object mecUserIsExist(String phone){
  248. return succeed(applyInfoService.mecUserIsExist(phone));
  249. }
  250. }