Commit 029e3439 authored by liudong1993's avatar liudong1993

资产代码copy

parent 0803a34d
using System;
using Mall.Common.AOP;
using Mall.Common.Plugin;
namespace Mall.Model.Entity.Property
{
/// <summary>
/// 耗材档案实体
/// </summary>
[Serializable]
[DB(ConnectionName = "PropertyConnection")]
public class RB_Supplies_Material
{
/// <summary>
/// rId
/// </summary>
public int Id
{
get;
set;
}
/// <summary>
/// 物料名称
/// </summary>
public string Name
{
get;
set;
}
/// <summary>
/// 物料编码
/// </summary>
public string SuppliesNum
{
get;
set;
}
/// <summary>
/// 分类id
/// </summary>
public int? CategoryId
{
get;
set;
}
/// <summary>
/// 品牌
/// </summary>
public string BrandName
{
get;
set;
}
/// <summary>
/// 型号
/// </summary>
public string SuppliesModel
{
get;
set;
}
/// <summary>
/// 库存单位
/// </summary>
public string Units
{
get;
set;
}
/// <summary>
/// 金额
/// </summary>
public decimal? Money
{
get;
set;
}
/// <summary>
/// 安全库存
/// </summary>
public int? SafetyStock
{
get;
set;
}
/// <summary>
/// 预留库存
/// </summary>
public int? ReservedStock
{
get;
set;
}
/// <summary>
/// 条形码号
/// </summary>
public string Barcode
{
get;
set;
}
/// <summary>
/// 供应商名称
/// </summary>
public string SupplierName
{
get;
set;
}
/// <summary>
/// 物料图片
/// </summary>
public string Images
{
get;
set;
}
/// <summary>
/// 备注
/// </summary>
public string Remark
{
get;
set;
}
/// <summary>
/// 状态 0 正常 1删除
/// </summary>
public int? Status
{
get;
set;
}
/// <summary>
/// 公司
/// </summary>
public int? RB_Branch_Id
{
get;
set;
}
/// <summary>
/// 集团
/// </summary>
public int? RB_Group_Id
{
get;
set;
}
/// <summary>
/// CreateBy
/// </summary>
public int? CreateBy
{
get;
set;
}
/// <summary>
/// CreateDate
/// </summary>
public DateTime? CreateDate
{
get;
set;
}
/// <summary>
/// UpdateBy
/// </summary>
public int? UpdateBy
{
get;
set;
}
/// <summary>
/// UpdateDate
/// </summary>
public DateTime? UpdateDate
{
get;
set;
}
}
}
\ No newline at end of file
using System;
using Mall.Common.AOP;
using Mall.Common.Plugin;
namespace Mall.Model.Entity.Property
{
/// <summary>
/// 耗材仓库实体
/// </summary>
[Serializable]
[DB(ConnectionName = "PropertyConnection")]
public class RB_Supplies_WareHouse
{
/// <summary>
/// Id
/// </summary>
public int Id
{
get;
set;
}
/// <summary>
/// 仓库名称
/// </summary>
public string Name
{
get;
set;
}
/// <summary>
/// 状态 0正常 1删除
/// </summary>
public int? Status
{
get;
set;
}
/// <summary>
/// 公司
/// </summary>
public int? RB_Branch_Id
{
get;
set;
}
/// <summary>
/// 集团
/// </summary>
public int? RB_Group_Id
{
get;
set;
}
/// <summary>
/// CreateBy
/// </summary>
public int? CreateBy
{
get;
set;
}
/// <summary>
/// CreateDate
/// </summary>
public DateTime? CreateDate
{
get;
set;
}
/// <summary>
/// UpdateBy
/// </summary>
public int? UpdateBy
{
get;
set;
}
/// <summary>
/// UpdateDate
/// </summary>
public DateTime? UpdateDate
{
get;
set;
}
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using Mall.Model.Entity.Property;
using Mall.Common.AOP;
namespace Mall.Model.Extend.Property
{
/// <summary>
/// 耗材档案扩展实体
/// </summary>
[Serializable]
[DB(ConnectionName = "PropertyConnection")]
public class RB_Supplies_Material_Extend : RB_Supplies_Material
{
/// <summary>
/// 分类名称
/// </summary>
public string CategoryName
{
get;
set;
}
/// <summary>
/// 图片列表
/// </summary>
public List<string> ImageList { get; set; }
/// <summary>
/// 仓库id
/// </summary>
public int? WareHouseId { get; set; }
/// <summary>
/// 库存数量
/// </summary>
public int? InventoryNum { get; set; }
/// <summary>
/// 档案ids
/// </summary>
public string SuppliesIdStr { get; set; }
}
}
\ No newline at end of file
using System;
using Mall.Model.Entity.Property;
using Mall.Common.AOP;
namespace Mall.Model.Extend.Property
{
/// <summary>
/// IJIJֿչʵ
/// </summary>
[Serializable]
[DB(ConnectionName = "PropertyConnection")]
public class RB_Supplies_WareHouse_Extend : RB_Supplies_WareHouse
{
/// <summary>
/// ֿids
/// </summary>
public string WareHouseIdStr { get; set; }
}
}
\ No newline at end of file
using Mall.Model.Entity.Property;
using Mall.Model.Extend.Property;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Mall.Repository.Property
{
/// <summary>
/// 耗材档案仓储类
/// </summary>
public partial class RB_Supplies_MaterialRepository : RepositoryBase<RB_Supplies_Material>
{
/// <summary>
/// 获取耗材分页数据
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="dmodel"></param>
/// <param name="count"></param>
/// <returns></returns>
public List<RB_Supplies_Material_Extend> GetPageList(int pageIndex, int pageSize, RB_Supplies_Material_Extend dmodel, out long count)
{
string where = " where 1=1 ";
where += string.Format(" AND sm.{0}={1}", nameof(RB_Supplies_Material_Extend.Status), 0);
where += $@" and sm.RB_Group_Id={dmodel.RB_Group_Id}";
if (!string.IsNullOrWhiteSpace(dmodel.Name.Trim()))
{
where += " and sm." + nameof(RB_Supplies_Material_Extend.Name) + " like '%" + dmodel.Name.Trim() + "%'";
}
if (!string.IsNullOrWhiteSpace(dmodel.SuppliesNum.Trim()))
{
where += " and sm." + nameof(RB_Supplies_Material_Extend.SuppliesNum) + " like '%" + dmodel.SuppliesNum.Trim() + "%'";
}
if (!string.IsNullOrWhiteSpace(dmodel.BrandName.Trim()))
{
where += " and sm." + nameof(RB_Supplies_Material_Extend.BrandName) + " like '%" + dmodel.BrandName.Trim() + "%'";
}
if (!string.IsNullOrWhiteSpace(dmodel.SupplierName.Trim()))
{
where += " and sm." + nameof(RB_Supplies_Material_Extend.SupplierName) + " like '%" + dmodel.SupplierName.Trim() + "%'";
}
if (dmodel.CategoryId > 0) {
where += " and sm." + nameof(RB_Supplies_Material_Extend.CategoryId) + "=" + dmodel.CategoryId;
}
string sql = $@" select sm.*,pc.Name as CategoryName from RB_Supplies_Material sm
left join rb_property_category pc on sm.CategoryId=pc.Id
{where} order by sm.Id desc";
return GetPage<RB_Supplies_Material_Extend>(pageIndex, pageSize, out count, sql).ToList();
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<RB_Supplies_Material_Extend> GetList(RB_Supplies_Material_Extend dmodel)
{
string where = " where 1=1 ";
where += string.Format(" AND sm.{0}={1}", nameof(RB_Supplies_Material_Extend.Status), 0);
where += $@" and sm.RB_Group_Id={dmodel.RB_Group_Id}";
if (!string.IsNullOrWhiteSpace(dmodel.Name))
{
where += " and sm." + nameof(RB_Supplies_Material_Extend.Name) + " like '%" + dmodel.Name + "%'";
}
if (!string.IsNullOrWhiteSpace(dmodel.SuppliesNum))
{
where += " and sm." + nameof(RB_Supplies_Material_Extend.SuppliesNum) + " like '%" + dmodel.SuppliesNum + "%'";
}
if (!string.IsNullOrWhiteSpace(dmodel.BrandName))
{
where += " and sm." + nameof(RB_Supplies_Material_Extend.BrandName) + " like '%" + dmodel.BrandName + "%'";
}
if (!string.IsNullOrWhiteSpace(dmodel.SupplierName))
{
where += " and sm." + nameof(RB_Supplies_Material_Extend.SupplierName) + " like '%" + dmodel.SupplierName + "%'";
}
if (dmodel.CategoryId > 0)
{
where += " and sm." + nameof(RB_Supplies_Material_Extend.CategoryId) + "=" + dmodel.CategoryId;
}
if (!string.IsNullOrEmpty(dmodel.SuppliesIdStr)) {
where += " and sm." + nameof(RB_Supplies_Material_Extend.Id) + " in(" + dmodel.SuppliesIdStr + ")";
}
string sql = $@" select sm.*,pc.Name as CategoryName from RB_Supplies_Material sm
left join rb_property_category pc on sm.CategoryId=pc.Id
{where} order by sm.Id desc";
return Get<RB_Supplies_Material_Extend>(sql).ToList();
}
}
}
using Mall.Model.Entity.Property;
using Mall.Model.Extend.Property;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Mall.Repository.Property
{
/// <summary>
/// 耗材仓库仓储类
/// </summary>
public partial class RB_Supplies_WareHouseRepository : RepositoryBase<RB_Supplies_WareHouse>
{
/// <summary>
/// 获取耗材仓库分页数据
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="dmodel"></param>
/// <param name="count"></param>
/// <returns></returns>
public List<RB_Supplies_WareHouse_Extend> GetPageList(int pageIndex, int pageSize, RB_Supplies_WareHouse_Extend dmodel, out long count)
{
string where = " where 1=1 ";
where += string.Format(" AND {0}={1}", nameof(RB_Supplies_WareHouse_Extend.Status), 0);
where += $@" and RB_Group_Id={dmodel.RB_Group_Id}";
if (!string.IsNullOrWhiteSpace(dmodel.Name.Trim()))
{
where += " and " + nameof(RB_Supplies_WareHouse_Extend.Name) + " like '%" + dmodel.Name.Trim() + "%'";
}
string sql = $@" select * from RB_Supplies_WareHouse {where} order by Id desc";
return GetPage<RB_Supplies_WareHouse_Extend>(pageIndex, pageSize, out count, sql).ToList();
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="dmodel"></param>
/// <returns></returns>
public List<RB_Supplies_WareHouse_Extend> GetList(RB_Supplies_WareHouse_Extend dmodel)
{
string where = " where 1=1 ";
where += string.Format(" AND {0}={1}", nameof(RB_Supplies_WareHouse_Extend.Status), 0);
where += $@" and RB_Group_Id={dmodel.RB_Group_Id}";
if (!string.IsNullOrWhiteSpace(dmodel.Name))
{
where += " and " + nameof(RB_Supplies_WareHouse_Extend.Name) + " like '%" + dmodel.Name + "%'";
}
if (!string.IsNullOrEmpty(dmodel.WareHouseIdStr)) {
where += $@" and {nameof(RB_Supplies_WareHouse.Id)} in ({dmodel.WareHouseIdStr})";
}
string sql = $@" select * from RB_Supplies_WareHouse {where} order by Id desc";
return Get<RB_Supplies_WareHouse_Extend>(sql).ToList();
}
}
}
......@@ -209,7 +209,57 @@ AND o.UserId in(
SELECT Id FROM rb_member_user WHERE SuperiorId BETWEEN 1 and 20
) AND o.UserId <> 39370
ORDER BY o.OrderId ASC ";
string commSql2 = $@"SELECT o.OrderId,o.OrderNo,od.Id AS DetailId,o.UserId,u.`Name`,o.Income,o.Consignee,o.Mobile,o.ShoppingAddress,od.GoodsName,od.Specification,od.Final_Price,
od.Number,
CASE WHEN d1.Id IS NULL THEN d2.OneCommission * od.Number ELSE d1.OneCommission * od.Number END AS OneCommission,
CASE WHEN d1.Id IS NULL THEN d2.TwoCommission * od.Number ELSE d1.TwoCommission * od.Number END AS TwoCommission
FROM rb_goods_order o
INNER JOIN rb_goods_orderdetail od on o.OrderId=od.OrderId
INNER JOIN rb_member_user u on o.UserId = u.Id
LEFT JOIN rb_goods_distributioncommission d1 on d1.GoodsId=od.GoodsId AND d1.DistributorGrade=74 and d1.SpecificationSort=od.SpecificationSort
LEFT JOIN rb_goods_distributioncommission d2 on d2.GoodsId=od.GoodsId AND d2.DistributorGrade=74 and d2.SpecificationSort=''
WHERE o.OrderId in(
SELECT t.OrderId FROM(
SELECT cm.OrderId,cm.UserId FROM rb_goods_ordercommission cm WHERE CommissionState = 2 AND TenantId =1 AND MallBaseId =1
AND cm.OrderId in(SELECT cm1.OrderId FROM rb_goods_ordercommission cm1 WHERE cm1.UserId in(SELECT Id FROM rb_member_user WHERE Id <> 39370 AND SuperiorId BETWEEN 1 and 20))
GROUP BY cm.OrderId,cm.UserId
)t GROUP BY t.OrderId HAVING COUNT(0)=1)
AND o.OrderId >=34137 and o.OrderId <=80622 and o.OrderId <> 63803 AND o.OrderId <> 63839
AND o.UserId in(
SELECT mu2.Id FROM rb_member_user mu1
INNER JOIN rb_member_user mu2 on mu1.Id = mu2.SuperiorId
WHERE mu1.Id <> 39370 AND mu1.SuperiorId BETWEEN 1 and 20
)
ORDER BY o.OrderId ASC;";
string sql3 = $@"SELECT o.OrderId,o.OrderNo,od.Id AS DetailId,o.UserId,u.`Name`,o.Income,o.Consignee,o.Mobile,o.ShoppingAddress,od.GoodsName,od.Specification,od.Final_Price,
od.Number,
CASE WHEN d1.Id IS NULL THEN d2.OneCommission * od.Number ELSE d1.OneCommission * od.Number END AS OneCommission,
CASE WHEN d1.Id IS NULL THEN d2.TwoCommission * od.Number ELSE d1.TwoCommission * od.Number END AS TwoCommission,
u21.Id AS FUserId,
u21.`Name` AS FName
FROM rb_goods_order o
INNER JOIN rb_goods_orderdetail od on o.OrderId=od.OrderId
INNER JOIN rb_member_user u on o.UserId = u.Id
INNER JOIN rb_member_user u21 on u.SuperiorId = u21.Id
LEFT JOIN rb_goods_distributioncommission d1 on d1.GoodsId=od.GoodsId AND d1.DistributorGrade=74 and d1.SpecificationSort=od.SpecificationSort
LEFT JOIN rb_goods_distributioncommission d2 on d2.GoodsId=od.GoodsId AND d2.DistributorGrade=74 and d2.SpecificationSort=''
WHERE o.OrderId in(
SELECT t.OrderId FROM(
SELECT cm.OrderId,cm.UserId FROM rb_goods_ordercommission cm WHERE CommissionState = 2 AND TenantId =1 AND MallBaseId =1
AND cm.OrderId in(SELECT cm1.OrderId FROM rb_goods_ordercommission cm1 WHERE cm1.UserId in(SELECT Id FROM rb_member_user WHERE Id <> 39370 AND SuperiorId BETWEEN 1 and 20))
GROUP BY cm.OrderId,cm.UserId
)t GROUP BY t.OrderId HAVING COUNT(0)=1)
AND o.OrderId >=34137 and o.OrderId <=80622 and o.OrderId <> 63803 AND o.OrderId <> 63839
AND o.UserId in(
SELECT mu2.Id FROM rb_member_user mu1
INNER JOIN rb_member_user mu2 on mu1.Id = mu2.SuperiorId
WHERE mu1.Id <> 39370 AND mu1.SuperiorId BETWEEN 1 and 20
)
ORDER BY o.OrderId ASC;";
DataSet OrderCommList = MySqlHelper.ExecuteDataset(MySqlHelper.defaultConnection, System.Data.CommandType.Text, citySql, null);
DataSet OrderComm2List = MySqlHelper.ExecuteDataset(MySqlHelper.defaultConnection, System.Data.CommandType.Text, sql3, null);
string Time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
foreach (DataRow item in OrderCommList.Tables[0].Rows)
{
......@@ -222,7 +272,41 @@ ORDER BY o.OrderId ASC ";
//插入返佣
string InertComm = $@"
insert into rb_goods_ordercommission (OrderId,OrderDetailId,UserId,Grade,Commission,IsGoodsDistribution,CommissionState,Remark,TenantId,MallBaseId,CreateDate,UpdateDate,Type,IsRemit)
values ({OrderId},{DetailId},{UserId},2,{TwoCommission},2,2,'补充二级返佣',1,1,'{Time}','{Time}',1,2)
values ({OrderId},{DetailId},{UserId},2,{TwoCommission},2,2,'自购补充二级返佣',1,1,'{Time}','{Time}',1,2);
";
var InertCommResult = MySqlHelper.ExecuteNonQuery(MySqlHelper.defaultConnection, System.Data.CommandType.Text, InertComm, null);
if (InertCommResult > 0)
{
string UserComm = $@"update rb_distributor_info set TotalCommission=TotalCommission+{TwoCommission},CommissionWithdrawal=CommissionWithdrawal+{TwoCommission}";
var UserCommResult = MySqlHelper.ExecuteNonQuery(MySqlHelper.defaultConnection, System.Data.CommandType.Text, UserComm, null);
if (UserCommResult <= 0)
{
Console.WriteLine("更新用户返佣失败 OrderId:" + OrderId + ",DetailId:" + DetailId + ",UserId:" + UserId + " TwoCommission:" + TwoCommission);
}
}
else
{
Console.WriteLine("返佣插入失败 OrderId:" + OrderId + ",DetailId:" + DetailId + ",UserId:" + UserId + " TwoCommission:" + TwoCommission);
}
}
else
{
Console.WriteLine("OrderId:" + OrderId + ",DetailId:" + DetailId + ",UserId:" + UserId + " TwoCommission:" + TwoCommission);
}
}
foreach (DataRow item in OrderComm2List.Tables[0].Rows)
{
int OrderId = Convert.ToInt32(item["OrderId"].ToString());
int DetailId = Convert.ToInt32(item["DetailId"].ToString());
int UserId = Convert.ToInt32(item["FUserId"].ToString());
decimal TwoCommission = Convert.ToDecimal(item["TwoCommission"].ToString());
if (TwoCommission > 0)
{
//插入返佣
string InertComm = $@"
insert into rb_goods_ordercommission (OrderId,OrderDetailId,UserId,Grade,Commission,IsGoodsDistribution,CommissionState,Remark,TenantId,MallBaseId,CreateDate,UpdateDate,Type,IsRemit)
values ({OrderId},{DetailId},{UserId},2,{TwoCommission},2,2,'下级购买补充二级返佣',1,1,'{Time}','{Time}',1,2);
";
var InertCommResult = MySqlHelper.ExecuteNonQuery(MySqlHelper.defaultConnection, System.Data.CommandType.Text, InertComm, null);
if (InertCommResult > 0)
......
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