|
|
@@ -3,6 +3,7 @@ package com.izouma.dingdong.service;
|
|
|
import com.izouma.dingdong.config.KsherPaySdk;
|
|
|
import com.izouma.dingdong.domain.OrderInfo;
|
|
|
import com.izouma.dingdong.enums.PayMethod;
|
|
|
+import com.izouma.dingdong.exception.BusinessException;
|
|
|
import com.izouma.dingdong.utils.SnowflakeIdWorker;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
@@ -20,7 +21,20 @@ public class ConsumptionService {
|
|
|
@Value("${ksher.private_key}")
|
|
|
private String privateKey;
|
|
|
|
|
|
- public void payOrder(OrderInfo orderInfo) {
|
|
|
+/* @Value("${wx.mp.app_id}")
|
|
|
+ private String channelSubAppid;*/
|
|
|
+
|
|
|
+ /*
|
|
|
+ 支付类型
|
|
|
+ CNY 人民币
|
|
|
+ THB 泰株
|
|
|
+ */
|
|
|
+ private String feeType = "CNY";
|
|
|
+
|
|
|
+ /*
|
|
|
+ app支付 只能微信和支付宝
|
|
|
+ */
|
|
|
+ public void appPay(OrderInfo orderInfo) {
|
|
|
//ksher支付SDK
|
|
|
KsherPaySdk ksherPaySdk = new KsherPaySdk(appid, privateKey);
|
|
|
//商家产生的唯一no
|
|
|
@@ -29,11 +43,29 @@ public class ConsumptionService {
|
|
|
Integer total = orderInfo.getRealAmount().multiply(BigDecimal.valueOf(100)).intValue();
|
|
|
//支付方式
|
|
|
String channel = "wechat";
|
|
|
- if (PayMethod.ALI_PAY.equals(orderInfo.getPayMethod())){
|
|
|
+ if (PayMethod.ALI_PAY.equals(orderInfo.getPayMethod())) {
|
|
|
channel = "alipay";
|
|
|
}
|
|
|
|
|
|
- //调app支付
|
|
|
- //ksherPaySdk.AppPay(mchOrderNo,"CNY",)
|
|
|
+ try {
|
|
|
+ //调app支付
|
|
|
+ ksherPaySdk.AppPay(mchOrderNo, feeType, channel, null, null, total);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.info("支付异常", e);
|
|
|
+ throw new BusinessException(e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ 聚合支付
|
|
|
+ */
|
|
|
+ public void cardPay(OrderInfo orderInfo) {
|
|
|
+ //ksher支付SDK
|
|
|
+ KsherPaySdk ksherPaySdk = new KsherPaySdk(appid, privateKey);
|
|
|
+ //商家产生的唯一no
|
|
|
+ String mchOrderNo = String.valueOf(new SnowflakeIdWorker(1, 1).nextId());
|
|
|
+ //支付方式
|
|
|
+ String channel = "ktbcard";
|
|
|
+ //ksherPaySdk.GatewayPay(mchOrderNo,feeType)
|
|
|
}
|
|
|
}
|