Commit 902d8608 by 翁国栋

8小时运营后台--

投保人信息验证
企业列表信息验证
导入信息验证
导入人员信息验证
保单搜索列表更据企业名称查找
parent 09698502
package cn.timer.api.bean.insure;
import lombok.Data;
/**
* @Description TODO
* @Author wgd
* @Date 2022/5/30 11:01
*/
@Data
public class BatchPayCallBack {
private String order_import_uuid;
private String pay_status;
private String transaction_id;
private String pay_time;
private String pay_money;
private String method;
}
......@@ -4,22 +4,21 @@ import cn.timer.api.bean.htzz.HtzzAssoZztx;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.mysql.cj.util.StringUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.*;
import org.springframework.beans.factory.annotation.Value;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.NotEmpty;
import java.io.Serializable;
import java.util.Date;
/**
* 投保人
*
......@@ -49,6 +48,7 @@ public class InsureApplicant extends Model<InsureApplicant> {
* 企业/网点名称
*/
@ApiModelProperty(value = "企业/网点名称")
@NotEmpty
private String applicantEName;
/**
* 企业/网点地址
......@@ -132,7 +132,7 @@ public class InsureApplicant extends Model<InsureApplicant> {
private String applicantInvoicedAmount;
@ApiModelProperty(value = "企业id", example = "")
private Integer orgCode;
@ApiModelProperty(value="银行账号")
@ApiModelProperty(value = "银行账号")
private String applicantCorporateBankAccount;
/**
......@@ -148,198 +148,231 @@ public class InsureApplicant extends Model<InsureApplicant> {
public void setApplicantEName(String applicantEName) {
this.applicantEName = applicantEName;
}
/**
* 获取:企业/网点名称
*/
public String getApplicantEName() {
return applicantEName;
}
/**
* 设置:企业/网点地址
*/
public void setApplicantEAddress(String applicantEAddress) {
this.applicantEAddress = applicantEAddress;
}
/**
* 获取:企业/网点地址
*/
public String getApplicantEAddress() {
return applicantEAddress;
}
/**
* 设置:人员清单
*/
public void setApplicantEmployeeList(String applicantEmployeeList) {
this.applicantEmployeeList = applicantEmployeeList;
}
/**
* 获取:人员清单
*/
public String getApplicantEmployeeList() {
return applicantEmployeeList;
}
/**
* 设置:企业授权操作人姓名
*/
public void setApplicantEContacts(String applicantEContacts) {
this.applicantEContacts = applicantEContacts;
}
/**
* 获取:企业授权操作人姓名
*/
public String getApplicantEContacts() {
return applicantEContacts;
}
/**
* 设置:操作人的联系电话
*/
public void setApplicantEPhone(String applicantEPhone) {
this.applicantEPhone = applicantEPhone;
}
/**
* 获取:操作人的联系电话
*/
public String getApplicantEPhone() {
return applicantEPhone;
}
/**
* 设置:企业证件类型:3646、统一社会信用代码 3924、组织机构代码
*/
public void setApplicantENoType(String applicantENoType) {
this.applicantENoType = applicantENoType;
}
/**
* 获取:企业证件类型:3646、统一社会信用代码 3924、组织机构代码
*/
public String getApplicantENoType() {
return applicantENoType;
}
/**
* 设置:企业证件号码
*/
public void setApplicantENo(String applicantENo) {
this.applicantENo = applicantENo;
}
/**
* 获取:企业证件号码
*/
public String getApplicantENo() {
return applicantENo;
}
/**
* 设置:企业邮箱
*/
public void setApplicantEMail(String applicantEMail) {
this.applicantEMail = applicantEMail;
}
/**
* 获取:企业邮箱
*/
public String getApplicantEMail() {
return applicantEMail;
}
/**
* 设置:省市区
*/
public void setApplicantProvinceCity(String applicantProvinceCity) {
this.applicantProvinceCity = applicantProvinceCity;
}
/**
* 获取:省市区
*/
public String getApplicantProvinceCity() {
return applicantProvinceCity;
}
/**
* 设置:发票收件地址
*/
public void setApplicantInvoiceReceivingAddress(String applicantInvoiceReceivingAddress) {
this.applicantInvoiceReceivingAddress = applicantInvoiceReceivingAddress;
}
/**
* 获取:发票收件地址
*/
public String getApplicantInvoiceReceivingAddress() {
return applicantInvoiceReceivingAddress;
}
/**
* 设置:发票开票电话
*/
public void setApplicantInvoiceBillingPhone(String applicantInvoiceBillingPhone) {
this.applicantInvoiceBillingPhone = applicantInvoiceBillingPhone;
}
/**
* 获取:发票开票电话
*/
public String getApplicantInvoiceBillingPhone() {
return applicantInvoiceBillingPhone;
}
/**
* 设置:企业开户行名称
*/
public void setApplicantBusinessBankName(String applicantBusinessBankName) {
this.applicantBusinessBankName = applicantBusinessBankName;
}
/**
* 获取:企业开户行名称
*/
public String getApplicantBusinessBankName() {
return applicantBusinessBankName;
}
/**
* 设置:保单号
*/
public void setPolicyNo(String policyNo) {
this.policyNo = policyNo;
}
/**
* 获取:保单号
*/
public String getPolicyNo() {
return policyNo;
}
/**
* 设置:投保类型:1个人 2 企业
*/
public void setApplicantType(String applicantType) {
this.applicantType = applicantType;
}
/**
* 获取:投保类型:1个人 2 企业
*/
public String getApplicantType() {
return applicantType;
}
/**
* 设置:报价请求流水号
*/
public void setTransId(String transId) {
this.transId = transId;
}
/**
* 获取:报价请求流水号
*/
public String getTransId() {
return transId;
}
/**
* 设置:报价号
*/
public void setCurrency(String currency) {
this.currency = currency;
}
/**
* 获取:报价号
*/
public String getCurrency() {
return currency;
}
/**
* 设置:发票开票金额
*/
public void setApplicantInvoicedAmount(String applicantInvoicedAmount) {
this.applicantInvoicedAmount = applicantInvoicedAmount;
}
/**
* 获取:发票开票金额
*/
......@@ -354,4 +387,30 @@ public class InsureApplicant extends Model<InsureApplicant> {
public void setOrgCode(Integer orgCode) {
this.orgCode = orgCode;
}
/*验证必要字段*/
public String checkValiad() {
if (StringUtils.isNullOrEmpty(applicantEName)) {
return "企业/网点名称未设置";
}
if (StringUtils.isNullOrEmpty(applicantEAddress)) {
return "企业/网点地址未设置";
}
if (StringUtils.isNullOrEmpty(applicantEContacts)) {
return "企业授权操作人姓名未设置";
}
if (StringUtils.isNullOrEmpty(applicantEPhone)) {
return "操作人的联系电话未设置";
}
if (StringUtils.isNullOrEmpty(applicantENoType)) {
return "企业证件类型未设置";
}
if (StringUtils.isNullOrEmpty(applicantENo)) {
return "企业证件号码未设置";
}
if (StringUtils.isNullOrEmpty(applicantEMail)) {
return "企业邮箱未设置";
}
return "true";
}
}
......@@ -41,6 +41,7 @@ public class WebSecurityConfig implements WebMvcConfigurer {
.excludePathPatterns("/callBack/policy/payCallBack")
.excludePathPatterns("/callBack/policy/issueCallback")
.excludePathPatterns("/callBack/policy/addpPayCallBack")
.excludePathPatterns("/callBack/policy/batchPayCallback")
.excludePathPatterns("/superLogin/**")
.excludePathPatterns("/actuator/*")
.excludePathPatterns("/doc*")
......
......@@ -2,6 +2,7 @@ package cn.timer.api.controller.insure;
import cn.timer.api.bean.insure.*;
import cn.timer.api.bean.yggl.YgglMainEmp;
import cn.timer.api.config.exception.CustomException;
import cn.timer.api.utils.HttpUtils;
import cn.timer.api.utils.ResultUtil;
import com.alibaba.fastjson.JSONObject;
......@@ -64,31 +65,8 @@ public class CallBackContorll {
@Value("${pay_page}")
private String payPage;
private Map setParams(String sign, String appid, String secret) {
/*当前时间戳*/
long timestamp = System.currentTimeMillis() / 1000;
log.info("时间戳" + timestamp);
Map paramsMap = Maps.newHashMap();
paramsMap.put("pid", appid);
paramsMap.put("timestamp", String.valueOf(timestamp));
paramsMap.put("trace_id", appid + timestamp + new Random().nextInt((9999 - 100) + 1) + 10);
// paramsMap.put("sign",Md5.md5(appid+secret+timestamp+sign.trim()));
String value;
if (sign == null) {
value = appid + secret + timestamp;
} else {
value = appid + secret + timestamp + sign;
log.info("body参数======" + sign);
}
paramsMap.put("sign", DigestUtils.md5Hex(value));
log.info("params参数======" + JSONObject.toJSONString(paramsMap));
return paramsMap;
}
@PostMapping(value = "/insuredCallBack")
@ApiOperation(value = "6.投保申请回调", httpMethod = "POST", notes = "投保申请回调")
@ApiOperation(value = "6.投保核保回调-弃用", httpMethod = "POST", notes = "投保申请回调")
private Map insuredCallBack(HttpServletRequest request, @RequestParam String pid, @RequestParam String sign, @RequestParam String timestamp) throws IOException {
Map map = Maps.newHashMap();
map.put("status", "error");
......@@ -128,6 +106,7 @@ public class CallBackContorll {
if (!pid.equals(appidq)) {
return map;
}
try {
InputStream is = null;
is = request.getInputStream();
StringBuilder sb = new StringBuilder();
......@@ -135,19 +114,19 @@ public class CallBackContorll {
for (int n; (n = is.read(b)) != -1; ) {
sb.append(new String(b, 0, n));
}
String value = DigestUtils.md5Hex(appidq + secretq + timestamp + sb.toString());
String value = DigestUtils.md5Hex(pid + secretq + timestamp + sb.toString());
if (!value.equals(sign)) {
return map;
throw new CustomException("增员核保回调验签失败");
}
CallBack callBack = JSONObject.parseObject(sb.toString(), CallBack.class);
if(callBack.getCallback_type().equals("1")) {
if (callBack.getCallback_type().equals("1")) {
List<InsureUser> insureUserList = InsureUser.builder().build().selectList(new QueryWrapper<InsureUser>().lambda().eq(InsureUser::getTransId, callBack.getOrder_import_info().getThird_uuid()));
InsurePolicy insurePolicy = InsurePolicy.builder().id(insureUserList.get(0).getPolicyId()).build().selectById();
if(callBack.getStatus().equals("1")) {
if (callBack.getStatus().equals("1")) {
if (insureUserList.size() > 0) {
insurePolicy.setStatus("4");/*设置为支付状态*/
insurePolicy.setUpdateTime(new Date());
InsurePay insurePay= InsurePay.builder().payStatus(1).
InsurePay insurePay = InsurePay.builder().payStatus(1).
serialNumber(callBack.getOrder_import_info().getUuid()).policyId(insurePolicy.getId()).amount(Double.parseDouble(callBack.getOrder_import_info().getTotal_money())).build();
insurePay.insert();
insurePolicy.setPayId(insurePay.getId());
......@@ -157,10 +136,8 @@ public class CallBackContorll {
InsureLog.builder().type(7)
.requestData(sb.toString()).createTime(new Date()).requestType(1).returnBody(JSONObject.toJSONString(callBack)).requestPath(base_api_url + "/callBack/policy/addpPayCallBack")
.returnCode(callBack.getStatus()).returnMsg("核保通过").policyId(insurePolicy.getId()).build().insert();
}else{
insureUserList.stream().forEach(v->{
} else {
insureUserList.stream().forEach(v -> {
v.setStatus("2");
v.setInsureStatus(2);
v.updateById();
......@@ -168,7 +145,7 @@ public class CallBackContorll {
insurePolicy.setStatus("1");
insurePolicy.updateById();
List<Map> errMap = callBack.getOrder_import_info().getErr_list();
String errorMsg="";
String errorMsg = "";
if (errMap.size() > 0) {
for (int i = 0; i < errMap.size(); i++) {
errorMsg = errorMsg + ("姓名:" + errMap.get(i).get("name").toString() + ",错误:" + errMap.get(i).get("err_content").toString() + ',');
......@@ -182,10 +159,15 @@ public class CallBackContorll {
.returnCode(callBack.getStatus()).returnMsg(errorMsg).policyId(insurePolicy.getId()).build().insert();
}
}
} catch (Exception e) {
e.printStackTrace();
throw new CustomException("增员核保回调异常");
} finally {
Map trueMap = Maps.newHashMap();
trueMap.put("status", "1");
return trueMap;
}
}
@PostMapping(value = "/CallBack")
@ApiOperation(value = "7.保全增员申请回调", httpMethod = "POST", notes = "投保申请回调")
......@@ -199,6 +181,7 @@ public class CallBackContorll {
if (!pid.equals(appidq)) {
return map;
}
try {
InputStream is = null;
is = request.getInputStream();
StringBuilder sb = new StringBuilder();
......@@ -206,20 +189,21 @@ public class CallBackContorll {
for (int n; (n = is.read(b)) != -1; ) {
sb.append(new String(b, 0, n));
}
String value = DigestUtils.md5Hex(appidq + secretq + timestamp + sb.toString());
String value = DigestUtils.md5Hex(pid + secretq + timestamp + sb.toString());
if (!value.equals(sign)) {
return map;
throw new CustomException("保全增员申请回调验签失败");
}
Map paramsMap = Maps.newHashMap();
paramsMap.put("pid", pid);
paramsMap.put("timestamp", timestamp);
paramsMap.put("sign", sign);
CallBack callBack = JSONObject.parseObject(sb.toString(), CallBack.class);
log.info("callBack=====" + sb.toString());
if (callBack.getStatus().equals("1")) {
List<InsureUser> list = InsureUser.builder().build().selectList(new QueryWrapper<InsureUser>().lambda().eq(InsureUser::getBatchNo, callBack.getOrder_import_info().getUuid()).eq(InsureUser::getInsureStatus, 3));
InsurePolicy insurePolicy = InsurePolicy.builder().build().selectOne(new QueryWrapper<InsurePolicy>().lambda().eq(InsurePolicy::getPolicyNo, list.get(0).getPolicyNo()));
if (callBack.getStatus().equals("1")) {
list.forEach(i -> {
i.setInsureStatus(1);
i.setStatus("1");
i.updateById();
YgglMainEmp.builder().isInsure(1).build().update(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getId, i.getUserId()));
});
......@@ -232,20 +216,17 @@ public class CallBackContorll {
YgglMainEmp.builder().isInsure(0).build().update(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getId, i.getUserId()));
});
}
InsurePolicy insurePolicy = InsurePolicy.builder().build().selectOne(new QueryWrapper<InsurePolicy>().lambda().eq(InsurePolicy::getPolicyNo, list.get(0).getPolicyNo()));
if (oldlist == null || oldlist.size() == 0) {
insurePolicy.setTotalPremium(String.valueOf(Double.valueOf(insurePolicy.getTotalPremium()) + Double.valueOf(callBack.getOrder_import_info().getTotal_money())));
}
insurePolicy.setPolicyFile(callBack.getOrder_import_info().getEndorsement_file());
insurePolicy.setUpdateTime(new Date());
insurePolicy.setStatus("1");
insurePolicy.updateById();
InsureLog.builder().requestParam(JSONObject.toJSONString(paramsMap)).type(7)
.requestData(sb.toString()).createTime(new Date()).requestType(1).returnBody(JSONObject.toJSONString(callBack)).requestPath(base_api_url + "/callBack/policy/CallBack")
.returnCode(callBack.getStatus()).returnMsg("更新成功").policyId(insurePolicy.getId()).build().insert();
} else {
String errorMsg = "";
InsureLog insureLog = InsureLog.builder().build().selectOne(new QueryWrapper<InsureLog>().lambda().eq(InsureLog::getTransId, callBack.getOrder_import_info().getThird_uuid()));
if(callBack.getOrder_import_info().getErr_list()!=null) {
List<Map> errMap = callBack.getOrder_import_info().getErr_list();
if (errMap.size() > 0) {
for (int i = 0; i < errMap.size(); i++) {
......@@ -254,37 +235,56 @@ public class CallBackContorll {
} else {
errorMsg = callBack.getErr_msg();
}
}
/*在保司系统点击取消申报时候会回调申报失败*/
if(StringUtils.isNullOrEmpty(callBack.getOrder_import_info().getSingle_serial_no())){
list.forEach(i -> {
i.setInsureStatus(2);
i.setStatus("2");
i.updateById();
YgglMainEmp.builder().isInsure(0).build().update(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getId, i.getUserId()));
});
}
//TODO 写入日志
InsureLog.builder().requestParam(JSONObject.toJSONString(paramsMap)).type(7)
.requestData(sb.toString()).createTime(new Date()).requestType(1).returnBody(JSONObject.toJSONString(callBack)).requestPath(base_api_url + "/callBack/policy/CallBack")
.returnCode(callBack.getStatus()).returnMsg(errorMsg).policyId(insureLog.getPolicyId()).build().insert();
.returnCode(callBack.getStatus()).returnMsg(errorMsg).policyId(insurePolicy.getId()).build().insert();
}
/*无论此次申请成功还是失败这笔单都需要重新申报*/
insurePolicy.setUpdateTime(new Date());
insurePolicy.setStatus("1");
insurePolicy.updateById();
} catch (Exception e) {
e.printStackTrace();
throw new CustomException("保全增员申请回调异常");
} finally {
Map trueMap = Maps.newHashMap();
trueMap.put("status", "1");
return trueMap;
}
}
@GetMapping(value = "/payStatus")
@ApiOperation(value = "8.支付完成跳转", httpMethod = "GET", notes = "用于支付时跳回我们系统更新状态")
private ModelAndView callBackPayStatus(HttpServletRequest request, @RequestParam Integer policyId) throws IOException {
log.info("支付完成回调(仅代表用户点了已支付,无法确认是否真正支付)");
InsurePolicy insurePolicy = InsurePolicy.builder().id(policyId).build().selectById();
InsurePay insurePay = InsurePay.builder().id(insurePolicy.getPayId()).build().selectById();
insurePay.setPayTime(new Date());
insurePay.updateById();
InsureLog.builder().type(7).createTime(new Date()).requestType(2).requestPath(base_api_url + "/payStatus?policyId=" + policyId)
.returnCode("suc").returnMsg("用户已支付"+insurePay.getAmount()+"元,等待更新保单状态").policyId(policyId).build().insert();
InsureLog.builder().type(7).createTime(new Date()).requestType(2).requestPath(base_api_url + "/callBack/policy/payStatus?policyId=" + policyId)
.returnCode("suc").returnMsg("用户已支付" + insurePay.getAmount() + "元,等待更新保单状态").policyId(policyId).build().insert();
ModelAndView mav = new ModelAndView();
mav.setViewName("redirect:"+payPage+"/#/payPage");
mav.setViewName("redirect:" + payPage + "/#/payPage?amount="+insurePay.getAmount());
return mav;
}
@PostMapping(value = "/payCallBack")
@ApiOperation(value = "9.投保支付收银台回调", httpMethod = "POST", notes = "支付完成跳转")
private Map payCallBack(HttpServletRequest request, @RequestParam String pid, @RequestParam String sign, @RequestParam String timestamp) throws IOException {
log.info("支付回调");
Map map = Maps.newHashMap();
try {
InputStream is = null;
is = request.getInputStream();
StringBuilder sb = new StringBuilder();
......@@ -292,14 +292,10 @@ public class CallBackContorll {
for (int n; (n = is.read(b)) != -1; ) {
sb.append(new String(b, 0, n));
}
String value = DigestUtils.md5Hex(appid + secret + timestamp + sb.toString());
String value = DigestUtils.md5Hex(pid + secret + timestamp + sb.toString());
if (!value.equals(sign)) {
return map;
throw new CustomException("投保支付收银台回调验签失败");
}
Map paramsMap = Maps.newHashMap();
paramsMap.put("pid", pid);
paramsMap.put("timestamp", timestamp);
paramsMap.put("sign", sign);
PayCallBack callBack = JSONObject.parseObject(sb.toString(), PayCallBack.class);
InsurePay insurePay = InsurePay.builder().build().selectOne(new QueryWrapper<InsurePay>().lambda().eq(InsurePay::getSerialNumber, callBack.getSerial_number()));
insurePay.setAmount(Double.valueOf(callBack.getAmount()));
......@@ -308,39 +304,43 @@ public class CallBackContorll {
insurePay.setSerialNumber(callBack.getSerial_number());
insurePay.setPayType(callBack.getPay_type());
insurePay.updateById();
InsureLog.builder().type(7).createTime(new Date()).requestType(1).requestPath(base_api_url + "/callBack/policy/payCallBack")
.returnCode("suc").returnMsg("确认支付成功,支付方式:" + insurePay.getPayType() + ",支付金额:" + callBack.getAmount()).policyId(insurePay.getPolicyId()).build().insert();
/*调用出单接口更新保单状态*/
Map paramsMap = Maps.newHashMap();
paramsMap.put("pid", pid);
paramsMap.put("timestamp", timestamp);
paramsMap.put("sign", sign);
Map bodyMap = Maps.newHashMap();
bodyMap.put("quotation_id", callBack.getSerial_number());
String data = HttpUtils.sendPost(getPolicyUrl, setParams(JSONObject.toJSONString(bodyMap), appid, secret), bodyMap);
String data = HttpUtils.sendPost(getPolicyUrl, InsureContorll.setParams(JSONObject.toJSONString(bodyMap), appid, secret), bodyMap);
Map dataMap = JSONObject.parseObject(data, Map.class);
if (dataMap.size() > 0) {
if (dataMap.get("errcode").toString().equals("e25")) {
if (dataMap.get("errcode").toString().equals("suc") || dataMap.get("errcode").toString().equals("e25")) {
//TODO 如果是E25则将保单设为出单中,更新交由保单出单回调做,设为出单状态是因为之后可以手动校验
InsurePolicy insurePolicy = InsurePolicy.builder().id(insurePay.getPolicyId()).build().selectById();
insurePolicy.setStatus("2");
insurePolicy.setUpdateTime(new Date());
insurePolicy.updateById();
InsureLog.builder().type(7).createTime(new Date()).requestType(1).requestPath(base_api_url + "/payCallBack")
.returnCode("suc").returnMsg(dataMap.get("errmsg").toString()).build().insert();
} else if (dataMap.get("errcode").toString().equals("suc")) {
InsureLog.builder().type(7).createTime(new Date()).requestType(1).requestPath(base_api_url + "/payCallBack")
.returnCode("suc").returnMsg("确认支付成功,支付方式:" + insurePay.getPayType() + ",支付金额:" + callBack.getAmount()).policyId(insurePay.getPolicyId()).build().insert();
} else {
InsureLog.builder().requestParam(JSONObject.toJSONString(setParams(JSONObject.toJSONString(bodyMap), appid, secret))).type(7)
}
InsureLog.builder().requestParam(JSONObject.toJSONString(InsureContorll.setParams(JSONObject.toJSONString(bodyMap), appid, secret))).type(7)
.requestData(JSONObject.toJSONString(bodyMap)).createTime(new Date()).requestType(1).returnBody(data).requestPath(getPolicyUrl)
.returnCode(dataMap.get("errcode").toString()).policyId(insurePay.getPolicyId()).returnMsg(dataMap.get("errmsg").toString()).build().insert();
}
}
} catch (Exception e) {
e.printStackTrace();
throw new CustomException("投保支付收银台回调异常");
} finally {
Map map = Maps.newHashMap();
map.put("status", "1");
return map;
}
}
@PostMapping(value = "/issueCallback")
@ApiOperation(value = "10.保单出单回调", httpMethod = "POST", notes = "支付完成跳转")
private Map issueCallback(HttpServletRequest request, @RequestParam String pid, @RequestParam String sign, @RequestParam String timestamp) throws IOException {
log.info("保单出单回调");
Map map = Maps.newHashMap();
map.put("status", "1");
try {
InputStream is = null;
is = request.getInputStream();
StringBuilder sb = new StringBuilder();
......@@ -348,9 +348,9 @@ public class CallBackContorll {
for (int n; (n = is.read(b)) != -1; ) {
sb.append(new String(b, 0, n));
}
String value = DigestUtils.md5Hex(appid + secret + timestamp + sb.toString());
String value = DigestUtils.md5Hex(pid + secret + timestamp + sb.toString());
if (!value.equals(sign)) {
return map;
throw new CustomException("保单出单回调验签失败");
}
PolicyCallBack callBack = JSONObject.parseObject(sb.toString(), PolicyCallBack.class);
InsurePay insurePay = InsurePay.builder().build().selectOne(new QueryWrapper<InsurePay>().lambda().eq(InsurePay::getSerialNumber, callBack.getSerial_number()));
......@@ -382,6 +382,45 @@ public class CallBackContorll {
insurePay.updateById();
InsureLog.builder().type(7).createTime(new Date()).requestType(1).returnBody(sb.toString()).requestPath(getPolicyUrl)
.returnCode(callBack.getStatus()).policyId(insurePay.getPolicyId()).returnMsg(callBack.getErr_msg()).build().insert();
} catch (Exception e) {
e.printStackTrace();
throw new CustomException("保单出单回调");
} finally {
Map map = Maps.newHashMap();
map.put("status", "1");
return map;
}
}
@PostMapping(value = "/batchPayCallback")
@ApiOperation(value = "增员支付回调-保司接口没启用", httpMethod = "POST", notes = "增员支付回调")
private Map batchPayCallback(HttpServletRequest request) throws IOException {
try {
InputStream is = null;
is = request.getInputStream();
StringBuilder sb = new StringBuilder();
byte[] b = new byte[4096];
for (int n; (n = is.read(b)) != -1; ) {
sb.append(new String(b, 0, n));
}
BatchPayCallBack callBack = JSONObject.parseObject(sb.toString(), BatchPayCallBack.class);
InsurePay insurePay = InsurePay.builder().build().selectOne(new QueryWrapper<InsurePay>().lambda().eq(InsurePay::getSerialNumber, callBack.getOrder_import_uuid()));
if (insurePay != null) {
insurePay.setPayStatus(Integer.parseInt(callBack.getPay_status()));
insurePay.setAmount(Double.parseDouble(callBack.getPay_money()));
insurePay.setPayType(callBack.getMethod());
insurePay.updateById();
}
InsureLog.builder().type(7).createTime(new Date()).requestType(1).returnBody(sb.toString()).requestPath(base_api_url + "/callBack/policy/batchPayCallback")
.returnCode(callBack.getPay_status()).policyId(insurePay.getPolicyId()).returnMsg("确认支付成功,支付方式:" + insurePay.getPayType() + ",支付金额:" + insurePay.getAmount()).build().insert();
} catch (Exception e) {
e.printStackTrace();
throw new CustomException("增员支付回调异常");
} finally {
Map map = Maps.newHashMap();
map.put("status", "1");
return map;
}
}
}
......@@ -9,6 +9,7 @@ import cn.timer.api.bean.insure.InsureApplicant;
import cn.timer.api.bean.qyzx.QyzxEntInfoM;
import cn.timer.api.config.annotation.CurrentUser;
import cn.timer.api.config.annotation.UserBean;
import cn.timer.api.config.exception.CustomException;
import cn.timer.api.dao.insure.InsureApplicantMapper;
import cn.timer.api.dto.insure.InsureDto;
import cn.timer.api.utils.HttpUtils;
......@@ -49,32 +50,42 @@ public class InsureApplicantController {
@PostMapping("/insureApplicationSetting")
@ApiOperation(value = "设置投保人", httpMethod = "POST", notes = "投保申请")
private Result<Object> insureApplicationSetting(@RequestBody InsureApplicant params) {
InsureApplicant insureApplicant = InsureApplicant.builder().build().selectOne(new QueryWrapper<InsureApplicant>().lambda().eq(InsureApplicant::getOrgCode,params.getOrgCode()));
try {
InsureApplicant insureApplicant = InsureApplicant.builder().build().selectOne(new QueryWrapper<InsureApplicant>().lambda().eq(InsureApplicant::getOrgCode, params.getOrgCode()));
params.setId(insureApplicant.getId());
params.updateById();
return ResultUtil.data(params);
} catch (Exception e) {
e.printStackTrace();
throw new CustomException("设置投保人异常");
}
}
@GetMapping("/getApplicantAdmin")
@ApiOperation(value = "获取投保人--运营后台", httpMethod = "GET", notes = "获取投保人")
private Result<Object> getApplicant(@RequestParam("orgCode") Integer orgCode) {
InsureApplicant insureApplicant = InsureApplicant.builder().build().selectOne(new QueryWrapper<InsureApplicant>().lambda().eq(InsureApplicant::getOrgCode,orgCode));
if(insureApplicant==null){
QyzxEntInfoM qyzxEntInfoM=QyzxEntInfoM.builder().id(orgCode).build().selectById();
try {
InsureApplicant insureApplicant = InsureApplicant.builder().build().selectOne(new QueryWrapper<InsureApplicant>().lambda().eq(InsureApplicant::getOrgCode, orgCode));
if (insureApplicant == null) {
QyzxEntInfoM qyzxEntInfoM = QyzxEntInfoM.builder().id(orgCode).build().selectById();
insureApplicant = getInsureApplicant(qyzxEntInfoM);
insureApplicant.setOrgCode(orgCode);
insureApplicant.insert();
}
return ResultUtil.data(insureApplicant);
} catch (Exception e) {
e.printStackTrace();
throw new CustomException("获取投保人异常");
}
}
private InsureApplicant getInsureApplicant(QyzxEntInfoM qyzxEntInfoM) {
InsureApplicant insureApplicant;
insureApplicant=new InsureApplicant();
insureApplicant = new InsureApplicant();
insureApplicant.setApplicantEName(qyzxEntInfoM.getName());
insureApplicant.setApplicantEAddress(qyzxEntInfoM.getWorkAddress());
insureApplicant.setApplicantEContacts(qyzxEntInfoM.getOperName());/*这里为避免联系人为空,默认使用法人*/
insureApplicant.setApplicantEContacts(qyzxEntInfoM.getLinkMan());
insureApplicant.setApplicantEPhone(qyzxEntInfoM.getPhone());/*这里为避免联系人为空,默认使用法人*/
insureApplicant.setApplicantType("2");
insureApplicant.setApplicantENoType("3646");
......@@ -86,14 +97,19 @@ public class InsureApplicantController {
@GetMapping("/getApplicant")
@ApiOperation(value = "获取投保人--8小时", httpMethod = "GET", notes = "获取投保人")
private Result<Object> getApplicant(@CurrentUser UserBean userBean) {
InsureApplicant insureApplicant = InsureApplicant.builder().build().selectOne(new QueryWrapper<InsureApplicant>().lambda().eq(InsureApplicant::getOrgCode,userBean.getOrgCode()));
if(insureApplicant==null){
QyzxEntInfoM qyzxEntInfoM=QyzxEntInfoM.builder().id(userBean.getOrgCode()).build().selectById();
try {
InsureApplicant insureApplicant = InsureApplicant.builder().build().selectOne(new QueryWrapper<InsureApplicant>().lambda().eq(InsureApplicant::getOrgCode, userBean.getOrgCode()));
if (insureApplicant == null) {
QyzxEntInfoM qyzxEntInfoM = QyzxEntInfoM.builder().id(userBean.getOrgCode()).build().selectById();
insureApplicant = getInsureApplicant(qyzxEntInfoM);
insureApplicant.setOrgCode(userBean.getOrgCode());
insureApplicant.insert();
}
return ResultUtil.data(insureApplicant);
} catch (Exception e) {
e.printStackTrace();
throw new CustomException("获取投保人异常");
}
}
}
......@@ -6,6 +6,8 @@ import cn.timer.api.bean.qyzx.QyzxEntInfoM;
import cn.timer.api.bean.yggl.YgglMainEmp;
import cn.timer.api.config.annotation.CurrentUser;
import cn.timer.api.config.annotation.UserBean;
import cn.timer.api.config.enums.Regular;
import cn.timer.api.config.exception.CustomException;
import cn.timer.api.controller.insure.enums.PlanEnum;
import cn.timer.api.dao.insure.InsureLogMapper;
import cn.timer.api.dao.insure.InsurePolicyMapper;
......@@ -18,12 +20,12 @@ import cn.timer.api.dto.insure.PolicyDto;
import cn.timer.api.dto.spmk.User;
import cn.timer.api.utils.*;
import com.alibaba.druid.util.Base64;
import com.aliyun.oss.common.utils.StringUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.beust.jcommander.internal.Lists;
import com.google.common.base.Strings;
import com.google.common.collect.Maps;
import com.google.gson.JsonObject;
import com.mysql.cj.util.StringUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
......@@ -44,6 +46,7 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.*;
import java.lang.reflect.Field;
import java.net.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
......@@ -131,7 +134,7 @@ public class InsureContorll {
* @param sign
* @return
*/
private Map setParams(String sign, String appid, String secret) {
protected static Map setParams(String sign, String appid, String secret) {
/*当前时间戳*/
long timestamp = System.currentTimeMillis() / 1000;
log.info("时间戳" + timestamp);
......@@ -154,12 +157,16 @@ public class InsureContorll {
@PostMapping(value = "/insured_add")
@ApiOperation(value = "1.投保申请", httpMethod = "POST", notes = "投保申请")
public Result<Object> insured_add(@RequestBody InsureDto insureDto) throws ParseException, URISyntaxException {
public Result<Object> insured_add(@RequestBody InsureDto insureDto){
InsureProduct insureProduct = InsureProduct.builder().id(Integer.parseInt(insureDto.getProductId())).build().selectById();
if (insureProduct == null) {
return ResultUtil.error("产品不存在");
}
QyzxEntInfoM qyzxEntInfoM = QyzxEntInfoM.builder().id(Integer.parseInt(insureDto.getOrgCode())).build().selectById(); // 企业信息
if (qyzxEntInfoM == null) {
return ResultUtil.error("企业不存在");
}
try {
DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
LocalDateTime now = LocalDateTime.now();
Date date = Date.from(now.atZone(ZoneId.systemDefault()).toInstant());
......@@ -168,6 +175,9 @@ public class InsureContorll {
bodyMap.put("is_ss", 0);
bodyMap.put("quotations_method", "1");
Map quotations = Maps.newHashMap();
if(insureDto.getPlans().size()<=0){
return ResultUtil.error("请选择计划和职业类别");
}
insureDto.getPlans().forEach(i -> {
i.setPrice(getPrice(i.getBenefitBasicPlan(), i.getBenefitOccupationCategory()));
insureDto.setTotalPrice(i.getPrice() * i.getUserIds().length + (insureDto.getTotalPrice() == null ? 0 : insureDto.getTotalPrice()));
......@@ -185,7 +195,7 @@ public class InsureContorll {
quotations.put("operator_name", "");//*币种:5人民币
if (insureProduct.getPayType() == 1) {
quotations.put("required_pay", 1);
quotations.put("callback_policy",base_api_url+"/callBack/policy/issueCallback");
quotations.put("callback_policy", base_api_url + "/callBack/policy/issueCallback");
}
/*企业信息*/
......@@ -194,6 +204,10 @@ public class InsureContorll {
return ResultUtil.error("未设置投保人");
}
Map companyApplicantMap = Maps.newHashMap();
if(!insureApplicant.checkValiad().equals("true")){
return ResultUtil.error(insureApplicant.checkValiad());
}
/*必要字段,空值影响到投保的成功*/
companyApplicantMap.put("applicant_e_name", insureApplicant.getApplicantEName());/*企业/网点名称*/
companyApplicantMap.put("applicant_e_address", insureApplicant.getApplicantEAddress());/*企业/网点地址*/
companyApplicantMap.put("applicant_e_contacts", insureApplicant.getApplicantEContacts());/*企业授权操作人姓名*/
......@@ -202,6 +216,16 @@ public class InsureContorll {
companyApplicantMap.put("applicant_e_no", insureApplicant.getApplicantENo());/*企业证件号码*/
companyApplicantMap.put("applicant_e_mail", insureApplicant.getApplicantEMail());/*企业邮箱*/
companyApplicantMap.put("applicant_province_city", "21024");/*省市区*/
/*非必要字段*/
companyApplicantMap.put("applicant_invoice_receiving_address", StringUtils.isNullOrEmpty(insureApplicant.getApplicantInvoiceReceivingAddress())?"":insureApplicant.getApplicantInvoiceReceivingAddress());
companyApplicantMap.put("applicant_invoice_billing_phone",StringUtils.isNullOrEmpty(insureApplicant.getApplicantInvoiceBillingPhone())?"":insureApplicant.getApplicantInvoiceBillingPhone());
companyApplicantMap.put("applicant_invoiced_amount",StringUtils.isNullOrEmpty(insureApplicant.getApplicantInvoicedAmount())?"":insureApplicant.getApplicantInvoicedAmount());
companyApplicantMap.put("applicant_corporate_bank_account",StringUtils.isNullOrEmpty(insureApplicant.getApplicantCorporateBankAccount())?"":insureApplicant.getApplicantCorporateBankAccount());
companyApplicantMap.put("applicant_business_bank_name",StringUtils.isNullOrEmpty(insureApplicant.getApplicantBusinessBankName())?"":insureApplicant.getApplicantBusinessBankName());
/*人员清单填被保人员*/
String url = creaXSSFWorkbook(insureDto.getPlans(), insureDto.getPolicyDateStart());
if (!StringUtil.isNotBlank(url)) {
......@@ -240,11 +264,11 @@ public class InsureContorll {
insured.put("insured_applicant_relations", "36960");
insured.put("insured_mobile", insureApplicant.getApplicantEPhone());
insured.put("insured_e_contact", insureApplicant.getApplicantEContacts());
insured.put("insured_name", qyzxEntInfoM.getName());
insured.put("insured_name", StringUtils.isNullOrEmpty(qyzxEntInfoM.getAttestName())?qyzxEntInfoM.getName():qyzxEntInfoM.getAttestName());
insured.put("insured_no_type", "3306");
insured.put("insured_no", qyzxEntInfoM.getCreditCode());
insured.put("insured_no", StringUtils.isNullOrEmpty(qyzxEntInfoM.getCreditCode())?insureApplicant.getApplicantENo():qyzxEntInfoM.getCreditCode());
insured.put("insured_zm_openid", "");
insured.put("benefit_basic_plan", p.getBenefitBasicPlan());/*基础计划写死*/
insured.put("benefit_basic_plan", p.getBenefitBasicPlan());
insured.put("benefit_occupation_category", p.getBenefitOccupationCategory());
insured.put("benefit_EL_employee_number_t", p.getUserIds().length);
insuredArray.add(insured);
......@@ -269,7 +293,7 @@ public class InsureContorll {
insurePolicy.setType(2);/*年单或者月单*/
insurePolicy.setCurrency("5");
if (dataMap.get("errcode").toString().equals("suc")) {
if(insureProduct.getPayType()!=1) {
if (insureProduct.getPayType() != 1) {
Object o = dataMap.get("data");
Map<String, Object> map = JSONObject.parseObject(JSONObject.toJSONString(o));
policyMap = JSONObject.parseObject(JSONObject.toJSONString(map.get("policy")), Map.class);
......@@ -278,7 +302,7 @@ public class InsureContorll {
insurePolicy.setPolicyFile(policyMap.get("policy_file").toString());
insurePolicy.setKitUrl(policyMap.get("kit_url").toString());
insurePolicy.setStatus("1");
}else{
} else {
insurePolicy.setStatus("4");
}
} else {
......@@ -305,12 +329,12 @@ public class InsureContorll {
insureUser.setTransId("P_" + qyzxEntInfoM.getId() + "_" + dtf2.format(now));
insureUser.setPremium(String.valueOf(insureDto.getTotalPrice()));
if (dataMap.get("errcode").toString().equals("suc")) {
if(insureProduct.getPayType()!=1) {
if (insureProduct.getPayType() != 1) {
insureUser.setBatchNo(batchMap.get(0).get("batch_no").toString());
insureUser.setPolicyNo(policyMap.get("policy_no").toString());
insureUser.setInsureStatus(1);
insureUser.setStatus("1");
}else{
} else {
insureUser.setInsureStatus(3);
insureUser.setStatus("2");
}
......@@ -340,7 +364,7 @@ public class InsureContorll {
}
}
/*进入在线支付*/
if (insureProduct.getPayType()==1) {
if (insureProduct.getPayType() == 1) {
Object o = dataMap.get("data");
Map<String, Object> map = JSONObject.parseObject(JSONObject.toJSONString(o));
List<Map> quotationsMap = JSONObject.parseObject(JSONObject.toJSONString(map.get("quotations")), List.class);
......@@ -348,7 +372,7 @@ public class InsureContorll {
/*请求收银台*/
Map<String, String> toPayParamsMap = setParams(null, appid, secret);
toPayParamsMap.put("serial_number", quotationsMap.get(0).get("serial_number").toString());
toPayParamsMap.put("jump_url", base_api_url +"/callBack/policy/payStatus?policyId="+insurePolicy.getId());
toPayParamsMap.put("jump_url", base_api_url + "/callBack/policy/payStatus?policyId=" + insurePolicy.getId());
toPayParamsMap.put("pay_type", "1");
toPayParamsMap.put("notify_url", base_api_url + "/callBack/policy/payCallBack");
/*生成一个支付链接返回到前台*/
......@@ -358,14 +382,14 @@ public class InsureContorll {
builder.addParameter(key, toPayParamsMap.get(key));
}
}
InsurePay insurePay= InsurePay.builder().payStatus(1).
InsurePay insurePay = InsurePay.builder().payStatus(1).
serialNumber(quotationsMap.get(0).get("serial_number").toString()).policyId(insurePolicy.getId()).build();
insurePay.insert();
insurePolicy.setPayId(insurePay.getId());
insurePolicy.updateById();
Map returnMap = Maps.newHashMap();
returnMap.put("url",builder.build());
returnMap.put("id",insurePay.getId());
returnMap.put("url", builder.build());
returnMap.put("id", insurePay.getId());
return ResultUtil.data(returnMap);
}
}
......@@ -373,102 +397,13 @@ public class InsureContorll {
}
return ResultUtil.error(dataMap.get("errmsg").toString());
}
return ResultUtil.error("网络异常");
}
/**
* 生成投保文件
*
* @param ids
* @return
*/
public String creaXSSFWorkbook(List<PlansDto> plansList, String createDate) {
if (plansList.size() <= 0) {
return "error";
}
LocalDate localDate = LocalDate.now();
Date date = new Date();
List list = Lists.newArrayList();
plansList.forEach(p -> {
List<YgglMainEmp> ygglMainEmpList = ygglMainEmpMapper.selectListByIds(p.getUserIds());
for (YgglMainEmp y : ygglMainEmpList) {
String[] arr = new String[]{String.valueOf(y.getId()), y.getName(), "身份证", y.getZjNum(), PlanEnum.getEnum(p.getBenefitBasicPlan(), p.getBenefitOccupationCategory()).getName(), createDate, "", StringUtils.isNullOrEmpty(p.getTricycleFrameNumber()) ? "无" : p.getTricycleFrameNumber(), PlanEnum.getEnum(p.getBenefitBasicPlan(), p.getBenefitOccupationCategory()).getType()};
list.add(arr);
}
});
String[] rowName = new String[]{"ID", "name", "ID_type", "ID_number", "Scheme_name", "Date_start", "Branch", "Tricycle_frame_number", "benefit_occupation_category"};
XSSFWorkbook xssfWorkbook = ExcelUtils.exportExcel(localDate + "_投保" + list.size() + "名人员清单.xlsx", rowName, list);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
String url = "";
try {
xssfWorkbook.write(byteArrayOutputStream);
byte[] bytes = byteArrayOutputStream.toByteArray();
String fileBase64 = Base64.byteArrayToBase64(bytes);
/*body参数 begin*/
Map bodyMap = Maps.newHashMap();
bodyMap.put("app", "mall");
bodyMap.put("name", localDate + "_" + list.size() + "名人员清单.xlsx");
bodyMap.put("file", fileBase64);
/*end*/
String data = HttpUtils.sendPost(uploadUrl, setParams(JSONObject.toJSONString(bodyMap), appid, secret), bodyMap);
Map<String, Object> dataMap = JSONObject.parseObject(data);
/*创建日志*/
if (dataMap.get("errcode").toString().equals("suc")) {
Object o = dataMap.get("data");
Map<String, Object> map = JSONObject.parseObject(JSONObject.toJSONString(o));
url = map.get("url").toString();
}
InsureLog.builder().requestParam(JSONObject.toJSONString(setParams(JSONObject.toJSONString(bodyMap), appid, secret))).type(4)
.requestData(JSONObject.toJSONString(bodyMap)).createTime(new Date()).requestType(1).returnBody(data).requestPath(uploadUrl)
.returnCode(dataMap.get("errcode").toString()).returnMsg(dataMap.get("errmsg").toString()).fileUrl(url).build().insert();
/*文件流base64*/
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
xssfWorkbook.close();
byteArrayOutputStream.close();
} catch (IOException e) {
return ResultUtil.error("投保错误");
}catch (Exception e){
e.printStackTrace();
throw new CustomException("投保异常");
}
}
return url;
}
@PostMapping(value = "/policyListAdmin")
@ApiOperation(value = "4.保单列表--运营后台端", httpMethod = "POST", notes = "保单列表--运营后台端")
public Result<Object> policyListAdmin(@RequestBody PolicyDto policyDto) {
Map map = Maps.newHashMap();
List<PolicyDto> list = insurePolicyMapper.policyList(policyDto);
map.put("list", list);
map.put("total", insurePolicyMapper.totalPolicy(policyDto));
return ResultUtil.data(map);
}
@GetMapping(value = "/policyDetail")
@ApiOperation(value = "5.保单信息", httpMethod = "GET", notes = "保单信息")
public Result<Object> policyDetail(@RequestParam("policyId") Integer policyId) {
// Map map = Maps.newHashMap();
PolicyDto policyDto = insurePolicyMapper.getPolicyDetail(policyId);
/*获取可选计划*/
// List<InsureUser> plansList = InsureUser.builder().build().selectList(new QueryWrapper<InsureUser>().lambda().eq(InsureUser::getApplyType,2).eq(InsureUser::getPolicyId,policyId).groupBy(InsureUser::getBenefitBasicPlan));
/*获取可选类型*/
// List<InsureUser> categoryList = InsureUser.builder().build().selectList(new QueryWrapper<InsureUser>().lambda().eq(InsureUser::getApplyType,2).eq(InsureUser::getPolicyId,policyId).groupBy(InsureUser::getBenefitOccupationCategory));
if (policyDto == null) {
return ResultUtil.error("保单不存在");
}
// map.put("policy",policyDto);
// map.put("plans",plansList.stream().map(InsureUser::getBenefitBasicPlan).toArray());
// map.put("category",categoryList.stream().map(InsureUser::getBenefitOccupationCategory).toArray());
return ResultUtil.data(policyDto);
}
@PostMapping(value = "/joinUser")
@ApiOperation(value = "2.增员", httpMethod = "POST", notes = "增员")
public Result<Object> joinUser(@RequestBody InsureDto insureDto) throws ParseException {
......@@ -478,6 +413,7 @@ public class InsureContorll {
if (insurePolicy == null) {
return ResultUtil.error("保单不存在");
}
try {
LocalDateTime now = LocalDateTime.now();
String url = creaXSSFWorkbook1(insureDto);
log.info("保全增员文件地址", url);
......@@ -490,7 +426,7 @@ public class InsureContorll {
bodyMap.put("from_source", "API");
bodyMap.put("import_review_callback", "");
bodyMap.put("import_callback", base_api_url + "/callBack/policy/CallBack");
if(insureProduct.getPayType()==1) {
if (insureProduct.getPayType() == 1) {
bodyMap.put("import_review_callback", base_api_url + "/callBack/policy/addpPayCallBack");
}
bodyMap.put("third_uuid", "IS_" + insurePolicy.getOrgCode() + "_" + dtf2.format(now));
......@@ -533,6 +469,8 @@ public class InsureContorll {
.insureStatus(3).policyId(insurePolicy.getId()).build().insert();
} catch (ParseException e) {
e.printStackTrace();
log.info("增员异常:policyDateStart:"+insureDto.getPolicyDateStart()+"policyDateEnd:"+insureDto.getPolicyDateEnd());
throw new CustomException("增员异常");
}
y.setIsInsure(1);
y.insertOrUpdate();
......@@ -547,104 +485,47 @@ public class InsureContorll {
.requestData(JSONObject.toJSONString(bodyMap)).createTime(new Date()).requestType(1).returnBody(responData).requestPath(batchUrl)
.returnCode(dataMap.get("errcode").toString()).returnMsg(dataMap.get("errmsg").toString()).policyId(insurePolicy.getId()).build().insert();
return ResultUtil.error(dataMap.get("errmsg").toString());
}catch (Exception e){
e.printStackTrace();
throw new CustomException("增员异常");
}
/**
* 生成保全增员文件
*
* @param ids
* @return
*/
public String creaXSSFWorkbook1(InsureDto insureDto) {
if (insureDto.getUserIds().length <= 0) {
return "error";
}
LocalDate localDate = LocalDate.now();
List<YgglMainEmp> ygglMainEmpList = ygglMainEmpMapper.selectListByIds(insureDto.getUserIds());
List list = Lists.newArrayList();
for (YgglMainEmp y : ygglMainEmpList) {
String[] arr = new String[]{String.valueOf(y.getId()), y.getName(), "身份证", y.getZjNum(), PlanEnum.getEnum(insureDto.getBenefitBasicPlan(), insureDto.getBenefitOccupationCategory()).getName(), insureDto.getPolicyDateStart(), "", StringUtils.isNullOrEmpty(insureDto.getTricycleFrameNumber()) ? "无" : insureDto.getTricycleFrameNumber(), PlanEnum.getEnum(insureDto.getBenefitBasicPlan(), insureDto.getBenefitOccupationCategory()).getType()};
list.add(arr);
}
String[] rowName = new String[]{"ID", "name", "ID_type", "ID_number", "Scheme_name", "Date_start", "Branch", "Tricycle_frame_number", "benefit_occupation_category"};
XSSFWorkbook xssfWorkbook = ExcelUtils.exportExcel(localDate + "_补充" + list.size() + "名人员清单.xlsx", rowName, list);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
String url = "";
try {
xssfWorkbook.write(byteArrayOutputStream);
byte[] bytes = byteArrayOutputStream.toByteArray();
String fileBase64 = Base64.byteArrayToBase64(bytes);
/*body参数 begin*/
Map bodyMap = Maps.newHashMap();
bodyMap.put("media", fileBase64);
/*end*/
String data = HttpUtils.sendPost(uploadUrl2, setParams(JSONObject.toJSONString(bodyMap), appidq, secretq), bodyMap);
Map<String, Object> dataMap = JSONObject.parseObject(data);
if (dataMap.get("errcode").toString().equals("suc")) {
Object o = dataMap.get("data");
Map<String, Object> map = JSONObject.parseObject(JSONObject.toJSONString(o));
url = map.get("file_url").toString();
}
InsureLog.builder().requestParam(JSONObject.toJSONString(setParams(JSONObject.toJSONString(bodyMap), appid, secret))).type(5)
.requestData(JSONObject.toJSONString(bodyMap)).createTime(new Date()).requestType(1).returnBody(data).requestPath(uploadUrl2)
.returnCode(dataMap.get("errcode").toString()).returnMsg(dataMap.get("errmsg").toString()).fileUrl(url).build().insert();
/*文件流base64*/
} catch (IOException e) {
e.printStackTrace();
} finally {
@PostMapping(value = "/policyListAdmin")
@ApiOperation(value = "4.保单列表--运营后台端", httpMethod = "POST", notes = "保单列表--运营后台端")
public Result<Object> policyListAdmin(@RequestBody PolicyDto policyDto) {
Map map = Maps.newHashMap();
try {
xssfWorkbook.close();
byteArrayOutputStream.close();
} catch (IOException e) {
List<PolicyDto> list = insurePolicyMapper.policyList(policyDto);
map.put("list", list);
map.put("total", insurePolicyMapper.totalPolicy(policyDto));
return ResultUtil.data(map);
}catch (Exception e){
e.printStackTrace();
throw new CustomException("获取保单列表异常");
}
}
return url;
}
@GetMapping(value = "/downPolicyFile")
@ApiOperation(value = "7.下载电子保单", httpMethod = "GET", notes = "下载电子保单")
public void downPolicyFile(@RequestParam("policyId") String policyId, HttpServletRequest request, HttpServletResponse response) {
InsurePolicy insurePolicy = InsurePolicy.builder().id(Integer.parseInt(policyId)).build().selectById();
if (insurePolicy == null || StringUtils.isNullOrEmpty(insurePolicy.getPolicyFile())) {
return;
}
OutputStream sos = null;
BufferedInputStream bis = null;
try {
response.setContentType("application/octet-stream");
response.setHeader("content-disposition", "attachment; filename=" + new String((insurePolicy.getPolicyNo() + ".pdf").getBytes("UTF8"), "ISO-8859-1"));
response.setCharacterEncoding("UTF-8");
sos = response.getOutputStream();
String destUrl = insurePolicy.getPolicyFile();
URL url = new URL(destUrl);
HttpURLConnection httpUrl = (HttpURLConnection) url.openConnection();
//连接指定的网络资源
httpUrl.connect();
//获取网络输入流
bis = new BufferedInputStream(httpUrl.getInputStream());
int b;
while ((b = bis.read()) != -1) {
sos.write(b);
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
@GetMapping(value = "/policyDetail")
@ApiOperation(value = "5.保单信息", httpMethod = "GET", notes = "保单信息")
public Result<Object> policyDetail(@RequestParam("policyId") Integer policyId) {
try {
sos.close();
} catch (IOException e) {
e.printStackTrace();
// Map map = Maps.newHashMap();
PolicyDto policyDto = insurePolicyMapper.getPolicyDetail(policyId);
/*获取可选计划*/
// List<InsureUser> plansList = InsureUser.builder().build().selectList(new QueryWrapper<InsureUser>().lambda().eq(InsureUser::getApplyType,2).eq(InsureUser::getPolicyId,policyId).groupBy(InsureUser::getBenefitBasicPlan));
/*获取可选类型*/
// List<InsureUser> categoryList = InsureUser.builder().build().selectList(new QueryWrapper<InsureUser>().lambda().eq(InsureUser::getApplyType,2).eq(InsureUser::getPolicyId,policyId).groupBy(InsureUser::getBenefitOccupationCategory));
if (policyDto == null) {
return ResultUtil.error("保单不存在");
}
try {
bis.close();
} catch (IOException e) {
// map.put("policy",policyDto);
// map.put("plans",plansList.stream().map(InsureUser::getBenefitBasicPlan).toArray());
// map.put("category",categoryList.stream().map(InsureUser::getBenefitOccupationCategory).toArray());
return ResultUtil.data(policyDto);
}catch (Exception e){
e.printStackTrace();
}
throw new CustomException("获取保单信息异常");
}
}
......@@ -655,6 +536,7 @@ public class InsureContorll {
if (insurePolicy == null) {
return ResultUtil.error("保单不存在");
}
try {
/*单个替换*/
if (insureDto.getLimit() == 1) {
if (!StringUtils.isNullOrEmpty(insureDto.getUserName()) && !StringUtils.isNullOrEmpty(insureDto.getIdCardNo())) {
......@@ -747,147 +629,65 @@ public class InsureContorll {
}
}
return ResultUtil.data("成功");
}catch (Exception e){
e.printStackTrace();
throw new CustomException("保全替换异常");
}
/**
* 生成保全替换文件
*
* @param ids
* @return
*/
public String creaXSSFWorkbook2(String[] ids, String date, String[] oldIds, String type, String tricycleFrameNumber) {
if (ids.length <= 0 || oldIds.length <= 0) {
return "error";
}
LocalDate localDate = LocalDate.now();
List<YgglMainEmp> newList = ygglMainEmpMapper.selectListByIds(ids);
List<YgglMainEmp> oldList = ygglMainEmpMapper.selectListByIds(oldIds);
if (newList.size() != oldList.size()) {
return "error";
}
List list = Lists.newArrayList();
for (int i = 0; i < newList.size(); i++) {
String[] arr = new String[]{String.valueOf(oldList.get(i).getId()),
oldList.get(i).getName(),
"身份证",
oldList.get(i).getZjNum(),
date.substring(0, 10),
newList.get(i).getName(),
"身份证",
newList.get(i).getZjNum(),
"", "", "", "", "", "", StringUtils.isNullOrEmpty(tricycleFrameNumber) ? "无" : tricycleFrameNumber, "1", type.equals("63119") ? "A类" : type.equals("63120") ? "B类" : "C类"};
list.add(arr);
}
String[] rowName = new String[]{"ID", "name", "ID_type", "ID_number", "Update_date", "replace_name", "replace_ID_type",
"replace_ID_number", "Date_of_birth", "insured_type", "insured_relationship", "cert_type_related_insured", "insured_relationship_id", "Branch",
"Tricycle_frame_number", "insured_number", "benefit_occupation_category"};
XSSFWorkbook xssfWorkbook = ExcelUtils.exportExcel(localDate + "_替换" + list.size() + "名人员清单.xlsx", rowName, list);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
String url = "";
try {
xssfWorkbook.write(byteArrayOutputStream);
byte[] bytes = byteArrayOutputStream.toByteArray();
String fileBase64 = Base64.byteArrayToBase64(bytes);
/*body参数 begin*/
Map bodyMap = Maps.newHashMap();
bodyMap.put("media", fileBase64);
/*end*/
String data = HttpUtils.sendPost(uploadUrl2, setParams(JSONObject.toJSONString(bodyMap), appidq, secretq), bodyMap);
Map<String, Object> dataMap = JSONObject.parseObject(data);
if (dataMap.get("errcode").toString().equals("suc")) {
Object o = dataMap.get("data");
Map<String, Object> map = JSONObject.parseObject(JSONObject.toJSONString(o));
url = map.get("file_url").toString();
@GetMapping(value = "/downPolicyFile")
@ApiOperation(value = "7.下载电子保单", httpMethod = "GET", notes = "下载电子保单")
public void downPolicyFile(@RequestParam("policyId") String policyId, HttpServletRequest request, HttpServletResponse response) {
InsurePolicy insurePolicy = InsurePolicy.builder().id(Integer.parseInt(policyId)).build().selectById();
if (insurePolicy == null || StringUtils.isNullOrEmpty(insurePolicy.getPolicyFile())) {
return;
}
InsureLog.builder().requestParam(JSONObject.toJSONString(setParams(JSONObject.toJSONString(bodyMap), appid, secret))).type(6)
.requestData(JSONObject.toJSONString(bodyMap)).createTime(new Date()).requestType(1).returnBody(data).requestPath(uploadUrl2)
.returnCode(dataMap.get("errcode").toString()).returnMsg(dataMap.get("errmsg").toString()).fileUrl(url).build().insert();
/*文件流base64*/
OutputStream sos = null;
BufferedInputStream bis = null;
try {
response.setContentType("application/octet-stream");
response.setHeader("content-disposition", "attachment; filename=" + new String((insurePolicy.getPolicyNo() + ".pdf").getBytes("UTF8"), "ISO-8859-1"));
response.setCharacterEncoding("UTF-8");
sos = response.getOutputStream();
String destUrl = insurePolicy.getPolicyFile();
URL url = new URL(destUrl);
HttpURLConnection httpUrl = (HttpURLConnection) url.openConnection();
//连接指定的网络资源
httpUrl.connect();
//获取网络输入流
bis = new BufferedInputStream(httpUrl.getInputStream());
int b;
while ((b = bis.read()) != -1) {
sos.write(b);
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
xssfWorkbook.close();
byteArrayOutputStream.close();
sos.close();
} catch (IOException e) {
e.printStackTrace();
}
try {
bis.close();
} catch (IOException e) {
e.printStackTrace();
}
return url;
}
/*获取基础计划的价格*/
private Integer getPrice(String plan, String type) {
/*
基础计划
30万雇主/3万医疗 36968,
50万雇主/5万医疗 36969,
80万雇主/10万医疗 36970,
80万雇主/20万医疗 36971,
100万雇主/10万医疗 36972
*/
/*行业类型
* A类 63119
* B类 63120
* C类 63121\
* */
switch (plan) {
case "36968":
if (type.equals("63119")) {
return PlanEnum.A_30.getPrice();
} else if (type.equals("63120")) {
return PlanEnum.B_30.getPrice();
}
break;
case "36969":
if (type.equals("63119")) {
return PlanEnum.A_50.getPrice();
} else if (type.equals("63120")) {
return PlanEnum.B_50.getPrice();
} else if (type.equals("63121")) {
return PlanEnum.C_50.getPrice();
}
break;
case "36970":
if (type.equals("63119")) {
return PlanEnum.A_80.getPrice();
} else if (type.equals("63120")) {
return PlanEnum.B_80.getPrice();
} else if (type.equals("63121")) {
return PlanEnum.C_80.getPrice();
}
break;
case "36971":
if (type.equals("63119")) {
return PlanEnum.A_80_20.getPrice();
} else if (type.equals("63120")) {
return PlanEnum.B_80_20.getPrice();
}
break;
case "36972":
if (type.equals("63119")) {
return PlanEnum.A_100.getPrice();
} else if (type.equals("63120")) {
return PlanEnum.B_100.getPrice();
}
break;
}
return 0;
}
@PostMapping(value = "/policyTotal")
@ApiOperation(value = "11.保单统计列表", httpMethod = "POST", notes = "保单统计列表")
@ApiOperation(value = "8.保单统计列表", httpMethod = "POST", notes = "保单统计列表")
public Result<Object> policyTotal() {
List<PolicyDto> list = insurePolicyMapper.policyTotalList();
return ResultUtil.data(list);
}
@GetMapping(value = "/isInsured")
@ApiOperation(value = "10.企业是否已投保", httpMethod = "POST", notes = "企业是否已投保")
@ApiOperation(value = "9.企业是否已投保-弃用", httpMethod = "POST", notes = "企业是否已投保")
public Result<Object> isInsured(@RequestParam("orgCode") String orgCode) {
InsurePolicy insurePolicy = InsurePolicy.builder().build().selectOne(new QueryWrapper<InsurePolicy>().lambda().eq(InsurePolicy::getOrgCode, orgCode).eq(InsurePolicy::getStatus, 1));
if (insurePolicy != null) {
......@@ -897,8 +697,9 @@ public class InsureContorll {
}
@GetMapping(value = "/verification")
@ApiOperation(value = "一键校验", httpMethod = "POST", notes = "一键校验")
@ApiOperation(value = "10.一键校验", httpMethod = "POST", notes = "一键校验")
public Result<Object> verification() {
try {
/*校验投保*/
List<InsurePolicy> insurePolicies = InsurePolicy.builder().build().selectList(new QueryWrapper<InsurePolicy>().lambda().eq(InsurePolicy::getStatus, 2));
insurePolicies.forEach(i -> {
......@@ -938,6 +739,10 @@ public class InsureContorll {
/*校验人员*/
return ResultUtil.success();
}catch (Exception e){
e.printStackTrace();
throw new CustomException("一键校验异常");
}
}
......@@ -952,7 +757,7 @@ public class InsureContorll {
@PostMapping(value = "/importUser")
@ApiOperation(value = "导入用户--运营后台", httpMethod = "POST", notes = "导入用户")
@ApiOperation(value = "12.导入用户--运营后台", httpMethod = "POST", notes = "导入用户")
public Result<Object> importUser(@RequestParam("orgCode") String orgCode, @RequestParam("file") MultipartFile file) {
SimpleDateFormat dtf = new SimpleDateFormat("yyyyMMdd");
QyzxEntInfoM company = QyzxEntInfoM.builder().id(Integer.valueOf(orgCode)).build().selectById();
......@@ -1054,7 +859,7 @@ public class InsureContorll {
}
@PostMapping(value = "/importUserClient")
@ApiOperation(value = "导入用户--8小时后台", httpMethod = "POST", notes = "导入用户")
@ApiOperation(value = "13.导入用户--8小时后台", httpMethod = "POST", notes = "导入用户")
public Result<Object> importUserClient(@CurrentUser UserBean userBean, @RequestParam("file") MultipartFile file) {
SimpleDateFormat dtf = new SimpleDateFormat("yyyyMMdd");
QyzxEntInfoM company = QyzxEntInfoM.builder().id(Integer.valueOf(userBean.getOrgCode())).build().selectById();
......@@ -1157,7 +962,7 @@ public class InsureContorll {
@PostMapping(value = "/importPolicy")
@ApiOperation(value = "导入保单--运营后台", httpMethod = "POST", notes = "导入用户")
@ApiOperation(value = "14.导入保单--运营后台", httpMethod = "POST", notes = "导入用户")
public Result<Object> importPolicy(@RequestParam("file") MultipartFile file, @RequestParam("productId") String productId) {
SimpleDateFormat dtf = new SimpleDateFormat("yyyyMMdd");
......@@ -1346,7 +1151,7 @@ public class InsureContorll {
}
@PostMapping(value = "/importUserPolicy")
@ApiOperation(value = "导入被保人员--运营后台", httpMethod = "POST", notes = "导入用户")
@ApiOperation(value = "15.导入被保人员--运营后台", httpMethod = "POST", notes = "导入用户")
public Result<Object> importUserPolicy(@RequestParam("file") MultipartFile file, @RequestParam("orgCode") Integer orgCode) {
if (file.getSize() <= 0) {
return ResultUtil.error("未上传文件");
......@@ -1358,6 +1163,7 @@ public class InsureContorll {
if (qyzxEntInfoM == null) {
return ResultUtil.error("企业不存在");
}
try {
XSSFWorkbook xw = null;
Map<String, String> map = Maps.newHashMap();
try {
......@@ -1387,6 +1193,9 @@ public class InsureContorll {
if (StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))) {
return ResultUtil.error("第" + i + "行第" + index + "列被保人身份证不能为空");
}
if (!Regular.match(ExcelUtils.getString(cell), Regular.IDCARD)) {
return ResultUtil.error("第" + i + "行第" + index + "身份证格式错误");
}
user.setInsuredNo(ExcelUtils.getString(cell));
break;
case "基础计划":
......@@ -1445,10 +1254,14 @@ public class InsureContorll {
e.printStackTrace();
}
return ResultUtil.error("导入失败");
}catch (Exception e) {
e.printStackTrace();
throw new CustomException("导入被保人异常");
}
}
@GetMapping(value = "/rePay")
@ApiOperation(value = "重新发起支付", httpMethod = "GET", notes = "重新发起支付")
@ApiOperation(value = "16.重新发起支付", httpMethod = "GET", notes = "重新发起支付")
public Result<Object> rePay(@RequestParam("payId")Integer payId){
InsurePay insurePay = InsurePay.builder().id(payId).build().selectById();
if(insurePay==null){
......@@ -1457,10 +1270,11 @@ public class InsureContorll {
if(insurePay.getPayStatus()!=1){
return ResultUtil.error("保单不是支付状态");
}
try {
InsurePolicy insurePolicy = InsurePolicy.builder().id(insurePay.getPolicyId()).build().selectById();
Map<String, String> toPayParamsMap=Maps.newHashMap();
Map<String, String> toPayParamsMap = Maps.newHashMap();
/*判断是投保还是保全,投保支付前是没有保单号的*/
if(StringUtils.isNullOrEmpty(insurePolicy.getPolicyNo())) {
if (StringUtils.isNullOrEmpty(insurePolicy.getPolicyNo())) {
/*投保支付*/
toPayParamsMap = setParams(null, appid, secret);
toPayParamsMap.put("serial_number", insurePay.getSerialNumber());
......@@ -1476,12 +1290,14 @@ public class InsureContorll {
builder.addParameter(key, toPayParamsMap.get(key));
}
}
InsureLog.builder().requestParam(JSONObject.toJSONString(toPayParamsMap)).type(7).createTime(new Date()).requestType(2).requestPath(toPayUrl)
.returnMsg("请求投保支付").policyId(insurePolicy.getId()).build().insert();
return ResultUtil.data(builder.build());
} catch (URISyntaxException e) {
e.printStackTrace();
return ResultUtil.error("请求错误");
}
}else{
} else {
/*保全支付*/
toPayParamsMap = setParams(batchToPayUrl, appidq, secretq);
toPayParamsMap.put("order_import_uuid", insurePay.getSerialNumber());
......@@ -1492,14 +1308,20 @@ public class InsureContorll {
insurePay.setPaySerialNo(importPayInfo.get("pay_serial_no").toString());
insurePay.setAmount(Double.parseDouble(importPayInfo.get("pay_money").toString()));
insurePay.updateById();
return ResultUtil.data(importPayInfo.get("pay_url").toString()+"&jump_url="+base_api_url +"/callBack/policy/payStatus?policyId="+insurePolicy.getId());
InsureLog.builder().requestParam(JSONObject.toJSONString(toPayParamsMap)).returnBody(returnPay).type(7).createTime(new Date()).requestType(2).requestPath(batchToPayUrl)
.returnMsg("请求保全支付").policyId(insurePolicy.getId()).build().insert();
return ResultUtil.data(importPayInfo.get("pay_url").toString() + "&jump_url=" + base_api_url + "/callBack/policy/payStatus?policyId=" + insurePolicy.getId() + "&notify_url=" + base_api_url + "/callBack/policy/batchPayCallback");
}
}catch (Exception e){
e.printStackTrace();
throw new CustomException("重新发起支付异常");
}
// String data = HttpUtils.sendGet(setParams())
};
@GetMapping(value = "/cePay")
@ApiOperation(value = "取消支付", httpMethod = "GET", notes = "取消支付")
@ApiOperation(value = "17.取消支付", httpMethod = "GET", notes = "取消支付")
public Result<Object> cancelPay(@RequestParam("payId")Integer payId){
InsurePay insurePay = InsurePay.builder().id(payId).build().selectById();
if(insurePay==null){
......@@ -1508,6 +1330,8 @@ public class InsureContorll {
if(insurePay.getPayStatus()!=1){
return ResultUtil.error("保单不是支付状态");
}
try {
InsurePolicy insurePolicy = InsurePolicy.builder().id(insurePay.getPolicyId()).build().selectById();
//TODO 验证保单的状态
long timestamp = System.currentTimeMillis() / 1000;
......@@ -1518,21 +1342,21 @@ public class InsureContorll {
map.put("sign", DigestUtils.md5Hex(appidq + secretq + timestamp));
map.put("timestamp", String.valueOf(timestamp));
map.put("set_status", "2");
map.put("import_uuid",insurePay.getSerialNumber());
map.put("import_uuid", insurePay.getSerialNumber());
String data = HttpUtils.sendGet(cancelPayment, map);
if(StringUtils.isNullOrEmpty(data)){
if (StringUtils.isNullOrEmpty(data)) {
return ResultUtil.error("取消失败,请重新再来");
}
Map returnMap = JSONObject.parseObject(data, Map.class);
InsureLog.builder().requestParam(JSONObject.toJSONString(setParams(JSONObject.toJSONString(map), appid, secret))).type(7)
.requestData(JSONObject.toJSONString(map)).createTime(new Date()).requestType(2).returnBody(data).requestPath(uploadUrl)
.returnCode(returnMap.get("errcode").toString()).returnMsg(returnMap.get("errmsg").toString()).build().insert();
if (returnMap.get("errcode").equals("suc")){
if (returnMap.get("errcode").equals("suc")) {
Map dataMap = JSONObject.parseObject(JSONObject.toJSONString(returnMap.get("data")), Map.class);
if(dataMap.get("status").equals("1")){
List<InsureUser> userList = InsureUser.builder().build().selectList(new QueryWrapper<InsureUser>().lambda().eq(InsureUser::getBatchNo,insurePay.getSerialNumber()));
if (dataMap.get("status").equals("1")) {
List<InsureUser> userList = InsureUser.builder().build().selectList(new QueryWrapper<InsureUser>().lambda().eq(InsureUser::getBatchNo, insurePay.getSerialNumber()));
/*取消成功*/
InsureUser.builder().status("2").insureStatus(2).build().update(new QueryWrapper<InsureUser>().lambda().eq(InsureUser::getBatchNo,insurePay.getSerialNumber()));
InsureUser.builder().status("2").insureStatus(2).build().update(new QueryWrapper<InsureUser>().lambda().eq(InsureUser::getBatchNo, insurePay.getSerialNumber()));
insurePay.setPayStatus(3);
insurePay.updateById();
insurePolicy.setStatus("1");
......@@ -1546,5 +1370,258 @@ public class InsureContorll {
/*生成一个支付链接返回到前台*/
return ResultUtil.error("取消失败,请重新再来");
}catch (Exception e){
e.printStackTrace();
throw new CustomException("重新发起支付异常");
}
}
/**
* 生成投保文件
*
* @return
*/
public String creaXSSFWorkbook(List<PlansDto> plansList, String createDate) {
if (plansList.size() <= 0) {
return "error";
}
LocalDate localDate = LocalDate.now();
Date date = new Date();
List list = Lists.newArrayList();
plansList.forEach(p -> {
List<YgglMainEmp> ygglMainEmpList = ygglMainEmpMapper.selectListByIds(p.getUserIds());
for (YgglMainEmp y : ygglMainEmpList) {
String[] arr = new String[]{String.valueOf(y.getId()), y.getName(), "身份证", y.getZjNum(), PlanEnum.getEnum(p.getBenefitBasicPlan(), p.getBenefitOccupationCategory()).getName(), createDate, "", StringUtils.isNullOrEmpty(p.getTricycleFrameNumber()) ? "无" : p.getTricycleFrameNumber(), PlanEnum.getEnum(p.getBenefitBasicPlan(), p.getBenefitOccupationCategory()).getType()};
list.add(arr);
}
});
String[] rowName = new String[]{"ID", "name", "ID_type", "ID_number", "Scheme_name", "Date_start", "Branch", "Tricycle_frame_number", "benefit_occupation_category"};
XSSFWorkbook xssfWorkbook = ExcelUtils.exportExcel(localDate + "_投保" + list.size() + "名人员清单.xlsx", rowName, list);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
String url = "";
try {
xssfWorkbook.write(byteArrayOutputStream);
byte[] bytes = byteArrayOutputStream.toByteArray();
String fileBase64 = Base64.byteArrayToBase64(bytes);
/*body参数 begin*/
Map bodyMap = Maps.newHashMap();
bodyMap.put("app", "mall");
bodyMap.put("name", localDate + "_" + list.size() + "名人员清单.xlsx");
bodyMap.put("file", fileBase64);
/*end*/
String data = HttpUtils.sendPost(uploadUrl, setParams(JSONObject.toJSONString(bodyMap), appid, secret), bodyMap);
Map<String, Object> dataMap = JSONObject.parseObject(data);
/*创建日志*/
if (dataMap.get("errcode").toString().equals("suc")) {
Object o = dataMap.get("data");
Map<String, Object> map = JSONObject.parseObject(JSONObject.toJSONString(o));
url = map.get("url").toString();
}
InsureLog.builder().requestParam(JSONObject.toJSONString(setParams(JSONObject.toJSONString(bodyMap), appid, secret))).type(4)
.requestData(JSONObject.toJSONString(bodyMap)).createTime(new Date()).requestType(1).returnBody(data).requestPath(uploadUrl)
.returnCode(dataMap.get("errcode").toString()).returnMsg(dataMap.get("errmsg").toString()).fileUrl(url).build().insert();
/*文件流base64*/
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
xssfWorkbook.close();
byteArrayOutputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return url;
}
/**
* 生成保全增员文件
*
* @param ids
* @return
*/
public String creaXSSFWorkbook1(InsureDto insureDto) {
if (insureDto.getUserIds().length <= 0) {
return "error";
}
LocalDate localDate = LocalDate.now();
List<YgglMainEmp> ygglMainEmpList = ygglMainEmpMapper.selectListByIds(insureDto.getUserIds());
List list = Lists.newArrayList();
for (YgglMainEmp y : ygglMainEmpList) {
String[] arr = new String[]{String.valueOf(y.getId()), y.getName(), "身份证", y.getZjNum(), PlanEnum.getEnum(insureDto.getBenefitBasicPlan(), insureDto.getBenefitOccupationCategory()).getName(), insureDto.getPolicyDateStart(), "", StringUtils.isNullOrEmpty(insureDto.getTricycleFrameNumber()) ? "无" : insureDto.getTricycleFrameNumber(), PlanEnum.getEnum(insureDto.getBenefitBasicPlan(), insureDto.getBenefitOccupationCategory()).getType()};
list.add(arr);
}
String[] rowName = new String[]{"ID", "name", "ID_type", "ID_number", "Scheme_name", "Date_start", "Branch", "Tricycle_frame_number", "benefit_occupation_category"};
XSSFWorkbook xssfWorkbook = ExcelUtils.exportExcel(localDate + "_补充" + list.size() + "名人员清单.xlsx", rowName, list);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
String url = "";
try {
xssfWorkbook.write(byteArrayOutputStream);
byte[] bytes = byteArrayOutputStream.toByteArray();
String fileBase64 = Base64.byteArrayToBase64(bytes);
/*body参数 begin*/
Map bodyMap = Maps.newHashMap();
bodyMap.put("media", fileBase64);
/*end*/
String data = HttpUtils.sendPost(uploadUrl2, setParams(JSONObject.toJSONString(bodyMap), appidq, secretq), bodyMap);
Map<String, Object> dataMap = JSONObject.parseObject(data);
if (dataMap.get("errcode").toString().equals("suc")) {
Object o = dataMap.get("data");
Map<String, Object> map = JSONObject.parseObject(JSONObject.toJSONString(o));
url = map.get("file_url").toString();
}
InsureLog.builder().requestParam(JSONObject.toJSONString(setParams(JSONObject.toJSONString(bodyMap), appid, secret))).type(5)
.requestData(JSONObject.toJSONString(bodyMap)).createTime(new Date()).requestType(1).returnBody(data).requestPath(uploadUrl2)
.returnCode(dataMap.get("errcode").toString()).returnMsg(dataMap.get("errmsg").toString()).fileUrl(url).build().insert();
/*文件流base64*/
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
xssfWorkbook.close();
byteArrayOutputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return url;
}
/**
* 生成保全替换文件
*
* @param ids
* @return
*/
public String creaXSSFWorkbook2(String[] ids, String date, String[] oldIds, String type, String tricycleFrameNumber) {
if (ids.length <= 0 || oldIds.length <= 0) {
return "error";
}
LocalDate localDate = LocalDate.now();
List<YgglMainEmp> newList = ygglMainEmpMapper.selectListByIds(ids);
List<YgglMainEmp> oldList = ygglMainEmpMapper.selectListByIds(oldIds);
if (newList.size() != oldList.size()) {
return "error";
}
List list = Lists.newArrayList();
for (int i = 0; i < newList.size(); i++) {
String[] arr = new String[]{String.valueOf(oldList.get(i).getId()),
oldList.get(i).getName(),
"身份证",
oldList.get(i).getZjNum(),
date.substring(0, 10),
newList.get(i).getName(),
"身份证",
newList.get(i).getZjNum(),
"", "", "", "", "", "", StringUtils.isNullOrEmpty(tricycleFrameNumber) ? "无" : tricycleFrameNumber, "1", type.equals("63119") ? "A类" : type.equals("63120") ? "B类" : "C类"};
list.add(arr);
}
String[] rowName = new String[]{"ID", "name", "ID_type", "ID_number", "Update_date", "replace_name", "replace_ID_type",
"replace_ID_number", "Date_of_birth", "insured_type", "insured_relationship", "cert_type_related_insured", "insured_relationship_id", "Branch",
"Tricycle_frame_number", "insured_number", "benefit_occupation_category"};
XSSFWorkbook xssfWorkbook = ExcelUtils.exportExcel(localDate + "_替换" + list.size() + "名人员清单.xlsx", rowName, list);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
String url = "";
try {
xssfWorkbook.write(byteArrayOutputStream);
byte[] bytes = byteArrayOutputStream.toByteArray();
String fileBase64 = Base64.byteArrayToBase64(bytes);
/*body参数 begin*/
Map bodyMap = Maps.newHashMap();
bodyMap.put("media", fileBase64);
/*end*/
String data = HttpUtils.sendPost(uploadUrl2, setParams(JSONObject.toJSONString(bodyMap), appidq, secretq), bodyMap);
Map<String, Object> dataMap = JSONObject.parseObject(data);
if (dataMap.get("errcode").toString().equals("suc")) {
Object o = dataMap.get("data");
Map<String, Object> map = JSONObject.parseObject(JSONObject.toJSONString(o));
url = map.get("file_url").toString();
}
InsureLog.builder().requestParam(JSONObject.toJSONString(setParams(JSONObject.toJSONString(bodyMap), appid, secret))).type(6)
.requestData(JSONObject.toJSONString(bodyMap)).createTime(new Date()).requestType(1).returnBody(data).requestPath(uploadUrl2)
.returnCode(dataMap.get("errcode").toString()).returnMsg(dataMap.get("errmsg").toString()).fileUrl(url).build().insert();
/*文件流base64*/
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
xssfWorkbook.close();
byteArrayOutputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return url;
}
/*获取基础计划的价格*/
private Integer getPrice(String plan, String type) {
/*
基础计划
30万雇主/3万医疗 36968,
50万雇主/5万医疗 36969,
80万雇主/10万医疗 36970,
80万雇主/20万医疗 36971,
100万雇主/10万医疗 36972
*/
/*行业类型
* A类 63119
* B类 63120
* C类 63121\
* */
switch (plan) {
case "36968":
if (type.equals("63119")) {
return PlanEnum.A_30.getPrice();
} else if (type.equals("63120")) {
return PlanEnum.B_30.getPrice();
}
break;
case "36969":
if (type.equals("63119")) {
return PlanEnum.A_50.getPrice();
} else if (type.equals("63120")) {
return PlanEnum.B_50.getPrice();
} else if (type.equals("63121")) {
return PlanEnum.C_50.getPrice();
}
break;
case "36970":
if (type.equals("63119")) {
return PlanEnum.A_80.getPrice();
} else if (type.equals("63120")) {
return PlanEnum.B_80.getPrice();
} else if (type.equals("63121")) {
return PlanEnum.C_80.getPrice();
}
break;
case "36971":
if (type.equals("63119")) {
return PlanEnum.A_80_20.getPrice();
} else if (type.equals("63120")) {
return PlanEnum.B_80_20.getPrice();
}
break;
case "36972":
if (type.equals("63119")) {
return PlanEnum.A_100.getPrice();
} else if (type.equals("63120")) {
return PlanEnum.B_100.getPrice();
}
break;
}
return 0;
}
}
......@@ -114,6 +114,7 @@ public class InsureUserController{
policyDto.setCategoryId(categoryId);
List<PolicyDto> list = insureUserMapper.selectPolicyList(policyDto);
String[] rowName = new String[]{"ID", "name", "ID_type", "ID_number", "Scheme_name", "Date_start", "Branch", "Tricycle_frame_number", "benefit_occupation_category"};
/*XSSFWorkbook xssfWorkbook = ExcelUtils.exportExcel("导出人员清单.xlsx", rowName, list);*/
// for ()
// XSSFWorkbook xssfWorkbook = ExcelUtils.exportExcel("导出人员清单.xlsx", rowName, list);
}
}
......@@ -5,6 +5,7 @@ import cn.timer.api.bean.insure.InsureLog;
import cn.timer.api.bean.insure.InsurePolicy;
import cn.timer.api.bean.insure.InsureUser;
import cn.timer.api.bean.yggl.YgglMainEmp;
import cn.timer.api.config.exception.CustomException;
import cn.timer.api.dao.insure.InsurePolicyMapper;
import cn.timer.api.dao.insure.InsureUserMapper;
import cn.timer.api.dao.yggl.YgglMainEmpMapper;
......@@ -36,10 +37,12 @@ public class InsureTaskTiming {
private YgglMainEmpMapper ygglMainEmpMapper;
@Scheduled(cron = "0 0 0 1 * ?")//每月第一天
public void updateInsureStatusTask() throws ParseException {
public void updateInsureStatusTask(){
try {
Date now = DateUtil.date();
/*获取正常的保单*/
List<InsurePolicy> insurePolicyList = InsurePolicy.builder().build().selectList(new QueryWrapper<InsurePolicy>().lambda().eq(InsurePolicy::getStatus, "1").lt(InsurePolicy::getPolicyDateEnd,now));
List<InsurePolicy> insurePolicyList = InsurePolicy.builder().build().selectList(new QueryWrapper<InsurePolicy>().lambda().eq(InsurePolicy::getStatus, "1").lt(InsurePolicy::getPolicyDateEnd, now));
if (insurePolicyList.size() > 0) {
/*获取已经过期保单*/
for (InsurePolicy insurePolicy : insurePolicyList) {
......@@ -48,14 +51,20 @@ public class InsureTaskTiming {
.eq(InsureUser::getInsureStatus, 1));
if (insureUsersList.size() > 0) {
int count = ygglMainEmpMapper.updateInsure(insureUsersList.stream().map(InsureUser::getUserId).toArray(Integer[]::new));
log.info("总共更新员工投保状态", count);
log.info("总共更新员工投保状态:"+count);
int uCount = insureUserMapper.updateInsure(insurePolicyList.stream().map(InsurePolicy::getId).toArray(Integer[]::new));
log.info("总共更新投保人投保状态", uCount);
log.info("总共更新投保人投保状态:"+uCount);
}
insurePolicy.setStatus("3");
insurePolicy.updateById();
InsureLog.builder().type(7)
.createTime(new Date()).requestType(1).returnMsg("保单已到期,自动失效").policyId(insurePolicy.getId()).build().insert();
}
}
log.error("暂无过期保单");
}catch (Exception e){
e.printStackTrace();
throw new CustomException("保单失效定时器异常");
}
}
}
......@@ -46,4 +46,5 @@ public class PolicyDto {
private Integer applyType;
private String monthD;
private String userName;
private String companyName;
}
......@@ -268,6 +268,9 @@
<if test="policy.policyDateStart!=null and policy.policyDateStart!=''">
and ip.policy_date_start <![CDATA[ >= ]]> #{policy.policyDateStart}
</if>
<if test="policy.companyName!=null and policy.companyName!=''">
and qy.name like CONCAT('%',#{policy.companyName},'%')
</if>
</where>
GROUP BY ip.id
order by ip.create_time desc
......@@ -319,17 +322,17 @@
<select id="policyTotalList" resultType="cn.timer.api.dto.insure.PolicyDto">
SELECT
ip.id as id,
ip.name AS schemeName,
ip.id AS id,
ip.NAME AS schemeName,
ip.type AS type,
count(ipp.id) AS totaPolicy,
count(ipp.org_code) AS totalCompany,
(select count(id) from insure_policy WHERE product_id=ip.id ) AS totaPolicy,
(select count(org_code) from insure_policy WHERE product_id=ip.id) as totalCompany,
count( iu.id ) AS totalUser,
sum(iu.price) as totalPremium,
sum( iu.price ) AS totalPremium,
ipp.update_time AS updateTime
FROM
insure_product ip
LEFT JOIN insure_policy ipp ON ipp.product_id = ip.id
LEFT JOIN insure_policy ipp ON ipp.product_id = ip.id and ipp.`status`=1
LEFT JOIN insure_user iu ON iu.policy_id = ipp.id
WHERE
ip.is_del = 0
......
......@@ -237,6 +237,17 @@
<select id="companyAdminCount" resultType="java.lang.Integer">
select count(qeim.id) from qyzx_ent_info_m qeim
<where>
<if test="param.name != null and param.name !=''">
and qeim.NAME like CONCAT('%',#{param.name},'%')
</if>
<if test="param.linkMan != null and param.linkMan !=''">
and qeim.link_man like CONCAT('%',#{param.linkMan},'%')
</if>
<if test="param.linkManPhone != null and param.linkManPhone !=''">
and qeim.phone like CONCAT('%',#{param.linkManPhone},'%')
</if>
</where>
</select>
<select id ="getCompanyList" resultType="java.util.HashMap">
......
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