package logic

import (
	"context"

	"fusenapi/server/home-user-auth/internal/svc"
	"fusenapi/server/home-user-auth/internal/types"
	"fusenapi/utils/auth"
	"fusenapi/utils/basic"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserStatusConfigLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewUserStatusConfigLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserStatusConfigLogic {
	return &UserStatusConfigLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UserStatusConfigLogic) UserStatusConfig(req *types.Request, userinfo *auth.UserInfo) (resp *basic.Response) {
	// 返回值必须调用Set重新返回, resp可以空指针调用 resp.SetStatus(basic.CodeOK, data)

	data := &types.DataStatusConfig{
		SearchList: []types.KeyName{
			{Key: -1, Name: "All"},
			{Key: -1, Name: "All"},
			{Key: 1, Name: "Order Has Been Placed"},
			{Key: 2, Name: "In Production"},
			{Key: 3, Name: "Shipped"},
			{Key: 4, Name: "Inventory"},
			{Key: 8, Name: "Ready for Shipment"},
			{Key: 5, Name: "Completed"},
			// {"key": 6, "name": "Refund Under Review"},
			{Key: 7, Name: "Transaction Closed"},
		},
		OrderStatus: []types.KeyNameButton{
			{Key: 1, Name: "Order Has Been Placed", Button: []string{"download_invoice", "cancel", "again", "toPay"}},
			{Key: 2, Name: "In Production", Button: []string{"download_invoice", "again", "toPay"}},
			{Key: 3, Name: "Shipped", Button: []string{"download_invoice", "again", "view_logistics"}},
			{Key: 5, Name: "Completed", Button: []string{"download_invoice", "again", "view_logistics", "delete"}},

			{Key: 7, Name: "Transaction Closed", Button: []string{"again", "delete"}},
		},

		InventoryStatus: []types.KeyNameButton{
			{Key: 1, Name: "Order Has Been Placed", Button: []string{"download_invoice", "cancel", "again", "toPay"}},
			{Key: 2, Name: "In Production", Button: []string{"download_invoice", "again", "toPay"}},
			{Key: 4, Name: "Inventory", Button: []string{"download_invoice", "again", "go_cloud", "toPay"}},
			{Key: 8, Name: "Ready for Shipment", Button: []string{"download_invoice", "again", "go_cloud", "delete"}},

			{Key: 7, Name: "Transaction Closed", Button: []string{"again", "delete"}},
		},

		Time: []types.KeyName{
			{Key: 0, Name: "All"},
			{Key: 1, Name: "within a month"},
			{Key: 2, Name: "within a quarter"},
			{Key: 3, Name: "Within half a year"},
			{Key: 4, Name: "Within a year"},
		},

		RefundReason: []types.KeyName{
			{Key: 1, Name: "I don't want it anymore"},
			{Key: 2, Name: "no reason"},
			{Key: 3, Name: "other"},
		},
		OrderLogisticsStatus: []types.KeyName{
			{Key: 1, Name: "Order"},
			{Key: 2, Name: "Completed"},
			{Key: 3, Name: "Shipped"},
			{Key: 4, Name: "UPS Pick Up"},
			{Key: 5, Name: "Arrival"},
		},
		InventoryLogisticsStatus: []types.KeyName{
			{Key: 1, Name: "Order"},
			{Key: 2, Name: "Arrival Inventory"},
			{Key: 3, Name: "Ready For Shipment"},
		},
		LogisticsStatus: []types.KeyNameButton{
			{Key: -1, Name: "All", Button: []string{}},
			{Key: 1, Name: "Draw", Button: []string{}},
			{Key: 2, Name: "Shipping", Button: []string{}},

			{Key: 3, Name: "UPS pick up", Button: []string{"check_detail"}},
			{Key: 4, Name: "Arrival", Button: []string{}},
		},
	}

	return resp.SetStatus(basic.CodeOK, data)
}

// [
// 	//返回订单每个状态值
// 	//搜索下拉列表
// 	'search_list' => [
// 		['key' => -1, "name" => 'All'],
// 		['key' => 1, "name" => 'Order Has Been Placed'],
// 		['key' => 2, "name" => 'In Production'],
// 		['key' => 3, "name" => 'Shipped'],
// 		['key' => 4, "name" => 'Inventory'],
// 		['key' => 8, "name" => 'Ready for Shipment'],
// 		['key' => 5, "name" => 'Completed'],
// //                ['key' => 6, "name" => 'Refund Under Review'],
// 		['key' => 7, "name" => 'Transaction Closed'],
// 	],
// 	//直邮单状态
// 	'order_status' => [
// 		['key' => 1, "name" => 'Order Has Been Placed', 'button' => ['download_invoice', 'cancel', 'again', 'toPay']],
// 		['key' => 2, "name" => 'In Production', 'button' => ['download_invoice', 'again', 'toPay']],
// 		['key' => 3, "name" => 'Shipped', 'button' => ['download_invoice', 'again', 'view_logistics']],
// 		['key' => 5, "name" => 'Completed', 'button' => ['download_invoice', 'again', 'view_logistics', 'delete']],
// //                ['key' => 6, "name" => 'Refund Under Review', 'button' => ['again', 'delete']],
// 		['key' => 7, "name" => 'Transaction Closed', 'button' => ['again', 'delete']],
// 	],
// 	//云仓单状态
// 	'Inventory_status' => [
// 		['key' => 1, "name" => 'Order Has Been Placed', 'button' => ['download_invoice', 'cancel', 'again', 'toPay']],
// 		['key' => 2, "name" => 'In Production', 'button' => ['download_invoice', 'again', 'toPay']],
// 		['key' => 4, "name" => 'Inventory', 'button' => ['download_invoice', 'again', 'go_cloud', 'toPay']],
// 		['key' => 8, "name" => 'Ready for Shipment', 'button' => ['download_invoice', 'again', 'go_cloud', 'delete']],
// //                ['key' => 6, "name" => 'Refund Under Review', 'button' => ['again', 'delete']],
// 		['key' => 7, "name" => 'Transaction Closed', 'button' => ['again', 'delete']],
// 	],
// 	//订单物流状态
// 	'order_logistics_status' => Order::$statusFontLogisticOrder,
// 	//订单物流状态
// 	'Inventory_logistics_status' => Order::$statusFontLogisticInventory,
// 	//返回订单时间筛选项
// 	'time' => [
// 		['key' => 0, 'name' => 'All'],
// 		['key' => 1, 'name' => 'within a month'],
// 		['key' => 2, 'name' => 'within a quarter'],
// 		['key' => 3, 'name' => 'Within half a year'],
// 		['key' => 4, 'name' => 'Within a year'],
// 	],
// 	//退款原因说明项
// 	'refund_reason' => [
// 		['key' => 1, 'name' => 'I don\'t want it anymore'],
// 		['key' => 2, 'name' => 'no reason'],
// 		['key' => 3, 'name' => 'other'],
// 	],
// 	//物流状态筛选项
// 	'logistics_status' => [
// 		['key' => -1, "name" => 'All'],
// 		['key' => 1, "name" => 'Draw', 'button' => []],
// 		['key' => 2, "name" => 'Shipping', 'button' => []],
// //                ['key' => Deliver::STATUS_PORT, "name" => 'To the port', 'button' => []],
// 		['key' => 3, "name" => 'UPS pick up', 'button' => ['check_detail']],
// 		['key' => 4, "name" => 'Arrival', 'button' => []],
// 	]
// ];