提交 0a19d3dc 编写于 作者: zhouweidong's avatar zhouweidong

支持微信支付

上级 e352a8db
......@@ -32,7 +32,9 @@ public class PayTradeAspect {
Object serviceParam =args[0];
if(serviceParam instanceof PayTrade){
PayTrade entity=(PayTrade)serviceParam;
entity.setTradeId((String) entity.getDefaultKey(true));
entity.setTradeName(entity.getSubject());
entity.setTradeStatus("NOTPAY");
payTradeService.save(entity);
}
}
......
package cn.ibizlab.core.extensions.service.wechat;
import lombok.Data;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
@Data
......@@ -22,44 +17,4 @@ public class WechatPayConfig extends WXPayConfig {
private InputStream certStream;
private IWXPayDomain WXPayDomain;
// public WechatPayConfig() throws Exception {
// String certPath = "/path/to/apiclient_cert.p12";
// File file = new File(certPath);
// InputStream certStream = new FileInputStream(file);
// this.certData = new byte[(int) file.length()];
// certStream.read(this.certData);
// certStream.close();
// }
//
// public String getAppID() {
// return "wx8888888888888888";
// }
//
// public String getMchID() {
// return "12888888";
// }
//
// public String getKey() {
// return "88888888888888888888888888888888";
// }
// public InputStream getCertStream() {
// ByteArrayInputStream certBis = new ByteArrayInputStream(this.certData);
// return certBis;
// }
// public int getHttpConnectTimeoutMs() {
// return 8000;
// }
//
// public int getHttpReadTimeoutMs() {
// return 10000;
// }
// @Override
// IWXPayDomain getWXPayDomain() {
// return null;
// }
}
\ No newline at end of file
package cn.ibizlab.core.extensions.service.wechat;
public class WechatPayDomain implements IWXPayDomain {
@Override
public void report(String domain, long elapsedTimeMillis, Exception ex) {
}
@Override
public DomainInfo getDomain(WXPayConfig config) {
return new DomainInfo("api.mch.weixin.qq.com",true);
}
}
......@@ -10,11 +10,10 @@ import org.springframework.context.annotation.Lazy;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.validation.constraints.NotBlank;
@RestController
public class PayCoreResource {
......@@ -34,15 +33,23 @@ public class PayCoreResource {
}
@ApiOperation(value = "查询订单", tags = {"查询订单" }, notes = "查询订单")
@RequestMapping(method = RequestMethod.POST,value = "/pay/trade/query")
public ResponseEntity<JSONObject> query(@Validated @RequestBody PayTradeDTO dto){
return ResponseEntity.status(HttpStatus.OK).body(payCoreService.query(payTradeMapping.toDomain(dto)));
@RequestMapping(method = RequestMethod.GET,value = "/pay/trade/query")
public ResponseEntity<JSONObject> query(@Validated @NotBlank(message = "开放平台配置标识不允许为空")@RequestParam("accessid") String accessId,
@NotBlank(message = "订单号不允许为空") @RequestParam("out_trade_no") String outTradeNo){
return ResponseEntity.status(HttpStatus.OK).body(payCoreService.query(accessId,outTradeNo));
}
@ApiOperation(value = "取消订单", tags = {"取消订单" }, notes = "取消订单")
@RequestMapping(method = RequestMethod.POST,value = "/pay/trade/cancel")
public ResponseEntity<JSONObject> cancel(@Validated @RequestBody PayTradeDTO dto){
return ResponseEntity.status(HttpStatus.OK).body(payCoreService.cancel(payTradeMapping.toDomain(dto)));
@RequestMapping(method = RequestMethod.GET,value = "/pay/trade/cancel")
public ResponseEntity<JSONObject> cancel(@Validated @NotBlank(message = "开放平台配置标识不允许为空")@RequestParam("accessid") String accessId,
@NotBlank(message = "订单号不允许为空") @RequestParam("out_trade_no") String outTradeNo){
return ResponseEntity.status(HttpStatus.OK).body(payCoreService.cancel(accessId,outTradeNo));
}
@ApiOperation(value = "支付回调", tags = {"支付回调" }, notes = "支付回调")
@RequestMapping(value = "/pay/trade/callback")
public ResponseEntity<String> callBack(HttpServletRequest req) {
return ResponseEntity.status(HttpStatus.OK).body(payCoreService.callBack(req));
}
@ApiOperation(value = "网页支付", tags = {"网页支付" }, notes = "网页支付")
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册