| | |
| | | <packaging>jar</packaging> |
| | | |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>com.aliyun</groupId> |
| | | <artifactId>aliyun-java-sdk-core</artifactId> |
| | | <version>4.4.3</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.google.cloud</groupId> |
| | | <artifactId>libraries-bom</artifactId> |
| | |
| | | import com.stylefeng.guns.modular.system.vo.PlatformVO; |
| | | import com.stylefeng.guns.modular.system.vo.WaterMoneyVO; |
| | | import com.stylefeng.guns.modular.system.vo.WaterVO; |
| | | import io.swagger.models.auth.In; |
| | | import org.checkerframework.checker.units.qual.A; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.ui.Model; |
| | |
| | | Wrapper<OrderCancel> orderCancelEntityWrapper = new EntityWrapper<>(); |
| | | // 用户取消订单记录 |
| | | List<OrderCancel> orderCancels = new ArrayList<>(); |
| | | List<Integer> integers = new ArrayList<>(); |
| | | integers.add(1); |
| | | integers.add(2); |
| | | if (time == 5 && !StringUtils.hasLength(insertTime)){ |
| | | // 余额充值wrapper |
| | | orderType = new EntityWrapper<TPubTransactionDetails>() |
| | |
| | | // 司机手动结算金额 |
| | | orderType1 = new EntityWrapper<SettlementDetail>() |
| | | .in("orderType", Arrays.asList(1, 4)); |
| | | // 用户取消订单费用 |
| | | orderCancelEntityWrapper.eq("state", 2) |
| | | .eq("userType", 1).in("payType",integers) |
| | | ; |
| | | }else{ |
| | | orderType = new EntityWrapper<TPubTransactionDetails>() |
| | | .eq("orderType", 5) |
| | |
| | | // 用户取消订单费用 |
| | | orderCancelEntityWrapper.eq("state", 2) |
| | | .eq("userType", 1) |
| | | .in("payType",integers) |
| | | .between("insertTime", start, end); |
| | | } |
| | | |
| | | |
| | | if (type != null){ |
| | | switch (type){ |
| | | case 1: |
| | |
| | | Wrapper<OrderCancel> orderCancelEntityWrapper = new EntityWrapper<>(); |
| | | // 司机手动结算金额 |
| | | Wrapper<SettlementDetail> orderType1 = new EntityWrapper<SettlementDetail>(); |
| | | List<Integer> integers = new ArrayList<>(); |
| | | integers.add(1); |
| | | integers.add(2); |
| | | if (time == 5 && !StringUtils.hasLength(insertTime)){ |
| | | // 余额充值wrapper |
| | | orderType = new EntityWrapper<TPubTransactionDetails>() |
| | |
| | | .in("orderType", Arrays.asList(1, 4)); |
| | | // 用户取消订单费用 |
| | | orderCancelEntityWrapper.eq("state", 2) |
| | | .in("payType",integers) |
| | | .eq("userType", 1); |
| | | }else{ |
| | | orderType = new EntityWrapper<TPubTransactionDetails>() |
| | |
| | | // 用户取消订单费用 |
| | | orderCancelEntityWrapper.eq("state", 2) |
| | | .eq("userType", 1) |
| | | .in("payType",integers) |
| | | .between("insertTime", start, end); |
| | | } |
| | | |
| | |
| | | import com.stylefeng.guns.modular.system.dao.TSystemPriceMapper; |
| | | import com.stylefeng.guns.modular.system.model.*; |
| | | import com.stylefeng.guns.modular.system.service.*; |
| | | import com.stylefeng.guns.modular.system.util.ChinaMobileUtil; |
| | | import com.stylefeng.guns.modular.system.util.GoogleMap.FleetEngineUtil; |
| | | import com.stylefeng.guns.modular.system.util.HttpRequestUtil; |
| | | import com.stylefeng.guns.modular.system.util.PushURL; |
| | |
| | | return SUCCESS_TIP; |
| | | } |
| | | |
| | | |
| | | @Resource |
| | | private ITUserService userService; |
| | | @RequestMapping(value = "/frozenOrder") |
| | | @ResponseBody |
| | | public Object frozenOrder(@RequestParam Integer tOrderPrivateCarId) throws Exception { |
| | | TOrderPrivateCar orderPrivateCar = tOrderPrivateCarService.selectById(tOrderPrivateCarId); |
| | | orderPrivateCar = this.setMoney(orderPrivateCar, 0D, 0D);//计算费用 |
| | | |
| | | //添加已收入明细 |
| | | TCompany company = companyService.selectById(orderPrivateCar.getCompanyId()); |
| | | TDriver tDriver = driverService.selectById(orderPrivateCar.getDriverId()); |
| | | Double taxi = company.getSpeMoney().doubleValue(); |
| | | Integer language =tDriver.getLanguage(); |
| | | BigDecimal d = null;//企业收入 |
| | | BigDecimal c = null;//司机收入 |
| | | if(company.getIsSpeFixedOrProportional() == 2){//固定 |
| | | d = new BigDecimal(taxi); |
| | | c = orderPrivateCar.getOrderMoney().subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN); |
| | | } |
| | | if(company.getIsSpeFixedOrProportional() == 1){//比例 |
| | | Double price = orderPrivateCar.getStartMoney().doubleValue() + orderPrivateCar.getMileageMoney().doubleValue() + orderPrivateCar.getWaitMoney().doubleValue()+ orderPrivateCar.getDurationMoney().doubleValue() + orderPrivateCar.getLongDistanceMoney().doubleValue(); |
| | | d = new BigDecimal(price).multiply(new BigDecimal(taxi).divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_HALF_EVEN); |
| | | c = orderPrivateCar.getOrderMoney().subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN); |
| | | } |
| | | if(orderPrivateCar.getIsFrozen()==1){ |
| | | TDriver driver = driverService.selectById(orderPrivateCar.getDriverId()); |
| | | driver.setBusinessMoney(new BigDecimal(null != driver.getBusinessMoney() ? driver.getBusinessMoney() : 0).subtract(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | |
| | | driverService.updateById(driver); |
| | | } |
| | | if (orderPrivateCar.getIsFrozen() == 1){ |
| | | TOrderPrivateCar orderPrivateCar1 = tOrderPrivateCarService.selectById(tOrderPrivateCarId); |
| | | if(orderPrivateCar1.getArriveTime()==null){ |
| | | orderPrivateCar1.setArriveTime(orderPrivateCar1.getStartServiceTime()); |
| | | } |
| | | orderPrivateCar1 = this.setMoney(orderPrivateCar1, 0D, 0D);//计算费用 |
| | | |
| | | orderPrivateCar1.setOrderMoney(orderPrivateCar1.getOrderMoney().add(orderPrivateCar1.getParkMoney()).add(orderPrivateCar1.getRoadTollMoney())); |
| | | //判断是否首单免费-免费直接完成 |
| | | Integer orderNumber = tOrderPrivateCarService.selectCount(new EntityWrapper<TOrderPrivateCar>().eq("userId",orderPrivateCar1.getUserId()).last("and (state=8 or state=9)")); |
| | | |
| | | if(orderNumber<=0){//判断是否是首单 |
| | | //判断是否免单 |
| | | TUser userInfo = userService.selectById(orderPrivateCar1.getUserId()); |
| | | if(userInfo.getFreeMoney().doubleValue()>0d){ |
| | | if(orderPrivateCar1.getOrderMoney().compareTo(userInfo.getFreeMoney())<=-1){ |
| | | orderPrivateCar1.setState(8); |
| | | orderPrivateCar1.setIsFree(2); |
| | | //添加已收入明细 |
| | | TCompany company = companyService.selectById(orderPrivateCar1.getCompanyId()); |
| | | BigDecimal speMoney = company.getSpeMoney(); |
| | | |
| | | if(company.getIsSpeFixedOrProportional() == 2){//固定 |
| | | d = speMoney; |
| | | c = orderPrivateCar1.getOrderMoney().subtract(d);//只有出行金额参与抽成,其余归属司机 |
| | | } |
| | | if(company.getIsSpeFixedOrProportional() == 1){//比例 |
| | | BigDecimal price = orderPrivateCar1.getStartMoney().add(orderPrivateCar1.getMileageMoney()).add(new BigDecimal(orderPrivateCar1.getWaitMoney())).add(orderPrivateCar1.getDurationMoney()).add(orderPrivateCar1.getLongDistanceMoney()); |
| | | d = price.multiply(speMoney).divide(new BigDecimal(100), new MathContext(2, RoundingMode.HALF_EVEN)); |
| | | c = orderPrivateCar1.getOrderMoney().subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN); |
| | | } |
| | | incomeService.saveData(1, orderPrivateCar1.getCompanyId(), 2, orderPrivateCar1.getId(), 1, d.doubleValue()); |
| | | incomeService.saveData(2, orderPrivateCar1.getDriverId(), 2, orderPrivateCar1.getId(), 1, c.doubleValue()); |
| | | TDriver driver = driverService.selectById(orderPrivateCar1.getDriverId()); |
| | | driver.setBusinessMoney(new BigDecimal(null != driver.getBusinessMoney() ? driver.getBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driver.setLaveBusinessMoney(new BigDecimal(null != driver.getLaveBusinessMoney() ? driver.getLaveBusinessMoney() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | if (null != driver.getBalance()){ |
| | | driver.setBalance(driver.getBalance().add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | }else{ |
| | | driver.setBalance(BigDecimal.ZERO.add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | } |
| | | driverService.updateById(driver); |
| | | }else{ |
| | | orderPrivateCar1.setState(7); |
| | | orderPrivateCar1.setOrderMoney(orderPrivateCar1.getOrderMoney().subtract(userInfo.getFreeMoney())); |
| | | orderPrivateCar1.setFreeMoney(userInfo.getFreeMoney()); |
| | | |
| | | } |
| | | |
| | | }else{ |
| | | orderPrivateCar1.setState(7); |
| | | } |
| | | |
| | | }else{ |
| | | orderPrivateCar1.setState(7); |
| | | } |
| | | |
| | | Map<String, String> map = chinaMobileUtil.midAxbUnBindSend(orderPrivateCar1.getBindId(),orderPrivateCar1.getTelX()); |
| | | if(String.valueOf(map.get("code")).equals("200")){ |
| | | orderPrivateCar1.setTelX(""); |
| | | orderPrivateCar1.setBindId(""); |
| | | } |
| | | tOrderPrivateCarService.updateById(orderPrivateCar1); |
| | | |
| | | |
| | | pushUtil.removeTask(orderPrivateCar1.getId(), 1);//删除定时任务,结束推送数据 |
| | | systemNoticeService.addSystemNotice(1, language == 1 ? "司机已结束本次行程,谢谢使用" : language == 2 ? |
| | | "The driver has finished the trip,thank you for using I-GO" : "Le chauffeur a terminé le trajet, merci d'utiliser I-GO", orderPrivateCar1.getUserId()); |
| | | |
| | | //回滚司机状态为空闲 |
| | | TDriver driver = driverService.selectById(orderPrivateCar1.getDriverId()); |
| | | driver.setState(2); |
| | | driverService.updateById(driver); |
| | | |
| | | TOrderPrivateCar finalOrderTaxi = orderPrivateCar1; |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | pushUtil.pushOrderState(1, finalOrderTaxi.getUserId(), finalOrderTaxi.getId(), 1, finalOrderTaxi.getState(), 0, ""); |
| | | pushUtil.pushOrderState(2, finalOrderTaxi.getDriverId(), finalOrderTaxi.getId(), 1, finalOrderTaxi.getState(), 0, ""); |
| | | } |
| | | }).start(); |
| | | |
| | | TOrderPrivateCar finalOrderPrivateCar = orderPrivateCar1; |
| | | new Thread(()->{ |
| | | try { |
| | | //上报google |
| | | fleetEngineUtil.reportBillableEvent(finalOrderPrivateCar.getTripId()); |
| | | System.err.println("上报时间:{},tripid:{},created_at:{},completed_at:{}"+ System.currentTimeMillis()+ finalOrderPrivateCar.getTripId()+ |
| | | finalOrderPrivateCar.getInsertTime().getTime()+finalOrderPrivateCar.getEndServiceTime().getTime()); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | }).start(); |
| | | // 冻结订单需要给司机推送一个消息; |
| | | TOrderPrivateCar finalOrderPrivateCar = orderPrivateCar; |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | |
| | | return SUCCESS_TIP; |
| | | } |
| | | @Autowired |
| | | private ChinaMobileUtil chinaMobileUtil; |
| | | @Autowired |
| | | private PushUtil pushUtil; |
| | | @Autowired |
| | | private ITSystemNoticeService systemNoticeService; |
| | | @Resource |
| | | private TSystemPriceMapper systemPriceMapper; |
| | | public TOrderPrivateCar setMoney(TOrderPrivateCar orderPrivateCar, Double parkingFee, Double crossingFee) throws Exception { |
| | |
| | | @TableField("mileageKilometers") |
| | | private Double mileageKilometers; |
| | | |
| | | |
| | | |
| | | |
| | | private BigDecimal freeMoney; |
| | | @TableField("isFree") |
| | | private Integer isFree; |
| | | |
| | | |
| | | |
| | |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import lombok.Data; |
| | | |
| | | import java.io.Serializable; |
| | | import java.math.BigDecimal; |
| | |
| | | * @since 2020-06-01 |
| | | */ |
| | | @TableName("t_user") |
| | | @Data |
| | | public class TUser extends Model<TUser> { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | |
| | | private Integer insertUser; |
| | | private Date updateTime; |
| | | private Integer updateUser; |
| | | private BigDecimal freeMoney; |
| | | |
| | | /** |
| | | *分享用户id |
| | |
| | | for (Map<String, Object> stringObjectMap : advertisementList1) { |
| | | Integer id = (Integer)stringObjectMap.get("id"); |
| | | TAdvertisementUser tAdvertisementUser = tAdvertisementUserMapper.selectTAdvertisementInform(id); |
| | | if(ToolUtil.isNotEmpty(tAdvertisementUser.getDriverId()) && ToolUtil.isNotEmpty(tAdvertisementUser.getUserId()) && "[]".equals(tAdvertisementUser.getDriverId()) && "[]".equals(tAdvertisementUser.getUserId())){ |
| | | if (tAdvertisementUser == null){ |
| | | continue; |
| | | } |
| | | if(ToolUtil.isNotEmpty(tAdvertisementUser.getDriverId()) |
| | | && ToolUtil.isNotEmpty(tAdvertisementUser.getUserId()) |
| | | && "[]".equals(tAdvertisementUser.getDriverId()) |
| | | && "[]".equals(tAdvertisementUser.getUserId())){ |
| | | // all |
| | | stringObjectMap.put("sendUser",1); |
| | | }else if(ToolUtil.isNotEmpty(tAdvertisementUser.getDriverId()) && ToolUtil.isNotEmpty(tAdvertisementUser.getUserId()) && "[]".equals(tAdvertisementUser.getDriverId()) && !"[]".equals(tAdvertisementUser.getUserId())){ |
New file |
| | |
| | | package com.stylefeng.guns.modular.system.util; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.aliyuncs.CommonRequest; |
| | | import com.aliyuncs.CommonResponse; |
| | | import com.aliyuncs.DefaultAcsClient; |
| | | import com.aliyuncs.IAcsClient; |
| | | import com.aliyuncs.exceptions.ClientException; |
| | | import com.aliyuncs.exceptions.ServerException; |
| | | import com.aliyuncs.http.MethodType; |
| | | import com.aliyuncs.profile.DefaultProfile; |
| | | import com.stylefeng.guns.core.util.MD5Util; |
| | | import org.apache.commons.codec.binary.Base64; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 中国移动工具类 |
| | | */ |
| | | @Component |
| | | public class ChinaMobileUtil { |
| | | |
| | | private static String APIKey = "LTAI4G1BpRaihVRZp1RS8Stn"; |
| | | |
| | | private static String SecretKey = "PDR7uUEGNf0wIPPVCPCVdySgTwCr90"; |
| | | |
| | | @Autowired |
| | | private HttpClientUtil httpClientUtil; |
| | | |
| | | |
| | | /** |
| | | * 绑定小号 |
| | | * @param phoneA |
| | | * @param phoneB |
| | | * @param areaCode |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public static Map<String, String> midAxbBindSend(String phoneA, String phoneB, Integer areaCode) throws Exception{ |
| | | Map<String, String> map1 = new HashMap<>(); |
| | | map1.put("code", "-1"); |
| | | map1.put("msg", ""); |
| | | map1.put("telX", ""); |
| | | map1.put("bindId", ""); |
| | | return map1; |
| | | //暂时屏蔽-后期放开 |
| | | /*DefaultProfile profile = DefaultProfile.getProfile( |
| | | "cn-hangzhou", // 地域ID |
| | | APIKey, // 您的AccessKey ID |
| | | SecretKey ); // 您的AccessKey Secret |
| | | IAcsClient client = new DefaultAcsClient(profile); |
| | | |
| | | CommonRequest request = new CommonRequest(); |
| | | request.setMethod(MethodType.POST); |
| | | request.setDomain("dyplsapi.aliyuncs.com"); |
| | | request.setVersion("2017-05-25"); |
| | | request.setAction("BindAxb"); |
| | | // 绑定关系的过期时间。必须晚于当前时间1分钟以上。 |
| | | request.putQueryParameter("Expiration", DateUtil.format(new Date(new Date().getTime()+7 * 24 * 60 * 60*1000L),"yyyy-MM-dd HH:mm:ss")); |
| | | // 号码池Key |
| | | request.putQueryParameter("PoolKey", "FC100000119206151"); |
| | | // AXB中的B号码 |
| | | request.putQueryParameter("PhoneNoB", phoneB); |
| | | // AXB中的A号码 |
| | | request.putQueryParameter("PhoneNoA", phoneA); |
| | | // 指定城市进行X号码的选号。 |
| | | request.putQueryParameter("ExpectCity", "北京"); |
| | | // 是否需要针对该绑定关系产生的所有通话录制通话录音。 |
| | | request.putQueryParameter("IsRecordingEnabled", "false"); |
| | | Map<String, String> map1 = new HashMap<>(); |
| | | try { |
| | | CommonResponse response = client.getCommonResponse(request); |
| | | // 处理请求结果 |
| | | System.out.println(response.getData()); |
| | | JSONObject jsonObject = JSONObject.parseObject(response.getData()); |
| | | if(jsonObject.getString("Code").equals("OK")){ |
| | | map1.put("code", "200"); |
| | | map1.put("msg", jsonObject.getString("Message")); |
| | | map1.put("telX", jsonObject.getJSONObject("SecretBindDTO").getString("SecretNo")); |
| | | map1.put("bindId", jsonObject.getJSONObject("SecretBindDTO").getString("SubsId")); |
| | | }else{ |
| | | map1.put("code", jsonObject.getString("Code")); |
| | | map1.put("msg", jsonObject.getString("Message")); |
| | | } |
| | | } catch (ServerException e) { |
| | | e.printStackTrace(); |
| | | map1.put("code", "-1"); |
| | | map1.put("msg", e.getErrMsg()); |
| | | } catch (ClientException e) { |
| | | System.out.println("ErrCode:" + e.getErrCode()); |
| | | System.out.println("ErrMsg:" + e.getErrMsg()); |
| | | System.out.println("RequestId:" + e.getRequestId()); |
| | | map1.put("code", "-1"); |
| | | map1.put("msg", e.getErrMsg()); |
| | | } |
| | | return map1;*/ |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 解绑小号关系 |
| | | * @param bindId 绑定关系id |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public static Map<String, String> midAxbUnBindSend(String bindId,String secretNo) throws Exception{ |
| | | DefaultProfile profile = DefaultProfile.getProfile( |
| | | "cn-hangzhou", // 地域ID |
| | | APIKey, // 您的AccessKey ID |
| | | SecretKey ); // 您的AccessKey Secret |
| | | IAcsClient client = new DefaultAcsClient(profile); |
| | | |
| | | CommonRequest request = new CommonRequest(); |
| | | request.setMethod(MethodType.POST); |
| | | request.setDomain("dyplsapi.aliyuncs.com"); |
| | | request.setVersion("2017-05-25"); |
| | | request.setAction("UnbindSubscription"); |
| | | // 绑定关系的过期时间。必须晚于当前时间1分钟以上。 |
| | | // 号码池Key |
| | | request.putQueryParameter("PoolKey", "FC100000119206151"); |
| | | // 隐私号码。调用BindAXG等号码绑定接口时指定或自动分配的X号码。 |
| | | request.putQueryParameter("SecretNo", secretNo); |
| | | // 绑定关系ID。 |
| | | // |
| | | //可以在控制台的号码管理 > 号码详情中查看绑定关系ID,或者在调用BindAxb等号码绑定API时查看返回参数中的SubsId。 |
| | | request.putQueryParameter("SubsId", bindId); |
| | | Map<String, String> map1 = new HashMap<>(); |
| | | try { |
| | | CommonResponse response = client.getCommonResponse(request); |
| | | // 处理请求结果 |
| | | System.out.println(response.getData()); |
| | | JSONObject jsonObject = JSONObject.parseObject(response.getData()); |
| | | if(jsonObject.getString("Code").equals("OK")){ |
| | | map1.put("code", "200"); |
| | | map1.put("msg", jsonObject.getString("Message")); |
| | | }else{ |
| | | map1.put("code", jsonObject.getString("Code")); |
| | | map1.put("msg", jsonObject.getString("Message")); |
| | | } |
| | | } catch (ServerException e) { |
| | | e.printStackTrace(); |
| | | map1.put("code", "-1"); |
| | | map1.put("msg", e.getErrMsg()); |
| | | } catch (ClientException e) { |
| | | System.out.println("ErrCode:" + e.getErrCode()); |
| | | System.out.println("ErrMsg:" + e.getErrMsg()); |
| | | System.out.println("RequestId:" + e.getRequestId()); |
| | | map1.put("code", "-1"); |
| | | map1.put("msg", e.getErrMsg()); |
| | | } |
| | | return map1; |
| | | } |
| | | |
| | | public static void main(String[] args) throws IOException { |
| | | try{ |
| | | // System.out.println(midAxbBindSend("18380476116","13688394165",null)); |
| | | System.out.println(midAxbUnBindSend("1000031640138366","17150145472")); |
| | | }catch (Exception e){ |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | public Map<String, String> HeaderUtils(String APIKey, String SecretKey) throws Exception{ |
| | | Map<String, String> header = new HashMap<>(); |
| | | long time = System.currentTimeMillis(); |
| | | String signStr = MD5Util.encrypt(APIKey + SecretKey + time); |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("apiKey", APIKey); |
| | | jsonObject.put("time", time); |
| | | jsonObject.put("sign", signStr); |
| | | Base64 base64 = new Base64(); |
| | | String s = base64.encodeToString(jsonObject.toJSONString().getBytes("UTF-8")); |
| | | header.put("header", s); |
| | | |
| | | jsonObject = new JSONObject(); |
| | | jsonObject.put("platformId", ""); |
| | | jsonObject.put("secret", ""); |
| | | s = base64.encodeToString(jsonObject.toJSONString().getBytes("UTF-8")); |
| | | header.put("accessCode", s); |
| | | return header; |
| | | } |
| | | } |
| | |
| | | import com.google.fleetengine.auth.token.VehicleClaims; |
| | | import com.google.fleetengine.auth.token.factory.signer.*; |
| | | import com.stylefeng.guns.modular.system.util.RedisUtil; |
| | | import com.stylefeng.guns.modular.system.util.UUIDUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | |
| | | private final String consumerPrivateKeyId = "40acf82cbd5250de2f5123caff40738bdd403b08"; |
| | | |
| | | private final String consumerPrivateKey = "MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDSwtbSBFgIXna6mWeKFWCK31NXUJH6uGduR1XrODGRedrqrTgr0BdNg8PDo6/zh/T+K0Svor6kgqpwnl9soOdn73oC4Nu+Ad7EiKa38j650jlZdLAr4hR0Ou9Kcnv45x/94auUO8jBz844cu24swLKiPsK9OnX65wVlKRfhhkGFuS/4OI76CmE7NqZDqPOW16o8tBO5TsgPVNkglFAU73fTp0kcHoLauT9QOB0+yZi39mnNXyU+2cL3Ylp5oaQCJpyssDRUqz/EiHa7FxUUgzCadG00+ePf5iYSnZKQRKWoOIawFvcCfcHx8GAl8Nn+79HtVQHB9hLsQ5+jqcdfKPfAgMBAAECggEAE9Ufz912xzrUY1TCKH1Ae3Dub732Lqihmv/9dsfv6ieUURcBvSW0u6eViVhi20DE7hH2QazH0cU18qkEg71UaTRgv9qW8vdMFiRhw9d4zZWZrfBMD6UTlahiEhhZ0B83pHVS5v0FNC+w0SEHe6Tks1hWfz5yrs3N/z3ghdihjC/5i1jeBoHXs1262SMazuwNGHblLApGPG+86taeFtbDI+31TKvZ8nomZHkEVFnARRUoBBcIwowRMqNfwlpcJhlz6kDWnoD08kHJ2zzJokozu7Lim+Ugt/MWwUOcA0hgq2QdymZFpkRkDl7tZmJtwTfTirjbGlpnPHVXEc1bWM7ocQKBgQD0LJ8e7JXf6bVFngq0jSJNKK7XDHYg0KhHXMApF59xxi29hdHXWPzgRJ45KkoUJc7MITpIJLXfCmi1XyDMf9m8lIf/oaqhJ7idYi7iAAPOJkdnHbSt0lebyjBWzCQ6OgS4NfF1+LEibTzRqiFs5K8EAyPYAVSTrpWoguoWtTzIGQKBgQDc9/I2PS+91Eb5RvuidTNsDqZJliTJQFlBjlDViFo3+l1N7jDFYwPBR/Tv4TVM5p9Zb+/Lo9X1pjDbm8QriTR4V+4HaLXkcCnmOsdSRInFUW4UIafwLX5ifjgfyaWgdKdn2UP1Lu/1qBN6GU1xjSfBQ6N3UqQiKkNPb7tuPJGqtwKBgQCQ4hU8vTclGMC14VQK1B/BVt1/vuYtDIJ9bZycBWdXlDc52LitpiDOVgjodJ5mHBT77M9vVVERWlTNIfgNP+OL0TptRZlAbJhP0p1s/oNDhFUj6211InVXfH54UkNAxYJdZ6yxynIYsma/JcsVmQ/8Ony/Q/LSempVBfEurjW1qQKBgQCQWPjFLdtOKqnildg0HFPnNvqx/38waPTluk5b76LgBpGFIyCBEVmWnacIPRpQjidyiYkggnp26oXoMC1KM2svYmGAPYr1G8CDQcqLl3JYkAVU6VeHsnBpbwLC4TttQkdJs8iNFohy9cUjcfwBPbDGs6TJghbuqqUl81uBe9e8qQKBgQDZm8T2KB34J7HAc5A+vqkmAo7mQLZg51OrzB1KnDU86pSAf0o3eSvfDUT6dpU9fRuZ1XYnbPnpoJwjFH3m4u9gqKF3PtVYfZyJrEqYwmhB9z6vd+dcsUlXM0fi37bGZkKBD0JGGt5OljM1qJG15x/LYfC/nwOmqWoOhNPCst2Z7w=="; |
| | | |
| | | private final static String key = "AIzaSyCG6PsfkaCEc94VK2vIAZk1YYKvOS_Ewts"; |
| | | private final String provider = "i-go-odrd-testing"; |
| | | |
| | | @Autowired |
| | |
| | | */ |
| | | return response.body(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 上报google可结算订单 |
| | | * @param tripId 行程id |
| | | * @return |
| | | */ |
| | | public boolean reportBillableEvent(String tripId) throws Exception { |
| | | String billableEventId = UUIDUtil.getRandomCode(); |
| | | String url = "https://mobilitybilling.googleapis.com/v1:reportBillableEvent?regionCode=GH&key=" + key + "&billableEventId=" + billableEventId; |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | | Map<String, String> headers = new HashMap<>(); |
| | | headers.put("Authorization", "Bearer " + getToken()); |
| | | headers.put("Content-Type", "application/json"); |
| | | post.addHeaders(headers); |
| | | JSONObject body = new JSONObject(); |
| | | body.put("related_ids", "[\"" + tripId + "\"]"); |
| | | post.body(body.toJSONString()); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | //上线客户测试和上线运营开放 |
| | | // HttpResponse response = post.execute(); |
| | | // if(200 != response.getStatus()){ |
| | | // logger.error(response.body()); |
| | | // throw new Exception(response.body()); |
| | | // } |
| | | return true; |
| | | } |
| | | /** |
| | | * 修改车辆信息 |
| | | * @param maximumCapacity |
New file |
| | |
| | | package com.stylefeng.guns.modular.system.util; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import org.apache.http.NameValuePair; |
| | | import org.apache.http.client.config.RequestConfig; |
| | | import org.apache.http.client.entity.UrlEncodedFormEntity; |
| | | import org.apache.http.client.methods.CloseableHttpResponse; |
| | | import org.apache.http.client.methods.HttpGet; |
| | | import org.apache.http.client.methods.HttpPost; |
| | | import org.apache.http.entity.ContentType; |
| | | 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.BasicNameValuePair; |
| | | import org.apache.http.util.EntityUtils; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * http工具类 |
| | | */ |
| | | @Component |
| | | public class HttpClientUtil { |
| | | |
| | | private CloseableHttpClient httpClient; |
| | | |
| | | private CloseableHttpResponse httpResponse; |
| | | |
| | | private RequestConfig requestConfig; |
| | | |
| | | |
| | | /** |
| | | * 创建一个httpClient对象 |
| | | */ |
| | | private void getHttpCline(){ |
| | | this.httpClient = HttpClients.createDefault(); |
| | | } |
| | | |
| | | private void setRequestConfig(){ |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 创建一个POST请求实例 |
| | | * @param url 请求地址 |
| | | * @param params 请求参数 |
| | | */ |
| | | private void setPostHttpRequset(String url, Map<String, Object> params, Map<String, String> header, String contentType){ |
| | | HttpPost httpPost = new HttpPost(url); |
| | | if(null != header){ |
| | | for(String key : header.keySet()){ |
| | | httpPost.setHeader(key, header.get(key)); |
| | | } |
| | | } |
| | | List<NameValuePair> list = new ArrayList<>(); |
| | | if(null != params){ |
| | | Set<String> keys = params.keySet(); |
| | | for(String key : keys){ |
| | | list.add(new BasicNameValuePair(key, params.get(key).toString())); |
| | | } |
| | | } |
| | | try { |
| | | switch (contentType){ |
| | | case "form": |
| | | httpPost.setEntity(new UrlEncodedFormEntity(list)); |
| | | break; |
| | | case "json": |
| | | String s = JSON.toJSONString(params); |
| | | System.err.println(s); |
| | | httpPost.setEntity(new StringEntity(s, ContentType.APPLICATION_JSON)); |
| | | break; |
| | | } |
| | | this.getHttpCline(); |
| | | httpResponse = this.httpClient.execute(httpPost); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | this.close(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取get请求实例 |
| | | * @param url 请求地址 |
| | | * @param params 请求参数 |
| | | */ |
| | | private void setGetHttpRequset(String url, Map<String, Object> params, Map<String, String> header){ |
| | | StringBuffer sb = new StringBuffer(); |
| | | String p = ""; |
| | | if(null != params){ |
| | | Set<String> keys = params.keySet(); |
| | | for(String key : keys){ |
| | | sb.append(key + "=" + params.get(key) + "&"); |
| | | } |
| | | p = "?" + sb.substring(0, sb.length() - 1); |
| | | } |
| | | HttpGet httpGet = new HttpGet(url + p); |
| | | if(null != header){ |
| | | for(String key : header.keySet()){ |
| | | httpGet.setHeader(key, header.get(key)); |
| | | } |
| | | } |
| | | this.getHttpCline(); |
| | | try { |
| | | httpResponse = this.httpClient.execute(httpGet); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | this.close(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 发送http请求 |
| | | * @param mothed "GET、POST、PUT、HEAD、DELETE、HEAD、OPTIONS" |
| | | * @param url 请求地址 |
| | | * @param params 请求参数 |
| | | * @param header 请求头 |
| | | * @param contentType 参数请求方式form/json |
| | | * @return |
| | | */ |
| | | public String pushHttpRequset(String mothed, String url, Map<String, Object> params, Map<String, String> header, String contentType){ |
| | | String content = null; |
| | | switch (mothed){ |
| | | case "GET": |
| | | this.setGetHttpRequset(url, params, header); |
| | | break; |
| | | case "POST": |
| | | this.setPostHttpRequset(url, params, header, contentType); |
| | | break; |
| | | } |
| | | if(httpResponse.getStatusLine().getStatusCode() == 200){ |
| | | try { |
| | | content = EntityUtils.toString(httpResponse.getEntity()); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | this.close(); |
| | | } |
| | | }else{ |
| | | try { |
| | | content = "返回状态码:" + httpResponse.getStatusLine() + "。" + EntityUtils.toString(httpResponse.getEntity()); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | this.close(); |
| | | } |
| | | } |
| | | this.close(); |
| | | return content; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 发送XML请求 |
| | | * @param url 请求地址 |
| | | * @param xml XML数据 |
| | | * @param header 自定义请求头 |
| | | * @return |
| | | */ |
| | | public String pushHttpRequsetXml(String url, String xml, Map<String, String> header){ |
| | | HttpPost httpPost = new HttpPost(url); |
| | | for(String key : header.keySet()){ |
| | | httpPost.setHeader(key, header.get(key)); |
| | | } |
| | | httpPost.setHeader("Content-Type", "application/xml"); |
| | | try { |
| | | httpPost.setEntity(new StringEntity(xml, "UTF-8")); |
| | | this.getHttpCline(); |
| | | httpResponse = this.httpClient.execute(httpPost); |
| | | String content = null; |
| | | if(httpResponse.getStatusLine().getStatusCode() == 200){ |
| | | try { |
| | | content = EntityUtils.toString(httpResponse.getEntity(), "UTF-8"); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | this.close(); |
| | | } |
| | | }else{ |
| | | try { |
| | | content = "返回状态码:" + httpResponse.getStatusLine() + "。" + EntityUtils.toString(httpResponse.getEntity()); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | this.close(); |
| | | } |
| | | } |
| | | this.close(); |
| | | return content; |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | this.close(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 关闭资源 |
| | | */ |
| | | private void close(){ |
| | | try { |
| | | httpClient.close(); |
| | | httpResponse.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | }finally { |
| | | try { |
| | | if(null != httpClient){ |
| | | httpClient.close(); |
| | | } |
| | | if(null != httpResponse){ |
| | | httpResponse.close(); |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | package com.stylefeng.guns.modular.system.util; |
| | | |
| | | |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.UUID; |
| | | |
| | | /** |
| | | * 定义生成随机码的工具类 |
| | | */ |
| | | public class UUIDUtil { |
| | | |
| | | private int i = 1; |
| | | |
| | | |
| | | /** |
| | | * 定义生成原生的UUID随机码 |
| | | * @return |
| | | */ |
| | | public static String getNativeUUID(){ |
| | | return UUID.randomUUID().toString(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 生成32位随机码 |
| | | * @return |
| | | */ |
| | | public static String getRandomCode(){ |
| | | return UUIDUtil.getNativeUUID().replaceAll("-", ""); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取给定长度的随机码 |
| | | * @param num |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public static String getRandomCode(Integer num) throws Exception{ |
| | | String str = null; |
| | | if(0 < num){ |
| | | if(num % 32 > 0){ |
| | | Integer s = num / 32; |
| | | Integer l = num % 32; |
| | | StringBuffer sb = new StringBuffer(); |
| | | for(int i = 0; i < s; i++){ |
| | | sb.append(UUIDUtil.getRandomCode()); |
| | | } |
| | | sb.append(UUIDUtil.getRandomCode().substring(0, l)); |
| | | str = sb.toString(); |
| | | }else if(num % 32 == 0){ |
| | | Integer s = num / 32; |
| | | StringBuffer sb = new StringBuffer(); |
| | | for(int i = 0; i < s; i++){ |
| | | sb.append(UUIDUtil.getRandomCode()); |
| | | } |
| | | str = sb.toString(); |
| | | }else{ |
| | | str = UUIDUtil.getRandomCode().substring(0, num); |
| | | } |
| | | }else{ |
| | | throw new Exception("参数只能大于0"); |
| | | } |
| | | return str; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取根据当前时间的字符串数据 |
| | | * @return |
| | | */ |
| | | public synchronized static String getTimeStr(){ |
| | | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddhhmmssS"); |
| | | return simpleDateFormat.format(new Date()); |
| | | } |
| | | } |
| | |
| | | TUser.initColumn = function () { |
| | | return [ |
| | | {field: 'selectItem', radio: true}, |
| | | {title: '领取时间', field: 'insertTime', visible: true, align: 'center', valign: 'middle'}, |
| | | {title: '使用时间', field: 'insertTime', visible: true, align: 'center', valign: 'middle'}, |
| | | {title: '补贴类型', field: 'type', visible: true, align: 'center', valign: 'middle'}, |
| | | {title: '金额', field: 'amount', visible: true, align: 'center', valign: 'middle'}, |
| | | {title: '领取用户id', field: 'name', visible: true, align: 'center', valign: 'middle',}, |