根据mac获取门店
This commit is contained in:
		| @ -8,6 +8,7 @@ import cn.iocoder.yudao.module.member.controller.app.diningplates.vo.AppUserInfo | ||||
| import cn.iocoder.yudao.module.member.controller.app.user.vo.AppUserInfoCardVO; | ||||
| import cn.iocoder.yudao.module.member.dal.dataobject.diningplates.DiningPlatesDO; | ||||
| import cn.iocoder.yudao.module.member.service.diningplates.DiningPlatesService; | ||||
| import cn.iocoder.yudao.module.system.api.deviceInfo.DeviceInfoApi; | ||||
| import io.swagger.v3.oas.annotations.Operation; | ||||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
| @ -18,9 +19,11 @@ import org.springframework.web.bind.annotation.RequestMapping; | ||||
| import org.springframework.web.bind.annotation.RestController; | ||||
|  | ||||
| import javax.annotation.Resource; | ||||
| import javax.servlet.http.HttpServletRequest; | ||||
| import javax.validation.Valid; | ||||
| import java.util.List; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||||
| import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||||
|  | ||||
| @Tag(name = "用户 App - 餐盘") | ||||
| @ -32,6 +35,11 @@ public class AppDiningPlatesController { | ||||
|     @Resource | ||||
|     private DiningPlatesService diningPlatesService; | ||||
|  | ||||
|     @Resource | ||||
|     private HttpServletRequest httpServletRequest; | ||||
|  | ||||
|     @Resource | ||||
|     private DeviceInfoApi deviceInfoApi; | ||||
|  | ||||
|     @GetMapping("/list") | ||||
|     @Operation(summary = "获得餐盘列表") | ||||
| @ -55,12 +63,14 @@ public class AppDiningPlatesController { | ||||
|     @GetMapping("/checkBind") | ||||
|     @Operation(summary = "验证餐盘绑定") | ||||
|     public CommonResult<AppUserInfoCardVO> checkBind(String diningPlatesNum,Long storeId) { | ||||
|         storeId  = getCarteen(); | ||||
|         return success(diningPlatesService.appCheckBind(diningPlatesNum,storeId)); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/unbind") | ||||
|     @Operation(summary = "餐盘解绑") | ||||
|     public CommonResult<String> unbind(String diningPlatesNum,Long storeId) { | ||||
|         storeId  = getCarteen(); | ||||
|         diningPlatesService.unbind(diningPlatesNum,storeId); | ||||
|         return success(diningPlatesNum); | ||||
|     } | ||||
| @ -68,6 +78,7 @@ public class AppDiningPlatesController { | ||||
|     @GetMapping("/getUserAndDish") | ||||
|     @Operation(summary = "根据餐盘号获取当前余额") | ||||
|     public CommonResult<AppUserInfo> getMoney(String cId, Long dishesId,Long storeId) { | ||||
|         storeId  = getCarteen(); | ||||
|         return success(diningPlatesService.getMoney(cId,dishesId,storeId)); | ||||
|     } | ||||
|  | ||||
| @ -80,6 +91,7 @@ public class AppDiningPlatesController { | ||||
|     @GetMapping("/checkBindAndUnBind") | ||||
|     @Operation(summary = "餐盘解绑") | ||||
|     public CommonResult<String> checkBindAndUnBind(String diningPlatesNum,Long storeId) { | ||||
|         storeId  = getCarteen(); | ||||
|         String b = diningPlatesService.checkBindAndUnBind(diningPlatesNum, storeId); | ||||
|         CommonResult<String> result = new CommonResult<>(); | ||||
|         result.setCode(200); | ||||
| @ -95,4 +107,16 @@ public class AppDiningPlatesController { | ||||
|     public CommonResult<Long> createDiningPlates(@Valid @RequestBody DiningPlatesSaveReqVO createReqVO) { | ||||
|         return success(diningPlatesService.createDiningPlates(createReqVO)); | ||||
|     } | ||||
|  | ||||
|  | ||||
|     public Long getCarteen() { | ||||
|         try { | ||||
|             String authorization = httpServletRequest.getHeader("Authorization"); | ||||
|             Long carteen = deviceInfoApi.getCarteen(authorization); | ||||
|  | ||||
|             return carteen; | ||||
|         } catch (Exception e) { | ||||
|             throw exception(2000_10_001, "无法获取设备编码"); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @ -11,6 +11,7 @@ import cn.iocoder.yudao.module.member.controller.app.orderdetail.vo.AppOrderDeta | ||||
| import cn.iocoder.yudao.module.member.controller.app.orderdetail.vo.AppOrderDetailSaveReqVO; | ||||
| import cn.iocoder.yudao.module.member.dal.dataobject.orderdetail.OrderDetailDO; | ||||
| import cn.iocoder.yudao.module.member.service.orderdetail.OrderDetailService; | ||||
| import cn.iocoder.yudao.module.system.api.deviceInfo.DeviceInfoApi; | ||||
| import io.swagger.v3.oas.annotations.Operation; | ||||
| import io.swagger.v3.oas.annotations.Parameter; | ||||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||||
| @ -26,11 +27,13 @@ import org.springframework.web.bind.annotation.RequestParam; | ||||
| import org.springframework.web.bind.annotation.RestController; | ||||
|  | ||||
| import javax.annotation.Resource; | ||||
| import javax.servlet.http.HttpServletRequest; | ||||
| import javax.servlet.http.HttpServletResponse; | ||||
| import javax.validation.Valid; | ||||
| import java.io.IOException; | ||||
| import java.util.List; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||||
| import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||||
| import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; | ||||
|  | ||||
| @ -43,9 +46,16 @@ public class AppOrderDetailController { | ||||
|     @Resource | ||||
|     private OrderDetailService orderDetailService; | ||||
|  | ||||
|     @Resource | ||||
|     private HttpServletRequest httpServletRequest; | ||||
|  | ||||
|     @Resource | ||||
|     private DeviceInfoApi deviceInfoApi; | ||||
|  | ||||
|     @PostMapping("/create") | ||||
|     @Operation(summary = "创建订单明细") | ||||
|     public CommonResult<Long> createOrderDetail(@Valid @RequestBody AppOrderDetailSaveReqVO createReqVO) { | ||||
|         createReqVO.setStoreId(getCarteen()); | ||||
|         return success(orderDetailService.createOrderDetail(createReqVO)); | ||||
|     } | ||||
|  | ||||
| @ -95,4 +105,14 @@ public class AppOrderDetailController { | ||||
|                         BeanUtils.toBean(list, OrderDetailRespVO.class)); | ||||
|     } | ||||
|  | ||||
|     public Long getCarteen() { | ||||
|         try { | ||||
|             String authorization = httpServletRequest.getHeader("Authorization"); | ||||
|             Long carteen = deviceInfoApi.getCarteen(authorization); | ||||
|  | ||||
|             return carteen; | ||||
|         } catch (Exception e) { | ||||
|             throw exception(2000_10_001, "无法获取设备编码"); | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 zengtao01
					zengtao01