|
@@ -3,6 +3,7 @@ package com.ym.mec.student.controller;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.huifu.adapay.model.payment.PayChannelEnum;
|
|
|
import com.huifu.adapay.model.payment.Payment;
|
|
|
+import com.ym.mec.biz.dal.dao.StudentPaymentOrderDao;
|
|
|
import com.ym.mec.biz.dal.dto.VipBuyResultDto;
|
|
|
import com.ym.mec.biz.dal.entity.Goods;
|
|
|
import com.ym.mec.biz.dal.entity.MusicGroup;
|
|
@@ -51,6 +52,10 @@ public class StudentOrderController extends BaseController {
|
|
|
private MusicGroupService musicGroupService;
|
|
|
@Autowired
|
|
|
private StudentPaymentOrderDetailService studentPaymentOrderDetailService;
|
|
|
+ @Autowired
|
|
|
+ private YqPayFeignService yqPayFeignService;
|
|
|
+ @Autowired
|
|
|
+ private StudentPaymentOrderDao studentPaymentOrderDao;
|
|
|
|
|
|
@PostMapping("/notify")
|
|
|
public Msg notify(@ModelAttribute Msg msg) throws Exception {
|
|
@@ -94,16 +99,16 @@ public class StudentOrderController extends BaseController {
|
|
|
return failed("未找到指定订单");
|
|
|
}
|
|
|
HashMap<String, Object> orderDetail = new HashMap<>();
|
|
|
- orderDetail.put("order",orderByOrderNo);
|
|
|
- orderDetail.put("groupType",orderByOrderNo.getGroupType());
|
|
|
- if(orderByOrderNo.getGroupType().equals(GroupType.MUSIC)){
|
|
|
+ orderDetail.put("order", orderByOrderNo);
|
|
|
+ orderDetail.put("groupType", orderByOrderNo.getGroupType());
|
|
|
+ if (orderByOrderNo.getGroupType().equals(GroupType.MUSIC)) {
|
|
|
MusicGroup musicGroup = musicGroupService.get(orderByOrderNo.getMusicGroupId());
|
|
|
List<Goods> goodsList = studentPaymentOrderDetailService.findApplyOrderGoods(orderByOrderNo.getId());
|
|
|
- orderDetail.put("goods",goodsList);
|
|
|
- orderDetail.put("course",musicGroup.getCourseForm());
|
|
|
- }else if(orderByOrderNo.getGroupType().equals(GroupType.VIP)){
|
|
|
+ orderDetail.put("goods", goodsList);
|
|
|
+ orderDetail.put("course", musicGroup.getCourseForm());
|
|
|
+ } else if (orderByOrderNo.getGroupType().equals(GroupType.VIP)) {
|
|
|
VipBuyResultDto vipBuyResultInfo = vipGroupService.findVipBuyResultInfo(Integer.valueOf(orderByOrderNo.getMusicGroupId()));
|
|
|
- orderDetail.put("detail",vipBuyResultInfo);
|
|
|
+ orderDetail.put("detail", vipBuyResultInfo);
|
|
|
}
|
|
|
|
|
|
return succeed(orderDetail);
|
|
@@ -202,7 +207,7 @@ public class StudentOrderController extends BaseController {
|
|
|
|
|
|
}
|
|
|
|
|
|
-// @Scheduled(cron = "0/30 * * * * ?")
|
|
|
+ // @Scheduled(cron = "0/30 * * * * ?")
|
|
|
@GetMapping("/setSuccessStatus")
|
|
|
public void setSuccessStatus() throws Exception {
|
|
|
List<StudentPaymentOrder> payingOrders = studentPaymentOrderService.findOrdersByStatus(DealStatusEnum.ING, "YQPAY");
|
|
@@ -221,7 +226,7 @@ public class StudentOrderController extends BaseController {
|
|
|
if (Arrays.asList(statusArr).contains(rpMap.get("tradeState"))) {
|
|
|
try {
|
|
|
studentPaymentOrderService.updateOrder(rpMap); //更新订单
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
continue;
|
|
|
}
|
|
@@ -230,4 +235,54 @@ public class StudentOrderController extends BaseController {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @GetMapping("/fixOrder")
|
|
|
+ private int fixOrder() throws Exception {
|
|
|
+ List<StudentPaymentOrder> payingOrders = studentPaymentOrderDao.findFixOrder(DealStatusEnum.SUCCESS, "YQPAY");
|
|
|
+
|
|
|
+ if (payingOrders.size() == 0) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ String merOrderNos = payingOrders.stream().map(StudentPaymentOrder::getOrderNo).collect(Collectors.joining(","));
|
|
|
+
|
|
|
+ String notifyUrl = ""; //回调地址
|
|
|
+ Map<String, Object> resultMap = new LinkedHashMap<>();
|
|
|
+ resultMap.put("merOrderNoList", merOrderNos);
|
|
|
+ Map<String, Object> requestMap = YqPayUtil.getRequestMap(notifyUrl, resultMap);
|
|
|
+
|
|
|
+ RsqMsg rsqMsg = new RsqMsg(requestMap);
|
|
|
+
|
|
|
+ Msg queryRs = yqPayFeignService.orderQuery(rsqMsg);
|
|
|
+
|
|
|
+ if (queryRs.getCode().equals("88")) {
|
|
|
+ String responseParameters = queryRs.getResponseParameters();
|
|
|
+ List<Map<String, Object>> responseList = JSON.parseObject(responseParameters, List.class);
|
|
|
+ for (Map<String, Object> response : responseList) {
|
|
|
+ String type = "per";
|
|
|
+ String orderNo = (String) response.get("merOrderNo");
|
|
|
+ String tempRoutingResultList = response.get("tempRoutingResultList").toString();
|
|
|
+ System.out.println(tempRoutingResultList);
|
|
|
+
|
|
|
+ if (tempRoutingResultList.contains("武汉大雅乐盟教育咨询有限公司")) {
|
|
|
+ type = "com";
|
|
|
+ }
|
|
|
+ fixUpdateOrder(orderNo,type);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return payingOrders.size();
|
|
|
+ }
|
|
|
+
|
|
|
+ void fixUpdateOrder(String orderNo,String type) {
|
|
|
+ StudentPaymentOrder order = studentPaymentOrderService.findOrderByOrderNo(orderNo);
|
|
|
+ if(type.equals("com")){
|
|
|
+ order.setComAmount(order.getActualAmount());
|
|
|
+ order.setPerAmount(BigDecimal.ZERO);
|
|
|
+ order.setMerNos("0023115");
|
|
|
+ }else {
|
|
|
+ order.setComAmount(BigDecimal.ZERO);
|
|
|
+ order.setPerAmount(order.getActualAmount());
|
|
|
+ order.setMerNos("0031215");
|
|
|
+ }
|
|
|
+ studentPaymentOrderService.update(order);
|
|
|
+ }
|
|
|
+
|
|
|
}
|