123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288 |
- using Library;
- using MySystem.Service.Main;
- using System;
- using System.Collections.Generic;
- namespace MySystem
- {
-
-
-
- public class StoreStockChangeUtil
- {
- #region 首页-仓库管理-整箱/逐台划拨
-
-
-
-
-
-
-
- public static string TransferWholeOrOneDo(int OrderId, int StoreId, int ToUserId, string SnIds)
- {
- var store = StoreHouseService.Query(StoreId);
- string[] SnIdList = SnIds.Split(',');
- string SnNos = "";
- var order = OrdersService.Query(OrderId);
- if (order.Id > 0)
- {
- if (order.Status == 2)
- {
- return "该订单已处理,请勿重复操作";
- }
- int ApplyType = 0;
- List<string> SourceSnNos = new List<string>();
- if (order.Sort > 0)
- {
- var Apply = MachineApplyService.Query(order.Sort);
- if (Apply.Id > 0)
- {
- ApplyType = Apply.Sort;
- Dictionary<string, object> File = new Dictionary<string, object>();
- File.Add("Status", 1);
- File.Add("QueryCount", order.Id);
- MachineApplyService.Edit(File, Apply.Id);
- if (!string.IsNullOrEmpty(Apply.SwapSnExpand))
- {
- string[] SwapSnExpands = Apply.SwapSnExpand.Split('\n');
- foreach (string sub in SwapSnExpands)
- {
- if (!string.IsNullOrEmpty(sub))
- {
- SourceSnNos.Add(sub.Split(':')[0]);
- }
- }
- }
- }
- }
- Dictionary<int, string> couponIds = new Dictionary<int, string>();
- int SnIndex = 0;
- foreach (string SnId in SnIdList)
- {
- string ChangeNo = "SC" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8);
- int SnIdNum = int.Parse(SnId);
- int LeaderUserId = 0;
- DateTime RecycEndDate = DateTime.Now.AddDays(360);
- if (SourceSnNos.Count > SnIndex)
- {
- string SourceSnNo = SourceSnNos[SnIndex];
- if (ApplyType <= 1)
- {
- var forSnNo = MachineForSnNoService.Query("SnNo='" + SourceSnNo + "'");
- var spos = PosMachinesTwoService.Query(forSnNo.SnId);
- RecycEndDate = spos.RecycEndDate == null ? RecycEndDate = DateTime.Now.AddDays(360) : spos.RecycEndDate.Value;
- LeaderUserId = spos.LeaderUserId;
- }
- else if (ApplyType > 1)
- {
- var coupon = PosCouponsService.Query("ExchangeCode='" + SourceSnNo + "'");
- LeaderUserId = coupon.LeaderUserId;
- if (coupon.OpId > 0)
- {
- if (couponIds.ContainsKey(coupon.OpId))
- {
- string[] datas = couponIds[coupon.OpId].Split(',');
- int Num = int.Parse(datas[2]) + 1;
- couponIds[coupon.OpId] = datas[0] + "," + datas[1] + "," + Num;
- }
- else
- {
- couponIds.Add(coupon.OpId, coupon.Id + "," + coupon.QueryCount + ",1");
- }
- }
- }
- }
- var pos = PosMachinesTwoService.Query(SnIdNum);
-
- if (pos.OpId > 0)
- {
- var sysAdmin = MySystem.Service.Operate.SysAdminService.Query("QueryCount=1 and UserId='" + pos.OpId + "'");
- if (sysAdmin.Id > 0)
- {
- sysAdmin.TotalMachineCount -= 1;
- Dictionary<string, object> File = new Dictionary<string, object>();
- File.Add("TotalMachineCount", sysAdmin.TotalMachineCount);
- MySystem.Service.Operate.SysAdminService.Edit(File, sysAdmin.Id);
- }
- }
- SnNos += pos.PosSn + ",";
- AddForTransfer(StoreId, pos.BrandId, KqProductsService.Query(pos.BrandId).Name, ChangeNo, 10, pos.PosSn, pos.PosSnType, 1, pos.DeviceType, store.UserId, DateTime.Now, ToUserId, StoreId, pos.OpId);
- UserStoreChangeUtil.AddForTransfer(store.UserId, pos.BrandId, ChangeNo, 0, pos.PosSn, pos.PosSnType, 0, pos.DeviceName, pos.DeviceKind, pos.DeviceType, ToUserId, DateTime.Now, pos.SourceStoreId, 1, (int)pos.BindingState, pos.BindMerchantId, (int)pos.ActivationState, pos.BuyUserId, pos.DeviceType);
- StoreChangeHistoryUtil.AddForTransfer(store.UserId, pos.BrandId, ChangeNo, 2, pos.PosSn, pos.PosSnType, 1, pos.DeviceName, pos.DeviceKind, pos.DeviceType, ToUserId, store.UserId, DateTime.Now, pos.SourceStoreId, store.Id, pos.OpId);
- PublicFunction.StatUserMachineData(ToUserId, pos.BrandId, 1);
- StoreHouseUtil.EditStoreStock(store.Id, store.LaveNum -= 1, store.OutNum += 1);
- PosMachinesTwoUtil.EditPosInfo(pos.Id, OrderId, ToUserId, ToUserId, DateTime.Now, RecycEndDate, order.QueryCount, LeaderUserId);
- }
- OrdersUtil.EditOrdersInfo(order.Id, 2, 1, DateTime.Now, SnNos.TrimEnd(','));
- string SendData = "{\"Kind\":\"4\",\"Data\":{\"StoreId\":\"" + StoreId + "\",\"SnIds\":\"" + SnIds + "\"}}";
- RedisDbconn.Instance.AddList("StoreApplyQueue", SendData);
- }
- return "success";
- }
- #endregion
- #region 首页-仓库管理-售后单划拨
-
-
-
-
-
-
-
- public static string TransferForChangeDo(int OrderId, int StoreId, string SnIds)
- {
- int CheckCount = MachineChangeService.Count("OutStoreId='" + StoreId + "' and AuditResult=0");
- if (CheckCount >= 10)
- {
- return "待审核订单超过10单,请等待管理员审核";
- }
- var store = StoreHouseService.Query(StoreId);
- string[] SnIdList = SnIds.Split(',');
- string SnNos = "";
- var order = OrdersService.Query(OrderId);
- if (order.Id > 0)
- {
- if (order.Status == 2)
- {
- return "该订单已处理,请勿重复操作";
- }
- int ToUserId = order.UserId;
- int ChangeId = 0;
- List<string> SourceSnNos = new List<string>();
- if (order.Sort > 0)
- {
- var Apply = MachineChangeService.Query(order.Sort);
- if (Apply.Id > 0)
- {
- Apply.Status = 1;
- if (!string.IsNullOrEmpty(Apply.ChangeSnExpand))
- {
- string[] ChangeSnExpand = Apply.ChangeSnExpand.Split('\n');
- foreach (string sub in ChangeSnExpand)
- {
- if (!string.IsNullOrEmpty(sub))
- {
- SourceSnNos.Add(sub.Split(':')[0]);
- }
- }
- }
- ChangeId = Apply.Id;
- }
- }
- int SnIndex = 0;
- List<string> contents = new List<string>();
- foreach (string SnId in SnIdList)
- {
- string ChangeNo = "SC" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8);
- int SnIdNum = int.Parse(SnId);
- DateTime RecycEndDate = DateTime.Now.AddDays(360);
- string SourceSnNo = "";
- if (SourceSnNos.Count > SnIndex)
- {
- SourceSnNo = SourceSnNos[SnIndex];
- var forSnNo = MachineForSnNoService.Query("SnNo='" + SourceSnNo + "'");
- var spos = PosMachinesTwoService.Query(forSnNo.SnId);
- RecycEndDate = spos.RecycEndDate == null ? RecycEndDate = DateTime.Now.AddDays(360) : spos.RecycEndDate.Value;
- }
- var pos = PosMachinesTwoService.Query(SnIdNum);
-
- if (pos.OpId > 0)
- {
- var sysAdmin = MySystem.Service.Operate.SysAdminService.Query("QueryCount=1 and UserId='" + pos.OpId + "'");
- if (sysAdmin.Id > 0)
- {
- sysAdmin.TotalMachineCount -= 1;
- Dictionary<string, object> File = new Dictionary<string, object>();
- File.Add("TotalMachineCount", sysAdmin.TotalMachineCount);
- MySystem.Service.Operate.SysAdminService.Edit(File, sysAdmin.Id);
- }
- }
- var merchant = PosMerchantInfoService.Query(pos.BindMerchantId);
- SnNos += pos.PosSn + ",";
- AddForTransfer(StoreId, pos.BrandId, KqProductsService.Query(pos.BrandId).Name, ChangeNo, 11, pos.PosSn, pos.PosSnType, 1, pos.DeviceType, store.UserId, DateTime.Now, ToUserId, StoreId, pos.OpId);
- UserStoreChangeUtil.AddForTransfer(store.UserId, pos.BrandId, ChangeNo, 0, pos.PosSn, pos.PosSnType, 0, pos.DeviceName, pos.DeviceKind, pos.DeviceType, ToUserId, DateTime.Now, pos.SourceStoreId, 1, (int)pos.BindingState, pos.BindMerchantId, (int)pos.ActivationState, pos.BuyUserId, pos.DeviceType);
- StoreChangeHistoryUtil.AddForTransfer(store.UserId, pos.BrandId, ChangeNo, 2, pos.PosSn, pos.PosSnType, 1, pos.DeviceName, pos.DeviceKind, pos.DeviceType, ToUserId, store.UserId, DateTime.Now, pos.SourceStoreId, store.Id, pos.OpId);
- PublicFunction.StatUserMachineData(ToUserId, pos.BrandId, 1);
- StoreHouseUtil.EditStoreStock(store.Id, store.LaveNum -= 1, store.OutNum += 1);
- PosMachinesTwoUtil.EditPosInfo(pos.Id, OrderId, ToUserId, ToUserId, DateTime.Now, RecycEndDate, order.QueryCount, 0);
- string content = "{";
- content += "\"OldSn\":\"" + SourceSnNo + "\",";
- content += "\"NewSn\":\"" + pos.PosSn + "\",";
- content += "\"MerNo\":\"" + merchant.KqMerNo + "\",";
- content += "\"ChangeId\":\"" + ChangeId + "\"";
- content += "}";
- contents.Add(content);
- }
- OrdersUtil.EditOrdersInfo(order.Id, 2, 1, DateTime.Now, SnNos.TrimEnd(','));
- foreach (string content in contents)
- {
- RedisDbconn.Instance.AddList("ChangePosTimerQueue", content);
- }
- string SendData = "{\"Kind\":\"4\",\"Data\":{\"StoreId\":\"" + StoreId + "\",\"SnIds\":\"" + SnIds + "\"}}";
- RedisDbconn.Instance.AddList("StoreApplyQueue", SendData);
- }
- return "success";
- }
- #endregion
- #region 添加仓库库存变动记录(仓库出货)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public static void AddForTransfer(int StoreId, int BrandId, string ProductName, string ChangeNo, int TransType, string SnNo, int SnType, int StockOpDirect, string DeviceType, int FromUserId, DateTime? FromDate, int ToUserId, int ToStoreId, int OpId)
- {
- Dictionary<string, object> query = new Dictionary<string, object>();
- query.Add("StoreId", StoreId);
- query.Add("BrandId", BrandId);
- query.Add("ProductName", ProductName);
- query.Add("ChangeNo", ChangeNo);
- query.Add("TransType", TransType);
- query.Add("SnNo", SnNo);
- query.Add("SnType", SnType);
- query.Add("StockOpDirect", 1);
- query.Add("DeviceType", DeviceType);
- query.Add("FromUserId", FromUserId);
- query.Add("FromDate", FromDate);
- query.Add("ToUserId", ToUserId);
- query.Add("ToStoreId", ToStoreId);
- query.Add("OpId", OpId);
- StoreStockChangeService.Add(query);
- }
- #endregion
- }
- }
|