扫码点餐部分
This commit is contained in:
@@ -3,11 +3,11 @@ package com.chaozhanggui.system.cashierservice.controller;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.chaozhanggui.system.cashierservice.service.CartService;
|
||||
import com.chaozhanggui.system.cashierservice.service.ProductService;
|
||||
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||
import com.chaozhanggui.system.cashierservice.util.TokenUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@@ -22,6 +22,8 @@ public class ProductController {
|
||||
|
||||
@Autowired
|
||||
private ProductService productService;
|
||||
@Autowired
|
||||
private CartService cartService;
|
||||
|
||||
/**
|
||||
* 通过桌码获取shopId
|
||||
@@ -29,12 +31,15 @@ public class ProductController {
|
||||
* @param code
|
||||
* @return shopid
|
||||
*/
|
||||
@RequestMapping("queryShopIdByTableCode")
|
||||
@RequestMapping("queryShop")
|
||||
public Result queryShopIdByTableCode(
|
||||
@RequestHeader("openId") String openId,
|
||||
@RequestHeader("id") String userId,
|
||||
@RequestParam("code") String code) {
|
||||
return productService.queryShopIdByTableCode(userId, openId, code);
|
||||
@RequestParam String lat,
|
||||
@RequestParam String lng,
|
||||
@RequestParam("code") String code
|
||||
) {
|
||||
return productService.queryShopIdByTableCode(userId, openId, code,lat,lng);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,24 +51,39 @@ public class ProductController {
|
||||
@RequestMapping("queryProduct")
|
||||
public Result queryProduct(@RequestBody Map<String, String> map) {
|
||||
|
||||
if (ObjectUtil.isEmpty(map) || map.size() <= 0 || !map.containsKey("code")) {
|
||||
if (ObjectUtil.isEmpty(map) || map.size() <= 0 || !map.containsKey("shopId")) {
|
||||
return Result.fail("参数错误");
|
||||
}
|
||||
return productService.queryProduct(
|
||||
map.get("code").toString(),
|
||||
map.get("shopId").toString(),
|
||||
(map.containsKey("productGroupId") && ObjectUtil.isNotEmpty(map.get("productGroupId"))) ? map.get("productGroupId").toString() : "");
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("queryProductSku")
|
||||
public Result queryProductSku(
|
||||
@RequestParam(value = "code", required = false) String code,
|
||||
@RequestParam("shopId") String shopId,
|
||||
@RequestParam("productId") String productId,
|
||||
@RequestParam("spec_tag") String spec_tag
|
||||
) {
|
||||
return productService.queryProductSku(shopId, productId, spec_tag);
|
||||
return productService.queryProductSku(code,shopId, productId, spec_tag);
|
||||
}
|
||||
|
||||
@PostMapping("addCart")
|
||||
public Result addCart(@RequestBody JSONObject jsonObject) {
|
||||
log.info("添加购物车数据:{}", jsonObject);
|
||||
return cartService.createCart(jsonObject);
|
||||
}
|
||||
|
||||
@PostMapping("cleanCart")
|
||||
public Result cleanCart(@RequestBody JSONObject jsonObject) {
|
||||
log.info("清空购物车数据:{}", jsonObject);
|
||||
cartService.clearCart(jsonObject);
|
||||
return Result.success(CodeEnum.SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 团购商品详情/商品类型为 套餐商品
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user