commit
f324751ed6
@ -0,0 +1,11 @@
|
||||
package au.com.royalpay.payment.manage.management.sysconfig.core;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SysPaymentConfig {
|
||||
List<JSONObject> getPaymentChannel();
|
||||
|
||||
void updatePaymentChannel(JSONObject manager, String channel, int type);
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package au.com.royalpay.payment.manage.management.sysconfig.core.impls;
|
||||
|
||||
import au.com.royalpay.payment.manage.management.sysconfig.core.SysPaymentConfig;
|
||||
import au.com.royalpay.payment.manage.mappers.system.RateMapper;
|
||||
import au.com.royalpay.payment.manage.mappers.system.SysChannelConfigMapper;
|
||||
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class SysPaymentConfigImpl implements SysPaymentConfig {
|
||||
@Resource
|
||||
private SysChannelConfigMapper sysChannelConfigMapper;
|
||||
|
||||
@Override
|
||||
public List<JSONObject> getPaymentChannel() {
|
||||
return sysChannelConfigMapper.selectAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePaymentChannel(JSONObject manager, String channel, int type) {
|
||||
JSONObject paymentConfig = sysChannelConfigMapper.find(channel, type);
|
||||
if (paymentConfig == null) {
|
||||
throw new BadRequestException("不存在该快捷通道");
|
||||
}
|
||||
Date lastUpdateTime = new Date();
|
||||
sysChannelConfigMapper.updatePaymentConfig(channel, type, lastUpdateTime, manager.getString("display_name"), false);
|
||||
sysChannelConfigMapper.updatePaymentConfig(channel, type, lastUpdateTime, manager.getString("display_name"), true);
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package au.com.royalpay.payment.manage.mappers.financial;
|
||||
|
||||
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
|
||||
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
|
||||
import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@AutoMapper(tablename = "financial_leader_prize_log", pkName = "leader_prize_log")
|
||||
public interface FinancialLeaderPrizeLogMapper {
|
||||
|
||||
@AutoSql(type = SqlType.SELECT)
|
||||
List<JSONObject> listLeaderPrizeLog(@Param(value = "record_id") String record_id);
|
||||
|
||||
@AutoSql(type = SqlType.INSERT)
|
||||
void save(JSONObject prizeLog);
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package au.com.royalpay.payment.manage.mappers.system;
|
||||
|
||||
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
|
||||
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
|
||||
import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@AutoMapper(tablename = "cb_channel_config",pkName = "channel_id")
|
||||
public interface SysChannelConfigMapper {
|
||||
@AutoSql(type = SqlType.SELECT)
|
||||
List<JSONObject> selectAll();
|
||||
|
||||
@AutoSql(type = SqlType.SELECT)
|
||||
JSONObject find(@Param(value = "channel_id") String channel, @Param(value = "type") int type);
|
||||
|
||||
void updatePaymentConfig(@Param(value = "channel_id") String channel, @Param(value = "type") int type, @Param(value = "last_update_date")Date lastUpdateDate,
|
||||
@Param(value = "last_update_by")String lastUpdateBy, @Param(value = "is_valid") boolean is_valid);
|
||||
|
||||
JSONObject findOne(@Param(value = "type") int type);
|
||||
}
|
@ -0,0 +1,194 @@
|
||||
package au.com.royalpay.payment.manage.processors;
|
||||
|
||||
import au.com.royalpay.payment.core.PaymentApi;
|
||||
import au.com.royalpay.payment.core.beans.PreOrderRequest;
|
||||
import au.com.royalpay.payment.core.beans.coupon.CouponInfo;
|
||||
import au.com.royalpay.payment.core.events.PaymentFinishedEvent;
|
||||
import au.com.royalpay.payment.core.events.RefundSendEvent;
|
||||
import au.com.royalpay.payment.core.processors.PaymentProcessor;
|
||||
import au.com.royalpay.payment.manage.mappers.log.CouponAccuessLogMapper;
|
||||
import au.com.royalpay.payment.tools.CommonConsts;
|
||||
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
|
||||
import au.com.royalpay.payment.tools.env.SysConfigManager;
|
||||
import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider;
|
||||
import au.com.royalpay.payment.tools.utils.CurrencyAmountUtils;
|
||||
import cn.yixblog.platform.http.HttpRequestGenerator;
|
||||
import cn.yixblog.platform.http.HttpRequestResult;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.github.miemiedev.mybatis.paginator.domain.Order;
|
||||
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class CtripCouponOnlyLogProcessor implements PaymentProcessor {
|
||||
|
||||
// todo 重构逻辑
|
||||
private org.slf4j.Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
|
||||
private static final String COUPON_ID = "CTRIP_COUPON_ONLY_LOG";
|
||||
|
||||
@Value("${app.customer.host}")
|
||||
private String CUSTOMER_HOST;
|
||||
|
||||
@Value("${customer.app.appid}")
|
||||
private String CUSTOMER_APP_ID;
|
||||
|
||||
@Value("${customer.app.auth-code}")
|
||||
private String CUSTOMER_AUTH_CODE;
|
||||
|
||||
@Resource
|
||||
private MerchantInfoProvider merchantInfoProvider;
|
||||
|
||||
@Resource
|
||||
private SysConfigManager sysConfigManager;
|
||||
|
||||
@Resource
|
||||
private CouponAccuessLogMapper payCouponAccuessLogMapper;
|
||||
@Resource
|
||||
private PaymentApi paymentApi;
|
||||
@Override
|
||||
public String processorId() {
|
||||
return COUPON_ID + "_USE";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleBeforeOrderSending(PreOrderRequest paymentInfo, JSONObject order) {
|
||||
JSONObject tmpEle = paymentInfo.getTmpEle();
|
||||
if (tmpEle == null) {
|
||||
return;
|
||||
}
|
||||
if (StringUtils.isEmpty(tmpEle.getString("ctrip_coupon_id"))) {
|
||||
return;
|
||||
}
|
||||
if (!isOnlyLogMerchant(order.getIntValue("client_id"))) {
|
||||
return;
|
||||
}
|
||||
JSONObject couponInfo = getPreOrderCoupon(tmpEle.getString("ctrip_coupon_id"), order.getIntValue("client_id"));
|
||||
if (couponInfo == null) {
|
||||
return;
|
||||
}
|
||||
BigDecimal payFee = paymentInfo.getTotalFee();
|
||||
BigDecimal exchange = paymentApi.channelApi(paymentInfo.getChannel()).queryExchangeRateDecimal(paymentInfo.getClientId());
|
||||
if (StringUtils.equals(paymentInfo.getCurrency(), "CNY")) {
|
||||
payFee = CurrencyAmountUtils.scale(payFee.divide(exchange,2, BigDecimal.ROUND_HALF_UP), PlatformEnvironment.getEnv().getForeignCurrency());
|
||||
}
|
||||
BigDecimal couponCondition = couponInfo.getBigDecimal("condition") == null ? BigDecimal.ZERO
|
||||
: couponInfo.getBigDecimal("condition");
|
||||
if (payFee.compareTo(couponCondition) < 0) {
|
||||
return;
|
||||
}
|
||||
JSONObject couponAccuessLog = new JSONObject();
|
||||
couponAccuessLog.put("client_id",order.getIntValue("client_id"));
|
||||
couponAccuessLog.put("customer_openid","创建订单时无");
|
||||
couponAccuessLog.put("creation_date",new Date());
|
||||
couponAccuessLog.put("order_id",order.getString("order_id"));
|
||||
couponAccuessLog.put("coupon_id","CTRIP_"+tmpEle.getString("ctrip_coupon_id"));
|
||||
//携程满减
|
||||
if (StringUtils.equals(couponInfo.getString("type"), "31")) {
|
||||
BigDecimal actureAmount = couponInfo.getBigDecimal("acture_amount");
|
||||
if (StringUtils.equals(paymentInfo.getCurrency(), "CNY")) {
|
||||
actureAmount = CurrencyAmountUtils.scale(couponInfo.getBigDecimal("acture_amount").multiply(exchange), PlatformEnvironment.getEnv().getForeignCurrency());
|
||||
}
|
||||
couponAccuessLog.put("coupon_deal_amount", actureAmount);
|
||||
}
|
||||
//携程折扣
|
||||
if (StringUtils.equals(couponInfo.getString("type"), "32")) {
|
||||
BigDecimal couponDiscount = couponInfo.getBigDecimal("discount").divide(CommonConsts.HUNDRED, 4, BigDecimal.ROUND_HALF_UP);
|
||||
BigDecimal couponDealAmount = CurrencyAmountUtils.scale(couponDiscount.multiply(paymentInfo.getTotalFee()), PlatformEnvironment.getEnv().getForeignCurrency());
|
||||
couponAccuessLog.put("coupon_deal_amount", couponDealAmount);
|
||||
}
|
||||
couponAccuessLog.put("currency", order.getString("currency"));
|
||||
couponAccuessLog.put("min_pay_amount", couponCondition);
|
||||
payCouponAccuessLogMapper.save(couponAccuessLog);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleAfterOrderPaid(PaymentFinishedEvent finishedEvent) {
|
||||
JSONObject order = finishedEvent.getOrder();
|
||||
String orderId = order.getString("order_id");
|
||||
List<JSONObject> accuessCouponLogs = payCouponAccuessLogMapper.findAccuessLogByOrderId(orderId, new PageBounds(Order.formString("last_update_date.desc")));
|
||||
if (accuessCouponLogs != null&&accuessCouponLogs.size()>0) {
|
||||
if (!isOnlyLogMerchant(order.getIntValue("client_id"))) {
|
||||
return;
|
||||
}
|
||||
JSONObject accuessCouponLog = accuessCouponLogs.get(0);
|
||||
String couponLogId = accuessCouponLog.getString("coupon_id");
|
||||
logger.info("订单 [" + orderId + "]成功使用Ctrip卡券=======>[" + couponLogId + "]");
|
||||
accuessCouponLog.put("is_valid", 1);
|
||||
accuessCouponLog.put("last_update_date", new Date());
|
||||
accuessCouponLog.put("customer_openid",order.getString("customer_id"));
|
||||
|
||||
payCouponAccuessLogMapper.update(accuessCouponLog);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCoupon(JSONObject client, String customerOpenId, String channel, List<CouponInfo> coupons) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleAfterRefund(RefundSendEvent event) {
|
||||
//do nothing
|
||||
JSONObject refundOrder = event.getRefundOrder();
|
||||
String orderId = refundOrder.getString("order_id");
|
||||
List<JSONObject> accuessCouponLogs = payCouponAccuessLogMapper.findUsedCouponByOrderIdList(orderId);
|
||||
if (accuessCouponLogs != null&& accuessCouponLogs.size()>0) {
|
||||
if (!isOnlyLogMerchant(refundOrder.getIntValue("client_id"))) {
|
||||
return;
|
||||
}
|
||||
JSONObject accuessCouponLog = accuessCouponLogs.get(0);
|
||||
accuessCouponLog.put("is_valid", 0);
|
||||
accuessCouponLog.put("last_update_date", new Date());
|
||||
accuessCouponLog.put("refund_id",refundOrder.getString("refund_id"));
|
||||
payCouponAccuessLogMapper.update(accuessCouponLog);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String registerBanner(JSONObject client, String channel) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 使用券的信息
|
||||
private JSONObject getPreOrderCoupon(String couponLogId,int clientId) {
|
||||
JSONObject client = merchantInfoProvider.getClientInfo(clientId);
|
||||
String timestamp = System.currentTimeMillis() + "";
|
||||
String base = CUSTOMER_APP_ID + timestamp + CUSTOMER_AUTH_CODE;
|
||||
String sign = DigestUtils.sha256Hex(base).toLowerCase();
|
||||
String uri = UriComponentsBuilder.fromHttpUrl(CUSTOMER_HOST + "coupon/" + couponLogId + "/couponLogInfo").queryParam("appid", CUSTOMER_APP_ID)
|
||||
.queryParam("timestamp", timestamp).queryParam("sign", sign).queryParam("client_moniker", client.getString("client_moniker")).toUriString();
|
||||
HttpRequestGenerator gen = new HttpRequestGenerator(uri, RequestMethod.GET);
|
||||
try {
|
||||
HttpRequestResult result = gen.execute();
|
||||
if (result.isSuccess()) {
|
||||
return result.getResponseContentJSONObj();
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
logger.error("积分商城优惠券 [" + couponLogId + "]使用失败");
|
||||
ignored.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isOnlyLogMerchant(int clientId) {
|
||||
JSONObject client = merchantInfoProvider.getClientInfo(clientId);
|
||||
JSONObject sysConfig = sysConfigManager.getSysConfig();
|
||||
if (sysConfig.getString("ctrip_coupon_only_log_merchant_list").contains(client.getString("client_moniker"))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,266 @@
|
||||
package au.com.royalpay.payment.manage.processors;
|
||||
|
||||
import au.com.royalpay.payment.core.PaymentApi;
|
||||
import au.com.royalpay.payment.core.TransactionService;
|
||||
import au.com.royalpay.payment.core.beans.PaymentQueryResult;
|
||||
import au.com.royalpay.payment.core.beans.PreOrderRequest;
|
||||
import au.com.royalpay.payment.core.beans.coupon.CouponInfo;
|
||||
import au.com.royalpay.payment.core.events.PaymentFinishedEvent;
|
||||
import au.com.royalpay.payment.core.events.RefundSendEvent;
|
||||
import au.com.royalpay.payment.core.mappers.PmtOrderMapper;
|
||||
import au.com.royalpay.payment.core.processors.PaymentProcessor;
|
||||
import au.com.royalpay.payment.manage.mappers.log.CouponAccuessLogMapper;
|
||||
import au.com.royalpay.payment.tools.CommonConsts;
|
||||
import au.com.royalpay.payment.tools.env.PlatformEnvironment;
|
||||
import au.com.royalpay.payment.tools.env.SysConfigManager;
|
||||
import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider;
|
||||
import au.com.royalpay.payment.tools.utils.CurrencyAmountUtils;
|
||||
import cn.yixblog.platform.http.HttpRequestGenerator;
|
||||
import cn.yixblog.platform.http.HttpRequestResult;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.github.miemiedev.mybatis.paginator.domain.Order;
|
||||
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class CtripCouponProvideProcessor implements PaymentProcessor {
|
||||
|
||||
// todo 重构逻辑
|
||||
private org.slf4j.Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
|
||||
private static final String COUPON_ID = "CTRIP_COUPON";
|
||||
|
||||
@Value("${app.customer.host}")
|
||||
private String CUSTOMER_HOST;
|
||||
|
||||
@Value("${customer.app.appid}")
|
||||
private String CUSTOMER_APP_ID;
|
||||
|
||||
@Value("${customer.app.auth-code}")
|
||||
private String CUSTOMER_AUTH_CODE;
|
||||
|
||||
@Resource
|
||||
private MerchantInfoProvider merchantInfoProvider;
|
||||
@Resource
|
||||
private SysConfigManager sysConfigManager;
|
||||
@Resource
|
||||
private CouponAccuessLogMapper payCouponAccuessLogMapper;
|
||||
@Resource
|
||||
private PaymentApi paymentApi;
|
||||
@Resource
|
||||
private PmtOrderMapper pmtOrderMapper;
|
||||
@Resource
|
||||
private TransactionService transactionService;
|
||||
@Override
|
||||
public String processorId() {
|
||||
return COUPON_ID + "_USE";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleBeforeOrderSending(PreOrderRequest paymentInfo, JSONObject order) {
|
||||
/*if (order.getIntValue("client_id") != 9) {
|
||||
return;
|
||||
}*/
|
||||
JSONObject tmpEle = paymentInfo.getTmpEle();
|
||||
if (tmpEle == null) {
|
||||
return;
|
||||
}
|
||||
if (StringUtils.isEmpty(tmpEle.getString("ctrip_coupon_id"))) {
|
||||
return;
|
||||
}
|
||||
logger.info("tmpEle:" + tmpEle.toJSONString());
|
||||
if (isOnlyLogMerchant(order.getIntValue("client_id"))) {
|
||||
return;
|
||||
}
|
||||
JSONObject couponInfo = getPreOrderCoupon(tmpEle.getString("ctrip_coupon_id"), order.getIntValue("client_id"));
|
||||
if (couponInfo == null) {
|
||||
return;
|
||||
}
|
||||
BigDecimal payFee = paymentInfo.getTotalFee();
|
||||
BigDecimal exchange = paymentApi.channelApi(paymentInfo.getChannel()).queryExchangeRateDecimal(paymentInfo.getClientId());
|
||||
if (StringUtils.equals(paymentInfo.getCurrency(), "CNY")) {
|
||||
payFee = CurrencyAmountUtils.scale(payFee.divide(exchange,2, BigDecimal.ROUND_HALF_UP), PlatformEnvironment.getEnv().getForeignCurrency());
|
||||
}
|
||||
BigDecimal couponCondition = couponInfo.getBigDecimal("condition") == null ? BigDecimal.ZERO
|
||||
: couponInfo.getBigDecimal("condition");
|
||||
if (payFee.compareTo(couponCondition) < 0) {
|
||||
return;
|
||||
}
|
||||
JSONObject couponAccuessLog = new JSONObject();
|
||||
couponAccuessLog.put("client_id",order.getIntValue("client_id"));
|
||||
couponAccuessLog.put("customer_openid","创建订单时无");
|
||||
couponAccuessLog.put("creation_date",new Date());
|
||||
couponAccuessLog.put("order_id",order.getString("order_id"));
|
||||
couponAccuessLog.put("coupon_id","CTRIP_"+tmpEle.getString("ctrip_coupon_id"));
|
||||
BigDecimal currentDiscount = paymentInfo.getDiscount();
|
||||
//携程满减
|
||||
if (StringUtils.equals(couponInfo.getString("type"), "31")) {
|
||||
BigDecimal actureAmount = couponInfo.getBigDecimal("acture_amount");
|
||||
if (StringUtils.equals(paymentInfo.getCurrency(), "CNY")) {
|
||||
actureAmount = CurrencyAmountUtils.scale(couponInfo.getBigDecimal("acture_amount").multiply(exchange), PlatformEnvironment.getEnv().getForeignCurrency());
|
||||
}
|
||||
paymentInfo.setDiscount(currentDiscount.add(actureAmount));
|
||||
couponAccuessLog.put("coupon_deal_amount", actureAmount);
|
||||
}
|
||||
//携程折扣
|
||||
if (StringUtils.equals(couponInfo.getString("type"), "32")) {
|
||||
BigDecimal couponDiscount = couponInfo.getBigDecimal("discount").divide(CommonConsts.HUNDRED, 4, BigDecimal.ROUND_HALF_UP);
|
||||
BigDecimal couponDealAmount = CurrencyAmountUtils.scale(couponDiscount.multiply(paymentInfo.getTotalFee()), PlatformEnvironment.getEnv().getForeignCurrency());
|
||||
paymentInfo.setDiscount(currentDiscount.add(couponDealAmount));
|
||||
couponAccuessLog.put("coupon_deal_amount", couponDealAmount);
|
||||
}
|
||||
couponAccuessLog.put("currency", order.getString("currency"));
|
||||
couponAccuessLog.put("min_pay_amount", couponCondition);
|
||||
payCouponAccuessLogMapper.save(couponAccuessLog);
|
||||
|
||||
JSONObject updateOrder = new JSONObject();
|
||||
BigDecimal customerPay = paymentInfo.getUserPayAmount();
|
||||
updateOrder.put("customer_payment_amount", customerPay);
|
||||
BigDecimal couponDiscount = paymentInfo.getDiscount();
|
||||
updateOrder.put("coupon_payment_amount", couponDiscount);
|
||||
updateOrder.put("order_id", paymentInfo.getOrderId());
|
||||
|
||||
pmtOrderMapper.update(updateOrder);
|
||||
|
||||
order.put("customer_payment_amount", customerPay);
|
||||
order.put("coupon_payment_amount", couponDiscount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleAfterOrderPaid(PaymentFinishedEvent finishedEvent) {
|
||||
JSONObject order = finishedEvent.getOrder();
|
||||
/*if (order.getIntValue("client_id") != 9) {
|
||||
return;
|
||||
}*/
|
||||
String orderId = order.getString("order_id");
|
||||
List<JSONObject> accuessCouponLogs = payCouponAccuessLogMapper.findAccuessLogByOrderId(orderId, new PageBounds(Order.formString("last_update_date.desc")));
|
||||
if (accuessCouponLogs != null&&accuessCouponLogs.size()>0) {
|
||||
if (isOnlyLogMerchant(order.getIntValue("client_id"))) {
|
||||
return;
|
||||
}
|
||||
JSONObject accuessCouponLog = accuessCouponLogs.get(0);
|
||||
String couponLogId = accuessCouponLog.getString("coupon_id");
|
||||
logger.info("订单 [" + orderId + "]成功使用Ctrip卡券=======>[" + couponLogId + "]");
|
||||
|
||||
//传入流水
|
||||
JSONObject useCoupontrans = new JSONObject();
|
||||
useCoupontrans.put("org_id", order.getIntValue("org_id"));
|
||||
useCoupontrans.put("system_transaction_id", accuessCouponLog.getString("accuess_id"));
|
||||
useCoupontrans.put("order_id", order.getString("order_id"));
|
||||
useCoupontrans.put("client_id", order.getIntValue("client_id"));
|
||||
useCoupontrans.put("transaction_currency", order.getString("currency"));
|
||||
if (StringUtils.equals(order.getString("currency"), "CNY")) {
|
||||
useCoupontrans.put("cny_amount", accuessCouponLog.getBigDecimal("coupon_deal_amount"));
|
||||
}
|
||||
useCoupontrans.put("clearing_currency", PlatformEnvironment.getEnv().getForeignCurrency());
|
||||
useCoupontrans.put("clearing_amount", accuessCouponLog.getBigDecimal("coupon_deal_amount"));
|
||||
useCoupontrans.put("transaction_amount", accuessCouponLog.getBigDecimal("coupon_deal_amount"));
|
||||
useCoupontrans.put("exchange_rate", finishedEvent.getExchangeRate());
|
||||
useCoupontrans.put("channel", order.getString("channel"));
|
||||
useCoupontrans.put("transaction_type", "Credit");
|
||||
PaymentQueryResult pay = finishedEvent.getPaymentQueryResult();
|
||||
useCoupontrans.put("transaction_time", pay.getPayTime());
|
||||
useCoupontrans.put("clearing_status", 0);
|
||||
useCoupontrans.put("system_generate", 1);
|
||||
useCoupontrans.put("remark", "Ctrip Coupon from Customer:" + couponLogId);
|
||||
accuessCouponLog = payCouponAccuessLogMapper.findAccuessLogByOrderId(orderId,new PageBounds(Order.formString("last_update_date.desc"))).get(0);
|
||||
if (accuessCouponLog != null) {
|
||||
transactionService.saveTransaction(useCoupontrans);
|
||||
accuessCouponLog.put("is_valid", 1);
|
||||
accuessCouponLog.put("last_update_date", new Date());
|
||||
accuessCouponLog.put("transaction_id", useCoupontrans.getString("transaction_id"));
|
||||
accuessCouponLog.put("customer_openid",order.getString("customer_id"));
|
||||
payCouponAccuessLogMapper.update(accuessCouponLog);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCoupon(JSONObject client, String customerOpenId, String channel, List<CouponInfo> coupons) {
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleAfterRefund(RefundSendEvent event) {
|
||||
//do nothing
|
||||
JSONObject refundOrder = event.getRefundOrder();
|
||||
/*if (refundOrder.getIntValue("client_id") != 9) {
|
||||
return;
|
||||
}*/
|
||||
logger.info("积分商城携程优惠券开始退款");
|
||||
String orderId = refundOrder.getString("order_id");
|
||||
List<JSONObject> accuessCouponLogs = payCouponAccuessLogMapper.findUsedCouponByOrderIdList(orderId);
|
||||
if (accuessCouponLogs != null&& accuessCouponLogs.size()>0) {
|
||||
if (isOnlyLogMerchant(refundOrder.getIntValue("client_id"))) {
|
||||
return;
|
||||
}
|
||||
JSONObject accuessCouponLog = accuessCouponLogs.get(0);
|
||||
JSONObject trans = transactionService.findTransaction(accuessCouponLog.getString("transaction_id"));
|
||||
if (trans != null) {
|
||||
logger.info("正在退款的券的初始信息" + trans.toJSONString());
|
||||
trans.remove("transaction_id");
|
||||
trans.put("transaction_type", "Debit");
|
||||
String coupon_id = accuessCouponLog.getString("coupon_id");
|
||||
trans.put("refund_id", refundOrder.getString("refund_id"));
|
||||
trans.put("transaction_time", new Date());
|
||||
trans.put("remark", "Refund for Customer Ctrip Coupon:" + coupon_id);
|
||||
logger.info("正在退款的券的信息" + trans.toJSONString());
|
||||
transactionService.saveTransaction(trans);
|
||||
logger.error("订单[" + orderId + "]发送全额退款,携程优惠券【" + coupon_id + "】转为Debit");
|
||||
accuessCouponLog.put("transaction_refund_id", trans.getString("transaction_id"));
|
||||
accuessCouponLog.put("refund_id", refundOrder.getString("refund_id"));
|
||||
accuessCouponLog.put("is_valid", 0);
|
||||
accuessCouponLog.put("last_update_date", new Date());
|
||||
payCouponAccuessLogMapper.update(accuessCouponLog);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String registerBanner(JSONObject client, String channel) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 使用券的信息
|
||||
private JSONObject getPreOrderCoupon(String couponLogId,int clientId) {
|
||||
JSONObject client = merchantInfoProvider.getClientInfo(clientId);
|
||||
String timestamp = System.currentTimeMillis() + "";
|
||||
String base = CUSTOMER_APP_ID + timestamp + CUSTOMER_AUTH_CODE;
|
||||
String sign = DigestUtils.sha256Hex(base).toLowerCase();
|
||||
String uri = UriComponentsBuilder.fromHttpUrl(CUSTOMER_HOST + "coupon/" + couponLogId + "/couponLogInfo").queryParam("appid", CUSTOMER_APP_ID)
|
||||
.queryParam("timestamp", timestamp).queryParam("sign", sign).queryParam("client_moniker", client.getString("client_moniker")).toUriString();
|
||||
HttpRequestGenerator gen = new HttpRequestGenerator(uri, RequestMethod.GET);
|
||||
try {
|
||||
HttpRequestResult result = gen.execute();
|
||||
if (result.isSuccess()) {
|
||||
return result.getResponseContentJSONObj();
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
logger.error("积分商城优惠券 [" + couponLogId + "]使用失败");
|
||||
ignored.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isOnlyLogMerchant(int clientId) {
|
||||
JSONObject client = merchantInfoProvider.getClientInfo(clientId);
|
||||
JSONObject sysConfig = sysConfigManager.getSysConfig();
|
||||
if (sysConfig.getString("ctrip_coupon_only_log_merchant_list").contains(client.getString("client_moniker"))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="au.com.royalpay.payment.manage.mappers.system.SysChannelConfigMapper">
|
||||
<update id="updatePaymentConfig">
|
||||
update cb_channel_config
|
||||
SET is_valid = #{is_valid},last_update_by = #{last_update_by},last_update_date = #{last_update_date}
|
||||
<where>
|
||||
type = #{type}
|
||||
<if test="is_valid">
|
||||
and channel_id = #{channel_id}
|
||||
</if>
|
||||
<if test="!is_valid">
|
||||
and channel_id != #{channel_id}
|
||||
</if>
|
||||
</where>
|
||||
</update>
|
||||
<select id="findOne" resultType="com.alibaba.fastjson.JSONObject">
|
||||
select * from cb_channel_config where is_valid = 1 and type = #{type} limit 1;
|
||||
</select>
|
||||
</mapper>
|
@ -0,0 +1,40 @@
|
||||
<section class="content-header">
|
||||
<h1>Basic Config</h1>
|
||||
<ol class="breadcrumb">
|
||||
<li>
|
||||
<a ui-sref="^"><i class="fa fa-cog"></i> System Config</a>
|
||||
</li>
|
||||
<li>Payment BankPay Config</li>
|
||||
</ol>
|
||||
</section>
|
||||
|
||||
<div class="content">
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
<div class="box-solid">
|
||||
<div class="box box-warning">
|
||||
<div class="box-header">
|
||||
<form role="form" style="margin:0px auto;width: 50%">
|
||||
<div class="form-group" >
|
||||
<label>快捷通道</label>
|
||||
<select class="form-control" name="industry" ng-change="updatePaymentConfig(1,cb_bankpay_channel)"
|
||||
ng-model="cb_bankpay_channel"
|
||||
id="cbbankpay-input" required
|
||||
ng-options="channel.channel_id as channel.channel_name for channel in cb_bankpay">
|
||||
<option value="">请选择</option>
|
||||
</select>
|
||||
<label>网银通道</label>
|
||||
<select class="form-control" name="industry" ng-change="updatePaymentConfig(2,pay_channel)"
|
||||
ng-model="pay_channel"
|
||||
id="-input" required
|
||||
ng-options="channel.channel_id as channel.channel_name for channel in pay">
|
||||
<option value="">请选择</option>
|
||||
</select>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
Loading…
Reference in new issue