You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

145 lines
7.7 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using BWP.B3Frameworks.BO;
using BWP.B3Frameworks.Utils;
using BWP.B3Sale.BL;
using BWP.B3Sale.BO;
using Forks.EnterpriseServices.BusinessInterfaces;
using Forks.EnterpriseServices.DomainObjects2;
namespace BWP.Web.Pages.WeixinMessage_
{
public class CusAcceptWeixinMessageTemplate : WeixinMessageUtil.IWeixinMessageView
{
WeixinMessage mMessage;
public CusAcceptWeixinMessageTemplate(WeixinMessage message)
{
mMessage = message;
}
public System.Web.UI.Control CreateContent()
{
var bl = BIFactory.Create<ICustomerAcceptBL>();
var cusAccept = bl.Load(mMessage.TargetID.Value);
var dmoTypeId = DmoTypeIDAttribute.GetID(typeof(SaleOutStore));
string outCode = string.Empty;
string dealer = string.Empty;
string car_Name = string.Empty;
string freightUnitPrice = string.Empty;
string driver_Name = string.Empty;
string driverPhone = string.Empty;
string allUnitNum = string.Empty;
string money = string.Empty;
string freightPrice = string.Empty;
if (cusAccept.BillType == dmoTypeId) {
var outbl = BIFactory.Create<ISaleOutStoreBL>();
if (cusAccept.BillID != null) {
var saleOutStore = outbl.Load(cusAccept.BillID.Value);
outCode = saleOutStore.Code;
dealer = saleOutStore.CustomerDealer_Name;
car_Name = saleOutStore.Car_Name;
if (!string.IsNullOrEmpty(saleOutStore.Car_Name) && !string.IsNullOrEmpty(saleOutStore.HandcarNumber)) {
car_Name = saleOutStore.Car_Name + "/" + saleOutStore.HandcarNumber;
}
freightUnitPrice = saleOutStore.FreightUnitPrice == null ? string.Empty : saleOutStore.FreightUnitPrice.ToString();
driver_Name = saleOutStore.Driver_Name;
driverPhone = saleOutStore.DriverPhone;
if (!string.IsNullOrEmpty(saleOutStore.DriverPhone) && !string.IsNullOrEmpty(saleOutStore.DriverPhone1)) {
driverPhone = saleOutStore.DriverPhone + "/" + saleOutStore.DriverPhone1;
}
allUnitNum = saleOutStore.AllUnitNum == null ? string.Empty : saleOutStore.AllUnitNum.ToString();
money = saleOutStore.Money == null ? string.Empty : saleOutStore.Money.ToString();
freightPrice = saleOutStore.FreightPrice == null ? string.Empty : saleOutStore.FreightPrice.ToString();
} else {
outCode = cusAccept.BillIDs;
dealer = cusAccept.CustomerDealer_Name;
car_Name = cusAccept.Car_Name;
if (!string.IsNullOrEmpty(cusAccept.Car_Name) && !string.IsNullOrEmpty(cusAccept.HandcarNumber)) {
car_Name = cusAccept.Car_Name + "/" + cusAccept.HandcarNumber;
}
freightUnitPrice = cusAccept.FreightUnitPrice == null ? string.Empty : cusAccept.FreightUnitPrice.ToString();
driver_Name = cusAccept.Driver_Name;
driverPhone = cusAccept.DriverPhone;
if (!string.IsNullOrEmpty(cusAccept.DriverPhone) && !string.IsNullOrEmpty(cusAccept.DriverPhone1)) {
driverPhone = cusAccept.DriverPhone + "/" + cusAccept.DriverPhone1;
}
allUnitNum = cusAccept.AcceptNumber == null ? string.Empty : cusAccept.AcceptNumber.ToString();
money = cusAccept.Money == null ? string.Empty : cusAccept.Money.ToString();
freightPrice = cusAccept.FreightPrice == null ? string.Empty : cusAccept.FreightPrice.ToString();
}
}
var checkTime = cusAccept.CheckTime == null ? "" : cusAccept.CheckTime.Value.ToString();
var acceptNumber = cusAccept.AcceptNumber==null?string.Empty:cusAccept.AcceptNumber.ToString();
var acceptFreightUnitPrice = cusAccept.FreightUnitPrice==null?string.Empty:cusAccept.FreightUnitPrice.ToString();
var acceptMoney = cusAccept.Money==null?string.Empty:cusAccept.Money.ToString();
var acceptFreightPrice = cusAccept.FreightPrice==null?string.Empty:cusAccept.FreightPrice.ToString();
var employee_Name = cusAccept.Employee_Name;
var tel = string.Empty;
using (var context = new TransactionContext()) {
tel = InnerBLUtil.GetDmoPropertyByID<string>(context.Session, typeof(Employee), "HandPhone", cusAccept.Employee_ID ?? 0);
}
var html = @"
<article class=""weui-article"">
<h1>{title}</h1>
<section>
<table border=""1"" cellspacing=""0"">
<tr><td colspan=""3"">经销商发货信息</td><td>单号</td><td colspan=""2"">{OutCode}</td></tr>
<tr><td>发货工厂</td><td colspan=""2"">{AccountingUnit_Name}</td><td>发货时间</td><td colspan=""2"">{CheckTime}</td></tr>
<tr><td>客户名称</td><td colspan=""5"">{CustomerDealer_Name}</td></tr>
<tr><td>运输车号</td><td colspan=""2"">{Car_Name}</td><td>运费单价</td><td colspan=""2"">{FreightUnitPrice}</td></tr>
<tr><td>司机姓名</td><td colspan=""2"">{Driver_Name}</td><td>司机电话</td><td colspan=""2"">{DriverPhone}</td></tr>
<tr><td>总数量(kg)</td><td>{AllUnitNum}</td><td>总金额</td><td>{Money}</td><td>总运费</td><td>{FreightPrice}</td></tr>
<tr><td>客户经理</td><td colspan=""2"">{Employee_Name}</td><td>联系电话</td><td colspan=""2"">{Tel}</td></tr>
<tr><td>温馨提示:</td><td colspan=""5"">如您对货单有疑问,请联系客户经理,谢谢!</td></tr>
<tr><td colspan=""3"">分销商发货明细</td><td>单号</td><td colspan=""2"">{AcceptCode}</td></tr>
<tr><td>客户名称</td><td colspan=""5"">{Customer_Name}</td></tr>
<tr><th>名称</th><th>品牌</th><th>件数</th><th>单价</th><th>重量</th><th>金额</th></tr>
{trs}
<tr><td>总数量</td><td colspan=""2"">{AcceptNumber}</td><td>运费单价</td><td colspan=""2"">{AcceptFreightUnitPrice}</td></tr>
<tr><td>总金额</td><td colspan=""2"">{AcceptMoney}</td><td>运费金额</td><td colspan=""2"">{AcceptFreightPrice}</td></tr>
</table>
</section>
</article>
";
html = html.Replace("{title}", mMessage.Title);
html = html.Replace("{OutCode}", outCode).Replace("{AccountingUnit_Name}", cusAccept.AccountingUnit_Name).Replace("{CheckTime}", checkTime).Replace("{CustomerDealer_Name}", dealer).Replace("{Car_Name}", car_Name).Replace("{FreightUnitPrice}", freightUnitPrice).Replace("{Driver_Name}", driver_Name).Replace("{DriverPhone}", driverPhone).Replace("{AllUnitNum}", allUnitNum).Replace("{Money}", money).Replace("{FreightPrice}", freightPrice).Replace("{AcceptCode}", cusAccept.Code).Replace("{Customer_Name}", cusAccept.Customer_Name).Replace("{AcceptNumber}", acceptNumber).Replace("{AcceptFreightUnitPrice}", acceptFreightUnitPrice).Replace("{AcceptMoney}", acceptMoney).Replace("{AcceptFreightPrice}", acceptFreightPrice).Replace("{Employee_Name}", employee_Name).Replace("{Tel}", tel);
if (cusAccept.Details.Count() > 0) {
var str = new StringBuilder();
foreach (var detail in cusAccept.Details) {
str.Append("<tr>");
str.Append("<td>");
str.Append(detail.Goods_Name);
str.Append("</td>");
str.Append("<td>");
str.Append(detail.BrandItem_Name);
str.Append("</td>");
str.Append("<td>");
str.Append(detail.AcceptSecondNumber);
str.Append("</td>");
str.Append("<td>");
str.Append(detail.Price);
str.Append("</td>");
str.Append("<td>");
str.Append(detail.AcceptNum);
str.Append("</td>");
str.Append("<td>");
str.Append(detail.AcceptMoney);
str.Append("</td>");
str.Append("</tr>");
}
html = html.Replace("{trs}", str.ToString());
}
return new LiteralControl(html);
}
public string GetTitle()
{
return mMessage.Title;
}
}
}