瀏覽代碼

update 上传文件去掉权限

周箭河 5 年之前
父節點
當前提交
ffaa206342

+ 23 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/entity/ExamRegistrationPayment.java

@@ -22,12 +22,18 @@ public class ExamRegistrationPayment {
 	@ApiModelProperty(value = "订单号(系统自动生成)")
 	private String orderNo;
 
+	@ApiModelProperty(value = "收款渠道")
+	private String payType;
+
 	@ApiModelProperty(value = "交易流水号(由第三方返回)")
 	private String transNo;
 
 	@ApiModelProperty(value = "渠道收款账户号")
 	private String merNo;
 
+	@ApiModelProperty(value = "支付方式")
+	private String payChannel;
+
 	@ApiModelProperty(value = "交易金额")
 	private java.math.BigDecimal transAmount;
 
@@ -146,9 +152,26 @@ public class ExamRegistrationPayment {
 	public String getTenantId(){
 		return this.tenantId;
 	}
+
+	public String getPayType() {
+		return payType;
+	}
+
+	public void setPayType(String payType) {
+		this.payType = payType;
+	}
+
+	public String getPayChannel() {
+		return payChannel;
+	}
+
+	public void setPayChannel(String payChannel) {
+		this.payChannel = payChannel;
+	}
 			
 	@Override
 	public String toString() {
 		return ToStringBuilder.reflectionToString(this);
 	}
+
 }

+ 7 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/ExamRegistrationPaymentService.java

@@ -19,4 +19,11 @@ public interface ExamRegistrationPaymentService extends BaseService<Long, ExamRe
      * @return
      */
     ExamRegistrationPayment getByOrderNo(String OrderNo);
+
+    /**
+     * 更新订单信息
+     * @param examRegistrationPayment
+     * @return
+     */
+    ExamRegistrationPayment updateOrder(ExamRegistrationPayment examRegistrationPayment);
 }

+ 189 - 0
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/NotifyCallback.java

