浏览代码

批量修改金额与开启缴费

zouxuan 5 年之前
父节点
当前提交
45f9c709ff

+ 14 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderDetailDao.java

@@ -4,6 +4,7 @@ import java.util.List;
 
 
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.dal.BaseDAO;
+import org.apache.ibatis.annotations.Param;
 
 
 public interface MusicGroupPaymentCalenderDetailDao extends BaseDAO<Long, MusicGroupPaymentCalenderDetail> {
 public interface MusicGroupPaymentCalenderDetailDao extends BaseDAO<Long, MusicGroupPaymentCalenderDetail> {
 
 
@@ -13,4 +14,17 @@ public interface MusicGroupPaymentCalenderDetailDao extends BaseDAO<Long, MusicG
 	 * @return
 	 * @return
 	 */
 	 */
 	int batchInsert(List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList);
 	int batchInsert(List<MusicGroupPaymentCalenderDetail> musicGroupPaymentCalenderDetailList);
+
+	/**
+	 * 获取列表
+	 * @param ids
+	 * @return
+	 */
+    List<MusicGroupPaymentCalenderDetail> queryListByIds(@Param("ids") String ids);
+
+	/**
+	 * 批量修改
+	 * @param calenderDetails
+	 */
+	void batchUpdate(@Param("calenderDetails") List<MusicGroupPaymentCalenderDetail> calenderDetails);
 }
 }

+ 8 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/MusicGroupPaymentCalenderDetailService.java

@@ -10,8 +10,14 @@ public interface MusicGroupPaymentCalenderDetailService extends BaseService<Long
     /**
     /**
      * 修改学员预计缴费金额
      * 修改学员预计缴费金额
      * @param actualAmount
      * @param actualAmount
-     * @param id
+     * @param ids
      * @return
      * @return
      */
      */
-    void updateActualAmount(BigDecimal actualAmount, Long id);
+    void updateActualAmount(BigDecimal actualAmount,String ids);
+
+    /**
+     * 开启缴费
+     * @param ids
+     */
+    void openPayment(String ids);
 }
 }

+ 46 - 13
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderDetailServiceImpl.java

@@ -1,20 +1,24 @@
 package com.ym.mec.biz.service.impl;
 package com.ym.mec.biz.service.impl;
 
 
-import com.ym.mec.common.exception.BizException;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
 import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDetailDao;
 import com.ym.mec.biz.dal.dao.MusicGroupPaymentCalenderDetailDao;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
 import com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail;
 import com.ym.mec.biz.service.MusicGroupPaymentCalenderDetailService;
 import com.ym.mec.biz.service.MusicGroupPaymentCalenderDetailService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.dal.BaseDAO;
+import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
 
 
 import java.math.BigDecimal;
 import java.math.BigDecimal;
 import java.util.Date;
 import java.util.Date;
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
 
 
 import static com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus.NON_PAYMENT;
 import static com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus.NON_PAYMENT;
+import static com.ym.mec.biz.dal.entity.MusicGroupStudentFee.PaymentStatus.PROCESSING;
 
 
 @Service
 @Service
 public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<Long, MusicGroupPaymentCalenderDetail>  implements MusicGroupPaymentCalenderDetailService {
 public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<Long, MusicGroupPaymentCalenderDetail>  implements MusicGroupPaymentCalenderDetailService {
@@ -29,19 +33,48 @@ public class MusicGroupPaymentCalenderDetailServiceImpl extends BaseServiceImpl<
 
 
 	@Override
 	@Override
 	@Transactional(rollbackFor = Exception.class)
 	@Transactional(rollbackFor = Exception.class)
-	public void updateActualAmount(BigDecimal actualAmount, Long id) {
-		if(actualAmount == null || id == null){
+	public void updateActualAmount(BigDecimal actualAmount,String ids) {
+		if(actualAmount == null || StringUtils.isEmpty(ids)){
 			throw new BizException("参数校验失败");
 			throw new BizException("参数校验失败");
 		}
 		}
-		MusicGroupPaymentCalenderDetail calenderDetail = musicGroupPaymentCalenderDetailDao.get(id);
-		if(calenderDetail == null){
+		String[] split = ids.split(",");
+		//获取缴费列表
+		List<MusicGroupPaymentCalenderDetail> calenderDetails = musicGroupPaymentCalenderDetailDao.queryListByIds(ids);
+		if(calenderDetails.size() == 0){
 			throw new BizException("缴费记录不存在");
 			throw new BizException("缴费记录不存在");
 		}
 		}
-		if(calenderDetail.getPaymentStatus() == null || calenderDetail.getPaymentStatus() != NON_PAYMENT){
-			throw new BizException("修改失败,缴费状态异常");
+		Date date = new Date();
+		calenderDetails.forEach(e->{
+			if(e.getPaymentStatus() == null || e.getPaymentStatus() != NON_PAYMENT){
+				throw new BizException("修改失败,缴费状态不匹配");
+			}
+			e.setUpdateTime(date);
+			e.setActualAmount(actualAmount);
+		});
+		musicGroupPaymentCalenderDetailDao.batchUpdate(calenderDetails);
+	}
+
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void openPayment(String ids) {
+		if(StringUtils.isEmpty(ids)){
+			throw new BizException("参数校验失败");
+		}
+		//获取缴费列表
+		List<MusicGroupPaymentCalenderDetail> calenderDetails = musicGroupPaymentCalenderDetailDao.queryListByIds(ids);
+		if(calenderDetails.size() == 0){
+			throw new BizException("缴费记录不存在");
 		}
 		}
-		calenderDetail.setActualAmount(actualAmount);
-		calenderDetail.setUpdateTime(new Date());
-		musicGroupPaymentCalenderDetailDao.update(calenderDetail);
+		Date date = new Date();
+		calenderDetails.forEach(e->{
+			if(e.getPaymentStatus() == null || e.getPaymentStatus() != NON_PAYMENT){
+				throw new BizException("修改失败,缴费状态不匹配");
+			}
+			e.setUpdateTime(date);
+			e.setPaymentStatus(PROCESSING);
+		});
+		musicGroupPaymentCalenderDetailDao.batchUpdate(calenderDetails);
+		Set<Integer> studentIds = calenderDetails.stream().map(e -> e.getUserId()).collect(Collectors.toSet());
+		//推送消息
 	}
 	}
 }
 }

