Commit 12775a91 authored by xuxin's avatar xuxin

修改userpayment中 paymentDate 的含义

parent f937d266
...@@ -15,7 +15,7 @@ public class UserPayment { ...@@ -15,7 +15,7 @@ public class UserPayment {
@Id @Id
private String id; private String id;
private String tradeNo = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date())+SmsUtils.createRandom(true, 4); private String tradeNo = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + SmsUtils.createRandom(true, 4);
private String username; private String username;
...@@ -23,6 +23,10 @@ public class UserPayment { ...@@ -23,6 +23,10 @@ public class UserPayment {
private boolean succeed; private boolean succeed;
/**
* 感觉这个时间记录的是订单创建时间不太合理
* 在业务中修改为 我们系统中记录的订单充值成功的时间
*/
private Date paymentDate = new Date(); private Date paymentDate = new Date();
private PaymentMethod paymentMethod; private PaymentMethod paymentMethod;
......
...@@ -3,8 +3,10 @@ package com.edgec.browserbackend.account.repository; ...@@ -3,8 +3,10 @@ package com.edgec.browserbackend.account.repository;
import com.edgec.browserbackend.account.domain.UserPayment; import com.edgec.browserbackend.account.domain.UserPayment;
import java.util.Date;
public interface UserPaymentRepositoryCustom { public interface UserPaymentRepositoryCustom {
boolean updatePaymentResult(UserPayment payment, boolean result); boolean updatePaymentResult(UserPayment payment, boolean result, Date paymentDate);
} }
...@@ -8,6 +8,8 @@ import org.springframework.data.mongodb.core.MongoTemplate; ...@@ -8,6 +8,8 @@ import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.BasicQuery; import org.springframework.data.mongodb.core.query.BasicQuery;
import org.springframework.data.mongodb.core.query.Update; import org.springframework.data.mongodb.core.query.Update;
import java.util.Date;
import static org.springframework.data.mongodb.core.query.Criteria.where; import static org.springframework.data.mongodb.core.query.Criteria.where;
public class UserPaymentRepositoryCustomImpl implements UserPaymentRepositoryCustom { public class UserPaymentRepositoryCustomImpl implements UserPaymentRepositoryCustom {
...@@ -16,18 +18,16 @@ public class UserPaymentRepositoryCustomImpl implements UserPaymentRepositoryCus ...@@ -16,18 +18,16 @@ public class UserPaymentRepositoryCustomImpl implements UserPaymentRepositoryCus
private MongoTemplate mongoTemplate; private MongoTemplate mongoTemplate;
@Override @Override
public boolean updatePaymentResult(UserPayment payment, boolean result) { public boolean updatePaymentResult(UserPayment payment, boolean result, Date paymentDate) {
Document doc = new Document(); Document doc = new Document();
BasicQuery basicQuery = new BasicQuery(doc); BasicQuery basicQuery = new BasicQuery(doc);
basicQuery.addCriteria(where("id").is(payment.getId()).and("succeed").is(!result)); basicQuery.addCriteria(where("id").is(payment.getId()).and("succeed").is(!result));
Update update = new Update(); Update update = new Update();
update.set("succeed", result); update.set("succeed", result);
update.set("paymentDate", paymentDate);
UpdateResult operation = mongoTemplate.updateFirst(basicQuery, update, UserPayment.class); UpdateResult operation = mongoTemplate.updateFirst(basicQuery, update, UserPayment.class);
if (operation.getModifiedCount() < 1) return operation.getModifiedCount() >= 1;
return false;
else
return true;
} }
} }
...@@ -556,7 +556,6 @@ public class PaymentServiceImpl implements PaymentService { ...@@ -556,7 +556,6 @@ public class PaymentServiceImpl implements PaymentService {
result.setBalance(Math.round(balance.getBalanced())); result.setBalance(Math.round(balance.getBalanced()));
} }
boolean isVpsClient = true; boolean isVpsClient = true;
WXPayConfig ourWxPayConfig = isVpsClient ? new FGLWxConfig() : new CloudamWxConfig(); WXPayConfig ourWxPayConfig = isVpsClient ? new FGLWxConfig() : new CloudamWxConfig();
WXPay wxPay = new WXPay(ourWxPayConfig); WXPay wxPay = new WXPay(ourWxPayConfig);
...@@ -576,8 +575,7 @@ public class PaymentServiceImpl implements PaymentService { ...@@ -576,8 +575,7 @@ public class PaymentServiceImpl implements PaymentService {
result.setStatus(respData.get("trade_state")); result.setStatus(respData.get("trade_state"));
if ("SUCCESS".equals(respData.get("trade_state"))) { if ("SUCCESS".equals(respData.get("trade_state"))) {
byTradeNo.setSucceed(true); byTradeNo.setSucceed(true);
boolean b = userPaymentRepository.updatePaymentResult(byTradeNo, true, new Date());
boolean b = userPaymentRepository.updatePaymentResult(byTradeNo, true);
if (b) { if (b) {
if (balance == null) { if (balance == null) {
...@@ -644,7 +642,7 @@ public class PaymentServiceImpl implements PaymentService { ...@@ -644,7 +642,7 @@ public class PaymentServiceImpl implements PaymentService {
if ("TRADE_SUCCESS".equals(response.getTradeStatus()) || "TRADE_FINISHED".equals(response.getTradeStatus())) { if ("TRADE_SUCCESS".equals(response.getTradeStatus()) || "TRADE_FINISHED".equals(response.getTradeStatus())) {
byTradeNo.setSucceed(true); byTradeNo.setSucceed(true);
boolean b = userPaymentRepository.updatePaymentResult(byTradeNo, true); boolean b = userPaymentRepository.updatePaymentResult(byTradeNo, true, new Date());
if (b) { if (b) {
...@@ -791,7 +789,7 @@ public class PaymentServiceImpl implements PaymentService { ...@@ -791,7 +789,7 @@ public class PaymentServiceImpl implements PaymentService {
private void dealPaySuccess(int chargeType, UserPaymentDto result, UserPayment byTradeNo, Account byName, UserBalance balance) { private void dealPaySuccess(int chargeType, UserPaymentDto result, UserPayment byTradeNo, Account byName, UserBalance balance) {
byTradeNo.setSucceed(true); byTradeNo.setSucceed(true);
// 2.1 更新 userPayment 的支付状态为成功 // 2.1 更新 userPayment 的支付状态为成功
boolean b = userPaymentRepository.updatePaymentResult(byTradeNo, true); boolean b = userPaymentRepository.updatePaymentResult(byTradeNo, true, new Date());
if (b) { if (b) {
log.info("订单 " + byTradeNo.getTradeNo() + " 的支付状态更新为成功"); log.info("订单 " + byTradeNo.getTradeNo() + " 的支付状态更新为成功");
// 2.2 获取充值优惠赠送 // 2.2 获取充值优惠赠送
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment