diff --git a/bweb/src/main/java/com/bweb/controller/BsMerchantController.java b/bweb/src/main/java/com/bweb/controller/BsMerchantController.java index f873a58..3c1917b 100644 --- a/bweb/src/main/java/com/bweb/controller/BsMerchantController.java +++ b/bweb/src/main/java/com/bweb/controller/BsMerchantController.java @@ -154,6 +154,30 @@ public class BsMerchantController { } } + @RequestMapping(value = "/listShow", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "列表展示") + public ResponseData listShow(@RequestBody JSONObject body) { + try { + if (body == null || StringUtils.isBlank(body.getString("merNo"))) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + // 查询商户 + BsMerchant merchant = merchantService.getMerchant(body.getString("merNo")); + if (merchant == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的商户"); + } + merchant.setListShow(!merchant.getListShow()); + merchantService.updateMerchant(merchant); + + return ResponseMsgUtil.success("操作成功"); + + } catch (Exception e) { + log.error("BsMerchantController --> listShow() error!", e); + return ResponseMsgUtil.exception(e); + } + } + @RequestMapping(value = "/disableMer", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "禁用商户") @@ -234,6 +258,9 @@ public class BsMerchantController { public ResponseData queryMerList(@RequestParam(value = "sourceType", required = false) Integer sourceType, @RequestParam(value = "merNo", required = false) String merNo, @RequestParam(value = "merName", required = false) String merName, + @RequestParam(value = "provinceCode", required = false) String provinceCode, + @RequestParam(value = "cityCode", required = false) String cityCode, + @RequestParam(value = "areaCode", required = false) String areaCode, @RequestParam(value = "pageNum", required = true) Integer pageNum, @RequestParam(value = "pageSize", required = true) Integer pageSize) { try { @@ -241,6 +268,9 @@ public class BsMerchantController { map.put("sourceType", sourceType); map.put("merNo", merNo); map.put("merName", merName); + map.put("provinceCode", provinceCode); + map.put("cityCode", cityCode); + map.put("areaCode", areaCode); PageHelper.startPage(pageNum,pageSize); return ResponseMsgUtil.success(new PageInfo<>(merchantService.getMerchantList(map))); diff --git a/cweb/src/main/java/com/cweb/controller/BsGasController.java b/cweb/src/main/java/com/cweb/controller/BsGasController.java index 494a619..971031b 100644 --- a/cweb/src/main/java/com/cweb/controller/BsGasController.java +++ b/cweb/src/main/java/com/cweb/controller/BsGasController.java @@ -5,6 +5,7 @@ import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.hfkj.channel.gas.newlink.NewLinkGasService; import com.hfkj.channel.gas.newlink.NewLinkRequestService; +import com.hfkj.channel.gas.shell.CqShellPetroleumGasService; import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.SysCode; @@ -39,13 +40,16 @@ public class BsGasController { private BsAgentPriceService agentPriceService; @Resource private NewLinkGasService newLinkGasService; + @Resource + private CqShellPetroleumGasService cqShellPetroleumGasService; @RequestMapping(value="/refresh",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "refresh") public ResponseData refresh() { try { - newLinkGasService.refresh(); + // newLinkGasService.refresh(); + cqShellPetroleumGasService.refresh(); return ResponseMsgUtil.success(""); @@ -99,7 +103,7 @@ public class BsGasController { try { PageHelper.startPage(pageNum,pageSize); - PageInfo pageInfo = new PageInfo<>(gasService.getGasList(longitude, latitude, oilNo, gasName, distanceLimit)); + PageInfo pageInfo = new PageInfo<>(gasService.getGasList(longitude, latitude, oilNo, gasName, distanceLimit, true)); for (GasListModel gas : pageInfo.getList()) { BigDecimal discount = new BigDecimal("100"); diff --git a/cweb/src/main/java/com/cweb/controller/order/OrderPayController.java b/cweb/src/main/java/com/cweb/controller/order/OrderPayController.java index df8478f..dcf57b0 100644 --- a/cweb/src/main/java/com/cweb/controller/order/OrderPayController.java +++ b/cweb/src/main/java/com/cweb/controller/order/OrderPayController.java @@ -101,9 +101,10 @@ public class OrderPayController { payMerKey = merPay.getChannelMerKey(); ledgerAccountFlag = merPay.getLedgerAccountFlag(); - } else if (merchant.getSourceType().equals(MerchantSourceTypeEnum.type2.getNumber())) { + } else if (merchant.getSourceType().equals(MerchantSourceTypeEnum.type2.getNumber()) + || merchant.getSourceType().equals(MerchantSourceTypeEnum.type3.getNumber())) { // 查询渠道支付配置 - BsGasChannelConfig payConfig = gasChannelConfigService.getDetail(MerchantSourceTypeEnum.type2); + BsGasChannelConfig payConfig = gasChannelConfigService.getDetail(MerchantSourceTypeEnum.getDataByType(merchant.getSourceType())); if (payConfig == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "商户未配置支付"); } diff --git a/service/src/main/java/com/hfkj/channel/gas/newlink/NewLinkGasService.java b/service/src/main/java/com/hfkj/channel/gas/newlink/NewLinkGasService.java index 8aabae2..cd93a73 100644 --- a/service/src/main/java/com/hfkj/channel/gas/newlink/NewLinkGasService.java +++ b/service/src/main/java/com/hfkj/channel/gas/newlink/NewLinkGasService.java @@ -47,6 +47,10 @@ public class NewLinkGasService { @Resource private BsGasOilGunNoService gasOilGunNoService; + /** + * 刷取全量油站 + * @throws Exception + */ public void refresh() throws Exception { // 最新全量加油站数据 List gasDataList = new ArrayList<>(); diff --git a/service/src/main/java/com/hfkj/channel/gas/shell/CqShellPetroleumGasService.java b/service/src/main/java/com/hfkj/channel/gas/shell/CqShellPetroleumGasService.java new file mode 100644 index 0000000..324edbe --- /dev/null +++ b/service/src/main/java/com/hfkj/channel/gas/shell/CqShellPetroleumGasService.java @@ -0,0 +1,282 @@ +package com.hfkj.channel.gas.shell; + +import com.alibaba.excel.util.CollectionUtils; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import com.hfkj.channel.gas.newlink.NewLinkRequestService; +import com.hfkj.entity.BsGasOilGunNo; +import com.hfkj.entity.BsGasOilPrice; +import com.hfkj.entity.BsMerchant; +import com.hfkj.service.gas.BsGasOilGunNoService; +import com.hfkj.service.gas.BsGasOilPriceService; +import com.hfkj.service.gas.BsGasService; +import com.hfkj.service.merchant.BsMerchantService; +import com.hfkj.sysenum.MerchantSourceTypeEnum; +import com.hfkj.sysenum.MerchantStatusEnum; +import com.hfkj.sysenum.gas.GasOilPriceStatusEnum; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; +import java.util.stream.Collectors; + +/** + * 重庆壳牌油站服务 + * @className: CqShellPetroleumService + * @author: HuRui + * @date: 2024/7/22 + **/ +@Component +public class CqShellPetroleumGasService { + + @Resource + private BsMerchantService merchantService; + @Resource + private BsGasService gasService; + @Resource + private BsGasOilPriceService gasOilPriceService; + @Resource + private BsGasOilGunNoService gasOilGunNoService; + + /** + * 刷取全量油站 + * @throws Exception + */ + public void refresh() throws Exception { + // 最新全量加油站数据 + List gasDataList = new ArrayList<>(); + // 初始化页数 + Integer totalPageNum = 3; + // 每页数量 + Integer pageSize = 50; + for (int pageIndex = 1; pageIndex <= totalPageNum;pageIndex++) { + // 查询油站 + JSONObject object = CqShellPetroleumRequestService.gasPageQueryAllStation(pageIndex, pageSize); + // 总页数 + JSONObject pageInfo = JSONObject.parseObject(object.getString("pageInfo")); + totalPageNum = (pageInfo.getInteger("totalCount") + pageSize - 1) / pageSize; + // 加入全量数据集合 + gasDataList.addAll(JSONArray.parseArray(object.getString("infoList"))); + } + // 设备核心数目 + int processorsNum = Runtime.getRuntime().availableProcessors(); + + Long startTime = System.currentTimeMillis(); + System.out.println("本次更新任务开始"); + System.out.println("重庆壳牌"); + // 初始化线程池 + ThreadPoolExecutor threadPool = new ThreadPoolExecutor( + processorsNum * 2, + processorsNum * 2, + 4, + TimeUnit.SECONDS, + new ArrayBlockingQueue(processorsNum * 2 * 10), + new ThreadPoolExecutor.DiscardPolicy()); + + // 大集合拆分成N个小集合,然后用多线程去处理数据,确保不会因为数据量过大导致执行过慢 + List> splitNList = splitList(gasDataList, 10); + // 记录单个任务的执行次数 + CountDownLatch countDownLatch = new CountDownLatch(splitNList.size()); + // 对拆分的集合进行批量处理, 先拆分的集合, 再多线程执行 + for (List singleList : splitNList) { + // 线程池执行 + threadPool.execute(new Thread(new Runnable(){ + @Override + public void run() { + //模拟执行时间 + System.out.println("当前线程:"+Thread.currentThread().getName()); + try { + for (Object obj : singleList) { + try { + //组装要执行的批量更新数据 + JSONObject gasData = (JSONObject) obj; + // 查询商户 + BsMerchant merchant = merchantService.getMerchant(gasData.getString("stationCode")); + if (merchant == null) { + merchant = new BsMerchant(); + merchant.setStatus(MerchantStatusEnum.status1.getNumber()); + } + merchant.setSourceType(MerchantSourceTypeEnum.type3.getNumber()); + merchant.setProvinceCode(gasData.getLong("provinceId")); + merchant.setProvinceName(gasData.getString("provinceName")); + merchant.setCityCode(gasData.getLong("cityId")); + merchant.setCityName(gasData.getString("cityName")); + merchant.setAreaCode(gasData.getLong("districtId")); + merchant.setAreaName(gasData.getString("districtName")); + merchant.setMerNo(gasData.getString("stationCode")); + merchant.setMerName(gasData.getString("stationName")); + merchant.setMerLogo("https://oil.dctpay.com/filesystem/gas_logo_default.jpg"); + merchant.setAddress(gasData.getString("stationAddress")); + merchant.setLongitude(gasData.getString("longitude")); + merchant.setLatitude(gasData.getString("latitude")); + merchant.setContactsName(merchant.getMerName()); + merchant.setContactsTel(merchant.getMerNo()); + merchant.setCustomerServiceTel("400-0236806"); + merchant.setMerLabel(null); + if (merchant.getId() == null) { + merchantService.createMerchant(merchant); + } else { + merchantService.updateMerchant(merchant); + } + + // 查询油站油价 + List gasOilPriceList = gasOilPriceService.getGasOilPriceList(merchant.getId()); + if (!gasOilPriceList.isEmpty()) { + BsGasOilPrice oilPriceExample = new BsGasOilPrice(); + oilPriceExample.setStatus(GasOilPriceStatusEnum.status2.getNumber()); + gasOilPriceService.batchUpdate(merchant.getMerNo(), oilPriceExample); + } + // 查询油站抢号 + List oilGunNoList = gasOilGunNoService.getOilGunNoList(merchant.getMerNo()); + for (BsGasOilGunNo gunNo : oilGunNoList) { + gunNo.setStatus(0); + } + + JSONArray oilPriceList = gasData.getJSONArray("oilPriceList"); + for (Object oilPrice : oilPriceList) { + JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); + // 查询油站油价 + List oilPriceCollect = gasOilPriceList.stream().filter(o -> o.getOilNo().equals(oilPriceObject.getString("goodsCode"))).collect(Collectors.toList()); + BsGasOilPrice gasOilPrice = null; + if (oilPriceCollect.isEmpty()) { + gasOilPrice = new BsGasOilPrice(); + gasOilPrice.setMerId(merchant.getId()); + gasOilPrice.setMerNo(merchant.getMerNo()); + gasOilPrice.setOilNo(oilPriceObject.getString("goodsCode")); + gasOilPrice.setOilNoName(oilPriceObject.getString("goodsCode")+"#"); + gasOilPrice.setStatus(GasOilPriceStatusEnum.status1.getNumber()); + // 油品类型 1:汽油:2:柴油;3:天然气 + if (oilPriceObject.getString("goodsGroupType").equals("GASOLINE")) { + gasOilPrice.setOilType(1); + gasOilPrice.setOilTypeName("汽油"); + } else if (oilPriceObject.getString("goodsGroupType").equals("DIESEL_OIL")) { + gasOilPrice.setOilType(2); + gasOilPrice.setOilTypeName("柴油"); + } else if (oilPriceObject.getString("goodsGroupType").equals("NATURAL_GAS")) { + gasOilPrice.setOilType(3); + gasOilPrice.setOilTypeName("天然气"); + } + } else { + gasOilPrice = oilPriceCollect.get(0); + gasOilPrice.setStatus(GasOilPriceStatusEnum.status1.getNumber()); + } + // 平台优惠 + gasOilPrice.setPreferentialMargin(new BigDecimal("0")); + gasOilPrice.setPriceCost(oilPriceObject.getJSONObject("goodsPrice").getBigDecimal("amount")); + gasOilPrice.setPriceVip(gasOilPrice.getPriceCost()); + gasOilPrice.setPriceGun(gasOilPrice.getPriceCost()); + gasOilPrice.setPriceOfficial(oilPriceObject.getJSONObject("listedPrice").getBigDecimal("amount")); + // 国标价 - 油站价 = 油站直降 + gasOilPrice.setGasStationDrop(gasOilPrice.getPriceOfficial().subtract(gasOilPrice.getPriceCost())); + gasOilPriceService.editOilPrice(gasOilPrice); + + for (Object gunNo : oilPriceObject.getJSONArray("oilGunNoList")) { + // 查询抢号 + List gunNoCollect = oilGunNoList.stream() + .filter(o -> o.getOilNo().equals(oilPriceObject.getString("goodsCode")) && o.getGunNo().equals(gunNo.toString())) + .collect(Collectors.toList()); + // 如果没有找到抢号就新增一个 + BsGasOilGunNo gasOilGunNo = null; + if (gunNoCollect.isEmpty()) { + gasOilGunNo = new BsGasOilGunNo(); + gasOilGunNo.setGasOilPriceId(gasOilPrice.getId()); + gasOilGunNo.setMerId(gasOilPrice.getMerId()); + gasOilGunNo.setMerNo(gasOilPrice.getMerNo()); + gasOilGunNo.setOilNo(gasOilPrice.getOilNo()); + gasOilGunNo.setOilNoName(gasOilPrice.getOilNoName()); + gasOilGunNo.setOilType(gasOilPrice.getOilType()); + gasOilGunNo.setOilTypeName(gasOilPrice.getOilTypeName()); + gasOilGunNo.setGunNo(gunNo.toString()); + gasOilGunNo.setStatus(1); + gasOilGunNo.setCreateTime(new Date()); + oilGunNoList.add(gasOilGunNo); + } else { + gasOilGunNo = gunNoCollect.get(0); + gasOilGunNo.setStatus(1); + } + } + } + + // 添加 + gasOilGunNoService.batchInsert(oilGunNoList.stream().filter(o-> o.getId() == null).collect(Collectors.toList())); + // 更新 + gasOilGunNoService.batchUpdate(oilGunNoList.stream().filter(o-> o.getId() != null && o.getStatus().equals(0)).collect(Collectors.toList())); + // 删除缓存 + gasOilGunNoService.cleanCache(merchant.getMerNo()); + // 清除油站缓存 + gasService.clean(merchant.getMerNo()); + } catch (Exception e) { + System.out.println("更新油站失败"); + } + } + + } catch (Exception e) { + System.out.println("更新油站出现异常"); + System.out.println(e.getMessage()); + } finally { + // 任务个数 - 1, 直至为0时唤醒await() + countDownLatch.countDown(); + } + } + })); + } + try { + // 让当前线程处于阻塞状态,直到锁存器计数为零 + countDownLatch.await(); + } catch (Exception e) { + System.out.println("系统出现异常"); + } + Long endTime = System.currentTimeMillis(); + Long useTime = endTime - startTime; + System.out.println("本次更新任务结束,共计用时"+useTime+"毫秒"); + } + + /** + * 拆分集合 + * + * @param 泛型对象 + * @param resList 需要拆分的集合 + * @param subListLength 每个子集合的元素个数 + * @return 返回拆分后的各个集合组成的列表 + **/ + public static List> splitList(List resList, int subListLength) { + if (CollectionUtils.isEmpty(resList) || subListLength <= 0) { + return new ArrayList<>(); + } + List> ret = new ArrayList<>(); + int size = resList.size(); + if (size <= subListLength) { + // 数据量不足 subListLength 指定的大小 + ret.add(resList); + } else { + int pre = size / subListLength; + int last = size % subListLength; + // 前面pre个集合,每个大小都是 subListLength 个元素 + for (int i = 0; i < pre; i++) { + List itemList = new ArrayList<>(subListLength); + for (int j = 0; j < subListLength; j++) { + itemList.add(resList.get(i * subListLength + j)); + } + ret.add(itemList); + } + + // last的进行处理 + if (last > 0) { + List itemList = new ArrayList<>(last); + for (int i = 0; i < last; i++) { + itemList.add(resList.get(pre * subListLength + i)); + } + ret.add(itemList); + } + } + return ret; + } +} diff --git a/service/src/main/java/com/hfkj/channel/gas/shell/CqShellPetroleumRequestService.java b/service/src/main/java/com/hfkj/channel/gas/shell/CqShellPetroleumRequestService.java new file mode 100644 index 0000000..2fcdd9e --- /dev/null +++ b/service/src/main/java/com/hfkj/channel/gas/shell/CqShellPetroleumRequestService.java @@ -0,0 +1,194 @@ +package com.hfkj.channel.gas.shell; + +import com.alibaba.fastjson.JSONObject; +import com.hfkj.common.exception.ErrorCode; +import com.hfkj.common.exception.ErrorHelp; +import com.hfkj.common.exception.SysCode; +import com.hfkj.common.utils.DateUtil; +import com.hfkj.common.utils.HttpsUtils; +import com.hfkj.common.utils.MD5Util; +import com.hfkj.config.CommonSysConst; +import org.apache.commons.lang3.StringUtils; + +import java.math.BigDecimal; +import java.util.*; + +/** + * 重庆壳牌请求 + * @className: CqShellPetroleumConfig + * @author: HuRui + * @date: 2024/7/22 + **/ +public class CqShellPetroleumRequestService { + + /** + * 请求地址 + */ + private final static String REQ_URL = CommonSysConst.getSysConfig().getCqShellReqUrl(); + /** + * 壳牌合作伙伴id + */ + private final static String PARTNER_ID = CommonSysConst.getSysConfig().getCqShellPartnerId(); + /** + * 平台商id + */ + private final static String PLAT_MERCHANT_ID = CommonSysConst.getSysConfig().getCqShellPlatMerchantId(); + /** + * 平台商key + */ + private final static String PLAT_MERCHANT_KEY = CommonSysConst.getSysConfig().getCqShellPlatMerchantKey(); + + /** + * 查询全量加油站 + * @param pageNum 当前页码 + * @param pageSize 每页数据量。最大值50 + * @return + */ + public static JSONObject gasPageQueryAllStation(Integer pageNum, Integer pageSize) throws Exception { + Map param = new HashMap<>(); + param.put("platMerchantId", PLAT_MERCHANT_ID); + param.put("pageNo", pageNum); + param.put("pageSize", pageSize); + return request(System.currentTimeMillis()+"","gasPageQueryAllStation", param); + } + + /** + * 查询单个油站全量信息 + * @param stationCode 油站编码 + * @return + */ + public static JSONObject gasStationQueryDetail(String stationCode) { + try { + Map param = new HashMap<>(); + param.put("platMerchantId", PLAT_MERCHANT_ID); + param.put("stationCode", stationCode); + return request(System.currentTimeMillis()+"","gasPageQueryAllStation", param); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + + /** + * 【同步】油站付款 + * @param orderNo 订单号 + * @param stationCode 油站编码 + * @param finishTime 完成时间 + * @param oilPrice 加油金额 + * @param oilCode 油品编码 + * @param oilGun 油枪 + * @param settlementAmount 支付金额 + * @param channelFavourAmount 优惠金额 + * @return + */ + public static JSONObject gasSyncPayment(String orderNo, + String stationCode, + Date finishTime, + BigDecimal oilPrice, + String oilCode, + String oilGun, + BigDecimal settlementAmount, + BigDecimal channelFavourAmount) throws Exception { + Map param = new HashMap<>(); + param.put("platMerchantId", PLAT_MERCHANT_ID); + param.put("stationCode", stationCode); + param.put("orderType", "OIL"); + param.put("finishTime", DateUtil.date2String(finishTime, "yyyy-MM-dd HH:mm:ss")); + param.put("channelFavourAmount", channelFavourAmount); + + Map tradeOilOrder = new HashMap<>(); + tradeOilOrder.put("amount", oilPrice); + tradeOilOrder.put("code", oilCode); + tradeOilOrder.put("oilGun", oilGun); + tradeOilOrder.put("channelSettlementAmount", settlementAmount); + param.put("tradeOilOrder", JSONObject.toJSONString(tradeOilOrder)); + return request(orderNo, "gas_sync_payment_notify", param); + } + + /** + * 【同步】油站退款 + * @param finishTime 业务完成时间 + * @param tradeNo 交易流水号 + * @return + */ + public static JSONObject gasSyncRefund(Date finishTime,String tradeNo) throws Exception { + Map param = new HashMap<>(); + param.put("platMerchantId", PLAT_MERCHANT_ID); + param.put("finishTime", DateUtil.date2String(finishTime, "yyyy-MM-dd HH:mm:ss")); + param.put("tradeNo", tradeNo.replace("HF","")); + // 请求接口 + return request(System.currentTimeMillis()+"" ,"gas_sync_refund_notify", param); + } + + /** + * 接口请求 + * @param map + * @return + * @throws Exception + */ + private static JSONObject request(String logSerialNo, String service, Map map) throws Exception { + Map param = new HashMap<>(); + param.put("merchantOrderNo", logSerialNo); + param.put("partnerId", PARTNER_ID); + param.put("service", service); + param.put("version", "1.0.0"); + param.put("signType", "MD5"); + + for (Map.Entry entry : map.entrySet()) { + param.put(entry.getKey(), entry.getValue()); + } + param.put("sign", MD5Util.encode(generateSignature(param, PLAT_MERCHANT_KEY).getBytes()).toLowerCase()); + // 请求接口 + JSONObject response = HttpsUtils.doPost(REQ_URL, param); + if (response == null || !response.getString("status").equals("SUCCESS")) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, response == null?"请求失败":response.getString("message")); + } + return response; + } + + /** + * 生成签名 + * @param data 数据 + * @param key 秘钥app_secret + * @return 加密结果 + */ + public static String generateSignature(final Map data, String key) { + Set keySet = data.keySet(); + String[] keyArray = keySet.toArray(new String[keySet.size()]); + Arrays.sort(keyArray); + StringBuilder sb = new StringBuilder(); + for (String k : keyArray) { + if (data.get(k) != null) { + if (StringUtils.isBlank(sb.toString())) { + sb.append(k).append("=").append(data.get(k)); + } else { + sb.append("&").append(k).append("=").append(data.get(k)); + } + } + } + sb.append(key); + return sb.toString(); + } + + /** + * 生成参数 + * @param data 数据 + * @return 加密结果 + */ + public static String generateParam(final Map data) { + Set keySet = data.keySet(); + String[] keyArray = keySet.toArray(new String[keySet.size()]); + StringBuilder sb = new StringBuilder(); + for (String k : keyArray) { + if (data.get(k) != null) { + if (StringUtils.isBlank(sb.toString())) { + sb.append(k).append("=").append(data.get(k)); + } else { + sb.append("&").append(k).append("=").append(data.get(k)); + } + } + } + return sb.toString(); + } +} diff --git a/service/src/main/java/com/hfkj/config/CommonSysConfig.java b/service/src/main/java/com/hfkj/config/CommonSysConfig.java index 72e9a16..51e2934 100644 --- a/service/src/main/java/com/hfkj/config/CommonSysConfig.java +++ b/service/src/main/java/com/hfkj/config/CommonSysConfig.java @@ -36,6 +36,25 @@ public class CommonSysConfig { * 能链【团油】AppSecret */ private String newLinkAppSecret; + + /** + * 加好油【重庆壳牌】请求地址 + */ + private String cqShellReqUrl; + /** + * 加好油【重庆壳牌】壳牌合作伙伴id + */ + private String cqShellPartnerId; + /** + * 加好油【重庆壳牌】平台商id + */ + private String cqShellPlatMerchantId; + /** + * 加好油【重庆壳牌】平台商key + */ + private String cqShellPlatMerchantKey; + + /** * 【惠支付】支付渠道回调地址 */ diff --git a/service/src/main/java/com/hfkj/dao/BsMerchantMapper.java b/service/src/main/java/com/hfkj/dao/BsMerchantMapper.java index ceb40d9..899c255 100644 --- a/service/src/main/java/com/hfkj/dao/BsMerchantMapper.java +++ b/service/src/main/java/com/hfkj/dao/BsMerchantMapper.java @@ -48,9 +48,10 @@ public interface BsMerchantMapper extends BsMerchantMapperExt { "contacts_name, contacts_tel, ", "customer_service_tel, address, ", "longitude, latitude, ", - "mer_label, `status`, ", - "create_time, update_time, ", - "ext_1, ext_2, ext_3)", + "mer_label, list_show, ", + "`status`, create_time, ", + "update_time, ext_1, ", + "ext_2, ext_3)", "values (#{sourceType,jdbcType=INTEGER}, #{provinceCode,jdbcType=BIGINT}, ", "#{provinceName,jdbcType=VARCHAR}, #{cityCode,jdbcType=BIGINT}, ", "#{cityName,jdbcType=VARCHAR}, #{areaCode,jdbcType=BIGINT}, ", @@ -60,9 +61,10 @@ public interface BsMerchantMapper extends BsMerchantMapperExt { "#{contactsName,jdbcType=VARCHAR}, #{contactsTel,jdbcType=VARCHAR}, ", "#{customerServiceTel,jdbcType=VARCHAR}, #{address,jdbcType=VARCHAR}, ", "#{longitude,jdbcType=VARCHAR}, #{latitude,jdbcType=VARCHAR}, ", - "#{merLabel,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, ", - "#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, ", - "#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" + "#{merLabel,jdbcType=VARCHAR}, #{listShow,jdbcType=BIT}, ", + "#{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ", + "#{updateTime,jdbcType=TIMESTAMP}, #{ext1,jdbcType=VARCHAR}, ", + "#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" }) @Options(useGeneratedKeys=true,keyProperty="id") int insert(BsMerchant record); @@ -93,6 +95,7 @@ public interface BsMerchantMapper extends BsMerchantMapperExt { @Result(column="longitude", property="longitude", jdbcType=JdbcType.VARCHAR), @Result(column="latitude", property="latitude", jdbcType=JdbcType.VARCHAR), @Result(column="mer_label", property="merLabel", jdbcType=JdbcType.VARCHAR), + @Result(column="list_show", property="listShow", jdbcType=JdbcType.BIT), @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP), @@ -107,7 +110,7 @@ public interface BsMerchantMapper extends BsMerchantMapperExt { "id, source_type, province_code, province_name, city_code, city_name, area_code, ", "area_name, oil_price_zone_id, oil_price_zone_name, mer_no, mer_logo, mer_name, ", "contacts_name, contacts_tel, customer_service_tel, address, longitude, latitude, ", - "mer_label, `status`, create_time, update_time, ext_1, ext_2, ext_3", + "mer_label, list_show, `status`, create_time, update_time, ext_1, ext_2, ext_3", "from bs_merchant", "where id = #{id,jdbcType=BIGINT}" }) @@ -132,6 +135,7 @@ public interface BsMerchantMapper extends BsMerchantMapperExt { @Result(column="longitude", property="longitude", jdbcType=JdbcType.VARCHAR), @Result(column="latitude", property="latitude", jdbcType=JdbcType.VARCHAR), @Result(column="mer_label", property="merLabel", jdbcType=JdbcType.VARCHAR), + @Result(column="list_show", property="listShow", jdbcType=JdbcType.BIT), @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP), @@ -171,6 +175,7 @@ public interface BsMerchantMapper extends BsMerchantMapperExt { "longitude = #{longitude,jdbcType=VARCHAR},", "latitude = #{latitude,jdbcType=VARCHAR},", "mer_label = #{merLabel,jdbcType=VARCHAR},", + "list_show = #{listShow,jdbcType=BIT},", "`status` = #{status,jdbcType=INTEGER},", "create_time = #{createTime,jdbcType=TIMESTAMP},", "update_time = #{updateTime,jdbcType=TIMESTAMP},", diff --git a/service/src/main/java/com/hfkj/dao/BsMerchantMapperExt.java b/service/src/main/java/com/hfkj/dao/BsMerchantMapperExt.java index 2feadbf..ddc1986 100644 --- a/service/src/main/java/com/hfkj/dao/BsMerchantMapperExt.java +++ b/service/src/main/java/com/hfkj/dao/BsMerchantMapperExt.java @@ -26,7 +26,8 @@ public interface BsMerchantMapperExt { " a.price_official priceOfficial," + " a.price_gun priceGun," + " a.price_vip priceVip," + - " a.gas_station_drop gasStationDrop" + + " a.gas_station_drop gasStationDrop," + + " b.list_show listShow" + " FROM" + " bs_gas_oil_price a" + " LEFT JOIN bs_merchant b on b.id = a.mer_id" + @@ -34,10 +35,13 @@ public interface BsMerchantMapperExt { " ORDER BY distance asc) a where 1 = 1" + " and a.merName like concat('%',#{gasName},'%') " + " " + + " " + + " and a.listShow = #{listShow} " + "") List queryGasList(@Param("longitude") String longitude, @Param("latitude") String latitude, @Param("oilNo") String oilNo, @Param("gasName") String gasName, - @Param("distanceLimit") Integer distanceLimit); + @Param("distanceLimit") Integer distanceLimit, + @Param("listShow") Boolean listShow); } diff --git a/service/src/main/java/com/hfkj/dao/BsMerchantSqlProvider.java b/service/src/main/java/com/hfkj/dao/BsMerchantSqlProvider.java index e82c194..3ab66c2 100644 --- a/service/src/main/java/com/hfkj/dao/BsMerchantSqlProvider.java +++ b/service/src/main/java/com/hfkj/dao/BsMerchantSqlProvider.java @@ -104,6 +104,10 @@ public class BsMerchantSqlProvider { sql.VALUES("mer_label", "#{merLabel,jdbcType=VARCHAR}"); } + if (record.getListShow() != null) { + sql.VALUES("list_show", "#{listShow,jdbcType=BIT}"); + } + if (record.getStatus() != null) { sql.VALUES("`status`", "#{status,jdbcType=INTEGER}"); } @@ -157,6 +161,7 @@ public class BsMerchantSqlProvider { sql.SELECT("longitude"); sql.SELECT("latitude"); sql.SELECT("mer_label"); + sql.SELECT("list_show"); sql.SELECT("`status`"); sql.SELECT("create_time"); sql.SELECT("update_time"); @@ -260,6 +265,10 @@ public class BsMerchantSqlProvider { sql.SET("mer_label = #{record.merLabel,jdbcType=VARCHAR}"); } + if (record.getListShow() != null) { + sql.SET("list_show = #{record.listShow,jdbcType=BIT}"); + } + if (record.getStatus() != null) { sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); } @@ -312,6 +321,7 @@ public class BsMerchantSqlProvider { sql.SET("longitude = #{record.longitude,jdbcType=VARCHAR}"); sql.SET("latitude = #{record.latitude,jdbcType=VARCHAR}"); sql.SET("mer_label = #{record.merLabel,jdbcType=VARCHAR}"); + sql.SET("list_show = #{record.listShow,jdbcType=BIT}"); sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); sql.SET("update_time = #{record.updateTime,jdbcType=TIMESTAMP}"); @@ -404,6 +414,10 @@ public class BsMerchantSqlProvider { sql.SET("mer_label = #{merLabel,jdbcType=VARCHAR}"); } + if (record.getListShow() != null) { + sql.SET("list_show = #{listShow,jdbcType=BIT}"); + } + if (record.getStatus() != null) { sql.SET("`status` = #{status,jdbcType=INTEGER}"); } diff --git a/service/src/main/java/com/hfkj/entity/BsMerchant.java b/service/src/main/java/com/hfkj/entity/BsMerchant.java index dce37db..80d8ca0 100644 --- a/service/src/main/java/com/hfkj/entity/BsMerchant.java +++ b/service/src/main/java/com/hfkj/entity/BsMerchant.java @@ -113,6 +113,11 @@ public class BsMerchant implements Serializable { */ private String merLabel; + /** + * 列表中展示 0:否 1:是 + */ + private Boolean listShow; + /** * 状态 0:删除 1:正常 2:禁用 */ @@ -296,6 +301,14 @@ public class BsMerchant implements Serializable { this.merLabel = merLabel; } + public Boolean getListShow() { + return listShow; + } + + public void setListShow(Boolean listShow) { + this.listShow = listShow; + } + public Integer getStatus() { return status; } @@ -376,6 +389,7 @@ public class BsMerchant implements Serializable { && (this.getLongitude() == null ? other.getLongitude() == null : this.getLongitude().equals(other.getLongitude())) && (this.getLatitude() == null ? other.getLatitude() == null : this.getLatitude().equals(other.getLatitude())) && (this.getMerLabel() == null ? other.getMerLabel() == null : this.getMerLabel().equals(other.getMerLabel())) + && (this.getListShow() == null ? other.getListShow() == null : this.getListShow().equals(other.getListShow())) && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) && (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime())) @@ -408,6 +422,7 @@ public class BsMerchant implements Serializable { result = prime * result + ((getLongitude() == null) ? 0 : getLongitude().hashCode()); result = prime * result + ((getLatitude() == null) ? 0 : getLatitude().hashCode()); result = prime * result + ((getMerLabel() == null) ? 0 : getMerLabel().hashCode()); + result = prime * result + ((getListShow() == null) ? 0 : getListShow().hashCode()); result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode()); @@ -443,6 +458,7 @@ public class BsMerchant implements Serializable { sb.append(", longitude=").append(longitude); sb.append(", latitude=").append(latitude); sb.append(", merLabel=").append(merLabel); + sb.append(", listShow=").append(listShow); sb.append(", status=").append(status); sb.append(", createTime=").append(createTime); sb.append(", updateTime=").append(updateTime); diff --git a/service/src/main/java/com/hfkj/entity/BsMerchantExample.java b/service/src/main/java/com/hfkj/entity/BsMerchantExample.java index 9822709..e1e43de 100644 --- a/service/src/main/java/com/hfkj/entity/BsMerchantExample.java +++ b/service/src/main/java/com/hfkj/entity/BsMerchantExample.java @@ -1465,6 +1465,66 @@ public class BsMerchantExample { return (Criteria) this; } + public Criteria andListShowIsNull() { + addCriterion("list_show is null"); + return (Criteria) this; + } + + public Criteria andListShowIsNotNull() { + addCriterion("list_show is not null"); + return (Criteria) this; + } + + public Criteria andListShowEqualTo(Boolean value) { + addCriterion("list_show =", value, "listShow"); + return (Criteria) this; + } + + public Criteria andListShowNotEqualTo(Boolean value) { + addCriterion("list_show <>", value, "listShow"); + return (Criteria) this; + } + + public Criteria andListShowGreaterThan(Boolean value) { + addCriterion("list_show >", value, "listShow"); + return (Criteria) this; + } + + public Criteria andListShowGreaterThanOrEqualTo(Boolean value) { + addCriterion("list_show >=", value, "listShow"); + return (Criteria) this; + } + + public Criteria andListShowLessThan(Boolean value) { + addCriterion("list_show <", value, "listShow"); + return (Criteria) this; + } + + public Criteria andListShowLessThanOrEqualTo(Boolean value) { + addCriterion("list_show <=", value, "listShow"); + return (Criteria) this; + } + + public Criteria andListShowIn(List values) { + addCriterion("list_show in", values, "listShow"); + return (Criteria) this; + } + + public Criteria andListShowNotIn(List values) { + addCriterion("list_show not in", values, "listShow"); + return (Criteria) this; + } + + public Criteria andListShowBetween(Boolean value1, Boolean value2) { + addCriterion("list_show between", value1, value2, "listShow"); + return (Criteria) this; + } + + public Criteria andListShowNotBetween(Boolean value1, Boolean value2) { + addCriterion("list_show not between", value1, value2, "listShow"); + return (Criteria) this; + } + public Criteria andStatusIsNull() { addCriterion("`status` is null"); return (Criteria) this; diff --git a/service/src/main/java/com/hfkj/service/gas/BsGasService.java b/service/src/main/java/com/hfkj/service/gas/BsGasService.java index 151291d..59d8b08 100644 --- a/service/src/main/java/com/hfkj/service/gas/BsGasService.java +++ b/service/src/main/java/com/hfkj/service/gas/BsGasService.java @@ -50,5 +50,5 @@ public interface BsGasService { * @param * @return */ - List getGasList(String longitude,String latitude,String oilNo,String gasName,Integer distanceLimit); + List getGasList(String longitude,String latitude,String oilNo,String gasName,Integer distanceLimit, Boolean listShow); } diff --git a/service/src/main/java/com/hfkj/service/gas/impl/BsGasServiceImpl.java b/service/src/main/java/com/hfkj/service/gas/impl/BsGasServiceImpl.java index 40bf017..af41f12 100644 --- a/service/src/main/java/com/hfkj/service/gas/impl/BsGasServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/gas/impl/BsGasServiceImpl.java @@ -184,8 +184,8 @@ public class BsGasServiceImpl implements BsGasService { } @Override - public List getGasList(String longitude, String latitude, String oilNo, String gasName, Integer distanceLimit) { - return merchantMapper.queryGasList(longitude,latitude,oilNo,gasName,distanceLimit); + public List getGasList(String longitude, String latitude, String oilNo, String gasName, Integer distanceLimit, Boolean listShow) { + return merchantMapper.queryGasList(longitude,latitude,oilNo,gasName,distanceLimit,listShow); } } diff --git a/service/src/main/java/com/hfkj/service/merchant/impl/BsMerchantServiceImpl.java b/service/src/main/java/com/hfkj/service/merchant/impl/BsMerchantServiceImpl.java index d415b7e..cfda86e 100644 --- a/service/src/main/java/com/hfkj/service/merchant/impl/BsMerchantServiceImpl.java +++ b/service/src/main/java/com/hfkj/service/merchant/impl/BsMerchantServiceImpl.java @@ -24,6 +24,7 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.RequestParam; import javax.annotation.Resource; import java.math.BigDecimal; @@ -66,6 +67,7 @@ public class BsMerchantServiceImpl implements BsMerchantService { @Override @Transactional(propagation= Propagation.REQUIRES_NEW,rollbackFor= {RuntimeException.class}) public void createMerchant(BsMerchant merchant) throws Exception { + merchant.setListShow(true); editData(merchant); if (secUserService.getDetailByLoginName(merchant.getContactsTel()) != null) { @@ -169,6 +171,21 @@ public class BsMerchantServiceImpl implements BsMerchantService { BsMerchantExample example = new BsMerchantExample(); BsMerchantExample.Criteria criteria = example.createCriteria().andStatusNotEqualTo(MerchantStatusEnum.status0.getNumber()); + if (MapUtils.getInteger(param, "sourceType") != null) { + criteria.andSourceTypeEqualTo(MapUtils.getInteger(param, "sourceType")); + } + if (MapUtils.getLong(param, "provinceCode") != null) { + criteria.andProvinceCodeEqualTo(MapUtils.getLong(param, "provinceCode")); + } + + if (MapUtils.getLong(param, "cityCode") != null) { + criteria.andCityCodeEqualTo(MapUtils.getLong(param, "cityCode")); + } + + if (MapUtils.getLong(param, "areaCode") != null) { + criteria.andAreaCodeEqualTo(MapUtils.getLong(param, "areaCode")); + } + if (MapUtils.getInteger(param, "sourceType") != null) { criteria.andSourceTypeEqualTo(MapUtils.getInteger(param, "sourceType")); } diff --git a/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java b/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java index c1ebdde..6080799 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java +++ b/service/src/main/java/com/hfkj/service/order/OrderPaySuccessService.java @@ -3,6 +3,8 @@ package com.hfkj.service.order; import com.alibaba.fastjson.JSONObject; import com.hfkj.channel.gas.newlink.NewLinkGasService; import com.hfkj.channel.gas.newlink.NewLinkRequestService; +import com.hfkj.channel.gas.shell.CqShellPetroleumRequestService; +import com.hfkj.common.exception.BaseException; import com.hfkj.entity.BsGasOrder; import com.hfkj.entity.BsMerchantUser; import com.hfkj.entity.BsOrderChild; @@ -96,29 +98,58 @@ public class OrderPaySuccessService { } } else if (gasOrder.getChannelType().equals(MerchantSourceTypeEnum.type2.getNumber())) { - // 能链【团油】 - Map param = new HashMap<>(); - param.put("gasId", gasOrder.getMerNo()); - param.put("oilNo", gasOrder.getGasOilNo()); - param.put("gunNo", Integer.parseInt(gasOrder.getGasGunNo())); - param.put("priceGun", gasOrder.getGasPriceGun()); // 油站价 - param.put("priceVip", gasOrder.getGasPriceCost()); // 成本价 - param.put("driverPhone", gasOrder.getUserPhone()); - param.put("thirdSerialNo", gasOrder.getOrderNo()); - param.put("refuelingAmount", gasOrder.getGasRefuelPrice()); - // 查询账户 - SecDictionary newLinkAccount = dictionaryService.getDictionary("NEW_LINK_ACCOUNT", "" + gasOrder.getGasOilType()); - if (newLinkAccount != null) { - param.put("accountNo", newLinkAccount.getCodeName()); + try { + // 能链【团油】 + Map param = new HashMap<>(); + param.put("gasId", gasOrder.getMerNo()); + param.put("oilNo", gasOrder.getGasOilNo()); + param.put("gunNo", Integer.parseInt(gasOrder.getGasGunNo())); + param.put("priceGun", gasOrder.getGasPriceGun()); // 油站价 + param.put("priceVip", gasOrder.getGasPriceCost()); // 成本价 + param.put("driverPhone", gasOrder.getUserPhone()); + param.put("thirdSerialNo", gasOrder.getOrderNo()); + param.put("refuelingAmount", gasOrder.getGasRefuelPrice()); + // 查询账户 + SecDictionary newLinkAccount = dictionaryService.getDictionary("NEW_LINK_ACCOUNT", "" + gasOrder.getGasOilType()); + if (newLinkAccount != null) { + param.put("accountNo", newLinkAccount.getCodeName()); + } + JSONObject pushResult = NewLinkRequestService.refuelingOrderPush(param); + if (pushResult != null && pushResult.getString("code").equals("200")) { + gasOrder.setChannelOrderNo(pushResult.getJSONObject("result").getString("orderNo")); + gasOrder.setAbnormal(false); + gasOrder.setAbnormalContent(null); + } else { + gasOrder.setAbnormal(true); + gasOrder.setAbnormalContent(pushResult.getString("message")); + } + } catch (Exception e) { + gasOrder.setAbnormal(true); + gasOrder.setAbnormalContent("推送订单未知异常!请稍后重新推送"); } - JSONObject pushResult = NewLinkRequestService.refuelingOrderPush(param); - if (pushResult != null && pushResult.getString("code").equals("200")) { - gasOrder.setChannelOrderNo(pushResult.getJSONObject("result").getString("orderNo")); + gasOrderService.updateGasOrder(gasOrder); + + } else if (gasOrder.getChannelType().equals(MerchantSourceTypeEnum.type3.getNumber())) { + try { + // 推送加好油【重庆壳牌】 + CqShellPetroleumRequestService.gasSyncPayment(gasOrder.getOrderNo(), + gasOrder.getMerNo(), + gasOrder.getPayTime(), + order.getTotalPrice(), + gasOrder.getGasOilNo(), + gasOrder.getGasGunNo(), + gasOrder.getPayablePrice(), + gasOrder.getTotalDeductionPrice() + ); gasOrder.setAbnormal(false); gasOrder.setAbnormalContent(null); - } else { + + } catch (BaseException e) { + gasOrder.setAbnormal(true); + gasOrder.setAbnormalContent(e.getErrorMsg()); + } catch (Exception e) { gasOrder.setAbnormal(true); - gasOrder.setAbnormalContent(pushResult.getString("message")); + gasOrder.setAbnormalContent("推送订单未知错误!请稍后重新推送"); } gasOrderService.updateGasOrder(gasOrder); } @@ -141,6 +172,7 @@ public class OrderPaySuccessService { } // TODO 赠送积分 } + // 子订单完成 orderService.childOrderComplete(gasOrder.getOrderChildNo()); } diff --git a/service/src/main/java/com/hfkj/service/order/OrderRefundBusiness.java b/service/src/main/java/com/hfkj/service/order/OrderRefundBusiness.java index a6983ce..2adbfec 100644 --- a/service/src/main/java/com/hfkj/service/order/OrderRefundBusiness.java +++ b/service/src/main/java/com/hfkj/service/order/OrderRefundBusiness.java @@ -2,6 +2,11 @@ package com.hfkj.service.order; import com.alibaba.fastjson.JSONObject; import com.hfkj.channel.gas.newlink.NewLinkRequestService; +import com.hfkj.channel.gas.shell.CqShellPetroleumRequestService; +import com.hfkj.common.exception.BaseException; +import com.hfkj.common.exception.ErrorCode; +import com.hfkj.common.exception.ErrorHelp; +import com.hfkj.common.exception.SysCode; import com.hfkj.entity.BsGasOrder; import com.hfkj.entity.BsMerchantAccount; import com.hfkj.entity.BsOrderChild; @@ -47,18 +52,33 @@ public class OrderRefundBusiness { gasOrderService.updateGasOrder(gasOrder); try { + // 订单是否异常 false:无异常 true:有异常 if (gasOrder.getAbnormal().equals(false)) { if (gasOrder.getChannelType().equals(MerchantSourceTypeEnum.type1.getNumber())) { // 退回商户额度 merchantAccountService.refund(gasOrder.getMerNo(), gasOrder.getGasRefuelPrice(), refund); } else if (gasOrder.getChannelType().equals(MerchantSourceTypeEnum.type2.getNumber())) { + // 请求团油渠道退款 JSONObject object = NewLinkRequestService.refuelingOrderRefund(gasOrder.getUserPhone(), gasOrder.getOrderNo(), refund.getRefundRemark()); if (object == null || !object.getString("code").equals("200")) { gasOrder.setAbnormal(true); gasOrder.setAbnormalContent("渠道退款失败!原因:" + object.getString("message")); gasOrderService.updateGasOrder(gasOrder); } + } else if (gasOrder.getChannelType().equals(MerchantSourceTypeEnum.type3.getNumber())) { + try { + // 请求重庆壳牌渠道退款 + CqShellPetroleumRequestService.gasSyncRefund(gasOrder.getPayTime(), gasOrder.getOrderNo()); + } catch (BaseException e) { + gasOrder.setAbnormal(true); + gasOrder.setAbnormalContent("渠道退款失败!原因:" + e.getErrorMsg()); + gasOrderService.updateGasOrder(gasOrder); + } catch (Exception e) { + gasOrder.setAbnormal(true); + gasOrder.setAbnormalContent("渠道退款失败!未知原因"); + gasOrderService.updateGasOrder(gasOrder); + } } } } catch (Exception e) {} diff --git a/service/src/main/java/com/hfkj/sysenum/MerchantSourceTypeEnum.java b/service/src/main/java/com/hfkj/sysenum/MerchantSourceTypeEnum.java index fbb8663..14964d0 100644 --- a/service/src/main/java/com/hfkj/sysenum/MerchantSourceTypeEnum.java +++ b/service/src/main/java/com/hfkj/sysenum/MerchantSourceTypeEnum.java @@ -19,6 +19,10 @@ public enum MerchantSourceTypeEnum { * 能链【团油】 */ type2(2, "能链【团油】"), + /** + * 加好油【重庆壳牌】 + */ + type3(3, "加好油【重庆壳牌】"), ; private Integer number; diff --git a/service/src/main/resources/dev/commonConfig.properties b/service/src/main/resources/dev/commonConfig.properties index 0db1aa5..2535fed 100644 --- a/service/src/main/resources/dev/commonConfig.properties +++ b/service/src/main/resources/dev/commonConfig.properties @@ -10,3 +10,8 @@ wxMaAppSecret=d8d6dcaef77d3b659258a01b5ddba5df newLinkReqUrl=https://test01-motorcade-hcs.czb365.com newLinkAppKey=297046381248288 newLinkAppSecret=3ef5320dd36e178ce2502fae1a8acd2b + +cqShellReqUrl=http://openapi.ngrok.xinyebang.cn/gateway.html +cqShellPartnerId=S0302207281600105753 +cqShellPlatMerchantId=S0302206141000105717 +cqShellPlatMerchantKey=wqisfmkzea6mwd7ogbyh3488jv0hqhdj diff --git a/service/src/main/resources/prod/commonConfig.properties b/service/src/main/resources/prod/commonConfig.properties index 98cbe3f..0247b38 100644 --- a/service/src/main/resources/prod/commonConfig.properties +++ b/service/src/main/resources/prod/commonConfig.properties @@ -8,3 +8,8 @@ wxMaAppSecret=d8d6dcaef77d3b659258a01b5ddba5df newLinkReqUrl=https://hcs.czb365.com newLinkAppKey=305490138943968 newLinkAppSecret=dbf7dca3de20c2f2a41fd64cfb682be8 + +cqShellReqUrl=http://api.shenmapay.com/gateway.html +cqShellPartnerId=S0302208021401950202 +cqShellPlatMerchantId=S0302206141001919666 +cqShellPlatMerchantKey=pic1yj2l3zby5ywpznrtdz7458ce2soj