Пример #1
0
        protected override SetRechargeOrderRD ProcessRequest(APIRequest <SetRechargeOrderRP> pRequest)
        {
            SetRechargeOrderRP rp = pRequest.Parameters;
            SetRechargeOrderRD rd = new SetRechargeOrderRD();

            var            rechargeOrderBll     = new RechargeOrderBLL(CurrentUserInfo);
            TUnitExpandBLL serviceUnitExpandBll = new TUnitExpandBLL(CurrentUserInfo);

            var vipBll = new VipBLL(CurrentUserInfo);
            var vipCardVipMappingBll  = new VipCardVipMappingBLL(CurrentUserInfo);
            var vipCardBll            = new VipCardBLL(CurrentUserInfo);
            var sysVipCardTypeBll     = new SysVipCardTypeBLL(CurrentUserInfo);
            var vipCardUpgradeRuleBll = new VipCardUpgradeRuleBLL(CurrentUserInfo);

            //获取会员信息
            VipEntity vipInfo;
            string    userId = "";

            //微信
            if (pRequest.ChannelId == "2")
            {
                vipInfo = vipBll.GetByID(pRequest.UserID);
                UnitService unitServer = new UnitService(CurrentUserInfo);
                rp.UnitId = unitServer.GetUnitByUnitTypeForWX("OnlineShopping", null).Id; //获取在线商城的门店标识
            }
            //掌柜App
            else
            {
                vipInfo = vipBll.GetByID(rp.VipId);
                userId  = pRequest.UserID;
            }

            string  OrderDesc     = "ReRecharge"; //"升级","充值"
            int?    VipCardTypeId = null;         //会员卡类型
            decimal returnAmount  = 0;            //赠送金额

            //会员卡类型条件
            List <IWhereCondition> complexConditionOne = new List <IWhereCondition> {
            };
            //获取会员与会员卡关系表
            var vipCardVipMappingEntity = vipCardVipMappingBll.QueryByEntity(new VipCardVipMappingEntity()
            {
                CustomerID = CurrentUserInfo.ClientID, VIPID = vipInfo.VIPID
            }, null).FirstOrDefault();

            //该会员有会员卡
            if (vipCardVipMappingEntity != null)
            {
                //获取该会员会员卡信息
                var vipCardEntity = vipCardBll.QueryByEntity(new VipCardEntity()
                {
                    CustomerID = CurrentUserInfo.ClientID, VipCardID = vipCardVipMappingEntity.VipCardID
                }, null).FirstOrDefault();

                //获取该会员卡类型
                var sysVipCardTypeEntity = sysVipCardTypeBll.GetByID(vipCardEntity.VipCardTypeID);
                VipCardTypeId = vipCardEntity.VipCardTypeID;

                //获取会员卡的会员活动
                var rechargeStrategyBLL = new RechargeStrategyBLL(CurrentUserInfo);
                var RechargeActivityDS  = rechargeStrategyBLL.GetRechargeActivityList(CurrentUserInfo.ClientID, VipCardTypeId.ToString(), 3);
                var RechargeStrategy    = new RechargeStrategyInfo();

                if (RechargeActivityDS != null && RechargeActivityDS.Tables[0].Rows.Count > 0)
                {
                    var RechargeStrategyList = DataTableToObject.ConvertToList <RechargeStrategyInfo>(RechargeActivityDS.Tables[0]);
                    //获取与充值金额最接近的活动
                    RechargeStrategy = RechargeStrategyList.Where(n => n.RechargeAmount <= rp.ActuallyPaid).OrderByDescending(n => n.RechargeAmount).FirstOrDefault();
                    if (RechargeStrategy != null)
                    {
                        //梯度
                        if (RechargeStrategy.RuleType == "Step")
                        {
                            //赠送金额 = 会员活动梯度设置赠送金额
                            returnAmount = RechargeStrategy.GiftAmount;
                        }
                        //叠加
                        if (RechargeStrategy.RuleType == "Superposition")
                        {
                            //赠送金额与满赠条件金额比例
                            decimal discount = RechargeStrategy.GiftAmount / RechargeStrategy.RechargeAmount;
                            //赠送金额 = 充值金额 * (设置赠送金额 / 设置满赠条件金额)
                            returnAmount = rp.ActuallyPaid * RechargeStrategy.GiftAmount / RechargeStrategy.RechargeAmount;
                        }
                    }
                }

                //获取等级高的会员卡类型条件
                complexConditionOne.Add(new MoreThanCondition()
                {
                    FieldName = "VipCardLevel", Value = sysVipCardTypeEntity.VipCardLevel, IncludeEquals = false
                });
                complexConditionOne.Add(new EqualsCondition()
                {
                    FieldName = "CustomerID", Value = CurrentUserInfo.ClientID
                });
            }
            //该会员没有会员卡
            else
            {
                //获取所有的会员卡类型条件
                complexConditionOne.Add(new EqualsCondition()
                {
                    FieldName = "CustomerID", Value = CurrentUserInfo.ClientID
                });
            }

            var sysVipCardTypeList = sysVipCardTypeBll.Query(complexConditionOne.ToArray(), null).ToList();

            if (sysVipCardTypeList == null)
            {
                throw new APIException("没有建立会员体系")
                      {
                          ErrorCode = 200
                      };
            }

            //获取会员卡类型升级规则
            List <IWhereCondition> complexConditionTwo = new List <IWhereCondition> {
            };

            complexConditionTwo.Add(new EqualsCondition()
            {
                FieldName = "CustomerID", Value = CurrentUserInfo.ClientID
            });
            complexConditionTwo.Add(new EqualsCondition()
            {
                FieldName = "IsRecharge", Value = 1
            });
            var vipCardUpgradeRuleList = vipCardUpgradeRuleBll.Query(complexConditionTwo.ToArray(), null);

            //将升级卡规则和可升级的会员卡匹配
            var vipCardTypeDetailList = vipCardUpgradeRuleList.Join(sysVipCardTypeList, n => n.VipCardTypeID, m => m.VipCardTypeID, (n, m) => new { n, m }).OrderByDescending(t => t.m.VipCardLevel).ToList();

            //判断是否满充值条件
            bool isUpgrade = false;


            for (int i = 0; i < vipCardTypeDetailList.Count; i++)
            {
                //实付金额 >= 可升级金额
                if (vipCardTypeDetailList[i].n.OnceRechargeAmount <= rp.ActuallyPaid)
                {
                    isUpgrade     = true;
                    VipCardTypeId = vipCardTypeDetailList[i].n.VipCardTypeID ?? 0;
                    break;
                }
            }
            if (isUpgrade)
            {
                OrderDesc = "Upgrade";  //升级
            }


            //充值订单
            var rechargeOrderEntity = new RechargeOrderEntity()
            {
                OrderID       = Guid.NewGuid(),
                OrderNo       = serviceUnitExpandBll.GetUnitOrderNo(),
                OrderDesc     = OrderDesc,
                VipID         = vipInfo.VIPID,
                VipCardNo     = vipInfo.VipCode,
                UnitId        = rp.UnitId,
                UserId        = userId,
                TotalAmount   = rp.ActuallyPaid,
                ActuallyPaid  = rp.ActuallyPaid,
                PosSourceName = rp.PosSourceName,
                ReturnAmount  = returnAmount,
                PayerID       = vipInfo.VIPID,
                Status        = 0,
                CustomerID    = CurrentUserInfo.ClientID,
                VipCardTypeId = VipCardTypeId
            };

            rechargeOrderBll.Create(rechargeOrderEntity);
            rd.orderId = rechargeOrderEntity.OrderID.ToString();

            //支付完成
            if (rp.PayStatus == 1)
            {
                //获取门店信息
                t_unitBLL    unitBLL  = new t_unitBLL(CurrentUserInfo);
                t_unitEntity unitInfo = null;
                if (!string.IsNullOrEmpty(rechargeOrderEntity.UnitId))
                {
                    unitInfo = unitBLL.GetByID(rechargeOrderEntity.UnitId);
                }
                //充值
                rechargeOrderBll.Recharge(rechargeOrderEntity, vipInfo, unitInfo, "");
            }

            return(rd);
        }
