private string SetOrderInfo()
        {
            string content  = string.Empty;
            var    respData = new Default.LowerRespData();

            try
            {
                string reqContent = "{\"special\":{\"EventId\":\"1\" ,\"skuId\":\"18A5685F3B0D43909740EEC20AEFBC73\" ,\"userName\":\"邵志峰\" ,\"phone\":\"13764683490\" ,\"individuationInfo\":\"一统江湖\" ,\"salesPrice\":\"18000\",\"tableNumber\":\"4\" },\"common\":{\"weiXinId\":\"gh_bf70d7900c28\",\"openId\":\"o8Y7Ejm0kL4QB8-h_Z0Bncl619v4\"}} ";


                var reqObj = reqContent.DeserializeJSONTo <setOrderInfoReqData>();

                string OpenID = reqObj.common.openId;
                string WeiXin = reqObj.common.weiXinId;

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

                var          loggingSessionInfo = Default.GetLjLoggingSession();
                InoutService inoutService       = new InoutService(loggingSessionInfo);
                string       strError           = string.Empty;
                string       strMsg             = string.Empty;
                bool         bReturn            = inoutService.SetWapPosInoutInfo(reqObj.special.skuId.Trim()
                                                                                  , reqObj.special.eventId.Trim()
                                                                                  , OpenID.Trim()
                                                                                  , WeiXin.Trim()
                                                                                  , reqObj.special.userName.Trim()
                                                                                  , reqObj.special.phone.Trim()
                                                                                  , reqObj.special.individuationInfo.Trim()
                                                                                  , reqObj.special.salesPrice.Trim()
                                                                                  , reqObj.special.tableNumber.Trim()
                                                                                  , loggingSessionInfo
                                                                                  , out strError, out strMsg);
                if (bReturn)
                {
                    respData.code = "200";
                }
                else
                {
                    respData.code = "101";
                }
                respData.description = strError;
                return(respData.ToJSON());
            }
            catch (Exception ex)
            {
                respData.code        = "103";
                respData.description = "数据库操作错误";
                respData.exception   = ex.ToString();
            }
            content = respData.ToJSON();
            return(content);
        }
Exemple #2
0
        /// <summary>
        /// 更新单据打包标识方法
        /// </summary>
        /// <param name="Customer_Id">客户标识</param>
        /// <param name="User_Id">用户标识</param>
        /// <param name="Unit_Id">组织标识</param>
        /// <param name="bat_id">批次号</param>
        /// <returns>true=成功,false=失败</returns>
        public bool SetInoutIfFlagInfo(string Customer_Id, string User_Id, string Unit_Id, string bat_id)
        {
            LoggingSessionInfo loggingSessionInfo = GetLoggingSessionInfo(Customer_Id, User_Id, Unit_Id);
            bool   bReturn  = false;
            string strError = string.Empty;

            InoutService inoutService = new InoutService();

            bReturn = inoutService.SetInoutOrderIfFlagInfo(loggingSessionInfo, bat_id, out strError);
            return(bReturn);
        }
Exemple #3
0
    protected void gvAdjBill_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        var serv = new InoutService();

        try
        {
            switch (e.CommandName)
            {
            case "Page": return;

            case "Check":
            {
                if (serv.SetInoutOrderStatus(loggingSessionInfo, e.CommandArgument.ToString(), BillActionType.Approve))
                {
                    this.InfoBox.ShowPopInfo("审批成功!");
                }
                else
                {
                    this.InfoBox.ShowPopError("审批失败!");
                }
            } break;

            case "Back":
            {
                if (serv.SetInoutOrderStatus(loggingSessionInfo, e.CommandArgument.ToString(), BillActionType.Reject))
                {
                    this.InfoBox.ShowPopInfo("回退成功!");
                }
                else
                {
                    this.InfoBox.ShowPopError("回退失败!");
                }
            } break;

            case "ajDelete":
            {
                if (serv.SetInoutOrderStatus(loggingSessionInfo, e.CommandArgument.ToString(), BillActionType.Cancel))
                {
                    this.InfoBox.ShowPopInfo("删除成功!");
                }
                else
                {
                    this.InfoBox.ShowPopError("删除失败!");
                }
            } break;
            }
            Query(0);
        }
        catch (Exception ex)
        {
            PageLog.Current.Write(ex);
            this.InfoBox.ShowPopError("加载数据出错!");
        }
    }
Exemple #4
0
        /// <summary>
        /// 支付回调/收款处理虚拟商品订单
        /// </summary>
        public void SetVirtualItem(LoggingSessionInfo loggingSessionInfo, string orderId)
        {
            var inoutBLL  = new T_InoutBLL(loggingSessionInfo);
            var inoutInfo = this._currentDAO.GetByID(orderId);

            if (inoutInfo != null)
            {
                //如果是经销商订单,付款完成后,订单状态修改成完成状态
                if (inoutInfo.data_from_id == "21")
                {
                    inoutInfo.Field7 = "700";
                    inoutInfo.status = "700";
                    inoutBLL.Update(inoutInfo);
                    InoutService inoutService = new InoutService(loggingSessionInfo);
                    T_VirtualItemTypeSettingBLL virtualItemTypeSettingBLL = new T_VirtualItemTypeSettingBLL(loggingSessionInfo);
                    VipCardVipMappingBLL        vipCardVipMappingBLL      = new VipCardVipMappingBLL(loggingSessionInfo);
                    T_Inout_DetailBLL           inoutDetailBLL            = new T_Inout_DetailBLL(loggingSessionInfo);
                    var    VipBLL      = new VipBLL(loggingSessionInfo);
                    var    inoutDetail = inoutService.GetInoutDetailInfoByOrderId(orderId).FirstOrDefault();
                    string itemId      = inoutDetail.item_id;

                    var virtualItemTypeSettingInfo = virtualItemTypeSettingBLL.QueryByEntity(new T_VirtualItemTypeSettingEntity()
                    {
                        ItemId = itemId
                    }, null).FirstOrDefault();
                    if (virtualItemTypeSettingInfo != null)
                    {
                        int    objectTypeId = int.Parse(virtualItemTypeSettingInfo.ObjecetTypeId);
                        string objectNo     = vipCardVipMappingBLL.BindVirtualItem(inoutInfo.vip_no, inoutInfo.VipCardCode, "", objectTypeId);
                        //将卡/券的编号保存到订单明细
                        T_Inout_DetailEntity inoutDetailEntity = inoutDetailBLL.GetByID(inoutDetail.order_detail_id);
                        if (inoutDetailEntity != null)
                        {
                            inoutDetailEntity.Field10 = objectNo;
                            inoutDetailBLL.Update(inoutDetailEntity);
                        }
                    }
                    //将Col48至为1
                    var VipData = VipBLL.GetByID(inoutInfo.vip_no);
                    if (VipData != null)
                    {
                        VipData.Col48 = "1";
                        VipBLL.Update(VipData);
                    }
                    // 判断客户是否是符合潜在经销商条件
                    var isCan = VipBLL.IsSetVipDealer(inoutInfo.vip_no);

                    if (isCan)
                    {
                        new RetailTraderBLL(loggingSessionInfo).CreatePrepRetailTrader(loggingSessionInfo, inoutInfo.vip_no); // 创建潜在经销商
                    }
                }
            }
        }
        private void SearchInoutDetailInfoByVip()
        {
            var             inoutService = new InoutService(Default.GetLoggingSession());
            OrderSearchInfo queryInfo    = new OrderSearchInfo();

            queryInfo.vip_no          = "0334f76bad484c02af4dd8c32802025b";;
            queryInfo.order_type_id   = "1F0A100C42484454BAEA211D4C14B80F";
            queryInfo.order_reason_id = "2F6891A2194A4BBAB6F17B4C99A6C6F5";
            queryInfo.red_flag        = "1";
            queryInfo.StartRow        = 0;
            queryInfo.EndRow          = 0 + 15;
            queryInfo.unit_id         = "bae1ed3ce4db4524a6d2398299075fbf";
            var data = inoutService.SearchInoutDetailInfoByVip(queryInfo);
        }
Exemple #6
0
    private void showInoutInfo(string orderId)
    {
        InoutInfo IOInfo = new InoutService().GetInoutInfoById(loggingSessionInfo, orderId);

        this.tbOrderNo.Text              = IOInfo.order_no;
        this.selOrderDate.Value          = (IOInfo.order_date ?? "").ToString();
        this.selReasonType.SelectedValue = IOInfo.order_reason_id;
        this.drpUnit.SelectedValue       = IOInfo.unit_id;
        this.drpUnit.SelectedText        = IOInfo.unit_name;
        loadWarehouse();
        this.selWarehouse.SelectedValue = IOInfo.warehouse_id;
        this.tbCompleteDate.Value       = (IOInfo.ref_order_no ?? "").ToString();
        this.tbRemark.Text       = IOInfo.remark;
        this.InoutDetailInfoList = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(IOInfo.InoutDetailList);
    }
Exemple #7
0
        /// <summary>
        /// 获取活动相关的统计信息
        /// </summary>
        /// <param name="WeiXinId">微信公众号标识</param>
        /// <param name="EventId">活动标识</param>
        /// <param name="loggingSessionInfo">登录</param>
        /// <returns></returns>
        public LEventsEntity GetEventTotalInfo(string WeiXinId
                                               , string EventId
                                               , LoggingSessionInfo loggingSessionInfo
                                               , out string strError)
        {
            LEventsEntity eventInfo = new LEventsEntity();

            #region
            if (EventId == null || EventId.Equals(""))
            {
                strError = "必须选择商品";
                return(eventInfo);
            }
            if (WeiXinId == null || WeiXinId.Equals(""))
            {
                strError = "微信公众号不能为空";
                return(eventInfo);
            }
            #endregion
            try
            {
                //1.获取已关注会员数量
                VipBLL vipServer = new VipBLL(loggingSessionInfo);
                eventInfo.hasVipCount = vipServer.GetHasVipCount(WeiXinId);
                //2.获取新采集会员数量
                eventInfo.newVipCount = vipServer.GetNewVipCount(WeiXinId);
                //3.获取已下单数量
                InoutService inoutServer = new InoutService(loggingSessionInfo);
                eventInfo.hasOrderCount = inoutServer.GetHasOrderCount(EventId);
                //4.获取已付款订单数
                eventInfo.hasPayCount = inoutServer.GetHasPayCount(EventId);
                //5.获取已销售订单额
                eventInfo.hasSalesAmount = inoutServer.GetHasSalesAmount(EventId);
                strError = "ok";
                return(eventInfo);
            }
            catch (Exception ex)
            {
                throw (ex);
            }
        }
