CREATE DEFINER=`inspect-v2-develop`@`%` PROCEDURE `updateTypeLabel`()
    COMMENT '数据迁移,储存过程'
BEGIN
	DECLARE s INT DEFAULT  0;
	DECLARE mealId VARCHAR(64);
	DECLARE num INT DEFAULT 0;
	
	DECLARE list CURSOR FOR  SELECT deploy_meal_id,COUNT(deploy_meal_id) from inspect_meal_deploy WHERE   is_deleted = '0' GROUP BY deploy_meal_id;
	
	DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET s = 1;
	
	OPEN list;
		
		FETCH list into mealId,num;
		while s<> 1 do
			IF num >= 1 THEN 
			UPDATE  inspect_meal_type_label SET meal_deploy_id = (SELECT id_ FROM inspect_meal_deploy WHERE is_deleted = '0' AND deploy_meal_id = mealId LIMIT 1) WHERE meal_id =  mealId AND is_deleted = '0';
			END IF;
			
			FETCH list into mealId,num;
		END WHILE;
		
	CLOSE list;

END
CREATE DEFINER=`inspect-v2-develop`@`%` PROCEDURE `updateStatus`(
																					IN app_id varchar(64),
																					IN appointmentStatus char(1),
																					IN payStatus char(1),
																					IN status_ char(1),
																					out sum int
																				)
    COMMENT '修改预约记录及快照表的状态'
BEGIN
	IF app_id is null OR app_id = '' THEN  set sum = 0 ;
	ELSEIF appointmentStatus is NOT null AND appointmentStatus <> '' AND payStatus is not null and payStatus <> '' AND status_ IS not null and status_ <> '' THEN
	UPDATE inspect_meal_appointment_record SET appointment_status =  appointmentStatus,pay_status = payStatus,status = status_ WHERE id_ = app_id;
	UPDATE inspect_item_appointment_record SET appointment_status =  appointmentStatus,pay_status = payStatus,status = status_ WHERE appointment_id = app_id;
	UPDATE inspect_order SET pay_status = payStatus WHERE id_ in (SELECT order_id FROM inspect_meal_appointment_record WHERE id_ = app_id);
	set sum = 3 ;
	ELSEIF appointmentStatus is NOT null AND appointmentStatus <> '' AND payStatus is not null and payStatus <> '' THEN
	UPDATE inspect_meal_appointment_record SET appointment_status =  appointmentStatus,pay_status = payStatus WHERE id_ = app_id;
	UPDATE inspect_item_appointment_record SET appointment_status =  appointmentStatus,pay_status = payStatus WHERE appointment_id = app_id;
	UPDATE inspect_order SET pay_status = payStatus WHERE id_ in (SELECT order_id FROM inspect_meal_appointment_record WHERE id_ = app_id);
	set sum = 3;
	ELSEIF appointmentStatus is NOT null AND appointmentStatus <> '' AND status_ IS not null and status_ <> '' THEN
	UPDATE inspect_meal_appointment_record SET appointment_status =  appointmentStatus,status = status_  WHERE id_ = app_id;
	UPDATE inspect_item_appointment_record SET appointment_status =  appointmentStatus,status = status_  WHERE appointment_id = app_id;
	set sum = 2;
	ELSEIF payStatus is not null and payStatus <> ''  AND status_ IS not null and status_ <> '' THEN
	UPDATE inspect_meal_appointment_record SET pay_status = payStatus,status = status_  WHERE id_ = app_id;
	UPDATE inspect_item_appointment_record SET pay_status = payStatus,status = status_  WHERE appointment_id = app_id;
	UPDATE inspect_order SET pay_status = payStatus WHERE id_ in (SELECT order_id FROM inspect_meal_appointment_record WHERE id_ = app_id);
	set sum = 3;
	end IF;
END

执行

在这里插入图片描述

Logo

汇聚全球AI编程工具,助力开发者即刻编程。

更多推荐