|  |  |  | 
|---|
|  |  |  | package com.doumee.api.common; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.alibaba.fastjson.JSONObject; | 
|---|
|  |  |  | import com.alibaba.fastjson.TypeReference; | 
|---|
|  |  |  | import com.doumee.api.BaseController; | 
|---|
|  |  |  | import com.doumee.biz.system.SystemDictDataBiz; | 
|---|
|  |  |  | import com.doumee.core.annotation.excel.ExcelToPdfTool; | 
|---|
|  |  |  | import com.doumee.core.annotation.trace.Trace; | 
|---|
|  |  |  | import com.doumee.core.constants.ResponseStatus; | 
|---|
|  |  |  | import com.doumee.core.exception.BusinessException; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.doumee.service.business.InsuranceApplyService; | 
|---|
|  |  |  | import com.doumee.service.business.InterfaceLogService; | 
|---|
|  |  |  | import com.doumee.service.business.third.SignService; | 
|---|
|  |  |  | import com.jzq.common.bean.sign.NotifyDataReq; | 
|---|
|  |  |  | import com.jzq.common.bean.sign.NotifyReq; | 
|---|
|  |  |  | import io.swagger.annotations.Api; | 
|---|
|  |  |  | import io.swagger.annotations.ApiImplicitParam; | 
|---|
|  |  |  | 
|---|
|  |  |  | import org.apache.commons.lang3.StringUtils; | 
|---|
|  |  |  | import org.apache.shiro.authz.annotation.RequiresPermissions; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.PostMapping; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RequestBody; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RequestMapping; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.RestController; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  | import org.springframework.web.multipart.MultipartFile; | 
|---|
|  |  |  | import org.springframework.web.multipart.MultipartHttpServletRequest; | 
|---|
|  |  |  | import org.springframework.web.multipart.commons.CommonsMultipartResolver; | 
|---|
|  |  |  | 
|---|
|  |  |  | import java.io.File; | 
|---|
|  |  |  | import java.io.IOException; | 
|---|
|  |  |  | import java.io.PrintWriter; | 
|---|
|  |  |  | import java.lang.reflect.Field; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | private InsuranceApplyService insuranceApplyService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | public InterfaceLogService interfaceLogService = null; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation("君子签签约回调通知") | 
|---|
|  |  |  | @PostMapping("/signNotify") | 
|---|
|  |  |  | public ApiResponse updateStatus(@RequestBody NotifyReq request) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public void updateStatus(@RequestParam Map<String,String> req, HttpServletResponse response) { | 
|---|
|  |  |  | Map<String, Object> context = new HashMap<>(); | 
|---|
|  |  |  | context.put("success",true); | 
|---|
|  |  |  | InterfaceLog log=new InterfaceLog(); | 
|---|
|  |  |  | log.setType(1); | 
|---|
|  |  |  | log.setCreateDate(new Date()); | 
|---|
|  |  |  | log.setIsdeleted(0); | 
|---|
|  |  |  | log.setRequest(JSONObject.toJSONString(request)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | log.setRequest(JSONObject.toJSONString(req)); | 
|---|
|  |  |  | log.setName("君子签签约回调通知"); | 
|---|
|  |  |  | log.setUrl(systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.SIGN_DONE_NOTIFY_URL).getCode()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | String appKey = systemDictDataBiz.queryByCode(Constants.SIGN,Constants.SIGN_APPKEY).getCode(); | 
|---|
|  |  |  | String appSecret  = systemDictDataBiz.queryByCode(Constants.SIGN,Constants.SIGN_APPSECRET).getCode(); | 
|---|
|  |  |  | if(!StringUtils.equals(appKey,request.getAppkey())){ | 
|---|
|  |  |  | if(!StringUtils.equals(appKey,req.get("appkey"))){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"appkey不匹配"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String sign = DigestUtils.sha1Hex("data"+JSONObject.toJSONString(request.getData())+"method"+request.getMethod()+"version"+request.getVersion()+"timestamp"+request.getTimestamp() | 
|---|
|  |  |  | String sign = DigestUtils.sha1Hex("data"+ req.get("data")+"method"+req.get("method")+"version"+req.get("version")+"timestamp"+req.get("timestamp") | 
|---|
|  |  |  | +"appKey"+appKey+"appSecret"+appSecret); | 
|---|
|  |  |  | if(!StringUtils.equals(sign,request.getSign())){ | 
|---|
|  |  |  | if(!StringUtils.equals(sign,req.get("sign"))){ | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"验签不通过"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | insuranceApplyService.dealSignResult(request.getData()); | 
|---|
|  |  |  | NotifyDataReq data   = JSONObject.parseObject(req.get("data"), NotifyDataReq.class); | 
|---|
|  |  |  | String r =  insuranceApplyService.dealSignResult(data); | 
|---|
|  |  |  | log.setRepose(r); | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | log.setRepose("处理异常;"+e.getMessage()); | 
|---|
|  |  |  | context.put("success",false); | 
|---|
|  |  |  | context.put("msg","处理发生异常"); | 
|---|
|  |  |  | throw  e; | 
|---|
|  |  |  | }finally { | 
|---|
|  |  |  | interfaceLogService.create(log); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ApiResponse.success(null); | 
|---|
|  |  |  | writerJson(response, context); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "上传", notes = "上传", httpMethod = "POST", position = 6) | 
|---|
|  |  |  | 
|---|
|  |  |  | String tempFileName = nowDate + "/" + fileName; | 
|---|
|  |  |  | String key = folder + tempFileName;// 文件名 | 
|---|
|  |  |  | ALiYunUtil obs = new ALiYunUtil(endpoint,access_id, access_key); | 
|---|
|  |  |  | int type = 2; | 
|---|
|  |  |  | if(StringUtils.endsWith(key,".mp4")){ | 
|---|
|  |  |  | type =1; | 
|---|
|  |  |  | }else if(StringUtils.endsWith(key,".jpg") | 
|---|
|  |  |  | || StringUtils.endsWith(key,".JPG") | 
|---|
|  |  |  | || StringUtils.endsWith(key,".png") | 
|---|
|  |  |  | || StringUtils.endsWith(key,".PNG") | 
|---|
|  |  |  | || StringUtils.endsWith(key,".jpeg") | 
|---|
|  |  |  | || StringUtils.endsWith(key,".JPEG")){ | 
|---|
|  |  |  | type =0; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (obs.uploadOnlineObject(file.getInputStream(),bucketName, key,null)) { | 
|---|
|  |  |  | // 移动成功,返回文件名 | 
|---|
|  |  |  | // sendSuccessMessage(response, resourcePath+key); | 
|---|
|  |  |  | 
|---|
|  |  |  | JSONObject fileJSON = new JSONObject(); | 
|---|
|  |  |  | fileJSON.put("url", resourcePath + key); | 
|---|
|  |  |  | fileJSON.put("imgaddr", tempFileName); | 
|---|
|  |  |  | fileJSON.put("type", type); | 
|---|
|  |  |  | fileJSON.put("imgname", fileName); | 
|---|
|  |  |  | fileJSON.put("originname", originname); | 
|---|
|  |  |  | context.put("data",fileJSON); | 
|---|