Merge branch 'hotfix' into develop

master
kira 6 years ago
commit da0e7c5c84

@ -156,4 +156,8 @@ public interface RetailAppService {
JSONObject getRefunds(JSONObject device, AppQueryBean appQueryBean); JSONObject getRefunds(JSONObject device, AppQueryBean appQueryBean);
JSONObject ctripCheck(JSONObject device);
JSONObject ctripCouponInfo(JSONObject device,String coupon_id);
} }

@ -422,7 +422,7 @@ public class RetailAppServiceImp implements RetailAppService {
return customerServiceService.checkAndSavePartner(account); return customerServiceService.checkAndSavePartner(account);
} }
//暂不使用 // 暂不使用
@Override @Override
public void addUnreadMsg(JSONObject device, JSONObject param) { public void addUnreadMsg(JSONObject device, JSONObject param) {
customerServiceService.addUnreadMsg(param); customerServiceService.addUnreadMsg(param);
@ -432,14 +432,25 @@ public class RetailAppServiceImp implements RetailAppService {
public JSONObject getRefunds(JSONObject device, AppQueryBean appQueryBean) { public JSONObject getRefunds(JSONObject device, AppQueryBean appQueryBean) {
JSONObject appParam = appQueryBean.toParams(); JSONObject appParam = appQueryBean.toParams();
JSONObject param = new JSONObject(); JSONObject param = new JSONObject();
if(appParam.get("client_ids")==null) { if (appParam.get("client_ids") == null) {
param.put("client_id", device.getIntValue("client_id")); param.put("client_id", device.getIntValue("client_id"));
} }
param.put("start_time",appParam.getDate("begin")); param.put("start_time", appParam.getDate("begin"));
param.put("end_time",appParam.getDate("end")); param.put("end_time", appParam.getDate("end"));
return refundService.listUnionAllApply(param, new PageBounds(appQueryBean.getPage(), appQueryBean.getLimit())); return refundService.listUnionAllApply(param, new PageBounds(appQueryBean.getPage(), appQueryBean.getLimit()));
} }
@Override
public JSONObject ctripCheck(JSONObject deivce) {
return couponVerificationService.ctripCheck(deivce.getIntValue("client_id"));
}
@Override
public JSONObject ctripCouponInfo(JSONObject device, String coupon_id) {
return couponVerificationService.ctripCouponInfo(coupon_id,device.getIntValue("client_id"));
}
@Override @Override
public void updateClient(JSONObject device, AppClientBean appClientBean) { public void updateClient(JSONObject device, AppClientBean appClientBean) {
String clientType = device.getString("client_type"); String clientType = device.getString("client_type");
@ -1298,8 +1309,8 @@ public class RetailAppServiceImp implements RetailAppService {
if (AlipayOnline.containsKey("channel")) { if (AlipayOnline.containsKey("channel")) {
channels.add(AlipayOnline); channels.add(AlipayOnline);
} }
JSONObject Hf = getChannel(clientId,now,"hf"); JSONObject Hf = getChannel(clientId, now, "hf");
if (Hf.containsKey("channel")){ if (Hf.containsKey("channel")) {
channels.add(Hf); channels.add(Hf);
} }
res.put("channels", channels); res.put("channels", channels);

@ -554,4 +554,14 @@ public class RetailAppController {
retailAppService.addUnreadMsg(device,param); retailAppService.addUnreadMsg(device,param);
} }
@RequestMapping(value = "/ctrip/check",method = RequestMethod.GET)
public void ctripCheck(@ModelAttribute(RETAIL_DEVICE) JSONObject device) {
retailAppService.ctripCheck(device);
}
@RequestMapping(value = "/ctrip/coupon/{couponId}",method = RequestMethod.GET)
public void ctripCheck(@ModelAttribute(RETAIL_DEVICE) JSONObject device,@PathVariable String couponId) {
retailAppService.ctripCouponInfo(device,couponId);
}
} }

@ -0,0 +1,41 @@
package au.com.royalpay.payment.manage.apps.events.listeners.ctrip;
import au.com.royalpay.payment.core.events.AfterPaymentFinishEvent;
import au.com.royalpay.payment.manage.customers.core.CouponValidateService;
import au.com.royalpay.payment.manage.mappers.log.CouponAccuessLogMapper;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Service;
import java.util.List;
import javax.annotation.Resource;
/**
* Created by wangning on 17/01/2018.
*/
@Service
public class AfterPaymentFinishListener implements ApplicationListener<AfterPaymentFinishEvent> {
Logger logger = LoggerFactory.getLogger(getClass());
@Resource
private CouponValidateService couponValidateService;
@Resource
private CouponAccuessLogMapper couponAccuessLogMapper;
@Override
public void onApplicationEvent(AfterPaymentFinishEvent event) {
JSONObject order = event.getFinishedEvent().getOrder();
String orderId = order.getString("order_id");
List<JSONObject> accuessCouponLogs = couponAccuessLogMapper.findCouponByOrderId(orderId);
if (accuessCouponLogs != null&&accuessCouponLogs.size()>0) {
JSONObject accuessCouponLog = accuessCouponLogs.get(0);
String couponId = accuessCouponLog.getString("coupon_id");
couponValidateService.ctripCouponLogNotice(couponId,orderId,order.getString("customer_id"));
logger.info("订单 [" + orderId + "]推送支付成功Ctrip卡券=======>[" + couponId + "]");
}
}
}

@ -0,0 +1,46 @@
package au.com.royalpay.payment.manage.apps.events.listeners.ctrip;
import au.com.royalpay.payment.core.events.RefundFinishedEvent;
import au.com.royalpay.payment.core.mappers.PmtOrderMapper;
import au.com.royalpay.payment.manage.customers.core.CouponValidateService;
import au.com.royalpay.payment.manage.mappers.log.CouponAccuessLogMapper;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Service;
import java.util.List;
import javax.annotation.Resource;
/**
* @author kira
* @date 2018/8/8
*/
@Service
public class RefundFinishedEventListener implements ApplicationListener<RefundFinishedEvent> {
Logger logger = LoggerFactory.getLogger(getClass());
@Resource
private PmtOrderMapper orderMapper;
@Resource
private CouponValidateService couponValidateService;
@Resource
private CouponAccuessLogMapper couponAccuessLogMapper;
@Override
public void onApplicationEvent(RefundFinishedEvent event) {
JSONObject refund = event.getRefundOrder();
JSONObject order = orderMapper.find(refund.getString("order_id"));
String orderId = order.getString("order_id");
List<JSONObject> accuessCouponLogs = couponAccuessLogMapper.findCouponByOrderId(orderId);
if (accuessCouponLogs != null&&accuessCouponLogs.size()>0) {
JSONObject accuessCouponLog = accuessCouponLogs.get(0);
String couponId = accuessCouponLog.getString("coupon_id");
couponValidateService.ctripCouponLogNotice(couponId,orderId,order.getString("customer_id"));
logger.info("订单 [" + orderId + "]推送退款成功Ctrip卡券=======>[" + couponId + "]");
}
}
}

@ -15,4 +15,10 @@ public interface CouponValidateService {
boolean useCoupon(String couponLogId); boolean useCoupon(String couponLogId);
JSONObject getPaymentManager(); JSONObject getPaymentManager();
JSONObject ctripCheck(int client_id);
JSONObject ctripCouponInfo(String coupon_log_id,int client_id);
JSONObject ctripCouponLogNotice(String coupon_log_id,String order_id,String open_id);
} }

@ -2,12 +2,16 @@ package au.com.royalpay.payment.manage.customers.core.impls;
import au.com.royalpay.payment.manage.customers.core.CouponValidateService; import au.com.royalpay.payment.manage.customers.core.CouponValidateService;
import au.com.royalpay.payment.manage.mappers.customers.CustomerMembershipMapper; import au.com.royalpay.payment.manage.mappers.customers.CustomerMembershipMapper;
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.tools.exceptions.BadRequestException; import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import cn.yixblog.platform.http.HttpRequestGenerator; import au.com.royalpay.payment.tools.exceptions.NotFoundException;
import cn.yixblog.platform.http.HttpRequestResult;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.time.DateUtils; import org.apache.commons.lang3.time.DateUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
@ -15,8 +19,14 @@ import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.util.UriComponentsBuilder; import org.springframework.web.util.UriComponentsBuilder;
import javax.annotation.Resource; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import cn.yixblog.platform.http.HttpRequestGenerator;
import cn.yixblog.platform.http.HttpRequestResult;
/** /**
@ -38,6 +48,8 @@ public class CouponValidateServiceImpl implements CouponValidateService {
@Resource @Resource
private CustomerMembershipMapper customerMembershipMapper; private CustomerMembershipMapper customerMembershipMapper;
@Resource
private ClientManager clientManager;
@Override @Override
public JSONObject getCoupon(JSONObject partner,int page,int limit) { public JSONObject getCoupon(JSONObject partner,int page,int limit) {
@ -145,4 +157,66 @@ public class CouponValidateServiceImpl implements CouponValidateService {
object.put("managers",customerMembershipMapper.listPaymentManagerByCus()); object.put("managers",customerMembershipMapper.listPaymentManagerByCus());
return object; return object;
} }
@Override
public JSONObject ctripCheck(int client_id) {
JSONObject client = clientManager.getClientInfo(client_id);
if(client==null){
throw new NotFoundException("Merchant Not Found");
}
String uri = signUrl(UriComponentsBuilder.fromHttpUrl(CUSTOMER_HOST + "coupon/"+client.getString("client_moniker")+"/enableCtrip"));
HttpRequestGenerator gen = new HttpRequestGenerator(uri, RequestMethod.GET);
try {
HttpRequestResult reqResult = gen.execute();
if (reqResult.isSuccess()) {
return reqResult.getResponseContentJSONObj();
}
} catch (Exception ignored) {
}
return null;
}
@Override
public JSONObject ctripCouponInfo(String coupon_id, int client_id) {
JSONObject client = clientManager.getClientInfo(client_id);
if(client==null){
throw new NotFoundException("Merchant Not Found");
}
String uri = signUrl(UriComponentsBuilder.fromHttpUrl(CUSTOMER_HOST + "/coupon/"+coupon_id+"/couponLogInfo"));
HttpRequestGenerator gen = new HttpRequestGenerator(uri, RequestMethod.POST);
gen.addQueryString("client_moniker",client.getString("client_moniker"));
try {
HttpRequestResult reqResult = gen.execute();
if (reqResult.isSuccess()) {
return reqResult.getResponseContentJSONObj();
}
} catch (Exception ignored) {
}
return null;
}
@Override
public JSONObject ctripCouponLogNotice(String coupon_id, String order_id, String open_id) {
String uri = signUrl(UriComponentsBuilder.fromHttpUrl(CUSTOMER_HOST + "coupon/"+coupon_id+"/addCtripCouponLog"));
HttpRequestGenerator gen = new HttpRequestGenerator(uri, RequestMethod.POST);
List<NameValuePair> params = new ArrayList<>();
params.add(new BasicNameValuePair("order_id", order_id));
params.add(new BasicNameValuePair("openid", open_id));
gen.setFormStringEntity(params);
try {
HttpRequestResult reqResult = gen.execute();
if (reqResult.isSuccess()) {
return reqResult.getResponseContentJSONObj();
}
} catch (Exception ignored) {
}
return null;
}
private String signUrl(UriComponentsBuilder uriComponentsBuilder) {
String timestamp = System.currentTimeMillis() + "";
String base = CUSTOMER_APP_ID + timestamp + CUSTOMER_AUTH_CODE;
String sign = DigestUtils.sha256Hex(base).toLowerCase();
return uriComponentsBuilder.queryParam("appid", CUSTOMER_APP_ID).queryParam("timestamp", timestamp).queryParam("sign", sign).toUriString();
}
} }

@ -1,11 +1,15 @@
package au.com.royalpay.payment.manage.mappers.log; package au.com.royalpay.payment.manage.mappers.log;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.alibaba.fastjson.JSONObject;
import cn.yixblog.support.mybatis.autosql.annotations.AdvanceSelect; import cn.yixblog.support.mybatis.autosql.annotations.AdvanceSelect;
import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper; import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql; import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType; import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.annotations.Param;
@AutoMapper(tablename = "cus_coupon_accuess_log", pkName = "accuess_id") @AutoMapper(tablename = "cus_coupon_accuess_log", pkName = "accuess_id")
public interface CouponAccuessLogMapper { public interface CouponAccuessLogMapper {
@ -19,4 +23,7 @@ public interface CouponAccuessLogMapper {
@AutoSql(type = SqlType.SELECT) @AutoSql(type = SqlType.SELECT)
@AdvanceSelect(addonWhereClause = "is_valid = 1") @AdvanceSelect(addonWhereClause = "is_valid = 1")
JSONObject findUsedCouponByOrderId(@Param("order_id") String order_id); JSONObject findUsedCouponByOrderId(@Param("order_id") String order_id);
@AutoSql(type = SqlType.SELECT)
List<JSONObject> findCouponByOrderId(@Param("order_id") String order_id);
} }

Loading…
Cancel
Save