mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 22:43:25 +08:00
【新增】用户如果下单时未填写发票信息,可通过订单详情提交发票申请,仅限支付后的订单。
This commit is contained in:
@@ -45,16 +45,12 @@ namespace CoreCms.Net.Web.WebApi.Controllers
|
||||
private readonly ICoreCmsAreaServices _areaServices;
|
||||
private readonly ICoreCmsBillReshipServices _reshipServices;
|
||||
private readonly ICoreCmsShipServices _shipServices;
|
||||
private readonly ICoreCmsBillDeliveryServices _billDeliveryServices;
|
||||
private readonly ICoreCmsLogisticsServices _logisticsServices;
|
||||
private readonly ICoreCmsGoodsServices _goodsServices;
|
||||
private readonly ICoreCmsStoreServices _storeServices;
|
||||
private readonly ICoreCmsOrderDistributionModelServices _orderDistributionModelServices;
|
||||
private readonly ICoreCmsBillPaymentsServices _billPaymentsServices;
|
||||
private readonly IRedisOperationRepository _redisOperationRepository;
|
||||
private readonly ICoreCmsUserServices _userServices;
|
||||
private readonly ICoreCmsClerkServices _clerkServices;
|
||||
|
||||
private readonly ICoreCmsInvoiceServices _invoiceServices;
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -65,8 +61,7 @@ namespace CoreCms.Net.Web.WebApi.Controllers
|
||||
, ICoreCmsBillAftersalesServices aftersalesServices
|
||||
, ICoreCmsSettingServices settingServices
|
||||
, ICoreCmsAreaServices areaServices
|
||||
, ICoreCmsBillReshipServices reshipServices, ICoreCmsShipServices shipServices
|
||||
, ICoreCmsBillDeliveryServices billDeliveryServices, ICoreCmsLogisticsServices logisticsServices, ICoreCmsGoodsServices goodsServices, ICoreCmsStoreServices storeServices, ICoreCmsOrderDistributionModelServices orderDistributionModelServices, IRedisOperationRepository redisOperationRepository, ICoreCmsBillPaymentsServices billPaymentsServices, ICoreCmsUserServices userServices, ICoreCmsClerkServices clerkServices)
|
||||
, ICoreCmsBillReshipServices reshipServices, ICoreCmsShipServices shipServices, ICoreCmsLogisticsServices logisticsServices, ICoreCmsOrderDistributionModelServices orderDistributionModelServices, IRedisOperationRepository redisOperationRepository, ICoreCmsUserServices userServices, ICoreCmsClerkServices clerkServices, ICoreCmsInvoiceServices invoiceServices)
|
||||
{
|
||||
_user = user;
|
||||
_orderServices = orderServices;
|
||||
@@ -75,15 +70,12 @@ namespace CoreCms.Net.Web.WebApi.Controllers
|
||||
_areaServices = areaServices;
|
||||
_reshipServices = reshipServices;
|
||||
_shipServices = shipServices;
|
||||
_billDeliveryServices = billDeliveryServices;
|
||||
_logisticsServices = logisticsServices;
|
||||
_goodsServices = goodsServices;
|
||||
_storeServices = storeServices;
|
||||
_orderDistributionModelServices = orderDistributionModelServices;
|
||||
_redisOperationRepository = redisOperationRepository;
|
||||
_billPaymentsServices = billPaymentsServices;
|
||||
_userServices = userServices;
|
||||
_clerkServices = clerkServices;
|
||||
_invoiceServices = invoiceServices;
|
||||
}
|
||||
|
||||
|
||||
@@ -681,6 +673,100 @@ namespace CoreCms.Net.Web.WebApi.Controllers
|
||||
|
||||
#endregion
|
||||
|
||||
#region 检查订单发票是否已经开具=======================================================
|
||||
|
||||
/// <summary>
|
||||
/// 检查订单发票是否已经开具
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Authorize]
|
||||
public async Task<WebApiCallBack> CheckInvoice([FromBody] FMStringId entity)
|
||||
{
|
||||
var jm = new WebApiCallBack();
|
||||
|
||||
if (string.IsNullOrEmpty(entity.id))
|
||||
{
|
||||
jm.msg = "请提交订单编码。";
|
||||
return jm;
|
||||
}
|
||||
|
||||
var isHave = await _invoiceServices.ExistsAsync(p => p.sourceId == entity.id && p.category == (int)GlobalEnumVars.OrderTaxCategory.Order);
|
||||
|
||||
jm.status = true;
|
||||
jm.data = isHave;
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region 提交发票申请=======================================================
|
||||
|
||||
/// <summary>
|
||||
/// 提交发票申请
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Authorize]
|
||||
public async Task<WebApiCallBack> SubmitInvoiceApply([FromBody] FMSubmitInvoiceApply entity)
|
||||
{
|
||||
var jm = new WebApiCallBack();
|
||||
|
||||
|
||||
if (entity.type == 3 && string.IsNullOrEmpty(entity.code))
|
||||
{
|
||||
jm.msg = "企业发票申请必须填写纳税人识别号";
|
||||
return jm;
|
||||
}
|
||||
|
||||
var isHave = await _invoiceServices.ExistsAsync(p => p.sourceId == entity.orderId && p.category == (int)GlobalEnumVars.OrderTaxCategory.Order);
|
||||
if (isHave)
|
||||
{
|
||||
jm.msg = "此订单已经存在发票信息。";
|
||||
return jm;
|
||||
}
|
||||
|
||||
var order = await _orderServices.QueryByClauseAsync(p => p.orderId == entity.orderId);
|
||||
if (order == null)
|
||||
{
|
||||
jm.msg = "订单查询失败。";
|
||||
return jm;
|
||||
}
|
||||
|
||||
if (order.userId != _user.ID)
|
||||
{
|
||||
jm.msg = "你无权申请发票。";
|
||||
return jm;
|
||||
}
|
||||
|
||||
//组装发票信息
|
||||
var taxInfo = new CoreCmsInvoice
|
||||
{
|
||||
category = (int)GlobalEnumVars.OrderTaxCategory.Order,
|
||||
sourceId = order.orderId,
|
||||
userId = order.userId,
|
||||
type = entity.type,
|
||||
title = entity.name,
|
||||
taxNumber = entity.code,
|
||||
amount = order.orderAmount,
|
||||
status = (int)GlobalEnumVars.OrderTaxStatus.No,
|
||||
createTime = DateTime.Now
|
||||
};
|
||||
|
||||
var bl = await _invoiceServices.InsertAsync(taxInfo) > 0;
|
||||
|
||||
jm.status = true;
|
||||
jm.data = bl;
|
||||
|
||||
return jm;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user