Ejemplo n.º 1
0
        public string DynamicVipPropertySave(string pRequest)
        {
            var clientBussinessDefinedBLL = new ClientBussinessDefinedBLL(PrivateLoggingSessionInfo);

            var rd = new EmptyRD();
            var rp = pRequest.DeserializeJSONTo <APIRequest <JIT.CPOS.BS.BLL.ClientBussinessDefinedBLL.DynamicVipPropertySaveRP> >();

            rp.Parameters.Validate();

            string result = clientBussinessDefinedBLL.DynamicVipPropertySave(rp.Parameters);

            var rsp = new SuccessResponse <IAPIResponseData>(rd);

            if (result == "3")
            {
                rsp.Message    = "添加属性失败,属性名称已经存在.";
                rsp.ResultCode = 201;
            }
            else if (result == "2")
            {
                rsp.Message    = "添加属性失败,最多添加50个.";
                rsp.ResultCode = 201;
            }
            return(rsp.ToJSON());
        }
Ejemplo n.º 2
0
        public string ActiveCard(string pRequest)
        {
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            var cardDepositBLL     = new CardDepositBLL(loggingSessionInfo);

            var rp = pRequest.DeserializeJSONTo <APIRequest <ActiveCardRP> >();

            rp.Parameters.Validate();

            var rd  = new EmptyRD();
            var rsp = new SuccessResponse <IAPIResponseData>(rd);

            int result = cardDepositBLL.ActiveCard(rp);

            if (result >= 1)
            {
                rsp.ResultCode = 0;
                rsp.Message    = result.ToString();
            }
            else
            {
                rsp.ResultCode = 300;
                rsp.Message    = "密码错误或卡已被使用!";
            }

            return(rsp.ToJSON());
        }
Ejemplo n.º 3
0
        public string ToggleRetailStatus(string pRequest)
        {
            var rp = pRequest.DeserializeJSONTo <APIRequest <ToggleRetailStatusRP> >();

            if (string.IsNullOrEmpty(rp.Parameters.RetailTraderID))
            {
                throw new APIException("缺少参数【RetailTraderID】或参数值为空")
                      {
                          ErrorCode = 135
                      };
            }
            if (string.IsNullOrEmpty(rp.Parameters.Status))
            {
                throw new APIException("缺少参数【Status】或参数值为空")
                      {
                          ErrorCode = 135
                      };
            }

            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            var bll = new RetailTraderBLL(loggingSessionInfo);

            RetailTraderEntity en = new RetailTraderEntity();

            en.RetailTraderID = rp.Parameters.RetailTraderID;
            en.Status         = rp.Parameters.Status;
            bll.Update(en, null, false);

            var rd  = new EmptyRD();
            var rsp = new SuccessResponse <IAPIResponseData>(rd);


            return(rsp.ToJSON());
        }
Ejemplo n.º 4
0
        public string SaveRetailTraderItemMapping(string pRequest)
        {
            var rp = pRequest.DeserializeJSONTo <APIRequest <RetailTraderItemMappingRP> >();

            var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID);
            var bll = new RetailTraderItemMappingBLL(loggingSessionInfo);
            var rd  = new EmptyRD();
            var rsp = new SuccessResponse <IAPIResponseData>(rd);

            var itemService  = new ItemService(loggingSessionInfo);
            var bllTrader    = new RetailTraderBLL(loggingSessionInfo);
            var entityTrader = bllTrader.GetByID(rp.Parameters.RetailTraderId);

            entityTrader.SalesType = "Sales";
            bllTrader.Update(entityTrader, null, false);


            bll.DeleteData(rp.Parameters.RetailTraderId);
            if (rp.Parameters.ItemList.Count() > 0)
            {
                foreach (var item in rp.Parameters.ItemList)
                {
                    RetailTraderItemMappingEntity entityRTIM = new RetailTraderItemMappingEntity();
                    entityRTIM.ItemId         = item.ItemId;
                    entityRTIM.RetailTraderId = rp.Parameters.RetailTraderId;
                    entityRTIM.CustomerID     = rp.CustomerID;
                    bll.Create(entityRTIM);
                    itemService.CreateTraderQRCode(rp.CustomerID, item.ItemId, item.ItemName, rp.Parameters.RetailTraderId, entityRTIM.MappingId.ToString());
                }
            }
            return(rsp.ToJSON());
        }
