ComplianceServer/oldcode/OrdRecalculation/Program_ShenJi_Old.cs

2923 lines
167 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using CRM.Core.BLL.Wx;
using CRM.Core.DAL;
using CRM.Core.Model;
using CRM.Core.Model.Entity;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using WX.CRM.Common;
namespace Program_ShenJi_Old
{
/*
* 复制订单表 wx_szzyorder_handle
-- 找出实际退款的数据
select x.orderid,sum(x.refundprice),max(t.arrivalpay),sum(x.refundprice)/max(t.arrivalpay) from wx_szzyorder t
join wx_szzyorderrefund x on x.orderid=t.orderid
where x.auditstatus= 1 and t.orderstatus<>90
group by x.orderid
having (sum(x.refundprice)/max(t.arrivalpay))>0.3
;
-- 修改没有更改订单状态的表为已退款
update wx_szzyorder_handle ww set ww.orderstatus=90
where ww.orderid in (
select x.orderid from wx_szzyorder t
join wx_szzyorderrefund x on x.orderid= t.orderid
where x.auditstatus= 1 and t.orderstatus<>90
group by x.orderid
having (sum(x.refundprice)/max(t.arrivalpay))>0.3
)
*/
public class XinMeiti2
{
public int orderid { get; set; }
public string username { get; set; }
public decimal arrivalpay { get; set; }
public int channel { get; set; }
public int opendays { get; set; }
public DateTime otime { get; set; }
public DateTime arrivaltime { get; set; }
public int midproductid { get; set; }
public string outid_2 { get; set; }
public string nickname_2 { get; set; }
public string teacherid_2 { get; set; }
public string teacher_2 { get; set; }
public string pay_2 { get; set; }
public DateTime arrivaltime_2 { get; set; }
public DateTime realstarttime_2 { get; set; }
public DateTime realendtime_2 { get; set; }
public int servericeday_2 { get; set; }
public int xuhao { get; set; }
public string resid { get; set; }
public DateTime? ctime { get; set; }
public long szzyorderid { get; set; }
public string teacher { get; set; }
}
//public class Xinmeiti2_PriceChangeHis
//{
// public int orderid { get; set; }
// public int targetOrderid { get; set; }
// public decimal oldPrice { get; set; }
// public decimal changePrice { get; set; }
// public decimal newPrice { get; set; }
// public string type { get; set; }
// public int channel { get; set; }
// public int opendays { get; set; }
// public int serviceday_2 { get; set; }
//}
public class GongYunJia
{
public string ModeulId { get; set; }
public double Price { get; set; }
public Dictionary<string, double> nianDic { get; set; }
/// <summary>
/// 是否根据年份计算
/// </summary>
public bool IsNian { get; set; }
}
public class Modeule_Info
{
public string ModuleId { get; set; }
public int opendays2 { get; set; }
public DateTime? starttime2 { get; set; }
public DateTime? endtime2 { get; set; }
public double modulePrice { get; set; }
/// <summary>
/// 公允加个
/// </summary>
public double gongyunPrice { get; set; }
}
public class MainOrder
{
public string szzyorderid { get; set; }
public string MainSzzyorderid { get; set; }
}
class Program
{
/// <summary>
/// 第一次审计的版本 1.0
/// </summary>
/// <param name="args"></param>
public static void Main2(string[] args)
{
#region
// MainOrd(args);//订单定性
// MainTime(args);//订单时间计算
#endregion
MainModle(args);//订单模块计算
ModulePriceJiSuan();//计算金额 和天数
DingJinClear();//计算 苹果、魅族、华为平台支付扣除 手续费后金额
XinMeiti2_PriceJisuan();//新媒体二数据
//Upgrade_JiSuan2();//软件 补差升级计算
Console.WriteLine("全部执行ok=================");
Console.ReadLine();
}
public static void Upgrade_JiSuan2()
{
var param = new List<MySqlParameter> { };
Module_Price_Upgrade_BL bl = new Module_Price_Upgrade_BL();
MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, "truncate table Module_Price_Upgrade;", param.ToArray());
DataSet main = MySqlDbHelper.DataQueray(ConStringHelper.ZxdCRMConn, CommandType.Text, @"select t.szzyorderid,t.MainSzzyorderid,count(*)nc from module_order_jisuan t group by t.szzyorderid,t.MainSzzyorderid; ", param.ToArray());
List<MainOrder> mainlist = main.Tables[0].ToList<MainOrder>();
Dictionary<string, string> orderMain = new Dictionary<string, string>();
foreach (var item in mainlist)
{
if (!orderMain.ContainsKey(item.szzyorderid))
{
orderMain.Add(item.szzyorderid, item.MainSzzyorderid);
}
}
DataSet dataSet = MySqlDbHelper.DataQueray(ConStringHelper.ZxdCRMConn, CommandType.Text, @"select t.* from module_price t
where t.moduleid in('1012','1011','1082','1018','1028','1010','1031','1038')
order by otime2, modulePrice; ", param.ToArray());
List<Module_Price_M> list = dataSet.Tables[0].ToList<Module_Price_M>();
Dictionary<string, List<Module_Price_M>> dic = new Dictionary<string, List<Module_Price_M>>();
Dictionary<string, int> dicxuhao = new Dictionary<string, int>();
foreach (var item in list)
{
if (!dic.ContainsKey(item.username))
{
item.xuhao = 1;
dic.Add(item.username, new List<Module_Price_M>() { item });
dicxuhao.Add(item.username, 1);
}
else
{
dicxuhao[item.username] = dicxuhao[item.username] + 1;
item.xuhao = dicxuhao[item.username];
dic[item.username].Add(item);
}
}
List<Module_Price_Upgrade> histList = new List<Module_Price_Upgrade>();
///循环用户 module_price 数据
foreach (var item in dic)
{
foreach (Module_Price_M ord in item.Value)
{
if (ord.opendays2 < 0)//发现小于零的数据
{
if (!orderMain.ContainsKey(ord.szzyorderid))
{
Module_Price_Upgrade oldhist = new Module_Price_Upgrade
{
orderid = ord.orderid,
targetOrderid = null,
jiancount = 0,
moduleid = ord.moduleid,
changePrice = 0,//金额
channel = ord.channel,
opendays2 = ord.opendays2,//补充复天数
modulePrice = ord.modulePrice,
endtime2 = ord.endtime2,
ctime2 = ord.ctime2,
id = ord.id,
isBu = ord.isBu,
isoneday = ord.isoneday,
midproductid = ord.midproductid,
modulePrice2 = ord.modulePrice2,
orderPrice = ord.orderPrice,
otime2 = ord.otime2,
starttime2 = ord.starttime2,
szzyorderid = ord.szzyorderid,
type = "减天数2",
username = ord.username,
xuhao = ord.xuhao
};
histList.Add(oldhist);
continue;
}
string ManOrderid = orderMain[ord.szzyorderid];//主ID
var nextBigOrd = item.Value.Where(m => m.moduleid == ord.moduleid && m.xuhao > ord.xuhao && m.modulePrice > 0).OrderBy(m => m.xuhao).FirstOrDefault();//查找下一个数据
if (nextBigOrd != null)
{
var prvBigOrd = item.Value.Where(m => m.moduleid == ord.moduleid && m.szzyorderid == ManOrderid && m.xuhao < ord.xuhao && m.modulePrice > 0).OrderBy(m => m.xuhao).FirstOrDefault();//上一个订单
if (prvBigOrd == null)
{
Module_Price_Upgrade oldhist = new Module_Price_Upgrade
{
orderid = ord.orderid,
targetOrderid = null,
jiancount = 0,
moduleid = ord.moduleid,
changePrice = 0,//金额
channel = ord.channel,
opendays2 = ord.opendays2,//补充复天数
modulePrice = ord.modulePrice,
endtime2 = ord.endtime2,
ctime2 = ord.ctime2,
id = ord.id,
isBu = ord.isBu,
isoneday = ord.isoneday,
midproductid = ord.midproductid,
modulePrice2 = ord.modulePrice2,
orderPrice = ord.orderPrice,
otime2 = ord.otime2,
starttime2 = ord.starttime2,
szzyorderid = ord.szzyorderid,
type = "减天数1",
username = ord.username,
xuhao = ord.xuhao
};
histList.Add(oldhist);
}
else
{
Module_Price_Upgrade oldhist = new Module_Price_Upgrade
{
orderid = ord.orderid,
targetOrderid = nextBigOrd.orderid,
jiancount = 0,
moduleid = ord.moduleid,
changePrice = ord.opendays2 * prvBigOrd.modulePrice / prvBigOrd.opendays2,
channel = ord.channel,
opendays2 = ord.opendays2,//补充复天数
modulePrice = ord.modulePrice,
endtime2 = ord.endtime2,
ctime2 = ord.ctime2,
id = ord.id,
isBu = ord.isBu,
isoneday = ord.isoneday,
midproductid = ord.midproductid,
modulePrice2 = ord.modulePrice2,
orderPrice = ord.orderPrice,
otime2 = ord.otime2,
starttime2 = ord.starttime2,
szzyorderid = ord.szzyorderid,
type = "减金额",
username = ord.username,
xuhao = ord.xuhao
};
Module_Price_Upgrade newhist = new Module_Price_Upgrade
{
orderid = nextBigOrd.orderid,
targetOrderid = nextBigOrd.orderid,
jiancount = 0,
moduleid = nextBigOrd.moduleid,
changePrice = -ord.opendays2 * prvBigOrd.modulePrice / prvBigOrd.opendays2,
channel = nextBigOrd.channel,
opendays2 = nextBigOrd.opendays2,//
modulePrice = nextBigOrd.modulePrice,
endtime2 = nextBigOrd.endtime2,
ctime2 = nextBigOrd.ctime2,
id = nextBigOrd.id,
isBu = nextBigOrd.isBu,
isoneday = nextBigOrd.isoneday,
midproductid = nextBigOrd.midproductid,
modulePrice2 = nextBigOrd.modulePrice2,
orderPrice = nextBigOrd.orderPrice,
otime2 = nextBigOrd.otime2,
starttime2 = nextBigOrd.starttime2,
szzyorderid = nextBigOrd.szzyorderid,
type = "加金额",
username = nextBigOrd.username,
xuhao = nextBigOrd.xuhao
};
nextBigOrd.modulePrice = nextBigOrd.modulePrice - ord.opendays2 * prvBigOrd.modulePrice / prvBigOrd.opendays2;
histList.Add(oldhist);
histList.Add(newhist);
}
}
else
{
Module_Price_Upgrade oldhist = new Module_Price_Upgrade
{
orderid = ord.orderid,
targetOrderid = null,
jiancount = 0,
moduleid = ord.moduleid,
changePrice = 0,//金额
channel = ord.channel,
opendays2 = ord.opendays2,//补充复天数
modulePrice = ord.modulePrice,
endtime2 = ord.endtime2,
ctime2 = ord.ctime2,
id = ord.id,
isBu = ord.isBu,
isoneday = ord.isoneday,
midproductid = ord.midproductid,
modulePrice2 = ord.modulePrice2,
orderPrice = ord.orderPrice,
otime2 = ord.otime2,
starttime2 = ord.starttime2,
szzyorderid = ord.szzyorderid,
type = "减天数2",
username = ord.username,
xuhao = ord.xuhao
};
histList.Add(oldhist);
}
}
}
}
bl.BulkInsertToMysql("Module_Price_Upgrade", histList);
}
/// <summary>
/// 补差升级计算
/// </summary>
public static void Upgrade_JiSuan()
{
using (zxdContext db = new zxdContext())
{
try
{
Module_Price_Upgrade_BL bl = new Module_Price_Upgrade_BL();
var param = new List<MySqlParameter> { };
// MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, @"DROP TABLE IF EXISTS `test_fuopendays`;
//CREATE TABLE `test_fuopendays` (
// `szzyorderid` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
// `opendays2` int(0) NULL DEFAULT NULL COMMENT '开通(天)',
// `MainSzzyorderid` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
// INDEX `IX_MainSzzyorderid`(`MainSzzyorderid`) USING BTREE
//) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
//SET FOREIGN_KEY_CHECKS = 1;
//insert into test_fuopendays(szzyorderid,opendays2,MainSzzyorderid)
//select tt.szzyorderid,tt.opendays2,t2.MainSzzyorderid from module_price tt
//join module_order_jisuan t2 on tt.szzyorderid=t2.szzyorderid where tt.opendays2<0;
//truncate table Module_Price_Upgrade;
//drop table IF EXISTS `test_xxsss`;
//", param.ToArray());
// string sql = @"
//create table test_xxsss
//as
//select x.id,orderid,szzyorderid,moduleid,starttime2,endtime2,otime2,ctime2,orderPrice,modulePrice,midproductid,
//username,opendays2,isBu,isoneday,channel,modulePrice2,isVirOrder,isRunRefundIns,
//(
//select if(count(*)=0,0,1) from module_price tt
//where tt.szzyorderid=x.szzyorderid and tt.opendays2<0
//)+
//(
//select if(count(*)=0,0,1) from test_fuopendays s2
//where x.szzyorderid =s2.MainSzzyorderid
//)
//jiancount ,
//DATEDIFF(x.endtime2,x.starttime2) useday
//from module_price x
//where x.username in
//(
// select t.username from module_price t
// where DATEDIFF(t.endtime2,t.starttime2)<>t.opendays2
// and t.moduleid in('1012','1011','1082','1018','1028','1010','1031','1038')
// and t.opendays2<0
//)
//and x.moduleid in('1012','1011','1082','1018','1028','1010','1031','1038')
//and x.opendays2>0
//order by x.username,x.otime2;";
// MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, sql, param.ToArray());
DataSet dataSet = MySqlDbHelper.DataQueray(ConStringHelper.ZxdCRMConn, CommandType.Text, "select * from test_xxsss t;", param.ToArray());
List<Module_Price_Upgrade> list = dataSet.Tables[0].ToList<Module_Price_Upgrade>();
Dictionary<string, List<Module_Price_Upgrade>> dic = new Dictionary<string, List<Module_Price_Upgrade>>();
Dictionary<string, int> dicxuhao = new Dictionary<string, int>();
foreach (var item in list)
{
if (!dic.ContainsKey(item.username))
{
item.xuhao = 1;
dic.Add(item.username, new List<Module_Price_Upgrade>() { item });
dicxuhao.Add(item.username, 1);
}
else
{
dicxuhao[item.username] = dicxuhao[item.username] + 1;
item.xuhao = dicxuhao[item.username];
dic[item.username].Add(item);
}
}
List<Module_Price_Upgrade> histList = new List<Module_Price_Upgrade>();
foreach (var item in dic)
{
foreach (var ord in item.Value)
{
if (ord.jiancount > 0)
{
//&& m.realstarttime_2 == ord.realendtime_2
var nextBigOrd = item.Value.Where(m => m.xuhao > ord.xuhao && m.moduleid == ord.moduleid && m.modulePrice > 0).OrderBy(m => m.xuhao).FirstOrDefault();//下一个订单模块
if (nextBigOrd != null)
{
if (ord.useday == ord.opendays2)
{
continue;
}
Module_Price_Upgrade oldhist = new Module_Price_Upgrade
{
orderid = ord.orderid,
targetOrderid = nextBigOrd.orderid,
jiancount = ord.jiancount,
moduleid = ord.moduleid,
changePrice = -((ord.opendays2 - ord.useday) * ord.modulePrice / ord.opendays2),
channel = ord.channel,
opendays2 = ord.useday - ord.opendays2,//补充复天数
modulePrice = ord.modulePrice,
useday = ord.useday,
endtime2 = ord.endtime2,
ctime2 = ord.ctime2,
id = ord.id,
isBu = ord.isBu,
isoneday = ord.isoneday,
isRunRefundIns = ord.isRunRefundIns,
isVirOrder = ord.isVirOrder,
midproductid = ord.midproductid,
modulePrice2 = ord.modulePrice2,
orderPrice = ord.orderPrice,
otime2 = ord.otime2,
starttime2 = ord.starttime2,
szzyorderid = ord.szzyorderid,
type = "减金额",
username = ord.username,
xuhao = ord.xuhao
};
Module_Price_Upgrade newhist = new Module_Price_Upgrade
{
orderid = nextBigOrd.orderid,
targetOrderid = nextBigOrd.orderid,
jiancount = nextBigOrd.jiancount,
moduleid = nextBigOrd.moduleid,
changePrice = ((ord.opendays2 - ord.useday) * ord.modulePrice / ord.opendays2),
channel = nextBigOrd.channel,
opendays2 = nextBigOrd.opendays2,//
modulePrice = nextBigOrd.modulePrice,
useday = nextBigOrd.useday,
endtime2 = nextBigOrd.endtime2,
ctime2 = nextBigOrd.ctime2,
id = nextBigOrd.id,
isBu = nextBigOrd.isBu,
isoneday = nextBigOrd.isoneday,
isRunRefundIns = nextBigOrd.isRunRefundIns,
isVirOrder = nextBigOrd.isVirOrder,
midproductid = nextBigOrd.midproductid,
modulePrice2 = nextBigOrd.modulePrice2,
orderPrice = nextBigOrd.orderPrice,
otime2 = nextBigOrd.otime2,
starttime2 = nextBigOrd.starttime2,
szzyorderid = nextBigOrd.szzyorderid,
type = "加金额",
username = nextBigOrd.username,
xuhao = nextBigOrd.xuhao
};
nextBigOrd.modulePrice = nextBigOrd.modulePrice + ((ord.opendays2 - ord.useday) * ord.modulePrice / ord.opendays2);
histList.Add(oldhist);
histList.Add(newhist);
}
else
{
if (ord.useday == ord.opendays2)
{
continue;
}
Module_Price_Upgrade oldhist = new Module_Price_Upgrade
{
orderid = ord.orderid,
targetOrderid = null,
jiancount = ord.jiancount,
moduleid = ord.moduleid,
changePrice = 0,
channel = ord.channel,
opendays2 = ord.useday - ord.opendays2,//补充复天数
modulePrice = ord.modulePrice,
useday = ord.useday,
endtime2 = ord.endtime2,
ctime2 = ord.ctime2,
id = ord.id,
isBu = ord.isBu,
isoneday = ord.isoneday,
isRunRefundIns = ord.isRunRefundIns,
isVirOrder = ord.isVirOrder,
midproductid = ord.midproductid,
modulePrice2 = ord.modulePrice2,
orderPrice = ord.orderPrice,
otime2 = ord.otime2,
starttime2 = ord.starttime2,
szzyorderid = ord.szzyorderid,
type = "减天数",
username = ord.username,
xuhao = ord.xuhao
};
histList.Add(oldhist);
}
}
}
}
bl.BulkInsertToMysql("Module_Price_Upgrade", histList);
}
catch (Exception e)
{
throw e;
}
}
}
/// <summary>
/// 新媒体二金额下摊计算
/// </summary>
public static void XinMeiti2_PriceJisuan()
{
Xinmeiti2_PricechangeHis_BL bl = new Xinmeiti2_PricechangeHis_BL();
var param = new List<MySqlParameter> { };
//新媒体二数据excel导入后进行starttime2、endtime2、opendays2、otime2 修改
#region excel后进行 starttime2endtime2opendays2otime2
//将虚拟订单先删除
MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, @"delete from module_price t where t.isVirOrder=1 and t.channel>=26800 and t.channel<26900;", param.ToArray());
MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, @"DROP TABLE IF EXISTS `xinmeiti2_time`;", param.ToArray());//清空中间表数据
MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, @"create table xinmeiti2_time
as
select t.orderid,t.opendays2,t.starttime2,t.endtime2,a.实际开始时间,a.实际结束时间,a.`服务天数`,x.cname,x.softusername,x.subproductname,a.老师昵称 teacher,x.outorderno,x.arrivalpay,a.`实付金额(元)`,a.确认到款时间 from module_price t
join wx_szzyorder x on x.orderid=t.orderid
join xinmeiti2 a on x.outorderno=a.订单编号
#left join order_teacher tea on x.orderid=tea.orderid
where t.channel>=26800 and t.channel<26900
#and t.opendays2<>a.`产品服务周期`
#and x.arrivalpay<>a.`实付金额(元)`
order by x.softusername,a.实际开始时间
; ", param.ToArray());
MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, @"update module_price t set t.starttime2=(select x.`实际开始时间` from xinmeiti2_time x where x.orderid=t.orderid)
where exists(select 1 from xinmeiti2_time x where x.orderid=t.orderid);", param.ToArray());
MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, @"update module_price t set t.endtime2=(select x.`实际结束时间` from xinmeiti2_time x where x.orderid=t.orderid)
where exists(select 1 from xinmeiti2_time x where x.orderid=t.orderid);", param.ToArray());
MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, @"update module_price t set t.opendays2=(select x.`服务天数` from xinmeiti2_time x where x.orderid=t.orderid)
where exists(select 1 from xinmeiti2_time x where x.orderid=t.orderid);", param.ToArray());
MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, @"update module_price t set t.otime2=(select x.`确认到款时间` from xinmeiti2_time x where x.orderid=t.orderid)
where exists(select 1 from xinmeiti2_time x where x.orderid=t.orderid);", param.ToArray());
#endregion
//创建临时表
MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, @"DROP TABLE IF EXISTS `xinmeiti2_pricechangehis`;
CREATE TABLE `xinmeiti2_pricechangehis` (
`id` int(0) NOT NULL AUTO_INCREMENT,
`orderid` int(0) NOT NULL,
`targetOrderid` int(0) NULL DEFAULT NULL,
`oldPrice` decimal(24, 4) NULL DEFAULT NULL,
`changePrice` decimal(24, 4) NULL DEFAULT NULL,
`newPrice` decimal(24, 4) NULL DEFAULT NULL,
`type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL,
`channel` int(0) NULL DEFAULT NULL,
`opendays` int(0) NULL DEFAULT NULL,
`serviceday_2` int(0) NULL DEFAULT NULL,
`username` varchar(255) NULL DEFAULT NULL,
`resid` varchar(255) NULL DEFAULT NULL,
`realstarttime_2` datetime(0) NULL DEFAULT NULL,
`realendtime_2` datetime(0) NULL DEFAULT NULL,
`otime` datetime(0) NULL DEFAULT NULL,
`nextstartime` datetime(0) NULL DEFAULT NULL,
`szzyorderid` bigint(20) NULL DEFAULT NULL,
`midproductid` int(11) NULL DEFAULT NULL,
`ctime` datetime(0) NULL DEFAULT NULL,
`teacher` varchar(255) NULL DEFAULT NULL,
PRIMARY KEY(`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; ", param.ToArray());//清空中间表数据
//MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, "truncate table module_order_jisuan;", param.ToArray());//清空中间表数据
string sql = @"select x.orderid,x.szzyorderid,cc.teacher,x.ctime,x.softusername username,x.arrivalpay,x.channel,x.opendays,x.otime,x.arrivaltime,a.midproductid,x.resid,t.订单编号 outid_2,t.用户昵称 nickname_2,t.老师ID teacherid_2,t.老师昵称 teacher_2
,t.`实付金额(元)` pay_2,t.确认到款时间 arrivaltime_2,t.实际开始时间 realstarttime_2,t.实际结束时间 realendtime_2,t.服务天数 servericeday_2 from xinmeiti2 t
join wx_szzyorder x on x.outorderno=t.订单编号
left join wx_szzysubproduct a on a.subproductid=x.subproductid
left join order_teacher cc on cc.orderid=x.orderid
where x.otime is not null
and x.otime<'2021-08-01'
and a.midproductid<>100700304
order by t.确认到款时间,x.otime;
";
DataSet dataSet = MySqlDbHelper.DataQueray(ConStringHelper.ZxdCRMConn, CommandType.Text, sql, param.ToArray());
List<XinMeiti2> list = dataSet.Tables[0].ToList<XinMeiti2>();
Dictionary<string, List<XinMeiti2>> dic = new Dictionary<string, List<XinMeiti2>>();
Dictionary<string, int> dicxuhao = new Dictionary<string, int>();
foreach (var item in list)
{
if (!dic.ContainsKey(item.resid))
{
item.xuhao = 1;
dic.Add(item.resid, new List<XinMeiti2>() { item });
dicxuhao.Add(item.resid, 1);
}
else
{
dicxuhao[item.resid] = dicxuhao[item.resid] + 1;
item.xuhao = dicxuhao[item.resid];
dic[item.resid].Add(item);
}
}
//100700303 股海擒龙专业版
//100700305 股海擒龙尊享版
//100700306 股海擒龙至尊版
///根据用户循环 用户所有的订单
List<Xinmeiti2_PricechangeHis> histList = new List<Xinmeiti2_PricechangeHis>();
foreach (var item in dic)
{
foreach (var ord in item.Value)
{
if (ord.servericeday_2 < ord.opendays && ord.midproductid != 100700306)
{
//&& m.realstarttime_2 == ord.realendtime_2
var nextBigOrd = item.Value.Where(m => m.xuhao > ord.xuhao && m.midproductid > ord.midproductid).OrderBy(m => m.xuhao).FirstOrDefault();//7天内数据
if (nextBigOrd != null)
{
Xinmeiti2_PricechangeHis oldhist = new Xinmeiti2_PricechangeHis
{
orderid = ord.orderid,
targetOrderid = nextBigOrd.orderid,
channel = ord.channel,
opendays = ord.opendays,
serviceday_2 = ord.servericeday_2,
oldPrice = ord.arrivalpay,
newPrice = ord.arrivalpay - ((ord.opendays - ord.servericeday_2) * ord.arrivalpay / ord.opendays),
changePrice = -((ord.opendays - ord.servericeday_2) * ord.arrivalpay / ord.opendays),
type = "减金额",
resid = ord.resid,
username = ord.username,
otime = ord.arrivaltime_2,
realendtime_2 = ord.realendtime_2,
realstarttime_2 = ord.realstarttime_2,
nextstartime = nextBigOrd.realstarttime_2,
ctime = ord.ctime,
midproductid = ord.midproductid,
szzyorderid = ord.szzyorderid,
teacher = ord.teacher
};
Xinmeiti2_PricechangeHis newhist = new Xinmeiti2_PricechangeHis
{
orderid = nextBigOrd.orderid,
targetOrderid = nextBigOrd.orderid,
channel = nextBigOrd.channel,
opendays = nextBigOrd.opendays,
serviceday_2 = nextBigOrd.servericeday_2,
oldPrice = nextBigOrd.arrivalpay,
changePrice = ((ord.opendays - ord.servericeday_2) * ord.arrivalpay / ord.opendays),
newPrice = nextBigOrd.arrivalpay + ((ord.opendays - ord.servericeday_2) * ord.arrivalpay / ord.opendays),
type = "加金额",
resid = nextBigOrd.resid,
username = nextBigOrd.username,
otime = nextBigOrd.arrivaltime_2,
realendtime_2 = nextBigOrd.realendtime_2,
realstarttime_2 = nextBigOrd.realstarttime_2,
teacher = nextBigOrd.teacher,
szzyorderid = nextBigOrd.szzyorderid,
midproductid = nextBigOrd.midproductid,
ctime = nextBigOrd.ctime
};
nextBigOrd.arrivalpay = nextBigOrd.arrivalpay + ((ord.opendays - ord.servericeday_2) * ord.arrivalpay / ord.opendays);
histList.Add(oldhist);
histList.Add(newhist);
}
}
}
}
bl.BulkInsertToMysql("xinmeiti2_pricechangehis", histList);
//将向后摊分的钱修改进 module_price表
#region module_price
MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, @"update module_price t set t.modulePrice= t.modulePrice2+(select sum(x.changePrice) from xinmeiti2_pricechangehis x where x.orderid=t.orderid and x.type='加金额')
where exists (select 1 from xinmeiti2_pricechangehis x where x.orderid=t.orderid and x.type='加金额') and t.isVirOrder<>1
;", param.ToArray());
MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, @"update module_price t set t.opendays2= (select x.opendays from xinmeiti2_pricechangehis x where x.orderid=t.orderid and x.type='减金额')
where exists (select 1 from xinmeiti2_pricechangehis x where x.orderid=t.orderid and x.type='减金额') and t.isVirOrder<>1
;", param.ToArray());
MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, @"
INSERT INTO `module_price`(`orderid`, `szzyorderid`, `moduleid`, `starttime2`, `endtime2`, `otime2`, `ctime2`, `orderPrice`, `modulePrice`, `midproductid`, `username`, `opendays2`,`channel`,isVirOrder,modulePrice2)
select a.orderid,a.szzyorderid,CONCAT(a.midproductid,a.teacher), a.nextstartime, a.nextstartime,a.otime otime2, a.ctime, 0 orderPrice,a.changePrice modulePrice,a.midproductid,a.username,(a.serviceday_2-a.opendays) opendays2
,a.channel,1 isVirOrder ,0 modulePrice2 from xinmeiti2_pricechangehis a
where a.type='减金额';", param.ToArray());
#endregion
}
/// <summary>
/// 合并住ID的操作
/// </summary>
/// <param name="args"></param>
public static void MainModle(string[] args)
{
Module_Order_BL bll = new Module_Order_BL();
using (zxdContext db = new zxdContext())
{
try
{
var param = new List<MySqlParameter> { };
MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, "truncate table module_order_jisuan;", param.ToArray());//清空中间表数据
string sql = @"select a.id,a.username,a.moduleid,a.szzyorderid,a.productcode2,a.starttime2,a.endtime2,a.usedays,a.subproductname2,a.opendays2,a.totaldays,a.price2,a.ctime2,a.otime2,ifnull(b.channel,a.channel2) channel2,a.status2,a.isrefund,a.canceluser,a.canceltime,a.returnPrice,b.arrivalpay,b.orderid,x.midproductid from module_order a
left join wx_szzyorder b on a.szzyorderid=b.szzyorderid
left join wx_szzysubproduct x on x.subproductid=b.subproductid
where a.otime2<'2021-08-1'
order by a.username,a.otime2,a.price2 desc,a.id;
";
DataSet dataSet = MySqlDbHelper.DataQueray(ConStringHelper.ZxdCRMConn, CommandType.Text, sql, param.ToArray());
List<Module_Order> list = dataSet.Tables[0].ToList<Module_Order>();
Dictionary<string, List<Module_Order>> dic = new Dictionary<string, List<Module_Order>>();
Dictionary<string, int> dicxuhao = new Dictionary<string, int>();
foreach (var item in list)
{
if (!dic.ContainsKey(item.username))
{
item.xuhao = 1;
dic.Add(item.username, new List<Module_Order>() { item });
dicxuhao.Add(item.username, 1);
}
else
{
dicxuhao[item.username] = dicxuhao[item.username] + 1;
item.xuhao = dicxuhao[item.username];
dic[item.username].Add(item);
}
}
List<Module_Order> addlist = new List<Module_Order>();
Console.WriteLine("数据循环计算!");
///根据用户循环模块订单数据
foreach (var item in dic)
{
//Dictionary<string, int> xuhao = new Dictionary<string, int>();
//bool youjia = true;
//DateTime time = DateTime.Now;
//Module_Order temp =null;
int xuhao = 0;
foreach (var cd in item.Value)//本用户所有模块列表
{
if (cd.xuhao < xuhao)
{
continue;
}
if (cd.arrivalpay.HasValue && cd.arrivalpay > 0)//有价订单
{
//temp = cd;
cd.MainSzzyorderid = cd.szzyorderid;
addlist.Add(cd);//添加主订单
DateTime otime = cd.otime2.Value.Date.AddDays(8);
var hebingList = item.Value.Where(m => m.xuhao > cd.xuhao && m.otime2 < otime).ToList();//7天内数据
foreach (var hebin in hebingList)
{
xuhao = hebin.xuhao;
if (hebin.arrivalpay > 0 && hebin.midproductid == cd.midproductid)//有价订单,同类型产品
{
xuhao = hebin.xuhao + 1;
//int[] zhizhun = { 100800201, 100800202 };//至尊版本,至尊vip
hebin.MainSzzyorderid = cd.szzyorderid;
addlist.Add(hebin);
//if (cd.midproductid == 100800101 && hebin.moduleid == "1010")//1010模块需要合并
//{
// hebin.MainSzzyorderid = cd.szzyorderid;
// addlist.Add(hebin);
//}
//else if (zhizhun.Contains(cd.midproductid.Value))//至尊和至尊vip都需要查找 101010311038
//{
// hebin.MainSzzyorderid = cd.szzyorderid;
// addlist.Add(hebin);
//}
//else
//{
// hebin.MainSzzyorderid = cd.szzyorderid;
// addlist.Add(hebin);
//}
}
else if (hebin.arrivalpay > 0 && hebin.midproductid != cd.midproductid)//不能进行合并
{
if (hebin.xuhao < item.Value.LastOrDefault().xuhao)
{
xuhao = hebin.xuhao;
}
break;
}
else if (!hebin.arrivalpay.HasValue)
{
hebin.MainSzzyorderid = cd.szzyorderid;
addlist.Add(hebin);
}
}
}
}
}
Console.WriteLine("入库成功数据:" + addlist.Count());
bll.BulkInsertToMysql("module_order_jisuan", addlist);
MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, "truncate table module_order_jisuan_price;", param.ToArray());//清空中间表数据
Console.WriteLine("module_order_jisuan_price清理成功");
MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, @"insert into module_order_jisuan_price(id,orderPrice)
select waa.id,
(
select sum(wcc.arrivalpay) from wx_szzyorder wcc where wcc.szzyorderid in(select DISTINCT aw.szzyorderid from module_order_jisuan aw where aw.MainSzzyorderid=waa.MainSzzyorderid)
) orderPrice#计算金额
from module_order_jisuan waa where waa.id in(
select min(id) from module_order_jisuan w where w.szzyorderid in( select a.MainSzzyorderid from module_order_jisuan a) group by w.szzyorderid
)
;", param.ToArray());//清空中间表数据
Console.WriteLine("插入计算数据成功!");
MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, "update module_order_jisuan set orderPrice=null;", param.ToArray());//清空中间表数据
Console.WriteLine("module_order_jisuan的orderPrice改成NULL成功");
MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, @"update module_order_jisuan t set t.orderPrice=(select x.orderPrice from module_order_jisuan_price x where x.id=t.id )
where exists(select 1 from module_order_jisuan_price x where x.id = t.id );
", param.ToArray());//清空中间表数据
Console.WriteLine("入库成功!");
}
catch
{
throw;
}
}
}
public static void ModulePriceJiSuan()
{
Module_Order_BL bll = new Module_Order_BL();
using (zxdContext db = new zxdContext())
{
try
{
var param = new List<MySqlParameter> { };
MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, "truncate table module_price;", param.ToArray());//清空中间表数据
string sql = @"select a.* from module_order_jisuan a
where a.otime2<'2021-08-1'
order by a.username,a.otime2,a.price2 desc,a.id;";
DataSet dataSet = MySqlDbHelper.DataQueray(ConStringHelper.ZxdCRMConn, CommandType.Text, sql, param.ToArray());
List<Module_Order> list = dataSet.Tables[0].ToList<Module_Order>();
Dictionary<string, List<Module_Order>> dic = new Dictionary<string, List<Module_Order>>();//主订单作为key
foreach (var item in list)
{
if (!dic.ContainsKey(item.MainSzzyorderid))
{
dic.Add(item.MainSzzyorderid, new List<Module_Order>() { item });
}
else
{
dic[item.MainSzzyorderid].Add(item);
}
}
List<CRM.Core.Model.EntityAudit.Module_Price> addlist = new List<CRM.Core.Model.EntityAudit.Module_Price>();
Console.WriteLine("数据循环计算!");
Dictionary<int, GongYunJia> midprodcut_moduleid = new Dictionary<int, GongYunJia>();
midprodcut_moduleid.Add(100800203, new GongYunJia() { ModeulId = "1012", IsNian = false, Price = 239200 });//汇金长赢
midprodcut_moduleid.Add(100800204, new GongYunJia() { ModeulId = "1011", IsNian = false, Price = 119200 });//龙虎大咖
midprodcut_moduleid.Add(100800106, new GongYunJia() { ModeulId = "1082", IsNian = false, Price = 9980 });//红心哥单独模块
midprodcut_moduleid.Add(100800104, new GongYunJia()
{
ModeulId = "1018",
IsNian = true,
Price = 30581.00,
nianDic = new Dictionary<string, double> { { "2019", 12906.01 }, { "2020", 6835.47 }, { "2021", 2631.98 } }
});//实训营
midprodcut_moduleid.Add(100800102, new GongYunJia()
{
ModeulId = "1028",
IsNian = true,
Price = 30581.00,
nianDic = new Dictionary<string, double> { { "2019", 12906.01 }, { "2020", 6835.47 }, { "2021", 2631.98 } }
});//研习班
midprodcut_moduleid.Add(100800101, new GongYunJia() { ModeulId = "1010", IsNian = false, Price = 9800 });//擒龙版
midprodcut_moduleid.Add(100800201, new GongYunJia() { ModeulId = "1031", IsNian = false, Price = 20000 });//至尊版
midprodcut_moduleid.Add(100800202, new GongYunJia() { ModeulId = "1038", IsNian = false, Price = 30000 });//至尊VIP
foreach (var item in dic)
{
//foreach (var cd in item.Value.OrderBy(m => m.xuhao))
//{
var MainOrder = item.Value.OrderBy(m => m.xuhao).FirstOrDefault();
double fenmu = 0;
//Dictionary<string, Modeule_Info>
List<Modeule_Info> infoList = new List<Modeule_Info>();
foreach (var mid in midprodcut_moduleid)
{
var xa1 = item.Value.Where(m => m.moduleid == mid.Value.ModeulId);
double m1 = Convert.ToDouble(xa1.Sum(m => m.opendays2));
if (m1 > 0)
{
infoList.Add(new Modeule_Info
{
endtime2 = xa1.Max(m => m.endtime2),
ModuleId = mid.Value.ModeulId,
opendays2 = Convert.ToInt32(m1),
starttime2 = xa1.Min(m => m.starttime2),
gongyunPrice = (mid.Value.IsNian ? (mid.Value.nianDic[MainOrder.otime2.Value.Year.ToString()]) : mid.Value.Price)
});
fenmu += (m1 * (mid.Value.IsNian ? (mid.Value.nianDic[MainOrder.otime2.Value.Year.ToString()]) : mid.Value.Price));
}
}
foreach (var infoitem in infoList)
{
CRM.Core.Model.EntityAudit.Module_Price price = new CRM.Core.Model.EntityAudit.Module_Price()
{
channel = MainOrder.channel2,
ctime2 = MainOrder.ctime2,
moduleid = infoitem.ModuleId,
szzyorderid = MainOrder.szzyorderid,
midproductid = MainOrder.midproductid,
orderid = MainOrder.orderid,
orderPrice = MainOrder.orderPrice,
otime2 = MainOrder.otime2,
username = MainOrder.username,
opendays2 = Convert.ToInt32(infoitem.opendays2),
starttime2 = infoitem.starttime2,
endtime2 = infoitem.endtime2,
modulePrice = (Convert.ToDouble(MainOrder.orderPrice) * infoitem.gongyunPrice * infoitem.opendays2) / fenmu
};
addlist.Add(price);
}
string[] nomoduleid = { "1012", "1011", "1082", "1018", "1028", "1010", "1031", "1038" };
var axa = item.Value.Where(bb => !nomoduleid.Contains(bb.moduleid)).ToList();//找出 没找到的模块数据
foreach (var nodata in axa)
{
Console.WriteLine($"找不到的模块数据:{nodata.id}|{nodata.orderid}|{nodata.moduleid}|{nodata.szzyorderid}|mainid:{nodata.MainSzzyorderid}");
}
}
#region
//int[] zhizhun = { 100800201, 100800202, 100800102 };//至尊版本,至尊vip,研习班
//if (zhizhun.Contains(MainOrder.midproductid.Value))
//{
// var xa = item.Value.Where(m => m.moduleid == "1010");
// var xa2 = item.Value.Where(m => m.moduleid == "1031");
// var xa3 = item.Value.Where(m => m.moduleid == "1038");
// var xa4 = item.Value.Where(m => m.moduleid == "1028");//研习班
// var xa4 = item.Value.Where(m => m.moduleid == "1028");//研习班
// double m1 = Convert.ToDouble(xa.Sum(m => m.opendays2));
// double m2 = Convert.ToDouble(xa2.Sum(m => m.opendays2));
// double m3 = Convert.ToDouble(xa3.Sum(m => m.opendays2));
// double m4 = Convert.ToDouble(xa4.Sum(m => m.opendays2));
// var fenmu = m1 * 9800.0000 / 365 + m2 * 20000.0000 / 365 + m3 * 30000.0000 / 365 + m4 * 30581.0000 / 365;
// if (m1 > 0)
// {
// Module_Price price = new Module_Price()
// {
// channel = MainOrder.channel2,
// ctime2 = MainOrder.ctime2,
// moduleid = "1010",
// szzyorderid = MainOrder.szzyorderid,
// midproductid = MainOrder.midproductid,
// orderid = MainOrder.orderid,
// orderPrice = MainOrder.orderPrice,
// otime2 = MainOrder.otime2,
// username = MainOrder.username,
// opendays2 = Convert.ToInt32(m1),
// starttime2 = xa.Min(m => m.starttime2),
// endtime2 = xa.Max(m => m.endtime2),
// modulePrice = (Convert.ToDouble(MainOrder.orderPrice) * 9800 * m1 / 365) / fenmu
// };
// addlist.Add(price);
// }
// if (m2 > 0)
// {
// Module_Price price2 = new Module_Price()
// {
// channel = MainOrder.channel2,
// ctime2 = MainOrder.ctime2,
// moduleid = "1031",
// szzyorderid = MainOrder.szzyorderid,
// midproductid = MainOrder.midproductid,
// orderid = MainOrder.orderid,
// orderPrice = MainOrder.orderPrice,
// otime2 = MainOrder.otime2,
// username = MainOrder.username,
// opendays2 = Convert.ToInt32(m2),
// starttime2 = xa2.Min(m => m.starttime2),
// endtime2 = xa2.Max(m => m.endtime2),
// modulePrice = (Convert.ToDouble(MainOrder.orderPrice) * 20000 * m2 / 365) / fenmu
// };
// addlist.Add(price2);
// }
// if (m3 > 0)
// {
// Module_Price price3 = new Module_Price()
// {
// channel = MainOrder.channel2,
// ctime2 = MainOrder.ctime2,
// moduleid = "1038",
// szzyorderid = MainOrder.szzyorderid,
// midproductid = MainOrder.midproductid,
// orderid = MainOrder.orderid,
// orderPrice = MainOrder.orderPrice,
// otime2 = MainOrder.otime2,
// username = MainOrder.username,
// opendays2 = Convert.ToInt32(m3),
// starttime2 = xa3.Min(m => m.starttime2),
// endtime2 = xa3.Max(m => m.endtime2),
// modulePrice = (Convert.ToDouble(MainOrder.orderPrice) * 30000 * m3 / 365) / fenmu
// };
// addlist.Add(price3);
// }
// if (m4 > 0)
// {
// Module_Price price4 = new Module_Price()
// {
// channel = MainOrder.channel2,
// ctime2 = MainOrder.ctime2,
// moduleid = "1028",
// szzyorderid = MainOrder.szzyorderid,
// midproductid = MainOrder.midproductid,
// orderid = MainOrder.orderid,
// orderPrice = MainOrder.orderPrice,
// otime2 = MainOrder.otime2,
// username = MainOrder.username,
// opendays2 = Convert.ToInt32(m4),
// starttime2 = xa4.Min(m => m.starttime2),
// endtime2 = xa4.Max(m => m.endtime2),
// modulePrice = (Convert.ToDouble(MainOrder.orderPrice) * 30581 * m4 / 365) / fenmu
// };
// addlist.Add(price4);
// }
// //string[] nomoduleid = { "1038", "1028", "1010", "1031" };
// //var axa = item.Value.Where(bb => !nomoduleid.Contains(bb.moduleid)).ToList();//找出 没找到的模块数据
// //foreach (var nodata in axa)
// //{
// // Console.WriteLine($"找不到的模块数据:{nodata.id}|{nodata.orderid}|{nodata.moduleid}|{nodata.szzyorderid}|mainid:{nodata.MainSzzyorderid}");
// //}
// //}
// //if (zhizhun.Contains(MainOrder.midproductid.Value))
// //{
// // var xa = item.Value.Where(m => m.moduleid == "1010");
// // var xa2 = item.Value.Where(m => m.moduleid == "1031");
// // var xa3 = item.Value.Where(m => m.moduleid == "1038");
// // var xa4 = item.Value.Where(m => m.moduleid == "1028");//研习班
// // double m1 = Convert.ToDouble(xa.Sum(m => m.opendays2));
// // double m2 = Convert.ToDouble(xa2.Sum(m => m.opendays2));
// // double m3 = Convert.ToDouble(xa3.Sum(m => m.opendays2));
// // double m4 = Convert.ToDouble(xa4.Sum(m => m.opendays2));
// // var fenmu = m1 * 9800.0000 / 365 + m2 * 20000.0000 / 365 + m3 * 30000.0000 / 365 + m4 * 30581.0000 / 365;
// // if (m1 > 0)
// // {
// // Module_Price price = new Module_Price()
// // {
// // channel = MainOrder.channel2,
// // ctime2 = MainOrder.ctime2,
// // moduleid = "1010",
// // szzyorderid = MainOrder.szzyorderid,
// // midproductid = MainOrder.midproductid,
// // orderid = MainOrder.orderid,
// // orderPrice = MainOrder.orderPrice,
// // otime2 = MainOrder.otime2,
// // username = MainOrder.username,
// // opendays2 = Convert.ToInt32(m1),
// // starttime2 = xa.Min(m => m.starttime2),
// // endtime2 = xa.Max(m => m.endtime2),
// // modulePrice = (Convert.ToDouble(MainOrder.orderPrice) * 9800 * m1 / 365) / fenmu
// // };
// // addlist.Add(price);
// // }
// // if (m2 > 0)
// // {
// // Module_Price price2 = new Module_Price()
// // {
// // channel = MainOrder.channel2,
// // ctime2 = MainOrder.ctime2,
// // moduleid = "1031",
// // szzyorderid = MainOrder.szzyorderid,
// // midproductid = MainOrder.midproductid,
// // orderid = MainOrder.orderid,
// // orderPrice = MainOrder.orderPrice,
// // otime2 = MainOrder.otime2,
// // username = MainOrder.username,
// // opendays2 = Convert.ToInt32(m2),
// // starttime2 = xa2.Min(m => m.starttime2),
// // endtime2 = xa2.Max(m => m.endtime2),
// // modulePrice = (Convert.ToDouble(MainOrder.orderPrice) * 20000 * m2 / 365) / fenmu
// // };
// // addlist.Add(price2);
// // }
// // if (m3 > 0)
// // {
// // Module_Price price3 = new Module_Price()
// // {
// // channel = MainOrder.channel2,
// // ctime2 = MainOrder.ctime2,
// // moduleid = "1038",
// // szzyorderid = MainOrder.szzyorderid,
// // midproductid = MainOrder.midproductid,
// // orderid = MainOrder.orderid,
// // orderPrice = MainOrder.orderPrice,
// // otime2 = MainOrder.otime2,
// // username = MainOrder.username,
// // opendays2 = Convert.ToInt32(m3),
// // starttime2 = xa3.Min(m => m.starttime2),
// // endtime2 = xa3.Max(m => m.endtime2),
// // modulePrice = (Convert.ToDouble(MainOrder.orderPrice) * 30000 * m3 / 365) / fenmu
// // };
// // addlist.Add(price3);
// // }
// // if (m4 > 0)
// // {
// // Module_Price price4 = new Module_Price()
// // {
// // channel = MainOrder.channel2,
// // ctime2 = MainOrder.ctime2,
// // moduleid = "1028",
// // szzyorderid = MainOrder.szzyorderid,
// // midproductid = MainOrder.midproductid,
// // orderid = MainOrder.orderid,
// // orderPrice = MainOrder.orderPrice,
// // otime2 = MainOrder.otime2,
// // username = MainOrder.username,
// // opendays2 = Convert.ToInt32(m4),
// // starttime2 = xa4.Min(m => m.starttime2),
// // endtime2 = xa4.Max(m => m.endtime2),
// // modulePrice = (Convert.ToDouble(MainOrder.orderPrice) * 30581 * m4 / 365) / fenmu
// // };
// // addlist.Add(price4);
// // }
// // string[] nomoduleid = { "1038", "1028", "1010", "1031" };
// // var axa = item.Value.Where(bb => !nomoduleid.Contains(bb.moduleid)).ToList();//找出 没找到的模块数据
// // foreach (var nodata in axa)
// // {
// // Console.WriteLine($"找不到的模块数据:{nodata.id}|{nodata.orderid}|{nodata.moduleid}|{nodata.szzyorderid}|mainid:{nodata.MainSzzyorderid}");
// // }
// //}
// //else if (MainOrder.midproductid.Value == 100800104)
// //{
// // var xa = item.Value.Where(m => m.moduleid == "1010");
// // var xa2 = item.Value.Where(m => m.moduleid == "1031");
// // var xa3 = item.Value.Where(m => m.moduleid == "1038");
// // var xa4 = item.Value.Where(m => m.moduleid == "1018");//研习班
// // double m1 = Convert.ToDouble(xa.Sum(m => m.opendays2));
// // double m2 = Convert.ToDouble(xa2.Sum(m => m.opendays2));
// // double m3 = Convert.ToDouble(xa3.Sum(m => m.opendays2));
// // double m4 = Convert.ToDouble(xa4.Sum(m => m.opendays2));
// // var fenmu = m1 * 9800.0000 / 365 + m2 * 20000.0000 / 365 + m3 * 30000.0000 / 365 + m4 * 30581.0000 / 365;
// // if (m1 > 0)
// // {
// // Module_Price price = new Module_Price()
// // {
// // channel = MainOrder.channel2,
// // ctime2 = MainOrder.ctime2,
// // moduleid = "1010",
// // szzyorderid = MainOrder.szzyorderid,
// // midproductid = MainOrder.midproductid,
// // orderid = MainOrder.orderid,
// // orderPrice = MainOrder.orderPrice,
// // otime2 = MainOrder.otime2,
// // username = MainOrder.username,
// // opendays2 = Convert.ToInt32(m1),
// // starttime2 = xa.Min(m => m.starttime2),
// // endtime2 = xa.Max(m => m.endtime2),
// // modulePrice = (Convert.ToDouble(MainOrder.orderPrice) * 9800 * m1 / 365) / fenmu
// // };
// // addlist.Add(price);
// // }
// // if (m2 > 0)
// // {
// // Module_Price price2 = new Module_Price()
// // {
// // channel = MainOrder.channel2,
// // ctime2 = MainOrder.ctime2,
// // moduleid = "1031",
// // szzyorderid = MainOrder.szzyorderid,
// // midproductid = MainOrder.midproductid,
// // orderid = MainOrder.orderid,
// // orderPrice = MainOrder.orderPrice,
// // otime2 = MainOrder.otime2,
// // username = MainOrder.username,
// // opendays2 = Convert.ToInt32(m2),
// // starttime2 = xa2.Min(m => m.starttime2),
// // endtime2 = xa2.Max(m => m.endtime2),
// // modulePrice = (Convert.ToDouble(MainOrder.orderPrice) * 20000 * m2 / 365) / fenmu
// // };
// // addlist.Add(price2);
// // }
// // if (m3 > 0)
// // {
// // Module_Price price3 = new Module_Price()
// // {
// // channel = MainOrder.channel2,
// // ctime2 = MainOrder.ctime2,
// // moduleid = "1038",
// // szzyorderid = MainOrder.szzyorderid,
// // midproductid = MainOrder.midproductid,
// // orderid = MainOrder.orderid,
// // orderPrice = MainOrder.orderPrice,
// // otime2 = MainOrder.otime2,
// // username = MainOrder.username,
// // opendays2 = Convert.ToInt32(m3),
// // starttime2 = xa3.Min(m => m.starttime2),
// // endtime2 = xa3.Max(m => m.endtime2),
// // modulePrice = (Convert.ToDouble(MainOrder.orderPrice) * 30000 * m3 / 365) / fenmu
// // };
// // addlist.Add(price3);
// // }
// // if (m4 > 0)
// // {
// // Module_Price price4 = new Module_Price()
// // {
// // channel = MainOrder.channel2,
// // ctime2 = MainOrder.ctime2,
// // moduleid = "1018",
// // szzyorderid = MainOrder.szzyorderid,
// // midproductid = MainOrder.midproductid,
// // orderid = MainOrder.orderid,
// // orderPrice = MainOrder.orderPrice,
// // otime2 = MainOrder.otime2,
// // username = MainOrder.username,
// // opendays2 = Convert.ToInt32(m4),
// // starttime2 = xa4.Min(m => m.starttime2),
// // endtime2 = xa4.Max(m => m.endtime2),
// // modulePrice = (Convert.ToDouble(MainOrder.orderPrice) * 30581 * m4 / 365) / fenmu
// // };
// // addlist.Add(price4);
// // }
// string[] nomoduleid = { "1010", "1031", "1038", "1018" };
// var axa = item.Value.Where(bb => !nomoduleid.Contains(bb.moduleid)).ToList();//找出 没找到的模块数据
// foreach (var nodata in axa)
// {
// Console.WriteLine($"找不到的模块数据:{nodata.id}|{nodata.orderid}|{nodata.moduleid}|{nodata.szzyorderid}|mainid:{nodata.MainSzzyorderid}");
// }
//}
// //else if (MainOrder.midproductid == 100800203)// 汇金长盈
// //{
// // var xa = item.Value.Where(xx => xx.moduleid == "1012");
// // int? m = xa.Sum(xx => xx.opendays2);
// // if (m > 0)
// // {
// // Module_Price price = new Module_Price()
// // {
// // channel = MainOrder.channel2,
// // ctime2 = MainOrder.ctime2,
// // moduleid = MainOrder.moduleid,
// // szzyorderid = MainOrder.szzyorderid,
// // midproductid = MainOrder.midproductid,
// // orderid = MainOrder.orderid,
// // orderPrice = MainOrder.orderPrice,
// // otime2 = MainOrder.otime2,
// // username = MainOrder.username,
// // opendays2 = m,
// // starttime2 = xa.Min(xx => xx.starttime2),
// // endtime2 = xa.Max(xx => xx.endtime2),
// // modulePrice = Convert.ToDouble(MainOrder.orderPrice)
// // };
// // addlist.Add(price);
// // }
// //}
// //else if (MainOrder.midproductid == 100800204)//龙虎大咖
// //{
// // var xa = item.Value.Where(xx => xx.moduleid == "1011");
// // int? m = xa.Sum(xx => xx.opendays2);
// // if (m > 0)
// // {
// // Module_Price price = new Module_Price()
// // {
// // channel = MainOrder.channel2,
// // ctime2 = MainOrder.ctime2,
// // moduleid = MainOrder.moduleid,
// // szzyorderid = MainOrder.szzyorderid,
// // midproductid = MainOrder.midproductid,
// // orderid = MainOrder.orderid,
// // orderPrice = MainOrder.orderPrice,
// // otime2 = MainOrder.otime2,
// // username = MainOrder.username,
// // opendays2 = m,
// // starttime2 = xa.Min(xx => xx.starttime2),
// // endtime2 = xa.Max(xx => xx.endtime2),
// // modulePrice = Convert.ToDouble(MainOrder.orderPrice)
// // };
// // addlist.Add(price);
// // }
// //}
// else if (midprodcut_moduleid.ContainsKey(MainOrder.midproductid.Value))
//{
// //Console.WriteLine($"{MainOrder.midproductid};{MainOrder.szzyorderid};{MainOrder.username}");
// string moduleidstr = midprodcut_moduleid[MainOrder.midproductid.Value].ModeulId;
// var xa = item.Value.Where(xx => xx.moduleid == moduleidstr);
// int? m1 = xa.Sum(xx => xx.opendays2);
// var xa2 = item.Value.Where(m => m.moduleid == "1010");
// double m2 = Convert.ToDouble(xa2.Sum(m => m.opendays2));
// var fenmu = m2 * 9800.0000 / 365 + m1 * midprodcut_moduleid[MainOrder.midproductid.Value].Price / 365;
// if (m1 > 0)
// {
// Module_Price price = new Module_Price()
// {
// channel = MainOrder.channel2,
// ctime2 = MainOrder.ctime2,
// moduleid = MainOrder.moduleid,
// szzyorderid = MainOrder.szzyorderid,
// midproductid = MainOrder.midproductid,
// orderid = MainOrder.orderid,
// orderPrice = MainOrder.orderPrice,
// otime2 = MainOrder.otime2,
// username = MainOrder.username,
// opendays2 = m1,
// starttime2 = xa.Min(xx => xx.starttime2),
// endtime2 = xa.Max(xx => xx.endtime2),
// modulePrice = (Convert.ToDouble(MainOrder.orderPrice) * midprodcut_moduleid[MainOrder.midproductid.Value].Price * m1 / 365) / fenmu
// };
// addlist.Add(price);
// }
// if (m2 > 0)
// {
// Module_Price price = new Module_Price()
// {
// channel = MainOrder.channel2,
// ctime2 = MainOrder.ctime2,
// moduleid = "1010",
// szzyorderid = MainOrder.szzyorderid,
// midproductid = MainOrder.midproductid,
// orderid = MainOrder.orderid,
// orderPrice = MainOrder.orderPrice,
// otime2 = MainOrder.otime2,
// username = MainOrder.username,
// opendays2 = Convert.ToInt32(m2),
// starttime2 = xa2.Min(xx => xx.starttime2),
// endtime2 = xa2.Max(xx => xx.endtime2),
// modulePrice = (Convert.ToDouble(MainOrder.orderPrice) * 9800 * m2 / 365) / fenmu
// };
// addlist.Add(price);
// }
// string[] nomoduleid = { moduleidstr, "1010" };
// var axa = item.Value.Where(bb => !nomoduleid.Contains(bb.moduleid)).ToList();//找出 没找到的模块数据
// foreach (var nodata in axa)
// {
// Console.WriteLine($"找不到的模块数据:{nodata.id}|{nodata.orderid}|{nodata.moduleid}|{nodata.szzyorderid}|mainid:{nodata.MainSzzyorderid}");
// }
//}
//else //擒龙版,至尊版和至尊vip模块不做摊分
//{
// var xa = item.Value.Where(m => m.moduleid == "1010");
// var xa2 = item.Value.Where(m => m.moduleid == "1031");
// var xa3 = item.Value.Where(m => m.moduleid == "1038");
// var xa4 = item.Value.Where(m => m.moduleid == "1028");//研习班
// var xa5 = item.Value.Where(m => m.moduleid == "1018");//实训营
// int? m1 = xa.Sum(m => m.opendays2);
// int? m2 = xa2.Sum(m => m.opendays2);
// int? m3 = xa3.Sum(m => m.opendays2);
// int? m4 = xa4.Sum(m => m.opendays2);
// int? m5 = xa5.Sum(m => m.opendays2);
// var fenmu = m1 * 9800.0000 / 365 + m4 * 30581.0000 / 365 + m5 * 30581.0000 / 365;
// Module_Price price = new Module_Price()
// {
// channel = MainOrder.channel2,
// ctime2 = MainOrder.ctime2,
// moduleid = MainOrder.moduleid,
// szzyorderid = MainOrder.szzyorderid,
// midproductid = MainOrder.midproductid,
// orderid = MainOrder.orderid,
// orderPrice = MainOrder.orderPrice,
// otime2 = MainOrder.otime2,
// username = MainOrder.username,
// opendays2 = m1,
// starttime2 = xa.Min(m => m.starttime2),
// endtime2 = xa.Max(m => m.endtime2),
// modulePrice = (Convert.ToDouble(MainOrder.orderPrice) * 9800 * m1 / 365) / fenmu// Convert.ToDouble(MainOrder.orderPrice)
// };
// addlist.Add(price);
// if (m4.HasValue && m4.Value > 0)
// {
// Module_Price price4 = new Module_Price()
// {
// channel = MainOrder.channel2,
// ctime2 = MainOrder.ctime2,
// moduleid = MainOrder.moduleid,
// szzyorderid = MainOrder.szzyorderid,
// midproductid = MainOrder.midproductid,
// orderid = MainOrder.orderid,
// orderPrice = MainOrder.orderPrice,
// otime2 = MainOrder.otime2,
// username = MainOrder.username,
// opendays2 = m4,
// starttime2 = xa4.Min(m => m.starttime2),
// endtime2 = xa4.Max(m => m.endtime2),
// modulePrice = (Convert.ToDouble(MainOrder.orderPrice) * 30581.0000 * m4 / 365) / fenmu// Convert.ToDouble(MainOrder.orderPrice)
// };
// addlist.Add(price4);
// }
// if (m5.HasValue && m5.Value > 0)
// {
// Module_Price price5 = new Module_Price()
// {
// channel = MainOrder.channel2,
// ctime2 = MainOrder.ctime2,
// moduleid = MainOrder.moduleid,
// szzyorderid = MainOrder.szzyorderid,
// midproductid = MainOrder.midproductid,
// orderid = MainOrder.orderid,
// orderPrice = MainOrder.orderPrice,
// otime2 = MainOrder.otime2,
// username = MainOrder.username,
// opendays2 = m5,
// starttime2 = xa5.Min(m => m.starttime2),
// endtime2 = xa5.Max(m => m.endtime2),
// modulePrice = (Convert.ToDouble(MainOrder.orderPrice) * 30581.0000 * m5 / 365) / fenmu// Convert.ToDouble(MainOrder.orderPrice)
// };
// addlist.Add(price5);
// }
// if (m2.HasValue && m2.Value > 0)
// {
// Module_Price price2 = new Module_Price()
// {
// channel = MainOrder.channel2,
// ctime2 = MainOrder.ctime2,
// moduleid = "1031",
// szzyorderid = MainOrder.szzyorderid,
// midproductid = MainOrder.midproductid,
// orderid = MainOrder.orderid,
// orderPrice = 0,
// otime2 = MainOrder.otime2,
// username = MainOrder.username,
// opendays2 = m2,
// starttime2 = xa2.Min(m => m.starttime2),
// endtime2 = xa2.Max(m => m.endtime2),
// modulePrice = 0
// };
// addlist.Add(price2);
// }
// if (m3.HasValue && m3.Value > 0)
// {
// Module_Price price3 = new Module_Price()
// {
// channel = MainOrder.channel2,
// ctime2 = MainOrder.ctime2,
// moduleid = "1038",
// szzyorderid = MainOrder.szzyorderid,
// midproductid = MainOrder.midproductid,
// orderid = MainOrder.orderid,
// orderPrice = 0,
// otime2 = MainOrder.otime2,
// username = MainOrder.username,
// opendays2 = m3,
// starttime2 = xa3.Min(m => m.starttime2),
// endtime2 = xa3.Max(m => m.endtime2),
// modulePrice = 0
// };
// addlist.Add(price3);
// }
// string[] nomoduleid = { "1010", "1031", "1038", "1028", "1018" };
// var axa = item.Value.Where(bb => !nomoduleid.Contains(bb.moduleid)).ToList();//找出 没找到的模块数据
// foreach (var nodata in axa)
// {
// Console.WriteLine($"找不到的模块数据:{nodata.id}|{nodata.orderid}|{nodata.moduleid}|{nodata.szzyorderid}|mainid:{nodata.MainSzzyorderid}");
// }
// }
#endregion
Console.WriteLine("入库成功数据:" + addlist.Count());
new Module_Price_BL().BulkInsertToMysql("module_price", addlist);
//免费单补充
MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, @"insert into module_price(szzyorderid,moduleid,starttime2,endtime2,otime2,ctime2,orderPrice,username,opendays2,modulePrice)
select szzyorderid,moduleid,starttime2,endtime2,otime2,ctime2,0,username,opendays2,0 from module_order w where w.id not in
(
select id from module_order_jisuan t
);");
// //对冲天数
// MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, @"INSERT INTO `module_price`(`orderid`, `szzyorderid`, `moduleid`, `starttime2`, `endtime2`, `otime2`, `ctime2`, `orderPrice`, `modulePrice`, `midproductid`, `username`, `opendays2`,`channel`)
//select b.orderid,a.szzyorderid, a.moduleid, a.endtime2, a.endtime2,a.endtime2 otime2, a.ctime2, 0 orderPrice,0 modulePrice,x.midproductid,a.username,a.usedays-a.opendays2 opendays2,ifnull(b.channel,a.channel2)channel from module_order a
//left join wx_szzyorder b on a.szzyorderid=b.szzyorderid
//left join wx_szzysubproduct x on x.subproductid=b.subproductid
//where a.usedays<a.opendays2 and a.usedays>=0
//and not exists
//(
// select 1 from wx_szzyordermodulerefund x where x.szzyorderid=a.szzyorderid and x.ismorepay=0
//)
//;");
//退款时间大于endtime2 对冲天数
// MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, @"INSERT INTO `module_price`(`orderid`, `szzyorderid`, `moduleid`, `starttime2`, `endtime2`, `otime2`, `ctime2`, `orderPrice`, `modulePrice`, `midproductid`, `username`, `opendays2`,`channel`)
//select b.orderid,a.szzyorderid, a.moduleid, a.endtime2, a.endtime2,a.endtime2 otime2,a.ctime2, 0 orderPrice,0 modulePrice,x.midproductid,a.username,a.usedays-a.opendays2 opendays2,
//ifnull(b.channel,a.channel2)channel from module_order a
//left join wx_szzyorder b on a.szzyorderid=b.szzyorderid
//left join wx_szzysubproduct x on x.subproductid=b.subproductid
//left join (select min(bb.refunddate) refunddate,orderid from wx_szzyorderrefund bb where bb.auditstatus=1 and bb.ismorepay=0 group by bb.orderid) xax on xax.orderid=b.orderid
//where a.usedays<a.opendays2 and a.usedays>=0
//and xax.orderid is not null
//and DATE_FORMAT(xax.refunddate,'%y%m%d')>DATE_FORMAT(a.endtime2,'%y%m%d')
//;");
// 修改赠送订单的渠道号
// MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, @"
//update module_price t set t.channel=(
// select aa.channel from module_order x
// left join wx_szzyorder aa on aa.szzyorderid=x.szzyorderid
// where x.username=t.username and x.szzyorderid<>t.szzyorderid and x.price2>0 order by x.otime2 desc limit 1
//)
//where t.channel is null;
//update module_price t set t.channel=(
// select x.channel2 from module_order x
// where x.username=t.username and x.szzyorderid<>t.szzyorderid and x.price2>0 order by x.otime2 desc limit 1
//)
//where t.channel is null or t.channel=16000 ;
//");
// 不在模块里面的订单,摊分数据 补充
MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, @"insert into module_price(
orderid, szzyorderid, moduleid, starttime2, endtime2, otime2, ctime2, orderPrice, modulePrice, midproductid, username, opendays2,isBu,channel
)
select a.orderid, b.szzyorderid,CONCAT(x.midproductid,ifnull(tea.teacher,'')) moduleid,a.starttime starttime2,a.endtime endtime2,a.otime otime2,b.ctime ctime2,
a.arrivalpay orderPrice,a.arrivalpay modulePrice,x.midproductid,a.softusername username,
if((b.opendays+ifnull(b.giftdays,0))=0,(xx.opendays+ifnull(xx.giftdays,0)),(b.opendays+ifnull(b.giftdays,0))) opendays2,1 isBu,b.channel
from wx_szzyorder_redefine_time a
left join wx_szzyorder_handle b on a.orderid=b.orderid
left join wx_szzyorder xx on xx.orderid=a.orderid
left join wx_szzysubproduct x on x.subproductid=b.subproductid
left join order_teacher tea on tea.orderid=a.orderid
where a.orderid not in
(
select orderid from wx_szzyorder where szzyorderid in(
select szzyorderid from module_order_jisuan where price2>0 group by szzyorderid
)
);");
Console.WriteLine("插入无端终止的模块数据");
//计算 苹果、华为、魅族平台数据
//复制金额数据
MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, @"update module_price t set t.modulePrice2= t.modulePrice;");
//计算金额至中间表
MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, @"truncate table module_price_pingtai;");
MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, @"
insert into module_price_pingtai(id,paytype,modulePrice)
select a.id,b.paytype,
(
case
when b.paytype=11 then a.modulePrice*0.68607
when b.paytype=12 then a.modulePrice*0.68760
when b.paytype=13 then a.modulePrice*0.686
end
)
modulePrice
from module_price a
left join wx_szzyorderpay b on a.orderid = b.orderid
where paytype is not NULL and b.paytype in(11,12,13);
");
//修改金额至正式表
MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, @"update module_price t set t.modulePrice=(select x.modulePrice from module_price_pingtai x where x.id=t.id)
where exists (select 1 from module_price_pingtai x where x.id=t.id);");
MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, @"update module_price t set t.orderPrice=0,t.modulePrice=0,t.modulePrice2=0 where orderid=80075948;");
//修改一天摊分数据加
MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, @"update module_price t set t.isoneday=1 where orderid in(select orderid from test_nowteacher)");
Console.WriteLine("入库成功!");
}
catch
{
throw;
}
}
}
/// <summary>
/// 订金清洗
/// </summary>
public static void DingJinClear()
{
//创建 金额清洗表
MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, @"DROP TABLE IF EXISTS `wx_order_payclear`;
CREATE TABLE `wx_order_payclear` (
`id` int(0) NOT NULL AUTO_INCREMENT,
`payid` int(0) NULL DEFAULT 0,
`orderid` int(0) NULL DEFAULT NULL COMMENT '订单号',
`payprice` decimal(10, 2) NULL DEFAULT NULL COMMENT '支付金额',
`paydate` datetime(0) NULL DEFAULT NULL COMMENT '支付时间',
`usedate` datetime(0) NULL DEFAULT NULL COMMENT '支付时间',
`usestatus` int(0) NOT NULL DEFAULT 0 COMMENT 'usestatus=0 未使用 usestatus=1 已使用',
`usetype` int(0) NOT NULL DEFAULT 0 COMMENT 'usertype=0 只付款 usertype=1 正向使用 usertype=-1 退款',
`useprice` decimal(24, 6) NULL DEFAULT NULL COMMENT '计算了苹果支付、魅族支付、华为支付手续费后的金额',
`useprice2` decimal(24, 6) NULL DEFAULT NULL COMMENT '原始金额',
`channel` int(0) NULL DEFAULT NULL COMMENT '渠道',
PRIMARY KEY (`id`) USING BTREE,
INDEX `ix_orderid`(`orderid`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic;
");
//订金入库
MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, @"
INSERT wx_order_payclear (payid,orderid,payprice,paydate,usedate,usestatus,usetype)
select t.id payid,t.orderid,t.payprice,t.paydate,t.paydate usedate,0 usestatus,0 usetype
from wx_szzyorderpay t
where t.auditstatus=1
and t.orderid like '2%';");
//修改订金退款
MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, @"
update wx_order_payclear x set
x.useprice=(select t.refundprice from wx_szzyorderrefund t where x.orderid=t.orderid and t.auditstatus=1),
x.usedate=(select t.audittime from wx_szzyorderrefund t where x.orderid=t.orderid and t.auditstatus=1),
x.channel=(select t.channel from wx_szzyorderrefund t where x.orderid=t.orderid and t.auditstatus=1),
x.usestatus=1,
x.usetype=-1
where exists
(select 1 from wx_szzyorderrefund t where x.orderid=t.orderid and t.auditstatus=1);
");
//插入otime的正向数据
MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, @"
insert into wx_order_payclear(payid,orderid,payprice,paydate,usedate,usestatus,usetype,useprice,channel)
select t.id payid,t.orderid,t.payprice,t.paydate,x.otime,1,1,t.payprice,t.channel from wx_szzyorderpay t
join wx_szzyorder x on x.orderid=t.orderid
where x.otime is not null
and x.orderstatus in(220,205,80,90)
and t.auditstatus=1
;
");
//插入无otime退款数据
MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, @"insert into wx_order_payclear(payid,orderid,usedate,usestatus,usetype,useprice,channel)
select 0,xass.orderid,xass.audittime,1,-1,xass.refundprice,xass.channel from wx_szzyorderrefund xass where xass.id in(
select DISTINCT f.id #,t.id payid,t.orderid,t.payprice,t.paydate,f.refunddate usedate,1 usestatus,1,f.refundprice
from wx_szzyorderpay t
join wx_szzyorder x on x.orderid=t.orderid
left join(select ax.* from wx_szzyorderrefund ax where ax.auditstatus=1) f on f.orderid=t.orderid
where x.otime is null
#and x.orderstatus in(220,205,80,90)
and t.auditstatus=1
and f.refundprice is not null
);
");
//数据清理
MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, @"delete from wx_order_payclear t where t.usestatus=0;
update wx_order_payclear t set t.useprice2=t.useprice;
");
//计算平台手续费后金额
MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, @"drop table module_price_pingtai2;");
//付款金额计算
MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, @"create table module_price_pingtai2
as
select a.id,b.paytype,
(
case
when b.paytype=11 then a.useprice*0.68607
when b.paytype=12 then a.useprice*0.68760
when b.paytype=13 then a.useprice*0.686
end
)
modulePrice
from wx_order_payclear a
left join wx_szzyorderpay b on a.orderid = b.orderid
where paytype is not NULL and b.paytype in(11,12,13)
and a.usetype=1;");
//退款金额计算
MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, @"insert into module_price_pingtai2(id,paytype,modulePrice)
select a.id,b.refundtype,
(
case
when b.refundtype=11 then a.useprice*0.68607
when b.refundtype=12 then a.useprice*0.68760
when b.refundtype=13 then a.useprice*0.686
end
)
modulePrice
from wx_order_payclear a
left join wx_szzyorderrefund b on a.orderid = b.orderid
where refundtype is not NULL and b.refundtype in(11,12,13)
#and b.auditstatus=1
and a.usetype=-1
;");
// 修改数据 平台支付手续费后的金额
MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, @"update wx_order_payclear t set t.useprice=(select x.modulePrice from module_price_pingtai2 x where x.id=t.id)
where exists (select 1 from module_price_pingtai2 x where x.id=t.id);");
}
/// <summary>
/// 被关闭的订单,进行挪价值
/// </summary>
public static void ModuleMovePrice()
{
using (zxdContext db = new zxdContext())
{
}
}
static void MainOrd(string[] args)
{
Console.WriteLine("开始订单性质计算:");
var param = new List<MySqlParameter> { };
MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, @"truncate table wx_szzyorder_redefine", param.ToArray());
WX_SzzyOrder_Redefine_BL bll = new WX_SzzyOrder_Redefine_BL();
using (zxdContext db = new zxdContext())
{
//开通的订单
DateTime time = new DateTime(2021, 08, 1);
string[] orderstats = { "220", "205", "80", "90" };
var openord = db.Wx_Szzyorder_Handle.Where(m => m.OTIME != null && orderstats.Contains(m.ORDERSTATUS) && m.OTIME < time);//有开通时间,表示已经开通了
var ordList22 = (from b in openord
join c in db.WX_SZZYSUBPRODUCT on b.SUBPRODUCTID equals c.SUBPRODUCTID
join userGroup in db.Order_Teacher on b.ORDERID equals userGroup.orderid into jiontemp
from userGroup in jiontemp.DefaultIfEmpty()//左关联(用户组/部门 关系表)
//join d in db.WX_SzzyOrderRefund on b.ORDERID equals d.orderid
//where b.ORDERSTATUS == "90"
//where d.auditstatus == 1
//where b.SOFTUSERNAME == item
select new NewOrd()
{
ord = b,
midproduct = c.MidProductId.Value,
teacher = userGroup.teacher
}).OrderBy(m => m.ord.OTIME).ToList();
Console.WriteLine("总订单数:" + ordList22.Count());
Dictionary<string, List<NewOrd>> dic = new Dictionary<string, List<NewOrd>>();
Dictionary<string, int> softOrdCount = new Dictionary<string, int>();
foreach (var item in ordList22)
{
if (!dic.ContainsKey(item.ord.SOFTUSERNAME))
{
item.xuhao = 1;
dic.Add(item.ord.SOFTUSERNAME, new List<NewOrd>() { item });
softOrdCount.Add(item.ord.SOFTUSERNAME, 1);
}
else
{
softOrdCount[item.ord.SOFTUSERNAME] = softOrdCount[item.ord.SOFTUSERNAME] + 1;
item.xuhao = softOrdCount[item.ord.SOFTUSERNAME];
dic[item.ord.SOFTUSERNAME].Add(item);
}
}
//var softuserlist = ordList22.GroupBy(m => m.ord.SOFTUSERNAME).Select(m => m.Key).ToList();
Console.WriteLine("订单客户数:" + dic.Count());
var product = db.WX_SZZYSUBPRODUCT.ToList();
List<WX_SzzyOrder_Redefine> addlist = new List<WX_SzzyOrder_Redefine>();
foreach (var item in dic)//循环客户
{
//var softOrdList = openord.Where(m => m.SOFTUSERNAME == item).OrderBy(m => m.OTIME);
//var softOrdList2 = ordList22.Where(m => m.ord.SOFTUSERNAME == item).OrderBy(m => m.ord.OTIME).ToList();
//var softOrdList = from a in db.Wx_Szzyorder_Handle
// join c in db.WX_SZZYSUBPRODUCT on a.SUBPRODUCTID equals c.SUBPRODUCTID
// where a.SOFTUSERNAME == item
// where a.OTIME != null
// where a.ARRIVALPAY > 1
// select new NewOrd()
// {
// midproduct = c.MidProductId.Value,
// ord = a
// };
var softOrdList = item.Value;
int i = 0;
int[] productids = { 100800201, 100800202 };//至尊版至尊VIP
int[] qinlongzhizhun = { 100800101, 100800201 };//擒龙版,至尊版
Console.WriteLine("客户:" + item.Key + "订单数:" + softOrdList.Count());
foreach (var myord in softOrdList)//本用户所有订单
{
if (i == 0)
{
WX_SzzyOrder_Redefine model = new WX_SzzyOrder_Redefine()
{
orderid = myord.ord.ORDERID,
softusername = myord.ord.SOFTUSERNAME,
ordertype = "新订单",
midproductid = myord.midproduct,
channel = myord.ord.CHANNEL,
arrivalpay = myord.ord.ARRIVALPAY,
giftdays = myord.ord.giftdays,
opendays = myord.ord.OPENDAYS,
otime = myord.ord.OTIME,
xuhao = myord.xuhao
};
addlist.Add(model);
//db.WX_SzzyOrder_Redefine.Add(model);
//db.SaveChanges();
//preModel = model;//
}
else
{
if (productids.Contains(myord.midproduct))
{
if (myord.midproduct == 100800202)//至尊VIP
{
var ooo = softOrdList.Where(m => m.midproduct == 100800202 && m.ord.OTIME < myord.ord.OTIME);//之前是否还有至尊vip
if (ooo.Count() == 0)//无至尊VIP
{
var bb = softOrdList.Where(m => qinlongzhizhun.Contains(m.midproduct) && m.ord.OTIME < myord.ord.OTIME);//之前是否还有至尊vip
if (bb.Count() == 0)
{
WX_SzzyOrder_Redefine model = new WX_SzzyOrder_Redefine()
{
orderid = myord.ord.ORDERID,
softusername = myord.ord.SOFTUSERNAME,
ordertype = "新订单",
midproductid = myord.midproduct,
channel = myord.ord.CHANNEL,
arrivalpay = myord.ord.ARRIVALPAY,
giftdays = myord.ord.giftdays,
opendays = myord.ord.OPENDAYS,
otime = myord.ord.OTIME,
xuhao = myord.xuhao
};
//db.WX_SzzyOrder_Redefine.Add(model);
//db.SaveChanges();
addlist.Add(model);
}
else
{
if (!string.IsNullOrEmpty(myord.ord.UPGRADEORDERIDS))
{
WX_SzzyOrder_Redefine model = new WX_SzzyOrder_Redefine()
{
orderid = myord.ord.ORDERID,
softusername = myord.ord.SOFTUSERNAME,
ordertype = "补差升级",
midproductid = myord.midproduct,
channel = myord.ord.CHANNEL,
arrivalpay = myord.ord.ARRIVALPAY,
giftdays = myord.ord.giftdays,
opendays = myord.ord.OPENDAYS,
otime = myord.ord.OTIME,
xuhao = myord.xuhao
};
//db.WX_SzzyOrder_Redefine.Add(model);
//db.SaveChanges();
addlist.Add(model);
}
else
{
WX_SzzyOrder_Redefine model = new WX_SzzyOrder_Redefine()
{
orderid = myord.ord.ORDERID,
softusername = myord.ord.SOFTUSERNAME,
ordertype = "产品升级",
midproductid = myord.midproduct,
channel = myord.ord.CHANNEL,
arrivalpay = myord.ord.ARRIVALPAY,
giftdays = myord.ord.giftdays,
opendays = myord.ord.OPENDAYS,
otime = myord.ord.OTIME,
xuhao = myord.xuhao
};
//db.WX_SzzyOrder_Redefine.Add(model);
//db.SaveChanges();
addlist.Add(model);
}
}
}
else//有至尊VIP
{
if (!string.IsNullOrEmpty(myord.ord.UPGRADEORDERIDS))
{
WX_SzzyOrder_Redefine model = new WX_SzzyOrder_Redefine()
{
orderid = myord.ord.ORDERID,
softusername = myord.ord.SOFTUSERNAME,
ordertype = "补差升级",
midproductid = myord.midproduct,
channel = myord.ord.CHANNEL,
arrivalpay = myord.ord.ARRIVALPAY,
giftdays = myord.ord.giftdays,
opendays = myord.ord.OPENDAYS,
otime = myord.ord.OTIME,
xuhao = myord.xuhao
};
//db.WX_SzzyOrder_Redefine.Add(model);
//db.SaveChanges();
addlist.Add(model);
}
else
{
WX_SzzyOrder_Redefine model = new WX_SzzyOrder_Redefine()
{
orderid = myord.ord.ORDERID,
softusername = myord.ord.SOFTUSERNAME,
ordertype = "复购",
midproductid = myord.midproduct,
channel = myord.ord.CHANNEL,
arrivalpay = myord.ord.ARRIVALPAY,
giftdays = myord.ord.giftdays,
opendays = myord.ord.OPENDAYS,
otime = myord.ord.OTIME,
xuhao = myord.xuhao
};
addlist.Add(model);
//db.WX_SzzyOrder_Redefine.Add(model);
//db.SaveChanges();
}
}
}
else
{//100800201至尊版本
var ooo = softOrdList.Where(m => m.midproduct == 100800201 && m.ord.OTIME < myord.ord.OTIME);//之前是否还有至尊vip
if (ooo.Count() == 0)//无至尊版本
{
var bb = softOrdList.Where(m => m.midproduct == 100800101 && m.ord.OTIME < myord.ord.OTIME);//之前是否还有至尊vip
if (bb.Count() == 0)//无擒龙
{
WX_SzzyOrder_Redefine model = new WX_SzzyOrder_Redefine()
{
orderid = myord.ord.ORDERID,
softusername = myord.ord.SOFTUSERNAME,
ordertype = "新订单",
midproductid = myord.midproduct,
channel = myord.ord.CHANNEL,
arrivalpay = myord.ord.ARRIVALPAY,
giftdays = myord.ord.giftdays,
opendays = myord.ord.OPENDAYS,
otime = myord.ord.OTIME,
xuhao = myord.xuhao
};
//db.WX_SzzyOrder_Redefine.Add(model);
//db.SaveChanges();
addlist.Add(model);
}
else
{
if (!string.IsNullOrEmpty(myord.ord.UPGRADEORDERIDS))
{
WX_SzzyOrder_Redefine model = new WX_SzzyOrder_Redefine()
{
orderid = myord.ord.ORDERID,
softusername = myord.ord.SOFTUSERNAME,
ordertype = "补差升级",
midproductid = myord.midproduct,
channel = myord.ord.CHANNEL,
arrivalpay = myord.ord.ARRIVALPAY,
giftdays = myord.ord.giftdays,
opendays = myord.ord.OPENDAYS,
otime = myord.ord.OTIME,
xuhao = myord.xuhao
};
//db.WX_SzzyOrder_Redefine.Add(model);
//db.SaveChanges();
addlist.Add(model);
}
else
{
WX_SzzyOrder_Redefine model = new WX_SzzyOrder_Redefine()
{
orderid = myord.ord.ORDERID,
softusername = myord.ord.SOFTUSERNAME,
ordertype = "产品升级",
midproductid = myord.midproduct,
channel = myord.ord.CHANNEL,
arrivalpay = myord.ord.ARRIVALPAY,
giftdays = myord.ord.giftdays,
opendays = myord.ord.OPENDAYS,
otime = myord.ord.OTIME,
xuhao = myord.xuhao
};
//db.WX_SzzyOrder_Redefine.Add(model);
//db.SaveChanges();
addlist.Add(model);
}
}
}
else
{
if (!string.IsNullOrEmpty(myord.ord.UPGRADEORDERIDS))
{
WX_SzzyOrder_Redefine model = new WX_SzzyOrder_Redefine()
{
orderid = myord.ord.ORDERID,
softusername = myord.ord.SOFTUSERNAME,
ordertype = "补差升级",
midproductid = myord.midproduct,
channel = myord.ord.CHANNEL,
arrivalpay = myord.ord.ARRIVALPAY,
giftdays = myord.ord.giftdays,
opendays = myord.ord.OPENDAYS,
otime = myord.ord.OTIME,
xuhao = myord.xuhao
};
//db.WX_SzzyOrder_Redefine.Add(model);
//db.SaveChanges();
addlist.Add(model);
}
else
{
WX_SzzyOrder_Redefine model = new WX_SzzyOrder_Redefine()
{
orderid = myord.ord.ORDERID,
softusername = myord.ord.SOFTUSERNAME,
ordertype = "复购",
midproductid = myord.midproduct,
channel = myord.ord.CHANNEL,
arrivalpay = myord.ord.ARRIVALPAY,
giftdays = myord.ord.giftdays,
opendays = myord.ord.OPENDAYS,
otime = myord.ord.OTIME,
xuhao = myord.xuhao
};
//db.WX_SzzyOrder_Redefine.Add(model);
//db.SaveChanges();
addlist.Add(model);
}
}
}
}
else//非至尊版至尊VIP
{
var ooo = new List<NewOrd>();
if ((myord.ord.CHANNEL >= 26800 && myord.ord.CHANNEL <= 26899) || (myord.ord.CHANNEL >= 26000 && myord.ord.CHANNEL <= 26199))//新媒体二、平台一
{
ooo = softOrdList.Where(m => m.midproduct == myord.midproduct && m.teacher == myord.teacher && m.ord.OTIME < myord.ord.OTIME).ToList();//小于当前订单同类产品 的集合
}
else
{
ooo = softOrdList.Where(m => m.midproduct == myord.midproduct && m.ord.OTIME < myord.ord.OTIME).ToList();//小于当前订单同类产品 的集合
}
if (ooo.Count() == 0)
{
WX_SzzyOrder_Redefine model = new WX_SzzyOrder_Redefine()
{
orderid = myord.ord.ORDERID,
softusername = myord.ord.SOFTUSERNAME,
ordertype = "新订单",
midproductid = myord.midproduct,
channel = myord.ord.CHANNEL,
arrivalpay = myord.ord.ARRIVALPAY,
giftdays = myord.ord.giftdays,
opendays = myord.ord.OPENDAYS,
otime = myord.ord.OTIME,
xuhao = myord.xuhao
};
//db.WX_SzzyOrder_Redefine.Add(model);
//db.SaveChanges();
addlist.Add(model);
}
else
{
if (!string.IsNullOrEmpty(myord.ord.UPGRADEORDERIDS))
{
WX_SzzyOrder_Redefine model = new WX_SzzyOrder_Redefine()
{
orderid = myord.ord.ORDERID,
softusername = myord.ord.SOFTUSERNAME,
ordertype = "补差升级",
midproductid = myord.midproduct,
channel = myord.ord.CHANNEL,
arrivalpay = myord.ord.ARRIVALPAY,
giftdays = myord.ord.giftdays,
opendays = myord.ord.OPENDAYS,
otime = myord.ord.OTIME,
xuhao = myord.xuhao
};
//db.WX_SzzyOrder_Redefine.Add(model);
//db.SaveChanges();
addlist.Add(model);
}
else
{
WX_SzzyOrder_Redefine model = new WX_SzzyOrder_Redefine()
{
orderid = myord.ord.ORDERID,
softusername = myord.ord.SOFTUSERNAME,
ordertype = "复购",
midproductid = myord.midproduct,
channel = myord.ord.CHANNEL,
arrivalpay = myord.ord.ARRIVALPAY,
giftdays = myord.ord.giftdays,
opendays = myord.ord.OPENDAYS,
otime = myord.ord.OTIME,
xuhao = myord.xuhao
};
//db.WX_SzzyOrder_Redefine.Add(model);
//db.SaveChanges();
addlist.Add(model);
}
//WX_SzzyOrder_Redefine model = new WX_SzzyOrder_Redefine()
//{
// orderid = myord.ord.ORDERID,
// softusername = myord.ord.SOFTUSERNAME,
// ordertype = "复购",
// midproductid = myord.midproduct
//};
////db.WX_SzzyOrder_Redefine.Add(model);
////db.SaveChanges();
//addlist.Add(model);
}
}
}
i++;
}
}
Console.WriteLine("插入数据开始========" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"));
//int xuhao = 0;
//foreach (var item in addlist)
//{
// xuhao++;
// item.xuhao = xuhao;
//}
bll.BulkInsertToMysql("wx_szzyorder_redefine", addlist);
Console.WriteLine("数据插入成功!" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"));
}
//Console.ReadLine();
}
/// <summary>
/// 计算时长
/// </summary>
/// <param name="args"></param>
static void MainTime(string[] args)
{
Console.WriteLine("订单的时间计算:");
var param = new List<MySqlParameter> { };
MySqlDbHelper.ExecuteNonQuery(ConStringHelper.ZxdCRMConn, CommandType.Text, @"truncate table wx_szzyorder_redefine_time", param.ToArray());
using (zxdContext db = new zxdContext())
{
var redefineList = (from a in db.WX_SzzyOrder_Redefine
join b in db.Wx_Szzyorder_Handle on a.orderid equals b.ORDERID
join userGroup in db.Order_Teacher on b.ORDERID equals userGroup.orderid into jiontemp
from userGroup in jiontemp.DefaultIfEmpty()//左关联(用户组/部门 关系表)
select new WX_SzzyOrder_Redefine_MAP
{
entry = a,
otime = b.OTIME.Value,
teacher = userGroup.teacher
}
)
.OrderBy(m => m.otime).ToList();//定性好的数据
string[] orderstats = { "220", "205", "80", "90" };
var openord = db.Wx_Szzyorder_Handle.Where(m => m.OTIME != null && orderstats.Contains(m.ORDERSTATUS));//有开通时间,表示已经开通了
var ordList22 = (from b in openord
join c in db.WX_SZZYSUBPRODUCT on b.SUBPRODUCTID equals c.SUBPRODUCTID
join userGroup in db.Order_Teacher on b.ORDERID equals userGroup.orderid into jiontemp
from userGroup in jiontemp.DefaultIfEmpty()//左关联(用户组/部门 关系表)
//join d in db.WX_SzzyOrderRefund on b.ORDERID equals d.orderid
//where b.ORDERSTATUS == "90"
//where d.auditstatus == 1
//where b.SOFTUSERNAME == item
select new NewOrd()
{
ord = b,
midproduct = c.MidProductId.Value,
teacher = userGroup.teacher
}).OrderBy(m => m.ord.OTIME).ToList();
Console.WriteLine("总订单数:" + ordList22.Count());
Dictionary<string, List<NewOrd>> dic = new Dictionary<string, List<NewOrd>>();
foreach (var item in ordList22)
{
if (!dic.ContainsKey(item.ord.SOFTUSERNAME))
{
dic.Add(item.ord.SOFTUSERNAME, new List<NewOrd>() { item });
}
else
{
dic[item.ord.SOFTUSERNAME].Add(item);
}
}
Dictionary<string, List<WX_SzzyOrder_Redefine_MAP>> redefineDic = new Dictionary<string, List<WX_SzzyOrder_Redefine_MAP>>();
foreach (var item in redefineList)
{
if (!redefineDic.ContainsKey(item.entry.softusername))
{
redefineDic.Add(item.entry.softusername, new List<WX_SzzyOrder_Redefine_MAP>() { item });
}
else
{
redefineDic[item.entry.softusername].Add(item);
}
}
#region ===========================================
Console.WriteLine("正向数据时间计算开始");
foreach (var userredlist in redefineDic)//循环用户的所有订单 处理表
{
//循环当前用户的计算订单列表
foreach (var item in userredlist.Value.OrderBy(m => m.entry.xuhao))
{
Console.WriteLine("订单:" + item.entry.orderid + "," + item.entry.ordertype);
//当前用户的订单列表
var list = dic[item.entry.softusername];
//当前订单的明细数据(订单表)
var entry = list.FirstOrDefault(m => m.ord.ORDERID == item.entry.orderid);
if (item.entry.ordertype == "新订单")
{
item.entry.starttime = entry.ord.OTIME.Value;
item.entry.endtime = entry.ord.OTIME.Value.AddDays(Convert.ToInt32(entry.ord.OPENDAYS.Value) + (entry.ord.giftdays.HasValue ? Convert.ToInt32(entry.ord.giftdays.Value) : 0));//开通时间+赠送时间
}
else if (item.entry.ordertype == "复购")
{
//时间延期,找到同类型未过期产品 的结束时间作为开始时间
var xx = userredlist.Value.OrderByDescending(m => m.entry.xuhao).Where(m => m.entry.midproductid == item.entry.midproductid && m.otime == item.otime && m.entry.orderid != entry.ord.ORDERID);//出现相同的otime
WX_SzzyOrder_Redefine_MAP preorder = new WX_SzzyOrder_Redefine_MAP();
//if ((item.ord.CHANNEL >= 26800 && item.ord.CHANNEL <= 26899) || (item.ord.CHANNEL >= 26000 && item.ord.CHANNEL <= 26199))//新媒体二,平台一
if (xx.Count() > 0)
{//出现Otime重复的需要通过序号来判断
preorder = userredlist.Value.OrderByDescending(m => m.entry.xuhao).FirstOrDefault(m => m.entry.midproductid == item.entry.midproductid
&& m.entry.xuhao < item.entry.xuhao
&& m.entry.orderid != entry.ord.ORDERID
&& m.teacher == item.teacher);//找出小于当前订单
}
else
{
preorder = userredlist.Value.OrderByDescending(m => m.otime).FirstOrDefault(m =>
m.entry.midproductid == item.entry.midproductid
&& m.entry.otime < item.entry.otime
&& m.entry.orderid != entry.ord.ORDERID
&& m.teacher == item.teacher);//找出小于当前订单
}
if (preorder.entry.endtime > entry.ord.OTIME)//如果上一个订单未到期
{
item.entry.starttime = preorder.entry.endtime;
item.entry.endtime = item.entry.starttime.Value.AddDays(Convert.ToInt32(entry.ord.OPENDAYS.Value) + (entry.ord.giftdays.HasValue ? Convert.ToInt32(entry.ord.giftdays.Value) : 0));//开通天数
}
else//如果已经到期,还是用自己的时间
{
item.entry.starttime = entry.ord.OTIME.Value;
item.entry.endtime = entry.ord.OTIME.Value.AddDays(Convert.ToInt32(entry.ord.OPENDAYS.Value) + (entry.ord.giftdays.HasValue ? Convert.ToInt32(entry.ord.giftdays.Value) : 0));//开通天数
}
}
else if (item.entry.ordertype == "补差升级")
{
//补差升级,用新产品的时长,结束上一个产品时长
//当前订单,用当前时间
item.entry.starttime = entry.ord.OTIME.Value;
item.entry.endtime = entry.ord.OTIME.Value.AddDays(Convert.ToInt32(entry.ord.OPENDAYS.Value) + (entry.ord.giftdays.HasValue ? Convert.ToInt32(entry.ord.giftdays.Value) : 0));//开通时间+赠送时间
//var upids = Array.ConvertAll(entry.ord.UPGRADEORDERIDS.Split(','), decimal.Parse);//被升级的订单ID集合
////补差的订单需要结束时长
//var beishengji = userredlist.Value.Where(m => upids.Contains(m.entry.orderid));
//foreach (var bei in beishengji)
//{
// if (bei.entry.endtime > item.entry.starttime)//当时间大于当前的订单的开始时间 需要终止时间
// {
// bei.entry.endtime = item.entry.starttime;
// }
//}
}
else if (item.entry.ordertype == "产品升级")
{
//int[] productids = { 100800201, 100800202 };//至尊版至尊VIP
//int[] qinlongzhizhun = { 100800101, 100800201 };//擒龙版,至尊版
item.entry.starttime = entry.ord.OTIME.Value;
item.entry.endtime = entry.ord.OTIME.Value.AddDays(Convert.ToInt32(entry.ord.OPENDAYS.Value) + (entry.ord.giftdays.HasValue ? Convert.ToInt32(entry.ord.giftdays.Value) : 0));//开通时间+赠送时间
//if (item.entry.midproductid == 100800202)//找到最近的一个至尊或者擒龙版本进行时间结束
//{
//}
}
}
}
Console.WriteLine("正向数据时间计算完毕!");
#endregion
#region 退
Console.WriteLine("退款数据时间计算开始!");
//退款订单
DateTime time1 = new DateTime(2021, 08, 1);
var tuikorder = (from a in db.WX_SzzyOrderRefund
join b in openord on a.orderid equals b.ORDERID
join c in db.WX_SZZYSUBPRODUCT on b.SUBPRODUCTID equals c.SUBPRODUCTID
join userGroup in db.Order_Teacher on b.ORDERID equals userGroup.orderid into jiontemp
from userGroup in jiontemp.DefaultIfEmpty()//左关联(用户组/部门 关系表)
where b.ORDERSTATUS == "90"
where a.auditstatus == 1
where a.audittime < time1
select new NewOrd()
{
ord = b,
midproduct = c.MidProductId.Value,
tuiTime = a.refunddate.Value,//退款审核时间
teacher = userGroup.teacher
}).OrderBy(m => m.tuiTime).ToList();
foreach (var item in tuikorder)
{
var list = dic[item.ord.SOFTUSERNAME];//退款订单对应的用户所有订单信息
var nnx = redefineDic[item.ord.SOFTUSERNAME];//计算表 用户所有订单;
var entry = nnx.FirstOrDefault(m => m.entry.orderid == item.ord.ORDERID);//当期的计算订单信息
entry.entry.statusname = "退款订单";
if (entry.entry.endtime.Value.Date > item.tuiTime && entry.entry.starttime.Value.Date < item.tuiTime)//订单还在使用中
{
var dayj = (entry.entry.endtime.Value.Date - item.tuiTime.Date).Days;
if (entry.entry.orderid == 80207870)
{
Console.WriteLine("a,orderid:" + entry.entry.orderid + ":pre item.tuiTime:" + item.tuiTime.ToString("yyyy-MM-dd HH:mm:ss"));
}
entry.entry.endtime = item.tuiTime;//修改结束时间
string[] typelis = { "复购", "新订单" };
var preModelList = new List<WX_SzzyOrder_Redefine_MAP>();
if ((item.ord.CHANNEL >= 26800 && item.ord.CHANNEL <= 26899) || (item.ord.CHANNEL >= 26000 && item.ord.CHANNEL <= 26199))//新媒体二,平台一
{
preModelList = nnx.Where(m
=> typelis.Contains(m.entry.ordertype)
&& m.entry.midproductid == entry.entry.midproductid
&& entry.teacher == m.teacher
&& m.entry.starttime >= entry.entry.endtime
).OrderBy(m => m.entry.starttime).ToList();//上一个订单
}
else
{
preModelList = nnx.Where(m
=> typelis.Contains(m.entry.ordertype)
&& m.entry.midproductid == entry.entry.midproductid
&& m.entry.starttime >= entry.entry.endtime
).OrderBy(m => m.entry.starttime).ToList();//上一个订单
}
foreach (var pre in preModelList)
{
var ss = (pre.entry.starttime.Value.Date - pre.entry.otime.Value.Date).Days;//开始时间往后移动了多少天
if (pre.entry.orderid == 80207870 || pre.entry.orderid == 80206880)
{
Console.WriteLine("1,orderid:" + pre.entry.orderid + ":pre.entry.starttime:" + pre.entry.starttime.Value.ToString("yyyy-MM-dd HH:mm:ss") + ", pre.entry.endtime :" + pre.entry.endtime.Value.ToString("yyyy-MM-dd HH:mm:ss"));
Console.WriteLine("1orderid:" + pre.entry.orderid + ":ss:" + ss + ",dayj:" + dayj);
}
if (ss > dayj)
{
pre.entry.starttime = pre.entry.starttime.Value.AddDays(-dayj);
pre.entry.endtime = pre.entry.endtime.Value.AddDays(-dayj);
}
else
{
pre.entry.starttime = pre.entry.starttime.Value.AddDays(-ss);
pre.entry.endtime = pre.entry.endtime.Value.AddDays(-ss);// item.tuiTime;//正在使用的订单结束时间==退款时间//
}
}
}
else if (entry.entry.starttime.Value.Date > item.tuiTime)//订单未使用直接退款
{
var dayj = (entry.entry.starttime.Value.Date - item.tuiTime.Date).Days;//退款时间和本来时间的时间差
if (entry.entry.orderid == 80207870)
{
Console.WriteLine("b,orderid:" + entry.entry.orderid + ":pre item.tuiTime:" + item.tuiTime.ToString("yyyy-MM-dd HH:mm:ss"));
}
entry.entry.starttime = item.tuiTime;//订单未使用开时间和结束时间都修改成退款时间
entry.entry.endtime = item.tuiTime;//修改结束时间
string[] typelis = { "复购", "新订单" };
var preModelList = nnx.Where(m
=> typelis.Contains(m.entry.ordertype)
&& m.entry.midproductid == entry.entry.midproductid
&& m.entry.starttime > entry.entry.endtime
&& entry.teacher == m.teacher //如果没有老师你也是null 一样能查找匹配
).OrderBy(m => m.entry.starttime);//上一个订单
foreach (var pre in preModelList)//之后的订单需要时间往前挪
{
//starttime永远大于otime
//var jsuandate = pre.entry.starttime.AddDays(-dayj);
//if (jsuandate < pre.otime)//如果比otime大,就用开通时间
//{
// pre.entry.starttime = jsuandate;
// pre.entry.endtime = pre.entry.endtime.AddDays(-dayj);
//}
//else
//{
// int shijiancha = (pre.entry.starttime.Date-pre.otime.Date).Days;//相差天数
// pre.entry.starttime = pre.otime;//开始时间必须>=otime此时otime=starttimeendtime需要减去时间差
// pre.entry.endtime = pre.entry.endtime.AddDays(-shijiancha); //pre.otime.AddDays(Convert.ToInt32(pre.entry.opendays.Value) + (pre.entry.giftdays.HasValue ? Convert.ToInt32(pre.entry.giftdays.Value) : 0));//开通时间+赠送时间
//}
var ss = (pre.entry.starttime.Value.Date - pre.entry.otime.Value.Date).Days;
if (pre.entry.orderid == 80207870 || pre.entry.orderid == 80206880)
{
Console.WriteLine("2,orderid:" + pre.entry.orderid + ":pre.entry.starttime:" + pre.entry.starttime.Value.ToString("yyyy-MM-dd HH:mm:ss") + ", pre.entry.endtime :" + pre.entry.endtime.Value.ToString("yyyy-MM-dd HH:mm:ss"));
Console.WriteLine("2orderid:" + pre.entry.orderid + ":ss:" + ss + ",dayj:" + dayj);
}
if (ss > dayj)
{
pre.entry.starttime = pre.entry.starttime.Value.AddDays(-dayj);
pre.entry.endtime = pre.entry.endtime.Value.AddDays(-dayj);
}
else
{
pre.entry.starttime = pre.entry.starttime.Value.AddDays(-ss);
pre.entry.endtime = pre.entry.endtime.Value.AddDays(-ss);
}
//pre.entry.starttime = pre.entry.starttime.AddDays(-dayj);
//pre.entry.endtime = pre.entry.endtime.AddDays(-dayj);
}
}
////退款订单
//var tuid = db.WX_SzzyOrder_Redefine.FirstOrDefault(m => m.orderid == item.orderid);
//if (tuid.endtime > item.optime && tuid.starttime < item.optime)
//{
// var dayj = (tuid.endtime.Date - item.optime.Date).Days;
// tuid.endtime = item.optime;
// UpdateWX_SzzyOrder_Redefine(db, tuid);//修改当前订单的结束时间
// var preModelList = db.WX_SzzyOrder_Redefine.Where(m => m.softusername == entry.SOFTUSERNAME && m.midproductid == item.midproduct && m.starttime > item.optime && m.orderid != tuid.orderid).OrderBy(m => m.endtime);//上一个订单
// foreach (var pre in preModelList)
// {
// pre.starttime = pre.starttime.AddDays(-dayj);
// pre.endtime = pre.endtime.AddDays(-dayj);
// UpdateWX_SzzyOrder_Redefine(db, pre);//修改当前订单的结束时间
// }
//}
//else if (tuid.starttime > item.optime)
//{
// var dayj = (tuid.endtime.Date - tuid.starttime.Date).Days;
// //tuid.starttime = item.starttime;
// tuid.endtime = tuid.starttime;
// UpdateWX_SzzyOrder_Redefine(db, tuid);//修改当前订单的结束时间
// var preModelList = db.WX_SzzyOrder_Redefine.Where(m => m.softusername == entry.SOFTUSERNAME && m.midproductid == item.midproduct && m.starttime > item.optime && m.orderid != tuid.orderid).OrderBy(m => m.endtime);//上一个订单
// foreach (var pre in preModelList)
// {
// pre.starttime = pre.starttime.AddDays(-dayj);
// pre.endtime = pre.endtime.AddDays(-dayj);
// UpdateWX_SzzyOrder_Redefine(db, pre);//修改当前订单的结束时间
// }
//}
}
Console.WriteLine("退款数据时间计算完毕!");
#endregion
WX_SzzyOrder_Redefine_Time_BL bll = new WX_SzzyOrder_Redefine_Time_BL();
List<WX_SzzyOrder_Redefine_Time> addlist = new List<WX_SzzyOrder_Redefine_Time>();
foreach (var item in redefineDic)
{
foreach (var map in item.Value)
{
addlist.Add(new WX_SzzyOrder_Redefine_Time()
{
endtime = map.entry.endtime.Value,
midproductid = map.entry.midproductid,
orderid = map.entry.orderid,
ordertype = map.entry.ordertype,
softusername = map.entry.softusername,
starttime = map.entry.starttime.Value,
status = map.entry.status,
statusname = map.entry.statusname,
opendays = map.entry.opendays,
giftdays = map.entry.giftdays,
arrivalpay = map.entry.arrivalpay,
channel = map.entry.channel,
otime = map.entry.otime,
xuhao = map.entry.xuhao
});
}
}
Console.WriteLine("数据写入");
bll.BulkInsertToMysql("wx_szzyorder_redefine_time", addlist);
Console.WriteLine("数据入库结束!");
Console.ReadLine();
}
}
/// <summary>
/// 计算了时间
/// </summary>
/// <param name="args"></param>
void MainOld(string[] args)
{
Console.WriteLine("开始计算:");
using (zxdContext db = new zxdContext())
{
//开通的订单
var openord = db.Wx_Szzyorder_Handle.Where(m => m.OTIME != null && m.ARRIVALPAY > 1);//有开通时间,表示已经开通了
//退款订单
var tuikorder = from a in db.WX_SzzyOrderRefund
join b in openord on a.orderid equals b.ORDERID
join c in db.WX_SZZYSUBPRODUCT on b.SUBPRODUCTID equals c.SUBPRODUCTID
where b.ORDERSTATUS == "90"
where a.auditstatus == 1
select new Ord
{
orderid = a.orderid,
optime = a.audittime.Value,
type = "TK",
midproduct = c.MidProductId.Value,
softusername = b.SOFTUSERNAME
};
//将退款订单和 开通的订单进行合并成一个集合
var allord = (from b in openord
join c in db.WX_SZZYSUBPRODUCT on b.SUBPRODUCTID equals c.SUBPRODUCTID
select new Ord
{
orderid = b.ORDERID,
optime = b.OTIME.Value,
type = "OD",
midproduct = c.MidProductId.Value,
softusername = b.SOFTUSERNAME
}).Union(
tuikorder
)
;
var ordList2 = allord.OrderBy(m => m.optime).ToList();
foreach (var item in ordList2)
{
if (item.type == "OD")
{
item.optime = item.optime.Date;
}
else
{
item.optime = item.optime.Date.AddSeconds(1);
}
}
var ordList = ordList2.OrderBy(m => m.optime).ToList();
//try
//{
foreach (var item in ordList)
{
/*
新订单 金额累加,叠加时长
复购 擒龙版买擒龙版,至尊版买至尊版 金额累加,叠加时长
时长升级 补差价升级高时长版本 金额累加,时长用新订单时长
产品升级 擒龙版买至尊版 金额累加,时长用新订单时长
退复购 退绝对金额减该订单时长剩余价值低于0时长清零
退时长升级 退绝对金额减该订单时长剩余价值低于0时长清零
退产品升级 退绝对金额时长不变剩余价值低于0时长清零
产品状态
在用 1
未使用 2
用完 3
退款 4
被升级 5
擒龙买至尊 6
擒龙版ID100800101
至尊版本ID100800201
*/
//普通订单
var entry = db.Wx_Szzyorder_Handle.FirstOrDefault(m => m.ORDERID == item.orderid);
//升级订单判断
if (!string.IsNullOrEmpty(entry.UPGRADEORDERIDS))
{
//var uporders = Array.ConvertAll(entry.UPGRADEORDERIDS.Split(','), decimal.Parse); ;
//var uporderList = db.WX_SzzyOrder_Redefine.Where(m => uporders.Contains(m.orderid)).ToList();//被升级的订单
//foreach (var up in uporderList)//循环被升级的订单
//{
// if (up.endtime > entry.OTIME.Value)
// {
// up.endtime = entry.OTIME.Value;
// UpdateWX_SzzyOrder_Redefine(db, up);//将被升级的订单修改数据
// var rdlist = db.WX_SzzyOrder_Redefine.Where(m => m.softusername == up.softusername && m.midproductid == up.midproductid && m.starttime > entry.OTIME.Value);
// foreach (var rd in rdlist)
// {
// }
// }
//}
//WX_SzzyOrder_Redefine model = new WX_SzzyOrder_Redefine()
//{
// orderid = item.orderid,
// softusername = item.softusername,
// ordertype = "升级订单",
// starttime = entry.OTIME.Value,
// endtime = entry.OTIME.Value.AddDays(Convert.ToInt32(entry.OPENDAYS.Value) + (entry.giftdays.HasValue ? Convert.ToInt32(entry.giftdays.Value) : 0))//开通时间+赠送时间
//};
//db.WX_SzzyOrder_Redefine.Add(model);
}
else//非升级订单
{
//订单
if (item.type == "OD")
{
var oldOrd = (from b in openord
join c in db.WX_SZZYSUBPRODUCT on b.SUBPRODUCTID equals c.SUBPRODUCTID
where b.SOFTUSERNAME == item.softusername
where b.OTIME < item.optime
where b.UPGRADEORDERIDS != null
where b.UPGRADEORDERIDS != ""
//where c.MidProductId == item.midproduct
select new NewOrd()
{
ord = b,
midproduct = c.MidProductId.Value
}
).ToList();
if (oldOrd.Count() == 0)//新订单
{
WX_SzzyOrder_Redefine model = new WX_SzzyOrder_Redefine()
{
orderid = item.orderid,
softusername = item.softusername,
ordertype = "新订单",
starttime = entry.OTIME.Value,
endtime = entry.OTIME.Value.AddDays(Convert.ToInt32(entry.OPENDAYS.Value) + (entry.giftdays.HasValue ? Convert.ToInt32(entry.giftdays.Value) : 0))//开通时间+赠送时间
,
midproductid = item.midproduct
};
db.WX_SzzyOrder_Redefine.Add(model);
db.SaveChanges();
}
else//复购
{
var nowlist = oldOrd.Where(m => m.midproduct == item.midproduct);//当前分类一样
if (nowlist.Count() == 0)//非同类型产品
{ //当前订单为至尊版本
if (item.midproduct == 100800201)
{
var qinlonglist = oldOrd.Where(m => m.midproduct == 100800101);//擒龙版订单
if (qinlonglist.Count() > 0)//如果有擒龙版订单
{
WX_SzzyOrder_Redefine model = new WX_SzzyOrder_Redefine()
{
orderid = item.orderid,
softusername = item.softusername,
ordertype = "擒龙复购至尊",
starttime = entry.OTIME.Value,
endtime = entry.OTIME.Value.AddDays(Convert.ToInt32(entry.OPENDAYS.Value) + (entry.giftdays.HasValue ? Convert.ToInt32(entry.giftdays.Value) : 0))//开通时间+赠送时间
,
midproductid = item.midproduct
};
db.WX_SzzyOrder_Redefine.Add(model);
db.SaveChanges();
}
else
{
WX_SzzyOrder_Redefine model = new WX_SzzyOrder_Redefine()
{
orderid = item.orderid,
softusername = item.softusername,
ordertype = "至尊版新单",
starttime = entry.OTIME.Value,
endtime = entry.OTIME.Value.AddDays(Convert.ToInt32(entry.OPENDAYS.Value) + (entry.giftdays.HasValue ? Convert.ToInt32(entry.giftdays.Value) : 0))//开通时间+赠送时间
,
midproductid = item.midproduct
};
db.WX_SzzyOrder_Redefine.Add(model);
db.SaveChanges();
}
}
else
{
WX_SzzyOrder_Redefine model = new WX_SzzyOrder_Redefine()
{
orderid = item.orderid,
softusername = item.softusername,
ordertype = "新订单",
starttime = entry.OTIME.Value,
endtime = entry.OTIME.Value.AddDays(Convert.ToInt32(entry.OPENDAYS.Value) + (entry.giftdays.HasValue ? Convert.ToInt32(entry.giftdays.Value) : 0))//开通时间+赠送时间
,
midproductid = item.midproduct
};
db.WX_SzzyOrder_Redefine.Add(model);
db.SaveChanges();
}
}//同类型产品复购
else
{
var preModel = db.WX_SzzyOrder_Redefine.Where(m => m.softusername == entry.SOFTUSERNAME && m.midproductid == item.midproduct).OrderByDescending(m => m.endtime).FirstOrDefault();//上一个订单
if (preModel != null)
{
WX_SzzyOrder_Redefine model = new WX_SzzyOrder_Redefine()
{
orderid = item.orderid,
softusername = item.softusername,
ordertype = "同类产品复购",
starttime = preModel.endtime,
endtime = preModel.endtime.Value.AddDays(Convert.ToInt32(entry.OPENDAYS.Value) + (entry.giftdays.HasValue ? Convert.ToInt32(entry.giftdays.Value) : 0))//开通时间+赠送时间
,
midproductid = item.midproduct
};
db.WX_SzzyOrder_Redefine.Add(model);
db.SaveChanges();
}
}
}
}
else
{
//退款订单
var tuid = db.WX_SzzyOrder_Redefine.FirstOrDefault(m => m.orderid == item.orderid);
if (tuid.endtime > item.optime && tuid.starttime < item.optime)
{
var dayj = (tuid.endtime.Value.Date - item.optime.Date).Days;
tuid.endtime = item.optime;
UpdateWX_SzzyOrder_Redefine(db, tuid);//修改当前订单的结束时间
var preModelList = db.WX_SzzyOrder_Redefine.Where(m => m.softusername == entry.SOFTUSERNAME && m.midproductid == item.midproduct && m.starttime > item.optime && m.orderid != tuid.orderid).OrderBy(m => m.endtime);//上一个订单
foreach (var pre in preModelList)
{
pre.starttime = pre.starttime.Value.AddDays(-dayj);
pre.endtime = pre.endtime.Value.AddDays(-dayj);
UpdateWX_SzzyOrder_Redefine(db, pre);//修改当前订单的结束时间
}
}
else if (tuid.starttime > item.optime)
{
var dayj = (tuid.endtime.Value.Date - tuid.starttime.Value.Date).Days;
//tuid.starttime = item.starttime;
tuid.endtime = tuid.starttime;
UpdateWX_SzzyOrder_Redefine(db, tuid);//修改当前订单的结束时间
var preModelList = db.WX_SzzyOrder_Redefine.Where(m => m.softusername == entry.SOFTUSERNAME && m.midproductid == item.midproduct && m.starttime > item.optime && m.orderid != tuid.orderid).OrderBy(m => m.endtime);//上一个订单
foreach (var pre in preModelList)
{
pre.starttime = pre.starttime.Value.AddDays(-dayj);
pre.endtime = pre.endtime.Value.AddDays(-dayj);
UpdateWX_SzzyOrder_Redefine(db, pre);//修改当前订单的结束时间
}
}
}
}
//Console.WriteLine(item.orderid);
}
//}
//catch (Exception e)
//{
// Console.WriteLine("出现错误:" +e.ToString());
//}
}
Console.ReadLine();
}
/// <summary>
/// 修改状态表数据
/// </summary>
/// <param name="db"></param>
/// <param name="model"></param>
public static void UpdateWX_SzzyOrder_Redefine(zxdContext db, WX_SzzyOrder_Redefine model)
{
var entry = db.WX_SzzyOrder_Redefine.FirstOrDefault(m => m.orderid == model.orderid);
entry.ordertype = model.ordertype;
entry.softusername = model.softusername;
entry.starttime = model.starttime;
entry.endtime = model.endtime;
entry.status = model.status;
entry.statusname = model.statusname;
db.SaveChanges();
}
public class Ord
{
public string softusername { get; set; }
public decimal orderid { get; set; }
/// <summary>
/// 操作时间,订单开通时间,或者退款的审核时间
/// </summary>
public DateTime optime { get; set; }
/// <summary>
/// TK:退款订单
/// OD:订单
/// </summary>
public string type { get; set; }
public int midproduct { get; set; }
}
public class NewOrd
{
public Wx_Szzyorder_Handle ord { get; set; }
public int midproduct { get; set; }
public DateTime tuiTime { get; set; }
public string teacher { get; set; }
public int xuhao { get; set; }
}
public class WX_SzzyOrder_Redefine_MAP
{
public WX_SzzyOrder_Redefine entry { get; set; }
public DateTime otime { get; set; }
public string teacher { get; set; }
}
public class Module_Price_M
{
public string MainSzzyorderid { get; set; }
public int id { get; set; }
public int? orderid { get; set; }
public string szzyorderid { get; set; }
public string moduleid { get; set; }
public DateTime? starttime2 { get; set; }
public DateTime? endtime2 { get; set; }
public DateTime? otime2 { get; set; }
public DateTime? ctime2 { get; set; }
public decimal? orderPrice { get; set; }
public decimal? modulePrice { get; set; }
public int? midproductid { get; set; }
public string username { get; set; }
public int? opendays2 { get; set; }
public int? isBu { get; set; }
public int? isoneday { get; set; }
public int? channel { get; set; }
public decimal? modulePrice2 { get; set; }
public int xuhao { get; set; }
}
}
}