| | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.extra.pinyin.PinyinUtil; |
| | | import cn.hutool.json.JSONArray; |
| | | import cn.hutool.json.JSONObject; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.ltkj.common.annotation.RepeatSubmit; |
| | | import com.ltkj.common.core.domain.entity.SysDept; |
| | | import com.ltkj.common.core.domain.entity.SysUser; |
| | |
| | | private ISysDeptService sysDeptService; |
| | | @Autowired |
| | | private TjFlowingWaterHisService tjFlowingWaterHisService; |
| | | @Autowired |
| | | private ITjSamplingService tjSamplingService; |
| | | |
| | | /** |
| | | * 查询该体检号对应的订单流水列表 |
| | |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | @PutMapping("supper") |
| | | @ApiOperation(value = "体检点击强制收费按钮接口") |
| | | @Transactional |
| | | @RepeatSubmit |
| | | public AjaxResult supperEdit(@RequestBody TjFlowingWater tjFlowingWater) { |
| | | Long userId = Long.valueOf(SecurityUtils.getLoginUser().getUserId()); |
| | | SysUser sysUser = userService.getById(userId); |
| | | |
| | | TjFlowingWater flowingWater = tjFlowingWaterService.getById(tjFlowingWater.getTjSerialNumber()); |
| | | // tjFlowingWater.setTollCollectorId(String.valueOf(SecurityUtils.getLoginUser().getUserId())); |
| | | // tjFlowingWater.setPayStasus(1L); |
| | | TjOrder order = orderService.getById(tjFlowingWater.getOrderId()); |
| | | |
| | | if(order.getFinishTime() !=null){ |
| | | return AjaxResult.error("该人员已签离,不可补录项目!"); |
| | | } |
| | | |
| | | TjCustomer customer = customerService.getById(order.getUserId()); |
| | | if (null != tjFlowingWater.getTjProIds() && tjFlowingWater.getTjProIds().length > 0) { |
| | | tjFlowingWater.setWaterId(PinyinUtil.getFirstLetter(customer.getCusName(), "").toUpperCase() +SecurityUtils.getUsername() + DateUtil.format(new Date(), "yyMMddHHmmssSSS")); |
| | | tjFlowingWater.setIsAddition("Y"); |
| | | if (tjFlowingWaterService.save(tjFlowingWater)) { |
| | | |
| | | Date dates = new Date(); |
| | | String jxbz = DateUtil.format(dates, "yyyyMMddHHmmss")+order.getOrderId(); |
| | | //异步单项收费明细 |
| | | Boolean b = asyncService.iundividualCharges(tjFlowingWater, order, customer, sysUser,jxbz); |
| | | if (!b){ |
| | | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); |
| | | return AjaxResult.error(); |
| | | } |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("waterId", tjFlowingWater.getWaterId()); |
| | | map.put("mobanId", reportService.getMoBanIds()); |
| | | return AjaxResult.success("收费成功", map); |
| | | } |
| | | } |
| | | |
| | | if (flowingWater.getPayStasus() == 1) { |
| | | return AjaxResult.success("该订单已付款 无须再付"); |
| | | } |
| | | String s = configService.selectConfigByKey("is_request_common_his_api"); |
| | | if (null != s && s.equals("Y") && order.getTjType().equals("2") && StrUtil.isNotBlank(tjFlowingWater.getHisWaterId())) { |
| | | tjFlowingWater.setPayStasus(1L); |
| | | } |
| | | if (tjFlowingWaterService.updateById(tjFlowingWater)) { |
| | | // LambdaQueryWrapper<TjOrderDetail> wq2 = new LambdaQueryWrapper<>(); |
| | | // wq2.eq(TjOrderDetail::getOrderId, tjFlowingWater.getOrderId()); |
| | | // wq2.isNull(TjOrderDetail::getFlowingWaterId); |
| | | List<TjConsumables> list2 = new ArrayList<>(); |
| | | // for (TjOrderDetail tjOrderDetail : detailService.list(wq2)) { |
| | | // tjOrderDetail.setFlowingWaterId(String.valueOf(tjFlowingWater.getTjSerialNumber())); |
| | | // detailService.updateById(tjOrderDetail); |
| | | // } |
| | | if (StrUtil.isBlank(flowingWater.getJxbz())){ |
| | | detailService.updateTjOrderDetailsFlowingWaterIdByJxbzisnull(String.valueOf(order.getOrderId()),String.valueOf(tjFlowingWater.getTjSerialNumber())); |
| | | remarkService.updateTjOrderRemarkSfbzByJxbzisnull(order.getOrderId().toString(),tjFlowingWater.getTjSerialNumber().toString()); |
| | | }else { |
| | | detailService.updateTjOrderDetailsFlowingWaterIdByJxbz(String.valueOf(order.getOrderId()), flowingWater.getJxbz(), String.valueOf(tjFlowingWater.getTjSerialNumber())); |
| | | remarkService.updateTjOrderRemarkSfbzByJxbz(order.getOrderId().toString(), flowingWater.getJxbz(), tjFlowingWater.getTjSerialNumber().toString()); |
| | | } |
| | | |
| | | LambdaQueryWrapper<TjOrderDetail> wq3 = new LambdaQueryWrapper<>(); |
| | | wq3.eq(TjOrderDetail::getOrderId, tjFlowingWater.getOrderId()); |
| | | wq3.isNotNull(TjOrderDetail::getFlowingWaterId); |
| | | List<TjOrderDetail> detailList = detailService.list(wq3); |
| | | if (null != detailList && !detailList.isEmpty()) { |
| | | LambdaQueryWrapper<TbTransition> wqq = new LambdaQueryWrapper<>(); |
| | | wqq.eq(TbTransition::getCusId, customer.getCusIdcard()); |
| | | wqq.in(TbTransition::getProId, detailList.stream().map(TjOrderDetail::getProId).collect(Collectors.toList())); |
| | | List<TbTransition> tbTransitionList = transitionService.list(wqq); |
| | | if (null != tbTransitionList && !tbTransitionList.isEmpty()) { |
| | | // extracted(order, list2, tbTransitionList); |
| | | //异步添加收费明细 |
| | | asyncService.collectFees(order, list2, tbTransitionList, sysUser, tjFlowingWater.getDiscount()); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("waterId", tjFlowingWater.getWaterId()); |
| | | map.put("mobanId", reportService.getMoBanIds()); |
| | | return AjaxResult.success("收费成功", map); |
| | | } |
| | | } |
| | | return AjaxResult.success("该用户已收费不可重复收费"); |
| | | } |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | @PutMapping("refund") |
| | | @ApiOperation(value = "体检点击强制退费按钮接口") |
| | | @Transactional |
| | | @RepeatSubmit |
| | | public AjaxResult refundEdit(@RequestBody String json){ |
| | | JSONObject parseObj = JSONUtil.parseObj(json); |
| | | String tjSerialNumber = parseObj.getStr("tjSerialNumber"); |
| | | TjFlowingWater tjFlowingWater = tjFlowingWaterService.getById(tjSerialNumber); |
| | | Long orderId = tjFlowingWater.getOrderId(); |
| | | LambdaQueryWrapper<TjOrderRemark> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(TjOrderRemark::getSfbz,tjSerialNumber); |
| | | List<TjOrderRemark> list = remarkService.list(wrapper); |
| | | if (list.isEmpty()){ |
| | | return AjaxResult.error("该人员没有已收费项目"); |
| | | } |
| | | String tjNumber = list.get(0).getTjNumber(); |
| | | List<Long> proIds = list.stream().map(TjOrderRemark::getProId).collect(Collectors.toList()); |
| | | LambdaQueryWrapper<TjSampling> wrapper1 = new LambdaQueryWrapper<>(); |
| | | wrapper1.eq(TjSampling::getTjNum,tjNumber); |
| | | wrapper1.in(TjSampling::getProId,proIds); |
| | | wrapper1.eq(TjSampling::getIsSignFor,"0"); |
| | | List<TjSampling> samplings = tjSamplingService.list(wrapper1); |
| | | if (!samplings.isEmpty()) |
| | | return AjaxResult.error("该人员此单中存在已做的化验项目,不可退费"); |
| | | |
| | | if (StrUtil.isBlank(tjFlowingWater.getJxbz())){ |
| | | |
| | | LambdaUpdateWrapper<TjOrderDetail> wrapper2 = new LambdaUpdateWrapper<>(); |
| | | wrapper2.set(TjOrderDetail::getFlowingWaterId,null) |
| | | .set(TjOrderDetail::getUpdateTime,new Date()) |
| | | .eq(TjOrderDetail::getOrderId,orderId) |
| | | .isNull(TjOrderDetail::getJxbz); |
| | | detailService.update(wrapper2); |
| | | |
| | | LambdaUpdateWrapper<TjOrderRemark> wrapper3 = new LambdaUpdateWrapper<>(); |
| | | // wrapper3 |
| | | }else { |
| | | // detailService.updateTjOrderDetailsFlowingWaterIdByJxbz(String.valueOf(order.getOrderId()), flowingWater.getJxbz(), String.valueOf(tjFlowingWater.getTjSerialNumber())); |
| | | // remarkService.updateTjOrderRemarkSfbzByJxbz(order.getOrderId().toString(), flowingWater.getJxbz(), tjFlowingWater.getTjSerialNumber().toString()); |
| | | } |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除体检流水 |
| | |
| | | .like(TjCustomer::getCusPhone, tjPhone); |
| | | List<TjCustomer> customerList = customerService.list(wq0); |
| | | if (null != customerList && !customerList.isEmpty()) { |
| | | for (TjCustomer customer : customerList) { |
| | | LambdaQueryWrapper<TjOrder> wq1 = new LambdaQueryWrapper<>(); |
| | | wq1.eq(TjOrder::getUserId, customer.getCusId()); |
| | | wq1.in(TjOrder::getUserId,customerList.stream().map(TjCustomer::getCusId).collect(Collectors.toList())); |
| | | wq1.eq(TjOrder::getCheckStatus, 0); |
| | | // wq1.isNotNull(TjOrder::getReportTime); |
| | | wq1.orderByDesc(TjOrder::getCreateTime); |
| | | List<TjOrder> tjOrders = orderService.list(wq1); |
| | | if (null != tjOrders && !tjOrders.isEmpty()) { |
| | | for (TjOrder order : tjOrders) { |
| | | TjCustomer customer = customerService.getById(order.getUserId()); |
| | | LambdaQueryWrapper<TjOrderDetail> wq2 = new LambdaQueryWrapper<>(); |
| | | wq2.eq(TjOrderDetail::getOrderId, order.getOrderId()); |
| | | List<TjOrderDetail> detailList = detailService.list(wq2); |
| | |
| | | tjRefundVo.setTjFlowingWater(water); |
| | | tjRefundVo.setTjNumber(order.getTjNumber()); |
| | | tjRefundVo.setTjOrderId(String.valueOf(order.getOrderId())); |
| | | tjCollectFeesVoList.add(tjRefundVo); |
| | | TjCollectFeesVo vo = BeanUtil.copyProperties(tjRefundVo, TjCollectFeesVo.class); |
| | | tjCollectFeesVoList.add(vo); |
| | | } |
| | | // tjRefundVo.setPaidIn(String.valueOf(one.getPaidIn())); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | return AjaxResult.success(tjCollectFeesVoList); |
| | | } |
| | | return AjaxResult.error("该用户不存在"); |
| | |
| | | return AjaxResult.error("暂时没有数据"); |
| | | } |
| | | |
| | | /** |
| | | * 体检已收费未收费信息查询接口 |
| | | */ |
| | | @GetMapping("/findTjChargedButNotChargedByTjNumN") |
| | | @ApiOperation(value = "体检已收费未收费信息查询接口") |
| | | public AjaxResult findTjChargedButNotChargedByTjNumN(@RequestParam @ApiParam(value = "0未缴费1已缴费") Integer type, |
| | | @RequestParam @ApiParam(value = "体检号") String OrderId, |
| | | @RequestParam String tjSerialNumber) { |
| | | if (null != OrderId) { |
| | | TjOrder order = orderService.getById(OrderId); |
| | | if (null != order) { |
| | | List<TjProject> tjProjectList = null; |
| | | TjFlowingWater water = tjFlowingWaterService.getById(tjSerialNumber); |
| | | if (type == 0) { |
| | | if (StrUtil.isBlank(water.getJxbz())) |
| | | tjProjectList = detailService.selectTjOrderDetailListByFlowingWaterIdIsNullAndJxbzIsNull(OrderId); |
| | | else tjProjectList = detailService.selectTjOrderDetailListByFlowingWaterIdIsNullN(OrderId,water.getJxbz()); |
| | | } else { |
| | | if (StrUtil.isBlank(water.getJxbz())) |
| | | tjProjectList = detailService.selectTjOrderDetailListByFlowingWaterIdIsNotNullAndJxbzIsNull(OrderId); |
| | | else tjProjectList = detailService.selectTjOrderDetailListByFlowingWaterIdIsNotNullN(OrderId,water.getJxbz()); |
| | | } |
| | | String pacId = transitionService.selectPacIdByTbTransitionTjNumAndProId(order.getTjNumber(),order.getCardId()); |
| | | String s = tjFlowingWaterService.getDiscount(OrderId); |
| | | if (null != tjProjectList && !tjProjectList.isEmpty()) { |
| | | for (TjProject project : tjProjectList) { |
| | | if (project.getProParentId() == 0) { |
| | | if (null != pacId) { |
| | | TjPackageProject pp = tjPackageProjectService.getOne(new LambdaQueryWrapper<TjPackageProject>().eq(TjPackageProject::getPacId, pacId) |
| | | .eq(TjPackageProject::getProId, String.valueOf(project.getProId()))); |
| | | if (null != pp) { |
| | | project.setProPrice(pp.getPriceNow()); |
| | | project.setProOrdPrice(pp.getPriceNow().multiply(new BigDecimal(s))); |
| | | } else { |
| | | project.setProPrice(project.getProPrice().setScale(2)); |
| | | project.setProOrdPrice(project.getProPrice().multiply(new BigDecimal(s)).setScale(2)); |
| | | } |
| | | } else { |
| | | project.setProPrice(project.getProPrice().setScale(2)); |
| | | project.setProOrdPrice(project.getProPrice().multiply(new BigDecimal(s)).setScale(2)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | List<TjFlowingWater> list = tjFlowingWaterService.list(new LambdaQueryWrapper<TjFlowingWater>() |
| | | .eq(TjFlowingWater::getOrderId, order) |
| | | .eq(TjFlowingWater::getPayStasus, 2)); |
| | | if (null != list && !list.isEmpty()) { |
| | | List<TjProject> projectList = projectService.getTjProListByPacIdAndDeptId(pacId); |
| | | if(null !=projectList && !projectList.isEmpty()){ |
| | | for (TjProject project : projectList) { |
| | | project.setProOrdPrice(tjPackageProjectService.getPacProPriceByPacIdAndPro(project.getProId(),pacId) |
| | | .multiply(new BigDecimal(s)).setScale(2)); |
| | | tjProjectList.add(project); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | return AjaxResult.success(tjProjectList); |
| | | } |
| | | } |
| | | return AjaxResult.error("暂时没有数据"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 体检退费项目查询接口 |