parent
bfc7b13cbc
commit
80fbf4ae2a
File diff suppressed because one or more lines are too long
@ -0,0 +1,25 @@ |
||||
package com.hai.service; |
||||
|
||||
import com.hai.entity.ApiOrderRecord; |
||||
|
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @serviceName ApiOrderRecordService.java |
||||
* @author Sum1Dream |
||||
* @version 1.0.0 |
||||
* @Description // 订单记录查询
|
||||
* @createTime 15:17 2022/6/10 |
||||
**/ |
||||
public interface ApiOrderRecordService { |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @name queryOrderResult.java |
||||
* @Description // 查询订单详情
|
||||
* @Date 15:18 2022/6/10 |
||||
* @Param [java.util.Map<java.lang.String,java.lang.Object>] |
||||
* @return com.hai.entity.ApiOrderRecord |
||||
*/ |
||||
ApiOrderRecord queryOrderResult(Map<String , Object> map); |
||||
} |
@ -0,0 +1,39 @@ |
||||
package com.hai.service.impl; |
||||
|
||||
import com.hai.dao.ApiOrderRecordMapper; |
||||
import com.hai.entity.ApiOrderRecord; |
||||
import com.hai.entity.ApiOrderRecordExample; |
||||
import com.hai.service.ApiOrderRecordService; |
||||
import com.itextpdf.text.pdf.qrcode.MaskUtil; |
||||
import org.apache.commons.collections4.MapUtils; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
@Service("apiOrderRecordService") |
||||
public class ApiOrderRecordServiceImpl implements ApiOrderRecordService { |
||||
|
||||
@Resource |
||||
private ApiOrderRecordMapper apiOrderRecordMapper; |
||||
|
||||
|
||||
@Override |
||||
public ApiOrderRecord queryOrderResult(Map<String, Object> map) { |
||||
|
||||
ApiOrderRecordExample example = new ApiOrderRecordExample(); |
||||
ApiOrderRecordExample.Criteria criteria = example.createCriteria(); |
||||
|
||||
criteria.andSourceOrderNoEqualTo(MapUtils.getString(map , "sourceOrderNo")); |
||||
criteria.andMchIdEqualTo(MapUtils.getString(map , "merchId")); |
||||
|
||||
List<ApiOrderRecord> list = apiOrderRecordMapper.selectByExample(example); |
||||
|
||||
if (list.size() > 0) { |
||||
return list.get(0); |
||||
} else { |
||||
return null; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,206 @@ |
||||
package com.v1.controller; |
||||
|
||||
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.utils.ResponseMsgUtil; |
||||
import com.hai.config.HuiLianTongConfig; |
||||
import com.hai.entity.HighUser; |
||||
import com.hai.model.ResponseData; |
||||
import com.hai.service.HighOpenApiService; |
||||
import com.hai.service.HighUserService; |
||||
import com.hai.service.SecConfigService; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
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.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
@Controller |
||||
@RequestMapping(value = "/gzSinopec") |
||||
@Api(value = "贵州中石化") |
||||
public class GzSinopecController { |
||||
|
||||
private static Logger log = LoggerFactory.getLogger(GzSinopecController.class); |
||||
|
||||
@Resource |
||||
private HighOpenApiService highOpenApiService; |
||||
|
||||
@Resource |
||||
private HighUserService highUserService; |
||||
|
||||
@Resource |
||||
private SecConfigService secConfigService; |
||||
|
||||
@Resource |
||||
private HuiLianTongConfig huiLianTongConfig; |
||||
|
||||
@RequestMapping(value = "/getGuizhouSinopecList", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "获取专属优惠券") |
||||
public ResponseData getUserExclusiveDiscount(@RequestParam(name = "useScope", required = false) Integer useScope, |
||||
@RequestParam(name = "phone", required = true) String phone, |
||||
@RequestParam(name = "year", required = false) String year) { |
||||
try { |
||||
|
||||
HighUser highUser = highUserService.findByPhone(phone); |
||||
|
||||
if (highUser == null || highUser.getStatus() == 0) { |
||||
log.error("getUserOrderPreList error!", "未找到用户"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "当前手机号暂无用户"); |
||||
} |
||||
|
||||
Map<String,Object> map = new HashMap<>(); |
||||
map.put("userId", highUser.getId()); |
||||
map.put("useScope", useScope); |
||||
if (year != null) { |
||||
map.put("createTimeS", year + "-01-01 00:00:00"); |
||||
map.put("createTimeE", year + "-12-31 23:59:59"); |
||||
} |
||||
|
||||
return ResponseMsgUtil.success(highOpenApiService.getUserCouponsList(map)); |
||||
|
||||
} catch (Exception 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("couNo")); |
||||
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); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,234 @@ |
||||
package com.v1.controller; |
||||
|
||||
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.utils.ResponseMsgUtil; |
||||
import com.hai.entity.ApiMerchants; |
||||
import com.hai.entity.ApiOrderRecord; |
||||
import com.hai.entity.HighUser; |
||||
import com.hai.entity.OutRechargeOrder; |
||||
import com.hai.model.ResponseData; |
||||
import com.hai.service.*; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import jdk.jfr.consumer.RecordedObject; |
||||
import org.apache.commons.collections4.MapUtils; |
||||
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.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @serviceName rechargeProductController.java |
||||
* @author Sum1Dream |
||||
* @version 1.0.0 |
||||
* @Description // 充值产品接口
|
||||
* @createTime 17:14 2022/6/9 |
||||
**/ |
||||
@Controller |
||||
@RequestMapping(value = "/rechargeProduct") |
||||
@Api(value = "充值产品接口") |
||||
public class RechargeProductController { |
||||
|
||||
private static Logger log = LoggerFactory.getLogger(GzSinopecController.class); |
||||
|
||||
@Resource |
||||
private ApiMerchantsService apiMerchantsService; |
||||
|
||||
@Resource |
||||
private SecConfigService secConfigService; |
||||
|
||||
@Resource |
||||
private OutRechargeOrderService outRechargeOrderService; |
||||
|
||||
@Resource |
||||
private ApiOrderRecordService apiOrderRecordService; |
||||
|
||||
@RequestMapping(value = "/getRechargeProduct", method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "获取充值产品") |
||||
public ResponseData getRechargeProduct(@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("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "非法ip地址,请联系管理人员!"); |
||||
} |
||||
|
||||
if (object.getString("apiKey") == null || |
||||
object.getString("merchId") == null || |
||||
object.getString("sign") == null || |
||||
object.getInteger("rechargeType") == null |
||||
) { |
||||
log.error("getRechargeProduct error!", "请求参数校验失败!"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR); |
||||
} |
||||
|
||||
ApiMerchants apiMerchants = apiMerchantsService.findById(object.getLong("merchId")); |
||||
|
||||
if (apiMerchants == null) { |
||||
log.error("getRechargeProduct error!", "商户号错误!"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "商户号错误!"); |
||||
} |
||||
|
||||
Map<String , Object> map = new HashMap<>(); |
||||
map.put("apiKey" , object.getString("apiKey")); |
||||
map.put("merchId" , object.getString("merchId")); |
||||
map.put("rechargeType" , object.getString("type")); |
||||
map.put("sign" , object.getString("sign")); |
||||
|
||||
if (!secConfigService.isSignVerify(map)) { |
||||
log.error("getRechargeProduct error!", "签名校验失败!"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY); |
||||
} |
||||
|
||||
return ResponseMsgUtil.success(apiMerchantsService.getMerchProduct(apiMerchants.getId() , object.getInteger("rechargeType"))); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighOpenApiController --> getRechargeProduct() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/checkAccountBalance", method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "查询帐户余额") |
||||
public ResponseData checkAccountBalance(@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("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "非法ip地址,请联系管理人员!"); |
||||
} |
||||
|
||||
if (object.getString("apiKey") == null || |
||||
object.getString("sign") == null || |
||||
object.getString("merchId") == null |
||||
) { |
||||
log.error("getRechargeProduct error!", "请求参数校验失败!"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR); |
||||
} |
||||
|
||||
ApiMerchants apiMerchants = apiMerchantsService.findById(object.getLong("merchId")); |
||||
|
||||
if (apiMerchants == null) { |
||||
log.error("getRechargeProduct error!", "商户号错误!"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "商户号错误!"); |
||||
} |
||||
|
||||
Map<String , Object> map = new HashMap<>(); |
||||
map.put("apiKey" , object.getString("apiKey")); |
||||
map.put("merchId" , object.getString("merchId")); |
||||
map.put("sign" , object.getString("sign")); |
||||
|
||||
if (!secConfigService.isSignVerify(map)) { |
||||
log.error("getRechargeProduct error!", "签名校验失败!"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY); |
||||
} |
||||
|
||||
return ResponseMsgUtil.success(apiMerchants.getAmounts()); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighOpenApiController --> getRechargeProduct() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/queryOrderResult", method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "查询订单结果") |
||||
public ResponseData queryOrderResult(@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("getRechargeProduct error!", "非法ip地址,请联系管理人员!"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "非法ip地址,请联系管理人员!"); |
||||
} |
||||
|
||||
if (object.getString("apiKey") == null || |
||||
object.getString("merchId") == null || |
||||
object.getString("sign") == null || |
||||
object.getString("sourceOrderNo") == null |
||||
|
||||
) { |
||||
log.error("getRechargeProduct error!", "请求参数校验失败!"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR); |
||||
} |
||||
|
||||
ApiMerchants apiMerchants = apiMerchantsService.findById(object.getLong("merchId")); |
||||
|
||||
if (apiMerchants == null) { |
||||
log.error("getRechargeProduct error!", "商户号错误!"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "商户号错误!"); |
||||
} |
||||
|
||||
Map<String , Object> map = new HashMap<>(); |
||||
map.put("apiKey" , object.getString("apiKey")); |
||||
map.put("merchId" , object.getString("merchId")); |
||||
map.put("sourceOrderNo" , object.getString("sourceOrderNo")); |
||||
map.put("sign" , object.getString("sign")); |
||||
|
||||
if (!secConfigService.isSignVerify(map)) { |
||||
log.error("getRechargeProduct error!", "签名校验失败!"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY); |
||||
} |
||||
|
||||
|
||||
ApiOrderRecord apiOrderRecord = apiOrderRecordService.queryOrderResult(map); |
||||
|
||||
OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderNo(apiOrderRecord.getOrderNo()); |
||||
|
||||
JSONObject returnObject = new JSONObject(); |
||||
returnObject.put("sourceOrderNo" , apiOrderRecord.getSourceOrderNo()); |
||||
returnObject.put("callbackStatus" , apiOrderRecord.getStatus()); |
||||
returnObject.put("goodsId" , apiOrderRecord.getGoodsId()); |
||||
returnObject.put("type" , rechargeOrder.getType()); |
||||
returnObject.put("operatorName" , rechargeOrder.getOperatorName()); |
||||
returnObject.put("rechargeType" , rechargeOrder.getRechargeType()); |
||||
returnObject.put("rechargeContent" , rechargeOrder.getRechargeContent()); |
||||
returnObject.put("rechargePrice" , rechargeOrder.getRechargePrice()); |
||||
returnObject.put("payRealPrice" , rechargeOrder.getPayRealPrice()); |
||||
returnObject.put("createTimed" , rechargeOrder.getCreateTimed()); |
||||
returnObject.put("payStatus" , rechargeOrder.getPayStatus()); |
||||
returnObject.put("rechargeStatus" , rechargeOrder.getRechargeStatus()); |
||||
|
||||
|
||||
return ResponseMsgUtil.success(returnObject); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighOpenApiController --> getRechargeProduct() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue