diff --git a/hai-bweb/src/main/java/com/bweb/controller/BsMsgController.java b/hai-bweb/src/main/java/com/bweb/controller/BsMsgController.java index 2dc9a62d..b4cc1734 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/BsMsgController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/BsMsgController.java @@ -91,6 +91,7 @@ public class BsMsgController { bsMsg.setOpId(userInfoModel.getSecUser().getId()); bsMsg.setOpName(userInfoModel.getSecUser().getUserName()); bsMsg.setMsgType(2); + bsMsg.setStatus(1); bsMsgService.insertMsg(bsMsg , null); return ResponseMsgUtil.success("新增成功"); diff --git a/hai-cweb/src/main/java/com/cweb/controller/CmsContentController.java b/hai-cweb/src/main/java/com/cweb/controller/CmsContentController.java index 34741740..04b3e5a4 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/CmsContentController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/CmsContentController.java @@ -6,6 +6,7 @@ import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.security.SessionObject; import com.hai.common.security.UserCenter; +import com.hai.common.utils.DateUtil; import com.hai.common.utils.ResponseMsgUtil; import com.hai.config.CmsContentConfig; import com.hai.entity.*; @@ -95,7 +96,7 @@ public class CmsContentController { object.put("sort" , cmsCategory.getSort()); object.put("code" , cmsCategory.getCode()); List cmsContent = cmsContentService.getListCmsContentByCategoryId(cmsCategory.getId() , companyId , platform); - if (cmsContent != null) { + if (cmsContent.size() > 0) { object.put("jumpType" , cmsContent.get(0).getJumpType()); object.put("jumpUrl" , cmsContent.get(0).getJumpUrl()); } @@ -106,16 +107,29 @@ public class CmsContentController { object.put("sort" , cmsCategory.getSort()); object.put("code" , cmsCategory.getCode()); List cmsContent = cmsContentService.getListCmsContentByCategoryId(cmsCategory.getId() , companyId , platform); - if (cmsContent != null) { + if (cmsContent.size() > 0) { object.put("jumpType" , cmsContent.get(0).getJumpType()); object.put("jumpUrl" , cmsContent.get(0).getJumpUrl()); } + Map mapUser = new HashMap<>(); + + mapUser.put("companyId" , companyId); + mapUser.put("whereCheck" , false); + mapUser.put("msgType" , 1); + mapUser.put("userId" , userInfoModel.getHighUser().getId()); + List listUser = bsMsgService.queryMsgByList(mapUser); + Map map = new HashMap<>(); map.put("companyId" , companyId); - map.put("whereCheck" , false); - map.put("userId" , userInfoModel.getHighUser().getId()); - object.put("childDate" , bsMsgService.queryMsgByList(map)); + map.put("msgType" , 2); + List list = bsMsgService.queryMsgByList(map); + list.addAll(listUser); + + for (BsMsg bsMsg : list) { + bsMsg.setTimeData( DateUtil.timeDifference(bsMsg.getCreateTime(), new Date() )); + } + object.put("childDate" , list); } objectList.add(object); } diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java b/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java index 81397a2a..057fd7f5 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java @@ -1 +1 @@ -package com.cweb.controller; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.cweb.config.SysConst; import com.hai.common.Base64Util; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.XmlUtil; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.security.SessionObject; import com.hai.common.security.UserCenter; import com.hai.common.utils.*; import com.hai.config.*; import com.hai.dao.HighGasOrderPushMapper; import com.hai.entity.*; import com.hai.enum_type.MerchantStoreSourceType; import com.hai.model.*; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.ssl.SSLContexts; import org.apache.http.util.EntityUtils; import org.bouncycastle.util.encoders.UrlBase64; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.util.IdGenerator; import org.springframework.web.bind.annotation.*; import sun.nio.cs.StreamEncoder; import javax.annotation.Resource; import javax.net.ssl.SSLContext; import javax.servlet.http.HttpServletRequest; import java.io.*; import java.math.BigDecimal; import java.nio.charset.StandardCharsets; import java.security.KeyStore; import java.util.*; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class HighTestController { private static Logger log = LoggerFactory.getLogger(HighTestController.class); @Resource private HighMerchantService highMerchantService; @Resource private HighMerchantStoreService highMerchantStoreService; @Resource private HighGasOilPriceService highGasOilPriceService; @Resource private HighOrderService highOrderService; @Autowired private UserCenter userCenter; @Resource private HighProfitSharingRecordService highProfitSharingRecordService; @Resource private BaiduVoiceService baiduVoiceService; @Resource private ShellGroupService shellGroupService; @Resource private HighGasService gasService; @Resource private BsMsgService bsMsgService; @RequestMapping(value = "/queryGasInfoByGasId", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据油站 id 拉取最新的油站数据") public ResponseData queryGasInfoByGasId(@RequestParam(name = "gasId", required = true) String gasId, HttpServletRequest request) { try { return ResponseMsgUtil.success(TuanYouConfig.queryGasInfoByGasId(gasId)); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardInfo() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/initTYMerchantStore", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "初始化加油站") public ResponseData initTYMerchantStore(@RequestParam(name = "merchantId", required = true) Long merchantId) throws Exception { HighMerchantModel merchant = highMerchantService.getMerchantById(merchantId); if (merchant == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到商户"); } JSONObject jsonObjectP = TuanYouConfig.queryGasInfoListByPage(1, 1000); JSONObject resultObjectP = jsonObjectP.getObject("result", JSONObject.class); for (int i = 1; i <= resultObjectP.getInteger("totalPageNum").intValue(); i++) { JSONObject jsonObject = TuanYouConfig.queryGasInfoListByPage(i, 1000); JSONObject resultObject = jsonObject.getObject("result", JSONObject.class); JSONArray jsonArray = resultObject.getJSONArray("gasInfoList"); HighMerchantStore highMerchantStore; HighGasOilPrice highGasOilPrice; for (Object gasObject : jsonArray) { JSONObject object = JSONObject.parseObject(JSONObject.toJSONString(gasObject)); HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreByKey(object.getString("gasId")); if (store != null) { store.setType(1); store.setMerchantId(merchant.getId()); store.setCompanyId(merchant.getCompanyId()); store.setStoreKey(object.getString("gasId")); store.setStoreName(object.getString("gasName")); store.setStoreLogo(object.getString("gasLogoSmall")); store.setRegionId(object.getLong("provinceCode")); store.setRegionName(object.getString("provinceName")); store.setAddress(object.getString("gasAddress")); store.setLongitude(object.getString("gasAddressLongitude")); store.setLatitude(object.getString("gasAddressLatitude")); store.setStatus(object.getInteger("gasStatus")); store.setOperatorId(0L); store.setOperatorName("系统创建"); store.setUpdateTime(new Date()); store.setExt1(object.getString("gasSourceId")); highMerchantStoreService.updateMerchantStoreDetail(store); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); // 查询门店油号 highGasOilPrice = highGasOilPriceService.getGasOilPriceByStoreAndOilNo(store.getId(), oilPriceObject.getInteger("oilNo")); if (highGasOilPrice == null) { highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); } else { highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); } highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } else { highMerchantStore = new HighMerchantStore(); highMerchantStore.setType(1); highMerchantStore.setMerchantId(merchant.getId()); highMerchantStore.setCompanyId(merchant.getCompanyId()); highMerchantStore.setStoreKey(object.getString("gasId")); highMerchantStore.setStoreName(object.getString("gasName")); highMerchantStore.setStoreLogo(object.getString("gasLogoSmall")); highMerchantStore.setRegionId(object.getLong("provinceCode")); highMerchantStore.setRegionName(object.getString("provinceName")); highMerchantStore.setAddress(object.getString("gasAddress")); highMerchantStore.setLongitude(object.getString("gasAddressLongitude")); highMerchantStore.setLatitude(object.getString("gasAddressLatitude")); highMerchantStore.setStatus(1); highMerchantStore.setOperatorId(0L); highMerchantStore.setOperatorName("系统创建"); highMerchantStore.setCreateTime(new Date()); highMerchantStore.setUpdateTime(new Date()); highMerchantStore.setExt1(object.getString("gasSourceId")); HighMerchantStoreModel merchantStoreModel = new HighMerchantStoreModel(); BeanUtils.copyProperties(highMerchantStore, merchantStoreModel); highMerchantStoreService.insertMerchantStore(merchantStoreModel); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(merchantStoreModel.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } } } return ResponseMsgUtil.success("初始化完成"); } @RequestMapping(value = "/detectTYMerchantStore", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "检测加油站") public ResponseData detectTYMerchantStore(@RequestParam(name = "merchantId", required = true) Long merchantId) throws Exception { HighMerchantModel merchant = highMerchantService.getMerchantById(merchantId); if (merchant == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到商户"); } Map param = new HashMap<>(); param.put("merchantId", merchant.getId()); List stores = highMerchantStoreService.getMerchantStoreList(param); for (HighMerchantStore store : stores) { JSONObject jsonObject = TuanYouConfig.queryGasInfoByGasId(store.getStoreKey()); if (jsonObject != null && jsonObject.getString("code").equals("200")) { JSONObject result = jsonObject.getJSONObject("result"); store.setStatus(result.getInteger("gasStatus")); } else { store.setStatus(0); } highMerchantStoreService.updateMerchantStoreDetail(store); } return ResponseMsgUtil.success("初始化完成"); } @RequestMapping(value = "/queryCompanyAccountInfo2JD", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询团油余额") public ResponseData queryCompanyAccountInfo2JD() { try { return ResponseMsgUtil.success(TuanYouConfig.queryCompanyAccountInfo2JD()); } catch (Exception e) { log.error("HighOrderController --> queryCompanyAccountInfo2JD() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryCompanyPriceDetail", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询团油余额") public ResponseData queryCompanyPriceDetail() { try { return ResponseMsgUtil.success(TuanYouConfig.queryCompanyPriceDetail("LW000115995", "92")); } catch (Exception e) { log.error("HighOrderController --> queryCompanyAccountInfo2JD() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/starbucksOrdersPay", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "星巴克支付") public ResponseData starbucksOrdersPay(@RequestParam(name = "orderNo", required = true) String orderNo) { try { return ResponseMsgUtil.success(QianZhuConfig.starbucksOrdersPay(orderNo)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/payKfcOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "肯德基支付") public ResponseData payKfcOrder(@RequestParam(name = "orderNo", required = true) String orderNo) { try { return ResponseMsgUtil.success(QianZhuConfig.payKfcOrder(orderNo)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/wxSplitAccount", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "微信分账") public ResponseData wxSplitAccount() { try { HighOrder orderNo = highOrderService.getOrderByOrderNo("HF2021101812025050304"); wxProfitsharing(orderNo.getOrderNo(), orderNo.getPaySerialNo(), orderNo.getPayRealPrice()); return ResponseMsgUtil.success("分账成功"); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryStaging", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "分期查询") public ResponseData queryStaging(@RequestParam(name = "oriOrgTrace", required = true) String oriOrgTrace, HttpServletRequest request) { try { String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0, 4) + CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4, CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) + DateUtil.format(new Date(), DateUtil.YMDHMS) + IDGenerator.nextId(6); return ResponseMsgUtil.success(UnionStagingPayConfig.queryStaging(orgTrace, oriOrgTrace, "", new Date(), request)); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } /* @RequestMapping(value = "/orderToRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "退款") public ResponseData orderToRefund(HttpServletRequest request) { try { OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund("4200001301202202035413938093", new BigDecimal("30.80"), new BigDecimal("16.90")); return ResponseMsgUtil.success(orderRefundModel); } catch (Exception e) { log.error("HighOrderController --> orderToRefund() error!", e); return ResponseMsgUtil.exception(e); } }*/ @RequestMapping(value = "/query", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "订单查询") public ResponseData query(@RequestParam(name = "oriOrgTrace", required = true) String oriOrgTrace, HttpServletRequest request) { try { String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0, 4) + CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4, CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) + DateUtil.format(new Date(), DateUtil.YMDHMS) + IDGenerator.nextId(6); return ResponseMsgUtil.success(UnionStagingPayConfig.query(orgTrace, oriOrgTrace, "", new Date(), request)); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } public void wxProfitsharing(String transaction_id, String out_order_no, BigDecimal amount) { try { Map param = new LinkedHashMap<>(); param.put("appid", "wx637bd6f7314daa46"); param.put("mch_id", "1289663601"); param.put("sub_mch_id", "1609882817"); // 个体户黎杨珍 param.put("transaction_id", transaction_id); param.put("out_order_no", out_order_no); param.put("nonce_str", WxUtils.makeNonStr()); // 分账金额 BigDecimal porofitSharingAmount = amount; List> receiversList = new ArrayList<>(); Map receiversMap = new LinkedHashMap<>(); receiversMap.put("type", "MERCHANT_ID"); receiversMap.put("account", "1603942866"); receiversMap.put("amount", porofitSharingAmount.multiply(new BigDecimal("100")).intValue()); receiversMap.put("description", "分给商户【惠昕石化】"); receiversList.add(receiversMap); param.put("receivers", JSONObject.toJSONString(receiversList)); String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5", WXPayConstants.SignType.HMACSHA256); param.put("sign", signStr); String resultXmL = this.doRefundRequest(param.get("mch_id"), null, WxUtils.mapToXml(param)); // 请求分账返回的结果 ResultProfitSharing resultProfitSharing = XmlUtil.getObjectFromXML(resultXmL, ResultProfitSharing.class); if (!resultProfitSharing.getResult_code().equals("FAIL")) { HighProfitSharingRecord sharingRecord = new HighProfitSharingRecord(); sharingRecord.setOutOrderNo(resultProfitSharing.getOut_order_no()); sharingRecord.setTransactionId(resultProfitSharing.getTransaction_id()); sharingRecord.setOrderId(resultProfitSharing.getOrder_id()); sharingRecord.setStatus(resultProfitSharing.getResult_code()); sharingRecord.setPrice(amount); sharingRecord.setCreateTime(new Date()); sharingRecord.setContent(resultXmL); highProfitSharingRecordService.insert(sharingRecord); } } catch (Exception e) { log.error("CmsContentController --> getCorporateAdvertising() error!", e); } } public CloseableHttpClient readCertificate(String mchId) throws Exception { /** * 注意PKCS12证书 是从微信商户平台-》账户设置-》 API安全 中下载的 */ KeyStore keyStore = KeyStore.getInstance("PKCS12"); //P12文件目录 证书路径,这里需要你自己修改,linux下还是windows下的根路径 FileInputStream instream = new FileInputStream("/home/project/wx_cert/1289663601_apiclient_cert.p12"); // FileInputStream instream = new FileInputStream("G:\\hurui-project/hai-parent/hai-service/src/main/java/privatekey/1289663601_apiclient_cert.p12"); try { keyStore.load(instream, "1289663601".toCharArray());//这里写密码..默认是你的MCHID } finally { instream.close(); } SSLContext sslcontext = SSLContexts.custom().loadKeyMaterial(keyStore, "1289663601".toCharArray()).build();//这里也是写密码的 SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext, SSLConnectionSocketFactory.getDefaultHostnameVerifier()); // Allow TLSv1 protocol only return HttpClients.custom().setSSLSocketFactory(sslsf).build(); } public String doRefundRequest(String mchId, String url, String data) throws Exception { //小程序退款需要调用双向证书的认证 CloseableHttpClient httpClient = readCertificate(mchId); try { HttpPost httpost = new HttpPost("https://api.mch.weixin.qq.com/secapi/pay/profitsharing"); // 设置响应头信息 httpost.addHeader("Connection", "keep-alive"); httpost.addHeader("Accept", "*/*"); httpost.addHeader("Content-Type", "text/xml"); httpost.addHeader("Host", "api.mch.weixin.qq.com"); httpost.addHeader("X-Requested-With", "XMLHttpRequest"); httpost.addHeader("Cache-Control", "max-age=0"); httpost.addHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) "); httpost.setEntity(new StringEntity(data, "UTF-8")); CloseableHttpResponse response = httpClient.execute(httpost); try { HttpEntity entity = response.getEntity(); String jsonStr = EntityUtils.toString(response.getEntity(), "UTF-8"); EntityUtils.consume(entity); return jsonStr; } finally { response.close(); } } catch (Exception e) { throw new RuntimeException(e); } finally { httpClient.close(); } } @RequestMapping(value = "/websocket", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "websocket") public ResponseData websocket(@RequestParam(name = "orderNo", required = true) String orderNo ) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); if (order.getHighChildOrderList().get(0).getGoodsType().equals(3)) { Map pushMsg = new HashMap<>(); pushMsg.put("userId", order.getHighChildOrderList().get(0).getGoodsId()); Map msgContent = new HashMap<>(); msgContent.put("order", highOrderService.getGasOrderDetail(order.getOrderNo())); msgContent.put("voice", baiduVoiceService.text2audio(order.getHighChildOrderList().get(0).getGoodsName() + "加油站,收款:" + order.getTotalPrice())); pushMsg.put("message", JSONObject.toJSONString(msgContent)); HttpsUtils.doPost("http://127.0.0.1:9901/msg/test/websocket", pushMsg, new HashMap<>()); } return ResponseMsgUtil.success("null"); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/gasStationQueryDetail", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "gasStationQueryDetail") public ResponseData gasStationQueryDetail() { try { return ResponseMsgUtil.success(shellGroupService.gasStationQueryDetail("0001")); } catch (Exception e) { log.error("HighOrderController --> gasStationQueryDetail() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/gasPageQueryAllStation", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "gasPageQueryAllStation") public ResponseData gasPageQueryAllStation() { try { gasService.getJiaHaoYouAllStation(); return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighOrderController --> gasPageQueryAllStation() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/gasSyncRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "gasSyncRefund") public ResponseData gasSyncRefund() { try { shellGroupService.gasSyncRefund(new Date(1659511289000L), "1659511289357"); return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighOrderController --> gasSyncRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getJzStationListPage", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "getJzStationListPage") public ResponseData getJzStationListPage() { try { gasService.getJinZhuAllStation(); return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighOrderController --> gasSyncRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/insertV2", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "支付") public ResponseData insertV2() { try { String orderNo = "HF2022080818504922206"; JSONObject object = QianZhuConfig.insertV2("PLM100024", orderNo, "15585850137"); object.put("orderNo", orderNo); return ResponseMsgUtil.success(object); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } /* @RequestMapping(value = "/QueryV2", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询订单号") public ResponseData QueryV2(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); JSONObject orderObject = QianZhuConfig.QueryV2(orderNo); if (orderObject != null && orderObject.getLong("Code") == 999) { // 订单失败 // 订单状态 1:订单正在处理中 2;订单成功: 3 订单失败 if (orderObject.getJSONObject("Data").getInteger("OrderState") == 3) { // 订单失败 if (order.getOrderStatus() == 2) { highOrderService.thirdOrderToRefund(order.getId()); } else { highOrderService.thirdCancelOrder(order.getId()); } } // 订单状态 1:订单正在处理中 2;订单成功: 3 订单失败 if (orderObject.getJSONObject("Data").getInteger("OrderState") == 2) { for (HighChildOrder childOrder : order.getHighChildOrderList()) { childOrder.setChildOrdeStatus(3); } order.setOrderStatus(3); order.setFinishTime(new Date()); highOrderService.updateOrder(order); } } return ResponseMsgUtil.success(QianZhuConfig.QueryV2(orderNo)); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } */ @RequestMapping(value = "/getKfcOrderByOrderNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询肯德基订单") public ResponseData getKfcOrderByOrderNo(@RequestParam(name = "orderNo", required = true) String orderNo) { try { return ResponseMsgUtil.success(QianZhuConfig.getKfcOrderByOrderNo(orderNo)); } catch (Exception e) { log.error("HighOrderController -> addOrder() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/starbucksOrderByOrderNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询星巴克订单") public ResponseData starbucksOrderByOrderNo(@RequestParam(name = "orderNo", required = true) String orderNo) { try { return ResponseMsgUtil.success(QianZhuConfig.starbucksOrderByOrderNo(orderNo)); } catch (Exception e) { log.error("HighOrderController -> addOrder() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/thirdOrderToRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "第三方退款") public ResponseData thirdOrderToRefund(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); highOrderService.thirdOrderToRefund(order.getId()); return ResponseMsgUtil.success(""); } catch (Exception e) { log.error("HighOrderController -> addOrder() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/rechargeOrderByCy", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "城宇话费充值 ") public ResponseData rechargeOrderByCy() { try { JSONObject object = new JSONObject(); object.put("mobile" , "18090580471"); object.put("productId" , 172); object.put("agentOrderId" , "RCG" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5)); return ResponseMsgUtil.success(RechargeConfig.rechargeOrderByCy(object)); } catch (Exception e) { log.error("HighOrderController -> addOrder() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryRechargeByCy", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "城宇查询订单") public ResponseData queryRechargeByCy(@RequestParam(name = "orderNo", required = true) String orderNo) { try { JSONObject object = new JSONObject(); object.put("orderNo" , orderNo); return ResponseMsgUtil.success(RechargeConfig.queryRechargeByCy(object)); } catch (Exception e) { log.error("HighOrderController -> addOrder() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/postIp", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "请求ip地址") public ResponseData postIp(HttpServletRequest request) { try { request.getHeader("regionId"); if (request.getHeader("regionId") != null && request.getHeader("regionId").length() != 0) { System.out.println("111"); } return ResponseMsgUtil.success(HttpsUtils.doPost("https://hsgcs.dctpay.com/brest/openApi/test")); } catch (Exception e) { log.error("HighOrderController -> addOrder() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/testMsg", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "测试站内信") public ResponseData testMsg(HttpServletRequest request) { try { // 用户 SessionObject sessionObject = userCenter.getSessionObject(request); HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); BsMsg bsMsg = new BsMsg(); bsMsg.setCompanyId(22L); bsMsg.setOpName("系统生成"); bsMsg.setMsgType(1); bsMsg.setType(1); bsMsg.setJumpType(1); bsMsg.setTitle("话费订单跳转"); bsMsg.setContent("123213"); bsMsgService.insertMsg(bsMsg , userInfoModel.getHighUser()); return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighOrderController -> addOrder() error!", e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file +package com.cweb.controller; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.cweb.config.SysConst; import com.hai.common.Base64Util; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.XmlUtil; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.security.SessionObject; import com.hai.common.security.UserCenter; import com.hai.common.utils.*; import com.hai.config.*; import com.hai.dao.HighGasOrderPushMapper; import com.hai.entity.*; import com.hai.enum_type.MerchantStoreSourceType; import com.hai.model.*; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.ssl.SSLContexts; import org.apache.http.util.EntityUtils; import org.bouncycastle.util.encoders.UrlBase64; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.util.IdGenerator; import org.springframework.web.bind.annotation.*; import sun.nio.cs.StreamEncoder; import javax.annotation.Resource; import javax.net.ssl.SSLContext; import javax.servlet.http.HttpServletRequest; import java.io.*; import java.math.BigDecimal; import java.nio.charset.StandardCharsets; import java.security.KeyStore; import java.util.*; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/test") @Api(value = "订单接口") public class HighTestController { private static Logger log = LoggerFactory.getLogger(HighTestController.class); @Resource private HighMerchantService highMerchantService; @Resource private HighMerchantStoreService highMerchantStoreService; @Resource private HighGasOilPriceService highGasOilPriceService; @Resource private HighOrderService highOrderService; @Autowired private UserCenter userCenter; @Resource private HighProfitSharingRecordService highProfitSharingRecordService; @Resource private BaiduVoiceService baiduVoiceService; @Resource private ShellGroupService shellGroupService; @Resource private HighGasService gasService; @Resource private BsMsgService bsMsgService; @RequestMapping(value = "/queryGasInfoByGasId", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据油站 id 拉取最新的油站数据") public ResponseData queryGasInfoByGasId(@RequestParam(name = "gasId", required = true) String gasId, HttpServletRequest request) { try { return ResponseMsgUtil.success(TuanYouConfig.queryGasInfoByGasId(gasId)); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardInfo() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/initTYMerchantStore", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "初始化加油站") public ResponseData initTYMerchantStore(@RequestParam(name = "merchantId", required = true) Long merchantId) throws Exception { HighMerchantModel merchant = highMerchantService.getMerchantById(merchantId); if (merchant == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到商户"); } JSONObject jsonObjectP = TuanYouConfig.queryGasInfoListByPage(1, 1000); JSONObject resultObjectP = jsonObjectP.getObject("result", JSONObject.class); for (int i = 1; i <= resultObjectP.getInteger("totalPageNum").intValue(); i++) { JSONObject jsonObject = TuanYouConfig.queryGasInfoListByPage(i, 1000); JSONObject resultObject = jsonObject.getObject("result", JSONObject.class); JSONArray jsonArray = resultObject.getJSONArray("gasInfoList"); HighMerchantStore highMerchantStore; HighGasOilPrice highGasOilPrice; for (Object gasObject : jsonArray) { JSONObject object = JSONObject.parseObject(JSONObject.toJSONString(gasObject)); HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreByKey(object.getString("gasId")); if (store != null) { store.setType(1); store.setMerchantId(merchant.getId()); store.setCompanyId(merchant.getCompanyId()); store.setStoreKey(object.getString("gasId")); store.setStoreName(object.getString("gasName")); store.setStoreLogo(object.getString("gasLogoSmall")); store.setRegionId(object.getLong("provinceCode")); store.setRegionName(object.getString("provinceName")); store.setAddress(object.getString("gasAddress")); store.setLongitude(object.getString("gasAddressLongitude")); store.setLatitude(object.getString("gasAddressLatitude")); store.setStatus(object.getInteger("gasStatus")); store.setOperatorId(0L); store.setOperatorName("系统创建"); store.setUpdateTime(new Date()); store.setExt1(object.getString("gasSourceId")); highMerchantStoreService.updateMerchantStoreDetail(store); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); // 查询门店油号 highGasOilPrice = highGasOilPriceService.getGasOilPriceByStoreAndOilNo(store.getId(), oilPriceObject.getInteger("oilNo")); if (highGasOilPrice == null) { highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); } else { highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); } highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } else { highMerchantStore = new HighMerchantStore(); highMerchantStore.setType(1); highMerchantStore.setMerchantId(merchant.getId()); highMerchantStore.setCompanyId(merchant.getCompanyId()); highMerchantStore.setStoreKey(object.getString("gasId")); highMerchantStore.setStoreName(object.getString("gasName")); highMerchantStore.setStoreLogo(object.getString("gasLogoSmall")); highMerchantStore.setRegionId(object.getLong("provinceCode")); highMerchantStore.setRegionName(object.getString("provinceName")); highMerchantStore.setAddress(object.getString("gasAddress")); highMerchantStore.setLongitude(object.getString("gasAddressLongitude")); highMerchantStore.setLatitude(object.getString("gasAddressLatitude")); highMerchantStore.setStatus(1); highMerchantStore.setOperatorId(0L); highMerchantStore.setOperatorName("系统创建"); highMerchantStore.setCreateTime(new Date()); highMerchantStore.setUpdateTime(new Date()); highMerchantStore.setExt1(object.getString("gasSourceId")); HighMerchantStoreModel merchantStoreModel = new HighMerchantStoreModel(); BeanUtils.copyProperties(highMerchantStore, merchantStoreModel); highMerchantStoreService.insertMerchantStore(merchantStoreModel); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(merchantStoreModel.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } } } return ResponseMsgUtil.success("初始化完成"); } @RequestMapping(value = "/detectTYMerchantStore", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "检测加油站") public ResponseData detectTYMerchantStore(@RequestParam(name = "merchantId", required = true) Long merchantId) throws Exception { HighMerchantModel merchant = highMerchantService.getMerchantById(merchantId); if (merchant == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到商户"); } Map param = new HashMap<>(); param.put("merchantId", merchant.getId()); List stores = highMerchantStoreService.getMerchantStoreList(param); for (HighMerchantStore store : stores) { JSONObject jsonObject = TuanYouConfig.queryGasInfoByGasId(store.getStoreKey()); if (jsonObject != null && jsonObject.getString("code").equals("200")) { JSONObject result = jsonObject.getJSONObject("result"); store.setStatus(result.getInteger("gasStatus")); } else { store.setStatus(0); } highMerchantStoreService.updateMerchantStoreDetail(store); } return ResponseMsgUtil.success("初始化完成"); } @RequestMapping(value = "/queryCompanyAccountInfo2JD", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询团油余额") public ResponseData queryCompanyAccountInfo2JD() { try { return ResponseMsgUtil.success(TuanYouConfig.queryCompanyAccountInfo2JD()); } catch (Exception e) { log.error("HighOrderController --> queryCompanyAccountInfo2JD() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryCompanyPriceDetail", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询团油余额") public ResponseData queryCompanyPriceDetail() { try { return ResponseMsgUtil.success(TuanYouConfig.queryCompanyPriceDetail("LW000115995", "92")); } catch (Exception e) { log.error("HighOrderController --> queryCompanyAccountInfo2JD() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/starbucksOrdersPay", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "星巴克支付") public ResponseData starbucksOrdersPay(@RequestParam(name = "orderNo", required = true) String orderNo) { try { return ResponseMsgUtil.success(QianZhuConfig.starbucksOrdersPay(orderNo)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/payKfcOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "肯德基支付") public ResponseData payKfcOrder(@RequestParam(name = "orderNo", required = true) String orderNo) { try { return ResponseMsgUtil.success(QianZhuConfig.payKfcOrder(orderNo)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/wxSplitAccount", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "微信分账") public ResponseData wxSplitAccount() { try { HighOrder orderNo = highOrderService.getOrderByOrderNo("HF2021101812025050304"); wxProfitsharing(orderNo.getOrderNo(), orderNo.getPaySerialNo(), orderNo.getPayRealPrice()); return ResponseMsgUtil.success("分账成功"); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryStaging", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "分期查询") public ResponseData queryStaging(@RequestParam(name = "oriOrgTrace", required = true) String oriOrgTrace, HttpServletRequest request) { try { String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0, 4) + CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4, CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) + DateUtil.format(new Date(), DateUtil.YMDHMS) + IDGenerator.nextId(6); return ResponseMsgUtil.success(UnionStagingPayConfig.queryStaging(orgTrace, oriOrgTrace, "", new Date(), request)); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } /* @RequestMapping(value = "/orderToRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "退款") public ResponseData orderToRefund(HttpServletRequest request) { try { OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund("4200001301202202035413938093", new BigDecimal("30.80"), new BigDecimal("16.90")); return ResponseMsgUtil.success(orderRefundModel); } catch (Exception e) { log.error("HighOrderController --> orderToRefund() error!", e); return ResponseMsgUtil.exception(e); } }*/ @RequestMapping(value = "/query", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "订单查询") public ResponseData query(@RequestParam(name = "oriOrgTrace", required = true) String oriOrgTrace, HttpServletRequest request) { try { String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0, 4) + CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4, CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) + DateUtil.format(new Date(), DateUtil.YMDHMS) + IDGenerator.nextId(6); return ResponseMsgUtil.success(UnionStagingPayConfig.query(orgTrace, oriOrgTrace, "", new Date(), request)); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } public void wxProfitsharing(String transaction_id, String out_order_no, BigDecimal amount) { try { Map param = new LinkedHashMap<>(); param.put("appid", "wx637bd6f7314daa46"); param.put("mch_id", "1289663601"); param.put("sub_mch_id", "1609882817"); // 个体户黎杨珍 param.put("transaction_id", transaction_id); param.put("out_order_no", out_order_no); param.put("nonce_str", WxUtils.makeNonStr()); // 分账金额 BigDecimal porofitSharingAmount = amount; List> receiversList = new ArrayList<>(); Map receiversMap = new LinkedHashMap<>(); receiversMap.put("type", "MERCHANT_ID"); receiversMap.put("account", "1603942866"); receiversMap.put("amount", porofitSharingAmount.multiply(new BigDecimal("100")).intValue()); receiversMap.put("description", "分给商户【惠昕石化】"); receiversList.add(receiversMap); param.put("receivers", JSONObject.toJSONString(receiversList)); String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5", WXPayConstants.SignType.HMACSHA256); param.put("sign", signStr); String resultXmL = this.doRefundRequest(param.get("mch_id"), null, WxUtils.mapToXml(param)); // 请求分账返回的结果 ResultProfitSharing resultProfitSharing = XmlUtil.getObjectFromXML(resultXmL, ResultProfitSharing.class); if (!resultProfitSharing.getResult_code().equals("FAIL")) { HighProfitSharingRecord sharingRecord = new HighProfitSharingRecord(); sharingRecord.setOutOrderNo(resultProfitSharing.getOut_order_no()); sharingRecord.setTransactionId(resultProfitSharing.getTransaction_id()); sharingRecord.setOrderId(resultProfitSharing.getOrder_id()); sharingRecord.setStatus(resultProfitSharing.getResult_code()); sharingRecord.setPrice(amount); sharingRecord.setCreateTime(new Date()); sharingRecord.setContent(resultXmL); highProfitSharingRecordService.insert(sharingRecord); } } catch (Exception e) { log.error("CmsContentController --> getCorporateAdvertising() error!", e); } } public CloseableHttpClient readCertificate(String mchId) throws Exception { /** * 注意PKCS12证书 是从微信商户平台-》账户设置-》 API安全 中下载的 */ KeyStore keyStore = KeyStore.getInstance("PKCS12"); //P12文件目录 证书路径,这里需要你自己修改,linux下还是windows下的根路径 FileInputStream instream = new FileInputStream("/home/project/wx_cert/1289663601_apiclient_cert.p12"); // FileInputStream instream = new FileInputStream("G:\\hurui-project/hai-parent/hai-service/src/main/java/privatekey/1289663601_apiclient_cert.p12"); try { keyStore.load(instream, "1289663601".toCharArray());//这里写密码..默认是你的MCHID } finally { instream.close(); } SSLContext sslcontext = SSLContexts.custom().loadKeyMaterial(keyStore, "1289663601".toCharArray()).build();//这里也是写密码的 SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext, SSLConnectionSocketFactory.getDefaultHostnameVerifier()); // Allow TLSv1 protocol only return HttpClients.custom().setSSLSocketFactory(sslsf).build(); } public String doRefundRequest(String mchId, String url, String data) throws Exception { //小程序退款需要调用双向证书的认证 CloseableHttpClient httpClient = readCertificate(mchId); try { HttpPost httpost = new HttpPost("https://api.mch.weixin.qq.com/secapi/pay/profitsharing"); // 设置响应头信息 httpost.addHeader("Connection", "keep-alive"); httpost.addHeader("Accept", "*/*"); httpost.addHeader("Content-Type", "text/xml"); httpost.addHeader("Host", "api.mch.weixin.qq.com"); httpost.addHeader("X-Requested-With", "XMLHttpRequest"); httpost.addHeader("Cache-Control", "max-age=0"); httpost.addHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) "); httpost.setEntity(new StringEntity(data, "UTF-8")); CloseableHttpResponse response = httpClient.execute(httpost); try { HttpEntity entity = response.getEntity(); String jsonStr = EntityUtils.toString(response.getEntity(), "UTF-8"); EntityUtils.consume(entity); return jsonStr; } finally { response.close(); } } catch (Exception e) { throw new RuntimeException(e); } finally { httpClient.close(); } } @RequestMapping(value = "/websocket", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "websocket") public ResponseData websocket(@RequestParam(name = "orderNo", required = true) String orderNo ) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); if (order.getHighChildOrderList().get(0).getGoodsType().equals(3)) { Map pushMsg = new HashMap<>(); pushMsg.put("userId", order.getHighChildOrderList().get(0).getGoodsId()); Map msgContent = new HashMap<>(); msgContent.put("order", highOrderService.getGasOrderDetail(order.getOrderNo())); msgContent.put("voice", baiduVoiceService.text2audio(order.getHighChildOrderList().get(0).getGoodsName() + "加油站,收款:" + order.getTotalPrice())); pushMsg.put("message", JSONObject.toJSONString(msgContent)); HttpsUtils.doPost("http://127.0.0.1:9901/msg/test/websocket", pushMsg, new HashMap<>()); } return ResponseMsgUtil.success("null"); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/gasStationQueryDetail", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "gasStationQueryDetail") public ResponseData gasStationQueryDetail() { try { return ResponseMsgUtil.success(shellGroupService.gasStationQueryDetail("0001")); } catch (Exception e) { log.error("HighOrderController --> gasStationQueryDetail() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/gasPageQueryAllStation", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "gasPageQueryAllStation") public ResponseData gasPageQueryAllStation() { try { gasService.getJiaHaoYouAllStation(); return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighOrderController --> gasPageQueryAllStation() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/gasSyncRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "gasSyncRefund") public ResponseData gasSyncRefund() { try { shellGroupService.gasSyncRefund(new Date(1659511289000L), "1659511289357"); return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighOrderController --> gasSyncRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getJzStationListPage", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "getJzStationListPage") public ResponseData getJzStationListPage() { try { gasService.getJinZhuAllStation(); return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighOrderController --> gasSyncRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/insertV2", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "支付") public ResponseData insertV2() { try { String orderNo = "HF2022080818504922206"; JSONObject object = QianZhuConfig.insertV2("PLM100024", orderNo, "15585850137"); object.put("orderNo", orderNo); return ResponseMsgUtil.success(object); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } /* @RequestMapping(value = "/QueryV2", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询订单号") public ResponseData QueryV2(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); JSONObject orderObject = QianZhuConfig.QueryV2(orderNo); if (orderObject != null && orderObject.getLong("Code") == 999) { // 订单失败 // 订单状态 1:订单正在处理中 2;订单成功: 3 订单失败 if (orderObject.getJSONObject("Data").getInteger("OrderState") == 3) { // 订单失败 if (order.getOrderStatus() == 2) { highOrderService.thirdOrderToRefund(order.getId()); } else { highOrderService.thirdCancelOrder(order.getId()); } } // 订单状态 1:订单正在处理中 2;订单成功: 3 订单失败 if (orderObject.getJSONObject("Data").getInteger("OrderState") == 2) { for (HighChildOrder childOrder : order.getHighChildOrderList()) { childOrder.setChildOrdeStatus(3); } order.setOrderStatus(3); order.setFinishTime(new Date()); highOrderService.updateOrder(order); } } return ResponseMsgUtil.success(QianZhuConfig.QueryV2(orderNo)); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } */ @RequestMapping(value = "/getKfcOrderByOrderNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询肯德基订单") public ResponseData getKfcOrderByOrderNo(@RequestParam(name = "orderNo", required = true) String orderNo) { try { return ResponseMsgUtil.success(QianZhuConfig.getKfcOrderByOrderNo(orderNo)); } catch (Exception e) { log.error("HighOrderController -> addOrder() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/starbucksOrderByOrderNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询星巴克订单") public ResponseData starbucksOrderByOrderNo(@RequestParam(name = "orderNo", required = true) String orderNo) { try { return ResponseMsgUtil.success(QianZhuConfig.starbucksOrderByOrderNo(orderNo)); } catch (Exception e) { log.error("HighOrderController -> addOrder() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/thirdOrderToRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "第三方退款") public ResponseData thirdOrderToRefund(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); highOrderService.thirdOrderToRefund(order.getId()); return ResponseMsgUtil.success(""); } catch (Exception e) { log.error("HighOrderController -> addOrder() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/rechargeOrderByCy", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "城宇话费充值 ") public ResponseData rechargeOrderByCy() { try { JSONObject object = new JSONObject(); object.put("mobile" , "18090580471"); object.put("productId" , 172); object.put("agentOrderId" , "RCG" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5)); return ResponseMsgUtil.success(RechargeConfig.rechargeOrderByCy(object)); } catch (Exception e) { log.error("HighOrderController -> addOrder() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryRechargeByCy", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "城宇查询订单") public ResponseData queryRechargeByCy(@RequestParam(name = "orderNo", required = true) String orderNo) { try { JSONObject object = new JSONObject(); object.put("orderNo" , orderNo); return ResponseMsgUtil.success(RechargeConfig.queryRechargeByCy(object)); } catch (Exception e) { log.error("HighOrderController -> addOrder() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/postIp", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "请求ip地址") public ResponseData postIp(HttpServletRequest request) { try { request.getHeader("regionId"); if (request.getHeader("regionId") != null && request.getHeader("regionId").length() != 0) { System.out.println("111"); } return ResponseMsgUtil.success(HttpsUtils.doPost("https://hsgcs.dctpay.com/brest/openApi/test")); } catch (Exception e) { log.error("HighOrderController -> addOrder() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/testMsg", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "测试站内信") public ResponseData testMsg(HttpServletRequest request) { try { bsMsgService.pushUserMsg(71465L , "支付成功"); return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighOrderController -> addOrder() error!", e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file diff --git a/hai-order/src/main/java/com/web/controller/business/OrderThirdPartyController.java b/hai-order/src/main/java/com/web/controller/business/OrderThirdPartyController.java index 1c8fa309..b048a71a 100644 --- a/hai-order/src/main/java/com/web/controller/business/OrderThirdPartyController.java +++ b/hai-order/src/main/java/com/web/controller/business/OrderThirdPartyController.java @@ -200,7 +200,7 @@ public class OrderThirdPartyController { } EasyExcel.write(fileUrl+pathName) - .head(ExportGasOrderModel.class) + .head(OrderThirdPartyModel.class) .sheet("交易订单") .doWrite(dataList); return ResponseMsgUtil.success(pathName); diff --git a/hai-service/src/main/java/com/hai/common/utils/DateUtil.java b/hai-service/src/main/java/com/hai/common/utils/DateUtil.java index 09d9f1a4..13bd107e 100644 --- a/hai-service/src/main/java/com/hai/common/utils/DateUtil.java +++ b/hai-service/src/main/java/com/hai/common/utils/DateUtil.java @@ -22,6 +22,7 @@ public class DateUtil { public static final String Y_M_D = "yyyy-MM-dd"; public static final String Y_M_D_HM = "yyyy-MM-dd HH:mm"; public static final String Y_M_D_HMS = "yyyy-MM-dd HH:mm:ss"; + public static final String Y_M_D_HMS_C = "yyyy年MM月dd日 HH:mm:ss"; public static final String YMD = "yyyyMMdd"; public static final String YMDHM = "yyyyMMddHHmm"; public static final String YMDHMS = "yyyyMMddHHmmss"; @@ -785,4 +786,36 @@ public class DateUtil { System.out.println(getSecondDiff(new Date(), date)); } + /** + * @Author Sum1Dream + * @Name timeDifference + * @Description // 计算时间差 + * @Date 16:22 2022/11/1 + * @Param [finishTime, end] + * @Return java.lang.String + */ + public static String timeDifference(Date finishTime , Date end) { + + long timeLag = end.getTime() - finishTime.getTime(); + //天 + long day=timeLag/(24*60*60*1000); + //小时 + long hour=(timeLag/(60*60*1000)); + //分钟 + long minute=((timeLag/(60*1000))); + //秒,顺便说一下,1秒 = 1000毫秒 + long s=(timeLag/1000); + + if (day >= 1) { + return day + "天前"; + } + if (hour >= 1) { + return hour + "小时前"; + } + if (minute >= 1) { + return minute + "分钟前"; + } + return s + "秒前"; + } + } diff --git a/hai-service/src/main/java/com/hai/dao/BsMsgUserMapperExt.java b/hai-service/src/main/java/com/hai/dao/BsMsgUserMapperExt.java index 9a27a561..0524370a 100644 --- a/hai-service/src/main/java/com/hai/dao/BsMsgUserMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/BsMsgUserMapperExt.java @@ -21,10 +21,11 @@ public interface BsMsgUserMapperExt { "where status = 2 " + "and company_id = #{param.companyId} " + " and user_id = #{param.userId} ", + " and user_id is null ", " and type = #{param.type} ", " and msg_type = #{param.msgType} ", " and where_check = #{param.whereCheck} ", - "order by create_time desc; " + + "order by create_time desc limit 5; " + " "}) @Results({ @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), diff --git a/hai-service/src/main/java/com/hai/entity/BsMsg.java b/hai-service/src/main/java/com/hai/entity/BsMsg.java index 9baeb059..d5c621ee 100644 --- a/hai-service/src/main/java/com/hai/entity/BsMsg.java +++ b/hai-service/src/main/java/com/hai/entity/BsMsg.java @@ -88,6 +88,9 @@ public class BsMsg implements Serializable { */ private Integer status; + // 时间内容 + private String timeData; + /** * ext_1 */ @@ -103,6 +106,14 @@ public class BsMsg implements Serializable { */ private String ext3; + public String getTimeData() { + return timeData; + } + + public void setTimeData(String timeData) { + this.timeData = timeData; + } + private static final long serialVersionUID = 1L; public Long getId() { @@ -334,4 +345,4 @@ public class BsMsg implements Serializable { sb.append("]"); return sb.toString(); } -} \ No newline at end of file +} diff --git a/hai-service/src/main/java/com/hai/order/service/OrderCreateHandleService.java b/hai-service/src/main/java/com/hai/order/service/OrderCreateHandleService.java index c410698a..81db5adb 100644 --- a/hai-service/src/main/java/com/hai/order/service/OrderCreateHandleService.java +++ b/hai-service/src/main/java/com/hai/order/service/OrderCreateHandleService.java @@ -74,6 +74,6 @@ public interface OrderCreateHandleService { * @Param [object] * @Return com.hai.entity.HighChildOrder */ - HighChildOrder prepaidRecharge(JSONObject object) throws Exception; + HighChildOrder mobileRecharge(HighOrder order , JSONObject object) throws Exception; } diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java index ba6927dc..e0a894c3 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java @@ -11,13 +11,12 @@ import com.hai.common.security.UserCenter; import com.hai.common.utils.DateUtil; import com.hai.common.utils.IDGenerator; import com.hai.config.*; +import com.hai.dao.OutRechargeOrderMapper; import com.hai.entity.*; -import com.hai.enum_type.GasClassGroupTaskStatus; -import com.hai.enum_type.JinZhuJiaYouOilNo; -import com.hai.enum_type.MerAccountMarketingType; -import com.hai.enum_type.MerchantStoreSourceType; +import com.hai.enum_type.*; import com.hai.model.GasPayPriceModel; import com.hai.model.HighMerchantModel; +import com.hai.model.OutRechargePriceModel; import com.hai.model.ResponseData; import com.hai.order.model.CreateOrderChildModel; import com.hai.order.model.CreateOrderModel; @@ -61,6 +60,12 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService { @Resource private OrderService orderService; + @Resource + private BsConfigService bsConfigService; + + @Resource + private SecConfigService secConfigService; + @Resource private HighUserService userService; @@ -79,12 +84,18 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService { @Resource private HighDiscountCouponRelService discountCouponRelService; + @Resource + private OutRechargeOrderMapper outRechargeOrderMapper; + @Resource private HighCouponHandselService highCouponHandselService; @Resource private HighMerchantAccountMarketingService merchantAccountMarketingService; + @Resource + private OutRechargePriceService outRechargePriceService; + @Resource private HighGasOrderService gasOrderService; @@ -809,7 +820,62 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService { } @Override - public HighChildOrder prepaidRecharge(JSONObject object) throws Exception { - return null; + public HighChildOrder mobileRecharge(HighOrder order , JSONObject object) throws Exception { + // 初始化话费订单对象 + OutRechargeOrder outRechargeOrder = new OutRechargeOrder(); + // 查询用户信息 + HighUser user = highUserService.findByUserId(object.getLong("userId")); + // 产品id + Long goodsId = object.getLong("goodsId"); + // 充值内容 + String rechargeContent = object.getString("rechargeContent"); + + // 查询产品详情 + OutRechargePriceModel outRechargePrice = outRechargePriceService.findById(goodsId, null); + + + // 判断充值系统是否关闭 + if (!secConfigService.isConfig("RECHARGE", "1")) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.RECHARGE_CLOSE, ""); + } + + // 生成交易子订单 + HighChildOrder childOrder = new HighChildOrder(); + childOrder.setMemId(user.getId()); + childOrder.setMemName(user.getName()); + childOrder.setMemPhone(user.getPhone()); + childOrder.setChildOrderNo(OrderUtil.generateChildOrderNo()); + childOrder.setGoodsType(OrderChildGoodsType.TYPE6.getNumber()); + childOrder.setGoodsId(goodsId); + childOrder.setGoodsName(OperatorEnum.getNameByType(outRechargePrice.getOperatorType()) + "话费充值" + outRechargePrice.getRechargePrice() + "元"); + childOrder.setGoodsSpecName(outRechargePrice.getRechargePrice() + "元"); + childOrder.setGoodsPrice(outRechargePrice.getRechargePrice()); + childOrder.setGoodsActualPrice(outRechargePrice.getPayPrice()); + childOrder.setSaleCount(1); + childOrder.setGiveawayType(false); + childOrder.setChildOrderStatus(OrderChildStatus.STATUS1.getNumber()); + childOrder.setTotalPrice(outRechargePrice.getRechargePrice()); + childOrder.setTotalActualPrice(outRechargePrice.getPayPrice()); + childOrder.setTotalDeductionPrice(childOrder.getTotalPrice().subtract(childOrder.getTotalActualPrice())); + childOrder.setPraiseStatus(0); + childOrder.setCreateTime(new Date()); + + outRechargeOrder.setUserId(user.getId()); + outRechargeOrder.setRechargeContent(rechargeContent); + outRechargeOrder.setCompanyId(outRechargePrice.getCompanyId()); + outRechargeOrder.setUserName(user.getName()); + outRechargeOrder.setRechargeType(outRechargePrice.getRechargeType()); + outRechargeOrder.setUserPhone(user.getPhone()); + outRechargeOrder.setOrderNo(order.getOrderNo()); + outRechargeOrder.setChildOrderNo(childOrder.getChildOrderNo()); + outRechargeOrder.setCreateTimed(new Date()); + outRechargeOrder.setGoodsId(goodsId); + outRechargeOrder.setRechargePrice(outRechargePrice.getRechargePrice()); + outRechargeOrder.setOrderPrice(outRechargePrice.getRechargePrice()); + outRechargeOrder.setType(1); + outRechargeOrder.setOperatorName(OperatorEnum.getNameByType(outRechargePrice.getOperatorType())); + outRechargeOrder.setOperatorType(outRechargePrice.getOperatorType()); + outRechargeOrderMapper.insert(outRechargeOrder); + return childOrder; } } diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java index c1398d32..efe9601d 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java @@ -92,6 +92,12 @@ public class OrderPaySuccessServiceImpl implements OrderPaySuccessService { @Resource private ApiMemberProductService apiMemberProductService; + @Resource + private BsMsgService bsMsgService; + + @Resource + private OutRechargeOrderService outRechargeOrderService; + @Override public HighOrder orderPaySuccessHandle(String orderNo, OrderPayType payType, String paySerialNo, BigDecimal payRealPrice, HighUserCard userCard) { HighOrder order = orderService.getOrderDetailByNo(orderNo); @@ -128,6 +134,9 @@ public class OrderPaySuccessServiceImpl implements OrderPaySuccessService { // 处理订单产品业务 orderBusHandle(order); + + // 推送支付成功消息 + bsMsgService.pushUserMsg(order.getId() , "支付成功"); } return order; @@ -152,6 +161,7 @@ public class OrderPaySuccessServiceImpl implements OrderPaySuccessService { timeout = 20, rollbackFor = Exception.class) public void orderBusHandle(HighOrder order) throws Exception { + for (HighChildOrder childOrder : order.getHighChildOrderList()) { if (childOrder.getGoodsType().equals(OrderChildGoodsType.TYPE1.getNumber())) { couponHandle(order, childOrder); @@ -170,7 +180,7 @@ public class OrderPaySuccessServiceImpl implements OrderPaySuccessService { } else if (childOrder.getGoodsType().equals(OrderChildGoodsType.TYPE5.getNumber())) { } else if (childOrder.getGoodsType().equals(OrderChildGoodsType.TYPE6.getNumber())) { - + mobileRecharge(order); } else if (childOrder.getGoodsType().equals(OrderChildGoodsType.TYPE7.getNumber())) { eCouponPackageHandle(order , childOrder); } else if (childOrder.getGoodsType().equals(OrderChildGoodsType.TYPE8.getNumber())) { @@ -462,5 +472,22 @@ public class OrderPaySuccessServiceImpl implements OrderPaySuccessService { } + /** + * @Author Sum1Dream + * @Name mobileRecharge + * @Description // 话费订单操作 + * @Date 13:46 2022/11/2 + * @Param [order] + * @Return void + */ + private void mobileRecharge(HighOrder order) throws Exception { + OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(order.getOrderNo()); + if (outRechargeOrder.getPayStatus() == null) { + if (order.getProductType().equals(9)) { + outRechargeOrderService.editOutRechargeOrder(order); + } + } + outRechargeOrderService.pollRequest(outRechargeOrder); + } } diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java index 1cfac1d2..1d5775a3 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java @@ -21,10 +21,7 @@ import com.hai.order.service.*; import com.hai.order.topic.OrderTopic; import com.hai.order.type.*; import com.hai.order.utils.OrderUtil; -import com.hai.service.HighDiscountAgentCodeService; -import com.hai.service.HighDiscountUserRelService; -import com.hai.service.HighUserPayPasswordService; -import com.hai.service.HighUserService; +import com.hai.service.*; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.apache.rocketmq.client.producer.SendCallback; @@ -86,6 +83,9 @@ public class OrderServiceImpl implements OrderService { @Resource private OrderPaySuccessService paySuccessService; + @Resource + private OutRechargeOrderService outRechargeOrderService; + @Override public HighOrder insertOrderData(HighOrder order) { orderMapper.insert(order); @@ -170,6 +170,9 @@ public class OrderServiceImpl implements OrderService { object.put("userId" , child.getMemId()); object.put("orderItems" , child.getOrderItems()); + /*********** 话费 请求数据************/ + object.put("rechargeContent" , child.getRechargeContent()); + object.put("goodsId" , child.getGoodsId()); // 购买卡券 if (child.getGoodsType().equals(OrderChildGoodsType.TYPE1.getNumber())) { order.setProductType(OrderProductType.PRODUCT_TYPE5.getNumber()); @@ -218,6 +221,9 @@ public class OrderServiceImpl implements OrderService { // 话费充值 } else if (child.getGoodsType().equals(OrderChildGoodsType.TYPE6.getNumber())) { + HighChildOrder childOrder = orderCreateHandleService.mobileRecharge(order , object); + childOrderList.add(childOrder); + order.setTitle(childOrder.getGoodsName()); order.setProductType(OrderProductType.PRODUCT_TYPE9.getNumber()); // 优惠券包 @@ -425,6 +431,8 @@ public class OrderServiceImpl implements OrderService { // 订单入库 HighOrder orderData = insertOrderData(order); + + if (orderData.getOrderStatus().equals(OrderStatus.STATUS1.getNumber())) { // 10分钟内未支付,自动取消订单 Message rocketMsg = MessageBuilder.withPayload(order).build(); diff --git a/hai-service/src/main/java/com/hai/service/BsMsgService.java b/hai-service/src/main/java/com/hai/service/BsMsgService.java index 745baaf3..e1feb345 100644 --- a/hai-service/src/main/java/com/hai/service/BsMsgService.java +++ b/hai-service/src/main/java/com/hai/service/BsMsgService.java @@ -1,5 +1,6 @@ package com.hai.service; +import com.alibaba.fastjson.JSONObject; import com.hai.entity.BsMsg; import com.hai.entity.BsMsgUser; import com.hai.entity.HighUser; @@ -86,5 +87,15 @@ public interface BsMsgService { */ List queryMsgByList(Map map); + /** + * @Author Sum1Dream + * @Name pushUserMsg + * @Description // 推送用户信息 + * @Date 18:21 2022/11/1 + * @Param [orderId, userId] + * @Return void + */ + void pushUserMsg(Long orderId , String title) throws Exception; + } diff --git a/hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java b/hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java index d0b735d6..2961432c 100644 --- a/hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java +++ b/hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java @@ -1,6 +1,7 @@ package com.hai.service; import com.alibaba.fastjson.JSONObject; +import com.hai.entity.HighOrder; import com.hai.entity.HighUserCard; import com.hai.entity.OutRechargeChildOrder; import com.hai.entity.OutRechargeOrder; @@ -186,4 +187,14 @@ public interface OutRechargeOrderService { */ List integralRebateRechargeOrder(); + /** + * @Author Sum1Dream + * @Name editOutRechargeOrder + * @Description // 根据订单号修改订单内容 + * @Date 11:42 2022/11/2 + * @Param [order, outRechargeOrder] + * @Return void + */ + void editOutRechargeOrder(HighOrder order); + } diff --git a/hai-service/src/main/java/com/hai/service/impl/BsMsgServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/BsMsgServiceImpl.java index 4a9fd11f..9a855120 100644 --- a/hai-service/src/main/java/com/hai/service/impl/BsMsgServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/BsMsgServiceImpl.java @@ -1,9 +1,13 @@ package com.hai.service.impl; +import com.alibaba.fastjson.JSONObject; +import com.hai.common.utils.DateUtil; import com.hai.dao.BsMsgMapper; import com.hai.dao.BsMsgUserMapper; import com.hai.entity.*; import com.hai.service.BsMsgService; +import com.hai.service.HighOrderService; +import com.hai.service.HighUserService; import org.apache.commons.collections4.MapUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -28,11 +32,16 @@ public class BsMsgServiceImpl implements BsMsgService { @Resource private BsMsgUserMapper bsMsgUserMapper; + @Resource + private HighOrderService highOrderService; + + @Resource + private HighUserService highUserService; + @Override @Transactional public void insertMsg(BsMsg bsMsg , HighUser user) { - bsMsg.setStatus(1); bsMsg.setCreateTime(new Date()); bsMsg.setUpdateTime(new Date()); @@ -133,4 +142,31 @@ public class BsMsgServiceImpl implements BsMsgService { public List queryMsgByList(Map map) { return bsMsgUserMapper.queryMsgByList(map); } + + @Override + public void pushUserMsg(Long orderId,String title) throws Exception { + // 查询订单 + HighOrder highOrder = highOrderService.getOrderById(orderId); + // 查询用户信息 + HighUser highUser = highUserService.findByUserId(highOrder.getMemId()); + + JSONObject object = new JSONObject(); + object.put("price" , highOrder.getPayRealPrice()); + object.put("objectName" , highOrder.getTitle()); + object.put("time" , DateUtil.date2String(highOrder.getCreateTime() , DateUtil.Y_M_D_HMS_C)); + + BsMsg bsMsg = new BsMsg(); + + bsMsg.setCompanyId(highOrder.getCompanyId()); + bsMsg.setOpName("系统生成"); + bsMsg.setMsgType(1); + bsMsg.setType(1); + bsMsg.setObjectId(orderId); + bsMsg.setObjectType(highOrder.getPayType()); + bsMsg.setJumpType(1); + bsMsg.setTitle(title); + bsMsg.setStatus(2); + bsMsg.setContent(object.toString()); + insertMsg(bsMsg , highUser); + } } diff --git a/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java index 8481a9be..9f6ed764 100644 --- a/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java @@ -996,4 +996,23 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { return outRechargeOrderMapper.integralRebateRechargeOrder(); } + @Override + public void editOutRechargeOrder(HighOrder orderData) { + OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(orderData.getOrderNo()); + + // 201:充值中 202:充值成功 203:充值失败 204:未充值 + outRechargeOrder.setRechargeStatus(201); + // 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款 + outRechargeOrder.setPayStatus(102); + outRechargeOrder.setMemDiscountId(orderData.getMemDiscountId()); + outRechargeOrder.setMemDiscountName(orderData.getMemDiscountName()); + outRechargeOrder.setPayType(orderData.getPayType()); + outRechargeOrder.setLaborUnionCard(orderData.getMemCardNo()); + outRechargeOrder.setDiscountDeductionPrice(orderData.getDeductionCouponPrice()); + outRechargeOrder.setIntegralDeductionPrice( new BigDecimal(orderData.getPayGold().toString()).divide(new BigDecimal(100))); + outRechargeOrder.setIntegralNum(new BigDecimal(orderData.getPayGold())); + outRechargeOrder.setPayPrice(orderData.getPayPrice()); + outRechargeOrder.setPayRealPrice(orderData.getPayRealPrice()); + outRechargeOrderService.updateOrder(outRechargeOrder); + } }