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.

115 lines
6.6 KiB

2 years ago
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;
2 years ago
using BBWYB.Server.Model.Dto;
using SDKAdapter.OperationPlatform.Client;
using SDKAdapter.OperationPlatform.Models;
2 years ago
using Yitter.IdGenerator;
namespace BBWYB.Server.Business
{
public class VenderBusiness : BaseBusiness, IDenpendency
{
private OP_PlatformClientFactory opPlatformClientFactory;
2 years ago
private FreeSqlMultiDBManager fsqlManager;
public VenderBusiness(IFreeSql fsql, NLogManager nLogManager, IIdGenerator idGenerator, FreeSqlMultiDBManager fsqlManager, OP_PlatformClientFactory opPlatformClientFactory) : base(fsql, nLogManager, idGenerator)
2 years ago
{
this.fsqlManager = fsqlManager;
this.opPlatformClientFactory = opPlatformClientFactory;
2 years ago
}
public IList<ShopResponse> GetShopList(long? shopId = null, Enums.Platform? platform = null)
2 years ago
{
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
});
}
public IList<OP_QueryExpressCompanyResponse> GetKuaiDi100ExpressCompanyList()
{
return new List<OP_QueryExpressCompanyResponse>()
{
new OP_QueryExpressCompanyResponse(){ ExpressName = "中通快递",ExpressId="zhongtong"},
new OP_QueryExpressCompanyResponse(){ ExpressName = "中通快运",ExpressId="zhongtongkuaiyun"},
new OP_QueryExpressCompanyResponse(){ ExpressName = "圆通速递",ExpressId="yuantong"},
new OP_QueryExpressCompanyResponse(){ ExpressName = "邮政快递包裹",ExpressId="youzhengguonei"},
new OP_QueryExpressCompanyResponse(){ ExpressName = "韵达快递",ExpressId="yunda"},
new OP_QueryExpressCompanyResponse(){ ExpressName = "申通快递",ExpressId="shentong"},
new OP_QueryExpressCompanyResponse(){ ExpressName = "顺丰快递",ExpressId="shunfeng"},
new OP_QueryExpressCompanyResponse(){ ExpressName = "顺丰快运",ExpressId="shunfengkuaiyun"},
new OP_QueryExpressCompanyResponse(){ ExpressName = "百世快递",ExpressId="huitongkuaidi"},
new OP_QueryExpressCompanyResponse(){ ExpressName = "德邦物流",ExpressId="debangwuliu"},
new OP_QueryExpressCompanyResponse(){ ExpressName = "德邦快递",ExpressId="debangkuaidi"},
new OP_QueryExpressCompanyResponse(){ ExpressName = "EMS",ExpressId="ems"},
new OP_QueryExpressCompanyResponse(){ ExpressName = "极兔速递",ExpressId="jtexpress"},
new OP_QueryExpressCompanyResponse(){ ExpressName = "安能物流",ExpressId="annengwuliu"},
new OP_QueryExpressCompanyResponse(){ ExpressName = "德坤物流",ExpressId="dekuncn"},
new OP_QueryExpressCompanyResponse(){ ExpressName = "壹米滴答",ExpressId="yimidida"},
new OP_QueryExpressCompanyResponse(){ ExpressName = "优速快递",ExpressId="youshuwuliu"},
new OP_QueryExpressCompanyResponse(){ ExpressName = "京广速递",ExpressId="jinguangsudikuaijian"},
new OP_QueryExpressCompanyResponse(){ ExpressName = "丰网速运",ExpressId="fengwang"},
new OP_QueryExpressCompanyResponse(){ ExpressName = "顺心捷达",ExpressId="sxjdfreight"},
new OP_QueryExpressCompanyResponse(){ ExpressName = "快捷速递",ExpressId="kuaijiesudi"}
};
}
2 years ago
}
}