From 1adc37c728dec34073205cbe1584f3f5ad9d9287 Mon Sep 17 00:00:00 2001 From: Sum1Dream <418471657@qq.com> Date: Tue, 28 Feb 2023 15:35:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AF=9D=E8=B4=B9=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=E4=BB=BB=E5=8A=A1=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ApiMchProductController.java | 3 - .../bweb/controller/HighTestController.java | 2 +- .../com/cweb/controller/CommonController.java | 14 +++++ .../OutRechargePriceController.java | 42 ++++++++------ .../OrderMobileRechargeController.java | 2 +- .../openApi/model/ApiGasOliPriceModel.java | 6 +- .../hai/openApi/model/ApiMchStoreModel.java | 11 ---- .../openApi/service/ApiMchProductService.java | 20 +++++++ .../impl/ApiMchProductServiceImpl.java | 39 +++++++++++++ .../java/com/hai/service/CommonService.java | 12 ++++ .../hai/service/impl/CommonServiceImpl.java | 14 +++++ .../impl/OutRechargeOrderServiceImpl.java | 6 +- .../java/com/v1/config/ApiCommonConfig.java | 55 +++++++++++++++++++ .../main/java/com/v1/config/AuthConfig.java | 1 + .../v1/controller/RefuelOnlineController.java | 50 +++++++++++++---- v1/src/main/resources/dev/application.yml | 2 +- 16 files changed, 229 insertions(+), 50 deletions(-) create mode 100644 v1/src/main/java/com/v1/config/ApiCommonConfig.java diff --git a/hai-bweb/src/main/java/com/bweb/controller/ApiMchProduct/ApiMchProductController.java b/hai-bweb/src/main/java/com/bweb/controller/ApiMchProduct/ApiMchProductController.java index d64e80f8..d84d87d0 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/ApiMchProduct/ApiMchProductController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/ApiMchProduct/ApiMchProductController.java @@ -75,9 +75,6 @@ public class ApiMchProductController { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "商户状态错误"); } - apiMchProductService.detailConfigMchProduct(object.getString("mchId")); - secConfigService.deleteSecConfig(object.getString("mchId")); - if (object.getJSONArray("productType") != null && object.getJSONArray("productType").size() > 0) { apiMchProductService.configMchProduct(object); } 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 0eda7eeb..b181f661 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.alipay.api.domain.ForbbidenTime; import com.alipay.api.domain.OfferObject; 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.*; import com.hai.config.*; import com.hai.entity.*; import com.hai.model.OrderRefundModel; import com.hai.model.ResponseData; import com.hai.order.service.OrderRefundService; import com.hai.order.service.OrderService; import com.hai.order.type.OrderPayType; import com.hai.order.type.OrderRefundOpUserType; 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.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 java.math.BigDecimal; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * @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 OutRechargeOrderService outRechargeOrderService; @Resource private OrderService orderService; @Resource private HighOrderService highOrderService; @Resource private OrderRefundService orderRefundService; @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 = "/insertV2", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "支付") public ResponseData insertV2() { try { Map map = new HashMap<>(); map.put("timetable" , new Date().getTime()); map.put("apiKey" , "9A838BEBC60712775E119366DB804C43"); map.put("orderNo" , "20220329182036435619"); map.put("count" , "1"); map.put("couTypeCode" , "test"); map.put("phone" , "15206071196"); map.put("merchId" , "20220670800"); map.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("https://hsgcs.dctpay.com/v1/gzSinopec/couJointDist" , map)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/phoneBillOrderError", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "话费订单错误") public ResponseData phoneBillOrderError() { List highOrders = orderService.phoneErrorOrder(); for (HighOrder order: highOrders) { try { outRechargeOrderService.rechargeOrderHandle(order.getOrderNo()); } catch (Exception e) { log.error("HighCouponSchedule --> expiredCoupon() error!", e); } } return ResponseMsgUtil.success("操作成功"); } @RequestMapping(value = "/checkOrderByOrderNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据订单号话费查询是否可以退款") public ResponseData checkOrderByOrderNo(@RequestParam(name = "orderNo", required = true) String orderNo) { try { OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(orderNo); OutRechargeChildOrder childOrder = new OutRechargeChildOrder(); if (outRechargeOrder.getOutRechargeChildOrders().size() > 0) { childOrder = outRechargeOrder.getOutRechargeChildOrders().get(0); } outRechargeOrderService.rechargeOrderHandle(orderNo); return ResponseMsgUtil.success("退款成功"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/orderRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "订单退款") public ResponseData orderRefund(@RequestParam(name = "orderNo", required = true) String orderNo) { try { Calendar createTimeS = Calendar.getInstance(); createTimeS.set(Calendar.DATE, 17); createTimeS.set(Calendar.HOUR_OF_DAY , 00); createTimeS.set(Calendar.MINUTE , 00); createTimeS.set(Calendar.SECOND , 00); Calendar createTimeE = Calendar.getInstance(); createTimeE.set(Calendar.DATE, 20); createTimeE.set(Calendar.HOUR_OF_DAY , 15); createTimeE.set(Calendar.MINUTE , 25); createTimeE.set(Calendar.SECOND , 00); Map param = new HashMap<>(); // param.put("createTimeS", createTimeS.getTimeInMillis()); // param.put("createTimeE", createTimeE.getTimeInMillis()); param.put("orderNo", orderNo); List orderRefundList = orderRefundService.getRefundOrderList(param); for (HighOrderRefund orderRefund : orderRefundList) { try { orderRefundService.refundPrice( orderRefund.getRefundOrderNo(), orderService.getOrderDetailByNo(orderRefund.getOrderNo()), OrderPayType.getDataByType(orderRefund.getPayType()), orderRefund.getRefundPrice(), orderRefund.getRefundIntegral() ); orderRefund.setExt1("true"); } catch (Exception e) { orderRefund.setExt1("false"); } finally { orderRefundService.update(orderRefund); } } return ResponseMsgUtil.success("退款成功"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } public String orderTitle(OutRechargeOrder outRechargeOrder) { // 1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 // 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款 switch (outRechargeOrder.getOperatorType()) { case 1: return outRechargeOrder.getRechargeContent() + "电信话费充值" + outRechargeOrder.getRechargePrice() + "元"; case 2: return outRechargeOrder.getRechargeContent() + "移动话费充值" + outRechargeOrder.getRechargePrice() + "元"; case 3: return outRechargeOrder.getRechargeContent() + "联通话费充值" + outRechargeOrder.getRechargePrice() + "元"; default: return null; } } } \ No newline at end of file + package com.bweb.controller; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.alipay.api.domain.ForbbidenTime; import com.alipay.api.domain.OfferObject; 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.*; import com.hai.config.*; import com.hai.entity.*; import com.hai.model.OrderRefundModel; import com.hai.model.ResponseData; import com.hai.order.service.OrderRefundService; import com.hai.order.service.OrderService; import com.hai.order.type.OrderPayType; import com.hai.order.type.OrderRefundOpUserType; 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.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 java.math.BigDecimal; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * @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 OutRechargeOrderService outRechargeOrderService; @Resource private OrderService orderService; @Resource private HighOrderService highOrderService; @Resource private OrderRefundService orderRefundService; @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 = "/getStationStores", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取油站") public ResponseData getStationStores() { try { Map mapPost = new HashMap<>(); mapPost.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); mapPost.put("merchId" , "20230258302"); Map map = new HashMap<>(); map.put("apiKey" , "0C7897EA3BD96156A5881618FF2FF645"); map.put("merchId" , "20230258302"); mapPost.put("sign" , WxUtils.generateSignApi(map, MapUtils.getString(map, "apiKey"), WXPayConstants.SignType.MD5)); return ResponseMsgUtil.success(HttpsUtils.doPost("http://localhost:9902/v1/refuelOnline/getStationStores" , mapPost , new HashMap<>())); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/phoneBillOrderError", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "话费订单错误") public ResponseData phoneBillOrderError() { List highOrders = orderService.phoneErrorOrder(); for (HighOrder order: highOrders) { try { outRechargeOrderService.rechargeOrderHandle(order.getOrderNo()); } catch (Exception e) { log.error("HighCouponSchedule --> expiredCoupon() error!", e); } } return ResponseMsgUtil.success("操作成功"); } @RequestMapping(value = "/checkOrderByOrderNo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据订单号话费查询是否可以退款") public ResponseData checkOrderByOrderNo(@RequestParam(name = "orderNo", required = true) String orderNo) { try { // 定义话费充值业务订单模型 or 充值记录订单模型 OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(orderNo); OutRechargeChildOrder childOrder = outRechargeOrder.getOutRechargeChildOrders().get(0); // -1 取消,0充值中 ,1充值成功,2充值失败,3部分成功 Integer status = outRechargeOrderService.getRechargeOrderLegality(outRechargeOrder , childOrder); return ResponseMsgUtil.success(status); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/orderRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "订单退款") public ResponseData orderRefund(@RequestParam(name = "orderNo", required = true) String orderNo) { try { Calendar createTimeS = Calendar.getInstance(); createTimeS.set(Calendar.DATE, 17); createTimeS.set(Calendar.HOUR_OF_DAY , 00); createTimeS.set(Calendar.MINUTE , 00); createTimeS.set(Calendar.SECOND , 00); Calendar createTimeE = Calendar.getInstance(); createTimeE.set(Calendar.DATE, 20); createTimeE.set(Calendar.HOUR_OF_DAY , 15); createTimeE.set(Calendar.MINUTE , 25); createTimeE.set(Calendar.SECOND , 00); Map param = new HashMap<>(); // param.put("createTimeS", createTimeS.getTimeInMillis()); // param.put("createTimeE", createTimeE.getTimeInMillis()); param.put("orderNo", orderNo); List orderRefundList = orderRefundService.getRefundOrderList(param); for (HighOrderRefund orderRefund : orderRefundList) { try { orderRefundService.refundPrice( orderRefund.getRefundOrderNo(), orderService.getOrderDetailByNo(orderRefund.getOrderNo()), OrderPayType.getDataByType(orderRefund.getPayType()), orderRefund.getRefundPrice(), orderRefund.getRefundIntegral() ); orderRefund.setExt1("true"); } catch (Exception e) { orderRefund.setExt1("false"); } finally { orderRefundService.update(orderRefund); } } return ResponseMsgUtil.success("退款成功"); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } public String orderTitle(OutRechargeOrder outRechargeOrder) { // 1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 // 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款 switch (outRechargeOrder.getOperatorType()) { case 1: return outRechargeOrder.getRechargeContent() + "电信话费充值" + outRechargeOrder.getRechargePrice() + "元"; case 2: return outRechargeOrder.getRechargeContent() + "移动话费充值" + outRechargeOrder.getRechargePrice() + "元"; case 3: return outRechargeOrder.getRechargeContent() + "联通话费充值" + outRechargeOrder.getRechargePrice() + "元"; default: return null; } } } \ No newline at end of file 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 75d02b1b..cf531f4d 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/CommonController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/CommonController.java @@ -232,6 +232,20 @@ public class CommonController { } } + @RequestMapping(value="/findSecConfigByType",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "根据码值类型查询数据") + public ResponseData findSecConfigByType(@RequestParam(name = "codeType", required = true) String codeType) { + try { + + return ResponseMsgUtil.success(commonService.findSecConfigByType(codeType)); + + } catch (Exception e) { + log.error("CommonController --> getDictionaryByCodeTypeAndValue() error!", e); + return ResponseMsgUtil.exception(e); + } + } + @RequestMapping(value = "/ getScanCodePageHtmlSign", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "获取扫码页面签名") diff --git a/hai-cweb/src/main/java/com/cweb/controller/OutRechargePriceController.java b/hai-cweb/src/main/java/com/cweb/controller/OutRechargePriceController.java index 48ae52db..b010541a 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/OutRechargePriceController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/OutRechargePriceController.java @@ -1,5 +1,6 @@ package com.cweb.controller; +import com.alibaba.fastjson.JSONObject; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.hai.common.exception.ErrorCode; @@ -8,10 +9,7 @@ import com.hai.common.exception.SysCode; import com.hai.common.security.SessionObject; import com.hai.common.security.UserCenter; import com.hai.common.utils.ResponseMsgUtil; -import com.hai.entity.BsCompany; -import com.hai.entity.HighAgent; -import com.hai.entity.OutRechargePrice; -import com.hai.entity.SecRegion; +import com.hai.entity.*; import com.hai.model.OutRechargePriceModel; import com.hai.model.ResponseData; import com.hai.model.UserInfoModel; @@ -32,6 +30,7 @@ import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -43,35 +42,44 @@ public class OutRechargePriceController { private static Logger log = LoggerFactory.getLogger(HighMerchantStoreController.class); - @Autowired - private UserCenter userCenter; - @Resource private OutRechargePriceService outRechargePriceService; - @Resource - private BsCompanyService bsCompanyService; - @Resource private CommonService commonService; + @RequestMapping(value = "/getRechargePriceByList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询充值金额列表") public ResponseData getRechargePriceByList( @RequestParam(name = "platformId", required = true) Integer platformId, - @RequestParam(name = "companyId", required = true) Long companyId, - @RequestParam(name = "operatorType", required = true) Integer operatorType + @RequestParam(name = "companyId", required = true) Long companyId ) { try { - Map map = new HashMap<>(); + Map map; + + List secDictionaryList = commonService.mappingSysNameOl("OPERATOR_TYPE"); + + List list = new ArrayList<>(); + + for (SecDictionary secDictionary : secDictionaryList) { + map = new HashMap<>(); + JSONObject object = new JSONObject(); + object.put("title" , secDictionary.getCodeName()); + object.put("id" , secDictionary.getCodeValue()); + object.put("explain_receipt_time" , commonService.findSecConfigByType("explain_receipt_time").getCodeValue()); + + map.put("companyId", companyId); + map.put("platformId", platformId); + map.put("operatorType", secDictionary.getCodeValue()); + object.put("priceList" , outRechargePriceService.getRechargePriceByList(map)); - map.put("companyId", companyId); - map.put("platformId", platformId); - map.put("operatorType", operatorType); + list.add(object); + } - return ResponseMsgUtil.success( outRechargePriceService.getRechargePriceByList(map)); + return ResponseMsgUtil.success(list); } catch (Exception e) { log.error("OutRechargePriceController --> getListUser() error!", e); return ResponseMsgUtil.exception(e); diff --git a/hai-order/src/main/java/com/web/controller/business/OrderMobileRechargeController.java b/hai-order/src/main/java/com/web/controller/business/OrderMobileRechargeController.java index 391d5090..4c1317bf 100644 --- a/hai-order/src/main/java/com/web/controller/business/OrderMobileRechargeController.java +++ b/hai-order/src/main/java/com/web/controller/business/OrderMobileRechargeController.java @@ -195,7 +195,7 @@ public class OrderMobileRechargeController { dataList.add(model); } - String fileUrl = SysConst.getSysConfig().getFileUrl() + "temporary/"; + String fileUrl = SysConst.getSysConfig().getFileUrl() + "temp orary/"; String pathName = System.currentTimeMillis()+".xlsx"; File file = new File(fileUrl); if (!file.exists()) { diff --git a/hai-service/src/main/java/com/hai/openApi/model/ApiGasOliPriceModel.java b/hai-service/src/main/java/com/hai/openApi/model/ApiGasOliPriceModel.java index ec023f8f..19b88975 100644 --- a/hai-service/src/main/java/com/hai/openApi/model/ApiGasOliPriceModel.java +++ b/hai-service/src/main/java/com/hai/openApi/model/ApiGasOliPriceModel.java @@ -44,7 +44,7 @@ public class ApiGasOliPriceModel { /** * 油枪号数组 */ - private String[] gasOliNo; + private List gasOliNo; public String getOilNo() { return oilNo; @@ -102,11 +102,11 @@ public class ApiGasOliPriceModel { this.oilTypeName = oilTypeName; } - public String[] getGasOliNo() { + public List getGasOliNo() { return gasOliNo; } - public void setGasOliNo(String[] gasOliNo) { + public void setGasOliNo(List gasOliNo) { this.gasOliNo = gasOliNo; } } diff --git a/hai-service/src/main/java/com/hai/openApi/model/ApiMchStoreModel.java b/hai-service/src/main/java/com/hai/openApi/model/ApiMchStoreModel.java index c11b5bcc..6d0f9282 100644 --- a/hai-service/src/main/java/com/hai/openApi/model/ApiMchStoreModel.java +++ b/hai-service/src/main/java/com/hai/openApi/model/ApiMchStoreModel.java @@ -7,9 +7,6 @@ public class ApiMchStoreModel { // 区域名称 private String regionName; - // 门店logo - private String storeLogo; - // 门店编码 private String storeCode; @@ -38,14 +35,6 @@ public class ApiMchStoreModel { this.regionName = regionName; } - public String getStoreLogo() { - return storeLogo; - } - - public void setStoreLogo(String storeLogo) { - this.storeLogo = storeLogo; - } - public String getStoreCode() { return storeCode; } diff --git a/hai-service/src/main/java/com/hai/openApi/service/ApiMchProductService.java b/hai-service/src/main/java/com/hai/openApi/service/ApiMchProductService.java index d4530a58..8dc3013e 100644 --- a/hai-service/src/main/java/com/hai/openApi/service/ApiMchProductService.java +++ b/hai-service/src/main/java/com/hai/openApi/service/ApiMchProductService.java @@ -57,6 +57,26 @@ public interface ApiMchProductService { */ ApiMchProduct findById(Long id); + /** + * @Author Sum1Dream + * @Name whereExistence + * @Description // 查询 + * @Date 14:31 2023/2/28 + * @Param [mchId, productType] + * @Return com.hai.entity.ApiMchProduct + */ + Boolean whereExistence(String mchId , Integer productType); + + /** + * @Author Sum1Dream + * @Name findByMap + * @Description // 根据map查询商户产品 + * @Date 10:55 2023/2/28 + * @Param [map] + * @Return com.hai.entity.ApiMchProduct + */ + ApiMchProduct findByMap(Map map); + /** * @Author Sum1Dream * @Name detailConfigMchProduct diff --git a/hai-service/src/main/java/com/hai/openApi/service/impl/ApiMchProductServiceImpl.java b/hai-service/src/main/java/com/hai/openApi/service/impl/ApiMchProductServiceImpl.java index e3882477..68b78092 100644 --- a/hai-service/src/main/java/com/hai/openApi/service/impl/ApiMchProductServiceImpl.java +++ b/hai-service/src/main/java/com/hai/openApi/service/impl/ApiMchProductServiceImpl.java @@ -13,6 +13,7 @@ import com.hai.openApi.service.ApiMchProductService; import com.hai.order.type.OrderProductType; import com.hai.service.SecConfigService; import org.apache.commons.collections4.MapUtils; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -54,6 +55,14 @@ public class ApiMchProductServiceImpl implements ApiMchProductService { apiMchProduct.setCreateTime(new Date()); apiMchProduct.setUpdateTime(new Date()); + if (whereExistence((object.getString("mchId")) , Integer.valueOf(productType.toString()))) { + continue; + } + + if (secConfigService.isConfig(OrderProductType.getDataByType(Integer.valueOf(productType.toString())).getApiCode() , object.getString("mchId"))) { + continue; + } + // 插入接口权限 SecConfig secConfig = new SecConfig(); secConfig.setCodeValue(object.getString("mchId")); @@ -106,6 +115,36 @@ public class ApiMchProductServiceImpl implements ApiMchProductService { return apiMchProductMapper.selectByPrimaryKey(id); } + @Override + public Boolean whereExistence(String mchId, Integer productType) { + ApiMchProductExample example = new ApiMchProductExample(); + + example.createCriteria().andMchIdEqualTo(mchId).andProductTypeEqualTo(productType); + + return apiMchProductMapper.selectByExample(example).size() > 0; + } + + @Override + public ApiMchProduct findByMap(Map map) { + ApiMchProductExample example = new ApiMchProductExample(); + ApiMchProductExample.Criteria criteria = example.createCriteria(); + + if (MapUtils.getInteger(map , "productType") != null) { + criteria.andProductTypeEqualTo(MapUtils.getInteger(map , "productType")); + } + if (StringUtils.isNotBlank(MapUtils.getString(map, "mchId"))) { + criteria.andMchIdEqualTo(MapUtils.getString(map, "mchId")); + } + + List list = apiMchProductMapper.selectByExample(example); + + if (list.size() > 0 ) { + return list.get(0); + } + + return null; + } + @Override public void detailConfigMchProduct(String mchId) { ApiMchProductExample example = new ApiMchProductExample(); diff --git a/hai-service/src/main/java/com/hai/service/CommonService.java b/hai-service/src/main/java/com/hai/service/CommonService.java index 2b494bbe..1e02830a 100644 --- a/hai-service/src/main/java/com/hai/service/CommonService.java +++ b/hai-service/src/main/java/com/hai/service/CommonService.java @@ -9,6 +9,7 @@ package com.hai.service; import com.alibaba.fastjson.JSONObject; import com.hai.entity.ApiCity; +import com.hai.entity.SecConfig; import com.hai.entity.SecDictionary; import com.hai.entity.SecRegion; import com.hai.model.IndexCountModel; @@ -298,4 +299,15 @@ public interface CommonService { ApiCity findCityByProvinceName(String provinceName); + /** + * @Author Sum1Dream + * @Name findSecConfigByType + * @Description // 查询配置内容 + * @Date 09:12 2023/2/28 + * @Param [codeType] + * @Return com.hai.entity.SecConfig + */ + SecConfig findSecConfigByType(String codeType); + + } diff --git a/hai-service/src/main/java/com/hai/service/impl/CommonServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/CommonServiceImpl.java index 45ac55df..c0442626 100644 --- a/hai-service/src/main/java/com/hai/service/impl/CommonServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/CommonServiceImpl.java @@ -71,6 +71,9 @@ public class CommonServiceImpl implements CommonService { @Resource private ApiCityMapper apiCityMapper; + @Resource + private SecConfigMapper secConfigMapper; + private Map> dicCache = new HashMap>(); @@ -716,5 +719,16 @@ public class CommonServiceImpl implements CommonService { } + @Override + public SecConfig findSecConfigByType(String codeType) { + + SecConfigExample example = new SecConfigExample(); + example.createCriteria().andCodeTypeEqualTo(codeType); + if (secConfigMapper.selectByExample(example).size() > 0) { + return secConfigMapper.selectByExample(example).get(0); + } + return null; + + } } diff --git a/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java index 6c592414..66b8ee83 100644 --- a/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java @@ -886,7 +886,11 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { objectData = (JSONObject) objects; } if (objectData.size() == 0) { - return 2; + if (jsonObject.getInteger("errno") == 0) { + return 2; + } else { + return 99; + } } else { // -1取消,0充值中 ,1充值成功,2充值失败,3部分成功 return objectData.getInteger("state"); diff --git a/v1/src/main/java/com/v1/config/ApiCommonConfig.java b/v1/src/main/java/com/v1/config/ApiCommonConfig.java new file mode 100644 index 00000000..b13b60e4 --- /dev/null +++ b/v1/src/main/java/com/v1/config/ApiCommonConfig.java @@ -0,0 +1,55 @@ +package com.v1.config; + +import com.hai.entity.ApiMchProduct; +import com.hai.entity.HighGasOilGunNo; +import com.hai.openApi.service.ApiMchProductService; +import com.hai.service.ApiMerchantsService; +import com.hai.service.HighGasOilGunNoService; +import org.springframework.context.annotation.Configuration; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Configuration +public class ApiCommonConfig { + + @Resource + private ApiMchProductService ApiMchProductService; + + @Resource + private HighGasOilGunNoService highGasOilGunNoService; + + public BigDecimal computationPriceCost(String mchId , Integer productType , BigDecimal price) { + + Map map = new HashMap<>(); + map.put("mchId" , mchId); + map.put("productType" , productType); + + ApiMchProduct apiMchProduct = ApiMchProductService.findByMap(map); + + return price.multiply(apiMchProduct.getDiscount()).setScale(2, BigDecimal.ROUND_HALF_UP); + + } + + + public List assemblyGasOilGunNo(Long oilPriceId) { + + List gasOilGunNos = new ArrayList<>(); + + List list = highGasOilGunNoService.getGunNoListByOilPrice(oilPriceId); + + + for (HighGasOilGunNo gasOilGunNo : list) { + gasOilGunNos.add(gasOilGunNo.getGunNo()); + } + + + return gasOilGunNos; + + } + +} diff --git a/v1/src/main/java/com/v1/config/AuthConfig.java b/v1/src/main/java/com/v1/config/AuthConfig.java index d85e96cd..863c83a8 100644 --- a/v1/src/main/java/com/v1/config/AuthConfig.java +++ b/v1/src/main/java/com/v1/config/AuthConfig.java @@ -96,6 +96,7 @@ public class AuthConfig implements WebMvcConfigurer { .excludePathPatterns("/selfOilStation/*") .excludePathPatterns("/order/*") .excludePathPatterns("/wxMsg/*") + .excludePathPatterns("/refuelOnline/*") ; } diff --git a/v1/src/main/java/com/v1/controller/RefuelOnlineController.java b/v1/src/main/java/com/v1/controller/RefuelOnlineController.java index 2af01bd8..9a42dc56 100644 --- a/v1/src/main/java/com/v1/controller/RefuelOnlineController.java +++ b/v1/src/main/java/com/v1/controller/RefuelOnlineController.java @@ -7,13 +7,12 @@ import com.hai.common.exception.SysCode; import com.hai.common.utils.ResponseMsgUtil; import com.hai.entity.*; import com.hai.model.ResponseData; +import com.hai.openApi.model.ApiGasOliPriceModel; import com.hai.openApi.model.ApiMchStoreModel; import com.hai.openApi.service.ApiMchProductService; import com.hai.order.type.OrderProductType; -import com.hai.service.ApiIpAddressService; -import com.hai.service.ApiMerchantsService; -import com.hai.service.HighMerchantStoreService; -import com.hai.service.SecConfigService; +import com.hai.service.*; +import com.v1.config.ApiCommonConfig; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; @@ -55,6 +54,12 @@ public class RefuelOnlineController { @Resource private HighMerchantStoreService highMerchantStoreService; + @Resource + private HighGasOilPriceService gasOilPriceService; + + @Resource + private ApiCommonConfig apiCommonConfig; + @RequestMapping(value = "/getStationStores", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "获取油站门店") @@ -69,11 +74,6 @@ public class RefuelOnlineController { ip = request.getHeader("x-forwarded-for"); } - if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { - log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); - } - if (StringUtils.isBlank(object.getString("apiKey")) || StringUtils.isBlank(object.getString("merchId")) || StringUtils.isBlank(object.getString("sign")) @@ -82,6 +82,11 @@ public class RefuelOnlineController { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR); } + if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) { + log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!"); + } + ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId")); if (apiMerchants == null) { @@ -91,7 +96,7 @@ public class RefuelOnlineController { if (!secConfigService.isConfig(OrderProductType.PRODUCT_TYPE6.getApiCode(), object.getString("merchId"))) { log.error("getAllCities error!", "当前帐户无权限查询!"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOT_AUTHORIZED, "当前帐户无权限查询!"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.MERCHANT_NOT_AUTHORIZED, ""); } Map map = new HashMap<>(); @@ -123,10 +128,31 @@ public class RefuelOnlineController { for (HighMerchantStore merchantStore : merchantStores) { ApiMchStoreModel apiMchStoreModel = new ApiMchStoreModel(); apiMchStoreModel.setAddress(merchantStore.getAddress()); -// apiMchStoreModel.setStore_logo(); + apiMchStoreModel.setStoreCode(merchantStore.getStoreKey()); + apiMchStoreModel.setLatitude(merchantStore.getLatitude()); + apiMchStoreModel.setLongitude(merchantStore.getLongitude()); + apiMchStoreModel.setStoreName(merchantStore.getStoreName()); + apiMchStoreModel.setRegionName(merchantStore.getRegionName()); + + List gasOilPrices = gasOilPriceService.getGasOilPriceByStore(merchantStore.getId()); + + for (HighGasOilPrice gasOilPrice : gasOilPrices) { + ApiGasOliPriceModel gasOliPriceModel = new ApiGasOliPriceModel(); + gasOliPriceModel.setPriceCost(apiCommonConfig.computationPriceCost(object.getString("merchId") , OrderProductType.PRODUCT_TYPE6.getNumber() , gasOilPrice.getPriceGun())); + gasOliPriceModel.setPriceGun(gasOilPrice.getPriceGun()); + gasOliPriceModel.setPriceOfficial(gasOilPrice.getPriceOfficial()); + gasOliPriceModel.setOilNo(gasOilPrice.getOilNo()); + gasOliPriceModel.setOilNoName(gasOilPrice.getOilNoName()); + gasOliPriceModel.setOilType(gasOilPrice.getOilType()); + gasOliPriceModel.setOilTypeName(gasOilPrice.getOilTypeName()); + gasOliPriceModel.setGasOliNo(apiCommonConfig.assemblyGasOilGunNo(gasOilPrice.getId())); + apiMchStoreModel.getApiGasOliPriceModels().add(gasOliPriceModel); + } + + apiMchStoreModels.add(apiMchStoreModel); } - return ResponseMsgUtil.success(merchantStores); + return ResponseMsgUtil.success(apiMchStoreModels); } catch (Exception e) { log.error("HighOpenApiController --> getRechargeProduct() error!", e); diff --git a/v1/src/main/resources/dev/application.yml b/v1/src/main/resources/dev/application.yml index 6d26a97d..457b5089 100644 --- a/v1/src/main/resources/dev/application.yml +++ b/v1/src/main/resources/dev/application.yml @@ -9,7 +9,7 @@ debug: false #datasource数据源设置 spring: datasource: - url: jdbc:mysql://139.159.177.244:3306/hsg_order?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false + url: jdbc:mysql://139.159.177.244:3306/hsg_2.0?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false username: root password: HF123456. type: com.alibaba.druid.pool.DruidDataSource