| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.alipay.api.internal.util.codec.Base64; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.stylefeng.guns.core.common.constant.JwtConstants; |
| | |
| | | import com.stylefeng.guns.modular.system.warpper.LoginWarpper; |
| | | import com.stylefeng.guns.modular.system.warpper.RegisteredWarpper; |
| | | import com.stylefeng.guns.modular.taxi.service.IOrderTaxiService; |
| | | import org.apache.http.entity.ContentType; |
| | | import org.apache.shiro.authc.SimpleAuthenticationInfo; |
| | | import org.apache.shiro.authc.UsernamePasswordToken; |
| | | import org.apache.shiro.authc.credential.HashedCredentialsMatcher; |
| | |
| | | import org.apache.shiro.util.ByteSource; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.http.*; |
| | | import org.springframework.mock.web.MockMultipartFile; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.LinkedMultiValueMap; |
| | | import org.springframework.util.MultiValueMap; |
| | | import org.springframework.web.client.RestTemplate; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.*; |
| | | import java.math.BigDecimal; |
| | | import java.security.SecureRandom; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private IOrderLogisticsService orderLogisticsService; |
| | | @Autowired |
| | | private ICompanyService companyService; |
| | | |
| | | @Value("${pushMinistryOfTransport}") |
| | | private boolean pushMinistryOfTransport; |
| | |
| | | String templateCode = ""; |
| | | switch (type){ |
| | | case 1: |
| | | templateCode = "SMS_476880205";//身份验证 |
| | | templateCode = "SMS_482775061";//身份验证 |
| | | break; |
| | | case 2: |
| | | templateCode = "SMS_476880205";//登录确认 |
| | | templateCode = "SMS_482775061";//登录确认 |
| | | break; |
| | | case 3: |
| | | templateCode = "SMS_476880205";//用户注册 |
| | | templateCode = "SMS_482775061";//用户注册 |
| | | break; |
| | | case 4: |
| | | templateCode = "SMS_476880205";//修改密码 |
| | | templateCode = "SMS_482775061";//修改密码 |
| | | break; |
| | | } |
| | | String sData = aLiSendSms.sendSms(phone, templateCode, "{\"code\":\"" + authCode + "\"}"); |
| | |
| | | @Override |
| | | public boolean checkCaptcha(String phone, String code) throws Exception { |
| | | Object value = redisUtil.getValue(phone); |
| | | if("1234".equals(code)){ |
| | | if("5689".equals(code)){ |
| | | return true; |
| | | } |
| | | |
| | |
| | | return ResultUtil.error("该车辆正在服务中,请更换其他车辆"); |
| | | } |
| | | } |
| | | List<TUseMoney> tUseMoney = useMoneyMapper.selectList(null); |
| | | if (tUseMoney.get(0).getMoney()>driver.getBalance()){ |
| | | // List<TUseMoney> tUseMoney = useMoneyMapper.selectList(null); |
| | | Company company = companyService.selectById(driver.getCompanyId()); |
| | | if (company.getDriverRestriction()>driver.getBalance()){ |
| | | pushUtil.expireWork(uid,2); |
| | | return new ResultUtil(-1,"您的余额不足,请及时充值!"); |
| | | } |
| | |
| | | redisUtil.remove("DEVICE_" + id);//清除车载端登录的标识 |
| | | return ResultUtil.success(); |
| | | } |
| | | @Autowired |
| | | private WeChatUtil weChatUtil; |
| | | @Autowired |
| | | private RestTemplate restTemplate; |
| | | @Override |
| | | public Driver generateCode(Driver userInfo) { |
| | | generateQrCode(userInfo); |
| | | return userInfo; |
| | | } |
| | | |
| | | private void generateQrCode(Driver userInfo) { |
| | | if (userInfo.getCode()!=null){ |
| | | return; |
| | | } |
| | | String accessToken = weChatUtil.getAccessToken(); |
| | | InputStream inputStream = null; |
| | | OutputStream outputStream = null; |
| | | try { |
| | | String url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + accessToken; |
| | | Map<String, Object> param = new HashMap<>(); |
| | | // param.put("page", "pageA/houseDetail"); |
| | | param.put("check_path", false); |
| | | // 用户id 用于分享 |
| | | param.put("scene", "uid="+userInfo.getId()+"userType=2"); |
| | | param.put("env_version", "release"); |
| | | param.put("width", 200); //二维码尺寸 |
| | | param.put("is_hyaline", true); // 是否需要透明底色, is_hyaline 为true时,生成透明底色的小程序码 参数仅对小程序码生效 |
| | | param.put("auto_color", true); // 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调 参数仅对小程序码生效 |
| | | Map<String, Object> line_color = new HashMap<>(); |
| | | line_color.put("r", 0); |
| | | line_color.put("g", 0); |
| | | line_color.put("b", 0); |
| | | param.put("line_color", line_color); |
| | | System.err.println("调用生成微信URL接口传参:" + param); |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headers.setContentType(MediaType.APPLICATION_JSON); |
| | | HttpEntity requestEntity = new HttpEntity(param, headers); |
| | | // HashMap<String, String> map = new HashMap<>(); |
| | | // map.put("path", path); |
| | | // HttpHeaders headers = new HttpHeaders(); |
| | | // headers.setContentType(MediaType.APPLICATION_JSON); |
| | | // HttpEntity requestEntity = new HttpEntity(map, headers); |
| | | // ResponseEntity<byte[]> rep = restTemplate.exchange(url, HttpMethod.POST, requestEntity, byte[].class); |
| | | // byte[] bytes = rep.getBody(); |
| | | ResponseEntity<byte[]> entity = restTemplate.exchange(url, HttpMethod.POST, requestEntity, byte[].class); |
| | | System.err.println("调用小程序生成微信永久小程序码URL接口返回结果:" + entity.getBody()); |
| | | byte[] result = entity.getBody(); |
| | | System.err.println(Base64.encodeBase64String(result)); |
| | | |
| | | inputStream = new ByteArrayInputStream(result); |
| | | String finalFileName = System.currentTimeMillis() + "" + new SecureRandom().nextInt(0x0400) + ".jpg"; |
| | | ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(result); |
| | | MultipartFile file = new MockMultipartFile(ContentType.APPLICATION_OCTET_STREAM.toString(), byteArrayInputStream); |
| | | String pictureName = OssUploadUtil.ossUploadCode(file,finalFileName); |
| | | System.err.println(pictureName); |
| | | userInfo.setCode(pictureName); |
| | | this.updateById(userInfo); |
| | | |
| | | } catch (Exception e) { |
| | | System.err.println("调用小程序生成微信永久小程序码URL接口异常" + e); |
| | | } finally { |
| | | if (inputStream != null) { |
| | | try { |
| | | inputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | if (outputStream != null) { |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | @Override |
| | | public String generateQrCodeTemp() { |
| | | |
| | | String accessToken = weChatUtil.getAccessToken(); |
| | | InputStream inputStream = null; |
| | | OutputStream outputStream = null; |
| | | try { |
| | | String url = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=" + accessToken; |
| | | Map<String, Object> param = new HashMap<>(); |
| | | // param.put("page", "pageA/houseDetail"); |
| | | // 用户id 用于分享 |
| | | param.put("path", "pages/home/home?uid=1userType=2"); |
| | | System.err.println("调用生成微信URL接口传参:" + param); |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headers.setContentType(MediaType.APPLICATION_JSON); |
| | | HttpEntity requestEntity = new HttpEntity(param, headers); |
| | | // HashMap<String, String> map = new HashMap<>(); |
| | | // map.put("path", path); |
| | | // HttpHeaders headers = new HttpHeaders(); |
| | | // headers.setContentType(MediaType.APPLICATION_JSON); |
| | | // HttpEntity requestEntity = new HttpEntity(map, headers); |
| | | // ResponseEntity<byte[]> rep = restTemplate.exchange(url, HttpMethod.POST, requestEntity, byte[].class); |
| | | // byte[] bytes = rep.getBody(); |
| | | ResponseEntity<byte[]> entity = restTemplate.exchange(url, HttpMethod.POST, requestEntity, byte[].class); |
| | | System.err.println("调用小程序生成微信永久小程序码URL接口返回结果:" + entity.getBody()); |
| | | byte[] result = entity.getBody(); |
| | | System.err.println(Base64.encodeBase64String(result)); |
| | | |
| | | inputStream = new ByteArrayInputStream(result); |
| | | String finalFileName = System.currentTimeMillis() + "" + new SecureRandom().nextInt(0x0400) + ".jpg"; |
| | | ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(result); |
| | | MultipartFile file = new MockMultipartFile(ContentType.APPLICATION_OCTET_STREAM.toString(), byteArrayInputStream); |
| | | String pictureName = OssUploadUtil.ossUploadCode(file,finalFileName); |
| | | System.err.println(pictureName); |
| | | return pictureName; |
| | | |
| | | } catch (Exception e) { |
| | | System.err.println("调用小程序生成微信永久小程序码URL接口异常" + e); |
| | | } finally { |
| | | if (inputStream != null) { |
| | | try { |
| | | inputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | if (outputStream != null) { |
| | | try { |
| | | outputStream.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | return ""; |
| | | } |
| | | /** |
| | | * 获取编号 |
| | | * @return |