Commit 4350ae1c by 陶湘宇

Merge commit '807eebdd' into develop

* commit '807eebdd':
  8小时后台-- 保单在线支付
parents d83f4fd3 807eebdd
......@@ -22,3 +22,6 @@ MODIFY COLUMN `lzyy` varchar(800) CHARACTER SET utf8 COLLATE utf8_general_ci NUL
ALTER TABLE yggl_main_emp`
ADD COLUMN `zpgl_zj_id` int(11) NULL DEFAULT NULL COMMENT '职级字典id' AFTER `zpgl_gzdd_id`;
ALTER TABLE `timer_test`.`insure_user`
ADD COLUMN `create_time` datetime(0) NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '创建时间' AFTER `reason`;
......@@ -170,3 +170,30 @@ INSERT INTO `timer_test`.`qyzx_admin_menu`(`id`, `menu_code`, `menu_name`, `sort
ALTER TABLE `timer_test`.`insure_user`
ADD COLUMN `reason` varchar(255) NULL COMMENT '批改原因' AFTER `apply_type`;
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for insure_pay
-- ----------------------------
DROP TABLE IF EXISTS `insure_pay`;
CREATE TABLE `insure_pay` (
`id` int(11) NOT NULL COMMENT 'id',
`pay_status` int(11) NULL DEFAULT NULL COMMENT '1已支付 2未支付 3已超时',
`amount` double NULL DEFAULT NULL COMMENT '支付金额',
`pay_time` datetime(0) NULL DEFAULT NULL COMMENT '支付时间',
`end_time` datetime(0) NULL DEFAULT NULL COMMENT '超时时间',
`pay_serial_no` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '支付流水号',
`pay_type` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '支付类型',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '支付流水表' ROW_FORMAT = Dynamic;
SET FOREIGN_KEY_CHECKS = 1;
ALTER TABLE `insure_product`
ADD COLUMN `pay_type` int(11) NULL DEFAULT NULL COMMENT '1 在线支付 2预付款 3线下支付' AFTER `is_del`;
ALTER TABLE `insure_policy`
ADD COLUMN `policy_pay_type` int(11) NOT NULL DEFAULT 1 COMMENT '1在线支付 2预付款 3线下支付' AFTER `create_time`,
ADD COLUMN `pay_id` int(11) NULL DEFAULT NULL COMMENT 'insure_pay表的id' AFTER `policy_pay_type`;
......@@ -13,7 +13,17 @@ import java.util.List;
@Data
public class CallBack implements Serializable {
private static final long serialVersionUID = 61499950876094044L;
/**
* 0失败 1成功
* 保全复核回调:0代表核保失败,1代表核保成功,核保成功才可调用支付
* 保全批单回调:0代表保全失败,1代表保全成功
*/
private String status;
/**
* 1保全复核回调
* 2保全批单回调
*/
private String callback_type;
private String policy_status;
private String err_msg;
private String policy_no;
......
package cn.timer.api.bean.insure;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.util.Date;
/**
* 支付流水表
*
* @author wgd
* @email 862422848@qq.com
* @date 2022-05-18 19:33:23
*/
@Entity
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "insure_pay")
@ApiModel("支付流水表")
public class InsurePay extends Model<InsurePay> {
private static final long serialVersionUID = 1L;
/**
* id
*/
@Id
@GeneratedValue
@TableId(type = IdType.AUTO)
@ApiModelProperty(value = "编号")
private Integer id;
/**
* 1已支付 2未支付 3已超时
*/
private Integer payStatus;
/**
* 支付金额
*/
private Double amount;
/**
* 支付时间
*/
private Date payTime;
/**
* 超时时间
*/
private Date endTime;
/**
* 支付流水号
*/
private String paySerialNo;
/**
* 支付类型
*/
private String payType;
private Integer policyId;
private String serialNumber;
/**
* 设置:id
*/
public void setId(Integer id) {
this.id = id;
}
/**
* 获取:id
*/
public Integer getId() {
return id;
}
/**
* 设置:1已支付 2未支付 3已超时
*/
public void setPayStatus(Integer payStatus) {
this.payStatus = payStatus;
}
/**
* 获取:1已支付 2未支付 3已超时
*/
public Integer getPayStatus() {
return payStatus;
}
/**
* 设置:支付金额
*/
public void setAmount(Double amount) {
this.amount = amount;
}
/**
* 获取:支付金额
*/
public Double getAmount() {
return amount;
}
/**
* 设置:支付时间
*/
public void setPayTime(Date payTime) {
this.payTime = payTime;
}
/**
* 获取:支付时间
*/
public Date getPayTime() {
return payTime;
}
/**
* 设置:超时时间
*/
public void setEndTime(Date endTime) {
this.endTime = endTime;
}
/**
* 获取:超时时间
*/
public Date getEndTime() {
return endTime;
}
/**
* 设置:支付流水号
*/
public void setPaySerialNo(String paySerialNo) {
this.paySerialNo = paySerialNo;
}
/**
* 获取:支付流水号
*/
public String getPaySerialNo() {
return paySerialNo;
}
/**
* 设置:支付类型
*/
public void setPayType(String payType) {
this.payType = payType;
}
/**
* 获取:支付类型
*/
public String getPayType() {
return payType;
}
}
......@@ -87,7 +87,7 @@ public class InsurePolicy extends Model<InsurePolicy> {
*/
private String totalPremium;
/**
* 1-正常
* 1-正常 2-等待校验 3-失效 4支付中
*/
private String status;
/**
......@@ -117,4 +117,14 @@ public class InsurePolicy extends Model<InsurePolicy> {
private Integer productId;
/**
* 1在线支付 2预付款 3线下支付
*/
private Integer policyPayType;
/**
* insure_pay表的id
*/
private Integer payId;
}
......@@ -70,6 +70,11 @@ public class InsureProduct extends Model<InsureProduct> {
private Integer isDel;
/**
* 1 在线支付 2预付款 3线下支付
*/
private Integer payType;
/**
* 设置:id
*/
public void setId(Integer id) {
......
package cn.timer.api.bean.insure;
import lombok.Data;
/**
* @Description 支付回调
* @Author wgd
* @Date 2022/5/17 15:26
*/
@Data
public class PayCallBack {
private String serial_number;
private String pay_status;
private String pay_serial_no;
private String pay_time;
private String amount;
private String pay_type;
}
package cn.timer.api.bean.insure;
import lombok.Data;
/**
* @Description TODO
* @Author wgd
* @Date 2022/5/20 18:34
*/
@Data
public class PolicyCallBack {
private String status;
private String policy_status;
private String err_msg;
private String policy_no;
private String serial_number;
private String quote_trans_id;
private String serial_no;
private String policy_file;
private String kit_url;
private String total_premium;
}
package cn.timer.api.controller.insure;
import cn.timer.api.bean.insure.CallBack;
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.insure.*;
import cn.timer.api.bean.yggl.YgglMainEmp;
import cn.timer.api.utils.HttpUtils;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
......@@ -25,6 +23,7 @@ import java.io.InputStream;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Random;
/**
* @Description TODO
......@@ -37,18 +36,47 @@ import java.util.Map;
@RequestMapping(value = "/callBack/policy", produces = {"application/json"})
public class CallBackContorll {
private static final Logger log = LoggerFactory.getLogger(CallBackContorll.class);
@Value("${insure.appid}")
private String appid;
@Value("${insure.secret}")
private String secret;
/*保全测试用*/
@Value("${insure.appidq}")
private String appidq;
@Value("${insure.secretq}")
private String secretq;
@Value("${insure.getPolicyUrl}")
private String getPolicyUrl;
@Value("${BASE_API_URL}")
private String base_api_url;
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 = "投保申请回调")
@ApiOperationSupport(order = 2)
private Map insuredCallBack(HttpServletRequest request, @RequestParam String pid, @RequestParam String sign, @RequestParam String timestamp) throws IOException {
Map map = Maps.newHashMap();
map.put("status", "error");
......@@ -77,7 +105,6 @@ public class CallBackContorll {
@PostMapping(value = "/CallBack")
@ApiOperation(value = "7.保全增员申请回调", httpMethod = "POST", notes = "投保申请回调")
@ApiOperationSupport(order = 2)
private Map callBack(HttpServletRequest request, @RequestParam String pid, @RequestParam String sign, @RequestParam String timestamp) throws IOException {
Map map = Maps.newHashMap();
map.put("status", "error");
......@@ -103,6 +130,11 @@ public class CallBackContorll {
paramsMap.put("timestamp", timestamp);
paramsMap.put("sign", sign);
CallBack callBack = JSONObject.parseObject(sb.toString(), CallBack.class);
/*1保全复核回调*/
if (callBack.getCallback_type().equals("1")) {
} else {
/*到这就已经支付成功出单了*/
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));
......@@ -136,7 +168,7 @@ public class CallBackContorll {
List<Map> errMap = callBack.getOrder_import_info().getErr_list();
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() + ',');
errorMsg = errorMsg + ("姓名:" + errMap.get(i).get("name").toString() + ",错误:" + errMap.get(i).get("err_content").toString() + ',');
}
} else {
errorMsg = callBack.getErr_msg();
......@@ -146,9 +178,119 @@ public class CallBackContorll {
.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();
}
}
Map trueMap = Maps.newHashMap();
trueMap.put("status", "1");
return trueMap;
}
@GetMapping(value = "/payStatus")
@ApiOperation(value = "8.支付完成跳转", httpMethod = "GET", notes = "用于支付时跳回我们系统更新状态")
private void callBackPayStatus(HttpServletRequest request, @RequestParam Integer policyId) throws IOException {
log.info("支付完成回调(仅代表用户点了已支付,无法确认是否真正支付)");
InsureLog.builder().type(7).createTime(new Date()).requestType(2).requestPath(base_api_url + "/payStatus?policyId=" + policyId)
.returnCode("suc").returnMsg("用户已支付,等待更新保单状态").policyId(policyId).build().insert();
}
@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();
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));
}
String value = DigestUtils.md5Hex(appid + secret + timestamp + sb.toString());
if (!value.equals(sign)) {
return map;
}
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()));
insurePay.setPayStatus(Integer.parseInt(callBack.getPay_status()));
insurePay.setPaySerialNo(callBack.getPay_serial_no());
insurePay.setSerialNumber(callBack.getSerial_number());
insurePay.setPayType(callBack.getPay_type());
insurePay.updateById();
/*调用出单接口更新保单状态*/
Map bodyMap = Maps.newHashMap();
bodyMap.put("quotation_id", callBack.getSerial_number());
String data = HttpUtils.sendPost(getPolicyUrl, 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"))) {
//TODO 如果是E25则将保单设为出单中,更新交由保单出单回调做,设为出单状态是因为之后可以手动校验
InsurePolicy insurePolicy = InsurePolicy.builder().id(insurePay.getPolicyId()).build().selectById();
insurePolicy.setStatus("2");
insurePolicy.setUpdateTime(new Date());
insurePolicy.updateById();
}
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(getPolicyUrl)
.returnCode(dataMap.get("errcode").toString()).returnMsg("请求出单中").build().insert();
map.put("status", "1");
}
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();
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");
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));
}
String value = DigestUtils.md5Hex(appid + secret + timestamp + sb.toString());
if (!value.equals(sign)) {
return map;
}
PolicyCallBack callBack = JSONObject.parseObject(sb.toString(), PolicyCallBack.class);
InsurePay insurePay = InsurePay.builder().build().selectOne(new QueryWrapper<InsurePay>().lambda().eq(InsurePay::getSerialNumber, callBack.getSerial_number()));
InsurePolicy insurePolicy = InsurePolicy.builder().id(insurePay.getPolicyId()).build().selectById();
List<InsureUser> userList = InsureUser.builder().build().selectList(new QueryWrapper<InsureUser>().lambda().eq(InsureUser::getPolicyId, insurePolicy.getId()));
insurePolicy.setUpdateTime(new Date());
if (callBack.getStatus().equals("1")) {
insurePay.setPayStatus(2);
insurePolicy.setPolicyNo(callBack.getPolicy_no());
insurePolicy.setTotalPremium(callBack.getTotal_premium());
insurePolicy.setPolicyFile(callBack.getPolicy_file());
insurePolicy.setStatus("1");
insurePolicy.setKitUrl(callBack.getKit_url());
userList.forEach(u -> {
u.setStatus("1");
u.setInsureStatus(1);
u.updateById();
});
} else {
insurePay.setPayStatus(3);
insurePolicy.setStatus("3");
userList.forEach(u -> {
u.setStatus("2");
u.setInsureStatus(2);
u.updateById();
});
insurePolicy.updateById();
insurePay.updateById();
}
return map;
}
}
......@@ -26,7 +26,9 @@ import com.google.common.collect.Maps;
import com.google.gson.JsonObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.http.client.utils.URIBuilder;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
......@@ -42,9 +44,7 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
......@@ -83,16 +83,34 @@ public class InsureContorll {
private String appidq;
@Value("${insure.secretq}")
private String secretq;
/*投保上传*/
@Value("${insure.uploadUrl}")
private String uploadUrl;
/*投保*/
@Value("${insure.insuredUrl}")
private String insuredUrl;
/*获取报价*/
@Value("${insure.createQuote}")
private String createQuote;
/*保全上传文件*/
@Value("${insure.uploadUrlq}")
private String uploadUrl2;
/*保全*/
@Value("${insure.batchUrl}")
private String batchUrl;
/*保单号查询*/
@Value("${insure.policyDetail}")
private String policyDetailUrl;
/*投保支付*/
@Value("${insure.toPayUrl}")
private String toPayUrl;
/*保全支付*/
@Value("${insure.batchToPayUrl}")
private String batchToPayUrl;
@Value("${insure.cancelPayment}")
private String cancelPayment;
private static SimpleDateFormat dtf3 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
......@@ -105,8 +123,6 @@ public class InsureContorll {
@Autowired
private InsurePolicyMapper insurePolicyMapper;
@Autowired
private InsureLogMapper insureLogMapper;
/**
......@@ -124,9 +140,13 @@ public class InsureContorll {
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 = appid + secret + timestamp + sign;
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;
......@@ -134,7 +154,7 @@ public class InsureContorll {
@PostMapping(value = "/insured_add")
@ApiOperation(value = "1.投保申请", httpMethod = "POST", notes = "投保申请")
public Result<Object> insured_add(@RequestBody InsureDto insureDto) throws ParseException {
public Result<Object> insured_add(@RequestBody InsureDto insureDto) throws ParseException, URISyntaxException {
InsureProduct insureProduct = InsureProduct.builder().id(Integer.parseInt(insureDto.getProductId())).build().selectById();
if (insureProduct == null) {
return ResultUtil.error("产品不存在");
......@@ -146,6 +166,7 @@ public class InsureContorll {
Map bodyMap = Maps.newHashMap();
ArrayList<Map> quotationsArry = new ArrayList<Map>();
bodyMap.put("is_ss", 0);
bodyMap.put("quotations_method", "1");
Map quotations = Maps.newHashMap();
insureDto.getPlans().forEach(i -> {
i.setPrice(getPrice(i.getBenefitBasicPlan(), i.getBenefitOccupationCategory()));
......@@ -162,9 +183,13 @@ public class InsureContorll {
quotations.put("last_serial_number", "");//*币种:5人民币*//*
quotations.put("from_source", "");//*币种:5人民币*//*
quotations.put("operator_name", "");//*币种:5人民币
if (insureProduct.getPayType() == 1) {
quotations.put("required_pay", 1);
quotations.put("callback_policy",base_api_url+"/callBack/policy/issueCallback");
}
/*企业信息*/
InsureApplicant insureApplicant = InsureApplicant.builder().build().selectOne(new QueryWrapper<InsureApplicant>().lambda().eq(InsureApplicant::getOrgCode,qyzxEntInfoM.getId()));
InsureApplicant insureApplicant = InsureApplicant.builder().build().selectOne(new QueryWrapper<InsureApplicant>().lambda().eq(InsureApplicant::getOrgCode, qyzxEntInfoM.getId()));
if (insureApplicant == null) {
return ResultUtil.error("未设置投保人");
}
......@@ -231,37 +256,38 @@ public class InsureContorll {
quotationsArry.add(quotations);
bodyMap.put("quotations", quotationsArry);
log.info(JSONObject.toJSONString(bodyMap));
String data = HttpUtils.sendPost(insuredUrl, setParams(JSONObject.toJSONString(bodyMap), appid, secret), bodyMap);
String data = HttpUtils.sendPost(insureProduct.getPayType() == 1 ? createQuote : insuredUrl, setParams(JSONObject.toJSONString(bodyMap), appid, secret), bodyMap);
Map dataMap = JSONObject.parseObject(data, Map.class);
if (dataMap != null) {
/*e25这个是预付款出单中状态*/
if ((dataMap.get("errcode").toString().equals("suc")) || (dataMap.get("errcode").toString().equals("e25"))) {
Map policyMap = Maps.newHashMap();
List<Map> batchMap = Lists.newArrayList();
InsurePolicy insurePolicy = InsurePolicy.builder().build();
insurePolicy.setPolicyDateStart(dtf3.parse(insureDto.getPolicyDateStart()));
insurePolicy.setPolicyDateEnd(dtf3.parse(insureDto.getPolicyDateEnd()));
insurePolicy.setType(2);/*年单或者月单*/
insurePolicy.setCurrency("5");
if (dataMap.get("errcode").toString().equals("suc")) {
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);
batchMap = JSONObject.parseObject(JSONObject.toJSONString(policyMap.get("batch")), List.class);
}
InsurePolicy insurePolicy = InsurePolicy.builder().build();
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("4");
}
} else {
insurePolicy.setStatus("2");
}
insurePolicy.setOrgCode(qyzxEntInfoM.getId());
insurePolicy.setCreateTime(date);
insurePolicy.setUpdateTime(date);
insurePolicy.setSchemeName(insureProduct.getName());/*先写死*/
insurePolicy.setSchemeName(insureProduct.getName());
insurePolicy.setTotalPremium(String.valueOf(insureDto.getTotalPrice()));
insurePolicy.setProductId(insureProduct.getId());
insurePolicy.insert();
......@@ -279,8 +305,18 @@ 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) {
insureUser.setBatchNo(batchMap.get(0).get("batch_no").toString());
insureUser.setPolicyNo(policyMap.get("policy_no").toString());
insureUser.setInsureStatus(1);
insureUser.setStatus("1");
}else{
insureUser.setInsureStatus(3);
insureUser.setStatus("2");
}
} else {
insureUser.setInsureStatus(3);
insureUser.setStatus("2");
}
insureUser.setBenefitBasicPlan(p.getBenefitBasicPlan());
insureUser.setUserId(y.getId());
......@@ -291,18 +327,10 @@ public class InsureContorll {
insureUser.setInsuredEContact(y.getName());
insureUser.setApplicantEmployeeList(url);
insureUser.setTricycleFrameNumber(p.getTricycleFrameNumber());
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.setApplyType(2);//投保类型
insureUser.setPolicyId(insurePolicy.getId());
insureUser.insert();
if (dataMap.get("errcode").toString().equals("suc")) {
y.setIsInsure(1);
......@@ -310,6 +338,36 @@ public class InsureContorll {
}
}
}
/*进入在线支付*/
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);
if ((Integer) quotationsMap.get(0).get("quotations_status") == 10 || (Integer) quotationsMap.get(0).get("quotations_status") == 15) {
/*请求收银台*/
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("pay_type", "1");
toPayParamsMap.put("notify_url", base_api_url + "/callBack/policy/payCallBack");
/*生成一个支付链接返回到前台*/
URIBuilder builder = new URIBuilder(toPayUrl);
if (toPayParamsMap != null) {
for (String key : toPayParamsMap.keySet()) {
builder.addParameter(key, toPayParamsMap.get(key));
}
}
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());
return ResultUtil.data(returnMap);
}
}
return ResultUtil.success(dataMap.get("errmsg").toString());
}
return ResultUtil.error(dataMap.get("errmsg").toString());
......@@ -448,7 +506,7 @@ public class InsureContorll {
ygglMainEmpList.forEach(y -> {
try {
InsureUser.builder()
.transId("IS_" + insurePolicy.getOrgCode() + "_" + dtf2.format(now))
.transId(bodyMap.get("third_uuid").toString())
.insuredName(qyzxEntInfoM.getName())
.price(String.valueOf(PlanEnum.getEnum(insureDto.getBenefitBasicPlan(), insureDto.getBenefitOccupationCategory()).getPrice()))/*前端获取的保费*/
.premium(String.valueOf(PlanEnum.getEnum(insureDto.getBenefitBasicPlan(), insureDto.getBenefitOccupationCategory()).getPrice() * insureDto.getUserIds().length))
......@@ -477,9 +535,35 @@ public class InsureContorll {
InsureLog.builder().requestParam(JSONObject.toJSONString(setParams(JSONObject.toJSONString(bodyMap), appid, secret))).type(2)
.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()).fileUrl(url).build().insert();
/*如果是在线支付的话*/
InsureProduct insureProduct = InsureProduct.builder().id(insurePolicy.getProductId()).build().selectById();
if(insureProduct.getPayType()==1){
log.info("当前订单为见费出单---进入支付页面");
Map payMap = Maps.newHashMap();
payMap.put("order_import_uuid",orderImportInfo.get("uuid"));
String returnPay = HttpUtils.sendPost(batchToPayUrl, setParams(JSONObject.toJSONString(payMap), appidq, secretq), payMap);
Map<String, Object> payDataMap = JSONObject.parseObject(returnPay);
Map<String, Object> payData = JSONObject.parseObject(JSONObject.toJSONString(payDataMap.get("data")));
Map<String, Object> importPayInfo = JSONObject.parseObject(JSONObject.toJSONString(payData.get("import_pay_info")));
InsurePay insurePay= InsurePay.builder()
.payStatus(Integer.parseInt(importPayInfo.get("pay_status").toString())).policyId(insurePolicy.getId())
.amount(Double.parseDouble(importPayInfo.get("pay_money").toString()))
.payType(importPayInfo.get("pay_type").toString())
.serialNumber(importPayInfo.get("order_import_uuid").toString())
.paySerialNo(importPayInfo.get("pay_serial_no").toString()).build();
insurePay.insert();
insurePolicy.setPayId(insurePay.getId());
insurePolicy.setStatus("4");/*支付中状态*/
insurePolicy.updateById();
Map returnMap = Maps.newHashMap();
returnMap.put("url",importPayInfo.get("pay_url").toString());
returnMap.put("payId",insurePay.getId());
return ResultUtil.data(returnMap);
}else {
return ResultUtil.data("核保成功,等待系统更新");
}
}
}
InsureLog.builder().requestParam(JSONObject.toJSONString(setParams(JSONObject.toJSONString(bodyMap), appid, secret))).type(2)
.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();
......@@ -593,12 +677,12 @@ public class InsureContorll {
return ResultUtil.error("保单不存在");
}
/*单个替换*/
if(insureDto.getLimit()==1){
if(!StringUtils.isNullOrEmpty(insureDto.getUserName())&&!StringUtils.isNullOrEmpty(insureDto.getIdCardNo())){
if (insureDto.getLimit() == 1) {
if (!StringUtils.isNullOrEmpty(insureDto.getUserName()) && !StringUtils.isNullOrEmpty(insureDto.getIdCardNo())) {
YgglMainEmp y = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().lambda()
.eq(YgglMainEmp::getName,insureDto.getUserName()).eq(YgglMainEmp::getZjNum,insureDto.getIdCardNo()));
if(y==null){
y=new YgglMainEmp();
.eq(YgglMainEmp::getName, insureDto.getUserName()).eq(YgglMainEmp::getZjNum, insureDto.getIdCardNo()));
if (y == null) {
y = new YgglMainEmp();
y.setName(insureDto.getUserName());
y.setZjType(0);
y.setZjNum(insureDto.getIdCardNo());
......@@ -782,7 +866,7 @@ public class InsureContorll {
break;
case "36969":
if (type.equals("63119")) {
return PlanEnum.A_30.getPrice();
return PlanEnum.A_50.getPrice();
} else if (type.equals("63120")) {
return PlanEnum.B_50.getPrice();
} else if (type.equals("63121")) {
......@@ -881,9 +965,9 @@ public class InsureContorll {
@PostMapping(value = "/policyTotalList")
@ApiOperation(value = "11.保单统计列表 -- 8小时端", httpMethod = "POST", notes = "保单统计列表")
public Result<Object> policyTotal(@CurrentUser UserBean userBean) {
Map map=Maps.newHashMap();
Map map = Maps.newHashMap();
List<InsureUserDto> list = insurePolicyMapper.selectPlansListByorgCode(userBean.getOrgCode());
map.put("list",list);
map.put("list", list);
return ResultUtil.data(map);
}
......@@ -900,8 +984,8 @@ public class InsureContorll {
return ResultUtil.error("请上传文件");
}
List<YgglMainEmp> yg = Lists.newArrayList();
List<YgglMainEmp> selectUserList=Lists.newArrayList();
List<YgglMainEmp> allList=Lists.newArrayList();
List<YgglMainEmp> selectUserList = Lists.newArrayList();
List<YgglMainEmp> allList = Lists.newArrayList();
try {
XSSFWorkbook xw = new XSSFWorkbook(file.getInputStream());
XSSFSheet sheetAt = xw.getSheetAt(0);
......@@ -974,8 +1058,8 @@ public class InsureContorll {
if (newList.size() > 0) {
newList.forEach(u -> u.insert());
}
allList=ygglMainEmpMapper.selectListByIZjNum(yg.stream().map(YgglMainEmp::getZjNum).toArray(String[]::new),company.getId());
selectUserList=allList.stream().filter(s->s.getIsInsure()==0).collect(Collectors.toList());
allList = ygglMainEmpMapper.selectListByIZjNum(yg.stream().map(YgglMainEmp::getZjNum).toArray(String[]::new), company.getId());
selectUserList = allList.stream().filter(s -> s.getIsInsure() == 0).collect(Collectors.toList());
//假期规则初始化
String current_time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
List<KqglAssoLeaveRules> rul = KqglAssoLeaveRules.builder().build().selectList(new QueryWrapper<KqglAssoLeaveRules>().lambda().eq(KqglAssoLeaveRules::getOrgCode, orgCode));
......@@ -983,9 +1067,9 @@ public class InsureContorll {
} catch (IOException e) {
e.printStackTrace();
}
List<String> message =allList.stream().filter(s->s.getIsInsure()==1).map(YgglMainEmp::getName).collect(Collectors.toList());
if(message.size()>0){
return ResultUtil.data(selectUserList, JSONObject.toJSONString(message)+"已投过保");
List<String> message = allList.stream().filter(s -> s.getIsInsure() == 1).map(YgglMainEmp::getName).collect(Collectors.toList());
if (message.size() > 0) {
return ResultUtil.data(selectUserList, JSONObject.toJSONString(message) + "已投过保");
}
return ResultUtil.data(selectUserList, "导入成功");
}
......@@ -1002,8 +1086,8 @@ public class InsureContorll {
return ResultUtil.error("请上传文件");
}
List<YgglMainEmp> yg = Lists.newArrayList();
List<YgglMainEmp> selectUserList=Lists.newArrayList();
List<YgglMainEmp> allList=Lists.newArrayList();
List<YgglMainEmp> selectUserList = Lists.newArrayList();
List<YgglMainEmp> allList = Lists.newArrayList();
try {
XSSFWorkbook xw = new XSSFWorkbook(file.getInputStream());
XSSFSheet sheetAt = xw.getSheetAt(0);
......@@ -1076,8 +1160,8 @@ public class InsureContorll {
if (newList.size() > 0) {
newList.forEach(u -> u.insert());
}
allList=ygglMainEmpMapper.selectListByIZjNum(yg.stream().map(YgglMainEmp::getZjNum).toArray(String[]::new),company.getId());
selectUserList=allList.stream().filter(s->s.getIsInsure()==0).collect(Collectors.toList());
allList = ygglMainEmpMapper.selectListByIZjNum(yg.stream().map(YgglMainEmp::getZjNum).toArray(String[]::new), company.getId());
selectUserList = allList.stream().filter(s -> s.getIsInsure() == 0).collect(Collectors.toList());
//假期规则初始化
String current_time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
List<KqglAssoLeaveRules> rul = KqglAssoLeaveRules.builder().build().selectList(new QueryWrapper<KqglAssoLeaveRules>().lambda().eq(KqglAssoLeaveRules::getOrgCode, userBean.getOrgCode()));
......@@ -1085,15 +1169,14 @@ public class InsureContorll {
} catch (IOException e) {
e.printStackTrace();
}
List<String> message =allList.stream().filter(s->s.getIsInsure()==1).map(YgglMainEmp::getName).collect(Collectors.toList());
if(message.size()>0){
return ResultUtil.data(selectUserList, JSONObject.toJSONString(message)+"已投过保");
List<String> message = allList.stream().filter(s -> s.getIsInsure() == 1).map(YgglMainEmp::getName).collect(Collectors.toList());
if (message.size() > 0) {
return ResultUtil.data(selectUserList, JSONObject.toJSONString(message) + "已投过保");
}
return ResultUtil.data(selectUserList, "导入成功");
}
@PostMapping(value = "/importPolicy")
@ApiOperation(value = "导入保单--运营后台", httpMethod = "POST", notes = "导入用户")
public Result<Object> importPolicy(@RequestParam("file") MultipartFile file, @RequestParam("productId") String productId) {
......@@ -1123,9 +1206,9 @@ public class InsureContorll {
for (int index = 0; index < row.getPhysicalNumberOfCells(); index++) {
XSSFCell titleCell = titleRow.getCell(index);
XSSFCell cell = row.getCell(index);
if(cell==null){
if (cell == null) {
continue;
}else {
} else {
cell.setCellType(CellType.STRING);
}
switch (ExcelUtils.getString(titleCell)) {
......@@ -1250,7 +1333,12 @@ public class InsureContorll {
.eq(YgglMainEmp::getName, insureUser.getInsuredEContact())
.eq(YgglMainEmp::getZjNum, insureUser.getInsuredNo())
.eq(YgglMainEmp::getOrgCode, insureUser.getOrgCode()));
if (ygglMainEmp != null) {
/*如果导入的人已经投保*/
if(ygglMainEmp.getIsInsure()==1){
continue;
}
insureUser.setInsuredMobile(ygglMainEmp.getPhone());
} else {
/*如果不存在员工就创建一名员工*/
......@@ -1280,19 +1368,19 @@ public class InsureContorll {
@PostMapping(value = "/importUserPolicy")
@ApiOperation(value = "导入被保人员--运营后台", httpMethod = "POST", notes = "导入用户")
public Result<Object> importUserPolicy(@RequestParam("file") MultipartFile file,@RequestParam("orgCode") Integer orgCode) {
if(file.getSize()<=0){
public Result<Object> importUserPolicy(@RequestParam("file") MultipartFile file, @RequestParam("orgCode") Integer orgCode) {
if (file.getSize() <= 0) {
return ResultUtil.error("未上传文件");
}
if(orgCode==null){
if (orgCode == null) {
return ResultUtil.error("企业不存在");
}
QyzxEntInfoM qyzxEntInfoM = QyzxEntInfoM.builder().id(orgCode).build().selectById();
if(qyzxEntInfoM==null){
if (qyzxEntInfoM == null) {
return ResultUtil.error("企业不存在");
}
XSSFWorkbook xw = null;
Map<String,String> map = Maps.newHashMap();
Map<String, String> map = Maps.newHashMap();
try {
xw = new XSSFWorkbook(file.getInputStream());
XSSFSheet sheetAt = xw.getSheetAt(0);
......@@ -1311,30 +1399,30 @@ public class InsureContorll {
cell.setCellType(CellType.STRING);
switch (ExcelUtils.getString(titleCell)) {
case "被保人姓名(必填)":
if(StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))){
return ResultUtil.error("第"+i+"行第"+index+"列被保人姓名不能为空");
if (StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))) {
return ResultUtil.error("第" + i + "行第" + index + "列被保人姓名不能为空");
}
user.setInsuredEContact(ExcelUtils.getString(cell));
break;
case "被保人身份证(必填)":
if(StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))){
return ResultUtil.error("第"+i+"行第"+index+"列被保人身份证不能为空");
if (StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))) {
return ResultUtil.error("第" + i + "行第" + index + "列被保人身份证不能为空");
}
user.setInsuredNo(ExcelUtils.getString(cell));
break;
case "基础计划":
if(ExcelUtils.getString(cell).equals("30万意外/3万医疗/扩展24小时")){
if (ExcelUtils.getString(cell).equals("30万意外/3万医疗/扩展24小时")) {
user.setBenefitBasicPlan("36968");
}else if (ExcelUtils.getString(cell).equals("50万意外/5万医疗/扩展24小时")) {
} else if (ExcelUtils.getString(cell).equals("50万意外/5万医疗/扩展24小时")) {
user.setBenefitBasicPlan("36969");
}else if (ExcelUtils.getString(cell).equals("80万意外/10万医疗/扩展24小时")) {
} else if (ExcelUtils.getString(cell).equals("80万意外/10万医疗/扩展24小时")) {
user.setBenefitBasicPlan("36970");
}else if (ExcelUtils.getString(cell).equals("80万雇主/20万医疗/扩展24小时")) {
} else if (ExcelUtils.getString(cell).equals("80万雇主/20万医疗/扩展24小时")) {
user.setBenefitBasicPlan("36971");
}else if (ExcelUtils.getString(cell).equals("100万意外/10万医疗/扩展24小时")) {
} else if (ExcelUtils.getString(cell).equals("100万意外/10万医疗/扩展24小时")) {
user.setBenefitBasicPlan("36972");
}else{
return ResultUtil.error("第"+i+"行第"+index+"基础计划不能为空");
} else {
return ResultUtil.error("第" + i + "行第" + index + "基础计划不能为空");
}
break;
case "职业类型":
......@@ -1347,17 +1435,17 @@ public class InsureContorll {
}
break;
case "二、三轮车车架号":
user.setTricycleFrameNumber(StringUtils.isNullOrEmpty(ExcelUtils.getString(cell))==true?"无":ExcelUtils.getString(cell));
user.setTricycleFrameNumber(StringUtils.isNullOrEmpty(ExcelUtils.getString(cell)) == true ? "无" : ExcelUtils.getString(cell));
break;
}
}
userList.add(user);
}
YgglMainEmp y;
for(InsureUser iu:userList){
y = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getZjNum,iu.getInsuredNo())
.eq(YgglMainEmp::getName,iu.getInsuredEContact()).eq(YgglMainEmp::getOrgCode,qyzxEntInfoM.getId()));
if(y==null){
for (InsureUser iu : userList) {
y = YgglMainEmp.builder().build().selectOne(new QueryWrapper<YgglMainEmp>().lambda().eq(YgglMainEmp::getZjNum, iu.getInsuredNo())
.eq(YgglMainEmp::getName, iu.getInsuredEContact()).eq(YgglMainEmp::getOrgCode, qyzxEntInfoM.getId()));
if (y == null) {
y = new YgglMainEmp();
y.setName(iu.getInsuredEContact());
y.setZjType(0);
......@@ -1365,9 +1453,9 @@ public class InsureContorll {
y.setOrgCode(qyzxEntInfoM.getId());
y.setIsInsure(0);
y.insert();
}else{
if(y.getIsInsure()==1){
return ResultUtil.error(y.getName()+"已经投保");
} else {
if (y.getIsInsure() == 1) {
return ResultUtil.error(y.getName() + "已经投保");
}
}
iu.setOrgCode(qyzxEntInfoM.getId());
......@@ -1379,4 +1467,107 @@ public class InsureContorll {
}
return ResultUtil.error("导入失败");
}
@GetMapping(value = "/rePay")
@ApiOperation(value = "重新发起支付", httpMethod = "GET", notes = "重新发起支付")
public Result<Object> rePay(@RequestParam("payId")Integer payId){
InsurePay insurePay = InsurePay.builder().id(payId).build().selectById();
if(insurePay==null){
return ResultUtil.error("保单不存在");
}
if(insurePay.getPayStatus()!=1){
return ResultUtil.error("保单不是支付状态");
}
InsurePolicy insurePolicy = InsurePolicy.builder().id(insurePay.getPolicyId()).build().selectById();
Map<String, String> toPayParamsMap=Maps.newHashMap();
/*判断是投保还是保全,投保支付前是没有保单号的*/
if(StringUtils.isNullOrEmpty(insurePolicy.getPolicyNo())) {
/*投保支付*/
toPayParamsMap = setParams(null, appid, secret);
toPayParamsMap.put("serial_number", insurePay.getSerialNumber());
toPayParamsMap.put("jump_url", base_api_url + "/callBack/policy/payStatus?policyId=" + insurePay.getPolicyId());
toPayParamsMap.put("pay_type", "1");
toPayParamsMap.put("notify_url", base_api_url + "/callBack/policy/payCallBack");
/*生成一个支付链接返回到前台*/
URIBuilder builder = null;
try {
builder = new URIBuilder(toPayUrl);
if (toPayParamsMap != null) {
for (String key : toPayParamsMap.keySet()) {
builder.addParameter(key, toPayParamsMap.get(key));
}
}
return ResultUtil.data(builder.build());
} catch (URISyntaxException e) {
e.printStackTrace();
return ResultUtil.error("请求错误");
}
}else{
/*保全支付*/
toPayParamsMap = setParams(batchToPayUrl, appidq, secretq);
toPayParamsMap.put("order_import_uuid", insurePay.getSerialNumber());
String returnPay = HttpUtils.sendPost(batchToPayUrl, setParams(JSONObject.toJSONString(toPayParamsMap), appidq, secretq), toPayParamsMap);
Map<String, Object> payDataMap = JSONObject.parseObject(returnPay);
Map<String, Object> payData = JSONObject.parseObject(JSONObject.toJSONString(payDataMap.get("data")));
Map<String, Object> importPayInfo = JSONObject.parseObject(JSONObject.toJSONString(payData.get("import_pay_info")));
if(!insurePay.getPaySerialNo().equals(importPayInfo.get("pay_serial_no").toString())&&!insurePay.getSerialNumber().equals(importPayInfo.get("order_import_uuid").toString())){
insurePay.setPaySerialNo(importPayInfo.get("pay_serial_no").toString());
insurePay.setSerialNumber(importPayInfo.get("order_import_uuid").toString());
insurePay.updateById();
}
return ResultUtil.data(importPayInfo.get("pay_url").toString());
}
// String data = HttpUtils.sendGet(setParams())
};
@GetMapping(value = "/cePay")
@ApiOperation(value = "取消支付", httpMethod = "GET", notes = "取消支付")
public Result<Object> cancelPay(@RequestParam("payId")Integer payId){
InsurePay insurePay = InsurePay.builder().id(payId).build().selectById();
if(insurePay==null){
return ResultUtil.error("保单不存在");
}
if(insurePay.getPayStatus()!=1){
return ResultUtil.error("保单不是支付状态");
}
InsurePolicy insurePolicy = InsurePolicy.builder().id(insurePay.getPolicyId()).build().selectById();
//TODO 验证保单的状态
long timestamp = System.currentTimeMillis() / 1000;
Map map = Maps.newHashMap();
map.put("pid", appidq);
// map.put("sign", DigestUtils.md5Hex(appid + secret + timestamp));
// map.put("timestamp", String.valueOf(timestamp));
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());
String data = HttpUtils.sendGet(cancelPayment, map);
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")){
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()));
/*取消成功*/
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");
insurePolicy.setPayId(null);
insurePolicy.updateById();
ygglMainEmpMapper.updateInsure(userList.stream().map(InsureUser::getUserId).toArray(Integer[]::new));
return ResultUtil.success("取消成功");
}
}
/*生成一个支付链接返回到前台*/
return ResultUtil.error("取消失败,请重新再来");
}
}
package cn.timer.api.controller.insure;
import cn.timer.api.bean.insure.InsurePay;
import cn.timer.api.bean.insure.InsurePolicy;
import cn.timer.api.dao.insure.InsureUserMapper;
import cn.timer.api.utils.Result;
import cn.timer.api.utils.ResultUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* 支付流水表
*
* @author wgd
* @email 862422848@qq.com
* @date 2022-05-18 19:33:23
*/
@RestController
@RequestMapping("/insurePay")
public class InsurePayController{
@Autowired
private InsureUserMapper insureUserMapper;
@Value("${insure.appid}")
private String appid;
@Value("${insure.secret}")
private String secret;
@Value("${insure.appidq}")
private String appidq;
@Value("${insure.secretq}")
private String secretq;
/*投保支付*/
@Value("${insure.toPayUrl}")
private String toPayUrl;
@GetMapping(value = "/cancelPayment")
@ApiOperation(value = "取消支付", httpMethod = "GET", notes = "取消支付")
public Result<Object> cancelPayment(@RequestParam(required = true,value = "policyId")Integer policyId){
InsurePolicy insurePolicy = InsurePolicy.builder().id(policyId).build().selectById();
if(insurePolicy==null){
return ResultUtil.error("保单不存在");
}
if("4".equals(insurePolicy.getStatus())){
return ResultUtil.error("保单不是未支付状态");
}
// String data = HttpUtils.sendGet(setParams())
return null;
};
}
package cn.timer.api.dao.insure;
import cn.timer.api.bean.insure.InsurePay;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;
/**
* 支付流水表
*
* @author wgd
* @email 862422848@qq.com
* @date 2022-05-18 19:33:23
*/
@Repository
public interface InsurePayMapper extends BaseMapper<InsurePay> {
}
......@@ -38,6 +38,6 @@ public class InsureDto {
private String userName;
private String idCardNo;
private String reason;/*批改原因*/
private Integer payType=1;/*支付方式 默认是在线支付*/
// private String
}
......@@ -40,5 +40,7 @@ public class PolicyDto {
private String planId;
private String categoryId;
private String productId;
private Integer policyPayType;
private Integer payId;
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.timer.api.dao.insure.InsurePayMapper">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="cn.timer.api.bean.insure.InsurePay" id="insurePayMap">
<result property="id" column="id"/>
<result property="payStatus" column="pay_status"/>
<result property="amount" column="amount"/>
<result property="payTime" column="pay_time"/>
<result property="endTime" column="end_time"/>
<result property="paySerialNo" column="pay_serial_no"/>
<result property="payType" column="pay_type"/>
<result property="policyId" column="policy_id"/>
<result property="serialNumber" column="serial_number"/>
</resultMap>
<select id="queryObject" resultType="cn.timer.api.bean.insure.InsurePay">
select *
from insure_pay
where id = #{value}
</select>
<select id="queryList" resultType="cn.timer.api.bean.insure.InsurePay">
select * from insure_pay
<where>
<if test="id != null and id != ''">AND `id` = #{id}</if>
<if test="payStatus != null and payStatus != ''">AND `pay_status` = #{payStatus}</if>
<if test="amount != null and amount != ''">AND `amount` = #{amount}</if>
<if test="payTime != null and payTime != ''">AND `pay_time` = #{payTime}</if>
<if test="endTime != null and endTime != ''">AND `end_time` = #{endTime}</if>
<if test="paySerialNo != null and paySerialNo != ''">AND `pay_serial_no` = #{paySerialNo}</if>
<if test="payType != null and payType != ''">AND `pay_type` = #{payType}</if>
</where>
<choose>
<when test="sidx != null and sidx.trim() != ''">
order by ${sidx} ${order}
</when>
<otherwise>
order by id desc
</otherwise>
</choose>
<if test="offset != null and limit != null">
limit #{offset}, #{limit}
</if>
</select>
<select id="queryTotal" resultType="int">
select count(*) from insure_pay
<where>
<if test="id != null and id != ''">AND `id` = #{id}</if>
<if test="payStatus != null and payStatus != ''">AND `pay_status` = #{payStatus}</if>
<if test="amount != null and amount != ''">AND `amount` = #{amount}</if>
<if test="payTime != null and payTime != ''">AND `pay_time` = #{payTime}</if>
<if test="endTime != null and endTime != ''">AND `end_time` = #{endTime}</if>
<if test="paySerialNo != null and paySerialNo != ''">AND `pay_serial_no` = #{paySerialNo}</if>
<if test="payType != null and payType != ''">AND `pay_type` = #{payType}</if>
</where>
</select>
<insert id="save" parameterType="cn.timer.api.bean.insure.InsurePay">
insert into insure_pay
(`id`,
`pay_status`,
`amount`,
`pay_time`,
`end_time`,
`pay_serial_no`,
`pay_type`)
values (#{id},
#{payStatus},
#{amount},
#{payTime},
#{endTime},
#{paySerialNo},
#{payType})
</insert>
<insert id="saveSelective" parameterType="cn.timer.api.bean.insure.InsurePay">
insert into insure_pay
(
<if test="id != null">`id`</if>
<if test="payStatus != null">,`pay_status`</if>
<if test="amount != null">,`amount`</if>
<if test="payTime != null">,`pay_time`</if>
<if test="endTime != null">,`end_time`</if>
<if test="paySerialNo != null">,`pay_serial_no`</if>
<if test="payType != null">,`pay_type`</if>
)
values
(
<if test="id != null">#{id}</if>
<if test="payStatus != null">,#{payStatus}</if>
<if test="amount != null">,#{amount}</if>
<if test="payTime != null">,#{payTime}</if>
<if test="endTime != null">,#{endTime}</if>
<if test="paySerialNo != null">,#{paySerialNo}</if>
<if test="payType != null">,#{payType}</if>
)
</insert>
<insert id="saveList" parameterType="cn.timer.api.bean.insure.InsurePay">
insert into insure_pay
(
`id`,
`pay_status`,
`amount`,
`pay_time`,
`end_time`,
`pay_serial_no`,
`pay_type`
)
values
<foreach collection="list" item="item" index="index" separator=",">
(
#{item.id},
#{item.payStatus},
#{item.amount},
#{item.payTime},
#{item.endTime},
#{item.paySerialNo},
#{item.payType}
)
</foreach>
</insert>
<update id="update" parameterType="cn.timer.api.bean.insure.InsurePay">
update insure_pay
<set>
<if test="payStatus != null">`pay_status` = #{payStatus},</if>
<if test="amount != null">`amount` = #{amount},</if>
<if test="payTime != null">`pay_time` = #{payTime},</if>
<if test="endTime != null">`end_time` = #{endTime},</if>
<if test="paySerialNo != null">`pay_serial_no` = #{paySerialNo},</if>
<if test="payType != null">`pay_type` = #{payType}</if>
</set>
where id = #{id}
</update>
<delete id="delete">
delete
from insure_pay
where id = #{value}
</delete>
<delete id="deleteBatch">
delete from insure_pay where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
......@@ -23,6 +23,8 @@
<result property="orgCode" column="org_code"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
<result property="policyPayType" column="policy_pay_type"/>
<result property="payId" column="pa_id"/>
</resultMap>
<select id="queryObject" resultType="cn.timer.api.bean.insure.InsurePolicy">
......@@ -244,7 +246,8 @@
sum(iu.price) AS totalPremium,
ip.update_time AS updateTime,
ip.`status` as `status`,
ip.org_code as orgCode
ip.org_code as orgCode,
ip.pay_id as payId
FROM
insure_policy ip
LEFT JOIN insure_user iu ON iu.policy_id = ip.id
......@@ -303,7 +306,9 @@
ip.org_code as orgCode,
iu.insured_name as insuredName,
iu.benefit_basic_plan as benefitBasicPlan,
iu.benefit_occupation_category as benefitOccupationCategory
iu.benefit_occupation_category as benefitOccupationCategory,
ip.policy_pay_type as policyPayType,
ip.product_id as productId
FROM
insure_policy ip
LEFT JOIN insure_user iu ON iu.policy_id = ip.id
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.core.db.dao.InsureProductMapper">
<mapper namespace="cn.timer.api.dao.insure.InsureProductMapper">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="cn.timer.api.bean.insure.InsureProduct" id="insureProductMap">
......@@ -12,6 +12,7 @@
<result property="type" column="type"/>
<result property="createTime" column="create_time"/>
<result property="isDel" column="is_del"/>
<result property="payType" column="pay_type"/>
</resultMap>
<select id="queryObject" resultType="cn.timer.api.bean.insure.InsureProduct">
......
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