oem逻辑优化 订单查询服务端相关代码
This commit is contained in:
1 parent
554d1f4b4f
commit
aeeb0fa0c6
33 files changed
+2448
-103
No files matched your search
@@ -0,0 +1,338 @@
|
||||
using AllBase;
|
||||
using AllBase.Helper;
|
||||
using AllBase.Model.DBModel;
|
||||
using AllBase.Model.Param.TemuProductManage;
|
||||
using AllBase.Model.Result;
|
||||
using NaiBa.Util;
|
||||
using NaiBa.Util.Extension;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Printing;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using TemuKJD.BaseForms;
|
||||
using TemuKJD.BLL;
|
||||
using TemuKJD.Extension;
|
||||
using TemuKJD.WXForms.ShopForms;
|
||||
using Work;
|
||||
|
||||
namespace TemuKJD.WXForms.AdminForms
|
||||
{
|
||||
public partial class WXAdminTransitWarehouseManage : BaseForms.BaseGeneralForm
|
||||
{
|
||||
static WXAdminTransitWarehouseManage inst = null;
|
||||
public static WXAdminTransitWarehouseManage Instance
|
||||
{
|
||||
get { if (inst == null) inst = new WXAdminTransitWarehouseManage(); return inst; }
|
||||
set { inst = value; }
|
||||
}
|
||||
|
||||
public static ConcurrentList<oms_wei_external_procurement_log> lstTransitWarehouseOrder { get; set; } = new ConcurrentList<oms_wei_external_procurement_log>();
|
||||
|
||||
public WXAdminTransitWarehouseManage()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
private void AdminShopForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
this.ucSplitPage1.PageChange += UcSplitPage1_PageChange;
|
||||
|
||||
this.dgvShop.AddSelectorColumn("colSelect");
|
||||
//this.dgvShop.AddMergeColumnHeader(new List<string>() { /*"colMinus",*/ "colProductRemaining", "colPlus" }, "选品限额");
|
||||
//this.dgvShop.AddMergeColumn(new List<string>() { /*"colMinus",*/ "colProductRemaining", "colPlus" });
|
||||
//this.dgvShop.Columns["colMinus"].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
|
||||
//this.dgvShop.Columns["colPlus"].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
|
||||
//this.dgvShop.Columns["colPlus"].HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter;
|
||||
|
||||
if (BaseClass.SaLevel != 1)
|
||||
{
|
||||
//dgvShop.Columns["colSubSa"].Visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool firstLoad = true;
|
||||
private void AdminShopForm_VisibleChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (this.Visible == true && firstLoad)
|
||||
{
|
||||
firstLoad = false;
|
||||
this.pbLoading.Visible = true;
|
||||
SearchTransitOrder(this.ucSplitPage1.CurrentPage);
|
||||
}
|
||||
}
|
||||
|
||||
private void UcSplitPage1_PageChange(object obj)
|
||||
{
|
||||
SearchTransitOrder(this.ucSplitPage1.CurrentPage);
|
||||
}
|
||||
|
||||
public void SearchTransitOrder(int page)
|
||||
{
|
||||
List<string> shopIdList = GetCheckedShopIdList();
|
||||
if (InvokeRequired)
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
this.pbLoading.Visible = true;
|
||||
this.dgvShop.Rows.Clear();
|
||||
lstTransitWarehouseOrder.Clear();
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.pbLoading.Visible = true;
|
||||
this.dgvShop.Rows.Clear();
|
||||
lstTransitWarehouseOrder.Clear();
|
||||
}
|
||||
Task.Run(() =>
|
||||
{
|
||||
int pageCount;
|
||||
decimal seconds = 0;
|
||||
var list = AdminGetServerShopLst(out pageCount, out seconds, page, ucSplitPage1.PageSize);
|
||||
lstTransitWarehouseOrder.AddRange(list);
|
||||
this.ucSplitPage1.TotalPage = pageCount;
|
||||
|
||||
|
||||
var url = BaseClass.BuildWXObjString("order/get_erp_order_list");
|
||||
var data = UserLogin.GetSignaturex();
|
||||
data += "&erp_order_id_in=" + string.Join(",", list.Select(s => s.order_no));
|
||||
data += "&is_not_count=true";
|
||||
data += "&page_size=" + 5000;
|
||||
Thread.Sleep(200);
|
||||
var html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
var orderList = JsonHelper.DeserializeJsonToList<oms_wei_order>(JObject.Parse(html)["data"].ParseToString());
|
||||
if (orderList == null)
|
||||
orderList = new List<oms_wei_order>();
|
||||
|
||||
foreach (var order in lstTransitWarehouseOrder)
|
||||
{
|
||||
order.oms_Wei_Order = orderList.FirstOrDefault(o => o.order_id == order.order_no);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
foreach (var order in lstTransitWarehouseOrder)
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
int rowIndex = this.dgvShop.Rows.Add(
|
||||
false,
|
||||
order.out_order_no,
|
||||
order.order_no,
|
||||
order.order_sku_id,
|
||||
BaseClass.StampToDateTime(order.oms_Wei_Order.create_time).ToString("yy-MM-dd HH:mm"),
|
||||
order.oms_Wei_Order.shop_name,
|
||||
order.buyer_account,
|
||||
order.out_amount * 0.01m,
|
||||
order.purchaser_note,
|
||||
order.express_1_company,
|
||||
order.express_1_waybill,
|
||||
order.express_2_company,
|
||||
order.express_2_waybill,
|
||||
order.refund_status,
|
||||
order.pickup_time == DateTime.MinValue ? "" : order.pickup_time.ToString("yy-MM-dd HH:mm"),
|
||||
order.transfer_warehouse_status,
|
||||
order.raw_message,
|
||||
order.created_time.ToString("yy-MM-dd HH:mm"),
|
||||
order.updated_time.ToString("yy-MM-dd HH:mm"),
|
||||
order.platform,
|
||||
order.order_platform_code,
|
||||
order.order_code,
|
||||
order.pre_allocated_order_no,
|
||||
order.is_transfer_ship,
|
||||
order.random_code
|
||||
);
|
||||
}));
|
||||
}
|
||||
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
this.pbLoading.Visible = false;
|
||||
this.statusBar.lblTaskStatus.Text = "店铺查询完毕";
|
||||
#if DEBUG
|
||||
this.statusBar.lblTaskStatus.Text += ",耗时:" + seconds;
|
||||
#endif
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
private void btnSearch_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (this.ucSplitPage1.CurrentPage != 1)
|
||||
this.ucSplitPage1.CurrentPage = 1;
|
||||
else
|
||||
SearchTransitOrder(1);
|
||||
}
|
||||
|
||||
private void pnlEmpty_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.txtWxOrderNo.Text = "";
|
||||
this.txtOutOrderNo.Text = "";
|
||||
this.txt.Text = "";
|
||||
this.textBox2.Text = "";
|
||||
}
|
||||
|
||||
bool IsOperate = false;
|
||||
private void btnLoginSelect_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (BaseMsgForm.ShowConfirm("确定删除仓库单吗?删除后不可恢复!").DialogResult == DialogResult.Cancel)
|
||||
return;
|
||||
|
||||
IsOperate = true;
|
||||
{
|
||||
List<string> outOrderIds = GetCheckedList();
|
||||
if (!outOrderIds.Any())
|
||||
{
|
||||
BaseMsgForm.ShowError("请选择需要删除的仓库单");
|
||||
IsOperate = false;
|
||||
return;
|
||||
}
|
||||
|
||||
//todo 删除订单
|
||||
var url3 = BaseClass.BuildWXObjString("order/wx_del_erp_transit_warehouse_order");
|
||||
var data3 = UserLogin.GetSignaturex();
|
||||
if (outOrderIds.Count > 0)
|
||||
data3 += "&out_order_no=" + string.Join(",", outOrderIds);
|
||||
var html3 = GetHtml.PostUtf8(url3, data3);
|
||||
if (string.IsNullOrEmpty(html3) || !html3.Contains("\"code\":200"))
|
||||
html3 = GetHtml.PostUtf8(url3, data3);
|
||||
|
||||
if (html3.Contains("\"code\":200"))
|
||||
{
|
||||
if (this.ucSplitPage1.CurrentPage != 1)
|
||||
this.ucSplitPage1.CurrentPage = 1;
|
||||
else
|
||||
SearchTransitOrder(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseMsgForm.ShowError("删除失败" + BaseRegex.GetStringJson(ref html3, "msg"));
|
||||
}
|
||||
}
|
||||
IsOperate = false;
|
||||
}
|
||||
|
||||
private void dgvShop_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
||||
{
|
||||
if (e.ColumnIndex < 0 || e.RowIndex < 0)
|
||||
return;
|
||||
string headerText = dgvShop.Columns[e.ColumnIndex].HeaderText;
|
||||
string outOrderNo = dgvShop.Rows[e.RowIndex].Cells["colOutOrderNo"].Value.ParseToString();
|
||||
var order = lstTransitWarehouseOrder.FirstOrDefault(v => v.out_order_no == outOrderNo);
|
||||
var row = dgvShop.Rows[e.RowIndex];
|
||||
|
||||
switch (headerText)
|
||||
{
|
||||
case "删除":
|
||||
if (BaseMsgForm.ShowConfirm("确定删除仓库单吗?删除后不可恢复!").DialogResult == DialogResult.Cancel)
|
||||
return;
|
||||
break;
|
||||
case "":
|
||||
row.Cells["colSelect"].Value = !row.Cells["colSelect"].Value.ParseToBool();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private List<string> GetCheckedList()
|
||||
{
|
||||
List<string> checkOrderLst = new List<string>();
|
||||
for (int i = 0; i < dgvShop.Rows.Count; i++)
|
||||
{
|
||||
if (dgvShop.Rows[i].Cells["colSelect"].Value.ParseToBool())
|
||||
{
|
||||
string shopName = dgvShop.Rows[i].Cells["colOutOrderNo"].Value.ParseToString();
|
||||
checkOrderLst.Add(shopName);
|
||||
}
|
||||
}
|
||||
return checkOrderLst;
|
||||
}
|
||||
|
||||
private List<string> GetCheckedShopIdList()
|
||||
{
|
||||
List<string> shopNameList = new List<string>();
|
||||
for (int i = 0; i < dgvShop.Rows.Count; i++)
|
||||
{
|
||||
if (dgvShop.Rows[i].Cells["colSelect"].Value.ParseToBool())
|
||||
{
|
||||
string shopName = dgvShop.Rows[i].Cells["colShopId"].Value.ParseToString();
|
||||
shopName += dgvShop.Rows[i].Cells["colUser"].Value.ParseToString();
|
||||
shopNameList.Add(shopName);
|
||||
}
|
||||
}
|
||||
return shopNameList;
|
||||
}
|
||||
|
||||
public List<oms_wei_external_procurement_log> AdminGetServerShopLst(out int pageCount, out decimal seconds, int page = 1, int pageSize = 50)
|
||||
{
|
||||
pageCount = 0;
|
||||
seconds = 0;
|
||||
|
||||
var url3 = BaseClass.BuildWXObjString("order/wx_get_transit_order");
|
||||
var data3 = UserLogin.GetSignaturex();
|
||||
Invoke(new Action(() => { }));
|
||||
if (!string.IsNullOrEmpty(txtOutOrderNo.Text.Trim()))
|
||||
data3 += "&out_order_no=" + string.Join(",", this.txtOutOrderNo.Text.Split(new string[] { "\r", "\n", " "}, StringSplitOptions.RemoveEmptyEntries));
|
||||
if (!string.IsNullOrEmpty(txtWxOrderNo.Text.Trim()))
|
||||
data3 += "&order_no=" + string.Join(",", this.txtWxOrderNo.Text.Split(new string[] { "\r", "\n", " " }, StringSplitOptions.RemoveEmptyEntries));
|
||||
if (!string.IsNullOrEmpty(txt.Text.Trim()))
|
||||
data3 += "&transfer_warehouse_status=" + string.Join(",", this.txt.Text.Split(new string[] { "\r", "\n", " " }, StringSplitOptions.RemoveEmptyEntries));
|
||||
if (!string.IsNullOrEmpty(textBox2.Text.Trim()))
|
||||
data3 += "&pre_allocated_order_no=" + string.Join(",", this.textBox2.Text.Split(new string[] { "\r", "\n", " " }, StringSplitOptions.RemoveEmptyEntries));
|
||||
data3 += "&is_admin=true";
|
||||
data3 += "&page=" + page;
|
||||
data3 += "&page_size=" + pageSize;
|
||||
data3 += "¬_count=false";
|
||||
var html3 = GetHtml.PostUtf8(url3, data3);
|
||||
if (string.IsNullOrEmpty(html3) || !html3.Contains("\"code\":200"))
|
||||
html3 = GetHtml.PostUtf8(url3, data3);
|
||||
if (string.IsNullOrEmpty(html3) || !html3.Contains("\"code\":200"))
|
||||
{
|
||||
//Dispatcher.Invoke(new Action(() =>
|
||||
//{
|
||||
// BaseMsgWindow.ShowError(MainWindow.Instance, "订单读取失败 " + BaseRegex.GetStringJson(ref html, "msg"));
|
||||
//}));
|
||||
//break;
|
||||
}
|
||||
List<oms_wei_external_procurement_log> transitOrderList = new List<oms_wei_external_procurement_log>();
|
||||
try
|
||||
{
|
||||
transitOrderList = JsonHelper.DeserializeJsonToList<oms_wei_external_procurement_log>(JObject.Parse(html3)["data"].ParseToString());
|
||||
if (transitOrderList == null)
|
||||
transitOrderList = new List<oms_wei_external_procurement_log>();
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
seconds = BaseRegex.GetDecimalJson(ref html3, "seconds");
|
||||
int count = BaseRegex.GetIntJson(ref html3, "count");
|
||||
pageCount = Math.Ceiling(1.0 * count / pageSize).ParseToInt();
|
||||
pageCount = Math.Max(pageCount, 1);
|
||||
return transitOrderList;
|
||||
}
|
||||
|
||||
private void dgvShop_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user