master
eason 6 years ago
parent a59789984e
commit 1f188598a6

@ -7,6 +7,10 @@ import java.util.List;
import javax.annotation.Resource;
import au.com.royalpay.payment.channels.wechat.config.WeChatPayConfig;
import au.com.royalpay.payment.channels.wechat.config.WechatPayEnvironment;
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApi;
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApiProvider;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.time.DateFormatUtils;
@ -57,6 +61,8 @@ public class EncourageUseProcessor implements Ordered, EncourageService {
@Resource
private TransactionService transactionService;
@Resource
private MpWechatApiProvider mpWechatApiProvider;
@Resource
private CustomerMapper customerMapper;
@Resource
private ManagerMapper managerMapper;
@ -94,9 +100,15 @@ public class EncourageUseProcessor implements Ordered, EncourageService {
logger.debug("不在有效期");
return new JSONObject();
}
if (!StringUtils.equals(openId, visitorOpenId)) {
logger.debug("不是同一人");
return new JSONObject();
if ("Wechat".equals(order.getString("channel"))) {
JSONObject wxUser = customerMapper.findCustomerByOpenId(visitorOpenId);
String merchantId = order.getString("merchant_id");
WeChatPayConfig.Merchant mch = WechatPayEnvironment.getEnv().getMerchantConfig(merchantId);
MpWechatApi api = mpWechatApiProvider.getApi(mch.getMpId());
if (!StringUtils.equals(wxUser.getString(api.getOpenIdKey()),openId)){
logger.debug("不是同一人");
return new JSONObject();
}
}
if (config.getBooleanValue("debug_mode") && !checkIsDeveloper(openId)) {
logger.debug("测试模式,不是管理员");
@ -105,7 +117,7 @@ public class EncourageUseProcessor implements Ordered, EncourageService {
JSONObject member = customerMembershipMapper.findByPaymentOpenId(openId);
if (member == null) {
member = new JSONObject();
JSONObject relation = customerMapper.findCustomerByOpenId(openId);
JSONObject relation = customerMapper.findCustomerByOpenId(visitorOpenId);
if (relation == null) {
logger.debug("用户关系不存在");
return new JSONObject();

Loading…
Cancel
Save