コード例 #1
0
        public override async Task HandleRevert(FlowSheet flowSheet)
        {
            var accountId  = flowSheet.GetPropertyValue <int>("AccountId");
            var feeAccount = await FeeAccountManager.GetByIdAsync(accountId);

            var totalFee       = flowSheet.GetPropertyValue <decimal>("Fee");
            var affectRemain   = flowSheet.GetPropertyValue <bool>("AffectRemain");
            var relCompanyName = flowSheet.GetPropertyValue <string>("RelCompanyName");

            if (affectRemain)
            {
                //往来单位金额变动
                await UnitManager.ChangeFee(flowSheet.UnitId.Value, accountId, totalFee, flowSheet, relCompanyName);
            }
            else
            {
                //账号金额变动
                await FeeAccountManager.BuildFeeHistory(feeAccount, flowSheet.UnitId, totalFee, flowSheet, relCompanyName);
            }
            //将对应的支票设置为收入退回
            if (flowSheet.GetPropertyValue <string>("PayType") == GetPayTypeName(2))
            {
                var feeCheckId = flowSheet.GetPropertyValue <int>("FeeCheckId");
                var feeCheck   = await FeeCheckManager.GetByIdAsync(feeCheckId);

                feeCheck.CheckStatus = CheckStatus.支出退票;
            }
        }
コード例 #2
0
        public override async Task Handle(FlowSheet flowSheet)
        {
            await base.Handle(flowSheet);

            await base.Handle(flowSheet);

            //数据处理
            var formObj     = Newtonsoft.Json.JsonConvert.DeserializeObject <JObject>(flowSheet.FlowInstance.FormData);
            var sheetData   = formObj["sheetData"];
            var sheetHeader = sheetData["header"];

            flowSheet.SheetDate = sheetHeader["sheetDate"].ToObjectWithDefault <DateTime>();
            flowSheet.Remarks   = sheetHeader["remarks"].ToObjectWithDefault <string>();
            var payUnitId = sheetHeader["payUnit"]["id"].ToObject <int>();//付款代理id
            var payUnit   = await UnitManager.GetByIdAsync(payUnitId);

            var receiveUnitId = sheetHeader["receiveUnit"]["id"].ToObject <int>();//收款供应商id
            var receiveUnit   = await UnitManager.GetByIdAsync(receiveUnitId);

            var fee = sheetHeader["fee"].ToObject <decimal>();//

            flowSheet.SetPropertyValue("Fee", fee);
            flowSheet.SetPropertyValue("OutUnitName", payUnit.UnitName);
            flowSheet.SetPropertyValue("OutCompanyName", sheetHeader["payUnit"]["companyName"].ToObjectWithDefault <string>());
            flowSheet.SetPropertyValue("InUnitName", receiveUnit.UnitName);
            flowSheet.SetPropertyValue("InCompanyName", sheetHeader["receiveUnit"]["companyName"].ToObjectWithDefault <string>());
            //读取对应的账号id
            var accountId = (await FeeAccountManager.GetByName(FeeAccount.StaticAccountName3)).Id;

            flowSheet.SetPropertyValue("AccountId", accountId);
            //往来单位金额变动
            await UnitManager.ChangeFee(payUnitId, accountId, fee, flowSheet);

            await UnitManager.ChangeFee(receiveUnitId, accountId, -fee, flowSheet);
        }
