Пример #1
0
        /// <summary>
        /// 核销拼团提货码
        /// </summary>
        /// <param name="db"></param>
        /// <param name="orderId"></param>
        /// <param name="pickupCode"></param>
        /// <param name="_logger"></param>
        /// <returns></returns>
        public static async Task <bool> TakeTheirFinishOrderAsync(ShopDbContext db, int orderId, string pickupCode, ILogger _logger)
        {
            var order = db.ConglomerationOrder.Find(orderId);

            if (!order.Type.Equals(ConsignmentType.自提))
            {
                throw new Exception("订单类型为快递类型");
            }
            if (!order.Status.Equals(ShopOrderStatus.待自提))
            {
                throw new Exception("订单不是待自提状态");
            }
            if (!order.PickupCode.Equals(pickupCode))
            {
                throw new Exception("提货码错误");
            }
            order.Status = ShopOrderStatus.已完成;
            db.SaveChanges();

            #region 积分获取
            var sourceType = await ShopIntegralRechargeServer.GetOrderSourceType(db, orderId, true, _logger);

            await ShopIntegralRechargeServer.GetOrderIntegral(db, orderId, sourceType, _logger);

            #endregion
            return(true);
        }
Пример #2
0
        /// <summary>
        /// 更新腻会员等级
        /// </summary>
        /// <param name="db"></param>
        /// <param name="memberId"></param>
        /// <param name="shopId"></param>
        /// <returns></returns>
        public static async Task UpdateMemberLevel(ShopDbContext db, ShopMemberSet shopMemberSet, int memberId, int shopId, ILogger _logger)
        {
            int count = await ShopIntegralRechargeServer.GetMemberIntegral(db, memberId, shopId, _logger);

            var shopmember = await db.ShopMembers.FirstOrDefaultAsync(m => m.MemberId.Equals(memberId) && m.ShopId.Equals(shopId) && !m.IsDel);

            ShopMemberLevel shopMemberLevels = null;

            if (shopMemberSet.IsSavaLevel)
            {
                shopMemberLevels = await GetLevelByIntegral(db, count, shopId, _logger);
            }
            else
            {
                shopMemberLevels = await GetLevelUp(db, count, shopId, shopmember, _logger);
            }
            if (shopMemberLevels == null)
            {
                return;
            }
            shopmember.ShopMemberLevelId = shopMemberLevels.Id;
            await db.SaveChangesAsync();
        }