Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
package cn.ysk.cashier.mybatis.entity;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.time.Instant;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "tb_call_queue")
|
||||
public class TbCallQueue {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id", nullable = false)
|
||||
private Integer id;
|
||||
|
||||
@Column(name = "call_table_id")
|
||||
private Integer callTableId;
|
||||
|
||||
@Size(max = 255)
|
||||
@Column(name = "phone")
|
||||
private String phone;
|
||||
|
||||
@Size(max = 255)
|
||||
@Column(name = "name")
|
||||
private String name;
|
||||
|
||||
@Size(max = 255)
|
||||
@Column(name = "shop_name")
|
||||
private String shopName;
|
||||
|
||||
@Column(name = "shop_id")
|
||||
private Integer shopId;
|
||||
|
||||
@Column(name = "state")
|
||||
private Byte state;
|
||||
|
||||
@Column(name = "create_time")
|
||||
private Instant createTime;
|
||||
|
||||
@Column(name = "call_time")
|
||||
private Instant callTime;
|
||||
|
||||
@Column(name = "call_count")
|
||||
private Integer callCount;
|
||||
|
||||
@Column(name = "pass_time")
|
||||
private Instant passTime;
|
||||
|
||||
@Column(name = "cancel_time")
|
||||
private Instant cancelTime;
|
||||
|
||||
@Column(name = "confirm_time")
|
||||
private Instant confirmTime;
|
||||
|
||||
@Size(max = 255)
|
||||
@Column(name = "note")
|
||||
private String note;
|
||||
|
||||
@Column(name = "user_id")
|
||||
private Integer userId;
|
||||
|
||||
@Size(max = 255)
|
||||
@Column(name = "open_id")
|
||||
private String openId;
|
||||
|
||||
@Column(name = "sub_state")
|
||||
private Integer subState;
|
||||
|
||||
@Column(name = "call_num")
|
||||
private String callNum;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package cn.ysk.cashier.mybatis.entity;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.time.Instant;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity
|
||||
@Table(name = "tb_call_table")
|
||||
public class TbCallTable {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id", nullable = false)
|
||||
private Integer id;
|
||||
|
||||
@Size(max = 255)
|
||||
@Column(name = "name")
|
||||
private String name;
|
||||
|
||||
@Size(max = 255)
|
||||
@Column(name = "note")
|
||||
private String note;
|
||||
|
||||
@Column(name = "wait_time")
|
||||
private Integer waitTime;
|
||||
|
||||
@Size(max = 255)
|
||||
@Column(name = "prefix")
|
||||
private String prefix;
|
||||
|
||||
@Column(name = "start")
|
||||
private Integer start;
|
||||
|
||||
@Column(name = "near_num")
|
||||
private Integer nearNum;
|
||||
|
||||
@Column(name = "state")
|
||||
private Byte state;
|
||||
|
||||
@Column(name = "shop_id")
|
||||
private Integer shopId;
|
||||
|
||||
@Size(max = 255)
|
||||
@Column(name = "qrcode")
|
||||
private String qrcode;
|
||||
|
||||
@Column(name = "create_time")
|
||||
private Instant createTime;
|
||||
|
||||
@Column(name = "update_time")
|
||||
private Instant updateTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package cn.ysk.cashier.mybatis.mapper;
|
||||
|
||||
import cn.ysk.cashier.pojo.shop.TbShopArea;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopTable;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
public interface MpShopAreaMapper extends BaseMapper<TbShopArea> {
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package cn.ysk.cashier.mybatis.mapper;
|
||||
|
||||
import cn.ysk.cashier.mybatis.entity.TbCallQueue;
|
||||
import cn.ysk.cashier.mybatis.vo.CallRecordVO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @description 针对表【tb_call_queue】的数据库操作Mapper
|
||||
* @createDate 2024-09-12 15:34:30
|
||||
* @Entity cn.ysk.cashier.mybatis.entity.TbCallQueue
|
||||
*/
|
||||
public interface TbCallQueueMapper extends BaseMapper<TbCallQueue> {
|
||||
|
||||
@Select("select a.*, b.note, TIMESTAMPDIFF(SECOND, a.create_time, NOW()) as since_at from tb_call_queue a " +
|
||||
"left join tb_call_table b on a.call_table_id=b.id " +
|
||||
"where a.shop_id=#{shopId} and a.call_table_id=#{callTableId}")
|
||||
Page<CallRecordVO> selectCallRecord(Integer shopId, Integer callTableId, Page<Object> objectPage);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package cn.ysk.cashier.mybatis.mapper;
|
||||
|
||||
import cn.ysk.cashier.mybatis.entity.TbCallTable;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @description 针对表【tb_call_table】的数据库操作Mapper
|
||||
* @createDate 2024-09-12 15:07:15
|
||||
* @Entity cn.ysk.cashier.mybatis.entity.TbCallTable
|
||||
*/
|
||||
public interface TbCallTableMapper extends BaseMapper<TbCallTable> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author GYJ
|
||||
@@ -41,6 +41,33 @@ public interface TbShopUserFlowMapper extends BaseMapper<TbShopUserFlow> {
|
||||
@Param("startTime") String startTime,
|
||||
@Param("endTime") String endTime);
|
||||
|
||||
@Select("<script>" +
|
||||
"SELECT" +
|
||||
" COALESCE(SUM(CASE WHEN flow.biz_code IN ('cashMemberIn', 'inMoneyIn', 'scanMemberIn') THEN flow.amount ELSE 0 END),0) AS 'inAmount'," +
|
||||
" COALESCE(SUM(CASE WHEN flow.biz_code = 'inMoneyOut' THEN flow.amount ELSE 0 END),0) AS 'outAmount'," +
|
||||
" COALESCE(SUM(CASE WHEN flow.biz_code IN ('accountGroupPay', 'accountPay', 'consumeOut', 'vipCardCash') THEN flow.amount ELSE 0 END),0) AS 'useAmount'," +
|
||||
" COALESCE(COUNT(CASE WHEN flow.biz_code IN ('accountGroupPay', 'accountPay', 'consumeOut', 'vipCardCash') THEN 1 ELSE NULL END),0) AS 'useNum'" +
|
||||
"FROM" +
|
||||
" tb_shop_user_flow flow" +
|
||||
" INNER JOIN tb_shop_user vip ON flow.shop_user_id = vip.id and vip.shop_id= #{shopId} " +
|
||||
"WHERE" +
|
||||
" flow.create_time BETWEEN #{startTime} AND #{endTime} " +
|
||||
"</script>")
|
||||
Map<String, Object> tradeIndexFlow(@Param("shopId") Integer shopId,
|
||||
@Param("startTime") String startTime,
|
||||
@Param("endTime") String endTime);
|
||||
|
||||
@Select("<script>" +
|
||||
"SELECT COALESCE(count(1),0) from( " +
|
||||
" SELECT flow.create_time " +
|
||||
" FROM tb_shop_user_flow flow " +
|
||||
" INNER JOIN tb_shop_user vip ON flow.shop_user_id = vip.id AND vip.shop_id = #{shopId} " +
|
||||
"WHERE biz_code IN ('cashMemberIn', 'inMoneyIn', 'scanMemberIn') " +
|
||||
"GROUP BY " +
|
||||
" shop_user_id) as flows where flows.create_time BETWEEN #{startTime} AND #{endTime}" +
|
||||
"</script>")
|
||||
Integer tradeIndexNewFlow(@Param("shopId") Integer shopId, @Param("startTime") String startTime, @Param("endTime") String endTime);
|
||||
|
||||
|
||||
@Select(value = "select * from tb_shop_user_flow where shop_user_id=#{userId} order by id desc limit #{page},#{size}")
|
||||
List<TbShopUserFlow> selectByUserId(@Param("userId") Integer userId,@Param("page") Integer page,@Param("size") Integer size);
|
||||
|
||||
@@ -1,29 +1,22 @@
|
||||
package cn.ysk.cashier.mybatis.rest;
|
||||
|
||||
import cn.hutool.core.io.IoUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.ysk.cashier.annotation.Log;
|
||||
import cn.ysk.cashier.domain.QiniuContent;
|
||||
import cn.ysk.cashier.exception.BadRequestException;
|
||||
import cn.ysk.cashier.mybatis.entity.Activate;
|
||||
import cn.ysk.cashier.mybatis.service.ShopService;
|
||||
import cn.ysk.cashier.service.QiNiuService;
|
||||
import cn.ysk.cashier.service.WxService;
|
||||
import cn.ysk.cashier.utils.CacheKey;
|
||||
import cn.ysk.cashier.utils.RedisUtils;
|
||||
import cn.ysk.cashier.utils.SecurityUtils;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.gson.JsonObject;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@@ -32,15 +25,9 @@ import java.util.Map;
|
||||
@Api(tags = "/shop/storage")
|
||||
@RequestMapping("/shop/storage")
|
||||
public class StorageController {
|
||||
@Autowired
|
||||
private ShopService shopService;
|
||||
private final ShopService shopService;
|
||||
private final RedisUtils redisUtils;
|
||||
|
||||
private final QiNiuService qiNiuService;
|
||||
private static final String APP_ID = "wxd88fffa983758a30";
|
||||
private static final String APP_SECRET = "a34a61adc0602118b49400baa8812454";
|
||||
private static final String TOKEN_URL = "https://api.weixin.qq.com/cgi-bin/token";
|
||||
private static final String QR_CODE_URL = "https://api.weixin.qq.com/wxa/getwxacode";
|
||||
private final WxService wxService;
|
||||
|
||||
@GetMapping("/findActivate")
|
||||
public ResponseEntity<Object> findActivate(@RequestParam String shopId){
|
||||
@@ -72,38 +59,10 @@ public class StorageController {
|
||||
*/
|
||||
@PostMapping("/getwxacode")
|
||||
public ResponseEntity<Object> getwxacode(@RequestBody Map<String, Object> params) {
|
||||
if (CollectionUtils.isEmpty(params) || !params.containsKey("shopId")) throw new BadRequestException("参数错误");
|
||||
if (redisUtils.hasKey(CacheKey.VIPCODE + params.get("shopId"))) return new ResponseEntity<>(redisUtils.get(CacheKey.VIPCODE + params.get("shopId")),HttpStatus.OK);
|
||||
try {
|
||||
InputStream qrCodeStream = fetchQRCode(params);
|
||||
QiniuContent qiniuContent = qiNiuService.uploadByte(IoUtil.readBytes(qrCodeStream),qiNiuService.findCloud());
|
||||
redisUtils.set(CacheKey.VIPCODE + params.get("shopId"),qiniuContent.getUrl());
|
||||
return new ResponseEntity<>(qiniuContent.getUrl(),HttpStatus.OK);
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
|
||||
.body("Failed to generate QR code: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private String getAccessToken() {
|
||||
String url = String.format("%s?grant_type=client_credential&appid=%s&secret=%s", TOKEN_URL, APP_ID, APP_SECRET);
|
||||
String response = HttpUtil.get(url);
|
||||
JSONObject jsonResponse = JSONObject.parseObject(response);
|
||||
if (!jsonResponse.containsKey("access_token")) {
|
||||
throw new RuntimeException("Failed to retrieve access token: " + response);
|
||||
}
|
||||
return jsonResponse.getString("access_token");
|
||||
}
|
||||
private InputStream fetchQRCode(Map<String, Object> params) {
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("path", "pages/member/index?shopId="+params.get("shopId"));//路径
|
||||
jsonObject.addProperty("is_hyaline", true);//是否需要透明底色,为 true 时,生成透明底色的小程序码
|
||||
if (params.containsKey("env_version")) jsonObject.addProperty("env_version", "trial");//正式版为 release,体验版为 trial,开发版为 develop
|
||||
String accessToken = getAccessToken();
|
||||
String url = String.format("%s?access_token=%s", QR_CODE_URL, accessToken);
|
||||
return HttpUtil.createPost(url)
|
||||
.body(jsonObject.toString(), "application/json")
|
||||
.execute()
|
||||
.bodyStream();
|
||||
if (CollectionUtils.isEmpty(params) || !params.containsKey("shopId"))
|
||||
throw new BadRequestException("参数错误");
|
||||
if (redisUtils.hasKey(CacheKey.VIPCODE + params.get("shopId")))
|
||||
return new ResponseEntity<>(redisUtils.get(CacheKey.VIPCODE + params.get("shopId")), HttpStatus.OK);
|
||||
return new ResponseEntity<>(wxService.getFetchQRCode(params), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package cn.ysk.cashier.mybatis.service;
|
||||
|
||||
import cn.ysk.cashier.pojo.shop.TbShopTable;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
public interface MpShopTableService extends IService<TbShopTable> {
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.ysk.cashier.mybatis.service;
|
||||
|
||||
import cn.ysk.cashier.mybatis.entity.TbCallQueue;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @description 针对表【tb_call_queue】的数据库操作Service
|
||||
* @createDate 2024-09-12 15:34:30
|
||||
*/
|
||||
public interface TbCallQueueService extends IService<TbCallQueue> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.ysk.cashier.mybatis.service;
|
||||
|
||||
import cn.ysk.cashier.mybatis.entity.TbCallTable;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @description 针对表【tb_call_table】的数据库操作Service
|
||||
* @createDate 2024-09-12 15:07:15
|
||||
*/
|
||||
public interface TbCallTableService extends IService<TbCallTable> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package cn.ysk.cashier.mybatis.service.impl;
|
||||
|
||||
import cn.ysk.cashier.mapper.shop.TbShopTableMapper;
|
||||
import cn.ysk.cashier.mybatis.entity.TagProductDepts;
|
||||
import cn.ysk.cashier.mybatis.mapper.MpShopTableMapper;
|
||||
import cn.ysk.cashier.mybatis.mapper.TagProductDeptsMapper;
|
||||
import cn.ysk.cashier.mybatis.service.MpShopTableService;
|
||||
import cn.ysk.cashier.mybatis.service.TagProductDeptsService;
|
||||
import cn.ysk.cashier.pojo.shop.TbShopTable;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class MpShopTableServiceImpl extends ServiceImpl<MpShopTableMapper, TbShopTable> implements MpShopTableService {
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.ysk.cashier.mybatis.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import cn.ysk.cashier.mybatis.entity.TbCallQueue;
|
||||
import cn.ysk.cashier.mybatis.service.TbCallQueueService;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbCallQueueMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @description 针对表【tb_call_queue】的数据库操作Service实现
|
||||
* @createDate 2024-09-12 15:34:30
|
||||
*/
|
||||
@Service
|
||||
public class TbCallQueueServiceImpl extends ServiceImpl<TbCallQueueMapper, TbCallQueue>
|
||||
implements TbCallQueueService{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.ysk.cashier.mybatis.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import cn.ysk.cashier.mybatis.entity.TbCallTable;
|
||||
import cn.ysk.cashier.mybatis.service.TbCallTableService;
|
||||
import cn.ysk.cashier.mybatis.mapper.TbCallTableMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @description 针对表【tb_call_table】的数据库操作Service实现
|
||||
* @createDate 2024-09-12 15:07:15
|
||||
*/
|
||||
@Service
|
||||
public class TbCallTableServiceImpl extends ServiceImpl<TbCallTableMapper, TbCallTable>
|
||||
implements TbCallTableService{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package cn.ysk.cashier.mybatis.vo;
|
||||
|
||||
import cn.ysk.cashier.mybatis.entity.TbCallQueue;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.time.Instant;
|
||||
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class CallRecordVO extends TbCallQueue {
|
||||
private String note;
|
||||
private Long sinceAt;
|
||||
}
|
||||
Reference in New Issue
Block a user