package pposRequest

import (
	"PPOSUtils/utils"
	"errors"
	"log"
	"net/url"
	"strings"
	"time"
)

/* 创单 - 参数：子系统ID、订单来源、具体业务类型
 * orderFrom订单来源：1后台/ 2微信/ 3自助机/ 4阿里体育/ 5手持终端/ 6安徽省平台/ 7手环机/ 8小程序/ 9来沪动/
 * businessType 业务类型：具体业务代码 - 参考文档 ppos-pro-doc ...
 */
func (that *PPOSClient) NewOrderCreateRequest(sysID, orderFrom, businessType int64) (*OrderCreateRequest, error) {
	switch sysID {
	case 11:
		if (orderFrom == 1 || orderFrom == 3) && (businessType == 1101 || businessType == 1102) {
			return that.NewCardOpenOrderCreateRequest(), nil //(开卡:一卡通/专项卡)会员订单..【后台】
		}
		if (orderFrom == 1 || orderFrom == 3) && businessType == 1103 {
			return that.NewCardRechargeOrderCreateRequest(), nil //(一卡通充值)会员订单..【后台】
		}
		if orderFrom == 1 && businessType == 1104 {
			return that.NewCardRefundCardOrderCreateRequest(), nil //(退卡)会员订单..【后台】
		}
		if (orderFrom == 1 || orderFrom == 3) && businessType == 1105 {
			return that.NewCardReplaceOrderCreateRequest(), nil //(补卡/换卡)会员订单..【后台】
		}
		if (orderFrom == 1 || orderFrom == 3) && businessType == 1107 {
			return that.NewCardRechargeOrderCreateRequest(), nil //(专项卡充值)会员订单..【后台】
		}
		if orderFrom == 2 && businessType == 1101 {
			return that.NewCardOpenCustomerOrderCreateRequest(), nil //(一卡通开卡)会员订单..【微信端】
		}
		if orderFrom == 2 && businessType == 1102 {
			return that.NewCardOpenCustomerOrderCreateRequest(), nil //(专项卡开卡)会员订单..【微信端】
		}
		if orderFrom == 2 && businessType == 1103 {
			return that.NewCardRechargeCustomerOrderCreateRequest(), nil //(一卡通充值)会员订单..【微信端】
		}
		if orderFrom == 2 && businessType == 1107 {
			return that.NewCardRechargeCustomerOrderCreateRequest(), nil //(专项卡充值)会员订单..【微信端】
		}
	case 12:
		if (orderFrom == 1 || orderFrom == 3 || orderFrom == 9 || orderFrom == 4 || orderFrom == 10) && businessType == 1201 {
			return that.NewTicketOrderCreateRequest(), nil //门票-(销售购票)门票订单..【后台】
		}
		if (orderFrom == 1 || orderFrom == 2 || orderFrom == 3 || orderFrom == 9 || orderFrom == 4) && businessType == 1202 {
			return that.NewTicketRepairOrderCreateRequest(), nil //门票-(超时补票)门票订单..【后台】
		}
		if (orderFrom == 2 || orderFrom == 6) && businessType == 1201 {
			return that.NewTicketCustomerOrderCreateRequest(), nil //门票-(门票预订)门票订单..【微信端】
		}
	case 13:
		if (orderFrom == 1 || orderFrom == 3 || orderFrom == 9 || orderFrom == 4) && businessType == 1301 {
			return that.NewFieldOrderCreateRequest(), nil //场地-(场地预订)场地订单..【后台】
		}
		if (orderFrom == 2 || orderFrom == 6) && businessType == 1301 {
			return that.NewFieldCustomerOrderCreateRequest(), nil //场地-(场地预订)场地订单..【微信端】
		}
	case 14:
		if (orderFrom == 1 || orderFrom == 2) && businessType == 1401 {
			return that.NewGoodsOrderCreateRequest(), nil //商品-(商品销售)商品订单..【后台】
		}
	case 15:
		if orderFrom == 1 && businessType == 1501 {
			return that.NewCosOrderCreateRequest(), nil //通用收款-通用收款订单..【后台】
		}
	case 16:
		if orderFrom == 1 && businessType == 1601 {
			return that.NewEventsOrderCreateRequest(), nil //赛事...【后台】
		}
		if orderFrom == 2 && businessType == 1601 {
			return that.NewWxEventsOrderCreateRequest(), nil //赛事...【微信】
		}
	case 17:
		if (orderFrom == 1 || orderFrom == 2) && businessType == 1701 {
			return that.NewCourseOrderCreateRequest(), nil //课程...【后台】
		}
		if orderFrom == 1 && businessType == 1703 {
			return that.NewClassOrderCreateRequest(), nil //课时,创建订单...【后台】
		}
		if orderFrom == 1 && businessType == 1705 {
			return that.NewClassRechargeCreateRequest(), nil //课时,创建续费订单...【后台】
		}
		if orderFrom == 1 && businessType == 1707 {
			return that.NewRefundCourseCreateOrderRequest(), nil //(退卡)课程订单...【后台】
		}
	case 18:
		if (orderFrom == 1 || orderFrom == 7) && businessType == 1801 {
			return that.NewLeaseOrderCreateRequest(), nil //租赁...【后台】
		}
	case 19:
		if orderFrom == 1 {
			return that.NewMCOrderCreateRequest(), nil //消息...【后台】
		}
	case 20:
		if (orderFrom == 1 || orderFrom == 2) && businessType == 2001 {
			return that.NewJointgoodsOrderCreateRequest(), nil //营销-组合
		}
	case 30:
		if orderFrom == 2 {
			return that.NewActivityApplyOrderCreateRequest(), nil //活动平台【微信端】
		}
	case 40:
		if (orderFrom == 1 || orderFrom == 2 ) && businessType == 4001 {
			return that.NewMmpRechargeOrderCreateRequest(), nil //会员中台-个人现金账户充值订单
		}
		if (orderFrom == 1 || orderFrom == 2 ) && businessType == 4003 {
			return that.NewMmpRechargecardRechargeOrderCreateRequest(), nil //会员中台-个人现金账户充值卡充值订单
		}
		//if orderFrom == 1 && businessType == 4004 {
		//	//会员中台-现金账户余额退还订单..【后台】
		//}
	default:
		return nil, errors.New("暂未实现该业务类型创单接口")
	}
	return nil, errors.New("请检查当前创建订单的业务类型参数是否匹配")
}