Exemple #8
0
        /// <summary>
        ///
        /// </summary>
        public string GetPosOrderListData()
        {
            var    service = new PosService(CurrentUserInfo);
            string content = string.Empty;

            string key = string.Empty;

            if (Request("vip_id") != null && Request("vip_id") != string.Empty)
            {
                key = Request("vip_id").ToString().Trim();
            }

            int pageIndex = Utils.GetIntVal(FormatParamValue(Request("page"))) - 1;

            var             inoutService = new InoutService(CurrentUserInfo);
            InoutDetailInfo data;

            int maxRowCount = PageSize;
            //int startRowIndex = Utils.GetIntVal(Request("start"));
            int startRowIndex = pageIndex * PageSize + 1;

            OrderSearchInfo queryInfo = new OrderSearchInfo();

            queryInfo.vip_no          = key;
            queryInfo.order_type_id   = "1F0A100C42484454BAEA211D4C14B80F";
            queryInfo.order_reason_id = "2F6891A2194A4BBAB6F17B4C99A6C6F5";
            queryInfo.red_flag        = "1";
            queryInfo.StartRow        = startRowIndex;
            queryInfo.EndRow          = startRowIndex + maxRowCount;
            data = inoutService.SearchInoutDetailInfo(queryInfo);

            content = string.Format("{{\"totalCount\":{1},\"topics\":{0}}}",
                                    data.InoutDetailList.ToJSON(),
                                    data.ICount);

            return(content);
        }
        protected override EmptyResponseData ProcessRequest(DTO.Base.APIRequest <SetSalesReturnRP> pRequest)
        {
            var rd   = new EmptyResponseData();
            var para = pRequest.Parameters;
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            var salesReturnBLL     = new T_SalesReturnBLL(loggingSessionInfo);
            var historyBLL         = new T_SalesReturnHistoryBLL(loggingSessionInfo);
            var refundOrderBLL     = new T_RefundOrderBLL(loggingSessionInfo);

            var inoutBLL     = new T_InoutBLL(loggingSessionInfo);
            var inoutService = new InoutService(loggingSessionInfo);

            var vipAmountBLL   = new VipAmountBLL(loggingSessionInfo);   //余额返现BLL实例化
            var vipIntegralBLL = new VipIntegralBLL(loggingSessionInfo); //积分BLL实例化

            var pTran = salesReturnBLL.GetTran();                        //事务
            T_SalesReturnEntity        salesReturnEntity = null;
            T_SalesReturnHistoryEntity historyEntity     = null;

            T_RefundOrderEntity refundEntity = null;

            var          vipBll     = new VipBLL(loggingSessionInfo);    //会员BLL实例化
            var          userBll    = new T_UserBLL(loggingSessionInfo); //店员BLL实例化
            T_UserEntity userEntity = null;                              //店员信息
            var          unitBLL    = new t_unitBLL(loggingSessionInfo);

            salesReturnEntity = salesReturnBLL.GetByID(para.SalesReturnID);
            //获取订单信息
            var inoutInfo = inoutBLL.GetInoutInfo(salesReturnEntity.OrderID, loggingSessionInfo);
            //获取会员信息
            var vipInfo = vipBll.GetByID(inoutInfo.vip_no);
            //获取门店信息
            t_unitEntity unitInfo = null;

            if (!string.IsNullOrEmpty(inoutInfo.sales_unit_id))
            {
                unitInfo = unitBLL.GetByID(inoutInfo.sales_unit_id);
            }
            userEntity = userBll.GetByID(loggingSessionInfo.UserID);
            using (pTran.Connection)
            {
                try
                {
                    switch (para.OperationType)
                    {
                    case 1:
                        #region 审核通过
                        salesReturnEntity.Status = 4;    //审核通过

                        #region 计算应退金额
                        decimal payable = 0;       //计算后应退金额

                        //根据订单ID获取订单明细[复用]
                        DataRow drItem     = inoutService.GetOrderDetailByOrderId(salesReturnEntity.OrderID).Tables[0].Select(" item_id= '" + salesReturnEntity.ItemID + "'").FirstOrDefault();
                        decimal salesPrice = Convert.ToDecimal(drItem["enter_price"]);
                        if (inoutInfo != null)
                        {
                            //订单总金额-运费
                            decimal tempAmount = inoutInfo.total_amount.Value - inoutInfo.DeliveryAmount;
                            //计算会员折扣
                            decimal discount = 1;
                            if (inoutInfo.discount_rate.Value > 0)
                            {
                                discount = inoutInfo.discount_rate.Value / 100;
                            }
                            //计算后应退金额
                            //payable = (((tempAmount - inoutInfo.CouponAmount) * discount) / tempAmount) * (salesPrice * salesReturnEntity.ActualQty.Value);
                            //公式:比例 =(应付金额 * 会员折扣 - 优惠券)/ 应付金额
                            //      应退金额 = 退货数量 * 销售价 * 比例
                            payable = ((tempAmount * discount - inoutInfo.CouponAmount) / tempAmount) * (salesPrice * salesReturnEntity.ActualQty.Value);
                        }
                        salesReturnEntity.RefundAmount  = payable;      //应退金额
                        salesReturnEntity.ConfirmAmount = payable;      //实退金额,默认为应退金额,可支持修改
                        #endregion

                        salesReturnBLL.Update(salesReturnEntity, pTran);

                        historyEntity = new T_SalesReturnHistoryEntity()
                        {
                            SalesReturnID = salesReturnEntity.SalesReturnID,
                            OperationType = 4,
                            OperationDesc = "审核",
                            OperatorID    = loggingSessionInfo.UserID,
                            HisRemark     = "您的服务单已审核通过,请将商品寄回",
                            OperatorName  = userEntity.user_name,
                            OperatorType  = 1
                        };
                        historyBLL.Create(historyEntity, pTran);

                        #endregion
                        break;

                    case 2:
                        #region 审核不通过
                        salesReturnEntity.Status = 3;    //审核不通过
                        salesReturnBLL.Update(salesReturnEntity, pTran);

                        historyEntity = new T_SalesReturnHistoryEntity()
                        {
                            SalesReturnID = salesReturnEntity.SalesReturnID,
                            OperationType = 3,
                            OperationDesc = "审核",
                            OperatorID    = loggingSessionInfo.UserID,
                            HisRemark     = para.Desc,
                            OperatorName  = userEntity.user_name,
                            OperatorType  = 1
                        };
                        historyBLL.Create(historyEntity, pTran);
                        break;

                        #endregion
                    case 3:
                        #region 确认收货
                        salesReturnEntity.Status = 6;    //确认收货
                        salesReturnBLL.Update(salesReturnEntity, pTran);

                        historyEntity = new T_SalesReturnHistoryEntity()
                        {
                            SalesReturnID = salesReturnEntity.SalesReturnID,
                            OperationType = 6,
                            OperationDesc = "收货",
                            OperatorID    = loggingSessionInfo.UserID,
                            HisRemark     = "您的服务单" + salesReturnEntity.SalesReturnNo + "的商品已经收到",
                            OperatorName  = userEntity.user_name,
                            OperatorType  = 1
                        };
                        historyBLL.Create(historyEntity, pTran);
                        //退货时生成退款单
                        if (salesReturnEntity.ServicesType == 1)
                        {
                            refundEntity = new T_RefundOrderEntity();
                            refundEntity.SalesReturnID = salesReturnEntity.SalesReturnID;
                            refundEntity.RefundNo      = DateTime.Now.ToString("yyyyMMddhhmmfff");
                            refundEntity.VipID         = salesReturnEntity.VipID;
                            refundEntity.DeliveryType  = salesReturnEntity.DeliveryType;
                            refundEntity.OrderID       = salesReturnEntity.OrderID;
                            refundEntity.ItemID        = salesReturnEntity.ItemID;
                            refundEntity.SkuID         = salesReturnEntity.SkuID;
                            refundEntity.Qty           = salesReturnEntity.Qty;
                            refundEntity.ActualQty     = salesReturnEntity.ActualQty;
                            refundEntity.UnitID        = salesReturnEntity.UnitID;
                            refundEntity.UnitName      = salesReturnEntity.UnitName;
                            refundEntity.UnitTel       = salesReturnEntity.UnitTel;
                            refundEntity.Address       = salesReturnEntity.Address;
                            refundEntity.Contacts      = salesReturnEntity.Contacts;
                            refundEntity.Phone         = salesReturnEntity.Phone;
                            refundEntity.RefundAmount  = salesReturnEntity.RefundAmount;        //退款金额
                            refundEntity.ConfirmAmount = salesReturnEntity.ConfirmAmount;       //确认退款金额

                            #region 计算应退现金金额、余额、积分、返现
                            var inoutDetail = inoutBLL.GetInoutInfo(salesReturnEntity.OrderID, loggingSessionInfo);
                            if (inoutDetail != null)
                            {
                                //订单实付金额-运费 >= 应退金额
                                if (inoutDetail.actual_amount - inoutDetail.DeliveryAmount >= salesReturnEntity.ConfirmAmount)
                                {
                                    refundEntity.ActualRefundAmount = salesReturnEntity.ConfirmAmount;
                                }
                                //订单实付金额-运费+余额抵扣 >= 应退金额
                                else if (inoutDetail.actual_amount - inoutDetail.DeliveryAmount + inoutDetail.VipEndAmount >= salesReturnEntity.ConfirmAmount)
                                {
                                    refundEntity.ActualRefundAmount = inoutDetail.actual_amount - inoutDetail.DeliveryAmount;     //实付金额
                                    //refundEntity.Amount = salesReturnEntity.ConfirmAmount - inoutDetail.actual_amount;  //退回余额
                                    refundEntity.Amount = salesReturnEntity.ConfirmAmount - refundEntity.ActualRefundAmount;      //退回余额
                                }
                                //订单实付金额-运费+余额抵扣+积分抵扣 >= 应退金额
                                else if (inoutDetail.actual_amount - inoutDetail.DeliveryAmount + inoutDetail.VipEndAmount + inoutDetail.IntegralAmount >= salesReturnEntity.ConfirmAmount)
                                {
                                    refundEntity.ActualRefundAmount = inoutDetail.actual_amount - inoutDetail.DeliveryAmount; //实付金额
                                    refundEntity.Amount             = inoutDetail.VipEndAmount;                               //退回余额
                                    //退回积分抵扣金额
                                    refundEntity.PointsAmount = salesReturnEntity.ConfirmAmount.Value - (inoutDetail.actual_amount.Value - inoutDetail.DeliveryAmount) - inoutDetail.VipEndAmount;
                                    //退回积分
                                    refundEntity.Points = (int)Math.Round(refundEntity.PointsAmount.Value * (inoutDetail.pay_points.Value / inoutDetail.IntegralAmount), 1);
                                }
                                else                                                                                    //订单实付金额-运费+余额抵扣+积分抵扣 < 应退金额
                                {
                                    refundEntity.Points             = (int)Math.Round(inoutDetail.pay_points.Value, 1); //退回积分
                                    refundEntity.PointsAmount       = inoutDetail.IntegralAmount;                       //退回积分抵扣金额
                                    refundEntity.Amount             = inoutDetail.VipEndAmount;                         //退回余额
                                    refundEntity.ActualRefundAmount = salesReturnEntity.ConfirmAmount;                  //实付金额
                                }
                                //订单实付金额-运费+余额抵扣+积分抵扣 >= 应退金额
                                //取消返现
                                //else if (inoutDetail.actual_amount - inoutDetail.DeliveryAmount + inoutDetail.VipEndAmount + inoutDetail.IntegralAmount + inoutDetail.ReturnAmount >= salesReturnEntity.ConfirmAmount)
                                //{
                                //    refundEntity.ActualRefundAmount = inoutDetail.actual_amount - inoutDetail.DeliveryAmount;//实付金额
                                //    refundEntity.Amount = inoutDetail.VipEndAmount;             //退回余额
                                //    refundEntity.Points = (int)Math.Round(inoutDetail.pay_points.Value, 1);//退回积分
                                //    refundEntity.PointsAmount = inoutDetail.IntegralAmount;       //退回积分抵扣金额
                                //    //退回的返现
                                //    refundEntity.ReturnAmount = salesReturnEntity.ConfirmAmount.Value - (inoutDetail.actual_amount.Value - inoutDetail.DeliveryAmount) - inoutDetail.VipEndAmount - inoutDetail.IntegralAmount;
                                //}
                            }
                            #endregion

                            refundEntity.Status     = 1;      //待退款
                            refundEntity.CustomerID = loggingSessionInfo.ClientID;
                            refundOrderBLL.Create(refundEntity, pTran);

                            var vipAmountEntity = vipAmountBLL.QueryByEntity(new VipAmountEntity()
                            {
                                VipId = vipInfo.VIPID, VipCardCode = vipInfo.VipCode
                            }, null).FirstOrDefault();

                            //退货返回余额
                            if (refundEntity.Amount > 0)
                            {
                                //变更余额和余额记录
                                var detailInfo = new VipAmountDetailEntity()
                                {
                                    Amount         = refundEntity.Amount.Value,
                                    AmountSourceId = "21",
                                    ObjectId       = refundEntity.RefundID.ToString()
                                };
                                var vipAmountDetailId = vipAmountBLL.AddVipAmount(vipInfo, unitInfo, ref vipAmountEntity, detailInfo, pTran, loggingSessionInfo);
                                if (!string.IsNullOrWhiteSpace(vipAmountDetailId))
                                {    //发送微信账户余额变动模板消息
                                    var CommonBLL = new CommonBLL();
                                    CommonBLL.BalanceChangedMessage(inoutInfo.order_no, vipAmountEntity, detailInfo, vipInfo.WeiXinUserId, vipInfo.VIPID, loggingSessionInfo);
                                }
                            }
                            //退货返回返现
                            if (refundEntity.ReturnAmount > 0)
                            {
                                var detailInfo = new VipAmountDetailEntity()
                                {
                                    Amount         = refundEntity.ReturnAmount.Value,
                                    ObjectId       = refundEntity.RefundID.ToString(),
                                    AmountSourceId = "22"
                                };
                                var vipAmountDetailId = vipAmountBLL.AddReturnAmount(vipInfo, unitInfo, vipAmountEntity, ref detailInfo, pTran, loggingSessionInfo);
                                if (!string.IsNullOrWhiteSpace(vipAmountDetailId))
                                {    //发送返现到账通知微信模板消息
                                    var CommonBLL = new CommonBLL();
                                    CommonBLL.CashBackMessage(salesReturnEntity.OrderNo, detailInfo.Amount, vipInfo.WeiXinUserId, vipInfo.VIPID, loggingSessionInfo);
                                }
                            }
                            //退货返回积分
                            if (refundEntity.Points > 0)
                            {
                                var IntegralDetail = new VipIntegralDetailEntity()
                                {
                                    Integral         = refundEntity.Points.Value,
                                    IntegralSourceID = "26",
                                    ObjectId         = refundEntity.RefundID.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, pTran, loggingSessionInfo);
                                    //发送微信积分变动通知模板消息
                                    if (!string.IsNullOrWhiteSpace(vipIntegralDetailId))
                                    {
                                        var CommonBLL = new CommonBLL();
                                        CommonBLL.PointsChangeMessage(OldIntegral, vipInfo, ChangeIntegral, vipInfo.WeiXinUserId, loggingSessionInfo);
                                    }
                                }
                            }
                            //确认收货时退回订单奖励积分、返现和佣金
                            vipIntegralBLL.CancelReward(inoutInfo, vipInfo, pTran);
                        }
                        #endregion
                        break;

                    case 4:
                        #region 拒绝收货
                        salesReturnEntity.Status = 5;    //拒绝收货
                        salesReturnBLL.Update(salesReturnEntity, pTran);

                        historyEntity = new T_SalesReturnHistoryEntity()
                        {
                            SalesReturnID = salesReturnEntity.SalesReturnID,
                            OperationType = 5,
                            OperationDesc = "收货",
                            OperatorID    = loggingSessionInfo.UserID,
                            HisRemark     = para.Desc,
                            OperatorName  = userEntity.user_name,
                            OperatorType  = 1
                        };
                        historyBLL.Create(historyEntity, pTran);
                        #endregion
                        break;

                    case 5:
                        #region 修改信息
                        if (para.ServicesType > 0)     //修改服务方式
                        {
                            salesReturnEntity.ServicesType = para.ServicesType;
                            string servicesTypeDesc = para.ServicesType == 1 ? "退货" : "换货";
                            historyEntity = new T_SalesReturnHistoryEntity()
                            {
                                SalesReturnID = salesReturnEntity.SalesReturnID,
                                OperationType = 11,
                                OperationDesc = "修改信息",
                                OperatorID    = loggingSessionInfo.UserID,
                                HisRemark     = "修改服务方式为" + servicesTypeDesc,
                                OperatorName  = userEntity.user_name,
                                OperatorType  = 1,
                                IsDelete      = 1
                            };
                            historyBLL.Create(historyEntity, pTran);
                        }
                        if (para.ActualQty > 0)    //修改申请数量
                        {
                            salesReturnEntity.ActualQty = para.ActualQty;
                            historyEntity = new T_SalesReturnHistoryEntity()
                            {
                                SalesReturnID = salesReturnEntity.SalesReturnID,
                                OperationType = 11,
                                OperationDesc = "修改信息",
                                OperatorID    = loggingSessionInfo.UserID,
                                HisRemark     = "修改确认退货数量为" + para.ActualQty,
                                OperatorName  = userEntity.user_name,
                                OperatorType  = 1,
                                IsDelete      = 1
                            };
                            historyBLL.Create(historyEntity, pTran);
                        }
                        if (para.ConfirmAmount >= 0)    //处理实退金额
                        {
                            salesReturnEntity.ConfirmAmount = para.ConfirmAmount;

                            historyEntity = new T_SalesReturnHistoryEntity()
                            {
                                SalesReturnID = salesReturnEntity.SalesReturnID,
                                OperationType = 13,
                                OperationDesc = "修改信息",
                                OperatorID    = loggingSessionInfo.UserID,
                                HisRemark     = "修改实退金额为" + para.ConfirmAmount,
                                OperatorName  = userEntity.user_name,
                                OperatorType  = 1,
                                IsDelete      = 1
                            };
                            historyBLL.Create(historyEntity, pTran);
                        }
                        salesReturnBLL.Update(salesReturnEntity, pTran);
                        #endregion
                        break;

                    case 6:
                        #region 取消
                        salesReturnEntity.Status = 2;    //取消申请
                        salesReturnBLL.Update(salesReturnEntity, pTran);
                        historyEntity = new T_SalesReturnHistoryEntity()
                        {
                            SalesReturnID = salesReturnEntity.SalesReturnID,
                            OperationType = 2,
                            OperationDesc = "取消申请",
                            OperatorID    = CurrentUserInfo.UserID,
                            HisRemark     = para.Desc,
                            OperatorName  = userEntity.user_name,
                            OperatorType  = 0
                        };
                        historyBLL.Create(historyEntity, pTran);
                        #endregion
                        break;

                    default:
                        break;
                    }
                    pTran.Commit();  //提交事物
                }
                catch (Exception ex)
                {
                    pTran.Rollback();//回滚事务
                    throw new APIException(ex.Message);
                }
            }
            return(rd);
        }
        /// <summary>
        /// 处理订单支付之后业务标识
        /// </summary>
        /// <param name="OrderCustomerInfo"></param>
        /// <param name="strResult"></param>
        /// <param name="strOutTradeNo"></param>
        private void SetPayOrderInfo(string OrderCustomerInfo, string strResult, string strOutTradeNo)
        {
            //order_id:  订单号
            //result:    success(交易成功)  或者   fail(交易失败)
            //out_trade_no:  与订单号对应的外部交易号(方便日后查询交易中的详细信息)
            try
            {
                #region check
                if (OrderCustomerInfo == null || OrderCustomerInfo.Equals(""))
                {
                    Loggers.Debug(new DebugLogInfo()
                    {
                        Message = string.Format("SetPayOrderInfo: {0}", "返回订单号为空")
                    });
                    return;
                }
                if (strResult == null || strResult.Equals("fail"))
                {
                    Loggers.Debug(new DebugLogInfo()
                    {
                        Message = string.Format("SetPayOrderInfo: {0}", "支付失败")
                    });
                    return;
                }
                #endregion

                #region 处理业务
                var infos = OrderCustomerInfo.Split(',');
                if (infos.Length != 2)
                {
                    Loggers.Debug(new DebugLogInfo()
                    {
                        Message = string.Format("SetPayOrderInfo-OrderCustomerInfo: {0}", "长度错误")
                    });
                    return;
                }
                string customerId         = infos[0].ToString().Trim();
                string orderCode          = infos[1].ToString().Trim();
                var    loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1");

                InoutService   service   = new InoutService(loggingSessionInfo);
                SetOrderEntity orderInfo = new SetOrderEntity();
                orderInfo.OrderCode     = orderCode;
                orderInfo.PaymentTypeId = "BB04817882B149838B19DE2BDDA5E91B";
                //orderInfo.PaymentAmount = Convert.ToDecimal(reqObj.special.paymentAmount);
                //orderInfo.LastUpdateBy = ToStr(reqObj.common.userId);
                orderInfo.PaymentTime = System.DateTime.Now;
                orderInfo.Status      = "2";
                orderInfo.StatusDesc  = "已支付";
                orderInfo.OutTradeNo  = strOutTradeNo;
                string strError = string.Empty;
                bool   bReturn  = service.SetOrderPayment(orderInfo, out strError);
                if (!bReturn)
                {
                    Loggers.Debug(new DebugLogInfo()
                    {
                        Message = string.Format("SetPayOrderInfo: {0}", "提交失败")
                    });
                }
                else
                {
                    string openId  = string.Empty;
                    string amount  = string.Empty;
                    string orderId = string.Empty;
                    //支付成功,发送邮件与短信
                    cUserService userServer = new cUserService(loggingSessionInfo);
                    userServer.SendOrderMessage(orderCode);

                    bool bReturnx = service.GetOrderOpenId(orderCode, out openId, out amount, out orderId);
                    //推送消息
                    if (bReturnx)
                    {
                        string dataStr = "{ \"OpenID\":\"" + openId + "\", \"" + amount + "\":2877 }";

                        //bool bReturnt = SetVipIntegral(loggingSessionInfo, dataStr);
                        VipIntegralBLL vipIntegralBLL = new VipIntegralBLL(loggingSessionInfo);
                        bool           bReturnt       = vipIntegralBLL.SetPushIntegral(orderId
                                                                                       , ConfigurationManager.AppSettings["push_weixin_msg_url"].Trim()
                                                                                       , out strError);
                        if (!bReturnt)
                        {
                            Loggers.Debug(new DebugLogInfo()
                            {
                                Message = string.Format("SetPayOrderInfo-失败: {0}", "发送失败")
                            });
                        }
                    }
                    else
                    {
                        Loggers.Debug(new DebugLogInfo()
                        {
                            Message = string.Format("SetPayOrderInfo-失败: {0}", "获取信息失败")
                        });
                    }
                }
                #endregion
            }
            catch (Exception ex) {
                Loggers.Debug(new DebugLogInfo()
                {
                    Message = string.Format("SetPayOrderInfo-失败: {0}", ex.ToString())
                });
            }
        }
Exemple #11
0
        /// <summary>
        /// 处理商品销量库存
        /// </summary>
        /// <param name="orderId">订单ID</param>
        /// <param name="inoutDetailList">订单明细</param>
        /// <param name="actionType">操作类型 1=提交订单;2=取消订单</param>
        /// <param name="loggingSessionInfo"></param>
        public void SetStock(string orderId, IList <InoutDetailInfo> inoutDetailList, int actionType, LoggingSessionInfo loggingSessionInfo)
        {
            var itemPropertyBLL = new T_Item_PropertyBLL(loggingSessionInfo);
            var skuPriceBLL     = new T_Sku_PriceBLL(loggingSessionInfo);

            var inoutService = new InoutService(loggingSessionInfo);

            foreach (var item in inoutDetailList)
            {
                //商品总库存
                var stockInfo = itemPropertyBLL.QueryByEntity(new T_Item_PropertyEntity()
                {
                    item_id = item.item_id, prop_id = "34FF4445D39F49AD8174954D18BC1346"
                }, null).FirstOrDefault();
                if (stockInfo != null)
                {
                    decimal stock = decimal.Parse(stockInfo.prop_value);
                    if (actionType == 1)
                    {
                        stock -= item.enter_qty;
                    }
                    else if (actionType == 2)
                    {
                        stock += item.enter_qty;
                    }
                    stockInfo.prop_value = stock.ToString();
                    itemPropertyBLL.Update(stockInfo);
                }
                //商品总销量
                var salesCountInfo = itemPropertyBLL.QueryByEntity(new T_Item_PropertyEntity()
                {
                    item_id = item.item_id, prop_id = "34FF4445D39F49AD8174954D18BC1347"
                }, null).FirstOrDefault();
                if (salesCountInfo != null)
                {
                    decimal salesCount = decimal.Parse(salesCountInfo.prop_value);
                    if (actionType == 1)
                    {
                        salesCount += item.enter_qty;
                    }
                    else if (actionType == 2)
                    {
                        salesCount -= item.enter_qty;
                    }

                    salesCountInfo.prop_value = salesCount.ToString();
                    itemPropertyBLL.Update(salesCountInfo);
                }
                //sku库存
                var skuStockInfo = skuPriceBLL.QueryByEntity(new T_Sku_PriceEntity()
                {
                    sku_id = item.sku_id, item_price_type_id = "77850286E3F24CD2AC84F80BC625859E", status = "1"
                }, null).FirstOrDefault();
                if (skuStockInfo != null)
                {
                    if (actionType == 1)
                    {
                        skuStockInfo.sku_price -= item.enter_qty;
                    }
                    else if (actionType == 2)
                    {
                        skuStockInfo.sku_price += item.enter_qty;
                    }

                    skuPriceBLL.Update(skuStockInfo);
                }
                //sku销量
                var skuSalesCountInfo = skuPriceBLL.QueryByEntity(new T_Sku_PriceEntity()
                {
                    sku_id = item.sku_id, item_price_type_id = "77850286E3F24CD2AC84F80BC625859f", status = "1"
                }, null).FirstOrDefault();
                if (skuSalesCountInfo != null)
                {
                    if (actionType == 1)
                    {
                        skuSalesCountInfo.sku_price += item.enter_qty;
                    }
                    else
                    {
                        skuSalesCountInfo.sku_price -= item.enter_qty;
                    }

                    skuPriceBLL.Update(skuSalesCountInfo);
                }
            }
        }
        protected override GetSalesReturnListRD ProcessRequest(DTO.Base.APIRequest <GetSalesReturnListRP> pRequest)
        {
            var rd             = new GetSalesReturnListRD();
            var para           = pRequest.Parameters;
            var salesReturnBLL = new T_SalesReturnBLL(CurrentUserInfo);

            var inoutService    = new InoutService(CurrentUserInfo);
            var tInoutDetailBll = new TInoutDetailBLL(CurrentUserInfo);

            //查询参数
            List <IWhereCondition> complexCondition = new List <IWhereCondition> {
            };

            complexCondition.Add(new EqualsCondition()
            {
                FieldName = "r.VipID", Value = CurrentUserInfo.UserID
            });

            //排序参数
            List <OrderBy> lstOrder = new List <OrderBy> {
            };

            lstOrder.Add(new OrderBy()
            {
                FieldName = "r.CreateTime", Direction = OrderByDirections.Desc
            });

            var tempList = salesReturnBLL.PagedQuery(complexCondition.ToArray(), lstOrder.ToArray(), para.PageSize, para.PageIndex + 1);//没有当前用户,就传空

            rd.TotalPageCount = tempList.PageCount;
            rd.TotalCount     = tempList.RowCount;

            List <SalesReturnInfo> salesReturnList = new List <SalesReturnInfo> {
            };
            SalesReturnInfo salesReturnInfo        = null;
            SkuDetailInfo   skuDetail = null;

            foreach (var item in tempList.Entities)
            {
                salesReturnInfo = new SalesReturnInfo();

                //根据订单ID获取订单明细[复用]
                DataRow drItem = inoutService.GetOrderDetailByOrderId(item.OrderID).Tables[0].Select(" item_id= '" + item.ItemID + "'").FirstOrDefault();
                //获取商品的图片[复用]
                string itemImage = tInoutDetailBll.GetOrderDetailImageList("'" + item.ItemID + "'").Tables[0].Rows[0]["imageUrl"].ToString();
                //获取订单详细列表中的商品规格[复用]
                DataRow[] drSku = inoutService.GetInoutDetailGgByOrderId(item.OrderID).Tables[0].Select(" sku_id='" + item.SkuID + "'");

                salesReturnInfo.SalesReturnID = item.SalesReturnID.ToString();
                salesReturnInfo.SalesReturnNo = item.SalesReturnNo;
                salesReturnInfo.ItemName      = drItem["item_name"].ToString();
                salesReturnInfo.SalesPrice    = Convert.ToDecimal(drItem["enter_price"]);
                salesReturnInfo.Qty           = item.Qty;
                salesReturnInfo.Status        = item.Status;
                salesReturnInfo.ImageUrl      = ImagePathUtil.GetImagePathStr(itemImage, "240");
                salesReturnInfo.ServicesType  = item.ServicesType;

                if (drSku.Count() > 0)
                {
                    skuDetail                 = new SkuDetailInfo();
                    skuDetail.PropName1       = drSku[0]["prop_1_name"].ToString();
                    skuDetail.PropDetailName1 = drSku[0]["prop_1_detail_name"].ToString();
                    skuDetail.PropName2       = drSku[0]["prop_2_name"].ToString();
                    skuDetail.PropDetailName2 = drSku[0]["prop_2_detail_name"].ToString();
                    skuDetail.PropName3       = drSku[0]["prop_3_name"].ToString();
                    skuDetail.PropDetailName3 = drSku[0]["prop_3_detail_name"].ToString();
                    salesReturnInfo.SkuDetail = skuDetail;
                }
                salesReturnList.Add(salesReturnInfo);
            }

            rd.SalesReturnList = salesReturnList.ToArray();
            rd.TotalCount      = tempList.RowCount;
            rd.TotalPageCount  = tempList.PageCount;
            return(rd);
        }
        protected override GetRefundOrderDetailRD ProcessRequest(DTO.Base.APIRequest <GetRefundOrderDetailRP> pRequest)
        {
            var rd   = new GetRefundOrderDetailRD();
            var para = pRequest.Parameters;

            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            var refundOrderBLL     = new T_RefundOrderBLL(loggingSessionInfo);

            var inoutService    = new InoutService(loggingSessionInfo);
            var tInoutDetailBll = new TInoutDetailBLL(loggingSessionInfo);
            var t_InoutBLL      = new T_InoutBLL(loggingSessionInfo);
            var PaymentTtpeBLL  = new T_Payment_TypeBLL(loggingSessionInfo);
            var refundEntity    = refundOrderBLL.GetByID(para.RefundID);

            if (refundEntity != null)
            {
                rd.RefundID           = refundEntity.RefundID;
                rd.RefundNo           = refundEntity.RefundNo;
                rd.Status             = refundEntity.Status;
                rd.OrderNo            = refundEntity.OrderNo;
                rd.Contacts           = refundEntity.Contacts;
                rd.Phone              = refundEntity.Phone;
                rd.ConfirmAmount      = refundEntity.ConfirmAmount;
                rd.ActualRefundAmount = refundEntity.ActualRefundAmount;
                rd.Points             = refundEntity.Points == null ? 0 : refundEntity.Points;
                rd.PointsAmount       = refundEntity.PointsAmount == null ? 0 : refundEntity.PointsAmount;
                rd.ReturnAmount       = refundEntity.ReturnAmount == null ? 0 : refundEntity.RefundAmount;
                rd.Amount             = refundEntity.Amount == null ? 0 : refundEntity.Amount;

                //支付方式名称
                var    OrderData     = t_InoutBLL.GetByID(refundEntity.OrderID);
                string m_PayTypeName = "";
                if (OrderData != null)
                {
                    var PayTypeData = PaymentTtpeBLL.GetByID(OrderData.pay_id);
                    if (PayTypeData != null)
                    {
                        m_PayTypeName = PayTypeData.Payment_Type_Name;
                    }
                }
                rd.PayTypeName = m_PayTypeName;


                rd.PayOrderID = refundEntity.PayOrderID;
                rd.OrderID    = refundEntity.OrderID;
                rd.ItemID     = refundEntity.ItemID;

                if (!string.IsNullOrEmpty(refundEntity.ItemID)) //取消订单时,直接跳转到订单详情
                {
                    //根据订单ID获取订单明细[复用]
                    DataRow drItem = inoutService.GetOrderDetailByOrderId(refundEntity.OrderID).Tables[0].Select(" item_id= '" + refundEntity.ItemID + "'").FirstOrDefault();
                    //获取商品的图片[复用]
                    string  itemImage = string.Empty;
                    DataSet ds        = tInoutDetailBll.GetOrderDetailImageList("'" + refundEntity.ItemID + "'");
                    if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                    {
                        itemImage = ds.Tables[0].Rows[0]["imageUrl"].ToString();
                    }
                    //获取订单详细列表中的商品规格[复用]
                    DataRow[] drSku = inoutService.GetInoutDetailGgByOrderId(refundEntity.OrderID).Tables[0].Select(" sku_id='" + refundEntity.SkuID + "'");

                    //订单的商品信息
                    var orderDetail = new OrderInfoDetail();

                    orderDetail.ItemName   = drItem["item_name"].ToString();
                    orderDetail.SalesPrice = Convert.ToDecimal(drItem["enter_price"]);
                    orderDetail.Qty        = Convert.ToInt32(drItem["enter_qty"]);
                    if (!string.IsNullOrEmpty(itemImage))
                    {
                        orderDetail.ImageUrl = ImagePathUtil.GetImagePathStr(itemImage, "240");
                    }
                    rd.OrderDetail = orderDetail;
                    //订单的商品规格
                    if (drSku.Count() > 0)
                    {
                        SkuDetailInfo skuDetail = new SkuDetailInfo();
                        skuDetail.PropName1       = drSku[0]["prop_1_name"].ToString();
                        skuDetail.PropDetailName1 = drSku[0]["prop_1_detail_name"].ToString();
                        skuDetail.PropName2       = drSku[0]["prop_2_name"].ToString();
                        skuDetail.PropDetailName2 = drSku[0]["prop_2_detail_name"].ToString();
                        skuDetail.PropName3       = drSku[0]["prop_3_name"].ToString();
                        skuDetail.PropDetailName3 = drSku[0]["prop_3_detail_name"].ToString();
                        rd.OrderDetail.SkuDetail  = skuDetail;
                    }
                }
            }
            return(rd);
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            var OrderID     = context.Request["OrderID"];
            var OrderStatus = context.Request["OrderStatus"];
            var CustomerID  = context.Request["CustomerID"];
            var UserID      = context.Request["UserID"];
            var ChannelID   = context.Request["ChannelID"];
            var SerialPay   = context.Request["SerialPay"];

            try
            {
                if (string.IsNullOrEmpty(OrderID) || string.IsNullOrEmpty(OrderStatus) || string.IsNullOrEmpty(CustomerID) || string.IsNullOrEmpty(UserID) || string.IsNullOrEmpty(ChannelID))
                {
                    throw new Exception("参数不全:OrderID,OrderStatus,CustomerID,UserID");
                }
                else
                {
                    if (OrderStatus == "2")
                    {
                        //支付成功,更新卡的支付状态
                        //OrderID就是VIPCardID
                        //
                        //var rp = pRequest.DeserializeJSONTo<APIRequest<SetVipCardRP>>();

                        //if (string.IsNullOrEmpty(rp.Parameters.PayID))
                        //{
                        //    throw new APIException("缺少参数【PayID】或参数值为空") { ErrorCode = 135 };
                        //}
                        var loggingSessionInfo = Default.GetBSLoggingSession(CustomerID, UserID);
                        //会员
                        var vipBll               = new VipBLL(loggingSessionInfo);
                        var vipAmountBll         = new VipAmountBLL(loggingSessionInfo);
                        var vipCardVipMappingBll = new VipCardVipMappingBLL(loggingSessionInfo);
                        //支付
                        var tPaymentTypeCustomerMappingBll = new TPaymentTypeCustomerMappingBLL(loggingSessionInfo);
                        var tPaymentTypeBll  = new T_Payment_TypeBLL(loggingSessionInfo);
                        var paymentDetailBll = new T_Payment_detailBLL(loggingSessionInfo);
                        //门店
                        var unitBLL = new t_unitBLL(loggingSessionInfo);
                        //商品订单支付
                        //更新积分和状态
                        //var loggingSessionInfo = Default.GetBSLoggingSession(CustomerID, "1");
                        var inoutBll = new T_InoutBLL(loggingSessionInfo);//订单业务对象实例化

                        var trrBll = new T_RewardRecordBLL(loggingSessionInfo);
                        //辨别打赏订单
                        var rewardOrderPrefix = "REWARD|";
                        if (OrderID.Contains(rewardOrderPrefix))
                        {
                            OrderID = OrderID.Substring(rewardOrderPrefix.Length, OrderID.Length - rewardOrderPrefix.Length);
                            var trrEntity = trrBll.GetByID(OrderID);
                            trrEntity.PayStatus      = 2;
                            trrEntity.LastUpdateTime = DateTime.Now;
                            trrEntity.LastUpdateBy   = loggingSessionInfo.UserID;
                            trrBll.Update(trrEntity);

                            #region 员工余额变更--需要独立出来处理
                            var userAmountBll = new VipAmountBLL(loggingSessionInfo);                                 //作为员工余额使用
                            var employeeId    = trrEntity.RewardedOP;
                            var rewardAmount  = trrEntity.RewardAmount == null ? 0 : (decimal)trrEntity.RewardAmount; //转为非null的decimal类型
                            //门店
                            var unitService = new UnitService(loggingSessionInfo);
                            var unitInfo    = unitService.GetUnitByUser(CustomerID, employeeId).FirstOrDefault();//获取员工所属门店

                            var tran = userAmountBll.GetTran();
                            using (tran.Connection)//事务
                            {
                                try
                                {
                                    var userAmountEntity = userAmountBll.GetByID(trrEntity.RewardedOP);
                                    if (userAmountEntity == null)
                                    {
                                        //创建
                                        userAmountEntity = new VipAmountEntity
                                        {
                                            VipId                  = employeeId,//员工ID
                                            VipCardCode            = string.Empty,
                                            BeginAmount            = 0,
                                            InAmount               = rewardAmount,
                                            OutAmount              = 0,
                                            EndAmount              = rewardAmount,
                                            TotalAmount            = rewardAmount,
                                            BeginReturnAmount      = 0,
                                            InReturnAmount         = 0,
                                            OutReturnAmount        = 0,
                                            ReturnAmount           = 0,
                                            ImminentInvalidRAmount = 0,
                                            InvalidReturnAmount    = 0,
                                            ValidReturnAmount      = 0,
                                            TotalReturnAmount      = 0,
                                            IsLocking              = 0,
                                            CustomerID             = CustomerID
                                        };
                                        userAmountBll.Create(userAmountEntity, tran);//创建员工余额表
                                    }
                                    else
                                    {
                                        //修改
                                        if (rewardAmount > 0)
                                        {
                                            userAmountEntity.InAmount    = (userAmountEntity.InAmount == null ? 0 : userAmountEntity.InAmount.Value) + rewardAmount;
                                            userAmountEntity.TotalAmount = (userAmountEntity.TotalAmount == null ? 0 : userAmountEntity.TotalAmount.Value) + rewardAmount;
                                        }
                                        else
                                        {
                                            userAmountEntity.OutAmount = (userAmountEntity.OutAmount == null ? 0 : userAmountEntity.OutAmount.Value) + Math.Abs(rewardAmount);
                                        }
                                        userAmountEntity.EndAmount = (userAmountEntity.EndAmount == null ? 0 : userAmountEntity.EndAmount.Value) + rewardAmount;

                                        userAmountBll.Update(userAmountEntity, tran);//更新余额
                                    }

                                    var vipamountDetailBll    = new VipAmountDetailBLL(loggingSessionInfo);
                                    var vipAmountDetailEntity = new VipAmountDetailEntity
                                    {
                                        VipAmountDetailId = Guid.NewGuid(),
                                        VipCardCode       = string.Empty,
                                        VipId             = employeeId,//员工ID
                                        UnitID            = unitInfo != null ? unitInfo.unit_id : string.Empty,
                                        UnitName          = unitInfo != null ? unitInfo.Name : string.Empty,
                                        Amount            = rewardAmount,
                                        UsedReturnAmount  = 0,
                                        EffectiveDate     = DateTime.Now,
                                        DeadlineDate      = Convert.ToDateTime("9999-12-31 23:59:59"),
                                        AmountSourceId    = "26",
                                        Reason            = "Reward",
                                        CustomerID        = CustomerID
                                    };
                                    vipamountDetailBll.Create(vipAmountDetailEntity, tran); //创建余额详情

                                    tran.Commit();                                          //提交事务
                                }
                                catch (Exception ex)
                                {
                                    tran.Rollback();
                                    Loggers.Debug(new DebugLogInfo()
                                    {
                                        Message = "异常-->支付成功回调时更新会员打赏金额出错(PayNotify.ashx):" + ex
                                    });
                                }
                            }
                            #endregion

                            if (trrEntity != null)
                            {
                                context.Response.Write("SUCCESS");
                            }
                            else
                            {
                                context.Response.Write("FAIL");
                            }
                            return;
                        }
                        //获取会员信息
                        var vipInfo = vipBll.GetByID(loggingSessionInfo.UserID);
                        //支付信息 Bear
                        //var tPaymentTypeCustomerMappingEntity = tPaymentTypeCustomerMappingBll.QueryByEntity(new TPaymentTypeCustomerMappingEntity(){ChannelId = ChannelID,CustomerId = loggingSessionInfo.ClientID },null).FirstOrDefault();
                        var paymentTypeList = tPaymentTypeBll.GetAll();
                        var tPaymentType    =
                            paymentTypeList.ToList()
                            .Find(t => t.Payment_Type_Code == "WXJS");

                        //var tPaymentType = tPaymentTypeBll.GetByID(tPaymentTypeCustomerMappingEntity.PaymentTypeID);
                        //获取订单信息
                        var inoutInfo = inoutBll.GetByID(OrderID);
                        if (inoutInfo != null)
                        {
                            var    bll = new TInOutStatusNodeBLL(loggingSessionInfo);
                            string msg;
                            if (!bll.SetOrderPayment(OrderID, out msg, ChannelID, SerialPay))
                            //if (!bll.SetOrderPayment(OrderID, out msg, ChannelID))
                            {
                                throw new Exception(msg);
                            }
                            else if (string.IsNullOrEmpty(inoutInfo.Field17) && string.IsNullOrEmpty(inoutInfo.Field18))
                            {
                                #region 发送订单支付成功微信模板消息
                                var SuccessCommonBLL = new CommonBLL();
                                //SuccessCommonBLL.SentPaymentMessage(inoutInfo, vipInfo.WeiXinUserId,vipInfo.VIPID, loggingSessionInfo);
                                new SendOrderPaySuccessMsgBLL().SentPaymentMessage(inoutInfo, vipInfo.WeiXinUserId, vipInfo.VIPID, loggingSessionInfo);
                                #endregion
                                Loggers.Debug(new DebugLogInfo()
                                {
                                    Message = "调用SetOrderPayment方法更新订单成功"
                                });
                            }
                            //获取订单信息,根据Field3==1判断,如果是ALD订单,则调用ALD接口更新ALD订单的状态
                            #region 更新ALD状态
                            //var orderbll = new InoutService(loggingSessionInfo);
                            //var orderInfo = orderbll.GetInoutInfoById(OrderID);
                            //if (orderInfo.Field3 == "1")
                            //{
                            //    Loggers.Debug(new DebugLogInfo() { Message = string.Format("更新O2OMarketing订单状态成功[OrderID={0}].", OrderID) });
                            //    //更新阿拉丁的订单状态
                            //    JIT.CPOS.Web.OnlineShopping.data.DataOnlineShoppingHandler.ALDChangeOrderStatus aldChangeOrder = new data.DataOnlineShoppingHandler.ALDChangeOrderStatus();
                            //    if (string.IsNullOrEmpty(orderInfo.vip_no))
                            //        throw new Exception("会员ID不能为空,OrderID:" + OrderID);
                            //    aldChangeOrder.MemberID = new Guid(orderInfo.vip_no);
                            //    aldChangeOrder.SourceOrdersID = OrderID;
                            //    aldChangeOrder.Status = int.Parse(orderInfo.status);
                            //    aldChangeOrder.IsPaid = true;
                            //    JIT.CPOS.Web.OnlineShopping.data.DataOnlineShoppingHandler.ALDChangeOrderStatusRequest aldRequest = new data.DataOnlineShoppingHandler.ALDChangeOrderStatusRequest();
                            //    aldRequest.BusinessZoneID = 1;//写死
                            //    aldRequest.Locale = 1;

                            //    aldRequest.UserID = new Guid(orderInfo.vip_no);
                            //    aldRequest.Parameters = aldChangeOrder;
                            //    var url = ConfigurationManager.AppSettings["ALDGatewayURL"];
                            //    var postContent = string.Format("Action=ChangeOrderStatus&ReqContent={0}", aldRequest.ToJSON());
                            //    Loggers.Debug(new DebugLogInfo() { Message = "通知ALD更改状态:" + postContent });
                            //    var strAldRsp = HttpWebClient.DoHttpRequest(url, postContent);
                            //    var aldRsp = strAldRsp.DeserializeJSONTo<JIT.CPOS.Web.OnlineShopping.data.DataOnlineShoppingHandler.ALDResponse>();
                            //    if (!aldRsp.IsSuccess())
                            //    {
                            //        Loggers.Debug(new DebugLogInfo() { Message = string.Format("更新阿拉丁订单状态失败[Request ={0}][Response={1}]", aldRequest.ToJSON(), strAldRsp) });
                            //    }
                            //}
                            #endregion

                            #region 格力推送通知
                            //try
                            //{
                            //    GLServiceOrderBLL glsobll = new GLServiceOrderBLL(loggingSessionInfo);
                            //    if (glsobll.ValidateGree(CustomerID, "cpos_bs_lj"))//先写死
                            //        glsobll.GreePushPaymentOorder(CustomerID, OrderID, loggingSessionInfo);
                            //}
                            //catch (Exception ex)
                            //{
                            //    Loggers.Debug(new DebugLogInfo() { Message = string.Format("付款推送评价师傅链接失败[OrderID={0}].", OrderID) });
                            //}
                            #endregion

                            #region ALD生活服务处理
                            //var rechargeBll = new RechargeStrategyBLL(loggingSessionInfo);
                            //var vipAmountBll = new VipAmountBLL(loggingSessionInfo);
                            //var couponBll = new CouponBLL(loggingSessionInfo);
                            //var vipCouponMappingBll = new VipCouponMappingBLL(loggingSessionInfo);
                            //var unitBll = new UnitBLL(loggingSessionInfo);
                            //DataSet dsOrderInfo = rechargeBll.GetInoutOrderItems(OrderID);
                            //int itemSort = 0;            //商品业务分类
                            //string skuId = string.Empty; //商品SkuId
                            //string vipId = string.Empty; //会员ID
                            //string itemId = string.Empty;//商品ID
                            //string couponId = string.Empty;//优惠券ID
                            //if (dsOrderInfo.Tables[0].Rows.Count > 0)
                            //{
                            //    //if (dsOrderInfo.Tables[0].Rows[0]["ItemSort"] != DBNull.Value && Convert.ToString(dsOrderInfo.Tables[0].Rows[0]["ItemSort"]) != "0")
                            //    itemSort = int.Parse(dsOrderInfo.Tables[0].Rows[0]["ItemSort"].ToString());
                            //    switch (itemSort)
                            //    {
                            //        case 2://充
                            //            #region 充值金额处理

                            //            VipAmountDetailBLL vipAmountDetailBll = new VipAmountDetailBLL(loggingSessionInfo);

                            //            List<IWhereCondition> complexCondition = new List<IWhereCondition> { };
                            //            complexCondition.Add(new EqualsCondition() { FieldName = "ObjectId", Value = OrderID });

                            //            var vipAmountDetal = vipAmountDetailBll.Query(complexCondition.ToArray(), null);
                            //            if (vipAmountDetal.Count() == 0)//确认没有多次执行回调
                            //            {
                            //                ////查询
                            //                //RechargeStrategyEntity[] rechargeList = rechargeBll.Query(complexCondition.ToArray(), lstOrder.ToArray());

                            //                skuId = dsOrderInfo.Tables[0].Rows[0]["SkuId"].ToString();
                            //                //RechargeStrategyEntity rechargeEntity = rechargeBll.GetByID(skuId);
                            //                DataSet dsSkuPirce = unitBll.GetSkuPirce(skuId);
                            //                decimal salePrice = 0;//购买金额
                            //                decimal returnCash = 0;//奖励金额
                            //                if (dsSkuPirce.Tables[0].Rows.Count > 0)
                            //                {
                            //                    salePrice = Convert.ToDecimal(dsSkuPirce.Tables[0].Rows[0]["SalesPrice"].ToString());
                            //                    returnCash = Convert.ToDecimal(dsSkuPirce.Tables[0].Rows[0]["ReturnCash"].ToString());
                            //                    InoutService server = new InoutService(loggingSessionInfo);
                            //                    #region 充值金额
                            //                    var tran = server.GetTran();
                            //                    using (tran.Connection)//事物
                            //                    {
                            //                        try
                            //                        {
                            //                            //充值金额
                            //                            vipAmountBll.AddVipEndAmount(UserID, salePrice, tran, "4", OrderID, loggingSessionInfo);//4=充值
                            //                            tran.Commit();
                            //                        }
                            //                        catch (Exception)
                            //                        {
                            //                            tran.Rollback();
                            //                            throw;
                            //                        }
                            //                    }
                            //                    #endregion

                            //                    #region 奖励金额
                            //                    var tran2 = server.GetTran();
                            //                    using (tran2.Connection)//事物
                            //                    {
                            //                        try
                            //                        {
                            //                            //奖励金额
                            //                            vipAmountBll.AddVipEndAmount(UserID, returnCash, tran2, "6", OrderID, loggingSessionInfo);//6=奖励金额
                            //                            tran2.Commit();
                            //                        }
                            //                        catch (Exception)
                            //                        {
                            //                            tran2.Rollback();
                            //                            throw;
                            //                        }
                            //                    }
                            //                    #endregion
                            //                }
                            //            }
                            //            #endregion
                            //            break;
                            //        case 3://券
                            //            #region 券类商品绑定到会员
                            //            itemId = dsOrderInfo.Tables[0].Rows[0]["ItemId"].ToString();
                            //            vipId = dsOrderInfo.Tables[0].Rows[0]["VipId"].ToString();
                            //            couponId = couponBll.GetCouponByItemId(itemId);
                            //            if (!string.IsNullOrEmpty(couponId))
                            //            {
                            //                VipCouponMappingEntity coupon = new VipCouponMappingEntity
                            //                {
                            //                    VIPID = vipId,
                            //                    CouponID = couponId,
                            //                };
                            //                vipCouponMappingBll.Create(coupon);
                            //            }
                            //            #endregion
                            //            break;
                            //        default:
                            //            break;
                            //    }
                            //}

                            #endregion

                            #region 订单与分润关系处理 add by Henry 2014-10-10
                            //var orderSubBll = new OrderOrderSubRunObjectMappingBLL(loggingSessionInfo);
                            //dynamic o = orderSubBll.SetOrderSub(CustomerID, OrderID);
                            //Type t = o.GetType();
                            //var Desc = t.GetProperty("Desc").GetValue(o, null).ToString();
                            //var IsSuccess = t.GetProperty("IsSuccess").GetValue(o, null).ToString();
                            //if (int.Parse(IsSuccess.ToString()) == 0) //失败
                            //    Loggers.Debug(new DebugLogInfo() { Message = string.Format("订单与分润关系处理失败:{0}", Desc) });
                            #endregion

                            CustomerBasicSettingBLL customerBasicSettingBll = new CustomerBasicSettingBLL(loggingSessionInfo);
                            string AfterPaySetStock = customerBasicSettingBll.GetSettingValueByCode("AfterPaySetStock");
                            if (AfterPaySetStock == "1")
                            {
                                var inoutServiceBLL = new InoutService(loggingSessionInfo);
                                var inoutDetailList = inoutServiceBLL.GetInoutDetailInfoByOrderId(OrderID);
                                inoutBll.SetStock(OrderID, inoutDetailList, 1, loggingSessionInfo);
                            }
                            ///超级分销商订单入队列
                            if (inoutInfo.data_from_id == "35" || inoutInfo.data_from_id == "36")
                            {
                                BS.BLL.RedisOperationBLL.Order.SuperRetailTraderOrderBLL bllSuperRetailTraderOrder = new BS.BLL.RedisOperationBLL.Order.SuperRetailTraderOrderBLL();
                                bllSuperRetailTraderOrder.SetRedisToSuperRetailTraderOrder(loggingSessionInfo, inoutInfo);
                            }

                            //购卡
                            if (!string.IsNullOrEmpty(inoutInfo.Field17) && !string.IsNullOrEmpty(inoutInfo.Field18))
                            {
                                //更新订单状态
                                inoutInfo             = inoutBll.GetByID(OrderID);
                                inoutInfo.Field7      = "700";
                                inoutInfo.status      = "700";
                                inoutInfo.status_desc = "已完成";
                                inoutInfo.Field10     = "已完成";
                                inoutBll.Update(inoutInfo);
                                //会员卡升级
                                vipCardVipMappingBll.BindVirtualItem(vipInfo.VIPID, vipInfo.VipCode, inoutInfo.sales_unit_id, Convert.ToInt32(inoutInfo.Field18), orderId: inoutInfo.order_id);

                                //分润计算
                                RedisSalesVipCardOrderBLL redisSalesVipCardOrderBll = new RedisSalesVipCardOrderBLL();
                                redisSalesVipCardOrderBll.SetRedisSalesVipCardOrder(loggingSessionInfo, inoutInfo);

                                //售卡处理积分、返现、佣金[完成订单]
                                new SendOrderRewardMsgBLL().OrderReward(inoutInfo, loggingSessionInfo, null);//存入到缓存
                            }
                            else
                            {
                                //订单入队列
                                RedisCalculateVipConsumeForUpgrade redisCalculateVipConsumeForUpgrade = new RedisCalculateVipConsumeForUpgrade();
                                redisCalculateVipConsumeForUpgrade.SetVipConsumeForUpgradeList(loggingSessionInfo, inoutInfo);
                            }

                            // add by liangx 2016-09-27 获取订单中的虚拟商品 start
                            CouponTypeBLL            couponTypeBLL            = new CouponTypeBLL(loggingSessionInfo);
                            RedisVipMappingCouponBLL redisVipMappingCouponBLL = new RedisVipMappingCouponBLL();

                            var couponTypes = couponTypeBLL.GetVirtualItemCouponTypes(inoutInfo.order_id);

                            if (couponTypes.Any())
                            {
                                redisVipMappingCouponBLL.SetVipMappingCoupon(couponTypes, "", couponTypes.FirstOrDefault().VipId, "PayVirtualItem");
                            }

                            // add by liangx 2016-09-27 获取订单中的虚拟商品 end

                            //获取门店信息
                            t_unitEntity unitInfo = null;
                            if (!string.IsNullOrEmpty(inoutInfo.sales_unit_id))
                            {
                                unitInfo = unitBLL.GetByID(inoutInfo.sales_unit_id);
                            }
                            //入支付明细表
                            var paymentDetail = new T_Payment_detailEntity()
                            {
                                Payment_Id        = Guid.NewGuid().ToString(),
                                Inout_Id          = inoutInfo.order_id,
                                UnitCode          = unitInfo == null ? "" : unitInfo.unit_code,
                                Payment_Type_Id   = tPaymentType.Payment_Type_Id,
                                Payment_Type_Code = tPaymentType.Payment_Type_Code,
                                Payment_Type_Name = tPaymentType.Payment_Type_Name,
                                Price             = inoutInfo.actual_amount,
                                Total_Amount      = inoutInfo.total_amount,
                                Pay_Points        = inoutInfo.pay_points,
                                CustomerId        = loggingSessionInfo.ClientID
                            };
                            paymentDetailBll.Create(paymentDetail);

                            List <IWhereCondition> complexCondition = new List <IWhereCondition> {
                            };
                            complexCondition.Add(new EqualsCondition()
                            {
                                FieldName = "Inout_Id", Value = inoutInfo.order_id
                            });
                            var paymentDetailList = paymentDetailBll.Query(complexCondition.ToArray(), null);

                            try
                            {
                                var msgRabbitMQ = new EventContract
                                {
                                    Operation  = OptEnum.Create,
                                    EntityType = EntityTypeEnum.Order,
                                    Id         = inoutInfo.order_id
                                };
                                var service = new EventService();
                                service.PublishMsg(msgRabbitMQ);

                                foreach (var detail in paymentDetailList)
                                {
                                    var paymentMQ = new EventContract
                                    {
                                        Operation  = OptEnum.Create,
                                        EntityType = EntityTypeEnum.OrderPayment,
                                        Id         = detail.Payment_Id
                                    };
                                    service.PublishMsg(paymentMQ);
                                }
                            }
                            catch (Exception)
                            {
                                throw new Exception("RabbitMQ Error");
                            }
                        }
                        else//充值订单
                        {
                            var rechargeOrderBll   = new RechargeOrderBLL(loggingSessionInfo);
                            var vipamountDetailBll = new VipAmountDetailBLL(loggingSessionInfo);
                            var rechargeOrderInfo  = rechargeOrderBll.GetByID(OrderID);
                            if (rechargeOrderInfo != null)
                            {
                                //获取门店信息
                                t_unitEntity unitInfo = null;
                                if (!string.IsNullOrEmpty(rechargeOrderInfo.UnitId))
                                {
                                    unitInfo = unitBLL.GetByID(rechargeOrderInfo.UnitId);
                                }
                                //充值
                                rechargeOrderBll.Recharge(rechargeOrderInfo, vipInfo, unitInfo, tPaymentType.Payment_Type_Id);
                                //入支付明细表
                                var paymentDetail = new T_Payment_detailEntity()
                                {
                                    Payment_Id        = Guid.NewGuid().ToString(),
                                    Inout_Id          = rechargeOrderInfo.OrderID.ToString(),
                                    UnitCode          = unitInfo == null ? "" : unitInfo.unit_code,
                                    Payment_Type_Id   = tPaymentType.Payment_Type_Id,
                                    Payment_Type_Code = tPaymentType.Payment_Type_Code,
                                    Payment_Type_Name = tPaymentType.Payment_Type_Name,
                                    Price             = rechargeOrderInfo.ActuallyPaid,
                                    Total_Amount      = rechargeOrderInfo.TotalAmount,
                                    Pay_Points        = rechargeOrderInfo.PayPoints,
                                    CustomerId        = loggingSessionInfo.ClientID
                                };
                                paymentDetailBll.Create(paymentDetail);
                            }
                            else
                            {
                                var receiveAmountOrderBll    = new ReceiveAmountOrderBLL(loggingSessionInfo);
                                var receiveAmountOrderEntity = receiveAmountOrderBll.GetByID(OrderID);



                                //更新订单状态
                                if (receiveAmountOrderEntity != null)
                                {
                                    VipIntegralBLL vipIntegralBll = new VipIntegralBLL(loggingSessionInfo);
                                    //更新订单
                                    receiveAmountOrderEntity.PayStatus = "10";
                                    // Bear
                                    //receiveAmountOrderEntity.PayTypeId = tPaymentTypeCustomerMappingEntity.PaymentTypeID;
                                    receiveAmountOrderEntity.PayTypeId    = tPaymentType.Payment_Type_Id;
                                    receiveAmountOrderEntity.PayDatetTime = DateTime.Now;
                                    receiveAmountOrderBll.Update(receiveAmountOrderEntity);

                                    //获取门店信息
                                    t_unitEntity unitInfo = null;
                                    if (!string.IsNullOrEmpty(receiveAmountOrderEntity.ServiceUnitId))
                                    {
                                        unitInfo = unitBLL.GetByID(receiveAmountOrderEntity.ServiceUnitId);
                                    }


                                    //使用过积分,处理积分
                                    if (receiveAmountOrderEntity.PayPoints != 0 && receiveAmountOrderEntity.PayPoints != null)
                                    {
                                        string sourceId       = "20"; //积分抵扣
                                        var    IntegralDetail = new VipIntegralDetailEntity()
                                        {
                                            Integral         = -Convert.ToInt32(receiveAmountOrderEntity.PayPoints),
                                            IntegralSourceID = sourceId,
                                            ObjectId         = receiveAmountOrderEntity.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, loggingSessionInfo);
                                            //发送微信积分变动通知模板消息
                                            if (!string.IsNullOrWhiteSpace(vipIntegralDetailId))
                                            {
                                                var CommonBLL = new CommonBLL();
                                                CommonBLL.PointsChangeMessage(OldIntegral, vipInfo, ChangeIntegral, vipInfo.WeiXinUserId, loggingSessionInfo);
                                            }
                                        }
                                    }
                                    //if (receiveAmountOrderEntity.CouponUsePay != 0 || receiveAmountOrderEntity.CouponUsePay != null)
                                    //{
                                    //    //更新使用记录
                                    //    var couponUseBll = new CouponUseBLL(loggingSessionInfo);
                                    //    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);

                                    //    var couponBll = new CouponBLL(CurrentUserInfo);
                                    //    var couponEntity = couponBll.GetByID(rp.CouponId);

                                    //    //更新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 (receiveAmountOrderEntity.AmountAcctPay != null && receiveAmountOrderEntity.AmountAcctPay != 0)
                                    {
                                        var vipAmountDetailBll = new VipAmountDetailBLL(loggingSessionInfo);

                                        var vipAmountEntity = vipAmountBll.QueryByEntity(new VipAmountEntity()
                                        {
                                            VipId = vipInfo.VIPID, VipCardCode = vipInfo.VipCode
                                        }, null).FirstOrDefault();
                                        if (vipAmountEntity != null)
                                        {
                                            var detailInfo = new VipAmountDetailEntity()
                                            {
                                                Amount         = -receiveAmountOrderEntity.AmountAcctPay,
                                                AmountSourceId = "1",
                                                ObjectId       = receiveAmountOrderEntity.OrderId.ToString()
                                            };
                                            var vipAmountDetailId = vipAmountBll.AddVipAmount(vipInfo, unitInfo, ref vipAmountEntity, detailInfo, loggingSessionInfo);
                                            if (!string.IsNullOrWhiteSpace(vipAmountDetailId))
                                            {//发送微信账户余额变动模板消息
                                                var CommonBLL = new CommonBLL();
                                                CommonBLL.BalanceChangedMessage(receiveAmountOrderEntity.OrderNo, vipAmountEntity, detailInfo, vipInfo.WeiXinUserId, vipInfo.VIPID, loggingSessionInfo);
                                            }
                                        }
                                    }


                                    //收款订单积分奖励

                                    vipIntegralBll.OrderReward(receiveAmountOrderEntity, null);


                                    var paymentDetail = new T_Payment_detailEntity()
                                    {
                                        Payment_Id        = Guid.NewGuid().ToString(),
                                        Inout_Id          = receiveAmountOrderEntity.OrderId.ToString(),
                                        UnitCode          = unitInfo == null ? "" : unitInfo.unit_code,
                                        Payment_Type_Id   = tPaymentType.Payment_Type_Id,
                                        Payment_Type_Code = tPaymentType.Payment_Type_Code,
                                        Payment_Type_Name = tPaymentType.Payment_Type_Name,
                                        Price             = receiveAmountOrderEntity.TransAmount,
                                        Total_Amount      = receiveAmountOrderEntity.TotalAmount,
                                        Pay_Points        = receiveAmountOrderEntity.PayPoints,
                                        CustomerId        = loggingSessionInfo.ClientID
                                    };
                                    paymentDetailBll.Create(paymentDetail);
                                }
                            }
                        }
                        context.Response.Write("SUCCESS");
                    }
                }
            }
            catch (Exception ex)
            {
                Loggers.Exception(new ExceptionLogInfo(ex));
                context.Response.Write("ERROR:" + ex.Message);
            }
        }
