面包店
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

hdl_goods_list.go 1.6 KiB

8 months ago
7 months ago
8 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package goods
  2. import (
  3. "applet/app/admin/md"
  4. svc "applet/app/admin/svc/category"
  5. "applet/app/admin/svc/goods"
  6. "applet/app/e"
  7. "github.com/gin-gonic/gin"
  8. )
  9. // 商品列表接口
  10. func GetMallGoodsList(c *gin.Context) {
  11. var args md.MallGoodsListReq
  12. args.Title = c.Query("title")
  13. args.Name = c.Query("name")
  14. args.CategoryId = c.Query("category_id")
  15. args.SaleState = c.Query("sale_state")
  16. args.PageId = c.Query("page")
  17. args.PageSize = c.Query("limit")
  18. args.SkuCode = c.Query("sku_code")
  19. tree, err := svc.GetAllCategory(c)
  20. data, total, err := goods.GetMallGoodsList(c, &args)
  21. if err != nil {
  22. e.OutErr(c, e.ERR_NO_DATA, err)
  23. return
  24. }
  25. var returnData = map[string]interface{}{
  26. "total": total,
  27. "cateList": tree,
  28. // "dataList": data,
  29. //-1审核拒绝 0审核中 1销售中 2已售罄 3放入仓库 4下架
  30. "stateList": []map[string]interface{}{
  31. {"name": "全部", "value": 99},
  32. {"name": "销售中", "value": 1},
  33. {"name": "已下架", "value": 2},
  34. },
  35. }
  36. if data == nil {
  37. returnData["dataList"] = []string{}
  38. } else {
  39. returnData["dataList"] = data
  40. }
  41. e.OutSuc(c, returnData, nil)
  42. return
  43. }
  44. func CheckSkuCode(c *gin.Context) {
  45. skuCode := c.Query("sku_code")
  46. goodsId := c.DefaultQuery("goods_id", "0")
  47. isHas, err := goods.CheckSkuCode(c, skuCode, goodsId)
  48. if err != nil {
  49. e.OutErr(c, e.ERR, err)
  50. return
  51. }
  52. var result = true
  53. if isHas {
  54. result = false
  55. e.OutSuc(c, map[string]interface{}{
  56. "result": result,
  57. "msg": "該sku編碼已存在,請保持唯一性",
  58. }, nil)
  59. return
  60. }
  61. e.OutSuc(c, map[string]interface{}{
  62. "result": result,
  63. "msg": "success",
  64. }, nil)
  65. return
  66. }