891 lines
56 KiB
C#
891 lines
56 KiB
C#
|
using Api.Framework;
|
|||
|
using Api.Framework.Enums;
|
|||
|
using Api.Framework.Model;
|
|||
|
using Api.Framework.SDK;
|
|||
|
using Api.Framework.Tools;
|
|||
|
using Chat.Framework;
|
|||
|
using Chat.Framework.WXSdk.IPAD;
|
|||
|
using CsharpHttpHelper;
|
|||
|
using PointManage.Entitys;
|
|||
|
using PointManage.Properties;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text.RegularExpressions;
|
|||
|
using System.Threading;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using Api.Framework.Utils;
|
|||
|
|
|||
|
namespace PointManage
|
|||
|
{
|
|||
|
public class Class1 : Plugin
|
|||
|
{
|
|||
|
public Class1()
|
|||
|
{
|
|||
|
this.Logo = Resources.积分管理;
|
|||
|
this.Name = Resources.PluginName;
|
|||
|
this.Note = Resources.PluginNote;
|
|||
|
}
|
|||
|
|
|||
|
#region 自定义变量
|
|||
|
public static PointManageConfig Config;
|
|||
|
private MainForm mainForm = null;
|
|||
|
#endregion
|
|||
|
|
|||
|
public override void Start()
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
var session = ApiClient.GetSession();
|
|||
|
#region 判断表是否存在,不存在创建表
|
|||
|
if (!session.TableExist<fl_plugin_pointmanage_checkin_info>())
|
|||
|
{
|
|||
|
session.CreateTable<fl_plugin_pointmanage_checkin_info>();
|
|||
|
session.AddIndex<fl_plugin_pointmanage_checkin_info>("uid");
|
|||
|
}
|
|||
|
if (!session.TableExist<fl_plugin_pointmanage_extra_award>())
|
|||
|
{
|
|||
|
session.CreateTable<fl_plugin_pointmanage_extra_award>();
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
//创建配置文件
|
|||
|
Config = this.ReadConfig<PointManageConfig>();
|
|||
|
|
|||
|
|
|||
|
// Config.Unsettled_Forbid_Exchange_Tip = @"一一一申 请 失 败一一一
|
|||
|
|
|||
|
//亲,系统检测到你有【付款成功】订单,
|
|||
|
//请收货完成后再来发起提现申请哦!";
|
|||
|
|
|||
|
// Config.NotReceiving_Forbid_Exchange_Tip = @"一一一申 请 失 败一一一
|
|||
|
|
|||
|
//亲,系统未检测到你有订单记录,
|
|||
|
//请完成首单后再来发起提现申请哦!";
|
|||
|
|
|||
|
// Util.Save(Config);
|
|||
|
|
|||
|
|
|||
|
SDK.ReciveIMEvent += SDK_ReciveIMEvent;
|
|||
|
SDK.OrderNoticeEvent += SDK_OrderNoticeEvent;
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
this.OnLog(ex.Message);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private readonly object lockAward2 = new object();
|
|||
|
|
|||
|
private void SDK_OrderNoticeEvent(object sender, Api.Framework.Events.OrderNoticeEvent e)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
if (Config.Extra_Award_Switch == SwitchType.开启 && e.OrderNoticeType == OrderNoticeType.客户订单)
|
|||
|
{
|
|||
|
if (e.ChatType == CpsType.多多进宝)
|
|||
|
return;
|
|||
|
var order = e.Order as base_model_order;
|
|||
|
if (order.db_status != SystemOrderStatus.订单结算) return;
|
|||
|
lock (lockAward2)
|
|||
|
{
|
|||
|
var session = ApiClient.GetSession();
|
|||
|
var award = session.FindSingle<fl_plugin_pointmanage_extra_award>("select * from fl_plugin_pointmanage_extra_award where uid = @uid", new { uid = e.Member.id });
|
|||
|
if (award == null)
|
|||
|
award = new fl_plugin_pointmanage_extra_award() { uid = e.Member.id, count = 1 };
|
|||
|
else
|
|||
|
award.count++;
|
|||
|
session.SaveExtraAward(award);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
this.OnLog($"{ex.Message} - {ex.StackTrace}");
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public override void ShowForm()
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
if (mainForm == null || mainForm.IsDisposed)
|
|||
|
{
|
|||
|
mainForm = new MainForm();
|
|||
|
mainForm.Show();
|
|||
|
}
|
|||
|
mainForm.Activate();
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
this.OnLog("执行时被" + ex.Message);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public override void Stop()
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
if (mainForm != null)
|
|||
|
{
|
|||
|
mainForm.CloseForm();
|
|||
|
mainForm = null;
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
this.OnLog(ex.Message);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private static Queue<exchange_info> exchangeQueue = new Queue<exchange_info>();//提现队列
|
|||
|
private static exchange_info GetExchange_info()
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
return exchangeQueue.Dequeue();
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{ }
|
|||
|
return null;
|
|||
|
}
|
|||
|
|
|||
|
private static bool _IsRun = false;
|
|||
|
|
|||
|
private void _ExchangeAction()
|
|||
|
{
|
|||
|
if (_IsRun) return;
|
|||
|
_IsRun = true;
|
|||
|
|
|||
|
Task.Run(() =>
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
var info = GetExchange_info();
|
|||
|
while (info != null)
|
|||
|
{
|
|||
|
Thread.Sleep(100);
|
|||
|
try
|
|||
|
{
|
|||
|
var session = ApiClient.GetSession();
|
|||
|
var member = session.FindMemberInfoById(info.uid);
|
|||
|
if (member == null) throw new Exception("用户数据异常");
|
|||
|
var robot = session.FindRobots().Where(f => f.id == info.rid).FirstOrDefault();
|
|||
|
if (robot == null) continue;
|
|||
|
var exchangePoint = member.cur_point;
|
|||
|
|
|||
|
if (exchangePoint >= Config.Exchange_Min_Point)
|
|||
|
{
|
|||
|
//查询用户今日兑换数量
|
|||
|
var exchange_num = session.Queryable<fl_point_hist>().Where(f => f.uid == member.id && f.type == "提现扣除" && f.crt_time >= DateTime.Today).Count();
|
|||
|
if (exchange_num >= Config.Exchange_Num)
|
|||
|
{
|
|||
|
ApiClient.SendMessage(robot, member.username, new VariateReplace().CommonReplace(Config.ExchangeInsufficientNumTip.Replace("[兑换次数]", Config.Exchange_Num.ToString()), member));//兑换次数不足
|
|||
|
continue;
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ApiClient.SendMessage(robot, member.username, new VariateReplace().CommonReplace(Config.ExchangeErrorTip, member).Replace("[最低提现额度]", Config.Exchange_Min_Point.ToString()), info.groupid);//兑换失败,积分不足提示语
|
|||
|
continue;
|
|||
|
}
|
|||
|
|
|||
|
if (Config.Integer_Exchange_Switch == SwitchType.开启 && exchangePoint >= 1)
|
|||
|
exchangePoint = Math.Floor(exchangePoint);
|
|||
|
|
|||
|
var back_apply_wx = false;//微信后台申请提现
|
|||
|
var remark = string.Empty;//人工审核原因
|
|||
|
|
|||
|
#region 微信兑换
|
|||
|
//微信商户转账转账 (满足最低兑积分兑换以及自动转账的最高兑换)
|
|||
|
if (member.exchange_type == ExchangeType.随系统设置)
|
|||
|
{
|
|||
|
if ((member.robot_type == ChatType.微信 || member.robot_type == ChatType.企业微信) && string.IsNullOrWhiteSpace(info.groupid) && Config.Exchange_PayType != PointPayType.关闭 && Config.Exchange_Transmatic_Maxpoint >= exchangePoint)
|
|||
|
{
|
|||
|
//当天微信自动转账金额中已经使用金额
|
|||
|
var sumpoint = session.Queryable<fl_exchange_info>().Where(f => f.IsTransmatic == true && f.rid == robot.id && f.time >= DateTime.Today).Sum(f => f.point);
|
|||
|
|
|||
|
if (Config.Exchange_Transmatic_SumPoint >= sumpoint)//每天的微信自动转账每日上限
|
|||
|
{
|
|||
|
//操作提现次数小于N次人工审核
|
|||
|
if (Config.Audit_Exchange_Frequency_SwitchType == SwitchType.开启)
|
|||
|
{
|
|||
|
if (long.Parse(session.FindTable("select count(id) as num from fl_exchange_info where uid = @uid", new { uid = member.id }).Rows[0]["num"].ToString()) < Config.Audit_Exchange_Frequency_Baseline)
|
|||
|
{
|
|||
|
member = session.ChangePoint(PointType.提现扣除, exchangePoint, member.id, "提现扣除【提交人工审核】.");//积分扣除
|
|||
|
|
|||
|
var exchangeList = new fl_exchange_info() { point = exchangePoint, state = ApplyType.未审核, time = DateTime.Now, uid = member.id, rid = robot.id, groupid = info.groupid };//保存用户兑换
|
|||
|
session.Insertable(exchangeList).ExecuteCommand();
|
|||
|
ApiClient.SendMessage(robot, member.username, new VariateReplace().CommonReplace(Config.ExchangeSuccessTip, member).Replace("[提现金额]", exchangePoint.ToString()), info.groupid);//成功提交兑换提示语
|
|||
|
string msg = new VariateReplace().CommonReplace(Config.ExchangeFrequencyLimitDingdingTip, member, robot).Replace("[提现金额]", exchangePoint.ToString());
|
|||
|
|
|||
|
//ApiClient.SendNoticeMessage(msg);//给钉钉发送消息
|
|||
|
if ((Config.notice_robotname == "请选择(钉钉/微信群机器人API名称)"))
|
|||
|
ApiClient.SendNoticeMessage(msg);//给钉钉发送消息
|
|||
|
else
|
|||
|
{
|
|||
|
var api = session.FindNoticeapiRobots().FirstOrDefault(f => f.name == Config.notice_robotname);
|
|||
|
if (api != null) ApiClient.SendNoticeMessage(api, msg);
|
|||
|
}
|
|||
|
|
|||
|
ApiClient.SendAdminEmail(ApiClient.Setting.SystemConfig.account_admin_email, "兑换次数限制需审核提醒", msg, true);
|
|||
|
continue;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (Config.Exchange_PayType == PointPayType.商户)
|
|||
|
{
|
|||
|
if (string.IsNullOrWhiteSpace(Config.ExchangeCommercialPayTip))
|
|||
|
{
|
|||
|
this.OnLog($"{robot.name} - {member.username}:商户付款提示语为空,操作终止,设置提示语后才能正常使用商户付款");
|
|||
|
continue;
|
|||
|
}
|
|||
|
|
|||
|
var ispaid = false;
|
|||
|
object appinfo = null;
|
|||
|
string url = ApiClient.SendWechatPay(new { robot_name = robot.name, robot_nick = robot.nick, username = member.username, usernick = member.usernick }, Class1.Config.ExchangePacketTitle.Replace("[积分名称]", ApiClient.Setting.SystemConfig.PointName).Replace("[兑换金额]", exchangePoint.ToString()), exchangePoint, out ispaid, out appinfo);
|
|||
|
|
|||
|
this.OnLog($@"{robot.name} - 【{member.usernick}({member.username})】商户连接:{(string.IsNullOrWhiteSpace(url) ? "空" : url)}
|
|||
|
appinfo is null:{(appinfo == null)}");
|
|||
|
if (!string.IsNullOrEmpty(url))
|
|||
|
{
|
|||
|
member = session.ChangePoint(PointType.提现扣除, exchangePoint, member.id, "提现扣除【商户付款成功】");
|
|||
|
session.Insertable<fl_exchange_info>(new fl_exchange_info() { point = exchangePoint, state = ApplyType.已审核, time = DateTime.Now, check_time = DateTime.Now, uid = member.id, remark = $"提现扣除【商户付款成功】 商户链接:{url}", rid = robot.id, IsTransmatic = true, groupid = info.groupid }).ExecuteCommand();//保存记录
|
|||
|
var pay_url = string.Empty;
|
|||
|
var mess_1 = string.Empty;
|
|||
|
if (ispaid)
|
|||
|
mess_1 = Config.ExchangeCommercialEftTip.Replace("[兑换金额]", exchangePoint.ToString());
|
|||
|
else
|
|||
|
{
|
|||
|
//pay_url = url;// ApiClient.ShortURL(url).Result;
|
|||
|
pay_url = ApiClient.ShortURL(url).Result;
|
|||
|
LogHelper.GetSingleObj().Info("商户提现链接", $"{member.usernick}({member.username});金额:{exchangePoint};原始:{url} => 缩短:{pay_url}");
|
|||
|
//if (string.IsNullOrWhiteSpace(pay_url))
|
|||
|
//{
|
|||
|
// pay_url = url;
|
|||
|
//}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
if (Config.ExchangeCommercialPayTip_MiniApp == SwitchType.开启 && appinfo != null)
|
|||
|
mess_1 = Util.GetMiNiAppXml(appinfo, robot.type);
|
|||
|
|
|||
|
if (string.IsNullOrWhiteSpace(mess_1))
|
|||
|
mess_1 = Config.ExchangeCommercialPayTip.Replace("[领取地址]", pay_url).Replace("[兑换金额]", exchangePoint.ToString());
|
|||
|
}
|
|||
|
var mess_2 = new VariateReplace().CommonReplace(Config.ExchangeAdoptTip.Replace("[兑换金额]", exchangePoint.ToString()).Replace("[领取地址]", pay_url), member);
|
|||
|
|
|||
|
ApiClient.SendMessage(
|
|||
|
new temp_send_data() { Groupid = info.groupid, Message = mess_1, Robot = robot, TouserName = member.username },
|
|||
|
new temp_send_data() { Groupid = info.groupid, Message = mess_2, Robot = robot, TouserName = member.username }
|
|||
|
);
|
|||
|
continue;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
var passInfo = session.FindWeixinpassword(robot.id);//微信自动转账
|
|||
|
if (passInfo != null && !string.IsNullOrEmpty(passInfo.password))//是否设置了账号密码
|
|||
|
{
|
|||
|
if (member.robot_type != Api.Framework.SDK.ChatType.微信) throw new Exception("暂时不支持自动转账!");
|
|||
|
var client = ChatClient.WXClient.Values.ToList().FirstOrDefault(f => f.WeixinHao == robot.name);
|
|||
|
if (client == null) throw new Exception(robot.name + ",该帐号没有登录!");
|
|||
|
if (client.WeixinType != Chat.Framework.WXSdk.Implement.WeixinType.Grpc微信) throw new Exception("您当前登录的微信版本,暂不支持自动转账!");
|
|||
|
|
|||
|
var flag = client.SendPay(member.username, Config.ExchangePacketTitle.Replace("[积分名称]", ApiClient.Setting.SystemConfig.PointName).Replace("[兑换金额]", exchangePoint.ToString()), (int)((decimal)exchangePoint * 100m), passInfo.password, 1, (Chat.Framework.WXSdk.IPAD.PayType)Enum.ToObject(typeof(Chat.Framework.WXSdk.IPAD.PayType), string.IsNullOrEmpty(info.groupid) ? ((int)Config.Exchange_PayType) : 2), passInfo.GetBank());//用户在群中进行提现操作时,将不会进行红包操作,强制以转账形式进行
|
|||
|
if (string.IsNullOrEmpty(flag))
|
|||
|
{
|
|||
|
member = session.ChangePoint(PointType.提现扣除, exchangePoint, member.id, "提现扣除【微信自动转账成功】");
|
|||
|
session.Insertable<fl_exchange_info>(new fl_exchange_info() { point = exchangePoint, state = ApplyType.已审核, time = DateTime.Now, check_time = DateTime.Now, uid = member.id, remark = "微信自动转账.", rid = robot.id, IsTransmatic = true, groupid = info.groupid }).ExecuteCommand();//保存记录
|
|||
|
ApiClient.SendMessage(robot, member.username, new VariateReplace().CommonReplace(Config.ExchangeTransmaticTip.Replace("[兑换金额]", exchangePoint.ToString()), member), info.groupid);//微信自动转账成功提示语
|
|||
|
continue;
|
|||
|
}
|
|||
|
else//转账失败,将提现请求提交至后台
|
|||
|
{
|
|||
|
if (Config.IsPaymentFailedUseCommercialPaySwitchType == SwitchType.开启)//微信支付失败,使用商户付款
|
|||
|
{
|
|||
|
if (string.IsNullOrWhiteSpace(Config.ExchangeCommercialPayTip))
|
|||
|
{
|
|||
|
this.OnLog($"{robot.name} - {member.username}:商户付款提示语为空,操作终止,设置提示语后才能正常使用商户付款");
|
|||
|
continue;
|
|||
|
}
|
|||
|
|
|||
|
var ispaid = false;
|
|||
|
object appinfo = null;
|
|||
|
string url = ApiClient.SendWechatPay(new { robot_name = robot.name, robot_nick = robot.nick, username = member.username, usernick = member.usernick }, Class1.Config.ExchangePacketTitle.Replace("[积分名称]", ApiClient.Setting.SystemConfig.PointName).Replace("[兑换金额]", exchangePoint.ToString()), exchangePoint, out ispaid, out appinfo);
|
|||
|
this.OnLog($@"{robot.name} - 【{member.usernick}({member.username})】商户连接:{url}
|
|||
|
appinfo is null:{(appinfo == null)}");
|
|||
|
if (!string.IsNullOrEmpty(url))
|
|||
|
{
|
|||
|
member = session.ChangePoint(PointType.提现扣除, exchangePoint, member.id, "提现扣除【微信自动转账失败,商户付款成功】");
|
|||
|
session.Insertable<fl_exchange_info>(new fl_exchange_info() { point = exchangePoint, state = ApplyType.已审核, time = DateTime.Now, check_time = DateTime.Now, uid = member.id, remark = $"提现扣除【微信自动转账失败,商户付款成功】 商户链接:{url}", rid = robot.id, IsTransmatic = true, groupid = info.groupid }).ExecuteCommand();//保存记录
|
|||
|
|
|||
|
var pay_url = string.Empty;
|
|||
|
var mess_1 = string.Empty;
|
|||
|
if (ispaid)
|
|||
|
mess_1 = Config.ExchangeCommercialEftTip.Replace("[兑换金额]", exchangePoint.ToString());
|
|||
|
else
|
|||
|
{
|
|||
|
if (Config.ExchangeCommercialPayTip_MiniApp == SwitchType.开启 && appinfo != null)
|
|||
|
mess_1 = Util.GetMiNiAppXml(appinfo, robot.type);
|
|||
|
|
|||
|
//pay_url = url;//ApiClient.ShortURL(url).Result;
|
|||
|
pay_url = ApiClient.ShortURL(url).Result;
|
|||
|
|
|||
|
LogHelper.GetSingleObj().Info("商户提现链接", $"{member.usernick}({member.username});金额:{exchangePoint};原始:{url} = > 缩短:{pay_url}");
|
|||
|
|
|||
|
if (string.IsNullOrWhiteSpace(mess_1))
|
|||
|
{
|
|||
|
mess_1 = Config.ExchangeCommercialPayTip.Replace("[领取地址]", pay_url).Replace("[兑换金额]", exchangePoint.ToString());
|
|||
|
}
|
|||
|
}
|
|||
|
var mess_2 = new VariateReplace().CommonReplace(Config.ExchangeAdoptTip.Replace("[兑换金额]", exchangePoint.ToString()).Replace("[领取地址]", pay_url), member);
|
|||
|
|
|||
|
ApiClient.SendMessage(
|
|||
|
new temp_send_data() { Groupid = info.groupid, Message = mess_1, Robot = robot, TouserName = member.username },
|
|||
|
new temp_send_data() { Groupid = info.groupid, Message = mess_2, Robot = robot, TouserName = member.username });
|
|||
|
continue;
|
|||
|
}
|
|||
|
else this.OnLog($"{robot.name} - {member.username}:商户付款兑换积分失败:创建订单号失败");
|
|||
|
}
|
|||
|
back_apply_wx = true;
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
//未设置微信支付密码,使用商户开启
|
|||
|
if (Class1.Config.IsEmptyPasswordUseCommercialPaySwitchType == SwitchType.开启)
|
|||
|
{
|
|||
|
if (string.IsNullOrWhiteSpace(Config.ExchangeCommercialPayTip))
|
|||
|
{
|
|||
|
this.OnLog($"{robot.name} - {member.username}:商户付款提示语为空,操作终止,设置提示语后才能正常使用商户付款");
|
|||
|
continue;
|
|||
|
}
|
|||
|
|
|||
|
var ispaid = false;
|
|||
|
object appinfo = null;
|
|||
|
string url = ApiClient.SendWechatPay(new { robot_name = robot.name, robot_nick = robot.nick, username = member.username, usernick = member.usernick }, Class1.Config.ExchangePacketTitle.Replace("[积分名称]", ApiClient.Setting.SystemConfig.PointName).Replace("[兑换金额]", exchangePoint.ToString()), exchangePoint, out ispaid, out appinfo);
|
|||
|
this.OnLog($@"{robot.name} - 【{member.usernick}({member.username})】商户连接:{url}
|
|||
|
appinfo is null:{(appinfo == null)}");
|
|||
|
if (!string.IsNullOrEmpty(url))
|
|||
|
{
|
|||
|
member = session.ChangePoint(PointType.提现扣除, exchangePoint, member.id, "提现扣除【微信字支付未开,商户付款成功】");
|
|||
|
session.Insertable<fl_exchange_info>(new fl_exchange_info() { point = exchangePoint, state = ApplyType.已审核, time = DateTime.Now, check_time = DateTime.Now, uid = member.id, remark = $"提现扣除【微信支付未开,商户付款成功】 商户链接:{url}", rid = robot.id, IsTransmatic = true, groupid = info.groupid }).ExecuteCommand();//保存记录
|
|||
|
|
|||
|
var pay_url = string.Empty;
|
|||
|
var mess_1 = string.Empty;
|
|||
|
if (ispaid)
|
|||
|
mess_1 = Config.ExchangeCommercialEftTip.Replace("[兑换金额]", exchangePoint.ToString());
|
|||
|
else
|
|||
|
{
|
|||
|
if (Config.ExchangeCommercialPayTip_MiniApp == SwitchType.开启 && appinfo != null)
|
|||
|
mess_1 = Util.GetMiNiAppXml(appinfo, robot.type);
|
|||
|
|
|||
|
//pay_url = url;//ApiClient.ShortURL(url).Result;
|
|||
|
pay_url = ApiClient.ShortURL(url).Result;
|
|||
|
|
|||
|
LogHelper.GetSingleObj().Info("商户提现链接", $"{member.usernick}({member.username});金额:{exchangePoint};原始:{url} = > 缩短:{pay_url}");
|
|||
|
|
|||
|
if (string.IsNullOrWhiteSpace(mess_1))
|
|||
|
mess_1 = Config.ExchangeCommercialPayTip.Replace("[领取地址]", pay_url).Replace("[兑换金额]", exchangePoint.ToString());
|
|||
|
}
|
|||
|
var mess_2 = new VariateReplace().CommonReplace(Config.ExchangeAdoptTip.Replace("[兑换金额]", exchangePoint.ToString()).Replace("[领取地址]", pay_url), member);
|
|||
|
|
|||
|
ApiClient.SendMessage(
|
|||
|
new temp_send_data() { Groupid = info.groupid, Message = mess_1, Robot = robot, TouserName = member.username },
|
|||
|
new temp_send_data() { Groupid = info.groupid, Message = mess_2, Robot = robot, TouserName = member.username });
|
|||
|
continue;
|
|||
|
}
|
|||
|
else this.OnLog($"{robot.name} - {member.username}:微信未设置支付密码。并且商户付款兑换积分失败:付款链接为空..已转至人工兑换");
|
|||
|
}
|
|||
|
else
|
|||
|
//this.OnLog($"{robot.name} - {member.username}:微信支付积分兑换失败:未设置支付密码。已转至人工兑换");
|
|||
|
this.OnLog($"{robot.name} - {member.username}:未设置支付密码使用商户付款-关闭状态。已转至人工兑换");
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
this.OnLog($"{robot.name} - {member.username}:今日微信自动转账金额已达上限({Config.Exchange_Transmatic_SumPoint}元),已转至人工兑换");
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
back_apply_wx = true;
|
|||
|
remark = "系统设置人工审核";
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 支付宝兑换 (超出了自动转账的条件)
|
|||
|
var exchange_NotAudited = session.Find<fl_exchange_info>("select * from fl_exchange_info where uid = @uid and state = 1", new { uid = member.id });
|
|||
|
if (exchange_NotAudited.Count != 0)//重复提交
|
|||
|
{
|
|||
|
ApiClient.SendMessage(robot, member.username, new VariateReplace().CommonReplace(Config.ExchangeUntreatedTip, member).Replace("[提现金额]", exchange_NotAudited[0].point.ToString()), info.groupid);//尚有未处理的订单
|
|||
|
continue;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
//微信人工兑换
|
|||
|
double point = 0d;
|
|||
|
if (Config.AlipaySwitch == SwitchType.开启)//支付宝兑换
|
|||
|
{
|
|||
|
//未绑定支付宝账号
|
|||
|
if (string.IsNullOrWhiteSpace(member.alipay_name) || string.IsNullOrWhiteSpace(member.alipay_num))
|
|||
|
{
|
|||
|
ApiClient.SendMessage(robot, member.username, Config.ExchangeUnBindAlipayTip, info.groupid);
|
|||
|
continue;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (back_apply_wx)
|
|||
|
point = exchangePoint;
|
|||
|
else
|
|||
|
point = Config.Exchange_Max_Point >= exchangePoint ? exchangePoint : Config.Exchange_Max_Point;//如果积分高于最高兑换,则只能兑换最高的积分值.反之只能兑换所有的积分
|
|||
|
member = session.ChangePoint(PointType.提现扣除, point, member.id, $"提现扣除【提交人工审核】{remark}");//积分扣除
|
|||
|
|
|||
|
var exchangeList = new fl_exchange_info() { point = point, state = ApplyType.未审核, time = DateTime.Now, uid = member.id, rid = robot.id, groupid = info.groupid };//保存用户兑换
|
|||
|
session.Insertable<fl_exchange_info>(exchangeList).ExecuteCommand();
|
|||
|
ApiClient.SendMessage(robot, member.username, new VariateReplace().CommonReplace(Config.ExchangeSuccessTip, member).Replace("[提现金额]", point.ToString()), info.groupid);//成功提交兑换提示语
|
|||
|
string msg = new VariateReplace().CommonReplace(Config.ExchangeSuccessDingdingTip, member, robot).Replace("[提现金额]", point.ToString());
|
|||
|
if ((Config.notice_robotname == "请选择(钉钉/微信群机器人API名称)"))
|
|||
|
ApiClient.SendNoticeMessage(msg);//给钉钉发送消息
|
|||
|
else
|
|||
|
{
|
|||
|
var api = session.FindNoticeapiRobots().FirstOrDefault(f => f.name == Config.notice_robotname);
|
|||
|
if (api != null) ApiClient.SendNoticeMessage(api, msg);
|
|||
|
}
|
|||
|
ApiClient.SendAdminEmail(ApiClient.Setting.SystemConfig.account_admin_email, "兑换审核提醒", msg, true);
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
this.OnLog($"提现异常:{ex.Message} ~ {ex.StackTrace}");
|
|||
|
}
|
|||
|
finally
|
|||
|
{
|
|||
|
info = GetExchange_info();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
this.OnLog($"提现异常:{ex.Message} - {ex.StackTrace}");
|
|||
|
}
|
|||
|
finally
|
|||
|
{
|
|||
|
_IsRun = false;
|
|||
|
}
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
private readonly object AwardLock = new object();
|
|||
|
private readonly object ExchangeLock = new object();
|
|||
|
private readonly object SignInLock = new object();
|
|||
|
|
|||
|
private static bool flag = false;
|
|||
|
private void SDK_ReciveIMEvent(object sender, ReciveIMEvent e)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
#region 抢红包功能
|
|||
|
if (Config.Extra_Award_Switch == SwitchType.开启 && !string.IsNullOrWhiteSpace(Config.Extra_Award_CMD))
|
|||
|
{
|
|||
|
var reg = Regex.Match(e.Message.Trim(), Config.Extra_Award_CMD);
|
|||
|
if (reg.Success)
|
|||
|
{
|
|||
|
var session = ApiClient.GetSession();
|
|||
|
var award = session.FindSingle<fl_plugin_pointmanage_extra_award>("select * from fl_plugin_pointmanage_extra_award where uid = @uid", new { uid = e.GetMemberinfo().id });
|
|||
|
if (award == null)
|
|||
|
{
|
|||
|
award = new fl_plugin_pointmanage_extra_award() { uid = e.GetMemberinfo().id, count = 0 };
|
|||
|
session.SaveExtraAward(award);
|
|||
|
}
|
|||
|
|
|||
|
string mess = string.Empty;
|
|||
|
if (award.count <= 0)
|
|||
|
{
|
|||
|
mess = new VariateReplace().CommonReplace(Config.Extra_AwardErrorTip, e.GetMemberinfo());
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
lock (AwardLock)
|
|||
|
{
|
|||
|
var point = Math.Round((new Random().Next(
|
|||
|
int.Parse(Math.Round(Config.Extra_Award_Min_Point * 100, 2).ToString()),
|
|||
|
int.Parse(Math.Round((Config.Extra_Award_Max_Point + 0.01) * 100, 2).ToString())
|
|||
|
)) / 100d, 2);
|
|||
|
var member = session.ChangePoint(PointType.其他奖励, point, e.GetMemberinfo().id, $"抢红包:{point}");
|
|||
|
mess = new VariateReplace().CommonReplace(Config.Extra_AwardSuccessTip.Replace("[红包金额]", point.ToString("0.00")), member);
|
|||
|
award.count--;
|
|||
|
session.SaveExtraAward(award);
|
|||
|
}
|
|||
|
}
|
|||
|
e.SendMessage(mess);
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 签到指令
|
|||
|
//签到指令
|
|||
|
if (Config.Checkin_Switch == SwitchType.开启)
|
|||
|
{
|
|||
|
if (!string.IsNullOrWhiteSpace(Config.Checkin_CMD) && Regex.IsMatch(e.Message.Trim(), Config.Checkin_CMD))
|
|||
|
{
|
|||
|
lock (SignInLock)
|
|||
|
{
|
|||
|
var key = e.Username + "_SignIn";
|
|||
|
if (Util.GetCache(key))
|
|||
|
{
|
|||
|
e.SendMessage(Config.CheckinRepeatTip);//重复签到提示
|
|||
|
return;
|
|||
|
}
|
|||
|
Util.SetCache(key, 30);
|
|||
|
}
|
|||
|
|
|||
|
string mess = string.Empty;
|
|||
|
var session = ApiClient.GetSession();
|
|||
|
var memberinfo = e.GetMemberinfo();
|
|||
|
if (Config.Restrict_Switch == SwitchType.开启)
|
|||
|
{
|
|||
|
var day = DateTime.Today.AddMonths(-Config.CheckinRestrictMonth);
|
|||
|
var data = session.FindRow($@"select COALESCE(SUM(num), 0) as num from(select count(*) as num from fl_order_alimama where db_userid = @id and db_status = 1002 and db_endtime >= @day
|
|||
|
UNION all
|
|||
|
select count(*) as num from fl_order_jingdong where db_userid = @id and db_status = 1002 and db_endtime >= @day
|
|||
|
UNION all
|
|||
|
select count(*) as num from fl_order_pinduoduo where db_userid = @id and db_status = 1002 and db_endtime >= @day
|
|||
|
UNION all
|
|||
|
select count(*) as num from fl_order_weipinhui where db_userid = @id and db_status = 1002 and db_endtime >= @day) as temp", new { id = e.GetMemberinfo().id, day = day.ToString("yyyy-MM-dd HH:mm:ss") })["num"].ToString();
|
|||
|
|
|||
|
if (int.Parse(data) <= 0)
|
|||
|
{
|
|||
|
e.SendMessage(Config.CheckinRestrictTip);
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
var checkin = session.Find<fl_plugin_pointmanage_checkin_info>($"select * from fl_plugin_pointmanage_checkin_info where uid = '{e.GetMemberinfo().id}'").FirstOrDefault();
|
|||
|
if (checkin == null)
|
|||
|
{
|
|||
|
checkin = new fl_plugin_pointmanage_checkin_info() { uid = e.GetMemberinfo().id, days = 1, time = DateTime.Now, chatType = e.ChatType, sumday = 1 };
|
|||
|
//签到成功1天,没有签到过
|
|||
|
var point = SigninReward();
|
|||
|
//积分的修改
|
|||
|
memberinfo = session.ChangePoint(PointType.其他奖励, point, memberinfo.id, "签到积分奖励");
|
|||
|
mess = new VariateReplace().CommonReplace(Config.CheckinSuccessTip, memberinfo)
|
|||
|
.Replace("[签到奖励]", point.ToString())
|
|||
|
.Replace("[连续签到次数]", "1")
|
|||
|
.Replace("[总共签到次数]", "1")
|
|||
|
.Replace("[每日语录]", Config.CheckinSuccessTip.Contains("[每日语录]") ? FindYuLu() : string.Empty);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
var baseTime = DateTime.Parse("2019-09-01 00:00:00");
|
|||
|
|
|||
|
var newTime = DateTime.Now;
|
|||
|
|
|||
|
var intervalHours = Math.Floor((newTime - baseTime).TotalHours / Config.Checkin_Period);
|
|||
|
var comparisonTime = baseTime.AddHours(intervalHours * Config.Checkin_Period);
|
|||
|
if (comparisonTime < checkin.time)//如果用户的签到时间比当前签到时间大,那么这个用户已经签到过了
|
|||
|
{
|
|||
|
e.SendMessage(Config.CheckinRepeatTip);//重复签到提示
|
|||
|
return;
|
|||
|
}
|
|||
|
else if ((checkin.time.AddHours(Config.Checkin_Period) >= comparisonTime))
|
|||
|
{
|
|||
|
//连续签到
|
|||
|
checkin.time = DateTime.Now;
|
|||
|
checkin.days += 1;
|
|||
|
checkin.sumday += 1;
|
|||
|
var point = SigninReward();
|
|||
|
//积分的修改
|
|||
|
memberinfo = session.ChangePoint(PointType.其他奖励, point, memberinfo.id, "签到积分奖励");
|
|||
|
mess = new VariateReplace().CommonReplace(Config.CheckinSuccessTip, memberinfo)
|
|||
|
.Replace("[签到奖励]", point.ToString())
|
|||
|
.Replace("[连续签到次数]", checkin.days.ToString())
|
|||
|
.Replace("[总共签到次数]", checkin.sumday.ToString())
|
|||
|
.Replace("[每日语录]", Config.CheckinSuccessTip.Contains("[每日语录]") ? FindYuLu() : string.Empty);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
//签到中断
|
|||
|
checkin.time = DateTime.Now;
|
|||
|
checkin.days = 1;
|
|||
|
checkin.sumday += 1;
|
|||
|
var point = SigninReward();
|
|||
|
|
|||
|
//积分的修改
|
|||
|
memberinfo = session.ChangePoint(PointType.其他奖励, point, memberinfo.id, "签到积分奖励");
|
|||
|
mess = new VariateReplace().CommonReplace(Config.CheckinSuccessTip, memberinfo)
|
|||
|
.Replace("[签到奖励]", point.ToString())
|
|||
|
.Replace("[连续签到次数]", "1")
|
|||
|
.Replace("[总共签到次数]", checkin.sumday.ToString())
|
|||
|
.Replace("[每日语录]", Config.CheckinSuccessTip.Contains("[每日语录]") ? FindYuLu() : string.Empty);
|
|||
|
}
|
|||
|
}
|
|||
|
session.Saveable(checkin).ExecuteReturnEntity();
|
|||
|
|
|||
|
if (!string.IsNullOrEmpty(mess))
|
|||
|
{
|
|||
|
e.SendMessage(mess);
|
|||
|
e.Cancel = true;
|
|||
|
return;
|
|||
|
}
|
|||
|
//}
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 用户支付宝绑定
|
|||
|
if (!string.IsNullOrWhiteSpace(Config.Alipay_Bind_CMD) && !string.IsNullOrWhiteSpace(Config.Alipay_ChatType))
|
|||
|
{
|
|||
|
var chatStr = Config.Alipay_ChatType.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).ToList();
|
|||
|
if (chatStr.Contains(e.ChatType.ToString()))
|
|||
|
{
|
|||
|
var reg = Regex.Match(e.Message.Trim(), Config.Alipay_Bind_CMD);
|
|||
|
if (reg.Success)
|
|||
|
{
|
|||
|
var session = ApiClient.GetSession();
|
|||
|
e.GetMemberinfo().alipay_num = reg.Groups["账号"].ToString().Trim();
|
|||
|
e.GetMemberinfo().alipay_name = reg.Groups["名称"].ToString().Trim();
|
|||
|
session.SaveOrUpdate(e.GetMemberinfo());
|
|||
|
e.SendMessage(new VariateReplace().CommonReplace(Config.AlipayBindSuccessTip, e.GetMemberinfo()));
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 用户身份证绑定
|
|||
|
if (!string.IsNullOrWhiteSpace(Config.IdentityId_Bind_CMD))
|
|||
|
{
|
|||
|
var reg = Regex.Match(e.Message.Trim(), Config.IdentityId_Bind_CMD);
|
|||
|
if (reg.Success)
|
|||
|
{
|
|||
|
var session = ApiClient.GetSession();
|
|||
|
if (Regex.IsMatch(reg.Groups["身份证号"].ToString().Trim(), @"(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$)"))
|
|||
|
{
|
|||
|
var idcard = reg.Groups["身份证号"].ToString().Trim();
|
|||
|
var realname = reg.Groups["姓名"].ToString().Trim();
|
|||
|
try
|
|||
|
{
|
|||
|
var flag = false;
|
|||
|
if (string.IsNullOrWhiteSpace(Config.IdentityIdCheckAppKey) && string.IsNullOrWhiteSpace(Config.IdentityIdMatchAppKey))
|
|||
|
{
|
|||
|
flag = true;
|
|||
|
}
|
|||
|
|
|||
|
var http = new HttpHelper();
|
|||
|
var item = new HttpItem();
|
|||
|
|
|||
|
if (!string.IsNullOrWhiteSpace(Config.IdentityIdCheckAppKey))
|
|||
|
{
|
|||
|
item.URL = $"http://apis.juhe.cn/idcard/index?key={Config.IdentityIdCheckAppKey}&cardno={idcard}";
|
|||
|
var result = http.GetHtml(item);
|
|||
|
var jsonObj = HttpExtend.JsonToDictionary(result.Html);
|
|||
|
if (jsonObj != null)
|
|||
|
{
|
|||
|
if (jsonObj.ContainsKey("resultcode"))
|
|||
|
{
|
|||
|
if (jsonObj["resultcode"].ToString() != "200" && jsonObj.ContainsKey("reason")) throw new Exception("异常");
|
|||
|
flag = true;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if ((string.IsNullOrWhiteSpace(Config.IdentityIdCheckAppKey) || flag) && !string.IsNullOrWhiteSpace(Config.IdentityIdMatchAppKey))
|
|||
|
{
|
|||
|
item.URL = $"http://op.juhe.cn/idcard/query?key={Config.IdentityIdMatchAppKey}&idcard={idcard}&realname={realname}";
|
|||
|
var result = http.GetHtml(item);
|
|||
|
var jsonObj = HttpExtend.JsonToDictionary(result.Html);
|
|||
|
if (jsonObj != null && jsonObj.ContainsKey("error_code"))
|
|||
|
{
|
|||
|
if (jsonObj["error_code"].ToString() == "0")
|
|||
|
{
|
|||
|
if (jsonObj.ContainsKey("result"))
|
|||
|
{
|
|||
|
var _result = jsonObj["result"] as Dictionary<string, object>;
|
|||
|
if (_result.ContainsKey("res"))
|
|||
|
{
|
|||
|
if (_result["res"].ToString() == "1") /*1:匹配 2:不匹配*/
|
|||
|
{
|
|||
|
e.GetMemberinfo().identity_card = idcard;
|
|||
|
e.GetMemberinfo().identity_name = realname;
|
|||
|
session.SaveOrUpdate(e.GetMemberinfo());
|
|||
|
e.SendMessage(new VariateReplace().CommonReplace(Config.IdentityIdBindSuccessTip, e.GetMemberinfo()));
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
throw new Exception("异常");
|
|||
|
}
|
|||
|
}
|
|||
|
else if (flag && string.IsNullOrWhiteSpace(Config.IdentityIdMatchAppKey))
|
|||
|
{
|
|||
|
e.GetMemberinfo().identity_card = idcard;
|
|||
|
e.GetMemberinfo().identity_name = realname;
|
|||
|
session.SaveOrUpdate(e.GetMemberinfo());
|
|||
|
e.SendMessage(new VariateReplace().CommonReplace(Config.IdentityIdBindSuccessTip, e.GetMemberinfo()));
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{
|
|||
|
e.SendMessage(new VariateReplace().CommonReplace(Config.IdentityIdBindUSuccessTip.Replace("[姓名]", "[身份证姓名]").Replace("[身份证姓名]", realname).Replace("[身份证号]", "[身份证号码]").Replace("[身份证号码]", idcard), e.GetMemberinfo()));
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
e.SendMessage(new VariateReplace().CommonReplace(Config.IdentityIdBindUSuccessTip.Replace("[姓名]", "[身份证姓名]").Replace("[身份证姓名]", reg.Groups["姓名"].ToString().Trim()).Replace("[身份证号]", "[身份证号码]").Replace("[身份证号码]", reg.Groups["身份证号"].ToString().Trim()), e.GetMemberinfo()));
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 查看用户积分信息
|
|||
|
if (Regex.IsMatch(e.Message.Trim(), Config.CheckUserPoint_CMD))
|
|||
|
{
|
|||
|
var session = ApiClient.GetSession();
|
|||
|
var _member = e.GetMemberinfo(true);
|
|||
|
if (_member != null)
|
|||
|
{
|
|||
|
var str = new VariateReplace().CommonReplace(Config.CheckPointSuccessTip, _member);
|
|||
|
e.SendMessage(str);
|
|||
|
e.Cancel = true;
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 兑换积分
|
|||
|
if (!string.IsNullOrWhiteSpace(Config.Exchange_CMD) && Regex.IsMatch(e.Message.Trim(), Config.Exchange_CMD))
|
|||
|
{
|
|||
|
lock (ExchangeLock)
|
|||
|
{
|
|||
|
var memberinfo = e.GetMemberinfo(true);
|
|||
|
double exchangePoint = memberinfo.cur_point;//兑换积分
|
|||
|
this.OnLog($"用户({memberinfo.username})余额:" + exchangePoint);
|
|||
|
|
|||
|
//限制兑换
|
|||
|
if (DateTime.Now <= memberinfo.ban_exchange_time)
|
|||
|
{
|
|||
|
e.SendMessage(new VariateReplace().CommonReplace(Config.Ban_Exchange_Tip, memberinfo));
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
//无购物不让提现
|
|||
|
if (Config.Unsettled_Forbid_Exchange == SwitchType.开启 && memberinfo.finish_order == 0)
|
|||
|
{
|
|||
|
if (memberinfo.bind_order != 0)
|
|||
|
e.SendMessage(Config.Unsettled_Forbid_Exchange_Tip);//无购物记录不予兑换
|
|||
|
else
|
|||
|
e.SendMessage(Config.NotReceiving_Forbid_Exchange_Tip);//无购物记录不予兑换
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
#region 支付宝绑定
|
|||
|
if (Config.IdentityIdSwitch == SwitchType.开启 && (string.IsNullOrWhiteSpace(e.GetMemberinfo().identity_card) || string.IsNullOrWhiteSpace(e.GetMemberinfo().identity_name)))
|
|||
|
{
|
|||
|
e.SendMessage(Config.IdentityIdUnBindExchangeTip);//当前未绑定身份证
|
|||
|
return;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
var session = ApiClient.GetSession();
|
|||
|
|
|||
|
#region 是否存在审核的订单
|
|||
|
var exchange_NotAudited_ = session.Find<fl_exchange_info>("select * from fl_exchange_info where uid = @uid and state = 1", new { uid = memberinfo.id });
|
|||
|
if (exchange_NotAudited_.Count != 0)
|
|||
|
{
|
|||
|
e.SendMessage(new VariateReplace().CommonReplace(Config.ExchangeUntreatedTip, memberinfo.id).Replace("[提现金额]", exchange_NotAudited_[0].point.ToString()));//尚有未处理的订单
|
|||
|
return;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 群内提现限制开关
|
|||
|
if (!string.IsNullOrWhiteSpace(e.Groupid) && Config.ExchangeErrorGroupBan_SwitchType == SwitchType.开启)
|
|||
|
{
|
|||
|
e.SendMessage(new VariateReplace().CommonReplace(Config.ExchangeErrorGroupBanTip, memberinfo));
|
|||
|
return;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
if (exchangePoint >= Config.Exchange_Min_Point)
|
|||
|
{
|
|||
|
//查询用户今日兑换数量
|
|||
|
var exchange_num = session.Queryable<fl_point_hist>().Where(f => f.uid == memberinfo.id && f.type == "提现扣除" && f.crt_time >= DateTime.Today).Count();
|
|||
|
|
|||
|
if (exchange_num >= Config.Exchange_Num)
|
|||
|
{
|
|||
|
e.SendMessage(new VariateReplace().CommonReplace(Config.ExchangeInsufficientNumTip.Replace("[兑换次数]", Config.Exchange_Num.ToString()), memberinfo));//兑换次数不足
|
|||
|
return;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
var data = exchangeQueue.FirstOrDefault(f => f.uid == e.GetMemberinfo().id);
|
|||
|
if (data == null)
|
|||
|
{
|
|||
|
exchangeQueue.Enqueue(new exchange_info() { uid = e.GetMemberinfo().id, rid = e.RobotInfo.id, groupid = e.Groupid });
|
|||
|
_ExchangeAction();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
e.SendMessage("提现处理中请稍后...");
|
|||
|
}
|
|||
|
e.Cancel = true;
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
e.SendMessage(new VariateReplace().CommonReplace(Config.ExchangeErrorTip, memberinfo).Replace("[最低提现额度]", Config.Exchange_Min_Point.ToString()));//兑换失败,积分不足提示语
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
this.OnLog("A:" + ex.Message);
|
|||
|
e.SendMessage(ApiClient.Setting.SystemConfig.msg_error);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#region 签到奖励积分
|
|||
|
/// <summary>
|
|||
|
/// 签到奖励积分
|
|||
|
/// </summary>
|
|||
|
/// <returns></returns>
|
|||
|
private double SigninReward()
|
|||
|
{
|
|||
|
Random r = new Random(Guid.NewGuid().GetHashCode());
|
|||
|
return Math.Round((r.Next((int)(Config.Checkin_Reward_Min * 100.00d), (int)(Config.Checkin_Reward_Max * 100.00d))) / 100.00d, 2);
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
internal const string _key = "<RSAKeyValue><Modulus>wmUZgme6iOPOaMTZtPu5DKQ8Dph9fSgy6abFyQv25MD8xOMPBBo0wsLUOVt8r9sk+li11mIg1fs1HPJ75UmIle+w9xhIx/nsXWejuQhXlQV0VyJtzI+id8G+FcyYaog91MfPndJoO3m30fSjE/0KDLDmv1EeQcP24RAzeA29p7c=</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>";
|
|||
|
/// <summary>
|
|||
|
///
|
|||
|
/// </summary>
|
|||
|
/// <returns></returns>
|
|||
|
private string FindYuLu()
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
AuthEndpoint end = new AuthEndpoint()
|
|||
|
{
|
|||
|
Appid = 10004,
|
|||
|
Enckey = _key,
|
|||
|
//Host = "https://cps.api.52cmg.cn/api/webtool.asmx/send_data",
|
|||
|
Host = $"{ApiClient.Setting.SystemConfig.cps_server_api}api/webtool.asmx/send_data",
|
|||
|
Method = "find_yulu"
|
|||
|
};
|
|||
|
HttpHelper http = new HttpHelper();
|
|||
|
var date = http.SendData(end, false);
|
|||
|
if (date.ok)
|
|||
|
return date.message.ToString();
|
|||
|
else
|
|||
|
return string.Empty;
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
this.OnLog("获取语录失败:" + ex.Message);
|
|||
|
}
|
|||
|
return string.Empty;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|