//NewCosOrderCreateRequest 创建订单（场地）
func (that *PPOSClient) NewFieldOrderCreateRequest() *OrderCreateRequest {
	return &OrderCreateRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/field/fieldBuyPlan/fieldCreateOrder",
			publicParamsSlice: []string{
				"company_id",
				"business_id",
				"stadium_id",
				"parent_order_no",
				"order_no",
				"sys_id",
				"sku_items",
			},
		},
		SysID: 13,
		bT:    time.Now(),
	}
}

//NewFieldCustomerOrderCreateRequest 创建订单（场地,C端）
func (that *PPOSClient) NewFieldCustomerOrderCreateRequest() *OrderCreateRequest {
	return &OrderCreateRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/field/wxFieldBuyPlan/fieldCreateOrder",
			publicParamsSlice: []string{
				"company_id",
				"business_id",
				"stadium_id",
				"parent_order_no",
				"order_no",
				"sys_id",
				"sku_items",
			},
		},
		SysID: 13,
		bT:    time.Now(),
	}
}

//NewTicketOrderCreateRequest 创建订单（门票）
func (that *PPOSClient) NewTicketOrderCreateRequest() *OrderCreateRequest {
	return &OrderCreateRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/ticket/ticketSale/ticketCreateOrder",
			publicParamsSlice: []string{
				"company_id",
				"business_id",
				"stadium_id",
				"parent_order_no",
				"order_no",
				"sys_id",
				"sku_items",
			},
		},
		SysID: 12,
		bT:    time.Now(),
	}
}

//NewTicketOrderCustomerCreateRequest 创建订单（门票,C端）
func (that *PPOSClient) NewTicketCustomerOrderCreateRequest() *OrderCreateRequest {
	return &OrderCreateRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/ticket/wxTicketSale/ticketCreateOrder",
			publicParamsSlice: []string{
				"company_id",
				"business_id",
				"stadium_id",
				"parent_order_no",
				"order_no",
				"sys_id",
				"sku_items",
			},
		},
		SysID: 12,
		bT:    time.Now(),
	}
}

