Просмотр исходного кода

Merge branch 'zx_saas_payment_config_0218' of http://git.dayaedu.com/yonge/mec into dev

# Conflicts:
#	mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/web/controller/UserController.java
#	mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExportServiceImpl.java
zouxuan 1 месяц назад
Родитель
Сommit
3b710211d6
43 измененных файлов с 1050 добавлено и 731 удалено
  1. 91 69
      mec-application/src/main/java/com/ym/mec/student/controller/StudentOrderController.java
  2. 3 7
      mec-application/src/main/java/com/ym/mec/teacher/controller/TeacherOrderController.java
  3. 6 6
      mec-application/src/main/java/com/ym/mec/web/controller/StudentPaymentOrderController.java
  4. 5 11
      mec-application/src/main/java/com/ym/mec/web/controller/TenantInfoController.java
  5. 7 8
      mec-application/src/main/java/com/ym/mec/web/controller/payment/AdapayController.java
  6. 30 21
      mec-application/src/main/java/com/ym/mec/web/controller/payment/YeepayController.java
  7. 1 0
      mec-application/src/main/resources/bootstrap-dev.properties
  8. 2 1
      mec-application/src/main/resources/bootstrap-test.properties
  9. 9 11
      mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/web/controller/UserController.java
  10. 1 1
      mec-auth/pom.xml
  11. 23 9
      mec-biz/pom.xml
  12. 8 0
      mec-biz/src/main/java/com/ym/mec/biz/service/HfMemberService.java
  13. 8 10
      mec-biz/src/main/java/com/ym/mec/biz/service/StudentPaymentOrderService.java
  14. 2 1
      mec-biz/src/main/java/com/ym/mec/biz/service/TenantOrderRecordService.java
  15. 5 3
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExportServiceImpl.java
  16. 233 43
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/HfMemberServiceImpl.java
  17. 89 13
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/HfMerchantConfigServiceImpl.java
  18. 54 42
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/MemberRankSettingServiceImpl.java
  19. 61 51
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/OrderPayOpsServiceImpl.java
  20. 25 46
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/PayServiceImpl.java
  21. 165 60
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderServiceImpl.java
  22. 4 3
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java
  23. 24 24
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRepairServiceImpl.java
  24. 5 2
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/TenantInfoServiceImpl.java
  25. 75 85
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/TenantOrderRecordServiceImpl.java
  26. 17 49
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/TenantPaymentOrderServiceImpl.java
  27. 7 2
      mec-biz/src/main/resources/config/mybatis/HfMerchantConfigMapper.xml
  28. 2 2
      mec-biz/src/main/resources/config/mybatis/MusicGroupPaymentEntitiesMapper.xml
  29. 8 17
      mec-mall/mall-portal/src/main/java/com/yonge/cooleshow/portal/controller/PaymentController.java
  30. 16 0
      mec-mall/mall-portal/src/main/resources/bootstrap-dev.properties
  31. 11 1
      mec-mall/pom.xml
  32. 4 4
      mec-thirdparty/pom.xml
  33. 2 11
      mec-thirdparty/src/main/java/com/ym/mec/thirdparty/adapay/AdapayInit.java
  34. 7 11
      mec-thirdparty/src/main/java/com/ym/mec/thirdparty/adapay/ConfigInit.java
  35. 2 14
      mec-thirdparty/src/main/java/com/ym/mec/thirdparty/adapay/CorpMemberService.java
  36. 20 31
      mec-thirdparty/src/main/java/com/ym/mec/thirdparty/adapay/Payment.java
  37. 2 10
      mec-thirdparty/src/main/java/com/ym/mec/thirdparty/adapay/SettleAccountService.java
  38. 3 14
      mec-thirdparty/src/main/java/com/ym/mec/thirdparty/yeepay/YeepayMerchantService.java
  39. 4 21
      mec-thirdparty/src/main/java/com/ym/mec/thirdparty/yeepay/YeepayPaymentService.java
  40. 2 11
      mec-thirdparty/src/main/java/com/ym/mec/thirdparty/yeepay/YeepayUploadService.java
  41. 0 1
      mec-thirdparty/src/main/java/com/ym/mec/thirdparty/yqpay/CFCARAUtil.java
  42. 6 4
      mec-thirdparty/src/main/java/com/ym/mec/thirdparty/yqpay/YqPayFeignService.java
  43. 1 1
      pom.xml

+ 91 - 69
mec-application/src/main/java/com/ym/mec/student/controller/StudentOrderController.java

@@ -2,18 +2,20 @@ package com.ym.mec.student.controller;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.huifu.adapay.core.AdapayCore;
-import com.huifu.adapay.core.util.AdapaySign;
-import com.yeepay.g3.sdk.yop.encrypt.DigitalEnvelopeDTO;
-import com.yeepay.g3.sdk.yop.utils.DigitalEnvelopeUtils;
-import com.yeepay.g3.sdk.yop.utils.RSAKeyUtils;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.microsvc.toolkit.middleware.payment.common.api.BasePaymentService;
+import com.microsvc.toolkit.middleware.payment.common.api.PaymentServiceContext;
+import com.microsvc.toolkit.middleware.payment.common.api.entity.PaymentResp;
+import com.microsvc.toolkit.middleware.payment.common.api.enums.PaymentStatus;
 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.dto.*;
 import com.ym.mec.biz.dal.entity.*;
-import com.ym.mec.biz.dal.enums.*;
+import com.ym.mec.biz.dal.enums.DealStatusEnum;
+import com.ym.mec.biz.dal.enums.GroupType;
+import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
+import com.ym.mec.biz.dal.enums.OrderTypeEnum;
 import com.ym.mec.biz.dal.page.StudentPaymentOrderQueryInfo;
 import com.ym.mec.biz.dal.vo.StudentPaymentOrderVo;
 import com.ym.mec.biz.dal.wrapper.CloudTeacherOrderWrapper;
@@ -23,7 +25,6 @@ import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.tenant.TenantContextHolder;
-import com.ym.mec.thirdparty.adapay.entity.HfMerchantConfig;
 import com.ym.mec.thirdparty.yqpay.Msg;
 import com.ym.mec.util.date.DateUtil;
 import com.ym.mec.util.http.HttpUtil;
@@ -36,19 +37,17 @@ import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.HttpStatus;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.web.bind.annotation.*;
 
+import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.math.BigDecimal;
 import java.net.URLEncoder;
