コード例 #1
0
        public virtual async Task GenerateLicenses(SoftLicenseGenerateItemInput input)
        {
            if (input.Count < 1)
            {
                throw new UserFriendlyException("生成卡密数量不能小于1!");
            }

            var licenseOption = await _softLicenseOptionRepository.FirstOrDefaultAsync(t => t.Id == input.SoftLicenseOptionId && t.SoftId == input.SoftId);

            if (licenseOption == null)
            {
                throw new UserFriendlyException("价格类型不存在!");
            }

            for (int i = 0; i < input.Count; i++)
            {
                SoftLicense license = new SoftLicense();
                license.SoftId      = licenseOption.SoftId;
                license.LicenseType = licenseOption.LicenseType;
                license.LicenseNo   = MD5Helper.EnCode16Bit(Guid.NewGuid().ToString());
                license.ApplyTime   = DateTime.Now;
                license.Status      = SoftLicenseStatus.Normal;
                license.SellType    = SoftLicenseSellType.None;
                license.Price       = licenseOption.Price;

                await _softLicenseRepository.InsertAsync(license);
            }
        }
コード例 #2
0
        public virtual async Task Create(SoftCreateInput input)
        {
            var item = input.MapTo <Soft>();

            //自动生成appid,appsecret
            item.AppId     = "ns" + MD5Helper.EnCode16Bit(DateTime.Now.ToString()).ToLower();
            item.AppSecret = MD5Helper.EnCode(RandExtension.GetRandomNum()).ToLower();
            item.IsActive  = true;//默认启用
            var entity = await _softRepository.InsertAsync(item);
        }