67 lines
2.8 KiB
C#
67 lines
2.8 KiB
C#
using Ninject;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Web.Mvc;
|
|
using WX.CRM.Common;
|
|
using WX.CRM.IBLL.weapp;
|
|
using WX.CRM.Model.MAP;
|
|
using WX.CRM.WebHelper;
|
|
using WX.CRM.WebHelper.Infrastructure;
|
|
|
|
namespace WX.CRM.WEB.Controllers.Weapp
|
|
{
|
|
public class WeappMessageController : BaseController
|
|
{
|
|
private readonly IWEAPP_GROUP _weappGroup = NinjectControllerFactory.ninjectKernel.Get<IWEAPP_GROUP>();
|
|
private readonly IWEAPP_USERGROUP _weappUserGroup = NinjectControllerFactory.ninjectKernel.Get<IWEAPP_USERGROUP>();
|
|
private readonly IWX_UserInfo _weappUserInfo = NinjectControllerFactory.ninjectKernel.Get<IWX_UserInfo>();
|
|
public WeappMessageController()
|
|
{
|
|
}
|
|
|
|
public ActionResult Index(decimal? eId, string accountNum)
|
|
{
|
|
var list = new List<UserGroupView>();
|
|
var groups = _weappGroup.GetList(p => (p.GROUPTYPE == 0 || p.SALEUSEREID == eId) && p.ACCOUNTNUM == accountNum).OrderBy(m => m.PKID);
|
|
var userGroups = _weappUserGroup.GetList(p => p.SALEUSEREID == eId && p.ACCOUNTNUM == accountNum);
|
|
var customerDt = _weappUserInfo.GetFriends(eId.Value, accountNum);
|
|
var customerList = new List<CustoemrDetail>();
|
|
foreach (DataRow row in customerDt.Rows)
|
|
{
|
|
var info = new CustoemrDetail
|
|
{
|
|
NickName = row["nickname"].ToString(),
|
|
OpenId = row["openid"].ToString()
|
|
};
|
|
customerList.Add(info);
|
|
}
|
|
foreach (var item in groups)
|
|
{
|
|
var userGroup = userGroups.Where(p => p.GROUPID == item.PKID);
|
|
var userGroupList = new List<UserGroup>();
|
|
foreach (var row in userGroup)
|
|
{
|
|
var customer = customerList.FirstOrDefault(p => p.OpenId == row.OPENID);
|
|
var data = new UserGroup { GroupId = row.GROUPID, OpenId = row.OPENID, SaleUserEid = row.SALEUSEREID, NickName = customer != null ? customer.NickName : string.Empty };
|
|
userGroupList.Add(data);
|
|
}
|
|
var info = new UserGroupView()
|
|
{
|
|
GroupId = item.PKID,
|
|
GroupName = item.GROUPNAME,
|
|
GroupType = item.GROUPTYPE,
|
|
SaleUserEid = item.SALEUSEREID,
|
|
AccountNum = item.ACCOUNTNUM,
|
|
UserGroupList = userGroupList
|
|
};
|
|
list.Add(info);
|
|
}
|
|
ViewBag.GroupList = list;
|
|
ViewBag.customerList = Utility.ConvertToJSON(customerList);
|
|
ViewBag.SaleUserName = InnerUserHelper.Instance.GetEidAndTrueName(InnerUserHelper.Instance.GetUserIdByEid(eId.Value));
|
|
return View();
|
|
}
|
|
}
|
|
}
|