Merge branch 'develop' of https://gitee.com/likeadmin/likeadmin_java into develop
This commit is contained in:
commit
12db298225
|
|
@ -55,7 +55,7 @@ public class WxPayDriver {
|
|||
* @return WxPayUnifiedOrderV3Result.JsapiResult
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
public static WxPayUnifiedOrderV3Result.JsapiResult unifiedOrder(PaymentRequestV3 requestV3) throws Exception {
|
||||
public static Object unifiedOrder(PaymentRequestV3 requestV3) throws Exception {
|
||||
// 订单参数
|
||||
Integer terminal = requestV3.getTerminal();
|
||||
String openId = requestV3.getOpenId();
|
||||
|
|
@ -88,7 +88,10 @@ public class WxPayDriver {
|
|||
payer.setOpenid(openId);
|
||||
|
||||
// H5平台
|
||||
TradeTypeEnum tradeTypeEnum = TradeTypeEnum.JSAPI;
|
||||
|
||||
if (terminal == ClientEnum.H5.getCode()) {
|
||||
tradeTypeEnum = TradeTypeEnum.H5;
|
||||
WxPayUnifiedOrderV3Request.SceneInfo sceneInfo = new WxPayUnifiedOrderV3Request.SceneInfo();
|
||||
WxPayUnifiedOrderV3Request.H5Info h5Info = new WxPayUnifiedOrderV3Request.H5Info();
|
||||
h5Info.setType(RequestUtils.device());
|
||||
|
|
@ -100,7 +103,7 @@ public class WxPayDriver {
|
|||
// 发起订单
|
||||
WxPayService wxPayService = WxPayDriver.handler(terminal);
|
||||
wxPayUnifiedOrderV3Request.setPayer(payer);
|
||||
return wxPayService.createOrderV3(TradeTypeEnum.JSAPI, wxPayUnifiedOrderV3Request);
|
||||
return wxPayService.createOrderV3(tradeTypeEnum, wxPayUnifiedOrderV3Request);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -50,8 +50,8 @@ public class PayController {
|
|||
|
||||
@GetMapping("/payStatus")
|
||||
@ApiOperation(("支付状态"))
|
||||
public AjaxResult<Object> payStatus(@Validated @NotNull(message = "from参数丢失") @RequestParam String from,
|
||||
@Validated @NotNull(message = "orderId参数丢失") @RequestParam Integer orderId) {
|
||||
public AjaxResult<PayStatusVo> payStatus(@Validated @NotNull(message = "from参数丢失") @RequestParam String from,
|
||||
@Validated @NotNull(message = "orderId参数丢失") @RequestParam Integer orderId) {
|
||||
PayStatusVo vo = iPayService.payStatus(from, orderId);
|
||||
return AjaxResult.success(vo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.mdd.common.entity.setting.DevPayConfig;
|
|||
import com.mdd.common.entity.setting.DevPayWay;
|
||||
import com.mdd.common.entity.user.User;
|
||||
import com.mdd.common.entity.user.UserAuth;
|
||||
import com.mdd.common.enums.ClientEnum;
|
||||
import com.mdd.common.enums.LogMoneyEnum;
|
||||
import com.mdd.common.enums.PaymentEnum;
|
||||
import com.mdd.common.exception.OperateException;
|
||||
|
|
@ -27,11 +28,10 @@ import com.mdd.front.vo.pay.PayWayListVo;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
|
|
@ -167,6 +167,17 @@ public class PayServiceImpl implements IPayService {
|
|||
requestV3.setOutTradeNo(params.getOutTradeNo());
|
||||
requestV3.setOrderAmount(params.getOrderAmount());
|
||||
requestV3.setDescription(params.getDescription());
|
||||
Object result = WxPayDriver.unifiedOrder(requestV3);
|
||||
if (terminal == ClientEnum.H5.getCode()) {
|
||||
Assert.notNull(params.getRedirectUrl(), "redirectUrl参数缺失");
|
||||
Map<String, String> map = new LinkedHashMap<>();
|
||||
String h5Url = result.toString();
|
||||
String redirectUrl = RequestUtils.uri() + params.getRedirectUrl();
|
||||
redirectUrl += "?checkPay=true&scene="+params.getAttach()+"&orderId="+params.getOrderId();
|
||||
h5Url += "&redirect_url="+redirectUrl;
|
||||
map.put("url", h5Url);
|
||||
return map;
|
||||
}
|
||||
return WxPayDriver.unifiedOrder(requestV3);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@ public class PaymentValidate implements Serializable {
|
|||
@ApiModelProperty("订单ID")
|
||||
private Integer orderId;
|
||||
|
||||
@ApiModelProperty(value = "重定向链接: H5端需要")
|
||||
private String redirectUrl;
|
||||
|
||||
@ApiModelProperty(value = "用户ID", notes = "该参数无需传递")
|
||||
private Integer userId;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue