예제 #1
0
        public void setOrderInfo()
        {
            APIRequest request = new APIRequest();

            request.common            = new CommonReqPara();
            request.common.customerId = "6c1ce52aa43441a3a13c87b41fcafd54";
            SetOrderInfoReqPara para = new SetOrderInfoReqPara();

            para.eventId         = new Guid("188660F3-6AA9-4686-A3D0-1C1D2A9772EE");
            para.qty             = "1";
            para.storeId         = "";
            para.totalAmount     = "2";
            para.mobile          = "";
            para.remark          = "";
            para.reqBy           = "1";
            para.joinNo          = "3";
            para.isPanicbuying   = "1";
            para.salesPrice      = "1";
            para.stdPrice        = "1";
            para.orderDetailList = new OrderDetail[] {
                new OrderDetail()
                {
                    salesPrice = "1", qty = "1", skuId = "0736cd34d0334e61232d058f9a96c491"
                }
            };
            request.special = para;

            string json = string.Format("action=setOrderInfo&ReqContent={0}", request.ToJSON());

            json = HttpUtility.UrlDecode("action=setOrderInfo&ReqContent=%7B%22common%22%3A%7B%22isAld%22%3A%220%22%2C%22baiduPushUserId%22%3Anull%2C%22baiduPushChannelId%22%3Anull%2C%22channelId%22%3A%224%22%2C%22locale%22%3A1%2C%22version%22%3Anull%2C%22plat%22%3A%22android%22%2C%22customerId%22%3A%2286a575e616044da3ac2c3ab492e44445%22%2C%22sessionId%22%3Anull%2C%22baiduPushAppId%22%3Anull%2C%22deviceToken%22%3Anull%2C%22userId%22%3A%229825938c3dc54c5ea172eea667115971%22%2C%22businessZoneId%22%3Anull%2C%22osInfo%22%3Anull%2C%22openId%22%3A%229825938c3dc54c5ea172eea667115971%22%7D%2C%22special%22%3A%7B%22tableNumber%22%3A%22%22%2C%22status%22%3A%22100%22%2C%22remark%22%3A%22%22%2C%22isGroupBy%22%3A0%2C%22joinNo%22%3A1%2C%22qty%22%3A3%2C%22username%22%3A%22%22%2C%22couponsPrompt%22%3A%22%22%2C%22deliveryId%22%3A%222%22%2C%22deliveryTime%22%3A%2218%3A35%3A35%22%2C%22eventId%22%3A%22061e0a01-3ec6-4471-bdf7-9ba9e6db4638%22%2C%22email%22%3A%22%22%2C%22reqBy%22%3A1%2C%22totalAmount%22%3A687.0%2C%22orderDetailList%22%3A%5B%7B%22beginDate%22%3A%222014-04-01+00%3A00%3A00%22%2C%22dayCount%22%3A0%2C%22discountRate%22%3A0.0%2C%22displayIndex%22%3A0%2C%22endDate%22%3A%222015-04-03+00%3A00%3A00%22%2C%22gg%22%3Anull%2C%22imageUrl%22%3A%22http%3A%2F%2Fwww.o2omarketing.cn%3A8400%2FFramework%2FUpload%2FImage%2F20140321%2F7ACDEEB3A26E479397D82F2FB38C89E4.png%22%2C%22itemCategoryName%22%3Anull%2C%22itemId%22%3A%221664035A8087491BB2B74D776334BF38%22%2C%22itemName%22%3A%22%E8%BF%9E%E9%94%81%E5%AF%86%E7%A0%81%E4%B9%A6%22%2C%22price%22%3A229.0%2C%22qty%22%3A3%2C%22salesPrice%22%3A195.0%2C%22selDate%22%3Anull%2C%22skuId%22%3A%227716d8389245544842456bc7f2b88d9e%22%2C%22selected%22%3Atrue%7D%5D%2C%22actualAmount%22%3A585.0%2C%22storeId%22%3Anull%2C%22deliveryAddress%22%3A%22%22%2C%22isPanicbuying%22%3A1%2C%22mobile%22%3A%22%22%7D%7D");
            var rsp = SendHttpRequest(url, json);

            Console.WriteLine(rsp);
        }
        public void ExecProcPEventItemQty(SetOrderInfoReqPara para, T_InoutEntity pEntity, SqlTransaction tran)
        {
            string sql = string.Format("exec spPEventItemQty '{0}','{1}','{2}','{3}'", para.customerId, para.eventId, pEntity.order_id, para.userId);

            if (tran != null)
            {
                this.SQLHelper.ExecuteNonQuery(tran, CommandType.Text, sql);
            }
            else
            {
                this.SQLHelper.ExecuteNonQuery(sql);
            }
        }