Exemple #15
0
        protected override GetMemberInfoRD ProcessRequest(DTO.Base.APIRequest <GetMemberInfoRP> pRequest)
        {
            GetMemberInfoRD rd = new GetMemberInfoRD();

            rd.MemberInfo = new MemberInfo();
            var vipLoginBLL = new VipBLL(base.CurrentUserInfo);

            //如果有一个查询标识非空,就用查询标识查,发现没有会员就报错
            if (!string.IsNullOrEmpty(pRequest.Parameters.SearchFlag))
            {
                List <IWhereCondition> complexCondition = new List <IWhereCondition> {
                };
                complexCondition.Add(new EqualsCondition()
                {
                    FieldName = "ClientID", Value = CurrentUserInfo.ClientID
                });
                var cond1 = new LikeCondition()
                {
                    FieldName = "VipName", Value = "%" + pRequest.Parameters.SearchFlag + "%"
                };
                var cond2 = new LikeCondition()
                {
                    FieldName = "VipRealName", Value = "%" + pRequest.Parameters.SearchFlag + "%"
                };
                var com1 = new ComplexCondition()
                {
                    Left = cond1, Right = cond2, Operator = LogicalOperators.Or
                };

                var cond3 = new EqualsCondition()
                {
                    FieldName = "Phone", Value = pRequest.Parameters.SearchFlag
                };
                var com2 = new ComplexCondition()
                {
                    Left = com1, Right = cond3, Operator = LogicalOperators.Or
                };
                complexCondition.Add(com2);
                complexCondition.Add(new DirectCondition("(WeiXinUserId!='' Or WeiXinUserId IS NOT NULL)"));
                var tempVipList = vipLoginBLL.Query(complexCondition.ToArray(), null);
                if (tempVipList != null && tempVipList.Length != 0)
                {
                    pRequest.UserID = pRequest.Parameters.MemberID = tempVipList[0].VIPID;
                }
            }

            string m_MemberID = "";

            if (!string.IsNullOrWhiteSpace(pRequest.Parameters.OwnerVipID))
            {
                m_MemberID = string.IsNullOrWhiteSpace(pRequest.Parameters.OwnerVipID) ? pRequest.UserID : pRequest.Parameters.OwnerVipID;
            }
            else
            {
                m_MemberID = string.IsNullOrWhiteSpace(pRequest.Parameters.MemberID) ? pRequest.UserID : pRequest.Parameters.MemberID;
            }

            string UserID       = m_MemberID;
            var    VipLoginInfo = vipLoginBLL.GetByID(UserID);

            if (VipLoginInfo == null)
            {
                throw new APIException("用户不存在")
                      {
                          ErrorCode = 330
                      }
            }
            ;
            #region 20140909 kun.zou 发现状态为0,改为1
            if (VipLoginInfo.Status.HasValue && VipLoginInfo.Status == 0)
            {
                VipLoginInfo.Status = 1;
                vipLoginBLL.Update(VipLoginInfo, false);
                var log = new VipLogEntity()
                {
                    Action       = "更新",
                    ActionRemark = "vip状态为0的改为1.",
                    CreateBy     = UserID,
                    CreateTime   = DateTime.Now,
                    VipID        = VipLoginInfo.VIPID,
                    LogID        = Guid.NewGuid().ToString("N")
                };
                var logBll = new VipLogBLL(base.CurrentUserInfo);
                logBll.Create(log);
            }
            #endregion
            int couponCount = vipLoginBLL.GetVipCoupon(UserID);

            rd.MemberInfo.Mobile      = VipLoginInfo.Phone;      //手机号码
            rd.MemberInfo.Name        = VipLoginInfo.UserName;   //姓名
            rd.MemberInfo.VipID       = VipLoginInfo.VIPID;      //组标识
            rd.MemberInfo.VipName     = VipLoginInfo.VipName;    //会员名
            rd.MemberInfo.ImageUrl    = VipLoginInfo.HeadImgUrl; //会员头像  add by Henry 2014-12-5
            rd.MemberInfo.VipRealName = VipLoginInfo.VipRealName;
            rd.MemberInfo.VipNo       = VipLoginInfo.VipCode;
            rd.MemberInfo.IsDealer    = VipLoginInfo.Col48 != null?int.Parse(VipLoginInfo.Col48) : 0;

            //超级分销体系配置表 为判断是否存在分销体系使用
            var T_SuperRetailTraderConfigbll = new T_SuperRetailTraderConfigBLL(CurrentUserInfo);
            //获取分销体系信息
            var T_SuperRetailTraderConfigInfo = T_SuperRetailTraderConfigbll.QueryByEntity(new T_SuperRetailTraderConfigEntity()
            {
                IsDelete = 0, CustomerId = CurrentUserInfo.CurrentUser.customer_id
            }, null).FirstOrDefault();
            if (T_SuperRetailTraderConfigInfo != null)
            {
                rd.MemberInfo.CanBeSuperRetailTrader = 1;
            }
            else
            {
                rd.MemberInfo.CanBeSuperRetailTrader = 0;
            }
            rd.MemberInfo.SuperRetailTraderID = VipLoginInfo.Col26;
            //rd.MemberInfo.Integration = VipLoginInfo.Integration ?? 0;//会员积分

            #region 会员有效积分
            var vipIntegralBLL  = new VipIntegralBLL(CurrentUserInfo);
            var vipIntegralInfo = vipIntegralBLL.QueryByEntity(new VipIntegralEntity()
            {
                VipID = UserID, VipCardCode = VipLoginInfo.VipCode
            }, null).FirstOrDefault();
            if (vipIntegralInfo != null)
            {
                rd.MemberInfo.Integration = vipIntegralInfo.ValidIntegral != null ? vipIntegralInfo.ValidIntegral.Value : 0;
            }
            #endregion

            //会员等级
            //rd.MemberInfo.VipLevelName = string.IsNullOrEmpty(vipLoginBLL.GetVipLeave(UserID)) ? null : vipLoginBLL.GetVipLeave(UserID);
            #region 会员卡名称
            var                vipCardVipMappingBLL = new VipCardVipMappingBLL(CurrentUserInfo);
            var                vipCardBLL           = new VipCardBLL(CurrentUserInfo);
            var                vipCardTypeBLL       = new SysVipCardTypeBLL(CurrentUserInfo);
            var                vipCardRuleBLL       = new VipCardRuleBLL(CurrentUserInfo);
            var                vipT_InoutBLL        = new T_InoutBLL(CurrentUserInfo);
            VipAmountBLL       vipAmountBLL         = new VipAmountBLL(CurrentUserInfo);
            ShoppingCartBLL    service     = new ShoppingCartBLL(CurrentUserInfo);
            ShoppingCartEntity queryEntity = new ShoppingCartEntity();
            queryEntity.VipId = UserID;
            int totalQty = service.GetListQty(queryEntity);
            rd.MemberInfo.ShopCartCount = totalQty;
            //定义当前自定义等级
            int?CurVipLevel        = 0;
            var vipCardMappingInfo = vipCardVipMappingBLL.QueryByEntity(new VipCardVipMappingEntity()
            {
                VIPID = UserID, CustomerID = CurrentUserInfo.ClientID
            },
                                                                        new OrderBy[] { new OrderBy()
                                                                                        {
                                                                                            FieldName = "CreateTime", Direction = OrderByDirections.Desc
                                                                                        } }).FirstOrDefault();
            if (vipCardMappingInfo != null)
            {
                var vipCardInfo = vipCardBLL.QueryByEntity(new VipCardEntity()
                {
                    VipCardID = vipCardMappingInfo.VipCardID, VipCardStatusId = 1
                }, null).FirstOrDefault();
                if (vipCardInfo != null)
                {
                    var vipCardTypeInfo = vipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity()
                    {
                        VipCardTypeID = vipCardInfo.VipCardTypeID
                    }, null).FirstOrDefault();
                    if (vipCardTypeInfo != null)
                    {
                        rd.MemberInfo.VipLevelName     = vipCardTypeInfo.VipCardTypeName != null ? vipCardTypeInfo.VipCardTypeName : "";
                        rd.MemberInfo.CardTypeImageUrl = vipCardTypeInfo.PicUrl != null ? vipCardTypeInfo.PicUrl : "";
                        rd.MemberInfo.CardTypePrice    = vipCardTypeInfo.Prices != null ? vipCardTypeInfo.Prices.Value : 0;
                        rd.MemberInfo.IsExtraMoney     = vipCardTypeInfo.IsExtraMoney != null ? vipCardTypeInfo.IsExtraMoney : 0;
                        CurVipLevel             = vipCardTypeInfo.VipCardLevel;
                        rd.MemberInfo.IsPrepaid = vipCardTypeInfo.Isprepaid;
                        if (CurVipLevel > 1)
                        {
                            var VipCardTypeSysInfo = vipCardTypeBLL.GetBindVipCardTypeInfo(CurrentUserInfo.ClientID, VipLoginInfo.Phone, pRequest.UserID, CurVipLevel);
                            if (VipCardTypeSysInfo == null || VipCardTypeSysInfo.Tables[0].Rows.Count == 0)
                            {
                                rd.MemberInfo.IsNeedCard = 2;
                            }
                        }
                        else
                        {
                            rd.MemberInfo.IsNeedCard = 1;
                        }
                        //因为卡等级不能重复,知道当前等级后查找相应的下一级是否是自动升级(消费升级)
                        var NextVipCardTypeInfo = vipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity()
                        {
                            VipCardLevel = CurVipLevel + 1, CustomerID = CurrentUserInfo.ClientID
                        }, null).FirstOrDefault();
                        if (NextVipCardTypeInfo != null)
                        {
                            //获取当前会员的消费金额信息
                            decimal CurVipConsumptionAmount = 0;
                            decimal VipConsumptionInfo      = vipT_InoutBLL.GetVipSumAmount(UserID);
                            if (VipConsumptionInfo > 0)
                            {
                                CurVipConsumptionAmount = Convert.ToDecimal(Convert.ToDecimal(VipConsumptionInfo).ToString("0.00"));
                            }
                            //知道下一等级后要判断,升级条件是否是消费升级
                            //定义累积消费金额
                            decimal AccumulatedAmount      = 0;
                            var     vipCardTypeUpGradeInfo = vipCardTypeBLL.GetVipCardTypeUpGradeInfo(CurrentUserInfo.ClientID, CurVipLevel);
                            if (vipCardTypeUpGradeInfo != null && vipCardTypeUpGradeInfo.Tables[0].Rows.Count > 0)
                            {
                                //判断拉取的所有卡等级里的最近的一级满足条件即可返回提示所需的值
                                int flag = 0;
                                foreach (DataRow dr in vipCardTypeUpGradeInfo.Tables[0].Rows)
                                {
                                    AccumulatedAmount = Convert.ToDecimal(Convert.ToDecimal(dr["BuyAmount"].ToString()).ToString("0.00"));
                                    //获取消费升级还需多少钱
                                    if (AccumulatedAmount > CurVipConsumptionAmount && flag == 0)
                                    {
                                        flag = 1;
                                        rd.MemberInfo.UpGradeNeedMoney = AccumulatedAmount - CurVipConsumptionAmount;
                                        if (rd.MemberInfo.UpGradeNeedMoney > 0)
                                        {
                                            rd.MemberInfo.UpgradePrompt = "还需要消费" + rd.MemberInfo.UpGradeNeedMoney + "元可以升级啦,快点通知会员!";
                                        }
                                    }
                                }
                            }
                        }

                        var VipCardRuleInfo = vipCardRuleBLL.QueryByEntity(new VipCardRuleEntity()
                        {
                            CustomerID = CurrentUserInfo.ClientID, VipCardTypeID = vipCardTypeInfo.VipCardTypeID
                        }, null).FirstOrDefault();
                        if (VipCardRuleInfo != null)
                        {
                            rd.MemberInfo.CardDiscount = Convert.ToDecimal(Convert.ToDecimal((VipCardRuleInfo.CardDiscount / 10)).ToString("0.00"));
                        }
                    }
                }
            }
            else
            {
                //表示需要领卡,并展示等级为1的默认卡
                rd.MemberInfo.IsNeedCard = 0;
                var VipCardTypeData = vipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity()
                {
                    VipCardLevel = 1, CustomerID = CurrentUserInfo.ClientID
                }, null).FirstOrDefault();
                if (VipCardTypeData != null)
                {
                    rd.MemberInfo.CardTypeImageUrl = VipCardTypeData.PicUrl != null ? VipCardTypeData.PicUrl : "";
                }
            }
            //获取红利/// decimal[0]=总收入(红利) decimal[2]=支出余额 decimal[1]=总提现金额
            decimal[] array = vipAmountBLL.GetVipSumAmountByCondition(UserID, CurrentUserInfo.ClientID, true);
            if (array[0] != null)
            {
                rd.MemberInfo.ProfitAmount = array[0];
            }
            //是否有付费的会员卡
            List <IWhereCondition> freeCardCon = new List <IWhereCondition> {
            };
            freeCardCon.Add(new EqualsCondition()
            {
                FieldName = "CustomerID", Value = CurrentUserInfo.ClientID
            });
            freeCardCon.Add(new DirectCondition("Prices>0"));
            var freeCardTypeInfo = vipCardTypeBLL.Query(freeCardCon.ToArray(), null).FirstOrDefault();
            if (freeCardTypeInfo != null)
            {
                rd.MemberInfo.IsCostCardType = 1;
            }
            else
            {
                rd.MemberInfo.IsCostCardType = 0;
            }

            #endregion

            rd.MemberInfo.Status       = VipLoginInfo.Status.HasValue ? VipLoginInfo.Status.Value : 1;
            rd.MemberInfo.CouponsCount = couponCount;
            rd.MemberInfo.IsActivate   = (VipLoginInfo.IsActivate.HasValue && VipLoginInfo.IsActivate.Value == 1 ? true : false);
            var customerBasicSettingBll = new CustomerBasicSettingBLL(CurrentUserInfo);
            rd.MemberInfo.MemberBenefits = customerBasicSettingBll.GetMemberBenefits(pRequest.CustomerID);



            //获取标签信息
            TagsBLL TagsBLL = new TagsBLL(base.CurrentUserInfo);


            var dsIdentity = TagsBLL.GetVipTagsList("", UserID);//“车主标签”  传7
            if (dsIdentity != null && dsIdentity.Tables.Count > 0 && dsIdentity.Tables[0].Rows.Count > 0)
            {
                rd.IdentityTagsList = DataTableToObject.ConvertToList <TagsInfo>(dsIdentity.Tables[0]).ToArray(); //“年龄段”  传8
            }


            #region 获取注册表单的列明和值

            var vipEntity = vipLoginBLL.QueryByEntity(new VipEntity()
            {
                VIPID = UserID
            }, null);

            if (vipEntity == null || vipEntity.Length == 0)
            {
                return(rd);
            }
            else
            {
                var ds = vipLoginBLL.GetVipColumnInfo(CurrentUserInfo.ClientID, "online005");

                var vipDs = vipLoginBLL.GetVipInfo(UserID);

                if (ds.Tables[0].Rows.Count > 0)
                {
                    var temp = ds.Tables[0].AsEnumerable().Select(t => new MemberControlInfo()
                    {
                        ColumnName  = t["ColumnName"].ToString(),
                        ControlType = Convert.ToInt32(t["ControlType"]),
                        ColumnValue = vipDs.Tables[0].Rows[0][t["ColumnName"].ToString()].ToString(),
                        ColumnDesc  = t["columnDesc"].ToString()
                    });

                    rd.MemberControlList = temp.ToArray();
                }
            }

            //var vipamountBll = new VipAmountBLL(this.CurrentUserInfo);

            //var vipAmountEntity = vipamountBll.GetByID(UserID);


            var unitBll = new UnitBLL(this.CurrentUserInfo);
            //Hashtable htPara = new Hashtable();
            //htPara["MemberID"] = UserID;
            //htPara["CustomerID"] = CurrentUserInfo.ClientID;
            //htPara["PageIndex"] = 1;
            //htPara["PageSize"] = 10;
            //DataSet dsMyAccount = unitBll.GetMyAccount(htPara);

            //if (dsMyAccount.Tables[0].Rows.Count > 0)
            //{
            //    //rd.AccountList = DataTableToObject.ConvertToList<AccountInfo>(dsMyAccount.Tables[0]);
            //    //rd.MemberInfo.Balance = Convert.ToDecimal(dsMyAccount.Tables[0].Rows[0]["Total"].ToString());
            //    //rd.TotalPageCount = int.Parse(dsMyAccount.Tables[0].Rows[0]["PageCount"].ToString());

            //}
            //else
            //    rd.MemberInfo.Balance = 0;

            //返现 add by Henry 2015-4-15
            var vipAmountBll = new VipAmountBLL(CurrentUserInfo);
            //var vipAmountInfo = vipAmountBll.GetByID(UserID);
            var vipAmountInfo = vipAmountBll.QueryByEntity(new VipAmountEntity()
            {
                VipId = UserID, VipCardCode = VipLoginInfo.VipCode
            }, null).FirstOrDefault();
            decimal returnAmount = 0;
            decimal amount       = 0;
            if (vipAmountInfo != null)
            {
                returnAmount = vipAmountInfo.ValidReturnAmount == null ? 0 : vipAmountInfo.ValidReturnAmount.Value;
                amount       = vipAmountInfo.EndAmount == null ? 0 : vipAmountInfo.EndAmount.Value;
            }
            rd.MemberInfo.ReturnAmount = returnAmount; //返现
            rd.MemberInfo.Balance      = amount;       //余额
            #endregion


            //获取订单的日期和订单的里的商品名称、商品单价、商品数量
            //先获取订单列表,再获取订单详细信息
            int?         pageSize     = 3; //rp.Parameters.PageSize;,只取三条记录
            int?         pageIndex    = 1; //rp.Parameters.PageIndex;
            string       OrderBy      = "";
            string       OrderType    = "";
            T_InoutBLL   T_InoutBLL   = new T_InoutBLL(CurrentUserInfo);
            InoutService InoutService = new InoutService(CurrentUserInfo);
            //只取状态为700的
            //根据订单列表取订单详情
            DataSet dsOrder = T_InoutBLL.GetOrdersByVipID(rd.MemberInfo.VipID, pageIndex ?? 1, pageSize ?? 15, OrderBy, OrderType);//获取会员信息
            if (dsOrder != null && dsOrder.Tables.Count != 0 && dsOrder.Tables[0].Rows.Count != 0)
            {
                List <JIT.CPOS.DTO.Module.VIP.Login.Response.OrderInfo> orderList = DataTableToObject.ConvertToList <JIT.CPOS.DTO.Module.VIP.Login.Response.OrderInfo>(dsOrder.Tables[1]);
                foreach (JIT.CPOS.DTO.Module.VIP.Login.Response.OrderInfo oi in orderList)
                {
                    IList <InoutDetailInfo> detailList = InoutService.GetInoutDetailInfoByOrderId(oi.order_id);
                    oi.DetailList = detailList;
                }
                rd.OrderList = orderList;
            }

            MessageInfo message = new MessageInfo();


            InnerGroupNewsBLL InnerGroupNewsService = new InnerGroupNewsBLL(CurrentUserInfo);
            SetoffToolsBLL    setofftoolsService    = new SetoffToolsBLL(CurrentUserInfo);

            //1=微信用户 2=APP员工
            int UnReadInnerMessageCount = InnerGroupNewsService.GetVipInnerGroupNewsUnReadCount(CurrentUserInfo.UserID, pRequest.CustomerID, 1, null, Convert.ToDateTime(VipLoginInfo.CreateTime));
            var setofftoolsMessageCount = setofftoolsService.GetUnReadSetoffToolsCount(CurrentUserInfo.UserID, pRequest.CustomerID, 1, 1);
            message.InnerGroupNewsCount = UnReadInnerMessageCount;
            message.SetoffToolsCount    = setofftoolsMessageCount;
            var VipUpNewsInfo = InnerGroupNewsService.GetVipInnerNewsInfo(CurrentUserInfo.ClientID, 2, 1, 3, 0);
            if (VipUpNewsInfo != null && VipUpNewsInfo.Tables[0].Rows.Count > 0)
            {
                message.UpGradeSucess = VipUpNewsInfo.Tables[0].Rows[0]["Text"] != null ? VipUpNewsInfo.Tables[0].Rows[0]["Text"].ToString() : "";
                //获取通知信息 并更新已读状态 数据如果不是一条进行更新所有数据
                var newsUserMappingBLL = new NewsUserMappingBLL(CurrentUserInfo);
                if (VipUpNewsInfo.Tables[0].Rows.Count > 1)//数据如果不是一条进行更新所有数据
                {
                    foreach (DataRow VipNewsdr in VipUpNewsInfo.Tables[0].Rows)
                    {
                        var vipNewsInfo = newsUserMappingBLL.QueryByEntity(new NewsUserMappingEntity()
                        {
                            CustomerId = CurrentUserInfo.ClientID, MappingID = VipNewsdr["MappingID"].ToString()
                        }, null).FirstOrDefault();
                        if (vipNewsInfo != null)
                        {
                            vipNewsInfo.HasRead = 1;
                            newsUserMappingBLL.Update(vipNewsInfo);
                        }
                    }
                }
                else
                {
                    var vipNewsInfo = newsUserMappingBLL.QueryByEntity(new NewsUserMappingEntity()
                    {
                        CustomerId = CurrentUserInfo.ClientID, MappingID = VipUpNewsInfo.Tables[0].Rows[0]["MappingID"].ToString()
                    }, null).FirstOrDefault();
                    if (vipNewsInfo != null)
                    {
                        vipNewsInfo.HasRead = 1;
                        newsUserMappingBLL.Update(vipNewsInfo);
                    }
                }
            }
            else
            {
                message.UpGradeSucess = "";
            }
            rd.MessageInfo = message;
            return(rd);
        }
    }
        private void SetPaymentInfo()
        {
            // 创建一个新的 WebClient 实例.
            WebClient myWebClient = new WebClient();

            try
            {
                string strError          = string.Empty;
                string OrderCustomerInfo = Request["order_id"];
                Loggers.Debug(new DebugLogInfo()
                {
                    Message = string.Format("支付跳转--order_id: {0}", OrderCustomerInfo)
                });
                Loggers.Debug(new DebugLogInfo()
                {
                    Message = string.Format("支付跳转--merchant_url: {0}", Request["merchant_url"].ToString())
                });
                if (OrderCustomerInfo == null || OrderCustomerInfo.Trim().Equals(""))
                {
                    strError = "订单标识为空";
                    Loggers.Debug(new DebugLogInfo()
                    {
                        Message = string.Format("支付跳转--单据: {0}", strError)
                    });
                }
                else
                {
                    #region 处理业务
                    var infos = OrderCustomerInfo.Split(',');
                    if (infos.Length != 2)
                    {
                        Loggers.Debug(new DebugLogInfo()
                        {
                            Message = string.Format("支付跳转: {0}", "长度错误")
                        });
                        return;
                    }
                    string customerId         = infos[0].ToString().Trim();
                    string orderCode          = infos[1].ToString().Trim();
                    var    loggingSessionInfo = Default.GetBSLoggingSession(customerId, "1");

                    InoutService service   = new InoutService(loggingSessionInfo);
                    InoutInfo    inoutInfo = new InoutInfo();
                    inoutInfo = service.GetInoutInfoByOrderCode(orderCode);
                    if (inoutInfo == null)
                    {
                        strError = "没有获取合法的订单信息";
                        Loggers.Debug(new DebugLogInfo()
                        {
                            Message = string.Format("支付跳转 {0}", "没有获取合法的订单信息")
                        });
                    }
                    else
                    {
                        #region Jermyn20131011 处理订单支付时订单信息
                        InoutInfo inoutModel = new InoutInfo();
                        string    phone      = string.Empty;
                        string    address    = string.Empty;
                        string    userName   = string.Empty;
                        inoutModel.order_id    = inoutInfo.order_id;
                        inoutModel.modify_time = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        #region
                        if (Request["phone"] != null)
                        {
                            inoutModel.Field6 = Request["phone"].Trim();
                            Loggers.Debug(new DebugLogInfo()
                            {
                                Message = string.Format("手机号码: {0}", inoutModel.Field6)
                            });
                        }
                        //else {
                        //    Loggers.Debug(new DebugLogInfo()
                        //    {
                        //        Message = string.Format("支付跳转--手机号码 {0}", "为空")
                        //    });
                        //}
                        if (Request["address"] != null)
                        {
                            inoutModel.Field4 = Request["address"].Trim();
                            Loggers.Debug(new DebugLogInfo()
                            {
                                Message = string.Format("地址: {0}", inoutModel.Field4)
                            });
                        }
                        if (Request["userName"] != null)
                        {
                            inoutModel.Field14 = Request["userName"].Trim();
                            Loggers.Debug(new DebugLogInfo()
                            {
                                Message = string.Format("用户名: {0}", inoutModel.Field14)
                            });
                        }
                        #endregion
                        bool bReturn = service.Update(inoutModel, out strError);
                        Loggers.Debug(new DebugLogInfo()
                        {
                            Message = string.Format("更新订单用户信息是否成功: {0}", strError)
                        });
                        #endregion
                        //请求参数:
                        //order_id:  订单号
                        //prod_name:  产品名称
                        //prod_price:  产品价格
                        //merchant_url:  用户付款中途退出或者付款成功后返回URL http://xxxx:9004/OnlineClothing/detail.html?itemId=C5BBD04EEE1643F381A522AD68D58828&back=list&customerId=f6a7da3d28f74f2abedfc3ea0cf65c01
                        //call_back_url:  交易结果返回URL(最终将会以POST方式推送交易结果到该地址)
                        string uriString = ConfigurationManager.AppSettings["PaypalUrl"].Trim();
                        string webUrl    = ConfigurationManager.AppSettings["website_url"];
                        var    postData  = "order_id=" + OrderCustomerInfo
                                           + "&prod_name=" + inoutInfo.InoutDetailList[0].item_name
                                           + "&prod_price=" + Convert.ToString(double.Parse(Convert.ToString(inoutInfo.actual_amount)).ToString("f2"))
                                           + "&merchant_url=" + Request["merchant_url"]
                                           + "&call_back_url=" + webUrl + "OnlineShopping/data/OnlinePayAfter.aspx";
                        CustomerPayAssignBLL    customerPayServer = new CustomerPayAssignBLL(loggingSessionInfo);
                        CustomerPayAssignEntity customerPayInfo   = new CustomerPayAssignEntity();
                        var list = customerPayServer.QueryByEntity(new CustomerPayAssignEntity
                        {
                            CustomerId      = loggingSessionInfo.CurrentUser.customer_id
                            , IsDelete      = 0
                            , PaymentTypeId = "BB04817882B149838B19DE2BDDA5E91B"
                        }, null);
                        if (list != null && list.Length > 0)
                        {
                            customerPayInfo = list[0];
                            if (customerPayInfo != null && customerPayInfo.AssignId != null && !customerPayInfo.AssignId.Equals(""))
                            {
                                string strFLAmount = (double.Parse(Convert.ToString(Convert.ToDecimal(customerPayInfo.CustomerProportion) * Convert.ToDecimal(inoutInfo.actual_amount) / Convert.ToDecimal(100)))).ToString("f2");
                                postData += "&params=" + customerPayInfo.CustomerAccountNumber + "^" + strFLAmount + "^";
                            }
                        }

                        //order_id=1234
                        //&prod_name=test8
                        //&prod_price=0.02
                        //&merchant_url=http://xxxx
                        //&call_back_url=http://180.153.154.21:9004/AlipayWapTrade/PaySuccess.aspx
                        //&[email protected]^0.02^
                        Loggers.Debug(new DebugLogInfo()
                        {
                            Message = string.Format("支付跳转-链接字符串: {0}", postData)
                        });
                        // 注意这种拼字符串的ContentType
                        myWebClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
                        // 转化成二进制数组
                        byte[] byteArray = Encoding.UTF8.GetBytes(postData);
                        // 上传数据,并获取返回的二进制数据.
                        byte[] responseArray = myWebClient.UploadData(uriString, "POST", byteArray);
                        var    data          = System.Text.Encoding.UTF8.GetString(responseArray);
                        Response.Write(data);
                        strError = "ok";
                    }
                    #endregion
                }

                Loggers.Debug(new DebugLogInfo()
                {
                    Message = string.Format("支付跳转--完成: {0}", strError)
                });
                //myWebClient.UploadData(Request["merchant_url"].ToString(), "POST",Encoding.ASCII.GetBytes("&strError="+strError+""));
            }
            catch (Exception ex) {
                Loggers.Debug(new DebugLogInfo()
                {
                    Message = string.Format("支付跳转--出错: {0}", ex.ToString())
                });
                // myWebClient.UploadData(Request["merchant_url"].ToString(), "POST", Encoding.ASCII.GetBytes("&strError=" + ex.ToString() + ""));
            }
        }
