/// <summary> /// 卡券核销 /// </summary> /// <param name="context"></param> /// <returns></returns> private string Hexiao(HttpContext context) { string cardCouponId = context.Request["cardcoupon_id"]; //主卡券ID string hexiaoCode = context.Request["hexiao_code"]; //核销码 if (string.IsNullOrEmpty(cardCouponId)) { apiResp.msg = "cardcoupon_id 参数必传"; return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); } if (string.IsNullOrEmpty(hexiaoCode)) { apiResp.msg = "hexiao_code 参数必传"; return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); } CardCoupons cardCoupon = bllCardCoupon.GetCardCoupon(int.Parse(cardCouponId)); if (cardCoupon == null) { apiResp.msg = "卡券不存在"; return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); } MyCardCoupons myCardCoupon = bllCardCoupon.Get <MyCardCoupons>(string.Format(" CardId={0} And Status=0 And UserId='{1}'", cardCoupon.CardId, currentUserInfo.UserID)); if (myCardCoupon == null) { apiResp.msg = "卡券不存在"; return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); } if (myCardCoupon.Status == 1) { apiResp.msg = "卡券已经使用"; return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); } string hexiaoChanel = ""; bool hexiaoResult = GetHexiaoChannel(hexiaoCode, out hexiaoChanel); if (!hexiaoResult) { apiResp.msg = "核销失败"; return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); } try { myCardCoupon.HexiaoCode = hexiaoCode; myCardCoupon.HexiaoChannel = hexiaoChanel; myCardCoupon.Status = 1; myCardCoupon.UseDate = DateTime.Now; if (!bllCardCoupon.Update(myCardCoupon)) { apiResp.msg = "核销失败"; return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); } else { apiResp.status = true; apiResp.msg = "ok"; } } catch (Exception ex) { apiResp.msg = ex.Message; return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); } return(ZentCloud.Common.JSONHelper.ObjectToJson(apiResp)); }