package com.fjhx.controller.order;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.entity.order.OrderFollow;
import com.fjhx.params.order.OrderInfoEx;
import com.fjhx.params.order.OrderInfoVo;
import com.fjhx.service.order.OrderFollowService;
import com.fjhx.service.order.OrderInfoService;
import org.springblade.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 售后管理
 */
@RestController
@RequestMapping("/afterSales")
public class AfterSalesController {

    @Autowired
    private OrderInfoService orderInfoService;

    @Autowired
    private OrderFollowService orderFollowService;

    /**
     * 添加售后管理
     */
    @PostMapping("/add")
    public R add(@RequestBody OrderInfoVo orderInfoVo) {
        orderInfoService.addAfterSales(orderInfoVo);
        return R.success();
    }

    /**
     * 分页
     */
    @PostMapping("/page")
    public R page(@RequestBody Map<String, Object> condition) {
        condition.put("afterSales", true);
        Page<OrderInfoEx> result = orderInfoService.getPage(condition);
        return R.success(result);
    }

    /**
     * 跟进
     */
    @PostMapping("/followUp")
    public R followUp(@RequestBody OrderFollow orderFollow) {
        orderFollowService.followUp(orderFollow);
        return R.success();
    }

}
