Browse Source

Merge remote-tracking branch 'origin/master'

Joburgess 5 years ago
parent
commit
d4fffcd08e
22 changed files with 528 additions and 81 deletions
  1. 14 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderDao.java
  2. 7 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/MusicGroupPaymentCalenderDetailDao.java
  3. 8 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/dao/TeacherDao.java
  4. 16 1
      mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentPaymentRouteOrder.java
  5. 10 0
      mec-biz/src/main/java/com/ym/mec/biz/dal/page/SysPaymentConfigQueryInfo.java
  6. 2 1
      mec-biz/src/main/java/com/ym/mec/biz/service/StudentPaymentRouteOrderService.java
  7. 7 4
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java
  8. 19 4
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java
  9. 70 17
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/PayServiceImpl.java
  10. 18 6
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentManageServiceImpl.java
  11. 85 21
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentRouteOrderServiceImpl.java
  12. 8 2
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderDetailMapper.xml
  13. 13 1
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderMapper.xml
  14. 15 15
      mec-biz/src/main/resources/config/mybatis/StudentPaymentRouteOrderMapper.xml
  15. 3 0
      mec-biz/src/main/resources/config/mybatis/SysPaymentConfigMapper.xml
  16. 3 0
      mec-biz/src/main/resources/config/mybatis/TeacherMapper.xml
  17. 177 0
      mec-thirdparty/src/main/java/com/ym/mec/thirdparty/eseal/provider/BytedancePlugin.java
  18. 24 0
      mec-util/src/main/java/com/ym/mec/util/sort/SortUtil.java
  19. 1 1
      mec-web/src/main/java/com/ym/mec/web/controller/ImportController.java
  20. 26 8
      mec-web/src/main/java/com/ym/mec/web/controller/SysPaymentConfigController.java
  21. 2 0
      mec-web/src/main/resources/columnMapper.ini
  22. BIN
      mec-web/src/main/resources/excelTemplate/财务管理导入模板.xlsx

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

@@ -256,4 +256,18 @@ public interface MusicGroupPaymentCalenderDao extends BaseDAO<Long, MusicGroupPa
      * @return java.util.List<java.util.Map<java.lang.Integer,java.lang.String>>
      */
     List<Map<Integer,String>> queryUserCoursePaymentStatus(@Param("studentId") Set studentId, @Param("musicGroupId") String musicGroupId);
+
+    /**
+     * 删除未缴费的缴费项
+     * @author zouxuan
+     * @param userId
+     */
+    void delStudentNoPaymentCalender(@Param("userId") Integer userId, @Param("musicGroupId") String musicGroupId);
+
+    /**
+     * 缴费预计人数减一
+     * @author
+     * @param userId
+     */
+    void cutCalenderExpectNum(@Param("userId") Integer userId, @Param("musicGroupId") String musicGroupId);
 }

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

@@ -205,4 +205,11 @@ public interface MusicGroupPaymentCalenderDetailDao extends BaseDAO<Long, MusicG
 	 * @return com.ym.mec.biz.dal.entity.MusicGroupPaymentCalenderDetail
 	 */
 	MusicGroupPaymentCalenderDetail findByOrderId(@Param("orderId") Long orderId);
+
+	/**
+	 * 删除未缴费的详情
+	 * @author
+	 * @param userId
+	 */
+    void delStudentNoPaymentCalenderDetail(@Param("userId") Integer userId, @Param("musicGroupId") String musicGroupId);
 }

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/TeacherDao.java

@@ -476,4 +476,12 @@ public interface TeacherDao extends BaseDAO<Integer, Teacher> {
     List<TeacherDefaultSalaryDto> queryTeacherDefaultSalary(@Param("organIdList") String organIdList);
 
     BasicUserDto findUserByPhone(String phone);
+
+    /**
+     * 是否存在该userId
+     * @Author zouxuan
+     * @param userId
+     * @return
+     */
+    Boolean existUser(@Param("userId") Object userId);
 }

+ 16 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/entity/StudentPaymentRouteOrder.java

@@ -7,6 +7,8 @@ import com.alibaba.fastjson.JSONObject;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.enums.AuditStatusEnum;
 
