|
@ -3,6 +3,8 @@ package com.yihu.jw.order;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;
|
|
|
|
import com.yihu.jw.entity.IntegerIdentityEntity;
|
|
import com.yihu.jw.entity.base.im.ConsultDo;
|
|
import com.yihu.jw.entity.base.im.ConsultDo;
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
|
|
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
|
|
@ -26,14 +28,17 @@ import com.yihu.jw.order.dao.BusinessOrderDao;
|
|
import com.yihu.jw.order.dao.BusinessOrderRefundDao;
|
|
import com.yihu.jw.order.dao.BusinessOrderRefundDao;
|
|
import com.yihu.jw.order.dao.ConsultOrderDao;
|
|
import com.yihu.jw.order.dao.ConsultOrderDao;
|
|
import com.yihu.jw.order.pay.wx.WeChatConfig;
|
|
import com.yihu.jw.order.pay.wx.WeChatConfig;
|
|
|
|
import com.yihu.jw.order.pay.ylz.YlzPayService;
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
|
|
|
|
|
import com.yihu.jw.util.common.BeanUtils;
|
|
import com.yihu.jw.util.common.XMLUtil;
|
|
import com.yihu.jw.util.common.XMLUtil;
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
import com.yihu.jw.util.wechat.WeiXinPayUtils;
|
|
import com.yihu.jw.util.wechat.WeiXinPayUtils;
|
|
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
|
|
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
|
|
import com.yihu.jw.wechat.dao.WechatDao;
|
|
import com.yihu.jw.wechat.dao.WechatDao;
|
|
import com.yihu.jw.wechat.dao.WxPayLogDao;
|
|
import com.yihu.jw.wechat.dao.WxPayLogDao;
|
|
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
@ -51,7 +56,7 @@ import java.util.*;
|
|
* 业务订单
|
|
* 业务订单
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
public class BusinessOrderService {
|
|
|
|
|
|
public class BusinessOrderService extends BaseJpaService {
|
|
|
|
|
|
private Logger logger = LoggerFactory.getLogger(BusinessOrderService.class);
|
|
private Logger logger = LoggerFactory.getLogger(BusinessOrderService.class);
|
|
|
|
|
|
@ -83,6 +88,8 @@ public class BusinessOrderService {
|
|
private YkyyEntranceService ykyyEntranceService;
|
|
private YkyyEntranceService ykyyEntranceService;
|
|
@Autowired
|
|
@Autowired
|
|
private PrescriptionInfoDao prescriptionInfoDao;
|
|
private PrescriptionInfoDao prescriptionInfoDao;
|
|
|
|
@Autowired
|
|
|
|
private YlzPayService ylzPayService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -130,7 +137,8 @@ public class BusinessOrderService {
|
|
businessOrderDO = businessOrderDao.save(businessOrderDO);
|
|
businessOrderDO = businessOrderDao.save(businessOrderDO);
|
|
businessOrderDOS.add(businessOrderDO);
|
|
businessOrderDOS.add(businessOrderDO);
|
|
wlyyPrescriptionDO.setOrderNo(businessOrderDO.getOrderNo());
|
|
wlyyPrescriptionDO.setOrderNo(businessOrderDO.getOrderNo());
|
|
prescriptionDao.save(wlyyPrescriptionDO);
|
|
|
|
|
|
wlyyPrescriptionDO.setOrderId(getCode());
|
|
|
|
wlyyPrescriptionDO = prescriptionDao.save(wlyyPrescriptionDO);
|
|
JSONArray array = new JSONArray();
|
|
JSONArray array = new JSONArray();
|
|
List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS = prescriptionInfoDao.findByPrescriptionId(code);
|
|
List<WlyyPrescriptionInfoDO> wlyyPrescriptionInfoDOS = prescriptionInfoDao.findByPrescriptionId(code);
|
|
for (WlyyPrescriptionInfoDO prescriptionInfoDO:wlyyPrescriptionInfoDOS){
|
|
for (WlyyPrescriptionInfoDO prescriptionInfoDO:wlyyPrescriptionInfoDOS){
|
|
@ -259,7 +267,7 @@ public class BusinessOrderService {
|
|
businessOrderDO.setStatus(0);
|
|
businessOrderDO.setStatus(0);
|
|
businessOrderDO.setCreateTime(new Date());
|
|
businessOrderDO.setCreateTime(new Date());
|
|
businessOrderDO.setUpdateTime(new Date());
|
|
businessOrderDO.setUpdateTime(new Date());
|
|
businessOrderDO.setOrderNo("VAS"+businessOrderDO.getOrderType()+System.currentTimeMillis());
|
|
|
|
|
|
businessOrderDO.setOrderNo("HLWLYY"+businessOrderDO.getOrderType()+System.currentTimeMillis());
|
|
businessOrderDO = businessOrderDao.save(businessOrderDO);
|
|
businessOrderDO = businessOrderDao.save(businessOrderDO);
|
|
List<BasePatientWechatDo> patientWechatDos = patientWechatDao.findByWechatIdAndPatientId(wechatId,businessOrderDO.getPatient());
|
|
List<BasePatientWechatDo> patientWechatDos = patientWechatDao.findByWechatIdAndPatientId(wechatId,businessOrderDO.getPatient());
|
|
String openId = "";
|
|
String openId = "";
|
|
@ -457,7 +465,7 @@ public class BusinessOrderService {
|
|
orderRefundDO.setRefundPrice(refundPrice);
|
|
orderRefundDO.setRefundPrice(refundPrice);
|
|
orderRefundDO.setAppId(wxWechatDO.getAppId());
|
|
orderRefundDO.setAppId(wxWechatDO.getAppId());
|
|
orderRefundDO.setMchId(wxWechatDO.getMchId());
|
|
orderRefundDO.setMchId(wxWechatDO.getMchId());
|
|
orderRefundDO.setOutRefundNo("VAS"+businessOrderDO.getOrderType()+System.currentTimeMillis());
|
|
|
|
|
|
orderRefundDO.setOutRefundNo("HLWLYY"+businessOrderDO.getOrderType()+System.currentTimeMillis());
|
|
orderRefundDO.setPatient(patient);
|
|
orderRefundDO.setPatient(patient);
|
|
orderRefundDO.setPatientName(patientDO.getName());
|
|
orderRefundDO.setPatientName(patientDO.getName());
|
|
orderRefundDO.setRefundDesc(description);
|
|
orderRefundDO.setRefundDesc(description);
|
|
@ -665,4 +673,153 @@ public class BusinessOrderService {
|
|
public void setPrescriptionDao(PrescriptionDao prescriptionDao) {
|
|
public void setPrescriptionDao(PrescriptionDao prescriptionDao) {
|
|
this.prescriptionDao = prescriptionDao;
|
|
this.prescriptionDao = prescriptionDao;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* 中山医院统一支付
|
|
|
|
*
|
|
|
|
* @param relationCode
|
|
|
|
* @param relationName
|
|
|
|
* @param orderCategory 1专家咨询2复诊4处方
|
|
|
|
* @param remark
|
|
|
|
* @param patient
|
|
|
|
* @param patientName
|
|
|
|
* @param doctor
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public BusinessOrderDO recharge(String relationCode,String relationName,String orderCategory,String remark,String patient,String patientName,String doctor,Double payPrice){
|
|
|
|
logger.info("参数========="+relationCode+"=="+orderCategory+"=="+patient+"=="+doctor+"==="+payPrice);
|
|
|
|
BusinessOrderDO businessOrderDO = new BusinessOrderDO();
|
|
|
|
if (orderCategory.equalsIgnoreCase("4")){
|
|
|
|
businessOrderDO = businessOrderDao.selectByRelationCode(relationCode);
|
|
|
|
if (businessOrderDO==null){
|
|
|
|
businessOrderDO = new BusinessOrderDO();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
businessOrderDO.setOrderNo("HLWLYY"+System.currentTimeMillis()+(int)(Math.random()*900)+100);
|
|
|
|
businessOrderDO.setCreateTime(new Date());
|
|
|
|
businessOrderDO.setUpdateTime(new Date());
|
|
|
|
businessOrderDO.setUploadStatus(0);
|
|
|
|
businessOrderDO.setRelationCode(relationCode);
|
|
|
|
businessOrderDO.setRelationName(relationName);
|
|
|
|
businessOrderDO.setOrderCategory(orderCategory);
|
|
|
|
businessOrderDO.setOrderType(1);
|
|
|
|
businessOrderDO.setRematk(remark);
|
|
|
|
businessOrderDO.setPatient(patient);
|
|
|
|
businessOrderDO.setPatientName(patientName);
|
|
|
|
businessOrderDO.setPayType(3);
|
|
|
|
businessOrderDO.setStatus(0);
|
|
|
|
businessOrderDO.setPayPrice(payPrice);
|
|
|
|
businessOrderDO.setDoctor(doctor);
|
|
|
|
businessOrderDO = businessOrderDao.save(businessOrderDO);
|
|
|
|
return businessOrderDO;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param code
|
|
|
|
* @param depositType WX_MIN 微信小程序,WX_PUB 微信公众号 ,ALI_WAP 支付宝生活号 WX_QR pc扫码,ALI_QR支付宝扫码
|
|
|
|
* @param wechatId
|
|
|
|
* @return
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public String reChargeJSON(String code,String depositType,String wechatId) throws Exception {
|
|
|
|
String response = null;
|
|
|
|
WxWechatDO wxWechatDO = wechatDao.findById(wechatId);
|
|
|
|
if(wxWechatDO==null){
|
|
|
|
throw new Exception("can't find wechat:the wxId is "+wechatId);
|
|
|
|
}
|
|
|
|
WlyyHospitalSysDictDO hospitalSysDictDO =hospitalSysDictDao.findById("YLZ_NOTIFY_URL");
|
|
|
|
BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(code);
|
|
|
|
if (businessOrderDO!=null){
|
|
|
|
BasePatientDO patientDO = patientDao.findById(businessOrderDO.getPatient());
|
|
|
|
String idcard = "";
|
|
|
|
String ssc = "";
|
|
|
|
if (patientDO!=null){
|
|
|
|
idcard = patientDO.getIdcard();
|
|
|
|
}
|
|
|
|
String openId = "";
|
|
|
|
List<BasePatientWechatDo> patientWechatDos = patientWechatDao.findByWechatIdAndPatientId(wechatId,businessOrderDO.getPatient());
|
|
|
|
if (patientWechatDos!=null&&patientWechatDos.size()!=0){
|
|
|
|
BasePatientWechatDo patientWechatDo = patientWechatDos.get(0);
|
|
|
|
openId = patientWechatDo.getOpenid();
|
|
|
|
}
|
|
|
|
String price = businessOrderDO.getPayPrice().toString();
|
|
|
|
String notifyUrl = hospitalSysDictDO.getDictCode();
|
|
|
|
response = ylzPayService.rechargeConsume("123456",businessOrderDO.getPatientName(),"01",ssc,"01",idcard,depositType,
|
|
|
|
price,price,businessOrderDO.getOrderNo(),idcard,"1",businessOrderDO.getPatientName(),businessOrderDO.getRematk(),openId,notifyUrl,notifyUrl,null);
|
|
|
|
}else {
|
|
|
|
return "找不到订单!";
|
|
|
|
}
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 易联众退款
|
|
|
|
* @param wechatId
|
|
|
|
* @param patient
|
|
|
|
* @param orderNo
|
|
|
|
* @param refundPrice
|
|
|
|
* @param description
|
|
|
|
* @return
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public Map<String,Object> ylzOrderRefund(String wechatId,String patient,String orderNo,Double refundPrice,String description) throws Exception {
|
|
|
|
WxWechatDO wxWechatDO = wechatDao.findById(wechatId);
|
|
|
|
if (wxWechatDO==null){
|
|
|
|
throw new Exception("this wechatId is null");
|
|
|
|
}
|
|
|
|
BusinessOrderDO businessOrderDO = businessOrderDao.selectByOrderNo(orderNo);
|
|
|
|
if (businessOrderDO==null){
|
|
|
|
throw new Exception("this orderId not exit");
|
|
|
|
}
|
|
|
|
BasePatientDO patientDO = patientDao.findById(patient);
|
|
|
|
if (patientDO==null){
|
|
|
|
throw new Exception("this patient not exit");
|
|
|
|
}
|
|
|
|
BusinessOrderRefundDO orderRefundDO = new BusinessOrderRefundDO();
|
|
|
|
orderRefundDO = orderRefundDao.selectByOrderNo(orderNo);
|
|
|
|
if (orderRefundDO==null){
|
|
|
|
orderRefundDO = new BusinessOrderRefundDO();
|
|
|
|
}
|
|
|
|
orderRefundDO.setCreateTime(new Date());
|
|
|
|
orderRefundDO.setUpdateTime(new Date());
|
|
|
|
orderRefundDO.setStatus(1);
|
|
|
|
orderRefundDO.setOrderNo(orderNo);
|
|
|
|
orderRefundDO.setOrderPrice(businessOrderDO.getPayPrice());
|
|
|
|
orderRefundDO.setRefundPrice(refundPrice);
|
|
|
|
orderRefundDO.setAppId(wxWechatDO.getAppId());
|
|
|
|
orderRefundDO.setMchId(wxWechatDO.getMchId());
|
|
|
|
orderRefundDO.setOutRefundNo("HLWLYY"+businessOrderDO.getOrderCategory()+System.currentTimeMillis());
|
|
|
|
orderRefundDO.setPatient(patient);
|
|
|
|
orderRefundDO.setPatientName(patientDO.getName());
|
|
|
|
orderRefundDO.setRefundDesc(description);
|
|
|
|
orderRefundDO = orderRefundDao.save(orderRefundDO);
|
|
|
|
String map = ylzPayService.refund(patientDO.getIdcard(),"123456",patientDO.getName(),"01",patientDO.getIdcard(),"01",orderRefundDO.getRefundPrice().toString(),"1",orderRefundDO.getOrderNo(),orderRefundDO.getOutRefundNo(),patientDO.getIdcard());
|
|
|
|
JSONObject object = JSONObject.parseObject(map);
|
|
|
|
if (object.get("respCode").toString().equalsIgnoreCase("000000")){
|
|
|
|
orderRefundDO.setStatus(2);
|
|
|
|
orderRefundDO.setRefundTime(new Date());
|
|
|
|
orderRefundDao.save(orderRefundDO);
|
|
|
|
}
|
|
|
|
return object;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 易联众查询交易订单
|
|
|
|
*
|
|
|
|
* @param orderNo
|
|
|
|
* @param tradeType
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public JSONObject tradeQuery(String orderNo,String tradeType){
|
|
|
|
BusinessOrderDO businessOrderDO = businessOrderDao.selectByOrderNo(orderNo);
|
|
|
|
String response = ylzPayService.tradeQuery(null,null,businessOrderDO.getPatientName(),orderNo,tradeType,businessOrderDO.getRematk());
|
|
|
|
JSONObject object = JSONObject.parseObject(response);
|
|
|
|
return object;
|
|
|
|
}
|
|
}
|
|
}
|