254 lines
9.0 KiB
C#
254 lines
9.0 KiB
C#
using Ninject;
|
|
using System;
|
|
using System.Text;
|
|
using WX.CRM.BLL.Util;
|
|
using WX.CRM.Common;
|
|
using WX.CRM.IBLL.Util;
|
|
using WX.CRM.WebHelper.Infrastructure;
|
|
|
|
namespace WX.CRM.WEB.ViewModel.Level2
|
|
{
|
|
/// <summary>
|
|
/// 注册
|
|
/// </summary>
|
|
public class RegUserParamModel
|
|
{
|
|
public string username { get; private set; }
|
|
public string password { get; private set; }
|
|
public string mobile { get; private set; }
|
|
public string campaignId { get; private set; }
|
|
public string acceptSMS { get; private set; }
|
|
public string platform { get; private set; }
|
|
public string userCardNo { get; private set; }
|
|
public RegUserParamModel(string username, string password, string mobile, string campaignId, string acceptSMS, string platform, string userCardNo)
|
|
{
|
|
this.username = username;
|
|
this.password = password;
|
|
this.mobile = mobile;
|
|
this.campaignId = campaignId;
|
|
this.acceptSMS = acceptSMS;
|
|
this.platform = platform;
|
|
this.userCardNo = userCardNo;
|
|
}
|
|
public void CheckUserName()
|
|
{
|
|
if (string.IsNullOrEmpty(this.username))
|
|
throw new ArgumentException("注册的用户名不能为空");
|
|
}
|
|
public void CheckcampaignId()
|
|
{
|
|
if (string.IsNullOrEmpty(this.campaignId))
|
|
throw new ArgumentException("注册的渠道号不能为空");
|
|
}
|
|
public returnOrderResult getResult()
|
|
{
|
|
try
|
|
{
|
|
string json = Utility.ConvertToJSON<RegUserParamModel>(this);
|
|
string url = Utility.GetSettingByKey("regUrl");
|
|
returnOrderResult result = new returnOrderResult();
|
|
result = result.getResultObj(url, json);
|
|
result.type = "reg";
|
|
result.userName = this.username;
|
|
return result;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error("批量注册_注册" + ex.ToString());
|
|
returnOrderResult result = new returnOrderResult();
|
|
result.result = false;
|
|
result.type = "reg";
|
|
result.userName = this.username;
|
|
result.retcode = 10005;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
}
|
|
/// <summary>
|
|
/// 添加订单
|
|
/// </summary>
|
|
public class AddOrderModel1
|
|
{
|
|
public string productCode { get; private set; }
|
|
|
|
public string userName { get; private set; }
|
|
|
|
public string userCardNo { get; private set; }
|
|
/// <summary>
|
|
/// 身份证号码
|
|
/// </summary>
|
|
public string cradNo { get; private set; }
|
|
|
|
public string mobile { get; private set; }
|
|
|
|
public string mark { get; private set; }
|
|
|
|
public int orderNum { get; private set; }
|
|
|
|
public string campaignId { get; private set; }
|
|
|
|
public string ActivityId { get; private set; }
|
|
|
|
public string fullName { get; private set; }
|
|
|
|
public decimal campanyId { get; private set; }
|
|
|
|
public string IP { get; private set; }
|
|
|
|
public string CreateUser { get; private set; }
|
|
public AddOrderModel1(string productCode, string userName, string campaignId, int orderNum, string mobile, string Ip, string createUser)
|
|
: this(productCode, userName, "", "", mobile, "", orderNum, campaignId, "", "", 0, Ip, createUser)
|
|
{ }
|
|
|
|
public AddOrderModel1(string productCode, string userName, string userCardNo, string cradNO,
|
|
string mobile, string mark, int orderNum, string campaignId, string ActivityId,
|
|
string fullName, decimal campanyId, string Ip, string createUser
|
|
)
|
|
{
|
|
this.productCode = productCode;
|
|
this.userName = userName;
|
|
this.userCardNo = userCardNo;
|
|
this.cradNo = cradNo;
|
|
this.mobile = mobile;
|
|
this.mark = mark;
|
|
this.orderNum = orderNum;
|
|
this.campaignId = campaignId;
|
|
this.ActivityId = ActivityId;
|
|
this.fullName = fullName;
|
|
this.campanyId = campanyId;
|
|
this.IP = Ip;
|
|
this.CreateUser = createUser;
|
|
}
|
|
public void CheckUserName()
|
|
{
|
|
if (string.IsNullOrEmpty(this.userName))
|
|
throw new ArgumentException("用户名不能为空");
|
|
}
|
|
public void CheckcampaignId()
|
|
{
|
|
if (string.IsNullOrEmpty(this.campaignId))
|
|
throw new ArgumentException("渠道号不能为空");
|
|
}
|
|
public void Checkmobile()
|
|
{
|
|
if (string.IsNullOrEmpty(this.mobile))
|
|
throw new ArgumentException("手机号码不能为空");
|
|
}
|
|
public void CheckProduct()
|
|
{
|
|
if (string.IsNullOrEmpty(this.productCode))
|
|
throw new ArgumentException("产品编码不能为空");
|
|
}
|
|
public void CheckorderNum()
|
|
{
|
|
if (this.orderNum == 0)
|
|
throw new ArgumentException("开通套数不能0");
|
|
}
|
|
public returnOrderResult getResult()
|
|
{
|
|
try
|
|
{
|
|
string json = Utility.ConvertToJSON<AddOrderModel1>(this);
|
|
string url = Utility.GetSettingByKey("L2AddOrder");
|
|
returnOrderResult result = new returnOrderResult();
|
|
result = result.getResultObj(url, json);
|
|
result.type = "add";
|
|
result.userName = this.userName;
|
|
return result;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error("批量注册_下单" + ex.ToString());
|
|
returnOrderResult result = new returnOrderResult();
|
|
result.result = false;
|
|
result.type = "add";
|
|
result.userName = this.userName;
|
|
result.retcode = 10005;
|
|
return result;
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 开通订单
|
|
/// </summary>
|
|
public class OpenOrderModel1
|
|
{
|
|
public string ApplyOrderId { get; private set; }
|
|
|
|
public string UserName { get; private set; }
|
|
|
|
public string PayNo { get; private set; }
|
|
|
|
public decimal PayPrice { get; private set; }
|
|
|
|
public string PayType { get; private set; }
|
|
public string PayMark { get; private set; }
|
|
|
|
public string PayExt1 { get; private set; }
|
|
|
|
public string PayExt2 { get; private set; }
|
|
public OpenOrderModel1(string ApplyOrderId, string userName)
|
|
: this(ApplyOrderId, userName, "", 0, "", "", "", "")
|
|
{ }
|
|
public OpenOrderModel1(
|
|
string ApplyOrderId, string userName, string PayNo,
|
|
decimal PayPrice, string PayType, string PayMark,
|
|
string PayExt1, string PayExt2)
|
|
{
|
|
this.ApplyOrderId = ApplyOrderId;
|
|
this.UserName = userName;
|
|
this.PayNo = PayNo;
|
|
this.PayPrice = PayPrice;
|
|
this.PayType = PayType;
|
|
this.PayMark = PayMark;
|
|
this.PayExt1 = PayExt1;
|
|
this.PayExt2 = PayExt2;
|
|
}
|
|
public void CheckApplyOrderId()
|
|
{
|
|
if (string.IsNullOrEmpty(this.ApplyOrderId))
|
|
throw new ArgumentException("订单Id不能为空");
|
|
}
|
|
public returnOrderResult getResult()
|
|
{
|
|
try
|
|
{
|
|
string json = Utility.ConvertToJSON<OpenOrderModel1>(this);
|
|
string url = Utility.GetSettingByKey("L2OpenOrder");
|
|
returnOrderResult result = new returnOrderResult();
|
|
result = result.getResultObj(url, json);
|
|
result.type = "open";
|
|
result.userName = this.UserName;
|
|
return result;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error("批量注册_开通" + ex.ToString());
|
|
returnOrderResult result = new returnOrderResult();
|
|
result.result = false;
|
|
result.type = "open";
|
|
result.userName = this.UserName;
|
|
result.retcode = 10005;
|
|
return result;
|
|
}
|
|
}
|
|
}
|
|
|
|
public class returnOrderResult
|
|
{
|
|
public bool result { get; set; }
|
|
public int retcode { get; set; }
|
|
public string ApplyOrderId { get; set; }
|
|
public string userName { get; set; }
|
|
public string type { get; set; }
|
|
public returnOrderResult getResultObj(string url, string json)
|
|
{
|
|
ISecurityHelper sHelper = NinjectControllerFactory.ninjectKernel.Get<ISecurityHelper>();
|
|
string key = sHelper.createSignEncodingStr(json, SecurityHelper.OrderClientIdKey);
|
|
string response = Utility.PostData(url + "?" + key, Encoding.UTF8);
|
|
string _retmsg = sHelper.decyptData(SecurityHelper.OrderClientIdKey, response);
|
|
return Utility.JSONToObject<returnOrderResult>(_retmsg);
|
|
}
|
|
}
|
|
} |