zouxuan 5 vuotta sitten
vanhempi
commit
5af11c7be3

+ 12 - 5
src/main/java/com/ym/mec/collectfee/controller/OrderController.java

@@ -2,12 +2,13 @@ package com.ym.mec.collectfee.controller;
 
 import com.ym.mec.collectfee.common.web.BaseController;
 import com.ym.mec.collectfee.service.OrderService;
+import com.ym.mec.collectfee.utils.Constants;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
@@ -29,6 +30,9 @@ public class OrderController extends BaseController {
     @ApiOperation(value = "根据学生编号,获取订单列表")
     @ApiImplicitParams({ @ApiImplicitParam(name = "userId", value = "学生编号", required = true, dataType = "Integer")})
     public Object getOrders(Integer userId){
+        if(userId == null){
+            return failed(Constants.PARAM_VERIFY_ERROR_MSG);
+        }
         return succeed(orderService.getOrderByUserId(userId));
     }
 
@@ -43,6 +47,9 @@ public class OrderController extends BaseController {
     @ApiImplicitParams({ @ApiImplicitParam(name = "poName", value = "乐团名称", required = true, dataType = "String"),
             @ApiImplicitParam(name = "voicePart", value = "声部名称", required = true, dataType = "String")})
     public Object queryNum(String poName,String voicePart){
+        if(StringUtils.isEmpty(voicePart) || StringUtils.isEmpty(poName)){
+            return failed(Constants.PARAM_VERIFY_ERROR_MSG);
+        }
         return succeed(orderService.countOrder(poName, voicePart));
     }
 
@@ -51,9 +58,9 @@ public class OrderController extends BaseController {
      * @param batchNum
      * @return
      */
-    @PostMapping("/pushOrder")
-    public String pushOrder(String batchNum){
-        return orderService.pushOrder(batchNum);
-    }
+//    @PostMapping("/pushOrder")
+//    public String pushOrder(String batchNum){
+//        return orderService.pushOrder(batchNum);
+//    }
 
 }

+ 44 - 13
src/main/java/com/ym/mec/collectfee/controller/UserController.java

@@ -7,6 +7,7 @@ import com.ym.mec.collectfee.service.ApplyInfoService;
 import com.ym.mec.collectfee.service.CourseGroupInfoService;
 import com.ym.mec.collectfee.service.OrderService;
 import com.ym.mec.collectfee.service.SchoolService;
+import com.ym.mec.collectfee.utils.Constants;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -20,6 +21,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.util.Date;
+import java.util.List;
 
 @RestController()
 @RequestMapping("user")
@@ -48,7 +50,7 @@ public class UserController extends BaseController {
             @ApiImplicitParam(name = "clazzId", value = "乐团编号", required = true, dataType = "Integer")})
     public Object getUserDetailByPhone(String phone,Integer clazzId){
         if(StringUtils.isEmpty(phone) || clazzId == null){
-            return failed("参数校验异常");
+            return failed(Constants.PARAM_VERIFY_ERROR_MSG);
         }
         ApplyInfo userByPhone = applyInfoService.findUserByPhone(phone, clazzId);
         School school = schoolService.get(clazzId);
@@ -79,7 +81,7 @@ public class UserController extends BaseController {
                 return failed("报名失败");
             }
         }
-        return failed();
+        return failed(Constants.PARAM_VERIFY_ERROR_MSG);
     }
 
     /**
@@ -92,6 +94,9 @@ public class UserController extends BaseController {
     @ApiImplicitParams({ @ApiImplicitParam(name = "clazzId", value = "乐团编号", required = true, dataType = "Integer"),
             @ApiImplicitParam(name = "schoolId", value = "学校编号", required = true, dataType = "Integer")})
     public Object getSchoolDetail(Integer schoolId,Integer clazzId){
+        if(schoolId == null || clazzId == null){
+            return failed(Constants.PARAM_VERIFY_ERROR_MSG);
+        }
         return succeed(orderService.getSchoolDetail(schoolId,clazzId));
     }
 
@@ -103,6 +108,9 @@ public class UserController extends BaseController {
     @ApiOperation(value = "根据学生编号获取乐团注册页面数据")
     @PostMapping("/getUserRegisterViewDetail")
     public Object getUserRegisterViewDetail(Integer stuId){
+        if(stuId == null){
+            return failed(Constants.PARAM_VERIFY_ERROR_MSG);
+        }
         return succeed(applyInfoService.getUserRegisterViewDetail(stuId));
     }
 
@@ -123,6 +131,9 @@ public class UserController extends BaseController {
     @ApiOperation(value = "根据乐团编号,获取乐团课程组列表")
     @ApiImplicitParams({ @ApiImplicitParam(name = "clazzId", value = "乐团编号", required = true, dataType = "Integer")})
     public Object getCourses(Integer clazzId){
+        if(clazzId == null){
+            return failed(Constants.PARAM_VERIFY_ERROR_MSG);
+        }
         return succeed(courseGroupInfoService.getCourses(clazzId));
     }
 
@@ -147,6 +158,9 @@ public class UserController extends BaseController {
     @ApiOperation(value = "获取学校详情")
     @GetMapping("/getSchool")
     public Object getSchool(Integer schoolId){
+        if(schoolId == null){
+            return failed(Constants.PARAM_VERIFY_ERROR_MSG);
+        }
         return succeed(applyInfoService.get(schoolId));
     }
 
@@ -154,11 +168,11 @@ public class UserController extends BaseController {
      * 保存学校列表
      * @return
      */
