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

Commit 61bbe216 authored by 姜秀龙's avatar 姜秀龙

离线支付-迈之接口

parent 52064dc9
...@@ -357,6 +357,7 @@ public class GoblinRedisConst { ...@@ -357,6 +357,7 @@ public class GoblinRedisConst {
public static final String GOBLIN_MIX_RESERVE_UID = PREFIX.concat("mix:reserve:uid:");//$mixId:$uid 混合售用户预约保存 public static final String GOBLIN_MIX_RESERVE_UID = PREFIX.concat("mix:reserve:uid:");//$mixId:$uid 混合售用户预约保存
public static final String GOBLIN_RECHARGE_WRISTBAND = PREFIX.concat("recharge:wristband"); public static final String GOBLIN_RECHARGE_WRISTBAND = PREFIX.concat("recharge:wristband");
public static final String GOBLIN_RECHARGE_MAIZHI_TOKEN = PREFIX.concat("recharge:maizhitoken");
/* ----------------------------------------------------------------- */ /* ----------------------------------------------------------------- */
public static final String GOBLIN_ORDER_LOG = PREFIX.concat("order:log:");//无用 public static final String GOBLIN_ORDER_LOG = PREFIX.concat("order:log:");//无用
......
package com.liquidnet.service.goblin.dto.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
import java.util.List;
/**
* <p>
* xx 服务实现类
* </p>
*
* @author jiangxiulong
* @since 2025-07-03 17:38
*/
@Data
@EqualsAndHashCode(callSuper = false)
public class MaiZhiAllVo {
// 基础响应类
@Data
public static class BaseResponse<T> {
private String msg;
private Integer errcode;
private T data;
}
// 登录授权
@Data
public static class AuthParam {
private String appid;
private String appSecret;
}
@Data
public static class AuthResponse extends BaseResponse<AuthResponse.DataRes> {
@Data
public static class DataRes {
private String accessToken;
private Integer expire;
}
}
// 实名
@Data
public static class IdCardParam {
@ApiModelProperty(value = "姓名")
private String name;
@ApiModelProperty(value = "身份证")
private String idcard;
}
@Data
public static class CheckIdcardResponse {
private String message;
private String msg;
private Integer result;
private String resultDesc;
private Integer gender;
private Integer age;
private String area;
private Integer errcode;
}
// 新增订单
@Data
public static class OrderParam {
private String operationNo;
private String out_trade_no;
private String dgoid;
private String receipt_amount;
private BigDecimal total;
private String payTime;
private List<User> userList;
@Data
public static class User {
private String name;
private String phone;
private String idcard;
private BigDecimal money;
}
}
@Data
public static class OrderResponse extends BaseResponse<String> {
}
// 订单查询
@Data
public static class OrderInfoParam {
private List<String> orderList;
}
@Data
public static class OrderInfoResponse {
private Integer errcode;
private List<OrderList> outlist;
@Data
public static class OrderList {
private String out_trade_no;
private Integer status;
private BigDecimal receipt_amount;
private String time;
private List<UserOrder> user_order;
@Data
public static class UserOrder {
private String fout_trade_no;
private Integer status;
private String name;
private String phone;
private String idcard;
private BigDecimal money;
}
}
}
// 核销码
@Data
public static class GenerateDeviceCodeResponse {
private String qrcode_str;
private Integer errcode;
}
// 设备编号获取
@Data
public static class DeviceNumberResponse {
private List<NumberList> list;
private Integer errcode;
@Data
public static class NumberList {
private String fout_trade_no;
private String cardno;
}
}
// 设备余额
@Data
public static class DeviceBalanceResponse {
private String cardno;
private BigDecimal money;
private String time;
private String msg;
private Integer errcode;
}
// 设备记录查询
@Data
public static class DeviceRecordResponse {
private List<Record> list;
private String msg;
private Integer errcode;
private String cardno;
private Integer total;
private Integer page;
@Data
public static class Record {
private String note;
private BigDecimal amt;
private BigDecimal ftbal;
private String time;
}
}
// 变更设备状态参数和响应类
@Data
public static class ChangeDeviceStatusParam {
private String cardno;
private int type;
}
@Data
public static class ChangeDeviceStatusResponse {
private String result;
}
}
...@@ -2,6 +2,7 @@ package com.liquidnet.service.goblin.service; ...@@ -2,6 +2,7 @@ package com.liquidnet.service.goblin.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.liquidnet.service.goblin.dto.vo.GoblinRechargeWristbandVo; import com.liquidnet.service.goblin.dto.vo.GoblinRechargeWristbandVo;
import com.liquidnet.service.goblin.dto.vo.MaiZhiAllVo.*;
import com.liquidnet.service.goblin.entity.GoblinRechargeWristband; import com.liquidnet.service.goblin.entity.GoblinRechargeWristband;
/** /**
...@@ -15,4 +16,18 @@ import com.liquidnet.service.goblin.entity.GoblinRechargeWristband; ...@@ -15,4 +16,18 @@ import com.liquidnet.service.goblin.entity.GoblinRechargeWristband;
public interface IGoblinRechargeWristbandService extends IService<GoblinRechargeWristband> { public interface IGoblinRechargeWristbandService extends IService<GoblinRechargeWristband> {
GoblinRechargeWristbandVo getList(); GoblinRechargeWristbandVo getList();
CheckIdcardResponse auth(IdCardParam param);
OrderResponse createOrder(OrderParam param);
OrderInfoResponse getOrder(OrderInfoParam param);
GenerateDeviceCodeResponse getQrcode(String outno);
DeviceNumberResponse getDeviceNumber(Integer operationNo, String starttime, String endtime);
DeviceBalanceResponse getDeviceBalance(String cardno);
DeviceRecordResponse getDeviceRecord(String cardno, Integer page);
} }
...@@ -2,31 +2,138 @@ package com.liquidnet.service.goblin.controller; ...@@ -2,31 +2,138 @@ package com.liquidnet.service.goblin.controller;
import com.liquidnet.service.base.ResponseDto; import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.goblin.dto.vo.GoblinRechargeWristbandVo; import com.liquidnet.service.goblin.dto.vo.GoblinRechargeWristbandVo;
import com.liquidnet.service.goblin.dto.vo.MaiZhiAllVo.*;
import com.liquidnet.service.goblin.service.IGoblinRechargeWristbandService; import com.liquidnet.service.goblin.service.IGoblinRechargeWristbandService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.List;
@Slf4j @Slf4j
@Api(tags = "充值金额") @Api(tags = "充值金额")
@RestController @RestController
@Validated @Validated
@RequestMapping("/recharge/goods") @RequestMapping("/recharge")
public class GoblinRechargeAmountController { public class GoblinRechargeAmountController {
@Autowired @Autowired
private IGoblinRechargeWristbandService iGoblinRechargeWristbandService; private IGoblinRechargeWristbandService iGoblinRechargeWristbandService;
@GetMapping("list") @GetMapping("goods/list")
@ApiOperation("获得金额列表") @ApiOperation("获得金额列表")
public ResponseDto<GoblinRechargeWristbandVo> getList() { public ResponseDto<GoblinRechargeWristbandVo> getList() {
return ResponseDto.success(iGoblinRechargeWristbandService.getList()); return ResponseDto.success(iGoblinRechargeWristbandService.getList());
} }
@PostMapping("auth")
@ApiOperation("二要素认证")
public ResponseDto<String> auth(@RequestBody IdCardParam param) {
CheckIdcardResponse res = iGoblinRechargeWristbandService.auth(param);
if (null != res && res.getErrcode() == 200) {
return ResponseDto.success(res.getMessage());
} else {
return ResponseDto.failure(res.getMsg());
}
}
@PostMapping("order/create")
@ApiOperation("创建订单")
public ResponseDto<String> createOrder(@RequestBody OrderParam param) {
OrderResponse res = iGoblinRechargeWristbandService.createOrder(param);
if (null != res && res.getErrcode() == 200) {
return ResponseDto.success(res.getMsg());
} else {
return ResponseDto.failure(res.getMsg());
}
}
@PostMapping("order/info")
@ApiOperation("订单查询")
public ResponseDto<List<OrderInfoResponse.OrderList>> getOrder(@RequestBody OrderInfoParam param) {
OrderInfoResponse res = iGoblinRechargeWristbandService.getOrder(param);
if (null != res && res.getErrcode() == 200) {
return ResponseDto.success(res.getOutlist());
} else {
return ResponseDto.failure();
}
}
@GetMapping("order/qrcode")
@ApiOperation("获取二维码字符串")
@ApiImplicitParams({
@ApiImplicitParam(type = "param", required = true, name = "outno", value = "分订单号"),
})
public ResponseDto<String> getQrcode(@NotBlank(message = "参数无效:outno") @RequestParam("outno") String outno) {
GenerateDeviceCodeResponse res = iGoblinRechargeWristbandService.getQrcode(outno);
if (null != res && res.getErrcode() == 200) {
return ResponseDto.success(res.getQrcode_str());
} else {
return ResponseDto.failure();
}
}
@GetMapping("device/mumber")
@ApiOperation("获取设备编号列表")
@ApiImplicitParams({
@ApiImplicitParam(type = "param", required = true, name = "operationNo", value = "分订单号"),
@ApiImplicitParam(type = "param", required = true, name = "starttime", value = "分订单号"),
@ApiImplicitParam(type = "param", required = true, name = "endtime", value = "分订单号"),
})
public ResponseDto<List<DeviceNumberResponse.NumberList>> getDeviceNumber(
@NotNull(message = "参数无效") @RequestParam("operationNo") Integer operationNo,
@NotBlank(message = "参数无效") @RequestParam("starttime") String starttime,
@NotBlank(message = "参数无效") @RequestParam("endtime") String endtime
) {
DeviceNumberResponse res = iGoblinRechargeWristbandService.getDeviceNumber(operationNo, starttime, endtime);
if (null != res && res.getErrcode() == 200) {
return ResponseDto.success(res.getList());
} else {
return ResponseDto.failure();
}
}
@GetMapping("device/balance")
@ApiOperation("获取余额")
@ApiImplicitParams({
@ApiImplicitParam(type = "param", required = true, name = "cardno", value = "设备编号"),
})
public ResponseDto<BigDecimal> getDeviceBalance(
@NotBlank(message = "参数无效:cardno") @RequestParam("cardno") String cardno
) {
DeviceBalanceResponse res = iGoblinRechargeWristbandService.getDeviceBalance(cardno);
if (null != res && res.getErrcode() == 200) {
return ResponseDto.success(res.getMoney());
} else {
return ResponseDto.failure(res.getMsg());
}
}
@GetMapping("device/record")
@ApiOperation("获取设备记录")
@ApiImplicitParams({
@ApiImplicitParam(type = "param", required = true, name = "cardno", value = "设备编号"),
@ApiImplicitParam(type = "param", required = true, name = "page", value = "分页"),
})
public ResponseDto<DeviceRecordResponse> getDeviceRecord(
@NotBlank(message = "参数无效:cardno") @RequestParam("cardno") String cardno,
@NotNull(message = "参数无效:cardno") @RequestParam("page") Integer page
) {
DeviceRecordResponse res = iGoblinRechargeWristbandService.getDeviceRecord(cardno, page);
if (null != res && res.getErrcode() == 200) {
return ResponseDto.success(res);
} else {
return ResponseDto.failure(res.getMsg());
}
}
} }
...@@ -3,12 +3,14 @@ package com.liquidnet.service.goblin.service.impl; ...@@ -3,12 +3,14 @@ package com.liquidnet.service.goblin.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liquidnet.service.goblin.dto.vo.GoblinRechargeAmountVo; import com.liquidnet.service.goblin.dto.vo.GoblinRechargeAmountVo;
import com.liquidnet.service.goblin.dto.vo.GoblinRechargeWristbandVo; import com.liquidnet.service.goblin.dto.vo.GoblinRechargeWristbandVo;
import com.liquidnet.service.goblin.dto.vo.MaiZhiAllVo.*;
import com.liquidnet.service.goblin.entity.GoblinRechargeAmount; import com.liquidnet.service.goblin.entity.GoblinRechargeAmount;
import com.liquidnet.service.goblin.entity.GoblinRechargeWristband; import com.liquidnet.service.goblin.entity.GoblinRechargeWristband;
import com.liquidnet.service.goblin.mapper.GoblinRechargeAmountMapper; import com.liquidnet.service.goblin.mapper.GoblinRechargeAmountMapper;
import com.liquidnet.service.goblin.mapper.GoblinRechargeWristbandMapper; import com.liquidnet.service.goblin.mapper.GoblinRechargeWristbandMapper;
import com.liquidnet.service.goblin.service.IGoblinRechargeWristbandService; import com.liquidnet.service.goblin.service.IGoblinRechargeWristbandService;
import com.liquidnet.service.goblin.util.GoblinRedisUtils; import com.liquidnet.service.goblin.util.GoblinRedisUtils;
import com.liquidnet.service.goblin.util.ThirdMaiZhiUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
...@@ -30,6 +32,9 @@ public class GoblinRechargeWristbandServiceImpl extends ServiceImpl<GoblinRechar ...@@ -30,6 +32,9 @@ public class GoblinRechargeWristbandServiceImpl extends ServiceImpl<GoblinRechar
@Autowired @Autowired
GoblinRedisUtils goblinRedisUtils; GoblinRedisUtils goblinRedisUtils;
@Autowired
ThirdMaiZhiUtils thirdMaiZhiUtils;
@Autowired @Autowired
private GoblinRechargeAmountMapper rechargeAmountMapper; private GoblinRechargeAmountMapper rechargeAmountMapper;
...@@ -69,4 +74,79 @@ public class GoblinRechargeWristbandServiceImpl extends ServiceImpl<GoblinRechar ...@@ -69,4 +74,79 @@ public class GoblinRechargeWristbandServiceImpl extends ServiceImpl<GoblinRechar
return result; return result;
} }
@Override
public CheckIdcardResponse auth(IdCardParam param) {
String accessToken = this.getAccessToken();
if (null != accessToken) {
return thirdMaiZhiUtils.checkIdcard(accessToken, param.getIdcard(), param.getName());
}
return null;
}
@Override
public OrderResponse createOrder(OrderParam param) {
String accessToken = this.getAccessToken();
if (null != accessToken) {
return thirdMaiZhiUtils.addOrder(accessToken, param);
}
return null;
}
@Override
public OrderInfoResponse getOrder(OrderInfoParam param) {
String accessToken = this.getAccessToken();
if (null != accessToken) {
return thirdMaiZhiUtils.getOrder(accessToken, param);
}
return null;
}
@Override
public GenerateDeviceCodeResponse getQrcode(String outno) {
String accessToken = this.getAccessToken();
if (null != accessToken) {
return thirdMaiZhiUtils.generateDeviceCode(accessToken, outno);
}
return null;
}
@Override
public DeviceNumberResponse getDeviceNumber(Integer operationNo, String starttime, String endtime) {
String accessToken = this.getAccessToken();
if (null != accessToken) {
return thirdMaiZhiUtils.getDeviceNumber(accessToken, operationNo, starttime, endtime);
}
return null;
}
@Override
public DeviceBalanceResponse getDeviceBalance(String cardno) {
String accessToken = this.getAccessToken();
if (null != accessToken) {
return thirdMaiZhiUtils.getDeviceBalance(accessToken, cardno);
}
return null;
}
@Override
public DeviceRecordResponse getDeviceRecord(String cardno, Integer page) {
String accessToken = this.getAccessToken();
if (null != accessToken) {
return thirdMaiZhiUtils.getDeviceRecord(accessToken, cardno, page);
}
return null;
}
private String getAccessToken() {
String token = goblinRedisUtils.getMaiZhiAccessToken();
if (null == token) {
AuthResponse response = thirdMaiZhiUtils.login("CM250001", "95b42275318c6df2d78c43525c2126e7", "380e8acd181abef8c6253721b05a54a1");
if (response.getErrcode() == 200) {
token = response.getData().getAccessToken();
goblinRedisUtils.setMaiZhiAccessToken(token, response.getData().getExpire() - 200);
}
}
return token;
}
} }
\ No newline at end of file
...@@ -2937,6 +2937,20 @@ public class GoblinRedisUtils { ...@@ -2937,6 +2937,20 @@ public class GoblinRedisUtils {
redisUtil.set(rdk, vo); redisUtil.set(rdk, vo);
} }
public void setMaiZhiAccessToken(String token, int time) {
String rdk = GoblinRedisConst.GOBLIN_RECHARGE_MAIZHI_TOKEN;
redisUtil.set(rdk, token, time);
}
public String getMaiZhiAccessToken() {
Object obj = redisUtil.get(GoblinRedisConst.GOBLIN_RECHARGE_MAIZHI_TOKEN);
if (obj == null) {
return null;
} else {
return (String) obj;
}
}
/* ---------------------------------------- ---------------------------------------- */ /* ---------------------------------------- ---------------------------------------- */
/* ---------------------------------------- ---------------------------------------- */ /* ---------------------------------------- ---------------------------------------- */
/* ---------------------------------------- ---------------------------------------- */ /* ---------------------------------------- ---------------------------------------- */
......
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