package com.ruoyi.model.controller;

import com.cyl.h5.pojo.vo.H5OrderVO;
import com.cyl.h5.service.H5OrderService;
import com.cyl.manager.oms.service.OrderService;
import com.ruoyi.applet.service.IMallOrderService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.model.domain.AppletOrder;
import com.ruoyi.model.domain.AppletOrderItem;
import com.ruoyi.model.service.IAppletOrderItemService;
import com.ruoyi.model.service.IAppletOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 订单信息Controller
 * 
 * @author ruoyi
 * @date 2025-03-28
 */
@RestController
@RequestMapping("/model/AppletOrderItem")
public class AppletOrderItemController extends BaseController
{
    @Autowired
    private IAppletOrderItemService appletOrderItemService;
    @Autowired
    private IMallOrderService mallOrderService;
    //下单小程序：那边来的订单信息
    @Autowired
    private H5OrderService h5OrderService;
    @Autowired
    private OrderService service;

    /**
     * 查询订单信息列表
     */
    @PreAuthorize("@ss.hasPermi('model:AppletOrderItem:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppletOrderItem appletOrderItem)
    {
        startPage();
        List<AppletOrderItem> list = appletOrderItemService.selectAppletOrderItemList(appletOrderItem);
        return getDataTable(list);
    }

    /**
     * 导出订单信息列表
     */
    @PreAuthorize("@ss.hasPermi('model:AppletOrder:export')")
    @Log(title = "订单信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AppletOrderItem appletOrderItem) throws IOException {
        List<AppletOrderItem> list = appletOrderItemService.selectAppletOrderItemList(appletOrderItem);
        ExcelUtil<AppletOrderItem> util = new ExcelUtil<AppletOrderItem>(AppletOrderItem.class);
        util.exportExcel(response, list, "订单信息数据");
    }

    /**
     * 获取订单信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('model:AppletOrder:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(appletOrderItemService.selectAppletOrderItemById(id));
    }

    /**
     * 新增订单信息
     */
    @PreAuthorize("@ss.hasPermi('model:AppletOrderItem:add')")
    @Log(title = "订单信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppletOrderItem appletOrderItem)
    {

        return toAjax(appletOrderItemService.insertAppletOrderItem(appletOrderItem));

    }

    /**
     * 修改订单信息
     */
    @PreAuthorize("@ss.hasPermi('model:AppletOrderItem:edit')")
    @Log(title = "订单信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppletOrderItem appletOrderItem)
    {
        return toAjax(appletOrderItemService.updateAppletOrderItem(appletOrderItem));
    }

    /**
     * 删除订单信息
     */
    @PreAuthorize("@ss.hasPermi('model:AppletOrderItem:remove')")
    @Log(title = "订单信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(appletOrderItemService.deleteAppletOrderItemByIds(ids));
    }
}
