package controllers

import (
	"encoding/json"
	"git.rosy.net.cn/baseapi/utils"
	"git.rosy.net.cn/jx-callback/business/jxstore/secretNumber"
	"github.com/astaxie/beego/server/web"
	"io/ioutil"
)

type AliApiController struct {
	web.Controller
}

type CallBack struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
}

func (c *AliApiController) SecretNumberMsg() {
	data, _ := ioutil.ReadAll(c.Ctx.Request.Body)
	values, _ := utils.HTTPBody2Values(data, false)
	mapData := utils.URLValues2Map(values)
	//东西在key上
	var res *secretNumber.SecretNumberMsgRes
	for k, _ := range mapData {
		if err := json.Unmarshal([]byte(k), &res); err == nil {
			secretNumber.CallbackBrandBill(res)
		}
	}
	c.Data["json"] = &CallBack{
		Code: 0,
		Msg:  "成功",
	}
	c.ServeJSON()
}
