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.
121 lines
7.7 KiB
121 lines
7.7 KiB
using BBWY.Server.Model.Db.Mds;
|
|
using BBWYB.Common.Log;
|
|
using BBWYB.Common.Models;
|
|
using BBWYB.Server.Model;
|
|
using BBWYB.Server.Model.Db;
|
|
using BBWYB.Server.Model.Db.MDS;
|
|
using BBWYB.Server.Model.Dto;
|
|
using Yitter.IdGenerator;
|
|
|
|
namespace BBWYB.Server.Business
|
|
{
|
|
public class VenderBusiness : BaseBusiness, IDenpendency
|
|
{
|
|
private FreeSqlMultiDBManager fsqlManager;
|
|
public VenderBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator, FreeSqlMultiDBManager fsqlManager) : base(fsql, nLogManager, idGenerator)
|
|
{
|
|
this.fsqlManager = fsqlManager;
|
|
}
|
|
|
|
public IList<ShopResponse> GetShopList(long? shopId = null, Enums.Platform? platform = null, bool filterTurnoverDays = false, bool filterSiNan = false)
|
|
{
|
|
return fsqlManager.MDSfsql.Select<Shops>().Where(s => !string.IsNullOrEmpty(s.ShopId))
|
|
.WhereIf(shopId != null, s => s.ShopId == shopId.ToString())
|
|
.WhereIf(platform != null, s => s.PlatformId == (int)platform)
|
|
.WhereIf(filterTurnoverDays, s => s.SkuSafeTurnoverDays != 0)
|
|
.WhereIf(filterSiNan, s => !string.IsNullOrEmpty(s.SiNanDingDingWebHook))
|
|
.ToList<ShopResponse>();
|
|
}
|
|
|
|
|
|
public long SaveShopSetting(ShopSettingRequest shopSettingRequest)
|
|
{
|
|
//根据shopId查询mds shop的主键Id
|
|
var shopId = shopSettingRequest.ShopId.ToString();
|
|
var mdsShop = fsqlManager.MDSfsql.Select<Shops>().Where(s => s.ShopId == shopId).ToOne();
|
|
if (mdsShop == null)
|
|
throw new BusinessException($"mds未找到shopId {shopSettingRequest.ShopId}");
|
|
|
|
if (shopSettingRequest.PurchaseAccountId == 0)
|
|
{
|
|
shopSettingRequest.PurchaseAccountId = idGenerator.NewLong();
|
|
var pa = new PurchaseAccount()
|
|
{
|
|
Id = shopSettingRequest.PurchaseAccountId,
|
|
AccountName = shopSettingRequest.AccountName,
|
|
AppKey = shopSettingRequest.AppKey,
|
|
AppSecret = shopSettingRequest.AppSecret,
|
|
AppToken = shopSettingRequest.AppToken,
|
|
CreateTime = DateTime.Now,
|
|
CreatorId = "",
|
|
Deleted = 0,
|
|
PurchasePlatformId = shopSettingRequest.PurchasePlatformId,
|
|
ShopId = shopSettingRequest.ShopId
|
|
};
|
|
|
|
var mdspa = new Purchaseaccount()
|
|
{
|
|
Id = shopSettingRequest.PurchaseAccountId.ToString(),
|
|
AccountName = shopSettingRequest.AccountName,
|
|
AppKey = shopSettingRequest.AppKey,
|
|
AppSecret = shopSettingRequest.AppSecret,
|
|
AppToken = shopSettingRequest.AppToken,
|
|
CreateTime = DateTime.Now,
|
|
CreatorId = "",
|
|
Deleted = 0,
|
|
PurchasePlatformId = ((int)shopSettingRequest.PurchasePlatformId).ToString(),
|
|
ShopId = mdsShop.Id
|
|
};
|
|
|
|
|
|
fsqlManager.BBWYfsql.Insert(pa).ExecuteAffrows();
|
|
fsqlManager.MDSfsql.Transaction(() =>
|
|
{
|
|
fsqlManager.MDSfsql.Insert(mdspa).ExecuteAffrows();
|
|
//修改扣点和管理密码
|
|
//fsqlManager.MDSfsql.Update<Shops>(mdsShop.Id).Set(s => s.ManagePwd, shopSettingRequest.ManagerPwd)
|
|
// .Set(s => s.PlatformCommissionRatio, shopSettingRequest.PlatformCommissionRatio)
|
|
// .Set(s => s.DingDingKey, shopSettingRequest.DingDingKey)
|
|
// .Set(s => s.DingDingWebHook, shopSettingRequest.DingDingWebHook)
|
|
// .Set(s => s.SkuSafeTurnoverDays, shopSettingRequest.SkuSafeTurnoverDays)
|
|
// .Set(s => s.SiNanDingDingKey, shopSettingRequest.SiNanDingDingKey)
|
|
// .Set(s => s.SiNanDingDingWebHook, shopSettingRequest.SiNanDingDingWebHook)
|
|
// .Set(s => s.SiNanPolicyLevel, shopSettingRequest.SiNanPolicyLevel)
|
|
// .ExecuteAffrows();
|
|
});
|
|
}
|
|
else
|
|
{
|
|
fsqlManager.BBWYfsql.Update<PurchaseAccount>(shopSettingRequest.PurchaseAccountId)
|
|
.Set(pa => pa.AppKey, shopSettingRequest.AppKey)
|
|
.Set(pa => pa.AppSecret, shopSettingRequest.AppSecret)
|
|
.Set(pa => pa.AppToken, shopSettingRequest.AppToken)
|
|
.Set(pa => pa.AccountName, shopSettingRequest.AccountName)
|
|
.Set(pa => pa.PurchasePlatformId, shopSettingRequest.PurchasePlatformId)
|
|
.ExecuteAffrows();
|
|
|
|
fsqlManager.MDSfsql.Transaction(() =>
|
|
{
|
|
fsqlManager.MDSfsql.Update<Purchaseaccount>(shopSettingRequest.PurchaseAccountId.ToString())
|
|
.Set(pa => pa.AppKey, shopSettingRequest.AppKey)
|
|
.Set(pa => pa.AppSecret, shopSettingRequest.AppSecret)
|
|
.Set(pa => pa.AppToken, shopSettingRequest.AppToken)
|
|
.Set(pa => pa.AccountName, shopSettingRequest.AccountName)
|
|
.Set(pa => pa.PurchasePlatformId, ((int)shopSettingRequest.PurchasePlatformId).ToString())
|
|
.ExecuteAffrows();
|
|
//修改扣点和管理密码
|
|
//fsqlManager.MDSfsql.Update<Shops>(mdsShop.Id).Set(s => s.ManagePwd, shopSettingRequest.ManagerPwd)
|
|
// .Set(s => s.PlatformCommissionRatio, shopSettingRequest.PlatformCommissionRatio)
|
|
// .Set(s => s.DingDingKey, shopSettingRequest.DingDingKey)
|
|
// .Set(s => s.DingDingWebHook, shopSettingRequest.DingDingWebHook)
|
|
// .Set(s => s.SkuSafeTurnoverDays, shopSettingRequest.SkuSafeTurnoverDays)
|
|
// .Set(s => s.SiNanDingDingKey, shopSettingRequest.SiNanDingDingKey)
|
|
// .Set(s => s.SiNanDingDingWebHook, shopSettingRequest.SiNanDingDingWebHook)
|
|
// .Set(s => s.SiNanPolicyLevel, shopSettingRequest.SiNanPolicyLevel)
|
|
// .ExecuteAffrows();
|
|
});
|
|
}
|
|
return shopSettingRequest.PurchaseAccountId;
|
|
}
|
|
}
|
|
}
|
|
|