| | |
| | | package com.stylefeng.guns.modular.smallLogistics.server.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.crossCity.model.OrderCrossCity; |
| | | import com.stylefeng.guns.modular.crossCity.server.impl.OrderCrossCityServiceImpl; |
| | | import com.stylefeng.guns.modular.smallLogistics.dao.OrderLogisticsMapper; |
| | | import com.stylefeng.guns.modular.smallLogistics.model.OrderLogistics; |
| | | import com.stylefeng.guns.modular.smallLogistics.model.OrderLogisticsSpread; |
| | | import com.stylefeng.guns.modular.smallLogistics.server.IOrderLogisticsService; |
| | | import com.stylefeng.guns.modular.smallLogistics.server.IOrderLogisticsSpreadService; |
| | | import com.stylefeng.guns.modular.specialTrain.dao.OrderPrivateCarMapper; |
| | | import com.stylefeng.guns.modular.specialTrain.model.OrderPrivateCar; |
| | | import com.stylefeng.guns.modular.specialTrain.server.IOrderPrivateCarService; |
| | | import com.stylefeng.guns.modular.specialTrain.server.impl.OrderPrivateCarServiceImpl; |
| | | import com.stylefeng.guns.modular.system.dao.*; |
| | | import com.stylefeng.guns.modular.system.model.*; |
| | | import com.stylefeng.guns.modular.system.service.*; |
| | |
| | | import com.stylefeng.guns.modular.system.util.Tingg.model.CheckoutRequest; |
| | | import com.stylefeng.guns.modular.system.util.Tingg.model.PayoutResponse; |
| | | import com.stylefeng.guns.modular.system.util.Tingg.model.Results; |
| | | import com.stylefeng.guns.modular.system.util.itextpdf.HtmlToPdfUtils; |
| | | import com.stylefeng.guns.modular.system.warpper.BaseWarpper; |
| | | import com.stylefeng.guns.modular.taxi.model.OrderTaxi; |
| | | import com.stylefeng.guns.modular.taxi.model.PaymentRecord; |
| | | import com.stylefeng.guns.modular.taxi.service.IPaymentRecordService; |
| | | import com.stylefeng.guns.modular.taxi.service.ITransactionDetailsService; |
| | |
| | | import org.jsoup.select.Elements; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.http.HttpEntity; |
| | | import org.springframework.http.HttpHeaders; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.LinkedMultiValueMap; |
| | | import org.springframework.util.MultiValueMap; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.FileOutputStream; |
| | | import java.io.FileWriter; |
| | | import java.math.BigDecimal; |
| | | import java.math.MathContext; |
| | | import java.math.RoundingMode; |
| | |
| | | |
| | | @Autowired |
| | | private IUserInfoService userInfoService; |
| | | |
| | | @Resource |
| | | private UserActivityDiscount1Mapper userActivityDiscount1Mapper; |
| | | @Autowired |
| | | private IPaymentRecordService paymentRecordService; |
| | | |
| | |
| | | @Value("${spring.mail.template-path}") |
| | | private String templatePath; |
| | | |
| | | @Autowired |
| | | private TEmailService emailService; |
| | | |
| | | private static List<Integer> orderIds = new ArrayList<>(); |
| | | |
| | | @Autowired |
| | | private IPhoneService phoneService; |
| | | |
| | | @Autowired |
| | | private ICancleOrderService cancleOrderService; |
| | | |
| | | @Autowired |
| | | private RestTemplate internalRestTemplate; |
| | | |
| | | @Autowired |
| | | private IRedEnvelopePaymentSettingsService redEnvelopePaymentSettingsService; |
| | | |
| | | @Autowired |
| | | private IUserRedPacketRecordService userRedPacketRecordService; |
| | | |
| | | @Autowired |
| | | private IOrderPrivateCarService orderPrivateCarService; |
| | | |
| | | @Resource |
| | | private OrderPrivateCarMapper orderPrivateCarMapper; |
| | | |
| | | @Autowired |
| | | private IDriverServiceService driverServiceService; |
| | | |
| | | @Autowired |
| | | private ISettlementRecordService settlementRecordService; |
| | | |
| | | @Resource |
| | | private CarServiceMapper carServiceMapper; |
| | | |
| | | @Autowired |
| | | private IAssignOrderService assignOrderService; |
| | | |
| | | @Autowired |
| | | private ISettlementDetailService settlementDetailService; |
| | | |
| | | @Autowired |
| | | private ISettlementAllocationService settlementAllocationService; |
| | | |
| | | @Resource |
| | | private CarMapper carMapper; |
| | | |
| | | @Autowired |
| | | private IOrderEvaluateService orderEvaluateService; |
| | | |
| | | @Autowired |
| | | private IUserActivityRedenvelopeService userActivityRedenvelopeService; |
| | | |
| | | |
| | | |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil queryLogisticsUnitPrice(Integer type, String startLonLat, String endAddress, Integer uid, Integer language) throws Exception { |
| | | FindPlaceFromTextVo findplacefromtext = GoogleMapUtil.textsearch(endAddress); |
| | | if(null == findplacefromtext){ |
| | | return ResultUtil.error(language == 1 ? "收货地址有误,无法查询具体地址信息" : language == 2 ? "The delivery address is incorrect, and the specific address information cannot be queried" : "L’adresse de livraison est incorrecte, impossible de vérifier l’adresse spécifique"); |
| | | } |
| | | Double lng = findplacefromtext.getLng(); |
| | | Double lat = findplacefromtext.getLat(); |
| | | ResultUtil<Map<String, Double>> price = this.getPrice1(type, startLonLat.split(",")[0], startLonLat.split(",")[1], lng.toString(), lat.toString(), language); |
| | | public ResultUtil queryLogisticsUnitPrice(Integer type, String startLonLat, String endLonLat, String endAddress, Integer uid, Integer language) throws Exception { |
| | | String[] split = endLonLat.split(","); |
| | | Double lng = Double.valueOf(split[0]); |
| | | Double lat = Double.valueOf(split[1]); |
| | | ResultUtil<Map<String, Object>> price = this.getPrice1(type, startLonLat.split(",")[0], startLonLat.split(",")[1], lng.toString(), lat.toString(), language); |
| | | if(price.getCode() != 200){ |
| | | return price; |
| | | } |
| | | Integer i = this.selectCount(new EntityWrapper<OrderLogistics>().eq("userId", uid).eq("isDelete", 1)); |
| | | Map<String, Double> map = price.getData(); |
| | | Map<String, Object> map = price.getData(); |
| | | map.put("first", i.doubleValue()); |
| | | return price; |
| | | } |
| | |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | public ResultUtil queryPayMoney(Integer number, Integer type, String startLonLat, String endAddress, Integer language) throws Exception{ |
| | | FindPlaceFromTextVo findplacefromtext = GoogleMapUtil.textsearch(endAddress); |
| | | if(null == findplacefromtext){ |
| | | return ResultUtil.error(language == 1 ? "收货地址有误,无法查询具体地址信息" : language == 2 ? "The delivery address is incorrect, and the specific address information cannot be queried" : "L’adresse de livraison est incorrecte, impossible de vérifier l’adresse spécifique"); |
| | | } |
| | | Double lng = findplacefromtext.getLng(); |
| | | Double lat = findplacefromtext.getLat(); |
| | | ResultUtil<Map<String, Double>> price = this.getPrice1(type, startLonLat.split(",")[0], startLonLat.split(",")[1], lng.toString(), lat.toString(), language); |
| | | public ResultUtil queryPayMoney(Integer number, Integer type, String startLonLat, String endLonLat, String endAddress, Integer language) throws Exception{ |
| | | String[] split = endLonLat.split(","); |
| | | Double lng = Double.valueOf(split[0]); |
| | | Double lat = Double.valueOf(split[1]); |
| | | ResultUtil<Map<String, Object>> price = this.getPrice1(type, startLonLat.split(",")[0], startLonLat.split(",")[1], lng.toString(), lat.toString(), language); |
| | | if(price.getCode() == 200 && type == 5){ |
| | | Map<String, Double> data = price.getData(); |
| | | data.put("ordinary", data.get("ordinary") * number); |
| | | data.put("precious", data.get("precious") * number); |
| | | Map<String, Object> data = price.getData(); |
| | | Double ordinary = Double.valueOf(data.get("ordinary").toString()); |
| | | Double precious = Double.valueOf(data.get("precious").toString()); |
| | | data.put("ordinary", ordinary * number); |
| | | data.put("precious", precious * number); |
| | | } |
| | | if(price.getCode() == 200){ |
| | | Map<String, Object> data = price.getData(); |
| | | Double ordinary = Double.valueOf(data.get("ordinary").toString()); |
| | | Double precious = Double.valueOf(data.get("precious").toString()); |
| | | Double discountMoney = Double.valueOf(data.get("discountMoney").toString()); |
| | | data.put("ordinary", ordinary - discountMoney); |
| | | data.put("precious", precious - discountMoney); |
| | | } |
| | | return price; |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public ResultUtil smallLogistics(Integer type, Integer cargoType, Integer cargoNumber, String remark, String placementLon, String placementLat, String startLon, String startLat, String startAddress, String recipient, |
| | | String recipientPhone, String endAddress, Integer urgent, Double tipMoney, Date travelTime, Integer orderSource, Integer uid, Integer language) throws Exception { |
| | | String recipientPhone, String endLonLat, String endAddress, Integer urgent, Double tipMoney, Date travelTime, Integer orderSource, Integer uid, Integer language) throws Exception { |
| | | startAddress = startAddress.replaceAll("& #40;", "("); |
| | | startAddress = startAddress.replaceAll("& #41;", ")"); |
| | | endAddress = endAddress.replaceAll("& #40;", "("); |
| | |
| | | OrderLogistics orderLogistics = new OrderLogistics(); |
| | | Company query = companyCityService.query1(placementLon, placementLat); |
| | | if(null == query){ |
| | | return ResultUtil.error(language == 1 ? "该地点暂无企业服务" : language == 2 ? "No corporate services are available at this location" : "Aucun service d’entreprise n’est disponible pour cet emplacement"); |
| | | return ResultUtil.error(language == 1 ? "该地点暂无企业服务" : language == 2 ? "No service yet at this area" : "Pas encore de service dans cette zone"); |
| | | } |
| | | orderLogistics.setCompanyId(query.getId()); |
| | | orderLogistics.setType(type); |
| | |
| | | orderLogistics.setPlacementLat(Double.valueOf(placementLat)); |
| | | ReverseGeocodeVo reverseGeocode = GoogleMapUtil.getReverseGeocode(Double.valueOf(placementLat), Double.valueOf(placementLon)); |
| | | if(null == reverseGeocode){ |
| | | return ResultUtil.error(language == 1 ? "解析地址出错" : language == 2 ? "Resolve address error" : "Erreur dans la résolution de l’adresse"); |
| | | return ResultUtil.error(language == 1 ? "解析地址出错" : language == 2 ? "Address resolution error" : "Erreur de résolution d’adresse"); |
| | | } |
| | | |
| | | String address = reverseGeocode.getAddress(); |
| | |
| | | orderLogistics.setStartLon(Double.valueOf(startLon)); |
| | | orderLogistics.setStartLat(Double.valueOf(startLat)); |
| | | orderLogistics.setStartAddress(startAddress); |
| | | FindPlaceFromTextVo findplacefromtext = GoogleMapUtil.textsearch(endAddress); |
| | | if(null == findplacefromtext){ |
| | | return ResultUtil.error(language == 1 ? "收货地址有误,无法查询具体地址信息" : language == 2 ? "The delivery address is incorrect, and the specific address information cannot be queried" : "L’adresse de livraison est incorrecte, impossible de vérifier l’adresse spécifique"); |
| | | } |
| | | Double lng = findplacefromtext.getLng(); |
| | | Double lat = findplacefromtext.getLat(); |
| | | |
| | | String[] split = endLonLat.split(","); |
| | | Double lng = Double.valueOf(split[0]); |
| | | Double lat = Double.valueOf(split[1]); |
| | | orderLogistics.setEndLon(lng); |
| | | orderLogistics.setEndLat(lat); |
| | | orderLogistics.setEndAddress(endAddress); |
| | |
| | | orderLogistics.setMileage(0D); |
| | | orderLogistics.setIsReassign(1); |
| | | orderLogistics.setReassignNotice(0); |
| | | ResultUtil<Map<String, Double>> price = this.getPrice1(type, String.valueOf(startLon), String.valueOf(startLat), lng.toString(), lat.toString(), language); |
| | | ResultUtil<Map<String, Object>> price = this.getPrice1(type, String.valueOf(startLon), String.valueOf(startLat), lng.toString(), lat.toString(), language); |
| | | if(price.getCode() != 200){ |
| | | return price; |
| | | } |
| | | Map<String, Double> data = price.getData(); |
| | | orderLogistics.setOrderMoney((cargoType == 1 ? data.get("ordinary") : data.get("precious")) + tipMoney); |
| | | orderLogistics.setTravelMoney(cargoType == 1 ? data.get("ordinary") : data.get("precious")); |
| | | if(type == 5){ |
| | | orderLogistics.setOrderMoney(((cargoType == 1 ? data.get("ordinary") : data.get("precious")) * cargoNumber) + tipMoney); |
| | | orderLogistics.setTravelMoney((cargoType == 1 ? data.get("ordinary") : data.get("precious")) * cargoNumber); |
| | | Map<String, Object> data = price.getData(); |
| | | Double ordinary = Double.valueOf(data.get("ordinary").toString()); |
| | | Double precious = Double.valueOf(data.get("precious").toString()); |
| | | Double discount = null; |
| | | if(null != data.get("discount")){ |
| | | discount = Double.valueOf(data.get("discount").toString()); |
| | | } |
| | | orderLogistics.setTipMoney(tipMoney); |
| | | Double discountMoney = Double.valueOf(data.get("discountMoney").toString()); |
| | | Integer activityId = null; |
| | | if(null != data.get("activityId")){ |
| | | activityId = Integer.valueOf(data.get("activityId").toString()); |
| | | } |
| | | orderLogistics.setOrderMoney((cargoType == 1 ? ordinary : precious) + tipMoney); |
| | | // orderLogistics.setTravelMoney((cargoType == 1 ? ordinary : precious)); |
| | | if(type == 5){ |
| | | orderLogistics.setOrderMoney(((cargoType == 1 ? ordinary : precious) * cargoNumber) + tipMoney); |
| | | // orderLogistics.setTravelMoney((cargoType == 1 ? ordinary : precious) * cargoNumber); |
| | | } |
| | | orderLogistics.setDiscount(discount); |
| | | orderLogistics.setDiscountMoney(discountMoney); |
| | | orderLogistics.setActivityId(activityId); |
| | | orderLogistics.setState(7);//待支付 |
| | | orderLogistics.setInsertTime(new Date()); |
| | | orderLogistics.setTravelTime(null == travelTime ? new Date() : travelTime); |
| | |
| | | |
| | | //添加消息 |
| | | systemNoticeService.addSystemNotice(1, language == 1 ? "您的市内包裹订单已下单成功,我们正在为您指派司机,请稍后!" : |
| | | language == 2 ? "Your parcel order has been successfully placed, we are assigning a driver for you, please wait!" |
| | | : "Votre commande de colis a bien été passée, nous vous assignons un chauffeur, veuillez patienter!", orderLogistics.getUserId(), 1); |
| | | language == 2 ? "You've placed the delivery order successfully, we are assigning you a driver, please wait." |
| | | : "Vous avez passé la commande de livraison avec succès, nous vous attribuons un chauffeur, veuillez patienter.", orderLogistics.getUserId(), 1); |
| | | |
| | | BaseWarpper baseWarpper = new BaseWarpper(); |
| | | baseWarpper.setId(orderLogistics.getId()); |
| | |
| | | |
| | | |
| | | |
| | | public ResultUtil<Map<String, Double>> getPrice1(Integer type, String startLon, String startLat, String endLon, String endLat, Integer language) throws Exception{ |
| | | public ResultUtil<Map<String, Object>> getPrice1(Integer type, String startLon, String startLat, String endLon, String endLat, Integer language) throws Exception{ |
| | | Company query = companyCityService.query1(startLon, startLat); |
| | | if(null == query){ |
| | | return ResultUtil.error(language == 1 ? "预约取货点暂无企业服务" : language == 2 ? |
| | | "There is no enterprise service at the reservation pickup point" : "Prise de rendez-vous point de collecte pas encore disponible pour les entreprises"); |
| | | "No service yet at the reserved pickup point." : "Les points de ramassage prévus ne sont pas disponibles pour le moment."); |
| | | } |
| | | Double price1 = 0D; |
| | | Double price2 = 0D; |
| | | Double discount = null; |
| | | Double discountMoney = 0D; |
| | | Integer activityId = null; |
| | | if(type == 4){//同城 |
| | | Map<String, Object> query1 = systemPriceMapper.query(query.getId(), type, null); |
| | | DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(Double.valueOf(startLat), Double.valueOf(startLon), Double.valueOf(endLat), Double.valueOf(endLon)); |
| | | if(null == distancematrix){ |
| | | return ResultUtil.error(language == 1 ? "计算距离出错" : language == 2 ? "Error in distance calculation" : "Erreur de calcul des distances"); |
| | | return ResultUtil.error(language == 1 ? "计算距离出错" : language == 2 ? "Errors in computing distance" : "Erreurs dans le calcul de la distance"); |
| | | } |
| | | if(distancematrix.getDistance() == 0){ |
| | | return ResultUtil.error(language == 1 ? "未获取到有效的距离" : language == 2 ? "A valid distance was not obtained" : "La distance effective n’est pas acquise"); |
| | | return ResultUtil.error(language == 1 ? "未获取到有效的距离" : language == 2 ? "Not obtaining available distance" : "Ne pas obtenir la distance disponible"); |
| | | } |
| | | String content = String.valueOf(query1.get("content")); |
| | | JSONObject jsonObject = JSON.parseObject(content); |
| | |
| | | price1 = jsonObject.getDouble("num11"); |
| | | } |
| | | if(dist.compareTo(jsonObject.getDouble("num10")) > 0){ |
| | | return ResultUtil.error(language == 1 ? "超出可服务范围" : language == 2 ? "Out of service range" : "Au-delà du service disponible"); |
| | | return ResultUtil.error(language == 1 ? "超出可服务范围" : language == 2 ? "Beyond service range" : "Au-delà de la portée de service"); |
| | | } |
| | | }else{ |
| | | Map<String, Object> query1 = systemPriceMapper.query(query.getId(), type, null); |
| | |
| | | price1 = jsonObject.getDouble("num1"); |
| | | price2 = jsonObject.getDouble("num2"); |
| | | } |
| | | Map<String, Double> map = new HashMap<>(); |
| | | |
| | | //计算折扣 |
| | | UserActivityDiscount1 query2 = userActivityDiscount1Mapper.query(query.getId()); |
| | | if(null != query2){ |
| | | activityId = query2.getId(); |
| | | discount = query2.getLogistics(); |
| | | if(null != discount){ |
| | | discountMoney = new BigDecimal(price1).multiply(new BigDecimal(discount / 10)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue(); |
| | | } |
| | | } |
| | | |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("ordinary", price1);//普通 |
| | | map.put("precious", price2);//贵重 |
| | | map.put("discount", discount);//折扣 |
| | | map.put("discountMoney", discountMoney);//折扣金额 |
| | | map.put("activityId", activityId);//折扣活动id |
| | | return ResultUtil.success(map); |
| | | } |
| | | |
| | |
| | | for(int i = 1; i <= querys.size(); i++){ |
| | | PushOrder pushOrder = pushOrderService.querys(i, 1, query.getId()).get(0); |
| | | //获取空闲司机 |
| | | List<Driver> list = driverService.queryIdleDriver(orderLogistics.getType(), null, orderLogistics.getStartLon(), orderLogistics.getStartLat(), pushOrder.getPushDistance(), null);//所有附近空闲司机 |
| | | List<Driver> list = driverService.queryIdleDriver(orderLogistics.getType(), orderLogistics.getServerCarModelId(), orderLogistics.getStartLon(), orderLogistics.getStartLat(), pushOrder.getPushDistance(), null);//所有附近空闲司机 |
| | | System.err.println("【" + orderLogistics.getId() + "】空闲司机:" + JSON.toJSONString(list)); |
| | | if(list.size() > 0){ |
| | | double driverProportion = pushOrder.getDriverProportion() / 100;//推送占比计算成小数 |
| | | int lastIndex = Double.valueOf(list.size() * driverProportion).intValue();//计算占比转成整数(下标截取) |
| | |
| | | } |
| | | }).start(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 包裹下单2.0 |
| | | * @param remark |
| | | * @param placementLon |
| | | * @param placementLat |
| | | * @param startLon |
| | | * @param startLat |
| | | * @param startAddress |
| | | * @param recipient |
| | | * @param recipientPhone |
| | | * @param endLon |
| | | * @param endLat |
| | | * @param endAddress |
| | | * @param serverCarModelId |
| | | * @param driverId |
| | | * @param orderSource |
| | | * @param uid |
| | | * @param language |
| | | * @return |
| | | */ |
| | | @Override |
| | | public ResultUtil placeOrderPackage(String remark, String placementLon, String placementLat, String startLon, String startLat, String startAddress, |
| | | String recipient, String recipientPhone, String endLon, String endLat, String endAddress, |
| | | Integer serverCarModelId, Integer driverId, Integer orderSource, Integer uid, Integer language) throws Exception { |
| | | /** |
| | | * 1.下了即时单就不能下预约单和即时单 |
| | | * 2.下了预约单和再下一张即时单不能再下预约单 |
| | | */ |
| | | List<OrderPrivateCar> orderPrivateCars = orderPrivateCarMapper.queryByState(uid, 1, 1, 1, 2, 3, 4, 5, 6, 11); |
| | | if(orderPrivateCars.size() > 0){ |
| | | return ResultUtil.error(language == 1 ? "有未完成的订单" : language == 2 ? "Uncompleted order(s)" : "Commande(s) non complétée(s)"); |
| | | } |
| | | int selectCount = this.selectCount(new EntityWrapper<OrderLogistics>().eq("userId", uid).eq("isDelete", 1) |
| | | .in("state", Arrays.asList(1, 2, 3, 4, 5, 7, 11, 12))); |
| | | if(0 < selectCount){ |
| | | return ResultUtil.error(language == 1 ? "有未完成的订单" : language == 2 ? "Uncompleted order(s)" : "Commande(s) non complétée(s)"); |
| | | } |
| | | startAddress = startAddress.replaceAll("& #40;", "("); |
| | | startAddress = startAddress.replaceAll("& #41;", ")"); |
| | | endAddress = endAddress.replaceAll("& #40;", "("); |
| | | endAddress = endAddress.replaceAll("& #41;", ")"); |
| | | if((orderSource == 1 || orderSource == 3) && null == serverCarModelId){ |
| | | return ResultUtil.error(language == 1 ? "请选择服务车型" : language == 2 ? "Please select vehicle-type" : "Veuillez sélectionner le type de véhicule"); |
| | | } |
| | | |
| | | OrderLogistics orderLogistics = new OrderLogistics(); |
| | | orderLogistics.setType(4); |
| | | orderLogistics.setUserId(uid); |
| | | orderLogistics.setServerCarModelId(serverCarModelId); |
| | | orderLogistics.setOrderNum(this.getOrderNum()); |
| | | orderLogistics.setPlacementLon(Double.valueOf(placementLon)); |
| | | orderLogistics.setPlacementLat(Double.valueOf(placementLat)); |
| | | orderLogistics.setCargoType(1); |
| | | orderLogistics.setUrgent(1); |
| | | orderLogistics.setCargoNumber(1); |
| | | |
| | | ReverseGeocodeVo reverseGeocode = GoogleMapUtil.getReverseGeocode(Double.valueOf(placementLat), Double.valueOf(placementLon)); |
| | | orderLogistics.setPlacementAddress(reverseGeocode.getAddress()); |
| | | orderLogistics.setStartLon(Double.valueOf(startLon)); |
| | | orderLogistics.setStartLat(Double.valueOf(startLat)); |
| | | orderLogistics.setStartAddress(startAddress); |
| | | orderLogistics.setEndLon(Double.valueOf(endLon)); |
| | | orderLogistics.setEndLat(Double.valueOf(endLat)); |
| | | orderLogistics.setEndAddress(endAddress); |
| | | orderLogistics.setRecipient(recipient); |
| | | orderLogistics.setRecipientPhone(recipientPhone); |
| | | orderLogistics.setState(1); |
| | | orderLogistics.setInsertTime(new Date()); |
| | | orderLogistics.setTravelTime(new Date()); |
| | | orderLogistics.setOrderSource(orderSource); |
| | | if(orderSource == 2){//扫码下单 |
| | | Driver driver = driverService.selectById(driverId); |
| | | if(null == driver){ |
| | | return ResultUtil.error(language == 1 ? "司机信息有误,无法完成下单" : language == 2 ? "Wrong driver-information, unable to place an order." : "Informations erronées sur le chauffeur, il ne peut donc pas passer une commande."); |
| | | } |
| | | if(driver.getAuthState() == 1){ |
| | | return ResultUtil.error(language == 1 ? "司机信息还未完成审核,无法完成下单" : language == 2 ? "The driver is not yet done with review, unable to place an order." : "Le chauffeur n’a pas encore terminé son examen, il ne peut donc pas passer une commande."); |
| | | } |
| | | if(driver.getAuthState() == 3){ |
| | | return ResultUtil.error(language == 1 ? "司机账户已被冻结,无法提供服务" : language == 2 ? "Driver account is frozen, unable to provide service." : "Le compte du chauffeur est gelé, il n’est donc pas possible de fournir des services."); |
| | | } |
| | | if(driver.getAuthState() == 4){ |
| | | return ResultUtil.error(language == 1 ? "司机信息未通过审核,无法提供服务" : language == 2 ? "The driver is not verified and qualified, unable to provide service." : "Le chauffeur n’est pas vérifié et qualifié, incapable de fournir le services."); |
| | | } |
| | | if(driver.getState() == 1){ |
| | | return ResultUtil.error(language == 1 ? "司机还未上线,无法提供服务" : language == 2 ? "The driver is not online, unable to provide service." : "Le chauffeur n’est pas en ligne, incapable de fournir le services."); |
| | | } |
| | | if(driver.getState() == 3){ |
| | | return ResultUtil.error(language == 1 ? "司机正在服务中,无法提供服务" : language == 2 ? "The driver is on a trip, unable to provide service." : "Le chauffeur est en service, incapable de fournir des services."); |
| | | } |
| | | List<DriverService> query = driverServiceService.query(driverId, 4); |
| | | if(query.size() == 0){ |
| | | return ResultUtil.error(language == 1 ? "该司机不能服务此业务" : language == 2 ? "Driver has outstanding fees to pay, unable to receive orders." : "Le chauffeur a des frais impayés à payer, incapable de recevoir des commandes."); |
| | | } |
| | | int count = settlementRecordService.selectCount(new EntityWrapper<SettlementRecord>().eq("driverId", driverId).eq("paymentStatus", 1)); |
| | | if(count > 0){ |
| | | return ResultUtil.error(language == 1 ? "司机未支付订单费用,无法进行接单" : language == 2 ? "Driver has outstanding fees to pay, unable to receive orders." : "Le chauffeur a des frais impayés à payer, incapable de recevoir des commandes."); |
| | | } |
| | | |
| | | orderLogistics.setDriverId(driverId); |
| | | orderLogistics.setCompanyId(driver.getFranchiseeId() != null && driver.getFranchiseeId() != 0 ? driver.getFranchiseeId() : ( |
| | | driver.getCompanyId() != null && driver.getCompanyId() != 0 ? driver.getCompanyId() : 1)); |
| | | orderLogistics.setState(2); |
| | | orderLogistics.setCarId(driver.getCarId()); |
| | | CarService query1 = carServiceMapper.query(1, driver.getCarId()); |
| | | orderLogistics.setServerCarModelId(query1.getServerCarModelId()); |
| | | orderLogistics.setSnatchOrderTime(new Date()); |
| | | |
| | | driver.setState(3); |
| | | driverService.updateById(driver); |
| | | } |
| | | |
| | | orderLogistics.setIsReassign(1); |
| | | orderLogistics.setIsDelete(1); |
| | | this.insert(orderLogistics); |
| | | |
| | | if(orderSource == 2){//扫码下单 |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | pushUtil.pushOrderState(1, uid, orderLogistics.getId(), 4, 2, 0); |
| | | pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), 4, 2, 0); |
| | | } |
| | | }).start(); |
| | | } |
| | | |
| | | |
| | | // TODO: 2021/5/11 修改,根据后台设定的派单范围查询范围内有无司机,将单子指派给距离最近的司机(距离相同随机取),范围内没有司机再进行推单流程 |
| | | if(orderLogistics.getState() == 1){ |
| | | Company query = companyCityService.query1(orderLogistics.getStartLon().toString(), orderLogistics.getStartLat().toString()); |
| | | if(null == query){ |
| | | return ResultUtil.error(language == 1 ? "起点暂未企业提供服务" : language == 2 ? "Starting point no enterprise to provide services" : "Point de départ pas encore disponible pour les entreprises"); |
| | | } |
| | | AssignOrder assignOrder = assignOrderService.selectOne(new EntityWrapper<AssignOrder>().eq("companyId", query.getId()).eq("type", 1)); |
| | | if(null != assignOrder && assignOrder.getPeople() > 0){//配置了指派规则才处理 |
| | | //获取空闲司机 |
| | | List<Driver> drivers = driverService.queryIdleDriver(4, orderLogistics.getServerCarModelId(), orderLogistics.getStartLon(), orderLogistics.getStartLat(), assignOrder.getDistance(), null);//获取范围内空闲司机 |
| | | if(drivers.size() > 0){//有司机,直接指派给司机 |
| | | Driver dr = null; |
| | | if(drivers.size() > 1){ |
| | | List<Driver> ds = new ArrayList<>();//存储直线距离最近的几个司机 |
| | | for(int i = 0; i < assignOrder.getPeople(); i++){ |
| | | Driver driver = null; |
| | | long m = 0; |
| | | int index = 0; |
| | | for(int j = 0; j < drivers.size(); j++){ |
| | | String value = redisUtil.getValue("DRIVER" + drivers.get(j).getId()); |
| | | if(null != value){ |
| | | String[] split = value.split(","); |
| | | DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(orderLogistics.getStartLat(), orderLogistics.getStartLon(), Double.valueOf(split[1]), Double.valueOf(split[0])); |
| | | Long distance = distancematrix.getDistance(); |
| | | if((0 == m && null == driver) || (distance < m)){ |
| | | driver = drivers.get(j); |
| | | m = distance; |
| | | index = j; |
| | | } |
| | | } |
| | | } |
| | | ds.add(driver); |
| | | drivers.remove(index); |
| | | } |
| | | |
| | | //再根据直线距离最短的司机中找出行驶距离最短的司机 |
| | | Long m = 0L; |
| | | for(Driver driver : ds){ |
| | | String value = redisUtil.getValue("DRIVER" + driver.getId()); |
| | | if(null != value){ |
| | | String[] split = value.split(","); |
| | | DistancematrixVo distancematrix = GoogleMapUtil.getDistancematrix(orderLogistics.getStartLat(), orderLogistics.getStartLon(), Double.valueOf(split[1]), Double.valueOf(split[0])); |
| | | Long d = distancematrix.getDistance(); |
| | | if((0 == m && null == dr) || (d.intValue() < m.intValue())){ |
| | | dr = driver; |
| | | m = d; |
| | | } |
| | | } |
| | | } |
| | | }else{ |
| | | dr = drivers.get(0); |
| | | } |
| | | |
| | | orderLogistics.setDriverId(dr.getId()); |
| | | orderLogistics.setCompanyId(dr.getFranchiseeId() != null && dr.getFranchiseeId() != 0 ? dr.getFranchiseeId() : ( |
| | | dr.getCompanyId() != null && dr.getCompanyId() != 0 ? dr.getCompanyId() : 1)); |
| | | orderLogistics.setState(2); |
| | | orderLogistics.setCarId(dr.getCarId()); |
| | | CarService query1 = carServiceMapper.query(1, dr.getCarId()); |
| | | orderLogistics.setServerCarModelId(query1.getServerCarModelId()); |
| | | orderLogistics.setSnatchOrderTime(new Date()); |
| | | |
| | | dr.setState(3); |
| | | driverService.updateById(dr); |
| | | this.updateById(orderLogistics); |
| | | |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | pushUtil.pushOrderState(1, uid, orderLogistics.getId(), 4, 2, 0); |
| | | pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), 4, 2, 0); |
| | | } |
| | | }).start(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | //推单操作 |
| | | if(orderLogistics.getState() == 1){ |
| | | this.pushOrder(orderLogistics); |
| | | }else{ |
| | | // //接单后定时任务判断司机是否去接乘客,没有则推送提醒 |
| | | // CancleOrder cancleOrder = cancleOrderService.query(orderLogistics.getCompanyId()); |
| | | // if(null != cancleOrder){ |
| | | // JSONObject object = JSON.parseObject(cancleOrder.getContent()); |
| | | // long time = object.getInteger("driverTimeout") * 60000L; |
| | | // new Timer().schedule(new TimerTask() { |
| | | // @Override |
| | | // public void run() { |
| | | // OrderLogistics orderLogistics1 = OrderLogisticsServiceImpl.this.selectById(orderLogistics.getId()); |
| | | // if(orderLogistics1.getState() == 2){ |
| | | // pushUtil.pushDriverTimeOut(1, orderLogistics1.getUserId(), orderLogistics1.getId(), 4); |
| | | // } |
| | | // } |
| | | // }, time); |
| | | // } |
| | | } |
| | | |
| | | |
| | | //添加消息 |
| | | systemNoticeService.addSystemNotice(1, language == 1 ? "您的市内包裹订单已下单成功,我们正在为您指派司机,请稍后!" : |
| | | language == 2 ? "You've placed the delivery order successfully, we are assigning you a driver, please wait." |
| | | : "Vous avez passé la commande de livraison avec succès, nous vous attribuons un chauffeur, veuillez patienter.", orderLogistics.getUserId(), 1); |
| | | |
| | | BaseWarpper baseWarpper = new BaseWarpper(); |
| | | baseWarpper.setState(orderLogistics.getState()); |
| | | baseWarpper.setId(orderLogistics.getId()); |
| | | return ResultUtil.success(baseWarpper); |
| | | } |
| | | |
| | | /** |
| | | * 订单支付 |
| | | * @param payType |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil payLogisticsOrder(Integer payType, Integer bankCardId, Integer orderId, Integer type, Integer language) throws Exception { |
| | | public ResultUtil payLogisticsOrder(Integer payType, Integer bankCardId, Integer orderId,Integer couponId, Integer redDeduction, Integer type, Integer language) throws Exception { |
| | | OrderLogistics orderLogistics = this.selectById(orderId); |
| | | if(orderLogistics.getState() != 7){ |
| | | return ResultUtil.error(language == 1 ? "订单已完成支付,不允许重复支付" : language == 2 ? "The order has been paid, no double payment is allowed" : "La commande a été payée, aucun paiement en double n’est autorisé", ""); |
| | | return ResultUtil.error(language == 1 ? "订单已完成支付,不允许重复支付" : language == 2 ? "The order has been paid, recurring payments is not allowed." : "La commande a été payée, les paiements récurrents ne sont pas autorisés.", ""); |
| | | } |
| | | Integer uid = orderLogistics.getUserId(); |
| | | Double orderMoney = orderLogistics.getOrderMoney(); |
| | | if(orderLogistics.getUrgent() == 2){ |
| | | orderMoney += null != orderLogistics.getTipMoney() ? orderLogistics.getTipMoney() : 0; |
| | | // orderMoney += null != orderLogistics.getTipMoney() ? orderLogistics.getTipMoney() : 0; |
| | | } |
| | | UserInfo userInfo = userInfoService.selectById(uid); |
| | | ResultUtil resultUtil = ResultUtil.success(""); |
| | | //折扣 |
| | | if(null != orderLogistics.getActivityId()){ |
| | | orderMoney = orderMoney - orderLogistics.getDiscountMoney(); |
| | | } |
| | | |
| | | //计算优惠券 |
| | | UserCouponRecord userCouponRecord = null; |
| | | if(null != couponId){ |
| | | //TODO 待翻译 |
| | | if(null != redDeduction && 1 == redDeduction){ |
| | | return ResultUtil.error(language == 1 ? "优惠券和红包不能同时使用" : language == 2 ? "" : "", ""); |
| | | } |
| | | userCouponRecord = userCouponRecordService.selectById(couponId); |
| | | if(userCouponRecord.getCompanyId() != orderLogistics.getCompanyId()){ |
| | | return ResultUtil.error(language == 1 ? "优惠券不能用于此订单" : language == 2 ? "Coupon cannot be used for this order." : "Le coupon ne peut pas être utilisé pour cette commande.", ""); |
| | | } |
| | | if(userCouponRecord.getState() == 2){ |
| | | return ResultUtil.error(language == 1 ? "优惠券已使用" : language == 2 ? "Coupon has been used." : "Le coupon a été utilisé.", ""); |
| | | } |
| | | if(userCouponRecord.getState() == 3){ |
| | | return ResultUtil.error(language == 1 ? "优惠券已过期" : language == 2 ? "Coupon is expired." : "Le coupon a expiré.", ""); |
| | | } |
| | | if(userCouponRecord.getCouponUseType() != 0 && userCouponRecord.getCouponUseType() != 4){ |
| | | return ResultUtil.error(language == 1 ? "优惠券不能用于此订单" : language == 2 ? "Coupon cannot be used for this order." : "Le coupon ne peut pas être utilisé pour cette commande.", ""); |
| | | } |
| | | if(userCouponRecord.getCouponType() == 2 && orderMoney.compareTo(userCouponRecord.getFullMoney()) < 0){ |
| | | return ResultUtil.error(language == 1 ? "优惠券不能用于此订单" : language == 2 ? "Coupon cannot be used for this order." : "Le coupon ne peut pas être utilisé pour cette commande.", ""); |
| | | } |
| | | orderMoney = orderMoney - userCouponRecord.getMoney(); |
| | | orderLogistics.setCouponMoney(userCouponRecord.getMoney()); |
| | | orderLogistics.setCouponId(couponId); |
| | | } |
| | | |
| | | //计算红包 |
| | | if(null != redDeduction && 1 == redDeduction){ |
| | | RedEnvelopePaymentSettings redEnvelopePaymentSettings = redEnvelopePaymentSettingsService.getRedEnvelopePaymentSettings(); |
| | | if(null != redEnvelopePaymentSettings){ |
| | | Double total = userRedPacketRecordService.queryRemainingAmount(uid); |
| | | List<UserRedPacketRecord> userRedPacketRecords = userRedPacketRecordService.selectList(new EntityWrapper<UserRedPacketRecord>().eq("userId", uid) |
| | | .eq("state", 1).eq("companyId", orderLogistics.getCompanyId()).gt("remainingAmount", 0).orderBy("insertTime", false)); |
| | | if(total.compareTo(orderMoney) >= 0){ |
| | | BigDecimal deductionRatio = redEnvelopePaymentSettings.getDeductionRatio(); |
| | | BigDecimal multiply = new BigDecimal(orderMoney).multiply(deductionRatio.divide(new BigDecimal(100))); |
| | | orderLogistics.setRedPacketMoney(multiply.doubleValue()); |
| | | orderMoney = orderMoney - multiply.doubleValue(); |
| | | |
| | | //获取红包id |
| | | JSONArray jsonArray = new JSONArray(); |
| | | for (UserRedPacketRecord userRedPacketRecord : userRedPacketRecords) { |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("id", userRedPacketRecord.getId()); |
| | | BigDecimal remainingAmount = new BigDecimal(userRedPacketRecord.getRemainingAmount()); |
| | | if(multiply.compareTo(remainingAmount) >= 0){ |
| | | multiply = multiply.subtract(remainingAmount); |
| | | jsonObject.put("money", remainingAmount); |
| | | jsonArray.add(jsonObject); |
| | | }else{ |
| | | userRedPacketRecord.setRemainingAmount(remainingAmount.subtract(multiply).doubleValue()); |
| | | jsonObject.put("money", multiply); |
| | | jsonArray.add(jsonObject); |
| | | break; |
| | | } |
| | | } |
| | | orderLogistics.setRedPacketId(jsonArray.toJSONString()); |
| | | }else{ |
| | | orderLogistics.setRedPacketMoney(total); |
| | | orderMoney = orderMoney - total; |
| | | //获取红包id |
| | | JSONArray jsonArray = new JSONArray(); |
| | | BigDecimal multiply = new BigDecimal(total); |
| | | for (UserRedPacketRecord userRedPacketRecord : userRedPacketRecords) { |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("id", userRedPacketRecord.getId()); |
| | | BigDecimal remainingAmount = new BigDecimal(userRedPacketRecord.getRemainingAmount()); |
| | | if(multiply.compareTo(remainingAmount) >= 0){ |
| | | multiply = multiply.subtract(remainingAmount); |
| | | jsonObject.put("money", remainingAmount); |
| | | jsonArray.add(jsonObject); |
| | | }else{ |
| | | userRedPacketRecord.setRemainingAmount(remainingAmount.subtract(multiply).doubleValue()); |
| | | jsonObject.put("money", multiply); |
| | | jsonArray.add(jsonObject); |
| | | break; |
| | | } |
| | | } |
| | | orderLogistics.setRedPacketId(jsonArray.toJSONString()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | orderMoney=new BigDecimal(orderMoney).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue(); |
| | | |
| | | if(payType == 1) {//手机支付 |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | |
| | | |
| | | if(payType == 3){//余额支付 |
| | | if(userInfo.getBalance() == null || userInfo.getBalance() < orderMoney){ |
| | | return ResultUtil.error(language == 1 ? "账户余额不足" : language == 2 ? "Insufficient account balance" : "Solde de compte insuffisant", ""); |
| | | return ResultUtil.error(language == 1 ? "账户余额不足" : language == 2 ? "Insufficient balance" : "Solde insuffisant", ""); |
| | | } |
| | | |
| | | userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(orderMoney)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | |
| | | SysIntegral query1 = sysIntegralMapper.query(orderLogistics.getCompanyId()); |
| | | userInfo.setIntegral(userInfo.getIntegral() + (orderMoney.intValue() * query1.getIntegral()));//积分 |
| | | |
| | | //处理优惠券 |
| | | if(null != userCouponRecord){ |
| | | userCouponRecord.setState(2); |
| | | userCouponRecord.setEndTime(new Date()); |
| | | userCouponRecordService.updateById(userCouponRecord); |
| | | } |
| | | if(null != orderLogistics.getRedPacketId()){ |
| | | JSONArray jsonArray = JSON.parseArray(orderLogistics.getRedPacketId()); |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | JSONObject jsonObject = jsonArray.getJSONObject(i); |
| | | Integer id1 = jsonObject.getInteger("id"); |
| | | Double money = jsonObject.getDouble("money"); |
| | | UserRedPacketRecord userRedPacketRecord = userRedPacketRecordService.selectById(id1); |
| | | userRedPacketRecord.setRemainingAmount(userRedPacketRecord.getRemainingAmount() - money); |
| | | if(0 == userRedPacketRecord.getRemainingAmount()){ |
| | | userRedPacketRecord.setState(2); |
| | | userRedPacketRecord.setEndTime(new Date()); |
| | | } |
| | | userRedPacketRecordService.updateById(userRedPacketRecord); |
| | | } |
| | | } |
| | | |
| | | //添加交易明细 |
| | | transactionDetailsService.saveData(uid, "包裹下单支付", orderMoney, 2, 1, 1, 4, orderId); |
| | | userInfoService.updateById(userInfo); |
| | | |
| | | orderLogistics.setState(1);//小件物流先支付后司机抢单 |
| | | orderLogistics.setState(8); |
| | | orderLogistics.setPayType(3); |
| | | orderLogistics.setPayMoney(orderMoney); |
| | | |
| | | |
| | | |
| | | if(ToolUtil.isNotEmpty(userInfo.getEmail())){ |
| | | String path = templatePath + "user/receiptLogistics.html"; |
| | | Document document = Jsoup.parse(new File(path), "UTF-8"); |
| | | SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy年MM月dd日"); |
| | | SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/MM/dd HH:mm"); |
| | | orderLogistics.setOrderMoney(orderLogistics.getOrderMoney()+orderLogistics.getFreeMoney().doubleValue()); |
| | | |
| | | //处理优惠券和红包 |
| | | if(null != userCouponRecord){ |
| | | userCouponRecord.setState(2); |
| | | userCouponRecord.setEndTime(new Date()); |
| | | userCouponRecordService.updateById(userCouponRecord); |
| | | } |
| | | if(null != orderLogistics.getRedPacketId()){ |
| | | JSONArray jsonArray = JSON.parseArray(orderLogistics.getRedPacketId()); |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | JSONObject jsonObject = jsonArray.getJSONObject(i); |
| | | Integer id1 = jsonObject.getInteger("id"); |
| | | Double money = jsonObject.getDouble("money"); |
| | | UserRedPacketRecord userRedPacketRecord = userRedPacketRecordService.selectById(id1); |
| | | userRedPacketRecord.setRemainingAmount(userRedPacketRecord.getRemainingAmount() - money); |
| | | if(0 == userRedPacketRecord.getRemainingAmount()){ |
| | | userRedPacketRecord.setState(2); |
| | | userRedPacketRecord.setEndTime(new Date()); |
| | | } |
| | | userRedPacketRecordService.updateById(userRedPacketRecord); |
| | | } |
| | | } |
| | | |
| | | if(orderLogistics.getIsplatPay()==1){ |
| | | //添加已收入明细 |
| | | Company company = companyService.selectById(orderLogistics.getCompanyId()); |
| | | Double speMoney = company.getSpeMoney(); |
| | | BigDecimal d = null;//企业收入 |
| | | BigDecimal c = null;//司机收入 |
| | | if(company.getIsSpeFixedOrProportional() == 2){//固定 |
| | | d = new BigDecimal(speMoney); |
| | | c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d);//只有出行金额参与抽成,其余归属司机 |
| | | } |
| | | if(company.getIsSpeFixedOrProportional() == 1){//比例 |
| | | Double price = orderLogistics.getStartMoney() + orderLogistics.getMileageMoney() + orderLogistics.getWaitMoney() + orderLogistics.getDurationMoney() + orderLogistics.getLongDistanceMoney(); |
| | | d = new BigDecimal(price).multiply(new BigDecimal(speMoney).divide(new BigDecimal(100), new MathContext(2, RoundingMode.HALF_EVEN))); |
| | | c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN); |
| | | } |
| | | incomeService.saveData(1, orderLogistics.getCompanyId(), 2, orderLogistics.getId(), 4, d.doubleValue()); |
| | | incomeService.saveData(2, orderLogistics.getDriverId(), 2, orderLogistics.getId(), 4, c.doubleValue()); |
| | | Driver driver = driverService.selectById(orderLogistics.getDriverId()); |
| | | if(1 == language){ |
| | | document.getElementById("english").remove(); |
| | | document.getElementById("french").remove(); |
| | | Element title_chinese = document.getElementById("title_chinese"); |
| | | title_chinese.text(sdf2.format(orderLogistics.getTravelTime()) + ",您在I-GO1个订单消费GHS " + orderLogistics.getPayMoney()); |
| | | Element xcf_chinese = document.getElementById("xcf_chinese"); |
| | | xcf_chinese.text("GHS " + orderLogistics.getOrderMoney()); |
| | | Element xj_chinese = document.getElementById("xj_chinese"); |
| | | xj_chinese.text("GHS " + orderLogistics.getOrderMoney()); |
| | | Element pay_type_chinese = document.getElementById("pay_type_chinese"); |
| | | pay_type_chinese.text("余额"); |
| | | Element pay_money_chinese = document.getElementById("pay_money_chinese"); |
| | | pay_money_chinese.text("GHS " + orderLogistics.getPayMoney()); |
| | | Element pay_time_chinese = document.getElementById("pay_time_chinese"); |
| | | pay_time_chinese.text(sdf1.format(orderLogistics.getTravelTime())); |
| | | Elements driver_chinese = document.getElementsByClass("driver_chinese"); |
| | | for (int i = 0; i < driver_chinese.size(); i++) { |
| | | Element element = driver_chinese.get(i); |
| | | element.text(driver.getFirstName() + "." + driver.getLastName()); |
| | | } |
| | | Element start_address_chinese = document.getElementById("start_address_chinese"); |
| | | start_address_chinese.text(orderLogistics.getStartAddress()); |
| | | Element end_address_chinese = document.getElementById("end_address_chinese"); |
| | | end_address_chinese.text(orderLogistics.getEndAddress()); |
| | | } |
| | | if(2 == language){ |
| | | document.getElementById("chinese").remove(); |
| | | document.getElementById("french").remove(); |
| | | Element title_english = document.getElementById("title_english"); |
| | | title_english.text(sdf2.format(orderLogistics.getTravelTime()) + ",You spent GHS " + orderLogistics.getPayMoney() + " on the trip "); |
| | | Element xcf_english = document.getElementById("xcf_english"); |
| | | xcf_english.text("GHS " + orderLogistics.getOrderMoney()); |
| | | Element xj_english = document.getElementById("xj_english"); |
| | | xj_english.text("GHS " + orderLogistics.getOrderMoney()); |
| | | Element pay_type_english = document.getElementById("pay_type_english"); |
| | | pay_type_english.text("balance"); |
| | | Element pay_money_english = document.getElementById("pay_money_english"); |
| | | pay_money_english.text("GHS " + orderLogistics.getPayMoney()); |
| | | Element pay_time_english = document.getElementById("pay_time_english"); |
| | | pay_time_english.text(sdf1.format(orderLogistics.getTravelTime())); |
| | | Elements driver_english = document.getElementsByClass("driver_english"); |
| | | for (int i = 0; i < driver_english.size(); i++) { |
| | | Element element = driver_english.get(i); |
| | | element.text(driver.getFirstName() + "." + driver.getLastName()); |
| | | } |
| | | Element start_address_english = document.getElementById("start_address_english"); |
| | | start_address_english.text(orderLogistics.getStartAddress()); |
| | | Element end_address_english = document.getElementById("end_address_english"); |
| | | end_address_english.text(orderLogistics.getEndAddress()); |
| | | } |
| | | if(3 == language){ |
| | | document.getElementById("chinese").remove(); |
| | | document.getElementById("english").remove(); |
| | | Element title_french = document.getElementById("title_french"); |
| | | title_french.text(sdf2.format(orderLogistics.getTravelTime()) + ",Vous consommez GHS " + orderLogistics.getPayMoney() + " sur votre commande i-go1 le "); |
| | | Element xcf_french = document.getElementById("xcf_french"); |
| | | xcf_french.text("GHS " + orderLogistics.getOrderMoney()); |
| | | Element xj_french = document.getElementById("xj_french"); |
| | | xj_french.text("GHS " + orderLogistics.getOrderMoney()); |
| | | Element pay_type_french = document.getElementById("pay_type_french"); |
| | | pay_type_french.text("Le solde"); |
| | | Element pay_money_french = document.getElementById("pay_money_french"); |
| | | pay_money_french.text("GHS " + orderLogistics.getPayMoney()); |
| | | Element pay_time_french = document.getElementById("pay_time_french"); |
| | | pay_time_french.text(sdf1.format(orderLogistics.getTravelTime())); |
| | | Elements driver_french = document.getElementsByClass("driver_french"); |
| | | for (int i = 0; i < driver_french.size(); i++) { |
| | | Element element = driver_french.get(i); |
| | | element.text(driver.getFirstName() + "." + driver.getLastName()); |
| | | } |
| | | Element start_address_french = document.getElementById("start_address_french"); |
| | | start_address_french.text(orderLogistics.getStartAddress()); |
| | | Element end_address_french = document.getElementById("end_address_french"); |
| | | end_address_french.text(orderLogistics.getEndAddress()); |
| | | } |
| | | |
| | | EmailUtil.send(userInfo.getEmail(), language == 1 ? "包裹收据" : language == 2 ? "Parcel receipt" : "Réception de colis", document.html()); |
| | | 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()); |
| | | driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driverService.updateById(driver); |
| | | } |
| | | |
| | | // TODO: 2020/5/24 这里需要给司机和用户推送订单状态 |
| | |
| | | pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0); |
| | | } |
| | | }).start(); |
| | | systemNoticeService.addSystemNotice(1, language == 1 ? "您已成功完成包裹订单支付,谢谢使用!" : language == 2 |
| | | ? "You have successfully completed the parcel order payment, thank you for using!" : |
| | | "Vous avez terminé avec succès le paiement de la commande de colis, merci de l’utiliser!", uid, 1); |
| | | this.pushOrder(orderLogistics);//推单 |
| | | } |
| | | |
| | | systemNoticeService.addSystemNotice(1, language == 1 ? "您已成功完成包裹订单支付,谢谢使用!" : language == 2 |
| | | ? "You've paid for the delivery order successfully, thank you for using I-GO" : |
| | | "Vous avez payé la commande de livraison avec succès, merci d’utiliser I-GO", uid, 1); |
| | | |
| | | |
| | | |
| | | language = userInfo.getLanguage(); |
| | | String payTypeChinese = ""; |
| | | String payTypeEnglish = ""; |
| | | String payTypeFrench = ""; |
| | | if(orderLogistics.getPayType() == 3){ |
| | | payTypeChinese = "余额支付"; |
| | | payTypeEnglish = "I-GO Wallet"; |
| | | payTypeFrench = "Portefeuille I-GO"; |
| | | } |
| | | |
| | | if(ToolUtil.isNotEmpty(userInfo.getEmail())){ |
| | | String path = templatePath + "user/receiptLogistics.html"; |
| | | Document document = Jsoup.parse(new File(path), "UTF-8"); |
| | | SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd"); |
| | | SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | Driver driver = driverService.selectById(orderLogistics.getDriverId()); |
| | | Car car = carMapper.selectById(orderLogistics.getCarId()); |
| | | Double aDouble = 0D; |
| | | if(null != orderLogistics.getDriverId()){ |
| | | aDouble = orderEvaluateService.queryDriverScore(orderLogistics.getDriverId()); |
| | | } |
| | | if(1 == language){ |
| | | document.getElementById("english").remove(); |
| | | document.getElementById("french").remove(); |
| | | document.getElementsByTag("title").get(0).text("I-GO电子收据"); |
| | | Element title_chinese = document.getElementById("title_chinese"); |
| | | title_chinese.text(DateUtil.conversionFormat(language, sdf2.format(orderLogistics.getTravelTime())) + ",您在I-GO此订单消费GHS " + orderLogistics.getPayMoney()); |
| | | Element xcf_chinese = document.getElementById("xcf_chinese"); |
| | | xcf_chinese.text("GHS " + new BigDecimal(orderLogistics.getOrderMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | if(null != orderLogistics.getCouponMoney() && orderLogistics.getCouponMoney() > 0){ |
| | | Element yhq_chinese = document.getElementById("yhq_chinese"); |
| | | yhq_chinese.text("GHS -" + new BigDecimal(orderLogistics.getCouponMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | }else{ |
| | | Element yhq_chinese_div = document.getElementById("yhq_chinese_div"); |
| | | yhq_chinese_div.remove(); |
| | | } |
| | | if(null != orderLogistics.getDiscountMoney() && orderLogistics.getDiscountMoney() > 0){ |
| | | Element zk_chinese = document.getElementById("zk_chinese"); |
| | | zk_chinese.text("GHS -" + new BigDecimal(orderLogistics.getDiscountMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | }else{ |
| | | Element zk_chinese_div = document.getElementById("zk_chinese_div"); |
| | | zk_chinese_div.remove(); |
| | | } |
| | | if(null != orderLogistics.getRedPacketMoney() && orderLogistics.getRedPacketMoney() > 0){ |
| | | Element hb_chinese = document.getElementById("hb_chinese"); |
| | | hb_chinese.text("GHS -" + new BigDecimal(orderLogistics.getRedPacketMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | }else{ |
| | | Element hb_chinese_div = document.getElementById("hb_chinese_div"); |
| | | hb_chinese_div.remove(); |
| | | } |
| | | Element xj_chinese = document.getElementById("xj_chinese"); |
| | | xj_chinese.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element pay_type_chinese = document.getElementById("pay_type_chinese"); |
| | | pay_type_chinese.text(payTypeChinese); |
| | | Element pay_money_chinese = document.getElementById("pay_money_chinese"); |
| | | pay_money_chinese.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element pdf_chinese = document.getElementById("pdf_chinese"); |
| | | pdf_chinese.attr("href", "http://182.160.16.251:80/user/base/order/uploadReceiptPdf?orderId=" + orderId + "&orderType=4"); |
| | | Element lost_item_chinese = document.getElementById("lost_item_chinese"); |
| | | lost_item_chinese.attr("href", "http://182.160.16.251:81/mailbox/user/lossGoods.html?language=" + language + "&orderId=" + orderId + "&orderType=4"); |
| | | // Element track_chinese = document.getElementById("track_chinese"); |
| | | // track_chinese.attr("href", "http://182.160.16.251:81/mailbox/user/location.html"); |
| | | Element pay_time_chinese = document.getElementById("pay_time_chinese"); |
| | | pay_time_chinese.text(DateUtil.conversionFormat(language, sdf1.format(orderLogistics.getTravelTime()))); |
| | | Elements driver_chinese = document.getElementsByClass("driver_chinese"); |
| | | for (int i = 0; i < driver_chinese.size(); i++) { |
| | | Element element = driver_chinese.get(i); |
| | | element.text(" " + driver.getFirstName() + "." + driver.getLastName()); |
| | | } |
| | | Element cp_chinese = document.getElementById("cp_chinese"); |
| | | cp_chinese.text("车牌:" + car.getCarLicensePlate()); |
| | | Element pf_chinese = document.getElementById("pf_chinese"); |
| | | pf_chinese.text("司机评分:" + aDouble); |
| | | Element start_address_chinese = document.getElementById("start_address_chinese"); |
| | | start_address_chinese.text(orderLogistics.getStartAddress()); |
| | | Element end_address_chinese = document.getElementById("end_address_chinese"); |
| | | end_address_chinese.text(orderLogistics.getEndAddress()); |
| | | Phone phone = phoneService.selectOne(new EntityWrapper<Phone>().eq("type", 2).eq("companyId", driver.getCompanyId())); |
| | | Element server_tel_chinese = document.getElementById("server_tel_chinese"); |
| | | server_tel_chinese.attr("href", "tel:" + (null != phone ? phone.getPhone() : "")); |
| | | } |
| | | if(2 == language){ |
| | | document.getElementById("chinese").remove(); |
| | | document.getElementById("french").remove(); |
| | | document.getElementsByTag("title").get(0).text("Receipt"); |
| | | Element title_english = document.getElementById("title_english"); |
| | | title_english.text(DateUtil.conversionFormat(language, sdf2.format(orderLogistics.getTravelTime())) + ",You spent GHS " + orderLogistics.getPayMoney() + " on the trip "); |
| | | Element xcf_english = document.getElementById("xcf_english"); |
| | | xcf_english.text("GHS " + new BigDecimal(orderLogistics.getOrderMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | if(null != orderLogistics.getCouponMoney() && orderLogistics.getCouponMoney() > 0){ |
| | | Element yhq_english = document.getElementById("yhq_english"); |
| | | yhq_english.text("GHS -" + new BigDecimal(orderLogistics.getCouponMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | }else{ |
| | | Element yhq_english_div = document.getElementById("yhq_english_div"); |
| | | yhq_english_div.remove(); |
| | | } |
| | | if(null != orderLogistics.getDiscountMoney() && orderLogistics.getDiscountMoney() > 0){ |
| | | Element zk_english = document.getElementById("zk_english"); |
| | | zk_english.text("GHS -" + new BigDecimal(orderLogistics.getDiscountMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | }else{ |
| | | Element zk_english_div = document.getElementById("zk_english_div"); |
| | | zk_english_div.remove(); |
| | | } |
| | | if(null != orderLogistics.getRedPacketMoney() && orderLogistics.getRedPacketMoney() > 0){ |
| | | Element hb_english = document.getElementById("hb_english"); |
| | | hb_english.text("GHS -" + new BigDecimal(orderLogistics.getRedPacketMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | }else{ |
| | | Element hb_english_div = document.getElementById("hb_english_div"); |
| | | hb_english_div.remove(); |
| | | } |
| | | Element xj_english = document.getElementById("xj_english"); |
| | | xj_english.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element pay_type_english = document.getElementById("pay_type_english"); |
| | | pay_type_english.text(payTypeEnglish); |
| | | Element pay_money_english = document.getElementById("pay_money_english"); |
| | | pay_money_english.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element pdf_english = document.getElementById("pdf_english"); |
| | | pdf_english.attr("href", "http://182.160.16.251:80/user/base/order/uploadReceiptPdf?orderId=" + orderId + "&orderType=4"); |
| | | Element lost_item_english = document.getElementById("lost_item_english"); |
| | | lost_item_english.attr("href", "http://182.160.16.251:81/mailbox/user/lossGoods.html?language=" + language + "&orderId=" + orderId + "&orderType=4"); |
| | | // Element track_english = document.getElementById("track_english"); |
| | | // track_english.attr("href", "http://182.160.16.251:81/mailbox/user/location.html"); |
| | | Element pay_time_english = document.getElementById("pay_time_english"); |
| | | pay_time_english.text(DateUtil.conversionFormat(language, sdf1.format(orderLogistics.getTravelTime()))); |
| | | Elements driver_english = document.getElementsByClass("driver_english"); |
| | | for (int i = 0; i < driver_english.size(); i++) { |
| | | Element element = driver_english.get(i); |
| | | element.text(" " + driver.getFirstName() + "." + driver.getLastName()); |
| | | } |
| | | Element cp_english = document.getElementById("cp_english"); |
| | | cp_english.text("Number Plate:" + car.getCarLicensePlate()); |
| | | Element pf_english = document.getElementById("pf_english"); |
| | | pf_english.text("Driver Rating:" + aDouble); |
| | | Element start_address_english = document.getElementById("start_address_english"); |
| | | start_address_english.text(orderLogistics.getStartAddress()); |
| | | Element end_address_english = document.getElementById("end_address_english"); |
| | | end_address_english.text(orderLogistics.getEndAddress()); |
| | | Phone phone = phoneService.selectOne(new EntityWrapper<Phone>().eq("type", 2).eq("companyId", driver.getCompanyId())); |
| | | Element server_tel_english = document.getElementById("server_tel_english"); |
| | | server_tel_english.attr("href", "tel:" + (null != phone ? phone.getPhone() : "")); |
| | | } |
| | | if(3 == language){ |
| | | document.getElementById("chinese").remove(); |
| | | document.getElementById("english").remove(); |
| | | document.getElementsByTag("title").get(0).text("Reçu"); |
| | | Element title_french = document.getElementById("title_french"); |
| | | title_french.text(DateUtil.conversionFormat(language, sdf2.format(orderLogistics.getTravelTime())) + ",Vous consommez GHS " + orderLogistics.getPayMoney() + " sur votre commande i-go1 le "); |
| | | Element xcf_french = document.getElementById("xcf_french"); |
| | | xcf_french.text("GHS " + new BigDecimal(orderLogistics.getOrderMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | if(null != orderLogistics.getCouponMoney() && orderLogistics.getCouponMoney() > 0){ |
| | | Element yhq_french = document.getElementById("yhq_french"); |
| | | yhq_french.text("GHS -" + new BigDecimal(orderLogistics.getCouponMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | }else{ |
| | | Element yhq_french_div = document.getElementById("yhq_french_div"); |
| | | yhq_french_div.remove(); |
| | | } |
| | | if(null != orderLogistics.getDiscountMoney() && orderLogistics.getDiscountMoney() > 0){ |
| | | Element zk_french = document.getElementById("zk_french"); |
| | | zk_french.text("GHS -" + new BigDecimal(orderLogistics.getDiscountMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | }else{ |
| | | Element zk_french_div = document.getElementById("zk_french_div"); |
| | | zk_french_div.remove(); |
| | | } |
| | | if(null != orderLogistics.getRedPacketMoney() && orderLogistics.getRedPacketMoney() > 0){ |
| | | Element hb_french = document.getElementById("hb_french"); |
| | | hb_french.text("GHS -" + new BigDecimal(orderLogistics.getRedPacketMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | }else{ |
| | | Element hb_french_div = document.getElementById("hb_french_div"); |
| | | hb_french_div.remove(); |
| | | } |
| | | Element xj_french = document.getElementById("xj_french"); |
| | | xj_french.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element pay_type_french = document.getElementById("pay_type_french"); |
| | | pay_type_french.text(payTypeFrench); |
| | | Element pay_money_french = document.getElementById("pay_money_french"); |
| | | pay_money_french.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element pdf_french = document.getElementById("pdf_french"); |
| | | pdf_french.attr("href", "http://182.160.16.251:80/user/base/order/uploadReceiptPdf?orderId=" + orderId + "&orderType=4"); |
| | | Element lost_item_french = document.getElementById("lost_item_french"); |
| | | lost_item_french.attr("href", "http://182.160.16.251:81/mailbox/user/lossGoods.html?language=" + language + "&orderId=" + orderId + "&orderType=4"); |
| | | // Element track_french = document.getElementById("track_french"); |
| | | // track_french.attr("href", "http://182.160.16.251:81/mailbox/user/location.html"); |
| | | Element pay_time_french = document.getElementById("pay_time_french"); |
| | | pay_time_french.text(DateUtil.conversionFormat(language, sdf1.format(orderLogistics.getTravelTime()))); |
| | | Elements driver_french = document.getElementsByClass("driver_french"); |
| | | for (int i = 0; i < driver_french.size(); i++) { |
| | | Element element = driver_french.get(i); |
| | | element.text(" " + driver.getFirstName() + "." + driver.getLastName()); |
| | | } |
| | | Element cp_french = document.getElementById("cp_french"); |
| | | cp_french.text("Plaque: GS " + car.getCarLicensePlate()); |
| | | Element pf_french = document.getElementById("pf_french"); |
| | | pf_french.text("Note du chauffeur: " + aDouble); |
| | | Element start_address_french = document.getElementById("start_address_french"); |
| | | start_address_french.text(orderLogistics.getStartAddress()); |
| | | Element end_address_french = document.getElementById("end_address_french"); |
| | | end_address_french.text(orderLogistics.getEndAddress()); |
| | | Phone phone = phoneService.selectOne(new EntityWrapper<Phone>().eq("type", 2).eq("companyId", driver.getCompanyId())); |
| | | Element server_tel_french = document.getElementById("server_tel_french"); |
| | | server_tel_french.attr("href", "tel:" + (null != phone ? phone.getPhone() : "")); |
| | | } |
| | | |
| | | EmailUtil.send(userInfo.getEmail(), language == 1 ? "I-GO电子收据" : language == 2 ? "Receipt" : "Reçu", document.html()); |
| | | |
| | | //开始生成pdf收据和html收据 |
| | | File file = new File("/usr/local/nginx/html/files/html/"); |
| | | if(!file.exists()){ |
| | | file.mkdirs(); |
| | | } |
| | | file = new File("/usr/local/nginx/html/files/html/parcel_receipt_" + orderId + ".html"); |
| | | if(!file.exists()){ |
| | | file.createNewFile(); |
| | | } |
| | | FileWriter fileWriter = new FileWriter(file); |
| | | fileWriter.write(document.html()); |
| | | fileWriter.flush(); |
| | | fileWriter.close(); |
| | | |
| | | File file1 = new File("/usr/local/nginx/html/files/pdf/"); |
| | | if(!file1.exists()){ |
| | | file1.mkdirs(); |
| | | } |
| | | file1 = new File("/usr/local/nginx/html/files/pdf/parcel_receipt_" + orderId + ".pdf"); |
| | | if(!file1.exists()){ |
| | | file1.createNewFile(); |
| | | } |
| | | try{ |
| | | FileOutputStream fileOutputStream = new FileOutputStream(file1); |
| | | HtmlToPdfUtils.convertToPdf("/usr/local/nginx/html/files/html/parcel_receipt_" + orderId + ".html", "I-GO", fileOutputStream); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | System.out.println("html转pdf异常"); |
| | | } |
| | | |
| | | String link ="http://182.160.16.251:81/files/html/parcel_receipt_" + orderId + ".html"; |
| | | TEmail tEmail = new TEmail(); |
| | | tEmail.setLink(link); |
| | | tEmail.setUserId(userInfo.getId()); |
| | | tEmail.setType(1); |
| | | tEmail.setName(language == 1 ? "I-GO电子收据" : language == 2 ? "Receipt" : "Reçu"); |
| | | tEmail.setOrderId(orderId); |
| | | tEmail.setCreateTime(new Date()); |
| | | int i = cn.hutool.core.date.DateUtil.dayOfWeek(new Date())-1; |
| | | String week = EmailUtil.getWeek(language, i); |
| | | tEmail.setWeek(week); |
| | | boolean am = cn.hutool.core.date.DateUtil.isAM(new Date()); |
| | | if(am){ |
| | | tEmail.setAmOrPm(language==1?"上午":language==2?"morning":"matin"); |
| | | }else { |
| | | tEmail.setAmOrPm(language==1?"下午":language==2?"afternoon":"après-midi"); |
| | | } |
| | | emailService.insert(tEmail); |
| | | } |
| | | |
| | | |
| | | } |
| | | Driver driver = driverService.selectById(orderLogistics.getDriverId()); |
| | | if(payType == 4){//现金支付 |
| | | SysIntegral query1 = sysIntegralMapper.query(orderLogistics.getCompanyId()); |
| | | userInfo.setIntegral(userInfo.getIntegral() + (orderMoney.intValue() * query1.getIntegral()));//积分 |
| | |
| | | orderLogistics.setDriverPay(1); |
| | | orderLogistics.setPayType(4); |
| | | orderLogistics.setPayMoney(orderMoney); |
| | | |
| | | if(ToolUtil.isNotEmpty(userInfo.getEmail())){ |
| | | String path = templatePath + "user/receiptLogistics.html"; |
| | | Document document = Jsoup.parse(new File(path), "UTF-8"); |
| | | SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy年MM月dd日"); |
| | | SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/MM/dd HH:mm"); |
| | | Driver driver = driverService.selectById(orderLogistics.getDriverId()); |
| | | if(1 == language){ |
| | | document.getElementById("english").remove(); |
| | | document.getElementById("french").remove(); |
| | | Element title_chinese = document.getElementById("title_chinese"); |
| | | title_chinese.text(sdf2.format(orderLogistics.getTravelTime()) + ",您在I-GO1个订单消费GHS " + orderLogistics.getPayMoney()); |
| | | Element xcf_chinese = document.getElementById("xcf_chinese"); |
| | | xcf_chinese.text("GHS " + orderLogistics.getOrderMoney()); |
| | | Element xj_chinese = document.getElementById("xj_chinese"); |
| | | xj_chinese.text("GHS " + orderLogistics.getOrderMoney()); |
| | | Element pay_type_chinese = document.getElementById("pay_type_chinese"); |
| | | pay_type_chinese.text("现金"); |
| | | Element pay_money_chinese = document.getElementById("pay_money_chinese"); |
| | | pay_money_chinese.text("GHS " + orderLogistics.getPayMoney()); |
| | | Element pay_time_chinese = document.getElementById("pay_time_chinese"); |
| | | pay_time_chinese.text(sdf1.format(orderLogistics.getTravelTime())); |
| | | Elements driver_chinese = document.getElementsByClass("driver_chinese"); |
| | | for (int i = 0; i < driver_chinese.size(); i++) { |
| | | Element element = driver_chinese.get(i); |
| | | element.text(driver.getFirstName() + "." + driver.getLastName()); |
| | | } |
| | | Element start_address_chinese = document.getElementById("start_address_chinese"); |
| | | start_address_chinese.text(orderLogistics.getStartAddress()); |
| | | Element end_address_chinese = document.getElementById("end_address_chinese"); |
| | | end_address_chinese.text(orderLogistics.getEndAddress()); |
| | | } |
| | | if(2 == language){ |
| | | document.getElementById("chinese").remove(); |
| | | document.getElementById("french").remove(); |
| | | Element title_english = document.getElementById("title_english"); |
| | | title_english.text(sdf2.format(orderLogistics.getTravelTime()) + ",You spent GHS " + orderLogistics.getPayMoney() + " on the trip "); |
| | | Element xcf_english = document.getElementById("xcf_english"); |
| | | xcf_english.text("GHS " + orderLogistics.getOrderMoney()); |
| | | Element xj_english = document.getElementById("xj_english"); |
| | | xj_english.text("GHS " + orderLogistics.getOrderMoney()); |
| | | Element pay_type_english = document.getElementById("pay_type_english"); |
| | | pay_type_english.text("cash"); |
| | | Element pay_money_english = document.getElementById("pay_money_english"); |
| | | pay_money_english.text("GHS " + orderLogistics.getPayMoney()); |
| | | Element pay_time_english = document.getElementById("pay_time_english"); |
| | | pay_time_english.text(sdf1.format(orderLogistics.getTravelTime())); |
| | | Elements driver_english = document.getElementsByClass("driver_english"); |
| | | for (int i = 0; i < driver_english.size(); i++) { |
| | | Element element = driver_english.get(i); |
| | | element.text(driver.getFirstName() + "." + driver.getLastName()); |
| | | } |
| | | Element start_address_english = document.getElementById("start_address_english"); |
| | | start_address_english.text(orderLogistics.getStartAddress()); |
| | | Element end_address_english = document.getElementById("end_address_english"); |
| | | end_address_english.text(orderLogistics.getEndAddress()); |
| | | } |
| | | if(3 == language){ |
| | | document.getElementById("chinese").remove(); |
| | | document.getElementById("english").remove(); |
| | | Element title_french = document.getElementById("title_french"); |
| | | title_french.text(sdf2.format(orderLogistics.getTravelTime()) + ",Vous consommez GHS " + orderLogistics.getPayMoney() + " sur votre commande i-go1 le "); |
| | | Element xcf_french = document.getElementById("xcf_french"); |
| | | xcf_french.text("GHS " + orderLogistics.getOrderMoney()); |
| | | Element xj_french = document.getElementById("xj_french"); |
| | | xj_french.text("GHS " + orderLogistics.getOrderMoney()); |
| | | Element pay_type_french = document.getElementById("pay_type_french"); |
| | | pay_type_french.text("espèces"); |
| | | Element pay_money_french = document.getElementById("pay_money_french"); |
| | | pay_money_french.text("GHS " + orderLogistics.getPayMoney()); |
| | | Element pay_time_french = document.getElementById("pay_time_french"); |
| | | pay_time_french.text(sdf1.format(orderLogistics.getTravelTime())); |
| | | Elements driver_french = document.getElementsByClass("driver_french"); |
| | | for (int i = 0; i < driver_french.size(); i++) { |
| | | Element element = driver_french.get(i); |
| | | element.text(driver.getFirstName() + "." + driver.getLastName()); |
| | | } |
| | | Element start_address_french = document.getElementById("start_address_french"); |
| | | start_address_french.text(orderLogistics.getStartAddress()); |
| | | Element end_address_french = document.getElementById("end_address_french"); |
| | | end_address_french.text(orderLogistics.getEndAddress()); |
| | | } |
| | | |
| | | EmailUtil.send(userInfo.getEmail(), language == 1 ? "包裹收据" : language == 2 ? "Parcel receipt" : "Réception de colis", document.html()); |
| | | orderLogistics.setOrderMoney(orderLogistics.getOrderMoney()+orderLogistics.getFreeMoney().doubleValue()); |
| | | |
| | | //处理优惠券和红包 |
| | | if(null != userCouponRecord){ |
| | | userCouponRecord.setState(2); |
| | | userCouponRecord.setEndTime(new Date()); |
| | | userCouponRecordService.updateById(userCouponRecord); |
| | | //添加优惠收入补贴 |
| | | Double money = userCouponRecord.getMoney(); |
| | | incomeService.saveData(2, orderLogistics.getDriverId(), 5, orderLogistics.getId(), 4, money); |
| | | driver.setBusinessMoney(new BigDecimal(null != driver.getBusinessMoney() ? driver.getBusinessMoney() : 0).add(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driver.setLaveBusinessMoney(new BigDecimal(null != driver.getLaveBusinessMoney() ? driver.getLaveBusinessMoney() : 0).add(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driverService.updateById(driver); |
| | | } |
| | | if(null != orderLogistics.getRedPacketId()){ |
| | | JSONArray jsonArray = JSON.parseArray(orderLogistics.getRedPacketId()); |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | JSONObject jsonObject = jsonArray.getJSONObject(i); |
| | | Integer id1 = jsonObject.getInteger("id"); |
| | | Double money = jsonObject.getDouble("money"); |
| | | UserRedPacketRecord userRedPacketRecord = userRedPacketRecordService.selectById(id1); |
| | | userRedPacketRecord.setRemainingAmount(userRedPacketRecord.getRemainingAmount() - money); |
| | | if(0 == userRedPacketRecord.getRemainingAmount()){ |
| | | userRedPacketRecord.setState(2); |
| | | userRedPacketRecord.setEndTime(new Date()); |
| | | } |
| | | userRedPacketRecordService.updateById(userRedPacketRecord); |
| | | } |
| | | Double money = orderLogistics.getRedPacketMoney(); |
| | | incomeService.saveData(2, orderLogistics.getDriverId(), 7, orderLogistics.getId(), 4, money); |
| | | driver.setBusinessMoney(new BigDecimal(null != driver.getBusinessMoney() ? driver.getBusinessMoney() : 0).add(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driver.setLaveBusinessMoney(new BigDecimal(null != driver.getLaveBusinessMoney() ? driver.getLaveBusinessMoney() : 0).add(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driverService.updateById(driver); |
| | | } |
| | | |
| | | if(null != orderLogistics.getDiscountMoney() && 0 < orderLogistics.getDiscountMoney()){ |
| | | Double money = orderLogistics.getDiscountMoney(); |
| | | incomeService.saveData(2, orderLogistics.getDriverId(), 6, orderLogistics.getId(), 4, money); |
| | | driver.setBusinessMoney(new BigDecimal(null != driver.getBusinessMoney() ? driver.getBusinessMoney() : 0).add(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driver.setLaveBusinessMoney(new BigDecimal(null != driver.getLaveBusinessMoney() ? driver.getLaveBusinessMoney() : 0).add(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(new BigDecimal(money)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driverService.updateById(driver); |
| | | } |
| | | |
| | | |
| | | if(orderLogistics.getIsplatPay()==1){ |
| | | //添加已收入明细 |
| | | Company company = companyService.selectById(orderLogistics.getCompanyId()); |
| | | Double speMoney = company.getSpeMoney(); |
| | | BigDecimal d = null;//企业收入 |
| | | BigDecimal c = null;//司机收入 |
| | | if(company.getIsSpeFixedOrProportional() == 2){//固定 |
| | | d = new BigDecimal(speMoney); |
| | | c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d);//只有出行金额参与抽成,其余归属司机 |
| | | } |
| | | if(company.getIsSpeFixedOrProportional() == 1){//比例 |
| | | Double price = orderLogistics.getStartMoney() + orderLogistics.getMileageMoney() + orderLogistics.getWaitMoney() + orderLogistics.getDurationMoney() + orderLogistics.getLongDistanceMoney(); |
| | | d = new BigDecimal(price).multiply(new BigDecimal(speMoney).divide(new BigDecimal(100), new MathContext(2, RoundingMode.HALF_EVEN))); |
| | | c = new BigDecimal(orderLogistics.getOrderMoney()).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN); |
| | | } |
| | | // incomeService.saveData(1, orderPrivateCar.getCompanyId(), 2, orderPrivateCar.getId(), 1, d.doubleValue()); |
| | | // incomeService.saveData(2, orderPrivateCar.getDriverId(), 2, orderPrivateCar.getId(), 1, c.doubleValue()); |
| | | |
| | | // 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()); |
| | | // driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | // driverService.updateById(driver); |
| | | |
| | | |
| | | //记录司机待结算金额 |
| | | if(d.compareTo(new BigDecimal(0)) > 0){ |
| | | SettlementDetail settlementDetail = new SettlementDetail(); |
| | | settlementDetail.setOrderId(orderId); |
| | | settlementDetail.setOrderType(1); |
| | | settlementDetail.setDriverId(driver.getId()); |
| | | settlementDetail.setOrderMoney(orderLogistics.getOrderMoney()); |
| | | settlementDetail.setPrice(d.doubleValue()); |
| | | settlementDetail.setCreateTime(new Date()); |
| | | settlementDetailService.insert(settlementDetail); |
| | | |
| | | SettlementAllocation settlementAllocation = settlementAllocationService.selectOne(null); |
| | | if(null != settlementAllocation){ |
| | | JSONObject jsonObject = JSON.parseObject(settlementAllocation.getContent()); |
| | | Double maxPrice = jsonObject.getDouble("maxPrice"); |
| | | Integer type1 = jsonObject.getInteger("type"); |
| | | if(1 == type1){ |
| | | List<SettlementDetail> settlementDetailList = settlementDetailService.selectList(new EntityWrapper<SettlementDetail>().eq("driverId", driver.getId()).isNull("settlementRecordId").last(" and DATE_FORMAT(now(), '%Y-%m-%d') = DATE_FORMAT(createTime, '%Y-%m-%d')")); |
| | | BigDecimal total = new BigDecimal(0); |
| | | for (SettlementDetail detail : settlementDetailList) { |
| | | total = total.add(new BigDecimal(detail.getPrice())); |
| | | } |
| | | if(maxPrice.compareTo(total.doubleValue()) <= 0){ |
| | | SettlementRecord settlementRecord = settlementRecordService.selectOne(new EntityWrapper<SettlementRecord>().eq("driverId", orderLogistics.getDriverId()) |
| | | .eq("type", type1).eq("paymentStatus", 1).last(" and day = DATE_FORMAT(now(), '%Y-%m-%d')")); |
| | | if(null == settlementRecord){ |
| | | settlementRecord = new SettlementRecord(); |
| | | settlementRecord.setDay(new Date()); |
| | | settlementRecord.setDriverId(orderLogistics.getDriverId()); |
| | | settlementRecord.setType(type1); |
| | | settlementRecord.setPaymentStatus(1); |
| | | settlementRecord.setPayMoney(total.doubleValue()); |
| | | settlementRecord.setInsertTime(new Date()); |
| | | settlementRecordService.insert(settlementRecord); |
| | | }else{ |
| | | settlementRecord.setPayMoney(total.doubleValue()); |
| | | settlementRecordService.updateById(settlementRecord); |
| | | } |
| | | for (SettlementDetail detail : settlementDetailList) { |
| | | detail.setSettlementRecordId(settlementRecord.getId()); |
| | | settlementDetailService.updateById(detail); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | // TODO: 2020/5/24 这里需要给司机和用户推送订单状态 |
| | | new Thread(new Runnable() { |
| | |
| | | }).start(); |
| | | |
| | | systemNoticeService.addSystemNotice(1, language == 1 ? "您已成功完成包裹订单支付,谢谢使用!" : language == 2 |
| | | ? "You have successfully completed the parcel order payment, thank you for using!" : |
| | | "Vous avez terminé avec succès le paiement de la commande de colis, merci de l’utiliser!", uid, 1); |
| | | |
| | | this.pushOrder(orderLogistics);//推单 |
| | | ? "You've paid for the delivery order successfully, thank you for using I-GO" : |
| | | "Vous avez payé la commande de livraison avec succès, merci d’utiliser I-GO", uid, 1); |
| | | |
| | | language = userInfo.getLanguage(); |
| | | String payTypeChinese = ""; |
| | | String payTypeEnglish = ""; |
| | | String payTypeFrench = ""; |
| | | if(orderLogistics.getPayType() == 3){ |
| | | payTypeChinese = "现金"; |
| | | payTypeEnglish = "Cash"; |
| | | payTypeFrench = "En espèces"; |
| | | } |
| | | |
| | | if(ToolUtil.isNotEmpty(userInfo.getEmail())){ |
| | | String path = templatePath + "user/receiptLogistics.html"; |
| | | Document document = Jsoup.parse(new File(path), "UTF-8"); |
| | | SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd"); |
| | | SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | Car car = carMapper.selectById(orderLogistics.getCarId()); |
| | | Double aDouble = 0D; |
| | | if(null != orderLogistics.getDriverId()){ |
| | | aDouble = orderEvaluateService.queryDriverScore(orderLogistics.getDriverId()); |
| | | } |
| | | if(1 == language){ |
| | | document.getElementById("english").remove(); |
| | | document.getElementById("french").remove(); |
| | | document.getElementsByTag("title").get(0).text("I-GO电子收据"); |
| | | Element title_chinese = document.getElementById("title_chinese"); |
| | | title_chinese.text(DateUtil.conversionFormat(language, sdf2.format(orderLogistics.getTravelTime())) + ",您在I-GO此订单消费GHS " + orderLogistics.getPayMoney()); |
| | | Element xcf_chinese = document.getElementById("xcf_chinese"); |
| | | xcf_chinese.text("GHS " + new BigDecimal(orderLogistics.getOrderMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | if(null != orderLogistics.getCouponMoney() && orderLogistics.getCouponMoney() > 0){ |
| | | Element yhq_chinese = document.getElementById("yhq_chinese"); |
| | | yhq_chinese.text("GHS -" + new BigDecimal(orderLogistics.getCouponMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | }else{ |
| | | Element yhq_chinese_div = document.getElementById("yhq_chinese_div"); |
| | | yhq_chinese_div.remove(); |
| | | } |
| | | if(null != orderLogistics.getDiscountMoney() && orderLogistics.getDiscountMoney() > 0){ |
| | | Element zk_chinese = document.getElementById("zk_chinese"); |
| | | zk_chinese.text("GHS -" + new BigDecimal(orderLogistics.getDiscountMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | }else{ |
| | | Element zk_chinese_div = document.getElementById("zk_chinese_div"); |
| | | zk_chinese_div.remove(); |
| | | } |
| | | if(null != orderLogistics.getRedPacketMoney() && orderLogistics.getRedPacketMoney() > 0){ |
| | | Element hb_chinese = document.getElementById("hb_chinese"); |
| | | hb_chinese.text("GHS -" + new BigDecimal(orderLogistics.getRedPacketMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | }else{ |
| | | Element hb_chinese_div = document.getElementById("hb_chinese_div"); |
| | | hb_chinese_div.remove(); |
| | | } |
| | | Element xj_chinese = document.getElementById("xj_chinese"); |
| | | xj_chinese.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element pay_type_chinese = document.getElementById("pay_type_chinese"); |
| | | pay_type_chinese.text(payTypeChinese); |
| | | Element pay_money_chinese = document.getElementById("pay_money_chinese"); |
| | | pay_money_chinese.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element pdf_chinese = document.getElementById("pdf_chinese"); |
| | | pdf_chinese.attr("href", "http://182.160.16.251:80/user/base/order/uploadReceiptPdf?orderId=" + orderId + "&orderType=4"); |
| | | Element lost_item_chinese = document.getElementById("lost_item_chinese"); |
| | | lost_item_chinese.attr("href", "http://182.160.16.251:81/mailbox/user/lossGoods.html?language=" + language + "&orderId=" + orderId + "&orderType=4"); |
| | | // Element track_chinese = document.getElementById("track_chinese"); |
| | | // track_chinese.attr("href", "http://182.160.16.251:81/mailbox/user/location.html"); |
| | | Element pay_time_chinese = document.getElementById("pay_time_chinese"); |
| | | pay_time_chinese.text(DateUtil.conversionFormat(language, sdf1.format(orderLogistics.getTravelTime()))); |
| | | Elements driver_chinese = document.getElementsByClass("driver_chinese"); |
| | | for (int i = 0; i < driver_chinese.size(); i++) { |
| | | Element element = driver_chinese.get(i); |
| | | element.text(" " + driver.getFirstName() + "." + driver.getLastName()); |
| | | } |
| | | Element cp_chinese = document.getElementById("cp_chinese"); |
| | | cp_chinese.text("车牌:" + car.getCarLicensePlate()); |
| | | Element pf_chinese = document.getElementById("pf_chinese"); |
| | | pf_chinese.text("司机评分:" + aDouble); |
| | | Element start_address_chinese = document.getElementById("start_address_chinese"); |
| | | start_address_chinese.text(orderLogistics.getStartAddress()); |
| | | Element end_address_chinese = document.getElementById("end_address_chinese"); |
| | | end_address_chinese.text(orderLogistics.getEndAddress()); |
| | | Phone phone = phoneService.selectOne(new EntityWrapper<Phone>().eq("type", 2).eq("companyId", driver.getCompanyId())); |
| | | Element server_tel_chinese = document.getElementById("server_tel_chinese"); |
| | | server_tel_chinese.attr("href", "tel:" + (null != phone ? phone.getPhone() : "")); |
| | | } |
| | | if(2 == language){ |
| | | document.getElementById("chinese").remove(); |
| | | document.getElementById("french").remove(); |
| | | document.getElementsByTag("title").get(0).text("Receipt"); |
| | | Element title_english = document.getElementById("title_english"); |
| | | title_english.text(DateUtil.conversionFormat(language, sdf2.format(orderLogistics.getTravelTime())) + ",You spent GHS " + orderLogistics.getPayMoney() + " on the trip "); |
| | | Element xcf_english = document.getElementById("xcf_english"); |
| | | xcf_english.text("GHS " + new BigDecimal(orderLogistics.getOrderMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | if(null != orderLogistics.getCouponMoney() && orderLogistics.getCouponMoney() > 0){ |
| | | Element yhq_english = document.getElementById("yhq_english"); |
| | | yhq_english.text("GHS -" + new BigDecimal(orderLogistics.getCouponMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | }else{ |
| | | Element yhq_english_div = document.getElementById("yhq_english_div"); |
| | | yhq_english_div.remove(); |
| | | } |
| | | if(null != orderLogistics.getDiscountMoney() && orderLogistics.getDiscountMoney() > 0){ |
| | | Element zk_english = document.getElementById("zk_english"); |
| | | zk_english.text("GHS -" + new BigDecimal(orderLogistics.getDiscountMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | }else{ |
| | | Element zk_english_div = document.getElementById("zk_english_div"); |
| | | zk_english_div.remove(); |
| | | } |
| | | if(null != orderLogistics.getRedPacketMoney() && orderLogistics.getRedPacketMoney() > 0){ |
| | | Element hb_english = document.getElementById("hb_english"); |
| | | hb_english.text("GHS -" + new BigDecimal(orderLogistics.getRedPacketMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | }else{ |
| | | Element hb_english_div = document.getElementById("hb_english_div"); |
| | | hb_english_div.remove(); |
| | | } |
| | | Element xj_english = document.getElementById("xj_english"); |
| | | xj_english.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element pay_type_english = document.getElementById("pay_type_english"); |
| | | pay_type_english.text(payTypeEnglish); |
| | | Element pay_money_english = document.getElementById("pay_money_english"); |
| | | pay_money_english.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element pdf_english = document.getElementById("pdf_english"); |
| | | pdf_english.attr("href", "http://182.160.16.251:80/user/base/order/uploadReceiptPdf?orderId=" + orderId + "&orderType=4"); |
| | | Element lost_item_english = document.getElementById("lost_item_english"); |
| | | lost_item_english.attr("href", "http://182.160.16.251:81/mailbox/user/lossGoods.html?language=" + language + "&orderId=" + orderId + "&orderType=4"); |
| | | // Element track_english = document.getElementById("track_english"); |
| | | // track_english.attr("href", "http://182.160.16.251:81/mailbox/user/location.html"); |
| | | Element pay_time_english = document.getElementById("pay_time_english"); |
| | | pay_time_english.text(DateUtil.conversionFormat(language, sdf1.format(orderLogistics.getTravelTime()))); |
| | | Elements driver_english = document.getElementsByClass("driver_english"); |
| | | for (int i = 0; i < driver_english.size(); i++) { |
| | | Element element = driver_english.get(i); |
| | | element.text(" " + driver.getFirstName() + "." + driver.getLastName()); |
| | | } |
| | | Element cp_english = document.getElementById("cp_english"); |
| | | cp_english.text("Number Plate:" + car.getCarLicensePlate()); |
| | | Element pf_english = document.getElementById("pf_english"); |
| | | pf_english.text("Driver Rating:" + aDouble); |
| | | Element start_address_english = document.getElementById("start_address_english"); |
| | | start_address_english.text(orderLogistics.getStartAddress()); |
| | | Element end_address_english = document.getElementById("end_address_english"); |
| | | end_address_english.text(orderLogistics.getEndAddress()); |
| | | Phone phone = phoneService.selectOne(new EntityWrapper<Phone>().eq("type", 2).eq("companyId", driver.getCompanyId())); |
| | | Element server_tel_english = document.getElementById("server_tel_english"); |
| | | server_tel_english.attr("href", "tel:" + (null != phone ? phone.getPhone() : "")); |
| | | } |
| | | if(3 == language){ |
| | | document.getElementById("chinese").remove(); |
| | | document.getElementById("english").remove(); |
| | | document.getElementsByTag("title").get(0).text("Reçu"); |
| | | Element title_french = document.getElementById("title_french"); |
| | | title_french.text(DateUtil.conversionFormat(language, sdf2.format(orderLogistics.getTravelTime())) + ",Vous consommez GHS " + orderLogistics.getPayMoney() + " sur votre commande i-go1 le "); |
| | | Element xcf_french = document.getElementById("xcf_french"); |
| | | xcf_french.text("GHS " + new BigDecimal(orderLogistics.getOrderMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | if(null != orderLogistics.getCouponMoney() && orderLogistics.getCouponMoney() > 0){ |
| | | Element yhq_french = document.getElementById("yhq_french"); |
| | | yhq_french.text("GHS -" + new BigDecimal(orderLogistics.getCouponMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | }else{ |
| | | Element yhq_french_div = document.getElementById("yhq_french_div"); |
| | | yhq_french_div.remove(); |
| | | } |
| | | if(null != orderLogistics.getDiscountMoney() && orderLogistics.getDiscountMoney() > 0){ |
| | | Element zk_french = document.getElementById("zk_french"); |
| | | zk_french.text("GHS -" + new BigDecimal(orderLogistics.getDiscountMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | }else{ |
| | | Element zk_french_div = document.getElementById("zk_french_div"); |
| | | zk_french_div.remove(); |
| | | } |
| | | if(null != orderLogistics.getRedPacketMoney() && orderLogistics.getRedPacketMoney() > 0){ |
| | | Element hb_french = document.getElementById("hb_french"); |
| | | hb_french.text("GHS -" + new BigDecimal(orderLogistics.getRedPacketMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | }else{ |
| | | Element hb_french_div = document.getElementById("hb_french_div"); |
| | | hb_french_div.remove(); |
| | | } |
| | | Element xj_french = document.getElementById("xj_french"); |
| | | xj_french.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element pay_type_french = document.getElementById("pay_type_french"); |
| | | pay_type_french.text(payTypeFrench); |
| | | Element pay_money_french = document.getElementById("pay_money_french"); |
| | | pay_money_french.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element pdf_french = document.getElementById("pdf_french"); |
| | | pdf_french.attr("href", "http://182.160.16.251:80/user/base/order/uploadReceiptPdf?orderId=" + orderId + "&orderType=4"); |
| | | Element lost_item_french = document.getElementById("lost_item_french"); |
| | | lost_item_french.attr("href", "http://182.160.16.251:81/mailbox/user/lossGoods.html?language=" + language + "&orderId=" + orderId + "&orderType=4"); |
| | | // Element track_french = document.getElementById("track_french"); |
| | | // track_french.attr("href", "http://182.160.16.251:81/mailbox/user/location.html"); |
| | | Element pay_time_french = document.getElementById("pay_time_french"); |
| | | pay_time_french.text(DateUtil.conversionFormat(language, sdf1.format(orderLogistics.getTravelTime()))); |
| | | Elements driver_french = document.getElementsByClass("driver_french"); |
| | | for (int i = 0; i < driver_french.size(); i++) { |
| | | Element element = driver_french.get(i); |
| | | element.text(" " + driver.getFirstName() + "." + driver.getLastName()); |
| | | } |
| | | Element cp_french = document.getElementById("cp_french"); |
| | | cp_french.text("Plaque: GS " + car.getCarLicensePlate()); |
| | | Element pf_french = document.getElementById("pf_french"); |
| | | pf_french.text("Note du chauffeur: " + aDouble); |
| | | Element start_address_french = document.getElementById("start_address_french"); |
| | | start_address_french.text(orderLogistics.getStartAddress()); |
| | | Element end_address_french = document.getElementById("end_address_french"); |
| | | end_address_french.text(orderLogistics.getEndAddress()); |
| | | Phone phone = phoneService.selectOne(new EntityWrapper<Phone>().eq("type", 2).eq("companyId", driver.getCompanyId())); |
| | | Element server_tel_french = document.getElementById("server_tel_french"); |
| | | server_tel_french.attr("href", "tel:" + (null != phone ? phone.getPhone() : "")); |
| | | } |
| | | |
| | | EmailUtil.send(userInfo.getEmail(), language == 1 ? "I-GO电子收据" : language == 2 ? "Receipt" : "Reçu", document.html()); |
| | | |
| | | //开始生成pdf收据和html收据 |
| | | File file = new File("/usr/local/nginx/html/files/html/"); |
| | | if(!file.exists()){ |
| | | file.mkdirs(); |
| | | } |
| | | file = new File("/usr/local/nginx/html/files/html/parcel_receipt_" + orderId + ".html"); |
| | | if(!file.exists()){ |
| | | file.createNewFile(); |
| | | } |
| | | FileWriter fileWriter = new FileWriter(file); |
| | | fileWriter.write(document.html()); |
| | | fileWriter.flush(); |
| | | fileWriter.close(); |
| | | |
| | | File file1 = new File("/usr/local/nginx/html/files/pdf/"); |
| | | if(!file1.exists()){ |
| | | file1.mkdirs(); |
| | | } |
| | | file1 = new File("/usr/local/nginx/html/files/pdf/parcel_receipt_" + orderId + ".pdf"); |
| | | if(!file1.exists()){ |
| | | file1.createNewFile(); |
| | | } |
| | | try{ |
| | | FileOutputStream fileOutputStream = new FileOutputStream(file1); |
| | | HtmlToPdfUtils.convertToPdf("/usr/local/nginx/html/files/html/parcel_receipt_" + orderId + ".html", "I-GO", fileOutputStream); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | System.out.println("html转pdf异常"); |
| | | } |
| | | |
| | | String link ="http://182.160.16.251:81/files/html/parcel_receipt_" + orderId + ".html"; |
| | | TEmail tEmail = new TEmail(); |
| | | tEmail.setLink(link); |
| | | tEmail.setUserId(userInfo.getId()); |
| | | tEmail.setType(1); |
| | | tEmail.setName(language == 1 ? "I-GO电子收据" : language == 2 ? "Receipt" : "Reçu"); |
| | | tEmail.setOrderId(orderId); |
| | | tEmail.setCreateTime(new Date()); |
| | | int i = cn.hutool.core.date.DateUtil.dayOfWeek(new Date())-1; |
| | | String week = EmailUtil.getWeek(language, i); |
| | | tEmail.setWeek(week); |
| | | boolean am = cn.hutool.core.date.DateUtil.isAM(new Date()); |
| | | if(am){ |
| | | tEmail.setAmOrPm(language==1?"上午":language==2?"morning":"matin"); |
| | | }else { |
| | | tEmail.setAmOrPm(language==1?"下午":language==2?"afternoon":"après-midi"); |
| | | } |
| | | emailService.insert(tEmail); |
| | | } |
| | | } |
| | | |
| | | this.updateById(orderLogistics); |
| | |
| | | |
| | | if(payType == 3){//余额支付 |
| | | if(userInfo.getBalance() == null || userInfo.getBalance() < orderMoney){ |
| | | return ResultUtil.error(language == 1 ? "账户余额不足" : language == 2 ? "Insufficient account balance" : "Solde de compte insuffisant"); |
| | | return ResultUtil.error(language == 1 ? "账户余额不足" : language == 2 ? "Insufficient balance" : "Solde insuffisant"); |
| | | } |
| | | |
| | | userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(orderMoney)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | |
| | | }).start(); |
| | | |
| | | systemNoticeService.addSystemNotice(1, language == 1 ? "您已成功完成包裹订单差价支付,谢谢使用!" : language == 2 |
| | | ? "You have successfully completed the difference payment of parcel order, thank you for using!" |
| | | : "Vous avez complété avec succès le paiement de la différence de commande de colis, merci de l’utiliser!", uid, 1); |
| | | ? "You've paid for the difference of delivery order successfully, thank you for using I-GO" |
| | | : "Vous avez payé la différence de commande de livraison avec succès, merci d’utiliser I-GO", uid, 1); |
| | | } |
| | | |
| | | if(payType == 4){//现金支付 |
| | |
| | | orderLogisticsSpreadService.updateById(orderLogisticsSpread); |
| | | |
| | | //添加已收入明细 |
| | | Company company = companyService.selectById(orderLogistics.getCompanyId()); |
| | | Double speMoney = orderLogistics.getType() == 4 ? company.getSameLogisticsMoney() : company.getCrossLogisticsMoney(); |
| | | BigDecimal d = null; |
| | | BigDecimal c = null; |
| | | if(company.getIsSpeFixedOrProportional() == 2){//固定 |
| | | d = new BigDecimal(speMoney); |
| | | c = new BigDecimal(orderMoney).subtract(d); |
| | | } |
| | | if(company.getIsSpeFixedOrProportional() == 1){//比例 |
| | | d = new BigDecimal(orderMoney).multiply(new BigDecimal(speMoney).divide(new BigDecimal(100), new MathContext(2, RoundingMode.HALF_EVEN))); |
| | | c = new BigDecimal(orderMoney).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN); |
| | | } |
| | | |
| | | Income income = incomeService.selectOne(new EntityWrapper<Income>().eq("userType", 1).eq("objectId", orderLogistics.getCompanyId()).eq("type", 2).eq("incomeId", orderLogistics.getId()).eq("orderType", orderLogistics.getType())); |
| | | income.setMoney(income.getMoney() + d.doubleValue()); |
| | | incomeService.updateById(income); |
| | | income = incomeService.selectOne(new EntityWrapper<Income>().eq("userType", 2).eq("objectId", orderLogistics.getCompanyId()).eq("type", 2).eq("incomeId", orderLogistics.getId()).eq("orderType", orderLogistics.getType())); |
| | | income.setMoney(income.getMoney() + c.doubleValue()); |
| | | incomeService.updateById(income); |
| | | Driver driver = driverService.selectById(orderLogistics.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()); |
| | | driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driverService.updateById(driver); |
| | | // Company company = companyService.selectById(orderLogistics.getCompanyId()); |
| | | // Double speMoney = orderLogistics.getType() == 4 ? company.getSameLogisticsMoney() : company.getCrossLogisticsMoney(); |
| | | // BigDecimal d = BigDecimal.ZERO; |
| | | // BigDecimal c = BigDecimal.ZERO; |
| | | // if(company.getIsSpeFixedOrProportional() == 2){//固定 |
| | | // d = new BigDecimal(speMoney); |
| | | // c = new BigDecimal(orderMoney).subtract(d); |
| | | // } |
| | | // if(company.getIsSpeFixedOrProportional() == 1){//比例 |
| | | // d = new BigDecimal(orderMoney).multiply(new BigDecimal(speMoney).divide(new BigDecimal(100), new MathContext(2, RoundingMode.HALF_EVEN))); |
| | | // c = new BigDecimal(orderMoney).subtract(d).setScale(2, BigDecimal.ROUND_HALF_EVEN); |
| | | // } |
| | | // |
| | | // Income income = incomeService.selectOne(new EntityWrapper<Income>().eq("userType", 1).eq("objectId", orderLogistics.getCompanyId()).eq("type", 2).eq("incomeId", orderLogistics.getId()).eq("orderType", orderLogistics.getType())); |
| | | // income.setMoney(income.getMoney() + d.doubleValue()); |
| | | // incomeService.updateById(income); |
| | | // income = incomeService.selectOne(new EntityWrapper<Income>().eq("userType", 2).eq("objectId", orderLogistics.getCompanyId()).eq("type", 2).eq("incomeId", orderLogistics.getId()).eq("orderType", orderLogistics.getType())); |
| | | // System.out.println("小件物流补差价income======"+income); |
| | | // income.setMoney(income.getMoney() + c.doubleValue()); |
| | | // incomeService.updateById(income); |
| | | // Driver driver = driverService.selectById(orderLogistics.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()); |
| | | // driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | // driverService.updateById(driver); |
| | | |
| | | // TODO: 2020/5/24 这里需要给司机和用户推送订单状态 |
| | | new Thread(new Runnable() { |
| | |
| | | }).start(); |
| | | |
| | | systemNoticeService.addSystemNotice(1, language == 1 ? "您已成功完成包裹订单差价支付,谢谢使用!" : language == 2 |
| | | ? "You have successfully completed the difference payment of parcel order, thank you for using!" |
| | | : "Vous avez complété avec succès le paiement de la différence de commande de colis, merci de l’utiliser!", uid, 1); |
| | | ? "You've paid for the difference of delivery order successfully, thank you for using I-GO" |
| | | : "Vous avez payé la différence de commande de livraison avec succès, merci d’utiliser I-GO", uid, 1); |
| | | } |
| | | |
| | | |
| | |
| | | if(null != query){ |
| | | //添加交易明细 |
| | | transactionDetailsService.saveData(orderLogistics.getUserId(), "完成订单", query.getAmount(), 2, 1, 1, orderLogistics.getType(), query.getOrderId()); |
| | | orderLogistics.setState(1);//先支付后抢单 |
| | | orderLogistics.setState(8); |
| | | orderLogistics.setPayType(query.getPayType()); |
| | | orderLogistics.setPayMoney(query.getAmount()); |
| | | this.updateById(orderLogistics); |
| | |
| | | userInfo.setIntegral(userInfo.getIntegral() + (query.getAmount().intValue() * query1.getIntegral()));//积分 |
| | | userInfoService.updateById(userInfo); |
| | | |
| | | //处理优惠券和红包 |
| | | if(null != orderLogistics.getCouponId()){ |
| | | UserCouponRecord userCouponRecord = userCouponRecordService.selectById(orderLogistics.getCouponId()); |
| | | userCouponRecord.setState(2); |
| | | userCouponRecord.setEndTime(new Date()); |
| | | userCouponRecordService.updateById(userCouponRecord); |
| | | } |
| | | if(null != orderLogistics.getRedPacketId()){ |
| | | JSONArray jsonArray = JSON.parseArray(orderLogistics.getRedPacketId()); |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | JSONObject jsonObject = jsonArray.getJSONObject(i); |
| | | Integer id1 = jsonObject.getInteger("id"); |
| | | Double money = jsonObject.getDouble("money"); |
| | | UserRedPacketRecord userRedPacketRecord = userRedPacketRecordService.selectById(id1); |
| | | userRedPacketRecord.setRemainingAmount(userRedPacketRecord.getRemainingAmount() - money); |
| | | if(0 == userRedPacketRecord.getRemainingAmount()){ |
| | | userRedPacketRecord.setState(2); |
| | | userRedPacketRecord.setEndTime(new Date()); |
| | | } |
| | | userRedPacketRecordService.updateById(userRedPacketRecord); |
| | | } |
| | | } |
| | | |
| | | query.setState(2); |
| | | query.setCode(order_id); |
| | | paymentRecordService.updateById(query); |
| | | |
| | | if(ToolUtil.isNotEmpty(userInfo.getEmail())){ |
| | | String path = templatePath + "user/receiptLogistics.html"; |
| | | Document document = Jsoup.parse(new File(path), "UTF-8"); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日"); |
| | | SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/MM/dd HH:mm"); |
| | | Driver driver = driverService.selectById(orderLogistics.getDriverId()); |
| | | if(1 == language){ |
| | | document.getElementById("english").remove(); |
| | | document.getElementById("french").remove(); |
| | | Element title_chinese = document.getElementById("title_chinese"); |
| | | title_chinese.text(sdf.format(orderLogistics.getTravelTime()) + ",您在I-GO1个订单消费GHS " + orderLogistics.getPayMoney()); |
| | | Element xcf_chinese = document.getElementById("xcf_chinese"); |
| | | xcf_chinese.text("GHS " + orderLogistics.getOrderMoney()); |
| | | Element xj_chinese = document.getElementById("xj_chinese"); |
| | | xj_chinese.text("GHS " + orderLogistics.getOrderMoney()); |
| | | Element pay_type_chinese = document.getElementById("pay_type_chinese"); |
| | | pay_type_chinese.text("余额"); |
| | | Element pay_money_chinese = document.getElementById("pay_money_chinese"); |
| | | pay_money_chinese.text("GHS " + orderLogistics.getPayMoney()); |
| | | Element pay_time_chinese = document.getElementById("pay_time_chinese"); |
| | | pay_time_chinese.text(sdf1.format(orderLogistics.getTravelTime())); |
| | | Elements driver_chinese = document.getElementsByClass("driver_chinese"); |
| | | for (int i = 0; i < driver_chinese.size(); i++) { |
| | | Element element = driver_chinese.get(i); |
| | | element.text(driver.getFirstName() + "." + driver.getLastName()); |
| | | } |
| | | Element start_address_chinese = document.getElementById("start_address_chinese"); |
| | | start_address_chinese.text(orderLogistics.getStartAddress()); |
| | | Element end_address_chinese = document.getElementById("end_address_chinese"); |
| | | end_address_chinese.text(orderLogistics.getEndAddress()); |
| | | } |
| | | if(2 == language){ |
| | | document.getElementById("chinese").remove(); |
| | | document.getElementById("french").remove(); |
| | | Element title_english = document.getElementById("title_english"); |
| | | title_english.text(sdf.format(orderLogistics.getTravelTime()) + ",You spent GHS " + orderLogistics.getPayMoney() + " on the trip "); |
| | | Element xcf_english = document.getElementById("xcf_english"); |
| | | xcf_english.text("GHS " + orderLogistics.getOrderMoney()); |
| | | Element xj_english = document.getElementById("xj_english"); |
| | | xj_english.text("GHS " + orderLogistics.getOrderMoney()); |
| | | Element pay_type_english = document.getElementById("pay_type_english"); |
| | | pay_type_english.text("balance"); |
| | | Element pay_money_english = document.getElementById("pay_money_english"); |
| | | pay_money_english.text("GHS " + orderLogistics.getPayMoney()); |
| | | Element pay_time_english = document.getElementById("pay_time_english"); |
| | | pay_time_english.text(sdf1.format(orderLogistics.getTravelTime())); |
| | | Elements driver_english = document.getElementsByClass("driver_english"); |
| | | for (int i = 0; i < driver_english.size(); i++) { |
| | | Element element = driver_english.get(i); |
| | | element.text(driver.getFirstName() + "." + driver.getLastName()); |
| | | } |
| | | Element start_address_english = document.getElementById("start_address_english"); |
| | | start_address_english.text(orderLogistics.getStartAddress()); |
| | | Element end_address_english = document.getElementById("end_address_english"); |
| | | end_address_english.text(orderLogistics.getEndAddress()); |
| | | } |
| | | if(3 == language){ |
| | | document.getElementById("chinese").remove(); |
| | | document.getElementById("english").remove(); |
| | | Element title_french = document.getElementById("title_french"); |
| | | title_french.text(sdf.format(orderLogistics.getTravelTime()) + ",Vous consommez GHS " + orderLogistics.getPayMoney() + " sur votre commande i-go1 le "); |
| | | Element xcf_french = document.getElementById("xcf_french"); |
| | | xcf_french.text("GHS " + orderLogistics.getOrderMoney()); |
| | | Element xj_french = document.getElementById("xj_french"); |
| | | xj_french.text("GHS " + orderLogistics.getOrderMoney()); |
| | | Element pay_type_french = document.getElementById("pay_type_french"); |
| | | pay_type_french.text("Le solde"); |
| | | Element pay_money_french = document.getElementById("pay_money_french"); |
| | | pay_money_french.text("GHS " + orderLogistics.getPayMoney()); |
| | | Element pay_time_french = document.getElementById("pay_time_french"); |
| | | pay_time_french.text(sdf1.format(orderLogistics.getTravelTime())); |
| | | Elements driver_french = document.getElementsByClass("driver_french"); |
| | | for (int i = 0; i < driver_french.size(); i++) { |
| | | Element element = driver_french.get(i); |
| | | element.text(driver.getFirstName() + "." + driver.getLastName()); |
| | | } |
| | | Element start_address_french = document.getElementById("start_address_french"); |
| | | start_address_french.text(orderLogistics.getStartAddress()); |
| | | Element end_address_french = document.getElementById("end_address_french"); |
| | | end_address_french.text(orderLogistics.getEndAddress()); |
| | | } |
| | | |
| | | EmailUtil.send(userInfo.getEmail(), language == 1 ? "包裹收据" : language == 2 ? "Parcel receipt" : "Réception de colis", document.html()); |
| | | } |
| | | |
| | | |
| | | |
| | | // TODO: 2020/5/24 这里需要给司机和用户推送订单状态 |
| | | new Thread(new Runnable() { |
| | |
| | | |
| | | |
| | | systemNoticeService.addSystemNotice(1, language == 1 ? "您已成功完成包裹订单支付,谢谢使用!" : language == 2 |
| | | ? "You have successfully completed the parcel order payment, thank you for using!" : |
| | | "Vous avez terminé avec succès le paiement de la commande de colis, merci de l’utiliser!", orderLogistics.getUserId(), 1); |
| | | |
| | | this.pushOrder(orderLogistics);//推单 |
| | | ? "You've paid for the delivery order successfully, thank you for using I-GO" : |
| | | "Vous avez payé la commande de livraison avec succès, merci d’utiliser I-GO", orderLogistics.getUserId(), 1); |
| | | |
| | | language = userInfo.getLanguage(); |
| | | String payTypeChinese = ""; |
| | | String payTypeEnglish = ""; |
| | | String payTypeFrench = ""; |
| | | if(orderLogistics.getPayType() == 1){ |
| | | payTypeChinese = "手机支付"; |
| | | payTypeEnglish = "Mobile money"; |
| | | payTypeFrench = "Argent mobile"; |
| | | } |
| | | if(orderLogistics.getPayType() == 2){ |
| | | payTypeChinese = "银行卡支付"; |
| | | payTypeEnglish = "Bank card"; |
| | | payTypeFrench = "Carte bancaire"; |
| | | } |
| | | |
| | | if(ToolUtil.isNotEmpty(userInfo.getEmail())){ |
| | | String path = templatePath + "user/receiptLogistics.html"; |
| | | Document document = Jsoup.parse(new File(path), "UTF-8"); |
| | | SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd"); |
| | | SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | Driver driver = driverService.selectById(orderLogistics.getDriverId()); |
| | | Car car = carMapper.selectById(orderLogistics.getCarId()); |
| | | Double aDouble = 0D; |
| | | if(null != orderLogistics.getDriverId()){ |
| | | aDouble = orderEvaluateService.queryDriverScore(orderLogistics.getDriverId()); |
| | | } |
| | | if(1 == language){ |
| | | document.getElementById("english").remove(); |
| | | document.getElementById("french").remove(); |
| | | document.getElementsByTag("title").get(0).text("I-GO电子收据"); |
| | | Element title_chinese = document.getElementById("title_chinese"); |
| | | title_chinese.text(DateUtil.conversionFormat(language, sdf2.format(orderLogistics.getTravelTime())) + ",您在I-GO此订单消费GHS " + orderLogistics.getPayMoney()); |
| | | Element xcf_chinese = document.getElementById("xcf_chinese"); |
| | | xcf_chinese.text("GHS " + new BigDecimal(orderLogistics.getOrderMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | if(null != orderLogistics.getCouponMoney() && orderLogistics.getCouponMoney() > 0){ |
| | | Element yhq_chinese = document.getElementById("yhq_chinese"); |
| | | yhq_chinese.text("GHS -" + new BigDecimal(orderLogistics.getCouponMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | }else{ |
| | | Element yhq_chinese_div = document.getElementById("yhq_chinese_div"); |
| | | yhq_chinese_div.remove(); |
| | | } |
| | | if(null != orderLogistics.getDiscountMoney() && orderLogistics.getDiscountMoney() > 0){ |
| | | Element zk_chinese = document.getElementById("zk_chinese"); |
| | | zk_chinese.text("GHS -" + new BigDecimal(orderLogistics.getDiscountMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | }else{ |
| | | Element zk_chinese_div = document.getElementById("zk_chinese_div"); |
| | | zk_chinese_div.remove(); |
| | | } |
| | | if(null != orderLogistics.getRedPacketMoney() && orderLogistics.getRedPacketMoney() > 0){ |
| | | Element hb_chinese = document.getElementById("hb_chinese"); |
| | | hb_chinese.text("GHS -" + new BigDecimal(orderLogistics.getRedPacketMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | }else{ |
| | | Element hb_chinese_div = document.getElementById("hb_chinese_div"); |
| | | hb_chinese_div.remove(); |
| | | } |
| | | Element xj_chinese = document.getElementById("xj_chinese"); |
| | | xj_chinese.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element pay_type_chinese = document.getElementById("pay_type_chinese"); |
| | | pay_type_chinese.text(payTypeChinese); |
| | | Element pay_money_chinese = document.getElementById("pay_money_chinese"); |
| | | pay_money_chinese.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element pdf_chinese = document.getElementById("pdf_chinese"); |
| | | pdf_chinese.attr("href", "http://182.160.16.251:80/user/base/order/uploadReceiptPdf?orderId=" + id + "&orderType=4"); |
| | | Element lost_item_chinese = document.getElementById("lost_item_chinese"); |
| | | lost_item_chinese.attr("href", "http://182.160.16.251:81/mailbox/user/lossGoods.html?language=" + language + "&orderId=" + id + "&orderType=4"); |
| | | // Element track_chinese = document.getElementById("track_chinese"); |
| | | // track_chinese.attr("href", "http://182.160.16.251:81/mailbox/user/location.html"); |
| | | Element pay_time_chinese = document.getElementById("pay_time_chinese"); |
| | | pay_time_chinese.text(DateUtil.conversionFormat(language, sdf1.format(orderLogistics.getTravelTime()))); |
| | | Elements driver_chinese = document.getElementsByClass("driver_chinese"); |
| | | for (int i = 0; i < driver_chinese.size(); i++) { |
| | | Element element = driver_chinese.get(i); |
| | | element.text(" " + driver.getFirstName() + "." + driver.getLastName()); |
| | | } |
| | | Element cp_chinese = document.getElementById("cp_chinese"); |
| | | cp_chinese.text("车牌:" + car.getCarLicensePlate()); |
| | | Element pf_chinese = document.getElementById("pf_chinese"); |
| | | pf_chinese.text("司机评分:" + aDouble); |
| | | Element start_address_chinese = document.getElementById("start_address_chinese"); |
| | | start_address_chinese.text(orderLogistics.getStartAddress()); |
| | | Element end_address_chinese = document.getElementById("end_address_chinese"); |
| | | end_address_chinese.text(orderLogistics.getEndAddress()); |
| | | Phone phone = phoneService.selectOne(new EntityWrapper<Phone>().eq("type", 2).eq("companyId", driver.getCompanyId())); |
| | | Element server_tel_chinese = document.getElementById("server_tel_chinese"); |
| | | server_tel_chinese.attr("href", "tel:" + (null != phone ? phone.getPhone() : "")); |
| | | } |
| | | if(2 == language){ |
| | | document.getElementById("chinese").remove(); |
| | | document.getElementById("french").remove(); |
| | | document.getElementsByTag("title").get(0).text("Receipt"); |
| | | Element title_english = document.getElementById("title_english"); |
| | | title_english.text(DateUtil.conversionFormat(language, sdf2.format(orderLogistics.getTravelTime())) + ",You spent GHS " + orderLogistics.getPayMoney() + " on the trip "); |
| | | Element xcf_english = document.getElementById("xcf_english"); |
| | | xcf_english.text("GHS " + new BigDecimal(orderLogistics.getOrderMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | if(null != orderLogistics.getCouponMoney() && orderLogistics.getCouponMoney() > 0){ |
| | | Element yhq_english = document.getElementById("yhq_english"); |
| | | yhq_english.text("GHS -" + new BigDecimal(orderLogistics.getCouponMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | }else{ |
| | | Element yhq_english_div = document.getElementById("yhq_english_div"); |
| | | yhq_english_div.remove(); |
| | | } |
| | | if(null != orderLogistics.getDiscountMoney() && orderLogistics.getDiscountMoney() > 0){ |
| | | Element zk_english = document.getElementById("zk_english"); |
| | | zk_english.text("GHS -" + new BigDecimal(orderLogistics.getDiscountMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | }else{ |
| | | Element zk_english_div = document.getElementById("zk_english_div"); |
| | | zk_english_div.remove(); |
| | | } |
| | | if(null != orderLogistics.getRedPacketMoney() && orderLogistics.getRedPacketMoney() > 0){ |
| | | Element hb_english = document.getElementById("hb_english"); |
| | | hb_english.text("GHS -" + new BigDecimal(orderLogistics.getRedPacketMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | }else{ |
| | | Element hb_english_div = document.getElementById("hb_english_div"); |
| | | hb_english_div.remove(); |
| | | } |
| | | Element xj_english = document.getElementById("xj_english"); |
| | | xj_english.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element pay_type_english = document.getElementById("pay_type_english"); |
| | | pay_type_english.text(payTypeEnglish); |
| | | Element pay_money_english = document.getElementById("pay_money_english"); |
| | | pay_money_english.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element pdf_english = document.getElementById("pdf_english"); |
| | | pdf_english.attr("href", "http://182.160.16.251:80/user/base/order/uploadReceiptPdf?orderId=" + id + "&orderType=4"); |
| | | Element lost_item_english = document.getElementById("lost_item_english"); |
| | | lost_item_english.attr("href", "http://182.160.16.251:81/mailbox/user/lossGoods.html?language=" + language + "&orderId=" + id + "&orderType=4"); |
| | | // Element track_english = document.getElementById("track_english"); |
| | | // track_english.attr("href", "http://182.160.16.251:81/mailbox/user/location.html"); |
| | | Element pay_time_english = document.getElementById("pay_time_english"); |
| | | pay_time_english.text(DateUtil.conversionFormat(language, sdf1.format(orderLogistics.getTravelTime()))); |
| | | Elements driver_english = document.getElementsByClass("driver_english"); |
| | | for (int i = 0; i < driver_english.size(); i++) { |
| | | Element element = driver_english.get(i); |
| | | element.text(" " + driver.getFirstName() + "." + driver.getLastName()); |
| | | } |
| | | Element cp_english = document.getElementById("cp_english"); |
| | | cp_english.text("Number Plate:" + car.getCarLicensePlate()); |
| | | Element pf_english = document.getElementById("pf_english"); |
| | | pf_english.text("Driver Rating:" + aDouble); |
| | | Element start_address_english = document.getElementById("start_address_english"); |
| | | start_address_english.text(orderLogistics.getStartAddress()); |
| | | Element end_address_english = document.getElementById("end_address_english"); |
| | | end_address_english.text(orderLogistics.getEndAddress()); |
| | | Phone phone = phoneService.selectOne(new EntityWrapper<Phone>().eq("type", 2).eq("companyId", driver.getCompanyId())); |
| | | Element server_tel_english = document.getElementById("server_tel_english"); |
| | | server_tel_english.attr("href", "tel:" + (null != phone ? phone.getPhone() : "")); |
| | | } |
| | | if(3 == language){ |
| | | document.getElementById("chinese").remove(); |
| | | document.getElementById("english").remove(); |
| | | document.getElementsByTag("title").get(0).text("Reçu"); |
| | | Element title_french = document.getElementById("title_french"); |
| | | title_french.text(DateUtil.conversionFormat(language, sdf2.format(orderLogistics.getTravelTime())) + ",Vous consommez GHS " + orderLogistics.getPayMoney() + " sur votre commande i-go1 le "); |
| | | Element xcf_french = document.getElementById("xcf_french"); |
| | | xcf_french.text("GHS " + new BigDecimal(orderLogistics.getOrderMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | if(null != orderLogistics.getCouponMoney() && orderLogistics.getCouponMoney() > 0){ |
| | | Element yhq_french = document.getElementById("yhq_french"); |
| | | yhq_french.text("GHS -" + new BigDecimal(orderLogistics.getCouponMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | }else{ |
| | | Element yhq_french_div = document.getElementById("yhq_french_div"); |
| | | yhq_french_div.remove(); |
| | | } |
| | | if(null != orderLogistics.getDiscountMoney() && orderLogistics.getDiscountMoney() > 0){ |
| | | Element zk_french = document.getElementById("zk_french"); |
| | | zk_french.text("GHS -" + new BigDecimal(orderLogistics.getDiscountMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | }else{ |
| | | Element zk_french_div = document.getElementById("zk_french_div"); |
| | | zk_french_div.remove(); |
| | | } |
| | | if(null != orderLogistics.getRedPacketMoney() && orderLogistics.getRedPacketMoney() > 0){ |
| | | Element hb_french = document.getElementById("hb_french"); |
| | | hb_french.text("GHS -" + new BigDecimal(orderLogistics.getRedPacketMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | }else{ |
| | | Element hb_french_div = document.getElementById("hb_french_div"); |
| | | hb_french_div.remove(); |
| | | } |
| | | Element xj_french = document.getElementById("xj_french"); |
| | | xj_french.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element pay_type_french = document.getElementById("pay_type_french"); |
| | | pay_type_french.text(payTypeFrench); |
| | | Element pay_money_french = document.getElementById("pay_money_french"); |
| | | pay_money_french.text("GHS " + new BigDecimal(orderLogistics.getPayMoney()).setScale(2, RoundingMode.HALF_EVEN)); |
| | | Element pdf_french = document.getElementById("pdf_french"); |
| | | pdf_french.attr("href", "http://182.160.16.251:80/user/base/order/uploadReceiptPdf?orderId=" + id + "&orderType=4"); |
| | | Element lost_item_french = document.getElementById("lost_item_french"); |
| | | lost_item_french.attr("href", "http://182.160.16.251:81/mailbox/user/lossGoods.html?language=" + language + "&orderId=" + id + "&orderType=4"); |
| | | // Element track_french = document.getElementById("track_french"); |
| | | // track_french.attr("href", "http://182.160.16.251:81/mailbox/user/location.html"); |
| | | Element pay_time_french = document.getElementById("pay_time_french"); |
| | | pay_time_french.text(DateUtil.conversionFormat(language, sdf1.format(orderLogistics.getTravelTime()))); |
| | | Elements driver_french = document.getElementsByClass("driver_french"); |
| | | for (int i = 0; i < driver_french.size(); i++) { |
| | | Element element = driver_french.get(i); |
| | | element.text(" " + driver.getFirstName() + "." + driver.getLastName()); |
| | | } |
| | | Element cp_french = document.getElementById("cp_french"); |
| | | cp_french.text("Plaque: GS " + car.getCarLicensePlate()); |
| | | Element pf_french = document.getElementById("pf_french"); |
| | | pf_french.text("Note du chauffeur: " + aDouble); |
| | | Element start_address_french = document.getElementById("start_address_french"); |
| | | start_address_french.text(orderLogistics.getStartAddress()); |
| | | Element end_address_french = document.getElementById("end_address_french"); |
| | | end_address_french.text(orderLogistics.getEndAddress()); |
| | | Phone phone = phoneService.selectOne(new EntityWrapper<Phone>().eq("type", 2).eq("companyId", driver.getCompanyId())); |
| | | Element server_tel_french = document.getElementById("server_tel_french"); |
| | | server_tel_french.attr("href", "tel:" + (null != phone ? phone.getPhone() : "")); |
| | | } |
| | | |
| | | EmailUtil.send(userInfo.getEmail(), language == 1 ? "I-GO电子收据" : language == 2 ? "Receipt" : "Reçu", document.html()); |
| | | |
| | | //开始生成pdf收据和html收据 |
| | | File file = new File("/usr/local/nginx/html/files/html/"); |
| | | if(!file.exists()){ |
| | | file.mkdirs(); |
| | | } |
| | | file = new File("/usr/local/nginx/html/files/html/parcel_receipt_" + id + ".html"); |
| | | if(!file.exists()){ |
| | | file.createNewFile(); |
| | | } |
| | | FileWriter fileWriter = new FileWriter(file); |
| | | fileWriter.write(document.html()); |
| | | fileWriter.flush(); |
| | | fileWriter.close(); |
| | | |
| | | File file1 = new File("/usr/local/nginx/html/files/pdf/"); |
| | | if(!file1.exists()){ |
| | | file1.mkdirs(); |
| | | } |
| | | file1 = new File("/usr/local/nginx/html/files/pdf/parcel_receipt_" + id + ".pdf"); |
| | | if(!file1.exists()){ |
| | | file1.createNewFile(); |
| | | } |
| | | try{ |
| | | FileOutputStream fileOutputStream = new FileOutputStream(file1); |
| | | HtmlToPdfUtils.convertToPdf("/usr/local/nginx/html/files/html/parcel_receipt_" + id + ".html", "I-GO", fileOutputStream); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | System.out.println("html转pdf异常"); |
| | | } |
| | | |
| | | String link ="http://182.160.16.251:81/files/html/parcel_receipt_" + id + ".html"; |
| | | TEmail tEmail = new TEmail(); |
| | | tEmail.setLink(link); |
| | | tEmail.setUserId(userInfo.getId()); |
| | | tEmail.setType(1); |
| | | tEmail.setName(language == 1 ? "I-GO电子收据" : language == 2 ? "Receipt" : "Reçu"); |
| | | tEmail.setOrderId(id); |
| | | tEmail.setCreateTime(new Date()); |
| | | int i = cn.hutool.core.date.DateUtil.dayOfWeek(new Date())-1; |
| | | String week = EmailUtil.getWeek(language, i); |
| | | tEmail.setWeek(week); |
| | | boolean am = cn.hutool.core.date.DateUtil.isAM(new Date()); |
| | | if(am){ |
| | | tEmail.setAmOrPm(language==1?"上午":language==2?"morning":"matin"); |
| | | }else { |
| | | tEmail.setAmOrPm(language==1?"下午":language==2?"afternoon":"après-midi"); |
| | | } |
| | | emailService.insert(tEmail); |
| | | } |
| | | }else{ |
| | | System.err.println("预支付数据异常(orderId = " + id + ")"); |
| | | } |
| | |
| | | }).start(); |
| | | |
| | | systemNoticeService.addSystemNotice(1, language == 1 ? "您已成功完成包裹订单差价支付,谢谢使用!" : language == 2 |
| | | ? "You have successfully completed the difference payment of parcel order, thank you for using!" |
| | | : "Vous avez complété avec succès le paiement de la différence de commande de colis, merci de l’utiliser!", orderLogistics.getUserId(), 1); |
| | | ? "You've paid for the difference of delivery order successfully, thank you for using I-GO" |
| | | : "Vous avez payé la différence de commande de livraison avec succès, merci d’utiliser I-GO", orderLogistics.getUserId(), 1); |
| | | }else{ |
| | | System.err.println("预支付数据异常(orderId = " + id + ")"); |
| | | } |
| | |
| | | public List<Map<String, Object>> queryMyOrderList(Integer uid, Integer pageNum, Integer size, Integer language) throws Exception { |
| | | pageNum = (pageNum - 1) * size; |
| | | List<Map<String, Object>> maps = orderLogisticsMapper.queryMyOrderList(uid, pageNum, size, language); |
| | | for (Map<String, Object> map : maps) { |
| | | if(null != map.get("orderTime")){ |
| | | String orderTime = map.get("orderTime").toString(); |
| | | map.put("orderTime", DateUtil.conversionFormat(language, orderTime)); |
| | | } |
| | | if(null != map.get("time")){ |
| | | String time = map.get("time").toString(); |
| | | map.put("time", DateUtil.conversionFormat(language, time)); |
| | | } |
| | | Integer orderId = Integer.valueOf(String.valueOf(map.get("orderId"))); |
| | | Integer state = Integer.valueOf(String.valueOf(map.get("state"))); |
| | | if(state == 6){ |
| | | map.put("receipt", "http://182.160.16.251:81/files/html/parcel_receipt_" + orderId + ".html"); |
| | | }else{ |
| | | map.put("receipt", ""); |
| | | } |
| | | if(state == 7){ |
| | | Double discountMoney = Double.valueOf(map.get("discountMoney").toString()); |
| | | Double orderMoney = Double.valueOf(map.get("orderMoney").toString()); |
| | | map.put("orderMoney", orderMoney - discountMoney); |
| | | } |
| | | } |
| | | return maps; |
| | | } |
| | | |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<Map<String, Object>> queryMyTravelRecord(Integer uid) { |
| | | return orderLogisticsMapper.queryMyTravelRecord(uid); |
| | | public List<Map<String, Object>> queryMyTravelRecord(Integer language, Integer uid) { |
| | | List<Map<String, Object>> list = orderLogisticsMapper.queryMyTravelRecord(uid); |
| | | for (Map<String, Object> map : list) { |
| | | if(null != map.get("time")){ |
| | | String time = map.get("time").toString(); |
| | | map.put("time", DateUtil.conversionFormat(language, time)); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> queryInvoiceOrder(Integer type, Date startTime, Date endTime, Double startMoney, Double endMoney, Integer uid, Integer orderType) throws Exception { |
| | | public List<Map<String, Object>> queryInvoiceOrder(Integer language, Integer type, Date startTime, Date endTime, Double startMoney, Double endMoney, Integer uid, Integer orderType) throws Exception { |
| | | startTime = dateUtil.getStartOrEndDate(startTime, "start"); |
| | | endTime = dateUtil.getStartOrEndDate(endTime, "end"); |
| | | return orderLogisticsMapper.queryInvoiceOrder(type, startTime, endTime, startMoney, endMoney, uid, orderType); |
| | | List<Map<String, Object>> list = orderLogisticsMapper.queryInvoiceOrder(type, startTime, endTime, startMoney, endMoney, uid, orderType); |
| | | for (Map<String, Object> map : list) { |
| | | map.put("orderName", language == 1 ? "包裹订单" : language == 2 ? "Delivery" : "Livraison"); |
| | | if(null != map.get("time")){ |
| | | String time = map.get("time").toString(); |
| | | map.put("time", DateUtil.conversionFormat(language, time)); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public ResultUtil addCancle(Integer id, String reason, String remark, Integer uid, Integer language) throws Exception { |
| | | public ResultUtil addCancle(Integer id, String reason, String remark, Integer uid, Double lon, Double lat, String address, Integer language) throws Exception { |
| | | if(ToolUtil.isNotEmpty(remark)){ |
| | | if(ToolUtil.isNotEmpty(remark)){ |
| | | List<SensitiveWords> sensitiveWords = sensitiveWordsMapper.selectList(null); |
| | |
| | | OrderLogistics orderLogistics = this.selectById(id); |
| | | Integer integer = null; |
| | | if(null == orderLogistics){ |
| | | return ResultUtil.error(language == 1 ? "取消订单失败,订单信息有误" : language == 2 ? "Failed to cancel the order, the order information is incorrect" : "Échec de l'annulation de la commande, les informations de la commande sont incorrectes"); |
| | | return ResultUtil.error(language == 1 ? "取消订单失败,订单信息有误" : language == 2 ? "Failed to cancel order, order-information error." : "Échec de l’annulation de la commande, erreur d’information de commande."); |
| | | } |
| | | if(orderLogistics.getState() > 5 && orderLogistics.getState() != 7 && orderLogistics.getState() != 11){ |
| | | return ResultUtil.error(language == 1 ? "取消订单失败,不合法的操作" : language == 2 ? "Cancel order failed, illegal operation" : "Échec de l'annulation de la commande, opération illégale"); |
| | | if(orderLogistics.getState() > 5 && orderLogistics.getState() != 11){ |
| | | return ResultUtil.error(language == 1 ? "取消订单失败,不合法的操作" : language == 2 ? "Failed to cancel order, illegal operation." : "Échec de l’annulation de la commande, opération illégale."); |
| | | } |
| | | |
| | | if(orderLogistics.getState() == 7){ |
| | | OrderCancel orderCancel = new OrderCancel(); |
| | | orderCancel.setOrderId(id); |
| | | orderCancel.setOrderType(orderLogistics.getType()); |
| | | orderCancel.setReason(reason); |
| | | orderCancel.setRemark(remark); |
| | | orderCancel.setState(2); |
| | | orderCancel.setInsertTime(new Date()); |
| | | orderCancel.setUserType(1); |
| | | orderCancelService.insert(orderCancel); |
| | | |
| | | if(null == orderLogistics.getDriverId()){//没有接单的情况 |
| | | integer = orderCancelService.saveData(id, 4, language == 1 ? "无司机接单" : language == 2 ? "No driver to take orders" : "Pas de chauffeur pour prendre les commandes", language == 1 ? "无司机接单" : language == 2 ? "No driver to take orders" : "Pas de chauffeur pour prendre les commandes", null, null, 2, 1, uid); |
| | | orderLogistics.setState(10); |
| | | this.updateById(orderLogistics); |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | |
| | | //回退支付金额 |
| | | if(null != orderLogistics.getPayType() && orderLogistics.getPayType() == 1) {//微信 |
| | | OrderCancel orderCancel = new OrderCancel(); |
| | | orderCancel.setOrderId(id); |
| | | orderCancel.setOrderType(orderLogistics.getType()); |
| | | orderCancel.setReason(reason); |
| | | orderCancel.setRemark(remark); |
| | | orderCancel.setState(1); |
| | | orderCancel.setInsertTime(new Date()); |
| | | orderCancel.setUserType(1); |
| | | orderCancelService.insert(orderCancel); |
| | | orderLogistics.setState(10); |
| | | this.updateById(orderLogistics); |
| | | //调用回退接口 |
| | | PaymentRecord query = paymentRecordService.query(1, orderLogistics.getUserId(), 1, orderLogistics.getId(), orderLogistics.getType(), 1, 2); |
| | | UserInfo userInfo = userInfoService.selectById(orderLogistics.getUserId()); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String payerTransactionID = sdf.format(new Date()) + orderCancel.getId(); |
| | | PayoutResponse payoutResponse = tinggPayoutUtil.sendPayout(userInfo.getPhoneOperator(), "+" + userInfo.getPhone(), payerTransactionID, query.getAmount().doubleValue(), callbackPath + "/base/orderCancelRefundCallback", "取消订单退款"); |
| | | AuthStatus authStatus = payoutResponse.getAuthStatus(); |
| | | Results results = payoutResponse.getResults().get(0); |
| | | String statusCode = results.getStatusCode(); |
| | | if(!"131".equals(authStatus.getAuthStatusCode())){ |
| | | return ResultUtil.error(authStatus.getAuthStatusDescription()); |
| | | }else { |
| | | BaseWarpper data = queryCancleAmount(id, language).getData(); |
| | | Double amount = data.getAmount(); |
| | | if(0 == amount){ |
| | | integer = orderCancelService.saveData(id, 4, reason, remark, null, null, 2, 1, uid); |
| | | if(5 == orderLogistics.getState()){ |
| | | orderLogistics.setState(6); |
| | | orderLogistics.setGetoffLon(lon); |
| | | orderLogistics.setGetoffLat(lat); |
| | | orderLogistics.setGetoffAddress(address); |
| | | orderLogistics.setGetoffTime(new Date()); |
| | | orderLogistics.setEndServiceTime(new Date()); |
| | | orderLogistics.setCancelMidway(1); |
| | | }else{ |
| | | orderLogistics.setState(10); |
| | | } |
| | | this.updateById(orderLogistics); |
| | | }else{ |
| | | if(5 == orderLogistics.getState()){ |
| | | orderLogistics.setGetoffLon(lon); |
| | | orderLogistics.setGetoffLat(lat); |
| | | orderLogistics.setGetoffAddress(address); |
| | | orderLogistics.setGetoffTime(new Date()); |
| | | orderLogistics.setEndServiceTime(new Date()); |
| | | orderLogistics.setCancelMidway(1); |
| | | } |
| | | orderLogistics.setOldState(orderLogistics.getState()); |
| | | orderLogistics.setState(12); |
| | | this.updateById(orderLogistics); |
| | | integer = orderCancelService.saveData(id, 4, reason, remark, null, amount, 1, 1, uid); |
| | | } |
| | | if(!"139".equals(statusCode)){ |
| | | return ResultUtil.error(results.getStatusDescription()); |
| | | } |
| | | } |
| | | if(null != orderLogistics.getPayType() && orderLogistics.getPayType() == 2){//支付宝 |
| | | OrderCancel orderCancel = new OrderCancel(); |
| | | orderCancel.setOrderId(id); |
| | | orderCancel.setOrderType(orderLogistics.getType()); |
| | | orderCancel.setReason(reason); |
| | | orderCancel.setRemark(remark); |
| | | orderCancel.setState(1); |
| | | orderCancel.setInsertTime(new Date()); |
| | | orderCancel.setUserType(1); |
| | | orderCancelService.insert(orderCancel); |
| | | orderLogistics.setState(10); |
| | | this.updateById(orderLogistics); |
| | | integer = orderCancel.getId(); |
| | | //调用回退接口 |
| | | PaymentRecord query = paymentRecordService.query(1, orderLogistics.getUserId(), 1, orderLogistics.getId(), orderLogistics.getType(), 1, 2); |
| | | UserInfo userInfo = userInfoService.selectById(orderLogistics.getUserId()); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String payerTransactionID = sdf.format(new Date()) + orderCancel.getId(); |
| | | PayoutResponse payoutResponse = tinggPayoutUtil.sendPayout(userInfo.getPhoneOperator(), "+" + userInfo.getPhone(), payerTransactionID, query.getAmount().doubleValue(), callbackPath + "/base/orderCancelRefundCallback", "取消订单退款"); |
| | | AuthStatus authStatus = payoutResponse.getAuthStatus(); |
| | | Results results = payoutResponse.getResults().get(0); |
| | | String statusCode = results.getStatusCode(); |
| | | if(!"131".equals(authStatus.getAuthStatusCode())){ |
| | | return ResultUtil.error(authStatus.getAuthStatusDescription()); |
| | | } |
| | | if(!"139".equals(statusCode)){ |
| | | return ResultUtil.error(results.getStatusDescription()); |
| | | } |
| | | } |
| | | if(null != orderLogistics.getPayType() && orderLogistics.getPayType() == 3){//余额 |
| | | UserInfo userInfo = userInfoService.selectById(orderLogistics.getUserId()); |
| | | userInfo.setBalance(userInfo.getBalance() + orderLogistics.getPayMoney()); |
| | | |
| | | OrderCancel orderCancel = new OrderCancel(); |
| | | orderCancel.setOrderId(id); |
| | | orderCancel.setOrderType(orderLogistics.getType()); |
| | | orderCancel.setReason(reason); |
| | | orderCancel.setRemark(remark); |
| | | orderCancel.setState(2); |
| | | orderCancel.setInsertTime(new Date()); |
| | | orderCancel.setUserType(1); |
| | | orderCancelService.insert(orderCancel); |
| | | userInfoService.updateById(userInfo); |
| | | orderLogistics.setState(10); |
| | | this.updateById(orderLogistics); |
| | | integer = orderCancel.getId(); |
| | | |
| | | //添加交易明细 |
| | | transactionDetailsService.saveData(orderLogistics.getUserId(), "包裹取消退款", orderLogistics.getPayMoney(), 1, 1, 1, 4, orderLogistics.getId()); |
| | | } |
| | | |
| | | if(null != orderLogistics.getDriverId()){ |
| | | this.deleteTask(id);//删除定时任务 |
| | | |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), orderLogistics.getType(), orderLogistics.getState(), 0); |
| | | pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), 4, orderLogistics.getState(), 0); |
| | | } |
| | | }).start(); |
| | | |
| | | //修改司机为空闲 |
| | | Driver driver = driverService.selectById(orderLogistics.getDriverId()); |
| | | driver.setState(2); |
| | | driverService.updateById(driver); |
| | | } |
| | | |
| | | //添加消息 |
| | | systemNoticeService.addSystemNotice(1, language == 1 ? "您已成功取消包裹订单,谢谢使用!" : language == 2 ? "You have successfully cancelled your parcel order, thank you for using!" |
| | | : "Vous avez annulé avec succès votre commande de colis, merci de l’utiliser!", orderLogistics.getUserId(), 1); |
| | | systemNoticeService.addSystemNotice(1, language == 1 ? "您已成功取消包裹订单,谢谢使用!" : language == 2 ? "You've cancelled the delivery order successfully, thank you for using I-GO " |
| | | : "Vous avez annulé la commande de livraison avec succès, merci d’utiliser I-GO", orderLogistics.getUserId(), 1); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("id", integer); |
| | | return ResultUtil.success(map); |
| | |
| | | Map<String, Object> map = new HashMap<>(); |
| | | UserInfo userInfo = userInfoService.selectById(uid); |
| | | map.put("balance", userInfo.getBalance()); |
| | | map.put("coupon", 0); |
| | | OrderLogistics orderLogistics = this.selectById(orderId); |
| | | UserActivityDiscount1 query2 = userActivityDiscount1Mapper.query(orderLogistics.getCompanyId()); |
| | | double v = orderLogistics.getOrderMoney(); |
| | | if(null != query2){ |
| | | Integer orderNum=this.selectCount(new EntityWrapper<OrderLogistics>().eq("userId",orderLogistics.getUserId()).eq("activityId",query2.getId()).last(" and to_days(getoffTime) = to_days(now())")); |
| | | if(query2.getDistance()*1000>orderLogistics.getMileage() && query2.getOrderNum()>orderNum){ |
| | | Double special = query2.getSpecial(); |
| | | orderLogistics.setDiscount(special); |
| | | Double orderMoney = orderLogistics.getOrderMoney(); |
| | | v = new BigDecimal(orderMoney).multiply(new BigDecimal(special / 10)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue(); |
| | | } |
| | | } |
| | | int i = userCouponRecordService.queryAvailable(uid, orderLogistics.getCompanyId(), 1, 4, v); |
| | | i = i + userCouponRecordService.queryAvailable(uid, orderLogistics.getCompanyId(), 1, 0, v); |
| | | map.put("coupon", i); |
| | | return map; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> queryOrderInfo(Integer orderId) throws Exception { |
| | | public Map<String, Object> queryOrderInfo(Integer language, Integer orderId) throws Exception { |
| | | Map<String, Object> map = orderLogisticsMapper.queryOrderInfo(orderId); |
| | | if(null != map.get("travelTime")){ |
| | | String travelTime = map.get("travelTime").toString(); |
| | | map.put("travelTime", DateUtil.conversionFormat1(language, travelTime)); |
| | | } |
| | | Integer state = Integer.valueOf(String.valueOf(map.get("state"))); |
| | | OrderLogistics orderLogistics = this.selectById(orderId); |
| | | if(null != map.get("reassignNotice") && Integer.valueOf(String.valueOf(map.get("reassignNotice"))) == 2){//改派完成,重新获取了新的司机数据,开始修改数据防止继续调用 |
| | | orderLogistics.setReassignNotice(0); |
| | | this.updateById(orderLogistics); |
| | | } |
| | | if(Integer.valueOf(String.valueOf(map.get("state"))) == 11){ |
| | | if(state == 11){ |
| | | map.put("state", map.get("oldState")); |
| | | } |
| | | if(Integer.valueOf(String.valueOf(map.get("state"))) != 8 && Integer.valueOf(String.valueOf(map.get("state"))) != 9){ |
| | | map.put("redPacketMoney", null); |
| | | map.put("couponMoney", null); |
| | | } |
| | | if(Integer.valueOf(String.valueOf(map.get("state"))) == 7){ |
| | | UserActivityDiscount1 query2 = userActivityDiscount1Mapper.query(Integer.valueOf(String.valueOf(map.get("companyId")))); |
| | | if(null != query2){ |
| | | Integer orderNum=this.selectCount(new EntityWrapper<OrderLogistics>().eq("userId",orderLogistics.getUserId()).eq("activityId",query2.getId()).last(" and to_days(getoffTime) = to_days(now())")); |
| | | if(query2.getDistance()*1000>orderLogistics.getMileage() && query2.getOrderNum()>orderNum){ |
| | | Double special = query2.getSpecial(); |
| | | orderLogistics.setDiscount(special); |
| | | Double orderMoney = orderLogistics.getOrderMoney(); |
| | | double v = new BigDecimal(orderMoney).multiply(new BigDecimal(special / 10)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue(); |
| | | if(orderMoney.compareTo(v) > 0){ |
| | | map.put("discountMoney",orderMoney - v); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | Map<String, String> geocode = gdMapGeocodingUtil.geocode(map.get("startLon").toString(), map.get("startLat").toString()); |
| | | map.put("startCity", geocode.get("city")); |
| | |
| | | String driverId = redisUtil.getValue("DEVICE_" + map.get("driverId")); |
| | | map.put("device", ToolUtil.isNotEmpty(driverId) ? 2 : 1); |
| | | map.put("orderType", orderLogistics.getType()); |
| | | if(state == 6){ |
| | | map.put("receipt", "http://182.160.16.251:81/files/html/parcel_receipt_" + orderId + ".html"); |
| | | }else{ |
| | | map.put("receipt", ""); |
| | | } |
| | | Integer companyId = 1; |
| | | if(null != map.get("driverId")){ |
| | | companyId = Integer.valueOf(String.valueOf(map.get("companyId"))); |
| | | } |
| | | CancleOrder cancleOrder = cancleOrderService.selectOne(new EntityWrapper<CancleOrder>().eq("companyId", companyId)); |
| | | JSONObject jsonObject = JSON.parseObject(cancleOrder.getContent()); |
| | | map.put("timeOutCancel", jsonObject.getIntValue("driverTimeout")); |
| | | return map; |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> queryCoupon(Integer orderId, Integer uid, Integer pageNum, Integer size) throws Exception { |
| | | public List<Map<String, Object>> queryCoupon(Integer language, Integer orderId, Integer uid, Integer pageNum, Integer size) throws Exception { |
| | | OrderLogistics orderLogistics = this.selectById(orderId); |
| | | List<Map<String, Object>> list = userCouponRecordService.queryCoupon(uid, orderLogistics.getCompanyId(), 1, 4, orderLogistics.getOrderMoney(), pageNum, size); |
| | | List<Map<String, Object>> list1 = userCouponRecordService.queryCoupon(uid, orderLogistics.getCompanyId(), 1, 0, orderLogistics.getOrderMoney(), pageNum, size); |
| | | List<Map<String, Object>> list = userCouponRecordService.queryCoupon(language, uid, orderLogistics.getCompanyId(), 1, 4, orderLogistics.getOrderMoney() - orderLogistics.getDiscountMoney(), pageNum, size); |
| | | List<Map<String, Object>> list1 = userCouponRecordService.queryCoupon(language, uid, orderLogistics.getCompanyId(), 1, 0, orderLogistics.getOrderMoney() - orderLogistics.getDiscountMoney(), pageNum, size); |
| | | list.addAll(list1); |
| | | return list; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取取消需要支付的金额 |
| | | * @param id |
| | | * @param language |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil<BaseWarpper> queryCancleAmount(Integer id, Integer language) throws Exception { |
| | | OrderLogistics orderLogistics = this.selectById(id); |
| | | if(null == orderLogistics){ |
| | | return ResultUtil.error(language == 1 ? "获取数据失败,订单信息有误" : language == 2 ? "Failed to obtain data, order-information error." : "Impossible d’obtenir les données, erreur d’information de commande. "); |
| | | } |
| | | BaseWarpper baseWarpper = new BaseWarpper(); |
| | | double amount = 0; |
| | | CancleOrder query = cancleOrderService.query(orderLogistics.getCompanyId()); |
| | | if(null == query || null == orderLogistics.getDriverId()){ |
| | | baseWarpper.setAmount(amount); |
| | | return ResultUtil.success(baseWarpper); |
| | | } |
| | | JSONObject object = JSON.parseObject(query.getContent()); |
| | | long t = object.getInteger("driverTimeout") * 60000L; |
| | | //司机超时未到达起点,免费取消 |
| | | if(orderLogistics.getState() < 3 && orderLogistics.getSnatchOrderTime().getTime() + t < System.currentTimeMillis()){ |
| | | baseWarpper.setAmount(amount); |
| | | return ResultUtil.success(baseWarpper); |
| | | } |
| | | |
| | | JSONObject order = object.getJSONObject("order"); |
| | | long m = order.getInteger("orderAcceptanceTime") * 60000L; |
| | | //超过免费时间,计算费用 |
| | | if(orderLogistics.getSnatchOrderTime().getTime() + m < System.currentTimeMillis()){ |
| | | BigDecimal money = order.getBigDecimal("money"); |
| | | if(null != orderLogistics.getSetOutTime()){ |
| | | //里程费 |
| | | BigDecimal mileageFee = order.getBigDecimal("mileageFee").multiply(new BigDecimal(orderLogistics.getMileage() / 1000)); |
| | | //时长费 |
| | | int s = Double.valueOf((System.currentTimeMillis() - orderLogistics.getSetOutTime().getTime()) / 60000).intValue(); |
| | | BigDecimal durationFee = order.getBigDecimal("durationFee").multiply(new BigDecimal(s)); |
| | | money = money.add(durationFee).add(mileageFee); |
| | | } |
| | | amount = money.setScale(2, RoundingMode.HALF_EVEN).doubleValue(); |
| | | } |
| | | baseWarpper.setAmount(amount); |
| | | return ResultUtil.success(baseWarpper); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除定时任务 |
| | | * @param orderId |
| | | */ |
| | | @Override |
| | | public void deleteTask(Integer orderId){ |
| | | //发送验证码短信 |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | // 以表单的方式提交 |
| | | headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); |
| | | //将请求头部和参数合成一个请求 |
| | | MultiValueMap<String, Object> params = new LinkedMultiValueMap<>(); |
| | | params.add("orderId", orderId + ""); |
| | | params.add("orderType", "4"); |
| | | HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<>(params, headers); |
| | | String s = internalRestTemplate.postForObject("http://driver-server/base/netty/deleteTask", requestEntity, String.class); |
| | | JSONObject jsonObject = JSON.parseObject(s, JSONObject.class); |
| | | if(jsonObject.getIntValue("code") != 200){ |
| | | System.err.println("调用driver-server出错了"); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 取消订单操作 |
| | | * @param id |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil cancleOrderPrivateCar(Integer id, Integer payType, Integer bankCardId, Integer cancleId, Integer type, Integer language) throws Exception { |
| | | OrderLogistics orderLogistics = this.selectById(id); |
| | | Integer uid = orderLogistics.getUserId(); |
| | | UserInfo userInfo = userInfoService.selectById(uid); |
| | | ResultUtil resultUtil = ResultUtil.success(""); |
| | | |
| | | if(null == orderLogistics){ |
| | | return ResultUtil.error(language == 1 ? "取消订单失败,订单信息有误" : language == 2 ? "Failed to cancel order, order-information error." : "Échec de l’annulation de la commande, erreur d’information de commande.", ""); |
| | | } |
| | | if(orderLogistics.getState() != 13){ |
| | | return ResultUtil.error(language == 1 ? "取消订单失败,不合法的操作" : language == 2 ? "Failed to cancel order, illegal operation." : "Échec de l’annulation de la commande, opération illégale.", ""); |
| | | } |
| | | OrderCancel orderCancel = null; |
| | | if(null == cancleId || cancleId==0){ |
| | | orderCancel = orderCancelService.query(id, 4, null, null, 1); |
| | | }else{ |
| | | orderCancel = orderCancelService.selectById(cancleId); |
| | | } |
| | | |
| | | Double amount = queryCancleAmount(id, language).getData().getAmount(); |
| | | if(0 < amount){ |
| | | if(payType == 1){//手机支付 |
| | | orderCancel.setPayType(1); |
| | | orderCancelService.updateById(orderCancel); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String merchantTransactionId = sdf.format(new Date()) + "4" + language + id; |
| | | CheckoutRequest checkoutRequest = new CheckoutRequest(); |
| | | checkoutRequest.setMsisdn(Long.valueOf(userInfo.getPhone())); |
| | | checkoutRequest.setCustomerEmail(userInfo.getEmail()); |
| | | checkoutRequest.setAccountNumber(userInfo.getPhone()); |
| | | checkoutRequest.setCustomerFirstName(userInfo.getFirstName()); |
| | | checkoutRequest.setCustomerLastName(userInfo.getLastName()); |
| | | checkoutRequest.setRequestAmount(amount); |
| | | checkoutRequest.setMerchantTransactionId(merchantTransactionId); |
| | | checkoutRequest.setRequestDescription("Cancel a trip"); |
| | | checkoutRequest.setCallbackUrl(callbackPath + "/base/wxCancelOrderTaxi"); |
| | | checkoutRequest.setPendingRedirectUrl(""); |
| | | checkoutRequest.setSuccessRedirectUrl("http://182.160.16.251:81/payMoney/pages/success.html"); |
| | | checkoutRequest.setFailRedirectUrl("http://182.160.16.251:81/payMoney/pages/fail.html"); |
| | | resultUtil = TinggPayUtil.checkoutRequest(checkoutRequest); |
| | | if(resultUtil.getCode()==200){ |
| | | paymentRecordService.saveData(1, null, null, id, 4, 1, amount, null, 1);//添加预支付数据 |
| | | } |
| | | |
| | | } |
| | | if(payType == 2){//银行卡支付 |
| | | orderCancel.setPayType(2); |
| | | orderCancelService.updateById(orderCancel); |
| | | BankCard bankCard = bankCardService.selectById(bankCardId); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | String merchantTransactionId = sdf.format(new Date()) + "4" + id; |
| | | CheckoutRequest checkoutRequest = new CheckoutRequest(); |
| | | checkoutRequest.setMsisdn(Long.valueOf(bankCard.getCode())); |
| | | checkoutRequest.setCustomerEmail(userInfo.getEmail()); |
| | | checkoutRequest.setAccountNumber(bankCard.getCode()); |
| | | checkoutRequest.setCustomerFirstName(bankCard.getFirstName()); |
| | | checkoutRequest.setCustomerLastName(bankCard.getLastName()); |
| | | checkoutRequest.setRequestAmount(amount); |
| | | checkoutRequest.setMerchantTransactionId(merchantTransactionId); |
| | | checkoutRequest.setRequestDescription("Cancel a trip"); |
| | | checkoutRequest.setCallbackUrl(callbackPath + "/base/wxCancelOrderTaxi"); |
| | | checkoutRequest.setPendingRedirectUrl(""); |
| | | checkoutRequest.setSuccessRedirectUrl("http://182.160.16.251:81/payMoney/pages/success.html"); |
| | | checkoutRequest.setFailRedirectUrl("http://182.160.16.251:81/payMoney/pages/fail.html"); |
| | | resultUtil = TinggPayUtil.checkoutRequest(checkoutRequest); |
| | | if(resultUtil.getCode()==200){ |
| | | paymentRecordService.saveData(1, null, null, id, 4, 2, amount, null, 1);//添加预支付数据 |
| | | } |
| | | |
| | | } |
| | | if(payType == 3){//余额支付 |
| | | if(userInfo.getBalance() != null && userInfo.getBalance() < amount){ |
| | | return ResultUtil.error((language == 1 ? "账户余额不足" : language == 2 ? "Insufficient balance" : "Solde insuffisant"), ""); |
| | | } |
| | | |
| | | userInfo.setBalance(new BigDecimal(userInfo.getBalance()).subtract(new BigDecimal(amount)).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | //添加交易明细 |
| | | transactionDetailsService.saveData(uid, "取消订单", amount, 2, 1, 1, 4, id); |
| | | userInfoService.updateById(userInfo); |
| | | |
| | | //解除小号绑定 |
| | | if(orderLogistics.getBindId() != null){ |
| | | ChinaMobileUtil.midAxbUnBindSend(orderLogistics.getBindId(),orderLogistics.getTelX()); |
| | | } |
| | | |
| | | if(5 == orderLogistics.getOldState()){ |
| | | orderLogistics.setState(6); |
| | | }else{ |
| | | orderLogistics.setState(10); |
| | | } |
| | | orderLogistics.setTelX(""); |
| | | orderLogistics.setBindId(""); |
| | | this.updateById(orderLogistics); |
| | | |
| | | orderCancel.setState(2); |
| | | orderCancel.setPayType(3); |
| | | orderCancelService.updateById(orderCancel); |
| | | |
| | | if(null != orderLogistics.getDriverId()){ |
| | | BigDecimal c =new BigDecimal(amount);//司机收入 |
| | | incomeService.saveData(2, orderLogistics.getDriverId(), 3, orderLogistics.getId(), 4, c.doubleValue()); |
| | | Driver driver = driverService.selectById(orderLogistics.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()); |
| | | driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driverService.updateById(driver); |
| | | |
| | | this.deleteTask(id);//删除定时任务 |
| | | pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), 4, orderLogistics.getState(), 0); |
| | | } |
| | | pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), 4, orderLogistics.getState(), 0); |
| | | |
| | | |
| | | //添加消息 |
| | | systemNoticeService.addSystemNotice(1, language == 1 ? "您已使用余额成功支付取消订单费用,谢谢使用!" : language == 2 |
| | | ? "You've paid for cancellation fee with the balance successfully, thank you for using I-GO" |
| | | : "Vous avez utilisé avec succès votre solde pour payer les frais d’annulation, merci d’utiliser I-GO", orderLogistics.getUserId(), 1); |
| | | } |
| | | } |
| | | return resultUtil; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 取消订单支付后的处理 |
| | | * @param id 订单=id |
| | | * @param order_id 工行支付单号 |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public void payCancelOrderPrivateCar(Integer id, String order_id, Integer language) throws Exception { |
| | | OrderLogistics orderLogistics = this.selectById(id); |
| | | PaymentRecord query = paymentRecordService.query(1, null, null, Integer.valueOf(id), 4, null, 1); |
| | | if(null != query){ |
| | | //添加交易明细 |
| | | transactionDetailsService.saveData(orderLogistics.getUserId(), "取消订单", query.getAmount(), 2, 1, 1, 4, query.getOrderId()); |
| | | |
| | | //解除小号绑定 |
| | | if(orderLogistics.getBindId() != null){ |
| | | ChinaMobileUtil.midAxbUnBindSend(orderLogistics.getBindId(),orderLogistics.getTelX()); |
| | | } |
| | | if(5 == orderLogistics.getOldState()){ |
| | | orderLogistics.setState(6); |
| | | }else{ |
| | | orderLogistics.setState(10); |
| | | } |
| | | orderLogistics.setBindId(""); |
| | | orderLogistics.setTelX(""); |
| | | this.updateById(orderLogistics); |
| | | |
| | | query.setState(2); |
| | | query.setCode(order_id); |
| | | paymentRecordService.updateById(query); |
| | | |
| | | OrderCancel query1 = orderCancelService.query(query.getOrderId(), query.getOrderType(), query.getAmount(), query.getPayType(), 1); |
| | | if (null != query1){ |
| | | query1.setState(2); |
| | | orderCancelService.updateById(query1); |
| | | } |
| | | |
| | | |
| | | if(null != orderLogistics.getDriverId()){ |
| | | BigDecimal c =new BigDecimal(query.getAmount());//司机收入 |
| | | incomeService.saveData(2, orderLogistics.getDriverId(), 3, orderLogistics.getId(), 4, c.doubleValue()); |
| | | Driver driver = driverService.selectById(orderLogistics.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()); |
| | | driver.setBalance(new BigDecimal(null != driver.getBalance() ? driver.getBalance() : 0).add(c).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | driverService.updateById(driver); |
| | | this.deleteTask(orderLogistics.getId());//删除定时任务 |
| | | |
| | | pushUtil.pushOrderState(2, orderLogistics.getDriverId(), orderLogistics.getId(), 4, orderLogistics.getState(), 0); |
| | | } |
| | | pushUtil.pushOrderState(1, orderLogistics.getUserId(), orderLogistics.getId(), 4, orderLogistics.getState(), 0); |
| | | |
| | | //添加消息 |
| | | systemNoticeService.addSystemNotice(1, language == 1 ? "您已使用余额成功支付取消订单费用,谢谢使用!" : language == 2 |
| | | ? "You've paid for cancellation fee with the balance successfully, thank you for using I-GO" |
| | | : "Vous avez utilisé avec succès votre solde pour payer les frais d’annulation, merci d’utiliser I-GO", orderLogistics.getUserId(), 1); |
| | | }else{ |
| | | System.err.println("预支付数据异常(orderId = " + id + ")"); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 修改目的地 |
| | | * @param orderId |
| | | * @param endLon |
| | | * @param endLat |
| | | * @param endAddress |
| | | */ |
| | | @Override |
| | | public void updateEndAddress(Integer orderId, String endLon, String endLat, String endAddress) { |
| | | OrderLogistics orderLogistics = this.selectById(orderId); |
| | | if(null != orderLogistics.getDriverId()){ |
| | | orderLogistics.setDestination(endAddress); |
| | | orderLogistics.setDestinationLat(endLat); |
| | | orderLogistics.setDestinationLon(endLon); |
| | | this.updateById(orderLogistics); |
| | | pushUtil.pushModifyAddress(2, orderLogistics.getDriverId(), orderId, 1, 1); |
| | | }else{ |
| | | orderLogistics.setEndAddress(endAddress); |
| | | orderLogistics.setEndLat(Double.valueOf(endLat)); |
| | | orderLogistics.setEndLon(Double.valueOf(endLon)); |
| | | this.updateById(orderLogistics); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public synchronized ResultUtil<BaseWarpper> queryRedMoney(Integer orderId) throws Exception { |
| | | OrderLogistics orderLogistics = this.selectById(orderId); |
| | | Integer companyId = orderLogistics.getCompanyId(); |
| | | |
| | | Map<String, Object> query = userActivityRedenvelopeService.query(companyId, orderLogistics.getTravelTime()); |
| | | Double money = 0D; |
| | | BaseWarpper baseWarpper = new BaseWarpper(); |
| | | if(null != query){ |
| | | Integer type = Integer.valueOf(String.valueOf(query.get("type"))); |
| | | if(type == 1){//固定金额 |
| | | money = Double.valueOf(String.valueOf(query.get("money"))); |
| | | }else{//随机金额 |
| | | Double startMoney = Double.valueOf(String.valueOf(query.get("startMoney"))); |
| | | Double endMoney = Double.valueOf(String.valueOf(query.get("endMoney"))); |
| | | money = new BigDecimal(startMoney + (Math.random() * (endMoney - startMoney))).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue(); |
| | | } |
| | | //判断当前红包是否大于剩余可领取总金额 |
| | | if(money.compareTo(Double.valueOf(query.get("lavePrice").toString())) > 0){ |
| | | baseWarpper.setAmount(0D); |
| | | return ResultUtil.success(baseWarpper); |
| | | } |
| | | } |
| | | |
| | | baseWarpper.setAmount(money); |
| | | |
| | | if(money > 0){ |
| | | //添加临时红包数据 |
| | | UserRedPacketRecord userRedPacketRecord = new UserRedPacketRecord(); |
| | | userRedPacketRecord.setMoney(money); |
| | | userRedPacketRecord.setRemainingAmount(money); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(new Date()); |
| | | calendar.set(Calendar.DAY_OF_MONTH, calendar.get(Calendar.DAY_OF_MONTH) + Integer.valueOf(String.valueOf(query.get("effective")))); |
| | | userRedPacketRecord.setInsertTime(new Date()); |
| | | userRedPacketRecord.setCompanyId(Integer.valueOf(String.valueOf(query.get("companyId")))); |
| | | userRedPacketRecord.setState(0); |
| | | userRedPacketRecord.setOrderId(orderLogistics.getId()); |
| | | userRedPacketRecord.setOrderType(4); |
| | | userRedPacketRecord.setUserId(orderLogistics.getUserId()); |
| | | userRedPacketRecordService.insert(userRedPacketRecord); |
| | | } |
| | | |
| | | return ResultUtil.success(baseWarpper); |
| | | } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public synchronized ResultUtil shareRedEnvelope(Integer orderId, Integer language) throws Exception { |
| | | OrderLogistics orderLogistics = this.selectById(orderId); |
| | | UserRedPacketRecord query = userRedPacketRecordService.query_(orderLogistics.getUserId(), orderLogistics.getCompanyId(), 0, 4, null); |
| | | if(null != query){ |
| | | Double money = query.getMoney(); |
| | | Map<String, Object> map = userActivityRedenvelopeService.query(orderLogistics.getCompanyId(), orderLogistics.getTravelTime()); |
| | | Double laveMoney = Double.valueOf(String.valueOf(map.get("laveMoney"))); |
| | | if(money.compareTo(laveMoney) > 0){ |
| | | return ResultUtil.error(language == 1 ? "手速太慢了,红包已派发完啦!" : language == 2 ? "Too slow, all the lucky-promo has been distributed!" : "Trop lent, toute la promo chanceuse a été distribuée !"); |
| | | } |
| | | //判断当前红包是否大于剩余可领取总金额 |
| | | if(money.compareTo(Double.valueOf(map.get("lavePrice").toString())) > 0){ |
| | | return ResultUtil.error(language == 1 ? "手速太慢了,红包已派发完啦!" : language == 2 ? "Too slow, all the lucky-promo has been distributed!" : "Trop lent, toute la promo chanceuse a été distribuée !"); |
| | | } |
| | | double v = new BigDecimal(laveMoney).subtract(new BigDecimal(money)).doubleValue(); |
| | | |
| | | UserActivityRedenvelope id = userActivityRedenvelopeService.selectById(String.valueOf(map.get("id"))); |
| | | id.setLaveMoney(v); |
| | | id.setLavePrice(new BigDecimal(id.getLavePrice() - money).setScale(2, BigDecimal.ROUND_HALF_EVEN).doubleValue()); |
| | | userActivityRedenvelopeService.updateById(id); |
| | | |
| | | query.setState(1); |
| | | query.setRedPacketActivityId(id.getId()); |
| | | userRedPacketRecordService.updateById(query); |
| | | |
| | | UserInfo userInfo = userInfoService.selectById(orderLogistics.getUserId()); |
| | | if(ToolUtil.isNotEmpty(userInfo.getEmail())){ |
| | | String path = templatePath + "user/redEnvelopes.html"; |
| | | Document document = Jsoup.parse(new File(path), "UTF-8"); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | if(1 == language){ |
| | | document.getElementById("english").remove(); |
| | | document.getElementById("french").remove(); |
| | | document.getElementsByTag("title").get(0).text("红包活动"); |
| | | Element user_chinese = document.getElementById("user_chinese"); |
| | | user_chinese.text("您好 " + userInfo.getNickName() + ","); |
| | | Element time_chinese = document.getElementById("time_chinese"); |
| | | time_chinese.text("此活动有效期在 " + DateUtil.conversionFormat(language, sdf.format(id.getStartTime())) + " 至 " + DateUtil.conversionFormat(language, sdf.format(id.getEnable())) + ",详情请查看I-GO平台"); |
| | | } |
| | | if(2 == language){ |
| | | document.getElementById("chinese").remove(); |
| | | document.getElementById("french").remove(); |
| | | document.getElementsByTag("title").get(0).text("Lucky-promo activities"); |
| | | Element user_english = document.getElementById("user_english"); |
| | | user_english.text("Hello " + userInfo.getNickName() + ","); |
| | | Element time_english = document.getElementById("time_english"); |
| | | time_english.text("You could use it from " + DateUtil.conversionFormat(language, sdf.format(id.getStartTime())) + " to " + DateUtil.conversionFormat(language, sdf.format(id.getEnable())) + ",check more details on the app."); |
| | | } |
| | | if(3 == language){ |
| | | document.getElementById("chinese").remove(); |
| | | document.getElementById("english").remove(); |
| | | document.getElementsByTag("title").get(0).text("Activités bonus"); |
| | | Element user_french = document.getElementById("user_french"); |
| | | user_french.text("Bonjour " + userInfo.getNickName() + ","); |
| | | Element time_french = document.getElementById("time_french"); |
| | | time_french.text("Cette promotion est valable du " + DateUtil.conversionFormat(language, sdf.format(id.getStartTime())) + " au " + DateUtil.conversionFormat(language, sdf.format(id.getEnable())) + ". Veuillez consulter la plateforme i-go pour plus de détails."); |
| | | } |
| | | |
| | | EmailUtil.send(userInfo.getEmail(), language == 1 ? "红包活动" : language == 2 ? "Lucky-promo activities" : "Activités bonus", document.html()); |
| | | //开始生成pdf收据和html收据 |
| | | File file = new File("/usr/local/nginx/html/files/html/"); |
| | | if(!file.exists()){ |
| | | file.mkdirs(); |
| | | } |
| | | file = new File("/usr/local/nginx/html/files/html/redpacket_" + orderId + ".html"); |
| | | if(!file.exists()){ |
| | | file.createNewFile(); |
| | | } |
| | | FileWriter fileWriter = new FileWriter(file); |
| | | fileWriter.write(document.html()); |
| | | fileWriter.flush(); |
| | | fileWriter.close(); |
| | | |
| | | String link ="http://182.160.16.251:81/files/html/redpacket_" + orderId + ".html"; |
| | | TEmail tEmail = new TEmail(); |
| | | tEmail.setLink(link); |
| | | tEmail.setUserId(userInfo.getId()); |
| | | tEmail.setType(1); |
| | | tEmail.setName(language == 1 ? "红包活动" : language == 2 ? "Lucky-promo activities" : "Activités bonus"); |
| | | tEmail.setOrderId(orderId); |
| | | tEmail.setCreateTime(new Date()); |
| | | int i = cn.hutool.core.date.DateUtil.dayOfWeek(new Date())-1; |
| | | tEmail.setWeek(EmailUtil.getWeek(language,i)); |
| | | boolean am = cn.hutool.core.date.DateUtil.isAM(new Date()); |
| | | if(am){ |
| | | tEmail.setAmOrPm(language==1?"上午":language==2?"morning":"matin"); |
| | | }else { |
| | | tEmail.setAmOrPm(language==1?"下午":language==2?"afternoon":"après-midi"); |
| | | } |
| | | emailService.insert(tEmail); |
| | | |
| | | } |
| | | |
| | | } |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取红包使用记录 |
| | | * @param uid |
| | | * @return |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public List<Map<String, Object>> queryRedEnvelope(Integer language, Integer uid) throws Exception { |
| | | List<Map<String, Object>> list = this.baseMapper.queryRedEnvelope(uid); |
| | | for (Map<String, Object> map : list) { |
| | | map.put("name", language == 1 ? "包裹" : language == 2 ? "Delivery" : "Livraison"); |
| | | if(null != map.get("time")){ |
| | | String time = map.get("time").toString(); |
| | | map.put("time", DateUtil.conversionFormat(language, time)); |
| | | } |
| | | } |
| | | return list; |
| | | } |
| | | } |