From 18101bbe99fad9d995ef07d6b6597e20ed16d472 Mon Sep 17 00:00:00 2001 From: YUANYE <418471657@qq.com> Date: Mon, 13 Sep 2021 09:31:52 +0800 Subject: [PATCH] 1 --- .../bweb/controller/SecUserController.java | 2 +- .../com/bweb/controller/TelApiController.java | 23 +- .../main/java/com/cweb/config/AuthConfig.java | 1 + .../java/com/cweb/config/WxMsgConfig.java | 55 +++++ .../com/cweb/controller/TelApiController.java | 216 ++++++++++++++++++ .../cweb/controller/pay/OrderController.java | 38 +++ .../controller/pay/WechatPayController.java | 36 ++- .../java/com/hai/config/CommonSysConfig.java | 36 --- .../main/java/com/hai/config/TelConfig.java | 7 - .../com/hai/config/WxMaConfiguration.java | 33 --- .../main/java/com/hai/config/WxMsgConfig.java | 90 -------- .../java/com/hai/enum_type/GoodsType.java | 46 ++++ .../main/java/com/hai/enum_type/PayType.java | 44 ++++ .../service/impl/HighOrderServiceImpl.java | 14 +- .../hai/service/impl/HighUserServiceImpl.java | 2 +- .../com/hai/service/pay/NotifyService.java | 1 + .../service/pay/impl/CinemaOrderService.java | 8 + .../pay/impl/GoodsOrderServiceImpl.java | 6 + .../hai/service/pay/impl/KfcOrderService.java | 8 + .../pay/impl/MobileOrderServiceImpl.java | 7 + .../service/pay/impl/NotifyServiceImpl.java | 15 +- .../resources/dev/commonConfig.properties | 3 - 22 files changed, 500 insertions(+), 191 deletions(-) create mode 100644 hai-cweb/src/main/java/com/cweb/config/WxMsgConfig.java create mode 100644 hai-cweb/src/main/java/com/cweb/controller/TelApiController.java delete mode 100644 hai-service/src/main/java/com/hai/config/WxMaConfiguration.java delete mode 100644 hai-service/src/main/java/com/hai/config/WxMsgConfig.java create mode 100644 hai-service/src/main/java/com/hai/enum_type/GoodsType.java create mode 100644 hai-service/src/main/java/com/hai/enum_type/PayType.java diff --git a/hai-bweb/src/main/java/com/bweb/controller/SecUserController.java b/hai-bweb/src/main/java/com/bweb/controller/SecUserController.java index 1d551ce9..fdff6fe2 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/SecUserController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/SecUserController.java @@ -72,7 +72,7 @@ public class SecUserController { //查询用户 SecUser secUser = secUserService.findById(userId); if(secUser == null){ - log.error("BaseMemberController --> sendUserPass() error!","未找到用户"); + log.error("BaseMemberController --> sendUserPass() error!",""); throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_MEMBER_ERROR, ""); } if(!secUser.getPassword().equals(MD5Util.encode(oldPassword.getBytes()))) { diff --git a/hai-bweb/src/main/java/com/bweb/controller/TelApiController.java b/hai-bweb/src/main/java/com/bweb/controller/TelApiController.java index 1f46bedc..86f1c12a 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/TelApiController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/TelApiController.java @@ -1,6 +1,5 @@ package com.bweb.controller; -import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; @@ -8,14 +7,13 @@ import com.hai.common.exception.SysCode; import com.hai.common.pay.util.IOUtil; import com.hai.common.pay.util.XmlUtil; import com.hai.common.utils.*; -import com.hai.config.CommonSysConst; -import com.hai.config.QianZhuConfig; import com.hai.config.TelConfig; -import com.hai.config.WxMsgConfig; -import com.hai.entity.HighDiscount; -import com.hai.entity.HighTelOrder; -import com.hai.entity.HighUser; +import com.hai.entity.*; +import com.hai.enum_type.GoodsType; +import com.hai.enum_type.PayType; import com.hai.model.ResponseData; +import com.hai.service.HighOrderService; +import com.hai.service.HighUserService; import com.hai.service.TelApiService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -27,9 +25,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.io.BufferedOutputStream; import java.math.BigDecimal; -import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; import java.util.Map; @@ -45,6 +41,12 @@ public class TelApiController { @Resource private TelApiService telApiService; + @Resource + private HighOrderService highOrderService; + + @Resource + private HighUserService highUserService; + /** * 中国电信号码格式验证 手机段: 133,153,180,181,189,177,1700,173,199 **/ @@ -189,7 +191,8 @@ public class TelApiController { public ResponseData getTest() { try { - return ResponseMsgUtil.success(WxMsgConfig.pushOneUser(668L)); + + return ResponseMsgUtil.success("1"); } catch (Exception e) { return ResponseMsgUtil.exception(e); } diff --git a/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java b/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java index 9f9be337..d17de229 100644 --- a/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java +++ b/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java @@ -119,6 +119,7 @@ public class AuthConfig implements WebMvcConfigurer { .excludePathPatterns("/order/qzOrderToPay") .excludePathPatterns("/czOrder/orderRefundNotify") .excludePathPatterns("/tPig/*") + .excludePathPatterns("/telApi/*") ; } diff --git a/hai-cweb/src/main/java/com/cweb/config/WxMsgConfig.java b/hai-cweb/src/main/java/com/cweb/config/WxMsgConfig.java new file mode 100644 index 00000000..dcecc399 --- /dev/null +++ b/hai-cweb/src/main/java/com/cweb/config/WxMsgConfig.java @@ -0,0 +1,55 @@ +package com.cweb.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 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 list = new ArrayList<>(); + + Map 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)); + } + + } + + + + +} diff --git a/hai-cweb/src/main/java/com/cweb/controller/TelApiController.java b/hai-cweb/src/main/java/com/cweb/controller/TelApiController.java new file mode 100644 index 00000000..cfebe4a2 --- /dev/null +++ b/hai-cweb/src/main/java/com/cweb/controller/TelApiController.java @@ -0,0 +1,216 @@ +package com.cweb.controller; + +import com.alibaba.fastjson.JSONObject; +import com.cweb.config.WxMsgConfig; +import com.hai.common.exception.ErrorCode; +import com.hai.common.exception.ErrorHelp; +import com.hai.common.exception.SysCode; +import com.hai.common.pay.util.IOUtil; +import com.hai.common.pay.util.XmlUtil; +import com.hai.common.utils.*; +import com.hai.config.TelConfig; +import com.hai.entity.HighChildOrder; +import com.hai.entity.HighOrder; +import com.hai.entity.HighTelOrder; +import com.hai.entity.HighUser; +import com.hai.enum_type.GoodsType; +import com.hai.enum_type.PayType; +import com.hai.model.ResponseData; +import com.hai.service.HighOrderService; +import com.hai.service.HighUserService; +import com.hai.service.TelApiService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.math.BigDecimal; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.SortedMap; +import java.util.regex.Pattern; + +@RestController +@RequestMapping(value = "/telApi") +@Api(value = "电话费充值数据接口") +public class TelApiController { + private static Logger log = LoggerFactory.getLogger(TelApiController.class); + + @Resource + private TelApiService telApiService; + + @Resource + private HighOrderService highOrderService; + + @Resource + private HighUserService highUserService; + + /** + * 中国电信号码格式验证 手机段: 133,153,180,181,189,177,1700,173,199 + **/ + private static final String CHINA_TELECOM_PATTERN = "(^1(33|53|77|73|99|8[019])\\d{8}$)|(^1700\\d{7}$)"; + + /** + * 中国联通号码格式验证 手机段:130,131,132,155,156,185,186,145,176,1709 + **/ + private static final String CHINA_UNICOM_PATTERN = "(^1(3[0-2]|4[5]|5[56]|7[6]|8[56])\\d{8}$)|(^1709\\d{7}$)"; + + /** + * 中国移动号码格式验证 + * 手机段:134,135,136,137,138,139,150,151,152,157,158,159,182,183,184,187,188,147,178,1705 + **/ + private static final String CHINA_MOBILE_PATTERN = "(^1(3[4-9]|4[7]|5[0-27-9]|7[8]|8[2-478])\\d{8}$)|(^1705\\d{7}$)"; + + + @RequestMapping(value = "/telPay", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "充值话费") + public ResponseData certification(@RequestBody HighTelOrder highTelOrder) { + try { + + if (StringUtils.isBlank(highTelOrder.getTel()) || + highTelOrder.getPrice() == null + ) { + log.error("telApi -> telPay() error!", "参数错误"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + int random = (int) (1 + Math.random() * (999999 - 100000 + 1)); + + Map map = new HashMap<>(); + + String mchid = "HFb44f8_10004"; + String tel = highTelOrder.getTel(); + String orderid = "HF" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5); + BigDecimal price = BigDecimal.valueOf(highTelOrder.getPrice()); + String teltype = isChinaMobilePhoneNum(highTelOrder.getTel()).toString(); + int timeout = 300; + String notify = "notify"; + String time = String.valueOf(new Date().getTime()); + String APIKEY = "483e5a68fe9bda2f7ab3f2665a0006cd"; + String sign = mchid + tel + price + orderid + teltype + notify + time + random + APIKEY; + + String param = "mchid=" + mchid + + "&tel=" + tel + + "&orderid=" + orderid + + "&price=" + price + + "&teltype=" + teltype + + "¬ify=" + notify + + "&time=" + time + + "&rand=" + random + + "&sign=" + MD5Util.encode(sign.getBytes()); + map.put("from", param); + + JSONObject object = HttpsUtils.doSmsPost("http://45.130.154.125:9998/api/telpay", map, new HashMap<>()); + return ResponseMsgUtil.success(object); + } catch (Exception e) { + log.error("HighMerchantController -> insertMerchant() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/notify", method = RequestMethod.POST) + @ApiOperation(value = "话费充值 -> 异步回调") + public void wechatNotify(HttpServletRequest request, HttpServletResponse response) { + try { + + log.info("话费充值 -> 异步通知:处理开始"); + + String notifyXml = null; // 话费充值系统发送的数据(格式) + notifyXml = IOUtil.inputStreamToString(request.getInputStream(), "UTF-8"); + + log.info("话费充值系统发送的数据:" + notifyXml); + SortedMap map = XmlUtil.parseXmlToTreeMap(notifyXml, "UTF-8"); + +// resXml = notifyService.wechatNotify(map); +// +// +// BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream()); +// out.write(resXml.getBytes()); +// out.flush(); +// out.close(); + log.info("话费充值 -> 异步通知:处理完成"); + } catch (Exception e) { + log.error("WechatPayController --> wechatNotify() error!", e); + } + } + + /** + * 查询电话属于哪个运营商 + * + * @param tel 手机号码 + * @return 0:不属于任何一个运营商,0:移动,1:联通,2:电信 99: 什么都不是 + */ + public Integer isChinaMobilePhoneNum(String tel) { + boolean b1 = tel != null && !tel.trim().equals("") && match(CHINA_MOBILE_PATTERN, tel); + if (b1) { + return 0; + } + b1 = tel != null && !tel.trim().equals("") && match(CHINA_UNICOM_PATTERN, tel); + if (b1) { + return 1; + } + b1 = tel != null && !tel.trim().equals("") && match(CHINA_TELECOM_PATTERN, tel); + if (b1) { + return 2; + } + return 99; + } + + /** + * 匹配函数 + * + * @param regex + * @param tel + * @return + */ + private static boolean match(String regex, String tel) { + return Pattern.matches(regex, tel); + } + + + @RequestMapping(value = "/getMemberGoods", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "获取渠道商获取关联商品") + public ResponseData getMemberGoods() { + try { + + JSONObject data = TelConfig.getMemberGoods(); + + return ResponseMsgUtil.success(data); + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/getTest", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "测试接口") + public ResponseData getTest() { + try { + + HighOrder order = highOrderService.getOrderById(699L); + + HighUser highUser = highUserService.findByUserId(order.getMemId()); + HighChildOrder presentation = highOrderService.getChildOrderByPresentation(order.getId()); + WxMsgConfig.pushOneUser( + presentation.getGoodsName() + "(" + GoodsType.getNameByType(presentation.getGoodsType()) + ")", + String.valueOf(order.getPayPrice()), + order.getOrderNo(), + order.getPayTime(), + PayType.getNameByType(order.getPayType()), order.getId(), + highUser.getOpenId()); + + return ResponseMsgUtil.success("1"); + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + } + +} diff --git a/hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java b/hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java index 0c0d85e8..58429e56 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.cweb.config.SysConst; +import com.cweb.config.WxMsgConfig; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; @@ -21,6 +22,8 @@ import com.hai.common.utils.ResponseMsgUtil; import com.hai.config.QianZhuConfig; import com.hai.config.TuanYouConfig; import com.hai.entity.*; +import com.hai.enum_type.GoodsType; +import com.hai.enum_type.PayType; import com.hai.model.HighCouponModel; import com.hai.model.HighUserModel; import com.hai.model.ResponseData; @@ -96,6 +99,9 @@ public class OrderController { @Resource private HighUserCardService highUserCardService; + @Resource + private HighUserService highUserService; + /** * * @Title: orderToPay @@ -267,6 +273,22 @@ public class OrderController { highOrderService.goldPayOrder(order.getMemId(), order.getId()); + new Thread(() -> { + // 查询订单信息 + if (order == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_ORDER, ""); + } + HighUser highUser = highUserService.findByUserId(order.getMemId()); + HighChildOrder presentation = highOrderService.getChildOrderByPresentation(order.getId()); + WxMsgConfig.pushOneUser( + presentation.getGoodsName() + "(" + GoodsType.getNameByType(presentation.getGoodsType()) + ")", + String.valueOf(order.getPayPrice()), + order.getOrderNo(), + order.getPayTime(), + PayType.getNameByType(order.getPayType()), order.getId(), + highUser.getOpenId()); + }).start(); + return ResponseMsgUtil.success("支付成功"); } catch (Exception e) { log.error("orderToPay error!", e); @@ -344,6 +366,22 @@ public class OrderController { highOrderService.hltUnionCardPay(userCard.getId(), order.getId()); + new Thread(() -> { + // 查询订单信息 + if (order == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_ORDER, ""); + } + HighUser highUser = highUserService.findByUserId(order.getMemId()); + HighChildOrder presentation = highOrderService.getChildOrderByPresentation(order.getId()); + WxMsgConfig.pushOneUser( + presentation.getGoodsName() + "(" + GoodsType.getNameByType(presentation.getGoodsType()) + ")", + String.valueOf(order.getPayPrice()), + order.getOrderNo(), + order.getPayTime(), + PayType.getNameByType(order.getPayType()), order.getId(), + highUser.getOpenId()); + }).start(); + return ResponseMsgUtil.success("支付成功"); } catch (Exception e) { log.error("orderToPay error!", e); diff --git a/hai-cweb/src/main/java/com/cweb/controller/pay/WechatPayController.java b/hai-cweb/src/main/java/com/cweb/controller/pay/WechatPayController.java index 156858b1..890e38b1 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/pay/WechatPayController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/pay/WechatPayController.java @@ -2,6 +2,10 @@ package com.cweb.controller.pay; import com.alibaba.fastjson.JSONObject; import com.cweb.config.SysConst; +import com.cweb.config.WxMsgConfig; +import com.hai.common.exception.ErrorCode; +import com.hai.common.exception.ErrorHelp; +import com.hai.common.exception.SysCode; import com.hai.common.pay.WechatPayUtil; import com.hai.common.pay.entity.WechatCallBackInfo; import com.hai.common.pay.util.IOUtil; @@ -10,13 +14,15 @@ import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.utils.HttpsUtils; import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.WxUtils; -import com.hai.entity.BsCompany; -import com.hai.entity.HighProfitSharingRecord; -import com.hai.entity.SecRegion; +import com.hai.entity.*; +import com.hai.enum_type.GoodsType; +import com.hai.enum_type.PayType; import com.hai.model.ResponseData; import com.hai.model.WxSharingOrderRequestModel; import com.hai.model.WxSharingReceiversVO; +import com.hai.service.HighOrderService; import com.hai.service.HighProfitSharingRecordService; +import com.hai.service.HighUserService; import com.hai.service.TelApiService; import com.hai.service.pay.NotifyService; import com.hai.service.pay.PayRecordService; @@ -69,6 +75,12 @@ public class WechatPayController { @Resource private WechatPayUtil wechatPayUtil; + @Resource + private HighOrderService highOrderService; + + @Resource + private HighUserService highUserService; + @Resource private TelApiService telApiService; @Resource @@ -102,6 +114,24 @@ public class WechatPayController { + "" + " "; }*/ + + new Thread(() -> { + // 查询订单信息 + HighOrder order = highOrderService.getOrderByOrderNo(map.get("out_trade_no")); + if (order == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_ORDER, ""); + } + HighUser highUser = highUserService.findByUserId(order.getMemId()); + HighChildOrder presentation = highOrderService.getChildOrderByPresentation(order.getId()); + WxMsgConfig.pushOneUser( + presentation.getGoodsName() + "(" + GoodsType.getNameByType(presentation.getGoodsType()) + ")", + String.valueOf(order.getPayPrice()), + order.getOrderNo(), + order.getPayTime(), + PayType.getNameByType(order.getPayType()), order.getId(), + highUser.getOpenId()); + }).start(); + BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream()); out.write(resXml.getBytes()); out.flush(); diff --git a/hai-service/src/main/java/com/hai/config/CommonSysConfig.java b/hai-service/src/main/java/com/hai/config/CommonSysConfig.java index 3e035bea..51d1e0a2 100644 --- a/hai-service/src/main/java/com/hai/config/CommonSysConfig.java +++ b/hai-service/src/main/java/com/hai/config/CommonSysConfig.java @@ -39,11 +39,6 @@ public class CommonSysConfig { private String telUrl; private String czOrderNotify; - private String apiKey; - private String apiSecret; - private String MpApiSecret; - private String tokenUrl; - public String getHuiLianTongUnionCardUrl() { return HuiLianTongUnionCardUrl; } @@ -236,35 +231,4 @@ public class CommonSysConfig { this.telUrl = telUrl; } - public String getApiKey() { - return apiKey; - } - - public void setApiKey(String apiKey) { - this.apiKey = apiKey; - } - - public String getApiSecret() { - return apiSecret; - } - - public void setApiSecret(String apiSecret) { - this.apiSecret = apiSecret; - } - - public String getMpApiSecret() { - return MpApiSecret; - } - - public void setMpApiSecret(String mpApiSecret) { - MpApiSecret = mpApiSecret; - } - - public String getTokenUrl() { - return tokenUrl; - } - - public void setTokenUrl(String tokenUrl) { - this.tokenUrl = tokenUrl; - } } diff --git a/hai-service/src/main/java/com/hai/config/TelConfig.java b/hai-service/src/main/java/com/hai/config/TelConfig.java index 85c7a6aa..1ccb332d 100644 --- a/hai-service/src/main/java/com/hai/config/TelConfig.java +++ b/hai-service/src/main/java/com/hai/config/TelConfig.java @@ -23,13 +23,6 @@ import java.util.Map; **/ public class TelConfig { - - @Resource - private OutRechargeOrderService outRechargeOrderService; - - @Resource - private OutRechargePriceService outRechargePriceService; - public static JSONObject getMemberGoods() throws Exception { Map map = new HashMap<>(); diff --git a/hai-service/src/main/java/com/hai/config/WxMaConfiguration.java b/hai-service/src/main/java/com/hai/config/WxMaConfiguration.java deleted file mode 100644 index 9c819990..00000000 --- a/hai-service/src/main/java/com/hai/config/WxMaConfiguration.java +++ /dev/null @@ -1,33 +0,0 @@ -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().getApiKey()); - config.setSecret(CommonSysConst.getSysConfig().getApiSecret()); - - maService = new WxMaServiceImpl(); - maService.setWxMaConfig(config); - } - -} diff --git a/hai-service/src/main/java/com/hai/config/WxMsgConfig.java b/hai-service/src/main/java/com/hai/config/WxMsgConfig.java deleted file mode 100644 index cfd6dec6..00000000 --- a/hai-service/src/main/java/com/hai/config/WxMsgConfig.java +++ /dev/null @@ -1,90 +0,0 @@ -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 cn.binarywang.wx.miniapp.bean.WxMaTemplateData; -import cn.binarywang.wx.miniapp.bean.WxMaUniformMessage; -import com.alibaba.fastjson.JSONObject; -import com.hai.common.utils.DateUtil; -import com.hai.common.utils.HttpsUtils; - -import com.hai.common.utils.ResponseMsgUtil; -import com.hai.entity.HighChildOrder; -import com.hai.entity.HighOrder; -import com.hai.model.ResponseData; -import com.hai.service.HighOrderService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class WxMsgConfig { - - private static Logger log = LoggerFactory.getLogger(WxMsgConfig.class); - - @Resource - private static HighOrderService highOrderService; - - - public static ResponseData pushOneUser(Long orderId) { - - try { - List list = new ArrayList<>(); - - HighChildOrder highChildOrder = highOrderService.getChildOrderByPresentation(orderId); - - HighOrder highOrder = highOrderService.getOrderById(orderId); - - - - Map m = new HashMap<>(); - m.put("thing1", highChildOrder.getGoodsName()); - m.put("amount2", highChildOrder.getGoodsActualPrice() + "元"); - m.put("character_string3", highOrder.getOrderNo()); - m.put("time4", DateUtil.date2String(highOrder.getPayTime() , "yyyy年MM月dd天 HH分mm秒")); - m.put("thing6", "微信支付"); - - 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("oUGn_4lkgegcjTc9oR1qBGjtAm3A"); // 小程序openId - subscribeMessage.setTemplateId("oUvaCPeeOg4wH6HTvCcSabU6FnzXUXOBXsqBYAPOV-U"); - subscribeMessage.setData(list); - subscribeMessage.setPage("pages/user/order_details/order_details?id=666"); - subscribeMessage.setMiniprogramState("developer"); - - final WxMaService wxService = WxMaConfiguration.getMaService(); - WxMaMsgService maMsgService = wxService.getMsgService(); - maMsgService.sendSubscribeMsg(subscribeMessage); - return ResponseMsgUtil.success("发送成功"); - } catch (Exception e) { - return ResponseMsgUtil.exception(e); - } - - } - - public static JSONObject getWxMsgToken() { - - Map map = new HashMap<>(); - - map.put("appid", CommonSysConst.getSysConfig().getApiKey()); - map.put("secret", CommonSysConst.getSysConfig().getApiSecret()); - map.put("grant_type", "client_credential"); - - return HttpsUtils.doGet(CommonSysConst.getSysConfig().getTokenUrl() + "/cgi-bin/token", map); - } - - -} diff --git a/hai-service/src/main/java/com/hai/enum_type/GoodsType.java b/hai-service/src/main/java/com/hai/enum_type/GoodsType.java new file mode 100644 index 00000000..4f246b7d --- /dev/null +++ b/hai-service/src/main/java/com/hai/enum_type/GoodsType.java @@ -0,0 +1,46 @@ +package com.hai.enum_type; + +import java.util.Objects; + +public enum GoodsType { + + goodsType1(1 , "卡卷"), + goodsType2(2 , "金币充值"), + goodsType3(3 , "团油"), + goodsType4(4 , "KFC"), + goodsType5(5 , "电影票"), + goodsType6(6 , "话费充值") + ; + + private Integer type; + private String name; + + + GoodsType(int type , String name) { + this.type = type; + this.name = name; + } + + public static String getNameByType(Integer type) { + for (GoodsType ele : values()) { + if(Objects.equals(type,ele.getType())) return ele.getName(); + } + return null; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/hai-service/src/main/java/com/hai/enum_type/PayType.java b/hai-service/src/main/java/com/hai/enum_type/PayType.java new file mode 100644 index 00000000..fffb3af9 --- /dev/null +++ b/hai-service/src/main/java/com/hai/enum_type/PayType.java @@ -0,0 +1,44 @@ +package com.hai.enum_type; + +import java.util.Objects; + +public enum PayType { + + payType1(1 , "支付宝"), + payType2(2 , "微信"), + payType3(3 , "金币"), + payType4(4 , "汇联通工会卡") + ; + + private Integer type; + private String name; + + + PayType(int type , String name) { + this.type = type; + this.name = name; + } + + public static String getNameByType(Integer type) { + for (PayType ele : values()) { + if(Objects.equals(type,ele.getType())) return ele.getName(); + } + return null; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java index 19bf0560..2928832c 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java @@ -8,12 +8,11 @@ import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.utils.DateUtil; import com.hai.common.utils.IDGenerator; -import com.hai.config.CommonSysConst; -import com.hai.config.HuiLianTongConfig; -import com.hai.config.HuiLianTongUnionCardConfig; -import com.hai.config.TuanYouConfig; +import com.hai.config.*; import com.hai.dao.*; import com.hai.entity.*; +import com.hai.enum_type.GoodsType; +import com.hai.enum_type.PayType; import com.hai.model.*; import com.hai.service.*; import org.apache.commons.collections4.MapUtils; @@ -82,6 +81,9 @@ public class HighOrderServiceImpl implements HighOrderService { @Resource private HighMerchantStoreService highMerchantStoreService; + @Resource + private HighOrderService highOrderService; + @Override @Transactional(propagation= Propagation.REQUIRES_NEW) public void insertOrder(HighOrder highOrder) throws Exception { @@ -472,8 +474,9 @@ public class HighOrderServiceImpl implements HighOrderService { highChildOrder.setGasOrderNo(orderPushObject.getJSONObject("result").getString("orderNo")); } } - updateOrder(order); } + + updateOrder(order); } @Override @@ -881,7 +884,6 @@ public class HighOrderServiceImpl implements HighOrderService { @Override public HighChildOrder getChildOrderByPresentation(Long orderId) { HighChildOrderExample example = new HighChildOrderExample(); - HighChildOrderExample.Criteria criteria = example.createCriteria(); example.createCriteria().andOrderIdEqualTo(orderId).andGiveawayTypeEqualTo(false); return highChildOrderMapper.selectByExample(example).get(0); } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java index 34301c88..b0aa79f6 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java @@ -136,7 +136,7 @@ public class HighUserServiceImpl implements HighUserService { HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); HighUser highUser = findByUserId(userInfoModel.getHighUser().getId()); if (highUser == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到用户"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_MEMBER_ERROR, "未找到用户"); } if (StringUtils.isNotBlank(highUser.getPhone())) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已绑定手机号,请勿重复绑定"); diff --git a/hai-service/src/main/java/com/hai/service/pay/NotifyService.java b/hai-service/src/main/java/com/hai/service/pay/NotifyService.java index 7c567461..21fb5018 100644 --- a/hai-service/src/main/java/com/hai/service/pay/NotifyService.java +++ b/hai-service/src/main/java/com/hai/service/pay/NotifyService.java @@ -27,4 +27,5 @@ public interface NotifyService { * @param paramsMap 异步回调返回的参数 */ String wechatNotify(Map paramsMap) throws Exception; + } diff --git a/hai-service/src/main/java/com/hai/service/pay/impl/CinemaOrderService.java b/hai-service/src/main/java/com/hai/service/pay/impl/CinemaOrderService.java index 0bfc6699..82e68ae5 100644 --- a/hai-service/src/main/java/com/hai/service/pay/impl/CinemaOrderService.java +++ b/hai-service/src/main/java/com/hai/service/pay/impl/CinemaOrderService.java @@ -6,7 +6,11 @@ import com.hai.dao.HighGasOrderPushMapper; import com.hai.entity.HighChildOrder; import com.hai.entity.HighGasOrderPush; import com.hai.entity.HighOrder; +import com.hai.entity.HighUser; +import com.hai.enum_type.GoodsType; +import com.hai.enum_type.PayType; import com.hai.service.HighOrderService; +import com.hai.service.HighUserService; import com.hai.service.pay.PayService; import org.springframework.stereotype.Service; @@ -24,6 +28,9 @@ public class CinemaOrderService implements PayService { @Resource private HighGasOrderPushMapper highGasOrderPushMapper; + @Resource + private HighUserService highUserService; + @Override public void paySuccess(Map map, String payType) throws Exception { if (payType.equals("Alipay")) { @@ -42,6 +49,7 @@ public class CinemaOrderService implements PayService { for (HighChildOrder childOrder : order.getHighChildOrderList()) { childOrder.setChildOrdeStatus(2); // 子订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 } + highOrderService.updateOrder(order); // 支付给千猪 JSONObject object = QianZhuConfig.payMovieOrder(order.getOrderNo()); diff --git a/hai-service/src/main/java/com/hai/service/pay/impl/GoodsOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/pay/impl/GoodsOrderServiceImpl.java index ff633c51..771a8728 100644 --- a/hai-service/src/main/java/com/hai/service/pay/impl/GoodsOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/pay/impl/GoodsOrderServiceImpl.java @@ -15,9 +15,12 @@ import com.hai.dao.HighCouponCodeOtherMapper; import com.hai.dao.HighGasOrderPushMapper; import com.hai.dao.HighUserCouponMapper; import com.hai.entity.*; +import com.hai.enum_type.GoodsType; +import com.hai.enum_type.PayType; import com.hai.model.HighMerchantStoreModel; import com.hai.model.ResultProfitSharing; import com.hai.service.*; +import com.hai.service.pay.NotifyService; import com.hai.service.pay.PayService; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; @@ -78,6 +81,9 @@ public class GoodsOrderServiceImpl implements PayService { @Resource private HighCouponCodeOtherMapper highCouponCodeOtherMapper; + @Resource + private NotifyService notifyService; + @Override @Transactional(propagation= Propagation.REQUIRES_NEW) public void paySuccess(Map map, String payType) throws Exception { diff --git a/hai-service/src/main/java/com/hai/service/pay/impl/KfcOrderService.java b/hai-service/src/main/java/com/hai/service/pay/impl/KfcOrderService.java index 0e4eff56..c01e0ed2 100644 --- a/hai-service/src/main/java/com/hai/service/pay/impl/KfcOrderService.java +++ b/hai-service/src/main/java/com/hai/service/pay/impl/KfcOrderService.java @@ -7,7 +7,11 @@ import com.hai.dao.HighGasOrderPushMapper; import com.hai.entity.HighChildOrder; import com.hai.entity.HighGasOrderPush; import com.hai.entity.HighOrder; +import com.hai.entity.HighUser; +import com.hai.enum_type.GoodsType; +import com.hai.enum_type.PayType; import com.hai.service.HighOrderService; +import com.hai.service.HighUserService; import com.hai.service.pay.PayService; import org.springframework.stereotype.Service; @@ -25,6 +29,9 @@ public class KfcOrderService implements PayService { @Resource private HighGasOrderPushMapper highGasOrderPushMapper; + @Resource + private HighUserService highUserService; + @Override public void paySuccess(Map map, String payType) throws Exception { if (payType.equals("Alipay")) { @@ -44,6 +51,7 @@ public class KfcOrderService implements PayService { childOrder.setChildOrdeStatus(2); // 子订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 } highOrderService.updateOrder(order); + // 支付给千猪 JSONObject object = QianZhuConfig.payKfcOrder(order.getOrderNo()); diff --git a/hai-service/src/main/java/com/hai/service/pay/impl/MobileOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/pay/impl/MobileOrderServiceImpl.java index 57dd9c96..bfcc4a3a 100644 --- a/hai-service/src/main/java/com/hai/service/pay/impl/MobileOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/pay/impl/MobileOrderServiceImpl.java @@ -6,7 +6,11 @@ import com.hai.dao.HighGasOrderPushMapper; import com.hai.entity.HighChildOrder; import com.hai.entity.HighGasOrderPush; import com.hai.entity.HighOrder; +import com.hai.entity.HighUser; +import com.hai.enum_type.GoodsType; +import com.hai.enum_type.PayType; import com.hai.service.HighOrderService; +import com.hai.service.HighUserService; import com.hai.service.pay.PayService; import org.springframework.stereotype.Service; @@ -31,6 +35,9 @@ public class MobileOrderServiceImpl implements PayService { @Resource private HighGasOrderPushMapper highGasOrderPushMapper; + @Resource + private HighUserService highUserService; + @Override public void paySuccess(Map map, String payType) throws Exception { if (payType.equals("Alipay")) { diff --git a/hai-service/src/main/java/com/hai/service/pay/impl/NotifyServiceImpl.java b/hai-service/src/main/java/com/hai/service/pay/impl/NotifyServiceImpl.java index d8cd592b..fdb29d39 100644 --- a/hai-service/src/main/java/com/hai/service/pay/impl/NotifyServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/pay/impl/NotifyServiceImpl.java @@ -1,8 +1,14 @@ package com.hai.service.pay.impl; -import com.alibaba.fastjson.JSONObject; import com.hai.common.pay.entity.OrderType; import com.hai.common.utils.SpringContextUtil; +import com.hai.entity.HighChildOrder; +import com.hai.entity.HighOrder; +import com.hai.entity.HighUser; +import com.hai.enum_type.GoodsType; +import com.hai.enum_type.PayType; +import com.hai.service.HighOrderService; +import com.hai.service.HighUserService; import com.hai.service.pay.NotifyService; import com.hai.service.pay.PayRecordService; import com.hai.service.pay.PayService; @@ -22,6 +28,12 @@ public class NotifyServiceImpl implements NotifyService { @Resource private PayRecordService payRecordService; + @Resource + private HighOrderService highOrderService; + + @Resource + private HighUserService highUserService; + @Override @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) public String alipayNotify(Map params) throws Exception { @@ -116,4 +128,5 @@ public class NotifyServiceImpl implements NotifyService { return payService; } + } diff --git a/hai-service/src/main/resources/dev/commonConfig.properties b/hai-service/src/main/resources/dev/commonConfig.properties index cf850c43..52a935fe 100644 --- a/hai-service/src/main/resources/dev/commonConfig.properties +++ b/hai-service/src/main/resources/dev/commonConfig.properties @@ -25,6 +25,3 @@ TelApiKey=2d01f6b520254b1a80f6b167832cea18 TelApiSecret=d11ee9b41e014a039f030e53ae6f5295 TelMemberId=d13091df65d64aafbf0f35d2093157b7 -apiKey=wx8d49e2f83025229d -apiSecret=d8d6dcaef77d3b659258a01b5ddba5df -tokenUrl=https://api.weixin.qq.com