diff --git a/hai-bweb/src/main/java/com/bweb/controller/ApiMerchantsController.java b/hai-bweb/src/main/java/com/bweb/controller/ApiMerchantsController.java index a9cf9858..a342e25d 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/ApiMerchantsController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/ApiMerchantsController.java @@ -280,84 +280,107 @@ public class ApiMerchantsController { } } -// @RequestMapping(value = "/getListMerchProduct", method = RequestMethod.GET) -// @ResponseBody -// @ApiOperation(value = "查询商户产品") -// public ResponseData getListMerchProduct(@RequestParam(value = "merchantId", required = true) Long merchantId) { -// try { -// -// return ResponseMsgUtil.success(apiMerchantsService.getListMerchProduct(merchantId)); -// -// } catch (Exception e) { -// log.error("ApiMerchantsController --> findById() error!", e); -// return ResponseMsgUtil.exception(e); -// } -// } -// -// @RequestMapping(value = "/getPhoneOrderList", method = RequestMethod.GET) -// @ResponseBody -// @ApiOperation(value = "获取订单") -// public ResponseData getPhoneOrderList( -// @RequestParam(name = "rechargeStatus", required = false) String rechargeStatus, -// @RequestParam(name = "orderNo", required = false) String orderNo, -// @RequestParam(name = "operatorType", required = false) String operatorType, -// @RequestParam(name = "laborUnionCard", required = false) String laborUnionCard, -// @RequestParam(name = "rechargeContent", required = false) String rechargeContent, -// @RequestParam(name = "userPhone", required = false) String userPhone, -// @RequestParam(name = "rechargeType", required = false) String rechargeType, -// @RequestParam(name = "payType", required = false) Integer payType, -// @RequestParam(name = "payTimeS", required = false) Long payTimeS, -// @RequestParam(name = "payTimeE", required = false) Long payTimeE, -// @RequestParam(name = "whetherTimeOut", required = false) Boolean whetherTimeOut, -// @RequestParam(name = "createTimeS", required = false) Long createTimeS, -// @RequestParam(name = "createTimeE", required = false) Long createTimeE, -// @RequestParam(name = "pageNum", required = true) Integer pageNum, -// @RequestParam(name = "pageSize", required = true) Integer pageSize, -// HttpServletRequest request) { -// try { -// -// SessionObject sessionObject = userCenter.getSessionObject(request); -// UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); -// -// Map map = new HashMap<>(); -// -// if (companyId != null) { -// map.put("companyId", companyId); -// } else if (userInfoModel.getSecRole().getRoleType() != 1){ -// if (userInfoModel.getSecRole().getRoleType() == 7) { -// map.put("companyId", 23); -// } else { -// map.put("companyId", userInfoModel.getBsCompany().getId()); -// } -// } -// -// map.put("rechargeStatus", rechargeStatus); -// map.put("payStatus", payStatus); -// map.put("orderNo", orderNo); -// map.put("whetherTimeOut", whetherTimeOut); -// map.put("operatorType", operatorType); -// map.put("laborUnionCard", laborUnionCard); -// map.put("rechargeContent", rechargeContent); -// map.put("userPhone", userPhone); -// map.put("rechargeType", rechargeType); -// map.put("payType", payType); -// if (payTimeS != null && payTimeE != null ) { -// map.put("payTimeS", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(payTimeS)); -// map.put("payTimeE", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(payTimeE)); -// } -// if (createTimeS != null && createTimeE != null) { -// map.put("createTimeS", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(createTimeS)); -// map.put("createTimeE", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(createTimeE)); -// } -// -// PageHelper.startPage(pageNum, pageSize); -// return ResponseMsgUtil.success(new PageInfo<>(outRechargeOrderService.getListRechargeOrder(map))); -// -// } catch (Exception e) { -// log.error("HighOrderController --> getUserOrderList() error!", e); -// return ResponseMsgUtil.exception(e); -// } -// } + @RequestMapping(value = "/getApiRechargePhoneByList", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "获取API充值话费订单") + public ResponseData getApiRechargePhoneByList( + @RequestParam(name = "payStatus", required = false) Integer payStatus, + @RequestParam(name = "rechargeStatus", required = false) Integer rechargeStatus, + @RequestParam(name = "callbackStatus", required = false) Integer callbackStatus, + @RequestParam(name = "orderNo", required = false) String orderNo, + @RequestParam(name = "sourceOrderNo", required = false) String sourceOrderNo, + @RequestParam(name = "operators", required = false) String operators, + @RequestParam(name = "rechargeNumber", required = false) String rechargeNumber, + @RequestParam(name = "payTimeS", required = false) Long payTimeS, + @RequestParam(name = "payTimeE", required = false) Long payTimeE, + @RequestParam(name = "createTimeS", required = false) Long createTimeS, + @RequestParam(name = "createTimeE", required = false) Long createTimeE, + @RequestParam(name = "pageNum", required = true) Integer pageNum, + @RequestParam(name = "pageSize", required = true) Integer pageSize, + HttpServletRequest request) { + try { + + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + + Map map = new HashMap<>(); + + if (userInfoModel.getApiMerchants() == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前账户权限不足"); + } + map.put("rechargeStatus", rechargeStatus); + map.put("payStatus", payStatus); + map.put("merchId", userInfoModel.getApiMerchants().getMchId()); + map.put("callbackStatus", callbackStatus); + map.put("orderNo", orderNo); + map.put("sourceOrderNo", sourceOrderNo); + map.put("operators", operators); + map.put("rechargeNumber", rechargeNumber); + if (payTimeS != null && payTimeE != null ) { + map.put("payTimeS", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(payTimeS)); + map.put("payTimeE", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(payTimeE)); + } + if (createTimeS != null && createTimeE != null) { + map.put("createTimeS", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(createTimeS)); + map.put("createTimeE", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(createTimeE)); + } + PageHelper.startPage(pageNum, pageSize); + return ResponseMsgUtil.success(new PageInfo<>(outRechargeOrderService.getApiRechargePhoneByList(map))); + + } catch (Exception e) { + log.error("HighOrderController --> getUserOrderList() error!", e); + return ResponseMsgUtil.exception(e); + } + } + @RequestMapping(value = "/getApiThirdOrderByList", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询API第三方订单列表") + public ResponseData getApiThirdOrderByList( + @RequestParam(name = "orderStatus", required = false) Integer orderStatus, + @RequestParam(name = "callbackStatus", required = false) Integer callbackStatus, + @RequestParam(name = "orderNo", required = false) String orderNo, + @RequestParam(name = "productType", required = false) Integer productType, + @RequestParam(name = "sourceOrderNo", required = false) String sourceOrderNo, + @RequestParam(name = "payTimeS", required = false) Long payTimeS, + @RequestParam(name = "payTimeE", required = false) Long payTimeE, + @RequestParam(name = "createTimeS", required = false) Long createTimeS, + @RequestParam(name = "createTimeE", required = false) Long createTimeE, + @RequestParam(name = "pageNum", required = true) Integer pageNum, + @RequestParam(name = "pageSize", required = true) Integer pageSize, + HttpServletRequest request) { + try { + + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + + Map map = new HashMap<>(); + + if (userInfoModel.getApiMerchants() == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前账户权限不足"); + } + map.put("orderStatus", orderStatus); + map.put("merchId", userInfoModel.getApiMerchants().getMchId()); + map.put("callbackStatus", callbackStatus); + map.put("productType", productType); + map.put("orderNo", orderNo); + map.put("sourceOrderNo", sourceOrderNo); + + if (payTimeS != null && payTimeE != null ) { + map.put("payTimeS", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(payTimeS)); + map.put("payTimeE", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(payTimeE)); + } + if (createTimeS != null && createTimeE != null) { + map.put("createTimeS", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(createTimeS)); + map.put("createTimeE", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(createTimeE)); + } + PageHelper.startPage(pageNum, pageSize); + return ResponseMsgUtil.success(new PageInfo<>(apiMerchantsService.getApiThirdOrderByList(map))); + + } catch (Exception e) { + log.error("HighOrderController --> getUserOrderList() error!", e); + return ResponseMsgUtil.exception(e); + } + } } diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighOpenApiController.java b/hai-bweb/src/main/java/com/bweb/controller/HighOpenApiController.java index 98185123..f339e771 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighOpenApiController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighOpenApiController.java @@ -18,6 +18,7 @@ import com.hai.entity.HighUser; import com.hai.enum_type.OrderPushType; import com.hai.model.ResponseData; import com.hai.model.UserInfoModel; +import com.hai.service.ApiIpAddressService; import com.hai.service.HighOpenApiService; import com.hai.service.HighUserService; import com.hai.service.SecConfigService; @@ -65,6 +66,10 @@ public class HighOpenApiController { private HuiLianTongConfig huiLianTongConfig; + @Resource + private ApiIpAddressService apiIpAddressService; + + @RequestMapping(value = "/getGuizhouSinopecList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取专属优惠券") @@ -99,7 +104,7 @@ public class HighOpenApiController { @RequestMapping(value="/getGuizhouSinopecList",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "获取贵州中石化电子卡券") - public ResponseData getGuizhouSinopecList(HttpServletRequest request) { + public ResponseData getGuizhouSinopecList(@RequestBody JSONObject object ,HttpServletRequest request) { try { String ip = ""; @@ -110,9 +115,9 @@ public class HighOpenApiController { ip = request.getHeader("x-forwarded-for"); } - if (!secConfigService.isConfig("IP_WHITE" , ip)) { - log.error("getGuizhouSinopec error!", "非法ip地址,请联系管理人员!"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "非法ip地址,请联系管理人员!"); + if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { + log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); } // 获取token @@ -147,11 +152,10 @@ public class HighOpenApiController { ip = request.getHeader("x-forwarded-for"); } - if (!secConfigService.isConfig("IP_WHITE" , ip)) { - log.error("getGuizhouSinopec error!", "非法ip地址,请联系管理人员!"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "非法ip地址,请联系管理人员!"); + if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { + log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); } - // 获取token String token = huiLianTongConfig.getToken(); @@ -183,9 +187,9 @@ public class HighOpenApiController { ip = request.getHeader("x-forwarded-for"); } - if (!secConfigService.isConfig("IP_WHITE" , ip)) { - log.error("couJointDist error!", "非法ip地址,请联系管理人员!"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "非法ip地址,请联系管理人员!"); + if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { + log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); } // 获取token diff --git a/hai-bweb/src/main/resources/dev/application.yml b/hai-bweb/src/main/resources/dev/application.yml index 11c2de93..59fb1869 100644 --- a/hai-bweb/src/main/resources/dev/application.yml +++ b/hai-bweb/src/main/resources/dev/application.yml @@ -9,7 +9,7 @@ debug: false #datasource数据源设置 spring: datasource: - url: jdbc:mysql://139.159.177.244:3306/hsg_pre?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false + url: jdbc:mysql://139.159.177.244:3306/hfkj?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false username: root password: HF123456. type: com.alibaba.druid.pool.DruidDataSource 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 da2a7da4..0e0dd885 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.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; @Resource private HighProfitSharingRecordService highProfitSharingRecordService; @Resource private HighGasOilGunNoService gasOilGunNoService; @Resource private HighGasOrderPushMapper highGasOrderPushMapper; @Resource private HuiLianTongConfig huiLianTongConfig; @Resource private UnionPayConfig unionPayConfig; @Resource private UnionStagingPayConfig unionStagingPayConfig; @Resource private UnionUserConfig unionUserConfig; @Resource private OutRechargeOrderService outRechargeOrderService; @Resource private HighOilCardService oilCardService; @Resource private BaiduVoiceService baiduVoiceService; @Resource private MqttProviderConfig mqttProviderConfig; @Autowired private WebSocket webSocket; @Resource private ShellGroupService shellGroupService; @Resource private HighGasService gasService; @Resource private JinZhuJiaYouService jinZhuJiaYouService; @RequestMapping(value = "/spPrint", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "发送打印机消息") public ResponseData spPrint(@RequestParam(name = "orderNo", required = true) String orderNo, HttpServletRequest request) { try { HighOrder highOrder = highOrderService.getOrderByOrderNo(orderNo); for (HighChildOrder highChildOrder : highOrder.getHighChildOrderList()) { HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreById(highChildOrder.getGoodsId()); new Thread(() -> { try { SpPrinterConfig sp = new SpPrinterConfig(); sp.print(store.getDeviceSn(), SpPrinterTemplate.oilCashierStubTemp( highChildOrder.getGoodsName(), highOrder.getOrderNo(), DateUtil.date2String(highOrder.getPayTime(), "yyyy-MM-dd HH:mm:ss"), "嗨森逛", highChildOrder.getGasGunNo(), highChildOrder.getGasOilNo(), highChildOrder.getGasOilLiters().toString(), highOrder.getTotalPrice().toString(), new HashMap<>(), false ), 1); Thread.sleep(6000); sp.print(store.getDeviceSn(), SpPrinterTemplate.oilClientStubTemp( highChildOrder.getGoodsName(), highOrder.getOrderNo(), DateUtil.date2String(highOrder.getPayTime(), "yyyy-MM-dd HH:mm:ss"), "嗨森逛", highChildOrder.getGasGunNo(), highChildOrder.getGasOilNo(), highChildOrder.getGasOilLiters().toString(), highOrder.getTotalPrice().toString(), new HashMap<>(), false ), 1); } catch (Exception e) { e.printStackTrace(); } }).start(); } return ResponseMsgUtil.success("发送成功"); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardInfo() error!", e); return ResponseMsgUtil.exception(e); } } @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 = "/pushTuanYouOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "推送团油订单") public ResponseData pushTuanYouOrder(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); for (HighChildOrder highChildOrder : order.getHighChildOrderList()) { HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreById(highChildOrder.getGoodsId()); // 推送团油订单 Map paramMap = new HashMap<>(); paramMap.put("gasId", store.getStoreKey()); paramMap.put("oilNo", highChildOrder.getGasOilNo()); paramMap.put("gunNo", highChildOrder.getGasGunNo()); BigDecimal priceGun = highChildOrder.getGasPriceGun(); BigDecimal priceVip = highChildOrder.getGasPriceVip(); paramMap.put("priceGun", priceGun); // 枪单价 paramMap.put("priceVip", priceVip); // 优惠价 paramMap.put("driverPhone", order.getMemPhone()); // paramMap.put("driverPhone", "17726395120"); paramMap.put("thirdSerialNo", order.getOrderNo()); paramMap.put("refuelingAmount", highChildOrder.getTotalPrice()); // 油品类型 1:汽油:2:柴油;3:天然气 if (highChildOrder.getGasOilType() == 1) { paramMap.put("accountNo", CommonSysConst.getSysConfig().getTuanYouGasolineAccount()); } else if (highChildOrder.getGasOilType() == 2) { paramMap.put("accountNo", CommonSysConst.getSysConfig().getTuanYouDieselAccount()); } JSONObject orderPushObject = TuanYouConfig.refuelingOrderPush(paramMap); // 推送团油订单记录 HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); highGasOrderPush.setCreateTime(new Date()); highGasOrderPush.setCode(orderPushObject.getString("code")); highGasOrderPush.setRequestContent(JSONObject.toJSONString(paramMap)); highGasOrderPush.setReturnContent(orderPushObject.toJSONString()); highGasOrderPushMapper.insert(highGasOrderPush); if (orderPushObject != null && orderPushObject.getString("code").equals("200")) { highChildOrder.setGasOrderNo(orderPushObject.getJSONObject("result").getString("orderNo")); } highOrderService.updateOrder(order); } return ResponseMsgUtil.success(order); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } } */ @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 = "/gasSyncPayment", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "gasSyncPayment") public ResponseData gasSyncPayment(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo("orderNo"); for (HighChildOrder childOrder : order.getHighChildOrderList()) { HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreById(childOrder.getGoodsId()); // 推送加好油 shellGroupService.gasSyncPayment(order.getOrderNo(), store.getStoreKey(), order.getPayTime(), childOrder.getTotalPrice(), childOrder.getGasOilNo(), childOrder.getGasGunNo(), order.getPayablePrice(), order.getDeductionPrice() ); } 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 = "/test", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "test") public ResponseData test() { try { JSONObject data = HuiLianTongUnionCardConfig.resolveResponse("Gbkl57c3fECXJRiCSOspjsb3bIyyFrE4TyMKKGsSAMzeXLElQQU00GoYZSYkJYg1G2Xlic2QvOd3\\nhJC7bc6qAg+9aoZr3IJi"); return ResponseMsgUtil.success(data); } catch (Exception e) { log.error("HighOrderController --> gasSyncRefund() error!", e); return ResponseMsgUtil.exception(e); } } public static String hexStringToString(String s) { if (s == null || s.equals("")) { return null; } s = s.replace(" ", ""); byte[] baKeyword = new byte[s.length() / 2]; for (int i = 0; i < baKeyword.length; i++) { try { baKeyword[i] = (byte) (0xff & Integer.parseInt(s.substring(i * 2, i * 2 + 2), 16)); } catch (Exception e) { e.printStackTrace(); } } try { s = new String(baKeyword, "UTF-8"); } catch (Exception e1) { e1.printStackTrace(); } return s; } /** * 获取打印内容,适用于云打印机 * * @param printText 打印文本 * @param pageCount 打印联数 * @param encodingStr 编码方式,默认UTF-8 * @return */ public byte[] getPrinterBytes(final byte[] printText, final int pageCount, String encodingStr) { try { byte[] array = new byte[printText.length + 9]; array[0] = 30; array[1] = 16; array[2] = (byte) pageCount;//打印份数 int num = array.length - 5; array[3] = (byte) (num >> 8); //array[4] = (byte)((uint)num & 0xFFu); array[4] = (byte) (num & 0xFF); for (int i = 0; i < printText.length; i++) { array[i + 5] = printText[i]; } array[array.length - 4] = 27; array[array.length - 3] = 99; byte[] crc16CodeArray = getCRC(printText); array[array.length - 2] = crc16CodeArray[0]; array[array.length - 1] = crc16CodeArray[1]; return array; /* if(encodingStr.equals("")){ encodingStr="UTF-8"; } byte[] msgByte = printText; // 消息数组 final byte[] dataByte = new byte[msgByte.length + 9]; dataByte[0] = 0x1E; dataByte[1] = 0x10; dataByte[2] = (byte) pageCount;// 打印多联 // 有效数据长度 final int len = dataByte.length - 5; dataByte[3] = (byte) (len >> 8); dataByte[4] = (byte) (len & 0xff); // 数据内容 System.arraycopy(msgByte, 0, dataByte, 5, msgByte.length); // 标识字节 dataByte[dataByte.length - 4] = 0x1b; dataByte[dataByte.length - 3] = 0x63; // 打印内容CRC校验 final byte[] dtCRC = getCRC(msgByte); dataByte[dataByte.length - 2] = (byte) (dtCRC[0]); dataByte[dataByte.length - 1] = (byte) (dtCRC[1]); msgByte = dataByte; return msgByte;*/ } catch (Exception ex) { System.out.println(ex.getStackTrace()); } return null; } /** * 获取打印内容,适用于云打印机 * * @param printText 打印文本 * @param pageCount 打印联数 * @param encodingStr 编码方式,默认UTF-8 * @return */ public byte[] getPrinterBytes(final String printText, final int pageCount, String encodingStr) { try { if (encodingStr.equals("")) { encodingStr = "UTF-8"; } byte[] msgByte = printText.getBytes(encodingStr); // 消息数组 final byte[] dataByte = new byte[msgByte.length + 9]; dataByte[0] = 0x1E; dataByte[1] = 0x10; dataByte[2] = (byte) pageCount;// 打印多联 // 有效数据长度 final int len = dataByte.length - 5; dataByte[3] = (byte) (len >> 8); dataByte[4] = (byte) (len & 0xff); // 数据内容 System.arraycopy(msgByte, 0, dataByte, 5, msgByte.length); // 标识字节 dataByte[dataByte.length - 4] = 0x1b; dataByte[dataByte.length - 3] = 0x63; // 打印内容CRC校验 final byte[] dtCRC = getCRC(msgByte); dataByte[dataByte.length - 2] = (byte) (dtCRC[0]); dataByte[dataByte.length - 1] = (byte) (dtCRC[1]); msgByte = dataByte; return msgByte; } catch (Exception ex) { System.out.println(ex.getStackTrace()); } return null; } private static int[] CRC16Table = {0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf, 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7, 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e, 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876, 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd, 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5, 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c, 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974, 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb, 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3, 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a, 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72, 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9, 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1, 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738, 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70, 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7, 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff, 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036, 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e, 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5, 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd, 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134, 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c, 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3, 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb, 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232, 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a, 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1, 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9, 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330, 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78}; private static byte[] getCRC(byte[] bytes) { int crc = 0xFFFF; // 初始值 for (byte b : bytes) { crc = (crc >> 8) ^ CRC16Table[(crc ^ b) & 0xff]; } byte[] b = new byte[2]; b[0] = (byte) ((crc >> 8) ^ 0xff); b[1] = (byte) ((crc & 0xff) ^ 0xff); return b; } private static final char[] HEXES = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; /** * byte数组 转换成 16进制小写字符串 */ private String bytes2Hex(byte[] bytes) { if (bytes == null || bytes.length == 0) { return null; } StringBuilder hex = new StringBuilder(); for (byte b : bytes) { hex.append(HEXES[(b >> 4) & 0x0F]); hex.append(HEXES[b & 0x0F]); } return hex.toString(); } @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 = "/getPayOrderByCouNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "支付") public ResponseData getPayOrderByCouNo() { try { JSONObject jsonObject = HuiLianTongConfig.getPayOrderByCouNo("3D3F3D3D3F393E3737363F3F363C3739363D3D"); if (jsonObject.getString("respCode").equals("0000")) { JSONObject data = HuiLianTongUnionCardConfig.resolveResponse(jsonObject.getString("data")); return ResponseMsgUtil.success(data); } return ResponseMsgUtil.success(jsonObject); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() 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.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.collections4.MapUtils; 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; @Resource private HighProfitSharingRecordService highProfitSharingRecordService; @Resource private HighGasOilGunNoService gasOilGunNoService; @Resource private HighGasOrderPushMapper highGasOrderPushMapper; @Resource private HuiLianTongConfig huiLianTongConfig; @Resource private UnionPayConfig unionPayConfig; @Resource private UnionStagingPayConfig unionStagingPayConfig; @Resource private UnionUserConfig unionUserConfig; @Resource private OutRechargeOrderService outRechargeOrderService; @Resource private HighOilCardService oilCardService; @Resource private BaiduVoiceService baiduVoiceService; @Resource private MqttProviderConfig mqttProviderConfig; @Autowired private WebSocket webSocket; @Resource private ShellGroupService shellGroupService; @Resource private HighGasService gasService; @Resource private JinZhuJiaYouService jinZhuJiaYouService; @RequestMapping(value = "/spPrint", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "发送打印机消息") public ResponseData spPrint(@RequestParam(name = "orderNo", required = true) String orderNo, HttpServletRequest request) { try { HighOrder highOrder = highOrderService.getOrderByOrderNo(orderNo); for (HighChildOrder highChildOrder : highOrder.getHighChildOrderList()) { HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreById(highChildOrder.getGoodsId()); new Thread(() -> { try { SpPrinterConfig sp = new SpPrinterConfig(); sp.print(store.getDeviceSn(), SpPrinterTemplate.oilCashierStubTemp( highChildOrder.getGoodsName(), highOrder.getOrderNo(), DateUtil.date2String(highOrder.getPayTime(), "yyyy-MM-dd HH:mm:ss"), "嗨森逛", highChildOrder.getGasGunNo(), highChildOrder.getGasOilNo(), highChildOrder.getGasOilLiters().toString(), highOrder.getTotalPrice().toString(), new HashMap<>(), false ), 1); Thread.sleep(6000); sp.print(store.getDeviceSn(), SpPrinterTemplate.oilClientStubTemp( highChildOrder.getGoodsName(), highOrder.getOrderNo(), DateUtil.date2String(highOrder.getPayTime(), "yyyy-MM-dd HH:mm:ss"), "嗨森逛", highChildOrder.getGasGunNo(), highChildOrder.getGasOilNo(), highChildOrder.getGasOilLiters().toString(), highOrder.getTotalPrice().toString(), new HashMap<>(), false ), 1); } catch (Exception e) { e.printStackTrace(); } }).start(); } return ResponseMsgUtil.success("发送成功"); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardInfo() error!", e); return ResponseMsgUtil.exception(e); } } @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 = "/pushTuanYouOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "推送团油订单") public ResponseData pushTuanYouOrder(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); for (HighChildOrder highChildOrder : order.getHighChildOrderList()) { HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreById(highChildOrder.getGoodsId()); // 推送团油订单 Map paramMap = new HashMap<>(); paramMap.put("gasId", store.getStoreKey()); paramMap.put("oilNo", highChildOrder.getGasOilNo()); paramMap.put("gunNo", highChildOrder.getGasGunNo()); BigDecimal priceGun = highChildOrder.getGasPriceGun(); BigDecimal priceVip = highChildOrder.getGasPriceVip(); paramMap.put("priceGun", priceGun); // 枪单价 paramMap.put("priceVip", priceVip); // 优惠价 paramMap.put("driverPhone", order.getMemPhone()); // paramMap.put("driverPhone", "17726395120"); paramMap.put("thirdSerialNo", order.getOrderNo()); paramMap.put("refuelingAmount", highChildOrder.getTotalPrice()); // 油品类型 1:汽油:2:柴油;3:天然气 if (highChildOrder.getGasOilType() == 1) { paramMap.put("accountNo", CommonSysConst.getSysConfig().getTuanYouGasolineAccount()); } else if (highChildOrder.getGasOilType() == 2) { paramMap.put("accountNo", CommonSysConst.getSysConfig().getTuanYouDieselAccount()); } JSONObject orderPushObject = TuanYouConfig.refuelingOrderPush(paramMap); // 推送团油订单记录 HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); highGasOrderPush.setCreateTime(new Date()); highGasOrderPush.setCode(orderPushObject.getString("code")); highGasOrderPush.setRequestContent(JSONObject.toJSONString(paramMap)); highGasOrderPush.setReturnContent(orderPushObject.toJSONString()); highGasOrderPushMapper.insert(highGasOrderPush); if (orderPushObject != null && orderPushObject.getString("code").equals("200")) { highChildOrder.setGasOrderNo(orderPushObject.getJSONObject("result").getString("orderNo")); } highOrderService.updateOrder(order); } return ResponseMsgUtil.success(order); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } } */ @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 = "/gasSyncPayment", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "gasSyncPayment") public ResponseData gasSyncPayment(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo("orderNo"); for (HighChildOrder childOrder : order.getHighChildOrderList()) { HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreById(childOrder.getGoodsId()); // 推送加好油 shellGroupService.gasSyncPayment(order.getOrderNo(), store.getStoreKey(), order.getPayTime(), childOrder.getTotalPrice(), childOrder.getGasOilNo(), childOrder.getGasGunNo(), order.getPayablePrice(), order.getDeductionPrice() ); } 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 = "/test", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "test") public ResponseData test() { try { JSONObject data = HuiLianTongUnionCardConfig.resolveResponse("Gbkl57c3fECXJRiCSOspjsb3bIyyFrE4TyMKKGsSAMzeXLElQQU00GoYZSYkJYg1G2Xlic2QvOd3\\nhJC7bc6qAg+9aoZr3IJi"); return ResponseMsgUtil.success(data); } catch (Exception e) { log.error("HighOrderController --> gasSyncRefund() error!", e); return ResponseMsgUtil.exception(e); } } public static String hexStringToString(String s) { if (s == null || s.equals("")) { return null; } s = s.replace(" ", ""); byte[] baKeyword = new byte[s.length() / 2]; for (int i = 0; i < baKeyword.length; i++) { try { baKeyword[i] = (byte) (0xff & Integer.parseInt(s.substring(i * 2, i * 2 + 2), 16)); } catch (Exception e) { e.printStackTrace(); } } try { s = new String(baKeyword, "UTF-8"); } catch (Exception e1) { e1.printStackTrace(); } return s; } /** * 获取打印内容,适用于云打印机 * * @param printText 打印文本 * @param pageCount 打印联数 * @param encodingStr 编码方式,默认UTF-8 * @return */ public byte[] getPrinterBytes(final byte[] printText, final int pageCount, String encodingStr) { try { byte[] array = new byte[printText.length + 9]; array[0] = 30; array[1] = 16; array[2] = (byte) pageCount;//打印份数 int num = array.length - 5; array[3] = (byte) (num >> 8); //array[4] = (byte)((uint)num & 0xFFu); array[4] = (byte) (num & 0xFF); for (int i = 0; i < printText.length; i++) { array[i + 5] = printText[i]; } array[array.length - 4] = 27; array[array.length - 3] = 99; byte[] crc16CodeArray = getCRC(printText); array[array.length - 2] = crc16CodeArray[0]; array[array.length - 1] = crc16CodeArray[1]; return array; /* if(encodingStr.equals("")){ encodingStr="UTF-8"; } byte[] msgByte = printText; // 消息数组 final byte[] dataByte = new byte[msgByte.length + 9]; dataByte[0] = 0x1E; dataByte[1] = 0x10; dataByte[2] = (byte) pageCount;// 打印多联 // 有效数据长度 final int len = dataByte.length - 5; dataByte[3] = (byte) (len >> 8); dataByte[4] = (byte) (len & 0xff); // 数据内容 System.arraycopy(msgByte, 0, dataByte, 5, msgByte.length); // 标识字节 dataByte[dataByte.length - 4] = 0x1b; dataByte[dataByte.length - 3] = 0x63; // 打印内容CRC校验 final byte[] dtCRC = getCRC(msgByte); dataByte[dataByte.length - 2] = (byte) (dtCRC[0]); dataByte[dataByte.length - 1] = (byte) (dtCRC[1]); msgByte = dataByte; return msgByte;*/ } catch (Exception ex) { System.out.println(ex.getStackTrace()); } return null; } /** * 获取打印内容,适用于云打印机 * * @param printText 打印文本 * @param pageCount 打印联数 * @param encodingStr 编码方式,默认UTF-8 * @return */ public byte[] getPrinterBytes(final String printText, final int pageCount, String encodingStr) { try { if (encodingStr.equals("")) { encodingStr = "UTF-8"; } byte[] msgByte = printText.getBytes(encodingStr); // 消息数组 final byte[] dataByte = new byte[msgByte.length + 9]; dataByte[0] = 0x1E; dataByte[1] = 0x10; dataByte[2] = (byte) pageCount;// 打印多联 // 有效数据长度 final int len = dataByte.length - 5; dataByte[3] = (byte) (len >> 8); dataByte[4] = (byte) (len & 0xff); // 数据内容 System.arraycopy(msgByte, 0, dataByte, 5, msgByte.length); // 标识字节 dataByte[dataByte.length - 4] = 0x1b; dataByte[dataByte.length - 3] = 0x63; // 打印内容CRC校验 final byte[] dtCRC = getCRC(msgByte); dataByte[dataByte.length - 2] = (byte) (dtCRC[0]); dataByte[dataByte.length - 1] = (byte) (dtCRC[1]); msgByte = dataByte; return msgByte; } catch (Exception ex) { System.out.println(ex.getStackTrace()); } return null; } private static int[] CRC16Table = {0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf, 0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7, 0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e, 0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876, 0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd, 0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5, 0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c, 0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974, 0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb, 0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3, 0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a, 0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72, 0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9, 0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1, 0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738, 0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70, 0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7, 0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff, 0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036, 0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e, 0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5, 0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd, 0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134, 0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c, 0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3, 0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb, 0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232, 0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a, 0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1, 0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9, 0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330, 0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78}; private static byte[] getCRC(byte[] bytes) { int crc = 0xFFFF; // 初始值 for (byte b : bytes) { crc = (crc >> 8) ^ CRC16Table[(crc ^ b) & 0xff]; } byte[] b = new byte[2]; b[0] = (byte) ((crc >> 8) ^ 0xff); b[1] = (byte) ((crc & 0xff) ^ 0xff); return b; } private static final char[] HEXES = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; /** * byte数组 转换成 16进制小写字符串 */ private String bytes2Hex(byte[] bytes) { if (bytes == null || bytes.length == 0) { return null; } StringBuilder hex = new StringBuilder(); for (byte b : bytes) { hex.append(HEXES[(b >> 4) & 0x0F]); hex.append(HEXES[b & 0x0F]); } return hex.toString(); } @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 = "/getPayOrderByCouNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "支付") public ResponseData getPayOrderByCouNo() { try { JSONObject jsonObject = HuiLianTongConfig.getPayOrderByCouNo("3D3F3D3D3F393E3737363F3F363C3739363D3D"); if (jsonObject.getString("respCode").equals("0000")) { JSONObject data = HuiLianTongUnionCardConfig.resolveResponse(jsonObject.getString("data")); return ResponseMsgUtil.success(data); } return ResponseMsgUtil.success(jsonObject); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/postThirdParty", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "提交第三方订单") public ResponseData postThirdParty(@RequestBody JSONObject object) { try { Map map = new HashMap<>(); map.put("customerMobile" , "18090580471"); map.put("productType" , object.getString("productType")); map.put("apiKey" , "E5A03E6AB18656BA2C56FA9A0DBAE561"); map.put("timetable" , new Date().getTime()); map.put("sourceOrderNo" , "POST" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5)); map.put("notifyUrl" , "https://hsgcs.dctpay.com/crest/czOrder/apiCallBack"); map.put("merchId" , "20221233300"); String signPost = WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5); object.put("customerMobile" , map.get("customerMobile")); object.put("productType" , map.get("productType")); object.put("apiKey" , map.get("apiKey")); object.put("timetable" , map.get("timetable")); object.put("sourceOrderNo" , map.get("sourceOrderNo")); object.put("notifyUrl" , map.get("notifyUrl")); object.put("merchId" , map.get("merchId")); object.put("sign" , signPost); JSONObject jsonObject = HttpsUtils.doPost("http://localhost:9902/v1/thirdParty/createOrder" , object); return ResponseMsgUtil.success(jsonObject); } catch (Exception e) { log.error("HighOrderController -> addOrder() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/postPhone", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "提交话费订单") public ResponseData postPhone(@RequestBody JSONObject object) { try { Map map = new HashMap<>(); map.put("mobile" , "18090580471"); map.put("apiConfigProductId" , object.getString("apiConfigProductId")); map.put("apiKey" , "E5A03E6AB18656BA2C56FA9A0DBAE561"); map.put("timetable" , new Date().getTime()); map.put("sourceOrderNo" , "PHONE" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5)); map.put("notifyUrl" , "https://hsgcs.dctpay.com/crest/czOrder/apiCallBack"); map.put("merchId" , "20221233300"); String signPost = WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5); object.put("mobile" , map.get("mobile")); object.put("apiConfigProductId" , map.get("apiConfigProductId")); object.put("apiKey" , map.get("apiKey")); object.put("timetable" , map.get("timetable")); object.put("sourceOrderNo" , map.get("sourceOrderNo")); object.put("notifyUrl" , map.get("notifyUrl")); object.put("merchId" , map.get("merchId")); object.put("sign" , signPost); JSONObject jsonObject = HttpsUtils.doPost("http://localhost:9902/v1/rechargeProduct/createOrder" , object); return ResponseMsgUtil.success(jsonObject); } catch (Exception e) { log.error("HighOrderController -> addOrder() error!", e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighThirdPartyController.java b/hai-cweb/src/main/java/com/cweb/controller/HighThirdPartyController.java index ded7f07c..93ba6bd2 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighThirdPartyController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighThirdPartyController.java @@ -334,7 +334,7 @@ public class HighThirdPartyController { HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); if (StringUtils.isBlank(object.getString("customerMobile")) || - StringUtils.isBlank(object.getString("regionId")) || + StringUtils.isBlank(object.getString("companyId")) || object.getInteger("productType") == null || object.getInteger("platformId") == null ) { @@ -342,14 +342,9 @@ public class HighThirdPartyController { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } - SecRegion region = commonService.getParentByRegion(object.getLong("regionId")); - if (region != null) { - BsCompany bsCompany = bsCompanyService.selectCompanyByRegion(region.getRegionId().toString()); - object.put("companyId", String.valueOf(bsCompany.getId())); - } - object.put("userId", userInfoModel.getHighUser().getId()); object.put("mchId", request.getHeader("mchId")); + object.put("companyId", object.getString("companyId")); return ResponseMsgUtil.success(highOrderService.insertThirdProduct(object)); diff --git a/hai-cweb/src/main/resources/dev/application.yml b/hai-cweb/src/main/resources/dev/application.yml index d0dd0258..9d3beabf 100644 --- a/hai-cweb/src/main/resources/dev/application.yml +++ b/hai-cweb/src/main/resources/dev/application.yml @@ -9,7 +9,7 @@ debug: false #datasource数据源设置 spring: datasource: - url: jdbc:mysql://139.159.177.244:3306/hsg_pre?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false + url: jdbc:mysql://139.159.177.244:3306/hfkj?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false username: root password: HF123456. type: com.alibaba.druid.pool.DruidDataSource diff --git a/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java b/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java index b16eb3b1..e8528b5c 100644 --- a/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java @@ -1285,4 +1285,33 @@ public interface HighOrderMapperExt { @Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR) }) List integralRebateOrder(); + + @Select({"" + }) + List getApiThirdOrderByList(@Param("map") Map map); + } diff --git a/hai-service/src/main/java/com/hai/dao/OutRechargeOrderMapperExt.java b/hai-service/src/main/java/com/hai/dao/OutRechargeOrderMapperExt.java index bed63e07..de2c6eee 100644 --- a/hai-service/src/main/java/com/hai/dao/OutRechargeOrderMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/OutRechargeOrderMapperExt.java @@ -3,10 +3,7 @@ package com.hai.dao; import com.hai.entity.HighOrder; import com.hai.entity.OutRechargeOrder; -import com.hai.model.OrderCountModel; -import com.hai.model.OutOrderModel; -import com.hai.model.OutRechargeOrderModel; -import com.hai.model.OutUserOrderModel; +import com.hai.model.*; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Result; import org.apache.ibatis.annotations.Results; @@ -196,4 +193,37 @@ public interface OutRechargeOrderMapperExt { @Result(column="whether_rebate", property="whetherRebate", jdbcType=JdbcType.BIT) }) List integralRebateRechargeOrder(); + + @Select({"" + }) + List getApiRechargePhoneByList(@Param("map") Map map); } diff --git a/hai-service/src/main/java/com/hai/entity/HighOrder.java b/hai-service/src/main/java/com/hai/entity/HighOrder.java index 600c70d3..3ee9fc17 100644 --- a/hai-service/src/main/java/com/hai/entity/HighOrder.java +++ b/hai-service/src/main/java/com/hai/entity/HighOrder.java @@ -73,7 +73,7 @@ public class HighOrder implements Serializable { private Integer payModel; /** - * 支付方式: 1:支付宝 2:微信 3:金币 4:汇联通工会卡 5:银联 6:银联分期 + * 支付方式: 1:支付宝 2:微信 3:金币 4:汇联通工会卡 5:银联 6:银联分期 7.API商户账号 */ private Integer payType; diff --git a/hai-service/src/main/java/com/hai/enum_type/OrderPayModelEnum.java b/hai-service/src/main/java/com/hai/enum_type/OrderPayModelEnum.java index 2d9f8c62..7588b790 100644 --- a/hai-service/src/main/java/com/hai/enum_type/OrderPayModelEnum.java +++ b/hai-service/src/main/java/com/hai/enum_type/OrderPayModelEnum.java @@ -9,6 +9,7 @@ public enum OrderPayModelEnum { type2(2 , "第三方平台"), type3(3 , "混合"), type4(4 , "油卡"), + type5(5 , "商户余额"), ; private Integer type; diff --git a/hai-service/src/main/java/com/hai/enum_type/OrderPayTypeEnum.java b/hai-service/src/main/java/com/hai/enum_type/OrderPayTypeEnum.java index c7879e90..df793e68 100644 --- a/hai-service/src/main/java/com/hai/enum_type/OrderPayTypeEnum.java +++ b/hai-service/src/main/java/com/hai/enum_type/OrderPayTypeEnum.java @@ -12,6 +12,7 @@ public enum OrderPayTypeEnum { type5(5 , "银联"), type6(6 , "银联分期"), type7(7 , "嗨森逛油卡"), + type8(8 , "API商户"), ; private Integer type; diff --git a/hai-service/src/main/java/com/hai/model/ApiRechargePhoneModel.java b/hai-service/src/main/java/com/hai/model/ApiRechargePhoneModel.java new file mode 100644 index 00000000..e696cf7d --- /dev/null +++ b/hai-service/src/main/java/com/hai/model/ApiRechargePhoneModel.java @@ -0,0 +1,163 @@ +package com.hai.model; + +import java.math.BigDecimal; +import java.util.Date; + +public class ApiRechargePhoneModel { + + /** + * 订单号码 + */ + private String orderNo; + + /** + * 来源订单号 + */ + private String sourceOrderNo; + + /** + * 运营商 + */ + private String operators; + + /** + * 充值号码 + */ + private String rechargeNumber; + + /** + * 充值金额 + */ + private BigDecimal rechargePrice; + + /** + * 支付金额 + */ + private BigDecimal payPrice; + + /** + * 创建时间 + */ + private Date createTimed; + + /** + * 支付时间 + */ + private Date payTime; + + /** + * 完成时间 + */ + private Date finishTime; + + /** + * 支付状态 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款 + */ + private Integer payStatus; + + /** + * 充值状态:201:充值中 202:充值成功 203:充值失败 204:未充值 + */ + private Integer rechargeStatus; + + /** + * 回调状态 100 :未回调 101:已回调 102:回调未响应 103:预备回调 + */ + private Integer callbackStatus; + + public String getOrderNo() { + return orderNo; + } + + public void setOrderNo(String orderNo) { + this.orderNo = orderNo; + } + + public String getSourceOrderNo() { + return sourceOrderNo; + } + + public void setSourceOrderNo(String sourceOrderNo) { + this.sourceOrderNo = sourceOrderNo; + } + + public String getOperators() { + return operators; + } + + public void setOperators(String operators) { + this.operators = operators; + } + + public String getRechargeNumber() { + return rechargeNumber; + } + + public void setRechargeNumber(String rechargeNumber) { + this.rechargeNumber = rechargeNumber; + } + + public BigDecimal getRechargePrice() { + return rechargePrice; + } + + public void setRechargePrice(BigDecimal rechargePrice) { + this.rechargePrice = rechargePrice; + } + + public BigDecimal getPayPrice() { + return payPrice; + } + + public void setPayPrice(BigDecimal payPrice) { + this.payPrice = payPrice; + } + + public Date getCreateTimed() { + return createTimed; + } + + public void setCreateTimed(Date createTimed) { + this.createTimed = createTimed; + } + + public Date getPayTime() { + return payTime; + } + + public void setPayTime(Date payTime) { + this.payTime = payTime; + } + + public Date getFinishTime() { + return finishTime; + } + + public void setFinishTime(Date finishTime) { + this.finishTime = finishTime; + } + + public Integer getPayStatus() { + return payStatus; + } + + public void setPayStatus(Integer payStatus) { + this.payStatus = payStatus; + } + + public Integer getRechargeStatus() { + return rechargeStatus; + } + + public void setRechargeStatus(Integer rechargeStatus) { + this.rechargeStatus = rechargeStatus; + } + + public Integer getCallbackStatus() { + return callbackStatus; + } + + public void setCallbackStatus(Integer callbackStatus) { + this.callbackStatus = callbackStatus; + } +} diff --git a/hai-service/src/main/java/com/hai/model/ApiThirdOrderModel.java b/hai-service/src/main/java/com/hai/model/ApiThirdOrderModel.java new file mode 100644 index 00000000..4d2d88e0 --- /dev/null +++ b/hai-service/src/main/java/com/hai/model/ApiThirdOrderModel.java @@ -0,0 +1,112 @@ +package com.hai.model; + +import java.math.BigDecimal; +import java.util.Date; + +public class ApiThirdOrderModel { + + /** + * 订单号码 + */ + private String orderNo; + + /** + * 来源订单号 + */ + private String sourceOrderNo; + + /** + * 订单金额 + */ + private BigDecimal orderPrice; + + /** + * 支付金额 + */ + private BigDecimal payPrice; + + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 支付时间 + */ + private Date payTime; + + /** + * 订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 6.退款中 7.拒绝退款 + */ + private Integer orderStatus; + + /** + * 回调状态 100 :未回调 101:已回调 102:回调未响应 103:预备回调 + */ + private Integer callbackStatus; + + public String getOrderNo() { + return orderNo; + } + + public void setOrderNo(String orderNo) { + this.orderNo = orderNo; + } + + public String getSourceOrderNo() { + return sourceOrderNo; + } + + public void setSourceOrderNo(String sourceOrderNo) { + this.sourceOrderNo = sourceOrderNo; + } + + public BigDecimal getOrderPrice() { + return orderPrice; + } + + public void setOrderPrice(BigDecimal orderPrice) { + this.orderPrice = orderPrice; + } + + public BigDecimal getPayPrice() { + return payPrice; + } + + public void setPayPrice(BigDecimal payPrice) { + this.payPrice = payPrice; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getPayTime() { + return payTime; + } + + public void setPayTime(Date payTime) { + this.payTime = payTime; + } + + public Integer getOrderStatus() { + return orderStatus; + } + + public void setOrderStatus(Integer orderStatus) { + this.orderStatus = orderStatus; + } + + public Integer getCallbackStatus() { + return callbackStatus; + } + + public void setCallbackStatus(Integer callbackStatus) { + this.callbackStatus = callbackStatus; + } +} diff --git a/hai-service/src/main/java/com/hai/service/ApiMerchantsService.java b/hai-service/src/main/java/com/hai/service/ApiMerchantsService.java index 0db8576e..fce1a3df 100644 --- a/hai-service/src/main/java/com/hai/service/ApiMerchantsService.java +++ b/hai-service/src/main/java/com/hai/service/ApiMerchantsService.java @@ -5,6 +5,7 @@ import com.hai.entity.ApiAmountRecord; import com.hai.entity.ApiMerchants; import com.hai.entity.ApiProductConfig; import com.hai.model.ApiProductConfigModel; +import com.hai.model.ApiThirdOrderModel; import java.math.BigDecimal; import java.util.List; @@ -109,5 +110,15 @@ public interface ApiMerchantsService { */ List getMerchProduct(Long merchantId , Integer rechargeType); + + /** + * @Author Sum1Dream + * @Name getApiThirdOrderByList + * @Description // 查询API第三方订单列表 + * @Date 18:19 2023/1/4 + * @Param [map] + * @Return java.util.List + */ + List getApiThirdOrderByList(Map map); } 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..1d365ea5 100644 --- a/hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java +++ b/hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java @@ -4,10 +4,7 @@ import com.alibaba.fastjson.JSONObject; import com.hai.entity.HighUserCard; import com.hai.entity.OutRechargeChildOrder; import com.hai.entity.OutRechargeOrder; -import com.hai.model.OrderCountModel; -import com.hai.model.OutOrderModel; -import com.hai.model.OutRechargeOrderModel; -import com.hai.model.OutUserOrderModel; +import com.hai.model.*; import io.swagger.models.auth.In; import java.math.BigDecimal; @@ -186,4 +183,15 @@ public interface OutRechargeOrderService { */ List integralRebateRechargeOrder(); + /** + * @Author Sum1Dream + * @Name getApiRechargePhoneByList + * @Description // 查询API话费订单列表 + * @Date 15:53 2023/1/4 + * @Param [map] + * @Return java.util.List + */ + List getApiRechargePhoneByList(Map map); + + } diff --git a/hai-service/src/main/java/com/hai/service/impl/ApiMerchantsServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/ApiMerchantsServiceImpl.java index 77f43d7b..9db999fa 100644 --- a/hai-service/src/main/java/com/hai/service/impl/ApiMerchantsServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/ApiMerchantsServiceImpl.java @@ -9,9 +9,11 @@ import com.hai.common.utils.RedisUtil; import com.hai.dao.ApiAmountRecordMapper; import com.hai.dao.ApiMerchantsMapper; import com.hai.dao.ApiProductConfigMapper; +import com.hai.dao.HighOrderMapper; import com.hai.entity.*; import com.hai.enum_type.UserObjectTypeEnum; import com.hai.model.ApiProductConfigModel; +import com.hai.model.ApiThirdOrderModel; import com.hai.model.UserInfoModel; import com.hai.service.ApiMerchantsService; import com.hai.service.SecUserService; @@ -48,6 +50,9 @@ public class ApiMerchantsServiceImpl implements ApiMerchantsService { @Resource private SecUserService secUserService; + @Resource + private HighOrderMapper highOrderMapper; + @Override @Transactional(rollbackFor=Exception.class,propagation= Propagation.REQUIRES_NEW) public void insertApiMerchants(ApiMerchants apiMerchants) throws Exception { @@ -187,5 +192,8 @@ public class ApiMerchantsServiceImpl implements ApiMerchantsService { return apiProductConfigMapper.getMerchProduct(merchantId , rechargeType); } - + @Override + public List getApiThirdOrderByList(Map map) { + return highOrderMapper.getApiThirdOrderByList(map); + } } diff --git a/hai-service/src/main/java/com/hai/service/impl/ApiOpenServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/ApiOpenServiceImpl.java index 4fc9dd94..73737b1d 100644 --- a/hai-service/src/main/java/com/hai/service/impl/ApiOpenServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/ApiOpenServiceImpl.java @@ -12,10 +12,13 @@ import com.hai.config.CommonSysConst; import com.hai.config.QianZhuConfig; import com.hai.config.RechargeConfig; +import com.hai.dao.HighChildOrderMapper; import com.hai.dao.HighOrderMapper; import com.hai.dao.OutRechargeOrderMapper; import com.hai.entity.*; +import com.hai.enum_type.OrderPayModelEnum; +import com.hai.enum_type.OrderPayTypeEnum; import com.hai.service.*; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Isolation; @@ -54,13 +57,24 @@ public class ApiOpenServiceImpl implements ApiOpenService { @Resource private HighOrderMapper highOrderMapper; + @Resource + private HighChildOrderMapper highChildOrderMapper; + + @Resource + private ApiMemberProductService apiMemberProductService; + + @Resource + private SecConfigService secConfigService; + + @Resource + private HighOrderService highOrderService; @Override @Transactional(rollbackFor=Exception.class,isolation = Isolation.SERIALIZABLE,propagation= Propagation.REQUIRES_NEW) public void createOrder(JSONObject object , ApiMerchants apiMerchants , ApiProductConfig productConfig) throws Exception { Map orderMap = new HashMap<>(); - orderMap.put("sourceOrderNo" , object.getString("orderNo")); + orderMap.put("sourceOrderNo" , object.getString("sourceOrderNo")); // 查询是否用重复订单 ApiOrderRecord apiOrderRecord = apiOrderRecordService.queryOrderResult(orderMap); @@ -114,9 +128,10 @@ public class ApiOpenServiceImpl implements ApiOpenService { outRechargeOrder.setRechargeType(apiProduct.getPhoneRechargeType()); outRechargeOrder.setOrderPrice(productConfig.getDiscountPrice()); outRechargeOrder.setPayPrice(productConfig.getDiscountPrice()); + outRechargeOrder.setPayRealPrice(productConfig.getDiscountPrice()); outRechargeOrder.setRechargeContent(object.getString("mobile")); outRechargeOrder.setPayTime(new Date()); - outRechargeOrder.setUserName(apiMerchants.getUserName()); + outRechargeOrder.setUserName(apiMerchants.getMerchantName()); outRechargeOrder.setUserPhone(apiMerchants.getPhone()); outRechargeOrder.setPayType(6); outRechargeOrder.setCompanyId(6666L); @@ -135,7 +150,7 @@ public class ApiOpenServiceImpl implements ApiOpenService { ApiOrderRecord apiOrderRecordPost = new ApiOrderRecord(); apiOrderRecordPost.setStatus(103); apiOrderRecordPost.setOrderNo(outRechargeOrder.getOrderNo()); - apiOrderRecordPost.setSourceOrderNo(apiAmountRecord.getSourceOrderNo()); + apiOrderRecordPost.setSourceOrderNo(object.getString("sourceOrderNo")); apiOrderRecordPost.setCreateTime(new Date()); apiOrderRecordPost.setMchId(apiMerchants.getMchId()); apiOrderRecordPost.setOrderId(outRechargeOrder.getId()); @@ -154,6 +169,7 @@ public class ApiOpenServiceImpl implements ApiOpenService { // 查询充值子订单 Map childOrderMap = new HashMap<>(); + childOrderMap.put("parent_order_id", outRechargeOrder.getId()); childOrderMap.put("status", 102); @@ -177,8 +193,8 @@ public class ApiOpenServiceImpl implements ApiOpenService { // 查询充值子订单 Map childOrderMap103 = new HashMap<>(); - childOrderMap.put("parent_order_id", outRechargeOrder.getId()); - childOrderMap.put("status", 103); + childOrderMap103.put("parent_order_id", outRechargeOrder.getId()); + childOrderMap103.put("status", 103); List childOrderList103 = outRechargeChildOrderService.getListRechargeChildOrder(childOrderMap103); if (childOrderList103.size() > 0) { @@ -211,11 +227,12 @@ public class ApiOpenServiceImpl implements ApiOpenService { } JSONObject returnObject = RechargeConfig.rechargeOrderByJj(object); object.put("return_content", returnObject); - if (returnObject != null && returnObject.getLong("code") == 200) { - childOrder.setStatus(102); - } else { - childOrder.setStatus(103); - } + childOrder.setStatus(102); +// if (returnObject != null && returnObject.getLong("code") == 200) { +// childOrder.setStatus(102); +// } else { +// childOrder.setStatus(103); +// } rechargePlatformType = 1; break; } @@ -271,15 +288,27 @@ public class ApiOpenServiceImpl implements ApiOpenService { @Override @Transactional(rollbackFor=Exception.class,isolation = Isolation.SERIALIZABLE,propagation= Propagation.REQUIRES_NEW) public void createOrder(JSONObject object , ApiMerchants apiMerchants) throws Exception { + // 定义订单 HighOrder highOrder = new HighOrder(); - highOrder.setMerchId(object.getString("mchId")); + highOrder.setMerchId(apiMerchants.getMchId()); highOrder.setWhetherRebate(false); highOrder.setMemPhone(apiMerchants.getPhone()); highOrder.setMemName(apiMerchants.getMerchantName()); highOrder.setMemId(apiMerchants.getId()); + highOrder.setCreateTime(new Date()); + highOrder.setOrderStatus(1); + highOrder.setProductType(object.getInteger("productType")); + highOrder.setPayModel(OrderPayModelEnum.type5.getType()); + highOrder.setPayType(OrderPayTypeEnum.type8.getType()); + highOrder.setOrderNo("HF" + DateUtil.date2String(new Date(),"yyyyMMddHHmmss") + IDGenerator.nextId(5)); + highOrderMapper.insert(highOrder); + + // 订单总金额 + BigDecimal marketPriceTotal = new BigDecimal(0); - JSONObject jsonObject = null; + // 定义下单json对象 + JSONObject jsonObject; // 获取token JSONObject userToken = QianZhuConfig.getTokenV2(apiMerchants.getId().toString(), apiMerchants.getMerchantName(), apiMerchants.getPhone()); @@ -290,8 +319,15 @@ public class ApiOpenServiceImpl implements ApiOpenService { // 1 星巴克 2 肯德基 3 会员充值 if (object.getInteger("productType") == 1) { + + // 判断当前商户是否有权限下单 + if (!secConfigService.isConfig("STARBUCKS_CONFIG" , object.getString("merchId"))) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOT_AUTHORIZED, "当前帐户无权限查询!"); + } + List List = new ArrayList<>(); + // 获取下单内容 JSONArray array = object.getJSONArray("orderItems"); // 组装下单数据 @@ -322,8 +358,10 @@ public class ApiOpenServiceImpl implements ApiOpenService { if (!"".equals(object1.getString("num"))) { contentMap.put("num", object1.getString("num")); } + // 添加到LIST List.add(JSON.toJSONString(contentMap)); } + // 下单 jsonObject = QianZhuConfig.starbucksOrders(apiMerchants.getId().toString(), object.getString("storeCode"), List.toString().replace(" ", ""), object.getString("customerMobile")); @@ -344,56 +382,198 @@ public class ApiOpenServiceImpl implements ApiOpenService { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, jsonObject.getString("message")); } - // 插入订单内容 - highOrder.setOrderNo(jsonObject.getJSONObject("data").getString("orderNo")); - highOrder.setCreateTime(new Date()); - highOrder.setMemId(apiMerchants.getId()); - highOrder.setMemName(apiMerchants.getMerchantName()); - highOrder.setMemPhone(apiMerchants.getPhone()); - highOrder.setOrderStatus(1); - highOrderMapper.insert(highOrder); - // 获取星巴克订单内容 JSONArray starbucksOrder = orderObject.getJSONObject("data").getJSONArray("orderItems"); -// for (Object starbucksObject : starbucksOrder) { -// JSONObject childObject = (JSONObject) starbucksObject; -// HighChildOrder childOrder = new HighChildOrder(); -// childOrder.setOrderId(highOrder.getId()); -// childOrder.setChildOrdeStatus(1); -// childOrder.setGoodsType(9); -// childOrder.setStoreId(object.getLong("storeCode")); -// childOrder.setGoodsId(object.getLong("productId")); -// childOrder.setStoreAddress(childObject.getString("storeAddress")); -// childOrder.setStoreName(childObject.getString("storeName")); -// childOrder.setGoodsName(childObject.getString("productName")); -// childOrder.setGoodsImg(childObject.getString("imgUrl")); -// childOrder.setSaleCount(childObject.getInteger("quantity")); -// childOrder.setGoodsPrice(childObject.getBigDecimal("marketPrice")); -// -// // 计算利润 -// BigDecimal profitPrice = childObject.getBigDecimal("marketPrice").multiply(productDetail.getBigDecimal("priceDiscount").divide(new BigDecimal(100))); -// // 计算子订单支付金额 -// BigDecimal childPrice = childObject.getBigDecimal("unitPrice").add(profitPrice).setScale(2 , RoundingMode.HALF_UP); -// if (childPrice.compareTo(childObject.getBigDecimal("marketPrice")) > 0) { -// childPrice = childObject.getBigDecimal("marketPrice"); -// } -// if (object.getLong("memDiscountId") != null) { -// childOrder.setGoodsActualPrice(childObject.getBigDecimal("marketPrice")); -// } else { -// childOrder.setGoodsActualPrice(childPrice); -// } -// childPrice = childPrice.multiply(childObject.getBigDecimal("quantity")); -// // 计算总订单实际支付金额 -// orderPayPrice = orderPayPrice.add(childPrice); -// // 计算市场价金额 -// marketPrice = marketPrice.add(childObject.getBigDecimal("marketPrice").multiply(childObject.getBigDecimal("quantity"))); -// childOrder.setTotalPrice(childPrice); -// highChildOrderMapper.insert(childOrder); -// } + // 循环获取星巴克订单 + for (Object starbucksObject : starbucksOrder) { + JSONObject childObject = (JSONObject) starbucksObject; + HighChildOrder childOrder = new HighChildOrder(); + childOrder.setOrderId(highOrder.getId()); + childOrder.setChildOrdeStatus(1); + childOrder.setMemId(highOrder.getMemId()); + childOrder.setGoodsType(9); + childOrder.setStoreId(object.getLong("storeCode")); + childOrder.setGoodsId(childObject.getLong("id")); + childOrder.setStoreAddress(childObject.getString("storeAddress")); + childOrder.setStoreName(childObject.getString("storeName")); + childOrder.setGoodsName(childObject.getString("productName")); + childOrder.setGoodsImg(childObject.getString("imgUrl")); + childOrder.setSaleCount(childObject.getInteger("quantity")); + childOrder.setGoodsPrice(childObject.getBigDecimal("marketPrice")); + + // 计算子订单支付金额 + BigDecimal childPrice = childObject.getBigDecimal("marketPrice"); + childOrder.setGoodsActualPrice(childPrice); + // 计算市场价金额 + childOrder.setTotalPrice(childPrice.multiply(childObject.getBigDecimal("quantity"))); + marketPriceTotal = marketPriceTotal.add(childOrder.getTotalPrice()); + + highChildOrderMapper.insert(childOrder); + } + // 拼接json对象 + object.put("sourceType" , 5); + object.put("content" , apiMerchants.getMerchantName() + "|" + "星巴克下单" + "|扣款" + marketPriceTotal); + }else if (object.getInteger("productType") == 2) { + + // 判断当前商户是否有肯德基下单权限 + if (!secConfigService.isConfig("KFC_CONFIG" , object.getString("merchId"))) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOT_AUTHORIZED, "当前帐户无权限查询!"); + } + // 判断就餐方式 + if (object.getInteger("eatType") == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请选择就餐方式!"); + } + // 下单 + jsonObject = QianZhuConfig.createKfcOrder(object.getInteger("eatType"), object.getString("storeCode"), object.getString("customerMobile"), object.getString("orderItems"), apiMerchants.getId().toString()); + + // 判断下单是否成功 + if (!Objects.equals(jsonObject.getString("code"), "10000")) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, jsonObject.getString("message")); + } + + // 根据订单号查询订单详情 + JSONObject orderObject = QianZhuConfig.getKfcOrderByOrderNo(jsonObject.getJSONObject("data").getString("orderNo")); + // 判断下单是否成功 + if (!orderObject.getBoolean("success")) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, jsonObject.getString("message")); + } + + // 获取肯德基订单内容 + JSONArray kfcOrder = orderObject.getJSONObject("data").getJSONObject("kfcPlaceOrder").getJSONArray("items"); + for (Object kfcObject : kfcOrder) { + + JSONObject childObject = (JSONObject) kfcObject; + HighChildOrder childOrder = new HighChildOrder(); + childOrder.setOrderId(highOrder.getId()); + childOrder.setChildOrdeStatus(1); + childOrder.setGoodsType(4); + childOrder.setMemId(highOrder.getMemId()); + childOrder.setExt6(object.getString("storeCode")); + childOrder.setGoodsId(childObject.getLong("productId")); + childOrder.setStoreAddress(orderObject.getJSONObject("data").getJSONObject("kfcPlaceOrder").getString("storeAddress")); + childOrder.setStoreName(orderObject.getJSONObject("data").getJSONObject("kfcPlaceOrder").getString("storeName")); + childOrder.setGoodsName(childObject.getString("productName")); + childOrder.setGoodsImg(childObject.getString("imageUrl")); + childOrder.setSaleCount(childObject.getInteger("quantity")); + childOrder.setGoodsPrice(childObject.getBigDecimal("originPrice")); + + // 计算利润 + // 计算子订单支付金额 + BigDecimal childPrice = childObject.getBigDecimal("originPrice"); + childOrder.setGoodsActualPrice(childPrice); + // 计算市场价金额 + childOrder.setTotalPrice(childPrice.multiply(childObject.getBigDecimal("quantity"))); + marketPriceTotal = marketPriceTotal.add(childOrder.getTotalPrice()); + highChildOrderMapper.insert(childOrder); + } + // 拼接json对象 + object.put("sourceType" , 4); + object.put("content" , apiMerchants.getMerchantName() + "|" + "肯德基下单" + "|扣款" + marketPriceTotal); + } else if (object.getInteger("productType") == 3) { + + // 判断是否有会员充值下单权限 + if (!secConfigService.isConfig("MEMBER_RECHARGE_CONFIG" , object.getString("merchId"))) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOT_AUTHORIZED, "当前帐户无权限查询!"); + } + + // 获取会员充值 + ApiMemberProduct memberProduct = apiMemberProductService.findById(object.getLong("goodsId")); + + if (memberProduct == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前产品不可购买"); + } + + object.put("productId", memberProduct.getProductId()); + + HighChildOrder childOrder = new HighChildOrder(); + childOrder.setOrderId(highOrder.getId()); + childOrder.setChildOrdeStatus(1); + childOrder.setGoodsType(10); + childOrder.setStoreId(object.getLong("storeCode")); + childOrder.setGoodsId(memberProduct.getId()); + childOrder.setGoodsName(memberProduct.getName()); + childOrder.setSaleCount(1); + childOrder.setMemId(highOrder.getMemId()); + childOrder.setGoodsPrice(memberProduct.getPrice()); + childOrder.setGoodsActualPrice(memberProduct.getPrice()); + // 计算市场价金额 + childOrder.setTotalPrice(memberProduct.getPrice()); + marketPriceTotal = marketPriceTotal.add(childOrder.getTotalPrice()); + highChildOrderMapper.insert(childOrder); + object.put("sourceType" , 6); + object.put("content" , apiMerchants.getMerchantName() + "|" + "第三方会员充值下单" + "|扣款" + marketPriceTotal); + } + // 当前账号余额是否可以充值当前金额 + if (apiMerchants.getAmounts().compareTo(marketPriceTotal) < 0) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.INSUFFICIENT_BALANCE); } + highOrder.setTotalPrice(marketPriceTotal); + highOrder.setPayPrice(marketPriceTotal); + highOrder.setPayRealPrice(marketPriceTotal); + highOrder.setPayablePrice(marketPriceTotal); + ApiAmountRecord apiAmountRecord = apiMerchantAmount(highOrder , apiMerchants , object); + + highOrder.setOrderStatus(2); + highOrder.setPayTime(new Date()); + highOrder.setPaySerialNo("22" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5)); + highOrderMapper.updateByPrimaryKey(highOrder); + + // 更新子订单状态 + List childOrderList = highOrderService.getChildOrderByOrder(highOrder.getId()); + + for (HighChildOrder highChildOrder : childOrderList) { + highChildOrder.setChildOrdeStatus(2); + highChildOrderMapper.updateByPrimaryKey(highChildOrder); + } + + // 插入订单记录 + ApiOrderRecord apiOrderRecordPost = new ApiOrderRecord(); + apiOrderRecordPost.setStatus(103); + apiOrderRecordPost.setOrderNo(highOrder.getOrderNo()); + apiOrderRecordPost.setSourceOrderNo(apiAmountRecord.getSourceOrderNo()); + apiOrderRecordPost.setCreateTime(new Date()); + apiOrderRecordPost.setMchId(apiMerchants.getMchId()); + apiOrderRecordPost.setOrderId(highOrder.getId()); + apiOrderRecordPost.setGoodsId(apiMerchants.getMchId()); + apiOrderRecordPost.setNotifyUrl(object.getString("notifyUrl")); + apiOrderRecordPost.setUpdateTime(new Date()); + + apiOrderRecordService.insertOrderRecord(apiOrderRecordPost); + } + + private ApiAmountRecord apiMerchantAmount(HighOrder highOrder , ApiMerchants apiMerchants , JSONObject object) throws Exception { + // 插入金额记录 + // 变更前金额 + BigDecimal beforeAmount = apiMerchants.getAmounts(); + // 计算金额 + apiMerchants.setAmounts(apiMerchants.getAmounts().subtract(highOrder.getPayPrice())); + // 变更后金额 + BigDecimal afterAmount = apiMerchants.getAmounts(); + + apiMerchantsService.updateApiMerchants(apiMerchants); + + ApiAmountRecord apiAmountRecord = new ApiAmountRecord(); + + apiAmountRecord.setCreateTime(new Date()); + apiAmountRecord.setUpdateTime(new Date()); + apiAmountRecord.setMchId(apiMerchants.getMchId()); + + apiAmountRecord.setStatus(100); + apiAmountRecord.setAmount(highOrder.getPayPrice()); + apiAmountRecord.setAfterAmount(afterAmount); + apiAmountRecord.setBeforeAmount(beforeAmount); + apiAmountRecord.setAmountType(2); + apiAmountRecord.setSourceType(object.getInteger("sourceType")); + apiAmountRecord.setSourceOrderNo(object.getString("sourceOrderNo")); + apiAmountRecord.setSourceId(apiMerchants.getId()); + apiAmountRecord.setSourceContent(object.getString("content")); + + apiAmountRecordService.insertAmountRecord(apiAmountRecord); + + return apiAmountRecord; } } 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..2207786b 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 @@ -11,6 +11,7 @@ import com.hai.common.security.AESEncodeUtil; import com.hai.common.utils.*; import com.hai.config.*; import com.hai.dao.HighGasOrderPushMapper; +import com.hai.dao.HighOrderMapper; import com.hai.dao.OutRechargeOrderMapper; import com.hai.dao.OutRechargeOrderMapperExt; import com.hai.entity.*; @@ -101,9 +102,6 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { @Resource private ApiMerchantsService apiMerchantsService; - @Resource - private HighGoldRecService highGoldRecService; - @Resource private ApiAmountRecordService apiAmountRecordService; @@ -996,4 +994,9 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { return outRechargeOrderMapper.integralRebateRechargeOrder(); } + @Override + public List getApiRechargePhoneByList(Map map) { + return outRechargeOrderMapper.getApiRechargePhoneByList(map); + } + } diff --git a/v1/src/main/java/com/v1/controller/ApiMerchantsController.java b/v1/src/main/java/com/v1/controller/ApiMerchantsController.java index bf70a102..ac87d7f7 100644 --- a/v1/src/main/java/com/v1/controller/ApiMerchantsController.java +++ b/v1/src/main/java/com/v1/controller/ApiMerchantsController.java @@ -37,6 +37,9 @@ public class ApiMerchantsController { @Resource private SecConfigService secConfigService; + @Resource + private ApiIpAddressService apiIpAddressService; + @RequestMapping(value = "/checkAccountBalance", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "查询帐户余额") @@ -51,7 +54,7 @@ public class ApiMerchantsController { ip = request.getHeader("x-forwarded-for"); } - if (!secConfigService.isConfig("IP_WHITE" , ip)) { + if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); } diff --git a/v1/src/main/java/com/v1/controller/ApiOrderController.java b/v1/src/main/java/com/v1/controller/ApiOrderController.java index 4acee2d9..b8680ba6 100644 --- a/v1/src/main/java/com/v1/controller/ApiOrderController.java +++ b/v1/src/main/java/com/v1/controller/ApiOrderController.java @@ -45,6 +45,9 @@ public class ApiOrderController { @Resource private ApiOpenService apiOpenService; + @Resource + private ApiIpAddressService apiIpAddressService; + @RequestMapping(value = "/createOrder", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "充值预下单") @@ -59,8 +62,8 @@ public class ApiOrderController { ip = request.getHeader("x-forwarded-for"); } - if (!secConfigService.isConfig("IP_WHITE" , ip)) { - log.error("createOrder error!", "非法ip地址,请联系管理人员!"); + if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { + log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); } diff --git a/v1/src/main/java/com/v1/controller/HighOrderController.java b/v1/src/main/java/com/v1/controller/HighOrderController.java index 59f3ad4b..f7f9102b 100644 --- a/v1/src/main/java/com/v1/controller/HighOrderController.java +++ b/v1/src/main/java/com/v1/controller/HighOrderController.java @@ -52,6 +52,9 @@ public class HighOrderController { @Resource private HighOrderService highOrderService; + @Resource + private ApiIpAddressService apiIpAddressService; + @RequestMapping(value = "/getCallOrderList", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "获取话费订单列表") @@ -66,7 +69,7 @@ public class HighOrderController { ip = request.getHeader("x-forwarded-for"); } - if (!secConfigService.isConfig("IP_WHITE" , ip)) { + if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); } @@ -134,7 +137,7 @@ public class HighOrderController { ip = request.getHeader("x-forwarded-for"); } - if (!secConfigService.isConfig("IP_WHITE" , ip)) { + if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); } diff --git a/v1/src/main/java/com/v1/controller/RechargeProductController.java b/v1/src/main/java/com/v1/controller/RechargeProductController.java index cb10fab6..5f0f3bad 100644 --- a/v1/src/main/java/com/v1/controller/RechargeProductController.java +++ b/v1/src/main/java/com/v1/controller/RechargeProductController.java @@ -57,6 +57,9 @@ public class RechargeProductController { @Resource private ApiOpenService apiOpenService; + @Resource + private ApiIpAddressService apiIpAddressService; + @RequestMapping(value = "/getRechargeProduct", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "获取充值产品") @@ -71,7 +74,7 @@ public class RechargeProductController { ip = request.getHeader("x-forwarded-for"); } - if (!secConfigService.isConfig("IP_WHITE" , ip)) { + if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); } @@ -131,11 +134,12 @@ public class RechargeProductController { ip = request.getHeader("x-forwarded-for"); } - if (!secConfigService.isConfig("IP_WHITE" , ip)) { + if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); } + if (StringUtils.isBlank(object.getString("apiKey")) || StringUtils.isBlank(object.getString("timetable")) || StringUtils.isBlank(object.getString("merchId")) || @@ -210,16 +214,17 @@ public class RechargeProductController { ip = request.getHeader("x-forwarded-for"); } - if (!secConfigService.isConfig("IP_WHITE" , ip)) { - log.error("createOrder error!", "非法ip地址,请联系管理人员!"); + if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { + log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); } + if (StringUtils.isBlank(object.getString("mobile")) || StringUtils.isBlank(object.getString("apiConfigProductId")) || StringUtils.isBlank(object.getString("apiKey")) || StringUtils.isBlank(object.getString("timetable")) || - StringUtils.isBlank(object.getString("orderNo")) || + StringUtils.isBlank(object.getString("sourceOrderNo")) || StringUtils.isBlank(object.getString("notifyUrl")) || StringUtils.isBlank(object.getString("sign")) || StringUtils.isBlank(object.getString("merchId")) @@ -247,11 +252,16 @@ public class RechargeProductController { throw ErrorHelp.genException(SysCode.System, ErrorCode.PRODUCT_ERROR); } + if (apiProductConfig.getStatus() == 102) { + log.error("createOrder error!", " 商品状态错误!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR , "商品状态错误"); + } + Map map = new HashMap<>(); map.put("mobile" , object.getString("mobile")); map.put("apiConfigProductId" , object.getString("apiConfigProductId")); map.put("timetable" , object.getString("timetable")); - map.put("orderNo" , object.getString("orderNo")); + map.put("sourceOrderNo" , object.getString("sourceOrderNo")); map.put("notifyUrl" , object.getString("notifyUrl")); map.put("apiKey" , object.getString("apiKey")); map.put("merchId" , object.getString("merchId")); @@ -266,6 +276,11 @@ public class RechargeProductController { throw ErrorHelp.genException(SysCode.System, ErrorCode.TIME_OUT); } + if (!secConfigService.isConfig("PHONE_CONFIG" , object.getString("merchId"))) { + log.error("getAllCities error!", "当前帐户无权限查询!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOT_AUTHORIZED, "当前帐户无权限查询!"); + } + apiOpenService.createOrder(object , apiMerchants , apiProductConfig); return ResponseMsgUtil.success("下单成功"); diff --git a/v1/src/main/java/com/v1/controller/SelfOilStationController.java b/v1/src/main/java/com/v1/controller/SelfOilStationController.java index 70622e40..a80aaf14 100644 --- a/v1/src/main/java/com/v1/controller/SelfOilStationController.java +++ b/v1/src/main/java/com/v1/controller/SelfOilStationController.java @@ -46,6 +46,9 @@ public class SelfOilStationController { @Resource private HighOrderService highOrderService; + @Resource + private ApiIpAddressService apiIpAddressService; + @RequestMapping(value = "/getSelfOilStationOrderList", method = RequestMethod.POST) @@ -62,7 +65,7 @@ public class SelfOilStationController { ip = request.getHeader("x-forwarded-for"); } - if (!secConfigService.isConfig("IP_WHITE" , ip)) { + if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); } diff --git a/v1/src/main/java/com/v1/controller/ThirdPartyController.java b/v1/src/main/java/com/v1/controller/ThirdPartyController.java index 93138758..722434fb 100644 --- a/v1/src/main/java/com/v1/controller/ThirdPartyController.java +++ b/v1/src/main/java/com/v1/controller/ThirdPartyController.java @@ -135,7 +135,7 @@ public class ThirdPartyController { ip = request.getHeader("x-forwarded-for"); } - if (!secConfigService.isConfig("IP_WHITE" , ip)) { + if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); } @@ -202,7 +202,7 @@ public class ThirdPartyController { ip = request.getHeader("x-forwarded-for"); } - if (!secConfigService.isConfig("IP_WHITE" , ip)) { + if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); } @@ -277,7 +277,7 @@ public class ThirdPartyController { ip = request.getHeader("x-forwarded-for"); } - if (!secConfigService.isConfig("IP_WHITE" , ip)) { + if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); } @@ -337,7 +337,7 @@ public class ThirdPartyController { ip = request.getHeader("x-forwarded-for"); } - if (!secConfigService.isConfig("IP_WHITE" , ip)) { + if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); } @@ -425,7 +425,7 @@ public class ThirdPartyController { ip = request.getHeader("x-forwarded-for"); } - if (!secConfigService.isConfig("IP_WHITE" , ip)) { + if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); } @@ -489,8 +489,8 @@ public class ThirdPartyController { ip = request.getHeader("x-forwarded-for"); } - if (!secConfigService.isConfig("IP_WHITE" , ip)) { - log.error("createOrder error!", "非法ip地址,请联系管理人员!"); + if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { + log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); } @@ -498,7 +498,7 @@ public class ThirdPartyController { StringUtils.isBlank(object.getString("productType")) || StringUtils.isBlank(object.getString("apiKey")) || StringUtils.isBlank(object.getString("timetable")) || - StringUtils.isBlank(object.getString("orderNo")) || + StringUtils.isBlank(object.getString("sourceOrderNo")) || StringUtils.isBlank(object.getString("notifyUrl")) || StringUtils.isBlank(object.getString("sign")) || StringUtils.isBlank(object.getString("merchId")) @@ -514,15 +514,11 @@ public class ThirdPartyController { throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_NOT_EXIST); } - Map productMap = new HashMap<>(); - - - Map map = new HashMap<>(); map.put("customerMobile" , object.getString("customerMobile")); map.put("productType" , object.getString("productType")); map.put("timetable" , object.getString("timetable")); - map.put("orderNo" , object.getString("orderNo")); + map.put("sourceOrderNo" , object.getString("sourceOrderNo")); map.put("notifyUrl" , object.getString("notifyUrl")); map.put("apiKey" , object.getString("apiKey")); map.put("merchId" , object.getString("merchId"));