package com.jwipc.shopping.controller.pc;

import com.jwipc.security.LoginUtil;
import com.jwipc.shopping.constant.ModuleConst;
import com.jwipc.shopping.entity.ShoppingAfterSales;
import com.jwipc.shopping.entity.ShoppingAfterSalesInfo;
import com.jwipc.shopping.logic.OnlineMallLogic;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 功能描述:
 *
 * @Author: zx
 * @Date: 2024/3/15 0015 9:46
 */
@Controller
@RequestMapping(ModuleConst.MODULE_ROOT + "/cart/page")
@RequiredArgsConstructor
@Slf4j
public class ShoppingCartPageController {
    @Autowired
    OnlineMallLogic onlineMallLogic;
    /**
     * 系统管理-数据字典管理首页列表
     *
     * @return 页面
     */
    @GetMapping("cartList")
    public String listUI() {
        return ModuleConst.MODULE_ROOT +"/cart/index";
    }

    @GetMapping("cartInfoList")
    public String infoListUI() {
        return ModuleConst.MODULE_ROOT +"/cartInfo/index";
    }
    /**
     * 到订单明细页面
     */
    @RequestMapping("detailListUI")
    public String detailListUI(Model model, Long cartId) {
        model.addAttribute("cartId", cartId);
        return ModuleConst.MODULE_ROOT +"/cart/detail";
    }

    /**
     * 售后申请页面
     */
    @RequestMapping("applyUI")
    public String applyUI(Model model, Long cartId) {
        String createUserName = LoginUtil.getName();
        String createUserCode = LoginUtil.getAccount();
        model.addAttribute("cartId", cartId);
        model.addAttribute("createUserName", createUserName);
        model.addAttribute("createUserCode", createUserCode);
        return ModuleConst.MODULE_ROOT +"/cart/apply";
    }
    /**
     * 售后申请查看页面
     */
    @RequestMapping("applyUILook")
    public String applyUILook(Model model, String cartId,Long id) {

        String createUserName = LoginUtil.getName();
        String createUserCode = LoginUtil.getAccount();
        Long poId = onlineMallLogic.findHeadByOrderCode(cartId);
        ShoppingAfterSales shoppingAfterSales = onlineMallLogic.findById(id);
        model.addAttribute("cartId", poId);
        model.addAttribute("createUserName", createUserName);
        model.addAttribute("createUserCode", createUserCode);
        model.addAttribute("shoppingAfterSales", shoppingAfterSales);
        return ModuleConst.MODULE_ROOT +"/cart/afterSalesLook";
    }
    /**
     * 售后申请备注编辑
     */
    @RequestMapping("note")
    public String note(Model model, Long sasiId) {

        String createUserName = LoginUtil.getName();
        String createUserCode = LoginUtil.getAccount();
        ShoppingAfterSalesInfo shoppingAfterSalesInfo = onlineMallLogic.findByInfoId(sasiId);
        model.addAttribute("sasiId", sasiId);
        model.addAttribute("createUserName", createUserName);
        model.addAttribute("createUserCode", createUserCode);
        model.addAttribute("shoppingAfterSalesInfo", shoppingAfterSalesInfo);
        return ModuleConst.MODULE_ROOT +"/cart/note";
    }
    /**
     * 发货单物流页面 packageId :物流单号
     */
    @RequestMapping("orderTrackDetail")
    public String orderTrackDetail(Model model, String packageId) {
        model.addAttribute("packageId", packageId);
        return ModuleConst.MODULE_ROOT +"/cart/orderTrackDetail";
    }

    /**
     * 到收货明细页面
     */
    @RequestMapping("confirmReceipt")
    public String confirmReceipt(Model model, Long cartId) {
        model.addAttribute("cartId", cartId);
        return ModuleConst.MODULE_ROOT +"/cart/confirmReceipt";
    }

    /**
     * 选购商品导入页面
     */
    @RequestMapping("/excel/buy/confirm/page")
    public String excelBuyConfirmPage(Model model){
        return ModuleConst.MODULE_ROOT +"/cart/excel_buy_confirm";
    }


}
