Commit d598c14f authored by liudong1993's avatar liudong1993

1 同业积分兑换

parent 8d546a10
using VT.FW.DB;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Mall.Model.Entity.Customer
{
/// <summary>
/// 客户积分明细
/// </summary>
[Serializable]
[DB(ConnectionName = "CustomerConnection")]
public class RB_Customer_Integral
{
/// <summary>
/// Id
/// </summary>
public int Id { get; set; }
/// <summary>
/// 客户Id
/// </summary>
public int CustomerId { get; set; }
/// <summary>
/// 客户类型 1同行 2直客
/// </summary>
public int CustomerType { get; set; }
/// <summary>
/// 订单ID
/// </summary>
public int OrderId { get; set; }
/// <summary>
/// 来源类型 1团队订单 2电商订单
/// </summary>
public int OrderType { get; set; }
/// <summary>
/// 变更金额(正负数 表示 增加 减少)
/// </summary>
public decimal IntegralNum { get; set; }
/// <summary>
/// 描述
/// </summary>
public string Description { get; set; }
/// <summary>
/// 集团ID
/// </summary>
public int GroupId { get; set; }
/// <summary>
/// 订单积分生成时间
/// </summary>
public DateTime CreateTime { get; set; }
/// <summary>
/// 归属团
/// </summary>
public int TCID { get; set; }
/// <summary>
/// 是否抵用 1是
/// </summary>
public int IsDeduction { get; set; }
/// <summary>
/// 同业员工ID
/// </summary>
public int CustomerChildrenId { get; set; }
/// <summary>
/// 总返佣金额
/// </summary>
public decimal MallCommission { get; set; }
}
}
......@@ -269,5 +269,15 @@ namespace Mall.Model.Entity.User
/// UnionId唯一Id
/// </summary>
public string Unoinid { get; set; }
/// <summary>
/// 绑定同业ID
/// </summary>
public int CustomerId { get; set; }
/// <summary>
/// 绑定同业员工ID
/// </summary>
public int CustomerChildrenId { get; set; }
}
}
using VT.FW.DB;
using System;
namespace Mall.Model.Extend.Customer
{
/// <summary>
/// 客户积分扩展表
/// </summary>
[Serializable]
[DB(ConnectionName = "CustomerConnection")]
public class RB_Customer_Integral_Extend : Entity.Customer.RB_Customer_Integral
{
/// <summary>
/// 积分状态 0自己的可用 1同行下通用 2不可用
/// </summary>
public int IntegralUse { get; set; }
/// <summary>
/// 类型 1收 2支
/// </summary>
public int Type { get; set; }
/// <summary>
/// 门店名称
/// </summary>
public string CustomerName { get; set; }
/// <summary>
/// 联系人
/// </summary>
public string ContactName { get; set; }
}
}
......@@ -110,5 +110,15 @@ namespace Mall.Model.Extend.User
/// 是否直接下级[1-是]
/// </summary>
public int IsDirect { get; set; }
/// <summary>
/// 同业联系人
/// </summary>
public int CustomerChildrenId { get; set; }
/// <summary>
/// 联系人名称
/// </summary>
public string CustomerChildrenName { get; set; }
}
}
......@@ -225,6 +225,11 @@ namespace Mall.Model.Extend.User
/// 用户可查看分组
/// </summary>
public List<GroupItem> LookGroupList { get; set; }
/// <summary>
/// 绑定同业OpenId
/// </summary>
public string CustomerOpenId { get; set; }
}
/// <summary>
......
This diff is collapsed.
This diff is collapsed.
using Mall.Common.Plugin;
using Mall.Model.Extend.Product;
using Mall.Model.Extend.User;
using Mall.Repository.Customer;
using Mall.Repository.Product;
using Mall.Repository.User;
using System;
......@@ -31,6 +32,22 @@ namespace Mall.Module.User
/// 售后订单
/// </summary>
private readonly RB_Goods_OrderAfterSaleRepository goods_OrderAfterSaleRepository = new RB_Goods_OrderAfterSaleRepository();
/// <summary>
/// 同业客户积分
/// </summary>
private readonly RB_Customer_IntegralRepository customer_IntegralRepository = new RB_Customer_IntegralRepository();
/// <summary>
/// 会员积分
/// </summary>
private readonly RB_Member_IntegralRepository member_IntegralRepository = new RB_Member_IntegralRepository();
/// <summary>
/// 分销商
/// </summary>
private readonly RB_Distributor_InfoRepository distributor_InfoRepository = new RB_Distributor_InfoRepository();
/// <summary>
/// 分销商日志
/// </summary>
private readonly RB_Distributor_LogRepository distributor_LogRepository = new RB_Distributor_LogRepository();
/// <summary>
......@@ -60,6 +77,93 @@ namespace Mall.Module.User
return member_UserRepository.Update(fileds, new WhereHelper(nameof(RB_Member_User_Extend.Id), extModel.Id));
}
/// <summary>
/// 绑定同业
/// </summary>
/// <param name="extModel"></param>
/// <returns></returns>
public bool SetMemberBindCustomer(RB_Member_User_Extend extModel) {
var userModel = member_UserRepository.GetEntity(extModel.Id);
if (userModel == null || userModel.CustomerId > 0) { return true; }
//根据OpenID 反查询 CustomerId
var CustomerModel = customer_IntegralRepository.GetCustomerToOpenId(extModel.CustomerOpenId);
if (CustomerModel == null) { return false; }
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{ nameof(RB_Member_User_Extend.CustomerId),CustomerModel.CustomerId},
{ nameof(RB_Member_User_Extend.CustomerChildrenId),CustomerModel.CustomerChildrenId},
};
bool flag = member_UserRepository.Update(fileds, new WhereHelper(nameof(RB_Member_User_Extend.Id), extModel.Id));
if (flag) {
var distModel = distributor_InfoRepository.GetList(new RB_Distributor_Info_Extend() { UserId = userModel.Id }).FirstOrDefault();
if (distModel != null) {
if (distModel.FXGradeId <= 2) {
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Distributor_Info_Extend.FXGradeId),3},
{ nameof(RB_Distributor_Info_Extend.UpdateDate),DateTime.Now}
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Distributor_Info_Extend.Id),
FiledValue=distModel.Id,
OperatorEnum=OperatorEnum.Equal
}
};
bool flag2 = distributor_InfoRepository.Update(keyValues, wheres);
if (flag2)
{
//记录日志
distributor_LogRepository.Insert(new Model.Entity.User.RB_Distributor_Log()
{
Content = "同行绑定赞羊,初始化分销商等级为:旅享家",
CreateDate = DateTime.Now,
EmpId = 0,
Id = 0,
MallBaseId = 1,
TenantId = 1,
Type = 1,
UserId = userModel.Id
});
}
}
}
}
//因为存在 一个同行 下有多个 联系人的情况,
//if (flag) {
// //开始初始化 积分数据
// var list = customer_IntegralRepository.GetList(new Model.Extend.Customer.RB_Customer_Integral_Extend() { OrderType = 1, CustomerId = CustomerId });
// if (list.Any())
// {
// foreach (var item in list)
// {
// member_IntegralRepository.Insert(new Model.Entity.User.RB_Member_Integral()
// {
// Id = 0,
// Image = 0,
// Type = item.IntegralNum > 0 ? Common.Enum.MarketingCenter.RecordTypeEnum.Income : Common.Enum.MarketingCenter.RecordTypeEnum.Expend,
// Integral = Math.Abs(Convert.ToInt32(item.IntegralNum)),
// CreateDate = item.CreateTime,
// MallBaseId = extModel.MallBaseId,
// TenantId = extModel.TenantId,
// OrderId = item.OrderId,
// PlatformType = Common.Enum.User.UserSourceEnum.ERP,
// UserId = extModel.Id,
// Description = item.Description,
// Remarks = ""
// });
// }
// Dictionary<string, object> fileds2 = new Dictionary<string, object>()
// {
// { nameof(RB_Member_User_Extend.Integral),list.Sum(x=>x.IntegralNum)},
// };
// member_UserRepository.Update(fileds, new WhereHelper(nameof(RB_Member_User_Extend.Id), extModel.Id));
// }
//}
return flag;
}
#region 小程序管理端-消息提醒
/// <summary>
......
......@@ -6,7 +6,6 @@ using Mall.Common;
using Mall.Common.Plugin;
using Mall.Model.Entity.User;
using Mall.Model.Extend.User;
using Mall.Repository;
using Mall.Repository.User;
using Mall.Repository.Product;
using Mall.Model.Extend.Product;
......@@ -17,12 +16,11 @@ using Mall.Repository.BaseSetUp;
using Mall.Common.Enum.User;
using Mall.Common.API;
using Newtonsoft.Json.Linq;
using System.Threading;
using Mall.Repository.Finance;
using NPOI.SS.Formula.Functions;
using VT.FW.DB;
using Mall.Repository.Miai;
using System.IO;
using Mall.Repository.Customer;
namespace Mall.Module.User
{
......@@ -40,7 +38,10 @@ namespace Mall.Module.User
/// 用户管理
/// </summary>
private readonly RB_Member_UserRepository2 member_UserRepository2 = new RB_Member_UserRepository2();
/// <summary>
/// ERP 同业积分
/// </summary>
private readonly RB_Customer_IntegralRepository customer_IntegralRepository = new RB_Customer_IntegralRepository();
/// <summary>
/// 会员等级
/// </summary>
......@@ -238,6 +239,13 @@ namespace Mall.Module.User
var gradeIds = string.Join(",", list.Where(x => x.MemberGrade > 0).Select(x => x.MemberGrade ?? 0));
gradeList = member_GradeRepository.GetList(new RB_Member_Grade_Extend() { GradeIds = gradeIds, TenantId = dmodel.TenantId, MallBaseId = dmodel.MallBaseId });
}
#region 查询绑定 同业联系人
List<Model.Extend.Customer.RB_Customer_Integral_Extend> CustomerList = new List<Model.Extend.Customer.RB_Customer_Integral_Extend>();
if (list.Any(x => x.CustomerChildrenId > 0))
{
CustomerList = customer_IntegralRepository.GetCustomerInfoList(string.Join(",", list.Where(x => x.CustomerChildrenId > 0).Select(x => x.CustomerChildrenId)));
}
#endregion
foreach (var item in list)
{
if (item.MemberGrade > 0)
......@@ -248,6 +256,12 @@ namespace Mall.Module.User
{
item.MemberGradeName = "普通会员";
}
if (item.CustomerChildrenId > 0)
{
string CustomerChildrenName = CustomerList.Where(x => x.CustomerChildrenId == item.CustomerChildrenId)?.Select(x => x.CustomerName + "/" + x.ContactName)?.FirstOrDefault() ?? "";
item.Name += "【" + CustomerChildrenName + "】";
}
}
}
return list;
......@@ -939,7 +953,27 @@ namespace Mall.Module.User
/// <returns></returns>
public List<RB_Member_Integral_Extend> GetMemberIntegralPageList(int pageIndex, int pageSize, out long count, RB_Member_Integral_Extend demodel)
{
return member_IntegralRepository.GetPageList(pageIndex, pageSize, out count, demodel);
var umodel = member_UserRepository.GetEntity(demodel.UserId);
if (demodel.MallBaseId == 1 && umodel != null && umodel.CustomerChildrenId > 0)
{
count = 0;
var imodel = customer_IntegralRepository.GetCustomerInfo(umodel.CustomerChildrenId);
if (imodel == null || imodel.IntegralUse == 2) { return new List<RB_Member_Integral_Extend>(); }
//查询erp同业积分
var list = customer_IntegralRepository.GetPageList(pageIndex, pageSize, out count, new Model.Extend.Customer.RB_Customer_Integral_Extend() { CustomerId = imodel.CustomerId, CustomerChildrenId = imodel.IntegralUse == 0 ? imodel.CustomerChildrenId : 0, Type = (int)demodel.Type });
return list.Select(x => new RB_Member_Integral_Extend()
{
Remarks = "",
Description = x.Description,
CreateDate = x.CreateTime,
Integral = Convert.ToInt32(Math.Abs(x.IntegralNum)),
Type = x.IntegralNum > 0 ? Common.Enum.MarketingCenter.RecordTypeEnum.Income : Common.Enum.MarketingCenter.RecordTypeEnum.Expend
}).ToList();
}
else
{
return member_IntegralRepository.GetPageList(pageIndex, pageSize, out count, demodel);
}
}
/// <summary>
......@@ -1504,6 +1538,13 @@ namespace Mall.Module.User
List<RB_Member_User_Extend> UserNum2List = member_UserRepository.GetDistributorReferralsNum(uids, tier: 2, tenantId: demodel.TenantId, mallBaseId: demodel.MallBaseId);//直接查询三级
List<RB_Member_User_Extend> UserNum3List = member_UserRepository.GetDistributorReferralsNum(uids, tier: 3, tenantId: demodel.TenantId, mallBaseId: demodel.MallBaseId);//直接查询三级
#region 查询绑定 同业联系人
List<Model.Extend.Customer.RB_Customer_Integral_Extend> CustomerList = new List<Model.Extend.Customer.RB_Customer_Integral_Extend>();
if (list.Any(x => x.CustomerChildrenId > 0)) {
CustomerList = customer_IntegralRepository.GetCustomerInfoList(string.Join(",", list.Where(x => x.CustomerChildrenId > 0).Select(x => x.CustomerChildrenId)));
}
#endregion
foreach (var item in list)
{
if (item.GradeId == 0)
......@@ -1556,6 +1597,11 @@ namespace Mall.Module.User
{
item.ThreeNum = UserNum3List.Where(x => x.SuperiorId == item.UserId).FirstOrDefault()?.ReferralsNum ?? 0;
}
if (item.CustomerChildrenId > 0) {
item.CustomerChildrenName = CustomerList.Where(x => x.CustomerChildrenId == item.CustomerChildrenId)?.Select(x => x.CustomerName + "/" + x.ContactName)?.FirstOrDefault() ?? "";
item.NickName += "【" + item.CustomerChildrenName + "】";
}
}
}
......@@ -4853,6 +4899,18 @@ namespace Mall.Module.User
}
#endregion
#region 同业积分处理
if (umodel.CustomerId > 0 && umodel.CustomerChildrenId>0)
{
//查询ERP 其账号是否可以积分兑换
var cmodel = customer_IntegralRepository.GetCustomerInfo(umodel.CustomerChildrenId);
if (cmodel != null && cmodel.IntegralUse!=2) {
decimal erpIntergral = customer_IntegralRepository.GetCustomerIntegralSurplus(umodel.CustomerId, cmodel.IntegralUse == 0 ? umodel.CustomerChildrenId : 0);
umodel.Integral = Convert.ToInt32(erpIntergral);
}
}
#endregion
objData = new
{
//孵化公司
......
using Mall.Model.Entity.Customer;
using Mall.Model.Extend.Customer;
using Mall.Model.Extend.User;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Mall.Repository.Customer
{
/// <summary>
/// 客人积分明细仓储类
/// </summary>
public class RB_Customer_IntegralRepository : BaseRepository<RB_Customer_Integral>
{
/// <summary>
/// 获取列表
/// </summary>
/// <param name="demodel"></param>
/// <returns></returns>
public List<RB_Customer_Integral_Extend> GetList(RB_Customer_Integral_Extend demodel)
{
string where = " 1=1 ";
if (demodel.GroupId > 0)
{
where += $@" and {nameof(RB_Customer_Integral_Extend.GroupId)} ={demodel.GroupId}";
}
if (demodel.OrderId > 0)
{
where += $@" and {nameof(RB_Customer_Integral_Extend.OrderId)} ={demodel.OrderId}";
}
if (demodel.OrderType > 0)
{
where += $@" and {nameof(RB_Customer_Integral_Extend.OrderType)} ={demodel.OrderType}";
}
if (demodel.CustomerId > 0)
{
where += $@" and {nameof(RB_Customer_Integral_Extend.CustomerId)} ={demodel.CustomerId}";
}
if (demodel.CustomerType > 0)
{
where += $@" and {nameof(RB_Customer_Integral_Extend.CustomerType)} ={demodel.CustomerType}";
}
if (demodel.TCID > 0)
{
where += $@" and {nameof(RB_Customer_Integral_Extend.TCID)} ={demodel.TCID}";
}
string sql = $@"select * from RB_Customer_Integral where {where} order by Id desc";
return Get<RB_Customer_Integral_Extend>(sql).ToList();
}
/// <summary>
/// 获取分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="count"></param>
/// <param name="demodel"></param>
/// <returns></returns>
public List<RB_Customer_Integral_Extend> GetPageList(int pageIndex, int pageSize, out long count, RB_Customer_Integral_Extend demodel)
{
string where = " 1=1 ";
if (demodel.GroupId > 0)
{
where += $@" and {nameof(RB_Customer_Integral_Extend.GroupId)} ={demodel.GroupId}";
}
if (demodel.OrderId > 0)
{
where += $@" and {nameof(RB_Customer_Integral_Extend.OrderId)} ={demodel.OrderId}";
}
if (demodel.OrderType > 0)
{
where += $@" and {nameof(RB_Customer_Integral_Extend.OrderType)} ={demodel.OrderType}";
}
if (demodel.CustomerId > 0)
{
where += $@" and {nameof(RB_Customer_Integral_Extend.CustomerId)} ={demodel.CustomerId}";
}
if (demodel.CustomerChildrenId > 0)
{
where += $@" and {nameof(RB_Customer_Integral_Extend.CustomerChildrenId)} ={demodel.CustomerChildrenId}";
}
if (demodel.Type == 1)
{
where += $@" and {nameof(RB_Customer_Integral_Extend.IntegralNum)} >0";
}
else if (demodel.Type == 2)
{
where += $@" and {nameof(RB_Customer_Integral_Extend.IntegralNum)} <=0";
}
string sql = $@"select * from RB_Customer_Integral where {where} order by Id desc";
return GetPage<RB_Customer_Integral_Extend>(pageIndex, pageSize, out count, sql).ToList();
}
/// <summary>
/// 获取积分余额
/// </summary>
/// <param name="customerId"></param>
/// <param name="customerChildrenId"></param>
/// <returns></returns>
public decimal GetCustomerIntegralSurplus(int customerId, int customerChildrenId) {
string sql = $@"SELECT SUM(IntegralNum) FROM rb_customer_integral i WHERE CustomerId ={customerId} {(customerChildrenId > 0 ? "and CustomerChildrenId=" + customerChildrenId : "")}";
var obj = ExecuteScalar(sql);
return obj == null ? 0 : Convert.ToDecimal(obj);
}
/// <summary>
/// 获取同业客户ID 通过 OpenId
/// </summary>
/// <param name="OpenId"></param>
/// <returns></returns>
public RB_Customer_Integral_Extend GetCustomerToOpenId(string OpenId) {
string sql = $@" SELECT InfoID CustomerId,ID as CustomerChildrenId FROM rb_customer_infochildren WHERE OpenId ='{OpenId}'";
return Get<RB_Customer_Integral_Extend>(sql).FirstOrDefault();
}
/// <summary>
/// 获取同行员工信息
/// </summary>
/// <param name="CustomerChildrenId"></param>
/// <returns></returns>
public RB_Customer_Integral_Extend GetCustomerInfo(int CustomerChildrenId) {
string sql = $@" select InfoID as CustomerId,ID as CustomerChildrenId,IntegralUse from rb_customer_infochildren where ID ={CustomerChildrenId}";
return Get<RB_Customer_Integral_Extend>(sql).FirstOrDefault();
}
/// <summary>
/// 更新erp同业积分余额
/// </summary>
/// <param name="customerId"></param>
/// <param name="totalIntegralNumber"></param>
public void UpdateCustomerIntegral(int customerId, int totalIntegralNumber)
{
string sql = $@"update rb_customer_info set Integral=Integral-{totalIntegralNumber} where CustomerId={customerId}";
Execute(sql);
}
/// <summary>
/// 获取联系人信息
/// </summary>
/// <param name="customerChildrenIds"></param>
/// <returns></returns>
public List<RB_Customer_Integral_Extend> GetCustomerInfoList(string customerChildrenIds) {
string sql = $@"SELECT c.ID as CustomerChildrenId,i.CustomerId,c.ContactName,i.CustomerName FROM rb_customer_infochildren c
left join rb_customer_info i on c.InfoID =i.CustomerId
WHERE c.ID in({customerChildrenIds})";
return Get<RB_Customer_Integral_Extend>(sql).ToList();
}
}
}
......@@ -65,7 +65,7 @@ namespace Mall.Repository.User
where += $@" and u.{nameof(RB_Member_User.SuperiorId)}={dmodel.SuperiorId}";
}
string sql = $@"select di.*,u.Name as NickName,u.SuperiorId,u.Photo,u.Source from RB_Distributor_Info di
string sql = $@"select di.*,u.Name as NickName,u.SuperiorId,u.Photo,u.Source,u.CustomerChildrenId from RB_Distributor_Info di
inner join rb_member_user u on di.UserId=u.Id
where {where} order by di.CreateDate desc";
return GetPage<RB_Distributor_Info_Extend>(pageIndex, pageSize, out rowCount, sql).ToList();
......
......@@ -555,7 +555,7 @@ namespace Mall.WebApi.Controllers.MallBase
//进阶小课堂价格可以为0 hk 2022-11-01修改
if (demodel.TenantId != 27)
{
if (((demodel.Income ?? 0) + ((demodel.DepositMoney))) <= 0)
if (((demodel.Income ?? 0) + demodel.DepositMoney) <= 0 && (demodel.Use_Integral ?? 0) != 1)
{
return ApiResult.ParamIsNull("订单金额不正确");
}
......
......@@ -93,6 +93,7 @@ namespace Mall.WebApi.Controllers.User
EduSchoolId = parms.GetInt("EduSchoolId", 0),
IsShow = 1,
LookTimes = 5,
CustomerId = parms.GetInt("CustomerId")
};
int EduId = parms.GetInt("EduId");//用于教育绑定用户 2022-03-15
if (requestParm.TenantId <= 0)
......
......@@ -69,6 +69,25 @@ namespace Mall.WebApi.Controllers.User
}
}
/// <summary>
/// 绑定同业
/// </summary>
/// <returns></returns>
[RateValve(Policy = Policy.Ip, Limit = 20, Duration = 60)]
[HttpPost]
public ApiResult SetMemberBindCustomer() {
JObject jobj = JObject.Parse(RequestParm.msg.ToString());
var extModel = new RB_Member_User_Extend()
{
Id = jobj.GetInt("Id"),
CustomerOpenId = jobj.GetStringValue("CustomerOpenId")
};
extModel.TenantId = RequestParm.TenantId;
extModel.MallBaseId = RequestParm.MallBaseId;
bool flag = MemberUserModule.SetMemberBindCustomer(extModel);
return flag ? ApiResult.Success() : ApiResult.Failed();
}
/// <summary>
/// 更改用户的手机号码 add by:W 2020-10-28
/// </summary>
......
......@@ -11,7 +11,9 @@
"EduConnection": "server=192.168.5.214;user id=reborn;password=Reborn@2018;database=reborn_edu;CharSet=utf8mb4; Convert Zero Datetime=true; ",
"EduConnectionPName": "MySql.Data.MySqlClient",
"ThinkConnection": "server=192.168.5.214;user id=reborn;password=Reborn@2018;database=reborn_think;CharSet=utf8mb4; Convert Zero Datetime=true; ",
"ThinkConnectionPName": "MySql.Data.MySqlClient"
"ThinkConnectionPName": "MySql.Data.MySqlClient",
"CustomerConnection": "server=192.168.5.214;user id=reborn;password=Reborn@2018;database=reborn_sell;CharSet=utf8mb4; Convert Zero Datetime=true; ",
"CustomerConnectionPName": "MySql.Data.MySqlClient"
},
"Logging": {
"LogLevel": {
......
......@@ -15,6 +15,7 @@ using Mall.Model.Extend.User;
using Mall.Module.User;
using Mall.Repository;
using Mall.Repository.BaseSetUp;
using Mall.Repository.Customer;
using Mall.Repository.Education;
using Mall.Repository.Finance;
using Mall.Repository.Product;
......@@ -77,6 +78,10 @@ namespace Mall.WindowsService.Module
/// </summary>
private static RB_Member_UserRepository member_UserRepository = new RB_Member_UserRepository();
/// <summary>
/// erp同业积分
/// </summary>
private static RB_Customer_IntegralRepository customer_IntegralRepository = new RB_Customer_IntegralRepository();
/// <summary>
/// 用户积分
/// </summary>
private static RB_Member_IntegralRepository member_IntegralRepository = new RB_Member_IntegralRepository();
......@@ -883,34 +888,63 @@ and DATE_FORMAT(a.PayTime,'%y-%m-%d')<DATE_FORMAT('{endDate}','%y-%m-%d') AND a
//积分抵扣回滚
if (TotalIntegralNumber > 0)
{
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
if (umodel.CustomerChildrenId > 0)
{
//进入erp同业积分更新
try
{
customer_IntegralRepository.Insert(new Model.Entity.Customer.RB_Customer_Integral()
{
Id = 0,
CustomerId = umodel.CustomerId,
CustomerChildrenId = umodel.CustomerChildrenId,
GroupId = 2,
OrderId = qitem.OrderId,
TCID = 0,
OrderType = 2,
IsDeduction = 1,
IntegralNum = TotalIntegralNumber,
CreateTime = DateTime.Now,
CustomerType = 1,
Description = "赞羊订单取消返回积分抵扣,订单号:" + qitem.OrderNo,
MallCommission = 0 - detailList.Sum(x => x.FXCommission)
});
//更新同行积分数
customer_IntegralRepository.UpdateCustomerIntegral(umodel.CustomerId, 0 - TotalIntegralNumber);
}
catch { }
}
else
{
Dictionary<string, object> keyValues1 = new Dictionary<string, object>() {
{ nameof(RB_Member_User_Extend.Integral),umodel.Integral + TotalIntegralNumber}
};
List<WhereHelper> wheres1 = new List<WhereHelper>() {
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Member_User_Extend.Id),
FiledValue=umodel.Id,
OperatorEnum=OperatorEnum.Equal
}
};
bool flag2 = member_UserRepository.Update(keyValues1, wheres1);
if (flag2)
{
member_IntegralRepository.Insert(new Mall.Model.Entity.User.RB_Member_Integral()
bool flag2 = member_UserRepository.Update(keyValues1, wheres1);
if (flag2)
{
Id = 0,
CreateDate = DateTime.Now,
Description = "订单取消返回积分抵扣,订单号:" + qitem.OrderNo,
Image = 0,
Integral = TotalIntegralNumber,
MallBaseId = item.MallBaseId,
PlatformType = qitem.OrderSource,
Remarks = "",
TenantId = item.TenantId,
Type = Common.Enum.MarketingCenter.RecordTypeEnum.Income,
UserId = qitem.UserId,
OrderId = qitem.OrderId
});
member_IntegralRepository.Insert(new Mall.Model.Entity.User.RB_Member_Integral()
{
Id = 0,
CreateDate = DateTime.Now,
Description = "订单取消返回积分抵扣,订单号:" + qitem.OrderNo,
Image = 0,
Integral = TotalIntegralNumber,
MallBaseId = item.MallBaseId,
PlatformType = qitem.OrderSource,
Remarks = "",
TenantId = item.TenantId,
Type = Common.Enum.MarketingCenter.RecordTypeEnum.Income,
UserId = qitem.UserId,
OrderId = qitem.OrderId
});
}
}
}
//优惠券回滚
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment