忽略dll文件git
This commit is contained in:
@@ -1,161 +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("<22><><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD><CEAA>");
|
||||
}
|
||||
if (m_CouponService.Exist(m => m.Name == entity.Name))
|
||||
{
|
||||
return Error("<22><><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||
}
|
||||
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("<22>Ż<EFBFBD>ȯ<EFBFBD><C8AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||
}
|
||||
if (request.Name.NotHas())
|
||||
{
|
||||
return Error("<22><><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD><CEAA>");
|
||||
}
|
||||
if (m_CouponService.Exist(m => m.Id != request.Id && m.Name == request.Name))
|
||||
{
|
||||
return Error("<22><><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||
}
|
||||
|
||||
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("<22><><EFBFBD>Ż<EFBFBD>ȯ<EFBFBD><C8AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||
}
|
||||
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>
|
||||
/// <20><>ѯ
|
||||
/// </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("<22><>ѡ<EFBFBD><D1A1><EFBFBD>Ż<EFBFBD>ȯ");
|
||||
}
|
||||
if (request.UserId == 0)
|
||||
{
|
||||
return Error("<22><>ѡ<EFBFBD><D1A1><EFBFBD>û<EFBFBD>");
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
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("<22><><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD><CEAA>");
|
||||
}
|
||||
if (m_CouponService.Exist(m => m.Name == entity.Name))
|
||||
{
|
||||
return Error("<22><><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||
}
|
||||
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("<22>Ż<EFBFBD>ȯ<EFBFBD><C8AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||
}
|
||||
if (request.Name.NotHas())
|
||||
{
|
||||
return Error("<22><><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD><CEAA>");
|
||||
}
|
||||
if (m_CouponService.Exist(m => m.Id != request.Id && m.Name == request.Name))
|
||||
{
|
||||
return Error("<22><><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||
}
|
||||
|
||||
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("<22><><EFBFBD>Ż<EFBFBD>ȯ<EFBFBD><C8AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||
}
|
||||
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>
|
||||
/// <20><>ѯ
|
||||
/// </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("<22><>ѡ<EFBFBD><D1A1><EFBFBD>Ż<EFBFBD>ȯ");
|
||||
}
|
||||
if (request.UserId == 0)
|
||||
{
|
||||
return Error("<22><>ѡ<EFBFBD><D1A1><EFBFBD>û<EFBFBD>");
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,110 +1,110 @@
|
||||
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>
|
||||
/// <20><>ѯ
|
||||
/// </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.shop.Has())
|
||||
{
|
||||
expr = expr.And(m => m.SellerNick.Contains(request.shop));
|
||||
}
|
||||
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);
|
||||
// ret.List.ForEach(
|
||||
// m => {m.Phone = m.Phone.Substring(0,3) + "***";
|
||||
// });
|
||||
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);
|
||||
}
|
||||
if (request.shop.Has())
|
||||
{
|
||||
expr = expr.And(m => m.SellerNick.Contains(request.shop));
|
||||
}
|
||||
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 = "CreateDate", 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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
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>
|
||||
/// <20><>ѯ
|
||||
/// </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.shop.Has())
|
||||
{
|
||||
expr = expr.And(m => m.SellerNick.Contains(request.shop));
|
||||
}
|
||||
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);
|
||||
// ret.List.ForEach(
|
||||
// m => {m.Phone = m.Phone.Substring(0,3) + "***";
|
||||
// });
|
||||
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);
|
||||
}
|
||||
if (request.shop.Has())
|
||||
{
|
||||
expr = expr.And(m => m.SellerNick.Contains(request.shop));
|
||||
}
|
||||
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 = "CreateDate", 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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,31 +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;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +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; }
|
||||
}
|
||||
}
|
||||
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; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +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;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,22 +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; }
|
||||
}
|
||||
}
|
||||
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; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,76 +1,76 @@
|
||||
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; }
|
||||
public virtual DbSet<TaoBaoRefundEntity> SellerTaoBaoRefund { 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();
|
||||
});
|
||||
|
||||
modelBuilder.Entity<TaoBaoRefundEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("sell_taobao_refund");
|
||||
entity.HasKey(p => p.Id);
|
||||
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
});
|
||||
|
||||
base.OnModelCreating(modelBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
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; }
|
||||
public virtual DbSet<TaoBaoRefundEntity> SellerTaoBaoRefund { 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();
|
||||
});
|
||||
|
||||
modelBuilder.Entity<TaoBaoRefundEntity>(entity =>
|
||||
{
|
||||
entity.ToTable("sell_taobao_refund");
|
||||
entity.HasKey(p => p.Id);
|
||||
entity.Property(e => e.Id).ValueGeneratedOnAdd();
|
||||
});
|
||||
|
||||
base.OnModelCreating(modelBuilder);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,38 +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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,34 +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;
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
using Hncore.Infrastructure.DDD;
|
||||
using Hncore.Pass.Sells.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Sells.Domain
|
||||
{
|
||||
public partial class TaoBaoRefundEntity
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string RefundId { get; set; }
|
||||
public string BuyerNick { get; set; }
|
||||
public string RefundFee { get; set; }
|
||||
public string Oid { get; set; }
|
||||
public string Tid { get; set; }
|
||||
public string RefundPhase { get; set; }
|
||||
public string BillType { get; set; }
|
||||
public string SellerNick { get; set; }
|
||||
public string Modified { get; set; }
|
||||
public string Phone { get; set; }
|
||||
public int status { get; set; }
|
||||
}
|
||||
}
|
||||
using Hncore.Infrastructure.DDD;
|
||||
using Hncore.Pass.Sells.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Hncore.Pass.Sells.Domain
|
||||
{
|
||||
public partial class TaoBaoRefundEntity
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string RefundId { get; set; }
|
||||
public string BuyerNick { get; set; }
|
||||
public string RefundFee { get; set; }
|
||||
public string Oid { get; set; }
|
||||
public string Tid { get; set; }
|
||||
public string RefundPhase { get; set; }
|
||||
public string BillType { get; set; }
|
||||
public string SellerNick { get; set; }
|
||||
public string Modified { get; set; }
|
||||
public string Phone { get; set; }
|
||||
public int status { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +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>
|
||||
<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>
|
||||
|
||||
@@ -1,18 +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>();
|
||||
}
|
||||
}
|
||||
}
|
||||
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>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,52 +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,
|
||||
}
|
||||
}
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +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; }
|
||||
}
|
||||
}
|
||||
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; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +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; }
|
||||
|
||||
}
|
||||
}
|
||||
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; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +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>();
|
||||
}
|
||||
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>();
|
||||
}
|
||||
}
|
||||
@@ -1,27 +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"
|
||||
}
|
||||
}
|
||||
{
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +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; }
|
||||
}
|
||||
}
|
||||
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; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,33 +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; }
|
||||
}
|
||||
}
|
||||
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; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
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; }
|
||||
public string shop { get; set; }
|
||||
}
|
||||
}
|
||||
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; }
|
||||
public string shop { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +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;
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,140 +1,140 @@
|
||||
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 && m.Status == CouponStatus.Origin && 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<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)
|
||||
{
|
||||
return await this.Give(couponId, "", userId, 1, CouponOriginType.TaoBao,"系统赠送",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;
|
||||
}
|
||||
}
|
||||
}
|
||||
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 && m.Status == CouponStatus.Origin && 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<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)
|
||||
{
|
||||
return await this.Give(couponId, "", userId, 1, CouponOriginType.TaoBao,"系统赠送",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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +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;
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,35 +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();
|
||||
}
|
||||
}
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,255 +1,255 @@
|
||||
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;
|
||||
using System.Net;
|
||||
using System.Web;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
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<string>> 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)
|
||||
{
|
||||
var msg_info = await process(json);
|
||||
if (msg_info != "")
|
||||
{
|
||||
var returnJson = new
|
||||
{
|
||||
DoDummySend = true,
|
||||
DoMemoUpdate = new
|
||||
{
|
||||
Flag = 1,
|
||||
Memo = msg_info
|
||||
},
|
||||
AliwwMsg = msg_info
|
||||
};
|
||||
return returnJson.ToJson();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public async Task<string> SengMsg(string Tid,string msg)
|
||||
{
|
||||
string appSecret = "xrzmtmfv46mmt9c9rzt2g7c74h9g7u7u";
|
||||
|
||||
|
||||
//阿奇所发送消息
|
||||
string accessToken = "TbAldsa2ph4sa7de69r5vvccm2767evg7k9rs4gsf4273upm8c";
|
||||
|
||||
WebRequest apiRequest = WebRequest.Create("http://gw.api.agiso.com/alds/WwMsg/Send");
|
||||
apiRequest.Method = "POST";
|
||||
apiRequest.ContentType = "application/x-www-form-urlencoded";
|
||||
apiRequest.Headers.Add("Authorization", "Bearer " + accessToken);
|
||||
apiRequest.Headers.Add("ApiVersion", "1");
|
||||
|
||||
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
|
||||
var args = new Dictionary<string,string>()
|
||||
{
|
||||
{"timestamp",Convert.ToInt64(ts.TotalSeconds).ToString()},
|
||||
{"tid",Tid},
|
||||
{"msg",msg},
|
||||
};
|
||||
args.Add("sign", Sign(args, appSecret));
|
||||
|
||||
string postData = "";
|
||||
foreach (var p in args)
|
||||
{
|
||||
if (!String.IsNullOrEmpty(postData))
|
||||
{
|
||||
postData += "&";
|
||||
}
|
||||
string tmpStr = String.Format("{0}={1}", p.Key, HttpUtility.UrlEncode(p.Value));
|
||||
postData += tmpStr;
|
||||
}
|
||||
|
||||
using (var sw = new StreamWriter(apiRequest.GetRequestStream()))
|
||||
{
|
||||
sw.Write(postData);
|
||||
}
|
||||
WebResponse apiResponse = null;
|
||||
try
|
||||
{
|
||||
apiResponse = apiRequest.GetResponse();
|
||||
}
|
||||
catch (WebException we)
|
||||
{
|
||||
if (we.Status == WebExceptionStatus.ProtocolError)
|
||||
{
|
||||
apiResponse = (we.Response as HttpWebResponse);
|
||||
}
|
||||
else{
|
||||
//TODO:处理异常
|
||||
return "";
|
||||
}
|
||||
}
|
||||
using(Stream apiDataStream = apiResponse.GetResponseStream()){
|
||||
using(StreamReader apiReader = new StreamReader(apiDataStream, Encoding.UTF8)){
|
||||
string apiResult = apiReader.ReadToEnd();
|
||||
apiReader.Close();
|
||||
apiResponse.Close();
|
||||
return apiResult;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public async Task<string> ReceivedRefundMsg(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 "";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
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;
|
||||
using System.Net;
|
||||
using System.Web;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
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<string>> 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)
|
||||
{
|
||||
var msg_info = await process(json);
|
||||
if (msg_info != "")
|
||||
{
|
||||
var returnJson = new
|
||||
{
|
||||
DoDummySend = true,
|
||||
DoMemoUpdate = new
|
||||
{
|
||||
Flag = 1,
|
||||
Memo = msg_info
|
||||
},
|
||||
AliwwMsg = msg_info
|
||||
};
|
||||
return returnJson.ToJson();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public async Task<string> SengMsg(string Tid,string msg)
|
||||
{
|
||||
string appSecret = "xrzmtmfv46mmt9c9rzt2g7c74h9g7u7u";
|
||||
|
||||
|
||||
//阿奇所发送消息
|
||||
string accessToken = "TbAldsa2ph4sa7de69r5vvccm2767evg7k9rs4gsf4273upm8c";
|
||||
|
||||
WebRequest apiRequest = WebRequest.Create("http://gw.api.agiso.com/alds/WwMsg/Send");
|
||||
apiRequest.Method = "POST";
|
||||
apiRequest.ContentType = "application/x-www-form-urlencoded";
|
||||
apiRequest.Headers.Add("Authorization", "Bearer " + accessToken);
|
||||
apiRequest.Headers.Add("ApiVersion", "1");
|
||||
|
||||
TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
|
||||
var args = new Dictionary<string,string>()
|
||||
{
|
||||
{"timestamp",Convert.ToInt64(ts.TotalSeconds).ToString()},
|
||||
{"tid",Tid},
|
||||
{"msg",msg},
|
||||
};
|
||||
args.Add("sign", Sign(args, appSecret));
|
||||
|
||||
string postData = "";
|
||||
foreach (var p in args)
|
||||
{
|
||||
if (!String.IsNullOrEmpty(postData))
|
||||
{
|
||||
postData += "&";
|
||||
}
|
||||
string tmpStr = String.Format("{0}={1}", p.Key, HttpUtility.UrlEncode(p.Value));
|
||||
postData += tmpStr;
|
||||
}
|
||||
|
||||
using (var sw = new StreamWriter(apiRequest.GetRequestStream()))
|
||||
{
|
||||
sw.Write(postData);
|
||||
}
|
||||
WebResponse apiResponse = null;
|
||||
try
|
||||
{
|
||||
apiResponse = apiRequest.GetResponse();
|
||||
}
|
||||
catch (WebException we)
|
||||
{
|
||||
if (we.Status == WebExceptionStatus.ProtocolError)
|
||||
{
|
||||
apiResponse = (we.Response as HttpWebResponse);
|
||||
}
|
||||
else{
|
||||
//TODO:处理异常
|
||||
return "";
|
||||
}
|
||||
}
|
||||
using(Stream apiDataStream = apiResponse.GetResponseStream()){
|
||||
using(StreamReader apiReader = new StreamReader(apiDataStream, Encoding.UTF8)){
|
||||
string apiResult = apiReader.ReadToEnd();
|
||||
apiReader.Close();
|
||||
apiResponse.Close();
|
||||
return apiResult;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public async Task<string> ReceivedRefundMsg(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 "";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,185 +1,185 @@
|
||||
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 TaoBaoRefundService : ServiceBase<TaoBaoRefundEntity>, IFindService
|
||||
{
|
||||
CourseContext m_DbContext;
|
||||
|
||||
public TaoBaoRefundService(
|
||||
CourseContext dbContext
|
||||
,IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
m_DbContext = dbContext;
|
||||
}
|
||||
|
||||
public async override Task<TaoBaoRefundEntity> Add(TaoBaoRefundEntity 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 async Task<string> ReceivedRefundMsg(HttpRequest request, Func<string, Task<bool>> refunds)
|
||||
{
|
||||
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 (refunds != null)
|
||||
{
|
||||
if (await refunds(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 "";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
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 TaoBaoRefundService : ServiceBase<TaoBaoRefundEntity>, IFindService
|
||||
{
|
||||
CourseContext m_DbContext;
|
||||
|
||||
public TaoBaoRefundService(
|
||||
CourseContext dbContext
|
||||
,IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor)
|
||||
{
|
||||
m_DbContext = dbContext;
|
||||
}
|
||||
|
||||
public async override Task<TaoBaoRefundEntity> Add(TaoBaoRefundEntity 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 async Task<string> ReceivedRefundMsg(HttpRequest request, Func<string, Task<bool>> refunds)
|
||||
{
|
||||
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 (refunds != null)
|
||||
{
|
||||
if (await refunds(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 "";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,50 +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();
|
||||
}
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +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": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
//{
|
||||
// "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": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +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"
|
||||
}
|
||||
//{
|
||||
// "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"
|
||||
}
|
||||
|
||||
@@ -1,10 +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"
|
||||
}
|
||||
//{
|
||||
// "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"
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user