|
|
@@ -0,0 +1,89 @@
|
|
|
+using Microsoft.AspNetCore.Mvc;
|
|
|
+using Microsoft.AspNetCore.Http;
|
|
|
+using Microsoft.Extensions.Logging;
|
|
|
+using Microsoft.Extensions.Options;
|
|
|
+using System.Collections.Generic;
|
|
|
+using LitJson;
|
|
|
+using Library;
|
|
|
+using System.Linq;
|
|
|
+using System;
|
|
|
+using MySystem.MainModels;
|
|
|
+
|
|
|
+namespace MySystem.Areas.Api.Controllers.v1
|
|
|
+{
|
|
|
+ public class OutApiController : BaseController
|
|
|
+ {
|
|
|
+ public OutApiController(IHttpContextAccessor accessor, ILogger<BaseController> logger, IOptions<Setting> setting) : base(accessor, logger, setting)
|
|
|
+ {
|
|
|
+ }
|
|
|
+
|
|
|
+ #region 设置服务费
|
|
|
+ [Route("/api/v1/deposit/set")]
|
|
|
+ public JsonResult SetDeposit(string value)
|
|
|
+ {
|
|
|
+ JsonData data = JsonMapper.ToObject(value);
|
|
|
+ Dictionary<string, object> req = new Dictionary<string, object>();
|
|
|
+ req.Add("PosSnId", data["posId"].ToString());
|
|
|
+ req.Add("BrandId", data["brandId"].ToString());
|
|
|
+ req.Add("Deposit", data["deposit"].ToString());
|
|
|
+ req.Add("CallBackUrl", data["callBackUrl"].ToString());
|
|
|
+ RedisDbconn.Instance.AddList("ChangePosFeeQueue", Newtonsoft.Json.JsonConvert.SerializeObject(req));
|
|
|
+ return Json(new AppResultJson() { Status = "1", Info = "" });
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ #region 设置费率
|
|
|
+ [Route("/api/v1/fee/set")]
|
|
|
+ public JsonResult SetFee(string value)
|
|
|
+ {
|
|
|
+ JsonData data = JsonMapper.ToObject(value);
|
|
|
+ int PosId = int.Parse(data["posId"].ToString());
|
|
|
+ int BrandId = int.Parse(data["brandId"].ToString());
|
|
|
+ decimal FeeRate = decimal.Parse(data["feeRate"].ToString());
|
|
|
+ int FeeExtra = int.Parse(data["feeExtra"].ToString());
|
|
|
+ string CallBackUrl = data["callBackUrl"].ToString();
|
|
|
+ PosMachinesTwo pos = maindb.PosMachinesTwo.FirstOrDefault(m => m.Id == PosId) ?? new PosMachinesTwo();
|
|
|
+ PosMerchantInfo mer = maindb.PosMerchantInfo.FirstOrDefault(m => m.Id == PosId) ?? new PosMerchantInfo();
|
|
|
+ PosMachinesFeeChangeRecord query = maindb.PosMachinesFeeChangeRecord.FirstOrDefault(m => m.PosId == PosId && m.Status == 0);
|
|
|
+ if(query == null)
|
|
|
+ {
|
|
|
+ query = maindb.PosMachinesFeeChangeRecord.Add(new PosMachinesFeeChangeRecord()
|
|
|
+ {
|
|
|
+ CreateDate = DateTime.Now, //创建时间
|
|
|
+ PosId = PosId, //机具Id
|
|
|
+ }).Entity;
|
|
|
+ maindb.SaveChanges();
|
|
|
+ }
|
|
|
+ query.UpdateDate = DateTime.Now; //创建时间
|
|
|
+ query.Sort = pos.BrandId; //品牌Id
|
|
|
+ query.UserId = pos.BuyUserId; //创客
|
|
|
+ query.PosId = PosId; //机具Id
|
|
|
+ query.PosSn = pos.PosSn;
|
|
|
+ query.MerNo = mer.MerchantNo;
|
|
|
+ query.MerchantId = mer.Id;
|
|
|
+ query.PosUserId = pos.BuyUserId; //机具所属人
|
|
|
+ query.ChangeFee = FeeRate; //调整费率
|
|
|
+ maindb.SaveChanges();
|
|
|
+ int ChangeKind = 0;
|
|
|
+ if(FeeRate == 0.63M && FeeExtra == 3)
|
|
|
+ {
|
|
|
+ ChangeKind = 1;
|
|
|
+ }
|
|
|
+ else if(FeeRate == 0.63M && FeeExtra == 0)
|
|
|
+ {
|
|
|
+ ChangeKind = 2;
|
|
|
+ }
|
|
|
+ else if(FeeRate == 0.6M && FeeExtra == 0)
|
|
|
+ {
|
|
|
+ ChangeKind = 3;
|
|
|
+ }
|
|
|
+ // PosId:机具Id
|
|
|
+ // Kind:1或2,1为费率0.63+3,2为费率0.63,3为费率0.6
|
|
|
+ // OpMan:操作人,app传创客编号,后台传SysUserName
|
|
|
+ string info = "{\"RecordId\":\"" + query.Id + "\",\"PosId\":\"" + pos.Id + "\",\"Fee\": \"" + FeeRate.ToString("f0").TrimEnd('0') + "\",\"Kind\": \"" + ChangeKind + "\",\"OpMan\": \"接口\",\"CallBackUrl\":\"" + CallBackUrl + "\"}";
|
|
|
+ RedisDbconn.Instance.AddList("SetDepositQueue", info);
|
|
|
+ return Json(new AppResultJson() { Status = "1", Info = "" });
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+ }
|
|
|
+}
|