修改库存
This commit is contained in:
parent
e5f5317f4e
commit
50fa846cf1
|
|
@ -14,6 +14,7 @@ import org.springframework.context.ApplicationContext;
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
import org.springframework.context.annotation.EnableAspectJAutoProxy;
|
||||||
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
|
@ -32,11 +33,14 @@ public class Shell {
|
||||||
SpringApplication springApplication = new SpringApplication(Shell.class);
|
SpringApplication springApplication = new SpringApplication(Shell.class);
|
||||||
springApplication.run(args);
|
springApplication.run(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
RestTemplate restTemplate(){
|
public RestTemplate restTemplate(){
|
||||||
return new RestTemplate();
|
return new RestTemplate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
|
public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
|
||||||
return (args) -> {
|
return (args) -> {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.chaozhanggui.system.cashierservice.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Documented
|
||||||
|
@Inherited
|
||||||
|
public @interface LimitSubmit {
|
||||||
|
String key() ;
|
||||||
|
/**
|
||||||
|
* 默认 10s
|
||||||
|
*/
|
||||||
|
int limit() default 7200;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求完成后 是否一直等待
|
||||||
|
* true则等待
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean needAllWait() default true;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,41 @@
|
||||||
|
package com.chaozhanggui.system.cashierservice.config;
|
||||||
|
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
|
|
||||||
|
import java.net.UnknownHostException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard Redis configuration.
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class RedisConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
//ConditionalOnMissingBean 当没有名称为redisTemplate的对象被创建时,
|
||||||
|
//才去创建redisTemplate对象
|
||||||
|
@ConditionalOnMissingBean(name = "redisTemplate")
|
||||||
|
public RedisTemplate<String, Object> redisTemplate(
|
||||||
|
RedisConnectionFactory redisConnectionFactory)
|
||||||
|
throws UnknownHostException {
|
||||||
|
RedisTemplate<String, Object> template = new RedisTemplate<String, Object>();
|
||||||
|
template.setConnectionFactory(redisConnectionFactory);
|
||||||
|
return template;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnMissingBean(StringRedisTemplate.class)
|
||||||
|
//StringRedisTemplate继承自RedisTemplate<String, String>
|
||||||
|
public StringRedisTemplate stringRedisTemplate(
|
||||||
|
RedisConnectionFactory redisConnectionFactory)
|
||||||
|
throws UnknownHostException {
|
||||||
|
StringRedisTemplate template = new StringRedisTemplate();
|
||||||
|
template.setConnectionFactory(redisConnectionFactory);
|
||||||
|
return template;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.chaozhanggui.system.cashierservice.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.chaozhanggui.system.cashierservice.service.DataService;
|
||||||
|
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@CrossOrigin(origins = "*")
|
||||||
|
@RestController
|
||||||
|
@Slf4j
|
||||||
|
@RequestMapping("data")
|
||||||
|
public class DataController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
DataService dataService;
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "handoverData")
|
||||||
|
public Result handoverData(@RequestHeader("token") String token,
|
||||||
|
@RequestHeader("loginName") String loginName,
|
||||||
|
@RequestHeader("clientType") String clientType,
|
||||||
|
Integer id){
|
||||||
|
return dataService.handoverprintData(token,id);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -129,8 +129,21 @@ public class OrderController {
|
||||||
@RequestMapping(value = "sendMessage")
|
@RequestMapping(value = "sendMessage")
|
||||||
public Result sendMessage(@RequestHeader("token") String token, @RequestHeader("loginName") String loginName,
|
public Result sendMessage(@RequestHeader("token") String token, @RequestHeader("loginName") String loginName,
|
||||||
@RequestHeader("clientType") String clientType,@RequestParam("orderId") String orderId){
|
@RequestHeader("clientType") String clientType,@RequestParam("orderId") String orderId){
|
||||||
|
|
||||||
return orderService.sendMassage(orderId);
|
return orderService.sendMassage(orderId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping(value = "scanSendMessage")
|
||||||
|
public Result scanSendMessage(@RequestHeader("token") String token, @RequestHeader("loginName") String loginName,
|
||||||
|
@RequestHeader("clientType") String clientType,@RequestParam("outNumber") String outNumber,@RequestParam("shopId") String shopId){
|
||||||
|
return orderService.scanSendMessage(outNumber,shopId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping(value = "getsendMessage")
|
||||||
|
public Result getsendMessage(@RequestHeader("token") String token, @RequestHeader("loginName") String loginName,
|
||||||
|
@RequestHeader("clientType") String clientType,@RequestParam("shopId") String shopId,@RequestParam("page") int page,
|
||||||
|
@RequestParam("pageSize") int pageSize){
|
||||||
|
return orderService.getOutNumber(shopId,page,pageSize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.chaozhanggui.system.cashierservice.controller;
|
package com.chaozhanggui.system.cashierservice.controller;
|
||||||
|
|
||||||
|
import com.chaozhanggui.system.cashierservice.annotation.LimitSubmit;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
|
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
|
||||||
import com.chaozhanggui.system.cashierservice.entity.dto.ReturnGroupOrderDto;
|
import com.chaozhanggui.system.cashierservice.entity.dto.ReturnGroupOrderDto;
|
||||||
import com.chaozhanggui.system.cashierservice.service.PayService;
|
import com.chaozhanggui.system.cashierservice.service.PayService;
|
||||||
|
|
@ -47,6 +48,7 @@ public class PayController {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping("scanpay")
|
@RequestMapping("scanpay")
|
||||||
|
@LimitSubmit(key = "scanpay:%s")
|
||||||
public Result scanpay(HttpServletRequest request,
|
public Result scanpay(HttpServletRequest request,
|
||||||
@RequestHeader("token") String token,
|
@RequestHeader("token") String token,
|
||||||
@RequestHeader("loginName") String loginName,
|
@RequestHeader("loginName") String loginName,
|
||||||
|
|
@ -69,6 +71,7 @@ public class PayController {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@GetMapping("accountPay")
|
@GetMapping("accountPay")
|
||||||
|
@LimitSubmit(key = "accountPay:%s")
|
||||||
public Result accountPay(@RequestHeader("token") String token,
|
public Result accountPay(@RequestHeader("token") String token,
|
||||||
@RequestHeader("loginName") String loginName,
|
@RequestHeader("loginName") String loginName,
|
||||||
@RequestHeader("clientType") String clientType,
|
@RequestHeader("clientType") String clientType,
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import org.apache.ibatis.annotations.Param;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@Mapper
|
@Mapper
|
||||||
|
|
@ -32,4 +33,13 @@ public interface TbOrderInfoMapper {
|
||||||
@Param("day") String day, @Param("orderNo") String orderNo);
|
@Param("day") String day, @Param("orderNo") String orderNo);
|
||||||
|
|
||||||
TbOrderInfo selectByTradeAndMasterId(@Param("day")String day, @Param("masterId")String masterId, @Param("shopId")Integer shopId);
|
TbOrderInfo selectByTradeAndMasterId(@Param("day")String day, @Param("masterId")String masterId, @Param("shopId")Integer shopId);
|
||||||
|
|
||||||
|
TbOrderInfo selectByOutNumber(@Param("tradeDay") String tradeDay,@Param("outNumber") String outNumber,@Param("shopId") String shopId);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
TbOrderInfo selectByOutNumberLimit(@Param("outNumber") String outNumber,@Param("shopId") String shopId);
|
||||||
|
|
||||||
|
|
||||||
|
Map<String,String> selectByOrderId(String orderId);
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.chaozhanggui.system.cashierservice.dao;
|
||||||
|
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbOrderOutNumber;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Mapper
|
||||||
|
public interface TbOrderOutNumberMapper {
|
||||||
|
int insert(TbOrderOutNumber record);
|
||||||
|
|
||||||
|
int insertSelective(TbOrderOutNumber record);
|
||||||
|
|
||||||
|
List<TbOrderOutNumber> selectAll(@Param("shopId") String shopId);
|
||||||
|
}
|
||||||
|
|
@ -98,6 +98,8 @@ public class TbOrderInfo implements Serializable {
|
||||||
private String masterId;
|
private String masterId;
|
||||||
private List<TbOrderDetail> detailList;
|
private List<TbOrderDetail> detailList;
|
||||||
|
|
||||||
|
private String outNumber;
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
public TbOrderInfo(){
|
public TbOrderInfo(){
|
||||||
super();
|
super();
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,77 @@
|
||||||
|
package com.chaozhanggui.system.cashierservice.entity;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class TbOrderOutNumber implements Serializable {
|
||||||
|
private String outCode;
|
||||||
|
|
||||||
|
private String shopId;
|
||||||
|
private String productName;
|
||||||
|
|
||||||
|
private String productSku;
|
||||||
|
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public String getOutCode() {
|
||||||
|
return outCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOutCode(String outCode) {
|
||||||
|
this.outCode = outCode == null ? null : outCode.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProductName() {
|
||||||
|
return productName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProductName(String productName) {
|
||||||
|
this.productName = productName == null ? null : productName.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getShopId() {
|
||||||
|
return shopId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShopId(String shopId) {
|
||||||
|
this.shopId = shopId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProductSku() {
|
||||||
|
return productSku;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProductSku(String productSku) {
|
||||||
|
this.productSku = productSku == null ? null : productSku.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status) {
|
||||||
|
this.status = status == null ? null : status.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRemark() {
|
||||||
|
return remark;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRemark(String remark) {
|
||||||
|
this.remark = remark == null ? null : remark.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCreateTime() {
|
||||||
|
return createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreateTime(Date createTime) {
|
||||||
|
this.createTime = createTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -19,6 +19,8 @@ public class TbShopUserFlow implements Serializable {
|
||||||
|
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
|
||||||
|
private String type;
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public Integer getId() {
|
public Integer getId() {
|
||||||
|
|
@ -76,4 +78,12 @@ public class TbShopUserFlow implements Serializable {
|
||||||
public void setCreateTime(Date createTime) {
|
public void setCreateTime(Date createTime) {
|
||||||
this.createTime = createTime;
|
this.createTime = createTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type == null ? null : type.trim();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,161 @@
|
||||||
|
package com.chaozhanggui.system.cashierservice.interceptor;
|
||||||
|
|
||||||
|
import com.chaozhanggui.system.cashierservice.annotation.LimitSubmit;
|
||||||
|
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
||||||
|
import com.chaozhanggui.system.cashierservice.util.RedisUtils;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.aspectj.lang.JoinPoint;
|
||||||
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
|
import org.aspectj.lang.annotation.*;
|
||||||
|
import org.aspectj.lang.reflect.MethodSignature;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.core.LocalVariableTableParameterNameDiscoverer;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Aspect
|
||||||
|
@Slf4j
|
||||||
|
public class LimitSubmitAspect {
|
||||||
|
//封装了redis操作各种方法
|
||||||
|
@Autowired
|
||||||
|
private RedisUtils redisUtil;
|
||||||
|
|
||||||
|
@Pointcut("@annotation(com.chaozhanggui.system.cashierservice.annotation.LimitSubmit)")
|
||||||
|
private void pay() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Pointcut("@annotation(com.chaozhanggui.system.cashierservice.annotation.LimitSubmit)")
|
||||||
|
private void pay1() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Around("pay()")
|
||||||
|
public Object handleSubmit(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||||
|
|
||||||
|
Method method = ((MethodSignature) joinPoint.getSignature()).getMethod();
|
||||||
|
|
||||||
|
Object[] args= joinPoint.getArgs();
|
||||||
|
|
||||||
|
//获取注解信息
|
||||||
|
LimitSubmit limitSubmit = method.getAnnotation(LimitSubmit.class);
|
||||||
|
boolean needAllWait = limitSubmit.needAllWait();
|
||||||
|
String redisKey = limitSubmit.key();
|
||||||
|
|
||||||
|
|
||||||
|
int submitTimeLimiter = limitSubmit.limit();
|
||||||
|
String key = getRedisKey(joinPoint, redisKey, String.valueOf(args[0]));
|
||||||
|
Object result = redisUtil.get(key);
|
||||||
|
log.info("开始锁定资源信息" + key);
|
||||||
|
|
||||||
|
if (result != null) {
|
||||||
|
log.info("锁定的值是" + result.toString());
|
||||||
|
throw new MsgException("正在处理中, 请勿重复操作");
|
||||||
|
}
|
||||||
|
boolean setResult = redisUtil.setIfAbsent(key, String.valueOf(System.currentTimeMillis()), submitTimeLimiter);
|
||||||
|
if (!setResult) {
|
||||||
|
throw new MsgException("1正在处理中, 请勿重复操作");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
Object proceed = joinPoint.proceed();
|
||||||
|
return proceed;
|
||||||
|
} catch (Throwable e) {
|
||||||
|
log.error("Exception in {}.{}() with cause = \'{}\' and exception = \'{}\'", joinPoint.getSignature().getDeclaringTypeName(),
|
||||||
|
joinPoint.getSignature().getName(), e.getCause() != null ? e.getCause() : "NULL", e.getMessage(), e);
|
||||||
|
throw e;
|
||||||
|
} finally {
|
||||||
|
if (!needAllWait) {
|
||||||
|
redisUtil.del(redisKey);
|
||||||
|
log.info("删除后的结果: " + redisUtil.get(redisKey));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@AfterReturning("pay1()")
|
||||||
|
public void AfterReturning(JoinPoint joinPoint) {
|
||||||
|
Method method = ((MethodSignature) joinPoint.getSignature()).getMethod();
|
||||||
|
|
||||||
|
Object[] args= joinPoint.getArgs();
|
||||||
|
LimitSubmit limitSubmit = method.getAnnotation(LimitSubmit.class);
|
||||||
|
String redisKey = limitSubmit.key();
|
||||||
|
String key = getRedisKey1(joinPoint, redisKey, String.valueOf(args[0]));
|
||||||
|
log.info("正常释放了锁资源" + key);
|
||||||
|
// 延时 1s 释放
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
redisUtil.del(key);
|
||||||
|
log.info("删除后的结果: " + redisUtil.get(redisKey));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterThrowing(pointcut = "pay1()", throwing = "ex")
|
||||||
|
public void AfterThrowing(JoinPoint joinPoint, Throwable ex) {
|
||||||
|
|
||||||
|
if (!(ex instanceof MsgException)) {
|
||||||
|
// 抛出的如果不是重复性提交的异常, 则释放锁资源
|
||||||
|
|
||||||
|
Method method = ((MethodSignature) joinPoint.getSignature()).getMethod();
|
||||||
|
LimitSubmit limitSubmit = method.getAnnotation(LimitSubmit.class);
|
||||||
|
String redisKey = limitSubmit.key();
|
||||||
|
Object[] args= joinPoint.getArgs();
|
||||||
|
String key = getRedisKey1(joinPoint, redisKey, String.valueOf(args[0]));
|
||||||
|
log.info("发生异常释放了锁资源" + key);
|
||||||
|
// 延时 1s 释放
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
redisUtil.del(key);
|
||||||
|
log.info("删除后的结果: " + redisUtil.get(redisKey));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支持多参数,从请求参数进行处理
|
||||||
|
*/
|
||||||
|
private String getRedisKey(ProceedingJoinPoint joinPoint, String key, String orderId) {
|
||||||
|
if (key.contains("%s") && orderId != null) {
|
||||||
|
key = String.format(key, orderId);
|
||||||
|
}
|
||||||
|
Method method = ((MethodSignature) joinPoint.getSignature()).getMethod();
|
||||||
|
|
||||||
|
LocalVariableTableParameterNameDiscoverer discoverer = new LocalVariableTableParameterNameDiscoverer();
|
||||||
|
String[] parameterNames = discoverer.getParameterNames(method);
|
||||||
|
if (parameterNames != null) {
|
||||||
|
for (int i = 0; i < parameterNames.length; i++) {
|
||||||
|
String item = parameterNames[i];
|
||||||
|
if (key.contains("#" + item)) {
|
||||||
|
key = key.replace("#" + item, joinPoint.getArgs()[i].toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return key.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getRedisKey1(JoinPoint joinPoint, String key, String orderId) {
|
||||||
|
if (key.contains("%s") && orderId != null) {
|
||||||
|
key = String.format(key, orderId);
|
||||||
|
}
|
||||||
|
Method method = ((MethodSignature) joinPoint.getSignature()).getMethod();
|
||||||
|
|
||||||
|
LocalVariableTableParameterNameDiscoverer discoverer = new LocalVariableTableParameterNameDiscoverer();
|
||||||
|
String[] parameterNames = discoverer.getParameterNames(method);
|
||||||
|
if (parameterNames != null) {
|
||||||
|
for (int i = 0; i < parameterNames.length; i++) {
|
||||||
|
String item = parameterNames[i];
|
||||||
|
if (key.contains("#" + item)) {
|
||||||
|
key = key.replace("#" + item, joinPoint.getArgs()[i].toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return key.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -30,7 +30,7 @@ public class SignInterceptor implements HandlerInterceptor {
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
RedisUtil redisUtil;
|
RedisUtils redisUtil;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -59,7 +59,7 @@ public class SignInterceptor implements HandlerInterceptor {
|
||||||
|
|
||||||
String key=RedisCst.ONLINE_USER.concat(":").concat(clientType).concat(":").concat(loginName);
|
String key=RedisCst.ONLINE_USER.concat(":").concat(clientType).concat(":").concat(loginName);
|
||||||
|
|
||||||
String cacheToken= redisUtil.getMessage(key);
|
String cacheToken= redisUtil.get(key)+"";
|
||||||
if(ObjectUtil.isEmpty(cacheToken)||!cacheToken.equals(token)){
|
if(ObjectUtil.isEmpty(cacheToken)||!cacheToken.equals(token)){
|
||||||
response.setContentType(CONTENT_TYPE);
|
response.setContentType(CONTENT_TYPE);
|
||||||
response.getWriter().print(JSONUtil.toJsonStr(new Result(CodeEnum.TOENNOEXIST)));
|
response.getWriter().print(JSONUtil.toJsonStr(new Result(CodeEnum.TOENNOEXIST)));
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,9 @@ public class WebAppConfigurer implements WebMvcConfigurer {
|
||||||
.excludePathPatterns("/login/login")
|
.excludePathPatterns("/login/login")
|
||||||
.excludePathPatterns("/cloudPrinter/print")
|
.excludePathPatterns("/cloudPrinter/print")
|
||||||
.excludePathPatterns("/cloudPrinter/handoverPrint")
|
.excludePathPatterns("/cloudPrinter/handoverPrint")
|
||||||
|
.excludePathPatterns("/data/handoverData")
|
||||||
|
.excludePathPatterns("/order/scanSendMessage")
|
||||||
|
.excludePathPatterns("/order/getsendMessage")
|
||||||
.excludePathPatterns("/order/sendMessage");
|
.excludePathPatterns("/order/sendMessage");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,8 @@ public class OrderDetailPO implements Serializable {
|
||||||
|
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
private String outNumber;
|
||||||
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class Detail implements Serializable{
|
public static class Detail implements Serializable{
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,7 @@ import java.util.Map;
|
||||||
public class CloudPrinterService {
|
public class CloudPrinterService {
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
TbShopUserMapper tbShopUserMapper;
|
TbShopUserMapper tbShopUserMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private TbOrderInfoMapper tbOrderInfoMapper;
|
private TbOrderInfoMapper tbOrderInfoMapper;
|
||||||
|
|
@ -192,6 +193,7 @@ public class CloudPrinterService {
|
||||||
|
|
||||||
String data= PrinterUtils.getCashPrintData(detailPO,printType,"return");
|
String data= PrinterUtils.getCashPrintData(detailPO,printType,"return");
|
||||||
|
|
||||||
|
|
||||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||||
PrinterUtils.printTickets(voiceJson,1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
PrinterUtils.printTickets(voiceJson,1, Integer.valueOf(printerNum), tbPrintMachineWithBLOBs.getAddress(), data);
|
||||||
}
|
}
|
||||||
|
|
@ -249,6 +251,8 @@ public class CloudPrinterService {
|
||||||
if(ObjectUtil.isNotEmpty(detailList)&&detailList.size()>0){
|
if(ObjectUtil.isNotEmpty(detailList)&&detailList.size()>0){
|
||||||
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getOrderType().equals("miniapp")?orderInfo.getTableName():orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance,(ObjectUtil.isEmpty(orderInfo.getPayType())||ObjectUtil.isNull(orderInfo.getPayType())?"":orderInfo.getPayType() ), "0", detailList,orderInfo.getRemark());
|
OrderDetailPO detailPO = new OrderDetailPO(shopInfo.getShopName(), "普通打印", orderInfo.getOrderType().equals("miniapp")?orderInfo.getTableName():orderInfo.getMasterId(), orderInfo.getOrderNo(), DateUtils.getTime(new Date(orderInfo.getCreatedAt())), "【POS-1】001", orderInfo.getOrderAmount().toPlainString(), balance,(ObjectUtil.isEmpty(orderInfo.getPayType())||ObjectUtil.isNull(orderInfo.getPayType())?"":orderInfo.getPayType() ), "0", detailList,orderInfo.getRemark());
|
||||||
String printType="结算单";
|
String printType="结算单";
|
||||||
|
|
||||||
|
detailPO.setOutNumber(orderInfo.getOutNumber());
|
||||||
if(ispre){
|
if(ispre){
|
||||||
printType="预结算单";
|
printType="预结算单";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,121 @@
|
||||||
|
package com.chaozhanggui.system.cashierservice.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.chaozhanggui.system.cashierservice.dao.*;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.*;
|
||||||
|
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
||||||
|
import com.chaozhanggui.system.cashierservice.model.HandoverInfo;
|
||||||
|
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||||
|
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||||
|
import com.chaozhanggui.system.cashierservice.util.DateUtils;
|
||||||
|
import com.chaozhanggui.system.cashierservice.util.JSONUtil;
|
||||||
|
import com.chaozhanggui.system.cashierservice.util.PrinterUtils;
|
||||||
|
import com.chaozhanggui.system.cashierservice.util.TokenUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class DataService {
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TbPrintMachineMapper tbPrintMachineMapper;
|
||||||
|
@Autowired
|
||||||
|
private TbShopInfoMapper tbShopInfoMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TbmerchantAccountMapper tbmerchantAccountMapper;
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ShopUserDutyMapper shopUserDutyMapper;
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TbPlussShopStaffMapper tbPlussShopStaffMapper;
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
ShopUserDutyPayMapper shopUserDutyPayMapper;
|
||||||
|
|
||||||
|
|
||||||
|
public Result handoverprintData(String token, Integer id){
|
||||||
|
|
||||||
|
|
||||||
|
JSONObject info= TokenUtil.parseParamFromToken(token);
|
||||||
|
MsgException.checkNull(info,"获取信息失败");
|
||||||
|
|
||||||
|
TbmerchantAccount tbmerchantAccount= tbmerchantAccountMapper.selectByPrimaryKey(Integer.valueOf(info.get("accountId").toString()));
|
||||||
|
MsgException.checkNull(tbmerchantAccount,"商户信息不存在");
|
||||||
|
|
||||||
|
TbShopInfo tbShopInfo= tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(tbmerchantAccount.getShopId()));
|
||||||
|
MsgException.checkNull(tbShopInfo,"店铺信息不存在");
|
||||||
|
|
||||||
|
|
||||||
|
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(tbShopInfo.getId());
|
||||||
|
if (ObjectUtil.isEmpty(shopInfo)) {
|
||||||
|
log.error("店铺信息不存在");
|
||||||
|
return Result.fail(CodeEnum.SHOPINFONOEXIST);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ShopUserDuty shopUserDuty=shopUserDutyMapper.selectByPrimaryKey(id);
|
||||||
|
// ShopUserDuty shopUserDuty=shopUserDutyMapper.selectByShopIdAndDay(tbShopInfo.getId(),tradeDay);
|
||||||
|
MsgException.checkNull(shopUserDuty,"交班信息不存在");
|
||||||
|
|
||||||
|
|
||||||
|
TbPlussShopStaff shopStaff= tbPlussShopStaffMapper.selectByPrimaryKey(Integer.valueOf(info.get("staffId").toString()));
|
||||||
|
MsgException.checkNull(shopStaff,"员工信息不存在");
|
||||||
|
|
||||||
|
|
||||||
|
List<HandoverInfo.PayInfo> list=null;
|
||||||
|
List<HandoverInfo.MemberData> memberData=null;
|
||||||
|
List<HandoverInfo.ProductCategory> productCategories=null;
|
||||||
|
List<Map<String,Object>> mapList= shopUserDutyPayMapper.selectByDutyId(shopUserDuty.getId());
|
||||||
|
if(ObjectUtil.isNotEmpty(mapList)&&mapList.size()>0){
|
||||||
|
list= JSONUtil.parseJSONStr2TList(JSONUtil.toJSONString(mapList), HandoverInfo.PayInfo.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
memberData=new ArrayList<>();
|
||||||
|
ShopUserDutyPay shopUserDutyPay=shopUserDutyPayMapper.selectByDuctIdAndType(shopUserDuty.getId(),"deposit");
|
||||||
|
if(ObjectUtil.isNotEmpty(shopUserDutyPay)){
|
||||||
|
memberData.add(new HandoverInfo.MemberData(shopUserDutyPay.getAmount().toPlainString(),"会员卡消费"));
|
||||||
|
}
|
||||||
|
|
||||||
|
memberData.add(new HandoverInfo.MemberData(ObjectUtil.isNull(shopUserDuty.getMemberInAmount())? BigDecimal.ZERO.toPlainString() : shopUserDuty.getMemberInAmount().toPlainString(),"会员卡充值"));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
List<Map<String,Object>> categries= shopUserDutyPayMapper.selectCetoryBydutyId(shopUserDuty.getId());
|
||||||
|
if(ObjectUtil.isNotEmpty(categries)&&categries.size()>0){
|
||||||
|
productCategories=JSONUtil.parseJSONStr2TList(JSONUtil.toJSONString(categries),HandoverInfo.ProductCategory.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
HandoverInfo handoverInfo=new HandoverInfo(tbShopInfo.getShopName(),
|
||||||
|
ObjectUtil.isNotEmpty(shopUserDuty.getLoginTime())? DateUtils.getTime(shopUserDuty.getLoginTime()):null,
|
||||||
|
ObjectUtil.isNotEmpty(shopUserDuty.getLoginOutTime())?DateUtils.getTime(shopUserDuty.getLoginOutTime()):"",
|
||||||
|
ObjectUtil.isNull(shopStaff.getName())?"":shopStaff.getName(),
|
||||||
|
list,memberData,shopUserDuty.getAmount().add(ObjectUtil.isNull(shopUserDuty.getQuickAmount())?BigDecimal.ZERO:shopUserDuty.getQuickAmount()).toPlainString(),
|
||||||
|
"0",
|
||||||
|
shopUserDuty.getAmount().subtract(shopUserDuty.getReturnAmount()).toPlainString(),
|
||||||
|
shopUserDuty.getAmount().add(ObjectUtil.isNull(shopUserDuty.getQuickAmount())?BigDecimal.ZERO:shopUserDuty.getQuickAmount()).toPlainString(),
|
||||||
|
shopUserDuty.getReturnAmount().toPlainString(),
|
||||||
|
shopUserDuty.getOrderNum().toString(),
|
||||||
|
productCategories,ObjectUtil.isNull(shopUserDuty.getQuickAmount())?"0":shopUserDuty.getQuickAmount().toPlainString()
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
|
return Result.success(CodeEnum.SUCCESS,handoverInfo);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -47,7 +47,7 @@ public class DutyService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private CloudPrinterService cloudPrinterService;
|
private CloudPrinterService cloudPrinterService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisUtil redisUtil;
|
private RedisUtils redisUtil;
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void exect(String message) {
|
public void exect(String message) {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||||
import com.chaozhanggui.system.cashierservice.util.MD5Util;
|
import com.chaozhanggui.system.cashierservice.util.MD5Util;
|
||||||
import com.chaozhanggui.system.cashierservice.util.RedisCst;
|
import com.chaozhanggui.system.cashierservice.util.RedisCst;
|
||||||
import com.chaozhanggui.system.cashierservice.util.RedisUtil;
|
import com.chaozhanggui.system.cashierservice.util.RedisUtils;
|
||||||
import com.chaozhanggui.system.cashierservice.util.TokenUtil;
|
import com.chaozhanggui.system.cashierservice.util.TokenUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
@ -46,7 +46,7 @@ public class LoginService {
|
||||||
TbPlussShopStaffMapper tbPlussShopStaffMapper;
|
TbPlussShopStaffMapper tbPlussShopStaffMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
RedisUtil redisUtil;
|
RedisUtils redisUtil;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
TbTokenMapper tbTokenMapper;
|
TbTokenMapper tbTokenMapper;
|
||||||
|
|
@ -115,7 +115,7 @@ public class LoginService {
|
||||||
|
|
||||||
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(account.getShopId()));
|
TbShopInfo shopInfo = tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(account.getShopId()));
|
||||||
|
|
||||||
redisUtil.saveMessage(key, token, 365 * 24 * 60 * 60);
|
redisUtil.set(key, token, 365 * 24 * 60 * 60);
|
||||||
|
|
||||||
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
|
String uuid = UUID.randomUUID().toString().replaceAll("-", "");
|
||||||
|
|
||||||
|
|
@ -133,7 +133,7 @@ public class LoginService {
|
||||||
accountMap.put("shopName", shopInfo.getShopName());
|
accountMap.put("shopName", shopInfo.getShopName());
|
||||||
}
|
}
|
||||||
accountMap.put("uuid", uuid);
|
accountMap.put("uuid", uuid);
|
||||||
redisUtil.saveMessage("CART:UUID:" + account.getShopId().concat(account.getId().toString()), uuid);
|
redisUtil.set("CART:UUID:" + account.getShopId().concat(account.getId().toString()), uuid);
|
||||||
|
|
||||||
return Result.success(CodeEnum.SUCCESS, accountMap);
|
return Result.success(CodeEnum.SUCCESS, accountMap);
|
||||||
}
|
}
|
||||||
|
|
@ -143,17 +143,17 @@ public class LoginService {
|
||||||
|
|
||||||
String key = RedisCst.ONLINE_USER.concat(":").concat(clientType).concat(":").concat(loginName);
|
String key = RedisCst.ONLINE_USER.concat(":").concat(clientType).concat(":").concat(loginName);
|
||||||
|
|
||||||
String cacheToken = redisUtil.getMessage(key);
|
String cacheToken = redisUtil.get(key)+"";
|
||||||
|
|
||||||
TbToken tbToken = tbTokenMapper.selectByToken(token);
|
TbToken tbToken = tbTokenMapper.selectByToken(token);
|
||||||
|
|
||||||
if (ObjectUtil.isEmpty(tbToken)) {
|
if (ObjectUtil.isEmpty(tbToken)) {
|
||||||
redisUtil.deleteByKey(key);
|
redisUtil.del(key);
|
||||||
return Result.fail(USERNOLOGIN);
|
return Result.fail(USERNOLOGIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!"1".equals(tbToken.getStatus()) || "2".equals(tbToken.getStatus()) || "3".equals(tbToken.getStatus())) {
|
if (!"1".equals(tbToken.getStatus()) || "2".equals(tbToken.getStatus()) || "3".equals(tbToken.getStatus())) {
|
||||||
redisUtil.deleteByKey(key);
|
redisUtil.del(key);
|
||||||
return Result.fail(USERNOLOGIN);
|
return Result.fail(USERNOLOGIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -164,7 +164,7 @@ public class LoginService {
|
||||||
if (!cacheToken.equals(token)) {
|
if (!cacheToken.equals(token)) {
|
||||||
return Result.fail(TOKENTERROR);
|
return Result.fail(TOKENTERROR);
|
||||||
}
|
}
|
||||||
redisUtil.deleteByKey(key);
|
redisUtil.del(key);
|
||||||
tbToken.setStatus(status);
|
tbToken.setStatus(status);
|
||||||
tbToken.setUpdateTime(new Date());
|
tbToken.setUpdateTime(new Date());
|
||||||
tbTokenMapper.updateByPrimaryKey(tbToken);
|
tbTokenMapper.updateByPrimaryKey(tbToken);
|
||||||
|
|
|
||||||
|
|
@ -114,8 +114,8 @@ public class MemberService {
|
||||||
|
|
||||||
if (ObjectUtil.isNotNull(tbShopUsers) && ObjectUtil.isNotEmpty(tbShopUsers)) {
|
if (ObjectUtil.isNotNull(tbShopUsers) && ObjectUtil.isNotEmpty(tbShopUsers)) {
|
||||||
TbShopUser tbShopUser = tbShopUsers.get(0);
|
TbShopUser tbShopUser = tbShopUsers.get(0);
|
||||||
String code = RandomUtil.randomNumbers(6);
|
// String code = RandomUtil.randomNumbers(6);
|
||||||
tbShopUser.setCode(code);
|
// tbShopUser.setCode(code);
|
||||||
tbShopUser.setTelephone(phone);
|
tbShopUser.setTelephone(phone);
|
||||||
tbShopUser.setBirthDay(String.valueOf(map.get("birthDay")));
|
tbShopUser.setBirthDay(String.valueOf(map.get("birthDay")));
|
||||||
tbShopUser.setName(String.valueOf(map.get("nickName")));
|
tbShopUser.setName(String.valueOf(map.get("nickName")));
|
||||||
|
|
@ -143,7 +143,7 @@ public class MemberService {
|
||||||
tbShopUser.setName(String.valueOf(map.get("nickName")));
|
tbShopUser.setName(String.valueOf(map.get("nickName")));
|
||||||
tbShopUser.setSex(Byte.parseByte(String.valueOf(map.get("sex"))));
|
tbShopUser.setSex(Byte.parseByte(String.valueOf(map.get("sex"))));
|
||||||
tbShopUser.setLevel(Byte.parseByte(String.valueOf(map.get("level"))));
|
tbShopUser.setLevel(Byte.parseByte(String.valueOf(map.get("level"))));
|
||||||
String code = RandomUtil.randomNumbers(6);
|
String code = RandomUtil.randomNumbers(8);
|
||||||
tbShopUser.setCode(code);
|
tbShopUser.setCode(code);
|
||||||
tbShopUser.setIsVip(Byte.parseByte("1"));
|
tbShopUser.setIsVip(Byte.parseByte("1"));
|
||||||
tbShopUser.setCreatedAt(System.currentTimeMillis());
|
tbShopUser.setCreatedAt(System.currentTimeMillis());
|
||||||
|
|
@ -258,6 +258,7 @@ public class MemberService {
|
||||||
|
|
||||||
TbShopUserFlow flow = new TbShopUserFlow();
|
TbShopUserFlow flow = new TbShopUserFlow();
|
||||||
flow.setShopUserId(shopUser.getId());
|
flow.setShopUserId(shopUser.getId());
|
||||||
|
flow.setType("+");
|
||||||
flow.setBizCode("scanMemberIn");
|
flow.setBizCode("scanMemberIn");
|
||||||
flow.setBizName("会员扫码充值");
|
flow.setBizName("会员扫码充值");
|
||||||
flow.setAmount(amount);
|
flow.setAmount(amount);
|
||||||
|
|
@ -311,6 +312,7 @@ public class MemberService {
|
||||||
TbShopUserFlow flow = new TbShopUserFlow();
|
TbShopUserFlow flow = new TbShopUserFlow();
|
||||||
flow.setShopUserId(shopUser.getId());
|
flow.setShopUserId(shopUser.getId());
|
||||||
flow.setBizCode("scanMemberIn");
|
flow.setBizCode("scanMemberIn");
|
||||||
|
flow.setType("+");
|
||||||
flow.setBizName("线下充值");
|
flow.setBizName("线下充值");
|
||||||
flow.setAmount(amount);
|
flow.setAmount(amount);
|
||||||
flow.setBalance(shopUser.getAmount());
|
flow.setBalance(shopUser.getAmount());
|
||||||
|
|
@ -337,6 +339,7 @@ public class MemberService {
|
||||||
flow = new TbShopUserFlow();
|
flow = new TbShopUserFlow();
|
||||||
flow.setShopUserId(shopUser.getId());
|
flow.setShopUserId(shopUser.getId());
|
||||||
flow.setBizCode("scanMemberAwardIn");
|
flow.setBizCode("scanMemberAwardIn");
|
||||||
|
flow.setType("+");
|
||||||
flow.setBizName("充值活动奖励");
|
flow.setBizName("充值活动奖励");
|
||||||
flow.setAmount(awardAmount);
|
flow.setAmount(awardAmount);
|
||||||
flow.setBalance(shopUser.getAmount());
|
flow.setBalance(shopUser.getAmount());
|
||||||
|
|
@ -421,6 +424,7 @@ public class MemberService {
|
||||||
TbShopUserFlow flow = new TbShopUserFlow();
|
TbShopUserFlow flow = new TbShopUserFlow();
|
||||||
flow.setShopUserId(shopUser.getId());
|
flow.setShopUserId(shopUser.getId());
|
||||||
flow.setBizCode("scanMemberIn");
|
flow.setBizCode("scanMemberIn");
|
||||||
|
flow.setType("+");
|
||||||
flow.setBizName("会员扫码充值");
|
flow.setBizName("会员扫码充值");
|
||||||
flow.setAmount(memberIn.getAmount());
|
flow.setAmount(memberIn.getAmount());
|
||||||
flow.setBalance(shopUser.getAmount());
|
flow.setBalance(shopUser.getAmount());
|
||||||
|
|
@ -448,6 +452,7 @@ public class MemberService {
|
||||||
TbShopUserFlow flow = new TbShopUserFlow();
|
TbShopUserFlow flow = new TbShopUserFlow();
|
||||||
flow.setShopUserId(shopUser.getId());
|
flow.setShopUserId(shopUser.getId());
|
||||||
flow.setBizCode("scanMemberIn");
|
flow.setBizCode("scanMemberIn");
|
||||||
|
flow.setType("+");
|
||||||
flow.setBizName("线下充值");
|
flow.setBizName("线下充值");
|
||||||
flow.setAmount(memberIn.getAmount());
|
flow.setAmount(memberIn.getAmount());
|
||||||
flow.setBalance(shopUser.getAmount());
|
flow.setBalance(shopUser.getAmount());
|
||||||
|
|
@ -474,6 +479,7 @@ public class MemberService {
|
||||||
flow = new TbShopUserFlow();
|
flow = new TbShopUserFlow();
|
||||||
flow.setShopUserId(shopUser.getId());
|
flow.setShopUserId(shopUser.getId());
|
||||||
flow.setBizCode("scanMemberAwardIn");
|
flow.setBizCode("scanMemberAwardIn");
|
||||||
|
flow.setType("+");
|
||||||
flow.setBizName("充值活动奖励");
|
flow.setBizName("充值活动奖励");
|
||||||
flow.setAmount(awardAmount);
|
flow.setAmount(awardAmount);
|
||||||
flow.setBalance(shopUser.getAmount());
|
flow.setBalance(shopUser.getAmount());
|
||||||
|
|
@ -555,6 +561,7 @@ public class MemberService {
|
||||||
TbShopUserFlow flow = new TbShopUserFlow();
|
TbShopUserFlow flow = new TbShopUserFlow();
|
||||||
flow.setShopUserId(shopUser.getId());
|
flow.setShopUserId(shopUser.getId());
|
||||||
flow.setBizCode("cashMemberIn");
|
flow.setBizCode("cashMemberIn");
|
||||||
|
flow.setType("+");
|
||||||
flow.setBizName("线下充值");
|
flow.setBizName("线下充值");
|
||||||
flow.setAmount(amount);
|
flow.setAmount(amount);
|
||||||
flow.setBalance(shopUser.getAmount());
|
flow.setBalance(shopUser.getAmount());
|
||||||
|
|
@ -580,6 +587,7 @@ public class MemberService {
|
||||||
flow = new TbShopUserFlow();
|
flow = new TbShopUserFlow();
|
||||||
flow.setShopUserId(shopUser.getId());
|
flow.setShopUserId(shopUser.getId());
|
||||||
flow.setBizCode("scanMemberAwardIn");
|
flow.setBizCode("scanMemberAwardIn");
|
||||||
|
flow.setType("+");
|
||||||
flow.setBizName("充值活动奖励");
|
flow.setBizName("充值活动奖励");
|
||||||
flow.setAmount(awardAmount);
|
flow.setAmount(awardAmount);
|
||||||
flow.setBalance(shopUser.getAmount());
|
flow.setBalance(shopUser.getAmount());
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||||
import com.chaozhanggui.system.cashierservice.util.DateUtils;
|
import com.chaozhanggui.system.cashierservice.util.DateUtils;
|
||||||
import com.chaozhanggui.system.cashierservice.util.HttpClientUtil;
|
import com.chaozhanggui.system.cashierservice.util.HttpClientUtil;
|
||||||
import com.chaozhanggui.system.cashierservice.util.RedisUtil;
|
import com.chaozhanggui.system.cashierservice.util.RedisUtil;
|
||||||
import com.chaozhanggui.system.cashierservice.util.TokenUtil;
|
import com.chaozhanggui.system.cashierservice.util.RedisUtils;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
@ -111,7 +111,7 @@ public class OrderService {
|
||||||
if (StringUtils.isEmpty(masterId)) {
|
if (StringUtils.isEmpty(masterId)) {
|
||||||
boolean flag = redisUtil.exists("SHOP:CODE:" + clientType + ":" + shopId);
|
boolean flag = redisUtil.exists("SHOP:CODE:" + clientType + ":" + shopId);
|
||||||
if (flag) {
|
if (flag) {
|
||||||
String code = redisUtil.getMessage("SHOP:CODE:" + clientType + ":" + shopId);
|
String code = redisUtil.getMessage("SHOP:CODE:" + clientType + ":" + shopId).toString();
|
||||||
Integer foodCode = Integer.valueOf(code) + 1;
|
Integer foodCode = Integer.valueOf(code) + 1;
|
||||||
code = "#" + String.format("%03d", foodCode);
|
code = "#" + String.format("%03d", foodCode);
|
||||||
redisUtil.saveMessage("SHOP:CODE:" + clientType + ":" + shopId, foodCode.toString());
|
redisUtil.saveMessage("SHOP:CODE:" + clientType + ":" + shopId, foodCode.toString());
|
||||||
|
|
@ -205,7 +205,7 @@ public class OrderService {
|
||||||
skuWithBLOBs.setUpdatedAt(System.currentTimeMillis());
|
skuWithBLOBs.setUpdatedAt(System.currentTimeMillis());
|
||||||
tbProductSkuMapper.updateByPrimaryKey(skuWithBLOBs);
|
tbProductSkuMapper.updateByPrimaryKey(skuWithBLOBs);
|
||||||
|
|
||||||
redisUtil.addSet("SHOP:CODE:SET" + clientType + ":" + shopId + ":" + DateUtils.getDay(),masterId.substring(1,masterId.length()));
|
redisUtil.saveMessage("SHOP:CODE:SET" + clientType + ":" + shopId + ":" + DateUtils.getDay(),masterId.substring(1,masterId.length()));
|
||||||
return Result.success(CodeEnum.SUCCESS, masterId);
|
return Result.success(CodeEnum.SUCCESS, masterId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -408,14 +408,14 @@ public class OrderService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized String generateOrderCode(String day, String clientType, String shopId) {
|
public synchronized String generateOrderCode(String day, String clientType, String shopId) {
|
||||||
String code = redisUtil.getMessage("SHOP:CODE:" + clientType + ":" + shopId + ":" + day);
|
String code = redisUtil.getMessage("SHOP:CODE:" + clientType + ":" + shopId + ":" + day)+"";
|
||||||
// 使用顺序递增的计数器生成取餐码
|
// 使用顺序递增的计数器生成取餐码
|
||||||
String orderCode = "";
|
String orderCode = "";
|
||||||
if (StringUtils.isEmpty(code)) {
|
if (StringUtils.isEmpty(code)||"null".equals(code)) {
|
||||||
orderCode = "1";
|
orderCode = "1";
|
||||||
redisUtil.saveMessage("SHOP:CODE:" + clientType + ":" + shopId + ":" + day,"1");
|
redisUtil.saveMessage("SHOP:CODE:" + clientType + ":" + shopId + ":" + day,"1");
|
||||||
} else {
|
} else {
|
||||||
orderCode = code;
|
orderCode =String.valueOf(Integer.valueOf(code)+1);
|
||||||
}
|
}
|
||||||
redisUtil.getIncrNum("SHOP:CODE:" + clientType + ":" + shopId + ":" + day, "2");
|
redisUtil.getIncrNum("SHOP:CODE:" + clientType + ":" + shopId + ":" + day, "2");
|
||||||
boolean flag = redisUtil.execsSet("SHOP:CODE:SET" + clientType + ":" + shopId + ":" + day,orderCode);
|
boolean flag = redisUtil.execsSet("SHOP:CODE:SET" + clientType + ":" + shopId + ":" + day,orderCode);
|
||||||
|
|
@ -430,15 +430,16 @@ public class OrderService {
|
||||||
public Result createCode(String shopId, String clientType, String userId, String type) {
|
public Result createCode(String shopId, String clientType, String userId, String type) {
|
||||||
String day = DateUtils.getDay();
|
String day = DateUtils.getDay();
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
String userCode = redisUtil.getMessage("SHOP:CODE:USER:" + clientType + ":" + shopId + ":" + day + userId);
|
String key="SHOP:CODE:USER:" + clientType + ":" + shopId + ":" + day + userId;
|
||||||
|
String userCode = redisUtil.getMessage(key)+"";
|
||||||
if ("1".equals(type)) {
|
if ("1".equals(type)) {
|
||||||
String code = "#" + generateOrderCode(day, clientType, shopId);
|
String code = "#" + generateOrderCode(day, clientType, shopId);
|
||||||
redisUtil.saveMessage("SHOP:CODE:USER:" + clientType + ":" + shopId + ":" + day + userId, code);
|
redisUtil.saveMessage(key, code);
|
||||||
jsonObject.put("code", code);
|
jsonObject.put("code", code);
|
||||||
} else {
|
} else {
|
||||||
if (StringUtils.isEmpty(userCode)) {
|
if (StringUtils.isEmpty(userCode)||"null".equals(userCode)||"#null".equals(userCode)) {
|
||||||
String code = "#" + generateOrderCode(day, clientType, shopId);
|
String code = "#" + generateOrderCode(day, clientType, shopId);
|
||||||
redisUtil.saveMessage("SHOP:CODE:USER:" + clientType + ":" + shopId + ":" + day + userId, code);
|
redisUtil.saveMessage(key, code);
|
||||||
jsonObject.put("code", code);
|
jsonObject.put("code", code);
|
||||||
} else {
|
} else {
|
||||||
jsonObject.put("code", userCode);
|
jsonObject.put("code", userCode);
|
||||||
|
|
@ -501,7 +502,7 @@ public class OrderService {
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Result cartStatus(Integer shopId, String masterId, String status, String userId, String uuid, String clientType) {
|
public Result cartStatus(Integer shopId, String masterId, String status, String userId, String uuid, String clientType) {
|
||||||
String newUuid = redisUtil.getMessage("CART:UUID:" + shopId + userId);
|
String newUuid = redisUtil.getMessage("CART:UUID:" + shopId + userId)+"";
|
||||||
String day = DateUtils.getDay();
|
String day = DateUtils.getDay();
|
||||||
if ("true".equals(status)) {
|
if ("true".equals(status)) {
|
||||||
List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(masterId, shopId, day, "create", uuid);
|
List<TbCashierCart> list = cashierCartMapper.selectAllCreateOrder(masterId, shopId, day, "create", uuid);
|
||||||
|
|
@ -704,6 +705,8 @@ public class OrderService {
|
||||||
return Result.success(CodeEnum.SUCCESS, pageInfo);
|
return Result.success(CodeEnum.SUCCESS, pageInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
TbShopUserMapper tbShopUserMapper;
|
||||||
public Result orderDetail(Integer shopId, Integer id) {
|
public Result orderDetail(Integer shopId, Integer id) {
|
||||||
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(id);
|
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(id);
|
||||||
if (Objects.nonNull(orderInfo)) {
|
if (Objects.nonNull(orderInfo)) {
|
||||||
|
|
@ -714,7 +717,14 @@ public class OrderService {
|
||||||
if (StringUtils.isNotEmpty(orderInfo.getTableName())){
|
if (StringUtils.isNotEmpty(orderInfo.getTableName())){
|
||||||
orderInfo.setTableId(orderInfo.getTableName());
|
orderInfo.setTableId(orderInfo.getTableName());
|
||||||
}
|
}
|
||||||
orderInfo.setMemberName("");
|
TbShopUser shopUser= tbShopUserMapper.selectByUserIdAndShopId(orderInfo.getMemberId(),orderInfo.getShopId());
|
||||||
|
if(Objects.nonNull(shopUser)&&Objects.nonNull(shopUser.getName())){
|
||||||
|
orderInfo.setMemberName(shopUser.getName());
|
||||||
|
}else {
|
||||||
|
orderInfo.setMemberName("");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return Result.success(CodeEnum.SUCCESS, orderInfo);
|
return Result.success(CodeEnum.SUCCESS, orderInfo);
|
||||||
}
|
}
|
||||||
|
|
@ -928,14 +938,114 @@ public class OrderService {
|
||||||
return Result.success(CodeEnum.SUCCESS);
|
return Result.success(CodeEnum.SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return Result.fail(linkedHashMap.containsKey(resObj.get("errcode")+"")?linkedHashMap.get(resObj.get("errcode")+""):"未知错误");
|
return Result.fail(linkedHashMap.containsKey(resObj.get("errcode")+"")?linkedHashMap.get(resObj.get("errcode")+""):"未知错误");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
TbOrderOutNumberMapper tbOrderOutNumberMapper;
|
||||||
|
public Result scanSendMessage(String outNumber,String shopId){
|
||||||
|
String day = DateUtils.getDay();
|
||||||
|
|
||||||
|
if(ObjectUtil.isEmpty(outNumber)){
|
||||||
|
return Result.fail(CodeEnum.OUTNUMBERNOTEXIST);
|
||||||
|
}
|
||||||
|
TbOrderOutNumber orderOutNumber=new TbOrderOutNumber();
|
||||||
|
String outCode= day.concat("#").concat(outNumber);
|
||||||
|
|
||||||
|
|
||||||
|
TbOrderInfo orderInfo= tbOrderInfoMapper.selectByOutNumber(day,outNumber,shopId);
|
||||||
|
if(Objects.isNull(orderInfo)){
|
||||||
|
orderInfo= tbOrderInfoMapper.selectByOutNumberLimit(outNumber,shopId);
|
||||||
|
if(Objects.isNull(orderInfo)){
|
||||||
|
return Result.fail(CodeEnum.OUTNUMBERERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TbShopInfo shopInfo= tbShopInfoMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getShopId()));
|
||||||
|
|
||||||
|
if(ObjectUtil.isEmpty(shopInfo)){
|
||||||
|
return Result.fail(CodeEnum.SHOPINFONOEXIST);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TbUserInfo userInfo= tbUserInfoMapper.selectByPrimaryKey(Integer.valueOf(orderInfo.getUserId()));
|
||||||
|
if(ObjectUtil.isEmpty(userInfo)||ObjectUtil.isEmpty(userInfo.getMiniAppOpenId())){
|
||||||
|
return Result.fail(CodeEnum.USERNOEXIST);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
JSONObject object= getAccessToken();
|
||||||
|
String accessToken=object.get("access_token")+"";
|
||||||
|
|
||||||
|
JSONObject object1=new JSONObject();
|
||||||
|
|
||||||
|
object1.put("template_id","z0fUG7-jhSfYCrw6poOvSRzh4_hgnPkm_5C7E5s5bCQ");
|
||||||
|
object1.put("touser",userInfo.getMiniAppOpenId());
|
||||||
|
|
||||||
|
|
||||||
|
JSONObject data=new JSONObject();
|
||||||
|
|
||||||
|
JSONObject tabname=new JSONObject();
|
||||||
|
tabname.put("value",orderInfo.getOutNumber());
|
||||||
|
|
||||||
|
|
||||||
|
JSONObject thing21=new JSONObject();
|
||||||
|
thing21.put("value",shopInfo.getShopName());
|
||||||
|
|
||||||
|
|
||||||
|
JSONObject thing8=new JSONObject();
|
||||||
|
thing8.put("value","你的餐品已出餐,请及时取餐。");
|
||||||
|
|
||||||
|
data.put("character_string1",tabname);
|
||||||
|
data.put("thing21",thing21);
|
||||||
|
data.put("thing8",thing8);
|
||||||
|
|
||||||
|
object1.put("data",data);
|
||||||
|
|
||||||
|
object1.put("miniprogram_state","trial");
|
||||||
|
object1.put("lang","zh_CN");
|
||||||
|
|
||||||
|
String response= HttpRequest.post("https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=".concat(accessToken)).body(object1.toString()).execute().body();
|
||||||
|
log.info("返回结果:{}",response);
|
||||||
|
JSONObject resObj=JSONObject.parseObject(response);
|
||||||
|
if(ObjectUtil.isNotEmpty(resObj)&&ObjectUtil.isNotNull(resObj)&&"0".equals(resObj.get("errcode")+"")){
|
||||||
|
|
||||||
|
orderOutNumber.setOutCode(outCode);
|
||||||
|
Map<String,String> map= tbOrderInfoMapper.selectByOrderId(orderInfo.getId().toString());
|
||||||
|
orderOutNumber.setShopId(shopId);
|
||||||
|
orderOutNumber.setProductName(map.containsKey("product_names")?map.get("product_names").substring(0,map.get("product_names").length()-1):"");
|
||||||
|
orderOutNumber.setProductSku(map.containsKey("product_sku_name")?map.get("product_sku_name").substring(0,map.get("product_sku_name").length()-1):"");
|
||||||
|
orderOutNumber.setStatus("0");
|
||||||
|
orderOutNumber.setRemark("成功");
|
||||||
|
orderOutNumber.setCreateTime(new Date());
|
||||||
|
tbOrderOutNumberMapper.insert(orderOutNumber);
|
||||||
|
return Result.success(CodeEnum.SUCCESS);
|
||||||
|
}
|
||||||
|
orderOutNumber.setOutCode(outCode);
|
||||||
|
orderOutNumber.setShopId(shopId);
|
||||||
|
Map<String,String> map= tbOrderInfoMapper.selectByOrderId(orderInfo.getId().toString());
|
||||||
|
orderOutNumber.setProductName(map.containsKey("product_names")?map.get("product_names").substring(0,map.get("product_names").length()-1):"");
|
||||||
|
orderOutNumber.setProductSku(map.containsKey("product_sku_name")?map.get("product_sku_name").substring(0,map.get("product_sku_name").length()-1):"");
|
||||||
|
orderOutNumber.setStatus("1");
|
||||||
|
orderOutNumber.setRemark(linkedHashMap.containsKey(resObj.get("errcode")+"")?linkedHashMap.get(resObj.get("errcode")+""):"未知错误");
|
||||||
|
orderOutNumber.setCreateTime(new Date());
|
||||||
|
tbOrderOutNumberMapper.insert(orderOutNumber);
|
||||||
|
return Result.fail(linkedHashMap.containsKey(resObj.get("errcode")+"")?linkedHashMap.get(resObj.get("errcode")+""):"未知错误");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Result getOutNumber(String shopId,Integer page,Integer pageSize){
|
||||||
|
PageHelper.startPage(page, pageSize);
|
||||||
|
List<TbOrderOutNumber> list= tbOrderOutNumberMapper.selectAll(shopId);
|
||||||
|
PageInfo pageInfo=new PageInfo(list);
|
||||||
|
return Result.success(CodeEnum.SUCCESS,pageInfo);
|
||||||
|
}
|
||||||
|
|
||||||
static LinkedHashMap<String,String> linkedHashMap=new LinkedHashMap<>();
|
static LinkedHashMap<String,String> linkedHashMap=new LinkedHashMap<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|
|
||||||
|
|
@ -484,6 +484,7 @@ public class PayService {
|
||||||
flow.setShopUserId(user.getId());
|
flow.setShopUserId(user.getId());
|
||||||
flow.setBizCode("accountPay");
|
flow.setBizCode("accountPay");
|
||||||
flow.setBizName("会员储值卡支付");
|
flow.setBizName("会员储值卡支付");
|
||||||
|
flow.setType("-");
|
||||||
flow.setAmount(orderInfo.getOrderAmount());
|
flow.setAmount(orderInfo.getOrderAmount());
|
||||||
flow.setBalance(user.getAmount());
|
flow.setBalance(user.getAmount());
|
||||||
flow.setCreateTime(new Date());
|
flow.setCreateTime(new Date());
|
||||||
|
|
@ -568,6 +569,7 @@ public class PayService {
|
||||||
TbShopUserFlow flow = new TbShopUserFlow();
|
TbShopUserFlow flow = new TbShopUserFlow();
|
||||||
flow.setShopUserId(user.getId());
|
flow.setShopUserId(user.getId());
|
||||||
flow.setBizCode("accountPay");
|
flow.setBizCode("accountPay");
|
||||||
|
flow.setType("-");
|
||||||
flow.setBizName("会员储值卡支付");
|
flow.setBizName("会员储值卡支付");
|
||||||
flow.setAmount(orderInfo.getOrderAmount());
|
flow.setAmount(orderInfo.getOrderAmount());
|
||||||
flow.setBalance(user.getAmount());
|
flow.setBalance(user.getAmount());
|
||||||
|
|
@ -860,6 +862,7 @@ public class PayService {
|
||||||
flow.setShopUserId(user.getId());
|
flow.setShopUserId(user.getId());
|
||||||
flow.setBizCode("accountReturnPay");
|
flow.setBizCode("accountReturnPay");
|
||||||
flow.setBizName("会员储值卡退款");
|
flow.setBizName("会员储值卡退款");
|
||||||
|
flow.setType("+");
|
||||||
flow.setAmount(orderInfo.getOrderAmount());
|
flow.setAmount(orderInfo.getOrderAmount());
|
||||||
flow.setBalance(user.getAmount());
|
flow.setBalance(user.getAmount());
|
||||||
flow.setCreateTime(new Date());
|
flow.setCreateTime(new Date());
|
||||||
|
|
@ -1109,6 +1112,7 @@ public class PayService {
|
||||||
flow.setShopUserId(user.getId());
|
flow.setShopUserId(user.getId());
|
||||||
flow.setBizCode("returnGroupOrder");
|
flow.setBizCode("returnGroupOrder");
|
||||||
flow.setBizName("会员储值卡退款");
|
flow.setBizName("会员储值卡退款");
|
||||||
|
flow.setType("+");
|
||||||
flow.setAmount(param.getRefundAmount());
|
flow.setAmount(param.getRefundAmount());
|
||||||
flow.setBalance(user.getAmount());
|
flow.setBalance(user.getAmount());
|
||||||
flow.setCreateTime(new Date());
|
flow.setCreateTime(new Date());
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,14 @@ public enum CodeEnum {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
OUTNUMBERNOTEXIST("100031",false,"取餐码不允许为空","fail"),
|
||||||
|
|
||||||
|
|
||||||
|
OUTNUMBERERROR("100032",false,"错误的取餐码","fail"),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -147,6 +147,10 @@ public class PrinterUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if(Objects.nonNull(detailPO.getOutNumber())){
|
||||||
|
sb.append("<QR>".concat(detailPO.getOutNumber()).concat("</QR><BR>"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
sb.append("<S>打印时间:"+DateUtils.getTime(new Date())+"</S><BR>");
|
sb.append("<S>打印时间:"+DateUtils.getTime(new Date())+"</S><BR>");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,12 +4,16 @@ import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
||||||
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
|
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
|
||||||
import org.springframework.data.redis.serializer.RedisSerializer;
|
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||||
|
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||||
import redis.clients.jedis.JedisPool;
|
import redis.clients.jedis.JedisPool;
|
||||||
import redis.clients.jedis.JedisPoolConfig;
|
import redis.clients.jedis.JedisPoolConfig;
|
||||||
|
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ClassName RedisConfig
|
* @ClassName RedisConfig
|
||||||
* @Author Administrator
|
* @Author Administrator
|
||||||
|
|
@ -80,4 +84,7 @@ public class RedisConfig {
|
||||||
container.setConnectionFactory(connectionFactory);
|
container.setConnectionFactory(connectionFactory);
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,687 @@
|
||||||
|
package com.chaozhanggui.system.cashierservice.util;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
import redis.clients.jedis.Jedis;
|
||||||
|
import redis.clients.jedis.JedisPool;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class RedisUtils {
|
||||||
|
|
||||||
|
@Value("${spring.redis.database}")
|
||||||
|
private int database;
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private JedisPool pool;
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisTemplate<String, Object> redisTemplate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 指定缓存失效时间
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param time 时间(秒)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean expire(String key, long time) {
|
||||||
|
try {
|
||||||
|
if (time > 0) {
|
||||||
|
redisTemplate.expire(key, time, TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据key 获取过期时间
|
||||||
|
*
|
||||||
|
* @param key 键 不能为null
|
||||||
|
* @return 时间(秒) 返回0代表为永久有效
|
||||||
|
*/
|
||||||
|
public long getExpire(String key) {
|
||||||
|
return redisTemplate.getExpire(key, TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断key是否存在
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @return true 存在 false不存在
|
||||||
|
*/
|
||||||
|
public boolean hasKey(String key) {
|
||||||
|
try {
|
||||||
|
return redisTemplate.hasKey(key);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除缓存
|
||||||
|
*
|
||||||
|
* @param key 可以传一个值 或多个
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public void del(String... key) {
|
||||||
|
if (key != null && key.length > 0) {
|
||||||
|
if (key.length == 1) {
|
||||||
|
redisTemplate.delete(key[0]);
|
||||||
|
} else {
|
||||||
|
redisTemplate.delete((Collection<String>) CollectionUtils.arrayToList(key));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================String=============================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 普通缓存获取
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @return 值
|
||||||
|
*/
|
||||||
|
public Object get(String key) {
|
||||||
|
return key == null ? null : redisTemplate.opsForValue().get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 普通缓存放入
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param value 值
|
||||||
|
* @return true成功 false失败
|
||||||
|
*/
|
||||||
|
public boolean set(String key, Object value) {
|
||||||
|
try {
|
||||||
|
redisTemplate.opsForValue().set(key, value);
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 普通缓存放入并设置时间
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param value 值
|
||||||
|
* @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期
|
||||||
|
* @return true成功 false 失败
|
||||||
|
*/
|
||||||
|
public boolean set(String key, Object value, long time) {
|
||||||
|
try {
|
||||||
|
if (time > 0) {
|
||||||
|
redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS);
|
||||||
|
} else {
|
||||||
|
set(key, value);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 递增
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param by 要增加几(大于0)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public long incr(String key, long delta) {
|
||||||
|
if (delta < 0) {
|
||||||
|
throw new RuntimeException("递增因子必须大于0");
|
||||||
|
}
|
||||||
|
return redisTemplate.opsForValue().increment(key, delta);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 递减
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param by 要减少几(小于0)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public long decr(String key, long delta) {
|
||||||
|
if (delta < 0) {
|
||||||
|
throw new RuntimeException("递减因子必须大于0");
|
||||||
|
}
|
||||||
|
return redisTemplate.opsForValue().increment(key, -delta);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================================Map=================================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HashGet
|
||||||
|
*
|
||||||
|
* @param key 键 不能为null
|
||||||
|
* @param item 项 不能为null
|
||||||
|
* @return 值
|
||||||
|
*/
|
||||||
|
public Object hget(String key, String item) {
|
||||||
|
return redisTemplate.opsForHash().get(key, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取hashKey对应的所有键值
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @return 对应的多个键值
|
||||||
|
*/
|
||||||
|
public Map<Object, Object> hmget(String key) {
|
||||||
|
return redisTemplate.opsForHash().entries(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HashSet
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param map 对应多个键值
|
||||||
|
* @return true 成功 false 失败
|
||||||
|
*/
|
||||||
|
public boolean hmset(String key, Map<String, Object> map) {
|
||||||
|
try {
|
||||||
|
redisTemplate.opsForHash().putAll(key, map);
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HashSet 并设置时间
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param map 对应多个键值
|
||||||
|
* @param time 时间(秒)
|
||||||
|
* @return true成功 false失败
|
||||||
|
*/
|
||||||
|
public boolean hmset(String key, Map<String, Object> map, long time) {
|
||||||
|
try {
|
||||||
|
redisTemplate.opsForHash().putAll(key, map);
|
||||||
|
if (time > 0) {
|
||||||
|
expire(key, time);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 向一张hash表中放入数据,如果不存在将创建
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param item 项
|
||||||
|
* @param value 值
|
||||||
|
* @return true 成功 false失败
|
||||||
|
*/
|
||||||
|
public boolean hset(String key, String item, Object value) {
|
||||||
|
try {
|
||||||
|
redisTemplate.opsForHash().put(key, item, value);
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 向一张hash表中放入数据,如果不存在将创建
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param item 项
|
||||||
|
* @param value 值
|
||||||
|
* @param time 时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间
|
||||||
|
* @return true 成功 false失败
|
||||||
|
*/
|
||||||
|
public boolean hset(String key, String item, Object value, long time) {
|
||||||
|
try {
|
||||||
|
redisTemplate.opsForHash().put(key, item, value);
|
||||||
|
if (time > 0) {
|
||||||
|
expire(key, time);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除hash表中的值
|
||||||
|
*
|
||||||
|
* @param key 键 不能为null
|
||||||
|
* @param item 项 可以使多个 不能为null
|
||||||
|
*/
|
||||||
|
public void hdel(String key, Object... item) {
|
||||||
|
redisTemplate.opsForHash().delete(key, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断hash表中是否有该项的值
|
||||||
|
*
|
||||||
|
* @param key 键 不能为null
|
||||||
|
* @param item 项 不能为null
|
||||||
|
* @return true 存在 false不存在
|
||||||
|
*/
|
||||||
|
public boolean hHasKey(String key, String item) {
|
||||||
|
return redisTemplate.opsForHash().hasKey(key, item);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* hash递增 如果不存在,就会创建一个 并把新增后的值返回
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param item 项
|
||||||
|
* @param by 要增加几(大于0)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public double hincr(String key, String item, double by) {
|
||||||
|
return redisTemplate.opsForHash().increment(key, item, by);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* hash递减
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param item 项
|
||||||
|
* @param by 要减少记(小于0)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public double hdecr(String key, String item, double by) {
|
||||||
|
return redisTemplate.opsForHash().increment(key, item, -by);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ============================set=============================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据key获取Set中的所有值
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Set<Object> sGet(String key) {
|
||||||
|
try {
|
||||||
|
return redisTemplate.opsForSet().members(key);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据value从一个set中查询,是否存在
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param value 值
|
||||||
|
* @return true 存在 false不存在
|
||||||
|
*/
|
||||||
|
public boolean sHasKey(String key, Object value) {
|
||||||
|
try {
|
||||||
|
return redisTemplate.opsForSet().isMember(key, value);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将数据放入set缓存
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param values 值 可以是多个
|
||||||
|
* @return 成功个数
|
||||||
|
*/
|
||||||
|
public long sSet(String key, Object... values) {
|
||||||
|
try {
|
||||||
|
return redisTemplate.opsForSet().add(key, values);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将set数据放入缓存
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param time 时间(秒)
|
||||||
|
* @param values 值 可以是多个
|
||||||
|
* @return 成功个数
|
||||||
|
*/
|
||||||
|
public long sSetAndTime(String key, long time, Object... values) {
|
||||||
|
try {
|
||||||
|
Long count = redisTemplate.opsForSet().add(key, values);
|
||||||
|
if (time > 0) {
|
||||||
|
expire(key, time);
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取set缓存的长度
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public long sGetSetSize(String key) {
|
||||||
|
try {
|
||||||
|
return redisTemplate.opsForSet().size(key);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移除值为value的
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param values 值 可以是多个
|
||||||
|
* @return 移除的个数
|
||||||
|
*/
|
||||||
|
public long setRemove(String key, Object... values) {
|
||||||
|
try {
|
||||||
|
Long count = redisTemplate.opsForSet().remove(key, values);
|
||||||
|
return count;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ===============================list=================================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取list缓存的内容
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param start 开始
|
||||||
|
* @param end 结束 0 到 -1代表所有值
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<Object> lGet(String key, long start, long end) {
|
||||||
|
try {
|
||||||
|
return redisTemplate.opsForList().range(key, start, end);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取list缓存的长度
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public long lGetListSize(String key) {
|
||||||
|
try {
|
||||||
|
return redisTemplate.opsForList().size(key);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过索引 获取list中的值
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param index 索引 index>=0时, 0 表头,1 第二个元素,依次类推;index<0时,-1,表尾,-2倒数第二个元素,依次类推
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Object lGetIndex(String key, long index) {
|
||||||
|
try {
|
||||||
|
return redisTemplate.opsForList().index(key, index);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将list放入缓存
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param value 值
|
||||||
|
* @param time 时间(秒)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean lSet(String key, Object value) {
|
||||||
|
try {
|
||||||
|
redisTemplate.opsForList().rightPush(key, value);
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将list放入缓存
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param value 值
|
||||||
|
* @param time 时间(秒)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean lSet(String key, Object value, long time) {
|
||||||
|
try {
|
||||||
|
redisTemplate.opsForList().rightPush(key, value);
|
||||||
|
if (time > 0) {
|
||||||
|
expire(key, time);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将list放入缓存
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param value 值
|
||||||
|
* @param time 时间(秒)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean lSet(String key, List<Object> value) {
|
||||||
|
try {
|
||||||
|
redisTemplate.opsForList().rightPushAll(key, value);
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将list放入缓存
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param value 值
|
||||||
|
* @param time 时间(秒)
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean lSet(String key, List<Object> value, long time) {
|
||||||
|
try {
|
||||||
|
redisTemplate.opsForList().rightPushAll(key, value);
|
||||||
|
if (time > 0) {
|
||||||
|
expire(key, time);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据索引修改list中的某条数据
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param index 索引
|
||||||
|
* @param value 值
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean lUpdateIndex(String key, long index, Object value) {
|
||||||
|
try {
|
||||||
|
redisTemplate.opsForList().set(key, index, value);
|
||||||
|
return true;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移除N个值为value
|
||||||
|
*
|
||||||
|
* @param key 键
|
||||||
|
* @param count 移除多少个
|
||||||
|
* @param value 值
|
||||||
|
* @return 移除的个数
|
||||||
|
*/
|
||||||
|
public long lRemove(String key, long count, Object value) {
|
||||||
|
try {
|
||||||
|
Long remove = redisTemplate.opsForList().remove(key, count, value);
|
||||||
|
return remove;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description 上锁并设置过期时间
|
||||||
|
* @Date 15:09 2023/7/7
|
||||||
|
* @Param [key, value, time]
|
||||||
|
* @return boolean
|
||||||
|
**/
|
||||||
|
public boolean setIfAbsent(String key, Object value, long time) {
|
||||||
|
try {
|
||||||
|
return redisTemplate.opsForValue().setIfAbsent(key, value, time, TimeUnit.SECONDS);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final int REDIS_SUCCESS = 1;
|
||||||
|
public int getIncrNum(String key, String message) {
|
||||||
|
Jedis jedis = null;
|
||||||
|
try {
|
||||||
|
// 从jedis池中获取一个jedis实例
|
||||||
|
jedis = pool.getResource();
|
||||||
|
if (database != 0) {
|
||||||
|
jedis.select(database);
|
||||||
|
}
|
||||||
|
if (message.equals("1")) {
|
||||||
|
jedis.decr(key);
|
||||||
|
} else {
|
||||||
|
jedis.incr(key);
|
||||||
|
}
|
||||||
|
return REDIS_SUCCESS;
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
// 释放对象池,即获取jedis实例使用后要将对象还回去
|
||||||
|
if (jedis != null) {
|
||||||
|
jedis.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return REDIS_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static final int REDIS_FAILED = -1;
|
||||||
|
String secKillScript = "local prodid=KEYS[1];\r\n" +
|
||||||
|
"local usernum=KEYS[2];\r\n" +
|
||||||
|
"local num= redis.call(\"get\" ,prodid);\r\n" +
|
||||||
|
"if tonumber(num)<tonumber(usernum) then \r\n" +
|
||||||
|
" return 0;\r\n" +
|
||||||
|
"end\r\n" +
|
||||||
|
"if tonumber(num)<=0 then \r\n" +
|
||||||
|
" return 0;\r\n" +
|
||||||
|
"else \r\n" +
|
||||||
|
" redis.call(\"DECRBY\",prodid,tonumber(usernum));\r\n" +
|
||||||
|
"end\r\n" +
|
||||||
|
"return 1";
|
||||||
|
public String seckill(String key,String num) {
|
||||||
|
Jedis jedis = null;
|
||||||
|
try {
|
||||||
|
if (StringUtils.isEmpty(key)) {
|
||||||
|
return REDIS_FAILED+"";
|
||||||
|
}
|
||||||
|
// 从jedis池中获取一个jedis实例
|
||||||
|
jedis = pool.getResource();
|
||||||
|
if (database!=0) {
|
||||||
|
jedis.select(database);
|
||||||
|
}
|
||||||
|
Object result = jedis.eval(secKillScript, Arrays.asList( key,num), new ArrayList<>());
|
||||||
|
String reString = String.valueOf(result);
|
||||||
|
return reString;
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
// 释放对象池,即获取jedis实例使用后要将对象还回去
|
||||||
|
// 释放对象池,即获取jedis实例使用后要将对象还回去
|
||||||
|
if (jedis != null) {
|
||||||
|
jedis.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return REDIS_FAILED+"";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除数据
|
||||||
|
* @param key
|
||||||
|
* @param values
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Boolean execsSet(String key,String values){
|
||||||
|
Jedis jedis = null ;
|
||||||
|
try {
|
||||||
|
jedis = pool.getResource();
|
||||||
|
return jedis.sismember(key,values);
|
||||||
|
}catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
// 释放对象池,即获取jedis实例使用后要将对象还回去
|
||||||
|
if (jedis != null) {
|
||||||
|
jedis.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -42,6 +42,9 @@ thirdPay:
|
||||||
payType: fushangtong
|
payType: fushangtong
|
||||||
callBack: https://cashierclient.sxczgkj.cn/cashier-client/notify/notifyPay
|
callBack: https://cashierclient.sxczgkj.cn/cashier-client/notify/notifyPay
|
||||||
url: https://paymentapi.sxczgkj.cn
|
url: https://paymentapi.sxczgkj.cn
|
||||||
|
wx:
|
||||||
|
appId: wxd88fffa983758a30
|
||||||
|
secrete: a34a61adc0602118b49400baa8812454
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@
|
||||||
|
|
||||||
<!-- 要生成的表tableName是数据库中的表名或视图名 domainObjectName是实体类名-->
|
<!-- 要生成的表tableName是数据库中的表名或视图名 domainObjectName是实体类名-->
|
||||||
<!-- <table tableName="%" schema="fycashier" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" ></table>-->
|
<!-- <table tableName="%" schema="fycashier" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" ></table>-->
|
||||||
<table tableName="tb_activate" domainObjectName="TbActivate"
|
<table tableName="tb_order_out_number" domainObjectName="TbOrderOutNumber"
|
||||||
enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"
|
enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"
|
||||||
enableSelectByExample="false" selectByExampleQueryId="false" >
|
enableSelectByExample="false" selectByExampleQueryId="false" >
|
||||||
</table>
|
</table>
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,9 @@
|
||||||
<result column="remark" jdbcType="VARCHAR" property="remark"/>
|
<result column="remark" jdbcType="VARCHAR" property="remark"/>
|
||||||
<result column="master_id" jdbcType="VARCHAR" property="masterId"/>
|
<result column="master_id" jdbcType="VARCHAR" property="masterId"/>
|
||||||
<result column="table_name" jdbcType="VARCHAR" property="tableName"/>
|
<result column="table_name" jdbcType="VARCHAR" property="tableName"/>
|
||||||
|
<result column="out_number" jdbcType="VARCHAR" property="outNumber"/>
|
||||||
|
|
||||||
|
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
id, order_no, settlement_amount, pack_fee, origin_amount, product_amount, amount,
|
id, order_no, settlement_amount, pack_fee, origin_amount, product_amount, amount,
|
||||||
|
|
@ -53,7 +56,7 @@
|
||||||
discount_amount, table_id, small_change, send_type, order_type, product_type, status,
|
discount_amount, table_id, small_change, send_type, order_type, product_type, status,
|
||||||
billing_id, merchant_id, shop_id, is_vip, member_id, user_id, product_score, deduct_score,
|
billing_id, merchant_id, shop_id, is_vip, member_id, user_id, product_score, deduct_score,
|
||||||
user_coupon_id, user_coupon_amount, refund_able, paid_time, is_effect, is_group,
|
user_coupon_id, user_coupon_amount, refund_able, paid_time, is_effect, is_group,
|
||||||
updated_at, `system_time`, created_at, is_accepted, pay_order_no,trade_day,`source`,remark,master_id,`table_name`
|
updated_at, `system_time`, created_at, is_accepted, pay_order_no,trade_day,`source`,remark,master_id,`table_name`,out_number
|
||||||
</sql>
|
</sql>
|
||||||
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||||
select
|
select
|
||||||
|
|
@ -542,4 +545,24 @@
|
||||||
|
|
||||||
select * from tb_order_info where trade_day = #{day} and table_id = #{masterId} and shop_id = #{shopId}
|
select * from tb_order_info where trade_day = #{day} and table_id = #{masterId} and shop_id = #{shopId}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectByOutNumber" resultMap="BaseResultMap">
|
||||||
|
select * from tb_order_info where trade_day = #{tradeDay} and out_number=#{outNumber} and shop_id=#{shopId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectByOutNumberLimit" resultMap="BaseResultMap">
|
||||||
|
select * from tb_order_info where out_number=#{outNumber} and shop_id=#{shopId} order by id desc limit 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectByOrderId" resultType="java.util.Map">
|
||||||
|
SELECT
|
||||||
|
GROUP_CONCAT( d.product_name, ',' ) AS product_names,
|
||||||
|
GROUP_CONCAT( d.product_sku_name, ',' ) AS product_sku_name
|
||||||
|
FROM
|
||||||
|
tb_order_detail d
|
||||||
|
WHERE
|
||||||
|
d.order_id = #{orderId}
|
||||||
|
GROUP BY
|
||||||
|
d.order_id
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
@ -0,0 +1,69 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.chaozhanggui.system.cashierservice.dao.TbOrderOutNumberMapper">
|
||||||
|
<resultMap id="BaseResultMap" type="com.chaozhanggui.system.cashierservice.entity.TbOrderOutNumber">
|
||||||
|
<result column="out_code" jdbcType="VARCHAR" property="outCode" />
|
||||||
|
<result column="shop_id" jdbcType="VARCHAR" property="shopId" />
|
||||||
|
|
||||||
|
<result column="product_name" jdbcType="VARCHAR" property="productName" />
|
||||||
|
<result column="product_sku" jdbcType="VARCHAR" property="productSku" />
|
||||||
|
<result column="status" jdbcType="VARCHAR" property="status" />
|
||||||
|
<result column="remark" jdbcType="VARCHAR" property="remark" />
|
||||||
|
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||||
|
</resultMap>
|
||||||
|
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbOrderOutNumber">
|
||||||
|
insert into tb_order_out_number (out_code,shop_id, product_name, product_sku,
|
||||||
|
status, remark, create_time
|
||||||
|
)
|
||||||
|
values (#{outCode,jdbcType=VARCHAR},#{shopId,jdbcType=VARCHAR} ,#{productName,jdbcType=VARCHAR}, #{productSku,jdbcType=VARCHAR},
|
||||||
|
#{status,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbOrderOutNumber">
|
||||||
|
insert into tb_order_out_number
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="outCode != null">
|
||||||
|
out_code,
|
||||||
|
</if>
|
||||||
|
<if test="productName != null">
|
||||||
|
product_name,
|
||||||
|
</if>
|
||||||
|
<if test="productSku != null">
|
||||||
|
product_sku,
|
||||||
|
</if>
|
||||||
|
<if test="status != null">
|
||||||
|
status,
|
||||||
|
</if>
|
||||||
|
<if test="remark != null">
|
||||||
|
remark,
|
||||||
|
</if>
|
||||||
|
<if test="createTime != null">
|
||||||
|
create_time,
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="outCode != null">
|
||||||
|
#{outCode,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="productName != null">
|
||||||
|
#{productName,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="productSku != null">
|
||||||
|
#{productSku,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="status != null">
|
||||||
|
#{status,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="remark != null">
|
||||||
|
#{remark,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
|
<if test="createTime != null">
|
||||||
|
#{createTime,jdbcType=TIMESTAMP},
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<select id="selectAll" resultMap="BaseResultMap">
|
||||||
|
select * from tb_order_out_number where shop_id=#{shopId} order by create_time desc
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
|
|
@ -9,12 +9,13 @@
|
||||||
<result column="biz_code" jdbcType="VARCHAR" property="bizCode" />
|
<result column="biz_code" jdbcType="VARCHAR" property="bizCode" />
|
||||||
<result column="biz_name" jdbcType="VARCHAR" property="bizName" />
|
<result column="biz_name" jdbcType="VARCHAR" property="bizName" />
|
||||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||||
|
<result column="type" jdbcType="VARCHAR" property="type" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
id, shop_user_id, amount, balance, biz_code, biz_name, create_time
|
id, shop_user_id, amount, balance, biz_code, biz_name, create_time, type
|
||||||
</sql>
|
</sql>
|
||||||
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
|
||||||
select
|
select
|
||||||
<include refid="Base_Column_List" />
|
<include refid="Base_Column_List" />
|
||||||
from tb_shop_user_flow
|
from tb_shop_user_flow
|
||||||
where id = #{id,jdbcType=INTEGER}
|
where id = #{id,jdbcType=INTEGER}
|
||||||
|
|
@ -24,12 +25,12 @@
|
||||||
where id = #{id,jdbcType=INTEGER}
|
where id = #{id,jdbcType=INTEGER}
|
||||||
</delete>
|
</delete>
|
||||||
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopUserFlow">
|
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopUserFlow">
|
||||||
insert into tb_shop_user_flow (id, shop_user_id, amount,
|
insert into tb_shop_user_flow (id, shop_user_id, amount,
|
||||||
balance, biz_code, biz_name,
|
balance, biz_code, biz_name,
|
||||||
create_time)
|
create_time, type)
|
||||||
values (#{id,jdbcType=INTEGER}, #{shopUserId,jdbcType=INTEGER}, #{amount,jdbcType=DECIMAL},
|
values (#{id,jdbcType=INTEGER}, #{shopUserId,jdbcType=INTEGER}, #{amount,jdbcType=DECIMAL},
|
||||||
#{balance,jdbcType=DECIMAL}, #{bizCode,jdbcType=VARCHAR}, #{bizName,jdbcType=VARCHAR},
|
#{balance,jdbcType=DECIMAL}, #{bizCode,jdbcType=VARCHAR}, #{bizName,jdbcType=VARCHAR},
|
||||||
#{createTime,jdbcType=TIMESTAMP})
|
#{createTime,jdbcType=TIMESTAMP}, #{type,jdbcType=VARCHAR})
|
||||||
</insert>
|
</insert>
|
||||||
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopUserFlow">
|
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopUserFlow">
|
||||||
insert into tb_shop_user_flow
|
insert into tb_shop_user_flow
|
||||||
|
|
@ -55,6 +56,9 @@
|
||||||
<if test="createTime != null">
|
<if test="createTime != null">
|
||||||
create_time,
|
create_time,
|
||||||
</if>
|
</if>
|
||||||
|
<if test="type != null">
|
||||||
|
type,
|
||||||
|
</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="id != null">
|
<if test="id != null">
|
||||||
|
|
@ -78,6 +82,9 @@
|
||||||
<if test="createTime != null">
|
<if test="createTime != null">
|
||||||
#{createTime,jdbcType=TIMESTAMP},
|
#{createTime,jdbcType=TIMESTAMP},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="type != null">
|
||||||
|
#{type,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopUserFlow">
|
<update id="updateByPrimaryKeySelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopUserFlow">
|
||||||
|
|
@ -101,31 +108,37 @@
|
||||||
<if test="createTime != null">
|
<if test="createTime != null">
|
||||||
create_time = #{createTime,jdbcType=TIMESTAMP},
|
create_time = #{createTime,jdbcType=TIMESTAMP},
|
||||||
</if>
|
</if>
|
||||||
|
<if test="type != null">
|
||||||
|
type = #{type,jdbcType=VARCHAR},
|
||||||
|
</if>
|
||||||
</set>
|
</set>
|
||||||
where id = #{id,jdbcType=INTEGER}
|
where id = #{id,jdbcType=INTEGER}
|
||||||
</update>
|
</update>
|
||||||
<update id="updateByPrimaryKey" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopUserFlow">
|
<update id="updateByPrimaryKey" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopUserFlow">
|
||||||
update tb_shop_user_flow
|
update tb_shop_user_flow
|
||||||
set shop_user_id = #{shopUserId,jdbcType=INTEGER},
|
set shop_user_id = #{shopUserId,jdbcType=INTEGER},
|
||||||
amount = #{amount,jdbcType=DECIMAL},
|
amount = #{amount,jdbcType=DECIMAL},
|
||||||
balance = #{balance,jdbcType=DECIMAL},
|
balance = #{balance,jdbcType=DECIMAL},
|
||||||
biz_code = #{bizCode,jdbcType=VARCHAR},
|
biz_code = #{bizCode,jdbcType=VARCHAR},
|
||||||
biz_name = #{bizName,jdbcType=VARCHAR},
|
biz_name = #{bizName,jdbcType=VARCHAR},
|
||||||
create_time = #{createTime,jdbcType=TIMESTAMP}
|
create_time = #{createTime,jdbcType=TIMESTAMP},
|
||||||
|
type = #{type,jdbcType=VARCHAR}
|
||||||
where id = #{id,jdbcType=INTEGER}
|
where id = #{id,jdbcType=INTEGER}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<select id="selectByMemberAccountFlow" resultType="java.util.Map">
|
<select id="selectByMemberAccountFlow" resultType="java.util.Map">
|
||||||
|
|
||||||
SELECT
|
SELECT
|
||||||
f.*,
|
f.*,
|
||||||
u.`name`
|
u.`name`
|
||||||
FROM
|
FROM
|
||||||
tb_shop_user_flow f
|
tb_shop_user_flow f
|
||||||
LEFT JOIN tb_shop_user u ON f.shop_user_id = u.id
|
LEFT JOIN tb_shop_user u ON f.shop_user_id = u.id
|
||||||
where 1=1
|
where 1=1
|
||||||
<if test="memberId != null and memberId!=''">
|
<if test="memberId != null and memberId!=''">
|
||||||
and u.id = #{memberId}
|
and u.id = #{memberId}
|
||||||
</if>
|
</if>
|
||||||
order by f.id desc
|
order by f.id desc
|
||||||
</select>
|
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue