//author : kk 20240104
public with sharing class LexConsumableOrder {
    @AuraEnabled
    public static Consumable_order__c initConsumableOrder(String recordId){
        try{
            Consumable_order__c res = [SELECT Id,Order_status__c,OwnerId
                FROM Consumable_order__c 
                    WHERE Id = : recordId];
            return res;
        }
        catch(Exception e){
            System.debug('lexSubmitCampaign,method:initSubmit   error: '+e.getMessage());
            return null;
        }

    }
    @AuraEnabled
    public static String updateConsumableOrder(String Id , String recordTypeid){
    	try {
    	    Consumable_order__c res = new Consumable_order__c();
    	    res.Id = Id;
    	    res.recordTypeid = recordTypeid;
    	    UPDATE res;
    	    return 'success';
    	}
    	catch (Exception e) {
    	    return '更新失败'+e.getMessage();
    	}
    	

    }
    @AuraEnabled
    public static List<Consumable_Orderdetails__c>  selectDeteails(String recordId){
    	try {
    	    List<Consumable_Orderdetails__c> res = [select Id,Name,CreatedByid,Consumable_order__r.id,
    	                                        Consumable_order__c,Consumable_order__r.recordtypeid,Consumable_product__c,Consumable_count__c,
    	                                        Asset_Model_No__c,Intra_Trade_List_RMB__c 
    	                                            from Consumable_Orderdetails__c 
    	                                                where Consumable_order__r.id = :recordId];
    	    return res;
    	}
    	catch (Exception e) {
    	    return null;
    	}
    	

    }
    @AuraEnabled
    public static String create(Consumable_order_details2__c rac){
    	Savepoint sp = Database.setSavepoint(); // 创建保存点
    	try {
    	    INSERT rac;
    	    return 'success';
    	}
    	catch (Exception e) {
    		Database.rollback(sp);
    	    return '新建失败'+e.getMessage();
    	}
    	
    }

    
}