添加快捷支付
This commit is contained in:
@@ -112,9 +112,9 @@ public class PayController {
|
|||||||
public Result queryQuickPayStatus(@RequestHeader("token") String token,
|
public Result queryQuickPayStatus(@RequestHeader("token") String token,
|
||||||
@RequestHeader("loginName") String loginName,
|
@RequestHeader("loginName") String loginName,
|
||||||
@RequestHeader("clientType") String clientType,
|
@RequestHeader("clientType") String clientType,
|
||||||
@RequestParam("id") Integer id
|
@RequestParam("orderId") String orderId
|
||||||
){
|
){
|
||||||
return payService.queryQuickPayStatus(id);
|
return payService.queryQuickPayStatus(orderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -23,4 +23,6 @@ public interface TbQuickPayMapper {
|
|||||||
int updateByPrimaryKey(TbQuickPay record);
|
int updateByPrimaryKey(TbQuickPay record);
|
||||||
|
|
||||||
List<TbQuickPay> selectByShopIdAndStaffId(@Param("shopId") Integer shopId,@Param("staffId") Integer staffId);
|
List<TbQuickPay> selectByShopIdAndStaffId(@Param("shopId") Integer shopId,@Param("staffId") Integer staffId);
|
||||||
|
|
||||||
|
TbQuickPay selectByOrderNo(String orderNo);
|
||||||
}
|
}
|
||||||
@@ -108,8 +108,8 @@ public class TbQuickPay implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public TbQuickPay(Integer id, Integer staffId, Integer shopId, String orderNo, String payType, BigDecimal amount, String status, String tradeNo, Date createTime, Date updateTime) {
|
public TbQuickPay(Integer id,Integer staffId, Integer shopId, String orderNo, String payType, BigDecimal amount, String status, String tradeNo, Date createTime, Date updateTime) {
|
||||||
this.id = id;
|
this.id=id;
|
||||||
this.staffId = staffId;
|
this.staffId = staffId;
|
||||||
this.shopId = shopId;
|
this.shopId = shopId;
|
||||||
this.orderNo = orderNo;
|
this.orderNo = orderNo;
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ public class PayService {
|
|||||||
reqbody = body.toString();
|
reqbody = body.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
PublicResp<MainScanResp> publicResp = thirdPayService.mainScan(url, thirdApply.getAppId(), reqbody, reqbody, payment.getAmount().setScale(2, RoundingMode.DOWN).multiply(new BigDecimal(100)).longValue(), payType.equals("wechatPay") ? thirdApply.getSmallAppid() : null, authCode, orderInfo.getOrderNo(), thirdApply.getStoreId(), callBack, thirdApply.getAppToken());
|
PublicResp<MainScanResp> publicResp = thirdPayService.mainScan(url, thirdApply.getAppId(), reqbody, reqbody, payment.getAmount().setScale(2, RoundingMode.DOWN).multiply(new BigDecimal(100)).longValue(), payType.equals("wechatPay") ? thirdApply.getSmallAppid() : null, authCode, DateUtils.getSsdfTimes(), thirdApply.getStoreId(), callBack, thirdApply.getAppToken());
|
||||||
if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
|
if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
|
||||||
if ("000000".equals(publicResp.getCode())) {
|
if ("000000".equals(publicResp.getCode())) {
|
||||||
MainScanResp mainScanResp = publicResp.getObjData();
|
MainScanResp mainScanResp = publicResp.getObjData();
|
||||||
@@ -369,7 +369,7 @@ public class PayService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PublicResp<OrderStatusQueryResp> orderstatus = thirdPayService.queryOrder(url, thirdApply.getAppId(), null, orderInfo.getOrderNo(), thirdApply.getAppToken());
|
PublicResp<OrderStatusQueryResp> orderstatus = thirdPayService.queryOrder(url, thirdApply.getAppId(), tbOrderPayment.getTradeNumber(), null, thirdApply.getAppToken());
|
||||||
if (ObjectUtil.isNotNull(orderstatus) && ObjectUtil.isNotEmpty(orderstatus)) {
|
if (ObjectUtil.isNotNull(orderstatus) && ObjectUtil.isNotEmpty(orderstatus)) {
|
||||||
if ("000000".equals(orderstatus.getCode())) {
|
if ("000000".equals(orderstatus.getCode())) {
|
||||||
if ("TRADE_SUCCESS".equals(orderstatus.getObjData().getState())) {
|
if ("TRADE_SUCCESS".equals(orderstatus.getObjData().getState())) {
|
||||||
@@ -785,11 +785,13 @@ public class PayService {
|
|||||||
// newOrderInfo.setPayOrderNo(object.getJSONObject("data").getString("refundOrderNumber"));
|
// newOrderInfo.setPayOrderNo(object.getJSONObject("data").getString("refundOrderNumber"));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PublicResp<OrderReturnResp> publicResp = thirdPayService.returnOrder(url, thirdApply.getAppId(), newOrderInfo.getOrderNo(), null, orderInfo.getOrderNo(), "订单退款", newOrderInfo.getPayAmount().setScale(2, RoundingMode.DOWN).multiply(new BigDecimal(100)).longValue(), callBack, null, thirdApply.getAppToken());
|
|
||||||
|
TbOrderPayment payment= tbOrderPaymentMapper.selectByOrderId(orderId+"");
|
||||||
|
PublicResp<OrderReturnResp> publicResp = thirdPayService.returnOrder(url, thirdApply.getAppId(), newOrderInfo.getOrderNo(), payment.getTradeNumber(), null, "订单退款", newOrderInfo.getPayAmount().setScale(2, RoundingMode.DOWN).multiply(new BigDecimal(100)).longValue(), callBack, null, thirdApply.getAppToken());
|
||||||
|
|
||||||
if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
|
if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
|
||||||
if ("000000".equals(publicResp.getCode())) {
|
if ("000000".equals(publicResp.getCode())) {
|
||||||
if (!publicResp.getObjData().getState().equals("ING") || "SUCCESS".equals(publicResp.getObjData().getState())) {
|
if (!"SUCCESS".equals(publicResp.getObjData().getState())&&!publicResp.getObjData().getState().equals("ING")) {
|
||||||
MsgException.check(true, "退款渠道调用失败");
|
MsgException.check(true, "退款渠道调用失败");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -855,11 +857,13 @@ public class PayService {
|
|||||||
|
|
||||||
String orderNo = SnowFlakeUtil.generateOrderNo();
|
String orderNo = SnowFlakeUtil.generateOrderNo();
|
||||||
|
|
||||||
TbQuickPay tbQuickPay = new TbQuickPay(null, Integer.valueOf(staffId), Integer.valueOf(shopId), orderNo, payType, payAmount, "1", null, new Date(), null);
|
TbQuickPay tbQuickPay = new TbQuickPay(null,Integer.valueOf(staffId), Integer.valueOf(shopId), orderNo, payType, payAmount, "1", null, new Date(), null);
|
||||||
|
|
||||||
if ("cash".equals(payType)) {
|
if ("cash".equals(payType)) {
|
||||||
tbQuickPay.setStatus("0");
|
tbQuickPay.setStatus("0");
|
||||||
tbQuickPay.setUpdateTime(new Date());
|
tbQuickPay.setUpdateTime(new Date());
|
||||||
|
tbQuickPayMapper.insert(tbQuickPay);
|
||||||
|
return Result.success(CodeEnum.SUCCESS, tbQuickPay);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
TbShopInfo tbShopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(shopId));
|
TbShopInfo tbShopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(shopId));
|
||||||
@@ -883,17 +887,35 @@ public class PayService {
|
|||||||
if (response.getStatusCodeValue() == 200 && ObjectUtil.isNotEmpty(response.getBody())) {
|
if (response.getStatusCodeValue() == 200 && ObjectUtil.isNotEmpty(response.getBody())) {
|
||||||
JSONObject object = JSONObject.parseObject(response.getBody());
|
JSONObject object = JSONObject.parseObject(response.getBody());
|
||||||
if (object.get("code").equals("0")) {
|
if (object.get("code").equals("0")) {
|
||||||
|
|
||||||
tbQuickPay.setTradeNo(object.getJSONObject("data").get("orderNumber").toString());
|
tbQuickPay.setTradeNo(object.getJSONObject("data").get("orderNumber").toString());
|
||||||
|
tbQuickPayMapper.insert(tbQuickPay);
|
||||||
|
return Result.success(CodeEnum.SUCCESS, tbQuickPay);
|
||||||
|
}
|
||||||
|
|
||||||
|
String status = ObjectUtil.isNotEmpty(object.getJSONObject("data")) ? object.getJSONObject("data").getString("status") : null;
|
||||||
|
if (ObjectUtil.isNotNull(status) && "7".equals(status)) {
|
||||||
|
tbQuickPayMapper.insert(tbQuickPay);
|
||||||
|
return Result.success(CodeEnum.PAYING,tbQuickPay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
PublicResp<MainScanResp> publicResp = thirdPayService.mainScan(url, thirdApply.getAppId(), "快捷收款", "快捷收款", payAmount.setScale(2, RoundingMode.DOWN).multiply(new BigDecimal(100)).longValue(), payType.equals("wechatPay") ? thirdApply.getSmallAppid() : null, authCode, tbQuickPay.getOrderNo(), thirdApply.getStoreId(), callBack, thirdApply.getAppToken());
|
PublicResp<MainScanResp> publicResp = thirdPayService.mainScan(url, thirdApply.getAppId(), "快捷收款", "快捷收款", payAmount.setScale(2, RoundingMode.DOWN).multiply(new BigDecimal(100)).longValue(), payType.equals("scanCode") ? thirdApply.getSmallAppid() : null, authCode, DateUtils.getSsdfTimes(), thirdApply.getStoreId(), callBack, thirdApply.getAppToken());
|
||||||
if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
|
if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
|
||||||
if ("000000".equals(publicResp.getCode())) {
|
if ("000000".equals(publicResp.getCode())) {
|
||||||
MainScanResp mainScanResp = publicResp.getObjData();
|
MainScanResp mainScanResp = publicResp.getObjData();
|
||||||
if ("TRADE_SUCCESS".equals(mainScanResp.getState())) {
|
if ("TRADE_SUCCESS".equals(mainScanResp.getState())) {
|
||||||
tbQuickPay.setTradeNo(mainScanResp.getPayOrderId());
|
tbQuickPay.setTradeNo(mainScanResp.getPayOrderId());
|
||||||
|
tbQuickPayMapper.insert(tbQuickPay);
|
||||||
|
return Result.success(CodeEnum.SUCCESS, tbQuickPay);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("TRADE_AWAIT".equals(mainScanResp.getState())) {
|
||||||
|
tbQuickPay.setTradeNo(mainScanResp.getPayOrderId());
|
||||||
|
log.info("ddddd:{}",tbQuickPay.getTradeNo());
|
||||||
|
tbQuickPayMapper.insert(tbQuickPay);
|
||||||
|
return Result.success(CodeEnum.PAYING,tbQuickPay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -901,15 +923,16 @@ public class PayService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tbQuickPayMapper.insert(tbQuickPay);
|
return Result.fail(CodeEnum.FAIL);
|
||||||
return Result.success(CodeEnum.SUCCESS, tbQuickPay);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Result queryQuickPayStatus(Integer id) {
|
public Result queryQuickPayStatus(String id) {
|
||||||
|
|
||||||
TbQuickPay tbQuickPay = tbQuickPayMapper.selectByPrimaryKey(id);
|
TbQuickPay tbQuickPay = tbQuickPayMapper.selectByOrderNo(id);
|
||||||
MsgException.checkNull(tbQuickPay, "订单信息不存在");
|
MsgException.checkNull(tbQuickPay, "订单信息不存在");
|
||||||
if (tbQuickPay.getPayType().equals("scanpay") && "1".equals(tbQuickPay.getStatus())) {
|
if (tbQuickPay.getPayType().equals("scanCode") && "1".equals(tbQuickPay.getStatus())) {
|
||||||
|
|
||||||
TbShopInfo tbShopInfo = tbShopInfoMapper.selectByPrimaryKey(tbQuickPay.getShopId());
|
TbShopInfo tbShopInfo = tbShopInfoMapper.selectByPrimaryKey(tbQuickPay.getShopId());
|
||||||
MsgException.checkNull(tbShopInfo, "店铺信息不存在");
|
MsgException.checkNull(tbShopInfo, "店铺信息不存在");
|
||||||
@@ -940,7 +963,7 @@ public class PayService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PublicResp<OrderStatusQueryResp> orderstatus = thirdPayService.queryOrder(url, thirdApply.getAppId(), null, tbQuickPay.getOrderNo(), thirdApply.getAppToken());
|
PublicResp<OrderStatusQueryResp> orderstatus = thirdPayService.queryOrder(url, thirdApply.getAppId(), tbQuickPay.getTradeNo(), null, thirdApply.getAppToken());
|
||||||
if (ObjectUtil.isNotNull(orderstatus) && ObjectUtil.isNotEmpty(orderstatus)) {
|
if (ObjectUtil.isNotNull(orderstatus) && ObjectUtil.isNotEmpty(orderstatus)) {
|
||||||
if ("000000".equals(orderstatus.getCode())) {
|
if ("000000".equals(orderstatus.getCode())) {
|
||||||
if ("TRADE_SUCCESS".equals(orderstatus.getObjData().getState())) {
|
if ("TRADE_SUCCESS".equals(orderstatus.getObjData().getState())) {
|
||||||
@@ -949,6 +972,8 @@ public class PayService {
|
|||||||
tbQuickPay.setUpdateTime(new Date());
|
tbQuickPay.setUpdateTime(new Date());
|
||||||
tbQuickPayMapper.updateByPrimaryKeySelective(tbQuickPay);
|
tbQuickPayMapper.updateByPrimaryKeySelective(tbQuickPay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public enum CodeEnum {
|
|||||||
CARTSPEC("100021",false,"购物车商品不存在","fail"),
|
CARTSPEC("100021",false,"购物车商品不存在","fail"),
|
||||||
CARTJH("100022",false,"暂无可激活的订单","fail"),
|
CARTJH("100022",false,"暂无可激活的订单","fail"),
|
||||||
|
|
||||||
PAYING("100015",true,"用户支付中","fail"),
|
PAYING("100015",false,"用户支付中","fail"),
|
||||||
MEMBERINSUFFICIENTFUNDS("100016",true,"会员资金不足","fail"),
|
MEMBERINSUFFICIENTFUNDS("100016",true,"会员资金不足","fail"),
|
||||||
PRINTMACHINENOEXSIT("100017",true,"此店铺未配置打印机","fail"),
|
PRINTMACHINENOEXSIT("100017",true,"此店铺未配置打印机","fail"),
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class Result {
|
|||||||
/**
|
/**
|
||||||
* 加密
|
* 加密
|
||||||
*/
|
*/
|
||||||
private boolean encrypt;
|
private boolean encrypt=false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 图标
|
* 图标
|
||||||
@@ -106,7 +106,7 @@ public class Result {
|
|||||||
Result dto = new Result();
|
Result dto = new Result();
|
||||||
dto.setData(data);
|
dto.setData(data);
|
||||||
dto.setMsg(enums.getMsg());
|
dto.setMsg(enums.getMsg());
|
||||||
dto.setEncrypt(enums.getEncrypt());
|
dto.setEncrypt(false);
|
||||||
dto.setCode(enums.getCode());
|
dto.setCode(enums.getCode());
|
||||||
dto.setIcon(enums.getIcon());
|
dto.setIcon(enums.getIcon());
|
||||||
if(enums.getEncrypt()){
|
if(enums.getEncrypt()){
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ public class ThirdPayService {
|
|||||||
|
|
||||||
private static String trade="/api/open/query/trade";
|
private static String trade="/api/open/query/trade";
|
||||||
|
|
||||||
|
private static String refund="/api/open/order/refund";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 被扫接口
|
* 被扫接口
|
||||||
* @param url
|
* @param url
|
||||||
@@ -183,7 +185,7 @@ public class ThirdPayService {
|
|||||||
param.setSign(sign);
|
param.setSign(sign);
|
||||||
String reqbody = JSONUtil.toJSONString(param);
|
String reqbody = JSONUtil.toJSONString(param);
|
||||||
log.info("请求参数:{}", reqbody);
|
log.info("请求参数:{}", reqbody);
|
||||||
String response = HttpRequest.post(url.concat(trade)).body(reqbody).execute().body();
|
String response = HttpRequest.post(url.concat(refund)).body(reqbody).execute().body();
|
||||||
log.info("返回结果:{}", response);
|
log.info("返回结果:{}", response);
|
||||||
PublicResp<OrderReturnResp> resp =JSONUtil.parseJSONStr2T(response,PublicResp.class);
|
PublicResp<OrderReturnResp> resp =JSONUtil.parseJSONStr2T(response,PublicResp.class);
|
||||||
resp.setObjData(JSONUtil.parseJSONStr2T(resp.getBizData(),OrderReturnResp.class));
|
resp.setObjData(JSONUtil.parseJSONStr2T(resp.getBizData(),OrderReturnResp.class));
|
||||||
@@ -285,7 +287,6 @@ public class ThirdPayService {
|
|||||||
if(value==null){
|
if(value==null){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
map.put(field.getName(), value);
|
map.put(field.getName(), value);
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
@@ -295,6 +296,6 @@ public class ThirdPayService {
|
|||||||
|
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
// mainScan("https://paymentapi.sxczgkj.cn","6639fdc9fdf6f35856a23b3c", "测试支付", "测试支付", 1L, "wx212769170d2c6b2a", "131112206836873461", "CZ".concat(String.valueOf(System.currentTimeMillis())), "S2405103298", "https://", "fEu7tJgqaoPCA5QevafnSHfqHtO7rWcvhyfA0ltuab7rbpgOlab7CFCmqxMIbssUvbOnFKLdQqW5xUvhzb7FoxJNMAkIf2KDzlgDl6Diw1oBq56agSAFHhgYr3bLxXXI");
|
new ThirdPayService(). mainScan("https://paymentapi.sxczgkj.cn","66446e41fdf63f75318ed3f8", "测试支付", "测试支付", 1L, "wxd88fffa983758a30", "131112206836873461", "CZ".concat(String.valueOf(System.currentTimeMillis())), "S2405154485", "https://cashierclient.sxczgkj.cn/cashier-client/notify/notifyPay", "vHtBsHhPc3L7dXDBSKGgB5oso061xqFJcmmvfZ7DxBdZYpJHeI9a7OdqB0tzrLidPCpcWHxrKZ5AuZIPPCrTa8RwUsHS9atzzucIwspTKGcwOXINU1gUacxAKkhqTyT0");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
spring:
|
spring:
|
||||||
profiles:
|
profiles:
|
||||||
active: prod2
|
active: dev
|
||||||
server:
|
server:
|
||||||
servlet:
|
servlet:
|
||||||
context-path: /cashier-client/
|
context-path: /cashier-client/
|
||||||
@@ -39,7 +39,7 @@ gateway:
|
|||||||
client:
|
client:
|
||||||
backUrl: https://cashierclient.sxczgkj.cn/cashier-client/notify/notifyPay
|
backUrl: https://cashierclient.sxczgkj.cn/cashier-client/notify/notifyPay
|
||||||
thirdPay:
|
thirdPay:
|
||||||
payType: ysk
|
payType: fushangtong
|
||||||
callBack: https://cashierclient.sxczgkj.cn/cashier-client/notify/notifyPay
|
callBack: https://cashierclient.sxczgkj.cn/cashier-client/notify/notifyPay
|
||||||
url: https://paymentapi.sxczgkj.cn
|
url: https://paymentapi.sxczgkj.cn
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
</resultMap>
|
</resultMap>
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
id, type, app_id, status, pay_password, applyment_state, created_at, updated_at,
|
id, type, app_id, status, pay_password, applyment_state, created_at, updated_at,
|
||||||
shop_id
|
shop_id,small_appid,store_id
|
||||||
</sql>
|
</sql>
|
||||||
<sql id="Blob_Column_List">
|
<sql id="Blob_Column_List">
|
||||||
app_token
|
app_token
|
||||||
|
|||||||
@@ -154,4 +154,8 @@
|
|||||||
<select id="selectByShopIdAndStaffId" resultMap="BaseResultMap">
|
<select id="selectByShopIdAndStaffId" resultMap="BaseResultMap">
|
||||||
select * from tb_quick_pay where shop_id=#{shopId} and staff_id=#{staffId} and `status`='0' order by id desc
|
select * from tb_quick_pay where shop_id=#{shopId} and staff_id=#{staffId} and `status`='0' order by id desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectByOrderNo" resultMap="BaseResultMap">
|
||||||
|
select * from tb_quick_pay where order_no=#{orderNo}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user