Merge branch 'master' into 2.0-dev

* master:
  修改配置星巴克 肯德基 会员充值 话费 微信商户号
  修改配置星巴克 肯德基 会员充值 话费 微信商户号

# Conflicts:
#	hai-cweb/src/main/java/com/cweb/controller/pay/CzOrderController.java
#	hai-cweb/src/main/java/com/cweb/controller/pay/ThirdOrderController.java
dev-discount
袁野 2 years ago
parent ff608b4070
commit db3341f13a
  1. 1
      hai-order/src/main/java/com/web/config/AuthConfig.java
  2. 231
      hai-order/src/main/java/com/web/controller/business/OrderTelChargeCallbackController.java
  3. 19
      hai-service/src/main/java/com/hai/config/CommonSysConfig.java
  4. 33
      hai-service/src/main/java/com/hai/config/WxMaConfiguration.java
  5. 121
      hai-service/src/main/java/com/hai/config/WxMsgConfig.java
  6. 8
      hai-service/src/main/resources/dev/commonConfig.properties
  7. 6
      hai-service/src/main/resources/prod-9401/commonConfig.properties
  8. 6
      hai-service/src/main/resources/prod/commonConfig.properties

@ -91,6 +91,7 @@ public class AuthConfig implements WebMvcConfigurer {
.excludePathPatterns("/**/swagger-ui.html")
.excludePathPatterns("/login/*")
.excludePathPatterns("/payNotify/*")
.excludePathPatterns("/telChargeCallback/*")
;
}

@ -0,0 +1,231 @@
package com.web.controller.business;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.pay.WechatPayUtil;
import com.hai.common.security.UserCenter;
import com.hai.config.UnionPayConfig;
import com.hai.config.WxMsgConfig;
import com.hai.dao.HighGasOrderPushMapper;
import com.hai.entity.*;
import com.hai.enum_type.OrderPushType;
import com.hai.enum_type.RechargePayType;
import com.hai.service.*;
import com.hai.service.impl.OutRechargeOrderServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@Controller
@RequestMapping(value = "telChargeCallback")
@Api(value = "话费充值回调业务")
public class OrderTelChargeCallbackController {
private static Logger log = LoggerFactory.getLogger(OutRechargeOrderServiceImpl.class);
@Resource
private OutRechargeOrderService outRechargeOrderService;
@Resource
private OutRechargeChildOrderService outRechargeChildOrderService;
@Resource
private HighUserService highUserService;
@Resource
private ApiOrderRecordService apiOrderRecordService;
@RequestMapping(value = "/rechargeCallbackByJj", method = RequestMethod.POST)
@ApiOperation(value = "尖椒充值回调")
@ResponseBody
public void rechargeCallbackByJj(@RequestBody String reqBodyStr, HttpServletRequest request, HttpServletResponse response) {
try {
JSONObject dataObject = JSONObject.parseObject(reqBodyStr, JSONObject.class);
log.info("============回调任务Start=============");
log.info("尖椒订单充值-回调参数: " + dataObject);
log.info("============回调任务End=============");
// 1 尖椒 2 龙阅
dataObject.put("orderNo" , dataObject.getString("out_order_id"));
// 查询充值记录订单
OutRechargeChildOrder childOrder = outRechargeChildOrderService.findByOrderNo(dataObject.getString("out_order_id"));
// 查询充值订单
OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderId(childOrder.getParentOrderId());
// 判断是否充值成功 并发送微信小程序服务通知
if (dataObject.getInteger("status") == 3) {
if (rechargeOrder.getRechargeStatus() ==201) {
new Thread(() -> {
HighUser highUser = highUserService.findByUserId(rechargeOrder.getUserId());
WxMsgConfig.rechargedSuccess(
rechargeOrder.getRechargeContent() + "充值成功",
String.valueOf(rechargeOrder.getPayRealPrice()),
rechargeOrder.getOrderNo(),
rechargeOrder.getFinishTime(),
RechargePayType.getNameByType(rechargeOrder.getPayType()),
highUser.getOpenId());
}).start();
}
childOrder.setStatus(101);
rechargeOrder.setRechargeStatus(202);
rechargeOrder.setPayStatus(100);
outRechargeOrderService.updateOrder(rechargeOrder);
outRechargeChildOrderService.updateOrder(childOrder);
// api商户订单
if (rechargeOrder.getPayType() == 6) {
apiOrderRecord(rechargeOrder);
}
} else {
// 充值失败操作
callbackResult(childOrder , rechargeOrder);
}
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=utf-8");
PrintWriter writer= response.getWriter();
writer.write("SUCCESS");
} catch (Exception e) {
log.error("WechatPayController --> wechatNotify() error!", e);
}
}
@RequestMapping(value = "/rechargeCallbackByLy", method = RequestMethod.POST)
@ApiOperation(value = "龙阅充值回调")
@ResponseBody
public void rechargeCallbackByLy(
@RequestParam(name = "out_trade_num", required = true) String out_trade_num,
@RequestParam(name = "userid", required = true) Long userid,
@RequestParam(name = "state", required = true) Long state,
@RequestBody String reqBodyStr ,
HttpServletRequest request, HttpServletResponse response) {
try {
log.info("============回调任务Start=============");
log.info("龙阅订单充值-回调参数: " + reqBodyStr);
log.info("============回调任务End=============");
OutRechargeChildOrder childOrder = outRechargeChildOrderService.findByOrderNo(out_trade_num);
OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderId(childOrder.getParentOrderId());
// 判断是否充值成功 并发送微信小程序服务通知
if (state == 1) {
if (rechargeOrder.getRechargeStatus() ==201) {
new Thread(() -> {
HighUser highUser = highUserService.findByUserId(rechargeOrder.getUserId());
WxMsgConfig.rechargedSuccess(
rechargeOrder.getRechargeContent() + "充值成功",
String.valueOf(rechargeOrder.getPayRealPrice()),
rechargeOrder.getOrderNo(),
rechargeOrder.getFinishTime(),
RechargePayType.getNameByType(rechargeOrder.getPayType()),
highUser.getOpenId());
}).start();
}
childOrder.setStatus(101);
rechargeOrder.setRechargeStatus(202);
rechargeOrder.setPayStatus(100);
rechargeOrder.setFinishTime(new Date());
outRechargeOrderService.updateOrder(rechargeOrder);
outRechargeChildOrderService.updateOrder(childOrder);
if (rechargeOrder.getPayType() == 6) {
apiOrderRecord(rechargeOrder);
}
} else {
callbackResult(childOrder , rechargeOrder);
}
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=utf-8");
PrintWriter writer= response.getWriter();
writer.write("SUCCESS");
} catch (Exception e) {
log.error("WechatPayController --> wechatNotify() error!", e);
}
}
// 充值回调结果处理
private void callbackResult(OutRechargeChildOrder childOrder , OutRechargeOrder rechargeOrder) throws Exception {
// 101:充值成功 102: 充值中 103:充值失败 104 未充值
// 订单支付状态 : 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款
if (childOrder.getStatus() == 102 && rechargeOrder.getPayStatus() == 102) {
Date rechargeTime = rechargeOrder.getCreateTimed();
Date currentTime = new Date();
// 当前时间减去充值时间
int hours = (int) ((currentTime.getTime() - rechargeTime.getTime()) / (1000 * 60 * 60));
// // 判断快充 并且 充值时间小于6
// if (rechargeOrder.getRechargeType() == 1 && hours < 6) {
// outRechargeOrderService.pollRequest(rechargeOrder);
// return;
// }
// 判断慢充 并且 充值时间小于72
if (hours < 72) {
outRechargeOrderService.pollRequest(rechargeOrder);
return;
}
rechargeOrder.setRechargeStatus(203);
childOrder.setStatus(103);
outRechargeOrderService.updateOrder(rechargeOrder);
outRechargeChildOrderService.updateOrder(childOrder);
outRechargeOrderService.rechargeOrderToRefund(rechargeOrder.getId());
// 发送充值失败 微信小程序服务通知
new Thread(() -> {
HighUser highUser = highUserService.findByUserId(rechargeOrder.getUserId());
WxMsgConfig.rechargedFail(
rechargeOrder.getRechargeContent() + "充值失败",
String.valueOf(rechargeOrder.getPayRealPrice()),
highUser.getOpenId());
}).start();
}
}
private void apiOrderRecord(OutRechargeOrder rechargeOrder) {
Map<String, Object> orderMap = new HashMap<>();
orderMap.put("orderId" , rechargeOrder.getId());
// 查询是否用重复订单
ApiOrderRecord apiOrderRecord = apiOrderRecordService.queryOrderResult(orderMap);
apiOrderRecord.setStatus(100);
apiOrderRecord.setRequestTime(new Date());
apiOrderRecordService.updateOrderRecord(apiOrderRecord);
}
}

