Compare commits
1 Commits
master
...
canteenpay
| Author | SHA1 | Date |
|---|---|---|
|
|
d82dab3057 |
|
|
@ -62,6 +62,8 @@ public class CleaningServicesOrder implements Serializable {
|
||||||
private String ordno;
|
private String ordno;
|
||||||
|
|
||||||
private Integer tenantId;
|
private Integer tenantId;
|
||||||
|
|
||||||
|
private String tradeId;
|
||||||
// /**
|
// /**
|
||||||
// * 类型
|
// * 类型
|
||||||
// */
|
// */
|
||||||
|
|
@ -213,5 +215,13 @@ public class CleaningServicesOrder implements Serializable {
|
||||||
public void setTenantId(Integer tenantId) {
|
public void setTenantId(Integer tenantId) {
|
||||||
this.tenantId = tenantId;
|
this.tenantId = tenantId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getTradeId() {
|
||||||
|
return tradeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTradeId(String tradeId) {
|
||||||
|
this.tradeId = tradeId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,9 @@ public class Customer {
|
||||||
@JsonProperty("custId")
|
@JsonProperty("custId")
|
||||||
private String custId;
|
private String custId;
|
||||||
|
|
||||||
|
@JsonProperty("openid")
|
||||||
|
private String openid;
|
||||||
|
|
||||||
@JsonProperty("custThirdId")
|
@JsonProperty("custThirdId")
|
||||||
private String custThirdId;
|
private String custThirdId;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,9 @@ import lombok.Data;
|
||||||
@Data
|
@Data
|
||||||
public class PayReturnInfo {
|
public class PayReturnInfo {
|
||||||
|
|
||||||
|
@JsonProperty("tradeId")
|
||||||
|
private String tradeId;
|
||||||
|
|
||||||
/** 客户编号 */
|
/** 客户编号 */
|
||||||
@JsonProperty("custNum")
|
@JsonProperty("custNum")
|
||||||
private String custNum;
|
private String custNum;
|
||||||
|
|
@ -71,6 +74,15 @@ public class PayReturnInfo {
|
||||||
|
|
||||||
// Getters and Setters
|
// Getters and Setters
|
||||||
|
|
||||||
|
|
||||||
|
public String getTradeId() {
|
||||||
|
return tradeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTradeId(String tradeId) {
|
||||||
|
this.tradeId = tradeId;
|
||||||
|
}
|
||||||
|
|
||||||
public String getCustNum() {
|
public String getCustNum() {
|
||||||
return custNum;
|
return custNum;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,25 +61,24 @@ public class CleaningServicesOrderServiceImpl extends ServiceImpl<CleaningServic
|
||||||
|
|
||||||
@Value("${niu.niupayurl}")
|
@Value("${niu.niupayurl}")
|
||||||
private String niupayurl;
|
private String niupayurl;
|
||||||
|
|
||||||
@Value("${niu.niusearchuserurl}")
|
@Value("${niu.niusearchuserurl}")
|
||||||
private String niusearchuserurl;
|
private String niusearchuserurl;
|
||||||
|
|
||||||
@Value("${niu.niupayreturnurl}")
|
@Value("${niu.niupayreturnurl}")
|
||||||
private String niupayreturnurl;
|
private String niupayreturnurl;
|
||||||
|
|
||||||
@Value("${niu.applicationid}")
|
@Value("${niu.applicationid}")
|
||||||
private String applicationid;
|
private String applicationid;
|
||||||
|
|
||||||
@Value("${niu.applicationidpsw}")
|
@Value("${niu.applicationidpsw}")
|
||||||
private String applicationidpsw;
|
private String applicationidpsw;
|
||||||
|
|
||||||
@Value("${niu.sncode}")
|
@Value("${niu.sncode}")
|
||||||
private String sncode;
|
private String sncode;
|
||||||
|
|
||||||
@Value("${niu.serialnum}")
|
@Value("${niu.serialnum}")
|
||||||
private String serialnum;
|
private String serialnum;
|
||||||
|
|
||||||
|
@Value("${canteen.searchuserurl}")
|
||||||
|
private String canteenSearchUserUrl;
|
||||||
|
@Value("${canteen.payurl}")
|
||||||
|
private String canteenPayUrl;
|
||||||
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private OtherServiceClient otherServiceClient;
|
private OtherServiceClient otherServiceClient;
|
||||||
|
|
@ -109,27 +108,16 @@ public class CleaningServicesOrderServiceImpl extends ServiceImpl<CleaningServic
|
||||||
*/
|
*/
|
||||||
private RestResult payByNiu(GreenUserInfo userInfo, CleaningServicesOrder dto) {
|
private RestResult payByNiu(GreenUserInfo userInfo, CleaningServicesOrder dto) {
|
||||||
//1 先查询人员对应的卡号
|
//1 先查询人员对应的卡号
|
||||||
//应用秘钥
|
|
||||||
String appsecret = applicationidpsw;
|
|
||||||
//传参
|
//传参
|
||||||
HashMap<Object, Object> bodyMap = new HashMap<>(2);
|
HashMap<Object, Object> bodyMap = new HashMap<>(2);
|
||||||
if (StringUtils.isEmpty(userInfo.getMobile())) {
|
if (StringUtils.isEmpty(userInfo.getMobile())) {
|
||||||
log.info("下单没有配置手机号,无法下单,请联系管理员配置");
|
log.info("下单没有配置手机号,无法下单,请联系管理员配置");
|
||||||
return new RestResult(Constant.FAILED, "没有配置手机号,无法下单,请联系管理员配置");
|
return new RestResult(Constant.FAILED, "没有配置手机号,无法下单,请联系管理员配置");
|
||||||
}
|
}
|
||||||
// bodyMap.put("mobile", "15996330508");
|
|
||||||
bodyMap.put("mobile", userInfo.getMobile());
|
bodyMap.put("mobile", userInfo.getMobile());
|
||||||
//请求内容字典排序,转换为String
|
HttpRequest request = HttpUtil.createPost(canteenSearchUserUrl);
|
||||||
String content = JSON.toJSONString(bodyMap, SerializerFeature.MapSortField, SerializerFeature.WriteMapNullValue);
|
log.info("request=" + JSONUtil.toJsonStr(bodyMap));
|
||||||
log.info("请求内容转换为JSON字符串,字典排序:{}", content);
|
request.body(JSONUtil.toJsonStr(bodyMap), ContentType.JSON.toString());
|
||||||
//构造请求验签参数方法
|
|
||||||
|
|
||||||
// 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());
|
|
||||||
HttpResponse response = request.execute();
|
HttpResponse response = request.execute();
|
||||||
log.info("response={}", response.body());
|
log.info("response={}", response.body());
|
||||||
//转成实体类
|
//转成实体类
|
||||||
|
|
@ -143,19 +131,20 @@ public class CleaningServicesOrderServiceImpl extends ServiceImpl<CleaningServic
|
||||||
return new RestResult(Constant.FAILED, "没有找到对应餐卡,无法下单,请联系管理员配置");
|
return new RestResult(Constant.FAILED, "没有找到对应餐卡,无法下单,请联系管理员配置");
|
||||||
}
|
}
|
||||||
Customer customer = customerList.get(0);
|
Customer customer = customerList.get(0);
|
||||||
//传参
|
Map<String, Object> payBodyMap = new HashMap<>();
|
||||||
HashMap<Object, Object> bodyMapForPayContent = new HashMap<>(2);
|
Double usePrice = dto.getUsePrice();
|
||||||
//构建 content
|
int convertedPrice = (int) (usePrice * 100);
|
||||||
intoMapEnity(bodyMapForPayContent, dto, customer);
|
payBodyMap.put("amount", convertedPrice);
|
||||||
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);
|
|
||||||
|
|
||||||
// HttpRequest requestForPay = HttpUtil.createPost(IpConfig.PAY_URL_TEST);
|
HttpRequest requestForPay = HttpUtil.createPost(canteenPayUrl);
|
||||||
HttpRequest requestForPay = HttpUtil.createPost(niupayurl);
|
|
||||||
log.info("request=" + JSONUtil.toJsonStr(payBodyMap));
|
log.info("request=" + JSONUtil.toJsonStr(payBodyMap));
|
||||||
requestForPay.body(JSONUtil.toJsonStr(payBodyMap), ContentType.JSON.toString());
|
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();
|
HttpResponse responseForPay = requestForPay.execute();
|
||||||
log.info("response={}", response.body());
|
log.info("response={}", response.body());
|
||||||
log.info("responseForPay={}", responseForPay.body());
|
log.info("responseForPay={}", responseForPay.body());
|
||||||
|
|
@ -165,7 +154,9 @@ public class CleaningServicesOrderServiceImpl extends ServiceImpl<CleaningServic
|
||||||
log.error("扣款食堂卡失败,请检查");
|
log.error("扣款食堂卡失败,请检查");
|
||||||
return new RestResult(Constant.FAILED, "扣款食堂卡无响应,请联系管理员");
|
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);
|
int result = dao.insert(dto);
|
||||||
if (result == 1) {
|
if (result == 1) {
|
||||||
return new RestResult(Constant.SUCCESS, "扣款成功," + "扣款金额为:" + apiResponseForPay.getData().getRealAmount() + "余额为:" + apiResponseForPay.getData().getWalletBal());
|
return new RestResult(Constant.SUCCESS, "扣款成功," + "扣款金额为:" + apiResponseForPay.getData().getRealAmount() + "余额为:" + apiResponseForPay.getData().getWalletBal());
|
||||||
|
|
|
||||||
|
|
@ -155,4 +155,10 @@ niu:
|
||||||
# sncode: 2ad34554g2 #虚拟支付设备
|
# sncode: 2ad34554g2 #虚拟支付设备
|
||||||
# serialnum: 02022840
|
# 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
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -187,10 +187,10 @@
|
||||||
insert into cleaning_services_order(service_name, ordno, user_id, name, status, order_time, use_price, price,
|
insert into cleaning_services_order(service_name, ordno, user_id, name, status, order_time, use_price, price,
|
||||||
unit,
|
unit,
|
||||||
description, created_by, created_time, updated_time, updated_by, is_deleted,
|
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},
|
values (#{serviceName}, #{ordno},#{userId}, #{name},#{status}, #{orderTime}, #{usePrice}, #{price}, #{unit},
|
||||||
#{description}, #{createdBy}, #{createdTime}, #{updatedTime}, #{updatedBy}, #{isDeleted}, #{tenantId},
|
#{description}, #{createdBy}, #{createdTime}, #{updatedTime}, #{updatedBy}, #{isDeleted}, #{tenantId},
|
||||||
#{phone}, #{serviceId})
|
#{phone}, #{serviceId}, #{tradeId})
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
|
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue