Commit 73439c0b by 张洪旺

coco

parent 9ce8b24a
......@@ -13,6 +13,8 @@
package cn.freemud.constant;
import cn.freemud.utils.DateTimeUtil;
public class RedisKeyConstant {
/**
* userInfoMap的redisKey前缀
......@@ -51,7 +53,7 @@ public class RedisKeyConstant {
* 支付回掉标记在redis的key前缀
*/
public final static String KGD_PAYMENT_CALLBACK_FMID = "kgd:payment:callback:fmid:";
/**
* 点餐门店绑定的商城门店redis的key前缀
*/
......@@ -67,4 +69,24 @@ public class RedisKeyConstant {
*/
public final static String KGD_SENDPOINT_ORDERID = "kgd:sendpoint:orderid:";
private final static String REDIS_KEY_SEP = ":";
/**
* cocoNotMadeGoods:商户号:门店号:yyyy-MM-dd
*
* @param partnerId
* @param storeId
* @return
*/
public static String notMadeGoodsNumber(String partnerId, String storeId) {
StringBuilder sb = new StringBuilder("cocoNotMadeGoods");
sb.append(REDIS_KEY_SEP);
sb.append(partnerId).append(REDIS_KEY_SEP);
sb.append(storeId).append(REDIS_KEY_SEP);
sb.append(DateTimeUtil.getCurrentDateStr());
return sb.toString();
}
}
package cn.freemud.controller;
import cn.freemud.base.entity.BaseResponse;
import cn.freemud.entities.vo.TakeMealNoticesVO;
import cn.freemud.service.CallerService;
import cn.freemud.utils.ResponseUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 叫号器
*/
@Slf4j
@RequestMapping("/caller")
@RestController
@Validated
public class CallerController {
private CallerService callerService;
public CallerController(CallerService callerService) {
this.callerService = callerService;
}
/**
* 取餐通知
* @return
*/
public BaseResponse takeMealNotices(TakeMealNoticesVO vo){
return callerService.takeMealNotices(vo);
}
}
package cn.freemud.entities.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
/**
* @author freemud
*/
@Getter
@Setter
public class TakeMealNoticesVO {
@ApiModelProperty(value = "商户Id")
private String partnerId;
@ApiModelProperty(value = "门店id")
private String storeCode;
@ApiModelProperty(value = "订单数量")
private Integer orderTotalNum;
@ApiModelProperty(value = "待制作杯数")
private Integer cupTotalNum;
@ApiModelProperty(value = "订单")
private String[] orders;
}
package cn.freemud.service;
import cn.freemud.base.entity.BaseResponse;
import cn.freemud.constant.RedisKeyConstant;
import cn.freemud.entities.vo.TakeMealNoticesVO;
import cn.freemud.utils.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import java.util.concurrent.TimeUnit;
@Service
public class CallerService {
@Autowired
private RedisTemplate redisTemplate;
/**
* 缓存 待制作杯数量
* @param vo
*/
private void cacheTakeMealNotices(TakeMealNoticesVO vo){
String redisKey = RedisKeyConstant.notMadeGoodsNumber(vo.getPartnerId(), vo.getStoreCode());
redisTemplate.boundValueOps(redisKey).set(vo.getCupTotalNum(),1, TimeUnit.DAYS);
}
public BaseResponse takeMealNotices(TakeMealNoticesVO vo){
cacheTakeMealNotices(vo);
//发送取餐通知消息 cc 生态
return ResponseUtil.success();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment