代客下单修改

This commit is contained in:
2025-11-18 18:39:52 +08:00
parent e40b4fe8cc
commit 08e76b8897
39 changed files with 12932 additions and 4425 deletions

415
http/yskApi/Instead.js Normal file
View File

@@ -0,0 +1,415 @@
// 代课下单
import http from '@/http/yskApi/http.js'
import { accountUrl, marketUrl } from './prveUrl.js'
const request = http.request
//就餐形式,默认堂食后付费
const useType = 'dine-in-after'
function getUseType() {
const type = uni.getStorageSync("useType")
return type ? type : useType
}
// import {
// webscoketUtill
// } from '../websock.js'
// let wxObj = null
// wx初始化购物车
// export function getWXCart(params) {
// let wxUrl = 'ws://192.168.1.31:2348/?' + objectToString(params)
// wxObj = new webscoketUtill(wxUrl,3000,9,(e)=>{
// console.log('收到消息');
// console.log(e);
// })
// return uni.getStorageSync('wxList')
// }
// 新增\删除\修改到购物车
// export function addWXCart(params) {
// wxObj.ws.send(params)
// }
function objectToString(obj) {
let result = '';
for (const key in obj) {
if (obj.hasOwnProperty(key)) {
result += `${key}=${obj[key]}&`;
}
}
// 去掉最后一个多余的 &
return result.slice(0, -1);
}
/**
* 获取当前台桌订单信息
* @returns
*/
export function getCart(params) {
return request({
url: `/api/place/cart`,
method: "get",
params: {
shopId: uni.getStorageSync("shopId"),
useType: getUseType(),
...params
}
});
}
/**
* 已上架商品列表
* @returns
*/
export function getGoodsLists(params, showLoading = true) {
return request({
url: `/product/admin/product/list`,
method: "get",
params: {
shopId: uni.getStorageSync("shopId"),
...params
},
showLoading
});
}
/**
* 点单
* @returns
*/
export function addCart(data) {
return request({
url: `/api/place/addCart`,
method: "post",
data: {
shopId: uni.getStorageSync("shopId"),
useType: getUseType(),
...data
}
});
}
/**
* 清空购物车/支付订单
* @returns
*/
export function $clearCart(data) {
return request({
url: `/api/place/clearCart`,
method: "delete",
data: {
shopId: uni.getStorageSync("shopId"),
useType: getUseType(),
...data
}
});
}
/**
* 删除购物车某个商品
* @returns
*/
export function $removeCart(data) {
return request({
url: `/api/place/removeCart`,
method: "delete",
data: {
shopId: uni.getStorageSync("shopId"),
useType: getUseType(),
...data
}
});
}
/**
* 更新规格
* @returns
*/
export function $updateCart(data) {
return request({
url: `/api/place/updateCart`,
method: "put",
data: {
shopId: uni.getStorageSync("shopId"),
...data
}
});
}
/**
* 批量打包
* @returns
*/
export function $allPack(data) {
return request({
url: `/api/place/pack`,
method: "put",
data: {
shopId: uni.getStorageSync("shopId"),
...data
}
});
}
/**
* 获取取餐号
* @returns
*/
export function $getMasterId(data) {
return request({
url: `/api/place/masterId`,
method: "get",
params: {
shopId: uni.getStorageSync("shopId"),
useType: getUseType(),
...data
}
});
}
/**
* 支付方式获取
* @returns
*/
export function $getPayType(data) {
return request({
url: `/account/admin/payType`,
method: "get",
params: {
shopId: uni.getStorageSync("shopId"),
...data
}
});
}
/**
* 创建订单
* @returns
*/
export function $createOrder(data) {
return request({
url: `/api/place/order`,
method: "post",
data: {
shopId: uni.getStorageSync("shopId"),
useType: getUseType(),
...data
}
});
}
/**
* 挂起订单
* @returns
*/
export function $cacheOrder(data) {
return request({
url: `/api/place/pending`,
method: "post",
data: {
shopId: uni.getStorageSync("shopId"),
useType: getUseType(),
...data
}
});
}
/**
* 获取已挂起订单
* @returns
*/
export function $getCacheOrder(data) {
return request({
url: `/api/place/pending/cart`,
method: "get",
params: {
shopId: uni.getStorageSync("shopId"),
useType: getUseType(),
...data
}
});
}
// 会员点单/取消会员点单
export function $setUser(data) {
return request({
url: `/api/place/updateVip`,
method: "put",
data: {
shopId: uni.getStorageSync("shopId"),
...data
}
});
}
// 删除订单
export function $delOrder(data) {
return request({
url: `/api/place/order`,
method: "delete",
data: {
shopId: uni.getStorageSync("shopId"),
...data
}
});
}
// 支付订单
export function $payOrder(data) {
return request({
url: '/api/place/pay',
method: "put",
data: {
shopId: uni.getStorageSync("shopId"),
...data
}
});
}
//退单
export function $returnCart(data) {
return request({
url: '/api/place/returnCart',
method: "put",
data: {
shopId: uni.getStorageSync("shopId"),
...data
}
});
}
// 选择台桌
export function $choseTable(data) {
return request({
url: '/api/place/choseTable',
method: "put",
data: {
shopId: uni.getStorageSync("shopId"),
...data
}
});
}
// 用餐人数
export function $choseCount(data) {
return request({
url: '/api/place/choseCount',
method: "put",
data: {
shopId: uni.getStorageSync("shopId"),
useType: getUseType(),
...data
}
});
}
// 批量生成台桌
export function $fastCreateTable(data) {
return request({
url: '/api/tbShopTable/generate',
method: "post",
data: {
shopId: uni.getStorageSync("shopId"),
...data
}
});
}
//打印当前台桌订单
export function $printOrder(data) {
return request({
url: '/api/place/printOrder',
method: "post",
data: {
shopId: uni.getStorageSync("shopId"),
...data
}
});
}
//打印当前台桌菜品
export function $printDishes(data) {
return request({
url: '/api/place/printDishes',
method: "post",
data: {
shopId: uni.getStorageSync("shopId"),
...data
}
});
}
// 就餐模式切换
export function $changeUseType(data) {
return request({
url: '/api/place/choseModel',
method: "put",
data: {
shopId: uni.getStorageSync("shopId"),
...data
}
});
}
// 退款
export function $returnOrder(data) {
return request({
url: '/api/place/returnOrder',
method: "post",
data: {
shopId: uni.getStorageSync("shopId"),
...data
}
});
}
//获取用户可用优惠券
export function $findCoupon(data) {
return request({
url: marketUrl+'/admin/coupon/findCoupon',
method: "get",
params: {
shopId: uni.getStorageSync("shopId"),
...data
}
});
}
//会员积分列表
export function $returnMemberPointsList(data) {
return request({
url: '/api/points/member-points/page',
method: "get",
params: {
shopId: uni.getStorageSync("shopId"),
...data
}
});
}
// 会员积分账户信息
export function $returnMemberPoints(memberId) {
return request({
url: '/api/points/member-points/' + memberId,
method: "get",
params: {
shopId: uni.getStorageSync("shopId"),
...data
}
});
}
//002-获取订单可用积分及抵扣金额(支付页面使用)
export function $calcUsablePoints(data) {
return request({
url: '/api/points/member-points/calc-usable-points',
method: "get",
params: {
shopId: uni.getStorageSync("shopId"),
...data
}
});
}
// 003-根据积分计算可抵扣金额
export function $calcDeDuctionPoints(data) {
return request({
url: '/api/points/member-points/calc-deduction-amount',
method: "get",
params: {
shopId: uni.getStorageSync("shopId"),
...data
}
});
}