//NewTicketOrderCreateRequest 创建订单（门票补票）
func (that *PPOSClient) NewTicketRepairOrderCreateRequest() *OrderCreateRequest {
	return &OrderCreateRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/ticket/leaveStadium/repairTicketCreateOrder",
			publicParamsSlice: []string{
				"company_id",
				"business_id",
				"stadium_id",
				"parent_order_no",
				"order_no",
				"sys_id",
				"sku_items",
			},
		},
		SysID: 12,
		bT:    time.Now(),
	}
}

//NewCosOrderCreateRequest 创建订单（商品）
func (that *PPOSClient) NewGoodsOrderCreateRequest() *OrderCreateRequest {
	return &OrderCreateRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/goods/goodsOrder/create",
			publicParamsSlice: []string{
				"company_id",
				"business_id",
				"stadium_id",
				"parent_order_no",
				"order_no",
				"sys_id",
				"sku_items",
			},
		},
		SysID: 14,
		bT:    time.Now(),
	}
}

//NewCardOpenOrderCreateRequest 创建订单（会员开卡）
func (that *PPOSClient) NewCardOpenOrderCreateRequest() *OrderCreateRequest {
	return &OrderCreateRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/cardWork/memberCard/createOrder",
			publicParamsSlice: []string{
				"company_id",
				"business_id",
				"stadium_id",
				"parent_order_no",
				"order_no",
				"sys_id",
				"sku_items",
			},
		},
		SysID: 11,
		bT:    time.Now(),
	}
}

//NewCardOpenCustomerOrderCreateRequest 创建订单（会员开卡，C端）
func (that *PPOSClient) NewCardOpenCustomerOrderCreateRequest() *OrderCreateRequest {
	return &OrderCreateRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/cardWork/wxMemberCard/createOrder",
			publicParamsSlice: []string{
				"company_id",
				"business_id",
				"stadium_id",
				"parent_order_no",
				"order_no",
				"sys_id",
				"sku_items",
			},
		},
		SysID: 11,
		bT:    time.Now(),
	}
}

//NewCardOpenOrderCreateRequest 创建订单（会员卡充值）
func (that *PPOSClient) NewCardRechargeOrderCreateRequest() *OrderCreateRequest {
	return &OrderCreateRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/cardWork/memberCard/createRechargeOrder",
			publicParamsSlice: []string{
				"company_id",
				"business_id",
				"stadium_id",
				"parent_order_no",
				"order_no",
				"sys_id",
				"sku_items",
			},
		},
		SysID: 11,
		bT:    time.Now(),
	}
}

//NewCardRefundCardOrderCreateRequest 创建订单（退卡）
func (that *PPOSClient) NewCardRefundCardOrderCreateRequest() *OrderCreateRequest {
	return &OrderCreateRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/cardWork/memberCard/refundCardCreateOrder",
			publicParamsSlice: []string{
				"company_id",
				"business_id",
				"stadium_id",
				"parent_order_no",
				"order_no",
				"sys_id",
				"sku_items",
			},
		},
		SysID: 11,
		bT:    time.Now(),
	}
}

//NewCardRechargeCustomerOrderCreateRequest 创建订单（会员卡充值，C端）
func (that *PPOSClient) NewCardRechargeCustomerOrderCreateRequest() *OrderCreateRequest {
	return &OrderCreateRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/cardWork/wxMemberCard/createRechargeOrder",
			publicParamsSlice: []string{
				"company_id",
				"business_id",
				"stadium_id",
				"parent_order_no",
				"order_no",
				"sys_id",
				"sku_items",
			},
		},
		SysID: 11,
		bT:    time.Now(),
	}
}

//NewCardReplaceOrderCreateRequest 创建订单（会员卡换卡）
func (that *PPOSClient) NewCardReplaceOrderCreateRequest() *OrderCreateRequest {
	return &OrderCreateRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/cardWork/memberCard/createReplaceOrder",
			publicParamsSlice: []string{
				"company_id",
				"business_id",
				"stadium_id",
				"parent_order_no",
				"order_no",
				"sys_id",
				"sku_items",
			},
		},
		SysID: 11,
		bT:    time.Now(),
	}
}

