/// <summary> /// 用户绑定 /// </summary> /// <param name="mobile">商户注册的手机号</param> /// <param name="valCode">验证码</param> /// <param name="cityName">城市</param> /// <param name="countyName">区域</param> /// <returns></returns> public static UUBaseResult BindUserSubmit(string mobile, string valCode, string cityName, string countyName) { UUUserSubmit model = new UUUserSubmit(); model.appid = _appid; model.nonce_str = Guid.NewGuid().ToString().Replace("-", ""); model.timestamp = GetTimestamp(); model.openid = _openid; model.user_mobile = mobile; model.validate_code = valCode; model.city_name = cityName; model.county_name = countyName; model.reg_ip = WebHelper.GetIP(); Dictionary <string, string> mydic = GetDictionary(model); model.sign = CreateMd5Sign(mydic, _appsecret); mydic.Add("sign", model.sign); string url = _host + _bindUserSubmitApiUrl; string resultJson = HttpPost(url, mydic); UUBaseResult result = JsonConvert.DeserializeObject <UUBaseResult>(resultJson); return(result); //{"openid":"eff85e7142304bae9acd45cf1563eaf2","return_code":"ok","return_msg":"用户绑定成功","appid":"d2fe3af49ce544c4b5c0731aa5ab28df","nonce_str":"15757e727a2141bf8017c30dbaec7cd8","sign":"6697C9EB3A2C290A5C253A8CDAA654BE"} }
/// <summary> /// UU跑腿发送验证码 /// </summary> /// <param name="aId"></param> /// <returns></returns> public ActionResult UUSendPhoneCode(int aId = 0, string phone = "", int storeId = 0) { //参数验证 if (aId <= 0) { _result.msg = "参数错误"; return(Json(_result)); } if (string.IsNullOrWhiteSpace(phone)) { _result.msg = "请输入手机号码"; return(Json(_result)); } UUBaseResult uuResult = UUApi.BindUserApply(phone); if (uuResult != null) { _result.msg = uuResult.return_msg; _result.code = uuResult.return_code == "ok" ? 1 : 0; } else { _result.msg = "uu接口异常"; _result.code = 0; } return(Json(_result)); }
/// <summary> /// 下单 /// </summary> /// <param name="model"></param> /// <returns></returns> public static UUBaseResult AddOrder(UUOrder model) { model.nonce_str = Guid.NewGuid().ToString().Replace("-", ""); model.timestamp = GetTimestamp(); Dictionary <string, string> mydic = GetDictionary(model); model.sign = CreateMd5Sign(mydic, _appsecret); mydic.Add("sign", model.sign); string url = _host + _addOrderApiUrl; string resultJson = HttpPost(url, mydic); UUBaseResult result = JsonConvert.DeserializeObject <UUBaseResult>(resultJson); return(result); //{"ordercode":"U23108001807251739989279322","origin_id":"20180725173348","return_code":"ok","return_msg":"订单发布成功","appid":"d2fe3af49ce544c4b5c0731aa5ab28df","nonce_str":"29d8c95be2fe4b73bb648211b94fee0b","sign":"EDDF8CDC25DB95E3CF98CFCA13EA6F5A"} }
/// <summary> /// UU配送推单 /// </summary> /// <param name="orderId">小程序订单表ID</param> /// <param name="rid"></param> /// <param name="tran"></param> /// <returns></returns> public string GetUUOrderUpdateSql(int orderId, int aid, int storeId, ref TransactionModel tran, bool getTranSql = false) { UUOrder order = GetModelByOrerId(aid, storeId, orderId); if (order == null) { return("UU配送:订单不存在(推单)"); } UUCustomerRelation customerRelation = UUCustomerRelationBLL.SingleModel.GetModelByAid(aid, storeId, 0); if (customerRelation == null) { return("UU配送:未设置UU配置(推单)"); } UUBaseResult result = UUApi.AddOrder(order); if (result == null) { return("UU配送:推送订单接口异常(推单)"); } if (result.return_code == "ok") { order.State = (int)UUOrderEnum.单成功; if (result == null || string.IsNullOrEmpty(result.ordercode)) { LogHelper.WriteInfo(this.GetType(), "UU配送:推送订单接口返回值异常(推单)" + JsonConvert.SerializeObject(result)); return("UU配送:推送订单接口返回值异常(推单)"); } order.order_code = result.ordercode; if (getTranSql) { return(base.ExecuteNonQuery($"update UUOrder set state={order.State},order_code='{order.order_code}' where id={order.Id}") > 0 ? "" : "UU配送:修改UU订单状态出错(推单)"); } else { tran.Add($"update UUOrder set state={order.State},order_code='{order.order_code}' where id={order.Id}"); } return(""); } return(result.return_msg); }
/// <summary> /// 解绑UU跑腿 /// </summary> /// <param name="aId"></param> /// <returns></returns> public ActionResult UUCancelBind(int aId = 0, int storeId = 0, int id = 0) { //参数验证 if (aId <= 0 || id <= 0) { _result.msg = "参数错误"; return(Json(_result)); } UUCustomerRelation model = UUCustomerRelationBLL.SingleModel.GetModel(id); if (model == null) { _result.msg = "请刷新重试"; return(Json(_result)); } if (model.AId != aId || model.StoreId != storeId) { _result.msg = "无效权限"; return(Json(_result)); } UUBaseResult uuResult = UUApi.CancelBind(model.OpenId); if (uuResult != null) { _result.msg = uuResult.return_msg; if (uuResult.return_code == "ok") { model.State = -1; UUCustomerRelationBLL.SingleModel.Update(model, "state"); _result.code = 1; } } else { _result.msg = "uu接口异常"; _result.code = 0; } return(Json(_result)); }
/// <summary> /// 取消绑定 /// </summary> /// <param name="openId">商户openid</param> /// <returns></returns> public static UUBaseResult CancelBind(string openId) { UUUserSubmit model = new UUUserSubmit(); model.appid = _appid; model.nonce_str = Guid.NewGuid().ToString().Replace("-", ""); model.timestamp = GetTimestamp(); model.openid = openId; Dictionary <string, string> mydic = GetDictionary(model); model.sign = CreateMd5Sign(mydic, _appsecret); mydic.Add("sign", model.sign); string url = _host + _cancelBindApiUrl; string resultJson = HttpPost(url, mydic); UUBaseResult result = JsonConvert.DeserializeObject <UUBaseResult>(resultJson); return(result); //{"return_code":"ok","return_msg":"解除绑定成功","appid":"d2fe3af49ce544c4b5c0731aa5ab28df","nonce_str":"217fb4e25f6c4f1cabe53e7ad6545508","sign":"36D551A0B0E71A42FFBE12C21F006145"} }
/// <summary> /// 用户申请,发送验证码 /// </summary> /// <param name="mobile">注册的手机号</param> /// <returns></returns> public static UUBaseResult BindUserApply(string mobile) { UUBindUserApply model = new UUBindUserApply(); model.appid = _appid; model.nonce_str = Guid.NewGuid().ToString().Replace("-", ""); model.timestamp = GetTimestamp(); model.user_mobile = mobile; model.user_ip = WebHelper.GetIP(); Dictionary <string, string> mydic = GetDictionary(model); model.sign = CreateMd5Sign(mydic, _appsecret); mydic.Add("sign", model.sign); string url = _host + _bindUserApplyApiUrl; string resultJson = HttpPost(url, mydic); UUBaseResult result = JsonConvert.DeserializeObject <UUBaseResult>(resultJson); return(result); }
/// <summary> /// 获取订单详情 /// </summary> /// <param name="openId">商户openid</param> /// <param name="orderCode">uu平台返回的订单order_code</param> /// <returns></returns> public static UUBaseResult GetOrderDetail(string openId, string orderCode) { UUBase model = new UUBase(); model.appid = _appid; model.nonce_str = Guid.NewGuid().ToString().Replace("-", ""); model.timestamp = GetTimestamp(); model.openid = openId; model.order_code = orderCode; Dictionary <string, string> mydic = GetDictionary(model); model.sign = CreateMd5Sign(mydic, _appsecret); mydic.Add("sign", model.sign); string url = _host + _getOrderDetailApiUrl; string resultJson = HttpPost(url, mydic); UUBaseResult result = JsonConvert.DeserializeObject <UUBaseResult>(resultJson); return(result); }
/// <summary> /// 取消订单 /// </summary> /// <param name="aid"></param> /// <param name="storeId"></param> /// <param name="orderId"></param> /// <param name="reason"></param> /// <returns></returns> public bool CancelOrder(int aid, int storeId, int orderId, string reason = "") { bool success = false; UUOrder model = GetModelByOrerId(aid, storeId, orderId); if (model == null) { LogHelper.WriteInfo(this.GetType(), $"UU配送:没有找到快跑者订单数据_{aid}_{storeId}_{orderId}(取消订单)"); return(success); } UUCustomerRelation customerRelation = UUCustomerRelationBLL.SingleModel.GetModelByAid(aid, storeId, 0); if (customerRelation == null) { LogHelper.WriteInfo(this.GetType(), $"UU配送:无效UU配置{aid}_{storeId}_{orderId}(取消订单)"); return(success); } if (!(model.State == (int)UUOrderEnum.单成功 || model.State == (int)UUOrderEnum.已到达 || model.State == (int)UUOrderEnum.跑男抢单)) { LogHelper.WriteInfo(this.GetType(), $"UU配送:取件前才能取消_{aid}_{storeId}_{orderId}(取消订单)"); return(success); } UUBaseResult result = UUApi.CanecelOrder(model.openid, model.order_code, reason); if (result == null || result.return_code != "ok") { LogHelper.WriteInfo(this.GetType(), $"UU配送:接口返回异常(取消订单)_{model.order_code}_{customerRelation.Id}" + (result != null ? result.return_msg : "")); } else { model.State = (int)UUOrderEnum.订单取消中; success = base.Update(model, "State"); if (!success) { LogHelper.WriteInfo(this.GetType(), $"UU配送:更新系统订单状态失败(取消订单)_{model.Id}"); } } return(success); }
/// <summary> /// UU跑腿配置 /// </summary> /// <returns></returns> public ActionResult UUPeiSongConfig(int aId = 0, string act = "", int storeId = 0, UUCustomerRelation model = null) { //参数验证 if (aId <= 0) { _result.msg = "参数错误"; return(Json(_result)); } //显示 if (string.IsNullOrEmpty(act)) { EditModel <UUCustomerRelation> em = new EditModel <UUCustomerRelation>(); em.appId = aId; em.storeId = storeId; em.aId = aId; UUCustomerRelation storemodel = UUCustomerRelationBLL.SingleModel.GetModelByAid(aId, storeId, 0); if (storemodel == null) { storemodel = new UUCustomerRelation(); } em.DataModel = storemodel; return(View(em)); } else { if (act == "edit") { if (model == null) { _result.msg = "参数出错"; return(Json(_result)); } if (string.IsNullOrEmpty(model.Phone)) { _result.msg = "请输入商户手机号"; return(Json(_result)); } if (string.IsNullOrEmpty(model.PhoneCode)) { _result.msg = "请输入验证码"; return(Json(_result)); } UUBaseResult result = UUApi.BindUserSubmit(model.Phone, model.PhoneCode, model.CityName, model.CountyName); if (result != null && result.return_code == "ok" && !string.IsNullOrEmpty(result.openid)) { model.OpenId = result.openid; model.UpdateTime = DateTime.Now; if (model.Id <= 0) { model.State = 0; model.AId = aId; model.StoreId = storeId; model.AddTime = DateTime.Now; UUCustomerRelationBLL.SingleModel.Add(model); } else { UUCustomerRelationBLL.SingleModel.Update(model); } _result.msg = "注册成功"; _result.code = 1; } } } return(Json(_result)); }