Exemplo n.º 1
0
 internal void Delete(T_InoutEntity dbEntity)
 {
     using (var conn = new SqlConnection(ConnectionString.XgxInsert))
     {
         conn.Open();
         conn.Delete(dbEntity);
     }
 }
Exemplo n.º 2
0
 internal void Update(T_InoutEntity dbEntity)
 {
     using (var conn = new SqlConnection(ConnectionString.XgxInsert))
     {
         dbEntity.modify_time = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
         //dbEntity.modify_user_id = "ERP";
         conn.Open();
         conn.Update(dbEntity);
     }
 }
        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);
            }
        }
        /// <summary>
        /// 入队列
        /// </summary>
        /// <param name="loggingSessionInfo"></param>
        /// <param name="orderInfo"></param>
        public void SetRedisSalesVipCardOrder(LoggingSessionInfo loggingSessionInfo, T_InoutEntity orderInfo)
        {
            var response = RedisOpenAPI.Instance.CCSalesCardOrder().SetSalesCardOrder(new CC_Order
            {
                CustomerID = loggingSessionInfo.ClientID,
                OrderId    = orderInfo.order_id.ToString(),
                OrderInfo  = orderInfo.JsonSerialize()
            });

            if (response.Code == ResponseCode.Fail)
            {
                //直接计算
                T_InoutBLL inoutBLL = new T_InoutBLL(loggingSessionInfo);
                inoutBLL.CalculateSalesVipCardOrder(loggingSessionInfo, orderInfo);
            }
        }
        public void OrderReward(T_InoutEntity orderInfo, LoggingSessionInfo loggingSessionInfo, SqlTransaction tran)
        {
            //下面往redis里存入数据
            var response = RedisOpenAPI.Instance.CCOrderReward().SeOrderReward(new CC_OrderReward
            {
                CustomerID = loggingSessionInfo.ClientID,
                LogSession = loggingSessionInfo.JsonSerialize(),
                OrderInfo  = orderInfo.JsonSerialize(),
                OrderID    = orderInfo.order_id
            });

            //如果往缓存redis里写入不成功,还是按照原来的老方法往数据库里写
            if (response.Code != ResponseCode.Success)
            {
                new VipIntegralBLL(loggingSessionInfo).OrderReward(orderInfo, tran);//还是把原来的事务传进去
                new RedisXML().RedisReadDBCount("OrderReward", "确认收货/完成订单 - 处理奖励", 2);
            }
            else
            {
                new RedisXML().RedisReadDBCount("OrderReward", "确认收货/完成订单 - 处理奖励", 1);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 在队列失效的情况下,直接计算
        /// </summary>
        /// <param name="loggingSessionInfo"></param>
        /// <param name="orderInfo"></param>
        public void CalculateVipConsumeForUpgrade(LoggingSessionInfo loggingSessionInfo, T_InoutEntity orderInfo)
        {
            VipCardUpgradeRuleBLL bllVipCardUpgradeRule = new VipCardUpgradeRuleBLL(loggingSessionInfo);
            VipCardVipMappingBLL  vipCardVipMappingBLL  = new VipCardVipMappingBLL(loggingSessionInfo);
            T_InoutBLL            bllInout = new T_InoutBLL(loggingSessionInfo);
            var entityVipCardUpgradeRule   = bllVipCardUpgradeRule.QueryByEntity(new VipCardUpgradeRuleEntity()
            {
                IsBuyUpgrade = 1, CustomerID = loggingSessionInfo.ClientID
            }, null);

            if (entityVipCardUpgradeRule != null)
            {
                decimal vipSumAmount = bllInout.GetVipSumAmount(orderInfo.vip_no);
                bool    isUpdate     = false;
                foreach (var rule in entityVipCardUpgradeRule.OrderByDescending(a => a.VipCardTypeID))
                {
                    if (rule.BuyAmount > 0)
                    {
                        if (vipSumAmount >= rule.BuyAmount)
                        {
                            if (!isUpdate)
                            {
                                vipCardVipMappingBLL.BindVirtualItem(orderInfo.vip_no, orderInfo.VipCardCode, "", (int)rule.VipCardTypeID, "TotalSales", 2, orderInfo.order_id);
                                isUpdate = true;
                            }
                        }
                    }
                    if (rule.OnceBuyAmount > 0)
                    {
                        if (orderInfo.actual_amount >= rule.OnceBuyAmount)
                        {
                            if (!isUpdate)
                            {
                                vipCardVipMappingBLL.BindVirtualItem(orderInfo.vip_no, orderInfo.VipCardCode, "", (int)rule.VipCardTypeID, "OneSales", 2, orderInfo.order_id);
                                isUpdate = true;
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 7
0
        private T_InoutEntity ConvertToT_Inout(OrderContract contract)
        {
            var vipFacade = new VipFacade();
            var vipEntity = vipFacade.GetById(contract.VipNo);

            var carrierId = contract.Delivery == EnumDelivery.HomeDelivery ? string.Empty : contract.CreateUnit;
            var statusStr = ((int)contract.Status).ToString();

            var result = new T_InoutEntity
            {
                order_id              = contract.OrderId,
                order_no              = contract.OrderNo,
                VipCardCode           = vipEntity.VipCode,
                order_type_id         = GetEnumOrderType(contract.OrderType),
                order_reason_id       = GetEnumOrderReason(contract.OrderReason),
                red_flag              = red_flag,
                warehouse_id          = "",
                order_date            = contract.OrderDate,
                request_date          = string.Empty,
                complete_date         = contract.CompleteDate,
                create_unit_id        = contract.CreateUnit,
                unit_id               = contract.CreateUnit,
                related_unit_id       = string.Empty,
                related_unit_code     = string.Empty,
                pos_id                = string.Empty,
                shift_id              = string.Empty,
                sales_user            = string.Empty,
                total_amount          = contract.TotalAmount,
                discount_rate         = contract.DiscountRate,
                actual_amount         = contract.ActualAmount,
                receive_points        = contract.ReceivePoints,
                pay_points            = contract.PayPoints,
                pay_id                = string.Empty,
                print_times           = 0,
                carrier_id            = carrierId,
                remark                = contract.Remark,
                status                = statusStr,
                status_desc           = GetStatusDescByStatus(contract.Status),
                total_qty             = contract.TotalQty,
                total_retail          = contract.TotalRetail,
                keep_the_change       = contract.KeepTheChange,
                wiping_zero           = contract.WipingZero,
                vip_no                = contract.VipNo,
                create_time           = contract.CreateTime,
                create_user_id        = contract.CreateUserId,
                approve_time          = contract.ApproveTime,
                approve_user_id       = contract.ApproveUserId,
                send_user_id          = contract.SendUserId,
                send_time             = contract.SendTime,
                accpect_user_id       = contract.AccpectUserId,
                accpect_time          = contract.AccpectTime,
                modify_user_id        = contract.ModifyUserId,
                modify_time           = contract.ModifyTime,
                data_from_id          = "3",
                sales_unit_id         = contract.SalesUnt,
                purchase_unit_id      = contract.PurchaseUnit,
                if_flag               = "0",
                customer_id           = ConfigMgr.CustomerId,
                sales_warehouse_id    = contract.SalesWarehouse,
                purchase_warehouse_id = contract.PurchaseWarehouse,
                Field1                = ((int)contract.IsPay).ToString(),
                Field2                = contract.TrackingNumber,
                Field3                = contract.BalancePayment,
                Field4                = contract.Address,
                Field6                = contract.Phone,
                Field7                = statusStr,
                Field8                = ((int)contract.Delivery).ToString(),
                Field9                = contract.DeliveryDateTime,
                Field10               = GetStatusDescByStatus(contract.Status),
                Field11               = string.Empty,
                Field12               = string.Empty,
                Field13               = vipEntity.WeiXinUserId,
                Field14               = contract.UserName,
                Field15               = string.Empty,
                Field16               = string.Empty,
                Field17               = string.Empty,
                Field18               = string.Empty,
                Field19               = string.Empty,
                Field20               = string.Empty,
                reserveQuantum        = contract.RequestDateQuantum,
                reserveDay            = contract.RequestDate,
                paymentcenter_id      = null,
                ReturnCash            = contract.CashBack,
            };

            return(result);
        }
Exemplo n.º 8
0
 public void Delete(T_InoutEntity dbEntity)
 {
     _cmd.Delete(dbEntity);
 }
Exemplo n.º 9
0
 public void Update(T_InoutEntity dbEntity)
 {
     _cmd.Update(dbEntity);
 }
Exemplo n.º 10
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 /// <param name="pTran">事务实例,可为null,如果为null,则不使用事务来更新</param>
 public void Update(T_InoutEntity pEntity, IDbTransaction pTran)
 {
     _currentDAO.Update(pEntity, pTran);
 }
Exemplo n.º 11
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 /// <param name="pTran">事务实例,可为null,如果为null,则不使用事务来更新</param>
 public void Delete(T_InoutEntity pEntity, IDbTransaction pTran)
 {
     _currentDAO.Delete(pEntity, pTran);
 }
Exemplo n.º 12
0
 /// <summary>
 /// 分页根据实体条件查询实体
 /// </summary>
 /// <param name="pQueryEntity">以实体形式传入的参数</param>
 /// <param name="pOrderBys">排序组合</param>
 /// <returns>符合条件的实体集</returns>
 public PagedQueryResult <T_InoutEntity> PagedQueryByEntity(T_InoutEntity pQueryEntity, OrderBy[] pOrderBys, int pPageSize, int pCurrentPageIndex)
 {
     return(_currentDAO.PagedQueryByEntity(pQueryEntity, pOrderBys, pPageSize, pCurrentPageIndex));
 }
Exemplo n.º 13
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 public void Update(T_InoutEntity pEntity)
 {
     _currentDAO.Update(pEntity);
 }
Exemplo n.º 14
0
        //<summary>
        //Pos订单入库
        //</summary>
        //<param name="pRequest"></param>
        //<returns></returns>
        protected override SetPosOrderRD ProcessRequest(APIRequest <SetPosOrderRP> pRequest)
        {
            //请求参数
            var rp = pRequest.Parameters;
            //返回参数
            var rd = new SetPosOrderRD();

            //订单
            var inoutBll    = new T_InoutBLL(CurrentUserInfo);
            var inoutDetail = new T_Inout_DetailBLL(CurrentUserInfo);
            //商品
            var itemCategoryBll = new T_Item_CategoryBLL(CurrentUserInfo);
            var itemBll         = new T_ItemBLL(CurrentUserInfo);
            var porpBll         = new T_PropBLL(CurrentUserInfo);
            var itemSkuPropBll  = new T_ItemSkuPropBLL(CurrentUserInfo);
            var skuBll          = new T_SkuBLL(CurrentUserInfo);
            var skuPriceBll     = new T_Sku_PriceBLL(CurrentUserInfo);
            var skuProperty     = new T_Sku_PropertyBLL(CurrentUserInfo);
            //获取会员信息
            var vipBll  = new VipBLL(CurrentUserInfo);
            var vipInfo = vipBll.GetByID(pRequest.UserID);
            var vipCardVipMappingBll    = new VipCardVipMappingBLL(CurrentUserInfo);
            var vipCardBll              = new VipCardBLL(CurrentUserInfo);
            var vipCardVipMappingEntity = vipCardVipMappingBll.QueryByEntity(new VipCardVipMappingEntity()
            {
                VIPID = vipInfo.VIPID, CustomerID = CurrentUserInfo.ClientID
            }, null).FirstOrDefault();
            string VipCardTypeID = ""; //卡类型Id

            if (vipCardVipMappingEntity != null)
            {
                var vipCardEntity = vipCardBll.GetByID(vipCardVipMappingEntity.VipCardID);
                VipCardTypeID = vipCardEntity.VipCardTypeID.ToString();
            }
            //员工
            var userBll = new T_UserBLL(CurrentUserInfo);

            //获取门店信息
            var          unitBll  = new t_unitBLL(CurrentUserInfo);
            t_unitEntity unitInfo = null;

            if (!string.IsNullOrEmpty(rp.UnitCode))
            {
                unitInfo = unitBll.QueryByEntity(new t_unitEntity()
                {
                    unit_code = rp.UnitCode, customer_id = CurrentUserInfo.ClientID
                }, null).FirstOrDefault();
                if (unitInfo == null)
                {
                    throw new APIException("请在正念商户后台录入相应门店")
                          {
                              ErrorCode = 100
                          };
                }
            }
            else
            {
                throw new APIException("缺少请求参数:门店编码")
                      {
                          ErrorCode = 102
                      };
            }

            //获取员工信息
            T_UserEntity userEntity = null;

            if (!string.IsNullOrEmpty(rp.MobliePhone))
            {
                userEntity = userBll.QueryByEntity(new T_UserEntity()
                {
                    user_telephone = rp.MobliePhone, customer_id = CurrentUserInfo.ClientID
                }, null).FirstOrDefault();
                //没有员工,新增默认员工(店员APP)
                if (userEntity == null)
                {
                    var roleBll    = new T_RoleBLL(CurrentUserInfo);
                    var roleEntity = roleBll.QueryByEntity(new T_RoleEntity()
                    {
                        role_code = "clerkAPP", customer_id = CurrentUserInfo.ClientID
                    }, null).FirstOrDefault();
                    if (roleEntity == null)
                    {
                        throw new APIException("请在正念商户后台录入相应角色")
                              {
                                  ErrorCode = 100
                              };
                    }
                    userEntity = new T_UserEntity();
                    userEntity.user_telephone = rp.MobliePhone;
                    userEntity.user_code      = rp.UserCode;
                    userEntity.user_name      = rp.UserCode;
                    userEntity.user_birthday  = rp.Birthday;
                    userEntity.user_email     = rp.EmailAddress;
                    userEntity.user_address   = rp.Address;
                    userEntity.user_postcode  = rp.Zip;
                    userBll.AddUser(ref userEntity, unitInfo, roleEntity);
                }
            }
            else
            {
                throw new APIException("缺少请求参数:员工手机号")
                      {
                          ErrorCode = 102
                      };
            }
            //获取会员折扣
            var     sysVipCardGradeBLL = new SysVipCardGradeBLL(CurrentUserInfo);
            decimal vipDiscount        = sysVipCardGradeBLL.GetVipDiscount() * 10;


            //订单号
            string        orderId      = BaseService.NewGuidPub();
            T_InoutEntity tInoutEntity = new T_InoutEntity();

            tInoutEntity.order_id = orderId;
            tInoutEntity.order_no = rp.OrderNo;

            //拼接ItemCodes
            //StringBuilder ItemCodes = new StringBuilder();
            //for (int j = 0; j < pRequest.Parameters.OrderDetailList.Count(); j++)
            //{
            //    if (j != 0)
            //    {
            //        ItemCodes.Append(",");
            //    }
            //    ItemCodes.Append(string.Format("{0}", pRequest.Parameters.OrderDetailList[j].ItemCode));
            //}

            ////通过itemCodes取出商品价格
            //SkuPriceService skuPriceService = new SkuPriceService(CurrentUserInfo);
            //List<SkuPrice> skuPriceList = skuPriceService.GetPriceListByItemCodes(ItemCodes.ToString(), CurrentUserInfo.ClientID);
            //if(skuPriceList.Count == 0)
            //{
            //    throw new APIException("未找到商品") { ErrorCode = 100 };
            //}

            //订单总金额
            decimal totalAmount = rp.TotalAmount;
            //订单实付金额
            decimal ActualAmount = rp.DiscountAmount;
            //订单折扣后金额
            decimal DiscountAmount = rp.DiscountAmount;
            //订单明细显示顺序
            int i = 1;

            //商品价格重新计算
            foreach (var item in pRequest.Parameters.OrderDetailList)
            {
                T_ItemEntity itemEntity = null; //商品
                T_SkuEntity  skuEntity  = null; //sku
                if (!string.IsNullOrEmpty(item.ItemCode))
                {
                    itemEntity = itemBll.QueryByEntity(new T_ItemEntity()
                    {
                        item_code = item.ItemCode, CustomerId = CurrentUserInfo.ClientID
                    }, null).FirstOrDefault();
                    if (itemEntity == null)
                    {
                        if (string.IsNullOrEmpty(item.ItemCategoryCode))
                        {
                            throw new APIException("缺少参数:商品类别名称")
                                  {
                                      ErrorCode = 200
                                  };
                        }
                        itemEntity           = new T_ItemEntity();
                        itemEntity.item_code = item.ItemCode;
                        itemEntity.item_name = item.ItemName;

                        itemBll.AddItem(itemEntity, out skuEntity, item.ItemCategoryName, item.ItemCategoryCode, item.SkuOriginPrice, item.SkuSalesPrice);
                    }
                    else
                    {
                        skuEntity = skuBll.QueryByEntity(new T_SkuEntity()
                        {
                            item_id = itemEntity.item_id
                        }, null).FirstOrDefault();
                    }
                }
                else
                {
                    throw new APIException("缺少参数:商品编码")
                          {
                              ErrorCode = 300
                          };
                }

                //订单明细相关处理
                T_Inout_DetailBLL    inoutDetailBll    = new T_Inout_DetailBLL(CurrentUserInfo);
                T_Inout_DetailEntity inoutDetailEntity = new T_Inout_DetailEntity()
                {
                    order_detail_id     = BaseService.NewGuidPub(),
                    order_id            = orderId,               //订单Id
                    sku_id              = skuEntity.sku_id,      //skuId
                    unit_id             = unitInfo.unit_id,      //门店Id
                    order_qty           = item.Qty,              //订单qty
                    enter_qty           = item.Qty,              //实际qty
                    enter_price         = item.price,            //折扣价
                    enter_amount        = item.price * item.Qty, //折扣价
                    std_price           = item.price,            //原价
                    discount_rate       = vipDiscount,           //折扣
                    retail_price        = item.price * item.Qty, //零售价
                    retail_amount       = item.price * item.Qty, //零售价
                    order_detail_status = "1",
                    display_index       = i,
                    if_flag             = 0
                };
                inoutDetailBll.Create(inoutDetailEntity);
                i++;
            }

            //优惠券使用
            if (!string.IsNullOrEmpty(rp.CouponId))
            {
                #region 判断优惠券是否是该会员的

                var vipcouponMappingBll = new VipCouponMappingBLL(CurrentUserInfo);

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

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

                #endregion

                #region 判断优惠券是否有效

                var couponBll = new CouponBLL(CurrentUserInfo);

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

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

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

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

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

                #endregion

                #region 优惠券核销
                var couponUseBll    = new CouponUseBLL(CurrentUserInfo);
                var couponUseEntity = new CouponUseEntity()
                {
                    CouponUseID    = Guid.NewGuid(),
                    CouponID       = rp.CouponId,
                    VipID          = pRequest.UserID,
                    UnitID         = unitInfo.unit_id,
                    OrderID        = orderId,
                    Comment        = "商城使用电子券",
                    CustomerID     = pRequest.CustomerID,
                    CreateBy       = pRequest.UserID,
                    CreateTime     = DateTime.Now,
                    LastUpdateBy   = pRequest.UserID,
                    LastUpdateTime = DateTime.Now,
                    IsDelete       = 0
                };
                couponUseBll.Create(couponUseEntity);
                #endregion

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

                #endregion

                #region 更新优惠券状态

                couponEntity.Status = 1;
                couponBll.Update(couponEntity);

                #endregion

                ActualAmount -= couponTypeEntity.ParValue ?? 0;
            }

            #region 使用积分
            //使用积分
            if (rp.IntegralFlag == 1)
            {
                var vipIntegralBll = new VipIntegralBLL(CurrentUserInfo);

                string sourceId       = "20"; //积分抵扣
                var    IntegralDetail = new VipIntegralDetailEntity()
                {
                    Integral         = -Convert.ToInt32(rp.Integral),
                    IntegralSourceID = sourceId,
                    ObjectId         = orderId
                };
                if (IntegralDetail.Integral != 0)
                {
                    //变动前积分
                    string OldIntegral = (vipInfo.Integration ?? 0).ToString();
                    //变动积分
                    string ChangeIntegral      = (IntegralDetail.Integral ?? 0).ToString();
                    var    vipIntegralDetailId = vipIntegralBll.AddIntegral(ref vipInfo, unitInfo, IntegralDetail, CurrentUserInfo);
                    //发送微信积分变动通知模板消息
                    if (!string.IsNullOrWhiteSpace(vipIntegralDetailId))
                    {
                        var CommonBLL = new CommonBLL();
                        CommonBLL.PointsChangeMessage(OldIntegral, vipInfo, ChangeIntegral, vipInfo.WeiXinUserId, CurrentUserInfo);
                    }
                }
                tInoutEntity.pay_points     = rp.Integral;
                tInoutEntity.receive_points = rp.Integral;
                ActualAmount -= rp.IntegralAmount;
            }
            #endregion

            #region 余额和返现修改

            var vipAmountBll       = new VipAmountBLL(CurrentUserInfo);
            var vipAmountDetailBll = new VipAmountDetailBLL(CurrentUserInfo);

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

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

            //使用余额
            if (rp.EndAmountFlag == 1)
            {
                var detailInfo = new VipAmountDetailEntity()
                {
                    Amount         = -rp.EndAmount,
                    AmountSourceId = "1",
                    ObjectId       = orderId
                };
                var vipAmountDetailId = vipAmountBll.AddVipAmount(vipInfo, unitInfo, ref vipAmountEntity, detailInfo, CurrentUserInfo);
                if (!string.IsNullOrWhiteSpace(vipAmountDetailId))
                {//发送微信账户余额变动模板消息
                    var CommonBLL = new CommonBLL();
                    CommonBLL.BalanceChangedMessage(tInoutEntity.order_no, vipAmountEntity, detailInfo, vipInfo.WeiXinUserId, vipInfo.VIPID, CurrentUserInfo);
                }
                tInoutEntity.Field3 = rp.EndAmount.ToString();
            }

            #endregion
            //订单主表更新
            tInoutEntity.VipCardCode      = vipInfo.VipCardCode;//会员卡号
            tInoutEntity.order_reason_id  = "2F6891A2194A4BBAB6F17B4C99A6C6F5";
            tInoutEntity.order_type_id    = "1F0A100C42484454BAEA211D4C14B80F";
            tInoutEntity.warehouse_id     = "67bb4c12785c42d4912aff7d34606592";
            tInoutEntity.data_from_id     = "";
            tInoutEntity.red_flag         = "1";
            tInoutEntity.order_date       = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); //订单时间
            tInoutEntity.create_unit_id   = unitInfo.unit_id;                             //门店
            tInoutEntity.unit_id          = unitInfo.unit_id;                             //门店
            tInoutEntity.sales_unit_id    = unitInfo.unit_id;                             //门店
            tInoutEntity.purchase_unit_id = unitInfo.unit_id;
            tInoutEntity.sales_user       = userEntity.user_id;
            tInoutEntity.total_amount     = totalAmount;  //订单金额
            tInoutEntity.discount_rate    = vipDiscount;  //会员折扣
            tInoutEntity.actual_amount    = ActualAmount; //实付金额
            tInoutEntity.total_qty        = rp.qty;
            tInoutEntity.total_retail     = totalAmount;  //订单金额
            tInoutEntity.vip_no           = vipInfo.VIPID;
            tInoutEntity.Field6           = vipInfo.Phone;
            tInoutEntity.Field14          = vipInfo.VipName;
            tInoutEntity.Field17          = VipCardTypeID;
            tInoutEntity.Field12          = DiscountAmount.ToString();
            tInoutEntity.Field11          = "知行易";
            tInoutEntity.customer_id      = CurrentUserInfo.ClientID;

            tInoutEntity.Field1      = "1";   //支付完成
            tInoutEntity.Field7      = "700"; //已完成
            tInoutEntity.status      = "700"; //已完成
            tInoutEntity.status_desc = "已完成";
            tInoutEntity.Field10     = "已完成";
            rd.Amount = ActualAmount - rp.EndAmount;

            inoutBll.Create(tInoutEntity);

            //订单奖励
            new SendOrderRewardMsgBLL().OrderReward(tInoutEntity, this.CurrentUserInfo, null);//存入到缓存
            rd.orderId = orderId;
            return(rd);
        }
    }
}
Exemplo n.º 15
0
        /// <summary>
        /// 计算销售会员卡分润
        /// </summary>
        /// <param name="loggingSessionInfo"></param>
        /// <param name="orderInfo"></param>
        public void CalculateSalesVipCardOrder(LoggingSessionInfo loggingSessionInfo, T_InoutEntity orderInfo)
        {
            if (orderInfo != null)
            {
                if (orderInfo.Field17 != null && orderInfo.Field18 != null && orderInfo.Field17.Length > 0 && orderInfo.Field18.Length > 0)
                {
                    VipBLL bllVip = new VipBLL(loggingSessionInfo);

                    T_Inout_DetailBLL           bllInoutDetail            = new T_Inout_DetailBLL(loggingSessionInfo);
                    T_VirtualItemTypeSettingBLL bllVirtualItemTypeSetting = new T_VirtualItemTypeSettingBLL(loggingSessionInfo);

                    var entityInoutDetail = bllInoutDetail.QueryByEntity(new T_Inout_DetailEntity()
                    {
                        order_id = orderInfo.order_id
                    }, null).FirstOrDefault();
                    var vipCardType = bllVirtualItemTypeSetting.QueryByEntity(new T_VirtualItemTypeSettingEntity()
                    {
                        SkuId = entityInoutDetail.sku_id, IsDelete = 0
                    }, null).FirstOrDefault();
                    if (vipCardType != null)
                    {
                        VipCardUpgradeRuleBLL bllVipCardUpgradeRule = new VipCardUpgradeRuleBLL(loggingSessionInfo);

                        int intVipCardTypeID         = Convert.ToInt32(vipCardType.ObjecetTypeId);
                        var entityVipCardUpgradeRule = bllVipCardUpgradeRule.QueryByEntity(new VipCardUpgradeRuleEntity()
                        {
                            VipCardTypeID = intVipCardTypeID, IsPurchaseUpgrade = 1, IsDelete = 0
                        }, null).SingleOrDefault();
                        #region
                        //if (entityVipCardUpgradeRule != null)
                        //{
                        //    VipCardGradeChangeLogEntity entityVipCardGradeChangeLog = new VipCardGradeChangeLogEntity();
                        //    VipCardStatusChangeLogEntity entityVipCardStatusChangeLog = new VipCardStatusChangeLogEntity();

                        //    VipCardGradeChangeLogBLL bllVipCardGradeChangeLog = new VipCardGradeChangeLogBLL(loggingSessionInfo);
                        //    VipCardStatusChangeLogBLL bllVipCardStatusChangeLog = new VipCardStatusChangeLogBLL(loggingSessionInfo);
                        //    VipCardVipMappingBLL vipCardVipMappingBLL = new VipCardVipMappingBLL(loggingSessionInfo);

                        //    //会员等级改变以及如日志
                        //    DataSet dsVipInfo = bllVip.GetVipCardLevel(orderInfo.vip_no, loggingSessionInfo.ClientID);
                        //    if(dsVipInfo.Tables.Count>0 && dsVipInfo.Tables[0].Rows.Count>0)
                        //    {
                        //        //会员升级
                        //        vipCardVipMappingBLL.BindVirtualItem(orderInfo.vip_no, orderInfo.VipCardCode, "", intVipCardTypeID);
                        //        //日志
                        //        entityVipCardGradeChangeLog = new VipCardGradeChangeLogEntity()
                        //        {
                        //            ChangeLogID=Guid.NewGuid().ToString(),
                        //            VipCardUpgradeRuleId=entityVipCardUpgradeRule.VipCardUpgradeRuleId,
                        //            OrderType = "SalesCard",
                        //            OrderId=orderInfo.order_id,
                        //            VipCardID = dsVipInfo.Tables[0].Rows[0]["VipCardID"].ToString(),
                        //            ChangeBeforeVipCardID = dsVipInfo.Tables[0].Rows[0]["VipCardID"].ToString(),
                        //            ChangeBeforeGradeID = Convert.ToInt32(dsVipInfo.Tables[0].Rows[0]["VipCardTypeID"].ToString()),
                        //            NowGradeID = intVipCardTypeID,
                        //            ChangeReason="Upgrade",
                        //            OperationType = 2,
                        //            ChangeTime=DateTime.Now,
                        //            UnitID=orderInfo.sales_unit_id,
                        //            OperationUserID=orderInfo.sales_user
                        //        };
                        //        bllVipCardGradeChangeLog.Create(entityVipCardGradeChangeLog);
                        //    }
                        //}
                        #endregion
                        //计算分润
                        VipCardProfitRuleBLL bllVipCardProfitRule = new VipCardProfitRuleBLL(loggingSessionInfo);
                        var entityVipCardProfitRule = bllVipCardProfitRule.QueryByEntity(new VipCardProfitRuleEntity()
                        {
                            VipCardTypeID = intVipCardTypeID, IsDelete = 0
                        }, null);
                        if (entityVipCardProfitRule != null)
                        {
                            VipAmountBLL       bllVipAmount       = new VipAmountBLL(loggingSessionInfo);
                            VipAmountDetailBLL bllVipAmountDetail = new VipAmountDetailBLL(loggingSessionInfo);
                            VipAmountEntity    entityVipAmount    = new VipAmountEntity();

                            foreach (var ProfitRule in entityVipCardProfitRule)
                            {
                                decimal amount            = 0;
                                string  strAmountSourceId = string.Empty;
                                string  strVipId          = string.Empty;

                                if (ProfitRule.ProfitOwner == "Employee")
                                {
                                    strAmountSourceId = "37";
                                    strVipId          = orderInfo.sales_user;
                                }
                                if (ProfitRule.ProfitOwner == "Unit")
                                {
                                    strAmountSourceId = "40";
                                    strVipId          = orderInfo.sales_unit_id;
                                }
                                if (ProfitRule.IsApplyAllUnits == 0)
                                {
                                    VipCardProfitRuleUnitMappingBLL bllVipCardProfitRuleUnitMapping = new VipCardProfitRuleUnitMappingBLL(loggingSessionInfo);
                                    var vipCardProfitRuleUnitMapping = bllVipCardProfitRuleUnitMapping.QueryByEntity(new VipCardProfitRuleUnitMappingEntity()
                                    {
                                        CardBuyToProfitRuleId = ProfitRule.CardBuyToProfitRuleId, UnitID = orderInfo.sales_unit_id, IsDelete = 0, CustomerID = loggingSessionInfo.ClientID
                                    }, null).SingleOrDefault();
                                    if (vipCardProfitRuleUnitMapping != null)
                                    {
                                        amount = (decimal)ProfitRule.FirstCardSalesProfitPct * (decimal)orderInfo.actual_amount * (decimal)0.01;
                                    }
                                    else
                                    {
                                        continue;
                                    }
                                }

                                amount = (decimal)ProfitRule.FirstCardSalesProfitPct * (decimal)orderInfo.actual_amount * (decimal)0.01;
                                if (amount > 0)
                                {
                                    IDbTransaction tran = new JIT.CPOS.BS.DataAccess.Base.TransactionHelper(loggingSessionInfo).CreateTransaction();

                                    VipAmountDetailEntity entityVipAmountDetail = new VipAmountDetailEntity
                                    {
                                        VipAmountDetailId = Guid.NewGuid(),
                                        VipId             = strVipId,
                                        Amount            = amount,
                                        UsedReturnAmount  = 0,
                                        EffectiveDate     = DateTime.Now,
                                        DeadlineDate      = Convert.ToDateTime("9999-12-31 23:59:59"),
                                        AmountSourceId    = strAmountSourceId,
                                        ObjectId          = orderInfo.order_id,
                                        CustomerID        = loggingSessionInfo.ClientID,
                                        Reason            = "超级分销商"
                                    };
                                    bllVipAmountDetail.Create(entityVipAmountDetail, (SqlTransaction)tran);

                                    entityVipAmount = new VipAmountEntity
                                    {
                                        VipId                  = strVipId,
                                        BeginAmount            = 0,
                                        InAmount               = amount,
                                        OutAmount              = 0,
                                        EndAmount              = amount,
                                        TotalAmount            = amount,
                                        BeginReturnAmount      = 0,
                                        InReturnAmount         = 0,
                                        OutReturnAmount        = 0,
                                        ReturnAmount           = 0,
                                        ImminentInvalidRAmount = 0,
                                        InvalidReturnAmount    = 0,
                                        ValidReturnAmount      = 0,
                                        TotalReturnAmount      = 0,
                                        IsLocking              = 0,
                                        CustomerID             = loggingSessionInfo.ClientID,
                                        VipCardCode            = ""
                                    };
                                    bllVipAmount.Create(entityVipAmount, tran);
                                }
                                else
                                {
                                    entityVipAmount.InReturnAmount    = (entityVipAmount.InReturnAmount == null ? 0 : entityVipAmount.InReturnAmount.Value) + amount;
                                    entityVipAmount.TotalReturnAmount = (entityVipAmount.TotalReturnAmount == null ? 0 : entityVipAmount.TotalReturnAmount.Value) + amount;

                                    entityVipAmount.ValidReturnAmount = (entityVipAmount.ValidReturnAmount == null ? 0 : entityVipAmount.ValidReturnAmount.Value) + amount;
                                    entityVipAmount.ReturnAmount      = (entityVipAmount.ReturnAmount == null ? 0 : entityVipAmount.ReturnAmount.Value) + amount;
                                    bllVipAmount.Update(entityVipAmount);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// 计算超级分销商佣金分润
        /// </summary>
        /// <param name="loggingSessionInfo"></param>
        /// <param name="orderInfo"></param>
        public void CalculateSuperRetailTraderOrder(LoggingSessionInfo loggingSessionInfo, T_InoutEntity orderInfo)
        {
            if (orderInfo != null)
            {
                if (orderInfo.data_from_id == "35" || orderInfo.data_from_id == "36")
                {
                    T_SuperRetailTraderBLL bllSuperRetailTrader = new T_SuperRetailTraderBLL(loggingSessionInfo);
                    DataSet dsAllFather = bllSuperRetailTrader.GetAllFather(orderInfo.sales_user);
                    if (dsAllFather != null && dsAllFather.Tables.Count > 0 && dsAllFather.Tables[0].Rows.Count > 0)
                    {
                        T_SuperRetailTraderProfitConfigBLL bllSuperRetailTraderProfitConfig = new T_SuperRetailTraderProfitConfigBLL(loggingSessionInfo);
                        T_SuperRetailTraderConfigBLL       bllSuperRetailTraderConfig       = new T_SuperRetailTraderConfigBLL(loggingSessionInfo);
                        T_SuperRetailTraderProfitDetailBLL bllSuperRetailTraderProfitDetail = new T_SuperRetailTraderProfitDetailBLL(loggingSessionInfo);

                        VipAmountBLL       bllVipAmount       = new VipAmountBLL(loggingSessionInfo);
                        VipAmountDetailBLL bllVipAmountDetail = new VipAmountDetailBLL(loggingSessionInfo);

                        var entitySuperRetailTraderProfitConfig = bllSuperRetailTraderProfitConfig.QueryByEntity(new T_SuperRetailTraderProfitConfigEntity()
                        {
                            CustomerId = loggingSessionInfo.ClientID, IsDelete = 0, Status = "10"
                        }, null);
                        var entityConfig = bllSuperRetailTraderConfig.QueryByEntity(new T_SuperRetailTraderConfigEntity()
                        {
                            CustomerId = loggingSessionInfo.ClientID, IsDelete = 0
                        }, null).SingleOrDefault();
                        if (entityConfig != null && entitySuperRetailTraderProfitConfig != null)
                        {
                            //佣金比列
                            decimal SkuCommission = Convert.ToDecimal(entityConfig.SkuCommission) * Convert.ToDecimal(0.01);
                            //商品分润比列
                            decimal DistributionProfit = Convert.ToDecimal(entityConfig.DistributionProfit) * Convert.ToDecimal(0.01);


                            foreach (DataRow dr in dsAllFather.Tables[0].Rows)
                            {
                                decimal amount            = 0;
                                string  strAmountSourceId = string.Empty;
                                T_SuperRetailTraderProfitConfigEntity singlProfitConfig = new T_SuperRetailTraderProfitConfigEntity();
                                if (dr["level"].ToString() == "1")    //佣金
                                {
                                    strAmountSourceId = "34";
                                    singlProfitConfig = entitySuperRetailTraderProfitConfig.Where(a => a.Level == Convert.ToInt16(dr["level"].ToString())).SingleOrDefault();
                                    if (singlProfitConfig != null)
                                    {
                                        if (singlProfitConfig.ProfitType == "Percent")
                                        {
                                            amount = Convert.ToDecimal(orderInfo.actual_amount) * SkuCommission;
                                        }
                                    }
                                }
                                else    //分润
                                {
                                    strAmountSourceId = "33";
                                    singlProfitConfig = entitySuperRetailTraderProfitConfig.Where(a => a.Level == Convert.ToInt16(dr["level"].ToString())).SingleOrDefault();
                                    if (singlProfitConfig != null)
                                    {
                                        if (singlProfitConfig.ProfitType == "Percent")
                                        {
                                            amount = Convert.ToDecimal(orderInfo.actual_amount) * Convert.ToDecimal(singlProfitConfig.Profit) * Convert.ToDecimal(0.01);
                                        }
                                    }
                                }
                                if (amount > 0)
                                {
                                    IDbTransaction tran = new JIT.CPOS.BS.DataAccess.Base.TransactionHelper(loggingSessionInfo).CreateTransaction();
                                    try
                                    {
                                        T_SuperRetailTraderProfitDetailEntity entitySuperRetailTraderProfitDetail = new T_SuperRetailTraderProfitDetailEntity()
                                        {
                                            SuperRetailTraderProfitConfigId = singlProfitConfig.SuperRetailTraderProfitConfigId,
                                            SuperRetailTraderID             = new Guid(dr["SuperRetailTraderID"].ToString()),
                                            Level             = Convert.ToInt16(dr["level"].ToString()),
                                            ProfitType        = "Cash",
                                            Profit            = amount,
                                            OrderType         = "Order",
                                            OrderId           = orderInfo.order_id,
                                            OrderDate         = Convert.ToDateTime(orderInfo.order_date),
                                            VipId             = orderInfo.vip_no,
                                            OrderActualAmount = orderInfo.actual_amount,
                                            SalesId           = new Guid(orderInfo.sales_user),
                                            OrderNo           = orderInfo.order_no,
                                            CustomerId        = loggingSessionInfo.ClientID
                                        };


                                        bllSuperRetailTraderProfitDetail.Create(entitySuperRetailTraderProfitDetail, (SqlTransaction)tran);


                                        VipAmountDetailEntity entityVipAmountDetail = new VipAmountDetailEntity();
                                        VipAmountEntity       entityVipAmount       = new VipAmountEntity();
                                        entityVipAmountDetail = new VipAmountDetailEntity
                                        {
                                            VipAmountDetailId = Guid.NewGuid(),
                                            VipId             = dr["SuperRetailTraderID"].ToString(),
                                            Amount            = amount,
                                            UsedReturnAmount  = 0,
                                            EffectiveDate     = DateTime.Now,
                                            DeadlineDate      = Convert.ToDateTime("9999-12-31 23:59:59"),
                                            AmountSourceId    = strAmountSourceId,
                                            ObjectId          = orderInfo.order_id,
                                            CustomerID        = loggingSessionInfo.ClientID,
                                            Reason            = "超级分销商"
                                        };
                                        bllVipAmountDetail.Create(entityVipAmountDetail, (SqlTransaction)tran);

                                        entityVipAmount = bllVipAmount.QueryByEntity(new VipAmountEntity()
                                        {
                                            VipId = dr["SuperRetailTraderID"].ToString(), IsDelete = 0, CustomerID = loggingSessionInfo.ClientID
                                        }, null).SingleOrDefault();
                                        if (entityVipAmount == null)
                                        {
                                            entityVipAmount = new VipAmountEntity
                                            {
                                                VipId                  = dr["SuperRetailTraderID"].ToString(),
                                                BeginAmount            = 0,
                                                InAmount               = amount,
                                                OutAmount              = 0,
                                                EndAmount              = amount,
                                                TotalAmount            = amount,
                                                BeginReturnAmount      = 0,
                                                InReturnAmount         = 0,
                                                OutReturnAmount        = 0,
                                                ReturnAmount           = 0,
                                                ImminentInvalidRAmount = 0,
                                                InvalidReturnAmount    = 0,
                                                ValidReturnAmount      = 0,
                                                TotalReturnAmount      = 0,
                                                IsLocking              = 0,
                                                CustomerID             = loggingSessionInfo.ClientID,
                                                VipCardCode            = ""
                                            };
                                            bllVipAmount.Create(entityVipAmount, tran);
                                        }
                                        else
                                        {
                                            entityVipAmount.InReturnAmount    = (entityVipAmount.InReturnAmount == null ? 0 : entityVipAmount.InReturnAmount.Value) + amount;
                                            entityVipAmount.TotalReturnAmount = (entityVipAmount.TotalReturnAmount == null ? 0 : entityVipAmount.TotalReturnAmount.Value) + amount;

                                            entityVipAmount.ValidReturnAmount = (entityVipAmount.ValidReturnAmount == null ? 0 : entityVipAmount.ValidReturnAmount.Value) + amount;
                                            entityVipAmount.ReturnAmount      = (entityVipAmount.ReturnAmount == null ? 0 : entityVipAmount.ReturnAmount.Value) + amount;

                                            bllVipAmount.Update(entityVipAmount);
                                        }
                                        tran.Commit();
                                    }
                                    catch (Exception)
                                    {
                                        tran.Rollback();
                                        throw;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 17
0
 public void ExecProcPEventItemQty(SetOrderInfoReqPara para, T_InoutEntity pEntity, SqlTransaction tran)
 {
     this._currentDAO.ExecProcPEventItemQty(para, pEntity, tran);
 }
Exemplo n.º 18
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="pEntity"></param>
 public void Delete(T_InoutEntity pEntity)
 {
     _currentDAO.Delete(pEntity);
 }
Exemplo n.º 19
0
        public void SetVipConsumeForUpgradeList(LoggingSessionInfo loggingSessionInfo, T_InoutEntity orderInfo)
        {
            var response = RedisOpenAPI.Instance.CCAllOrder().SetOrder(new CC_Order
            {
                CustomerID = loggingSessionInfo.ClientID,
                OrderId    = orderInfo.order_id,
                OrderInfo  = orderInfo.JsonSerialize()
            });

            if (response.Code == ResponseCode.Fail)
            {
                //直接计算
                CalculateVipConsumeForUpgrade(loggingSessionInfo, orderInfo);
            }
        }
Exemplo n.º 20
0
 /// <summary>
 /// 根据实体条件查询实体
 /// </summary>
 /// <param name="pQueryEntity">以实体形式传入的参数</param>
 /// <param name="pOrderBys">排序组合</param>
 /// <returns>符合条件的实体集</returns>
 public T_InoutEntity[] QueryByEntity(T_InoutEntity pQueryEntity, OrderBy[] pOrderBys)
 {
     return(_currentDAO.QueryByEntity(pQueryEntity, pOrderBys));
 }
Exemplo n.º 21
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);
        }
Exemplo n.º 22
0
 /// <summary>
 /// 创建一个新实例
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 public void Create(T_InoutEntity pEntity)
 {
     _currentDAO.Create(pEntity);
 }
Exemplo n.º 23
0
 public void Create(T_InoutEntity dbEntity)
 {
     _cmd.Create(dbEntity);
 }
Exemplo n.º 24
0
        /// <summary>
        /// 提交订单
        /// </summary>
        /// <param name="inoutEntity"></param>
        /// <param name="ItemId">物资ID</param>
        /// <param name="VipId">用户ID</param>
        /// <returns></returns>
        public int SubmitVipPayMent(T_InoutEntity inoutEntity, string ItemId, string VipId)
        {
            int i = itemService.SubmitVipPayMent(inoutEntity, ItemId, VipId);

            return(i);
        }
        /// <summary>
        /// 入 订单支付完成 队列
        /// </summary>
        public void SentPaymentMessage(T_InoutEntity Inout, string OpenID, string VipID, LoggingSessionInfo loggingSessionInfo)
        {
            //
            var commonBLL = new CommonBLL();

            //
            var wxTMConfigData = new WXTMConfigBLL(loggingSessionInfo).QueryByEntity(new WXTMConfigEntity
            {
                TemplateIdShort = "TM00398",
                CustomerId      = loggingSessionInfo.ClientID,
                IsDelete        = 0
            }, null).FirstOrDefault();

            if (wxTMConfigData == null)
            {
                return;
            }

            //
            string     ItemName       = commonBLL.GetItemName(Inout.order_no, loggingSessionInfo);
            PaySuccess PaySuccessData = new PaySuccess();

            PaySuccessData.first = new DataInfo()
            {
                value = wxTMConfigData.FirstText, color = wxTMConfigData.FirstColour
            };
            PaySuccessData.orderProductPrice = new DataInfo()
            {
                value = Math.Round(Inout.actual_amount ?? 0, 2).ToString(), color = wxTMConfigData.Colour1
            };
            PaySuccessData.orderProductName = new DataInfo()
            {
                value = ItemName, color = wxTMConfigData.Colour2
            };
            PaySuccessData.orderAddress = new DataInfo()
            {
                value = Inout.Field4, color = wxTMConfigData.Colour3
            };
            PaySuccessData.orderName = new DataInfo()
            {
                value = Inout.order_no, color = wxTMConfigData.Colour3
            };
            PaySuccessData.remark = new DataInfo()
            {
                value = wxTMConfigData.RemarkText, color = wxTMConfigData.RemarkColour
            };

            //
            var response = RedisOpenAPI.Instance.CCOrderPaySuccess().SetPaySuccess(new CC_PaySuccess
            {
                CustomerID = loggingSessionInfo.ClientID,
                ConfigData = new CC_ConfigData
                {
                    LogSession = loggingSessionInfo.JsonSerialize(),
                    OpenID     = OpenID,
                    TemplateID = wxTMConfigData.TemplateID,
                    VipID      = VipID
                },
                PaySuccessData = new CC_PaySuccessData
                {
                    first = new CC_DataInfo {
                        value = PaySuccessData.first.value, color = PaySuccessData.first.color
                    },
                    orderAddress = new CC_DataInfo {
                        value = PaySuccessData.orderAddress.value, color = PaySuccessData.orderAddress.color
                    },
                    orderName = new CC_DataInfo {
                        value = PaySuccessData.orderName.value, color = PaySuccessData.orderName.color
                    },
                    orderProductName = new CC_DataInfo {
                        value = PaySuccessData.orderProductName.value, color = PaySuccessData.orderProductName.color
                    },
                    orderProductPrice = new CC_DataInfo {
                        value = PaySuccessData.orderProductPrice.value, color = PaySuccessData.orderProductPrice.color
                    },
                    remark = new CC_DataInfo {
                        value = PaySuccessData.remark.value, color = PaySuccessData.remark.color
                    }
                }
            });

            if (response.Code != ResponseCode.Success)
            {
                commonBLL.SendMatchWXTemplateMessage(wxTMConfigData.TemplateID, null, null, null, PaySuccessData, null, null, null, null, "15", OpenID, VipID, loggingSessionInfo);
                new RedisXML().RedisReadDBCount("OrderPaySuccess", "微信端支付成功通知", 2);
            }
            else
            {
                new RedisXML().RedisReadDBCount("OrderPaySuccess", "微信端支付成功通知", 1);
            }
            //return commonBLL.SendMatchWXTemplateMessage(wxTMConfigData.TemplateID, null, null, null, PaySuccessData, null, "15", OpenID, VipID, loggingSessionInfo);
        }