diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java b/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java index 045078c5..b91740c8 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java @@ -272,6 +272,29 @@ public class HighOrderController { childOrder.setGoodsSpecName("默认"); } + // 汇联通充值 + if (childOrder.getGoodsType() == 8) { + if (childOrder.getGoodsPrice() == null) { + log.error("HighOrderController --> addOrder() error!", "请设置充值金额"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请设置充值金额"); + } + if (highOrder.getMemCardNo() == null) { + log.error("HighOrderController --> addOrder() error!", "请设置充值卡号"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请设置充值卡号"); + } + // 查询用户信息 + HighUser user = highUserService.findByUserId(childOrder.getGoodsId()); + if (user == null) { + log.error("HighOrderController --> addOrder() error!", "未找到用户"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_MEMBER_ERROR, ""); + } + highOrder.setPayType(2); // 第三方平台 + childOrder.setGoodsActualPrice(childOrder.getGoodsPrice()); + childOrder.setGoodsName(user.getName()); + childOrder.setGoodsImg(user.getHeaderImg()); + childOrder.setGoodsSpecName("默认"); + } + childOrder.setMemId(userInfoModel.getHighUser().getId()); childOrder.setTotalPrice(childOrder.getGoodsPrice().multiply(new BigDecimal(childOrder.getSaleCount().toString()))); childOrder.setGiveawayType(false); // 是否是赠品 0:否 1:是 diff --git a/hai-service/src/main/java/com/hai/config/HuiLianTongUnionCardConfig.java b/hai-service/src/main/java/com/hai/config/HuiLianTongUnionCardConfig.java index 4fd33a61..5b0f4d55 100644 --- a/hai-service/src/main/java/com/hai/config/HuiLianTongUnionCardConfig.java +++ b/hai-service/src/main/java/com/hai/config/HuiLianTongUnionCardConfig.java @@ -121,6 +121,31 @@ public class HuiLianTongUnionCardConfig { } } + /** + * 充值 + * @param orderNo 订单号 + * @param cardNo 卡号 + * @param tranAmount 支付金额 + * @param businessType 业务类型 1.卖中石化加油券的,固定填sinopec_oil_code 2.其他商品或服务的,固定填hisen_consume + * @param tranVoucher 银行卡充值可填银行卡号;支付宝、微信充值可填相应的扣款单号;接入方也可自定义填入交易流水跟踪号,但长度不能超过50 + * @param tranDesc 交易描述 + * @return + * @throws Exception + */ + public static JSONObject deposit(String orderNo, String cardNo, BigDecimal tranAmount, String businessType, String tranVoucher , String tranDesc) throws Exception { + Map dataMap = new HashMap<>(); + dataMap.put("orderNo", orderNo); + dataMap.put("cardType", "ghk"); + dataMap.put("cardNo", cardNo); + dataMap.put("tranAmount", tranAmount); + dataMap.put("tranChannel", "HiSen"); + dataMap.put("businessType", businessType); + dataMap.put("tranVoucher", tranVoucher); + dataMap.put("tranDesc", tranDesc); + System.out.println("工会卡支付请求参数" + JSON.toJSONString(dataMap)); + return request("qtk/deposit", dataMap); + } + /** * 支付 * @param orderNo 订单号 diff --git a/hai-service/src/main/java/com/hai/entity/HighChildOrder.java b/hai-service/src/main/java/com/hai/entity/HighChildOrder.java index 7aad31a7..ffc657a7 100644 --- a/hai-service/src/main/java/com/hai/entity/HighChildOrder.java +++ b/hai-service/src/main/java/com/hai/entity/HighChildOrder.java @@ -44,7 +44,7 @@ public class HighChildOrder implements Serializable { private String storeAddress; /** - * 商品类型 1:卡卷 2:金币充值 3:团油【加油站】 4: KFC 5:电影票 + * 商品类型 1:卡卷 2:金币充值 3:团油【加油站】 4: KFC 5:电影票 8: 汇联通充值 */ private Integer goodsType; @@ -524,4 +524,4 @@ public class HighChildOrder implements Serializable { sb.append("]"); return sb.toString(); } -} \ No newline at end of file +} diff --git a/hai-service/src/main/java/com/hai/service/pay/impl/GoodsOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/pay/impl/GoodsOrderServiceImpl.java index c3a0925f..04df7221 100644 --- a/hai-service/src/main/java/com/hai/service/pay/impl/GoodsOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/pay/impl/GoodsOrderServiceImpl.java @@ -1,5 +1,6 @@ package com.hai.service.pay.impl; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.hai.common.exception.ErrorCode; @@ -10,6 +11,7 @@ import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.utils.WxUtils; import com.hai.config.CommonSysConst; import com.hai.config.HuiLianTongConfig; +import com.hai.config.HuiLianTongUnionCardConfig; import com.hai.config.TuanYouConfig; import com.hai.dao.HighCouponCodeOtherMapper; import com.hai.dao.HighDiscountPackageRecordMapper; @@ -259,6 +261,8 @@ public class GoodsOrderServiceImpl implements PayService { if (highChildOrder.getGoodsType() == 2) { highChildOrder.setChildOrdeStatus(3); // 子订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 + order.setFinishTime(new Date()); + order.setOrderStatus(3); // 订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 // 金币 1:100 Integer goldNum = new BigDecimal(highChildOrder.getTotalPrice().toString()).multiply(new BigDecimal("100")).intValue(); highUserService.goldHandle(highChildOrder.getGoodsId(), goldNum, 1, 1, highChildOrder.getId()); @@ -327,6 +331,51 @@ public class GoodsOrderServiceImpl implements PayService { discountPackageActualService.updateHighDiscountPackageActual(actual); } } + + if (highChildOrder.getGoodsType() == 8) { + // 汇联通充值 + String goodsDesc = "汇联通充值"+order.getPayPrice()+"元"; + String tranDesc = ""; + String businessType = "ghk_deposit"; + + // 汇联通卡充值 + JSONObject deposit = HuiLianTongUnionCardConfig.deposit(order.getOrderNo(), order.getMemCardNo(), order.getPayPrice(), businessType, map.get("transaction_id"), tranDesc); + System.out.println("工会卡支付响应参数" + deposit.toJSONString()); + + JSONObject dataObject = HuiLianTongUnionCardConfig.resolveResponse(deposit.getString("data")); + + Map dataMap = new HashMap<>(); + dataMap.put("orderNo", order.getOrderNo()); + dataMap.put("cardType", "ghk"); + dataMap.put("cardNo", order.getMemCardNo()); + dataMap.put("checkPassword", "N"); + dataMap.put("tranAmount", order.getPayPrice()); + dataMap.put("tranChannel", "HiSen"); + dataMap.put("businessType", businessType); + dataMap.put("goodsDesc", goodsDesc); + dataMap.put("tranDesc", tranDesc); + HighGasOrderPush payPush = new HighGasOrderPush(); + payPush.setType(OrderPushType.type5.getType()); + payPush.setOrderNo(order.getOrderNo()); + payPush.setCreateTime(new Date()); + payPush.setCode(deposit.getString("respCode")); + payPush.setRequestContent(JSON.toJSONString(dataMap)); + payPush.setReturnContent(deposit.toJSONString()); + highGasOrderPushMapper.insert(payPush); + + if (!Objects.equals(deposit.getString("respCode"), "0000")) { + throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR , deposit.getString("respMessage")); + } + // 记录回调信息 + if (!dataObject.getBoolean("success")) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, dataObject.getString("message")); + } + + // 修改订单状态 + highChildOrder.setChildOrdeStatus(3); // 子订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 + order.setFinishTime(new Date()); + order.setOrderStatus(3); // 订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 + } } highOrderService.updateOrder(order);