|
@@ -4,11 +4,16 @@ package com.miaxis.app.controller.film;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.miaxis.common.config.WxpayConfig;
|
|
import com.miaxis.common.config.WxpayConfig;
|
|
import com.miaxis.common.constant.Constants;
|
|
import com.miaxis.common.constant.Constants;
|
|
|
|
+import com.miaxis.common.enums.OrderStatusEnum;
|
|
|
|
+import com.miaxis.common.exception.CustomException;
|
|
|
|
+import com.miaxis.feign.dto.WxSend;
|
|
|
|
+import com.miaxis.feign.service.IWxSendService;
|
|
import com.miaxis.wx.domain.WxOrder;
|
|
import com.miaxis.wx.domain.WxOrder;
|
|
import com.miaxis.wx.dto.FilmWxOrderJsonData;
|
|
import com.miaxis.wx.dto.FilmWxOrderJsonData;
|
|
import com.miaxis.wx.dto.WxOrderNotifyDTO;
|
|
import com.miaxis.wx.dto.WxOrderNotifyDTO;
|
|
import com.miaxis.wx.service.IRefundRecordService;
|
|
import com.miaxis.wx.service.IRefundRecordService;
|
|
import com.miaxis.wx.service.IWxOrderService;
|
|
import com.miaxis.wx.service.IWxOrderService;
|
|
|
|
+import com.miaxis.wx.service.IWxXcxMessageService;
|
|
import com.wechat.pay.contrib.apache.httpclient.auth.AutoUpdateCertificatesVerifier;
|
|
import com.wechat.pay.contrib.apache.httpclient.auth.AutoUpdateCertificatesVerifier;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -44,6 +49,12 @@ public class FilmNotifyController {
|
|
@Autowired
|
|
@Autowired
|
|
private IRefundRecordService refundRecordService;
|
|
private IRefundRecordService refundRecordService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ IWxXcxMessageService wxXcxMessageService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IWxSendService wxSendService;
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -75,9 +86,20 @@ public class FilmNotifyController {
|
|
wxOrderJsonData.setWxOrderNotifyDTO(dbWxOrderNotifyDTO);
|
|
wxOrderJsonData.setWxOrderNotifyDTO(dbWxOrderNotifyDTO);
|
|
wxOrder.setOrderDataJson(JSONObject.toJSONString(wxOrderJsonData));
|
|
wxOrder.setOrderDataJson(JSONObject.toJSONString(wxOrderJsonData));
|
|
//UserInfo student = SecurityUtils.getLoginUser().getStudent();
|
|
//UserInfo student = SecurityUtils.getLoginUser().getStudent();
|
|
|
|
+ //如果订单状态成功,则调用小程序推送服务
|
|
|
|
+ if ("TICKET_SUCCESS".equals(wxOrderNotifyDTO.getEventName())){
|
|
|
|
+ wxOrder.setOrderStatus(OrderStatusEnum.SUCCESS.getCode());
|
|
|
|
+ sendXcxMessage();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
//如果回调回来的订单关闭,则调用退款
|
|
//如果回调回来的订单关闭,则调用退款
|
|
if ("ORDER_CLOSE".equals(wxOrderNotifyDTO.getEventName())){
|
|
if ("ORDER_CLOSE".equals(wxOrderNotifyDTO.getEventName())){
|
|
String refundCode = getOrderCode(null);
|
|
String refundCode = getOrderCode(null);
|
|
|
|
+ wxOrder.setOrderStatus(OrderStatusEnum.FAILD.getCode());
|
|
wxOrder.setOutRefundNo(refundCode);
|
|
wxOrder.setOutRefundNo(refundCode);
|
|
threadPoolTaskExecutor.execute(new Runnable() {
|
|
threadPoolTaskExecutor.execute(new Runnable() {
|
|
@Override
|
|
@Override
|
|
@@ -85,7 +107,7 @@ public class FilmNotifyController {
|
|
try {
|
|
try {
|
|
refundRecordService.refund(wxOrder,refundCode);
|
|
refundRecordService.refund(wxOrder,refundCode);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
- log.info(e.getMessage());
|
|
|
|
|
|
+ throw new CustomException("订单:"+wxOrder.getOutTradeNo()+"退款失败");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -101,6 +123,30 @@ public class FilmNotifyController {
|
|
return filmNotifyReturnDTO;
|
|
return filmNotifyReturnDTO;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void sendXcxMessage() {
|
|
|
|
+ String xcxMessageToken = wxXcxMessageService.getXcxMessageToken();
|
|
|
|
+ WxSend wxSend = new WxSend();
|
|
|
|
+ //wxSend.setAccess_token(xcxMessageToken);
|
|
|
|
+ wxSend.setTouser("oO7PJ5JxqYj0kVYLb1e3FG55mD8E");
|
|
|
|
+ wxSend.setTemplate_id("NlZAFJj1p5aHFOg6BBesP7xFAJh5kIZ0kp_YwtJje0g");
|
|
|
|
+ wxSend.setPage("/pages/index/index?active=user");
|
|
|
|
+
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
+ JSONObject jsonObject1 = new JSONObject();
|
|
|
|
+ JSONObject jsonObject2 = new JSONObject();
|
|
|
|
+ JSONObject jsonObject3 = new JSONObject();
|
|
|
|
+ jsonObject1.put("value","2019年10月1日");
|
|
|
|
+ jsonObject2.put("value","林霖强");
|
|
|
|
+ jsonObject3.put("value","3");
|
|
|
|
+ jsonObject.put("time3",jsonObject1);
|
|
|
|
+ jsonObject.put("name1",jsonObject2);
|
|
|
|
+ jsonObject.put("thing2",jsonObject3);
|
|
|
|
+
|
|
|
|
+ wxSend.setData(jsonObject);
|
|
|
|
+ wxSend.setMiniprogram_state("developer");
|
|
|
|
+ wxSend.setLang("zh_CN");
|
|
|
|
+ String result = wxSendService.sendMessage(xcxMessageToken,wxSend);
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
@Data
|
|
@Data
|