|
df_order_all=df_user_order_all.function()
#销售已审核
df_order_xs_checked=df_order_all[which(df_order_all$State==0),]
#在用(销售已审、服务期内)
df_order_in_use=df_order_all[which(df_order_all$State==0&df_order_all$UseStart_Date<Sys.time()&df_order_all$UseEnd_Date<Sys.time()),]
#显示
df_order_in_use[,1:5]
#部门名称
c_dept_name=distinct.function(df_order_in_use$DeptName)
c_dept_name
#显示
df_show1=NULL
df_show2=NULL
#部门
for(dept_name_i in 1:length(c_dept_name))
{
#print(c_dept_name[dept_name_i])
#在用 部门
df_order_in_use_dept= df_order_in_use[grep(c_dept_name[dept_name_i],df_order_in_use$DeptName),]
#print(df_order_in_use_dept[1,])
#在用 部门 用户
c_user_name=distinct.function(df_order_in_use_dept$User_Name)
for(user_name_i in 1:length(c_user_name))
{
#ceshi
df_order_in_use_dept= df_order_in_use[grep("北京张部",df_order_in_use$DeptName),]
df_order_username=df_order_in_use_dept[grep("mafei885",df_order_in_use_dept$User_Name),]
length(df_order_username$User_ID)
df_order_username=rbind(df_order_username)
df_order_username=df_order_in_use_dept[grep(c_user_name[user_name_i],df_order_in_use_dept$User_Name),]
if(length(df_order_username$User_ID)==1)
{
df_order_username$IsMain=TRUE
df_order_username$MainCode=df_order_username$Order_Code
df_show1=rbind(df_show1,df_order_username)
}
if(length(df_order_username$User_ID)>1)
{
for(user_name_ii in 1:length( df_order_username$User_ID))
{
df_show1=rbind(df_show1,GetMainOrder.function(df_order_all ,df_order_username[user_name_ii,]))
}
}
#break
#print(c_user_name[user_name_i])
}
}
length(df_show1$User_ID)
#df_show1$IsMain[which(df_show1$IsMain==TRUE)]
df_show1$MainCode[which(df_show1$MainCode=="tgzy320173110461350")]
#遍历主订单
maincode=distinct.function( df_show1$MainCode)
for(maincode_i in 1:length(maincode))
{
print(maincode_i)
df_main= df_show1[which(df_show1$MainCode==maincode[maincode_i]),]
df_main_cols_tmp=df_main[which(df_main$Order_Code==maincode[maincode_i]),]
df_main_cols_tmp$RealMoney=sum(df_main$RealMoney)
df_show2=rbind(df_show2,df_main_cols_tmp)
}
df_order_all[which(df_order_all$User_Name=="mafei885"),]
write.csv(df_order_all,"df_order_all.csv")
write.csv(df_order_in_use,"df_order_in_use.csv")
write.csv(df_show1,"df_show1.csv")
write.csv(df_show2,"df_show2.csv")
想把输出到csv文件的文件名和相应dataframe设置成参数的形式,不知道r支持动态参数吗,有大神给提供代码片段最好
|
|