+ 35 - 0
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderDetailMapper.xml

@@ -91,6 +91,38 @@
 		</set>
 		</set>
 		WHERE id_ = #{id}
 		WHERE id_ = #{id}
 	</update>
 	</update>
+	<update id="batchUpdate">
+		<foreach collection="calenderDetails" item="item" index="index" open="" close="" separator=";">
+			UPDATE music_group_payment_calender_detail
+			<set>
+				<if test="item.userId != null">
+					user_id_ = #{item.userId},
+				</if>
+				<if test="item.userStatus != null">
+					user_status_ = #{item.userStatus},
+				</if>
+				<if test="item.paymentStatus != null">
+					payment_status_ = #{item.paymentStatus},
+				</if>
+				<if test="item.expectAmount != null">
+					expect_amount_ = #{item.expectAmount},
+				</if>
+				<if test="item.updateTime != null">
+					update_time_ = #{item.updateTime},
+				</if>
+				<if test="item.musicGroupPaymentCalenderId != null">
+					music_group_payment_calender_id_ = #{item.musicGroupPaymentCalenderId},
+				</if>
+				<if test="item.actualAmount != null">
+					actual_amount_ = #{item.actualAmount},
+				</if>
+				<if test="item.payTime != null">
+					pay_time_ = #{item.payTime}
+				</if>
+			</set>
+			WHERE id_ = #{item.id}
+		</foreach>
+	</update>
 
 
 	<!-- 根据主键删除一条记录 -->
 	<!-- 根据主键删除一条记录 -->
 	<delete id="delete">
 	<delete id="delete">
@@ -130,4 +162,7 @@
 			</if>
 			</if>
 		</where>
 		</where>
 	</select>
 	</select>
+	<select id="queryListByIds" resultMap="MusicGroupPaymentCalenderDetail">
+		SELECT * FROM music_group_payment_calender_detail WHERE FIND_IN_SET(id_,#{ids})
+	</select>
 </mapper>
 </mapper>

+ 10 - 2
mec-web/src/main/java/com/ym/mec/web/controller/MusicGroupPaymentCalenderDetailController.java

@@ -32,8 +32,16 @@ public class MusicGroupPaymentCalenderDetailController extends BaseController {
     @ApiOperation(value = "修改学员预计缴费金额")
     @ApiOperation(value = "修改学员预计缴费金额")
     @PostMapping("/updateActualAmount")
     @PostMapping("/updateActualAmount")
     @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalenderDetail/updateActualAmount')")
     @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalenderDetail/updateActualAmount')")
-    public Object updateActualAmount(BigDecimal actualAmount,Long id) {
-        musicGroupPaymentCalenderDetailService.updateActualAmount(actualAmount,id);
+    public Object updateActualAmount(BigDecimal actualAmount,String ids) {
+        musicGroupPaymentCalenderDetailService.updateActualAmount(actualAmount,ids);
+        return succeed();
+    }
+
+    @ApiOperation(value = "开启缴费")
+    @PostMapping("/openPayment")
+    @PreAuthorize("@pcs.hasPermissions('musicGroupPaymentCalenderDetail/openPayment')")
+    public Object openPayment(String ids) {
+        musicGroupPaymentCalenderDetailService.openPayment(ids);
         return succeed();
         return succeed();
     }
     }
 }
 }