前端需要改的部分:
链接:/pages/store/table_code/index.vue
前两张图找接口:isTableCode
方便复制:number
this.changeTable(tableId,number);
uni.switchTab({
url: '/pages/store_list/index'
})
第三张图找接口:changeTable
方便复制:
async changeTable(tableId,number) {
await this.addTableCode(number);
changeTable({
tableId: this.info.tableId,
y_tableId:tableId
}).then(() => {
this.$util.Tips({
title: '换桌完成',
success: this.getStore
});
this.getStore();
}).catch(err => {
this.$util.Tips({
title: err
});
});
},
后端需要改的部分:
方便复制:
public function isUserChangingTables(int $uid, int $store_id, int $qrcode_id, int $store_checkout_method)
{
$where = ['store_id' => $store_id, 'uid' => $uid, 'checkout_method' => $store_checkout_method, 'type' => 10, 'status' => [0, 1]];
$whereTo = ['store_id' => $store_id, 'qrcode_id' => $qrcode_id, 'checkout_method' => $store_checkout_method, 'type' => 10, 'status' => [0, 1]];
$table = $this->dao->getOne($where);
$table1 = $this->dao->getOne($whereTo);
if ($table) {
if ($table['qrcode_id'] != $qrcode_id) {
return ['code' => 0, 'number' => $table['number_diners'], 'tableId' => $table['id']];
} else {
return ['code' => 1, 'number' => $table['number_diners'], 'tableId' => $table['id']];
}
} else {
if ($store_checkout_method == 1) {
/** @var UserCollagePartakeServices $partakeService */
$partakeService = app()->make(UserCollagePartakeServices::class);
$partake_where = ['uid' => $uid, 'store_id' => $store_id, 'status' => 1];
$partake = $partakeService->getMaxTime($partake_where);
if (!$partake) {
return ['code' => 2, 'number' => $table1 ? $table1['number_diners'] : 0, 'tableId' => $table1 ? $table1['id'] : 0];
}
$table2 = $this->dao->get($partake['collate_code_id']);
if (!$table2) {
return ['code' => 2, 'number' => $table1 ? $table1['number_diners'] : 0, 'tableId' => $table1 ? $table1['id'] : 0];
}
if (in_array($table2['status'], [0, 1])) {
if ($table2['qrcode_id'] != $qrcode_id) {
return ['code' => 0, 'number' => $table2['number_diners'], 'tableId' => $table2['id']];
} else {
return ['code' => 1, 'number' => $table2['number_diners'], 'tableId' => $table2['id']];
}
} else {
return ['code' => 2, 'number' => $table1 ? $table1['number_diners'] : 0, 'tableId' => $table1 ? $table1['id'] : 0];
}
} else {
return ['code' => 1, 'number' => 0, 'tableId' => 0];
}
}
}