推荐消费有礼 消费有礼 以及这块业务BUG 修改
This commit is contained in:
parent
654545c8a7
commit
8be7b0f73d
@ -25,6 +25,8 @@ public class ActiveConsumptionRecord extends Model<ActiveConsumptionRecord> {
|
||||
private Integer userId;
|
||||
//店铺id
|
||||
private Integer storeId;
|
||||
//活动子表id
|
||||
private String activeConsumptionChildIds;
|
||||
//创建者
|
||||
private String createBy;
|
||||
//创建时间
|
||||
@ -33,5 +35,6 @@ public class ActiveConsumptionRecord extends Model<ActiveConsumptionRecord> {
|
||||
private String updateBy;
|
||||
//更新时间
|
||||
private Date updateTime;
|
||||
|
||||
}
|
||||
|
||||
|
@ -4,9 +4,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fuint.business.marketingActivity.activeConsumption.entity.ActiveConsumption;
|
||||
import com.fuint.business.marketingActivity.activeConsumption.vo.ActiveConsumptionVOS;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 消费有礼活动(ActiveConsumption)表数据库访问层
|
||||
@ -17,5 +19,7 @@ import java.util.List;
|
||||
public interface ActiveConsumptionMapper extends BaseMapper<ActiveConsumption> {
|
||||
|
||||
IPage selectConsumptions(Page page, @Param("activeConsumption") ActiveConsumption activeConsumption);
|
||||
|
||||
List<ActiveConsumptionVOS> selectConsumptionsByMap(@Param("map")Map map);
|
||||
}
|
||||
|
||||
|
@ -31,5 +31,6 @@
|
||||
from active_consumption_child acc
|
||||
where
|
||||
acc.active_consumption_id = #{id}
|
||||
order by acc.consume_amount desc
|
||||
</select>
|
||||
</mapper>
|
@ -2,37 +2,41 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.fuint.business.marketingActivity.activeConsumption.mapper.ActiveConsumptionMapper">
|
||||
|
||||
<resultMap type="com.fuint.business.marketingActivity.activeConsumption.vo.ActiveConsumptionVOS" id="ActiveConsumptionMap">
|
||||
<resultMap type="com.fuint.business.marketingActivity.activeConsumption.vo.ActiveConsumptionVOS"
|
||||
id="ActiveConsumptionMap">
|
||||
<result property="id" column="id" jdbcType="INTEGER"/>
|
||||
<result property="chainStorId" column="chain_storId" jdbcType="INTEGER"/>
|
||||
<result property="storeId" column="store_id" jdbcType="INTEGER"/>
|
||||
<result property="name" column="name" jdbcType="VARCHAR"/>
|
||||
<result property="participationConditionMoney" column="participation_condition_money" jdbcType="VARCHAR"/>
|
||||
<result property="activeStartTime" column="active_start_time" />
|
||||
<result property="activeEndTime" column="active_end_time" />
|
||||
<result property="adaptOil" column="adapt_oil" />
|
||||
<result property="adaptUserType" column="adapt_user_type" />
|
||||
<result property="member_type" column="member_type" />
|
||||
<result property="dieselUserLevel" column="diesel_user_level" />
|
||||
<result property="gasolineUserLevel" column="gasoline_user_level" />
|
||||
<result property="naturalUserLevel" column="natural_user_level" />
|
||||
<result property="paymentType" column="payment_type" />
|
||||
<result property="participationCondition" column="participation_condition" />
|
||||
<result property="participationAcount" column="participation_acount" />
|
||||
<result property="limitAcount" column="limit_acount" />
|
||||
<result property="activeGift" column="active_gift" />
|
||||
<result property="points" column="points" />
|
||||
<result property="status" column="status" />
|
||||
<result property="isonline" column="isonline" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<collection property="activeConsumptionChildList" javaType="java.util.ArrayList" ofType="com.fuint.business.marketingActivity.activeConsumption.entity.ActiveConsumptionChild"
|
||||
select="com.fuint.business.marketingActivity.activeConsumption.mapper.ActiveConsumptionChildMapper.selectConsumptionChilds" column="id">
|
||||
<result property="activeStartTime" column="active_start_time"/>
|
||||
<result property="activeEndTime" column="active_end_time"/>
|
||||
<result property="adaptOil" column="adapt_oil"/>
|
||||
<result property="adaptUserType" column="adapt_user_type"/>
|
||||
<result property="member_type" column="member_type"/>
|
||||
<result property="dieselUserLevel" column="diesel_user_level"/>
|
||||
<result property="gasolineUserLevel" column="gasoline_user_level"/>
|
||||
<result property="naturalUserLevel" column="natural_user_level"/>
|
||||
<result property="paymentType" column="payment_type"/>
|
||||
<result property="participationCondition" column="participation_condition"/>
|
||||
<result property="participationAcount" column="participation_acount"/>
|
||||
<result property="limitAcount" column="limit_acount"/>
|
||||
<result property="activeGift" column="active_gift"/>
|
||||
<result property="points" column="points"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="isonline" column="isonline"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<collection property="activeConsumptionChildList" javaType="java.util.ArrayList"
|
||||
ofType="com.fuint.business.marketingActivity.activeConsumption.entity.ActiveConsumptionChild"
|
||||
select="com.fuint.business.marketingActivity.activeConsumption.mapper.ActiveConsumptionChildMapper.selectConsumptionChilds"
|
||||
column="id">
|
||||
</collection>
|
||||
</resultMap>
|
||||
|
||||
|
||||
<select id="selectConsumptions" resultMap="ActiveConsumptionMap">
|
||||
select
|
||||
*
|
||||
@ -53,4 +57,12 @@
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
<select id="selectConsumptionsByMap" resultMap="ActiveConsumptionMap" >
|
||||
select
|
||||
*
|
||||
from active_consumption
|
||||
where
|
||||
store_id = #{map.storeId}
|
||||
and isonline = #{map.isonline}
|
||||
</select>
|
||||
</mapper>
|
||||
|
@ -3,6 +3,9 @@ package com.fuint.business.marketingActivity.activeConsumption.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.fuint.business.marketingActivity.activeConsumption.entity.ActiveConsumptionRecord;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 消费有礼记录表(ActiveConsumptionRecord)表服务接口
|
||||
*
|
||||
@ -11,5 +14,8 @@ import com.fuint.business.marketingActivity.activeConsumption.entity.ActiveConsu
|
||||
*/
|
||||
public interface ActiveConsumptionRecordService extends IService<ActiveConsumptionRecord> {
|
||||
|
||||
// 自定义条件查询
|
||||
List<ActiveConsumptionRecord> selectByMap(Map<String, Object> map);
|
||||
|
||||
}
|
||||
|
||||
|
@ -8,9 +8,11 @@ import com.fuint.business.marketingActivity.activeConsumption.entity.ActiveConsu
|
||||
import com.fuint.business.marketingActivity.activeConsumption.entity.ActiveConsumptionChild;
|
||||
import com.fuint.business.marketingActivity.activeConsumption.vo.ActiveConsumptionAppletVO;
|
||||
import com.fuint.business.marketingActivity.activeConsumption.vo.ActiveConsumptionVO;
|
||||
import com.fuint.business.marketingActivity.activeConsumption.vo.ActiveConsumptionVOS;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 消费有礼活动(ActiveConsumption)表服务接口
|
||||
@ -97,5 +99,11 @@ public interface ActiveConsumptionService extends IService<ActiveConsumption> {
|
||||
* @return
|
||||
*/
|
||||
ActiveConsumption selectById(Integer id);
|
||||
/**
|
||||
*
|
||||
* 自定义条件查询
|
||||
*/
|
||||
List<ActiveConsumptionVOS> selectByMap(Map<String, Object> map);
|
||||
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,9 @@ import com.fuint.business.marketingActivity.activeConsumption.mapper.ActiveConsu
|
||||
import com.fuint.business.marketingActivity.activeConsumption.service.ActiveConsumptionRecordService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 消费有礼记录表(ActiveConsumptionRecord)表服务实现类
|
||||
*
|
||||
@ -16,5 +19,9 @@ import org.springframework.stereotype.Service;
|
||||
@Service("activeConsumptionRecordService")
|
||||
public class ActiveConsumptionRecordServiceImpl extends ServiceImpl<ActiveConsumptionRecordMapper, ActiveConsumptionRecord> implements ActiveConsumptionRecordService {
|
||||
|
||||
@Override
|
||||
public List<ActiveConsumptionRecord> selectByMap(Map<String, Object> map) {
|
||||
return baseMapper.selectByMap(map);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,10 +51,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import javax.annotation.Resource;
|
||||
import java.io.Serializable;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -597,6 +594,7 @@ public class ActiveConsumptionServiceImpl extends ServiceImpl<ActiveConsumptionM
|
||||
activeConsumption.setChainStorId(nowAccountInfo.getChainStoreId());
|
||||
activeConsumption.setStoreId(nowAccountInfo.getStoreId());
|
||||
activeConsumption.setIsonline("0");
|
||||
// 新增主表
|
||||
int row = baseMapper.insert(activeConsumption);
|
||||
// 插入子表信息
|
||||
if (ObjectUtil.isNotEmpty(activeConsumption.getPointList())){
|
||||
@ -644,6 +642,8 @@ public class ActiveConsumptionServiceImpl extends ServiceImpl<ActiveConsumptionM
|
||||
return row;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int updateActiveConsumption(ActiveConsumption activeConsumption) {
|
||||
int row = baseMapper.updateById(activeConsumption);
|
||||
@ -709,6 +709,12 @@ public class ActiveConsumptionServiceImpl extends ServiceImpl<ActiveConsumptionM
|
||||
return activeConsumption;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ActiveConsumptionVOS> selectByMap(Map<String, Object> map) {
|
||||
List<ActiveConsumptionVOS> activeConsumptionVOS = baseMapper.selectConsumptionsByMap(map);
|
||||
return activeConsumptionVOS;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数组转字符串
|
||||
* @param array
|
||||
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fuint.business.marketingActivity.activeConsumption.entity.ActiveConsumptionChild;
|
||||
import io.swagger.models.auth.In;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ -61,6 +62,40 @@ public class ActiveConsumptionVOS implements Serializable {
|
||||
private List<ActiveConsumptionChild> activeConsumptionChildList;
|
||||
//创建者
|
||||
private String createBy;
|
||||
//适用时间段类型:0每周、1每月
|
||||
private String suitTimeSlotType;
|
||||
//适用时间段:周/月
|
||||
private String suitDate;
|
||||
/**
|
||||
*活动时间类型:0永久有效;1自定义
|
||||
*/
|
||||
private String activityTimeType;
|
||||
/**
|
||||
*每人每天参与上限
|
||||
*/
|
||||
private Integer everyDayCeiling;
|
||||
/**
|
||||
*每人每月参与上限
|
||||
*/
|
||||
private Integer monthlyCeiling;
|
||||
/**
|
||||
*每人累计参与上限
|
||||
*/
|
||||
private Integer accumulateCeiling;
|
||||
/**
|
||||
*会员标签id
|
||||
*/
|
||||
private String userLabelIds;
|
||||
/**
|
||||
*适用时间段前
|
||||
*/
|
||||
@JsonFormat(pattern = "HH:mm", timezone = "GMT+8")
|
||||
private Date suitTimeSlotFront;
|
||||
/**
|
||||
*适用时间段后
|
||||
*/
|
||||
@JsonFormat(pattern = "HH:mm", timezone = "GMT+8")
|
||||
private Date suitTimeSlotAfter;
|
||||
//创建时间
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8")
|
||||
private Date createTime;
|
||||
|
@ -30,6 +30,7 @@ public class ActiveRecommendChild extends Model<ActiveRecommendChild> {
|
||||
private String activeGift;
|
||||
//礼品对象类型 0:邀请人获得 1:新用户获得
|
||||
private String giftUserType;
|
||||
// 使用说明
|
||||
private String instruction;
|
||||
//券id
|
||||
private Integer vouchersId;
|
||||
|
@ -0,0 +1,43 @@
|
||||
package com.fuint.business.marketingActivity.activeUserConsume.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
// 推荐会员消费有礼记录表
|
||||
@Data
|
||||
@TableName("active_user_consume_records")
|
||||
public class ActiveUserConsumeRecords {
|
||||
//主键id
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
//活动id
|
||||
private Integer activeUserConsumeId;
|
||||
//所属连锁店id
|
||||
private Integer chainStoreId;
|
||||
//所属店铺id
|
||||
private Integer storeId;
|
||||
//邀请人id
|
||||
private String userId;
|
||||
//被邀请人id
|
||||
private String inviteeUserId;
|
||||
//被邀请人姓名
|
||||
private String inviteeUserName;
|
||||
//
|
||||
private String remark;
|
||||
//来源
|
||||
private String type;
|
||||
//创建者
|
||||
private String createBy;
|
||||
//创建时间
|
||||
@JsonFormat(pattern = "yyyy-MM-dd ")
|
||||
private Date createTime;
|
||||
//更新者
|
||||
private String updateBy;
|
||||
//更新时间
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" , timezone = "GMT+8")
|
||||
private Date updateTime;
|
||||
}
|
@ -2,6 +2,14 @@ package com.fuint.business.marketingActivity.activeUserConsume.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.fuint.business.marketingActivity.activeUserConsume.entity.ActiveUserConsume;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface ActiveUserConsumeMapper extends BaseMapper<ActiveUserConsume> {
|
||||
|
||||
List<ActiveUserConsume> selectListByMap(@Param("map")Map<String, Object> map);
|
||||
}
|
||||
|
@ -0,0 +1,9 @@
|
||||
package com.fuint.business.marketingActivity.activeUserConsume.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.fuint.business.marketingActivity.activeUserConsume.entity.ActiveUserConsumeRecords;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface ActiveUserConsumeRecordsMapper extends BaseMapper<ActiveUserConsumeRecords> {
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.fuint.business.marketingActivity.activeUserConsume.mapper.ActiveUserConsumeMapper">
|
||||
|
||||
|
||||
<!-- 定义结果映射 -->
|
||||
<resultMap id="BaseResultMap"
|
||||
type="com.fuint.business.marketingActivity.activeUserConsume.entity.ActiveUserConsume">
|
||||
<id column="id" property="id" jdbcType="INTEGER"/>
|
||||
<result column="chain_store_id" property="chainStoreId" jdbcType="INTEGER"/>
|
||||
<result column="store_id" property="storeId" jdbcType="INTEGER"/>
|
||||
<result column="name" property="name" jdbcType="VARCHAR"/>
|
||||
<result column="active_time_type" property="activeTimeType" jdbcType="VARCHAR"/>
|
||||
<result column="active_start_time" property="activeStartTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="active_end_time" property="activeEndTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="frequency_limit" property="frequencyLimit" jdbcType="INTEGER"/>
|
||||
<result column="suit_oil_type" property="suitOilType" jdbcType="VARCHAR"/>
|
||||
<result column="suit_oil_ids" property="suitOilIds" jdbcType="VARCHAR"/>
|
||||
<result column="payment_type" property="paymentType" jdbcType="VARCHAR"/>
|
||||
<result column="user_grade_ids" property="userGradeIds" jdbcType="VARCHAR"/>
|
||||
<result column="courtesy_reward" property="courtesyReward" jdbcType="VARCHAR"/>
|
||||
<result column="points" property="points" jdbcType="INTEGER"/>
|
||||
<result column="growth_value" property="growthValue" jdbcType="INTEGER"/>
|
||||
<result column="isonline" property="isonline" jdbcType="VARCHAR"/>
|
||||
<result column="create_by" property="createBy" jdbcType="VARCHAR"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="update_by" property="updateBy" jdbcType="VARCHAR"/>
|
||||
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
||||
|
||||
<!-- 子表集合映射 -->
|
||||
<collection property="couponList"
|
||||
ofType="com.fuint.business.marketingActivity.activeUserConsume.entity.ActiveUserConsumeChild"
|
||||
column="id" select="selectChildren" fetchType="lazy"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 查询主表并关联子表 -->
|
||||
<select id="selectListByMap" resultMap="BaseResultMap" parameterType="Map">
|
||||
SELECT a.*, b.active_user_consume_id
|
||||
FROM active_user_consume a
|
||||
LEFT JOIN (
|
||||
SELECT active_user_consume_id,
|
||||
json_arrayagg(json_object('id', id, 'vouchers_id', vouchers_id, 'gift_card_total',
|
||||
gift_card_total)) AS couponList
|
||||
FROM active_user_consume_child
|
||||
GROUP BY active_user_consume_id
|
||||
) b ON a.id = b.active_user_consume_id
|
||||
<where>
|
||||
<foreach collection="map" item="value" index="key" open="" close="" separator=" AND ">
|
||||
${key} = #{value}
|
||||
</foreach>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!-- 查询子表 -->
|
||||
<select id="selectChildren"
|
||||
resultType="com.fuint.business.marketingActivity.activeUserConsume.entity.ActiveUserConsumeChild">
|
||||
SELECT id,
|
||||
active_user_consume_id,
|
||||
vouchers_id,
|
||||
gift_card_total,
|
||||
create_by,
|
||||
create_time,
|
||||
update_by,
|
||||
update_time
|
||||
FROM active_user_consume_child
|
||||
WHERE active_user_consume_id = #{activeUserConsumeId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.fuint.business.marketingActivity.activeUserConsume.mapper.ActiveUserConsumeRecordsMapper">
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</mapper>
|
@ -0,0 +1,7 @@
|
||||
package com.fuint.business.marketingActivity.activeUserConsume.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.fuint.business.marketingActivity.activeUserConsume.entity.ActiveUserConsumeRecords;
|
||||
|
||||
public interface ActiveUserConsumeRecordsService extends IService<ActiveUserConsumeRecords> {
|
||||
}
|
@ -4,6 +4,9 @@ import com.fuint.business.marketingActivity.activeUserConsume.entity.ActiveUserC
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 推荐会员消费有礼(ActiveUserConsume)表服务接口
|
||||
*
|
||||
@ -12,6 +15,8 @@ import org.springframework.data.domain.PageRequest;
|
||||
*/
|
||||
public interface ActiveUserConsumeService {
|
||||
|
||||
// 自定义条件查询 并返回子对象
|
||||
List<ActiveUserConsume> selectListByMap(Map<String,Object> map);
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
|
@ -0,0 +1,12 @@
|
||||
package com.fuint.business.marketingActivity.activeUserConsume.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fuint.business.marketingActivity.activeUserConsume.entity.ActiveUserConsumeRecords;
|
||||
import com.fuint.business.marketingActivity.activeUserConsume.mapper.ActiveUserConsumeRecordsMapper;
|
||||
import com.fuint.business.marketingActivity.activeUserConsume.service.ActiveUserConsumeRecordsService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class ActiveUserConsumeRecordsServiceImpl extends ServiceImpl<ActiveUserConsumeRecordsMapper, ActiveUserConsumeRecords> implements ActiveUserConsumeRecordsService {
|
||||
|
||||
}
|
@ -12,11 +12,13 @@ import com.fuint.business.marketingActivity.activeUserConsume.service.ActiveUser
|
||||
import com.fuint.business.marketingActivity.activeUserConsume.service.ActiveUserConsumeService;
|
||||
import com.fuint.common.dto.AccountInfo;
|
||||
import com.fuint.common.util.TokenUtil;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 推荐会员消费有礼(ActiveUserConsume)表服务实现类
|
||||
@ -31,6 +33,14 @@ public class ActiveUserConsumeServiceImpl extends ServiceImpl<ActiveUserConsumeM
|
||||
private ActiveUserConsumeChildService activeUserConsumeChildService;
|
||||
@Autowired
|
||||
private ActiveAppletService activeAppletService;
|
||||
@Autowired
|
||||
private ActiveUserConsumeMapper activeUserConsumeMapper;
|
||||
|
||||
@Override
|
||||
public List<ActiveUserConsume> selectListByMap(Map<String, Object> map) {
|
||||
|
||||
return activeUserConsumeMapper.selectListByMap(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
|
@ -1,6 +1,9 @@
|
||||
package com.fuint.business.marketingActivity.cardCoupon.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
@ -17,6 +20,7 @@ import java.io.Serializable;
|
||||
@Data
|
||||
public class CardCouponUser extends Model<CardCouponUser> {
|
||||
//主键id
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Integer id;
|
||||
//所属连锁店id
|
||||
private Integer chainStoreId;
|
||||
|
@ -24,6 +24,8 @@ public interface CardCouponService extends IService<CardCoupon> {
|
||||
|
||||
IPage selectAllByPageAndStoreId(Page page, CardCoupon cardCoupon);
|
||||
|
||||
|
||||
CardCoupon selectOneBuId(Integer id);
|
||||
/**
|
||||
* 卡券详情(小程序)
|
||||
* @param id
|
||||
|
@ -10,6 +10,7 @@ import io.swagger.models.auth.In;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 用户优惠卷表2024(CardCouponUser)表服务接口
|
||||
@ -18,6 +19,10 @@ import java.util.List;
|
||||
* @since 2024-09-22 15:14:30
|
||||
*/
|
||||
public interface CardCouponUserService extends IService<CardCouponUser> {
|
||||
|
||||
|
||||
List<CardCouponUser> selectByMap(Map<String,Object> map);
|
||||
|
||||
/**
|
||||
* 判断用户是否还能领取该优惠卷
|
||||
* @param couponId 优惠卷id
|
||||
|
@ -119,6 +119,11 @@ public class CardCouponServiceImpl extends ServiceImpl<CardCouponMapper, CardCou
|
||||
return cardCouponUniVoIPage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CardCoupon selectOneBuId(Integer id) {
|
||||
return baseMapper.selectById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 卡券详情(小程序)
|
||||
*
|
||||
|
@ -21,6 +21,7 @@ import org.springframework.stereotype.Service;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 用户优惠卷表2024(CardCouponUser)表服务实现类
|
||||
@ -35,6 +36,11 @@ public class CardCouponUserServiceImpl extends ServiceImpl<CardCouponUserMapper,
|
||||
@Autowired
|
||||
private CardCouponUserMapper cardCouponUserMapper;
|
||||
|
||||
@Override
|
||||
public List<CardCouponUser> selectByMap(Map<String, Object> map) {
|
||||
return baseMapper.selectByMap(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断用户是否还能领取该优惠卷
|
||||
*
|
||||
|
@ -24,6 +24,7 @@ public class CardExchange extends Model<CardExchange> {
|
||||
private Integer id;
|
||||
//所属连锁店id
|
||||
private Integer chainStorId;
|
||||
// 商品id
|
||||
private Integer giftId;
|
||||
//所属店铺id
|
||||
private Integer storeId;
|
||||
|
@ -10,6 +10,7 @@ import com.fuint.business.order.dto.AllOrderInfoDto;
|
||||
import com.fuint.business.order.entity.AllOrderInfo;
|
||||
import com.fuint.business.order.entity.CardBalanceChange;
|
||||
import com.fuint.business.order.entity.HandoverRecord;
|
||||
import com.fuint.business.order.vo.AllOrderActivityVo;
|
||||
import com.fuint.business.order.vo.AllOrderInfoUniVo;
|
||||
import com.fuint.business.order.vo.AllOrderInfoVo;
|
||||
import com.fuint.business.order.vo.CardBalanceChangeVo;
|
||||
@ -62,6 +63,7 @@ public interface AllOrderInfoMapper extends BaseMapper<AllOrderInfo> {
|
||||
AllOrderInfoVo getHandoverByOrderNo(@Param("allOrderInfo") AllOrderInfo allOrderInfo);
|
||||
|
||||
|
||||
AllOrderActivityVo getOneByOrderId(@Param("orderId") Integer orderId);
|
||||
/**
|
||||
* 根据支付状态查询订单笔数
|
||||
*
|
||||
|
@ -729,7 +729,7 @@
|
||||
count(CASE WHEN payment_channel = '拉卡拉' THEN 1 ELSE 0 END) AS laKaLaCount
|
||||
from all_order_info
|
||||
where
|
||||
store_id = #{order.storeId}
|
||||
store_id = #{order.storeId}
|
||||
<if test="order.beginTime != null and order.beginTime != ''"><!-- 开始时间检索 -->
|
||||
and date_format(create_time,'%y%m%d') >= date_format(#{order.beginTime},'%y%m%d')
|
||||
</if>
|
||||
@ -776,6 +776,14 @@
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="getOneByOrderId" resultType="com.fuint.business.order.vo.AllOrderActivityVo">
|
||||
SELECT info.*,
|
||||
oil.oil_num as shengshu,
|
||||
oil.oils as oils
|
||||
FROM all_order_info info
|
||||
Left JOIN oil_order oil ON info.order_no = oil.order_no
|
||||
where info.id = #{orderId}
|
||||
</select>
|
||||
|
||||
<!-- <where>-->
|
||||
<!-- store_id = #{order.storeId}-->
|
||||
|
@ -7,6 +7,7 @@ import com.fuint.business.order.dto.AllOrderInfoDto;
|
||||
import com.fuint.business.order.entity.AllOrderInfo;
|
||||
import com.fuint.business.order.entity.CashierOrder;
|
||||
import com.fuint.business.order.entity.HandoverRecord;
|
||||
import com.fuint.business.order.vo.AllOrderActivityVo;
|
||||
import com.fuint.business.order.vo.AllOrderInfoUniVo;
|
||||
import com.fuint.business.order.vo.AllOrderInfoVo;
|
||||
import com.fuint.business.order.vo.CardBalanceChangeVo;
|
||||
@ -159,4 +160,8 @@ public interface AllOrderInfoService {
|
||||
* @return
|
||||
*/
|
||||
IPage<AllOrderInfoUniVo> queryByPageUni(Page page, AllOrderInfo allOrderInfo);
|
||||
|
||||
// 根据订单id 查询订单 并且有且只有一个关联油品订单
|
||||
AllOrderActivityVo getOneByOrderId(Integer orderId);
|
||||
|
||||
}
|
||||
|
@ -30,6 +30,14 @@ public interface GrowthValueChangeService {
|
||||
*/
|
||||
public int insertGrowthValueChange(GrowthValueChange growthValueChange);
|
||||
|
||||
|
||||
/**
|
||||
* 添加成长值变化记录信息(活动专用 消费有礼 推荐消费有礼)
|
||||
* @param growthValueChange
|
||||
* @return
|
||||
*/
|
||||
public int insertGrowthValueChangeActive(GrowthValueChange growthValueChange);
|
||||
|
||||
/**
|
||||
* 修改成长值变化记录信息
|
||||
* @param growthValueChange
|
||||
|
@ -25,11 +25,8 @@ import com.fuint.business.order.mapper.AllOrderInfoMapper;
|
||||
import com.fuint.business.order.mapper.OilOrderMapper;
|
||||
import com.fuint.business.order.mapper.OrderGoodsMapper;
|
||||
import com.fuint.business.order.service.*;
|
||||
import com.fuint.business.order.vo.AllOrderInfoUniVo;
|
||||
import com.fuint.business.order.vo.AllOrderInfoVo;
|
||||
import com.fuint.business.order.vo.*;
|
||||
import com.fuint.business.order.vo.Excel.*;
|
||||
import com.fuint.business.order.vo.OilOrderVo;
|
||||
import com.fuint.business.order.vo.OrderGoodsVo;
|
||||
import com.fuint.business.petrolStationManagement.entity.OilGun;
|
||||
import com.fuint.business.petrolStationManagement.entity.OilName;
|
||||
import com.fuint.business.petrolStationManagement.entity.OilTracking;
|
||||
@ -1679,6 +1676,12 @@ public class AllOrderInfoServiceImpl extends ServiceImpl<AllOrderInfoMapper, All
|
||||
return this.allOrderInfoMapper.queryAllByLimit(page, allOrderInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AllOrderActivityVo getOneByOrderId(Integer orderId) {
|
||||
AllOrderActivityVo allOrderInfoVo = allOrderInfoMapper.getOneByOrderId(orderId);
|
||||
return allOrderInfoVo;
|
||||
}
|
||||
|
||||
|
||||
private long dayCount(String beginTimeStr, String endTimeStr) {
|
||||
// 将字符串表示的时间转换成 LocalDate 对象
|
||||
|
@ -51,7 +51,9 @@ public class GrowthValueChangeServiceImpl extends ServiceImpl<GrowthValueChangeM
|
||||
GrowthValueChange growthValueChange1 = baseMapper.selectOne(queryWrapper);
|
||||
if (ObjectUtil.isNotEmpty(growthValueChange1)){
|
||||
Integer growthValue = growthValueChange1.getGrowthValue();
|
||||
// 成长值变化值 = 老值 + 新的变化值
|
||||
growthValueChange1.setGrowthValue(growthValue+growthValueChange.getGrowthValue());
|
||||
// 更新后值
|
||||
growthValueChange1.setAfterTheChange(growthValueChange.getAfterTheChange());
|
||||
row = baseMapper.updateById(growthValueChange1);
|
||||
}else {
|
||||
@ -60,6 +62,10 @@ public class GrowthValueChangeServiceImpl extends ServiceImpl<GrowthValueChangeM
|
||||
return row;
|
||||
}
|
||||
|
||||
public int insertGrowthValueChangeActive(GrowthValueChange growthValueChange){
|
||||
return baseMapper.insert(growthValueChange);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateGrowthValueChange(GrowthValueChange growthValueChange) {
|
||||
return baseMapper.updateById(growthValueChange);
|
||||
|
@ -0,0 +1,13 @@
|
||||
package com.fuint.business.order.vo;
|
||||
|
||||
import com.fuint.business.order.entity.AllOrderInfo;
|
||||
import lombok.Data;
|
||||
|
||||
// 消费有礼 查询订单 专用 vo
|
||||
@Data
|
||||
public class AllOrderActivityVo extends AllOrderInfo {
|
||||
// 加油升数
|
||||
private Double shengshu;
|
||||
// 油号id
|
||||
private String oils;
|
||||
}
|
@ -7,6 +7,7 @@ import com.fuint.business.userManager.entity.MtInvitation;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 邀请注册表(MtInvitation)表数据库访问层
|
||||
@ -24,6 +25,8 @@ public interface MtInvitationMapper extends BaseMapper<MtInvitation> {
|
||||
*/
|
||||
MtInvitation queryById(Integer id);
|
||||
|
||||
List<MtInvitation> selectListByMap(@Param("map") Map<String, Object> map);
|
||||
|
||||
MtInvitation queryByStoreId(@Param("storeId") Integer storeId,@Param("userId") Integer userId);
|
||||
|
||||
|
||||
|
@ -110,6 +110,19 @@
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectListByMap" resultType="com.fuint.business.userManager.entity.MtInvitation" parameterType="map">
|
||||
select
|
||||
id, userId, storeId, inviterId, staffId,chain_store_id, status, create_time, create_by, update_time, update_by
|
||||
from mt_invitation
|
||||
<where>
|
||||
<foreach collection="map" item="value" index="key" open="" close="" separator=" AND ">
|
||||
<if test="value != null and value != ''">
|
||||
${key} = #{value}
|
||||
</if>
|
||||
</foreach>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!--新增所有列-->
|
||||
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into mt_invitation(userId, storeId, inviterId, staffId,chain_store_id, status, create_time, create_by, update_time, update_by)
|
||||
|
@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fuint.business.userManager.entity.MtInvitation;
|
||||
import io.lettuce.core.dynamic.annotation.Param;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 邀请注册表(MtInvitation)表服务接口
|
||||
@ -14,6 +16,9 @@ import io.lettuce.core.dynamic.annotation.Param;
|
||||
*/
|
||||
public interface MtInvitationService {
|
||||
|
||||
// 自定义查询
|
||||
MtInvitation getOneByMap(Map<String,Object> map);
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
|
@ -14,6 +14,8 @@ import com.fuint.common.dto.AccountInfo;
|
||||
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 邀请注册表(MtInvitation)表服务实现类
|
||||
@ -26,6 +28,16 @@ public class MtInvitationServiceImpl implements MtInvitationService {
|
||||
@Resource
|
||||
private MtInvitationMapper mtInvitationMapper;
|
||||
|
||||
@Override
|
||||
public MtInvitation getOneByMap(Map<String, Object> map) {
|
||||
|
||||
List<MtInvitation> mtInvitations = mtInvitationMapper.selectListByMap(map);
|
||||
if(mtInvitations.size() == 0){
|
||||
return null;
|
||||
}
|
||||
return mtInvitations.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
|
@ -195,4 +195,32 @@ public class DateUtil {
|
||||
cal.set(Calendar.SECOND, 59);
|
||||
return cal.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 获取当天 0点 0时0分 0秒
|
||||
*/
|
||||
public static Date getTodayMidnight() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 获取明天 0点 0时0分 0秒
|
||||
*/
|
||||
|
||||
public static Date getTomorrowMidnight() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.add(Calendar.DAY_OF_MONTH, 1); // 增加一天
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
return calendar.getTime();
|
||||
}
|
||||
}
|
||||
|
@ -50,5 +50,20 @@ public class PayCenterController extends BaseController {
|
||||
logger.info("收银台获取可用优惠券参数:{}", map);
|
||||
return getSuccessResult("查询成功",payCenterService.getCoupon(map));
|
||||
}
|
||||
/**
|
||||
* 收银台支付成功后 消费有礼
|
||||
* @date 12:01 2024/9/19
|
||||
* @param map 请求参数
|
||||
* @param request
|
||||
* @return com.fuint.framework.web.ResponseObject
|
||||
**/
|
||||
@PostMapping("/cashRegisterSpendWisely")
|
||||
public ResponseObject cashRegisterSpendWisely(@RequestBody Map<String,String> map,HttpServletRequest request) throws Exception {
|
||||
map.put("storeId","157");
|
||||
map.put("userId","309");
|
||||
map.put("orderId","2012");
|
||||
logger.info("收银台获取可用优惠券参数:{}", map);
|
||||
return getSuccessResult("查询成功",payCenterService.cashRegisterSpendWisely(map));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,4 +25,6 @@ public interface PayCenterService {
|
||||
* @return java.lang.Object
|
||||
**/
|
||||
Object getCoupon(Map<String,String> map);
|
||||
|
||||
Object cashRegisterSpendWisely(Map<String,String> map);
|
||||
}
|
||||
|
@ -1,11 +1,19 @@
|
||||
package com.fuint.pay.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateField;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alipay.api.domain.Inventory;
|
||||
import com.fuint.business.integral.entity.IntegralDetail;
|
||||
import com.fuint.business.integral.service.IntegralDetailService;
|
||||
import com.fuint.business.marketingActivity.activeConsumption.entity.ActiveConsumption;
|
||||
import com.fuint.business.marketingActivity.activeConsumption.entity.ActiveConsumptionChild;
|
||||
import com.fuint.business.marketingActivity.activeConsumption.entity.ActiveConsumptionRecord;
|
||||
import com.fuint.business.marketingActivity.activeConsumption.service.ActiveConsumptionRecordService;
|
||||
import com.fuint.business.marketingActivity.activeConsumption.service.ActiveConsumptionService;
|
||||
import com.fuint.business.marketingActivity.activeConsumption.vo.ActiveConsumptionVOS;
|
||||
import com.fuint.business.marketingActivity.activePrice.entity.ActivePriceRecord;
|
||||
import com.fuint.business.marketingActivity.activePrice.entity.ActivePriceRule;
|
||||
import com.fuint.business.marketingActivity.activePrice.entity.ActiveSubPrice;
|
||||
@ -15,15 +23,31 @@ import com.fuint.business.marketingActivity.activePrice.service.ActivePriceServi
|
||||
import com.fuint.business.marketingActivity.activePrice.service.ActiveSubPriceService;
|
||||
import com.fuint.business.marketingActivity.activePrice.vo.ActivePriceRuleRespVO;
|
||||
import com.fuint.business.marketingActivity.activePrice.vo.ActiveSubPriceRespVO;
|
||||
import com.fuint.business.marketingActivity.activeUserConsume.entity.ActiveUserConsume;
|
||||
import com.fuint.business.marketingActivity.activeUserConsume.entity.ActiveUserConsumeChild;
|
||||
import com.fuint.business.marketingActivity.activeUserConsume.entity.ActiveUserConsumeRecords;
|
||||
import com.fuint.business.marketingActivity.activeUserConsume.service.ActiveUserConsumeChildService;
|
||||
import com.fuint.business.marketingActivity.activeUserConsume.service.ActiveUserConsumeRecordsService;
|
||||
import com.fuint.business.marketingActivity.activeUserConsume.service.ActiveUserConsumeService;
|
||||
import com.fuint.business.marketingActivity.cardCoupon.entity.CardCoupon;
|
||||
import com.fuint.business.marketingActivity.cardCoupon.entity.CardCouponUser;
|
||||
import com.fuint.business.marketingActivity.cardCoupon.service.CardCouponService;
|
||||
import com.fuint.business.marketingActivity.cardCoupon.service.CardCouponUserService;
|
||||
import com.fuint.business.marketingActivity.cardCoupon.vo.CardCouponVO;
|
||||
import com.fuint.business.order.entity.AllOrderInfo;
|
||||
import com.fuint.business.order.entity.GrowthValueChange;
|
||||
import com.fuint.business.order.service.AllOrderInfoService;
|
||||
import com.fuint.business.order.service.GrowthValueChangeService;
|
||||
import com.fuint.business.order.vo.AllOrderActivityVo;
|
||||
import com.fuint.business.order.vo.AllOrderInfoVo;
|
||||
import com.fuint.business.userGroup.entity.UserDiscount;
|
||||
import com.fuint.business.userGroup.service.UserDiscountService;
|
||||
import com.fuint.business.userManager.entity.MtInvitation;
|
||||
import com.fuint.business.userManager.entity.UserBalance;
|
||||
import com.fuint.business.userManager.service.MtInvitationService;
|
||||
import com.fuint.business.userManager.service.UserBalanceService;
|
||||
import com.fuint.common.dto.AccountInfo;
|
||||
import com.fuint.common.util.DateUtil;
|
||||
import com.fuint.common.util.StringUtils;
|
||||
import com.fuint.common.util.TokenUtil;
|
||||
import com.fuint.module.AlipayApi.service.impl.AlipayServiceImpl1;
|
||||
@ -37,10 +61,14 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import weixin.popular.bean.pay.OrderInfo;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
@Service
|
||||
public class PayCenterServiceImpl implements PayCenterService {
|
||||
private static final Logger logger = LoggerFactory.getLogger(PayCenterServiceImpl.class);
|
||||
@ -58,6 +86,27 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
private UserDiscountService userDiscountService;
|
||||
@Autowired
|
||||
private CardCouponUserService cardCouponUserService;
|
||||
@Autowired
|
||||
private ActiveConsumptionService activeConsumptionService;
|
||||
@Autowired
|
||||
private ActiveConsumptionRecordService activeConsumptionRecordService;
|
||||
@Autowired
|
||||
private AllOrderInfoService allOrderInfoService;
|
||||
@Autowired
|
||||
private IntegralDetailService integralDetailService;
|
||||
@Autowired
|
||||
private GrowthValueChangeService growthValueChangeService;
|
||||
@Autowired
|
||||
private CardCouponService cardCouponService;
|
||||
@Autowired
|
||||
private MtInvitationService mtInvitationService;
|
||||
@Autowired
|
||||
private ActiveUserConsumeService activeUserConsumeService;
|
||||
@Autowired
|
||||
private ActiveUserConsumeRecordsService activeUserConsumeRecordsService;
|
||||
@Autowired
|
||||
private ActiveUserConsumeChildService activeUserConsumeChildService;
|
||||
|
||||
/**
|
||||
* 收银台获取可用优惠券和可以参加的优惠活动
|
||||
*
|
||||
@ -69,7 +118,7 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
@Override
|
||||
public Object getActivity(Map<String, String> map) {
|
||||
//实际会收钱的支付方式
|
||||
List<String> canUsePayWays = Arrays.asList("ALIPAY","WECHAT","UNIONPAY","CASH");
|
||||
List<String> canUsePayWays = Arrays.asList("ALIPAY", "WECHAT", "UNIONPAY", "CASH");
|
||||
/*1.先把所有用到的值取出来 */
|
||||
//当前时间,从点击结算的这一刻算
|
||||
Date nowDate = new Date();
|
||||
@ -78,8 +127,8 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
Integer storeId = nowAccountInfo.getStoreId();
|
||||
int userId = Integer.parseInt(map.get("userId"));
|
||||
//查会员等级
|
||||
UserBalance userBalance = userBalanceService.selectUserBalanceByStorId(userId,storeId);
|
||||
if(null==userBalance){
|
||||
UserBalance userBalance = userBalanceService.selectUserBalanceByStorId(userId, storeId);
|
||||
if (null == userBalance) {
|
||||
//非会员,不能参加任何活动
|
||||
return new ArrayList<>();
|
||||
}
|
||||
@ -87,9 +136,9 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
int gradeId = userBalance.getGradeId();
|
||||
//会员标签,会有多个,一个集和
|
||||
List<Integer> labelIdList = new ArrayList<>();
|
||||
if(StringUtils.isNotEmpty(userBalance.getUserLabelId())){
|
||||
if (StringUtils.isNotEmpty(userBalance.getUserLabelId())) {
|
||||
List<String> labelIdStrList = Arrays.asList(userBalance.getUserLabelId().split(StrUtil.COMMA));
|
||||
labelIdStrList.forEach(str->labelIdList.add(Integer.parseInt(str)));
|
||||
labelIdStrList.forEach(str -> labelIdList.add(Integer.parseInt(str)));
|
||||
}
|
||||
//油号id
|
||||
Integer oilId = Integer.valueOf(map.get("oilId"));
|
||||
@ -105,98 +154,99 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
String payWay = map.get("payWay");
|
||||
/*2.查询所有可参加的营销活动 */
|
||||
List<ActivityVO> actList = new ArrayList<>();
|
||||
if(!canUsePayWays.contains(payWay)){
|
||||
if (!canUsePayWays.contains(payWay)) {
|
||||
//所选支付方式不符合活动参与条件
|
||||
return actList;
|
||||
}
|
||||
try {
|
||||
//2.1 查可参加的分时优惠和限时特价
|
||||
actList.addAll(this.getFenshiAndTejiaAct(nowDate,userId,gradeId,storeId,labelIdList,oilAmount,oilLiter,oilId,oilPrice,payWay));
|
||||
}catch (Exception e){
|
||||
actList.addAll(this.getFenshiAndTejiaAct(nowDate, userId, gradeId, storeId, labelIdList, oilAmount, oilLiter, oilId, oilPrice, payWay));
|
||||
} catch (Exception e) {
|
||||
//测试用,数据问题先忽略
|
||||
System.out.println("分时优惠和限时特价"+e);
|
||||
System.out.println("分时优惠和限时特价" + e);
|
||||
}
|
||||
try {
|
||||
//2.2 查可参加的立减营销
|
||||
actList.addAll(this.getLijianAct(nowDate,userId,gradeId,storeId,labelIdList,oilAmount,oilLiter,oilId,payWay));
|
||||
}catch (Exception e){
|
||||
actList.addAll(this.getLijianAct(nowDate, userId, gradeId, storeId, labelIdList, oilAmount, oilLiter, oilId, payWay));
|
||||
} catch (Exception e) {
|
||||
//测试用,数据问题先忽略
|
||||
System.out.println("立减营销"+e);
|
||||
System.out.println("立减营销" + e);
|
||||
}
|
||||
try {
|
||||
//2.3 查可参加的折扣营销(会员折扣)
|
||||
actList.addAll(this.getZhekouAct(nowDate,gradeId,storeId,oilAmount,payWay));
|
||||
}catch (Exception e){
|
||||
actList.addAll(this.getZhekouAct(nowDate, gradeId, storeId, oilAmount, payWay));
|
||||
} catch (Exception e) {
|
||||
//测试用,数据问题先忽略
|
||||
e.printStackTrace();
|
||||
System.out.println("折扣营销"+e);
|
||||
System.out.println("折扣营销" + e);
|
||||
}
|
||||
return actList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前会员可以参加的分时优惠和限时特价活动
|
||||
*
|
||||
* @param nowDate 结算那一刻的时间
|
||||
* @param userId 用户Id
|
||||
* @param gradeId 会员等级
|
||||
* @param storeId 店铺id
|
||||
* @param labelIdList 会员标签id集和
|
||||
* @param oilAmount 当前加油金额
|
||||
* @param oilLiter 当前加油升数
|
||||
* @param oilId 当前加油选择的油号id
|
||||
* @param oilPrice 油单价
|
||||
* @param payWay 支付方式
|
||||
* @return java.util.List<com.fuint.pay.vo.ActivityVO>
|
||||
* @author vinjor-M
|
||||
* @date 10:15 2024/9/21
|
||||
* @param nowDate 结算那一刻的时间
|
||||
* @param userId 用户Id
|
||||
* @param gradeId 会员等级
|
||||
* @param storeId 店铺id
|
||||
* @param labelIdList 会员标签id集和
|
||||
* @param oilAmount 当前加油金额
|
||||
* @param oilLiter 当前加油升数
|
||||
* @param oilId 当前加油选择的油号id
|
||||
* @param oilPrice 油单价
|
||||
* @param payWay 支付方式
|
||||
* @return java.util.List<com.fuint.pay.vo.ActivityVO>
|
||||
**/
|
||||
private List<ActivityVO> getFenshiAndTejiaAct(Date nowDate,Integer userId,Integer gradeId,Integer storeId,
|
||||
List<Integer> labelIdList,Double oilAmount,Double oilLiter,
|
||||
Integer oilId,Double oilPrice,String payWay){
|
||||
**/
|
||||
private List<ActivityVO> getFenshiAndTejiaAct(Date nowDate, Integer userId, Integer gradeId, Integer storeId,
|
||||
List<Integer> labelIdList, Double oilAmount, Double oilLiter,
|
||||
Integer oilId, Double oilPrice, String payWay) {
|
||||
/*1.先查满足条件的所有生效中的活动规则*/
|
||||
List<ActivePriceRuleRespVO> activePriceRuleList = activePriceRuleService.selectAllAct(storeId, nowDate);
|
||||
/*2.进行初步过滤,这里只过滤活动硬性的限制*/
|
||||
List<ActivePriceRuleRespVO> filteredList = activePriceRuleList.stream()
|
||||
//适用当前会员等级的
|
||||
.filter(rule->rule.getLevelId().equals(gradeId.toString()))
|
||||
.filter(rule -> rule.getLevelId().equals(gradeId.toString()))
|
||||
//适用当前会员标签的
|
||||
.filter(rule->checkUtil.checkLabelId(rule.getBabelIds(),labelIdList))
|
||||
.filter(rule -> checkUtil.checkLabelId(rule.getBabelIds(), labelIdList))
|
||||
//适用当前加油金额或加油升数的
|
||||
.filter(rule -> checkUtil.checkConsume(rule,oilAmount,oilLiter))
|
||||
.filter(rule -> checkUtil.checkConsume(rule, oilAmount, oilLiter))
|
||||
//适用当前时间段的
|
||||
.filter(rule -> checkUtil.checkTime(rule.getTimeType(),rule.getTimeSlots(),rule.getDayStartTime(),rule.getDayEndTime(),nowDate))
|
||||
.filter(rule -> checkUtil.checkTime(rule.getTimeType(), rule.getTimeSlots(), rule.getDayStartTime(), rule.getDayEndTime(), nowDate))
|
||||
//适用当前油号的
|
||||
.filter(rule-> checkUtil.checkOil(rule.getOilList(),oilId))
|
||||
.filter(rule -> checkUtil.checkOil(rule.getOilList(), oilId))
|
||||
//适用当前支付方式的
|
||||
.filter(rule-> rule.getPaymentType().contains(payWay)).collect(Collectors.toList());
|
||||
if(filteredList.isEmpty()){
|
||||
.filter(rule -> rule.getPaymentType().contains(payWay)).collect(Collectors.toList());
|
||||
if (filteredList.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
/*3.再次过滤,这里过滤掉用户已经超出参加次数限制的*/
|
||||
//符合条件的活动规则,查询当前会员已经参与的记录,此处查分时特价和限时特价的
|
||||
List<String> actTypeList = Arrays.asList("1,2".split(StrUtil.COMMA));
|
||||
List<ActivePriceRecord> recordAllList = activePriceRecordService.selectListByUserIdAndActIds(userId,
|
||||
filteredList.stream().map(ActivePriceRuleRespVO::getId).collect(Collectors.toList()),null,actTypeList);
|
||||
if(!recordAllList.isEmpty()){
|
||||
filteredList.stream().map(ActivePriceRuleRespVO::getId).collect(Collectors.toList()), null, actTypeList);
|
||||
if (!recordAllList.isEmpty()) {
|
||||
filteredList = filteredList.stream()
|
||||
//过滤掉超过每日参加次数限制的
|
||||
.filter(rule -> checkUtil.checkUseNum(rule.getId(),rule.getDayLimitNum(),nowDate,recordAllList, "day"))
|
||||
.filter(rule -> checkUtil.checkUseNum(rule.getId(), rule.getDayLimitNum(), nowDate, recordAllList, "day"))
|
||||
//过滤掉超过累计参加次数限制的
|
||||
.filter(rule -> checkUtil.checkUseNum(rule.getId(),rule.getLimitNum(),null,recordAllList,null)).collect(Collectors.toList());
|
||||
.filter(rule -> checkUtil.checkUseNum(rule.getId(), rule.getLimitNum(), null, recordAllList, null)).collect(Collectors.toList());
|
||||
}
|
||||
/*4.得到用户最终可以参加的活动,计算优惠金额并转换成统一的对象*/
|
||||
List<ActivityVO> rtnList = new ArrayList<>();
|
||||
if(!filteredList.isEmpty()){
|
||||
for(ActivePriceRuleRespVO rule:filteredList){
|
||||
if (!filteredList.isEmpty()) {
|
||||
for (ActivePriceRuleRespVO rule : filteredList) {
|
||||
ActivityVO activityVO = new ActivityVO();
|
||||
activityVO.setId(rule.getActiveType()+"_"+rule.getActiveId()+"_"+rule.getId());
|
||||
activityVO.setId(rule.getActiveType() + "_" + rule.getActiveId() + "_" + rule.getId());
|
||||
activityVO.setActId(rule.getActiveId());
|
||||
activityVO.setRuleId(rule.getId());
|
||||
activityVO.setType(rule.getActiveType());
|
||||
activityVO.setActName(rule.getActiveTitle());
|
||||
activityVO.setRuleName(rule.getRuleName());
|
||||
activityVO.setPayTypes(rule.getPaymentType());
|
||||
activityVO.setDisAmount(checkUtil.computeDisAmount(rule,oilId,oilPrice,oilAmount,oilLiter));
|
||||
activityVO.setDisAmount(checkUtil.computeDisAmount(rule, oilId, oilPrice, oilAmount, oilLiter));
|
||||
rtnList.add(activityVO);
|
||||
}
|
||||
}
|
||||
@ -205,61 +255,62 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
|
||||
/**
|
||||
* 获取当前会员可以参加的立减营销活动
|
||||
*
|
||||
* @param nowDate 结算那一刻的时间
|
||||
* @param userId 用户Id
|
||||
* @param gradeId 会员等级
|
||||
* @param storeId 店铺id
|
||||
* @param labelIdList 会员标签id集和
|
||||
* @param oilAmount 当前加油金额
|
||||
* @param oilLiter 当前加油升数
|
||||
* @param oilId 当前加油选择的油号id
|
||||
* @param payWay 支付方式
|
||||
* @return java.util.List<com.fuint.pay.vo.ActivityVO>
|
||||
* @author vinjor-M
|
||||
* @date 17:28 2024/9/21
|
||||
* @param nowDate 结算那一刻的时间
|
||||
* @param userId 用户Id
|
||||
* @param gradeId 会员等级
|
||||
* @param storeId 店铺id
|
||||
* @param labelIdList 会员标签id集和
|
||||
* @param oilAmount 当前加油金额
|
||||
* @param oilLiter 当前加油升数
|
||||
* @param oilId 当前加油选择的油号id
|
||||
* @param payWay 支付方式
|
||||
* @return java.util.List<com.fuint.pay.vo.ActivityVO>
|
||||
**/
|
||||
private List<ActivityVO> getLijianAct(Date nowDate,Integer userId,Integer gradeId,Integer storeId,
|
||||
List<Integer> labelIdList,Double oilAmount,Double oilLiter,
|
||||
Integer oilId,String payWay){
|
||||
**/
|
||||
private List<ActivityVO> getLijianAct(Date nowDate, Integer userId, Integer gradeId, Integer storeId,
|
||||
List<Integer> labelIdList, Double oilAmount, Double oilLiter,
|
||||
Integer oilId, String payWay) {
|
||||
/*1.先查满足条件的所有生效中的活动规则*/
|
||||
List<ActiveSubPriceRespVO> activeSubPriceList = activeSubPriceService.selectAllAct(storeId,nowDate);
|
||||
List<ActiveSubPriceRespVO> activeSubPriceList = activeSubPriceService.selectAllAct(storeId, nowDate);
|
||||
/*2.进行初步过滤,这里只过滤活动硬性的限制*/
|
||||
List<ActiveSubPriceRespVO> filteredList = activeSubPriceList.stream()
|
||||
//适用当前会员等级的
|
||||
.filter(rule->Arrays.asList(rule.getLevelId().split(StrUtil.COMMA)).contains(gradeId.toString()))
|
||||
.filter(rule -> Arrays.asList(rule.getLevelId().split(StrUtil.COMMA)).contains(gradeId.toString()))
|
||||
//适用当前会员标签的
|
||||
.filter(rule->checkUtil.checkLabelId(rule.getBabelIds(),labelIdList))
|
||||
.filter(rule -> checkUtil.checkLabelId(rule.getBabelIds(), labelIdList))
|
||||
//适用当前时间段的
|
||||
.filter(rule -> checkUtil.checkTime(rule.getTimeType(),rule.getTimeSlots(),checkUtil.getTimeFromDate(rule.getTimeApplyStart()),checkUtil.getTimeFromDate(rule.getTimeApplyEnd()),nowDate))
|
||||
.filter(rule -> checkUtil.checkTime(rule.getTimeType(), rule.getTimeSlots(), checkUtil.getTimeFromDate(rule.getTimeApplyStart()), checkUtil.getTimeFromDate(rule.getTimeApplyEnd()), nowDate))
|
||||
//适用当前油号的
|
||||
.filter(rule-> checkUtil.checkOilLijian(rule.getApplyOilType(),rule.getApplyOil(),oilId))
|
||||
.filter(rule -> checkUtil.checkOilLijian(rule.getApplyOilType(), rule.getApplyOil(), oilId))
|
||||
//适用当前支付方式的
|
||||
.filter(rule-> rule.getPaymentType().contains(payWay)).collect(Collectors.toList());
|
||||
.filter(rule -> rule.getPaymentType().contains(payWay)).collect(Collectors.toList());
|
||||
/*3.再次过滤,这里过滤掉用户已经超出参加次数限制的*/
|
||||
//符合条件的活动规则,查询当前会员已经参与的记录,此处查立减营销的参与记录
|
||||
List<String> actTypeList = Arrays.asList("3".split(StrUtil.COMMA));
|
||||
List<ActivePriceRecord> recordAllList = activePriceRecordService.selectListByUserIdAndActIds(userId,
|
||||
null,filteredList.stream().map(ActiveSubPriceRespVO::getId).collect(Collectors.toList()),actTypeList);
|
||||
if(!recordAllList.isEmpty()){
|
||||
null, filteredList.stream().map(ActiveSubPriceRespVO::getId).collect(Collectors.toList()), actTypeList);
|
||||
if (!recordAllList.isEmpty()) {
|
||||
filteredList = filteredList.stream()
|
||||
//过滤掉超过每日参加次数限制的
|
||||
.filter(rule -> checkUtil.checkUseNum(rule.getId(),rule.getDayLimitNum(),nowDate,recordAllList,"day"))
|
||||
.filter(rule -> checkUtil.checkUseNum(rule.getId(), rule.getDayLimitNum(), nowDate, recordAllList, "day"))
|
||||
//过滤掉超过每月参加次数限制的
|
||||
.filter(rule -> checkUtil.checkUseNum(rule.getId(),rule.getMonthLimitNum(),nowDate,recordAllList,"month"))
|
||||
.filter(rule -> checkUtil.checkUseNum(rule.getId(), rule.getMonthLimitNum(), nowDate, recordAllList, "month"))
|
||||
//过滤掉超过累计参加次数限制的
|
||||
.filter(rule -> checkUtil.checkUseNum(rule.getId(),rule.getLimitNum(),null,recordAllList,null)).collect(Collectors.toList());
|
||||
.filter(rule -> checkUtil.checkUseNum(rule.getId(), rule.getLimitNum(), null, recordAllList, null)).collect(Collectors.toList());
|
||||
}
|
||||
/*4.得到用户最终可以参加的活动,计算优惠金额并转换成统一的对象*/
|
||||
List<ActivityVO> rtnList = new ArrayList<>();
|
||||
if(!filteredList.isEmpty()){
|
||||
for(ActiveSubPriceRespVO rule:filteredList){
|
||||
if (!filteredList.isEmpty()) {
|
||||
for (ActiveSubPriceRespVO rule : filteredList) {
|
||||
ActivityVO activityVO = new ActivityVO();
|
||||
activityVO.setId("3_"+rule.getId().toString());
|
||||
activityVO.setId("3_" + rule.getId().toString());
|
||||
activityVO.setActId(rule.getId());
|
||||
activityVO.setType("3");
|
||||
activityVO.setActName(rule.getActiveName());
|
||||
activityVO.setPayTypes(rule.getPaymentType());
|
||||
activityVO.setDisAmount(checkUtil.computeDisAmountLijian(rule,oilAmount,oilLiter));
|
||||
activityVO.setDisAmount(checkUtil.computeDisAmountLijian(rule, oilAmount, oilLiter));
|
||||
rtnList.add(activityVO);
|
||||
}
|
||||
}
|
||||
@ -268,51 +319,52 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
|
||||
/**
|
||||
* 获取当前会员可以参加的折扣营销活动
|
||||
*
|
||||
* @param nowDate 结算那一刻的时间
|
||||
* @param gradeId 会员等级
|
||||
* @param storeId 店铺id
|
||||
* @param oilAmount 当前加油金额
|
||||
* @param payWay 支付方式
|
||||
* @return java.util.List<com.fuint.pay.vo.ActivityVO>
|
||||
* @author vinjor-M
|
||||
* @date 11:46 2024/9/22
|
||||
* @param nowDate 结算那一刻的时间
|
||||
* @param gradeId 会员等级
|
||||
* @param storeId 店铺id
|
||||
* @param oilAmount 当前加油金额
|
||||
* @param payWay 支付方式
|
||||
* @return java.util.List<com.fuint.pay.vo.ActivityVO>
|
||||
**/
|
||||
private List<ActivityVO> getZhekouAct(Date nowDate,Integer gradeId,Integer storeId,Double oilAmount,String payWay){
|
||||
**/
|
||||
private List<ActivityVO> getZhekouAct(Date nowDate, Integer gradeId, Integer storeId, Double oilAmount, String payWay) {
|
||||
/*1.先查满足条件的所有生效中的活动规则*/
|
||||
List<UserDiscount> userDiscountList = userDiscountService.selectAllAct(storeId,nowDate);
|
||||
List<UserDiscount> userDiscountList = userDiscountService.selectAllAct(storeId, nowDate);
|
||||
/*2.进行初步过滤,这里只过滤活动硬性的限制*/
|
||||
List<UserDiscount> filteredList = userDiscountList.stream()
|
||||
//适用当前会员等级的
|
||||
.filter(rule->rule.getGradeId().equals(gradeId))
|
||||
.filter(rule -> rule.getGradeId().equals(gradeId))
|
||||
//节假日要求是否满足
|
||||
.filter(rule->checkUtil.checkTimeJiejiari(rule.getHolidayIsUse(),nowDate))
|
||||
.filter(rule -> checkUtil.checkTimeJiejiari(rule.getHolidayIsUse(), nowDate))
|
||||
//当前时间在 适用时间段内 或者 当前时间不在 不适用时间段内的
|
||||
.filter(rule ->this.checkTimeZhekouPrex(rule,nowDate))
|
||||
.filter(rule -> this.checkTimeZhekouPrex(rule, nowDate))
|
||||
//是否满足最低消费金额
|
||||
.filter(rule-> rule.getConsumeAmount() <=oilAmount)
|
||||
.filter(rule -> rule.getConsumeAmount() <= oilAmount)
|
||||
//适用当前支付方式的
|
||||
.filter(rule-> rule.getUsePaymentWay().contains(payWay)).collect(Collectors.toList());
|
||||
.filter(rule -> rule.getUsePaymentWay().contains(payWay)).collect(Collectors.toList());
|
||||
/*3.得到用户最终可以参加的活动,计算优惠金额并转换成统一的对象*/
|
||||
List<ActivityVO> rtnList = new ArrayList<>();
|
||||
if(!filteredList.isEmpty()){
|
||||
if (!filteredList.isEmpty()) {
|
||||
UserDiscount discount;
|
||||
if(filteredList.size()==1){
|
||||
if (filteredList.size() == 1) {
|
||||
discount = filteredList.get(0);
|
||||
}else{
|
||||
} else {
|
||||
//取折扣最大的,也就是折扣数值最小的,正序排列,取第一个
|
||||
discount = filteredList.stream().sorted(Comparator.comparingDouble(UserDiscount::getDiscount)).collect(Collectors.toList()).get(0);
|
||||
}
|
||||
ActivityVO activityVO = new ActivityVO();
|
||||
activityVO.setId("4_"+discount.getId().toString());
|
||||
activityVO.setId("4_" + discount.getId().toString());
|
||||
activityVO.setActId(discount.getId());
|
||||
activityVO.setType("4");
|
||||
activityVO.setActName("折扣营销");
|
||||
activityVO.setPayTypes(discount.getUsePaymentWay());
|
||||
//计算优惠金额
|
||||
double disAmount = 0.0;
|
||||
if(null!=discount.getDiscount()){
|
||||
Double newOilAmount = oilAmount*discount.getDiscount();
|
||||
disAmount = oilAmount-newOilAmount;
|
||||
if (null != discount.getDiscount()) {
|
||||
Double newOilAmount = oilAmount * discount.getDiscount();
|
||||
disAmount = oilAmount - newOilAmount;
|
||||
}
|
||||
activityVO.setDisAmount(disAmount);
|
||||
rtnList.add(activityVO);
|
||||
@ -322,26 +374,27 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
|
||||
/**
|
||||
* 营销折扣活动适用时间判断前置处理方法
|
||||
* @author vinjor-M
|
||||
* @date 13:57 2024/9/25
|
||||
* @param rule 规则对象
|
||||
*
|
||||
* @param rule 规则对象
|
||||
* @param nowDate 当前时间
|
||||
* @return java.lang.Boolean
|
||||
**/
|
||||
private Boolean checkTimeZhekouPrex(UserDiscount rule,Date nowDate){
|
||||
* @author vinjor-M
|
||||
* @date 13:57 2024/9/25
|
||||
**/
|
||||
private Boolean checkTimeZhekouPrex(UserDiscount rule, Date nowDate) {
|
||||
String startTimeStr;
|
||||
String endTimeStr;
|
||||
if("0".equals(rule.getAvailableOrUn())){
|
||||
if ("0".equals(rule.getAvailableOrUn())) {
|
||||
//适用时间
|
||||
startTimeStr = checkUtil.getTimeFromDate(rule.getSuitTimeSlotFront());
|
||||
endTimeStr = checkUtil.getTimeFromDate(rule.getSuitTimeSlotAfter());
|
||||
return checkUtil.checkTime(rule.getSuitTimeSlotType(),rule.getSuitDate(),startTimeStr,endTimeStr,nowDate);
|
||||
}else if("1".equals(rule.getAvailableOrUn())){
|
||||
return checkUtil.checkTime(rule.getSuitTimeSlotType(), rule.getSuitDate(), startTimeStr, endTimeStr, nowDate);
|
||||
} else if ("1".equals(rule.getAvailableOrUn())) {
|
||||
//不适用时间
|
||||
startTimeStr = checkUtil.getTimeFromDate(rule.getNoUseTimeFront());
|
||||
endTimeStr = checkUtil.getTimeFromDate(rule.getNoUseTimeAfter());
|
||||
return checkUtil.checkTimeReverse(rule.getNoUseTimeType(),rule.getNoUseDate(),startTimeStr,endTimeStr,nowDate);
|
||||
}else {
|
||||
return checkUtil.checkTimeReverse(rule.getNoUseTimeType(), rule.getNoUseDate(), startTimeStr, endTimeStr, nowDate);
|
||||
} else {
|
||||
//超出预设值范围,不可用
|
||||
return false;
|
||||
}
|
||||
@ -356,9 +409,9 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
* @date 14:24 2024/9/19
|
||||
**/
|
||||
@Override
|
||||
public Object getCoupon(Map<String, String> map){
|
||||
public Object getCoupon(Map<String, String> map) {
|
||||
//实际会收钱的支付方式
|
||||
List<String> canUsePayWays = Arrays.asList("ALIPAY","WECHAT","UNIONPAY","CASH");
|
||||
List<String> canUsePayWays = Arrays.asList("ALIPAY", "WECHAT", "UNIONPAY", "CASH");
|
||||
/*1.先把所有用到的值取出来 */
|
||||
//当前时间,从点击结算的这一刻算
|
||||
Date nowDate = new Date();
|
||||
@ -367,21 +420,21 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
Integer storeId = nowAccountInfo.getStoreId();
|
||||
int userId = Integer.parseInt(map.get("userId"));
|
||||
//油号id
|
||||
Integer oilId = Integer.valueOf(map.getOrDefault("oilId","99999"));
|
||||
Integer oilId = Integer.valueOf(map.getOrDefault("oilId", "99999"));
|
||||
//加油金额(不含商品金额)
|
||||
Double oilAmount = Double.valueOf(map.getOrDefault("oilAmount","0"));
|
||||
Double oilAmount = Double.valueOf(map.getOrDefault("oilAmount", "0"));
|
||||
//油升数
|
||||
Double oilLiter = Double.valueOf(map.getOrDefault("oilLiter","0"));
|
||||
Double oilLiter = Double.valueOf(map.getOrDefault("oilLiter", "0"));
|
||||
//支付方式
|
||||
String payWay = map.get("payWay");
|
||||
if("after_pay".equals(payWay)){
|
||||
if ("after_pay".equals(payWay)) {
|
||||
//挂账,不可以用优惠券
|
||||
return new ArrayList<>();
|
||||
}
|
||||
//选择的商品
|
||||
List<GoodsVO> goodsList = new ArrayList<>();
|
||||
String goodsStr = map.getOrDefault("goods","");
|
||||
if(StringUtils.isNotEmpty(goodsStr)){
|
||||
String goodsStr = map.getOrDefault("goods", "");
|
||||
if (StringUtils.isNotEmpty(goodsStr)) {
|
||||
JSONArray goodsArray = JSONUtil.parseArray(map.get("goods"));
|
||||
goodsList = goodsArray.toList(GoodsVO.class);
|
||||
}
|
||||
@ -391,31 +444,31 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
List<GoodsVO> finalGoodsList = goodsList;
|
||||
List<CardCouponVO> filteredList = couponVOList.stream()
|
||||
//当前时间在 适用时间段内 或者 当前时间不在 不适用时间段内的
|
||||
.filter(rule -> this.checkTimeCouponPrex(rule,nowDate))
|
||||
.filter(rule -> this.checkTimeCouponPrex(rule, nowDate))
|
||||
//如果是油品券,需要过滤出当前油品可用的
|
||||
.filter(rule -> checkUtil.checkOilCoupon(rule,oilId))
|
||||
.filter(rule -> checkUtil.checkOilCoupon(rule, oilId))
|
||||
//如果是油品券,需要过滤出达到满减条件的
|
||||
.filter(rule -> checkUtil.checkMaxCoupon(rule,oilAmount,oilLiter))
|
||||
.filter(rule -> checkUtil.checkMaxCoupon(rule, oilAmount, oilLiter))
|
||||
//如果是单品立减券,需要过滤出当前选择的商品可用且满足最低消费金额的
|
||||
.filter(rule-> checkUtil.checkGoodsCoupon(rule, finalGoodsList)).collect(Collectors.toList());
|
||||
if(filteredList.isEmpty()){
|
||||
.filter(rule -> checkUtil.checkGoodsCoupon(rule, finalGoodsList)).collect(Collectors.toList());
|
||||
if (filteredList.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
/*3.再次过滤,这里过滤掉用户已经超出参加次数限制的*/
|
||||
List<Integer> filteredCoupIdList = filteredList.stream().map(CardCoupon::getId).collect(Collectors.toList());
|
||||
//查出本用户这些优惠券的使用记录
|
||||
List<CardCouponUser> usedList = cardCouponUserService.selectListByUsed(userId,filteredCoupIdList);
|
||||
if(!usedList.isEmpty()){
|
||||
List<CardCouponUser> usedList = cardCouponUserService.selectListByUsed(userId, filteredCoupIdList);
|
||||
if (!usedList.isEmpty()) {
|
||||
//过滤
|
||||
filteredList = filteredList.stream()
|
||||
//过滤掉使用次数限制的
|
||||
.filter(rule->checkUtil.checkUseNumCoupon(rule.getId(),rule.getLimitTotalDay(), rule.getLimitTotalNum(), nowDate,usedList)).collect(Collectors.toList());
|
||||
.filter(rule -> checkUtil.checkUseNumCoupon(rule.getId(), rule.getLimitTotalDay(), rule.getLimitTotalNum(), nowDate, usedList)).collect(Collectors.toList());
|
||||
}
|
||||
/*4.得到用户最终可以使用的优惠券,计算优惠金额并转换成统一的对象*/
|
||||
List<CouponVO> rtnList = new ArrayList<>();
|
||||
if(!filteredList.isEmpty()){
|
||||
for(CardCouponVO rule:filteredList){
|
||||
if("0".equals(rule.getUseWithOther()) && !canUsePayWays.contains(payWay)){
|
||||
if (!filteredList.isEmpty()) {
|
||||
for (CardCouponVO rule : filteredList) {
|
||||
if ("0".equals(rule.getUseWithOther()) && !canUsePayWays.contains(payWay)) {
|
||||
//不可以与其他优惠同时用,且支付方式不是 实际付钱的,跳过
|
||||
break;
|
||||
}
|
||||
@ -425,35 +478,422 @@ public class PayCenterServiceImpl implements PayCenterService {
|
||||
couponVO.setName(rule.getName());
|
||||
couponVO.setUseWithOther(rule.getUseWithOther());
|
||||
//计算优惠金额
|
||||
couponVO.setDisAmount(checkUtil.computeDisAmountCoupon(rule,oilAmount,oilLiter));
|
||||
couponVO.setDisAmount(checkUtil.computeDisAmountCoupon(rule, oilAmount, oilLiter));
|
||||
rtnList.add(couponVO);
|
||||
}
|
||||
}
|
||||
return rtnList;
|
||||
}
|
||||
|
||||
// 消费有礼 屎山代码
|
||||
@Override
|
||||
public Object cashRegisterSpendWisely(Map<String, String> map) {
|
||||
// 订单id
|
||||
// 用户id
|
||||
// 店铺id
|
||||
// 1.查询当前用户在当前店铺的 会员信息
|
||||
UserBalance userBalance = userBalanceService.selectUserBalanceByStorId(Integer.parseInt(map.get("userId")), Integer.parseInt(map.get("storeId")));
|
||||
// 2.查询出 当前用户 在当前店铺 参与过的活动记录
|
||||
HashMap<String, Object> m1 = new HashMap<>();
|
||||
m1.put("user_id", map.get("userId"));
|
||||
m1.put("store_id", map.get("storeId"));
|
||||
List<ActiveConsumptionRecord> records = activeConsumptionRecordService.selectByMap(m1);
|
||||
// 3.查询出 当前店铺下 isonline=0 能用的所有活动 以及子活动对象
|
||||
HashMap<String, Object> m3 = new HashMap<>();
|
||||
m3.put("storeId", map.get("storeId"));
|
||||
m3.put("isonline", "0");
|
||||
List<ActiveConsumptionVOS> actives = activeConsumptionService.selectByMap(m3);
|
||||
// 4.查询出当前订单相关信息
|
||||
AllOrderActivityVo order = allOrderInfoService.getOneByOrderId(Integer.parseInt(map.get("orderId")));
|
||||
// 先排除所有时间条件
|
||||
Date nowDate = new Date();
|
||||
//会员标签,会有多个,一个集和
|
||||
List<Integer> labelIdList = new ArrayList<>();
|
||||
if (StringUtils.isNotEmpty(userBalance.getUserLabelId())) {
|
||||
List<String> labelIdStrList = Arrays.asList(userBalance.getUserLabelId().split(StrUtil.COMMA));
|
||||
labelIdStrList.forEach(str -> labelIdList.add(Integer.parseInt(str)));
|
||||
}
|
||||
// 过滤
|
||||
List<ActiveConsumptionVOS> f1 = actives.stream()
|
||||
// 过滤支付方式
|
||||
.filter(active -> checkUtil.checkPayWay(order.getPayType(), active.getPaymentType()))
|
||||
// 过滤 活动时间 以及 适用时间
|
||||
.filter(active -> this.checkTimeConsumptionPrex(active, nowDate))
|
||||
// 过滤会员标签
|
||||
.filter(active -> checkUtil.checkLabelId(active.getUserLabelIds(), labelIdList))
|
||||
// 过滤会员等级
|
||||
.filter(active -> checkUtil.checkGradeId(userBalance.getGradeId(), active.getDieselUserLevel()))
|
||||
// 过滤掉当前会员 没有参与次数的活动
|
||||
.filter(active -> checkUtil.checkRecordNum(active.getEveryDayCeiling(), active.getMonthlyCeiling(), active.getAccumulateCeiling(), records, active.getId()))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 然后根据过滤后的 活动主表 再去匹配子表
|
||||
for (ActiveConsumptionVOS active : f1) {
|
||||
|
||||
Boolean b1 = true;
|
||||
Boolean b2 = true;
|
||||
Boolean b3 = true;
|
||||
String str = "";
|
||||
for (ActiveConsumptionChild child : active.getActiveConsumptionChildList()) {
|
||||
// 先判断 订单是否包含油品 活动是否有油品活动 当前查询结果集的sql语句已经按照金额排序了 所以直接从头遍历即可 (并且保证一种活动类型 只能参与一次 并且是金额最高的一次)
|
||||
if (order.getShengshu() != null && child.getOrderType().equals("2") && b1 == true) {
|
||||
if (order.getShengshu() >= Double.parseDouble(child.getConsumeAmount())) {
|
||||
// 如果以上条件都满足那么用户成功参与了这个活动
|
||||
b1 = false;
|
||||
Boolean aBoolean = setActiveGift(child, userBalance, order);
|
||||
// 奖励发放成功 将此 活动奖励子表 id 拼接
|
||||
if (aBoolean) {
|
||||
str += child.getId() + ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
// 判断实收金额
|
||||
if (order.getPayMoney() != null && child.getOrderType().equals("1") && b2 == true) {
|
||||
if (order.getPayMoney() >= Double.parseDouble(child.getConsumeAmount())) {
|
||||
// 如果以上条件都满足那么用户成功参与了这个活动
|
||||
b2 = false;
|
||||
Boolean aBoolean = setActiveGift(child, userBalance, order);
|
||||
// 奖励发放成功 将此 活动奖励子表 id 拼接
|
||||
if (aBoolean) {
|
||||
str += child.getId() + ",";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
// 判断订单金额
|
||||
if (order.getGoodsMoney() != null && child.getOrderType().equals("0") && b3 == true) {
|
||||
if (order.getGoodsMoney() >= Double.parseDouble(child.getConsumeAmount())) {
|
||||
// 如果以上条件都满足那么用户成功参与了这个活动
|
||||
b3 = false;
|
||||
Boolean aBoolean = setActiveGift(child, userBalance, order);
|
||||
// 奖励发放成功 将此 活动奖励子表 id 拼接
|
||||
if (aBoolean) {
|
||||
str += child.getId() + ",";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 如果拼接后的 id 长度 >1 说明参与本活动了 新增 用户活动参与表
|
||||
if (str.length() > 1) {
|
||||
ActiveConsumptionRecord record = new ActiveConsumptionRecord();
|
||||
record.setActiveConsumptionId(active.getId());
|
||||
record.setUserId(userBalance.getMtUserId());
|
||||
record.setStoreId(userBalance.getStoreId());
|
||||
record.setActiveConsumptionChildIds(str);
|
||||
boolean save = activeConsumptionRecordService.save(record);
|
||||
}
|
||||
|
||||
}
|
||||
// 上面处理完 当前消费用户的赠送 下面处理 邀请人赠送
|
||||
HashMap<String, Object> m2 = new HashMap<>();
|
||||
m2.put("userId", userBalance.getMtUserId());
|
||||
m2.put("storeId", userBalance.getStoreId());
|
||||
MtInvitation invitation = mtInvitationService.getOneByMap(m2);
|
||||
// 当推荐人 不为null时 再去判断推荐人是否有资格参与活动
|
||||
if (invitation != null) {
|
||||
// 根据店铺id 和 邀请人id 查询出 邀请人会员信息
|
||||
UserBalance invitationBalance = userBalanceService.selectUserBalanceByStorId(invitation.getInviterId(), Integer.parseInt(map.get("storeId")));
|
||||
|
||||
|
||||
// 1.查询出推荐消费有礼 当前店铺下 isonline=0 能用的所有活动 以及子活动对象 active_user_consume
|
||||
HashMap<String, Object> m4 = new HashMap<>();
|
||||
m4.put("store_id", userBalance.getStoreId());
|
||||
m4.put("isonline", 0);
|
||||
List<ActiveUserConsume> activeUserConsumes = activeUserConsumeService.selectListByMap(m4);
|
||||
|
||||
// 2. 过滤 会员等级 支付方式 适用油品 这是针对消费者的条件
|
||||
List<ActiveUserConsume> f2 = activeUserConsumes.stream()
|
||||
// 过滤会员等级
|
||||
.filter(consume -> checkUtil.checkGradeId(userBalance.getGradeId(), consume.getUserGradeIds()))
|
||||
// 过滤 支付方式
|
||||
.filter(consume -> checkUtil.checkPayWay(order.getPayType(), consume.getPaymentType()))
|
||||
// 过滤油品 order.oils f2.suit_oil_ids
|
||||
.filter(consume -> checkUtil.checkPayWay(order.getOils(), consume.getSuitOilIds()))
|
||||
// 过滤 活动时间
|
||||
.filter(consume -> this.checkTimeConsumptionPrex(consume, nowDate))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
for (ActiveUserConsume active : f2) {
|
||||
// 先根据当前活动id 与 推荐人 id 查询历史参加次数
|
||||
HashMap<String, Object> m8 = new HashMap<>();
|
||||
m8.put("active_user_consume_id", active.getId());
|
||||
m8.put("store_id", Integer.parseInt(map.get("storeId")));
|
||||
// 这里指的是被邀请人id
|
||||
m8.put("user_id", invitationBalance.getMtUserId());
|
||||
List<ActiveUserConsumeRecords> r = (List<ActiveUserConsumeRecords>) activeUserConsumeRecordsService.listByMap(m8);
|
||||
// 活动领取次数 必须 > 领取过的次数
|
||||
if (active.getFrequencyLimit() > r.size()) {
|
||||
|
||||
// 无论是 参与积分 成长值 优惠券 都算参与活动
|
||||
Boolean b1 = false;
|
||||
// 积分不为空赠送积分
|
||||
if (active.getPoints() != null) {
|
||||
//
|
||||
invitationBalance.setPoints(invitationBalance.getPoints() + active.getPoints());
|
||||
userBalanceService.updateUserBalance(invitationBalance);
|
||||
// 新增积分变更记录表
|
||||
IntegralDetail i = new IntegralDetail();
|
||||
i.setUserId(invitationBalance.getMtUserId());
|
||||
i.setPointsChange(Double.valueOf(active.getPoints()));
|
||||
i.setCurrentPoints(invitationBalance.getPoints());
|
||||
i.setType("推荐消费有礼活动赠送");
|
||||
i.setStoreId(invitationBalance.getStoreId());
|
||||
i.setChangeType("1");
|
||||
i.setChainStoreId(invitationBalance.getChainStoreId());
|
||||
integralDetailService.insert(i);
|
||||
b1 = true;
|
||||
}
|
||||
|
||||
// 成长值不为空赠送成长值
|
||||
if (active.getGrowthValue() != null) {
|
||||
//
|
||||
invitationBalance.setGrowthValue(invitationBalance.getGrowthValue() + active.getGrowthValue());
|
||||
userBalanceService.updateUserBalance(invitationBalance);
|
||||
//
|
||||
GrowthValueChange g = new GrowthValueChange();
|
||||
g.setUserId(invitationBalance.getMtUserId());
|
||||
g.setChainStoreId(invitationBalance.getChainStoreId());
|
||||
g.setStoreId(invitationBalance.getStoreId());
|
||||
g.setChangeType("1");
|
||||
g.setFromType("推荐消费有礼活动赠送");
|
||||
g.setGrowthValue(active.getGrowthValue());
|
||||
g.setAfterTheChange(invitationBalance.getGrowthValue());
|
||||
g.setOrderNo(order.getOrderNo());
|
||||
int i = growthValueChangeService.insertGrowthValueChangeActive(g);
|
||||
b1 = true;
|
||||
}
|
||||
|
||||
// 优惠卷不为空 赠送优惠卷
|
||||
List<ActiveUserConsumeChild> list = activeUserConsumeChildService.selectByActiveUserConsumeId(active.getId());
|
||||
if (list.size() > 0) {
|
||||
|
||||
for (ActiveUserConsumeChild child : list) {
|
||||
// 优惠卷还得判断自身的活动限制 (因为这是 给某个用户 赠送某个优惠卷 只需要判断 每日每人领取上限 每人总领取上限 优惠卷数量不 <=0)
|
||||
HashMap<String, Object> m9 = new HashMap<>();
|
||||
m9.put("store_id", Integer.parseInt(map.get("storeId")));
|
||||
m9.put("mt_user_id", invitationBalance.getMtUserId());
|
||||
m9.put("card_coupon_id", child.getVouchersId());
|
||||
// 获取当前优惠卷信息
|
||||
CardCoupon card = cardCouponService.getById(child.getVouchersId());
|
||||
|
||||
// 获取 总的 当前用户 领取优惠卷的列表
|
||||
List<CardCouponUser> list1 = cardCouponUserService.selectByMap(m9);
|
||||
// 获取今天 领取次数
|
||||
Stream<CardCouponUser> list2 = list1.stream()
|
||||
.filter(cardCouponUser -> checkUtil.isBetween(cardCouponUser.getCreateTime(), DateUtil.getTodayMidnight(), DateUtil.getTomorrowMidnight()));
|
||||
|
||||
// 此活动上架 收银台可送 且 已领取 + 活动发放数量 < 总数量 且 未超过 总上限 当日上限
|
||||
if (card.getStatus().equals("1") &&
|
||||
card.getSySend().equals("1") &&
|
||||
card.getTfGetNum()+child.getGiftCardTotal() < card.getTfTotal() &&
|
||||
list1.size() < card.getGetNumLimit() &&
|
||||
list2.count() < card.getDayGetLimit()) {
|
||||
// 将优惠卷 与 当前用户关联 并且 优惠卷 领取数量 + 方法数量
|
||||
card.setTfGetNum(card.getTfGetNum() + child.getGiftCardTotal());
|
||||
cardCouponService.updateById(card);
|
||||
|
||||
for (int i = 0; i <child.getGiftCardTotal() ; i++) {
|
||||
CardCouponUser cardUser = new CardCouponUser();
|
||||
cardUser.setChainStoreId(invitationBalance.getChainStoreId());
|
||||
cardUser.setStoreId(invitationBalance.getStoreId());
|
||||
cardUser.setMtUserId(invitationBalance.getMtUserId());
|
||||
// 手机号码 需要连表 空着
|
||||
cardUser.setFromType("3");
|
||||
cardUser.setActiveId(child.getActiveUserConsumeId());
|
||||
cardUser.setCardCouponId(child.getVouchersId());
|
||||
cardUser.setStartTime(card.getEffectiveDateStart());
|
||||
cardUser.setEndTime(card.getEffectiveDateEnd());
|
||||
cardUser.setStatus("0");
|
||||
cardCouponUserService.save(cardUser);
|
||||
}
|
||||
|
||||
b1 = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (b1) {
|
||||
// 新增活动关系表
|
||||
ActiveUserConsumeRecords userRecord = new ActiveUserConsumeRecords();
|
||||
userRecord.setActiveUserConsumeId(active.getId()); //活动id
|
||||
userRecord.setStoreId(Integer.parseInt(map.get("storeId"))); // 店铺id
|
||||
userRecord.setUserId(String.valueOf(invitationBalance.getMtUserId())); // 邀请人id
|
||||
userRecord.setInviteeUserId(String.valueOf(userBalance.getMtUserId())); // 被邀请人id
|
||||
userRecord.setRemark("推荐消费有礼");
|
||||
// 被邀请人姓名 需要连表 先空着
|
||||
boolean save = activeUserConsumeRecordsService.save(userRecord);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// 根据不同的 活动赠送 0:赠送积分1:赠送优惠券 2. 赠送兑换券 3:赠送成长值 4. 赠送实物 处理不同的业务逻辑
|
||||
private Boolean setActiveGift(ActiveConsumptionChild child, UserBalance userBalance, AllOrderActivityVo order) {
|
||||
Boolean b1 = false;
|
||||
if (child.getActiveGift().equals("0")) {
|
||||
//
|
||||
userBalance.setPoints(userBalance.getPoints() + Integer.parseInt(child.getGivePoints()));
|
||||
userBalanceService.updateUserBalance(userBalance);
|
||||
// 新增积分变更记录表
|
||||
IntegralDetail i = new IntegralDetail();
|
||||
i.setUserId(userBalance.getMtUserId());
|
||||
i.setPointsChange(Double.parseDouble(child.getGivePoints()));
|
||||
i.setCurrentPoints(userBalance.getPoints());
|
||||
i.setType("消费有礼活动赠送");
|
||||
i.setStoreId(userBalance.getStoreId());
|
||||
i.setChangeType("1");
|
||||
i.setChainStoreId(userBalance.getChainStoreId());
|
||||
integralDetailService.insert(i);
|
||||
|
||||
b1 = true;
|
||||
return b1;
|
||||
}
|
||||
if (child.getActiveGift().equals("3")) {
|
||||
// 当前用户成长值 = 之前成长值 + 这次要送的成长值
|
||||
userBalance.setGrowthValue(userBalance.getGrowthValue() + Integer.parseInt(child.getGiveGrowthValue()));
|
||||
userBalanceService.updateUserBalance(userBalance);
|
||||
//
|
||||
GrowthValueChange g = new GrowthValueChange();
|
||||
g.setUserId(userBalance.getMtUserId());
|
||||
g.setChainStoreId(userBalance.getChainStoreId());
|
||||
g.setStoreId(userBalance.getStoreId());
|
||||
g.setChangeType("1");
|
||||
g.setFromType("消费有礼活动赠送");
|
||||
// 成长值
|
||||
g.setGrowthValue(Integer.parseInt(child.getGiveGrowthValue()));
|
||||
// 成长变化后的值
|
||||
g.setAfterTheChange(userBalance.getGrowthValue());
|
||||
g.setOrderNo(order.getOrderNo());
|
||||
int i = growthValueChangeService.insertGrowthValueChangeActive(g);
|
||||
b1 = true;
|
||||
return b1;
|
||||
}
|
||||
if (child.getActiveGift().equals("1")) {
|
||||
// 优惠卷还得判断自身的活动限制 (因为这是 给某个用户 赠送某个优惠卷 只需要判断 每日每人领取上限 每人总领取上限 优惠卷数量不 <=0)
|
||||
HashMap<String, Object> m1 = new HashMap<>();
|
||||
m1.put("card_coupon_id", child.getVouchersId());
|
||||
m1.put("mt_user_id", userBalance.getMtUserId());
|
||||
// 获取当前优惠卷信息
|
||||
CardCoupon card = cardCouponService.getById(child.getVouchersId());
|
||||
|
||||
// 获取 总的 当前用户 领取优惠卷的列表
|
||||
List<CardCouponUser> list1 = cardCouponUserService.selectByMap(m1);
|
||||
// 过滤掉 不是今天的领取次数
|
||||
Stream<CardCouponUser> list2 = list1.stream()
|
||||
.filter(cardCouponUser -> checkUtil.isBetween(cardCouponUser.getCreateTime(), DateUtil.getTodayMidnight(), DateUtil.getTomorrowMidnight()));
|
||||
|
||||
// 此 优惠卷 上架 收银台可送 且 活动发放数量+已领取 < 总数量 且 未超过 总上限 当日上限 先都判断一下不为 null 防止空指针
|
||||
card.setTfGetNum( (card.getTfGetNum() == null) ? 0 : card.getTfGetNum());
|
||||
|
||||
if ( card.getStatus().equals("1") &&
|
||||
card.getSySend().equals("1") &&
|
||||
(child.getGiftCardTotal() + card.getTfGetNum()) < card.getTfTotal() &&
|
||||
list1.size() < card.getGetNumLimit() &&
|
||||
list2.count() < card.getDayGetLimit()
|
||||
) {
|
||||
|
||||
// 将优惠卷 与 当前用户关联 并且 优惠卷 领取数量 + 活动设定赠送优惠卷数量
|
||||
card.setTfGetNum(card.getTfGetNum()+child.getGiftCardTotal());
|
||||
cardCouponService.updateById(card);
|
||||
// 并且 循环 添加多张优惠卷与用户领取记录表
|
||||
for (int i = 0; i < child.getGiftCardTotal(); i++) {
|
||||
CardCouponUser cardUser = new CardCouponUser();
|
||||
cardUser.setChainStoreId(userBalance.getChainStoreId());
|
||||
cardUser.setStoreId(userBalance.getStoreId());
|
||||
cardUser.setMtUserId(userBalance.getMtUserId());
|
||||
// 手机号码 需要连表 空着
|
||||
cardUser.setFromType("3"); // 3代表 消费有礼活动
|
||||
cardUser.setActiveId(child.getActiveConsumptionId());
|
||||
cardUser.setCardCouponId(child.getVouchersId());
|
||||
cardUser.setStartTime(card.getEffectiveDateStart());
|
||||
cardUser.setEndTime(card.getEffectiveDateEnd());
|
||||
cardUser.setStatus("0");
|
||||
cardCouponUserService.save(cardUser);
|
||||
}
|
||||
|
||||
b1 = true;
|
||||
return b1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return b1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 推荐消费有礼 活动时间前置处理 0永久有效;1自定义
|
||||
**/
|
||||
public Boolean checkTimeConsumptionPrex(ActiveUserConsume consume, Date nowDate) {
|
||||
if ("0".equals(consume.getActiveTimeType())) {
|
||||
// 如果永久有效 这里没时间字段 不需要匹配
|
||||
return true;
|
||||
} else if ("1".equals(consume.getActiveTimeType())) {
|
||||
// 如果自定义日期 直接判断日期时间 即可
|
||||
return checkUtil.isBetween(nowDate, consume.getActiveStartTime(), consume.getActiveEndTime());
|
||||
} else {
|
||||
//超出预设值范围,不可用
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 消费有礼活动 活动时间 前置处理
|
||||
**/
|
||||
public Boolean checkTimeConsumptionPrex(ActiveConsumptionVOS active, Date nowDate) {
|
||||
if ("0".equals(active.getActivityTimeType())) {
|
||||
// 如果永久有效 再去匹配 适用时间
|
||||
return checkUtil.checkTimeConsumption(active.getSuitTimeSlotType(), active.getSuitDate(), checkUtil.getTimeFromDate(active.getSuitTimeSlotFront()), checkUtil.getTimeFromDate(active.getSuitTimeSlotAfter()), nowDate);
|
||||
} else if ("1".equals(active.getActivityTimeType())) {
|
||||
// 如果自定义日期 先判断是否在 活动时间 在去匹配 适用时间
|
||||
if (checkUtil.isBetween(nowDate, active.getActiveStartTime(), active.getActiveEndTime())) {
|
||||
return checkUtil.checkTimeConsumption(active.getSuitTimeSlotType(), active.getSuitDate(), checkUtil.getTimeFromDate(active.getSuitTimeSlotFront()), checkUtil.getTimeFromDate(active.getSuitTimeSlotAfter()), nowDate);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
//超出预设值范围,不可用
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 优惠券适用时间判断前置处理方法
|
||||
* @author vinjor-M
|
||||
* @date 13:57 2024/9/25
|
||||
* @param rule 规则对象
|
||||
*
|
||||
* @param rule 规则对象
|
||||
* @param nowDate 当前时间
|
||||
* @return java.lang.Boolean
|
||||
* @author vinjor-M
|
||||
* @date 13:57 2024/9/25
|
||||
**/
|
||||
private Boolean checkTimeCouponPrex(CardCouponVO rule,Date nowDate){
|
||||
private Boolean checkTimeCouponPrex(CardCouponVO rule, Date nowDate) {
|
||||
String startTimeStr;
|
||||
String endTimeStr;
|
||||
if("0".equals(rule.getAvailableOrUn())){
|
||||
if ("0".equals(rule.getAvailableOrUn())) {
|
||||
//适用时间
|
||||
startTimeStr = checkUtil.getTimeFromDate(rule.getAvailablePeriodStart());
|
||||
endTimeStr = checkUtil.getTimeFromDate(rule.getAvailablePeriodEnd());
|
||||
return checkUtil.checkTime(rule.getAvailableType(),"1".equals(rule.getAvailableType())?rule.getAvailableWeek():rule.getAvailableDay(),startTimeStr,endTimeStr,nowDate);
|
||||
}else if("1".equals(rule.getAvailableOrUn())){
|
||||
return checkUtil.checkTime(rule.getAvailableType(), "1".equals(rule.getAvailableType()) ? rule.getAvailableWeek() : rule.getAvailableDay(), startTimeStr, endTimeStr, nowDate);
|
||||
} else if ("1".equals(rule.getAvailableOrUn())) {
|
||||
//不适用时间
|
||||
startTimeStr = checkUtil.getTimeFromDate(rule.getUnAvailablePeriodStart());
|
||||
endTimeStr = checkUtil.getTimeFromDate(rule.getUnAvailablePeriodEnd());
|
||||
return checkUtil.checkTimeReverse(rule.getUnAvailableType(),"1".equals(rule.getUnAvailableType())?rule.getUnAvailableWeek():rule.getUnAvailableDay(),startTimeStr,endTimeStr,nowDate);
|
||||
}else {
|
||||
return checkUtil.checkTimeReverse(rule.getUnAvailableType(), "1".equals(rule.getUnAvailableType()) ? rule.getUnAvailableWeek() : rule.getUnAvailableDay(), startTimeStr, endTimeStr, nowDate);
|
||||
} else {
|
||||
//超出预设值范围,不可用
|
||||
return false;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user