예제 #1
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());
        }
예제 #2
0
        //修改分销商密码
        private string RetailSetPassWord(string pRequest)
        {
            var rp = pRequest.DeserializeJSONTo <APIRequest <RetailSetPassWordRP> >();
            var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID);

            string pNewPass = MD5Helper.Encryption(rp.Parameters.pNewPWD);

            //pOldPWD = MD5Helper.Encryption(pOldPWD);
            rp.Parameters.pOldPWD = EncryptManager.Hash(rp.Parameters.pOldPWD, HashProviderType.MD5);

            //组装参数
            var rd         = new RetailSetPassWordRD();
            var rsp        = new SuccessResponse <IAPIResponseData>(rd);
            var serviceBll = new RetailTraderBLL(loggingSessionInfo);
            var entity     = serviceBll.GetByID(rp.Parameters.pID);//获取分销商实体

            //if (pOldPWD == entity.User_Password)
            if (rp.Parameters.pOldPWD == entity.RetailTraderPass)
            {
                entity.RetailTraderPass = pNewPass;
                entity.LastUpdateBy     = "1";
                entity.LastUpdateTime   = DateTime.Now;
                //new cUserService(CurrentUserInfo).SetUserInfo(entity, entity.userRoleInfoList, out error);
                serviceBll.Update(entity);
                rsp.Message = "";
            }
            else
            {
                rsp.ResultCode = 135;
                rsp.Message    = "旧密码不正确";
            }
            return(rsp.ToJSON());
        }
예제 #3
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());
        }
