|
@ -38,6 +38,7 @@ import com.yihu.jw.util.common.QrcodeUtil;
|
|
|
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.ByteToInputStream;
|
|
|
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
|
|
|
import com.yihu.jw.wechat.dao.WechatDao;
|
|
@ -275,7 +276,7 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
|
|
|
businessOrderDO.setStatus(0);
|
|
|
businessOrderDO.setCreateTime(new Date());
|
|
|
businessOrderDO.setUpdateTime(new Date());
|
|
|
businessOrderDO.setOrderNo("HLWYY"+businessOrderDO.getOrderType()+System.currentTimeMillis());
|
|
|
businessOrderDO.setOrderNo("HLWYY"+businessOrderDO.getOrderType()+System.currentTimeMillis()+(int)(Math.random()*900)+100);
|
|
|
businessOrderDO = businessOrderDao.save(businessOrderDO);
|
|
|
List<BasePatientWechatDo> patientWechatDos = patientWechatDao.findByWechatIdAndPatientId(wechatId,businessOrderDO.getPatient());
|
|
|
String openId = "";
|
|
@ -332,13 +333,11 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Map<String,Object> refund(Map<String,String> par,String appKey) throws Exception {
|
|
|
String xml = WeiXinPayUtils.getXmlBeforUnifiedorder(par, appKey);
|
|
|
Map<String, Object> map = WeiXinPayUtils.refund(xml,true);
|
|
|
//创建日志记录
|
|
|
createLog(par,xml,map);
|
|
|
map.remove("wxPayResult");
|
|
|
return map;
|
|
|
public String refund(Map<String,String> par,String appKey) throws Exception {
|
|
|
String xml= WeiXinPayUtils.getXmlBeforUnifiedorder(par, appKey);
|
|
|
logger.info("xml:"+xml);
|
|
|
WlyyHospitalSysDictDO hospitalSysDictDO = hospitalSysDictDao.findById("REFUND");
|
|
|
return HttpUtil.doRefund("https://api.mch.weixin.qq.com/secapi/pay/refund",xml,hospitalSysDictDO.getDictCode(),hospitalSysDictDO.getDictValue());
|
|
|
}
|
|
|
|
|
|
|
|
@ -486,7 +485,10 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
|
|
|
if (patientDO==null){
|
|
|
throw new Exception("this patient not exit");
|
|
|
}
|
|
|
BusinessOrderRefundDO orderRefundDO = new BusinessOrderRefundDO();
|
|
|
BusinessOrderRefundDO orderRefundDO = orderRefundDao.selectByOrderNo(orderNo);
|
|
|
if (orderRefundDO==null){
|
|
|
orderRefundDO = new BusinessOrderRefundDO();
|
|
|
}
|
|
|
orderRefundDO.setCreateTime(new Date());
|
|
|
orderRefundDO.setUpdateTime(new Date());
|
|
|
orderRefundDO.setStatus(1);
|
|
@ -495,12 +497,15 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
|
|
|
orderRefundDO.setRefundPrice(refundPrice);
|
|
|
orderRefundDO.setAppId(wxWechatDO.getAppId());
|
|
|
orderRefundDO.setMchId(wxWechatDO.getMchId());
|
|
|
orderRefundDO.setOutRefundNo("HLWYY"+businessOrderDO.getOrderType()+System.currentTimeMillis());
|
|
|
orderRefundDO.setOutRefundNo("HLWYY"+businessOrderDO.getOrderType()+System.currentTimeMillis()+(int)(Math.random()*900)+100);
|
|
|
orderRefundDO.setPatient(patient);
|
|
|
orderRefundDO.setPatientName(patientDO.getName());
|
|
|
orderRefundDO.setRefundDesc(description);
|
|
|
orderRefundDO = orderRefundDao.save(orderRefundDO);
|
|
|
Map<String,Object> map = refund(wechatId,orderRefundDO.getOrderNo(),orderRefundDO.getOutRefundNo(),orderRefundDO.getOrderPrice().toString(),orderRefundDO.getRefundPrice().toString(),orderRefundDO.getRefundDesc());
|
|
|
Integer orderPrice = orderRefundDO.getOrderPrice().intValue();
|
|
|
Integer refundPrice1 = orderRefundDO.getRefundPrice().intValue();
|
|
|
Map<String,Object> map = refund(wechatId,orderRefundDO.getOrderNo(),orderRefundDO.getOutRefundNo(),orderPrice.toString(),refundPrice1.toString(),orderRefundDO.getRefundDesc());
|
|
|
logger.info("map"+map);
|
|
|
if (map.get("return_code").toString().equalsIgnoreCase("SUCCESS")){
|
|
|
orderRefundDO.setStatus(2);
|
|
|
orderRefundDO.setRefundTime(new Date());
|
|
@ -531,7 +536,10 @@ public class BusinessOrderService extends BaseJpaService<BusinessOrderDO,Busines
|
|
|
map.put("refund_fee",refundFee);
|
|
|
map.put("total_fee",totalFee);
|
|
|
map.put("refund_desc",descrption);
|
|
|
Map<String, Object> refund = refund(map, wxWechatDO.getAppKey());
|
|
|
logger.info("map:"+map);
|
|
|
|
|
|
String res = refund(map, wxWechatDO.getAppKey());
|
|
|
Map<String, Object> refund = XMLUtil.xmltoMap(res);
|
|
|
return refund;
|
|
|
}
|
|
|
|