-import java.security.PrivateKey;
-import java.security.PublicKey;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -58,66 +57,66 @@ import java.util.stream.Collectors;
 @EnableScheduling
 public class StudentOrderController extends BaseController {
     private static final Logger logger = LoggerFactory.getLogger(StudentOrderController.class);
-    @Autowired
+    @Resource
     private StudentPaymentOrderService studentPaymentOrderService;
-    @Autowired
+    @Resource
     private VipGroupService vipGroupService;
-    @Autowired
+    @Resource
     private MusicGroupService musicGroupService;
-    @Autowired
+    @Resource
     private StudentPaymentOrderDetailService studentPaymentOrderDetailService;
-    @Autowired
+    @Resource
     private StudentPaymentOrderDao studentPaymentOrderDao;
-    @Autowired
+    @Resource
     private SysConfigDao sysConfigDao;
-    @Autowired
+    @Resource
     private SporadicChargeInfoService sporadicChargeInfoService;
-    @Autowired
+    @Resource
     private OrganizationDao organizationDao;
-    @Autowired
+    @Resource
     private CourseScheduleEvaluateDao courseScheduleEvaluateDao;
-    @Autowired
+    @Resource
     private StudentGoodsSellDao studentGoodsSellDao;
-    @Autowired
+    @Resource
     private LuckDrawCountService luckDrawCountService;
-    @Autowired
+    @Resource
     private DegreeRegistrationDao degreeRegistrationDao;
-    @Autowired
+    @Resource
     private SysUserFeignService sysUserFeignService;
-    @Autowired
+    @Resource
     private MusicGroupPaymentCalenderDao musicGroupPaymentCalenderDao;
-    @Autowired
+    @Resource
     private MusicGroupPaymentCalenderCourseSettingsDao musicGroupPaymentCalenderCourseSettingsDao;
-    @Autowired
+    @Resource
     private ReplacementInstrumentActivityDao replacementInstrumentActivityDao;
-    @Autowired
+    @Resource
     private CloudTeacherOrderService cloudTeacherOrderService;
-    @Autowired
+    @Resource
     private SysCouponCodeDao sysCouponCodeDao;
-    @Autowired
+    @Resource
     private StudentRegistrationDao studentRegistrationDao;
-    @Autowired
+    @Resource
     private VipGroupActivityService vipGroupActivityService;
-    @Autowired
+    @Resource
     private TenantOrderRecordService tenantOrderRecordService;
-    @Autowired
+    @Resource
     private OrderPayOpsService orderPayOpsService;
-    @Autowired
+    @Resource
     private MusicGroupPaymentCalenderActivityService musicGroupPaymentCalenderActivityService;
-    @Autowired
+    @Resource
     private TenantConfigService tenantConfigService;
-    @Autowired
+    @Resource
     private OrganizationService organizationService;
-    @Autowired
+    @Resource
     private VipGroupCategoryDao vipGroupCategoryDao;
-    @Autowired
+    @Resource
     private TempBuyDoubleElevenUserLogDao tempBuyDoubleElevenUserLogDao;
-    @Autowired
-    private HfMerchantConfigService hfMerchantConfigService;
-    @Autowired
+    @Resource
     private TempDirectorTrainingCampDetailService tempDirectorTrainingCampDetailService;
-    @Autowired
+    @Resource
     private MusicGroupPaymentCalenderMemberService musicGroupPaymentCalenderMemberService;
+    @Resource
+    private PaymentServiceContext paymentServiceContext;
 
     @Value("${spring.profiles.active:dev}")
     private String profiles;
@@ -134,16 +133,42 @@ public class StudentOrderController extends BaseController {
         return succeed(studentPaymentOrderPageInfo);
     }
 
-    @PostMapping("/callback/{orderNo}")
-	public String callback(@PathVariable("orderNo") String orderNo, HttpServletRequest request) {
-		
-		StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.findOrderByOrderNo(orderNo);
-		
+    @PostMapping("/callback/{vendor}")
+	public String callback(@PathVariable("vendor") String vendor, HttpServletRequest request) {
+        BasePaymentService paymentService = paymentServiceContext.getPaymentService(vendor);
+        if (Objects.isNull(paymentService)) {
+            throw new BizException("支付渠道不存在 " + vendor);
+        }
+        PaymentResp paymentResp = paymentService.callbackNotifyForPay(request);
+        logger.info("payment vendor={}, paymentResp={}", vendor, JSON.toJSONString(paymentResp));
+        if (Objects.isNull(paymentResp)) {
+            return "支付回调失败";
+        }
+		StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.findOrderByOrderNo(paymentResp.getMerOrderNo());
 		if(studentPaymentOrder == null) {
-			return "订单号错误";
-		}
-		
-		PaymentChannelEnum paymentChannel = PaymentChannelEnum.codeOf(studentPaymentOrder.getPaymentChannel());
+            //获取机构订单
+            TenantOrderRecord record = tenantOrderRecordService.getOne(Wrappers.<TenantOrderRecord> lambdaQuery()
+                    .eq(TenantOrderRecord::getOrderNo, paymentResp.getMerOrderNo()));
+            if (Objects.isNull(record)) {
+                throw new BizException("订单号不存在:{}", paymentResp.getMerOrderNo());
+            }else {
+                tenantOrderRecordService.callback(record, paymentResp);
+            }
+		}else {
+            try {
+                Map<String, String> notifyMap = new HashMap<>(4);
+                notifyMap.put("channelType", paymentResp.getPaymentChannel());
+                notifyMap.put("tradeState", paymentResp.getPaymentStatus() == PaymentStatus.SUCCESSED?"1":"0");
+                notifyMap.put("totalMoney", paymentResp.getPaymentAmount().toString());
+                notifyMap.put("merOrderNo", paymentResp.getMerOrderNo());
+                studentPaymentOrderService.updateOrder(notifyMap);
+            } catch (Exception e) {
+                throw new RuntimeException(e);
+            }
+        }
+        return paymentService.returnNotifyResult(request);
+        /*
+        PaymentChannelEnum paymentChannel = PaymentChannelEnum.codeOf(studentPaymentOrder.getPaymentChannel());
 		
 		try {
 			
@@ -234,24 +259,22 @@ public class StudentOrderController extends BaseController {
 		} catch (Exception e) {
 			return e.getMessage();
 		}
-		
-		return "succeeded";
+		*/
+//		return "succeeded";
 	}
 
     @PostMapping("/notify")
     public Msg notify(@ModelAttribute Msg msg) throws Exception {
         logger.info(msg.toString());
-        Map<String, Object> rqMap = new LinkedHashMap<String, Object>();
-        rqMap.put("code", msg.getCode());
-        rqMap.put("msg", msg.getMsg());
-        rqMap.put("responseType", msg.getResponseType());
-        rqMap.put("responseParameters", msg.getResponseParameters());
-        rqMap.put("sign", msg.getSign());
+//        Map<String, Object> rqMap = new LinkedHashMap<String, Object>();
+//        rqMap.put("code", msg.getCode());
+//        rqMap.put("msg", msg.getMsg());
+//        rqMap.put("responseType", msg.getResponseType());
+//        rqMap.put("responseParameters", msg.getResponseParameters());
+//        rqMap.put("sign", msg.getSign());
         //boolean rs = YqPayUtil.verify(rqMap);
         msg.setMsg("fail");
-        Map<String, String> notifyMap = new HashMap<>();
-        //if (rs) {
-        notifyMap = JSON.parseObject(msg.getResponseParameters(), Map.class);
+        Map<String, String> notifyMap = JSON.parseObject(msg.getResponseParameters(), Map.class);
         //}
         //支付中订单存在,更新状态
         if (msg.getResponseType().equals("1") && notifyMap.size() > 0) {
@@ -502,11 +525,11 @@ public class StudentOrderController extends BaseController {
     @GetMapping("/setSuccessStatus")
     public HttpResponseResult setSuccessStatus(String orderNo) throws Exception {
         if (!profiles.equals("dev") && !profiles.equals("test")) {
-//            return failed("非法操作");
+            return failed("非法操作");
         }
         List<StudentPaymentOrder> payingOrders = studentPaymentOrderService.findOrdersByStatus(DealStatusEnum.ING);
 
-        String[] statusArr = {"0", "1", "7"};
+//        String[] statusArr = {"0", "1", "7"};
         for (StudentPaymentOrder payingOrder : payingOrders) {
             if (StringUtils.isNotBlank(orderNo) && !orderNo.equals(payingOrder.getOrderNo())) {
                 continue;
@@ -518,7 +541,6 @@ public class StudentOrderController extends BaseController {
                     continue;
                 }
             }
-
             Map<String, String> rpMap = new HashMap<>();
             rpMap.put("tradeState", "1");
             rpMap.put("remarks", "模拟支付成功");
@@ -529,14 +551,14 @@ public class StudentOrderController extends BaseController {
 
             String channelType = rpMap.get("channelType").equals("1") ? "WXPay" : (rpMap.get("channelType").equals("2") ? "Alipay" : "quickPay");
             rpMap.put("channelType", channelType);
-            if (Arrays.asList(statusArr).contains(rpMap.get("tradeState"))) {
+            studentPaymentOrderService.updateOrder(rpMap); //更新订单
+            /*if (Arrays.asList(statusArr).contains(rpMap.get("tradeState"))) {
                 try {
-                    studentPaymentOrderService.updateOrder(rpMap); //更新订单
                 } catch (Exception e) {
                     e.printStackTrace();
                     continue;
                 }
-            }
+            }*/
         }
         return succeed();
     }
@@ -895,7 +917,7 @@ public class StudentOrderController extends BaseController {
 
     @GetMapping("/reConfirmOrder")
     public HttpResponseResult<List<StudentPaymentOrder>> reConfirmOrder(Date startTime, Date endTime) {
-        if (!profiles.equals("prod")) {
+        if (!profiles.equals("prod") && !profiles.equals("pre")) {
             return failed("测试环境不支持");
         }
         return succeed(studentPaymentOrderService.reConfirmOrder(startTime, endTime));

+ 3 - 7
mec-application/src/main/java/com/ym/mec/teacher/controller/TeacherOrderController.java

@@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 
@@ -22,14 +23,9 @@ import java.io.IOException;
 @Api(tags = "订单回调")
 @RestController
 public class TeacherOrderController extends BaseController {
-	private static final Logger logger = LoggerFactory.getLogger(TeacherOrderController.class);
-	@Autowired
-	private YqPayFeignService yqPayFeignService;
-	@Autowired
-	private TenantPaymentOrderDao tenantPaymentOrderDao;
-	@Autowired
+	@Resource
 	private SysConfigDao sysConfigDao;
-	@Autowired
+	@Resource
 	private TenantPaymentOrderService tenantPaymentOrderService;
 
 	@RequestMapping("paymentResult")

+ 6 - 6
mec-application/src/main/java/com/ym/mec/web/controller/StudentPaymentOrderController.java

@@ -18,13 +18,13 @@ import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 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.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -34,15 +34,15 @@ import java.util.stream.Collectors;
 @RestController
 public class StudentPaymentOrderController extends BaseController {
 
-    @Autowired
+    @Resource
     private StudentPaymentOrderService studentPaymentOrderService;
-    @Autowired
+    @Resource
     private StudentPaymentOrderDetailService studentPaymentOrderDetailService;
-    @Autowired
+    @Resource
     private OrganizationService organizationService;
-    @Autowired
+    @Resource
     private SysConfigDao sysConfigDao;
-    @Autowired
+    @Resource
     private StudentPaymentOrderDao studentPaymentOrderDao;
 
     @ApiOperation(value = "获取订单列表")

+ 5 - 11
mec-application/src/main/java/com/ym/mec/web/controller/TenantInfoController.java

@@ -8,7 +8,6 @@ import com.ym.mec.biz.dal.entity.TenantInfo;
 import com.ym.mec.biz.dal.entity.TenantProductSumm;
 import com.ym.mec.biz.service.TenantInfoSendMsgService;
 import com.ym.mec.biz.service.TenantInfoService;
-import com.ym.mec.biz.service.TenantOrderRecordService;
 import com.ym.mec.common.controller.BaseController;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.page.WrapperUtil;
@@ -18,14 +17,12 @@ import io.swagger.annotations.*;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.BindingResult;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
 import javax.validation.Valid;
 import java.math.BigDecimal;
 import java.util.Map;
@@ -44,17 +41,14 @@ import static com.ym.mec.biz.service.impl.TenantInfoSendMsgServiceImpl.OPEN;
 public class TenantInfoController extends BaseController {
     private static final Logger log = LoggerFactory.getLogger(TenantInfoController.class);
 
-    @Autowired
+    @Resource
     private TenantInfoService tenantInfoService;
 
-    @Autowired
+    @Resource
     private SysUserFeignService sysUserFeignService;
 
-    @Autowired
-    private TenantInfoSendMsgService tenantInfoSendMsgService;
-
     @Resource
-    private TenantOrderRecordService tenantOrderRecordService;
+    private TenantInfoSendMsgService tenantInfoSendMsgService;
 
     @ApiOperation("添加机构信息")
     @PostMapping(value = "/add")
@@ -187,9 +181,9 @@ public class TenantInfoController extends BaseController {
         return succeed();
     }
 
-    @PostMapping("/callback/{orderNo}")
+    /*@PostMapping("/callback/{orderNo}")
     public String callback(@PathVariable("orderNo") String orderNo, HttpServletRequest request) {
         return tenantOrderRecordService.callback(orderNo, request);
-    }
+    }*/
 
 }

+ 7 - 8
mec-application/src/main/java/com/ym/mec/web/controller/payment/AdapayController.java

@@ -16,7 +16,6 @@ import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.tenant.TenantContextHolder;
 import com.ym.mec.thirdparty.adapay.ConfigInit;
-import com.ym.mec.thirdparty.adapay.Payment;
 import com.ym.mec.thirdparty.adapay.entity.AccountInfo;
 import com.ym.mec.thirdparty.adapay.entity.HfMerchantConfig;
 import com.ym.mec.util.date.DateUtil;
@@ -26,7 +25,6 @@ import io.swagger.annotations.ApiOperation;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -34,6 +32,7 @@ import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.*;
@@ -48,10 +47,9 @@ import java.util.Map;
 @RestController
 public class AdapayController extends BaseController {
 
-    @Autowired
+    @Resource
     private HfMemberService hfMemberService;
-    
-    @Autowired
+    @Resource
     private HfMerchantConfigService hfMerchantConfigService;
 
     @Value("${spring.profiles.active:dev}")
@@ -213,12 +211,13 @@ public class AdapayController extends BaseController {
         long createdLte = DateUtil.getLastSecondWithDay(endTime).getTime();
         int pageIndex = 1;
         List<Map<String, Object>> data = new ArrayList<>();
-        while (profiles.equals("prod")) {
+        while (profiles.equals("prod") || profiles.equals("pre")) {
         	HfMerchantConfig hfMerchantConfig = hfMerchantConfigService.queryByTenantId(TenantContextHolder.getTenantId(), PaymentChannelEnum.ADAPAY.getCode());
             if(hfMerchantConfig == null){
             	throw new BizException("机构[{}]汇付商户信息找不到", TenantContextHolder.getTenantId());
             }
-            Map<String, Object> paymentList = Payment.queryList(hfMerchantConfig.getAppId(), hfMerchantConfig.getMerKey(), pageIndex, createdGte, createdLte);
+            Map<String, Object> paymentList = hfMemberService.queryWithKey(hfMerchantConfig.getAppId(), hfMerchantConfig.getMerKey(), pageIndex, createdGte, createdLte);
+//            Map<String, Object> paymentList = Payment.queryList(hfMerchantConfig.getAppId(), hfMerchantConfig.getMerKey(), pageIndex, createdGte, createdLte);
             JSONArray payments = (JSONArray) paymentList.get("payments");
             if (!paymentList.get("status").equals("succeeded")) {
                 throw new BizException("查询失败,请重试");
@@ -248,7 +247,7 @@ public class AdapayController extends BaseController {
                     }
                     if (paymentMap.get("pay_mode").equals("delay")) {
                         if (!paymentMap.containsKey("payment_confirms")) {
-                            Map<String, Object> confirmMap = Payment.queryConfirmList(hfMerchantConfig.getAppId(), hfMerchantConfig.getMerKey(), paymentMap.get("id").toString());
+                            Map<String, Object> confirmMap = hfMemberService.queryConfirmList(hfMerchantConfig.getAppId(), hfMerchantConfig.getMerKey(), paymentMap.get("id").toString());
                             if (confirmMap.containsKey("payment_confirms")) {
                                 paymentMap.put("payment_confirms", confirmMap.get("payment_confirms"));
                             }

+ 30 - 21
mec-application/src/main/java/com/ym/mec/web/controller/payment/YeepayController.java

@@ -2,6 +2,9 @@ package com.ym.mec.web.controller.payment;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
+import com.microsvc.toolkit.middleware.payment.common.api.BasePaymentService;
+import com.microsvc.toolkit.middleware.payment.common.api.PaymentServiceContext;
+import com.microsvc.toolkit.middleware.payment.common.api.entity.PaymentMerchant;
 import com.yeepay.g3.sdk.yop.encrypt.DigitalEnvelopeDTO;
 import com.yeepay.g3.sdk.yop.utils.DigitalEnvelopeUtils;
 import com.yeepay.g3.sdk.yop.utils.RSAKeyUtils;
@@ -17,7 +20,6 @@ import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.tenant.TenantContextHolder;
 import com.ym.mec.thirdparty.adapay.entity.HfMerchantConfig;
-import com.ym.mec.thirdparty.yeepay.YeepayMerchantService;
 import com.ym.mec.thirdparty.yeepay.YeepayUploadService;
 import com.ym.mec.thirdparty.yeepay.entity.MerchantInfo;
 import io.swagger.annotations.Api;
@@ -26,12 +28,11 @@ import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import java.io.File;
 import java.io.FileOutputStream;
@@ -47,20 +48,19 @@ import java.util.Date;
 public class YeepayController extends BaseController {
     private static final Logger logger = LoggerFactory.getLogger(YeepayController.class);
 
-    @Autowired
+    @Resource
     private HfMemberService hfMemberService;
     
-    @Autowired
+    @Resource
     private HfMerchantConfigService hfMerchantConfigService;
     
-    @Autowired
+    @Resource
     private YeepayUploadService yeepayUploadService;
-    
-    @Autowired
-    private YeepayMerchantService yeepayMerchantService;
+    @Resource
+    private PaymentServiceContext paymentServiceContext;
 
-    @Value("${spring.profiles.active:dev}")
-    private String profiles;
+//    @Value("${spring.profiles.active:dev}")
+//    private String profiles;
 
     @ApiOperation(value = "企业用户列表")
     @GetMapping("/queryPage")
@@ -74,14 +74,16 @@ public class YeepayController extends BaseController {
     @ApiOperation(value = "企业用户注册查询")
     @GetMapping("/registerQuery")
     @PreAuthorize("@pcs.hasPermissions('yeepay/registerQuery')")
-    public HttpResponseResult<JSONObject> registerQuery(String requestNo) throws IOException {
-		
-		HfMerchantConfig hfMerchantConfig = hfMerchantConfigService.queryByTenantId(TenantContextHolder.getTenantId(), PaymentChannelEnum.YEEPAY.getCode());
-        if(hfMerchantConfig == null){
-        	throw new BizException("机构[{}][{}]商户信息找不到", TenantContextHolder.getTenantId(), PaymentChannelEnum.YEEPAY.getCode());
+    public HttpResponseResult<PaymentMerchant.MerchantMember> registerQuery(String requestNo) throws IOException {
+        BasePaymentService paymentService = paymentServiceContext.getPaymentService(PaymentChannelEnum.YEEPAY.getCode() + "_" + TenantContextHolder.getTenantId());
+        if(paymentService == null){
+        	throw new BizException("机构[{}][{}]支付服务找不到", TenantContextHolder.getTenantId(), PaymentChannelEnum.YEEPAY.getCode());
         }
-        
-        return succeed(yeepayMerchantService.registerQueryV2(hfMerchantConfig, requestNo));
+        PaymentMerchant.MerchantConfig merchantConfig = hfMemberService.getMerchantConfig(PaymentChannelEnum.YEEPAY.getCode(), TenantContextHolder.getTenantId());
+        PaymentMerchant.MerchantMember hfMerchantConfig = new PaymentMerchant.MerchantMember();
+        hfMerchantConfig.setRequestNo(requestNo);
+        return succeed(paymentService.getPaymentCorpMember(merchantConfig, hfMerchantConfig));
+//        return succeed(yeepayMerchantService.registerQueryV2(hfMerchantConfig, requestNo));
     }
 
     @ApiOperation("新建企业用户")
@@ -172,12 +174,19 @@ public class YeepayController extends BaseController {
             inputStream.close();
             fos.close();
             
-            HfMerchantConfig hfMerchantConfig = hfMerchantConfigService.queryByTenantId(TenantContextHolder.getTenantId(), PaymentChannelEnum.YEEPAY.getCode());
+            /*HfMerchantConfig hfMerchantConfig = hfMerchantConfigService.queryByTenantId(TenantContextHolder.getTenantId(), PaymentChannelEnum.YEEPAY.getCode());
             if(hfMerchantConfig == null){
             	throw new BizException("请配置机构的易宝商户信息");
+            }*/
+            BasePaymentService paymentService = paymentServiceContext.getPaymentService(PaymentChannelEnum.YEEPAY.getCode() + "_" + TenantContextHolder.getTenantId());
+            if(paymentService == null){
+            	throw new BizException("机构[{}][{}]支付服务找不到", TenantContextHolder.getTenantId(), PaymentChannelEnum.YEEPAY.getCode());
             }
-        	
-            return succeed(yeepayUploadService.upload(hfMerchantConfig, file));
+            PaymentMerchant.MerchantConfig merchantConfig = hfMemberService.getMerchantConfig(PaymentChannelEnum.YEEPAY.getCode(), TenantContextHolder.getTenantId());
+            String upload = paymentService.upload(merchantConfig, file);
+            return succeed(upload);
+
+//            return succeed(yeepayUploadService.upload(hfMerchantConfig, file));
         } catch (Exception e) {
             return failed(e.getMessage());
         } finally {

+ 1 - 0
mec-application/src/main/resources/bootstrap-dev.properties

@@ -10,3 +10,4 @@ spring.cloud.nacos.config.file-extension=yaml
 #\u662F\u5426\u52A8\u6001\u5237\u65B0
 spring.cloud.nacos.config.enabled=true
 logging.config=classpath:logback-dev.xml
+spring.cloud.nacos.config.shared-dataids=base.yaml

+ 2 - 1
mec-application/src/main/resources/bootstrap-test.properties

@@ -9,4 +9,5 @@ spring.cloud.nacos.config.prefix=app
 spring.cloud.nacos.config.file-extension=yaml
 #\u662F\u5426\u52A8\u6001\u5237\u65B0
 spring.cloud.nacos.config.enabled=true
-logging.config=classpath:logback-test-env.xml
+logging.config=classpath:logback-test-env.xml
+spring.cloud.nacos.config.shared-dataids=base.yaml

+ 9 - 11
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/web/controller/UserController.java

@@ -1,9 +1,6 @@
 package com.ym.mec.auth.web.controller;
 
 import com.alibaba.fastjson.JSON;
-import com.dayaedu.cbs.openfeign.service.CbsQrCodeScanService;
-import com.dayaedu.cbs.openfeign.wrapper.qrcode.CbsQrCodeScanWrapper;
-import com.huifu.adapay.core.util.StringUtil;
 import com.ym.mec.auth.api.dto.SysUserInfo;
 import com.ym.mec.auth.api.dto.SysUserQueryInfo;
 import com.ym.mec.auth.api.entity.SysUser;
@@ -29,14 +26,15 @@ import com.ym.mec.thirdparty.user.realname.RealnameAuthenticationPluginContext;
 import com.ym.mec.thirdparty.user.realname.provider.LinkfaceRealnameAuthenticationPlugin;
 import com.ym.mec.util.date.DateUtil;
 import io.swagger.annotations.*;
+import jodd.util.StringUtil;
 import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.http.MediaType;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
 import org.springframework.web.bind.annotation.*;
 
+import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import java.io.IOException;
 import java.util.*;
@@ -46,19 +44,19 @@ import java.util.*;
 @Api(tags = "会员服务")
 public class UserController extends BaseController {
 
-	@Autowired
+	@Resource
 	private SysUserService sysUserService;
-	@Autowired
+	@Resource
 	private SysRoleService sysRoleService;
-	@Autowired
+	@Resource
 	private ImFeignService imFeignService;
-	@Autowired
+	@Resource
 	private SysUserRoleService sysUserRoleService;
-	@Autowired
+	@Resource
 	private IdGeneratorService smsCodeService;
-	@Autowired
+	@Resource
 	private TenantInfoService tenantInfoService;
-	@Autowired
+	@Resource
 	private RedisCache<String,Object> redisCache;
 
 	/*@Value("${message.debugMode}")

+ 1 - 1
mec-auth/pom.xml

@@ -23,7 +23,7 @@
 		<dependency>
 			<groupId>com.microsvc.toolkit.common</groupId>
 			<artifactId>microsvc-common-webportal</artifactId>
-			<version>${com.microsvc.toolkit.version}</version>
+			<version>${microsvc.version}</version>
 		</dependency>
 		<!-- 引用Mybatis 和 Mysql驱动开始 -->
 		<dependency>

+ 23 - 9
mec-biz/pom.xml

@@ -50,21 +50,35 @@
 			<artifactId>thumbnailator</artifactId>
 			<version>0.4.11</version>
 		</dependency>
-
+		<dependency>
+			<groupId>com.microsvc.toolkit.middleware</groupId>
+			<artifactId>microsvc-middleware-payment</artifactId>
+			<version>${microsvc.version}</version>
+			<exclusions>
+				<exclusion>
+					<artifactId>mybatis-plus-annotation</artifactId>
+					<groupId>com.baomidou</groupId>
+				</exclusion>
+				<exclusion>
+					<groupId>org.springframework.boot</groupId>
+					<artifactId>spring-boot-starter-log4j2</artifactId>
+				</exclusion>
+			</exclusions>
+		</dependency>
 		<dependency>
 			<groupId>com.microsvc.toolkit.middleware</groupId>
 			<artifactId>microsvc-middleware-live</artifactId>
-			<version>${com.microsvc.toolkit.version}</version>
+			<version>${microsvc.version}</version>
 		</dependency>
 		<dependency>
 			<groupId>com.microsvc.toolkit.common</groupId>
 			<artifactId>microsvc-common-response</artifactId>
-			<version>${com.microsvc.toolkit.version}</version>
+			<version>${microsvc.version}</version>
 		</dependency>
 		<dependency>
 			<groupId>com.microsvc.toolkit.middleware</groupId>
 			<artifactId>microsvc-middleware-rtc</artifactId>
-			<version>${com.microsvc.toolkit.version}</version>
+			<version>${microsvc.version}</version>
 		</dependency>
 
 		<!--修复依赖冲突-->
@@ -75,22 +89,22 @@
 		<dependency>
 			<groupId>com.microsvc.toolkit.config</groupId>
 			<artifactId>microsvc-config-validator</artifactId>
-			<version>${com.microsvc.toolkit.version}</version>
+			<version>${microsvc.version}</version>
 		</dependency>
         <dependency>
             <groupId>com.microsvc.toolkit.config</groupId>
             <artifactId>microsvc-config-jwt</artifactId>
-            <version>${com.microsvc.toolkit.version}</version>
+            <version>${microsvc.version}</version>
         </dependency>
 		<dependency>
 			<groupId>com.microsvc.toolkit.middleware</groupId>
 			<artifactId>microsvc-middleware-im</artifactId>
-			<version>${com.microsvc.toolkit.version}</version>
+			<version>${microsvc.version}</version>
 		</dependency>
 		<dependency>
 			<groupId>com.microsvc.toolkit.middleware</groupId>
 			<artifactId>microsvc-middleware-oss</artifactId>
-			<version>${com.microsvc.toolkit.version}</version>
+			<version>${microsvc.version}</version>
 		</dependency>
 
 		<dependency>
@@ -111,7 +125,7 @@
 				</exclusion>
 			</exclusions>
 			<groupId>com.microsvc.toolkit.common</groupId>
-			<version>${com.microsvc.toolkit.version}</version>
+			<version>${microsvc.version}</version>
 		</dependency>
 		<dependency>
 			<groupId>com.yonge.log</groupId>

+ 8 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/HfMemberService.java

@@ -1,7 +1,9 @@
 package com.ym.mec.biz.service;
 
 import java.io.File;
+import java.util.Map;
 
+import com.microsvc.toolkit.middleware.payment.common.api.entity.PaymentMerchant;
 import com.ym.mec.biz.dal.entity.HfMember;
 import com.ym.mec.common.service.BaseService;
 import com.ym.mec.thirdparty.adapay.entity.AccountInfo;
@@ -22,7 +24,13 @@ public interface HfMemberService extends BaseService<Integer, HfMember> {
 
     boolean createMember(HfMember member, File file) throws Exception;
 
+    PaymentMerchant.MerchantConfig getMerchantConfig(String paymentVerdor, Integer tenantId);
+
     boolean updateMember(HfMember member, File file) throws Exception;
 
     boolean mergeSettleAccount(String memberId, AccountInfo accountInfo) throws Exception;
+
+    Map<String, Object> queryWithKey(String appId, String merKey, int pageIndex, long createdGte, long createdLte);
+
+    Map<String, Object> queryConfirmList(String appId, String merchantKey, String paymentId);
 }

+ 8 - 10
mec-biz/src/main/java/com/ym/mec/biz/service/StudentPaymentOrderService.java

@@ -1,15 +1,7 @@
 package com.ym.mec.biz.service;
 
-import java.math.BigDecimal;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
-import com.ym.mec.biz.dal.dto.*;
-import com.ym.mec.common.entity.OrderSkuSync;
-import org.apache.ibatis.annotations.Param;
-
 import com.ym.mec.biz.dal.dao.StudentPaymentOrderDao;
+import com.ym.mec.biz.dal.dto.*;
 import com.ym.mec.biz.dal.entity.ActivityUserMapper;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail;
@@ -23,10 +15,16 @@ import com.ym.mec.biz.dal.vo.StudentPaymentOrderVo;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.entity.MallCreateOrderModel;
 import com.ym.mec.common.entity.OrderCancelModel;
+import com.ym.mec.common.entity.OrderSkuSync;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.service.BaseService;
 import com.ym.mec.thirdparty.adapay.entity.BaseResult;
-import com.ym.mec.thirdparty.adapay.entity.HfMerchantConfig;
+import org.apache.ibatis.annotations.Param;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
 
 public interface StudentPaymentOrderService extends BaseService<Long, StudentPaymentOrder> {
 

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

@@ -1,6 +1,7 @@
 package com.ym.mec.biz.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.microsvc.toolkit.middleware.payment.common.api.entity.PaymentResp;
 import com.ym.mec.biz.dal.dto.TenantOrderRecordDto;
 import com.ym.mec.biz.dal.entity.TenantOrderRecord;
 import com.ym.mec.common.page.PageInfo;
@@ -33,7 +34,7 @@ public interface TenantOrderRecordService extends IService<TenantOrderRecord> {
 
     void rechargeSuccess(TenantOrderRecord record);
 
-    String callback(String orderNo, HttpServletRequest request);
+    void callback(TenantOrderRecord record, PaymentResp paymentResp);
 
 }
 

+ 5 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExportServiceImpl.java

@@ -171,6 +171,8 @@ public class ExportServiceImpl implements ExportService {
     @Resource
     private StudentCourseConsumerService studentCourseConsumerService;
     @Resource
+    private HfMemberService hfMemberService;
+    @Resource
     private TeacherCloudCourseReportService teacherCloudCourseReportService;
     @Resource
     private OssPluginContext ossPluginContext;
@@ -686,14 +688,14 @@ public class ExportServiceImpl implements ExportService {
         long createdLte = DateUtil.getLastSecondWithDay(endTime).getTime();
         int pageIndex = 1;
         List<Map<String, Object>> data = new ArrayList<>();
-        while ("prod".equals(profiles)) {
+        while ("prod".equals(profiles) || "pre".equals(profiles)) {
             Map<String, Object> paymentList = null;
             HfMerchantConfig hfMerchantConfig = hfMerchantConfigService.queryByTenantId(TenantContextHolder.getTenantId(), PaymentChannelEnum.ADAPAY.getCode());
             if (hfMerchantConfig == null) {
                 throw new BizException("机构[{}]汇付商户信息找不到", TenantContextHolder.getTenantId());
             }
             try {
-                paymentList = Payment.queryList(hfMerchantConfig.getAppId(), hfMerchantConfig.getMerKey(), pageIndex, createdGte, createdLte);
+                paymentList = hfMemberService.queryWithKey(hfMerchantConfig.getAppId(), hfMerchantConfig.getMerKey(), pageIndex, createdGte, createdLte);
             } catch (Exception e) {
                 e.printStackTrace();
             }
@@ -728,7 +730,7 @@ public class ExportServiceImpl implements ExportService {
                         if (!paymentMap.containsKey("payment_confirms")) {
                             Map<String, Object> confirmMap = null;
                             try {
-                                confirmMap = Payment.queryConfirmList(hfMerchantConfig.getAppId(), hfMerchantConfig.getMerKey(), paymentMap.get("id").toString());
+                                confirmMap = hfMemberService.queryConfirmList(hfMerchantConfig.getAppId(), hfMerchantConfig.getMerKey(), paymentMap.get("id").toString());
                             } catch (Exception e) {
                                 e.printStackTrace();
                             }

+ 233 - 43
mec-biz/src/main/java/com/ym/mec/biz/service/impl/HfMemberServiceImpl.java

@@ -1,16 +1,10 @@
 package com.ym.mec.biz.service.impl;
 
-import java.io.File;
-import java.io.IOException;
-import java.util.Date;
-import java.util.Map;
-
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
+import com.alibaba.fastjson.JSON;
+import com.huifu.adapay.core.exception.BaseAdaPayException;
+import com.microsvc.toolkit.middleware.payment.common.api.BasePaymentService;
+import com.microsvc.toolkit.middleware.payment.common.api.PaymentServiceContext;
+import com.microsvc.toolkit.middleware.payment.common.api.entity.PaymentMerchant;
 import com.ym.mec.biz.dal.config.AdapayNotifyConstants;
 import com.ym.mec.biz.dal.dao.HfMemberDao;
 import com.ym.mec.biz.dal.dto.YeepayMember;
@@ -21,37 +15,40 @@ import com.ym.mec.biz.service.HfMerchantConfigService;
 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.tenant.TenantContextHolder;
 import com.ym.mec.thirdparty.adapay.CorpMemberService;
 import com.ym.mec.thirdparty.adapay.SettleAccountService;
 import com.ym.mec.thirdparty.adapay.entity.AccountInfo;
 import com.ym.mec.thirdparty.adapay.entity.EnterpriseUser;
 import com.ym.mec.thirdparty.adapay.entity.HfMerchantConfig;
-import com.ym.mec.thirdparty.yeepay.YeepayMerchantService;
-import com.ym.mec.thirdparty.yeepay.entity.MerchantInfo;
+import com.ym.mec.thirdparty.exception.ThirdpartyException;
 import com.ym.mec.util.string.MessageFormatter;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.io.File;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
 
 @Service
+@Slf4j
 public class HfMemberServiceImpl extends BaseServiceImpl<Integer, HfMember> implements HfMemberService {
 	
-    @Autowired
+    @Resource
     private HfMemberDao hfMemberDao;
-    
-    @Autowired
-    private SettleAccountService settleAccountService;
-    
-    @Autowired
-    private CorpMemberService corpMemberService;
-    
-    @Autowired
+    @Resource
     private HfMerchantConfigService hfMerchantConfigService;
-    
-    @Autowired
-    private YeepayMerchantService yeepayMerchantService;
+    @Resource
+    private PaymentServiceContext paymentServiceContext;
 
     @Value("${spring.profiles.active:dev}")
     private String env;
 
-	private String cardName;
 
     @Override
     public BaseDAO<Integer, HfMember> getDAO() {
@@ -84,7 +81,21 @@ public class HfMemberServiceImpl extends BaseServiceImpl<Integer, HfMember> impl
         if (hasMember != null) {
             throw new BizException("公司名与已有公司名相同,请核查");
         }
-        
+        BasePaymentService paymentService = paymentServiceContext.getPaymentService(member.getPayerName() + "_" + member.getTenantId());
+        if (paymentService == null) {
+            throw new BizException("支付渠道不存在:{}", member.getPayerName());
+        }
+        PaymentMerchant.MerchantConfig merchantConfig = getMerchantConfig(member.getPayerName() + "_" + member.getTenantId(),member.getTenantId());
+        PaymentMerchant.MerchantMember merchantMember = getHfMerchantMember(member);
+        merchantMember.setAttachFile(file);
+        try {
+            log.info("创建子账户参数:{}", JSON.toJSONString(merchantMember));
+            paymentService.createPaymentCorpMember(merchantConfig, merchantMember);
+        }catch (Exception e) {
+            log.error("创建子账户失败", e);
+            throw new BizException("创建子账户失败:" + e.getMessage());
+        }
+/*
         switch (PaymentChannelEnum.codeOf(member.getPayerName())) {
 		case ADAPAY:
 			createMemberWithAdapay(member, file);
@@ -99,7 +110,7 @@ public class HfMemberServiceImpl extends BaseServiceImpl<Integer, HfMember> impl
 		default:
 			
 			return false;
-		}
+		}*/
 
         Date nowDate = new Date();
         member.setCreateTime(nowDate);
@@ -111,14 +122,133 @@ public class HfMemberServiceImpl extends BaseServiceImpl<Integer, HfMember> impl
     }
 
     @Override
+    public PaymentMerchant.MerchantConfig getMerchantConfig(String paymentVerdor, Integer tenantId) {
+        HfMerchantConfig merchantConfig = hfMerchantConfigService.queryByTenantId(tenantId,paymentVerdor);
+        if (merchantConfig == null) {
+            throw new BizException("机构[{}]商户信息找不到", tenantId);
+        }
+        return PaymentMerchant.MerchantConfig.builder()
+                .payerName(paymentVerdor)
+                .appId(merchantConfig.getAppId())
+                .merchantKey(merchantConfig.getMerKey())
+                .apiKey(merchantConfig.getApiKey())
+                .rsaPrivateKey(merchantConfig.getRsaPrivateKey())
+                .rsaPublicKey(merchantConfig.getRsaPublicKey())
+                .wxAppId(merchantConfig.getWxAppId())
+                .wxAppSecret(merchantConfig.getWxAppSecret())
+                .alipayAppId(merchantConfig.getAlipayAppId())
+                .alipayPublicKey(merchantConfig.getAlipayPublicKey())
+                .platformPayeeMemberId(merchantConfig.getPlatformPayeeMemberId())
+                .build();
+    }
+
+    private PaymentMerchant.MerchantMember getHfMerchantMember(HfMember tenantMember) {
+        if (StringUtils.equalsIgnoreCase(tenantMember.getPayerName(), PaymentChannelEnum.ADAPAY.getCode())) {
+            PaymentMerchant.MerchantMember merchantMember = PaymentMerchant.MerchantMember.builder()
+                    .memberId(tenantMember.getMemberId())
+                    .merchantName(tenantMember.getName())
+                    .provinceCode(tenantMember.getProvCode())
+                    .cityCode(tenantMember.getAreaCode())
+                    .districtCode(tenantMember.getDistrictCode())
+                    .socialCreditCode(tenantMember.getSocialCreditCode())
+                    .socialCreditCodeExpires(tenantMember.getSocialCreditCodeExpires())
+                    .businessScope(tenantMember.getBusinessScope())
+                    .legalName(tenantMember.getLegalPerson())
+                    .legalLicenceNo(tenantMember.getLegalCertId())
+                    .legalCertIdExpires(tenantMember.getLegalCertIdExpires())
+                    .mobile(tenantMember.getLegalMp())
+                    .legalLicenceType(tenantMember.getLegalLicenceType())
+                    .address(tenantMember.getAddress())
+                    .bankCode(tenantMember.getBankCode())
+                    .bankAccountType(tenantMember.getBankAcctType())
+                    .bankCardNo(tenantMember.getCardNo())
+                    .cardName(tenantMember.getCardName())
+                    .zipCode(tenantMember.getZipCode())
+                    .requestNo(tenantMember.getRequestNo())
+                    .licenceNo(tenantMember.getSocialCreditCode())
+                    .contactName(tenantMember.getContactName())
+                    .contactMobile(tenantMember.getContactMobile())
+                    .contactEmail(tenantMember.getContactEmail())
+                    .contactLicenceNo(tenantMember.getContactLicenceNo())
+                    .primaryIndustryCategory("120")
+                    .secondaryIndustryCategory("120004")
+                    .settlementDirection("BANKCARD")
+                    .build();
+            if (StringUtils.equals(env, "prod") || StringUtils.equals(env, "pre")) {
+                merchantMember.setNotifyUrl(MessageFormatter.arrayFormat(AdapayNotifyConstants.corp_member_notify_url_prod, "adapay"));
+            } else {
+                merchantMember.setNotifyUrl(MessageFormatter.arrayFormat(AdapayNotifyConstants.corp_member_notify_url_test, "adapay"));
+            }
+            return merchantMember;
+        } else {
+            YeepayMember yeepayMember = (YeepayMember) tenantMember;
+            PaymentMerchant.MerchantMember merchantMember = PaymentMerchant.MerchantMember.builder()
+                    .memberId(yeepayMember.getMemberId())
+                    .merchantName(yeepayMember.getName())
+                    .merchantType(yeepayMember.getMerchantType())
+                    .provinceCode(yeepayMember.getProvCode())
+                    .cityCode(yeepayMember.getAreaCode())
+                    .districtCode(yeepayMember.getDistrictCode())
+                    .socialCreditCode(yeepayMember.getSocialCreditCode())
+                    .socialCreditCodeExpires(yeepayMember.getSocialCreditCodeExpires())
+                    .businessScope(yeepayMember.getBusinessScope())
+                    .legalName(yeepayMember.getLegalPerson())
+                    .legalLicenceNo(yeepayMember.getLegalCertId())
+                    .legalCertIdExpires(yeepayMember.getLegalCertIdExpires())
+                    .mobile(yeepayMember.getLegalMp())
+                    .legalLicenceType(yeepayMember.getLegalLicenceType())
+                    .legalLicenceFrontUrl(yeepayMember.getLegalLicenceFrontUrl())
+                    .legalLicenceBackUrl(yeepayMember.getLegalLicenceBackUrl())
+                    .address(yeepayMember.getAddress())
+                    .bankCode(yeepayMember.getBankCode())
+                    .bankAccountType(yeepayMember.getBankAcctType())
+                    .bankCardNo(yeepayMember.getCardNo())
+                    .cardName(yeepayMember.getCardName())
+                    .zipCode(yeepayMember.getZipCode())
+                    .requestNo(yeepayMember.getRequestNo())
+                    .licenceNo(yeepayMember.getSocialCreditCode())
+                    .licenceUrl(yeepayMember.getLicenceUrl())
+                    .openAccountLicenceUrl(yeepayMember.getOpenAccountLicenceUrl())
+                    .contactName(yeepayMember.getContactName())
+                    .contactMobile(yeepayMember.getContactMobile())
+                    .contactEmail(yeepayMember.getContactEmail())
+                    .contactLicenceNo(yeepayMember.getContactLicenceNo())
+                    .primaryIndustryCategory("120")
+                    .secondaryIndustryCategory("120004")
+                    .settlementDirection("BANKCARD")
+                    .build();
+            String notifyURL = MessageFormatter.arrayFormat(AdapayNotifyConstants.corp_member_notify_url_test, "yeepay");
+            if (StringUtils.equals(env, "prod") || StringUtils.equals(env, "pre")) {
+                notifyURL = MessageFormatter.arrayFormat(AdapayNotifyConstants.corp_member_notify_url_prod, "yeepay");
+            }
+            merchantMember.setNotifyUrl(notifyURL);
+            return merchantMember;
+        }
+    }
+
+    @Override
     @Transactional(rollbackFor = Exception.class)
     public boolean updateMember(HfMember member, File file) throws Exception {
         HfMember hfMember = hfMemberDao.get(member.getId());
         if (hfMember == null) {
             throw new BizException("商户不存在请核对");
         }
+        BasePaymentService paymentService = paymentServiceContext.getPaymentService(member.getPayerName() + "_" + member.getTenantId());
+        if (paymentService == null) {
+            throw new BizException("支付渠道不存在:{}", member.getPayerName());
+        }
+        PaymentMerchant.MerchantConfig merchantConfig = getMerchantConfig(member.getPayerName() + "_" + member.getTenantId(),member.getTenantId());
+        PaymentMerchant.MerchantMember merchantMember = getHfMerchantMember(member);
+        merchantMember.setAttachFile(file);
+        try {
+            log.info("更新商户信息失败:{}", JSON.toJSONString(merchantMember));
+            paymentService.updatePaymentCorpMember(merchantConfig, merchantMember);
+        }catch (Exception e) {
+            log.error("更新商户信息失败", e);
+            throw new BizException("更新商户信息失败:" + e.getMessage());
+        }
+        /*Integer tenantId = member.getTenantId();
 
-        Integer tenantId = member.getTenantId();
         
         HfMerchantConfig hfMerchantConfig = hfMerchantConfigService.queryByTenantId(tenantId, member.getPayerName());
         if(hfMerchantConfig == null){
@@ -141,7 +271,7 @@ public class HfMemberServiceImpl extends BaseServiceImpl<Integer, HfMember> impl
         enterpriseUser.setMemberId(member.getMemberId());
         enterpriseUser.setName(member.getName());
         
-        if(StringUtils.equals(env, "prod")){
+        if(StringUtils.equals(env, "prod") || StringUtils.equals(env, "pre")){
             enterpriseUser.setNotifyUrl(AdapayNotifyConstants.corp_member_notify_url_prod);
         }else {
             enterpriseUser.setNotifyUrl(AdapayNotifyConstants.corp_member_notify_url_test);
@@ -152,7 +282,7 @@ public class HfMemberServiceImpl extends BaseServiceImpl<Integer, HfMember> impl
         enterpriseUser.setSocialCreditCodeExpires(member.getSocialCreditCodeExpires());
         
         corpMemberService.update(hfMerchantConfig.getMerKey(), hfMerchantConfig.getAppId(), enterpriseUser, enterpriseUser.getNotifyUrl());
-
+*/
         Date nowDate = new Date();
         member.setUpdateTime(nowDate);
         member.setStatus("pending");
@@ -170,11 +300,6 @@ public class HfMemberServiceImpl extends BaseServiceImpl<Integer, HfMember> impl
         if (!hfMember.getStatus().equals("succeeded")) {
             throw new BizException("商户审核通过,才能绑定结算卡");
         }
-        /*hfMember.setCardNo(accountInfo.getCardId());
-        hfMember.setBankCode(accountInfo.getBankCode());
-        hfMember.setBankAcctType(accountInfo.getBankAcctType());
-        hfMember.setCardName(accountInfo.getCardName());*/
-        
         accountInfo.setAreaCode(hfMember.getAreaCode());
         accountInfo.setBankAcctType(hfMember.getBankAcctType());
         accountInfo.setBankCode(hfMember.getBankCode());
@@ -191,22 +316,87 @@ public class HfMemberServiceImpl extends BaseServiceImpl<Integer, HfMember> impl
         if(hfMerchantConfig == null){
         	throw new BizException("机构[{}]汇付商户信息找不到", tenantId);
         }
+        BasePaymentService paymentService = paymentServiceContext.getPaymentService(PaymentChannelEnum.ADAPAY.getCode() + "_" + TenantContextHolder.getTenantId());
+        if (paymentService == null) {
+            throw new BizException("支付渠道不存在:{}", PaymentChannelEnum.ADAPAY.getCode() + "_" + TenantContextHolder.getTenantId());
+        }
 
         //删除结算账户
         if (StringUtils.isNotBlank(hfMember.getSettleAccountId())) {
-            settleAccountService.delete(hfMerchantConfig.getMerKey(), hfMerchantConfig.getAppId(), memberId, hfMember.getSettleAccountId());
+//            settleAccountService.delete(hfMerchantConfig.getMerKey(), hfMerchantConfig.getAppId(), memberId, hfMember.getSettleAccountId());
+            paymentService.deleteSettleAccount(hfMerchantConfig.getMerKey(), hfMerchantConfig.getAppId(), memberId, hfMember.getSettleAccountId());
         }
 
         //创建结算账户
-        String settleAccountId = settleAccountService.create(hfMerchantConfig.getMerKey(), hfMerchantConfig.getAppId(), accountInfo);
+//        String settleAccountId = settleAccountService.create(hfMerchantConfig.getMerKey(), hfMerchantConfig.getAppId(), accountInfo);
+        PaymentMerchant.MerchantConfig merchantConfig = getMerchantConfig(PaymentChannelEnum.ADAPAY.getCode(), TenantContextHolder.getTenantId());
+        String settleAccount = paymentService.createSettleAccount(merchantConfig, getAccountInfo(accountInfo));
 
-        hfMember.setSettleAccountId(settleAccountId);
+        hfMember.setSettleAccountId(settleAccount);
         if (hfMemberDao.update(hfMember) <= 0) {
             throw new BizException("绑卡失败,请重试");
         }
         return true;
     }
-    
+
+    private PaymentMerchant.AccountInfo getAccountInfo(AccountInfo accountInfo) {
+        return PaymentMerchant.AccountInfo.builder()
+                .memberId(accountInfo.getMemberId())
+                .cardId(accountInfo.getCardId())
+                .cardName(accountInfo.getCardName())
+                .certId(accountInfo.getCertId())
+                .certType(accountInfo.getCertType())
+                .telNo(accountInfo.getTelNo())
+                .bankCode(accountInfo.getBankCode())
+                .bankName(accountInfo.getBankName())
+                .bankAcctType(accountInfo.getBankAcctType())
+                .provCode(accountInfo.getProvCode())
+                .areaCode(accountInfo.getAreaCode())
+                .build();
+    }
+
+    @Override
+    public Map<String, Object> queryWithKey(String appId, String merKey, int pageIndex, long createdGte, long createdLte) {
+        Map<java.lang.String, java.lang.Object> paymentParams = new HashMap<>();
+        paymentParams.put("app_id", appId);
+        paymentParams.put("page_index", pageIndex);
+        paymentParams.put("page_size", "20");
+        paymentParams.put("created_gte", createdGte);
+        paymentParams.put("created_lte", createdLte);
+        Map<String, Object> payment = null;
+        try {
+            payment = com.huifu.adapay.model.Payment.queryList(paymentParams, merKey);
+        } catch (BaseAdaPayException e) {
+            throw new BizException("查询支付对象列表失败:{}", e, e.getMessage());
+        }
+        String error_code = (String) payment.get("error_code");
+        if (null != error_code) {
+            String errorMsg = (String) payment.get("error_msg");
+            throw new ThirdpartyException(errorMsg);
+        }
+        return payment;
+    }
+
+    @Override
+    public Map<String, Object> queryConfirmList(String appId, String merchantKey, String paymentId){
+        Map<String, Object> paymentParams = new HashMap<>();
+        paymentParams.put("app_id", appId);
+        paymentParams.put("payment_id", paymentId);
+
+        Map<String, Object> payment = null;
+        try {
+            payment = com.huifu.adapay.model.Payment.queryConfirmList(paymentParams, merchantKey);
+        } catch (BaseAdaPayException e) {
+            throw new BizException("查询支付确认列表失败:{}", e, e.getMessage());
+        }
+        String error_code = (String) payment.get("error_code");
+        if (null != error_code) {
+            String errorMsg = (String) payment.get("error_msg");
+            throw new ThirdpartyException(errorMsg);
+        }
+        return payment;
+    }
+    /*
 	private boolean createMemberWithAdapay(HfMember member, File file) {
 		Integer tenantId = member.getTenantId();
 
@@ -231,7 +421,7 @@ public class HfMemberServiceImpl extends BaseServiceImpl<Integer, HfMember> impl
 		enterpriseUser.setMemberId(member.getMemberId());
 		enterpriseUser.setName(member.getName());
 
-		if (StringUtils.equals(env, "prod")) {
+		if (StringUtils.equals(env, "prod") || StringUtils.equals(env, "pre")) {
 			enterpriseUser.setNotifyUrl(MessageFormatter.arrayFormat(AdapayNotifyConstants.corp_member_notify_url_prod, "adapay"));
 		} else {
 			enterpriseUser.setNotifyUrl(MessageFormatter.arrayFormat(AdapayNotifyConstants.corp_member_notify_url_test, "adapay"));
@@ -276,10 +466,10 @@ public class HfMemberServiceImpl extends BaseServiceImpl<Integer, HfMember> impl
 		merchantInfo.setSettlementDirection("BANKCARD");
 
 		String notifyURL = MessageFormatter.arrayFormat(AdapayNotifyConstants.corp_member_notify_url_test, "yeepay");
-		if (StringUtils.equals(env, "prod")) {
+		if (StringUtils.equals(env, "prod") || StringUtils.equals(env, "pre")) {
 			notifyURL = MessageFormatter.arrayFormat(AdapayNotifyConstants.corp_member_notify_url_prod, "yeepay");
 		}
 		
 		return yeepayMerchantService.registerSaasMerchantV2(hfMerchantConfig, merchantInfo, notifyURL);
-	}
+	}*/
 }

+ 89 - 13
mec-biz/src/main/java/com/ym/mec/biz/service/impl/HfMerchantConfigServiceImpl.java

@@ -1,32 +1,108 @@
 package com.ym.mec.biz.service.impl;
 
-import java.util.HashMap;
-import java.util.Map;
-
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
+import com.google.common.collect.Lists;
+import com.microsvc.toolkit.middleware.payment.common.api.PaymentServiceContext;
+import com.microsvc.toolkit.middleware.payment.impl.AdapayPaymentServicePlugin;
+import com.microsvc.toolkit.middleware.payment.impl.YeepayPaymentServicePlugin;
+import com.microsvc.toolkit.middleware.payment.properties.PayConfigProperties;
 import com.ym.mec.biz.dal.dao.HfMerchantConfigDao;
-import com.ym.mec.biz.dal.enums.PaymentChannelEnum;
 import com.ym.mec.biz.service.HfMerchantConfigService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
-import com.ym.mec.thirdparty.adapay.AdapayInit;
 import com.ym.mec.thirdparty.adapay.entity.HfMerchantConfig;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
+import javax.annotation.Resource;
+import java.util.HashMap;
+import java.util.List;
 
+@Slf4j
 @Service
-public class HfMerchantConfigServiceImpl extends BaseServiceImpl<Integer, HfMerchantConfig>  implements HfMerchantConfigService,InitializingBean {
+public class HfMerchantConfigServiceImpl extends BaseServiceImpl<Integer, HfMerchantConfig>  implements HfMerchantConfigService {
 	
-	@Autowired
+	@Resource
 	private HfMerchantConfigDao hfMerchantConfigDao;
+	@Resource
+	private PayConfigProperties properties;
 
 	@Override
 	public BaseDAO<Integer, HfMerchantConfig> getDAO() {
 		return hfMerchantConfigDao;
 	}
 
-	@Override
+	@PostConstruct
+	public void init(){
+		List<HfMerchantConfig> list = hfMerchantConfigDao.findAll(new HashMap<>());
+
+		if(CollectionUtils.isEmpty(list)) {
+			return;
+		}
+
+		List<String> pluginNames = Lists.newArrayList();
+		for (HfMerchantConfig config : list) {
+			if (StringUtils.isEmpty(config.getPayerName())) {
+				log.error("数据错误 {}", config);
+			} else if (StringUtils.equalsIgnoreCase(config.getPayerName(),"ADAPAY")) {
+				PayConfigProperties.AdapayPayConfig adapayPayConfig = new PayConfigProperties.AdapayPayConfig();
+				adapayPayConfig.setEnable(true);
+				adapayPayConfig.setAppId(config.getAppId());
+				adapayPayConfig.setPayType(config.getPayerName() + "_" + config.getTenantId());
+				adapayPayConfig.setMerchantKey(config.getMerKey());
+				adapayPayConfig.setMerchantId(config.getApiKey());
+				adapayPayConfig.setPayNotifyUrl(properties.getPayNotifyUrl());
+				adapayPayConfig.setRefundNotifyUrl(properties.getRefundNotifyUrl());
+				adapayPayConfig.setKeyPublic(config.getRsaPublicKey());
+				adapayPayConfig.setKeyPrivate(config.getRsaPrivateKey());
+				adapayPayConfig.setWxAppId(config.getWxAppId());
+				adapayPayConfig.setWxAppSecret(config.getWxAppSecret());
+//				adapayPayConfig.setMiniAppId(config.getMiniAppId());
+//				adapayPayConfig.setMiniAppSecret(config.getMiniAppSerret());
+				adapayPayConfig.setSupportCreditCards(properties.getSupportCreditCards());
+				try {
+					AdapayPaymentServicePlugin plugin = new AdapayPaymentServicePlugin(adapayPayConfig.getPayType(), adapayPayConfig, false);
+					PaymentServiceContext.addPlugin(plugin);
+					pluginNames.add(plugin.venderName());
+				} catch (Exception e) {
+					log.error("初始[汇付]化支付插件失败", e);
+				}
+			} else if (StringUtils.equalsIgnoreCase(config.getPayerName(),"YEEPAY")){
+				PayConfigProperties.YeepayPayConfig yeepayPayConfig = new PayConfigProperties.YeepayPayConfig();
+				yeepayPayConfig.setEnable(true);
+				yeepayPayConfig.setAppId(config.getAppId());
+				yeepayPayConfig.setPayType(config.getPayerName() + "_" + config.getTenantId());
+				yeepayPayConfig.setMerchantId(config.getPlatformPayeeMemberId());
+				yeepayPayConfig.setPayNotifyUrl(properties.getPayNotifyUrl());
+				yeepayPayConfig.setRefundNotifyUrl(properties.getRefundNotifyUrl());
+				yeepayPayConfig.setKeyPublic(config.getRsaPublicKey());
+				yeepayPayConfig.setKeyPrivate(config.getRsaPrivateKey());
+				yeepayPayConfig.setWxAppId(config.getWxAppId());
+				yeepayPayConfig.setWxAppSecret(config.getWxAppSecret());
+				yeepayPayConfig.setSupportCreditCards(properties.getSupportCreditCards());
+				yeepayPayConfig.setAlipayAppId(config.getAlipayAppId());
+				yeepayPayConfig.setAlipayPrivateKey(config.getAlipayPrivateKey());
+				yeepayPayConfig.setAlipayPublicKey(config.getAlipayPublicKey());
+//				yeepayPayConfig.setMiniAppId(config.getMiniAppId());
+//				yeepayPayConfig.setMiniAppSecret(config.getMiniAppSerret());
+				try {
+					YeepayPaymentServicePlugin plugin = new YeepayPaymentServicePlugin(yeepayPayConfig.getPayType(), yeepayPayConfig, false);
+					PaymentServiceContext.addPlugin(plugin);
+
+					pluginNames.add(plugin.venderName());
+				} catch (Exception e) {
+					log.error("初始化[易宝]支付插件失败", e);
+				}
+			}else {
+				log.error("数据错误 {}", config);
+			}
+		}
+		log.info("初始化支付插件完成, plugins={}", pluginNames);
+	}
+
+	/*@Override
 	public void afterPropertiesSet() throws Exception {
 		AdapayInit adapayInit = AdapayInit.getInstance(false, true);
 		
@@ -34,7 +110,7 @@ public class HfMerchantConfigServiceImpl extends BaseServiceImpl<Integer, HfMerc
 		params.put("payerName", PaymentChannelEnum.ADAPAY.getCode());
 		
 		adapayInit.initWithMerConfig(hfMerchantConfigDao.findAll(params));
-	}
+	}*/
 
 	@Override
 	public HfMerchantConfig queryByTenantId(Integer tenantId, String payerName) {

+ 54 - 42
mec-biz/src/main/java/com/ym/mec/biz/service/impl/MemberRankSettingServiceImpl.java

@@ -5,6 +5,10 @@ import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.google.common.collect.Lists;
+import com.microsvc.toolkit.middleware.payment.common.api.BasePaymentService;
+import com.microsvc.toolkit.middleware.payment.common.api.PaymentServiceContext;
+import com.microsvc.toolkit.middleware.payment.common.api.entity.PaymentResp;
+import com.microsvc.toolkit.middleware.payment.common.api.enums.PaymentStatus;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.*;
@@ -23,8 +27,6 @@ import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.service.IdGeneratorService;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
-import com.ym.mec.thirdparty.adapay.Payment;
-import com.ym.mec.thirdparty.adapay.entity.HfMerchantConfig;
 import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
 import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.date.DateUtil;
@@ -36,7 +38,6 @@ import org.redisson.api.RBucket;
 import org.redisson.api.RedissonClient;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.http.HttpStatus;
 import org.springframework.stereotype.Service;
@@ -55,91 +56,91 @@ import static com.ym.mec.biz.dal.enums.CouponDetailTypeEnum.MEMBER;
 @Service
 public class MemberRankSettingServiceImpl extends BaseServiceImpl<Integer, MemberRankSetting> implements MemberRankSettingService {
 
-    @Autowired
+    @Resource
     private MemberRankSettingDao memberRankSettingDao;
-    @Autowired
+    @Resource
     private MemberRankPrivilegesDao memberRankPrivilegesDao;
-    @Autowired
+    @Resource
     private StudentService studentService;
-    @Autowired
+    @Resource
     private StudentPaymentOrderService studentPaymentOrderService;
-    @Autowired
+    @Resource
     private SysUserCashAccountService sysUserCashAccountService;
-    @Autowired
+    @Resource
     private SysUserCashAccountDetailService sysUserCashAccountDetailService;
 
-    @Autowired
+    @Resource
     private LessonCoursewareService lessonCoursewareService;
 
-    @Autowired
+    @Resource
     private SysUserService sysUserService;
 
     @Resource
     private CbsMusicScoreCategoriesService cbsMusicScoreCategoriesService;
     @Lazy
-    @Autowired
+    @Resource
     private ContractService contractService;
-    @Autowired
+    @Resource
     private SysUserFeignService sysUserFeignService;
-    @Autowired
+    @Resource
     private CloudTeacherOrderService cloudTeacherOrderService;
-    @Autowired
+    @Resource
     private IdGeneratorService idGeneratorService;
-    @Autowired
+    @Resource
     private SysCouponCodeService sysCouponCodeService;
-    @Autowired
+    @Resource
     private StudentCloudCoachPaymentDetailsService studentCloudCoachPaymentDetailsService;
-    @Autowired
+    @Resource
     private CloudCoachPaymentProgramService cloudCoachPaymentProgramService;
-    @Autowired
+    @Resource
     private RedissonClient redissonClient;
-    @Autowired
+    @Resource
     private SysConfigDao sysConfigDao;
-    @Autowired
+    @Resource
     private SysMessageService sysMessageService;
-    @Autowired
+    @Resource
     private VipGroupActivityDao vipGroupActivityDao;
-    @Autowired
+    @Resource
     private TenantConfigService tenantConfigService;
-    @Autowired
+    @Resource
     private ActivityUserMapperService activityUserMapperService;
-    @Autowired
+    @Resource
     private MemberFeeSettingService memberFeeSettingService;
-    @Autowired
+    @Resource
     private TeacherDao teacherDao;
-    @Autowired
+    @Resource
     private LiveGoodsService liveGoodsService;
-    @Autowired
+    @Resource
     private TempBuyFreeLiveTheoryCourseDao tempBuyFreeLiveTheoryCourseDao;
-    @Autowired
+    @Resource
     private TempLittleArtistTrainingCampUserRelationDao tempLittleArtistTrainingCampUserRelationDao;
-    @Autowired
+    @Resource
     private StudentPaymentOrderDetailDao studentPaymentOrderDetailDao;
 
-    @Autowired
+    @Resource
     private MemberRankCategoryMapperService memberRankCategoryMapperService;
 
-    @Autowired
+    @Resource
     private MemberRankCourseTypeMapperService memberRankCourseTypeMapperService;
     
-    @Autowired
-    private HfMerchantConfigService hfMerchantConfigService;
-
-    @Autowired
+    @Resource
     private SysMusicScoreDao sysMusicScoreDao;
 
-    @Autowired
+    @Resource
     private CloudTeacherOrderDao cloudTeacherOrderDao;
 
-    @Autowired
+    @Resource
     private MusicGroupDao musicGroupDao;
 
-    @Autowired
+    @Resource
     private TenantMemberRankSettingService tenantMemberRankSettingService;
 
-    @Autowired
+    @Resource
     private MemberRankOrganizationFeeMapperDao memberRankOrganizationFeeMapperDao;
 
+    @Resource
+    private PaymentServiceContext paymentServiceContext;
+
     private final Logger logger = LoggerFactory.getLogger(this.getClass());
 
     @Override
@@ -724,7 +725,18 @@ public class MemberRankSettingServiceImpl extends BaseServiceImpl<Integer, Membe
     //检查订单在第三方是否支付成功
     private void checkOrder(StudentPaymentOrder orderByOrderNo) throws Exception {
         if (StringUtils.isNotBlank(orderByOrderNo.getTransNo())) {
-
+            BasePaymentService paymentService = paymentServiceContext.getPaymentService(orderByOrderNo.getPaymentChannel() + "_" + orderByOrderNo.getTenantId());
+            if (paymentService == null) {
+                throw new BizException("支付渠道[{}]找不到", orderByOrderNo.getPaymentChannel());
+            }
+            PaymentResp paymentResp = paymentService.query(orderByOrderNo.getOrderNo(), orderByOrderNo.getOrderNo());
+            if (Objects.isNull(paymentResp)) {
+                throw new BizException("订单支付状态获取异常,稍后请重试");
+            }
+            if (paymentResp.getPaymentStatus() == PaymentStatus.SUCCESSED) {
+                throw new BizException("该订单已经支付成功,无法关闭。");
+            }
+            /*
             HfMerchantConfig hfMerchantConfig = hfMerchantConfigService.queryByTenantId(orderByOrderNo.getTenantId(), orderByOrderNo.getPaymentChannel());
             if(hfMerchantConfig == null){
             	throw new BizException("机构[{}]汇付商户信息找不到", orderByOrderNo.getTenantId());
@@ -734,7 +746,7 @@ public class MemberRankSettingServiceImpl extends BaseServiceImpl<Integer, Membe
             String status = (String) payment.get("status");
             if (status.equals("succeeded")) {
                 throw new BizException("该订单已经支付成功,无法关闭。");
-            }
+            }*/
         }
     }
 

+ 61 - 51
mec-biz/src/main/java/com/ym/mec/biz/service/impl/OrderPayOpsServiceImpl.java

@@ -1,33 +1,5 @@
 package com.ym.mec.biz.service.impl;
 
-import java.math.BigDecimal;
-import java.math.RoundingMode;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.TimeUnit;
-import java.util.function.BiPredicate;
-import java.util.function.Consumer;
-import java.util.function.Function;
-
-import com.huifu.adapay.core.util.StringUtil;
-import com.ym.mec.biz.service.*;
-import org.apache.commons.lang3.StringUtils;
-import org.redisson.api.RBucket;
-import org.redisson.api.RedissonClient;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.util.DigestUtils;
-
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.alipay.api.AlipayApiException;
@@ -35,6 +7,10 @@ import com.alipay.api.AlipayClient;
 import com.alipay.api.DefaultAlipayClient;
 import com.alipay.api.request.AlipaySystemOauthTokenRequest;
 import com.alipay.api.response.AlipaySystemOauthTokenResponse;
+import com.microsvc.toolkit.middleware.payment.common.api.BasePaymentService;
+import com.microsvc.toolkit.middleware.payment.common.api.PaymentServiceContext;
+import com.microsvc.toolkit.middleware.payment.common.api.entity.PaymentOrder;
+import com.microsvc.toolkit.middleware.payment.common.api.entity.PaymentReq;
 import com.ym.mec.biz.dal.dao.SysConfigDao;
 import com.ym.mec.biz.dal.dto.PaymentParam;
 import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
@@ -43,15 +19,33 @@ import com.ym.mec.biz.dal.entity.TenantOrderRecord;
 import com.ym.mec.biz.dal.entity.TenantPaymentOrder;
 import com.ym.mec.biz.dal.enums.DealStatusEnum;
 import com.ym.mec.biz.dal.enums.PaymentChannelEnum;
+import com.ym.mec.biz.service.*;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.WrapperUtil;
 import com.ym.mec.thirdparty.adapay.ConfigInit;
-import com.ym.mec.thirdparty.adapay.Payment;
 import com.ym.mec.thirdparty.adapay.entity.HfMerchantConfig;
-import com.ym.mec.thirdparty.yeepay.YeepayPaymentService;
 import com.ym.mec.util.date.DateUtil;
 import com.ym.mec.util.http.HttpUtil;
 import com.ym.mec.util.json.JsonUtil;
+import org.apache.commons.lang3.StringUtils;
+import org.joda.time.DateTime;
+import org.redisson.api.RBucket;
+import org.redisson.api.RedissonClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+import org.springframework.util.DigestUtils;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
+import java.util.function.BiPredicate;
+import java.util.function.Consumer;
+import java.util.function.Function;
 
 import static com.ym.mec.biz.dal.enums.OrderTypeEnum.MALL_BUY;
 
@@ -63,25 +57,22 @@ import static com.ym.mec.biz.dal.enums.OrderTypeEnum.MALL_BUY;
 public class OrderPayOpsServiceImpl implements OrderPayOpsService {
     private static final Logger log = LoggerFactory.getLogger(OrderPayOpsServiceImpl.class);
 
-    @Autowired
+    @Resource
     private StudentPaymentOrderService studentPaymentOrderService;
-    @Autowired
+    @Resource
     private TenantPaymentOrderService tenantPaymentOrderService;
-    @Autowired
+    @Resource
     private TenantOrderRecordService tenantOrderRecordService;
-    
-    @Autowired
+    @Resource
     private HfMerchantConfigService hfMerchantConfigService;
-    
-    @Autowired
-    private YeepayPaymentService yeepayPaymentService;
-    
-    @Autowired
+    @Resource
     private RedissonClient redissonClient;
-    @Autowired
+    @Resource
     private TenantConfigService tenantConfigService;
-    @Autowired
+    @Resource
     private SysConfigDao sysConfigDao;
+    @Resource
+    private PaymentServiceContext paymentServiceContext;
 
     //tenant 机构开通、续费付款、 cloudTeacherOrder 团练宝激活支付、tenantRecharge 机构充值
     private static final String[] tenantPlatform = {"tenant", "cloudTeacherOrder", "tenantRecharge"};
@@ -101,7 +92,7 @@ public class OrderPayOpsServiceImpl implements OrderPayOpsService {
             //tenant 机构开通、续费付款、 cloudTeacherOrder 团练宝激活支付、tenantRecharge 机构充值
             payment = tenantPlatformOrder(payParam);
             //主动延迟检查订单
-            delayCheckTenant();
+//            delayCheckTenant();感觉不需要这个流程,反而会影响正常的支付回调
         } else {
             StudentPaymentOrder studentPaymentOrder = studentPaymentOrderService.findOrderByOrderNo(payParam.getOrderNo());
             if(studentPaymentOrder == null) {
@@ -141,7 +132,6 @@ public class OrderPayOpsServiceImpl implements OrderPayOpsService {
 
 
     private void checkSing(PaymentParam param) {
-        
         //查询商户支付账户
         HfMerchantConfig hfMerchantConfig = hfMerchantConfigService.queryByTenantId(param.getTenantId(), param.getPayerName());
         if(hfMerchantConfig == null){
@@ -262,14 +252,34 @@ public class OrderPayOpsServiceImpl implements OrderPayOpsService {
         	throw new BizException("请配置机构的汇付商户信息");
         }
         
-        Map<String, Object> payment = new HashMap<String, Object>();
-        String transNo = null;
-        
+//        Map<String, Object> payment = new HashMap<String, Object>();
+//        String transNo = null;
+        BasePaymentService paymentService = paymentServiceContext.getPaymentService(payParam.getPayerName() + "_" + payParam.getTenantId());
+        if (paymentService == null) {
+            throw new BizException("支付渠道错误:" + payParam.getPayerName());
+        }
+        PaymentOrder paymentOrder = new PaymentOrder();
+        paymentOrder.setMerOrderNo(payParam.getOrderNo());
+        paymentOrder.setPrice(payParam.getAmount());
+        paymentOrder.setSubject(payParam.getOrderSubject());
+        paymentOrder.setBody(payParam.getOrderBody());
+        paymentOrder.setExpirationTime(DateTime.now().plusMinutes(120).toDate());
+        paymentOrder.setPaymentChannel(payParam.getPayChannel());
+        paymentOrder.setIp(payParam.getIp());
+        paymentOrder.setCode(payParam.getCode());
+        paymentOrder.setPayMode(true);
+        PaymentReq paymentReq = paymentService.pay(paymentOrder);
+        if (Objects.isNull(paymentReq)) {
+            throw new BizException("生成支付参数异常");
+        }
+//        transNo = paymentReq.getTransNo();
+        /*
         PaymentChannelEnum paymentChannel = PaymentChannelEnum.codeOf(payParam.getPayerName());
         
         switch (paymentChannel) {
 		case ADAPAY:
 
+
 	        //初始化支付数据
 	        Map<String, Object> paymentParams = getPaymentParam(payParam, clazz, hfMerchantConfig.getPlatformPayeeMemberId());
 	        paymentParams.put("time_expire", timeExpire);
@@ -320,12 +330,12 @@ public class OrderPayOpsServiceImpl implements OrderPayOpsService {
 
 		default:
 			break;
-		}
-        log.info("executePayment create order param >>>>> {}", JSON.toJSONString(payment));
+		}*/
+        log.info("executePayment create order param >>>>> {}", JSON.toJSONString(paymentReq));
         //修改流水
-        setTransNoByApply(transNo, clazz, setOption, action);
+        setTransNoByApply(paymentReq.getTransNo(), clazz, setOption, action);
 
-        return payment;
+        return paymentReq.getReqParams();
     }
 
     private <T> void checkOrderState(T obj, Function<T, DealStatusEnum> func) {

+ 25 - 46
mec-biz/src/main/java/com/ym/mec/biz/service/impl/PayServiceImpl.java

@@ -1,78 +1,57 @@
 package com.ym.mec.biz.service.impl;
 
-import java.math.BigDecimal;
-import java.util.*;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.stream.Collectors;
-
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
 import com.alibaba.fastjson.JSON;
-import com.ym.mec.biz.dal.dao.GoodsProcurementDao;
 import com.ym.mec.biz.dal.dao.HfMemberDao;
 import com.ym.mec.biz.dal.dao.StudentPaymentOrderDao;
 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.Goods;
-import com.ym.mec.biz.dal.entity.GoodsProcurement;
-import com.ym.mec.biz.dal.entity.HfMember;
-import com.ym.mec.biz.dal.entity.StudentPaymentOrder;
-import com.ym.mec.biz.dal.entity.StudentPaymentOrderDetail;
-import com.ym.mec.biz.dal.entity.StudentPaymentRouteOrder;
-import com.ym.mec.biz.dal.entity.SysPaymentConfig;
+import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.FeeTypeEnum;
 import com.ym.mec.biz.dal.enums.OrderDetailTypeEnum;
 import com.ym.mec.biz.dal.enums.OrderTypeEnum;
 import com.ym.mec.biz.dal.enums.PaymentChannelEnum;
-import com.ym.mec.biz.service.GoodsService;
-import com.ym.mec.biz.service.HfMerchantConfigService;
-import com.ym.mec.biz.service.PayService;
-import com.ym.mec.biz.service.SellOrderService;
-import com.ym.mec.biz.service.StudentPaymentOrderDetailService;
-import com.ym.mec.biz.service.StudentPaymentOrderService;
-import com.ym.mec.biz.service.SysConfigService;
-import com.ym.mec.biz.service.SysPaymentConfigService;
+import com.ym.mec.biz.service.*;
 import com.ym.mec.common.exception.BizException;
-import com.ym.mec.common.redis.service.RedisCache;
 import com.ym.mec.thirdparty.adapay.ConfigInit;
 import com.ym.mec.thirdparty.adapay.Payment;
 import com.ym.mec.thirdparty.adapay.entity.HfMerchantConfig;
 import com.ym.mec.thirdparty.yqpay.YqPayUtil;
 import com.ym.mec.util.date.DateUtil;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.stream.Collectors;
 
 /**
  * 支付服务类
  */
 @Service
 public class PayServiceImpl implements PayService {
-    @Autowired
+    @Resource
     private StudentPaymentOrderService studentPaymentOrderService;
-    
-    @Autowired
+    @Resource
     private StudentPaymentOrderDetailService studentPaymentOrderDetailService;
-    
-    @Autowired
+    @Resource
     private GoodsService goodsService;
-    
-    @Autowired
+    @Resource
     private HfMerchantConfigService hfMerchantConfigService;
-    
-    @Autowired
+    @Resource
     private SysConfigDao sysConfigDao;
-    @Autowired
+    @Resource
     private SysPaymentConfigService sysPaymentConfigService;
-    @Autowired
+    @Resource
     private StudentPaymentRouteOrderDao studentPaymentRouteOrderDao;
-    @Autowired
+    @Resource
     private SellOrderService sellOrderService;
-    @Autowired
+    @Resource
     private HfMemberDao hfMemberDao;
-    
-    @Autowired
+    @Resource
     private StudentPaymentOrderDao studentPaymentOrderDao;
 
     @Override
@@ -94,7 +73,7 @@ public class PayServiceImpl implements PayService {
 		PaymentChannelEnum paymentChannel = PaymentChannelEnum.codeOf(paymentChannelStr);
         
         Integer tenantId = studentPaymentOrder.getTenantId();
-        
+
         HfMerchantConfig hfMerchantConfig = hfMerchantConfigService.queryByTenantId(tenantId, paymentChannelStr);
         if(hfMerchantConfig == null){
         	throw new BizException("机构[{}][{}]商户信息找不到", tenantId, paymentChannelStr);
@@ -135,11 +114,11 @@ public class PayServiceImpl implements PayService {
 		Date date = new Date();
         
         //如果当前是买的小课/网管课
-		if (studentPaymentOrder != null && (studentPaymentOrder.getType() == OrderTypeEnum.SMALL_CLASS_TO_BUY || studentPaymentOrder.getType() == OrderTypeEnum.PRACTICE_GROUP_BUY
-				|| studentPaymentOrder.getType() == OrderTypeEnum.PRACTICE_GROUP_RENEW || studentPaymentOrder.getType() == OrderTypeEnum.LIVE_GROUP_BUY)) {
+		if (studentPaymentOrder.getType() == OrderTypeEnum.SMALL_CLASS_TO_BUY || studentPaymentOrder.getType() == OrderTypeEnum.PRACTICE_GROUP_BUY
+				|| studentPaymentOrder.getType() == OrderTypeEnum.PRACTICE_GROUP_RENEW || studentPaymentOrder.getType() == OrderTypeEnum.LIVE_GROUP_BUY) {
 			
 			//忽略的分部
-			List<Integer> ignoreOrganList = Arrays.asList(4);
+			List<Integer> ignoreOrganList = Collections.singletonList(4);
 			
 			// 是否由平台收款
 			String isPlatformCollection = sysConfigDao.findConfigValue(SysConfigService.IS_OPEN_SMALL_CLASS_INCOME_TO_PLATFORM);
@@ -190,7 +169,7 @@ public class PayServiceImpl implements PayService {
 		}
 		
 		//如果是乐队指导培训的订单,由武汉学校收款
-		if(studentPaymentOrder != null && studentPaymentOrder.getType() == OrderTypeEnum.DIRECTOR_TRAINING_CAMP) {
+		if(studentPaymentOrder.getType() == OrderTypeEnum.DIRECTOR_TRAINING_CAMP) {
 			
 			Integer routeOrganId = 50;
 			HfMember receiverMember = hfMemberDao.getByOrganId(routeOrganId, paymentChannelStr);

+ 165 - 60
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPaymentOrderServiceImpl.java

@@ -3,6 +3,12 @@ package com.ym.mec.biz.service.impl;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.google.common.collect.Lists;
+import com.microsvc.toolkit.common.tools.ThreadPool;
+import com.microsvc.toolkit.middleware.payment.common.api.BasePaymentService;
+import com.microsvc.toolkit.middleware.payment.common.api.PaymentServiceContext;
+import com.microsvc.toolkit.middleware.payment.common.api.entity.*;
+import com.microsvc.toolkit.middleware.payment.common.api.enums.PaymentStatus;
 import com.ym.mec.auth.api.client.SysUserFeignService;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.biz.dal.dao.*;
@@ -27,18 +33,15 @@ import com.ym.mec.common.service.IdGeneratorService;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.common.tenant.TenantContextHolder;
 import com.ym.mec.thirdparty.adapay.ConfigInit;
-import com.ym.mec.thirdparty.adapay.Payment;
 import com.ym.mec.thirdparty.adapay.entity.BaseResult;
-import com.ym.mec.thirdparty.adapay.entity.HfMerchantConfig;
-import com.ym.mec.thirdparty.yeepay.YeepayPaymentService;
 import com.ym.mec.thirdparty.yqpay.*;
 import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.date.DateUtil;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.http.HttpStatus;
 import org.springframework.stereotype.Service;
@@ -46,7 +49,6 @@ import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
-import java.io.IOException;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.util.*;
@@ -57,6 +59,7 @@ import java.util.stream.Collectors;
 import static com.ym.mec.biz.dal.enums.DealStatusEnum.CLOSE;
 import static com.ym.mec.biz.dal.enums.DealStatusEnum.SUCCESS;
 
+@Slf4j
 @Service
 public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, StudentPaymentOrder> implements StudentPaymentOrderService {
 
@@ -127,14 +130,10 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
     @Resource
     private ContractService contractService;
     @Resource
-    private HfMerchantConfigService hfMerchantConfigService;
-    @Resource
     private StudentDao studentDao;
     @Resource
     private SysUserCashAccountDetailService sysUserCashAccountDetailService;
     @Resource
-    private YeepayPaymentService yeepayPaymentService;
-    @Resource
     private CourseScheduleStudentPaymentDao courseScheduleStudentPaymentDao;
     @Resource
     private StudentRepairDao studentRepairDao;
@@ -150,6 +149,8 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
     private MusicGroupPaymentCalenderAddressService musicGroupPaymentCalenderAddressService;
     @Resource
     private MusicGroupPaymentCalenderMemberService musicGroupPaymentCalenderMemberService;
+    @Resource
+    private PaymentServiceContext paymentServiceContext;
 
     private final Logger logger = LoggerFactory.getLogger(this.getClass());
     @Override
@@ -157,8 +158,6 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
         return studentPaymentOrderDao;
     }
 
-    private final static Logger LOGGER = LoggerFactory.getLogger(StudentPaymentOrderServiceImpl.class);
-
     @Override
     public StudentPaymentOrderDao getDao() {
         return studentPaymentOrderDao;
@@ -356,16 +355,20 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
     @Transactional
     public OrderCancelModel updateOrderStatus(Date date, StudentPaymentOrder payingOrder) throws Exception {
     	
-        HfMerchantConfig hfMerchantConfig = hfMerchantConfigService.queryByTenantId(payingOrder.getTenantId(), payingOrder.getPaymentChannel());
+        /*HfMerchantConfig hfMerchantConfig = hfMerchantConfigService.queryByTenantId(payingOrder.getTenantId(), payingOrder.getPaymentChannel());
         if(hfMerchantConfig == null){
             throw new BizException("机构[{}]汇付商户信息找不到", payingOrder.getTenantId());
-        }
+        }*/
         
-        PaymentChannelEnum paymentChannel = PaymentChannelEnum.codeOf(payingOrder.getPaymentChannel());
+//        PaymentChannelEnum paymentChannel = PaymentChannelEnum.codeOf(payingOrder.getPaymentChannel());
         
-        OrderCancelModel  model = new OrderCancelModel();
-        Map<String, Object> payment = new HashMap<String, Object>();
-
+//        Map<String, Object> payment = new HashMap<String, Object>();
+        PaymentResp paymentResp = paymentServiceContext.getPaymentService(payingOrder.getPaymentChannel() + "_" + payingOrder.getTenantId())
+                .query(payingOrder.getTransNo(), payingOrder.getOrderNo());
+        if (paymentResp == null) {
+            throw new BizException("订单支付状态获取异常,稍后请重试,transNo:{},orderNo:{},paymentChannel:{}", payingOrder.getTransNo(), payingOrder.getOrderNo(), payingOrder.getPaymentChannel());
+        }
+/*
         if(paymentChannel == PaymentChannelEnum.ADAPAY) {
         	payment = Payment.queryPayment(payingOrder.getTransNo(), hfMerchantConfig.getMerKey());
         }else if(paymentChannel == PaymentChannelEnum.YEEPAY) {
@@ -386,28 +389,33 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
         	throw new BizException("[{}]支付渠道不支持", payingOrder.getPaymentChannel());
         }
         
-        LOGGER.warn("订单[{}]交易主动查询接口返回:{}", payingOrder.getTransNo(), payment);
-
+        LOGGER.warn("订单[{}]交易主动查询接口返回:{}", payingOrder.getTransNo(), payment);*/
         Map<String, String> rpMap = new HashMap<>();
         rpMap.put("merOrderNo", payingOrder.getOrderNo());
         rpMap.put("orderNo", payingOrder.getTransNo());
-        rpMap.put("channelType", (String) payment.get("pay_channel"));
-        model.setPayChannel((String) payment.get("pay_channel"));
-        String status = (String) payment.get("status");
-        if (payment.containsKey("error_msg")) {
-            rpMap.put("remarks", (String) payment.get("error_msg"));
+        rpMap.put("channelType", paymentResp.getPaymentChannel());
+        OrderCancelModel  model = new OrderCancelModel();
+        model.setPayChannel(paymentResp.getPaymentChannel());
+//        String status = (String) payment.get("status");
+        if (paymentResp.getPaymentStatus() == PaymentStatus.FAILED || (DateUtil.minutesBetween(DateUtil.addHours(payingOrder.getUpdateTime(), 2),date) > 0)) {
+            rpMap.put("remarks", paymentResp.getMsg());
+            rpMap.put("tradeState", "0");
+            model.setStatus(false);
+        }else if (paymentResp.getPaymentStatus() == PaymentStatus.SUCCESSED) {
+            rpMap.put("tradeState", "1");
+            model.setStatus(true);
         }
-        if (status.equals("succeeded")) {
+        /*if (status.equals("succeeded")) {
             rpMap.put("tradeState", "1");
             model.setStatus(true);
         } else if (status.equals("failed")
                 || (DateUtil.minutesBetween(DateUtil.addHours(payingOrder.getUpdateTime(), 2),date) > 0)) {
             rpMap.put("tradeState", "0");
             model.setStatus(false);
-        }
+        }*/
 
-        if (status.equals("succeeded") ||
-                (status.equals("failed") || payingOrder.getCreateTime().before(DateUtil.addMinutes(new Date(), -35)))) {
+        if (paymentResp.getPaymentStatus() == PaymentStatus.SUCCESSED ||
+                (paymentResp.getPaymentStatus() == PaymentStatus.FAILED || payingOrder.getCreateTime().before(DateUtil.addMinutes(new Date(), -35)))) {
             try {
                 updateOrder(rpMap); //更新订单
                 model.setSuccess(true);
@@ -501,21 +509,45 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
         }
         Date date = new Date();
         
-        HfMerchantConfig hfMerchantConfig = null;
-        
         List<StudentPaymentRouteOrder> routeOrders = studentPaymentRouteOrderService.getDao().getRouteOrders(order.getOrderNo());
-        
-        PaymentChannelEnum paymentChannel = PaymentChannelEnum.codeOf(order.getPaymentChannel());
-        
 
-    	if(hfMerchantConfig == null){
-    		hfMerchantConfig = hfMerchantConfigService.queryByTenantId(order.getTenantId(), order.getPaymentChannel());
-    	}
+        /*HfMerchantConfig hfMerchantConfig = hfMerchantConfigService.queryByTenantId(order.getTenantId(), order.getPaymentChannel());
         if(hfMerchantConfig == null){
-        	throw new BizException("机构[{}][{}]商户信息找不到", order.getTenantId(), order.getPaymentChannel());
+            throw new BizException("机构[{}][{}]商户信息找不到", order.getTenantId(), order.getPaymentChannel());
+        }*/
+        BasePaymentService paymentService = paymentServiceContext.getPaymentService(order.getPaymentChannel() + "_" + order.getTenantId());
+        for (StudentPaymentRouteOrder routeOrder : routeOrders) {
+            if (routeOrder.getRouteAmount().compareTo(BigDecimal.ZERO) == 0) {
+                routeOrder.setServiceFee(BigDecimal.ZERO);
+                routeOrder.setUpdateTime(date);
+                studentPaymentRouteOrderService.getDao().update(routeOrder);
+                continue;
+            }
+            // 执行分账逻辑
+            DivideReq.DivMember divMember = DivideReq.DivMember.builder()
+                    .memberId(routeOrder.getMerNo().equals(ConfigInit.merNo) ? "0" : routeOrder.getMerNo())
+                    .amount(routeOrder.getRouteAmount().setScale(2, RoundingMode.HALF_UP))
+                    .feeFlag("Y")
+                    .build();
+            DivideReq divideReq = DivideReq.builder()
+                    .transNo(order.getTransNo())
+                    .orderNo(order.getOrderNo())
+                    .divideOrderNo(idGeneratorService.generatorId("payment") + "")
+                    .divideAmount(divMember.getAmount())
+                    .divMembers(Lists.newArrayList(divMember))
+                    .build();
+            try {
+                DivideResp divide = paymentService.divide(divideReq);
+                log.info("分账信息返回:{}", divide);
+                routeOrder.setServiceFee(divide.getFeeAmount());
+                routeOrder.setUpdateTime(date);
+                studentPaymentRouteOrderService.getDao().update(routeOrder);
+            } catch (Exception e) {
+                log.error("分账失败 orderId:{}", order.getId(), e);
+            }
         }
-        
-        StudentPaymentRouteOrder studentPaymentRouteOrder = null;
+
+        /*StudentPaymentRouteOrder studentPaymentRouteOrder = null;
         
         if(paymentChannel == PaymentChannelEnum.ADAPAY) {
         	
@@ -601,7 +633,7 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
 
                 studentPaymentRouteOrderService.getDao().update(spro);
 			}
-		}
+		}*/
         
         return true;
     }
@@ -886,12 +918,24 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
             return PayStatus.FAILED;
         }
         
-    	HfMerchantConfig hfMerchantConfig = hfMerchantConfigService.queryByTenantId(studentPaymentOrder.getTenantId(), studentPaymentOrder.getPaymentChannel());
+    	/*HfMerchantConfig hfMerchantConfig = hfMerchantConfigService.queryByTenantId(studentPaymentOrder.getTenantId(), studentPaymentOrder.getPaymentChannel());
         if(hfMerchantConfig == null){
         	throw new BizException("机构[{}]汇付商户信息找不到", studentPaymentOrder.getTenantId());
+        }*/
+        PaymentResp paymentResp = paymentServiceContext.getPaymentService(paymentChannel + "_" + studentPaymentOrder.getTenantId())
+                .query(transNo, orderNo);
+        if (paymentResp == null) {
+            throw new BizException("订单支付状态获取异常,稍后请重试,transNo:{},orderNo:{},paymentChannel:{}", transNo, orderNo, paymentChannel);
+        }
+        if (paymentResp.getPaymentStatus() == PaymentStatus.SUCCESSED) {
+            return PayStatus.SUCCESSED;
+        } else if (paymentResp.getPaymentStatus() == PaymentStatus.PENDDING) {
+            return PayStatus.PAYING;
+        }else {
+            return PayStatus.FAILED;
         }
-        
-        if (StringUtils.equals(paymentChannel, "ADAPAY")) {
+
+        /*if (StringUtils.equals(paymentChannel, "ADAPAY")) {
             Map<String, Object> payment = Payment.queryPayment(transNo, hfMerchantConfig.getMerKey());
             String status = (String) payment.get("status");
             if (status.equals("succeeded")) {
@@ -945,7 +989,7 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
         	}
             throw new BizException(result.get("message").toString());
         }
-        throw new BizException("支付渠道错误");
+        throw new BizException("支付渠道错误");*/
     }
 
     @Override
@@ -1071,7 +1115,8 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
         Date nowDate = new Date();
         //增加商品库存
         List<StudentPaymentOrderDetail> studentPaymentOrderDetailList = studentPaymentOrderDetailService.queryOrderDetail(order.getId());
-        String goodsIds = studentPaymentOrderDetailList.stream().filter(t -> StringUtils.isNotBlank(t.getMinuendStockGoodsIdList())).map(t -> t.getMinuendStockGoodsIdList()).collect(Collectors.joining(","));
+        String goodsIds = studentPaymentOrderDetailList.stream().map(StudentPaymentOrderDetail::getMinuendStockGoodsIdList)
+                .filter(StringUtils::isNotBlank).collect(Collectors.joining(","));
         if(StringUtils.isNotBlank(goodsIds)){
         	List<Goods> goodsList = goodsService.getGoodsWithLocked(goodsIds);
         	Map<Integer,Goods> goodsMap = goodsList.stream().collect(Collectors.toMap(Goods :: getId, t -> t));
@@ -1091,7 +1136,7 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
 				
 				batchUpdateGoodsMap.put(goods.getId(), goods);
         	}
-            if(batchUpdateGoodsMap.size() > 0){
+            if(!batchUpdateGoodsMap.isEmpty()){
             	goodsService.batchUpdate(new ArrayList<Goods>(batchUpdateGoodsMap.values()));
             }
         }
@@ -1119,9 +1164,9 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
             if (studentRegistration.getMusicGroupStatus() == StudentMusicGroupStatusEnum.APPLY) {
                 List<StudentPaymentOrder> oldStudentPaymentOrderList = this.queryByCondition(GroupType.MUSIC, musicGroupId, userId, SUCCESS, OrderTypeEnum.APPLY);
                 //判断是否有成功的订单,如果有,表示已经处理过人数
-                if (oldStudentPaymentOrderList == null || oldStudentPaymentOrderList.size() == 0) {
+                if (CollectionUtils.isEmpty(oldStudentPaymentOrderList)) {
                     List<StudentPaymentOrderDetail> orderDetail = studentPaymentOrderDetailService.getOrderDetail(order.getId());
-                    if (orderDetail != null && orderDetail.size() > 0) {
+                    if (CollectionUtils.isNotEmpty(orderDetail)) {
                         long count = orderDetail.stream().filter(e -> e.getType() == OrderDetailTypeEnum.MUSICAL || e.getType() == OrderDetailTypeEnum.CLOUD_TEACHER).count();
                         MusicGroup musicGroup = musicGroupService.get(musicGroupId);
                         //如果购买了乐器或者云教练,或者不是会员团,那么关闭订单时人数减一
@@ -1327,7 +1372,7 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
         studentGoodsSell.setGoodsJson(model.getOrderInfo());
         studentGoodsSell.setOrderNo(model.getOrderNo());
         List<Integer> couponIdList = model.getCouponIdList();
-        if (couponIdList != null && couponIdList.size() > 0) {
+        if (CollectionUtils.isNotEmpty(couponIdList)) {
             studentGoodsSell.setCouponIds(StringUtils.join(couponIdList, ","));
         }
         studentGoodsSell.setTenantId(student.getTenantId());
@@ -1418,13 +1463,13 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
                         long count = goodsOrderItemVOS.stream().filter(e -> StringUtils.isEmpty(e.getOrderSn())).count();
                         //如果有空的商品货号,不处理
                         if(count == 0l){
-                            List<String> productSns = goodsOrderItemVOS.stream().map(e -> e.getProductSn()).distinct().collect(Collectors.toList());
+                            List<String> productSns = goodsOrderItemVOS.stream().map(GoodsOrderItemVO::getProductSn).distinct().collect(Collectors.toList());
                             List<Goods> goodsList = goodsService.getGoodsDao().findBySns(productSns);
                             //如果有不匹配的商品货号,不处理
                             if(CollectionUtils.isEmpty(goodsList) || goodsList.size() < productSns.size()){
                                 return;
                             }
-                            Map<String, Goods> goodsSnMap = goodsList.stream().collect(Collectors.groupingBy(e -> e.getSn(),
+                            Map<String, Goods> goodsSnMap = goodsList.stream().collect(Collectors.groupingBy(Goods::getSn,
                                     Collectors.collectingAndThen(Collectors.toList(), v -> v.get(0))));
                             List<StudentPaymentOrderDetail> orderDetails = new ArrayList<>();
                             List<SellOrder> sellOrders = new ArrayList<>();
@@ -1685,12 +1730,52 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
     }
 
     @Override
-    @Transactional
+    @Transactional(rollbackFor = Exception.class)
     public OrderCancelModel cancelOrder(StudentPaymentOrder order, String reason) {
         OrderCancelModel model = new OrderCancelModel();
         model.setSuccess(true);
         try {
-            HfMerchantConfig hfMerchantConfig = hfMerchantConfigService.queryByTenantId(order.getTenantId(), order.getPaymentChannel());
+            String errorMessage = null;
+            BasePaymentService paymentService = paymentServiceContext.getPaymentService(order.getPaymentChannel() + "_" + order.getTenantId());
+            if (paymentService == null) {
+                throw new BizException("支付渠道不支持:{}", order.getPaymentChannel());
+            }
+            PaymentResp paymentResp = paymentService.query(order.getTransNo(), order.getOrderNo());
+            if (paymentResp == null) {
+                throw new BizException("订单支付状态获取异常,稍后请重试,transNo:{},orderNo:{},paymentChannel:{}", order.getTransNo(), order.getOrderNo(), order.getPaymentChannel());
+            }
+            if (paymentResp.getPaymentStatus() == PaymentStatus.SUCCESSED) {
+                model.setStatus(true);
+                order.setStatus(SUCCESS);
+            } else if (paymentResp.getPaymentStatus() == PaymentStatus.PENDDING) {
+                // 执行关单操作
+                PaymentClose paymentClose = paymentService.close(order.getTransNo(), reason, order.getOrderNo());
+                model.setSuccess(false);
+                if (Objects.nonNull(paymentClose)) {
+                    model.setMessage(paymentClose.getMsg());
+                    errorMessage = paymentClose.getMsg();
+                    // 订单取消,三方返回异常信息
+                    if (StringUtils.isNotEmpty(errorMessage)) {
+                        log.warn("cancelPayment orderNo={}, ex={}", order.getOrderNo(), errorMessage);
+                        // 记录异常消息
+                        ThreadPool.getExecutor().submit(() -> {
+                            order.setMemo(paymentClose.getMsg());
+                            // 更新订单关单异常信息
+                            studentPaymentOrderDao.update(order);
+                        });
+                    }else {
+                        model.setSuccess(true);
+                    }
+                }
+                model.setStatus(false);
+                order.setStatus(CLOSE);
+            }else {
+                model.setStatus(false);
+                order.setStatus(CLOSE);
+                order.setMemo(reason);
+            }
+
+            /*HfMerchantConfig hfMerchantConfig = hfMerchantConfigService.queryByTenantId(order.getTenantId(), order.getPaymentChannel());
             if(hfMerchantConfig == null){
                 throw new BizException("机构[{}]汇付商户信息找不到", order.getTenantId());
             }
@@ -1738,7 +1823,7 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
                 order.setStatus(CLOSE);
                 model.setSuccess(success);
                 model.setMessage(closeInfo.get("msg"));
-            }
+            }*/
             if (model.getSuccess()) {
                 TenantContextHolder.setTenantId(order.getTenantId());
                 callOrderCallBack(order);
@@ -1753,23 +1838,43 @@ public class StudentPaymentOrderServiceImpl extends BaseServiceImpl<Long, Studen
     }
 
     @Override
-    @Transactional
+    @Transactional(rollbackFor = Exception.class)
     public BaseResult<Map<String, Object>> refund(String orderNo, String notifyUrl, String refundNo) {
 
-        StudentPaymentOrder orderByOrderNo = this.findOrderByOrderNo(orderNo);
-        if (orderByOrderNo == null) {
+        StudentPaymentOrder paymentOrder = this.findOrderByOrderNo(orderNo);
+        if (paymentOrder == null) {
             throw new BizException("为找到订单");
         }
-        if (orderByOrderNo.getActualAmount().compareTo(BigDecimal.ZERO) ==0) {
+        if (paymentOrder.getActualAmount().compareTo(BigDecimal.ZERO) ==0) {
             throw new BizException("0元订单");
         }
-
+        BasePaymentService paymentService = paymentServiceContext.getPaymentService(paymentOrder.getPaymentChannel() + "_" + paymentOrder.getTenantId());
+        if (paymentService == null) {
+            throw new BizException("支付渠道不支持:{}", paymentOrder.getPaymentChannel());
+        }
+        RefundOrder refundOrder = new RefundOrder();
+        refundOrder.setUserId(paymentOrder.getUserId().toString());
+        refundOrder.setMerOrderNo(refundNo);
+        refundOrder.setRefundAmount(paymentOrder.getActualAmount());
+        refundOrder.setOrderAmount(paymentOrder.getActualAmount());
+        refundOrder.setTransNo(paymentOrder.getTransNo());
+        refundOrder.setPaymentOrderNo(paymentOrder.getOrderNo());
+        RefundResp refundResp = paymentService.refund(refundOrder);
+        // 申请请求失败
+        if (PaymentStatus.FAILED == refundResp.getPaymentStatus()) {
+            return BaseResult.failed(refundResp.getMsg());
+        } else {
+            Map<String,Object> param = new HashMap<>();
+            param.put("refundNo",refundNo);
+            return BaseResult.succeed(param);
+        }
+/*
         HfMerchantConfig hfMerchantConfig = hfMerchantConfigService.queryByTenantId(orderByOrderNo.getTenantId(), orderByOrderNo.getPaymentChannel());
         if(hfMerchantConfig == null){
             throw new BizException("请配置机构的汇付商户信息");
         }
         return Payment.reversePayment(orderByOrderNo.getTransNo(),hfMerchantConfig.getAppId(),refundNo,
-                               orderByOrderNo.getActualAmount().setScale(2,BigDecimal.ROUND_HALF_UP).toString(),notifyUrl);
+                               orderByOrderNo.getActualAmount().setScale(2, RoundingMode.HALF_UP).toString(),notifyUrl);*/
     }
 
     @Override

+ 4 - 3
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentRegistrationServiceImpl.java

@@ -1386,7 +1386,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
             
         }
 
-        if (studentPaymentOrder.getStatus().equals(DealStatusEnum.FAILED)) {
+        if (studentPaymentOrder.getStatus().equals(DealStatusEnum.FAILED) || studentPaymentOrder.getStatus().equals(DealStatusEnum.CLOSE)) {
             MusicGroup musicGroup = musicGroupDao.get(studentRegistration.getMusicGroupId());
             studentRegistration.setPayingStatus(0);
             studentRegistrationDao.update(studentRegistration);
@@ -1395,7 +1395,8 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
             
             //增加商品库存
             List<StudentPaymentOrderDetail> studentPaymentOrderDetailList = studentPaymentOrderDetailService.queryOrderDetail(studentPaymentOrder.getId());
-            String goodsIds = studentPaymentOrderDetailList.stream().filter(t -> StringUtils.isNotBlank(t.getMinuendStockGoodsIdList())).map(t -> t.getMinuendStockGoodsIdList()).collect(Collectors.joining(","));
+            String goodsIds = studentPaymentOrderDetailList.stream().map(StudentPaymentOrderDetail::getMinuendStockGoodsIdList)
+                    .filter(StringUtils::isNotBlank).collect(Collectors.joining(","));
             if(StringUtils.isNotBlank(goodsIds)){
 //            	GoodsProcurement goodsProcurement = null;
             	List<Goods> goodsList = goodsService.getGoodsWithLocked(goodsIds);
@@ -1435,7 +1436,7 @@ public class StudentRegistrationServiceImpl extends BaseServiceImpl<Long, Studen
             		goodsProcurementDao.batchUpdate(new ArrayList<GoodsProcurement>(goodsProcurementMap.values()));
             	}*/
                 
-                if(batchUpdateGoodsMap.size() > 0){
+                if(!batchUpdateGoodsMap.isEmpty()){
                 	goodsService.batchUpdate(new ArrayList<Goods>(batchUpdateGoodsMap.values()));
                 }
             }

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

@@ -31,13 +31,13 @@ import org.apache.commons.lang.math.NumberUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Isolation;
 import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.util.*;
@@ -51,53 +51,53 @@ import static com.ym.mec.biz.dal.enums.DealStatusEnum.*;
 @Service
 public class StudentRepairServiceImpl extends BaseServiceImpl<Integer, StudentRepair> implements StudentRepairService {
     private static final Logger log = LoggerFactory.getLogger(StudentRepairServiceImpl.class);
-    @Autowired
+    @Resource
     private StudentRepairDao studentRepairDao;
-    @Autowired
+    @Resource
     private SysUserFeignService sysUserFeignService;
-    @Autowired
+    @Resource
     private PayService payService;
-    @Autowired
+    @Resource
     private IdGeneratorService idGeneratorService;
-    @Autowired
+    @Resource
     private SysConfigDao sysConfigDao;
-    @Autowired
+    @Resource
     private StudentPaymentOrderService studentPaymentOrderService;
-    @Autowired
+    @Resource
     private StudentPaymentOrderDetailService studentPaymentOrderDetailService;
-    @Autowired
+    @Resource
     private MusicGroupDao musicGroupDao;
-    @Autowired
+    @Resource
     private SysUserCashAccountService sysUserCashAccountService;
-    @Autowired
+    @Resource
     private SysUserCashAccountDetailService sysUserCashAccountDetailService;
-    @Autowired
+    @Resource
     private SysMessageService sysMessageService;
-    @Autowired
+    @Resource
     private StudentService studentService;
-    @Autowired
+    @Resource
     private StudentPaymentRouteOrderService studentPaymentRouteOrderService;
-    @Autowired
+    @Resource
     private SellOrderService sellOrderService;
-    @Autowired
+    @Resource
     private StudentGoodsSellDao studentGoodsSellDao;
-    @Autowired
+    @Resource
     private StudentPaymentOrderAddressService studentPaymentOrderAddressService;
 
     @Lazy
-    @Autowired
+    @Resource
     private ContractService contractService;
-    @Autowired
+    @Resource
     private GoodsService goodsService;
-    @Autowired
+    @Resource
     private StudentInstrumentService studentInstrumentService;
-    @Autowired
+    @Resource
     private StudentGoodsSellService studentGoodsSellService;
-    @Autowired
+    @Resource
     private SysCouponCodeService sysCouponCodeService;
-    @Autowired
+    @Resource
     private TeacherService teacherService;
-    @Autowired
+    @Resource
     private MallFeignService mallFeignService;
 
     private final Logger logger = LoggerFactory.getLogger(this.getClass());

+ 5 - 2
mec-biz/src/main/java/com/ym/mec/biz/service/impl/TenantInfoServiceImpl.java

@@ -666,6 +666,9 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
      * 获取协议变量参数
      */
     private Map<String, Object> getContractParam(TenantInfoPageVo tenantInfo) {
+        if (tenantInfo.getStudentUpLimit() == null) {
+            tenantInfo.setStudentUpLimit(0);
+        }
         //将数据转换为Map
         Map<String, Object> param = WrapperUtil.toMap(tenantInfo);
         //购买服务的时长单位
@@ -748,7 +751,7 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
         log.info("getContractAndUpLoad >>>>ok  tenantId:{} en:{} val:{}", tenantId, en, val);
         Date now = new Date();
         //创建PDF本次缓存地址
-        String srcPdfPath = contractBaseDir + lexiaoyaContract + DateUtils.formatDate(now, "yyyyMMddHHmmss") + "/" + tenantId + "_" + java.time.LocalDateTime.now().getSecond() + ".pdf";
+        String srcPdfPath = contractBaseDir + "/" + lexiaoyaContract + "/" + DateUtils.formatDate(now, "yyyyMMddHHmmss") + "/" + tenantId + "_" + java.time.LocalDateTime.now().getSecond() + ".pdf";
         //生成文件
         File srcFile = new File(srcPdfPath);
         if (!srcFile.getParentFile().exists()) {
@@ -761,7 +764,7 @@ public class TenantInfoServiceImpl extends ServiceImpl<TenantInfoDao, TenantInfo
             PDFUtil.renderToPDFByData(TenantInfoServiceImpl.class.getResource("/").getFile(), contractHtml, srcPdfPath, "simsun.ttc");
         } catch (IOException e) {
             FileUtils.deleteQuietly(srcFile);
-            throw new BizException("生成产品协议失败");
+            log.error("生成产品协议失败", e);
         }
         //上传到云服务器后获取上传地址
         String dateStrOss = DateUtils.formatDate(now, "yyyy/MM/dd");

+ 75 - 85
mec-biz/src/main/java/com/ym/mec/biz/service/impl/TenantOrderRecordServiceImpl.java

@@ -1,79 +1,44 @@
 package com.ym.mec.biz.service.impl;
 
-import java.math.BigDecimal;
-import java.security.PrivateKey;
-import java.security.PublicKey;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.concurrent.TimeUnit;
-import java.util.function.Consumer;
-
-import com.alibaba.fastjson.JSONObject;
-import com.huifu.adapay.core.AdapayCore;
-import com.huifu.adapay.core.util.AdapaySign;
-import com.yeepay.g3.sdk.yop.encrypt.DigitalEnvelopeDTO;
-import com.yeepay.g3.sdk.yop.utils.DigitalEnvelopeUtils;
-import com.yeepay.g3.sdk.yop.utils.RSAKeyUtils;
-
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.joda.time.LocalDateTime;
-import org.redisson.api.RBucket;
-import org.redisson.api.RedissonClient;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.microsvc.toolkit.middleware.payment.common.api.BasePaymentService;
+import com.microsvc.toolkit.middleware.payment.common.api.PaymentServiceContext;
+import com.microsvc.toolkit.middleware.payment.common.api.entity.PaymentResp;
+import com.microsvc.toolkit.middleware.payment.common.api.enums.PaymentStatus;
 import com.ym.mec.biz.dal.dao.CloudTeacherOrderDao;
 import com.ym.mec.biz.dal.dao.TenantOrderRecordDao;
 import com.ym.mec.biz.dal.dto.TenantOrderRecordDto;
-import com.ym.mec.biz.dal.entity.CloudTeacherOrder;
-import com.ym.mec.biz.dal.entity.PlatformServe;
-import com.ym.mec.biz.dal.entity.PlatformServeDetail;
-import com.ym.mec.biz.dal.entity.TenantAssetsInfo;
-import com.ym.mec.biz.dal.entity.TenantConfig;
-import com.ym.mec.biz.dal.entity.TenantInfo;
-import com.ym.mec.biz.dal.entity.TenantOrderRecord;
-import com.ym.mec.biz.dal.entity.TenantProductInfo;
-import com.ym.mec.biz.dal.entity.TenantProxyDividend;
-import com.ym.mec.biz.dal.entity.TenantProxyUserRelation;
+import com.ym.mec.biz.dal.entity.*;
 import com.ym.mec.biz.dal.enums.DealStatusEnum;
 import com.ym.mec.biz.dal.enums.MessageTypeEnum;
-import com.ym.mec.biz.dal.enums.PaymentChannelEnum;
 import com.ym.mec.biz.dal.enums.PeriodEnum;
 import com.ym.mec.biz.dal.enums.TenantOrderRecordEnum;
-import com.ym.mec.biz.service.CloudTeacherOrderService;
-import com.ym.mec.biz.service.HfMerchantConfigService;
-import com.ym.mec.biz.service.PlatformServeDetailService;
-import com.ym.mec.biz.service.PlatformServeService;
-import com.ym.mec.biz.service.SysMessageService;
-import com.ym.mec.biz.service.TenantAssetsInfoService;
-import com.ym.mec.biz.service.TenantConfigService;
-import com.ym.mec.biz.service.TenantInfoService;
-import com.ym.mec.biz.service.TenantOrderRecordService;
-import com.ym.mec.biz.service.TenantProductInfoService;
-import com.ym.mec.biz.service.TenantProxyDividendService;
-import com.ym.mec.biz.service.TenantProxyUserRelationService;
+import com.ym.mec.biz.service.*;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.page.PageInfo;
 import com.ym.mec.common.page.PageUtil;
 import com.ym.mec.common.page.WrapperUtil;
 import com.ym.mec.common.tenant.TenantContextHolder;
-import com.ym.mec.thirdparty.adapay.Payment;
-import com.ym.mec.thirdparty.adapay.entity.HfMerchantConfig;
 import com.ym.mec.thirdparty.message.MessageSenderPluginContext;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.joda.time.LocalDateTime;
+import org.redisson.api.RBucket;
+import org.redisson.api.RedissonClient;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
-import javax.servlet.http.HttpServletRequest;
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.util.*;
+import java.util.concurrent.TimeUnit;
+import java.util.function.Consumer;
 
 /**
  * 机构付款记录表(TenantOrderRecord)表服务实现类
@@ -85,36 +50,34 @@ import javax.servlet.http.HttpServletRequest;
 public class TenantOrderRecordServiceImpl extends ServiceImpl<TenantOrderRecordDao, TenantOrderRecord> implements TenantOrderRecordService {
     private static final Logger log = LoggerFactory.getLogger(TenantOrderRecordServiceImpl.class);
 
-    @Autowired
+    @Resource
     private TenantProductInfoService tenantProductInfoService;
-    @Autowired
+    @Resource
     private PlatformServeService platformServeService;
-    @Autowired
+    @Resource
     private PlatformServeDetailService platformServeDetailService;
-    @Autowired
+    @Resource
     private TenantInfoService tenantInfoService;
-    @Autowired
+    @Resource
     private RedissonClient redissonClient;
-    @Autowired
+    @Resource
     private TenantAssetsInfoService assetsInfoService;
-    @Autowired
+    @Resource
     private TenantConfigService tenantConfigService;
-    @Autowired
+    @Resource
     private SysMessageService sysMessageService;
-    @Autowired
+    @Resource
     private CloudTeacherOrderDao cloudTeacherOrderDao;
-    @Autowired
+    @Resource
     private CloudTeacherOrderService cloudTeacherOrderService;
-    @Autowired
+    @Resource
     private TenantProxyDividendService tenantProxyDividendService;
-    @Autowired
+    @Resource
     private TenantProxyUserRelationService tenantProxyUserRelationService;
-
-    @Autowired
-    private HfMerchantConfigService hfMerchantConfigService;
-    
-    @Autowired
+    @Resource
     private TenantOrderRecordDao tenantOrderRecordDao;
+    @Resource
+    private PaymentServiceContext paymentServiceContext;
 
     //订单不存在
     private static final String PAYMENT_ID_NOT_EXISTS = "payment_id_not_exists";
@@ -230,13 +193,13 @@ public class TenantOrderRecordServiceImpl extends ServiceImpl<TenantOrderRecordD
 
     //开通成功
     @Transactional(rollbackFor = Exception.class)
-    private void open(TenantOrderRecord record) {
+    public void open(TenantOrderRecord record) {
         tenantInfoService.tenantOpenSuccess(record.getTenantId());
     }
 
     //续费成功
     @Transactional(rollbackFor = Exception.class)
-    private void renew(TenantOrderRecord record) {
+    public void renew(TenantOrderRecord record) {
         //机构产品信息
         TenantProductInfo productInfo = tenantProductInfoService.getOne(new WrapperUtil<TenantProductInfo>()
                 .hasEq("tenant_id_", record.getTenantId()).queryWrapper().eq("using_", 0));
@@ -355,7 +318,22 @@ public class TenantOrderRecordServiceImpl extends ServiceImpl<TenantOrderRecordD
 
     //主动去第三方查询订单状态
     private void checkTransOrderState(TenantOrderRecord orderRecord) {
-        Map<String, Object> payment = new HashMap<String, Object>();
+        BasePaymentService paymentService = paymentServiceContext.getPaymentService(orderRecord.getPaymentChannel() + "_" + orderRecord.getTenantId());
+        if (paymentService == null) {
+            throw new BizException("支付渠道[{}]找不到", orderRecord.getPaymentChannel());
+        }
+        PaymentResp paymentResp = paymentService.query(orderRecord.getOrderNo(), orderRecord.getOrderNo());
+        if (Objects.isNull(paymentResp)) {
+            throw new BizException("订单支付状态获取异常,稍后请重试");
+        }
+        if (paymentResp.getPaymentStatus() == PaymentStatus.SUCCESSED) {
+            orderRecord.setOrderState(1);
+        }else if (paymentResp.getPaymentStatus() == PaymentStatus.PENDDING) {
+            orderRecord.setOrderState(0);
+        }else {
+            orderRecord.setOrderState(2);
+        }
+        /*Map<String, Object> payment = new HashMap<String, Object>();
         try {
             Integer tenantId = orderRecord.getTenantId();
             HfMerchantConfig hfMerchantConfig = hfMerchantConfigService.queryByTenantId(tenantId, orderRecord.getPaymentChannel());
@@ -402,7 +380,7 @@ public class TenantOrderRecordServiceImpl extends ServiceImpl<TenantOrderRecordD
             log.info("    >>>>> checkTenantOrder  orderRecord >>>>> {}", JSON.toJSONString(orderRecord));
         } catch (Exception e) {
             log.error("    >>>>> checkTenantOrder  payment error>>>>> {}", JSON.toJSONString(orderRecord));
-        }
+        }*/
     }
 
     //超时返回true
@@ -466,19 +444,31 @@ public class TenantOrderRecordServiceImpl extends ServiceImpl<TenantOrderRecordD
      */
     @Override
     @Transactional(rollbackFor = Exception.class)
-	public String callback(String orderNo, HttpServletRequest request) {
-
-		TenantOrderRecord record = this.getOne(Wrappers.<TenantOrderRecord> lambdaQuery().eq(TenantOrderRecord::getOrderNo, orderNo));
-		if (Objects.isNull(record)) {
-			return "failed";
-		}
+	public void callback(TenantOrderRecord record, PaymentResp paymentResp) {
 		record = tenantOrderRecordDao.getLockedById(record.getId());
 		// 只处理未支付状态的订单
 		if (!record.getOrderState().equals(0)) {
-			return "succeeded";
+			return;
 		}
+        PaymentStatus paymentStatus = paymentResp.getPaymentStatus();
+        if (paymentStatus == PaymentStatus.SUCCESSED) {
+            Consumer<TenantOrderRecord> consumer = checkOrder.get(record.getOrderType());
+            if (Objects.nonNull(consumer)) {
+                consumer.accept(record);
+            }
+            LocalDateTime now = LocalDateTime.now();
+            record.setPayDate(now.toLocalDate().toDate());
+            record.setPayTime(now.toDate());
+            // 修改流水
+            record.setOrderState(1);
+            baseMapper.updateById(record);
+        } else if (paymentStatus == PaymentStatus.FAILED) {
+            // 修改流水
+            record.setOrderState(2);
+            baseMapper.updateById(record);
+        }
 
-		PaymentChannelEnum paymentChannel = PaymentChannelEnum.codeOf(record.getPaymentChannel());
+        /*PaymentChannelEnum paymentChannel = PaymentChannelEnum.codeOf(record.getPaymentChannel());
 
 		try {
 
@@ -574,7 +564,7 @@ public class TenantOrderRecordServiceImpl extends ServiceImpl<TenantOrderRecordD
 			return e.getMessage();
 		}
 
-		return "succeeded";
+		return "succeeded";*/
 	}
 
 }

+ 17 - 49
mec-biz/src/main/java/com/ym/mec/biz/service/impl/TenantPaymentOrderServiceImpl.java

@@ -1,33 +1,10 @@
 package com.ym.mec.biz.service.impl;
 
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
-import com.ym.mec.biz.service.*;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-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;
-
-import com.alibaba.fastjson.JSON;
-import com.ym.mec.biz.dal.dao.StudentPaymentRouteOrderDao;
 import com.ym.mec.biz.dal.dao.SysConfigDao;
 import com.ym.mec.biz.dal.dao.TeacherDao;
 import com.ym.mec.biz.dal.dao.TenantEntryActivitiesDao;
 import com.ym.mec.biz.dal.dao.TenantPaymentOrderDao;
 import com.ym.mec.biz.dal.dto.PageInfoOrder;
-import com.ym.mec.biz.dal.entity.StudentPaymentRouteOrder;
-import com.ym.mec.biz.dal.entity.SysTenantAccountDetail.TransType;
 import com.ym.mec.biz.dal.entity.Teacher;
 import com.ym.mec.biz.dal.entity.TenantEntryActivities;
 import com.ym.mec.biz.dal.entity.TenantEntryActivities.SuitableUser;
@@ -36,55 +13,46 @@ import com.ym.mec.biz.dal.entity.TenantPaymentOrder.TenantPaymentType;
 import com.ym.mec.biz.dal.enums.DealStatusEnum;
 import com.ym.mec.biz.dal.enums.PaymentChannelEnum;
 import com.ym.mec.biz.dal.page.TenantPaymentOrderQueryInfo;
+import com.ym.mec.biz.service.PayService;
+import com.ym.mec.biz.service.SysConfigService;
+import com.ym.mec.biz.service.TenantPaymentOrderService;
 import com.ym.mec.common.dal.BaseDAO;
 import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.service.IdGeneratorService;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
-import com.ym.mec.thirdparty.adapay.ConfigInit;
-import com.ym.mec.thirdparty.adapay.Payment;
-import com.ym.mec.thirdparty.adapay.entity.HfMerchantConfig;
-import com.ym.mec.thirdparty.yqpay.Msg;
-import com.ym.mec.thirdparty.yqpay.RsqMsg;
-import com.ym.mec.thirdparty.yqpay.YqPayFeignService;
-import com.ym.mec.thirdparty.yqpay.YqPayUtil;
 import com.ym.mec.util.collection.MapUtil;
 import com.ym.mec.util.date.DateUtil;
+import org.springframework.http.HttpStatus;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Propagation;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.util.*;
 
 @Service
 public class TenantPaymentOrderServiceImpl extends BaseServiceImpl<Long, TenantPaymentOrder> implements TenantPaymentOrderService {
 
-    private static final Logger logger = LoggerFactory.getLogger(TenantPaymentOrderServiceImpl.class);
-
-    @Autowired
+    @Resource
     private TenantPaymentOrderDao tenantPaymentOrderDao;
 
-    @Autowired
+    @Resource
     private TenantEntryActivitiesDao tenantEntryActivitiesDao;
 
-    @Autowired
+    @Resource
     private IdGeneratorService idGeneratorService;
 
-    @Autowired
+    @Resource
     private PayService payService;
 
-    @Autowired
+    @Resource
     private SysConfigDao sysConfigDao;
 
-    @Autowired
+    @Resource
     private TeacherDao teacherDao;
 
-    @Autowired
-    private SysTenantAccountService sysTenantAccountService;
-
-    @Autowired
-    private YqPayFeignService yqPayFeignService;
-    @Autowired
-    private StudentPaymentRouteOrderDao studentPaymentRouteOrderDao;
-    
-    @Autowired
-    private HfMerchantConfigService hfMerchantConfigService;
-
     @Override
     public BaseDAO<Long, TenantPaymentOrder> getDAO() {
         return tenantPaymentOrderDao;

+ 7 - 2
mec-biz/src/main/resources/config/mybatis/HfMerchantConfigMapper.xml

@@ -33,8 +33,13 @@
 
 	<!-- 全查询 -->
 	<select id="findAll" resultMap="HfMerchantConfig">
-		SELECT * FROM hf_merchant_config WHERE payer_name_ = #{payerName} ORDER
-		BY id_
+		SELECT * FROM hf_merchant_config
+		<where>
+			<if test="payerName != null and payerName != ''">
+				AND payer_name_ = #{payerName}
+			</if>
+		</where>
+		ORDER BY id_
 	</select>
 
 	<!-- 向数据库增加一条记录 -->

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

@@ -30,8 +30,8 @@
 	
 	<!-- 向数据库增加一条记录 -->
 	<insert id="insert" parameterType="com.ym.mec.biz.dal.entity.MusicGroupPaymentEntities" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
-		INSERT INTO music_group_payment_entities (id_,music_group_id_,name_,payment_method_,amount_,memo_,create_time_,update_time_,tenant_id_)
-		VALUES(#{id},#{musicGroupId},#{name},#{paymentMethod, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{amount},#{memo},now(),now(),#{tenantId})
+		INSERT INTO music_group_payment_entities (music_group_id_,name_,payment_method_,amount_,memo_,create_time_,update_time_,tenant_id_)
+		VALUES(#{musicGroupId},#{name},#{paymentMethod, typeHandler=com.ym.mec.common.dal.CustomEnumTypeHandler},#{amount},#{memo},now(),now(),#{tenantId})
 	</insert>
     <insert id="batchAdd">
 		INSERT INTO music_group_payment_entities (music_group_id_,name_,payment_method_,amount_,memo_,create_time_,update_time_,tenant_id_)

+ 8 - 17
mec-mall/mall-portal/src/main/java/com/yonge/cooleshow/portal/controller/PaymentController.java

@@ -1,6 +1,5 @@
 package com.yonge.cooleshow.portal.controller;
 
-import cn.hutool.core.map.MapUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.huifu.adapay.core.AdapayCore;
@@ -8,30 +7,25 @@ import com.huifu.adapay.core.util.AdapaySign;
 import com.yeepay.g3.sdk.yop.encrypt.DigitalEnvelopeDTO;
 import com.yeepay.g3.sdk.yop.utils.DigitalEnvelopeUtils;
 import com.yeepay.g3.sdk.yop.utils.RSAKeyUtils;
-import com.ym.mec.auth.api.client.SysUserFeignService;
-import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.common.controller.BaseController;
-import com.ym.mec.common.entity.HttpResponseResult;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.thirdparty.adapay.entity.HfMerchantConfig;
 import com.ym.mec.web.WebFeignService;
 import com.yonge.cooleshow.mall.common.enums.OrderCacheEnum;
 import com.yonge.cooleshow.mbg.model.UserOrderPayment;
-import com.yonge.cooleshow.portal.dto.OrderPayRes;
 import com.yonge.cooleshow.portal.service.OmsPortalOrderService;
 import com.yonge.cooleshow.portal.service.UserOrderPaymentService;
 import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
 import org.redisson.api.RLock;
 import org.redisson.api.RedissonClient;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.http.HttpStatus;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
+import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
-import javax.validation.Valid;
 import java.math.BigDecimal;
 import java.security.PrivateKey;
 import java.security.PublicKey;
@@ -49,19 +43,16 @@ import java.util.concurrent.TimeUnit;
 public class PaymentController extends BaseController {
     private final static Logger log = LoggerFactory.getLogger(PaymentController.class);
 
-    @Autowired
-    private SysUserFeignService sysUserFeignService;
-
-    @Autowired
+    @Resource
     private OmsPortalOrderService orderService;
 
-    @Autowired
+    @Resource
     private RedissonClient redissonClient;
 
-    @Autowired
+    @Resource
     private UserOrderPaymentService userOrderPaymentService;
 
-    @Autowired
+    @Resource
     private WebFeignService webFeignService;
 
 

+ 16 - 0
mec-mall/mall-portal/src/main/resources/bootstrap-dev.properties

@@ -0,0 +1,16 @@
+#\u6307\u5b9a\u5f00\u53d1\u73af\u5883
+#spring.profiles.active=dev
+#\u670d\u52a1\u5668\u5730\u5740
+spring.cloud.nacos.config.server-addr=10.206.0.17:8848
+#\u9ed8\u8ba4\u4e3aPublic\u547d\u540d\u7a7a\u95f4,\u53ef\u4ee5\u7701\u7565\u4e0d\u5199
+spring.cloud.nacos.config.namespace=470509f8-ea21-42cb-9c64-924c5ccc68ce
+#\u6307\u5b9a\u914d\u7f6e\u7fa4\u7ec4 --\u5982\u679c\u662fPublic\u547d\u540d\u7a7a\u95f4 \u5219\u53ef\u4ee5\u7701\u7565\u7fa4\u7ec4\u914d\u7f6e
+spring.cloud.nacos.config.group=DEFAULT_GROUP
+#\u6587\u4ef6\u540d -- \u5982\u679c\u6ca1\u6709\u914d\u7f6e\u5219\u9ed8\u8ba4\u4e3a ${spring.appliction.name}
+spring.cloud.nacos.config.prefix=mall-portal
+#\u6307\u5b9a\u6587\u4ef6\u540e\u7f00
+spring.cloud.nacos.config.file-extension=yaml
+#\u662f\u5426\u52a8\u6001\u5237\u65b0
+spring.cloud.nacos.config.refresh.enabled=true
+#\u662f\u5426\u542f\u7528nacos\u914d\u7f6e\u4e2d\u5fc3
+spring.cloud.nacos.config.enabled=true

+ 11 - 1
mec-mall/pom.xml

@@ -24,7 +24,17 @@
     </properties>
 
     <dependencies>
-
+        <dependency>
+            <groupId>com.microsvc.toolkit.middleware</groupId>
+            <artifactId>microsvc-middleware-payment</artifactId>
+            <version>${microsvc.version}</version>
+            <exclusions>
+                <exclusion>
+                    <artifactId>mybatis-plus-annotation</artifactId>
+                    <groupId>com.baomidou</groupId>
+                </exclusion>
+            </exclusions>
+        </dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-aop</artifactId>

+ 4 - 4
mec-thirdparty/pom.xml

@@ -94,7 +94,7 @@
 			<systemPath>
 				${project.basedir}/libs/SADK-3.2.5.2.jar</systemPath>
 		</dependency>
-
+<!--
 		<dependency>
 			<groupId>com.yeepay.yop</groupId>
 			<artifactId>yop-java-sdk</artifactId>
@@ -111,14 +111,14 @@
 			<version>
 				1.2.10</version>
 		</dependency>
-	
-		<!-- https://mvnrepository.com/artifact/com.huifu.adapay/adapay-java-sdk -->
+
+		&lt;!&ndash; https://mvnrepository.com/artifact/com.huifu.adapay/adapay-java-sdk &ndash;&gt;
 		<dependency>
 			<groupId>com.huifu.adapay</groupId>
 			<artifactId>
 				adapay-java-sdk</artifactId>
 			<version>1.2.10</version>
-		</dependency>
+		</dependency>-->
 		
 		<dependency>
 		    <groupId>

+ 2 - 11
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/adapay/AdapayInit.java

@@ -1,14 +1,5 @@
 package com.ym.mec.thirdparty.adapay;
 
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import com.huifu.adapay.Adapay;
-import com.huifu.adapay.model.MerConfig;
-import com.ym.mec.thirdparty.adapay.entity.HfMerchantConfig;
-import com.ym.mec.thirdparty.exception.ThirdpartyException;
-
 /**
  * 系统初始化
  */
@@ -39,7 +30,7 @@ public class AdapayInit {
 		return init;
 	}
 
-	public boolean initWithMerConfig(List<HfMerchantConfig> adapayMerConfigList) {
+	/*public boolean initWithMerConfig(List<HfMerchantConfig> adapayMerConfigList) {
 		
 		Adapay.debug = debug;
 		Adapay.prodMode = prodMode;
@@ -62,5 +53,5 @@ public class AdapayInit {
 		}
 
 		return true;
-	}
+	}*/
 }

+ 7 - 11
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/adapay/ConfigInit.java

@@ -1,13 +1,9 @@
 package com.ym.mec.thirdparty.adapay;
 
-import com.huifu.adapay.Adapay;
-import com.huifu.adapay.model.MerConfig;
-
-
 public class ConfigInit {
 
 
-    private static ConfigInit instance;
+//    private static ConfigInit instance;
     public final static Integer organId = 16; //商户对应的分部
     public final static String merNo = "B09767221"; //商户对应的分部
     public final static String appId = "app_756972d1-882e-44c6-9f52-e6a6b93c8756";
@@ -15,7 +11,7 @@ public class ConfigInit {
     public final static String wxAppId = "wx751141096e75a4ee";
     public final static String wxAppSecret = "e882d76c95d1613607a85338b1bed3ff";
     public final static String wxMpOAuth2AccessTokenUrl = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=%s&secret=%s&code=%s&grant_type=authorization_code";
-    public final static MerConfig merConfig = new MerConfig();
+    /*public final static MerConfig merConfig = new MerConfig();
 
     static {
         try {
@@ -32,9 +28,9 @@ public class ConfigInit {
         } else {
             return instance;
         }
-        /**
+        *//**
          *添加商户配置,一个商户只需要 添加一次,添加以后在内存中。
-         */
+         *//*
 
         String apiKey = "api_live_bfc3c02f-657b-4731-9fcd-ea9503aa3bb9";
         String mockApiKey = "api_test_d09b9f68-9798-43b3-93b7-a22ef406a20c";
@@ -44,13 +40,13 @@ public class ConfigInit {
         merConfig.setApiMockKey(mockApiKey);
         merConfig.setRSAPrivateKey(rsaPrivateKey);
         Adapay.initWithMerConfig(merConfig);
-        /**
+        *//**
          *启动MQTT,一个商户只需要 启动一次,启动完成以后一直在服务器后端运行
-         */
+         *//*
         // notifyCallback = new NotifyCallback();
         //Adapay.startMqttListener(merConfig, notifyCallback);
         return instance;
-    }
+    }*/
 
     public ConfigInit() {
     }

+ 2 - 14
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/adapay/CorpMemberService.java

@@ -1,25 +1,13 @@
 package com.ym.mec.thirdparty.adapay;
 
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
 
-import com.huifu.adapay.core.exception.BaseAdaPayException;
-import com.huifu.adapay.model.AdapayCommon;
-import com.huifu.adapay.model.CorpMember;
-import com.ym.mec.thirdparty.adapay.entity.EnterpriseUser;
-import com.ym.mec.thirdparty.exception.ThirdpartyException;
-
 /**
  * 企业用户相关服务
  */
 @Service
 public class CorpMemberService {
-
+/*
 	private final static Logger logger = LoggerFactory.getLogger(CorpMemberService.class);
 
 	public boolean create(String merchantKey, String appId, EnterpriseUser req, String notifyUrl) {
@@ -134,6 +122,6 @@ public class CorpMemberService {
 		}
 
 		return null;
-	}
+	}*/
 	
 }

+ 20 - 31
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/adapay/Payment.java

@@ -1,26 +1,16 @@
 package com.ym.mec.thirdparty.adapay;
 
-import java.math.BigDecimal;
-import java.util.*;
-
-import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
-import com.google.common.collect.Lists;
-import com.huifu.adapay.core.exception.BaseAdaPayException;
-import com.huifu.adapay.core.util.StringUtil;
-import com.huifu.adapay.model.PaymentReverse;
-import com.huifu.adapay.model.Refund;
-import com.ym.mec.thirdparty.adapay.entity.BaseResult;
 import com.ym.mec.thirdparty.adapay.entity.HfMerchantConfig;
-import com.ym.mec.thirdparty.exception.ThirdpartyException;
-
-import org.apache.commons.lang3.StringUtils;
-import org.joda.time.DateTime;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.springframework.util.CollectionUtils;
 import org.springframework.util.DigestUtils;
 
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
 public class Payment {
 
 	private final static Logger LOGGER = LoggerFactory.getLogger(Payment.class);
@@ -30,7 +20,7 @@ public class Payment {
      * @return 创建的支付对象
      * @throws Exception 异常
      */
-    public static Map<String, Object> executePayment(String appId, String merchantKey, Map<String, Object> paymentParams) throws Exception {
+    /*public static Map<String, Object> executePayment(String appId, String merchantKey, Map<String, Object> paymentParams) throws Exception {
         paymentParams.put("app_id", appId);
 
         LOGGER.info("汇付[创建支付对象] Req:{}", paymentParams);
@@ -51,12 +41,12 @@ public class Payment {
     }
 
 
-    /**
+    *//**
      * 创建确认对象
      *
      * @return 查询的支付对象
      * @throws Exception 异常
-     */
+     *//*
     public static Map<String, Object> createConfirm(Map<String, Object> confirm, String merchantKey) throws Exception {
         confirm = com.huifu.adapay.model.Payment.createConfirm(confirm, merchantKey);
 
@@ -68,13 +58,12 @@ public class Payment {
         return confirm;
     }
 
-    /**
+    *//**
      * 查询一个支付交易
      *
-     * @param paymentId 要查询的支付id
      * @return 查询的支付对象
      * @throws Exception 异常
-     */
+     *//*
     public static Map<String, Object> queryPayment(String paymentId, String merchantKey) throws Exception {
         LOGGER.info("=======query payment begin=======");
         //查询支付对象的参数,全部参数请参考 https://docs.adapay.tech/api/04-trade.html#id7
@@ -95,10 +84,10 @@ public class Payment {
         }
         LOGGER.info("queryPayment >>> =======query payment end=======");
         return payment;
-    }
+    }*/
 
 
-    public static Map<String, Object> queryList(String appId, String merchantKey, Integer pageIndex, Long createdGte, Long createdLte) throws Exception {
+    /*public static Map<String, Object> queryList(String appId, String merchantKey, Integer pageIndex, Long createdGte, Long createdLte) throws Exception {
         Map<java.lang.String, java.lang.Object> paymentParams = new HashMap<>();
         paymentParams.put("app_id", appId);
         paymentParams.put("page_index", pageIndex);
@@ -112,8 +101,8 @@ public class Payment {
             throw new ThirdpartyException(errorMsg);
         }
         return payment;
-    }
-
+    }*/
+/*
     public static Map<String, Object> queryConfirmList(String appId, String merchantKey, String paymentId) throws Exception {
         Map<String, Object> paymentParams = new HashMap<>();
         paymentParams.put("app_id", appId);
@@ -126,13 +115,13 @@ public class Payment {
             throw new ThirdpartyException(errorMsg);
         }
         return payment;
-    }
+    }*/
 
     public static Map<String, Object> getPayMap(HfMerchantConfig hfMerchantConfig, BigDecimal amount, String orderNo, String returnUrl, String orderSubject, String orderBody) throws Exception {
 
         Map<String, Object> paymentParams = new LinkedHashMap<>();
         paymentParams.put("appId", hfMerchantConfig.getAppId());
-        paymentParams.put("amount", amount.setScale(2, BigDecimal.ROUND_HALF_UP));
+        paymentParams.put("amount", amount.setScale(2, RoundingMode.HALF_UP));
         paymentParams.put("orderNo", orderNo);
 //        paymentParams.put("notifyUrl", notifyUrl);
         paymentParams.put("returnUrl", returnUrl);
@@ -149,7 +138,7 @@ public class Payment {
         paymentParams.remove("appId");
         return paymentParams;
     }
-
+/*
     public static BaseResult<Map<String ,Object>> refundPayment(Map<String, Object> refundParams) {
 
         LOGGER.info("退款对象信息:{}",refundParams);
@@ -203,7 +192,7 @@ public class Payment {
     }
 
 
-    /**
+    *//**
      *
      针对已经创建的 支付对象,您可以调用关单接口进行交易的关闭。调用此接口后,该用户订单将不再能支付成功。 对于关单功能的使用有如下规则:
      1.存在关单记录,不能再次关单
@@ -216,7 +205,7 @@ public class Payment {
      * @param reason 原因
      * @param merchantKey 商户Key
      * @return Map<String, Object>
-     */
+     *//*
     public static Map<String ,String> closeWithKey(String transNo, String reason, String merchantKey) {
 
 
@@ -258,6 +247,6 @@ public class Payment {
         result.put("status", "success");
 
         return result;
-    }
+    }*/
 
 }

+ 2 - 10
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/adapay/SettleAccountService.java

@@ -1,22 +1,14 @@
 package com.ym.mec.thirdparty.adapay;
 
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 
-import com.huifu.adapay.core.exception.BaseAdaPayException;
-import com.ym.mec.thirdparty.adapay.entity.AccountInfo;
-import com.ym.mec.thirdparty.exception.ThirdpartyException;
-
 /**
  * 结算账户服务
  * 注:若用户想更新银行卡,则需要先调用删除结算账户对象,再使用原 member_id 重新创建结算账户对象,且必须与原创建结算账户使用的身份证和银行卡户名保持一致。
  */
 @Service
 public class SettleAccountService {
-
+/*
 	public String create(String merchantKey, String appId, AccountInfo accountInfo) {
 		Map<String, Object> settleCountParams = new HashMap<String, Object>();
 		Map<String, Object> accountInfoMap = new HashMap<String, Object>();
@@ -60,5 +52,5 @@ public class SettleAccountService {
 			new ThirdpartyException("结算账户删除失败:{}", e, e.getMessage());
 		}
 		return false;
-	}
+	}*/
 }

+ 3 - 14
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/yeepay/YeepayMerchantService.java

@@ -1,26 +1,15 @@
 package com.ym.mec.thirdparty.yeepay;
 
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
 
-import com.alibaba.fastjson.JSONObject;
-import com.yeepay.g3.sdk.yop.client.YopRequest;
-import com.yeepay.g3.sdk.yop.client.YopResponse;
-import com.yeepay.g3.sdk.yop.client.YopRsaClient;
-import com.yeepay.g3.sdk.yop.exception.YopClientException;
-import com.ym.mec.thirdparty.adapay.entity.HfMerchantConfig;
-import com.ym.mec.thirdparty.yeepay.entity.MerchantInfo;
-
 @Service
 public class YeepayMerchantService {
 
-	private static final Logger LOGGER = LoggerFactory.getLogger(YeepayMerchantService.class);
 
+	private static final Logger LOGGER = LoggerFactory.getLogger(YeepayMerchantService.class);
+/*
 	public JSONObject registerQueryV2(HfMerchantConfig hfMerchantConfig, String requestNo) throws IOException {
 
 		YopRequest request = new YopRequest(hfMerchantConfig.getAppId(), hfMerchantConfig.getRsaPrivateKey());
@@ -103,6 +92,6 @@ public class YeepayMerchantService {
 
 	public void merchantInfoModify(String merchantNo, MerchantInfo merchantInfo, String notifyURL) throws YopClientException {
 
-	}
+	}*/
 
 }

+ 4 - 21
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/yeepay/YeepayPaymentService.java

@@ -1,27 +1,10 @@
 package com.ym.mec.thirdparty.yeepay;
 
-import java.io.IOException;
-import java.util.*;
-
-import com.google.common.collect.Lists;
-import org.apache.commons.lang3.StringUtils;
-import org.joda.time.DateTime;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
 
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-import com.yeepay.g3.sdk.yop.client.YopRequest;
-import com.yeepay.g3.sdk.yop.client.YopResponse;
-import com.yeepay.g3.sdk.yop.client.YopRsaClient;
-import com.ym.mec.thirdparty.adapay.entity.HfMerchantConfig;
-import com.ym.mec.thirdparty.exception.ThirdpartyException;
-import com.ym.mec.util.date.DateUtil;
-
 @Service
 public class YeepayPaymentService {
-
+/*
 	private static final Logger LOGGER = LoggerFactory.getLogger(YeepayPaymentService.class);
 
 	public Map<String, Object> prePay(HfMerchantConfig hfMerchantConfig, Map<String, Object> params) throws IOException {
@@ -107,12 +90,12 @@ public class YeepayPaymentService {
 	}
 
 
-    /**
+    *//**
      * 关闭订单
      * @param transNo 交易流水号
      * @param reason 原因
      * @return Map<String, Object>
-     */
+     *//*
     public Map<String,String> close(HfMerchantConfig hfMerchantConfig,String transNo, String reason, String outTransNo) {
 
 
@@ -162,5 +145,5 @@ public class YeepayPaymentService {
 
 
         return result;
-    }
+    }*/
 }

+ 2 - 11
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/yeepay/YeepayUploadService.java

@@ -1,23 +1,14 @@
 package com.ym.mec.thirdparty.yeepay;
 
-import java.io.File;
-import java.io.IOException;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
 
-import com.alibaba.fastjson.JSONObject;
-import com.yeepay.g3.sdk.yop.client.YopRequest;
-import com.yeepay.g3.sdk.yop.client.YopResponse;
-import com.yeepay.g3.sdk.yop.client.YopRsaClient;
-import com.ym.mec.thirdparty.adapay.entity.HfMerchantConfig;
-
 @Service
 public class YeepayUploadService {
 	
 	private static final Logger LOGGER = LoggerFactory.getLogger(YeepayUploadService.class);
-
+/*
 	public String upload(HfMerchantConfig hfMerchantConfig, File file) {
 		
 		YopRequest request = new YopRequest(hfMerchantConfig.getAppId(), hfMerchantConfig.getRsaPrivateKey());
@@ -37,5 +28,5 @@ public class YeepayUploadService {
         
         return null;
 		
-	}
+	}*/
 }

+ 0 - 1
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/yqpay/CFCARAUtil.java

@@ -6,7 +6,6 @@ import cfca.sadk.lib.crypto.JCrypto;
 import cfca.sadk.system.FileHelper;
 import cfca.sadk.util.*;
 import cfca.sadk.x509.certificate.X509Cert;
-import org.hibernate.validator.internal.util.privilegedactions.GetClassLoader;
 import org.springframework.core.io.ClassPathResource;
 
 import javax.crypto.spec.SecretKeySpec;

+ 6 - 4
mec-thirdparty/src/main/java/com/ym/mec/thirdparty/yqpay/YqPayFeignService.java

@@ -4,15 +4,17 @@ import feign.Logger;
 import feign.codec.Encoder;
 import feign.form.spring.SpringFormEncoder;
 import org.springframework.beans.factory.ObjectFactory;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.cloud.openfeign.support.SpringEncoder;
 import org.springframework.context.annotation.Bean;
 import org.springframework.http.MediaType;
-import org.springframework.web.bind.annotation.*;
-
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
 
+import javax.annotation.Resource;
 import java.util.Map;
 
 @FeignClient(value = "YqPayFeignService",url = "https://qyfquery.95epay.com",configuration = YqPayFeignService.FormSupportConfig.class)
@@ -34,7 +36,7 @@ public interface YqPayFeignService {
     class FormSupportConfig {
 
 
-        @Autowired
+        @Resource
         private ObjectFactory<HttpMessageConverters> messageConverters;
         // new一个form编码器,实现支持form表单提交
         @Bean

+ 1 - 1
pom.xml

@@ -25,8 +25,8 @@
 		<docker.host>http://127.0.0.1:2375</docker.host>
 		<docker.registry.repository>127.0.0.1:5000</docker.registry.repository>
 		<docker.maven.plugin.version>1.2.2</docker.maven.plugin.version>
-		<com.microsvc.toolkit.version>1.0.8-RC1</com.microsvc.toolkit.version>
 		<cbs.version>1.0.26</cbs.version>
+		<microsvc.version>1.2.0</microsvc.version>
 	</properties>
 
 	<dependencyManagement>