|
|
|
using BBWY.Common.Http;
|
|
|
|
using BBWY.Common.Models;
|
|
|
|
using BBWY.Server.Model;
|
|
|
|
using BBWY.Server.Model.Db;
|
|
|
|
using BBWY.Server.Model.Dto;
|
|
|
|
using Microsoft.Extensions.Options;
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using Yitter.IdGenerator;
|
|
|
|
|
|
|
|
namespace BBWY.Server.Business
|
|
|
|
{
|
|
|
|
public class EvaluationAssistantBusiness : BasePlatformRelayBusiness, IDenpendency
|
|
|
|
{
|
|
|
|
private IFreeSql fsql;
|
|
|
|
|
|
|
|
private IIdGenerator idGenerator;
|
|
|
|
|
|
|
|
public EvaluationAssistantBusiness(RestApiService restApiService, IOptions<GlobalConfig> options, YunDingBusiness yunDingBusiness, IFreeSql fsql, IIdGenerator idGenerator) : base(restApiService, options, yunDingBusiness)
|
|
|
|
{
|
|
|
|
this.fsql = fsql;
|
|
|
|
this.idGenerator = idGenerator;
|
|
|
|
}
|
|
|
|
|
|
|
|
#region 赠品模板
|
|
|
|
public void AddOrEditGiftTemplate(AddOrEditGiftTemplateRequest request)
|
|
|
|
{
|
|
|
|
var giftCount = request.GiftSkus.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Count();
|
|
|
|
if (request.Id == 0)
|
|
|
|
{
|
|
|
|
var giftTemplate = new GiftTemplate()
|
|
|
|
{
|
|
|
|
Id = idGenerator.NewLong(),
|
|
|
|
CreateTime = DateTime.Now,
|
|
|
|
TemplateName = request.TemplateName,
|
|
|
|
Platform = Enums.Platform.京东,
|
|
|
|
ShopId = request.ShopId,
|
|
|
|
TemplateSpu = request.TemplateSpu,
|
|
|
|
GiftCount = giftCount,
|
|
|
|
GiftSkus = request.GiftSkus
|
|
|
|
};
|
|
|
|
fsql.Insert(giftTemplate).ExecuteAffrows();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
fsql.Update<GiftTemplate>(request.Id).Set(g => g.TemplateName, request.TemplateName)
|
|
|
|
.Set(g => g.TemplateSpu, request.TemplateSpu)
|
|
|
|
.Set(g => g.GiftSkus, request.GiftSkus)
|
|
|
|
.Set(g => g.GiftCount, giftCount)
|
|
|
|
.ExecuteAffrows();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public IList<GiftTemplateResponse> GetGiftTemplateList(long shopId)
|
|
|
|
{
|
|
|
|
return fsql.Select<GiftTemplate>().Where(g => g.ShopId == shopId).ToList<GiftTemplateResponse>();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void DeleteGiftTemplate(long giftTemplateId)
|
|
|
|
{
|
|
|
|
fsql.Delete<GiftTemplate>(giftTemplateId).ExecuteAffrows();
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|