Exemple #17
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);
        }
Exemple #18
0
        /// <summary>
        /// 接待推送
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void bw_DoWorkJd(object sender, DoWorkEventArgs e)
        {
            while (true)
            {
                try
                {
                    ConfigurationManager.RefreshSection("appSettings");
                    var time = ConfigurationManager.AppSettings["Timing"];

                    //支持配置多客户
                    string[] customerIDs = ConfigurationManager.AppSettings["CustomerIDs"].Split(',');
                    foreach (string customerID in customerIDs)
                    {
                        loggingSessionInfo = GetLoggingSession(customerID, "PushService");

                        var       vipBll      = new VipBLL(loggingSessionInfo);       //会员BLL实例化
                        var       orderBll    = new Car_OrderBLL(loggingSessionInfo); //订单BLL实例化
                        var       orderEntity = new Car_OrderEntity();
                        VipEntity vipEntity   = null;

                        //查询参数
                        List <IWhereCondition> complexCondition = new List <IWhereCondition> {
                        };
                        complexCondition.Add(new LessThanCondition()
                        {
                            FieldName        = "ReserveTime",
                            Value            = DateTime.Now.AddMinutes(15),
                            IncludeEquals    = true,
                            DateTimeAccuracy = DateTimeAccuracys.DateTime
                        }); //
                        complexCondition.Add(new MoreThanCondition()
                        {
                            FieldName        = "ReserveTime",
                            Value            = DateTime.Now,
                            IncludeEquals    = true,
                            DateTimeAccuracy = DateTimeAccuracys.DateTime
                        }); //
                        complexCondition.Add(new LessThanCondition()
                        {
                            FieldName = "Status", Value = 3
                        });                                                                                                                          //????
                        complexCondition.Add(new DirectCondition(" ((PushStatus = '1' or (VipID is null or VipID = '')) and PushStatus != '15') ")); //未推送
                        //排序参数
                        List <OrderBy> lstOrder = new List <OrderBy> {
                        };
                        lstOrder.Add(new OrderBy()
                        {
                            FieldName = "ReserveTime", Direction = OrderByDirections.Asc
                        });
                        //orderEntity = orderBll.QueryByEntity(new Car_OrderEntity { ReserveTime > DateTime.Now }, null);
                        var tempOrderList = orderBll.Query(complexCondition.ToArray(), lstOrder.ToArray());
                        if (tempOrderList != null && tempOrderList.Length != 0)
                        {
                            //接待提前15分钟的订单消息推送
                            var orderPush = new InoutService(loggingSessionInfo);
                            orderPush.OrderPushMessage(tempOrderList[0].OrderID.ToString(), "15");

                            orderEntity            = orderBll.GetByID(tempOrderList[0].OrderID);
                            orderEntity.PushStatus = 15;
                            orderBll.Update(orderEntity);
                        }
                    }


                    //MessageDAO dao = new MessageDAO(new BasicUserInfo());
                    //MessageChannelDAO channelDao = new MessageChannelDAO(new BasicUserInfo());
                    //var entitys = dao.GetValidMessage();
                    //foreach (var item in entitys)
                    //{
                    //    try
                    //    {
                    //        var entity = channelDao.GetByID(item.ChannelID);
                    //        if (entity == null)
                    //        {
                    //            throw new Exception(string.Format("未找到相应的ChannelID为:{0}的Channel信息", item.ChannelID));
                    //        }
                    //        switch (entity.MobilePlatform)
                    //        {
                    //            case 1:
                    //                var request = item.GetRequest();
                    //                var baiduResponse = BaiduCloudPush.PushMessage(entity.GetBaiDuChannel(), request);
                    //                if (baiduResponse.IsSuccess)
                    //                {
                    //                    item.SendCount = (item.SendCount ?? 0) + 1;
                    //                    item.Status = 2;
                    //                    Loggers.Debug(new DebugLogInfo() { Message = "【发送成功】:" + item.MessageContent });
                    //                }
                    //                else
                    //                {
                    //                    item.SendCount = (item.SendCount ?? 0) + 1;
                    //                    item.Status = 1;
                    //                    item.FaultReason = baiduResponse.ErrorMessage;
                    //                    Loggers.Debug(new DebugLogInfo() { Message = "【发送失败】:" + item.MessageContent });
                    //                }
                    //                break;
                    //            case 2:
                    //                var IOSChannel = entity.GetIOSChannel();
                    //                var notification = item.GetIOSNotification();
                    //                var IOSResponse = IOSNotificationService.CreateInstance(IOSChannel.SandBox ?? true, IOSChannel.P12, IOSChannel.P12PWD).SendNotification(notification);
                    //                if (IOSResponse)
                    //                {
                    //                    item.SendCount = (item.SendCount ?? 0) + 1;
                    //                    item.Status = 2;
                    //                    Loggers.Debug(new DebugLogInfo() { Message = "【发送到推送服务器成功】:" + item.MessageContent });
                    //                }
                    //                else
                    //                {
                    //                    item.SendCount = (item.SendCount ?? 0) + 1;
                    //                    item.Status = 1;
                    //                    item.FaultReason = "发送到推送服务器失败";
                    //                    Loggers.Debug(new DebugLogInfo() { Message = "【发送到推送服务器成功】:" + item.MessageContent });
                    //                }
                    //                break;
                    //            default:
                    //                throw new Exception("错误的平台类型");
                    //        }


                    //        dao.Update(item);
                    //    }
                    //    catch (Exception ee)
                    //    {
                    //        item.SendCount = (item.SendCount ?? 0) + 1;
                    //        item.FaultReason = ee.Message;
                    //        item.Status = 1;
                    //        dao.Update(item);
                    //        Loggers.Exception(new ExceptionLogInfo(ee));
                    //        throw ee;
                    //    }
                    //}
                    Thread.Sleep(TimeSpan.FromSeconds(Interval));
                }
                catch (Exception ex)
                {
                    Loggers.Exception(new ExceptionLogInfo(ex));
                }
            }
        }
        protected void LoadData()
        {
            var         currentUser = Default.GetBSLoggingSession("f6a7da3d28f74f2abedfc3ea0cf65c01", null); //03201e18799a47179d2f6bf8424d86c9
            string      unitId      = Request.QueryString["unit_id"];                                        // "8c41446fe80d4f2e9e3d659df01641fa";
            UnitService unitService = new UnitService(currentUser);
            var         unitObj     = unitService.GetUnitById(unitId);
            string      unitName    = unitObj.Name;
            decimal     totalAmount = 0;
            string      today       = DateTime.Now.ToString("yyyy-MM-dd");
            //string today = (new DateTime(2013, 10, 11)).ToString("yyyy-MM-dd");
            string topOrderStr = "";

            InoutService    service   = new InoutService(currentUser);
            OrderSearchInfo queryInfo = new OrderSearchInfo();

            queryInfo.order_type_id    = "1F0A100C42484454BAEA211D4C14B80F";
            queryInfo.order_reason_id  = "2F6891A2194A4BBAB6F17B4C99A6C6F5";
            queryInfo.red_flag         = "1";
            queryInfo.StartRow         = 0;
            queryInfo.EndRow           = 1000;
            queryInfo.unit_id          = unitId;
            queryInfo.order_date_begin = today;
            //花间堂定制酒店 非花间堂使用false
            var list = service.SearchInoutInfo(queryInfo, false);

            int n = 1;

            if (list != null && list.InoutInfoList != null)
            {
                foreach (var item in list.InoutInfoList)
                {
                    totalAmount += item.total_amount;
                    if (n <= 2)
                    {
                        topOrderStr += GetOrderStr(item);
                    }
                    n++;
                }
            }

            topDataStr = "[";
            var topData = service.GetInoutDetailInfoByTop3(queryInfo);

            if (topData != null && topData.Count > 0)
            {
                decimal total = 0;
                for (var i = 0; i < topData.Count; i++)
                {
                    total += topData[i].retail_amount;
                }
                for (var i = 0; i < topData.Count; i++)
                {
                    var topItem = topData[i];
                    //string percent = string.Format("{0,25:N}", (topItem.retail_amount / total * 100));
                    string percent = (topItem.retail_amount / total * 100).ToString("f1");
                    if (i > 0)
                    {
                        topDataStr += ",";
                    }
                    topDataStr += "{";
                    topDataStr += string.Format(" name:\"{0}\", data1:\"{1}\", data2:\"{2}\" ",
                                                topItem.item_name != null && topItem.item_name.Length > 10 ?
                                                topItem.item_name.Substring(0, 10) + "..." : topItem.item_name,
                                                topItem.retail_amount,
                                                percent + "%");
                    topDataStr += "}";
                }
            }
            topDataStr += "]";


            //if (Request["store_name"] != null && Request["store_name"].Trim().Length > 0)
            //{
            //    unitName = HttpUtility.HtmlDecode(Request["store_name"].Trim());
            //}

            this.lblUnitName.InnerHtml    = unitName;
            this.lblDate.InnerHtml        = today;
            this.lblTotalAmount.InnerHtml = string.Format("{0,25:N}", totalAmount);
            strDiv = topOrderStr;
        }
        protected override GetSalesReturnDetailRD ProcessRequest(DTO.Base.APIRequest <GetSalesReturnDetailRP> pRequest)
        {
            var rd   = new GetSalesReturnDetailRD();
            var para = pRequest.Parameters;
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            var salesReturnBLL     = new T_SalesReturnBLL(loggingSessionInfo);
            var historyBLL         = new T_SalesReturnHistoryBLL(loggingSessionInfo);

            var inoutService      = new InoutService(loggingSessionInfo);
            var tInoutDetailBll   = new TInoutDetailBLL(loggingSessionInfo);
            var inoutBLL          = new T_InoutBLL(CurrentUserInfo);
            var salesReturnEntity = salesReturnBLL.GetByID(para.SalesReturnID);
            var PaymentTtpeBLL    = new T_Payment_TypeBLL(loggingSessionInfo);

            if (salesReturnEntity != null)
            {
                var orderInfo = inoutBLL.GetByID(salesReturnEntity.OrderID);

                rd.SalesReturnID = salesReturnEntity.SalesReturnID.ToString();
                rd.SalesReturnNo = salesReturnEntity.SalesReturnNo;
                rd.OrderID       = salesReturnEntity.OrderID;

                rd.OrderNo = orderInfo.order_no;

                rd.Status       = salesReturnEntity.Status;
                rd.DeliveryType = salesReturnEntity.DeliveryType;
                rd.Reason       = salesReturnEntity.Reason;
                rd.Qty          = salesReturnEntity.Qty;
                rd.ActualQty    = salesReturnEntity.ActualQty;
                rd.Contacts     = salesReturnEntity.Contacts;
                rd.Phone        = salesReturnEntity.Phone;
                rd.Address      = string.Empty;

                if (orderInfo != null)
                {
                    rd.Address = orderInfo.Field4;
                }
                rd.ServicesType = salesReturnEntity.ServicesType;

                //根据订单ID获取订单明细[复用]
                DataRow drItem = inoutService.GetOrderDetailByOrderId(salesReturnEntity.OrderID).Tables[0].Select(" item_id= '" + salesReturnEntity.ItemID + "'").FirstOrDefault();
                //获取商品的图片[复用]
                //string itemImage = tInoutDetailBll.GetOrderDetailImageList("'" + salesReturnEntity.ItemID + "'").Tables[0].Rows[0]["imageUrl"].ToString();
                string  itemImage = string.Empty;
                DataSet ds        = tInoutDetailBll.GetOrderDetailImageList("'" + salesReturnEntity.ItemID + "'");
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    itemImage = ds.Tables[0].Rows[0]["imageUrl"].ToString();
                }

                //获取订单详细列表中的商品规格[复用]
                DataRow[] drSku = inoutService.GetInoutDetailGgByOrderId(salesReturnEntity.OrderID).Tables[0].Select(" sku_id='" + salesReturnEntity.SkuID + "'");

                //订单的商品信息
                var orderDetail = new OrderInfoDetail();

                orderDetail.ItemName   = drItem["item_name"].ToString();
                orderDetail.SalesPrice = Convert.ToDecimal(drItem["enter_price"]);
                orderDetail.Qty        = Convert.ToInt32(drItem["enter_qty"]);
                if (!string.IsNullOrEmpty(itemImage))
                {
                    orderDetail.ImageUrl = ImagePathUtil.GetImagePathStr(itemImage, "240");
                }

                orderDetail.PayTypeName = salesReturnEntity.PayTypeName;
                //支付方式名称
                var    OrderData     = inoutBLL.GetByID(salesReturnEntity.OrderID);
                string m_PayTypeName = "";
                if (OrderData != null)
                {
                    var PayTypeData = PaymentTtpeBLL.GetByID(OrderData.pay_id);
                    if (PayTypeData != null)
                    {
                        m_PayTypeName = PayTypeData.Payment_Type_Name;
                    }
                }
                orderDetail.PayTypeName = m_PayTypeName;


                orderDetail.RefundAmount  = salesReturnEntity.RefundAmount == null ? 0 : salesReturnEntity.RefundAmount.Value;
                orderDetail.ConfirmAmount = salesReturnEntity.ConfirmAmount == null ? 0 : salesReturnEntity.ConfirmAmount.Value;
                rd.OrderDetail            = orderDetail;
                //订单的商品规格
                if (drSku.Count() > 0)
                {
                    SkuDetailInfo skuDetail = new SkuDetailInfo();
                    skuDetail.PropName1       = drSku[0]["prop_1_name"].ToString();
                    skuDetail.PropDetailName1 = drSku[0]["prop_1_detail_name"].ToString();
                    skuDetail.PropName2       = drSku[0]["prop_2_name"].ToString();
                    skuDetail.PropDetailName2 = drSku[0]["prop_2_detail_name"].ToString();
                    skuDetail.PropName3       = drSku[0]["prop_3_name"].ToString();
                    skuDetail.PropDetailName3 = drSku[0]["prop_3_detail_name"].ToString();
                    rd.OrderDetail.SkuDetail  = skuDetail;
                }
                var history = historyBLL.QueryByEntity(new T_SalesReturnHistoryEntity()
                {
                    SalesReturnID = salesReturnEntity.SalesReturnID
                }, new[] { new OrderBy {
                               FieldName = "CreateTime", Direction = OrderByDirections.Desc
                           } });
                rd.HistoryList = history.Select(t => new HistoryInfo()
                {
                    HistoryID = t.HistoryID.ToString(), OperationDesc = t.OperationDesc, HisRemark = t.HisRemark, OperatorName = t.OperatorName, CreateTime = t.CreateTime.Value.ToString("yyyy-MM-dd HH:mm")
                }).ToArray();
            }
            return(rd);
        }
        protected override GetSalesReturnListRD ProcessRequest(DTO.Base.APIRequest <GetSalesReturnListRP> pRequest)
        {
            var rd   = new GetSalesReturnListRD();
            var para = pRequest.Parameters;

            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            var salesReturnBLL     = new T_SalesReturnBLL(loggingSessionInfo);
            var T_InoutBLL         = new T_InoutBLL(loggingSessionInfo);
            var inoutService       = new InoutService(loggingSessionInfo);
            var tInoutDetailBll    = new TInoutDetailBLL(loggingSessionInfo);

            //查询参数
            List <IWhereCondition> complexCondition = new List <IWhereCondition> {
            };

            complexCondition.Add(new EqualsCondition()
            {
                FieldName = "r.CustomerID", Value = loggingSessionInfo.ClientID
            });

            if (!string.IsNullOrEmpty(para.SalesReturnNo))
            {
                complexCondition.Add(new LikeCondition()
                {
                    FieldName = "r.SalesReturnNo", Value = "%" + para.SalesReturnNo + "%"
                });
            }
            if (para.DeliveryType > 0)
            {
                complexCondition.Add(new EqualsCondition()
                {
                    FieldName = "r.DeliveryType", Value = para.DeliveryType
                });
            }
            if (para.Status > 0 && para.Status < 8)
            {
                complexCondition.Add(new EqualsCondition()
                {
                    FieldName = "r.Status", Value = para.Status
                });
            }
            else if (para.Status == 8)//包含待退款和已退款
            {
                string[] statusArr = new string[] { "6", "7" };
                complexCondition.Add(new InCondition <string>()
                {
                    FieldName = "r.Status", Values = statusArr
                });
            }
            if (!string.IsNullOrEmpty(para.paymentcenterId))
            {
                complexCondition.Add(new EqualsCondition()
                {
                    FieldName = "t.paymentcenter_id", Value = para.paymentcenterId
                });
            }
            if (!string.IsNullOrEmpty(para.payId))
            {
                complexCondition.Add(new EqualsCondition()
                {
                    FieldName = "p.Payment_Type_Id", Value = para.payId
                });
            }
            //门店过滤处理


            //排序参数
            List <OrderBy> lstOrder = new List <OrderBy> {
            };

            lstOrder.Add(new OrderBy()
            {
                FieldName = "r.CreateTime", Direction = OrderByDirections.Desc
            });

            var tempList = salesReturnBLL.PagedQuery(complexCondition.ToArray(), lstOrder.ToArray(), para.PageSize, para.PageIndex);

            rd.TotalPageCount = tempList.PageCount;
            rd.TotalCount     = tempList.RowCount;

            List <SalesReturnInfo> salesReturnList = new List <SalesReturnInfo> {
            };
            SalesReturnInfo salesReturnInfo        = null;

            //SkuDetailInfo skuDetail = null;

            foreach (var item in tempList.Entities)
            {
                salesReturnInfo = new SalesReturnInfo();

                //根据订单ID获取订单明细[复用]
                DataRow drItem = inoutService.GetOrderDetailByOrderId(item.OrderID).Tables[0].Select(" item_id= '" + item.ItemID + "'").FirstOrDefault();
                if (drItem != null)
                {
                    //获取商品的图片[复用]
                    string  itemImage = string.Empty;
                    DataSet ds        = tInoutDetailBll.GetOrderDetailImageList("'" + item.ItemID + "'");
                    if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                    {
                        itemImage = ds.Tables[0].Rows[0]["imageUrl"].ToString();
                    }
                    //获取订单详细列表中的商品规格[复用]
                    //DataRow[] drSku = inoutService.GetInoutDetailGgByOrderId(item.OrderID).Tables[0].Select(" sku_id='" + item.SkuID + "'");

                    salesReturnInfo.SalesReturnID = item.SalesReturnID.ToString();
                    salesReturnInfo.SalesReturnNo = item.SalesReturnNo;
                    salesReturnInfo.ItemName      = drItem["item_name"].ToString();
                    salesReturnInfo.SalesPrice    = Convert.ToDecimal(drItem["enter_price"]);
                    salesReturnInfo.Qty           = item.Qty;
                    salesReturnInfo.Status        = item.Status;
                    if (!string.IsNullOrEmpty(itemImage))
                    {
                        salesReturnInfo.ImageUrl = ImagePathUtil.GetImagePathStr(itemImage, "240");
                    }
                    salesReturnInfo.VipName      = item.VipName;
                    salesReturnInfo.DeliveryType = item.DeliveryType;
                    salesReturnInfo.CreateTime   = item.CreateTime.Value.ToString("yyyy-MM-dd HH:mm");
                    //商户单号,支付方式
                    salesReturnInfo.paymentcenterId = item.paymentcenterId;
                    salesReturnInfo.paymentName     = item.PayTypeName;
                    salesReturnInfo.ServicesType    = item.ServicesType;
                    //if (drSku.Count() > 0)
                    //{
                    //    skuDetail = new SkuDetailInfo();
                    //    skuDetail.PropName1 = drSku[0]["prop_1_name"].ToString();
                    //    skuDetail.PropDetailName1 = drSku[0]["prop_1_detail_name"].ToString();
                    //    skuDetail.PropName2 = drSku[0]["prop_2_name"].ToString();
                    //    skuDetail.PropDetailName2 = drSku[0]["prop_2_detail_name"].ToString();
                    //    skuDetail.PropName3 = drSku[0]["prop_3_name"].ToString();
                    //    skuDetail.PropDetailName3 = drSku[0]["prop_3_detail_name"].ToString();
                    //    salesReturnInfo.SkuDetail = skuDetail;
                    //
                    //}
                    salesReturnList.Add(salesReturnInfo);
                }
            }

            rd.SalesReturnList = salesReturnList.ToArray();
            rd.TotalCount      = tempList.RowCount;
            rd.TotalPageCount  = tempList.PageCount;
            return(rd);
        }
        public void AutoSetOrderNotPayCache()
        {
            foreach (var customer in _CustomerIDList)
            {
                _T_loggingSessionInfo.ClientID = customer.Key;
                _T_loggingSessionInfo.CurrentLoggingManager.Connection_String = customer.Value;

                //
                _T_InoutBLL    = new T_InoutBLL(_T_loggingSessionInfo);
                _Inout3Service = new InoutService(_T_loggingSessionInfo);
                var inoutStatus = new TInoutStatusBLL(_T_loggingSessionInfo);
                _VipBLL = new VipBLL(_T_loggingSessionInfo);

                //
                // var t_InoutList = new List<string>();
                try
                {
                    List <IWhereCondition> complexCondition = new List <IWhereCondition>();
                    string[] statusArr = { "620", "610", "600" };
                    complexCondition.Add(new InCondition <string>()
                    {
                        FieldName = "Field7", Values = statusArr
                    });
                    complexCondition.Add(
                        new DirectCondition(
                            " CONVERT(NVARCHAR(10),complete_date,120) = CONVERT(NVARCHAR(10),DATEADD(day, -1, GETDATE()),120)"));

                    var t_InoutEntitys = _T_InoutBLL.Query(complexCondition.ToArray(), null);
                    if (t_InoutEntitys == null || t_InoutEntitys.Count() <= 0)
                    {
                    }
                    //
                    //   roleList = roleEntities.Select(it => it.role_id).ToList();

                    foreach (var t_InoutInfo in t_InoutEntitys)
                    {
                        TInoutStatusEntity info = new TInoutStatusEntity();
                        info.InoutStatusID = Guid.Parse(Utils.NewGuid());
                        info.OrderID       = t_InoutInfo.order_id;
                        info.CustomerID    = _T_loggingSessionInfo.ClientID;
                        info.Remark        = string.Empty;
                        info.OrderStatus   = 700;

                        string statusDesc = GetStatusDesc("700");//变更后的状态名称

                        try
                        {
                            info.StatusRemark = "订单状态从" + t_InoutInfo.status_desc + "变为" + statusDesc + "[操作人:自动]";
                            _Inout3Service.UpdateOrderDeliveryStatus(t_InoutInfo.order_id, "700", Utils.GetNow());
                        }
                        catch
                        {
                            continue;
                        }

                        inoutStatus.Create(info);

                        #region 支付成功,调用RabbitMQ发送给ERP

                        try
                        {
                            var msg = new EventContract
                            {
                                Operation  = OptEnum.Update,
                                EntityType = EntityTypeEnum.Order,
                                Id         = t_InoutInfo.order_id
                            };
                            var eventService = new EventService();
                            eventService.PublishMsg(msg);
                        }
                        catch (Exception ex)
                        {
                            throw new Exception(ex.Message);
                        }

                        #endregion
                    }
                }
                catch
                {
                    // ignored
                }
            }
        }
