|
@@ -1,51 +1,48 @@
|
|
package com.jpsoft.picc.modules.auth.controller;
|
|
package com.jpsoft.picc.modules.auth.controller;
|
|
|
|
|
|
-import cn.hutool.core.date.DateUnit;
|
|
|
|
import com.github.pagehelper.Page;
|
|
import com.github.pagehelper.Page;
|
|
import com.jpsoft.picc.modules.auth.dto.AcceptInsuranceDTO;
|
|
import com.jpsoft.picc.modules.auth.dto.AcceptInsuranceDTO;
|
|
import com.jpsoft.picc.modules.auth.dto.InsuranceApplicationDTO;
|
|
import com.jpsoft.picc.modules.auth.dto.InsuranceApplicationDTO;
|
|
import com.jpsoft.picc.modules.auth.dto.InsuranceJobsDTO;
|
|
import com.jpsoft.picc.modules.auth.dto.InsuranceJobsDTO;
|
|
import com.jpsoft.picc.modules.base.entity.*;
|
|
import com.jpsoft.picc.modules.base.entity.*;
|
|
import com.jpsoft.picc.modules.base.service.*;
|
|
import com.jpsoft.picc.modules.base.service.*;
|
|
-import com.jpsoft.picc.modules.business.dao.InsurancePolicyDAO;
|
|
|
|
import com.jpsoft.picc.modules.business.entity.ApplicationPolicy;
|
|
import com.jpsoft.picc.modules.business.entity.ApplicationPolicy;
|
|
import com.jpsoft.picc.modules.business.entity.InsuranceApplication;
|
|
import com.jpsoft.picc.modules.business.entity.InsuranceApplication;
|
|
import com.jpsoft.picc.modules.business.entity.InsurancePolicy;
|
|
import com.jpsoft.picc.modules.business.entity.InsurancePolicy;
|
|
-import com.jpsoft.picc.modules.business.entity.InsurancePolicyMember;
|
|
|
|
import com.jpsoft.picc.modules.business.service.ApplicationPolicyService;
|
|
import com.jpsoft.picc.modules.business.service.ApplicationPolicyService;
|
|
import com.jpsoft.picc.modules.business.service.InsuranceApplicationService;
|
|
import com.jpsoft.picc.modules.business.service.InsuranceApplicationService;
|
|
import com.jpsoft.picc.modules.business.service.InsurancePolicyMemberService;
|
|
import com.jpsoft.picc.modules.business.service.InsurancePolicyMemberService;
|
|
import com.jpsoft.picc.modules.business.service.InsurancePolicyService;
|
|
import com.jpsoft.picc.modules.business.service.InsurancePolicyService;
|
|
|
|
+import com.jpsoft.picc.config.JpCloudConfig;
|
|
import com.jpsoft.picc.modules.common.constant.PolicyStatus;
|
|
import com.jpsoft.picc.modules.common.constant.PolicyStatus;
|
|
import com.jpsoft.picc.modules.common.dto.MessageResult;
|
|
import com.jpsoft.picc.modules.common.dto.MessageResult;
|
|
import com.jpsoft.picc.modules.common.dto.Sort;
|
|
import com.jpsoft.picc.modules.common.dto.Sort;
|
|
import com.jpsoft.picc.modules.common.utils.PojoUtils;
|
|
import com.jpsoft.picc.modules.common.utils.PojoUtils;
|
|
|
|
+import com.jpsoft.picc.modules.common.utils.SignUtil;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.jasig.cas.client.authentication.AttributePrincipal;
|
|
import org.jasig.cas.client.authentication.AttributePrincipal;
|
|
import org.joda.time.DateTime;
|
|
import org.joda.time.DateTime;
|
|
import org.joda.time.Interval;
|
|
import org.joda.time.Interval;
|
|
-import org.joda.time.Period;
|
|
|
|
-import org.slf4j.Logger;
|
|
|
|
-import org.slf4j.LoggerFactory;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.format.annotation.DateTimeFormat;
|
|
import org.springframework.format.annotation.DateTimeFormat;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
-import java.text.SimpleDateFormat;
|
|
|
|
|
|
+import java.net.URLEncoder;
|
|
|
|
+import java.security.Policy;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
|
|
|
+@Slf4j
|
|
@Api(description="投保信息")
|
|
@Api(description="投保信息")
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping("/auth/insuranceApplication")
|
|
@RequestMapping("/auth/insuranceApplication")
|
|
public class InsuranceApplicationController {
|
|
public class InsuranceApplicationController {
|
|
- private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
-
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private InsuranceApplicationService insuranceApplicationService;
|
|
private InsuranceApplicationService insuranceApplicationService;
|
|
|
|
|
|
@@ -73,6 +70,12 @@ public class InsuranceApplicationController {
|
|
@Autowired
|
|
@Autowired
|
|
private ApplicationPolicyService applicationPolicyService;
|
|
private ApplicationPolicyService applicationPolicyService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private JpCloudConfig jpCloudConfig;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private TransactionRecordService transactionRecordService;
|
|
|
|
+
|
|
@ApiOperation(value="投保单列表")
|
|
@ApiOperation(value="投保单列表")
|
|
@RequestMapping(value = "pageList",method = RequestMethod.POST)
|
|
@RequestMapping(value = "pageList",method = RequestMethod.POST)
|
|
@ApiImplicitParams({
|
|
@ApiImplicitParams({
|
|
@@ -125,7 +128,7 @@ public class InsuranceApplicationController {
|
|
msgResult.setResult(true);
|
|
msgResult.setResult(true);
|
|
}
|
|
}
|
|
catch(Exception ex){
|
|
catch(Exception ex){
|
|
- logger.error(ex.getMessage(),ex);
|
|
|
|
|
|
+ log.error(ex.getMessage(),ex);
|
|
|
|
|
|
msgResult.setResult(false);
|
|
msgResult.setResult(false);
|
|
msgResult.setMessage(ex.getMessage());
|
|
msgResult.setMessage(ex.getMessage());
|
|
@@ -214,7 +217,7 @@ public class InsuranceApplicationController {
|
|
msgResult.setResult(true);
|
|
msgResult.setResult(true);
|
|
}
|
|
}
|
|
catch(Exception ex){
|
|
catch(Exception ex){
|
|
- logger.error(ex.getMessage(),ex);
|
|
|
|
|
|
+ log.error(ex.getMessage(),ex);
|
|
|
|
|
|
msgResult.setResult(false);
|
|
msgResult.setResult(false);
|
|
msgResult.setMessage(ex.getMessage());
|
|
msgResult.setMessage(ex.getMessage());
|
|
@@ -309,7 +312,7 @@ public class InsuranceApplicationController {
|
|
msgResult.setResult(true);
|
|
msgResult.setResult(true);
|
|
}
|
|
}
|
|
catch(Exception ex){
|
|
catch(Exception ex){
|
|
- logger.error(ex.getMessage(),ex);
|
|
|
|
|
|
+ log.error(ex.getMessage(),ex);
|
|
|
|
|
|
msgResult.setResult(false);
|
|
msgResult.setResult(false);
|
|
msgResult.setMessage(ex.getMessage());
|
|
msgResult.setMessage(ex.getMessage());
|
|
@@ -387,7 +390,7 @@ public class InsuranceApplicationController {
|
|
msgResult.setResult(true);
|
|
msgResult.setResult(true);
|
|
}
|
|
}
|
|
catch(Exception ex){
|
|
catch(Exception ex){
|
|
- logger.error(ex.getMessage(),ex);
|
|
|
|
|
|
+ log.error(ex.getMessage(),ex);
|
|
|
|
|
|
msgResult.setResult(false);
|
|
msgResult.setResult(false);
|
|
msgResult.setMessage(ex.getMessage());
|
|
msgResult.setMessage(ex.getMessage());
|
|
@@ -451,7 +454,7 @@ public class InsuranceApplicationController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch(Exception ex){
|
|
catch(Exception ex){
|
|
- logger.error(ex.getMessage(),ex);
|
|
|
|
|
|
+ log.error(ex.getMessage(),ex);
|
|
|
|
|
|
msgResult.setResult(false);
|
|
msgResult.setResult(false);
|
|
msgResult.setMessage(ex.getMessage());
|
|
msgResult.setMessage(ex.getMessage());
|
|
@@ -489,7 +492,117 @@ public class InsuranceApplicationController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch(Exception ex){
|
|
catch(Exception ex){
|
|
- logger.error(ex.getMessage(),ex);
|
|
|
|
|
|
+ log.error(ex.getMessage(),ex);
|
|
|
|
+
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return msgResult;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @PostMapping(value="changeStatus")
|
|
|
|
+ @ApiOperation(value = "修改投保单状态(测试用)")
|
|
|
|
+ @ApiImplicitParams({
|
|
|
|
+ @ApiImplicitParam(name = "applicationId",value = "投保单编号", required = true, paramType = "form"),
|
|
|
|
+ @ApiImplicitParam(name = "status",value = "状态:草稿10/已退回15/待初审20/待复审30/待缴费40/待制单50/待出单60/已出单70/已过期100", required = true, paramType = "form"),
|
|
|
|
+ })
|
|
|
|
+ public MessageResult<String> changeStatus(String applicationId,String status){
|
|
|
|
+ MessageResult<String> messageResult = new MessageResult<>();
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ //todo
|
|
|
|
+ InsuranceApplication insuranceApplication = insuranceApplicationService.get(applicationId);
|
|
|
|
+ insuranceApplication.setStatus(status);
|
|
|
|
+ insuranceApplication.setUpdateTime(new Date());
|
|
|
|
+
|
|
|
|
+ insuranceApplicationService.update(insuranceApplication);
|
|
|
|
+
|
|
|
|
+ messageResult.setResult(true);
|
|
|
|
+ }
|
|
|
|
+ catch (Exception ex){
|
|
|
|
+ messageResult.setResult(false);
|
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return messageResult;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @ResponseBody
|
|
|
|
+ @ApiOperation(value="缴费接口")
|
|
|
|
+ @ApiImplicitParam(name = "applicationId",value = "投保单编号",paramType ="form",required = true)
|
|
|
|
+ @PostMapping(value="/paySubmit")
|
|
|
|
+ public MessageResult paySubmit(HttpServletRequest request,String applicationId){
|
|
|
|
+ MessageResult msgResult = new MessageResult<>();
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ InsuranceApplication insuranceApplication = insuranceApplicationService.get(applicationId);
|
|
|
|
+
|
|
|
|
+ if(insuranceApplication==null){
|
|
|
|
+ throw new Exception("投保单不存在!");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(!String.valueOf(PolicyStatus.PendingPay.getValue()).equals(insuranceApplication.getStatus())){
|
|
|
|
+ throw new Exception("投保单当前状态不是待缴费状态!");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ AttributePrincipal principal = (AttributePrincipal) request.getUserPrincipal();
|
|
|
|
+ Company company = companyService.findByCreateBy(principal.getName());
|
|
|
|
+
|
|
|
|
+ String serialNumber = (String)principal.getAttributes().get("serialNumber");
|
|
|
|
+
|
|
|
|
+ TransactionRecord transactionRecord = new TransactionRecord();
|
|
|
|
+ transactionRecord.setId(UUID.randomUUID().toString());
|
|
|
|
+ transactionRecord.setApplicationId(applicationId);
|
|
|
|
+ transactionRecord.setCompanyId(company.getId());
|
|
|
|
+ transactionRecord.setAmount(insuranceApplication.getInsuranceFee());
|
|
|
|
+ transactionRecord.setPaymentStatus("0");
|
|
|
|
+ transactionRecord.setOrderNo(DateTime.now().toString("yyyyMMddHHmmssSSS"));
|
|
|
|
+ transactionRecord.setCreateBy(principal.getName());
|
|
|
|
+ transactionRecord.setCreateTime(new Date());
|
|
|
|
+
|
|
|
|
+ int affectCount = transactionRecordService.insert(transactionRecord);
|
|
|
|
+
|
|
|
|
+ if(affectCount==0){
|
|
|
|
+ throw new Exception("创建交易单失败!");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ HashMap<String, Object> paramMap = new HashMap<String, Object>();
|
|
|
|
+ paramMap.put("orderNo", transactionRecord.getOrderNo());
|
|
|
|
+ paramMap.put("orderName", insuranceApplication.getDefinitionName() + "网上缴费");
|
|
|
|
+ paramMap.put("freezeTime", transactionRecord.getCreateTime().getTime() / 1000);
|
|
|
|
+ paramMap.put("unfreezeTime", transactionRecord.getCreateTime().getTime() / 1000);
|
|
|
|
+ paramMap.put("orderAmount", transactionRecord.getAmount());
|
|
|
|
+ paramMap.put("code", jpCloudConfig.getPlatformCode()); //平台号
|
|
|
|
+ paramMap.put("buyerSerialNumber", serialNumber);//取登录用户的ID
|
|
|
|
+ paramMap.put("sellerSerialNumber", jpCloudConfig.getSellerSerialNumber());
|
|
|
|
+ paramMap.put("notifyBackUrl", jpCloudConfig.getNotifyBackUrl());
|
|
|
|
+ paramMap.put("synchroBackUrl", jpCloudConfig.getSynchroBackUrl());
|
|
|
|
+ String sign = SignUtil.createSign(paramMap, "1234567890");
|
|
|
|
+
|
|
|
|
+ paramMap.put("orderName", URLEncoder.encode(insuranceApplication.getDefinitionName() + "网上缴费","UTF-8"));
|
|
|
|
+ paramMap.put("notifyBackUrl", URLEncoder.encode(jpCloudConfig.getNotifyBackUrl(),"UTF-8"));
|
|
|
|
+ paramMap.put("synchroBackUrl", URLEncoder.encode(jpCloudConfig.getSynchroBackUrl(),"UTF-8"));
|
|
|
|
+
|
|
|
|
+ paramMap.put("sign", sign);
|
|
|
|
+
|
|
|
|
+ String param = "";
|
|
|
|
+
|
|
|
|
+ for (Map.Entry<String, Object> map : paramMap.entrySet()) {
|
|
|
|
+ param += map.getKey() + "=" + map.getValue() + "&";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (StringUtils.isNotBlank(param)) {
|
|
|
|
+ param = param.substring(0, param.length() - 1);
|
|
|
|
+ }
|
|
|
|
+ String returnUrl = jpCloudConfig.getJpcloudUrl() + "?" + param;
|
|
|
|
+
|
|
|
|
+ msgResult.setData(returnUrl);
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
+ }
|
|
|
|
+ catch(Exception ex){
|
|
|
|
+ log.error(ex.getMessage(),ex);
|
|
|
|
|
|
msgResult.setResult(false);
|
|
msgResult.setResult(false);
|
|
msgResult.setMessage(ex.getMessage());
|
|
msgResult.setMessage(ex.getMessage());
|