diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighOpenApiController.java b/hai-bweb/src/main/java/com/bweb/controller/HighOpenApiController.java index b03e50e6..36165384 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighOpenApiController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighOpenApiController.java @@ -1,27 +1,35 @@ package com.bweb.controller; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; +import com.hai.common.security.SessionObject; 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.model.ResponseData; +import com.hai.model.UserInfoModel; 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.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.net.InetAddress; import java.text.SimpleDateFormat; +import java.util.Date; import java.util.HashMap; import java.util.Map; @@ -44,7 +52,13 @@ public class HighOpenApiController { @Resource private HighUserService highUserService; - @RequestMapping(value = "/getUserExclusiveDiscount", method = RequestMethod.GET) + @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, @@ -70,7 +84,137 @@ public class HighOpenApiController { return ResponseMsgUtil.success(highOpenApiService.getUserCouponsList(map)); } 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); } } 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 47ecfa94..d973cfdc 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.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.XmlUtil; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.WxUtils; import com.hai.config.*; import com.hai.dao.HighGasOrderPushMapper; import com.hai.entity.*; import com.hai.model.*; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.ssl.SSLContexts; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; 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.net.ssl.SSLContext; import javax.servlet.http.HttpServletRequest; import java.io.FileInputStream; import java.math.BigDecimal; import java.security.KeyStore; import java.util.*; /** * @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 HltUnionCardVipService hltUnionCardVipService; @Resource private HighTestService highTestService; @Resource private OutRechargeOrderService outRechargeOrderService; @Resource private HighOrderService highOrderService; @Resource private HighUserService highUserService; @RequestMapping(value = "/getBackendToken", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取访问令牌backendToken") public ResponseData getBackendToken() { try { return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/GetMembershipLevel", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "请求会员体系") public ResponseData GetMembershipLevel(@RequestParam(name = "phone", required = true) String phone , @RequestParam(name = "regionId", required = true) String regionId ) { try { return ResponseMsgUtil.success(hltUnionCardVipService.GetMembershipLevel(phone , regionId)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/submitSms", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "请求短信") public ResponseData submitSms(@RequestParam(name = "phone", required = true) String phone , @RequestParam(name = "sms", required = true) String sms ) { try { return ResponseMsgUtil.success(HuiLianTongUnionCardConfig.submitSms(phone , sms)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @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="/getReadFile",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "存入用户信息") public ResponseData getReadFile() { try { highTestService.getReadFile(); return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("getUserByTelephone",e); return ResponseMsgUtil.exception(e); } } // @RequestMapping(value="/getUserDiscount",method = RequestMethod.GET) // @ResponseBody // @ApiOperation(value = "赠送优惠券") // public ResponseData getUserDiscount(@RequestParam(name = "id", required = true) Long id) { // try { // highTestService.getUserDiscount(id); // return ResponseMsgUtil.success(null); // } catch (Exception e) { // log.error("getUserByTelephone",e); // return ResponseMsgUtil.exception(e); // } // } @RequestMapping(value="/queryAmount",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询余额") public ResponseData queryAmount() { try { // outRechargeOrderService.queryAmount(); return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("getUserByTelephone",e); return ResponseMsgUtil.exception(e); } } // @RequestMapping(value = "/getMobile", method = RequestMethod.GET) // @ResponseBody // @ApiOperation(value = "话费充值") // public ResponseData getMobile( // @RequestParam(name = "orderNo", required = true) String orderNo, // @RequestParam(name = "amount", required = true) Integer amount, // @RequestParam(name = "isFast", required = true) Integer isFast, // @RequestParam(name = "phone", required = true) String phone) { // try { // JSONObject object = outRechargeOrderService.getMobile(phone,amount,orderNo , isFast); // return ResponseMsgUtil.success(object.getInteger("code")); // } catch (Exception e) { // log.error("HighUserCardController --> getHuiLianTongCardInfo() error!", 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, ""); } return ResponseMsgUtil.success(HuiLianTongUnionCardConfig.resolveResponse(consumptionRecord.getString("data"))); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardConsume() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/orderToRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "积分充值退款") public ResponseData orderToRefund(@RequestParam(name = "orderId", required = true) Long orderId ,HttpServletRequest request) { try { HighOrder highOrder = highOrderService.getOrderById(orderId); // 微信退款 OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund(highOrder.getPaySerialNo(), highOrder.getPayRealPrice(), highOrder.getPayRealPrice()); if(orderRefundModel.getResult_code().equals("SUCCESS")) { for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { childOrder.setChildOrdeStatus(4); } highOrder.setOrderStatus(4); highOrder.setRefundTime(new Date()); highOrder.setRefundPrice(highOrder.getPayRealPrice()); highOrderService.updateOrder(highOrder); } if (highUserService.findGoldRepeat(3 , highOrder.getId())) { highUserService.goldHandle(highOrder.getMemId(), highOrder.getPayRealPrice().multiply(BigDecimal.valueOf(100)).intValue(), 1, 3, highOrder.getId()); }else { log.error("orderToPay error!", "已有退款记录"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已有退款记录"); } return ResponseMsgUtil.success(orderRefundModel); } catch (Exception e) { log.error("HighOrderController --> orderToRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/orderToRefundWx", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "微信退款") public ResponseData orderToRefundWx(@RequestParam(name = "orderId", required = true) Long orderId ,HttpServletRequest request) { try { OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId); // 微信退款 OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund(order.getPaySerialNo(), order.getPayRealPrice(), order.getPayRealPrice()); if(orderRefundModel.getResult_code().equals("SUCCESS")) { order.setStatus(5); order.setRefundTime(new Date()); order.setRefundFee(order.getPayRealPrice()); outRechargeOrderService.updateOrder(order); } return ResponseMsgUtil.success(orderRefundModel); } catch (Exception e) { log.error("HighOrderController --> orderToRefund() error!", e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file +package com.bweb.controller; import com.alibaba.fastjson.JSONArray; 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.pay.util.XmlUtil; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.WxUtils; import com.hai.config.*; import com.hai.dao.HighGasOrderPushMapper; import com.hai.entity.*; import com.hai.model.*; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.ssl.SSLContexts; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; 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.net.ssl.SSLContext; import javax.servlet.http.HttpServletRequest; import java.io.FileInputStream; import java.math.BigDecimal; import java.security.KeyStore; import java.util.*; /** * @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 HltUnionCardVipService hltUnionCardVipService; @Resource private HighTestService highTestService; @Resource private OutRechargeOrderService outRechargeOrderService; @Resource private HighOrderService highOrderService; @Resource private HighUserService highUserService; @RequestMapping(value = "/getBackendToken", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取访问令牌backendToken") public ResponseData getBackendToken() { try { return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/GetMembershipLevel", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "请求会员体系") public ResponseData GetMembershipLevel(@RequestParam(name = "phone", required = true) String phone , @RequestParam(name = "regionId", required = true) String regionId ) { try { return ResponseMsgUtil.success(hltUnionCardVipService.GetMembershipLevel(phone , regionId)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/submitSms", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "请求短信") public ResponseData submitSms(@RequestParam(name = "phone", required = true) String phone , @RequestParam(name = "sms", required = true) String sms ) { try { return ResponseMsgUtil.success(HuiLianTongUnionCardConfig.submitSms(phone , sms)); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @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="/getReadFile",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "存入用户信息") public ResponseData getReadFile() { try { highTestService.getReadFile(); return ResponseMsgUtil.success(null); } catch (Exception e) { log.error("getUserByTelephone",e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value="/queryAmount",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询余额") public ResponseData queryAmount() { try { // outRechargeOrderService.queryAmount(); return ResponseMsgUtil.success(null); } 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, ""); } return ResponseMsgUtil.success(HuiLianTongUnionCardConfig.resolveResponse(consumptionRecord.getString("data"))); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardConsume() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/orderToRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "积分充值退款") public ResponseData orderToRefund(@RequestParam(name = "orderId", required = true) Long orderId ,HttpServletRequest request) { try { HighOrder highOrder = highOrderService.getOrderById(orderId); // 微信退款 OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund(highOrder.getPaySerialNo(), highOrder.getPayRealPrice(), highOrder.getPayRealPrice()); if(orderRefundModel.getResult_code().equals("SUCCESS")) { for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { childOrder.setChildOrdeStatus(4); } highOrder.setOrderStatus(4); highOrder.setRefundTime(new Date()); highOrder.setRefundPrice(highOrder.getPayRealPrice()); highOrderService.updateOrder(highOrder); } if (highUserService.findGoldRepeat(3 , highOrder.getId())) { highUserService.goldHandle(highOrder.getMemId(), highOrder.getPayRealPrice().multiply(BigDecimal.valueOf(100)).intValue(), 1, 3, highOrder.getId()); }else { log.error("orderToPay error!", "已有退款记录"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已有退款记录"); } return ResponseMsgUtil.success(orderRefundModel); } catch (Exception e) { log.error("HighOrderController --> orderToRefund() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/zwrefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "银联退款") public ResponseData zwrefund( @RequestParam(name = "orderId", required = true) Long orderId , @RequestParam(name = "MER_ID", required = true) String MER_ID , @RequestParam(name = "TERM_ID", required = true) String TERM_ID , HttpServletRequest request) { try { OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId); // 订单退款 JSONObject refund = UnionPayConfig.zwrefund(MER_ID, TERM_ID, order.getOrderNo(), order.getPaySerialNo(), order.getPayRealPrice().multiply(new BigDecimal("100")).longValue()); if (!refund.getString("resultcode").equals("W6")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, refund.getString("returnmsg")); } order.setStatus(5); order.setRefundTime(new Date()); order.setOutRefundNo(refund.getString("oriwtorderid")); order.setRefundFee(order.getPayRealPrice()); outRechargeOrderService.updateOrder(order); return ResponseMsgUtil.success(refund); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/rechargeOrderToRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "话费退款") public ResponseData rechargeOrderToRefund( @RequestParam(name = "orderId", required = true) Long orderId) { try { outRechargeOrderService.rechargeOrderToRefund(orderId); return ResponseMsgUtil.success("退款成功"); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } } \ No newline at end of file diff --git a/hai-bweb/src/main/java/com/bweb/controller/OutRechargeOrderController.java b/hai-bweb/src/main/java/com/bweb/controller/OutRechargeOrderController.java index e9277341..625c8bc5 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/OutRechargeOrderController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/OutRechargeOrderController.java @@ -608,8 +608,6 @@ public class OutRechargeOrderController { OutRechargeOrder order = outRechargeOrderService.findByOrderId(rechargeOrderRecord.getRechargeOrderId()); if (order.getStatus() == 2) { outRechargeOrderService.rechargeOrderToRefund(order.getId()); - order.setStatus(5); - outRechargeOrderService.updateOrder(order); } } diff --git a/hai-cweb/src/main/java/com/cweb/config/SysConfig.java b/hai-cweb/src/main/java/com/cweb/config/SysConfig.java index b8ba35f1..3106e7d4 100644 --- a/hai-cweb/src/main/java/com/cweb/config/SysConfig.java +++ b/hai-cweb/src/main/java/com/cweb/config/SysConfig.java @@ -27,6 +27,9 @@ public class SysConfig { private String notifyUrl; private String qzNotifyUrl; + private String wxGzSubAppId; + private String wxGzSubMchId; + // 重庆惠兑电子商务有限公司 private String HDAppId; @@ -149,4 +152,20 @@ public class SysConfig { public void setHDAppId(String 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; + } } diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighCouponAgentController.java b/hai-cweb/src/main/java/com/cweb/controller/HighCouponAgentController.java index f627d928..97c4203a 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighCouponAgentController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighCouponAgentController.java @@ -74,7 +74,8 @@ public class HighCouponAgentController { if (convertCode.getCouponCodeId() != null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "兑换码已被使用"); } - return ResponseMsgUtil.success(highCouponAgentService.useConvertCode(body.getString("code"))); + + return ResponseMsgUtil.success(highCouponAgentService.useConvertCode(body.getString("phone"), body.getString("code"))); } catch (DeadlockLoserDataAccessException deadlockLoserDataAccessException) { log.error("HighActivityController -> userLottery() error!", "服务器繁忙"); diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java b/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java index 1d8f3a8d..c2139d4a 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java @@ -228,17 +228,19 @@ public class HighOrderController { childOrder.setGoodsImg(store.getStoreLogo()); // 平台的价格 + // childOrder.setGasPriceGun(priceDetail.getBigDecimal("priceGun")); + // childOrder.setGasPriceVip(priceDetail.getBigDecimal("priceVip")); childOrder.setExt1(childOrder.getGasPriceVip().toString()); childOrder.setGoodsActualPrice(new BigDecimal(childOrder.getGoodsPrice().toString()).divide(childOrder.getGasPriceGun(),10,BigDecimal.ROUND_DOWN).multiply(childOrder.getGasPriceVip()).setScale(2,BigDecimal.ROUND_HALF_UP)); // 团油的价格 - childOrder.setGasPriceGun(priceDetail.getBigDecimal("priceGun")); - childOrder.setGasPriceVip(priceDetail.getBigDecimal("priceVip")); - childOrder.setGoodsPrice(new BigDecimal(childOrder.getGoodsPrice().toString()).divide(childOrder.getGasPriceGun(),10,BigDecimal.ROUND_DOWN).multiply(childOrder.getGasPriceVip()).setScale(2,BigDecimal.ROUND_HALF_UP)); + // childOrder.setGasPriceGun(priceDetail.getBigDecimal("priceGun")); + // childOrder.setGasPriceVip(priceDetail.getBigDecimal("priceVip")); + // childOrder.setGoodsPrice(new BigDecimal(childOrder.getGoodsPrice().toString()).divide(childOrder.getGasPriceGun(),10,BigDecimal.ROUND_DOWN).multiply(childOrder.getGasPriceVip()).setScale(2,BigDecimal.ROUND_HALF_UP)); childOrder.setGoodsSpecName("默认"); - childOrder.setTotalPrice(childOrder.getGoodsPrice().multiply(new BigDecimal(childOrder.getSaleCount().toString()))); - // childOrder.setTotalPrice(childOrder.getGoodsActualPrice().multiply(new BigDecimal(childOrder.getSaleCount().toString()))); + // childOrder.setTotalPrice(childOrder.getGoodsPrice().multiply(new BigDecimal(childOrder.getSaleCount().toString()))); + childOrder.setTotalPrice(childOrder.getGoodsPrice()); } if (childOrder.getGoodsType() == 7) { @@ -270,7 +272,6 @@ public class HighOrderController { childOrder.setGoodsActualPrice(discountPackage.getPrice()); childOrder.setGoodsSpecName("默认"); } - // 汇联通充值 if (childOrder.getGoodsType() == 8) { if (childOrder.getGoodsPrice() == null) { @@ -397,6 +398,11 @@ public class HighOrderController { } } + public static void main(String[] args) { + System.out.println(new BigDecimal("10").divide(new BigDecimal("7.20"),10,BigDecimal.ROUND_DOWN) + .multiply(new BigDecimal("6.75")).setScale(2,BigDecimal.ROUND_HALF_UP)); + } + @RequestMapping(value = "/getOrderById", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据id查询订单详情") diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java b/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java index 29685856..95a05e9d 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighTestController.java @@ -1 +1,5 @@ -package com.cweb.controller; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.cweb.config.SysConst; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.XmlUtil; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.security.SessionObject; import com.hai.common.utils.*; import com.hai.config.*; import com.hai.dao.HighGasOrderPushMapper; import com.hai.entity.*; import com.hai.model.*; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.ssl.SSLContexts; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Controller; import org.springframework.util.IdGenerator; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.net.ssl.SSLContext; import javax.servlet.http.HttpServletRequest; import java.io.FileInputStream; import java.math.BigDecimal; import java.security.KeyStore; import java.util.*; /** * @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 HighMerchantService highMerchantService; @Resource private HighMerchantStoreService highMerchantStoreService; @Resource private HighGasOilPriceService highGasOilPriceService; @Resource private HighOrderService highOrderService; @Resource private HighProfitSharingRecordService highProfitSharingRecordService; @Resource private HighGasOrderPushMapper highGasOrderPushMapper; @Resource private HuiLianTongConfig huiLianTongConfig; @Resource private UnionPayConfig unionPayConfig; @Resource private UnionStagingPayConfig unionStagingPayConfig; @Resource private UnionUserConfig unionUserConfig; @Resource private OutRechargeOrderService outRechargeOrderService; @RequestMapping(value = "/getHuiLianTongCardInfo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询汇联通工会卡详情") public ResponseData getHuiLianTongCardInfo(@RequestParam(name = "cardNo", required = true) String cardNo, HttpServletRequest request) { try { // 用户 // JSONObject cardInfo = HuiLianTongUnionCardConfig.queryCardInfo(cardNo); if (StringUtils.isBlank(cardInfo.getString("data"))) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQUEST_ERROR, ""); } return ResponseMsgUtil.success(HuiLianTongUnionCardConfig.resolveResponse(cardInfo.getString("data"))); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardInfo() error!", e); return ResponseMsgUtil.exception(e); } } // // @RequestMapping(value = "/getMobile", method = RequestMethod.GET) // @ResponseBody // @ApiOperation(value = "话费充值") // public ResponseData getMobile( // @RequestParam(name = "orderNo", required = true) String orderNo, // @RequestParam(name = "amount", required = true) Integer amount, // @RequestParam(name = "phone", required = true) String phone, // HttpServletRequest request) { // try { // return ResponseMsgUtil.success(outRechargeOrderService.getMobile(phone,amount,orderNo)); // // } catch (Exception e) { // log.error("HighUserCardController --> getHuiLianTongCardInfo() error!", e); // return ResponseMsgUtil.exception(e); // } // } @RequestMapping(value = "/initTYMerchantStore", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "初始化加油站") public ResponseData initTYMerchantStore(@RequestParam(name = "merchantId", required = true) Long merchantId) throws Exception { HighMerchantModel merchant = highMerchantService.getMerchantById(merchantId); if (merchant == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到商户"); } JSONObject jsonObjectP = TuanYouConfig.queryGasInfoListByPage(1, 1000); JSONObject resultObjectP = jsonObjectP.getObject("result", JSONObject.class); for (int i = 1; i <= resultObjectP.getInteger("totalPageNum").intValue();i++) { JSONObject jsonObject = TuanYouConfig.queryGasInfoListByPage(i, 1000); JSONObject resultObject = jsonObject.getObject("result", JSONObject.class); JSONArray jsonArray = resultObject.getJSONArray("gasInfoList"); HighMerchantStore highMerchantStore; HighGasOilPrice highGasOilPrice; for (Object gasObject : jsonArray) { JSONObject object = JSONObject.parseObject(JSONObject.toJSONString(gasObject)); HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreByKey(object.getString("gasId")); if (store != null) { store.setType(1); store.setMerchantId(merchant.getId()); store.setCompanyId(merchant.getCompanyId()); store.setStoreKey(object.getString("gasId")); store.setStoreName(object.getString("gasName")); store.setStoreLogo(object.getString("gasLogoSmall")); store.setRegionId(object.getLong("provinceCode")); store.setRegionName(object.getString("provinceName")); store.setAddress(object.getString("gasAddress")); store.setLongitude(object.getString("gasAddressLongitude")); store.setLatitude(object.getString("gasAddressLatitude")); store.setStatus(object.getInteger("gasStatus")); store.setOperatorId(0L); store.setOperatorName("系统创建"); store.setUpdateTime(new Date()); store.setExt1(object.getString("gasSourceId")); highMerchantStoreService.updateMerchantStoreDetail(store); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); // 查询门店油号 highGasOilPrice = highGasOilPriceService.getGasOilPriceByStoreAndOilNo(store.getId(), oilPriceObject.getInteger("oilNo")); if (highGasOilPrice == null) { highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); } else { highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); } highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } else { highMerchantStore = new HighMerchantStore(); highMerchantStore.setType(1); highMerchantStore.setMerchantId(merchant.getId()); highMerchantStore.setCompanyId(merchant.getCompanyId()); highMerchantStore.setStoreKey(object.getString("gasId")); highMerchantStore.setStoreName(object.getString("gasName")); highMerchantStore.setStoreLogo(object.getString("gasLogoSmall")); highMerchantStore.setRegionId(object.getLong("provinceCode")); highMerchantStore.setRegionName(object.getString("provinceName")); highMerchantStore.setAddress(object.getString("gasAddress")); highMerchantStore.setLongitude(object.getString("gasAddressLongitude")); highMerchantStore.setLatitude(object.getString("gasAddressLatitude")); highMerchantStore.setStatus(1); highMerchantStore.setOperatorId(0L); highMerchantStore.setOperatorName("系统创建"); highMerchantStore.setCreateTime(new Date()); highMerchantStore.setUpdateTime(new Date()); highMerchantStore.setExt1(object.getString("gasSourceId")); HighMerchantStoreModel merchantStoreModel = new HighMerchantStoreModel(); BeanUtils.copyProperties(highMerchantStore, merchantStoreModel); highMerchantStoreService.insertMerchantStore(merchantStoreModel); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(merchantStoreModel.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } } } return ResponseMsgUtil.success("初始化完成"); } @RequestMapping(value = "/pushTuanYouOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "推送团油订单") public ResponseData pushTuanYouOrder() { try { HighOrder order = highOrderService.getOrderByOrderNo("HF2021102112141171406"); for (HighChildOrder highChildOrder : order.getHighChildOrderList()) { HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreById(highChildOrder.getGoodsId()); // 推送团油订单 Map paramMap = new HashMap<>(); paramMap.put("gasId", store.getStoreKey()); paramMap.put("oilNo", highChildOrder.getGasOilNo()); paramMap.put("gunNo", highChildOrder.getGasGunNo()); BigDecimal priceGun = highChildOrder.getGasPriceGun(); BigDecimal priceVip = highChildOrder.getGasPriceVip(); paramMap.put("priceGun", priceGun); // 枪单价 paramMap.put("priceVip", priceVip); // 优惠价 paramMap.put("driverPhone", order.getMemPhone()); // paramMap.put("driverPhone", "17726395120"); paramMap.put("thirdSerialNo", order.getOrderNo()); paramMap.put("refuelingAmount", highChildOrder.getTotalPrice()); // 油品类型 1:汽油:2:柴油;3:天然气 if (highChildOrder.getGasOilType() == 1) { paramMap.put("accountNo", CommonSysConst.getSysConfig().getTuanYouGasolineAccount()); } else if (highChildOrder.getGasOilType() == 2) { paramMap.put("accountNo", CommonSysConst.getSysConfig().getTuanYouDieselAccount()); } JSONObject orderPushObject = TuanYouConfig.refuelingOrderPush(paramMap); // 推送团油订单记录 HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); highGasOrderPush.setCreateTime(new Date()); highGasOrderPush.setCode(orderPushObject.getString("code")); highGasOrderPush.setRequestContent(JSONObject.toJSONString(paramMap)); highGasOrderPush.setReturnContent(orderPushObject.toJSONString()); highGasOrderPushMapper.insert(highGasOrderPush); if (orderPushObject != null && orderPushObject.getString("code").equals("200")) { highChildOrder.setGasOrderNo(orderPushObject.getJSONObject("result").getString("orderNo")); } highOrderService.updateOrder(order); } return ResponseMsgUtil.success(order); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryCompanyAccountInfo2JD", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询团油余额") public ResponseData queryCompanyAccountInfo2JD() { try { return ResponseMsgUtil.success(TuanYouConfig.queryCompanyAccountInfo2JD()); } catch (Exception e) { log.error("HighOrderController --> queryCompanyAccountInfo2JD() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryCompanyPriceDetail", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询团油余额") public ResponseData queryCompanyPriceDetail() { try { return ResponseMsgUtil.success(TuanYouConfig.queryCompanyPriceDetail("LW000115995", "92")); } catch (Exception e) { log.error("HighOrderController --> queryCompanyAccountInfo2JD() error!", e); return ResponseMsgUtil.exception(e); } } /*@RequestMapping(value = "/couJointDist", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "派发贵州卡券") public ResponseData couJointDist(@RequestParam(name = "token", required = true) String token) { try { return ResponseMsgUtil.success(HuiLianTongConfig.couJointDist(token,"HF2022022116504244204","20JY000575",1,"15286590001", "oArhO6cA1UVgvFHwEfJ_k0hd6MWM")); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } }*/ @RequestMapping(value = "/unionPay", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "银联支付") public ResponseData unionPay(HttpServletRequest request) { try { // return ResponseMsgUtil.success(RequestUtils.getIpAddress(request)); return ResponseMsgUtil.success(unionPayConfig.upPreOrder(UnionPayConfig.MER_ID3, UnionPayConfig.TERM_ID3, "HF"+System.currentTimeMillis(), new BigDecimal("1"), "test",CommonSysConst.getSysConfig().getUnionPayNotifyUrl(), request)); } catch (Exception e) { log.error("HighOrderController --> unionPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getToken", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取贵州中石化token") public ResponseData getToken() { try { return ResponseMsgUtil.success(huiLianTongConfig.getToken()); } catch (Exception e) { log.error("HighOrderController --> getToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/unionTradeQuery", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "银联交易查询") public ResponseData unionTradeQuery(@RequestParam(name = "paySerialNo", required = true) String paySerialNo) { try { return ResponseMsgUtil.success(UnionPayConfig.tradeQuery(UnionPayConfig.MER_ID1, UnionPayConfig.TERM_ID1, paySerialNo)); } catch (Exception e) { log.error("HighOrderController --> unionTradeQuery() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getBackendToken", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取访问令牌backendToken") public ResponseData getBackendToken() { try { return ResponseMsgUtil.success(unionUserConfig.getBackendToken()); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/wxSplitAccount", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "微信分账") public ResponseData wxSplitAccount() { try { HighOrder orderNo = highOrderService.getOrderByOrderNo("HF2021101812025050304"); wxProfitsharing(orderNo.getOrderNo(),orderNo.getPaySerialNo(),orderNo.getPayRealPrice()); return ResponseMsgUtil.success("分账成功"); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/unionStagingPay", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "银联分期支付") public ResponseData unionStagingPay(HttpServletRequest request) { try { /* String orderNo = DateUtil.format(new Date(), DateUtil.YMDHMS); orderNo += IDGenerator.nextId(28 - orderNo.length());*/ String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0,4) +CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4,CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) +DateUtil.format(new Date(), DateUtil.YMDHMS) +IDGenerator.nextId(6); return ResponseMsgUtil.success(unionStagingPayConfig.advancePay( orgTrace, orgTrace, new BigDecimal("1"), CommonSysConst.getSysConfig().getUnionStagingPayNotifyUrl(), request)); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryStaging", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "分期查询") public ResponseData queryStaging(@RequestParam(name = "oriOrgTrace", required = true) String oriOrgTrace,HttpServletRequest request) { try { String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0,4) +CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4,CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) +DateUtil.format(new Date(), DateUtil.YMDHMS) +IDGenerator.nextId(6); return ResponseMsgUtil.success(UnionStagingPayConfig.queryStaging(orgTrace,oriOrgTrace ,"", new Date(), request)); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } /* @RequestMapping(value = "/orderToRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "退款") public ResponseData orderToRefund(HttpServletRequest request) { try { OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund("4200001301202202035413938093", new BigDecimal("30.80"), new BigDecimal("16.90")); return ResponseMsgUtil.success(orderRefundModel); } catch (Exception e) { log.error("HighOrderController --> orderToRefund() error!", e); return ResponseMsgUtil.exception(e); } }*/ @RequestMapping(value = "/query", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "订单查询") public ResponseData query(@RequestParam(name = "oriOrgTrace", required = true) String oriOrgTrace,HttpServletRequest request) { try { String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0,4) +CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4,CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) +DateUtil.format(new Date(), DateUtil.YMDHMS) +IDGenerator.nextId(6); return ResponseMsgUtil.success(UnionStagingPayConfig.query(orgTrace,oriOrgTrace ,"", new Date(), request)); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/mposrefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "分期退款") public ResponseData mposrefund(@RequestParam(name = "oriOrgTrace", required = true) String oriOrgTrace,HttpServletRequest request) { try { String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0,4) +CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4,CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) +DateUtil.format(new Date(), DateUtil.YMDHMS) +IDGenerator.nextId(6); return ResponseMsgUtil.success(UnionStagingPayConfig.standardRefund(orgTrace,oriOrgTrace ,new BigDecimal("1"), "", new Date(), request)); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/mposfindrefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "分期退款查询") public ResponseData mposfindrefund(@RequestParam(name = "oriOrgTrace", required = true) String oriOrgTrace,HttpServletRequest request) { try { String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0,4) +CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4,CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) +DateUtil.format(new Date(), DateUtil.YMDHMS) +IDGenerator.nextId(6); return ResponseMsgUtil.success(UnionStagingPayConfig.mposfindrefund(orgTrace,oriOrgTrace ,"", new Date(), request)); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } public void wxProfitsharing(String transaction_id,String out_order_no, BigDecimal amount) { try { Map param = new LinkedHashMap<>(); param.put("appid", "wx637bd6f7314daa46"); param.put("mch_id", "1289663601"); param.put("sub_mch_id" , "1609882817"); // 个体户黎杨珍 param.put("transaction_id" , transaction_id); param.put("out_order_no" , out_order_no); param.put("nonce_str" , WxUtils.makeNonStr()); // 分账金额 BigDecimal porofitSharingAmount = amount; List> receiversList = new ArrayList<>(); Map receiversMap = new LinkedHashMap<>(); receiversMap.put("type", "MERCHANT_ID"); receiversMap.put("account", "1603942866"); receiversMap.put("amount", porofitSharingAmount.multiply(new BigDecimal("100")).intValue()); receiversMap.put("description", "分给商户【惠昕石化】"); receiversList.add(receiversMap); param.put("receivers" , JSONObject.toJSONString(receiversList)); String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5" , WXPayConstants.SignType.HMACSHA256); param.put("sign" , signStr); String resultXmL = this.doRefundRequest(param.get("mch_id"),null, WxUtils.mapToXml(param)); // 请求分账返回的结果 ResultProfitSharing resultProfitSharing = XmlUtil.getObjectFromXML(resultXmL, ResultProfitSharing.class); if (!resultProfitSharing.getResult_code().equals("FAIL")) { HighProfitSharingRecord sharingRecord = new HighProfitSharingRecord(); sharingRecord.setOutOrderNo(resultProfitSharing.getOut_order_no()); sharingRecord.setTransactionId(resultProfitSharing.getTransaction_id()); sharingRecord.setOrderId(resultProfitSharing.getOrder_id()); sharingRecord.setStatus(resultProfitSharing.getResult_code()); sharingRecord.setPrice(amount); sharingRecord.setCreateTime(new Date()); sharingRecord.setContent(resultXmL); highProfitSharingRecordService.insert(sharingRecord); } } catch (Exception e) { log.error("CmsContentController --> getCorporateAdvertising() error!", e); } } public CloseableHttpClient readCertificate(String mchId) throws Exception{ /** * 注意PKCS12证书 是从微信商户平台-》账户设置-》 API安全 中下载的 */ KeyStore keyStore = KeyStore.getInstance("PKCS12"); //P12文件目录 证书路径,这里需要你自己修改,linux下还是windows下的根路径 FileInputStream instream = new FileInputStream("/home/project/wx_cert/1289663601_apiclient_cert.p12"); // FileInputStream instream = new FileInputStream("G:\\hurui-project/hai-parent/hai-service/src/main/java/privatekey/1289663601_apiclient_cert.p12"); try { keyStore.load(instream, "1289663601".toCharArray());//这里写密码..默认是你的MCHID } finally { instream.close(); } SSLContext sslcontext = SSLContexts.custom().loadKeyMaterial(keyStore, "1289663601".toCharArray()).build();//这里也是写密码的 SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext, SSLConnectionSocketFactory.getDefaultHostnameVerifier()); // Allow TLSv1 protocol only return HttpClients.custom().setSSLSocketFactory(sslsf).build(); } public String doRefundRequest(String mchId, String url, String data) throws Exception { //小程序退款需要调用双向证书的认证 CloseableHttpClient httpClient = readCertificate(mchId); try { HttpPost httpost = new HttpPost("https://api.mch.weixin.qq.com/secapi/pay/refund"); // 设置响应头信息 httpost.addHeader("Connection", "keep-alive"); httpost.addHeader("Accept", "*/*"); httpost.addHeader("Content-Type", "text/xml"); httpost.addHeader("Host", "api.mch.weixin.qq.com"); httpost.addHeader("X-Requested-With", "XMLHttpRequest"); httpost.addHeader("Cache-Control", "max-age=0"); httpost.addHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) "); httpost.setEntity(new StringEntity(data, "UTF-8")); CloseableHttpResponse response = httpClient.execute(httpost); try { HttpEntity entity = response.getEntity(); String jsonStr = EntityUtils.toString(response.getEntity(), "UTF-8"); EntityUtils.consume(entity); return jsonStr; } finally { response.close(); } } catch (Exception e){ throw new RuntimeException(e); } finally { httpClient.close(); } } } \ No newline at end of file +<<<<<<< HEAD +package com.cweb.controller; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.cweb.config.SysConst; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.XmlUtil; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.security.SessionObject; import com.hai.common.utils.*; import com.hai.config.*; import com.hai.dao.HighGasOrderPushMapper; import com.hai.entity.*; import com.hai.model.*; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.ssl.SSLContexts; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Controller; import org.springframework.util.IdGenerator; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.net.ssl.SSLContext; import javax.servlet.http.HttpServletRequest; import java.io.FileInputStream; import java.math.BigDecimal; import java.security.KeyStore; import java.util.*; /** * @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 HighMerchantService highMerchantService; @Resource private HighMerchantStoreService highMerchantStoreService; @Resource private HighGasOilPriceService highGasOilPriceService; @Resource private HighOrderService highOrderService; @Resource private HighProfitSharingRecordService highProfitSharingRecordService; @Resource private HighGasOrderPushMapper highGasOrderPushMapper; @Resource private HuiLianTongConfig huiLianTongConfig; @Resource private UnionPayConfig unionPayConfig; @Resource private UnionStagingPayConfig unionStagingPayConfig; @Resource private UnionUserConfig unionUserConfig; @Resource private OutRechargeOrderService outRechargeOrderService; @RequestMapping(value = "/getHuiLianTongCardInfo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询汇联通工会卡详情") public ResponseData getHuiLianTongCardInfo(@RequestParam(name = "cardNo", required = true) String cardNo, HttpServletRequest request) { try { // 用户 // JSONObject cardInfo = HuiLianTongUnionCardConfig.queryCardInfo(cardNo); if (StringUtils.isBlank(cardInfo.getString("data"))) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQUEST_ERROR, ""); } return ResponseMsgUtil.success(HuiLianTongUnionCardConfig.resolveResponse(cardInfo.getString("data"))); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardInfo() error!", e); return ResponseMsgUtil.exception(e); } } // // @RequestMapping(value = "/getMobile", method = RequestMethod.GET) // @ResponseBody // @ApiOperation(value = "话费充值") // public ResponseData getMobile( // @RequestParam(name = "orderNo", required = true) String orderNo, // @RequestParam(name = "amount", required = true) Integer amount, // @RequestParam(name = "phone", required = true) String phone, // HttpServletRequest request) { // try { // return ResponseMsgUtil.success(outRechargeOrderService.getMobile(phone,amount,orderNo)); // // } catch (Exception e) { // log.error("HighUserCardController --> getHuiLianTongCardInfo() error!", e); // return ResponseMsgUtil.exception(e); // } // } @RequestMapping(value = "/initTYMerchantStore", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "初始化加油站") public ResponseData initTYMerchantStore(@RequestParam(name = "merchantId", required = true) Long merchantId) throws Exception { HighMerchantModel merchant = highMerchantService.getMerchantById(merchantId); if (merchant == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到商户"); } JSONObject jsonObjectP = TuanYouConfig.queryGasInfoListByPage(1, 1000); JSONObject resultObjectP = jsonObjectP.getObject("result", JSONObject.class); for (int i = 1; i <= resultObjectP.getInteger("totalPageNum").intValue();i++) { JSONObject jsonObject = TuanYouConfig.queryGasInfoListByPage(i, 1000); JSONObject resultObject = jsonObject.getObject("result", JSONObject.class); JSONArray jsonArray = resultObject.getJSONArray("gasInfoList"); HighMerchantStore highMerchantStore; HighGasOilPrice highGasOilPrice; for (Object gasObject : jsonArray) { JSONObject object = JSONObject.parseObject(JSONObject.toJSONString(gasObject)); HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreByKey(object.getString("gasId")); if (store != null) { store.setType(1); store.setMerchantId(merchant.getId()); store.setCompanyId(merchant.getCompanyId()); store.setStoreKey(object.getString("gasId")); store.setStoreName(object.getString("gasName")); store.setStoreLogo(object.getString("gasLogoSmall")); store.setRegionId(object.getLong("provinceCode")); store.setRegionName(object.getString("provinceName")); store.setAddress(object.getString("gasAddress")); store.setLongitude(object.getString("gasAddressLongitude")); store.setLatitude(object.getString("gasAddressLatitude")); store.setStatus(object.getInteger("gasStatus")); store.setOperatorId(0L); store.setOperatorName("系统创建"); store.setUpdateTime(new Date()); store.setExt1(object.getString("gasSourceId")); highMerchantStoreService.updateMerchantStoreDetail(store); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); // 查询门店油号 highGasOilPrice = highGasOilPriceService.getGasOilPriceByStoreAndOilNo(store.getId(), oilPriceObject.getInteger("oilNo")); if (highGasOilPrice == null) { highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); } else { highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); } highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } else { highMerchantStore = new HighMerchantStore(); highMerchantStore.setType(1); highMerchantStore.setMerchantId(merchant.getId()); highMerchantStore.setCompanyId(merchant.getCompanyId()); highMerchantStore.setStoreKey(object.getString("gasId")); highMerchantStore.setStoreName(object.getString("gasName")); highMerchantStore.setStoreLogo(object.getString("gasLogoSmall")); highMerchantStore.setRegionId(object.getLong("provinceCode")); highMerchantStore.setRegionName(object.getString("provinceName")); highMerchantStore.setAddress(object.getString("gasAddress")); highMerchantStore.setLongitude(object.getString("gasAddressLongitude")); highMerchantStore.setLatitude(object.getString("gasAddressLatitude")); highMerchantStore.setStatus(1); highMerchantStore.setOperatorId(0L); highMerchantStore.setOperatorName("系统创建"); highMerchantStore.setCreateTime(new Date()); highMerchantStore.setUpdateTime(new Date()); highMerchantStore.setExt1(object.getString("gasSourceId")); HighMerchantStoreModel merchantStoreModel = new HighMerchantStoreModel(); BeanUtils.copyProperties(highMerchantStore, merchantStoreModel); highMerchantStoreService.insertMerchantStore(merchantStoreModel); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(merchantStoreModel.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } } } return ResponseMsgUtil.success("初始化完成"); } @RequestMapping(value = "/pushTuanYouOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "推送团油订单") public ResponseData pushTuanYouOrder() { try { HighOrder order = highOrderService.getOrderByOrderNo("HF2021102112141171406"); for (HighChildOrder highChildOrder : order.getHighChildOrderList()) { HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreById(highChildOrder.getGoodsId()); // 推送团油订单 Map paramMap = new HashMap<>(); paramMap.put("gasId", store.getStoreKey()); paramMap.put("oilNo", highChildOrder.getGasOilNo()); paramMap.put("gunNo", highChildOrder.getGasGunNo()); BigDecimal priceGun = highChildOrder.getGasPriceGun(); BigDecimal priceVip = highChildOrder.getGasPriceVip(); paramMap.put("priceGun", priceGun); // 枪单价 paramMap.put("priceVip", priceVip); // 优惠价 paramMap.put("driverPhone", order.getMemPhone()); // paramMap.put("driverPhone", "17726395120"); paramMap.put("thirdSerialNo", order.getOrderNo()); paramMap.put("refuelingAmount", highChildOrder.getTotalPrice()); // 油品类型 1:汽油:2:柴油;3:天然气 if (highChildOrder.getGasOilType() == 1) { paramMap.put("accountNo", CommonSysConst.getSysConfig().getTuanYouGasolineAccount()); } else if (highChildOrder.getGasOilType() == 2) { paramMap.put("accountNo", CommonSysConst.getSysConfig().getTuanYouDieselAccount()); } JSONObject orderPushObject = TuanYouConfig.refuelingOrderPush(paramMap); // 推送团油订单记录 HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); highGasOrderPush.setCreateTime(new Date()); highGasOrderPush.setCode(orderPushObject.getString("code")); highGasOrderPush.setRequestContent(JSONObject.toJSONString(paramMap)); highGasOrderPush.setReturnContent(orderPushObject.toJSONString()); highGasOrderPushMapper.insert(highGasOrderPush); if (orderPushObject != null && orderPushObject.getString("code").equals("200")) { highChildOrder.setGasOrderNo(orderPushObject.getJSONObject("result").getString("orderNo")); } highOrderService.updateOrder(order); } return ResponseMsgUtil.success(order); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryCompanyAccountInfo2JD", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询团油余额") public ResponseData queryCompanyAccountInfo2JD() { try { return ResponseMsgUtil.success(TuanYouConfig.queryCompanyAccountInfo2JD()); } catch (Exception e) { log.error("HighOrderController --> queryCompanyAccountInfo2JD() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryCompanyPriceDetail", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询团油余额") public ResponseData queryCompanyPriceDetail() { try { return ResponseMsgUtil.success(TuanYouConfig.queryCompanyPriceDetail("LW000115995", "92")); } catch (Exception e) { log.error("HighOrderController --> queryCompanyAccountInfo2JD() error!", e); return ResponseMsgUtil.exception(e); } } /*@RequestMapping(value = "/couJointDist", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "派发贵州卡券") public ResponseData couJointDist(@RequestParam(name = "token", required = true) String token) { try { return ResponseMsgUtil.success(HuiLianTongConfig.couJointDist(token,"HF2022022116504244204","20JY000575",1,"15286590001", "oArhO6cA1UVgvFHwEfJ_k0hd6MWM")); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } }*/ @RequestMapping(value = "/unionPay", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "银联支付") public ResponseData unionPay(HttpServletRequest request) { try { // return ResponseMsgUtil.success(RequestUtils.getIpAddress(request)); return ResponseMsgUtil.success(unionPayConfig.upPreOrder(UnionPayConfig.MER_ID3, UnionPayConfig.TERM_ID3, "HF"+System.currentTimeMillis(), new BigDecimal("1"), "test",CommonSysConst.getSysConfig().getUnionPayNotifyUrl(), request)); } catch (Exception e) { log.error("HighOrderController --> unionPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getToken", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取贵州中石化token") public ResponseData getToken() { try { return ResponseMsgUtil.success(huiLianTongConfig.getToken()); } catch (Exception e) { log.error("HighOrderController --> getToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/unionTradeQuery", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "银联交易查询") public ResponseData unionTradeQuery(@RequestParam(name = "paySerialNo", required = true) String paySerialNo) { try { return ResponseMsgUtil.success(UnionPayConfig.tradeQuery(UnionPayConfig.MER_ID1, UnionPayConfig.TERM_ID1, paySerialNo)); } catch (Exception e) { log.error("HighOrderController --> unionTradeQuery() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getBackendToken", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取访问令牌backendToken") public ResponseData getBackendToken() { try { return ResponseMsgUtil.success(unionUserConfig.getBackendToken()); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/wxSplitAccount", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "微信分账") public ResponseData wxSplitAccount() { try { HighOrder orderNo = highOrderService.getOrderByOrderNo("HF2021101812025050304"); wxProfitsharing(orderNo.getOrderNo(),orderNo.getPaySerialNo(),orderNo.getPayRealPrice()); return ResponseMsgUtil.success("分账成功"); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/unionStagingPay", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "银联分期支付") public ResponseData unionStagingPay(HttpServletRequest request) { try { /* String orderNo = DateUtil.format(new Date(), DateUtil.YMDHMS); orderNo += IDGenerator.nextId(28 - orderNo.length());*/ String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0,4) +CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4,CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) +DateUtil.format(new Date(), DateUtil.YMDHMS) +IDGenerator.nextId(6); return ResponseMsgUtil.success(unionStagingPayConfig.advancePay( orgTrace, orgTrace, new BigDecimal("1"), CommonSysConst.getSysConfig().getUnionStagingPayNotifyUrl(), request)); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryStaging", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "分期查询") public ResponseData queryStaging(@RequestParam(name = "oriOrgTrace", required = true) String oriOrgTrace,HttpServletRequest request) { try { String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0,4) +CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4,CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) +DateUtil.format(new Date(), DateUtil.YMDHMS) +IDGenerator.nextId(6); return ResponseMsgUtil.success(UnionStagingPayConfig.queryStaging(orgTrace,oriOrgTrace ,"", new Date(), request)); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } /* @RequestMapping(value = "/orderToRefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "退款") public ResponseData orderToRefund(HttpServletRequest request) { try { OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund("4200001301202202035413938093", new BigDecimal("30.80"), new BigDecimal("16.90")); return ResponseMsgUtil.success(orderRefundModel); } catch (Exception e) { log.error("HighOrderController --> orderToRefund() error!", e); return ResponseMsgUtil.exception(e); } }*/ @RequestMapping(value = "/query", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "订单查询") public ResponseData query(@RequestParam(name = "oriOrgTrace", required = true) String oriOrgTrace,HttpServletRequest request) { try { String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0,4) +CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4,CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) +DateUtil.format(new Date(), DateUtil.YMDHMS) +IDGenerator.nextId(6); return ResponseMsgUtil.success(UnionStagingPayConfig.query(orgTrace,oriOrgTrace ,"", new Date(), request)); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/mposrefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "分期退款") public ResponseData mposrefund(@RequestParam(name = "oriOrgTrace", required = true) String oriOrgTrace,HttpServletRequest request) { try { String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0,4) +CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4,CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) +DateUtil.format(new Date(), DateUtil.YMDHMS) +IDGenerator.nextId(6); return ResponseMsgUtil.success(UnionStagingPayConfig.standardRefund(orgTrace,oriOrgTrace ,new BigDecimal("1"), "", new Date(), request)); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/mposfindrefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "分期退款查询") public ResponseData mposfindrefund(@RequestParam(name = "oriOrgTrace", required = true) String oriOrgTrace,HttpServletRequest request) { try { String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0,4) +CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4,CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) +DateUtil.format(new Date(), DateUtil.YMDHMS) +IDGenerator.nextId(6); return ResponseMsgUtil.success(UnionStagingPayConfig.mposfindrefund(orgTrace,oriOrgTrace ,"", new Date(), request)); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } public void wxProfitsharing(String transaction_id,String out_order_no, BigDecimal amount) { try { Map param = new LinkedHashMap<>(); param.put("appid", "wx637bd6f7314daa46"); param.put("mch_id", "1289663601"); param.put("sub_mch_id" , "1609882817"); // 个体户黎杨珍 param.put("transaction_id" , transaction_id); param.put("out_order_no" , out_order_no); param.put("nonce_str" , WxUtils.makeNonStr()); // 分账金额 BigDecimal porofitSharingAmount = amount; List> receiversList = new ArrayList<>(); Map receiversMap = new LinkedHashMap<>(); receiversMap.put("type", "MERCHANT_ID"); receiversMap.put("account", "1603942866"); receiversMap.put("amount", porofitSharingAmount.multiply(new BigDecimal("100")).intValue()); receiversMap.put("description", "分给商户【惠昕石化】"); receiversList.add(receiversMap); param.put("receivers" , JSONObject.toJSONString(receiversList)); String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5" , WXPayConstants.SignType.HMACSHA256); param.put("sign" , signStr); String resultXmL = this.doRefundRequest(param.get("mch_id"),null, WxUtils.mapToXml(param)); // 请求分账返回的结果 ResultProfitSharing resultProfitSharing = XmlUtil.getObjectFromXML(resultXmL, ResultProfitSharing.class); if (!resultProfitSharing.getResult_code().equals("FAIL")) { HighProfitSharingRecord sharingRecord = new HighProfitSharingRecord(); sharingRecord.setOutOrderNo(resultProfitSharing.getOut_order_no()); sharingRecord.setTransactionId(resultProfitSharing.getTransaction_id()); sharingRecord.setOrderId(resultProfitSharing.getOrder_id()); sharingRecord.setStatus(resultProfitSharing.getResult_code()); sharingRecord.setPrice(amount); sharingRecord.setCreateTime(new Date()); sharingRecord.setContent(resultXmL); highProfitSharingRecordService.insert(sharingRecord); } } catch (Exception e) { log.error("CmsContentController --> getCorporateAdvertising() error!", e); } } public CloseableHttpClient readCertificate(String mchId) throws Exception{ /** * 注意PKCS12证书 是从微信商户平台-》账户设置-》 API安全 中下载的 */ KeyStore keyStore = KeyStore.getInstance("PKCS12"); //P12文件目录 证书路径,这里需要你自己修改,linux下还是windows下的根路径 FileInputStream instream = new FileInputStream("/home/project/wx_cert/1289663601_apiclient_cert.p12"); // FileInputStream instream = new FileInputStream("G:\\hurui-project/hai-parent/hai-service/src/main/java/privatekey/1289663601_apiclient_cert.p12"); try { keyStore.load(instream, "1289663601".toCharArray());//这里写密码..默认是你的MCHID } finally { instream.close(); } SSLContext sslcontext = SSLContexts.custom().loadKeyMaterial(keyStore, "1289663601".toCharArray()).build();//这里也是写密码的 SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext, SSLConnectionSocketFactory.getDefaultHostnameVerifier()); // Allow TLSv1 protocol only return HttpClients.custom().setSSLSocketFactory(sslsf).build(); } public String doRefundRequest(String mchId, String url, String data) throws Exception { //小程序退款需要调用双向证书的认证 CloseableHttpClient httpClient = readCertificate(mchId); try { HttpPost httpost = new HttpPost("https://api.mch.weixin.qq.com/secapi/pay/refund"); // 设置响应头信息 httpost.addHeader("Connection", "keep-alive"); httpost.addHeader("Accept", "*/*"); httpost.addHeader("Content-Type", "text/xml"); httpost.addHeader("Host", "api.mch.weixin.qq.com"); httpost.addHeader("X-Requested-With", "XMLHttpRequest"); httpost.addHeader("Cache-Control", "max-age=0"); httpost.addHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) "); httpost.setEntity(new StringEntity(data, "UTF-8")); CloseableHttpResponse response = httpClient.execute(httpost); try { HttpEntity entity = response.getEntity(); String jsonStr = EntityUtils.toString(response.getEntity(), "UTF-8"); EntityUtils.consume(entity); return jsonStr; } finally { response.close(); } } catch (Exception e){ throw new RuntimeException(e); } finally { httpClient.close(); } } } +======= +package com.cweb.controller; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.cweb.config.SysConst; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.pay.util.XmlUtil; import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.security.SessionObject; import com.hai.common.utils.*; import com.hai.config.*; import com.hai.dao.HighGasOrderPushMapper; import com.hai.entity.*; import com.hai.model.*; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.entity.StringEntity; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.ssl.SSLContexts; import org.apache.http.util.EntityUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Controller; import org.springframework.util.IdGenerator; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.net.ssl.SSLContext; import javax.servlet.http.HttpServletRequest; import java.io.FileInputStream; import java.math.BigDecimal; import java.security.KeyStore; import java.util.*; /** * @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 HighMerchantService highMerchantService; @Resource private HighMerchantStoreService highMerchantStoreService; @Resource private HighGasOilPriceService highGasOilPriceService; @Resource private HighOrderService highOrderService; @Resource private HighProfitSharingRecordService highProfitSharingRecordService; @Resource private HighGasOrderPushMapper highGasOrderPushMapper; @Resource private HuiLianTongConfig huiLianTongConfig; @Resource private UnionPayConfig unionPayConfig; @Resource private UnionStagingPayConfig unionStagingPayConfig; @Resource private UnionUserConfig unionUserConfig; @Resource private HighUserService highUserService; @Resource private OutRechargeOrderService outRechargeOrderService; @RequestMapping(value = "/getHuiLianTongCardInfo", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询汇联通工会卡详情") public ResponseData getHuiLianTongCardInfo(@RequestParam(name = "cardNo", required = true) String cardNo, HttpServletRequest request) { try { // 用户 // JSONObject cardInfo = HuiLianTongUnionCardConfig.queryCardInfo(cardNo); if (StringUtils.isBlank(cardInfo.getString("data"))) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQUEST_ERROR, ""); } return ResponseMsgUtil.success(HuiLianTongUnionCardConfig.resolveResponse(cardInfo.getString("data"))); } catch (Exception e) { log.error("HighUserCardController --> getHuiLianTongCardInfo() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/initTYMerchantStore", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "初始化加油站") public ResponseData initTYMerchantStore(@RequestParam(name = "merchantId", required = true) Long merchantId) throws Exception { HighMerchantModel merchant = highMerchantService.getMerchantById(merchantId); if (merchant == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到商户"); } JSONObject jsonObjectP = TuanYouConfig.queryGasInfoListByPage(1, 1000); JSONObject resultObjectP = jsonObjectP.getObject("result", JSONObject.class); for (int i = 1; i <= resultObjectP.getInteger("totalPageNum").intValue();i++) { JSONObject jsonObject = TuanYouConfig.queryGasInfoListByPage(i, 1000); JSONObject resultObject = jsonObject.getObject("result", JSONObject.class); JSONArray jsonArray = resultObject.getJSONArray("gasInfoList"); HighMerchantStore highMerchantStore; HighGasOilPrice highGasOilPrice; for (Object gasObject : jsonArray) { JSONObject object = JSONObject.parseObject(JSONObject.toJSONString(gasObject)); HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreByKey(object.getString("gasId")); if (store != null) { store.setType(1); store.setMerchantId(merchant.getId()); store.setCompanyId(merchant.getCompanyId()); store.setStoreKey(object.getString("gasId")); store.setStoreName(object.getString("gasName")); store.setStoreLogo(object.getString("gasLogoSmall")); store.setRegionId(object.getLong("provinceCode")); store.setRegionName(object.getString("provinceName")); store.setAddress(object.getString("gasAddress")); store.setLongitude(object.getString("gasAddressLongitude")); store.setLatitude(object.getString("gasAddressLatitude")); store.setStatus(object.getInteger("gasStatus")); store.setOperatorId(0L); store.setOperatorName("系统创建"); store.setUpdateTime(new Date()); store.setExt1(object.getString("gasSourceId")); highMerchantStoreService.updateMerchantStoreDetail(store); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); // 查询门店油号 highGasOilPrice = highGasOilPriceService.getGasOilPriceByStoreAndOilNo(store.getId(), oilPriceObject.getInteger("oilNo")); if (highGasOilPrice == null) { highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); } else { highGasOilPrice.setMerchantStoreId(store.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); } highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } else { highMerchantStore = new HighMerchantStore(); highMerchantStore.setType(1); highMerchantStore.setMerchantId(merchant.getId()); highMerchantStore.setCompanyId(merchant.getCompanyId()); highMerchantStore.setStoreKey(object.getString("gasId")); highMerchantStore.setStoreName(object.getString("gasName")); highMerchantStore.setStoreLogo(object.getString("gasLogoSmall")); highMerchantStore.setRegionId(object.getLong("provinceCode")); highMerchantStore.setRegionName(object.getString("provinceName")); highMerchantStore.setAddress(object.getString("gasAddress")); highMerchantStore.setLongitude(object.getString("gasAddressLongitude")); highMerchantStore.setLatitude(object.getString("gasAddressLatitude")); highMerchantStore.setStatus(1); highMerchantStore.setOperatorId(0L); highMerchantStore.setOperatorName("系统创建"); highMerchantStore.setCreateTime(new Date()); highMerchantStore.setUpdateTime(new Date()); highMerchantStore.setExt1(object.getString("gasSourceId")); HighMerchantStoreModel merchantStoreModel = new HighMerchantStoreModel(); BeanUtils.copyProperties(highMerchantStore, merchantStoreModel); highMerchantStoreService.insertMerchantStore(merchantStoreModel); JSONArray oilPriceList = object.getJSONArray("oilPriceList"); for (Object oilPrice : oilPriceList) { JSONObject oilPriceObject = JSONObject.parseObject(JSONObject.toJSONString(oilPrice)); highGasOilPrice = new HighGasOilPrice(); highGasOilPrice.setMerchantStoreId(merchantStoreModel.getId()); highGasOilPrice.setOilNo(oilPriceObject.getInteger("oilNo")); highGasOilPrice.setOilNoName(oilPriceObject.getString("oilNoName")); highGasOilPrice.setPriceVip(oilPriceObject.getBigDecimal("priceVip")); highGasOilPrice.setPriceGun(oilPriceObject.getBigDecimal("priceGun")); highGasOilPrice.setPriceOfficial(oilPriceObject.getBigDecimal("priceOfficial")); highGasOilPrice.setOilType(oilPriceObject.getInteger("oilType")); highGasOilPrice.setOilTypeName(oilPriceObject.getString("oilTypeName")); highGasOilPriceService.editGasOilPrice(highGasOilPrice); } } } } return ResponseMsgUtil.success("初始化完成"); } @RequestMapping(value = "/pushTuanYouOrder", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "推送团油订单") public ResponseData pushTuanYouOrder() { try { HighOrder order = highOrderService.getOrderByOrderNo("HF2021102112141171406"); for (HighChildOrder highChildOrder : order.getHighChildOrderList()) { HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreById(highChildOrder.getGoodsId()); // 推送团油订单 Map paramMap = new HashMap<>(); paramMap.put("gasId", store.getStoreKey()); paramMap.put("oilNo", highChildOrder.getGasOilNo()); paramMap.put("gunNo", highChildOrder.getGasGunNo()); BigDecimal priceGun = highChildOrder.getGasPriceGun(); BigDecimal priceVip = highChildOrder.getGasPriceVip(); paramMap.put("priceGun", priceGun); // 枪单价 paramMap.put("priceVip", priceVip); // 优惠价 paramMap.put("driverPhone", order.getMemPhone()); // paramMap.put("driverPhone", "17726395120"); paramMap.put("thirdSerialNo", order.getOrderNo()); paramMap.put("refuelingAmount", highChildOrder.getTotalPrice()); // 油品类型 1:汽油:2:柴油;3:天然气 if (highChildOrder.getGasOilType() == 1) { paramMap.put("accountNo", CommonSysConst.getSysConfig().getTuanYouGasolineAccount()); } else if (highChildOrder.getGasOilType() == 2) { paramMap.put("accountNo", CommonSysConst.getSysConfig().getTuanYouDieselAccount()); } JSONObject orderPushObject = TuanYouConfig.refuelingOrderPush(paramMap); // 推送团油订单记录 HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); highGasOrderPush.setCreateTime(new Date()); highGasOrderPush.setCode(orderPushObject.getString("code")); highGasOrderPush.setRequestContent(JSONObject.toJSONString(paramMap)); highGasOrderPush.setReturnContent(orderPushObject.toJSONString()); highGasOrderPushMapper.insert(highGasOrderPush); if (orderPushObject != null && orderPushObject.getString("code").equals("200")) { highChildOrder.setGasOrderNo(orderPushObject.getJSONObject("result").getString("orderNo")); } highOrderService.updateOrder(order); } return ResponseMsgUtil.success(order); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryCompanyAccountInfo2JD", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "查询团油余额") public ResponseData queryCompanyAccountInfo2JD() { try { return ResponseMsgUtil.success(TuanYouConfig.queryCompanyAccountInfo2JD()); } catch (Exception e) { log.error("HighOrderController --> queryCompanyAccountInfo2JD() error!", e); return ResponseMsgUtil.exception(e); } } /*@RequestMapping(value = "/couJointDist", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "派发贵州卡券") public ResponseData couJointDist(@RequestParam(name = "token", required = true) String token) { try { return ResponseMsgUtil.success(HuiLianTongConfig.couJointDist(token,"HF2022022116504244204","20JY000575",1,"15286590001", "oArhO6cA1UVgvFHwEfJ_k0hd6MWM")); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } }*/ @RequestMapping(value = "/unionPay", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "银联支付") public ResponseData unionPay(HttpServletRequest request) { try { // return ResponseMsgUtil.success(RequestUtils.getIpAddress(request)); return ResponseMsgUtil.success(unionPayConfig.upPreOrder(UnionPayConfig.MER_ID3, UnionPayConfig.TERM_ID3, "HF"+System.currentTimeMillis(), new BigDecimal("1"), "test",CommonSysConst.getSysConfig().getUnionPayNotifyUrl(), request)); } catch (Exception e) { log.error("HighOrderController --> unionPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getToken", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取贵州中石化token") public ResponseData getToken() { try { return ResponseMsgUtil.success(huiLianTongConfig.getToken()); } catch (Exception e) { log.error("HighOrderController --> getToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/unionTradeQuery", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "银联交易查询") public ResponseData unionTradeQuery(@RequestParam(name = "paySerialNo", required = true) String paySerialNo) { try { return ResponseMsgUtil.success(UnionPayConfig.tradeQuery(UnionPayConfig.MER_ID1, UnionPayConfig.TERM_ID1, paySerialNo)); } catch (Exception e) { log.error("HighOrderController --> unionTradeQuery() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/getBackendToken", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取访问令牌backendToken") public ResponseData getBackendToken() { try { return ResponseMsgUtil.success(unionUserConfig.getBackendToken()); } catch (Exception e) { log.error("HighOrderController --> getBackendToken() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/wxSplitAccount", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "微信分账") public ResponseData wxSplitAccount() { try { HighOrder orderNo = highOrderService.getOrderByOrderNo("HF2021101812025050304"); wxProfitsharing(orderNo.getOrderNo(),orderNo.getPaySerialNo(),orderNo.getPayRealPrice()); return ResponseMsgUtil.success("分账成功"); } catch (Exception e) { log.error("HighOrderController --> getOrderById() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/unionStagingPay", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "银联分期支付") public ResponseData unionStagingPay(HttpServletRequest request) { try { /* String orderNo = DateUtil.format(new Date(), DateUtil.YMDHMS); orderNo += IDGenerator.nextId(28 - orderNo.length());*/ String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0,4) +CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4,CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) +DateUtil.format(new Date(), DateUtil.YMDHMS) +IDGenerator.nextId(6); return ResponseMsgUtil.success(unionStagingPayConfig.advancePay( orgTrace, orgTrace, new BigDecimal("1"), CommonSysConst.getSysConfig().getUnionStagingPayNotifyUrl(), request)); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/queryStaging", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "分期查询") public ResponseData queryStaging(@RequestParam(name = "oriOrgTrace", required = true) String oriOrgTrace,HttpServletRequest request) { try { String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0,4) +CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4,CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) +DateUtil.format(new Date(), DateUtil.YMDHMS) +IDGenerator.nextId(6); return ResponseMsgUtil.success(UnionStagingPayConfig.queryStaging(orgTrace,oriOrgTrace ,"", new Date(), request)); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/query", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "订单查询") public ResponseData query(@RequestParam(name = "oriOrgTrace", required = true) String oriOrgTrace,HttpServletRequest request) { try { String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0,4) +CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4,CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) +DateUtil.format(new Date(), DateUtil.YMDHMS) +IDGenerator.nextId(6); return ResponseMsgUtil.success(UnionStagingPayConfig.query(orgTrace,oriOrgTrace ,"", new Date(), request)); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/mposrefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "分期退款") public ResponseData mposrefund(@RequestParam(name = "oriOrgTrace", required = true) String oriOrgTrace,HttpServletRequest request) { try { String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0,4) +CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4,CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) +DateUtil.format(new Date(), DateUtil.YMDHMS) +IDGenerator.nextId(6); return ResponseMsgUtil.success(UnionStagingPayConfig.standardRefund(orgTrace,oriOrgTrace ,new BigDecimal("1"), "", new Date(), request)); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } @RequestMapping(value = "/mposfindrefund", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "分期退款查询") public ResponseData mposfindrefund(@RequestParam(name = "oriOrgTrace", required = true) String oriOrgTrace,HttpServletRequest request) { try { String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0,4) +CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4,CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) +DateUtil.format(new Date(), DateUtil.YMDHMS) +IDGenerator.nextId(6); return ResponseMsgUtil.success(UnionStagingPayConfig.mposfindrefund(orgTrace,oriOrgTrace ,"", new Date(), request)); } catch (Exception e) { log.error("HighOrderController --> unionStagingPay() error!", e); return ResponseMsgUtil.exception(e); } } public void wxProfitsharing(String transaction_id,String out_order_no, BigDecimal amount) { try { Map param = new LinkedHashMap<>(); param.put("appid", "wx637bd6f7314daa46"); param.put("mch_id", "1289663601"); param.put("sub_mch_id" , "1609882817"); // 个体户黎杨珍 param.put("transaction_id" , transaction_id); param.put("out_order_no" , out_order_no); param.put("nonce_str" , WxUtils.makeNonStr()); // 分账金额 BigDecimal porofitSharingAmount = amount; List> receiversList = new ArrayList<>(); Map receiversMap = new LinkedHashMap<>(); receiversMap.put("type", "MERCHANT_ID"); receiversMap.put("account", "1603942866"); receiversMap.put("amount", porofitSharingAmount.multiply(new BigDecimal("100")).intValue()); receiversMap.put("description", "分给商户【惠昕石化】"); receiversList.add(receiversMap); param.put("receivers" , JSONObject.toJSONString(receiversList)); String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5" , WXPayConstants.SignType.HMACSHA256); param.put("sign" , signStr); String resultXmL = this.doRefundRequest(param.get("mch_id"),null, WxUtils.mapToXml(param)); // 请求分账返回的结果 ResultProfitSharing resultProfitSharing = XmlUtil.getObjectFromXML(resultXmL, ResultProfitSharing.class); if (!resultProfitSharing.getResult_code().equals("FAIL")) { HighProfitSharingRecord sharingRecord = new HighProfitSharingRecord(); sharingRecord.setOutOrderNo(resultProfitSharing.getOut_order_no()); sharingRecord.setTransactionId(resultProfitSharing.getTransaction_id()); sharingRecord.setOrderId(resultProfitSharing.getOrder_id()); sharingRecord.setStatus(resultProfitSharing.getResult_code()); sharingRecord.setPrice(amount); sharingRecord.setCreateTime(new Date()); sharingRecord.setContent(resultXmL); highProfitSharingRecordService.insert(sharingRecord); } } catch (Exception e) { log.error("CmsContentController --> getCorporateAdvertising() error!", e); } } public CloseableHttpClient readCertificate(String mchId) throws Exception{ /** * 注意PKCS12证书 是从微信商户平台-》账户设置-》 API安全 中下载的 */ KeyStore keyStore = KeyStore.getInstance("PKCS12"); //P12文件目录 证书路径,这里需要你自己修改,linux下还是windows下的根路径 FileInputStream instream = new FileInputStream("/home/project/wx_cert/1289663601_apiclient_cert.p12"); // FileInputStream instream = new FileInputStream("G:\\hurui-project/hai-parent/hai-service/src/main/java/privatekey/1289663601_apiclient_cert.p12"); try { keyStore.load(instream, "1289663601".toCharArray());//这里写密码..默认是你的MCHID } finally { instream.close(); } SSLContext sslcontext = SSLContexts.custom().loadKeyMaterial(keyStore, "1289663601".toCharArray()).build();//这里也是写密码的 SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext, SSLConnectionSocketFactory.getDefaultHostnameVerifier()); // Allow TLSv1 protocol only return HttpClients.custom().setSSLSocketFactory(sslsf).build(); } public String doRefundRequest(String mchId, String url, String data) throws Exception { //小程序退款需要调用双向证书的认证 CloseableHttpClient httpClient = readCertificate(mchId); try { HttpPost httpost = new HttpPost("https://api.mch.weixin.qq.com/secapi/pay/refund"); // 设置响应头信息 httpost.addHeader("Connection", "keep-alive"); httpost.addHeader("Accept", "*/*"); httpost.addHeader("Content-Type", "text/xml"); httpost.addHeader("Host", "api.mch.weixin.qq.com"); httpost.addHeader("X-Requested-With", "XMLHttpRequest"); httpost.addHeader("Cache-Control", "max-age=0"); httpost.addHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) "); httpost.setEntity(new StringEntity(data, "UTF-8")); CloseableHttpResponse response = httpClient.execute(httpost); try { HttpEntity entity = response.getEntity(); String jsonStr = EntityUtils.toString(response.getEntity(), "UTF-8"); EntityUtils.consume(entity); return jsonStr; } finally { response.close(); } } catch (Exception e){ throw new RuntimeException(e); } finally { httpClient.close(); } } } +>>>>>>> 03d4100cf43fd37121eb9eb614937280bf66c0e9 diff --git a/hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java b/hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java index 17fe2b7b..ff746a8e 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java @@ -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 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) @ResponseBody @ApiOperation(value = "分账") diff --git a/hai-cweb/src/main/java/com/cweb/controller/WechatController.java b/hai-cweb/src/main/java/com/cweb/controller/WechatController.java index 0d0a83ef..b539fc5b 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/WechatController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/WechatController.java @@ -32,10 +32,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; 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) @ResponseBody @@ -271,25 +244,42 @@ public class WechatController { } } - @RequestMapping(value = "/loginByTel1", method = RequestMethod.GET) + @RequestMapping(value = "/loginByTel", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "根据手机号码登陆") - public ResponseData loginByTel1(@RequestParam(value = "phone", required = true) String phone, + public ResponseData loginByTel(@RequestBody JSONObject body, HttpServletRequest request, HttpServletResponse response) { 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); - // 定义个人所有数据 - // 定义个人所有数据 - 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); + HighUser user = highUserService.findByPhone(body.getString("phone")); - return ResponseMsgUtil.success(so); + // 获取手机号验证码 + String phoneSmsCode = (String) redisUtil.get("SMS_"+ body.getString("phone")); + + // 验证码校验 + if (StringUtils.isNotBlank(phoneSmsCode) && Objects.equals(phoneSmsCode,body.getString("smsCode"))) { + // 定义个人所有数据 + // 定义个人所有数据 + 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); + } + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "验证码错误"); } catch (Exception e) { return ResponseMsgUtil.exception(e); diff --git a/hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java b/hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java index 64cf51c0..b7267bfe 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java @@ -191,7 +191,13 @@ public class OrderController { } else { 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.setSub_openid(openId); diff --git a/hai-cweb/src/main/resources/dev/config.properties b/hai-cweb/src/main/resources/dev/config.properties index 996cde57..4e9a74e1 100644 --- a/hai-cweb/src/main/resources/dev/config.properties +++ b/hai-cweb/src/main/resources/dev/config.properties @@ -11,6 +11,8 @@ wxMchId=1289663601 wxSubAppId=wx8d49e2f83025229d wxSubMchId=1609882817 wxUnifiedOrderUrl=https://api.mch.weixin.qq.com/pay/unifiedorder +wxGzSubAppId=wxa075e8509802f826 +wxGzSubMchId=1619676214 # ???????????? HDAppId = 1614670195 diff --git a/hai-cweb/src/main/resources/prod/config.properties b/hai-cweb/src/main/resources/prod/config.properties index 86c32fe7..5b218155 100644 --- a/hai-cweb/src/main/resources/prod/config.properties +++ b/hai-cweb/src/main/resources/prod/config.properties @@ -11,6 +11,9 @@ wxMchId=1289663601 wxSubAppId=wx8d49e2f83025229d wxSubMchId=1609882817 wxUnifiedOrderUrl=https://api.mch.weixin.qq.com/pay/unifiedorder +wxGzSubAppId=wxa075e8509802f826 +wxGzSubMchId=1619676214 + notifyUrl=https://hsg.dctpay.com/crest/wechatpay/notify diff --git a/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java b/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java index a61bd46d..9d88fe18 100644 --- a/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java +++ b/hai-schedule/src/main/java/com/hai/schedule/HighCouponSchedule.java @@ -6,6 +6,7 @@ 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.dao.HighCouponAgentCodeMapper; import com.hai.dao.HighCouponCodeOtherMapper; import com.hai.dao.HighUserCouponMapper; import com.hai.entity.*; @@ -39,6 +40,9 @@ public class HighCouponSchedule { @Resource private HighCouponCodeOtherMapper highCouponCodeOtherMapper; + @Resource + private HighCouponAgentCodeMapper highCouponAgentCodeMapper; + @Resource private HighOrderService highOrderService; @@ -70,7 +74,6 @@ public class HighCouponSchedule { **/ @Scheduled(cron="0 0/10 * * * ?") //每10分钟执行一次 public void handleCouponStatus() throws Exception { - HighCouponCodeOtherExample example = new HighCouponCodeOtherExample(); example.createCriteria().andStatusEqualTo(20).andTypeEqualTo(1); List otherList = highCouponCodeOtherMapper.selectByExample(example); @@ -85,26 +88,36 @@ public class HighCouponSchedule { couponCodeOther.setStatus(data.getJSONObject("data").getInteger("state")); highCouponCodeOtherMapper.updateByPrimaryKey(couponCodeOther); - HighUserCouponExample userCouponExample = new HighUserCouponExample(); - userCouponExample.createCriteria().andQrCodeImgEqualTo(couponCodeOther.getCouNo()).andStatusEqualTo(1); - List list = highUserCouponMapper.selectByExample(userCouponExample); - if (list.size() > 0) { - HighUserCoupon userCoupon = list.get(0); - if (data.getJSONObject("data").getInteger("state") == 40) { - userCoupon.setStatus(2); - userCoupon.setConsumeTime(new Date()); - } else { - userCoupon.setStatus(0); + if (couponCodeOther.getCouponAgentCodeId() != null) { + HighCouponAgentCode agentCode = highCouponAgentCodeMapper.selectByPrimaryKey(couponCodeOther.getCouponAgentCodeId()); + if (agentCode == null) { + agentCode.setStatus(3); + highCouponAgentCodeMapper.updateByPrimaryKey(agentCode); + } + } + + if (couponCodeOther.getChildOrderId() != null) { + HighUserCouponExample userCouponExample = new HighUserCouponExample(); + userCouponExample.createCriteria().andQrCodeImgEqualTo(couponCodeOther.getCouNo()).andStatusEqualTo(1); + List list = highUserCouponMapper.selectByExample(userCouponExample); + if (list.size() > 0) { + HighUserCoupon userCoupon = list.get(0); + if (data.getJSONObject("data").getInteger("state") == 40) { + userCoupon.setStatus(2); + userCoupon.setConsumeTime(new Date()); + } else { + userCoupon.setStatus(0); + } + highUserCouponMapper.updateByPrimaryKey(userCoupon); + } + // 查询订单中的汇联通卡券全部已处理 + HighCouponCodeOtherExample otherExample = new HighCouponCodeOtherExample(); + otherExample.createCriteria().andChildOrderIdEqualTo(couponCodeOther.getChildOrderId()).andStatusEqualTo(20).andTypeEqualTo(1); + if (highCouponCodeOtherMapper.selectByExample(otherExample).size() == 0) { + highOrderService.childOrderComplete(couponCodeOther.getChildOrderId()); } - highUserCouponMapper.updateByPrimaryKey(userCoupon); } - } - // 查询订单中的汇联通卡券全部已处理 - HighCouponCodeOtherExample otherExample = new HighCouponCodeOtherExample(); - otherExample.createCriteria().andChildOrderIdEqualTo(couponCodeOther.getChildOrderId()).andStatusEqualTo(20).andTypeEqualTo(1); - if (highCouponCodeOtherMapper.selectByExample(otherExample).size() == 0) { - highOrderService.childOrderComplete(couponCodeOther.getChildOrderId()); } } } diff --git a/hai-service/src/main/java/com/hai/config/WxOrderConfig.java b/hai-service/src/main/java/com/hai/config/WxOrderConfig.java index 4ece88bd..bf1f45b9 100644 --- a/hai-service/src/main/java/com/hai/config/WxOrderConfig.java +++ b/hai-service/src/main/java/com/hai/config/WxOrderConfig.java @@ -80,6 +80,23 @@ public class WxOrderConfig { return XmlUtil.getObjectFromXML(resultXmL, OrderRefundModel.class); } + public static OrderRefundModel orderToRefund(String paySerialNo,BigDecimal totalFee, String subMchId , BigDecimal refundFee) throws Exception { + Map 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 { //双向证书的认证 diff --git a/hai-service/src/main/java/com/hai/dao/HighCouponAgentCodeMapper.java b/hai-service/src/main/java/com/hai/dao/HighCouponAgentCodeMapper.java index 8aaad6b1..220c3470 100644 --- a/hai-service/src/main/java/com/hai/dao/HighCouponAgentCodeMapper.java +++ b/hai-service/src/main/java/com/hai/dao/HighCouponAgentCodeMapper.java @@ -41,22 +41,22 @@ public interface HighCouponAgentCodeMapper extends HighCouponAgentCodeMapperExt @Insert({ "insert into high_coupon_agent_code (`type`, coupon_agent_id, ", "coupon_id, agent_id, ", - "coupon_agent_record_id, convert_code, ", - "coupon_code_id, coupon_code, ", - "qr_code, `status`, ", - "remark, create_time, ", - "sales_time, operator_id, ", - "operator_name, ext_1, ", - "ext_2, ext_3)", + "coupon_agent_record_id, convert_user_phone, ", + "convert_code, coupon_code_id, ", + "coupon_code, qr_code, ", + "`status`, remark, ", + "create_time, sales_time, ", + "operator_id, operator_name, ", + "ext_1, ext_2, ext_3)", "values (#{type,jdbcType=INTEGER}, #{couponAgentId,jdbcType=BIGINT}, ", "#{couponId,jdbcType=BIGINT}, #{agentId,jdbcType=BIGINT}, ", - "#{couponAgentRecordId,jdbcType=BIGINT}, #{convertCode,jdbcType=VARCHAR}, ", - "#{couponCodeId,jdbcType=BIGINT}, #{couponCode,jdbcType=VARCHAR}, ", - "#{qrCode,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, ", - "#{remark,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, ", - "#{salesTime,jdbcType=TIMESTAMP}, #{operatorId,jdbcType=BIGINT}, ", - "#{operatorName,jdbcType=VARCHAR}, #{ext1,jdbcType=VARCHAR}, ", - "#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" + "#{couponAgentRecordId,jdbcType=BIGINT}, #{convertUserPhone,jdbcType=VARCHAR}, ", + "#{convertCode,jdbcType=VARCHAR}, #{couponCodeId,jdbcType=BIGINT}, ", + "#{couponCode,jdbcType=VARCHAR}, #{qrCode,jdbcType=VARCHAR}, ", + "#{status,jdbcType=INTEGER}, #{remark,jdbcType=VARCHAR}, ", + "#{createTime,jdbcType=TIMESTAMP}, #{salesTime,jdbcType=TIMESTAMP}, ", + "#{operatorId,jdbcType=BIGINT}, #{operatorName,jdbcType=VARCHAR}, ", + "#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" }) @Options(useGeneratedKeys=true,keyProperty="id") int insert(HighCouponAgentCode record); @@ -73,6 +73,7 @@ public interface HighCouponAgentCodeMapper extends HighCouponAgentCodeMapperExt @Result(column="coupon_id", property="couponId", jdbcType=JdbcType.BIGINT), @Result(column="agent_id", property="agentId", jdbcType=JdbcType.BIGINT), @Result(column="coupon_agent_record_id", property="couponAgentRecordId", jdbcType=JdbcType.BIGINT), + @Result(column="convert_user_phone", property="convertUserPhone", jdbcType=JdbcType.VARCHAR), @Result(column="convert_code", property="convertCode", jdbcType=JdbcType.VARCHAR), @Result(column="coupon_code_id", property="couponCodeId", jdbcType=JdbcType.BIGINT), @Result(column="coupon_code", property="couponCode", jdbcType=JdbcType.VARCHAR), @@ -91,9 +92,9 @@ public interface HighCouponAgentCodeMapper extends HighCouponAgentCodeMapperExt @Select({ "select", - "id, `type`, coupon_agent_id, coupon_id, agent_id, coupon_agent_record_id, convert_code, ", - "coupon_code_id, coupon_code, qr_code, `status`, remark, create_time, sales_time, ", - "operator_id, operator_name, ext_1, ext_2, ext_3", + "id, `type`, coupon_agent_id, coupon_id, agent_id, coupon_agent_record_id, convert_user_phone, ", + "convert_code, coupon_code_id, coupon_code, qr_code, `status`, remark, create_time, ", + "sales_time, operator_id, operator_name, ext_1, ext_2, ext_3", "from high_coupon_agent_code", "where id = #{id,jdbcType=BIGINT}" }) @@ -104,6 +105,7 @@ public interface HighCouponAgentCodeMapper extends HighCouponAgentCodeMapperExt @Result(column="coupon_id", property="couponId", jdbcType=JdbcType.BIGINT), @Result(column="agent_id", property="agentId", jdbcType=JdbcType.BIGINT), @Result(column="coupon_agent_record_id", property="couponAgentRecordId", jdbcType=JdbcType.BIGINT), + @Result(column="convert_user_phone", property="convertUserPhone", jdbcType=JdbcType.VARCHAR), @Result(column="convert_code", property="convertCode", jdbcType=JdbcType.VARCHAR), @Result(column="coupon_code_id", property="couponCodeId", jdbcType=JdbcType.BIGINT), @Result(column="coupon_code", property="couponCode", jdbcType=JdbcType.VARCHAR), @@ -136,6 +138,7 @@ public interface HighCouponAgentCodeMapper extends HighCouponAgentCodeMapperExt "coupon_id = #{couponId,jdbcType=BIGINT},", "agent_id = #{agentId,jdbcType=BIGINT},", "coupon_agent_record_id = #{couponAgentRecordId,jdbcType=BIGINT},", + "convert_user_phone = #{convertUserPhone,jdbcType=VARCHAR},", "convert_code = #{convertCode,jdbcType=VARCHAR},", "coupon_code_id = #{couponCodeId,jdbcType=BIGINT},", "coupon_code = #{couponCode,jdbcType=VARCHAR},", diff --git a/hai-service/src/main/java/com/hai/dao/HighCouponAgentCodeSqlProvider.java b/hai-service/src/main/java/com/hai/dao/HighCouponAgentCodeSqlProvider.java index 86c441e6..85e542ca 100644 --- a/hai-service/src/main/java/com/hai/dao/HighCouponAgentCodeSqlProvider.java +++ b/hai-service/src/main/java/com/hai/dao/HighCouponAgentCodeSqlProvider.java @@ -48,6 +48,10 @@ public class HighCouponAgentCodeSqlProvider { sql.VALUES("coupon_agent_record_id", "#{couponAgentRecordId,jdbcType=BIGINT}"); } + if (record.getConvertUserPhone() != null) { + sql.VALUES("convert_user_phone", "#{convertUserPhone,jdbcType=VARCHAR}"); + } + if (record.getConvertCode() != null) { sql.VALUES("convert_code", "#{convertCode,jdbcType=VARCHAR}"); } @@ -115,6 +119,7 @@ public class HighCouponAgentCodeSqlProvider { sql.SELECT("coupon_id"); sql.SELECT("agent_id"); sql.SELECT("coupon_agent_record_id"); + sql.SELECT("convert_user_phone"); sql.SELECT("convert_code"); sql.SELECT("coupon_code_id"); sql.SELECT("coupon_code"); @@ -169,6 +174,10 @@ public class HighCouponAgentCodeSqlProvider { sql.SET("coupon_agent_record_id = #{record.couponAgentRecordId,jdbcType=BIGINT}"); } + if (record.getConvertUserPhone() != null) { + sql.SET("convert_user_phone = #{record.convertUserPhone,jdbcType=VARCHAR}"); + } + if (record.getConvertCode() != null) { sql.SET("convert_code = #{record.convertCode,jdbcType=VARCHAR}"); } @@ -235,6 +244,7 @@ public class HighCouponAgentCodeSqlProvider { sql.SET("coupon_id = #{record.couponId,jdbcType=BIGINT}"); sql.SET("agent_id = #{record.agentId,jdbcType=BIGINT}"); sql.SET("coupon_agent_record_id = #{record.couponAgentRecordId,jdbcType=BIGINT}"); + sql.SET("convert_user_phone = #{record.convertUserPhone,jdbcType=VARCHAR}"); sql.SET("convert_code = #{record.convertCode,jdbcType=VARCHAR}"); sql.SET("coupon_code_id = #{record.couponCodeId,jdbcType=BIGINT}"); sql.SET("coupon_code = #{record.couponCode,jdbcType=VARCHAR}"); @@ -278,6 +288,10 @@ public class HighCouponAgentCodeSqlProvider { sql.SET("coupon_agent_record_id = #{couponAgentRecordId,jdbcType=BIGINT}"); } + if (record.getConvertUserPhone() != null) { + sql.SET("convert_user_phone = #{convertUserPhone,jdbcType=VARCHAR}"); + } + if (record.getConvertCode() != null) { sql.SET("convert_code = #{convertCode,jdbcType=VARCHAR}"); } diff --git a/hai-service/src/main/java/com/hai/dao/HighCouponCodeOtherMapper.java b/hai-service/src/main/java/com/hai/dao/HighCouponCodeOtherMapper.java index 523833df..c1520e09 100644 --- a/hai-service/src/main/java/com/hai/dao/HighCouponCodeOtherMapper.java +++ b/hai-service/src/main/java/com/hai/dao/HighCouponCodeOtherMapper.java @@ -39,15 +39,17 @@ public interface HighCouponCodeOtherMapper extends HighCouponCodeOtherMapperExt int deleteByPrimaryKey(Long id); @Insert({ - "insert into high_coupon_code_other (`type`, order_id, ", - "child_order_id, cou_type_code, ", - "cou_no, `status`, active_time, ", + "insert into high_coupon_code_other (`type`, coupon_agent_code_id, ", + "order_id, child_order_id, ", + "cou_type_code, cou_no, ", + "`status`, active_time, ", "valid_start_date, valid_end_date, ", "create_time, ext_1, ", "ext_2, ext_3)", - "values (#{type,jdbcType=INTEGER}, #{orderId,jdbcType=BIGINT}, ", - "#{childOrderId,jdbcType=BIGINT}, #{couTypeCode,jdbcType=VARCHAR}, ", - "#{couNo,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, #{activeTime,jdbcType=TIMESTAMP}, ", + "values (#{type,jdbcType=INTEGER}, #{couponAgentCodeId,jdbcType=BIGINT}, ", + "#{orderId,jdbcType=BIGINT}, #{childOrderId,jdbcType=BIGINT}, ", + "#{couTypeCode,jdbcType=VARCHAR}, #{couNo,jdbcType=VARCHAR}, ", + "#{status,jdbcType=INTEGER}, #{activeTime,jdbcType=TIMESTAMP}, ", "#{validStartDate,jdbcType=TIMESTAMP}, #{validEndDate,jdbcType=TIMESTAMP}, ", "#{createTime,jdbcType=TIMESTAMP}, #{ext1,jdbcType=VARCHAR}, ", "#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" @@ -63,6 +65,7 @@ public interface HighCouponCodeOtherMapper extends HighCouponCodeOtherMapperExt @Results({ @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), @Result(column="type", property="type", jdbcType=JdbcType.INTEGER), + @Result(column="coupon_agent_code_id", property="couponAgentCodeId", jdbcType=JdbcType.BIGINT), @Result(column="order_id", property="orderId", jdbcType=JdbcType.BIGINT), @Result(column="child_order_id", property="childOrderId", jdbcType=JdbcType.BIGINT), @Result(column="cou_type_code", property="couTypeCode", jdbcType=JdbcType.VARCHAR), @@ -80,14 +83,16 @@ public interface HighCouponCodeOtherMapper extends HighCouponCodeOtherMapperExt @Select({ "select", - "id, `type`, order_id, child_order_id, cou_type_code, cou_no, `status`, active_time, ", - "valid_start_date, valid_end_date, create_time, ext_1, ext_2, ext_3", + "id, `type`, coupon_agent_code_id, order_id, child_order_id, cou_type_code, cou_no, ", + "`status`, active_time, valid_start_date, valid_end_date, create_time, ext_1, ", + "ext_2, ext_3", "from high_coupon_code_other", "where id = #{id,jdbcType=BIGINT}" }) @Results({ @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), @Result(column="type", property="type", jdbcType=JdbcType.INTEGER), + @Result(column="coupon_agent_code_id", property="couponAgentCodeId", jdbcType=JdbcType.BIGINT), @Result(column="order_id", property="orderId", jdbcType=JdbcType.BIGINT), @Result(column="child_order_id", property="childOrderId", jdbcType=JdbcType.BIGINT), @Result(column="cou_type_code", property="couTypeCode", jdbcType=JdbcType.VARCHAR), @@ -115,6 +120,7 @@ public interface HighCouponCodeOtherMapper extends HighCouponCodeOtherMapperExt @Update({ "update high_coupon_code_other", "set `type` = #{type,jdbcType=INTEGER},", + "coupon_agent_code_id = #{couponAgentCodeId,jdbcType=BIGINT},", "order_id = #{orderId,jdbcType=BIGINT},", "child_order_id = #{childOrderId,jdbcType=BIGINT},", "cou_type_code = #{couTypeCode,jdbcType=VARCHAR},", diff --git a/hai-service/src/main/java/com/hai/dao/HighCouponCodeOtherSqlProvider.java b/hai-service/src/main/java/com/hai/dao/HighCouponCodeOtherSqlProvider.java index 8e3059d9..43e013f4 100644 --- a/hai-service/src/main/java/com/hai/dao/HighCouponCodeOtherSqlProvider.java +++ b/hai-service/src/main/java/com/hai/dao/HighCouponCodeOtherSqlProvider.java @@ -32,6 +32,10 @@ public class HighCouponCodeOtherSqlProvider { sql.VALUES("`type`", "#{type,jdbcType=INTEGER}"); } + if (record.getCouponAgentCodeId() != null) { + sql.VALUES("coupon_agent_code_id", "#{couponAgentCodeId,jdbcType=BIGINT}"); + } + if (record.getOrderId() != null) { sql.VALUES("order_id", "#{orderId,jdbcType=BIGINT}"); } @@ -91,6 +95,7 @@ public class HighCouponCodeOtherSqlProvider { sql.SELECT("id"); } sql.SELECT("`type`"); + sql.SELECT("coupon_agent_code_id"); sql.SELECT("order_id"); sql.SELECT("child_order_id"); sql.SELECT("cou_type_code"); @@ -128,6 +133,10 @@ public class HighCouponCodeOtherSqlProvider { sql.SET("`type` = #{record.type,jdbcType=INTEGER}"); } + if (record.getCouponAgentCodeId() != null) { + sql.SET("coupon_agent_code_id = #{record.couponAgentCodeId,jdbcType=BIGINT}"); + } + if (record.getOrderId() != null) { sql.SET("order_id = #{record.orderId,jdbcType=BIGINT}"); } @@ -186,6 +195,7 @@ public class HighCouponCodeOtherSqlProvider { sql.SET("id = #{record.id,jdbcType=BIGINT}"); sql.SET("`type` = #{record.type,jdbcType=INTEGER}"); + sql.SET("coupon_agent_code_id = #{record.couponAgentCodeId,jdbcType=BIGINT}"); sql.SET("order_id = #{record.orderId,jdbcType=BIGINT}"); sql.SET("child_order_id = #{record.childOrderId,jdbcType=BIGINT}"); sql.SET("cou_type_code = #{record.couTypeCode,jdbcType=VARCHAR}"); @@ -212,6 +222,10 @@ public class HighCouponCodeOtherSqlProvider { sql.SET("`type` = #{type,jdbcType=INTEGER}"); } + if (record.getCouponAgentCodeId() != null) { + sql.SET("coupon_agent_code_id = #{couponAgentCodeId,jdbcType=BIGINT}"); + } + if (record.getOrderId() != null) { sql.SET("order_id = #{orderId,jdbcType=BIGINT}"); } diff --git a/hai-service/src/main/java/com/hai/entity/HighCouponAgentCode.java b/hai-service/src/main/java/com/hai/entity/HighCouponAgentCode.java index f43416a6..a5b23b11 100644 --- a/hai-service/src/main/java/com/hai/entity/HighCouponAgentCode.java +++ b/hai-service/src/main/java/com/hai/entity/HighCouponAgentCode.java @@ -45,6 +45,11 @@ public class HighCouponAgentCode extends HighCouponAgentCodeModel implements Ser */ private Long couponAgentRecordId; + /** + * 兑换人手机号 + */ + private String convertUserPhone; + /** * 兑换码 */ @@ -151,6 +156,14 @@ public class HighCouponAgentCode extends HighCouponAgentCodeModel implements Ser this.couponAgentRecordId = couponAgentRecordId; } + public String getConvertUserPhone() { + return convertUserPhone; + } + + public void setConvertUserPhone(String convertUserPhone) { + this.convertUserPhone = convertUserPhone; + } + public String getConvertCode() { return convertCode; } @@ -273,6 +286,7 @@ public class HighCouponAgentCode extends HighCouponAgentCodeModel implements Ser && (this.getCouponId() == null ? other.getCouponId() == null : this.getCouponId().equals(other.getCouponId())) && (this.getAgentId() == null ? other.getAgentId() == null : this.getAgentId().equals(other.getAgentId())) && (this.getCouponAgentRecordId() == null ? other.getCouponAgentRecordId() == null : this.getCouponAgentRecordId().equals(other.getCouponAgentRecordId())) + && (this.getConvertUserPhone() == null ? other.getConvertUserPhone() == null : this.getConvertUserPhone().equals(other.getConvertUserPhone())) && (this.getConvertCode() == null ? other.getConvertCode() == null : this.getConvertCode().equals(other.getConvertCode())) && (this.getCouponCodeId() == null ? other.getCouponCodeId() == null : this.getCouponCodeId().equals(other.getCouponCodeId())) && (this.getCouponCode() == null ? other.getCouponCode() == null : this.getCouponCode().equals(other.getCouponCode())) @@ -298,6 +312,7 @@ public class HighCouponAgentCode extends HighCouponAgentCodeModel implements Ser result = prime * result + ((getCouponId() == null) ? 0 : getCouponId().hashCode()); result = prime * result + ((getAgentId() == null) ? 0 : getAgentId().hashCode()); result = prime * result + ((getCouponAgentRecordId() == null) ? 0 : getCouponAgentRecordId().hashCode()); + result = prime * result + ((getConvertUserPhone() == null) ? 0 : getConvertUserPhone().hashCode()); result = prime * result + ((getConvertCode() == null) ? 0 : getConvertCode().hashCode()); result = prime * result + ((getCouponCodeId() == null) ? 0 : getCouponCodeId().hashCode()); result = prime * result + ((getCouponCode() == null) ? 0 : getCouponCode().hashCode()); @@ -326,6 +341,7 @@ public class HighCouponAgentCode extends HighCouponAgentCodeModel implements Ser sb.append(", couponId=").append(couponId); sb.append(", agentId=").append(agentId); sb.append(", couponAgentRecordId=").append(couponAgentRecordId); + sb.append(", convertUserPhone=").append(convertUserPhone); sb.append(", convertCode=").append(convertCode); sb.append(", couponCodeId=").append(couponCodeId); sb.append(", couponCode=").append(couponCode); diff --git a/hai-service/src/main/java/com/hai/entity/HighCouponAgentCodeExample.java b/hai-service/src/main/java/com/hai/entity/HighCouponAgentCodeExample.java index 9b568b00..44123806 100644 --- a/hai-service/src/main/java/com/hai/entity/HighCouponAgentCodeExample.java +++ b/hai-service/src/main/java/com/hai/entity/HighCouponAgentCodeExample.java @@ -485,6 +485,76 @@ public class HighCouponAgentCodeExample { return (Criteria) this; } + public Criteria andConvertUserPhoneIsNull() { + addCriterion("convert_user_phone is null"); + return (Criteria) this; + } + + public Criteria andConvertUserPhoneIsNotNull() { + addCriterion("convert_user_phone is not null"); + return (Criteria) this; + } + + public Criteria andConvertUserPhoneEqualTo(String value) { + addCriterion("convert_user_phone =", value, "convertUserPhone"); + return (Criteria) this; + } + + public Criteria andConvertUserPhoneNotEqualTo(String value) { + addCriterion("convert_user_phone <>", value, "convertUserPhone"); + return (Criteria) this; + } + + public Criteria andConvertUserPhoneGreaterThan(String value) { + addCriterion("convert_user_phone >", value, "convertUserPhone"); + return (Criteria) this; + } + + public Criteria andConvertUserPhoneGreaterThanOrEqualTo(String value) { + addCriterion("convert_user_phone >=", value, "convertUserPhone"); + return (Criteria) this; + } + + public Criteria andConvertUserPhoneLessThan(String value) { + addCriterion("convert_user_phone <", value, "convertUserPhone"); + return (Criteria) this; + } + + public Criteria andConvertUserPhoneLessThanOrEqualTo(String value) { + addCriterion("convert_user_phone <=", value, "convertUserPhone"); + return (Criteria) this; + } + + public Criteria andConvertUserPhoneLike(String value) { + addCriterion("convert_user_phone like", value, "convertUserPhone"); + return (Criteria) this; + } + + public Criteria andConvertUserPhoneNotLike(String value) { + addCriterion("convert_user_phone not like", value, "convertUserPhone"); + return (Criteria) this; + } + + public Criteria andConvertUserPhoneIn(List values) { + addCriterion("convert_user_phone in", values, "convertUserPhone"); + return (Criteria) this; + } + + public Criteria andConvertUserPhoneNotIn(List values) { + addCriterion("convert_user_phone not in", values, "convertUserPhone"); + return (Criteria) this; + } + + public Criteria andConvertUserPhoneBetween(String value1, String value2) { + addCriterion("convert_user_phone between", value1, value2, "convertUserPhone"); + return (Criteria) this; + } + + public Criteria andConvertUserPhoneNotBetween(String value1, String value2) { + addCriterion("convert_user_phone not between", value1, value2, "convertUserPhone"); + return (Criteria) this; + } + public Criteria andConvertCodeIsNull() { addCriterion("convert_code is null"); return (Criteria) this; diff --git a/hai-service/src/main/java/com/hai/entity/HighCouponCodeOther.java b/hai-service/src/main/java/com/hai/entity/HighCouponCodeOther.java index 4de2daf8..d24ceb61 100644 --- a/hai-service/src/main/java/com/hai/entity/HighCouponCodeOther.java +++ b/hai-service/src/main/java/com/hai/entity/HighCouponCodeOther.java @@ -23,6 +23,11 @@ public class HighCouponCodeOther implements Serializable { */ private Integer type; + /** + * 代理商卡券销售码id + */ + private Long couponAgentCodeId; + /** * 订单id */ @@ -92,6 +97,14 @@ public class HighCouponCodeOther implements Serializable { this.type = type; } + public Long getCouponAgentCodeId() { + return couponAgentCodeId; + } + + public void setCouponAgentCodeId(Long couponAgentCodeId) { + this.couponAgentCodeId = couponAgentCodeId; + } + public Long getOrderId() { return orderId; } @@ -202,6 +215,7 @@ public class HighCouponCodeOther implements Serializable { HighCouponCodeOther other = (HighCouponCodeOther) that; return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) && (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType())) + && (this.getCouponAgentCodeId() == null ? other.getCouponAgentCodeId() == null : this.getCouponAgentCodeId().equals(other.getCouponAgentCodeId())) && (this.getOrderId() == null ? other.getOrderId() == null : this.getOrderId().equals(other.getOrderId())) && (this.getChildOrderId() == null ? other.getChildOrderId() == null : this.getChildOrderId().equals(other.getChildOrderId())) && (this.getCouTypeCode() == null ? other.getCouTypeCode() == null : this.getCouTypeCode().equals(other.getCouTypeCode())) @@ -222,6 +236,7 @@ public class HighCouponCodeOther implements Serializable { int result = 1; result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); result = prime * result + ((getType() == null) ? 0 : getType().hashCode()); + result = prime * result + ((getCouponAgentCodeId() == null) ? 0 : getCouponAgentCodeId().hashCode()); result = prime * result + ((getOrderId() == null) ? 0 : getOrderId().hashCode()); result = prime * result + ((getChildOrderId() == null) ? 0 : getChildOrderId().hashCode()); result = prime * result + ((getCouTypeCode() == null) ? 0 : getCouTypeCode().hashCode()); @@ -245,6 +260,7 @@ public class HighCouponCodeOther implements Serializable { sb.append("Hash = ").append(hashCode()); sb.append(", id=").append(id); sb.append(", type=").append(type); + sb.append(", couponAgentCodeId=").append(couponAgentCodeId); sb.append(", orderId=").append(orderId); sb.append(", childOrderId=").append(childOrderId); sb.append(", couTypeCode=").append(couTypeCode); diff --git a/hai-service/src/main/java/com/hai/entity/HighCouponCodeOtherExample.java b/hai-service/src/main/java/com/hai/entity/HighCouponCodeOtherExample.java index fb8b42fc..42cb8649 100644 --- a/hai-service/src/main/java/com/hai/entity/HighCouponCodeOtherExample.java +++ b/hai-service/src/main/java/com/hai/entity/HighCouponCodeOtherExample.java @@ -245,6 +245,66 @@ public class HighCouponCodeOtherExample { return (Criteria) this; } + public Criteria andCouponAgentCodeIdIsNull() { + addCriterion("coupon_agent_code_id is null"); + return (Criteria) this; + } + + public Criteria andCouponAgentCodeIdIsNotNull() { + addCriterion("coupon_agent_code_id is not null"); + return (Criteria) this; + } + + public Criteria andCouponAgentCodeIdEqualTo(Long value) { + addCriterion("coupon_agent_code_id =", value, "couponAgentCodeId"); + return (Criteria) this; + } + + public Criteria andCouponAgentCodeIdNotEqualTo(Long value) { + addCriterion("coupon_agent_code_id <>", value, "couponAgentCodeId"); + return (Criteria) this; + } + + public Criteria andCouponAgentCodeIdGreaterThan(Long value) { + addCriterion("coupon_agent_code_id >", value, "couponAgentCodeId"); + return (Criteria) this; + } + + public Criteria andCouponAgentCodeIdGreaterThanOrEqualTo(Long value) { + addCriterion("coupon_agent_code_id >=", value, "couponAgentCodeId"); + return (Criteria) this; + } + + public Criteria andCouponAgentCodeIdLessThan(Long value) { + addCriterion("coupon_agent_code_id <", value, "couponAgentCodeId"); + return (Criteria) this; + } + + public Criteria andCouponAgentCodeIdLessThanOrEqualTo(Long value) { + addCriterion("coupon_agent_code_id <=", value, "couponAgentCodeId"); + return (Criteria) this; + } + + public Criteria andCouponAgentCodeIdIn(List values) { + addCriterion("coupon_agent_code_id in", values, "couponAgentCodeId"); + return (Criteria) this; + } + + public Criteria andCouponAgentCodeIdNotIn(List values) { + addCriterion("coupon_agent_code_id not in", values, "couponAgentCodeId"); + return (Criteria) this; + } + + public Criteria andCouponAgentCodeIdBetween(Long value1, Long value2) { + addCriterion("coupon_agent_code_id between", value1, value2, "couponAgentCodeId"); + return (Criteria) this; + } + + public Criteria andCouponAgentCodeIdNotBetween(Long value1, Long value2) { + addCriterion("coupon_agent_code_id not between", value1, value2, "couponAgentCodeId"); + return (Criteria) this; + } + public Criteria andOrderIdIsNull() { addCriterion("order_id is null"); return (Criteria) this; diff --git a/hai-service/src/main/java/com/hai/service/HighCouponAgentService.java b/hai-service/src/main/java/com/hai/service/HighCouponAgentService.java index 052070db..78cd9f89 100644 --- a/hai-service/src/main/java/com/hai/service/HighCouponAgentService.java +++ b/hai-service/src/main/java/com/hai/service/HighCouponAgentService.java @@ -125,6 +125,6 @@ public interface HighCouponAgentService { * @param code * @return */ - Map useConvertCode(String code); + Map useConvertCode(String phone, String code) throws Exception; } diff --git a/hai-service/src/main/java/com/hai/service/SecConfigService.java b/hai-service/src/main/java/com/hai/service/SecConfigService.java index 42dea3b1..55cfb33b 100644 --- a/hai-service/src/main/java/com/hai/service/SecConfigService.java +++ b/hai-service/src/main/java/com/hai/service/SecConfigService.java @@ -38,6 +38,14 @@ public interface SecConfigService { **/ 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); } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java index 39ecca0c..0997f502 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighCouponAgentServiceImpl.java @@ -1,5 +1,7 @@ package com.hai.service.impl; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import com.github.pagehelper.PageInfo; import com.hai.common.GenerateCode; import com.hai.common.exception.ErrorCode; @@ -7,10 +9,10 @@ import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.utils.DateUtil; import com.hai.common.utils.ResponseMsgUtil; -import com.hai.dao.HighCouponAgentCodeMapper; -import com.hai.dao.HighCouponAgentRecordMapper; -import com.hai.dao.HighCouponAgentRelMapper; +import com.hai.config.HuiLianTongConfig; +import com.hai.dao.*; import com.hai.entity.*; +import com.hai.enum_type.OrderPushType; import com.hai.model.AgentSalesModel; import com.hai.service.*; import org.apache.commons.collections4.MapUtils; @@ -55,6 +57,15 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { @Resource private HighAgentService highAgentService; + @Resource + private HuiLianTongConfig huiLianTongConfig; + + @Resource + private HighGasOrderPushMapper highGasOrderPushMapper; + + @Resource + private HighCouponCodeOtherMapper highCouponCodeOtherMapper; + @Override @Transactional(propagation= Propagation.REQUIRES_NEW) public void assignCouponAgent(HighCouponAgentRel highCouponAgentRel,Integer stockCount) { @@ -411,7 +422,7 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { @Override @Transactional(propagation= Propagation.REQUIRES_NEW,isolation= Isolation.SERIALIZABLE) - public Map useConvertCode(String code) { + public Map useConvertCode(String phone, String code) throws Exception { // 查询兑换码 HighCouponAgentCode convertCode = getConvertCode(code); if (convertCode == null) { @@ -423,21 +434,85 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { if (convertCode.getCouponCodeId() != null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "兑换码已被使用"); } - // 查询未销售的卡券 - List codeList = highCouponCodeService.getNoSaleCode(convertCode.getCouponId()); - if (codeList.size() == 0) { + // 查询卡券 + HighCoupon coupon = highCouponService.getCouponById(convertCode.getCouponId()); + if (coupon == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的卡券"); + } + if (!coupon.getStatus().equals(2)) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂时无法使用兑换码"); } - HighCouponCode couponCode = codeList.get(0); - couponCode.setIsAssignAgent(true); - couponCode.setAgentId(convertCode.getAgentId()); - couponCode.setReceiveTime(new Date()); - couponCode.setStatus(2); - highCouponCodeService.updateCouponCode(couponCode); - - convertCode.setCouponCodeId(couponCode.getId()); - convertCode.setCouponCode(couponCode.getSalesCode()); - convertCode.setQrCode(couponCode.getExt1()); + // 卡券来源:1.中石化 2.消费券 3.其他 4:贵州中石化 + if (coupon.getCouponSource().equals(4)) { + if (StringUtils.isBlank(phone)) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "需要填写手机手机号"); + } + convertCode.setConvertUserPhone(phone); + convertCode.setCouponCode(System.currentTimeMillis()+""); + // 获取token + String token = huiLianTongConfig.getToken(); + + Map push = new HashMap<>(); + push.put("token", token); + push.put("orderNo", coupon.getCouponKey()); + push.put("couTypeCode", coupon.getCouponKey()); + push.put("distCouCount", 1); + push.put("userPhone", phone); + push.put("thirdUserId", phone); + + // 推送给高速 + JSONObject returnParam = HuiLianTongConfig.couJointDist(token, + MapUtils.getString(push, "orderNo"), + MapUtils.getString(push, "couTypeCode"), + MapUtils.getInteger(push, "distCouCount"), + MapUtils.getString(push, "userPhone"), + MapUtils.getString(push, "userPhone") + ); + + if (returnParam != null && returnParam.getString("result").equals("success")) { + JSONArray dataArray = returnParam.getJSONArray("data"); + for (Object data : dataArray) { + JSONObject dataObject = (JSONObject) data; + HighCouponCodeOther couponCodeOther = new HighCouponCodeOther(); + couponCodeOther.setType(1); + couponCodeOther.setCouponAgentCodeId(convertCode.getId()); + couponCodeOther.setCouTypeCode(dataObject.getString("couTypeCode")); + couponCodeOther.setCouNo(dataObject.getString("couNo")); + couponCodeOther.setActiveTime(dataObject.getDate("activeTime")); + couponCodeOther.setValidStartDate(dataObject.getDate("validStartDate")); + couponCodeOther.setValidEndDate(dataObject.getDate("validEndDate")); + couponCodeOther.setStatus(20); + couponCodeOther.setCreateTime(new Date()); + highCouponCodeOtherMapper.insert(couponCodeOther); + } + } + // 推送记录 + HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); + highGasOrderPush.setType(OrderPushType.type6.getType()); + highGasOrderPush.setOrderNo(convertCode.getCouponCode()); + highGasOrderPush.setCreateTime(new Date()); + highGasOrderPush.setCode(returnParam.getString("result")); + highGasOrderPush.setRequestContent(JSONObject.toJSONString(push)); + highGasOrderPush.setReturnContent(returnParam.toJSONString()); + highGasOrderPushMapper.insert(highGasOrderPush); + + } else { + // 查询未销售的卡券 + List codeList = highCouponCodeService.getNoSaleCode(convertCode.getCouponId()); + if (codeList.size() == 0) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂时无法使用兑换码"); + } + HighCouponCode couponCode = codeList.get(0); + couponCode.setIsAssignAgent(true); + couponCode.setAgentId(convertCode.getAgentId()); + couponCode.setReceiveTime(new Date()); + couponCode.setStatus(2); + highCouponCodeService.updateCouponCode(couponCode); + + convertCode.setCouponCodeId(couponCode.getId()); + convertCode.setCouponCode(couponCode.getSalesCode()); + convertCode.setQrCode(couponCode.getExt1()); + } convertCode.setStatus(3); highCouponAgentCodeMapper.updateByPrimaryKey(convertCode); @@ -447,5 +522,6 @@ public class HighCouponAgentServiceImpl implements HighCouponAgentService { map.put("couponCode", highCouponCodeService.getCouponCodeById(convertCode.getCouponCodeId())); map.put("couponAgentCode", convertCode); return map; + } } diff --git a/hai-service/src/main/resources/prod-9401/commonConfig.properties b/hai-service/src/main/resources/prod-9401/commonConfig.properties index 3b3d8351..49e2f939 100644 --- a/hai-service/src/main/resources/prod-9401/commonConfig.properties +++ b/hai-service/src/main/resources/prod-9401/commonConfig.properties @@ -1,8 +1,12 @@ tuanYouUrl=https://hcs.czb365.com -tuanYouAppKey=210091174083104 -tuanYouAppSecret=f9811df6791d309bf48f4a8db9edaa45 -tuanYouDieselAccount=9hp52qgg4400 -tuanYouGasolineAccount=9hp52qf04400 +# tuanYouAppKey=210091174083104 +# tuanYouAppSecret=f9811df6791d309bf48f4a8db9edaa45 +# tuanYouDieselAccount=9hp52qgg4400 +# tuanYouGasolineAccount=9hp52qf04400 +tuanYouAppKey=232373843366592 +tuanYouAppSecret=b07cca748a3b83e27e4821d2a8423d91 +tuanYouDieselAccount=c2qitcag4400 +tuanYouGasolineAccount=c2qitc984400 qinzhuUrl=https://live.qianzhu8.com qinzhuHtmlUrl=https://qz.dctpay.com diff --git a/hai-service/src/main/resources/prod/commonConfig.properties b/hai-service/src/main/resources/prod/commonConfig.properties index 199ba1ae..685edb95 100644 --- a/hai-service/src/main/resources/prod/commonConfig.properties +++ b/hai-service/src/main/resources/prod/commonConfig.properties @@ -1,8 +1,12 @@ tuanYouUrl=https://hcs.czb365.com -tuanYouAppKey=210091174083104 -tuanYouAppSecret=f9811df6791d309bf48f4a8db9edaa45 -tuanYouDieselAccount=9hp52qgg4400 -tuanYouGasolineAccount=9hp52qf04400 +# tuanYouAppKey=210091174083104 +# tuanYouAppSecret=f9811df6791d309bf48f4a8db9edaa45 +# tuanYouDieselAccount=9hp52qgg4400 +# tuanYouGasolineAccount=9hp52qf04400 +tuanYouAppKey=232373843366592 +tuanYouAppSecret=b07cca748a3b83e27e4821d2a8423d91 +tuanYouDieselAccount=c2qitcag4400 +tuanYouGasolineAccount=c2qitc984400 qinzhuUrl=https://live.qianzhu8.com qinzhuHtmlUrl=https://qz.dctpay.com