package com.miaxis.wx.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.miaxis.common.enums.OrderStatusEnum;
import com.miaxis.system.service.ISysConfigService;
import com.miaxis.wx.domain.WxOrder;
import com.miaxis.wx.dto.PcWxOrderListDTO;
import com.miaxis.wx.dto.QuerySchoolOrderListDTO;
import com.miaxis.wx.mapper.WxOrderMapper;
import com.miaxis.wx.service.IRefundRecordService;
import com.miaxis.wx.service.IWxOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 电影订单Service业务层处理
 *
 * @author miaxis
 * @date 2021-05-07
 */
@Service
@Slf4j
public class WxOrderServiceImpl extends ServiceImpl<WxOrderMapper, WxOrder> implements IWxOrderService {
    @Resource
    private WxOrderMapper wxOrderMapper;


    @Autowired
    private ISysConfigService configService;


    @Autowired
    private IRefundRecordService refundRecordService;



    @Override
    public void createVipOrder(WxOrder wxOrder) {
        String price = null ;
        if (wxOrder.getReferralUserId() == null){
            price = configService.selectConfigByKey("vip_price");
        }else {
            price = configService.selectConfigByKey("vip_price_referral");
        }
        Double dprice = Double.valueOf(price);
        Double v =dprice* 100;
        wxOrder.setTotal(v.intValue());
        wxOrder.setOrderStatus(OrderStatusEnum.PROCESSING.getCode());

    }
    @Override
    public WxOrder getByOutTradeNo(String outTradeNo) {
        return wxOrderMapper.getByOutTradeNo(outTradeNo);
    }

    @Override
    public List<WxOrder> selectPcOrderList(PcWxOrderListDTO pcWxOrderListDTO) {
        return wxOrderMapper.selectPcOrderList(pcWxOrderListDTO);
    }

    @Override
    public List<WxOrder> QuerySchoolOrderList(QuerySchoolOrderListDTO dto) {
        return wxOrderMapper.QuerySchoolOrderList(dto);
    }


}
