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

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