|
@@ -0,0 +1,80 @@
|
|
|
+package com.example.xiaoshiweixinback.service;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.example.xiaoshiweixinback.domain.Activity;
|
|
|
+import com.example.xiaoshiweixinback.domain.AssoActivityVoucher;
|
|
|
+import com.example.xiaoshiweixinback.domain.AssoPersonVoucher;
|
|
|
+import com.example.xiaoshiweixinback.domain.AssoVipVoucher;
|
|
|
+import com.example.xiaoshiweixinback.entity.assoPersonVoucher.SendVoucherToPersonVO;
|
|
|
+import com.example.xiaoshiweixinback.mapper.ActivityMapper;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author admin
|
|
|
+ * @description 针对表【activity(折扣策略)】的数据库操作Service实现
|
|
|
+ * @createDate 2024-07-03 16:06:58
|
|
|
+ */
|
|
|
+@Service
|
|
|
+@RequiredArgsConstructor
|
|
|
+public class ActivityService extends ServiceImpl<ActivityMapper, Activity> {
|
|
|
+ @Autowired
|
|
|
+ private AssoActivityVoucherService assoActivityVoucherService;
|
|
|
+ @Autowired
|
|
|
+ private AssoPersonVoucherService assoPersonVoucherService;
|
|
|
+ //根据使用场景id查询活动
|
|
|
+ public List<Activity> getActivities(Integer useScope) {
|
|
|
+ List<Activity> activities = this.getBaseMapper().queryScopeActivity(useScope);
|
|
|
+ if(activities.size()==0){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ Activity activity =activities.get(0);
|
|
|
+ return activities;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void sendVoucherToPerson(String personUuid, Integer activityId) {
|
|
|
+ List<AssoActivityVoucher> assoActivityVouchers = assoActivityVoucherService.getAssoActivityVoucher(activityId);
|
|
|
+ if(assoActivityVouchers.size()==0){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+SendVoucherToPersonVO sendVoucherToPersonVO =this.loadSendVoucherToPersonVO(assoActivityVouchers,personUuid);
|
|
|
+
|
|
|
+ assoPersonVoucherService.sendVoucherToPerson(sendVoucherToPersonVO);
|
|
|
+ }
|
|
|
+
|
|
|
+ private SendVoucherToPersonVO loadSendVoucherToPersonVO(List<AssoActivityVoucher> assoActivityVoucher, String personUuid ) {
|
|
|
+ SendVoucherToPersonVO sendVoucherToPersonVO =new SendVoucherToPersonVO();
|
|
|
+ sendVoucherToPersonVO.setGetWay(0);
|
|
|
+ List<String> personIds =new ArrayList<>();
|
|
|
+ personIds.add(personUuid);
|
|
|
+ sendVoucherToPersonVO.setPersonUuids(personIds);
|
|
|
+ List<SendVoucherToPersonVO.InAddVoucherVO> inAddVoucherVOS =new ArrayList<>();
|
|
|
+ assoActivityVoucher.forEach(item->{
|
|
|
+ SendVoucherToPersonVO.InAddVoucherVO inAddVoucherVO =new SendVoucherToPersonVO.InAddVoucherVO();
|
|
|
+ inAddVoucherVO.setVoucherId(item.getVoucherId());
|
|
|
+ inAddVoucherVO.setNumber(item.getVoucherNum());
|
|
|
+ inAddVoucherVOS.add(inAddVoucherVO);
|
|
|
+ });
|
|
|
+ sendVoucherToPersonVO.setInAddVoucherVOS(inAddVoucherVOS);
|
|
|
+ return sendVoucherToPersonVO;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void doingActivity(String personUuid,Integer useScope){
|
|
|
+ List<Activity> activities = this.getActivities(useScope);
|
|
|
+ if(activities==null||activities.size()==0){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Activity activity =activities.get(0);
|
|
|
+ Integer activityId =activity.getId();
|
|
|
+ this.sendVoucherToPerson(personUuid,activityId);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|