-    @GetMapping("/saveSeminary")
-    public Object saveSeminary(){
-        applyInfoService.saveSeminary();
-        return succeed();
-    }
+//    @GetMapping("/saveSeminary")
+//    public Object saveSeminary(){
+//        applyInfoService.saveSeminary();
+//        return succeed();
+//    }
 
     /**
      * 修改乐团信息
@@ -185,12 +199,26 @@ public class UserController extends BaseController {
         return succeed("修改成功");
     }
 
+    /**
+     * 修改学生信息
+     * @return
+     */
+    @ApiOperation(value = "批量调剂学员专业")
+    @PostMapping("/updateUserSub")
+    public Object updateUserSub(String userId,Integer subId,Integer courseId){
+        if(StringUtils.isEmpty(userId) || subId == null || courseId == null){
+            return failed(Constants.PARAM_VERIFY_ERROR_MSG);
+        }
+        applyInfoService.updateUserSub(userId,subId,courseId);
+        return succeed("修改成功");
+    }
+
     @ApiOperation(value = "学员课程班查询,本接口用于查询指定学员报名的课程班(小课或乐团)列表")
     @PostMapping("/queryUserCourse")
     @ApiImplicitParams({ @ApiImplicitParam(name = "userId", value = "用户编号", required = true, dataType = "Integer")})
     public Object queryUserCourse(Integer userId){
         if(userId == null){
-            return failed("参数校验异常");
+            return failed(Constants.PARAM_VERIFY_ERROR_MSG);
         }
         return succeed(applyInfoService.queryUserCourse(userId));
     }
@@ -199,11 +227,11 @@ public class UserController extends BaseController {
      * 推送学生续费成功的订单数据到mec
      * @return
      */
-    @PostMapping("/pushRenew")
-    public Object pushRenew(RenewBean renewBean){
-        applyInfoService.pushRenew(renewBean);
-        return succeed();
-    }
+//    @PostMapping("/pushRenew")
+//    public Object pushRenew(RenewBean renewBean){
+//        applyInfoService.pushRenew(renewBean);
+//        return succeed();
+//    }
 
     /**
      * 查询mec用户信息
@@ -211,6 +239,9 @@ public class UserController extends BaseController {
      */
     @PostMapping("/findMecUser")
     public Object findMecUser(Integer userId){
+        if(userId == null){
+            return failed(Constants.PARAM_VERIFY_ERROR_MSG);
+        }
         return succeed(applyInfoService.findMecUser(userId));
     }
 }

+ 7 - 0
src/main/java/com/ym/mec/collectfee/dao/ApplyInfoDao.java

@@ -36,4 +36,11 @@ public interface ApplyInfoDao extends BaseDAO<Integer, ApplyInfo> {
      * @return
      */
     ApplyInfo findByUserId(Integer userId);
+
+    /**
+     * 调剂
+     * @param userId
+     * @param subId
+     */
+    void updateUserSub(@Param("userId") Integer userId, @Param("subId")Integer subId,@Param("courseId")Integer courseId);
 }

+ 10 - 0
src/main/java/com/ym/mec/collectfee/entity/StudentsQueryInfo.java