235
http/yskApi/http.js Normal file
View File

@@ -0,0 +1,235 @@
/**
* HTTP的封装 基于uni.request
* 包括: 通用响应结果的处理 和 业务的增删改查函数
*
* @author terrfly
* @site https://www.jeequan.com
* @date 2021/12/16 18:35
*/
// 设置env配置文件
import envConfig from '@/env/config.js'
// 导入全局属性
import appConfig from '@/config/appConfig.js'
import storageManage from '@/commons/utils/storageManage.js'
import infoBox from "@/commons/utils/infoBox.js"
import go from '@/commons/utils/go.js';
import { reject } from 'lodash';
// 设置node环境
// envConfig.changeEnv(storageManage.env('production'))
envConfig.changeEnv(storageManage.env('development'))
// 测试服
// #ifdef H5
let baseUrl = '/api/'
// #endif
// #ifndef H5
// let baseUrl = 'https://tapi.cashier.sxczgkj.cn/'
//预发布
// let baseUrl = 'https://pre-cashieradmin.sxczgkj.cn'
//正式
// let baseUrl = 'https://cashier.sxczgkj.com/'
let baseUrl = appConfig.env.JEEPAY_BASE_URL
// #endif
const loadingShowTime = 200
function getHeader(){
const headerObject={}
headerObject["token"] = storageManage.token()
headerObject["shopId"] = uni.getStorageSync("shopInfo").id
headerObject["platformType"] = 'APP'
return headerObject
}
// 通用处理逻辑
function commonsProcess(showLoading, httpReqCallback) {
// 判断是否请求完成(用作 是否loading
// 包括: 'ing', 'ingLoading', 'finish'
let reqState = 'ing'
// 是否已经提示的错误信息
let isShowErrorToast = false
// 请求完成, 需要处理的动作
let reqFinishFunc = () => {
if (reqState == 'ingLoading') { // 关闭loading弹层
infoBox.hideLoading()
}
reqState = 'finish' // 请求完毕
}
// 明确显示loading
if (showLoading) {
// xx ms内响应完成不提示loading
setTimeout(() => {
if (reqState == 'ing') {
reqState = 'ingLoading'
infoBox.showLoading()
}
}, loadingShowTime)
}
return httpReqCallback().then((httpData) => {
reqFinishFunc(); // 请求完毕的动作
// 从http响应数据中解构响应数据 [ 响应码、 bodyData ]
let {
statusCode,
data
} = httpData
// 避免混淆重新命名
let bodyData = data
if (statusCode == 500) {
isShowErrorToast = true
return Promise.reject(bodyData) // 跳转到catch函数
}
if (statusCode == 501) {
// storageManage.token(null, true)
// 提示信息
isShowErrorToast = true
// infoBox.showErrorToast('请登录').then(() => {
// go.to("PAGES_LOGIN", {}, go.GO_TYPE_RELAUNCH)
// })
return Promise.reject(bodyData) // 跳转到catch函数
}
// http响应码不正确
if (statusCode != 200 && statusCode != 204 && statusCode != 201) {
isShowErrorToast = true
bodyData.msg=bodyData.msg=='Bad credentials'?'用户名或密码错误':bodyData.msg
infoBox.showToast(bodyData.msg || '服务器异常')
return Promise.reject(bodyData) // 跳转到catch函数
}
// // 业务响应异常
if (bodyData.hasOwnProperty('code') && bodyData.code != 200) {
isShowErrorToast = true
infoBox.showToast(bodyData.msg)
// if (bodyData.code == 5005) { // 密码已过期, 直接跳转到更改密码页面
// uni.reLaunch({
// url: '/pageUser/setting/updatePwd'
// })
// }
// if(bodyData.code == 500){ // 密码已过期, 直接跳转到更改密码页面
// uni.redirectTo({url: '/pages/login/index'})
// }
return Promise.reject(bodyData) // 跳转到catch函数
}
// 构造请求成功的响应数据
return Promise.resolve(bodyData.data)
}).catch(res => {
console.log(res)
if(res.code==501){
storageManage.token(null, true)
infoBox.showToast('登录过期,请重新登录').then(() => {
uni.redirectTo({url: '/pages/login/index'})
reject()
})
}
// if(res.status==400){
// storageManage.token(null, true)
// infoBox.showErrorToast('').then(() => {
// go.to("PAGES_LOGIN", {}, go.GO_TYPE_RELAUNCH)
// })
// }
if(res.code==500){
infoBox.showToast(res.msg||'服务器异常').then(() => {})
}
// if(res&&res.msg){
// infoBox.showErrorToast(res.msg)
// }
reqFinishFunc(); // 请求完毕的动作
// 如果没有提示错误, 那么此处提示 异常。
if (!isShowErrorToast) {
infoBox.showToast(`请求网络异常`)
}
return Promise.reject(res)
}).finally(() => { // finally 是 then结束后再执行, 此处不适用。 需要在请求完成后立马调用: reqFinishFunc()
});
}
// 默认 显示loading(控制 xxs 内 不提示loading )
function req(uri, data, method = "GET", showLoading = true, extParams = {}) {
// headerObject[appConfig.tokenKey] = storageManage.token()
return commonsProcess(showLoading, () => {
return uni.request(
Object.assign({
url: baseUrl + uri,
data: data,
method: method,
header: getHeader()
}, extParams)
)
})
}
// 默认 显示loading(控制 xxs 内 不提示loading )
function request(args) {
const {
url,
data,
params,
method = "GET",
showLoading = true,
extParams = {}
} = args
let headerObject = {}
// headerObject[appConfig.tokenKey] = storageManage.token()
return commonsProcess(showLoading, () => {
return uni.request(
Object.assign({
url: baseUrl + url,
data: params||data,
method: method,
header: getHeader()
}, extParams)
)
})
}
// 上传
function upload(uri, data, file, showLoading = true, extParams = {}) {
// 放置token
let headerObject = {}
// headerObject[appConfig.tokenKey] = storageManage.token()
return commonsProcess(showLoading, () => {
return uni.uploadFile(
Object.assign({
url: baseUrl + uri,
formData: data,
name: "file",
filePath: file.path||file.url,
header: getHeader()
}, extParams)
).then((httpData) => {
// uni.upload 返回bodyData 的是 string类型。 需要解析。
httpData.data = JSON.parse(httpData.data)
return Promise.resolve(httpData)
}).catch(err=>{
uni.hideLoading()
infoBox.showErrorToast(`上传失败`)
})
})
}
export default {
req: req,
request,
upload: upload
}