Ejemplo n.º 5
0
        private string DownEnrollTpl(string pRequest)
        {
            var rp = pRequest.DeserializeJSONTo <APIRequest <JIT.CPOS.BS.BLL.LEventSignUpBLL.DownEnrollTplRP> >();

            rp.Parameters.Validate();

            var       rd        = new EmptyRD(); // new JIT.CPOS.BS.BLL.LEventSignUpBLL.DownEnrollTplRD();
            DataTable dataTable = PrivateLEventSignUpBLL.DownEnrollTpl(rp.Parameters.EventID, rp.Parameters.Status);

            //数据获取
            Workbook wb       = DataTableExporter.WriteXLS(dataTable, 0);
            string   savePath = HttpContext.Current.Server.MapPath(@"~/File/Excel");

            if (!System.IO.Directory.Exists(savePath))
            {
                System.IO.Directory.CreateDirectory(savePath);
            }
            savePath = savePath + "\\报名人员模板-" + dataTable.TableName + ".xls";
            wb.Save(savePath);//保存Excel文件
            new ExcelCommon().OutPutExcel(HttpContext.Current, savePath);
            HttpContext.Current.Response.End();

            var rsp = new SuccessResponse <IAPIResponseData>(rd);

            if (dataTable == null || !(dataTable.Columns.Count > 0))
            {
                rsp.ResultCode = 201;
                rsp.Message    = "生成失败!";
            }

            return(rsp.ToJSON());
        }
Ejemplo n.º 6
0
        public string SaveAgentCustomer(string pRequest)
        {
            var rp = pRequest.DeserializeJSONTo <APIRequest <SaveAgentCustomerRP> >();
            LoggingSessionInfo loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID);


            if (rp.Parameters.AgentCustomerInfo == null)
            {
                throw new APIException("缺少参数【AgentCustomerInfo】或参数值为空")
                      {
                          ErrorCode = 135
                      };
            }

            if (string.IsNullOrEmpty(rp.Parameters.AgentCustomerInfo.AgentName))
            {
                throw new APIException("缺少参数【AgentName】或参数值为空")
                      {
                          ErrorCode = 135
                      };
            }


            AgentCustomerBLL _AgentCustomerBLL = new AgentCustomerBLL(loggingSessionInfo);


            var AgentCustomerInfo = rp.Parameters.AgentCustomerInfo;

            if (string.IsNullOrEmpty(AgentCustomerInfo.FromSource))//如果没有标识来源,则默认为微信
            {
                AgentCustomerInfo.FromSource = "WeiXin";
            }

            //如果该标签的id为空//创建一条记录
            if (string.IsNullOrEmpty(AgentCustomerInfo.AgentID))
            {
                //TagsEntity en = new TagsEntity();
                AgentCustomerInfo.AgentID        = Guid.NewGuid().ToString();
                AgentCustomerInfo.CreateTime     = DateTime.Now;
                AgentCustomerInfo.CreateBy       = rp.UserID;
                AgentCustomerInfo.LastUpdateTime = DateTime.Now;
                AgentCustomerInfo.LastUpdateBy   = rp.UserID;
                AgentCustomerInfo.IsDelete       = 0;
                AgentCustomerInfo.CustomerID     = rp.CustomerID;
                _AgentCustomerBLL.Create(AgentCustomerInfo);
            }
            else
            {
                AgentCustomerInfo.LastUpdateTime = DateTime.Now;
                AgentCustomerInfo.LastUpdateBy   = rp.UserID;
                AgentCustomerInfo.IsDelete       = 0;
                AgentCustomerInfo.CustomerID     = rp.CustomerID;
                _AgentCustomerBLL.Update(AgentCustomerInfo, null, false);
            }
            var rd  = new EmptyRD();//返回值
            var rsp = new SuccessResponse <IAPIResponseData>(rd);

            return(rsp.ToJSON());
        }
