package com.community.huiju.service.impl;

import com.community.commom.mode.ResponseBean;
import com.community.commom.session.UserElement;
import com.community.huiju.dao.TaUserLicenseOrderMapper;
import com.community.huiju.model.TaUserLicenseOrder;
import com.community.huiju.service.ITaUserLicenseOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

/**
 * 月租车 订单业务
 */
@Service
@Slf4j
public class TaUserLicenseOrderServiceImpl implements ITaUserLicenseOrderService {

    @Autowired
    private TaUserLicenseOrderMapper taUserLicenseOrderMapper;

    @Override
    public ResponseBean selectRecords(UserElement userElement) {
        ResponseBean responseBean = new ResponseBean();
        List<TaUserLicenseOrder> taUserLicenseOrders = taUserLicenseOrderMapper.selectRecords(userElement.getCommunityId(), userElement.getId());

        taUserLicenseOrders.forEach(e->{
            e.setExtensionPrice(String.valueOf(Long.valueOf(String.valueOf(e.getExtensionPrice())) / 100));
            e.setUnitPrice(String.valueOf(Long.valueOf(String.valueOf(e.getUnitPrice())) / 100));
        });

        responseBean.addSuccess(taUserLicenseOrders);
        return responseBean;
    }
}