View File

@@ -0,0 +1,19 @@
import http from '@/http/yskApi/http.js'
const request = http.request
import {marketUrl} from './prveUrl.js'
/**
* 限时折扣
* @returns
*/
export function limitTimeDiscount(params) {
return request({
url: marketUrl+`/admin/limitTimeDiscount`,
method: 'get',
params: {
shopId: uni.getStorageSync('shopInfo').id,
...params
}
})
}

View File

@@ -0,0 +1,20 @@
import http from '@/http/yskApi/http.js'
const request = http.request
import {marketUrl} from '../prveUrl.js'
/**
* 新客立减
* @returns
*/
export function getDiscountByUserId(params) {
return request({
url: marketUrl+`/admin/consumeDiscount/getDiscountByUserId`,
method: 'get',
params: {
shopId: uni.getStorageSync('shopInfo').id,
...params
}
})
}

View File

@@ -0,0 +1,21 @@
import http from '@/http/yskApi/http.js'
const request = http.request
import {marketUrl} from '../prveUrl.js'
/**
* 满减活动
* @returns
*/
export function discountActivity(params) {
console.log(uni.getStorageSync('shopInfo').id)
return request({
url: marketUrl+`/admin/discountActivity`,
method: 'get',
params: {
shopId: uni.getStorageSync('shopInfo').id,
...params
}
})
}

