コード例 #1
0
ファイル: CommissionManager.cs プロジェクト: 453495181/Agents
        /// <summary>
        /// 添加佣金
        /// </summary>
        private async Task AddCommissionAsync(Order order, CommissionType type, Agent agent)
        {
            if (agent == null)
            {
                return;
            }
            decimal commission = 0;

            switch (type)
            {
            case CommissionType.Level1:
                //commission = ConfigHelper.GetConfigString("CommissionLevel1").ToDecimal();
                commission = 15;
                break;

            case CommissionType.Level2:
                //commission = ConfigHelper.GetConfigString("CommissionLevel2").ToDecimal();
                commission = 10;
                break;

            case CommissionType.Level3:
                //commission = ConfigHelper.GetConfigString("CommissionLevel3").ToDecimal();
                commission = 5;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(type), type, null);
            }

            var model = new Commission();

            model.Init();
            model.Money   = order.Money * commission / 100;
            model.Type    = type;
            model.State   = CommissionState.UnPayed;
            model.AgentId = agent.Id;
            model.OrderId = order.Id;
            await CommissionRepository.AddAsync(model);
        }