Authored by chenchao

optimized

package com.yohoufo.order.service;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import com.yohoufo.common.alarm.EventBusPublisher;
import com.yohoufo.order.common.EnterQuitEnum;
import com.yohoufo.order.event.InviteRecordEvent;
import com.yohoufo.order.service.impl.TradeBillsService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yoho.core.common.utils.DateUtil;
... ... @@ -31,31 +12,33 @@ import com.yohobuy.ufo.model.order.bo.OrderInfo;
import com.yohobuy.ufo.model.order.common.EntrySellerType;
import com.yohobuy.ufo.model.order.common.OrderCodeType;
import com.yohobuy.ufo.model.order.common.OrderStatus;
import com.yohobuy.ufo.model.order.common.Payment;
import com.yohobuy.ufo.model.order.resp.EntryThreshold;
import com.yohobuy.ufo.model.order.resp.PageResp;
import com.yohobuy.ufo.model.user.resp.AuthorizeResultRespVO;
import com.yohoufo.common.alarm.CommonAlarmEventPublisher;
import com.yohoufo.common.alarm.EventBusPublisher;
import com.yohoufo.common.caller.UfoServiceCaller;
import com.yohoufo.common.utils.TimeUtils;
import com.yohoufo.dal.order.EntrySellerRechargeOrderMapper;
import com.yohoufo.dal.order.OrdersPayMapper;
import com.yohoufo.dal.order.OrdersPayRefundMapper;
import com.yohoufo.dal.order.SellerJoinHistoryMapper;
import com.yohoufo.dal.order.SellerWalletDetailMapper;
import com.yohoufo.dal.order.SellerWalletMapper;
import com.yohoufo.dal.order.model.EntrySellerRechargeOrder;
import com.yohoufo.dal.order.model.OrdersPay;
import com.yohoufo.dal.order.model.OrdersPayRefund;
import com.yohoufo.dal.order.model.SellerJoinHistory;
import com.yohoufo.dal.order.model.SellerWallet;
import com.yohoufo.dal.order.model.SellerWalletDetail;
import com.yohoufo.dal.order.model.StoredSeller;
import com.yohoufo.dal.order.*;
import com.yohoufo.dal.order.model.*;
import com.yohoufo.dal.user.model.ZhiMaCert;
import com.yohobuy.ufo.model.order.common.Payment;
import com.yohoufo.order.common.EnterQuitEnum;
import com.yohoufo.order.event.InviteRecordEvent;
import com.yohoufo.order.model.request.PaymentRequest;
import com.yohoufo.order.model.response.PrepayResponse;
import com.yohoufo.order.service.impl.PaymentServiceImpl;
import com.yohoufo.order.service.impl.SellerService;
import com.yohoufo.order.service.impl.TradeBillsService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
@Service
public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
... ... @@ -139,28 +122,11 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
return result;
}
@Override
public void processAfterPay(OrderInfo orderInfo) {
logger.info("充值后回调,处理processAfterPay,orderInfo={}", orderInfo);
private void processFirstTimeCharge(SellerWallet sw, OrderInfo orderInfo){
Long orderCode = orderInfo.getOrderCode();
BigDecimal amount = orderInfo.getAmount();
Integer payment = orderInfo.getPayment();
tradeBillsService.addPayRechargeEnsureRecord(orderInfo.getUid(), orderInfo.getSkup(), orderCode, payment,
orderInfo.getAmount());
BigDecimal beforeAmount = BigDecimal.ZERO;
BigDecimal beforeLockAmount = BigDecimal.ZERO;
BigDecimal afterAmount = BigDecimal.ZERO;
BigDecimal afterLockAmount = BigDecimal.ZERO;
Integer uid = orderInfo.getUid();
SellerWallet sw = sellerWalletMapper.selectByUidAndType(uid, 1);
logger.info("充值后回调,处理总账表,orderCode={}", orderCode);
if (orderInfo.getType() == TYPE_FIRST_RECHARGE) {
ZhiMaCert cert = null;
try {
ApiResponse<?> resp = ufoServiceCaller.call("ufo.user.zhiMaCertInfo", ApiResponse.class, uid);
... ... @@ -231,8 +197,31 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
EventBusPublisher.publishEvent(inviteRecordEvent);
}
addJoinHistory(uid, certNo);
afterAmount = amount;
}
@Override
public void processAfterPay(OrderInfo orderInfo) {
logger.info("充值后回调,处理processAfterPay,orderInfo={}", orderInfo);
Long orderCode = orderInfo.getOrderCode();
BigDecimal amount = orderInfo.getAmount();
Integer payment = orderInfo.getPayment();
tradeBillsService.addPayRechargeEnsureRecord(orderInfo.getUid(), orderInfo.getSkup(), orderCode, payment,
orderInfo.getAmount());
BigDecimal beforeAmount = BigDecimal.ZERO;
BigDecimal beforeLockAmount = BigDecimal.ZERO;
BigDecimal afterAmount = BigDecimal.ZERO;
BigDecimal afterLockAmount = BigDecimal.ZERO;
Integer uid = orderInfo.getUid();
SellerWallet sw = sellerWalletMapper.selectByUidAndType(uid, 1);
logger.info("充值后回调,处理总账表,orderCode={}", orderCode);
if (orderInfo.getType() == TYPE_FIRST_RECHARGE) {
processFirstTimeCharge(sw, orderInfo);
afterAmount = amount;
} else {
// 修改钱包余额
if (sw == null) {
... ... @@ -1040,7 +1029,7 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
newRecord.setStatus((byte) 0);
newRecord.setSerialNo(Integer.toString(swd.getId()));
newRecord.setOrderType(0);
int timeStamp = (int) (new Date().getTime() / 1000);
int timeStamp = DateUtil.currentTimeSeconds();
newRecord.setCreateTime(timeStamp);
newRecord.setUpdateTime(timeStamp);
logger.info("商品下架,添加退款记录,bean={}", newRecord);
... ...