Authored by Lixiaodi

提交商家充值,增加日志

... ... @@ -302,4 +302,12 @@ public class OrdersPay {
public void setAttach(String attach) {
this.attach = attach;
}
@Override
public String toString() {
return "OrdersPay [id=" + id + ", orderCode=" + orderCode + ", uid=" + uid + ", payment=" + payment
+ ", amount=" + amount + ", payOrderCode=" + payOrderCode + ", payLevel=" + payLevel + ", serialNo="
+ serialNo + ", createTime=" + createTime + ", attach=" + attach + "]";
}
}
\ No newline at end of file
... ...
... ... @@ -72,4 +72,11 @@ public class SellerWallet {
public void setUpdateTime(Integer updateTime) {
this.updateTime = updateTime;
}
@Override
public String toString() {
return "SellerWallet [id=" + id + ", uid=" + uid + ", amount=" + amount + ", status=" + status + ", type="
+ type + ", createTime=" + createTime + ", updateTime=" + updateTime + "]";
}
}
\ No newline at end of file
... ...
... ... @@ -82,4 +82,12 @@ public class SellerWalletDetail {
public void setUpdateTime(Integer updateTime) {
this.updateTime = updateTime;
}
@Override
public String toString() {
return "SellerWalletDetail [id=" + id + ", walletId=" + walletId + ", uid=" + uid + ", orderCode=" + orderCode
+ ", amount=" + amount + ", type=" + type + ", createTime=" + createTime + ", updateTime=" + updateTime
+ "]";
}
}
\ No newline at end of file
... ...
... ... @@ -13,11 +13,14 @@ import com.alibaba.fastjson.JSONObject;
import com.yoho.core.common.utils.DateUtil;
import com.yoho.error.ServiceError;
import com.yoho.error.exception.ServiceException;
import com.yoho.tools.common.beans.ApiResponse;
import com.yohobuy.ufo.model.order.bo.OrderInfo;
import com.yohobuy.ufo.model.order.common.OrderCodeType;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.common.TabType;
import com.yohobuy.ufo.model.user.resp.AuthorizeResultRespVO;
import com.yohoufo.common.alarm.CommonAlarmEventPublisher;
import com.yohoufo.common.caller.UfoServiceCaller;
import com.yohoufo.common.utils.TimeUtils;
import com.yohoufo.dal.order.EntrySellerRechargeOrderMapper;
import com.yohoufo.dal.order.OrdersPayMapper;
... ... @@ -53,6 +56,9 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
@Autowired
private CacheCleaner cacheCleaner;
@Autowired
UfoServiceCaller ufoServiceCaller;
/**
* 更新订单状态
... ... @@ -70,12 +76,22 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
@Override
public void processAfterPay(OrderInfo orderInfo) {
logger.info("充值后回调,处理processAfterPay,orderInfo={}", orderInfo);
// 首次充值,调用认证成功接口
if (orderInfo.getType() == TYPE_FIRST_RECHARGE) {
// TODO
try {
logger.info("首次充值后回调,调用商家入驻接口,uid={}", orderInfo.getUid());
ufoServiceCaller.call("ufo.user.addUserAsStoredSeller", ApiResponse.class, orderInfo.getUid());
} catch (Exception e) {
logger.error("首次充值后回调,商家入驻接口失败,uid={}", orderInfo.getUid());
CommonAlarmEventPublisher.publish("商家入驻失败", "ufo.user.addUserAsStoredSeller", "首次充值后回调,商家入驻接口失败:uid=" + orderInfo.getUid() + ",充值订单号为:" + orderInfo.getOrderCode());
return;
}
}
BigDecimal amount = orderInfo.getAmount();
SellerWallet sw = sellerWalletMapper.selectByUidAndType(orderInfo.getUid(), 1);
logger.info("充值后回调,处理总账表,orderCode={}", orderInfo.getOrderCode());
if (orderInfo.getType() == TYPE_FIRST_RECHARGE) {
if (sw != null) {
logger.error("首次充值保证金余额{},发现钱包已存在,uid={}", amount, orderInfo.getUid());
... ... @@ -90,7 +106,9 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
sw.setType(1);
sw.setCreateTime(TimeUtils.getTimeStampSecond());
sw.setUpdateTime(0);
logger.info("首次充值后回调,处理总账表新增账号,bean={}", sw);
sellerWalletMapper.insert(sw);
logger.info("首次充值后回调,处理总账表新增账号成功,bean={}", sw);
} else {
// 修改钱包余额
if (sw == null) {
... ... @@ -106,12 +124,14 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
sw.setAmount(orderInfo.getAmount());
sw.setUpdateTime(TimeUtils.getTimeStampSecond());
logger.info("后期充值,处理总账表增加余额,bean={}", sw);
if (sellerWalletMapper.addMoney(sw) == 0) {
logger.error("充值保证金余额{},更新表返回0,uid={}", amount, orderInfo.getUid());
CommonAlarmEventPublisher.publish("充值保证金余额失败", "ufo.order.recharge", "更新表返回0,uid=" + orderInfo.getUid() + ",充值订单号为:" + orderInfo.getOrderCode()+", 充值金额为:"+amount);
return;
}
}
logger.info("{}修改钱包表余额成功,orderCode={}", orderInfo.getOrderCode());
// 增加充值记录
SellerWalletDetail swd = new SellerWalletDetail();
... ... @@ -121,11 +141,14 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
swd.setWalletId(sw.getId());
swd.setAmount(orderInfo.getAmount());
swd.setCreateTime(TimeUtils.getTimeStampSecond());
logger.info("充值后,处理增加钱包明细,bean={}", swd);
sellerWalletDetailMapper.insert(swd);
logger.info("充值后,处理增加钱包明细成功,orderCode={}", orderInfo.getOrderCode());
logger.info("充值后,删除订单列表缓存,uid={}", orderInfo.getUid());
cacheCleaner.delete(Arrays.asList(
CacheKeyBuilder.orderListKey(orderInfo.getUid(), TabType.BUY.getValue()),
CacheKeyBuilder.orderDetailKey(orderInfo.getUid(), TabType.BUY.getValue(), orderInfo.getOrderCode())));
CacheKeyBuilder.orderListKey(orderInfo.getUid(), TabType.SELL.getValue()),
CacheKeyBuilder.orderDetailKey(orderInfo.getUid(), TabType.SELL.getValue(), orderInfo.getOrderCode())));
}
... ... @@ -295,7 +318,9 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
swd.setWalletId(sw.getId());
swd.setAmount(amount);
swd.setCreateTime(TimeUtils.getTimeStampSecond());
logger.info("支付保证金,钱包明细记录,bean={}", swd);
sellerWalletDetailMapper.insert(swd);
logger.info("支付保证金,钱包明细记录成功,bean={}", swd);
}
// 退还保证金
... ... @@ -307,11 +332,15 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
swd.setWalletId(sw.getId());
swd.setAmount(amount);
swd.setCreateTime(TimeUtils.getTimeStampSecond());
logger.info("退还保证金,钱包明细记录,bean={}", swd);
sellerWalletDetailMapper.insert(swd);
logger.info("退还保证金,钱包明细记录成功,bean={}", swd);
}
// 退出入驻:归还所有保证金 总账+明细
public BigDecimal returnEarnest(Integer uid, long orderCode) {
logger.info("商家退出,退还保证金,钱包归零处理开始,uid={},orderCode={}", uid, orderCode);
SellerWallet sw = sellerWalletMapper.selectByUidAndType(uid, 1);
if (sw == null) {
... ... @@ -320,6 +349,7 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
return null;
}
BigDecimal amount = sw.getAmount();
logger.info("商家退出,退还保证金,钱包归零处理,钱包信息={}", sw);
if (sw.getStatus() == null || sw.getStatus() == 0) {
logger.error("退还所有保证金{},钱包不可用,uid={}", amount, uid);
... ... @@ -327,14 +357,13 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
return null;
}
sw.setAmount(amount);
sw.setUpdateTime(TimeUtils.getTimeStampSecond());
if (sellerWalletMapper.returnMoney(sw) == 0) {
logger.error("退还所有证金失败,更新表返回0,uid={}", uid);
CommonAlarmEventPublisher.publish("退还所有保证金失败", "ufo.order.recharge", "更新表返回0,uid=" + uid + ", 退还金额为:"+ amount);
return null;
}
logger.info("商家退出,退还保证金,钱包归零处理,余额扣除成功,钱包信息={}", sw);
// 增加充值记录
SellerWalletDetail swd = new SellerWalletDetail();
swd.setOrderCode(orderCode);
... ... @@ -343,12 +372,14 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
swd.setWalletId(sw.getId());
swd.setAmount(amount);
swd.setCreateTime(TimeUtils.getTimeStampSecond());
logger.info("商家退出,退还保证金,钱包归零处理,增加扣减明细,bean={}", swd);
sellerWalletDetailMapper.insert(swd);
return amount;
}
private SellerWallet changeEarnest(Integer uid, BigDecimal money, String message) {
logger.info("{}修改钱包表入口,uid={},money={}", message, uid, money);
// 使用钱包余额,支付保证金
SellerWallet sw = sellerWalletMapper.selectByUidAndType(uid, 1);
... ... @@ -370,11 +401,13 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
sw.setAmount(money.multiply(new BigDecimal("-1")));
sw.setUpdateTime(TimeUtils.getTimeStampSecond());
logger.info("{}修改钱包表余额,bean={}", sw);
if (sellerWalletMapper.addMoney(sw) == 0) {
logger.error(message + "失败,(并发)更新表返回0,uid={}", uid);
CommonAlarmEventPublisher.publish(message + "失败", "ufo.order.recharge", "(并发)更新表返回0,uid=" + uid + ", 金额为:"+ money);
return null;
}
logger.info("{}修改钱包表余额成功,bean={}", sw);
return sw;
}
... ... @@ -392,20 +425,26 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
JSONObject attach = new JSONObject();
attach.put("order_type", OrderCodeType.SELLER_TYPE.getType());
ordersPay.setAttach(attach.toJSONString());
logger.info("增加支付记录orders_pay,bean={}", ordersPay);
ordersPayDao.insertSelective(ordersPay);
logger.info("增加支付记录orders_pay成功,orderCode={}", swd.getOrderCode());
}
public void changePriceUpdateOrdersPay(SellerWalletDetail swd) {
public int changePriceUpdateOrdersPay(SellerWalletDetail swd) {
// 增加支付记录
OrdersPay ordersPay = new OrdersPay();
ordersPay.setOrderCode(swd.getOrderCode());
ordersPay.setUid(swd.getUid());
ordersPay.setAmount(swd.getAmount());
String message = "修改保证金order_pay记录金额";
if (ordersPayDao.addMoney(ordersPay) == 0) {
logger.info("商家修改价格,修改支付记录金额orders_pay,bean={}", ordersPay);
int result;
if ((result = ordersPayDao.addMoney(ordersPay)) == 0) {
logger.error(message + "{}失败,修改DB返回记录数为0,orderCode={}", swd.getAmount(), swd.getOrderCode());
CommonAlarmEventPublisher.publish(message + "失败", "ufo.order.changePriceOrdersPay", "修改DB返回记录数为0,orderCode=" + swd.getOrderCode()+", 金额为:"+swd.getAmount());
}
logger.info("商家修改价格,修改支付记录金额orders_pay成功,orderCode={}", swd.getOrderCode());
return result;
}
}
... ...