瀏覽代碼

订单增加分页

周箭河 5 年之前
父節點
當前提交
7ba25fc507

+ 10 - 1
src/main/java/com/ym/mec/collectfee/controller/OrderController.java

@@ -1,10 +1,12 @@
 package com.ym.mec.collectfee.controller;
 
 import com.ym.mec.collectfee.common.web.BaseController;
+import com.ym.mec.collectfee.entity.OrderQueryInfo;
 import com.ym.mec.collectfee.service.OrderService;
 import com.ym.mec.collectfee.utils.Constants;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.ModelAttribute;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
@@ -36,7 +38,14 @@ public class OrderController extends BaseController {
 //  @ApiImplicitParams({ @ApiImplicitParam(name = "classId", value = "乐团编号", required = true, dataType = "Integer")})
 	  public Object checkOrders(Integer classId, Integer type, String voicyPart, String startTime, String endTime, Integer branchId){
 	      return succeed(orderService.getOrderByClassId(classId,type,voicyPart,startTime,endTime,branchId));
-	  }
+    }
+
+    @PostMapping("/orderListPage")
+//  @ApiOperation(value = "根据学生编号,获取订单列表")
+//  @ApiImplicitParams({ @ApiImplicitParam(name = "classId", value = "乐团编号", required = true, dataType = "Integer")})
+    public Object orderListPage(@ModelAttribute OrderQueryInfo queryInfo){
+        return succeed(orderService.queryOrderPage(queryInfo));
+    }
 
     /**
      * 查询报名人数

+ 37 - 4
src/main/java/com/ym/mec/collectfee/controller/UserController.java

@@ -11,6 +11,7 @@ import com.ym.mec.collectfee.utils.Constants;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.dao.DuplicateKeyException;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpSession;
@@ -110,7 +111,7 @@ public class UserController extends BaseController {
     /**
      * 根据乐团id获取乐团详情,查询乐团状态也通过该接口
      *
-     * @param clazzId
+     * @param schoolId
      * @return
      */
 //    @ApiOperation(value = "根据乐团编号获取乐团详情,查询乐团状态也通过该接口")
