|
|
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 org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yoho.core.common.utils.DateUtil;
|
|
|
import com.yoho.error.ServiceError;
|
...
|
...
|
@@ -9,26 +21,26 @@ 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.order.resp.PageResp;
|
|
|
import com.yohoufo.common.alarm.CommonAlarmEventPublisher;
|
|
|
import com.yohoufo.common.caller.UfoServiceCaller;
|
|
|
import com.yohoufo.common.utils.TimeUtils;
|
|
|
import com.yohoufo.dal.order.*;
|
|
|
import com.yohoufo.dal.order.model.*;
|
|
|
import com.yohoufo.dal.order.EntrySellerRechargeOrderMapper;
|
|
|
import com.yohoufo.dal.order.OrdersPayMapper;
|
|
|
import com.yohoufo.dal.order.OrdersPayRefundMapper;
|
|
|
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.SellerWallet;
|
|
|
import com.yohoufo.dal.order.model.SellerWalletDetail;
|
|
|
import com.yohoufo.order.common.Payment;
|
|
|
import com.yohoufo.order.model.request.PaymentRequest;
|
|
|
import com.yohoufo.order.model.response.PrepayResponse;
|
|
|
import com.yohoufo.order.service.cache.CacheCleaner;
|
|
|
import com.yohoufo.order.service.cache.CacheKeyBuilder;
|
|
|
import com.yohoufo.order.service.impl.PaymentServiceImpl;
|
|
|
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.util.Arrays;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
@Service
|
|
|
public class MerchantOrderPaymentService extends AbstractOrderPaymentService {
|
...
|
...
|
@@ -145,6 +157,9 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { |
|
|
swd.setType(SellerWalletDetail.Type.RE_CHARGE.getValue());
|
|
|
swd.setCreateTime(TimeUtils.getTimeStampSecond());
|
|
|
swd.setUpdateTime(0);
|
|
|
JSONObject att = new JSONObject();
|
|
|
att.put("payment", orderInfo.getPayment());
|
|
|
swd.setAttachValue(att.toJSONString());
|
|
|
logger.info("充值后,处理增加钱包明细,bean={}", swd);
|
|
|
sellerWalletDetailMapper.insert(swd);
|
|
|
logger.info("充值后,处理增加钱包明细成功,orderCode={}", orderInfo.getOrderCode());
|
...
|
...
|
@@ -295,6 +310,56 @@ public class MerchantOrderPaymentService extends AbstractOrderPaymentService { |
|
|
return buildOrderInfo(buyerOrder);
|
|
|
}
|
|
|
|
|
|
public com.yohoufo.common.ApiResponse getMerchantWalletInfo(Integer uid) {
|
|
|
SellerWallet sw = sellerWalletMapper.selectByUidAndType(uid, 1);
|
|
|
if (sw == null) {
|
|
|
return new com.yohoufo.common.ApiResponse(400, "钱包不存在", null);
|
|
|
}
|
|
|
if (sw.getStatus() == null || sw.getStatus() == 0) {
|
|
|
return new com.yohoufo.common.ApiResponse(400, "钱包不可用", null);
|
|
|
}
|
|
|
JSONObject result = new JSONObject();
|
|
|
result.put("all", sw.getAmount().add(sw.getLockAmount()));
|
|
|
result.put("used", sw.getLockAmount());
|
|
|
result.put("avail", sw.getAmount());
|
|
|
return new com.yohoufo.common.ApiResponse(200, "查询成功", result);
|
|
|
}
|
|
|
|
|
|
public com.yohoufo.common.ApiResponse getMerchantWalletDetailInfo(Integer uid, int page, int limit) {
|
|
|
SellerWallet sw = sellerWalletMapper.selectByUidAndType(uid, 1);
|
|
|
if (sw == null) {
|
|
|
return new com.yohoufo.common.ApiResponse(400, "钱包不存在", null);
|
|
|
}
|
|
|
if (sw.getStatus() == null || sw.getStatus() == 0) {
|
|
|
return new com.yohoufo.common.ApiResponse(400, "钱包不可用", null);
|
|
|
}
|
|
|
int count = sellerWalletDetailMapper.selectUserDetailCount(uid);
|
|
|
PageResp<JSONObject> pageResp = new PageResp<>();
|
|
|
pageResp.setPage(page);
|
|
|
pageResp.setPageSize(limit);
|
|
|
pageResp.setTotal(count);
|
|
|
pageResp.setPagetotal((int) Math.ceil(count * 1.0 / limit));
|
|
|
if (count == 0) {
|
|
|
pageResp.setData(new ArrayList<>());
|
|
|
return new com.yohoufo.common.ApiResponse(200, "查询成功", pageResp);
|
|
|
} else {
|
|
|
List<SellerWalletDetail> resultList = sellerWalletDetailMapper.selectUserDetailCount(uid,
|
|
|
(page - 1) * limit, count);
|
|
|
List<JSONObject> array = new ArrayList<>();
|
|
|
pageResp.setData(array);
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 HH:mm");
|
|
|
for (SellerWalletDetail detail : resultList) {
|
|
|
JSONObject result = new JSONObject();
|
|
|
result.put("amount", detail.getAmount());
|
|
|
result.put("type", sw.getType());
|
|
|
result.put("info", SellerWalletDetail.Type.of(sw.getType()).getName());
|
|
|
result.put("time", sdf.format(new Date(1000L * detail.getCreateTime())));
|
|
|
array.add(result);
|
|
|
}
|
|
|
return new com.yohoufo.common.ApiResponse(200, "查询成功", pageResp);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 支付保证金:总账修改
|
|
|
public SellerWallet useEarnest(Integer uid, BigDecimal money, String attach) {
|
|
|
return changeEarnest(uid, money, 0L, attach, SellerWalletDetail.Type.PUBLISH);
|
...
|
...
|
|