/// <summary> /// 批量设置打折详情页牛皮癣 /// </summary> /// <param name="request"></param> /// <returns></returns> public static async Task <OperationResult <SetDiscountProductDetailImgResponse> > SetDiscountProductDetailImgAsync(SetDiscountProductDetailImgRequest request) { var response = new SetDiscountProductDetailImgResponse() { ResponseCode = "00001", ResponseMessage = "操作失败" }; int result = 0; int newAuditStatus = 0;//审核状态 bool isAllPids = false; try { //获取活动原先审核状态: 初始状态的改为初始状态,其他状态则改为已提交状态 int oldAuditStatus = await DalSalePromotionActivity.GetActivityAuditStatus(request.ActivityId); if (oldAuditStatus > 0) { newAuditStatus = 1; } //没有指定pid就更新活动下所有商品的图片 if (!(request.Pid?.Count > 0)) { isAllPids = true; } using (var dbHelper = DbHelper.CreateDbHelper()) { bool transResult = false; try { dbHelper.BeginTransaction(); //1.设置图片 var updateImgResult = await DalSalePromotionActivity.BatchUpdateProductDetailImageAsync(dbHelper, request, isAllPids); if (updateImgResult > 0) { result = updateImgResult; //2.修改活动审核状态、下架状态字段 var updateStatusResult = await DalSalePromotionActivity.UpdateActivityAuditAndUnShelveStatusAsync(dbHelper, request.ActivityId, newAuditStatus, request.Operator); if (updateStatusResult > 0) { transResult = true; } } if (transResult) { dbHelper.Commit(); response.ResponseCode = "0000"; response.ResponseMessage = "操作成功"; //设置读写库标识 await DalSalePromotionActivity.SetDBFlagCache(request.ActivityId); } else { dbHelper.Rollback(); Logger.Warn($"SetDiscountProductDetailImgAsync=>Rollback,{JsonConvert.SerializeObject(request)}"); } } catch (Exception ex) { dbHelper.Rollback(); Logger.Error($"SetDiscountProductDetailImgAsync=>Rollback 异常,{JsonConvert.SerializeObject(request)},ex:{ex.InnerException}"); throw; } } } catch (Exception ex) { Logger.Error($"SetDiscountProductDetailImgAsync,{JsonConvert.SerializeObject(request)}", ex); } response.ResponseRow = result; return(OperationResult.FromResult(response)); }