public ActionResult CheckApply(string keyValue) { ExpApplyEntity entity = entityApp.GetForm(keyValue); AgentApp agApp = new AgentApp(); AgentEntity ag = agApp.GetForm(entity.c_agent_id); //更新申请表 entity.c_apply_state = 1; entityApp.SubmitForm(entity, keyValue); //更新代理商表 ag.c_agnet_type = (int)AgentType.Fran; agApp.SubmitForm(ag, null, ag.F_Id); #region 推荐奖励 //积分奖励 ScoreLogic.DealRewardScore(ag.F_Id, RewartType.Recommend); Agent ag2 = AgentLogic.GetEnityById(entity.c_agent_id); #endregion //扣减积分 int score = Convert.ToInt32(CommConfigLogic.GetValueFromConfig((int)ConfigCategory.ScoreConfigCate, (int)RewardConfigKey.expLevelUpScore)); ScoreDetailLogic.UpdateAgentScore(entity.c_agent_id, -score, "体验店升级扣除"); //升级 AgentRelation ar = AgentRelationLogic.FindEntity(t => t.c_child_id == ag.F_Id); Agent recomm_ag = AgentLogic.GetEnityById(ar.c_parent_id); LevelLogic.IsLevelUpWithCondition(recomm_ag); #region 生成代理商订单 Order order = new Order(); order.c_agent_id = ag.F_Id; order.c_mobile = ag.c_mobile; order.c_state = (int)OrderState.NoDeliver; order.c_remark = "代理商订单"; order.c_order_num = DateTime.Now.ToString("yyyyMMddHHmmss-") + Guid.NewGuid().ToString().Substring(0, 6); order.c_order_type = (int)OrderType.Agent; OrderLogic.InsertNewEntiy(order); #endregion return(Success("审核成功。")); }
public ActionResult PostOrder(string OrderId) { AjaxResult result = new AjaxResult(); try { Order order = OrderLogic.GetEnityById(OrderId); if (order == null) { throw new Exception("未找到订单"); } order.c_total = OrderDetailLogic.SumOrderTotal(OrderId); order.c_order_num = DateTime.Now.ToString("yyyyMMddHHmmss-") + Guid.NewGuid().ToString().Substring(0, 6); order.c_state = (int)OrderState.NoDeliver; order.c_rec_person = agentInfo.agent.c_rec_person; order.c_mobile = agentInfo.agent.c_rec_mobile; order.c_address = agentInfo.agent.c_address; if (agentInfo.CanCashScore < order.c_total) { throw new Exception("剩余积分不足以支付订单内所有商品"); } OrderLogic.UpdateEntity(order); int changeScore = 0 - (int)order.c_total; ScoreDetailLogic.UpdateAgentScore(agentInfo.agent.c_id, changeScore, "购买产品"); var detailList = OrderDetailLogic.GetList().Where(t => t.c_order_id == order.F_Id); if (detailList.Count() > 0) { int totalAmount = (int)detailList.Sum(t => t.c_amount); ScoreLogic.DealRewardScore(agentInfo.agent.c_id, RewartType.Purchase, totalAmount); } result.state = ResultType.success.ToString(); result.message = "成功"; return(Content(result.ToJson())); } catch (Exception ex) { result.state = ResultType.error.ToString(); result.message = string.Format("提交失败({0})", ex.Message); return(Content(result.ToJson())); throw; } }
public ActionResult EnabledAccount(string keyValue) { bool hadReward = agentApp.hadReward(keyValue); AgentEntity userEntity = new AgentEntity(); userEntity.F_Id = keyValue; userEntity.c_state = 1;//0:未审核 1:审核通过 userEntity.c_had_reward = true; agentApp.UpdateForm(userEntity); Agent ag = AgentLogic.GetEnityById(keyValue); //升级 AgentRelation ar = AgentRelationLogic.FindEntity(t => t.c_child_id == ag.c_id); Agent recomm_ag = AgentLogic.GetEnityById(ar.c_parent_id); LevelLogic.IsLevelUpWithCondition(recomm_ag); if (!hadReward) { #region 推荐奖励 //积分奖励 ScoreLogic.DealRewardScore(ag.c_id, RewartType.Recommend); #endregion if (ag.c_agnet_type != (int)AgentType.Exp)//体验店计算上下级奖励即可 { #region 生成代理商订单 Order order = new Order(); order.c_agent_id = ag.c_id; order.c_mobile = ag.c_mobile; order.c_state = (int)OrderState.NoDeliver; order.c_remark = "代理商订单"; order.c_order_num = DateTime.Now.ToString("yyyyMMddHHmmss-") + Guid.NewGuid().ToString().Substring(0, 6); order.c_order_type = (int)OrderType.Agent; OrderLogic.InsertNewEntiy(order); #endregion } } return(Success("审核成功。")); }