| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.kidgrow.common.constant.ConsumptionConstant; |
| | | import com.kidgrow.common.model.*; |
| | | import com.kidgrow.common.service.impl.SuperServiceImpl; |
| | | import com.kidgrow.common.utils.DateUtils; |
| | | import com.kidgrow.oprationcenter.feign.DiagnosticService; |
| | | import com.kidgrow.oprationcenter.feign.RoleOrganizationService; |
| | | import com.kidgrow.oprationcenter.mapper.ProductOrderRecordMapper; |
| | | import com.kidgrow.oprationcenter.model.ConsumptionRecord; |
| | | import com.kidgrow.oprationcenter.model.ProductOrderRecord; |
| | | import com.kidgrow.oprationcenter.service.IConsumptionRecordService; |
| | | import com.kidgrow.oprationcenter.service.IProductOrderDetailService; |
| | | import com.kidgrow.oprationcenter.service.IProductOrderRecordService; |
| | | import com.kidgrow.oprationcenter.vo.DiagnosisRecord; |
| | | import com.kidgrow.oprationcenter.vo.GroupProductDetail; |
| | | import com.kidgrow.oprationcenter.vo.ProductOrderJoinDetail; |
| | | import com.kidgrow.oprationcenter.vo.UserProductDetail; |
| | | import com.kidgrow.usercenter.feign.SysDoctorService; |
| | | import com.kidgrow.usercenter.feign.SysHospitalService; |
| | | import com.kidgrow.usercenter.model.SysHospital; |
| | |
| | | |
| | | /** |
| | | * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br> |
| | | * |
| | | * @version 1.0 |
| | | * @Description: 产品/明显的充值记录<br> |
| | | * @Project: 用户中心<br> |
| | | * @CreateDate: Created in 2020-04-01 09:37:05 <br> |
| | | * @Author: <a href="4345453@kidgrow.com">liuke</a> |
| | | * @version 1.0 |
| | | */ |
| | | @Slf4j |
| | | @Service |
| | | public class ProductOrderRecordServiceImpl extends SuperServiceImpl<ProductOrderRecordMapper, ProductOrderRecord> implements IProductOrderRecordService { |
| | | @Autowired |
| | | @Autowired |
| | | DiagnosticService diagnosticService; |
| | | @Autowired |
| | | private RoleOrganizationService roleOrganizationService; |
| | |
| | | private SysHospitalService sysHospitalService; |
| | | @Autowired |
| | | private IProductOrderDetailService productOrderDetailService; |
| | | @Autowired |
| | | private IConsumptionRecordService consumptionRecordService; |
| | | |
| | | /** |
| | | * 列表 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @Override |
| | | public PageResult<ProductOrderRecord> findList(Map<String, Object> params){ |
| | | public PageResult<ProductOrderRecord> findList(Map<String, Object> params) { |
| | | Page<ProductOrderRecord> page = new Page<>(MapUtils.getInteger(params, "page"), MapUtils.getInteger(params, "limit")); |
| | | List<ProductOrderRecord> list = baseMapper.findList(page, params); |
| | | List<ProductOrderRecord> list = baseMapper.findList(page, params); |
| | | return PageResult.<ProductOrderRecord>builder().data(list).code(0).count(page.getTotal()).build(); |
| | | } |
| | | |
| | | /** |
| | | * 获取诊断列表 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @Override |
| | | public PageResult<DiagnosisRecord> findAllDataList(Map<String, Object> params){ |
| | | return diagnosticService.getDiagnosticItemList(params).getData(); |
| | | public PageResult<DiagnosisRecord> findAllDataList(Map<String, Object> params) { |
| | | return diagnosticService.getDiagnosticItemList(params).getData(); |
| | | } |
| | | |
| | | /** |
| | | * 列表 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | |
| | | Page<ProductOrderJoinDetail> page = new Page<>(MapUtils.getInteger(params, "page"), MapUtils.getInteger(params, "limit")); |
| | | Map<String, Object> roleOrgMap = roleOrganizationService.getRoleOrgMap(sysUser.getRoles()); |
| | | params.putAll(roleOrgMap); |
| | | List<ProductOrderJoinDetail> list = baseMapper.findAllList(page,params); |
| | | List<ProductOrderJoinDetail> list = baseMapper.findAllList(page, params); |
| | | return PageResult.<ProductOrderJoinDetail>builder().data(list).code(0).count(page.getTotal()).build(); |
| | | } |
| | | |
| | | /** |
| | | * 获取统计数据 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @Override |
| | | public PageResult<GroupProductDetail> groupList(Map<String, Object> params) { |
| | | Page<GroupProductDetail> page = new Page<>(MapUtils.getInteger(params, "page"), MapUtils.getInteger(params, "limit")); |
| | | List<GroupProductDetail> list = baseMapper.groupProductDetail(page,params); |
| | | List<GroupProductDetail> list = baseMapper.groupProductDetail(page, params); |
| | | return PageResult.<GroupProductDetail>builder().data(list).code(0).count(page.getTotal()).build(); |
| | | } |
| | | |
| | | /** |
| | | * 统计用户所有套餐剩余 |
| | | * 统计用户所有套餐剩余 套餐剩余量=(有效期内的医院所有共享+科室私有的套餐的读片量)-预扣费的读片量 |
| | | * |
| | | * @param hospitalId |
| | | * @param departmentId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public ResultBody biUserNowProduct(long hospitalId, Long departmentId) { |
| | | if (hospitalId>0&& departmentId>0) { |
| | | //查询当前医院正在使用的套餐 |
| | | Map<String,Object> selectMap=new HashMap<>(); |
| | | selectMap.put("hospitalId",hospitalId); |
| | | List<ProductOrderJoinDetail> productOrderDetailList=productOrderDetailService.findAllList(selectMap); |
| | | Long userAICount=0l; |
| | | if (productOrderDetailList.size()>0) { |
| | | public ResultBody biUserNowProduct(Long hospitalId, Long departmentId) { |
| | | if (hospitalId > 0 && departmentId > 0) { |
| | | UserProductDetail userProductDetail=productOrderDetailService.getUserProductDetail(hospitalId,departmentId); |
| | | int userAICount = 0; |
| | | if (userProductDetail!=null) { |
| | | //包含共享的数据 |
| | | List<ProductOrderJoinDetail> productOrderJoinDetailListShare=productOrderDetailList.stream().filter(f->f.getIsShare()).collect(Collectors.toList()); |
| | | List<ProductOrderJoinDetail> productOrderJoinDetailListShare = userProductDetail.getProductOrderJoinDetailListShare(); |
| | | //科室私有的数据 |
| | | List<ProductOrderJoinDetail> productOrderJoinDetailsListDep=productOrderDetailList.stream().filter((f->departmentId.equals(f.getDepartmentId())&&f.getIsShare()==false)).collect(Collectors.toList()); |
| | | List<ProductOrderJoinDetail> productOrderJoinDetailsListDep = userProductDetail.getProductOrderJoinDetailsListDep(); |
| | | //本医院可共享的读片总量 |
| | | Long shareCount=productOrderJoinDetailListShare.stream().collect(Collectors.summingLong(ProductOrderJoinDetail::getAilightCount)); |
| | | int shareCount = productOrderJoinDetailListShare.stream().collect(Collectors.summingInt(ProductOrderJoinDetail::getAilightCount)); |
| | | //本科室私有读片总量 |
| | | Long depCount=productOrderJoinDetailsListDep.stream().collect(Collectors.summingLong(ProductOrderJoinDetail::getAilightCount)); |
| | | int depCount = productOrderJoinDetailsListDep.stream().collect(Collectors.summingInt(ProductOrderJoinDetail::getAilightCount)); |
| | | //可用的总量 |
| | | userAICount=shareCount+depCount; |
| | | userAICount = shareCount + depCount; |
| | | //计算预扣费的总量 |
| | | Map<String, Object> selectMap = new HashMap<>(); |
| | | selectMap.put("recordType", ConsumptionConstant.BEFORE_DEDUCTION); |
| | | List<ConsumptionRecord> consumptionRecordList = consumptionRecordService.findAllList(selectMap); |
| | | if (consumptionRecordList.size() > 0) { |
| | | //共享套餐里面的detailid |
| | | List<Long> shareDetailId = productOrderJoinDetailListShare.stream().map(m -> m.getId()).collect(Collectors.toList()); |
| | | //私有套餐里面的detailid |
| | | List<Long> depDetailId = productOrderJoinDetailsListDep.stream().map(m -> m.getId()).collect(Collectors.toList()); |
| | | //共享套餐里面预扣费总数 |
| | | int shareConCount = consumptionRecordList.stream().filter(f -> shareDetailId.contains(f.getProOrderDetailId())).collect(Collectors.summingInt(ConsumptionRecord::getConsumptionCount)); |
| | | //共享套餐里面预扣费总数 |
| | | int depConCount = consumptionRecordList.stream().filter(f -> depDetailId.contains(f.getProOrderDetailId())).collect(Collectors.summingInt(ConsumptionRecord::getConsumptionCount)); |
| | | userAICount -= (shareConCount + depConCount); |
| | | } |
| | | } |
| | | |
| | | return ResultBody.ok().data(userAICount); |
| | | } |
| | | else |
| | | { |
| | | } else { |
| | | return ResultBody.failed("医院和科室数据有误!"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据ProductOrderRecord对象当做查询条件进行查询 |
| | | * @param productOrderRecord |
| | | * @return ProductOrderRecord |
| | | */ |
| | | * 根据ProductOrderRecord对象当做查询条件进行查询 |
| | | * |
| | | * @param productOrderRecord |
| | | * @return ProductOrderRecord |
| | | */ |
| | | @Override |
| | | public ProductOrderRecord findByObject(ProductOrderRecord productOrderRecord){ |
| | | public ProductOrderRecord findByObject(ProductOrderRecord productOrderRecord) { |
| | | return baseMapper.findByObject(productOrderRecord); |
| | | } |
| | | |
| | | /** |
| | | * 修改数据状态 启用 禁用 |
| | | * |
| | | * @param params |
| | | * @return |
| | | */ |
| | |
| | | @Override |
| | | public ResultBody getTypeByUser(SysUser sysUser) { |
| | | List<SysOrganization> organizations = sysUser.getOrganizations(); |
| | | if(organizations.size()>0){ |
| | | if (organizations.size() > 0) { |
| | | SysOrganization sysOrganization = organizations.get(0); |
| | | List<ProductOrderJoinDetail> list=baseMapper.getTypeByUser(sysOrganization.getId()); |
| | | if (list.size()>0) { |
| | | List<ProductOrderJoinDetail> list = baseMapper.getTypeByUser(sysOrganization.getId()); |
| | | if (list.size() > 0) { |
| | | ProductOrderJoinDetail productOrderJoinDetail = list.get(0); |
| | | //查询用户的真实姓名 |
| | | Map<String,Object> selectMap=new HashMap<>(); |
| | | selectMap.put("user_id",sysUser.getId()); |
| | | Map<String, Object> selectMap = new HashMap<>(); |
| | | selectMap.put("user_id", sysUser.getId()); |
| | | ResultBody listByMap = sysDoctorService.getListByMap(selectMap); |
| | | List<SysDoctor> sysDoctors = JSON.parseArray(JSON.toJSONString(listByMap.getData()), SysDoctor.class); |
| | | String str=""; |
| | | if(sysDoctors!=null&&sysDoctors.size()>0){ |
| | | str= sysDoctors.get(0).getDoctorName(); |
| | | String str = ""; |
| | | if (sysDoctors != null && sysDoctors.size() > 0) { |
| | | str = sysDoctors.get(0).getDoctorName(); |
| | | } |
| | | //查询医院的 logo |
| | | Map<String,Object> map=new HashMap<>(); |
| | | map.put("id",sysOrganization.getId()); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("id", sysOrganization.getId()); |
| | | ResultBody allByMap = sysHospitalService.findAllByMap(map); |
| | | List<SysHospital> hospitals = JSON.parseArray(JSON.toJSONString(allByMap.getData()), SysHospital.class); |
| | | String logo=""; |
| | | if(hospitals.size()>0){ |
| | | String logo = ""; |
| | | if (hospitals.size() > 0) { |
| | | logo = hospitals.get(0).getHospitalLogo(); |
| | | } |
| | | Map<String,Object> mapVo=new HashMap<>(); |
| | | mapVo.put("type",productOrderJoinDetail.getProType()); |
| | | mapVo.put("realName",str); |
| | | Map<String, Object> mapVo = new HashMap<>(); |
| | | mapVo.put("type", productOrderJoinDetail.getProType()); |
| | | mapVo.put("realName", str); |
| | | //剩余时间 |
| | | Date proEndtime = productOrderJoinDetail.getProEndtime(); |
| | | Double surplusDay=DateUtils.getDays(proEndtime, new Date()); |
| | | Double surplusDay = DateUtils.getDays(proEndtime, new Date()); |
| | | int surplus = surplusDay.intValue(); |
| | | mapVo.put("surplus",surplus); |
| | | mapVo.put("logo",logo); |
| | | mapVo.put("surplus", surplus); |
| | | mapVo.put("logo", logo); |
| | | //获取 售后服务工程师********不能从sysOrganization获取,从department获取 |
| | | /* mapVo.put("saleUserName",sysOrganization.getSaleUserName()); |
| | | mapVo.put("saleUserTel",sysOrganization.getSaleUserTel());*/ |
| | | return ResultBody.ok().data(mapVo); |
| | | }else { |
| | | } else { |
| | | return ResultBody.failed("该用户套餐已经失效"); |
| | | } |
| | | }else { |
| | | } else { |
| | | return ResultBody.failed("该用户的组织已经失效"); |
| | | } |
| | | } |