瀏覽代碼

报名缴费增加重复缴费接口

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

+ 34 - 14
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentPaymentOrderDao.java

@@ -1,8 +1,11 @@
 package com.ym.mec.biz.dal.dao;
 
 import com.ym.mec.biz.dal.entity.Goods;
+import com.ym.mec.biz.dal.entity.MusicGroup;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
+import com.ym.mec.biz.dal.enums.DealStatusEnum;
 import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
+import com.ym.mec.biz.dal.enums.OrderTypeEnum;
 import com.ym.mec.common.dal.BaseDAO;
 import org.apache.ibatis.annotations.Param;
 
@@ -10,19 +13,36 @@ import java.util.List;
 
 public interface StudentPaymentOrderDao extends BaseDAO<Long, StudentPaymentOrder> {
 
-	/**
-	 * 查询商品列表
-	 * @param musicGroupId
-	 * @param type
-	 * @return
-	 */
-	List<Goods> queryApplyGoodsList(@Param("musicGroupId") Integer musicGroupId, @Param("type") OrderDetailTypeEnum type);
+    /**
+     * 查询商品列表
+     *
+     * @param musicGroupId
+     * @param type
+     * @return
+     */
+    List<Goods> queryApplyGoodsList(@Param("musicGroupId") Integer musicGroupId, @Param("type") OrderDetailTypeEnum type);
 
-	/**
-	 * @Author: Joburgess
-	 * @Date: 2019/10/3
-	 * 根据学生vip课获取缴费订单
-	 */
-	StudentPaymentOrder findByStudentVipGroup(@Param("vipGroupId") Long vipGroupId,
-											  @Param("userId") Long userId);
+    /**
+     * @Author: Joburgess
+     * @Date: 2019/10/3
+     * 根据学生vip课获取缴费订单
+     */
+    StudentPaymentOrder findByStudentVipGroup(@Param("vipGroupId") Long vipGroupId, @Param("userId") Long userId);
+
+    /**
+     * 查询乐团报名的订单
+     *
+     * @param userId
+     * @param musicGroupId
+     * @param status
+     * @return
+     */
+    StudentPaymentOrder findMusicGroupApplyOrderByStatus(@Param("userId") Integer userId, @Param("musicGroupId") String musicGroupId, @Param("status") DealStatusEnum status);
+
+    /**
+     * 根据订单号查询订单
+     * @param orderNo
+     * @return
+     */
+    StudentPaymentOrder findOrderByOrderNo(@Param("orderNo") String orderNo);
 }

+ 21 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/StudentPaymentOrderService.java

@@ -4,8 +4,11 @@ import java.util.List;
 
 import com.ym.mec.biz.dal.entity.Goods;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
+import com.ym.mec.biz.dal.enums.DealStatusEnum;
 import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
+import com.ym.mec.biz.dal.enums.OrderTypeEnum;
 import com.ym.mec.common.service.BaseService;
+import org.apache.ibatis.annotations.Param;
 
 public interface StudentPaymentOrderService extends BaseService<Long, StudentPaymentOrder> {
 
@@ -16,4 +19,22 @@ public interface StudentPaymentOrderService extends BaseService<Long, StudentPay
 	 * @return
 	 */
 	List<Goods> queryApplyGoodsList(Integer musicGroupId, OrderDetailTypeEnum type);
+
+	/**
+	 * 查询报名缴费订单
+	 * @param musicGroupId
+	 * @param status
+	 * @return
+	 */
+	StudentPaymentOrder findMusicGroupApplyOrderByStatus(Integer userId,String musicGroupId, DealStatusEnum status);
+
+
+	/**
+	 * 根据orderNo查询订单
+	 * @param orderNo
+	 * @return
+	 */
+	StudentPaymentOrder findOrderByOrderNo(String orderNo);
+
+
 }

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

@@ -93,6 +93,6 @@ public interface StudentRegistrationService extends BaseService<Long, StudentReg
      * @param goodsList
      * @return
      */
-    StudentPaymentOrder addOrder(Integer userId,BigDecimal amount,String orderNo,String paymentChannel,BigDecimal courseFee, List<MusicGroupSubjectGoodsGroup> goodsGroups, List<Goods> goodsList, List<Goods> otherGoodsList);
+    StudentPaymentOrder addOrder(Integer userId,BigDecimal amount,String orderNo,String paymentChannel,BigDecimal courseFee, List<MusicGroupSubjectGoodsGroup> goodsGroups, List<Goods> goodsList, List<Goods> otherGoodsList,String musicGroupId);
 
 }