//NewCosOrderCreateRequest 创建订单（通用收款）
func (that *PPOSClient) NewCosOrderCreateRequest() *OrderCreateRequest {
	return &OrderCreateRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/cos/order/create",
			publicParamsSlice: []string{
				"company_id",
				"business_id",
				"stadium_id",
				"parent_order_no",
				"order_no",
				"sys_id",
				"sku_items",
			},
		},
		SysID: 15,
		bT:    time.Now(),
	}
}

//NewCosOrderCreateRequest 创建订单（赛事活动）
func (that *PPOSClient) NewEventsOrderCreateRequest() *OrderCreateRequest {
	return &OrderCreateRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/events/order/create",
			publicParamsSlice: []string{
				"company_id",
				"business_id",
				"parent_order_no",
				"order_no",
				"sys_id",
				"sku_items",
			},
		},
		SysID: 16,
		bT:    time.Now(),
	}
}

//NewJointgoodsOrderCreateRequest 创建订单（营销-组合收款）
func (that *PPOSClient) NewJointgoodsOrderCreateRequest() *OrderCreateRequest {
	return &OrderCreateRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/marketing/jointgoodsProductSale/jointgoodsProductCreateOrder",
			publicParamsSlice: []string{
				"company_id",
				"business_id",
				"stadium_id",
				"parent_order_no",
				"order_no",
				"sys_id",
				"sku_items",
			},
		},
		SysID: 20,
		bT:    time.Now(),
	}
}

//NewWxEventsOrderCreateRequest 创建订单（赛事微信下单）
func (that *PPOSClient) NewWxEventsOrderCreateRequest() *OrderCreateRequest {
	return &OrderCreateRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/events/order/wxCreate",
			publicParamsSlice: []string{
				"company_id",
				"business_id",
				"parent_order_no",
				"order_no",
				"sys_id",
				"sku_items",
				"order_from",
			},
		},
		SysID: 16,
		bT:    time.Now(),
	}
}

//NewCourseOrderCreateRequest 创建订单（课程）
func (that *PPOSClient) NewCourseOrderCreateRequest() *OrderCreateRequest {
	return &OrderCreateRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/class/courseOrder/create",
			publicParamsSlice: []string{
				"company_id",
				"business_id",
				"stadium_id",
				"parent_order_no",
				"order_no",
				"sys_id",
				"sku_items",
			},
		},
		SysID: 17,
		bT:    time.Now(),
	}
}

//NewClassOrderCreateRequest 创建订单（课时）
func (that *PPOSClient) NewClassOrderCreateRequest() *OrderCreateRequest {
	return &OrderCreateRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/class/classOrder/create",
			publicParamsSlice: []string{
				"company_id",
				"business_id",
				"stadium_id",
				"parent_order_no",
				"order_no",
				"sys_id",
				"sku_items",
			},
		},
		SysID: 17,
		bT:    time.Now(),
	}
}

//NewClassRechargeCreateRequest  创建续费订单（课时）
func (that *PPOSClient) NewClassRechargeCreateRequest() *OrderCreateRequest {
	return &OrderCreateRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/class/courseOrder/createRechargeOrder",
			publicParamsSlice: []string{
				"company_id",
				"business_id",
				"stadium_id",
				"parent_order_no",
				"order_no",
				"sys_id",
				"sku_items",
			},
		},
		SysID: 17,
		bT:    time.Now(),
	}
}

//NewRefundCourseCreateOrderRequest  (退卡)课程订单...【后台】
func (that *PPOSClient) NewRefundCourseCreateOrderRequest() *OrderCreateRequest {
	return &OrderCreateRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/class/courseOrder/refundCourseCreateOrder",
			publicParamsSlice: []string{
				"company_id",
				"business_id",
				"stadium_id",
				"parent_order_no",
				"order_no",
				"sys_id",
				"sku_items",
			},
		},
		SysID: 17,
		bT:    time.Now(),
	}
}

//NewCourseRefundCardCreateOrderRequest  退课订单（课程）
func (that *PPOSClient) NewCourseRefundCardCreateOrderRequest() *OrderCreateRequest {
	return &OrderCreateRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/class/courseOrder/refundCardCreateOrder",
			publicParamsSlice: []string{
				"company_id",
				"business_id",
				"stadium_id",
				"parent_order_no",
				"order_no",
				"sys_id",
				"sku_items",
			},
		},
		SysID: 17,
		bT:    time.Now(),
	}
}

