| | |
| | | import com.kidgrow.common.model.ResultBody; |
| | | import com.kidgrow.common.service.impl.SuperServiceImpl; |
| | | import com.kidgrow.oprationcenter.mapper.SaasClientPayMapper; |
| | | import com.kidgrow.oprationcenter.model.PayManager; |
| | | import com.kidgrow.oprationcenter.model.SaasClientPay; |
| | | import com.kidgrow.oprationcenter.service.AlipayService; |
| | | import com.kidgrow.oprationcenter.service.IPayManagerService; |
| | | import com.kidgrow.oprationcenter.service.ISaasClientPayService; |
| | | import com.kidgrow.oprationcenter.service.WxService; |
| | | import com.kidgrow.oprationcenter.vo.SaasClientPayExcel; |
| | | import com.kidgrow.oprationcenter.vo.SaasClientPayVo; |
| | | //import com.kidgrow.recordcenter.feign.ChildService; |
| | | import com.kidgrow.usercenter.feign.SysDoctorService; |
| | | import com.kidgrow.usercenter.model.SysDoctor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | import org.springframework.cglib.beans.BeanCopier; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.*; |
| | | |
| | | //import com.kidgrow.recordcenter.feign.ChildService; |
| | | |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Autowired |
| | | private SysDoctorService sysDoctorService; |
| | | // @Autowired |
| | | // private ChildService childService; |
| | | @Autowired |
| | | WxService wxService; |
| | | @Autowired |
| | | AlipayService alipayService; |
| | | @Autowired |
| | | IPayManagerService payManagerService; |
| | | @Override |
| | | public PageResult<SaasClientPayVo> findList(Map<String, Object> params){ |
| | | Long doctorId = MapUtils.getLong(params, "doctorId"); |
| | |
| | | beanCopier.copy(saasClientPay,vo,null); |
| | | double v = Double.parseDouble(vo.getPayPrice().toString())/100; |
| | | vo.setPrice(v+""); |
| | | // if (StringUtils.isNotBlank(vo.getChildId())) { |
| | | // Map<String,Object> map=new HashMap<>(); |
| | | // map.put("id",vo.getChildId()); |
| | | // ResultBody byId = childService.findById(map); |
| | | // if(byId.getCode()==0){ |
| | | // Child parse = JSON.parseObject(JSON.toJSONString(byId.getData()), Child.class); |
| | | // if(parse!=null){ |
| | | // vo.setChildName(parse.getChildName()); |
| | | // vo.setChildSex(parse.getChildSex()); |
| | | // vo.setChildBirthday(parse.getChildBirthday()); |
| | | // } |
| | | // } |
| | | // } |
| | | listVo.add(vo); |
| | | } |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public SaasClientPay findByObject(SaasClientPay saasClientPay){ |
| | | return baseMapper.findByObject(saasClientPay); |
| | | } |
| | | |
| | | /** |
| | | * 查看一个科室的某个诊断的支付状态 |
| | | * @param hospitalId |
| | | * @param departmentId |
| | | * @param diaId |
| | | * @return |
| | | */ |
| | | @Override |
| | | public SaasClientPay findModelByObject(Long hospitalId,Long departmentId,String diaId) { |
| | | SaasClientPay saasClientPay = new SaasClientPay(); |
| | | saasClientPay.setCreateHospitalDepartid(departmentId.toString()); |
| | | saasClientPay.setCreateHospitalId(hospitalId); |
| | | saasClientPay.setDiaId(diaId); |
| | | return baseMapper.findByObject(saasClientPay); |
| | | } |
| | | |
| | |
| | | vo.setPayCustom(vc); |
| | | Double vk = Double.parseDouble(saasClientPay.getPayKidgrow().toString())/100; |
| | | vo.setPayKidgrow(vk); |
| | | // if (StringUtils.isNotBlank(saasClientPay.getChildId())) { |
| | | // Map<String,Object> map=new HashMap<>(); |
| | | // map.put("id",saasClientPay.getChildId()); |
| | | // ResultBody byId = childService.findById(map); |
| | | // if(byId.getCode()==0){ |
| | | // Child parse = JSON.parseObject(JSON.toJSONString(byId.getData()), Child.class); |
| | | // if(parse!=null){ |
| | | // vo.setChildName(parse.getChildName()); |
| | | // vo.setChildSex(parse.getChildSex()); |
| | | // vo.setChildBirthday(parse.getChildBirthday()); |
| | | // } |
| | | // } |
| | | // } |
| | | listVo.add(vo); |
| | | } |
| | | } |
| | | return listVo; |
| | | } |
| | | |
| | | /** |
| | | * 获取微信和支付宝的二维码 |
| | | * @param saasClientPay |
| | | * @return |
| | | */ |
| | | @Override |
| | | public ResultBody getCode(SaasClientPay saasClientPay,HttpServletRequest request) throws Exception { |
| | | SaasClientPay modelByObject = findByObject(saasClientPay); |
| | | if(modelByObject!=null){ |
| | | String str=""; |
| | | Map<String, String> wxCode = this.getWxCode(modelByObject, request); |
| | | if(wxCode!=null){ |
| | | saasClientPay.setPrepayId(wxCode.get("prepay_id")); |
| | | str=wxCode.get("code_url"); |
| | | } |
| | | String aliCode = this.getaliPayCode(modelByObject); |
| | | List<String> list=new ArrayList<>(); |
| | | list.add(str); |
| | | list.add(aliCode); |
| | | Map<String,Object> map=new HashMap<>(); |
| | | map.put("list",list); |
| | | double v = Double.parseDouble(modelByObject.getPayPrice().toString())/100; |
| | | map.put("payPrice",v); |
| | | return ResultBody.ok().data(map); |
| | | } |
| | | saasClientPay.setId(UUID.randomUUID().toString().replace("-","")); |
| | | saasClientPay.setOutTradeNo(UUID.randomUUID().toString().replace("-","")); |
| | | PayManager payManager = new PayManager(); |
| | | payManager.setDepartmentId(Long.valueOf(saasClientPay.getCreateHospitalDepartid())); |
| | | payManager.setHospitalId(saasClientPay.getCreateHospitalId()); |
| | | payManager.setIsDel(false); |
| | | payManager.setEnabled(true); |
| | | PayManager byObject = payManagerService.findByObject(payManager); |
| | | if(byObject==null){ |
| | | return ResultBody.failed().msg("该部门或医院没有开通单次支付"); |
| | | } |
| | | |
| | | saasClientPay.setPayPrice(Double.valueOf(byObject.getPayPrice()).intValue()); |
| | | // saasClientPay.setPayPrice(1); |
| | | saasClientPay.setPayKidgrow(Double.valueOf(byObject.getPayKidgrow()).intValue()); |
| | | saasClientPay.setPayCustom(Double.valueOf(byObject.getPayCustom()).intValue()); |
| | | saasClientPay.setPayStatus(0); |
| | | String str=""; |
| | | Map<String, String> wxCode = this.getWxCode(saasClientPay, request); |
| | | if(wxCode!=null){ |
| | | saasClientPay.setPrepayId(wxCode.get("prepay_id")); |
| | | str=wxCode.get("code_url"); |
| | | } |
| | | boolean b = this.saveOrUpdate(saasClientPay); |
| | | String aliCode = this.getaliPayCode(saasClientPay); |
| | | List<String> list=new ArrayList<>(); |
| | | list.add(str); |
| | | list.add(aliCode); |
| | | Map<String,Object> map=new HashMap<>(); |
| | | map.put("list",list); |
| | | double v = byObject.getPayPrice() / 100; |
| | | map.put("payPrice",v); |
| | | return ResultBody.ok().data(map); |
| | | } |
| | | /** |
| | | * 获取微信的二维码 |
| | | * @param saasClientPay |
| | | * @return |
| | | */ |
| | | public Map<String,String> getWxCode(SaasClientPay saasClientPay, HttpServletRequest request) throws Exception{ |
| | | return wxService.getCode(saasClientPay,request); |
| | | |
| | | } |
| | | /** |
| | | * 获取支付宝的二维码 |
| | | * @param saasClientPay |
| | | * @return |
| | | */ |
| | | public String getaliPayCode(SaasClientPay saasClientPay) throws Exception{ |
| | | return alipayService.getCode(saasClientPay); |
| | | } |
| | | } |