|
|
@@ -48,7 +48,8 @@ namespace MySystem
|
|
|
while (DoCount < list.Rows.Count)
|
|
|
{
|
|
|
WebCMSEntities db = new WebCMSEntities();
|
|
|
- //导入人工已退
|
|
|
+ SpModels.WebCMSEntities spdb = new SpModels.WebCMSEntities();
|
|
|
+ //导激活
|
|
|
if (_Kind == "1")
|
|
|
{
|
|
|
var tran = db.Database.BeginTransaction();
|
|
|
@@ -63,37 +64,273 @@ namespace MySystem
|
|
|
for (int i = DoCount; i < DoCount + Size; i++)
|
|
|
{
|
|
|
DataRow dr = list.Rows[i];
|
|
|
- string PosSn = dr[0].ToString().Replace("机具SN:", "");// 退押机具Sn
|
|
|
- string Statuss = dr[1].ToString(); // 结果
|
|
|
- string SeoDescription = dr[2].ToString();// 备注
|
|
|
- int Status = 0;
|
|
|
- if (Statuss == "SUCCESS")//成功
|
|
|
+ string OrderNo = dr["订单编码"].ToString();
|
|
|
+ string CreateDate = dr["订单创建时间"].ToString();
|
|
|
+ string PhoneNumber = dr["选择号码"].ToString();
|
|
|
+ string HasFirstCharge = dr["是否有首充"].ToString();
|
|
|
+ string FirstChargeAmount = dr["首充金额(元)"].ToString();
|
|
|
+ string Province = dr["号码归属省份"].ToString();
|
|
|
+ string City = dr["号码归属地市"].ToString();
|
|
|
+ string ProductName = dr["商品名称"].ToString();
|
|
|
+ string ActiveName = dr["促销活动名称"].ToString();
|
|
|
+ string ProductType = dr["商品类型名称"].ToString();
|
|
|
+ string ActualAmount = dr["实付金额(元)"].ToString();
|
|
|
+ string OrderStatus = dr["订单状态"].ToString();
|
|
|
+ string ActStatus = dr["激活状态名称"].ToString();
|
|
|
+ string ActDate = dr["激活时间"].ToString();
|
|
|
+ string WorkNo = dr["BOSS员工工号"].ToString();
|
|
|
+ string AccountName = dr["账号姓名"].ToString();
|
|
|
+ string SimNo = dr["SIM卡号"].ToString();
|
|
|
+
|
|
|
+ // PosMerchantInfo checkMer = db.PosMerchantInfo.FirstOrDefault(m => m.KqMerNo == PhoneNumber && m.Field5 == ActStatus);
|
|
|
+ // if (checkMer == null)
|
|
|
+ // {
|
|
|
+ string json = "{";
|
|
|
+ json += "\"OrderNo\":\"" + OrderNo + "\",";
|
|
|
+ json += "\"CreateDate\":\"" + CreateDate + "\",";
|
|
|
+ json += "\"PhoneNumber\":\"" + PhoneNumber + "\",";
|
|
|
+ json += "\"HasFirstCharge\":\"" + HasFirstCharge + "\",";
|
|
|
+ json += "\"FirstChargeAmount\":\"" + FirstChargeAmount + "\",";
|
|
|
+ json += "\"Province\":\"" + Province + "\",";
|
|
|
+ json += "\"City\":\"" + City + "\",";
|
|
|
+ json += "\"ProductName\":\"" + ProductName + "\",";
|
|
|
+ json += "\"ActiveName\":\"" + ActiveName + "\",";
|
|
|
+ json += "\"ProductType\":\"" + ProductType + "\",";
|
|
|
+ json += "\"ActualAmount\":\"" + ActualAmount + "\",";
|
|
|
+ json += "\"OrderStatus\":\"" + OrderStatus + "\",";
|
|
|
+ json += "\"ActStatus\":\"" + ActStatus + "\",";
|
|
|
+ json += "\"ActDate\":\"" + ActDate + "\",";
|
|
|
+ json += "\"WorkNo\":\"" + WorkNo + "\",";
|
|
|
+ json += "\"AccountName\":\"" + AccountName + "\",";
|
|
|
+ json += "\"SimNo\":\"" + SimNo + "\"";
|
|
|
+ json += "}";
|
|
|
+
|
|
|
+ spdb.BindRecord.Add(new SpModels.BindRecord()
|
|
|
{
|
|
|
- Status = 1;
|
|
|
- }
|
|
|
- if (Statuss == "FAIL")//失败
|
|
|
+ CreateDate = DateTime.Parse(CreateDate),
|
|
|
+ UpdateTime = DateTime.Parse(CreateDate), //机具绑定、解绑时间
|
|
|
+ CreateTime = DateTime.Parse(CreateDate), //商户操作时间
|
|
|
+ MerNewSnNo = PhoneNumber, //商户手机号
|
|
|
+ MerSnNo = SimNo, //序列号
|
|
|
+ MerName = AccountName, //商户名称
|
|
|
+ MerNo = PhoneNumber, //商户编号
|
|
|
+ Remark = ProductType,
|
|
|
+ Field1 = Province,
|
|
|
+ Field2 = ActiveName,
|
|
|
+ Field3 = ProductName,
|
|
|
+ Field4 = WorkNo,
|
|
|
+ Field5 = ActStatus,
|
|
|
+ SeoTitle = ActualAmount,
|
|
|
+ SeoKeyword = ActDate,
|
|
|
+ SeoDescription = json,
|
|
|
+ ProductType = "14",
|
|
|
+ Status = 1,
|
|
|
+ });
|
|
|
+
|
|
|
+ spdb.Merchants.Add(new SpModels.Merchants()
|
|
|
{
|
|
|
- Status = 2;
|
|
|
- }
|
|
|
- var pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == PosSn) ?? new PosMachinesTwo();
|
|
|
- var merchantDepositReturns = db.MerchantDepositReturns.FirstOrDefault(m => m.MerchantId == pos.BindMerchantId && m.Status == 0) ?? new MerchantDepositReturns();
|
|
|
- if (merchantDepositReturns.Id == 0)
|
|
|
+ SnNo = SimNo,
|
|
|
+ CreateTime = DateTime.Parse(CreateDate),
|
|
|
+ UpdateTime = DateTime.Parse(CreateDate),
|
|
|
+ AgentName = AccountName,
|
|
|
+ MerRealName = AccountName,
|
|
|
+ MerMobile = PhoneNumber,
|
|
|
+ MerNo = PhoneNumber,
|
|
|
+ MerName = AccountName,
|
|
|
+ ProductType = "14",
|
|
|
+ Status = 1,
|
|
|
+ });
|
|
|
+ SuccessCount += 1;
|
|
|
+ }
|
|
|
+ DoCount += Size;
|
|
|
+ db.SaveChanges();
|
|
|
+ tran.Commit();
|
|
|
+ if (DoCount >= list.Rows.Count)
|
|
|
+ {
|
|
|
+ RedisDbconn.Instance.Set("SIMPosMerchantTradeCheckImport:" + checkKey, "success|" + SuccessCount);
|
|
|
+ RedisDbconn.Instance.SetExpire("SIMPosMerchantTradeCheckImport:" + checkKey, 60000);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ DoCount = list.Rows.Count;
|
|
|
+ function.WriteLog(ex.ToString(), "导入广电卡激活数据");
|
|
|
+ tran.Rollback();
|
|
|
+ ErrorMsg msg = new ErrorMsg()
|
|
|
+ {
|
|
|
+ Time = DateTime.Now,
|
|
|
+ ErrorContent = ex.ToString(),
|
|
|
+ };
|
|
|
+ function.WriteLog(Newtonsoft.Json.JsonConvert.SerializeObject(msg), "导入广电卡激活数据Excel文件异常");
|
|
|
+ }
|
|
|
+ tran.Dispose();
|
|
|
+ }
|
|
|
+ //导交易
|
|
|
+ if (_Kind == "2")
|
|
|
+ {
|
|
|
+ var tran = db.Database.BeginTransaction();
|
|
|
+ try
|
|
|
+ {
|
|
|
+ int Size = 100;
|
|
|
+ if (list.Rows.Count - DoCount < 100)
|
|
|
+ {
|
|
|
+ Size = list.Rows.Count - DoCount;
|
|
|
+ }
|
|
|
+ Dictionary<string, int> storeData = new Dictionary<string, int>();
|
|
|
+ for (int i = DoCount; i < DoCount + Size; i++)
|
|
|
+ {
|
|
|
+ DataRow dr = list.Rows[i];
|
|
|
+ string Mobile = dr["用户手机号"].ToString();
|
|
|
+ string SimNo = dr["SIM卡号"].ToString();
|
|
|
+ string CreateMonth = dr["入网月份"].ToString();
|
|
|
+ string SettleMonth = dr["结算月份"].ToString();
|
|
|
+ string SettleTime = dr["结算账期"].ToString();
|
|
|
+ string SettleSpace = dr["结算场景"].ToString();
|
|
|
+ string BusinessType = dr["业务类型"].ToString();
|
|
|
+ string Province = dr["用户省份"].ToString();
|
|
|
+ string City = dr["用户地市"].ToString();
|
|
|
+ string Team = dr["团队归属"].ToString();
|
|
|
+ string WorkName = dr["行销宝姓名"].ToString();
|
|
|
+ string WorkNo = dr["行销宝工号"].ToString();
|
|
|
+ string ProductName = dr["商品名称"].ToString();
|
|
|
+ string TotalAmount = dr["账单总金额"].ToString();
|
|
|
+ string InAmount = dr["套内金额"].ToString();
|
|
|
+ string OutAmount = dr["套外金额"].ToString();
|
|
|
+ string UserStatus = dr["用户状态"].ToString();
|
|
|
+ string ChannelCode = dr["渠道编码"].ToString();
|
|
|
+ string ChannelName = dr["渠道名称"].ToString();
|
|
|
+ string OrderCreateTime = dr["订单创建时间"].ToString();
|
|
|
+ string OrderStatus = dr["订单状态"].ToString();
|
|
|
+ string ActTime = dr["激活时间"].ToString();
|
|
|
+ string SourceProductName = dr["原订单商品名称"].ToString();
|
|
|
+ string ProductType = dr["商品类型名称"].ToString();
|
|
|
+ string ActivityName = dr["促销活动名称"].ToString();
|
|
|
+ string Percent = dr["分成比例"].ToString();
|
|
|
+ string OrgDivi = dr["机构分成"].ToString();
|
|
|
+
|
|
|
+ string json = "{";
|
|
|
+ json += "\"Mobile\":\"" + Mobile + "\",";
|
|
|
+ json += "\"SimNo\":\"" + SimNo + "\",";
|
|
|
+ json += "\"CreateMonth\":\"" + CreateMonth + "\",";
|
|
|
+ json += "\"SettleMonth\":\"" + SettleMonth + "\",";
|
|
|
+ json += "\"SettleTime\":\"" + SettleTime + "\",";
|
|
|
+ json += "\"SettleSpace\":\"" + SettleSpace + "\",";
|
|
|
+ json += "\"BusinessType\":\"" + BusinessType + "\",";
|
|
|
+ json += "\"Province\":\"" + Province + "\",";
|
|
|
+ json += "\"City\":\"" + City + "\",";
|
|
|
+ json += "\"Team\":\"" + Team + "\",";
|
|
|
+ json += "\"WorkName\":\"" + WorkName + "\",";
|
|
|
+ json += "\"WorkNo\":\"" + WorkNo + "\",";
|
|
|
+ json += "\"ProductName\":\"" + ProductName + "\",";
|
|
|
+ json += "\"TotalAmount\":\"" + TotalAmount + "\",";
|
|
|
+ json += "\"InAmount\":\"" + InAmount + "\",";
|
|
|
+ json += "\"OutAmount\":\"" + OutAmount + "\",";
|
|
|
+ json += "\"UserStatus\":\"" + UserStatus + "\",";
|
|
|
+ json += "\"ChannelCode\":\"" + ChannelCode + "\",";
|
|
|
+ json += "\"ChannelName\":\"" + ChannelName + "\",";
|
|
|
+ json += "\"OrderCreateTime\":\"" + OrderCreateTime + "\",";
|
|
|
+ json += "\"OrderStatus\":\"" + OrderStatus + "\",";
|
|
|
+ json += "\"ActTime\":\"" + ActTime + "\",";
|
|
|
+ json += "\"SourceProductName\":\"" + SourceProductName + "\",";
|
|
|
+ json += "\"ProductType\":\"" + ProductType + "\",";
|
|
|
+ json += "\"ActivityName\":\"" + ActivityName + "\",";
|
|
|
+ json += "\"Percent\":\"" + Percent + "\",";
|
|
|
+ json += "\"OrgDivi\":\"" + OrgDivi + "\"";
|
|
|
+ json += "}";
|
|
|
+
|
|
|
+ bool op = true;
|
|
|
+ string OrderNo = DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8);
|
|
|
+ decimal TotalAmountNum = decimal.Parse(function.CheckNum(numberString: TotalAmount));
|
|
|
+ DateTime CreateDate = DateTime.Parse(OrderCreateTime);
|
|
|
+ string CheckDate = DateTime.Now.AddMonths(-3).ToString("yyyyMM");
|
|
|
+ if (int.Parse(CreateMonth) >= int.Parse(CheckDate)) op = false;
|
|
|
+ if (OrderStatus == "待激活") op = false;
|
|
|
+ if (UserStatus.Contains("注销") || UserStatus.Contains("欠费"))
|
|
|
{
|
|
|
- RedisDbconn.Instance.AddList("ErrList" + checkKey, "以下操作失败,机具" + PosSn + ',' + "对应的退押订单" + merchantDepositReturns.SeoKeyword + "该订单未找到或不符合规则");
|
|
|
+ op = false;
|
|
|
+ SimposMerchantInfo checkSimMer = db.SimposMerchantInfo.FirstOrDefault(m => m.KqMerNo == Mobile && m.KqSnNo == SimNo);
|
|
|
+ if (checkSimMer != null)
|
|
|
+ {
|
|
|
+ checkSimMer.Status = -1;
|
|
|
+ if (UserStatus.Contains("欠费") && checkSimMer.Status != -1)
|
|
|
+ {
|
|
|
+ checkSimMer.Status = -2;
|
|
|
+ }
|
|
|
+ db.SaveChanges();
|
|
|
+ }
|
|
|
+ PosMerchantInfo checkMer = db.PosMerchantInfo.FirstOrDefault(m => m.KqMerNo == Mobile && m.KqSnNo == SimNo);
|
|
|
+ if (checkMer != null)
|
|
|
+ {
|
|
|
+ checkMer.Status = -1;
|
|
|
+ if (UserStatus.Contains("欠费") && checkMer.Status != -1)
|
|
|
+ {
|
|
|
+ checkMer.Status = -2;
|
|
|
+ }
|
|
|
+ db.SaveChanges();
|
|
|
+ }
|
|
|
+ PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == SimNo);
|
|
|
+ if (pos != null)
|
|
|
+ {
|
|
|
+ pos.Status = -1;
|
|
|
+ if (UserStatus.Contains("欠费") && pos.Status != -1)
|
|
|
+ {
|
|
|
+ pos.Status = -2;
|
|
|
+ }
|
|
|
+ db.SaveChanges();
|
|
|
+ }
|
|
|
}
|
|
|
- else
|
|
|
+ if (UserStatus.Contains("正常"))
|
|
|
{
|
|
|
- //失败
|
|
|
- if (Status == 2)
|
|
|
+ SimposMerchantInfo checkSimMer = db.SimposMerchantInfo.FirstOrDefault(m => m.KqMerNo == Mobile && m.KqSnNo == SimNo);
|
|
|
+ if (checkSimMer != null)
|
|
|
+ {
|
|
|
+ if (checkSimMer.Status == -2) checkSimMer.Status = 0;
|
|
|
+ db.SaveChanges();
|
|
|
+ }
|
|
|
+ PosMerchantInfo checkMer = db.PosMerchantInfo.FirstOrDefault(m => m.KqMerNo == Mobile && m.KqSnNo == SimNo);
|
|
|
+ if (checkMer != null)
|
|
|
+ {
|
|
|
+ if (checkMer.Status == -2) checkMer.Status = 1;
|
|
|
+ db.SaveChanges();
|
|
|
+ }
|
|
|
+
|
|
|
+ PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == SimNo);
|
|
|
+ if (pos != null && pos.Status < 0)
|
|
|
{
|
|
|
- var posm = db.PosMerchantInfo.FirstOrDefault(m => m.Id == merchantDepositReturns.MerchantId) ?? new PosMerchantInfo();
|
|
|
- posm.StandardStatus = 101;
|
|
|
+ if (pos.Status == -2)
|
|
|
+ {
|
|
|
+ pos.Status = 0;
|
|
|
+ }
|
|
|
+ db.SaveChanges();
|
|
|
}
|
|
|
- merchantDepositReturns.Status = Status;
|
|
|
- merchantDepositReturns.UpdateDate = DateTime.Now;
|
|
|
- merchantDepositReturns.SeoDescription = SeoDescription;
|
|
|
- merchantDepositReturns.SeoTitle = Operator;
|
|
|
- SuccessCount += 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (TotalAmountNum > 0 && op)
|
|
|
+ {
|
|
|
+ spdb.TradeRecord.Add(new SpModels.TradeRecord()
|
|
|
+ {
|
|
|
+ CreateDate = DateTime.Now.AddMonths(-1), //创建时间
|
|
|
+ TradeSerialNo = OrderNo, //订单编号
|
|
|
+ AgentNo = WorkName + WorkNo, //一级服务商编号
|
|
|
+ MerNo = Mobile, //商户编
|
|
|
+ TradeSnNo = SimNo, //sim卡号
|
|
|
+ ChannelSerial = OrderNo, //请求号
|
|
|
+ TradeAmount = TotalAmountNum, //账单总金额
|
|
|
+ TradeStatus = OrderStatus, //订单状态
|
|
|
+ TradeDate = CreateMonth,
|
|
|
+ TradeTime = CreateDate.ToString("yyyyMMdd"),
|
|
|
+ BankCardType = "01",
|
|
|
+ TradeType = "01",
|
|
|
+ ProductType = "14",
|
|
|
+ Status = 1,
|
|
|
+ Field1 = ProductName,
|
|
|
+ Field2 = SourceProductName,
|
|
|
+ Field3 = ProductType,
|
|
|
+ Field4 = BusinessType,
|
|
|
+ SeoDescription = json,
|
|
|
+ });
|
|
|
+
|
|
|
+ spdb.SaveChanges();
|
|
|
}
|
|
|
}
|
|
|
DoCount += Size;
|
|
|
@@ -101,21 +338,21 @@ namespace MySystem
|
|
|
tran.Commit();
|
|
|
if (DoCount >= list.Rows.Count)
|
|
|
{
|
|
|
- RedisDbconn.Instance.Set("SIMPosMerchantTradeCheckImport:" + checkKey, "success|" + SuccessCount);
|
|
|
+ RedisDbconn.Instance.Set("SIMPosMerchantTradeCheckImport:" + checkKey, "success|");
|
|
|
RedisDbconn.Instance.SetExpire("SIMPosMerchantTradeCheckImport:" + checkKey, 60000);
|
|
|
}
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
DoCount = list.Rows.Count;
|
|
|
- function.WriteLog(ex.ToString(), "导入首台服务费退还结果");
|
|
|
+ function.WriteLog(ex.ToString(), "导入广电卡交易数据");
|
|
|
tran.Rollback();
|
|
|
ErrorMsg msg = new ErrorMsg()
|
|
|
{
|
|
|
Time = DateTime.Now,
|
|
|
ErrorContent = ex.ToString(),
|
|
|
};
|
|
|
- function.WriteLog(Newtonsoft.Json.JsonConvert.SerializeObject(msg), "导入首台服务费退还结果Excel文件异常");
|
|
|
+ function.WriteLog(Newtonsoft.Json.JsonConvert.SerializeObject(msg), "导入广电卡交易数据Excel文件异常");
|
|
|
}
|
|
|
tran.Dispose();
|
|
|
}
|