From 1bc3d2c899cd7f089e2fa2784732ecfecd471f05 Mon Sep 17 00:00:00 2001 From: hu177768073 <177768073@qq.com> Date: Wed, 18 Dec 2024 17:04:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/cweb/controller/CommonController.java | 31 +++++++++++++++-- .../com/cweb/controller/PhgController.java | 33 +++++++++++++++++++ .../hfkj/common/pay/util/SignatureUtil.java | 9 ++--- .../java/com/hfkj/config/CommonSysConfig.java | 4 +++ .../resources/dev/commonConfig.properties | 1 + 5 files changed, 72 insertions(+), 6 deletions(-) diff --git a/cweb/src/main/java/com/cweb/controller/CommonController.java b/cweb/src/main/java/com/cweb/controller/CommonController.java index 37da2d7..a275e9a 100644 --- a/cweb/src/main/java/com/cweb/controller/CommonController.java +++ b/cweb/src/main/java/com/cweb/controller/CommonController.java @@ -3,8 +3,10 @@ package com.cweb.controller; import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.model.ResponseData; import com.hfkj.service.CommonService; +import com.hfkj.service.sec.SecDictionaryService; 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.web.bind.annotation.*; @@ -16,10 +18,35 @@ import javax.annotation.Resource; @RequestMapping(value="/common") @Api(value="共用接口") public class CommonController { - Logger log = LoggerFactory.getLogger(CommonController.class); - @Resource private CommonService commonService; + @Resource + private SecDictionaryService secDictionaryService; + + @RequestMapping(value="/queryDictionary",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询数据字典") + public ResponseData queryDictionary(@RequestParam(value = "codeType" , required = false) String codeType, + @RequestParam(value = "codeValue" , required = false) String codeValue) { + try { + + if (StringUtils.isBlank(codeType) && StringUtils.isBlank(codeValue)) { + return ResponseMsgUtil.success(secDictionaryService.getDictionary()); + + } else if (StringUtils.isNotBlank(codeType) && StringUtils.isNotBlank(codeValue)) { + return ResponseMsgUtil.success(secDictionaryService.getDictionary(codeType, codeValue)); + + } else if (StringUtils.isNotBlank(codeType)) { + return ResponseMsgUtil.success(secDictionaryService.getDictionary(codeType)); + } + + return ResponseMsgUtil.success(null); + + } catch (Exception e) { + log.error("error!",e); + return ResponseMsgUtil.exception(e); + } + } } diff --git a/cweb/src/main/java/com/cweb/controller/PhgController.java b/cweb/src/main/java/com/cweb/controller/PhgController.java index 3386092..80ad7c2 100644 --- a/cweb/src/main/java/com/cweb/controller/PhgController.java +++ b/cweb/src/main/java/com/cweb/controller/PhgController.java @@ -1,11 +1,13 @@ package com.cweb.controller; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.hfkj.common.exception.ErrorCode; import com.hfkj.common.exception.ErrorHelp; import com.hfkj.common.exception.SysCode; import com.hfkj.common.pay.util.SignatureUtil; import com.hfkj.common.security.UserCenter; +import com.hfkj.common.utils.HttpsUtils; import com.hfkj.common.utils.RedisUtil; import com.hfkj.common.utils.ResponseMsgUtil; import com.hfkj.config.CommonSysConst; @@ -35,6 +37,8 @@ import java.util.Map; @Api(value = "普惠go业务") public class PhgController { private static Logger log = LoggerFactory.getLogger(PhgController.class); + @Resource + private UserCenter userCenter; @RequestMapping(value="/login",method = RequestMethod.POST) @ResponseBody @@ -55,4 +59,33 @@ public class PhgController { } } + + + @RequestMapping(value="/queryPhgList",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询普惠GO优惠券列表") + public ResponseData queryPhgList(@RequestParam(name = "status", required = true) Integer status) { + try { + // 用户信息 + UserSessionObject userSessionObject = userCenter.getSessionModel(UserSessionObject.class); + // 状态转换 + if (status == 3) { + status = 0; // 已过期 + } + Map param = new HashMap<>(); + param.put("appid", CommonSysConst.getSysConfig().getPhgAppid()); + param.put("phone", userSessionObject.getUser().getPhone()); + param.put("status", status); // 状态 0:已过期 1:未使用 2:已使用 + param.put("sign", SignatureUtil.createSign(param, CommonSysConst.getSysConfig().getPhgAppSecret())); + JSONObject response = HttpsUtils.doPost(CommonSysConst.getSysConfig().getPhgReqUrl()+"/crest/output/getListUserDiscount", JSONObject.toJSONString(param)); + if (!response.getString("return_code").equals("000000")) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, response.getString("return_msg")); + } + return ResponseMsgUtil.success(JSONArray.parse(response.getString("return_data"))); + + } catch (Exception e) { + return ResponseMsgUtil.exception(e); + } + } + } diff --git a/service/src/main/java/com/hfkj/common/pay/util/SignatureUtil.java b/service/src/main/java/com/hfkj/common/pay/util/SignatureUtil.java index 2835fc7..000afbc 100644 --- a/service/src/main/java/com/hfkj/common/pay/util/SignatureUtil.java +++ b/service/src/main/java/com/hfkj/common/pay/util/SignatureUtil.java @@ -86,11 +86,12 @@ public class SignatureUtil { public static void main(String[] args) throws Exception { String paramStr = "{\n" + - " \"appId\": \"hffeab7fdb44d4f1\",\n" + - " \"orderNo\": \"test10021001\",\n" + - " \"refundReason\": \"测试退款\"" + + " \"appId\": \"hf7356c71fb97ab0\",\n" + + " \"phone\": \"15983485280\",\n" + + " \"reqId\": \"test10001\",\n" + + " \"status\":1" + "}"; - String sign = createSign(JSONObject.parseObject(paramStr), "3a9b2772b9a2d319a9b18e55fa30246d"); + String sign = createSign(JSONObject.parseObject(paramStr), "8aef995ff71485dc19b36e35f04c4016"); System.out.println(sign); } diff --git a/service/src/main/java/com/hfkj/config/CommonSysConfig.java b/service/src/main/java/com/hfkj/config/CommonSysConfig.java index 8d4ac85..eeb0fb1 100644 --- a/service/src/main/java/com/hfkj/config/CommonSysConfig.java +++ b/service/src/main/java/com/hfkj/config/CommonSysConfig.java @@ -72,6 +72,10 @@ public class CommonSysConfig { */ private String huiPayPreorderNotifyUrl; + /** + * 【普惠Go】请求URL + */ + private String phgReqUrl; /** * 【普惠GO】appid */ diff --git a/service/src/main/resources/dev/commonConfig.properties b/service/src/main/resources/dev/commonConfig.properties index 94c4d74..d5d78d3 100644 --- a/service/src/main/resources/dev/commonConfig.properties +++ b/service/src/main/resources/dev/commonConfig.properties @@ -16,5 +16,6 @@ cqShellPartnerId=S0302207281600105753 cqShellPlatMerchantId=S0302206141000105717 cqShellPlatMerchantKey=wqisfmkzea6mwd7ogbyh3488jv0hqhdj +phgReqUrl=https://phgcs.dctpay.com phgAppid=20241266600 phgAppSecret=BCB83776BDA7F609FBE99BBB8AC33840