package com.ltkj.web.controller.callback; import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ltkj.common.core.domain.AjaxResult; import com.ltkj.hosp.domain.*; import com.ltkj.hosp.mapper.TjSamplingMapper; import com.ltkj.hosp.service.*; 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.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import java.util.List; import java.util.Map; /** * 对接其他平台提供的回调服务 */ @Slf4j @RestController @RequestMapping("callBack") public class CallBackController { @Autowired private HisSyncDictService hisSyncDictService; @Autowired private ITjFlowingWaterService tjFlowingWaterService; @Autowired private ITjOrderRemarkService remarkService; @Autowired private ITjOrderDetailService tjOrderDetailService; @Autowired private ITbTransitionService transitionService; @Autowired private TjSamplingMapper tjSamplingMapper; @Autowired private TjProBlService blService; @Autowired private ITjOrderService tjOrderService; @Autowired private ITjCustomerService tjCustomerService; @Autowired private ITjOrderService orderService; /** * 收退费回调接口 * @param params * @return */ @PostMapping("pushZhiFuMsg") public AjaxResult pushZhiFuMsg(@RequestBody Map params){ log.info("回调 ->{}", JSONUtil.toJsonStr(params)); String type = params.get("type").toString(); // type 1为煤机医院传参 // feiYongId 费用Id // yeWuLx 业务类型,1-收费;2-退费/作废 if (type.equals("1")){ String feiYongId = params.get("feiYongId").toString(); String yeWuLx = params.get("yeWuLx").toString(); // 收费 if (yeWuLx.equals("1")){ LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(TjFlowingWater::getHisWaterId, feiYongId); TjFlowingWater water = tjFlowingWaterService.getOne(wrapper); water.setPayStasus(1L); tjFlowingWaterService.updateById(water); }else { LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(TjFlowingWater::getHisTfWaterId, feiYongId).or().eq(TjFlowingWater::getHisWaterId, feiYongId); TjFlowingWater water = tjFlowingWaterService.getOne(wrapper); TjOrder order = orderService.getById(water.getOrderId()); if (order != null){ // 退费 String bldh = water.getJxbz(); if (bldh != null){ remarkService.deleteTjOrderDetailByjxbz(bldh); tjOrderDetailService.deleteTjOrderDetailByjxbz(bldh); tjFlowingWaterService.deleteTjOrderDetailByjxbz(bldh); transitionService.deleteTjOrderDetailByjxbz(bldh); blService.remove(new LambdaQueryWrapper().eq(TjProBl::getTjh, order.getTjNumber()).eq(TjProBl::getBldh, bldh)); tjSamplingMapper.deleteByTjNumAndCusIdAndJxbzo(order.getTjNumber(), order.getUserId(),bldh); }else { tjOrderService.deleteTjOrderByOrderId(order.getOrderId()); tjOrderDetailService.deleteTjOrderDetailByOrderDetailId(String.valueOf(order.getOrderId())); remarkService.deletedOrderRemarkByTjNum(order.getTjNumber()); tjFlowingWaterService.deleteTjFlowingWaterByOrderId(String.valueOf(order.getOrderId())); transitionService.deletedTbTransitionByTjNum(order.getTjNumber()); TjCustomer customer = tjCustomerService.getById(order.getUserId()); customer.setCardId("0"); tjCustomerService.updateById(customer); tjSamplingMapper.deleteByTjNumAndCusId(order.getTjNumber(), order.getUserId()); } } } } return AjaxResult.success(); } @PostMapping("getZdList") public AjaxResult getZdList(@RequestBody Map params){ String hosp = params.get("hosp").toString(); LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); wrapper.eq(HisSyncDict::getHospId,hosp); List list = hisSyncDictService.list(wrapper); return AjaxResult.success(list); } }