面包店
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.
 
 
 
 
 

72 lines
1.6 KiB

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