附近小店
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 

76 satır
1.8 KiB

  1. package svc
  2. import (
  3. "applet/app/db"
  4. "applet/app/e"
  5. "applet/app/utils"
  6. "encoding/json"
  7. "github.com/gin-gonic/gin"
  8. )
  9. func Goods(c *gin.Context) {
  10. var arg map[string]string
  11. if err := c.ShouldBindJSON(&arg); err != nil {
  12. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  13. return
  14. }
  15. goods := db.GetGoods(MasterDb(c), arg)
  16. goodsList := make([]map[string]interface{}, 0)
  17. if goods != nil {
  18. for _, v := range *goods {
  19. speImageList := make([]string, 0)
  20. if v.IsSpeImageOn == 1 {
  21. json.Unmarshal([]byte(v.SpeImages), &speImageList)
  22. }
  23. tmp := map[string]interface{}{
  24. "id": utils.IntToStr(v.Id),
  25. "title": v.Title,
  26. "img": v.Img,
  27. "info": v.Info,
  28. "price": v.Price,
  29. "stock": utils.IntToStr(v.Stock),
  30. "is_single_sku": utils.IntToStr(v.IsSingleSku),
  31. "sale_count": utils.IntToStr(v.SaleCount),
  32. "spe_image_list": speImageList,
  33. }
  34. goodsList = append(goodsList, tmp)
  35. }
  36. }
  37. e.OutSuc(c, goodsList, nil)
  38. return
  39. }
  40. func GoodsSku(c *gin.Context) {
  41. var arg map[string]string
  42. if err := c.ShouldBindJSON(&arg); err != nil {
  43. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  44. return
  45. }
  46. sku := db.GetGoodsSku(MasterDb(c), arg["goods_id"])
  47. skuList := make([]map[string]string, 0)
  48. if sku != nil {
  49. for _, v := range *sku {
  50. tmp := map[string]string{
  51. "sku_id": utils.Int64ToStr(v.SkuId),
  52. "goods_id": utils.IntToStr(v.GoodsId),
  53. "price": v.Price,
  54. "stock": utils.IntToStr(v.Stock),
  55. "indexes": v.Indexes,
  56. "sku": v.Sku,
  57. }
  58. skuList = append(skuList, tmp)
  59. }
  60. }
  61. e.OutSuc(c, skuList, nil)
  62. return
  63. }
  64. func GoodsCoupon(c *gin.Context) {
  65. var arg map[string]string
  66. if err := c.ShouldBindJSON(&arg); err != nil {
  67. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  68. return
  69. }
  70. returnData := CommCoupon(c, arg["amount"])
  71. e.OutSuc(c, returnData, nil)
  72. return
  73. }