118
http/yskApi/order.js Normal file
View File

@@ -0,0 +1,118 @@
import http from '@/http/yskApi/http.js'
const request = http.request
import {orderUrl} from './prveUrl.js'
/**
* 查询订单
* @param {*} data
* @returns
*/
export function tbOrderInfoData(data) {
return request({
url: "/order/admin/order",
method: "get",
data: {
shopId: uni.getStorageSync('shopId'),
...data
}
});
}
/**
* 导出数据
* @param {*} data
* @returns
*/
export function tbOrderInfoDownload(data) {
return request({
url: "/api/tbOrderInfo/download",
method: "post",
data: {
shopId: uni.getStorageSync('shopId'),
...data
},
responseType: "blob"
});
}
export function createOrder(data, urlType = 'order') {
return request({
url: `/${urlType}/admin/order/createOrder`,
method: "POST",
data: {
...data
}
})
}
/**
* 通过Id查询订单
* @param {*} id
* @returns
*/
export function tbOrderInfoDetail(id) {
return request({
url: orderUrl+ `/admin/order/historyOrder?orderId=${id}`,
method: "get"
});
}
/**
* 通过Id查询订单
* @param {*} createdAt
* @returns
*/
export function payCount(createdAt) {
console.log(createdAt);
return request({
url: `/api/tbOrderInfo/payCount`,
method: "post",
data: {
shopId: uni.getStorageSync('shopId'),
createdAt: createdAt
}
});
}
/**
* 订单列表
* @param {*} createdAt
* @returns
*/
export function tbGroupOrderInfo(params) {
return request({
url: `/api/tbGroupOrderInfo`,
method: "post",
data: {
shopId: uni.getStorageSync('shopId'),
...params
}
});
}
/**
* 退单
* @param {*} data
* @returns
*/
export function returnGpOrder(data) {
return request({
url: `/api/tbGroupOrderInfo/returnGpOrder`,
method: "post",
data
});
}
/**
* 店铺订单支付获取链接
*/
export function $getOrderPayUrl(data) {
return request({
url: `/api/shopPayApi/getOrderPayUrl`,
method: "get",
data: {
shopId: uni.getStorageSync('shopId'),
...data
}
});
}

3
http/yskApi/prveUrl.js Normal file
View File

@@ -0,0 +1,3 @@
export const marketUrl = '/market'
export const accountUrl = '/account'
export const orderUrl = '/order'

59
http/yskApi/shop-user.js Normal file
View File

@@ -0,0 +1,59 @@
// 用户管理
import http from './http.js'
import {accountUrl} from './prveUrl.js'
const request=http.request
// 获取店铺会员二维码
export function getwxacode(data) {
return request({
url: `/shop/storage/getwxacode`,
method: "post",
data
});
}
/**
* 商家用户列表
* @returns
*/
export function queryAllShopUser(params) {
return request({
url: accountUrl+`/admin/shopUser`,
method: "get",
params: {
shopId: uni.getStorageSync('shopId'),
...params
}
});
}
/**
* 查询商家用户概述信息
* @returns
*/
export function queryAllShopInfo(params) {
return request({
url: `/api/tbShopUser/summary`,
method: "get",
params: {
shopId: uni.getStorageSync('shopId'),
isVip:1,
...params
}
});
}
/**
* 获取店铺用户详情
* @returns
*/
export function shopUserDetail(params) {
return request({
url: accountUrl+`/admin/shopUser/detail`,
method: "get",
params: {
shopId: uni.getStorageSync('shopId'),
...params
}
});
}