| @@ -163,6 +163,7 @@ public class WxCarController extends BaseController { | |||
| if (!StringUtils.isBlank(vendorPersonId)) { | |||
| resultMap.put("vendorPersonId", vendorPersonId); | |||
| } | |||
| resultMap.put("supportPay", park.getSupportPay()); | |||
| return new ResultData(resultMap); | |||
| } catch (Exception e) { | |||
| logger.error("park init error",e); | |||
| @@ -450,7 +451,9 @@ public class WxCarController extends BaseController { | |||
| try { | |||
| //创建车场支付订单 | |||
| ParkCreatePayOrder payOrder = parkFactory.getParkService(park.getVendorType()).createPayOrder(paramMap, park,carNumber); | |||
| if (null == payOrder || StringUtils.isBlank(payOrder.getUniqueParkOrderNumber())) { | |||
| EnumCarVendor carVendor = EnumCarVendor.getEnum(park.getVendorType()); | |||
| String uniquePayOrderNo = ParkCreatePayOrder.getUniqueParkOrderNumber(payOrder.getParkOrderNumber(), carVendor); | |||
| if (null == payOrder || StringUtils.isBlank(uniquePayOrderNo)) { | |||
| return new ResultData(Result.ERROR,"创建车场订单错误."); | |||
| } | |||
| if (payOrder.getFee() <= 0 ) { | |||
| @@ -490,7 +493,7 @@ public class WxCarController extends BaseController { | |||
| new ResultData(Result.ERROR,ErrorCode.API_KEY_NOT_FOUND.name()); | |||
| } | |||
| //创建微信支付订单 | |||
| PayAdapterResult wxResult = wxParkPayService.createWxPayOrder(user.getOpenId(), user.getAppId(), receiver.getReceiverAccount(), "停车费支付", attachSb.toString(), payOrder.getUniqueParkOrderNumber(), payOrder.getFee(), | |||
| PayAdapterResult wxResult = wxParkPayService.createWxPayOrder(user.getOpenId(), user.getAppId(), receiver.getReceiverAccount(), "停车费支付", attachSb.toString(), uniquePayOrderNo, payOrder.getFee(), | |||
| "127.0.0.1", park.getPaidCallBack(), payAccount.getApiKey(), new Date()); | |||
| return new ResultData(wxResult); | |||
| } catch (Exception e) { | |||
| @@ -0,0 +1,111 @@ | |||
| package com.iformall.controller.callback.car.fute; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.controller.callback.car.WxParkCallBackBaseController; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.vo.WxCarCYFVo; | |||
| import com.iformall.enums.EnumCarCmd; | |||
| import com.iformall.enums.EnumCarVendor; | |||
| import com.iformall.enums.EnumCouponSendSendType; | |||
| import com.iformall.enums.EnumPayWay; | |||
| import com.iformall.service.*; | |||
| import com.iformall.service.park.impl.cyf.CYFUtil; | |||
| import com.iformall.service.park.impl.tjd.TJDUtil; | |||
| import lombok.extern.slf4j.Slf4j; | |||
| import org.apache.commons.collections.CollectionUtils; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.PostMapping; | |||
| import org.springframework.web.bind.annotation.RequestBody; | |||
| import org.springframework.web.bind.annotation.RequestMapping; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| import java.util.Date; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| /** | |||
| * @author: furunxin | |||
| * @Date: 2020/7/6 15:29 | |||
| * @Description: 车易付回调接口 | |||
| */ | |||
| @Slf4j | |||
| @RestController | |||
| @RequestMapping("/futeCarCallback") | |||
| public class WxCarFuteCallBackController extends WxParkCallBackBaseController { | |||
| @Autowired | |||
| WxParkService wxParkService; | |||
| @Autowired | |||
| WxCarCmdLogService wxCarCmdLogService; | |||
| @Autowired | |||
| WxCUserService wxCUserService; | |||
| @Autowired | |||
| WxCUserCarService wxCUserCarService; | |||
| @Autowired | |||
| WxCouponSendService wxCouponSendService; | |||
| @Autowired | |||
| WxCarPayRecordService wxCarPayRecordService; | |||
| @Autowired | |||
| WxCUserBasicInfoService wxCUserBasicInfoService; | |||
| /** | |||
| * @description 捷顺 车辆入场通知 | |||
| * {dataItems=[{"inTime":"2020-12-09 11:21:15","carNumber":"浙-AF81797","inCarPhoto":"p201127315/NISSP_IMG_PARK_IN/20201209/a9f1130651b9493f8eab64f14afbdd47","isReal":0,"itemId":"a9f1130651b9493f8eab64f14afbdd47","inOperator":"超级管理员","equipName":"东门入口","parkName":"杭州东站西子国际","vehicleInfo":"{\"plateNo\":\"浙-AF81797\",\"plateColor\":\"GREEN\",\"plateBackColor\":0,\"plateWordColor\":0,\"vehicleColor\":null,\"vehicleLogo\":null,\"vehicleModel\":null,\"mainModel\":0,\"subModel\":0,\"vehicleModelTrust\":0,\"mainModelTrust\":0,\"subModelTrust\":0,\"plateNoTrust\":1,\"vehicleLogoTrust\":0,\"vehicleColorTrust\":0}","equipCode":"208202496","parkCode":"p201127315"}], pno=dzxzgj, sn=6C958D99D2769AA16F3A3F06E962263F, tn=-2, ts=20201209112118886, ve=1.0} | |||
| * | |||
| * | |||
| * | |||
| * @Params [paramMap] | |||
| * @return com.iformall.common.Result | |||
| * @Author furunxin | |||
| * @Date 2020/7/8 上午8:27 | |||
| **/ | |||
| @PostMapping(value = "/parkIn") | |||
| public Result parkInCallback(@RequestBody Map<String, Object> paramMap) { | |||
| log.info("["+getIpAddr()+"] futeCarCallback parkIn: " + paramMap.toString()); | |||
| //解析车易付参数 | |||
| return super.parkInCallBack(EnumCarVendor.CAR_FUTE, EnumCarCmd.CAR_FUTE_CALLBACK_PARK_IN, paramMap); | |||
| } | |||
| /** | |||
| * @description 车易付 车辆离场通知 | |||
| * @Params [param] | |||
| * @return java.util.Map | |||
| * @Author furunxin | |||
| * @Date 2020/7/12 上午9:00 | |||
| **/ | |||
| @PostMapping(value = "/parkOut") | |||
| public Result parkOutCallback(@RequestBody Map<String, Object> paramMap) { | |||
| log.info("["+getIpAddr()+"] futeCarCallback parkOut: " + paramMap.toString()); | |||
| return super.parkOutCallBack(EnumCarVendor.CAR_FUTE, EnumCarCmd.CAR_FUTE_CALLBACK_PARK_OUT, paramMap); | |||
| } | |||
| @PostMapping(value = "/unbind") | |||
| public Result unbindCallback(@RequestBody Map<String, Object> paramMap) { | |||
| log.info("["+getIpAddr()+"] futeCarCallback unbind: " + paramMap.toString()); | |||
| //解析车易付参数 | |||
| return super.unbindCarCallBack(EnumCarVendor.CAR_FUTE, EnumCarCmd.CAR_FUTE_CALLBACK_UNBIND, paramMap); | |||
| } | |||
| @PostMapping(value = "/paid") | |||
| public Result paidCallback(@RequestBody Map<String, Object> paramMap) { | |||
| log.info("["+getIpAddr()+"] futeCarCallback paid: " + paramMap.toString()); | |||
| //解析车易付参数 | |||
| return super.paidCallback(EnumCarVendor.CAR_FUTE, EnumCarCmd.CAR_FUTE_CALLBACK_PAID, paramMap); | |||
| } | |||
| } | |||
| @@ -6,6 +6,8 @@ import com.iformall.domain.po.WxActivityJoin; | |||
| import com.iformall.domain.po.WxCampaign; | |||
| import com.iformall.domain.po.WxCarPayOrder; | |||
| import com.iformall.domain.po.WxMall; | |||
| import com.iformall.domain.po.WxPark; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.msg.WxMsgRecord; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.mapper.WxActivityJoinMapper; | |||
| @@ -14,7 +16,9 @@ import com.iformall.mapper.WxCampaignMapper; | |||
| import com.iformall.mapper.WxCarPayOrderMapper; | |||
| import com.iformall.mapper.WxMallMapper; | |||
| import com.iformall.mq.MqBaseProducer; | |||
| import com.iformall.service.WxParkService; | |||
| import com.iformall.service.park.ParkFactory; | |||
| import com.iformall.service.park.entity.ParkCreatePayOrder; | |||
| import com.iformall.service.park.entity.ParkNotifyPaid; | |||
| import com.iformall.utils.DateUtils; | |||
| import org.apache.commons.collections.map.HashedMap; | |||
| @@ -48,10 +52,20 @@ public class CarPaidNotifySchedule { | |||
| @Autowired | |||
| ParkFactory parkFactory; | |||
| @Autowired | |||
| WxParkService wxParkService; | |||
| private List<WxMall> getMalls() { | |||
| WxMall wxMall = new WxMall(); | |||
| return wxMallMapper.findList(wxMall); | |||
| } | |||
| private WxPark getCurrentPark(TenantEntity tenantEntity) { | |||
| WxPark parkQ = new WxPark(); | |||
| parkQ.updateTenantInfo(tenantEntity); | |||
| WxPark wxPark = wxParkService.getByObj(parkQ); | |||
| return wxPark; | |||
| } | |||
| /** | |||
| * 5分钟执行一次 | |||
| @@ -61,6 +75,7 @@ public class CarPaidNotifySchedule { | |||
| public void sendMsg() { | |||
| List<WxMall> malls = getMalls(); | |||
| for (WxMall mall : malls) { | |||
| WxPark wxPark = getCurrentPark(mall); | |||
| WxCarPayOrder payOrder = new WxCarPayOrder(); | |||
| payOrder.updateTenantInfo(mall); | |||
| payOrder.setNotifyCountLimit(10); | |||
| @@ -71,7 +86,8 @@ public class CarPaidNotifySchedule { | |||
| WxCarPayOrder _po = orderList.get(i); | |||
| //通知车场支付成功 | |||
| try { | |||
| parkFactory.getParkService(_po.getCarVendor()).notifyPaid(new ParkNotifyPaid(_po.getTenantId(), _po.getParkOrderNo(), _po.getPayAmount(), _po.getPayTime())); | |||
| String payOrderNo = ParkCreatePayOrder.getUniqueParkOrderNumber(_po.getParkOrderNo(), EnumCarVendor.getEnum(_po.getCarVendor())); | |||
| parkFactory.getParkService(_po.getCarVendor()).notifyPaid(wxPark,new ParkNotifyPaid(_po.getTenantId(),payOrderNo,_po.getParkOrderNo(), _po.getPayAmount(), _po.getPayTime())); | |||
| payOrder.setParkNotify(EnumYesOrNo.YES.getCode()); | |||
| payOrder.setUpdateTime(new Date()); | |||
| payOrder.setNotifyCount(payOrder.getNotifyCount()+1); | |||
| @@ -34,7 +34,12 @@ public enum EnumCarCmd { | |||
| CAR_HAIKANGWEISHI_CALLBACK_PARK_IN(628,"海康进场通知"), | |||
| CAR_HAIKANGWEISHI_CALLBACK_PARK_OUT(629,"海康出场通知"), | |||
| CAR_HAIKANGWEISHI_CALLBACK_UNBIND(630,"海康解绑车牌通知"), | |||
| CAR_HAIKANGWEISHI_CALLBACK_PAID(631,"海康支付通知") | |||
| CAR_HAIKANGWEISHI_CALLBACK_PAID(631,"海康支付通知"), | |||
| CAR_FUTE_CALLBACK_PARK_IN(628,"福特进场通知"), | |||
| CAR_FUTE_CALLBACK_PARK_OUT(629,"福特出场通知"), | |||
| CAR_FUTE_CALLBACK_UNBIND(630,"福特解绑车牌通知"), | |||
| CAR_FUTE_CALLBACK_PAID(631,"福特支付通知") | |||
| ; | |||
| public static EnumCarCmd getEnum(Integer code) { | |||
| @@ -14,7 +14,8 @@ public enum EnumCarVendor { | |||
| CAR_BOLINK(5, "BoLink",false), | |||
| CAE_CYF(6,"CYF",false), | |||
| CAR_JIESHUN(7,"JIESHUN",true), | |||
| CAR_HAIKANGWEISHI(8,"HAIKANGWEISHI",true) | |||
| CAR_HAIKANGWEISHI(8,"HAIKANGWEISHI",true), | |||
| CAR_FUTE(9,"FUTE",false)//深圳市福特智能科技有限公司 | |||
| ; | |||
| public static EnumCarVendor getEnum(Integer code) { | |||
| @@ -62,7 +62,7 @@ public interface ParkAdapterService { | |||
| /** | |||
| * 停车订单成功通知车场 | |||
| */ | |||
| void notifyPaid(ParkNotifyPaid notifyPaid) throws Exception; | |||
| void notifyPaid(WxPark park,ParkNotifyPaid notifyPaid) throws Exception; | |||
| /** | |||
| * 查询停车场状态, 给老的集成用 | |||
| @@ -13,6 +13,8 @@ import com.iformall.service.park.impl.bolink.BoLinkParkService; | |||
| import com.iformall.service.park.impl.cyf.CYFParkCallbackService; | |||
| import com.iformall.service.park.impl.cyf.CYFParkService; | |||
| import com.iformall.service.park.impl.dahua.DaHuaParkService; | |||
| import com.iformall.service.park.impl.fute.FuteParkCallbackService; | |||
| import com.iformall.service.park.impl.fute.FuteParkService; | |||
| import com.iformall.service.park.impl.haikangweishi.HaiKangWeiShiParkCallbackService; | |||
| import com.iformall.service.park.impl.haikangweishi.HaiKangWeiShiParkService; | |||
| import com.iformall.service.park.impl.jieshun.JieShunParkCallbackService; | |||
| @@ -37,6 +39,8 @@ public class ParkFactory { | |||
| JieShunParkService jieshunService; | |||
| @Autowired | |||
| HaiKangWeiShiParkService haikangWeishiService; | |||
| @Autowired | |||
| FuteParkService futeParkService; | |||
| @Autowired | |||
| CYFParkCallbackService cyfCallbackService; | |||
| @@ -44,6 +48,8 @@ public class ParkFactory { | |||
| JieShunParkCallbackService jieshunCallBackService; | |||
| @Autowired | |||
| HaiKangWeiShiParkCallbackService haikangWeishiCallBackService; | |||
| @Autowired | |||
| FuteParkCallbackService futeParkCallbackService; | |||
| private Map<Integer,ParkAdapterService> parkServiceMap ; | |||
| private Map<Integer,EnumCarVendor> enumMap ; | |||
| @@ -63,6 +69,7 @@ public class ParkFactory { | |||
| parkServiceMap.put(EnumCarVendor.CAR_TJD.getCode(), tjdService); | |||
| parkServiceMap.put(EnumCarVendor.CAR_JIESHUN.getCode(), jieshunService); | |||
| parkServiceMap.put(EnumCarVendor.CAR_HAIKANGWEISHI.getCode(), haikangWeishiService); | |||
| parkServiceMap.put(EnumCarVendor.CAR_FUTE.getCode(), futeParkService); | |||
| return parkServiceMap; | |||
| } | |||
| @@ -84,6 +91,7 @@ public class ParkFactory { | |||
| } | |||
| callBackServiceMap = new ConcurrentHashMap<Integer, ParkCallBackAdapterService>(); | |||
| callBackServiceMap.put(EnumCarVendor.CAE_CYF.getCode(), cyfCallbackService); | |||
| callBackServiceMap.put(EnumCarVendor.CAR_FUTE.getCode(), futeParkCallbackService); | |||
| return callBackServiceMap; | |||
| } | |||
| @@ -9,16 +9,12 @@ public class ParkCreatePayOrder implements Serializable{ | |||
| private static final long serialVersionUID = 5585069626450856545L; | |||
| private EnumCarVendor carVendor; | |||
| /*停车场返回的订单ID**/ | |||
| private String parkOrderNumber=""; | |||
| /*停车费**/ | |||
| private Integer fee; | |||
| public ParkCreatePayOrder(EnumCarVendor carVendor,String parkOrderNumber,Integer fee) { | |||
| this.carVendor = carVendor; | |||
| public ParkCreatePayOrder(String parkOrderNumber,Integer fee) { | |||
| if (!StringUtils.isBlank(parkOrderNumber)) { | |||
| this.parkOrderNumber = parkOrderNumber; | |||
| } | |||
| @@ -27,15 +23,22 @@ public class ParkCreatePayOrder implements Serializable{ | |||
| } | |||
| } | |||
| public String getUniqueParkOrderNumber() { | |||
| public Integer getFee() { | |||
| return fee; | |||
| } | |||
| public String getParkOrderNumber() { | |||
| return parkOrderNumber; | |||
| } | |||
| public static String getUniqueParkOrderNumber(String parkOrderNumber,EnumCarVendor carVendor) { | |||
| if (!StringUtils.isBlank(parkOrderNumber)) { | |||
| return carVendor.getMessage()+"_"+parkOrderNumber; | |||
| } | |||
| return null; | |||
| } | |||
| public Integer getFee() { | |||
| return fee; | |||
| } | |||
| public static String getRealParkOrderNumber(String uniqueParkOrderNumber,EnumCarVendor carVendor) { | |||
| return uniqueParkOrderNumber.replaceFirst(carVendor.getMessage()+"_", ""); | |||
| } | |||
| } | |||
| @@ -19,7 +19,9 @@ public class ParkNotifyPaid implements Serializable{ | |||
| /*停车场返回的订单ID**/ | |||
| private String tenantId; | |||
| /*停车场订单**/ | |||
| /*订单编号**/ | |||
| private String payOrderNo; | |||
| /*停车场订单编号**/ | |||
| private String parkOrderNo; | |||
| /*支付金额**/ | |||
| private Integer fee; | |||
| @@ -27,7 +27,7 @@ public class ParkStopFee implements Serializable{ | |||
| /*给支付小程序的额外数据**/ | |||
| private Map extraData=new HashMap(); | |||
| /*备注**/ | |||
| private String remark=""; | |||
| private String remark="";//车场有可能返回的提示信息 | |||
| private String sysNotice="";//系统提示,非车厂提示; | |||
| @@ -122,7 +122,7 @@ public class BoLinkParkService extends BaseParkService implements ParkAdapterSer | |||
| } | |||
| @Override | |||
| public void notifyPaid(ParkNotifyPaid notifyPaid) | |||
| public void notifyPaid(WxPark park,ParkNotifyPaid notifyPaid) | |||
| throws Exception { | |||
| } | |||
| @@ -205,7 +205,7 @@ public class CYFParkService extends BaseParkService implements ParkAdapterServic | |||
| } | |||
| @Override | |||
| public void notifyPaid(ParkNotifyPaid notifyPaid) throws Exception { | |||
| public void notifyPaid(WxPark park,ParkNotifyPaid notifyPaid) throws Exception { | |||
| } | |||
| } | |||
| @@ -88,7 +88,7 @@ public class DaHuaParkService extends BaseParkService implements ParkAdapterServ | |||
| } | |||
| @Override | |||
| public void notifyPaid(ParkNotifyPaid notifyPaid) throws Exception { | |||
| public void notifyPaid(WxPark park,ParkNotifyPaid notifyPaid) throws Exception { | |||
| } | |||
| } | |||
| @@ -0,0 +1,111 @@ | |||
| package com.iformall.service.park.impl.fute; | |||
| import java.text.ParseException; | |||
| import java.util.ArrayList; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.alibaba.fastjson.JSONArray; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.domain.po.WxCarJSOrder; | |||
| import com.iformall.domain.po.WxPark; | |||
| import com.iformall.domain.vo.WxCarCYFVo; | |||
| import com.iformall.enums.EnumCarVendor; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.WxCarJSOrderMapper; | |||
| import com.iformall.service.WxParkService; | |||
| import com.iformall.service.park.ParkBatchCallBackAdapterService; | |||
| import com.iformall.service.park.ParkCallBackAdapterService; | |||
| import com.iformall.service.park.entity.ParkNotifyParam; | |||
| import com.iformall.service.park.impl.BaseParkService; | |||
| import lombok.extern.slf4j.Slf4j; | |||
| @Slf4j | |||
| @Service | |||
| public class FuteParkCallbackService extends BaseParkService implements ParkCallBackAdapterService { | |||
| @Autowired | |||
| WxParkService wxParkService; | |||
| /** | |||
| * {dataItems=[{"inTime":"2020-12-09 11:21:15","carNumber":"浙-AF81797","inCarPhoto":"p201127315/NISSP_IMG_PARK_IN/20201209/a9f1130651b9493f8eab64f14afbdd47","isReal":0,"itemId":"a9f1130651b9493f8eab64f14afbdd47","inOperator":"超级管理员","equipName":"东门入口","parkName":"杭州东站西子国际","vehicleInfo":"{\"plateNo\":\"浙-AF81797\",\"plateColor\":\"GREEN\",\"plateBackColor\":0,\"plateWordColor\":0,\"vehicleColor\":null,\"vehicleLogo\":null,\"vehicleModel\":null,\"mainModel\":0,\"subModel\":0,\"vehicleModelTrust\":0,\"mainModelTrust\":0,\"subModelTrust\":0,\"plateNoTrust\":1,\"vehicleLogoTrust\":0,\"vehicleColorTrust\":0}","equipCode":"208202496","parkCode":"p201127315"}], pno=dzxzgj, sn=6C958D99D2769AA16F3A3F06E962263F, tn=-2, ts=20201209112118886, ve=1.0} | |||
| */ | |||
| @Override | |||
| public ParkNotifyParam parseInNoticyParam(Object param) { | |||
| Map<String,Object> paramMap = (Map<String, Object>) param; | |||
| String carNumber = paramMap.get("car_number").toString(); | |||
| String parkCode = paramMap.get("park_id").toString(); | |||
| String parkName = ""; | |||
| String synId = paramMap.get("order_id").toString(); | |||
| Long inTime = (Long)paramMap.get("in_time"); | |||
| ParkNotifyParam p = new ParkNotifyParam(); | |||
| p.setCarNumber(carNumber); | |||
| p.setParkId(parkCode); | |||
| p.setParkName(parkName); | |||
| p.setSynId(synId); | |||
| try { | |||
| p.setEntranceTime(new Date(inTime)); | |||
| } catch (Exception e) { | |||
| log.error("fute entranceTime format error",e); | |||
| return null; | |||
| } | |||
| return p; | |||
| } | |||
| @Override | |||
| public ParkNotifyParam parseOutNoticyParam(Object param) { | |||
| Map<String,Object> paramMap = (Map<String, Object>) param; | |||
| String carNumber = paramMap.get("car_number").toString(); | |||
| String parkCode = paramMap.get("park_id").toString(); | |||
| String parkName = ""; | |||
| String synId = paramMap.get("order_id").toString(); | |||
| Long inTime = (Long)paramMap.get("in_time"); | |||
| Long outTime = (Long)paramMap.get("out_time"); | |||
| ParkNotifyParam p = new ParkNotifyParam(); | |||
| p.setCarNumber(carNumber); | |||
| p.setParkId(parkCode); | |||
| p.setParkName(parkName); | |||
| p.setSynId(synId); | |||
| try { | |||
| p.setEntranceTime(new Date(inTime)); | |||
| } catch (Exception e) { | |||
| log.error("fute entranceTime format error",e); | |||
| return null; | |||
| } | |||
| try { | |||
| p.setOutTime(new Date(outTime)); | |||
| } catch (Exception e) { | |||
| log.error("fute outTime format error",e); | |||
| return null; | |||
| } | |||
| p.setFee(String.valueOf(paramMap.get("amount_receivable"))); | |||
| return p; | |||
| } | |||
| @Override | |||
| public ParkNotifyParam parseUnbindNoticyParam(Object param) { | |||
| return null; | |||
| } | |||
| @Override | |||
| public ParkNotifyParam parsePaidNoticyParam(Object param) { | |||
| return null; | |||
| } | |||
| } | |||
| @@ -0,0 +1,178 @@ | |||
| package com.iformall.service.park.impl.fute; | |||
| import java.math.BigDecimal; | |||
| import java.util.Date; | |||
| import java.util.HashMap; | |||
| import java.util.Map; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.beans.factory.annotation.Qualifier; | |||
| import org.springframework.data.redis.core.RedisTemplate; | |||
| import org.springframework.stereotype.Service; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.alibaba.fastjson.JSONArray; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxCUserBasicInfo; | |||
| import com.iformall.domain.po.WxCarJSOrder; | |||
| import com.iformall.domain.po.WxCoupon; | |||
| import com.iformall.domain.po.WxPark; | |||
| import com.iformall.domain.vo.WxCouponOrderCarCVo; | |||
| import com.iformall.domain.vo.WxParkCouponConfig; | |||
| import com.iformall.enums.EnumCarVendor; | |||
| import com.iformall.enums.EnumCouponUnit; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.WxCarJSOrderMapper; | |||
| import com.iformall.service.WxParkService; | |||
| import com.iformall.service.park.ParkAdapterService; | |||
| import com.iformall.service.park.entity.ParkCreatePayOrder; | |||
| import com.iformall.service.park.entity.ParkNotifyPaid; | |||
| import com.iformall.service.park.entity.ParkStopFee; | |||
| import com.iformall.service.park.impl.BaseParkService; | |||
| import com.iformall.service.park.impl.util.ParkHelper; | |||
| import com.iformall.service.park.utils.ParkCacheUtils; | |||
| import com.iformall.utils.RedisCacheUtils; | |||
| import com.iformall.utils.RedisLock; | |||
| /** | |||
| * 福特停车 | |||
| * | |||
| */ | |||
| @Service | |||
| public class FuteParkService extends BaseParkService implements ParkAdapterService { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| ParkHelper parkHelper; | |||
| @Autowired | |||
| @Qualifier("objectCommonRedisTemplate") | |||
| RedisTemplate<String, Object> redisTemplate; | |||
| @Autowired | |||
| RedisLock redisLock; | |||
| FuteUtil fute = new FuteUtil(); | |||
| @Override | |||
| public ResultData parkInitConfig(WxPark park) throws Exception { | |||
| return null; | |||
| } | |||
| @Override | |||
| public String initLogin(Map<String, String> paramMap, WxPark park, WxCUserBasicInfo member) throws Exception{ | |||
| return null; | |||
| } | |||
| @Override | |||
| public String bindCar(Map<String, String> paramMap, WxPark park, WxCUserBasicInfo member) throws Exception{ | |||
| return "fute"; | |||
| } | |||
| @Override | |||
| public void unbindCar(Map<String, String> paramMap, WxPark park, WxCUserBasicInfo member) throws Exception{ | |||
| } | |||
| /** | |||
| * 每一次查询都会产生订单,然后根据订单号查询 | |||
| */ | |||
| @Override | |||
| public ParkStopFee carStopFee(Map<String, String> paramMap, WxPark park,String carNumber) throws Exception{ | |||
| //如果车牌号是鄂AAAAAA, 为测试车牌 | |||
| if (carNumber.equals("鄂AAAAAA")) { | |||
| return new ParkStopFee("-111",fute.utcToLocal("2020-12-16 00:00:00"),fute.utcToLocal("2020-12-17 00:00:00"), | |||
| "0.01",null,"payPath",null,"测试车牌,仅测试用",null); | |||
| }else if(carNumber.equals("鄂AAAAAB")) { | |||
| throw new MallinkException(21000,"车辆未入场"); | |||
| } | |||
| String retCode = fute.getCarStopFee(park, carNumber); | |||
| if (StringUtils.isBlank(retCode)) { | |||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(), "fute getCarStopFee error. has no result"); | |||
| } | |||
| JSONObject result = JSON.parseObject(retCode); | |||
| if (result.getInteger("state") != 1 ) { | |||
| String message = result.getString("errmsg"); | |||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(), "fute getCarStopFee error."+message); | |||
| } | |||
| return new ParkStopFee(result.getString("parking_order_id"),fute.utcToLocal(result.getString("intime")),fute.utcToLocal(result.getString("outtime")), | |||
| result.getString("price"),"appId","payPath",null,null,null); | |||
| } | |||
| /** | |||
| * @return | |||
| */ | |||
| @Override | |||
| public ResultData useCoupon(Map<String, String> paramMap, WxPark park, WxCouponOrderCarCVo userCar,WxCoupon coupon,String carNumber) throws Exception{ | |||
| if (null == userCar) { | |||
| return new ResultData(ErrorCode.CYF_STOP_FEE_FAIL.getCode(),"当前用户未查询到优惠券!"); | |||
| } | |||
| if (StringUtils.isBlank(userCar.getCUserPhone())) { | |||
| return new ResultData(ErrorCode.CYF_STOP_FEE_FAIL.getCode(),"当前用户未查询到手机号!"+userCar.getcUserId()); | |||
| } | |||
| Map<String,String> valueMap = WxParkCouponConfig.parseValue(userCar.getVendorParams()); | |||
| if (null == valueMap) { | |||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY.getCode(),"当前停车券没有关联停车场优惠券配置。"+coupon.getTitle()); | |||
| } | |||
| //String orderNo = paramMap.get("parkOrderId"); | |||
| String couponNo = valueMap.get("couponNo"); | |||
| if (StringUtils.isBlank(couponNo)) { | |||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY.getCode(),"当前停车券没有关联停车场优惠券配置[couponNo]。"+coupon.getTitle()); | |||
| } | |||
| String ret = fute.useCoupon(park, couponNo, carNumber); | |||
| //打折登陆验证 | |||
| logger.info("fute useCoupon result:"+ret); | |||
| JSONObject retObj = JSON.parseObject(ret); | |||
| if (retObj.getIntValue("state") == 1){ | |||
| return new ResultData(); | |||
| }else { | |||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY.getCode(),"当前用户使用福特优惠券失败。"+retObj.getString("errmsg")); | |||
| } | |||
| } | |||
| @Override | |||
| public ParkCreatePayOrder createPayOrder(Map<String, String> paramMap, WxPark park, String carNumber) throws Exception { | |||
| String retCode = fute.getCarStopFee(park, carNumber); | |||
| if (StringUtils.isBlank(retCode)) { | |||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(), "fute getCarStopFee error. has no result"); | |||
| } | |||
| JSONObject result = JSON.parseObject(retCode); | |||
| if (result.getInteger("state") != 1 ) { | |||
| String message = result.getString("errmsg"); | |||
| throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(), "fute getCarStopFee error."+message); | |||
| } | |||
| String price = result.getString("price"); | |||
| Integer fee = new BigDecimal(price).multiply(new BigDecimal(100)).intValue(); | |||
| return new ParkCreatePayOrder(result.getString("parking_order_id"), fee); | |||
| } | |||
| @Override | |||
| public void notifyPaid(WxPark park,ParkNotifyPaid notifyPaid) throws Exception { | |||
| fute.notifyPaid(park, notifyPaid.getParkOrderNo(), notifyPaid.getFee()); | |||
| } | |||
| @Override | |||
| public ResultData getParkStatus(WxPark park) throws Exception{ | |||
| return new ResultData(); | |||
| } | |||
| @Override | |||
| public boolean ignoreUseCouponCache() { | |||
| return false; | |||
| } | |||
| } | |||
| @@ -0,0 +1,234 @@ | |||
| package com.iformall.service.park.impl.fute; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.domain.po.WxPark; | |||
| import com.iformall.exception.MallinkException; | |||
| import lombok.extern.slf4j.Slf4j; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.apache.http.Consts; | |||
| import org.apache.http.HttpEntity; | |||
| import org.apache.http.HttpResponse; | |||
| import org.apache.http.NameValuePair; | |||
| import org.apache.http.client.entity.UrlEncodedFormEntity; | |||
| import org.apache.http.client.methods.HttpPost; | |||
| import org.apache.http.entity.StringEntity; | |||
| import org.apache.http.impl.client.CloseableHttpClient; | |||
| import org.apache.http.impl.client.HttpClients; | |||
| import org.apache.http.message.BasicHeader; | |||
| import org.apache.http.message.BasicNameValuePair; | |||
| import org.apache.http.protocol.HTTP; | |||
| import org.apache.http.util.EntityUtils; | |||
| import java.io.IOException; | |||
| import java.io.UnsupportedEncodingException; | |||
| import java.math.BigDecimal; | |||
| import java.net.URLEncoder; | |||
| import java.security.MessageDigest; | |||
| import java.security.NoSuchAlgorithmException; | |||
| import java.text.ParseException; | |||
| import java.text.SimpleDateFormat; | |||
| import java.time.LocalDateTime; | |||
| import java.time.format.DateTimeFormatter; | |||
| import java.util.ArrayList; | |||
| import java.util.Collections; | |||
| import java.util.Date; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| import java.util.TimeZone; | |||
| /** | |||
| * @author: furunxin | |||
| * @Date: 2020/7/1 17:16 | |||
| * @Description: 车易付接口对接参数类 | |||
| */ | |||
| @Slf4j | |||
| public class FuteUtil { | |||
| public static final String QUERY_PRICE = "http://s1.appykt.com/zld/parkapi/query_price"; | |||
| public static final String COUPON_USE = "http://s1.appykt.com/zld/useTicket"; | |||
| public static final String NOTIFY_PAID = "http://s1.appykt.com/zld/parkapi/pay_notify"; | |||
| /** | |||
| * @description UTC时间转化为本地时间 | |||
| * @Params [utcTime] | |||
| * @return java.util.Date | |||
| * @Author furunxin | |||
| * @Date 2020/7/8 下午12:45 | |||
| **/ | |||
| public static Date utcToLocal(String seconds) throws ParseException { | |||
| String format = "yyyy-MM-dd HH:mm:ss"; | |||
| SimpleDateFormat sdf = new SimpleDateFormat(format); | |||
| Date date=sdf.parse(seconds); | |||
| return date; | |||
| } | |||
| /** | |||
| * 查询停车费 | |||
| **/ | |||
| public String getCarStopFee(WxPark wxPark,String carNumber){ | |||
| String vendroParams = wxPark.getVendorParams(); | |||
| JSONObject vp = JSON.parseObject(vendroParams); | |||
| Map param = new HashMap(); | |||
| param.put("access_type", "scan_center_pay");//scan_center_pay:中央缴费 scan_out_pay:出口支付 | |||
| param.put("carnum", carNumber); | |||
| param.put("parkid", wxPark.getParkingId()); | |||
| log.info("fute getCarStopFee :" + JSON.toJSONString(param)); | |||
| return ProcBussiness(QUERY_PRICE, param,vp.getString("signkey")); | |||
| } | |||
| /** | |||
| * 使用优惠券 | |||
| **/ | |||
| public String useCoupon(WxPark wxPark,String couponNo,String carNumber){ | |||
| String vendroParams = wxPark.getVendorParams(); | |||
| JSONObject vp = JSON.parseObject(vendroParams); | |||
| Map param = new HashMap(); | |||
| param.put("carNumber", carNumber);//商户编号 | |||
| param.put("code", couponNo);//优惠券编号 | |||
| param.put("parkid", wxPark.getParkingId()); | |||
| log.info("fute useCoupon :" + JSON.toJSONString(param)); | |||
| return ProcBussiness(COUPON_USE, param, vp.getString("signkey")); | |||
| } | |||
| /** | |||
| * 支付成功通知车场 | |||
| * @param wxPark | |||
| * @param orderNo | |||
| * @param token | |||
| * @return | |||
| */ | |||
| public String notifyPaid(WxPark wxPark,String parkOrderNo,Integer fee) { | |||
| String vendroParams = wxPark.getVendorParams(); | |||
| JSONObject vp = JSON.parseObject(vendroParams); | |||
| Map param = new HashMap(); | |||
| param.put("out_trade_no", parkOrderNo);//商户编号 | |||
| String feestr = new BigDecimal(fee).divide(new BigDecimal(100)).stripTrailingZeros().toPlainString(); | |||
| param.put("total_amount", feestr);//优惠券编号 | |||
| param.put("pay_channel", 1);//优惠券编号 | |||
| param.put("pay_status", 1);//优惠券编号 | |||
| log.info("fute notifyOrderResult :" + JSON.toJSONString(param)); | |||
| return ProcBussiness(NOTIFY_PAID, param,vp.getString("signkey")); | |||
| } | |||
| private static String ProcBussiness(String url,Map<String,Object> param,String signKey) { | |||
| try { | |||
| String sign = sign(param, signKey); | |||
| param.put("sign", sign); | |||
| return Proc(url,param); | |||
| } catch (Exception e) { | |||
| log.error("fute request error.",e); | |||
| } | |||
| return null; | |||
| } | |||
| private static String Proc(String url, Map<String,Object> param) { | |||
| CloseableHttpClient httpClient = HttpClients.createDefault(); | |||
| HttpPost httpPost = new HttpPost(url); | |||
| httpPost.addHeader(HTTP.CONTENT_TYPE,"application/json"); | |||
| httpPost.addHeader("Accept", "application/json"); | |||
| httpPost.addHeader("Accept-Encoding", "UTF-8"); | |||
| if (null != param) { | |||
| httpPost.setEntity(new StringEntity(JSON.toJSONString(param),"UTF-8")); | |||
| } | |||
| if (null != param) { | |||
| log.info("fute httpRequest:[url]"+url+"[params]"+JSON.toJSONString(param)); | |||
| }else { | |||
| log.info("fute httpRequest:[url]"+url); | |||
| } | |||
| HttpResponse response = null; | |||
| try { | |||
| response = httpClient.execute(httpPost); | |||
| } catch (Exception e) { | |||
| log.error(e.getLocalizedMessage(),e); | |||
| } | |||
| String result = null; | |||
| //打印StatusLine | |||
| log.debug("StatusLine: " + response.getStatusLine()); | |||
| try{ | |||
| //获取实体 | |||
| HttpEntity httpEntity= response.getEntity(); | |||
| result = EntityUtils.toString(httpEntity, "UTF-8"); | |||
| log.debug(result); | |||
| } catch (Exception e) { | |||
| log.error(e.getLocalizedMessage(),e); | |||
| } | |||
| try { //关闭流并释放资源 | |||
| httpClient.close(); | |||
| } catch (IOException e) { | |||
| log.error(e.getLocalizedMessage()); | |||
| } | |||
| return result; | |||
| } | |||
| private static String sign(Map<String, Object> map, String signKey){ | |||
| if(map==null){ | |||
| return null; | |||
| } | |||
| if(map.containsKey("sign")) { | |||
| map.remove("sign"); | |||
| } | |||
| List<String> keyList = new ArrayList<String>(map.keySet()); | |||
| Collections.sort(keyList); | |||
| StringBuffer sb = new StringBuffer(); | |||
| for(int i=0;i<keyList.size();i++){ | |||
| String key = keyList.get(i); | |||
| Object value = map.get(key); | |||
| sb.append(key+"="+value+"&"); | |||
| } | |||
| String signStr = (sb.substring(0,sb.length()-1)+signKey).toLowerCase(); | |||
| String md5Str = MD5(signStr); | |||
| return md5Str; | |||
| } | |||
| /** | |||
| * 生成MD5 | |||
| */ | |||
| private static String MD5(String s) { | |||
| return MD5(s,"utf-8"); | |||
| } | |||
| /** | |||
| * 生成MD5 | |||
| */ | |||
| private static String MD5(String s, String charset) { | |||
| try { | |||
| MessageDigest messagedigest = MessageDigest.getInstance("MD5"); | |||
| messagedigest.reset(); | |||
| byte abyte0[] = messagedigest.digest(s.getBytes(charset)); | |||
| return byteToString(abyte0); | |||
| } catch (NoSuchAlgorithmException e) { | |||
| e.printStackTrace(); | |||
| } catch (UnsupportedEncodingException e) { | |||
| e.printStackTrace(); | |||
| } | |||
| return null; | |||
| } | |||
| private static String byteToString(byte abyte0[]) { | |||
| int i = abyte0.length; | |||
| char ac[] = new char[i * 2]; | |||
| int j = 0; | |||
| for (int k = 0; k < i; k++) { | |||
| byte byte0 = abyte0[k]; | |||
| ac[j++] = hexDigits[byte0 >>> 4 & 0xf]; | |||
| ac[j++] = hexDigits[byte0 & 0xf]; | |||
| } | |||
| return new String(ac); | |||
| } | |||
| private static final char hexDigits[] = { '0', '1', '2', '3', '4', '5', | |||
| '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; | |||
| } | |||
| @@ -240,7 +240,7 @@ public class HaiKangWeiShiParkService extends BaseParkService implements ParkAda | |||
| } | |||
| @Override | |||
| public void notifyPaid(ParkNotifyPaid notifyPaid) throws Exception { | |||
| public void notifyPaid(WxPark park,ParkNotifyPaid notifyPaid) throws Exception { | |||
| } | |||
| @Override | |||
| @@ -349,7 +349,7 @@ public class JieShunParkService extends BaseParkService implements ParkAdapterSe | |||
| } | |||
| @Override | |||
| public void notifyPaid(ParkNotifyPaid notifyPaid) throws Exception { | |||
| public void notifyPaid(WxPark park,ParkNotifyPaid notifyPaid) throws Exception { | |||
| } | |||
| @Override | |||
| @@ -107,6 +107,6 @@ public class ShangAnParkService extends BaseParkService implements ParkAdapterSe | |||
| } | |||
| @Override | |||
| public void notifyPaid(ParkNotifyPaid notifyPaid) throws Exception { | |||
| public void notifyPaid(WxPark park,ParkNotifyPaid notifyPaid) throws Exception { | |||
| } | |||
| } | |||
| @@ -268,6 +268,6 @@ public class TJDParkService extends BaseParkService implements ParkAdapterServic | |||
| } | |||
| @Override | |||
| public void notifyPaid(ParkNotifyPaid notifyPaid) throws Exception { | |||
| public void notifyPaid(WxPark park,ParkNotifyPaid notifyPaid) throws Exception { | |||
| } | |||
| } | |||
| @@ -5,6 +5,7 @@ import java.util.Map; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.domain.po.WxCarPayOrder; | |||
| import com.iformall.domain.po.WxPark; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.enums.EnumCarVendor; | |||
| import com.iformall.service.pay.service.pay.entity.PayAdapterResult; | |||
| @@ -18,7 +19,7 @@ public interface WxParkPayService { | |||
| public String handlePaidCallBack(Map<String, String> paramMap); | |||
| public void handlePaidSuccess(TenantEntity tenantEntity,Long cUserId,Integer carVendor,String carNumber,String parkOrderNo, | |||
| public void handlePaidSuccess(TenantEntity tenantEntity,WxPark wxPark,Long cUserId,Integer carVendor,String carNumber,String payOrderNo, | |||
| Integer fee,Date paidTime,String transcationId,String merchantAccount,Long merchantId,String merchantName) throws Exception; | |||
| public WxCarPayOrder detailWxCarPayOrder(Long id,String tenantId); | |||
| @@ -9,6 +9,7 @@ import com.iformall.common.IdWorker; | |||
| import com.iformall.domain.po.WxAppinfo; | |||
| import com.iformall.domain.po.WxCarPayOrder; | |||
| import com.iformall.domain.po.WxCoupon; | |||
| import com.iformall.domain.po.WxPark; | |||
| import com.iformall.domain.po.WxPayAccount; | |||
| import com.iformall.domain.po.WxPayOrder; | |||
| import com.iformall.domain.po.WxRefundOrder; | |||
| @@ -22,7 +23,9 @@ import com.iformall.mapper.WxCarPayOrderMapper; | |||
| import com.iformall.mapper.WxPayAccountMapper; | |||
| import com.iformall.pay.WxPayment; | |||
| import com.iformall.service.ExcelService; | |||
| import com.iformall.service.WxParkService; | |||
| import com.iformall.service.park.ParkFactory; | |||
| import com.iformall.service.park.entity.ParkCreatePayOrder; | |||
| import com.iformall.service.park.entity.ParkNotifyPaid; | |||
| import com.iformall.service.pay.service.pay.entity.PayAdapterResult; | |||
| import com.iformall.service.pay.service.pay.wx.v2.miniApp.appPay.WxMiniAppPayAdapterService; | |||
| @@ -41,6 +44,7 @@ import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.context.annotation.Lazy; | |||
| import org.springframework.stereotype.Service; | |||
| @@ -69,7 +73,11 @@ public class WxParkPayServiceImpl implements WxParkPayService { | |||
| @Autowired | |||
| RedisLock redisLock; | |||
| @Lazy | |||
| @Autowired | |||
| WxParkService wxParkService; | |||
| @Override | |||
| public PageInfo<WxCarPayOrder> listPayOrderAsPage(WxCarPayOrder record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCarPayOrderMapper.findList(record)); | |||
| @@ -94,6 +102,13 @@ public class WxParkPayServiceImpl implements WxParkPayService { | |||
| return XmlUtil.getRequestXml(resultMap); | |||
| } | |||
| private WxPark getCurrentPark(TenantEntity tenantEntity) { | |||
| WxPark parkQ = new WxPark(); | |||
| parkQ.updateTenantInfo(tenantEntity); | |||
| WxPark wxPark = wxParkService.getByObj(parkQ); | |||
| return wxPark; | |||
| } | |||
| @Override | |||
| public String handlePaidCallBack(Map<String, String> paramMap) { | |||
| //支付返回消息 | |||
| @@ -106,7 +121,7 @@ public class WxParkPayServiceImpl implements WxParkPayService { | |||
| Integer cashFee = Integer.parseInt(cashFeeStr); | |||
| if (cashFee > 0 ) { | |||
| try { | |||
| String parkOrderNo = paramMap.get("out_trade_no"); | |||
| String payOrderNo = paramMap.get("out_trade_no"); | |||
| String time_end = paramMap.get("time_end"); | |||
| String transcationId = paramMap.get("transaction_id"); | |||
| @@ -117,6 +132,9 @@ public class WxParkPayServiceImpl implements WxParkPayService { | |||
| TenantEntity te = new TenantEntity(); | |||
| te.setTenantId(tenantId); | |||
| te.setParentTenantId(parentTenantId); | |||
| WxPark park = getCurrentPark(te); | |||
| Integer carVendor = attachObj.getInteger("v"); | |||
| Long cUserId = attachObj.getLong("u"); | |||
| String carNumber = attachObj.getString("car"); | |||
| @@ -124,7 +142,7 @@ public class WxParkPayServiceImpl implements WxParkPayService { | |||
| Long merchantId = attachObj.getLong("mid"); | |||
| String merchantName = attachObj.getString("mn"); | |||
| handlePaidSuccess(te,cUserId,carVendor,carNumber,parkOrderNo,Integer.parseInt(cashFeeStr), | |||
| handlePaidSuccess(te,park,cUserId,carVendor,carNumber,payOrderNo,Integer.parseInt(cashFeeStr), | |||
| DateUtils.string2Date(time_end, DateUtils.DATE_PATTERN_ALL_NOSPACE).getTime(),transcationId, | |||
| merchantAccount,merchantId,merchantName); | |||
| } catch (Exception e) { | |||
| @@ -144,16 +162,17 @@ public class WxParkPayServiceImpl implements WxParkPayService { | |||
| } | |||
| @Override | |||
| public void handlePaidSuccess(TenantEntity tenantEntity,Long cUserId,Integer carVendor,String carNumber, | |||
| String parkOrderNo,Integer fee,Date paidTime,String transcationId,String merchantAccount, | |||
| public void handlePaidSuccess(TenantEntity tenantEntity,WxPark wxPark,Long cUserId,Integer carVendor,String carNumber, | |||
| String payOrderNo,Integer fee,Date paidTime,String transcationId,String merchantAccount, | |||
| Long merchantId,String merchantName) throws Exception{ | |||
| //查询该笔订单是否已经存在 | |||
| WxCarPayOrder payOrder = wxCarPayOrderMapper.findOneByParkOderNo(parkOrderNo, tenantEntity.getTenantId()); | |||
| WxCarPayOrder payOrder = wxCarPayOrderMapper.findOneByParkOderNo(payOrderNo, tenantEntity.getTenantId()); | |||
| String parkOrderNo = ParkCreatePayOrder.getRealParkOrderNumber(payOrderNo,EnumCarVendor.getEnum(carVendor)); | |||
| if (null == payOrder) { | |||
| //此处需要加锁,防止并发设置 | |||
| long time = System.currentTimeMillis() + RedisLock.TIMEOUT; | |||
| String timeStr = String.valueOf(time); | |||
| boolean stocksetlock = redisLock.lock("carPayOrderLock_"+parkOrderNo, timeStr); | |||
| boolean stocksetlock = redisLock.lock("carPayOrderLock_"+payOrderNo, timeStr); | |||
| if (stocksetlock) { | |||
| try { | |||
| //创建停车支付订单记录 | |||
| @@ -178,7 +197,7 @@ public class WxParkPayServiceImpl implements WxParkPayService { | |||
| //通知车场支付成功 | |||
| try { | |||
| parkFactory.getParkService(carVendor).notifyPaid(new ParkNotifyPaid(tenantEntity.getTenantId(), parkOrderNo, fee, paidTime)); | |||
| parkFactory.getParkService(carVendor).notifyPaid(wxPark,new ParkNotifyPaid(tenantEntity.getTenantId(),payOrderNo,parkOrderNo,fee,paidTime)); | |||
| payOrder.setParkNotify(EnumYesOrNo.YES.getCode()); | |||
| payOrder.setUpdateTime(new Date()); | |||
| wxCarPayOrderMapper.updateById(payOrder); | |||
| @@ -188,12 +207,11 @@ public class WxParkPayServiceImpl implements WxParkPayService { | |||
| payOrder.setUpdateTime(new Date()); | |||
| wxCarPayOrderMapper.updateById(payOrder); | |||
| } | |||
| }catch(Exception e) { | |||
| logger.error("handlePaidSuccess fail.",e); | |||
| throw new MallinkException(ErrorCode.ORDER_IS_FAIL.getCode(),"支付同步失败"+parkOrderNo); | |||
| throw new MallinkException(ErrorCode.ORDER_IS_FAIL.getCode(),"支付同步失败"+payOrderNo); | |||
| }finally { | |||
| redisLock.unlock("carPayOrderLock_"+parkOrderNo, timeStr); | |||
| redisLock.unlock("carPayOrderLock_"+payOrderNo, timeStr); | |||
| } | |||
| } | |||
| } | |||