Forráskód Böngészése

Merge remote-tracking branch 'origin/master'

Joburgess 5 éve
szülő
commit
1ef546930d

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

@@ -11,6 +11,7 @@ public class RegisterPayDto {
     private String goodsGroupIds;
     private String goodsIds;
     private String otherGoodsIds;
+    Boolean isUseBalancePayment = false;
 
     public Integer getRegisterId() {
         return registerId;
@@ -51,4 +52,12 @@ public class RegisterPayDto {
     public void setOtherGoodsIds(String otherGoodsIds) {
         this.otherGoodsIds = otherGoodsIds;
     }
+
+	public Boolean getIsUseBalancePayment() {
+		return isUseBalancePayment;
+	}
+
+	public void setIsUseBalancePayment(Boolean isUseBalancePayment) {
+		this.isUseBalancePayment = isUseBalancePayment;
+	}
 }

+ 16 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/CooperationOrganQueryInfo.java

@@ -0,0 +1,16 @@
+package com.ym.mec.biz.dal.page;
+
+import com.ym.mec.common.page.QueryInfo;
+
+public class CooperationOrganQueryInfo extends QueryInfo {
+
+    private String organId;
+
+	public String getOrganId() {
+		return organId;
+	}
+
+	public void setOrganId(String organId) {
+		this.organId = organId;
+	}
+}

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/page/SchoolQueryInfo.java

@@ -7,6 +7,8 @@ public class SchoolQueryInfo extends QueryInfo {
 
     @ApiModelProperty(value = "合作单位编号",required = false)
     private Integer cooperationOrganId;
+    
+    private String organId;
 
     public Integer getCooperationOrganId() {
         return cooperationOrganId;
@@ -15,4 +17,12 @@ public class SchoolQueryInfo extends QueryInfo {
     public void setCooperationOrganId(Integer cooperationOrganId) {
         this.cooperationOrganId = cooperationOrganId;
     }
+
+	public String getOrganId() {
+		return organId;
+	}
+
+	public void setOrganId(String organId) {
+		this.organId = organId;
+	}
 }

+ 17 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupService.java

@@ -7,10 +7,13 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import org.springframework.web.bind.annotation.RequestBody;
+
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dto.BasicUserDto;
 import com.ym.mec.biz.dal.dto.CourseScheduleTeachersDto;
 import com.ym.mec.biz.dal.dto.MusicCardDto;
+import com.ym.mec.biz.dal.dto.RegisterPayDto;
 import com.ym.mec.biz.dal.dto.SubFeeSettingDto;
 import com.ym.mec.biz.dal.dto.UpdateExpectedNumDto;
 import com.ym.mec.biz.dal.entity.ApprovalStatus;
@@ -30,6 +33,20 @@ public interface MusicGroupService extends BaseService<String, MusicGroup> {
 	String createGroup(SubFeeSettingDto subFeeSettingDto) throws Exception;
 
 	/**
+	 * 缴费
+	 * @param registerPayDto
+	 * @return
+	 */
+	Map pay(RegisterPayDto registerPayDto) throws Exception;
+
+	/**
+	 * 继续缴费
+	 * @param registerPayDto
+	 * @return
+	 */
+	Map rePay(RegisterPayDto registerPayDto) throws Exception;
+
+	/**
 	 * 获取学生所在乐团详情
 	 * @return
 	 */

+ 291 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -24,6 +24,7 @@ import com.ym.mec.util.http.HttpUtil;
 
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
@@ -125,6 +126,15 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 	
 	@Autowired
     private StudentPaymentOrderDetailDao studentPaymentOrderDetailDao;
+	
+    @Autowired
+    private MusicGroupSubjectPlanService musicGroupSubjectPlanService;
+    @Autowired
+    private StudentRegistrationService studentRegistrationService;
+    @Autowired
+    private MusicGroupSubjectGoodsGroupService musicGroupSubjectGoodsGroupService;
+    @Autowired
+    private GoodsService goodsService;
 
     @Override
     public BaseDAO<String, MusicGroup> getDAO() {
@@ -215,6 +225,285 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
     @Override
     @Transactional(rollbackFor = Exception.class)
+	public Map pay(RegisterPayDto registerPayDto) throws Exception {
+
+        StudentRegistration studentRegistration = studentRegistrationService.get(registerPayDto.getRegisterId().longValue());
+        if (studentRegistration == null) {
+            throw new BizException("报名信息有误,请核查");
+        }
+
+        Integer userId = studentRegistration.getUserId();
+
+        BigDecimal amount = registerPayDto.getAmount(); //前端获取的价格
+        BigDecimal orderAmount = new BigDecimal("0");
+
+        //获取课程价格
+        MusicGroupSubjectPlan musicOneSubjectClassPlan = musicGroupSubjectPlanService.getMusicOneSubjectClassPlan(studentRegistration.getMusicGroupId(), studentRegistration.getActualSubjectId());
+        BigDecimal courseFee = musicOneSubjectClassPlan.getFee();
+        if (studentRegistration.getTemporaryCourseFee() != null) {
+            courseFee = studentRegistration.getTemporaryCourseFee();
+        }
+        orderAmount = orderAmount.add(courseFee);
+
+
+        //乐器及打包辅件
+        List<MusicGroupSubjectGoodsGroup> goodsGroups = new ArrayList<>();
+
+        if (studentRegistration.getTemporaryCourseFee() != null) {
+            List<StudentPaymentOrderDetail> orderDetails = studentPaymentOrderDetailService.findUserApplyOrder(studentRegistration.getUserId(), DealStatusEnum.WAIT_PAY);
+            for (StudentPaymentOrderDetail orderDetail : orderDetails) {
+                if (orderDetail == null || orderDetail.getPrice() == null){
+                    continue;
+                }
+                MusicGroupSubjectGoodsGroup musicGroupSubjectGoodsGroup = new MusicGroupSubjectGoodsGroup();
+                GoodsType goodsType = orderDetail.getType().equals(OrderDetailTypeEnum.MUSICAL) ? GoodsType.INSTRUMENT : GoodsType.ACCESSORIES;
+                musicGroupSubjectGoodsGroup.setType(goodsType);
+                musicGroupSubjectGoodsGroup.setGoodsIdList(orderDetail.getGoodsIdList());
+                musicGroupSubjectGoodsGroup.setPrice(orderDetail.getPrice());
+
+                goodsGroups.add(musicGroupSubjectGoodsGroup);
+
+                orderAmount = orderAmount.add(orderDetail.getPrice());
+            }
+        } else if (registerPayDto.getGoodsGroupIds() != null && !registerPayDto.getGoodsGroupIds().equals("")) {
+            goodsGroups = musicGroupSubjectGoodsGroupService.findGoodsGroupByIds(registerPayDto.getGoodsGroupIds());
+            for (MusicGroupSubjectGoodsGroup goodsGroup : goodsGroups) {
+                if (goodsGroup.getType().equals(GoodsType.INSTRUMENT) && musicOneSubjectClassPlan.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.LEASE)) {
+                    orderAmount = orderAmount.add(musicOneSubjectClassPlan.getDepositFee());
+                    continue;
+                }
+                if (goodsGroup.getType().equals(GoodsType.INSTRUMENT) && musicOneSubjectClassPlan.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.FREE)) {
+                    continue;
+                }
+                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) {
+            throw new BizException("商品价格不符");
+        }
+
+        String orderNo = idGeneratorService.generatorId("payment") + "";
+        
+        String channelType = "";
+
+        StudentPaymentOrder studentPaymentOrder = studentRegistrationService.addOrder(studentRegistration, amount, orderNo, channelType, courseFee, goodsGroups, goodsList, otherGoodsList);
+
+        Date date = new Date();
+        
+        if(registerPayDto.getIsUseBalancePayment() || amount.doubleValue() == 0){
+        	SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(userId);
+        	if(userCashAccount == null){
+        		throw new BizException("用户账户找不到");
+        	}
+        	if(userCashAccount.getBalance().subtract(amount).doubleValue() > 0){
+        		// 更新订单信息
+        		studentPaymentOrder.setBalancePaymentAmount(amount);
+                studentPaymentOrder.setStatus(DealStatusEnum.SUCCESS);
+                studentPaymentOrder.setUpdateTime(date);
+                studentPaymentOrderService.update(studentPaymentOrder);
+                
+        		sysUserCashAccountService.updateBalance(userId, amount.negate(),PlatformCashAccountDetailTypeEnum.PAY_FEE,"乐团续费");
+        		
+        		//更新下次续费时间
+        		/*musicGroupStudentFee.setUpdateTime(date);
+                musicGroupStudentFee.setLatestPaidTime(date);
+                musicGroupStudentFee.setPaymentStatus(PaymentStatus.PAID_COMPLETED);
+                musicGroupStudentFee.setTemporaryCourseFee(new BigDecimal(0));
+                musicGroupStudentFee.setNextPaymentDate(musicGroupPaymentCalenderService.getNextPaymentDate(musicGroupId));
+                musicGroupStudentFeeDao.update(musicGroupStudentFee);*/
+                
+        		return null;
+        	}else{
+				if (userCashAccount.getBalance().doubleValue() > 0) {
+					sysUserCashAccountService.updateBalance(userId, userCashAccount.getBalance().negate(), PlatformCashAccountDetailTypeEnum.PAY_FEE, "乐团续费");
+					amount = amount.subtract(userCashAccount.getBalance());
+					studentPaymentOrder.setBalancePaymentAmount(userCashAccount.getBalance());
+				} else {
+					studentPaymentOrder.setBalancePaymentAmount(new BigDecimal(0));
+				}
+        	}
+        }
+        
+
+        Map payMap = payService.getPayMap(
+                orderAmount,
+                orderNo,
+                "http://mstudev.dayaedu.com/api-student/studentOrder/notify",
+                "http://mstudev.dayaedu.com/#/paymentresult?orderNo=" + orderNo,
+                "测试订单",
+                "测试订单");
+        
+        studentPaymentOrder.setPaymentChannel((String) payMap.get("type"));
+        studentPaymentOrder.setUpdateTime(date);
+        studentPaymentOrderService.update(studentPaymentOrder);
+        
+		return payMap;
+	}
+
+	@Override
+    @Transactional(rollbackFor = Exception.class)
+	public Map rePay(RegisterPayDto registerPayDto) throws Exception {
+		StudentRegistration studentRegistration = studentRegistrationService.get(registerPayDto.getRegisterId().longValue());
+        if (studentRegistration == null) {
+            throw new BizException("报名信息有误,请核查");
+        }
+
+        Integer userId = studentRegistration.getUserId();
+        
+        StudentPaymentOrder ApplyOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, studentRegistration.getMusicGroupId().toString(), DealStatusEnum.ING);
+        if (ApplyOrder == null) {
+            throw new BizException("没有支付中的订单,请勿非法请求");
+        }
+
+        BigDecimal amount = registerPayDto.getAmount(); //前端获取的价格
+        BigDecimal orderAmount = new BigDecimal("0");
+
+        //获取课程价格
+        MusicGroupSubjectPlan musicOneSubjectClassPlan = musicGroupSubjectPlanService.getMusicOneSubjectClassPlan(studentRegistration.getMusicGroupId(), studentRegistration.getActualSubjectId());
+        BigDecimal courseFee = musicOneSubjectClassPlan.getFee();
+        if (studentRegistration.getTemporaryCourseFee() != null) {
+            courseFee = studentRegistration.getTemporaryCourseFee();
+        }
+        orderAmount = orderAmount.add(courseFee);
+
+
+        //乐器及打包辅件
+        List<MusicGroupSubjectGoodsGroup> goodsGroups = new ArrayList<>();
+        if (studentRegistration.getTemporaryCourseFee() != null) {
+            List<StudentPaymentOrderDetail> orderDetails = studentPaymentOrderDetailService.findUserApplyOrder(studentRegistration.getUserId(), DealStatusEnum.WAIT_PAY);
+            for (StudentPaymentOrderDetail orderDetail : orderDetails) {
+                if (orderDetail == null || orderDetail.getPrice() == null){
+                    continue;
+                }
+                MusicGroupSubjectGoodsGroup musicGroupSubjectGoodsGroup = new MusicGroupSubjectGoodsGroup();
+                GoodsType goodsType = orderDetail.getType().equals(OrderDetailTypeEnum.MUSICAL) ? GoodsType.INSTRUMENT : GoodsType.ACCESSORIES;
+                musicGroupSubjectGoodsGroup.setType(goodsType);
+                musicGroupSubjectGoodsGroup.setGoodsIdList(orderDetail.getGoodsIdList());
+                musicGroupSubjectGoodsGroup.setPrice(orderDetail.getPrice());
+                goodsGroups.add(musicGroupSubjectGoodsGroup);
+                orderAmount = orderAmount.add(orderDetail.getPrice());
+            }
+        } else if (registerPayDto.getGoodsGroupIds() != null && !registerPayDto.getGoodsGroupIds().equals("")) {
+            goodsGroups = musicGroupSubjectGoodsGroupService.findGoodsGroupByIds(registerPayDto.getGoodsGroupIds());
+            for (MusicGroupSubjectGoodsGroup goodsGroup : goodsGroups) {
+                if (goodsGroup.getType().equals(GoodsType.INSTRUMENT) && musicOneSubjectClassPlan.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.LEASE)) {
+                    orderAmount = orderAmount.add(musicOneSubjectClassPlan.getDepositFee());
+                    continue;
+                }
+                if (goodsGroup.getType().equals(GoodsType.INSTRUMENT) && musicOneSubjectClassPlan.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.FREE)) {
+                    continue;
+                }
+
+                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) {
+            throw new BizException("商品价格不符");
+        }
+
+        String orderNo = idGeneratorService.generatorId("payment") + "";
+        
+        String channelType = "";
+
+        StudentPaymentOrder studentPaymentOrder = studentRegistrationService.reAddOrder(userId, amount, orderNo, channelType, courseFee, goodsGroups, goodsList, otherGoodsList, studentRegistration.getMusicGroupId(), ApplyOrder);
+
+        Date date = new Date();
+        
+        if(registerPayDto.getIsUseBalancePayment() || amount.doubleValue() == 0){
+        	SysUserCashAccount userCashAccount = sysUserCashAccountService.getLocked(userId);
+        	if(userCashAccount == null){
+        		throw new BizException("用户账户找不到");
+        	}
+        	if(userCashAccount.getBalance().subtract(amount).doubleValue() > 0){
+        		// 更新订单信息
+        		studentPaymentOrder.setBalancePaymentAmount(amount);
+                studentPaymentOrder.setStatus(DealStatusEnum.SUCCESS);
+                studentPaymentOrder.setUpdateTime(date);
+                studentPaymentOrderService.update(studentPaymentOrder);
+                
+        		sysUserCashAccountService.updateBalance(userId, amount.negate(),PlatformCashAccountDetailTypeEnum.PAY_FEE,"乐团续费");
+        		
+        		//更新下次续费时间
+        		/*musicGroupStudentFee.setUpdateTime(date);
+                musicGroupStudentFee.setLatestPaidTime(date);
+                musicGroupStudentFee.setPaymentStatus(PaymentStatus.PAID_COMPLETED);
+                musicGroupStudentFee.setTemporaryCourseFee(new BigDecimal(0));
+                musicGroupStudentFee.setNextPaymentDate(musicGroupPaymentCalenderService.getNextPaymentDate(musicGroupId));
+                musicGroupStudentFeeDao.update(musicGroupStudentFee);*/
+                
+        		return null;
+        	}else{
+				if (userCashAccount.getBalance().doubleValue() > 0) {
+					sysUserCashAccountService.updateBalance(userId, userCashAccount.getBalance().negate(), PlatformCashAccountDetailTypeEnum.PAY_FEE, "乐团续费");
+					amount = amount.subtract(userCashAccount.getBalance());
+					studentPaymentOrder.setBalancePaymentAmount(userCashAccount.getBalance());
+				} else {
+					studentPaymentOrder.setBalancePaymentAmount(new BigDecimal(0));
+				}
+        	}
+        }
+
+        Map payMap = payService.getPayMap(
+                orderAmount,
+                orderNo,
+                "http://mstudev.dayaedu.com/api-student/studentOrder/notify",
+                "http://mstudev.dayaedu.com/#/paymentresult?orderNo=" + orderNo,
+                "测试订单",
+                "测试订单");
+        
+        studentPaymentOrder.setPaymentChannel((String) payMap.get("type"));
+        studentPaymentOrder.setUpdateTime(date);
+        studentPaymentOrderService.update(studentPaymentOrder);
+        
+		return payMap;
+	}
+
+	@Override
+    @Transactional(rollbackFor = Exception.class)
     public void updateSubjectInfo(SubFeeSettingDto subFeeSettingDto) throws Exception {
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         if(sysUser == null){
@@ -777,7 +1066,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         studentPaymentOrder.setMusicGroupId(musicGroupId);
         studentPaymentOrder.setCreateTime(date);
         studentPaymentOrder.setUpdateTime(date);
-        studentPaymentOrder.setVersion(1);
+        studentPaymentOrder.setVersion(0);
         studentPaymentOrderService.insert(studentPaymentOrder);
 
         ArrayList<StudentPaymentOrderDetail> studentPaymentOrderDetailList = new ArrayList<>();
@@ -826,7 +1115,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         }
 
         try {
-            Map<String, Object> payMap = payService.getPayMap(amount, idGeneratorService.generatorId("payment") + "", "https://pay.dayaedu.com/api/yqpay/notify",
+            Map<String, Object> payMap = payService.getPayMap(amount, studentPaymentOrder.getOrderNo(), "https://pay.dayaedu.com/api/yqpay/notify",
                     "http://dev.dayaedu.com", "续费", "乐团续费");
             studentPaymentOrder.setPaymentChannel((String) payMap.get("type"));
             studentPaymentOrder.setUpdateTime(date);

+ 11 - 5
mec-biz/src/main/resources/config/mybatis/CooperationOrganMapper.xml

@@ -25,7 +25,7 @@
 
     <!-- 全查询 -->
     <select id="findAll" resultMap="CooperationOrgan">
-		SELECT * FROM cooperation_organ AND del_flag_ = 0
+		SELECT * FROM cooperation_organ AND del_flag_ != 1
 		ORDER BY id_
 	</select>
 
@@ -79,10 +79,13 @@
             parameterType="map">
         SELECT * FROM cooperation_organ
         <where>
-                del_flag_ = 0
+                del_flag_ != 1
             <if test="search != null">
                 AND FIND_IN_SET(organ_id_,#{search})
             </if>
+	        <if test="organId != null">
+	            AND FIND_IN_SET(organ_id_,#{organId})
+	        </if>
         </where>
         ORDER BY update_time_ DESC
         <include refid="global.limit"/>
@@ -92,19 +95,22 @@
     <select id="queryCount" resultType="int">
 		SELECT COUNT(*) FROM cooperation_organ
         <where>
-            del_flag_ = 0
+            del_flag_ != 1
             <if test="search != null">
                 AND organ_id_ = #{search}
             </if>
+	        <if test="organId != null">
+	            AND FIND_IN_SET(organ_id_,#{organId})
+	        </if>
         </where>
 	</select>
 
     <select id="queryByOrganId" resultMap="CooperationOrgan">
-        SELECT * FROM cooperation_organ WHERE FIND_IN_SET(organ_id_,#{organId}) AND del_flag_ = 0
+        SELECT * FROM cooperation_organ WHERE FIND_IN_SET(organ_id_,#{organId}) AND del_flag_ != 1
     </select>
 
     <select id="queryNameByIds" resultType="java.util.Map">
         SELECT co.id_ 'key',co.name_ 'value' FROM cooperation_organ co
-        WHERE FIND_IN_SET(co.id_,#{organIds}) AND co.del_flag_ = 0
+        WHERE FIND_IN_SET(co.id_,#{organIds}) AND co.del_flag_ != 1
     </select>
 </mapper>

+ 12 - 6
mec-biz/src/main/resources/config/mybatis/SchoolMapper.xml

@@ -92,36 +92,42 @@
 
     <!-- 分页查询 -->
     <select id="queryPage" resultMap="School" parameterType="map">
-        SELECT * FROM school where del_flag_ = 0
+        SELECT * FROM school where del_flag_ != 1
         <if test="cooperationOrganId != null">
             AND cooperation_organ_id_ = #{cooperationOrganId}
         </if>
+        <if test="organId != null">
+            AND FIND_IN_SET(organ_id_,#{organId})
+        </if>
         ORDER BY id_
         <include refid="global.limit"/>
     </select>
 
     <!-- 查询当前表的总记录数 -->
     <select id="queryCount" resultType="int">
-		SELECT COUNT(*) FROM school where del_flag_ = 0
+		SELECT COUNT(*) FROM school where del_flag_ != 1
         <if test="cooperationOrganId != null">
             AND cooperation_organ_id_ = #{cooperationOrganId}
         </if>
+        <if test="organId != null">
+            AND FIND_IN_SET(organ_id_,#{organId})
+        </if>
 	</select>
     <select id="queryByOrganId" resultMap="School">
         SELECT * FROM school
         <where>
-            del_flag_ = 0
+            del_flag_ != 1
             <if test="organId != null">
                 AND FIND_IN_SET(organ_id_,#{organId})
             </if>
         </where>
     </select>
     <select id="queryNameByIds" resultType="java.util.Map" >
-        select id_ `key`,name_ `value` FROM school s WHERE FIND_IN_SET(id_,#{schoolIds}) AND s.del_flag_ = 0
+        select id_ `key`,name_ `value` FROM school s WHERE FIND_IN_SET(id_,#{schoolIds}) AND s.del_flag_ != 1
     </select>
     
     <select id="findByUserId" resultMap="School">
-        select * from school where del_flag_ = 0 and user_id_ = #{userId}
+        select * from school where del_flag_ != 1 and user_id_ = #{userId}
     </select>
     <select id="findVipSchoolByUserId" resultMap="School">
         SELECT
@@ -129,7 +135,7 @@
         FROM
             school
         WHERE
-            del_flag_ = 0
+            del_flag_ != 1
             <if test="isDefault==null">
                 AND ( user_id_ IS NULL OR user_id_ = #{userId} )
             </if>

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

@@ -6,10 +6,8 @@ import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 
 import java.math.BigDecimal;
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
-import java.util.Map;
 import java.util.Objects;
 
 import javax.annotation.Resource;
@@ -32,15 +30,10 @@ import com.ym.mec.biz.dal.entity.Goods;
 import com.ym.mec.biz.dal.entity.MusicGroup;
 import com.ym.mec.biz.dal.entity.MusicGroupStudentFee;
 import com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus;
-import com.ym.mec.biz.dal.entity.MusicGroupSubjectGoodsGroup;
 import com.ym.mec.biz.dal.entity.MusicGroupSubjectPlan;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
-import com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail;
 import com.ym.mec.biz.dal.entity.StudentRegistration;
 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.OrderDetailTypeEnum;
 import com.ym.mec.biz.dal.enums.PaymentStatusEnum;
 import com.ym.mec.biz.service.GoodsService;
 import com.ym.mec.biz.service.MusicGroupService;
@@ -246,90 +239,7 @@ public class MusicGroupController extends BaseController {
             return failed(HttpStatus.CONTINUE, "您有待支付的订单");
         }
 
-        BigDecimal amount = registerPayDto.getAmount(); //前端获取的价格
-        BigDecimal orderAmount = new BigDecimal("0");
-
-        //获取课程价格
-        MusicGroupSubjectPlan musicOneSubjectClassPlan = musicGroupSubjectPlanService.getMusicOneSubjectClassPlan(studentRegistration.getMusicGroupId(), studentRegistration.getActualSubjectId());
-        BigDecimal courseFee = musicOneSubjectClassPlan.getFee();
-        if (studentRegistration.getTemporaryCourseFee() != null) {
-            courseFee = studentRegistration.getTemporaryCourseFee();
-        }
-        orderAmount = orderAmount.add(courseFee);
-
-
-        //乐器及打包辅件
-        List<MusicGroupSubjectGoodsGroup> goodsGroups = new ArrayList<>();
-
-        if (studentRegistration.getTemporaryCourseFee() != null) {
-            List<StudentPaymentOrderDetail> orderDetails = studentPaymentOrderDetailService.findUserApplyOrder(studentRegistration.getUserId(), DealStatusEnum.WAIT_PAY);
-            for (StudentPaymentOrderDetail orderDetail : orderDetails) {
-                if (orderDetail == null || orderDetail.getPrice() == null){
-                    continue;
-                }
-                MusicGroupSubjectGoodsGroup musicGroupSubjectGoodsGroup = new MusicGroupSubjectGoodsGroup();
-                GoodsType goodsType = orderDetail.getType().equals(OrderDetailTypeEnum.MUSICAL) ? GoodsType.INSTRUMENT : GoodsType.ACCESSORIES;
-                musicGroupSubjectGoodsGroup.setType(goodsType);
-                musicGroupSubjectGoodsGroup.setGoodsIdList(orderDetail.getGoodsIdList());
-                musicGroupSubjectGoodsGroup.setPrice(orderDetail.getPrice());
-
-                goodsGroups.add(musicGroupSubjectGoodsGroup);
-
-                orderAmount = orderAmount.add(orderDetail.getPrice());
-            }
-        } else if (registerPayDto.getGoodsGroupIds() != null && !registerPayDto.getGoodsGroupIds().equals("")) {
-            goodsGroups = musicGroupSubjectGoodsGroupService.findGoodsGroupByIds(registerPayDto.getGoodsGroupIds());
-            for (MusicGroupSubjectGoodsGroup goodsGroup : goodsGroups) {
-                if (goodsGroup.getType().equals(GoodsType.INSTRUMENT) && musicOneSubjectClassPlan.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.LEASE)) {
-                    orderAmount = orderAmount.add(musicOneSubjectClassPlan.getDepositFee());
-                    continue;
-                }
-                if (goodsGroup.getType().equals(GoodsType.INSTRUMENT) && musicOneSubjectClassPlan.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.FREE)) {
-                    continue;
-                }
-                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("商品价格不符");
-        }
-
-
-        String orderNo = idGeneratorService.generatorId("payment") + "";
-
-        Map payMap = payService.getPayMap(
-                orderAmount,
-                orderNo,
-                "http://mstudev.dayaedu.com/api-student/studentOrder/notify",
-                "http://mstudev.dayaedu.com/#/paymentresult?orderNo=" + orderNo,
-                "测试订单",
-                "测试订单");
-
-        studentRegistrationService.addOrder(studentRegistration, amount, orderNo, (String) payMap.get("type"), courseFee, goodsGroups, goodsList, otherGoodsList);
-
-        return succeed(payMap);
+        return succeed(musicGroupService.pay(registerPayDto));
     }
 
     @ApiOperation(value = "乐团报名重新支付")
@@ -348,93 +258,7 @@ public class MusicGroupController extends BaseController {
             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.getActualSubjectId());
-        BigDecimal courseFee = musicOneSubjectClassPlan.getFee();
-        if (studentRegistration.getTemporaryCourseFee() != null) {
-            courseFee = studentRegistration.getTemporaryCourseFee();
-        }
-        orderAmount = orderAmount.add(courseFee);
-
-
-        //乐器及打包辅件
-        List<MusicGroupSubjectGoodsGroup> goodsGroups = new ArrayList<>();
-        if (studentRegistration.getTemporaryCourseFee() != null) {
-            List<StudentPaymentOrderDetail> orderDetails = studentPaymentOrderDetailService.findUserApplyOrder(studentRegistration.getUserId(), DealStatusEnum.WAIT_PAY);
-            for (StudentPaymentOrderDetail orderDetail : orderDetails) {
-                if (orderDetail == null || orderDetail.getPrice() == null){
-                    continue;
-                }
-                MusicGroupSubjectGoodsGroup musicGroupSubjectGoodsGroup = new MusicGroupSubjectGoodsGroup();
-                GoodsType goodsType = orderDetail.getType().equals(OrderDetailTypeEnum.MUSICAL) ? GoodsType.INSTRUMENT : GoodsType.ACCESSORIES;
-                musicGroupSubjectGoodsGroup.setType(goodsType);
-                musicGroupSubjectGoodsGroup.setGoodsIdList(orderDetail.getGoodsIdList());
-                musicGroupSubjectGoodsGroup.setPrice(orderDetail.getPrice());
-                goodsGroups.add(musicGroupSubjectGoodsGroup);
-                orderAmount = orderAmount.add(orderDetail.getPrice());
-            }
-        } else if (registerPayDto.getGoodsGroupIds() != null && !registerPayDto.getGoodsGroupIds().equals("")) {
-            goodsGroups = musicGroupSubjectGoodsGroupService.findGoodsGroupByIds(registerPayDto.getGoodsGroupIds());
-            for (MusicGroupSubjectGoodsGroup goodsGroup : goodsGroups) {
-                if (goodsGroup.getType().equals(GoodsType.INSTRUMENT) && musicOneSubjectClassPlan.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.LEASE)) {
-                    orderAmount = orderAmount.add(musicOneSubjectClassPlan.getDepositFee());
-                    continue;
-                }
-                if (goodsGroup.getType().equals(GoodsType.INSTRUMENT) && musicOneSubjectClassPlan.getKitGroupPurchaseType().equals(KitGroupPurchaseTypeEnum.FREE)) {
-                    continue;
-                }
-
-                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("商品价格不符");
-        }
-
-        String orderNo = idGeneratorService.generatorId("payment") + "";
-
-        Map payMap = payService.getPayMap(
-                orderAmount,
-                orderNo,
-                "http://mstudev.dayaedu.com/api-student/studentOrder/notify",
-                "http://mstudev.dayaedu.com/#/paymentresult?orderNo=" + orderNo,
-                "测试订单",
-                "测试订单");
-
-        studentRegistrationService.reAddOrder(userId, amount, orderNo, (String) payMap.get("type"), courseFee, goodsGroups, goodsList, otherGoodsList, studentRegistration.getMusicGroupId(), ApplyOrder);
-
-        return succeed(payMap);
+        return succeed(musicGroupService.rePay(registerPayDto));
     }
 
     @ApiOperation(value = "订单状态查询")

+ 41 - 8
mec-web/src/main/java/com/ym/mec/web/controller/CooperationOrganController.java

@@ -1,19 +1,31 @@
 package com.ym.mec.web.controller;
 
-import com.ym.mec.biz.dal.entity.CooperationOrgan;
-import com.ym.mec.biz.service.CooperationOrganService;
-import com.ym.mec.common.controller.BaseController;
-import com.ym.mec.common.page.QueryInfo;
-
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
 
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
-import java.util.Date;
+import com.ym.mec.auth.api.client.SysUserFeignService;
+import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.dao.EmployeeDao;
+import com.ym.mec.biz.dal.entity.CooperationOrgan;
+import com.ym.mec.biz.dal.entity.Employee;
+import com.ym.mec.biz.dal.page.CooperationOrganQueryInfo;
+import com.ym.mec.biz.service.CooperationOrganService;
+import com.ym.mec.common.controller.BaseController;
 
 @RequestMapping("cooperationOrgan")
 @Api(tags = "合作单位(教学点)服务")
@@ -22,6 +34,10 @@ public class CooperationOrganController extends BaseController {
 
     @Autowired
     private CooperationOrganService cooperationOrganService;
+    @Autowired
+    private EmployeeDao employeeDao;
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
 
     @ApiOperation(value = "新增合作单位(教学点)")
     @PostMapping("/add")
@@ -51,7 +67,24 @@ public class CooperationOrganController extends BaseController {
     @ApiOperation(value = "分页查询合作单位(教学点)列表")
     @GetMapping("/queryPage")
     @PreAuthorize("@pcs.hasPermissions('cooperationOrgan/queryPage')")
-    public Object queryPage(QueryInfo queryInfo) {
+    public Object queryPage(CooperationOrganQueryInfo queryInfo) {
+		SysUser sysUser = sysUserFeignService.queryUserInfo();
+		if (sysUser == null) {
+			return failed("用户信息获取失败");
+		}
+		if(!sysUser.getIsSuperAdmin()){
+			Employee employee = employeeDao.get(sysUser.getId());
+			if (StringUtils.isEmpty(queryInfo.getOrganId())) {
+				queryInfo.setOrganId(employee.getOrganIdList());
+			}else if(StringUtils.isEmpty(employee.getOrganIdList())){
+				return failed("用户所在分部异常");
+			}else {
+				List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
+				if(!list.containsAll(Arrays.asList(queryInfo.getOrganId().split(",")))){
+					return failed("非法请求");
+				}
+			}
+		}
         return succeed(cooperationOrganService.queryPage(queryInfo));
     }
 

+ 19 - 0
mec-web/src/main/java/com/ym/mec/web/controller/SchoolController.java

@@ -8,9 +8,11 @@ import com.ym.mec.biz.dal.entity.School;
 import com.ym.mec.biz.dal.page.SchoolQueryInfo;
 import com.ym.mec.biz.service.SchoolService;
 import com.ym.mec.common.controller.BaseController;
+
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
+
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -68,6 +70,23 @@ public class SchoolController extends BaseController {
     @GetMapping("/queryPage")
     @PreAuthorize("@pcs.hasPermissions('school/queryPage')")
     public Object queryPage(SchoolQueryInfo queryInfo){
+		SysUser sysUser = sysUserFeignService.queryUserInfo();
+		if (sysUser == null) {
+			return failed("用户信息获取失败");
+		}
+		if(!sysUser.getIsSuperAdmin()){
+			Employee employee = employeeDao.get(sysUser.getId());
+			if (StringUtils.isEmpty(queryInfo.getOrganId())) {
+				queryInfo.setOrganId(employee.getOrganIdList());
+			}else if(StringUtils.isEmpty(employee.getOrganIdList())){
+				return failed("用户所在分部异常");
+			}else {
+				List<String> list = Arrays.asList(employee.getOrganIdList().split(","));
+				if(!list.containsAll(Arrays.asList(queryInfo.getOrganId().split(",")))){
+					return failed("非法请求");
+				}
+			}
+		}
         return succeed(schoolService.queryPage(queryInfo));
     }