예제 #4
0
        public string DownloadQRCode(string pRequest)
        {
            //try
            //{
            var rd  = new RetailTraderItemQRCodeRD();
            var rsp = new SuccessResponse <IAPIResponseData>(rd);

            string path = "";
            var    rp   = pRequest.DeserializeJSONTo <APIRequest <RetailTraderItemQRCode> >();

            if (string.IsNullOrEmpty(rp.Parameters.RetailTraderId))
            {
                throw new APIException("请输入RetailTraderId参数")
                      {
                          ErrorCode = 000
                      }
            }
            ;
            var         loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            var         bll                = new RetailTraderBLL(loggingSessionInfo);
            HttpContext context            = System.Web.HttpContext.Current;
            var         entityRetailTrader = bll.GetByID(rp.Parameters.RetailTraderId);
            DataSet     ds = bll.RetailTraderItemQRCode(rp.Parameters.RetailTraderId);

            try
            {
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    List <GetRetailTraderItemQRCode> list = DataTableToObject.ConvertToList <GetRetailTraderItemQRCode>(ds.Tables[0]).ToList();
                    path = CreateZipAndResponse(list, context.Response, entityRetailTrader.RetailTraderName);
                    if (!string.IsNullOrEmpty(path))
                    {
                        rd.FilePath = path;
                    }
                }
                else
                {
                    throw new Exception("未绑定商品!");
                    //context.Response.Write("<script languge='javascript'>alert('No Data'); window.location.href='index.aspx'</script>");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }


            return(rsp.ToJSON());
        }
예제 #5
0
        /// <summary>
        /// 核销优惠劵
        /// </summary>
        /// <param name="pRequest"></param>
        /// <returns></returns>
        private string BestowCoupon(string pRequest)
        {
            RespData respData = new RespData();

            try
            {
                var reqObj = pRequest.DeserializeJSONTo <reqConunbondata>();
                if (string.IsNullOrEmpty(reqObj.userId))
                {
                    respData.ResultCode = "103";
                    respData.Message    = "登陆用户不能为空";
                }
                if (string.IsNullOrEmpty(reqObj.Parameters.doorID))
                {
                    respData.ResultCode = "103";
                    respData.Message    = "此APP版本无法核销,请升级到新版本。";
                    return(respData.ToJSON());
                }
                var loggingSessionInfo = Default.GetBSLoggingSession(reqObj.customerId, reqObj.userId);
                var couponUseBll       = new CouponUseBLL(loggingSessionInfo);             //优惠券使用BLL实例化
                var vcmBll             = new VipCouponMappingBLL(loggingSessionInfo);      //优惠券BLL实例化
                var couponTypeBll      = new CouponTypeBLL(loggingSessionInfo);            //优惠券类型
                var mappingBll         = new CouponTypeUnitMappingBLL(loggingSessionInfo); //优惠券和门店映射
                //var vcmEntity = new VipCouponMappingEntity();
                CouponBLL bll = new CouponBLL(loggingSessionInfo);



                //判断是否有权限核销优惠券
                CouponEntity couponEntity = null;
                if (!string.IsNullOrEmpty(reqObj.Parameters.couponCode))
                {
                    CouponEntity[] couponEntityArray = bll.QueryByEntity(new CouponEntity()
                    {
                        CouponCode = reqObj.Parameters.couponCode, CustomerID = reqObj.customerId
                    }, null);
                    if (couponEntityArray.Length != 0)
                    {
                        couponEntity = couponEntityArray[0];
                    }
                }
                else
                {
                    couponEntity = bll.GetByID(reqObj.Parameters.cuponID);
                }


                if (couponEntity != null)
                {
                    List <IWhereCondition> wheresOrderNo = new List <IWhereCondition>();
                    wheresOrderNo.Add(new EqualsCondition()
                    {
                        FieldName = "CouponID", Value = couponEntity.CouponID
                    });
                    var resultCouponVipID = vcmBll.Query(wheresOrderNo.ToArray(), null);

                    var couponTypeInfo = couponTypeBll.GetByID(couponEntity.CouponTypeID);
                    if (couponTypeInfo != null)
                    {
                        if (couponTypeInfo.SuitableForStore == 2)//下面的doorid传的是门店的id,如果等于1所有门店都能用,如果等于3所有分销商都能用
                        {
                            var couponTypeUnitMapping = mappingBll.QueryByEntity(new CouponTypeUnitMappingEntity()
                            {
                                CouponTypeID = new Guid(couponEntity.CouponTypeID.ToString()), ObjectID = reqObj.Parameters.doorID
                            }, null).FirstOrDefault();

                            if (couponTypeUnitMapping == null)
                            {
                                respData.ResultCode = "104";
                                respData.Message    = "请到指定门店/分销商使用";
                                return(respData.ToJSON());
                            }
                        }
                        if (couponTypeInfo.SuitableForStore == 3)//下面的doorid传的是门店的id,如果等于1所有门店都能用,如果等于3所有分销商都能用
                        {
                            //doorid必须是获取,分销商如果没数据,就报错。
                            RetailTraderBLL    _RetailTraderBLL = new RetailTraderBLL(loggingSessionInfo);
                            RetailTraderEntity en = _RetailTraderBLL.GetByID(reqObj.Parameters.doorID);
                            if (en == null)
                            {
                                respData.ResultCode = "104";
                                respData.Message    = "请到指定分销商使用";
                                return(respData.ToJSON());
                            }
                        }
                        if (couponTypeInfo.SuitableForStore == 1)//下面的doorid传的是门店的id,如果等于1所有门店都能用,如果等于3所有分销商都能用
                        {
                            //doorid必须是获取,门店如果没有数据,就报错。
                            TUnitBLL    _TUnitBLL = new TUnitBLL(loggingSessionInfo);
                            TUnitEntity en        = _TUnitBLL.GetByID(reqObj.Parameters.doorID);
                            if (en == null)
                            {
                                respData.ResultCode = "104";
                                respData.Message    = "请到指定门店使用";
                                return(respData.ToJSON());
                            }
                        }

                        int res = bll.BestowCoupon(couponEntity.CouponID, reqObj.Parameters.doorID);
                        if (res > 0) //如果没有影响一行,所以Coupon表里这条记录的status=1了,不能被使用了。
                        {
                            InoutService server = new InoutService(loggingSessionInfo);
                            var          tran   = server.GetTran();
                            using (tran.Connection)//事务
                            {
                                #region 优惠券使用记录
                                var couponUseEntity = new CouponUseEntity()
                                {
                                    CouponID = couponEntity.CouponID,
                                    VipID    = resultCouponVipID.Length == 0 ? "" : resultCouponVipID[0].VIPID,
                                    UnitID   = reqObj.Parameters.doorID,
                                    //OrderID = orderEntity.OrderID.ToString(),
                                    //CreateBy = reqObj.userId,
                                    Comment    = "核销电子券",
                                    CustomerID = reqObj.customerId
                                };
                                couponUseBll.Create(couponUseEntity);//生成优惠券使用记录
                                #endregion

                                //#region 修改优惠券数量   2016-06-03 使用了redis不用在这里更新数量
                                //couponTypeInfo.IsVoucher = couponTypeInfo.IsVoucher == null ? 1 : couponTypeInfo.IsVoucher + 1;
                                //couponTypeBll.Update(couponTypeInfo, tran);
                                //#endregion

                                respData.ResultCode = "200";
                                respData.Message    = "优惠劵使用成功";

                                tran.Commit();
                            }
                        }
                        else
                        {
                            respData.ResultCode = "103";
                            respData.Message    = "优惠劵已使用";
                        }
                    }
                }
                else
                {
                    respData.ResultCode = "104";
                    respData.Message    = "没有找到对应券。";
                    return(respData.ToJSON());
                }
            }
            catch (Exception)
            {
                respData.ResultCode = "103";
                respData.Message    = "数据库操作失败";
            }
            return(respData.ToJSON());
        }