From ec87cf1ee2b9382bf9d089711f0ff82ae8e7077c Mon Sep 17 00:00:00 2001 From: jyy <jyy> Date: Wed, 09 Jun 2021 20:44:16 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/api_score_meger' into api_score_meger --- zq-erp/src/main/java/com/matrix/system/score/action/ScoreRuleSettingAction.java | 274 ++++++++++++++++++++++++++---------------------------- 1 files changed, 133 insertions(+), 141 deletions(-) diff --git a/zq-erp/src/main/java/com/matrix/system/score/action/ScoreRuleSettingAction.java b/zq-erp/src/main/java/com/matrix/system/score/action/ScoreRuleSettingAction.java index 9cb88db..25a2ee1 100644 --- a/zq-erp/src/main/java/com/matrix/system/score/action/ScoreRuleSettingAction.java +++ b/zq-erp/src/main/java/com/matrix/system/score/action/ScoreRuleSettingAction.java @@ -1,141 +1,133 @@ -package com.matrix.system.score.action; - -import com.matrix.core.constance.MatrixConstance; -import com.matrix.core.pojo.AjaxResult; -import com.matrix.core.tools.WebUtil; -import com.matrix.system.common.bean.BusParameterSettings; -import com.matrix.system.common.bean.SysUsers; -import com.matrix.system.common.dao.BusParameterSettingsDao; -import com.matrix.system.score.constant.ScoreSettingConstant; -import com.matrix.system.score.service.ScoreRuleSettingService; -import com.matrix.system.score.vo.ScoreRuleSettingsVo; - -import cn.hutool.core.util.StrUtil; - -import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * @author wzy - * @date 2021-02-22 - **/ -@RestController -@RequestMapping(value = "/score/ruleSetting") -public class ScoreRuleSettingAction { - - @Autowired - private ScoreRuleSettingService scoreRuleSettingService; - @Autowired - private BusParameterSettingsDao busParameterSettingsDao; - - - @GetMapping(value = "/testApi") - public AjaxResult testApi() { - scoreRuleSettingService.testMethod(); - return AjaxResult.buildSuccessInstance("success"); - } - - /** - *查询积分规则配置 - */ - @RequestMapping(value = "/selectScoreRule") - public AjaxResult selectScoreRule() { - - AjaxResult result= AjaxResult.buildSuccessInstance("查询成功"); - SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); - Long companyId = user.getCompanyId(); - - //积分有效期 - String[] jfyxqArrayCode={ScoreSettingConstant.VALID_PERIOD_POINTS}; - String[] jfyxqArrayName={"积分有效期:从获得开始 到"}; - List<ScoreRuleSettingsVo> jfyxqRuleSettingsVo = getRuleSettingsVo(jfyxqArrayCode,jfyxqArrayName,companyId); - result.putInMap("jfyxq", jfyxqRuleSettingsVo); - //积分抵扣现金 - String[] jfdxjArrayCode={ScoreSettingConstant.CREDIT_POINTS_CASH}; - String[] jfdxjArrayName={"积分抵扣现金"}; - List<BusParameterSettings> dataList = busParameterSettingsDao.selectByCodesAndCompanyId(Arrays.asList(jfdxjArrayCode), companyId); - List<ScoreRuleSettingsVo> jfdxjRuleSettingsVo=new ArrayList<ScoreRuleSettingsVo>(); - int index=0; - for (BusParameterSettings item:dataList){ - ScoreRuleSettingsVo paramVo=new ScoreRuleSettingsVo(); - BeanUtils.copyProperties(item,paramVo); - paramVo.setParamName(jfdxjArrayName[index]); - String paramValue = paramVo.getParamValue(); - if(StrUtil.isNotEmpty(paramValue)) { - paramVo.setParamSwitch(Boolean.TRUE); - }else { - paramVo.setParamSwitch(Boolean.FALSE); - } - jfdxjRuleSettingsVo.add(paramVo); - index++; - } - result.putInMap("jfdxj", jfdxjRuleSettingsVo); - //门店积分规则 - String[] mdjfArrayCode={ - ScoreSettingConstant.CASH_CONSUMPTION, - ScoreSettingConstant.PRINCIPAL_BALANCE_CONSUMPTION, - ScoreSettingConstant.BONUS_BALANCE_CONSUMPTION, - ScoreSettingConstant.PRINCIPAL_CONSUMPTION, - ScoreSettingConstant.GIVE_CONSUMPTION, - ScoreSettingConstant.REFERRALS_CONSUMPTION}; - String[] mdjfArrayName={ - "现金消费", - "本金余额消费", - "赠金余额消费", - "本金消耗", - "赠送消耗", - "转介客户"}; - List<ScoreRuleSettingsVo> mdjfRuleSettingsVo = getRuleSettingsVo(mdjfArrayCode,mdjfArrayName,companyId); - result.putInMap("mdjf", mdjfRuleSettingsVo); - //商城积分规则 - String[] scjfArrayCode={ - ScoreSettingConstant.CASH_CONSUMPTION_SHOP, - ScoreSettingConstant.RESERVATION_SERVICE_SHOP, - ScoreSettingConstant.EVALUATUIN_ORDER_SHOP, - ScoreSettingConstant.SIGN_SHOP}; - String[] scjfArrayName={ - "现金消费", - "预约服务", - "评价订单", - "签到"}; - List<ScoreRuleSettingsVo> scjfRuleSettingsVo =getRuleSettingsVo(scjfArrayCode,scjfArrayName,companyId); - result.putInMap("scjf", scjfRuleSettingsVo); - return result; - } - - /** - *获取对应的积分规则设置数据 - * @param ArrayCode - * @param ArrayName - * @param companyId - * @return - */ - private List<ScoreRuleSettingsVo> getRuleSettingsVo(String[] ArrayCode,String[] ArrayName,Long companyId){ - List<BusParameterSettings> dataList = busParameterSettingsDao.selectByCodesAndCompanyId(Arrays.asList(ArrayCode), companyId); - List<ScoreRuleSettingsVo> scoreRuleSettingsVos=new ArrayList<ScoreRuleSettingsVo>(); - int index=0; - for (BusParameterSettings item:dataList){ - ScoreRuleSettingsVo paramVo=new ScoreRuleSettingsVo(); - BeanUtils.copyProperties(item,paramVo); - paramVo.setParamName(ArrayName[index]); - scoreRuleSettingsVos.add(paramVo); - index++; - } - return scoreRuleSettingsVos; - } - - /** - * 修改公司维度的积分规则 - */ - @PostMapping(value = "/updateScoreRule") - public @ResponseBody - AjaxResult updateScoreRule(@RequestBody List<BusParameterSettings> busParameterSettings) { - return scoreRuleSettingService.updateScoreRuleByCompanyId(busParameterSettings); - } - -} +package com.matrix.system.score.action; + +import com.matrix.core.constance.MatrixConstance; +import com.matrix.core.pojo.AjaxResult; +import com.matrix.core.tools.WebUtil; +import com.matrix.system.common.bean.BusParameterSettings; +import com.matrix.system.common.bean.SysUsers; +import com.matrix.system.common.dao.BusParameterSettingsDao; +import com.matrix.system.score.constant.ScoreSettingConstant; +import com.matrix.system.score.service.ScoreRuleSettingService; +import com.matrix.system.score.vo.ScoreRuleSettingsVo; + +import cn.hutool.core.util.StrUtil; + +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +/** + * @author wzy + * @date 2021-02-22 + **/ +@RestController +@RequestMapping(value = "/score/ruleSetting") +public class ScoreRuleSettingAction { + + @Autowired + private ScoreRuleSettingService scoreRuleSettingService; + @Autowired + private BusParameterSettingsDao busParameterSettingsDao; + + + /** + *查询积分规则配置 + */ + @RequestMapping(value = "/selectScoreRule") + public AjaxResult selectScoreRule() { + + AjaxResult result= AjaxResult.buildSuccessInstance("查询成功"); + SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); + Long companyId = user.getCompanyId(); + + //积分有效期 + String[] jfyxqArrayCode={ScoreSettingConstant.VALID_PERIOD_POINTS}; + String[] jfyxqArrayName={"积分有效期:从获得开始 到"}; + List<ScoreRuleSettingsVo> jfyxqRuleSettingsVo = getRuleSettingsVo(jfyxqArrayCode,jfyxqArrayName,companyId); + result.putInMap("jfyxq", jfyxqRuleSettingsVo); + //积分抵扣现金 + String[] jfdxjArrayCode={ScoreSettingConstant.CREDIT_POINTS_CASH}; + String[] jfdxjArrayName={"积分抵扣现金"}; + List<BusParameterSettings> dataList = busParameterSettingsDao.selectByCodesAndCompanyId(Arrays.asList(jfdxjArrayCode), companyId); + List<ScoreRuleSettingsVo> jfdxjRuleSettingsVo=new ArrayList<ScoreRuleSettingsVo>(); + int index=0; + for (BusParameterSettings item:dataList){ + ScoreRuleSettingsVo paramVo=new ScoreRuleSettingsVo(); + BeanUtils.copyProperties(item,paramVo); + paramVo.setParamName(jfdxjArrayName[index]); + String paramValue = paramVo.getParamValue(); + if(StrUtil.isNotEmpty(paramValue)) { + paramVo.setParamSwitch(Boolean.TRUE); + }else { + paramVo.setParamSwitch(Boolean.FALSE); + } + jfdxjRuleSettingsVo.add(paramVo); + index++; + } + result.putInMap("jfdxj", jfdxjRuleSettingsVo); + //门店积分规则 + String[] mdjfArrayCode={ + ScoreSettingConstant.CASH_CONSUMPTION, + ScoreSettingConstant.PRINCIPAL_BALANCE_CONSUMPTION, + ScoreSettingConstant.BONUS_BALANCE_CONSUMPTION, + ScoreSettingConstant.PRINCIPAL_CONSUMPTION, + ScoreSettingConstant.GIVE_CONSUMPTION, + ScoreSettingConstant.REFERRALS_CONSUMPTION}; + String[] mdjfArrayName={ + "现金消费", + "本金余额消费", + "赠金余额消费", + "本金消耗", + "赠送消耗", + "转介客户"}; + List<ScoreRuleSettingsVo> mdjfRuleSettingsVo = getRuleSettingsVo(mdjfArrayCode,mdjfArrayName,companyId); + result.putInMap("mdjf", mdjfRuleSettingsVo); + //商城积分规则 + String[] scjfArrayCode={ + ScoreSettingConstant.CASH_CONSUMPTION_SHOP, + ScoreSettingConstant.RESERVATION_SERVICE_SHOP, + ScoreSettingConstant.EVALUATUIN_ORDER_SHOP}; + String[] scjfArrayName={ + "现金消费", + "预约服务", + "评价订单"}; + List<ScoreRuleSettingsVo> scjfRuleSettingsVo =getRuleSettingsVo(scjfArrayCode,scjfArrayName,companyId); + result.putInMap("scjf", scjfRuleSettingsVo); + return result; + } + + /** + *获取对应的积分规则设置数据 + * @param ArrayCode + * @param ArrayName + * @param companyId + * @return + */ + private List<ScoreRuleSettingsVo> getRuleSettingsVo(String[] ArrayCode,String[] ArrayName,Long companyId){ + List<BusParameterSettings> dataList = busParameterSettingsDao.selectByCodesAndCompanyId(Arrays.asList(ArrayCode), companyId); + List<ScoreRuleSettingsVo> scoreRuleSettingsVos=new ArrayList<ScoreRuleSettingsVo>(); + int index=0; + for (BusParameterSettings item:dataList){ + ScoreRuleSettingsVo paramVo=new ScoreRuleSettingsVo(); + BeanUtils.copyProperties(item,paramVo); + paramVo.setParamName(ArrayName[index]); + scoreRuleSettingsVos.add(paramVo); + index++; + } + return scoreRuleSettingsVos; + } + + /** + * 修改公司维度的积分规则 + */ + @PostMapping(value = "/updateScoreRule") + public @ResponseBody + AjaxResult updateScoreRule(@RequestBody List<BusParameterSettings> busParameterSettings) { + return scoreRuleSettingService.updateScoreRuleByCompanyId(busParameterSettings); + } + +} -- Gitblit v1.9.1