diff --git a/src/main/java/au/com/royalpay/payment/manage/apps/events/listeners/AfterPaymentFinishListener.java b/src/main/java/au/com/royalpay/payment/manage/apps/events/listeners/AfterPaymentFinishListener.java index 36369dca4..1d498a083 100644 --- a/src/main/java/au/com/royalpay/payment/manage/apps/events/listeners/AfterPaymentFinishListener.java +++ b/src/main/java/au/com/royalpay/payment/manage/apps/events/listeners/AfterPaymentFinishListener.java @@ -1,14 +1,13 @@ package au.com.royalpay.payment.manage.apps.events.listeners; import au.com.royalpay.payment.core.events.AfterPaymentFinishEvent; - +import au.com.royalpay.payment.manage.customers.core.CustomerPaymentInfoService; 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.apache.commons.lang3.StringUtils; import org.springframework.context.ApplicationListener; -import org.springframework.data.redis.core.BoundListOperations; -import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -18,33 +17,36 @@ import javax.annotation.Resource; */ @Service public class AfterPaymentFinishListener implements ApplicationListener { - @Resource - private StringRedisTemplate stringRedisTemplate; @Resource private SysCustomerPaymentInfoMapper sysCustomerPaymentInfoMapper; + @Resource + private CustomerPaymentInfoService customerPaymentInfoService; @Override public void onApplicationEvent(AfterPaymentFinishEvent event) { JSONObject order = event.getFinishedEvent().getOrder(); - JSONObject lastOrderInfo = new JSONObject(); - - BoundListOperations 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")); - + if(!"hf".equals(order.getString("channel"))){ + return; + } + if(StringUtils.isEmpty(order.getString("ext_params"))){ + return; + } + JSONObject extParam = JSONObject.parseObject(order.getString("ext_params")); JSONObject orderInfo = sysCustomerPaymentInfoMapper.selectPaymentInfo(order.getString("customer_id")); - if (orderInfo != null) { - lastOrderInfo.put("id", orderInfo.getString("id")); - sysCustomerPaymentInfoMapper.update(lastOrderInfo); + orderInfo.put("idcard_name", extParam.getString("payer_name")); + orderInfo.put("idcard_no", extParam.getString("payer_identity_card")); + orderInfo.put("bankcard", extParam.getString("card_number")); + orderInfo.put("bank", extParam.getString("bankId")); + sysCustomerPaymentInfoMapper.update(orderInfo); }else { - lastOrderInfo.put("id", IdUtil.getId()); - sysCustomerPaymentInfoMapper.save(lastOrderInfo); + JSONObject lastOrderInfo = new JSONObject(); + lastOrderInfo.put("wechat_openid", extParam.getString("customer_id")); + lastOrderInfo.put("idcard_name", extParam.getString("payer_name")); + lastOrderInfo.put("idcard_no", extParam.getString("payer_identity_card")); + lastOrderInfo.put("bankcard", extParam.getString("card_number")); + lastOrderInfo.put("bank", extParam.getString("bankId")); + customerPaymentInfoService.save(lastOrderInfo); } } diff --git a/src/main/java/au/com/royalpay/payment/manage/customers/core/CustomerPaymentInfoService.java b/src/main/java/au/com/royalpay/payment/manage/customers/core/CustomerPaymentInfoService.java index 9b5c24b0d..ed472ea8c 100644 --- a/src/main/java/au/com/royalpay/payment/manage/customers/core/CustomerPaymentInfoService.java +++ b/src/main/java/au/com/royalpay/payment/manage/customers/core/CustomerPaymentInfoService.java @@ -4,9 +4,9 @@ import com.alibaba.fastjson.JSONObject; public interface CustomerPaymentInfoService { - void saveCustomerPaymentInfo(JSONObject paymentInfo); + void save(JSONObject paymentInfo); - void updateCustomerPaymentInfo(JSONObject paymentInfo); + void update(JSONObject paymentInfo); JSONObject selectPaymentInfoByOpenId(String open_id); } diff --git a/src/main/java/au/com/royalpay/payment/manage/customers/core/impls/CustomerPaymentInfoImpl.java b/src/main/java/au/com/royalpay/payment/manage/customers/core/impls/CustomerPaymentInfoImpl.java index 22037a1d6..6e40b71a0 100644 --- a/src/main/java/au/com/royalpay/payment/manage/customers/core/impls/CustomerPaymentInfoImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/customers/core/impls/CustomerPaymentInfoImpl.java @@ -15,7 +15,7 @@ public class CustomerPaymentInfoImpl implements CustomerPaymentInfoService { private SysCustomerPaymentInfoMapper sysCustomerPaymentInfoMapper; @Override - public void saveCustomerPaymentInfo(JSONObject paymentInfo) { + public void save(JSONObject paymentInfo) { if (sysCustomerPaymentInfoMapper.selectPaymentInfo(paymentInfo.getString("wechat_openid")) != null) { throw new BadRequestException("openid already exists"); } @@ -25,7 +25,7 @@ public class CustomerPaymentInfoImpl implements CustomerPaymentInfoService { } @Override - public void updateCustomerPaymentInfo(JSONObject paymentInfo) { + public void update(JSONObject paymentInfo) { if (paymentInfo.getString("id") == null) { throw new BadRequestException("ID is empty"); } diff --git a/src/main/java/au/com/royalpay/payment/manage/customers/web/CustomerPaymentInfoController.java b/src/main/java/au/com/royalpay/payment/manage/customers/web/CustomerPaymentInfoController.java index f8eb0acc1..a401def85 100644 --- a/src/main/java/au/com/royalpay/payment/manage/customers/web/CustomerPaymentInfoController.java +++ b/src/main/java/au/com/royalpay/payment/manage/customers/web/CustomerPaymentInfoController.java @@ -15,12 +15,12 @@ public class CustomerPaymentInfoController { @RequestMapping(value = "/update", method = RequestMethod.POST) public void savePaymentInfo(@RequestBody JSONObject paymentInfo) { - customerPaymentInfoService.saveCustomerPaymentInfo(paymentInfo); + customerPaymentInfoService.save(paymentInfo); } @RequestMapping(value = "/update", method = RequestMethod.PUT) public void updatePaymentInfo(@RequestBody JSONObject paymentInfo) { - customerPaymentInfoService.updateCustomerPaymentInfo(paymentInfo); + customerPaymentInfoService.update(paymentInfo); } @RequestMapping(value = "/{openid}/check", method = RequestMethod.GET)