+ 27 - 15
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderServiceImpl.java

@@ -2,6 +2,8 @@ package com.ym.mec.biz.service.impl;
 
 import java.util.List;
 
+import com.ym.mec.biz.dal.enums.DealStatusEnum;
+import com.ym.mec.biz.dal.enums.OrderTypeEnum;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -14,19 +16,29 @@ import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 
 @Service
-public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, StudentPaymentOrder>  implements StudentPaymentOrderService {
-	
-	@Autowired
-	private StudentPaymentOrderDao studentPaymentOrderDao;
-
-	@Override
-	public BaseDAO<Long, StudentPaymentOrder> getDAO() {
-		return studentPaymentOrderDao;
-	}
-
-	@Override
-	public List<Goods> queryApplyGoodsList(Integer musicGroupId, OrderDetailTypeEnum type) {
-		return studentPaymentOrderDao.queryApplyGoodsList(musicGroupId, type);
-	}
-	
+public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, StudentPaymentOrder> implements StudentPaymentOrderService {
+
+    @Autowired
+    private StudentPaymentOrderDao studentPaymentOrderDao;
+
+    @Override
+    public BaseDAO<Long, StudentPaymentOrder> getDAO() {
+        return studentPaymentOrderDao;
+    }
+
+    @Override
+    public List<Goods> queryApplyGoodsList(Integer musicGroupId, OrderDetailTypeEnum type) {
+        return studentPaymentOrderDao.queryApplyGoodsList(musicGroupId, type);
+    }
+
+    @Override
+    public StudentPaymentOrder findMusicGroupApplyOrderByStatus(Integer userId,String musicGroupId, DealStatusEnum status) {
+        return studentPaymentOrderDao.findMusicGroupApplyOrderByStatus(userId,musicGroupId, status);
+    }
+
+    @Override
+    public StudentPaymentOrder findOrderByOrderNo(String orderNo) {
+        return studentPaymentOrderDao.findOrderByOrderNo(orderNo);
+    }
+
 }

+ 2 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java

@@ -140,7 +140,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
 
     @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) {
+    public StudentPaymentOrder addOrder(Integer userId, BigDecimal amount, String orderNo, String paymentChannel, BigDecimal courseFee, List<MusicGroupSubjectGoodsGroup> goodsGroups, List<Goods> goodsList, List<Goods> otherGoodsList, String musicGroupId) {
 
         Date date = new Date();
         StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
@@ -151,6 +151,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
         studentPaymentOrder.setActualAmount(amount);
         studentPaymentOrder.setStatus(DealStatusEnum.ING);
         studentPaymentOrder.setPaymentChannel(paymentChannel);
+        studentPaymentOrder.setMusicGroupId(musicGroupId);
         studentPaymentOrderService.insert(studentPaymentOrder);
 
         ArrayList<StudentPaymentOrderDetail> studentPaymentOrderDetailList = new ArrayList<>();

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

@@ -150,4 +150,13 @@
             LEFT JOIN student_payment_order spo ON svgp.student_payment_order_id_=spo.id_
             WHERE svgp.user_id_=#{userId} AND svgp.vip_group_id_=#{vipGroupId}
     </select>
+    <!-- 查询报名订单 -->
+    <select id="findMusicGroupApplyOrderByStatus" resultMap="StudentPaymentOrder">
+        SELECT * FROM student_payment_order WHERE music_group_id_= #{musicGroupId} AND user_id_=#{userId} AND type_ = 'APPLY' AND status_ = #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
+    </select>
+
+    <!-- 根据订单号查询订单 -->
+    <select id="findOrderByOrderNo" resultMap="StudentPaymentOrder">
+        SELECT * FROM student_payment_order WHERE order_no_ = #{orderNo}
+    </select>
 </mapper>

+ 93 - 2
mec-student/src/main/java/com/ym/mec/student/controller/MusicGroupController.java

@@ -5,8 +5,10 @@ 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.*;
+import com.ym.mec.biz.dal.enums.DealStatusEnum;
 import com.ym.mec.biz.dal.enums.GoodsType;
 import com.ym.mec.biz.dal.enums.KitGroupPurchaseTypeEnum;
+import com.ym.mec.biz.dal.enums.OrderTypeEnum;
 import com.ym.mec.biz.service.*;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
@@ -16,6 +18,7 @@ import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
@@ -97,6 +100,93 @@ public class MusicGroupController extends BaseController {
             return failed("报名信息有误,请核查");
         }
 
+        StudentPaymentOrder ApplyOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, studentRegistration.getMusicGroupId().toString(), DealStatusEnum.SUCCESS);
+        if (ApplyOrder != null) {
+            return failed("您已支付成功,请勿重复支付");
+        }
+
+        //判断用户是否已存在订单
+        ApplyOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, studentRegistration.getMusicGroupId().toString(), DealStatusEnum.ING);
+        if (ApplyOrder != null) {
+            return failed(HttpStatus.CONTINUE, "您有待支付的订单");
+        }
+
+        BigDecimal amount = registerPayDto.getAmount(); //前端获取的价格
+        BigDecimal orderAmount = new BigDecimal("0");
+
+        //获取课程价格
+        MusicGroupSubjectPlan musicOneSubjectClassPlan = musicGroupSubjectPlanService.getMusicOneSubjectClassPlan(studentRegistration.getMusicGroupId(), studentRegistration.getSubjectId());
+        BigDecimal courseFee = musicOneSubjectClassPlan.getFee();
+        orderAmount = orderAmount.add(courseFee);
+
+
+        //乐器及打包辅件
+        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());
+                }
+            }
+        }
+
+        //单独辅件
+        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/api/yqpay/notify", "http://dev.dayaedu.com", "测试订单", "测试订单");
+
+        studentRegistrationService.addOrder(userId, amount, orderNo, "双乾", courseFee, goodsGroups, goodsList, otherGoodsList, studentRegistration.getMusicGroupId().toString());
+
+        return succeed(payMap);
+    }
+
+    @ApiOperation(value = "乐团报名重新支付")
+    @PostMapping("/rePay")
+    @ApiImplicitParams({@ApiImplicitParam(name = "registerPayDto", value = "支付信息", required = true, dataType = "Integer")})
+    public HttpResponseResult rePay(@RequestBody RegisterPayDto registerPayDto) throws Exception {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        Integer userId = sysUser.getId();
+        StudentRegistration studentRegistration = studentRegistrationService.get(registerPayDto.getRegisterId().longValue());
+        if (!studentRegistration.getUserId().equals(userId)) {
+            return failed("报名信息有误,请核查");
+        }
+
+        StudentPaymentOrder ApplyOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, studentRegistration.getMusicGroupId().toString(), DealStatusEnum.SUCCESS);
+        if (ApplyOrder != null) {
+            return failed("您已支付成功,请勿重复支付");
+        }
+
+        //判断用户是否已存在订单
+        ApplyOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, studentRegistration.getMusicGroupId().toString(), DealStatusEnum.ING);
+        if (ApplyOrder == null) {
+            return failed(HttpStatus.CONTINUE, "没有支付中的订单,请勿非法请求");
+        }
+
         BigDecimal amount = registerPayDto.getAmount(); //前端获取的价格
         BigDecimal orderAmount = new BigDecimal("0");
 
@@ -146,7 +236,7 @@ public class MusicGroupController extends BaseController {
 
         Map payMap = payService.getPayMap(orderAmount, orderNo, "https://pay.dayaedu.com/api/yqpay/notify", "http://dev.dayaedu.com", "测试订单", "测试订单");
 
-        studentRegistrationService.addOrder(userId, amount, orderNo, "双乾", courseFee, goodsGroups, goodsList, otherGoodsList);
+        studentRegistrationService.addOrder(userId, amount, orderNo, "双乾", courseFee, goodsGroups, goodsList, otherGoodsList, studentRegistration.getMusicGroupId().toString());
 
         return succeed(payMap);
     }
@@ -165,6 +255,7 @@ public class MusicGroupController extends BaseController {
     @GetMapping("/getOrderStatus")
     @ApiImplicitParams({@ApiImplicitParam(name = "orderNo", value = "订单号", required = true, dataType = "String")})
     public HttpResponseResult getOrderStatus(String orderNo) {
-        return succeed(orderNo);
+        StudentPaymentOrder order = studentPaymentOrderService.findOrderByOrderNo(orderNo);
+        return succeed(order);
     }
 }