Пример #2
0
        /// <summary>
        /// 获取订单号码(每次返回10个订单号)
        /// </summary>
        /// <returns></returns>
        public string GetOrderNo()
        {
            var loggingSessionInfo = Default.GetLjLoggingSession();

            //根据客户标识获取连接字符串  qianzhi  2013-07-30
            if (!string.IsNullOrEmpty(Request["CustomerId"]))
            {
                loggingSessionInfo = Default.GetBSLoggingSession(Request["CustomerId"].Trim(), "");
            }

            string content = string.Empty;
            GetResponseParams <GetOrderNoEntity> response = new GetResponseParams <GetOrderNoEntity>();

            response.Code            = "200";
            response.Description     = "操作成功";
            response.Params          = new GetOrderNoEntity();
            response.Params.orderNos = new List <OrderNoEntity>();

            if (string.IsNullOrEmpty(Request["UnitId"]) ||
                string.IsNullOrEmpty(Request["CustomerId"]))
            {
                response.Code        = "201";
                response.Description = "请求的参数不能为空";
                return(string.Format("{{\"Description\":\"{2}\",\"Code\":\"{1}\",\"orderNos\":{0}}}",
                                     response.Params.ToJSON(), response.Code, response.Description));
            }

            try
            {
                string unitId     = Request["UnitId"].ToString().Trim();     //门店标识
                string customerId = Request["CustomerId"].ToString().Trim(); //客户标识

                TUnitExpandBLL service = new TUnitExpandBLL(loggingSessionInfo);
                int            orderNo = service.GetOrderNo(loggingSessionInfo, unitId, 10);

                OrderNoEntity orderEntity = null;
                for (int i = 0; i < 10; i++)
                {
                    orderEntity = new OrderNoEntity();
                    var len = orderNo.ToString().Length;
                    switch (len)
                    {
                    case 1: orderEntity.orderNo = "000" + orderNo; break;

                    case 2: orderEntity.orderNo = "00" + orderNo; break;

                    case 3: orderEntity.orderNo = "0" + orderNo; break;

                    case 4: orderEntity.orderNo = orderNo.ToString(); break;
                    }

                    response.Params.orderNos.Add(orderEntity);

                    orderNo++;
                }
            }
            catch (Exception ex)
            {
                response.Code        = "201";
                response.Description = "操作失败:" + ex.ToString();
            }
            content = string.Format("{{\"Description\":\"{2}\",\"Code\":\"{1}\",\"orderNos\":{0}}}",
                                    response.Params.orderNos.ToJSON(), response.Code, response.Description);
            return(content);
        }
