|
|
@@ -1640,8 +1640,8 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
{
|
|
|
return "请输入商户编号";
|
|
|
}
|
|
|
- string[] OldSnList = OldSn.Split('\n');
|
|
|
- string[] NewSnList = NewSn.Split('\n');
|
|
|
+ string[] OldSnList = OldSn.Replace("\r", "").Split('\n');
|
|
|
+ string[] NewSnList = NewSn.Replace("\r", "").Split('\n');
|
|
|
if (OldSnList.Length != NewSnList.Length)
|
|
|
{
|
|
|
return "原机具SN数量和新机具SN数量不一致";
|
|
|
@@ -1893,8 +1893,8 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
{
|
|
|
return "请输入坏机退回仓库编号";
|
|
|
}
|
|
|
- OldSnList = OldSn.Split('\n');
|
|
|
- NewSnList = NewSn.Split('\n');
|
|
|
+ OldSnList = OldSn.Replace("\r", "").Split('\n');
|
|
|
+ NewSnList = NewSn.Replace("\r", "").Split('\n');
|
|
|
if (OldSnList.Length != NewSnList.Length)
|
|
|
{
|
|
|
return "原机具SN数量和新机具SN数量不一致";
|
|
|
@@ -2009,7 +2009,6 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
newpos.BindMerchantId = oldpos.BindMerchantId;
|
|
|
|
|
|
newpos.StoreId = oldpos.StoreId;
|
|
|
- newpos.UserId = oldpos.UserId;
|
|
|
newpos.PreUserId = oldpos.PreUserId;
|
|
|
|
|
|
if (!opData.Contains(oldpos.BuyUserId + ":" + oldpos.BrandId))
|
|
|
@@ -2131,8 +2130,8 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
{
|
|
|
return "请输入坏机退回仓库编号";
|
|
|
}
|
|
|
- OldSnList = OldSn.Split('\n');
|
|
|
- NewSnList = NewSn.Split('\n');
|
|
|
+ OldSnList = OldSn.Replace("\r", "").Split('\n');
|
|
|
+ NewSnList = NewSn.Replace("\r", "").Split('\n');
|
|
|
if (OldSnList.Length != NewSnList.Length)
|
|
|
{
|
|
|
return "原机具SN数量和新机具SN数量不一致";
|
|
|
@@ -2333,6 +2332,295 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
+ #region 创客跨品牌换机
|
|
|
+
|
|
|
+ public IActionResult ChangePosCrossBrand(string right)
|
|
|
+ {
|
|
|
+ ViewBag.RightInfo = RightInfo;
|
|
|
+ ViewBag.right = right;
|
|
|
+
|
|
|
+ return View();
|
|
|
+ }
|
|
|
+
|
|
|
+ [HttpPost]
|
|
|
+ public string ChangePosCrossBrandDo(string MakerCode, string OldSn, string BackStoreNo, string NewSn, string FromStoreNo, int IsSend = 0)
|
|
|
+ {
|
|
|
+ string[] OldSnList;
|
|
|
+ string[] NewSnList;
|
|
|
+ decimal amount = 0;
|
|
|
+ List<string> opData = new List<string>();
|
|
|
+ if (string.IsNullOrEmpty(MakerCode))
|
|
|
+ {
|
|
|
+ return "请输入创客编号";
|
|
|
+ }
|
|
|
+ if (string.IsNullOrEmpty(OldSn))
|
|
|
+ {
|
|
|
+ return "请输入旧机SN";
|
|
|
+ }
|
|
|
+ if (string.IsNullOrEmpty(BackStoreNo))
|
|
|
+ {
|
|
|
+ return "请输入旧机退回仓库编号";
|
|
|
+ }
|
|
|
+ if (string.IsNullOrEmpty(NewSn))
|
|
|
+ {
|
|
|
+ return "请输入新机SN";
|
|
|
+ }
|
|
|
+ if (string.IsNullOrEmpty(FromStoreNo))
|
|
|
+ {
|
|
|
+ return "请输入新机发货仓库编号";
|
|
|
+ }
|
|
|
+ OldSnList = OldSn.Replace("\r", "").Replace("\n", ",").Split(',');
|
|
|
+ NewSnList = NewSn.Replace("\r", "").Replace("\n", ",").Split(',');
|
|
|
+ if (OldSnList.Length != NewSnList.Length)
|
|
|
+ {
|
|
|
+ return "原机具SN数量和新机具SN数量不一致";
|
|
|
+ }
|
|
|
+
|
|
|
+ var ChangeRecordNo = "KPHJ" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8); //变更记录单号
|
|
|
+ for (int i = 0; i < OldSnList.Length; i++)
|
|
|
+ {
|
|
|
+ string OldSnNum = OldSnList[i];
|
|
|
+ string NewSnNum = NewSnList[i];
|
|
|
+ UserForMakerCode userForMakerCode = db.UserForMakerCode.FirstOrDefault(m => m.MakerCode == MakerCode) ?? new UserForMakerCode();
|
|
|
+ var userInfo = db.Users.FirstOrDefault(m => m.Id == userForMakerCode.UserId) ?? new Users();
|
|
|
+ if (userInfo.Id == 0)
|
|
|
+ {
|
|
|
+ return MakerCode + "不存在或关联信息缺失";
|
|
|
+ }
|
|
|
+ StoreForCode storeForCodeFrom = db.StoreForCode.FirstOrDefault(m => m.Code == FromStoreNo) ?? new StoreForCode();
|
|
|
+ if (storeForCodeFrom.StoreId == 0)
|
|
|
+ {
|
|
|
+ return "您输入的新机发货仓库编号不存在";
|
|
|
+ }
|
|
|
+ StoreForCode storeForCodeBack = db.StoreForCode.FirstOrDefault(m => m.Code == BackStoreNo) ?? new StoreForCode();
|
|
|
+ if (storeForCodeBack.StoreId == 0)
|
|
|
+ {
|
|
|
+ return "您输入的旧机退回仓库编号不存在";
|
|
|
+ }
|
|
|
+ MachineForSnNo oldForSnNo = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == OldSnNum) ?? new MachineForSnNo();
|
|
|
+ if (oldForSnNo.SnId == 0)
|
|
|
+ {
|
|
|
+ return OldSnNum + "不存在或关联信息缺失";
|
|
|
+ }
|
|
|
+ MachineForSnNo newForSnNo = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == NewSnNum) ?? new MachineForSnNo();
|
|
|
+ if (newForSnNo.SnId == 0)
|
|
|
+ {
|
|
|
+ return NewSnNum + "不存在或关联信息缺失";
|
|
|
+ }
|
|
|
+ PosMachinesTwo oldpos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == oldForSnNo.SnId && m.BindingState == 0 && m.ActivationState == 0 && m.BuyUserId == userForMakerCode.UserId) ?? new PosMachinesTwo();
|
|
|
+ if (oldpos.Id == 0)
|
|
|
+ {
|
|
|
+ return "您输入的旧机SN不存在或者不在" + MakerCode + "名下";
|
|
|
+ }
|
|
|
+ PosMachinesTwo newpos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == newForSnNo.SnId && m.BindingState == 0 && m.ActivationState == 0 && m.BuyUserId == 0 && m.UserId == 0 && m.PreUserId == 0) ?? new PosMachinesTwo();
|
|
|
+ if (newpos.Id == 0)
|
|
|
+ {
|
|
|
+ return "您输入的新机SN不存在或不满足条件";
|
|
|
+ }
|
|
|
+ StoreHouse storeFrom = db.StoreHouse.FirstOrDefault(m => m.Id == storeForCodeFrom.StoreId);
|
|
|
+ if (Convert.ToInt32(storeFrom.BrandId) != Convert.ToInt32(newpos.BrandId))
|
|
|
+ {
|
|
|
+ return "您输入的新机发货仓库不符新机机具对应品牌";
|
|
|
+ }
|
|
|
+ if (newpos.StoreId != storeFrom.Id)
|
|
|
+ {
|
|
|
+ return "您输入的新机SN不在新机发货仓库";
|
|
|
+ }
|
|
|
+ StoreHouse storeBack = db.StoreHouse.FirstOrDefault(m => m.Id == storeForCodeBack.StoreId);
|
|
|
+ if (Convert.ToInt32(storeBack.BrandId) != Convert.ToInt32(oldpos.BrandId))
|
|
|
+ {
|
|
|
+ return "您输入的旧机退回仓库不符旧机机具对应品牌";
|
|
|
+ }
|
|
|
+ var brandInfo = db.KqProducts.FirstOrDefault(m => m.Id == oldpos.BrandId) ?? new KqProducts();
|
|
|
+ var brandNew = db.KqProducts.FirstOrDefault(m => m.Id == newpos.BrandId) ?? new KqProducts();
|
|
|
+ if (brandInfo.Kind != brandNew.Kind)
|
|
|
+ {
|
|
|
+ return "原机具和新机具不是同种机型(电签或大POS)";
|
|
|
+ }
|
|
|
+ if (brandInfo.Name.Contains("大POS"))
|
|
|
+ {
|
|
|
+ amount = 300;
|
|
|
+ }
|
|
|
+ if (brandInfo.Name.Contains("电签"))
|
|
|
+ {
|
|
|
+ amount = 200;
|
|
|
+ }
|
|
|
+ var storeFromUserAcount = db.UserAccount.FirstOrDefault(m => m.Id == storeFrom.UserId) ?? new UserAccount();
|
|
|
+ var storeBackUserAcount = db.UserAccount.FirstOrDefault(m => m.Id == storeBack.UserId) ?? new UserAccount();
|
|
|
+ storeFromUserAcount.ValidAmount += amount;
|
|
|
+ storeBackUserAcount.ValidAmount -= amount;
|
|
|
+ storeFrom.LaveNum -= 1;
|
|
|
+ storeBack.LaveNum += 1;
|
|
|
+
|
|
|
+ if (oldpos.OpId > 0)
|
|
|
+ {
|
|
|
+ if (newpos.OpId > 0)
|
|
|
+ {
|
|
|
+ var opUserAccount = opdb.UserAccount.FirstOrDefault(m => m.Sort > 0 && m.Id == oldpos.OpId && m.UserId == oldpos.OpId) ?? new OpModels.UserAccount();
|
|
|
+ decimal TotalAmount = opUserAccount.ValidAmount + opUserAccount.TotalAmt + opUserAccount.ValidForGetAmount;//旧的总金额
|
|
|
+ opUserAccount.ValidAmount += oldpos.OpReserve3;
|
|
|
+ opUserAccount.ValidForGetAmount += oldpos.OpReserve2;
|
|
|
+ opUserAccount.TotalAmt += oldpos.OpReserve1;
|
|
|
+
|
|
|
+ var amoutRecord = opdb.AmountRecord.Add(new OpModels.AmountRecord
|
|
|
+ {
|
|
|
+ CreateDate = DateTime.Now,
|
|
|
+ UserId = oldpos.OpId,
|
|
|
+ SeoDescription = "创客跨品牌换机",
|
|
|
+ OperateType = 1,
|
|
|
+ UseAmount = oldpos.OpReserve3 + oldpos.OpReserve2 + oldpos.OpReserve1,
|
|
|
+ BeforeAmount = TotalAmount,
|
|
|
+ AfterAmount = TotalAmount + oldpos.OpReserve3 + oldpos.OpReserve2 + oldpos.OpReserve1,
|
|
|
+ }).Entity;
|
|
|
+ }
|
|
|
+ if (newpos.OpId == 0)
|
|
|
+ {
|
|
|
+ newpos.OpReserve1 = oldpos.OpReserve1;
|
|
|
+ newpos.OpReserve2 = oldpos.OpReserve3;
|
|
|
+ newpos.OpReserve3 = oldpos.OpReserve1;
|
|
|
+ newpos.OpId = oldpos.OpId;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //发出方
|
|
|
+ db.StoreChangeHistory.Add(new StoreChangeHistory()
|
|
|
+ {
|
|
|
+ CreateDate = DateTime.Now,
|
|
|
+ UserId = userInfo.Id, //创客
|
|
|
+ BrandId = newpos.BrandId,//产品类型
|
|
|
+ ChangeRecordNo = ChangeRecordNo, //变更记录单号
|
|
|
+ TransType = 6, //交易类型(0 采购 1 调拨 2 出货 3 退货 4 驳回 5 回仓退款 6 换机出库 7 换机入库)
|
|
|
+ SnNo = newpos.PosSn, //SN编号
|
|
|
+ SnType = newpos.PosSnType, //SN机具类型
|
|
|
+ StockOpDirect = 1, //库存操作方向(0 入库 1 出库)
|
|
|
+ DeviceVendor = newpos.DeviceName, //设备厂商
|
|
|
+ DeviceModel = newpos.DeviceKind, //设备型号
|
|
|
+ DeviceType = newpos.DeviceType, //设备类型
|
|
|
+ // FromUserId = storeFrom.UserId, //出货创客
|
|
|
+ StoreId = storeFrom.Id,//出货仓库
|
|
|
+ FromDate = DateTime.Now, //出库时间
|
|
|
+ FromRemark = "跨品牌换机,出库", //出库备注
|
|
|
+ SourceStoreId = newpos.SourceStoreId, //源仓库
|
|
|
+ ToUserId = userInfo.Id,//收货创客
|
|
|
+ });
|
|
|
+ //接收方
|
|
|
+ db.StoreChangeHistory.Add(new StoreChangeHistory()
|
|
|
+ {
|
|
|
+ CreateDate = DateTime.Now,
|
|
|
+ UserId = userInfo.Id, //创客
|
|
|
+ BrandId = oldpos.BrandId,//产品类型
|
|
|
+ ChangeRecordNo = ChangeRecordNo, //变更记录单号
|
|
|
+ TransType = 7, //交易类型(0 采购 1 调拨 2 出货 3 退货 4 驳回 5 回仓退款 6 换机出库 7 换机入库)
|
|
|
+ SnNo = oldpos.PosSn, //SN编号
|
|
|
+ SnType = oldpos.PosSnType, //SN机具类型
|
|
|
+ StockOpDirect = 0, //库存操作方向(0 入库 1 出库)
|
|
|
+ DeviceVendor = oldpos.DeviceName, //设备厂商
|
|
|
+ DeviceModel = oldpos.DeviceKind, //设备型号
|
|
|
+ DeviceType = oldpos.DeviceType, //设备类型
|
|
|
+ StoreId = oldpos.StoreId,//出货仓库
|
|
|
+ FromDate = DateTime.Now, //出库时间
|
|
|
+ FromRemark = "跨品牌换机,入库", //出库备注
|
|
|
+ SourceStoreId = oldpos.SourceStoreId, //源仓库
|
|
|
+ ToStoreId = storeBack.Id,//收货仓库
|
|
|
+ });
|
|
|
+
|
|
|
+ newpos.BuyUserId = oldpos.BuyUserId;
|
|
|
+ newpos.UserId = oldpos.UserId;
|
|
|
+ newpos.RecycEndDate = oldpos.RecycEndDate;
|
|
|
+ newpos.ScanQrTrade = oldpos.ScanQrTrade;
|
|
|
+ newpos.DebitCardTrade = oldpos.DebitCardTrade;
|
|
|
+ newpos.CreditTrade = oldpos.CreditTrade;
|
|
|
+ newpos.PosSnType = oldpos.PosSnType;
|
|
|
+ newpos.TransferTime = oldpos.TransferTime;
|
|
|
+ newpos.IsPurchase = oldpos.IsPurchase;
|
|
|
+ newpos.BindingState = oldpos.BindingState;
|
|
|
+ newpos.ActivationState = oldpos.ActivationState;
|
|
|
+ newpos.BindingTime = oldpos.BindingTime;
|
|
|
+ newpos.ActivationTime = oldpos.ActivationTime;
|
|
|
+ newpos.IsFirst = oldpos.IsFirst;
|
|
|
+ newpos.SeoKeyword = oldpos.SeoKeyword;
|
|
|
+ newpos.PrizeParams = oldpos.PrizeParams;
|
|
|
+ newpos.LeaderUserId = oldpos.LeaderUserId;
|
|
|
+ newpos.BindMerchantId = oldpos.BindMerchantId;
|
|
|
+
|
|
|
+ newpos.PreUserId = oldpos.PreUserId;
|
|
|
+
|
|
|
+ if (!opData.Contains(newpos.BuyUserId + ":" + newpos.BrandId))
|
|
|
+ {
|
|
|
+ opData.Add(newpos.BuyUserId + ":" + newpos.BrandId);
|
|
|
+ }
|
|
|
+ if (!opData.Contains(oldpos.BuyUserId + ":" + oldpos.BrandId))
|
|
|
+ {
|
|
|
+ opData.Add(oldpos.BuyUserId + ":" + oldpos.BrandId);
|
|
|
+ }
|
|
|
+
|
|
|
+ oldpos.StoreId = storeBack.Id;
|
|
|
+ oldpos.QueryCount = 0;
|
|
|
+ oldpos.UpdateDate = null;
|
|
|
+ oldpos.ActivityList = null;
|
|
|
+ oldpos.SeoKeyword = null;
|
|
|
+ oldpos.SeoDescription = null;
|
|
|
+ oldpos.OrderId = 0;
|
|
|
+ oldpos.RecycEndDate = null;
|
|
|
+ oldpos.RecycBackCount = 0;
|
|
|
+ oldpos.PrizeParams = null;
|
|
|
+ oldpos.ScanQrTrade = 0;
|
|
|
+ oldpos.BindMerchantId = 0;
|
|
|
+ oldpos.CreditTrade = 0;
|
|
|
+ oldpos.DebitCardTrade = 0;
|
|
|
+ oldpos.IsVip = 0;
|
|
|
+ oldpos.UserNav = null;
|
|
|
+ oldpos.TransferTime = null;
|
|
|
+ oldpos.IsPurchase = 0;
|
|
|
+ oldpos.Detail = null;
|
|
|
+ oldpos.BindingTime = null;
|
|
|
+ oldpos.BindingState = 0;
|
|
|
+ oldpos.ActivationTime = null;
|
|
|
+ oldpos.ActivationState = 0;
|
|
|
+ oldpos.LeaderUserId = 0;
|
|
|
+ oldpos.PreUserId = 0;
|
|
|
+ oldpos.IsFirst = 0;
|
|
|
+ oldpos.DownFeeMan = null;
|
|
|
+ oldpos.DownFeeFlag = 0;
|
|
|
+ oldpos.DownFeeDate = null;
|
|
|
+ oldpos.UpFeeMan = null;
|
|
|
+ oldpos.UpFeeFlag = 0;
|
|
|
+ oldpos.UpFeeDate = null;
|
|
|
+ oldpos.OpReserve1 = 0;
|
|
|
+ oldpos.OpReserve2 = 0;
|
|
|
+ oldpos.OpReserve3 = 0;
|
|
|
+ oldpos.OpId = 0;
|
|
|
+ oldpos.RecycStartDate = null;
|
|
|
+ oldpos.SourcePosSn = null;
|
|
|
+ oldpos.BuyUserId = 0;
|
|
|
+ oldpos.UserId = 0;
|
|
|
+
|
|
|
+ PublicFunction.ClearPosHistory(db, oldpos.PosSn); //清除机具历史记录
|
|
|
+ db.SaveChanges();
|
|
|
+ opdb.SaveChanges();
|
|
|
+ if (IsSend == 1)
|
|
|
+ {
|
|
|
+ RedisDbconn.Instance.AddList("MsgPersonalQueue", Newtonsoft.Json.JsonConvert.SerializeObject(new MsgPersonal()
|
|
|
+ {
|
|
|
+ UserId = userForMakerCode.UserId, //接收创客
|
|
|
+ MsgType = 2,
|
|
|
+ Title = "创客跨品牌换机", //标题
|
|
|
+ Summary = "您的旧机 " + brandInfo.Name + " SN:" + OldSnNum + "已经成功为您换为" + brandNew.Name + "SN:" + NewSnNum + "。",
|
|
|
+ CreateDate = DateTime.Now,
|
|
|
+
|
|
|
+ }));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ foreach (string sub in opData)
|
|
|
+ {
|
|
|
+ string[] datalist = sub.Split(":");
|
|
|
+ PublicFunction.SycnMachineCount(int.Parse(datalist[0]), int.Parse(datalist[1]));
|
|
|
+ }
|
|
|
+ return "success";
|
|
|
+ }
|
|
|
+ #endregion
|
|
|
+
|
|
|
+
|
|
|
|
|
|
#region 机具解绑
|
|
|
|
|
|
@@ -2514,7 +2802,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
{
|
|
|
return "创客不存在";
|
|
|
}
|
|
|
- string[] SnList = Coupons.Split('\n');
|
|
|
+ string[] SnList = Coupons.Replace("\r", "").Split('\n');
|
|
|
foreach (var item in SnList)
|
|
|
{
|
|
|
var coupos = db.PosCoupons.FirstOrDefault(m => m.ExchangeCode == item && m.LeaderUserId == 0);
|
|
|
@@ -2559,7 +2847,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
{
|
|
|
return "创客不存在";
|
|
|
}
|
|
|
- string[] SnList = PosSn.Split('\n');
|
|
|
+ string[] SnList = PosSn.Replace("\r", "").Split('\n');
|
|
|
foreach (var item in SnList)
|
|
|
{
|
|
|
var pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == item && m.LeaderUserId == 0);
|
|
|
@@ -3450,7 +3738,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
return "请输入机具号";
|
|
|
}
|
|
|
string result = SysUserName + "设置\n";
|
|
|
- string[] PosSnList = PosSns.Split('\n');
|
|
|
+ string[] PosSnList = PosSns.Replace("\r", "").Split('\n');
|
|
|
int total = PosSnList.Length;
|
|
|
int index = 0;
|
|
|
foreach (string SubPosSn in PosSnList)
|
|
|
@@ -3909,7 +4197,7 @@ namespace MySystem.Areas.Admin.Controllers
|
|
|
FeeType = "0.63";
|
|
|
}
|
|
|
|
|
|
- string[] PosSnList = PosSn.Split('\n');
|
|
|
+ string[] PosSnList = PosSn.Replace("\r", "").Split('\n');
|
|
|
var PosId = "";
|
|
|
var RecordId = "";
|
|
|
var error = "";
|