mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 17:43:26 +08:00
【优化】移除旧版自定义交易组件。
This commit is contained in:
@@ -28,7 +28,6 @@ using CoreCms.Net.Model.ViewModels.UI;
|
||||
using CoreCms.Net.Utility.Extensions;
|
||||
using CoreCms.Net.Utility.Helper;
|
||||
using CoreCms.Net.WeChat.Service.HttpClients;
|
||||
using CoreCms.Net.WeChat.Service.TransactionComponent.Enum;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -62,9 +61,7 @@ namespace CoreCms.Net.Web.Admin.Controllers
|
||||
private readonly ICoreCmsLogisticsServices _logisticsServices;
|
||||
private readonly ICoreCmsPaymentsServices _paymentsServices;
|
||||
private readonly ICoreCmsSettingServices _settingServices;
|
||||
private readonly IWeChatTransactionComponentOrderServices _tcOrderServices;
|
||||
private readonly ICoreCmsUserWeChatInfoServices _userWeChatInfoServices;
|
||||
private readonly IWeChatTransactionComponentDeliveryCompanyServices _tcDeliveryCompanyServices;
|
||||
private readonly IRedisOperationRepository _redisOperationRepository;
|
||||
private readonly CoreCms.Net.WeChat.Service.HttpClients.IWeChatApiHttpClientFactory _weChatApiHttpClientFactory;
|
||||
|
||||
@@ -85,7 +82,7 @@ namespace CoreCms.Net.Web.Admin.Controllers
|
||||
, ICoreCmsLogisticsServices logisticsServices
|
||||
, ICoreCmsBillPaymentsServices billPaymentsServices
|
||||
, ICoreCmsPaymentsServices paymentsServices
|
||||
, ICoreCmsSettingServices settingServices, IWeChatTransactionComponentOrderServices tcOrderServices, ICoreCmsUserWeChatInfoServices userWeChatInfoServices, IWeChatTransactionComponentDeliveryCompanyServices tcDeliveryCompanyServices, IRedisOperationRepository redisOperationRepository, ICoreCmsBillDeliveryServices billDeliveryServices, IWeChatApiHttpClientFactory weChatApiHttpClientFactory, ICoreCmsOrderItemServices orderItemServices)
|
||||
, ICoreCmsSettingServices settingServices, ICoreCmsUserWeChatInfoServices userWeChatInfoServices, IRedisOperationRepository redisOperationRepository, ICoreCmsBillDeliveryServices billDeliveryServices, IWeChatApiHttpClientFactory weChatApiHttpClientFactory, ICoreCmsOrderItemServices orderItemServices)
|
||||
{
|
||||
_webHostEnvironment = webHostEnvironment;
|
||||
_coreCmsOrderServices = coreCmsOrderServices;
|
||||
@@ -97,9 +94,7 @@ namespace CoreCms.Net.Web.Admin.Controllers
|
||||
_billPaymentsServices = billPaymentsServices;
|
||||
_paymentsServices = paymentsServices;
|
||||
_settingServices = settingServices;
|
||||
_tcOrderServices = tcOrderServices;
|
||||
_userWeChatInfoServices = userWeChatInfoServices;
|
||||
_tcDeliveryCompanyServices = tcDeliveryCompanyServices;
|
||||
_redisOperationRepository = redisOperationRepository;
|
||||
_billDeliveryServices = billDeliveryServices;
|
||||
_weChatApiHttpClientFactory = weChatApiHttpClientFactory;
|
||||
@@ -498,7 +493,6 @@ namespace CoreCms.Net.Web.Admin.Controllers
|
||||
var storeList = await _storeServices.QueryAsync();
|
||||
|
||||
var logistics = await _logisticsServices.QueryListByClauseAsync(p => p.isDelete == false);
|
||||
var deliveryCompany = await _tcDeliveryCompanyServices.GetCaChe();
|
||||
|
||||
var result = await _coreCmsOrderServices.GetOrderShipInfo(entity.id);
|
||||
if (!result.status)
|
||||
@@ -525,7 +519,6 @@ namespace CoreCms.Net.Web.Admin.Controllers
|
||||
orderModel = result.data,
|
||||
storeList,
|
||||
logistics,
|
||||
deliveryCompany
|
||||
};
|
||||
|
||||
return jm;
|
||||
@@ -1660,7 +1653,6 @@ namespace CoreCms.Net.Web.Admin.Controllers
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region 批量删除订单============================================================
|
||||
// POST: Api/CoreCmsOrder/DeleteOrder/10
|
||||
/// <summary>
|
||||
@@ -1724,8 +1716,7 @@ namespace CoreCms.Net.Web.Admin.Controllers
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region 预览快递进度============================================================
|
||||
// POST: Api/CoreCmsOrder/GetDetails/10
|
||||
/// <summary>
|
||||
@@ -1752,99 +1743,5 @@ namespace CoreCms.Net.Web.Admin.Controllers
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 获取交易组件订单信息
|
||||
// POST: Api/CoreCmsOrder/GetTcOrder/10
|
||||
/// <summary>
|
||||
/// 获取交易组件订单信息
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("获取交易组件订单信息")]
|
||||
public async Task<AdminUiCallBack> GetTcOrder([FromBody] FMStringId entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var orderModel = await _coreCmsOrderServices.QueryByClauseAsync(p => p.orderId == entity.id);
|
||||
if (orderModel == null)
|
||||
{
|
||||
jm.msg = "不存在此订单信息";
|
||||
return jm;
|
||||
}
|
||||
|
||||
var tcOrder = await _tcOrderServices.QueryByClauseAsync(p => p.outOrderId == entity.id);
|
||||
if (tcOrder == null)
|
||||
{
|
||||
jm.msg = "不存在此订单交易组件推送记录";
|
||||
return jm;
|
||||
}
|
||||
|
||||
var weChatUserInfo = await _userWeChatInfoServices.QueryByClauseAsync(p => p.userId == orderModel.userId);
|
||||
if (weChatUserInfo == null)
|
||||
{
|
||||
jm.msg = "用户微信数据拉取失败";
|
||||
return jm;
|
||||
}
|
||||
|
||||
//获取小程序认证
|
||||
var accessToken = WeChatCacheAccessTokenHelper.GetWxOpenAccessToken();
|
||||
var client = _weChatApiHttpClientFactory.CreateWxOpenClient();
|
||||
var request = new ShopOrderGetRequest();
|
||||
request.AccessToken = accessToken;
|
||||
request.OutOrderId = orderModel.orderId;
|
||||
request.OpenId = weChatUserInfo.openid;
|
||||
|
||||
var response = await client.ExecuteShopOrderGetAsync(request);
|
||||
|
||||
var orderStatus = EnumHelper.EnumToList<OrderStatus>();
|
||||
var deliveryTypeEnum = EnumHelper.EnumToList<DeliveryTypeEnum>();
|
||||
|
||||
|
||||
jm.code = response.IsSuccessful() ? 0 : 1;
|
||||
jm.msg = response.IsSuccessful() ? "获取成功" : response.ErrorMessage;
|
||||
jm.data = new
|
||||
{
|
||||
response.Order,
|
||||
orderStatus,
|
||||
deliveryTypeEnum
|
||||
};
|
||||
jm.otherData = accessToken;
|
||||
|
||||
//更新拉取订单
|
||||
if (response.Order is { OrderId: > 0 } && tcOrder.orderId == null)
|
||||
{
|
||||
await _tcOrderServices.UpdateAsync(
|
||||
p => new WeChatTransactionComponentOrder() { orderId = response.Order.OrderId },
|
||||
p => p.id == tcOrder.id && p.outOrderId == tcOrder.outOrderId);
|
||||
}
|
||||
|
||||
if (response.Order is { OrderId: > 0 } && (response.Order.Status == 11 || response.Order.Status == 10) && (orderModel.payStatus == (int)GlobalEnumVars.OrderPayStatus.Yes || orderModel.payStatus == (int)GlobalEnumVars.OrderPayStatus.PartialYes))
|
||||
{
|
||||
var payment = await _billPaymentsServices.QueryByClauseAsync(p =>
|
||||
p.sourceId == orderModel.orderId && p.status == (int)GlobalEnumVars.BillPaymentsStatus.Payed);
|
||||
if (payment != null)
|
||||
{
|
||||
var userInfo = await _userWeChatInfoServices.QueryByClauseAsync(p => p.userId == orderModel.userId);
|
||||
//获取同步地址接口地址
|
||||
var refreshRequest = new ShopOrderPayRequest();
|
||||
refreshRequest.AccessToken = accessToken;
|
||||
refreshRequest.OutOrderId = orderModel.orderId;
|
||||
refreshRequest.OpenId = userInfo.openid;
|
||||
refreshRequest.ActionType = 1;
|
||||
refreshRequest.TransactionId = payment.tradeNo;
|
||||
refreshRequest.PayTime = payment.createTime;
|
||||
|
||||
var refreshResponse = await client.ExecuteShopOrderPayAsync(refreshRequest);
|
||||
NLogUtil.WriteAll(NLog.LogLevel.Error, LogType.RedisMessageQueue, "自定义交易组件-手动同步", JsonConvert.SerializeObject(refreshResponse));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,129 +0,0 @@
|
||||
using System;
|
||||
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();
|
||||
|
||||
try
|
||||
{
|
||||
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,
|
||||
};
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
jm.code = 0;
|
||||
jm.msg = e.Message;
|
||||
jm.otherData = new
|
||||
{
|
||||
service_agent_type_service = -1,
|
||||
service_agent_type_phone = -1,
|
||||
service_agent_type_path = -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
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,402 +0,0 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/7/14 23:14:23
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.Entities.Expression;
|
||||
using CoreCms.Net.Model.FromBody;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using CoreCms.Net.Filter;
|
||||
using CoreCms.Net.Loging;
|
||||
using CoreCms.Net.IServices;
|
||||
using CoreCms.Net.Utility.Helper;
|
||||
using CoreCms.Net.Utility.Extensions;
|
||||
using CoreCms.Net.WeChat.Service.TransactionComponent.Enum;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NPOI.HSSF.UserModel;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Web.Admin.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 自定义交易组件上传类目资质
|
||||
///</summary>
|
||||
[Description("自定义交易组件上传类目资质")]
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
[RequiredErrorForAdmin]
|
||||
[Authorize(Permissions.Name)]
|
||||
public class WeChatTransactionComponentAuditCategoryController : ControllerBase
|
||||
{
|
||||
private readonly IWebHostEnvironment _webHostEnvironment;
|
||||
private readonly IWeChatTransactionComponentAuditCategoryServices _weChatTransactionComponentAuditCategoryServices;
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
///</summary>
|
||||
public WeChatTransactionComponentAuditCategoryController(IWebHostEnvironment webHostEnvironment
|
||||
, IWeChatTransactionComponentAuditCategoryServices weChatTransactionComponentAuditCategoryServices
|
||||
)
|
||||
{
|
||||
_webHostEnvironment = webHostEnvironment;
|
||||
_weChatTransactionComponentAuditCategoryServices = weChatTransactionComponentAuditCategoryServices;
|
||||
}
|
||||
|
||||
#region 获取列表============================================================
|
||||
// POST: Api/WeChatTransactionComponentAuditCategory/GetPageList
|
||||
/// <summary>
|
||||
/// 获取列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("获取列表")]
|
||||
public async Task<AdminUiCallBack> GetPageList()
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
var pageCurrent = Request.Form["page"].FirstOrDefault().ObjectToInt(1);
|
||||
var pageSize = Request.Form["limit"].FirstOrDefault().ObjectToInt(30);
|
||||
var where = PredicateBuilder.True<WeChatTransactionComponentAuditCategory>();
|
||||
//获取排序字段
|
||||
var orderField = Request.Form["orderField"].FirstOrDefault();
|
||||
|
||||
Expression<Func<WeChatTransactionComponentAuditCategory, object>> orderEx = orderField switch
|
||||
{
|
||||
"id" => p => p.id,
|
||||
"licenseImage" => p => p.licenseImage,
|
||||
"level1" => p => p.level1,
|
||||
"level1Name" => p => p.level1Name,
|
||||
"level2" => p => p.level2,
|
||||
"level2Name" => p => p.level2Name,
|
||||
"level3" => p => p.level3,
|
||||
"level3Name" => p => p.level3Name,
|
||||
"certificateImage" => p => p.certificateImage,
|
||||
"auditId" => p => p.auditId,
|
||||
"status" => p => p.status,
|
||||
"brandId" => p => p.brandId,
|
||||
"rejectReason" => p => p.rejectReason,
|
||||
"createTime" => p => p.createTime,
|
||||
_ => p => p.id
|
||||
};
|
||||
|
||||
//设置排序方式
|
||||
var orderDirection = Request.Form["orderDirection"].FirstOrDefault();
|
||||
var orderBy = orderDirection switch
|
||||
{
|
||||
"asc" => OrderByType.Asc,
|
||||
"desc" => OrderByType.Desc,
|
||||
_ => OrderByType.Desc
|
||||
};
|
||||
//查询筛选
|
||||
|
||||
//序列 int
|
||||
var id = Request.Form["id"].FirstOrDefault().ObjectToInt(0);
|
||||
if (id > 0)
|
||||
{
|
||||
where = where.And(p => p.id == id);
|
||||
}
|
||||
//营业执照或组织机构代码证 nvarchar
|
||||
var licenseImage = Request.Form["licenseImage"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(licenseImage))
|
||||
{
|
||||
where = where.And(p => p.licenseImage.Contains(licenseImage));
|
||||
}
|
||||
//一级类目 int
|
||||
var level1 = Request.Form["level1"].FirstOrDefault().ObjectToInt(0);
|
||||
if (level1 > 0)
|
||||
{
|
||||
where = where.And(p => p.level1 == level1);
|
||||
}
|
||||
//一级类目名称 nvarchar
|
||||
var level1Name = Request.Form["level1Name"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(level1Name))
|
||||
{
|
||||
where = where.And(p => p.level1Name.Contains(level1Name));
|
||||
}
|
||||
//二级类目 int
|
||||
var level2 = Request.Form["level2"].FirstOrDefault().ObjectToInt(0);
|
||||
if (level2 > 0)
|
||||
{
|
||||
where = where.And(p => p.level2 == level2);
|
||||
}
|
||||
//二级类目名称 nvarchar
|
||||
var level2Name = Request.Form["level2Name"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(level2Name))
|
||||
{
|
||||
where = where.And(p => p.level2Name.Contains(level2Name));
|
||||
}
|
||||
//三级类目 int
|
||||
var level3 = Request.Form["level3"].FirstOrDefault().ObjectToInt(0);
|
||||
if (level3 > 0)
|
||||
{
|
||||
where = where.And(p => p.level3 == level3);
|
||||
}
|
||||
//三级类目名称 nvarchar
|
||||
var level3Name = Request.Form["level3Name"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(level3Name))
|
||||
{
|
||||
where = where.And(p => p.level3Name.Contains(level3Name));
|
||||
}
|
||||
//资质材料 nvarchar
|
||||
var certificateImage = Request.Form["certificateImage"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(certificateImage))
|
||||
{
|
||||
where = where.And(p => p.certificateImage.Contains(certificateImage));
|
||||
}
|
||||
//审核单 nvarchar
|
||||
var auditId = Request.Form["auditId"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(auditId))
|
||||
{
|
||||
where = where.And(p => p.auditId.Contains(auditId));
|
||||
}
|
||||
//审核状态 int
|
||||
var status = Request.Form["status"].FirstOrDefault().ObjectToInt(0);
|
||||
if (status > 0)
|
||||
{
|
||||
where = where.And(p => p.status == status);
|
||||
}
|
||||
//品牌id int
|
||||
var brandId = Request.Form["brandId"].FirstOrDefault().ObjectToInt(0);
|
||||
if (brandId > 0)
|
||||
{
|
||||
where = where.And(p => p.brandId == brandId);
|
||||
}
|
||||
//拒绝原因 nvarchar
|
||||
var rejectReason = Request.Form["rejectReason"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(rejectReason))
|
||||
{
|
||||
where = where.And(p => p.rejectReason.Contains(rejectReason));
|
||||
}
|
||||
//创建时间 datetime
|
||||
var createTime = Request.Form["createTime"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(createTime))
|
||||
{
|
||||
if (createTime.Contains("到"))
|
||||
{
|
||||
var dts = createTime.Split("到");
|
||||
var dtStart = dts[0].Trim().ObjectToDate();
|
||||
where = where.And(p => p.createTime > dtStart);
|
||||
var dtEnd = dts[1].Trim().ObjectToDate();
|
||||
where = where.And(p => p.createTime < dtEnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
var dt = createTime.ObjectToDate();
|
||||
where = where.And(p => p.createTime > dt);
|
||||
}
|
||||
}
|
||||
//获取数据
|
||||
var list = await _weChatTransactionComponentAuditCategoryServices.QueryPageAsync(where, orderEx, orderBy, pageCurrent, pageSize, true);
|
||||
//返回数据
|
||||
jm.data = list;
|
||||
jm.code = 0;
|
||||
jm.count = list.TotalCount;
|
||||
jm.msg = "数据调用成功!";
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 首页数据============================================================
|
||||
// POST: Api/WeChatTransactionComponentAuditCategory/GetIndex
|
||||
/// <summary>
|
||||
/// 首页数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("首页数据")]
|
||||
public AdminUiCallBack GetIndex()
|
||||
{
|
||||
//返回数据
|
||||
var jm = new AdminUiCallBack { code = 0 };
|
||||
|
||||
var auditCategoryStatus = EnumHelper.EnumToList<AuditEnum.AuditCategoryStatus>();
|
||||
|
||||
jm.data = new
|
||||
{
|
||||
auditCategoryStatus
|
||||
};
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 创建数据============================================================
|
||||
// POST: Api/WeChatTransactionComponentAuditCategory/GetCreate
|
||||
/// <summary>
|
||||
/// 创建数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("创建数据")]
|
||||
public AdminUiCallBack GetCreate()
|
||||
{
|
||||
//返回数据
|
||||
var jm = new AdminUiCallBack { code = 0 };
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 创建提交============================================================
|
||||
// POST: Api/WeChatTransactionComponentAuditCategory/DoCreate
|
||||
/// <summary>
|
||||
/// 创建提交
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("创建提交")]
|
||||
public async Task<AdminUiCallBack> DoCreate([FromBody] WeChatTransactionComponentAuditCategory entity)
|
||||
{
|
||||
var jm = await _weChatTransactionComponentAuditCategoryServices.InsertAsync(entity);
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 编辑数据============================================================
|
||||
// POST: Api/WeChatTransactionComponentAuditCategory/GetEdit
|
||||
/// <summary>
|
||||
/// 编辑数据
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("编辑数据")]
|
||||
public async Task<AdminUiCallBack> GetEdit([FromBody] FMIntId entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var model = await _weChatTransactionComponentAuditCategoryServices.QueryByIdAsync(entity.id, false);
|
||||
if (model == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
jm.code = 0;
|
||||
jm.data = model;
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 编辑提交============================================================
|
||||
// POST: Api/WeChatTransactionComponentAuditCategory/Edit
|
||||
/// <summary>
|
||||
/// 编辑提交
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("编辑提交")]
|
||||
public async Task<AdminUiCallBack> DoEdit([FromBody] WeChatTransactionComponentAuditCategory entity)
|
||||
{
|
||||
var jm = await _weChatTransactionComponentAuditCategoryServices.UpdateAsync(entity);
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 删除数据============================================================
|
||||
// POST: Api/WeChatTransactionComponentAuditCategory/DoDelete/10
|
||||
/// <summary>
|
||||
/// 单选删除
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("单选删除")]
|
||||
public async Task<AdminUiCallBack> DoDelete([FromBody] FMIntId entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var model = await _weChatTransactionComponentAuditCategoryServices.ExistsAsync(p => p.id == entity.id, true);
|
||||
if (!model)
|
||||
{
|
||||
jm.msg = GlobalConstVars.DataisNo;
|
||||
return jm;
|
||||
}
|
||||
jm = await _weChatTransactionComponentAuditCategoryServices.DeleteByIdAsync(entity.id);
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 预览数据============================================================
|
||||
// POST: Api/WeChatTransactionComponentAuditCategory/GetDetails/10
|
||||
/// <summary>
|
||||
/// 预览数据
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("预览数据")]
|
||||
public async Task<AdminUiCallBack> GetDetails([FromBody] FMIntId entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var model = await _weChatTransactionComponentAuditCategoryServices.QueryByIdAsync(entity.id, false);
|
||||
if (model == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
jm.code = 0;
|
||||
|
||||
var auditCategoryStatus = EnumHelper.EnumToList<AuditEnum.AuditCategoryStatus>();
|
||||
jm.data = new
|
||||
{
|
||||
model,
|
||||
auditCategoryStatus,
|
||||
imagesArr = model.certificateImage.Split(",")
|
||||
};
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 同步审核状态============================================================
|
||||
// POST: Api/WeChatTransactionComponentAuditCategory/DoDelete/10
|
||||
/// <summary>
|
||||
/// 同步审核状态
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("同步审核状态")]
|
||||
public async Task<AdminUiCallBack> DoRefresh([FromBody] FMIntId entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var model = await _weChatTransactionComponentAuditCategoryServices.QueryByClauseAsync(p => p.id == entity.id, true);
|
||||
if (model == null)
|
||||
{
|
||||
jm.msg = GlobalConstVars.DataisNo;
|
||||
return jm;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(model.auditId))
|
||||
{
|
||||
jm.msg = "审核单获取失败,请重新提交";
|
||||
return jm;
|
||||
}
|
||||
|
||||
jm = await _weChatTransactionComponentAuditCategoryServices.RefreshStatus(model);
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,585 +0,0 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2022/3/20 1:19:25
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using CoreCms.Net.Caching.AccressToken;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.Entities.Expression;
|
||||
using CoreCms.Net.Model.FromBody;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using CoreCms.Net.Filter;
|
||||
using CoreCms.Net.Loging;
|
||||
using CoreCms.Net.IServices;
|
||||
using CoreCms.Net.Utility.Helper;
|
||||
using CoreCms.Net.Utility.Extensions;
|
||||
using CoreCms.Net.WeChat.Service.HttpClients;
|
||||
using CoreCms.Net.WeChat.Service.TransactionComponent.Enum;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NPOI.HSSF.UserModel;
|
||||
using SKIT.FlurlHttpClient.Wechat.Api;
|
||||
using SKIT.FlurlHttpClient.Wechat.Api.Models;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Web.Admin.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 自定义交易组件上传品牌信息
|
||||
///</summary>
|
||||
[Description("自定义交易组件上传品牌信息")]
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
[RequiredErrorForAdmin]
|
||||
[Authorize(Permissions.Name)]
|
||||
public class WeChatTransactionComponentBrandAuditController : ControllerBase
|
||||
{
|
||||
private readonly IWebHostEnvironment _webHostEnvironment;
|
||||
private readonly IWeChatTransactionComponentBrandAuditServices _weChatTransactionComponentBrandAuditServices;
|
||||
private readonly CoreCms.Net.WeChat.Service.HttpClients.IWeChatApiHttpClientFactory _weChatApiHttpClientFactory;
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
///</summary>
|
||||
public WeChatTransactionComponentBrandAuditController(IWebHostEnvironment webHostEnvironment
|
||||
, IWeChatTransactionComponentBrandAuditServices weChatTransactionComponentBrandAuditServices, IWeChatApiHttpClientFactory weChatApiHttpClientFactory)
|
||||
{
|
||||
_webHostEnvironment = webHostEnvironment;
|
||||
_weChatTransactionComponentBrandAuditServices = weChatTransactionComponentBrandAuditServices;
|
||||
_weChatApiHttpClientFactory = weChatApiHttpClientFactory;
|
||||
}
|
||||
|
||||
#region 获取列表============================================================
|
||||
// POST: Api/WeChatTransactionComponentBrandAudit/GetPageList
|
||||
/// <summary>
|
||||
/// 获取列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("获取列表")]
|
||||
public async Task<AdminUiCallBack> GetPageList()
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
var pageCurrent = Request.Form["page"].FirstOrDefault().ObjectToInt(1);
|
||||
var pageSize = Request.Form["limit"].FirstOrDefault().ObjectToInt(30);
|
||||
var where = PredicateBuilder.True<WeChatTransactionComponentBrandAudit>();
|
||||
//获取排序字段
|
||||
var orderField = Request.Form["orderField"].FirstOrDefault();
|
||||
|
||||
Expression<Func<WeChatTransactionComponentBrandAudit, object>> orderEx = orderField switch
|
||||
{
|
||||
"id" => p => p.id,
|
||||
"license" => p => p.license,
|
||||
"brand_audit_type" => p => p.brand_audit_type,
|
||||
"trademark_type" => p => p.trademark_type,
|
||||
"brand_management_type" => p => p.brand_management_type,
|
||||
"commodity_origin_type" => p => p.commodity_origin_type,
|
||||
"brand_wording" => p => p.brand_wording,
|
||||
"sale_authorization" => p => p.sale_authorization,
|
||||
"trademark_registration_certificate" => p => p.trademark_registration_certificate,
|
||||
"trademark_change_certificate" => p => p.trademark_change_certificate,
|
||||
"trademark_registrant" => p => p.trademark_registrant,
|
||||
"trademark_registrant_nu" => p => p.trademark_registrant_nu,
|
||||
"trademark_authorization_period" => p => p.trademark_authorization_period,
|
||||
"trademark_registration_application" => p => p.trademark_registration_application,
|
||||
"trademark_applicant" => p => p.trademark_applicant,
|
||||
"trademark_application_time" => p => p.trademark_application_time,
|
||||
"imported_goods_form" => p => p.imported_goods_form,
|
||||
"scene_group_list" => p => p.scene_group_list,
|
||||
"audit_id" => p => p.audit_id,
|
||||
"status" => p => p.status,
|
||||
"brandId" => p => p.brandId,
|
||||
"rejectReason" => p => p.rejectReason,
|
||||
"createTime" => p => p.createTime,
|
||||
_ => p => p.id
|
||||
};
|
||||
|
||||
//设置排序方式
|
||||
var orderDirection = Request.Form["orderDirection"].FirstOrDefault();
|
||||
var orderBy = orderDirection switch
|
||||
{
|
||||
"asc" => OrderByType.Asc,
|
||||
"desc" => OrderByType.Desc,
|
||||
_ => OrderByType.Desc
|
||||
};
|
||||
//查询筛选
|
||||
|
||||
//序列 int
|
||||
var id = Request.Form["id"].FirstOrDefault().ObjectToInt(0);
|
||||
if (id > 0)
|
||||
{
|
||||
where = where.And(p => p.id == id);
|
||||
}
|
||||
//营业执照或组织机构代码证 nvarchar
|
||||
var license = Request.Form["license"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(license))
|
||||
{
|
||||
where = where.And(p => p.license.Contains(license));
|
||||
}
|
||||
//认证审核类型 int
|
||||
var brand_audit_type = Request.Form["brand_audit_type"].FirstOrDefault().ObjectToInt(0);
|
||||
if (brand_audit_type > 0)
|
||||
{
|
||||
where = where.And(p => p.brand_audit_type == brand_audit_type);
|
||||
}
|
||||
//商标分类 nvarchar
|
||||
var trademark_type = Request.Form["trademark_type"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(trademark_type))
|
||||
{
|
||||
where = where.And(p => p.trademark_type.Contains(trademark_type));
|
||||
}
|
||||
//经营类型 int
|
||||
var brand_management_type = Request.Form["brand_management_type"].FirstOrDefault().ObjectToInt(0);
|
||||
if (brand_management_type > 0)
|
||||
{
|
||||
where = where.And(p => p.brand_management_type == brand_management_type);
|
||||
}
|
||||
//商品产地是否进口 int
|
||||
var commodity_origin_type = Request.Form["commodity_origin_type"].FirstOrDefault().ObjectToInt(0);
|
||||
if (commodity_origin_type > 0)
|
||||
{
|
||||
where = where.And(p => p.commodity_origin_type == commodity_origin_type);
|
||||
}
|
||||
//商标/品牌词 nvarchar
|
||||
var brand_wording = Request.Form["brand_wording"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(brand_wording))
|
||||
{
|
||||
where = where.And(p => p.brand_wording.Contains(brand_wording));
|
||||
}
|
||||
//销售授权书 nvarchar
|
||||
var sale_authorization = Request.Form["sale_authorization"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(sale_authorization))
|
||||
{
|
||||
where = where.And(p => p.sale_authorization.Contains(sale_authorization));
|
||||
}
|
||||
//商标注册证书 nvarchar
|
||||
var trademark_registration_certificate = Request.Form["trademark_registration_certificate"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(trademark_registration_certificate))
|
||||
{
|
||||
where = where.And(p => p.trademark_registration_certificate.Contains(trademark_registration_certificate));
|
||||
}
|
||||
//商标变更证明 nvarchar
|
||||
var trademark_change_certificate = Request.Form["trademark_change_certificate"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(trademark_change_certificate))
|
||||
{
|
||||
where = where.And(p => p.trademark_change_certificate.Contains(trademark_change_certificate));
|
||||
}
|
||||
//商标注册人姓名 nvarchar
|
||||
var trademark_registrant = Request.Form["trademark_registrant"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(trademark_registrant))
|
||||
{
|
||||
where = where.And(p => p.trademark_registrant.Contains(trademark_registrant));
|
||||
}
|
||||
//商标注册号/申请号 nvarchar
|
||||
var trademark_registrant_nu = Request.Form["trademark_registrant_nu"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(trademark_registrant_nu))
|
||||
{
|
||||
where = where.And(p => p.trademark_registrant_nu.Contains(trademark_registrant_nu));
|
||||
}
|
||||
//商标有效期 datetime
|
||||
var trademark_authorization_period = Request.Form["trademark_authorization_period"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(trademark_authorization_period))
|
||||
{
|
||||
if (trademark_authorization_period.Contains("到"))
|
||||
{
|
||||
var dts = trademark_authorization_period.Split("到");
|
||||
var dtStart = dts[0].Trim().ObjectToDate();
|
||||
where = where.And(p => p.trademark_authorization_period > dtStart);
|
||||
var dtEnd = dts[1].Trim().ObjectToDate();
|
||||
where = where.And(p => p.trademark_authorization_period < dtEnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
var dt = trademark_authorization_period.ObjectToDate();
|
||||
where = where.And(p => p.trademark_authorization_period > dt);
|
||||
}
|
||||
}
|
||||
//商标注册申请受理通知书 nvarchar
|
||||
var trademark_registration_application = Request.Form["trademark_registration_application"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(trademark_registration_application))
|
||||
{
|
||||
where = where.And(p => p.trademark_registration_application.Contains(trademark_registration_application));
|
||||
}
|
||||
//商标申请人姓名 nvarchar
|
||||
var trademark_applicant = Request.Form["trademark_applicant"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(trademark_applicant))
|
||||
{
|
||||
where = where.And(p => p.trademark_applicant.Contains(trademark_applicant));
|
||||
}
|
||||
//商标申请时间 datetime
|
||||
var trademark_application_time = Request.Form["trademark_application_time"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(trademark_application_time))
|
||||
{
|
||||
if (trademark_application_time.Contains("到"))
|
||||
{
|
||||
var dts = trademark_application_time.Split("到");
|
||||
var dtStart = dts[0].Trim().ObjectToDate();
|
||||
where = where.And(p => p.trademark_application_time > dtStart);
|
||||
var dtEnd = dts[1].Trim().ObjectToDate();
|
||||
where = where.And(p => p.trademark_application_time < dtEnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
var dt = trademark_application_time.ObjectToDate();
|
||||
where = where.And(p => p.trademark_application_time > dt);
|
||||
}
|
||||
}
|
||||
//中华人民共和国海关进口货物报关单 nvarchar
|
||||
var imported_goods_form = Request.Form["imported_goods_form"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(imported_goods_form))
|
||||
{
|
||||
where = where.And(p => p.imported_goods_form.Contains(imported_goods_form));
|
||||
}
|
||||
//商品使用场景 int
|
||||
var scene_group_list = Request.Form["scene_group_list"].FirstOrDefault().ObjectToInt(0);
|
||||
if (scene_group_list > 0)
|
||||
{
|
||||
where = where.And(p => p.scene_group_list == scene_group_list);
|
||||
}
|
||||
//审核单id nvarchar
|
||||
var audit_id = Request.Form["audit_id"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(audit_id))
|
||||
{
|
||||
where = where.And(p => p.audit_id.Contains(audit_id));
|
||||
}
|
||||
//审核状态 int
|
||||
var status = Request.Form["status"].FirstOrDefault().ObjectToInt(0);
|
||||
if (status > 0)
|
||||
{
|
||||
where = where.And(p => p.status == status);
|
||||
}
|
||||
//品牌id int
|
||||
var brandId = Request.Form["brandId"].FirstOrDefault().ObjectToInt(0);
|
||||
if (brandId > 0)
|
||||
{
|
||||
where = where.And(p => p.brandId == brandId);
|
||||
}
|
||||
//拒绝原因 nvarchar
|
||||
var rejectReason = Request.Form["rejectReason"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(rejectReason))
|
||||
{
|
||||
where = where.And(p => p.rejectReason.Contains(rejectReason));
|
||||
}
|
||||
//创建时间 datetime
|
||||
var createTime = Request.Form["createTime"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(createTime))
|
||||
{
|
||||
if (createTime.Contains("到"))
|
||||
{
|
||||
var dts = createTime.Split("到");
|
||||
var dtStart = dts[0].Trim().ObjectToDate();
|
||||
where = where.And(p => p.createTime > dtStart);
|
||||
var dtEnd = dts[1].Trim().ObjectToDate();
|
||||
where = where.And(p => p.createTime < dtEnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
var dt = createTime.ObjectToDate();
|
||||
where = where.And(p => p.createTime > dt);
|
||||
}
|
||||
}
|
||||
//获取数据
|
||||
var list = await _weChatTransactionComponentBrandAuditServices.QueryPageAsync(where, orderEx, orderBy, pageCurrent, pageSize, true);
|
||||
//返回数据
|
||||
jm.data = list;
|
||||
jm.code = 0;
|
||||
jm.count = list.TotalCount;
|
||||
jm.msg = "数据调用成功!";
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 首页数据============================================================
|
||||
// POST: Api/WeChatTransactionComponentBrandAudit/GetIndex
|
||||
/// <summary>
|
||||
/// 首页数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("首页数据")]
|
||||
public AdminUiCallBack GetIndex()
|
||||
{
|
||||
//返回数据
|
||||
var jm = new AdminUiCallBack { code = 0 };
|
||||
|
||||
//认证审核类型
|
||||
var registerType = EnumHelper.EnumToList<GlobalEnumVars.RegisterType>();
|
||||
//商标分类
|
||||
var trademarkType = EnumHelper.EnumToList<GlobalEnumVars.TrademarkType>();
|
||||
//品牌经营类型
|
||||
var brandManagementType = EnumHelper.EnumToList<GlobalEnumVars.BrandManagementType>();
|
||||
//商品产地是否进口
|
||||
var commodityOriginType = EnumHelper.EnumToList<GlobalEnumVars.CommodityOriginType>();
|
||||
|
||||
var auditCategoryStatus = EnumHelper.EnumToList<AuditEnum.AuditCategoryStatus>();
|
||||
|
||||
|
||||
jm.data = new
|
||||
{
|
||||
registerType,
|
||||
trademarkType,
|
||||
brandManagementType,
|
||||
commodityOriginType,
|
||||
auditCategoryStatus
|
||||
};
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 创建数据============================================================
|
||||
// POST: Api/WeChatTransactionComponentBrandAudit/GetCreate
|
||||
/// <summary>
|
||||
/// 创建数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("创建数据")]
|
||||
public AdminUiCallBack GetCreate()
|
||||
{
|
||||
//返回数据
|
||||
var jm = new AdminUiCallBack { code = 0 };
|
||||
|
||||
//认证审核类型
|
||||
var registerType = EnumHelper.EnumToList<GlobalEnumVars.RegisterType>();
|
||||
//商标分类
|
||||
var trademarkType = EnumHelper.EnumToList<GlobalEnumVars.TrademarkType>();
|
||||
//品牌经营类型
|
||||
var brandManagementType = EnumHelper.EnumToList<GlobalEnumVars.BrandManagementType>();
|
||||
//商品产地是否进口
|
||||
var commodityOriginType = EnumHelper.EnumToList<GlobalEnumVars.CommodityOriginType>();
|
||||
|
||||
jm.data = new
|
||||
{
|
||||
registerType,
|
||||
trademarkType,
|
||||
brandManagementType,
|
||||
commodityOriginType,
|
||||
};
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 创建提交============================================================
|
||||
// POST: Api/WeChatTransactionComponentBrandAudit/DoCreate
|
||||
/// <summary>
|
||||
/// 创建提交
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("创建提交")]
|
||||
public async Task<AdminUiCallBack> DoCreate([FromBody] WeChatTransactionComponentBrandAudit entity)
|
||||
{
|
||||
var jm = await _weChatTransactionComponentBrandAuditServices.InsertAsync(entity);
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 编辑数据============================================================
|
||||
// POST: Api/WeChatTransactionComponentBrandAudit/GetEdit
|
||||
/// <summary>
|
||||
/// 编辑数据
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("编辑数据")]
|
||||
public async Task<AdminUiCallBack> GetEdit([FromBody] FMIntId entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var model = await _weChatTransactionComponentBrandAuditServices.QueryByIdAsync(entity.id, false);
|
||||
if (model == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
jm.code = 0;
|
||||
|
||||
//认证审核类型
|
||||
var registerType = EnumHelper.EnumToList<GlobalEnumVars.RegisterType>();
|
||||
//商标分类
|
||||
var trademarkType = EnumHelper.EnumToList<GlobalEnumVars.TrademarkType>();
|
||||
//品牌经营类型
|
||||
var brandManagementType = EnumHelper.EnumToList<GlobalEnumVars.BrandManagementType>();
|
||||
//商品产地是否进口
|
||||
var commodityOriginType = EnumHelper.EnumToList<GlobalEnumVars.CommodityOriginType>();
|
||||
|
||||
jm.data = new
|
||||
{
|
||||
model,
|
||||
registerType,
|
||||
trademarkType,
|
||||
brandManagementType,
|
||||
commodityOriginType,
|
||||
};
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 编辑提交============================================================
|
||||
// POST: Api/WeChatTransactionComponentBrandAudit/Edit
|
||||
/// <summary>
|
||||
/// 编辑提交
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("编辑提交")]
|
||||
public async Task<AdminUiCallBack> DoEdit([FromBody] WeChatTransactionComponentBrandAudit entity)
|
||||
{
|
||||
var jm = await _weChatTransactionComponentBrandAuditServices.UpdateAsync(entity);
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 删除数据============================================================
|
||||
// POST: Api/WeChatTransactionComponentBrandAudit/DoDelete/10
|
||||
/// <summary>
|
||||
/// 单选删除
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("单选删除")]
|
||||
public async Task<AdminUiCallBack> DoDelete([FromBody] FMIntId entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var model = await _weChatTransactionComponentBrandAuditServices.ExistsAsync(p => p.id == entity.id, true);
|
||||
if (!model)
|
||||
{
|
||||
jm.msg = GlobalConstVars.DataisNo;
|
||||
return jm;
|
||||
}
|
||||
jm = await _weChatTransactionComponentBrandAuditServices.DeleteByIdAsync(entity.id);
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 预览数据============================================================
|
||||
// POST: Api/WeChatTransactionComponentBrandAudit/GetDetails/10
|
||||
/// <summary>
|
||||
/// 预览数据
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("预览数据")]
|
||||
public async Task<AdminUiCallBack> GetDetails([FromBody] FMIntId entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var model = await _weChatTransactionComponentBrandAuditServices.QueryByIdAsync(entity.id, false);
|
||||
if (model == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
jm.code = 0;
|
||||
jm.data = model;
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 提交审核============================================================
|
||||
// POST: Api/WeChatTransactionComponentBrandAudit/DoAudit/10
|
||||
/// <summary>
|
||||
/// 提交审核
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("提交审核")]
|
||||
public async Task<AdminUiCallBack> DoAudit([FromBody] FMIntId entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var model = await _weChatTransactionComponentBrandAuditServices.QueryByIdAsync(entity.id, false);
|
||||
if (model == null)
|
||||
{
|
||||
jm.msg = GlobalConstVars.DataisNo;
|
||||
return jm;
|
||||
}
|
||||
|
||||
//获取小程序认证
|
||||
var accessToken = WeChatCacheAccessTokenHelper.GetWxOpenAccessToken();
|
||||
var client = _weChatApiHttpClientFactory.CreateWxOpenClient();
|
||||
var request = new ShopAuditAuditBrandRequest();
|
||||
|
||||
request.AccessToken = accessToken;
|
||||
|
||||
request.Audit.LicenseUrl = model.license;
|
||||
request.Audit.Brand.BrandAuditType = model.brand_audit_type;
|
||||
request.Audit.Brand.TrademarkType = model.trademark_type;
|
||||
request.Audit.Brand.BrandManagementType = model.brand_management_type;
|
||||
request.Audit.Brand.CommodityOriginType = model.commodity_origin_type;
|
||||
request.Audit.Brand.BrandWording = model.brand_wording;
|
||||
|
||||
request.Audit.Brand.SaleAuthorizationUrlList = !string.IsNullOrEmpty(model.sale_authorization)
|
||||
? new List<string>(model.sale_authorization.Split(",")) : new List<string>();
|
||||
|
||||
request.Audit.Brand.TrademarkRegistrationCertificateUrlList = !string.IsNullOrEmpty(model.trademark_registration_certificate)
|
||||
? new List<string>(model.trademark_registration_certificate.Split(",")) : new List<string>();
|
||||
|
||||
request.Audit.Brand.TrademarkChangeCertificateUrlList = !string.IsNullOrEmpty(model.trademark_change_certificate)
|
||||
? new List<string>(model.trademark_change_certificate.Split(",")) : new List<string>();
|
||||
|
||||
request.Audit.Brand.TrademarkRegistrant = model.trademark_registrant;
|
||||
request.Audit.Brand.TrademarkRegistrantNumber = model.trademark_registrant_nu;
|
||||
|
||||
request.Audit.Brand.TrademarkAuthorizationTime = model.trademark_authorization_period;
|
||||
|
||||
request.Audit.Brand.TrademarkRegistrationApplicationUrlList = !string.IsNullOrEmpty(model.trademark_registration_application)
|
||||
? new List<string>(model.trademark_registration_application.Split(",")) : new List<string>();
|
||||
|
||||
|
||||
request.Audit.Brand.TrademarkApplicant = model.trademark_applicant;
|
||||
request.Audit.Brand.TrademarkAuthorizationTime = model.trademark_application_time;
|
||||
|
||||
request.Audit.Brand.ImportedGoodsFormUrlList = !string.IsNullOrEmpty(model.imported_goods_form)
|
||||
? new List<string>(model.imported_goods_form.Split(",")) : new List<string>();
|
||||
|
||||
var response = await client.ExecuteShopAuditAuditBrandAsync(request);
|
||||
|
||||
if (response.IsSuccessful())
|
||||
{
|
||||
var bl = await _weChatTransactionComponentBrandAuditServices.UpdateAsync(
|
||||
p => new WeChatTransactionComponentBrandAudit() { audit_id = response.AuditId },
|
||||
p => p.id == model.id);
|
||||
|
||||
jm.code = 0;
|
||||
jm.msg = "提交审核成功";
|
||||
}
|
||||
else
|
||||
{
|
||||
jm.code = 1;
|
||||
jm.data = response.ErrorCode;
|
||||
jm.msg = response.ErrorMessage;
|
||||
jm.otherData = accessToken;
|
||||
}
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,194 +0,0 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/7/11 23:48:58
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using CoreCms.Net.Caching.AccressToken;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.Entities.Expression;
|
||||
using CoreCms.Net.Filter;
|
||||
using CoreCms.Net.IServices;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using CoreCms.Net.Utility.Extensions;
|
||||
using CoreCms.Net.WeChat.Service.HttpClients;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SKIT.FlurlHttpClient.Wechat.Api;
|
||||
using SKIT.FlurlHttpClient.Wechat.Api.Models;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Web.Admin.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 自定义交易组件快递公司
|
||||
///</summary>
|
||||
[Description("自定义交易组件快递公司")]
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
[RequiredErrorForAdmin]
|
||||
[Authorize(Permissions.Name)]
|
||||
public class WeChatTransactionComponentDeliveryCompanyController : ControllerBase
|
||||
{
|
||||
private readonly IWebHostEnvironment _webHostEnvironment;
|
||||
private readonly IWeChatTransactionComponentDeliveryCompanyServices _weChatTransactionComponentDeliveryCompanyServices;
|
||||
private readonly CoreCms.Net.WeChat.Service.HttpClients.IWeChatApiHttpClientFactory _weChatApiHttpClientFactory;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
///</summary>
|
||||
public WeChatTransactionComponentDeliveryCompanyController(IWebHostEnvironment webHostEnvironment
|
||||
, IWeChatTransactionComponentDeliveryCompanyServices weChatTransactionComponentDeliveryCompanyServices, IWeChatApiHttpClientFactory weChatApiHttpClientFactory)
|
||||
{
|
||||
_webHostEnvironment = webHostEnvironment;
|
||||
_weChatTransactionComponentDeliveryCompanyServices = weChatTransactionComponentDeliveryCompanyServices;
|
||||
_weChatApiHttpClientFactory = weChatApiHttpClientFactory;
|
||||
}
|
||||
|
||||
#region 获取列表============================================================
|
||||
// POST: Api/WeChatTransactionComponentDeliveryCompany/GetPageList
|
||||
/// <summary>
|
||||
/// 获取列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("获取列表")]
|
||||
public async Task<AdminUiCallBack> GetPageList()
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
var pageCurrent = Request.Form["page"].FirstOrDefault().ObjectToInt(1);
|
||||
var pageSize = Request.Form["limit"].FirstOrDefault().ObjectToInt(30);
|
||||
var where = PredicateBuilder.True<WeChatTransactionComponentDeliveryCompany>();
|
||||
//获取排序字段
|
||||
var orderField = Request.Form["orderField"].FirstOrDefault();
|
||||
|
||||
Expression<Func<WeChatTransactionComponentDeliveryCompany, object>> orderEx = orderField switch
|
||||
{
|
||||
"deliveryId" => p => p.deliveryId,
|
||||
"deliveryName" => p => p.deliveryName,
|
||||
_ => p => p.deliveryId
|
||||
};
|
||||
|
||||
//设置排序方式
|
||||
var orderDirection = Request.Form["orderDirection"].FirstOrDefault();
|
||||
var orderBy = orderDirection switch
|
||||
{
|
||||
"asc" => OrderByType.Asc,
|
||||
"desc" => OrderByType.Desc,
|
||||
_ => OrderByType.Desc
|
||||
};
|
||||
//查询筛选
|
||||
|
||||
//快递公司id nvarchar
|
||||
var deliveryId = Request.Form["deliveryId"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(deliveryId))
|
||||
{
|
||||
where = where.And(p => p.deliveryId.Contains(deliveryId));
|
||||
}
|
||||
//快递公司名称 nvarchar
|
||||
var deliveryName = Request.Form["deliveryName"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(deliveryName))
|
||||
{
|
||||
where = where.And(p => p.deliveryName.Contains(deliveryName));
|
||||
}
|
||||
//获取数据
|
||||
var list = await _weChatTransactionComponentDeliveryCompanyServices.QueryPageAsync(where, orderEx, orderBy, pageCurrent, pageSize, true);
|
||||
//返回数据
|
||||
jm.data = list;
|
||||
jm.code = 0;
|
||||
jm.count = list.TotalCount;
|
||||
jm.msg = "数据调用成功!";
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 首页数据============================================================
|
||||
// POST: Api/WeChatTransactionComponentDeliveryCompany/GetIndex
|
||||
/// <summary>
|
||||
/// 首页数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("首页数据")]
|
||||
public AdminUiCallBack GetIndex()
|
||||
{
|
||||
//返回数据
|
||||
var jm = new AdminUiCallBack { code = 0 };
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 获取快递公司列表============================================================
|
||||
// POST: Api/WeChatTransactionComponentDeliveryCompany/DoGetCompanyList/10
|
||||
/// <summary>
|
||||
/// 获取快递公司列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("获取快递公司列表")]
|
||||
public async Task<AdminUiCallBack> DoGetCompanyList()
|
||||
{
|
||||
var jm = new AdminUiCallBack { code = 0 };
|
||||
var bl = false;
|
||||
try
|
||||
{
|
||||
//获取小程序认证
|
||||
var accessToken = WeChatCacheAccessTokenHelper.GetWxOpenAccessToken();
|
||||
var client = _weChatApiHttpClientFactory.CreateWxOpenClient();
|
||||
var request = new ShopDeliveryGetCompanyListRequest();
|
||||
request.AccessToken = accessToken;
|
||||
|
||||
var response = await client.ExecuteShopDeliveryGetCompanyListAsync(request);
|
||||
if (response.IsSuccessful())
|
||||
{
|
||||
var company = new List<WeChatTransactionComponentDeliveryCompany>();
|
||||
|
||||
foreach (var item in response.DeliveryCompanyList)
|
||||
{
|
||||
company.Add(new WeChatTransactionComponentDeliveryCompany()
|
||||
{
|
||||
deliveryId = item.DeliveryId,
|
||||
deliveryName = item.DeliveryName
|
||||
});
|
||||
}
|
||||
|
||||
await _weChatTransactionComponentDeliveryCompanyServices.DeleteAsync(p => p.deliveryId != "");
|
||||
bl = await _weChatTransactionComponentDeliveryCompanyServices.InsertAsync(company) > 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
jm.msg = response.ErrorMessage;
|
||||
}
|
||||
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? "更新成功" : "更新失败";
|
||||
jm.otherData = response;
|
||||
return jm;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
jm.code = 1;
|
||||
jm.msg = e.ToString();
|
||||
return jm;
|
||||
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,930 +0,0 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/7/4 2:52:27
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using CoreCms.Net.Caching.AccressToken;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.Entities.Expression;
|
||||
using CoreCms.Net.Model.FromBody;
|
||||
using CoreCms.Net.Filter;
|
||||
using CoreCms.Net.IServices;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using CoreCms.Net.Utility.Helper;
|
||||
using CoreCms.Net.Utility.Extensions;
|
||||
using CoreCms.Net.WeChat.Service.HttpClients;
|
||||
using CoreCms.Net.WeChat.Service.TransactionComponent.Enum;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SKIT.FlurlHttpClient.Wechat.Api;
|
||||
using SKIT.FlurlHttpClient.Wechat.Api.Models;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Web.Admin.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 自定义交易组件商品列表
|
||||
///</summary>
|
||||
[Description("自定义交易组件商品列表")]
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
[RequiredErrorForAdmin]
|
||||
[Authorize(Permissions.Name)]
|
||||
public class WeChatTransactionComponentGoodController : ControllerBase
|
||||
{
|
||||
private readonly IWebHostEnvironment _webHostEnvironment;
|
||||
private readonly IWeChatTransactionComponentGoodServices _weChatTransactionComponentGoodsServices;
|
||||
private readonly IWeChatTransactionComponentGoodSKUServices _weChatTransactionComponentGoodSkuServices;
|
||||
|
||||
private readonly IWeChatTransactionComponentAuditCategoryServices
|
||||
_weChatTransactionComponentAuditCategoryServices;
|
||||
private readonly ICoreCmsProductsServices _productsServices;
|
||||
private readonly CoreCms.Net.WeChat.Service.HttpClients.IWeChatApiHttpClientFactory _weChatApiHttpClientFactory;
|
||||
|
||||
private readonly IWeChatTransactionComponentBrandAuditServices _weChatTransactionComponentBrandAuditServices;
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
///</summary>
|
||||
public WeChatTransactionComponentGoodController(IWebHostEnvironment webHostEnvironment
|
||||
, IWeChatTransactionComponentGoodServices weChatTransactionComponentGoodsServices, IWeChatTransactionComponentGoodSKUServices weChatTransactionComponentGoodSkuServices, ICoreCmsProductsServices productsServices, IWeChatApiHttpClientFactory weChatApiHttpClientFactory, IWeChatTransactionComponentAuditCategoryServices weChatTransactionComponentAuditCategoryServices, IWeChatTransactionComponentBrandAuditServices weChatTransactionComponentBrandAuditServices)
|
||||
{
|
||||
_webHostEnvironment = webHostEnvironment;
|
||||
_weChatTransactionComponentGoodsServices = weChatTransactionComponentGoodsServices;
|
||||
_weChatTransactionComponentGoodSkuServices = weChatTransactionComponentGoodSkuServices;
|
||||
_productsServices = productsServices;
|
||||
_weChatApiHttpClientFactory = weChatApiHttpClientFactory;
|
||||
_weChatTransactionComponentAuditCategoryServices = weChatTransactionComponentAuditCategoryServices;
|
||||
_weChatTransactionComponentBrandAuditServices = weChatTransactionComponentBrandAuditServices;
|
||||
}
|
||||
|
||||
#region 获取列表============================================================
|
||||
// POST: Api/WeChatTransactionComponentGood/GetPageList
|
||||
/// <summary>
|
||||
/// 获取列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("获取列表")]
|
||||
public async Task<AdminUiCallBack> GetPageList()
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
var pageCurrent = Request.Form["page"].FirstOrDefault().ObjectToInt(1);
|
||||
var pageSize = Request.Form["limit"].FirstOrDefault().ObjectToInt(30);
|
||||
var where = PredicateBuilder.True<WeChatTransactionComponentGood>();
|
||||
//获取排序字段
|
||||
var orderField = Request.Form["orderField"].FirstOrDefault();
|
||||
|
||||
Expression<Func<WeChatTransactionComponentGood, object>> orderEx = orderField switch
|
||||
{
|
||||
"id" => p => p.id,
|
||||
"productId" => p => p.productId,
|
||||
"createTime" => p => p.createTime,
|
||||
"outProductId" => p => p.outProductId,
|
||||
"title" => p => p.title,
|
||||
"path" => p => p.path,
|
||||
"headImg" => p => p.headImg,
|
||||
"qualificationPics" => p => p.qualificationPics,
|
||||
"descInfoDesc" => p => p.descInfoDesc,
|
||||
"descInfoImgs" => p => p.descInfoImgs,
|
||||
"thirdCatId" => p => p.thirdCatId,
|
||||
"brandId" => p => p.brandId,
|
||||
"infoVersion" => p => p.infoVersion,
|
||||
"lastPostTime" => p => p.lastPostTime,
|
||||
"updateTime" => p => p.updateTime,
|
||||
_ => p => p.id
|
||||
};
|
||||
|
||||
//设置排序方式
|
||||
var orderDirection = Request.Form["orderDirection"].FirstOrDefault();
|
||||
var orderBy = orderDirection switch
|
||||
{
|
||||
"asc" => OrderByType.Asc,
|
||||
"desc" => OrderByType.Desc,
|
||||
_ => OrderByType.Desc
|
||||
};
|
||||
//查询筛选
|
||||
|
||||
//序列 int
|
||||
var id = Request.Form["id"].FirstOrDefault().ObjectToInt(0);
|
||||
if (id > 0)
|
||||
{
|
||||
where = where.And(p => p.id == id);
|
||||
}
|
||||
//交易组件平台内部商品ID bigint
|
||||
var productId = Request.Form["productId"].FirstOrDefault().ObjectToInt(0);
|
||||
if (productId > 0)
|
||||
{
|
||||
where = where.And(p => p.productId == productId);
|
||||
}
|
||||
//交易组件创建时间 datetime
|
||||
var createTime = Request.Form["createTime"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(createTime))
|
||||
{
|
||||
if (createTime.Contains("到"))
|
||||
{
|
||||
var dts = createTime.Split("到");
|
||||
var dtStart = dts[0].Trim().ObjectToDate();
|
||||
where = where.And(p => p.createTime > dtStart);
|
||||
var dtEnd = dts[1].Trim().ObjectToDate();
|
||||
where = where.And(p => p.createTime < dtEnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
var dt = createTime.ObjectToDate();
|
||||
where = where.And(p => p.createTime > dt);
|
||||
}
|
||||
}
|
||||
//商品序列 nvarchar
|
||||
var outProductId = Request.Form["outProductId"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(outProductId))
|
||||
{
|
||||
where = where.And(p => p.outProductId.Contains(outProductId));
|
||||
}
|
||||
//商品标题 nvarchar
|
||||
var title = Request.Form["title"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(title))
|
||||
{
|
||||
where = where.And(p => p.title.Contains(title));
|
||||
}
|
||||
//小程序路径 nvarchar
|
||||
var path = Request.Form["path"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(path))
|
||||
{
|
||||
where = where.And(p => p.path.Contains(path));
|
||||
}
|
||||
//主图列表 nvarchar
|
||||
var headImg = Request.Form["headImg"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(headImg))
|
||||
{
|
||||
where = where.And(p => p.headImg.Contains(headImg));
|
||||
}
|
||||
//商品资质图片列表 nvarchar
|
||||
var qualificationPics = Request.Form["qualificationPics"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(qualificationPics))
|
||||
{
|
||||
where = where.And(p => p.qualificationPics.Contains(qualificationPics));
|
||||
}
|
||||
//商品详情图文 nvarchar
|
||||
var descInfoDesc = Request.Form["descInfoDesc"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(descInfoDesc))
|
||||
{
|
||||
where = where.And(p => p.descInfoDesc.Contains(descInfoDesc));
|
||||
}
|
||||
//商品详情图片列表 nvarchar
|
||||
var descInfoImgs = Request.Form["descInfoImgs"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(descInfoImgs))
|
||||
{
|
||||
where = where.And(p => p.descInfoImgs.Contains(descInfoImgs));
|
||||
}
|
||||
//第三级类目ID int
|
||||
var thirdCatId = Request.Form["thirdCatId"].FirstOrDefault().ObjectToInt(0);
|
||||
if (thirdCatId > 0)
|
||||
{
|
||||
where = where.And(p => p.thirdCatId == thirdCatId);
|
||||
}
|
||||
//品牌id int
|
||||
var brandId = Request.Form["brandId"].FirstOrDefault().ObjectToInt(0);
|
||||
if (brandId > 0)
|
||||
{
|
||||
where = where.And(p => p.brandId == brandId);
|
||||
}
|
||||
//预留字段 nvarchar
|
||||
var infoVersion = Request.Form["infoVersion"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(infoVersion))
|
||||
{
|
||||
where = where.And(p => p.infoVersion.Contains(infoVersion));
|
||||
}
|
||||
//最后提交时间 datetime
|
||||
var lastPostTime = Request.Form["lastPostTime"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(lastPostTime))
|
||||
{
|
||||
if (lastPostTime.Contains("到"))
|
||||
{
|
||||
var dts = lastPostTime.Split("到");
|
||||
var dtStart = dts[0].Trim().ObjectToDate();
|
||||
where = where.And(p => p.lastPostTime > dtStart);
|
||||
var dtEnd = dts[1].Trim().ObjectToDate();
|
||||
where = where.And(p => p.lastPostTime < dtEnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
var dt = lastPostTime.ObjectToDate();
|
||||
where = where.And(p => p.lastPostTime > dt);
|
||||
}
|
||||
}
|
||||
//最后更新时间 datetime
|
||||
var updateTime = Request.Form["updateTime"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(updateTime))
|
||||
{
|
||||
if (updateTime.Contains("到"))
|
||||
{
|
||||
var dts = updateTime.Split("到");
|
||||
var dtStart = dts[0].Trim().ObjectToDate();
|
||||
where = where.And(p => p.updateTime > dtStart);
|
||||
var dtEnd = dts[1].Trim().ObjectToDate();
|
||||
where = where.And(p => p.updateTime < dtEnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
var dt = updateTime.ObjectToDate();
|
||||
where = where.And(p => p.updateTime > dt);
|
||||
}
|
||||
}
|
||||
//获取数据
|
||||
var list = await _weChatTransactionComponentGoodsServices.QueryPageAsync(where, orderEx, orderBy, pageCurrent, pageSize, true);
|
||||
//返回数据
|
||||
jm.data = list;
|
||||
jm.code = 0;
|
||||
jm.count = list.TotalCount;
|
||||
jm.msg = "数据调用成功!";
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 首页数据============================================================
|
||||
// POST: Api/WeChatTransactionComponentGood/GetIndex
|
||||
/// <summary>
|
||||
/// 首页数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("首页数据")]
|
||||
public AdminUiCallBack GetIndex()
|
||||
{
|
||||
//返回数据
|
||||
var jm = new AdminUiCallBack { code = 0 };
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 创建数据============================================================
|
||||
// POST: Api/WeChatTransactionComponentGood/GetCreate
|
||||
/// <summary>
|
||||
/// 创建数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("创建数据")]
|
||||
public async Task<AdminUiCallBack> GetCreate()
|
||||
{
|
||||
//返回数据
|
||||
var jm = new AdminUiCallBack { code = 0 };
|
||||
|
||||
var brand = await _weChatTransactionComponentBrandAuditServices.QueryListByClauseAsync(p => p.brandId > 0 && p.status == (int)AuditEnum.AuditCategoryStatus.审核成功);
|
||||
|
||||
jm.data = new
|
||||
{
|
||||
brand
|
||||
};
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 创建提交============================================================
|
||||
// POST: Api/WeChatTransactionComponentGood/DoCreate
|
||||
/// <summary>
|
||||
/// 创建提交
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("创建提交")]
|
||||
public async Task<AdminUiCallBack> DoCreate([FromBody] WeChatTransactionComponentGood entity)
|
||||
{
|
||||
var jm = await _weChatTransactionComponentGoodsServices.InsertAsync(entity);
|
||||
jm.otherData = entity;
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 编辑数据============================================================
|
||||
// POST: Api/WeChatTransactionComponentGood/GetEdit
|
||||
/// <summary>
|
||||
/// 编辑数据
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("编辑数据")]
|
||||
public async Task<AdminUiCallBack> GetEdit([FromBody] FMIntId entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var model = await _weChatTransactionComponentGoodsServices.QueryByIdAsync(entity.id, false);
|
||||
if (model == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
|
||||
var goodId = Convert.ToInt32(model.outProductId);
|
||||
var products = await _productsServices.QueryListByClauseAsync(p => p.goodsId == goodId && p.isDel == false, p => p.id, OrderByType.Asc, true);
|
||||
var sku = await _weChatTransactionComponentGoodSkuServices.QueryListByClauseAsync(p => p.outProductId == model.outProductId, p => p.id, OrderByType.Asc, true);
|
||||
|
||||
var brand = await _weChatTransactionComponentBrandAuditServices.QueryListByClauseAsync(p => p.brandId > 0 && p.status == (int)AuditEnum.AuditCategoryStatus.审核成功);
|
||||
|
||||
jm.code = 0;
|
||||
jm.data = new
|
||||
{
|
||||
model,
|
||||
products,
|
||||
sku,
|
||||
brand
|
||||
};
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 编辑提交============================================================
|
||||
// POST: Api/WeChatTransactionComponentGood/Edit
|
||||
/// <summary>
|
||||
/// 编辑提交
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("编辑提交")]
|
||||
public async Task<AdminUiCallBack> DoEdit([FromBody] WeChatTransactionComponentGood entity)
|
||||
{
|
||||
var jm = await _weChatTransactionComponentGoodsServices.UpdateAsync(entity);
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 删除数据============================================================
|
||||
// POST: Api/WeChatTransactionComponentGood/DoDelete/10
|
||||
/// <summary>
|
||||
/// 单选删除
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("单选删除")]
|
||||
public async Task<AdminUiCallBack> DoDelete([FromBody] FMIntId entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var model = await _weChatTransactionComponentGoodsServices.ExistsAsync(p => p.id == entity.id, true);
|
||||
if (!model)
|
||||
{
|
||||
jm.msg = GlobalConstVars.DataisNo;
|
||||
return jm;
|
||||
}
|
||||
jm = await _weChatTransactionComponentGoodsServices.DeleteByIdAsync(entity.id);
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 提交审核============================================================
|
||||
// POST: Api/WeChatTransactionComponentGood/DoAudit/10
|
||||
/// <summary>
|
||||
/// 提交审核
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("提交审核")]
|
||||
public async Task<AdminUiCallBack> DoAudit([FromBody] FMIntId entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var model = await _weChatTransactionComponentGoodsServices.QueryByClauseAsync(p => p.id == entity.id, true);
|
||||
if (model == null)
|
||||
{
|
||||
jm.msg = GlobalConstVars.DataisNo;
|
||||
return jm;
|
||||
}
|
||||
|
||||
var sku = await _weChatTransactionComponentGoodSkuServices.QueryListByClauseAsync(p => p.isSelect == true && p.outProductId == model.outProductId);
|
||||
|
||||
|
||||
//获取小程序认证
|
||||
var accessToken = WeChatCacheAccessTokenHelper.GetWxOpenAccessToken();
|
||||
var client = _weChatApiHttpClientFactory.CreateWxOpenClient();
|
||||
var request = new ShopSPUAddRequest();
|
||||
|
||||
request.AccessToken = accessToken;
|
||||
|
||||
request.OutProductId = model.outProductId;
|
||||
request.Title = model.title;
|
||||
request.PagePath = model.path;
|
||||
request.HeadImageUrlList = new List<string>(model.headImg.Split(","));
|
||||
|
||||
var category = await _weChatTransactionComponentAuditCategoryServices.QueryByClauseAsync(p => p.level3 == model.thirdCatId, true);
|
||||
if (category != null && !string.IsNullOrEmpty(category.certificateImage))
|
||||
{
|
||||
request.QualificationPictureUrlList = new List<string>(category.certificateImage.Split(","));
|
||||
}
|
||||
else
|
||||
{
|
||||
request.QualificationPictureUrlList = new List<string>();
|
||||
}
|
||||
|
||||
|
||||
request.Detail = new ShopSPUAddRequest.Types.Detail();
|
||||
|
||||
request.Detail.Description = model.descInfoDesc;
|
||||
request.Detail.ImageUrlList = new List<string>();
|
||||
|
||||
request.CategoryId = model.thirdCatId;
|
||||
request.BrandId = model.brandId;
|
||||
request.InfoVersion = model.infoVersion;
|
||||
|
||||
request.SKUList = new List<ShopSPUAddRequest.Types.SKU>();
|
||||
sku.ForEach(p =>
|
||||
{
|
||||
var item = new ShopSPUAddRequest.Types.SKU();
|
||||
item.OutProductId = p.outProductId;
|
||||
item.OutSKUId = p.outSkuId;
|
||||
item.ThumbnailUrl = p.thumbImg;
|
||||
item.SalePrice = Convert.ToInt32(p.salePrice * 100);
|
||||
item.MarketPrice = Convert.ToInt32(p.marketPrice * 100);
|
||||
item.Stock = p.stockNum;
|
||||
item.BarCode = p.barCode;
|
||||
item.SKUCode = p.skuCode;
|
||||
|
||||
request.SKUList.Add(item);
|
||||
});
|
||||
|
||||
var response = await client.ExecuteShopSPUAddAsync(request);
|
||||
|
||||
if (response.IsSuccessful())
|
||||
{
|
||||
var createTime = new DateTime(response.Data.CreateTime.Year, response.Data.CreateTime.Month,
|
||||
response.Data.CreateTime.Day, response.Data.CreateTime.Hour, response.Data.CreateTime.Minute,
|
||||
response.Data.CreateTime.Second);
|
||||
|
||||
model.productId = response.Data.ProductId;
|
||||
model.createTime = createTime;
|
||||
model.lastPostTime = createTime;
|
||||
|
||||
await _weChatTransactionComponentGoodsServices.UpdateAsync(model);
|
||||
|
||||
if (response.Data.SKUList.Length > 0)
|
||||
{
|
||||
foreach (var item in response.Data.SKUList)
|
||||
{
|
||||
foreach (var o in sku)
|
||||
{
|
||||
if (o.outSkuId == item.OutSKUId)
|
||||
{
|
||||
o.skuId = item.SKUId;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await _weChatTransactionComponentGoodSkuServices.UpdateAsync(sku);
|
||||
}
|
||||
|
||||
jm.code = 0;
|
||||
jm.msg = "提交成功";
|
||||
}
|
||||
else
|
||||
{
|
||||
jm.code = 1;
|
||||
jm.data = response.ErrorCode;
|
||||
jm.msg = response.ErrorMessage;
|
||||
jm.otherData = accessToken;
|
||||
}
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 提交更新============================================================
|
||||
// POST: Api/WeChatTransactionComponentGood/DoUpdateSpu/10
|
||||
/// <summary>
|
||||
/// 提交更新
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("提交更新")]
|
||||
public async Task<AdminUiCallBack> DoUpdateSpu([FromBody] FMIntId entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var model = await _weChatTransactionComponentGoodsServices.QueryByClauseAsync(p => p.id == entity.id, true);
|
||||
if (model == null)
|
||||
{
|
||||
jm.msg = GlobalConstVars.DataisNo;
|
||||
return jm;
|
||||
}
|
||||
|
||||
var sku = await _weChatTransactionComponentGoodSkuServices.QueryListByClauseAsync(p =>
|
||||
p.isSelect == true && p.outProductId == model.outProductId);
|
||||
|
||||
|
||||
|
||||
//获取小程序认证
|
||||
var accessToken = WeChatCacheAccessTokenHelper.GetWxOpenAccessToken();
|
||||
var client = _weChatApiHttpClientFactory.CreateWxOpenClient();
|
||||
var request = new ShopSPUUpdateRequest();
|
||||
|
||||
request.AccessToken = accessToken;
|
||||
|
||||
request.OutProductId = model.outProductId;
|
||||
request.ProductId = model.productId;
|
||||
request.Title = model.title;
|
||||
request.PagePath = model.path;
|
||||
request.HeadImageUrlList = new List<string>(model.headImg.Split(","));
|
||||
|
||||
var category = await _weChatTransactionComponentAuditCategoryServices.QueryByClauseAsync(p => p.level3 == model.thirdCatId, true);
|
||||
if (category != null && !string.IsNullOrEmpty(category.certificateImage))
|
||||
{
|
||||
request.QualificationPictureUrlList = new List<string>(category.certificateImage.Split(","));
|
||||
}
|
||||
else
|
||||
{
|
||||
request.QualificationPictureUrlList = new List<string>();
|
||||
}
|
||||
|
||||
request.Detail = new ShopSPUUpdateRequest.Types.Detail();
|
||||
|
||||
request.Detail.Description = model.descInfoDesc;
|
||||
request.Detail.ImageUrlList = new List<string>();
|
||||
request.CategoryId = model.thirdCatId;
|
||||
request.BrandId = model.brandId;
|
||||
|
||||
request.SKUList = new List<ShopSPUUpdateRequest.Types.SKU>();
|
||||
|
||||
sku.ForEach(p =>
|
||||
{
|
||||
var item = new ShopSPUUpdateRequest.Types.SKU();
|
||||
item.OutProductId = p.outProductId;
|
||||
item.OutSKUId = p.outSkuId;
|
||||
item.ThumbnailUrl = p.thumbImg;
|
||||
item.SalePrice = Convert.ToInt32(p.salePrice * 100);
|
||||
item.MarketPrice = Convert.ToInt32(p.marketPrice * 100);
|
||||
item.Stock = p.stockNum;
|
||||
item.BarCode = p.barCode;
|
||||
item.SKUCode = p.skuCode;
|
||||
|
||||
request.SKUList.Add(item);
|
||||
});
|
||||
|
||||
var response = await client.ExecuteShopSPUUpdateAsync(request);
|
||||
|
||||
|
||||
if (response.IsSuccessful())
|
||||
{
|
||||
model.productId = response.Data.ProductId;
|
||||
model.updateTime = DateTime.Now;
|
||||
|
||||
await _weChatTransactionComponentGoodsServices.UpdateAsync(model);
|
||||
|
||||
if (response.Data.SKUList.Length > 0)
|
||||
{
|
||||
foreach (var item in response.Data.SKUList)
|
||||
{
|
||||
foreach (var o in sku)
|
||||
{
|
||||
if (o.outSkuId == item.OutSKUId)
|
||||
{
|
||||
o.skuId = item.SKUId;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
await _weChatTransactionComponentGoodSkuServices.UpdateAsync(sku);
|
||||
}
|
||||
|
||||
jm.code = 0;
|
||||
jm.msg = "提交成功";
|
||||
}
|
||||
else
|
||||
{
|
||||
jm.code = 1;
|
||||
jm.data = response.ErrorCode;
|
||||
jm.msg = response.ErrorMessage;
|
||||
}
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 获取商品及状态============================================================
|
||||
// POST: Api/WeChatTransactionComponentGood/GetSKU/10
|
||||
/// <summary>
|
||||
/// 获取商品及状态
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("获取商品及状态")]
|
||||
public async Task<AdminUiCallBack> GetSKU([FromBody] FMIntId entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var model = await _weChatTransactionComponentGoodsServices.QueryByClauseAsync(p => p.id == entity.id, true);
|
||||
if (model == null)
|
||||
{
|
||||
jm.msg = GlobalConstVars.DataisNo;
|
||||
return jm;
|
||||
}
|
||||
|
||||
var editStatus = EnumHelper.EnumToList<SpuEnum.EditStatus>();
|
||||
var spuStatus = EnumHelper.EnumToList<SpuEnum.EditStatus>();
|
||||
|
||||
|
||||
//获取小程序认证
|
||||
var accessToken = WeChatCacheAccessTokenHelper.GetWxOpenAccessToken();
|
||||
var client = _weChatApiHttpClientFactory.CreateWxOpenClient();
|
||||
var request = new ShopSPUGetRequest();
|
||||
request.AccessToken = accessToken;
|
||||
|
||||
//默认0:获取线上数据, 1:获取草稿数据
|
||||
var needEditSpu = Convert.ToInt32(entity.data);
|
||||
|
||||
request.OutProductId = model.outProductId;
|
||||
request.RequireEdittingSPU = needEditSpu == 1 ? true : false;
|
||||
|
||||
var response = await client.ExecuteShopSPUGetAsync(request);
|
||||
|
||||
|
||||
if (response.IsSuccessful())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
jm.code = response.IsSuccessful() ? 0 : 1;
|
||||
jm.msg = response.IsSuccessful() ? "操作成功" : response.ErrorMessage;
|
||||
jm.data = new
|
||||
{
|
||||
result = response,
|
||||
editStatus,
|
||||
spuStatus
|
||||
};
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 撤回商品审核============================================================
|
||||
// POST: Api/WeChatTransactionComponentGood/DoCountermand/10
|
||||
/// <summary>
|
||||
/// 撤回商品审核
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("撤回商品审核")]
|
||||
public async Task<AdminUiCallBack> DeleteSpuAudit([FromBody] FMIntId entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var model = await _weChatTransactionComponentGoodsServices.QueryByClauseAsync(p => p.id == entity.id, true);
|
||||
if (model == null)
|
||||
{
|
||||
jm.msg = GlobalConstVars.DataisNo;
|
||||
return jm;
|
||||
}
|
||||
|
||||
//获取小程序认证
|
||||
var accessToken = WeChatCacheAccessTokenHelper.GetWxOpenAccessToken();
|
||||
|
||||
var client = _weChatApiHttpClientFactory.CreateWxOpenClient();
|
||||
var request = new ShopSPUDeleteAuditRequest();
|
||||
request.AccessToken = accessToken;
|
||||
request.OutProductId = model.outProductId;
|
||||
|
||||
var response = await client.ExecuteShopSPUDeleteAuditAsync(request);
|
||||
|
||||
|
||||
jm.code = response.IsSuccessful() ? 0 : 1;
|
||||
jm.msg = response.IsSuccessful() ? "撤回成功" : response.ErrorMessage;
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 删除商品============================================================
|
||||
// POST: Api/WeChatTransactionComponentGood/DeleteSpu/10
|
||||
/// <summary>
|
||||
/// 删除商品
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("删除商品")]
|
||||
public async Task<AdminUiCallBack> DeleteSpu([FromBody] FMIntId entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var model = await _weChatTransactionComponentGoodsServices.QueryByClauseAsync(p => p.id == entity.id, true);
|
||||
if (model == null)
|
||||
{
|
||||
jm.msg = GlobalConstVars.DataisNo;
|
||||
return jm;
|
||||
}
|
||||
|
||||
//获取小程序认证
|
||||
var accessToken = WeChatCacheAccessTokenHelper.GetWxOpenAccessToken();
|
||||
|
||||
var client = _weChatApiHttpClientFactory.CreateWxOpenClient();
|
||||
var request = new ShopSPUDeleteRequest();
|
||||
request.AccessToken = accessToken;
|
||||
request.OutProductId = model.outProductId;
|
||||
|
||||
var response = await client.ExecuteShopSPUDeleteAsync(request);
|
||||
|
||||
jm.code = response.IsSuccessful() ? 0 : 1;
|
||||
jm.msg = response.IsSuccessful() ? "删除成功" : response.ErrorMessage;
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 上架商品============================================================
|
||||
// POST: Api/WeChatTransactionComponentGood/DoListing/10
|
||||
/// <summary>
|
||||
/// 上架商品
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("上架商品")]
|
||||
public async Task<AdminUiCallBack> DoListing([FromBody] FMIntId entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var model = await _weChatTransactionComponentGoodsServices.QueryByClauseAsync(p => p.id == entity.id, true);
|
||||
if (model == null)
|
||||
{
|
||||
jm.msg = GlobalConstVars.DataisNo;
|
||||
return jm;
|
||||
}
|
||||
|
||||
//获取小程序认证
|
||||
var accessToken = WeChatCacheAccessTokenHelper.GetWxOpenAccessToken();
|
||||
|
||||
var client = _weChatApiHttpClientFactory.CreateWxOpenClient();
|
||||
var request = new ShopSPUListingRequest();
|
||||
request.AccessToken = accessToken;
|
||||
request.OutProductId = model.outProductId;
|
||||
|
||||
var response = await client.ExecuteShopSPUListingAsync(request);
|
||||
|
||||
jm.code = response.IsSuccessful() ? 0 : 1;
|
||||
jm.msg = response.IsSuccessful() ? "上架成功" : response.ErrorMessage;
|
||||
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 下架商品============================================================
|
||||
// POST: Api/WeChatTransactionComponentGood/DoDelistingPpu/10
|
||||
/// <summary>
|
||||
/// 下架商品
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("下架商品")]
|
||||
public async Task<AdminUiCallBack> DoDelistingSpu([FromBody] FMIntId entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var model = await _weChatTransactionComponentGoodsServices.QueryByClauseAsync(p => p.id == entity.id, true);
|
||||
if (model == null)
|
||||
{
|
||||
jm.msg = GlobalConstVars.DataisNo;
|
||||
return jm;
|
||||
}
|
||||
|
||||
|
||||
//获取小程序认证
|
||||
var accessToken = WeChatCacheAccessTokenHelper.GetWxOpenAccessToken();
|
||||
|
||||
var client = _weChatApiHttpClientFactory.CreateWxOpenClient();
|
||||
var request = new ShopSPUDelistingRequest();
|
||||
request.AccessToken = accessToken;
|
||||
request.OutProductId = model.outProductId;
|
||||
|
||||
var response = await client.ExecuteShopSPUDelistingAsync(request);
|
||||
|
||||
jm.code = response.IsSuccessful() ? 0 : 1;
|
||||
jm.msg = response.IsSuccessful() ? "下架成功" : response.ErrorMessage;
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 预览数据============================================================
|
||||
// POST: Api/WeChatTransactionComponentGood/GetDetails/10
|
||||
/// <summary>
|
||||
/// 预览数据
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("预览数据")]
|
||||
public async Task<AdminUiCallBack> GetDetails([FromBody] FMIntId entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var model = await _weChatTransactionComponentGoodsServices.QueryByIdAsync(entity.id, false);
|
||||
if (model == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
jm.code = 0;
|
||||
jm.data = model;
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 免审更新============================================================
|
||||
// POST: Api/WeChatTransactionComponentGood/WithoutAuditUpdateSKU/10
|
||||
/// <summary>
|
||||
/// 提交更新
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("免审更新")]
|
||||
public async Task<AdminUiCallBack> WithoutAuditUpdateSKU([FromBody] FMIntId entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var model = await _weChatTransactionComponentGoodsServices.QueryByClauseAsync(p => p.id == entity.id, true);
|
||||
if (model == null)
|
||||
{
|
||||
jm.msg = GlobalConstVars.DataisNo;
|
||||
return jm;
|
||||
}
|
||||
|
||||
var sku = await _weChatTransactionComponentGoodSkuServices.QueryListByClauseAsync(p =>
|
||||
p.isSelect == true && p.outProductId == model.outProductId);
|
||||
|
||||
//获取小程序认证
|
||||
var accessToken = WeChatCacheAccessTokenHelper.GetWxOpenAccessToken();
|
||||
var client = _weChatApiHttpClientFactory.CreateWxOpenClient();
|
||||
var request = new ShopSPUUpdateWithoutAuditRequest();
|
||||
|
||||
request.AccessToken = accessToken;
|
||||
|
||||
request.OutProductId = model.outProductId;
|
||||
request.ProductId = model.productId;
|
||||
|
||||
request.PagePath = model.path;
|
||||
|
||||
request.SKUList = new List<ShopSPUUpdateWithoutAuditRequest.Types.SKU>();
|
||||
|
||||
sku.ForEach(p =>
|
||||
{
|
||||
var item = new ShopSPUUpdateWithoutAuditRequest.Types.SKU();
|
||||
|
||||
item.OutSKUId = p.outSkuId;
|
||||
|
||||
item.SalePrice = Convert.ToInt32(p.salePrice * 100);
|
||||
item.MarketPrice = Convert.ToInt32(p.marketPrice * 100);
|
||||
item.Stock = p.stockNum;
|
||||
item.BarCode = p.barCode;
|
||||
item.SKUCode = p.skuCode;
|
||||
|
||||
request.SKUList.Add(item);
|
||||
});
|
||||
|
||||
var response = await client.ExecuteShopSPUUpdateWithoutAuditAsync(request);
|
||||
|
||||
if (response.IsSuccessful())
|
||||
{
|
||||
|
||||
jm.code = 0;
|
||||
jm.msg = "更新成功";
|
||||
}
|
||||
else
|
||||
{
|
||||
jm.code = 1;
|
||||
jm.data = response.ErrorCode;
|
||||
jm.msg = response.ErrorMessage;
|
||||
}
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,792 +0,0 @@
|
||||
/***********************************************************************
|
||||
* Project: CoreCms
|
||||
* ProjectName: 核心内容管理系统
|
||||
* Web: https://www.corecms.net
|
||||
* Author: 大灰灰
|
||||
* Email: jianweie@163.com
|
||||
* CreateTime: 2021/7/3 16:30:55
|
||||
* Description: 暂无
|
||||
***********************************************************************/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using CoreCms.Net.Caching.AccressToken;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.Model.Entities;
|
||||
using CoreCms.Net.Model.Entities.Expression;
|
||||
using CoreCms.Net.Model.FromBody;
|
||||
using CoreCms.Net.Filter;
|
||||
using CoreCms.Net.IServices;
|
||||
using CoreCms.Net.Model.ViewModels.UI;
|
||||
using CoreCms.Net.Utility.Helper;
|
||||
using CoreCms.Net.Utility.Extensions;
|
||||
using CoreCms.Net.WeChat.Service.HttpClients;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NPOI.HSSF.UserModel;
|
||||
using SKIT.FlurlHttpClient.Wechat.Api;
|
||||
using SKIT.FlurlHttpClient.Wechat.Api.Models;
|
||||
using SqlSugar;
|
||||
|
||||
namespace CoreCms.Net.Web.Admin.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// 自定义交易组件三级类目
|
||||
///</summary>
|
||||
[Description("自定义交易组件三级类目")]
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
[RequiredErrorForAdmin]
|
||||
[Authorize(Permissions.Name)]
|
||||
public class WeChatTransactionComponentThirdCategoryController : ControllerBase
|
||||
{
|
||||
private readonly IWebHostEnvironment _webHostEnvironment;
|
||||
private readonly IWeChatTransactionComponentThirdCategoryServices _weChatTcThirdCatListServices;
|
||||
private readonly CoreCms.Net.WeChat.Service.HttpClients.IWeChatApiHttpClientFactory _weChatApiHttpClientFactory;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
///</summary>
|
||||
public WeChatTransactionComponentThirdCategoryController(IWebHostEnvironment webHostEnvironment
|
||||
, IWeChatTransactionComponentThirdCategoryServices weChatTcThirdCatListServices, IWeChatApiHttpClientFactory weChatApiHttpClientFactory)
|
||||
{
|
||||
_webHostEnvironment = webHostEnvironment;
|
||||
_weChatTcThirdCatListServices = weChatTcThirdCatListServices;
|
||||
_weChatApiHttpClientFactory = weChatApiHttpClientFactory;
|
||||
}
|
||||
|
||||
#region 获取列表============================================================
|
||||
// POST: Api/WeChatTCThirdCatList/GetPageList
|
||||
/// <summary>
|
||||
/// 获取列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("获取列表")]
|
||||
public async Task<AdminUiCallBack> GetPageList()
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
var pageCurrent = Request.Form["page"].FirstOrDefault().ObjectToInt(1);
|
||||
var pageSize = Request.Form["limit"].FirstOrDefault().ObjectToInt(30);
|
||||
var where = PredicateBuilder.True<WeChatTransactionComponentThirdCategory>();
|
||||
//获取排序字段
|
||||
var orderField = Request.Form["orderField"].FirstOrDefault();
|
||||
|
||||
Expression<Func<WeChatTransactionComponentThirdCategory, object>> orderEx = orderField switch
|
||||
{
|
||||
"id" => p => p.id,
|
||||
"third_cat_id" => p => p.third_cat_id,
|
||||
"third_cat_name" => p => p.third_cat_name,
|
||||
"qualification" => p => p.qualification,
|
||||
"qualification_type" => p => p.qualification_type,
|
||||
"product_qualification" => p => p.product_qualification,
|
||||
"product_qualification_type" => p => p.product_qualification_type,
|
||||
"second_cat_id" => p => p.second_cat_id,
|
||||
"second_cat_name" => p => p.second_cat_name,
|
||||
"first_cat_id" => p => p.first_cat_id,
|
||||
"first_cat_name" => p => p.first_cat_name,
|
||||
"createTime" => p => p.createTime,
|
||||
_ => p => p.id
|
||||
};
|
||||
|
||||
//设置排序方式
|
||||
var orderDirection = Request.Form["orderDirection"].FirstOrDefault();
|
||||
var orderBy = orderDirection switch
|
||||
{
|
||||
"asc" => OrderByType.Asc,
|
||||
"desc" => OrderByType.Desc,
|
||||
_ => OrderByType.Desc
|
||||
};
|
||||
//查询筛选
|
||||
|
||||
//序列 int
|
||||
var id = Request.Form["id"].FirstOrDefault().ObjectToInt(0);
|
||||
if (id > 0)
|
||||
{
|
||||
where = where.And(p => p.id == id);
|
||||
}
|
||||
//类目ID int
|
||||
var third_cat_id = Request.Form["third_cat_id"].FirstOrDefault().ObjectToInt(0);
|
||||
if (third_cat_id > 0)
|
||||
{
|
||||
where = where.And(p => p.third_cat_id == third_cat_id);
|
||||
}
|
||||
//类目名称 nvarchar
|
||||
var third_cat_name = Request.Form["third_cat_name"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(third_cat_name))
|
||||
{
|
||||
where = where.And(p => p.third_cat_name.Contains(third_cat_name));
|
||||
}
|
||||
//类目资质 nvarchar
|
||||
var qualification = Request.Form["qualification"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(qualification))
|
||||
{
|
||||
where = where.And(p => p.qualification.Contains(qualification));
|
||||
}
|
||||
//类目资质类型,0:不需要,1:必填,2:选填 int
|
||||
var qualification_type = Request.Form["qualification_type"].FirstOrDefault().ObjectToInt(0);
|
||||
if (qualification_type > 0)
|
||||
{
|
||||
where = where.And(p => p.qualification_type == qualification_type);
|
||||
}
|
||||
//商品资质 nvarchar
|
||||
var product_qualification = Request.Form["product_qualification"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(product_qualification))
|
||||
{
|
||||
where = where.And(p => p.product_qualification.Contains(product_qualification));
|
||||
}
|
||||
//商品资质类型,0:不需要,1:必填,2:选填 int
|
||||
var product_qualification_type = Request.Form["product_qualification_type"].FirstOrDefault().ObjectToInt(0);
|
||||
if (product_qualification_type > 0)
|
||||
{
|
||||
where = where.And(p => p.product_qualification_type == product_qualification_type);
|
||||
}
|
||||
//二级类目ID int
|
||||
var second_cat_id = Request.Form["second_cat_id"].FirstOrDefault().ObjectToInt(0);
|
||||
if (second_cat_id > 0)
|
||||
{
|
||||
where = where.And(p => p.second_cat_id == second_cat_id);
|
||||
}
|
||||
//二级类目名称 nvarchar
|
||||
var second_cat_name = Request.Form["second_cat_name"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(second_cat_name))
|
||||
{
|
||||
where = where.And(p => p.second_cat_name.Contains(second_cat_name));
|
||||
}
|
||||
//一级类目ID int
|
||||
var first_cat_id = Request.Form["first_cat_id"].FirstOrDefault().ObjectToInt(0);
|
||||
if (first_cat_id > 0)
|
||||
{
|
||||
where = where.And(p => p.first_cat_id == first_cat_id);
|
||||
}
|
||||
//一级类目名称 nvarchar
|
||||
var first_cat_name = Request.Form["first_cat_name"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(first_cat_name))
|
||||
{
|
||||
where = where.And(p => p.first_cat_name.Contains(first_cat_name));
|
||||
}
|
||||
//创建时间 datetime
|
||||
var createTime = Request.Form["createTime"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(createTime))
|
||||
{
|
||||
if (createTime.Contains("到"))
|
||||
{
|
||||
var dts = createTime.Split("到");
|
||||
var dtStart = dts[0].Trim().ObjectToDate();
|
||||
where = where.And(p => p.createTime > dtStart);
|
||||
var dtEnd = dts[1].Trim().ObjectToDate();
|
||||
where = where.And(p => p.createTime < dtEnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
var dt = createTime.ObjectToDate();
|
||||
where = where.And(p => p.createTime > dt);
|
||||
}
|
||||
}
|
||||
//获取数据
|
||||
var list = await _weChatTcThirdCatListServices.QueryPageAsync(where, " first_cat_id asc, second_cat_id asc , third_cat_id asc ", pageCurrent, pageSize, false);
|
||||
//返回数据
|
||||
jm.data = list;
|
||||
jm.code = 0;
|
||||
jm.count = list.TotalCount;
|
||||
jm.msg = "数据调用成功!";
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 首页数据============================================================
|
||||
// POST: Api/WeChatTCThirdCatList/GetIndex
|
||||
/// <summary>
|
||||
/// 首页数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("首页数据")]
|
||||
public AdminUiCallBack GetIndex()
|
||||
{
|
||||
//返回数据
|
||||
var jm = new AdminUiCallBack { code = 0 };
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 刷新数据============================================================
|
||||
// POST: Api/CoreCmsMiNiStoreThirdCatList/DoBatchDelete/10,11,20
|
||||
/// <summary>
|
||||
/// 刷新数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("刷新数据")]
|
||||
public async Task<AdminUiCallBack> DoRefresh()
|
||||
{
|
||||
var jm = new AdminUiCallBack { code = 0 };
|
||||
var bl = false;
|
||||
try
|
||||
{
|
||||
var dt = DateTime.Now;
|
||||
var stime = new DateTime(dt.Year, dt.Month, dt.Day, 0, 0, 0);
|
||||
var etime = new DateTime(dt.Year, dt.Month, dt.Day, 23, 59, 59);
|
||||
|
||||
var isHave = await _weChatTcThirdCatListServices.ExistsAsync(p => p.createTime > stime && p.createTime < etime);
|
||||
if (isHave)
|
||||
{
|
||||
jm.code = 1;
|
||||
jm.msg = "今日已经更新,不要频繁调用";
|
||||
return jm;
|
||||
}
|
||||
|
||||
|
||||
//获取小程序认证
|
||||
var accessToken = WeChatCacheAccessTokenHelper.GetWxOpenAccessToken();
|
||||
var client = _weChatApiHttpClientFactory.CreateWxOpenClient();
|
||||
var request = new ShopCategoryGetRequest { AccessToken = accessToken };
|
||||
|
||||
var response = await client.ExecuteShopCategoryGetAsync(request);
|
||||
if (response.IsSuccessful())
|
||||
{
|
||||
if (response.CategoryList.Length > 0)
|
||||
{
|
||||
var list = new List<WeChatTransactionComponentThirdCategory>();
|
||||
|
||||
foreach (var item in response.CategoryList)
|
||||
{
|
||||
list.Add(new WeChatTransactionComponentThirdCategory()
|
||||
{
|
||||
third_cat_id = item.ThirdCategoryId,
|
||||
third_cat_name = item.ThirdCategoryName,
|
||||
qualification = item.Qualification,
|
||||
qualification_type = item.QualificationType,
|
||||
product_qualification = item.ProductQualification,
|
||||
product_qualification_type = item.ProductQualificationType,
|
||||
second_cat_id = item.SecondCategoryId,
|
||||
second_cat_name = item.SecondCategoryName,
|
||||
first_cat_id = item.FirstCategoryId,
|
||||
first_cat_name = item.FirstCategoryName,
|
||||
createTime = DateTime.Now
|
||||
|
||||
});
|
||||
}
|
||||
await _weChatTcThirdCatListServices.DeleteAsync(p => p.id > 0);
|
||||
bl = await _weChatTcThirdCatListServices.InsertAsync(list) > 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
jm.code = 1;
|
||||
jm.msg = response.ErrorMessage;
|
||||
jm.otherData = response;
|
||||
return jm;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
jm.code = 1;
|
||||
jm.msg = e.ToString();
|
||||
return jm;
|
||||
}
|
||||
|
||||
jm.code = bl ? 0 : 1;
|
||||
jm.msg = bl ? "更新成功" : "更新失败";
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 预览数据============================================================
|
||||
// POST: Api/WeChatTCThirdCatList/GetDetails/10
|
||||
/// <summary>
|
||||
/// 预览数据
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("预览数据")]
|
||||
public async Task<AdminUiCallBack> GetDetails([FromBody] FMIntId entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var model = await _weChatTcThirdCatListServices.QueryByIdAsync(entity.id, false);
|
||||
if (model == null)
|
||||
{
|
||||
jm.msg = "不存在此信息";
|
||||
return jm;
|
||||
}
|
||||
jm.code = 0;
|
||||
jm.data = model;
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 选择导出============================================================
|
||||
// POST: Api/WeChatTCThirdCatList/SelectExportExcel/10
|
||||
/// <summary>
|
||||
/// 选择导出
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("选择导出")]
|
||||
public async Task<AdminUiCallBack> SelectExportExcel([FromBody] FMArrayIntIds entity)
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
//创建Excel文件的对象
|
||||
var book = new HSSFWorkbook();
|
||||
//添加一个sheet
|
||||
var mySheet = book.CreateSheet("Sheet1");
|
||||
//获取list数据
|
||||
var listModel = await _weChatTcThirdCatListServices.QueryListByClauseAsync(p => entity.id.Contains(p.id), p => p.id, OrderByType.Asc, true);
|
||||
//给sheet1添加第一行的头部标题
|
||||
var headerRow = mySheet.CreateRow(0);
|
||||
var headerStyle = ExcelHelper.GetHeaderStyle(book);
|
||||
|
||||
var cell0 = headerRow.CreateCell(0);
|
||||
cell0.SetCellValue("序列");
|
||||
cell0.CellStyle = headerStyle;
|
||||
mySheet.SetColumnWidth(0, 10 * 256);
|
||||
|
||||
var cell1 = headerRow.CreateCell(1);
|
||||
cell1.SetCellValue("类目ID");
|
||||
cell1.CellStyle = headerStyle;
|
||||
mySheet.SetColumnWidth(1, 10 * 256);
|
||||
|
||||
var cell2 = headerRow.CreateCell(2);
|
||||
cell2.SetCellValue("类目名称");
|
||||
cell2.CellStyle = headerStyle;
|
||||
mySheet.SetColumnWidth(2, 10 * 256);
|
||||
|
||||
var cell3 = headerRow.CreateCell(3);
|
||||
cell3.SetCellValue("类目资质");
|
||||
cell3.CellStyle = headerStyle;
|
||||
mySheet.SetColumnWidth(3, 10 * 256);
|
||||
|
||||
var cell4 = headerRow.CreateCell(4);
|
||||
cell4.SetCellValue("类目资质类型,0:不需要,1:必填,2:选填");
|
||||
cell4.CellStyle = headerStyle;
|
||||
mySheet.SetColumnWidth(4, 10 * 256);
|
||||
|
||||
var cell5 = headerRow.CreateCell(5);
|
||||
cell5.SetCellValue("商品资质");
|
||||
cell5.CellStyle = headerStyle;
|
||||
mySheet.SetColumnWidth(5, 10 * 256);
|
||||
|
||||
var cell6 = headerRow.CreateCell(6);
|
||||
cell6.SetCellValue("商品资质类型,0:不需要,1:必填,2:选填");
|
||||
cell6.CellStyle = headerStyle;
|
||||
mySheet.SetColumnWidth(6, 10 * 256);
|
||||
|
||||
var cell7 = headerRow.CreateCell(7);
|
||||
cell7.SetCellValue("二级类目ID");
|
||||
cell7.CellStyle = headerStyle;
|
||||
mySheet.SetColumnWidth(7, 10 * 256);
|
||||
|
||||
var cell8 = headerRow.CreateCell(8);
|
||||
cell8.SetCellValue("二级类目名称");
|
||||
cell8.CellStyle = headerStyle;
|
||||
mySheet.SetColumnWidth(8, 10 * 256);
|
||||
|
||||
var cell9 = headerRow.CreateCell(9);
|
||||
cell9.SetCellValue("一级类目ID");
|
||||
cell9.CellStyle = headerStyle;
|
||||
mySheet.SetColumnWidth(9, 10 * 256);
|
||||
|
||||
var cell10 = headerRow.CreateCell(10);
|
||||
cell10.SetCellValue("一级类目名称");
|
||||
cell10.CellStyle = headerStyle;
|
||||
mySheet.SetColumnWidth(10, 10 * 256);
|
||||
|
||||
var cell11 = headerRow.CreateCell(11);
|
||||
cell11.SetCellValue("创建时间");
|
||||
cell11.CellStyle = headerStyle;
|
||||
mySheet.SetColumnWidth(11, 10 * 256);
|
||||
|
||||
headerRow.Height = 30 * 20;
|
||||
var commonCellStyle = ExcelHelper.GetCommonStyle(book);
|
||||
|
||||
//将数据逐步写入sheet1各个行
|
||||
for (var i = 0; i < listModel.Count; i++)
|
||||
{
|
||||
var rowTemp = mySheet.CreateRow(i + 1);
|
||||
|
||||
var rowTemp0 = rowTemp.CreateCell(0);
|
||||
rowTemp0.SetCellValue(listModel[i].id.ToString());
|
||||
rowTemp0.CellStyle = commonCellStyle;
|
||||
|
||||
var rowTemp1 = rowTemp.CreateCell(1);
|
||||
rowTemp1.SetCellValue(listModel[i].third_cat_id.ToString());
|
||||
rowTemp1.CellStyle = commonCellStyle;
|
||||
|
||||
var rowTemp2 = rowTemp.CreateCell(2);
|
||||
rowTemp2.SetCellValue(listModel[i].third_cat_name.ToString());
|
||||
rowTemp2.CellStyle = commonCellStyle;
|
||||
|
||||
var rowTemp3 = rowTemp.CreateCell(3);
|
||||
rowTemp3.SetCellValue(listModel[i].qualification.ToString());
|
||||
rowTemp3.CellStyle = commonCellStyle;
|
||||
|
||||
var rowTemp4 = rowTemp.CreateCell(4);
|
||||
rowTemp4.SetCellValue(listModel[i].qualification_type.ToString());
|
||||
rowTemp4.CellStyle = commonCellStyle;
|
||||
|
||||
var rowTemp5 = rowTemp.CreateCell(5);
|
||||
rowTemp5.SetCellValue(listModel[i].product_qualification.ToString());
|
||||
rowTemp5.CellStyle = commonCellStyle;
|
||||
|
||||
var rowTemp6 = rowTemp.CreateCell(6);
|
||||
rowTemp6.SetCellValue(listModel[i].product_qualification_type.ToString());
|
||||
rowTemp6.CellStyle = commonCellStyle;
|
||||
|
||||
var rowTemp7 = rowTemp.CreateCell(7);
|
||||
rowTemp7.SetCellValue(listModel[i].second_cat_id.ToString());
|
||||
rowTemp7.CellStyle = commonCellStyle;
|
||||
|
||||
var rowTemp8 = rowTemp.CreateCell(8);
|
||||
rowTemp8.SetCellValue(listModel[i].second_cat_name.ToString());
|
||||
rowTemp8.CellStyle = commonCellStyle;
|
||||
|
||||
var rowTemp9 = rowTemp.CreateCell(9);
|
||||
rowTemp9.SetCellValue(listModel[i].first_cat_id.ToString());
|
||||
rowTemp9.CellStyle = commonCellStyle;
|
||||
|
||||
var rowTemp10 = rowTemp.CreateCell(10);
|
||||
rowTemp10.SetCellValue(listModel[i].first_cat_name.ToString());
|
||||
rowTemp10.CellStyle = commonCellStyle;
|
||||
|
||||
var rowTemp11 = rowTemp.CreateCell(11);
|
||||
rowTemp11.SetCellValue(listModel[i].createTime.ToString());
|
||||
rowTemp11.CellStyle = commonCellStyle;
|
||||
|
||||
}
|
||||
// 导出excel
|
||||
string webRootPath = _webHostEnvironment.WebRootPath;
|
||||
string tpath = "/files/" + DateTime.Now.ToString("yyyy-MM-dd") + "/";
|
||||
string fileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "-WeChatTCThirdCatList导出(选择结果).xls";
|
||||
string filePath = webRootPath + tpath;
|
||||
DirectoryInfo di = new DirectoryInfo(filePath);
|
||||
if (!di.Exists)
|
||||
{
|
||||
di.Create();
|
||||
}
|
||||
FileStream fileHssf = new FileStream(filePath + fileName, FileMode.Create);
|
||||
book.Write(fileHssf);
|
||||
fileHssf.Close();
|
||||
|
||||
jm.code = 0;
|
||||
jm.msg = GlobalConstVars.ExcelExportSuccess;
|
||||
jm.data = tpath + fileName;
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 查询导出============================================================
|
||||
// POST: Api/WeChatTCThirdCatList/QueryExportExcel/10
|
||||
/// <summary>
|
||||
/// 查询导出
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("查询导出")]
|
||||
public async Task<AdminUiCallBack> QueryExportExcel()
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
|
||||
var where = PredicateBuilder.True<WeChatTransactionComponentThirdCategory>();
|
||||
//查询筛选
|
||||
|
||||
//序列 int
|
||||
var id = Request.Form["id"].FirstOrDefault().ObjectToInt(0);
|
||||
if (id > 0)
|
||||
{
|
||||
where = where.And(p => p.id == id);
|
||||
}
|
||||
//类目ID int
|
||||
var third_cat_id = Request.Form["third_cat_id"].FirstOrDefault().ObjectToInt(0);
|
||||
if (third_cat_id > 0)
|
||||
{
|
||||
where = where.And(p => p.third_cat_id == third_cat_id);
|
||||
}
|
||||
//类目名称 nvarchar
|
||||
var third_cat_name = Request.Form["third_cat_name"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(third_cat_name))
|
||||
{
|
||||
where = where.And(p => p.third_cat_name.Contains(third_cat_name));
|
||||
}
|
||||
//类目资质 nvarchar
|
||||
var qualification = Request.Form["qualification"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(qualification))
|
||||
{
|
||||
where = where.And(p => p.qualification.Contains(qualification));
|
||||
}
|
||||
//类目资质类型,0:不需要,1:必填,2:选填 int
|
||||
var qualification_type = Request.Form["qualification_type"].FirstOrDefault().ObjectToInt(0);
|
||||
if (qualification_type > 0)
|
||||
{
|
||||
where = where.And(p => p.qualification_type == qualification_type);
|
||||
}
|
||||
//商品资质 nvarchar
|
||||
var product_qualification = Request.Form["product_qualification"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(product_qualification))
|
||||
{
|
||||
where = where.And(p => p.product_qualification.Contains(product_qualification));
|
||||
}
|
||||
//商品资质类型,0:不需要,1:必填,2:选填 int
|
||||
var product_qualification_type = Request.Form["product_qualification_type"].FirstOrDefault().ObjectToInt(0);
|
||||
if (product_qualification_type > 0)
|
||||
{
|
||||
where = where.And(p => p.product_qualification_type == product_qualification_type);
|
||||
}
|
||||
//二级类目ID int
|
||||
var second_cat_id = Request.Form["second_cat_id"].FirstOrDefault().ObjectToInt(0);
|
||||
if (second_cat_id > 0)
|
||||
{
|
||||
where = where.And(p => p.second_cat_id == second_cat_id);
|
||||
}
|
||||
//二级类目名称 nvarchar
|
||||
var second_cat_name = Request.Form["second_cat_name"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(second_cat_name))
|
||||
{
|
||||
where = where.And(p => p.second_cat_name.Contains(second_cat_name));
|
||||
}
|
||||
//一级类目ID int
|
||||
var first_cat_id = Request.Form["first_cat_id"].FirstOrDefault().ObjectToInt(0);
|
||||
if (first_cat_id > 0)
|
||||
{
|
||||
where = where.And(p => p.first_cat_id == first_cat_id);
|
||||
}
|
||||
//一级类目名称 nvarchar
|
||||
var first_cat_name = Request.Form["first_cat_name"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(first_cat_name))
|
||||
{
|
||||
where = where.And(p => p.first_cat_name.Contains(first_cat_name));
|
||||
}
|
||||
//创建时间 datetime
|
||||
var createTime = Request.Form["createTime"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(createTime))
|
||||
{
|
||||
var dt = createTime.ObjectToDate();
|
||||
where = where.And(p => p.createTime > dt);
|
||||
}
|
||||
//获取数据
|
||||
//创建Excel文件的对象
|
||||
var book = new HSSFWorkbook();
|
||||
//添加一个sheet
|
||||
var mySheet = book.CreateSheet("Sheet1");
|
||||
//获取list数据
|
||||
var listModel = await _weChatTcThirdCatListServices.QueryListByClauseAsync(where, p => p.id, OrderByType.Asc, true);
|
||||
//给sheet1添加第一行的头部标题
|
||||
var headerRow = mySheet.CreateRow(0);
|
||||
var headerStyle = ExcelHelper.GetHeaderStyle(book);
|
||||
|
||||
var cell0 = headerRow.CreateCell(0);
|
||||
cell0.SetCellValue("序列");
|
||||
cell0.CellStyle = headerStyle;
|
||||
mySheet.SetColumnWidth(0, 10 * 256);
|
||||
|
||||
var cell1 = headerRow.CreateCell(1);
|
||||
cell1.SetCellValue("类目ID");
|
||||
cell1.CellStyle = headerStyle;
|
||||
mySheet.SetColumnWidth(1, 10 * 256);
|
||||
|
||||
var cell2 = headerRow.CreateCell(2);
|
||||
cell2.SetCellValue("类目名称");
|
||||
cell2.CellStyle = headerStyle;
|
||||
mySheet.SetColumnWidth(2, 10 * 256);
|
||||
|
||||
var cell3 = headerRow.CreateCell(3);
|
||||
cell3.SetCellValue("类目资质");
|
||||
cell3.CellStyle = headerStyle;
|
||||
mySheet.SetColumnWidth(3, 10 * 256);
|
||||
|
||||
var cell4 = headerRow.CreateCell(4);
|
||||
cell4.SetCellValue("类目资质类型,0:不需要,1:必填,2:选填");
|
||||
cell4.CellStyle = headerStyle;
|
||||
mySheet.SetColumnWidth(4, 10 * 256);
|
||||
|
||||
var cell5 = headerRow.CreateCell(5);
|
||||
cell5.SetCellValue("商品资质");
|
||||
cell5.CellStyle = headerStyle;
|
||||
mySheet.SetColumnWidth(5, 10 * 256);
|
||||
|
||||
var cell6 = headerRow.CreateCell(6);
|
||||
cell6.SetCellValue("商品资质类型,0:不需要,1:必填,2:选填");
|
||||
cell6.CellStyle = headerStyle;
|
||||
mySheet.SetColumnWidth(6, 10 * 256);
|
||||
|
||||
var cell7 = headerRow.CreateCell(7);
|
||||
cell7.SetCellValue("二级类目ID");
|
||||
cell7.CellStyle = headerStyle;
|
||||
mySheet.SetColumnWidth(7, 10 * 256);
|
||||
|
||||
var cell8 = headerRow.CreateCell(8);
|
||||
cell8.SetCellValue("二级类目名称");
|
||||
cell8.CellStyle = headerStyle;
|
||||
mySheet.SetColumnWidth(8, 10 * 256);
|
||||
|
||||
var cell9 = headerRow.CreateCell(9);
|
||||
cell9.SetCellValue("一级类目ID");
|
||||
cell9.CellStyle = headerStyle;
|
||||
mySheet.SetColumnWidth(9, 10 * 256);
|
||||
|
||||
var cell10 = headerRow.CreateCell(10);
|
||||
cell10.SetCellValue("一级类目名称");
|
||||
cell10.CellStyle = headerStyle;
|
||||
mySheet.SetColumnWidth(10, 10 * 256);
|
||||
|
||||
var cell11 = headerRow.CreateCell(11);
|
||||
cell11.SetCellValue("创建时间");
|
||||
cell11.CellStyle = headerStyle;
|
||||
mySheet.SetColumnWidth(11, 10 * 256);
|
||||
|
||||
|
||||
headerRow.Height = 30 * 20;
|
||||
var commonCellStyle = ExcelHelper.GetCommonStyle(book);
|
||||
|
||||
//将数据逐步写入sheet1各个行
|
||||
for (var i = 0; i < listModel.Count; i++)
|
||||
{
|
||||
var rowTemp = mySheet.CreateRow(i + 1);
|
||||
|
||||
|
||||
var rowTemp0 = rowTemp.CreateCell(0);
|
||||
rowTemp0.SetCellValue(listModel[i].id.ToString());
|
||||
rowTemp0.CellStyle = commonCellStyle;
|
||||
|
||||
|
||||
|
||||
var rowTemp1 = rowTemp.CreateCell(1);
|
||||
rowTemp1.SetCellValue(listModel[i].third_cat_id.ToString());
|
||||
rowTemp1.CellStyle = commonCellStyle;
|
||||
|
||||
|
||||
|
||||
var rowTemp2 = rowTemp.CreateCell(2);
|
||||
rowTemp2.SetCellValue(listModel[i].third_cat_name.ToString());
|
||||
rowTemp2.CellStyle = commonCellStyle;
|
||||
|
||||
|
||||
|
||||
var rowTemp3 = rowTemp.CreateCell(3);
|
||||
rowTemp3.SetCellValue(listModel[i].qualification.ToString());
|
||||
rowTemp3.CellStyle = commonCellStyle;
|
||||
|
||||
|
||||
|
||||
var rowTemp4 = rowTemp.CreateCell(4);
|
||||
rowTemp4.SetCellValue(listModel[i].qualification_type.ToString());
|
||||
rowTemp4.CellStyle = commonCellStyle;
|
||||
|
||||
|
||||
|
||||
var rowTemp5 = rowTemp.CreateCell(5);
|
||||
rowTemp5.SetCellValue(listModel[i].product_qualification.ToString());
|
||||
rowTemp5.CellStyle = commonCellStyle;
|
||||
|
||||
|
||||
|
||||
var rowTemp6 = rowTemp.CreateCell(6);
|
||||
rowTemp6.SetCellValue(listModel[i].product_qualification_type.ToString());
|
||||
rowTemp6.CellStyle = commonCellStyle;
|
||||
|
||||
|
||||
|
||||
var rowTemp7 = rowTemp.CreateCell(7);
|
||||
rowTemp7.SetCellValue(listModel[i].second_cat_id.ToString());
|
||||
rowTemp7.CellStyle = commonCellStyle;
|
||||
|
||||
|
||||
|
||||
var rowTemp8 = rowTemp.CreateCell(8);
|
||||
rowTemp8.SetCellValue(listModel[i].second_cat_name.ToString());
|
||||
rowTemp8.CellStyle = commonCellStyle;
|
||||
|
||||
|
||||
|
||||
var rowTemp9 = rowTemp.CreateCell(9);
|
||||
rowTemp9.SetCellValue(listModel[i].first_cat_id.ToString());
|
||||
rowTemp9.CellStyle = commonCellStyle;
|
||||
|
||||
|
||||
|
||||
var rowTemp10 = rowTemp.CreateCell(10);
|
||||
rowTemp10.SetCellValue(listModel[i].first_cat_name.ToString());
|
||||
rowTemp10.CellStyle = commonCellStyle;
|
||||
|
||||
|
||||
|
||||
var rowTemp11 = rowTemp.CreateCell(11);
|
||||
rowTemp11.SetCellValue(listModel[i].createTime.ToString());
|
||||
rowTemp11.CellStyle = commonCellStyle;
|
||||
|
||||
|
||||
}
|
||||
// 写入到excel
|
||||
string webRootPath = _webHostEnvironment.WebRootPath;
|
||||
string tpath = "/files/" + DateTime.Now.ToString("yyyy-MM-dd") + "/";
|
||||
string fileName = DateTime.Now.ToString("yyyyMMddHHmmssfff") + "-WeChatTCThirdCatList导出(查询结果).xls";
|
||||
string filePath = webRootPath + tpath;
|
||||
DirectoryInfo di = new DirectoryInfo(filePath);
|
||||
if (!di.Exists)
|
||||
{
|
||||
di.Create();
|
||||
}
|
||||
FileStream fileHssf = new FileStream(filePath + fileName, FileMode.Create);
|
||||
book.Write(fileHssf);
|
||||
fileHssf.Close();
|
||||
|
||||
jm.code = 0;
|
||||
jm.msg = GlobalConstVars.ExcelExportSuccess;
|
||||
jm.data = tpath + fileName;
|
||||
|
||||
return jm;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 获取交易组件三级类目====================================================
|
||||
|
||||
// POST: Api/Tools/GetGoods
|
||||
/// <summary>
|
||||
/// 获取商品列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Description("获取三级类目")]
|
||||
public async Task<AdminUiCallBack> GetThirdCategories()
|
||||
{
|
||||
var jm = new AdminUiCallBack();
|
||||
var pageCurrent = Request.Form["page"].FirstOrDefault().ObjectToInt(1);
|
||||
var pageSize = Request.Form["limit"].FirstOrDefault().ObjectToInt(30);
|
||||
var where = PredicateBuilder.True<WeChatTransactionComponentThirdCategory>();
|
||||
|
||||
//商品名称 nvarchar
|
||||
var name = Request.Form["name"].FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(name)) where = where.And(p => p.third_cat_name.Contains(name));
|
||||
|
||||
//获取数据
|
||||
var list = await _weChatTcThirdCatListServices.QueryPageAsync(where, p => p.createTime, OrderByType.Desc,
|
||||
pageCurrent, pageSize);
|
||||
//返回数据
|
||||
|
||||
jm.data = list;
|
||||
jm.code = 0;
|
||||
jm.count = list.TotalCount;
|
||||
jm.msg = "数据调用成功!";
|
||||
return jm;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user