|
|
@ -21,6 +21,7 @@ import com.ynxbd.common.result.ServiceException; |
|
|
|
import com.ynxbd.common.service.*; |
|
|
|
import com.ynxbd.common.service.*; |
|
|
|
import com.ynxbd.common.service.params.RegParams; |
|
|
|
import com.ynxbd.common.service.params.RegParams; |
|
|
|
import com.ynxbd.wx.config.WeChatConfig; |
|
|
|
import com.ynxbd.wx.config.WeChatConfig; |
|
|
|
|
|
|
|
import com.ynxbd.wx.wxfactory.ReqParamHelper; |
|
|
|
import com.ynxbd.wx.wxfactory.WxPayHelper; |
|
|
|
import com.ynxbd.wx.wxfactory.WxPayHelper; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.codec.digest.DigestUtils; |
|
|
|
import org.apache.commons.codec.digest.DigestUtils; |
|
|
@ -139,11 +140,11 @@ public class PayAction extends BaseAction { |
|
|
|
* @param payCode 支付方式 |
|
|
|
* @param payCode 支付方式 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Action("PeisPay") |
|
|
|
@Action("PeisPay") |
|
|
|
public Result PeisPay(String openid, String patientId, String treatNum, String totalFee, String recipeId,String payCode){ |
|
|
|
public Result PeisPay(String openid, String patientId, String treatNum, String totalFee, String recipeId, String payCode) { |
|
|
|
if(openid==null||patientId==null||treatNum==null||totalFee==null||recipeId==null){ |
|
|
|
if (openid == null || patientId == null || treatNum == null || totalFee == null || recipeId == null) { |
|
|
|
return Result.error(ResultEnum.PARAM_IS_DEFECT); |
|
|
|
return Result.error(ResultEnum.PARAM_IS_DEFECT); |
|
|
|
} |
|
|
|
} |
|
|
|
if(new BigDecimal(totalFee).compareTo(BigDecimal.ZERO)==0){ |
|
|
|
if (new BigDecimal(totalFee).compareTo(BigDecimal.ZERO) == 0) { |
|
|
|
return Result.error(ResultEnum.PAY_MONEY_IS_ZERO); |
|
|
|
return Result.error(ResultEnum.PAY_MONEY_IS_ZERO); |
|
|
|
} |
|
|
|
} |
|
|
|
MerchantEnum merchantEnum = MerchantEnum.getMerchantEnumByCode(payCode); |
|
|
|
MerchantEnum merchantEnum = MerchantEnum.getMerchantEnumByCode(payCode); |
|
|
@ -152,8 +153,8 @@ public class PayAction extends BaseAction { |
|
|
|
} |
|
|
|
} |
|
|
|
String outTradeNo = CodeHelper.getOutTradeNo(merchantEnum); |
|
|
|
String outTradeNo = CodeHelper.getOutTradeNo(merchantEnum); |
|
|
|
PeisService peisService = new PeisService(); |
|
|
|
PeisService peisService = new PeisService(); |
|
|
|
if(!peisService.Reserve(openid,patientId,treatNum,outTradeNo,totalFee,recipeId)){ |
|
|
|
if (!peisService.Reserve(openid, patientId, treatNum, outTradeNo, totalFee, recipeId)) { |
|
|
|
log.info("{} [体检预约]体检预约信息保存失败 patientId={},recipeId-{}", merchantEnum.NAME, patientId,recipeId); |
|
|
|
log.info("{} [体检预约]体检预约信息保存失败 patientId={},recipeId-{}", merchantEnum.NAME, patientId, recipeId); |
|
|
|
return Result.error(ResultEnum.SPECIFIED_QUESTIONED_USER_NOT_EXIST); |
|
|
|
return Result.error(ResultEnum.SPECIFIED_QUESTIONED_USER_NOT_EXIST); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -170,6 +171,7 @@ public class PayAction extends BaseAction { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 体检退费 |
|
|
|
* 体检退费 |
|
|
|
|
|
|
|
* |
|
|
|
* @param recipeId 订单号 |
|
|
|
* @param recipeId 订单号 |
|
|
|
* @param payCode 支付方式 |
|
|
|
* @param payCode 支付方式 |
|
|
|
* @param totalFee 订单金额 |
|
|
|
* @param totalFee 订单金额 |
|
|
@ -177,22 +179,21 @@ public class PayAction extends BaseAction { |
|
|
|
* @param openid openid |
|
|
|
* @param openid openid |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Action("peisRefund") |
|
|
|
@Action("peisRefund") |
|
|
|
public Result peisRefund(String recipeId, String payCode, String outTradeNo, String totalFee,String openid){ |
|
|
|
public Result peisRefund(String recipeId, String payCode, String outTradeNo, String totalFee, String openid) { |
|
|
|
log.info("[体检预约]取消预约退费,recipeId-{}.payCode-{},outTradeNo-{},totalFee-{},openid-{}",recipeId,payCode,outTradeNo,totalFee,openid); |
|
|
|
log.info("[体检预约]取消预约退费,recipeId-{}.payCode-{},outTradeNo-{},totalFee-{},openid-{}", recipeId, payCode, outTradeNo, totalFee, openid); |
|
|
|
PeisService peisService = new PeisService(); |
|
|
|
PeisService peisService = new PeisService(); |
|
|
|
MerchantEnum merchantEnum = MerchantEnum.getMerchantEnumByCode(payCode); |
|
|
|
MerchantEnum merchantEnum = MerchantEnum.getMerchantEnumByCode(payCode); |
|
|
|
PeisDao peisDao = new PeisDao(); |
|
|
|
PeisDao peisDao = new PeisDao(); |
|
|
|
Recipe recipe = peisDao.selectByOutTradeNo(outTradeNo); |
|
|
|
Recipe recipe = peisDao.selectByOutTradeNo(outTradeNo); |
|
|
|
if(new BigDecimal(totalFee).compareTo(recipe.getTotalFee())!=0){ |
|
|
|
if (new BigDecimal(totalFee).compareTo(recipe.getTotalFee()) != 0) { |
|
|
|
return Result.error(ResultEnum.REFUND_MONEY_ERROR); |
|
|
|
return Result.error(ResultEnum.REFUND_MONEY_ERROR); |
|
|
|
} |
|
|
|
} |
|
|
|
String pushMessage = "已申请退款,原因:患者主动取消退费,订单号:" + outTradeNo +"orderNo:"+ recipeId; |
|
|
|
String pushMessage = "已申请退款,原因:患者主动取消退费,订单号:" + outTradeNo + "orderNo:" + recipeId; |
|
|
|
Result result = peisService.peisAutoRefund(recipeId,merchantEnum,outTradeNo,new BigDecimal(totalFee),pushMessage,new Date(),openid); |
|
|
|
Result result = peisService.peisAutoRefund(recipeId, merchantEnum, outTradeNo, new BigDecimal(totalFee), pushMessage, new Date(), openid); |
|
|
|
if(result.isSuccess()){ |
|
|
|
if (result.isSuccess()) { |
|
|
|
peisService.peisRefund(recipeId,"OK",""); |
|
|
|
peisService.peisRefund(recipeId, "OK", ""); |
|
|
|
} |
|
|
|
} else { |
|
|
|
else { |
|
|
|
peisService.peisRefund(recipeId, "FAIL", result.getMessage()); |
|
|
|
peisService.peisRefund(recipeId,"FAIL",result.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
@ -504,7 +505,7 @@ public class PayAction extends BaseAction { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Action("refundRegister") |
|
|
|
@Action("refundRegister") |
|
|
|
public Result refundRegister(String hisTransNo){ |
|
|
|
public Result refundRegister(String hisTransNo) { |
|
|
|
return new RegService().refundRegister(hisTransNo); |
|
|
|
return new RegService().refundRegister(hisTransNo); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -807,16 +808,26 @@ public class PayAction extends BaseAction { |
|
|
|
* [在线问诊]支付 |
|
|
|
* [在线问诊]支付 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Action("createOLOrder") |
|
|
|
@Action("createOLOrder") |
|
|
|
public Result createOLOrder(String payCode, String openid, String patientId, BigDecimal totalFee, String deptCode, String deptName, String doctName, String doctCode) { |
|
|
|
public Result createOLOrder(String payCode, String outTradeNo, String enOutTradeNo, String openid, String patientId, BigDecimal totalFee, String deptCode, String deptName, String doctName, String doctCode) { |
|
|
|
if ( totalFee == null || ObjectUtils.isEmpty(openid) || ObjectUtils.isEmpty(patientId) || ObjectUtils.isEmpty(deptName) || ObjectUtils.isEmpty(doctName)) { |
|
|
|
log.info("[问诊]订单创建 payCode={}, outTradeNo={}, enOutTradeNo={}, deptCode={}, doctCode={}, totalFee={}", payCode, outTradeNo, enOutTradeNo, deptCode, doctCode, totalFee); |
|
|
|
|
|
|
|
if (totalFee == null || ObjectUtils.isEmpty(openid) || ObjectUtils.isEmpty(patientId) || ObjectUtils.isEmpty(deptName) || ObjectUtils.isEmpty(doctName)) { |
|
|
|
return Result.error(ResultEnum.PARAM_IS_DEFECT); |
|
|
|
return Result.error(ResultEnum.PARAM_IS_DEFECT); |
|
|
|
} |
|
|
|
} |
|
|
|
if (totalFee.compareTo(BigDecimal.ZERO) == 0) { // 0 元处理
|
|
|
|
if (totalFee.compareTo(BigDecimal.ZERO) == 0) { // 0 元处理
|
|
|
|
return Result.error(ResultEnum.PAY_MONEY_IS_ZERO); |
|
|
|
return Result.error(ResultEnum.PAY_MONEY_IS_ZERO); |
|
|
|
} |
|
|
|
} |
|
|
|
MerchantEnum merchantEnum = MerchantEnum.getMerchantEnumByCode(payCode); |
|
|
|
if (ObjectUtils.isEmpty(outTradeNo)) { |
|
|
|
String outTradeNo = CodeHelper.getOutTradeNo(merchantEnum); |
|
|
|
outTradeNo = CodeHelper.getOutTradeNo(MerchantEnum.WX); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
if (outTradeNo.length() > 32) { |
|
|
|
|
|
|
|
return Result.error(ResultEnum.PARAM_IS_INVALID); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!outTradeNo.equals(ReqParamHelper.decode(enOutTradeNo))) { |
|
|
|
|
|
|
|
return Result.error(ResultEnum.PARAM_IS_INVALID); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
MerchantEnum merchantEnum = MerchantEnum.getMerchantEnumByCode(payCode); |
|
|
|
if (merchantEnum == null) { |
|
|
|
if (merchantEnum == null) { |
|
|
|
return Result.error(ResultEnum.PAY_TYPE_NOT_SUPPORT); |
|
|
|
return Result.error(ResultEnum.PAY_TYPE_NOT_SUPPORT); |
|
|
|
} |
|
|
|
} |
|
|
@ -827,7 +838,7 @@ public class PayAction extends BaseAction { |
|
|
|
if (respJson == null) { |
|
|
|
if (respJson == null) { |
|
|
|
return Result.error(ResultEnum.PAY_ERROR); // 支付异常
|
|
|
|
return Result.error(ResultEnum.PAY_ERROR); // 支付异常
|
|
|
|
} |
|
|
|
} |
|
|
|
respJson.put("outTradeNo",outTradeNo); |
|
|
|
respJson.put("outTradeNo", outTradeNo); |
|
|
|
return Result.success(respJson); |
|
|
|
return Result.success(respJson); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|