Browse Source

修改 bug

master
王泽彦 8 months ago
parent
commit
50e996dda9
  1. 39
      admin/src/app/api/classroom.ts
  2. 43
      admin/src/app/views/classroom/components/classroom-edit.vue
  3. 27
      niucloud/app/adminapi/controller/classroom/Classroom.php
  4. 4
      niucloud/app/adminapi/route/classroom.php
  5. 13
      niucloud/app/api/controller/apiController/OrderTable.php
  6. 91
      niucloud/app/common.php
  7. 95
      niucloud/app/service/admin/classroom/ClassroomService.php
  8. 230
      niucloud/app/service/api/apiService/OrderTableService.php
  9. 6
      niucloud/app/service/api/pay/PayService.php
  10. 172
      uniapp/components/order-form-popup/index.vue

39
admin/src/app/api/classroom.ts

@ -63,6 +63,45 @@ export function getWithPersonnelList(params: Record<string, any>) {
return request.get('classroom/personnel_all', { params })
}
/**
* ID获取指定角色人员
* @param campusId ID
* @returns
*/
export function getPersonnelByRole(campusId?: number | string) {
const params: Record<string, any> = {}
if (campusId) {
params.campus_id = campusId
}
return request.get('classroom/personnel_all', { params })
}
/**
*
* @param campusId ID
* @returns
*/
export function getCoachPersonnel(campusId?: number | string) {
const params: Record<string, any> = {}
if (campusId) {
params.campus_id = campusId
}
return request.get('classroom/coach_personnel', { params })
}
/**
*
* @param campusId ID
* @returns
*/
export function getEducationalPersonnel(campusId?: number | string) {
const params: Record<string, any> = {}
if (campusId) {
params.campus_id = campusId
}
return request.get('classroom/educational_personnel', { params })
}
export function getAllClassroomList() {
return request.get('classroom/classroom_all')
}

43
admin/src/app/views/classroom/components/classroom-edit.vue

