/// <summary> /// 发起支付 /// 订单确认后京东会异步发起支付,不再需要调用发起支付接口了。 /// </summary> /// <param name="jdOrderId">京东订单编号</param> /// <returns></returns> public JDBoolOut DoPay(int paymentCompanyId, string jdOrderId) { (paymentCompanyId == default(int)).TrueThrow("paymentCompanyId不能为空"); jdOrderId.NullOrEmptyCheck("jdOrderId"); var result = new JDBoolOut(); var token = GetJdToken(paymentCompanyId); token.NullCheck("token"); string str = CallApi("https://bizapi.jd.com/api/order/doPay", $"token={token.Access_Token}&jdOrderId={jdOrderId}"); JDBoolResult json = JsonConvert.DeserializeObject <JDBoolResult>(str); if (json != null) { result.Success = json.success; result.ResultCode = json.resultCode; result.ResultMessage = json.resultMessage; result.Data = json.success && json.result; } else { _log.InsertLog(LogLevel.Error, "京东-发起支付异常", str); } return(result); }
private JDBoolOut DeleteJDMessageByToken(string token, string msgId) { token.NullOrEmptyCheck("token"); JDBoolOut result = new JDBoolOut(); string str = CallApi("https://bizapi.jd.com/api/message/del", $"token={token}&id={msgId}"); JDBoolResult json = JsonConvert.DeserializeObject <JDBoolResult>(str); if (json != null) { result.Success = json.success; result.ResultCode = json.resultCode; result.ResultMessage = json.resultMessage; result.Data = json.success && json.result; } else { _log.InsertLog(LogLevel.Error, "京东-删除京东消息异常", str); } return(result); }
/// <summary> /// 取消售后服务单 /// </summary> /// <param name="reason">取消原因</param> /// <param name="afterSaleOrderIds">待取消售后服务单号</param> /// <returns></returns> public JDBoolOut AS_CancelAfterSaleOrder (int paymentCompanyId, string reason, params int[] afterSaleOrderIds) { reason.NullOrEmptyCheck("reason"); afterSaleOrderIds.NullCheck("afterSaleOrderIds"); (afterSaleOrderIds.Any() == false).TrueThrow("待取消售后服务单号不能为空"); (paymentCompanyId == default(int)).TrueThrow("paymentCompanyId不能为空"); var token = GetJdToken(paymentCompanyId); token.NullCheck("token"); var result = new JDBoolOut(); string str = CallApi("https://bizapi.jd.com/api/afterSale/auditCancel", $"token={token.Access_Token}¶m={{serviceIdList:{JsonConvert.SerializeObject(afterSaleOrderIds)},approveNotes:\"{reason}\"}}"); JDBoolResult json = JsonConvert.DeserializeObject <JDBoolResult>(str); if (json != null) { result.Success = json.success; result.ResultCode = json.resultCode; result.ResultMessage = json.resultMessage; result.Data = json.success && json.result; } else { _log.InsertLog(LogLevel.Error, "京东-取消售后服务单异常", str); } return(result); }
/// <summary> /// 创建售后服务单 /// 需要该配送单已经妥投。 /// 需要先调用10.3接口校验订单中某商品是否可以提交售后服务 /// 需要先调用10.4接口查询支持的服务类型 /// 需要先调用10.5接口查询支持的商品返回京东方式 /// </summary> /// <returns></returns> public JDBoolOut AS_CreateAfterSaleOrder(JDAfterSaleIn afterOrder) { afterOrder.NullCheck("afterOrder"); afterOrder.Check(); var result = new JDBoolOut(); var token = GetJdToken(afterOrder.PaymentCompanyId); token.NullCheck("token"); string _params = JsonConvert.SerializeObject(afterOrder); string str = CallApi("https://bizapi.jd.com/api/afterSale/createAfsApply", $"token={token.Access_Token}¶m={_params}"); JDStringlResult json = JsonConvert.DeserializeObject <JDStringlResult>(str); if (json != null) { result.Success = json.success; result.ResultCode = json.resultCode; result.ResultMessage = json.resultMessage; //success为服务单保存状态 result.Data = json.success; } else { _log.InsertLog(LogLevel.Error, "京东-创建服务单异常", str); } return(result); }
/// <summary> /// 删除京东消息 /// </summary> /// <param name="msgId">京东消息编码</param> /// <returns></returns> public JDBoolOut DeleteJDMessage(int paymentCompanyId, string msgId) { (paymentCompanyId == default(int)).TrueThrow("paymentCompanyId不能为空"); var token = GetJdToken(paymentCompanyId); token.NullCheck("token"); JDBoolOut result = DeleteJDMessageByToken(token.Access_Token, msgId); return(result); }
/// <summary> /// 删除京东消息 /// </summary> /// <param name="paymentCompanyId"></param> /// <param name="msgId"></param> /// <returns></returns> public ActionResult DeleteJDMessage(int?paymentCompanyId, string msgId) { JDBoolOut json = null; if (paymentCompanyId > 0) { json = _jdService.DeleteJDMessage(paymentCompanyId.Value, msgId); } else { json = _jdService.DeleteJDMessage(msgId); } return(Content(JsonConvert.SerializeObject(json))); }