提交代码

master
胡锐 1 month ago
parent dd11156f0c
commit 1bc3d2c899
  1. 31
      cweb/src/main/java/com/cweb/controller/CommonController.java
  2. 33
      cweb/src/main/java/com/cweb/controller/PhgController.java
  3. 9
      service/src/main/java/com/hfkj/common/pay/util/SignatureUtil.java
  4. 4
      service/src/main/java/com/hfkj/config/CommonSysConfig.java
  5. 1
      service/src/main/resources/dev/commonConfig.properties

@ -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);
}
}
}

@ -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<String,Object> 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);
}
}
}

@ -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);
}

@ -72,6 +72,10 @@ public class CommonSysConfig {
*/
private String huiPayPreorderNotifyUrl;
/**
* 普惠Go请求URL
*/
private String phgReqUrl;
/**
* 普惠GOappid
*/

@ -16,5 +16,6 @@ cqShellPartnerId=S0302207281600105753
cqShellPlatMerchantId=S0302206141000105717
cqShellPlatMerchantKey=wqisfmkzea6mwd7ogbyh3488jv0hqhdj
phgReqUrl=https://phgcs.dctpay.com
phgAppid=20241266600
phgAppSecret=BCB83776BDA7F609FBE99BBB8AC33840

Loading…
Cancel
Save