public CPS_Convert_LinkResponse ConvertLink(int plan_id, int user_id)
 {
     try
     {
         dm_dauomai_plan_manageEntity dm_Dauomai_Plan_ManageEntity = GetEntity(plan_id);
         if (dm_Dauomai_Plan_ManageEntity.IsEmpty())
         {
             throw new Exception("推广计划不存在!");
         }
         DuoMai_ApiManage        duoMai_ApiManage        = new DuoMai_ApiManage(CommonConfig.duomai_appkey, CommonConfig.duomai_appsecret);
         CPS_Convert_LinkRequest cPS_Convert_LinkRequest = new CPS_Convert_LinkRequest();
         cPS_Convert_LinkRequest.ads_id = dm_Dauomai_Plan_ManageEntity.ads_id;
         cPS_Convert_LinkRequest.ext    = new CPS_Convert_Link_ext
         {
             euid = user_id.ToString()
         };
         cPS_Convert_LinkRequest.site_id = CommonConfig.duomai_pid;
         cPS_Convert_LinkRequest.url     = dm_Dauomai_Plan_ManageEntity.url;
         return(duoMai_ApiManage.Get_CPS_Convert_Link(cPS_Convert_LinkRequest));
     }
     catch (Exception ex)
     {
         if (ex is ExceptionEx)
         {
             throw;
         }
         else
         {
             throw ExceptionEx.ThrowServiceException(ex);
         }
     }
 }
        public void StartPlan(int plan_id)
        {
            IRepository db = null;

            try
            {
                dm_dauomai_plan_manageEntity dm_Dauomai_Plan_ManageEntity = GetEntity(plan_id);
                if (dm_Dauomai_Plan_ManageEntity.IsEmpty())
                {
                    throw new Exception("推广计划不存在!");
                }

                dm_Dauomai_Plan_ManageEntity.use_status = 1;
                dm_Dauomai_Plan_ManageEntity.Modify(dm_Dauomai_Plan_ManageEntity.id);

                dm_decoration_fun_manageEntity dm_Decoration_Fun_ManageEntity = this.BaseRepository("dm_data").FindEntity <dm_decoration_fun_manageEntity>(t => t.fun_param == plan_id.ToString());

                db = this.BaseRepository("dm_data").BeginTrans();

                ///功能中不存在该计划
                if (dm_Decoration_Fun_ManageEntity.IsEmpty())
                {
                    dm_Decoration_Fun_ManageEntity            = new dm_decoration_fun_manageEntity();
                    dm_Decoration_Fun_ManageEntity.fun_name   = dm_Dauomai_Plan_ManageEntity.ads_name;
                    dm_Decoration_Fun_ManageEntity.fun_param  = dm_Dauomai_Plan_ManageEntity.id.ToString();
                    dm_Decoration_Fun_ManageEntity.fun_remark = dm_Dauomai_Plan_ManageEntity.commission;
                    dm_Decoration_Fun_ManageEntity.fun_type   = 2;
                    dm_Decoration_Fun_ManageEntity.Create();
                    db.Insert(dm_Decoration_Fun_ManageEntity);
                }
                else
                {
                    dm_Decoration_Fun_ManageEntity.fun_name   = dm_Dauomai_Plan_ManageEntity.ads_name;
                    dm_Decoration_Fun_ManageEntity.fun_param  = dm_Dauomai_Plan_ManageEntity.id.ToString();
                    dm_Decoration_Fun_ManageEntity.fun_remark = dm_Dauomai_Plan_ManageEntity.commission;
                    dm_Decoration_Fun_ManageEntity.Modify(dm_Decoration_Fun_ManageEntity.id);
                    db.Update(dm_Decoration_Fun_ManageEntity);
                }
                db.Update(dm_Dauomai_Plan_ManageEntity);
                db.Commit();
            }
            catch (Exception ex)
            {
                if (db != null)
                {
                    db.Rollback();
                }
                if (ex is ExceptionEx)
                {
                    throw;
                }
                else
                {
                    throw ExceptionEx.ThrowServiceException(ex);
                }
            }
        }
        public void StopPlan(int plan_id)
        {
            IRepository db = null;

            try
            {
                dm_dauomai_plan_manageEntity dm_Dauomai_Plan_ManageEntity = GetEntity(plan_id);
                if (dm_Dauomai_Plan_ManageEntity.IsEmpty())
                {
                    throw new Exception("推广计划不存在!");
                }

                dm_Dauomai_Plan_ManageEntity.use_status = 0;
                dm_Dauomai_Plan_ManageEntity.Modify(dm_Dauomai_Plan_ManageEntity.id);

                db = this.BaseRepository("dm_data").BeginTrans();
                db.Delete <dm_decoration_fun_manageEntity>(t => t.fun_param == plan_id.ToString());
                db.Delete <dm_decoration_template_module_itemEntity>(t => t.module_fun_id == plan_id);
                db.Update(dm_Dauomai_Plan_ManageEntity);
                db.Commit();
            }
            catch (Exception ex)
            {
                if (db != null)
                {
                    db.Rollback();
                }
                if (ex is ExceptionEx)
                {
                    throw;
                }
                else
                {
                    throw ExceptionEx.ThrowServiceException(ex);
                }
            }
        }