Пример #3
0
        protected override DownloadQRCodeRD ProcessRequest(DTO.Base.APIRequest <DownloadQRCodeRP> pRequest)
        {
            string content    = string.Empty;
            string customerId = string.Empty;
            var    RD         = new DownloadQRCodeRD();

            try
            {
                #region 解析传入参数
                //解析请求字符串
                var RP = pRequest.Parameters;

                //判断客户ID是否传递

                customerId = CurrentUserInfo.CurrentUser.customer_id;


                #endregion
                var    imageUrl = string.Empty;
                Random ro       = new Random();
                var    iUp      = 100000000;
                var    iDown    = 50000000;

                if (string.IsNullOrEmpty(RP.VipDCode.ToString()) || RP.VipDCode == 0)
                {
                    throw new APIException("VipDCode参数不能为空");
                }
                var rpVipDCode = 0;                   //临时二维码
                var iResult    = ro.Next(iDown, iUp); //随机数

                if (RP.VipDCode == 9)                 //永久二维码
                {
                    var userQRCodeBll  = new WQRCodeManagerBLL(CurrentUserInfo);
                    var marketEventBll = new MarketEventBLL(CurrentUserInfo);

                    var marketEventEntity = marketEventBll.QueryByEntity(new MarketEventEntity()
                    {
                        EventCode = "CA00002433", CustomerId = CurrentUserInfo.ClientID
                    }, null).FirstOrDefault();
                    var userQRCode = userQRCodeBll.QueryByEntity(new WQRCodeManagerEntity()
                    {
                        ObjectId = marketEventEntity.MarketEventID, CustomerId = CurrentUserInfo.ClientID
                    }, null);                                                                                                                                                              //

                    if (userQRCode != null && userQRCode.Length > 0)
                    {
                        RD.imageUrl = userQRCode[0].ImageUrl;
                        return(RD);
                    }

                    //获取当前二维码 最大值
                    iResult    = new WQRCodeManagerBLL(CurrentUserInfo).GetMaxWQRCod() + 1;
                    rpVipDCode = 1;                 //永久

                    #region 获取微信帐号
                    //门店关联的公众号
                    var tueBll    = new TUnitExpandBLL(CurrentUserInfo);
                    var tueEntity = new TUnitExpandEntity();
                    if (!string.IsNullOrEmpty(CurrentUserInfo.CurrentUserRole.UnitId))
                    {
                        tueEntity = tueBll.QueryByEntity(new TUnitExpandEntity()
                        {
                            UnitId = CurrentUserInfo.CurrentUserRole.UnitId
                        }, null).FirstOrDefault();
                    }

                    var server = new WApplicationInterfaceBLL(CurrentUserInfo);
                    var wxObj  = new WApplicationInterfaceEntity();
                    if (tueEntity != null && !string.IsNullOrEmpty(tueEntity.Field1))
                    {
                        wxObj = server.QueryByEntity(new WApplicationInterfaceEntity {
                            AppID = tueEntity.Field1, CustomerId = customerId
                        }, null).FirstOrDefault();
                    }
                    else
                    {
                        wxObj = server.QueryByEntity(new WApplicationInterfaceEntity {
                            CustomerId = customerId
                        }, null).FirstOrDefault();
                    }

                    if (wxObj == null)
                    {
                        throw new APIException("没有对应公众号");
                    }
                    else
                    {
                        var commonServer = new CommonBLL();

                        imageUrl = commonServer.GetQrcodeUrl(wxObj.AppID
                                                             , wxObj.AppSecret
                                                             , rpVipDCode.ToString("")    //二维码类型  0: 临时二维码  1:永久二维码
                                                             , iResult, CurrentUserInfo); //iResult作为场景值ID,临时二维码时为32位整型,永久二维码时只支持1--100000
                        if (imageUrl != null && !imageUrl.Equals(""))
                        {
                            CPOS.Common.DownloadImage downloadServer = new DownloadImage();
                            string downloadImageUrl = ConfigurationManager.AppSettings["website_WWW"];
                            imageUrl = downloadServer.DownloadFile(imageUrl, downloadImageUrl);
                            //如果名称不为空,就把图片放在一定的背景下面
                            //if (!string.IsNullOrEmpty(RP.Parameters.RetailTraderName))
                            //{
                            //    string apiDomain = ConfigurationManager.AppSettings["website_url"];

                            //    imageUrl = CombinImage(apiDomain + @"/HeadImage/qrcodeBack.jpg", imageUrl, RP.Parameters.RetailTraderName + "合作二维码");
                            //}
                        }
                    }

                    #endregion

                    if (!string.IsNullOrEmpty(imageUrl))    //永久二维码
                    {
                        #region 创建店员永久二维码匹配表
                        var userQrTypeBll = new WQRCodeTypeBLL(CurrentUserInfo);
                        var userQrType    = userQrTypeBll.QueryByEntity(new WQRCodeTypeEntity()
                        {
                            TypeName = "签到"
                        }, null);                                                                                       //"UserQrCode"
                        if (userQrType != null && userQrType.Length > 0)
                        {
                            var userQrCodeBll = new WQRCodeManagerBLL(CurrentUserInfo);
                            var userQrCode    = new WQRCodeManagerEntity();
                            userQrCode.QRCode        = iResult.ToString();//记录传过去的二维码场景值
                            userQrCode.QRCodeTypeId  = userQrType[0].QRCodeTypeId;
                            userQrCode.IsUse         = 1;
                            userQrCode.CustomerId    = CurrentUserInfo.CurrentUser.customer_id;
                            userQrCode.ImageUrl      = imageUrl;
                            userQrCode.ApplicationId = wxObj.ApplicationId;
                            //objectId 为店员ID
                            userQrCode.ObjectId = marketEventEntity.MarketEventID;
                            userQrCodeBll.Create(userQrCode);
                        }
                        #endregion
                    }
                }

                RD.imageUrl = imageUrl;
            }
            catch
            {
                throw new APIException("生成二维码错误");
            }
            return(RD);
        }
        protected override SetReceiveAmountOrderRD ProcessRequest(APIRequest <SetReceiveAmountOrderRP> pRequest)
        {
            SetReceiveAmountOrderRP rp = pRequest.Parameters;
            SetReceiveAmountOrderRD rd = new SetReceiveAmountOrderRD();

            var receiveAmountOrderBll = new ReceiveAmountOrderBLL(CurrentUserInfo);
            var sysVipCardGradeBLL    = new SysVipCardGradeBLL(CurrentUserInfo); //获取折扣表
            var vipBLL  = new VipBLL(CurrentUserInfo);
            var unitBLL = new t_unitBLL(CurrentUserInfo);
            var vipInfo = vipBLL.GetByID(pRequest.UserID); //获取会员信息

            if (vipInfo == null)
            {
                throw new APIException("没有会员信息")
                      {
                          ErrorCode = 101
                      };
            }
            var unitInfo = unitBLL.GetByID(rp.UnitId);

            if (unitInfo == null)
            {
                throw new APIException("没有服务门店信息")
                      {
                          ErrorCode = 101
                      };
            }
            decimal discountAmount = 0;               //抵扣金额汇总
            decimal couponAmount   = 0;               //优惠券抵用金额
            decimal endAmount      = rp.VipEndAmount; //余额
            decimal integralAmount = rp.Integral;
            //获取订单号
            TUnitExpandBLL serviceUnitExpand = new TUnitExpandBLL(CurrentUserInfo);
            string         orderNo           = serviceUnitExpand.GetUnitOrderNo();
            //折扣
            decimal discount = 1;

            if (rp.VipDiscount > 0)
            {
                discount = sysVipCardGradeBLL.GetVipDiscount() / 10;//会员折扣
            }
            decimal tempAmount = Math.Round((discount == 0 ? 1 : discount) * rp.TotalAmount, 2, MidpointRounding.AwayFromZero);
            Guid    orderId    = Guid.NewGuid();

            //积分处理
            if (rp.IntegralFlag == 1)
            {
                //加入折扣金额
                discountAmount = discountAmount + rp.IntegralAmount;
            }
            else
            {
                integralAmount = 0;
            }

            //使用优惠券
            if (rp.CouponFlag == 1)
            {
                #region 判断优惠券是否是该会员的

                var vipcouponMappingBll = new VipCouponMappingBLL(CurrentUserInfo);

                var vipcouponmappingList = vipcouponMappingBll.QueryByEntity(new VipCouponMappingEntity()
                {
                    VIPID    = vipInfo.VIPID,
                    CouponID = rp.CouponId
                }, null);

                if (vipcouponmappingList == null || vipcouponmappingList.Length == 0)
                {
                    throw new APIException("此张优惠券不是该会员的")
                          {
                              ErrorCode = 103
                          };
                }

                #endregion

                #region 判断优惠券是否有效

                var couponBll = new CouponBLL(CurrentUserInfo);

                var couponEntity = couponBll.GetByID(rp.CouponId);

                if (couponEntity == null)
                {
                    throw new APIException("无效的优惠券")
                          {
                              ErrorCode = 103
                          };
                }

                if (couponEntity.Status == 1)
                {
                    throw new APIException("优惠券已使用")
                          {
                              ErrorCode = 103
                          };
                }

                if (couponEntity.EndDate < DateTime.Now)
                {
                    throw new APIException("优惠券已过期")
                          {
                              ErrorCode = 103
                          };
                }
                var couponTypeBll    = new CouponTypeBLL(CurrentUserInfo);
                var couponTypeEntity = couponTypeBll.GetByID(couponEntity.CouponTypeID);

                if (couponTypeEntity == null)
                {
                    throw new APIException("无效的优惠券类型")
                          {
                              ErrorCode = 103
                          };
                }

                #endregion

                discountAmount = discountAmount + couponTypeEntity.ParValue ?? 0;
                couponAmount   = couponTypeEntity.ParValue ?? 0;

                //更新使用记录
                var couponUseBll    = new CouponUseBLL(CurrentUserInfo);
                var couponUseEntity = new CouponUseEntity()
                {
                    CouponUseID    = Guid.NewGuid(),
                    CouponID       = rp.CouponId,
                    VipID          = vipInfo.VIPID,
                    UnitID         = rp.UnitId,
                    OrderID        = orderId.ToString(),
                    Comment        = "商城使用电子券",
                    CustomerID     = CurrentUserInfo.ClientID,
                    CreateBy       = CurrentUserInfo.UserID,
                    CreateTime     = DateTime.Now,
                    LastUpdateBy   = CurrentUserInfo.UserID,
                    LastUpdateTime = DateTime.Now,
                    IsDelete       = 0
                };
                couponUseBll.Create(couponUseEntity);

                //更新CouponType数量
                var conponTypeBll    = new CouponTypeBLL(CurrentUserInfo);
                var conponTypeEntity = conponTypeBll.QueryByEntity(new CouponTypeEntity()
                {
                    CouponTypeID = new Guid(couponEntity.CouponTypeID), CustomerId = CurrentUserInfo.ClientID
                }, null).FirstOrDefault();
                conponTypeEntity.IsVoucher += 1;
                conponTypeBll.Update(conponTypeEntity);

                //停用该优惠券
                couponEntity.Status = 1;
                couponBll.Update(couponEntity);
            }

            //使用余额
            if (rp.VipEndAmountFlag == 1)
            {
                var vipAmountBll       = new VipAmountBLL(CurrentUserInfo);
                var vipAmountDetailBll = new VipAmountDetailBLL(CurrentUserInfo);

                var vipAmountEntity = vipAmountBll.QueryByEntity(new VipAmountEntity()
                {
                    VipId = vipInfo.VIPID, VipCardCode = vipInfo.VipCode
                }, null).FirstOrDefault();
                if (vipAmountEntity != null)
                {
                    //判断该会员账户是否被冻结
                    if (vipAmountEntity.IsLocking == 1)
                    {
                        throw new APIException("账户已被冻结,请先解冻")
                              {
                                  ErrorCode = 103
                              }
                    }
                    ;

                    //判断该会员的账户余额是否大于本次使用的余额
                    if (vipAmountEntity.EndAmount < rp.VipEndAmount)
                    {
                        throw new APIException(string.Format("账户余额不足,当前余额为【{0}】", vipAmountEntity.EndAmount))
                              {
                                  ErrorCode = 103
                              }
                    }
                    ;

                    //所剩余额大于商品价格,扣除余额的数量为商品价格
                    if (tempAmount < rp.VipEndAmount)
                    {
                        rp.VipEndAmount = endAmount = Convert.ToDecimal(tempAmount);
                    }
                }
            }
            //不使用余额,余额为0
            else
            {
                endAmount = 0;
            }
            //实付金额
            decimal transAmount = tempAmount - discountAmount;
            //支付状态
            string payStatus = "0";
            //支付时间
            DateTime?PayDatetTime = null;

            //实付金额全是由余额支付,支付状态和支付时间全部更新,积分扣减、余额扣减、优惠券使用
            if (transAmount == endAmount || transAmount == 0)
            {
                payStatus    = "10";
                PayDatetTime = DateTime.Now;
                //处理积分抵扣
                if (rp.IntegralFlag == 1)
                {
                    var    vipIntegralBll = new VipIntegralBLL(CurrentUserInfo);
                    string sourceId       = "20"; //积分抵扣
                    var    IntegralDetail = new VipIntegralDetailEntity()
                    {
                        Integral         = -Convert.ToInt32(rp.Integral),
                        IntegralSourceID = sourceId,
                        ObjectId         = orderId.ToString()
                    };
                    if (IntegralDetail.Integral != 0)
                    {
                        //变动前积分
                        string OldIntegral = (vipInfo.Integration ?? 0).ToString();
                        //变动积分
                        string ChangeIntegral      = (IntegralDetail.Integral ?? 0).ToString();
                        var    vipIntegralDetailId = vipIntegralBll.AddIntegral(ref vipInfo, unitInfo, IntegralDetail, CurrentUserInfo);
                        //发送微信积分变动通知模板消息
                        if (!string.IsNullOrWhiteSpace(vipIntegralDetailId))
                        {
                            var CommonBLL = new CommonBLL();
                            CommonBLL.PointsChangeMessage(OldIntegral, vipInfo, ChangeIntegral, vipInfo.WeiXinUserId, CurrentUserInfo);
                        }
                    }
                }
                //处理余额抵扣
                if (rp.VipEndAmountFlag == 1)
                {
                    var vipAmountBll       = new VipAmountBLL(CurrentUserInfo);
                    var vipAmountDetailBll = new VipAmountDetailBLL(CurrentUserInfo);

                    var vipAmountEntity = vipAmountBll.QueryByEntity(new VipAmountEntity()
                    {
                        VipId = vipInfo.VIPID, VipCardCode = vipInfo.VipCode
                    }, null).FirstOrDefault();
                    if (vipAmountEntity != null)
                    {
                        var detailInfo = new VipAmountDetailEntity()
                        {
                            Amount         = -rp.VipEndAmount,
                            AmountSourceId = "1",
                            ObjectId       = orderId.ToString()
                        };
                        var vipAmountDetailId = vipAmountBll.AddVipAmount(vipInfo, unitInfo, ref vipAmountEntity, detailInfo, CurrentUserInfo);
                        if (!string.IsNullOrWhiteSpace(vipAmountDetailId))
                        {//发送微信账户余额变动模板消息
                            var CommonBLL = new CommonBLL();
                            CommonBLL.BalanceChangedMessage(orderNo, vipAmountEntity, detailInfo, vipInfo.WeiXinUserId, vipInfo.VIPID, CurrentUserInfo);
                        }
                    }
                }
            }
            //收款订单
            ReceiveAmountOrderEntity receiveAmountOrderEntity = new ReceiveAmountOrderEntity()
            {
                OrderId             = orderId,
                OrderNo             = orderNo,
                VipId               = vipInfo.VIPID,
                ServiceUnitId       = unitInfo.unit_id,
                ServiceUserId       = rp.EmployeeID,
                TotalAmount         = rp.TotalAmount,
                VipDiscount         = discount * 100,
                TransAmount         = transAmount,
                PayPoints           = integralAmount,
                AmountFromPayPoints = rp.IntegralAmount,
                CouponUsePay        = couponAmount,
                AmountAcctPay       = endAmount,
                PayStatus           = payStatus,
                TimeStamp           = rp.TimeStamp,
                PayDatetTime        = PayDatetTime,
                CustomerId          = CurrentUserInfo.ClientID
            };
            receiveAmountOrderBll.Create(receiveAmountOrderEntity);
            //订单奖励
            if (transAmount == endAmount || transAmount == 0)
            {
                var vipIntegralBll = new VipIntegralBLL(CurrentUserInfo);
                vipIntegralBll.OrderReward(receiveAmountOrderEntity, null);
            }
            rd.orderId = orderId.ToString();
            return(rd);
        }
    }
}
Пример #5
0
        public string setOrderInfo()
        {
            //string content = string.Empty;
            var respData = new setOrderInfoRespData();
            //try
            //{
            string reqContent = "";

            Loggers.Debug(new DebugLogInfo()
            {
                Message = string.Format("setOrderInfo: {0}", reqContent)
            });

            #region     //解析请求字符串 chech

            //var reqObj = reqContent.DeserializeJSONTo<setOrderInfoReqData>();
            //reqObj = reqObj == null ? new setOrderInfoReqData() : reqObj;
            //if (reqObj.special == null)
            //{
            //    reqObj.special = new setOrderInfoReqSpecialData();
            //}
            //if (reqObj.special == null)
            //{
            //    respData.code = "102";
            //    respData.description = "没有特殊参数";
            //    return respData.ToJSON().ToString();
            //}

            //if (reqObj.special.skuId == null || reqObj.special.skuId.Equals(""))
            //{
            //    respData.code = "2201";
            //    respData.description = "skuId不能为空";
            //    return respData.ToJSON().ToString();
            //}

            //if (reqObj.special.qty == null || reqObj.special.qty.Equals(""))
            //{
            //    respData.code = "2202";
            //    respData.description = "qty购买的数量不能为空";
            //    return respData.ToJSON().ToString();
            //}

            //if (reqObj.special.salesPrice == null || reqObj.special.salesPrice.Equals(""))
            //{
            //    respData.code = "2203";
            //    respData.description = "salesPrice销售价格不能为空";
            //    return respData.ToJSON().ToString();
            //}

            //if (reqObj.special.stdPrice == null || reqObj.special.stdPrice.Equals(""))
            //{
            //    respData.code = "2204";
            //    respData.description = "stdPrice原价格不能为空";
            //    return respData.ToJSON().ToString();
            //}
            //if (reqObj.special.deliveryId == null || reqObj.special.deliveryId.Equals(""))
            //{
            //    respData.code = "2205";
            //    respData.description = "deliveryId提货方式不能为空";
            //    return respData.ToJSON().ToString();
            //}

            //if (reqObj.common.userId == null || reqObj.common.userId.Equals(""))
            //{
            //    respData.code = "2206";
            //    respData.description = "userId不能为空";
            //    return respData.ToJSON().ToString();
            //}

            #endregion

            #region     //判断客户ID是否传递

            //if (!string.IsNullOrEmpty(reqObj.common.customerId))
            //{
            //    customerId = reqObj.common.customerId;
            //}
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;

            #endregion

            #region 设置参数

            InoutService   service   = new InoutService(loggingSessionInfo);
            SetOrderEntity orderInfo = new SetOrderEntity();
            orderInfo.SkuId    = "1";
            orderInfo.TotalQty = 1;
            //if (reqObj.special.storeId == null || reqObj.special.storeId.Trim().Equals(""))
            //{
            //    UnitService unitServer = new UnitService(loggingSessionInfo);
            //    orderInfo.StoreId = unitServer.GetUnitByUnitType("OnlineShopping", null).Id; //获取在线商城的门店标识
            //}
            //else
            //{
            //    orderInfo.StoreId = ToStr(reqObj.special.storeId);
            //}
            orderInfo.StoreId         = "1";
            orderInfo.SalesPrice      = 0;
            orderInfo.StdPrice        = -1;
            orderInfo.TotalAmount     = 0;
            orderInfo.Mobile          = "";
            orderInfo.Email           = "";
            orderInfo.Remark          = "";
            orderInfo.CreateBy        = "";
            orderInfo.LastUpdateBy    = "";
            orderInfo.DeliveryId      = "";
            orderInfo.DeliveryTime    = "";
            orderInfo.DeliveryAddress = "";
            orderInfo.CustomerId      = loggingSessionInfo.CurrentLoggingManager.Customer_Id;
            orderInfo.OpenId          = "";
            orderInfo.username        = "";
            if (orderInfo.OrderId == null || orderInfo.OrderId.Equals(""))
            {
                orderInfo.OrderId      = BaseService.NewGuidPub();
                orderInfo.OrderDate    = System.DateTime.Now.ToString("yyyy-MM-dd");
                orderInfo.Status       = "100";
                orderInfo.StatusDesc   = "待审核";
                orderInfo.DiscountRate = Convert.ToDecimal((orderInfo.SalesPrice / orderInfo.StdPrice) * 100);
                //获取订单号
                TUnitExpandBLL serviceUnitExpand = new TUnitExpandBLL(loggingSessionInfo);
                orderInfo.OrderCode = serviceUnitExpand.GetUnitOrderNo();
            }

            #endregion

            string strError = string.Empty;
            string strMsg   = string.Empty;

            Loggers.Debug(new DebugLogInfo()
            {
                Message = string.Format("setOrderInfo: {0}", "开始保存")
            });

            bool bReturn = service.SetOrderOnlineShoppingCoupon(orderInfo, out strError, out strMsg);

            #region 返回信息设置

            //respData.content = new setOrderInfoRespContentData();
            //respData.content.orderId = orderInfo.OrderId;
            //respData.exception = strError;
            //respData.description = strMsg;
            //if (!bReturn)
            //{
            //    respData.code = "111";
            //}

            #endregion
            //}

            //content = respData.ToJSON();
            //return content;

            return(orderInfo.OrderCode);
        }
