Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
25120d25e7
|
|
@ -0,0 +1,297 @@
|
|||
package com.czg.controller.user;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.resp.CzgResult;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 小程序主页相关接口
|
||||
* @author Administrator
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/user/home")
|
||||
public class HomeController {
|
||||
@GetMapping("/homePageUp")
|
||||
public CzgResult<?> homePageUp() {
|
||||
return CzgResult.success(JSONObject.parseObject("""
|
||||
{
|
||||
"carousel": [
|
||||
{
|
||||
"name": "轮播图1",
|
||||
"coverImg": "https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240516/cba9df1d4d2b452daf0e7940fa6bafba.png",
|
||||
"jumpType": "relative",
|
||||
"absUrl": ""
|
||||
},
|
||||
{
|
||||
"name": "轮播图2",
|
||||
"coverImg": "https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240516/a2edc122ce4540ecae5e61f9cc7a701f.png",
|
||||
"jumpType": "relative",
|
||||
"absUrl": ""
|
||||
},
|
||||
{
|
||||
"name": "轮播图3",
|
||||
"coverImg": "https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240516/3d34f9c457fc4267b277c00a8f74d8f9.png",
|
||||
"jumpType": "relative",
|
||||
"absUrl": ""
|
||||
},
|
||||
{
|
||||
"name": "轮播图4",
|
||||
"coverImg": "https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240516/2482d7856e9b4c46b3f5b87d8b74126d.png",
|
||||
"jumpType": "relative",
|
||||
"absUrl": ""
|
||||
}
|
||||
],
|
||||
"district": [
|
||||
{
|
||||
"coverImg": "https://czg-oss.oss-cn-hangzhou.aliyuncs.com/app/statics/%E9%A2%84%E7%BA%A6%E5%88%B0%E5%BA%97.png",
|
||||
"name": "预约到店",
|
||||
"value": "",
|
||||
"fontColor": "",
|
||||
"jumpType": "relative",
|
||||
"absUrl": "index/tothestore"
|
||||
},
|
||||
{
|
||||
"coverImg": "https://czg-oss.oss-cn-hangzhou.aliyuncs.com/app/statics/%E6%89%AB%E7%A0%81%E7%82%B9%E9%A4%90.png",
|
||||
"name": "扫码点餐",
|
||||
"value": "scan",
|
||||
"fontColor": "",
|
||||
"jumpType": "scan",
|
||||
"absUrl": ""
|
||||
},
|
||||
{
|
||||
"coverImg": "https://czg-oss.oss-cn-hangzhou.aliyuncs.com/app/statics/%E5%92%96%E5%95%A1%E9%A5%AE%E5%93%81.png",
|
||||
"name": "咖啡饮品",
|
||||
"value": "1",
|
||||
"fontColor": "",
|
||||
"jumpType": "relative",
|
||||
"absUrl": "index/drinks"
|
||||
},
|
||||
{
|
||||
"coverImg": "https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240418/2f79d02678004e9c8db00ae6115e780a.png",
|
||||
"name": "每日免单",
|
||||
"value": "",
|
||||
"fontColor": "",
|
||||
"jumpType": "relative",
|
||||
"absUrl": "index/freedaily"
|
||||
},
|
||||
{
|
||||
"coverImg": "https://cashier-oss.oss-cn-beijing.aliyuncs.com/tcwm/wm.png",
|
||||
"name": "外 卖",
|
||||
"value": "{\\"appId\\":\\"wxc2bb94c0ddda1032\\",\\"path\\":\\"pages/index/shopList/index?token=ceshi\\"}",
|
||||
"fontColor": "",
|
||||
"jumpType": "scan_applet",
|
||||
"absUrl": ""
|
||||
}
|
||||
],
|
||||
"menu": [
|
||||
{
|
||||
"dictId": 1,
|
||||
"dictName": "allCity",
|
||||
"name": "全城",
|
||||
"isChild": true,
|
||||
"value": null,
|
||||
"detail": [
|
||||
{
|
||||
"dictId": 13,
|
||||
"dictName": "allCity",
|
||||
"name": "行政区",
|
||||
"isChild": null,
|
||||
"value": "",
|
||||
"detail": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"dictId": 2,
|
||||
"dictName": "category",
|
||||
"name": "品类",
|
||||
"isChild": true,
|
||||
"value": null,
|
||||
"detail": [
|
||||
{
|
||||
"dictId": 56,
|
||||
"dictName": "category",
|
||||
"name": "双人餐",
|
||||
"isChild": null,
|
||||
"value": "2",
|
||||
"detail": []
|
||||
},
|
||||
{
|
||||
"dictId": 11,
|
||||
"dictName": "category",
|
||||
"name": "饮品小吃",
|
||||
"isChild": null,
|
||||
"value": "4",
|
||||
"detail": []
|
||||
},
|
||||
{
|
||||
"dictId": 12,
|
||||
"dictName": "category",
|
||||
"name": "咖啡饮品",
|
||||
"isChild": null,
|
||||
"value": "1",
|
||||
"detail": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"dictId": 3,
|
||||
"dictName": "sort",
|
||||
"name": "智能排序",
|
||||
"isChild": true,
|
||||
"value": null,
|
||||
"detail": [
|
||||
{
|
||||
"dictId": 8,
|
||||
"dictName": "sort",
|
||||
"name": "离我最近",
|
||||
"isChild": null,
|
||||
"value": "1",
|
||||
"detail": []
|
||||
},
|
||||
{
|
||||
"dictId": 9,
|
||||
"dictName": "sort",
|
||||
"name": "销量优先",
|
||||
"isChild": null,
|
||||
"value": "2",
|
||||
"detail": []
|
||||
},
|
||||
{
|
||||
"dictId": 10,
|
||||
"dictName": "sort",
|
||||
"name": "价格优先",
|
||||
"isChild": null,
|
||||
"value": "3",
|
||||
"detail": []
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"dictId": 4,
|
||||
"dictName": "near1",
|
||||
"name": "附近1KM",
|
||||
"isChild": false,
|
||||
"value": "near",
|
||||
"detail": []
|
||||
}
|
||||
],
|
||||
"todayList": {
|
||||
"name": "今日上新",
|
||||
"todayList": [],
|
||||
"date": "10点更新"
|
||||
},
|
||||
"salesList": {
|
||||
"name": "飙升热榜",
|
||||
"hotList": [],
|
||||
"date": "8点更新"
|
||||
},
|
||||
"bannerVO": {
|
||||
"coupons": null,
|
||||
"counponsInfo": [
|
||||
{
|
||||
"name": "小***你",
|
||||
"logo": "https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/aef489a444793e37e2f33aeb3fe1fe13.jpeg",
|
||||
"money": 56.0
|
||||
},
|
||||
{
|
||||
"name": "红***好",
|
||||
"logo": "https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/a906414986b1bee60cec709dabf2103b.jpeg",
|
||||
"money": 159.5
|
||||
},
|
||||
{
|
||||
"name": "这***绿",
|
||||
"logo": "https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/e847667f37d86dc4a48ffcf69bb1a964.jpeg",
|
||||
"money": 106.5
|
||||
},
|
||||
{
|
||||
"name": "慢***上",
|
||||
"logo": "https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/a0be3632c238d1a8e24e51ff8942efc6.jpeg",
|
||||
"money": 171.0
|
||||
},
|
||||
{
|
||||
"name": "里***们",
|
||||
"logo": "https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/c26400a670209b60abcd28bfc6d22171.jpeg",
|
||||
"money": 59.5
|
||||
},
|
||||
{
|
||||
"name": "紫***大",
|
||||
"logo": "https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/e731f8a883ab1ef2a71487f2eb5b0e38.jpeg",
|
||||
"money": 165.0
|
||||
},
|
||||
{
|
||||
"name": "我***紫",
|
||||
"logo": "https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/f73810e20530a70dd068e0e0a82677d4.jpeg",
|
||||
"money": 100.0
|
||||
},
|
||||
{
|
||||
"name": "他***灰",
|
||||
"logo": "https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/cd794c0c5dd3b212e7c46eaa7c3a85cc.jpeg",
|
||||
"money": 133.0
|
||||
},
|
||||
{
|
||||
"name": "这***下",
|
||||
"logo": "https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/be1e70097583d1a08a9951925d66ef33.jpeg",
|
||||
"money": 37.5
|
||||
},
|
||||
{
|
||||
"name": "小***红",
|
||||
"logo": "https://cashier-oss.oss-cn-beijing.aliyuncs.com/status/%E6%BE%B6%E6%9D%91%E5%84%9A/ccf1f255cd30c2aed0b421213df01863.jpeg",
|
||||
"money": 109.0
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
"""));
|
||||
}
|
||||
|
||||
@GetMapping("/home")
|
||||
public CzgResult<?> home() {
|
||||
return CzgResult.success(JSONObject.parseObject("""
|
||||
{
|
||||
"total": 1,
|
||||
"list": [
|
||||
{
|
||||
"shopName": "漫巷咖啡",
|
||||
"shopImage": "https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240612/6f3618a31d2a4b489215647871ae732e.jpg",
|
||||
"productName": "鸡尾酒套餐",
|
||||
"image": "https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240612/0c07e1f79a244ed498dfe4a70848c479.jpeg",
|
||||
"originPrice": 200.00,
|
||||
"salePrice": 180.00,
|
||||
"discount": 9.00,
|
||||
"save": 20.00,
|
||||
"realSalesNumber": 0,
|
||||
"shopTag": [],
|
||||
"proTag": [],
|
||||
"distances": "4.2km",
|
||||
"districts": "未央区",
|
||||
"id": 661,
|
||||
"endTime": 1739577599999
|
||||
}
|
||||
],
|
||||
"pageNum": 1,
|
||||
"pageSize": 10,
|
||||
"size": 1,
|
||||
"startRow": 1,
|
||||
"endRow": 1,
|
||||
"pages": 1,
|
||||
"prePage": 0,
|
||||
"nextPage": 0,
|
||||
"isFirstPage": true,
|
||||
"isLastPage": true,
|
||||
"hasPreviousPage": false,
|
||||
"hasNextPage": false,
|
||||
"navigatePages": 8,
|
||||
"navigatepageNums": [
|
||||
1
|
||||
],
|
||||
"navigateFirstPage": 1,
|
||||
"navigateLastPage": 1,
|
||||
"firstPage": 1,
|
||||
"lastPage": 1
|
||||
}
|
||||
"""));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package com.czg.controller.user;
|
||||
|
||||
import com.czg.account.dto.shopinfo.ShopInfoByCodeDTO;
|
||||
import com.czg.account.service.ShopInfoService;
|
||||
import com.czg.resp.CzgResult;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 小程序店铺相关
|
||||
* @author Administrator
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/user/shopInfo")
|
||||
public class UShopInfoController {
|
||||
@Resource
|
||||
private ShopInfoService shopInfoService;
|
||||
|
||||
/**
|
||||
* 桌码换取详细店铺信息
|
||||
* @return 店铺信息
|
||||
*/
|
||||
@GetMapping
|
||||
public CzgResult<ShopInfoByCodeDTO> getByCode(@RequestParam @NotEmpty String tableCode, String lat, String lng) {
|
||||
return CzgResult.success(shopInfoService.getByCode(tableCode, lat, lng, true));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package com.czg.controller.user;
|
||||
|
||||
import com.czg.account.entity.ShopUser;
|
||||
import com.czg.account.service.ShopUserService;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 店铺会员相关
|
||||
* @author Administrator
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/user/shopUser")
|
||||
public class UShopUserController {
|
||||
@Resource
|
||||
private ShopUserService shopUserService;
|
||||
|
||||
/**
|
||||
* 获取当前店铺会员信息
|
||||
* 请求头必须携带shopId, 不携带则会失败
|
||||
* @return 店铺会员信息
|
||||
*/
|
||||
@GetMapping
|
||||
public CzgResult<ShopUser> get() {
|
||||
return CzgResult.success(shopUserService.queryChain().eq(ShopUser::getShopId, StpKit.USER.getShopId()).eq(ShopUser::getId, StpKit.USER.getLoginIdAsLong()).one());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package com.czg.controller.user;
|
||||
|
||||
import com.czg.account.service.GeoService;
|
||||
import com.czg.resp.CzgResult;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* geo位置管理
|
||||
* @author Administrator
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/user/geo")
|
||||
public class UserGeoController {
|
||||
@Resource
|
||||
private GeoService geoService;
|
||||
|
||||
@GetMapping("/geocode")
|
||||
public CzgResult<?> getAddress(@RequestParam @NotEmpty String lat, @RequestParam @NotEmpty String lng) {
|
||||
return CzgResult.success(geoService.getAddress(lat, lng));
|
||||
}
|
||||
}
|
||||
|
|
@ -54,7 +54,7 @@ public class SaTokenConfigure implements WebMvcConfigurer {
|
|||
// 重置根路径,防止satoken切割根路径导致匹配不到路径
|
||||
ApplicationInfo.routePrefix = "";
|
||||
|
||||
SaRouter.match("/user/**").notMatch("/user/login", "/user/test")
|
||||
SaRouter.match("/user/**").notMatch("/user/login", "/user/test", "/user/geo/**", "/user/home/**")
|
||||
.check(r -> StpKit.USER.checkMiniUser())
|
||||
.setHit(true)
|
||||
// .match("/**")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,116 @@
|
|||
|
||||
package com.czg.account.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import java.io.Serial;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 台桌配置 实体类。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-02-13
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ShopTableDTO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 自增id
|
||||
*/
|
||||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
private Integer shopId;
|
||||
|
||||
/**
|
||||
* 客座数,允许的客座数量
|
||||
*/
|
||||
private Integer maxCapacity;
|
||||
|
||||
/**
|
||||
* 台桌排序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 区域Id
|
||||
*/
|
||||
private Integer areaId;
|
||||
|
||||
/**
|
||||
* 是否接受网络预定
|
||||
*/
|
||||
private Integer isPredate;
|
||||
|
||||
/**
|
||||
* 网络预定台桌支付金额
|
||||
*/
|
||||
private BigDecimal predateAmount;
|
||||
|
||||
/**
|
||||
* idle-空闲 using-使用中 subscribe预定,closed--关台, opening 开台中,cleaning 台桌清理中
|
||||
*/
|
||||
private String status;
|
||||
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 二维码
|
||||
*/
|
||||
private String qrcode;
|
||||
|
||||
/**
|
||||
* 自动清台 0手动 1自动
|
||||
*/
|
||||
private Integer autoClear;
|
||||
|
||||
/**
|
||||
* 使用时间
|
||||
*/
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime useTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
/**
|
||||
* 已点商品数量
|
||||
*/
|
||||
private Integer productNum;
|
||||
|
||||
/**
|
||||
* 总金额
|
||||
*/
|
||||
private BigDecimal totalAmount;
|
||||
|
||||
/**
|
||||
* 应付金额
|
||||
*/
|
||||
private BigDecimal realAmount;
|
||||
|
||||
/**
|
||||
* 用餐人数
|
||||
*/
|
||||
private Integer useNum;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
package com.czg.account.dto.shopinfo;
|
||||
|
||||
import com.czg.account.entity.ShopInfo;
|
||||
import com.czg.account.entity.ShopTable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ShopInfoByCodeDTO {
|
||||
/**
|
||||
* 当前用户距离店铺的米数
|
||||
*/
|
||||
private double distance;
|
||||
/**
|
||||
* 店铺信息
|
||||
*/
|
||||
private ShopInfo shopInfo;
|
||||
/**
|
||||
* 台桌信息
|
||||
*/
|
||||
private ShopTable shopTable;
|
||||
}
|
||||
|
|
@ -0,0 +1,125 @@
|
|||
package com.czg.account.entity;
|
||||
|
||||
import com.czg.enums.ShopTableStatusEnum;
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 台桌配置 实体类。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-02-13
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("tb_shop_table")
|
||||
public class ShopTable implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 自增id
|
||||
*/
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private Integer id;
|
||||
|
||||
private String name;
|
||||
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 客座数,允许的客座数量
|
||||
*/
|
||||
private Integer maxCapacity;
|
||||
|
||||
/**
|
||||
* 台桌排序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 区域Id
|
||||
*/
|
||||
private Integer areaId;
|
||||
|
||||
/**
|
||||
* 是否接受网络预定
|
||||
*/
|
||||
private Integer isPredate;
|
||||
|
||||
/**
|
||||
* 网络预定台桌支付金额
|
||||
*/
|
||||
private BigDecimal predateAmount;
|
||||
|
||||
/**
|
||||
* idle-空闲 using-使用中 subscribe预定,closed--关台, opening 开台中,cleaning 台桌清理中
|
||||
*/
|
||||
private String status;
|
||||
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Column(onInsertValue = "now()", onUpdateValue = "now()")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 二维码
|
||||
*/
|
||||
private String tableCode;
|
||||
|
||||
/**
|
||||
* 自动清台 0手动 1自动
|
||||
*/
|
||||
private Integer autoClear;
|
||||
|
||||
/**
|
||||
* 使用时间
|
||||
*/
|
||||
private LocalDateTime useTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
private LocalDateTime endTime;
|
||||
|
||||
/**
|
||||
* 已点商品数量
|
||||
*/
|
||||
private Integer productNum;
|
||||
|
||||
/**
|
||||
* 总金额
|
||||
*/
|
||||
private BigDecimal totalAmount;
|
||||
|
||||
/**
|
||||
* 应付金额
|
||||
*/
|
||||
private BigDecimal realAmount;
|
||||
|
||||
/**
|
||||
* 用餐人数
|
||||
*/
|
||||
private Integer useNum;
|
||||
|
||||
public boolean canUseByStatus() {
|
||||
return !ShopTableStatusEnum.CLOSED.equalsVal(status) && !ShopTableStatusEnum.CLEANING.equalsVal(status) && !ShopTableStatusEnum.SUBSCRIBE.equalsVal(status);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.czg.account.service;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
public interface GeoService {
|
||||
Object getAddress(@NotEmpty String lat, @NotEmpty String lng);
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ package com.czg.account.service;
|
|||
|
||||
import com.czg.account.dto.PageDTO;
|
||||
import com.czg.account.dto.shopinfo.ShopInfoAddDTO;
|
||||
import com.czg.account.dto.shopinfo.ShopInfoByCodeDTO;
|
||||
import com.czg.account.dto.shopinfo.ShopInfoEditDTO;
|
||||
import com.czg.account.entity.ShopInfo;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
|
|
@ -18,4 +19,6 @@ public interface ShopInfoService extends IService<ShopInfo> {
|
|||
Boolean edit(ShopInfoEditDTO shopInfoEditDTO);
|
||||
|
||||
ShopInfo detail();
|
||||
|
||||
ShopInfoByCodeDTO getByCode(String tableCode, String lat, String lng, boolean checkState);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
package com.czg.account.service;
|
||||
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.account.entity.ShopTable;
|
||||
|
||||
/**
|
||||
* 台桌配置 服务层。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-02-13
|
||||
*/
|
||||
public interface ShopTableService extends IService<ShopTable> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package com.czg.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 台桌状态枚举
|
||||
* @author Administrator
|
||||
*/
|
||||
|
||||
@Getter
|
||||
public enum ShopTableStatusEnum {
|
||||
// 空闲
|
||||
IDLE("idle"),
|
||||
// 使用中
|
||||
USING("using"),
|
||||
// 关台
|
||||
CLOSED("closed"),
|
||||
// 预定
|
||||
SUBSCRIBE("subscribe"),
|
||||
// 清台
|
||||
CLEANING("cleaning");
|
||||
private final String value;
|
||||
|
||||
ShopTableStatusEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public boolean equalsVal(String val) {
|
||||
return val.equals(value);
|
||||
}
|
||||
}
|
||||
|
|
@ -10,12 +10,19 @@ import lombok.Getter;
|
|||
public enum ShopUserFlowBizEnum {
|
||||
// 会员充值
|
||||
CASH_IN("cashIn"),
|
||||
// 重置奖励
|
||||
AWARD_IN("awardIn"),
|
||||
// 微信小程序充值
|
||||
WECHAT_IN("wechatIn"),
|
||||
// 支付宝小程序重置
|
||||
ALIPAY_IN("alipayIn"),
|
||||
// 订单支付奖励
|
||||
ORDER_PAY("orderPay"),
|
||||
// 订单退款
|
||||
ORDER_REFUND("orderRefund"),
|
||||
// 充值退款
|
||||
RECHARGE_REFUND("rechargeRefund"),
|
||||
// 管理员手动增减余额
|
||||
ADMIN_IN("adminIn");
|
||||
private final String code;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
package com.czg.utils;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
@Component
|
||||
public class GeoUtil {
|
||||
// 地球半径,单位:公里
|
||||
private static final double EARTH_RADIUS = 6371.0;
|
||||
|
||||
/**
|
||||
* 计算两点之间的球面距离
|
||||
* @param lat1 第一个点的纬度
|
||||
* @param lon1 第一个点的经度
|
||||
* @param lat2 第二个点的纬度
|
||||
* @param lon2 第二个点的经度
|
||||
* @return 距离(单位:米)
|
||||
*/
|
||||
public static double getDistance(double lat1, double lon1, double lat2, double lon2) {
|
||||
// 将角度转换为弧度
|
||||
double radLat1 = Math.toRadians(lat1);
|
||||
double radLat2 = Math.toRadians(lat2);
|
||||
double deltaLat = radLat2 - radLat1;
|
||||
double deltaLon = Math.toRadians(lon2 - lon1);
|
||||
|
||||
// Haversine 公式
|
||||
double a = Math.pow(Math.sin(deltaLat / 2), 2) +
|
||||
Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(deltaLon / 2), 2);
|
||||
double c = 2 * Math.asin(Math.sqrt(a));
|
||||
|
||||
// 计算距离(米)
|
||||
return EARTH_RADIUS * c * 1000;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.czg.service.account.mapper;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.account.entity.ShopTable;
|
||||
|
||||
/**
|
||||
* 台桌配置 映射层。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-02-13
|
||||
*/
|
||||
public interface ShopTableMapper extends BaseMapper<ShopTable> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
package com.czg.service.account.service.impl;
|
||||
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.czg.account.service.GeoService;
|
||||
import com.czg.exception.ApiNotPrintException;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestClient;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 经纬度
|
||||
*
|
||||
* @author Administrator
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class GeoServiceImpl implements GeoService {
|
||||
private final RestClient restClient = RestClient.create();
|
||||
private static final String API_KEY = "7a7f2e4790ea222660a027352ee3af39";
|
||||
private static final String BASE_URL = "https://restapi.amap.com/v3/geocode/regeo";
|
||||
|
||||
@Override
|
||||
public JSONObject getAddress(String lat, String lng) {
|
||||
// 高德 API 坐标格式为 "经度,纬度"
|
||||
String location = lng + "," + lat;
|
||||
|
||||
String response = restClient.get()
|
||||
.uri(BASE_URL + "?key=" + API_KEY + "&location=" + location)
|
||||
.retrieve()
|
||||
.body(String.class);
|
||||
|
||||
JSONObject jsonObject = JSONObject.parseObject(response);
|
||||
if (jsonObject == null) {
|
||||
log.warn("经纬度获取失败{}", response);
|
||||
throw new ApiNotPrintException("获取经纬度失败");
|
||||
}
|
||||
return jsonObject.getJSONObject("regeocode");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -2,23 +2,29 @@ package com.czg.service.account.service.impl;
|
|||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.CoordinateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import com.czg.account.dto.PageDTO;
|
||||
import com.czg.account.dto.shopinfo.ShopInfoAddDTO;
|
||||
import com.czg.account.dto.shopinfo.ShopInfoByCodeDTO;
|
||||
import com.czg.account.dto.shopinfo.ShopInfoEditDTO;
|
||||
import com.czg.account.entity.*;
|
||||
import com.czg.account.service.*;
|
||||
import com.czg.enums.StatusEnum;
|
||||
import com.czg.exception.ApiNotPrintException;
|
||||
import com.czg.exception.CzgException;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.service.account.mapper.ShopInfoMapper;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import com.czg.utils.GeoUtil;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
|
|
@ -28,11 +34,27 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
|
|||
@Resource
|
||||
private SysUserService sysUserService;
|
||||
@Resource
|
||||
private SysUsersRolesService sysUsersRolesService;
|
||||
@Resource
|
||||
private SysRoleService sysRoleService;
|
||||
@Resource
|
||||
private MerchantRegisterService merchantRegisterService;
|
||||
@Resource
|
||||
private ShopTableService shopTableService;
|
||||
|
||||
private ShopInfo getShopInfo(Long shopId) {
|
||||
ShopInfo shopInfo = getById(shopId);
|
||||
if (shopInfo == null) {
|
||||
throw new ApiNotPrintException("店铺不存在");
|
||||
}
|
||||
if ((DateUtil.date().toLocalDateTime().isAfter(shopInfo.getExpireTime())) || shopInfo.getStatus() != StatusEnum.ENABLED.value()) {
|
||||
throw new ApiNotPrintException("店铺已过期,请联系商家");
|
||||
}
|
||||
if (StatusEnum.DISABLE.value() == shopInfo.getOnSale()) {
|
||||
throw new ApiNotPrintException("店铺已停业,请联系商家");
|
||||
}
|
||||
|
||||
shopInfo.setBookingSms(null);
|
||||
shopInfo.setOperationPwd(null);
|
||||
shopInfo.setBindAccount(null);
|
||||
return shopInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ShopInfo> get(PageDTO pageDTO, String shopName, Integer status) {
|
||||
|
|
@ -99,4 +121,24 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
|
|||
public ShopInfo detail() {
|
||||
return queryChain().eq(ShopInfo::getId, StpKit.USER.getLoginIdAsLong()).one();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShopInfoByCodeDTO getByCode(String tableCode, String lat, String lng, boolean checkState) {
|
||||
ShopTable shopTable = shopTableService.queryChain().eq(ShopTable::getTableCode, tableCode).one();
|
||||
if (shopTable == null) {
|
||||
throw new ApiNotPrintException("错误的台桌码");
|
||||
}
|
||||
|
||||
if (checkState && !shopTable.canUseByStatus()) {
|
||||
throw new ApiNotPrintException("台桌状态不可用");
|
||||
}
|
||||
ShopInfo shopInfo = getShopInfo(shopTable.getShopId());
|
||||
|
||||
double distance = 0;
|
||||
if (StrUtil.isAllNotBlank(lat, lng, shopInfo.getLat(), shopInfo.getLng())) {
|
||||
// 计算距离,单位:米
|
||||
distance = GeoUtil.getDistance(Long.parseLong(shopInfo.getLat()), Long.parseLong(shopInfo.getLng()), Long.parseLong(lat), Long.parseLong(lng));
|
||||
}
|
||||
return new ShopInfoByCodeDTO(distance, shopInfo, shopTable);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
package com.czg.service.account.service.impl;
|
||||
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.account.entity.ShopTable;
|
||||
import com.czg.account.service.ShopTableService;
|
||||
import com.czg.service.account.mapper.ShopTableMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 台桌配置 服务层实现。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-02-13
|
||||
*/
|
||||
@Service
|
||||
public class ShopTableServiceImpl extends ServiceImpl<ShopTableMapper, ShopTable> implements ShopTableService{
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<?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.czg.service.account.mapper.ShopTableMapper">
|
||||
|
||||
</mapper>
|
||||
|
|
@ -23,13 +23,13 @@ public class Main {
|
|||
// packageName 指定生成代码项目
|
||||
// tableName 指定需要生成的表
|
||||
|
||||
String packageName = "system";
|
||||
// String packageName = "account";
|
||||
// String packageName = "product";
|
||||
// String packageName = "order";
|
||||
// String servicePackageName = "system";
|
||||
// String servicePackageName = "account";
|
||||
// String servicePackageName = "product";
|
||||
String packageName = "account";
|
||||
|
||||
String tableName = "tb_order_detail";
|
||||
String author = "ww";
|
||||
String tableName = "tb_shop_table";
|
||||
String author = "zs";
|
||||
|
||||
//配置数据源
|
||||
HikariDataSource dataSource = new HikariDataSource();
|
||||
|
|
|
|||
Loading…
Reference in New Issue