@@ -0,0 +1,189 @@
+package com.keao.edu.user.service;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.huifu.adapay.notify.MQTTCallbackHandler;
+import com.keao.edu.thirdparty.adapay.ConfigInit;
+import com.keao.edu.user.entity.ExamRegistrationPayment;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
+import java.util.Date;
+
+
+@Service
+public class NotifyCallback implements MQTTCallbackHandler {
+
+    @Autowired
+    private ExamRegistrationPaymentService examRegistrationPaymentService;
+
+
+    private static NotifyCallback notifyCallback;
+
+    @PostConstruct
+    public void init() {
+        notifyCallback = this;
+    }
+
+    /**
+     * 用户接收并处理支付成功的异步消息
+     *
+     * @param payment 成功的支付对象
+     * @throws Exception 异常
+     */
+    @Override
+    public void paymentSuccessMessageArrived(String payment) throws Exception {
+        System.out.println(String.format("receive paymentSuccess  msg=%s", payment));
+        JSONObject dataObj = JSON.parseObject(payment);
+        if (!dataObj.getString("app_id").equals(ConfigInit.appId)) {
+            return;
+        }
+        String orderNo = dataObj.getString("order_no");
+        ExamRegistrationPayment order = notifyCallback.examRegistrationPaymentService.getByOrderNo(orderNo);
+        order.setPayChannel(dataObj.getString("pay_channel"));
+        order.setTransStatus("SUCCESS");
+        order.setUpdateTime(new Date());
+        order.setTransSuccessedTime(new Date());
+        notifyCallback.examRegistrationPaymentService.updateOrder(order);
+    }
+
+    /**
+     * 用户接收并处理支付失败的异步消息
+     *
+     * @param payment 失败的支付对象
+     * @throws Exception 异常
+     */
+    @Override
+    public void paymentFailedMessageArrived(String payment) throws Exception {
+        System.out.println(String.format("receive paymentFailed msg=%s", payment));
+        JSONObject dataObj = JSON.parseObject(payment);
+        if (!dataObj.getString("app_id").equals(ConfigInit.appId)) {
+            return;
+        }
+        String orderNo = dataObj.getString("order_no");
+        ExamRegistrationPayment order = notifyCallback.examRegistrationPaymentService.getByOrderNo(orderNo);
+        order.setPayChannel(dataObj.getString("pay_channel"));
+        order.setTransStatus("FAILED");
+        order.setUpdateTime(new Date());
+        notifyCallback.examRegistrationPaymentService.updateOrder(order);
+    }
+
+
+    /**
+     * 用户接收并处理关闭支付交易成功的异步消息
+     *
+     * @param payment 关闭成功的支付对象
+     * @throws Exception 异常
+     */
+    @Override
+    public void paymentCloseSuccessMessageArrived(String payment) throws Exception {
+        System.out.println(String.format("receive paymentCloseSuccess msg=%s", payment));
+        JSONObject dataObj = JSON.parseObject(payment);
+        if (!dataObj.getString("app_id").equals(ConfigInit.appId)) {
+            return;
+        }
+        String orderNo = dataObj.getString("order_no");
+        ExamRegistrationPayment order = notifyCallback.examRegistrationPaymentService.getByOrderNo(orderNo);
+        order.setPayChannel(dataObj.getString("pay_channel"));
+        order.setTransStatus("FAILED");
+        order.setUpdateTime(new Date());
+        notifyCallback.examRegistrationPaymentService.updateOrder(order);
+    }
+
+    /**
+     * 用户接收并处理关闭支付交易失败的异步消息
+     *
+     * @param payment 关闭失败的支付对象
+     * @throws Exception 异常
+     */
+    @Override
+    public void paymentCloseFailedMessageArrived(String payment) throws Exception {
+        System.out.println(String.format("receive paymentCloseFailed msg=%s", payment));
+    }
+
+    @Override
+    public void paymentReverseFailedMessageArrived(String payment) throws Exception {
+
+        System.out.println(String.format("receive payment ReverseFailed msg=%s", payment));
+    }
+
+    @Override
+    public void paymentReverseSuccessMessageArrived(String payment) throws Exception {
+        System.out.println(String.format("receive payment ReverseSuccess msg=%s", payment));
+    }
+
+    /**
+     * 用户接收并处理退款成功的异步消息
+     *
+     * @param refund 成功的退款对象
+     * @throws Exception 异常
+     */
+    @Override
+    public void refundSuccessMessageArrived(String refund) throws Exception {
+        System.out.println(String.format("receive refundSuccess msg=%s", refund));
+    }
+
+    /**
+     * 用户接收并处理退款失败的异步消息
+     *
+     * @param refund 失败的退款对象
+     * @throws Exception 异常
+     */
+    @Override
+    public void refundFailedMessageArrived(String refund) throws Exception {
+        System.out.println(String.format("receive refundFailed   msg=%s", refund));
+    }
+
+    @Override
+    public void corpMemberSuccessMessageArrived(String corpMember) throws Exception {
+        System.out.println(String.format("receive corpMember   msg=%s", corpMember));
+    }
+
+    @Override
+    public void corpMemberFailedMessageArrived(String corpMember) throws Exception {
+        System.out.println(String.format("receive corpMember  msg=%s", corpMember));
+    }
+
+    @Override
+    public void unknowMessageArrived(String message) throws Exception {
+        System.out.println(String.format("receive unknow  msg=%s", message));
+    }
+
+    @Override
+    public void drawCashFailedMessageArrived(String drawCash) throws Exception {
+        System.out.println(String.format("receive unknow  msg=%s", drawCash));
+
+    }
+
+    @Override
+    public void drawCashSuccessedMessageArrived(String drawCash) throws Exception {
+
+        System.out.println(String.format("receive unknow  msg=%s", drawCash));
+
+    }
+
+    @Override
+    public void pagePaymentFailedMessageArrived(String arg0) throws Exception {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void pagePaymentSuccessedMessageArrived(String arg0) throws Exception {
+        // TODO Auto-generated method stub
+
+    }
+
+    @Override
+    public void connectionLost(String message) throws Exception {
+        // TODO Auto-generated method stub
+        System.out.println("mqtt...........lost.............");
+
+    }
+
+    @Override
+    public void connectSuccess() throws Exception {
+        System.out.println("mqtt...........connect.............");
+    }
+}

+ 25 - 15
edu-user/edu-user-server/src/main/java/com/keao/edu/user/service/impl/ExamRegistrationPaymentServiceImpl.java

@@ -1,6 +1,7 @@
 package com.keao.edu.user.service.impl;
 
 import com.keao.edu.common.dal.BaseDAO;
+import com.keao.edu.common.exception.BizException;
 import com.keao.edu.common.service.impl.BaseServiceImpl;
 import com.keao.edu.user.dao.ExamRegistrationPaymentDao;
 import com.keao.edu.user.entity.ExamRegistrationPayment;
@@ -10,22 +11,31 @@ import org.springframework.stereotype.Service;
 
 @Service
 public class ExamRegistrationPaymentServiceImpl extends BaseServiceImpl<Long, ExamRegistrationPayment> implements ExamRegistrationPaymentService {
-	
-	@Autowired
-	private ExamRegistrationPaymentDao examRegistrationPaymentDao;
 
-	@Override
-	public BaseDAO<Long, ExamRegistrationPayment> getDAO() {
-		return examRegistrationPaymentDao;
-	}
+    @Autowired
+    private ExamRegistrationPaymentDao examRegistrationPaymentDao;
 
-	@Override
-	public ExamRegistrationPayment getExamIngOrder(Integer examinationBasicId, Integer userId) {
-		return examRegistrationPaymentDao.getExamIngOrder(examinationBasicId,userId);
-	}
+    @Override
+    public BaseDAO<Long, ExamRegistrationPayment> getDAO() {
+        return examRegistrationPaymentDao;
+    }
 
-	@Override
-	public ExamRegistrationPayment getByOrderNo(String OrderNo) {
-		return examRegistrationPaymentDao.getByOrderNo(OrderNo);
-	}
+    @Override
+    public ExamRegistrationPayment getExamIngOrder(Integer examinationBasicId, Integer userId) {
+        return examRegistrationPaymentDao.getExamIngOrder(examinationBasicId, userId);
+    }
+
+    @Override
+    public ExamRegistrationPayment getByOrderNo(String OrderNo) {
+        return examRegistrationPaymentDao.getByOrderNo(OrderNo);
+    }
+
+    @Override
+    public ExamRegistrationPayment updateOrder(ExamRegistrationPayment examRegistrationPayment) {
+        if (examRegistrationPayment.getTransStatus().equals("SUCCESS")) {
+            throw new BizException("订单状态不在支付中");
+        }
+        examRegistrationPaymentDao.update(examRegistrationPayment);
+        return examRegistrationPayment;
+    }
 }