1 /** 2 * 3 * @Title: getDoctorProfit 4 * @Description: 获取当日的利润明细(已付款以后的状态,包含当日总计) 5 * @author: lijunwei 6 * @date 2018年8月25日 下午3:35:24 7 * @param queryDate 8 * @param doctorid 9 * @return Map<String,Object> 10 */ 11 @SuppressWarnings("unchecked") 12 @Override 13 public Map<String,Object> getDoctorProfit(String queryDate,Long doctorid){ 14 15 try { 16 if (!StringUtils.isEmpty(queryDate) && !StringUtils.isEmpty(doctorid)) {//参数不为空 17 18 Map<String,Object> map = new HashMap<>(); 19 BigDecimal money_prescription_all = new BigDecimal(0);//线上调理(即购买方案)当日合计 20 BigDecimal money_register_all = new BigDecimal(0);//挂号费用当日合计 21 BigDecimal total_money_all = new BigDecimal(0);//当日利润总计 (挂号费+线上调理费) 22 23 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 24 Date startdate = sdf.parse(queryDate+" 00:00:00"); 25 Date enddate = sdf.parse(queryDate+" 23:59:59"); 26 27 List<MmsPrescriptionMain> mainList = mmsPrescriptionMainService.list( 28 new QueryWrapper<MmsPrescriptionMain>() 29 .lambda() 30 .eq(MmsPrescriptionMain::getDoctorId, doctorid) 31 .eq(MmsPrescriptionMain::getStatus, PrescriptionStatusEnum.SETTLEMENT) 32 .gt(MmsPrescriptionMain::getPaymentTime, startdate) 33 .lt(MmsPrescriptionMain::getPaymentTime, enddate) 34 .orderByDesc(MmsPrescriptionMain::getPaymentTime) 35 ); 36 if(!CollectionUtil.isEmpty(mainList)) { 37 38 //通过医生id获取医生的分润比例 39 Double proportion = 20.00;//默认为百分之20 40 MmsDoctor md = new MmsDoctor(); 41 md.setDoctorid(doctorid); 42 MmsDoctor doctor = super.getOne(md); 43 if(doctor != null&&!StringUtils.isEmpty(doctor.getProrata())) { 44 proportion = doctor.getProrata(); 45 } 46 47 for (MmsPrescriptionMain mmsPrescriptionMain : mainList) { 48 //按照比例对线上调理费进行分润 49 BigDecimal prescriptionFee = DecimalCalculate.safeDivide(DecimalCalculate.safeMultiply(mmsPrescriptionMain.getTotalMoney(), proportion),100,2); 50 mmsPrescriptionMain.setTotalMoney(prescriptionFee); 51 52 money_prescription_all = DecimalCalculate.safeAdd(money_prescription_all, mmsPrescriptionMain.getTotalMoney()); 53 //通过患者userName:ovBR_1iLA1-5F4gNvQq5gd0dYqI4获取患者姓名 54 PmsUser pmsUser = pmsUserService.findByOpenid(mmsPrescriptionMain.getUserName()); 55 mmsPrescriptionMain.setUserName(pmsUser != null ? pmsUser.getName():""); 56 57 if(!StringUtils.isEmpty(mmsPrescriptionMain.getRegisterId())) {//挂号 58 MmsRegister mmsRegister = mmsRegisterService.getById(mmsPrescriptionMain.getRegisterId());//获取挂号记录详情 59 if(mmsRegister != null) { 60 61 //按照比例对挂号费进行分润 62 DecimalFormat dFormat = new DecimalFormat("#.00"); 63 BigDecimal registerFee = DecimalCalculate.safeDivide(DecimalCalculate.safeMultiply(mmsRegister.getMoney(), proportion),100); 64 String money = dFormat.format(registerFee); 65 mmsPrescriptionMain.setMoney(BigDecimal.valueOf(Double.parseDouble(money)));//挂号费 66 67 money_register_all = DecimalCalculate.safeAdd(money_register_all, BigDecimal.valueOf(Double.parseDouble(money))); 68 } 69 } 70 } 71 72 //当日利润总计 (挂号费+线上调理费) 73 total_money_all = DecimalCalculate.safeAdd(money_prescription_all, money_register_all); 74 75 map.put("money_prescription_all", money_prescription_all);//线上调理(即购买方案)当日合计 76 map.put("money_register_all", money_register_all);//挂号费用当日合计 77 map.put("total_money_all", DecimalCalculate.setScaleDown(total_money_all,2));//医生利润当日合计总额 78 map.put("mainList", mainList);//医生利润明细 79 80 return map; 81 82 }else { 83 return null; 84 } 85 86 }else { 87 return null; 88 } 89 90 } catch (ParseException e) { 91 e.printStackTrace(); 92 } 93 94 return null; 95 }
写博客是为了记住自己容易忘记的东西,另外也是对自己工作的总结,文章可以转载,无需版权。希望尽自己的努力,做到更好,大家一起努力进步!
如果有什么问题,欢迎大家一起探讨,代码如有问题,欢迎各位大神指正!
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/15444.html