public IHttpActionResult GetProductInfo(string code) { LogHelper.WriteLog("GetProductInfo code" + code); SimpleResult result = new SimpleResult(); IProductInfoService _service = new ProductInfoService(); try { if (UserAuthorization) { var list = _service.GetProductInfo(code); result.Resource = list; result.Status = Result.SUCCEED; } else { result.Status = ResultType; result.Resource = ReAccessToken; result.Msg = TokenMessage; } } catch (Exception ex) { LogHelper.WriteLog("GetProductInfo code" + code, ex); result.Status = Result.FAILURE; result.Msg = ex.Message; } LogHelper.WriteLog("GetProductInfo " + Json(result)); return(Json(result)); }
public IHttpActionResult GetPayPage(string orderCode) { LogHelper.WriteLog("GetPayPage " + orderCode); SimpleResult result = new SimpleResult(); IOrderService _orderService = new OrderService(); IProductInfoService _service = new ProductInfoService(); ICouponService _couponService = new CouponService(); string msg = ""; try { if (UserAuthorization) { var orderInfo = _orderService.GetOrderInfo(orderCode); if (orderInfo == null) { msg = "订单不存在!"; result.Status = Result.SYSTEM_ERROR; result.Resource = null; } else if (orderInfo.PayTime != null) { msg = "该订单已付款!"; result.Status = Result.SYSTEM_ERROR; result.Resource = null; } else { if (!string.IsNullOrEmpty(orderInfo.ExperienceVoucherCode)) { //var isUseCoupon = _couponService.Exist(orderInfo.ExperienceVoucherCode); //if (isUseCoupon != 3) //{ // orderInfo.ExperienceVoucherCode = ""; //} using (var scope = new TransactionScope())//创建事务 { _couponService.UpdatebycouponCode(orderInfo.ExperienceVoucherCode); orderInfo.ExperienceVoucherCode = null; _orderService.UpdateOrder(orderInfo); scope.Complete();//这是最后提交事务 } } var productInfo = _service.GetProductInfo(orderInfo.ProductCode); result.Status = Result.SUCCEED; result.Resource = new { orderInfo = orderInfo, productInfo = productInfo }; } result.Msg = msg; } else { result.Status = ResultType; result.Resource = ReAccessToken; result.Msg = TokenMessage; } } catch (Exception ex) { LogHelper.WriteLog("GetPayPage orderCode" + orderCode, ex); result.Status = Result.FAILURE; result.Msg = ex.Message; } LogHelper.WriteLog("GetPayPage result" + Json(result)); return(Json(result)); }