61 lines
2.7 KiB
C#
61 lines
2.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using WX.CRM.BLL.Wx;
|
|
using WX.CRM.Common;
|
|
using WX.CRM.DataSynFactory.Templates;
|
|
using WX.CRM.Model.Entity;
|
|
using System.Linq;
|
|
namespace WX.CRM.DataSynFactory.Cmd
|
|
{
|
|
public class Client_RefundContract_IMP : Interfaces.IDataImportSvr<Client_RefundContract>
|
|
{
|
|
private WX_SZZYORDER_BL _order = new WX_SZZYORDER_BL();
|
|
private WX_SZZYORDERREFUND_BL orderRefund_BL = new WX_SZZYORDERREFUND_BL();
|
|
//private WX_SZZYORDERREFUND_BL _refundOrder = new WX_SZZYORDERREFUND_BL();
|
|
private WX_SZZYORDERREFUNDCONTRACT_BL _refundOrderContract = new WX_SZZYORDERREFUNDCONTRACT_BL();
|
|
public bool GenerateBusinessOne(Client_RefundContract t)
|
|
{
|
|
try
|
|
{
|
|
var orderId = decimal.Parse(t.OrderId);
|
|
var order = _order.Get(p => p.ORDERID == orderId);
|
|
if (order != null)
|
|
{
|
|
var orderRefundContract = _refundOrderContract.Get(p => p.ORDERID == order.ORDERID);
|
|
if (t.type.HasValue && t.type.Value == 1)
|
|
{
|
|
List<WX_SZZYORDERREFUND> refList = orderRefund_BL.GetList(m => m.ORDERID == orderId).ToList();
|
|
foreach (var item in refList)
|
|
{
|
|
if (item.AUDITSTATUS == 0 && orderRefundContract != null)//签过退款协议,然后状态必须是尚未退款状态
|
|
{
|
|
orderRefund_BL.RefundCancel(item.ID, Convert.ToDateTime(t.ContractTime));//取消退款
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (orderRefundContract != null)
|
|
{
|
|
_refundOrderContract.Delete(p => p.ORDERID == order.ORDERID);
|
|
var contract = new WX_SZZYORDERREFUNDCONTRACT(order.ORDERID, t.HtId, t.RefundPrice, 0, t.ContractTime, t.ContractKey, 0);
|
|
return _refundOrderContract.Add(contract) > 0;
|
|
}
|
|
else
|
|
{
|
|
var contract = new WX_SZZYORDERREFUNDCONTRACT(order.ORDERID, t.HtId, t.RefundPrice, 0, t.ContractTime, t.ContractKey, 0);
|
|
return _refundOrderContract.Add(contract) > 0;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error(ex.ToString());
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|