//NewLeaseOrderCreateRequest 创建订单（租赁）
func (that *PPOSClient) NewLeaseOrderCreateRequest() *OrderCreateRequest {
	return &OrderCreateRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/lease/leaseSale/leaseCreateOrder",
			publicParamsSlice: []string{
				"company_id",
				"business_id",
				"stadium_id",
				"parent_order_no",
				"order_no",
				"sys_id",
				"sku_items",
			},
		},
		SysID: 18,
		bT:    time.Now(),
	}
}

//NewMCOrderCreateRequest 创建订单（消息）
func (that *PPOSClient) NewMCOrderCreateRequest() *OrderCreateRequest {
	return &OrderCreateRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/mc/order/create",
			publicParamsSlice: []string{
				"company_id",
				"business_id",
				"stadium_id",
				"parent_order_no",
				"order_no",
				"sys_id",
			},
		},
		SysID: 19,
		bT:    time.Now(),
	}
}

//NewActivityApplyOrderCreateRequest 创建订单（活动平台）
func (that *PPOSClient) NewActivityApplyOrderCreateRequest() *OrderCreateRequest {
	return &OrderCreateRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/activityPlatform/activity/applyOrderCreate",
			publicParamsSlice: []string{
				"company_id",
				"business_id",
				"stadium_id",
				"parent_order_no",
				"order_no",
				"sys_id",
				"sku_items",
			},
		},
		SysID: 18,
		bT:    time.Now(),
	}
}

//NewMmpRechargeOrderCreateRequest 创建订单（会员中台个人现金账户充值）
func (that *PPOSClient) NewMmpRechargeOrderCreateRequest() *OrderCreateRequest {
	return &OrderCreateRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/memberMiddlePlatform/cashOrder/createRechargeOrder",
			publicParamsSlice: []string{
				"company_id",
				"business_id",
				"stadium_id",
				"parent_order_no",
				"order_no",
				"sys_id",
				"sku_items",
			},
		},
		SysID: 40,
		bT:    time.Now(),
	}
}

//NewMmpRechargecardRechargeOrderCreateRequest 创建订单（个人现金账户充值卡充值）
func (that *PPOSClient) NewMmpRechargecardRechargeOrderCreateRequest() *OrderCreateRequest {
	return &OrderCreateRequest{
		Request: Request{
			Client:     that,
			apiAddress: "/memberMiddlePlatform/cashOrder/createRechargeCardOrder",
			publicParamsSlice: []string{
				"company_id",
				"business_id",
				"stadium_id",
				"parent_order_no",
				"order_no",
				"sys_id",
				"sku_items",
			},
		},
		SysID: 40,
		bT:    time.Now(),
	}
}

type OrderCreateRequest struct {
	Request
	SysID    int64            //
	SkuItems map[string]int64 //
	SkuStr   string           //
	bT       time.Time        //耗时时间

}

func (that *OrderCreateRequest) SetParentOrderNo(value int64) *OrderCreateRequest {
	that.initParams()
	that.params.Set("parent_order_no", utils.ToString(value)) //总单号
	return that
}
func (that *OrderCreateRequest) SetSysID(value int64) *OrderCreateRequest {
	that.initParams()
	that.params.Set("sys_id", utils.ToString(value))
	return that
}

//格式sku:num,若多个，用逗号拼接,即sku:num,sku:num,sku:num
func (that *OrderCreateRequest) SetSkuStr(value string) *OrderCreateRequest {
	that.initParams()
	that.params.Set("sku_items", value)
	return that
}

//通用收款的sku数据
func (that *OrderCreateRequest) SetSkuData(value string) *OrderCreateRequest {
	that.initParams()
	that.params.Set("sku_data", value)
	return that
}
func (that *OrderCreateRequest) SetSku(sku string, num int64) *OrderCreateRequest {
	if that.SkuItems == nil {
		that.SkuItems = map[string]int64{}
	}
	that.SkuItems[sku] = num
	return that
}

