初始提交
This commit is contained in:
161
Services/Hncore.Pass.Sells/Controllers/CouponController.cs
Normal file
161
Services/Hncore.Pass.Sells/Controllers/CouponController.cs
Normal file
@@ -0,0 +1,161 @@
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Sells.Domain;
|
||||
using Hncore.Pass.Sells.Model;
|
||||
using Hncore.Pass.Sells.Request.RedeemCode;
|
||||
using Hncore.Pass.Sells.Service;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Live.Controllers
|
||||
{
|
||||
[ApiVersion("1.0")]
|
||||
[Route("api/sells/v{version:apiVersion}/coupon/[action]")]
|
||||
public class CouponController : HncoreControllerBase
|
||||
{
|
||||
CouponService m_CouponService;
|
||||
CouponResourceService m_CouponResource;
|
||||
|
||||
public CouponController(CouponService _CouponService
|
||||
, CouponResourceService _CouponResource)
|
||||
{
|
||||
m_CouponService = _CouponService;
|
||||
m_CouponResource = _CouponResource;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> Post([FromBody]PostCouponRequest request)
|
||||
{
|
||||
var entity = request.MapTo<CouponEntity>();
|
||||
if (entity.Name.NotHas())
|
||||
{
|
||||
return Error("名称不能为空");
|
||||
}
|
||||
if (m_CouponService.Exist(m => m.Name == entity.Name))
|
||||
{
|
||||
return Error("名称已经存在了");
|
||||
}
|
||||
var ret = await m_CouponService.Add(entity);
|
||||
return Success();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> Put([FromBody]PostCouponRequest request)
|
||||
{
|
||||
var entity = await m_CouponService.GetById(request.Id);
|
||||
if (entity == null)
|
||||
{
|
||||
return Error("优惠券不存在");
|
||||
}
|
||||
if (request.Name.NotHas())
|
||||
{
|
||||
return Error("名称不能为空");
|
||||
}
|
||||
if (m_CouponService.Exist(m => m.Id != request.Id && m.Name == request.Name))
|
||||
{
|
||||
return Error("名称已经存在了");
|
||||
}
|
||||
|
||||
entity.Name = request.Name;
|
||||
entity.AllowMinAmount = request.AllowMinAmount;
|
||||
entity.CouponType = request.CouponType;
|
||||
entity.CouponValue = request.CouponValue;
|
||||
entity.DateRule = request.DateRule;
|
||||
if (entity.DateRule == ECouponDateRule.BenginEnd)
|
||||
{
|
||||
entity.EndDate = request.EndDate;
|
||||
entity.StartDate = request.StartDate;
|
||||
}
|
||||
else
|
||||
{
|
||||
entity.ValidDay = request.ValidDay;
|
||||
}
|
||||
await m_CouponService.Update(entity);
|
||||
return Success();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> Disabled([FromQuery]int Id)
|
||||
{
|
||||
var redeemCode = await m_CouponService.GetById(Id);
|
||||
if (redeemCode == null)
|
||||
{
|
||||
return Error("该优惠券不存在");
|
||||
}
|
||||
redeemCode.Disabled = 1;
|
||||
await m_CouponService.Update(redeemCode);
|
||||
return Success();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> Delete([FromQuery]int id)
|
||||
{
|
||||
await m_CouponService.DeleteById(id);
|
||||
return Success();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public ApiResult Deletes([FromBody] List<int> ids)
|
||||
{
|
||||
ids.ForEach(async m => await m_CouponService.DeleteById(m));
|
||||
return Success();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<ApiResult> Get([FromQuery] int id)
|
||||
{
|
||||
var ret = await m_CouponService.GetById(id);
|
||||
return Success(ret);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
[HttpGet]
|
||||
public async Task<ApiResult> Page([FromQuery]PageRequestBase request)
|
||||
{
|
||||
Expression<Func<CouponEntity, bool>> expr = m =>
|
||||
string.IsNullOrEmpty(request.KeyWord)
|
||||
|| (m.Name.Contains(request.KeyWord));
|
||||
|
||||
var ret = await m_CouponService.Page(request.PageIndex, request.PageSize, expr);
|
||||
var data = ret.ToApiResult();
|
||||
return data;
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> Give([FromBody]GiveCouponModelRequest request)
|
||||
{
|
||||
if (request.CouponId==0)
|
||||
{
|
||||
return Error("请选择优惠券");
|
||||
}
|
||||
if (request.UserId == 0)
|
||||
{
|
||||
return Error("请选择用户");
|
||||
}
|
||||
await this.m_CouponService.Give(request.CouponId, this.Request.GetManageUserInfo().OperaterId.ToString(), request.UserId, 1);
|
||||
return Success();
|
||||
}
|
||||
[HttpPost]
|
||||
public async Task<ApiResult> Freeze([FromQuery]int originId)
|
||||
{
|
||||
await m_CouponService.Freeze(originId);
|
||||
return Success();
|
||||
}
|
||||
[HttpGet,UserAuth]
|
||||
public async Task<ApiResult> GetAvailableCoupon()
|
||||
{
|
||||
var userId = this.Request.GetUserInfo().UserId;
|
||||
var ret = await m_CouponService.GetUserAvailableCoupon(userId);
|
||||
return Success(ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
100
Services/Hncore.Pass.Sells/Controllers/TaoBaoController.cs
Normal file
100
Services/Hncore.Pass.Sells/Controllers/TaoBaoController.cs
Normal file
@@ -0,0 +1,100 @@
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Sells.Domain;
|
||||
using Hncore.Pass.Sells.Request.RedeemCode;
|
||||
using Hncore.Pass.Sells.Service;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using System.Threading.Tasks;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using Hncore.Infrastructure.EntitiesExtension;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Hncore.Infrastructure.Common;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Live.Controllers
|
||||
{
|
||||
[ApiVersion("1.0")]
|
||||
[Route("api/sells/v{version:apiVersion}/taobao/[action]")]
|
||||
public class TaoBaoController : HncoreControllerBase
|
||||
{
|
||||
SellerTaoBaoService m_SellerTaoBaoService;
|
||||
|
||||
public TaoBaoController(SellerTaoBaoService _SellerTaoBaoService)
|
||||
{
|
||||
m_SellerTaoBaoService = _SellerTaoBaoService;
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
public async Task<ApiResult> Get([FromQuery] int id)
|
||||
{
|
||||
var ret = await m_SellerTaoBaoService.GetById(id);
|
||||
return Success(ret);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
[HttpGet]
|
||||
public async Task<ApiResult> Page([FromQuery]TaoBaoRequest request)
|
||||
{
|
||||
Expression<Func<TaoBaoOrderEntity, bool>> expr = m => 1 == 1;
|
||||
|
||||
if (request.KeyWord.Has())
|
||||
{
|
||||
expr = expr.And(m => m.Phone.Contains(request.KeyWord));
|
||||
expr = expr.Or(m => m.Tid.Contains(request.KeyWord));
|
||||
expr = expr.Or(m => m.BuyerNick.Contains(request.KeyWord));
|
||||
}
|
||||
if (request.BTime.HasValue && request.ETime.HasValue)
|
||||
{
|
||||
expr = expr.And(m => m.Created >= request.BTime && m.Created <= request.ETime);
|
||||
}
|
||||
var ret = await m_SellerTaoBaoService.PageDesc(request.PageIndex, request.PageSize, expr,true,m=>m.Id);
|
||||
|
||||
var data = ret.ToApiResult();
|
||||
return data;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> Export([FromQuery]TaoBaoRequest request)
|
||||
{
|
||||
Expression<Func<TaoBaoOrderEntity, bool>> expr = m => 1 == 1;
|
||||
if (request.BTime.HasValue && request.ETime.HasValue)
|
||||
{
|
||||
expr = expr.And(m => m.CreateDate >= request.BTime && m.CreateDate <= request.ETime);
|
||||
}
|
||||
var ret = await m_SellerTaoBaoService.Query(expr).ToListAsync();
|
||||
|
||||
|
||||
var data = new ExcelData<TaoBaoOrderEntity>
|
||||
{
|
||||
SheetName = DateTime.Now.ToString("yyyy-MM-dd"),
|
||||
Data = ret
|
||||
};
|
||||
|
||||
var title = new List<ExcelTitle>(){
|
||||
new ExcelTitle { Property = "Created", Title = "创建日期" ,Format=(val)=>((DateTime) val).ToString("yyyy-MM-dd hh:mm:ss")},
|
||||
new ExcelTitle { Property = "Tid", Title = "订单号" },
|
||||
new ExcelTitle { Property = "SellerNick", Title = "销售人" },
|
||||
new ExcelTitle { Property = "BuyerNick", Title = "购买人" },
|
||||
new ExcelTitle { Property = "Phone", Title = "购买人手机号" },
|
||||
new ExcelTitle { Property = "Price", Title = "单价" },
|
||||
new ExcelTitle { Property = "Num", Title = "数量" },
|
||||
new ExcelTitle { Property = "TotalFee", Title = "订单金额" },
|
||||
new ExcelTitle { Property = "Payment", Title = "实付金额" }
|
||||
};
|
||||
var fileBytes = ExcelHelper.ExportListToExcel(data, title);
|
||||
|
||||
var fileName = $"{DateTime.Now.ToString("yyyyMMdd")}淘宝订单明细.xlsx";
|
||||
Response.Headers.Add("X-Suggested-Filename", fileName.UrlEncode());
|
||||
return File(fileBytes, "application/octet-stream", fileName);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
31
Services/Hncore.Pass.Sells/Domain/Coupon/Coupon.cs
Normal file
31
Services/Hncore.Pass.Sells/Domain/Coupon/Coupon.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using Hncore.Infrastructure.DDD;
|
||||
using Hncore.Pass.Sells.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Sells.Domain
|
||||
{
|
||||
public partial class CouponEntity : EntityWithDelete<int>, ITenant
|
||||
{
|
||||
public int TenantId { get; set; } = 0;
|
||||
public int? StoreId { get; set; } = 0;
|
||||
public string Name { get; set; }
|
||||
public string Remark { get; set; }
|
||||
public ECouponType CouponType { get; set; }
|
||||
public int? TotalCount { get; set; }
|
||||
public int? GrantCount { get; set; } = 0;
|
||||
public int? UsedCount { get; set; } = 0;
|
||||
public int? GetLimitCount { get; set; }
|
||||
public ECouponUseRange UseRange { get; set; }
|
||||
public int AllowMinAmount { get; set; }
|
||||
public int CouponValue { get; set; }
|
||||
public ECouponDateRule DateRule { get; set; }
|
||||
public int ValidDay { get; set; }
|
||||
public DateTime? StartDate { get; set; } = DateTime.Now;
|
||||
public DateTime? EndDate { get; set; } = DateTime.Now;
|
||||
public DateTime? CreateDate { get; set; } = DateTime.Now;
|
||||
public int IsOverlay { get; set; }
|
||||
public int IsOpen { get; set; }
|
||||
public int? Disabled { get; set; } = 0;
|
||||
}
|
||||
}
|
||||
18
Services/Hncore.Pass.Sells/Domain/Coupon/CouponResource.cs
Normal file
18
Services/Hncore.Pass.Sells/Domain/Coupon/CouponResource.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using Hncore.Infrastructure.DDD;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Sells.Domain
|
||||
{
|
||||
public partial class CouponResourceEntity : EntityWithDelete<int>, ITenant
|
||||
{
|
||||
public int TenantId { get; set; }
|
||||
public int? StoreId { get; set; }
|
||||
public int? CouponId { get; set; }
|
||||
public int? ResourceId { get; set; }
|
||||
public string ResourceImage { get; set; }
|
||||
public string ResourceName { get; set; }
|
||||
public int? ResourceType { get; set; }
|
||||
public decimal? Price { get; set; }
|
||||
}
|
||||
}
|
||||
25
Services/Hncore.Pass.Sells/Domain/Coupon/CouponUserOrgin.cs
Normal file
25
Services/Hncore.Pass.Sells/Domain/Coupon/CouponUserOrgin.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using Hncore.Infrastructure.DDD;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using static Hncore.Pass.Sells.Domain.Enums;
|
||||
|
||||
namespace Hncore.Pass.Sells.Domain
|
||||
{
|
||||
public partial class CouponUserOrginEntity : EntityWithDelete<int>, ITenant
|
||||
{
|
||||
public int TenantId { get; set; }
|
||||
public int? StoreId { get; set; }
|
||||
public string From { get; set; }
|
||||
public int? ToUser { get; set; }
|
||||
public string ToUserRef { get; set; }
|
||||
public int? CouponId { get; set; }
|
||||
public int? CouponCount { get; set; }
|
||||
public CouponOriginType OriginType { get; set; } = CouponOriginType.Admin;
|
||||
public string Remark { get; set; }
|
||||
public DateTime? CreateDate { get; set; } = DateTime.Now;
|
||||
public DateTime? StartTime { get; set; }
|
||||
public DateTime? EndTime { get; set; }
|
||||
|
||||
public CouponStatus Status { get; set; } = CouponStatus.Origin;
|
||||
}
|
||||
}
|
||||
22
Services/Hncore.Pass.Sells/Domain/Coupon/CouponUserUse.cs
Normal file
22
Services/Hncore.Pass.Sells/Domain/Coupon/CouponUserUse.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using Hncore.Infrastructure.DDD;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Sells.Domain
|
||||
{
|
||||
public partial class CouponUserUseEntity : EntityWithDelete<int>, ITenant
|
||||
{
|
||||
|
||||
public int TenantId { get; set; }
|
||||
public int? StoreId { get; set; }
|
||||
public int? UserId { get; set; }
|
||||
public int? CouponId { get; set; }
|
||||
public int? CouponCount { get; set; }
|
||||
public string OrderNo { get; set; }
|
||||
public decimal? Amount { get; set; }
|
||||
public int? Remark { get; set; }
|
||||
public int? Status { get; set; }
|
||||
public DateTime? CreateDate { get; set; }
|
||||
public int? OrderType { get; set; }
|
||||
}
|
||||
}
|
||||
68
Services/Hncore.Pass.Sells/Domain/CourseContext.cs
Normal file
68
Services/Hncore.Pass.Sells/Domain/CourseContext.cs
Normal file
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using Hncore.Infrastructure.EF;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
|
||||
namespace Hncore.Pass.Sells.Domain
|
||||
{
|
||||
public partial class CourseContext : DbContextBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
/// </summary>
|
||||
/// <param name="options">上下文实体</param>
|
||||
/// <param name="httpContextAccessor">http请求上下文</param>
|
||||
public CourseContext(DbContextOptions<CourseContext> options, IHttpContextAccessor httpContextAccessor) :
|
||||
base(options, httpContextAccessor)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual DbSet<CouponEntity> SellCoupon { get; set; }
|
||||
public virtual DbSet<CouponResourceEntity> SellCouponResource { get; set; }
|
||||
public virtual DbSet<CouponUserOrginEntity> SellCouponUserOrgin { get; set; }
|
||||
public virtual DbSet<CouponUserUseEntity> SellCouponUserUse { get; set; }
|
||||
public virtual DbSet<TaoBaoOrderEntity> SellerTaoBao { get; set; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<CouponEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("sell_coupon");
|
||||
entity.HasKey(p => p.Id);
|
||||
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
});
|
||||
|
||||
modelBuilder.Entity<CouponResourceEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("sell_coupon_resource");
|
||||
entity.HasKey(p => p.Id);
|
||||
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
});
|
||||
|
||||
modelBuilder.Entity<CouponUserOrginEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("sell_coupon_user_orgin");
|
||||
entity.HasKey(p => p.Id);
|
||||
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
});
|
||||
|
||||
modelBuilder.Entity<CouponUserUseEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("sell_coupon_user_use");
|
||||
entity.HasKey(p => p.Id);
|
||||
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
});
|
||||
|
||||
modelBuilder.Entity<TaoBaoOrderEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("sell_taobao");
|
||||
entity.HasKey(p => p.Id);
|
||||
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
});
|
||||
|
||||
base.OnModelCreating(modelBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
38
Services/Hncore.Pass.Sells/Domain/Enums.cs
Normal file
38
Services/Hncore.Pass.Sells/Domain/Enums.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Sells.Domain
|
||||
{
|
||||
public class Enums
|
||||
{
|
||||
public enum CouponOriginType
|
||||
{
|
||||
|
||||
[DisplayName("管理员赠送")]
|
||||
Admin = 1,
|
||||
[DisplayName("淘宝下单")]
|
||||
TaoBao = 2,
|
||||
[DisplayName("用户")]
|
||||
User = 3,
|
||||
[DisplayName("关注公众号")]
|
||||
MP = 4,
|
||||
[DisplayName("完善信息")]
|
||||
UserInfo = 5,
|
||||
}
|
||||
|
||||
public enum CouponStatus
|
||||
{
|
||||
|
||||
[DisplayName("认领")]
|
||||
Origin = 1,
|
||||
[DisplayName("使用")]
|
||||
Used = 2,
|
||||
[DisplayName("冻结")]
|
||||
Disabled = 3,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using Hncore.Infrastructure.DDD;
|
||||
using Hncore.Pass.Sells.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Sells.Domain
|
||||
{
|
||||
public partial class TaoBaoOrderEntity
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int? Num { get; set; }
|
||||
public string Tid { get; set; }
|
||||
public string Platform { get; set; }
|
||||
public string PlatformUserId { get; set; }
|
||||
public string ReceiverName { get; set; }
|
||||
public string Phone { get; set; }
|
||||
public string ReceiverAddress { get; set; }
|
||||
public string BuyerArea { get; set; }
|
||||
public string Status { get; set; }
|
||||
public string SellerNick { get; set; }
|
||||
public string BuyerNick { get; set; }
|
||||
public string BuyerMessage { get; set; }
|
||||
public decimal? Price { get; set; }
|
||||
|
||||
public decimal? TotalFee { get; set; }
|
||||
public decimal? Payment { get; set; }
|
||||
public DateTime? Created { get; set; }
|
||||
public string TradeFrom { get; set; }
|
||||
public string SellerMemo { get; set; }
|
||||
public string SkuPropertiesName { get; set; }
|
||||
public int? SellerFlag { get; set; }
|
||||
public DateTime CreateDate { get; set; } = DateTime.Now;
|
||||
}
|
||||
}
|
||||
35
Services/Hncore.Pass.Sells/Hncore.Pass.Sells.csproj
Normal file
35
Services/Hncore.Pass.Sells/Hncore.Pass.Sells.csproj
Normal file
@@ -0,0 +1,35 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
|
||||
<ServerGarbageCollection>false</ServerGarbageCollection>
|
||||
<ConcurrentGarbageCollection>true</ConcurrentGarbageCollection>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.App">
|
||||
<PrivateAssets Condition="'%(PackageReference.Version)' == ''">all</PrivateAssets>
|
||||
<Publish Condition="'%(PackageReference.Version)' == ''">true</Publish>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" />
|
||||
<PackageReference Include="NPinyin.Core" Version="2.1.3" />
|
||||
<PackageReference Include="PinYinConverterCore" Version="1.0.2" />
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.2.0" />
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql.Design" Version="1.1.2" />
|
||||
<PackageReference Include="ThoughtWorks.QRCode.Core" Version="1.0.1.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Infrastructure\Hncore.Infrastructure\Hncore.Infrastructure.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="AppData\" />
|
||||
<Folder Include="ServiceClient\" />
|
||||
<Folder Include="Utils\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
18
Services/Hncore.Pass.Sells/Map/MapConfig.cs
Normal file
18
Services/Hncore.Pass.Sells/Map/MapConfig.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using Hncore.Infrastructure.Extension;
|
||||
using Hncore.Pass.Sells.Domain;
|
||||
using Hncore.Pass.Sells.Model;
|
||||
using Hncore.Pass.Sells.Request.RedeemCode;
|
||||
|
||||
namespace Hncore.Pass.Sells.Map
|
||||
{
|
||||
public class MapConfig
|
||||
{
|
||||
public static void Config()
|
||||
{
|
||||
|
||||
TinyMapperExtension.Binds<CouponEntity, PostCouponRequest>();
|
||||
|
||||
TinyMapperExtension.Binds<CouponResourceEntity, ResourceModel>();
|
||||
}
|
||||
}
|
||||
}
|
||||
52
Services/Hncore.Pass.Sells/Model/Enums.cs
Normal file
52
Services/Hncore.Pass.Sells/Model/Enums.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Hncore.Pass.Sells.Model
|
||||
{
|
||||
public enum RedeemCodeActivityStatus
|
||||
{
|
||||
[DisplayName("已失效")]
|
||||
Disabled = 0,
|
||||
[DisplayName("未开始")]
|
||||
NoStart = 1,
|
||||
[DisplayName("进行中")]
|
||||
Doing = 2,
|
||||
[DisplayName("已结束")]
|
||||
Over = 3,
|
||||
}
|
||||
|
||||
public enum RedeemCodeStatus
|
||||
{
|
||||
[DisplayName("已失效")]
|
||||
Disabled = 0,
|
||||
[DisplayName("未使用")]
|
||||
NoUsed = 1,
|
||||
[DisplayName("已经使用")]
|
||||
Used = 2,
|
||||
}
|
||||
|
||||
public enum ECouponType
|
||||
{
|
||||
[DisplayName("满减券")]
|
||||
Minus = 1,
|
||||
[DisplayName("折扣券")]
|
||||
Discount =2,
|
||||
}
|
||||
|
||||
public enum ECouponUseRange
|
||||
{
|
||||
[DisplayName("所有商品")]
|
||||
All = 1,
|
||||
[DisplayName("制定商品")]
|
||||
Limit = 2,
|
||||
}
|
||||
|
||||
public enum ECouponDateRule
|
||||
{
|
||||
[DisplayName("起止时间")]
|
||||
BenginEnd = 1,
|
||||
[DisplayName("领取当天起")]
|
||||
BeginCurrent = 2,
|
||||
[DisplayName("领取次日起")]
|
||||
BeginMorrow = 3,
|
||||
}
|
||||
}
|
||||
16
Services/Hncore.Pass.Sells/Model/ResourceModel.cs
Normal file
16
Services/Hncore.Pass.Sells/Model/ResourceModel.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Sells.Model
|
||||
{
|
||||
public class ResourceModel
|
||||
{
|
||||
public int? ResourceId { get; set; }
|
||||
public string ResourceImage { get; set; }
|
||||
public string ResourceName { get; set; }
|
||||
public int? ResourceType { get; set; }
|
||||
public decimal? Price { get; set; }
|
||||
}
|
||||
}
|
||||
20
Services/Hncore.Pass.Sells/Model/UserCouponModel.cs
Normal file
20
Services/Hncore.Pass.Sells/Model/UserCouponModel.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using Hncore.Pass.Sells.Domain;
|
||||
using System;
|
||||
|
||||
namespace Hncore.Pass.Sells.Model
|
||||
{
|
||||
public class UserCouponModel
|
||||
{
|
||||
public int Count { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public CouponUserOrginEntity Orgin { get; set; }
|
||||
public CouponEntity Coupon { get; set; }
|
||||
|
||||
public int ValidDays { get => (this.Orgin.EndTime.Value - this.Orgin.StartTime.Value).Days; }
|
||||
|
||||
public bool IsUsed { get => Orgin.Status==Enums.CouponStatus.Used; }
|
||||
|
||||
public bool IsExpired { get => DateTime.Now> this.Orgin.EndTime; }
|
||||
|
||||
}
|
||||
}
|
||||
27
Services/Hncore.Pass.Sells/Program.cs
Normal file
27
Services/Hncore.Pass.Sells/Program.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using Hncore.Infrastructure.Common;
|
||||
using Microsoft.AspNetCore;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Sells
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
|
||||
{
|
||||
LogHelper.Fatal("未捕获的异常", e.ExceptionObject.ToString());
|
||||
};
|
||||
|
||||
TaskScheduler.UnobservedTaskException += (_, ev) => { LogHelper.Fatal("未捕获的异常", ev.Exception); };
|
||||
|
||||
CreateWebHostBuilder(args).Build().Run();
|
||||
}
|
||||
|
||||
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
|
||||
WebHost.CreateDefaultBuilder(args)
|
||||
.UseStartup<Startup>();
|
||||
}
|
||||
}
|
||||
27
Services/Hncore.Pass.Sells/Properties/launchSettings.json
Normal file
27
Services/Hncore.Pass.Sells/Properties/launchSettings.json
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:16867",
|
||||
"sslPort": 44324
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"Hncore.Pass.Sells": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "http://localhost:5000"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using Hncore.Pass.Sells.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Sells.Request.RedeemCode
|
||||
{
|
||||
public class GiveCouponModelRequest
|
||||
{
|
||||
public int CouponId { get; set; }
|
||||
public int UserId { get; set; }
|
||||
public int Count { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using Hncore.Pass.Sells.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Sells.Request.RedeemCode
|
||||
{
|
||||
public class PostCouponRequest
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Remark { get; set; }
|
||||
public ECouponType CouponType { get; set; }
|
||||
public int? TotalCount { get; set; }
|
||||
public int? GrantCount { get; set; } = 0;
|
||||
public int? UsedCount { get; set; } = 0;
|
||||
public int? GetLimitCount { get; set; }
|
||||
public ECouponUseRange UseRange { get; set; }
|
||||
public int AllowMinAmount { get; set; }
|
||||
public int AllowMaxAmount { get; set; }
|
||||
public int CouponValue { get; set; }
|
||||
public ECouponDateRule DateRule { get; set; }
|
||||
public int ValidDay { get; set; }
|
||||
public DateTime? StartDate { get; set; }
|
||||
public DateTime? EndDate { get; set; }
|
||||
public DateTime? CreateDate { get; set; } = DateTime.Now;
|
||||
public int IsOpen { get; set; }
|
||||
public int? Disabled { get; set; } = 0;
|
||||
|
||||
public List<ResourceModel> Resource { get; set; }
|
||||
}
|
||||
}
|
||||
13
Services/Hncore.Pass.Sells/Request/Coupon/TaoBaoRequest.cs
Normal file
13
Services/Hncore.Pass.Sells/Request/Coupon/TaoBaoRequest.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using System;
|
||||
|
||||
namespace Hncore.Pass.Sells.Request.RedeemCode
|
||||
{
|
||||
public class TaoBaoRequest: PageRequestBase
|
||||
{
|
||||
|
||||
public DateTime? BTime { get; set; }
|
||||
|
||||
public DateTime? ETime { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Pass.Sells.Domain;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace Hncore.Pass.Sells.Service
|
||||
{
|
||||
public class CouponResourceService : ServiceBase<CouponResourceEntity>, IFindService
|
||||
{
|
||||
CourseContext m_DbContext;
|
||||
public CouponResourceService(CourseContext dbContext, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
m_DbContext = dbContext;
|
||||
}
|
||||
}
|
||||
}
|
||||
142
Services/Hncore.Pass.Sells/Service/Coupon/CouponService.cs
Normal file
142
Services/Hncore.Pass.Sells/Service/Coupon/CouponService.cs
Normal file
@@ -0,0 +1,142 @@
|
||||
using Hncore.Infrastructure.Common;
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Pass.Sells.Domain;
|
||||
using Hncore.Pass.Sells.Model;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using static Hncore.Pass.Sells.Domain.Enums;
|
||||
using Hncore.Infrastructure.Extension;
|
||||
namespace Hncore.Pass.Sells.Service
|
||||
{
|
||||
public class CouponService : ServiceBase<CouponEntity>, IFindService
|
||||
{
|
||||
CourseContext m_DbContext;
|
||||
CouponUserOrginService m_CouponUserOrginService;
|
||||
public CouponService(CouponUserOrginService m_CouponUserOrginService
|
||||
, CourseContext dbContext
|
||||
, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
m_DbContext = dbContext;
|
||||
this.m_CouponUserOrginService = m_CouponUserOrginService;
|
||||
}
|
||||
|
||||
public async Task<bool> Give(int couponId, string fromUser, int toUser, int count, CouponOriginType originType= CouponOriginType.Admin, string remark = "系统赠送", string toUserRef="")
|
||||
{
|
||||
var orginCoupon = new CouponUserOrginEntity()
|
||||
{
|
||||
CouponCount = count,
|
||||
CouponId = couponId,
|
||||
Remark = originType.GetEnumDisplayName(),
|
||||
From = fromUser,
|
||||
ToUser = toUser,
|
||||
OriginType= originType,
|
||||
ToUserRef= toUserRef
|
||||
};
|
||||
var coupon = await this.GetById(couponId);
|
||||
if (coupon == null || coupon.Disabled == 1)
|
||||
return false;
|
||||
using (var tran = await m_DbContext.Database.BeginTransactionAsync())
|
||||
{
|
||||
try
|
||||
{
|
||||
if (coupon.DateRule == ECouponDateRule.BeginCurrent)
|
||||
{
|
||||
orginCoupon.StartTime = DateTime.Now;
|
||||
orginCoupon.EndTime = DateTime.Now.AddDays(coupon.ValidDay);
|
||||
}
|
||||
else if (coupon.DateRule == ECouponDateRule.BeginMorrow)
|
||||
{
|
||||
orginCoupon.StartTime = DateTime.Now.AddDays(1);
|
||||
orginCoupon.EndTime = DateTime.Now.AddDays(coupon.ValidDay + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
orginCoupon.StartTime = coupon.StartDate;
|
||||
orginCoupon.EndTime = coupon.EndDate;
|
||||
}
|
||||
|
||||
await m_CouponUserOrginService.Add(orginCoupon);
|
||||
coupon.GrantCount++;
|
||||
await this.Update(coupon);
|
||||
tran.Commit();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Error("Give", ex);
|
||||
tran.Rollback();
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public async Task<List<UserCouponModel>> GetUserCoupon(int userId)
|
||||
{
|
||||
var oroginCoupons = m_CouponUserOrginService.Query(m => m.ToUser == userId);
|
||||
|
||||
var hasCoupon = from orgin in oroginCoupons
|
||||
join coupon in this.Query(true) on orgin.CouponId equals coupon.Id
|
||||
select new UserCouponModel { Count = 1, UserId = orgin.ToUser.Value, Coupon = coupon, Orgin = orgin };
|
||||
|
||||
return await hasCoupon.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<bool> Use(int couponId, string orderNo, int userId, int count)
|
||||
{
|
||||
var userOrginCoupons = await GetUserAvailableCoupon(userId);
|
||||
|
||||
var oneCoupon = userOrginCoupons.OrderBy(m => m.ValidDays).FirstOrDefault();
|
||||
if (oneCoupon == null)
|
||||
return false;
|
||||
oneCoupon.Orgin.Status = CouponStatus.Used;
|
||||
await m_CouponUserOrginService.Update(oneCoupon.Orgin);
|
||||
return true;
|
||||
}
|
||||
|
||||
public async Task<List<UserCouponModel>> GetUserAvailableCoupon(int userId)
|
||||
{
|
||||
var oroginCoupons=m_CouponUserOrginService.Query(m =>m.ToUser==userId&& m.Status == CouponStatus.Origin && m.ToUser == userId && DateTime.Now > m.StartTime && DateTime.Now <= m.EndTime);
|
||||
|
||||
var hasCoupon = from orgin in oroginCoupons
|
||||
join coupon in this.Query(true) on orgin.CouponId equals coupon.Id
|
||||
select new UserCouponModel { Count =1,UserId=orgin.ToUser.Value, Coupon = coupon, Orgin = orgin };
|
||||
|
||||
return await hasCoupon.ToListAsync();
|
||||
}
|
||||
|
||||
public async Task<UserCouponModel> GetOneUserAvailableCoupon(int userId,int couponId)
|
||||
{
|
||||
var oroginCoupons = m_CouponUserOrginService.Query(m => m.ToUser == userId && m.Status == CouponStatus.Origin && m.ToUser == userId && DateTime.Now > m.StartTime && DateTime.Now <= m.EndTime);
|
||||
|
||||
oroginCoupons=oroginCoupons.Where(m => m.CouponId == couponId);
|
||||
var hasCoupon = from orgin in oroginCoupons
|
||||
join coupon in this.Query(true) on orgin.CouponId equals coupon.Id
|
||||
select new UserCouponModel { Count = 1, UserId = orgin.ToUser.Value, Coupon = coupon, Orgin = orgin };
|
||||
|
||||
return await hasCoupon.FirstOrDefaultAsync();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public async Task<bool> TaoBaoGive(int userId, int couponId,string taobao)
|
||||
{
|
||||
if (m_CouponUserOrginService.Exist(m => (m.ToUser == userId||m.ToUserRef== taobao) && m.CreateDate.Value.Month == DateTime.Now.Month))
|
||||
return false;
|
||||
return await this.Give(couponId, "", userId, 1, CouponOriginType.TaoBao);
|
||||
}
|
||||
|
||||
public async Task<bool> Freeze(int originId)
|
||||
{
|
||||
var entity = await m_CouponUserOrginService.GetById(originId);
|
||||
entity.Status = CouponStatus.Disabled;
|
||||
await m_CouponUserOrginService.Update(entity);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Pass.Sells.Domain;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using static Hncore.Pass.Sells.Domain.Enums;
|
||||
|
||||
namespace Hncore.Pass.Sells.Service
|
||||
{
|
||||
public class CouponUserOrginService : ServiceBase<CouponUserOrginEntity>, IFindService
|
||||
{
|
||||
CourseContext m_DbContext;
|
||||
public CouponUserOrginService(CourseContext dbContext, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
m_DbContext = dbContext;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Pass.Sells.Domain;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Hncore.Pass.Sells.Service
|
||||
{
|
||||
public class CouponUserUseService : ServiceBase<CouponUserUseEntity>, IFindService
|
||||
{
|
||||
CourseContext m_DbContext;
|
||||
public CouponUserUseService(CourseContext dbContext, IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
m_DbContext = dbContext;
|
||||
}
|
||||
|
||||
public async Task<List<CouponUserUseEntity>> GetUsedCoupon(int userId, int couponId = 0)
|
||||
{
|
||||
var ret = await this.Query(m => m.UserId == userId && (couponId == 0 || m.CouponId == couponId)).ToListAsync();
|
||||
var origins = ret.GroupBy(m => m.CouponId).Select(m =>
|
||||
{
|
||||
var usedCoupon = new CouponUserUseEntity()
|
||||
{
|
||||
CouponCount = m.Sum(p => p.CouponCount),
|
||||
CouponId = m.Key,
|
||||
UserId = userId
|
||||
};
|
||||
return usedCoupon;
|
||||
});
|
||||
return origins.ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
136
Services/Hncore.Pass.Sells/Service/SellerTaoBaoService.cs
Normal file
136
Services/Hncore.Pass.Sells/Service/SellerTaoBaoService.cs
Normal file
@@ -0,0 +1,136 @@
|
||||
using Hncore.Infrastructure.Common;
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Pass.Sells.Domain;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Hncore.Infrastructure.Serializer;
|
||||
using System;
|
||||
using System.Security.Cryptography;
|
||||
|
||||
namespace Hncore.Pass.Sells.Service
|
||||
{
|
||||
public class SellerTaoBaoService : ServiceBase<TaoBaoOrderEntity>, IFindService
|
||||
{
|
||||
CourseContext m_DbContext;
|
||||
|
||||
public SellerTaoBaoService(
|
||||
CourseContext dbContext
|
||||
,IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
m_DbContext = dbContext;
|
||||
}
|
||||
|
||||
public async override Task<TaoBaoOrderEntity> Add(TaoBaoOrderEntity entity, bool autoSave = true)
|
||||
{
|
||||
if (!this.Exist(m => m.Tid == entity.Tid))
|
||||
{
|
||||
return await base.Add(entity, autoSave);
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
public async Task<string> ReceivedMsg(HttpRequest request, Func<string, Task<bool>> process)
|
||||
{
|
||||
string appSecret = "xrzmtmfv46mmt9c9rzt2g7c74h9g7u7u";
|
||||
long timestamp = long.Parse(request.Query["timestamp"]);
|
||||
long aopic = long.Parse(request.Query["aopic"]); // 根据aopic判断推送类型
|
||||
string sign = request.Query["sign"];
|
||||
string json = request.Form["json"];
|
||||
|
||||
|
||||
LogHelper.Info("淘宝回调", $"timestamp={timestamp},aopic={aopic},sign={sign},json={json}");
|
||||
|
||||
var dictParams = new Dictionary<string, string>();
|
||||
dictParams.Add("timestamp", timestamp.ToString());
|
||||
dictParams.Add("json", json);
|
||||
var checkSign = Sign(dictParams, appSecret);
|
||||
if (!string.Equals(checkSign, sign))
|
||||
{
|
||||
LogHelper.Error("淘宝回调验签失败", checkSign);
|
||||
return "验签失败";
|
||||
}
|
||||
// 验签通过进行相关的业务
|
||||
|
||||
/*
|
||||
* 返回空字符或者不返回,不进行任何操作
|
||||
* 返回规定格式,进行相应操作。允许的操作有更新发货状态、更新备注、生成旺旺消息
|
||||
* DoDummySend:更新发货状态(false不更新发货状态)
|
||||
* DoMemoUpdate:更新备注(null不更新备注)。Flag是旗帜,可以传0-5的数字,如果传-1或者不传此参数,则保留原旗帜;Memo为备注内容
|
||||
* AliwwMsg:想要发给买家的旺旺消息(null或空字符串,不发消息)
|
||||
*/
|
||||
if (process != null)
|
||||
{
|
||||
if (await process(json))
|
||||
{
|
||||
var returnJson = new
|
||||
{
|
||||
DoDummySend = true,
|
||||
DoMemoUpdate = new
|
||||
{
|
||||
Flag = 1,
|
||||
Memo = "购买成功"
|
||||
},
|
||||
AliwwMsg = "购买成功"
|
||||
};
|
||||
return returnJson.ToJson();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
//参数签名
|
||||
public string Sign(IDictionary<string, string> args, string ClientSecret)
|
||||
{
|
||||
IDictionary<string, string> sortedParams = new SortedDictionary<string, string>(args, StringComparer.Ordinal);
|
||||
string str = "";
|
||||
foreach (var m in sortedParams)
|
||||
{
|
||||
str += (m.Key + m.Value);
|
||||
}
|
||||
//头尾加入AppSecret
|
||||
str = ClientSecret + str + ClientSecret;
|
||||
var encodeStr = MD5Encrypt(str).ToUpper();
|
||||
return encodeStr;
|
||||
}
|
||||
|
||||
//Md5摘要
|
||||
public static string MD5Encrypt(string text)
|
||||
{
|
||||
MD5 md5 = new MD5CryptoServiceProvider();
|
||||
byte[] fromData = System.Text.Encoding.UTF8.GetBytes(text);
|
||||
byte[] targetData = md5.ComputeHash(fromData);
|
||||
string byte2String = null;
|
||||
|
||||
for (int i = 0; i < targetData.Length; i++)
|
||||
{
|
||||
byte2String += targetData[i].ToString("x2");
|
||||
}
|
||||
|
||||
return byte2String;
|
||||
}
|
||||
|
||||
|
||||
public async Task<string> Test()
|
||||
{
|
||||
string appSecret = "xrzmtmfv46mmt9c9rzt2g7c74h9g7u7u";
|
||||
long timestamp = 1585122176;
|
||||
long aopic = 2; // 根据aopic判断推送类型
|
||||
string sign = "442B91FB4811A8899EBEA689205F98A1";
|
||||
string json = "{\"Platform\":\"TAOBAO\",\"PlatformUserId\":\"619727442\",\"ReceiverName\":null,\"ReceiverMobile\":\"15538302361\",\"ReceiverPhone\":null,\"ReceiverAddress\":null,\"BuyerArea\":null,\"ExtendedFields\":{},\"Tid\":908706240358624821,\"Status\":\"WAIT_SELLER_SEND_GOODS\",\"SellerNick\":\"可乐开发商\",\"BuyerNick\":\"woai853133256\",\"Type\":null,\"BuyerMessage\":null,\"Price\":\"1.00\",\"Num\":6,\"TotalFee\":\"6.00\",\"Payment\":\"6.00\",\"PayTime\":null,\"PicPath\":\"https://img.alicdn.com/bao/uploaded/i3/619727442/TB2ZSA.XNvxQeBjy0FiXXXioXXa_!!619727442.png\",\"PostFee\":\"0.00\",\"Created\":\"2020-03-25 15:42:50\",\"TradeFrom\":\"WAP,WAP\",\"Orders\":[{\"Oid\":908706240358624821,\"NumIid\":537279953649,\"OuterIid\":null,\"OuterSkuId\":null,\"Title\":\"老客户续费连接\",\"Price\":\"1.00\",\"Num\":6,\"TotalFee\":\"6.00\",\"Payment\":\"6.00\",\"PicPath\":\"https://img.alicdn.com/bao/uploaded/i3/619727442/TB2ZSA.XNvxQeBjy0FiXXXioXXa_!!619727442.png\",\"SkuId\":\"3208012025040\",\"SkuPropertiesName\":\"付费方式:月付;服务器套餐:套餐1;对应金额:1元选项\",\"DivideOrderFee\":null,\"PartMjzDiscount\":null}],\"SellerMemo\":null,\"SellerFlag\":0,\"CreditCardFee\":null}";
|
||||
|
||||
|
||||
var dictParams = new Dictionary<string, string>();
|
||||
dictParams.Add("timestamp", timestamp.ToString());
|
||||
dictParams.Add("json", json);
|
||||
var checkSign = Sign(dictParams, appSecret);
|
||||
if (!string.Equals(checkSign, sign))
|
||||
{
|
||||
LogHelper.Error("淘宝回调验签失败", checkSign);
|
||||
return "验签失败";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
50
Services/Hncore.Pass.Sells/Startup.cs
Normal file
50
Services/Hncore.Pass.Sells/Startup.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using Hncore.Infrastructure.Service;
|
||||
using Hncore.Infrastructure.WebApi;
|
||||
using Hncore.Pass.Sells.Domain;
|
||||
using Hncore.Pass.Sells.Map;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
|
||||
namespace Hncore.Pass.Sells
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public IConfiguration Configuration { get; }
|
||||
|
||||
public Startup(IHostingEnvironment env)
|
||||
{
|
||||
Configuration = env.UseAppsettings();
|
||||
}
|
||||
|
||||
public IServiceProvider ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddDbContext<CourseContext>(opt => { opt.UseMySql(Configuration["MySql"]); });
|
||||
|
||||
RedisHelper.Initialization(new CSRedis.CSRedisClient(Configuration["Redis"]));
|
||||
|
||||
services.AddHttpClient();
|
||||
services.AutoAddService();
|
||||
|
||||
services.AddServiceClient(Configuration["Service_BaseUrl"]);
|
||||
|
||||
return services.Init(Configuration, CompatibilityVersion.Version_2_2, new ServiceOption
|
||||
{
|
||||
UseGlobalManageAuthFilter = false,
|
||||
IgnoreJsonNullValue =true
|
||||
});
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IApplicationLifetime applicationLifetime,
|
||||
ILoggerFactory loggerFactory)
|
||||
{
|
||||
app.Init(loggerFactory, applicationLifetime);
|
||||
MapConfig.Config();
|
||||
}
|
||||
}
|
||||
}
|
||||
25
Services/Hncore.Pass.Sells/appsettings.Development.json
Normal file
25
Services/Hncore.Pass.Sells/appsettings.Development.json
Normal file
@@ -0,0 +1,25 @@
|
||||
//{
|
||||
// "MySql": "Server=rm-bp12e1533udh1827azo.mysql.rds.aliyuncs.com;Database=etor_property_test;User=etor_test;Password=etor_test!QAZ2wsx;Convert Zero Datetime=True;TreatTinyAsBoolean=false;",
|
||||
// "Redis": "47.92.85.90:6379,password=etor0070x01,defaultDatabase=7,poolsize=1"
|
||||
//}
|
||||
{
|
||||
"Host_BaseUrl": "http://ipistest.etor.top11",
|
||||
"Wx_Mp_Appid": "wxd6b150a17c252fec",
|
||||
"MySql": "Server=47.92.244.89;Database=property;User=root;Password=qaz123!@#;Convert Zero Datetime=True;TreatTinyAsBoolean=false;port=5000;",
|
||||
"Redis": "47.92.85.90:6379,password=etor0070x01,defaultDatabase=10,poolsize=1",
|
||||
"Service_BaseUrl": "http://localhost:5000",
|
||||
"Wx": {
|
||||
"mp": {
|
||||
"appId": "",
|
||||
"appSecret": "",
|
||||
"mchId": "",
|
||||
"mchKey": ""
|
||||
},
|
||||
"mini": {
|
||||
"appId": "",
|
||||
"appSecret": "",
|
||||
"mchId": "",
|
||||
"mchKey": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
10
Services/Hncore.Pass.Sells/appsettings.Local.json
Normal file
10
Services/Hncore.Pass.Sells/appsettings.Local.json
Normal file
@@ -0,0 +1,10 @@
|
||||
//{
|
||||
// "MySql": "Server=rm-bp12e1533udh1827azo.mysql.rds.aliyuncs.com;Database=etor_property_test;User=etor_test;Password=etor_test!QAZ2wsx;Convert Zero Datetime=True;TreatTinyAsBoolean=false;",
|
||||
// "Redis": "47.92.85.90:6379,password=etor0070x01,defaultDatabase=7,poolsize=1"
|
||||
//}
|
||||
{
|
||||
"Host_BaseUrl": "http://ipistest.etor.top11",
|
||||
"Wx_Mp_Appid": "wxd6b150a17c252fec",
|
||||
"MySql": "Server=47.92.244.89;Database=property;User=root;Password=qaz123!@#;Convert Zero Datetime=True;TreatTinyAsBoolean=false;port=5000;",
|
||||
"Redis": "47.92.85.90:6379,password=etor0070x01,defaultDatabase=10,poolsize=1"
|
||||
}
|
||||
10
Services/Hncore.Pass.Sells/appsettings.Production.json
Normal file
10
Services/Hncore.Pass.Sells/appsettings.Production.json
Normal file
@@ -0,0 +1,10 @@
|
||||
//{
|
||||
// "MySql": "Server=rm-bp12e1533udh1827azo.mysql.rds.aliyuncs.com;Database=etor_property_test;User=etor_test;Password=etor_test!QAZ2wsx;Convert Zero Datetime=True;TreatTinyAsBoolean=false;",
|
||||
// "Redis": "47.92.85.90:6379,password=etor0070x01,defaultDatabase=7,poolsize=1"
|
||||
//}
|
||||
{
|
||||
"Host_BaseUrl": "http://ipistest.etor.top11",
|
||||
"Wx_Mp_Appid": "wxd6b150a17c252fec",
|
||||
"MySql": "Server=47.92.244.89;Database=property;User=root;Password=qaz123!@#;Convert Zero Datetime=True;TreatTinyAsBoolean=false;port=5000;",
|
||||
"Redis": "127.0.0.1:6379,password=123456,defaultDatabase=8,poolsize=1"
|
||||
}
|
||||
8
Services/Hncore.Pass.Sells/appsettings.json
Normal file
8
Services/Hncore.Pass.Sells/appsettings.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
1
Services/Hncore.Pass.Sells/生成模型.bat
Normal file
1
Services/Hncore.Pass.Sells/生成模型.bat
Normal file
@@ -0,0 +1 @@
|
||||
dotnet ef dbcontext scaffold "Server=47.92.244.89;Database=course;User=root;Password=qaz123!@#;Convert Zero Datetime=True;TreatTinyAsBoolean=false;port=5000;" "Pomelo.EntityFrameworkCore.MySql" -o Domain -t sell_coupon -t sell_coupon_resource -t sell_coupon_user_orgin -t sell_coupon_user_use -t sell_fanstool -t sell_fanstool_award -t sell_fanstool_poster -t sell_fanstool_user -t sell_limittime -t sell_limittime_resource -t sell_payaward -t sell_payaward_award -t sell_payaward_limit_resource -t sell_payaward_record -t sell_popad -t sell_popad_record -t sell_redeemcode -t sell_redeemcode_lib -t sell_redeemcode_resource -t sell_seller -t sell_seller_config -t sell_seller_grade -t sell_seller_product -t sell_seller_record -f
|
||||
Reference in New Issue
Block a user