func (c *PhotoController) OrderDet() { if c.Ctx.Input.IsGet() { beego.Debug("OrderDet Get") } if c.Ctx.Input.IsPost() { beego.Debug("OrderDet Post") } id := c.Input().Get("id") beego.Debug("id:", id) if len(id) != 0 { porder, err := models.GetPorder(id) if err != nil { beego.Error(err) } c.Data["Porder"] = porder beego.Debug("Porder:", porder) pdetails, err := models.GetPdetails(porder.OpenId, porder.Pnumber) if err != nil { beego.Error(err) } c.Data["Pdetails"] = pdetails beego.Debug("Pdetails:", pdetails) } c.TplName = "porderdet.html" }
func (c *PhotoController) AdminDetails() { bool, username := chackAccount(c.Ctx) if bool { } else { c.Redirect("/admin", 302) return } c.Data["isUser"] = bool c.Data["User"] = username id := c.Input().Get("id") beego.Debug("id:", id) if len(id) != 0 { porder, err := models.GetPorder(id) if err != nil { beego.Error(err) } c.Data["Porder"] = porder beego.Debug("Porder:", porder) pdetails, err := models.GetPdetails(porder.OpenId, porder.Pnumber) if err != nil { beego.Error(err) } c.Data["Pdetails"] = pdetails psize, err := models.GetOnePsize(porder.PsizeId) if err != nil { beego.Error(err) } c.Data["Psize"] = psize ptemp, err := models.GetOnePtemp(porder.PtempId) if err != nil { beego.Error(err) } c.Data["Ptemp"] = ptemp beego.Debug("Ptemp:", ptemp) var photos_i []int64 // beego.Debug(photos) err = json.Unmarshal([]byte(porder.Photos), &photos_i) if err != nil { beego.Error(err) } var photoss []*models.Photos for i := 0; i < len(photos_i); i++ { photos, err := models.GetOnePhotos(photos_i[i]) if err != nil { beego.Error(err) } photoss = append(photoss, photos) } c.Data["Photos"] = photoss } c.TplName = "padmindetails.html" }
func (c *PhotoController) PostAdminUpState() { beego.Debug(c.Input()) request_json := `{"errcode":1,"errmsg":"request_json error"}` if c.Ctx.Input.IsGet() { beego.Debug("PostAadminUpState Get") } if c.Ctx.Input.IsPost() { beego.Debug("PostAadminUpState Post") id := c.Input().Get("id") state := c.Input().Get("state") if len(id) == 0 || len(state) == 0 { request_json = `{"errcode":1,"errmsg":"id or state error"}` c.Ctx.WriteString(request_json) return } porder, err := models.GetPorder(id) if err != nil { beego.Error(err) request_json = `{"errcode":1,"errmsg":"GetPorder error"}` c.Ctx.WriteString(request_json) return } otype := int8(0) det := "类型错误" switch state { case "1": otype = int8(1) det = "订单已经生成,等待客服处理" break case "2": otype = int8(2) det = "客服确认订单" break case "3": otype = int8(3) det = "客服发送物流" break case "4": otype = int8(4) det = "订单完成" break } if otype == int8(0) { request_json = `{"errcode":1,"errmsg":"otype error"}` c.Ctx.WriteString(request_json) return } err = models.UpPorderState(id, state) if err != nil { beego.Error(err) request_json = `{"errcode":1,"errmsg":"UpPorderState error"}` c.Ctx.WriteString(request_json) return } _, err = models.AddPdetails(porder.OpenId, porder.Pnumber, otype, det) if err != nil { beego.Error(err) request_json = `{"errcode":1,"errmsg":"AddPorder error"}` c.Ctx.WriteString(request_json) return } request_json = fmt.Sprintf(`{"errcode":0,"errmsg":"","data":%d}`, otype) beego.Debug("request_json :", request_json) } c.Ctx.WriteString(request_json) }