Exemple #23
0
        /// <summary>
        /// 获取订单
        /// </summary>
        /// <returns></returns>
        public string GetOrderInfo()
        {
            string content = string.Empty;
            GetResponseParams <GetOrderInfoEntity> response = new GetResponseParams <GetOrderInfoEntity>();

            response.Code        = "200";
            response.Description = "操作成功";
            response.Params      = new GetOrderInfoEntity();

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

            var loggingSessionInfo = Default.GetLjLoggingSession();

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

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

                InoutService inoutService = new InoutService(loggingSessionInfo);
                //TUnitExpandBLL service = new TUnitExpandBLL(loggingSessionInfo);
                //var unitExpandEntity = new TUnitExpandEntity() { UnitId = unitId };
                //var unitExpandEntitys = service.QueryByEntity(unitExpandEntity, null).ToList();
                //if (unitExpandEntitys != null && unitExpandEntitys.Count > 0)
                //{
                var orderId = inoutService.GetInoutId(new InoutInfo()
                {
                    sales_unit_id = unitId,
                    //customer_id = customerId,
                    order_type_id   = "1F0A100C42484454BAEA211D4C14B80F",
                    order_reason_id = "2F6891A2194A4BBAB6F17B4C99A6C6F5",
                    red_flag        = "1",
                    Field16         = orderNo
                });
                if (orderId != null && orderId.Trim().Length > 0)
                {
                    response.Params.order = inoutService.GetInoutInfoById(orderId);
                }
                //}
            }
            catch (Exception ex)
            {
                response.Code        = "201";
                response.Description = "操作失败:" + ex.ToString();
            }
            content = string.Format("{{\"Description\":\"{2}\",\"Code\":\"{1}\",\"content\":{0}}}",
                                    response.Params.order.ToJSON(), response.Code, response.Description);
            return(content);
        }
