Browse Source

Merge remote-tracking branch 'origin/master'

Joburgess 5 years ago
parent
commit
fdc79b4dcb

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

@@ -3,7 +3,7 @@ package com.ym.mec.biz.dal.enums;
 import com.ym.mec.common.enums.BaseEnum;
 import com.ym.mec.common.enums.BaseEnum;
 
 
 public enum GroupType implements BaseEnum<String, GroupType> {
 public enum GroupType implements BaseEnum<String, GroupType> {
-	MUSIC("乐团课"), VIP("VIP课"), DEMO("试听课"), SPORADIC("零星收费"), PRACTICE("网管课"), COMM("对外课程");
+	MUSIC("乐团课"), VIP("VIP课"), DEMO("试听课"), SPORADIC("零星收费"), PRACTICE("网管课"), COMM("对外课程"),REPAIR("乐器维修");
 
 
 	private String desc;
 	private String desc;
 
 

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

@@ -15,7 +15,8 @@ public enum OrderTypeEnum implements BaseEnum<String, OrderTypeEnum> {
 	PRACTICE_GROUP_RENEW("PRACTICE_GROUP_RENEW", "网管课续费"),
 	PRACTICE_GROUP_RENEW("PRACTICE_GROUP_RENEW", "网管课续费"),
 	COURSE_GROUP_BUY("COURSE_GROUP_BUY","对外课程购买"),
 	COURSE_GROUP_BUY("COURSE_GROUP_BUY","对外课程购买"),
 	LUCK("LUCK", "福袋活动"),
 	LUCK("LUCK", "福袋活动"),
-	TENANT_RECHARGE("TENANT_RECHARGE","租户充值");
+	TENANT_RECHARGE("TENANT_RECHARGE","租户充值"),
+	REPAIR("REPAIR","乐器维修");
 
 
 	private String code;
 	private String code;
 
 

+ 10 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/StudentRepairService.java

@@ -7,10 +7,20 @@ import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.BaseService;
 import com.ym.mec.common.service.BaseService;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
+import java.math.BigDecimal;
+import java.util.Map;
+
 public interface StudentRepairService extends BaseService<Integer, StudentRepair> {
 public interface StudentRepairService extends BaseService<Integer, StudentRepair> {
 
 
     /**
     /**
      * 根据维修技师获取相应学生列表
      * 根据维修技师获取相应学生列表
      */
      */
     PageInfo<BasicUserDto> getStudents(RepairStudentQueryInfo queryInfo);
     PageInfo<BasicUserDto> getStudents(RepairStudentQueryInfo queryInfo);
+
+    /**
+     * 添加维修单
+     * @param repairInfo
+     * @return
+     */
+   Map addRepair(StudentRepair repairInfo) throws Exception;
 }
 }

+ 5 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/SysConfigService.java

@@ -181,6 +181,11 @@ public interface SysConfigService extends BaseService<Long, SysConfig> {
     String NEW_MSG_PUSH = "您收到一条作业回复,请点击查看";
     String NEW_MSG_PUSH = "您收到一条作业回复,请点击查看";
 
 
     /**
     /**
+     * @describe 教务端baseUrl
+     */
+    String EDU_TEACHER_BASE_URL = "edu_teacher_base_url";
+
+    /**
      * @return com.ym.mec.biz.dal.entity.SysConfig
      * @return com.ym.mec.biz.dal.entity.SysConfig
      * @params paramName
      * @params paramName
      * @describe 根据配置名称获取配置信息
      * @describe 根据配置名称获取配置信息

+ 96 - 4
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRepairServiceImpl.java

@@ -1,27 +1,47 @@
 package com.ym.mec.biz.service.impl;
 package com.ym.mec.biz.service.impl;
 
 
 import com.ym.mec.biz.dal.dao.StudentRepairDao;
 import com.ym.mec.biz.dal.dao.StudentRepairDao;
+import com.ym.mec.biz.dal.dao.SysConfigDao;
 import com.ym.mec.biz.dal.dto.BasicUserDto;
 import com.ym.mec.biz.dal.dto.BasicUserDto;
+import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.entity.StudentRepair;
 import com.ym.mec.biz.dal.entity.StudentRepair;
+import com.ym.mec.biz.dal.entity.SysConfig;
+import com.ym.mec.biz.dal.entity.SysUserCashAccount;
+import com.ym.mec.biz.dal.enums.DealStatusEnum;
+import com.ym.mec.biz.dal.enums.GroupType;
+import com.ym.mec.biz.dal.enums.OrderTypeEnum;
+import com.ym.mec.biz.dal.enums.PlatformCashAccountDetailTypeEnum;
 import com.ym.mec.biz.dal.page.RepairStudentQueryInfo;
 import com.ym.mec.biz.dal.page.RepairStudentQueryInfo;
+import com.ym.mec.biz.service.PayService;
+import com.ym.mec.biz.service.StudentPaymentOrderService;
 import com.ym.mec.biz.service.StudentRepairService;
 import com.ym.mec.biz.service.StudentRepairService;
+import com.ym.mec.biz.service.SysConfigService;
 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.page.PageInfo;
 import com.ym.mec.common.page.PageInfo;
+import com.ym.mec.common.service.IdGeneratorService;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.collection.MapUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.math.BigDecimal;
+import java.util.*;
 
 
 @Service
 @Service
 public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRepair> implements StudentRepairService {
 public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRepair> implements StudentRepairService {
 
 
     @Autowired
     @Autowired
     private StudentRepairDao studentRepairDao;
     private StudentRepairDao studentRepairDao;
+    @Autowired
+    private PayService payService;
+    @Autowired
+    private IdGeneratorService idGeneratorService;
+    @Autowired
+    private SysConfigDao sysConfigDao;
+    @Autowired
+    private StudentPaymentOrderService studentPaymentOrderService;
 
 
 
 
     @Override
     @Override
@@ -45,4 +65,76 @@ public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRe
         pageInfo.setRows(dataList);
         pageInfo.setRows(dataList);
         return pageInfo;
         return pageInfo;
     }
     }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Map addRepair(StudentRepair repairInfo) throws Exception {
+
+        Date date = new Date();
+        BigDecimal amount = repairInfo.getAmount();
+        String orderNo = idGeneratorService.generatorId("payment") + "";
+        repairInfo.setTransNo(orderNo);
+        studentRepairDao.insert(repairInfo);
+
+        String channelType = "";
+
+        StudentPaymentOrder studentPaymentOrder = new StudentPaymentOrder();
+        studentPaymentOrder.setUserId(repairInfo.getStudentId());
+        studentPaymentOrder.setGroupType(GroupType.REPAIR);
+        studentPaymentOrder.setOrderNo(orderNo);
+        studentPaymentOrder.setType(OrderTypeEnum.REPAIR);
+        studentPaymentOrder.setExpectAmount(amount);
+        studentPaymentOrder.setActualAmount(amount);
+        studentPaymentOrder.setStatus(DealStatusEnum.ING);
+        studentPaymentOrder.setMusicGroupId(repairInfo.getId().toString());
+        studentPaymentOrder.setPaymentChannel("BALANCE");
+        studentPaymentOrder.setUpdateTime(date);
+        studentPaymentOrder.setOrganId(repairInfo.getOrganId());
+        studentPaymentOrder.setRoutingOrganId(repairInfo.getOrganId());
+
+        studentPaymentOrderService.insert(studentPaymentOrder);
+
+        studentPaymentOrder.setVersion(0);
+
+
+        if (amount.compareTo(BigDecimal.ZERO) == 0) {
+            Map<String, String> notifyMap = new HashMap<>();
+            notifyMap.put("tradeState", "1");
+            notifyMap.put("merOrderNo", studentPaymentOrder.getOrderNo());
+            notifyMap.put("channelType", channelType);
+            notifyMap.put("orderNo", "");
+            studentPaymentOrderService.updateOrder(notifyMap);
+            return notifyMap;
+        }
+
+        String baseApiUrl = sysConfigDao.findConfigValue(SysConfigService.EDU_TEACHER_BASE_URL);
+
+        Map<String, BigDecimal> classFee = new HashMap<>();
+        classFee.put("course", BigDecimal.ZERO);
+        classFee.put("instrument", BigDecimal.ZERO);
+        classFee.put("accessories", BigDecimal.ZERO);
+        classFee.put("other", amount);
+
+        Map payMap = payService.getPayMap(
+                amount,
+                orderNo,
+                baseApiUrl + "/api-web/studentOrder/notify",
+                baseApiUrl + "/api-web/studentOrder/paymentResult?orderNo=" + orderNo,
+                "乐器维修",
+                "乐器维修",
+                repairInfo.getStudentId(),
+                classFee,
+                repairInfo.getOrganId()
+        );
+
+        Map<String, BigDecimal> routingFee = (Map<String, BigDecimal>) payMap.get("routingFee");
+        studentPaymentOrder.setRoutingOrganId((Integer) payMap.get("routingOrganId"));
+        studentPaymentOrder.setComAmount(routingFee.get("COM"));
+        studentPaymentOrder.setPerAmount(routingFee.get("PER"));
+        studentPaymentOrder.setMerNos((String) payMap.get("routingMerNos"));
+        studentPaymentOrder.setPaymentChannel((String) payMap.get("type"));
+        studentPaymentOrder.setUpdateTime(date);
+        studentPaymentOrderService.update(studentPaymentOrder);
+        return payMap;
+    }
 }
 }

+ 16 - 0
mec-web/src/main/java/com/ym/mec/web/controller/education/EduRepairController.java

@@ -5,6 +5,7 @@ import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.EmployeeDao;
 import com.ym.mec.biz.dal.dao.EmployeeDao;
 import com.ym.mec.biz.dal.entity.Employee;
 import com.ym.mec.biz.dal.entity.Employee;
+import com.ym.mec.biz.dal.entity.StudentRepair;
 import com.ym.mec.biz.dal.page.RepairStudentQueryInfo;
 import com.ym.mec.biz.dal.page.RepairStudentQueryInfo;
 import com.ym.mec.biz.service.StudentRepairService;
 import com.ym.mec.biz.service.StudentRepairService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.controller.BaseController;
@@ -15,6 +16,7 @@ import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.HttpStatus;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
 
 
@@ -49,4 +51,18 @@ public class EduRepairController extends BaseController {
         queryInfo.setOrganIdList(employee.getOrganIdList());
         queryInfo.setOrganIdList(employee.getOrganIdList());
         return succeed(studentRepairService.getStudents(queryInfo));
         return succeed(studentRepairService.getStudents(queryInfo));
     }
     }
+
+    @ApiOperation("添加维修单")
+    @PostMapping(value = "/addRepair")
+    public HttpResponseResult addRepair(StudentRepair repairInfo) throws Exception {
+        SysUser sysUser = sysUserFeignService.queryUserInfo();
+        if (sysUser == null) {
+            return failed(HttpStatus.FORBIDDEN, "请登录");
+        }
+        repairInfo.setEmployeeId(sysUser.getId());
+        repairInfo.setEmployeeName(sysUser.getRealName());
+        return succeed(studentRepairService.addRepair(repairInfo));
+    }
+
+
 }
 }