コード例 #3
0
        public override async Task Handle(FlowSheet flowSheet)
        {
            await base.Handle(flowSheet);

            //数据处理
            var formObj     = Newtonsoft.Json.JsonConvert.DeserializeObject <JObject>(flowSheet.FlowInstance.FormData);
            var sheetData   = formObj["sheetData"];
            var sheetHeader = sheetData["header"];

            flowSheet.Remarks = sheetHeader["remarks"].ToObjectWithDefault <string>();
            var unitId         = sheetHeader["unitId"].ToObject <int>();                //代理id;
            var accountId      = sheetHeader["accountId"].ToObjectWithDefault <int?>(); //账号id;
            var payType        = sheetHeader["payType"].ToObject <int>();
            var totalFee       = sheetHeader["totalFee"].ToObject <decimal>();          //
            var affectRemain   = sheetHeader["affectRemain"].ToObject <bool>();
            var relCompanyName = sheetHeader["relCompanyName"]?.ToObject <string>();

            flowSheet.UnitId = unitId;
            flowSheet.SetPropertyValue("Fee", totalFee);
            flowSheet.SetPropertyValue("PayType", GetPayTypeName(payType));
            flowSheet.SetPropertyValue("AffectRemain", affectRemain);
            flowSheet.SetPropertyValue("RelCompanyName", relCompanyName);
            //读取对应的账号id
            if (payType == 0)
            {
                accountId = (await FeeAccountManager.GetByName(FeeAccount.StaticAccountName1)).Id;
            }
            else if (payType == 2)
            {
                accountId = (await FeeAccountManager.GetByName(FeeAccount.StaticAccountName2)).Id;
                //建立支票信息
                var feeCheckId = sheetHeader["feeCheck"]["id"].ToObject <int>();
                //设置对应支票信息为已支出
                var feeCheck = await FeeCheckManager.GetByIdAsync(feeCheckId);

                if (feeCheck.CheckStatus != CheckStatus.收入)
                {
                    throw new UserFriendlyException("支票状态不是收入,无法进行使用");
                }
                feeCheck.CheckStatus    = CheckStatus.支出;
                feeCheck.OutFlowSheetId = flowSheet.Id;//设置支票的支出单据
                flowSheet.SetPropertyValue("FeeCheckId", feeCheckId);
            }
            var feeAccount = await FeeAccountManager.GetByIdAsync(accountId.Value);

            flowSheet.SetPropertyValue("AccountId", accountId);
            if (affectRemain)
            {
                //往来单位金额变动
                await UnitManager.ChangeFee(unitId, accountId.Value, -totalFee, flowSheet, relCompanyName);
            }
            else
            {
                //账户金额变动
                await FeeAccountManager.BuildFeeHistory(feeAccount, unitId, -totalFee, flowSheet, relCompanyName);
            }
        }
コード例 #4
0
        public override async Task HandleRevert(FlowSheet flowSheet)
        {
            var accountId      = flowSheet.GetPropertyValue <int>("AccountId");
            var totalFee       = flowSheet.GetPropertyValue <decimal>("Fee");
            var relCompanyName = flowSheet.GetPropertyValue <string>("RelCompanyName");
            //往来单位金额变动
            await UnitManager.ChangeFee(flowSheet.UnitId.Value, accountId, -totalFee, flowSheet, relCompanyName);

            //将对应的支票设置为收入退回
            if (flowSheet.GetPropertyValue <string>("PayType") == GetPayTypeName(2))
            {
                var feeCheckId = flowSheet.GetPropertyValue <int>("FeeCheckId");
                var feeCheck   = await FeeCheckManager.GetByIdAsync(feeCheckId);

                feeCheck.CheckStatus = CheckStatus.收入退票;
            }
        }
コード例 #5
0
        public override async Task Handle(FlowSheet flowSheet)
        {
            await base.Handle(flowSheet);

            //数据处理
            var formObj     = Newtonsoft.Json.JsonConvert.DeserializeObject <JObject>(flowSheet.FlowInstance.FormData);
            var sheetData   = formObj["sheetData"];
            var sheetHeader = sheetData["header"];

            flowSheet.Remarks = sheetHeader["remarks"].ToObjectWithDefault <string>();
            var unitId         = sheetHeader["unitId"].ToObject <int>();                //代理id;
            var accountId      = sheetHeader["accountId"].ToObjectWithDefault <int?>(); //账号id;
            var payType        = sheetHeader["payType"].ToObject <int>();
            var totalFee       = sheetHeader["totalFee"].ToObject <decimal>();          //
            var relCompanyName = sheetHeader["relCompanyName"]?.ToObject <string>();

            flowSheet.UnitId = unitId;
            flowSheet.SetPropertyValue("Fee", totalFee);
            flowSheet.SetPropertyValue("PayType", GetPayTypeName(payType));
            flowSheet.SetPropertyValue("RelCompanyName", relCompanyName);
            //读取对应的账号id
            if (payType == 0)
            {
                accountId = (await FeeAccountManager.GetByName(FeeAccount.StaticAccountName1)).Id;
            }
            else if (payType == 2)
            {
                accountId = (await FeeAccountManager.GetByName(FeeAccount.StaticAccountName2)).Id;
                //建立支票信息
                var feeCheck = sheetHeader["feeCheck"].ToObject <FeeCheck>();
                feeCheck.CheckStatus   = CheckStatus.收入;
                feeCheck.InFlowSheetId = flowSheet.Id;
                feeCheck.Remarks       = flowSheet.Remarks;
                var feeCheckId = await FeeCheckManager.InsertAndGetIdAsync(feeCheck);

                flowSheet.SetPropertyValue("FeeCheckId", feeCheckId);
            }
            flowSheet.SetPropertyValue("AccountId", accountId);
            //往来单位金额变动
            await UnitManager.ChangeFee(unitId, accountId.Value, totalFee, flowSheet, relCompanyName);
        }
