记得上下班打卡 | git大法好,push需谨慎

Commit 22a098c4 authored by 姜秀龙's avatar 姜秀龙

离线支付-迈之接口

parent 1650f26c
......@@ -157,6 +157,7 @@ public class MaiZhiAllVo {
private String cardno;
private Integer total;
private Integer page;
@Data
public static class Record {
private String note;
......@@ -166,15 +167,10 @@ public class MaiZhiAllVo {
}
}
// 变更设备状态参数和响应类
@Data
public static class ChangeDeviceStatusParam {
private String cardno;
private int type;
}
// 变更设备状态
@Data
public static class ChangeDeviceStatusResponse {
private String result;
private String msg;
private Integer errcode;
}
}
......@@ -30,4 +30,8 @@ public interface IGoblinRechargeWristbandService extends IService<GoblinRecharge
DeviceBalanceResponse getDeviceBalance(String cardno);
DeviceRecordResponse getDeviceRecord(String cardno, Integer page);
ChangeDeviceStatusResponse changeDeviceStatus(String cardno, int type);
ChangeDeviceStatusResponse refundRes(String cardno);
}
......@@ -126,7 +126,7 @@ public class GoblinRechargeAmountController {
})
public ResponseDto<DeviceRecordResponse> getDeviceRecord(
@NotBlank(message = "参数无效:cardno") @RequestParam("cardno") String cardno,
@NotNull(message = "参数无效:cardno") @RequestParam("page") Integer page
@NotNull(message = "参数无效:page") @RequestParam("page") Integer page
) {
DeviceRecordResponse res = iGoblinRechargeWristbandService.getDeviceRecord(cardno, page);
if (null != res && res.getErrcode() == 200) {
......@@ -136,4 +136,36 @@ public class GoblinRechargeAmountController {
}
}
@GetMapping("order/refund/apply")
@ApiOperation("退款申请")
@ApiImplicitParams({
@ApiImplicitParam(type = "param", required = true, name = "cardno", value = "设备编号"),
})
public ResponseDto<ChangeDeviceStatusResponse> refundApply(
@NotBlank(message = "参数无效:cardno") @RequestParam("cardno") String cardno
) {
ChangeDeviceStatusResponse res = iGoblinRechargeWristbandService.changeDeviceStatus(cardno, 1);
if (null != res && res.getErrcode() == 200) {
return ResponseDto.success(res);
} else {
return ResponseDto.failure(res.getMsg());
}
}
@GetMapping("order/refund/result")
@ApiOperation("退款结果查询")
@ApiImplicitParams({
@ApiImplicitParam(type = "param", required = true, name = "cardno", value = "设备编号"),
})
public ResponseDto<ChangeDeviceStatusResponse> refundRes(
@NotBlank(message = "参数无效:cardno") @RequestParam("cardno") String cardno
) {
ChangeDeviceStatusResponse res = iGoblinRechargeWristbandService.refundRes(cardno);
if (null != res && res.getErrcode() == 200) {
return ResponseDto.success(res);
} else {
return ResponseDto.failure(res.getMsg());
}
}
}
......@@ -137,6 +137,24 @@ public class GoblinRechargeWristbandServiceImpl extends ServiceImpl<GoblinRechar
return null;
}
@Override
public ChangeDeviceStatusResponse changeDeviceStatus(String cardno, int type) {
String accessToken = this.getAccessToken();
if (null != accessToken) {
return thirdMaiZhiUtils.changeDeviceStatus(accessToken, cardno, type);
}
return null;
}
@Override
public ChangeDeviceStatusResponse refundRes(String cardno) {
String accessToken = this.getAccessToken();
if (null != accessToken) {
return thirdMaiZhiUtils.refundRes(accessToken, cardno);
}
return null;
}
private String getAccessToken() {
String token = goblinRedisUtils.getMaiZhiAccessToken();
if (null == token) {
......
......@@ -232,22 +232,58 @@ public class ThirdMaiZhiUtils {
}
}
public ChangeDeviceStatusResponse changeDeviceStatus(ChangeDeviceStatusParam param, String token) throws Exception {
String url = "https://www.mz-cx.com/home/openapi/upd_cardtype";
HttpHeaders headers = new HttpHeaders();
headers.set("Authorization", "Bearer " + token);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url)
.queryParam("cardno", param.getCardno())
.queryParam("type", param.getType());
HttpEntity<Void> request = new HttpEntity<>(headers);
ResponseEntity<ChangeDeviceStatusResponse> response = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, request, ChangeDeviceStatusResponse.class);
if (response.getStatusCode() == HttpStatus.OK) {
return response.getBody();
} else {
throw new Exception("Device status change failed with status: " + response.getStatusCode());
public ChangeDeviceStatusResponse changeDeviceStatus(String accessToken, String cardno, int type) {
try {
String url = "https://www.mz-cx.com/home/openapi/upd_cardtype";
// 创建请求头并设置 Authorization
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.set("access-token", accessToken);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url)
.queryParam("cardno", cardno)
.queryParam("type", type);
HttpEntity<Void> request = new HttpEntity<>(headers);
ResponseEntity<String> response = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, request, String.class);
// 处理响应
if (response.getStatusCode() == HttpStatus.OK) {
return JsonUtils.fromJson(response.getBody(), ChangeDeviceStatusResponse.class);
} else {
throw new Exception("changeDeviceStatus API failed with status: " + response.getStatusCode());
}
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public ChangeDeviceStatusResponse refundRes(String accessToken, String cardno) {
try {
String url = "https://www.mz-cx.com/home/openapi/get_cardtui";
// 创建请求头并设置 Authorization
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.set("access-token", accessToken);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url)
.queryParam("cardno", cardno);
HttpEntity<Void> request = new HttpEntity<>(headers);
ResponseEntity<String> response = restTemplate.exchange(builder.toUriString(), HttpMethod.GET, request, String.class);
// 处理响应
if (response.getStatusCode() == HttpStatus.OK) {
return JsonUtils.fromJson(response.getBody(), ChangeDeviceStatusResponse.class);
} else {
throw new Exception("refundRes API failed with status: " + response.getStatusCode());
}
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment