Esempio n. 1
0
        public void Execute(User currentUser)
        {
            using (var tran = TransactionHelper.BeginTransaction())
            {
                var liquidate = this.LiquidateService.GetById(LiquidateId);
                if (liquidate == null || liquidate.State != LiquidateStates.Processing)
                {
                    throw new Exception("没有找到相关的清算记录");
                }

                this.LiquidateService.Delete(liquidate);
                var ids = liquidate.DealIds.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(x => Convert.ToInt32(x)).ToList();
                if (liquidate.Count != ShopDealLogService.UpdateLiquidateId(ids, 0, liquidate.LiquidateId, ShopId))
                {
                    throw new Exception("清算数据冲突");
                }
                var dealLogIds = ShopDealLogService.GetAddins(ids.ToArray());
                if (liquidate.Count != dealLogIds.Count)
                {
                    throw new Exception("清算数据冲突");
                }
                if (liquidate.Count != DealLogService.UpdateLiquidateId(dealLogIds, 0, liquidate.LiquidateId, ShopId))
                {
                    throw new Exception("清算数据冲突");
                }
                tran.Commit();
            }
        }
Esempio n. 2
0
        public void DoLiquidate(int shopid, List <int> ids)
        {
            var liquidate = this.LiquidateService.ReadyLiquidate(shopid, ids.ToArray());

            if (liquidate.Count == 0)
            {
                throw new Exception("没有可以清算的交易");
            }
            liquidate.DealIds = string.Join(",", ids.ToArray());
            liquidate.ShopId  = shopid;
            liquidate.State   = LiquidateStates.Processing;

            this.LiquidateService.Insert(liquidate);
            if (liquidate.Count != ShopDealLogService.UpdateLiquidateId(ids, liquidate.LiquidateId, 0, shopid))
            {
                throw new Exception("清算数据冲突");
            }
            var dealLogIds = ShopDealLogService.GetAddins(ids.ToArray());

            if (liquidate.Count != dealLogIds.Count)
            {
                throw new Exception("清算数据冲突");
            }
            if (liquidate.Count != DealLogService.UpdateLiquidateId(dealLogIds, liquidate.LiquidateId, 0, shopid))
            {
                throw new Exception("清算数据冲突");
            }
        }