public ActionResult UpsertBeautyServicePackageDetail(BeautyServicePackageDetail packageDetail)
        {
            var isSuccess  = false;
            var msg        = string.Empty;
            var rawPackage = BeautyServicePackageManager.GetBeautyServicePackage(packageDetail.PackageId);

            if (rawPackage != null && rawPackage.IsPackageCodeGenerated)
            {
                if (packageDetail.PKID <= 0)
                {
                    msg = "已生成兑换码不允许添加产品!";
                    return(Json(new { IsSuccess = false, Msg = msg }, JsonRequestBehavior.AllowGet));
                }
                var rawPackageDetail = BeautyServicePackageManager.GetBeautyServicePackageDetails(packageDetail.PackageId).FirstOrDefault();
                if (rawPackageDetail != null &&
                    (rawPackageDetail.ShopCommission != packageDetail.ShopCommission ||
                     rawPackageDetail.VipSettlementPrice != packageDetail.VipSettlementPrice ||
                     rawPackageDetail.ServiceCodeNum != packageDetail.ServiceCodeNum ||
                     rawPackageDetail.ServiceCodeStartTime != packageDetail.ServiceCodeStartTime ||
                     rawPackageDetail.ServiceCodeEndTime != packageDetail.ServiceCodeEndTime ||
                     rawPackageDetail.EffectiveDayAfterExchange != packageDetail.EffectiveDayAfterExchange ||
                     rawPackageDetail.Num != packageDetail.Num))
                {
                    msg = "已生成兑换码只允许修改名称!";
                    return(Json(new { IsSuccess = false, Msg = msg }, JsonRequestBehavior.AllowGet));
                }
            }

            var user = HttpContext.User.Identity.Name;

            if (packageDetail != null && !string.IsNullOrEmpty(packageDetail.Name) && !string.IsNullOrEmpty(packageDetail.PID))
            {
                if (packageDetail.Num > 20 || packageDetail.Num < 0)
                {
                    msg = "兑换码包含的服务数量介于0~20之间";
                    return(Json(new { IsSuccess = false, Msg = msg }, JsonRequestBehavior.AllowGet));
                }
                if (packageDetail.CooperateId <= 0)//兑换码的合作用户配置在外层
                {
                    var package = BeautyServicePackageManager.GetBeautyServicePackage(packageDetail.PackageId);
                    packageDetail.CooperateId = package?.CooperateId ?? 0;
                }
                if (packageDetail.PKID > 0)
                {
                    packageDetail.UpdateUser = user;
                    var updateResult = BeautyServicePackageManager.UpdateBeautyServicePackageDetail(packageDetail);
                    isSuccess = updateResult.Item1;
                    msg       = updateResult.Item2;
                }
                else
                {
                    packageDetail.CreateUser = user;
                    isSuccess = BeautyServicePackageManager.InsertBeautyServicePackageDetail(packageDetail);
                    if (!isSuccess)
                    {
                        msg = "更新失败";
                    }
                }
            }
            else
            {
                msg = "信息不完善";
            }

            return(Json(new { IsSuccess = isSuccess, Msg = msg }, JsonRequestBehavior.AllowGet));
        }