Exemple #24
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());
        }
Exemple #25
0
        public string setiAlumniOrderInfo()
        {
            string content  = string.Empty;
            var    respData = new Default.LowerRespData();

            try
            {
                string reqContent = Request["ReqContent"];

                //reqContent = "{\"common\":{\\\"weiXinId\\\":\\\"gh_bf70d7900c28\\\",\\\"openId\\\":\\\"o8Y7Ejm0kL4QB8-h_Z0Bncl619v4\\\"},\"special\":{\\\"salesPrice\\\":\\\"235\\\",\\\"stdPrice\\\":\\\"250\\\",\\\"orderCode\\\":\\\"DO2013080800001\\\",\\\"totalAmount\\\":\\\"470\\\",\\\"deliveryName\\\":\\\"�ŵ����\\\",\\\"qty\\\":\\\"2\\\",\\\"deliveryRemark\\\":\\\"\\\",\\\"orderId\\\":\\\"E370FC0B39A77078E044005056BE1CB0\\\"}}";
                //reqContent = Server.UrlDecode(reqContent);
                //reqContent = HttpUtility.UrlDecode(reqContent);
                //reqContent = reqContent.Replace("\\\"","\"");
                Loggers.Debug(new DebugLogInfo()
                {
                    Message = string.Format("setiAlumniOrderInfo: {0}", reqContent)
                });
                var reqObj = reqContent.DeserializeJSONTo <setOrderInfoReqData>();

                string OpenID = reqObj.common.openId;
                string WeiXin = reqObj.common.weiXinId;


                #region
                if (OpenID == null || OpenID.Trim().Equals(""))
                {
                    respData.code        = "110";
                    respData.description = "OpenID不能为空";
                    return(respData.ToJSON());
                }
                if (reqObj.special.skuId == null || reqObj.special.skuId.Trim().Equals(""))
                {
                    respData.code        = "110";
                    respData.description = "skuId不能为空";
                    return(respData.ToJSON());
                }
                if (reqObj.special.orderId == null || reqObj.special.orderId.Trim().Equals(""))
                {
                    respData.code        = "110";
                    respData.description = "订单标识不能为空";
                    return(respData.ToJSON());
                }
                if (reqObj.special.orderCode == null || reqObj.special.orderCode.Trim().Equals(""))
                {
                    respData.code        = "110";
                    respData.description = "订单号码不能为空";
                    return(respData.ToJSON());
                }
                if (reqObj.special.qty == null || reqObj.special.qty.Trim().Equals(""))
                {
                    respData.code        = "110";
                    respData.description = "数量不能为空";
                    return(respData.ToJSON());
                }
                if (reqObj.special.salesPrice == null || reqObj.special.salesPrice.Trim().Equals(""))
                {
                    respData.code        = "110";
                    respData.description = "销售价格不能为空";
                    return(respData.ToJSON());
                }
                if (reqObj.special.stdPrice == null || reqObj.special.stdPrice.Trim().Equals(""))
                {
                    respData.code        = "110";
                    respData.description = "标准价格不能为空";
                    return(respData.ToJSON());
                }
                if (reqObj.special.totalAmount == null || reqObj.special.totalAmount.Trim().Equals(""))
                {
                    respData.code        = "110";
                    respData.description = "总价不能为空";
                    return(respData.ToJSON());
                }
                #endregion

                var loggingSessionInfo = Default.GetBSLoggingSession("29E11BDC6DAC439896958CC6866FF64E", "1");
                //Default.WriteLog(loggingSessionInfo, "setiAlumniOrderInfo", null, respData, reqObj.special.ToJSON());

                InoutService inoutService = new InoutService(loggingSessionInfo);
                string       strError     = string.Empty;
                string       strMsg       = string.Empty;
                bool         bReturn      = inoutService.SetiAlumniWapPosInoutInfo(reqObj.special.skuId.Trim()
                                                                                   , reqObj.special.orderId.Trim()
                                                                                   , OpenID.Trim()
                                                                                   , WeiXin.Trim()
                                                                                   , reqObj.special.orderCode.Trim()
                                                                                   , reqObj.special.qty.Trim()
                                                                                   , reqObj.special.stdPrice.Trim()
                                                                                   , reqObj.special.salesPrice.Trim()
                                                                                   , reqObj.special.totalAmount.Trim()
                                                                                   , reqObj.special.deliveryName.Trim()
                                                                                   , reqObj.special.deliveryRemark.Trim()
                                                                                   , loggingSessionInfo
                                                                                   , out strError, out strMsg);
                if (bReturn)
                {
                    respData.code = "200";
                    // 推送消息
                    string msgUrl  = ConfigurationManager.AppSettings["push_weixin_msg_url"].Trim();
                    string msgText = string.Format("{0}", strMsg);
                    string msgData = "<xml><OpenID><![CDATA[" + OpenID + "]]></OpenID><Content><![CDATA[" + msgText + "]]></Content></xml>";

                    var msgResult = Common.Utils.GetRemoteData(msgUrl, "POST", msgData);

                    Loggers.Debug(new DebugLogInfo()
                    {
                        Message = string.Format("PushMsgResult:{0}", msgResult)
                    });
                }
                else
                {
                    respData.code = "101";
                }
                respData.description = strError;
                return(respData.ToJSON());
            }
            catch (Exception ex)
            {
                respData.code        = "103";
                respData.description = "数据库操作错误";
                respData.exception   = ex.ToString();
            }
            content = respData.ToJSON();
            return(content);
        }
        protected override GetOrderDetailRD ProcessRequest(DTO.Base.APIRequest <GetOrderDetailRP> pRequest)
        {
            GetOrderDetailRD rd      = new GetOrderDetailRD();
            string           orderId = pRequest.Parameters.OrderId;

            rd.OrderListInfo = new OrderListInfo();

            #region 获取订单列表

            T_InoutBLL orderBll  = new T_InoutBLL(this.CurrentUserInfo);
            var        orderList = orderBll.QueryByEntity(new T_InoutEntity()
            {
                order_id = orderId
            }, null);

            #endregion

            #region 获取会员信息

            string vipNo  = orderList[0].vip_no;
            VipBLL vipBll = new VipBLL(this.CurrentUserInfo);

            var vipList = vipBll.QueryByEntity(new VipEntity()
            {
                VIPID = vipNo
            }, null);

            #endregion

            #region 获取配方式

            //Bear 20160928 注释 更具商品信息获取对应配送
            string deliveryId = orderList[0].Field8;


            DeliveryBLL deliverBll = new DeliveryBLL(this.CurrentUserInfo);

            var deliverList = deliverBll.QueryByEntity(new DeliveryEntity()
            {
                DeliveryId = deliveryId
            }, null);



            #endregion

            #region 获取门店信息

            string storeId = orderList[0].sales_unit_id;
            if (!string.IsNullOrEmpty(orderList[0].purchase_unit_id))//如果有发货门店,则显示发货门店信息
            {
                storeId = orderList[0].purchase_unit_id;
            }
            TInoutBLL tInoutBll = new TInoutBLL(this.CurrentUserInfo);
            //string storeName = tInoutBll.GetStoreName(storeId);
            DataSet storeDs = tInoutBll.GetStoreInfo(storeId);
            rd.OrderListInfo.StoreID = storeId;

            #endregion

            //配送商
            string carrierId = orderList[0].carrier_id;

            //DataSet carrierDs = tInoutBll.GetStoreInfo(carrierId);
            //if (carrierDs.Tables[0].Rows.Count > 0)
            //{
            //    rd.OrderListInfo.CarrierID = carrierId;
            //    rd.OrderListInfo.CarrierName = carrierDs.Tables[0].Rows[0]["unit_name"].ToString();
            //}
            if (!string.IsNullOrEmpty(carrierId))
            {
                //配送方式 1.送货到家;2.到店提货
                if (deliveryId == "1")
                {
                    var  logisticsCompanyBLL = new T_LogisticsCompanyBLL(this.CurrentUserInfo);
                    Guid m_carrierId         = Guid.Parse(carrierId);
                    var  logCompInfo         = logisticsCompanyBLL.GetByID(m_carrierId);
                    if (logCompInfo != null)
                    {
                        rd.OrderListInfo.CarrierID   = carrierId;
                        rd.OrderListInfo.CarrierName = logCompInfo.LogisticsName;
                    }
                }
                else if (deliveryId == "2")
                {
                    var unitBLL  = new t_unitBLL(this.CurrentUserInfo);
                    var unitInfo = unitBLL.GetByID(carrierId);
                    if (unitInfo != null)
                    {
                        rd.OrderListInfo.CarrierID   = carrierId;
                        rd.OrderListInfo.CarrierName = unitInfo.unit_name;
                    }
                }
                else if (deliveryId == "4")
                {
                    var unitBLL  = new t_unitBLL(this.CurrentUserInfo);
                    var unitInfo = unitBLL.GetByID(carrierId);
                    if (unitInfo != null)
                    {
                        rd.OrderListInfo.CarrierID   = carrierId;
                        rd.OrderListInfo.CarrierName = unitInfo.unit_name;
                    }
                }
            }
            rd.OrderListInfo.CourierNumber = orderList[0].Field2;                                      //配送单号
            rd.OrderListInfo.Invoice       = orderList[0].Field19 == null ? "" : orderList[0].Field19; //发票信息
            if (vipList.Count() > 0)
            {
                rd.OrderListInfo.VipID        = vipList[0].VIPID;
                rd.OrderListInfo.Phone        = vipList[0].Phone;
                rd.OrderListInfo.UserName     = vipList[0].VipName;
                rd.OrderListInfo.VipRealName  = vipList[0].VipRealName;
                rd.OrderListInfo.VipLevelDesc = vipList[0].VipLevelDesc;
                rd.OrderListInfo.VipCode      = vipList[0].VipCode;
                rd.OrderListInfo.Email        = vipList[0].Email;
                rd.OrderListInfo.VipLevel     = Convert.ToInt32(vipList[0].VipLevel);
            }

            if (storeDs.Tables[0].Rows.Count > 0)
            {
                rd.OrderListInfo.StoreName    = storeDs.Tables[0].Rows[0]["unit_name"].ToString();
                rd.OrderListInfo.StoreAddress = storeDs.Tables[0].Rows[0]["unit_address"].ToString();
                rd.OrderListInfo.StoreTel     = storeDs.Tables[0].Rows[0]["unit_tel"].ToString();
            }

            if (orderList.Count() > 0)
            {
                rd.OrderListInfo.discount_rate = orderList[0].discount_rate ?? 100;//订单折扣
                rd.OrderListInfo.OrderID       = orderList[0].order_id;
                rd.OrderListInfo.OrderCode     = orderList[0].order_no;
                rd.OrderListInfo.OrderDate     = orderList[0].order_date;
                rd.OrderListInfo.ReceiverName  = orderList[0].Field14; //收件人
                rd.OrderListInfo.TotalQty      = Convert.ToDecimal(orderList[0].total_qty);

                string TotalAmount = String.Format("{0:F}", orderList[0].total_amount ?? 0);

                rd.OrderListInfo.TotalAmount = TotalAmount;

                rd.OrderListInfo.Total_Retail      = Convert.ToDecimal(orderList[0].total_retail);
                rd.OrderListInfo.Remark            = orderList[0].remark;
                rd.OrderListInfo.Status            = orderList[0].status;
                rd.OrderListInfo.OrderStatus       = int.Parse(orderList[0].Field7);
                rd.OrderListInfo.StatusDesc        = orderList[0].status_desc;
                rd.OrderListInfo.DeliveryAddress   = orderList[0].Field4;
                rd.OrderListInfo.DeliveryTime      = orderList[0].Field9;
                rd.OrderListInfo.ClinchTime        = orderList[0].create_time;
                rd.OrderListInfo.ReceiptTime       = orderList[0].accpect_time;
                rd.OrderListInfo.CouponsPrompt     = orderList[0].Field16;
                rd.OrderListInfo.DeliveryID        = orderList[0].Field8;
                rd.OrderListInfo.IsPayment         = orderList[0].Field1;
                rd.OrderListInfo.ReceivePoints     = orderList[0].receive_points;
                rd.OrderListInfo.PaymentTime       = orderList[0].Field1 == "1" ? orderList[0].complete_date : null;
                rd.OrderListInfo.OrderReasonTypeId = orderList[0].order_reason_id;
                rd.OrderListInfo.ActualDecimal     = orderList[0].actual_amount ?? 0;



                rd.OrderListInfo.PaymentTypeCode = orderList[0].Payment_Type_Code;
                rd.OrderListInfo.PaymentTypeName = orderList[0].Payment_Type_Name;

                rd.OrderListInfo.ReserveTime = orderList[0].reserveDay + " " + orderList[0].reserveQuantum;

                var deliveryBll = new TOrderCustomerDeliveryStrategyMappingBLL(this.CurrentUserInfo);
                rd.OrderListInfo.DeliveryAmount = deliveryBll.GetDeliverAmount(orderId);        //配送费 add by henry***

                if (!string.IsNullOrEmpty(orderList[0].Field15) && orderList[0].Field15 != "0") //是否是团购商品 add by Henry 2014-12-22
                {
                    rd.OrderListInfo.IsEvent = 1;                                               //团购商品
                }
                else
                {
                    rd.OrderListInfo.IsEvent = 0;   //普通商品
                }
                #region update by changjian.tian

                rd.OrderListInfo.Mobile         = orderList[0].Field6; //配送联系电话
                rd.OrderListInfo.DeliveryRemark = orderList[0].remark;

                rd.OrderListInfo.IsEvaluation = orderList[0].IsEvaluation == null ? 0 : orderList[0].IsEvaluation.Value;//评论
                #endregion
            }

            if (deliverList.Count() > 0)
            {
                rd.OrderListInfo.DeliveryName = deliverList[0].DeliveryName;
            }


            T_Inout_DetailBLL orderDetailBll = new T_Inout_DetailBLL(this.CurrentUserInfo);
            //退换货Bll实例化
            T_SalesReturnBLL salesReturnBll = new T_SalesReturnBLL(this.CurrentUserInfo);

            var orderDetailList = orderDetailBll.QueryByEntity(new T_Inout_DetailEntity()
            {
                order_id = orderId
            }, null);

            var inoutService = new InoutService(this.CurrentUserInfo);

            #region 根据订单ID获取订单明细

            var ds = inoutService.GetOrderDetailByOrderId(orderId);

            #endregion

            #region 获取订单详细列表中的商品规格

            var ggDs = inoutService.GetInoutDetailGgByOrderId(orderId);

            #endregion

            if (ds.Tables[0].Rows.Count > 0)
            {
                string ItemIdList =
                    ds.Tables[0].AsEnumerable().Aggregate("", (x, j) =>
                {
                    x += string.Format("'{0}',", j["item_id"].ToString());
                    return(x);
                }).Trim(',');

                TInoutDetailBLL tInoutDetailBll = new TInoutDetailBLL(this.CurrentUserInfo);
                //获取商品的图片
                DataSet imageDs = tInoutDetailBll.GetOrderDetailImageList(ItemIdList);



                var tmp = ds.Tables[0].AsEnumerable().Select(t => new OrderDetailEntity()
                {
                    ItemID          = t["item_id"].ToString(),
                    ItemName        = t["item_name"].ToString(),
                    SkuID           = t["sku_id"].ToString(),
                    SalesReturnFlag = salesReturnBll.CheckSalesReturn(orderId, t["sku_id"].ToString()),//是否可申请退换货
                    //GG = t["prop_1_detail_name"].ToString()+t["prop_2_detail_name"].ToString()+t["prop_3_detail_name"].ToString()
                    //+t["prop_4_detail_name"].ToString()+t["prop_5_detail_name"].ToString(),
                    Field9 = t["Field9"].ToString(),
                    isGB   = Convert.ToInt32(t["isGB"]),
                    GG     =
                        ggDs.Tables[0].AsEnumerable()
                        .Where(tt => tt["sku_id"].ToString() == t["sku_id"].ToString())
                        .Select(tt => new GuiGeInfo
                    {
                        PropName1       = tt["prop_1_name"].ToString(),
                        PropDetailName1 = tt["prop_1_detail_name"].ToString(),
                        PropName2       = tt["prop_2_name"].ToString(),
                        PropDetailName2 = tt["prop_2_detail_name"].ToString(),
                        PropName3       = tt["prop_3_name"].ToString(),
                        PropDetailName3 = tt["prop_3_detail_name"].ToString(),
                        PropName4       = tt["prop_4_name"].ToString(),
                        PropDetailName4 = tt["prop_4_detail_name"].ToString(),
                        PropName5       = tt["prop_5_name"].ToString(),
                        PropDetailName5 = tt["prop_5_detail_name"].ToString()
                    }).FirstOrDefault(),
                    SalesPrice = Convert.ToDecimal(t["enter_price"]),
                    //DiscountRate = Convert.ToDecimal(t["discount_rate"]),
                    DiscountRate     = Convert.ToDecimal(t["order_discount_rate"]),
                    ItemCategoryName = t["itemCategoryName"].ToString(),
                    BeginDate        = t["Field1"].ToString(),
                    EndDate          = t["Field2"].ToString(),
                    DayCount         = Convert.ToInt32(t["DayCount"]),
                    Qty       = Convert.ToDecimal(t["enter_qty"]),
                    ImageInfo =
                        imageDs.Tables[0].AsEnumerable()
                        .Where(c => c["ObjectId"].ToString() == t["item_id"].ToString())
                        .OrderBy(c => c["displayIndex"])
                        .Select(c => new OrderDetailImage
                    {
                        ImageID  = c["imageId"].ToString(),
                        ImageUrl = ImagePathUtil.GetImagePathStr(c["imageUrl"].ToString(), "240")
                    }).ToArray(),
                    IfService = Convert.ToInt32(t["IfService"])
                });

                int tempCount = 0;
                foreach (var i in tmp)
                {
                    if (i.IfService == 0)
                    {
                        tempCount++;
                    }
                }
                if (tempCount == 0)
                {
                    rd.OrderListInfo.IsAllService = 3; // 3-全部为虚拟商品
                }
                else if (tempCount == tmp.Count())
                {
                    rd.OrderListInfo.IsAllService = 1; // 1-全部为实物商品
                }
                else
                {
                    rd.OrderListInfo.IsAllService = 2; // 2-包含实物商品和虚拟商品
                }

                #region 根据商品获取配送方式

                var deliveryIds = new List <int?>();
                if (rd.OrderListInfo.IsAllService == 3)
                {
                    deliveryIds.Add(1);
                    deliveryIds.Add(2);
                    deliveryIds.Add(4);
                    rd.OrderListInfo.CanUseDeliveryIDs = deliveryIds;
                }
                else
                {
                    T_Item_Delivery_MappingBLL mappingBll = new T_Item_Delivery_MappingBLL(this.CurrentUserInfo);

                    var complexCondition = new List <IWhereCondition> {
                    };
                    var itemIdArray      = ItemIdList.Replace("'", "").Split(',');
                    complexCondition.Add(new InCondition <string>()
                    {
                        FieldName = "Item_Id", Values = itemIdArray
                    });

                    var itemDeliveryList = mappingBll.Query(complexCondition.ToArray(), null);

                    bool needAddDelivery4 = false;
                    bool needAddDelivery2 = false;
                    if (itemDeliveryList.ToList().Find(d => d.DeliveryId == 4) != null)
                    {
                        needAddDelivery4 = true;
                    }
                    else
                    {
                        if (itemDeliveryList.ToList().Find(d => d.DeliveryId == 2) != null)
                        {
                            needAddDelivery2 = true;
                        }
                    }

                    var itemDeliveryGroupList = itemDeliveryList.GroupBy(d => d.Item_Id);

                    var index = 0;
                    foreach (var info in itemDeliveryGroupList)
                    {
                        var tmpList = info.ToList <T_Item_Delivery_MappingEntity>(); //分组后的集合
                        if (index == 0)
                        {
                            deliveryIds.AddRange(tmpList.Select(d => d.DeliveryId));
                            index++;
                            continue;
                        }
                        deliveryIds = deliveryIds.Intersect(tmpList.Select(d => d.DeliveryId)).ToList();
                        if (deliveryIds.Count <= 0)
                        {
                            break; // 后面的不用求了
                        }
                        index++;
                    }

                    if (!deliveryIds.Contains(4) && needAddDelivery4)
                    {
                        deliveryIds.Add(4);
                    }

                    if (!deliveryIds.Contains(2) && needAddDelivery2)
                    {
                        deliveryIds.Add(2);
                    }

                    rd.OrderListInfo.CanUseDeliveryIDs = deliveryIds.OrderBy(t => t.Value).ToList();
                }

                #endregion

                rd.OrderListInfo.OrderDetailInfo = tmp.ToArray();
            }


            var vipIntegralDetailBll = new VipIntegralDetailBLL(this.CurrentUserInfo);
            // var integral = vipIntegralDetailBll.GetVipIntegralByOrder(orderId, pRequest.UserID);
            //使用积分
            rd.OrderListInfo.OrderIntegral = Math.Abs(vipIntegralDetailBll.GetVipIntegralByOrder(orderId, vipNo));
            //积分抵扣金额 add by Henry 2014-10-8
            //decimal integralAmountPre = vipBll.GetIntegralAmountPre(this.CurrentUserInfo.ClientID);//获取积分金额比例
            //rd.OrderListInfo.UseIntegralToAmount =rd.OrderListInfo.OrderIntegral*(integralAmountPre>0?integralAmountPre:0.01M);
            rd.OrderListInfo.UseIntegralToAmount = vipBll.GetAmountByIntegralPer(CurrentUserInfo.ClientID, rd.OrderListInfo.OrderIntegral);

            var couponUseBll = new CouponUseBLL(this.CurrentUserInfo);

            var couponParValue = couponUseBll.GetCouponParValue(orderId);
            rd.OrderListInfo.CouponAmount = couponParValue;


            var vipAmountDetailBll = new VipAmountDetailBLL(this.CurrentUserInfo);
            //使用的账户余额
            rd.OrderListInfo.VipEndAmount = Math.Abs(vipAmountDetailBll.GetVipAmountByOrderId(orderId, vipNo, 1));
            //使用余额,将余额从实付款中分开
            if (rd.OrderListInfo.VipEndAmount != 0)
            {
                rd.OrderListInfo.ActualDecimal = rd.OrderListInfo.ActualDecimal - rd.OrderListInfo.VipEndAmount;
            }
            //使用的返现金额
            rd.OrderListInfo.ReturnAmount = Math.Abs(vipAmountDetailBll.GetVipAmountByOrderId(orderId, vipNo, 13));
            //使用阿拉币和阿拉币抵扣 add by Henry 2014-10-13
            if (pRequest.ChannelId == "4")//阿拉丁APP调用
            {
                decimal aldAmount = Math.Abs(vipAmountDetailBll.GetVipAmountByOrderId(orderId, vipNo, 11));
                rd.OrderListInfo.ALDAmount      = aldAmount;
                rd.OrderListInfo.ALDAmountMoney = aldAmount * 0.01M;
            }
            #region 获取订单积分,优惠券金额,使用余额


            //var vipIntegralDetailBll = new VipIntegralDetailBLL(this.CurrentUserInfo);

            //var vipIntegralList = vipIntegralDetailBll.QueryByEntity(new VipIntegralDetailEntity()
            //{
            //    VIPID = pRequest.UserID,
            //    ObjectId = orderId
            //}, null);
            //if (vipIntegralList != null && vipIntegralList.Length > 0)
            //{
            //    rd.OrderListInfo.OrderIntegral = Math.Abs(vipIntegralList[0].Integral??0);
            //}

            //var tOrderCouponMappingBll = new TOrderCouponMappingBLL(this.CurrentUserInfo);

            //var tOrderCouponMappingList = tOrderCouponMappingBll.QueryByEntity(new TOrderCouponMappingEntity()
            //{
            //    OrderId = orderId
            //}, null);
            //if (tOrderCouponMappingList != null && tOrderCouponMappingList.Length > 0)
            //{
            //    var couponId = tOrderCouponMappingList[0].CouponId;

            //    var couponBll = new CouponBLL(this.CurrentUserInfo);
            //    var couponEntity = couponBll.GetByID(couponId);

            //    if (couponEntity != null)
            //    {
            //        var couponTypeId = couponEntity.CouponTypeID;

            //        var couponTypeBll = new CouponTypeBLL(this.CurrentUserInfo);
            //        var couponTypeEntity = couponTypeBll.GetByID(couponTypeId);
            //        if (couponTypeEntity != null)
            //        {
            //            rd.OrderListInfo.CouponAmount = couponTypeEntity.ParValue ?? 0;
            //        }
            //    }
            //}
            //var vipAmountDetailBll = new VipAmountDetailBLL(this.CurrentUserInfo);
            //var vipAmountDetailList = vipAmountDetailBll.QueryByEntity(new VipAmountDetailEntity()
            //{
            //    VipId = pRequest.UserID,
            //    ObjectId = orderId
            //}, null);

            //if (vipAmountDetailList != null && vipAmountDetailList.Length > 0)
            //{
            //    rd.OrderListInfo.VipEndAmount = Math.Abs(vipAmountDetailList[0].Amount ?? 0);
            //}

            #endregion
            return(rd);
        }