|
|
package com.yoho.ufo.order.service.impl;
|
|
|
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
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.yoho.order.dal.SellerWalletDetailMapper;
|
|
|
import com.yoho.order.model.MerchantReq;
|
|
|
import com.yoho.order.model.SellerWalletDetail;
|
|
|
import com.yoho.ufo.service.model.PageResponseBO;
|
|
|
import com.yohobuy.ufo.model.order.bo.MerchantOrderAttachInfo;
|
|
|
|
|
|
@Service
|
|
|
public class MerchantServiceImpl {
|
|
|
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(MerchantServiceImpl.class);
|
|
|
|
|
|
private ThreadLocal<SimpleDateFormat> sdf = ThreadLocal.withInitial(()-> new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"));
|
|
|
|
|
|
@Autowired
|
|
|
private SellerWalletDetailMapper mapper;
|
|
|
|
|
|
|
|
|
public MerchantOrderAttachInfo earnestDetail(MerchantReq req) {
|
|
|
return exchange(mapper.selectById(req.getId()));
|
|
|
}
|
|
|
|
|
|
|
|
|
public PageResponseBO<MerchantOrderAttachInfo> earnestList(MerchantReq req) {
|
|
|
|
|
|
Integer stratTime = parse(req.getStartTime());
|
|
|
Integer endTime = parse(req.getEndTime());
|
|
|
|
|
|
int total = mapper.selectMerchantInfoCount(req.getUid(), stratTime, endTime, req.getStateList());
|
|
|
if(total == 0) {
|
|
|
return new PageResponseBO<>();
|
|
|
}
|
|
|
|
|
|
List<SellerWalletDetail> beanList = mapper.selectMerchantInfo(req.getUid(), stratTime, endTime, req.getStateList(), req.getStart(), req.getRows());
|
|
|
List<MerchantOrderAttachInfo> boList = new ArrayList<>();
|
|
|
for(SellerWalletDetail detail : beanList) {
|
|
|
boList.add(exchange(detail));
|
|
|
}
|
|
|
|
|
|
PageResponseBO<MerchantOrderAttachInfo> result=new PageResponseBO<>();
|
|
|
result.setList(boList);
|
|
|
result.setPage(req.getPage());
|
|
|
result.setSize(req.getSize());
|
|
|
result.setTotal(total);
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
private MerchantOrderAttachInfo exchange(SellerWalletDetail detail) {
|
|
|
MerchantOrderAttachInfo info = new MerchantOrderAttachInfo();
|
|
|
if(StringUtils.isNotBlank(detail.getAttachValue())) {
|
|
|
info = JSON.parseObject(detail.getAttachValue(), MerchantOrderAttachInfo.class);
|
|
|
}
|
|
|
info.setId(detail.getId());
|
|
|
info.setUid(detail.getUid());
|
|
|
info.setType(detail.getType());
|
|
|
info.setUserName("");
|
|
|
info.setTime(sdf.get().format(new Date(detail.getCreateTime() * 1000L)));
|
|
|
if (info.getType() / 10 == 3 || info.getType()==61) {
|
|
|
info.setAccountAmount(detail.getAmount().toString());
|
|
|
info.setLockEarnestMoney(detail.getAmount().toString());
|
|
|
info.setAvailEarnestMoney("/");
|
|
|
} else {
|
|
|
info.setAccountAmount("/");
|
|
|
info.setLockEarnestMoney("/");
|
|
|
info.setAvailEarnestMoney(detail.getAmount().toString());
|
|
|
}
|
|
|
info.setAccountAllAmount(detail.getAvailAmount().add(detail.getLockAmount()).toString());
|
|
|
info.setLockAllEarnestMoney(detail.getLockAmount().toString());
|
|
|
info.setAvailAllEarnestMoney(detail.getAvailAmount().toString());
|
|
|
return info;
|
|
|
}
|
|
|
|
|
|
|
|
|
private Integer parse(String startTime) {
|
|
|
if(StringUtils.isBlank(startTime)) {
|
|
|
return null;
|
|
|
}
|
|
|
try {
|
|
|
return (int) (new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(startTime).getTime()/1000);
|
|
|
} catch (ParseException e) {
|
|
|
return null;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|