@@ -237,7 +238,7 @@ public class UserController extends BaseController {
 //    @ApiOperation(value = "关闭乐团缴费功能")
     @PostMapping("/closeClassPay")
     public Object closeClassPay(Integer id) {
-        if (id == null ) {
+        if (id == null) {
             return failed(Constants.PARAM_VERIFY_ERROR_MSG);
         }
         School school = schoolService.get(id);
@@ -253,9 +254,41 @@ public class UserController extends BaseController {
      */
 //    @ApiOperation(value = "修改学生信息")
     @PostMapping("/updateUser")
-    public Object updateUser(@ModelAttribute ApplyInfo applyInfo) {
-        applyInfo.setUpdateTime(new Date());
+    @Transactional(rollbackFor = Exception.class)
+    public Object updateUser(@ModelAttribute ApplyInfo applyInfo) throws Exception {
+
+        if (applyInfo.getId() == null || applyInfo.getId() <= 0) {
+            return failed(Constants.PARAM_VERIFY_ERROR_MSG);
+        }
+
+        if (applyInfo.getStatus() != null && applyInfo.getStatus() != 1) {
+            return failed("不能修改报名成功以外的状态");
+        }
+
+        ApplyInfo oldApplyInfo = applyInfoService.get(applyInfo.getId());
+        if (oldApplyInfo == null) {
+            return failed("报名信息不存在,请核对");
+        }
+        boolean flag = false;
+
+        if (applyInfo.getStatus().equals(1) && !oldApplyInfo.getStatus().equals(1)) {
+            flag = true;
+        }
+
+        Date date = new Date();
+        applyInfo.setUpdateTime(date);
         applyInfoService.update(applyInfo);
+
+        //改成成功,推送mec
+        if (flag) {
+            ApplyInfo newApplyInfo = applyInfoService.get(applyInfo.getId());
+            // 增加报名人数
+            CourseGroupInfo courseGroupInfo = courseGroupInfoService.get(newApplyInfo.getCourseId());
+            courseGroupInfo.setRegNum(courseGroupInfo.getRegNum() + 1);
+            courseGroupInfoService.upByIdAndVersion(courseGroupInfo);
+            //推送mec
+            applyInfoService.userRegister(newApplyInfo.getPatriarchPhone()); //推送mec
+        }
         return succeed("修改成功");
     }
 

+ 1 - 1
src/main/java/com/ym/mec/collectfee/controller/YqPayController.java

@@ -509,7 +509,7 @@ public class YqPayController extends BaseController {
     }
 
 
-    @Scheduled(cron = "0/5 * * * * ?")
+    //@Scheduled(cron = "0/5 * * * * ?")
     //@RequestMapping("/getOrderStatus")
     public void getOrderStatus() throws Exception {
 

+ 5 - 0
src/main/java/com/ym/mec/collectfee/dao/OrderDao.java

@@ -1,7 +1,9 @@
 package com.ym.mec.collectfee.dao;
 
 import com.ym.mec.collectfee.common.dao.BaseDAO;
+import com.ym.mec.collectfee.entity.ApplyInfoPage;
 import com.ym.mec.collectfee.entity.Order;
+import com.ym.mec.collectfee.entity.OrderPage;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Component;
 
@@ -36,4 +38,7 @@ public interface OrderDao extends BaseDAO<Integer, Order> {
 
     Order findRegOrderByStatus(@Param("userId") Integer userId,@Param("status") Integer status);
 
+    int queryOrderCount(Map<String, Object> params);
+
+    List<Order> queryOrderPage(Map<String, Object> queryInfo);
 }

+ 36 - 0
src/main/java/com/ym/mec/collectfee/entity/OrderPage.java

@@ -0,0 +1,36 @@
+package com.ym.mec.collectfee.entity;
+
+import java.math.BigDecimal;
+
+public class OrderPage extends Order {
+
+    private BigDecimal amount;
+
+    private String subName;
+
+    private String schoolName;
+
+    public String getSchoolName() {
+        return schoolName;
+    }
+
+    public void setSchoolName(String schoolName) {
+        this.schoolName = schoolName;
+    }
+
+    public BigDecimal getAmount() {
+        return amount;
+    }
+
+    public void setAmount(BigDecimal amount) {
+        this.amount = amount;
+    }
+
+    public String getSubName() {
+        return subName;
+    }
+
+    public void setSubName(String subName) {
+        this.subName = subName;
+    }
+}

+ 61 - 0
src/main/java/com/ym/mec/collectfee/entity/OrderQueryInfo.java

@@ -0,0 +1,61 @@
+package com.ym.mec.collectfee.entity;
+
+import com.ym.mec.collectfee.common.page.QueryInfo;
+
+public class OrderQueryInfo extends QueryInfo {
+
+    private Integer classId;
+    private Integer type;
+    private String voicyPart;
+    private String startTime;
+    private String endTime;
+    private Integer branchId;
+
+    public Integer getClassId() {
+        return classId;
+    }
+
+    public void setClassId(Integer classId) {
+        this.classId = classId;
+    }
+
+    public Integer getType() {
+        return type;
+    }
+
+    public void setType(Integer type) {
+        this.type = type;
+    }
+
+    public String getVoicyPart() {
+        return voicyPart;
+    }
+
+    public void setVoicyPart(String voicyPart) {
+        this.voicyPart = voicyPart;
+    }
+
+    public String getStartTime() {
+        return startTime;
+    }
+
+    public void setStartTime(String startTime) {
+        this.startTime = startTime;
+    }
+
+    public String getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(String endTime) {
+        this.endTime = endTime;
+    }
+
+    public Integer getBranchId() {
+        return branchId;
+    }
+
+    public void setBranchId(Integer branchId) {
+        this.branchId = branchId;
+    }
+}

+ 10 - 0
src/main/java/com/ym/mec/collectfee/service/ApplyInfoService.java

@@ -22,12 +22,22 @@ public interface ApplyInfoService extends BaseService<Integer, ApplyInfo> {
      */
     Boolean userRegister(String phone,Integer orderId);
 
+    Boolean userRegister(String phone);
+
+
     /**
      * 推送mec  3.2.13添加乐团学员(含缴费)(125218)
      * @return
      */
     RequestMecApplyClass getApplyClass(ApplyInfo applyInfo,Integer orderId);
 
+
+    /**
+     * 推送mec  3.2.13添加乐团学员(含缴费)(125218)
+     * @return
+     */
+    RequestMecApplyClass getApplyClass(ApplyInfo applyInfo);
+
     /**
      * 获取分部列表
      * @return

+ 4 - 3
src/main/java/com/ym/mec/collectfee/service/OrderService.java

@@ -1,10 +1,9 @@
 package com.ym.mec.collectfee.service;
 
 import com.alibaba.fastjson.JSON;
+import com.ym.mec.collectfee.common.page.PageInfo;
 import com.ym.mec.collectfee.common.service.BaseService;
-import com.ym.mec.collectfee.entity.Account;
-import com.ym.mec.collectfee.entity.Order;
-import com.ym.mec.collectfee.entity.School;
+import com.ym.mec.collectfee.entity.*;
 import com.ym.mec.collectfee.utils.yqpay.YqPayUtil;
 import org.apache.ibatis.annotations.Param;
 
@@ -107,4 +106,6 @@ public interface OrderService extends BaseService<Integer, Order> {
 
     Order findRegOrderByStatus(Integer userId, Integer status);
 
+    PageInfo<Order> queryOrderPage(OrderQueryInfo queryInfo);
+
 }

+ 91 - 1
src/main/java/com/ym/mec/collectfee/service/impl/ApplyInfoServiceImpl.java

@@ -61,7 +61,7 @@ import lombok.extern.slf4j.Slf4j;
 @Service
 @Slf4j
 public class ApplyInfoServiceImpl extends BaseServiceImpl<Integer, ApplyInfo> implements ApplyInfoService {
-	
+
 	@Autowired
 	private ApplyInfoDao applyInfoDao;
 	@Autowired
@@ -159,6 +159,52 @@ public class ApplyInfoServiceImpl extends BaseServiceImpl<Integer, ApplyInfo> im
 	}
 
 	@Override
+	public Boolean userRegister(String phone) {
+		try {
+			ApplyInfo applyInfo = applyInfoDao.findUserByPhone(phone,null);
+			if(applyInfo != null && applyInfo.getStatus() == 1 && applyInfo.getPushStatus() != 1){
+				//组装请求
+				applyInfo.setRealName(applyInfo.getName());
+				String gClass = applyInfo.getgClass();
+				applyInfo.setgClass(applyInfo.getGrade() + applyInfo.getgClass());
+				applyInfo.setMobile(applyInfo.getPatriarchPhone());
+				XStream xs = new XStream();
+				xs.autodetectAnnotations(true);
+				xs.ignoreUnknownElements();
+				String body = xs.toXML(applyInfo);
+				body = body.substring(body.indexOf("<user>")+6,body.indexOf("</user>"));
+				//推送mec注册接口
+//				log.info("推送到用户数据到mec注册 body: " + body);
+				body = getBody(body,121301);
+				Date date = new Date();
+				try {
+					applyInfo.setUpdateTime(date);
+					ResponseUserInfo userInfo = parseRegisterInfo(body);
+					applyInfo.setUserId(userInfo.getUserId());
+					applyInfo.setPushStatus(1);
+					applyInfo.setGClass(gClass);
+					RequestMecApplyClass applyClass = getApplyClass(applyInfo);
+					body = xs.toXML(applyClass);
+					body = body.substring(body.indexOf("<body>")+6,body.indexOf("</body>"));
+					//推送mec用户缴费
+//					log.info("推送到用户数据到mec缴费 body: " + body);
+					getBody(body,125218);
+					applyInfoDao.update(applyInfo);
+					return true;
+				}catch (Exception e){
+					e.printStackTrace();
+					applyInfo.setPushStatus(2);
+					applyInfoDao.update(applyInfo);
+				}
+				return false;
+			}
+		}catch (Exception e){
+			e.printStackTrace();
+		}
+		return false;
+	}
+
+	@Override
 	public RequestMecApplyClass getApplyClass(ApplyInfo applyInfo,Integer orderId) {
 //		Order order = orderDao.findOrderByStatus(applyInfo.getId(), null);
 		Order order = orderDao.get(orderId);
@@ -207,6 +253,50 @@ public class ApplyInfoServiceImpl extends BaseServiceImpl<Integer, ApplyInfo> im
 		}
 		return null;
 	}
+	@Override
+	public RequestMecApplyClass getApplyClass(ApplyInfo applyInfo) {
+			//封装请求参数
+			RequestMecApplyClass applyClass = new RequestMecApplyClass();
+			//<studentId>学员编号</studentId>
+			applyClass.setStudentId(applyInfo.getUserId());
+			//<classId>课程班(乐团)编号</classId>
+			applyClass.setClassId(applyInfo.getClassId());
+			//<subName>学员专业名称</subName>
+			CourseGroupInfo groupInfo = courseGroupInfoDao.get(applyInfo.getCourseId());
+			applyClass.setSubName(groupInfo.getSubName());
+			//<remark>备注</remark>
+			//applyClass.setRemark(order.getRemark());
+			List<Course> courses = new ArrayList<>();
+			Course course = new Course();
+			//<courseId>课程组编号</courseId>
+			course.setCourseId(groupInfo.getId());
+			course.setTuitionFee(new BigDecimal(0));
+			courses.add(course);
+			applyClass.setCourses(courses);
+			//<amount>缴费总金额</amount>
+//			applyClass.setAmount(order.getAmount());
+			applyClass.setAmount(new BigDecimal(0));
+			//<tuiFee>学费金额</tuiFee>
+//			applyClass.setTuiFee(order.getTuiFee());
+			applyClass.setTuiFee(new BigDecimal(0));
+			//<goodsFee>乐器费用</goodsFee>
+//			applyClass.setGoodsFee(order.getGoodsFee());
+			applyClass.setGoodsFee(new BigDecimal(0));
+			//<sdName>杂费名称</sdName>
+			List<Sundry> sundries = new ArrayList<>();
+			Sundry sundry = new Sundry();
+//			sundry.setSdFee(order.getSdFee());
+			sundry.setSdFee(new BigDecimal(0));
+//			String sdName = order.getSdName();
+//			if(StringUtils.isEmpty(sdName)){
+//				sdName = order.getRemark();
+//			}
+//			//<sdFee>杂费金额</sdFee>
+//			sundry.setSdName(sdName);
+			sundries.add(sundry);
+			applyClass.setSundries(sundries);
+			return applyClass;
+	}
 
 	@Override
 	public List<Branch> getBranches() {

+ 27 - 2
src/main/java/com/ym/mec/collectfee/service/impl/OrderServiceImpl.java

@@ -3,6 +3,7 @@ package com.ym.mec.collectfee.service.impl;
 import com.alibaba.fastjson.JSON;
 import com.thoughtworks.xstream.XStream;
 import com.ym.mec.collectfee.common.dao.BaseDAO;
+import com.ym.mec.collectfee.common.page.PageInfo;
 import com.ym.mec.collectfee.common.service.impl.BaseServiceImpl;
 import com.ym.mec.collectfee.dao.OrderDao;
 import com.ym.mec.collectfee.entity.*;
@@ -11,6 +12,7 @@ import com.ym.mec.collectfee.service.OrderService;
 import com.ym.mec.collectfee.service.SchoolService;
 import com.ym.mec.collectfee.service.YqPayService;
 import com.ym.mec.collectfee.utils.HttpUtil;
+import com.ym.mec.collectfee.utils.MapUtil;
 import com.ym.mec.collectfee.utils.XStreamUtil;
 import com.ym.mec.collectfee.utils.yqpay.YqPayUtil;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -178,8 +180,8 @@ public class OrderServiceImpl extends BaseServiceImpl<Integer, Order> implements
     }
 
     @Override
-    public List<Order> getOrderByClassId(Integer classId, Integer type, String voicyPart,String startTime,String endTime, Integer branchId) {
-        return orderDao.getOrderByClassId(classId, type, voicyPart,startTime,endTime,branchId);
+    public List<Order> getOrderByClassId(Integer classId, Integer type, String voicyPart, String startTime, String endTime, Integer branchId) {
+        return orderDao.getOrderByClassId(classId, type, voicyPart, startTime, endTime, branchId);
     }
 
     public static void main(String[] args) {
@@ -214,5 +216,28 @@ public class OrderServiceImpl extends BaseServiceImpl<Integer, Order> implements
         return orderDao.findRegOrderByStatus(userId, status);
     }
 
+    @Override
+    public PageInfo<Order> queryOrderPage(OrderQueryInfo queryInfo) {
+        PageInfo<Order> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
+        Map<String, Object> params = new HashMap<>();
+        MapUtil.populateMap(params, queryInfo);
+
+        List<Order> dataList = null;
+        int count = orderDao.queryOrderCount(params);
+        if (count > 0) {
+            int page = count % pageInfo.getLimit() > 0 ? 1 : 0;
+            int totalPage = count / pageInfo.getLimit() + page;
+            pageInfo.setTotal(count);
+            pageInfo.setTotalPage(totalPage);
+            params.put("offset", pageInfo.getOffset());
+            dataList = orderDao.queryOrderPage(params);
+        }
+        if (count == 0) {
+            dataList = new ArrayList<>();
+        }
+        pageInfo.setRows(dataList);
+        return pageInfo;
+    }
+
 
 }

+ 32 - 0
src/main/resources/config/mybatis/OrderMapper.xml

@@ -239,4 +239,36 @@
     <select id="findRegOrderByStatus" resultMap="Order">
         SELECT * FROM `order` WHERE `user_id` = #{userId} AND `type`=1 AND `status` = #{status}
     </select>
+    <sql id="orderPage">
+        <if test="classId != null">
+            and class_id = #{classId}
+        </if>
+        <if test="type != null">
+            and type = #{type}
+        </if>
+        <if test="branchId != null">
+            and branch_id = #{branchId}
+        </if>
+        <if test="voicyPart != null">
+            and voicy_part like '%${voicyPart}%'
+        </if>
+        <if test="startTime != null and startTime != ''">
+            <![CDATA[ and pay_time >= ]]>#{startTime}
+        </if>
+        <if test="endTime != null and endTime != ''">
+            <![CDATA[ and pay_time <= ]]>#{endTime}
+        </if>
+    </sql>
+
+    <!-- 查询当前表的总记录数 -->
+    <select id="queryOrderCount" resultType="java.lang.Integer">
+        SELECT COUNT(*) FROM `order` WHERE status=2
+        <include refid="orderPage"/>
+    </select>
+
+    <select id="queryOrderPage" resultMap="Order" parameterType="map">
+        SELECT * FROM `order` WHERE status=2
+        <include refid="orderPage"/>
+        <include refid="global.limit"/>
+    </select>
 </mapper>