Пример #6
0
        /// <summary>
        /// 基金购买
        /// </summary>
        /// <param name="reqContent"></param>
        /// <returns></returns>
        public void BuyFund()
        {
            DateTime dt                 = DateTime.Now;
            string   orderNO            = HuaAnFactory.GenerateSeqNO();
            var      loggingSessionInfo = Default.GetBSLoggingSession(m_customerID, m_userID);

            WXHouseDetailBLL    wxhdbll = new WXHouseDetailBLL(loggingSessionInfo);
            WXHouseDetailEntity wxhde   = wxhdbll.GetDetailByID(m_customerID, m_detailID);

            if (wxhde == null)
            {
                throw new Exception("没有找到该楼盘信息。");
            }

            string realPay = wxhde.RealPay.ToString();

            //产生订单号
            TUnitExpandBLL TUeBll = new TUnitExpandBLL(loggingSessionInfo);
            // string seqNO = TUeBll.GetUnitOrderNo(loggingSessionInfo, "ed7d227564b54778a4cffb7335a8b078");

            string seqNO = HuaAnFactory.GenerateSeqNO();
            //1判断会员楼盘明细映射是否存在记录
            WXHouseVipMappingBLL bll = new WXHouseVipMappingBLL(loggingSessionInfo);
            DataSet ds        = bll.VerifWXHouseVipMapping(m_userID, m_detailID, m_customerID);
            Guid    mappingID = Guid.NewGuid();

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                //1.1存在
                mappingID = new Guid(ds.Tables[0].Rows[0]["MappingID"].ToString());
            }
            else
            {
                //1.2不存在
                //插入会员楼盘明细映射表
                WXHouseVipMappingEntity WXHvmEntity = new WXHouseVipMappingEntity();
                WXHvmEntity.MappingID  = mappingID;
                WXHvmEntity.DetailID   = new Guid(m_detailID);
                WXHvmEntity.CustomerID = m_customerID;
                WXHvmEntity.VIPID      = m_userID;
                //WXHvmEntity.HouseSaleNo = "";//预售号码
                WXHvmEntity.ReserveNo = orderNO;
                //WXHvmEntity.HoseMessage = "";//房子描述信息
                WXHvmEntity.HoseState = 0;
                WXHvmEntity.IsBuyHose = (int)PayHouseStateEnum.Unknown;
                WXHvmEntity.IsBuyFund = 1;
                WXHvmEntity.IsRedeem  = (int)FundStateEnum.Unknown;
                bll.Create(WXHvmEntity);
            }
            //1.3插入交易手续费表
            Guid feeID = Guid.NewGuid();
            WXHouseTradeFeeEntity WXHtfEntity = new WXHouseTradeFeeEntity();

            WXHtfEntity.FeeID      = feeID;
            WXHtfEntity.TradeType  = 0;
            WXHtfEntity.FeeType    = 0;
            WXHtfEntity.Fee        = 0;
            WXHtfEntity.CustomerID = m_customerID;
            WXHouseTradeFeeBLL WXHtfBll = new WXHouseTradeFeeBLL(loggingSessionInfo);

            WXHtfBll.Create(WXHtfEntity);
            ////1.4插入预付款订单
            //WXHousePrePaymentEntity WXHppEntity = new WXHousePrePaymentEntity();
            //Guid prePaymentID = Guid.NewGuid();
            //WXHppEntity.PrePaymentID = prePaymentID;
            //WXHppEntity.FeeID = feeID;
            //WXHppEntity.MappingID = mappingID;
            //WXHppEntity.OrderNo = orderNO;
            //WXHppEntity.RealPay = Convert.ToDecimal(realPay);
            //WXHppEntity.OrderDate = dt.ToString();
            //WXHppEntity.CustomerID = m_customerID;
            //WXHousePrePaymentBLL WXHppBll = new WXHousePrePaymentBLL(loggingSessionInfo);
            //WXHppBll.Create(WXHppEntity);

            //创建会员客户协议号映射
            //CreateClientAgreementNO(rp, loggingSessionInfo);

            //处理调用华安请求From表单对象
            Receive.ReceiveBuyMessage pEnity = new Receive.ReceiveBuyMessage();
            pEnity.MerchantID   = HuaAnConfigurationAppSitting.MerchantID;
            pEnity.Merchantdate = dt.ToString("yyyyMMdd");
            pEnity.Totalamt     = Convert.ToDecimal(realPay);
            VipBLL    vbll = new VipBLL(loggingSessionInfo);
            VipEntity ve   = vbll.GetVipDetailByVipID(m_userID);

            pEnity.Assignbuyer    = ve.VipCode;
            pEnity.Assbuyername   = ve.VipName;
            pEnity.Assbuyermobile = ve.Phone;
            pEnity.Fee            = "0";
            //用于回调更新
            string strCommon = "CustomerID=" + m_customerID;

            strCommon += "|UserID=" + m_userID;
            strCommon += "|HouseDetailID=" + m_detailID;
            strCommon += "|MappingID=" + mappingID.ToString();
            //  strCommon += "|PrePaymentID=" + prePaymentID.ToString();
            strCommon          += "|ToPageURL=http://o2oapi.aladingyidong.com/ApplicationInterface/Project/HuaAn/HuaAnCallBack.aspx?action=BuyCallBack";
            pEnity.Commonreturn = strCommon;
            //回调url
            pEnity.RetURL  = "";
            pEnity.PageURL = string.Format(HuaAnConfigurationAppSitting.CallBackPageUrl, "BuyCallBack");
            //pEnity.PageURL = "http://o2oapi.aladingyidong.com/ApplicationInterface/Project/HuaAn/HuaAnCallBack.aspx?action=BuyCallBack";
            pEnity.Memo = "";
            //请求表单对象
            var fromList = new HuaAnFactory().FormRequestContent(dt, Utility.GetRequsetXml(pEnity), HuaAnConfigurationAppSitting.Buy, orderNO);
            var rdData   = new PayEntityRD();

            rdData.FormData = fromList;
            //华安url
            rdData.Url = HuaAnConfigurationAppSitting.ReservationPurchaseUrl;
            //请求表单对象
            Model = new HuaAnFactory().FormRequestContent(dt, Utility.GetRequsetXml(pEnity), HuaAnConfigurationAppSitting.Buy, seqNO);
        }