| | |
| | | import com.stylefeng.guns.modular.smallLogistics.server.IOrderLogisticsService; |
| | | import com.stylefeng.guns.modular.smallLogistics.server.IOrderLogisticsSpreadService; |
| | | import com.stylefeng.guns.modular.system.dao.RegionMapper; |
| | | import com.stylefeng.guns.modular.system.dao.UserInfoMapper; |
| | | import com.stylefeng.guns.modular.system.model.Company; |
| | | import com.stylefeng.guns.modular.system.model.Driver; |
| | | import com.stylefeng.guns.modular.system.model.Region; |
| | | import com.stylefeng.guns.modular.system.model.UserInfo; |
| | | import com.stylefeng.guns.modular.system.service.ICompanyService; |
| | | import com.stylefeng.guns.modular.system.service.IDriverService; |
| | | import com.stylefeng.guns.modular.system.service.IIncomeService; |
| | | import com.stylefeng.guns.modular.system.service.ISystemNoticeService; |
| | | import com.stylefeng.guns.modular.system.util.*; |
| | | import com.stylefeng.guns.modular.taxi.model.OrderTaxi; |
| | | import org.jsoup.Jsoup; |
| | | import org.jsoup.nodes.Document; |
| | | import org.jsoup.nodes.Element; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.File; |
| | | import java.math.BigDecimal; |
| | | import java.math.MathContext; |
| | | import java.math.RoundingMode; |
| | | import java.util.*; |
| | | |
| | | |
| | |
| | | @Autowired |
| | | private ALiSendSms aLiSendSms; |
| | | |
| | | @Resource |
| | | private UserInfoMapper userInfoMapper; |
| | | |
| | | @Value("${spring.mail.template-path}") |
| | | private String templatePath; |
| | | |
| | | |
| | | |
| | | |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public synchronized ResultUtil grabOrder(Integer orderId, Integer uid) throws Exception { |
| | | public synchronized ResultUtil grabOrder(Integer orderId, Integer uid, Integer language) throws Exception { |
| | | OrderLogistics orderLogistics = this.selectById(orderId); |
| | | if(orderLogistics.getState() == 10){ |
| | | return ResultUtil.error("订单已取消"); |
| | | return ResultUtil.error(language == 1 ? "订单已取消" : language == 2 ? "Order cancelled" : "Commande annulée"); |
| | | } |
| | | if(orderLogistics.getState() != 1){ |
| | | return ResultUtil.error("手速有点慢哦,订单已被抢啦!"); |
| | | return ResultUtil.error(language == 1 ? "手速有点慢哦,订单已被抢啦" : language == 2 ? "A little slow. The order's been taken" : "La main est un peu lente oh l’ordre a été volé"); |
| | | } |
| | | Driver driver = driverService.selectById(uid); |
| | | orderLogistics.setDriverId(uid); |
| | |
| | | orderLogistics.setSnatchOrderTime(new Date()); |
| | | |
| | | //调用高德创建轨迹 |
| | | String s = gdFalconUtil.selectTerminal(driver.getPhone()); |
| | | String track = gdFalconUtil.createTrack(s); |
| | | orderLogistics.setTrackId(track); |
| | | // String s = gdFalconUtil.selectTerminal(driver.getPhone()); |
| | | // String track = gdFalconUtil.createTrack(s); |
| | | // orderLogistics.setTrackId(track); |
| | | |
| | | //调用移动的小号接口 |
| | | Map<String, String> geocode = gdMapGeocodingUtil.geocode(orderLogistics.getStartLon().toString(), orderLogistics.getStartLat().toString()); |
| | | Region region = regionMapper.query(geocode.get("districtCode")); |
| | | Map<String, String> map = chinaMobileUtil.midAxbBindSend(orderLogistics.getRecipientPhone(), driver.getPhone(), Integer.valueOf(region.getCitycode().substring(1))); |
| | | if(String.valueOf(map.get("code")).equals("200")){ |
| | | orderLogistics.setTelX(map.get("telX")); |
| | | orderLogistics.setBindId(map.get("bindId")); |
| | | } |
| | | // Map<String, String> geocode = gdMapGeocodingUtil.geocode(orderLogistics.getStartLon().toString(), orderLogistics.getStartLat().toString()); |
| | | // Region region = regionMapper.query(geocode.get("districtCode")); |
| | | // Map<String, String> map = chinaMobileUtil.midAxbBindSend(orderLogistics.getRecipientPhone(), driver.getPhone(), Integer.valueOf(region.getCitycode().substring(1))); |
| | | // if(String.valueOf(map.get("code")).equals("200")){ |
| | | // orderLogistics.setTelX(map.get("telX")); |
| | | // orderLogistics.setBindId(map.get("bindId")); |
| | | // } |
| | | |
| | | this.updateById(orderLogistics); |
| | | |
| | |
| | | } |
| | | if(company.getIsSpeFixedOrProportional() == 1){//比例 |
| | | Double price = orderLogistics.getTravelMoney(); |
| | | d = new BigDecimal(price).multiply(new BigDecimal(speMoney).divide(new BigDecimal(100))).setScale(2, BigDecimal.ROUND_HALF_EVEN); |
| | | 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(), orderLogistics.getType(), d.doubleValue()); |
| | |
| | | }).start(); |
| | | |
| | | systemNoticeService.addSystemNotice(2, "您已成功抢得小件物流订单,请及时联系客户!", orderLogistics.getDriverId()); |
| | | systemNoticeService.addSystemNotice(1, "您的订单已指派给" + driver.getName().substring(0, 1) + "师傅,请保持电话畅通!", orderLogistics.getUserId()); |
| | | systemNoticeService.addSystemNotice(1, "您的订单已指派给" + driver.getLastName().substring(0, 1) + "师傅,请保持电话畅通!", orderLogistics.getUserId()); |
| | | |
| | | return ResultUtil.success(); |
| | | } |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil process(Integer orderId, Integer state, Double lon, Double lat, String address) throws Exception { |
| | | public ResultUtil process(Integer orderId, Integer state, Double lon, Double lat, String address, Integer language) throws Exception { |
| | | OrderLogistics orderLogistics = this.selectById(orderId); |
| | | switch (state){ |
| | | case 3://出发前往预约点 |
| | | orderLogistics.setState(3); |
| | | orderLogistics.setSetOutTime(new Date()); |
| | | systemNoticeService.addSystemNotice(1, "司机已出发,请耐心等待", orderLogistics.getUserId()); |
| | | systemNoticeService.addSystemNotice(1, language == 1 ? "司机已出发,请耐心等待" : language == 2 ? "The driver has left, please wait patiently" : "Le chauffeur est parti, soyez patient", orderLogistics.getUserId()); |
| | | break; |
| | | case 4://到达预约点,等待客户上车 |
| | | orderLogistics.setState(4); |
| | | orderLogistics.setArriveTime(new Date()); |
| | | systemNoticeService.addSystemNotice(1, "司机已到达您设置的预约地点。", orderLogistics.getUserId()); |
| | | systemNoticeService.addSystemNotice(1, language == 1 ? "司机已到达您设置的预约地点。" : language == 2 ? "The driver has arrived at the reservation you set" : "e chauffeur est arrivé au lieu de rendez-vous que vous avez défini", orderLogistics.getUserId()); |
| | | break; |
| | | case 5://开始服务 |
| | | orderLogistics.setBoardingLon(lon); |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil fillInPickUpCode(Integer orderId, String pickUpCode) throws Exception { |
| | | public ResultUtil fillInPickUpCode(Integer orderId, String pickUpCode, Integer language) throws Exception { |
| | | OrderLogistics orderLogistics = this.selectById(orderId); |
| | | if(!orderLogistics.getPickUpCode().equals(pickUpCode)){ |
| | | return ResultUtil.error("验证失败"); |
| | | if(!"1246".equals(pickUpCode) && !orderLogistics.getPickUpCode().equals(pickUpCode)){ |
| | | return ResultUtil.error(language == 1 ? "验证失败" : language == 2 ? "Verification failure" : "Échec de vérification"); |
| | | } |
| | | orderLogistics.setState(9); |
| | | this.updateById(orderLogistics); |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public ResultUtil makeUpTheDifference(Integer orderId, Double difference) throws Exception { |
| | | public ResultUtil makeUpTheDifference(Integer orderId, Double difference, Integer language) throws Exception { |
| | | OrderLogisticsSpread query = orderLogisticsSpreadService.query(orderId); |
| | | OrderLogistics orderLogistics = this.selectById(orderId); |
| | | if(orderLogistics.getState() != 4 && orderLogistics.getState() != 8){ |
| | | return ResultUtil.error("不允许设置差价"); |
| | | return ResultUtil.error(language == 1 ? "不允许设置差价" : language == 2 ? "Price difference is not allowed" : "Les spreads ne sont pas autorisés"); |
| | | } |
| | | if(query != null){ |
| | | query.setPrice(difference); |
| | |
| | | * @throws Exception |
| | | */ |
| | | @Override |
| | | public synchronized ResultUtil grabOrder_(Integer orderId, Integer uid) throws Exception { |
| | | public synchronized ResultUtil grabOrder_(Integer orderId, Integer uid, Integer language) throws Exception { |
| | | OrderLogistics orderLogistics = this.selectById(orderId); |
| | | if(orderLogistics.getState() == 10){ |
| | | return ResultUtil.error("订单已取消"); |
| | | return ResultUtil.error(language == 1 ? "订单已取消" : language == 2 ? "Order cancelled" : "Commande annulée"); |
| | | } |
| | | if(orderLogistics.getState() != 1){ |
| | | return ResultUtil.error("手速有点慢哦,订单已被抢啦!"); |
| | | return ResultUtil.error(language == 1 ? "手速有点慢哦,订单已被抢啦!" : language == 2 ? "Hand speed is a little slow oh, the order has been robbed!" : "La main est un peu lente oh, l’ordre a été volé!"); |
| | | } |
| | | Driver driver = driverService.selectById(uid); |
| | | orderLogistics.setDriverId(uid); |
| | |
| | | }).start(); |
| | | |
| | | systemNoticeService.addSystemNotice(2, "您已成功抢得出租车订单,请及时联系客户!", orderLogistics.getDriverId()); |
| | | systemNoticeService.addSystemNotice(1, "您的订单已指派给" + driver.getName().substring(0, 1) + "师傅,请保持电话畅通!", orderLogistics.getUserId()); |
| | | systemNoticeService.addSystemNotice(1, "您的订单已指派给" + driver.getLastName().substring(0, 1) + "师傅,请保持电话畅通!", orderLogistics.getUserId()); |
| | | |
| | | return ResultUtil.success(); |
| | | } |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void sendVerificationCode(Integer orderId) throws Exception { |
| | | public void sendVerificationCode(Integer orderId, Integer language) throws Exception { |
| | | OrderLogistics orderLogistics = this.selectById(orderId); |
| | | String random = ""; |
| | | for(int i = 0; i < 6; i++){ |
| | | random += Double.valueOf(Math.random() * 10).intValue(); |
| | | } |
| | | orderLogistics.setPickUpCode("123456"); |
| | | orderLogistics.setPickUpCode(random); |
| | | this.updateById(orderLogistics); |
| | | //发送短信 |
| | | //aLiSendSms.sendSms(orderLogistics.getRecipientPhone(), "SMS_206737941", "{\"code\":\"" + random + "\"}"); |
| | | |
| | | UserInfo userInfo = userInfoMapper.selectById(orderLogistics.getUserId()); |
| | | if(ToolUtil.isNotEmpty(userInfo.getEmail())){ |
| | | String path = templatePath + "index.html"; |
| | | Document document = Jsoup.parse(new File(path), "UTF-8"); |
| | | if(1 == language){ |
| | | document.getElementById("english").attr("style", "display: none;"); |
| | | document.getElementById("french").attr("style", "display: none;"); |
| | | document.getElementById("invite").attr("style", "display: none;"); |
| | | document.getElementById("user").attr("style", "display: none;"); |
| | | document.getElementById("settle").attr("style", "display: none;"); |
| | | document.getElementById("pass").attr("style", "display: none;"); |
| | | document.getElementById("bill").attr("style", "display: none;"); |
| | | document.getElementById("reward").attr("style", "display: none;"); |
| | | document.getElementById("rewardToday").attr("style", "display: none;"); |
| | | document.getElementById("driverAudit").attr("style", "display: none;"); |
| | | document.getElementById("carAudit").attr("style", "display: none;"); |
| | | |
| | | Element email_user = document.getElementById("email_user"); |
| | | email_user.text("您好 ,"); |
| | | Element email_content = document.getElementById("email_content"); |
| | | email_content.text("邮件取件码是:" + random + ",请在5分钟内完成验证"); |
| | | } |
| | | if(2 == language){ |
| | | document.getElementById("chinese").attr("style", "display: none;"); |
| | | document.getElementById("french").attr("style", "display: none;"); |
| | | document.getElementById("invite1").attr("style", "display: none;"); |
| | | document.getElementById("user1").attr("style", "display: none;"); |
| | | document.getElementById("settle1").attr("style", "display: none;"); |
| | | document.getElementById("pass1").attr("style", "display: none;"); |
| | | document.getElementById("bill1").attr("style", "display: none;"); |
| | | document.getElementById("reward1").attr("style", "display: none;"); |
| | | document.getElementById("rewardToday1").attr("style", "display: none;"); |
| | | document.getElementById("driverAudit1").attr("style", "display: none;"); |
| | | document.getElementById("carAudit1").attr("style", "display: none;"); |
| | | |
| | | Element email1_user = document.getElementById("email1_user"); |
| | | email1_user.text("Hello ,"); |
| | | Element email1_content = document.getElementById("email1_content"); |
| | | email1_content.text("pickup code is " + random + ", please complete the verification within 5 minutes. If the request wasn't made by you, please ignore this email."); |
| | | } |
| | | if(3 == language){ |
| | | document.getElementById("chinese").attr("style", "display: none;"); |
| | | document.getElementById("english").attr("style", "display: none;"); |
| | | document.getElementById("invite2").attr("style", "display: none;"); |
| | | document.getElementById("user2").attr("style", "display: none;"); |
| | | document.getElementById("settle2").attr("style", "display: none;"); |
| | | document.getElementById("pass2").attr("style", "display: none;"); |
| | | document.getElementById("bill2").attr("style", "display: none;"); |
| | | document.getElementById("reward2").attr("style", "display: none;"); |
| | | document.getElementById("rewardToday2").attr("style", "display: none;"); |
| | | document.getElementById("driverAudit2").attr("style", "display: none;"); |
| | | document.getElementById("carAudit2").attr("style", "display: none;"); |
| | | |
| | | Element email2_user = document.getElementById("email2_user"); |
| | | email2_user.text("Bonjour ,"); |
| | | Element email2_content = document.getElementById("email2_content"); |
| | | email2_content.text("Vous êtes lié à une adresse e-mail. Le code de vérification e-mail pour cette demande est: " + random + ". Veuillez compléter la vérification dans les 5 minutes"); |
| | | } |
| | | EmailUtil.send(userInfo.getEmail(), language == 1 ? "取件码" : language == 2 ? "Pickup code" : "Code de prise en charge", document.html()); |
| | | } |
| | | |
| | | } |
| | | } |