Commit 12775a91 authored by xuxin's avatar xuxin

修改userpayment中 paymentDate 的含义

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