package router

import (
	"cold-delivery/app/admin/controller"
	"cold-delivery/common/actions"
	"github.com/gin-gonic/gin"
	jwt "gogs.baozhida.cn/zoie/OAuth-core/pkg/jwtauth"
)

func init() {
	routerCheckRole = append(routerCheckRole, registerWaybillRouter)
	routerNoCheckRole = append(routerNoCheckRole, registerWaybillRouter2)

}

// 派费管理
// 需认证的路由代码
func registerWaybillRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
	cont := controller.WaybillController{}
	r := v1.Group("/waybill").Use(authMiddleware.MiddlewareFunc()).Use(actions.PermissionAction())
	{
		r.GET("", cont.GetPage)
		r.GET("/:id", cont.Get)
		r.POST("", cont.Insert)
		r.POST("/delivery", cont.Delivery)
		r.POST("/packing", cont.Packing) // 待取药装箱
		r.PUT("", cont.Update)
		r.DELETE("", cont.Delete)
		r.PUT("/adminaudit", cont.AdminAudit)             //管理员审核订单
		r.POST("/receipt", cont.Receipt)                  // 签收
		r.GET("/customer", cont.GetCustomerPage)          // 客户下单列表
		r.POST("/customer", cont.CustomerInsert)          // 客户下单
		r.PUT("/update-status", cont.UpdateStatus)        // 修改订单状态
		r.PUT("/audit", cont.Audit)                       // 审核订单
		r.GET("/applet", cont.GetAppletPage)              // app 运单列表
		r.GET("/applet-count", cont.GetAppletCount)       // app 运单-统计
		r.POST("/import", cont.Import)                    // 导入运单
		r.GET("/export-template", cont.ExportTemplate)    // 导出运单模板
		r.GET("/home", cont.Home)                         // 首页统计
		r.POST("/user-stats", cont.UserStats)             // 用户运单统计
		r.GET("/export", cont.Export)                     // 运单管理-导出
		r.GET("/customer/export", cont.CustomerExport)    // 客户下单
		r.GET("/temperature-pdf", cont.TemperaturePDF)    // 导出温湿度pdf
		r.GET("/createsole", cont.CreateSole)             // 生成唯一订单编号
		r.PUT("/turnarounds", cont.Turnarounds)           // 订单转门店
		r.POST("/assignment", cont.SecondaryDistribution) // 二次分配订单
	}
}

func registerWaybillRouter2(v1 *gin.RouterGroup) {
	cont := controller.WaybillController{}
	test := controller.CoolerBoxController{}
	r := v1.Group("/waybill")
	{
		r.POST("/customer/receipt", cont.CustomerReceipt) // 客户签收
		r.GET("/no", cont.GetByWaybillNo)
		r.GET("/newlocus", test.GetCoolerBoxNewestLocus)
	}
}
