mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2025-12-06 18:13:26 +08:00
【新增】新增新人注册可以自动识别并发放优惠券。
This commit is contained in:
@@ -898,6 +898,22 @@ namespace CoreCms.Net.Configuration
|
||||
/// </summary>
|
||||
public static readonly string ShowLiveBroadCast = "showLiveBroadCast";
|
||||
|
||||
/// <summary>
|
||||
/// 是否开启赠送优惠券
|
||||
/// </summary>
|
||||
|
||||
public static readonly string IsAllowGiveCoupon = "isAllowGiveCoupon";
|
||||
|
||||
/// <summary>
|
||||
/// 选择注册赠送优惠券
|
||||
/// </summary>
|
||||
public static readonly string SelectGiveCoupon = "selectGiveCoupon";
|
||||
|
||||
/// <summary>
|
||||
/// 赠送数量
|
||||
/// </summary>
|
||||
public static readonly string GiveCouponNumber = "giveCouponNumber";
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -45,6 +45,11 @@ namespace CoreCms.Net.Configuration
|
||||
di.Add(SystemSettingConstVars.PrivacyPolicyId, new DictionaryKeyValues() { sKey = "隐私政策", sValue = "4" });
|
||||
di.Add(SystemSettingConstVars.PrivacyPolicy, new DictionaryKeyValues() { sKey = "隐私政策", sValue = "" });
|
||||
|
||||
//开启赠送新人优惠券
|
||||
di.Add(SystemSettingConstVars.IsAllowGiveCoupon, new DictionaryKeyValues() { sKey = "是否赠送新人优惠券", sValue = "2" });
|
||||
di.Add(SystemSettingConstVars.SelectGiveCoupon, new DictionaryKeyValues() { sKey = "选择注册赠送优惠券", sValue = "0" });
|
||||
di.Add(SystemSettingConstVars.GiveCouponNumber, new DictionaryKeyValues() { sKey = "赠送优惠券数量", sValue = "1" });
|
||||
|
||||
//开关功能
|
||||
di.Add(SystemSettingConstVars.ShowStoreBalanceRechargeSwitch, new DictionaryKeyValues() { sKey = "显示充值功能", sValue = "2" });
|
||||
di.Add(SystemSettingConstVars.IsAllowWithdrawCash, new DictionaryKeyValues() { sKey = "是否允许提现", sValue = "2" });
|
||||
|
||||
@@ -60,8 +60,10 @@ namespace CoreCms.Net.IServices
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="promotionId"></param>
|
||||
/// <param name="promotion"></param>
|
||||
/// <param name="number"></param>
|
||||
/// <param name="remark"></param>
|
||||
/// <returns></returns>
|
||||
Task<WebApiCallBack> AddData(int userId, int promotionId, CoreCmsPromotion promotion);
|
||||
Task<WebApiCallBack> AddData(int userId, int promotionId, CoreCmsPromotion promotion, int number = 1, string remark = "接口领取");
|
||||
|
||||
/// <summary>
|
||||
/// 通过优惠券号领取优惠券
|
||||
|
||||
@@ -108,8 +108,10 @@ namespace CoreCms.Net.Services
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="promotionId"></param>
|
||||
/// <param name="promotion"></param>
|
||||
/// <param name="number">数量</param>
|
||||
/// <param name="remark">说明</param>
|
||||
/// <returns></returns>
|
||||
public async Task<WebApiCallBack> AddData(int userId, int promotionId, CoreCmsPromotion promotion)
|
||||
public async Task<WebApiCallBack> AddData(int userId, int promotionId, CoreCmsPromotion promotion, int number = 1, string remark = "接口领取")
|
||||
{
|
||||
var jm = new WebApiCallBack();
|
||||
|
||||
@@ -124,19 +126,43 @@ namespace CoreCms.Net.Services
|
||||
{
|
||||
eTime = eTime.AddHours(promotion.effectiveHours);
|
||||
}
|
||||
var coupon = new CoreCmsCoupon
|
||||
{
|
||||
couponCode = GeneratePromotionCode()[0],
|
||||
promotionId = promotion.id,
|
||||
isUsed = false,
|
||||
userId = userId,
|
||||
createTime = dtTime,
|
||||
startTime = dtTime,
|
||||
endTime = eTime,
|
||||
remark = "接口领取"
|
||||
};
|
||||
|
||||
var bl = await _dal.InsertAsync(coupon) > 0;
|
||||
bool bl;
|
||||
if (number > 1)
|
||||
{
|
||||
var list = new List<CoreCmsCoupon>();
|
||||
for (var i = 0; i < number; i++)
|
||||
{
|
||||
list.Add(new CoreCmsCoupon
|
||||
{
|
||||
couponCode = GeneratePromotionCode()[0],
|
||||
promotionId = promotion.id,
|
||||
isUsed = false,
|
||||
userId = userId,
|
||||
createTime = dtTime,
|
||||
startTime = dtTime,
|
||||
endTime = eTime,
|
||||
remark = remark
|
||||
});
|
||||
}
|
||||
bl = await _dal.InsertAsync(list) > 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
var coupon = new CoreCmsCoupon
|
||||
{
|
||||
couponCode = GeneratePromotionCode()[0],
|
||||
promotionId = promotion.id,
|
||||
isUsed = false,
|
||||
userId = userId,
|
||||
createTime = dtTime,
|
||||
startTime = dtTime,
|
||||
endTime = eTime,
|
||||
remark = remark
|
||||
};
|
||||
bl = await _dal.InsertAsync(coupon) > 0;
|
||||
}
|
||||
|
||||
jm.status = bl;
|
||||
jm.msg = bl ? "领取成功" : "领取失败";
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using SqlSugar;
|
||||
using static SKIT.FlurlHttpClient.Wechat.Api.Models.CgibinUserInfoBatchGetRequest.Types;
|
||||
|
||||
|
||||
namespace CoreCms.Net.Services;
|
||||
@@ -59,6 +60,10 @@ public class CoreCmsUserServices : BaseServices<CoreCmsUser>, ICoreCmsUserServic
|
||||
private readonly ICoreCmsDistributionGradeRepository _distributionGradeRepository;
|
||||
private readonly ICoreCmsDistributionRepository _distributionRepository;
|
||||
|
||||
private readonly ICoreCmsPromotionServices _coreCmsPromotionServices;
|
||||
private readonly ICoreCmsCouponServices _coreCmsCouponServices;
|
||||
|
||||
|
||||
public CoreCmsUserServices(IUnitOfWork unitOfWork
|
||||
, ICoreCmsUserRepository dal
|
||||
, ICoreCmsUserBalanceServices userBalanceServices
|
||||
@@ -67,7 +72,7 @@ public class CoreCmsUserServices : BaseServices<CoreCmsUser>, ICoreCmsUserServic
|
||||
ICoreCmsUserWeChatInfoServices userWeChatInfoServices, ICoreCmsUserGradeServices userGradeServices,
|
||||
PermissionRequirement permissionRequirement, IHttpContextAccessor httpContextAccessor,
|
||||
ICoreCmsUserLogServices userLogServices, IServiceProvider serviceProvider,
|
||||
ICoreCmsBillPaymentsServices billPaymentsServices, ICoreCmsDistributionGradeRepository distributionGradeRepository, ICoreCmsDistributionRepository distributionRepository)
|
||||
ICoreCmsBillPaymentsServices billPaymentsServices, ICoreCmsDistributionGradeRepository distributionGradeRepository, ICoreCmsDistributionRepository distributionRepository, ICoreCmsPromotionServices coreCmsPromotionServices, ICoreCmsCouponServices coreCmsCouponServices)
|
||||
{
|
||||
_dal = dal;
|
||||
BaseDal = dal;
|
||||
@@ -85,6 +90,8 @@ public class CoreCmsUserServices : BaseServices<CoreCmsUser>, ICoreCmsUserServic
|
||||
_billPaymentsServices = billPaymentsServices;
|
||||
_distributionGradeRepository = distributionGradeRepository;
|
||||
_distributionRepository = distributionRepository;
|
||||
_coreCmsPromotionServices = coreCmsPromotionServices;
|
||||
_coreCmsCouponServices = coreCmsCouponServices;
|
||||
}
|
||||
|
||||
|
||||
@@ -627,6 +634,8 @@ public class CoreCmsUserServices : BaseServices<CoreCmsUser>, ICoreCmsUserServic
|
||||
}
|
||||
}
|
||||
|
||||
var allConfigs = await _settingServices.GetConfigDictionaries();
|
||||
|
||||
//如果没有头像和昵称,那么就取系统头像和昵称吧
|
||||
if (!string.IsNullOrEmpty(entity.avatar))
|
||||
{
|
||||
@@ -634,7 +643,6 @@ public class CoreCmsUserServices : BaseServices<CoreCmsUser>, ICoreCmsUserServic
|
||||
}
|
||||
else
|
||||
{
|
||||
var allConfigs = await _settingServices.GetConfigDictionaries();
|
||||
var defaultImage =
|
||||
CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.ShopDefaultImage);
|
||||
userInfo.avatarImage = defaultImage;
|
||||
@@ -688,7 +696,6 @@ public class CoreCmsUserServices : BaseServices<CoreCmsUser>, ICoreCmsUserServic
|
||||
|
||||
if (userId > 0 && entity.invitecode > 0 && userInfo.parentId > 0)
|
||||
{
|
||||
var allConfigs = await _settingServices.GetConfigDictionaries();
|
||||
var inviterUserIntegral = CommonHelper
|
||||
.GetConfigDictionary(allConfigs, SystemSettingConstVars.InviterUserIntegral)
|
||||
.ObjectToInt(); //是否开启积分功能
|
||||
@@ -719,6 +726,22 @@ public class CoreCmsUserServices : BaseServices<CoreCmsUser>, ICoreCmsUserServic
|
||||
}
|
||||
|
||||
userInfo = await _dal.QueryByIdAsync(userId);
|
||||
|
||||
|
||||
var isAllowGiveCoupon = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.IsAllowGiveCoupon).ObjectToInt(); //是否赠送新人优惠券
|
||||
var selectGiveCoupon = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.SelectGiveCoupon).ObjectToInt(); //选择注册赠送优惠券
|
||||
var giveCouponNumber = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.GiveCouponNumber).ObjectToInt(); //赠送优惠券数量
|
||||
|
||||
if (userId > 0 && isAllowGiveCoupon == 1 && selectGiveCoupon > 0 && giveCouponNumber > 0)
|
||||
{
|
||||
var promotion = await _coreCmsPromotionServices.QueryByIdAsync(selectGiveCoupon);
|
||||
|
||||
var dt = DateTime.Now;
|
||||
if (!promotion.isDel && promotion.isEnable && promotion.startTime < dt && promotion.endTime > dt)
|
||||
{
|
||||
await _coreCmsCouponServices.AddData(userId, promotion.id, promotion, giveCouponNumber, "新人注册赠送");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -42,16 +42,17 @@ namespace CoreCms.Net.Web.Admin.Controllers
|
||||
{
|
||||
private readonly IWebHostEnvironment _webHostEnvironment;
|
||||
private readonly ICoreCmsSettingServices _coreCmsSettingServices;
|
||||
private readonly ICoreCmsPromotionServices _coreCmsPromotionServices;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
///</summary>
|
||||
/// <param name="webHostEnvironment"></param>
|
||||
///<param name="CoreCmsSettingServices"></param>
|
||||
public CoreCmsSettingController(IWebHostEnvironment webHostEnvironment, ICoreCmsSettingServices CoreCmsSettingServices)
|
||||
public CoreCmsSettingController(IWebHostEnvironment webHostEnvironment, ICoreCmsSettingServices CoreCmsSettingServices, ICoreCmsPromotionServices coreCmsPromotionServices)
|
||||
{
|
||||
_webHostEnvironment = webHostEnvironment;
|
||||
_coreCmsSettingServices = CoreCmsSettingServices;
|
||||
_coreCmsPromotionServices = coreCmsPromotionServices;
|
||||
}
|
||||
|
||||
#region 首页数据============================================================
|
||||
@@ -69,10 +70,14 @@ namespace CoreCms.Net.Web.Admin.Controllers
|
||||
var configs = await _coreCmsSettingServices.GetConfigDictionaries();
|
||||
var filesStorageOptionsType = EnumHelper.EnumToList<GlobalEnumVars.FilesStorageOptionsType>();
|
||||
|
||||
var dt = DateTime.Now;
|
||||
var coupons = await _coreCmsPromotionServices.QueryListByClauseAsync(p => p.type == (int)GlobalEnumVars.PromotionType.Coupon && p.startTime < dt && p.endTime > dt && !p.isDel && p.isEnable);
|
||||
|
||||
jm.data = new
|
||||
{
|
||||
configs,
|
||||
filesStorageOptionsType
|
||||
filesStorageOptionsType,
|
||||
coupons
|
||||
};
|
||||
|
||||
return jm;
|
||||
|
||||
@@ -3887,12 +3887,10 @@
|
||||
平台设置表
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:CoreCms.Net.Web.Admin.Controllers.CoreCmsSettingController.#ctor(Microsoft.AspNetCore.Hosting.IWebHostEnvironment,CoreCms.Net.IServices.ICoreCmsSettingServices)">
|
||||
<member name="M:CoreCms.Net.Web.Admin.Controllers.CoreCmsSettingController.#ctor(Microsoft.AspNetCore.Hosting.IWebHostEnvironment,CoreCms.Net.IServices.ICoreCmsSettingServices,CoreCms.Net.IServices.ICoreCmsPromotionServices)">
|
||||
<summary>
|
||||
构造函数
|
||||
</summary>
|
||||
<param name="webHostEnvironment"></param>
|
||||
<param name="CoreCmsSettingServices"></param>
|
||||
</member>
|
||||
<member name="M:CoreCms.Net.Web.Admin.Controllers.CoreCmsSettingController.GetIndex">
|
||||
<summary>
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
<li lay-id="inviteFriends">邀请好友设置</li>
|
||||
<li lay-id="filesStorage">附件设置</li>
|
||||
<li lay-id="store">门店设置</li>
|
||||
<li lay-id="newMember">新人设置</li>
|
||||
<li lay-id="other">其他设置</li>
|
||||
</ul>
|
||||
<div class="layui-tab-content">
|
||||
@@ -199,8 +200,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="layui-tab-item">
|
||||
|
||||
<div class="layui-form coreshop-form">
|
||||
@@ -918,6 +917,52 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-tab-item">
|
||||
<div class="layui-form coreshop-form">
|
||||
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;"> <legend>新人设置</legend></fieldset>
|
||||
<blockquote class="layui-elem-quote">
|
||||
注意:当前发送优惠券,只判断了选择的优惠券是否在有效期,另外并未计算优惠券剩余多少可领取与新人放发放数量对比限制。
|
||||
</blockquote>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">{{d.data.configs['isAllowGiveCoupon']['sKey']}}:</label>
|
||||
<div class="layui-input-inline layui-inline-5">
|
||||
<input type="radio" lay-filter="isAllowGiveCoupon" name="isAllowGiveCoupon" value="1" title="开启" {{d.data.configs['isAllowGiveCoupon']['sValue']==="1" ? 'checked':''}}>
|
||||
<input type="radio" lay-filter="isAllowGiveCoupon" name="isAllowGiveCoupon" value="2" title="不开启" {{d.data.configs['isAllowGiveCoupon']['sValue']==="2" ? 'checked':''}}>
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux">用户注册是否自动赠送优惠券</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">{{d.data.configs['selectGiveCoupon']['sKey']}}:</label>
|
||||
<div class="layui-input-inline layui-inline-5">
|
||||
<select name="selectGiveCoupon">
|
||||
<option>请选择</option>
|
||||
{{# layui.each( d.data.coupons, function(index, item){ }}
|
||||
<option value="{{ item.id }}" {{item.id.toString()===d.data.configs['selectGiveCoupon']['sValue']?'selected="selected"':'' }}>{{ item.name }}</option>
|
||||
{{# }); }}
|
||||
</select>
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux">只能选择在有效活动期内正常的优惠券</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">{{d.data.configs['giveCouponNumber']['sKey']}}:</label>
|
||||
<div class="layui-input-inline layui-inline-5">
|
||||
<input type="text" name="giveCouponNumber" value="{{d.data.configs['giveCouponNumber']['sValue']}}" lay-verify="title" autocomplete="off" placeholder="" class="layui-input">
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux">赠送优惠券的数量</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"> </label>
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn" lay-submit="" lay-filter="save">保存更改</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-tab-item">
|
||||
<div class="layui-form coreshop-form">
|
||||
<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;"> <legend>客服</legend></fieldset>
|
||||
|
||||
Reference in New Issue
Block a user