@ -111,7 +111,7 @@
>
<el-option label="请选择教务" value=""></el-option>
<el-option
v-for="(item, index) in headCoachList"
v-for="(item, index) in educationalList"
:key="index"
:label="item['name']"
:value="item['id']"
@ -178,6 +178,8 @@ import {
getClassroomInfo,
getWithCampusList,
getWithPersonnelList,
getCoachPersonnel,
getEducationalPersonnel,
} from '@/app/api/classroom'
let showDialog = ref(false)
@ -300,16 +302,41 @@ const setCampusIdList = async () => {
campusIdList.value = await (await getWithCampusList({})).data
}
setCampusIdList()
//
const headCoachList = ref([] as any[])
const setHeadCoachList = async () => {
headCoachList.value = await (await getWithPersonnelList({})).data
}
setHeadCoachList()
const assistantCoachList = ref([] as any[])
const setAssistantCoachList = async () => {
assistantCoachList.value = await (await getWithPersonnelList({})).data
const setCoachLists = async (campusId?: number | string) => {
const data = await (await getCoachPersonnel(campusId)).data
headCoachList.value = data
assistantCoachList.value = data
}
setCoachLists()
//
const educationalList = ref([] as any[])
const setEducationalList = async (campusId?: number | string) => {
educationalList.value = await (await getEducationalPersonnel(campusId)).data
}
setAssistantCoachList()
setEducationalList()
//
watch(() => formData.campus_id, (newCampusId) => {
if (newCampusId) {
//
setCoachLists(newCampusId)
setEducationalList(newCampusId)
//
formData.head_coach = ''
formData.assistant_coach = ''
formData.educational_id = ''
} else {
//
setCoachLists()
setEducationalList()
}
})
const setFormData = async (row: any = null) => {
Object.assign(formData, initialFormData)
loading.value = true

27
niucloud/app/adminapi/controller/classroom/Classroom.php

@ -116,7 +116,32 @@ class Classroom extends BaseAdminController
public function getPersonnelAll()
{
return success((new ClassroomService())->getPersonnelAll());
$params = $this->request->params([
["campus_id", 0]
]);
return success((new ClassroomService())->getPersonnelAll($params));
}
/**
* 获取教练人员(主教练、助教)
*/
public function getCoachPersonnel()
{
$params = $this->request->params([
["campus_id", 0]
]);
return success((new ClassroomService())->getCoachPersonnel($params));
}
/**
* 获取教务人员
*/
public function getEducationalPersonnel()
{
$params = $this->request->params([
["campus_id", 0]
]);
return success((new ClassroomService())->getEducationalPersonnel($params));
}
public function classroom_all()

4
niucloud/app/adminapi/route/classroom.php

@ -32,6 +32,10 @@ Route::group('classroom', function () {
Route::get('campus_all','classroom.Classroom/getCampusAll');
Route::get('personnel_all','classroom.Classroom/getPersonnelAll');
Route::get('coach_personnel','classroom.Classroom/getCoachPersonnel');
Route::get('educational_personnel','classroom.Classroom/getEducationalPersonnel');
Route::get('classroom_all','classroom.Classroom/classroom_all');

13
niucloud/app/api/controller/apiController/OrderTable.php

@ -87,6 +87,8 @@ class OrderTable extends BaseApiService
["order_type", ""], // 订单类型必填验证
["student_id", ""], // 学生ID必填验证
["order_amount", ""], // 订单金额(可选,会从课程获取)
["gift_id", ""], // 赠品ID(可选)
["gift_type", ""], // 赠品核销类型(可选):1-减现, 2-赠课
["remark", ""] // 备注(可选)
]);
@ -103,6 +105,15 @@ class OrderTable extends BaseApiService
return fail('缺少必要参数: ' . implode(', ', $missing_params));
}
// 验证赠品相关参数
if (!empty($params['gift_id']) && empty($params['gift_type'])) {
return fail('选择赠品时必须指定核销类型');
}
if (!empty($params['gift_type']) && !in_array($params['gift_type'], ['1', '2'])) {
return fail('无效的赠品核销类型,只能是1(减现)或2(赠课)');
}
// 如果前端没提供员工ID,使用当前登录的员工ID
if(empty($params['staff_id'])) {
if(empty($staff_id)) {
@ -140,6 +151,8 @@ class OrderTable extends BaseApiService
'campus_id' => $campus_id,//校区ID
'order_type' => $params['order_type'],
'student_id' => $params['student_id'],//学生ID
'gift_id' => !empty($params['gift_id']) ? $params['gift_id'] : null,//赠品ID
'gift_type' => !empty($params['gift_type']) ? $params['gift_type'] : null,//赠品核销类型:1-减现, 2-赠课
'remark' => $params['remark'],//备注
'order_status' => 'pending',//订单状态,默认为待支付
];

91
niucloud/app/common.php

@ -1514,4 +1514,95 @@ function getValidCourseByStudentId($studentId)
->order('id', 'desc')
->find();
return $course ?? [];
}
/**
* 根据校区ID和部门ID获取对应角色的人员列表
* @param int $campus_id 校区ID(必填)
* @param array $dept_ids 部门ID数组,例如:[1, 2, 23] 对应市场、教务、教练部门
* @return array 人员列表,包含person_id、name、phone等信息
*
* 使用示例:
* // 获取校区1的市场人员
* $market_staff = get_personnel_by_campus_dept(1, [1]);
*
* // 获取校区2的教练和教务人员
* $coaches_and_educators = get_personnel_by_campus_dept(2, [24, 2]);
*/
function get_personnel_by_campus_dept($campus_id, $dept_ids = [])
{
if (empty($campus_id) || empty($dept_ids)) {
return [];
}
try {
// 1. 根据部门ID获取对应的角色ID,使用正确的表名
$role_ids = \think\facade\Db::table('school_sys_role')->where([
['dept_id', 'in', $dept_ids],
['status', '=', 1]
])->column('role_id');
if (empty($role_ids)) {
return [];
}
// 2. 根据校区ID和角色ID获取人员
$personnel_list = \think\facade\Db::table('school_campus_person_role')
->alias('cpr')
->leftJoin('school_personnel p', 'cpr.person_id = p.id')
->where([
['cpr.campus_id', '=', $campus_id],
['cpr.role_id', 'in', $role_ids],
['cpr.deleted_at', '=', 0],
['p.status', '=', 2]
])
->field('cpr.person_id, p.name, p.phone, cpr.role_id, cpr.dept_id')
->select()
->toArray();
return $personnel_list;
} catch (\Exception $e) {
\think\facade\Log::write('获取校区部门人员失败:' . $e->getMessage());
return [];
}
}
/**
* 根据校区ID和角色ID获取人员列表
* @param int $campus_id 校区ID
* @param array $role_ids 角色ID数组
* @return array 人员列表
*
* 使用示例:
* // 获取指定校区的教练主管和普通教练
* $coaches = get_personnel_by_campus_role(1, [1, 5]);
*/
function get_personnel_by_campus_role($campus_id, $role_ids = [])
{
if (empty($campus_id) || empty($role_ids)) {
return [];
}
try {
// 根据校区ID和角色ID直接获取人员
$personnel_list = \think\facade\Db::table('school_campus_person_role')
->alias('cpr')
->leftJoin('school_personnel p', 'cpr.person_id = p.id')
->where([
['cpr.campus_id', '=', $campus_id],
['cpr.role_id', 'in', $role_ids],
['cpr.deleted_at', '=', 0],
['p.status', '=', 2]
])
->field('cpr.person_id, p.name, p.phone, cpr.role_id, cpr.dept_id')
->select()
->toArray();
return $personnel_list;
} catch (\Exception $e) {
\think\facade\Log::write('获取校区角色人员失败:' . $e->getMessage());
return [];
}
}

95
niucloud/app/service/admin/classroom/ClassroomService.php

@ -110,10 +110,99 @@ class ClassroomService extends BaseAdminService
return $campusModel->select()->toArray();
}
public function getPersonnelAll()
public function getPersonnelAll($params = [])
{
$personnelModel = new Personnel();
return $personnelModel->select()->toArray();
$campus_id = $params['campus_id'] ?? 0;
// 如果没有传校区ID,返回所有人员
if (empty($campus_id)) {
$personnelModel = new Personnel();
return $personnelModel->field('id, name, phone')->select()->toArray();
}
// 根据校区ID获取对应的教练、教务、市场人员
// 部门ID: 1=市场, 2=教务, 23=教练(实际系统中教练角色的dept_id是23)
$dept_ids = [1, 2, 23];
$personnel_list = get_personnel_by_campus_dept($campus_id, $dept_ids);
// 格式化返回数据,保持与原接口一致
$result = [];
foreach ($personnel_list as $person) {
$result[] = [
'id' => $person['person_id'],
'name' => $person['name'],
'phone' => $person['phone'],
'role_id' => $person['role_id'],
'dept_id' => $person['dept_id']
];
}
return $result;
}
/**
* 获取教练人员(主教练、助教)
*/
public function getCoachPersonnel($params = [])
{
$campus_id = $params['campus_id'] ?? 0;
// 如果没有传校区ID,返回所有教练人员
if (empty($campus_id)) {
// 这里可以直接查询所有教练角色的人员,但为了保持一致性,我们使用公共方法
$personnelModel = new Personnel();
return $personnelModel->field('id, name, phone')->select()->toArray();
}
// 根据校区ID获取教练人员(角色ID: 1=教练主管, 5=普通教练)
$role_ids = [1, 5];
$personnel_list = get_personnel_by_campus_role($campus_id, $role_ids);
// 格式化返回数据
$result = [];
foreach ($personnel_list as $person) {
$result[] = [
'id' => $person['person_id'],
'name' => $person['name'],
'phone' => $person['phone'],
'role_id' => $person['role_id'],
'dept_id' => $person['dept_id']
];
}
return $result;
}
/**
* 获取教务人员
*/
public function getEducationalPersonnel($params = [])
{
$campus_id = $params['campus_id'] ?? 0;
// 如果没有传校区ID,返回所有教务人员
if (empty($campus_id)) {
$personnelModel = new Personnel();
return $personnelModel->field('id, name, phone')->select()->toArray();
}
// 根据校区ID获取教务人员(部门ID: 2=教务)
$dept_ids = [2];
$personnel_list = get_personnel_by_campus_dept($campus_id, $dept_ids);
// 格式化返回数据
$result = [];
foreach ($personnel_list as $person) {
$result[] = [
'id' => $person['person_id'],
'name' => $person['name'],
'phone' => $person['phone'],
'role_id' => $person['role_id'],
'dept_id' => $person['dept_id']
];
}
return $result;
}
public function classroom_all()

