Browse Source

刷卡消费

Lishi
xxe 2 years ago
parent
commit
d59eeddbb8
3 changed files with 32 additions and 20 deletions
  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 View File

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


+ 22
- 16
HKCardOUT/Logic/RemoteService.cs View File

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


@@ -17,34 +19,38 @@ namespace HKCardOUT.Logic
/// 判断卡状态 /// 判断卡状态
/// </summary> /// </summary>
/// <param name="input"></param> /// <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>
/// 同步消费记录 /// 同步消费记录
/// </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>
/// 获取店铺信息 /// 获取店铺信息
/// </summary> /// </summary>
public static void PullShopInfo() 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; DataBus.StoreInfo = data;
} }
} }


+ 8
- 2
HKCardOUT/Logic/Service/HKCore.cs View File

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


Loading…
Cancel
Save