+import static com.ym.mec.biz.dal.enums.AuditStatusEnum.ING;
+
 public class StudentPaymentRouteOrder {
     private Long id;
 
@@ -39,6 +41,11 @@ public class StudentPaymentRouteOrder {
     * 是否承担手续费Y-是 N-否
     */
     private String feeFlag;
+
+    /**
+    * 销售类型   销售收入/服务收入
+    */
+    private String incomeType;
     
     private Integer userId;
     
@@ -60,7 +67,7 @@ public class StudentPaymentRouteOrder {
 
     private String goodsJson;
     
-    private AuditStatusEnum auditStatus;
+    private AuditStatusEnum auditStatus = ING;
     
     private String auditComment;
     
@@ -80,6 +87,14 @@ public class StudentPaymentRouteOrder {
     
     private Organization organ = new Organization();
 
+	public String getIncomeType() {
+		return incomeType;
+	}
+
+	public void setIncomeType(String incomeType) {
+		this.incomeType = incomeType;
+	}
+
 	public String getGoodsIds() {
 		return goodsIds;
 	}

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

@@ -17,6 +17,8 @@ public class SysPaymentConfigQueryInfo extends QueryInfo {
     @ApiModelProperty(value = "是否设置按费用类型分润 1-是 0 -否", required = true)
     private Integer hasTypeRoute;
 
+    private Integer hasRouteScale;
+
     public Integer getOrganId() {
         return organId;
     }
@@ -32,4 +34,12 @@ public class SysPaymentConfigQueryInfo extends QueryInfo {
     public void setHasTypeRoute(Integer hasTypeRoute) {
         this.hasTypeRoute = hasTypeRoute;
     }
+
+    public Integer getHasRouteScale() {
+        return hasRouteScale;
+    }
+
+    public void setHasRouteScale(Integer hasRouteScale) {
+        this.hasRouteScale = hasRouteScale;
+    }
 }

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

@@ -9,6 +9,7 @@ import com.ym.mec.biz.dal.dto.StudentPaymentRouteOrderDto;
 import com.ym.mec.biz.dal.entity.StudentPaymentRouteOrder;
 import com.ym.mec.biz.dal.enums.AuditStatusEnum;
 import com.ym.mec.biz.dal.page.StudentPaymentOrderQueryInfo;
+import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.page.QueryInfo;
 import com.ym.mec.common.service.BaseService;
@@ -72,5 +73,5 @@ public interface StudentPaymentRouteOrderService extends BaseService<Long, Stude
 	 * @param file
 	 * @return
 	 */
-    List<StudentPaymentRouteOrder> importRouteOrder(MultipartFile file) throws Exception;
+	HttpResponseResult<List<StudentPaymentRouteOrder>> importRouteOrder(MultipartFile file) throws Exception;
 }

+ 7 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupPaymentCalenderServiceImpl.java

@@ -228,9 +228,12 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		// 设置批次号
 		musicGroupPaymentCalender.setBatchNo(idGeneratorService.generatorId() + "");
 		musicGroupPaymentCalenderDao.insert(musicGroupPaymentCalender);
-		//如果是进行中加学生
-		if (musicGroupPaymentCalender.getPaymentType() == PaymentType.ADD_STUDENT) {
-			addStudent(musicGroupPaymentCalender,musicGroupPaymentCalenderCourseSettingsList);
+		
+		if (musicGroupPaymentCalender.getStatus() != PaymentCalenderStatusEnum.AUDITING) {
+			// 如果是进行中加学生
+			if (musicGroupPaymentCalender.getPaymentType() == PaymentType.ADD_STUDENT) {
+				addStudent(musicGroupPaymentCalender, musicGroupPaymentCalenderCourseSettingsList);
+			}
 		}
 
 		if (musicGroupPaymentCalenderCourseSettingsList.size() > 0) {
@@ -262,7 +265,7 @@ public class MusicGroupPaymentCalenderServiceImpl extends BaseServiceImpl<Long,
 		//收费标准名称
 		String name = musicGroupPaymentCalenderDao.getCalenderSettingsName(id);
 		List<MusicGroupPaymentCalenderCourseSettings> musicGroupPaymentCalenderCourseSettings = musicGroupPaymentCalenderCourseSettingsDao.queryCalenderCourseSettings(id);
-		Map<String, Object> result = new HashMap<>(2);
+		Map<String, Object> result = new HashMap<>(4);
 		result.put("musicGroupPaymentCalenderCourseSettings", musicGroupPaymentCalenderCourseSettings);
 		result.put("calender", calender);
 		result.put("calenderSettingsName", name);

+ 19 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MusicGroupServiceImpl.java

@@ -1374,7 +1374,7 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
 
         Date date = new Date();
 
-        if (date.after(expireDate)) {
+        if (expireDate.before(date)) {
             throw new BizException("日期设置错误");
         }
 
@@ -1511,7 +1511,12 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             BigDecimal amount = new BigDecimal(0);
 
             // 判断乐器是否是租赁
-            // MusicGroupSubjectPlan musicGroupSubjectPlan = musicGroupSubjectPlanDao.getMusicOneSubjectClassPlan(musicGroupId, subjectId);
+            MusicGroupSubjectPlan musicGroupSubjectPlan = musicGroupSubjectPlanDao.getMusicOneSubjectClassPlan(musicGroupId, studentRegistration.getActualSubjectId());
+            if(musicGroupSubjectPlan != null){
+            	musicGroupSubjectPlan.setPaidStudentNum(musicGroupSubjectPlan.getPaidStudentNum() - 1);
+            	musicGroupSubjectPlan.setUpdateTime(date);
+            	musicGroupSubjectPlanDao.update(musicGroupSubjectPlan);
+            }
 
             StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, musicGroupId, SUCCESS);
 
@@ -1631,7 +1636,12 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
         BigDecimal amount = new BigDecimal(0);
 
         // 判断乐器是否是租赁
-        // MusicGroupSubjectPlan musicGroupSubjectPlan = musicGroupSubjectPlanDao.getMusicOneSubjectClassPlan(musicGroupId, subjectId);
+        MusicGroupSubjectPlan musicGroupSubjectPlan = musicGroupSubjectPlanDao.getMusicOneSubjectClassPlan(musicGroupId, studentRegistration.getActualSubjectId());
+        if(musicGroupSubjectPlan != null){
+        	musicGroupSubjectPlan.setPaidStudentNum(musicGroupSubjectPlan.getPaidStudentNum() - 1);
+        	musicGroupSubjectPlan.setUpdateTime(date);
+        	musicGroupSubjectPlanDao.update(musicGroupSubjectPlan);
+        }
 
         StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.findMusicGroupApplyOrderByStatus(userId, musicGroupId, SUCCESS);
 
@@ -1690,7 +1700,12 @@ public class MusicGroupServiceImpl extends BaseServiceImpl<String, MusicGroup> i
             sysUserCashAccountDetailService.addCashAccountDetail(userId, amount, SysUserCashAccountDetailService.MUSIC_GROUP + musicGroupId, "",
                     PlatformCashAccountDetailTypeEnum.REFUNDS, null, SUCCESS, "退出乐团", null);
         }
-
+        //缴费项目预计人数减一
+        musicGroupPaymentCalenderDao.cutCalenderExpectNum(userId,musicGroupId);
+        //删除所有未缴费的类型为新增学员的缴费项
+        musicGroupPaymentCalenderDao.delStudentNoPaymentCalender(userId,musicGroupId);
+        musicGroupPaymentCalenderDetailDao.delStudentNoPaymentCalenderDetail(userId,musicGroupId);
+        //删除所有未缴费的缴费详情
         return true;
     }
 

+ 70 - 17
mec-biz/src/main/java/com/ym/mec/biz/service/impl/PayServiceImpl.java

@@ -6,6 +6,7 @@ import com.ym.mec.biz.dal.dao.StudentPaymentRouteOrderDao;
 import com.ym.mec.biz.dal.dao.SysConfigDao;
 import com.ym.mec.biz.dal.dto.AmountChannelDto;
 import com.ym.mec.biz.dal.dto.RouteScaleDto;
+import com.ym.mec.biz.dal.entity.Group;
 import com.ym.mec.biz.dal.entity.StudentPaymentRouteOrder;
 import com.ym.mec.biz.dal.entity.SysAccount;
 import com.ym.mec.biz.dal.entity.SysPaymentConfig;
@@ -395,38 +396,69 @@ public class PayServiceImpl implements PayService {
             return null;
         }
 
+        Map<String, BigDecimal> sellAmount = sellOrderService.getSellAmount(orderNo);
+        if (sellAmount == null) {
+            return null;
+        }
+
         String typeRouteScale = paymentConfig.getTypeRouteScale();
         List<RouteScaleDto> routeScaleDtos = JSON.parseArray(typeRouteScale, RouteScaleDto.class);
         List<Integer> organIds = routeScaleDtos.stream().map(RouteScaleDto::getOrganId).collect(Collectors.toList());
         List<SysPaymentConfig> paymentConfigByOrganIds = sysPaymentConfigService.findPaymentConfigByOrganIds(organIds);
 
-        Map<String, BigDecimal> sellAmount = sellOrderService.getSellAmount(orderNo);
-        if (sellAmount == null) {
-            return null;
-        }
+        long serviceCount = routeScaleDtos.stream().filter(e -> e.getFeeType().equals(FeeTypeEnum.SERVICE)).count();
+        long sellCount = routeScaleDtos.stream().filter(e -> e.getFeeType().equals(FeeTypeEnum.SELL)).count();
+
+        BigDecimal routeAmount = sellAmount.get("actualAmount");
+        BigDecimal routeBalance = sellAmount.get("balance");
+
+        BigDecimal serviceHasRouteMoney = BigDecimal.ZERO;
+        BigDecimal serviceHasRouteBalance = BigDecimal.ZERO;
+        BigDecimal sellHasRouteMoney = BigDecimal.ZERO;
+        BigDecimal sellHasRouteBalance = BigDecimal.ZERO;
 
         Iterator<RouteScaleDto> iterator = routeScaleDtos.iterator();
-        boolean hasFeeFlag = false;
+        BigDecimal maxAmount = BigDecimal.ZERO;
         while (iterator.hasNext()) {
             RouteScaleDto routeScaleDto = iterator.next();
             routeScaleDto.setPayType(paymentConfig.getPayType());
-            if (routeScaleDto.getFeeType().equals(FeeTypeEnum.SELL)) {
-                routeScaleDto.setAmount(sellAmount.get("actualAmount"));
-                routeScaleDto.setBalance(sellAmount.get("balance"));
+            if (routeScaleDto.getFeeType().equals(FeeTypeEnum.SERVICE)) {
+                routeAmount = amount.subtract(sellAmount.get("actualAmount"));
+                routeBalance = balanceAmount.subtract(sellAmount.get("balance"));
+                serviceCount--;
             } else {
-                routeScaleDto.setAmount(amount.subtract(sellAmount.get("actualAmount")));
-                routeScaleDto.setBalance(balanceAmount.subtract(sellAmount.get("balance")));
+                routeAmount = sellAmount.get("actualAmount");
+                routeBalance = sellAmount.get("balance");
+                sellCount--;
+            }
+
+            BigDecimal routingMoney = routeAmount.multiply(new BigDecimal(routeScaleDto.getScale())).divide(new BigDecimal(100), 2, BigDecimal.ROUND_DOWN);
+            BigDecimal routingBalance = routeBalance.multiply(new BigDecimal(routeScaleDto.getScale())).divide(new BigDecimal(100), 2, BigDecimal.ROUND_DOWN);
+
+            if (routeScaleDto.getFeeType().equals(FeeTypeEnum.SERVICE) && serviceCount == 0) {
+                routingMoney = routeAmount.subtract(serviceHasRouteMoney);
+                routingBalance = routeBalance.subtract(serviceHasRouteBalance);
+            } else if (routeScaleDto.getFeeType().equals(FeeTypeEnum.SELL) && sellCount == 0) {
+                routingMoney = routeAmount.subtract(sellHasRouteMoney);
+                routingBalance = routeBalance.subtract(sellHasRouteBalance);
+            }
+            routeScaleDto.setAmount(routingMoney);
+            routeScaleDto.setBalance(routingBalance);
+
+            if (routeScaleDto.getFeeType().equals(FeeTypeEnum.SERVICE)) {
+                serviceHasRouteMoney = serviceHasRouteMoney.add(routingMoney);
+                serviceHasRouteBalance = serviceHasRouteBalance.add(routingBalance);
+            } else {
+                sellHasRouteMoney = sellHasRouteMoney.add(routingMoney);
+                sellHasRouteBalance = sellHasRouteBalance.add(routingBalance);
             }
 
             if (routeScaleDto.getAmount().compareTo(BigDecimal.ZERO) <= 0) {
                 iterator.remove();
                 continue;
             }
-            if (!hasFeeFlag && routeScaleDto.getAmount().compareTo(amount.divide(new BigDecimal(2), 2, BigDecimal.ROUND_DOWN)) >= 0) {
-                routeScaleDto.setFeeFlag("Y");
-                hasFeeFlag = true;
-            }else {
-                routeScaleDto.setFeeFlag("N");
+            if (routeScaleDto.getAmount().compareTo(maxAmount) > 0) {
+                maxAmount = routeScaleDto.getAmount();
             }
 
             for (SysPaymentConfig paymentConfigByOrganId : paymentConfigByOrganIds) {
@@ -438,7 +470,28 @@ public class PayServiceImpl implements PayService {
                 }
             }
         }
-        return routeScaleDtos;
+        boolean hasFeeFlag = false;
+        Map<String, List<RouteScaleDto>> routeScaleDtosMap = routeScaleDtos.stream().collect(Collectors.groupingBy(RouteScaleDto::getMerNo));
+
+        List<RouteScaleDto> newRouteScaleDtos = new ArrayList<>();
+        for (Map.Entry<String, List<RouteScaleDto>> groupRouteScaleDtos : routeScaleDtosMap.entrySet()) {
+            RouteScaleDto routeScaleDto = null;
+            for (RouteScaleDto scaleDto : groupRouteScaleDtos.getValue()) {
+                if(routeScaleDto == null){
+                    routeScaleDto = scaleDto;
+                }else {
+                    routeScaleDto.setAmount(routeScaleDto.getAmount().add(scaleDto.getAmount()));
+                    routeScaleDto.setBalance(routeScaleDto.getBalance().add(scaleDto.getBalance()));
+                }
+                if (!hasFeeFlag && scaleDto.getAmount().compareTo(maxAmount) == 0) {
+                    routeScaleDto.setFeeFlag("Y");
+                    hasFeeFlag = true;
+                } else {
+                    routeScaleDto.setFeeFlag("N");
+                }
+            }
+            newRouteScaleDtos.add(routeScaleDto);
+        }
+        return newRouteScaleDtos;
     }
-
 }

+ 18 - 6
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentManageServiceImpl.java

@@ -37,8 +37,6 @@ public class StudentManageServiceImpl implements StudentManageService {
     @Autowired
     private OrganizationDao organizationDao;
     @Autowired
-    private MusicGroupStudentFeeDao musicGroupStudentFeeDao;
-    @Autowired
     private CourseScheduleStudentPaymentDao scheduleStudentPaymentDao;
     @Autowired
     private TeacherDao teacherDao;
@@ -68,6 +66,8 @@ public class StudentManageServiceImpl implements StudentManageService {
     private MusicGroupQuitDao musicGroupQuitDao;
     @Autowired
     private SubjectChangeDao subjectChangeDao;
+    @Autowired
+    private MusicGroupPaymentCalenderDao musicGroupPaymentCalenderDao;
 
     @Override
     public PageInfo<StudentManageListDto> findStudentsByOrganId(StudentManageQueryInfo queryInfo) {
@@ -341,7 +341,17 @@ public class StudentManageServiceImpl implements StudentManageService {
         PageInfo<MusicGroupStudentsDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
         Map<String, Object> params = new HashMap<>();
         MapUtil.populateMap(params, queryInfo);
-
+//        if(StringUtils.isNotEmpty(queryInfo.getPaymentStatus())){
+//            List<Integer> userIds;
+//            if("NON_PAYMENT".equals(queryInfo.getPaymentStatus())){
+//                userIds = musicGroupPaymentCalenderDao.queryUserByNoPayment(queryInfo.getClassGroupId());
+//            }else {
+//                userIds = musicGroupPaymentCalenderDao.queryUserByPayment(queryInfo.getClassGroupId());
+//            }
+//            if(userIds != null && userIds.size() > 0){
+//                params.put("userIds",userIds);
+//            }
+//        }
         List<MusicGroupStudentsDto> dataList = null;
         int count = studentManageDao.countMusicGroupStudent(params);
         if (queryInfo.getIsExport() && count > 50000) {
@@ -351,9 +361,11 @@ public class StudentManageServiceImpl implements StudentManageService {
             pageInfo.setTotal(count);
             params.put("offset", pageInfo.getOffset());
             dataList = studentManageDao.queryMusicGroupStudent(params);
-//            Map<Integer,String> maps = MapUtil.convertIntegerMap(musicGroupStudentFeeDao.findPaymentStatusMap(queryInfo.getMusicGroupId()));
-//            dataList.forEach(e->{
-//                e.setPaymentStatus(maps.get(e.getUserId()));
+//            Set<Integer> collect = dataList.stream().map(e -> e.getUserId()).collect(Collectors.toSet());
+//            Map<Integer,String> paymentStatusMap = MapUtil.convertIntegerMap(
+//                    musicGroupPaymentCalenderDao.queryUserCoursePaymentStatus(collect,queryInfo.getMusicGroupId()));
+//            dataList.forEach(e -> {
+//                e.setPaymentStatus(paymentStatusMap.get(e.getUserId()));
 //            });
         }
         if (count == 0) {

+ 85 - 21
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentRouteOrderServiceImpl.java

@@ -8,8 +8,12 @@ import java.util.Map.Entry;
 import java.util.stream.Collectors;
 
 import com.alibaba.fastjson.JSONArray;
+import com.ym.mec.auth.api.client.SysUserFeignService;
+import com.ym.mec.auth.api.entity.SysUser;
+import com.ym.mec.biz.dal.dao.*;
 import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.*;
+import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.util.date.DateUtil;
 import com.ym.mec.util.excel.IniFileUtil;
 import com.ym.mec.util.excel.POIUtil;
@@ -22,11 +26,6 @@ import org.springframework.transaction.annotation.Transactional;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
-import com.ym.mec.biz.dal.dao.GoodsDao;
-import com.ym.mec.biz.dal.dao.SellOrderDao;
-import com.ym.mec.biz.dal.dao.StudentPaymentOrderDao;
-import com.ym.mec.biz.dal.dao.StudentPaymentRouteOrderDao;
-import com.ym.mec.biz.dal.dao.SysUserCashAccountDao;
 import com.ym.mec.biz.dal.dto.PageInfoOrder;
 import com.ym.mec.biz.dal.dto.StudentPaymentRouteOrderDto;
 import com.ym.mec.biz.dal.page.StudentPaymentOrderQueryInfo;
@@ -61,6 +60,10 @@ public class StudentPaymentRouteOrderServiceImpl extends BaseServiceImpl<Long, S
     private GoodsService goodsService;
     @Autowired
     private SellOrderService sellOrderService;
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
+    @Autowired
+    private TeacherDao teacherDao;
 
     @Override
     public BaseDAO<Long, StudentPaymentRouteOrder> getDAO() {
@@ -189,6 +192,7 @@ public class StudentPaymentRouteOrderServiceImpl extends BaseServiceImpl<Long, S
 			studentPaymentOrder.setMemo(studentPaymentRouteOrder.getMemo());
 			studentPaymentOrder.setUserId(studentPaymentRouteOrder.getUserId());
 			studentPaymentOrder.setPayTime(studentPaymentRouteOrder.getPayTime());
+			studentPaymentOrder.setTransNo(studentPaymentRouteOrder.getTransNo());
 			
 	        studentPaymentRouteOrderDao.insertOrder(studentPaymentOrder);
 	        
@@ -238,7 +242,7 @@ public class StudentPaymentRouteOrderServiceImpl extends BaseServiceImpl<Long, S
 
 	                BigDecimal hasRouteSellOrderActualAmount = BigDecimal.ZERO;
 	                for (SellOrder sellOrder : sellOrderList) {
-	                    if (!goodsMap.getKey().equals(sellOrder.getParentGoodsId()) && !goodsMap.getKey().equals(sellOrder.getGoodsId())) {
+	                    if (!goodsMap.getKey().equals(sellOrder.getParentGoodsId()) && !goodsMap.getKey().equals(sellOrder.getGoodsId().toString())) {
 	                        continue;
 	                    }
 	                    BigDecimal sellOrderActualAmount = BigDecimal.ZERO;
@@ -312,13 +316,18 @@ public class StudentPaymentRouteOrderServiceImpl extends BaseServiceImpl<Long, S
 
 	@Override
 	@Transactional(rollbackFor = Exception.class)
-	public List<StudentPaymentRouteOrder> importRouteOrder(MultipartFile file) throws Exception{
+	public HttpResponseResult<List<StudentPaymentRouteOrder>> importRouteOrder(MultipartFile file) throws Exception{
+		SysUser sysUser = sysUserFeignService.queryUserInfo();
+		if(sysUser == null || sysUser.getId() == null){
+			throw new BizException("用户信息获取失败");
+		}
 		Map<String, List<Map<String, Object>>> sheetsListMap = POIUtil.importExcel(new ByteArrayInputStream(file.getBytes()), 2, file.getOriginalFilename());
 		InputStream inputStream = new ClassPathResource("columnMapper.ini").getInputStream();
 		Map<String,String> columns = IniFileUtil.readIniFile(inputStream, TemplateTypeEnum.ROUTE_ORDER.getMsg());
 		List<StudentPaymentRouteOrder> studentPaymentRouteOrders = new ArrayList<>();
 		Map<String, Integer> organMap = getMap("organization", "name_", "id_", true, String.class, Integer.class);
 		Map<String, Integer> cooperationOrganMap = getMap("cooperation_organ", "name_", "id_", true, String.class, Integer.class);
+		StringBuffer sb = new StringBuffer();
 		for (String e : sheetsListMap.keySet()) {
 			List<Map<String, Object>> sheet = sheetsListMap.get(e);
 			List<Object> collect = sheet.stream().map(m -> m.get("交易流水号")).collect(Collectors.toList());
@@ -330,24 +339,43 @@ public class StudentPaymentRouteOrderServiceImpl extends BaseServiceImpl<Long, S
 				throw new BizException("导入数据错误  重复的交易流水号:{}",list.get(0));
 			}
 
-			valueIsNull: for (Map<String, Object> row : sheet) {
-
+			valueIsNull: for (int j = 0; j < sheet.size(); j++) {
+				int rowNum = j + 2;
+				Map<String, Object> row = sheet.get(j);
 				if (row.size() == 0){
 					continue;
 				}
 				JSONObject objectMap = new JSONObject();
-				for (String s : row.keySet()) {
+				Iterator<String> iterator = row.keySet().iterator();
+				for (int i = 0; i < row.keySet().size(); i++) {
+					String s = iterator.next();
 					if(!columns.containsKey(s)){
 						continue;
 					}
 					String columnValue = columns.get(s);
+					if (columnValue.equals("incomeType")) {
+						if(StringUtils.isEmpty(row.get(s).toString())){
+							sb.append("第" + rowNum).append("行数据导入失败:收入类型不可为空;");
+							continue valueIsNull;
+						} else {
+							objectMap.put("incomeType", row.get(s));
+						}
+					}
 					if (columnValue.equals("transNo")) {
 						if(StringUtils.isEmpty(row.get(s).toString())){
+							sb.append("第" + rowNum).append("行数据导入失败:交易流水号不可为空;");
+							continue valueIsNull;
+						}
+					}
+					if (columnValue.equals("payTime") && StringUtils.isEmpty(row.get(s).toString())) {
+						if(StringUtils.isEmpty(row.get(s).toString())){
+							sb.append("第" + rowNum).append("行数据导入失败:交易日期不可为空;");
 							continue valueIsNull;
 						}
 					}
 					if (columnValue.equals("merNo")) {
 						if(StringUtils.isEmpty(row.get(s).toString())){
+							sb.append("第" + rowNum).append("行数据导入失败:收款账户不可为空;");
 							continue valueIsNull;
 						}else {
 							objectMap.put("merNo", row.get(s));
@@ -357,6 +385,7 @@ public class StudentPaymentRouteOrderServiceImpl extends BaseServiceImpl<Long, S
 					if (columnValue.equals("organName") && StringUtils.isNotEmpty(row.get(s).toString())) {
 						Integer integer = organMap.get(row.get(s));
 						if(integer == null){
+							sb.append("第" + rowNum).append("行数据导入失败:分部名称不存在;");
 							continue valueIsNull;
 						}else {
 							objectMap.put("routeOrganId", integer);
@@ -367,26 +396,42 @@ public class StudentPaymentRouteOrderServiceImpl extends BaseServiceImpl<Long, S
 						Integer integer = cooperationOrganMap.get(row.get(s));
 						if(integer != null){
 							objectMap.put("schoolId", integer);
+						}else {
+							sb.append("第" + rowNum).append("行数据导入失败:所属学校名称不存在;");
+							continue valueIsNull;
+						}
+						continue;
+					}
+					if (columnValue.equals("userId") && StringUtils.isNotEmpty(row.get(s).toString())) {
+						Boolean flag = teacherDao.existUser(row.get(s));
+						if(flag){
+							objectMap.put("userId", row.get(s));
+						}else {
+							sb.append("第" + rowNum).append("行数据导入失败:学员编号不存在;");
+							continue valueIsNull;
 						}
 						continue;
 					}
-					if (columnValue.equals("payTime") && StringUtils.isNotEmpty(row.get(s).toString())) {
+					if (columnValue.equals("payTime")) {
 						String toString = row.get(s).toString();
-						if(StringUtils.isNotEmpty(toString)){
-							Date date = DateUtil.stringToDate(toString, DateUtil.DEFAULT_PATTERN);
-							if(date == null){
-								throw new BizException("导入数据错误  交易日期格式错误");
-							}else {
-								objectMap.put(columnValue, DateUtil.format(date,DateUtil.DEFAULT_PATTERN));
-							}
+						Date date = DateUtil.stringToDate(toString, DateUtil.DEFAULT_PATTERN);
+						if(date == null){
+							sb.append("第" + rowNum).append("行数据导入失败:交易日期格式错误;");
+							continue valueIsNull;
+						}else {
+							objectMap.put(columnValue, DateUtil.format(date,DateUtil.DEFAULT_PATTERN));
 						}
 						continue;
 					}
 					objectMap.put(columnValue, row.get(s));
 				}
 				StudentPaymentRouteOrder studentPaymentRouteOrder = JSONObject.parseObject(objectMap.toJSONString(),StudentPaymentRouteOrder.class);
-				//是否有销售金额
-				if(studentPaymentRouteOrder.getSaleAmount() != null && studentPaymentRouteOrder.getSaleAmount().longValue() != 0l){
+				//销售收入
+				if("销售收入".equals(studentPaymentRouteOrder.getIncomeType())){
+					if(studentPaymentRouteOrder.getSaleAmount() == null){
+						throw new BizException("导入失败:交易流水号{},收入类型为销售收入时,销售金额不可为空",studentPaymentRouteOrder.getTransNo());
+					}
+					studentPaymentRouteOrder.setServiceAmount(null);
 					String goodsIds = studentPaymentRouteOrder.getGoodsIds();
 					String goodsNums = studentPaymentRouteOrder.getGoodsNums();
 
@@ -416,7 +461,16 @@ public class StudentPaymentRouteOrderServiceImpl extends BaseServiceImpl<Long, S
 						}
 					}
 					studentPaymentRouteOrder.setGoodsJson(goodsJSON.toJSONString());
+					//服务收入
+				}else {
+					studentPaymentRouteOrder.setSaleAmount(null);
+					if(studentPaymentRouteOrder.getServiceAmount() == null){
+						throw new BizException("导入失败:交易流水号{},收入类型为服务收入时,服务金额不可为空",studentPaymentRouteOrder.getTransNo());
+					}
 				}
+				studentPaymentRouteOrder.setCreateBy(sysUser.getId());
+				studentPaymentRouteOrder.setUpdateBy(sysUser.getId());
+				studentPaymentRouteOrder.setUserId(sysUser.getId());
 				studentPaymentRouteOrders.add(studentPaymentRouteOrder);
 			}
 		}
@@ -426,8 +480,18 @@ public class StudentPaymentRouteOrderServiceImpl extends BaseServiceImpl<Long, S
 				throw new BizException("导入失败:请勿录入重复的交易流水号");
 			}
 			studentPaymentRouteOrderDao.batchAdd(studentPaymentRouteOrders);
+		}else {
+			throw new BizException("导入失败:没有可以录入的数据");
+		}
+		HttpResponseResult httpResponseResult = new HttpResponseResult();
+		httpResponseResult.setData(studentPaymentRouteOrders);
+		httpResponseResult.setMsg(sb.toString());
+		if(StringUtils.isNotEmpty(sb.toString())){
+			httpResponseResult.setCode(0);
+		}else {
+			httpResponseResult.setCode(200);
 		}
-		return studentPaymentRouteOrders;
+		return httpResponseResult;
 	}
 
 }

+ 8 - 2
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderDetailMapper.xml

@@ -184,12 +184,18 @@
     <delete id="deleteByCalenderId">
 		DELETE FROM music_group_payment_calender_detail WHERE music_group_payment_calender_id_ = #{id}
 	</delete>
+    <delete id="delStudentNoPaymentCalenderDetail">
+		DELETE mgpcd FROM  music_group_payment_calender_detail mgpcd
+		LEFT JOIN music_group_payment_calender mgpc ON mgpc.id_ = mgpcd.music_group_payment_calender_id_
+		WHERE mgpcd.user_id_ = #{userId} AND mgpcd.payment_status_ = 'NON_PAYMENT' AND mgpc.music_group_id_ = #{musicGroupId}
+	</delete>
 
     <!-- 分页查询 -->
 	<select id="queryPage" resultMap="MusicGroupPaymentCalenderDetail" parameterType="map">
-		SELECT mgpcd.*,su.username_,su.phone_,st.name_ subject_names_,sr.music_group_status_,
+		SELECT su.username_,su.phone_,st.name_ subject_names_,sr.music_group_status_,
 		CASE WHEN mgpcd.start_payment_date_ IS NULL THEN mgpc.start_payment_date_ ELSE mgpcd.start_payment_date_ END start_payment_date_mgpc_,
-		CASE WHEN mgpcd.deadline_payment_date_ IS NULL THEN mgpc.deadline_payment_date_ ELSE mgpcd.deadline_payment_date_ END deadline_payment_date_mgpc_
+		CASE WHEN mgpcd.deadline_payment_date_ IS NULL THEN mgpc.deadline_payment_date_ ELSE mgpcd.deadline_payment_date_ END deadline_payment_date_mgpc_,
+		CASE WHEN mgpc.status_ = 'OPEN' OR mgpcd.open_ = 1 THEN 1 ELSE 0 END open_,mgpcd.*
 		FROM music_group_payment_calender_detail mgpcd
 		LEFT JOIN sys_user su ON su.id_ = mgpcd.user_id_
 		LEFT JOIN student_registration sr ON sr.user_id_ = mgpcd.user_id_

+ 13 - 1
mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentCalenderMapper.xml

@@ -206,6 +206,13 @@
 	        WHERE id_ = #{item.id}
 		</foreach>
     </update>
+    <update id="cutCalenderExpectNum">
+        UPDATE music_group_payment_calender
+        SET expect_num_ = expect_num_ - 1
+        WHERE id_ IN (SELECT music_group_payment_calender_id_ FROM music_group_payment_calender_detail
+        WHERE user_id_ = #{userId} AND payment_status_ = 'NON_PAYMENT')
+        AND payment_type_ != 'ADD_STUDENT' AND expect_num_ > 0 AND music_group_id_ = #{musicGroupId}
+    </update>
 
     <!-- 根据主键删除一条记录 -->
     <delete id="delete">
@@ -215,12 +222,17 @@
     <delete id="delByGroupId">
         DELETE FROM music_group_payment_calender WHERE music_group_id_ = #{musicGroupId}
     </delete>
+    <delete id="delStudentNoPaymentCalender">
+        DELETE FROM music_group_payment_calender
+        WHERE id_ IN (SELECT music_group_payment_calender_id_ FROM music_group_payment_calender_detail
+        WHERE user_id_ = #{userId} AND payment_status_ = 'NON_PAYMENT') AND payment_type_ = 'ADD_STUDENT' AND music_group_id_ = #{musicGroupId}
+    </delete>
 
     <!-- 分页查询 -->
     <select id="queryPage" resultMap="MusicGroupPaymentCalender" parameterType="map">
         SELECT * FROM music_group_payment_calender mgpc
         <include refid="queryPageSql"/>
-        ORDER BY mgpc.payment_valid_start_date_ DESC
+        ORDER BY mgpc.payment_valid_start_date_,mgpc.id_ DESC
         <include refid="global.limit"/>
     </select>
 

+ 15 - 15
mec-biz/src/main/resources/config/mybatis/StudentPaymentRouteOrderMapper.xml

@@ -153,7 +153,7 @@
             #{routeOrder.userId},#{routeOrder.schoolId},#{routeOrder.transNo},#{routeOrder.payTime},
             #{routeOrder.saleAmount},#{routeOrder.serviceAmount},#{routeOrder.memo},#{routeOrder.goodsJson},
             #{routeOrder.auditStatus,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{routeOrder.auditComment},
-            #{routeOrder.createTime},#{routeOrder.updateTime},NOW(),NOW())
+            NOW(),NOW(),#{routeOrder.createBy},#{routeOrder.updateBy})
         </foreach>
     </insert>
 
@@ -267,7 +267,7 @@
         SELECT SUM(route_amount_)
         FROM student_payment_order spo
         LEFT JOIN student_payment_route_order spro ON spo.order_no_ = spro.order_no_
-        WHERE spro.route_organ_id_ = #{routeOrganId} AND spo.payment_channel_ IN
+        WHERE spro.route_organ_id_ = #{routeOrganId} AND spo.status_ IN ('SUCCESS','ING') AND spo.payment_channel_ IN
         <foreach collection="paymentChannelEnumList" item="paymentChannel" open="(" close=")" separator=",">
             #{paymentChannel,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}
         </foreach>
@@ -294,7 +294,7 @@
         ORDER BY spo.id_ ASC
     </select>
     <select id="countByTransNo" resultType="java.lang.String">
-        SELECT order_no_ FROM student_payment_route_order WHERE trans_no_ IN
+        SELECT trans_no_ FROM student_payment_route_order WHERE trans_no_ IN
         <foreach collection="transNos" open="(" close=")" item="item" separator=",">
             #{item}
         </foreach>
@@ -311,19 +311,19 @@
             keyColumn="id" keyProperty="id">
         INSERT INTO student_payment_order
         (id_, group_type_, user_id_, organ_id_, routing_organ_id_, type_, expect_amount_, actual_amount_, com_amount_,
-        per_amount_,
-        balance_payment_amount_, remit_fee_, course_remit_fee_, trans_no_,
-        status_, memo_, create_time_, update_time_, payment_channel_, payment_business_channel_,
-        payment_account_no_, mer_nos_, order_no_, music_group_id_, class_group_id_, pay_time_)
+         per_amount_,
+         balance_payment_amount_, remit_fee_, course_remit_fee_, trans_no_,
+         status_, memo_, create_time_, update_time_, payment_channel_, payment_business_channel_,
+         payment_account_no_, mer_nos_, order_no_, music_group_id_, class_group_id_, pay_time_)
         VALUES (#{id}, #{groupType,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
-        #{userId}, #{organId}, #{routingOrganId},
-        #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
-        #{expectAmount}, #{actualAmount}, #{comAmount}, #{perAmount}, #{balancePaymentAmount},
-        #{remitFee}, #{courseRemitFee}, #{transNo},
-        #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{memo}, #{createTime}, now(),
-        #{paymentChannel}, #{paymentBusinessChannel}, #{paymentAccountNo}, #{merNos}, #{orderNo},
-        #{musicGroupId},
-        #{classGroupId}, #{payTime})
+                #{userId}, #{organId}, #{routingOrganId},
+                #{type,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},
+                #{expectAmount}, #{actualAmount}, #{comAmount}, #{perAmount}, #{balancePaymentAmount},
+                #{remitFee}, #{courseRemitFee}, #{transNo},
+                #{status,typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler}, #{memo}, #{createTime}, now(),
+                #{paymentChannel}, #{paymentBusinessChannel}, #{paymentAccountNo}, #{merNos}, #{orderNo},
+                #{musicGroupId},
+                #{classGroupId}, #{payTime})
     </insert>
 
     <select id="queryAuditCount" parameterType="map" resultType="int">

+ 3 - 0
mec-biz/src/main/resources/config/mybatis/SysPaymentConfigMapper.xml

@@ -160,6 +160,9 @@
             <if test='hasTypeRoute != null and hasTypeRoute.toString()=="0".toString()'>
                 AND spc.type_route_scale_ = ''
             </if>
+            <if test='hasRouteScale != null and hasRouteScale.toString()=="1".toString()'>
+                AND (spc.hf_mer_no_ !='' || spc.route_scale_ != '')
+            </if>
         </where>
     </sql>
 

+ 3 - 0
mec-biz/src/main/resources/config/mybatis/TeacherMapper.xml

@@ -1193,4 +1193,7 @@
         gender_,user_type_
         FROM sys_user WHERE phone_ = #{phone}
     </select>
+    <select id="existUser" resultType="java.lang.Boolean">
+        SELECT COUNT(0) FROM student WHERE user_id_ = #{userId} LIMIT 1
+    </select>
 </mapper>

+ 177 - 0
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/eseal/provider/BytedancePlugin.java

@@ -0,0 +1,177 @@
+package com.ym.mec.thirdparty.eseal.provider;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.codec.digest.DigestUtils;
+import org.springframework.beans.factory.DisposableBean;
+import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.annotation.Value;
+
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.JSONPath;
+import com.ym.mec.thirdparty.exception.ThirdpartyException;
+import com.ym.mec.util.http.HttpUtil;
+import com.ym.mec.util.sort.SortUtil;
+import com.ym.mec.util.string.ValueUtil;
+
+public class BytedancePlugin implements InitializingBean, DisposableBean {
+
+	@Value("${eseal.bytedance.projectid:E6894439939350463244}")
+	public String projectId = "E6894439939350463244";
+
+	@Value("${eseal.bytedance.projectSecret:F%#1*#3^z61GEvH0Nf2N1u68v!vvU5n9C^3RE!z3Q^H$UD3521625&&q!H43QnNf}")
+	public String projectSecret = "F%#1*#3^z61GEvH0Nf2N1u68v!vvU5n9C^3RE!z3Q^H$UD3521625&&q!H43QnNf";
+
+	@Value("${eseal.bytedance.apisUrl:http://sandbox.letsign.com}")
+	public String apisUrl = "http://sandbox.letsign.com";
+
+	public static String getName() {
+		return "ByteDance";
+	}
+
+	@Override
+	public void afterPropertiesSet() throws Exception {
+
+	}
+
+	@Override
+	public void destroy() throws Exception {
+
+	}
+
+	/**
+	 * 创建用户账户(个人)
+	 * @param userId 用户编号
+	 * @param realName 姓名
+	 * @param idcard 身份证号码
+	 * @param mobile 手机号码
+	 * @return 账户唯一标识
+	 * @throws IOException 
+	 */
+	public String createUserAccount(String userId, String realName, String idcard, String mobile) throws IOException {
+		String path = "/open-api/certification/noUser/person3/";
+		String url = apisUrl + path;
+		Map<String, Object> params = new HashMap<String, Object>();
+
+		// 基础参数
+		params.put("appCode", projectId);
+		params.put("timestamp", "" + System.currentTimeMillis());
+		params.put("version", "v1");
+
+		// 业务参数
+		params.put("personOpenCode", userId);
+		params.put("personMobile", mobile);
+		params.put("personName", realName);
+		params.put("personIdCard", idcard);
+
+		// token
+		String token = generateToken(params, projectSecret);
+		params.put("token", token);
+
+		params.put("personIdCardFrontFile", "");
+		params.put("personIdCardBackFile", "");
+
+		String result = HttpUtil.postForHttp(url, params);
+		System.out.println(result);
+
+		JSONObject jsonObject = JSONObject.parseObject(result);
+		if (jsonObject.getInteger("code") == 0) {
+			return userId;
+		}
+		throw new ThirdpartyException("创建个人账户失败:{}", jsonObject.getString("description"));
+	}
+
+	/**
+	 * 创建用户账户(企业)
+	 * @param orgName  机构名称
+	 * @param organCode 统一社会信用代码
+	 * @return e签宝账户唯一标识
+	 */
+	public String createOrganAccount(String orgName, String organCode) {
+
+		return null;
+	}
+
+	/**
+	 * 文件上传
+	 * @param contractFile 协议文件
+	 * @param userId 用户账号
+	 * @return
+	 * @throws IOException
+	 */
+	public String uploadFile(File contractFile, String userId) throws IOException {
+		String path = "/open-api/contract/opt/upload";
+		String url = apisUrl + path;
+		Map<String, Object> params = new HashMap<String, Object>();
+
+		// 基础参数
+		params.put("appCode", projectId);
+		params.put("timestamp", "" + System.currentTimeMillis());
+		params.put("version", "v1");
+
+		// 业务参数
+		params.put("companyOpenCode", "");
+		params.put("personOpenCode", userId);
+		params.put("signType", 1);
+		params.put("canRefuse", 0);
+
+		// token
+		String token = generateToken(params, projectSecret);
+		params.put("token", token);
+
+		params.put("contractFile", contractFile);
+
+		String result = HttpUtil.postForHttp(url, params);
+		System.out.println(result);
+
+		JSONObject jsonObject = JSONObject.parseObject(result);
+		if (jsonObject.getInteger("code") == 0) {
+			return (String) JSONPath.eval(jsonObject, "$.data.contractCode");
+		}
+		throw new ThirdpartyException("上传文件失败:{}", jsonObject.getString("description"));
+	}
+
+	/**
+	 * 企业PDF摘要签署(印章图片)
+	 * @param sealData 电子印章数据
+	 * @param srcPdfPath 源文件
+	 * @param destPdfPath 签名后的目标文件
+	 * @return
+	 */
+	public boolean organSign(String sealData, String srcPdfPath, String destPdfPath) {
+		return true;
+	}
+
+	/**
+	 * 用户签名
+	 * @param accountId e签宝账户唯一标识
+	 * @param sealData 电子印章数据
+	 * @param srcPdfPath 平台签名后的源文件
+	 * @param destPdfPath 平台、用户都签名后的文件地址
+	 * @return
+	 */
+	public boolean userSign(String accountId, String sealData, String srcPdfPath, String destPdfPath) {
+
+		return true;
+	}
+
+	private String generateToken(Map<String, Object> params, String secret) {
+
+		params = SortUtil.sortWithAscII(params);
+		String paramsStr = ValueUtil.joinKeyValue(params, "", "", "", true);
+		String md5Str = new String(DigestUtils.md5(paramsStr.getBytes()));
+
+		paramsStr = md5Str + secret;
+
+		return DigestUtils.sha1Hex(paramsStr);
+	}
+
+	public static void main(String[] args) throws IOException {
+		BytedancePlugin plugin = new BytedancePlugin();
+		plugin.createUserAccount("1", "高勇", "421125198708123313", "13720176797");
+	}
+
+}

+ 24 - 0
mec-util/src/main/java/com/ym/mec/util/sort/SortUtil.java

@@ -0,0 +1,24 @@
+package com.ym.mec.util.sort;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.TreeSet;
+
+public class SortUtil {
+
+	/**
+	 * 按照ASCII码表顺序排序
+	 * @param srcMap
+	 * @return
+	 */
+	public static Map<String, Object> sortWithAscII(Map<String, Object> srcMap) {
+
+		LinkedHashMap<String, Object> targetMap = new LinkedHashMap<String, Object>();
+
+		TreeSet<String> sortedKey = new TreeSet<String>(srcMap.keySet());
+		for (String key : sortedKey) {
+			targetMap.put(key, srcMap.get(key));
+		}
+		return targetMap;
+	}
+}

+ 1 - 1
mec-web/src/main/java/com/ym/mec/web/controller/ImportController.java

@@ -64,7 +64,7 @@ public class ImportController extends BaseController {
     @PostMapping(value = "routeOrder")
     @PreAuthorize("@pcs.hasPermissions('import/routeOrder')")
     public HttpResponseResult<List<StudentPaymentRouteOrder>> importRouteOrder(@RequestParam("file") MultipartFile file) throws Exception {
-        return succeed(studentPaymentRouteOrderService.importRouteOrder(file));
+        return studentPaymentRouteOrderService.importRouteOrder(file);
     }
 
     @ApiOperation(value = "下载导入模板")

+ 26 - 8
mec-web/src/main/java/com/ym/mec/web/controller/SysPaymentConfigController.java

@@ -1,6 +1,7 @@
 package com.ym.mec.web.controller;
 
 import com.ym.mec.biz.dal.entity.SysPaymentConfig;
+import com.ym.mec.biz.dal.enums.AccountType;
 import com.ym.mec.biz.dal.enums.PaymentChannelEnum;
 import com.ym.mec.biz.dal.page.SysPaymentConfigQueryInfo;
 import com.ym.mec.biz.service.SysPaymentConfigService;
@@ -71,6 +72,9 @@ public class SysPaymentConfigController extends BaseController {
     @GetMapping("/queryPage")
     @PreAuthorize("@pcs.hasPermissions('paymentConfig/queryPage')")
     public Object queryPage(SysPaymentConfigQueryInfo queryInfo) {
+        if (queryInfo.getHasTypeRoute() == null) {
+            queryInfo.setHasRouteScale(1);
+        }
         return succeed(sysPaymentConfigService.queryPage(queryInfo));
     }
 
@@ -89,14 +93,23 @@ public class SysPaymentConfigController extends BaseController {
         if (StringUtils.isBlank(config.getTypeRouteScale())) {
             return failed("分润配置不能为空");
         }
-        SysPaymentConfig paymentConfig = sysPaymentConfigService.get(config.getId());
+        SysPaymentConfig paymentConfig = sysPaymentConfigService.findPaymentConfigByOrganId(config.getOrganId());
         if (paymentConfig != null && StringUtils.isNotBlank(paymentConfig.getTypeRouteScale())) {
             return failed("此分部配置存在,请核查");
         }
         Date nowDate = new Date();
-        paymentConfig.setTypeRouteScale(config.getTypeRouteScale());
-        paymentConfig.setUpdateTime(nowDate);
-        sysPaymentConfigService.update(paymentConfig);
+        if (paymentConfig != null) {
+            paymentConfig.setTypeRouteScale(config.getTypeRouteScale());
+            paymentConfig.setUpdateTime(nowDate);
+            sysPaymentConfigService.update(paymentConfig);
+        } else {
+            config.setPayType(PaymentChannelEnum.ADAPAY);
+            config.setType(2);
+            config.setCreateTime(nowDate);
+            config.setUpdateTime(nowDate);
+            sysPaymentConfigService.insert(config);
+            paymentConfig = config;
+        }
         return succeed(paymentConfig);
     }
 
@@ -123,10 +136,15 @@ public class SysPaymentConfigController extends BaseController {
         if (paymentConfig == null) {
             return failed("此分部配置不存在");
         }
-        Date nowDate = new Date();
-        paymentConfig.setTypeRouteScale("");
-        paymentConfig.setUpdateTime(nowDate);
-        sysPaymentConfigService.update(paymentConfig);
+
+        if (StringUtils.isBlank(paymentConfig.getHfMerNo()) && StringUtils.isBlank(paymentConfig.getRouteScale())) {
+            sysPaymentConfigService.delete(id);
+        } else {
+            Date nowDate = new Date();
+            paymentConfig.setTypeRouteScale("");
+            paymentConfig.setUpdateTime(nowDate);
+            sysPaymentConfigService.update(paymentConfig);
+        }
         return succeed(paymentConfig);
     }
 

+ 2 - 0
mec-web/src/main/resources/columnMapper.ini

@@ -36,8 +36,10 @@
 
 
 [财务管理导入模板]
+收入类型 = incomeType
 所属分部 = organName
 所属学校 = cooperationOrganName
+学员编号 = userId
 交易流水号 = transNo
 收款账户 = merNo
 交易日期 = payTime

BIN
mec-web/src/main/resources/excelTemplate/财务管理导入模板.xlsx