230
niucloud/app/service/api/apiService/OrderTableService.php

@ -117,21 +117,46 @@ class OrderTableService extends BaseApiService
//创建订单
public function addData(array $data)
{
$success = OrderTable::create($data);
$res = [
'code' => 1,
'msg' => '操作成功',
'data' => []
];
if (!$success) {
try {
// 如果选择了赠品,验证赠品是否可用
if (!empty($data['gift_id'])) {
$giftValidation = $this->validateGift($data['gift_id'], $data['resource_id']);
if (!$giftValidation['valid']) {
return [
'code' => 0,
'msg' => $giftValidation['message'],
'data' => []
];
}
}
$success = OrderTable::create($data);
// 如果订单创建成功且使用了赠品,更新赠品状态
if ($success && !empty($data['gift_id'])) {
$this->updateGiftStatus($data['gift_id'], $success->id);
}
$res = [
'code' => 1,
'msg' => '操作成功',
'data' => ['order_id' => $success->id ?? null]
];
if (!$success) {
$res = [
'code' => 0,
'msg' => '操作失败',
'data' => []
];
}
return $res;
} catch (\Exception $e) {
return [
'code' => 0,
'msg' => '操作失败',
'msg' => '创建订单异常: ' . $e->getMessage(),
'data' => []
];
}
return $res;
}
//更新订单支付状态
@ -206,6 +231,9 @@ class OrderTableService extends BaseApiService
// 3. 创建支付记录
$this->createPaymentRecord($orderArray);
// 4.处理赠品
$this->handleGift($orderArray);
}
/**
* 支付成功后为学员分配课程
@ -452,4 +480,186 @@ class OrderTableService extends BaseApiService
return false;
}
}
/**
* 处理赠品
*/
private function handleGift(array $orderData)
{
try {
// 如果订单没有使用赠品,跳过处理
if (empty($orderData['gift_id']) || empty($orderData['gift_type'])) {
return true;
}
$gift_id = $orderData['gift_id'];
$gift_type = $orderData['gift_type'];
$order_amount = $orderData['order_amount'];
// 验证赠品是否存在且可用
$gift = Db::table('shcool_resources_gift')
->where('id', $gift_id)
->where('gift_status', 1)
->where('order_id', $orderData['id']) // 必须是被当前订单绑定的赠品
->find();
if (!$gift) {
\think\facade\Log::warning('处理赠品失败:赠品不存在或不可用', [
'gift_id' => $gift_id,
'order_id' => $orderData['id']
]);
return false;
}
// 根据赠品类型进行处理
switch ($gift_type) {
case '1': // 减现
$this->handleGiftCash($orderData, $gift);
break;
case '2': // 赠课
$this->handleGiftCourse($orderData, $gift);
break;
default:
\think\facade\Log::warning('处理赠品失败:未知的赠品类型', [
'gift_type' => $gift_type,
'order_id' => $orderData['id']
]);
return false;
}
// 更新赠品状态为已使用
Db::table('shcool_resources_gift')
->where('id', $gift_id)
->update([
'gift_status' => 2, // 已使用
'use_time' => time(),
'update_time' => time()
]);
\think\facade\Log::info('赠品处理成功', [
'gift_id' => $gift_id,
'gift_type' => $gift_type,
'order_id' => $orderData['id']
]);
return true;
} catch (\Exception $e) {
\think\facade\Log::error('处理赠品异常', [
'order_data' => $orderData,
'error' => $e->getMessage(),
'trace' => $e->getTraceAsString()
]);
return false;
}
}
/**
* 验证赠品是否可用
*/
private function validateGift($gift_id, $resource_id)
{
try {
$gift = Db::table('shcool_resources_gift')
->where('id', $gift_id)
->where('resource_id', $resource_id)
->where('gift_status', 1)
->where('order_id', 0) // 必须是未使用的赠品
->find();
if (!$gift) {
return [
'valid' => false,
'message' => '赠品不存在或已被使用'
];
}
return [
'valid' => true,
'message' => '赠品验证通过'
];
} catch (\Exception $e) {
\think\facade\Log::error('验证赠品异常', [
'gift_id' => $gift_id,
'resource_id' => $resource_id,
'error' => $e->getMessage()
]);
return [
'valid' => false,
'message' => '赠品验证异常: ' . $e->getMessage()
];
}
}
/**
* 更新赠品状态,绑定到订单
*/
private function updateGiftStatus($gift_id, $order_id)
{
try {
$result = Db::table('shcool_resources_gift')
->where('id', $gift_id)
->where('gift_status', 1)
->where('order_id', 0)
->update([
'order_id' => $order_id,
'update_time' => time()
]);
if ($result) {
\think\facade\Log::info('赠品状态更新成功', [
'gift_id' => $gift_id,
'order_id' => $order_id
]);
} else {
\think\facade\Log::warning('赠品状态更新失败', [
'gift_id' => $gift_id,
'order_id' => $order_id
]);
}
return $result;
} catch (\Exception $e) {
\think\facade\Log::error('更新赠品状态异常', [
'gift_id' => $gift_id,
'order_id' => $order_id,
'error' => $e->getMessage()
]);
return false;
}
}
/**
* 处理减现赠品
*/
private function handleGiftCash($orderData, $gift)
{
// 减现赠品的具体逻辑可以根据业务需求实现
// 例如:修改订单金额、创建退款记录等
\think\facade\Log::info('处理减现赠品', [
'order_id' => $orderData['id'],
'gift_id' => $gift['id'],
'gift_name' => $gift['gift_name']
]);
// TODO: 具体的减现逻辑实现
return true;
}
/**
* 处理赠课赠品
*/
private function handleGiftCourse($orderData, $gift)
{
// 赠课赠品的具体逻辑可以根据业务需求实现
// 例如:增加学员课时、创建额外课程记录等
\think\facade\Log::info('处理赠课赠品', [
'order_id' => $orderData['id'],
'gift_id' => $gift['id'],
'gift_name' => $gift['gift_name']
]);
// TODO: 具体的赠课逻辑实现
return true;
}
}

