Pārlūkot izejas kodu

报名缴费修改

周箭河 5 gadi atpakaļ
vecāks
revīzija
b0247987d1

+ 11 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentPaymentOrderDetailDao.java

@@ -2,8 +2,18 @@ package com.ym.mec.biz.dal.dao;
 
 import com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail;
 import com.ym.mec.common.dal.BaseDAO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 public interface StudentPaymentOrderDetailDao extends BaseDAO<Long, StudentPaymentOrderDetail> {
 
-	
+
+    /**
+     * 批量添加订单详情
+     *
+     * @param studentPaymentOrderDetailList
+     * @return
+     */
+    int batchAdd(@Param("studentPaymentOrderDetailList") List<StudentPaymentOrderDetail> studentPaymentOrderDetailList);
 }

+ 11 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/MusicCardDto.java

@@ -13,6 +13,9 @@ public class MusicCardDto {
     @ApiModelProperty(value = "乐团编号",required = true)
     private String musicGroupId;
 
+    @ApiModelProperty(value = "科目编号",required = true)
+    private String subjectId;
+
     @ApiModelProperty(value = "乐团名称",required = true)
     private String musicGroupName;
 
@@ -113,4 +116,12 @@ public class MusicCardDto {
     public void setRegisterId(String registerId) {
         this.registerId = registerId;
     }
+
+    public String getSubjectId() {
+        return subjectId;
+    }
+
+    public void setSubjectId(String subjectId) {
+        this.subjectId = subjectId;
+    }
 }

+ 9 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dto/RegisterPayDto.java

@@ -10,6 +10,7 @@ public class RegisterPayDto {
     private Integer registerId;
     private String goodsGroupIds;
     private String goodsIds;
+    private String otherGoodsIds;
 
     public Integer getRegisterId() {
         return registerId;
@@ -42,4 +43,12 @@ public class RegisterPayDto {
     public void setAmount(BigDecimal amount) {
         this.amount = amount;
     }
+
+    public String getOtherGoodsIds() {
+        return otherGoodsIds;
+    }
+
+    public void setOtherGoodsIds(String otherGoodsIds) {
+        this.otherGoodsIds = otherGoodsIds;
+    }
 }

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/enums/OrderDetailTypeEnum.java

@@ -7,7 +7,8 @@ import com.ym.mec.common.enums.BaseEnum;
  */
 public enum OrderDetailTypeEnum implements BaseEnum<String, OrderDetailTypeEnum> {
 	MUSICAL("MUSICAL", "乐器"),
-	TEACHING("TEACHING", "教辅"),
+	ACCESSORIES("ACCESSORIES", "辅件"),
+	TEACHING("TEACHING", "教谱"),
 	OTHER("OTHER", "其他"),
 	COURSE("COURSE", "课程");
 

+ 12 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/StudentPaymentOrderDetailService.java

@@ -2,7 +2,19 @@ package com.ym.mec.biz.service;
 
 import com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail;
 import com.ym.mec.common.service.BaseService;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 public interface StudentPaymentOrderDetailService extends BaseService<Long, StudentPaymentOrderDetail> {
 
+
+    /**
+     * 批量添加订单
+     *
+     * @param studentPaymentOrderDetailList
+     * @return
+     */
+    int batchAdd(List<StudentPaymentOrderDetail> studentPaymentOrderDetailList);
+
 }

+ 16 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/StudentRegistrationService.java

@@ -1,10 +1,14 @@
 package com.ym.mec.biz.service;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 import com.ym.mec.biz.dal.dto.StudentApplyDetailDto;
 import com.ym.mec.biz.dal.dto.StudentFeeDto;
 import com.ym.mec.biz.dal.dto.StudentInfo;
+import com.ym.mec.biz.dal.entity.Goods;
+import com.ym.mec.biz.dal.entity.MusicGroupSubjectGoodsGroup;
+import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.entity.StudentRegistration;
 import com.ym.mec.biz.dal.page.StudentRegistrationQueryInfo;
 import com.ym.mec.common.page.PageInfo;
@@ -79,4 +83,16 @@ public interface StudentRegistrationService extends BaseService<Long, StudentReg
      */
     StudentInfo queryStudentInfo(Integer userId);
 
+
+    /**
+     * 学生注册缴费订单
+     * @param userId
+     * @param amount
+     * @param courseFee
+     * @param goodsGroups
+     * @param goodsList
+     * @return
+     */
+    StudentPaymentOrder addOrder(Integer userId,BigDecimal amount,String orderNo,String paymentChannel,BigDecimal courseFee, List<MusicGroupSubjectGoodsGroup> goodsGroups, List<Goods> goodsList, List<Goods> otherGoodsList);
+
 }

+ 15 - 9
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderDetailServiceImpl.java

@@ -9,15 +9,21 @@ import com.ym.mec.biz.service.StudentPaymentOrderDetailService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 
+import java.util.List;
+
 @Service
-public class StudentPaymentOrderDetailServiceImpl extends BaseServiceImpl<Long, StudentPaymentOrderDetail>  implements StudentPaymentOrderDetailService {
-	
-	@Autowired
-	private StudentPaymentOrderDetailDao studentPaymentOrderDetailDao;
+public class StudentPaymentOrderDetailServiceImpl extends BaseServiceImpl<Long, StudentPaymentOrderDetail> implements StudentPaymentOrderDetailService {
+
+    @Autowired
+    private StudentPaymentOrderDetailDao studentPaymentOrderDetailDao;
+
+    @Override
+    public BaseDAO<Long, StudentPaymentOrderDetail> getDAO() {
+        return studentPaymentOrderDetailDao;
+    }
 
-	@Override
-	public BaseDAO<Long, StudentPaymentOrderDetail> getDAO() {
-		return studentPaymentOrderDetailDao;
-	}
-	
+    @Override
+    public int batchAdd(List<StudentPaymentOrderDetail> studentPaymentOrderDetailList) {
+        return studentPaymentOrderDetailDao.batchAdd(studentPaymentOrderDetailList);
+    }
 }

+ 94 - 6
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java

@@ -1,5 +1,6 @@
 package com.ym.mec.biz.service.impl;
 
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
@@ -8,6 +9,13 @@ import java.util.Map;
 
 import javax.annotation.Resource;
 
+import com.ym.mec.biz.dal.dto.VipGroupBuyParamsDto;
+import com.ym.mec.biz.dal.entity.*;
+import com.ym.mec.biz.dal.enums.*;
+import com.ym.mec.biz.service.StudentPaymentOrderDetailService;
+import com.ym.mec.biz.service.StudentPaymentOrderService;
+import com.ym.mec.common.exception.BizException;
+import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -20,8 +28,6 @@ import com.ym.mec.biz.dal.dao.StudentRegistrationDao;
 import com.ym.mec.biz.dal.dto.StudentApplyDetailDto;
 import com.ym.mec.biz.dal.dto.StudentFeeDto;
 import com.ym.mec.biz.dal.dto.StudentInfo;
-import com.ym.mec.biz.dal.entity.StudentRegistration;
-import com.ym.mec.biz.dal.enums.YesOrNoEnum;
 import com.ym.mec.biz.dal.page.StudentRegistrationQueryInfo;
 import com.ym.mec.biz.service.StudentRegistrationService;
 import com.ym.mec.common.dal.BaseDAO;
@@ -36,6 +42,10 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
     private StudentRegistrationDao studentRegistrationDao;
     @Autowired
     private SysUserFeignService sysUserFeignService;
+    @Autowired
+    private StudentPaymentOrderService studentPaymentOrderService;
+
+    private StudentPaymentOrderDetailService studentPaymentOrderDetailService;
 
     @Override
     public BaseDAO<Long, StudentRegistration> getDAO() {
@@ -123,8 +133,86 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         return studentRegistration;
     }
 
-	@Override
-	public StudentInfo queryStudentInfo(Integer userId) {
-		return studentRegistrationDao.queryStudentInfo(userId);
-	}
+    @Override
+    public StudentInfo queryStudentInfo(Integer userId) {
+        return studentRegistrationDao.queryStudentInfo(userId);
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public StudentPaymentOrder addOrder(Integer userId, BigDecimal amount, String orderNo, String paymentChannel, BigDecimal courseFee, List<MusicGroupSubjectGoodsGroup> goodsGroups, List<Goods> goodsList, List<Goods> otherGoodsList) {
+
+        Date date = new Date();
+        StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
+        studentPaymentOrder.setUserId(userId);
+        studentPaymentOrder.setType(OrderTypeEnum.APPLY);
+        studentPaymentOrder.setExpectAmount(amount);
+        studentPaymentOrder.setActualAmount(amount);
+        studentPaymentOrder.setStatus(DealStatusEnum.ING);
+        studentPaymentOrder.setPaymentChannel(paymentChannel);
+        studentPaymentOrderService.insert(studentPaymentOrder);
+
+        ArrayList<StudentPaymentOrderDetail> studentPaymentOrderDetailList = new ArrayList<>();
+        StudentPaymentOrderDetail studentPaymentOrderDetail = new StudentPaymentOrderDetail();
+        studentPaymentOrderDetail.setType(OrderDetailTypeEnum.COURSE);
+        studentPaymentOrderDetail.setPrice(courseFee);
+        studentPaymentOrderDetail.setCreateTime(date);
+        studentPaymentOrderDetail.setUpdateTime(date);
+        studentPaymentOrderDetail.setPaymentOrderId(studentPaymentOrder.getId());
+        studentPaymentOrderDetailList.add(studentPaymentOrderDetail);
+        //乐器及打包辅件
+        if (goodsGroups != null) {
+            for (MusicGroupSubjectGoodsGroup goodsGroup : goodsGroups) {
+                StudentPaymentOrderDetail studentPaymentOrderDetail4goodsGroup = new StudentPaymentOrderDetail();
+                OrderDetailTypeEnum type = null;
+                if (goodsGroup.getType().equals(GoodsType.INSTRUMENT)) {
+                    type = OrderDetailTypeEnum.MUSICAL;
+                } else if (goodsGroup.getType().equals(GoodsType.ACCESSORIES)) {
+                    type = OrderDetailTypeEnum.ACCESSORIES;
+                } else if (goodsGroup.getType().equals(GoodsType.OTHER)) {
+                    type = OrderDetailTypeEnum.TEACHING;
+                }
+                studentPaymentOrderDetail4goodsGroup.setType(type);
+                studentPaymentOrderDetail4goodsGroup.setPrice(goodsGroup.getPrice());
+                studentPaymentOrderDetail4goodsGroup.setGoodsIdList(goodsGroup.getGoodsIdList());
+                studentPaymentOrderDetail4goodsGroup.setCreateTime(date);
+                studentPaymentOrderDetail4goodsGroup.setUpdateTime(date);
+                studentPaymentOrderDetail4goodsGroup.setPaymentOrderId(studentPaymentOrder.getId());
+                studentPaymentOrderDetailList.add(studentPaymentOrderDetail4goodsGroup);
+            }
+        }
+
+        //单独辅件
+        if (goodsList != null) {
+            for (Goods goods : goodsList) {
+                StudentPaymentOrderDetail studentPaymentOrderDetail4goods = new StudentPaymentOrderDetail();
+                studentPaymentOrderDetail4goods.setType(OrderDetailTypeEnum.ACCESSORIES);
+                studentPaymentOrderDetail4goods.setPrice(goods.getGroupPurchasePrice());
+                studentPaymentOrderDetail4goods.setGoodsIdList(goods.getId().toString());
+                studentPaymentOrderDetail4goods.setCreateTime(date);
+                studentPaymentOrderDetail4goods.setUpdateTime(date);
+                studentPaymentOrderDetail4goods.setPaymentOrderId(studentPaymentOrder.getId());
+                studentPaymentOrderDetailList.add(studentPaymentOrderDetail4goods);
+
+            }
+        }
+        //单独教谱
+        if (otherGoodsList != null) {
+            for (Goods goods : otherGoodsList) {
+                StudentPaymentOrderDetail studentPaymentOrderDetail4otherGoods = new StudentPaymentOrderDetail();
+                studentPaymentOrderDetail4otherGoods.setType(OrderDetailTypeEnum.TEACHING);
+                studentPaymentOrderDetail4otherGoods.setPrice(goods.getGroupPurchasePrice());
+                studentPaymentOrderDetail4otherGoods.setGoodsIdList(goods.getId().toString());
+                studentPaymentOrderDetail4otherGoods.setCreateTime(date);
+                studentPaymentOrderDetail4otherGoods.setUpdateTime(date);
+                studentPaymentOrderDetail4otherGoods.setPaymentOrderId(studentPaymentOrder.getId());
+                studentPaymentOrderDetailList.add(studentPaymentOrderDetail4otherGoods);
+            }
+        }
+
+        studentPaymentOrderDetailService.batchAdd(studentPaymentOrderDetailList);
+
+        return studentPaymentOrder;
+    }
+
 }

+ 2 - 1
mec-biz/src/main/resources/config/mybatis/MusicGroupMapper.xml

@@ -140,6 +140,7 @@
 		<result column="register_id_" property="registerId" />
 		<result column="user_name_" property="userName" />
 		<result column="subject_name_" property="subjectName" />
+		<result column="subject_id_" property="subjectId" />
 		<result column="current_class_" property="currentClass" />
 		<result column="current_grade_" property="currentGrade" />
 		<result column="music_group_name_" property="musicGroupName" />
@@ -151,7 +152,7 @@
 
     <select id="queryUserMusicGroups" resultMap="queryUserMusicGroupsMap">
 		SELECT sr.id_ register_id_,sr.name_ user_name_,sr.current_class_,sr.current_grade_,
-		sr.payment_status_,mg.name_ music_group_name_,s.name_ subject_name_,mg.id_ music_group_id_
+		sr.payment_status_,mg.name_ music_group_name_,s.name_ subject_name_,s.id_ subject_id_,mg.id_ music_group_id_
 		FROM student_registration sr
 		LEFT JOIN music_group mg ON sr.music_group_id_ = mg.id_
 		LEFT JOIN `subject` s ON sr.actual_subject_id_ = s.id_

+ 9 - 0
mec-biz/src/main/resources/config/mybatis/StudentPaymentOrderDetailMapper.xml

@@ -77,4 +77,13 @@
     <select id="queryCount" resultType="int">
 		SELECT COUNT(*) FROM student_payment_order_detail
 	</select>
+
+    <insert id="batchAdd" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id_">
+        INSERT INTO student_payment_order_detail
+        (type_,goods_id_list_,price_,create_time_,update_time_,payment_order_id_)
+        VALUE
+        <foreach collection="studentPaymentOrderDetailList" item="orderDetail" separator=",">
+            (#{orderDetail.type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{orderDetail.goodsIdList},#{orderDetail.price},#{orderDetail.createTime},#{orderDetail.updateTime},#{orderDetail.paymentOrderId})
+        </foreach>
+    </insert>
 </mapper>

+ 45 - 32
mec-student/src/main/java/com/ym/mec/student/controller/MusicGroupController.java

@@ -4,10 +4,7 @@ import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dto.MusicGroupSubjectGoodsAndInfoDto;
 import com.ym.mec.biz.dal.dto.RegisterPayDto;
-import com.ym.mec.biz.dal.entity.Goods;
-import com.ym.mec.biz.dal.entity.MusicGroupSubjectGoodsGroup;
-import com.ym.mec.biz.dal.entity.MusicGroupSubjectPlan;
-import com.ym.mec.biz.dal.entity.StudentRegistration;
+import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.GoodsType;
 import com.ym.mec.biz.dal.enums.KitGroupPurchaseTypeEnum;
 import com.ym.mec.biz.service.*;
@@ -23,10 +20,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import java.math.BigDecimal;
-import java.util.Date;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 @RequestMapping("musicGroup")
 @Api(tags = "乐团服务")
@@ -47,7 +41,8 @@ public class MusicGroupController extends BaseController {
     private GoodsService goodsService;
     @Autowired
     private StudentPaymentOrderService studentPaymentOrderService;
-    @Autowired PayService payService;
+    @Autowired
+    PayService payService;
 
     @ApiOperation("获取学生所在乐团列表")
     @GetMapping(value = "/queryUserMusicGroups")
@@ -102,47 +97,56 @@ public class MusicGroupController extends BaseController {
             return failed("报名信息有误,请核查");
         }
 
-        BigDecimal amount = registerPayDto.getAmount();
-
+        BigDecimal amount = registerPayDto.getAmount(); //前端获取的价格
         BigDecimal orderAmount = new BigDecimal("0");
 
         //获取课程价格
         MusicGroupSubjectPlan musicOneSubjectClassPlan = musicGroupSubjectPlanService.getMusicOneSubjectClassPlan(studentRegistration.getMusicGroupId(), studentRegistration.getSubjectId());
-        orderAmount.add(musicOneSubjectClassPlan.getFee());
+        BigDecimal courseFee = musicOneSubjectClassPlan.getFee();
+        orderAmount = orderAmount.add(courseFee);
 
 
         //乐器及打包辅件
-        if (registerPayDto.getGoodsGroupIds() != null) {
-            List<MusicGroupSubjectGoodsGroup> goodsGroups = musicGroupSubjectGoodsGroupService.findGoodsGroupByIds(registerPayDto.getGoodsGroupIds());
-            goodsGroups.forEach(goodsGroup -> {
-                //辅件价格
-                if (goodsGroup.getType().equals(GoodsType.ACCESSORIES)) {
-                    orderAmount.add(goodsGroup.getPrice());
-                    return;
-                }
-                if (musicOneSubjectClassPlan.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.LEASE)) {//租赁
-                    orderAmount.add(musicOneSubjectClassPlan.getDepositFee());
-                } else if (musicOneSubjectClassPlan.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.GROUP)) {//团购
-                    orderAmount.add(goodsGroup.getPrice()).subtract(goodsGroup.getRemissionCourseFee());//团购减免课程费用
+        List<MusicGroupSubjectGoodsGroup> goodsGroups = null;
+        if (registerPayDto.getGoodsGroupIds() != null && !registerPayDto.getGoodsGroupIds().equals("")) {
+            goodsGroups = musicGroupSubjectGoodsGroupService.findGoodsGroupByIds(registerPayDto.getGoodsGroupIds());
+            for (MusicGroupSubjectGoodsGroup goodsGroup : goodsGroups) {
+                orderAmount = orderAmount.add(goodsGroup.getPrice());
+                //团购乐器减免课程费用
+                if (goodsGroup.getType().equals(GoodsType.INSTRUMENT) && goodsGroup.getRemissionCourseFee() != null && musicOneSubjectClassPlan.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.GROUP)) {//团购
+                    orderAmount = orderAmount.subtract(goodsGroup.getRemissionCourseFee());
                 }
-            });
+            }
         }
 
         //单独辅件
-        if (registerPayDto.getGoodsIds() != null) {
-            List<Goods> goodsList = goodsService.findGoodsByIds(registerPayDto.getGoodsIds());
-            goodsList.forEach(goods -> {
-                orderAmount.add(goods.getGroupPurchasePrice());
-            });
+        List<Goods> goodsList = null;
+        if (registerPayDto.getGoodsIds() != null && !registerPayDto.getGoodsIds().equals("")) {
+            goodsList = goodsService.findGoodsByIds(registerPayDto.getGoodsIds());
+            for (Goods goods : goodsList) {
+                orderAmount = orderAmount.add(goods.getGroupPurchasePrice());
+            }
+        }
+
+        //单独教谱
+        List<Goods> otherGoodsList = null;
+        if (registerPayDto.getOtherGoodsIds() != null && !registerPayDto.getOtherGoodsIds().equals("")) {
+            otherGoodsList = goodsService.findGoodsByIds(registerPayDto.getOtherGoodsIds());
+            for (Goods goods : otherGoodsList) {
+                orderAmount = orderAmount.add(goods.getGroupPurchasePrice());
+            }
         }
         if (amount.compareTo(orderAmount) != 0) {
             return failed("商品价格不符");
         }
 
+
         IdWorker idWorker = new IdWorker(0, 0);
         String orderNo = idWorker.nextId();
 
-        Map payMap = payService.getPayMap(orderAmount,orderNo,"https://pay.dayaedu.com/yqpay/notify","http://dev.dayaedu.com","测试订单","测试订单");
+        Map payMap = payService.getPayMap(orderAmount, orderNo, "https://pay.dayaedu.com/yqpay/notify", "http://dev.dayaedu.com", "测试订单", "测试订单");
+
+        studentRegistrationService.addOrder(userId, amount, orderNo, "双乾", courseFee, goodsGroups, goodsList, otherGoodsList);
 
         return succeed(payMap);
     }
@@ -150,8 +154,17 @@ public class MusicGroupController extends BaseController {
     @GetMapping("/test")
     public Object test() throws Exception {
 
+        IdWorker idWorker = new IdWorker(0, 0);
+        String orderNo = idWorker.nextId();
         BigDecimal amount = new BigDecimal("200");
-        Map map = payService.getPayMap(amount,"201910113456789386903","https://pay.dayaedu.com/notify","https://baodiu.com","测试订单","测试订单");
+        Map map = payService.getPayMap(amount, orderNo, "https://pay.dayaedu.com/notify", "https://baodiu.com", "测试订单", "测试订单");
         return succeed(map);
     }
+
+    @ApiOperation(value = "订单状态查询")
+    @GetMapping("/getOrderStatus")
+    @ApiImplicitParams({@ApiImplicitParam(name = "orderNo", value = "订单号", required = true, dataType = "String")})
+    public HttpResponseResult getOrderStatus(String orderNo) {
+        return succeed(orderNo);
+    }
 }