/// <summary> /// 代理等级配置 /// </summary> /// <returns></returns> public ActionResult AgentLevelConfig() { int aid = Utility.IO.Context.GetRequestInt("aid", 0); if (aid <= 0) { return(Content("参数错误")); } XcxAppAccountRelation xcx = XcxAppAccountRelationBLL.SingleModel.GetModelById(aid); if (xcx == null) { return(Content("小程序不存在")); } PinPlatform platform = PinPlatformBLL.SingleModel.GetModelByAid(xcx.Id); if (platform == null) { platform = new PinPlatform() { aid = xcx.Id }; platform.Id = Convert.ToInt32(PinPlatformBLL.SingleModel.Add(platform)); } ViewBag.PinAgentLevelConfigList = PinAgentLevelConfigBLL.SingleModel.GetListByAid(aid); ViewBag.aid = aid; return(View(platform)); }
/// <summary> /// 提现申请界面 /// </summary> /// <param name="aId"></param> /// <param name="storeId"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <returns></returns> // GET: PinAdmin/Cash public ActionResult Index(int aId = 0, int storeId = 0) { if (aId <= 0 || storeId <= 0) { return(Content("参数错误")); } PinPlatform platform = PinPlatformBLL.SingleModel.GetModelByAid(aId); if (platform == null) { return(Content("平台信息错误")); } PinStore store = (PinStore)Request.RequestContext.RouteData.Values["pinStore"]; C_UserInfo userInfo = C_UserInfoBLL.SingleModel.GetModel(store.userId); if (userInfo == null) { return(Content($"用户信息错误")); } PinAgent agent = PinAgentBLL.SingleModel.GetModelByUserId(userInfo.Id); int sumCash = DrawCashApplyBLL.SingleModel.GetSumCash(aId, store.userId); ViewBag.DrawCashSum = (sumCash * 0.01).ToString("0.00"); ViewData["platform"] = platform; ViewData["userInfo"] = userInfo; ViewData["agent"] = agent; return(View(store)); }
public ActionResult SaveAgentPolicy() { int aid = Utility.IO.Context.GetRequestInt("aid", 0); string agentPolicy = Utility.IO.Context.GetRequest("agentPolicy", string.Empty); if (aid <= 0 || string.IsNullOrEmpty(agentPolicy)) { result.msg = "参数错误"; return(Json(result)); } PinPlatform platform = PinPlatformBLL.SingleModel.GetModelByAid(aid); if (platform == null) { result.code = 0; result.msg = "平台不存在"; return(Json(result)); } platform.AgentPolicy = agentPolicy; if (PinPlatformBLL.SingleModel.Update(platform, "AgentPolicy")) { result.code = 1; result.msg = "保存成功"; } else { result.msg = "保存失败"; } return(Json(result)); }
public ActionResult TxSetting(int aid = 0) { if (aid <= 0) { return(Content("参数错误")); } XcxAppAccountRelation xcx = XcxAppAccountRelationBLL.SingleModel.GetModelById(aid); if (xcx == null) { return(Content("小程序不存在")); } PinPlatform platform = PinPlatformBLL.SingleModel.GetModelByAid(xcx.Id); if (platform == null) { platform = new PinPlatform() { aid = xcx.Id }; platform.Id = Convert.ToInt32(PinPlatformBLL.SingleModel.Add(platform)); } return(View(platform)); }
public ActionResult SaveTxSetting(int aid = 0, int minTxMoney = 0, int dealDays = 0, int serviceFee = 0, int toWx = 0, int toBank = 0, int qrcodeServiceFee = 0, int agentServiceFee = 0) { if (aid <= 0 || serviceFee < 0 || qrcodeServiceFee < 0 || agentServiceFee < 0) { result.msg = "参数错误"; return(Json(result)); } XcxAppAccountRelation xcx = XcxAppAccountRelationBLL.SingleModel.GetModelById(aid); if (xcx == null) { result.msg = "小程序不存在"; return(Json(result)); } PinPlatform platform = PinPlatformBLL.SingleModel.GetModelByAid(xcx.Id); if (platform == null) { result.msg = "平台信息错误"; return(Json(result)); } platform.minTxMoney = minTxMoney; platform.dealDays = dealDays; platform.serviceFee = serviceFee; platform.qrcodeServiceFee = qrcodeServiceFee; platform.agentServiceFee = agentServiceFee; //platform.toWx = toWx; platform.toBank = toBank; result.code = PinPlatformBLL.SingleModel.Update(platform, "minTxMoney,dealDays,serviceFee,qrcodeServiceFee,agentServiceFee") ? 1 : 0; result.msg = result.code == 1 ? "保存成功" : "保存失败"; return(Json(result)); }
/// <summary> /// 平台配置 /// </summary> /// <param name="aid"></param> /// <returns></returns> public ActionResult Setting(int aid = 0) { if (aid <= 0) { return(Content("参数错误")); } XcxAppAccountRelation xcx = XcxAppAccountRelationBLL.SingleModel.GetModelById(aid); if (xcx == null) { return(Content("小程序不存在")); } List <PinPicture> picList = PinPictureBLL.SingleModel.GetListByAid_Type(aid, 0); picList.ForEach(pic => pic.funModel = funList.Where(fun => fun.id == pic.funId).FirstOrDefault()); ViewData["picList"] = picList; PinPlatform platform = PinPlatformBLL.SingleModel.GetModelByAid(aid); if (platform == null) { platform = new PinPlatform() { aid = aid }; platform.Id = Convert.ToInt32(PinPlatformBLL.SingleModel.Add(platform)); } platform.poster = Microsoft.JScript.GlobalObject.unescape(platform.poster); return(View(platform)); }
public ActionResult SavePoster(int aid = 0, string poster = "") { if (aid <= 0 || string.IsNullOrEmpty(poster)) { result.msg = "参数错误"; return(Json(result)); } PinPlatform platform = PinPlatformBLL.SingleModel.GetModelByAid(aid); if (platform == null) { result.code = 0; result.msg = "平台不存在"; return(Json(result)); } platform.posterbk = platform.poster; platform.poster = poster; if (PinPlatformBLL.SingleModel.Update(platform, "posterbk,poster")) { result.code = 1; result.msg = "保存成功"; } else { result.msg = "保存失败"; } return(Json(result)); }
public ActionResult SaveAgentSetting() { int aid = Utility.IO.Context.GetRequestInt("aid", 0); int agentProtectDays = Utility.IO.Context.GetRequestInt("agentProtectDays", 0); int jumpExtract = Utility.IO.Context.GetRequestInt("jumpExtract", 0); int agentSearchPort = Utility.IO.Context.GetRequestInt("agentSearchPort", 0); if (aid <= 0) { result.msg = "参数错误"; return(Json(result)); } if (agentProtectDays <= 0) { result.msg = "代理保护期不能小于0"; return(Json(result)); } if (jumpExtract <= 0) { result.msg = "越级分佣比不能少于零"; return(Json(result)); } PinPlatform platform = PinPlatformBLL.SingleModel.GetModelByAid(aid); if (platform == null) { result.msg = "平台不存在"; return(Json(result)); } platform.agentProtectDays = agentProtectDays; platform.AgentSearchPort = agentSearchPort; platform.JumpExtract = jumpExtract; if (PinPlatformBLL.SingleModel.Update(platform, "agentProtectDays,AgentSearchPort,JumpExtract")) { result.code = 1; result.msg = "保存成功"; } else { result.msg = "保存失败"; } return(Json(result)); }
/// <summary> /// 成为代理自动入驻店铺 /// </summary> /// <param name="agent"></param> /// <returns></returns> public bool AddStore(PinAgent agent) { C_UserInfo userInfo = C_UserInfoBLL.SingleModel.GetModel(agent.userId); if (userInfo == null) { log4net.LogHelper.WriteError(GetType(), new Exception($"代理缴费自动入驻门店失败:找不到用户信息 userid:{agent.userId}")); return(false); } if (userInfo.StoreId > 0) { return(true); } PinStore store = GetModel($"loginName=@loginName and state>-1 and aid={agent.aId}", new MySqlParameter[] { new MySqlParameter("@loginName", userInfo.TelePhone) }); if (store != null) { return(true); } PinPlatform platform = PinPlatformBLL.SingleModel.GetModelByAid((agent.aId)); if (platform == null) { log4net.LogHelper.WriteError(GetType(), new Exception($"代理缴费自动入驻门店失败:平台信息错误 aId:{agent.aId}")); return(false); } PinStore storeInfo = new PinStore { aId = agent.aId, rz = 1, state = 1, endDate = DateTime.Now.AddDays(platform.freeDays), loginName = userInfo.TelePhone, password = Utility.DESEncryptTools.GetMd5Base32("123456"), startDate = DateTime.Now, userId = userInfo.Id, phone = userInfo.TelePhone, logo = userInfo.HeadImgUrl, storeName = userInfo.NickName, }; int result = OpenStore(userInfo, storeInfo); return(result > 0); }
/// <summary> /// 检查待收货、待自取订单是否超过规定时间可以自动完成交易 /// </summary> /// <returns></returns> public bool CheckOrderSuccess(int aid = 6933593) { PinPlatform platform = PinPlatformBLL.SingleModel.GetModelByAid(aid); if (platform == null) { log4net.LogHelper.WriteError(GetType(), new Exception("拼享惠订单自动完成交易服务异常:找不到平台配置 aid:" + aid)); return(false); } if (platform.orderSuccessDays > 0) { DateTime date = DateTime.Now.AddDays(-platform.orderSuccessDays); string sqlwhere = $"ordertype=0 and aid={aid} and state in ({(int)PinOrderState.待收货},{(int)PinOrderState.待自取}) and payState!={(int)PayState.未付款} and paytime<'{date}'"; List <PinGoodsOrder> list = GetList(sqlwhere); if (list != null && list.Count > 0) { OrderSuccess(list, remark: "交易完成"); } } return(true); }
public ActionResult Reg(string act = "", string loginname = "", string password = "", string authCode = "", int aid = 0) { if (!string.IsNullOrEmpty(act)) { if (aid <= 0 || loginname.Length == 0) { result.msg = "非法请求"; return(Json(result)); } if (act == "reg") { PinStore store = PinStoreBLL.SingleModel.GetStoreByPhone(loginname); if (store != null) { result.msg = "用户名已存在,请登陆"; return(Json(result)); } string code = RedisUtil.Get <string>(loginname); if (code == "" || authCode == "" || code != authCode) { result.msg = "验证码错误"; return(Json(result)); } PinPlatform platform = PinPlatformBLL.SingleModel.GetModelByAid(aid); store = new PinStore { aId = aid, rz = 1, state = 1, endDate = DateTime.Now.AddDays(platform.freeDays), loginName = loginname, password = Utility.DESEncryptTools.GetMd5Base32(password), startDate = DateTime.Now, userId = 0,// phone = loginname, logo = "", storeName = "", agentId = 0 }; object obj = PinStoreBLL.SingleModel.Add(store); int storeId = 0; if (!Convert.IsDBNull(obj)) { storeId = Convert.ToInt32(obj); } if (storeId > 0) { //店铺开通成功,检查用户是否在小程序端授权过手机号码,如果有,进行关联 //拼享惠绑定的的appid为: C_UserInfo userInfo = C_UserInfoBLL.SingleModel.GetModelByTelephone_appid(store.phone, "wxbb2fe3080d04c9b2"); if (userInfo != null) { userInfo.StoreId = storeId; C_UserInfoBLL.SingleModel.Update(userInfo, "StoreId"); } result.code = 1; result.obj = new { store.aId, storeId = store.id, }; result.msg = DESEncryptTools.DESEncrypt(store.id.ToString()); } else { result.msg = "开通失败"; result.obj = 0; } return(Json(result)); } } return(View()); }
/// <summary> /// 申请提现 /// </summary> /// <param name="aId"></param> /// <param name="storeId"></param> /// <param name="txway"></param> /// <param name="cash"></param> /// <param name="cashType">0:扫码提现 1:平台提现</param> /// <returns></returns> public ActionResult AddApply(int aId = 0, int storeId = 0, int txway = -1, int cash = 0, int cashType = (int)DrawCashApplyType.拼享惠平台交易) { if (aId <= 0 || storeId <= 0) { result.msg = "参数错误"; return(Json(result)); } PinPlatform platform = PinPlatformBLL.SingleModel.GetModelByAid(aId); if (platform == null) { result.msg = "平台信息错误"; return(Json(result)); } PinStore store = PinStoreBLL.SingleModel.GetModelByAid_Id(aId, storeId); if (store == null) { result.msg = "店铺信息错误"; return(Json(result)); } C_UserInfo userInfo = C_UserInfoBLL.SingleModel.GetModel(store.userId); if (userInfo == null) { result.msg = "用户信息错误"; return(Json(result)); } if (cash < platform.minTxMoney) { result.msg = $"提现金额不可低于{platform.minTxMoneyStr}元"; return(Json(result)); } string account = string.Empty; string accountName = string.Empty; switch (txway) { case 1: //提现到银行卡 if (string.IsNullOrEmpty(store.bankcardName)) { result.msg = "请设置银行卡账户名称"; return(Json(result)); } accountName = store.bankcardName; if (string.IsNullOrEmpty(store.bankcardNum)) { result.msg = "请设置银行卡账户"; return(Json(result)); } if (platform.toBank != 1) { result.msg = "暂时无法通过银行卡提现"; return(Json(result)); } account = store.bankcardNum; break; case 0: //提现到微信 if (platform.toWx != 1) { result.msg = "暂时无法通过微信提现"; return(Json(result)); } accountName = "微信账号"; account = userInfo.NickName; break; default: result.msg = "参数错误"; return(Json(result)); } int serviceFee = cash * platform.serviceFee / 1000; switch (cashType) { case (int)DrawCashApplyType.拼享惠平台交易: if (cash > store.cash && cashType == (int)DrawCashApplyType.拼享惠平台交易) { result.msg = "超出可提现金额"; return(Json(result)); } double fee = cash * platform.serviceFee * 0.001; serviceFee = (int)Math.Ceiling(fee); result.code = DrawCashApplyBLL.SingleModel.PxhAddApply(store, userInfo.Id, account, accountName, cash, txway, serviceFee, (int)DrawCashApplyType.拼享惠平台交易); break; case (int)DrawCashApplyType.拼享惠代理收益: PinAgent agent = PinAgentBLL.SingleModel.GetModelByUserId(userInfo.Id); if (agent == null) { result.msg = "你还不是代理"; return(Json(result)); } if (cash * 1000 > agent.cash) { result.msg = "超出可提现金额"; return(Json(result)); } fee = cash * platform.agentServiceFee * 0.001; serviceFee = (int)Math.Ceiling(fee); result.code = DrawCashApplyBLL.SingleModel.PxhAddApply(agent, userInfo.Id, account, accountName, cash, txway, serviceFee); break; case (int)DrawCashApplyType.拼享惠扫码收益: if (cash > store.qrcodeCash && cashType == (int)DrawCashApplyType.拼享惠扫码收益) { result.msg = "超出可提现金额"; return(Json(result)); } fee = cash * platform.qrcodeServiceFee * 0.001; serviceFee = (int)Math.Ceiling(fee); result.code = DrawCashApplyBLL.SingleModel.PxhAddApply(store, userInfo.Id, account, accountName, cash, txway, serviceFee, (int)DrawCashApplyType.拼享惠扫码收益); break; default: result.msg = "参数错误"; return(Json(result)); } //result.code = drawCashApplyBLL.PxhAddApply(store, userInfo.Id, account, accountName, cash, txway, serviceFee, 0); result.msg = result.code == 1 ? "申请已提交" : "提交失败"; return(Json(result)); }
public ActionResult saveSetting(int aid = 0, int openKf = -1, int freeDays = 0, string kfPhone = "", int agentFee = 0, int agentExtract = 0, int orderExtract = 0, int agentProtectDays = 0, string ServiceWeiXin = "", int orderSuccessDays = 0, int firstExtract = 0, int secondExtract = 0, int agentSearchPort = 0, int addStorePort = 0) { if (aid <= 0 || (openKf != 0 && openKf != 1)) { result.code = 0; result.msg = "参数错误"; return(Json(result)); } if (freeDays <= 0) { result.code = 0; result.msg = "免费体验天数:请输入大于0的整数"; return(Json(result)); } if (openKf == 1 && string.IsNullOrEmpty(kfPhone)) { result.code = 0; result.msg = "请输入客服号码"; return(Json(result)); } if (agentFee <= 0) { result.code = 0; result.msg = "代理费不能少于0元"; return(Json(result)); } if (agentProtectDays <= 0) { result.code = 0; result.msg = "代理保护期不能小于0"; return(Json(result)); } if (agentExtract <= 0) { result.code = 0; result.msg = "入驻提成不能少于零"; return(Json(result)); } if (orderExtract <= 0) { result.code = 0; result.msg = "订单提成不能少于零"; return(Json(result)); } if (firstExtract < 0 || secondExtract < 0) { result.code = 0; result.msg = "直接分佣比例或者间接分佣比例不能少于零"; return(Json(result)); } if ((firstExtract + secondExtract) > 1000) { result.code = 0; result.msg = "直接分佣比例跟间接分佣比例之和不能大于100%"; return(Json(result)); } PinPlatform platform = PinPlatformBLL.SingleModel.GetModelByAid(aid); if (platform == null) { result.code = 0; result.msg = "平台不存在"; return(Json(result)); } platform.openKf = openKf; platform.freeDays = freeDays; platform.kfPhone = kfPhone; platform.agentFee = agentFee; platform.agentExtract = agentExtract; platform.orderExtract = orderExtract; platform.agentProtectDays = agentProtectDays; platform.ServiceWeiXin = ServiceWeiXin; platform.orderSuccessDays = orderSuccessDays; platform.FirstExtract = firstExtract; platform.SecondExtract = secondExtract; platform.AgentSearchPort = agentSearchPort; platform.AddStorePort = addStorePort; if (PinPlatformBLL.SingleModel.Update(platform, "AddStorePort,FirstExtract,SecondExtract,AgentSearchPort,freedays,openkf,kfphone,agentFee,agentExtract,orderExtract,agentProtectDays,ServiceWeiXin")) { result.code = 1; result.msg = "保存成功"; return(Json(result)); } else { result.code = 0; result.msg = "保存失败"; return(Json(result)); } }
/// <summary> /// 代理提成 /// </summary> /// <param name="agent"></param> /// <param name="pinOrder"></param> /// <param name="tran"></param> /// <returns></returns> public bool UpdateIncome(PinAgent agent, PinGoodsOrder pinOrder, TransactionModel tran = null) { bool istran = tran != null; if (!istran) { tran = new TransactionModel(); } PinPlatform platform = PinPlatformBLL.SingleModel.GetModelByAid(agent.aId); if (platform == null) { log4net.LogHelper.WriteError(GetType(), new Exception($"代理提成错误:找不到平台信息信息 userid:{agent.fuserId}")); return(istran); } PinAgentLevelConfig agentLevelConfig = PinAgentLevelConfigBLL.SingleModel.GetPinAgentLevelConfig(agent.AgentLevel, agent.aId); if (agentLevelConfig == null) { log4net.LogHelper.WriteInfo(GetType(), $"代理提成错误:当前入驻代理商{agent.id}等级找不到"); return(istran); } PinAgent fagent = GetModelByUserId(agent.fuserId); if (fagent == null) { log4net.LogHelper.WriteInfo(GetType(), $"代理提成错误:找不到上级代理信息 userid:{agent.fuserId}"); return(istran); } //查找该代理上级所属等级 根据所属等级进行不同比例分成 PinAgentLevelConfig fagentLevelConfig = PinAgentLevelConfigBLL.SingleModel.GetPinAgentLevelConfig(fagent.AgentLevel, fagent.aId); if (fagentLevelConfig == null) { log4net.LogHelper.WriteInfo(GetType(), $"代理提成错误:上级代理商{fagent.id}等级找不到"); return(istran); } int percent = fagentLevelConfig.AgentExtract; if (agentLevelConfig.LevelId > fagentLevelConfig.LevelId) { //表示当前代理商级别高于所属上级代理商级别则按越级比例分配给上级 percent = platform.JumpExtract; } //上级代理获得提成 fagent.cash += pinOrder.money * percent; fagent.money += pinOrder.money * percent; tran.Add(BuildUpdateSql(fagent, "cash,money")); #region 查找上级代理商是否有上级,如果有上级则上级也要获得抽成 PinAgent grandfatherAgent = GetModelByUserId(fagent.fuserId); if (grandfatherAgent != null) { //上上级 PinAgentLevelConfig gfagentLevelConfig = PinAgentLevelConfigBLL.SingleModel.GetPinAgentLevelConfig(grandfatherAgent.AgentLevel, grandfatherAgent.aId); if (fagentLevelConfig == null || gfagentLevelConfig.SecondAgentExtract <= 0 || (gfagentLevelConfig.AgentExtract + gfagentLevelConfig.SecondAgentExtract) > 1000) { log4net.LogHelper.WriteInfo(GetType(), $"上上级代理提成错误:上上级代理商{grandfatherAgent.id}等级找不到或者比例不能分成"); return(istran); } grandfatherAgent.cash += pinOrder.money * gfagentLevelConfig.SecondAgentExtract; grandfatherAgent.money += pinOrder.money * gfagentLevelConfig.SecondAgentExtract; tran.Add(BuildUpdateSql(grandfatherAgent, "cash,money")); } #endregion if (istran) { return(true); } return(ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray)); }
/// <summary> /// 代理提成日志 /// </summary> /// <param name="agent"></param> /// <param name="pinOrder"></param> /// <param name="tran"></param> /// <returns></returns> public bool AddAgentLog(PinAgent agent, PinGoodsOrder pinOrder, TransactionModel tran = null) { bool istran = tran != null; if (!istran) { tran = new TransactionModel(); } PinPlatform platform = PinPlatformBLL.SingleModel.GetModelByAid(agent.aId); if (platform == null) { log4net.LogHelper.WriteError(GetType(), new Exception("平台信息错误")); return(false); } #region 旧代码 没有代理商等级时候的逻辑 //int Percent = platform.agentExtract;//上级比例 //PinAgent grandfatherAgent = null; //int money = pinOrder.money * Percent; //if (agent.fuserId > 0) //{ // PinAgent fatherAgent = PinAgentBLL.SingleModel.GetModelByUserId(agent.fuserId); // if (fatherAgent != null) // { // grandfatherAgent = PinAgentBLL.SingleModel.GetModelByUserId(fatherAgent.fuserId); // if (grandfatherAgent != null && platform.FirstExtract > 0 && platform.SecondExtract > 0 && (platform.FirstExtract + platform.SecondExtract) <= 1000) // { // //表示有上上级 重新分配上级提成比例 // money = Convert.ToInt32(platform.FirstExtract * 0.001 * money); // } // } //} //PinAgentIncomeLog log = new PinAgentIncomeLog() //{ // aId = agent.aId, // userId = agent.fuserId, // sourceUid = agent.userId, // income = money, // source = 0 //}; //C_UserInfo userInfo = C_UserInfoBLL.SingleModel.GetModel(agent.userId); //if (userInfo == null) //{ // log.remark = $"代理付费日志出错:找不到代理用户信息 userid:{agent.userId}"; // log4net.LogHelper.WriteError(GetType(), new Exception(log.remark)); // tran.Add(BuildAddSql(log)); // if (istran) return true; // return ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray); //} //log.remark = $"{userInfo.NickName} 成为代理"; //if (agent.fuserId > 0) //{ // PinAgent fagent = PinAgentBLL.SingleModel.GetModelByUserId(agent.fuserId); // if (fagent == null) // { // log.remark = $"代理付费日志出错:找不到上级代理 userid:{agent.fuserId}"; // log4net.LogHelper.WriteError(GetType(), new Exception(log.remark)); // tran.Add(BuildAddSql(log)); // if (istran) return true; // return ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray); // } // log.agentId = fagent.id; // log.beforeMoney = fagent.cash; // log.afterMoney = fagent.cash + money; // C_UserInfo fuserInfo = C_UserInfoBLL.SingleModel.GetModel(agent.fuserId); // if (fuserInfo == null) // { // log.remark = $"代理付费日志出错:找不到上级代理用户信息 userid:{agent.fuserId}"; // log4net.LogHelper.WriteError(GetType(), new Exception(log.remark)); // tran.Add(BuildAddSql(log)); // if (istran) return true; // return ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray); // } // log.remark += $",{fuserInfo.NickName}获得提成{log.incomeStr}元"; //} //tran.Add(BuildAddSql(log)); #region 级分提成日志 //if (grandfatherAgent != null && platform.FirstExtract > 0 && platform.SecondExtract > 0 && (platform.FirstExtract + platform.SecondExtract) <= 1000) //{ // //表示有上上级 记录分给上上级提成日志 // int grandfatherAgentMoney = Convert.ToInt32(pinOrder.money * Percent * platform.SecondExtract * 0.001); // PinAgentIncomeLog grandfatherAgentLog = new PinAgentIncomeLog() // { // aId = grandfatherAgent.aId, // userId = grandfatherAgent.userId, // sourceUid = agent.userId, // income = grandfatherAgentMoney, // source = 0, // ExtractType = 1 // }; // grandfatherAgentLog.agentId = grandfatherAgent.id; // grandfatherAgentLog.beforeMoney = grandfatherAgent.cash; // grandfatherAgentLog.afterMoney = grandfatherAgent.cash + grandfatherAgentMoney; // C_UserInfo gfuserInfo = C_UserInfoBLL.SingleModel.GetModel(grandfatherAgent.userId); // if (gfuserInfo == null) // { // grandfatherAgentLog.remark = $"代理付费日志出错:找不到上上级代理用户信息 userid:{grandfatherAgent.userId}"; // log4net.LogHelper.WriteError(GetType(), new Exception(grandfatherAgentLog.remark)); // tran.Add(BuildAddSql(grandfatherAgentLog)); // if (istran) return true; // return ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray); // } // grandfatherAgentLog.remark += $",{gfuserInfo.NickName}获得提成{grandfatherAgentLog.incomeStr}元"; // grandfatherAgentLog.remark += $"{userInfo.NickName} 成为代理(下下级)"; // tran.Add(BuildAddSql(grandfatherAgentLog)); //} #endregion #endregion PinAgentLevelConfig agentLevelConfig = PinAgentLevelConfigBLL.SingleModel.GetPinAgentLevelConfig(agent.AgentLevel, agent.aId); if (agentLevelConfig == null) { log4net.LogHelper.WriteInfo(GetType(), $"代理提成log错误:当前入驻代理商{agent.id}等级找不到"); return(false); } PinAgent fagent = PinAgentBLL.SingleModel.GetModelByUserId(agent.fuserId); if (fagent == null) { log4net.LogHelper.WriteInfo(GetType(), $"代理提成log错误:找不到上级代理信息 userid:{agent.fuserId}"); return(false); } //查找该代理上级所属等级 根据所属等级进行不同比例分成 PinAgentLevelConfig fagentLevelConfig = PinAgentLevelConfigBLL.SingleModel.GetPinAgentLevelConfig(fagent.AgentLevel, fagent.aId); if (fagentLevelConfig == null) { log4net.LogHelper.WriteInfo(GetType(), $"代理提log成错误:上级代理商{fagent.id}等级找不到"); return(false); } int percent = fagentLevelConfig.AgentExtract; if (agentLevelConfig.LevelId > fagentLevelConfig.LevelId) { //表示当前代理商级别高于所属上级代理商级别则按越级比例分配给上级 percent = platform.JumpExtract; } int money = pinOrder.money * percent; PinAgentIncomeLog fAgengLog = new PinAgentIncomeLog() { aId = agent.aId, userId = agent.fuserId, sourceUid = agent.userId, income = money, source = 0, agentId = fagent.id, beforeMoney = fagent.cash, afterMoney = fagent.cash + money }; C_UserInfo agentUserInfo = C_UserInfoBLL.SingleModel.GetModel(agent.userId); if (agentUserInfo == null) { fAgengLog.remark = $"代理付费日志出错:找不到代理用户信息 userid:{agent.userId}"; log4net.LogHelper.WriteInfo(GetType(), fAgengLog.remark); tran.Add(BuildAddSql(fAgengLog)); if (istran) { return(true); } return(ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray)); } fAgengLog.remark = $"{agentUserInfo.NickName}成为{agentLevelConfig.LevelName}代理"; C_UserInfo fuserInfo = C_UserInfoBLL.SingleModel.GetModel(agent.fuserId); if (fuserInfo == null) { fAgengLog.remark = $"代理付费日志出错:找不到上级代理用户信息 userid:{agent.fuserId}"; log4net.LogHelper.WriteInfo(GetType(), fAgengLog.remark); tran.Add(BuildAddSql(fAgengLog)); if (istran) { return(true); } return(ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray)); } fAgengLog.remark += $",{fuserInfo.NickName}获得提成{fAgengLog.incomeStr}元"; tran.Add(BuildAddSql(fAgengLog)); #region 级分提成日志 PinAgent grandfatherAgent = PinAgentBLL.SingleModel.GetModelByUserId(fagent.fuserId); if (grandfatherAgent != null) { //表示有上上级 记录分给上上级提成日志 PinAgentLevelConfig gfagentLevelConfig = PinAgentLevelConfigBLL.SingleModel.GetPinAgentLevelConfig(grandfatherAgent.AgentLevel, grandfatherAgent.aId); if (fagentLevelConfig == null || gfagentLevelConfig.SecondAgentExtract <= 0 || (gfagentLevelConfig.AgentExtract + gfagentLevelConfig.SecondAgentExtract) > 1000) { log4net.LogHelper.WriteInfo(GetType(), $"上上级代理提成错误:上上级代理商{grandfatherAgent.id}等级找不到或者比例不能分成"); return(istran); } int grandfatherAgentMoney = pinOrder.money * gfagentLevelConfig.SecondAgentExtract; PinAgentIncomeLog grandfatherAgentLog = new PinAgentIncomeLog() { aId = grandfatherAgent.aId, userId = grandfatherAgent.userId, sourceUid = agent.userId, income = grandfatherAgentMoney, source = 0, ExtractType = 1, agentId = grandfatherAgent.id, beforeMoney = grandfatherAgent.cash, afterMoney = grandfatherAgent.cash + grandfatherAgentMoney }; C_UserInfo gfuserInfo = C_UserInfoBLL.SingleModel.GetModel(grandfatherAgent.userId); if (gfuserInfo == null) { grandfatherAgentLog.remark = $"代理付费日志出错:找不到上上级代理用户信息 userid:{grandfatherAgent.userId}"; log4net.LogHelper.WriteError(GetType(), new Exception(grandfatherAgentLog.remark)); tran.Add(BuildAddSql(grandfatherAgentLog)); if (istran) { return(true); } return(ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray)); } grandfatherAgentLog.remark += $",{gfuserInfo.NickName}获得提成{grandfatherAgentLog.incomeStr}元"; grandfatherAgentLog.remark += $"{fuserInfo.NickName} 成为代理(下下级)"; tran.Add(BuildAddSql(grandfatherAgentLog)); } #endregion if (istran) { return(true); } return(ExecuteTransactionDataCorect(tran.sqlArray, tran.ParameterArray)); }