6
niucloud/app/service/api/pay/PayService.php

@ -155,12 +155,6 @@ class PayService extends BaseApiService
return $this->core_pay_service->getPayTypeByTrade($trade_type, $this->channel);
}
public function getQrcode()
{
// todo
}
/**
* 二维码支付回调
*/

172
uniapp/components/order-form-popup/index.vue

@ -57,29 +57,25 @@
/>
</view>
<!-- <view class="form-item">-->
<!-- <text class="label">课时数</text>-->
<!-- <input -->
<!-- class="form-input readonly"-->
<!-- type="number"-->
<!-- v-model="formData.total_hours"-->
<!-- placeholder="请先选择课程"-->
<!-- readonly-->
<!-- disabled-->
<!-- />-->
<!-- </view>-->
<view class="form-item" v-if="giftList.length > 0">
<text class="label">选择赠品</text>
<view class="picker-wrapper" @click="showGiftPicker">
<text class="picker-text" :class="{ 'placeholder': !formData.gift_id }">
{{ selectedGift && selectedGift.label || '请选择赠品(可选)' }}
</text>
<text class="picker-arrow"></text>
</view>
</view>
<!-- <view class="form-item">-->
<!-- <text class="label">赠送课时</text>-->
<!-- <input -->
<!-- class="form-input readonly"-->
<!-- type="number"-->
<!-- v-model="formData.gift_hours"-->
<!-- placeholder="请先选择课程"-->
<!-- readonly-->
<!-- disabled-->
<!-- />-->
<!-- </view>-->
<view class="form-item" v-if="formData.gift_id">
<text class="label">赠品核销类型 <text class="required">*</text></text>
<view class="picker-wrapper" @click="showGiftTypePicker">
<text class="picker-text" :class="{ 'placeholder': !formData.gift_type }">
{{ selectedGiftType && selectedGiftType.label || '请选择核销类型' }}
</text>
<text class="picker-arrow"></text>
</view>
</view>
<view class="form-item">
<text class="label">备注</text>
@ -148,6 +144,8 @@ export default {
order_amount: '',
total_hours: '',
gift_hours: '',
gift_id: '', // ID
gift_type: '', // 1-, 2-
remark: '',
class_id: '1' // ID
},
@ -163,11 +161,18 @@ export default {
courseSelectedIndex: -1,
paymentSelectedIndex: -1,
orderTypeSelectedIndex: -1,
giftSelectedIndex: -1,
giftTypeSelectedIndex: -1,
//
courseList: [],
paymentTypes: [], //
orderTypes: [] //
orderTypes: [], //
giftList: [], //
giftTypes: [ //
{ value: '1', label: '减现' },
{ value: '2', label: '赠课' }
]
}
},
computed: {
@ -179,6 +184,12 @@ export default {
},
selectedOrderType() {
return this.orderTypes.find(item => item.value === this.formData.order_type)
},
selectedGift() {
return this.giftList.find(item => item.value == this.formData.gift_id)
},
selectedGiftType() {
return this.giftTypes.find(item => item.value === this.formData.gift_type)
}
},
watch: {
@ -189,6 +200,7 @@ export default {
this.initForm()
this.loadCourseList()
this.loadDictionaries() //
this.loadGiftList() //
}
},
studentInfo: {
@ -208,6 +220,7 @@ export default {
console.log('组件挂载时 visible 为 true,开始加载数据')
this.loadCourseList()
this.loadDictionaries()
this.loadGiftList()
}
},
methods: {
@ -220,6 +233,8 @@ export default {
order_amount: '',
total_hours: '',
gift_hours: '',
gift_id: '',
gift_type: '',
remark: '',
class_id: '1' // ID
}
@ -228,6 +243,8 @@ export default {
this.courseSelectedIndex = -1
this.paymentSelectedIndex = -1
this.orderTypeSelectedIndex = -1
this.giftSelectedIndex = -1
this.giftTypeSelectedIndex = -1
},
async loadCourseList() {
@ -323,6 +340,47 @@ export default {
}
},
/**
* 加载可用赠品列表
*/
async loadGiftList() {
console.log('开始加载赠品列表,资源ID:', this.resourceId)
try {
if (!this.resourceId) {
console.warn('缺少资源ID,无法加载赠品列表')
this.giftList = []
return
}
const res = await apiRoute.xs_customerResourcesGetGiftRecordList({
resource_id: this.resourceId
})
console.log('赠品列表API响应:', res)
if (res.code === 1) {
// gift_status=1
this.giftList = (res.data || [])
.filter(gift => gift.gift_status === 1)
.map(gift => ({
value: gift.id,
label: gift.gift_name,
gift_type: gift.gift_type,
gift_type_text: gift.gift_type_text,
gift_time: gift.gift_time,
gift_time_formatted: gift.gift_time_formatted,
giver_name: gift.giver_name
}))
console.log('可用赠品列表:', this.giftList)
} else {
console.error('获取赠品列表失败:', res.msg)
this.giftList = []
}
} catch (error) {
console.error('获取赠品列表异常:', error)
this.giftList = []
}
},
showCoursePicker() {
this.currentPicker = 'course'
this.pickerTitle = '选择课程'
@ -377,6 +435,47 @@ export default {
this.$refs.pickerPopup.open()
},
showGiftPicker() {
this.currentPicker = 'gift'
this.pickerTitle = '选择赠品'
// ""
this.pickerOptions = [
{ value: '', label: '不选择赠品' },
...this.giftList
]
//
if (this.formData.gift_id) {
const currentIndex = this.pickerOptions.findIndex(item => item.id == this.formData.gift_id)
this.giftSelectedIndex = currentIndex >= 0 ? currentIndex : 0
} else {
this.giftSelectedIndex = 0
}
this.pickerValue = [this.giftSelectedIndex]
this.selectedIndex = this.giftSelectedIndex
this.$refs.pickerPopup.open()
},
showGiftTypePicker() {
this.currentPicker = 'giftType'
this.pickerTitle = '选择核销类型'
this.pickerOptions = this.giftTypes
//
if (this.formData.gift_type) {
const currentIndex = this.giftTypes.findIndex(item => item.value === this.formData.gift_type)
this.giftTypeSelectedIndex = currentIndex >= 0 ? currentIndex : 0
} else {
this.giftTypeSelectedIndex = 0
}
this.pickerValue = [this.giftTypeSelectedIndex]
this.selectedIndex = this.giftTypeSelectedIndex
this.$refs.pickerPopup.open()
},
onPickerChange(e) {
this.selectedIndex = e.detail.value[0]
},
@ -409,6 +508,21 @@ export default {
this.orderTypeSelectedIndex = this.selectedIndex
this.formData.order_type = selectedOption.value
break
case 'gift':
this.giftSelectedIndex = this.selectedIndex
this.formData.gift_id = selectedOption.value
// ""
if (!selectedOption.id) {
this.formData.gift_type = ''
this.giftTypeSelectedIndex = -1
}
console.log('赠品选择后更新表单数据:', this.formData)
break
case 'giftType':
this.giftTypeSelectedIndex = this.selectedIndex
this.formData.gift_type = selectedOption.value
console.log('赠品类型选择后更新表单数据:', this.formData)
break
}
this.closePicker()
@ -440,6 +554,10 @@ export default {
uni.showToast({ title: '请输入有效的订单金额', icon: 'none' })
return false
}
if (this.formData.gift_id && !this.formData.gift_type) {
uni.showToast({ title: '请选择赠品核销类型', icon: 'none' })
return false
}
return true
},
@ -456,6 +574,14 @@ export default {
order_status: 'pending'
}
//
if (!orderData.gift_id) {
orderData.gift_id = null
orderData.gift_type = null
}
console.log('准备提交的订单数据:', orderData)
const res = await apiRoute.xs_orderTableAdd(orderData)
if (res.code === 1) {

Loading…
Cancel
Save