예제 #3
0
        public string SetOrderInfo(SetOrderInfoReqPara para)
        {
            var loggingSessionInfo = this.CurrentUserInfo as LoggingSessionInfo;
            //获取订单号
            TUnitExpandBLL serviceUnitExpand = new TUnitExpandBLL(loggingSessionInfo);
            string         OrderCode         = serviceUnitExpand.GetUnitOrderNo();

            ////如果StoreID为空,是在线商城订单,重复的逻辑
            //if (string.IsNullOrEmpty(para.storeId.Trim()))
            //{
            //    UnitService unitServer = new UnitService(loggingSessionInfo);
            //    para.storeId = unitServer.GetUnitByUnitType("OnlineShopping", null).Id; //获取在线商城的门店标识
            //}

            //判断活动的有效性

            #region 活动有效性


            decimal salesPrice = 0;                         //活动销售价
            decimal qty        = Convert.ToInt32(para.qty); //所购数量
            //砍价活动
            if (para.isBargain == "1")
            {
                var eventBll = new PanicbuyingEventBLL(loggingSessionInfo);
                var detail   = eventBll.GetKJEventWithSkuDetail(para.eventId.ToString(), para.orderDetailList[0].skuId.ToString());
                if (detail == null)
                {
                    throw new Exception("未找到相关活动商品信息");
                }
                //1.需要判断,该订单的商品是否还有盈余
                if (detail.RemainingQty <= 0)
                {
                    throw new Exception("活动商品数量不足,当前数量:0");
                }
                //2.判断,该商品活动是否已经终止
                if (!string.IsNullOrEmpty(detail.StopReason))
                {
                    throw new Exception("活动已停止,停止原因:" + detail.StopReason);
                }
                //3.判断购买个数是否小于等于剩余个数
                if (int.Parse(para.qty) > detail.RemainingQty)
                {
                    throw new Exception("活动商品数量不足,当前数量:" + detail.RemainingQty);
                }

                //获取当前会员购买个数
                if (detail.SinglePurchaseQty > 0)//限购
                {
                    List <IWhereCondition> buyCondition = new List <IWhereCondition> {
                    };
                    buyCondition.Add(new EqualsCondition()
                    {
                        FieldName = "VipId", Value = para.userId
                    });
                    buyCondition.Add(new EqualsCondition()
                    {
                        FieldName = "itemId", Value = detail.ItemId
                    });
                    //修改为商品与活动都筛选 xiaowen.qin 2016.5.21
                    buyCondition.Add(new EqualsCondition()
                    {
                        FieldName = "EventId", Value = para.eventId
                    });
                    buyCondition.Add(new DirectCondition(" EventOrderMappingId IS NOT NULL "));
                    var panicbuyingKJEventJoinBLL = new PanicbuyingKJEventJoinBLL(loggingSessionInfo);
                    int buyCount = panicbuyingKJEventJoinBLL.Query(buyCondition.ToArray(), null).Count();
                    if (buyCount + int.Parse(para.qty) > detail.SinglePurchaseQty)
                    {
                        throw new Exception("限购" + detail.SinglePurchaseQty + "件,你还能购买" + (detail.SinglePurchaseQty - buyCount) + "件,请修改购买数量");
                    }
                }
            }
            else //团购抢购
            {
                var eventBll = new vwItemPEventDetailBLL(loggingSessionInfo);
                var detail   = eventBll.GetByEventIDAndSkuID(para.eventId, para.orderDetailList[0].skuId.ToString());
                salesPrice       = detail.SalesPrice ?? 0;        //团购抢购销售价
                para.totalAmount = (salesPrice * qty).ToString(); //团购抢购总金额
                if (detail == null)
                {
                    throw new Exception("未找到相关活动商品信息");
                }
                //1.需要判断,该订单的商品是否还有盈余
                if (detail.RemainingQty <= 0)
                {
                    throw new Exception("活动商品数量不足,当前数量:0");
                }
                //2.判断,该商品活动是否已经终止
                if (!string.IsNullOrEmpty(detail.StopReason))
                {
                    throw new Exception("活动已停止,停止原因:" + detail.StopReason);
                }
                //3.判断购买个数是否小于等于剩余个数
                if (int.Parse(para.qty) > detail.RemainingQty)
                {
                    throw new Exception("活动商品数量不足,当前数量:" + detail.RemainingQty);
                }
            }

            if (string.IsNullOrEmpty(para.userId))
            {
                throw new Exception("会员信息不存在");
            }

            #endregion

            //订单类型

            #region 根据订单参数设置订单类型

            string order_reason_id = string.Empty;
            if (para.isGroupBy == "1") //团购
            {
                order_reason_id = "CB43DD7DD1C94853BE98C4396738E00C";
            }
            else if (para.isPanicbuying == "1") //抢购
            {
                order_reason_id = "671E724C85B847BDA1E96E0E5A62055A";
            }
            else if (para.isBargain == "1") //砍价
            {
                order_reason_id = "096419BFDF394F7FABFE0DFCA909537F";
            }
            else //普通
            {
                order_reason_id = "2F6891A2194A4BBAB6F17B4C99A6C6F5";
            }

            #endregion

            //创建事务
            var tran    = this._currentDAO.GetTran();
            var orderId = string.Empty;
            try
            {
                using (tran.Connection)
                {
                    T_InoutEntity entity = new T_InoutEntity()
                    {
                        #region 订单初始化
                        order_date       = DateTime.Now.ToString("yyyy-MM-dd"),
                        order_type_id    = "1F0A100C42484454BAEA211D4C14B80F",
                        create_time      = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                        customer_id      = para.customerId,
                        status           = "1",
                        total_qty        = Convert.ToDecimal(para.qty),
                        unit_id          = para.storeId,
                        order_no         = OrderCode,
                        order_id         = Guid.NewGuid().ToString("N"),
                        order_reason_id  = order_reason_id,                    //订单类型:普通,团购,抢购
                        red_flag         = "1",
                        warehouse_id     = "67bb4c12785c42d4912aff7d34606592", //???是否是这个??
                        create_unit_id   = para.storeId,
                        create_user_id   = para.userId,
                        total_amount     = Convert.ToDecimal(para.totalAmount),
                        actual_amount    = Convert.ToDecimal(para.actualAmount),
                        discount_rate    = para.Rate,
                        total_retail     = Convert.ToDecimal(para.totalAmount),
                        print_times      = Convert.ToInt32(para.joinNo),
                        vip_no           = para.userId,
                        data_from_id     = para.reqBy,
                        if_flag          = "0",
                        remark           = para.remark,
                        Field1           = "0",
                        Field3           = para.isALD,
                        Field7           = "-99",
                        Field8           = para.deliveryId,
                        send_time        = para.deliveryTime,
                        Field9           = para.deliveryTime,
                        Field4           = para.deliveryAddress,
                        Field6           = para.mobile,
                        Field12          = para.email,
                        Field13          = para.openId,
                        Field10          = "未审核",
                        Field14          = para.username,
                        Field20          = para.tableNumber,
                        Field16          = para.couponsPrompt,
                        Field15          = order_reason_id,
                        sales_unit_id    = para.storeId,
                        purchase_unit_id = para.storeId
                                           #endregion
                    };
                    //订单状态
                    if (loggingSessionInfo.CurrentLoggingManager.IsApprove == null ||
                        loggingSessionInfo.CurrentLoggingManager.IsApprove.Equals("0"))
                    {
                        entity.status      = "100";
                        entity.status_desc = "未审批";
                    }
                    //创建订单
                    this._currentDAO.Create(entity, tran);
                    orderId = entity.order_id;
                    //创建订单明细

                    #region 订单明细列表

                    var detailbll = new T_Inout_DetailBLL(loggingSessionInfo);
                    foreach (var item in para.orderDetailList)
                    {
                        var detailEntity = new T_Inout_DetailEntity()
                        {
                            create_time         = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                            create_user_id      = para.userId,
                            modify_time         = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                            modify_user_id      = para.userId,
                            unit_id             = para.storeId,
                            discount_rate       = para.Rate,
                            std_price           = Convert.ToDecimal(item.salesPrice),
                            enter_price         = Convert.ToDecimal(item.salesPrice),
                            sku_id              = item.skuId,
                            enter_qty           = Convert.ToDecimal(para.qty),
                            order_id            = entity.order_id,
                            order_detail_id     = Guid.NewGuid().ToString("N"),
                            order_qty           = entity.total_qty,
                            enter_amount        = item.Amount,
                            order_detail_status = "1",
                            retail_amount       = item.Amount,
                            retail_price        = item.Amount,
                            display_index       = 1,
                            if_flag             = 0
                        };
                        detailbll.Create(detailEntity, tran);
                    }

                    #endregion

                    //下订单,修改抢购商品的数量信息存储过程ProcPEventItemQty
                    //var eventbll = new vwItemPEventDetailBLL(loggingSessionInfo);
                    //eventbll.ExecProcPEventItemQty(para, entity, tran);
                    tran.Commit();
                }
            }
            catch (Exception ex)
            {
                tran.Rollback();
                throw ex;
            }
            //
            return(orderId);
        }
 public void ExecProcPEventItemQty(SetOrderInfoReqPara para, T_InoutEntity pEntity, SqlTransaction tran)
 {
     this._currentDAO.ExecProcPEventItemQty(para, pEntity, tran);
 }