| @@ -2,6 +2,7 @@ package com.iformall.controller.market; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.annotation.ApiVersion; | import com.iformall.annotation.ApiVersion; | ||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.constant.SwaggerConstant; | import com.iformall.constant.SwaggerConstant; | ||||
| @@ -11,6 +12,7 @@ import com.iformall.domain.po.base.BaseEntity.SortField; | |||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.enums.EnumOfflineActivityAwardsMoneyRule; | import com.iformall.enums.EnumOfflineActivityAwardsMoneyRule; | ||||
| import com.iformall.enums.EnumOfflineActivityMerchantType; | import com.iformall.enums.EnumOfflineActivityMerchantType; | ||||
| import com.iformall.enums.EnumOfflineActivityMode; | |||||
| import com.iformall.enums.EnumOfflineActivityStatus; | import com.iformall.enums.EnumOfflineActivityStatus; | ||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.service.WxVtwoActivityOrderService; | import com.iformall.service.WxVtwoActivityOrderService; | ||||
| @@ -164,14 +166,15 @@ public class WxVtwoAmountGiftActivityController extends BaseController { | |||||
| activityOrder.setCreateDateBegin(activity.getStartTime()); | activityOrder.setCreateDateBegin(activity.getStartTime()); | ||||
| activityOrder.setCreateDateEnd(activity.getEndTime()); | activityOrder.setCreateDateEnd(activity.getEndTime()); | ||||
| Map<String,Object> statisticsMap = wxVtwoActivityOrderService.getStatistics(activityOrder); | |||||
| WxVtwoActivityOrder orderOne = wxVtwoActivityOrderService.getlimitOne(activityOrder); | WxVtwoActivityOrder orderOne = wxVtwoActivityOrderService.getlimitOne(activityOrder); | ||||
| if(orderOne == null){ | if(orderOne == null){ | ||||
| Map<String,Object> result = new HashMap<>(); | |||||
| result.put("cus_name","查无此人"); | |||||
| result.put("cus_phone",activityOrder.getCusPhone()); | |||||
| return new ResultData(result); | |||||
| statisticsMap.put("cus_name","查无此人"); | |||||
| statisticsMap.put("cus_phone",activityOrder.getCusPhone()); | |||||
| return new ResultData(statisticsMap); | |||||
| } | } | ||||
| Map<String,Object> statisticsMap = wxVtwoActivityOrderService.getStatistics(activityOrder); | |||||
| statisticsMap.put("cus_name",orderOne.getCusName()); | statisticsMap.put("cus_name",orderOne.getCusName()); | ||||
| statisticsMap.put("cus_phone",orderOne.getCusPhone()); | statisticsMap.put("cus_phone",orderOne.getCusPhone()); | ||||
| return new ResultData(statisticsMap); | return new ResultData(statisticsMap); | ||||
| @@ -227,4 +230,89 @@ public class WxVtwoAmountGiftActivityController extends BaseController { | |||||
| wxVtwoActivityOrderService.exportData(request,response,activityOrder,activity.getId()); | wxVtwoActivityOrderService.exportData(request,response,activityOrder,activity.getId()); | ||||
| } | } | ||||
| @ApiVersion(group = SwaggerConstant.V_A_2_0) | |||||
| @ApiOperation("活动发放页面处理") | |||||
| @PostMapping("grantAwardPage") | |||||
| public ResultData grantAwardPage(@RequestBody WxVtwoActivityGrant activityGrant) { | |||||
| TenantEntity tenantEntity = getTenantInfo(); | |||||
| activityGrant.updateTenantInfo(tenantEntity); | |||||
| if(activityGrant.getActivityId() == null){ | |||||
| return new ResultData(Result.ERROR,"活动ID为空"); | |||||
| } | |||||
| if(activityGrant.getOrderIdList() == null || activityGrant.getOrderIdList().isEmpty()){ | |||||
| return new ResultData(Result.ERROR,"请选择订单"); | |||||
| } | |||||
| WxVtwoAmountGiftActivity amountGiftActivity = wxVtwoAmountGiftActivityService.getInfoById(activityGrant.getActivityId(), activityGrant.getTenantId()); | |||||
| if(amountGiftActivity == null){ | |||||
| return new ResultData(Result.ERROR,"查询不到活动"); | |||||
| } | |||||
| if(!EnumOfflineActivityStatus.ON_LINE.getCode().equals(amountGiftActivity.getStatus())){ | |||||
| throw new MallinkException(Result.ERROR, "请检查活动状态"); | |||||
| } | |||||
| if(EnumOfflineActivityMode.CONDITION_SUM.getCode().equals(amountGiftActivity.getAmountModel())){ | |||||
| if(activityGrant.getOrderFilterIdList() == null || activityGrant.getOrderFilterIdList().isEmpty()){ | |||||
| return new ResultData(Result.ERROR,"请筛选订单"); | |||||
| } | |||||
| }else{ | |||||
| activityGrant.setOrderFilterIdList(null); | |||||
| } | |||||
| try{ | |||||
| wxVtwoAmountGiftActivityService.handlerGrantAwardPage(amountGiftActivity,activityGrant); | |||||
| return new ResultData(activityGrant); | |||||
| }catch(MallinkException e){ | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||||
| }catch(Exception e){ | |||||
| logger.error("异常:" + e); | |||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||||
| } | |||||
| } | |||||
| @ApiVersion(group = SwaggerConstant.V_A_2_0) | |||||
| @ApiOperation("活动发放") | |||||
| @PostMapping("grantAward") | |||||
| public ResultData grantAward(@RequestBody WxVtwoActivityGrant activityGrant) { | |||||
| TenantEntity tenantEntity = getTenantInfo(); | |||||
| activityGrant.updateTenantInfo(tenantEntity); | |||||
| if(activityGrant.getActivityId() == null){ | |||||
| return new ResultData(Result.ERROR,"活动ID为空"); | |||||
| } | |||||
| if(activityGrant.getOrderIdList() == null || activityGrant.getOrderIdList().isEmpty()){ | |||||
| return new ResultData(Result.ERROR,"请选择订单"); | |||||
| } | |||||
| WxVtwoAmountGiftActivity amountGiftActivity = wxVtwoAmountGiftActivityService.getInfoById(activityGrant.getActivityId(), activityGrant.getTenantId()); | |||||
| if(amountGiftActivity == null){ | |||||
| return new ResultData(Result.ERROR,"查询不到活动"); | |||||
| } | |||||
| if(!EnumOfflineActivityStatus.ON_LINE.getCode().equals(amountGiftActivity.getStatus())){ | |||||
| throw new MallinkException(Result.ERROR, "请检查活动状态"); | |||||
| } | |||||
| if(EnumOfflineActivityMode.CONDITION_SUM.getCode().equals(amountGiftActivity.getAmountModel())){ | |||||
| if(activityGrant.getOrderFilterIdList() == null || activityGrant.getOrderFilterIdList().isEmpty()){ | |||||
| return new ResultData(Result.ERROR,"请筛选订单"); | |||||
| } | |||||
| }else{ | |||||
| activityGrant.setOrderFilterIdList(null); | |||||
| } | |||||
| if(activityGrant.getGrantAwardList() == null || activityGrant.getGrantAwardList().isEmpty()){ | |||||
| return new ResultData(Result.ERROR,"奖励项为空"); | |||||
| } | |||||
| // if(StringUtils.isBlank(activityGrant.getSignImg())){ | |||||
| // return new ResultData(Result.ERROR,"签名为空"); | |||||
| // } | |||||
| activityGrant.setCreateBy(getUserId()); | |||||
| activityGrant.setCreateByName(getUser().getName()); | |||||
| try{ | |||||
| wxVtwoAmountGiftActivityService.grantAward(amountGiftActivity, activityGrant); | |||||
| return new ResultData(); | |||||
| }catch(MallinkException e){ | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||||
| }catch(Exception e){ | |||||
| logger.error("异常:" + e); | |||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -2,6 +2,7 @@ package com.iformall.controller.market; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.annotation.ApiVersion; | import com.iformall.annotation.ApiVersion; | ||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.constant.SwaggerConstant; | import com.iformall.constant.SwaggerConstant; | ||||
| @@ -11,6 +12,7 @@ import com.iformall.domain.po.base.BaseEntity.SortField; | |||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.enums.EnumOfflineActivityAwardsMoneyRule; | import com.iformall.enums.EnumOfflineActivityAwardsMoneyRule; | ||||
| import com.iformall.enums.EnumOfflineActivityMerchantType; | import com.iformall.enums.EnumOfflineActivityMerchantType; | ||||
| import com.iformall.enums.EnumOfflineActivityMode; | |||||
| import com.iformall.enums.EnumOfflineActivityStatus; | import com.iformall.enums.EnumOfflineActivityStatus; | ||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.service.WxVtwoActivityOrderService; | import com.iformall.service.WxVtwoActivityOrderService; | ||||
| @@ -178,7 +180,7 @@ public class WxVtwoCashBackActivityController extends BaseController { | |||||
| } | } | ||||
| TenantEntity tenantInfo = getTenantInfo(); | TenantEntity tenantInfo = getTenantInfo(); | ||||
| WxVtwoCashBackActivity activity = wxVtwoCashBackActivityService.getById(activityOrder.getActivityId(), tenantInfo.getTenantId()); | |||||
| WxVtwoCashBackActivity activity = wxVtwoCashBackActivityService.getInfoById(activityOrder.getActivityId(), tenantInfo.getTenantId()); | |||||
| if(activity == null){ | if(activity == null){ | ||||
| return new ResultData(Result.ERROR,"未查询到活动"); | return new ResultData(Result.ERROR,"未查询到活动"); | ||||
| } | } | ||||
| @@ -186,14 +188,15 @@ public class WxVtwoCashBackActivityController extends BaseController { | |||||
| activityOrder.setCreateDateBegin(activity.getStartTime()); | activityOrder.setCreateDateBegin(activity.getStartTime()); | ||||
| activityOrder.setCreateDateEnd(activity.getEndTime()); | activityOrder.setCreateDateEnd(activity.getEndTime()); | ||||
| Map<String,Object> statisticsMap = wxVtwoActivityOrderService.getStatistics(activityOrder); | |||||
| WxVtwoActivityOrder orderOne = wxVtwoActivityOrderService.getlimitOne(activityOrder); | WxVtwoActivityOrder orderOne = wxVtwoActivityOrderService.getlimitOne(activityOrder); | ||||
| if(orderOne == null){ | if(orderOne == null){ | ||||
| Map<String,Object> result = new HashMap<>(); | |||||
| result.put("cus_name","查无此人"); | |||||
| result.put("cus_phone",activityOrder.getCusPhone()); | |||||
| return new ResultData(result); | |||||
| statisticsMap.put("cus_name","查无此人"); | |||||
| statisticsMap.put("cus_phone",activityOrder.getCusPhone()); | |||||
| return new ResultData(statisticsMap); | |||||
| } | } | ||||
| Map<String,Object> statisticsMap = wxVtwoActivityOrderService.getStatistics(activityOrder); | |||||
| statisticsMap.put("cus_name",orderOne.getCusName()); | statisticsMap.put("cus_name",orderOne.getCusName()); | ||||
| statisticsMap.put("cus_phone",orderOne.getCusPhone()); | statisticsMap.put("cus_phone",orderOne.getCusPhone()); | ||||
| return new ResultData(statisticsMap); | return new ResultData(statisticsMap); | ||||
| @@ -212,7 +215,7 @@ public class WxVtwoCashBackActivityController extends BaseController { | |||||
| } | } | ||||
| TenantEntity tenantInfo = getTenantInfo(); | TenantEntity tenantInfo = getTenantInfo(); | ||||
| WxVtwoCashBackActivity activity = wxVtwoCashBackActivityService.getById(activityOrder.getActivityId(), tenantInfo.getTenantId()); | |||||
| WxVtwoCashBackActivity activity = wxVtwoCashBackActivityService.getInfoById(activityOrder.getActivityId(), tenantInfo.getTenantId()); | |||||
| if(activity == null){ | if(activity == null){ | ||||
| return new ResultData(Result.ERROR,"未查询到活动"); | return new ResultData(Result.ERROR,"未查询到活动"); | ||||
| } | } | ||||
| @@ -249,4 +252,89 @@ public class WxVtwoCashBackActivityController extends BaseController { | |||||
| wxVtwoActivityOrderService.exportData(request,response,activityOrder,activity.getId()); | wxVtwoActivityOrderService.exportData(request,response,activityOrder,activity.getId()); | ||||
| } | } | ||||
| @ApiVersion(group = SwaggerConstant.V_A_2_0) | |||||
| @ApiOperation("活动发放页面处理") | |||||
| @PostMapping("grantAwardPage") | |||||
| public ResultData grantAwardPage(@RequestBody WxVtwoCashBackGrant activityGrant) { | |||||
| TenantEntity tenantEntity = getTenantInfo(); | |||||
| activityGrant.updateTenantInfo(tenantEntity); | |||||
| if(activityGrant.getActivityId() == null){ | |||||
| return new ResultData(Result.ERROR,"活动ID为空"); | |||||
| } | |||||
| if(activityGrant.getOrderIdList() == null || activityGrant.getOrderIdList().isEmpty()){ | |||||
| return new ResultData(Result.ERROR,"请选择订单"); | |||||
| } | |||||
| WxVtwoCashBackActivity cashBackActivity = wxVtwoCashBackActivityService.getById(activityGrant.getActivityId(), activityGrant.getTenantId()); | |||||
| if(cashBackActivity == null){ | |||||
| return new ResultData(Result.ERROR,"查询不到活动"); | |||||
| } | |||||
| if(!EnumOfflineActivityStatus.ON_LINE.getCode().equals(cashBackActivity.getStatus())){ | |||||
| throw new MallinkException(Result.ERROR, "请检查活动状态"); | |||||
| } | |||||
| if(EnumOfflineActivityMode.CONDITION_SUM.getCode().equals(cashBackActivity.getAmountModel())){ | |||||
| if(activityGrant.getOrderFilterIdList() == null || activityGrant.getOrderFilterIdList().isEmpty()){ | |||||
| return new ResultData(Result.ERROR,"请筛选订单"); | |||||
| } | |||||
| }else{ | |||||
| activityGrant.setOrderFilterIdList(null); | |||||
| } | |||||
| try{ | |||||
| wxVtwoCashBackActivityService.handlerGrantAwardPage(cashBackActivity,activityGrant); | |||||
| return new ResultData(activityGrant); | |||||
| }catch(MallinkException e){ | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||||
| }catch(Exception e){ | |||||
| logger.error("异常:" + e); | |||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||||
| } | |||||
| } | |||||
| @ApiVersion(group = SwaggerConstant.V_A_2_0) | |||||
| @ApiOperation("活动发放") | |||||
| @PostMapping("grantAward") | |||||
| public ResultData grantAward(@RequestBody WxVtwoCashBackGrant activityGrant) { | |||||
| TenantEntity tenantEntity = getTenantInfo(); | |||||
| activityGrant.updateTenantInfo(tenantEntity); | |||||
| if(activityGrant.getActivityId() == null){ | |||||
| return new ResultData(Result.ERROR,"活动ID为空"); | |||||
| } | |||||
| if(activityGrant.getOrderIdList() == null || activityGrant.getOrderIdList().isEmpty()){ | |||||
| return new ResultData(Result.ERROR,"请选择订单"); | |||||
| } | |||||
| WxVtwoCashBackActivity cashBackActivity = wxVtwoCashBackActivityService.getById(activityGrant.getActivityId(), activityGrant.getTenantId()); | |||||
| if(cashBackActivity == null){ | |||||
| return new ResultData(Result.ERROR,"查询不到活动"); | |||||
| } | |||||
| if(!EnumOfflineActivityStatus.ON_LINE.getCode().equals(cashBackActivity.getStatus())){ | |||||
| throw new MallinkException(Result.ERROR, "请检查活动状态"); | |||||
| } | |||||
| if(EnumOfflineActivityMode.CONDITION_SUM.getCode().equals(cashBackActivity.getAmountModel())){ | |||||
| if(activityGrant.getOrderFilterIdList() == null || activityGrant.getOrderFilterIdList().isEmpty()){ | |||||
| return new ResultData(Result.ERROR,"请筛选订单"); | |||||
| } | |||||
| }else{ | |||||
| activityGrant.setOrderFilterIdList(null); | |||||
| } | |||||
| if(activityGrant.getGrantAwardList() == null || activityGrant.getGrantAwardList().isEmpty()){ | |||||
| return new ResultData(Result.ERROR,"奖励项为空"); | |||||
| } | |||||
| // if(StringUtils.isBlank(activityGrant.getSignImg())){ | |||||
| // return new ResultData(Result.ERROR,"签名为空"); | |||||
| // } | |||||
| activityGrant.setCreateBy(getUserId()); | |||||
| activityGrant.setCreateByName(getUser().getName()); | |||||
| try{ | |||||
| wxVtwoCashBackActivityService.grantAward(cashBackActivity, activityGrant); | |||||
| return new ResultData(); | |||||
| }catch(MallinkException e){ | |||||
| logger.error(e.getMessage()); | |||||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||||
| }catch(Exception e){ | |||||
| logger.error("异常:" + e); | |||||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||||
| } | |||||
| } | |||||
| } | } | ||||
| @@ -166,14 +166,15 @@ public class WxVtwoPrizeDrawActivityController extends BaseController { | |||||
| activityOrder.setCreateDateBegin(activity.getStartTime()); | activityOrder.setCreateDateBegin(activity.getStartTime()); | ||||
| activityOrder.setCreateDateEnd(activity.getEndTime()); | activityOrder.setCreateDateEnd(activity.getEndTime()); | ||||
| Map<String,Object> statisticsMap = wxVtwoActivityOrderService.getStatistics(activityOrder); | |||||
| WxVtwoActivityOrder orderOne = wxVtwoActivityOrderService.getlimitOne(activityOrder); | WxVtwoActivityOrder orderOne = wxVtwoActivityOrderService.getlimitOne(activityOrder); | ||||
| if(orderOne == null){ | if(orderOne == null){ | ||||
| Map<String,Object> result = new HashMap<>(); | |||||
| result.put("cus_name","查无此人"); | |||||
| result.put("cus_phone",activityOrder.getCusPhone()); | |||||
| return new ResultData(result); | |||||
| statisticsMap.put("cus_name","查无此人"); | |||||
| statisticsMap.put("cus_phone",activityOrder.getCusPhone()); | |||||
| return new ResultData(statisticsMap); | |||||
| } | } | ||||
| Map<String,Object> statisticsMap = wxVtwoActivityOrderService.getStatistics(activityOrder); | |||||
| statisticsMap.put("cus_name",orderOne.getCusName()); | statisticsMap.put("cus_name",orderOne.getCusName()); | ||||
| statisticsMap.put("cus_phone",orderOne.getCusPhone()); | statisticsMap.put("cus_phone",orderOne.getCusPhone()); | ||||
| return new ResultData(statisticsMap); | return new ResultData(statisticsMap); | ||||
| @@ -241,7 +242,7 @@ public class WxVtwoPrizeDrawActivityController extends BaseController { | |||||
| if(activityGrant.getOrderIdList() == null || activityGrant.getOrderIdList().isEmpty()){ | if(activityGrant.getOrderIdList() == null || activityGrant.getOrderIdList().isEmpty()){ | ||||
| return new ResultData(Result.ERROR,"请选择订单"); | return new ResultData(Result.ERROR,"请选择订单"); | ||||
| } | } | ||||
| WxVtwoPrizeDrawActivity prizeDrawActivity = wxVtwoPrizeDrawActivityService.getById(activityGrant.getActivityId(), activityGrant.getTenantId()); | |||||
| WxVtwoPrizeDrawActivity prizeDrawActivity = wxVtwoPrizeDrawActivityService.getInfoById(activityGrant.getActivityId(), activityGrant.getTenantId()); | |||||
| if(prizeDrawActivity == null){ | if(prizeDrawActivity == null){ | ||||
| return new ResultData(Result.ERROR,"查询不到活动"); | return new ResultData(Result.ERROR,"查询不到活动"); | ||||
| } | } | ||||
| @@ -280,7 +281,7 @@ public class WxVtwoPrizeDrawActivityController extends BaseController { | |||||
| if(activityGrant.getOrderIdList() == null || activityGrant.getOrderIdList().isEmpty()){ | if(activityGrant.getOrderIdList() == null || activityGrant.getOrderIdList().isEmpty()){ | ||||
| return new ResultData(Result.ERROR,"请选择订单"); | return new ResultData(Result.ERROR,"请选择订单"); | ||||
| } | } | ||||
| WxVtwoPrizeDrawActivity prizeDrawActivity = wxVtwoPrizeDrawActivityService.getById(activityGrant.getActivityId(), activityGrant.getTenantId()); | |||||
| WxVtwoPrizeDrawActivity prizeDrawActivity = wxVtwoPrizeDrawActivityService.getInfoById(activityGrant.getActivityId(), activityGrant.getTenantId()); | |||||
| if(prizeDrawActivity == null){ | if(prizeDrawActivity == null){ | ||||
| return new ResultData(Result.ERROR,"查询不到活动"); | return new ResultData(Result.ERROR,"查询不到活动"); | ||||
| } | } | ||||
| @@ -16,6 +16,10 @@ import lombok.Data; | |||||
| @TableName(value ="wx_vtwo_activity_grant_award") | @TableName(value ="wx_vtwo_activity_grant_award") | ||||
| @Data | @Data | ||||
| public class WxVtwoActivityGrantAward extends TenantEntity { | public class WxVtwoActivityGrantAward extends TenantEntity { | ||||
| @TableField(exist = false) | |||||
| private String name; | |||||
| /** | /** | ||||
| * | * | ||||
| */ | */ | ||||
| @@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.annotation.TableField; | |||||
| import com.baomidou.mybatisplus.annotation.TableId; | import com.baomidou.mybatisplus.annotation.TableId; | ||||
| import com.baomidou.mybatisplus.annotation.TableName; | import com.baomidou.mybatisplus.annotation.TableName; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import java.math.BigDecimal; | |||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.List; | import java.util.List; | ||||
| @@ -70,7 +72,7 @@ public class WxVtwoCashBackActivity extends TenantEntity { | |||||
| * 返现总金额限制 | * 返现总金额限制 | ||||
| */ | */ | ||||
| @TableField(value = "cash_back_limit") | @TableField(value = "cash_back_limit") | ||||
| private Integer cashBackLimit; | |||||
| private BigDecimal cashBackLimit; | |||||
| /** | /** | ||||
| * 返现计算规则 | * 返现计算规则 | ||||
| @@ -68,7 +68,7 @@ public class WxVtwoCashBackAward extends TenantEntity { | |||||
| * 返现金额限制 | * 返现金额限制 | ||||
| */ | */ | ||||
| @TableField(value = "cash_back_limit") | @TableField(value = "cash_back_limit") | ||||
| private Integer cashBackLimit; | |||||
| private BigDecimal cashBackLimit; | |||||
| /** | /** | ||||
| * 分担规则(0-商管 1-商户 2-分担) | * 分担规则(0-商管 1-商户 2-分担) | ||||
| @@ -1,5 +1,7 @@ | |||||
| package com.iformall.domain.po; | package com.iformall.domain.po; | ||||
| import com.alibaba.fastjson.JSON; | |||||
| import com.aliyun.openservices.shade.org.apache.commons.lang3.StringUtils; | |||||
| import com.baomidou.mybatisplus.annotation.IdType; | import com.baomidou.mybatisplus.annotation.IdType; | ||||
| import com.baomidou.mybatisplus.annotation.TableField; | import com.baomidou.mybatisplus.annotation.TableField; | ||||
| import com.baomidou.mybatisplus.annotation.TableId; | import com.baomidou.mybatisplus.annotation.TableId; | ||||
| @@ -7,6 +9,9 @@ import com.baomidou.mybatisplus.annotation.TableName; | |||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import java.math.BigDecimal; | import java.math.BigDecimal; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.List; | |||||
| import com.iformall.domain.vo.WxVtwoActivityGrantRule; | |||||
| import lombok.Data; | import lombok.Data; | ||||
| /** | /** | ||||
| @@ -63,6 +68,18 @@ public class WxVtwoCashBackGrant extends TenantEntity { | |||||
| */ | */ | ||||
| @TableField(value = "lottery_num") | @TableField(value = "lottery_num") | ||||
| private String lotteryNum; | private String lotteryNum; | ||||
| @TableField(exist = false) | |||||
| private List<String> lotteryNumList; | |||||
| public List<String> getLotteryNumList() { | |||||
| if(StringUtils.isNotBlank(lotteryNum)){ | |||||
| try { | |||||
| List<String> stringList = JSON.parseArray(lotteryNum, String.class); | |||||
| stringList.removeIf(String::isEmpty); | |||||
| lotteryNumList = stringList.isEmpty() ? null : stringList; | |||||
| } catch (Exception e){} | |||||
| } | |||||
| return lotteryNumList; | |||||
| } | |||||
| /** | /** | ||||
| * 抽奖券数量 | * 抽奖券数量 | ||||
| @@ -75,6 +92,18 @@ public class WxVtwoCashBackGrant extends TenantEntity { | |||||
| */ | */ | ||||
| @TableField(value = "anniversary_lottery_num") | @TableField(value = "anniversary_lottery_num") | ||||
| private String anniversaryLotteryNum; | private String anniversaryLotteryNum; | ||||
| @TableField(exist = false) | |||||
| private List<String> anniversaryLotteryNumList; | |||||
| public List<String> getAnniversaryLotteryNumList() { | |||||
| if(StringUtils.isNotBlank(anniversaryLotteryNum)){ | |||||
| try { | |||||
| List<String> stringList = JSON.parseArray(anniversaryLotteryNum, String.class); | |||||
| stringList.removeIf(String::isEmpty); | |||||
| anniversaryLotteryNumList = stringList.isEmpty() ? null : stringList; | |||||
| } catch (Exception e){} | |||||
| } | |||||
| return anniversaryLotteryNumList; | |||||
| } | |||||
| /** | /** | ||||
| * 实际领奖人 | * 实际领奖人 | ||||
| @@ -94,12 +123,6 @@ public class WxVtwoCashBackGrant extends TenantEntity { | |||||
| @TableField(value = "cash_back_limit") | @TableField(value = "cash_back_limit") | ||||
| private BigDecimal cashBackLimit; | private BigDecimal cashBackLimit; | ||||
| /** | |||||
| * 返现金额计算规则 | |||||
| */ | |||||
| @TableField(value = "cash_back_rule") | |||||
| private Integer cashBackRule; | |||||
| /** | /** | ||||
| * 返现金额 | * 返现金额 | ||||
| */ | */ | ||||
| @@ -121,7 +144,7 @@ public class WxVtwoCashBackGrant extends TenantEntity { | |||||
| /** | /** | ||||
| * 实际返现金额 | * 实际返现金额 | ||||
| */ | */ | ||||
| @TableField(value = "real_cash_back") | |||||
| @TableField(exist = false) | |||||
| private BigDecimal realCashBack; | private BigDecimal realCashBack; | ||||
| /** | /** | ||||
| @@ -147,6 +170,8 @@ public class WxVtwoCashBackGrant extends TenantEntity { | |||||
| */ | */ | ||||
| @TableField(value = "create_by") | @TableField(value = "create_by") | ||||
| private Long createBy; | private Long createBy; | ||||
| @TableField(exist = false) | |||||
| private String createByName; | |||||
| /** | /** | ||||
| * 创建时间 | * 创建时间 | ||||
| @@ -159,4 +184,17 @@ public class WxVtwoCashBackGrant extends TenantEntity { | |||||
| */ | */ | ||||
| @TableField(value = "update_date") | @TableField(value = "update_date") | ||||
| private Date updateDate; | private Date updateDate; | ||||
| @TableField(exist = false) | |||||
| private List<WxVtwoCashBackGrantAward> grantAwardList; | |||||
| @TableField(exist = false) | |||||
| private List<Long> orderIdList; | |||||
| @TableField(exist = false) | |||||
| private List<Long> orderFilterIdList; | |||||
| @TableField(exist = false) | |||||
| private List<WxVtwoActivityOrder> orderList; | |||||
| } | } | ||||
| @@ -16,6 +16,10 @@ import lombok.Data; | |||||
| @TableName(value ="wx_vtwo_cash_back_grant_award") | @TableName(value ="wx_vtwo_cash_back_grant_award") | ||||
| @Data | @Data | ||||
| public class WxVtwoCashBackGrantAward extends TenantEntity { | public class WxVtwoCashBackGrantAward extends TenantEntity { | ||||
| @TableField(exist = false) | |||||
| private String name; | |||||
| /** | /** | ||||
| * | * | ||||
| */ | */ | ||||
| @@ -1,11 +1,8 @@ | |||||
| package com.iformall.service; | package com.iformall.service; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.domain.po.WxVtwoAmountGiftActivity; | |||||
| import com.iformall.domain.po.*; | |||||
| import com.baomidou.mybatisplus.extension.service.IService; | import com.baomidou.mybatisplus.extension.service.IService; | ||||
| import com.iformall.domain.po.WxVtwoCashBackActivity; | |||||
| import com.iformall.domain.po.WxVtwoPrizeDrawActivity; | |||||
| import com.iformall.domain.po.WxVtwoSpecialTopicActivity; | |||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| /** | /** | ||||
| @@ -22,4 +19,8 @@ public interface WxVtwoAmountGiftActivityService extends IService<WxVtwoAmountGi | |||||
| WxVtwoAmountGiftActivity getById(Long id, String tenantId); | WxVtwoAmountGiftActivity getById(Long id, String tenantId); | ||||
| void handleSpecialTopicActivity(TenantEntity tenantEntity, WxVtwoSpecialTopicActivity activity); | void handleSpecialTopicActivity(TenantEntity tenantEntity, WxVtwoSpecialTopicActivity activity); | ||||
| void handlerGrantAwardPage(WxVtwoAmountGiftActivity amountGiftActivity, WxVtwoActivityGrant activityGrant); | |||||
| void grantAward(WxVtwoAmountGiftActivity amountGiftActivity,WxVtwoActivityGrant activityGrant); | |||||
| } | } | ||||
| @@ -1,11 +1,8 @@ | |||||
| package com.iformall.service; | package com.iformall.service; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.domain.po.WxVtwoAmountGiftActivity; | |||||
| import com.iformall.domain.po.WxVtwoCashBackActivity; | |||||
| import com.iformall.domain.po.*; | |||||
| import com.baomidou.mybatisplus.extension.service.IService; | import com.baomidou.mybatisplus.extension.service.IService; | ||||
| import com.iformall.domain.po.WxVtwoPrizeDrawActivity; | |||||
| import com.iformall.domain.po.WxVtwoSpecialTopicActivity; | |||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| /** | /** | ||||
| @@ -22,4 +19,8 @@ public interface WxVtwoCashBackActivityService extends IService<WxVtwoCashBackAc | |||||
| WxVtwoCashBackActivity getById(Long id, String tenantId); | WxVtwoCashBackActivity getById(Long id, String tenantId); | ||||
| void handleSpecialTopicActivity(TenantEntity tenantEntity, WxVtwoSpecialTopicActivity activity); | void handleSpecialTopicActivity(TenantEntity tenantEntity, WxVtwoSpecialTopicActivity activity); | ||||
| void handlerGrantAwardPage(WxVtwoCashBackActivity cashBackActivity, WxVtwoCashBackGrant activityGrant); | |||||
| void grantAward(WxVtwoCashBackActivity cashBackActivity,WxVtwoCashBackGrant activityGrant); | |||||
| } | } | ||||
| @@ -1,8 +1,12 @@ | |||||
| package com.iformall.service; | package com.iformall.service; | ||||
| import com.iformall.domain.po.WxVtwoActivityGrant; | |||||
| import com.iformall.domain.po.WxVtwoActivityOrder; | |||||
| import com.iformall.domain.po.WxVtwoCashBackGrant; | import com.iformall.domain.po.WxVtwoCashBackGrant; | ||||
| import com.baomidou.mybatisplus.extension.service.IService; | import com.baomidou.mybatisplus.extension.service.IService; | ||||
| import java.util.List; | |||||
| /** | /** | ||||
| * @author xiaohu | * @author xiaohu | ||||
| * @description 针对表【wx_vtwo_cash_back_grant(线下返现活动发奖)】的数据库操作Service | * @description 针对表【wx_vtwo_cash_back_grant(线下返现活动发奖)】的数据库操作Service | ||||
| @@ -10,4 +14,6 @@ import com.baomidou.mybatisplus.extension.service.IService; | |||||
| */ | */ | ||||
| public interface WxVtwoCashBackGrantService extends IService<WxVtwoCashBackGrant> { | public interface WxVtwoCashBackGrantService extends IService<WxVtwoCashBackGrant> { | ||||
| void handleFromOrder(String activityName, WxVtwoCashBackGrant activityGrant, List<WxVtwoActivityOrder> orderList, boolean isGrant); | |||||
| } | } | ||||
| @@ -8,22 +8,27 @@ import com.iformall.common.IdWorker; | |||||
| import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.domain.vo.WxVtwoActivityGrantRule; | |||||
| import com.iformall.domain.vo.WxVtwoActivityOrderStatistics; | import com.iformall.domain.vo.WxVtwoActivityOrderStatistics; | ||||
| import com.iformall.domain.vo.WxVtwoActivityRuleDetail; | import com.iformall.domain.vo.WxVtwoActivityRuleDetail; | ||||
| import com.iformall.enums.*; | import com.iformall.enums.*; | ||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.mapper.*; | import com.iformall.mapper.*; | ||||
| import com.iformall.service.ExcelService; | |||||
| import com.iformall.service.WxVtwoActivityAwardService; | |||||
| import com.iformall.service.WxVtwoActivityMerchantService; | |||||
| import com.iformall.service.WxVtwoAmountGiftActivityService; | |||||
| import com.iformall.service.*; | |||||
| import org.apache.commons.lang3.StringUtils; | import org.apache.commons.lang3.StringUtils; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import org.springframework.transaction.annotation.Transactional; | import org.springframework.transaction.annotation.Transactional; | ||||
| import java.math.BigDecimal; | |||||
| import java.math.RoundingMode; | |||||
| import java.util.ArrayList; | |||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | |||||
| import java.util.function.Function; | |||||
| import static java.util.stream.Collectors.toMap; | |||||
| /** | /** | ||||
| * @author xiaohu | * @author xiaohu | ||||
| @@ -55,6 +60,21 @@ public class WxVtwoAmountGiftActivityServiceImpl extends ServiceImpl<WxVtwoAmoun | |||||
| @Autowired | @Autowired | ||||
| private WxVtwoActivityMerchantService wxVtwoActivityMerchantService; | private WxVtwoActivityMerchantService wxVtwoActivityMerchantService; | ||||
| @Autowired | |||||
| private WxVtwoActivityOrderService wxVtwoActivityOrderService; | |||||
| @Autowired | |||||
| private WxVtwoActivityGrantService wxVtwoActivityGrantService; | |||||
| @Autowired | |||||
| private WxVtwoActivityGrantOrderService wxVtwoActivityGrantOrderService; | |||||
| @Autowired | |||||
| private WxVtwoActivityGrantAwardService wxVtwoActivityGrantAwardService; | |||||
| @Autowired | |||||
| private WxVtwoActivityGrantSettlementService wxVtwoActivityGrantSettlementService; | |||||
| @Autowired | @Autowired | ||||
| private ExcelService excelService; | private ExcelService excelService; | ||||
| @@ -233,6 +253,89 @@ public class WxVtwoAmountGiftActivityServiceImpl extends ServiceImpl<WxVtwoAmoun | |||||
| activity.setActivityEndTime(amountGiftActivity.getEndTime()); | activity.setActivityEndTime(amountGiftActivity.getEndTime()); | ||||
| activity.setActivityStatus(amountGiftActivity.getStatus()); | activity.setActivityStatus(amountGiftActivity.getStatus()); | ||||
| } | } | ||||
| @Override | |||||
| public void handlerGrantAwardPage(WxVtwoAmountGiftActivity amountGiftActivity,WxVtwoActivityGrant activityGrant) { | |||||
| List<WxVtwoActivityOrder> orderList = wxVtwoActivityOrderService.findGrantOrder(activityGrant,activityGrant.getOrderIdList(),activityGrant.getOrderFilterIdList()); | |||||
| wxVtwoActivityGrantService.handleFromOrder(amountGiftActivity.getName(),activityGrant,orderList,false); | |||||
| List<WxVtwoActivityAward> activityAwardList = wxVtwoActivityAwardService.findActivityAwardList(activityGrant.getActivityId(), activityGrant.getTenantId()); | |||||
| activityGrant.setAwardList(activityAwardList); | |||||
| List<WxVtwoActivityGrantAward> grantAwardList = new ArrayList<>(); | |||||
| if(EnumOfflineActivityMode.ONE.getCode().equals(amountGiftActivity.getAmountModel())){ | |||||
| for(WxVtwoActivityOrder order:orderList){ | |||||
| Integer awardGrade = 0; | |||||
| for (WxVtwoActivityRuleDetail rule :amountGiftActivity.getAmountRulesObject()){ | |||||
| if((rule.getMinAmount() == null || order.getOrderMoney().compareTo(rule.getMinAmount()) >= 0) | |||||
| && (rule.getMaxAmount() == null || order.getOrderMoney().compareTo(rule.getMaxAmount()) <= 0)){ | |||||
| awardGrade = rule.getAwardGrade(); | |||||
| } | |||||
| } | |||||
| if(awardGrade != null){ | |||||
| WxVtwoActivityGrantAward grantAward = new WxVtwoActivityGrantAward(); | |||||
| grantAward.setOrderId(order.getId()); | |||||
| grantAward.setModeType(EnumOfflineActivityAwardsModeType.AMOUNT.getCode()); | |||||
| grantAward.setName("订单赠礼("+order.getOrderNo()+")"); | |||||
| grantAward.setAwardGrade(awardGrade); | |||||
| grantAwardList.add(grantAward); | |||||
| } | |||||
| } | |||||
| }else{ | |||||
| BigDecimal orderMoneySum = orderList.stream().filter(order -> EnumYesOrNo.YES.getCode().equals(order.getIsAmount())) | |||||
| .map(WxVtwoActivityOrder::getOrderMoney).reduce(BigDecimal.ZERO, BigDecimal::add); | |||||
| Integer awardGrade = 0; | |||||
| for (WxVtwoActivityRuleDetail rule :amountGiftActivity.getAmountRulesObject()){ | |||||
| if((rule.getMinAmount() == null || orderMoneySum.compareTo(rule.getMinAmount()) >= 0) | |||||
| && (rule.getMaxAmount() == null || orderMoneySum.compareTo(rule.getMaxAmount()) <= 0)){ | |||||
| awardGrade = rule.getAwardGrade(); | |||||
| } | |||||
| } | |||||
| if(awardGrade != null){ | |||||
| WxVtwoActivityGrantAward grantAward = new WxVtwoActivityGrantAward(); | |||||
| grantAward.setModeType(EnumOfflineActivityAwardsModeType.AMOUNT.getCode()); | |||||
| grantAward.setName("订单金额赠礼"); | |||||
| grantAward.setAwardGrade(awardGrade); | |||||
| grantAwardList.add(grantAward); | |||||
| } | |||||
| } | |||||
| //联单 | |||||
| Integer jointCount = wxVtwoActivityOrderService.getJointCount(amountGiftActivity.getRelatedModel(),orderList); | |||||
| if(jointCount != 0){ | |||||
| Map<Integer, WxVtwoActivityRuleDetail> jointCountMap = amountGiftActivity.getRelatedRulesObject().stream().collect(toMap(WxVtwoActivityRuleDetail::getRelatedCount, Function.identity())); | |||||
| WxVtwoActivityRuleDetail relatedRule = jointCountMap.get(jointCount); | |||||
| if(relatedRule != null && relatedRule.getAwardGrade() != null){ | |||||
| Integer awardGrade = relatedRule.getAwardGrade(); | |||||
| WxVtwoActivityGrantAward grantAward = new WxVtwoActivityGrantAward(); | |||||
| grantAward.setModeType(EnumOfflineActivityAwardsModeType.COUNT.getCode()); | |||||
| grantAward.setName("联单赠礼"); | |||||
| grantAward.setAwardGrade(awardGrade); | |||||
| grantAwardList.add(grantAward); | |||||
| } | |||||
| } | |||||
| activityGrant.setGrantAwardList(grantAwardList); | |||||
| } | |||||
| @Override | |||||
| @Transactional(rollbackFor = Exception.class) | |||||
| public void grantAward(WxVtwoAmountGiftActivity amountGiftActivity,WxVtwoActivityGrant activityGrant) { | |||||
| List<WxVtwoActivityOrder> orderList = wxVtwoActivityOrderService.findGrantOrder(activityGrant,activityGrant.getOrderIdList(),activityGrant.getOrderFilterIdList()); | |||||
| wxVtwoActivityGrantService.handleFromOrder(amountGiftActivity.getName(),activityGrant,orderList,false); | |||||
| wxVtwoActivityGrantService.saveOrUpdate(activityGrant); | |||||
| wxVtwoActivityGrantOrderService.saveGrantOrder(activityGrant.getId(),activityGrant.getActivityId(),orderList); | |||||
| wxVtwoActivityGrantAwardService.saveGrantAward(activityGrant); | |||||
| wxVtwoActivityGrantSettlementService.saveGrantSettlement(activityGrant); | |||||
| } | |||||
| } | } | ||||
| @@ -20,11 +20,15 @@ import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import org.springframework.transaction.annotation.Transactional; | import org.springframework.transaction.annotation.Transactional; | ||||
| import java.util.Date; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| import java.math.BigDecimal; | |||||
| import java.math.RoundingMode; | |||||
| import java.util.*; | |||||
| import java.util.function.Function; | |||||
| import java.util.stream.Collectors; | import java.util.stream.Collectors; | ||||
| import static java.util.stream.Collectors.toList; | |||||
| import static java.util.stream.Collectors.toMap; | |||||
| /** | /** | ||||
| * @author xiaohu | * @author xiaohu | ||||
| * @description 针对表【wx_vtwo_cash_back_activity(线下返现活动)】的数据库操作Service实现 | * @description 针对表【wx_vtwo_cash_back_activity(线下返现活动)】的数据库操作Service实现 | ||||
| @@ -55,6 +59,12 @@ public class WxVtwoCashBackActivityServiceImpl extends ServiceImpl<WxVtwoCashBac | |||||
| @Autowired | @Autowired | ||||
| private WxVtwoActivityMerchantService wxVtwoActivityMerchantService; | private WxVtwoActivityMerchantService wxVtwoActivityMerchantService; | ||||
| @Autowired | |||||
| private WxVtwoActivityOrderService wxVtwoActivityOrderService; | |||||
| @Autowired | |||||
| private WxVtwoCashBackGrantService wxVtwoCashBackGrantService; | |||||
| @Autowired | @Autowired | ||||
| private ExcelService excelService; | private ExcelService excelService; | ||||
| @@ -201,9 +211,6 @@ public class WxVtwoCashBackActivityServiceImpl extends ServiceImpl<WxVtwoCashBac | |||||
| cashBackActivity.setTaxDeductionRulesObject(JSONObject.parseObject(cashBackActivity.getTaxDeductionRules(), WxVtwoActivityTaxDeductionRule.class)); | cashBackActivity.setTaxDeductionRulesObject(JSONObject.parseObject(cashBackActivity.getTaxDeductionRules(), WxVtwoActivityTaxDeductionRule.class)); | ||||
| } | } | ||||
| WxVtwoCashBackAward cashBackAwardQ = new WxVtwoCashBackAward(); | |||||
| cashBackAwardQ.setTenantId(tenantId); | |||||
| cashBackAwardQ.setActivityId(id); | |||||
| List<WxVtwoCashBackAward> activityAwardList = wxVtwoCashBackAwardService.findActivityAwardList(id,tenantId); | List<WxVtwoCashBackAward> activityAwardList = wxVtwoCashBackAwardService.findActivityAwardList(id,tenantId); | ||||
| Map<Integer, List<WxVtwoCashBackAward>> activityAwardMap = activityAwardList.stream().collect(Collectors.groupingBy(WxVtwoCashBackAward::getModelType)); | Map<Integer, List<WxVtwoCashBackAward>> activityAwardMap = activityAwardList.stream().collect(Collectors.groupingBy(WxVtwoCashBackAward::getModelType)); | ||||
| cashBackActivity.setAmountRulesObject(activityAwardMap.get(EnumOfflineActivityAwardsModeType.AMOUNT.getCode())); | cashBackActivity.setAmountRulesObject(activityAwardMap.get(EnumOfflineActivityAwardsModeType.AMOUNT.getCode())); | ||||
| @@ -236,6 +243,187 @@ public class WxVtwoCashBackActivityServiceImpl extends ServiceImpl<WxVtwoCashBac | |||||
| activity.setActivityStatus(cashBackActivity.getStatus()); | activity.setActivityStatus(cashBackActivity.getStatus()); | ||||
| } | } | ||||
| @Override | |||||
| public void handlerGrantAwardPage(WxVtwoCashBackActivity cashBackActivity,WxVtwoCashBackGrant activityGrant) { | |||||
| List<WxVtwoActivityOrder> orderList = wxVtwoActivityOrderService.findGrantOrder(activityGrant,activityGrant.getOrderIdList(),activityGrant.getOrderFilterIdList()); | |||||
| wxVtwoCashBackGrantService.handleFromOrder(cashBackActivity.getName(),activityGrant,orderList,false); | |||||
| List<WxVtwoCashBackGrantAward> grantAwardList = new ArrayList<>(); | |||||
| BigDecimal cashBackTotal = BigDecimal.ZERO; | |||||
| List<WxVtwoCashBackAward> sortAmountAwardList = cashBackActivity.getAmountRulesObject().stream().sorted(Comparator.comparing(WxVtwoCashBackAward::getMinAmount)).collect(toList()); | |||||
| if(EnumOfflineActivityMode.ONE.getCode().equals(cashBackActivity.getAmountModel())){ | |||||
| for(WxVtwoActivityOrder order:orderList){ | |||||
| WxVtwoCashBackAward cashBackAward = null; | |||||
| for(WxVtwoCashBackAward award:sortAmountAwardList){ | |||||
| if((award.getMinAmount() == null || order.getOrderMoney().compareTo(award.getMinAmount()) >= 0) | |||||
| && (award.getMaxAmount() == null || order.getOrderMoney().compareTo(award.getMaxAmount()) <= 0)){ | |||||
| cashBackAward = award; | |||||
| } | |||||
| } | |||||
| if(cashBackAward != null && cashBackAward.getCashBackRatio() != null){ | |||||
| BigDecimal cashBackPrice = order.getOrderMoney().multiply(cashBackAward.getCashBackRatio().divide(new BigDecimal(100))); | |||||
| if(cashBackAward.getCashBackLimit() != null && cashBackAward.getCashBackLimit().compareTo(BigDecimal.ZERO) > 0 | |||||
| && cashBackAward.getCashBackLimit().compareTo(cashBackPrice) < 0 ){ | |||||
| cashBackPrice = cashBackAward.getCashBackLimit(); | |||||
| } | |||||
| cashBackPrice = awardsRulePrice(cashBackPrice,cashBackActivity.getCashBackRule()); | |||||
| if(cashBackPrice.compareTo(BigDecimal.ZERO) > 0){ | |||||
| cashBackTotal = cashBackTotal.add(cashBackPrice); | |||||
| WxVtwoCashBackGrantAward grantAward = new WxVtwoCashBackGrantAward(); | |||||
| grantAward.setName("订单返现("+order.getOrderNo()+")"); | |||||
| grantAward.setOrderId(order.getId()); | |||||
| grantAward.setOrderAmount(order.getOrderMoney()); | |||||
| grantAward.setModeType(EnumOfflineActivityAwardsModeType.AMOUNT.getCode()); | |||||
| grantAward.setCashBackRule(cashBackActivity.getCashBackRule()); | |||||
| grantAward.setCashBack(cashBackPrice); | |||||
| handleGrantAward(grantAward,cashBackAward); | |||||
| grantAwardList.add(grantAward); | |||||
| } | |||||
| } | |||||
| } | |||||
| }else{ | |||||
| BigDecimal orderMoneySum = orderList.stream().filter(order -> EnumYesOrNo.YES.getCode().equals(order.getIsAmount())) | |||||
| .map(WxVtwoActivityOrder::getOrderMoney).reduce(BigDecimal.ZERO, BigDecimal::add); | |||||
| WxVtwoCashBackAward cashBackAward = null; | |||||
| for(WxVtwoCashBackAward award:sortAmountAwardList){ | |||||
| if((award.getMinAmount() == null || orderMoneySum.compareTo(award.getMinAmount()) >= 0) | |||||
| && (award.getMaxAmount() == null || orderMoneySum.compareTo(award.getMaxAmount()) <= 0)){ | |||||
| cashBackAward = award; | |||||
| } | |||||
| } | |||||
| if(cashBackAward != null && cashBackAward.getCashBackRatio() != null){ | |||||
| BigDecimal cashBackPrice = orderMoneySum.multiply(cashBackAward.getCashBackRatio().divide(new BigDecimal(100))); | |||||
| cashBackPrice = awardsRulePrice(cashBackPrice,cashBackActivity.getCashBackRule()); | |||||
| if(cashBackPrice.compareTo(BigDecimal.ZERO) > 0){ | |||||
| cashBackTotal = cashBackTotal.add(cashBackPrice); | |||||
| WxVtwoCashBackGrantAward grantAward = new WxVtwoCashBackGrantAward(); | |||||
| grantAward.setName("订单金额返现"); | |||||
| grantAward.setOrderAmount(orderMoneySum); | |||||
| grantAward.setModeType(EnumOfflineActivityAwardsModeType.AMOUNT.getCode()); | |||||
| grantAward.setCashBackRule(cashBackActivity.getCashBackRule()); | |||||
| grantAward.setCashBack(cashBackPrice); | |||||
| handleGrantAward(grantAward,cashBackAward); | |||||
| grantAwardList.add(grantAward); | |||||
| } | |||||
| } | |||||
| } | |||||
| //联单 | |||||
| Integer jointCount = wxVtwoActivityOrderService.getJointCount(cashBackActivity.getRelatedModel(),orderList); | |||||
| if(jointCount != 0){ | |||||
| Map<Integer, WxVtwoCashBackAward> jointCountMap = cashBackActivity.getRelatedRulesObject().stream().collect(toMap(WxVtwoCashBackAward::getRelatedCount, Function.identity())); | |||||
| WxVtwoCashBackAward cashBackAward = jointCountMap.get(jointCount); | |||||
| if(cashBackAward != null && cashBackAward.getCashBackRatio() != null){ | |||||
| BigDecimal orderMoneySum = orderList.stream().map(WxVtwoActivityOrder::getOrderMoney).reduce(BigDecimal.ZERO, BigDecimal::add); | |||||
| BigDecimal cashBackPrice = orderMoneySum.multiply(cashBackAward.getCashBackRatio().divide(new BigDecimal(100))); | |||||
| cashBackPrice = awardsRulePrice(cashBackPrice,cashBackActivity.getCashBackRule()); | |||||
| if(cashBackPrice.compareTo(BigDecimal.ZERO) > 0){ | |||||
| cashBackTotal = cashBackTotal.add(cashBackPrice); | |||||
| WxVtwoCashBackGrantAward grantAward = new WxVtwoCashBackGrantAward(); | |||||
| grantAward.setName("联单返现"); | |||||
| grantAward.setOrderAmount(orderMoneySum); | |||||
| grantAward.setModeType(EnumOfflineActivityAwardsModeType.COUNT.getCode()); | |||||
| grantAward.setCashBackRule(cashBackActivity.getCashBackRule()); | |||||
| grantAward.setCashBack(cashBackPrice); | |||||
| handleGrantAward(grantAward,cashBackAward); | |||||
| grantAwardList.add(grantAward); | |||||
| } | |||||
| } | |||||
| } | |||||
| //计算返现金额最大限制 | |||||
| BigDecimal prop = BigDecimal.ONE; | |||||
| if(cashBackTotal.compareTo(cashBackActivity.getCashBackLimit()) >= 0){ | |||||
| prop = cashBackActivity.getCashBackLimit().divide(cashBackTotal,4,RoundingMode.HALF_UP); | |||||
| } | |||||
| BigDecimal realCashBackTotal = BigDecimal.ZERO; | |||||
| if(prop.compareTo(BigDecimal.ONE) < 0){ | |||||
| for (WxVtwoCashBackGrantAward grantAward:grantAwardList){ | |||||
| grantAward.setCashBack(awardsRulePrice(grantAward.getCashBack().multiply(prop),cashBackActivity.getCashBackRule())); | |||||
| realCashBackTotal = realCashBackTotal.add(grantAward.getCashBack()); | |||||
| } | |||||
| } | |||||
| activityGrant.setCashBackLimit(cashBackActivity.getCashBackLimit()); | |||||
| activityGrant.setCashBack(realCashBackTotal); | |||||
| if(EnumOfflineActivityMode.ONE.getCode().equals(cashBackActivity.getAmountModel())){ | |||||
| //单独算税点 | |||||
| BigDecimal taxAmount = BigDecimal.ZERO; | |||||
| for (WxVtwoCashBackGrantAward grantAward:grantAwardList){ | |||||
| grantAward.setTaxDeductionRules(cashBackActivity.getTaxDeductionRules()); | |||||
| WxVtwoActivityTaxDeductionRule taxDeductionRulesObject = cashBackActivity.getTaxDeductionRulesObject(); | |||||
| if(taxDeductionRulesObject.getStartingTax() != null && grantAward.getCashBack().compareTo(taxDeductionRulesObject.getStartingTax()) > 0 | |||||
| && taxDeductionRulesObject.getTaxPoints() != null){ | |||||
| grantAward.setTaxAmount(grantAward.getCashBack().multiply(taxDeductionRulesObject.getTaxPoints()) | |||||
| .divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP)); | |||||
| taxAmount = taxAmount.add(grantAward.getTaxAmount()); | |||||
| } | |||||
| } | |||||
| activityGrant.setTaxAmount(taxAmount); | |||||
| }else{ | |||||
| activityGrant.setTaxDeductionRules(cashBackActivity.getTaxDeductionRules()); | |||||
| WxVtwoActivityTaxDeductionRule taxDeductionRulesObject = cashBackActivity.getTaxDeductionRulesObject(); | |||||
| if(taxDeductionRulesObject.getStartingTax() != null && activityGrant.getCashBack().compareTo(taxDeductionRulesObject.getStartingTax()) > 0 | |||||
| && taxDeductionRulesObject.getTaxPoints() != null){ | |||||
| activityGrant.setTaxAmount(activityGrant.getCashBack().multiply(taxDeductionRulesObject.getTaxPoints()) | |||||
| .divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP)); | |||||
| //税点分摊到发奖上面 | |||||
| } | |||||
| } | |||||
| activityGrant.setGrantAwardList(grantAwardList); | |||||
| } | |||||
| private BigDecimal awardsRulePrice(BigDecimal awardsPrice,Integer awardsRule){ | |||||
| BigDecimal awardsRulePrice = BigDecimal.ZERO; | |||||
| if(EnumOfflineActivityAwardsRule.DEF.getCode().equals(awardsRule)){ | |||||
| awardsRulePrice = awardsPrice.setScale(2, RoundingMode.HALF_UP); | |||||
| } else if (EnumOfflineActivityAwardsRule.YUAN.getCode().equals(awardsRule)) { | |||||
| awardsRulePrice = awardsPrice.setScale(0, RoundingMode.HALF_UP); | |||||
| }else if (EnumOfflineActivityAwardsRule.TEN.getCode().equals(awardsRule)){ | |||||
| awardsRulePrice = awardsPrice.divide(new BigDecimal(10)) | |||||
| .setScale(0, RoundingMode.HALF_UP).multiply(new BigDecimal(10)); | |||||
| } | |||||
| return awardsRulePrice; | |||||
| } | |||||
| private void handleGrantAward(WxVtwoCashBackGrantAward grantAward,WxVtwoCashBackAward cashBackAward){ | |||||
| grantAward.setMinAmount(cashBackAward.getMinAmount()); | |||||
| grantAward.setMaxAmount(cashBackAward.getMaxAmount()); | |||||
| grantAward.setAwardId(cashBackAward.getId()); | |||||
| grantAward.setAwardName(cashBackAward.getName()); | |||||
| grantAward.setCashBackRatio(cashBackAward.getCashBackRatio()); | |||||
| grantAward.setShareRule(cashBackAward.getShareRule()); | |||||
| grantAward.setMallShareRate(cashBackAward.getMallShareRate()); | |||||
| grantAward.setMerchantShareRate(cashBackAward.getMerchantShareRate()); | |||||
| } | |||||
| @Override | |||||
| @Transactional(rollbackFor = Exception.class) | |||||
| public void grantAward(WxVtwoCashBackActivity cashBackActivity,WxVtwoCashBackGrant activityGrant) { | |||||
| List<WxVtwoActivityOrder> orderList = wxVtwoActivityOrderService.findGrantOrder(activityGrant,activityGrant.getOrderIdList(),activityGrant.getOrderFilterIdList()); | |||||
| // wxVtwoActivityGrantService.handleFromOrder(amountGiftActivity.getName(),activityGrant,orderList,false); | |||||
| // | |||||
| // wxVtwoActivityGrantService.saveOrUpdate(activityGrant); | |||||
| // | |||||
| // wxVtwoActivityGrantOrderService.saveGrantOrder(activityGrant.getId(),activityGrant.getActivityId(),orderList); | |||||
| // | |||||
| // wxVtwoActivityGrantAwardService.saveGrantAward(activityGrant); | |||||
| // | |||||
| // wxVtwoActivityGrantSettlementService.saveGrantSettlement(activityGrant); | |||||
| } | |||||
| } | } | ||||
| @@ -1,11 +1,22 @@ | |||||
| package com.iformall.service.impl; | package com.iformall.service.impl; | ||||
| import com.alibaba.fastjson.JSON; | |||||
| import com.aliyun.openservices.shade.org.apache.commons.lang3.StringUtils; | |||||
| import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | ||||
| import com.iformall.common.IdWorker; | |||||
| import com.iformall.domain.po.WxVtwoActivityGrant; | |||||
| import com.iformall.domain.po.WxVtwoActivityOrder; | |||||
| import com.iformall.domain.po.WxVtwoCashBackGrant; | import com.iformall.domain.po.WxVtwoCashBackGrant; | ||||
| import com.iformall.service.WxVtwoCashBackGrantService; | import com.iformall.service.WxVtwoCashBackGrantService; | ||||
| import com.iformall.mapper.WxVtwoCashBackGrantMapper; | import com.iformall.mapper.WxVtwoCashBackGrantMapper; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| import java.math.BigDecimal; | |||||
| import java.util.ArrayList; | |||||
| import java.util.Date; | |||||
| import java.util.List; | |||||
| /** | /** | ||||
| * @author xiaohu | * @author xiaohu | ||||
| * @description 针对表【wx_vtwo_cash_back_grant(线下返现活动发奖)】的数据库操作Service实现 | * @description 针对表【wx_vtwo_cash_back_grant(线下返现活动发奖)】的数据库操作Service实现 | ||||
| @@ -15,6 +26,56 @@ import org.springframework.stereotype.Service; | |||||
| public class WxVtwoCashBackGrantServiceImpl extends ServiceImpl<WxVtwoCashBackGrantMapper, WxVtwoCashBackGrant> | public class WxVtwoCashBackGrantServiceImpl extends ServiceImpl<WxVtwoCashBackGrantMapper, WxVtwoCashBackGrant> | ||||
| implements WxVtwoCashBackGrantService{ | implements WxVtwoCashBackGrantService{ | ||||
| @Autowired | |||||
| private WxVtwoCashBackGrantMapper wxVtwoCashBackGrantMapper; | |||||
| @Override | |||||
| public void handleFromOrder(String activityName, WxVtwoCashBackGrant activityGrant, List<WxVtwoActivityOrder> orderList, boolean isGrant) { | |||||
| activityGrant.setActivityName(activityName); | |||||
| activityGrant.setOrderList(orderList); | |||||
| BigDecimal orderMoneySum = BigDecimal.ZERO; | |||||
| List<String> lotteryNumList = new ArrayList<>(); | |||||
| int lotteryCount = 0; | |||||
| List<String> anniversaryLotteryNumList = new ArrayList<>(); | |||||
| for (WxVtwoActivityOrder order : orderList) { | |||||
| orderMoneySum = orderMoneySum.add(order.getOrderMoney()); | |||||
| if(order.getLotteryNumList() != null && !order.getLotteryNumList().isEmpty()){ | |||||
| lotteryNumList.addAll(order.getLotteryNumList()); | |||||
| } | |||||
| if(order.getLotteryCount() != null){ | |||||
| lotteryCount = lotteryCount + order.getLotteryCount(); | |||||
| } | |||||
| if(StringUtils.isNotBlank(order.getAnniversaryLotteryNum())){ | |||||
| anniversaryLotteryNumList.add(order.getAnniversaryLotteryNum()); | |||||
| } | |||||
| } | |||||
| activityGrant.setOrderMoneySum(orderMoneySum); | |||||
| activityGrant.setOrderCount(orderList.size()); | |||||
| activityGrant.setCusName(orderList.get(0).getCusName()); | |||||
| activityGrant.setCusPhone(orderList.get(0).getCusPhone()); | |||||
| if(!isGrant){ | |||||
| activityGrant.setLotteryNum(JSON.toJSONString(lotteryNumList)); | |||||
| activityGrant.setLotteryCount(lotteryCount); | |||||
| activityGrant.setAnniversaryLotteryNum(JSON.toJSONString(anniversaryLotteryNumList)); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public boolean saveOrUpdate(WxVtwoCashBackGrant activityGrant) { | |||||
| Date now = new Date(); | |||||
| if(activityGrant.getId() == null){ | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| activityGrant.setId(idWorker.nextId()); | |||||
| activityGrant.setCreateDate(now); | |||||
| activityGrant.setCreateDate(now); | |||||
| wxVtwoCashBackGrantMapper.insert(activityGrant); | |||||
| } | |||||
| else{ | |||||
| activityGrant.setUpdateDate(now); | |||||
| wxVtwoCashBackGrantMapper.updateById(activityGrant); | |||||
| } | |||||
| return true; | |||||
| } | |||||
| } | } | ||||
| @@ -299,7 +299,7 @@ public class WxVtwoPrizeDrawActivityServiceImpl extends ServiceImpl<WxVtwoPrizeD | |||||
| if(order_limit > 0){ | if(order_limit > 0){ | ||||
| WxVtwoActivityGrantRule grantRule = new WxVtwoActivityGrantRule(); | WxVtwoActivityGrantRule grantRule = new WxVtwoActivityGrantRule(); | ||||
| grantRule.setModeType(EnumOfflineActivityAwardsModeType.AMOUNT.getCode()); | grantRule.setModeType(EnumOfflineActivityAwardsModeType.AMOUNT.getCode()); | ||||
| grantRule.setName("订单总金额抽奖"); | |||||
| grantRule.setName("订单金额抽奖"); | |||||
| grantRule.setAwardLimit(order_limit); | grantRule.setAwardLimit(order_limit); | ||||
| grantRuleList.add(grantRule); | grantRuleList.add(grantRule); | ||||
| @@ -14,7 +14,7 @@ | |||||
| <result property="amountModel" column="amount_model" jdbcType="SMALLINT"/> | <result property="amountModel" column="amount_model" jdbcType="SMALLINT"/> | ||||
| <result property="businessOrderLimit" column="business_order_limit" jdbcType="INTEGER"/> | <result property="businessOrderLimit" column="business_order_limit" jdbcType="INTEGER"/> | ||||
| <result property="relatedModel" column="related_model" jdbcType="SMALLINT"/> | <result property="relatedModel" column="related_model" jdbcType="SMALLINT"/> | ||||
| <result property="cashBackLimit" column="cash_back_limit" jdbcType="INTEGER"/> | |||||
| <result property="cashBackLimit" column="cash_back_limit" jdbcType="DECIMAL"/> | |||||
| <result property="cashBackRule" column="cash_back_rule" jdbcType="SMALLINT"/> | <result property="cashBackRule" column="cash_back_rule" jdbcType="SMALLINT"/> | ||||
| <result property="taxDeductionRules" column="tax_deduction_rules" jdbcType="VARCHAR"/> | <result property="taxDeductionRules" column="tax_deduction_rules" jdbcType="VARCHAR"/> | ||||
| <result property="merchantRule" column="merchant_rule" jdbcType="SMALLINT"/> | <result property="merchantRule" column="merchant_rule" jdbcType="SMALLINT"/> | ||||
| @@ -15,7 +15,7 @@ | |||||
| <result property="relatedCount" column="related_count" jdbcType="INTEGER"/> | <result property="relatedCount" column="related_count" jdbcType="INTEGER"/> | ||||
| <result property="name" column="name" jdbcType="VARCHAR"/> | <result property="name" column="name" jdbcType="VARCHAR"/> | ||||
| <result property="cashBackRatio" column="cash_back_ratio" jdbcType="DECIMAL"/> | <result property="cashBackRatio" column="cash_back_ratio" jdbcType="DECIMAL"/> | ||||
| <result property="cashBackLimit" column="cash_back_limit" jdbcType="INTEGER"/> | |||||
| <result property="cashBackLimit" column="cash_back_limit" jdbcType="DECIMAL"/> | |||||
| <result property="shareRule" column="share_rule" jdbcType="SMALLINT"/> | <result property="shareRule" column="share_rule" jdbcType="SMALLINT"/> | ||||
| <result property="mallShareRate" column="mall_share_rate" jdbcType="DECIMAL"/> | <result property="mallShareRate" column="mall_share_rate" jdbcType="DECIMAL"/> | ||||
| <result property="merchantShareRate" column="merchant_share_rate" jdbcType="DECIMAL"/> | <result property="merchantShareRate" column="merchant_share_rate" jdbcType="DECIMAL"/> | ||||
| @@ -20,11 +20,9 @@ | |||||
| <result property="realName" column="real_name" jdbcType="VARCHAR"/> | <result property="realName" column="real_name" jdbcType="VARCHAR"/> | ||||
| <result property="realCard" column="real_card" jdbcType="VARCHAR"/> | <result property="realCard" column="real_card" jdbcType="VARCHAR"/> | ||||
| <result property="cashBackLimit" column="cash_back_limit" jdbcType="DECIMAL"/> | <result property="cashBackLimit" column="cash_back_limit" jdbcType="DECIMAL"/> | ||||
| <result property="cashBackRule" column="cash_back_rule" jdbcType="SMALLINT"/> | |||||
| <result property="cashBack" column="cash_back" jdbcType="DECIMAL"/> | <result property="cashBack" column="cash_back" jdbcType="DECIMAL"/> | ||||
| <result property="taxDeductionRules" column="tax_deduction_rules" jdbcType="VARCHAR"/> | <result property="taxDeductionRules" column="tax_deduction_rules" jdbcType="VARCHAR"/> | ||||
| <result property="taxAmount" column="tax_amount" jdbcType="DECIMAL"/> | <result property="taxAmount" column="tax_amount" jdbcType="DECIMAL"/> | ||||
| <result property="realCashBack" column="real_cash_back" jdbcType="DECIMAL"/> | |||||
| <result property="remark" column="remark" jdbcType="VARCHAR"/> | <result property="remark" column="remark" jdbcType="VARCHAR"/> | ||||
| <result property="signImg" column="sign_img" jdbcType="VARCHAR"/> | <result property="signImg" column="sign_img" jdbcType="VARCHAR"/> | ||||
| <result property="status" column="status" jdbcType="SMALLINT"/> | <result property="status" column="status" jdbcType="SMALLINT"/> | ||||
| @@ -39,8 +37,8 @@ | |||||
| order_count,cus_name,cus_phone, | order_count,cus_name,cus_phone, | ||||
| lottery_num,lottery_count,anniversary_lottery_num, | lottery_num,lottery_count,anniversary_lottery_num, | ||||
| real_name,real_card,cash_back_limit, | real_name,real_card,cash_back_limit, | ||||
| cash_back_rule,cash_back,tax_deduction_rules, | |||||
| tax_amount,real_cash_back,remark,sign_img, | |||||
| cash_back,tax_deduction_rules, | |||||
| tax_amount,remark,sign_img, | |||||
| status,create_by,create_date, | status,create_by,create_date, | ||||
| update_date | update_date | ||||
| </sql> | </sql> | ||||