You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
3.0 KiB
75 lines
3.0 KiB
package com.ynxbd.common.action;
|
|
|
|
import com.ynxbd.common.action.base.BaseAction;
|
|
import com.ynxbd.common.bean.enums.MerchantEnum;
|
|
import com.ynxbd.common.bean.pay.Order;
|
|
import com.ynxbd.common.helper.common.DateHelper;
|
|
import com.ynxbd.common.helper.common.HttpHelper;
|
|
import com.ynxbd.common.service.OutCollectService;
|
|
import com.ynxbd.wx.wxfactory.WxPayHelper;
|
|
import com.ynxbd.common.result.Result;
|
|
import com.ynxbd.common.result.ResultEnum;
|
|
import com.ynxbd.common.service.PayService;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.struts2.convention.annotation.Action;
|
|
import org.apache.struts2.convention.annotation.Namespace;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
@Slf4j
|
|
@Namespace("/wechat_mini")
|
|
public class WechatMiniAction extends BaseAction {
|
|
|
|
/**
|
|
* [外采支付]
|
|
*
|
|
* @param authCode 二维码授权码
|
|
* @param title 标题
|
|
* @param operateUser 操作人
|
|
* @param totalFee 总金额
|
|
* @return Y|N
|
|
*/
|
|
@Action("miniPayMicro")
|
|
public Result microPay(String authCode, String title, String operateUser, BigDecimal totalFee, String barCode, String patientId, String cardNo, String mid) {
|
|
Result result = PayService.isNoPay();
|
|
if (result != null) {
|
|
return result;
|
|
}
|
|
|
|
MerchantEnum merchantEnum = MerchantEnum.getMerchantEnumByAuthCode(authCode);
|
|
if (merchantEnum == null) {
|
|
log.info("[外采支付]条码不符合规则 authCode={}", authCode);
|
|
return Result.error(ResultEnum.PAY_AUTH_CODE_RULES_ERROR); // 条码不符合规则
|
|
}
|
|
|
|
log.info("{} 外采支付 title={}, totalFee={}", merchantEnum.NAME, title, totalFee);
|
|
if (operateUser == null || authCode == null || title == null || totalFee == null) {
|
|
return Result.error(ResultEnum.PARAM_IS_DEFECT);
|
|
}
|
|
|
|
String ip = HttpHelper.getIpAddress(request);
|
|
Order order = PayService.payMicro(merchantEnum, title, totalFee, authCode, ip);
|
|
String outTradeNo = order.getOutTradeNo();
|
|
if (!order.isSuccess()) {
|
|
log.info("[外采支付]订单号={}, errMsg={}", outTradeNo, order.getErrorMsg());
|
|
// 等待输入密码
|
|
if (WxPayHelper.USER_PAYING.equals(order.getTradeState())) {
|
|
return Result.error(ResultEnum.PAY_NEED_PASSWORD, order.getOutTradeNo(), order.getErrorMsg());
|
|
}
|
|
return Result.error(ResultEnum.ERROR, order.getOutTradeNo(), order.getErrorMsg());
|
|
}
|
|
|
|
order.setOperateUser(operateUser);
|
|
order.setTotalFee(totalFee);
|
|
order.setAuthCode(authCode);
|
|
order.setPatientId(patientId);
|
|
order.setOpenid(mid);
|
|
order.setPayWay(merchantEnum.PAY_WAY_MICRO);
|
|
Order orderResult = new OutCollectService().ocPayMicro(order, barCode, cardNo);
|
|
|
|
return orderResult.isSuccess()
|
|
? Result.success(outTradeNo)
|
|
: Result.error(ResultEnum.ERROR, outTradeNo, orderResult.getErrorMsg());
|
|
}
|
|
|
|
}
|
|
|