@@ -9,6 +9,16 @@ public class StudentsQueryInfo extends QueryInfo {
 
     private Integer status;
 
+    private Integer subId;
+
+    public Integer getSubId() {
+        return subId;
+    }
+
+    public void setSubId(Integer subId) {
+        this.subId = subId;
+    }
+
     public String getName() {
         return name;
     }

+ 13 - 4
src/main/java/com/ym/mec/collectfee/service/ApplyInfoService.java

@@ -1,9 +1,11 @@
 package com.ym.mec.collectfee.service;
 
+import com.ym.mec.collectfee.common.page.PageInfo;
 import com.ym.mec.collectfee.common.service.BaseService;
 import com.ym.mec.collectfee.entity.*;
 
 import java.util.List;
+import java.util.Map;
 
 public interface ApplyInfoService extends BaseService<Integer, ApplyInfo> {
 
@@ -23,7 +25,7 @@ public interface ApplyInfoService extends BaseService<Integer, ApplyInfo> {
      * 推送mec  3.2.13添加乐团学员(含缴费)(125218)
      * @return
      */
-    Object getApplyClass(ApplyInfo applyInfo);
+    RequestMecApplyClass getApplyClass(ApplyInfo applyInfo);
 
     /**
      * 获取分部列表
@@ -42,16 +44,16 @@ public interface ApplyInfoService extends BaseService<Integer, ApplyInfo> {
      * @param stuId
      * @return
      */
-    Object getUserRegisterViewDetail(Integer stuId);
+    Map<String, Object> getUserRegisterViewDetail(Integer stuId);
 
-    Object queryUserPage(StudentsQueryInfo queryInfo);
+    PageInfo<ApplyInfoPage> queryUserPage(StudentsQueryInfo queryInfo);
 
     /**
      *本接口用于查询指定学员报名的课程班(小课或乐团)列表
      * @param userId
      * @return
      */
-    Object queryUserCourse(Integer userId);
+    List<MecCourse> queryUserCourse(Integer userId);
 
     /**
      * 查询mec用户信息
@@ -67,4 +69,11 @@ public interface ApplyInfoService extends BaseService<Integer, ApplyInfo> {
      * @return
      */
     boolean pushRenew(RenewBean renewBean);
+
+    /**
+     * 批量调剂
+     * @param userId
+     * @param subId
+     */
+    void updateUserSub(String userId, Integer subId,Integer courseId);
 }

+ 13 - 3
src/main/java/com/ym/mec/collectfee/service/impl/ApplyInfoServiceImpl.java

@@ -15,6 +15,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.io.StringWriter;
 import java.io.Writer;
@@ -183,7 +184,7 @@ public class ApplyInfoServiceImpl extends BaseServiceImpl<Integer, ApplyInfo> im
 	}
 
 	@Override
-	public Object getUserRegisterViewDetail(Integer stuId) {
+	public Map<String, Object> getUserRegisterViewDetail(Integer stuId) {
 		Map<String, Object> vIewDetail = applyInfoDao.getUserRegisterVIewDetail(stuId);
 		String subName = vIewDetail.get("sub_name_").toString();
 		if(subName.contains("圆号") || subName.contains("上低音") ||subName.contains("长号") ||subName.contains("大号")){
@@ -195,7 +196,7 @@ public class ApplyInfoServiceImpl extends BaseServiceImpl<Integer, ApplyInfo> im
 	}
 
 	@Override
-	public Object queryUserPage(StudentsQueryInfo queryInfo) {
+	public PageInfo<ApplyInfoPage> queryUserPage(StudentsQueryInfo queryInfo) {
 		PageInfo<ApplyInfoPage> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
 		Map<String, Object> params = new HashMap<>();
 		MapUtil.populateMap(params, queryInfo);
@@ -215,7 +216,7 @@ public class ApplyInfoServiceImpl extends BaseServiceImpl<Integer, ApplyInfo> im
 	}
 
 	@Override
-	public Object queryUserCourse(Integer userId) {
+	public List<MecCourse> queryUserCourse(Integer userId) {
 		try {
 			//获取学员信息
 			findMecUser(userId);
@@ -299,6 +300,15 @@ public class ApplyInfoServiceImpl extends BaseServiceImpl<Integer, ApplyInfo> im
 		return false;
 	}
 
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void updateUserSub(String userId, Integer subId,Integer courseId) {
+		String[] userIds = userId.split(",");
+		for (String string:userIds) {
+			applyInfoDao.updateUserSub(Integer.parseInt(string),subId,courseId);
+		}
+	}
+
 
 	private List<MecCourse> getCourses(String body) throws Exception{
 		body = getBody(body,123031);

+ 5 - 0
src/main/java/com/ym/mec/collectfee/utils/Constants.java

@@ -0,0 +1,5 @@
+package com.ym.mec.collectfee.utils;
+
+public interface Constants {
+    String PARAM_VERIFY_ERROR_MSG = "参数校验异常";
+}

+ 18 - 12
src/main/resources/config/mybatis/ApplyInfoMapper.xml

@@ -5,7 +5,7 @@
 不要修改此文件。所有改动将在下次重新自动生成时丢失。
 -->
 <mapper namespace="com.ym.mec.collectfee.dao.ApplyInfoDao">
-	
+
 	<resultMap type="com.ym.mec.collectfee.entity.ApplyInfo" id="ApplyInfo">
 		<result column="id_" property="id" />
 		<result column="user_id_" property="userId" />
@@ -55,17 +55,17 @@
 		<result column="amount_" property="amount" />
 		<result column="create_time_" property="createTime" />
 	</resultMap>
-	
+
 	<!-- 根据主键查询一条记录 -->
 	<select id="get" resultMap="ApplyInfo" >
 		SELECT * FROM apply_info WHERE id_ = #{id} 
 	</select>
-	
+
 	<!-- 全查询 -->
 	<select id="findAll" resultMap="ApplyInfo">
 		SELECT * FROM apply_info ORDER BY id_
 	</select>
-	
+
 	<!-- 向数据库增加一条记录 -->
 	<insert id="insert" parameterType="com.ym.mec.collectfee.entity.ApplyInfo" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
 		INSERT INTO apply_info (course_id_,class_id_,user_id_,branch_id_,name_,sex_,birthday_,city_,school_,grade_,g_class_,sub_id_,is_adjust_,patriarch_phone_,patriarch_name_,patriarch_unit_,update_time_,create_time_) VALUES
@@ -134,11 +134,15 @@
 		WHERE id_ = #{id}
 	</update>
 
-	<!-- 根据主键删除一条记录 -->
+    <update id="updateUserSub">
+            UPDATE apply_info SET sub_id_ = #{subId},course_id_ = #{courseId},update_time_ = #{updateTime} WHERE id_ = ${userId}
+    </update>
+
+    <!-- 根据主键删除一条记录 -->
 	<delete id="delete" >
 		DELETE FROM apply_info WHERE id_ = #{id} 
 	</delete>
-	
+
 	<!-- 分页查询 -->
 	<select id="queryPage" resultMap="ApplyInfo" parameterType="map">
 		SELECT * FROM apply_info ai <include refid="studentsPage"/> ORDER BY id_ <include refid="global.limit"/>
@@ -155,9 +159,12 @@
 			<if test="status != null">
 				AND ai.status_ = #{status}
 			</if>
+			<if test="subId != null">
+				AND ai.sub_id_ = #{subId}
+			</if>
 		</where>
 	</sql>
-	
+
 	<!-- 查询当前表的总记录数 -->
 	<select id="findCount" resultType="int">
 		SELECT COUNT(*) FROM apply_info <include refid="studentsPage"/>
@@ -179,16 +186,15 @@
 	</select>
 
 	<select id="queryUserPage" resultMap="ApplyInfoPage" parameterType="map">
-		SELECT ai.*,cgi.sub_name_ sub_name_,o.amount amount_ FROM apply_info ai
-		LEFT JOIN course_group_info cgi ON ai.sub_id_ = cgi.sub_id_
+		SELECT ao.*,cgi.sub_name_ sub_name_ FROM (SELECT ai.*,o.amount amount_ FROM apply_info ai
 		LEFT JOIN `order` o ON ai.id_ = o.user_id
-		<include refid="studentsPage"/>
-		ORDER BY ai.update_time_ DESC
+		<include refid="studentsPage"/>) ao LEFT JOIN course_group_info cgi ON ao.course_id_ = cgi.id_
+		ORDER BY ao.update_time_ DESC
 		<include refid="global.limit"/>
 	</select>
 
 	<select id="queryUserCount" resultType="java.lang.Integer">
-		SELECT count(ai.id_) FROM apply_info ai
+		SELECT count(DISTINCT ai.id_) FROM apply_info ai
 		LEFT JOIN course_group_info cgi ON ai.sub_id_ = cgi.sub_id_
 		LEFT JOIN `order` o ON ai.id_ = o.user_id
 		<include refid="studentsPage"/>