add listen customerPaymentInfo

master
luoyang 6 years ago
parent 0c0f9f19df
commit 0a1327d926

@ -2,6 +2,8 @@ package au.com.royalpay.payment.manage.apps.events.listeners;
import au.com.royalpay.payment.core.events.AfterPaymentFinishEvent;
import au.com.royalpay.payment.manage.mappers.system.SysCustomerPaymentInfoMapper;
import au.com.royalpay.payment.tools.utils.id.IdUtil;
import com.alibaba.fastjson.JSONObject;
import org.springframework.context.ApplicationListener;
@ -18,11 +20,32 @@ import javax.annotation.Resource;
public class AfterPaymentFinishListener implements ApplicationListener<AfterPaymentFinishEvent> {
@Resource
private StringRedisTemplate stringRedisTemplate;
@Resource
private SysCustomerPaymentInfoMapper sysCustomerPaymentInfoMapper;
@Override
public void onApplicationEvent(AfterPaymentFinishEvent event) {
JSONObject order = event.getFinishedEvent().getOrder();
JSONObject lastOrderInfo = new JSONObject();
BoundListOperations<String, String> ops = stringRedisTemplate.boundListOps("customer_impression");
ops.rightPush(order.toJSONString());
lastOrderInfo.put("wechat_openid", order.getString("customer_id"));
lastOrderInfo.put("idcard_name", order.getString("payer_name"));
lastOrderInfo.put("idcard_no", order.getString("payer_identity_card"));
lastOrderInfo.put("bankcard", order.getString("card_number"));
lastOrderInfo.put("bank", order.getString("bankId"));
JSONObject orderInfo = sysCustomerPaymentInfoMapper.selectPaymentInfo(order.getString("customer_id"));
if (orderInfo != null) {
lastOrderInfo.put("id", orderInfo.getString("id"));
sysCustomerPaymentInfoMapper.update(lastOrderInfo);
}else {
lastOrderInfo.put("id", IdUtil.getId());
sysCustomerPaymentInfoMapper.save(lastOrderInfo);
}
}
}

@ -3,6 +3,7 @@ package au.com.royalpay.payment.manage.customers.core.impls;
import au.com.royalpay.payment.manage.customers.core.CustomerPaymentInfoService;
import au.com.royalpay.payment.manage.mappers.system.SysCustomerPaymentInfoMapper;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.utils.id.IdUtil;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Service;
@ -18,6 +19,8 @@ public class CustomerPaymentInfoImpl implements CustomerPaymentInfoService {
if (sysCustomerPaymentInfoMapper.selectPaymentInfo(paymentInfo.getString("wechat_openid")) != null) {
throw new BadRequestException("openid already exists");
}
paymentInfo.put("id", IdUtil.getId());
sysCustomerPaymentInfoMapper.save(paymentInfo);
}

Loading…
Cancel
Save