新增中石化对外开放接口

dev-discount
袁野 3 years ago
parent cdd632a4e4
commit 03d4100cf4
  1. 156
      hai-bweb/src/main/java/com/bweb/controller/HighOpenApiController.java
  2. 2
      hai-bweb/src/main/java/com/bweb/controller/HighTestController.java
  3. 2
      hai-bweb/src/main/java/com/bweb/controller/OutRechargeOrderController.java
  4. 19
      hai-cweb/src/main/java/com/cweb/config/SysConfig.java
  5. 2
      hai-cweb/src/main/java/com/cweb/controller/HighTestController.java
  6. 53
      hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java
  7. 52
      hai-cweb/src/main/java/com/cweb/controller/WechatController.java
  8. 8
      hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java
  9. 2
      hai-cweb/src/main/resources/dev/config.properties
  10. 3
      hai-cweb/src/main/resources/prod/config.properties
  11. 17
      hai-service/src/main/java/com/hai/config/WxOrderConfig.java
  12. 8
      hai-service/src/main/java/com/hai/service/SecConfigService.java

@ -1,27 +1,35 @@
package com.bweb.controller; package com.bweb.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode; import com.hai.common.exception.SysCode;
import com.hai.common.security.SessionObject;
import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.ResponseMsgUtil;
import com.hai.config.HuiLianTongConfig;
import com.hai.entity.HighCoupon;
import com.hai.entity.HighMerchant;
import com.hai.entity.HighUser; import com.hai.entity.HighUser;
import com.hai.model.ResponseData; import com.hai.model.ResponseData;
import com.hai.model.UserInfoModel;
import com.hai.service.HighOpenApiService; import com.hai.service.HighOpenApiService;
import com.hai.service.HighUserService; import com.hai.service.HighUserService;
import com.hai.service.SecConfigService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.net.InetAddress;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -44,7 +52,13 @@ public class HighOpenApiController {
@Resource @Resource
private HighUserService highUserService; private HighUserService highUserService;
@RequestMapping(value = "/getUserExclusiveDiscount", method = RequestMethod.GET) @Resource
private SecConfigService secConfigService;
@Resource
private HuiLianTongConfig huiLianTongConfig;
@RequestMapping(value = "/getGuizhouSinopecList", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "获取专属优惠券") @ApiOperation(value = "获取专属优惠券")
public ResponseData getUserExclusiveDiscount(@RequestParam(name = "useScope", required = false) Integer useScope, public ResponseData getUserExclusiveDiscount(@RequestParam(name = "useScope", required = false) Integer useScope,
@ -70,7 +84,137 @@ public class HighOpenApiController {
return ResponseMsgUtil.success(highOpenApiService.getUserCouponsList(map)); return ResponseMsgUtil.success(highOpenApiService.getUserCouponsList(map));
} catch (Exception e) { } catch (Exception e) {
log.error("HighOrderController --> getUserPreOrderList() error!", e); log.error("HighOpenApiController --> getGuizhouSinopecList() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/getGuizhouSinopecList",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "获取贵州中石化电子卡券")
public ResponseData getGuizhouSinopecList(HttpServletRequest request) {
try {
String ip = "";
// 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for
if (request.getHeader("x-forwarded-for") == null) {
ip = request.getRemoteAddr();
} else {
ip = request.getHeader("x-forwarded-for");
}
if (!secConfigService.isConfig("IP_WHITE" , ip)) {
log.error("getGuizhouSinopec error!", "非法ip地址,请联系管理人员!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "非法ip地址,请联系管理人员!");
}
// 获取token
String token = huiLianTongConfig.getToken();
// 查询电子卡券类型
JSONObject corpCouTypes = HuiLianTongConfig.getCorpCouTypes(token);
System.out.println(corpCouTypes.toJSONString());
if (!corpCouTypes.getString("result").equals("success")) {
log.error("HighOpenApiController -> getGuizhouSinopecList() error!","获取电子卡券列表失败");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "获取电子卡券列表失败");
}
return ResponseMsgUtil.success(corpCouTypes.getJSONArray("data"));
} catch (Exception e) {
log.error("HighCouponController -> getGuizhouSinopec() error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/checkCouponStatus",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "查询电子券状态")
public ResponseData checkCouponStatus(@RequestBody JSONObject object, HttpServletRequest request) {
try {
String ip = "";
// 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for
if (request.getHeader("x-forwarded-for") == null) {
ip = request.getRemoteAddr();
} else {
ip = request.getHeader("x-forwarded-for");
}
if (!secConfigService.isConfig("IP_WHITE" , ip)) {
log.error("getGuizhouSinopec error!", "非法ip地址,请联系管理人员!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "非法ip地址,请联系管理人员!");
}
// 获取token
String token = huiLianTongConfig.getToken();
// 查询电子卡券类型
JSONObject data = HuiLianTongConfig.getCouState(token, object.getString("orderNo"));
if (!data.getString("result").equals("success")) {
log.error("HighOpenApiController -> insertCoupon() error!","查询电子券状态失败");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "查询电子券状态失败");
}
return ResponseMsgUtil.success(data.getJSONObject("data"));
} catch (Exception e) {
log.error("HighCouponController -> getGuizhouSinopec() error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/couJointDist",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "商户派发电子券")
public ResponseData couJointDist(@RequestBody JSONObject object, HttpServletRequest request) {
try {
String ip = "";
// 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for
if (request.getHeader("x-forwarded-for") == null) {
ip = request.getRemoteAddr();
} else {
ip = request.getHeader("x-forwarded-for");
}
if (!secConfigService.isConfig("IP_WHITE" , ip)) {
log.error("couJointDist error!", "非法ip地址,请联系管理人员!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "非法ip地址,请联系管理人员!");
}
// 获取token
String token = huiLianTongConfig.getToken();
// 商户派发电子券
JSONObject returnParam = HuiLianTongConfig.couJointDist(token, object.getString("orderNo"), object.getString("couTypeCode"), object.getInteger("distCouCount"), object.getString("phone"), object.getString("thirdUserId"));
if (returnParam == null || !returnParam.getString("result").equals("success")) {
log.error("HighOpenApiController -> couJointDist() error!","商户派发电子券失败");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "商户派发电子券失败");
}
return ResponseMsgUtil.success(returnParam.getJSONArray("data"));
} catch (Exception e) {
log.error("HighOpenApiController -> couJointDist() error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/test",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "测试")
public ResponseData test(HttpServletRequest request) {
try {
String ip = "";
if (request.getHeader("x-forwarded-for") == null) {
ip = request.getRemoteAddr();
}
ip = request.getHeader("x-forwarded-for");
return ResponseMsgUtil.success(ip);
} catch (Exception e) {
log.error("HighCouponController -> getGuizhouSinopec() error!",e);
return ResponseMsgUtil.exception(e); return ResponseMsgUtil.exception(e);
} }
} }

File diff suppressed because one or more lines are too long

@ -608,8 +608,6 @@ public class OutRechargeOrderController {
OutRechargeOrder order = outRechargeOrderService.findByOrderId(rechargeOrderRecord.getRechargeOrderId()); OutRechargeOrder order = outRechargeOrderService.findByOrderId(rechargeOrderRecord.getRechargeOrderId());
if (order.getStatus() == 2) { if (order.getStatus() == 2) {
outRechargeOrderService.rechargeOrderToRefund(order.getId()); outRechargeOrderService.rechargeOrderToRefund(order.getId());
order.setStatus(5);
outRechargeOrderService.updateOrder(order);
} }
} }

@ -27,6 +27,9 @@ public class SysConfig {
private String notifyUrl; private String notifyUrl;
private String qzNotifyUrl; private String qzNotifyUrl;
private String wxGzSubAppId;
private String wxGzSubMchId;
// 重庆惠兑电子商务有限公司 // 重庆惠兑电子商务有限公司
private String HDAppId; private String HDAppId;
@ -149,4 +152,20 @@ public class SysConfig {
public void setHDAppId(String HDAppId) { public void setHDAppId(String HDAppId) {
this.HDAppId = HDAppId; this.HDAppId = HDAppId;
} }
public String getWxGzSubAppId() {
return wxGzSubAppId;
}
public void setWxGzSubAppId(String wxGzSubAppId) {
this.wxGzSubAppId = wxGzSubAppId;
}
public String getWxGzSubMchId() {
return wxGzSubMchId;
}
public void setWxGzSubMchId(String wxGzSubMchId) {
this.wxGzSubMchId = wxGzSubMchId;
}
} }

File diff suppressed because one or more lines are too long

@ -538,59 +538,6 @@ public class OutRechargeOrderController {
} }
// @RequestMapping(value = "/orderToRefund", method = RequestMethod.GET)
// @ResponseBody
// @ApiOperation(value = "订单退款")
// public ResponseData orderToRefund(@RequestParam(name = "orderId", required = false) Long orderId,
// HttpServletRequest request) {
// try {
//
// OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId);
// if (order == null) {
// log.error("orderToPay error!", "未找到充值订单");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到充值订单");
// }
//
// // 订单状态 : 1.待支付 2.已支付 3.已完成 4.已取消 5.已退款
// if (order.getStatus() != 2) {
// log.error("orderToPay error!", "无法退款,订单不处于已支付状态");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单不处于已支付状态");
// }
//
// Map<String,String> param = new HashMap<>();
// param.put("appid", "wx637bd6f7314daa46");
// param.put("mch_id", "1289663601");
// param.put("sub_mch_id" , "1609882817");
// param.put("nonce_str", WxUtils.makeNonStr());
// param.put("transaction_id", order.getPaySerialNo());
// param.put("out_refund_no", "HFR"+new Date().getTime());
// param.put("total_fee", String.valueOf(order.getPayRealPrice().multiply(new BigDecimal("100")).intValue()));
// param.put("refund_fee", String.valueOf(order.getPayRealPrice().multiply(new BigDecimal("100")).intValue()));
// param.put("sign_type", "HMAC-SHA256");
//
// String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5" , WXPayConstants.SignType.HMACSHA256);
// param.put("sign", signStr);
//
// String resultXmL = doRefundRequest(param.get("mch_id"), null, WxUtils.mapToXml(param));
// OrderRefundModel orderRefundModel = XmlUtil.getObjectFromXML(resultXmL, OrderRefundModel.class);
// if(orderRefundModel.getResult_code().equals("SUCCESS")) {
// order.setStatus(5);
// order.setRefundTime(new Date());
// order.setOutRefundNo(orderRefundModel.getOut_refund_no());
// order.setRefundId(orderRefundModel.getRefund_id());
// order.setRefundFee(new BigDecimal(orderRefundModel.getRefund_fee()).divide(new BigDecimal("100")));
// outRechargeOrderService.updateOrder(order);
// return ResponseMsgUtil.success("退款成功");
// }
// return ResponseMsgUtil.success("退款失败!错误代码:"+orderRefundModel.getErr_code()+",错误描述"+orderRefundModel.getErr_code_des());
//
// } catch (Exception e) {
// log.error("HighOrderController --> getUserOrderList() error!", e);
// return ResponseMsgUtil.exception(e);
// }
// }
@RequestMapping(value = "/wxProfitsharing", method = RequestMethod.GET) @RequestMapping(value = "/wxProfitsharing", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "分账") @ApiOperation(value = "分账")

@ -32,10 +32,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@ -158,30 +155,6 @@ public class WechatController {
} }
} }
@RequestMapping(value = "/loginByTel", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "小程序根据手机号登录或注册")
public ResponseData loginByPhone(@RequestParam(value = "loginByTel", required = true) String loginByTel,
HttpServletRequest request, HttpServletResponse response) {
try {
// 根据手机号查询用户
HighUser user = highUserService.findByPhone(loginByTel);
// 定义个人所有数据
HighUserModel highUserModel = new HighUserModel();
HighUser detailData = highUserService.getDetailDataByUser(user.getId());
detailData.setPassword(null);
highUserModel.setHighUser(detailData);
SessionObject so = new SessionObject(user.getPhone(), 1 , highUserModel);
userCenter.save(request, response, so);
return ResponseMsgUtil.success(so);
} catch (Exception e) {
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/getUserInfo", method = RequestMethod.GET) @RequestMapping(value = "/getUserInfo", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ -271,14 +244,27 @@ public class WechatController {
} }
} }
@RequestMapping(value = "/loginByTel1", method = RequestMethod.GET) @RequestMapping(value = "/loginByTel", method = RequestMethod.POST)
@ResponseBody @ResponseBody
@ApiOperation(value = "根据手机号码登陆") @ApiOperation(value = "根据手机号码登陆")
public ResponseData loginByTel1(@RequestParam(value = "phone", required = true) String phone, public ResponseData loginByTel(@RequestBody JSONObject body,
HttpServletRequest request, HttpServletResponse response) { HttpServletRequest request, HttpServletResponse response) {
try { try {
if (body == null
|| StringUtils.isBlank(body.getString("phone"))
|| StringUtils.isBlank(body.getString("smsCode"))) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
// 根据手机号查询用户 // 根据手机号查询用户
HighUser user = highUserService.findByPhone(phone); HighUser user = highUserService.findByPhone(body.getString("phone"));
// 获取手机号验证码
String phoneSmsCode = (String) redisUtil.get("SMS_"+ body.getString("phone"));
// 验证码校验
if (StringUtils.isNotBlank(phoneSmsCode) && Objects.equals(phoneSmsCode,body.getString("smsCode"))) {
// 定义个人所有数据 // 定义个人所有数据
// 定义个人所有数据 // 定义个人所有数据
HighUserModel highUserModel = new HighUserModel(); HighUserModel highUserModel = new HighUserModel();
@ -288,8 +274,12 @@ public class WechatController {
SessionObject so = new SessionObject(user.getPhone(), 1 , highUserModel); SessionObject so = new SessionObject(user.getPhone(), 1 , highUserModel);
userCenter.save(request, response, so); userCenter.save(request, response, so);
return ResponseMsgUtil.success(so); return ResponseMsgUtil.success(so);
}
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "验证码错误");
} catch (Exception e) { } catch (Exception e) {
return ResponseMsgUtil.exception(e); return ResponseMsgUtil.exception(e);

@ -191,7 +191,13 @@ public class OrderController {
} else { } else {
weChatPayReqInfo.setSub_appid(SysConst.getSysConfig().getWxSubAppId());//商户号 weChatPayReqInfo.setSub_appid(SysConst.getSysConfig().getWxSubAppId());//商户号
} }
weChatPayReqInfo.setSub_mch_id(SysConst.getSysConfig().getWxSubMchId()); //子商户号
if (order.getHighChildOrderList().get(0).getGoodsType() == 8) {
weChatPayReqInfo.setSub_mch_id(SysConst.getSysConfig().getWxGzSubMchId());//商户号
} else {
weChatPayReqInfo.setSub_mch_id(SysConst.getSysConfig().getWxSubMchId());
}
//子商户号
// weChatPayReqInfo.setOpenid(openId); // weChatPayReqInfo.setOpenid(openId);
weChatPayReqInfo.setSub_openid(openId); weChatPayReqInfo.setSub_openid(openId);

@ -11,6 +11,8 @@ wxMchId=1289663601
wxSubAppId=wx8d49e2f83025229d wxSubAppId=wx8d49e2f83025229d
wxSubMchId=1609882817 wxSubMchId=1609882817
wxUnifiedOrderUrl=https://api.mch.weixin.qq.com/pay/unifiedorder wxUnifiedOrderUrl=https://api.mch.weixin.qq.com/pay/unifiedorder
wxGzSubAppId=wxa075e8509802f826
wxGzSubMchId=1619676214
# ???????????? # ????????????
HDAppId = 1614670195 HDAppId = 1614670195

@ -11,6 +11,9 @@ wxMchId=1289663601
wxSubAppId=wx8d49e2f83025229d wxSubAppId=wx8d49e2f83025229d
wxSubMchId=1609882817 wxSubMchId=1609882817
wxUnifiedOrderUrl=https://api.mch.weixin.qq.com/pay/unifiedorder wxUnifiedOrderUrl=https://api.mch.weixin.qq.com/pay/unifiedorder
wxGzSubAppId=wxa075e8509802f826
wxGzSubMchId=1619676214
notifyUrl=https://hsg.dctpay.com/crest/wechatpay/notify notifyUrl=https://hsg.dctpay.com/crest/wechatpay/notify

@ -80,6 +80,23 @@ public class WxOrderConfig {
return XmlUtil.getObjectFromXML(resultXmL, OrderRefundModel.class); return XmlUtil.getObjectFromXML(resultXmL, OrderRefundModel.class);
} }
public static OrderRefundModel orderToRefund(String paySerialNo,BigDecimal totalFee, String subMchId , BigDecimal refundFee) throws Exception {
Map<String,String> param = new HashMap<>();
param.put("appid", "wx637bd6f7314daa46");
param.put("mch_id", "1289663601");
param.put("sub_mch_id" , subMchId);
param.put("nonce_str", WxUtils.makeNonStr());
param.put("transaction_id", paySerialNo);
param.put("out_refund_no", "HFR"+new Date().getTime());
param.put("total_fee", String.valueOf(totalFee.multiply(new BigDecimal("100")).intValue()));
param.put("refund_fee", String.valueOf(refundFee.multiply(new BigDecimal("100")).intValue()));
param.put("sign_type", "HMAC-SHA256");
String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5" , WXPayConstants.SignType.HMACSHA256);
param.put("sign", signStr);
String resultXmL = doSSLRequest(param.get("mch_id"), "https://api.mch.weixin.qq.com/secapi/pay/refund", WxUtils.mapToXml(param));
return XmlUtil.getObjectFromXML(resultXmL, OrderRefundModel.class);
}
private static String doSSLRequest(String mchId, String url, String data) throws Exception { private static String doSSLRequest(String mchId, String url, String data) throws Exception {
//双向证书的认证 //双向证书的认证

@ -38,6 +38,14 @@ public interface SecConfigService {
**/ **/
SecConfig findByCodeType(String codeType); SecConfig findByCodeType(String codeType);
/**
* @Author Sum1Dream
* @name isConfig.java
* @Description // 查询值
* @Date 3:53 下午 2022/3/14
* @Param [java.lang.String, java.lang.String]
* @return java.lang.Boolean
*/
Boolean isConfig(String codeType , String codeValue); Boolean isConfig(String codeType , String codeValue);
} }

Loading…
Cancel
Save