Commit dc0adaec by 翁国栋

运营后台--

一键校验
parent 363ec83e
...@@ -7,6 +7,7 @@ import cn.timer.api.config.annotation.CurrentUser; ...@@ -7,6 +7,7 @@ import cn.timer.api.config.annotation.CurrentUser;
import cn.timer.api.config.annotation.UserBean; import cn.timer.api.config.annotation.UserBean;
import cn.timer.api.controller.insure.bean.ExcelBean; import cn.timer.api.controller.insure.bean.ExcelBean;
import cn.timer.api.controller.insure.enums.InsuranceEnum; import cn.timer.api.controller.insure.enums.InsuranceEnum;
import cn.timer.api.dao.insure.InsureLogMapper;
import cn.timer.api.dao.insure.InsurePolicyMapper; import cn.timer.api.dao.insure.InsurePolicyMapper;
import cn.timer.api.dao.insure.InsureUserMapper; import cn.timer.api.dao.insure.InsureUserMapper;
import cn.timer.api.dao.yggl.YgglMainEmpMapper; import cn.timer.api.dao.yggl.YgglMainEmpMapper;
...@@ -97,6 +98,9 @@ public class InsureContorll { ...@@ -97,6 +98,9 @@ public class InsureContorll {
@Autowired @Autowired
private InsurePolicyMapper insurePolicyMapper; private InsurePolicyMapper insurePolicyMapper;
@Autowired
private InsureLogMapper insureLogMapper;
/** /**
* 设置请求参数 * 设置请求参数
...@@ -223,106 +227,88 @@ public class InsureContorll { ...@@ -223,106 +227,88 @@ public class InsureContorll {
quotationsArry.add(quotations); quotationsArry.add(quotations);
bodyMap.put("quotations", quotationsArry); bodyMap.put("quotations", quotationsArry);
log.info(JSONObject.toJSONString(bodyMap)); log.info(JSONObject.toJSONString(bodyMap));
Map dataMap = requestAgent(bodyMap); String data = HttpUtils.sendPost(insuredUrl, setParams(JSONObject.toJSONString(bodyMap), appid, secret), bodyMap);
Map policyMap= Maps.newHashMap(); Map dataMap = JSONObject.parseObject(data, Map.class);
List<Map> batchMap = Lists.newArrayList();
if (dataMap != null) { if (dataMap != null) {
if(dataMap.get("errcode").toString().equals("suc")){ if ((dataMap.get("errcode").toString().equals("suc")) || (dataMap.get("errcode").toString().equals("e25"))) {
Object o = dataMap.get("data"); Map policyMap = Maps.newHashMap();
Map<String, Object> map = JSONObject.parseObject(JSONObject.toJSONString(o)); List<Map> batchMap = Lists.newArrayList();
policyMap = JSONObject.parseObject(JSONObject.toJSONString(map.get("policy")), Map.class); if (dataMap.get("errcode").toString().equals("suc")) {
batchMap = JSONObject.parseObject(JSONObject.toJSONString(policyMap.get("batch")), List.class); Object o = dataMap.get("data");
} Map<String, Object> map = JSONObject.parseObject(JSONObject.toJSONString(o));
List<YgglMainEmp> ygglMainEmpList = ygglMainEmpMapper.selectListByIds(insureDto.getUserIds()); policyMap = JSONObject.parseObject(JSONObject.toJSONString(map.get("policy")), Map.class);
insurePolicy = InsurePolicy.builder().build(); batchMap = JSONObject.parseObject(JSONObject.toJSONString(policyMap.get("batch")), List.class);
insurePolicy.setPolicyDateStart(dtf3.parse(insureDto.getPolicyDateStart()));
insurePolicy.setPolicyDateEnd(dtf3.parse(insureDto.getPolicyDateEnd()));
if(dataMap.get("errcode").toString().equals("suc")) {
insurePolicy.setPolicyNo(policyMap.get("policy_no").toString());
insurePolicy.setPolicyFile(policyMap.get("policy_file").toString());
insurePolicy.setKitUrl(policyMap.get("kit_url").toString());
}
insurePolicy.setType(2);/*年单或者月单*/
insurePolicy.setCurrency("5");
if(dataMap.get("errcode").toString().equals("suc")) {
insurePolicy.setStatus("1");
}else {
insurePolicy.setStatus("2");
}
insurePolicy.setOrgCode(qyzxEntInfoM.getId());
insurePolicy.setCreateTime(date);
insurePolicy.setUpdateTime(date);
insurePolicy.setSchemeName(insureProduct.getName());/*先写死*/
insurePolicy.setTotalPremium(String.valueOf(insureDto.getUserIds().length * price));
insurePolicy.setProductId(insureProduct.getId());
insurePolicy.insert();
InsureLog.builder().requestParam(JSONObject.toJSONString(setParams(JSONObject.toJSONString(bodyMap), appid, secret))).type(1)
.requestData(JSONObject.toJSONString(bodyMap)).createTime(new Date()).requestType(1).returnBody(JSONObject.toJSONString(dataMap)).requestPath(insuredUrl)
.returnCode(dataMap.get("errcode").toString()).returnMsg(dataMap.get("errmsg").toString()).policyId(insurePolicy.getId()).fileUrl(url).build().insert();
InsureUser insureUser;
for (YgglMainEmp y : ygglMainEmpList) {
insureUser = InsureUser.builder().build();
insureUser.setUserId(y.getId());
insureUser.setInsuredName(qyzxEntInfoM.getName());
insureUser.setPrice(price.toString());/*前端获取的保费*/
insureUser.setTransId("P_" + qyzxEntInfoM.getId() + "_" + dtf2.format(now));
insureUser.setPremium(String.valueOf(ygglMainEmpList.size() * price));
if(dataMap.get("errcode").toString().equals("suc")) {
insureUser.setBatchNo(batchMap.get(0).get("batch_no").toString());
insureUser.setPolicyNo(policyMap.get("policy_no").toString());
} }
insureUser.setBenefitBasicPlan(insureDto.getBenefitBasicPlan()); List<YgglMainEmp> ygglMainEmpList = ygglMainEmpMapper.selectListByIds(insureDto.getUserIds());
insureUser.setUserId(y.getId()); insurePolicy = InsurePolicy.builder().build();
insureUser.setOrgCode(y.getOrgCode()); insurePolicy.setPolicyDateStart(dtf3.parse(insureDto.getPolicyDateStart()));
insureUser.setBenefitOccupationCategory(insureDto.getBenefitOccupationCategory()); insurePolicy.setPolicyDateEnd(dtf3.parse(insureDto.getPolicyDateEnd()));
insureUser.setInsuredMobile(y.getPhone()); if (dataMap.get("errcode").toString().equals("suc")) {
insureUser.setInsuredNo(y.getZjNum()); insurePolicy.setPolicyNo(policyMap.get("policy_no").toString());
insureUser.setInsuredEContact(y.getName()); insurePolicy.setPolicyFile(policyMap.get("policy_file").toString());
insureUser.setApplicantEmployeeList(url); insurePolicy.setKitUrl(policyMap.get("kit_url").toString());
if(dataMap.get("errcode").toString().equals("suc")) {
insureUser.setInsureStatus(1);
insureUser.setStatus("1");
}else{
insureUser.setInsureStatus(2);
insureUser.setStatus("2");
} }
insureUser.setPolicyDateStart(dtf3.parse(insureDto.getPolicyDateStart())); insurePolicy.setType(2);/*年单或者月单*/
insureUser.setPolicyDateEnd(dtf3.parse(insureDto.getPolicyDateEnd())); insurePolicy.setCurrency("5");
if (dataMap.get("errcode").toString().equals("suc")) {
insureUser.setPolicyId(insurePolicy.getId()); insurePolicy.setStatus("1");
insureUser.setApplyType(1); } else {
insureUser.insert(); insurePolicy.setStatus("2");
if(dataMap.get("errcode").toString().equals("suc")) {
y.setIsInsure(1);
y.insertOrUpdate();
} }
} insurePolicy.setOrgCode(qyzxEntInfoM.getId());
return ResultUtil.error("投保成功"); insurePolicy.setCreateTime(date);
} insurePolicy.setUpdateTime(date);
return ResultUtil.error(dataMap.get("errmsg").toString()); insurePolicy.setSchemeName(insureProduct.getName());/*先写死*/
insurePolicy.setTotalPremium(String.valueOf(insureDto.getUserIds().length * price));
} insurePolicy.setProductId(insureProduct.getId());
insurePolicy.insert();
/*测试用生产环境不需要*/ InsureLog.builder().requestParam(JSONObject.toJSONString(setParams(JSONObject.toJSONString(bodyMap), appid, secret))).type(1)
synchronized private Map requestAgent(Map bodyMap) { .requestData(JSONObject.toJSONString(bodyMap)).createTime(new Date()).requestType(1).returnBody(JSONObject.toJSONString(dataMap)).requestPath(insuredUrl)
String data = HttpUtils.sendPost(insuredUrl, setParams(JSONObject.toJSONString(bodyMap), appid, secret), bodyMap); .returnCode(dataMap.get("errcode").toString()).returnMsg(dataMap.get("errmsg").toString()).policyId(insurePolicy.getId()).fileUrl(url).build().insert();
Map dataMap = JSONObject.parseObject(data, Map.class); InsureUser insureUser;
if (dataMap.get("errcode").toString().equals("suc")) { for (YgglMainEmp y : ygglMainEmpList) {
return dataMap; insureUser = InsureUser.builder().build();
} else { insureUser.setUserId(y.getId());
if (dataMap.get("errcode").toString().equals("e25") && (dataMap.get("errmsg").toString().equals("出单中"))) { insureUser.setInsuredName(qyzxEntInfoM.getName());
try { insureUser.setPrice(price.toString());/*前端获取的保费*/
Thread.sleep(30000); insureUser.setTransId("P_" + qyzxEntInfoM.getId() + "_" + dtf2.format(now));
return requestAgent(bodyMap); insureUser.setPremium(String.valueOf(ygglMainEmpList.size() * price));
} catch (InterruptedException e) { if (dataMap.get("errcode").toString().equals("suc")) {
e.printStackTrace(); insureUser.setBatchNo(batchMap.get(0).get("batch_no").toString());
insureUser.setPolicyNo(policyMap.get("policy_no").toString());
}
insureUser.setBenefitBasicPlan(insureDto.getBenefitBasicPlan());
insureUser.setUserId(y.getId());
insureUser.setOrgCode(y.getOrgCode());
insureUser.setBenefitOccupationCategory(insureDto.getBenefitOccupationCategory());
insureUser.setInsuredMobile(y.getPhone());
insureUser.setInsuredNo(y.getZjNum());
insureUser.setInsuredEContact(y.getName());
insureUser.setApplicantEmployeeList(url);
if (dataMap.get("errcode").toString().equals("suc")) {
insureUser.setInsureStatus(1);
insureUser.setStatus("1");
} else {
insureUser.setInsureStatus(3);
insureUser.setStatus("2");
}
insureUser.setPolicyDateStart(dtf3.parse(insureDto.getPolicyDateStart()));
insureUser.setPolicyDateEnd(dtf3.parse(insureDto.getPolicyDateEnd()));
insureUser.setPolicyId(insurePolicy.getId());
insureUser.setApplyType(2);//投保类型
insureUser.insert();
if (dataMap.get("errcode").toString().equals("suc")) {
y.setIsInsure(1);
y.insertOrUpdate();
}
} }
} }
return dataMap; return ResultUtil.success(dataMap.get("errmsg").toString());
} }
} return ResultUtil.error("网络异常");
}
/** /**
* 生成投保问文件 * 生成投保问文件
...@@ -801,4 +787,42 @@ public class InsureContorll { ...@@ -801,4 +787,42 @@ public class InsureContorll {
} }
return ResultUtil.success(); return ResultUtil.success();
} }
@GetMapping(value = "/verification")
@ApiOperation(value = "一键校验", httpMethod = "Post", notes = "一键校验")
public Result<Object> verification() {
List<InsurePolicy> insurePolicies = InsurePolicy.builder().build().selectList(new QueryWrapper<InsurePolicy>().lambda().eq(InsurePolicy::getStatus,2));
insurePolicies.forEach(i->{
InsureLog insureLog = InsureLog.builder().build().selectOne(new QueryWrapper<InsureLog>().lambda().eq(InsureLog::getPolicyId,i.getId()).eq(InsureLog::getType,1));
Map bodyMap = JSONObject.parseObject(insureLog.getRequestData(), Map.class);
String data = HttpUtils.sendPost(insuredUrl, setParams(JSONObject.toJSONString(bodyMap), appid, secret),bodyMap );
log.info("校验结果:{}",data);
Map dataMap = JSONObject.parseObject(data, Map.class);
if (dataMap != null) {
if ((dataMap.get("errcode").toString().equals("suc"))) {
Object o = dataMap.get("data");
Map<String, Object> map = JSONObject.parseObject(JSONObject.toJSONString(o));
Map policyMap = JSONObject.parseObject(JSONObject.toJSONString(map.get("policy")), Map.class);
i.setPolicyNo(policyMap.get("policy_no").toString());
i.setPolicyFile(policyMap.get("policy_file").toString());
i.setKitUrl(policyMap.get("kit_url").toString());
i.setStatus("1");
i.updateById();
/*批次信息*/
List<Map> batchMap = JSONObject.parseObject(JSONObject.toJSONString(policyMap.get("batch")), List.class);
List<InsureUser> insureUserList = InsureUser.builder().build().selectList(new QueryWrapper<InsureUser>().lambda().eq(InsureUser::getPolicyId,i.getId())
.eq(InsureUser::getType,2));
insureUserList.forEach(user->{
user.setBatchNo(batchMap.get(0).get("batch_no").toString());
user.setPolicyNo(policyMap.get("policy_no").toString());
user.setInsureStatus(1);
user.setStatus("1");
user.updateById();
YgglMainEmp.builder().isInsure(1).build().update(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getId, user.getUserId()));
});
}
}
});
return ResultUtil.success();
};
} }
...@@ -18,5 +18,6 @@ import java.util.List; ...@@ -18,5 +18,6 @@ import java.util.List;
@Repository @Repository
public interface InsureLogMapper extends BaseMapper<InsureLog> { public interface InsureLogMapper extends BaseMapper<InsureLog> {
List<InsureLog> selectListById(@Param("policyId")String policyId); List<InsureLog> selectListById(@Param("policyId")String policyId);
List<InsureLog> selectListByIds(@Param("array")Integer[] ids);
} }
...@@ -176,4 +176,12 @@ ...@@ -176,4 +176,12 @@
where policy_id = #{policyId} where policy_id = #{policyId}
ORDER BY create_time DESC ORDER BY create_time DESC
</select> </select>
<select id="selectListByIds" resultType="cn.timer.api.bean.insure.InsureLog">
select * from insure_log
where type = 1 and policy_id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</select>
</mapper> </mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment