package com.liangjian.dataplatform.member.controller;
import com.liangjian.dataplatform.member.entity.po.secondary.FiltersData;
import com.liangjian.dataplatform.member.entity.response.ResultObject;
import com.liangjian.dataplatform.member.entity.tag.EsTagInfo;
import com.liangjian.dataplatform.member.service.IMemEsCountService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import net.sf.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.ws.rs.POST;
import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("/memcount")
@Api(value = "订单复购会员统计", tags = "订单复购会员统计", description = "订单复购会员统计")
public class MemEsCountController {


    @Autowired
    private IMemEsCountService iMemEsCountService;

    @GetMapping("/orderCount")
    @ApiOperation(value = "获取订单统计")
    public ResultObject<Object>getLastLog() {
        Map<String,Object> map = iMemEsCountService.getOrderCount();
        return ResultObject.success("保存成功",map);
    }

    @GetMapping("/getMemeberCount")
    @ApiOperation(value = "获取会员统计")
    public Map<String,Object> getMemeberCount(@ApiParam(value = "标签", required = false) @RequestParam String tagKey,@ApiParam(value = "平台", required = false) @RequestParam String zkey,@ApiParam(value = "性别", required = false) @RequestParam String sexkey) {
        Map<String,Object> map = iMemEsCountService.getMemeberCount(tagKey,zkey,sexkey);
        return map;
    }

    @GetMapping("/getMemeberDayCount")
    @ApiOperation(value = "会员增加统计")
    public Map<String,Object> getMemeberDayCount(@ApiParam(value = "天数", required = false) @RequestParam Integer mDay) {
        Map<String,Object> map= iMemEsCountService.getMemeberDayCount(mDay);
        return map;
    }

    @PostMapping("/AllTagList")
    @ApiOperation(value = "获取标签列表")
    public Map<String,Object> getAllTagList(@ApiParam(value = "参数", required = true) @RequestBody FiltersData data) {
        Map<String,Object> map = iMemEsCountService.getAllTagList(data);
        return map;
    }

    @PostMapping("/TagTypes")
    @ApiOperation(value = "标签类目")
    public Map<String,Object> TagTypes(@ApiParam(value = "参数",required = true)@RequestBody FiltersData data){
        Map<String,Object> map=iMemEsCountService.getTagTypes(data);
        return map;
    }

    @PostMapping("/usedrug")
    @ApiOperation(value = "用户用药")
    public Map<String,Object> getUsedrug(@ApiParam(value = "参数", required = true) @RequestBody FiltersData data) {
        Map<String,Object> map = iMemEsCountService.getUsedrug(data);
        return map;
    }

    @PostMapping("/EditTag")
    @ApiOperation(value = "修改标签")
    public ResultObject<Object> EditTag(@ApiParam(value = "标签",required = true) @RequestBody EsTagInfo esTagInfo){
        String retStr = iMemEsCountService.editTag(esTagInfo);
        return ResultObject.success("保存成功",null);
    }

    @PostMapping("/editType")
    @ApiOperation(value = "修改标签")
    public ResultObject<Object> editType(@ApiParam(value = "标签",required = true) @RequestBody EsTagInfo esTagInfo){
        String retStr = iMemEsCountService.editType(esTagInfo);
        return ResultObject.success("保存成功",null);
    }
}