【新增】自定义交易组件增加【获取商家信息】【更新商家信息】两个接口处理。

This commit is contained in:
大灰灰
2022-08-20 01:26:56 +08:00
parent 05a37fb99a
commit 57b7855595
9 changed files with 415 additions and 5 deletions

View File

@@ -0,0 +1,117 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
using CoreCms.Net.Caching.AccressToken;
using CoreCms.Net.Model.Entities;
using CoreCms.Net.Model.ViewModels.UI;
using CoreCms.Net.WeChat.Service.HttpClients;
using SKIT.FlurlHttpClient.Wechat.Api;
using SKIT.FlurlHttpClient.Wechat.Api.Models;
using CoreCms.Net.WeChat.Service.TransactionComponent.FromBody;
namespace CoreCms.Net.Web.Admin.Controllers.WeChat
{
/// <summary>
/// 自定义交易组件上传类目资质
///</summary>
[Description("自定义交易组件上传类目资质")]
[Route("api/[controller]/[action]")]
[ApiController]
public class WeChatTransactionComponentAccountController : ControllerBase
{
private readonly Net.WeChat.Service.HttpClients.IWeChatApiHttpClientFactory _weChatApiHttpClientFactory;
/// <summary>
/// 构造函数
/// </summary>
/// <param name="weChatApiHttpClientFactory"></param>
public WeChatTransactionComponentAccountController(IWeChatApiHttpClientFactory weChatApiHttpClientFactory)
{
_weChatApiHttpClientFactory = weChatApiHttpClientFactory;
}
#region ============================================================
// POST: Api/WeChatTransactionComponentAccount/GetInfo
/// <summary>
/// 获取商家信息
/// </summary>
/// <returns></returns>
[HttpPost]
[Description("获取商家信息")]
public async Task<AdminUiCallBack> GetInfo()
{
var jm = new AdminUiCallBack();
var accessToken = WeChatCacheAccessTokenHelper.GetWxOpenAccessToken();
var client = _weChatApiHttpClientFactory.CreateWxOpenClient();
var request = new ShopAccountGetInfoRequest();
request.AccessToken = accessToken;
var response = await client.ExecuteShopAccountGetInfoAsync(request);
jm.code = response.IsSuccessful() ? 0 : 1;
jm.msg = response.IsSuccessful() ? "获取成功" : response.ErrorMessage;
jm.data = response.Data;
jm.otherData = new
{
service_agent_type_service = response.Data.ServiceAgentTypeList?.Contains(0) == true ? 0 : -1,
service_agent_type_phone = response.Data.ServiceAgentTypeList?.Contains(2) == true ? 0 : -1,
service_agent_type_path = response.Data.ServiceAgentTypeList?.Contains(1) == true ? 0 : -1,
};
return jm;
}
#endregion
#region ============================================================
// POST: Api/WeChatTransactionComponentAccount/DoUpdateInfo
/// <summary>
/// 更新商家信息
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
[HttpPost]
[Description("更新商家信息")]
public async Task<AdminUiCallBack> DoUpdateInfo([FromBody] FMUpdateInfo entity)
{
var jm = new AdminUiCallBack { code = 0 };
var accessToken = WeChatCacheAccessTokenHelper.GetWxOpenAccessToken();
var client = _weChatApiHttpClientFactory.CreateWxOpenClient();
var request = new ShopAccountUpdateInfoRequest();
request.AccessToken = accessToken;
request.ServiceAgentTypeList = entity.service_agent_type;
request.ServiceAgentPagePath = entity.service_agent_path;
request.ServiceAgentPhoneNumber = entity.service_agent_phone;
request.DefaultReceivingAddress = new ShopAccountUpdateInfoRequest.Types.Address();
request.DefaultReceivingAddress.ReceiverName = entity.default_receiving_address.receiver_name;
request.DefaultReceivingAddress.Detail = entity.default_receiving_address.detailed_address;
request.DefaultReceivingAddress.TeleNumber = entity.default_receiving_address.tel_number;
request.DefaultReceivingAddress.Country = entity.default_receiving_address.country;
request.DefaultReceivingAddress.Province = entity.default_receiving_address.province;
request.DefaultReceivingAddress.City = entity.default_receiving_address.city;
request.DefaultReceivingAddress.District = entity.default_receiving_address.town;
var response = await client.ExecuteShopAccountUpdateInfoAsync(request);
jm.code = response.IsSuccessful() ? 0 : 1;
jm.msg = response.IsSuccessful() ? "更新成功" : response.ErrorMessage;
jm.data = entity;
return jm;
}
#endregion
}
}

View File

@@ -51,7 +51,7 @@ namespace CoreCms.Net.Web.Admin.Controllers
{
private readonly IWebHostEnvironment _webHostEnvironment;
private readonly IWeChatTransactionComponentBrandAuditServices _weChatTransactionComponentBrandAuditServices;
private readonly WeChat.Service.HttpClients.IWeChatApiHttpClientFactory _weChatApiHttpClientFactory;
private readonly CoreCms.Net.WeChat.Service.HttpClients.IWeChatApiHttpClientFactory _weChatApiHttpClientFactory;
/// <summary>
/// 构造函数

View File

@@ -46,7 +46,7 @@ namespace CoreCms.Net.Web.Admin.Controllers
{
private readonly IWebHostEnvironment _webHostEnvironment;
private readonly IWeChatTransactionComponentDeliveryCompanyServices _weChatTransactionComponentDeliveryCompanyServices;
private readonly WeChat.Service.HttpClients.IWeChatApiHttpClientFactory _weChatApiHttpClientFactory;
private readonly CoreCms.Net.WeChat.Service.HttpClients.IWeChatApiHttpClientFactory _weChatApiHttpClientFactory;
/// <summary>

View File

@@ -54,7 +54,7 @@ namespace CoreCms.Net.Web.Admin.Controllers
private readonly IWeChatTransactionComponentAuditCategoryServices
_weChatTransactionComponentAuditCategoryServices;
private readonly ICoreCmsProductsServices _productsServices;
private readonly WeChat.Service.HttpClients.IWeChatApiHttpClientFactory _weChatApiHttpClientFactory;
private readonly CoreCms.Net.WeChat.Service.HttpClients.IWeChatApiHttpClientFactory _weChatApiHttpClientFactory;
private readonly IWeChatTransactionComponentBrandAuditServices _weChatTransactionComponentBrandAuditServices;

View File

@@ -49,7 +49,7 @@ namespace CoreCms.Net.Web.Admin.Controllers
{
private readonly IWebHostEnvironment _webHostEnvironment;
private readonly IWeChatTransactionComponentThirdCategoryServices _weChatTcThirdCatListServices;
private readonly WeChat.Service.HttpClients.IWeChatApiHttpClientFactory _weChatApiHttpClientFactory;
private readonly CoreCms.Net.WeChat.Service.HttpClients.IWeChatApiHttpClientFactory _weChatApiHttpClientFactory;
/// <summary>