Files
29WxOrder/29WxOrder/OrderForms/OrderEdit.cs
T
2026-06-12 10:41:13 +08:00

299 lines
12 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using AllBase;
using AllBase.DouYinModel.Result;
using AllBase.Model.Result;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Work;
using Work.Api;
using Work.BaseForms;
using Work.BuyUsers;
namespace _29WxOrder.OrderForms
{
public partial class OrderEdit : BaseGeneralForm
{
public OrderEdit()
{
InitializeComponent();
}
public BuyOrderListForm buyOrderListForm;
public SendOrderListForms sendOrderForms;
public AfterSaleOrderListForm afterSaleOrderListForm;
public DouYinOrderModel orderDetail { get; internal set; }
/// <summary>
/// 1sendorder 2 buyorder 4 aftersale
/// </summary>
public int formtype = 0;
private void OrderEdit_Load(object sender, EventArgs e)
{
this.TitleText = "编辑订单";
if (string.IsNullOrEmpty(orderDetail?.product_id))
{
return;
}
string url = BaseClass.Build29WxObjString("upid&act=get");
string html = GetHtml.PostUtf8(url, "pid=" + orderDetail.product_id + "&" + UserLogin.GetSignaturex());
var jArr = JObject.Parse(html)["data"];
if (jArr.Count() > 0)
{
if (JObject.Parse(html)["data"][0]["up_ids"].ToString() == JObject.Parse(html)["data"][0]["default_up_ids"].ToString())
{
rbProduct1.Checked = true;
}
else if (JObject.Parse(html)["data"][0]["up_ids2"].ToString() == JObject.Parse(html)["data"][0]["default_up_ids"].ToString())
{
rbProduct2.Checked = true;
}
else if (JObject.Parse(html)["data"][0]["up_ids3"].ToString() == JObject.Parse(html)["data"][0]["default_up_ids"].ToString())
{
rbProduct3.Checked = true;
}
else if (JObject.Parse(html)["data"][0]["up_ids4"].ToString() == JObject.Parse(html)["data"][0]["default_up_ids"].ToString())
{
rbProduct4.Checked = true;
}
else if (JObject.Parse(html)["data"][0]["up_ids5"].ToString() == JObject.Parse(html)["data"][0]["default_up_ids"].ToString())
{
rbProduct5.Checked = true;
}
tbCustomProductId1.Text = JObject.Parse(html)["data"][0]["up_ids"].ToString();
tbCustomProductId2.Text = JObject.Parse(html)["data"][0]["up_ids2"].ToString();
tbCustomProductId3.Text = JObject.Parse(html)["data"][0]["up_ids3"].ToString();
tbCustomProductId4.Text = JObject.Parse(html)["data"][0]["up_ids4"].ToString();
tbCustomProductId5.Text = JObject.Parse(html)["data"][0]["up_ids5"].ToString();
}
tbDefProductId.Text = orderDetail.up_product_id;
tbname.Text = orderDetail.name;
tbmobile.Text = orderDetail.mobile;
tbaddress.Text = orderDetail.address;
tbsku.Text = orderDetail.sku;
tborderidbuy.Text = orderDetail.order_id_buy;
tbcount.Text = orderDetail.count.ToString();
tbprice.Text = orderDetail.buy_price;
cbexpress_name.Text = orderDetail.express_name;
tbexpress_no.Text = orderDetail.express_no;
tbremark.Text = orderDetail.remark;
foreach (var item in CollectionClass.ExpressList)
{
cbexpress_name.Items.Add(item.name);
}
cbmaishou.Items.Clear();
List<UserModel> listum = new List<UserModel>();
foreach (KeyValuePair<BuyNumber, UserCookies> item in TaoBaoBuyUser.buyUserCookies)//拍单买手号
{
UserModel um = new UserModel();
um.name = item.Key.name;
um.uid = item.Value.uid;
listum.Add(um);
}
foreach (KeyValuePair<BuyNumber, UserCookies> item in PddBuyUser.buyUserCookies)//拍单买手号
{
UserModel um = new UserModel();
um.name = item.Key.name;
um.uid = item.Value.uid;
listum.Add(um);
}
foreach (KeyValuePair<BuyNumber, UserCookies> item in ALBuyUser.buyUserCookies)//拍单买手号
{
UserModel um = new UserModel();
um.name = item.Key.name;
um.uid = item.Value.uid;
listum.Add(um);
}
foreach (var item in AllBase.Helper.GlobalConfig.LstPddPifaShop)//拍单买手号
{
UserModel um = new UserModel();
um.name = item.PddId;
um.uid = item.PddId;
listum.Add(um);
}
cbmaishou.DataSource = listum;
cbmaishou.ValueMember = "uid";
cbmaishou.DisplayMember = "name";
for (int i = 0; i < cbmaishou.Items.Count; i++)
{
if (orderDetail.buyer_mobile_uid == (cbmaishou.Items[i] as UserModel).uid)
{
cbmaishou.SelectedIndex = i;
break;
}
}
}
private void btsave_Click(object sender, EventArgs e)
{
StringBuilder sb = new StringBuilder();
sb.Append("&pid=" + orderDetail.product_id);
sb.Append("&up_ids=" + tbCustomProductId1.Text.Trim());
sb.Append("&up_ids2=" + tbCustomProductId2.Text.Trim());
sb.Append("&up_ids3=" + tbCustomProductId3.Text.Trim());
sb.Append("&up_ids4=" + tbCustomProductId4.Text.Trim());
sb.Append("&up_ids5=" + tbCustomProductId5.Text.Trim());
string defid = "";
if (rbProduct1.Checked == true)
{
defid = tbCustomProductId1.Text.Trim();
sb.Append("&default_up_ids=" + tbCustomProductId1.Text.Trim());
}
else if (rbProduct2.Checked == true)
{
defid = tbCustomProductId2.Text.Trim();
sb.Append("&default_up_ids=" + tbCustomProductId2.Text.Trim());
}
else if (rbProduct3.Checked == true)
{
defid = tbCustomProductId3.Text.Trim();
sb.Append("&default_up_ids=" + tbCustomProductId3.Text.Trim());
}
else if (rbProduct4.Checked == true)
{
defid = tbCustomProductId4.Text.Trim();
sb.Append("&default_up_ids=" + tbCustomProductId4.Text.Trim());
}
else if (rbProduct5.Checked == true)
{
defid = tbCustomProductId5.Text.Trim();
sb.Append("&default_up_ids=" + tbCustomProductId5.Text.Trim());
}
string url = BaseClass.Build29WxObjString("upid&act=save");
string htmlUpid = GetHtml.PostUtf8(url, sb + "&" + UserLogin.GetSignaturex());
sb = new StringBuilder();
sb.Append("&order_id=" + orderDetail.order_id);
sb.Append("&sku=" + GetHtml.UrlEncodeUtf8(tbsku.Text));
sb.Append("&count=" + tbcount.Text);
sb.Append("&buy_price=" + tbprice.Text);
sb.Append("&express_name=" + cbexpress_name.Text);
sb.Append("&express_no=" + tbexpress_no.Text);
sb.Append("&name=" + GetHtml.UrlEncodeUtf8(tbname.Text));
sb.Append("&mobile=" + GetHtml.UrlEncodeUtf8(tbmobile.Text));
sb.Append("&address=" + GetHtml.UrlEncodeUtf8(tbaddress.Text));
sb.Append("&buyer_mobile=" + cbmaishou.Text);
sb.Append("&buyer_mobile_uid=" + cbmaishou.SelectedValue);
sb.Append("&order_id_buy=" + tborderidbuy.Text);
sb.Append("&remark=" + tbremark.Text);
sb.Append("&is_update_order=0"); // 1修改状态0不修改状态
DouShopLoginInfo shop = Work.CollectionClass.DouShopLoginList.Find(x => x.ShopId == orderDetail.shop_id.ToString());
if (shop != null)
{
orderDetail.remark = tbremark.Text.ToString();
Dictionary<string, string> dic = new Dictionary<string, string>() { };
dic.Add("remark", tbremark.Text.ToString());
dic.Add("order_id", orderDetail.order_id);
DouyinApi apix = new DouyinApi(shop);
apix.JsonData = dic;
string htmls = apix.AddOrderRemark();
}
url = BaseClass.Build29WxObjString("order&act=update");
var result = GetHtml.PostUtf8(url, UserLogin.GetSignaturex() + sb.ToString());
if (formtype == 1)
{
sendOrderForms.RreshUpIds(orderDetail.order_id);
}
else if (formtype == 2)
{
buyOrderListForm.RreshUpIds(orderDetail.order_id, orderDetail.product_id);
}
else if (formtype == 4 && afterSaleOrderListForm != null)
{
afterSaleOrderListForm.RreshUpIds(orderDetail.order_id);
}
if (!string.IsNullOrEmpty(htmlUpid) && htmlUpid.Contains("\"code\":200") && !string.IsNullOrEmpty(result) && result.Contains("\"code\":200"))
{
BaseMsgForm.ShowInfo("编辑成功");
}
else
{
var msg1 = "";
var msg2 = "";
if (!string.IsNullOrEmpty(htmlUpid) && !htmlUpid.Contains("\"code\":200"))
{
msg1 = "," + BaseRegex.GetStringJson(ref htmlUpid, "msg");
}
if (!string.IsNullOrEmpty(result) && !result.Contains("\"code\":200"))
{
msg2 = "," + BaseRegex.GetStringJson(ref result, "msg");
}
BaseMsgForm.ShowInfo("编辑失败" + msg1 + msg2);
}
}
private void button1_Click(object sender, EventArgs e)
{
string orderId = orderDetail.order_id;
string orderId_buy = tborderidbuy.Text;
string payMobile = cbmaishou.Text;
string payMobileId = cbmaishou.SelectedValue.ToString();
if (string.IsNullOrEmpty(payMobile))
{
BaseMsgForm.ShowInfo("请添加拍单账户", "", FormLevel.SMALL);
return;
}
if (string.IsNullOrEmpty(orderId_buy))
{
BaseMsgForm.ShowInfo("请添加拍单单号", "", FormLevel.SMALL);
return;
}
string cookies = "";
if (orderId_buy.Contains("-"))
{
var payAccount = PddBuyUser.buyUserCookies.First(x => x.Key.name == payMobile);
if (payAccount.Value == null)
{
BaseMsgForm.ShowInfo("未找到对应的拍单账户", "", FormLevel.SMALL);
return;
}
for (int j = 0; j < payAccount.Value.Cookies.Count; j++)
{
cookies += payAccount.Value.Cookies[j].Name + "=" + payAccount.Value.Cookies[j].Value + "; ";
}
}
else
{
var payAccount = TaoBaoBuyUser.buyUserCookies.FirstOrDefault(x => x.Key.name == payMobile);
if (payAccount.Value == null)
{
BaseMsgForm.ShowInfo("未找到对应的拍单账户", "", FormLevel.SMALL);
return;
}
for (int j = 0; j < payAccount.Value.Cookies.Count; j++)
{
cookies += payAccount.Value.Cookies[j].Name + "=" + payAccount.Value.Cookies[j].Value + "; ";
}
}
string buyPrice = new AutoConfirmExpress(cookies).CheckOrderPrice(orderId_buy, orderId, payMobile);
if (!string.IsNullOrEmpty(buyPrice))
{
tbprice.Text = buyPrice;
}
}
}
public class UserModel
{
public string uid { get; set; }
public string name { get; set; }
}
}