@ -107,6 +107,25 @@ public class CommonSysConfig {
private String fileUrl;
private String wxAppId;
private String wxAppSecret;
public String getWxAppId() {
return wxAppId;
}
public void setWxAppId(String wxAppId) {
this.wxAppId = wxAppId;
}
public String getWxAppSecret() {
return wxAppSecret;
}
public void setWxAppSecret(String wxAppSecret) {
this.wxAppSecret = wxAppSecret;
}
public String getChongQingCnpcUrl() {
return ChongQingCnpcUrl;
}

@ -0,0 +1,33 @@
package com.hai.config;
import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
import cn.binarywang.wx.miniapp.config.impl.WxMaDefaultConfigImpl;
import org.springframework.context.annotation.Configuration;
import javax.annotation.PostConstruct;
@Configuration
public class WxMaConfiguration {
private static WxMaService maService;
public static WxMaService getMaService() {
if (maService == null) {
throw new IllegalArgumentException(String.format("未找到对应的配置,请核实!"));
}
return maService;
}
@PostConstruct
public void init() {
WxMaDefaultConfigImpl config = new WxMaDefaultConfigImpl();
config.setAppid(CommonSysConst.getSysConfig().getWxAppId());
config.setSecret(CommonSysConst.getSysConfig().getWxAppSecret());
maService = new WxMaServiceImpl();
maService.setWxMaConfig(config);
}
}

@ -0,0 +1,121 @@
package com.hai.config;
import cn.binarywang.wx.miniapp.api.WxMaMsgService;
import cn.binarywang.wx.miniapp.api.WxMaService;
import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage;
import com.hai.common.utils.DateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Async;
import java.util.*;
public class WxMsgConfig {
private static Logger log = LoggerFactory.getLogger(WxMsgConfig.class);
public static void pushOneUser(String orderName , String price , String orderNo , Date payTime , String remark , Long orderId , String openId) {
try {
List<WxMaSubscribeMessage.Data> list = new ArrayList<>();
Map<String, String> m = new HashMap<>();
m.put("thing1", orderName);
m.put("amount2", price + "元");
m.put("character_string3", orderNo);
m.put("time4", DateUtil.date2String(payTime , "yyyy年MM月dd日 HH:mm:ss"));
m.put("thing6", remark);
for (String key: m.keySet()) {
WxMaSubscribeMessage.Data msgElement = new WxMaSubscribeMessage.Data();
msgElement.setName(key);
msgElement.setValue(m.get(key));
list.add(msgElement);
}
WxMaSubscribeMessage subscribeMessage = new WxMaSubscribeMessage();
subscribeMessage.setToUser(openId); // 小程序openId
subscribeMessage.setTemplateId("oUvaCPeeOg4wH6HTvCcSabU6FnzXUXOBXsqBYAPOV-U");
subscribeMessage.setData(list);
subscribeMessage.setPage("pages/user/order_details/order_details?id=" + orderId);
subscribeMessage.setMiniprogramState("developer");
final WxMaService wxService = WxMaConfiguration.getMaService();
WxMaMsgService maMsgService = wxService.getMsgService();
maMsgService.sendSubscribeMsg(subscribeMessage);
} catch (Exception e) {
log.error(String.valueOf(e));
}
}
public static void rechargedSuccess(String orderName , String price , String orderNo , Date payTime , String payType , String openId) {
try {
List<WxMaSubscribeMessage.Data> list = new ArrayList<>();
Map<String, String> m = new HashMap<>();
m.put("character_string1", orderNo); // 订单号
m.put("thing11", orderName); // 充值项目
m.put("thing10", payType); // 支付方式
m.put("amount8", price); // 支付金额
m.put("date5", DateUtil.date2String(payTime , "yyyy年MM月dd日 HH:mm:ss"));
for (String key: m.keySet()) {
WxMaSubscribeMessage.Data msgElement = new WxMaSubscribeMessage.Data();
msgElement.setName(key);
msgElement.setValue(m.get(key));
list.add(msgElement);
}
WxMaSubscribeMessage subscribeMessage = new WxMaSubscribeMessage();
subscribeMessage.setToUser(openId); // 小程序openId
subscribeMessage.setTemplateId("ZO6kC3oJv0zj9QzL0htsF-mM9vAElcgPZEcUGglxsoU");
subscribeMessage.setData(list);
final WxMaService wxService = WxMaConfiguration.getMaService();
WxMaMsgService maMsgService = wxService.getMsgService();
maMsgService.sendSubscribeMsg(subscribeMessage);
} catch (Exception e) {
log.error(String.valueOf(e));
}
}
public static void rechargedFail(String orderName , String price , String openId) {
try {
List<WxMaSubscribeMessage.Data> list = new ArrayList<>();
Map<String, String> m = new HashMap<>();
m.put("thing1", orderName); // 订单内容
m.put("thing2", "充值通道爆满!"); // 失败原因
m.put("amount3", price); // 退款金额
m.put("thing4", "退款将在1-3日内原路退回"); // 温馨提示
for (String key: m.keySet()) {
WxMaSubscribeMessage.Data msgElement = new WxMaSubscribeMessage.Data();
msgElement.setName(key);
msgElement.setValue(m.get(key));
list.add(msgElement);
}
WxMaSubscribeMessage subscribeMessage = new WxMaSubscribeMessage();
subscribeMessage.setToUser(openId); // 小程序openId
subscribeMessage.setTemplateId("xjacmzuWSRdiKGz4IJVeuvyGE0vOhoy0JVQPgOr-PuI");
subscribeMessage.setData(list);
final WxMaService wxService = WxMaConfiguration.getMaService();
WxMaMsgService maMsgService = wxService.getMsgService();
maMsgService.sendSubscribeMsg(subscribeMessage);
} catch (Exception e) {
log.error(String.valueOf(e));
}
}
}

@ -79,13 +79,13 @@ TelApiSecret=d11ee9b41e014a039f030e53ae6f5295
TelMemberId=d13091df65d64aafbf0f35d2093157b7
# Jj
JjNotifyUrl = https://hsgcs.dctpay.com/crest/czOrder/rechargeCallbackByJj
JjNotifyUrl = https://hsgcs.dctpay.com/order/telChargeCallback/rechargeCallbackByJj
JjAppKey = eaomqcbpdz7yjfih
JjUrl = https://hfcs.dmjvip.com/index.php/third/mobile/
JjAppSecret = xkf9eoq2cjh6uvzp0mtrga134lnibdw8
#LY
LyNotifyUrl = https://hsgcs.dctpay.com/crest/czOrder/rechargeCallbackByLy
LyNotifyUrl = https://hsgcs.dctpay.com/order/telChargeCallback/rechargeCallbackByLy
#LyApiKey=CMdyxh2gJ7tbXc6rS0KADqPIfVpaQLjU
#LyMemberId=18665
#LyPostUrl=https://cz.31994.cn/yrapi.php/
@ -106,3 +106,7 @@ unionRsaKey=891f6775fba7f12cc23df7c75e02b39b891f6775fba7f12c
#url
fileUrl=/home/project/hsg/filesystem/
#fileUrl=/Volumes/work/code/filesystem/
#wx
wxAppId=wx8d49e2f83025229d
wxAppSecret=d8d6dcaef77d3b659258a01b5ddba5df

@ -71,13 +71,13 @@ TelApiSecret=d11ee9b41e014a039f030e53ae6f5295
TelMemberId=d13091df65d64aafbf0f35d2093157b7
// Mobile
JjNotifyUrl = https://hsg.dctpay.com/crest/czOrder/rechargeCallbackByJj
JjNotifyUrl = https://hsg.dctpay.com/order/telChargeCallback/rechargeCallbackByJj
JjAppKey = p429mlj3cvn5hb07
JjUrl = https://jj.dmjvip.com/index.php/third/mobile/
JjAppSecret = bf57pnqy8mkexr0v169c3g4odazwu2ij
#LY
LyNotifyUrl = https://hsg.dctpay.com/crest/czOrder/rechargeCallbackByLy
LyNotifyUrl = https://hsg.dctpay.com/order/telChargeCallback/rechargeCallbackByLy
#LyApiKey=CMdyxh2gJ7tbXc6rS0KADqPIfVpaQLjU
#LyMemberId=18665
#LyPostUrl=https://cz.31994.cn/yrapi.php/
@ -98,3 +98,5 @@ unionRsaKey=f2e6b6b95da445866194498c371a7c8af2e6b6b95da44586
#url
fileUrl=/home/project/hsg/filesystem/
wxAppId=wx8d49e2f83025229d
wxAppSecret=d8d6dcaef77d3b659258a01b5ddba5df

@ -69,13 +69,13 @@ TelApiSecret=d11ee9b41e014a039f030e53ae6f5295
TelMemberId=d13091df65d64aafbf0f35d2093157b7
// Mobile
JjNotifyUrl = https://hsg.dctpay.com/crest/czOrder/rechargeCallbackByJj
JjNotifyUrl = https://hsg.dctpay.com/order/telChargeCallback/rechargeCallbackByJj
JjAppKey = p429mlj3cvn5hb07
JjUrl = https://jj.dmjvip.com/index.php/third/mobile/
JjAppSecret = bf57pnqy8mkexr0v169c3g4odazwu2ij
#LY
LyNotifyUrl = https://hsg.dctpay.com/crest/czOrder/rechargeCallbackByLy
LyNotifyUrl = https://hsg.dctpay.com/order/telChargeCallback/rechargeCallbackByLy
#LyApiKey=CMdyxh2gJ7tbXc6rS0KADqPIfVpaQLjU
##LyMemberId=18665
##LyPostUrl=https://cz.31994.cn/yrapi.php/
@ -96,3 +96,5 @@ unionRsaKey=f2e6b6b95da445866194498c371a7c8af2e6b6b95da44586
#url
fileUrl=/home/project/hsg/filesystem/
wxAppId=wx8d49e2f83025229d
wxAppSecret=d8d6dcaef77d3b659258a01b5ddba5df

Loading…
Cancel
Save