# 2022-03-21

### 1.4.1 开源社区版:
无
### 0.3.0 专业版:
【新增】微信自定义交易组件增加【免审更新】功能。
【新增】微信自定义交易组件增加【上传品牌信息】功能。
【新增】微信自定义交易组件增加【品牌信息】审核回调验证功能。
This commit is contained in:
JianWeie
2022-03-21 04:10:58 +08:00
parent 88dec4dd21
commit 37c3ff7bf3
36 changed files with 3907 additions and 106 deletions

View File

@@ -0,0 +1,585 @@
/***********************************************************************
* 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]
public class WeChatTransactionComponentBrandAuditController : ControllerBase
{
private readonly IWebHostEnvironment _webHostEnvironment;
private readonly IWeChatTransactionComponentBrandAuditServices _weChatTransactionComponentBrandAuditServices;
private readonly 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
}
}

View File

@@ -843,6 +843,74 @@ namespace CoreCms.Net.Web.Admin.Controllers
}
#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
}
}