func (that *OrderCreateRequest) SetOrderNo(orderNo int64) *OrderCreateRequest {
	that.initParams()
	that.params.Set("order_no", utils.ToString(orderNo))
	return that
}

func (that *OrderCreateRequest) SetCustomerInfo(customerInfo string) *OrderCreateRequest {
	that.initParams()
	that.params.Set("customer_info", utils.ToString(customerInfo))
	return that
}

func (that *OrderCreateRequest) SetHandleInfo(handleInfo string) *OrderCreateRequest {
	that.initParams()
	that.params.Set("handle_info", utils.ToString(handleInfo))
	return that
}

func (that *OrderCreateRequest) SetOrderFrom(value int64) *OrderCreateRequest {
	that.initParams()
	that.params.Set("order_from", utils.ToString(value))
	return that
}

func (that *OrderCreateRequest) SetSkuItems(value string) *OrderCreateRequest {
	that.initParams()
	that.params.Set("sku_items", utils.ToString(value))
	return that
}

//Params ...
func (that *OrderCreateRequest) Params() (url.Values, error) {
	that.initParams()
	_params := that.params
	_params.Set("sys_id", utils.ToString(that.SysID))
	if that.SkuItems != nil {
		_itemSlice := []string{}
		for _k, _v := range that.SkuItems {
			_itemSlice = append(_itemSlice, _k+":"+utils.ToString(_v))
		}
		_params.Set("sku_items", strings.Join(_itemSlice, ","))
	}
	//
	if that.publicParamsSlice != nil {
		for _, _v := range that.publicParamsSlice {
			if _params.Get(_v) == "" {
				return nil, errors.New(that.apiAddress + "缺少参数:" + _v)
			}
		}
	}
	return _params, nil
}

//Do ...
func (that *OrderCreateRequest) Do() (*OrderInfoResponse, error) {
	//返回data
	_data, _err := that.GetData(that.apiAddress, that)
	log.Println(that.apiAddress+" 耗时: ", time.Since(that.bT))
	if _err != nil {
		return nil, _err
	}
	_mp, _ok := _data.(map[string]interface{})
	if !_ok {
		return nil, errors.New(that.apiAddress + "请求响应格式不正确,错误代码01")
	}
	_slice := []string{"order", "item", "member_info", "stadium_info"}
	for _, _v := range _slice {
		if _, _ok := _mp[_v]; !_ok {
			return nil, errors.New(that.apiAddress + "请求响应格式不正确,错误代码02")
		}
	}
	//返回结果
	_rs := new(OrderInfoResponse)
	//
	if _, _ok := _mp["stadium_info"].(map[string]interface{}); _ok {
		_stadiumInfo := new(StadiumInfo)
		if _err := that.ParseResponeMp(_stadiumInfo, _mp["stadium_info"], false); _err != nil {
			return nil, errors.New(that.apiAddress + "请求响应格式化异常1:" + _err.Error())
		}
		_rs.StadiumInfo = _stadiumInfo
	}
	//
	if _, _ok := _mp["member_info"].(map[string]interface{}); _ok {
		_memberInfo := new(MemberInfo)
		if _err := that.ParseResponeMp(_memberInfo, _mp["member_info"], false); _err != nil {
			return nil, errors.New(that.apiAddress + "请求响应格式化异常2:" + _err.Error())
		}
		_rs.MemberInfo = _memberInfo
	}
	//
	_orderInfo := new(OrderInfo)
	if _err := that.ParseResponeMp(_orderInfo, _mp["order"], false); _err != nil {
		return nil, errors.New(that.apiAddress + "请求响应格式化异常3:" + _err.Error())
	}
	_rs.Order = _orderInfo
	//
	_itemData, _ok := _mp["item"].([]interface{})
	if !_ok {
		return nil, errors.New(that.apiAddress + "请求响应格式不正确,错误代码01")
	}
	_itemSlice := []*OrderItem{}
	for _, _v := range _itemData {
		_item := new(OrderItem)
		if _err := that.ParseResponeMp(_item, _v, false); _err != nil {
			return nil, errors.New(that.apiAddress + "请求响应格式化异常:" + _err.Error())
		}
		_itemSlice = append(_itemSlice, _item)
	}
	_rs.Item = _itemSlice
	//
	return _rs, nil
}
