| | |
| | | import cn.exrick.xboot.your.util.HttpUtil; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.json.JSONArray; |
| | | import cn.hutool.json.JSONObject; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | |
| | | String openid = SessionKeyOpenId.getStr("openid"); |
| | | |
| | | if(StrUtil.isEmpty(openid)){ |
| | | return ResultUtil.error(SessionKeyOpenId.toString()); |
| | | return ResultUtil.error("error微信:"+SessionKeyOpenId.toString()); |
| | | } |
| | | |
| | | QueryWrapper<Customer> wrapper = new QueryWrapper<>(); |
| | |
| | | if(one==null){ |
| | | return ResultUtil.error(openid);//首次登陆需绑定零售许可证 |
| | | }else { |
| | | one.setLoginNum(one.getLoginNum()+1); |
| | | iCustomerService.saveOrUpdate(one); |
| | | return ResultUtil.data(one,"登录成功"); |
| | | } |
| | | } |
| | |
| | | public static JSONObject getSessionKeyOrOpenId(String code){ |
| | | //微信端登录code |
| | | String wxCode = code; |
| | | String requestUrl = "https://api.weixin.qq.com/sns/jscode2session?appid=wx0f10f6d253f3ee6b&secret=4d4cbc8da31a96559114ad693de70631&grant_type=authorization_code&js_code="+code; |
| | | String requestUrl = "https://api.weixin.qq.com/sns/jscode2session?appid=wx77c0d2c54010b7e4&secret=2282710e890670e916c189347d70a7c5&grant_type=authorization_code&js_code="+code; |
| | | JSONObject jsonObject = JSONUtil.parseObj( HttpUtil.get(requestUrl)); |
| | | return jsonObject; |
| | | } |
| | |
| | | //openId:微信id |
| | | @RequestMapping(value = "/bindWx", method = RequestMethod.POST) |
| | | @ApiOperation(value = "微信绑定零售许可证") |
| | | public Object bindWx(String licence,String openId){ |
| | | public Object bindWx(String licence,String openId,String linker,String phone){ |
| | | QueryWrapper<Customer> wrapper2 = new QueryWrapper<>(); |
| | | wrapper2.eq("open_id",openId); |
| | | Customer c = iCustomerService.getOne(wrapper2); |
| | | if(c==null){ |
| | | |
| | | }else { |
| | | System.out.println(c.getOpenId()); |
| | | c.setOpenId(""); |
| | | iCustomerService.saveOrUpdate(c); |
| | | } |
| | | |
| | | QueryWrapper<Customer> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("licence",licence); |
| | | if(StrUtil.isNotEmpty(linker)){ |
| | | wrapper.eq("linker",linker); |
| | | } |
| | | if(StrUtil.isNotEmpty(phone)){ |
| | | wrapper.eq("phone",phone); |
| | | } |
| | | Customer one = iCustomerService.getOne(wrapper); |
| | | if(one==null){ |
| | | return ResultUtil.error("零售许可证无效");//首次登陆需绑定零售许可证 |
| | |
| | | wrapper2.eq("customer_id",customerId); |
| | | wrapper2.eq("send_date",format); |
| | | OrderTask orderTask = iOrderTaskService.getOne(wrapper2); |
| | | if(orderTask==null){ |
| | | return ResultUtil.error("今日无订单"); |
| | | } |
| | | String carId = orderTask.getCarId(); |
| | | Car car = iCarService.getById(carId); |
| | | String[] carids = new String[1]; |
| | | carids[0]= car.getCode(); |
| | | String latestGps = haiKangPost.findLatestGps(carids); |
| | | JSONObject jsonObject = JSONUtil.parseObj(latestGps); |
| | | String data = jsonObject.getStr("data"); |
| | | JSONObject jsonObject2 = JSONUtil.parseObj(data); |
| | | Integer lng = jsonObject2.getInt("longitude"); |
| | | Integer lat = jsonObject2.getInt("latitude"); |
| | | |
| | | DecimalFormat df = new DecimalFormat("#.000000"); |
| | | Map<String,Object> map = new HashMap<>(); |
| | | map.put("lng",df.format(lng/360000.0)); |
| | | map.put("lat",df.format(lat/360000.0)); |
| | | map.put("content","还有3单,预计10:22送达"); |
| | | map.put("lng",118.167491); |
| | | map.put("lat",39.651253); |
| | | map.put("content","暂无车辆数据"); |
| | | if(StrUtil.isEmpty(car.getCode())){ |
| | | return ResultUtil.data(map); |
| | | } |
| | | try { |
| | | String[] carids = new String[1]; |
| | | carids[0]= car.getCode(); |
| | | String latestGps = haiKangPost.findLatestGps(carids); |
| | | JSONObject jsonObject = JSONUtil.parseObj(latestGps); |
| | | String data = jsonObject.getStr("data"); |
| | | JSONArray objects = JSONUtil.parseArray(data); |
| | | JSONObject jsonObject2 = objects.getJSONObject(0); |
| | | Integer lng = jsonObject2.getInt("longitude"); |
| | | Integer lat = jsonObject2.getInt("latitude"); |
| | | |
| | | DecimalFormat df = new DecimalFormat("#.000000"); |
| | | map.put("lng",df.format(lng/360000.0)); |
| | | map.put("lat",df.format(lat/360000.0)); |
| | | }catch (Exception e){ |
| | | |
| | | } |
| | | QueryWrapper<OrderTask> wrapper = new QueryWrapper<OrderTask>(); |
| | | wrapper.eq("area_id",orderTask.getAreaId()); |
| | | wrapper.eq("send_date",format); |
| | | wrapper.eq("status",0); |
| | | wrapper.orderByAsc("seq"); |
| | | List<OrderTask> list = iOrderTaskService.list(wrapper); |
| | | |
| | | if(list.size()>0){ |
| | | if(list.get(0).getSeq()<orderTask.getSeq()){ |
| | | int i = orderTask.getSeq() - list.get(0).getSeq(); |
| | | map.put("content","还有"+i+"单,预计"+(i*5)+"分钟后送达"); |
| | | } |
| | | if(list.get(0).getSeq()==orderTask.getSeq()){ |
| | | int i = orderTask.getSeq() - list.get(0).getSeq(); |
| | | map.put("content","预计5分钟内送达"); |
| | | } |
| | | } |
| | | return ResultUtil.data(map); |
| | | } |
| | | |
| | |
| | | @ApiOperation(value = "加油助力") |
| | | public Object likes(String customerId){ |
| | | OrderTask order = getOrder(customerId); |
| | | if(order==null){ |
| | | ResultUtil.error("今日无订单"); |
| | | } |
| | | order.setLikes(1); |
| | | iOrderTaskService.saveOrUpdate(order); |
| | | return ResultUtil.success("助力成功"); |
| | |
| | | } |
| | | return new ResultUtil<CustomerReceive>().setErrorMsg("操作失败"); |
| | | } |
| | | |
| | | //14.获取签收人列表 |
| | | @RequestMapping(value = "/getCustomerReceive", method = RequestMethod.GET) |
| | | @ApiOperation(value = "获取签收人") |
| | | public Result<List<CustomerReceive>> getCustomerReceive(String customerId) { |
| | | PageVo page = new PageVo(); |
| | | page.setPageSize(30); |
| | | page.setPageNumber(1); |
| | | page.setOrder("desc"); |
| | | page.setSort("createTime"); |
| | | QueryWrapper<CustomerReceive> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("customer_id",customerId); |
| | | IPage<CustomerReceive> data = iCustomerReceiveService.page2(PageUtil.initMpPage(page),wrapper); |
| | | return new ResultUtil<List<CustomerReceive>>().setData(data.getRecords()); |
| | | } |
| | | |
| | | //15.获取签收人 |
| | | @RequestMapping(value = "/getCustomerReceiveById", method = RequestMethod.GET) |
| | | @ApiOperation(value = "获取签收人") |
| | | public Result<CustomerReceive> getCustomerReceiveById(String customerReceiveId) { |
| | | CustomerReceive byId = iCustomerReceiveService.getById(customerReceiveId); |
| | | return new ResultUtil<CustomerReceive>().setData(byId); |
| | | } |
| | | |
| | | //16.删除接货人 |
| | | @RequestMapping(value = "/deleteReceive", method = RequestMethod.POST) |
| | | @ApiOperation(value = "删除接货人") |
| | | public Object deleteReceive(String id) { |
| | | iCustomerReceiveService.removeById(id); |
| | | return ResultUtil.success("删除成功"); |
| | | } |
| | | } |