/// <summary> /// 取消订单 /// </summary> /// <returns></returns> public ActionResult CancelOrder() { string orderno = Context.GetRequest("orderno", string.Empty); object data = new FNCancelOrderRequestModel() { partner_order_code = orderno, order_cancel_reason_code = 2, order_cancel_code = 0, order_cancel_description = "货品不新鲜", order_cancel_time = Convert.ToInt64(FNApi.SingleModel.GetTimeStamp()), }; string url = FNApi._cancelorderapi; string result = FNApi.SingleModel.UseFNApi(data, url); return(Json(new { isok = true, msg = result }, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 取消订单 /// </summary> /// <returns></returns> public ActionResult CancelFNOrder() { string orderid = Context.GetRequest("orderid", string.Empty); string orderno = Context.GetRequest("orderno", string.Empty); int cancelcode = Context.GetRequestInt("cancel_reason_id", 0); string cancel_reason = Context.GetRequest("cancel_reason", string.Empty); object data = new FNCancelOrderRequestModel() { partner_order_code = orderno, order_cancel_reason_code = 2, order_cancel_code = cancelcode, order_cancel_description = cancel_reason, order_cancel_time = Convert.ToInt64(FNApi.SingleModel.GetTimeStamp()), }; string url = FNApi._cancelorderapi; string result = FNApi.SingleModel.UseFNApi(data, url); if (string.IsNullOrEmpty(result)) { return(Json(new { isok = false, msg = "取消订单失败" }, JsonRequestBehavior.AllowGet)); } FNApiReponseModel <object> reposemodel = JsonConvert.DeserializeObject <FNApiReponseModel <object> >(result); if (reposemodel == null || reposemodel.code != 200) { return(Json(new { isok = false, msg = reposemodel == null ?"接口异常":reposemodel.msg }, JsonRequestBehavior.AllowGet)); } else { FNOrder order = FNOrderBLL.SingleModel.GetModelByOrderNo(orderno); if (order == null) { return(Json(new { isok = false, msg = "找不到蜂鸟订单" }, JsonRequestBehavior.AllowGet)); } order.state = (int)FNOrderEnum.已取消; order.updatetime = DateTime.Now; order.order_cancel_reason_code = 2; order.order_cancel_code = cancelcode; order.order_cancel_description = cancel_reason; order.order_cancel_time = FNApi.SingleModel.GetTimeStamp().ToString(); bool success = FNOrderBLL.SingleModel.Update(order, "state,updatetime,order_cancel_reason_code,order_cancel_code,order_cancel_description,order_cancel_time"); if (!success) { return(Json(new { isok = false, msg = "修改蜂鸟订单状态失败" }, JsonRequestBehavior.AllowGet)); } FoodGoodsOrder foodGoodOrder = FoodGoodsOrderBLL.SingleModel.GetModel($" Id = {orderid} "); if (foodGoodOrder == null) { return(Json(new { isok = false, msg = "蜂鸟配送:找不到订单" }, JsonRequestBehavior.AllowGet)); } //退款接口 abel if (foodGoodOrder.BuyMode == (int)miniAppBuyMode.微信支付) { success = FoodGoodsOrderBLL.SingleModel.outOrder(foodGoodOrder, foodGoodOrder.State); } else if (foodGoodOrder.BuyMode == (int)miniAppBuyMode.储值支付) { SaveMoneySetUser userSaveMoney = SaveMoneySetUserBLL.SingleModel.getModelByUserId(foodGoodOrder.UserId) ?? new SaveMoneySetUser(); success = FoodGoodsOrderBLL.SingleModel.outOrderBySaveMoneyUser(foodGoodOrder, userSaveMoney, foodGoodOrder.State); } } return(Json(new { isok = true, msg = result }, JsonRequestBehavior.AllowGet)); }