diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighGasChannelConfigController.java b/hai-bweb/src/main/java/com/bweb/controller/HighGasChannelConfigController.java index 9106eabf..5989fc32 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighGasChannelConfigController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighGasChannelConfigController.java @@ -67,8 +67,7 @@ public class HighGasChannelConfigController { // 查询平台 HighGasChannelConfig platform = gasChannelConfigService.getConfig( - GasChannel.getChannelByType(body.getInteger("channelId")), - GasChannelPayPlatformType.getPlatformByType(body.getInteger("payPlatformType"))); + GasChannel.getChannelByType(body.getInteger("channelId"))); if (platform == null) { platform = new HighGasChannelConfig(); @@ -78,6 +77,7 @@ public class HighGasChannelConfigController { platform.setPayPlatformType(body.getInteger("payPlatformType")); platform.setPayPlatformMerName(body.getString("payPlatformMerName")); platform.setPayPlatformMerNo(body.getString("payPlatformMerNo")); + platform.setPayPlatformMerKey(body.getString("payPlatformKey")); platform.setProfitSharingStatus(body.getBoolean("profitSharingStatus")); platform.setProfitSharingRatio(body.getBigDecimal("profitSharingRatio")); platform.setProfitSharingReceiversNo(body.getString("profitSharingReceiversNo")); diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighMerchantStoreController.java b/hai-bweb/src/main/java/com/bweb/controller/HighMerchantStoreController.java index ad941a41..2a5853e0 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighMerchantStoreController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighMerchantStoreController.java @@ -13,10 +13,7 @@ import com.hai.common.security.UserCenter; import com.hai.common.utils.HttpsUtils; import com.hai.common.utils.ResponseMsgUtil; import com.hai.config.CommonSysConst; -import com.hai.entity.BsCompany; -import com.hai.entity.HighMerchant; -import com.hai.entity.HighMerchantStore; -import com.hai.entity.SecRegion; +import com.hai.entity.*; import com.hai.enum_type.MerchantStoreSourceType; import com.hai.model.*; import com.hai.service.*; @@ -135,7 +132,10 @@ public class HighMerchantStoreController { highMerchantStore.setMerchantId(merchant.getId()); highMerchantStore.setOperatorId(userInfoModel.getSecUser().getId()); highMerchantStore.setOperatorName(userInfoModel.getSecUser().getUserName()); - highMerchantStore.setSourceType(MerchantStoreSourceType.type1.getNumber()); + + if (highMerchantStore.getSourceType() == null) { + highMerchantStore.setSourceType(MerchantStoreSourceType.type1.getNumber()); + } highMerchantStoreService.insertMerchantStore(highMerchantStore); return ResponseMsgUtil.success(highMerchantStore); @@ -250,11 +250,14 @@ public class HighMerchantStoreController { store.setTelephone(highMerchantStore.getTelephone()); store.setAddress(highMerchantStore.getAddress()); store.setLatitude(highMerchantStore.getLatitude()); + store.setExt3(highMerchantStore.getExt3()); store.setLongitude(highMerchantStore.getLongitude()); store.setDeviceSn(highMerchantStore.getDeviceSn()); store.setDeviceKey(highMerchantStore.getDeviceKey()); store.setDeviceName(highMerchantStore.getDeviceName()); - + if (highMerchantStore.getSourceType() != null) { + store.setSourceType(highMerchantStore.getSourceType()); + } store.setUpdateTime(new Date()); store.setOperatorId(userInfoModel.getSecUser().getId()); store.setOperatorName(userInfoModel.getSecUser().getUserName()); @@ -383,5 +386,91 @@ public class HighMerchantStoreController { } } + @RequestMapping(value="/insertStoreOilCard",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "新增门店油卡") + public ResponseData insertStoreOilCard(@RequestBody HighStoreOilCard highStoreOilCard, HttpServletRequest request) { + try { + //发布人员 + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + if (userInfoModel.getMerchant() == null) { + log.error("HighMerchantController -> insertMerchantStore() error!","该主角色没有权限"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, ""); + } + + if (highStoreOilCard.getStoreId() == null + || StringUtils.isBlank(highStoreOilCard.getOilCardNo()) + ) { + log.error("HighMerchantStoreController -> insertMerchantStore() error!","参数错误"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + // 查询门店 + HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreById(highStoreOilCard.getStoreId()); + if (store == null) { + log.error("BsStudentController --> addStudent() error!", "未找到门店信息"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到门店信息"); + } + BsCompany company = bsCompanyService.getCompanyById(store.getCompanyId()); + if (company == null) { + log.error("HighMerchantStoreController -> insertMerchantStore() error!","未找到分公司"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOF_FOUND, ""); + } + + + highStoreOilCard.setType(1); + highStoreOilCard.setStatus(1); + highStoreOilCard.setCreateTime(new Date()); + highStoreOilCard.setUpdateTime(new Date()); + highStoreOilCard.setOpId(userInfoModel.getSecUser().getId()); + highStoreOilCard.setOpName(userInfoModel.getSecUser().getUserName()); + highMerchantStoreService.insertStoreOilCard(highStoreOilCard); + + return ResponseMsgUtil.success(highStoreOilCard); + } catch (Exception e) { + log.error("HighMerchantStoreController -> editMerchantStore() error!",e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/deleteStoreOilCard", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "删除油卡") + public ResponseData deleteStoreOilCard(@RequestParam(name = "id", required = false) Long id) { + try { + + HighStoreOilCard highStoreOilCard = highMerchantStoreService.findStoreOilCard(id); + + if (highStoreOilCard == null) { + throw ErrorHelp.genException(SysCode.System , ErrorCode.COMMON_ERROR, "未查到相关油卡"); + } + + highStoreOilCard.setUpdateTime(new Date()); + highStoreOilCard.setStatus(0); + + highMerchantStoreService.updateStoreOilCard(highStoreOilCard); + return ResponseMsgUtil.success("删除油卡"); + + } catch (Exception e) { + log.error("HighOrderController --> getBackendToken() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + + @RequestMapping(value = "/getStoreOilCardList", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询油卡") + public ResponseData getStoreOilCardList(@RequestParam(name = "storeId", required = false) Long storeId) { + try { + + return ResponseMsgUtil.success(highMerchantStoreService.getStoreOilCardList(storeId)); + + } catch (Exception e) { + log.error("HighOrderController --> getBackendToken() error!", e); + return ResponseMsgUtil.exception(e); + } + } } diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java b/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java index e6c76621..2a271c0c 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighTestController.java @@ -1 +1 @@ - package com.bweb.controller; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.utils.HttpsUtils; import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.WxUtils; import com.hai.config.DianConfig; import com.hai.config.HuiLianTongUnionCardConfig; import com.hai.config.TuanYouConfig; import com.hai.entity.*; import com.hai.enum_type.GasOilPriceStatusEnum; import com.hai.model.HighMerchantModel; import com.hai.model.HighMerchantStoreModel; import com.hai.model.ResponseData; import com.hai.openApi.config.BlxConfig; import com.hai.order.service.OrderService; import com.hai.order.type.OrderProductType; import com.hai.order.type.OrderRefundOpUserType; import com.hai.order.utils.OrderUtil; import com.hai.pay.channel.huipay.config.HuiConfig; 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.bouncycastle.LICENSE; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.io.FileOutputStream; import java.io.InputStream; import java.math.BigDecimal; import java.net.URL; import java.net.URLConnection; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @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 OrderService orderService; @Resource private HighUserCardService highUserCardService; @Resource private HighOrderService highOrderService; @Resource private HighUserService highUserService; @Resource private HighMerchantService highMerchantService; @Resource private HighMerchantStoreService highMerchantStoreService; @Resource private HighGasOilPriceService highGasOilPriceService; @Resource private HuiConfig huiConfig; @Resource private CommonService commonService; @RequestMapping(value="/resolveResponse",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "解析") public ResponseData resolveResponse( @RequestParam(name = "data", required = false) String data ) { try { JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(data); return ResponseMsgUtil.success(cardInfoObject); } catch (Exception e) { log.error("getUserByTelephone",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getHuiLianTongCardConsume", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询汇联通工会卡消费记录") public ResponseData getHuiLianTongCardConsume(@RequestParam(name = "businessType", required = true) String businessType, @RequestParam(name = "cardNo", required = true) String cardNo, @RequestParam(name = "sdate", required = true) Long sdate, @RequestParam(name = "edate", required = true) Long edate, @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request) { try { JSONObject consumptionRecord = HuiLianTongUnionCardConfig.queryConsumptionRecordByBusiness(businessType, cardNo, sdate, edate, pageNum, pageSize); if (StringUtils.isBlank(consumptionRecord.getString("data"))) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQUEST_ERROR, ""); } JSONArray array = HuiLianTongUnionCardConfig.resolveResponse(consumptionRecord.getString("data")).getJSONArray("records"); return ResponseMsgUtil.success(array); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardConsume() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/createOrder", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "创建订单") public ResponseData createOrder(@RequestBody JSONObject object) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("timetable" , new Date().getTime()); mapPost.put("orderNo" , "TEST" + OrderUtil.generateOrderNo()); mapPost.put("productType" , object.getString("productType")); mapPost.put("content" , object.getJSONObject("content").toString()); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/createOrder" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/payOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "支付订单") public ResponseData payOrder(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("mchOrderNo" , mchOrderNo); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("mchOrderNo" , mchOrderNo); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/orderPay" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryOrderDetail", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询订单详情") public ResponseData queryOrderDetail(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("mchOrderNo" , mchOrderNo); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("mchOrderNo" , mchOrderNo); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/queryOrderDetail" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/deposit", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡充值") public ResponseData deposit(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); HighChildOrder highChildOrder = order.getHighChildOrderList().get(0); if (order.getOrderStatus() != 2) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态错误"); } // 汇联通充值 String goodsDesc = "汇联通充值"+order.getPayPrice()+"元"; String tranDesc = ""; String businessType = "ghk_deposit"; String orderNoAgain = OrderUtil.generateOrderNo(); order.setOrderStatus(Integer.valueOf(3)); order.setRemarks("工会卡再次充值订单号" + orderNoAgain); highOrderService.updateOrder(order); // 汇联通卡充值 JSONObject deposit = HuiLianTongUnionCardConfig.deposit(orderNoAgain, highChildOrder.getGoodsSpecName(), order.getPayPrice(), businessType, order.getPaySerialNo(), goodsDesc); return ResponseMsgUtil.success( HuiLianTongUnionCardConfig.resolveResponse(deposit.getString("data"))); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getHuiLianTongCardByCardNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据卡号查询汇联通工会卡详情") public ResponseData getHuiLianTongCardByCardNo(@RequestParam(name = "cardNo", required = true) String cardNo) { try { // 查询工会卡 JSONObject cardInfo = HuiLianTongUnionCardConfig.queryBalance(cardNo); JSONObject resolveResponse = HuiLianTongUnionCardConfig.resolveResponse(cardInfo.getString("data")); return ResponseMsgUtil.success(resolveResponse); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardByCardNo() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/consumption", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡支付") public ResponseData consumption(@RequestParam(name = "payRealPrice", required = true) BigDecimal payRealPrice, @RequestParam(name = "cardNo", required = true) String cardNo) { try { String goodsDesc = ""; String tranDesc = ""; String instCode = "11101527"; String businessType = "hisen_consume"; // 工会卡支付 JSONObject consumption = HuiLianTongUnionCardConfig.consumption(OrderUtil.generateOrderNo(), cardNo, payRealPrice, businessType, instCode, goodsDesc, tranDesc); if (!consumption.getString("respCode").equals("0000")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumption.getString("respMessage")); } // 响应参数 JSONObject consumptionResult = HuiLianTongUnionCardConfig.resolveResponse(consumption.getString("data")); if (consumptionResult.getBoolean("success") != true) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumptionResult.getString("message")); } return ResponseMsgUtil.success(consumptionResult); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardByCardNo() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/refundOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡退款") public ResponseData refundOrder(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); if (order.getOrderStatus() != 2) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态错误"); } orderService.refundOrder(order, OrderProductType.getDataByType(order.getProductType()).getName() + "退款",OrderRefundOpUserType.TYPE1, null, "系统自动退款"); if (order.getProductType().equals(4)) { HighUser user = highUserService.findByUserId(order.getMemId()); // 获取应退款积分 int integralNum = order.getTotalPrice().multiply(new BigDecimal(100)).intValue(); if ( integralNum> user.getGold()) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "积分数量不足"); } String remark = "订单" + order.getOrderNo() + "退还积分:" + integralNum; // 积分退款 highUserService.goldHandle(user.getId(), integralNum,2, 3, order.getId() , remark , order.getOrderNo()); } return ResponseMsgUtil.success("退款成功"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/externalOrderRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "对外订单退款") public ResponseData externalOrderRefund(@RequestParam(name = "paySerialNo", required = true) String paySerialNo, @RequestParam(name = "WxMchId", required = true) String WxMchId, @RequestParam(name = "payRealPrice", required = true) String payRealPrice) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "B94B5E62807FA56A7260AB581D8A1B48"); mapPost.put("merchId" , "20230394901"); mapPost.put("paySerialNo" , paySerialNo); mapPost.put("wxMchId" , WxMchId); mapPost.put("payRealPrice" , payRealPrice); mapPost.put("refundPrice" , payRealPrice); Map map = new HashMap<>(); map.put("apiKey" , "B94B5E62807FA56A7260AB581D8A1B48"); map.put("merchId" , "20230394901"); map.put("paySerialNo" , paySerialNo); map.put("wxMchId" , WxMchId); map.put("payRealPrice" , payRealPrice); map.put("refundPrice" , payRealPrice); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("https://hsg.dctpay.com/v1/order/externalOrderRefund" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getBlxCouponBalance", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询停车券") public ResponseData getBlxCouponBalance(@RequestParam(name = "phone", required = true) String phone) { try { highUserCardService.getBlxCouponBalance(phone); return ResponseMsgUtil.success("object"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryJsParking", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询捷顺停车场") public ResponseData queryJsParking(@RequestParam(name = "gps", required = true) String gps) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("gps" , gps); mapPost.put("range" , "1000"); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/queryJsParking" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getUserCouponPage", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询捷顺停车场") public ResponseData getUserCouponPage(@RequestParam(name = "phone", required = true) String phone) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("phone" , phone); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/getUserCouponPage" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryJsOrderList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询车牌订单列表信息") public ResponseData queryJsOrderList(@RequestParam(name = "carNo", required = true) String carNo, @RequestParam(name = "orderStatus", required = true) String orderStatus) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("orderStatus" , orderStatus); mapPost.put("carNo" , carNo); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/queryJsOrderList" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getCouponList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询车牌订单列表信息") public ResponseData getCouponList() { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2 FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/getCouponList" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/sendCoupon", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "发放券") public ResponseData sendCoupon(@RequestParam(name = "couponCode", required = true) String couponCode, @RequestParam(name = "receiverCount", required = true) String receiverCount, @RequestParam(name = "receiverPhone", required = true) String receiverPhone) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/getCouponList" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/preorder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "发起支付") public ResponseData preorder() { try { JSONObject object = new JSONObject(); object.put("outTradeNo" , "HUI" + OrderUtil.generateOrderNo()); object.put("transType" , "JSAPI"); object.put("payMode" , "WECHAT"); object.put("totalAmount" , "0.01"); object.put("profitSharing" , 0); object.put("subject" , "测试"); object.put("userId" , "oUGn_4unIjp90MY-oEXluY4laDrQ"); return ResponseMsgUtil.success(huiConfig.preorder(object)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryGasInfoListByPage", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询团油门店") public ResponseData queryGasInfoListByPage() { try { HighMerchantModel merchant = highMerchantService.getMerchantById(39L); 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.setSourceType(2); 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.setPrestoreType(0); 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.getString("oilNo")); if (highGasOilPrice == null) { highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("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")); highGasOilPrice.setStatus(GasOilPriceStatusEnum.status1.getStatus()); } else { highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("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.setSourceType(2); 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.setPrestoreType(0); 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.getString("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("完成"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/test", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "测试") public ResponseData test(@RequestParam(name = "no", required = true) String no) { try { JSONObject jsonObject = DianConfig.getGasInfoByGasId(no); return ResponseMsgUtil.success(jsonObject); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getGasInfoAll", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取全量油站") public ResponseData getGasInfoAll() { try { HighMerchantModel merchant = highMerchantService.getMerchantById(39L); JSONObject jsonObject = DianConfig.getGasInfoAll(); JSONArray resultObject = jsonObject.getObject("result", JSONArray.class); for (int i = 0; i < resultObject.size();i++) { Object objectData = resultObject.get(i); JSONObject object = JSONObject.parseObject(JSONObject.toJSONString(objectData)); HighMerchantStore highMerchantStore; HighGasOilPrice highGasOilPrice; HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreByKey(object.getString("jyzid")); SecRegion region = commonService.getRegionsByName(object.getString("province")); if (store != null) { store.setType(1); store.setSourceType(6); store.setMerchantId(merchant.getId()); store.setCompanyId(merchant.getCompanyId()); store.setStoreKey(object.getString("jyzid")); store.setStoreName(object.getString("mingcheng")); store.setStoreLogo(object.getString("tupian")); store.setRegionId(region.getRegionId()); store.setRegionName(object.getString("province")); store.setAddress(object.getString("dizhi")); store.setLongitude(object.getString("lng")); store.setLatitude(object.getString("lat")); store.setStatus(object.getInteger("zhuangtai")); store.setPrestoreType(0); 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.getString("youhao")); if (highGasOilPrice == null) { highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("youhao")); highGasOilPrice.setOilNoName(oilPriceObject.getString("youhao") + "#"); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oiltype")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oiltype").equals("1") ? "汽油": "柴油"); highGasOilPrice.setStatus(GasOilPriceStatusEnum.status1.getStatus()); } else { highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("youhao")); highGasOilPrice.setOilNoName( oilPriceObject.getString("youhao") + "#"); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oiltype")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oiltype").equals("1") ? "汽油": "柴油"); } highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } else { highMerchantStore = new HighMerchantStore(); highMerchantStore.setType(1); highMerchantStore.setSourceType(6); highMerchantStore.setMerchantId(merchant.getId()); highMerchantStore.setCompanyId(merchant.getCompanyId()); highMerchantStore.setStoreKey(object.getString("jyzid")); highMerchantStore.setStoreName(object.getString("mingcheng")); highMerchantStore.setStoreLogo(object.getString("tupian")); highMerchantStore.setRegionId(region.getRegionId()); highMerchantStore.setRegionName(object.getString("province")); highMerchantStore.setAddress(object.getString("dizhi")); highMerchantStore.setLongitude(object.getString("lng")); highMerchantStore.setLatitude(object.getString("lat")); highMerchantStore.setStatus(1); highMerchantStore.setPrestoreType(0); 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.getString("youhao")); highGasOilPrice.setOilNoName(oilPriceObject.getString("youhao") + "#"); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oiltype")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oiltype").equals("1") ? "汽油": "柴油"); highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } } 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.bweb.controller; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.utils.HttpsUtils; import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.WxUtils; import com.hai.config.DianConfig; import com.hai.config.HuiLianTongUnionCardConfig; import com.hai.config.KytcService; import com.hai.config.TuanYouConfig; import com.hai.entity.*; import com.hai.enum_type.GasOilPriceStatusEnum; import com.hai.model.HighMerchantModel; import com.hai.model.HighMerchantStoreModel; import com.hai.model.ResponseData; import com.hai.openApi.config.BlxConfig; import com.hai.order.service.OrderService; import com.hai.order.type.OrderProductType; import com.hai.order.type.OrderRefundOpUserType; import com.hai.order.utils.OrderUtil; import com.hai.pay.channel.huipay.config.HuiConfig; 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.bouncycastle.LICENSE; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.io.FileOutputStream; import java.io.InputStream; import java.math.BigDecimal; import java.net.URL; import java.net.URLConnection; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @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 OrderService orderService; @Resource private HighUserCardService highUserCardService; @Resource private HighOrderService highOrderService; @Resource private HighUserService highUserService; @Resource private HighMerchantService highMerchantService; @Resource private HighMerchantStoreService highMerchantStoreService; @Resource private HighGasOilPriceService highGasOilPriceService; @Resource private HuiConfig huiConfig; @Resource private CommonService commonService; @Resource private HighOilCardOrderService highOilCardOrderService; @RequestMapping(value="/resolveResponse",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "解析") public ResponseData resolveResponse( @RequestParam(name = "data", required = false) String data ) { try { JSONObject cardInfoObject = HuiLianTongUnionCardConfig.resolveResponse(data); return ResponseMsgUtil.success(cardInfoObject); } catch (Exception e) { log.error("getUserByTelephone",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getHuiLianTongCardConsume", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询汇联通工会卡消费记录") public ResponseData getHuiLianTongCardConsume(@RequestParam(name = "businessType", required = true) String businessType, @RequestParam(name = "cardNo", required = true) String cardNo, @RequestParam(name = "sdate", required = true) Long sdate, @RequestParam(name = "edate", required = true) Long edate, @RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request) { try { JSONObject consumptionRecord = HuiLianTongUnionCardConfig.queryConsumptionRecordByBusiness(businessType, cardNo, sdate, edate, pageNum, pageSize); if (StringUtils.isBlank(consumptionRecord.getString("data"))) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQUEST_ERROR, ""); } JSONArray array = HuiLianTongUnionCardConfig.resolveResponse(consumptionRecord.getString("data")).getJSONArray("records"); return ResponseMsgUtil.success(array); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardConsume() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/createOrder", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "创建订单") public ResponseData createOrder(@RequestBody JSONObject object) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("timetable" , new Date().getTime()); mapPost.put("orderNo" , "TEST" + OrderUtil.generateOrderNo()); mapPost.put("productType" , object.getString("productType")); mapPost.put("content" , object.getJSONObject("content").toString()); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/createOrder" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/payOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "支付订单") public ResponseData payOrder(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("mchOrderNo" , mchOrderNo); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("mchOrderNo" , mchOrderNo); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/orderPay" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryOrderDetail", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询订单详情") public ResponseData queryOrderDetail(@RequestParam(name = "mchOrderNo", required = true) String mchOrderNo) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); mapPost.put("mchOrderNo" , mchOrderNo); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); map.put("mchOrderNo" , mchOrderNo); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/order/queryOrderDetail" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/deposit", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡充值") public ResponseData deposit(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); HighChildOrder highChildOrder = order.getHighChildOrderList().get(0); if (order.getOrderStatus() != 2) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态错误"); } // 汇联通充值 String goodsDesc = "汇联通充值"+order.getPayPrice()+"元"; String tranDesc = ""; String businessType = "ghk_deposit"; String orderNoAgain = OrderUtil.generateOrderNo(); order.setOrderStatus(Integer.valueOf(3)); order.setRemarks("工会卡再次充值订单号" + orderNoAgain); highOrderService.updateOrder(order); // 汇联通卡充值 JSONObject deposit = HuiLianTongUnionCardConfig.deposit(orderNoAgain, highChildOrder.getGoodsSpecName(), order.getPayPrice(), businessType, order.getPaySerialNo(), goodsDesc); return ResponseMsgUtil.success( HuiLianTongUnionCardConfig.resolveResponse(deposit.getString("data"))); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getHuiLianTongCardByCardNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据卡号查询汇联通工会卡详情") public ResponseData getHuiLianTongCardByCardNo(@RequestParam(name = "cardNo", required = true) String cardNo) { try { // 查询工会卡 JSONObject cardInfo = HuiLianTongUnionCardConfig.queryBalance(cardNo); JSONObject resolveResponse = HuiLianTongUnionCardConfig.resolveResponse(cardInfo.getString("data")); return ResponseMsgUtil.success(resolveResponse); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardByCardNo() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/consumption", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡支付") public ResponseData consumption(@RequestParam(name = "payRealPrice", required = true) BigDecimal payRealPrice, @RequestParam(name = "cardNo", required = true) String cardNo) { try { String goodsDesc = ""; String tranDesc = ""; String instCode = "11101527"; String businessType = "hisen_consume"; // 工会卡支付 JSONObject consumption = HuiLianTongUnionCardConfig.consumption(OrderUtil.generateOrderNo(), cardNo, payRealPrice, businessType, instCode, goodsDesc, tranDesc); if (!consumption.getString("respCode").equals("0000")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumption.getString("respMessage")); } // 响应参数 JSONObject consumptionResult = HuiLianTongUnionCardConfig.resolveResponse(consumption.getString("data")); if (consumptionResult.getBoolean("success") != true) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumptionResult.getString("message")); } return ResponseMsgUtil.success(consumptionResult); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardByCardNo() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/refundOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "工会卡退款") public ResponseData refundOrder(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOrder order = highOrderService.getOrderByOrderNo(orderNo); if (order.getOrderStatus() != 2) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单状态错误"); } orderService.refundOrder(order, OrderProductType.getDataByType(order.getProductType()).getName() + "退款",OrderRefundOpUserType.TYPE1, null, "系统自动退款"); if (order.getProductType().equals(4)) { HighUser user = highUserService.findByUserId(order.getMemId()); // 获取应退款积分 int integralNum = order.getTotalPrice().multiply(new BigDecimal(100)).intValue(); if ( integralNum> user.getGold()) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "积分数量不足"); } String remark = "订单" + order.getOrderNo() + "退还积分:" + integralNum; // 积分退款 highUserService.goldHandle(user.getId(), integralNum,2, 3, order.getId() , remark , order.getOrderNo()); } return ResponseMsgUtil.success("退款成功"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/externalOrderRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "对外订单退款") public ResponseData externalOrderRefund(@RequestParam(name = "paySerialNo", required = true) String paySerialNo, @RequestParam(name = "WxMchId", required = true) String WxMchId, @RequestParam(name = "payRealPrice", required = true) String payRealPrice) { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "B94B5E62807FA56A7260AB581D8A1B48"); mapPost.put("merchId" , "20230394901"); mapPost.put("paySerialNo" , paySerialNo); mapPost.put("wxMchId" , WxMchId); mapPost.put("payRealPrice" , payRealPrice); mapPost.put("refundPrice" , payRealPrice); Map map = new HashMap<>(); map.put("apiKey" , "B94B5E62807FA56A7260AB581D8A1B48"); map.put("merchId" , "20230394901"); map.put("paySerialNo" , paySerialNo); map.put("wxMchId" , WxMchId); map.put("payRealPrice" , payRealPrice); map.put("refundPrice" , payRealPrice); System.out.println(map); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("https://hsg.dctpay.com/v1/order/externalOrderRefund" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getBlxCouponBalance", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询停车券") public ResponseData getBlxCouponBalance(@RequestParam(name = "phone", required = true) String phone) { try { highUserCardService.getBlxCouponBalance(phone); return ResponseMsgUtil.success("object"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryJsParking", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询捷顺停车场") public ResponseData queryJsParking(@RequestParam(name = "gps", required = true) String gps) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("gps" , gps); mapPost.put("range" , "1000"); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/queryJsParking" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getUserCouponPage", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询捷顺停车场") public ResponseData getUserCouponPage(@RequestParam(name = "phone", required = true) String phone) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("phone" , phone); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/getUserCouponPage" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryJsOrderList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询车牌订单列表信息") public ResponseData queryJsOrderList(@RequestParam(name = "carNo", required = true) String carNo, @RequestParam(name = "orderStatus", required = true) String orderStatus) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("orderStatus" , orderStatus); mapPost.put("carNo" , carNo); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/queryJsOrderList" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getCouponList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询车牌订单列表信息") public ResponseData getCouponList() { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2 FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/getCouponList" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/sendCoupon", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "发放券") public ResponseData sendCoupon(@RequestParam(name = "couponCode", required = true) String couponCode, @RequestParam(name = "receiverCount", required = true) String receiverCount, @RequestParam(name = "receiverPhone", required = true) String receiverPhone) { try { Map mapPost = new HashMap<>(); mapPost.put("merchId" , "20230258302"); mapPost.put("sign" , WxUtils.generateSignApi(mapPost, "0C7897EA3BD96156A5881618FF2FF645", WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/blxCoupon/getCouponList" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/preorder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "发起支付") public ResponseData preorder() { try { JSONObject object = new JSONObject(); object.put("outTradeNo" , "HUI" + OrderUtil.generateOrderNo()); object.put("transType" , "JSAPI"); object.put("payMode" , "WECHAT"); object.put("totalAmount" , "0.01"); object.put("profitSharing" , 0); object.put("subject" , "测试"); object.put("userId" , "oUGn_4unIjp90MY-oEXluY4laDrQ"); return ResponseMsgUtil.success(huiConfig.preorder(object)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryGasInfoListByPage", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询团油门店") public ResponseData queryGasInfoListByPage() { try { HighMerchantModel merchant = highMerchantService.getMerchantById(39L); 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.setSourceType(2); 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.setPrestoreType(0); 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.getString("oilNo")); if (highGasOilPrice == null) { highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("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")); highGasOilPrice.setStatus(GasOilPriceStatusEnum.status1.getStatus()); } else { highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("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.setSourceType(2); 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.setPrestoreType(0); 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.getString("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("完成"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/test", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "测试") public ResponseData test(@RequestParam(name = "no", required = true) String no) { try { JSONObject jsonObject = DianConfig.getGasInfoByGasId(no); return ResponseMsgUtil.success(jsonObject); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getGasInfoAll", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取全量油站") public ResponseData getGasInfoAll() { try { HighMerchantModel merchant = highMerchantService.getMerchantById(39L); JSONObject jsonObject = DianConfig.getGasInfoAll(); JSONArray resultObject = jsonObject.getObject("result", JSONArray.class); for (int i = 0; i < resultObject.size();i++) { Object objectData = resultObject.get(i); JSONObject object = JSONObject.parseObject(JSONObject.toJSONString(objectData)); HighMerchantStore highMerchantStore; HighGasOilPrice highGasOilPrice; HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreByKey(object.getString("jyzid")); SecRegion region = commonService.getRegionsByName(object.getString("province")); if (store != null) { store.setType(1); store.setSourceType(6); store.setMerchantId(merchant.getId()); store.setCompanyId(merchant.getCompanyId()); store.setStoreKey(object.getString("jyzid")); store.setStoreName(object.getString("mingcheng")); store.setStoreLogo(object.getString("tupian")); store.setRegionId(region.getRegionId()); store.setRegionName(object.getString("province")); store.setAddress(object.getString("dizhi")); store.setLongitude(object.getString("lng")); store.setLatitude(object.getString("lat")); store.setStatus(object.getInteger("zhuangtai")); store.setPrestoreType(0); 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.getString("youhao")); if (highGasOilPrice == null) { highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("youhao")); highGasOilPrice.setOilNoName(oilPriceObject.getString("youhao") + "#"); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oiltype")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oiltype").equals("1") ? "汽油": "柴油"); highGasOilPrice.setStatus(GasOilPriceStatusEnum.status1.getStatus()); } else { highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("youhao")); highGasOilPrice.setOilNoName( oilPriceObject.getString("youhao") + "#"); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oiltype")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oiltype").equals("1") ? "汽油": "柴油"); } highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } else { highMerchantStore = new HighMerchantStore(); highMerchantStore.setType(1); highMerchantStore.setSourceType(6); highMerchantStore.setMerchantId(merchant.getId()); highMerchantStore.setCompanyId(merchant.getCompanyId()); highMerchantStore.setStoreKey(object.getString("jyzid")); highMerchantStore.setStoreName(object.getString("mingcheng")); highMerchantStore.setStoreLogo(object.getString("tupian")); highMerchantStore.setRegionId(region.getRegionId()); highMerchantStore.setRegionName(object.getString("province")); highMerchantStore.setAddress(object.getString("dizhi")); highMerchantStore.setLongitude(object.getString("lng")); highMerchantStore.setLatitude(object.getString("lat")); highMerchantStore.setStatus(1); highMerchantStore.setPrestoreType(0); 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.getString("youhao")); highGasOilPrice.setOilNoName(oilPriceObject.getString("youhao") + "#"); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oiltype")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oiltype").equals("1") ? "汽油": "柴油"); highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } } return ResponseMsgUtil.success(jsonObject); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getOrderPay", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "getOrderPay") public ResponseData getOrderPay(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOilCardOrder highOilCardOrder = highOilCardOrderService.findOrder(orderNo); highOilCardOrder.setStatus(2); JSONObject object = KytcService.getOrderPay(highOilCardOrder.getThirdOrderNo() , highOilCardOrder.getPrice() , highOilCardOrder.getCardNo()); highOilCardOrder.setExt1(object.toJSONString()); highOilCardOrderService.updateOilCardOrder(highOilCardOrder); return ResponseMsgUtil.success("成功"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getOrderInfo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "getOrderInfo") public ResponseData getOrderInfo(@RequestParam(name = "orderNo", required = true) String orderNo) { try { HighOilCardOrder highOilCardOrder = highOilCardOrderService.findOrder(orderNo); JSONObject object = KytcService.getOrderInfo(highOilCardOrder.getThirdOrderNo()); highOilCardOrder.setExt2(object.toJSONString()); if (object.getBoolean("State") == true) { JSONObject jsonObject = object.getJSONObject("Data"); if (jsonObject.getInteger("OilOrderState") == 2) { highOilCardOrder.setStatus(3); HighOrder highOrder = highOrderService.getOrderByOrderNo(highOilCardOrder.getOrderNo()); highOrder.setOrderStatus(3); highOrder.getHighChildOrderList().get(0).setChildOrderStatus(3); highOrderService.updateOrder(highOrder); } } highOilCardOrderService.updateOilCardOrder(highOilCardOrder); return ResponseMsgUtil.success("成功"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file diff --git a/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java b/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java index cfb3f453..2279fb54 100644 --- a/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java +++ b/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java @@ -145,6 +145,7 @@ public class AuthConfig implements WebMvcConfigurer { .excludePathPatterns("/outRechargePrice/*") .excludePathPatterns("/userDiscount/*") .excludePathPatterns("/highThirdParty/*") + .excludePathPatterns("/group/*") ; } diff --git a/hai-cweb/src/main/java/com/cweb/controller/CommonController.java b/hai-cweb/src/main/java/com/cweb/controller/CommonController.java index 41485c9d..5c597cb1 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/CommonController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/CommonController.java @@ -50,6 +50,9 @@ public class CommonController { @Autowired private RedisUtil redisUtil; + @Resource + private HighUserService highUserService; + @Resource private BsIntegralRebateService bsIntegralRebateService; @@ -504,4 +507,25 @@ public class CommonController { } } + @RequestMapping(value = "/getLevelUserMsg", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "获取用户级别信息") + public ResponseData getLevelUserMsg( + @RequestParam(name = "userId", required = false) Long userId) { + try { + + JSONObject object = new JSONObject(); + + + object.put("userLeve" , highUserService.findUserLevel(userId)); + object.put("price" , commonService.findSecConfigByType("LEVEL_PRICE").getCodeValue()); + + return ResponseMsgUtil.success(object); + + } catch (Exception e) { + log.error("HighOrderController --> unionStagingPay() error!", e); + return ResponseMsgUtil.exception(e); + } + } + } diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighGasController.java b/hai-cweb/src/main/java/com/cweb/controller/HighGasController.java index b355f9b1..dfe7e9ae 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighGasController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighGasController.java @@ -49,17 +49,16 @@ public class HighGasController { @Resource private HighOrderService highOrderService; + @Resource - private CommonService commonService; + private HighMerchantStoreService highMerchantStoreService; @Resource - private HighTyAgentOilStationService tyAgentOilStationService; + private CommonService commonService; @Resource private HighTyAgentPriceService tyAgentPriceService; - @Resource - private HighGasOrderPushMapper highGasOrderPushMapper; @Resource private HighMerchantStoreService merchantStoreService; @@ -170,7 +169,7 @@ public class HighGasController { } } - } else if (MapUtils.getInteger(map, "source_type").equals(2)|| MapUtils.getInteger(map, "source_type").equals(6)) { + } else if (MapUtils.getInteger(map, "source_type").equals(2)) { // 查询是否配置了【油站的】优惠比例 HighTyAgentPrice tyAgentPrice = tyAgentPriceService.getDetail(1, MapUtils.getLong(map, "id"), MapUtils.getString(map, "oil_no")); if (tyAgentPrice != null) { @@ -287,7 +286,8 @@ public class HighGasController { if (store.getSourceType().equals(MerchantStoreSourceType.type1.getNumber()) || store.getSourceType().equals(MerchantStoreSourceType.type3.getNumber()) || store.getSourceType().equals(MerchantStoreSourceType.type4.getNumber()) - || store.getSourceType().equals(MerchantStoreSourceType.type5.getNumber())) { + || store.getSourceType().equals(MerchantStoreSourceType.type5.getNumber()) + || store.getSourceType().equals(MerchantStoreSourceType.type7.getNumber())) { Map param = new HashMap<>(); param.put("provinceName", null); param.put("provinceCode", null); @@ -387,6 +387,10 @@ public class HighGasController { oilPriceMapList.add(oilPriceMap); } param.put("oilPriceList", oilPriceMapList); + if (store.getSourceType().equals(MerchantStoreSourceType.type7.getNumber())) { + param.put("oilCardList", highMerchantStoreService.getStoreOilCardList(store.getId())); + param.put("img", store.getExt3()); + } return ResponseMsgUtil.success(param); @@ -495,40 +499,13 @@ public class HighGasController { price.put("priceOfficial" , price.getString("priceGun")); price.put("oilNo" , price.getString("youhao")); price.put("oilType" , price.getString("oiltype")); + price.put("priceVip" , price.getString("priceVip")); // 查询油站油品状态 HighGasOilPrice oilNo = highGasOilPriceService.getGasOilPriceByStoreAndOilNo(store.getId(), price.getString("youhao")); if (oilNo != null && !oilNo.getStatus().equals(GasOilPriceStatusEnum.status1.getStatus())) { continue; } - // 查询是否配置了【油站的】优惠比例 - HighTyAgentPrice tyAgentPrice = tyAgentPriceService.getDetail(1, store.getId(), price.getString("youhao")); - if (tyAgentPrice != null) { - // 优惠比例 / 100 = 最终优惠比例 - BigDecimal priceRate = tyAgentPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN)); - // 油品国标价 * 最终优惠比例 - price.put("priceVip", price.getBigDecimal("priceGun").multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP)); - } else { - // 查询是否配置了【油品】优惠比例 - HighGasDiscountOilPrice gasDiscountOilPrice = gasDiscountOilPriceService.getDetailByOilNo(price.getString("youhao")); - if (gasDiscountOilPrice != null) { - // 优惠比例 / 100 = 最终优惠比例 - BigDecimal priceRate = gasDiscountOilPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN)); - // 油品国标价 * 最终优惠比例 - price.put("priceVip", price.getBigDecimal("priceGun").multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP)); - } - } - - // 查询是否配置了【代理商油站】优惠比例 - if (isTyAgent != null && isTyAgent == true) { - HighTyAgentPrice agentPrice = tyAgentPriceService.getDetail(2, store.getId(), price.getString("youhao")); - if (agentPrice != null) { - // 优惠比例 / 100 = 最终优惠比例 - BigDecimal priceRate = agentPrice.getPriceRate().divide(new BigDecimal("100").setScale(2, BigDecimal.ROUND_DOWN)); - // 油品国标价 * 最终优惠比例 - price.put("priceVip", price.getBigDecimal("priceGun").multiply(priceRate).setScale(2, BigDecimal.ROUND_HALF_UP)); - } - } newOilPriceList.add(price); } diff --git a/hai-cweb/src/main/java/com/cweb/controller/group/GroupController.java b/hai-cweb/src/main/java/com/cweb/controller/group/GroupController.java new file mode 100644 index 00000000..0414daea --- /dev/null +++ b/hai-cweb/src/main/java/com/cweb/controller/group/GroupController.java @@ -0,0 +1,149 @@ +package com.cweb.controller.group; + + +import com.alibaba.fastjson.JSONObject; +import com.hai.common.security.SessionObject; +import com.hai.common.security.UserCenter; +import com.hai.common.utils.ResponseMsgUtil; +import com.hai.entity.BsMsg; +import com.hai.group.GroupService; +import com.hai.model.HighUserModel; +import com.hai.model.ResponseData; +import com.hai.service.BsMsgService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @author sum1dream + */ +@Controller +@RequestMapping(value = "/group") +@Api(value = "团购") +public class GroupController { + + Logger log = LoggerFactory.getLogger(GroupController.class); + + + @Resource + private GroupService groupService; + + @RequestMapping(value="/getStoreList",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "商户查询门店列表") + public ResponseData getStoreListByMer( + @RequestParam(value = "name" , required = false) String name, + @RequestParam(value = "childId" , required = false) Long childId, + @RequestParam(value = "parentId" , required = false) Long parentId, + @RequestParam(name = "longitude", required = false) String longitude, + @RequestParam(name = "latitude", required = false) String latitude + ) { + try { + + JSONObject map = new JSONObject(); + map.put("name" , name); + map.put("childId" , childId); + map.put("parentId" , parentId); + map.put("longitude" , longitude); + map.put("latitude" , latitude); + + JSONObject object = groupService.getStoreList(map); + + if (object.getString("return_code").equals("000000")) { + return ResponseMsgUtil.success(object.getJSONArray("return_data")); + } else { + + return ResponseMsgUtil.success(object.getString("return_msg")); + } + + + } catch (Exception e) { + log.error(e.getMessage(), e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/getGroupContent",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询团购内容") + public ResponseData getGroupContent(@RequestParam(value = "groupId" , required = true) Long groupId) { + try { + + JSONObject object = groupService.getGroupContent(groupId); + + if (object.getString("return_code").equals("000000")) { + return ResponseMsgUtil.success(object.getJSONObject("return_data")); + } else { + + return ResponseMsgUtil.success(object.getString("return_msg")); + } + + + } catch (Exception e) { + log.error(e.getMessage(), e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value="/getStoreMsg",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询门店信息") + public ResponseData getStoreMsg(@RequestParam(value = "storeId" , required = true) Long storeId) { + try { + + + JSONObject object = groupService.getStoreMsg(storeId); + + if (object.getString("return_code").equals("000000")) { + return ResponseMsgUtil.success(object.getJSONObject("return_data")); + } else { + + return ResponseMsgUtil.success(object.getString("return_msg")); + } + + + } catch (Exception e) { + log.error(e.getMessage(), e); + return ResponseMsgUtil.exception(e); + } + } + + + @RequestMapping(value="/getBsStoreImgByList",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询门店图片列表") + public ResponseData getBsStoreImgByList( + @RequestParam(value = "type" , required = false) Integer type, + @RequestParam(value = "storeId" , required = false) Long storeId) { + try { + JSONObject map = new JSONObject(); + map.put("storeId" , storeId); + map.put("type" , type); + + JSONObject object = groupService.getBsStoreImgByList(map); + + if (object.getString("return_code").equals("000000")) { + return ResponseMsgUtil.success(object.getJSONArray("return_data")); + } else { + + return ResponseMsgUtil.success(object.getString("return_msg")); + } + + } catch (Exception e) { + log.error(e.getMessage(), e); + return ResponseMsgUtil.exception(e); + } + } +} diff --git a/hai-order/src/main/java/com/web/controller/OrderPayController.java b/hai-order/src/main/java/com/web/controller/OrderPayController.java index 89ffc696..88873c7c 100644 --- a/hai-order/src/main/java/com/web/controller/OrderPayController.java +++ b/hai-order/src/main/java/com/web/controller/OrderPayController.java @@ -163,7 +163,11 @@ public class OrderPayController { if (productType != null) { orderTitle = productType.getName(); } + JSONObject objectGas = new JSONObject(); + Integer payPlatformType = 1; + String payPlatformKey = null; + String payPlatformMerNo = null; if (PlatformType.TYPE2.getNumber().equals(body.getInteger("platformType"))) { weChatPayReqInfo.setSub_mch_id(WxOrderConfig.MCH_ID_1648729281); @@ -246,48 +250,79 @@ public class OrderPayController { } else if (store.getSourceType().equals(MerchantStoreSourceType.type2.getNumber())) { // 查询支付配置 - HighGasChannelConfig gasChannelConfig = gasChannelConfigService.getConfig(GasChannel.type2, GasChannelPayPlatformType.type1); + HighGasChannelConfig gasChannelConfig = gasChannelConfigService.getConfig(GasChannel.type2); if (gasChannelConfig == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未配置支付参数,请稍后重试!"); } + + payPlatformType = gasChannelConfig.getPayPlatformType(); + payPlatformKey = gasChannelConfig.getPayPlatformMerKey(); + payPlatformMerNo = gasChannelConfig.getPayPlatformMerNo(); + weChatPayReqInfo.setSub_mch_id(gasChannelConfig.getPayPlatformMerNo()); profitSharing = gasChannelConfig.getProfitSharingStatus().equals(true) ? "Y" : "N"; } else if (store.getSourceType().equals(MerchantStoreSourceType.type3.getNumber())) { // 查询支付配置 - HighGasChannelConfig gasChannelConfig = gasChannelConfigService.getConfig(GasChannel.type3, GasChannelPayPlatformType.type1); + HighGasChannelConfig gasChannelConfig = gasChannelConfigService.getConfig(GasChannel.type3); if (gasChannelConfig == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未配置支付参数,请稍后重试!"); } + payPlatformType = gasChannelConfig.getPayPlatformType(); + payPlatformMerNo = gasChannelConfig.getPayPlatformMerNo(); + payPlatformKey = gasChannelConfig.getPayPlatformMerKey(); + weChatPayReqInfo.setSub_mch_id(gasChannelConfig.getPayPlatformMerNo()); profitSharing = gasChannelConfig.getProfitSharingStatus().equals(true) ? "Y" : "N"; } else if (store.getSourceType().equals(MerchantStoreSourceType.type4.getNumber())) { // 查询支付配置 - HighGasChannelConfig gasChannelConfig = gasChannelConfigService.getConfig(GasChannel.type4, GasChannelPayPlatformType.type1); + HighGasChannelConfig gasChannelConfig = gasChannelConfigService.getConfig(GasChannel.type4); if (gasChannelConfig == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未配置支付参数,请稍后重试!"); } + payPlatformType = gasChannelConfig.getPayPlatformType(); + payPlatformMerNo = gasChannelConfig.getPayPlatformMerNo(); + payPlatformKey = gasChannelConfig.getPayPlatformMerKey(); weChatPayReqInfo.setSub_mch_id(gasChannelConfig.getPayPlatformMerNo()); profitSharing = gasChannelConfig.getProfitSharingStatus().equals(true) ? "Y" : "N"; } else if (store.getSourceType().equals(MerchantStoreSourceType.type5.getNumber())) { // 查询支付配置 - HighGasChannelConfig gasChannelConfig = gasChannelConfigService.getConfig(GasChannel.type5, GasChannelPayPlatformType.type1); + HighGasChannelConfig gasChannelConfig = gasChannelConfigService.getConfig(GasChannel.type5); if (gasChannelConfig == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未配置支付参数,请稍后重试!"); } + payPlatformType = gasChannelConfig.getPayPlatformType(); + payPlatformMerNo = gasChannelConfig.getPayPlatformMerNo(); + payPlatformKey = gasChannelConfig.getPayPlatformMerKey(); weChatPayReqInfo.setSub_mch_id(gasChannelConfig.getPayPlatformMerNo()); profitSharing = gasChannelConfig.getProfitSharingStatus().equals(true) ? "Y" : "N"; } else if (store.getSourceType().equals(MerchantStoreSourceType.type6.getNumber())) { // 查询支付配置 - HighGasChannelConfig gasChannelConfig = gasChannelConfigService.getConfig(GasChannel.type2, GasChannelPayPlatformType.type1); + HighGasChannelConfig gasChannelConfig = gasChannelConfigService.getConfig(GasChannel.type6); if (gasChannelConfig == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未配置支付参数,请稍后重试!"); } + payPlatformType = gasChannelConfig.getPayPlatformType(); + payPlatformMerNo = gasChannelConfig.getPayPlatformMerNo(); + payPlatformKey = gasChannelConfig.getPayPlatformMerKey(); + weChatPayReqInfo.setSub_mch_id(gasChannelConfig.getPayPlatformMerNo()); + profitSharing = gasChannelConfig.getProfitSharingStatus().equals(true) ? "Y" : "N"; + + } else if (store.getSourceType().equals(MerchantStoreSourceType.type7.getNumber())) { + + // 查询支付配置 + HighGasChannelConfig gasChannelConfig = gasChannelConfigService.getConfig(GasChannel.type7); + if (gasChannelConfig == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未配置支付参数,请稍后重试!"); + } + payPlatformType = gasChannelConfig.getPayPlatformType(); + payPlatformMerNo = gasChannelConfig.getPayPlatformMerNo(); + payPlatformKey = gasChannelConfig.getPayPlatformMerKey(); weChatPayReqInfo.setSub_mch_id(gasChannelConfig.getPayPlatformMerNo()); profitSharing = gasChannelConfig.getProfitSharingStatus().equals(true) ? "Y" : "N"; @@ -306,6 +341,17 @@ public class OrderPayController { } else if (order.getProductType().equals(OrderProductType.PRODUCT_TYPE12.getNumber())) { weChatPayReqInfo.setSub_mch_id(WxOrderConfig.MCH_ID_1614670195); + } else if (order.getProductType().equals(OrderProductType.PRODUCT_TYPE15.getNumber())) { + // 查询支付配置 + HighGasChannelConfig gasChannelConfig = gasChannelConfigService.getConfig(GasChannel.type7); + if (gasChannelConfig == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未配置支付参数,请稍后重试!"); + } + payPlatformType = gasChannelConfig.getPayPlatformType(); + payPlatformMerNo = gasChannelConfig.getPayPlatformMerNo(); + payPlatformKey = gasChannelConfig.getPayPlatformMerKey(); + weChatPayReqInfo.setSub_mch_id(gasChannelConfig.getPayPlatformMerNo()); + profitSharing = gasChannelConfig.getProfitSharingStatus().equals(true) ? "Y" : "N"; } else { weChatPayReqInfo.setSub_mch_id(WxOrderConfig.MCH_ID_1609882817); } @@ -327,8 +373,24 @@ public class OrderPayController { weChatPayReqInfo.setTime_expire(DateUtil.date2String(DateUtil.addMinute(order.getCreateTime(), 10), "yyyyMMddHHmmss")); SortedMap sortedMap; - - if (!order.getProductType().equals(OrderProductType.PRODUCT_TYPE6.getNumber())) { + + if (payPlatformType == 2) { + objectGas.put("outTradeNo" , order.getOrderNo()); + objectGas.put("transType" , "JSAPI"); + objectGas.put("payMode" , "WECHAT"); + objectGas.put("totalAmount" , order.getTotalPrice()); + objectGas.put("profitSharing" , 0); + objectGas.put("notifyUrl" , SysConst.getSysConfig().getHuiPayNotify()); + objectGas.put("subject" , orderTitle); + objectGas.put("userId" , body.getString("openId")); + + sortedMap = huiConfig.preorder(objectGas , payPlatformKey , payPlatformMerNo); + + order.setAccountMerchantNum(payPlatformMerNo); + order.setProfitSharingStatus(false); + order.setPayChannel(2); + orderService.updateOrderData(order); + } else { //附加数据,区分订单类型 Map payMap = new HashMap<>(); payMap.put("app_id", weChatPayReqInfo.getSub_appid()); @@ -341,25 +403,6 @@ public class OrderPayController { order.setProfitSharingStatus(profitSharing.equals("Y")); order.setPayChannel(1); orderService.updateOrderData(order); - - } else { - JSONObject object = new JSONObject(); - object.put("outTradeNo" , order.getOrderNo()); - object.put("transType" , "JSAPI"); - object.put("payMode" , "WECHAT"); - object.put("totalAmount" , order.getPayPrice()); - object.put("profitSharing" , 0); - object.put("notifyUrl" , SysConst.getSysConfig().getHuiPayNotify()); - object.put("subject" , orderTitle); - object.put("userId" , body.getString("openId")); - - sortedMap = huiConfig.preorder(object); - - order.setAccountMerchantNum(HuiConfig.hlMerNo); - order.setProfitSharingStatus(false); - order.setPayChannel(2); - orderService.updateOrderData(order); - } diff --git a/hai-service/src/main/java/com/hai/common/utils/WxUtils.java b/hai-service/src/main/java/com/hai/common/utils/WxUtils.java index 7766c62f..cd1c160c 100644 --- a/hai-service/src/main/java/com/hai/common/utils/WxUtils.java +++ b/hai-service/src/main/java/com/hai/common/utils/WxUtils.java @@ -1,6 +1,5 @@ package com.hai.common.utils; -import com.alibaba.fastjson.JSON; import com.google.common.collect.Maps; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.pay.util.sdk.WXPayXmlUtil; @@ -10,7 +9,6 @@ import com.thoughtworks.xstream.io.xml.XppDriver; import net.sf.cglib.beans.BeanMap; import org.apache.commons.lang3.StringUtils; -import org.springframework.util.DigestUtils; import javax.crypto.Mac; @@ -619,4 +617,25 @@ public class WxUtils { } } + + public static String generateSignKytc(Map map , String key) throws Exception { + Set keySet = map.keySet(); + String[] keyArray = keySet.toArray(new String[keySet.size()]); + Arrays.sort(keyArray); + StringBuilder sb = new StringBuilder(); + for (String k : keyArray) { + if (k.equals(WXPayConstants.FIELD_SIGN) || k.equals("key")) { + continue; + } + if (map.get(k) != null) // 参数值为空,则不参与签名 + { + sb.append(k).append("=").append(map.get(k)).append("&"); + } + } + sb.append("key=").append(key); + + return MD5(sb.toString().toUpperCase() , true); + + } + } diff --git a/hai-service/src/main/java/com/hai/config/KytcService.java b/hai-service/src/main/java/com/hai/config/KytcService.java new file mode 100644 index 00000000..658ee73e --- /dev/null +++ b/hai-service/src/main/java/com/hai/config/KytcService.java @@ -0,0 +1,39 @@ +package com.hai.config; + +import com.alibaba.fastjson.JSONObject; +import com.hai.common.pay.util.sdk.WXPayConstants; +import com.hai.common.utils.HttpsUtils; +import com.hai.common.utils.WxUtils; +import org.springframework.stereotype.Component; + +import java.math.BigDecimal; +import java.util.HashMap; +import java.util.Map; + +@Component +public class KytcService { + + private final static String reqUrl = "https://kykh.dctpay.com"; + private final static String key = "ad/s-kfa*#s!dkfjhjh"; + + public static JSONObject getOrderPay(String orderNo , BigDecimal price , String cardNo) throws Exception { + JSONObject paramMap = new JSONObject(); + + paramMap.put("Amount" ,price); + paramMap.put("OrderNo" , orderNo); + paramMap.put("CardNo" , cardNo); + paramMap.put("sign", WxUtils.generateSignKytc(paramMap , key)); + + return HttpsUtils.doPost(reqUrl + "/api/hf/order-pay", paramMap); + } + + public static JSONObject getOrderInfo(String orderNo) throws Exception { + JSONObject paramMap = new JSONObject(); + + paramMap.put("OrderNo" , orderNo); + paramMap.put("sign", WxUtils.generateSignKytc(paramMap , key)); + + return HttpsUtils.doPost(reqUrl + "/api/hf/order-info", paramMap); + } + +} diff --git a/hai-service/src/main/java/com/hai/dao/HighGasChannelConfigMapper.java b/hai-service/src/main/java/com/hai/dao/HighGasChannelConfigMapper.java index 57281c5d..66ffc110 100644 --- a/hai-service/src/main/java/com/hai/dao/HighGasChannelConfigMapper.java +++ b/hai-service/src/main/java/com/hai/dao/HighGasChannelConfigMapper.java @@ -41,18 +41,20 @@ public interface HighGasChannelConfigMapper extends HighGasChannelConfigMapperEx @Insert({ "insert into high_gas_channel_config (channel_id, channel_name, ", "pay_platform_type, pay_platform_mer_name, ", - "pay_platform_mer_no, profit_sharing_status, ", - "profit_sharing_receivers_no, profit_sharing_ratio, ", - "profit_sharing_receivers_name, `status`, ", - "create_time, update_time, ", - "ext_1, ext_2, ext_3)", + "pay_platform_mer_no, pay_platform_mer_key, ", + "profit_sharing_status, profit_sharing_receivers_no, ", + "profit_sharing_ratio, profit_sharing_receivers_name, ", + "`status`, create_time, ", + "update_time, ext_1, ", + "ext_2, ext_3)", "values (#{channelId,jdbcType=INTEGER}, #{channelName,jdbcType=VARCHAR}, ", "#{payPlatformType,jdbcType=INTEGER}, #{payPlatformMerName,jdbcType=VARCHAR}, ", - "#{payPlatformMerNo,jdbcType=VARCHAR}, #{profitSharingStatus,jdbcType=BIT}, ", - "#{profitSharingReceiversNo,jdbcType=VARCHAR}, #{profitSharingRatio,jdbcType=DECIMAL}, ", - "#{profitSharingReceiversName,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, ", - "#{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, ", - "#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" + "#{payPlatformMerNo,jdbcType=VARCHAR}, #{payPlatformMerKey,jdbcType=VARCHAR}, ", + "#{profitSharingStatus,jdbcType=BIT}, #{profitSharingReceiversNo,jdbcType=VARCHAR}, ", + "#{profitSharingRatio,jdbcType=DECIMAL}, #{profitSharingReceiversName,jdbcType=VARCHAR}, ", + "#{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(HighGasChannelConfig record); @@ -69,6 +71,7 @@ public interface HighGasChannelConfigMapper extends HighGasChannelConfigMapperEx @Result(column="pay_platform_type", property="payPlatformType", jdbcType=JdbcType.INTEGER), @Result(column="pay_platform_mer_name", property="payPlatformMerName", jdbcType=JdbcType.VARCHAR), @Result(column="pay_platform_mer_no", property="payPlatformMerNo", jdbcType=JdbcType.VARCHAR), + @Result(column="pay_platform_mer_key", property="payPlatformMerKey", jdbcType=JdbcType.VARCHAR), @Result(column="profit_sharing_status", property="profitSharingStatus", jdbcType=JdbcType.BIT), @Result(column="profit_sharing_receivers_no", property="profitSharingReceiversNo", jdbcType=JdbcType.VARCHAR), @Result(column="profit_sharing_ratio", property="profitSharingRatio", jdbcType=JdbcType.DECIMAL), @@ -85,8 +88,9 @@ public interface HighGasChannelConfigMapper extends HighGasChannelConfigMapperEx @Select({ "select", "id, channel_id, channel_name, pay_platform_type, pay_platform_mer_name, pay_platform_mer_no, ", - "profit_sharing_status, profit_sharing_receivers_no, profit_sharing_ratio, profit_sharing_receivers_name, ", - "`status`, create_time, update_time, ext_1, ext_2, ext_3", + "pay_platform_mer_key, profit_sharing_status, profit_sharing_receivers_no, profit_sharing_ratio, ", + "profit_sharing_receivers_name, `status`, create_time, update_time, ext_1, ext_2, ", + "ext_3", "from high_gas_channel_config", "where id = #{id,jdbcType=BIGINT}" }) @@ -97,6 +101,7 @@ public interface HighGasChannelConfigMapper extends HighGasChannelConfigMapperEx @Result(column="pay_platform_type", property="payPlatformType", jdbcType=JdbcType.INTEGER), @Result(column="pay_platform_mer_name", property="payPlatformMerName", jdbcType=JdbcType.VARCHAR), @Result(column="pay_platform_mer_no", property="payPlatformMerNo", jdbcType=JdbcType.VARCHAR), + @Result(column="pay_platform_mer_key", property="payPlatformMerKey", jdbcType=JdbcType.VARCHAR), @Result(column="profit_sharing_status", property="profitSharingStatus", jdbcType=JdbcType.BIT), @Result(column="profit_sharing_receivers_no", property="profitSharingReceiversNo", jdbcType=JdbcType.VARCHAR), @Result(column="profit_sharing_ratio", property="profitSharingRatio", jdbcType=JdbcType.DECIMAL), @@ -126,6 +131,7 @@ public interface HighGasChannelConfigMapper extends HighGasChannelConfigMapperEx "pay_platform_type = #{payPlatformType,jdbcType=INTEGER},", "pay_platform_mer_name = #{payPlatformMerName,jdbcType=VARCHAR},", "pay_platform_mer_no = #{payPlatformMerNo,jdbcType=VARCHAR},", + "pay_platform_mer_key = #{payPlatformMerKey,jdbcType=VARCHAR},", "profit_sharing_status = #{profitSharingStatus,jdbcType=BIT},", "profit_sharing_receivers_no = #{profitSharingReceiversNo,jdbcType=VARCHAR},", "profit_sharing_ratio = #{profitSharingRatio,jdbcType=DECIMAL},", diff --git a/hai-service/src/main/java/com/hai/dao/HighGasChannelConfigSqlProvider.java b/hai-service/src/main/java/com/hai/dao/HighGasChannelConfigSqlProvider.java index e15430af..ed1c652f 100644 --- a/hai-service/src/main/java/com/hai/dao/HighGasChannelConfigSqlProvider.java +++ b/hai-service/src/main/java/com/hai/dao/HighGasChannelConfigSqlProvider.java @@ -48,6 +48,10 @@ public class HighGasChannelConfigSqlProvider { sql.VALUES("pay_platform_mer_no", "#{payPlatformMerNo,jdbcType=VARCHAR}"); } + if (record.getPayPlatformMerKey() != null) { + sql.VALUES("pay_platform_mer_key", "#{payPlatformMerKey,jdbcType=VARCHAR}"); + } + if (record.getProfitSharingStatus() != null) { sql.VALUES("profit_sharing_status", "#{profitSharingStatus,jdbcType=BIT}"); } @@ -103,6 +107,7 @@ public class HighGasChannelConfigSqlProvider { sql.SELECT("pay_platform_type"); sql.SELECT("pay_platform_mer_name"); sql.SELECT("pay_platform_mer_no"); + sql.SELECT("pay_platform_mer_key"); sql.SELECT("profit_sharing_status"); sql.SELECT("profit_sharing_receivers_no"); sql.SELECT("profit_sharing_ratio"); @@ -154,6 +159,10 @@ public class HighGasChannelConfigSqlProvider { sql.SET("pay_platform_mer_no = #{record.payPlatformMerNo,jdbcType=VARCHAR}"); } + if (record.getPayPlatformMerKey() != null) { + sql.SET("pay_platform_mer_key = #{record.payPlatformMerKey,jdbcType=VARCHAR}"); + } + if (record.getProfitSharingStatus() != null) { sql.SET("profit_sharing_status = #{record.profitSharingStatus,jdbcType=BIT}"); } @@ -208,6 +217,7 @@ public class HighGasChannelConfigSqlProvider { sql.SET("pay_platform_type = #{record.payPlatformType,jdbcType=INTEGER}"); sql.SET("pay_platform_mer_name = #{record.payPlatformMerName,jdbcType=VARCHAR}"); sql.SET("pay_platform_mer_no = #{record.payPlatformMerNo,jdbcType=VARCHAR}"); + sql.SET("pay_platform_mer_key = #{record.payPlatformMerKey,jdbcType=VARCHAR}"); sql.SET("profit_sharing_status = #{record.profitSharingStatus,jdbcType=BIT}"); sql.SET("profit_sharing_receivers_no = #{record.profitSharingReceiversNo,jdbcType=VARCHAR}"); sql.SET("profit_sharing_ratio = #{record.profitSharingRatio,jdbcType=DECIMAL}"); @@ -248,6 +258,10 @@ public class HighGasChannelConfigSqlProvider { sql.SET("pay_platform_mer_no = #{payPlatformMerNo,jdbcType=VARCHAR}"); } + if (record.getPayPlatformMerKey() != null) { + sql.SET("pay_platform_mer_key = #{payPlatformMerKey,jdbcType=VARCHAR}"); + } + if (record.getProfitSharingStatus() != null) { sql.SET("profit_sharing_status = #{profitSharingStatus,jdbcType=BIT}"); } diff --git a/hai-service/src/main/java/com/hai/entity/HighGasChannelConfig.java b/hai-service/src/main/java/com/hai/entity/HighGasChannelConfig.java index 2b243585..65032172 100644 --- a/hai-service/src/main/java/com/hai/entity/HighGasChannelConfig.java +++ b/hai-service/src/main/java/com/hai/entity/HighGasChannelConfig.java @@ -20,7 +20,7 @@ public class HighGasChannelConfig implements Serializable { private Long id; /** - * 渠道id 1:自建站 2:团油 3:加好油 4:金猪加油 6:点点网络 + * 渠道id 1:自建站 2:团油 3:加好油 4:金猪加油 */ private Integer channelId; @@ -30,7 +30,7 @@ public class HighGasChannelConfig implements Serializable { private String channelName; /** - * 平台类型 1:微信 + * 平台类型 1:微信 2: 惠支付 */ private Integer payPlatformType; @@ -44,6 +44,11 @@ public class HighGasChannelConfig implements Serializable { */ private String payPlatformMerNo; + /** + * 商户key + */ + private String payPlatformMerKey; + /** * 是否分账 */ @@ -135,6 +140,14 @@ public class HighGasChannelConfig implements Serializable { this.payPlatformMerNo = payPlatformMerNo; } + public String getPayPlatformMerKey() { + return payPlatformMerKey; + } + + public void setPayPlatformMerKey(String payPlatformMerKey) { + this.payPlatformMerKey = payPlatformMerKey; + } + public Boolean getProfitSharingStatus() { return profitSharingStatus; } @@ -233,6 +246,7 @@ public class HighGasChannelConfig implements Serializable { && (this.getPayPlatformType() == null ? other.getPayPlatformType() == null : this.getPayPlatformType().equals(other.getPayPlatformType())) && (this.getPayPlatformMerName() == null ? other.getPayPlatformMerName() == null : this.getPayPlatformMerName().equals(other.getPayPlatformMerName())) && (this.getPayPlatformMerNo() == null ? other.getPayPlatformMerNo() == null : this.getPayPlatformMerNo().equals(other.getPayPlatformMerNo())) + && (this.getPayPlatformMerKey() == null ? other.getPayPlatformMerKey() == null : this.getPayPlatformMerKey().equals(other.getPayPlatformMerKey())) && (this.getProfitSharingStatus() == null ? other.getProfitSharingStatus() == null : this.getProfitSharingStatus().equals(other.getProfitSharingStatus())) && (this.getProfitSharingReceiversNo() == null ? other.getProfitSharingReceiversNo() == null : this.getProfitSharingReceiversNo().equals(other.getProfitSharingReceiversNo())) && (this.getProfitSharingRatio() == null ? other.getProfitSharingRatio() == null : this.getProfitSharingRatio().equals(other.getProfitSharingRatio())) @@ -255,6 +269,7 @@ public class HighGasChannelConfig implements Serializable { result = prime * result + ((getPayPlatformType() == null) ? 0 : getPayPlatformType().hashCode()); result = prime * result + ((getPayPlatformMerName() == null) ? 0 : getPayPlatformMerName().hashCode()); result = prime * result + ((getPayPlatformMerNo() == null) ? 0 : getPayPlatformMerNo().hashCode()); + result = prime * result + ((getPayPlatformMerKey() == null) ? 0 : getPayPlatformMerKey().hashCode()); result = prime * result + ((getProfitSharingStatus() == null) ? 0 : getProfitSharingStatus().hashCode()); result = prime * result + ((getProfitSharingReceiversNo() == null) ? 0 : getProfitSharingReceiversNo().hashCode()); result = prime * result + ((getProfitSharingRatio() == null) ? 0 : getProfitSharingRatio().hashCode()); @@ -280,6 +295,7 @@ public class HighGasChannelConfig implements Serializable { sb.append(", payPlatformType=").append(payPlatformType); sb.append(", payPlatformMerName=").append(payPlatformMerName); sb.append(", payPlatformMerNo=").append(payPlatformMerNo); + sb.append(", payPlatformMerKey=").append(payPlatformMerKey); sb.append(", profitSharingStatus=").append(profitSharingStatus); sb.append(", profitSharingReceiversNo=").append(profitSharingReceiversNo); sb.append(", profitSharingRatio=").append(profitSharingRatio); diff --git a/hai-service/src/main/java/com/hai/entity/HighGasChannelConfigExample.java b/hai-service/src/main/java/com/hai/entity/HighGasChannelConfigExample.java index 49af0e58..fd2296f2 100644 --- a/hai-service/src/main/java/com/hai/entity/HighGasChannelConfigExample.java +++ b/hai-service/src/main/java/com/hai/entity/HighGasChannelConfigExample.java @@ -516,6 +516,76 @@ public class HighGasChannelConfigExample { return (Criteria) this; } + public Criteria andPayPlatformMerKeyIsNull() { + addCriterion("pay_platform_mer_key is null"); + return (Criteria) this; + } + + public Criteria andPayPlatformMerKeyIsNotNull() { + addCriterion("pay_platform_mer_key is not null"); + return (Criteria) this; + } + + public Criteria andPayPlatformMerKeyEqualTo(String value) { + addCriterion("pay_platform_mer_key =", value, "payPlatformMerKey"); + return (Criteria) this; + } + + public Criteria andPayPlatformMerKeyNotEqualTo(String value) { + addCriterion("pay_platform_mer_key <>", value, "payPlatformMerKey"); + return (Criteria) this; + } + + public Criteria andPayPlatformMerKeyGreaterThan(String value) { + addCriterion("pay_platform_mer_key >", value, "payPlatformMerKey"); + return (Criteria) this; + } + + public Criteria andPayPlatformMerKeyGreaterThanOrEqualTo(String value) { + addCriterion("pay_platform_mer_key >=", value, "payPlatformMerKey"); + return (Criteria) this; + } + + public Criteria andPayPlatformMerKeyLessThan(String value) { + addCriterion("pay_platform_mer_key <", value, "payPlatformMerKey"); + return (Criteria) this; + } + + public Criteria andPayPlatformMerKeyLessThanOrEqualTo(String value) { + addCriterion("pay_platform_mer_key <=", value, "payPlatformMerKey"); + return (Criteria) this; + } + + public Criteria andPayPlatformMerKeyLike(String value) { + addCriterion("pay_platform_mer_key like", value, "payPlatformMerKey"); + return (Criteria) this; + } + + public Criteria andPayPlatformMerKeyNotLike(String value) { + addCriterion("pay_platform_mer_key not like", value, "payPlatformMerKey"); + return (Criteria) this; + } + + public Criteria andPayPlatformMerKeyIn(List values) { + addCriterion("pay_platform_mer_key in", values, "payPlatformMerKey"); + return (Criteria) this; + } + + public Criteria andPayPlatformMerKeyNotIn(List values) { + addCriterion("pay_platform_mer_key not in", values, "payPlatformMerKey"); + return (Criteria) this; + } + + public Criteria andPayPlatformMerKeyBetween(String value1, String value2) { + addCriterion("pay_platform_mer_key between", value1, value2, "payPlatformMerKey"); + return (Criteria) this; + } + + public Criteria andPayPlatformMerKeyNotBetween(String value1, String value2) { + addCriterion("pay_platform_mer_key not between", value1, value2, "payPlatformMerKey"); + return (Criteria) this; + } + public Criteria andProfitSharingStatusIsNull() { addCriterion("profit_sharing_status is null"); return (Criteria) this; diff --git a/hai-service/src/main/java/com/hai/enum_type/GasChannel.java b/hai-service/src/main/java/com/hai/enum_type/GasChannel.java index f120ac43..a3fe2053 100644 --- a/hai-service/src/main/java/com/hai/enum_type/GasChannel.java +++ b/hai-service/src/main/java/com/hai/enum_type/GasChannel.java @@ -12,6 +12,7 @@ public enum GasChannel { type4(4 , "金猪加油"), type5(5 , "paylo系统"), type6(6 , "点点网络"), + type7(7 , "烨歌百货"), ; private Integer type; diff --git a/hai-service/src/main/java/com/hai/enum_type/GasChannelPayPlatformType.java b/hai-service/src/main/java/com/hai/enum_type/GasChannelPayPlatformType.java index df3653a7..31064383 100644 --- a/hai-service/src/main/java/com/hai/enum_type/GasChannelPayPlatformType.java +++ b/hai-service/src/main/java/com/hai/enum_type/GasChannelPayPlatformType.java @@ -7,6 +7,7 @@ import java.util.Objects; */ public enum GasChannelPayPlatformType { type1(1 , "微信"), + type2(2 , "惠支付"), ; private Integer type; diff --git a/hai-service/src/main/java/com/hai/enum_type/MerchantStoreSourceType.java b/hai-service/src/main/java/com/hai/enum_type/MerchantStoreSourceType.java index 29fdd78b..d001e293 100644 --- a/hai-service/src/main/java/com/hai/enum_type/MerchantStoreSourceType.java +++ b/hai-service/src/main/java/com/hai/enum_type/MerchantStoreSourceType.java @@ -13,6 +13,7 @@ public enum MerchantStoreSourceType { type4(4, "金猪加油", "金猪加油"), type5(5, "paylo", "四川壳牌"), type6(6, "点点网络", "团油"), + type7(7, "油卡站点", "自建站"), ; private Integer number; diff --git a/hai-service/src/main/java/com/hai/group/GroupService.java b/hai-service/src/main/java/com/hai/group/GroupService.java new file mode 100644 index 00000000..e591c164 --- /dev/null +++ b/hai-service/src/main/java/com/hai/group/GroupService.java @@ -0,0 +1,66 @@ +package com.hai.group; + +import com.alibaba.fastjson.JSONObject; +import com.hai.common.utils.HttpsUtils; +import com.hai.config.CommonSysConst; +import org.springframework.stereotype.Component; + +import java.util.HashMap; +import java.util.Map; +@Component +public class GroupService { + + + /** + * @Author Sum1Dream + * @Name getStoreList + * @Description // 查询门店列表 + * @Date 11:24 2023/11/1 + * @Param params + * @return com.alibaba.fastjson.JSONObject + */ + public JSONObject getStoreList(JSONObject params) { + return HttpsUtils.doPost(CommonSysConst.getSysConfig().getPayPostUrl() + "/openGroup/getStoreList" , params); + } + + /** + * @Author Sum1Dream + * @Name getGroupContent + * @Description // 查询团购内容 + * @Date 11:24 2023/11/1 + * @Param groupId + * @return com.alibaba.fastjson.JSONObject + */ + public JSONObject getGroupContent(Long groupId) { + Map params = new HashMap<>(); + params.put("groupId" , groupId); + return HttpsUtils.doGet(CommonSysConst.getSysConfig().getPayPostUrl() + "/openGroup/getGroupContent" , params); + } + + /** + * @Author Sum1Dream + * @Name getStoreMsg + * @Description // 查询门店信息 + * @Date 11:24 2023/11/1 + * @Param storeId + * @return com.alibaba.fastjson.JSONObject + */ + public JSONObject getStoreMsg(Long storeId) { + Map params = new HashMap<>(); + params.put("storeId" , storeId); + return HttpsUtils.doGet(CommonSysConst.getSysConfig().getPayPostUrl() + "/openGroup/getStoreMsg" , params); + } + + /** + * @Author Sum1Dream + * @Name getBsStoreImgByList + * @Description // 门店查询图片 + * @Date 10:00 2023/11/2 + * @Param params + * @return com.alibaba.fastjson.JSONObject + */ + public JSONObject getBsStoreImgByList(JSONObject params) { + return HttpsUtils.doPost(CommonSysConst.getSysConfig().getPayPostUrl() + "/openGroup/getBsStoreImgByList" , params); + } + +} diff --git a/hai-service/src/main/java/com/hai/order/model/CreateOrderChildModel.java b/hai-service/src/main/java/com/hai/order/model/CreateOrderChildModel.java index fd759710..1d0519fa 100644 --- a/hai-service/src/main/java/com/hai/order/model/CreateOrderChildModel.java +++ b/hai-service/src/main/java/com/hai/order/model/CreateOrderChildModel.java @@ -92,6 +92,8 @@ public class CreateOrderChildModel { private String gasGunNo; // 代理商价格 private Boolean isTyAgent; + // 油卡号 + private String oilCardNo; /** ======================= 油站所需参数 ======================== **/ diff --git a/hai-service/src/main/java/com/hai/order/service/OrderCreateHandleService.java b/hai-service/src/main/java/com/hai/order/service/OrderCreateHandleService.java index c6077cdd..dd7b7062 100644 --- a/hai-service/src/main/java/com/hai/order/service/OrderCreateHandleService.java +++ b/hai-service/src/main/java/com/hai/order/service/OrderCreateHandleService.java @@ -108,4 +108,15 @@ public interface OrderCreateHandleService { */ HighChildOrder blxOrder(HighOrder order , CreateOrderChildModel createOrderChildModel) throws Exception; + /** + * @Author Sum1Dream + * @Name levelUp + * @Description // 升级会员 + * @Date 11:02 2023/11/6 + * @Param order + * @Param createOrderChildModel + * @return com.hai.entity.HighChildOrder + */ + HighChildOrder levelUp(HighOrder order , CreateOrderChildModel createOrderChildModel) throws Exception; + } diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java index 211992b7..239651ba 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java @@ -150,6 +150,9 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService { @Resource private ShoppingCartService shoppingCartService; + @Resource + private HighOilCardOrderService highOilCardOrderService; + @Override public List couponHandle(HighDiscountUserRel discountUserRel, CreateOrderChildModel createOrderChild) throws Exception { if (createOrderChild.getSaleCount() != 1) { @@ -354,6 +357,13 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService { if (store == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的油站"); } + + if (store.getSourceType() == 7) { + if (createOrderChild.getOilCardNo() == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "卡号不能为空!"); + } + } + // 查询商户 HighMerchant merchant = merchantService.getDetailById(store.getMerchantId()); if (merchant == null) { @@ -549,6 +559,20 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService { } gasOrderService.addGasOrder(gasOrder); + + if (store.getSourceType() == 7 ){ + HighOilCardOrder oilCardOrder = new HighOilCardOrder(); + oilCardOrder.setPrice(createOrderChild.getGoodsPrice()); + oilCardOrder.setCardNo(createOrderChild.getOilCardNo()); + oilCardOrder.setOrderNo(createOrderModel.getOrderNo()); + oilCardOrder.setThirdOrderNo("HF" + OrderUtil.generateOrderNo()); + oilCardOrder.setCreateTime(new Date()); + oilCardOrder.setUpdateTime(new Date()); + oilCardOrder.setStatus(1); + + highOilCardOrderService.insertOilCardOrder(oilCardOrder); + } + return childOrder; } @@ -1087,4 +1111,30 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService { return childOrder; } + + @Override + public HighChildOrder levelUp(HighOrder order, CreateOrderChildModel createOrderChildModel) throws Exception { + HighChildOrder childOrder = new HighChildOrder(); + childOrder.setOrderNo(order.getOrderNo()); + childOrder.setMemId(order.getMemId()); + childOrder.setMemName(order.getMemName()); + childOrder.setMemPhone(order.getMemPhone()); + childOrder.setChildOrderNo(OrderUtil.generateChildOrderNo()); + childOrder.setGoodsType(OrderChildGoodsType.TYPE14.getNumber()); + childOrder.setGoodsId(order.getMemId()); + childOrder.setGoodsName("升级会员"); + childOrder.setGoodsSpecName("升级会员"); + childOrder.setGoodsPrice(createOrderChildModel.getGoodsPrice()); + childOrder.setGoodsActualPrice(childOrder.getGoodsPrice()); + childOrder.setSaleCount(createOrderChildModel.getSaleCount()); + childOrder.setGiveawayType(false); + childOrder.setChildOrderStatus(OrderChildStatus.STATUS1.getNumber()); + childOrder.setTotalPrice(childOrder.getGoodsPrice()); + childOrder.setTotalActualPrice(childOrder.getGoodsPrice()); + childOrder.setTotalDeductionPrice(childOrder.getTotalPrice().subtract(childOrder.getTotalActualPrice())); + childOrder.setPraiseStatus(0); + childOrder.setCreateTime(new Date()); + + return childOrder; + } } diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java index f9ab0be4..57d2cafb 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java @@ -120,6 +120,9 @@ public class OrderPaySuccessServiceImpl implements OrderPaySuccessService { @Resource private HighOrderService highOrderService; + @Resource + private HighOilCardOrderService highOilCardOrderService; + @Override public HighOrder orderPaySuccessHandle(String orderNo, OrderPayType payType, String paySerialNo, BigDecimal payRealPrice, HighUserCard userCard) { @@ -241,6 +244,8 @@ public class OrderPaySuccessServiceImpl implements OrderPaySuccessService { blxCouponHandle(order , childOrder); } else if (childOrder.getGoodsType().equals(OrderChildGoodsType.TYPE13.getNumber())) { blxOrderHandle(order); + } else if (childOrder.getGoodsType().equals(OrderChildGoodsType.TYPE14.getNumber())) { + levelUp(order); } } } @@ -393,6 +398,17 @@ public class OrderPaySuccessServiceImpl implements OrderPaySuccessService { object.put("priceGun", gasOrder.getGasPriceGun()); // 枪单价 object.put("priceVip", gasOrder.getGasPriceVip()); // 优惠价 DianConfig.refuelingOrderPush(object); + } else if (gasOrder.getChannelType().equals(MerchantStoreSourceType.type7.getNumber())) { + + HighOilCardOrder highOilCardOrder = highOilCardOrderService.findOrder(order.getOrderNo()); + + highOilCardOrder.setStatus(2); + + JSONObject object = KytcService.getOrderPay(highOilCardOrder.getThirdOrderNo() , highOilCardOrder.getPrice() , highOilCardOrder.getCardNo()); + + highOilCardOrder.setExt1(object.toJSONString()); + + highOilCardOrderService.updateOilCardOrder(highOilCardOrder); } } } @@ -600,4 +616,25 @@ public class OrderPaySuccessServiceImpl implements OrderPaySuccessService { } + private void levelUp(HighOrder order) { + + HighUserLevel userLevel = new HighUserLevel(); + + userLevel.setLevel("1"); + userLevel.setCreateTime(new Date()); + userLevel.setUserId(order.getMemId()); + userLevel.setStatus(1); + userLevel.setUpdateTime(new Date()); + + userService.insertLevelUp(userLevel); + + + order.setOrderStatus(OrderStatus.STATUS3.getNumber()); + order.setFinishTime(new Date()); + for (HighChildOrder childOrder : order.getHighChildOrderList()) { + childOrder.setChildOrderStatus(OrderChildStatus.STATUS3.getNumber()); + } + + } + } diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java index 73db1ba4..183ccf12 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java @@ -357,6 +357,12 @@ public class OrderServiceImpl implements OrderService { order.setTitle(order.getTitle() + "+" +childOrder.getGoodsName()); order.setExt6(order.getExt6() + "," +childOrder.getGoodsImg()); } + } else if (child.getGoodsType().equals(OrderChildGoodsType.TYPE14.getNumber())) { + HighChildOrder childOrder = orderCreateHandleService.levelUp(order , child); + childOrderList.add(childOrder); + order.setProductType(OrderProductType.PRODUCT_TYPE15.getNumber()); + order.setSecUserId(childOrder.getId()); + order.setTitle("升级会员"); } else { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知业务类型"); } diff --git a/hai-service/src/main/java/com/hai/order/type/OrderChildGoodsType.java b/hai-service/src/main/java/com/hai/order/type/OrderChildGoodsType.java index c51519da..d69c88ea 100644 --- a/hai-service/src/main/java/com/hai/order/type/OrderChildGoodsType.java +++ b/hai-service/src/main/java/com/hai/order/type/OrderChildGoodsType.java @@ -22,6 +22,7 @@ public enum OrderChildGoodsType { TYPE11(11, "实物商品购买"), TYPE12(12, "比邻星停车券"), TYPE13(13, "比邻星停车"), + TYPE14(14, "升级会员"), ; private Integer number; diff --git a/hai-service/src/main/java/com/hai/order/type/OrderProductType.java b/hai-service/src/main/java/com/hai/order/type/OrderProductType.java index 3b3d8cd0..8a2757e0 100644 --- a/hai-service/src/main/java/com/hai/order/type/OrderProductType.java +++ b/hai-service/src/main/java/com/hai/order/type/OrderProductType.java @@ -24,6 +24,7 @@ public enum OrderProductType { PRODUCT_TYPE12(12, "实物商品" , "orderLogo/goods.png", "GOODS"), PRODUCT_TYPE13(13, "比邻星停车券" , "orderLogo/coupon.png", "BLX_COUPON"), PRODUCT_TYPE14(14, "比邻星停车业务" , "orderLogo/coupon.png", "BLX_PARK"), + PRODUCT_TYPE15(15, "升级会员" , "orderLogo/coupon.png", "LEVEL_UP"), PRODUCT_TYPE101(101, "惠支付" , "orderLogo/pay.png", "PAY"), PRODUCT_TYPE102(102, "门店活动" , "orderLogo/store_activity.png", "STORE_ACTIVITY"), ; diff --git a/hai-service/src/main/java/com/hai/pay/channel/huipay/config/HuiConfig.java b/hai-service/src/main/java/com/hai/pay/channel/huipay/config/HuiConfig.java index 318e457c..f7842f43 100644 --- a/hai-service/src/main/java/com/hai/pay/channel/huipay/config/HuiConfig.java +++ b/hai-service/src/main/java/com/hai/pay/channel/huipay/config/HuiConfig.java @@ -8,10 +8,13 @@ import com.hai.common.pay.WechatPayUtil; import com.hai.common.utils.HttpsUtils; import com.hai.config.CommonSysConst; import com.hai.dao.HighPayRecordMapper; +import com.hai.entity.HighGasChannelConfig; import com.hai.entity.HighOrder; import com.hai.entity.HighPayRecord; +import com.hai.enum_type.GasChannel; import com.hai.order.utils.OrderUtil; import com.hai.pay.channel.huipay.utils.SignatureUtil; +import com.hai.service.HighGasChannelConfigService; import com.hai.service.HighOrderService; import com.hai.service.pay.PayRecordService; import org.slf4j.Logger; @@ -29,16 +32,18 @@ import java.util.TreeMap; public class HuiConfig { @Resource - private PayRecordService payRecordService; + private HighGasChannelConfigService gasChannelConfigService; @Resource - private HighOrderService highOrderService; + private PayRecordService payRecordService; private static Logger log = LoggerFactory.getLogger(HuiConfig.class); // 请求地址 public final static String postUrl = "https://pay.dctpay.com/openApi/v1/"; + public final static String hlSubAppid = "wx8d49e2f83025229d"; + // 渝北区浩联物资经营部 public final static String hlMerNo = "2023090816465844909"; public final static String yFMerNo = "2023101109385455305"; @@ -47,8 +52,6 @@ public class HuiConfig { public final static String hlKey = "ZatCMLMSZxnkc2rk7dtpTORMLcKetcKt"; public final static String yFKey = "plfJ6Ohgj4OmPblknuMzoSeT8cvI5dTR"; - public final static String hlSubAppid = "wx8d49e2f83025229d"; - /** * @Author Sum1Dream * @Name preorder @@ -57,6 +60,43 @@ public class HuiConfig { * @Param object * @return java.util.SortedMap */ + public SortedMap preorder(JSONObject object , String key , String payPlatformMerNo) throws Exception { + object.put("merchantNo" , payPlatformMerNo); + object.put("subAppid" , hlSubAppid); + object.put("sign" , SignatureUtil.createSign(object , key)); + + JSONObject jsonObject = HttpsUtils.doPost(postUrl + "trade/preorder", object, new HashMap<>()); + // 签名校验 + SortedMap sortedMap; + if (jsonObject.getString("return_code").equals("000000")) { + + JSONObject payParam = jsonObject.getJSONObject("return_data").getJSONObject("payParam"); + sortedMap = new TreeMap<>(); + sortedMap.put("appId", payParam.get("app_id")); + sortedMap.put("nonceStr", payParam.get("nonce_str")); + sortedMap.put("timeStamp", payParam.get("time_stamp")); + sortedMap.put("signType", "MD5"); + sortedMap.put("package", payParam.get("package")); + sortedMap.put("sign", payParam.get("pay_sign")); + + // 将支付请求存入支付纪录 + HighPayRecord payRecord = new HighPayRecord(); + payRecord.setBodyInfo(String.valueOf(payParam)); + payRecord.setResType(1); + payRecord.setPayType(2); + payRecord.setPayMoney(object.getBigDecimal("totalAmount")); + payRecordService.addPayRecord(payRecord); + + } else { + log.error("微信支付 -> 组装支付参数:支付信息错误"); + log.error("错误信息:" + jsonObject.getString("return_msg")); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法支付,请稍后重新提交订单支付!"); + } + + return sortedMap; + + } + public SortedMap preorder(JSONObject object) throws Exception { object.put("merchantNo" , yFMerNo); object.put("subAppid" , hlSubAppid); @@ -104,12 +144,14 @@ public class HuiConfig { */ public JSONObject refund(HighOrder order) throws Exception { + HighGasChannelConfig gasChannelConfig = gasChannelConfigService.getConfig(order.getAccountMerchantNum()); + JSONObject object = new JSONObject(); - object.put("merchantNo" , hlMerNo); + object.put("merchantNo" , gasChannelConfig.getPayPlatformMerNo()); object.put("outTradeNo" , order.getOrderNo()); object.put("refundTradeNo" , OrderUtil.generateRefundOrderNo()); object.put("refundAmount" , order.getPayRealPrice()); - object.put("sign" , SignatureUtil.createSign(object , hlKey)); + object.put("sign" , SignatureUtil.createSign(object , gasChannelConfig.getPayPlatformMerKey())); return HttpsUtils.doPost(postUrl + "trade/refund", object, new HashMap<>()); diff --git a/hai-service/src/main/java/com/hai/service/HighGasChannelConfigService.java b/hai-service/src/main/java/com/hai/service/HighGasChannelConfigService.java index f44adbc3..82ac4566 100644 --- a/hai-service/src/main/java/com/hai/service/HighGasChannelConfigService.java +++ b/hai-service/src/main/java/com/hai/service/HighGasChannelConfigService.java @@ -23,4 +23,8 @@ public interface HighGasChannelConfigService { */ HighGasChannelConfig getConfig(GasChannel channelId, GasChannelPayPlatformType payPlatformType); + HighGasChannelConfig getConfig(GasChannel channelId); + + HighGasChannelConfig getConfig(String merNo); + } diff --git a/hai-service/src/main/java/com/hai/service/HighMerchantStoreService.java b/hai-service/src/main/java/com/hai/service/HighMerchantStoreService.java index 9723586f..0c78e26e 100644 --- a/hai-service/src/main/java/com/hai/service/HighMerchantStoreService.java +++ b/hai-service/src/main/java/com/hai/service/HighMerchantStoreService.java @@ -2,6 +2,7 @@ package com.hai.service; import com.github.pagehelper.PageInfo; import com.hai.entity.HighMerchantStore; +import com.hai.entity.HighStoreOilCard; import com.hai.model.GasSelfBuiltStationModel; import com.hai.model.HighMerchantStoreModel; @@ -105,4 +106,44 @@ public interface HighMerchantStoreService { * @return */ List getGasSelfBuiltStationList(Map map); + + /** + * @Author Sum1Dream + * @Name insertStoreOilCard + * @Description // 新增门店油卡 + * @Date 14:28 2023/11/2 + * @Param highStoreOilCard + * @return void + */ + void insertStoreOilCard(HighStoreOilCard highStoreOilCard) throws Exception; + + /** + * @Author 胡锐 + * @Description 修改新增门店油卡 + * @Date 2021/3/12 22:15 + **/ + void updateStoreOilCard(HighStoreOilCard highStoreOilCard) throws Exception; + + + /** + * @Author Sum1Dream + * @Name findStoreOilCard + * @Description // 查询门店油卡 + * @Date 14:42 2023/11/2 + * @Param id + * @return com.hai.entity.HighStoreOilCard + */ + HighStoreOilCard findStoreOilCard(Long id); + + /** + * @Author Sum1Dream + * @Name getStoreOilCardList + * @Description //TODO + * @Date 14:32 2023/11/2 + * @Param map + * @return java.util.List + */ + List getStoreOilCardList(Long storeId); + + } diff --git a/hai-service/src/main/java/com/hai/service/HighOilCardOrderService.java b/hai-service/src/main/java/com/hai/service/HighOilCardOrderService.java new file mode 100644 index 00000000..ade6c60f --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/HighOilCardOrderService.java @@ -0,0 +1,13 @@ +package com.hai.service; + +import com.hai.entity.HighOilCardOrder; + +public interface HighOilCardOrderService { + + void insertOilCardOrder(HighOilCardOrder highOilCardOrder); + + void updateOilCardOrder(HighOilCardOrder highOilCardOrder); + + HighOilCardOrder findOrder(String orderNo); + +} diff --git a/hai-service/src/main/java/com/hai/service/HighUserService.java b/hai-service/src/main/java/com/hai/service/HighUserService.java index d9985380..42901a8c 100644 --- a/hai-service/src/main/java/com/hai/service/HighUserService.java +++ b/hai-service/src/main/java/com/hai/service/HighUserService.java @@ -3,6 +3,7 @@ package com.hai.service; import com.alibaba.fastjson.JSONObject; import com.hai.common.security.SessionObject; import com.hai.entity.HighUser; +import com.hai.entity.HighUserLevel; import com.hai.enum_type.LoginPlatform; import com.hai.model.HighUserModel; @@ -161,5 +162,12 @@ public interface HighUserService { */ JSONObject userDistributionStatistics(Long userId); + void insertLevelUp(HighUserLevel highUserLevel); + + void editLevelUp(HighUserLevel highUserLevel); + + HighUserLevel findUserLevel(Long userId); + + } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighGasChannelConfigServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighGasChannelConfigServiceImpl.java index 873819da..b1cd93af 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighGasChannelConfigServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighGasChannelConfigServiceImpl.java @@ -45,4 +45,30 @@ public class HighGasChannelConfigServiceImpl implements HighGasChannelConfigServ } return null; } + + @Override + public HighGasChannelConfig getConfig(GasChannel channelId) { + HighGasChannelConfigExample example = new HighGasChannelConfigExample(); + example.createCriteria() + .andChannelIdEqualTo(channelId.getType()) + .andStatusEqualTo(1); + List list = gasChannelConfigMapper.selectByExample(example); + if (list.size() > 0) { + return list.get(0); + } + return null; + } + + @Override + public HighGasChannelConfig getConfig(String merNo) { + HighGasChannelConfigExample example = new HighGasChannelConfigExample(); + example.createCriteria() + .andPayPlatformMerNoEqualTo(merNo) + .andStatusEqualTo(1); + List list = gasChannelConfigMapper.selectByExample(example); + if (list.size() > 0) { + return list.get(0); + } + return null; + } } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighGasDiscountOilPriceServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighGasDiscountOilPriceServiceImpl.java index 13a250af..ce87e530 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighGasDiscountOilPriceServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighGasDiscountOilPriceServiceImpl.java @@ -156,6 +156,7 @@ public class HighGasDiscountOilPriceServiceImpl implements HighGasDiscountOilPri || store.getSourceType().equals(MerchantStoreSourceType.type4.getNumber()) || store.getSourceType().equals(MerchantStoreSourceType.type5.getNumber()) || store.getSourceType().equals(MerchantStoreSourceType.type6.getNumber()) + || store.getSourceType().equals(MerchantStoreSourceType.type7.getNumber()) ) { // 嗨森逛平台价 油枪价 * 折扣 diff --git a/hai-service/src/main/java/com/hai/service/impl/HighGasServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighGasServiceImpl.java index 3875ca5b..4fee89d0 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighGasServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighGasServiceImpl.java @@ -503,6 +503,7 @@ public class HighGasServiceImpl implements HighGasService { highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getString("youhao")); + highGasOilPrice.setPreferentialMargin(new BigDecimal(0)); highGasOilPrice.setOilNoName(oilPriceObject.getString("youhao") + "#"); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); @@ -515,6 +516,7 @@ public class HighGasServiceImpl implements HighGasService { highGasOilPrice.setOilNo(oilPriceObject.getString("youhao")); highGasOilPrice.setOilNoName( oilPriceObject.getString("youhao") + "#"); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); + highGasOilPrice.setPreferentialMargin(new BigDecimal(0)); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oiltype")); @@ -555,6 +557,7 @@ public class HighGasServiceImpl implements HighGasService { highGasOilPrice.setOilNo(oilPriceObject.getString("youhao")); highGasOilPrice.setOilNoName(oilPriceObject.getString("youhao") + "#"); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); + highGasOilPrice.setPreferentialMargin(new BigDecimal(0)); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oiltype")); diff --git a/hai-service/src/main/java/com/hai/service/impl/HighMerchantStoreServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighMerchantStoreServiceImpl.java index 361087de..8f48501c 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighMerchantStoreServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighMerchantStoreServiceImpl.java @@ -10,6 +10,7 @@ import com.hai.common.utils.CoordCommonUtil; import com.hai.common.utils.MD5Util; import com.hai.config.SpPrinterConfig; import com.hai.dao.HighMerchantStoreMapper; +import com.hai.dao.HighStoreOilCardMapper; import com.hai.entity.*; import com.hai.model.GasSelfBuiltStationModel; import com.hai.model.HighMerchantStoreModel; @@ -44,6 +45,9 @@ public class HighMerchantStoreServiceImpl implements HighMerchantStoreService { @Resource private HighMerchantStoreAccountService merchantStoreAccountService; + @Resource + private HighStoreOilCardMapper highStoreOilCardMapper; + @Override @Transactional(propagation= Propagation.REQUIRES_NEW) public void insertMerchantStore(HighMerchantStoreModel highMerchantStore) throws Exception { @@ -255,5 +259,29 @@ public class HighMerchantStoreServiceImpl implements HighMerchantStoreService { return highMerchantStoreMapper.selectGasSelfBuiltStationList(map); } + @Override + public void insertStoreOilCard(HighStoreOilCard highStoreOilCard) throws Exception { + highStoreOilCardMapper.insert(highStoreOilCard); + } + + @Override + public void updateStoreOilCard(HighStoreOilCard highStoreOilCard) throws Exception { + highStoreOilCardMapper.updateByPrimaryKey(highStoreOilCard); + } + + @Override + public HighStoreOilCard findStoreOilCard(Long id) { + return highStoreOilCardMapper.selectByPrimaryKey(id); + } + + @Override + public List getStoreOilCardList(Long storeId) { + HighStoreOilCardExample example = new HighStoreOilCardExample(); + HighStoreOilCardExample.Criteria criteria = example.createCriteria(); + + criteria.andStoreIdEqualTo(storeId).andStatusEqualTo(1); + + return highStoreOilCardMapper.selectByExample(example); + } } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighOilCardOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighOilCardOrderServiceImpl.java new file mode 100644 index 00000000..c2c6537f --- /dev/null +++ b/hai-service/src/main/java/com/hai/service/impl/HighOilCardOrderServiceImpl.java @@ -0,0 +1,43 @@ +package com.hai.service.impl; + +import com.hai.dao.HighOilCardOrderMapper; +import com.hai.entity.HighOilCardOrder; +import com.hai.entity.HighOilCardOrderExample; +import com.hai.service.HighOilCardOrderService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; + +@Service("highOilCardOrderService") +public class HighOilCardOrderServiceImpl implements HighOilCardOrderService { + + @Resource + private HighOilCardOrderMapper highOilCardOrderMapper; + + @Override + public void insertOilCardOrder(HighOilCardOrder highOilCardOrder) { + highOilCardOrderMapper.insert(highOilCardOrder); + } + + @Override + public void updateOilCardOrder(HighOilCardOrder highOilCardOrder) { + highOilCardOrderMapper.updateByPrimaryKey(highOilCardOrder); + } + + @Override + public HighOilCardOrder findOrder(String orderNo) { + HighOilCardOrderExample example = new HighOilCardOrderExample(); + HighOilCardOrderExample.Criteria criteria = example.createCriteria(); + + criteria.andOrderNoEqualTo(orderNo); + + List list = highOilCardOrderMapper.selectByExample(example); + + if (list.size() > 0) { + return list.get(0); + } + + return null; + } +} diff --git a/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java index 856d5729..9f150669 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java @@ -12,6 +12,7 @@ import com.hai.common.utils.DateUtil; import com.hai.common.utils.HttpsUtils; import com.hai.common.utils.RequestUtils; import com.hai.dao.HighGoldRecMapper; +import com.hai.dao.HighUserLevelMapper; import com.hai.dao.HighUserLoginLogMapper; import com.hai.dao.HighUserMapper; import com.hai.entity.*; @@ -50,7 +51,7 @@ public class HighUserServiceImpl implements HighUserService { private HighUserCouponService highUserCouponService; @Resource - private OutRechargeOrderService outRechargeOrderService; + private HighUserLevelMapper highUserLevelMapper; @Resource private HighUserCardService highUserCardService; @@ -420,6 +421,32 @@ public class HighUserServiceImpl implements HighUserService { JSONObject object = new JSONObject(); + return null; + } + + @Override + public void insertLevelUp(HighUserLevel highUserLevel) { + highUserLevelMapper.insert(highUserLevel); + } + + @Override + public void editLevelUp(HighUserLevel highUserLevel) { + highUserLevelMapper.updateByPrimaryKeySelective(highUserLevel); + } + + @Override + public HighUserLevel findUserLevel(Long userId) { + HighUserLevelExample example = new HighUserLevelExample(); + HighUserLevelExample.Criteria criteria = example.createCriteria(); + + criteria.andUserIdEqualTo(userId).andStatusEqualTo(1); + + List list = highUserLevelMapper.selectByExample(example); + + if (list.size() > 0) { + return list.get(0); + } + return null; } } diff --git a/hai-user/src/main/java/com/web/controller/LoginController.java b/hai-user/src/main/java/com/web/controller/LoginController.java index 745ae2c0..9ffb1595 100644 --- a/hai-user/src/main/java/com/web/controller/LoginController.java +++ b/hai-user/src/main/java/com/web/controller/LoginController.java @@ -1 +1 @@ -package com.web.controller; import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; import com.alibaba.fastjson.JSONObject; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.security.UserCenter; import com.hai.common.utils.*; import com.hai.config.UnionUserConfig; import com.hai.config.WxMaConfiguration; import com.hai.entity.HighUser; import com.hai.enum_type.LoginPlatform; import com.hai.model.HighUserModel; import com.hai.model.ResponseData; import com.hai.service.HighUserService; import com.web.type.LoginType; import com.hai.enum_type.RedisFileFolder; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/login") @Api(value = "登录业务") public class LoginController { private static Logger log = LoggerFactory.getLogger(LoginController.class); @Resource private RedisUtil redisUtil; @Resource private HighUserService userService; @Resource private UserCenter userCenter; @Resource private WxMaConfiguration wxMaConfiguration; @Resource private UnionUserConfig unionUserConfig; @RequestMapping(value = "/phone", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "手机号登录") public ResponseData phone(@RequestBody JSONObject body, HttpServletRequest request, HttpServletResponse response) { try { if (body == null || StringUtils.isBlank(body.getString("platform")) || StringUtils.isBlank(body.getString("type")) || StringUtils.isBlank(body.getString("phone")) ) { log.error("LoginController --> phone() error!", "请求参数校验失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } String phone = body.getString("phone"); // 客户端 LoginPlatform platform = LoginPlatform.getDataByType(body.getString("platform")); if (platform == null) { log.error("LoginController --> phone() error!", "未知客户端"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知客户端"); } // 校验手机号格式 if (MemberValidateUtil.validatePhone(phone) == false) { log.error("LoginController --> phone() error!", "请输入正确的手机号"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入正确的手机号"); } // 登录类型 LoginType loginType = LoginType.getDataByType(body.getString("type")); if (loginType == null) { log.error("LoginController --> phone() error!", "未知登录类型;" + body.getString("type")); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知登录类型"); } if (body.getString("type").equals(LoginType.SMS.getCode())) { if (StringUtils.isBlank(body.getString("smsCode"))) { log.error("LoginController --> phone() error!", "请输入短信验证码"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入短信验证码"); } // 手机号的验证码 Object phoneCodeObject = redisUtil.get(RedisFileFolder.SMS_CODE.getCode() + phone); if (phoneCodeObject == null) { log.error("LoginController --> phone() error!", "短信验证码错误"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "短信验证码错误"); } if (!body.getString("smsCode").equals(phoneCodeObject.toString())) { log.error("LoginController --> phone() error!", "短信验证码错误"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "短信验证码错误"); } redisUtil.del(RedisFileFolder.SMS_CODE.getCode() + phone); Map other = new HashMap<>(); other.put("openIdH5", body.getString("openIdH5")); return ResponseMsgUtil.success(userService.loginAndRegister(platform, phone, body.getLong("popularizeUserId"), other, request, response)); } throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "登录失败"); } catch (Exception e) { log.error("LoginController --> phone() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/openId", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "openId登录") public ResponseData openId(@RequestBody JSONObject body,HttpServletRequest request, HttpServletResponse response) { try { if (body == null || StringUtils.isBlank(body.getString("platform")) || StringUtils.isBlank(body.getString("type")) || StringUtils.isBlank(body.getString("openId")) ) { log.error("LoginController --> phone() error!", "请求参数校验失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } // 客户端 LoginPlatform platform = LoginPlatform.getDataByType(body.getString("platform")); if (platform == null) { log.error("LoginController --> phone() error!", "未知客户端"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知客户端"); } // 登录类型 LoginType loginType = LoginType.getDataByType(body.getString("type")); if (loginType == null) { log.error("LoginController --> phone() error!", "未知登录类型;" + body.getString("type")); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知登录类型"); } if (body.getString("type").equals(LoginType.WECHAT_MP_OPENID.getCode())) { Map param = new HashMap<>(); param.put("openId", body.getString("openId")); List userList = userService.getUserList(param); if (userList.size() > 0) { HighUser user = userList.get(0); if (StringUtils.isNotBlank(user.getPhone())){ return ResponseMsgUtil.success(userService.loginAndRegister(platform, user.getPhone(), body.getLong("popularizeUserId"), new HashMap<>(), request, response)); } } return ResponseMsgUtil.success(null); } else if (body.getString("type").equals(LoginType.WECHAT_MA_OPENID.getCode())) { Map param = new HashMap<>(); param.put("openIdH5", body.getString("openId")); List userList = userService.getUserList(param); if (userList.size() > 0) { HighUser user = userList.get(0); if (StringUtils.isNotBlank(user.getPhone())) { return ResponseMsgUtil.success(userService.loginAndRegister(platform, user.getPhone(), body.getLong("popularizeUserId"), new HashMap<>(), request, response)); } } return ResponseMsgUtil.success(null); } throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "登录失败"); } catch (Exception e) { log.error("LoginController --> phone() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/wxMiniHandleCode", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "微信小程序code解析") public ResponseData wxMiniHandleCode(@RequestBody JSONObject body) { try { if (body == null|| StringUtils.isBlank(body.getString("code"))) { log.error("LoginController --> phone() error!", "请求参数校验失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } WxMaJscode2SessionResult session; if (body.getInteger("type") != null) { //请求微信api,获取用户session_key以及openId session = WxMaConfiguration.getMaService(body.getInteger("type")).jsCode2SessionInfo(body.getString("code")); } else { //请求微信api,获取用户session_key以及openId session = WxMaConfiguration.getMaService().jsCode2SessionInfo(body.getString("code")); } //保存小程序用户登录的openId及sessionKey信息 redisUtil.hset("WX_OPENID_SESSION_REDIS", session.getOpenid(), session); JSONObject jo = new JSONObject(); jo.put("openId", session.getOpenid()); return ResponseMsgUtil.success(jo); } catch (Exception e) { return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/wxMini", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "微信小程序") public ResponseData wxMini(@RequestBody JSONObject body,HttpServletRequest request, HttpServletResponse response) { try { if (body == null || StringUtils.isBlank(body.getString("encryptedData")) || StringUtils.isBlank(body.getString("iv")) || StringUtils.isBlank(body.getString("openId"))) { log.error("LoginController --> phone() error!", "请求参数校验失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } String encryptedData = body.getString("encryptedData").replace(" ", "+"); String iv = body.getString("iv").replace(" ", "+"); //请求微信api,获取用户session_key以及openId Object skObject = redisUtil.hget("WX_OPENID_SESSION_REDIS", body.getString("openId")); if (skObject == null) { throw ErrorHelp.genException(SysCode.MiniProgram, ErrorCode.WECHAT_LOGIN_ERROR); } WxMaJscode2SessionResult session = (WxMaJscode2SessionResult) skObject; WxMaPhoneNumberInfo phoneNoInfo; if (body.getInteger("type") != null) { phoneNoInfo = WxMaConfiguration .getMaService(body.getInteger("type")) .getUserService() .getPhoneNoInfo(session.getSessionKey(), encryptedData, iv); } else { phoneNoInfo = WxMaConfiguration .getMaService() .getUserService() .getPhoneNoInfo(session.getSessionKey(), encryptedData, iv); } if (phoneNoInfo == null || StringUtils.isEmpty(phoneNoInfo.getPurePhoneNumber())) { log.error("LoginController --> wxMini() error!", "登录失败! 用户手机号解析失败"); throw ErrorHelp.genException(SysCode.MiniProgram, ErrorCode.WECHAT_DECRYPT_ERROR, "登录失败! 用户手机号解析失败"); } Map other = new HashMap<>(); other.put("openId", session.getOpenid()); return ResponseMsgUtil.success(userService.loginAndRegister(LoginPlatform.WXAPPLETS, phoneNoInfo.getPurePhoneNumber(), body.getLong("popularizeUserId"), other, request, response)); } catch (Exception e) { log.error("LoginController --> wxMini() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/union", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "银联授权手机号登录接口") public ResponseData union(@RequestBody JSONObject body,HttpServletRequest request, HttpServletResponse response) { try { if (body == null || StringUtils.isBlank(body.getString("code"))) { log.error("LoginController --> phone() error!", "请求参数校验失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } // 获取应用访问令牌 String backendToken = unionUserConfig.getBackendToken(); // 获取授权访问令牌 JSONObject token = unionUserConfig.getAccessToken(backendToken, body.getString("code")); if (token == null || !token.getString("resp").equals("00")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, token.getString("msg")); } // 获取用户手机号 JSONObject userMobile = unionUserConfig.getUserMobile(backendToken, token.getJSONObject("params").getString("accessToken"), token.getJSONObject("params").getString("openId")); if (userMobile == null || !userMobile.getString("resp").equals("00")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, userMobile.getString("msg")); } // 解密,获取手机号 String mobile = UnionUtils.getDecryptedValue(userMobile.getJSONObject("params").getString("mobile"), unionUserConfig.getRsaKey()); Map other = new HashMap<>(); other.put("unionId", token.getJSONObject("params").getString("openId")); other.put("unionUnionId", token.getJSONObject("params").getString("unionId")); return ResponseMsgUtil.success(userService.loginAndRegister(LoginPlatform.UNIONPAY, mobile, body.getLong("popularizeUserId"), other, request, response)); } catch (Exception e) { return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/out", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "退出登录") public ResponseData out(HttpServletRequest request, HttpServletResponse response) { try { HighUserModel userInfoModel = userCenter.getSessionModel(HighUserModel.class); if (userInfoModel == null) { log.error("CoresController --> outLogin() error!", "用户身份错误或已过期"); throw ErrorHelp.genException(SysCode.System, ErrorCode.SEC_USER_EXPIRED, ""); } userCenter.remove(request, response); return ResponseMsgUtil.success("退出登录成功"); } catch (Exception e) { log.error("CoresController --> outLogin() error!", e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file +package com.web.controller; import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult; import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo; import com.alibaba.fastjson.JSONObject; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.security.UserCenter; import com.hai.common.utils.*; import com.hai.config.UnionUserConfig; import com.hai.config.WxMaConfiguration; import com.hai.entity.HighUser; import com.hai.enum_type.LoginPlatform; import com.hai.model.HighUserModel; import com.hai.model.ResponseData; import com.hai.service.HighUserService; import com.web.type.LoginType; import com.hai.enum_type.RedisFileFolder; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @Auther: 胡锐 * @Description: * @Date: 2021/3/26 23:08 */ @Controller @RequestMapping(value = "/login") @Api(value = "登录业务") public class LoginController { private static Logger log = LoggerFactory.getLogger(LoginController.class); @Resource private RedisUtil redisUtil; @Resource private HighUserService userService; @Resource private UserCenter userCenter; @Resource private WxMaConfiguration wxMaConfiguration; @Resource private UnionUserConfig unionUserConfig; @RequestMapping(value = "/phone", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "手机号登录") public ResponseData phone(@RequestBody JSONObject body, HttpServletRequest request, HttpServletResponse response) { try { if (body == null || StringUtils.isBlank(body.getString("platform")) || StringUtils.isBlank(body.getString("type")) || StringUtils.isBlank(body.getString("phone")) ) { log.error("LoginController --> phone() error!", "请求参数校验失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } String phone = body.getString("phone"); // 客户端 LoginPlatform platform = LoginPlatform.getDataByType(body.getString("platform")); if (platform == null) { log.error("LoginController --> phone() error!", "未知客户端"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知客户端"); } // 校验手机号格式 if (MemberValidateUtil.validatePhone(phone) == false) { log.error("LoginController --> phone() error!", "请输入正确的手机号"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入正确的手机号"); } // 登录类型 LoginType loginType = LoginType.getDataByType(body.getString("type")); if (loginType == null) { log.error("LoginController --> phone() error!", "未知登录类型;" + body.getString("type")); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知登录类型"); } if (body.getString("type").equals(LoginType.SMS.getCode())) { if (StringUtils.isBlank(body.getString("smsCode"))) { log.error("LoginController --> phone() error!", "请输入短信验证码"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入短信验证码"); } // 手机号的验证码 Object phoneCodeObject = redisUtil.get(RedisFileFolder.SMS_CODE.getCode() + phone); if (phoneCodeObject == null) { log.error("LoginController --> phone() error!", "短信验证码错误"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "短信验证码错误"); } if (!body.getString("smsCode").equals(phoneCodeObject.toString())) { log.error("LoginController --> phone() error!", "短信验证码错误"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "短信验证码错误"); } redisUtil.del(RedisFileFolder.SMS_CODE.getCode() + phone); Map other = new HashMap<>(); other.put("openIdH5", body.getString("openIdH5")); return ResponseMsgUtil.success(userService.loginAndRegister(platform, phone, body.getLong("popularizeUserId"), other, request, response)); } throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "登录失败"); } catch (Exception e) { log.error("LoginController --> phone() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/openId", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "openId登录") public ResponseData openId(@RequestBody JSONObject body,HttpServletRequest request, HttpServletResponse response) { try { if (body == null || StringUtils.isBlank(body.getString("platform")) || StringUtils.isBlank(body.getString("type")) || StringUtils.isBlank(body.getString("openId")) ) { log.error("LoginController --> phone() error!", "请求参数校验失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } // 客户端 LoginPlatform platform = LoginPlatform.getDataByType(body.getString("platform")); if (platform == null) { log.error("LoginController --> phone() error!", "未知客户端"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知客户端"); } // 登录类型 LoginType loginType = LoginType.getDataByType(body.getString("type")); if (loginType == null) { log.error("LoginController --> phone() error!", "未知登录类型;" + body.getString("type")); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知登录类型"); } if (body.getString("type").equals(LoginType.WECHAT_MP_OPENID.getCode())) { Map param = new HashMap<>(); param.put("openId", body.getString("openId")); List userList = userService.getUserList(param); if (userList.size() > 0) { HighUser user = userList.get(0); if (StringUtils.isNotBlank(user.getPhone())){ return ResponseMsgUtil.success(userService.loginAndRegister(platform, user.getPhone(), body.getLong("popularizeUserId"), new HashMap<>(), request, response)); } } return ResponseMsgUtil.success(null); } else if (body.getString("type").equals(LoginType.WECHAT_MA_OPENID.getCode())) { Map param = new HashMap<>(); param.put("openIdH5", body.getString("openId")); List userList = userService.getUserList(param); if (userList.size() > 0) { HighUser user = userList.get(0); if (StringUtils.isNotBlank(user.getPhone())) { return ResponseMsgUtil.success(userService.loginAndRegister(platform, user.getPhone(), body.getLong("popularizeUserId"), new HashMap<>(), request, response)); } } return ResponseMsgUtil.success(null); } throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "登录失败"); } catch (Exception e) { log.error("LoginController --> phone() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/wxMiniHandleCode", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "微信小程序code解析") public ResponseData wxMiniHandleCode(@RequestBody JSONObject body) { try { if (body == null|| StringUtils.isBlank(body.getString("code"))) { log.error("LoginController --> phone() error!", "请求参数校验失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } WxMaJscode2SessionResult session; if (body.getInteger("type") != null) { //请求微信api,获取用户session_key以及openId session = WxMaConfiguration.getMaService(body.getInteger("type")).jsCode2SessionInfo(body.getString("code")); } else { //请求微信api,获取用户session_key以及openId session = WxMaConfiguration.getMaService().jsCode2SessionInfo(body.getString("code")); } //保存小程序用户登录的openId及sessionKey信息 redisUtil.hset("WX_OPENID_SESSION_REDIS", session.getOpenid(), session); JSONObject jo = new JSONObject(); jo.put("openId", session.getOpenid()); return ResponseMsgUtil.success(jo); } catch (Exception e) { return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/wxMini", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "微信小程序") public ResponseData wxMini(@RequestBody JSONObject body,HttpServletRequest request, HttpServletResponse response) { try { if (body == null || StringUtils.isBlank(body.getString("encryptedData")) || StringUtils.isBlank(body.getString("iv")) || StringUtils.isBlank(body.getString("openId"))) { log.error("LoginController --> phone() error!", "请求参数校验失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } String encryptedData = body.getString("encryptedData").replace(" ", "+"); String iv = body.getString("iv").replace(" ", "+"); //请求微信api,获取用户session_key以及openId Object skObject = redisUtil.hget("WX_OPENID_SESSION_REDIS", body.getString("openId")); if (skObject == null) { throw ErrorHelp.genException(SysCode.MiniProgram, ErrorCode.WECHAT_LOGIN_ERROR); } WxMaJscode2SessionResult session = (WxMaJscode2SessionResult) skObject; WxMaPhoneNumberInfo phoneNoInfo; if (body.getInteger("type") != null) { phoneNoInfo = WxMaConfiguration .getMaService(body.getInteger("type")) .getUserService() .getPhoneNoInfo(session.getSessionKey(), encryptedData, iv); } else { phoneNoInfo = WxMaConfiguration .getMaService() .getUserService() .getPhoneNoInfo(session.getSessionKey(), encryptedData, iv); } if (phoneNoInfo == null || StringUtils.isEmpty(phoneNoInfo.getPurePhoneNumber())) { log.error("LoginController --> wxMini() error!", "登录失败! 用户手机号解析失败"); throw ErrorHelp.genException(SysCode.MiniProgram, ErrorCode.WECHAT_DECRYPT_ERROR, "登录失败! 用户手机号解析失败"); } Map other = new HashMap<>(); other.put("openId", session.getOpenid()); return ResponseMsgUtil.success(userService.loginAndRegister(LoginPlatform.WXAPPLETS, phoneNoInfo.getPurePhoneNumber(), body.getLong("popularizeUserId"), other, request, response)); } catch (Exception e) { log.error("LoginController --> wxMini() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/union", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "银联授权手机号登录接口") public ResponseData union(@RequestBody JSONObject body,HttpServletRequest request, HttpServletResponse response) { try { if (body == null || StringUtils.isBlank(body.getString("code"))) { log.error("LoginController --> phone() error!", "请求参数校验失败"); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); } // 获取应用访问令牌 String backendToken = unionUserConfig.getBackendToken(); // 获取授权访问令牌 JSONObject token = unionUserConfig.getAccessToken(backendToken, body.getString("code")); if (token == null || !token.getString("resp").equals("00")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, token.getString("msg")); } // 获取用户手机号 JSONObject userMobile = unionUserConfig.getUserMobile(backendToken, token.getJSONObject("params").getString("accessToken"), token.getJSONObject("params").getString("openId")); if (userMobile == null || !userMobile.getString("resp").equals("00")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, userMobile.getString("msg")); } // 解密,获取手机号 String mobile = UnionUtils.getDecryptedValue(userMobile.getJSONObject("params").getString("mobile"), unionUserConfig.getRsaKey()); Map other = new HashMap<>(); other.put("unionId", token.getJSONObject("params").getString("openId")); other.put("unionUnionId", token.getJSONObject("params").getString("unionId")); return ResponseMsgUtil.success(userService.loginAndRegister(LoginPlatform.UNIONPAY, mobile, body.getLong("popularizeUserId"), other, request, response)); } catch (Exception e) { return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/out", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "退出登录") public ResponseData out(HttpServletRequest request, HttpServletResponse response) { try { HighUserModel userInfoModel = userCenter.getSessionModel(HighUserModel.class); if (userInfoModel == null) { log.error("CoresController --> outLogin() error!", "用户身份错误或已过期"); throw ErrorHelp.genException(SysCode.System, ErrorCode.SEC_USER_EXPIRED, ""); } userCenter.remove(request, response); return ResponseMsgUtil.success("退出登录成功"); } catch (Exception e) { log.error("CoresController --> outLogin() error!", e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file