コード例 #6
0
        public override async Task Action(FlowSheet flowSheet, string action, DateTime?lastModifyTime)
        {
            //数据处理
            var formObj     = Newtonsoft.Json.JsonConvert.DeserializeObject <JObject>(flowSheet.FlowInstance.FormData);
            var sheetData   = formObj["sheetData"];
            var sheetHeader = sheetData["header"];

            flowSheet.Fee = sheetHeader["totalFee"].ToObjectWithDefault <decimal>();
            var unitId = sheetHeader["unitId"].ToObject <int>();//代理商id

            if (action == "backToCart")
            {
                foreach (var sheetItem in sheetData["body"])
                {
                    var materialId = Convert.ToInt32(sheetItem["id"]);                //对应的物料Id
                    var number     = sheetItem["number"].ToObjectWithDefault <int>(); //订购数量

                    var materialCart = await CartRepository.GetAll().Where(o => o.UnitId == unitId && o.CreatorUserId == AbpSession.UserId && o.MaterialId == materialId).FirstOrDefaultAsync();

                    if (materialCart != null)
                    {
                        materialCart.Number += number;
                        await CartRepository.UpdateAsync(materialCart);
                    }
                    else
                    {
                        materialCart = new MaterialSellCart()
                        {
                            MaterialId = materialId,
                            Number     = number,
                            UnitId     = unitId
                        };
                        await CartRepository.InsertAsync(materialCart);
                    }
                }
                //删除订单
                await FlowSheetManager.DeleteAsync(flowSheet);
            }
            else if (action == "modify")
            {
                if (flowSheet.OrderStatus != "待审核")
                {
                    throw new UserFriendlyException("本单据已被审核,当前操作无效,请重新查看");
                }
            }
            else if (action == "verify")
            {
                if (flowSheet.FlowInstance.LastModificationTime != null && (!lastModifyTime.HasValue || (flowSheet.FlowInstance.LastModificationTime.Value - lastModifyTime.Value).TotalSeconds > 1))
                {
                    throw new UserFriendlyException($"本单据已在{flowSheet.FlowInstance.LastModificationTime?.ToString("yyyy-MM-dd HH:mm:ss")}被{flowSheet.FlowInstance.LastModifierUser?.Name}修改,当前操作无效,请重新查看后再提交");
                }
                flowSheet.OrderStatus = "待发货";
            }
            else if (action == "cancel")
            {
                flowSheet.OrderStatus = "已取消";
            }
            else if (action == "send")
            {
                flowSheet.OrderStatus = "已发货";
                //‘收货时间’‘收货人姓名’‘联系方式’‘收货地址’
                flowSheet.SetPropertyValue("Receiver", sheetHeader["receiver"].ToObjectWithDefault <string>());
                flowSheet.SetPropertyValue("DeliverDate", sheetHeader["deliverDate"].ToObjectWithDefault <DateTime>());
                flowSheet.SetPropertyValue("ReceiverMobile", sheetHeader["receiverMobile"].ToObjectWithDefault <string>());
                flowSheet.SetPropertyValue("ReceiverAddress", sheetHeader["receiverAddress"].ToObjectWithDefault <string>());
                var totalFee = sheetHeader["totalFee"].ToObjectWithDefault <decimal>();
                //更改往来单位金额
                await UnitManager.ChangeFee(unitId, null, -totalFee, flowSheet);

                var materialSellIds = new List <int>();
                var toOutMaterials  = new Dictionary <int, int>();
                var outStoreId      = sheetHeader["storeId"].ToObjectWithDefault <int?>();
                if (outStoreId == null)
                {
                    throw new UserFriendlyException("请选择发货仓库");
                }

                var logs = new List <string>();

                foreach (var sheetItem in sheetData["body"])
                {
                    var materialId   = sheetItem["materialId"].ToObjectWithDefault <int>(); //商品Id
                    var number       = sheetItem["number"].ToObjectWithDefault <int>();     //出货数量
                    var materialSell = await MaterialSellManager.GetAll().Include(o => o.Material)
                                       .Where(o => o.FlowSheetId == flowSheet.Id && o.MaterialId == materialId).FirstOrDefaultAsync();

                    if (materialSell != null)
                    {
                        if (materialSell.SellNumber != number)
                        {
                            //发生订购数量更改需要进行记录
                            logs.Add($"商品\"{materialSell.Material.Name}\"订购数量从{materialSell.SellNumber}调整为{number}");
                        }
                        materialSell.SellNumber = number;
                        materialSell.OutNumber  = materialSell.SellNumber;//设置销售记录的出货数量等于订货数量
                    }
                    //建立销售出库记录
                    var materialSellOut = new MaterialSellOut()
                    {
                        UnitId      = unitId,
                        FlowSheetId = flowSheet.Id,
                        MaterialId  = materialId,
                        OutNumber   = number,
                        Price       = sheetItem["price"].ToObjectWithDefault <decimal>(),
                        Discount    = sheetItem["discount"].ToObjectWithDefault <decimal>()
                    };
                    await MaterialSellOutManager.InsertAsync(materialSellOut);

                    //检测库存是否足够
                    if (!StoreMaterialManager.IsSatisfied(materialId, outStoreId.Value, unitId, number, out var message))
                    {
                        throw new UserFriendlyException(message);
                    }
                    //库存变化
                    await StoreMaterialManager.CountMaterial(outStoreId.Value, materialId, -number, flowSheet);
                }
                if (logs.Count > 0)
                {
                    flowSheet.SetPropertyValue("Log", $"{AbpSession.Name()}于{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}将{string.Join(';', logs)}");
                }
            }
            else if (action == "back")
            {
                var totalFee = sheetHeader["totalFee"].ToObjectWithDefault <decimal>();
                flowSheet.OrderStatus = "已退货";
                //更改往来单位金额
                await UnitManager.ChangeFee(unitId, null, totalFee, flowSheet);

                var materialSellIds = new List <int>();
                var toOutMaterials  = new Dictionary <int, int>();
                var backStoreId     = sheetHeader["backStoreId"].ToObjectWithDefault <int?>();
                if (backStoreId == null)
                {
                    throw new UserFriendlyException("请选择退入仓库");
                }

                foreach (var sheetItem in sheetData["body"])
                {
                    var materialId = sheetItem["materialId"].ToObjectWithDefault <int>(); //商品Id
                    var number     = sheetItem["number"].ToObjectWithDefault <int>();     //出货数量
                    //库存变化
                    await StoreMaterialManager.CountMaterial(backStoreId.Value, materialId, number, flowSheet);

                    //产生退货数据
                    var materialSellBack = new MaterialSellBack()
                    {
                        UnitId      = unitId,
                        MaterialId  = materialId,
                        BackNumber  = number,
                        FlowSheetId = flowSheet.Id,
                        Discount    = sheetItem["discount"].ToObjectWithDefault <decimal>(),
                        Price       = sheetItem["price"].ToObjectWithDefault <decimal>(),
                    };
                    await MaterialSellBackManager.InsertAsync(materialSellBack);
                }
            }
        }