336 lines
12 KiB
C#
336 lines
12 KiB
C#
using MyCode.Project.Domain.Message.Act.Report2301;
|
||
using MyCode.Project.Domain.Message.Act.SalesSheetPay;
|
||
using MyCode.Project.Domain.Message.Common;
|
||
using MyCode.Project.Domain.Message.Request.Act;
|
||
using MyCode.Project.Domain.Message.Request.SalesSheet;
|
||
using MyCode.Project.Domain.Message.Response.CouponActivity;
|
||
using MyCode.Project.Domain.Message.Response.MeiTuan;
|
||
using MyCode.Project.Domain.Message.Response.SalesSheet;
|
||
using MyCode.Project.Domain.Message.Response.ServiceOrder;
|
||
using MyCode.Project.Domain.Message.Response.User;
|
||
using MyCode.Project.Infrastructure.Common;
|
||
using MyCode.Project.Infrastructure.Constant;
|
||
using MyCode.Project.Infrastructure.Enumeration;
|
||
using MyCode.Project.Services;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Net;
|
||
using System.Web;
|
||
using System.Web.Http;
|
||
|
||
namespace MyCode.Project.WebApi.Areas.Wechat.Controllers
|
||
{
|
||
/// <summary>
|
||
/// 销售订单相关
|
||
/// </summary>
|
||
public class SalesSheetController : BaseWechatController
|
||
{
|
||
private ISalesSheetService _salesSheetService;
|
||
private ISalesSheetPayService _salesSheetPayService;
|
||
private IMemberServiceInvService _memberServiceInvService;
|
||
private IPreSalesSheetService _preSalesSheetService;
|
||
private IMemberRechargeService _memberRechargeService;
|
||
|
||
/// <summary>
|
||
///
|
||
/// </summary>
|
||
/// <param name="salesSheetService"></param>
|
||
public SalesSheetController(ISalesSheetService salesSheetService
|
||
, ISalesSheetPayService salesSheetPayService
|
||
, IMemberServiceInvService memberServiceInvService
|
||
, IPreSalesSheetService preSalesSheetService
|
||
, IMemberRechargeService memberRechargeService)
|
||
{
|
||
_preSalesSheetService = preSalesSheetService;
|
||
_salesSheetService = salesSheetService;
|
||
_salesSheetPayService = salesSheetPayService;
|
||
_memberServiceInvService = memberServiceInvService;
|
||
_memberRechargeService = memberRechargeService;
|
||
}
|
||
|
||
|
||
#region GetPageList(获取门店销售订单分页列表)
|
||
/// <summary>
|
||
/// 获取门店销售订单分页列表
|
||
/// </summary>
|
||
/// <param name="request"></param>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public PageResult<SalesSheetPageListResp> GetPageList(PagedSearch<SalesSheetPageListQuery> request)
|
||
{
|
||
return _salesSheetService.GetPageList(request, this.CurrentLogin);
|
||
}
|
||
#endregion
|
||
|
||
#region 创建销售订单
|
||
/// <summary>
|
||
/// 创建销售订单
|
||
/// </summary>
|
||
/// <param name="request"></param>
|
||
[HttpPost]
|
||
public Guid Save(SalesSheetAct request)
|
||
{
|
||
return _salesSheetService.Save(request, this.CurrentLogin);
|
||
}
|
||
#endregion
|
||
|
||
#region OnlinePay(销售单、预售单在线扫码支付)
|
||
/// <summary>
|
||
/// 销售单、预售单在线扫码支付
|
||
/// </summary>
|
||
/// <param name="act"></param>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public string OnlinePay(SalesSheetOnlinePayAct act)
|
||
{
|
||
string ip = HttpContext.Current.Request.UserHostAddress;
|
||
return _salesSheetPayService.OnlinePay(act, this.CurrentLogin, ip);
|
||
}
|
||
#endregion
|
||
|
||
#region IfSuccess(支付是否成功的查询回调)
|
||
/// <summary>
|
||
/// 支付是否成功的查询回调(等于100支付成功)
|
||
/// </summary>
|
||
/// <param name="id">充值订单主键ID</param>
|
||
/// <param name="refType">订单来源,1销售单,2预售单</param>
|
||
/// <returns>等于100支付成功</returns>
|
||
[HttpGet]
|
||
public int IfSuccess(Guid id, int refType)
|
||
{
|
||
return _salesSheetPayService.IfSuccess(id, refType);
|
||
}
|
||
#endregion
|
||
|
||
#region 确认结账(现金和会员和刷卡支付)
|
||
/// <summary>
|
||
/// 确认结账(现金和会员和刷卡支付)
|
||
/// </summary>
|
||
/// <param name="request"></param>
|
||
[HttpPost]
|
||
public void ConfirmPay(SalesSheetOnlinePayAct request)
|
||
{
|
||
_salesSheetPayService.ConfirmPay(request, this.CurrentLogin);
|
||
}
|
||
#endregion
|
||
|
||
#region 确认结账(用于纯余额结账)
|
||
/// <summary>
|
||
/// 确认结账(用于纯余额结账)
|
||
/// </summary>
|
||
/// <param name="request"></param>
|
||
[HttpPost]
|
||
public void BalancePay(SalesSheetOnlinePayAct request)
|
||
{
|
||
_salesSheetPayService.BalancePay(request, this.CurrentLogin);
|
||
}
|
||
#endregion
|
||
|
||
#region GetDetail(获取门店销售订单详情)
|
||
/// <summary>
|
||
/// 获取门店销售订单详情
|
||
/// </summary>
|
||
/// <param name="id"></param>
|
||
/// <returns></returns>
|
||
[HttpGet]
|
||
public SalesSheetResp GetDetail(Guid id)
|
||
{
|
||
return _salesSheetService.GetDetail(id);
|
||
}
|
||
#endregion
|
||
|
||
#region SaveReturnSheet(退款退货)
|
||
/// <summary>
|
||
/// 退款退货
|
||
/// </summary>
|
||
/// <param name="act"></param>
|
||
[HttpPost]
|
||
public void SaveReturnSheet(ReturnSheetAct act)
|
||
{
|
||
if (act.SalesType == (int)SalesType.Sales)
|
||
{
|
||
_salesSheetPayService.SaveReturnSheet(act, this.CurrentLogin);
|
||
}
|
||
else if (act.SalesType == 2) //换货
|
||
{
|
||
|
||
}
|
||
else if (act.SalesType == 20)
|
||
{
|
||
ReturnPreSheetAct returnPreSheetAct = new ReturnPreSheetAct();
|
||
returnPreSheetAct.SheetId = act.SheetId;
|
||
returnPreSheetAct.AccountType = 1;
|
||
var iid = _preSalesSheetService.ReturnPreSheet(returnPreSheetAct, this.CurrentLogin);
|
||
}
|
||
else if (act.SalesType == 30)
|
||
{
|
||
_memberRechargeService.ReturnRecharge(act.SheetId, this.CurrentLogin, 1);
|
||
}
|
||
|
||
}
|
||
#endregion
|
||
|
||
#region 扫门票码创建订单
|
||
/// <summary>
|
||
/// 扫门票码创建订单
|
||
/// </summary>
|
||
/// <param name="Id">扫码所得ID(即会员参与活动记录主键ID)</param>
|
||
/// <param name="ShopId">店铺ID(店长或店员可不传参)</param>
|
||
/// <returns></returns>
|
||
[HttpGet]
|
||
public ScanCodeOrderResp SaveActivityOrder(Guid Id,Guid? ShopId)
|
||
{
|
||
ScanCodeOrderResp result = new ScanCodeOrderResp();
|
||
ShopId = ShopId.HasValue ? ShopId.Value : this.CurrentLogin.ShopId;
|
||
result = _salesSheetService.SaveActivityOrder(Id,ShopId.Value, this.CurrentLogin);
|
||
if (result.Code == 0)
|
||
{
|
||
SalesSheetOnlinePayAct act = new SalesSheetOnlinePayAct();
|
||
act.Amount = 0;
|
||
act.Balance = 0;
|
||
act.CouponId = null;
|
||
act.DirectAmount = 0;
|
||
act.Discount = 0;
|
||
act.PayMode = 0;
|
||
act.RefType = 1;
|
||
act.SheetId = result.Id;
|
||
_salesSheetPayService.ConfirmPay(act, this.CurrentLogin);
|
||
}
|
||
return result;
|
||
}
|
||
#endregion
|
||
|
||
#region SaveScanCodeOrder(全局扫码创建订单)
|
||
/// <summary>
|
||
/// 全局扫码创建订单
|
||
/// </summary>
|
||
/// <param name="act"></param>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public ScanCodeOrderResp SaveScanCodeOrder(ScanCodeOrderAct act)
|
||
{
|
||
var result= _salesSheetService.SaveScanCodeOrder(act.scene,this.CurrentLogin);
|
||
if (result.Code == 0 && result.Id!=Guid.Empty)
|
||
{
|
||
SalesSheetOnlinePayAct sales = new SalesSheetOnlinePayAct();
|
||
sales.Amount = 0;
|
||
sales.Balance = 0;
|
||
sales.CouponId = null;
|
||
sales.DirectAmount = 0;
|
||
sales.Discount = 0;
|
||
sales.PayMode = 0;
|
||
sales.RefType = 1;
|
||
sales.SheetId = result.Id;
|
||
_salesSheetPayService.ConfirmPay(sales, this.CurrentLogin);
|
||
}
|
||
return result;
|
||
}
|
||
#endregion
|
||
|
||
#region GetServiceSetList(获取买商品赠送的服务套餐列表)
|
||
/// <summary>
|
||
/// 获取买商品赠送的服务套餐列表
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpGet]
|
||
public List<ServiceInvInfo> GetServiceSetList()
|
||
{
|
||
return _memberServiceInvService.GetServiceSetList(this.CurrentLogin.CustomerId);
|
||
}
|
||
#endregion
|
||
|
||
#region GetCouponListsForSalesSheet(销售订单获取可用优惠券列表,设置了一口价的订单不允许使用优惠券)
|
||
/// <summary>
|
||
/// 销售订单获取可用优惠券列表,设置了一口价的订单不允许使用优惠券
|
||
/// </summary>
|
||
/// <param name="sheetId"></param>
|
||
/// <returns></returns>
|
||
[HttpGet]
|
||
public List<CouponList> GetCouponListsForSalesSheet(Guid sheetId)
|
||
{
|
||
return _salesSheetService.GetCouponListsForSalesSheet(sheetId);
|
||
}
|
||
#endregion
|
||
|
||
#region GetBuLuServiceSetList(获取补录的服务套餐列表)
|
||
/// <summary>
|
||
/// 获取补录的服务套餐列表
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
[HttpGet]
|
||
public List<ServiceInvInfo> GetBuLuServiceSetList()
|
||
{
|
||
return _memberServiceInvService.GetServiceSetList(this.CurrentLogin.CustomerId,1);
|
||
}
|
||
#endregion
|
||
|
||
|
||
//#region SaveReturnSheetTemp(临时的补退款退货单的支付表记录)
|
||
///// <summary>
|
||
///// 临时的补退款退货单的支付表记录
|
||
///// </summary>
|
||
///// <param name="days"></param>
|
||
//[HttpGet]
|
||
//[AllowAnonymous]
|
||
//public void SaveReturnSheetTemp(DateTime days)
|
||
//{
|
||
// _salesSheetPayService.SaveReturnSheetTemp(days);
|
||
//}
|
||
//#endregion
|
||
|
||
|
||
#region TuanGouConfirmPayOnline( 确认结账(用于对接了抖音的店铺团购核销码支付))
|
||
/// <summary>
|
||
/// 确认结账(用于对接了抖音的店铺团购核销码支付)
|
||
/// </summary>
|
||
/// <param name="act"> </param>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
public Guid? TuanGouConfirmPayOnline(DouYinOnlinePayAct act)
|
||
{
|
||
act.ClerkID = this.CurrentLogin.ClerkId;
|
||
|
||
return _salesSheetPayService.TuanGouConfirmPayOnline(act, this.CurrentLogin,1);
|
||
|
||
}
|
||
#endregion
|
||
|
||
#region Cancel( 用于验券错误需要撤回验券等场景, 有时间限制,验券超过一个小时就不可再撤销。同时适用于抖音团购券码与三方券码)
|
||
/// <summary>
|
||
/// 用于验券错误需要撤回验券等场景, 有时间限制,验券超过一个小时就不可再撤销。同时适用于抖音团购券码与三方券码
|
||
/// </summary>
|
||
/// <param name="id">订单ID </param>
|
||
/// <returns></returns>
|
||
[HttpGet]
|
||
[AllowAnonymous]
|
||
public void Cancel(string id)
|
||
{
|
||
|
||
_salesSheetPayService.Cancel(id);
|
||
}
|
||
#endregion
|
||
|
||
#region Cancel( 解析返回的字符串)
|
||
/// <summary>
|
||
/// 解析返回的字符串
|
||
/// </summary>
|
||
/// <param name="id">订单ID </param>
|
||
/// <returns></returns>
|
||
[HttpPost]
|
||
[AllowAnonymous]
|
||
public MeiTuanCommonResp<List<GetConsumeResp>> JieXi(string resultJson)
|
||
{
|
||
|
||
//resultJson = resultJson.Replace("\\\"", "'");
|
||
//LogHelper.Info(resultJson);
|
||
//resultJson = resultJson.Replace("\\", "");
|
||
//LogHelper.Info(resultJson);
|
||
MeiTuanCommonResp<List<GetConsumeResp>> douYinResp = new MeiTuanCommonResp<List<GetConsumeResp>>();
|
||
douYinResp = JsonHelper.ToObject<MeiTuanCommonResp<List<GetConsumeResp>>>(resultJson);
|
||
//_salesSheetPayService.Cancel(id);
|
||
return douYinResp;
|
||
}
|
||
#endregion
|
||
}
|
||
}
|