| | |
| | | case 1: |
| | | OrderPrivateCar orderPrivateCar = privateCarService.selectById(orderId); |
| | | orderPrivateCar.setRecordTime(new Date()); |
| | | orderPrivateCar.setRouteRecord(fileLink); |
| | | orderPrivateCar.setRouteRecord(orderPrivateCar.getRouteRecord()==null? fileLink: orderPrivateCar.getRouteRecord()+","+fileLink); |
| | | privateCarService.updateById(orderPrivateCar); |
| | | break; |
| | | case 5: |
| | | OrderCrossCity orderCrossCity = crossCityService.selectById(orderId); |
| | | orderCrossCity.setRecordTime(new Date()); |
| | | orderCrossCity.setRouteRecord(fileLink); |
| | | orderCrossCity.setRouteRecord(orderCrossCity.getRouteRecord()==null? fileLink: orderCrossCity.getRouteRecord()+","+fileLink); |
| | | crossCityService.updateById(orderCrossCity); |
| | | break; |
| | | case 7: |
| | | TOrderTransfer orderTransfer = orderTransferService.selectById(orderId); |
| | | orderTransfer.setRecordTime(new Date()); |
| | | orderTransfer.setRouteRecord(fileLink); |
| | | orderTransfer.setRouteRecord(orderTransfer.getRouteRecord()==null? fileLink: orderTransfer.getRouteRecord()+","+fileLink); |
| | | orderTransferService.updateById(orderTransfer); |
| | | break; |
| | | } |
| | |
| | | @ApiOperation(value = "获取抢单界面的订单详情", tags = {"司机端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=城际,4=小件物流-同城,5=小件物流-跨城)", name = "orderType", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=城际,4=小件物流-同城,5=小件物流-跨城7=接送机)", name = "orderType", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "当前定位经度", name = "lon", required = true, dataType = "string"), |
| | | @ApiImplicitParam(value = "当前定位纬度", name = "lat", required = true, dataType = "string"), |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | |
| | | @ApiOperation(value = "司机抢单操作", tags = {"司机端-首页"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=城际,4=小件物流-同城,5=小件物流-跨城)", name = "orderType", required = true, dataType = "int"), |
| | | @ApiImplicitParam(value = "订单类型(1=专车,2=出租车,3=城际,4=小件物流-同城,5=小件物流-跨城 7接送机)", name = "orderType", required = true, dataType = "int"), |
| | | @ApiImplicitParam(name = "Authorization", value = "Bearer +token", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9.....") |
| | | }) |
| | | public ResultUtil grabOrder(Integer orderId, Integer orderType, HttpServletRequest request){ |
| | |
| | | * @since 2020-09-02 |
| | | */ |
| | | public interface TOrderTransferMapper extends BaseMapper<TOrderTransfer> { |
| | | Map<String, Object> queryPushOrder(@Param("orderId") Integer orderId); |
| | | |
| | | /** |
| | | * 根据条件查询专车订单列表 |
| | | * @return |
| | |
| | | and state = 2 and (UNIX_TIMESTAMP(travelTime) - UNIX_TIMESTAMP(now())) >= 1800 |
| | | </if> |
| | | </select> |
| | | <select id="queryPushOrder" resultType="map"> |
| | | select |
| | | id as orderId, |
| | | state as orderState, |
| | | ('接送机订单') as orderName, |
| | | DATE_FORMAT(travelTime, '%m月%d日 %H:%i') as travelTime, |
| | | startAddress as startAddress, |
| | | endAddress as endAddress, |
| | | startLon as startLon, |
| | | startLat as startLat, |
| | | endLon as endLon, |
| | | endLat as endLat, |
| | | isReassign as isReassign, |
| | | orderType as reservation, |
| | | orderSource as orderSource, |
| | | orderType as orderType, |
| | | isReassign as isReassign, |
| | | companyId as companyId |
| | | from t_order_private_car where id = #{orderId} |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.baomidou.mybatisplus.service.IService; |
| | | import com.stylefeng.guns.modular.system.model.TOrderTransfer; |
| | | import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import java.util.List; |
| | |
| | | * @since 2020-09-02 |
| | | */ |
| | | public interface ITOrderTransferService extends IService<TOrderTransfer> { |
| | | ResultUtil grabOrder(Integer orderId, Integer uid) throws Exception; |
| | | |
| | | Map<String, Object> queryPushOrder(Integer orderId) throws Exception; |
| | | |
| | | |
| | | /** |
| | | * 根据条件查询专车订单列表 |
| | |
| | | List<Map<String, Object>> list3 = orderLogisticsService.queryMyAllOrder(state, uid); |
| | | datas.addAll(list3); |
| | | |
| | | //接送机 |
| | | List<Map<String, Object>> list4 = orderTransferService.queryOrderList(state,uid); |
| | | datas.addAll(list4); |
| | | |
| | | List<OrderListWarpper> orderListWarpper = OrderListWarpper.getOrderListWarpper(datas); |
| | | |
| | | //分页 |
| | |
| | | break; |
| | | case 6: |
| | | break; |
| | | |
| | | case 7://专车 |
| | | map = orderTransferService.queryPushOrder(orderId); |
| | | String order7 = String.valueOf(map.get("startLon")) + "," + String.valueOf(map.get("startLat")); |
| | | String distance7 = gdMapElectricFenceUtil.getDistance(lon + "," + lat, order7, 1).get("distance"); |
| | | map.put("startDistance", ToolUtil.isNotEmpty(distance7) ? Double.valueOf(distance7) / 1000 : 0); |
| | | |
| | | try { |
| | | //总距离 |
| | | String end = String.valueOf(map.get("endLon")) + "," + String.valueOf(map.get("endLat")); |
| | | distance = gdMapElectricFenceUtil.getDistance(end, order7, 1).get("distance"); |
| | | map.put("totalDistance", ToolUtil.isNotEmpty(distance) ? Double.valueOf(distance) / 1000 : 0); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | |
| | | Integer orderSource7 = Integer.valueOf(String.valueOf(map.get("orderSource"))); |
| | | if(orderSource7 == 1 || orderSource7 == 2 || orderSource7 == 3){ |
| | | if(Integer.valueOf(String.valueOf(map.get("orderType"))) == 1 && Integer.valueOf(String.valueOf(map.get("isReassign"))) == 1){ |
| | | map.put("type", "乘客下单"); |
| | | } |
| | | if(Integer.valueOf(String.valueOf(map.get("orderType"))) == 1 && Integer.valueOf(String.valueOf(map.get("isReassign"))) == 2){ |
| | | map.put("type", "改派"); |
| | | } |
| | | if(Integer.valueOf(String.valueOf(map.get("orderType"))) == 2 && Integer.valueOf(String.valueOf(map.get("isReassign"))) == 1){ |
| | | map.put("type", "预约"); |
| | | } |
| | | if(Integer.valueOf(String.valueOf(map.get("orderType"))) == 2 && Integer.valueOf(String.valueOf(map.get("isReassign"))) == 2){ |
| | | map.put("type", "改派"); |
| | | } |
| | | } |
| | | if(orderSource7 == 5){ |
| | | if(Integer.valueOf(String.valueOf(map.get("orderType"))) == 1 && Integer.valueOf(String.valueOf(map.get("isReassign"))) == 1){ |
| | | map.put("type", "调度下单"); |
| | | } |
| | | if(Integer.valueOf(String.valueOf(map.get("orderType"))) == 1 && Integer.valueOf(String.valueOf(map.get("isReassign"))) == 2){ |
| | | map.put("type", "改派"); |
| | | } |
| | | if(Integer.valueOf(String.valueOf(map.get("orderType"))) == 2 && Integer.valueOf(String.valueOf(map.get("isReassign"))) == 1){ |
| | | map.put("type", "预约"); |
| | | } |
| | | if(Integer.valueOf(String.valueOf(map.get("orderType"))) == 2 && Integer.valueOf(String.valueOf(map.get("isReassign"))) == 2){ |
| | | map.put("type", "改派"); |
| | | } |
| | | } |
| | | break; |
| | | } |
| | | return map; |
| | | } |
| | |
| | | return orderLogisticsService.grabOrder(orderId, uid); |
| | | case 6: |
| | | break; |
| | | case 7://接送机 |
| | | return orderTransferService.grabOrder(orderId, uid); |
| | | } |
| | | return null; |
| | | } |
| | |
| | | package com.stylefeng.guns.modular.system.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar; |
| | | import com.stylefeng.guns.modular.system.dao.TOrderTransferMapper; |
| | | import com.stylefeng.guns.modular.system.model.Driver; |
| | | import com.stylefeng.guns.modular.system.model.TOrderTransfer; |
| | | import com.stylefeng.guns.modular.system.service.IDriverService; |
| | | import com.stylefeng.guns.modular.system.service.ISystemNoticeService; |
| | | import com.stylefeng.guns.modular.system.service.ITOrderTransferService; |
| | | import com.stylefeng.guns.modular.system.util.GDFalconUtil; |
| | | import com.stylefeng.guns.modular.system.util.PushMinistryOfTransportUtil; |
| | | import com.stylefeng.guns.modular.system.util.PushUtil; |
| | | import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | | import com.stylefeng.guns.modular.taxi.model.OrderTaxi; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | */ |
| | | @Service |
| | | public class TOrderTransferServiceImpl extends ServiceImpl<TOrderTransferMapper, TOrderTransfer> implements ITOrderTransferService { |
| | | @Resource |
| | | private TOrderTransferMapper orderTransferMapper; |
| | | @Autowired |
| | | private IDriverService driverService; |
| | | @Autowired |
| | | private GDFalconUtil gdFalconUtil; |
| | | @Autowired |
| | | private PushUtil pushUtil; |
| | | @Autowired |
| | | private PushMinistryOfTransportUtil pushMinistryOfTransportUtil; |
| | | |
| | | @Autowired |
| | | private ISystemNoticeService systemNoticeService; |
| | | @Value("${pushMinistryOfTransport}") |
| | | private boolean pushMinistryOfTransport; |
| | | @Override |
| | | public Map<String, Object> queryPushOrder(Integer orderId) throws Exception { |
| | | return orderTransferMapper.queryPushOrder(orderId); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> getTransferOrderList(Page<Map<String, Object>> page, String beginTime, String endTime, Integer roleType, Integer nowUserId, String orderNum, Integer orderSource, String userName, String userPhone, String passengers, String passengersPhone, Integer serverCarModelId, String driver, Integer state) { |
| | | return this.baseMapper.getTransferOrderList(page, beginTime, endTime, roleType, nowUserId, orderNum, orderSource, userName, userPhone, passengers, passengersPhone, serverCarModelId, driver, state); |
| | | } |
| | | |
| | | @Override |
| | | public synchronized ResultUtil grabOrder(Integer orderId, Integer uid) throws Exception { |
| | | TOrderTransfer orderPrivateCar = this.selectById(orderId); |
| | | //处理摆渡车的情况 |
| | | if(orderPrivateCar.getType() == 2){ |
| | | //查看用户下的摆渡车是否已被人抢了 |
| | | // List<OrderPrivateCar> list = this.selectList( |
| | | // new EntityWrapper<OrderPrivateCar>() |
| | | // .eq("type", 2) |
| | | // .eq("userId", orderPrivateCar.getUserId()) |
| | | // .ne("state", 1) |
| | | // .eq("crossCityOrderId", orderPrivateCar.getCrossCityOrderId()) |
| | | // .eq("place", orderPrivateCar.getPlace()) |
| | | // ); |
| | | // List<OrderTaxi> list1 = orderTaxiService.selectList( |
| | | // new EntityWrapper<OrderTaxi>() |
| | | // .eq("type", 2) |
| | | // .eq("userId", orderPrivateCar.getUserId()) |
| | | // .ne("state", 1) |
| | | // .eq("crossCityOrderId", orderPrivateCar.getCrossCityOrderId()) |
| | | // .eq("place", orderPrivateCar.getPlace()) |
| | | // ); |
| | | // if(list.size() > 0 || list1.size() > 0){ |
| | | // return ResultUtil.error("手速有点慢哦,订单已被抢啦!"); |
| | | // } |
| | | } |
| | | |
| | | if(orderPrivateCar.getState() == 9){ |
| | | return ResultUtil.error("订单已取消"); |
| | | } |
| | | if(orderPrivateCar.getState() != 1){ |
| | | return ResultUtil.error("手速有点慢哦,订单已被抢啦!"); |
| | | } |
| | | Driver driver = driverService.selectById(uid); |
| | | orderPrivateCar.setDriverId(uid); |
| | | orderPrivateCar.setCarId(driver.getCarId()); |
| | | orderPrivateCar.setCompanyId(driver.getFranchiseeId() != null && driver.getFranchiseeId() != 0 ? driver.getFranchiseeId() : ( |
| | | driver.getCompanyId() != null && driver.getCompanyId() != 0 ? driver.getCompanyId() : 1)); |
| | | orderPrivateCar.setState(2); |
| | | orderPrivateCar.setSnatchOrderTime(new Date()); |
| | | |
| | | //调用高德创建轨迹 |
| | | String s = gdFalconUtil.selectTerminal(driver.getPhone()); |
| | | String track = gdFalconUtil.createTrack(s); |
| | | orderPrivateCar.setTrackId(track); |
| | | |
| | | //调用移动的小号接口 |
| | | // Map<String, String> geocode = gdMapGeocodingUtil.geocode(orderPrivateCar.getStartLon().toString(), orderPrivateCar.getStartLat().toString()); |
| | | // Region region = regionMapper.query(geocode.get("districtCode")); |
| | | // Map<String, String> map = chinaMobileUtil.midAxbBindSend(orderPrivateCar.getPassengersPhone(), driver.getPhone(), Integer.valueOf(region.getCitycode().substring(1))); |
| | | // if(String.valueOf(map.get("code")).equals("200")){ |
| | | // orderPrivateCar.setTelX(map.get("telX")); |
| | | // orderPrivateCar.setBindId(map.get("bindId")); |
| | | // } |
| | | |
| | | //处理摆渡车的情况 |
| | | if(orderPrivateCar.getType() == 2){ |
| | | // //查看用户下的摆渡车是否已被人抢了 |
| | | // List<OrderPrivateCar> list = this.selectList( |
| | | // new EntityWrapper<OrderPrivateCar>() |
| | | // .eq("type", 2) |
| | | // .eq("userId", orderPrivateCar.getUserId()) |
| | | // .ne("state", 1) |
| | | // .eq("crossCityOrderId", orderPrivateCar.getCrossCityOrderId()) |
| | | // .eq("place", orderPrivateCar.getPlace()) |
| | | // ); |
| | | // List<OrderTaxi> list1 = orderTaxiService.selectList( |
| | | // new EntityWrapper<OrderTaxi>() |
| | | // .eq("type", 2) |
| | | // .eq("userId", orderPrivateCar.getUserId()) |
| | | // .ne("state", 1) |
| | | // .eq("crossCityOrderId", orderPrivateCar.getCrossCityOrderId()) |
| | | // .eq("place", orderPrivateCar.getPlace()) |
| | | // ); |
| | | // for(OrderPrivateCar orderPrivateCar1 : list){ |
| | | // orderPrivateCar1.setState(10); |
| | | // this.updateById(orderPrivateCar1); |
| | | // } |
| | | // for(OrderTaxi orderTaxi : list1){ |
| | | // orderTaxi.setState(10); |
| | | // orderTaxiService.updateById(orderTaxi); |
| | | // } |
| | | } |
| | | |
| | | this.updateById(orderPrivateCar); |
| | | |
| | | //如果是预约单,则不修改司机为服务中 |
| | | if(orderPrivateCar.getOrderType() != 2 || (orderPrivateCar.getOrderType() == 2 && orderPrivateCar.getTravelTime().getTime() < System.currentTimeMillis() + 600000)){ |
| | | //修改司机为服务中 |
| | | driver.setState(3); |
| | | driverService.updateById(driver); |
| | | } |
| | | |
| | | //推送相关代码------------------start---------------- |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | pushUtil.pushOrderState(1, orderPrivateCar.getUserId(), orderPrivateCar.getId(), 7, orderPrivateCar.getState()); |
| | | pushUtil.pushOrderState(2, orderPrivateCar.getDriverId(), orderPrivateCar.getId(), 7, orderPrivateCar.getState()); |
| | | if(orderPrivateCar.getType() == 2){ |
| | | pushUtil.pushFerryOrderState(1, orderPrivateCar.getUserId(), orderPrivateCar.getId(), 1, 2); |
| | | } |
| | | } |
| | | }).start(); |
| | | |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | pushUtil.pushDriverPosition(orderId, 7); |
| | | } |
| | | }).start(); |
| | | |
| | | systemNoticeService.addSystemNotice(2, "您已成功抢得专车订单,请及时联系客户!", orderPrivateCar.getDriverId()); |
| | | systemNoticeService.addSystemNotice(1, "您的订单已指派给" + driver.getName().substring(0, 1) + "师傅,请保持电话畅通!", orderPrivateCar.getUserId()); |
| | | |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | if(pushMinistryOfTransport){ |
| | | //上传数据 |
| | | pushMinistryOfTransportUtil.orderCreate(orderId); |
| | | pushMinistryOfTransportUtil.orderMatch(orderId); |
| | | } |
| | | } |
| | | }).start(); |
| | | |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> getTransferOrderDetailById(Integer orderId) { |
| | | return this.baseMapper.getTransferOrderDetailById(orderId); |
| | | } |
| | |
| | | }) |
| | | public ResultUtil invoicing(Invoice invoice, String order, HttpServletRequest request){ |
| | | try { |
| | | |
| | | Integer uid = userInfoService.getUserIdFormRedis(request); |
| | | if(null == uid){ |
| | | return ResultUtil.tokenErr(); |
| | |
| | | import com.stylefeng.guns.modular.system.service.*; |
| | | //import com.stylefeng.guns.modular.system.util.ICBCPayUtil; |
| | | import com.stylefeng.guns.modular.system.service.impl.UserServiceImpl; |
| | | import com.stylefeng.guns.modular.system.util.ALiSendSms; |
| | | import com.stylefeng.guns.modular.system.util.PayMoneyUtil; |
| | | import com.stylefeng.guns.modular.system.util.RedisUtil; |
| | | import com.stylefeng.guns.modular.system.util.ResultUtil; |
| | | import com.stylefeng.guns.modular.system.util.*; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | @PostMapping("/get/coupon/info") |
| | | @ApiOperation(value = "使用说明", tags = {"线下推广页面"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "电话", name = "phone", required = true, dataType = "String"), |
| | | @ApiImplicitParam(value = "验证码", name = "code", required = true, dataType = "String") |
| | | |
| | | }) |
| | | public ResultUtil coupon(Integer acId){ |
| | | TActivityGeneralization tActivityGeneralization = activityGeneralizationService.selectById(acId); |
| | |
| | | return ResultUtil.success(tActivityGeneralization.getUseExplain()); |
| | | } |
| | | |
| | | @Autowired |
| | | private WeChatUtil weChatUtil; |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/get/coupon/toWe") |
| | | @ApiOperation(value = "获取微信链接", tags = {"线下推广页面"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | |
| | | }) |
| | | public ResultUtil toWe(){ |
| | | try { |
| | | String urlLink = weChatUtil.getUrlLink(null, null); |
| | | return ResultUtil.success(urlLink); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | return ResultUtil.error("请稍后再试"); |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | if(c.getTimeInMillis() > sdf.parse(day).getTime()){ |
| | | throw new SystemException("日期不能小于当天"); |
| | | } |
| | | |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | List<LineShift> lineShifts = lineShiftMapper.queryByLineId(lineId); |
| | | List<Map<String, Object>> s = lineSiteMapper.queryDriver(lineId, sdf.parse(day), driverId); |
| | |
| | | |
| | | |
| | | |
| | | <select id="queryMyInvoice" resultType="Invoice"> |
| | | <select id="queryMyInvoice" resultType="map"> |
| | | select |
| | | id as id, |
| | | insertTime as insertTime, |
New file |
| | |
| | | package com.stylefeng.guns.modular.system.kaipiao; |
| | | |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.stylefeng.guns.modular.system.kaipiao.email.KaiPiaoEmail; |
| | | import com.stylefeng.guns.modular.system.kaipiao.entity.InvoiceData; |
| | | import com.stylefeng.guns.modular.system.kaipiao.entity.InvoiceDetails; |
| | | import com.stylefeng.guns.modular.system.kaipiao.entity.MaterialInfo; |
| | | import com.stylefeng.guns.modular.system.kaipiao.entity.ReturnData; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | public class KaiPiaoUtil { |
| | | public static void main(String[] args) { |
| | | InvoiceData invoiceData = new InvoiceData(); |
| | | //设置纳税人识别号 |
| | | invoiceData.setNsrsbh(""); |
| | | |
| | | InvoiceDetails invoiceDetails = new InvoiceDetails(); |
| | | //设置订单号 |
| | | invoiceDetails.setOrderNo(""); |
| | | //设置发票种类 01专票 02普票 |
| | | invoiceDetails.setFppzDm("02"); |
| | | //设置销售方税号 |
| | | invoiceDetails.setXsfnsrsbh(""); |
| | | //设置销售方名称 |
| | | invoiceDetails.setXsfmc(""); |
| | | //设置销售方地址 |
| | | invoiceDetails.setXsfdz(""); |
| | | //设置销售方电话 |
| | | invoiceDetails.setXsflxdh(""); |
| | | //设置销售方开户行 |
| | | invoiceDetails.setXsfkhh(""); |
| | | //设置销售方银行账号 |
| | | invoiceDetails.setXsfyhzh(""); |
| | | //设置购买方税号 |
| | | invoiceDetails.setGmfnsrsbh(""); |
| | | //设置购买方名称 |
| | | invoiceDetails.setGmfmc(""); |
| | | //设置合计金额 |
| | | invoiceDetails.setHjje(""); |
| | | //设置合计税额 |
| | | invoiceDetails.setHjse(""); |
| | | //设置价税总计 |
| | | invoiceDetails.setJshj(""); |
| | | //设置开票方纳税人识别号 |
| | | invoiceDetails.setKpfnsrsbh(""); |
| | | //设置明细行数 |
| | | invoiceDetails.setSpsl("1"); |
| | | //设置含税标识 |
| | | invoiceDetails.setHsbz("2"); |
| | | |
| | | |
| | | //新建一个明细表 |
| | | List<MaterialInfo> materialInfos = new ArrayList<>(); |
| | | MaterialInfo materialInfo = new MaterialInfo(); |
| | | materialInfos.add(materialInfo); |
| | | invoiceDetails.setMxzbList(materialInfos); |
| | | |
| | | |
| | | |
| | | invoiceData.setData(invoiceDetails); |
| | | |
| | | |
| | | |
| | | System.err.println(JSONUtil.parse(invoiceData)); |
| | | //开票 |
| | | |
| | | |
| | | // String testData = "{\"nsrsbh\": \"91440400MA4WKU0K8A\", \"data\": {\"orderNo\": \"9d957b7229de4496ae487d1041415bbwasc\",\"fppzDm\": \"02\",\"tdyslxDm\":\"\",\"xsfnsrsbh\": \"91440400MA4WKU0K8A\",\"xsfmc\": \"广东欣档科技有限公司\",\"xsfdz\": \"珠海市高新区唐家湾镇大学路101号3栋102号\",\"xsflxdh\": \"13902872568\",\"xsfkhh\": \"中国建设银行股份有限公司珠海市分行营业部\",\"xsfyhzh\": \"22050164864700000347\",\"gmfnsrsbh\": \"91110105101781969R\",\"gmfmc\": \"北京市红牛维他命饮料有限责任公司\",\"gmfdz\": \"北京市朝阳区建国门外大街永安东里8号\",\"gmflxdh\": \"010-85288069\",\"gmfkhh\": \"中国工商银行北京商务中心区支行国贸大厦分理处\",\"gmfyhzh\": \"0200041609067021427\",\"kpr\": \"\",\"skr\": \"\",\"fhr\": \"\",\"hjje\": 69.29,\"hjse\": 9.01,\"jehj\": 0,\"jshj\": \"78.30\",\"kce\": 0,\"kpfnsrsbh\": \"91440400MA4WKU0K8A\",\"spsl\": 1,\"bz\": \"\",\"hsbz\": \"2\",\"sfzsgmfyhzh\": \"N\",\"sfzsxsfyhzh\": \"N\",\"mxzbList\": [{\"xh\": 1,\"fphxzDm\": \"0\",\"xmmc\": \"唯他可可椰子水/凤梨口味/330ML\",\"hwhyslwfwmc\": \"*软饮料*唯他可可椰子水/凤梨口味/330ML\",\"sphfwssflhbbm\": \"1030307020000000000\",\"spfwjc\": \"软饮料\",\"ggxh\": \"12瓶/箱\",\"dw\": \"箱\",\"spsl\": \"1\",\"dj\": 69.29,\"je\": 69.29,\"hsje\": 78.3,\"slv\": \"0.13\",\"se\": 9.01,\"kce\": \"\",\"hsdj\": 78.3,\"bhsdj\": 69.29,\"bhsje\": 69.29}]}}"; |
| | | // SptBlueInvOpenDemo blueInvOpenDemo = new SptBlueInvOpenDemo(); |
| | | // ReturnData returnData = blueInvOpenDemo.blueInvOpen(testData, "43b9ef0799534e298ca2b6b73a6cab48", "31s1m151s161"); |
| | | // System.out.println(returnData); |
| | | |
| | | //拿文件地址 |
| | | // String testData = "{\n" + |
| | | // "\t\"nsrsbh\": \"91440400MA4WKU0K8A\",\n" + |
| | | // "\t\"fphm\": \"24442000000000372439\",\n" + |
| | | // "\t\"kprq\": \"2024-05-29 11:52:25\"\n" + |
| | | // "}"; |
| | | // SptBlueInvOpenDemo blueInvOpenDemo = new SptBlueInvOpenDemo(); |
| | | // ReturnData returnData = blueInvOpenDemo.getUrl(testData, "43b9ef0799534e298ca2b6b73a6cab48", "31s1m151s161"); |
| | | // System.out.println(returnData); |
| | | |
| | | // 发邮件 |
| | | // String testData = "{\n" + |
| | | // "\t\"nsrsbh\": \"91440400MA4WKU0K8A\",\n" + |
| | | // "\t\"fphm\": \"24442000000000372439\",\n" + |
| | | // "\t\"sjyx\": \"2855143437@qq.com\"\n" + |
| | | // "}"; |
| | | // SptBlueInvOpenDemo blueInvOpenDemo = new SptBlueInvOpenDemo(); |
| | | // ReturnData returnData = blueInvOpenDemo.toEmail(testData, "43b9ef0799534e298ca2b6b73a6cab48", "31s1m151s161"); |
| | | // System.out.println(returnData); |
| | | |
| | | // 查结果 |
| | | // String testData = "{\n" + |
| | | // "\t\"nsrsbh\": \"91440400MA4WKU0K8A\",\n" + |
| | | // "\t\"jflsh\": \"3230867364023107584\"\n" + |
| | | // "}"; |
| | | // SptBlueInvOpenDemo blueInvOpenDemo = new SptBlueInvOpenDemo(); |
| | | // ReturnData returnData = blueInvOpenDemo.checkEamil(testData, "43b9ef0799534e298ca2b6b73a6cab48", "31s1m151s161"); |
| | | // System.out.println(returnData); |
| | | |
| | | |
| | | } |
| | | } |
New file |
| | |
| | | package com.stylefeng.guns.modular.system.kaipiao; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.stylefeng.guns.modular.system.kaipiao.entity.ReturnData; |
| | | import com.stylefeng.guns.modular.system.kaipiao.util.CreatAndSendUtil; |
| | | |
| | | |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.Base64; |
| | | |
| | | public class SptBlueInvOpenDemo { |
| | | |
| | | /** |
| | | * 调用数票通接口开具蓝字发票 |
| | | * @param dataJson 需要开具发票的订单信息及明细组成的json字符串,具体字段见接口对接文档 |
| | | * @param appSecret 企业密钥 由江苏航信分配获取 |
| | | * @param appId 企业标识 由江苏航信分配获取 |
| | | * @return ReturnData |
| | | */ |
| | | public static ReturnData blueInvOpen(String dataJson, String appSecret, String appId){ |
| | | /* |
| | | TODO |
| | | 校验订单流水号(orderNo),不能为空且不能与已开票据的重复 |
| | | */ |
| | | |
| | | //接口代码详见各业务接口说明 全电蓝字发票开具为:SALE.DZSJLZINVOPEN |
| | | String interfaceCode = "SALE.DZSJLZINVOPEN"; |
| | | |
| | | ReturnData returnData = CreatAndSendUtil.creatAndSend(dataJson, appSecret, appId, interfaceCode); |
| | | |
| | | if (returnData != null){ |
| | | if ("0000".equals(returnData.getReturn_info().getReturn_code())){ |
| | | String data = returnData.getData(); |
| | | byte[] decode = Base64.getDecoder().decode(data.getBytes(StandardCharsets.UTF_8)); |
| | | returnData.setData(new String(decode)); |
| | | JSONObject jsonObject = JSONObject.parseObject(new String(decode)); |
| | | // System.out.println("发票号码:" + jsonObject.get("fphm")); |
| | | // System.out.println("开票日期:" + jsonObject.get("kprq")); |
| | | /* |
| | | TODO |
| | | 开票成功,改变数据库中的数据等操作 |
| | | */ |
| | | }else { |
| | | /* |
| | | 开票失败,return_message查看失败原因 |
| | | */ |
| | | } |
| | | return returnData; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | public static ReturnData getUrl(String dataJson, String appSecret, String appId){ |
| | | /* |
| | | TODO |
| | | 校验订单流水号(orderNo),不能为空且不能与已开票据的重复 |
| | | */ |
| | | |
| | | //接口代码详见各业务接口说明 全电蓝字发票开具为:SALE.DZSJLZINVOPEN |
| | | String interfaceCode = "SALE.QDINVDOWNURL"; |
| | | |
| | | ReturnData returnData = CreatAndSendUtil.creatAndSend(dataJson, appSecret, appId, interfaceCode); |
| | | |
| | | if (returnData != null){ |
| | | if ("0000".equals(returnData.getReturn_info().getReturn_code())){ |
| | | String data = returnData.getData(); |
| | | byte[] decode = Base64.getDecoder().decode(data.getBytes(StandardCharsets.UTF_8)); |
| | | returnData.setData(new String(decode)); |
| | | JSONObject jsonObject = JSONObject.parseObject(new String(decode)); |
| | | // System.out.println("发票号码:" + jsonObject.get("fphm")); |
| | | // System.out.println("开票日期:" + jsonObject.get("kprq")); |
| | | /* |
| | | TODO |
| | | 开票成功,改变数据库中的数据等操作 |
| | | */ |
| | | }else { |
| | | /* |
| | | 开票失败,return_message查看失败原因 |
| | | */ |
| | | } |
| | | return returnData; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public static ReturnData toEmail(String dataJson, String appSecret, String appId){ |
| | | /* |
| | | TODO |
| | | 校验订单流水号(orderNo),不能为空且不能与已开票据的重复 |
| | | */ |
| | | |
| | | //接口代码详见各业务接口说明 全电蓝字发票开具为:SALE.DZSJLZINVOPEN |
| | | String interfaceCode = "SALE.OWNEMAILDELIVERY"; |
| | | |
| | | ReturnData returnData = CreatAndSendUtil.creatAndSend(dataJson, appSecret, appId, interfaceCode); |
| | | |
| | | if (returnData != null){ |
| | | if ("0000".equals(returnData.getReturn_info().getReturn_code())){ |
| | | String data = returnData.getData(); |
| | | byte[] decode = Base64.getDecoder().decode(data.getBytes(StandardCharsets.UTF_8)); |
| | | returnData.setData(new String(decode)); |
| | | JSONObject jsonObject = JSONObject.parseObject(new String(decode)); |
| | | // System.out.println("发票号码:" + jsonObject.get("fphm")); |
| | | // System.out.println("开票日期:" + jsonObject.get("kprq")); |
| | | /* |
| | | TODO |
| | | 开票成功,改变数据库中的数据等操作 |
| | | */ |
| | | }else { |
| | | /* |
| | | 开票失败,return_message查看失败原因 |
| | | */ |
| | | } |
| | | return returnData; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public static ReturnData checkEamil(String dataJson, String appSecret, String appId){ |
| | | /* |
| | | TODO |
| | | 校验订单流水号(orderNo),不能为空且不能与已开票据的重复 |
| | | */ |
| | | |
| | | //接口代码详见各业务接口说明 全电蓝字发票开具为:SALE.DZSJLZINVOPEN |
| | | String interfaceCode = "SALE.OWNEMAILDELIVERYQUERY"; |
| | | |
| | | ReturnData returnData = CreatAndSendUtil.creatAndSend(dataJson, appSecret, appId, interfaceCode); |
| | | |
| | | if (returnData != null){ |
| | | if ("0000".equals(returnData.getReturn_info().getReturn_code())){ |
| | | String data = returnData.getData(); |
| | | byte[] decode = Base64.getDecoder().decode(data.getBytes(StandardCharsets.UTF_8)); |
| | | returnData.setData(new String(decode)); |
| | | JSONObject jsonObject = JSONObject.parseObject(new String(decode)); |
| | | // System.out.println("发票号码:" + jsonObject.get("fphm")); |
| | | // System.out.println("开票日期:" + jsonObject.get("kprq")); |
| | | /* |
| | | TODO |
| | | 开票成功,改变数据库中的数据等操作 |
| | | */ |
| | | }else { |
| | | /* |
| | | 开票失败,return_message查看失败原因 |
| | | */ |
| | | } |
| | | return returnData; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.stylefeng.guns.modular.system.kaipiao.email; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.stylefeng.guns.modular.system.kaipiao.entity.GlobalInfo; |
| | | import com.stylefeng.guns.modular.system.kaipiao.util.CreatAndSendUtil; |
| | | import org.springframework.util.Base64Utils; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.io.IOException; |
| | | import java.nio.file.Files; |
| | | import java.nio.file.Paths; |
| | | import java.util.Base64; |
| | | |
| | | public class KaiPiaoEmail { |
| | | /** 带格式的正文内容 */ |
| | | public static String emailContent(){ |
| | | StringBuilder contentBuilder = new StringBuilder(); |
| | | contentBuilder.append("<h2>尊敬的友商,您好!</h2>"); |
| | | contentBuilder.append("<br/>"); |
| | | contentBuilder.append("<br/>"); |
| | | contentBuilder.append("购买方名称:某某某公司<br/>"); |
| | | contentBuilder.append("发票号码 : 11223344<br/>"); |
| | | contentBuilder.append("开具日期 : 2023-09-26<br/>"); |
| | | contentBuilder.append("价税合计 : 100¥<br/>"); |
| | | contentBuilder.append("<br/>"); |
| | | contentBuilder.append("<br/>"); |
| | | contentBuilder.append("<br/>"); |
| | | contentBuilder.append("<hr>"); |
| | | contentBuilder.append("您好!您已接收到全面数字化的电子发票。目前,全面数字化的电子发票在全国部分省(区、市)试点推广," + |
| | | "其法律效力、基本用途等与现有纸质发票相同。如您在办理涉及数电票业务的过程中遇到问题," + |
| | | "可以拨打当地12366纳税服务热线或到就近办税服务厅进行咨询或反馈意见建议,我们将竭诚帮助您解决相关问题。"); |
| | | return contentBuilder.toString(); |
| | | } |
| | | // 调用邮件代发接口时,需要的内层数据 |
| | | public static String agentEmailData(){ |
| | | JSONObject str = new JSONObject(); |
| | | str.put("subject","由power项目代发qq邮箱,经由jxfw项目,到163邮箱的的邮件"); |
| | | str.put("content",emailContent()); |
| | | str.put("nsrsbh","91440400MA4WKU0K8A"); |
| | | str.put("agentEmail","2855143437@qq.com"); |
| | | str.put("targetEmail","420516635@qq.com"); |
| | | str.put("host","smtp.qq.com"); |
| | | str.put("port","587"); |
| | | // str.put("fileBytes",fjBytes); |
| | | // str.put("fileName","通用蓝票.pdf"); |
| | | str.put("agentPasscode","rzkoxcfzwtizddaj"); |
| | | // base64编码 |
| | | String data = Base64Utils.encodeToString(str.toString().getBytes()); |
| | | return data; |
| | | } |
| | | /** |
| | | * 构建通用请求信息体 |
| | | * @param interfaceCode 接口code |
| | | * @param innerData 内部请求信息 |
| | | * |
| | | * */ |
| | | public static JSONObject createParam(String interfaceCode, String innerData){ |
| | | |
| | | // 对报名信息做签名认证操作 |
| | | |
| | | //生成报文globalInfo |
| | | GlobalInfo globalInfo = CreatAndSendUtil.createGlobalInfo(interfaceCode, "31s1m151s161"); |
| | | //生成数据签名 |
| | | String dataSign = CreatAndSendUtil.createDataSign(globalInfo.toString(), innerData, "43b9ef0799534e298ca2b6b73a6cab48"); |
| | | |
| | | JSONObject param = new JSONObject(); |
| | | param.put("global_info",globalInfo); |
| | | // 具体接口需要的报文信息 |
| | | param.put("data",innerData); |
| | | param.put("data_sign",dataSign); |
| | | return param; |
| | | } |
| | | public static JSONObject sendEmail() throws IOException { |
| | | RestTemplate restTemplate = new RestTemplate(); |
| | | // url换成真实地址,这里用的是本地地址 |
| | | String url = "https://csfw.jsaisino.com/csapp/invincomeservice"; |
| | | // 附件文件经过一次编码,byte[]类型数据经过一次编码 |
| | | // String enCodeData = Base64.getEncoder().encodeToString(Files.readAllBytes(Paths.get("D:\\MyText\\正常蓝票.pdf"))); |
| | | // createParam()方法是构建post请求的方法,自由实现 |
| | | JSONObject param = createParam("SALE.DZSJSENDEMAIL",agentEmailData()); |
| | | String result = restTemplate.postForObject(url, param, String.class); |
| | | System.err.println(result); |
| | | JSONObject resultJsonObject = JSONObject.parseObject(result); |
| | | return resultJsonObject; |
| | | } |
| | | } |
New file |
| | |
| | | package com.stylefeng.guns.modular.system.kaipiao.entity; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class ChargeInfo { |
| | | |
| | | private String xh; |
| | | private String pzlx; |
| | | private String fpdm; |
| | | private String fphm; |
| | | private String zzfphm; |
| | | private String pzhm; |
| | | private String kjrq; |
| | | private String hjje; |
| | | private String kce; |
| | | private String bz; |
| | | private String ly; |
| | | private String bckcje; |
| | | private String pzhjje; |
| | | |
| | | // getters and setters |
| | | |
| | | |
| | | // ... similar getters and setters for other fields ... |
| | | } |
New file |
| | |
| | | package com.stylefeng.guns.modular.system.kaipiao.entity; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class GlobalInfo { |
| | | |
| | | /** |
| | | * 应用代码 |
| | | */ |
| | | public String application_code; |
| | | |
| | | /** |
| | | * 接口代码 |
| | | */ |
| | | public String interface_code; |
| | | |
| | | /** |
| | | * 版本号 |
| | | */ |
| | | public String version; |
| | | |
| | | /** |
| | | * 企业简称 |
| | | */ |
| | | public String app_abbr; |
| | | |
| | | /** |
| | | * 企业标识 |
| | | */ |
| | | public String app_id; |
| | | |
| | | /** |
| | | * 数据流水号 |
| | | */ |
| | | public String data_id; |
| | | |
| | | /** |
| | | * 重写toString方法,用于签名 |
| | | * @see Object#toString() |
| | | */ |
| | | @Override |
| | | public String toString() { |
| | | |
| | | String str = "{" |
| | | + "\"global_info\":{" |
| | | + "\"application_code\":\"" + this.application_code + "\"," |
| | | + "\"interface_code\":\"" + this.interface_code + "\"," |
| | | + "\"version\":\"" + this.version + "\"," |
| | | + "\"app_abbr\":\"" + this.app_abbr + "\"," |
| | | + "\"app_id\":\"" + this.app_id + "\"," |
| | | + "\"data_id\":\"" + this.data_id + "\"" |
| | | + "},"; |
| | | return str; |
| | | } |
| | | } |
New file |
| | |
| | | package com.stylefeng.guns.modular.system.kaipiao.entity; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | @Data |
| | | public class InvoiceData { |
| | | |
| | | private String nsrsbh =""; |
| | | private InvoiceDetails data; |
| | | |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.stylefeng.guns.modular.system.kaipiao.entity; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | public class InvoiceDetails { |
| | | |
| | | private String orderNo =""; |
| | | private String fppzDm =""; |
| | | // private String tdyslxDm =""; |
| | | // private String cezslxDm =""; |
| | | private String xsfnsrsbh = ""; |
| | | private String xsfmc =""; |
| | | private String xsfdz =""; |
| | | private String xsflxdh =""; |
| | | private String xsfkhh = ""; |
| | | private String xsfyhzh = ""; |
| | | private String gmfnsrsbh = ""; |
| | | private String gmfmc = ""; |
| | | // private String gmfdz = ""; |
| | | // private String gmflxdh = ""; |
| | | // private String gmfkhh =""; |
| | | // private String gmfyhzh = ""; |
| | | // private String kpr = ""; |
| | | // private String skr = ""; |
| | | // private String fhr = ""; |
| | | private String hjje = ""; |
| | | private String hjse = ""; |
| | | // private String jehj = ""; |
| | | private String jshj = ""; |
| | | // private String kce = ""; |
| | | private String kpfnsrsbh = ""; |
| | | private String spsl = ""; |
| | | // private String bz = ""; |
| | | private String hsbz = ""; |
| | | // private String sfwzzfp ; |
| | | // private String zpFppzDm ; |
| | | private String fpdm = ""; |
| | | private String zzfphm = ""; |
| | | // private String kjly ; |
| | | // private String gmfZrrbs = ""; |
| | | private String sfzsgmfyhzh = ""; |
| | | private String sfzsxsfyhzh = ""; |
| | | private List<MaterialInfo> mxzbList; |
| | | // private List<ChargeInfo> cepzmxList; |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.stylefeng.guns.modular.system.kaipiao.entity; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class MaterialInfo { |
| | | |
| | | private String xh =""; |
| | | private String fphxzDm = ""; |
| | | private String xmmc = ""; |
| | | private String spfwjc = ""; |
| | | private String sphfwssflhbbm = ""; |
| | | private String hwhyslwfwmc = ""; |
| | | private String ggxh = ""; |
| | | private String dw = ""; |
| | | private String spsl = ""; |
| | | private String dj = ""; |
| | | private String hsdj = ""; |
| | | private String je = ""; |
| | | private String hsje = ""; |
| | | private String slv = ""; |
| | | private String se = ""; |
| | | private String kce = ""; |
| | | private String lslbz = ""; |
| | | private String xsyhzcbz = ""; |
| | | private String ssyhzclxDm = ""; |
| | | private String tdzsfsDm = ""; |
| | | private String zzstsgl = ""; |
| | | |
| | | } |
New file |
| | |
| | | package com.stylefeng.guns.modular.system.kaipiao.entity; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class ReturnData { |
| | | |
| | | /** |
| | | * 返回结果 |
| | | */ |
| | | private ReturnInfo return_info; |
| | | |
| | | /** |
| | | * 返回数据 业务接口响应报文的Base64编码 |
| | | */ |
| | | private String data; |
| | | |
| | | @Data |
| | | public static class ReturnInfo { |
| | | |
| | | /** |
| | | * 返回代码 0000:成功,其他:失败 |
| | | */ |
| | | private String return_code; |
| | | |
| | | /** |
| | | * 返回信息 |
| | | */ |
| | | private String return_message; |
| | | } |
| | | } |
New file |
| | |
| | | package com.stylefeng.guns.modular.system.kaipiao.util; |
| | | |
| | | |
| | | import cn.hutool.http.HttpUtil; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.stylefeng.guns.modular.system.kaipiao.entity.GlobalInfo; |
| | | import com.stylefeng.guns.modular.system.kaipiao.entity.ReturnData; |
| | | import org.springframework.util.Base64Utils; |
| | | import cn.hutool.core.codec.Base64; |
| | | import javax.crypto.Mac; |
| | | import javax.crypto.spec.SecretKeySpec; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.security.InvalidKeyException; |
| | | import java.security.NoSuchAlgorithmException; |
| | | import java.util.Objects; |
| | | |
| | | public class CreatAndSendUtil { |
| | | |
| | | /** |
| | | * 通用调用数票通接口 |
| | | * @param dataJson 业务接口请求报文json,具体字段见接口对接文档 |
| | | * @param appSecret 企业密钥 由江苏航信分配获取 |
| | | * @param appId 企业标识 由江苏航信分配获取 |
| | | * @param interfaceCode 接口代码 接口代码详见接口对接文档 |
| | | * @return ReturnData |
| | | */ |
| | | public static ReturnData creatAndSend(String dataJson, String appSecret, String appId, String interfaceCode){ |
| | | ReturnData returnData = new ReturnData(); |
| | | ReturnData.ReturnInfo returnInfo = new ReturnData.ReturnInfo(); |
| | | |
| | | //对json进行Base64编码 |
| | | String dataBase64Str = Base64.encode(dataJson, "UTF-8"); |
| | | //生成报文globalInfo |
| | | GlobalInfo globalInfo = CreatAndSendUtil.createGlobalInfo(interfaceCode, appId); |
| | | //生成数据签名 |
| | | String dataSign = CreatAndSendUtil.createDataSign(globalInfo.toString(), dataBase64Str, appSecret); |
| | | //组装请求报文 |
| | | JSONObject jsonObj = new JSONObject(); |
| | | jsonObj.put("global_info", globalInfo); |
| | | jsonObj.put("data", dataBase64Str); |
| | | jsonObj.put("data_sign", dataSign); |
| | | String qqbw = JSONObject.toJSONString(jsonObj); |
| | | //System.out.println(qqbw); |
| | | //发送请求,数票通url见接口对接文档 |
| | | String sptUrl = "https://csfw.jsaisino.com/csapp/invincomeservice"; |
| | | String returnStr = ""; |
| | | try { |
| | | returnStr = HttpUtil.post(sptUrl, qqbw); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | returnInfo.setReturn_code("9998"); |
| | | returnInfo.setReturn_message("http接口请求异常:" + e.getMessage()); |
| | | returnData.setReturn_info(returnInfo); |
| | | return returnData; |
| | | } |
| | | if (!Objects.equals(returnStr, "")){ |
| | | //将调用返回的数据进行转换 |
| | | JSONObject returnObj = JSONObject.parseObject(returnStr); |
| | | returnData = JSONObject.toJavaObject(returnObj, ReturnData.class); |
| | | return returnData; |
| | | } |
| | | return returnData; |
| | | } |
| | | |
| | | /** |
| | | * 创建外层报文 |
| | | * @param appId 企业标识 由江苏航信分配获取 |
| | | * @param interfaceCode 接口代码 接口代码详见接口对接文档 |
| | | * @return ReturnData |
| | | */ |
| | | public static GlobalInfo createGlobalInfo(String interfaceCode, String appId){ |
| | | GlobalInfo globalInfo = new GlobalInfo(); |
| | | globalInfo.setApplication_code("JXFW"); |
| | | globalInfo.setInterface_code(interfaceCode); |
| | | //版本 目前为1.0 |
| | | globalInfo.setVersion("1.0"); |
| | | globalInfo.setApp_abbr(""); |
| | | //企业标识 由江苏航信分配获取 |
| | | globalInfo.setApp_id(appId); |
| | | //数据流水号 企业标识+日期(yyyyMMdd)+序列号 |
| | | globalInfo.setData_id(""); |
| | | return globalInfo; |
| | | } |
| | | |
| | | /** |
| | | * 对报文进行加密,生成数据签名 |
| | | * @param globalInfoStr 外层报文Json |
| | | * @param data 数据 业务接口请求报文的Base64编码 |
| | | * @param appSecret 企业密钥 由江苏航信分配获取 |
| | | * @return String |
| | | */ |
| | | public static String createDataSign(String globalInfoStr, String data, String appSecret){ |
| | | String str = globalInfoStr + "\"data\":\"" + data + "\"," + "\"data_sign\":\"" + "\"" + "}"; |
| | | byte[] byteKey = appSecret.getBytes(StandardCharsets.UTF_8); |
| | | SecretKeySpec secretKeySpec = new SecretKeySpec(byteKey, "HmacSHA512"); |
| | | byte[] byteData = null; |
| | | try { |
| | | Mac mac = Mac.getInstance("HmacSHA512"); |
| | | mac.init(secretKeySpec); |
| | | byteData = mac.doFinal(str.getBytes(StandardCharsets.UTF_8)); |
| | | } catch (NoSuchAlgorithmException | InvalidKeyException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return Base64Utils.encodeToString(byteData); |
| | | } |
| | | } |
| | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.stylefeng.guns.modular.CharteredCar.model.OrderCharteredCar; |
| | | import com.stylefeng.guns.modular.CharteredCar.server.IOrderCharteredCarService; |
| | | import com.stylefeng.guns.modular.crossCity.dao.OrderCrossCityMapper; |
| | | import com.stylefeng.guns.modular.crossCity.model.OrderCrossCity; |
| | | import com.stylefeng.guns.modular.crossCity.server.IOrderCrossCityService; |
| | | import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar; |
| | | import com.stylefeng.guns.modular.specialTrain.server.IOrderPrivateCarService; |
| | | import com.stylefeng.guns.modular.system.dao.InvoiceMapper; |
| | | import com.stylefeng.guns.modular.system.model.Invoice; |
| | | import com.stylefeng.guns.modular.system.service.IInvoiceService; |
| | | import com.stylefeng.guns.modular.taxi.model.OrderTaxi; |
| | | import com.stylefeng.guns.modular.taxi.service.IOrderTaxiService; |
| | | import com.stylefeng.guns.modular.transfer.model.OrderTransferCar; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | @Autowired |
| | | private IOrderTaxiService orderTaxiService; |
| | | |
| | | @Autowired |
| | | private IOrderPrivateCarService orderPrivateCarService; |
| | | @Autowired |
| | | private IOrderCrossCityService crossCityService; |
| | | @Autowired |
| | | private IOrderCharteredCarService orderCharteredCarService; |
| | | |
| | | |
| | | /** |
| | |
| | | Integer orderId = jsonObject.getIntValue("id"); |
| | | switch (orderType){ |
| | | case 1://专车 |
| | | OrderPrivateCar privateCar= orderPrivateCarService.selectById(orderId); |
| | | sum.add(new BigDecimal(privateCar.getPayMoney())); |
| | | break; |
| | | case 2://出租车 |
| | | OrderTaxi orderTaxi = orderTaxiService.selectById(orderId); |
| | | sum.add(new BigDecimal(orderTaxi.getPayMoney())); |
| | | break; |
| | | case 3://跨城出行 |
| | | OrderCrossCity orderCrossCity = crossCityService.selectById(orderId); |
| | | sum.add(new BigDecimal(orderCrossCity.getPayMoney())); |
| | | break; |
| | | case 4://同城小件物流 |
| | | break; |
| | | case 5://跨城小件物流 |
| | | break; |
| | | // case 6://包车 |
| | | // OrderCharteredCar orderCharteredCar = orderCharteredCarService.selectById(orderId); |
| | | // sum.add(new BigDecimal(orderCharteredCar.getPayMoney())); |
| | | // break; |
| | | case 7://接送机 |
| | | break; |
| | | } |
| | | } |
| | | |
New file |
| | |
| | | package com.stylefeng.guns.modular.system.util; |
| | | |
| | | import org.codehaus.jettison.json.JSONObject; |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.InputStreamReader; |
| | | import java.net.HttpURLConnection; |
| | | import java.net.URL; |
| | | |
| | | |
| | | public class AmapGeocoding { |
| | | |
| | | private static final String AMAP_GEOCODING_API = "https://restapi.amap.com/v3/geocode/regeo"; |
| | | private static final String AMAP_KEY = "116e73b6d14f7da0292daa6037955749"; // 替换为你的高德地图API Key |
| | | |
| | | public static String getCityCode(double latitude, double longitude) throws Exception { |
| | | String url = AMAP_GEOCODING_API + "?location=" + longitude + "," + latitude |
| | | + "&output=json&key=" + AMAP_KEY + "&radius=1000&extensions=all"; |
| | | |
| | | HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection(); |
| | | connection.setRequestMethod("GET"); |
| | | connection.connect(); |
| | | |
| | | BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); |
| | | StringBuilder response = new StringBuilder(); |
| | | String line; |
| | | while ((line = reader.readLine()) != null) { |
| | | response.append(line); |
| | | } |
| | | reader.close(); |
| | | connection.disconnect(); |
| | | |
| | | JSONObject jsonObject = new JSONObject(response.toString()); |
| | | if ("1".equals(jsonObject.getString("status"))) { |
| | | JSONObject regeocode = jsonObject.getJSONObject("regeocode"); |
| | | JSONObject addressComponent = regeocode.getJSONObject("addressComponent"); |
| | | String cityCode = addressComponent.getString("adcode"); // adcode即为citycode |
| | | return cityCode; |
| | | } else { |
| | | throw new RuntimeException("Failed to fetch city code. Error message: " + jsonObject.getString("info")); |
| | | } |
| | | } |
| | | |
| | | public static String getCityName(double latitude, double longitude) throws Exception { |
| | | String url = AMAP_GEOCODING_API + "?location=" + longitude + "," + latitude |
| | | + "&output=json&key=" + AMAP_KEY + "&radius=1000&extensions=all"; |
| | | |
| | | HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection(); |
| | | connection.setRequestMethod("GET"); |
| | | connection.connect(); |
| | | |
| | | BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); |
| | | StringBuilder response = new StringBuilder(); |
| | | String line; |
| | | while ((line = reader.readLine()) != null) { |
| | | response.append(line); |
| | | } |
| | | reader.close(); |
| | | connection.disconnect(); |
| | | |
| | | JSONObject jsonObject = new JSONObject(response.toString()); |
| | | if ("1".equals(jsonObject.getString("status"))) { |
| | | JSONObject regeocode = jsonObject.getJSONObject("regeocode"); |
| | | JSONObject addressComponent = regeocode.getJSONObject("addressComponent"); |
| | | String cityName = addressComponent.getString("city"); // 这里改为了获取城市名称 |
| | | return cityName; |
| | | } else { |
| | | throw new RuntimeException("Failed to fetch city name. Error message: " + jsonObject.getString("info")); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | public static void main(String[] args) throws Exception { |
| | | double lat = 116.3913; // 纬度 |
| | | double lng = 39.90539; // 经度 |
| | | System.out.println("City Code: " + getCityCode(lat, lng)); |
| | | } |
| | | } |
New file |
| | |
| | | //package com.stylefeng.guns.modular.system.util; |
| | | // |
| | | //import com.alibaba.fastjson.JSON; |
| | | //import com.alibaba.fastjson.JSONObject; |
| | | //import com.stylefeng.guns.core.util.ToolUtil; |
| | | //import org.springframework.beans.factory.annotation.Autowired; |
| | | //import org.springframework.http.HttpEntity; |
| | | //import org.springframework.http.ResponseEntity; |
| | | //import org.springframework.stereotype.Component; |
| | | // |
| | | //import java.util.HashMap; |
| | | //import java.util.Map; |
| | | // |
| | | //@Component |
| | | //public class UrlLinkUtil { |
| | | // @Autowired |
| | | // private HttpClientUtil httpClientUtil; |
| | | // |
| | | // @Autowired |
| | | // private RedisUtil redisUtil; |
| | | // public String getWxAppletsAccessToken() throws Exception{ |
| | | // String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" + "wxc89ecab90d24edd8" + "&secret=" + "bca863174d22736a4a9758a67484947e"; |
| | | // String s = httpClientUtil.pushHttpRequset("GET", url, null, null, "form"); |
| | | // if(ToolUtil.isEmpty(s)){ |
| | | // return null; |
| | | // } |
| | | // JSONObject jsonObject = JSON.parseObject(s); |
| | | // return jsonObject.getString("access_token"); |
| | | // } |
| | | // |
| | | // public String getUrlLink(String path, String query) throws Exception{ |
| | | // String wxAppletsAccessToken = redisUtil.getValue("wxAppletsAccessToken"); |
| | | // String url = "https://api.weixin.qq.com/wxa/generate_urllink?access_token=" + wxAppletsAccessToken; |
| | | // Map<String, Object> param = new HashMap<>(); |
| | | // param.put("expire_type", 1); |
| | | // param.put("expire_interval", 1); |
| | | // param.put("path", path); |
| | | // param.put("query", query); |
| | | // param.put("env_version", "release"); |
| | | // HttpHeaders httpHeaders = new HttpHeaders(); |
| | | // MediaType type=MediaType.parseMediaType("application/json;charset=UTF-8"); |
| | | // httpHeaders.setContentType(type); |
| | | // HttpEntity<Map<String, Object>> requestEntity = new HttpEntity<>(param, httpHeaders); |
| | | // ResponseEntity<String> exchange = restTemplate.exchange(url, HttpMethod.POST, requestEntity, String.class); |
| | | // String body1 = exchange.getBody(); |
| | | // return body1; |
| | | // } |
| | | // |
| | | // |
| | | //} |
| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.system.util.HttpClientUtil; |
| | | import com.stylefeng.guns.modular.system.util.RedisUtil; |
| | | import com.stylefeng.guns.modular.system.util.UUIDUtil; |
| | | import org.apache.commons.codec.digest.DigestUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.http.*; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.io.ByteArrayInputStream; |
| | | import java.io.InputStream; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLDecoder; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.Timer; |
| | | import java.util.TimerTask; |
| | | |
| | | /** |
| | | * 微信工具类 |
| | |
| | | |
| | | @Autowired |
| | | private RestTemplate restTemplate; |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | * @return |
| | | */ |
| | | public String getAccessToken(){ |
| | | String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wx0e72f86394831b34&secret=930f857abc74f7bb5cbd89e1544c5669"; |
| | | String url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wxc89ecab90d24edd8&secret=bca863174d22736a4a9758a67484947e"; |
| | | String backData = restTemplate.getForObject(url, String.class); |
| | | String accessToken = JSONObject.parseObject(backData).getString("access_token"); |
| | | return accessToken; |
| | | } |
| | | |
| | | public String getUrlLink(String path, String query) throws Exception{ |
| | | String wxAppletsAccessToken = getAccessToken(); |
| | | String url = "https://api.weixin.qq.com/wxa/generate_urllink?access_token=" + wxAppletsAccessToken; |
| | | Map<String, Object> param = new HashMap<>(); |
| | | param.put("expire_type", 1); |
| | | param.put("expire_interval", 1); |
| | | param.put("path", path); |
| | | param.put("query", query); |
| | | param.put("env_version", "release"); |
| | | HttpHeaders httpHeaders = new HttpHeaders(); |
| | | MediaType type=MediaType.parseMediaType("application/json;charset=UTF-8"); |
| | | httpHeaders.setContentType(type); |
| | | HttpEntity<Map<String, Object>> requestEntity = new HttpEntity<>(param, httpHeaders); |
| | | ResponseEntity<String> exchange = restTemplate.exchange(url, HttpMethod.POST, requestEntity, String.class); |
| | | String body1 = exchange.getBody(); |
| | | return body1; |
| | | } |
| | | |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | @ResponseBody |
| | | @PostMapping("/get/site") |
| | | @ApiOperation(value = "获取站点", tags = {"用户端-接送机"}, notes = "") |
| | | @ApiImplicitParams({ |
| | | |
| | | }) |
| | | public ResultUtil site(double latitude, double longitude){ |
| | | |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | }, |
| | | { |
| | | "sourceType": "com.stylefeng.guns.core.config.properties.MutiDataSourceProperties", |
| | | "name": "guns.muti-datasource.data-source-names", |
| | | "type": "java.lang.String[]" |
| | | }, |
| | | { |
| | | "sourceType": "com.stylefeng.guns.core.config.properties.MutiDataSourceProperties", |
| | | "name": "guns.muti-datasource.driver-class-name", |
| | | "type": "java.lang.String" |
| | | }, |
| | | { |
| | | "sourceType": "com.stylefeng.guns.core.config.properties.MutiDataSourceProperties", |
| | | "name": "guns.muti-datasource.driver-class-name", |
| | | "type": "java.lang.String" |
| | | }, |
| | | { |
| | | "sourceType": "com.stylefeng.guns.core.config.properties.MutiDataSourceProperties", |
| | | "name": "guns.muti-datasource.driver-class-name", |
| | | "type": "java.lang.String" |
| | | }, |
| | | { |
| | | "sourceType": "com.stylefeng.guns.core.config.properties.MutiDataSourceProperties", |
| | | "name": "guns.muti-datasource.password", |
| | | "type": "java.lang.String" |
| | | }, |
| | | { |
| | |
| | | }, |
| | | { |
| | | "sourceType": "com.stylefeng.guns.core.config.properties.MutiDataSourceProperties", |
| | | "name": "guns.muti-datasource.url", |
| | | "type": "java.lang.String" |
| | | }, |
| | | { |
| | | "sourceType": "com.stylefeng.guns.core.config.properties.MutiDataSourceProperties", |
| | | "name": "guns.muti-datasource.username", |
| | | "type": "java.lang.String" |
| | | }, |
| | |
| | | }, |
| | | { |
| | | "sourceType": "com.stylefeng.guns.core.config.properties.MutiDataSourceProperties", |
| | | "name": "guns.muti-datasource.username", |
| | | "type": "java.lang.String" |
| | | }, |
| | | { |
| | | "sourceType": "com.stylefeng.guns.core.config.properties.MutiDataSourceProperties", |
| | | "name": "guns.muti-datasource.validation-query", |
| | | "type": "java.lang.String" |
| | | }, |
| | | { |
| | | "sourceType": "com.stylefeng.guns.core.config.properties.MutiDataSourceProperties", |
| | | "name": "guns.muti-datasource.validation-query", |
| | | "type": "java.lang.String" |
| | | }, |
| | |
| | | |
| | | |
| | | |
| | | <select id="queryMyInvoice" resultType="Invoice"> |
| | | <select id="queryMyInvoice" resultType="map"> |
| | | select |
| | | id as id, |
| | | insertTime as insertTime, |