123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.AspNetCore.Http;
- using Microsoft.Extensions.Logging;
- using Microsoft.Extensions.Options;
- using Microsoft.AspNetCore.Authorization;
- using System.Web;
- using MySystem.Models.Main;
- using LitJson;
- using Library;
- namespace MySystem.Areas.Api.Controllers.v1
- {
- [Area("Api")]
- [Route("Api/v1/[controller]/[action]")]
- public class MerchantParamSetController : BaseController
- {
- public MerchantParamSetController(IHttpContextAccessor accessor) : base(accessor)
- {
- }
- #region 商户-商户活动参数
-
- public JsonResult Detail(string value)
- {
- value = DesDecrypt(value);
- value = value.Replace("null", "\"\"");
- JsonData data = JsonMapper.ToObject(value);
- Dictionary<string, object> Obj = DetailDo(value);
- return Json(new AppResultJson() { Status = "1", Info = "", Data = Obj });
- }
- public Dictionary<string, object> DetailDo(string value)
- {
- JsonData data = JsonMapper.ToObject(value);
- Dictionary<string, object> Obj = new Dictionary<string, object>();
- int Id = int.Parse(function.CheckInt(data.getItem("Id").ToString()));
- MerchantParamSet query = MerchantParamSetDbconn.Instance.Get(Id);
- if (query == null)
- {
- query = new MerchantParamSet();
- query.IsAll = 1;
- }
- Obj.Add("IsAll", query.IsAll);
- Obj.Add("MinPayMoney", query.MinPayMoney);
- Obj.Add("GetPercent", query.GetPercent);
- Obj.Add("ProfitDays", query.ProfitDays);
- Obj.Add("DiviPercent", query.DiviPercent);
- Obj.Add("DiviPersons", query.DiviPersons);
- return Obj;
- }
- #endregion
- #region 商户-活动配置
-
- public JsonResult Set(string value)
- {
- value = DesDecrypt(value);
- value = value.Replace("null", "\"\"");
- JsonData data = JsonMapper.ToObject(value);
- AppResultJson result = SetDo(value);
- return Json(new AppResultJson() { Status = result.Status, Info = result.Info, Data = result.Data });
- }
- public AppResultJson SetDo(string value)
- {
- JsonData data = JsonMapper.ToObject(value);
- int IsAll = int.Parse(function.CheckInt(data.getItem("IsAll").ToString()));
- decimal MinPayMoney = decimal.Parse(function.CheckNum(data.getItem("MinPayMoney").ToString()));
- decimal GetPercent = decimal.Parse(function.CheckNum(data.getItem("GetPercent").ToString()));
- int ProfitDays = int.Parse(function.CheckInt(data.getItem("ProfitDays").ToString()));
- decimal DiviPercent = decimal.Parse(function.CheckNum(data.getItem("DiviPercent").ToString()));
- int DiviPersons = int.Parse(function.CheckInt(data.getItem("DiviPersons").ToString()));
- string MobileCode = data.getItem("MobileCode").ToString();
- if (string.IsNullOrEmpty(data["IsAll"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写是否收全额" };
- }
- if (string.IsNullOrEmpty(data["MinPayMoney"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写订单参与门槛" };
- }
- if (string.IsNullOrEmpty(data["GetPercent"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写商家实收比例" };
- }
- if (string.IsNullOrEmpty(data["ProfitDays"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写分红期限(天)" };
- }
- if (!function.IsInt(data["ProfitDays"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写正确的分红期限(天)" };
- }
- if (string.IsNullOrEmpty(data["DiviPercent"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写最大分红比例" };
- }
- if (string.IsNullOrEmpty(data["DiviPersons"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写单笔订单分红人数" };
- }
- if (!function.IsInt(data["DiviPersons"].ToString()))
- {
- return new AppResultJson() { Status = "-1", Info = "请填写正确的单笔订单分红人数" };
- }
- int Id = int.Parse(function.CheckInt(data["Id"].ToString()));
- MerchantInfo merchant = maindb.MerchantInfo.FirstOrDefault(m => m.Id == Id);
- MobileCodeCheck mobilecheck = RedisDbconn.Instance.Get<MobileCodeCheck>("MobileCodeCheck:" + merchant.Mobile);
- if (mobilecheck == null)
- {
- return new AppResultJson() { Status = "-1", Info = "短信验证码不正确" };
- }
- if (mobilecheck.CheckCode != MobileCode)
- {
- return new AppResultJson() { Status = "-1", Info = "短信验证码不正确" };
- }
- RedisDbconn.Instance.Clear("MobileCodeCheck:" + merchant.Mobile);
- Dictionary<string, object> Obj = new Dictionary<string, object>();
- MerchantParamSet query = maindb.MerchantParamSet.FirstOrDefault(m => m.Id == Id);
- if(query == null)
- {
- query = maindb.MerchantParamSet.Add(new MerchantParamSet()
- {
- Id = Id,
- CreateDate = DateTime.Now,
- }).Entity;
- maindb.SaveChanges();
- }
- query.UpdateDate = DateTime.Now;
- query.IsAll = IsAll;
- query.MinPayMoney = MinPayMoney;
- query.GetPercent = GetPercent;
- query.ProfitDays = ProfitDays;
- query.DiviPercent = DiviPercent;
- query.DiviPersons = DiviPersons;
- maindb.SaveChanges();
- Obj.Add("UpdateDate", query.UpdateDate.Value.ToString("yyyy-MM-dd HH:mm:ss"));
- return new AppResultJson() { Status = "1", Info = "", Data = Obj };
- }
- #endregion
- #region 检查签名是否合法,合法返回1,不合法返回提示信息
-
-
-
-
-
-
- private string CheckSign(string value, string[] signField)
- {
- JsonData json = JsonMapper.ToObject(value);
- Dictionary<string, string> dic = new Dictionary<string, string>();
- for (int i = 0; i < signField.Length; i++)
- {
- dic.Add(signField[i], json[signField[i]].ToString());
- }
- string sign = json["sign"].ToString();
- return new Sign().sign(dic, sign);
- }
- #endregion
- }
- }
|