Explorar el Código

刷卡消费

Lishi
xxe hace 2 años
padre
commit
d59eeddbb8
Se han modificado 3 ficheros con 32 adiciones y 20 borrados
  1. +2
    -2
      HKCardOUT/Helper/DataBus.cs
  2. +22
    -16
      HKCardOUT/Logic/RemoteService.cs
  3. +8
    -2
      HKCardOUT/Logic/Service/HKCore.cs

+ 2
- 2
HKCardOUT/Helper/DataBus.cs Ver fichero

@@ -36,11 +36,11 @@ namespace HKCardOUT.Helper
/// <summary>
/// 检查卡的状态
/// </summary>
public static string CheckCardStatus = DataBus.SaasRoute + "";
public static string CheckCardStatus = DataBus.SaasRoute + "api/member-helper/membercardinfo/";
/// <summary>
/// 同步消费记录
/// </summary>
public static string SyncSaleLog = DataBus.SaasRoute + "";
public static string SyncSaleLog = DataBus.SaasRoute + "api/member-helper/memberconsumptionorrecharge";
/// <summary>
/// 获取店铺信息
/// </summary>


+ 22
- 16
HKCardOUT/Logic/RemoteService.cs Ver fichero

@@ -6,6 +6,8 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Markup;
using XExten.Advance.HttpFramework.MultiCommon;
using XExten.Advance.HttpFramework.MultiFactory;
using XExten.Advance.LinqFramework;

@@ -17,34 +19,38 @@ namespace HKCardOUT.Logic
/// 判断卡状态
/// </summary>
/// <param name="input"></param>
public static void CheckCardStuatas(string input)
public static int CheckCardStuatas(string CardNo)
{
IHttpMultiClient.HttpMulti.AddNode(t =>
{
t.NodePath = ApiRoute.CheckCardStatus;
}).Build().RunStringFirst();
return IHttpMultiClient.HttpMulti.AddNode(t =>
{
t.NodePath = ApiRoute.CheckCardStatus + CardNo;
}).Build().RunStringFirst().ToModel<JObject>()["data"]["cardState"].ToString().AsInt();
}
/// <summary>
/// 同步消费记录
/// </summary>
/// <param name="input"></param>
public static void SyncSaleLog(dynamic input)
/// <param name="CardNo"></param>
/// <param name="Money"></param>
public static bool SyncSaleLog(string CardNo, decimal Money)
{
IHttpMultiClient.HttpMulti.AddNode(t =>
{
t.NodePath = ApiRoute.SyncSaleLog;
}).Build().RunStringFirst();
var data = IHttpMultiClient.HttpMulti.AddNode(t =>
{
t.ReqType = MultiType.POST;
t.JsonParam = (new { Money, Type = -1, CardNum = CardNo }).ToJson();
t.NodePath = ApiRoute.SyncSaleLog;
}).Build().RunStringFirst();
return bool.Parse(data.ToModel<JObject>()["data"].ToString());
}
/// <summary>
/// 获取店铺信息
/// </summary>
public static void PullShopInfo()
{
var data = IHttpMultiClient.HttpMulti.AddNode(t =>
{
t.NodePath = ApiRoute.PullShopInfo;
}).Build().RunStringFirst()
.ToModel<JObject>()["data"].ToJson().ToModel<StoreInfoResponse>();
var data = IHttpMultiClient.HttpMulti.AddNode(t =>
{
t.NodePath = ApiRoute.PullShopInfo;
}).Build().RunStringFirst()
.ToModel<JObject>()["data"].ToJson().ToModel<StoreInfoResponse>();
DataBus.StoreInfo = data;
}
}


+ 8
- 2
HKCardOUT/Logic/Service/HKCore.cs Ver fichero

@@ -1,4 +1,5 @@
using HKCardOUT.Logic.Model;
using HandyControl.Controls;
using HKCardOUT.Logic.Model;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -16,6 +17,7 @@ namespace HKCardOUT.Logic.Service
/// <returns></returns>
public bool DeviceSale(SaleLog input)
{
if (RemoteService.CheckCardStuatas(input.CardNo) != 1) return false;
var Old = DbContext.Context.Queryable<SaleLog>()
.Where(t => t.CardNo == input.CardNo).OrderByDescending(t => t.CreateTime).First();
if (Old != null)
@@ -23,7 +25,11 @@ namespace HKCardOUT.Logic.Service
//10秒防止重复刷卡
if (Old.CreateTime.Subtract(DateTime.Now).TotalSeconds > 10d)
{
return DbContext.Context.Insertable(input).CallEntityMethod(t => t.Create()).ExecuteCommand() > 0;
if (DbContext.Context.Insertable(input).CallEntityMethod(t => t.Create()).ExecuteCommand() > 0)
{
var res = RemoteService.SyncSaleLog(input.CardNo, input.Money);
}
}
return false;
}


Cargando…
Cancelar
Guardar