| | |
| | | package com.ltkj.web.controller.callback; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | 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.core.domain.AjaxResult; |
| | | import com.ltkj.common.core.domain.entity.SysUser; |
| | | import com.ltkj.hosp.domain.*; |
| | | import com.ltkj.hosp.mapper.TjProjectMapper; |
| | | import com.ltkj.hosp.mapper.TjSamplingMapper; |
| | | import com.ltkj.hosp.service.*; |
| | | import com.ltkj.system.service.ISysConfigService; |
| | | import com.ltkj.system.service.ISysUserService; |
| | | import com.ltkj.web.controller.system.TjOrderController; |
| | | import com.ltkj.web.wxUtils.HttpClientUtils; |
| | | import jodd.util.StringUtil; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 对接其他平台提供的回调服务 |
| | |
| | | private ITjCustomerService tjCustomerService; |
| | | @Autowired |
| | | private ITjOrderService orderService; |
| | | @Autowired |
| | | private TjProjectMapper tjProjectMapper; |
| | | @Autowired |
| | | private ISysConfigService sysConfigService; |
| | | @Autowired |
| | | private TjOrderController tjOrderController; |
| | | @Autowired |
| | | private ISysUserService userService; |
| | | @Autowired |
| | | private TjOrderYcxmService ycxmService; |
| | | |
| | | /** |
| | | * 收退费回调接口 |
| | |
| | | LambdaQueryWrapper<TjFlowingWater> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(TjFlowingWater::getHisWaterId, feiYongId); |
| | | TjFlowingWater water = tjFlowingWaterService.getOne(wrapper); |
| | | water.setPayStasus(1L); |
| | | tjFlowingWaterService.updateById(water); |
| | | if(null !=water){ |
| | | water.setPayStasus(1L); |
| | | water.setSfjs("1"); |
| | | water.setJsrq(new Date()); |
| | | water.setJsrxm("his回调"); |
| | | water.setJsrdm("999"); |
| | | if (tjFlowingWaterService.updateById(water)) { |
| | | String jxbz = water.getJxbz(); |
| | | if(StringUtil.isNotBlank(jxbz)){ |
| | | tjOrderDetailService.updateTjOrderDetailsFlowingWaterIdByJxbz(water.getOrderId().toString(),jxbz,water.getTjSerialNumber().toString()); |
| | | remarkService.updateTjOrderRemarkSfbzByJxbz(water.getOrderId().toString(),jxbz,water.getTjSerialNumber().toString()); |
| | | // LambdaUpdateWrapper<TjSampling> wrapper1 = new LambdaUpdateWrapper<>(); |
| | | // wrapper1.eq(TjSampling::getJxbz,jxbz); |
| | | // wrapper1.set(TjSampling::getIsPay,1); |
| | | // tjSamplingService.update(wrapper1); |
| | | }else { |
| | | tjOrderDetailService.updateTjOrderDetailsFlowingWaterIdByJxbzisnull(water.getOrderId().toString(),water.getTjSerialNumber().toString()); |
| | | remarkService.updateTjOrderRemarkSfbzByJxbzisnull(water.getOrderId().toString(),water.getTjSerialNumber().toString()); |
| | | // LambdaUpdateWrapper<TjSampling> wrapper1 = new LambdaUpdateWrapper<>(); |
| | | // wrapper1.isNull(TjSampling::getJxbz); |
| | | // wrapper1.set(TjSampling::getIsPay,1); |
| | | // tjSamplingService.update(wrapper1); |
| | | } |
| | | SysUser user = null; |
| | | if (water.getCreateId()!= null) |
| | | user = userService.getById(water.getCreateId()); |
| | | else user = userService.getById(1L); |
| | | TjOrder tjOrder = orderService.getById(water.getOrderId()); |
| | | List<TjOrderDetail> detailList = tjOrderDetailService.getCaiYangDengJi(water.getOrderId()); |
| | | tjOrderController.addCaiYangDengJi(detailList, !detailList.isEmpty(), tjOrder, user, null); |
| | | } |
| | | }else { |
| | | return AjaxResult.error("查不到流水号: "+feiYongId); |
| | | } |
| | | }else { |
| | | LambdaQueryWrapper<TjFlowingWater> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(TjFlowingWater::getHisTfWaterId, feiYongId).or().eq(TjFlowingWater::getHisWaterId, feiYongId); |
| | |
| | | if (order != null){ |
| | | // 退费 |
| | | String bldh = water.getJxbz(); |
| | | // lisRevoke(water.getTjNumber(),bldh); |
| | | if (bldh != null){ |
| | | remarkService.deleteTjOrderDetailByjxbz(bldh); |
| | | remarkService.updateTjOrderRemarkSfbzByJxbz(order.getOrderId().toString(),bldh,null); |
| | | /* remarkService.deleteTjOrderDetailByjxbz(bldh); |
| | | tjOrderDetailService.deleteTjOrderDetailByjxbz(bldh); |
| | | tjFlowingWaterService.deleteTjOrderDetailByjxbz(bldh); |
| | | transitionService.deleteTjOrderDetailByjxbz(bldh); |
| | | blService.remove(new LambdaQueryWrapper<TjProBl>().eq(TjProBl::getTjh, order.getTjNumber()).eq(TjProBl::getBldh, bldh)); |
| | | tjSamplingMapper.deleteByTjNumAndCusIdAndJxbzo(order.getTjNumber(), order.getUserId(),bldh); |
| | | tjSamplingMapper.deleteByTjNumAndCusIdAndJxbzo(order.getTjNumber(), order.getUserId(),bldh);*/ |
| | | }else { |
| | | tjOrderService.deleteTjOrderByOrderId(order.getOrderId()); |
| | | /* TjCustomer customer = tjCustomerService.getById(order.getUserId()); |
| | | customer.setCardId("0"); |
| | | tjCustomerService.updateById(customer); |
| | | tjOrderService.removeById(order.getOrderId());*/ |
| | | /* tjOrderService.deleteTjOrderByOrderId(order.getOrderId()); |
| | | tjOrderDetailService.deleteTjOrderDetailByOrderDetailId(String.valueOf(order.getOrderId())); |
| | | remarkService.deletedOrderRemarkByTjNum(order.getTjNumber()); |
| | | tjFlowingWaterService.deleteTjFlowingWaterByOrderId(String.valueOf(order.getOrderId())); |
| | | transitionService.deletedTbTransitionByTjNum(order.getTjNumber()); |
| | | ycxmService.delOrderYcXmJyByTjh(order.getTjNumber()); |
| | | tjSamplingMapper.deleteByTjNumAndCusId(order.getTjNumber(), order.getUserId());*/ |
| | | |
| | | TjCustomer customer = tjCustomerService.getById(order.getUserId()); |
| | | customer.setCardId("0"); |
| | | tjCustomerService.updateById(customer); |
| | | tjSamplingMapper.deleteByTjNumAndCusId(order.getTjNumber(), order.getUserId()); |
| | | remarkService.updateTjOrderRemarkSfbzByJxbzisnull(order.getOrderId().toString(),null); |
| | | |
| | | |
| | | } |
| | | water.setPayStasus(2L); |
| | | water.setRefundPersonId("his回调"); |
| | | water.setRefundTime(new Date()); |
| | | water.setRefundPrice(water.getPaidIn()); |
| | | tjFlowingWaterService.updateById(water); |
| | | } |
| | | } |
| | | } |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | private void lisRevoke(String tjNum,String jxbz){ |
| | | LambdaQueryWrapper<TjSampling> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(TjSampling::getTjNum,tjNum); |
| | | if (StrUtil.isNotBlank(jxbz)) |
| | | wrapper.eq(TjSampling::getJxbz,jxbz); |
| | | List<TjSampling> list = tjSamplingMapper.selectList(wrapper); |
| | | List<TjSampling> isMergeList = list.stream().filter(i -> i.getIsMerge() == 1).collect(Collectors.toList()); |
| | | JSONArray array = JSONUtil.createArray(); |
| | | for (TjSampling sampling : isMergeList) { |
| | | String[] proIds = sampling.getProId().split(","); |
| | | for (String proId : proIds) { |
| | | JSONObject object = JSONUtil.createObj(); |
| | | TjProject project = tjProjectMapper.selectById(proId); |
| | | object.putOpt("txm",sampling.getJyxh()); |
| | | object.putOpt("sfxmid",project.getProId()); |
| | | object.putOpt("sfxmname",project.getProName()); |
| | | object.putOpt("primaryKey",proId); |
| | | array.add(object); |
| | | } |
| | | list = list.stream().filter(i -> !i.getProId().equals(sampling.getProId())).collect(Collectors.toList()); |
| | | } |
| | | for (TjSampling sampling : list) { |
| | | String proId = sampling.getProId(); |
| | | JSONObject object = JSONUtil.createObj(); |
| | | TjProject project = tjProjectMapper.selectById(proId); |
| | | object.putOpt("txm",sampling.getJyxh()); |
| | | object.putOpt("sfxmid",project.getProId()); |
| | | object.putOpt("sfxmname",project.getProName()); |
| | | object.putOpt("primaryKey",proId); |
| | | array.add(object); |
| | | } |
| | | String apiUrl = sysConfigService.selectConfigByKey("common_api_url"); |
| | | String hospbm = sysConfigService.selectConfigByKey("common_api_service_hospbm"); |
| | | HashMap<String, Object> hashMap = new HashMap<>(); |
| | | hashMap.put("list",array); |
| | | String post = HttpClientUtils.sendPost(apiUrl + "/api/lis/"+ hospbm +"/revoke", hashMap); |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 获取所有的His字典集合 |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @PostMapping("getZdList") |
| | | public AjaxResult getZdList(@RequestBody Map<String ,Object> params){ |
| | | String hosp = params.get("hosp").toString(); |
| | |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | /** |
| | | * 获取所有的检验项目 |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @PostMapping("getLisXmList") |
| | | public AjaxResult getLisXmList(@RequestBody Map<String ,Object> params){ |
| | | List<Map<String, Object>> list = tjProjectMapper.getLisViewList(); |
| | | return AjaxResult.success(list); |
| | | } |
| | | |
| | | /** |
| | | * Lis确认撤销回调 |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @PostMapping("lisRevoke") |
| | | public AjaxResult lisRevoke(@RequestBody Map<String ,Object> params){ |
| | | List<String> keys = (List<String>) params.get("keys"); |
| | | String czy = params.get("czy").toString(); |
| | | String hospid = params.get("hospid").toString(); |
| | | |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | } |