diff --git a/ghy-admin/src/main/java/com/ghy/web/controller/order/OrderDetailInsuranceUserController.java b/ghy-admin/src/main/java/com/ghy/web/controller/order/OrderDetailInsuranceUserController.java index 483b0f86..442e0788 100644 --- a/ghy-admin/src/main/java/com/ghy/web/controller/order/OrderDetailInsuranceUserController.java +++ b/ghy-admin/src/main/java/com/ghy/web/controller/order/OrderDetailInsuranceUserController.java @@ -4,6 +4,7 @@ import java.util.List; import com.ghy.web.pojo.vo.CertNoTwoElementReq; import com.ghy.web.service.AliCloudService; +import com.ghy.web.service.InsuranceService; import lombok.extern.slf4j.Slf4j; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; @@ -38,6 +39,9 @@ public class OrderDetailInsuranceUserController extends BaseController @Autowired private AliCloudService aliCloudService; + @Autowired + private InsuranceService insuranceService; + @RequiresPermissions("worker:user:view") @GetMapping() public String user() @@ -108,6 +112,13 @@ public class OrderDetailInsuranceUserController extends BaseController log.error("身份证二要素校验失败:{}", e.getMessage(), e); return AjaxResult.error(e.getMessage(), "身份证二要素校验失败!"); } + // 将保险人员增员到原保险订单上去 + try { + insuranceService.editInsurance(orderDetailInsuranceUser); + }catch (Exception e){ + log.error("保险增员失败:{}", e.getMessage(), e); + return AjaxResult.error(e.getMessage(), "保险增员失败!"); + } return toAjax(orderDetailInsuranceUserService.insertOrderDetailInsuranceUser(orderDetailInsuranceUser)); } diff --git a/ghy-admin/src/main/java/com/ghy/web/pojo/vo/InsuranceOrderEditReq.java b/ghy-admin/src/main/java/com/ghy/web/pojo/vo/InsuranceOrderEditReq.java new file mode 100644 index 00000000..1d36e13c --- /dev/null +++ b/ghy-admin/src/main/java/com/ghy/web/pojo/vo/InsuranceOrderEditReq.java @@ -0,0 +1,22 @@ +package com.ghy.web.pojo.vo; + +import lombok.Data; + +@Data +public class InsuranceOrderEditReq { + + private String requestNo; + + private String channelCode = "NNDD0806QH"; + + private String sign; + + private String orderNumber; + + private String workName; + + private String workerID; + + + +} diff --git a/ghy-admin/src/main/java/com/ghy/web/service/InsuranceService.java b/ghy-admin/src/main/java/com/ghy/web/service/InsuranceService.java index 20f61979..cf8a6aa3 100644 --- a/ghy-admin/src/main/java/com/ghy/web/service/InsuranceService.java +++ b/ghy-admin/src/main/java/com/ghy/web/service/InsuranceService.java @@ -1,9 +1,11 @@ package com.ghy.web.service; +import com.ghy.order.domain.OrderDetailInsuranceUser; + public interface InsuranceService { - public void orderInsurance(String orderCode) throws Exception; - + void orderInsurance(String orderCode) throws Exception; + void editInsurance(OrderDetailInsuranceUser orderDetailInsuranceUser) throws Exception ; } diff --git a/ghy-admin/src/main/java/com/ghy/web/service/impl/InsuranceServiceImpl.java b/ghy-admin/src/main/java/com/ghy/web/service/impl/InsuranceServiceImpl.java index 8ac071dc..eb74281f 100644 --- a/ghy-admin/src/main/java/com/ghy/web/service/impl/InsuranceServiceImpl.java +++ b/ghy-admin/src/main/java/com/ghy/web/service/impl/InsuranceServiceImpl.java @@ -9,9 +9,14 @@ import com.alibaba.fastjson.JSONObject; import com.ghy.common.utils.security.Md5Utils; import com.ghy.customer.domain.CustomerAddress; import com.ghy.customer.service.CustomerAddressService; +import com.ghy.order.domain.OrderDetail; +import com.ghy.order.domain.OrderDetailInsuranceUser; import com.ghy.order.domain.OrderMaster; +import com.ghy.order.service.IOrderDetailInsuranceUserService; +import com.ghy.order.service.OrderDetailService; import com.ghy.order.service.OrderMasterService; import com.ghy.web.pojo.vo.CertNoTwoElementReq; +import com.ghy.web.pojo.vo.InsuranceOrderEditReq; import com.ghy.web.pojo.vo.InsuranceOrderReq; import com.ghy.web.service.InsuranceService; import com.ghy.worker.domain.Worker; @@ -21,8 +26,10 @@ import com.ghy.worker.service.WorkerService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; import java.util.Date; +import java.util.List; @Slf4j @Service @@ -39,10 +46,13 @@ public class InsuranceServiceImpl implements InsuranceService { private CustomerAddressService customerAddressService; @Autowired - private IWorkerCertificationService workerCertificationService; + private WorkerService workerService; @Autowired - private WorkerService workerService; + private OrderDetailService orderDetailService; + + @Autowired + private IOrderDetailInsuranceUserService orderDetailInsuranceUserService; @Override public void orderInsurance(String orderCode) throws Exception{ @@ -69,4 +79,49 @@ public class InsuranceServiceImpl implements InsuranceService { throw new Exception(JSONObject.parseObject(result).getString("msg")); } } + + @Override + public void editInsurance(OrderDetailInsuranceUser orderDetailInsuranceUser) throws Exception { + // 查询子单 + OrderDetail detail = orderDetailService.selectById(orderDetailInsuranceUser.getOrderDetailId()); + // 查询主单 + OrderMaster master = orderMasterService.selectById(detail.getOrderMasterId()); + // 查师傅信息 + Worker worker = workerService.selectById(master.getWorkerId()); + CertNoTwoElementReq certNoTwoElementReq = JSONUtil.toBean(worker.getRemark(), CertNoTwoElementReq.class); + // 查询主单下的所有子单 + List detailList = orderDetailService.selectByOrderMasterId(detail.getOrderMasterId()); + StringBuilder workerName = new StringBuilder(); + StringBuilder workerId = new StringBuilder(); + // 拼上主单信息 + workerName.append(certNoTwoElementReq.getCertName()); + workerId.append(certNoTwoElementReq.getCertNo()); + detailList.forEach(model->{ + OrderDetailInsuranceUser param = new OrderDetailInsuranceUser(); + param.setOrderDetailId(model.getId()); + List users = orderDetailInsuranceUserService.selectOrderDetailInsuranceUserList(param); + if(!CollectionUtils.isEmpty(users)){ + users.forEach(user->{ + workerName.append(",").append(user.getName()); + workerId.append(",").append(user.getIdCardNum()); + }); + } + }); + // 再拼上 现在要加入的师傅的信息 + workerName.append(",").append(orderDetailInsuranceUser.getName()); + workerId.append(",").append(orderDetailInsuranceUser.getIdCardNum()); + InsuranceOrderEditReq editReq = new InsuranceOrderEditReq(); + editReq.setOrderNumber(master.getCode()); + editReq.setRequestNo(master.getCode() + System.currentTimeMillis()); + editReq.setSign(Md5Utils.hash(editReq.getRequestNo() + editReq.getChannelCode() + Key)); + editReq.setOrderNumber(master.getCode()); + editReq.setWorkName(workerName.toString()); + editReq.setWorkerID(workerId.toString()); + log.info("调用保险请求url:{},内容:{}", baseUrl+"/platInterface/updateOrder", JSONUtil.toJsonStr(editReq)); + String result = HttpUtil.post(baseUrl+"/platInterface/updateOrder", JSONUtil.toJsonStr(editReq)); + log.info("调用保险返回内容:{}", result); + if(!"1".equals(JSONObject.parseObject(result).getString("code"))){ + throw new Exception(JSONObject.parseObject(result).getString("msg")); + } + } }