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.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.MpWechatApiProvider;
import org.apache.commons.lang3.StringUtils;
@ -68,6 +69,8 @@ public class EncourageUseProcessor implements Ordered, EncourageService {
private ManagerMapper managerMapper;
@Resource
private OrderMapper orderMapper;
@Resource
private ManagerCustomerRelationAlipayMapper managerCustomerRelationAlipayMapper;
@Override
public int getOrder() {
@ -100,7 +103,13 @@ public class EncourageUseProcessor implements Ordered, EncourageService {
logger.debug("不在有效期");
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);
String merchantId = order.getString("merchant_id");
WeChatPayConfig.Merchant mch = WechatPayEnvironment.getEnv().getMerchantConfig(merchantId);
@ -110,25 +119,48 @@ public class EncourageUseProcessor implements Ordered, EncourageService {
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("测试模式,不是管理员");
return new JSONObject();
}
JSONObject member = customerMembershipMapper.findByPaymentOpenId(openId);
if (member == null) {
member = new JSONObject();
JSONObject relation = customerMapper.findCustomerByOpenId(visitorOpenId);
if (relation == null) {
logger.debug("用户关系不存在");
return new JSONObject();
if ("Wechat".equals(channel)){
JSONObject relation = customerMapper.findCustomerByOpenId(visitorOpenId);
if (relation == null) {
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);
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);
if ("Alipay".equals(channel)){
JSONObject relation = managerCustomerRelationAlipayMapper.findCustomerByUserId(openId);
if (relation == null) {
logger.debug("用户关系不存在");
return new JSONObject();
}
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");
int usedOrders = customerEncourageMoneyAccessLogMapper.countOrders(memberId, new Date());

Loading…
Cancel
Save