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.
86 lines
4.3 KiB
86 lines
4.3 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 SDKAdapter.OperationPlatform.Client;
|
|
using SDKAdapter.OperationPlatform.Models;
|
|
using Yitter.IdGenerator;
|
|
|
|
namespace BBWYB.Server.Business
|
|
{
|
|
public class VenderBusiness : BaseBusiness, IDenpendency
|
|
{
|
|
private OP_PlatformClientFactory opPlatformClientFactory;
|
|
private FreeSqlMultiDBManager fsqlManager;
|
|
public VenderBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator, FreeSqlMultiDBManager fsqlManager, OP_PlatformClientFactory opPlatformClientFactory) : base(fsql, nLogManager, idGenerator)
|
|
{
|
|
this.fsqlManager = fsqlManager;
|
|
this.opPlatformClientFactory = opPlatformClientFactory;
|
|
}
|
|
|
|
public IList<ShopResponse> GetShopList(long? shopId = null, Enums.Platform? platform = null)
|
|
{
|
|
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)
|
|
.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 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.MDSfsql.Insert(mdspa).ExecuteAffrows();
|
|
}
|
|
else
|
|
{
|
|
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();
|
|
}
|
|
return shopSettingRequest.PurchaseAccountId;
|
|
}
|
|
|
|
public IList<OP_QueryExpressCompanyResponse> GetExpressCompanyList(PlatformRequest request)
|
|
{
|
|
return opPlatformClientFactory.GetClient((SDKAdapter.AdapterEnums.PlatformType)request.Platform)
|
|
.GetExpressCompanyList(new OP_QueryExpressCompanyRequest()
|
|
{
|
|
AppKey = request.AppKey,
|
|
AppSecret = request.AppSecret,
|
|
AppToken = request.AppToken,
|
|
Platform = (SDKAdapter.AdapterEnums.PlatformType)request.Platform
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|