package com.hai.config;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.entity.HighCoupon;
import com.hai.enum_type.CmsContentDataEnum;
import com.hai.service.HighCouponService;
import com.hai.service.HighDiscountPackageService;
import com.itextpdf.tool.xml.html.head.Title;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * @serviceName QrCodeUtilsConfig.java
 * @author Sum1Dream
 * @version 1.0.0
 * @Description // CMS内容工具
 * @createTime 09:54 2022/4/13
 **/
@Configuration
public class CmsContentConfig {

    @Resource
    private HighCouponService highCouponService;

    @Resource
    private HighDiscountPackageService highDiscountPackageService;

    public Object getCmsContentData(String title , Long companyId) throws Exception {

        Map<String , Object> map = new HashMap<>();
        // 判断是否是天天好券
        if (CmsContentDataEnum.DISCOUNT.getName().equals(title)) {
            map.put("companyId", companyId);
            map.put("salesType" , 1);
            map.put("status" , 1);
            PageHelper.startPage(1, 3);
            return new PageInfo<>( highDiscountPackageService.getDiscountPackageList(map)).getList();
        } else if (CmsContentDataEnum.REFUEL.getName().equals(title) ||  CmsContentDataEnum.INTEGRAL.getName().equals(title) ||  CmsContentDataEnum.UNION_CARD.getName().equals(title) ||  CmsContentDataEnum.BLX_COUPON.getName().equals(title)){
            map.put("companyId", companyId);
            map.put("displayArea", CmsContentDataEnum.getTypeByName(title));
            map.put("notCouponSource", 2);
            map.put("status", 2);
            PageHelper.startPage(1, 3);
            return new PageInfo<>(highCouponService.getCouponList(map)).getList();
        } else if (CmsContentDataEnum.MSG.getName().equals(title)){
            map.put("companyId", companyId);
            map.put("displayArea", CmsContentDataEnum.getTypeByName(title));
            map.put("notCouponSource", 2);
            map.put("status", 2);
            PageHelper.startPage(1, 3);
            return new PageInfo<>(highCouponService.getCouponList(map)).getList();
        }
        return  null;

    }




}
