85 lines
2.8 KiB
C#
85 lines
2.8 KiB
C#
using CRM.Core.BLL.Wx;
|
|
using CRM.Core.Common.WebHelper;
|
|
using Quartz;
|
|
using System;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using WX.CRM.Common;
|
|
|
|
namespace CRM.Core.CoreService.Contract
|
|
{
|
|
public class ContractRebuildJob : IJob
|
|
{
|
|
static bool rBuilding = false;
|
|
|
|
private WX_SZZYORDER_BL orderBL = new WX_SZZYORDER_BL();
|
|
|
|
public void Execute(JobExecutionContext context)
|
|
{
|
|
if (rBuilding)
|
|
{
|
|
return;
|
|
}
|
|
rBuilding = true;
|
|
try
|
|
{
|
|
var orderList = orderBL.GetList(m => m.PRODUCTID == 1007 && m.ISOPEN == 1 && m.CONTRACTCODE != "").Select(m => new { m.ORDERID, m.SZZYORDERID, m.CONTRACTCODE }).ToList();
|
|
LogHelper.Info("订单数量:" + orderList.Count);
|
|
int count = 0;
|
|
if (orderList != null && orderList.Count > 0)
|
|
{
|
|
foreach (var model in orderList)
|
|
{
|
|
var jsonModel = new ContractRebuildModel
|
|
{
|
|
sign = "1qazxdr5",
|
|
htid = model.CONTRACTCODE
|
|
};
|
|
//if (count > 2)
|
|
//{
|
|
// break;
|
|
//}
|
|
string json = JsonHelper.ObjDivertToJson(jsonModel);
|
|
string retmsg = Utility.PostAjaxData("https://r2.soft.dn8188.com/contract_sign_crm/reconfirm", json, Encoding.UTF8);//返回信息
|
|
|
|
ContractResponseModel res = JsonHelper.JsonDivertToObj<ContractResponseModel>(retmsg);
|
|
if (res.ret == 0)
|
|
{
|
|
LogHelper.Info("重新生成合同:" + model.CONTRACTCODE + ",订单号:" + model.ORDERID.ToString() + "成功");
|
|
}
|
|
else
|
|
{
|
|
LogHelper.Info("重新生成合同:" + model.CONTRACTCODE + ",订单号:" + model.ORDERID.ToString() + "失败,错误信息:" + res.msg);
|
|
|
|
}
|
|
count++;
|
|
//生成
|
|
Thread.Sleep(600);
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error("重新生成合同错误:" + ex);
|
|
}
|
|
}
|
|
|
|
public class ContractRebuildModel
|
|
{
|
|
public string sign { get; set; }
|
|
|
|
public string htid { get; set; }
|
|
}
|
|
|
|
public class ContractResponseModel
|
|
{
|
|
public int ret { get; set; }
|
|
|
|
public string msg { get; set; }
|
|
}
|
|
}
|
|
}
|