|
@ -6,9 +6,11 @@ import com.yihu.jw.entity.base.servicePackage.ServicePackageSignRecordDO;
|
|
|
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
|
|
|
import com.yihu.jw.entity.base.wx.WxPayLogDO;
|
|
|
import com.yihu.jw.entity.base.wx.WxWechatDO;
|
|
|
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
|
|
|
import com.yihu.jw.entity.hospital.mapping.DoctorMappingDO;
|
|
|
import com.yihu.jw.entity.order.BusinessOrderDO;
|
|
|
import com.yihu.jw.entity.order.BusinessOrderRefundDO;
|
|
|
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
|
|
|
import com.yihu.jw.hospital.mapping.dao.DoctorMappingDao;
|
|
|
import com.yihu.jw.hospital.ykyy.service.YkyyService;
|
|
|
import com.yihu.jw.order.dao.BusinessOrderDao;
|
|
@ -21,6 +23,7 @@ import com.yihu.jw.rm.patient.PatientRequestMapping;
|
|
|
import com.yihu.jw.util.common.XMLUtil;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.jw.util.wechat.WeiXinPayUtils;
|
|
|
import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
|
|
|
import com.yihu.jw.utils.StringUtil;
|
|
|
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
|
|
|
import com.yihu.jw.wechat.dao.WechatDao;
|
|
@ -29,6 +32,7 @@ import com.yihu.jw.wechat.service.WxPayLogService;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.checkerframework.checker.units.qual.A;
|
|
|
import org.json.JSONObject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
@ -61,6 +65,8 @@ public class BusinessOrderService {
|
|
|
private YkyyService ykyyService;
|
|
|
@Autowired
|
|
|
private DoctorMappingDao doctorMappingDao;
|
|
|
@Autowired
|
|
|
private WlyyHospitalSysDictDao hospitalSysDictDao;
|
|
|
|
|
|
|
|
|
/**
|
|
@ -77,7 +83,7 @@ public class BusinessOrderService {
|
|
|
String patient = businessOrderDO.getPatient();
|
|
|
BasePatientDO basePatientDO = patientDao.findById(patient);
|
|
|
String orderNo = businessOrderDO.getOrderNo();
|
|
|
String patientId = basePatientDO.getUserId();
|
|
|
String patientId = basePatientDO.getYktId();
|
|
|
String orderAmout = businessOrderDO.getPayPrice().toString();
|
|
|
String description = businessOrderDO.getDescription();
|
|
|
String state = businessOrderDO.getStatus().toString();
|
|
@ -99,6 +105,7 @@ public class BusinessOrderService {
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Map<String, Object> saveOrderAndPay(BusinessOrderDO businessOrderDO,String wechatId) throws Exception {
|
|
|
businessOrderDO.setStatus(0);
|
|
|
businessOrderDO.setCreateTime(new Date());
|
|
@ -114,13 +121,10 @@ public class BusinessOrderService {
|
|
|
if(wxWechatDO==null){
|
|
|
throw new Exception("can't find wechat:the wxId is "+wechatId);
|
|
|
}
|
|
|
String url = wxWechatDO.getBaseUrl();
|
|
|
String notifyUrl =url+"/ykyy"+BaseHospitalRequestMapping.WxPay.Notify;
|
|
|
Map<String,Object> map = unifiedorder(wechatId,businessOrderDO.getDescription(),businessOrderDO.getPayPrice().toString(),WeChatConfig.TRADE_TYPE_JSAPI,openId,businessOrderDO.getOrderNo(),notifyUrl);
|
|
|
String patient = businessOrderDO.getPatient();
|
|
|
BasePatientDO basePatientDO = patientDao.findById(patient);
|
|
|
String orderNo = businessOrderDO.getOrderNo();
|
|
|
String patientId = basePatientDO.getUserId();
|
|
|
String patientId = basePatientDO.getYktId();
|
|
|
String orderAmout = businessOrderDO.getPayPrice().toString();
|
|
|
String description = businessOrderDO.getDescription();
|
|
|
String state = businessOrderDO.getStatus().toString();
|
|
@ -131,7 +135,14 @@ public class BusinessOrderService {
|
|
|
String orderCatagrate = businessOrderDO.getOrderCategory();
|
|
|
String pcCallBack=businessOrderDO.getPcCallbackUrl();
|
|
|
String appCallBack = businessOrderDO.getAppCallbackUrl();
|
|
|
ykyyService.addYktOrder(orderNo,patientId,orderAmout,description,state,orderType,doctorMappingDO.getMappingCode(),payType,null,patientTel,orderCatagrate,pcCallBack,appCallBack);
|
|
|
String url = wxWechatDO.getBaseUrl();
|
|
|
String notifyUrl =url+"/ykyy"+BaseHospitalRequestMapping.WxPay.Notify;
|
|
|
Map<String,Object> map = unifiedorder(wechatId,description,businessOrderDO.getPayPrice().toString(),WeChatConfig.TRADE_TYPE_JSAPI,openId,orderNo,notifyUrl);
|
|
|
String doctorId = "";
|
|
|
if (doctorMappingDO!=null){
|
|
|
doctorId = doctorMappingDO.getMappingCode();
|
|
|
}
|
|
|
ykyyService.addYktOrder(orderNo,patientId,orderAmout,description,state,orderType,doctorId,payType,null,patientTel,orderCatagrate,pcCallBack,appCallBack);
|
|
|
return map;
|
|
|
}
|
|
|
|
|
@ -165,6 +176,32 @@ public class BusinessOrderService {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
|
|
|
public Map<String,Object> selectOrderByRelationCode(String relationCode,String wechatId) throws Exception {
|
|
|
WxWechatDO wxWechatDO = wechatDao.findById(wechatId);
|
|
|
BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(relationCode);
|
|
|
String body = businessOrderDO.getDescription();
|
|
|
List<WlyyHospitalSysDictDO> hospitalSysDictDOS = hospitalSysDictDao.findByDictName("WX_MONEY");
|
|
|
String totalFee = null;
|
|
|
if (hospitalSysDictDOS!=null&&hospitalSysDictDOS.size()!=0){
|
|
|
totalFee= hospitalSysDictDOS.get(0).getDictValue();
|
|
|
}
|
|
|
String patient = businessOrderDO.getPatient();
|
|
|
String openid = "";
|
|
|
if (StringUtils.isNoneBlank(patient)){
|
|
|
List<BasePatientWechatDo> patientWechatDo = patientWechatDao.findByWechatIdAndPatientId(wechatId,patient);
|
|
|
if (patientWechatDo!=null&&patientWechatDo.size()!=0){
|
|
|
openid = patientWechatDo.get(0).getOpenid();
|
|
|
}
|
|
|
}
|
|
|
String ourTradeNo = businessOrderDO.getOrderNo();
|
|
|
|
|
|
String url = wxWechatDO.getBaseUrl();
|
|
|
String notifyUrl =url+"/ykyy"+BaseHospitalRequestMapping.WxPay.Notify;
|
|
|
Map<String,Object> map = unifiedorder(wechatId,body,totalFee,WeChatConfig.TRADE_TYPE_JSAPI,openid,ourTradeNo,notifyUrl);
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 微信下单
|
|
|
* @param wechatId
|
|
@ -177,7 +214,8 @@ public class BusinessOrderService {
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public Map<String,Object> unifiedorder(String wechatId,String body,String totalFee,String tradeType,String openId,String ourTradeNo,String notifyUrl) throws Exception {
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Map<String,Object> unifiedorder(String wechatId,String body,String totalFee,String tradeType,String openId,String ourTradeNo,String notifyUrl) throws Exception {
|
|
|
WxWechatDO wxWechatDO = wechatDao.findById(wechatId);
|
|
|
if(wxWechatDO==null){
|
|
|
throw new Exception("can't find wechat:the wxId is "+wechatId);
|
|
@ -207,8 +245,21 @@ public class BusinessOrderService {
|
|
|
map.put("notify_url",notifyUrl);
|
|
|
map.put("trade_type", tradeType);
|
|
|
map.put("openid", openId);
|
|
|
/* String token_url = "https://api.weixin.qq.com/cgi-bin/token";
|
|
|
String params = "grant_type=client_credential&appid=" + wxWechatDO.getAppId() + "&secret=" + wxWechatDO.getAppSecret();
|
|
|
String result = HttpUtil.sendGet(token_url, params);
|
|
|
JSONObject json = new JSONObject(result);
|
|
|
if (json.has("access_token")) {
|
|
|
String token = json.get("access_token").toString();
|
|
|
String expires_in = json.get("expires_in").toString();
|
|
|
String openidList_url = "https://api.weixin.qq.com/cgi-bin/user/get";
|
|
|
String params1 ="access_token="+ token +"&next_openid=";
|
|
|
String result1 = HttpUtil.sendGet(openidList_url, params1);
|
|
|
JSONObject json1 = new JSONObject(result1);
|
|
|
}*/
|
|
|
Map<String, Object> pay = unifiedorder(map, wxWechatDO.getAppKey());
|
|
|
String returnCode = pay.get("return_code").toString();
|
|
|
|
|
|
if (returnCode.equalsIgnoreCase("SUCCESS")){
|
|
|
String appid = pay.get("appid").toString();
|
|
|
String mchId = pay.get("mch_id").toString();
|
|
@ -406,7 +457,7 @@ public class BusinessOrderService {
|
|
|
BusinessOrderDO businessOrderDO = businessOrderDao.selectByOrderNo(orderNo);
|
|
|
String patient = businessOrderDO.getPatient();
|
|
|
BasePatientDO basePatientDO = patientDao.findById(patient);
|
|
|
String patientId = basePatientDO.getUserId();
|
|
|
String patientId = basePatientDO.getYktId();
|
|
|
String orderAmout = businessOrderDO.getPayPrice().toString();
|
|
|
String description = businessOrderDO.getDescription();
|
|
|
String state = businessOrderDO.getStatus().toString();
|