Ejemplo n.º 7
0
        public EmptyRD GenerateCoupon(GenerateCouponRP generateCouponRP)
        {
            EmptyRD rd      = new EmptyRD();
            string  endTime = generateCouponRP.EndTime != null?Convert.ToDateTime(generateCouponRP.EndTime).ToShortDateString() + " 23:59:59" : null;

            string result = this._currentDAO.GenerateCoupon(generateCouponRP.CouponTypeID, generateCouponRP.CouponName, generateCouponRP.BeginTime, endTime, generateCouponRP.Description, generateCouponRP.Qty);

            return(rd);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 用户接受协议成为分经销商
        /// </summary>
        /// <param name="pRequest"></param>
        /// <returns></returns>
        public string SetPreRetailTraderToNomal(string pRequest)
        {
            var rp = pRequest.DeserializeJSONTo <APIRequest <RetailTraderRP> >();

            if (string.IsNullOrEmpty(rp.UserID))
            {
                throw new APIException("缺少参数【UserID】或参数值为空")
                      {
                          ErrorCode = 135
                      };
            }
            var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, "1");
            var RetailTraderBLL    = new RetailTraderBLL(loggingSessionInfo);
            var VipBLL             = new VipBLL(loggingSessionInfo);

            var Data = RetailTraderBLL.GetByID(rp.UserID);

            if (Data == null)
            {
                throw new APIException("参数【rp.Parameters.RetailTraderID】错误找不到对应经销商")
                      {
                          ErrorCode = 136
                      };
            }
            var vipData = VipBLL.GetByID(Data.MultiLevelSalerFromVipId);

            if (vipData != null)
            {
                if (!string.IsNullOrWhiteSpace(vipData.SetoffUserId))//经销商二维码扫码关注的会员,成为经销商时,自动被集客
                {
                    DataSet ds = RetailTraderBLL.GetMultiLevelBeAddNode(vipData.SetoffUserId);
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        Data.HigheRetailTraderID = ds.Tables[0].Rows[0]["BeAddNode"].ToString();
                        if (ds.Tables[0].Rows[0]["BeAddNodeFlag"] != DBNull.Value)
                        {
                            int Flag = Convert.ToInt32(ds.Tables[0].Rows[0]["BeAddNodeFlag"]);
                            if (Flag == 1)//添加经销商拓展节点记录
                            {
                                var T_HierarchySystemExNodeBLL = new T_HierarchySystemExNodeBLL(loggingSessionInfo);
                                T_HierarchySystemExNodeBLL.AddHierarchySystemExNode(Data.RetailTraderID);
                            }
                        }
                    }
                }
            }
            Data.Status = "1";

            RetailTraderBLL.Update(Data);
            var response = new EmptyRD();
            var rsp      = new SuccessResponse <IAPIResponseData>(response);

            return(rsp.ToJSON());
        }
        public string DeleteEvent(string pRequest)
        {
            var        reqObj             = pRequest.DeserializeJSONTo <APIRequest <EventRP> >();
            var        loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            LEventsBLL bll = new LEventsBLL(loggingSessionInfo);

            bll.DeleteByProc(reqObj.Parameters.EventId);
            var rd  = new EmptyRD();
            var rsp = new SuccessResponse <IAPIResponseData>(rd);

            return(rsp.ToJSON());
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 更改优惠券状态
        /// </summary>
        /// <param name="pRequest"></param>
        /// <returns></returns>
        public string SetCouponStates(string pRequest)
        {
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            var couponBLL          = new CouponBLL(loggingSessionInfo);

            var rd = new EmptyRD();
            var rp = pRequest.DeserializeJSONTo <APIRequest <SetCouponCodeRP> >();
            //rp.Parameters.Validate();
            var rsp = couponBLL.SetCouponStates(rp.Parameters);

            return(rsp.ToJSON());
        }
Ejemplo n.º 11
0
        public EmptyRD DynamicVipFormDelete(DynamicVipFormIDRP dynamicVipFormIDRP)
        {
            var rd = new EmptyRD();

            Guid g = new Guid();

            Guid.TryParse(dynamicVipFormIDRP.FormID, out g);

            Delete(g, null);

            return(rd);
        }
Ejemplo n.º 12
0
        public EmptyRD DynamicVipFormSceneSave(DynamicVipFormSceneSaveRP dynamicVipFormSceneSaveRP)
        {
            var rd = new EmptyRD();

            if (dynamicVipFormSceneSaveRP.SceneList.Length > 0)
            {
                MobileModuleObjectMappingBLL mmomBLL = new MobileModuleObjectMappingBLL(CurrentUserInfo);

                mmomBLL.DynamicVipFormSceneSave(dynamicVipFormSceneSaveRP);
            }

            return(rd);
        }
Ejemplo n.º 13
0
        public string StartOrStopShare(string pRequest)
        {
            var             reqObj             = pRequest.DeserializeJSONTo <APIRequest <EventShareRP> >();
            var             loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            LEventsShareBLL bll = new LEventsShareBLL(loggingSessionInfo);

            bll.UpdateEventShareStatus(reqObj.Parameters.ShareId, reqObj.Parameters.State);

            var rd  = new EmptyRD();
            var rsp = new SuccessResponse <IAPIResponseData>(rd);

            return(rsp.ToJSON());
        }
Ejemplo n.º 14
0
        public EmptyRD DynamicVipFormRename(DynamicVipFormRenameRP rp)
        {
            var rd = new EmptyRD();

            MobileModuleEntity mme = new MobileModuleEntity();

            mme = GetByID(rp.FormID);

            if (mme != null)
            {
                mme.ModuleName = rp.Name;
                Update(mme);
            }

            return(rd);
        }
Ejemplo n.º 15
0
        public string DynamicVipFormSceneSave(string pRequest)
        {
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            var vipBLL             = new VipBLL(loggingSessionInfo);

            var rd = new EmptyRD();
            var rp = pRequest.DeserializeJSONTo <APIRequest <JIT.CPOS.BS.BLL.MobileModuleBLL.DynamicVipFormSceneSaveRP> >();

            rp.Parameters.Validate();

            rd = this.PrivatePublicMobileModuleBLL.DynamicVipFormSceneSave(rp.Parameters);

            var rsp = new SuccessResponse <IAPIResponseData>(rd);

            return(rsp.ToJSON());
        }
Ejemplo n.º 16
0
        /// <summary>
        /// 查询正在使用的动态属性
        /// Add by wen wu 20140928
        /// </summary>
        /// <param name="ptype"></param>
        /// <param name="pRequest"></param>
        /// <returns></returns>
        public string DynamicControlDisplaySave(string ptype, string pRequest)
        {
            var clientBussinessDefinedBLL = new ClientBussinessDefinedBLL(PrivateLoggingSessionInfo);
            var rd = new EmptyRD();
            var rp = pRequest.DeserializeJSONTo <APIRequest <JIT.CPOS.BS.BLL.ClientBussinessDefinedBLL.DynamicControlDisplayListRP> >();

            rp.Parameters.Validate();
            string result = clientBussinessDefinedBLL.DynamicControlDisplaySave(rp.Parameters);
            var    rsp    = new SuccessResponse <IAPIResponseData>(rd);

            if (result != "1")
            {
                rsp.Message    = "保存属性失败.";
                rsp.ResultCode = 201;
            }
            return(rsp.ToJSON());
        }
Ejemplo n.º 17
0
        public string GenerateCoupon(string pRequest)
        {
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;

            var rp = pRequest.DeserializeJSONTo <APIRequest <GenerateCouponRP> >();

            rp.Parameters.Validate();

            var rd        = new EmptyRD();
            var couponBLL = new CouponBLL(loggingSessionInfo);

            rd = couponBLL.GenerateCoupon(rp.Parameters);

            var rsp = new SuccessResponse <IAPIResponseData>(rd);

            return(rsp.ToJSON());
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 添加活动分享
        /// </summary>
        /// <param name="pRequest"></param>
        /// <returns></returns>
        public string AddEventShare(string pRequest)
        {
            var                       rd = new EmptyRD();
            var                       rp = pRequest.DeserializeJSONTo <APIRequest <EventShareRP> >();
            var                       loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            LEventsShareBLL           bllShare           = new LEventsShareBLL(loggingSessionInfo);
            PrizeCouponTypeMappingBLL bllPrize           = new PrizeCouponTypeMappingBLL(loggingSessionInfo);

            if (bllShare.HasShare(rp.Parameters.EventId) > 0)
            {
                var errRsp = new ErrorResponse();
                errRsp.Message = "该活动已设置了分享";
                return(errRsp.ToJSON());
            }
            var entityShare = new LEventsShareEntity();


            string strGuid = Guid.NewGuid().ToString();

            entityShare.ShareId = strGuid;
            entityShare.EventId = rp.Parameters.EventId;
            //entityShare.PrizeTypeID = rp.Parameters.PrizeTypeID;
            //entityShare.TotalCount = rp.Parameters.TotalCount;
            entityShare.IsDelete   = 0;
            entityShare.State      = 1;
            entityShare.ShareTimes = rp.Parameters.ShareTimes;

            bllShare.Create(entityShare);

            var entityPrize = new LPrizesEntity();

            entityPrize.EventId      = strGuid;
            entityPrize.PrizeName    = rp.Parameters.PrizeName;
            entityPrize.PrizeTypeId  = rp.Parameters.PrizeTypeID;
            entityPrize.Point        = rp.Parameters.Point;
            entityPrize.CouponTypeID = rp.Parameters.CouponTypeID;
            entityPrize.CountTotal   = rp.Parameters.TotalCount;
            entityPrize.CreateBy     = loggingSessionInfo.UserID;
            bllShare.SaveSharePrize(entityPrize);

            var rsp = new SuccessResponse <IAPIResponseData>(rd);

            return(rsp.ToJSON());
        }
Ejemplo n.º 19
0
        public string SaveTypeList(string pRequest)
        {
            var rp = pRequest.DeserializeJSONTo <APIRequest <SaveTypeRP> >();
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;


            var service    = new T_TypeBLL(loggingSessionInfo);
            var LevelCount = rp.Parameters.LevelCount;

            if (LevelCount == 0)
            {
                throw new APIException("缺少参数【LevelCount】或参数值为空")
                      {
                          ErrorCode = 135
                      };
            }

            foreach (T_TypeEntity en in rp.Parameters.typeList)
            {
                if (!string.IsNullOrEmpty(en.type_name))
                {
                    en.type_id          = Utils.NewGuid();
                    en.type_code        = en.type_name;
                    en.type_name        = en.type_name;
                    en.type_name_en     = en.type_name;
                    en.type_domain      = "UnitType";
                    en.type_system_flag = 0;//是否系统标识
                    en.status           = 1;
                    en.type_Level       = en.type_Level;
                    en.customer_id      = loggingSessionInfo.ClientID;
                    service.Create(en);
                }
            }
            //更新门店type的等级和角色类型的等级
            service.UpdateShop(LevelCount, loggingSessionInfo.ClientID);

            var rd = new EmptyRD();//返回值

            var rsp = new SuccessResponse <IAPIResponseData>(rd);

            return(rsp.ToJSON());
        }
Ejemplo n.º 20
0
        public string AppendEventShare(string pRequest)
        {
            var                       rp = pRequest.DeserializeJSONTo <APIRequest <AppendShareRP> >();
            var                       loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            LEventsShareBLL           bllShare           = new LEventsShareBLL(loggingSessionInfo);
            PrizeCouponTypeMappingBLL bllPrize           = new PrizeCouponTypeMappingBLL(loggingSessionInfo);

            var entityPrize = new LPrizesEntity();

            entityPrize.PrizesID     = rp.Parameters.PrizesId;
            entityPrize.EventId      = rp.Parameters.ShareId;
            entityPrize.CountTotal   = rp.Parameters.AppendQty;
            entityPrize.LastUpdateBy = loggingSessionInfo.UserID;

            bllShare.AppendSharePrize(entityPrize);

            var rd  = new EmptyRD();
            var rsp = new SuccessResponse <IAPIResponseData>(rd);

            return(rsp.ToJSON());
        }
Ejemplo n.º 21
0
        public string DynamicVipFormSave(string pRequest)
        {
            var rp = pRequest.DeserializeJSONTo <APIRequest <JIT.CPOS.BS.BLL.MobileModuleBLL.DynamicVipFormSaveRP> >();

            rp.Parameters.Validate();

            var rd  = new EmptyRD();
            var rsp = new SuccessResponse <IAPIResponseData>(rd);

            int result = this.PrivatePublicMobileModuleBLL.DynamicVipFormSave(rp.Parameters);

            if (result >= 0)
            {
                rsp.ResultCode = 0;
                rsp.Message    = result.ToString();
            }
            else
            {
                rsp.ResultCode = 202;
                rsp.Message    = "更新失败!";
            }
            return(rsp.ToJSON());
        }
Ejemplo n.º 22
0
        public object BindCoupon(BindCouponRP bindCouponRP)
        {
            var           rd = new EmptyRD();
            ErrorResponse er = new ErrorResponse();
            SuccessResponse <IAPIResponseData> sr = new SuccessResponse <IAPIResponseData>();

            //If coupon exists
            var coupon = _currentDAO.Query(
                new IWhereCondition[] {
                new EqualsCondition()
                {
                    FieldName = "CouponCode", Value = bindCouponRP.CouponCode
                }
                , new EqualsCondition()
                {
                    FieldName = "CustomerID", Value = CurrentUserInfo.ClientID
                }
                , new EqualsCondition()
                {
                    FieldName = "Status", Value = "0"
                }
                , new EqualsCondition()
                {
                    FieldName = "IsDelete", Value = "0"
                }
            }, null);

            if (coupon.Length == 0)
            {
                er.Message = "该优惠券编号不存在或已被使用!";
            }
            else
            {
                //if coupon bound
                VipCouponMappingBLL vipCouponMappingBLL = new VipCouponMappingBLL(CurrentUserInfo);
                var mapping = vipCouponMappingBLL.Query(
                    new IWhereCondition[] {
                    new EqualsCondition()
                    {
                        FieldName = "CouponID", Value = coupon[0].CouponID
                    }
                    , new EqualsCondition()
                    {
                        FieldName = "IsDelete", Value = "0"
                    }
                }, null);

                if (mapping.Length > 0)
                {
                    er.Message = "该优惠券已分发!";
                }
                else
                {
                    //bind coupon
                    vipCouponMappingBLL.Create(
                        new VipCouponMappingEntity()
                    {
                        VipCouponMapping = Guid.NewGuid().ToString(),
                        VIPID            = bindCouponRP.VipID,
                        CouponID         = coupon[0].CouponID,
                        IsDelete         = 0,
                        CreateBy         = CurrentUserInfo.UserID,
                        CreateTime       = DateTime.Now
                    });

                    sr.Message = "分发成功!";
                }
            }

            object result;

            if (!string.IsNullOrEmpty(er.Message))
            {
                result = er;
            }
            else
            {
                result = sr;
            }

            return(result);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// 上传图片通用方法
        /// </summary>
        /// <param name="pRequest"></param>
        /// <returns></returns>
        protected string UploadFiles(string pRequest)
        {
            var rp = pRequest.DeserializeJSONTo <APIRequest <UploadFilesRP> >();

            rp.Parameters.Validate();

            var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID);


            var rd = new EmptyRD();

            var objectImageBll = new ObjectImagesBLL(loggingSessionInfo);   //图片BLL实例化

            var    customerBasicSettingBll = new CustomerBasicSettingBLL(loggingSessionInfo);
            string expandName = rp.Parameters.ExpandName;

            //随机生成文件名称
            string fileName = StringUtil.GetRandomStr(18).ToLower() + "." + expandName;

            //允许上传的扩展名
            string allowExpandName = customerBasicSettingBll.GetSettingValueByCode("AllowUploadExpandName");

            allowExpandName = !string.IsNullOrEmpty(allowExpandName) ? allowExpandName : "gif,jpg,jpeg,png,bmp";//设置缺省图片格式
            //不允许
            if (allowExpandName.IndexOf(expandName) == -1)
            {
                var rsp = new SuccessResponse <IAPIResponseData>(rd);
                rsp.ResultCode = 1;
                rsp.Message    = "请上传" + allowExpandName + "格式的文件";
                return(rsp.ToJSON());
            }
            //转base64的编码,获取流
            MemoryStream stream = new MemoryStream(Convert.FromBase64String(rp.Parameters.Base64str));

            byte[] bytes = new byte[stream.Length];
            stream.Read(bytes, 0, bytes.Length);
            stream.Seek(0, SeekOrigin.Begin);

            if (allowExpandName.IndexOf(expandName) > -1)
            {
                //允许上传的图片最大限制
                string uploadImageMax = customerBasicSettingBll.GetSettingValueByCode("UploadImageMax");
                if (!string.IsNullOrEmpty(uploadImageMax))
                {
                    int maxSize = int.Parse(uploadImageMax);
                    if (stream.Length > maxSize)
                    {
                        var rsp = new SuccessResponse <IAPIResponseData>(rd);
                        rsp.ResultCode = 1;
                        rsp.Message    = "请上传" + maxSize + "M以内的图片";
                        return(rsp.ToJSON());
                    }
                }
            }
            //文件目录
            string uploadFilePath = customerBasicSettingBll.GetSettingValueByCode("UploadFilePath");

            uploadFilePath = string.IsNullOrEmpty(uploadFilePath)? "/Images/":uploadFilePath;//如果为空,就取默认的

            uploadFilePath += DateTime.Now.Year + "/" + DateTime.Now.Month + "." + DateTime.Now.Day + "/";
            if (!IOUtil.ExistsFile(IOUtil.MapPath(uploadFilePath)))
            {
                IOUtil.CreateDirectoryIfNotExists(IOUtil.MapPath(uploadFilePath));
            }

            // 把 byte[] 写入文件
            FileStream   fs = new FileStream(IOUtil.MapPath(uploadFilePath) + fileName, FileMode.Create);//通过IOUtil.MapPath由网络目录转换成物理目录
            BinaryWriter bw = new BinaryWriter(fs);

            bw.Write(bytes);
            bw.Close();
            fs.Close();

            objectImageBll.Create(new ObjectImagesEntity()
            {
                ImageId = Guid.NewGuid().ToString(), ObjectId = rp.Parameters.ObjectID, ImageURL = uploadFilePath + fileName
            });

            //文件DNS地址
            string fileDNS = customerBasicSettingBll.GetSettingValueByCode("FileDNS");;

            var rsp1 = new SuccessResponse <IAPIResponseData>(rd);

            rsp1.Message = fileDNS + uploadFilePath + fileName;//当前上传的图片路径
            return(rsp1.ToJSON());
        }
Ejemplo n.º 24
0
        public SuccessResponse <IAPIResponseData> VipConsume(APIRequest <VipConsumeRP> rp)
        {
            var cardDepositBLL            = new CardDepositBLL(CurrentUserInfo);
            var registerValidationCodeBLL = new RegisterValidationCodeBLL(CurrentUserInfo);
            var vipBLL = new VipBLL(CurrentUserInfo);
            var rd     = new EmptyRD();
            var rsp    = new SuccessResponse <IAPIResponseData>(rd);

            string phone = "";

            var vip = vipBLL.Query(new IWhereCondition[] { new EqualsCondition()
                                                           {
                                                               FieldName = "VipID", Value = rp.Parameters.VipID
                                                           } }, null);

            if (vip.Length > 0)
            {
                phone = vip[0].Phone;

                if (string.IsNullOrEmpty(phone))
                {
                    rsp.ResultCode = 202;
                    rsp.Message    = "会员未注册手机号!";
                }
                else if (string.IsNullOrEmpty(rp.Parameters.SMSCode))
                {
                    //发送验证码
                    registerValidationCodeBLL.SendCode(phone);
                }
                else
                {
                    //验证验证码
                    var codeEntity = registerValidationCodeBLL.Query(new IWhereCondition[] {
                        new EqualsCondition()
                        {
                            FieldName = "Mobile", Value = phone
                        }
                        , new EqualsCondition()
                        {
                            FieldName = "Code", Value = rp.Parameters.SMSCode
                        }
                        , new EqualsCondition()
                        {
                            FieldName = "IsValidated", Value = 0
                        }
                        , new EqualsCondition()
                        {
                            FieldName = "IsDelete", Value = 0
                        }
                    }, new OrderBy[] {
                        new OrderBy()
                        {
                            FieldName = "CreateTime", Direction = OrderByDirections.Desc
                        }
                    });

                    if (codeEntity != null && codeEntity.Length > 0)
                    {
                        System.Data.SqlClient.SqlTransaction tran = GetTran();
                        using (tran.Connection)
                        {
                            registerValidationCodeBLL.DeleteByMobile(phone, 1, tran);

                            string       errorMessage = "";
                            VipAmountBLL vipAmountBLL = new VipAmountBLL(CurrentUserInfo);
                            vipAmountBLL.SetVipAmountChange(CurrentUserInfo.ClientID, 5, rp.Parameters.VipID, rp.Parameters.Amount, CurrentUserInfo.CurrentUserRole.UnitId, "Prepaid card consumption" + "~" + (rp.Parameters.DocumentCode ?? ""), "Out", out errorMessage, tran);

                            tran.Commit();
                        }
                    }
                    else
                    {
                        rsp.ResultCode = 203;
                        rsp.Message    = "请先获取验证码!";
                    }
                }
            }
            else
            {
                rsp.ResultCode = 201;
                rsp.Message    = "会员不存在!";
            }

            return(rsp);
        }