StudentPaymentOrderController.java 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. package com.ym.mec.web.controller;
  2. import com.ym.mec.auth.api.client.SysUserFeignService;
  3. import com.ym.mec.auth.api.entity.SysUser;
  4. import com.ym.mec.biz.dal.dao.EmployeeDao;
  5. import com.ym.mec.biz.dal.dao.StudentPaymentOrderDao;
  6. import com.ym.mec.biz.dal.dao.SysConfigDao;
  7. import com.ym.mec.biz.dal.dto.BasicUserDto;
  8. import com.ym.mec.biz.dal.entity.Employee;
  9. import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
  10. import com.ym.mec.biz.dal.page.SporadicOrderQueryInfo;
  11. import com.ym.mec.biz.dal.page.StudentPaymentOrderQueryInfo;
  12. import com.ym.mec.biz.service.StudentPaymentOrderDetailService;
  13. import com.ym.mec.biz.service.StudentPaymentOrderService;
  14. import com.ym.mec.common.controller.BaseController;
  15. import com.ym.mec.common.entity.HttpResponseResult;
  16. import com.ym.mec.common.page.PageInfo;
  17. import io.swagger.annotations.Api;
  18. import io.swagger.annotations.ApiImplicitParam;
  19. import io.swagger.annotations.ApiImplicitParams;
  20. import io.swagger.annotations.ApiOperation;
  21. import org.apache.commons.lang3.StringUtils;
  22. import org.springframework.beans.factory.annotation.Autowired;
  23. import org.springframework.beans.factory.annotation.Value;
  24. import org.springframework.security.access.prepost.PreAuthorize;
  25. import org.springframework.web.bind.annotation.GetMapping;
  26. import org.springframework.web.bind.annotation.RequestMapping;
  27. import org.springframework.web.bind.annotation.RestController;
  28. import java.math.BigDecimal;
  29. import java.util.Arrays;
  30. import java.util.List;
  31. import java.util.stream.Collectors;
  32. @RequestMapping("order")
  33. @Api(tags = "订单服务")
  34. @RestController
  35. public class StudentPaymentOrderController extends BaseController {
  36. @Autowired
  37. private StudentPaymentOrderService studentPaymentOrderService;
  38. @Autowired
  39. private StudentPaymentOrderDetailService studentPaymentOrderDetailService;
  40. @Autowired
  41. private SysUserFeignService sysUserFeignService;
  42. @Autowired
  43. private EmployeeDao employeeDao;
  44. @Autowired
  45. private SysConfigDao sysConfigDao;
  46. @Autowired
  47. private StudentPaymentOrderDao studentPaymentOrderDao;
  48. @ApiOperation(value = "获取订单列表")
  49. @GetMapping("/queryPage")
  50. @PreAuthorize("@pcs.hasPermissions('order/queryPage')")
  51. public Object queryOrderPage(StudentPaymentOrderQueryInfo queryInfo) {
  52. SysUser sysUser = sysUserFeignService.queryUserInfo();
  53. if (sysUser == null) {
  54. return failed("用户信息获取失败");
  55. }
  56. if (!sysUser.getIsSuperAdmin()) {
  57. Employee employee = employeeDao.get(sysUser.getId());
  58. if (StringUtils.isEmpty(queryInfo.getOrganId())) {
  59. queryInfo.setOrganId(employee.getOrganIdList());
  60. } else if (StringUtils.isEmpty(employee.getOrganIdList())) {
  61. return failed("用户所在分部异常");
  62. } else {
  63. List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
  64. if (!list.containsAll(Arrays.asList(queryInfo.getOrganId().split(",")))) {
  65. return failed("非法请求");
  66. }
  67. }
  68. }
  69. if(StringUtils.isNotBlank(queryInfo.getSearch())){
  70. List<BasicUserDto> users = studentPaymentOrderDao.getUsers(queryInfo.getSearch());
  71. List<Integer> userIds = users.stream().map(BasicUserDto::getUserId).collect(Collectors.toList());
  72. if(userIds.size() >0){
  73. queryInfo.setUserIds(userIds);
  74. }
  75. }
  76. PageInfo<StudentPaymentOrder> studentPaymentOrderPageInfo = studentPaymentOrderService.OrderQueryPage(queryInfo);
  77. int openHideMode = Integer.parseInt(sysConfigDao.findConfigValue("open_hide_mode"));
  78. if (openHideMode == 1) {
  79. for (StudentPaymentOrder row : studentPaymentOrderPageInfo.getRows()) {
  80. if (row.getComAmount() != null) {
  81. BigDecimal balancePaymentAmount = row.getBalancePaymentAmount() == null ? BigDecimal.ZERO : row.getBalancePaymentAmount();
  82. BigDecimal comAmount = row.getComAmount() == null ? BigDecimal.ZERO : row.getComAmount();
  83. row.setExpectAmount(comAmount.add(balancePaymentAmount));
  84. row.setActualAmount(comAmount.add(balancePaymentAmount));
  85. }
  86. }
  87. }
  88. return succeed(studentPaymentOrderPageInfo);
  89. }
  90. @ApiOperation(value = "获取零星收费订单列表")
  91. @GetMapping("/sporadicQueryPage")
  92. @PreAuthorize("@pcs.hasPermissions('order/sporadicQueryPage')")
  93. public Object sporadicQueryPage(SporadicOrderQueryInfo queryInfo) {
  94. SysUser sysUser = sysUserFeignService.queryUserInfo();
  95. if (sysUser == null) {
  96. return failed("用户信息获取失败");
  97. }
  98. if (!sysUser.getIsSuperAdmin()) {
  99. Employee employee = employeeDao.get(sysUser.getId());
  100. if (StringUtils.isEmpty(queryInfo.getOrganId())) {
  101. queryInfo.setOrganId(employee.getOrganIdList());
  102. } else if (StringUtils.isEmpty(employee.getOrganIdList())) {
  103. return failed("用户所在分部异常");
  104. } else {
  105. List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
  106. if (!list.containsAll(Arrays.asList(queryInfo.getOrganId().split(",")))) {
  107. return failed("非法请求");
  108. }
  109. }
  110. }
  111. return succeed(studentPaymentOrderService.sporadicQueryPage(queryInfo));
  112. }
  113. @ApiOperation(value = "获取订单列表1")
  114. @GetMapping("/queryPage1")
  115. @PreAuthorize("@pcs.hasPermissions('order/queryPage1')")
  116. public Object queryOrderPage1(StudentPaymentOrderQueryInfo queryInfo) {
  117. SysUser sysUser = sysUserFeignService.queryUserInfo();
  118. if (sysUser == null) {
  119. return failed("用户信息获取失败");
  120. }
  121. if (!sysUser.getIsSuperAdmin()) {
  122. Employee employee = employeeDao.get(sysUser.getId());
  123. if (StringUtils.isEmpty(queryInfo.getOrganId())) {
  124. queryInfo.setOrganId(employee.getOrganIdList());
  125. } else if (StringUtils.isEmpty(employee.getOrganIdList())) {
  126. return failed("用户所在分部异常");
  127. } else {
  128. List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
  129. if (!list.containsAll(Arrays.asList(queryInfo.getOrganId().split(",")))) {
  130. return failed("非法请求");
  131. }
  132. }
  133. }
  134. queryInfo.setOrderType("1");
  135. PageInfo<StudentPaymentOrder> studentPaymentOrderPageInfo = studentPaymentOrderService.OrderQueryPage(queryInfo);
  136. for (StudentPaymentOrder row : studentPaymentOrderPageInfo.getRows()) {
  137. BigDecimal balancePaymentAmount = row.getBalancePaymentAmount() == null ? BigDecimal.ZERO : row.getBalancePaymentAmount();
  138. BigDecimal comAmount = row.getComAmount() == null ? BigDecimal.ZERO : row.getComAmount();
  139. if (row.getComAmount() != null) {
  140. row.setExpectAmount(comAmount.add(balancePaymentAmount));
  141. row.setActualAmount(comAmount.add(balancePaymentAmount));
  142. }
  143. }
  144. return succeed(studentPaymentOrderPageInfo);
  145. }
  146. @ApiOperation(value = "获取订单列表2")
  147. @GetMapping("/queryPage2")
  148. @PreAuthorize("@pcs.hasPermissions('order/queryPage2')")
  149. public Object queryOrderPage2(StudentPaymentOrderQueryInfo queryInfo) {
  150. SysUser sysUser = sysUserFeignService.queryUserInfo();
  151. if (sysUser == null) {
  152. return failed("用户信息获取失败");
  153. }
  154. if (!sysUser.getIsSuperAdmin()) {
  155. Employee employee = employeeDao.get(sysUser.getId());
  156. if (StringUtils.isEmpty(queryInfo.getOrganId())) {
  157. queryInfo.setOrganId(employee.getOrganIdList());
  158. } else if (StringUtils.isEmpty(employee.getOrganIdList())) {
  159. return failed("用户所在分部异常");
  160. } else {
  161. List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
  162. if (!list.containsAll(Arrays.asList(queryInfo.getOrganId().split(",")))) {
  163. return failed("非法请求");
  164. }
  165. }
  166. }
  167. queryInfo.setOrderType("2");
  168. PageInfo<StudentPaymentOrder> studentPaymentOrderPageInfo = studentPaymentOrderService.OrderQueryPage(queryInfo);
  169. for (StudentPaymentOrder row : studentPaymentOrderPageInfo.getRows()) {
  170. BigDecimal balancePaymentAmount = row.getBalancePaymentAmount() == null ? BigDecimal.ZERO : row.getBalancePaymentAmount();
  171. BigDecimal perAmount = row.getPerAmount() == null ? BigDecimal.ZERO : row.getPerAmount();
  172. if (row.getPerAmount() != null) {
  173. row.setExpectAmount(perAmount.add(balancePaymentAmount));
  174. row.setActualAmount(perAmount.add(balancePaymentAmount));
  175. }
  176. }
  177. return succeed(studentPaymentOrderPageInfo);
  178. }
  179. @ApiOperation(value = "获取乐器采购清单")
  180. @GetMapping("/getMusicalList")
  181. @PreAuthorize("@pcs.hasPermissions('order/getMusicalList')")
  182. @ApiImplicitParams({@ApiImplicitParam(name = "musicGroupId", value = "乐团id", required = true, dataType = "String")})
  183. public Object getMusicalList(String musicGroupId) {
  184. return succeed(studentPaymentOrderDetailService.getMusicalList(musicGroupId));
  185. }
  186. @ApiOperation(value = "乐器清单确认")
  187. @GetMapping("/verifyMusicalList")
  188. @PreAuthorize("@pcs.hasPermissions('order/verifyMusicalList')")
  189. @ApiImplicitParams({@ApiImplicitParam(name = "musicGroupId", value = "乐团id", required = true, dataType = "String")})
  190. public Object verifyMusicalListMusicalList(String musicGroupId) {
  191. return succeed(studentPaymentOrderDetailService.verifyMusicalList(musicGroupId));
  192. }
  193. @ApiOperation(value = "财务订单列表")
  194. @GetMapping("/finance")
  195. @PreAuthorize("@pcs.hasPermissions('order/finance')")
  196. public Object financeOrder(StudentPaymentOrderQueryInfo queryInfo) {
  197. SysUser sysUser = sysUserFeignService.queryUserInfo();
  198. if (sysUser == null) {
  199. return failed("用户信息获取失败");
  200. }
  201. if (!sysUser.getIsSuperAdmin()) {
  202. Employee employee = employeeDao.get(sysUser.getId());
  203. if (StringUtils.isEmpty(queryInfo.getRoutingOrganId())) {
  204. queryInfo.setRoutingOrganId(employee.getOrganIdList());
  205. } else if (StringUtils.isEmpty(employee.getOrganIdList())) {
  206. return failed("用户所在分部异常");
  207. } else {
  208. List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
  209. if (!list.containsAll(Arrays.asList(queryInfo.getRoutingOrganId().split(",")))) {
  210. return failed("非法请求");
  211. }
  212. }
  213. }
  214. PageInfo<StudentPaymentOrder> studentPaymentOrderPageInfo = studentPaymentOrderService.OrderQueryPage(queryInfo);
  215. return succeed(studentPaymentOrderPageInfo);
  216. }
  217. @ApiOperation(value = "查询订单状态")
  218. @GetMapping("/getOrderStatus")
  219. @PreAuthorize("@pcs.hasPermissions('order/getOrderStatus')")
  220. @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "订单id", required = true, dataType = "int")})
  221. public HttpResponseResult<Boolean> getOrderStatus(Long id) throws Exception {
  222. return succeed(studentPaymentOrderService.getOrderStatus(id));
  223. }
  224. }