Compare commits

...

1 Commits

Author SHA1 Message Date
sxu d82dab3057 驿站支付修改 2025-04-27 17:32:13 +08:00
6 changed files with 55 additions and 33 deletions

View File

@ -62,6 +62,8 @@ public class CleaningServicesOrder implements Serializable {
private String ordno;
private Integer tenantId;
private String tradeId;
// /**
// * 类型
// */
@ -213,5 +215,13 @@ public class CleaningServicesOrder implements Serializable {
public void setTenantId(Integer tenantId) {
this.tenantId = tenantId;
}
public String getTradeId() {
return tradeId;
}
public void setTradeId(String tradeId) {
this.tradeId = tradeId;
}
}

View File

@ -15,6 +15,9 @@ public class Customer {
@JsonProperty("custId")
private String custId;
@JsonProperty("openid")
private String openid;
@JsonProperty("custThirdId")
private String custThirdId;

View File

@ -9,6 +9,9 @@ import lombok.Data;
@Data
public class PayReturnInfo {
@JsonProperty("tradeId")
private String tradeId;
/** 客户编号 */
@JsonProperty("custNum")
private String custNum;
@ -71,6 +74,15 @@ public class PayReturnInfo {
// Getters and Setters
public String getTradeId() {
return tradeId;
}
public void setTradeId(String tradeId) {
this.tradeId = tradeId;
}
public String getCustNum() {
return custNum;
}

View File

@ -61,25 +61,24 @@ public class CleaningServicesOrderServiceImpl extends ServiceImpl<CleaningServic
@Value("${niu.niupayurl}")
private String niupayurl;
@Value("${niu.niusearchuserurl}")
private String niusearchuserurl;
@Value("${niu.niupayreturnurl}")
private String niupayreturnurl;
@Value("${niu.applicationid}")
private String applicationid;
@Value("${niu.applicationidpsw}")
private String applicationidpsw;
@Value("${niu.sncode}")
private String sncode;
@Value("${niu.serialnum}")
private String serialnum;
@Value("${canteen.searchuserurl}")
private String canteenSearchUserUrl;
@Value("${canteen.payurl}")
private String canteenPayUrl;
@Resource
private OtherServiceClient otherServiceClient;
@ -109,27 +108,16 @@ public class CleaningServicesOrderServiceImpl extends ServiceImpl<CleaningServic
*/
private RestResult payByNiu(GreenUserInfo userInfo, CleaningServicesOrder dto) {
//1 先查询人员对应的卡号
//应用秘钥
String appsecret = applicationidpsw;
//传参
HashMap<Object, Object> bodyMap = new HashMap<>(2);
if (StringUtils.isEmpty(userInfo.getMobile())) {
log.info("下单没有配置手机号,无法下单,请联系管理员配置");
return new RestResult(Constant.FAILED, "没有配置手机号,无法下单,请联系管理员配置");
}
// bodyMap.put("mobile", "15996330508");
bodyMap.put("mobile", userInfo.getMobile());
//请求内容字典排序转换为String
String content = JSON.toJSONString(bodyMap, SerializerFeature.MapSortField, SerializerFeature.WriteMapNullValue);
log.info("请求内容转换为JSON字符串字典排序{}", content);
//构造请求验签参数方法
// Map<String, Object> map = makeSign(content, appsecret, bodyMap);
Map<String, Object> map = makeSign(content, applicationidpsw, bodyMap);
// HttpRequest request = HttpUtil.createPost(IpConfig.SEARCH_USER);
HttpRequest request = HttpUtil.createPost(niusearchuserurl);
log.info("request=" + JSONUtil.toJsonStr(map));
request.body(JSONUtil.toJsonStr(map), ContentType.JSON.toString());
HttpRequest request = HttpUtil.createPost(canteenSearchUserUrl);
log.info("request=" + JSONUtil.toJsonStr(bodyMap));
request.body(JSONUtil.toJsonStr(bodyMap), ContentType.JSON.toString());
HttpResponse response = request.execute();
log.info("response={}", response.body());
//转成实体类
@ -143,19 +131,20 @@ public class CleaningServicesOrderServiceImpl extends ServiceImpl<CleaningServic
return new RestResult(Constant.FAILED, "没有找到对应餐卡,无法下单,请联系管理员配置");
}
Customer customer = customerList.get(0);
//传参
HashMap<Object, Object> bodyMapForPayContent = new HashMap<>(2);
//构建 content
intoMapEnity(bodyMapForPayContent, dto, customer);
String payContent = JSON.toJSONString(bodyMapForPayContent, SerializerFeature.MapSortField, SerializerFeature.WriteMapNullValue);
log.info("content: " + payContent);
// Map<String, Object> payBodyMap = makeSign(payContent, appsecret, bodyMapForPayContent);
Map<String, Object> payBodyMap = makeSign(payContent, applicationidpsw, bodyMapForPayContent);
Map<String, Object> payBodyMap = new HashMap<>();
Double usePrice = dto.getUsePrice();
int convertedPrice = (int) (usePrice * 100);
payBodyMap.put("amount", convertedPrice);
// HttpRequest requestForPay = HttpUtil.createPost(IpConfig.PAY_URL_TEST);
HttpRequest requestForPay = HttpUtil.createPost(niupayurl);
HttpRequest requestForPay = HttpUtil.createPost(canteenPayUrl);
log.info("request=" + JSONUtil.toJsonStr(payBodyMap));
requestForPay.body(JSONUtil.toJsonStr(payBodyMap), ContentType.JSON.toString());
requestForPay.header("Content-Type", "application/json");
requestForPay.header("MERCHANT-ID", "378915229716713472");
requestForPay.header("custId", customer.getCustId());
requestForPay.header("openid", customer.getOpenid());
requestForPay.header("source-type", "7");
requestForPay.header("sign", "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkqpPYMDEBTiLgH08AnVYMH1WfHlB5dZC8mRq4aHmvKpGdRgeE11EylhVLsm2N5ryNYI6THgwQpL0jJ9g3lTaq4KzR8LkJlBbyFrnaflB3AtNQugg59f77eMSjHx4cTKbLWtyRfxNR2QK6AjBLkMH2v3GL4dn0aGml9fcN0cL4xLH8g8HJ1DEMGx6cJGQhuE7eQqsUkmmBs7ElbXfOFHWhLFOAgZ98Ieeog5JDnewGMl4yqyytFIPcv2VDlb46MmnZciwXYmZh5W1B9ltmO6LNvJj0itWB1ObTGzKJf9WQDG2Xq38JqFm0TttJAKxYb95ZQGZnmwIDAQAB");
HttpResponse responseForPay = requestForPay.execute();
log.info("response={}", response.body());
log.info("responseForPay={}", responseForPay.body());
@ -165,7 +154,9 @@ public class CleaningServicesOrderServiceImpl extends ServiceImpl<CleaningServic
log.error("扣款食堂卡失败,请检查");
return new RestResult(Constant.FAILED, "扣款食堂卡无响应,请联系管理员");
}
if (StringUtils.isNotNull(apiResponseForPay) && apiResponseForPay.getCode() == 10000) {
if (StringUtils.isNotNull(apiResponseForPay) && apiResponseForPay.getCode() == 200) {
String tradeId = apiResponseForPay.getData().getTradeId();
dto.setTradeId(tradeId);
int result = dao.insert(dto);
if (result == 1) {
return new RestResult(Constant.SUCCESS, "扣款成功," + "扣款金额为:" + apiResponseForPay.getData().getRealAmount() + "余额为:" + apiResponseForPay.getData().getWalletBal());

View File

@ -155,4 +155,10 @@ niu:
# sncode: 2ad34554g2 #虚拟支付设备
# serialnum: 02022840
canteen:
searchuserurl: http://sgwpdm.ah.sgcc.com.cn/canteen/custInfo/queryCustInfoDetailForApp
payurl: http://sgwpdm.ah.sgcc.com.cn/canteen/api/v2/mobile/order/stage/pay
refundurl: http://sgwpdm.ah.sgcc.com.cn/canteen/api/v2/mobile/order/stage/refund

View File

@ -187,10 +187,10 @@
insert into cleaning_services_order(service_name, ordno, user_id, name, status, order_time, use_price, price,
unit,
description, created_by, created_time, updated_time, updated_by, is_deleted,
tenant_id, phone, service_id)
tenant_id, phone, service_id, trade_id)
values (#{serviceName}, #{ordno},#{userId}, #{name},#{status}, #{orderTime}, #{usePrice}, #{price}, #{unit},
#{description}, #{createdBy}, #{createdTime}, #{updatedTime}, #{updatedBy}, #{isDeleted}, #{tenantId},
#{phone}, #{serviceId})
#{phone}, #{serviceId}, #{tradeId})
</insert>
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">