2026-03-16 02:47:48 +08:00
using Mtxfw.Model ;
using System ;
using System.Collections ;
using System.Collections.Generic ;
using System.Configuration ;
using System.Data ;
using System.Data.SqlClient ;
using System.Data.SqlTypes ;
using System.Globalization ;
using System.IO ;
using System.Security.Cryptography ;
using System.Text ;
namespace Mtxfw.DAL
{
public class MemberStatistics_huiyuan
{
private static user_info daoUser = new user_info ( ) ;
private static user_Results daoResults = new user_Results ( ) ;
private static user_Results_jl2 daojl2 = new user_Results_jl2 ( ) ;
private static user_jjfp daojjfp = new user_jjfp ( ) ;
private static order_info daoorder = new order_info ( ) ;
private static Mtxfw . DAL . Article daoArt = new Mtxfw . DAL . Article ( ) ;
private static user_proxy daoproxy = new user_proxy ( ) ;
private static DAL . P_Product daoProduct = new DAL . P_Product ( ) ;
private static DAL . P_Guige daoGuige = new DAL . P_Guige ( ) ;
private static DAL . business_info daobusiness = new DAL . business_info ( ) ;
#region 更 新 新 零 售 和 批 发 业 绩
/// <summary>
/// 更新业绩和积分,并记录业绩明细
/// </summary>
/// <param name="config"></param>
/// <param name="umodel"></param>
2026-03-20 02:20:12 +08:00
/// <param name="pv">付款金额</param>
/// <param name="xfz">消费值</param>
2026-03-16 02:47:48 +08:00
/// <param name="gtype"></param>
/// <param name="dt"></param>
2026-03-20 02:20:12 +08:00
/// <param name="ttype">0热卖推荐, 1会员商城</param>
2026-03-16 02:47:48 +08:00
/// <param name="ptype"></param>
/// <param name="peitype"></param>
/// <param name="orderid"></param>
/// <param name="OId"></param>
/// <param name="Province"></param>
/// <param name="City"></param>
/// <param name="County"></param>
/// <param name="Tradingarea"></param>
2026-03-20 02:20:12 +08:00
public static void UpdteYJ ( Mtxfw . Utility . Config config , Model . user_info umodel , Double pv , Double xfz , int gtype , DateTime dt , int ttype , int ptype , int peitype , string orderid , int OId , string Province , string City , string County , string Tradingarea )
2026-03-16 02:47:48 +08:00
{
Model . User_Errlog mo ;
string mindt = DateTime . Now . ToString ( "yyyy-MM-dd" ) + " 00:00:00" ;
string maxdt = DateTime . Now . AddDays ( 1 ) . ToString ( "yyyy-MM-dd" ) + " 00:00:00" ;
try
{
#region 不 知 道 干 嘛 , 但 尊 重 历 史
Model . user_Results_jl2 mjl2 ;
mjl2 = new Model . user_Results_jl2 ( ) ;
mjl2 . MemberId = umodel . Id ;
mjl2 . MemberId2 = 0 ;
mjl2 . Addmoney = pv ;
mjl2 . Cutmoney = 0 ;
mjl2 . Totalmoney = umodel . umoney20 + pv ;
mjl2 . addtime = dt ;
2026-03-20 02:20:12 +08:00
mjl2 . BZContent = ttype = = 0 ? "购买热卖商品" : "购买商城商品" ;
2026-03-16 02:47:48 +08:00
mjl2 . PayID = "" ;
mjl2 . OrdersIDs = "" ;
mjl2 . OrdersID = 0 ;
mjl2 . utype = 8 ;
mjl2 . utype2 = 0 ; //0新零售业绩
mjl2 . Seef = 0 ;
mjl2 . seeftime = dt ;
mjl2 . gtype = gtype ;
daojl2 . Add ( mjl2 ) ;
mjl2 = new Model . user_Results_jl2 ( ) ;
umodel . umoney20 + = pv ;
umodel . umoney20 = Convert . ToDouble ( umodel . umoney20 . ToString ( "f2" ) ) ;
daoUser . UpdateMoney ( "umoney20" , pv , umodel . Id ) ;
umodel . umoney21 + = pv ;
umodel . umoney21 = Convert . ToDouble ( umodel . umoney21 . ToString ( "f2" ) ) ;
daoUser . UpdateMoney ( "umoney21" , pv , umodel . Id ) ;
if ( umodel . uLevel7 = = 1 )
{
umodel . uLevel7 = 0 ;
daoUser . UpdateuLevel ( "uLevel7" , umodel . uLevel7 , umodel . Id ) ;
}
if ( umodel . uLevel14 = = 0 )
{
daoUser . UpdateuLevel ( "uLevel14" , 1 , umodel . Id ) ;
}
//if (umodel.uLevel < (ptype + 1))
//{
// daoUser.UpdateuLevel("uLevel", (ptype + 1), umodel.Id);
//}
#endregion
2026-03-20 02:20:12 +08:00
///如果热卖推荐且符合条件更新自己的等级
2026-03-20 10:14:07 +08:00
var uplevel = 0 ;
if ( ttype = = 0 )
2026-03-20 02:20:12 +08:00
{
2026-03-20 10:14:07 +08:00
uplevel = UpdteSelfuLevel ( gtype , umodel , config , ptype , pv ) ;
2026-03-20 02:20:12 +08:00
}
2026-03-16 02:47:48 +08:00
/// umodel.ContactIDS 值的格式如下:",68,160021,160023,160024,"
string [ ] ASuperiorsIDS = ( umodel . ContactIDS ) . Split ( ',' ) ;
int uds = 1 , uds0 = 1 , uds1 = 1 ;
int YContactID = umodel . ContactID ;
string YContactIDS = umodel . ContactIDS ;
ASuperiorsIDS = ( umodel . ContactIDS ) . Split ( ',' ) ;
Double yfbl = 0 ;
for ( int ak = ASuperiorsIDS . Length - 2 ; ak > 0 ; ak - - )
{
if ( ASuperiorsIDS [ ak ] ! = "" )
{
//
DataSet ds = daoUser . GetList1 ( "ID,ContactIDS,ContactID,umoney17,umoney18,uLevel" , "gtype=" + gtype + " and UserState='正常' And IFStores=0 And uLevel17=0 And id=" + ASuperiorsIDS [ ak ] ) ;
if ( ds . Tables [ 0 ] . Rows . Count > 0 )
{
int dID = Convert . ToInt32 ( ds . Tables [ 0 ] . Rows [ 0 ] [ "ID" ] . ToString ( ) ) ;
//string YContactID = ds.Tables[0].Rows[0]["ContactID"].ToString();
//string YContactIDS = ds.Tables[0].Rows[0]["ContactIDS"].ToString();
Double umoney18 = Convert . ToDouble ( ( Convert . ToDouble ( ds . Tables [ 0 ] . Rows [ 0 ] [ "umoney18" ] ) + pv ) . ToString ( "f2" ) ) ;
//Double Yumoney19 = Convert.ToDouble((Convert.ToDouble(ds.Tables[0].Rows[0]["umoney19"]) + pv).ToString("f2"));
int YuLevel = Convert . ToInt32 ( ds . Tables [ 0 ] . Rows [ 0 ] [ "uLevel" ] . ToString ( ) ) ;
//int YuLevel4 = Convert.ToInt32(ds.Tables[0].Rows[0]["uLevel4"].ToString());
//int YuLevel11 = Convert.ToInt32(ds.Tables[0].Rows[0]["uLevel11"].ToString());
//int YIFBecomeAgents = Convert.ToInt32(ds.Tables[0].Rows[0]["IFBecomeAgents"].ToString());
//已分的奖金比例
//推荐链条中的人等级比被推荐人等级高,才可以分奖金
if ( umodel . uLevel < ( YuLevel ) )
{
daoUser . UpdateMoney ( "umoney18" , pv , dID ) ;
daoUser . UpdateMoney ( "umoney19" , pv , dID ) ;
var isLast = ak = = 1 ;
2026-03-20 02:20:12 +08:00
//热卖商品,且遍历到当前会员是付款仁直接推荐人,则计算佣金
if ( ttype = = 0 & & YuLevel = = YContactID )
{
//计算佣金
YongJinJS ( config , umodel , ds . Tables [ 0 ] . Rows [ 0 ] , YContactID , YContactIDS , pv , xfz , yfbl , ttype ) ;
}
//结算奖金(按等级算批发差价)
yfbl = JiangJinJS ( config , umodel , ds . Tables [ 0 ] . Rows [ 0 ] , YContactID , YContactIDS , pv , xfz , yfbl , ttype ) ;
2026-03-16 02:47:48 +08:00
}
///再更新上级等级
/////如果符合条件更新自己的等级 移到上面了,这里 注释掉了,如果今后没影响,记得删掉,留着没意义
//var uplevel = UpdteSelfuLevel(gtype, umodel, config, ptype, pv);
2026-03-20 02:20:12 +08:00
///如果热卖商城的商品,更新上级的等级
if ( uplevel > 0 & & ttype = = 0 )
2026-03-16 02:47:48 +08:00
{
UpdteContacttLevel ( gtype , umodel , config , ds . Tables [ 0 ] . Rows [ 0 ] , YContactID , YContactIDS , uplevel ) ;
///上面更新金额和等级的几个方法顺序不能颠倒,否则会出错
}
}
ds . Clear ( ) ;
}
}
}
catch ( Exception ex )
{
mo = new Model . User_Errlog ( ) ;
mo . DLID = 0 ;
mo . ErrType = "更新新零售业绩" ;
mo . addtime = dt ;
mo . ErrBody = ex . ToString ( ) ;
mo . ErrBody2 = ex . Message ;
new DAL . User_Errlog ( ) . Add ( mo ) ;
}
}
#endregion
#region 更 新 会 员 级 别
/// <summary>
/// 通过购买指定商品,或指定金额提升自己会员级别
/// </summary>
/// <param name="gtype"></param>
/// <param name="umodel">自己的数据</param>
/// <param name="config">配置文件</param>
/// <param name="ptype">直通升级商品级别</param>
/// <param name="pv">金额</param>
public static int UpdteSelfuLevel ( int gtype , Model . user_info umodel , Mtxfw . Utility . Config config , int ptype , Double pv )
{
Model . User_Errlog mo ;
DateTime dt = DateTime . Now ;
try
{
if ( umodel ! = null )
{
int dID = umodel . Id ;
int duLevel = umodel . uLevel ;
var uplevel1_amount = config . direct_upgrade_level1_amount_condition ;
var uplevel2_amount = config . direct_upgrade_level2_amount_condition ;
var uplevel3_amount = config . direct_upgrade_level3_amount_condition ;
var uplevel4_amount = config . direct_upgrade_level4_amount_condition ;
2026-03-23 18:11:54 +08:00
var uplevel5_amount = config . direct_upgrade_level5_amount_condition ;
2026-03-16 02:47:48 +08:00
if ( duLevel < ptype )
{
var flag = daoUser . UpdateuLevel ( "uLevel" , ptype , dID ) ;
if ( ptype = = 1 )
{
//买1级商品提升到1级会员, 并加积分
daoUser . UpdateMoney ( "umoney30" , pv , dID ) ;
}
return flag ? 1 : 0 ;
}
else if ( uplevel1_amount > 0 & & pv > = uplevel1_amount & & duLevel < 1 )
{
//买1级商品提升到1级会员, 并加积分
daoUser . UpdateMoney ( "umoney30" , pv , dID ) ;
var flag = daoUser . UpdateuLevel ( "uLevel" , 1 , dID ) ;
return flag ? 1 : 0 ;
}
else if ( uplevel2_amount > 0 & & pv > = uplevel2_amount & & duLevel < 2 )
{
var flag = daoUser . UpdateuLevel ( "uLevel" , 2 , dID ) ;
return flag ? 2 : 0 ;
}
else if ( uplevel3_amount > 0 & & pv > = uplevel3_amount & & duLevel < 3 )
{
var flag = daoUser . UpdateuLevel ( "uLevel" , 3 , dID ) ;
return flag ? 3 : 0 ;
}
else if ( uplevel4_amount > 0 & & pv > = uplevel4_amount & & duLevel < 4 )
{
var flag = daoUser . UpdateuLevel ( "uLevel" , 4 , dID ) ;
return flag ? 4 : 0 ;
}
2026-03-23 18:11:54 +08:00
else if ( uplevel5_amount > 0 & & pv > = uplevel5_amount & & duLevel < 4 )
{
var flag = daoUser . UpdateuLevel ( "uLevel" , 5 , dID ) ;
return flag ? 3 : 0 ;
}
2026-03-16 02:47:48 +08:00
}
}
catch ( Exception ex )
{
mo = new Model . User_Errlog ( ) ;
mo . DLID = 0 ;
mo . ErrType = "更新自身会员级别" ;
mo . addtime = dt ;
mo . ErrBody = ex . ToString ( ) ;
mo . ErrBody2 = ex . Message ;
new DAL . User_Errlog ( ) . Add ( mo ) ;
}
return 0 ;
}
/// <summary>
/// 推荐链条中的升级机制
/// </summary>
/// <param name="gtype"></param>
/// <param name="umodel">自己的数据</param>
/// <param name="config">配置文件</param>
/// <param name="Rows">上级的数据</param>
/// <param name="YContactID">直属上级</param>
/// <param name="YContactIDS">上级链条</param>
/// <param name="selflevel">我当前上升到的等级</param>
public static void UpdteContacttLevel ( int gtype , Model . user_info umodel , Mtxfw . Utility . Config config , DataRow Rows , int YContactID , string YContactIDS , int selflevel )
{
Model . User_Errlog mo ;
DateTime dt = DateTime . Now ;
try
{
var rowid = Convert . ToInt32 ( Rows [ "ID" ] . ToString ( ) ) ;
var rowlevel = Convert . ToInt32 ( Rows [ "uLevel" ] . ToString ( ) ) ;
//只给直属上级升级,如果不是直属上级就不升级了
if ( YContactID ! = rowid )
{
return ;
}
//如果直接上级等级小于1, 就不升级了.从第1级开始这种类别的升级
if ( rowlevel < 1 )
{
return ;
}
//如果当前级别超过直接上级,直接上级就不能通过他不升级了
if ( selflevel > rowlevel )
{
return ;
}
if ( umodel ! = null )
{
2026-03-23 18:11:54 +08:00
var uplevel5_amount = config . upgrade_level5_amount_condition ;
2026-03-16 02:47:48 +08:00
var uplevel3_amount = config . upgrade_level3_amount_condition ;
var uplevel4_amount = config . upgrade_level4_amount_condition ;
2026-03-23 18:11:54 +08:00
var upgrade_level5 = config . upgrade_level5_person_condition ;
2026-03-16 02:47:48 +08:00
var upgrade_level3 = config . upgrade_level3_person_condition ;
var upgrade_level4 = config . upgrade_level4_person_condition ;
var umoneyyjze = umodel . umoney18 ;
var uplevel = 0 ;
var tjcount = 0 ;
switch ( selflevel )
{
2026-03-23 18:11:54 +08:00
//case 2:
// if (rowlevel == 2)
// {
// // rowlevel是否升到2级的条件
// if (uplevel2_amount>0 && upgrade_level2>0)
// {
// tjcount = daoUser.GetCount("gtype=" + gtype + " and IFStores=0 And userstate='正常' and ContactID=" + rowid + " and uLevel=" + rowlevel + "");
// if (tjcount >= upgrade_level2 && umoneyyjze >= uplevel2_amount)
// {
// uplevel = 2;
// }
// }
2026-03-16 02:47:48 +08:00
2026-03-23 18:11:54 +08:00
// }
// break;
case 3 :
2026-03-16 02:47:48 +08:00
//
2026-03-23 18:11:54 +08:00
if ( rowlevel = = 3 )
2026-03-16 02:47:48 +08:00
{
// rowlevel是否升到3级的条件
2026-03-23 18:11:54 +08:00
if ( uplevel3_amount > 0 & & upgrade_level3 > 0 )
2026-03-16 02:47:48 +08:00
{
tjcount = daoUser . GetCount ( "gtype=" + gtype + " and IFStores=0 And userstate='正常' and ContactID=" + rowid + " and uLevel=" + rowlevel + "" ) ;
2026-03-23 18:11:54 +08:00
if ( tjcount > = upgrade_level3 & & umoneyyjze > = uplevel3_amount )
2026-03-16 02:47:48 +08:00
{
uplevel = 3 ;
}
}
}
break ;
2026-03-23 18:11:54 +08:00
case 4 :
if ( rowlevel = = 4 )
2026-03-16 02:47:48 +08:00
{
// rowlevel是否升到4级的条件
2026-03-23 18:11:54 +08:00
if ( uplevel4_amount > 0 & & upgrade_level4 > 0 )
2026-03-16 02:47:48 +08:00
{
tjcount = daoUser . GetCount ( "gtype=" + gtype + " and IFStores=0 And userstate='正常' and ContactID=" + rowid + " and uLevel=" + rowlevel + "" ) ;
2026-03-23 18:11:54 +08:00
if ( tjcount > = upgrade_level4 & & umoneyyjze > = uplevel4_amount )
2026-03-16 02:47:48 +08:00
{
uplevel = 4 ;
}
}
}
break ;
2026-03-23 18:11:54 +08:00
case 5 :
2026-03-16 02:47:48 +08:00
if ( rowlevel = = 4 )
{
// rowlevel是否升到5级的条件
2026-03-23 18:11:54 +08:00
if ( uplevel5_amount > 0 & & upgrade_level5 > 0 )
2026-03-16 02:47:48 +08:00
{
tjcount = daoUser . GetCount ( "gtype=" + gtype + " and IFStores=0 And userstate='正常' and ContactID=" + rowid + " and uLevel=" + rowlevel + "" ) ;
2026-03-23 18:11:54 +08:00
if ( tjcount > = upgrade_level5 & & umoneyyjze > = uplevel5_amount )
2026-03-16 02:47:48 +08:00
{
uplevel = 5 ;
}
}
}
break ;
}
if ( uplevel > 0 )
{
daoUser . UpdateuLevel ( "uLevel" , uplevel , rowid ) ;
}
}
}
catch ( Exception ex )
{
mo = new Model . User_Errlog ( ) ;
mo . DLID = 0 ;
mo . ErrType = "更新自身会员级别" ;
mo . addtime = dt ;
mo . ErrBody = ex . ToString ( ) ;
mo . ErrBody2 = ex . Message ;
new DAL . User_Errlog ( ) . Add ( mo ) ;
}
}
public static void UpdteuLevel ( int gtype , Mtxfw . Utility . Config config , int dID , string YContactIDS , int YuLevel , int YuLevel4 , int YuLevel11 , int YIFBecomeAgents , Double Yumoney18 , Double Yumoney19 , DateTime dt )
{
int duLevel = YuLevel ;
int ccount = 0 ;
int tjcount = daoUser . GetCount ( "gtype=" + gtype + " and IFStores=0 And userstate='正常' and uLevel14=1 and ContactID=" + dID + "" ) ;
//acount = daoUser.GetCount("gtype=" + gtype + " and IFStores=0 And userstate='正常' And (uLevel14=1 or uLevel24=1) and uLevel17=0 and ContactIDS like '" + YContactIDS + dID + ",%'");
if ( duLevel < 1 )
{
if ( config . webMoney69 ! = "0" | | config . webMoney70 ! = "0" )
{
if ( tjcount > = Convert . ToInt32 ( config . webMoney69 ) & & Yumoney18 > = Convert . ToDouble ( ( Convert . ToDouble ( config . webMoney70 ) * 10000 ) . ToString ( "f2" ) ) )
{
duLevel = 1 ;
}
}
}
if ( duLevel < 2 )
{
if ( config . webMoney73 ! = "0" | | config . webMoney79 ! = "0" )
{
if ( tjcount > = Convert . ToInt32 ( config . webMoney73 ) & & Yumoney18 > = Convert . ToDouble ( ( Convert . ToDouble ( config . webMoney79 ) * 10000 ) . ToString ( "f2" ) ) )
{
duLevel = 2 ;
}
}
}
if ( duLevel < 3 )
{
if ( config . webMoney23 ! = "0" | | config . webMoney26 ! = "0" )
{
if ( tjcount > = Convert . ToInt32 ( config . webMoney23 ) & & Yumoney18 > = Convert . ToDouble ( ( Convert . ToDouble ( config . webMoney26 ) * 10000 ) . ToString ( "f2" ) ) )
{
duLevel = 3 ;
}
}
}
if ( duLevel < 4 )
{
if ( config . webMoney24 ! = "0" | | config . webMoney27 ! = "0" )
{
if ( tjcount > = Convert . ToInt32 ( config . webMoney24 ) & & Yumoney18 > = Convert . ToDouble ( ( Convert . ToDouble ( config . webMoney27 ) * 10000 ) . ToString ( "f2" ) ) )
{
duLevel = 4 ;
}
}
}
if ( duLevel < 5 )
{
if ( config . webMoney25 ! = "0" | | config . webMoney28 ! = "0" )
{
if ( tjcount > = Convert . ToInt32 ( config . webMoney25 ) & & Yumoney18 > = Convert . ToDouble ( ( Convert . ToDouble ( config . webMoney28 ) * 10000 ) . ToString ( "f2" ) ) )
{
duLevel = 5 ;
}
}
}
if ( duLevel < 6 )
{
int vcount = 0 ;
DataSet dss = daoUser . GetList1 ( "id,ContactIDS" , "gtype=" + gtype + " and IFStores=0 And userstate='正常' and ContactID=" + dID + "" ) ;
if ( dss . Tables [ 0 ] . Rows . Count > 0 )
{
foreach ( System . Data . DataRow Drr in dss . Tables [ 0 ] . Rows )
{
int aid = Convert . ToInt32 ( Drr [ "id" ] ) ;
string aContactIDS = Drr [ "ContactIDS" ] . ToString ( ) ;
int acount = daoUser . GetCount ( "gtype=" + gtype + " and IFStores=0 And userstate='正常' And uLevel>4 and (id=" + aid + " or ContactIDS Like '" + aContactIDS + aid + ",%')" ) ;
if ( acount > 0 )
{
vcount + = 1 ;
}
}
}
dss . Clear ( ) ;
if ( vcount > = Convert . ToInt32 ( config . webMoney172 ) )
{
duLevel = 6 ;
}
}
if ( YuLevel ! = duLevel )
{
if ( YuLevel > duLevel )
{
if ( YIFBecomeAgents = = 0 )
{
Mtxfw . Model . user_Results_jl4 Modeljl4 = new Mtxfw . Model . user_Results_jl4 ( ) ;
Modeljl4 . MemberId = dID ;
Modeljl4 . MemberId0 = 0 ;
Modeljl4 . MemberId1 = YuLevel ;
Modeljl4 . MemberId2 = duLevel ;
Modeljl4 . IFMFSJ = tjcount ;
Modeljl4 . IFUpdateMoney = ccount ;
Modeljl4 . UpdateMoney = Yumoney18 ;
Modeljl4 . UpdateMoney2 = 0 ;
Modeljl4 . utype = "5" ;
Modeljl4 . addtime = dt ;
Modeljl4 . gtype = 0 ;
new DAL . user_Results_jl4 ( ) . Add ( Modeljl4 ) ;
daoUser . UpdateuLevel ( "uLevel" , duLevel , dID ) ;
}
}
else
{
Mtxfw . Model . user_Results_jl4 Modeljl4 = new Mtxfw . Model . user_Results_jl4 ( ) ;
Modeljl4 . MemberId = dID ;
Modeljl4 . MemberId0 = 0 ;
Modeljl4 . MemberId1 = YuLevel ;
Modeljl4 . MemberId2 = duLevel ;
Modeljl4 . IFMFSJ = tjcount ;
Modeljl4 . IFUpdateMoney = ccount ;
Modeljl4 . UpdateMoney = Yumoney18 ;
Modeljl4 . UpdateMoney2 = 0 ;
Modeljl4 . utype = "5" ;
Modeljl4 . addtime = dt ;
Modeljl4 . gtype = 0 ;
new DAL . user_Results_jl4 ( ) . Add ( Modeljl4 ) ;
daoUser . UpdateuLevel ( "uLevel" , duLevel , dID ) ;
}
}
int duLevel4 = YuLevel4 ;
if ( duLevel4 < 4 )
{
Double zcount = 0.00 ;
Double maxzcount = 0.00 ;
Double minzcount = 0.00 ;
DataSet dss = daoUser . GetList1 ( "id,umoney19" , "gtype=" + gtype + " and IFStores=0 And userstate='正常' and uLevel17=0 and ContactID=" + dID + "" ) ;
if ( dss . Tables [ 0 ] . Rows . Count > 0 )
{
foreach ( System . Data . DataRow Drr in dss . Tables [ 0 ] . Rows )
{
int aid = Convert . ToInt32 ( Drr [ "id" ] ) ;
Double umoney19 = Convert . ToDouble ( Convert . ToDouble ( Drr [ "umoney19" ] . ToString ( ) ) . ToString ( "f2" ) ) ;
zcount + = umoney19 ;
if ( maxzcount = = 0.00 )
{
maxzcount = umoney19 ;
}
else
{
if ( maxzcount < umoney19 )
{
maxzcount = umoney19 ;
}
}
}
}
dss . Clear ( ) ;
minzcount = ( zcount - maxzcount ) ;
if ( duLevel4 < 1 )
{
if ( minzcount > = Convert . ToDouble ( Convert . ToDouble ( config . webMoney3 ) . ToString ( "f2" ) ) )
{
duLevel4 = 1 ;
}
}
if ( duLevel4 < 2 )
{
if ( minzcount > = Convert . ToDouble ( Convert . ToDouble ( config . webMoney4 ) . ToString ( "f2" ) ) )
{
duLevel4 = 2 ;
}
}
if ( duLevel4 < 3 )
{
if ( minzcount > = Convert . ToDouble ( Convert . ToDouble ( config . webMoney5 ) . ToString ( "f2" ) ) )
{
duLevel4 = 3 ;
}
}
if ( YuLevel4 ! = duLevel4 )
{
if ( YuLevel4 > duLevel4 )
{
if ( YuLevel11 = = 0 )
{
Mtxfw . Model . user_Results_jl4 Modeljl4 = new Mtxfw . Model . user_Results_jl4 ( ) ;
Modeljl4 . MemberId = dID ;
Modeljl4 . MemberId0 = 0 ;
Modeljl4 . MemberId1 = YuLevel4 ;
Modeljl4 . MemberId2 = duLevel4 ;
Modeljl4 . IFMFSJ = tjcount ;
Modeljl4 . IFUpdateMoney = ccount ;
Modeljl4 . UpdateMoney = Yumoney19 ;
Modeljl4 . UpdateMoney2 = 0 ;
Modeljl4 . utype = "6" ;
Modeljl4 . addtime = dt ;
Modeljl4 . gtype = 0 ;
new DAL . user_Results_jl4 ( ) . Add ( Modeljl4 ) ;
daoUser . UpdateuLevel ( "uLevel4" , duLevel4 , dID ) ;
}
}
else
{
Mtxfw . Model . user_Results_jl4 Modeljl4 = new Mtxfw . Model . user_Results_jl4 ( ) ;
Modeljl4 . MemberId = dID ;
Modeljl4 . MemberId0 = 0 ;
Modeljl4 . MemberId1 = YuLevel4 ;
Modeljl4 . MemberId2 = duLevel4 ;
Modeljl4 . IFMFSJ = tjcount ;
Modeljl4 . IFUpdateMoney = ccount ;
Modeljl4 . UpdateMoney = Yumoney19 ;
Modeljl4 . UpdateMoney2 = 0 ;
Modeljl4 . utype = "6" ;
Modeljl4 . addtime = dt ;
Modeljl4 . gtype = 0 ;
new DAL . user_Results_jl4 ( ) . Add ( Modeljl4 ) ;
daoUser . UpdateuLevel ( "uLevel4" , duLevel4 , dID ) ;
}
}
}
}
public static void UpdteuLevel0 ( int gtype , Mtxfw . Utility . Config config , int dID , string YContactIDS , int YuLevel , int uLevel24 , int YIFBecomeAgents , Double Yumoney33 , DateTime dt )
{
}
#endregion
#region 分 红 结 算
//分红结算
public static void FHJS ( int jjfpid , DateTime dt , Mtxfw . Utility . Config config , int gtype , Double FHMoney , Double FHMoney0 )
{
try
{
Double ZFHMoney = 0.00 ;
DataSet dss = daoUser . GetList1 ( "id,umoney47,umoney48,umoney49,uLevel43" , "gtype=" + gtype + " and UserState='正常' And IFStores=0 and uLevel46=0 And umoney48>0" ) ;
if ( dss . Tables [ 0 ] . Rows . Count > 0 )
{
foreach ( System . Data . DataRow Drr in dss . Tables [ 0 ] . Rows )
{
int dID = Convert . ToInt32 ( Drr [ "id" ] . ToString ( ) ) ;
Double Yumoney47 = Convert . ToDouble ( Convert . ToDouble ( Drr [ "umoney47" ] . ToString ( ) ) . ToString ( "f4" ) ) ;
Double Yumoney48 = Convert . ToDouble ( Convert . ToDouble ( Drr [ "umoney48" ] . ToString ( ) ) . ToString ( "f4" ) ) ;
Double Yumoney49 = Convert . ToDouble ( Convert . ToDouble ( Drr [ "umoney49" ] . ToString ( ) ) . ToString ( "f4" ) ) ;
int duLevel43 = Convert . ToInt32 ( Drr [ "uLevel43" ] . ToString ( ) ) ;
Double umoney1 = Convert . ToDouble ( ( Yumoney48 * FHMoney ) . ToString ( "f4" ) ) ;
if ( umoney1 > 0.0000 )
{
if ( Yumoney47 < umoney1 )
{
umoney1 = Yumoney47 ;
}
}
if ( umoney1 > 0.0000 )
{
Model . user_Results_jl2 mjl2 ;
mjl2 = new Model . user_Results_jl2 ( ) ;
mjl2 . MemberId = dID ;
mjl2 . MemberId2 = 0 ;
mjl2 . Addmoney = - umoney1 ;
mjl2 . Cutmoney = 0 ;
mjl2 . Totalmoney = ( Yumoney47 - umoney1 ) ;
mjl2 . addtime = dt ;
mjl2 . BZContent = "分红释放" ;
mjl2 . PayID = "" ;
mjl2 . OrdersIDs = "" ;
mjl2 . OrdersID = 0 ;
mjl2 . utype = 26 ;
mjl2 . utype2 = 0 ;
mjl2 . Seef = 0 ;
mjl2 . seeftime = dt ;
mjl2 . gtype = gtype ;
daojl2 . Add ( mjl2 ) ;
daoUser . UpdateMoney ( "umoney47" , - umoney1 , dID ) ;
daoUser . UpdateMoney ( "umoney49" , umoney1 , dID ) ;
Yumoney47 = Convert . ToDouble ( ( Yumoney47 - umoney1 ) . ToString ( "f4" ) ) ;
Yumoney49 = Convert . ToDouble ( ( Yumoney49 + umoney1 ) . ToString ( "f4" ) ) ;
Double zxfmoney = Convert . ToDouble ( Convert . ToDouble ( config . webMoney41 ) . ToString ( "f4" ) ) ;
Double qyzmoney = 0.0000 ;
if ( Convert . ToDouble ( Yumoney49 . ToString ( "f4" ) ) > = zxfmoney )
{
int icount = Convert . ToInt32 ( ( Convert . ToDouble ( Yumoney49 . ToString ( "f4" ) ) / zxfmoney ) . ToString ( "0.##" ) . Split ( '.' ) [ 0 ] ) ;
if ( icount > 0 )
{
int ycount = ( icount - duLevel43 ) ;
if ( ycount > 0 )
{
daoUser . UpdateuLevel0 ( "uLevel43" , ycount , dID ) ;
qyzmoney = Convert . ToDouble ( ( Convert . ToDouble ( config . webMoney42 ) * ycount ) . ToString ( "f4" ) ) ;
if ( Yumoney48 < qyzmoney )
{
qyzmoney = Yumoney48 ;
}
if ( qyzmoney > 0.0000 )
{
mjl2 = new Model . user_Results_jl2 ( ) ;
mjl2 . MemberId = dID ;
mjl2 . MemberId2 = 0 ;
mjl2 . Addmoney = - qyzmoney ;
mjl2 . Cutmoney = 0 ;
mjl2 . Totalmoney = ( Yumoney48 - qyzmoney ) ;
mjl2 . addtime = dt ;
mjl2 . BZContent = "订单释放达到" + ( Convert . ToDouble ( config . webMoney41 ) * ycount ) . ToString ( "0.##" ) + "消耗" + qyzmoney + "个" ;
mjl2 . PayID = "" ;
mjl2 . OrdersIDs = "" ;
mjl2 . OrdersID = 0 ;
mjl2 . utype = 27 ;
mjl2 . utype2 = 1 ;
mjl2 . Seef = 0 ;
mjl2 . seeftime = dt ;
mjl2 . gtype = gtype ;
daojl2 . Add ( mjl2 ) ;
daoUser . UpdateMoney ( "umoney48" , - qyzmoney , dID ) ;
Yumoney48 = Convert . ToDouble ( ( Yumoney48 - qyzmoney ) . ToString ( "f4" ) ) ;
}
}
}
}
DataSet jlds = daojl2 . GetList1 ( "id,OrdersID,addmoney,Cutmoney" , "gtype=" + gtype + " and utype=26 and IFDelete=0 and Addmoney>0 and seef=0 and MemberId=" + dID + " order by addtime asc" ) ;
if ( jlds . Tables [ 0 ] . Rows . Count > 0 )
{
Double jdmoney = umoney1 ;
foreach ( System . Data . DataRow Dr0 in jlds . Tables [ 0 ] . Rows )
{
Int64 rid = Convert . ToInt64 ( Dr0 [ "id" ] . ToString ( ) ) ;
Int32 OrdersID = Convert . ToInt32 ( Dr0 [ "OrdersID" ] . ToString ( ) ) ;
Double addmoney = Convert . ToDouble ( Convert . ToDouble ( Dr0 [ "addmoney" ] . ToString ( ) ) . ToString ( "f4" ) ) ;
Double Cutmoney = Convert . ToDouble ( Convert . ToDouble ( Dr0 [ "Cutmoney" ] . ToString ( ) ) . ToString ( "f4" ) ) ;
if ( jdmoney > 0.0000 )
{
Double jdmoney0 = 0.00 ;
if ( addmoney > Cutmoney )
{
Double cemoney = Convert . ToDouble ( ( Cutmoney + jdmoney ) . ToString ( "f4" ) ) ;
if ( cemoney > = addmoney )
{
jdmoney0 = Convert . ToDouble ( ( addmoney - Cutmoney ) . ToString ( "f4" ) ) ;
jdmoney = Convert . ToDouble ( ( jdmoney - jdmoney0 ) . ToString ( "f4" ) ) ;
daojl2 . UpdateSeef ( 1 , rid ) ;
daojl2 . Updatemoney ( "Cutmoney" , jdmoney0 , rid ) ;
}
else
{
jdmoney0 = jdmoney ;
jdmoney = Convert . ToDouble ( ( jdmoney - jdmoney0 ) . ToString ( "f4" ) ) ;
daojl2 . Updatemoney ( "Cutmoney" , jdmoney0 , rid ) ;
}
}
else
{
daojl2 . UpdateSeef ( 1 , rid ) ;
}
}
else
{
break ;
}
}
}
jlds . Clear ( ) ;
ZFHMoney + = umoney1 ;
daoUser . UpdateMoney ( "umoney1" , umoney1 , dID ) ;
Statistics ( dt , dID , 0 , 0 , 1 , 3 , 1 , "来源补贴" , gtype ) ;
}
}
}
dss . Clear ( ) ;
dss = daoUser . GetList1 ( "id,umoney47,umoney48,umoney49,uLevel43" , "gtype=" + gtype + " and UserState='正常' And IFStores=0 and uLevel46=1 And umoney48>0" ) ;
if ( dss . Tables [ 0 ] . Rows . Count > 0 )
{
foreach ( System . Data . DataRow Drr in dss . Tables [ 0 ] . Rows )
{
int dID = Convert . ToInt32 ( Drr [ "id" ] . ToString ( ) ) ;
Double Yumoney47 = Convert . ToDouble ( Convert . ToDouble ( Drr [ "umoney47" ] . ToString ( ) ) . ToString ( "f4" ) ) ;
Double Yumoney48 = Convert . ToDouble ( Convert . ToDouble ( Drr [ "umoney48" ] . ToString ( ) ) . ToString ( "f4" ) ) ;
Double Yumoney49 = Convert . ToDouble ( Convert . ToDouble ( Drr [ "umoney49" ] . ToString ( ) ) . ToString ( "f4" ) ) ;
int duLevel43 = Convert . ToInt32 ( Drr [ "uLevel43" ] . ToString ( ) ) ;
Double umoney1 = Convert . ToDouble ( ( Yumoney48 * FHMoney0 ) . ToString ( "f4" ) ) ;
if ( umoney1 > 0.0000 )
{
if ( Yumoney47 < umoney1 )
{
umoney1 = Yumoney47 ;
}
}
if ( umoney1 > 0.0000 )
{
Model . user_Results_jl2 mjl2 ;
mjl2 = new Model . user_Results_jl2 ( ) ;
mjl2 . MemberId = dID ;
mjl2 . MemberId2 = 0 ;
mjl2 . Addmoney = - umoney1 ;
mjl2 . Cutmoney = 0 ;
mjl2 . Totalmoney = ( Yumoney47 - umoney1 ) ;
mjl2 . addtime = dt ;
mjl2 . BZContent = "分红释放" ;
mjl2 . PayID = "" ;
mjl2 . OrdersIDs = "" ;
mjl2 . OrdersID = 0 ;
mjl2 . utype = 26 ;
mjl2 . utype2 = 0 ;
mjl2 . Seef = 0 ;
mjl2 . seeftime = dt ;
mjl2 . gtype = gtype ;
daojl2 . Add ( mjl2 ) ;
daoUser . UpdateMoney ( "umoney47" , - umoney1 , dID ) ;
daoUser . UpdateMoney ( "umoney49" , umoney1 , dID ) ;
Yumoney47 = Convert . ToDouble ( ( Yumoney47 - umoney1 ) . ToString ( "f4" ) ) ;
Yumoney49 = Convert . ToDouble ( ( Yumoney49 + umoney1 ) . ToString ( "f4" ) ) ;
Double zxfmoney = Convert . ToDouble ( Convert . ToDouble ( config . webMoney41 ) . ToString ( "f4" ) ) ;
Double qyzmoney = 0.0000 ;
if ( Convert . ToDouble ( Yumoney49 . ToString ( "f4" ) ) > = zxfmoney )
{
int icount = Convert . ToInt32 ( ( Convert . ToDouble ( Yumoney49 . ToString ( "f4" ) ) / zxfmoney ) . ToString ( "0.##" ) . Split ( '.' ) [ 0 ] ) ;
if ( icount > 0 )
{
int ycount = ( icount - duLevel43 ) ;
if ( ycount > 0 )
{
daoUser . UpdateuLevel0 ( "uLevel43" , ycount , dID ) ;
qyzmoney = Convert . ToDouble ( ( Convert . ToDouble ( config . webMoney42 ) * ycount ) . ToString ( "f4" ) ) ;
if ( Yumoney48 < qyzmoney )
{
qyzmoney = Yumoney48 ;
}
if ( qyzmoney > 0.0000 )
{
mjl2 = new Model . user_Results_jl2 ( ) ;
mjl2 . MemberId = dID ;
mjl2 . MemberId2 = 0 ;
mjl2 . Addmoney = - qyzmoney ;
mjl2 . Cutmoney = 0 ;
mjl2 . Totalmoney = ( Yumoney48 - qyzmoney ) ;
mjl2 . addtime = dt ;
mjl2 . BZContent = "订单释放达到" + ( Convert . ToDouble ( config . webMoney41 ) * ycount ) . ToString ( "0.##" ) + "消耗" + qyzmoney + "个" ;
mjl2 . PayID = "" ;
mjl2 . OrdersIDs = "" ;
mjl2 . OrdersID = 0 ;
mjl2 . utype = 27 ;
mjl2 . utype2 = 1 ;
mjl2 . Seef = 0 ;
mjl2 . seeftime = dt ;
mjl2 . gtype = gtype ;
daojl2 . Add ( mjl2 ) ;
daoUser . UpdateMoney ( "umoney48" , - qyzmoney , dID ) ;
Yumoney48 = Convert . ToDouble ( ( Yumoney48 - qyzmoney ) . ToString ( "f4" ) ) ;
}
}
}
}
DataSet jlds = daojl2 . GetList1 ( "id,OrdersID,addmoney,Cutmoney" , "gtype=" + gtype + " and utype=26 and IFDelete=0 and Addmoney>0 and seef=0 and MemberId=" + dID + " order by addtime asc" ) ;
if ( jlds . Tables [ 0 ] . Rows . Count > 0 )
{
Double jdmoney = umoney1 ;
foreach ( System . Data . DataRow Dr0 in jlds . Tables [ 0 ] . Rows )
{
Int64 rid = Convert . ToInt64 ( Dr0 [ "id" ] . ToString ( ) ) ;
Int32 OrdersID = Convert . ToInt32 ( Dr0 [ "OrdersID" ] . ToString ( ) ) ;
Double addmoney = Convert . ToDouble ( Convert . ToDouble ( Dr0 [ "addmoney" ] . ToString ( ) ) . ToString ( "f4" ) ) ;
Double Cutmoney = Convert . ToDouble ( Convert . ToDouble ( Dr0 [ "Cutmoney" ] . ToString ( ) ) . ToString ( "f4" ) ) ;
if ( jdmoney > 0.0000 )
{
Double jdmoney0 = 0.00 ;
if ( addmoney > Cutmoney )
{
Double cemoney = Convert . ToDouble ( ( Cutmoney + jdmoney ) . ToString ( "f4" ) ) ;
if ( cemoney > = addmoney )
{
jdmoney0 = Convert . ToDouble ( ( addmoney - Cutmoney ) . ToString ( "f4" ) ) ;
jdmoney = Convert . ToDouble ( ( jdmoney - jdmoney0 ) . ToString ( "f4" ) ) ;
daojl2 . UpdateSeef ( 1 , rid ) ;
daojl2 . Updatemoney ( "Cutmoney" , jdmoney0 , rid ) ;
}
else
{
jdmoney0 = jdmoney ;
jdmoney = Convert . ToDouble ( ( jdmoney - jdmoney0 ) . ToString ( "f4" ) ) ;
daojl2 . Updatemoney ( "Cutmoney" , jdmoney0 , rid ) ;
}
}
else
{
daojl2 . UpdateSeef ( 1 , rid ) ;
}
}
else
{
break ;
}
}
}
jlds . Clear ( ) ;
ZFHMoney + = umoney1 ;
daoUser . UpdateMoney ( "umoney1" , umoney1 , dID ) ;
Statistics ( dt , dID , 0 , 0 , 1 , 3 , 1 , "来源补贴" , gtype ) ;
}
}
}
dss . Clear ( ) ;
daojjfp . Updatecount ( "count1" , - ZFHMoney , gtype , 0 ) ;
daojjfp . Updatecount ( ZFHMoney , 0 , 0 , 0 , 0 , 0 , jjfpid ) ;
}
catch ( Exception ex )
{
Model . User_Errlog mo = new Model . User_Errlog ( ) ;
mo . DLID = 0 ;
mo . ErrType = "分红结算" ;
mo . addtime = dt ;
mo . ErrBody = ex . ToString ( ) ;
mo . ErrBody2 = ex . Message ;
new DAL . User_Errlog ( ) . Add ( mo ) ;
}
}
#endregion
#region 奖 金 结 算
//奖金结算
public static void JJJS ( Mtxfw . Utility . Config config , Model . user_info umodel , DateTime dt , int gtype , bool IFHYZ )
{
}
#endregion
/// <summary>
2026-03-20 02:20:12 +08:00
/// 奖金结算(批发差价)
2026-03-16 02:47:48 +08:00
/// </summary>
/// <param name="config">配置文件</param>
/// <param name="umodel">支付客户数据</param>
/// <param name="ContactRow">一条支付链条用户数据</param>
/// <param name="YContactID">支付客户直接上级</param>
/// <param name="YContactIDS">支付链条</param>
2026-03-20 02:20:12 +08:00
/// <param name="pv">付款金额</param>
/// <param name="xfz">消费值</param>
2026-03-16 02:47:48 +08:00
/// <param name="yfbl">已分奖金比例</param>
2026-03-20 02:20:12 +08:00
/// <param name="ttype">0热卖推荐, 1会员商城</param>
public static Double JiangJinJS ( Mtxfw . Utility . Config config , Model . user_info umodel , DataRow ContactRow , int YContactID , string YContactIDS , Double pv , Double xfz , double yfbl , int ttype )
2026-03-16 02:47:48 +08:00
{
Model . User_Errlog mo ;
DateTime dt = DateTime . Now ;
double result = yfbl ;
try
{
2026-03-23 18:11:54 +08:00
2026-03-16 02:47:48 +08:00
int dID = Convert . ToInt32 ( ContactRow [ "ID" ] . ToString ( ) ) ;
//Yumoney17就是余额, 而且写成负数
Double Yumoney17 = Convert . ToDouble ( Convert . ToDouble ( ContactRow [ "umoney17" ] ) . ToString ( "f4" ) ) ;
int ContactLevel = Convert . ToInt32 ( ContactRow [ "uLevel" ] . ToString ( ) ) ;
int buyerlevel = umodel . uLevel ;
var buyerlevelname = Mtxfw . Utility . Common . GetuLevelname ( buyerlevel ) ;
var Contactlevelname = Mtxfw . Utility . Common . GetuLevelname ( ContactLevel ) ; ;
2026-03-20 02:20:12 +08:00
var BZContent = "" ; //备注
if ( ttype = = 0 )
{
2026-03-20 10:14:07 +08:00
BZContent = "热卖商品批发差价" ;
2026-03-20 02:20:12 +08:00
}
else
{
2026-03-20 10:14:07 +08:00
BZContent = "商城商品批发差价" ;
2026-03-20 02:20:12 +08:00
}
2026-03-16 02:47:48 +08:00
//当前奖金比例
Double fixed_bonus = 0 ;
//当前级别对应的最大奖金比例 - 下级已分比例 等于当前等级剩余可分奖金比例
2026-03-20 02:20:12 +08:00
//热卖商品分配方案
if ( ttype = = 0 )
2026-03-16 02:47:48 +08:00
{
2026-03-20 10:14:07 +08:00
2026-03-20 02:20:12 +08:00
switch ( ContactLevel )
{
case 1 :
fixed_bonus = config . level1_fixed_bonus - yfbl ;
break ;
case 2 :
fixed_bonus = config . level2_fixed_bonus - yfbl ;
break ;
case 3 :
fixed_bonus = config . level3_fixed_bonus - yfbl ;
break ;
case 4 :
fixed_bonus = config . level4_fixed_bonus - yfbl ;
break ;
}
}
//商城商品分配方案
else
{
switch ( ContactLevel )
{
case 1 :
fixed_bonus = config . level1_fixed_bonus - yfbl ;
break ;
case 2 :
fixed_bonus = config . level2_fixed_bonus - yfbl ;
break ;
case 3 :
fixed_bonus = config . level3_fixed_bonus - yfbl ;
break ;
case 4 :
fixed_bonus = config . level4_fixed_bonus - yfbl ;
break ;
}
2026-03-16 02:47:48 +08:00
}
if ( fixed_bonus > 0 )
{
if ( pv > 0 )
{
Double jaingjin = Convert . ToDouble ( ( fixed_bonus * pv ) . ToString ( "f4" ) ) ;
if ( jaingjin > 0.0000 )
{
var mjl2 = new Model . user_Results_jl2 ( ) ;
mjl2 . MemberId = dID ;
mjl2 . MemberId2 = 0 ;
mjl2 . Addmoney = jaingjin ;
mjl2 . Cutmoney = 0 ;
mjl2 . Totalmoney = - ( Yumoney17 - jaingjin ) ;
mjl2 . addtime = dt ;
2026-03-20 02:20:12 +08:00
mjl2 . BZContent = BZContent ;
2026-03-16 02:47:48 +08:00
mjl2 . PayID = "" ;
mjl2 . OrdersIDs = "" ;
mjl2 . OrdersID = 0 ;
mjl2 . utype = 1 ;
mjl2 . utype2 = 0 ;
mjl2 . Seef = 0 ;
mjl2 . seeftime = dt ;
mjl2 . gtype = 0 ;
daojl2 . Add ( mjl2 ) ;
}
var flag = daoUser . UpdateMoney ( "umoney17" , - jaingjin , dID ) ;
if ( flag > 0 )
{
//增加已分比例
return result + = fixed_bonus ;
}
}
}
}
catch ( Exception ex )
{
mo = new Model . User_Errlog ( ) ;
mo . DLID = 0 ;
mo . ErrType = "奖金结算,JiangJinJS" ;
mo . addtime = dt ;
mo . ErrBody = ex . ToString ( ) ;
mo . ErrBody2 = ex . Message ;
new DAL . User_Errlog ( ) . Add ( mo ) ;
}
return result ;
}
2026-03-20 02:20:12 +08:00
/// <summary>
/// 佣金结算
/// </summary>
/// <param name="config">配置文件</param>
/// <param name="umodel">支付客户数据</param>
/// <param name="ContactRow">一条支付链条用户数据</param>
/// <param name="YContactID">支付客户直接上级</param>
/// <param name="YContactIDS">支付链条</param>
/// <param name="pv">付款金额</param>
/// <param name="xfz">消费值</param>
/// <param name="yfbl">已分奖金比例</param>
/// <param name="ttype">0热卖推荐, 1会员商城</param>
public static Double YongJinJS ( Mtxfw . Utility . Config config , Model . user_info umodel , DataRow ContactRow , int YContactID , string YContactIDS , Double pv , Double xfz , double yfbl , int ttype )
{
Model . User_Errlog mo ;
DateTime dt = DateTime . Now ;
double result = yfbl ;
try
{
2026-03-23 18:11:54 +08:00
var uplevel2_amount = config . direct_upgrade_level2_amount_condition ;
///热卖商品只有到达升级到2级金额的才能拿佣金
if ( pv < uplevel2_amount )
{
result = 0 ;
}
2026-03-20 02:20:12 +08:00
int dID = Convert . ToInt32 ( ContactRow [ "ID" ] . ToString ( ) ) ;
//Yumoney17就是余额, 而且写成负数
Double Yumoney17 = Convert . ToDouble ( Convert . ToDouble ( ContactRow [ "umoney17" ] ) . ToString ( "f4" ) ) ;
int ContactLevel = Convert . ToInt32 ( ContactRow [ "uLevel" ] . ToString ( ) ) ;
int buyerlevel = umodel . uLevel ;
var buyerlevelname = Mtxfw . Utility . Common . GetuLevelname ( buyerlevel ) ;
var Contactlevelname = Mtxfw . Utility . Common . GetuLevelname ( ContactLevel ) ; ;
var BZContent = "业务佣金" ; //备注
2026-03-20 10:14:07 +08:00
Double fixed_bonus = 0 ; //config.level3_fixed_bonus
2026-03-20 02:20:12 +08:00
if ( fixed_bonus > 0 )
{
if ( pv > 0 )
{
Double jaingjin = Convert . ToDouble ( ( fixed_bonus * pv ) . ToString ( "f4" ) ) ;
if ( jaingjin > 0.0000 )
{
var mjl2 = new Model . user_Results_jl2 ( ) ;
mjl2 . MemberId = dID ;
mjl2 . MemberId2 = 0 ;
mjl2 . Addmoney = jaingjin ;
mjl2 . Cutmoney = 0 ;
mjl2 . Totalmoney = - ( Yumoney17 - jaingjin ) ;
mjl2 . addtime = dt ;
mjl2 . BZContent = BZContent ;
mjl2 . PayID = "" ;
mjl2 . OrdersIDs = "" ;
mjl2 . OrdersID = 0 ;
mjl2 . utype = 1 ;
mjl2 . utype2 = 0 ;
mjl2 . Seef = 0 ;
mjl2 . seeftime = dt ;
mjl2 . gtype = 0 ;
daojl2 . Add ( mjl2 ) ;
}
var flag = daoUser . UpdateMoney ( "umoney17" , - jaingjin , dID ) ;
if ( flag > 0 )
{
//增加已分比例
return result + = fixed_bonus ;
}
}
}
}
catch ( Exception ex )
{
mo = new Model . User_Errlog ( ) ;
mo . DLID = 0 ;
mo . ErrType = "奖金结算,JiangJinJS" ;
mo . addtime = dt ;
mo . ErrBody = ex . ToString ( ) ;
mo . ErrBody2 = ex . Message ;
new DAL . User_Errlog ( ) . Add ( mo ) ;
}
return result ;
}
2026-03-16 02:47:48 +08:00
#region 更 新 奖 金
public static void UpdteJJ ( Mtxfw . Utility . Config config , int YID , Int64 ResultId , string ContactIDS , string UserName , Double umoney26 , Double pv , ref Double FHMoney0 , int gtype , DateTime dt , int ifxy )
{
Model . User_Errlog mo ;
try
{
string [ ] ASuperiorsIDS = ( ContactIDS ) . Split ( ',' ) ;
if ( ifxy = = 1 )
{
UserName = "小于" + UserName ;
}
Double bfb = 0.00 ;
int uds = 1 ;
for ( int ak = ASuperiorsIDS . Length - 2 ; ak > 0 ; ak - - )
{
if ( ASuperiorsIDS [ ak ] ! = "" )
{
DataSet ds = daoUser . GetList1 ( "ID,uLevel,ContactIDS,RealName,umoney26" , "gtype=" + gtype + " and UserState='正常' And IFStores=0 And uLevel17=0 And id=" + ASuperiorsIDS [ ak ] ) ;
if ( ds . Tables [ 0 ] . Rows . Count > 0 )
{
int dID = Convert . ToInt32 ( ds . Tables [ 0 ] . Rows [ 0 ] [ "ID" ] . ToString ( ) ) ;
int YuLevel = Convert . ToInt32 ( ds . Tables [ 0 ] . Rows [ 0 ] [ "uLevel" ] . ToString ( ) ) ;
string YContactIDS = ds . Tables [ 0 ] . Rows [ 0 ] [ "ContactIDS" ] . ToString ( ) ;
string YRealName = ds . Tables [ 0 ] . Rows [ 0 ] [ "RealName" ] . ToString ( ) ;
Double Yumoney26 = Convert . ToDouble ( Convert . ToDouble ( ds . Tables [ 0 ] . Rows [ 0 ] [ "umoney26" ] ) . ToString ( "f4" ) ) ;
if ( uds = = 1 )
{
int djid = dID ;
bfb = ( Convert . ToDouble ( config . webMoney2 ) ) ;
Double umoney2 = Convert . ToDouble ( Convert . ToDouble ( ( ( bfb / 100 ) * pv ) . ToString ( "0.####" ) ) . ToString ( "f4" ) ) ;
if ( umoney2 > 0.0000 )
{
Double syzmoney = 0.0000 ;
string strmoney = daoorder . Getzd ( "(sum(Totalprice0)-sum(Totalprice10))" , "ttype=1 and IFDelete=0 and O_Payed=1 and O_Shipped=0 and Totalprice0>Totalprice10 and UserId=" + djid ) . ToString ( ) ;
if ( strmoney ! = "" )
{
syzmoney = Convert . ToDouble ( Convert . ToDouble ( Convert . ToDouble ( strmoney ) . ToString ( "0.####" ) ) . ToString ( "f4" ) ) ;
}
if ( syzmoney < umoney2 )
{
umoney2 = syzmoney ;
}
}
if ( umoney2 > 0.0000 )
{
FHMoney0 + = umoney2 ;
daoUser . UpdateMoney ( "umoney2" , umoney2 , djid ) ;
Statistics ( dt , djid , YID , ResultId , 0 , 0 , 1 , "来源" + UserName + "每日产出" + pv . ToString ( ) + "的" + bfb . ToString ( ) + "%" , gtype ) ;
}
}
uds + = 1 ;
}
}
}
}
catch ( Exception ex )
{
mo = new Model . User_Errlog ( ) ;
mo . DLID = 0 ;
mo . ErrType = "更新奖金" ;
mo . addtime = dt ;
mo . ErrBody = ex . ToString ( ) ;
mo . ErrBody2 = ex . Message ;
new DAL . User_Errlog ( ) . Add ( mo ) ;
}
}
#endregion
#region 奖 金 统 计
//hasRead 0任务包奖励 1商城奖励 2增值积分奖励 Sended=0事业部奖励 Sended=1商家联盟奖励 Sended=2推广员奖励 Sended=3爆品区奖励 Sended=4补贴专区奖励 Sended=5体验区奖励
public static void Statistics ( DateTime UpdateTime , int dID , int YID , Int64 ResultId , int hasRead , int Sended , int Seef , string strconent , int gtype )
{
DataSet ds = null ;
try
{
ds = daoUser . GetList1 ( "id,uLevel,uLevel7,uLevel8,uLevel11,gtype,regtime,phone,email,umoney,umoney0,umoney1,umoney2,umoney3,umoney4,umoney5,umoney6,umoney7,umoney8,umoney9,umoney10,umoney11,umoney12,umoney15,umoney16,umoney17,umoney18,umoney20,umoney22,umoney23,umoney24,umoney27,umoney28,umoney29,umoney32,umoney37" , "gtype=" + gtype + " and UserState='正常' And (IFStores=0 or IFStores=2) And id=" + dID ) ; // And (umoney0+umoney2+umoney3+umoney4+umoney5+umoney7+umoney8+umoney9+umoney10+umoney11+umoney12)>0
if ( ds . Tables [ 0 ] . Rows . Count > 0 )
{
foreach ( System . Data . DataRow Dr in ds . Tables [ 0 ] . Rows )
{
int UID = int . Parse ( Dr [ "id" ] . ToString ( ) ) ;
int uLevel = int . Parse ( Dr [ "uLevel" ] . ToString ( ) ) ;
int uLevel11 = int . Parse ( Dr [ "uLevel11" ] . ToString ( ) ) ;
int uLevel7 = int . Parse ( Dr [ "uLevel7" ] . ToString ( ) ) ;
int uLevel8 = int . Parse ( Dr [ "uLevel8" ] . ToString ( ) ) ;
string strPhone = Dr [ "phone" ] . ToString ( ) ;
string strEmail = Dr [ "email" ] . ToString ( ) ;
DateTime regtime = DateTime . Parse ( Dr [ "regtime" ] . ToString ( ) ) ;
Double umoney = Convert . ToDouble ( Dr [ "umoney" ] . ToString ( ) ) - Convert . ToDouble ( Dr [ "umoney17" ] . ToString ( ) ) ;
Double umoney00 = Convert . ToDouble ( Convert . ToDouble ( Dr [ "umoney" ] . ToString ( ) ) . ToString ( "f4" ) ) ;
Double umoney0 = Convert . ToDouble ( Convert . ToDouble ( Dr [ "umoney0" ] . ToString ( ) ) . ToString ( "f4" ) ) ;
Double umoney1 = Convert . ToDouble ( Convert . ToDouble ( Dr [ "umoney1" ] . ToString ( ) ) . ToString ( "f4" ) ) ;
Double umoney2 = Convert . ToDouble ( Convert . ToDouble ( Dr [ "umoney2" ] . ToString ( ) ) . ToString ( "f4" ) ) ;
Double umoney3 = Convert . ToDouble ( Convert . ToDouble ( Dr [ "umoney3" ] . ToString ( ) ) . ToString ( "f4" ) ) ;
Double umoney4 = Convert . ToDouble ( Convert . ToDouble ( Dr [ "umoney4" ] . ToString ( ) ) . ToString ( "f4" ) ) ;
Double umoney5 = Convert . ToDouble ( Convert . ToDouble ( Dr [ "umoney5" ] . ToString ( ) ) . ToString ( "f4" ) ) ;
Double umoney6 = Convert . ToDouble ( Convert . ToDouble ( Dr [ "umoney6" ] . ToString ( ) ) . ToString ( "f4" ) ) ;
Double umoney7 = Convert . ToDouble ( Convert . ToDouble ( Dr [ "umoney7" ] . ToString ( ) ) . ToString ( "f4" ) ) ;
Double umoney8 = Convert . ToDouble ( Convert . ToDouble ( Dr [ "umoney8" ] . ToString ( ) ) . ToString ( "f4" ) ) ;
Double umoney9 = Convert . ToDouble ( Convert . ToDouble ( Dr [ "umoney9" ] . ToString ( ) ) . ToString ( "f4" ) ) ;
Double umoney10 = Convert . ToDouble ( Dr [ "umoney10" ] . ToString ( ) ) ;
Double umoney11 = Convert . ToDouble ( Dr [ "umoney11" ] . ToString ( ) ) ;
Double Yumoney15 = Convert . ToDouble ( Dr [ "umoney15" ] . ToString ( ) ) ;
Double umoney16 = Convert . ToDouble ( Dr [ "umoney16" ] . ToString ( ) ) ;
Double umoney18 = 0.00 ;
Double umoney20 = Convert . ToDouble ( Convert . ToDouble ( Dr [ "umoney20" ] . ToString ( ) ) . ToString ( "f4" ) ) ;
Double umoney22 = Convert . ToDouble ( Convert . ToDouble ( Dr [ "umoney22" ] . ToString ( ) ) . ToString ( "f4" ) ) ;
Double umoney23 = Convert . ToDouble ( Convert . ToDouble ( Dr [ "umoney23" ] . ToString ( ) ) . ToString ( "f4" ) ) ;
Double umoney24 = Convert . ToDouble ( Convert . ToDouble ( Dr [ "umoney24" ] . ToString ( ) ) . ToString ( "f4" ) ) ;
Double umoney27 = Convert . ToDouble ( Convert . ToDouble ( Dr [ "umoney27" ] ) . ToString ( "f4" ) ) ;
Double umoney28 = Convert . ToDouble ( Convert . ToDouble ( Dr [ "umoney28" ] ) . ToString ( "f4" ) ) ;
Double umoney29 = Convert . ToDouble ( Convert . ToDouble ( Dr [ "umoney29" ] ) . ToString ( "f4" ) ) ;
Double umoney32 = Convert . ToDouble ( Convert . ToDouble ( Dr [ "umoney32" ] ) . ToString ( "f4" ) ) ;
Double umoney37 = Convert . ToDouble ( Convert . ToDouble ( Dr [ "umoney37" ] ) . ToString ( "f4" ) ) ;
umoney0 = umoney1 + umoney2 + umoney3 + umoney4 + umoney5 + umoney6 + umoney7 + umoney8 + umoney9 + umoney10 + umoney11 ;
umoney0 = Convert . ToDouble ( umoney0 . ToString ( "f4" ) ) ;
if ( umoney0 > 0.0000 )
{
Double umoney12 = 0.00 ;
Double umoney13 = 0.00 ;
Double umoney14 = 0.00 ;
Double umoney15 = 0.00 ;
Double Totalmoney = Convert . ToDouble ( ( umoney0 - umoney12 - umoney13 - umoney14 - umoney15 ) . ToString ( "f4" ) ) ;
Mtxfw . Model . user_Results ModelResults = new Mtxfw . Model . user_Results ( ) ;
ModelResults . b0 = umoney0 ;
ModelResults . b1 = umoney1 ;
ModelResults . b2 = umoney2 ;
ModelResults . b3 = umoney3 ;
ModelResults . b4 = umoney4 ;
ModelResults . b5 = umoney5 ;
ModelResults . b6 = umoney6 ;
ModelResults . b7 = umoney7 ;
ModelResults . b8 = umoney8 ;
ModelResults . b9 = umoney9 ;
ModelResults . b10 = umoney10 ;
ModelResults . b11 = umoney11 ;
ModelResults . b12 = umoney12 ;
ModelResults . b13 = umoney13 ;
ModelResults . b14 = umoney14 ;
ModelResults . b15 = umoney15 ;
ModelResults . b16 = 0 ;
ModelResults . b17 = 0 ;
ModelResults . b18 = umoney18 ;
ModelResults . conent = strconent ;
ModelResults . Totalmoney = Totalmoney ;
ModelResults . MemberId = UID ;
ModelResults . UserId = YID ;
ModelResults . ListNumber = ResultId . ToString ( ) ;
ModelResults . Managers = "" ;
ModelResults . hasRead = hasRead ;
ModelResults . Sended = Sended ;
ModelResults . Seef = Seef ;
ModelResults . utype = "0" ;
ModelResults . gtype = gtype ;
ModelResults . addtime = UpdateTime ;
Int64 ResultID = daoResults . Add ( ModelResults ) ;
Model . user_Results_jl2 mjl2 ;
if ( ( hasRead = = 0 | | hasRead = = 1 ) & & Sended < 5 )
{
if ( Totalmoney > 0.0000 )
{
if ( Seef = = 1 )
{
Double jjmoney = Totalmoney ;
int utype = 1 ;
Double yemoney = umoney ;
string selmoney = "umoney" ;
mjl2 = new Model . user_Results_jl2 ( ) ;
mjl2 . MemberId = UID ;
mjl2 . MemberId2 = YID ;
mjl2 . Addmoney = jjmoney ;
mjl2 . Cutmoney = 0 ;
mjl2 . Totalmoney = yemoney + jjmoney ;
mjl2 . addtime = UpdateTime ;
mjl2 . BZContent = ModelResults . conent ;
mjl2 . PayID = "" ;
mjl2 . OrdersIDs = "" ;
mjl2 . OrdersID = 0 ;
mjl2 . utype = utype ;
mjl2 . utype2 = 0 ;
mjl2 . Seef = Seef ;
mjl2 . seeftime = UpdateTime ;
mjl2 . gtype = gtype ;
daojl2 . Add ( mjl2 ) ;
daoUser . UpdateMoney ( selmoney , jjmoney , UID ) ;
daoUser . UpdateMoney ( "umoney23" , jjmoney , UID ) ;
daoUser . UpdateMoney ( "umoney24" , jjmoney , UID ) ;
if ( umoney12 > 0.0000 )
{
mjl2 = new Model . user_Results_jl2 ( ) ;
mjl2 . MemberId = UID ;
mjl2 . MemberId2 = YID ;
mjl2 . Addmoney = umoney12 ;
mjl2 . Cutmoney = 0 ;
mjl2 . Totalmoney = umoney22 + umoney12 ;
mjl2 . addtime = DateTime . Now ;
mjl2 . BZContent = ModelResults . conent ;
mjl2 . PayID = "" ;
mjl2 . OrdersIDs = "" ;
mjl2 . OrdersID = 0 ;
mjl2 . utype = 0 ;
mjl2 . utype2 = 0 ;
mjl2 . Seef = Seef ;
mjl2 . seeftime = DateTime . Now ;
mjl2 . gtype = gtype ;
daojl2 . Add ( mjl2 ) ;
daoUser . UpdateMoney ( "umoney22" , umoney12 , UID ) ;
}
}
}
}
}
daoUser . UpdateMoney0 ( UID ) ;
}
}
ds . Tables . Clear ( ) ;
}
catch ( Exception ex )
{
Model . User_Errlog mo = new Model . User_Errlog ( ) ;
mo . DLID = 0 ;
mo . ErrType = "奖金结算" ;
mo . addtime = UpdateTime ;
mo . ErrBody = ex . ToString ( ) ;
mo . ErrBody2 = ex . Message ;
new DAL . User_Errlog ( ) . Add ( mo ) ;
}
}
#endregion
#region 删 除 未 付 款 订 单
public static void DeleteOrder ( Mtxfw . Utility . Config config , int gtype , string apath , int type )
{
DataSet ds = null ;
DataSet ds1 = null ;
DateTime dt = DateTime . Now ;
string mindt = dt . ToString ( "yyyy-MM-dd" ) + " 00:00:00" ;
string maxdt = dt . AddDays ( 1 ) . ToString ( "yyyy-MM-dd" ) + " 00:00:00" ;
Model . User_Errlog mo ;
Model . User_CZ_log logmodel ;
Model . user_Results_jl2 mjl2 ;
try
{
if ( type = = 0 )
{
ds = daoorder . GetList1 ( "id,ptype,peitype,addressid,orderid,UserID,Totalprice2" , "gtype=" + gtype + " and ttype<>1 and IFDelete=0 And (O_Payed='0' or O_Payed='-1') And O_SubmitDate<=DateAdd(hour,-1,'" + dt + "')" ) ;
if ( ds . Tables [ 0 ] . Rows . Count > 0 )
{
foreach ( System . Data . DataRow Dr in ds . Tables [ 0 ] . Rows )
{
int id = int . Parse ( Dr [ "id" ] . ToString ( ) ) ;
int ptype = int . Parse ( Dr [ "ptype" ] . ToString ( ) ) ;
int peitype = int . Parse ( Dr [ "peitype" ] . ToString ( ) ) ;
int agentid = int . Parse ( Dr [ "addressid" ] . ToString ( ) ) ;
string orderid = Dr [ "orderid" ] . ToString ( ) ;
int UserID = int . Parse ( Dr [ "UserID" ] . ToString ( ) ) ;
Double Totalprice2 = Convert . ToDouble ( Convert . ToDouble ( Dr [ "Totalprice2" ] . ToString ( ) ) . ToString ( "f2" ) ) ;
daoorder . UpdateIFDelete ( 1 , dt . ToString ( ) , id ) ;
if ( ptype = = 0 )
{
System . Data . DataSet Ds_op = new Mtxfw . DAL . order_product_info ( ) . GetList1 ( "Totalnum,guige,selcolor" , "utype='0' And orderid=" + id + " And IFDelete=0 Order By SubmitTime asc" ) ;
if ( Ds_op . Tables [ 0 ] . Rows . Count > 0 )
{
foreach ( System . Data . DataRow drv2 in Ds_op . Tables [ 0 ] . Rows )
{
string selcolor = drv2 [ "selcolor" ] . ToString ( ) ;
int prodNum = Convert . ToInt32 ( drv2 [ "Totalnum" ] ) ;
string guige = drv2 [ "guige" ] . ToString ( ) ;
if ( guige ! = "" )
{
Mtxfw . Model . P_Guige gmodel = new DAL . P_Guige ( ) . GetModel ( Convert . ToInt32 ( guige ) ) ;
if ( gmodel ! = null )
{
int ZKC = 0 ;
bool IFKC = true ;
string strcolors = gmodel . G_Color ;
string [ ] acolors = gmodel . G_Color . Split ( ',' ) ;
for ( int jj = 0 ; jj < acolors . Length ; jj + + )
{
if ( acolors [ jj ] ! = "" )
{
var ac = acolors [ jj ] . Split ( '|' ) ;
if ( ac . Length > 1 )
{
if ( ac [ 1 ] ! = "" )
{
int intNum = Convert . ToInt32 ( ac [ 1 ] ) ;
if ( ac [ 0 ] = = selcolor )
{
intNum = ( intNum + Convert . ToInt32 ( prodNum ) ) ;
strcolors = strcolors . Replace ( ac [ 0 ] + "|" + ac [ 1 ] , ac [ 0 ] + "|" + intNum ) ;
}
ZKC + = intNum ;
IFKC = false ;
}
}
}
}
gmodel . G_Color = strcolors ;
if ( peitype = = 1 )
{
if ( gmodel . G_tihuodian ! = "" )
{
string tihuodians = "" ;
string [ ] atihuodians = gmodel . G_tihuodian . Split ( ',' ) ;
for ( int k = 0 ; k < atihuodians . Length ; k + + )
{
if ( atihuodians [ k ] ! = "" )
{
var ac = atihuodians [ k ] . Split ( '|' ) ;
if ( ac [ 0 ] = = agentid . ToString ( ) )
{
if ( tihuodians ! = "" )
{
tihuodians + = ( "," + ac [ 0 ] + "|" + ( Convert . ToInt32 ( ac [ 1 ] ) + Convert . ToInt32 ( prodNum ) ) + "|" + ac [ 2 ] ) ;
}
else
{
tihuodians + = ( ac [ 0 ] + "|" + ( Convert . ToInt32 ( ac [ 1 ] ) + Convert . ToInt32 ( prodNum ) ) + "|" + ac [ 2 ] ) ;
}
}
else
{
if ( tihuodians ! = "" )
{
tihuodians + = "," + atihuodians [ k ] ;
}
else
{
tihuodians + = atihuodians [ k ] ;
}
}
}
}
gmodel . G_tihuodian = tihuodians ;
}
}
if ( IFKC )
{
gmodel . G_KC = gmodel . G_KC + Convert . ToInt32 ( prodNum ) ;
}
else
{
gmodel . G_KC = ZKC ;
}
new DAL . P_Guige ( ) . Update ( gmodel ) ;
}
}
}
}
Ds_op . Clear ( ) ;
Mtxfw . Model . user_info umodel = new Mtxfw . DAL . user_info ( ) . GetModel ( UserID ) ;
if ( umodel ! = null )
{
Mtxfw . Model . Article amodel = new Mtxfw . Model . Article ( ) ;
amodel . senderid = 0 ;
amodel . receiverid = umodel . Id ;
amodel . Title = "订单删除通知" ;
amodel . ParentID = 30 ;
amodel . CategoryId = "0" ;
amodel . AddTime = DateTime . Now ;
amodel . Author = "../image/order-ico.png" ;
amodel . Content = "您的订单" + orderid + "1小时内未付款, 已被删除" ;
amodel . Paths = "orders.html" ;
amodel . Content2 = "" ;
amodel . Paths2 = "" ;
amodel . KeyWords = "" ;
amodel . media_id = "" ;
amodel . thumb_media_id = "" ;
amodel . wtype = 4 ;
amodel . wtype2 = 0 ;
amodel . LinkID = 1 ;
amodel . Seef = 0 ;
amodel . gtype = gtype ;
string dataid = new Article ( ) . Add ( amodel ) . ToString ( ) ;
if ( umodel . registrationId ! = "" )
{
List < string > RegistrationIDList = new List < string > ( ) ;
RegistrationIDList . Add ( umodel . registrationId ) ;
string title = amodel . Title ;
string strMsg = amodel . Content ;
bool is_production = true ;
string strLog = "" ;
new Jiguang . JPush . JPushV3 ( ) . SendPushV2 ( RegistrationIDList , title , dataid , strMsg , is_production , out strLog ) ;
}
}
}
}
}
ds . Tables . Clear ( ) ;
ds = daoorder . GetList1 ( "id,hasRead,ttype,MemberId,UserId,Totalprice4" , "gtype=" + gtype + " and IFDelete=0 and ptype=0 And O_Payed='2' And O_Payed_Date<=DateAdd(day,-7,'" + dt + "')" ) ;
if ( ds . Tables [ 0 ] . Rows . Count > 0 )
{
foreach ( System . Data . DataRow Dr in ds . Tables [ 0 ] . Rows )
{
int id = int . Parse ( Dr [ "id" ] . ToString ( ) ) ;
int hasRead = int . Parse ( Dr [ "hasRead" ] . ToString ( ) ) ;
int ttype = int . Parse ( Dr [ "ttype" ] . ToString ( ) ) ;
int UserId = int . Parse ( Dr [ "UserId" ] . ToString ( ) ) ;
int MemberId = int . Parse ( Dr [ "MemberId" ] . ToString ( ) ) ;
Double Totalprice4 = Convert . ToDouble ( Convert . ToDouble ( Dr [ "Totalprice4" ] ) . ToString ( "f2" ) ) ;
daoorder . UpdateqyState ( 0 , "3" , DateTime . Now , id ) ;
if ( ttype = = 0 | | ttype = = 2 | | ttype = = 8 )
{
if ( MemberId > 0 )
{
string RealName = daoUser . Getzd ( "RealName" , "id=" + UserId ) . ToString ( ) ;
Mtxfw . Model . user_info umodel0 = new Mtxfw . DAL . user_info ( ) . GetModel ( MemberId ) ;
if ( umodel0 ! = null )
{
Double zmoney = Totalprice4 ;
if ( Convert . ToDouble ( umodel0 . umoney40 . ToString ( "f2" ) ) < zmoney )
{
zmoney = Convert . ToDouble ( umodel0 . umoney40 . ToString ( "f2" ) ) ;
}
if ( zmoney > 0.00 )
{
mjl2 = new Model . user_Results_jl2 ( ) ;
mjl2 . MemberId = umodel0 . Id ;
mjl2 . MemberId2 = 0 ;
mjl2 . Addmoney = - zmoney ;
mjl2 . Cutmoney = 0 ;
mjl2 . Totalmoney = ( umodel0 . umoney40 - zmoney ) ;
mjl2 . addtime = dt ;
mjl2 . BZContent = RealName + "确认收货,成本" ;
mjl2 . PayID = "" ;
mjl2 . OrdersIDs = "" ;
mjl2 . OrdersID = 0 ;
mjl2 . utype = 16 ;
mjl2 . utype2 = 0 ;
mjl2 . Seef = - 1 ;
mjl2 . seeftime = dt ;
mjl2 . gtype = gtype ;
new Mtxfw . DAL . user_Results_jl2 ( ) . Add ( mjl2 ) ;
umodel0 . umoney40 - = zmoney ;
//减少买家余额
daoUser . UpdateMoney ( "umoney40" , - zmoney , umodel0 . Id ) ;
mjl2 = new Model . user_Results_jl2 ( ) ;
mjl2 . MemberId = umodel0 . Id ;
mjl2 . MemberId2 = 0 ;
mjl2 . Addmoney = zmoney ;
mjl2 . Cutmoney = 0 ;
mjl2 . Totalmoney = ( umodel0 . umoney41 + zmoney ) ;
mjl2 . addtime = dt ;
mjl2 . BZContent = RealName + "确认收货,成本" ;
mjl2 . PayID = "" ;
mjl2 . OrdersIDs = "" ;
mjl2 . OrdersID = 0 ;
mjl2 . utype = 17 ;
mjl2 . utype2 = 0 ;
mjl2 . Seef = - 1 ;
mjl2 . seeftime = dt ;
mjl2 . gtype = gtype ;
new Mtxfw . DAL . user_Results_jl2 ( ) . Add ( mjl2 ) ;
umodel0 . umoney41 + = zmoney ;
//减少买家余额
daoUser . UpdateMoney ( "umoney41" , zmoney , umodel0 . Id ) ;
}
}
}
}
if ( hasRead = = 2 )
{
daoorder . UpdatehasRead ( 3 , id ) ;
}
}
}
ds . Tables . Clear ( ) ;
/ * if ( config . JDTPEnable = = "0" )
{
ds = daoorder . GetList1 ( "id,pid,orderid,openid,transaction_id,kdcompay,yundanhao,Contacttel" , "gtype=" + gtype + " and IFDelete=0 and ifxhpt=1 And ifxnhy=0 and transaction_id<>'' And openid<>'' And O_Payed_Date<=DateAdd(hour,-24,'" + dt + "')" ) ;
if ( ds . Tables [ 0 ] . Rows . Count > 0 )
{
bool ifb = true ;
DateTime dt1 = Convert . ToDateTime ( DateTime . Now . ToString ( "yyyy-MM-dd HH:mm:ss" ) ) ;
if ( config . webXaccess_token ! = "" & & config . webXaccess_token_time ! = "" )
{
DateTime dt2 = Convert . ToDateTime ( Convert . ToDateTime ( config . webXaccess_token_time ) . AddMinutes ( 100 ) . ToString ( "yyyy-MM-dd HH:mm:ss" ) ) ;
if ( dt1 > dt2 )
{
ifb = false ;
}
}
else
{
ifb = false ;
}
if ( ! ifb )
{
Mtxfw . Utility . WXaccess_token ac = Mtxfw . Utility . Common . getxaccess_token ( config . webXAppID , config . webXAppSecret ) ;
config . webXaccess_token = ac . access_token ;
config . webXaccess_token_time = dt1 . ToString ( "yyyy-MM-dd HH:mm:ss" ) ;
config . Save ( ) ;
}
foreach ( System . Data . DataRow Dr in ds . Tables [ 0 ] . Rows )
{
int id = int . Parse ( Dr [ "id" ] . ToString ( ) ) ;
int pid = int . Parse ( Dr [ "pid" ] . ToString ( ) ) ;
string orderid = Dr [ "orderid" ] . ToString ( ) ;
string openid = Dr [ "openid" ] . ToString ( ) ;
string transaction_id = Dr [ "transaction_id" ] . ToString ( ) ;
string kdcompay = Dr [ "kdcompay" ] . ToString ( ) ;
string yundanhao = Dr [ "yundanhao" ] . ToString ( ) ;
string Contacttel = Dr [ "Contacttel" ] . ToString ( ) ;
string strproducts = new DAL . P_Product ( ) . Getzd ( "P_Name" , "P_id=" + pid ) . ToString ( ) ;
if ( strproducts = = "" )
{
strproducts = "测试商品" ;
}
string access_token = config . webXaccess_token ;
string order_key = "\"order_key\":{\"order_number_type\":2,\"transaction_id\":\"" + transaction_id + "\"}" ;
int logistics_type = 4 ;
int delivery_mode = 1 ;
string shipping_list = "\"shipping_list\":[" ;
shipping_list + = "{\"tracking_no\":\"\",\"express_company\":\"自提\",\"item_desc\":\"" + strproducts + "\",\"contact\":" ;
shipping_list + = "{\"consignor_contact\":\"153****9828\",\"receiver_contact\":\"" + Mtxfw . Utility . Common . cphone ( Contacttel ) + "\"}" ;
shipping_list + = "}" ;
shipping_list + = "]" ;
string upload_time = DateTime . Now . ToString ( "yyyy-MM-ddTHH:mm:ss+08:00" ) ;
string payer = "\"payer\":{\"openid\":\"" + openid + "\"}" ;
string paramString = "{" + order_key + ",\"logistics_type\":" + logistics_type + ",\"delivery_mode\":" + delivery_mode + "," + shipping_list + ",\"upload_time\":\"" + upload_time + "\"," + payer + "}" ;
string strResult = Mtxfw . Utility . Common . getPage2 ( "https://api.weixin.qq.com/wxa/sec/order/upload_shipping_info?access_token=" + access_token , "" , "utf-8" , true , true , paramString ) ;
mo = new Model . User_Errlog ( ) ;
mo . DLID = 0 ;
mo . ErrType = "upload_shipping_info0" ;
mo . addtime = DateTime . Now ;
mo . ErrBody = paramString ;
mo . ErrBody2 = strResult ;
new DAL . User_Errlog ( ) . Add ( mo ) ;
if ( strResult . IndexOf ( "\"errcode\"" ) ! = - 1 )
{
Mtxfw . Utility . return_upload_shipping_info remsg = ( Mtxfw . Utility . return_upload_shipping_info ) Mtxfw . Utility . Common . Fromreturn_upload_shipping_info ( strResult ) ;
if ( remsg . errcode = = 0 )
{
daoorder . Updateifxnhy ( 1 , id ) ;
}
}
else
{
daoorder . Updateifxnhy ( 2 , id ) ;
}
}
}
ds . Tables . Clear ( ) ;
} * /
}
if ( dt . Hour = = 0 )
{
if ( type = = 0 )
{
if ( new Mtxfw . DAL . user_Results_jl3 ( ) . GetCount ( "utype=0 And addtime>='" + mindt + "' and addtime<'" + maxdt + "'" ) = = 0 )
{
Model . user_Results_jl3 mjl3 = new Model . user_Results_jl3 ( ) ;
mjl3 . blmoney = 0 ;
mjl3 . fs = 0 ;
mjl3 . utype = "0" ;
mjl3 . addtime = dt ;
mjl3 . gtype = 0 ;
new Mtxfw . DAL . user_Results_jl3 ( ) . Add ( mjl3 ) ;
Mtxfw . Utility . Common . BackUpData ( 1 , apath ) ;
if ( dt . Day = = 1 )
{
DataSet dss = daoUser . GetList1 ( "id,uLevel4" , "gtype=" + gtype + " and UserState='正常' And IFStores=0 and uLevel4>0" ) ;
if ( dss . Tables [ 0 ] . Rows . Count > 0 )
{
foreach ( System . Data . DataRow Drr in dss . Tables [ 0 ] . Rows )
{
int dID = Convert . ToInt32 ( Drr [ "id" ] . ToString ( ) ) ;
int duLevel4 = Convert . ToInt32 ( Drr [ "uLevel4" ] . ToString ( ) ) ;
mjl2 = new Model . user_Results_jl2 ( ) ;
mjl2 . MemberId = dID ;
mjl2 . MemberId2 = duLevel4 ;
mjl2 . Addmoney = 0 ;
mjl2 . Cutmoney = 0 ;
mjl2 . Totalmoney = 0 ;
mjl2 . addtime = dt . AddDays ( - 1 ) ;
mjl2 . BZContent = "每月级别统计" ;
mjl2 . PayID = "" ;
mjl2 . OrdersIDs = "" ;
mjl2 . OrdersID = 0 ;
mjl2 . utype = 30 ;
mjl2 . utype2 = 0 ;
mjl2 . Seef = 0 ;
mjl2 . seeftime = dt ;
mjl2 . gtype = gtype ;
daojl2 . Add ( mjl2 ) ;
}
}
dss . Clear ( ) ;
dss = daoUser . GetList1 ( "id,umoney19" , "gtype=" + gtype + " and UserState='正常' And IFStores=0 and umoney19>0" ) ;
if ( dss . Tables [ 0 ] . Rows . Count > 0 )
{
foreach ( System . Data . DataRow Drr in dss . Tables [ 0 ] . Rows )
{
int dID = Convert . ToInt32 ( Drr [ "id" ] . ToString ( ) ) ;
Double dumoney19 = Convert . ToDouble ( Drr [ "umoney19" ] . ToString ( ) ) ;
mjl2 = new Model . user_Results_jl2 ( ) ;
mjl2 . MemberId = dID ;
mjl2 . MemberId2 = 0 ;
mjl2 . Addmoney = dumoney19 ;
mjl2 . Cutmoney = 0 ;
mjl2 . Totalmoney = dumoney19 ;
mjl2 . addtime = dt . AddDays ( - 1 ) ;
mjl2 . BZContent = "每月业绩统计" ;
mjl2 . PayID = "" ;
mjl2 . OrdersIDs = "" ;
mjl2 . OrdersID = 0 ;
mjl2 . utype = 29 ;
mjl2 . utype2 = 0 ;
mjl2 . Seef = 0 ;
mjl2 . seeftime = dt ;
mjl2 . gtype = gtype ;
daojl2 . Add ( mjl2 ) ;
}
}
dss . Clear ( ) ;
daoUser . Updategui0 ( ) ;
}
}
}
}
if ( dt . Hour = = 0 )
{
DayOfWeek day = dt . DayOfWeek ;
string dayString = day . ToString ( ) . ToLower ( ) ;
if ( type = = 0 )
{
if ( config . FHEnable5 = = "1" )
{
bool b = true ;
if ( b )
{
if ( new Mtxfw . DAL . user_jjfp ( ) . GetCount ( "TType=1 And addtime>='" + mindt + "' and addtime<'" + maxdt + "'" ) > 0 )
{
b = false ;
}
}
if ( b )
{
Double FHMoney = 0.00 , FHMoney0 = 0.00 ;
DataSet ds0 = new DAL . user_jjfp ( ) . GetList ( "" , "gtype=" + gtype + " and TType=0" ) ;
if ( ds0 . Tables [ 0 ] . Rows . Count > 0 )
{
FHMoney = Convert . ToDouble ( Convert . ToDouble ( ds0 . Tables [ 0 ] . Rows [ 0 ] [ "count2" ] ) . ToString ( "f2" ) ) ;
FHMoney0 = Convert . ToDouble ( Convert . ToDouble ( ds0 . Tables [ 0 ] . Rows [ 0 ] [ "count4" ] ) . ToString ( "f2" ) ) ;
}
ds0 . Clear ( ) ;
string mindt0 = DateTime . Now . AddDays ( - 1 ) . ToString ( "yyyy-MM-dd" ) + " 00:00:00" ;
string maxdt0 = DateTime . Now . ToString ( "yyyy-MM-dd" ) + " 00:00:00" ;
int addweek = Mtxfw . Utility . Common . GetWeekOfYear ( dt ) ;
if ( dayString = = "sunday" )
{
addweek - = 1 ;
}
int addmonth = Convert . ToInt32 ( ( addweek / 4 ) . ToString ( ) . Split ( '.' ) [ 0 ] ) ;
if ( addweek % 4 ! = 0 )
{
addmonth + = 1 ;
}
int ns = dt . Year - 2018 ;
if ( ns > 0 )
{
addweek + = ns * 52 ;
addmonth + = ns * 13 ;
}
Mtxfw . Model . user_jjfp jjfpmodel = new Mtxfw . Model . user_jjfp ( ) ;
jjfpmodel . count1 = 0 ;
jjfpmodel . count2 = 0 ;
jjfpmodel . count3 = 0 ;
jjfpmodel . count4 = 0 ;
jjfpmodel . count5 = 0 ;
jjfpmodel . count6 = 0 ;
jjfpmodel . count7 = 0 ;
jjfpmodel . count8 = 0 ;
jjfpmodel . addweek = addweek ;
jjfpmodel . addmonth = addmonth ;
jjfpmodel . addweektime1 = dt ;
jjfpmodel . addweektime2 = dt ;
jjfpmodel . TType = 1 ;
jjfpmodel . addtime = dt ;
jjfpmodel . zjnum = "" ;
int jjfpid = new Mtxfw . DAL . user_jjfp ( ) . Add ( jjfpmodel ) ;
Mtxfw . DAL . MemberStatistics . FHJS ( jjfpid , dt , config , gtype , FHMoney , FHMoney0 ) ;
if ( dt . Day = = 1 )
{
daoUser . UpdateuLevel ( "uLevel46" , 0 , "IFStores=0 and uLevel46=1" ) ;
}
logmodel = new Model . User_CZ_log ( ) ;
logmodel . MemberId = 0 ;
logmodel . AddTime = DateTime . Now ;
logmodel . IP = "" ;
logmodel . Body = "自动分红结算" ;
logmodel . UType = 0 ;
new DAL . User_CZ_log ( ) . Add ( logmodel ) ;
}
}
}
}
}
catch ( Exception ex )
{
mo = new Model . User_Errlog ( ) ;
mo . DLID = 0 ;
mo . ErrType = "删除未付款订单" ;
mo . addtime = DateTime . Now ;
mo . ErrBody = ex . ToString ( ) ;
mo . ErrBody2 = ex . Message ;
new DAL . User_Errlog ( ) . Add ( mo ) ;
}
}
#endregion
}
//public class hbList
//{
// public Double hbje { get; set; }
//}
}