...
|
...
|
@@ -33,233 +33,234 @@ import java.util.stream.Collectors; |
|
|
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"));
|
|
|
|
|
|
private ThreadLocal<SimpleDateFormat> sdf = ThreadLocal.withInitial(() -> new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"));
|
|
|
|
|
|
@Autowired
|
|
|
private SellerWalletDetailMapper mapper;
|
|
|
@Autowired
|
|
|
@Autowired
|
|
|
private SellerWalletMapper sellerWalletMapper;
|
|
|
@Autowired
|
|
|
private StoredSellerMapper storedSellerMapper;
|
|
|
@Autowired
|
|
|
private ProductMapper productMapper;
|
|
|
@Autowired
|
|
|
private GoodsMapper goodsMapper;
|
|
|
@Autowired
|
|
|
private StorageMapper storageMapper;
|
|
|
@Autowired
|
|
|
private UfoSizeMapper ufoSizeMapper;
|
|
|
@Autowired
|
|
|
private StoragePriceMapper storagePriceMapper;
|
|
|
@Autowired
|
|
|
private StoredSellerMapper storedSellerMapper;
|
|
|
@Autowired
|
|
|
private ProductMapper productMapper;
|
|
|
@Autowired
|
|
|
private GoodsMapper goodsMapper;
|
|
|
@Autowired
|
|
|
private StorageMapper storageMapper;
|
|
|
@Autowired
|
|
|
private UfoSizeMapper ufoSizeMapper;
|
|
|
@Autowired
|
|
|
private StoragePriceMapper storagePriceMapper;
|
|
|
|
|
|
public MerchantOrderAttachInfo earnestDetail(MerchantReq req) {
|
|
|
SellerWalletDetail sellerWalletDetail = mapper.selectById(req.getId());
|
|
|
MerchantOrderAttachInfo info = new MerchantOrderAttachInfo();
|
|
|
if(StringUtils.isNotBlank(sellerWalletDetail.getAttachValue())) {
|
|
|
info = JSON.parseObject(sellerWalletDetail.getAttachValue(), MerchantOrderAttachInfo.class);
|
|
|
}
|
|
|
info.setId(sellerWalletDetail.getId());
|
|
|
info.setUid(sellerWalletDetail.getUid());
|
|
|
info.setType(sellerWalletDetail.getType());
|
|
|
info.setTime(sdf.get().format(new Date(sellerWalletDetail.getCreateTime() * 1000L)));
|
|
|
SellerWalletDetail.TypeSearch curType = null;
|
|
|
//如果类型不存在,则不进行处理
|
|
|
if(info.getType()==null || (curType = SellerWalletDetail.TypeSearch.of(new int[]{info.getType().intValue()}))==null){
|
|
|
return info;
|
|
|
}
|
|
|
if(curType.equals(SellerWalletDetail.TypeSearch.RE_CHARGE)){
|
|
|
return dealReCharge(info,sellerWalletDetail);//保证金充值
|
|
|
}
|
|
|
if(curType.equals(SellerWalletDetail.TypeSearch.SELLER_ONSHELF)){
|
|
|
return dealSellerOnShelf(info,sellerWalletDetail);//卖家上架商品
|
|
|
}
|
|
|
if(curType.equals(SellerWalletDetail.TypeSearch.SELLER_OFFSHELF)){
|
|
|
return dealSellerOffShelf(info,sellerWalletDetail);//卖家下架商品
|
|
|
}
|
|
|
if(curType.equals(SellerWalletDetail.TypeSearch.TRADE_COMPLETE)){
|
|
|
return dealTradeComplete(info,sellerWalletDetail);//商品交易完成
|
|
|
}
|
|
|
if(curType.equals(SellerWalletDetail.TypeSearch.SELLER_TRADEFAILED)){
|
|
|
return dealSellerTradeFailed(info,sellerWalletDetail);//卖家原因交易失败
|
|
|
}
|
|
|
if(curType.equals(SellerWalletDetail.TypeSearch.SELLER_ADDPRICE)){
|
|
|
return dealSellerAddPrice(info,sellerWalletDetail);//卖家上调价格
|
|
|
}
|
|
|
if(curType.equals(SellerWalletDetail.TypeSearch.SELLER_REDUCEPRICE)){
|
|
|
return dealSellerReducePrice(info,sellerWalletDetail);//卖家下调价格
|
|
|
}
|
|
|
if(curType.equals(SellerWalletDetail.TypeSearch.BUYER_CANCEL)){
|
|
|
return dealBuyerCancel(info,sellerWalletDetail);//买家付款后取消订单
|
|
|
}
|
|
|
if(curType.equals(SellerWalletDetail.TypeSearch.SYSTEM_OFFSHELF)){
|
|
|
return dealSystemOffShelf(info,sellerWalletDetail);//系统下架商品
|
|
|
}
|
|
|
if(curType.equals(SellerWalletDetail.TypeSearch.SELLER_QUIT)){
|
|
|
return dealSellerQuit(info,sellerWalletDetail);//卖家退出入驻
|
|
|
}
|
|
|
return info;
|
|
|
}
|
|
|
public MerchantOrderAttachInfo earnestDetail(MerchantReq req) {
|
|
|
SellerWalletDetail sellerWalletDetail = mapper.selectById(req.getId());
|
|
|
MerchantOrderAttachInfo info = new MerchantOrderAttachInfo();
|
|
|
if (StringUtils.isNotBlank(sellerWalletDetail.getAttachValue())) {
|
|
|
info = JSON.parseObject(sellerWalletDetail.getAttachValue(), MerchantOrderAttachInfo.class);
|
|
|
}
|
|
|
info.setId(sellerWalletDetail.getId());
|
|
|
info.setUid(sellerWalletDetail.getUid());
|
|
|
info.setType(sellerWalletDetail.getType());
|
|
|
info.setTime(sdf.get().format(new Date(sellerWalletDetail.getCreateTime() * 1000L)));
|
|
|
SellerWalletDetail.TypeSearch curType = null;
|
|
|
//如果类型不存在,则不进行处理
|
|
|
if (info.getType() == null || (curType = SellerWalletDetail.TypeSearch.of(new int[]{info.getType().intValue()})) == null) {
|
|
|
return info;
|
|
|
}
|
|
|
if (curType.equals(SellerWalletDetail.TypeSearch.RE_CHARGE)) {
|
|
|
return dealReCharge(info, sellerWalletDetail);//保证金充值
|
|
|
}
|
|
|
if (curType.equals(SellerWalletDetail.TypeSearch.SELLER_ONSHELF)) {
|
|
|
return dealSellerOnShelf(info, sellerWalletDetail);//卖家上架商品
|
|
|
}
|
|
|
if (curType.equals(SellerWalletDetail.TypeSearch.SELLER_OFFSHELF)) {
|
|
|
return dealSellerOffShelf(info, sellerWalletDetail);//卖家下架商品
|
|
|
}
|
|
|
if (curType.equals(SellerWalletDetail.TypeSearch.TRADE_COMPLETE)) {
|
|
|
return dealTradeComplete(info, sellerWalletDetail);//商品交易完成
|
|
|
}
|
|
|
if (curType.equals(SellerWalletDetail.TypeSearch.SELLER_TRADEFAILED)) {
|
|
|
return dealSellerTradeFailed(info, sellerWalletDetail);//卖家原因交易失败
|
|
|
}
|
|
|
if (curType.equals(SellerWalletDetail.TypeSearch.SELLER_ADDPRICE)) {
|
|
|
return dealSellerAddPrice(info, sellerWalletDetail);//卖家上调价格
|
|
|
}
|
|
|
if (curType.equals(SellerWalletDetail.TypeSearch.SELLER_REDUCEPRICE)) {
|
|
|
return dealSellerReducePrice(info, sellerWalletDetail);//卖家下调价格
|
|
|
}
|
|
|
if (curType.equals(SellerWalletDetail.TypeSearch.BUYER_CANCEL)) {
|
|
|
return dealBuyerCancel(info, sellerWalletDetail);//买家付款后取消订单
|
|
|
}
|
|
|
if (curType.equals(SellerWalletDetail.TypeSearch.SYSTEM_OFFSHELF)) {
|
|
|
return dealSystemOffShelf(info, sellerWalletDetail);//系统下架商品
|
|
|
}
|
|
|
if (curType.equals(SellerWalletDetail.TypeSearch.SELLER_QUIT)) {
|
|
|
return dealSellerQuit(info, sellerWalletDetail);//卖家退出入驻
|
|
|
}
|
|
|
return info;
|
|
|
}
|
|
|
|
|
|
private MerchantOrderAttachInfo dealReCharge(MerchantOrderAttachInfo info,SellerWalletDetail sellerWalletDetail) {
|
|
|
if(info.getPayment()!=null){
|
|
|
info.setRechargeType(1==info.getPayment().intValue()?"支付宝":"微信");//充值方式
|
|
|
}
|
|
|
info.setSeriNo(info.getOrderCode()==null?null:info.getOrderCode().toString());//充值流水
|
|
|
info.setRechargeTime(info.getTime());//充值时间
|
|
|
info.setRechargeMoney(sellerWalletDetail.getAmount());//充值金额
|
|
|
return info;
|
|
|
}
|
|
|
private MerchantOrderAttachInfo dealReCharge(MerchantOrderAttachInfo info, SellerWalletDetail sellerWalletDetail) {
|
|
|
if (info.getPayment() != null) {
|
|
|
info.setRechargeType(1 == info.getPayment().intValue() ? "支付宝" : "微信");//充值方式
|
|
|
}
|
|
|
info.setSeriNo(info.getOrderCode() == null ? null : info.getOrderCode().toString());//充值流水
|
|
|
info.setRechargeTime(info.getTime());//充值时间
|
|
|
info.setRechargeMoney(sellerWalletDetail.getAmount());//充值金额
|
|
|
return info;
|
|
|
}
|
|
|
|
|
|
private MerchantOrderAttachInfo dealSellerOnShelf(MerchantOrderAttachInfo info,SellerWalletDetail sellerWalletDetail) {
|
|
|
info.setOnShelfTime(info.getTime());
|
|
|
info.setLockEarnestMoney(sellerWalletDetail.getAmount()==null?null:sellerWalletDetail.getAmount().abs().toString());
|
|
|
initProductInfo(info);
|
|
|
return info;
|
|
|
}
|
|
|
private MerchantOrderAttachInfo dealSellerOnShelf(MerchantOrderAttachInfo info, SellerWalletDetail sellerWalletDetail) {
|
|
|
info.setOnShelfTime(info.getTime());
|
|
|
info.setLockEarnestMoney(sellerWalletDetail.getAmount() == null ? null : sellerWalletDetail.getAmount().abs().toString());
|
|
|
initProductInfo(info);
|
|
|
return info;
|
|
|
}
|
|
|
|
|
|
private void initProductInfo(MerchantOrderAttachInfo info){
|
|
|
//根据orderCode查商品信息
|
|
|
info.setProductCount(info.getProductCount()==null?1:info.getProductCount());
|
|
|
StorageProductBo bo = initStorageProduct(info);
|
|
|
if(null == bo || bo.getProduct()==null || bo.getStorage() == null){
|
|
|
LOGGER.info("dealSellerOnShelf StorageProductBo is null!StorageProductBo is {},MerchantOrderAttachInfo is {}",bo,info);
|
|
|
return ;
|
|
|
}
|
|
|
info.setProductName(bo.getProduct().getProductName());
|
|
|
info.setSkup(bo.getProduct().getSkup());
|
|
|
List<Goods> goodsList = goodsMapper.selectByProductId(Arrays.asList(bo.getProduct().getId()));
|
|
|
if(!CollectionUtils.isEmpty(goodsList)){
|
|
|
info.setProductColor(goodsList.get(0).getGoodsName());
|
|
|
}
|
|
|
Size size = null;
|
|
|
if(bo.getStorage().getSizeId()!=null &&(size = ufoSizeMapper.selectOneById(bo.getStorage().getSizeId()))!=null){
|
|
|
info.setProductSize(size.getSizeName());
|
|
|
}
|
|
|
}
|
|
|
private void initProductInfo(MerchantOrderAttachInfo info) {
|
|
|
//根据orderCode查商品信息
|
|
|
info.setProductCount(info.getProductCount() == null ? 1 : info.getProductCount());
|
|
|
StorageProductBo bo = initStorageProduct(info);
|
|
|
if (null == bo || bo.getProduct() == null || bo.getStorage() == null) {
|
|
|
LOGGER.info("dealSellerOnShelf StorageProductBo is null!StorageProductBo is {},MerchantOrderAttachInfo is {}", bo, info);
|
|
|
return;
|
|
|
}
|
|
|
info.setProductName(bo.getProduct().getProductName());
|
|
|
info.setSkup(bo.getProduct().getSkup());
|
|
|
List<Goods> goodsList = goodsMapper.selectByProductId(Arrays.asList(bo.getProduct().getId()));
|
|
|
if (!CollectionUtils.isEmpty(goodsList)) {
|
|
|
info.setProductColor(goodsList.get(0).getGoodsName());
|
|
|
}
|
|
|
Size size = null;
|
|
|
if (bo.getStorage().getSizeId() != null && (size = ufoSizeMapper.selectOneById(bo.getStorage().getSizeId())) != null) {
|
|
|
info.setProductSize(size.getSizeName());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private StorageProductBo initStorageProduct(MerchantOrderAttachInfo info){
|
|
|
if(null != info.getStorageId()){
|
|
|
Storage storage = storageMapper.selectByPrimaryKey(info.getStorageId());
|
|
|
if(storage!=null){
|
|
|
Product product = null != storage.getProductId()?productMapper.selectByPrimaryKey(storage.getProductId()):null;
|
|
|
return new StorageProductBo(storage,product);
|
|
|
}
|
|
|
}
|
|
|
if(info.getSkup()!=null){
|
|
|
StoragePrice storagePrice = storagePriceMapper.selectBySkup(info.getSkup());
|
|
|
Storage storage = storageMapper.selectByPrimaryKey(storagePrice.getStorageId());
|
|
|
Product product = productMapper.selectByPrimaryKey(storagePrice.getProductId());
|
|
|
return new StorageProductBo(storage,product);
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
private MerchantOrderAttachInfo dealSellerOffShelf(MerchantOrderAttachInfo info,SellerWalletDetail sellerWalletDetail) {
|
|
|
info.setUnShelfTime(info.getTime());
|
|
|
info.setReleaseEarnestMoney(sellerWalletDetail.getAmount()==null?null:sellerWalletDetail.getAmount().abs().toString());
|
|
|
initProductInfo(info);
|
|
|
return info;
|
|
|
}
|
|
|
private StorageProductBo initStorageProduct(MerchantOrderAttachInfo info) {
|
|
|
if (null != info.getStorageId()) {
|
|
|
Storage storage = storageMapper.selectByPrimaryKey(info.getStorageId());
|
|
|
if (storage != null) {
|
|
|
Product product = null != storage.getProductId() ? productMapper.selectByPrimaryKey(storage.getProductId()) : null;
|
|
|
return new StorageProductBo(storage, product);
|
|
|
}
|
|
|
}
|
|
|
if (info.getSkup() != null) {
|
|
|
StoragePrice storagePrice = storagePriceMapper.selectBySkup(info.getSkup());
|
|
|
Storage storage = storageMapper.selectByPrimaryKey(storagePrice.getStorageId());
|
|
|
Product product = productMapper.selectByPrimaryKey(storagePrice.getProductId());
|
|
|
return new StorageProductBo(storage, product);
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
private MerchantOrderAttachInfo dealSellerOffShelf(MerchantOrderAttachInfo info, SellerWalletDetail sellerWalletDetail) {
|
|
|
info.setUnShelfTime(info.getTime());
|
|
|
info.setReleaseEarnestMoney(sellerWalletDetail.getAmount() == null ? null : sellerWalletDetail.getAmount().abs().toString());
|
|
|
initProductInfo(info);
|
|
|
return info;
|
|
|
}
|
|
|
|
|
|
private MerchantOrderAttachInfo dealTradeComplete(MerchantOrderAttachInfo info,SellerWalletDetail sellerWalletDetail) {
|
|
|
info.setTradeCompleteTime(info.getTime());
|
|
|
info.setReleaseEarnestMoney(sellerWalletDetail.getAmount()==null?null:sellerWalletDetail.getAmount().abs().toString());
|
|
|
initProductInfo(info);
|
|
|
return info;
|
|
|
}
|
|
|
private MerchantOrderAttachInfo dealTradeComplete(MerchantOrderAttachInfo info, SellerWalletDetail sellerWalletDetail) {
|
|
|
info.setTradeCompleteTime(info.getTime());
|
|
|
info.setReleaseEarnestMoney(sellerWalletDetail.getAmount() == null ? null : sellerWalletDetail.getAmount().abs().toString());
|
|
|
initProductInfo(info);
|
|
|
return info;
|
|
|
}
|
|
|
|
|
|
private MerchantOrderAttachInfo dealSellerTradeFailed(MerchantOrderAttachInfo info,SellerWalletDetail sellerWalletDetail) {
|
|
|
info.setCancelOrderTime(info.getTime());
|
|
|
info.setReleaseEarnestMoney(sellerWalletDetail.getAmount()==null?null:sellerWalletDetail.getAmount().abs().toString());
|
|
|
initProductInfo(info);
|
|
|
return info;
|
|
|
}
|
|
|
private MerchantOrderAttachInfo dealSellerTradeFailed(MerchantOrderAttachInfo info, SellerWalletDetail sellerWalletDetail) {
|
|
|
info.setCancelOrderTime(info.getTime());
|
|
|
info.setReleaseEarnestMoney(sellerWalletDetail.getAmount() == null ? null : sellerWalletDetail.getAmount().abs().toString());
|
|
|
initProductInfo(info);
|
|
|
return info;
|
|
|
}
|
|
|
|
|
|
private MerchantOrderAttachInfo dealSellerAddPrice(MerchantOrderAttachInfo info,SellerWalletDetail sellerWalletDetail) {
|
|
|
info.setAdjustPriceTime(info.getTime());
|
|
|
info.setBeforeAdjustPrice(info.getBeforeProductPrice()==null?null:info.getBeforeProductPrice().toString());
|
|
|
info.setBeforeAdjustLockMoney(info.getBeforeEarnestMoney());
|
|
|
info.setAfterAdjustPrice(info.getAfterProductPrice()==null?null:info.getAfterProductPrice().toString());
|
|
|
info.setAfterAdjustLockMoney((info.getAfterEarnestMoney()));
|
|
|
if(info.getAfterAdjustLockMoney()!=null && info.getBeforeAdjustLockMoney()!=null){
|
|
|
BigDecimal afterLockMoney = new BigDecimal(info.getAfterAdjustLockMoney());
|
|
|
info.setAddLockEarnestMoney(afterLockMoney.subtract(new BigDecimal(info.getBeforeAdjustLockMoney())).abs().toString());
|
|
|
}
|
|
|
initProductInfo(info);
|
|
|
return info;
|
|
|
}
|
|
|
private MerchantOrderAttachInfo dealSellerAddPrice(MerchantOrderAttachInfo info, SellerWalletDetail sellerWalletDetail) {
|
|
|
info.setAdjustPriceTime(info.getTime());
|
|
|
info.setBeforeAdjustPrice(info.getBeforeProductPrice() == null ? null : info.getBeforeProductPrice().toString());
|
|
|
info.setBeforeAdjustLockMoney(info.getBeforeEarnestMoney());
|
|
|
info.setAfterAdjustPrice(info.getAfterProductPrice() == null ? null : info.getAfterProductPrice().toString());
|
|
|
info.setAfterAdjustLockMoney((info.getAfterEarnestMoney()));
|
|
|
if (info.getAfterAdjustLockMoney() != null && info.getBeforeAdjustLockMoney() != null) {
|
|
|
BigDecimal afterLockMoney = new BigDecimal(info.getAfterAdjustLockMoney());
|
|
|
info.setAddLockEarnestMoney(afterLockMoney.subtract(new BigDecimal(info.getBeforeAdjustLockMoney())).abs().toString());
|
|
|
}
|
|
|
initProductInfo(info);
|
|
|
return info;
|
|
|
}
|
|
|
|
|
|
private MerchantOrderAttachInfo dealSellerReducePrice(MerchantOrderAttachInfo info,SellerWalletDetail sellerWalletDetail) {
|
|
|
info.setAdjustPriceTime(info.getTime());
|
|
|
info.setBeforeAdjustPrice(info.getBeforeProductPrice()==null?null:info.getBeforeProductPrice().toString());
|
|
|
info.setBeforeAdjustLockMoney(info.getBeforeEarnestMoney());
|
|
|
info.setAfterAdjustPrice(info.getAfterProductPrice()==null?null:info.getAfterProductPrice().toString());
|
|
|
info.setAfterAdjustLockMoney((info.getAfterEarnestMoney()));
|
|
|
if(info.getAfterAdjustLockMoney()!=null && info.getBeforeAdjustLockMoney()!=null){
|
|
|
BigDecimal afterLockMoney = new BigDecimal(info.getAfterAdjustLockMoney());
|
|
|
info.setReduceLockEarnestMoney(afterLockMoney.subtract(new BigDecimal(info.getBeforeAdjustLockMoney())).abs().toString());
|
|
|
}
|
|
|
initProductInfo(info);
|
|
|
return info;
|
|
|
}
|
|
|
private MerchantOrderAttachInfo dealSellerReducePrice(MerchantOrderAttachInfo info, SellerWalletDetail sellerWalletDetail) {
|
|
|
info.setAdjustPriceTime(info.getTime());
|
|
|
info.setBeforeAdjustPrice(info.getBeforeProductPrice() == null ? null : info.getBeforeProductPrice().toString());
|
|
|
info.setBeforeAdjustLockMoney(info.getBeforeEarnestMoney());
|
|
|
info.setAfterAdjustPrice(info.getAfterProductPrice() == null ? null : info.getAfterProductPrice().toString());
|
|
|
info.setAfterAdjustLockMoney((info.getAfterEarnestMoney()));
|
|
|
if (info.getAfterAdjustLockMoney() != null && info.getBeforeAdjustLockMoney() != null) {
|
|
|
BigDecimal afterLockMoney = new BigDecimal(info.getAfterAdjustLockMoney());
|
|
|
info.setReduceLockEarnestMoney(afterLockMoney.subtract(new BigDecimal(info.getBeforeAdjustLockMoney())).abs().toString());
|
|
|
}
|
|
|
initProductInfo(info);
|
|
|
return info;
|
|
|
}
|
|
|
|
|
|
private MerchantOrderAttachInfo dealBuyerCancel(MerchantOrderAttachInfo info,SellerWalletDetail sellerWalletDetail) {
|
|
|
info.setBuyerCancelTime(info.getTime());
|
|
|
info.setReleaseEarnestMoney(sellerWalletDetail.getAmount()==null?null:sellerWalletDetail.getAmount().toString());
|
|
|
initProductInfo(info);
|
|
|
return info;
|
|
|
}
|
|
|
private MerchantOrderAttachInfo dealBuyerCancel(MerchantOrderAttachInfo info, SellerWalletDetail sellerWalletDetail) {
|
|
|
info.setBuyerCancelTime(info.getTime());
|
|
|
info.setReleaseEarnestMoney(sellerWalletDetail.getAmount() == null ? null : sellerWalletDetail.getAmount().toString());
|
|
|
initProductInfo(info);
|
|
|
return info;
|
|
|
}
|
|
|
|
|
|
private MerchantOrderAttachInfo dealSystemOffShelf(MerchantOrderAttachInfo info,SellerWalletDetail sellerWalletDetail) {
|
|
|
info.setUnShelfTime(info.getTime());
|
|
|
info.setReleaseEarnestMoney(sellerWalletDetail.getAmount()==null?null:sellerWalletDetail.getAmount().toString());
|
|
|
initProductInfo(info);
|
|
|
return info;
|
|
|
}
|
|
|
private MerchantOrderAttachInfo dealSystemOffShelf(MerchantOrderAttachInfo info, SellerWalletDetail sellerWalletDetail) {
|
|
|
info.setUnShelfTime(info.getTime());
|
|
|
info.setReleaseEarnestMoney(sellerWalletDetail.getAmount() == null ? null : sellerWalletDetail.getAmount().toString());
|
|
|
initProductInfo(info);
|
|
|
return info;
|
|
|
}
|
|
|
|
|
|
private MerchantOrderAttachInfo dealSellerQuit(MerchantOrderAttachInfo info,SellerWalletDetail sellerWalletDetail) {
|
|
|
info.setRefundSeriNo(null == info.getOrderCode()?null:info.getOrderCode().toString());
|
|
|
info.setRefundTime(info.getTime());
|
|
|
info.setRefundType(1==info.getPayment().intValue()?"支付宝":"微信");
|
|
|
info.setRefundMoney(sellerWalletDetail.getAmount()==null?null:sellerWalletDetail.getAmount().toString());
|
|
|
return info;
|
|
|
}
|
|
|
private MerchantOrderAttachInfo dealSellerQuit(MerchantOrderAttachInfo info, SellerWalletDetail sellerWalletDetail) {
|
|
|
info.setRefundSeriNo(null == info.getOrderCode() ? null : info.getOrderCode().toString());
|
|
|
info.setRefundTime(info.getTime());
|
|
|
info.setRefundType(1 == info.getPayment().intValue() ? "支付宝" : "微信");
|
|
|
info.setRefundMoney(sellerWalletDetail.getAmount() == null ? null : sellerWalletDetail.getAmount().toString());
|
|
|
return info;
|
|
|
}
|
|
|
|
|
|
|
|
|
public PageResponseBO<MerchantOrderAttachInfo> earnestList(MerchantReq req) {
|
|
|
Integer stratTime = parse(req.getStartTime());
|
|
|
Integer endTime = parse(req.getEndTime());
|
|
|
List<Integer> uids = null;
|
|
|
if(StringUtils.isNotBlank(req.getMerchantName()) || StringUtils.isNotBlank(req.getUid())){
|
|
|
uids = storedSellerMapper.selectUidByCertNameAndUid(req.getMerchantName(),req.getUid());
|
|
|
if(CollectionUtils.isEmpty(uids)){
|
|
|
return new PageResponseBO<>();
|
|
|
}
|
|
|
}
|
|
|
int total = mapper.selectMerchantInfoCount(CollectionUtils.isEmpty(uids)?null:uids, stratTime, endTime, req.getStateList(),req.getOrderCode());
|
|
|
if(total == 0) {
|
|
|
return new PageResponseBO<>();
|
|
|
}
|
|
|
List<SellerWalletDetail> beanList = mapper.selectMerchantInfo(CollectionUtils.isEmpty(uids)?null:uids, stratTime, endTime, req.getStateList(),req.getOrderCode(), req.getStart(), req.getRows());
|
|
|
if(CollectionUtils.isEmpty(beanList)){
|
|
|
PageResponseBO<MerchantOrderAttachInfo> result=new PageResponseBO<>();
|
|
|
result.setPage(req.getPage());
|
|
|
result.setSize(req.getSize());
|
|
|
result.setTotal(total);
|
|
|
return result;
|
|
|
}
|
|
|
Map<Integer,Map<String,Object>> storedSellerMap = this.storedSellerMapper.selectNameByUids(beanList.stream().map(cell->cell.getUid()).collect(Collectors.toList()));
|
|
|
List<MerchantOrderAttachInfo> boList = new ArrayList<>();
|
|
|
for(SellerWalletDetail detail : beanList) {
|
|
|
MerchantOrderAttachInfo info = exchange(detail);
|
|
|
info.setOrderCode(detail.getOrderCode());
|
|
|
Map<String,Object> storedSellerDataMap = storedSellerMap.get(detail.getUid());
|
|
|
if(null != storedSellerDataMap){
|
|
|
info.setMerchantName((String)storedSellerDataMap.get("cert_name"));
|
|
|
}
|
|
|
boList.add(info);
|
|
|
}
|
|
|
PageResponseBO<MerchantOrderAttachInfo> result=new PageResponseBO<>();
|
|
|
public PageResponseBO<MerchantOrderAttachInfo> earnestList(MerchantReq req) {
|
|
|
Integer stratTime = parse(req.getStartTime());
|
|
|
Integer endTime = parse(req.getEndTime());
|
|
|
List<Integer> uids = null;
|
|
|
if (StringUtils.isNotBlank(req.getMerchantName()) || StringUtils.isNotBlank(req.getUid())) {
|
|
|
uids = storedSellerMapper.selectUidByCertNameAndUid(req.getMerchantName(), req.getUid());
|
|
|
if (CollectionUtils.isEmpty(uids)) {
|
|
|
return new PageResponseBO<>();
|
|
|
}
|
|
|
}
|
|
|
int total = mapper.selectMerchantInfoCount(CollectionUtils.isEmpty(uids) ? null : uids, stratTime, endTime, req.getStateList(), req.getOrderCode());
|
|
|
if (total == 0) {
|
|
|
return new PageResponseBO<>();
|
|
|
}
|
|
|
List<SellerWalletDetail> beanList = mapper.selectMerchantInfo(CollectionUtils.isEmpty(uids) ? null : uids, stratTime, endTime, req.getStateList(), req.getOrderCode(), req.getStart(), req.getRows());
|
|
|
if (CollectionUtils.isEmpty(beanList)) {
|
|
|
PageResponseBO<MerchantOrderAttachInfo> result = new PageResponseBO<>();
|
|
|
result.setPage(req.getPage());
|
|
|
result.setSize(req.getSize());
|
|
|
result.setTotal(total);
|
|
|
return result;
|
|
|
}
|
|
|
Map<Integer, Map<String, Object>> storedSellerMap = this.storedSellerMapper.selectNameByUids(beanList.stream().map(cell -> cell.getUid()).collect(Collectors.toList()));
|
|
|
List<MerchantOrderAttachInfo> boList = new ArrayList<>();
|
|
|
for (SellerWalletDetail detail : beanList) {
|
|
|
MerchantOrderAttachInfo info = exchange(detail);
|
|
|
info.setOrderCode(detail.getOrderCode());
|
|
|
Map<String, Object> storedSellerDataMap = storedSellerMap.get(detail.getUid());
|
|
|
if (null != storedSellerDataMap) {
|
|
|
info.setMerchantName((String) storedSellerDataMap.get("cert_name"));
|
|
|
}
|
|
|
boList.add(info);
|
|
|
}
|
|
|
PageResponseBO<MerchantOrderAttachInfo> result = new PageResponseBO<>();
|
|
|
result.setList(boList);
|
|
|
result.setPage(req.getPage());
|
|
|
result.setSize(req.getSize());
|
...
|
...
|
@@ -268,92 +269,96 @@ public class MerchantServiceImpl { |
|
|
}
|
|
|
|
|
|
|
|
|
private MerchantOrderAttachInfo exchange(SellerWalletDetail detail) {
|
|
|
MerchantOrderAttachInfo info = new MerchantOrderAttachInfo();
|
|
|
if(StringUtils.isNotBlank(detail.getAttachValue())) {
|
|
|
info = JSON.parseObject(detail.getAttachValue(), MerchantOrderAttachInfo.class);
|
|
|
info=info == null?new MerchantOrderAttachInfo():info;
|
|
|
}
|
|
|
info.setId(detail.getId());
|
|
|
info.setUid(detail.getUid());
|
|
|
info.setType(detail.getType());
|
|
|
if(null != info.getType()){
|
|
|
info.setTypeName(SellerWalletDetail.Type.of(detail.getType()).getName());
|
|
|
}
|
|
|
info.setTime(sdf.get().format(new Date(detail.getCreateTime() * 1000L)));
|
|
|
if (info.getType() / 10 == 3 || info.getType()==61) {
|
|
|
info.setAccountAmount(detail.getAmount()==null?null:detail.getAmount().toString());
|
|
|
info.setLockEarnestMoney(detail.getAmount()==null?null:detail.getAmount().toString());
|
|
|
info.setAvailEarnestMoney("/");
|
|
|
} else {
|
|
|
info.setAccountAmount("/");
|
|
|
info.setLockEarnestMoney("/");
|
|
|
info.setAvailEarnestMoney(detail.getAmount()==null?null:detail.getAmount().toString());
|
|
|
}
|
|
|
info.setAccountAllAmount(detail.getAvailAmount() == null?detail.getLockAmount()==null?
|
|
|
null:detail.getLockAmount().toString():detail.getAvailAmount().add(detail.getLockAmount()).toString());
|
|
|
info.setAvailAllEarnestMoney(detail.getAvailAmount() == null?null:detail.getAvailAmount().toString());
|
|
|
info.setLockAllEarnestMoney(detail.getLockAmount()==null?null:detail.getLockAmount().toString());
|
|
|
return info;
|
|
|
}
|
|
|
private MerchantOrderAttachInfo exchange(SellerWalletDetail detail) {
|
|
|
MerchantOrderAttachInfo info = new MerchantOrderAttachInfo();
|
|
|
if (StringUtils.isNotBlank(detail.getAttachValue())) {
|
|
|
try {
|
|
|
info = JSON.parseObject(detail.getAttachValue(), MerchantOrderAttachInfo.class);
|
|
|
} catch (Exception e) {
|
|
|
// ignore exception
|
|
|
}
|
|
|
info = info == null ? new MerchantOrderAttachInfo() : info;
|
|
|
}
|
|
|
info.setId(detail.getId());
|
|
|
info.setUid(detail.getUid());
|
|
|
info.setType(detail.getType());
|
|
|
if (null != info.getType()) {
|
|
|
info.setTypeName(SellerWalletDetail.Type.of(detail.getType()).getName());
|
|
|
}
|
|
|
info.setTime(sdf.get().format(new Date(detail.getCreateTime() * 1000L)));
|
|
|
if (info.getType() / 10 == 3 || info.getType() == 61) {
|
|
|
info.setAccountAmount(detail.getAmount() == null ? null : detail.getAmount().toString());
|
|
|
info.setLockEarnestMoney(detail.getAmount() == null ? null : detail.getAmount().toString());
|
|
|
info.setAvailEarnestMoney("/");
|
|
|
} else {
|
|
|
info.setAccountAmount("/");
|
|
|
info.setLockEarnestMoney("/");
|
|
|
info.setAvailEarnestMoney(detail.getAmount() == null ? null : detail.getAmount().toString());
|
|
|
}
|
|
|
info.setAccountAllAmount(detail.getAvailAmount() == null ? detail.getLockAmount() == null ?
|
|
|
null : detail.getLockAmount().toString() : detail.getAvailAmount().add(detail.getLockAmount()).toString());
|
|
|
info.setAvailAllEarnestMoney(detail.getAvailAmount() == null ? null : detail.getAvailAmount().toString());
|
|
|
info.setLockAllEarnestMoney(detail.getLockAmount() == null ? null : detail.getLockAmount().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;
|
|
|
}
|
|
|
}
|
|
|
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;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public PageResponseBO<MerchantOrderAttachInfo> listSellerWallets(MerchantReq req) {
|
|
|
List<Integer> uids = null;
|
|
|
if(StringUtils.isNotBlank(req.getMerchantName())){
|
|
|
uids = storedSellerMapper.selectUidByCertName(req.getMerchantName());
|
|
|
if(CollectionUtils.isEmpty(uids)){
|
|
|
return new PageResponseBO<>();
|
|
|
}
|
|
|
}
|
|
|
int total = this.sellerWalletMapper.selectTotalByUidAndMerchantUids(req.getUid(),uids);
|
|
|
if(total == 0){
|
|
|
return new PageResponseBO<>();
|
|
|
}
|
|
|
List<SellerWallet> sellerWallets = this.sellerWalletMapper.selectByUidAndMerchantUids(req.getUid(),uids,req.getStart(),req.getSize());
|
|
|
if(CollectionUtils.isEmpty(sellerWallets)){
|
|
|
PageResponseBO<MerchantOrderAttachInfo> result = new PageResponseBO<>();
|
|
|
result.setTotal(total);
|
|
|
result.setPage(req.getPage());
|
|
|
result.setSize(req.getSize());
|
|
|
return result;
|
|
|
}
|
|
|
List<MerchantOrderAttachInfo> infos = initMerchantOrderAttachInfos(sellerWallets);
|
|
|
PageResponseBO<MerchantOrderAttachInfo> result = new PageResponseBO<>();
|
|
|
result.setTotal(total);
|
|
|
result.setList(infos);
|
|
|
result.setPage(req.getPage());
|
|
|
result.setSize(req.getSize());
|
|
|
return result;
|
|
|
}
|
|
|
public PageResponseBO<MerchantOrderAttachInfo> listSellerWallets(MerchantReq req) {
|
|
|
List<Integer> uids = null;
|
|
|
if (StringUtils.isNotBlank(req.getMerchantName())) {
|
|
|
uids = storedSellerMapper.selectUidByCertName(req.getMerchantName());
|
|
|
if (CollectionUtils.isEmpty(uids)) {
|
|
|
return new PageResponseBO<>();
|
|
|
}
|
|
|
}
|
|
|
int total = this.sellerWalletMapper.selectTotalByUidAndMerchantUids(req.getUid(), uids);
|
|
|
if (total == 0) {
|
|
|
return new PageResponseBO<>();
|
|
|
}
|
|
|
List<SellerWallet> sellerWallets = this.sellerWalletMapper.selectByUidAndMerchantUids(req.getUid(), uids, req.getStart(), req.getSize());
|
|
|
if (CollectionUtils.isEmpty(sellerWallets)) {
|
|
|
PageResponseBO<MerchantOrderAttachInfo> result = new PageResponseBO<>();
|
|
|
result.setTotal(total);
|
|
|
result.setPage(req.getPage());
|
|
|
result.setSize(req.getSize());
|
|
|
return result;
|
|
|
}
|
|
|
List<MerchantOrderAttachInfo> infos = initMerchantOrderAttachInfos(sellerWallets);
|
|
|
PageResponseBO<MerchantOrderAttachInfo> result = new PageResponseBO<>();
|
|
|
result.setTotal(total);
|
|
|
result.setList(infos);
|
|
|
result.setPage(req.getPage());
|
|
|
result.setSize(req.getSize());
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
private List<MerchantOrderAttachInfo> initMerchantOrderAttachInfos(List<SellerWallet> sellerWallets) {
|
|
|
List<MerchantOrderAttachInfo> infos = new ArrayList<>();
|
|
|
Map<Integer,Map<String,Object>> storedSellerMap = this.storedSellerMapper.selectNameByUids(sellerWallets.stream().map(cell->cell.getUid()).collect(Collectors.toList()));
|
|
|
for (SellerWallet sellerWallet : sellerWallets) {
|
|
|
MerchantOrderAttachInfo info = new MerchantOrderAttachInfo();
|
|
|
BigDecimal amount = sellerWallet.getAmount();
|
|
|
BigDecimal lockMoney = sellerWallet.getLockAmount();
|
|
|
info.setId(sellerWallet.getId());
|
|
|
info.setAccountAmount(null == amount?null == lockMoney?null:lockMoney.toString():amount.add(sellerWallet.getLockAmount()).toString());
|
|
|
info.setLockEarnestMoney(null == lockMoney?null:lockMoney.toString());
|
|
|
info.setAvailEarnestMoney(null == amount?null:amount.toString());
|
|
|
info.setUid(sellerWallet.getUid());
|
|
|
Map<String,Object> certInfo = storedSellerMap.get(sellerWallet.getUid());
|
|
|
info.setMerchantName(certInfo==null?"":(String)certInfo.get("cert_name"));
|
|
|
infos.add(info);
|
|
|
}
|
|
|
return infos;
|
|
|
}
|
|
|
private List<MerchantOrderAttachInfo> initMerchantOrderAttachInfos(List<SellerWallet> sellerWallets) {
|
|
|
List<MerchantOrderAttachInfo> infos = new ArrayList<>();
|
|
|
Map<Integer, Map<String, Object>> storedSellerMap = this.storedSellerMapper.selectNameByUids(sellerWallets.stream().map(cell -> cell.getUid()).collect(Collectors.toList()));
|
|
|
for (SellerWallet sellerWallet : sellerWallets) {
|
|
|
MerchantOrderAttachInfo info = new MerchantOrderAttachInfo();
|
|
|
BigDecimal amount = sellerWallet.getAmount();
|
|
|
BigDecimal lockMoney = sellerWallet.getLockAmount();
|
|
|
info.setId(sellerWallet.getId());
|
|
|
info.setAccountAmount(null == amount ? null == lockMoney ? null : lockMoney.toString() : amount.add(sellerWallet.getLockAmount()).toString());
|
|
|
info.setLockEarnestMoney(null == lockMoney ? null : lockMoney.toString());
|
|
|
info.setAvailEarnestMoney(null == amount ? null : amount.toString());
|
|
|
info.setUid(sellerWallet.getUid());
|
|
|
Map<String, Object> certInfo = storedSellerMap.get(sellerWallet.getUid());
|
|
|
info.setMerchantName(certInfo == null ? "" : (String) certInfo.get("cert_name"));
|
|
|
infos.add(info);
|
|
|
}
|
|
|
return infos;
|
|
|
}
|
|
|
} |
...
|
...
|
|