예제 #1
0
        /// <summary>
        /// 添加礼包优惠券配置
        /// </summary>
        /// <param name="packId"></param>
        /// <param name="getRuleId"></param>
        /// <param name="quantity"></param>
        /// <returns></returns>
        public bool AddGiftPackCouponConfig(long packId, Guid getRuleGUID, int quantity, string user)
        {
            bool succes = false;

            try
            {
                var pkid = dbScopeManager.Execute(conn => DALVipBaoYangPackage.AddGiftPackCouponConfig(conn, packId, getRuleGUID, quantity));
                succes = pkid > 0;
                if (succes)
                {
                    VipBaoYangPackageService.InsertBaoYangOprLog(new
                    {
                        LogType     = "VipBaoYangPackageRedemptionCodeCoupon",
                        IdentityID  = pkid.ToString(),
                        OldValue    = string.Empty,
                        NewValue    = JsonConvert.SerializeObject(new { PKID = pkid, PackId = packId, GetRuleGUID = getRuleGUID, Quantity = quantity }),
                        Remarks     = $"Add",
                        OperateUser = user,
                    });
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message, ex);
            }
            return(succes);
        }
예제 #2
0
        /// <summary>
        /// 新增礼包配置
        /// </summary>
        /// <param name="config"></param>
        /// <returns></returns>
        public bool AddVipBaoYangGiftPackConfig(VipBaoYangGiftPackConfig config, string user)
        {
            bool success = false;

            try
            {
                var pkid = dbScopeManager.Execute(conn => DALVipBaoYangPackage.AddVipBaoYangGiftPackConfig(conn, config));
                success     = pkid > 0;
                config.PKID = pkid;
                if (success)
                {
                    VipBaoYangPackageService.InsertBaoYangOprLog(new
                    {
                        LogType     = "VipBaoYangPackageRedemptionCodeGiftPack",
                        IdentityID  = pkid.ToString(),
                        OldValue    = string.Empty,
                        NewValue    = JsonConvert.SerializeObject(new { config.PackId, config.PackageId, config.IsValid, config.PackName }),
                        Remarks     = $"Add",
                        OperateUser = user,
                    });
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message, ex);
            }
            return(success);
        }
예제 #3
0
        private bool Create2BOrder(decimal price, string pid, string name, Guid vipUserId,
                                   int count, string batchCode)
        {
            var success = false;

            try
            {
                var result = VipBaoYangPackageService.CreateOrder(price, pid, name, vipUserId, count, batchCode);
                if (result != null && result.OrderId > 0)
                {
                    VipBaoYangPackageService.ExecuteOrderProcess(new ExecuteOrderProcessRequest()
                    {
                        OrderId          = result.OrderId,
                        OrderProcessEnum = OrderProcessEnum.GeneralCompleteToHome,
                        CreateBy         = vipUserId.ToString()
                    });
                    logger.Info($"创建买断制2B订单{result.OrderId}成功, 一共{count}个产品数量, 关联批次号:{batchCode}");
                    success = dbScopeManager.Execute(conn => DALVipBaoYangPackage.UpdateRedemptionCode(conn, batchCode, result.OrderId));
                }
                else
                {
                    logger.Error($"创建买断制2B订单失败, 一共{count}个产品数量, 批次号:{batchCode}");
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message, ex);
            }
            return(success);
        }
예제 #4
0
        /// <summary>
        /// 添加保养套餐
        /// </summary>
        /// <param name="package"></param>
        /// <returns></returns>
        public bool InsertVipBaoYangPackage(VipBaoYangPackageViewModel package)
        {
            var result    = false;
            var productId = string.Empty;

            try
            {
                dbScopeManager.CreateTransaction(conn =>
                {
                    var pkid = DALVipBaoYangPackage.InsertVipBaoYangPackage(conn, new VipBaoYangPackageDbModel(package));
                    if (pkid > 0)
                    {
                        productId = $"BY-TUHU-BXGSDCBY|{pkid.ToString()}";
                        result    = DALVipBaoYangPackage.UpdateVipBaoYangPackagePID(conn, pkid, productId) > 0;
                    }
                    if (result)
                    {
                        package.PKID = pkid;
                        package.PID  = productId;
                        VipBaoYangPackageService.CreateProduct(pkid.ToString(), package.PackageName, package.CreateUser);
                    }
                });

                if (result)
                {
                    InsertLog(productId, null, JsonConvert.SerializeObject(package), "Insert", package.CreateUser);
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }

            return(result);
        }
예제 #5
0
 /// <summary>
 /// 记录导出的日志
 /// </summary>
 /// <param name="batchCode"></param>
 /// <param name="user"></param>
 public static void InsertDownloadRedemptionCodeRecord(string batchCode, string user)
 {
     try
     {
         VipBaoYangPackageService.InsertBaoYangOprLog(new
         {
             LogType     = "VipBaoYangPackageExportRedemptionCode",
             IdentityID  = batchCode,
             OldValue    = string.Empty,
             NewValue    = string.Empty,
             Remarks     = $"{user}下载了批次{batchCode}的兑换码",
             OperateUser = user,
             CreateTime  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),
         });
     }
     catch (Exception ex)
     {
         logger.Error(ex);
     }
 }
예제 #6
0
        /// <summary>
        /// 生成兑换码
        /// </summary>
        /// <param name="packId"></param>
        /// <param name="quantity"></param>
        /// <param name="startTime"></param>
        /// <param name="endTime"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public bool GenerateRedemptionCode(long packId, int quantity, DateTime startTime, DateTime endTime, string user)
        {
            bool success = false;

            try
            {
                var result = VipBaoYangPackageService.GenerateRedemptionCode(quantity, startTime, endTime, user);
                if (result.Success && result.Codes != null && result.Codes.Any())
                {
                    var codes = result.Codes.Select(x => new VipBaoYangRedemptionCode
                    {
                        BatchCode      = result.BatchCode,
                        CreateUser     = user,
                        EndTime        = endTime,
                        StartTime      = startTime,
                        PackId         = packId,
                        RedemptionCode = x,
                        Status         = "0New",
                    }).ToList();
                    success = dbScopeManager.Execute(conn => DALVipBaoYangPackage.InsertBaoYangRedemptionCode(conn, codes));
                    if (success)
                    {
                        var packageConfig = GetVipBaoYangPackageByPackId(packId);
                        var package       = packageConfig.Item2;
                        var totalCount    = packageConfig.Item1 * codes.Count;
                        if (package.SettlementMethod == SettlementMethod.PreSettled.ToString())
                        {
                            Create2BOrder(package.Price, package.PID, package.PackageName, package.VipUserId, totalCount, result.BatchCode);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message, ex);
            }
            return(success);
        }