master
eason 6 years ago
parent 1f188598a6
commit e7f96bcabb

@ -9,6 +9,7 @@ import javax.annotation.Resource;
import au.com.royalpay.payment.channels.wechat.config.WeChatPayConfig; import au.com.royalpay.payment.channels.wechat.config.WeChatPayConfig;
import au.com.royalpay.payment.channels.wechat.config.WechatPayEnvironment; import au.com.royalpay.payment.channels.wechat.config.WechatPayEnvironment;
import au.com.royalpay.payment.manage.mappers.system.ManagerCustomerRelationAlipayMapper;
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApi; import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApi;
import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApiProvider; import au.com.royalpay.payment.tools.connections.mpsupport.MpWechatApiProvider;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -68,6 +69,8 @@ public class EncourageUseProcessor implements Ordered, EncourageService {
private ManagerMapper managerMapper; private ManagerMapper managerMapper;
@Resource @Resource
private OrderMapper orderMapper; private OrderMapper orderMapper;
@Resource
private ManagerCustomerRelationAlipayMapper managerCustomerRelationAlipayMapper;
@Override @Override
public int getOrder() { public int getOrder() {
@ -100,7 +103,13 @@ public class EncourageUseProcessor implements Ordered, EncourageService {
logger.debug("不在有效期"); logger.debug("不在有效期");
return new JSONObject(); return new JSONObject();
} }
if ("Wechat".equals(order.getString("channel"))) { String channel = order.getString("channel");
if ("Wechat".equals(channel)) {
JSONObject relation = customerMapper.findCustomerByOpenId(visitorOpenId);
if (relation == null) {
logger.debug("用户关系不存在");
return new JSONObject();
}
JSONObject wxUser = customerMapper.findCustomerByOpenId(visitorOpenId); JSONObject wxUser = customerMapper.findCustomerByOpenId(visitorOpenId);
String merchantId = order.getString("merchant_id"); String merchantId = order.getString("merchant_id");
WeChatPayConfig.Merchant mch = WechatPayEnvironment.getEnv().getMerchantConfig(merchantId); WeChatPayConfig.Merchant mch = WechatPayEnvironment.getEnv().getMerchantConfig(merchantId);
@ -110,25 +119,48 @@ public class EncourageUseProcessor implements Ordered, EncourageService {
return new JSONObject(); return new JSONObject();
} }
} }
if (config.getBooleanValue("debug_mode") && !checkIsDeveloper(openId)) { if ("Alipay".equals(channel)){
if (!StringUtils.equals(visitorOpenId,openId)){
logger.debug("不是同一人");
return new JSONObject();
}
}
if (config.getBooleanValue("debug_mode") && !checkIsDeveloper(visitorOpenId)) {
logger.debug("测试模式,不是管理员"); logger.debug("测试模式,不是管理员");
return new JSONObject(); return new JSONObject();
} }
JSONObject member = customerMembershipMapper.findByPaymentOpenId(openId); JSONObject member = customerMembershipMapper.findByPaymentOpenId(openId);
if (member == null) { if (member == null) {
member = new JSONObject(); member = new JSONObject();
JSONObject relation = customerMapper.findCustomerByOpenId(visitorOpenId); if ("Wechat".equals(channel)){
if (relation == null) { JSONObject relation = customerMapper.findCustomerByOpenId(visitorOpenId);
logger.debug("用户关系不存在"); if (relation == null) {
return new JSONObject(); logger.debug("用户关系不存在");
return new JSONObject();
}
member.put("payment_openid", openId);
member.put("kanga_openid", relation.getString("kanga_openid"));
member.put("redpack_openid", relation.getString("redpack_openid"));
member.put("attend_time", new Date());
member.put("member_point", -1);
member.put("encourage_balance", 0);
customerMembershipMapper.saveMember(member);
} }
member.put("payment_openid", openId); if ("Alipay".equals(channel)){
member.put("kanga_openid", relation.getString("kanga_openid")); JSONObject relation = managerCustomerRelationAlipayMapper.findCustomerByUserId(openId);
member.put("redpack_openid", relation.getString("redpack_openid")); if (relation == null) {
member.put("attend_time", new Date()); logger.debug("用户关系不存在");
member.put("member_point", -1); return new JSONObject();
member.put("encourage_balance", 0); }
customerMembershipMapper.saveMember(member); member.put("payment_openid", openId);
member.put("kanga_openid", openId.concat("-kanga_openid"));
member.put("redpack_openid", openId.concat("-redpack_openid"));
member.put("attend_time", new Date());
member.put("member_point", -1);
member.put("encourage_balance", 0);
customerMembershipMapper.saveMember(member);
}
} }
String memberId = member.getString("member_id"); String memberId = member.getString("member_id");
int usedOrders = customerEncourageMoneyAccessLogMapper.countOrders(memberId, new Date()); int usedOrders = customerEncourageMoneyAccessLogMapper.countOrders(memberId, new Date());

Loading…
Cancel
Save