zq-erp/src/main/java/com/matrix/system/common/dao/BusParameterSettingsDao.java
@@ -1,52 +1,52 @@ package com.matrix.system.common.dao; import com.matrix.core.pojo.PaginationVO; import com.matrix.system.common.bean.BusParameterSettings; import org.apache.ibatis.annotations.Param; import java.util.List; import java.util.Map; /** * This field was generated by Zking.software.Codegen. * @date 2016-11-28 16:55 */ public interface BusParameterSettingsDao { public int insert(BusParameterSettings busParameterSettings); public int batchInsert(@Param("list") List<BusParameterSettings> busParameterSettingsList); public int updateByMap(Map<String, Object> modifyMap); public int updateByModel(BusParameterSettings busParameterSettings); public int deleteByIds(@Param("list") List<Long> list); public int deleteById(Long paramId); public int deleteByModel(@Param("record") BusParameterSettings busParameterSettings); public List<BusParameterSettings> selectInPage(@Param("record") BusParameterSettings busParameterSettings, @Param("pageVo") PaginationVO pageVo); public List<BusParameterSettings> selectByModel(@Param("record") BusParameterSettings busParameterSettings); public int selectTotalRecord(@Param("record") BusParameterSettings busParameterSettings); public BusParameterSettings selectById(Long paramId); public BusParameterSettings selectForUpdate(Long paramId); List<BusParameterSettings> selectByCodes(@Param("list")List<String> codeList, @Param("companyId")Long companyId,@Param("shopId")Long shopId); BusParameterSettings selectByCode(@Param("code")String code, @Param("companyId")Long companyId,@Param("shopId")Long shopId); BusParameterSettings selectCompanyParamByCode(@Param("code")String code, @Param("companyId")Long companyId); int updateParams(@Param("list")List<BusParameterSettings> parameterSettings, @Param("companyId")Long companyId); package com.matrix.system.common.dao; import com.matrix.core.pojo.PaginationVO; import com.matrix.system.common.bean.BusParameterSettings; import org.apache.ibatis.annotations.Param; import java.util.List; import java.util.Map; /** * This field was generated by Zking.software.Codegen. * @date 2016-11-28 16:55 */ public interface BusParameterSettingsDao { public int insert(BusParameterSettings busParameterSettings); public int batchInsert(@Param("list") List<BusParameterSettings> busParameterSettingsList); public int updateByMap(Map<String, Object> modifyMap); public int updateByModel(BusParameterSettings busParameterSettings); public int deleteByIds(@Param("list") List<Long> list); public int deleteById(Long paramId); public int deleteByModel(@Param("record") BusParameterSettings busParameterSettings); public List<BusParameterSettings> selectInPage(@Param("record") BusParameterSettings busParameterSettings, @Param("pageVo") PaginationVO pageVo); public List<BusParameterSettings> selectByModel(@Param("record") BusParameterSettings busParameterSettings); public int selectTotalRecord(@Param("record") BusParameterSettings busParameterSettings); public BusParameterSettings selectById(Long paramId); public BusParameterSettings selectForUpdate(Long paramId); List<BusParameterSettings> selectByCodes(@Param("list")List<String> codeList, @Param("companyId")Long companyId,@Param("shopId")Long shopId); List<BusParameterSettings> selectByCodesAndCompanyId(@Param("list")List<String> codeList, @Param("companyId")Long companyId); BusParameterSettings selectByCode(@Param("code")String code, @Param("companyId")Long companyId,@Param("shopId")Long shopId); BusParameterSettings selectCompanyParamByCode(@Param("code")String code, @Param("companyId")Long companyId); int updateParams(@Param("list")List<BusParameterSettings> parameterSettings, @Param("companyId")Long companyId); } zq-erp/src/main/java/com/matrix/system/common/service/impl/InitBusParameterSettingService.java
New file @@ -0,0 +1,51 @@ package com.matrix.system.common.service.impl; import com.matrix.system.common.bean.BusParameterSettings; import com.matrix.system.common.bean.SysCompany; import com.matrix.system.common.dao.BusParameterSettingsDao; import com.matrix.system.score.constant.ScoreSettingConstant; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; @Service public class InitBusParameterSettingService { @Autowired private BusParameterSettingsDao busParameterSettingsDao; /** * 初始化默认积分规则设置 */ public void initBusParameterSetting(SysCompany sysCompany) { long companyId = sysCompany.getComId(); List<BusParameterSettings> ruleSettings=new ArrayList<>(); ruleSettings.add(addScoreRuleSetting(ScoreSettingConstant.VALID_PERIOD_POINTS, companyId)); ruleSettings.add(addScoreRuleSetting(ScoreSettingConstant.CREDIT_POINTS_CASH, companyId)); ruleSettings.add(addScoreRuleSetting(ScoreSettingConstant.CASH_CONSUMPTION, companyId)); ruleSettings.add(addScoreRuleSetting(ScoreSettingConstant.PRINCIPAL_BALANCE_CONSUMPTION, companyId)); ruleSettings.add(addScoreRuleSetting(ScoreSettingConstant.BONUS_BALANCE_CONSUMPTION, companyId)); ruleSettings.add(addScoreRuleSetting(ScoreSettingConstant.PRINCIPAL_CONSUMPTION, companyId)); ruleSettings.add(addScoreRuleSetting(ScoreSettingConstant.GIVE_CONSUMPTION, companyId)); ruleSettings.add(addScoreRuleSetting(ScoreSettingConstant.REFERRALS_CONSUMPTION, companyId)); ruleSettings.add(addScoreRuleSetting(ScoreSettingConstant.CASH_CONSUMPTION_SHOP, companyId)); ruleSettings.add(addScoreRuleSetting(ScoreSettingConstant.RESERVATION_SERVICE_SHOP, companyId)); ruleSettings.add(addScoreRuleSetting(ScoreSettingConstant.EVALUATUIN_ORDER_SHOP, companyId)); ruleSettings.add(addScoreRuleSetting(ScoreSettingConstant.SIGN_SHOP, companyId)); busParameterSettingsDao.batchInsert(ruleSettings); } private BusParameterSettings addScoreRuleSetting(String code,long companyId) { BusParameterSettings busParameterSetting = new BusParameterSettings(); busParameterSetting.setParamCode(code); busParameterSetting.setCompanyId(companyId); return busParameterSetting; } } zq-erp/src/main/java/com/matrix/system/common/service/impl/SysCompanyServiceImpl.java
@@ -1,245 +1,249 @@ package com.matrix.system.common.service.impl; import com.matrix.core.constance.MatrixConstance; import com.matrix.core.constance.SystemErrorCode; import com.matrix.core.exception.GlobleException; import com.matrix.core.pojo.PaginationVO; import com.matrix.core.tools.ModelUtils; import com.matrix.core.tools.StringUtils; import com.matrix.core.tools.WebUtil; import com.matrix.system.common.bean.*; import com.matrix.system.common.dao.SysCompanyDao; import com.matrix.system.common.dao.SysRoleDao; import com.matrix.system.common.dao.SysRolePwoerFnDao; import com.matrix.system.common.service.SysCompanyService; import com.matrix.system.hive.bean.SysShopInfo; import com.matrix.system.hive.bean.Warehouse; import com.matrix.system.hive.dao.SysShopInfoDao; import com.matrix.system.hive.dao.WarehouseDao; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; import java.util.Map; /** * 公司管理 * * @author JIANGYOUYAO * @email 935090232@qq.com * @date Dec 11, 2017 */ @Service public class SysCompanyServiceImpl implements SysCompanyService { @Autowired private SysCompanyDao sysCompanyDao; @Autowired private SysRoleDao sysRoleDao; @Autowired private SysRolePwoerFnDao rolePwoerFnDao; @Autowired private SysShopInfoDao shopInfoDao; @Autowired private InitCustomerDataDictionaryService initCustomerDataDictionaryService; @Autowired private InitShoppingGoodsCategoryService initShoppingGoodsCategoryService; @Autowired private InitRolePowerService initRolePowerService; @Autowired private InitGoodsTypeService initGoodsTypeService; @Autowired private InitShopProductCateService initShopProductCateService; @Transactional @Override public int add(SysCompany sysCompany) { SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); sysCompany.setCreateBy(user.getSuName()); sysCompany.setUpdateBy(user.getSuName()); int i= sysCompanyDao.insert(sysCompany); SysShopInfo zbShop= addZbShop(sysCompany); initCustomerDataDictionaryService.initCustomerDataDictionary(sysCompany); initShoppingGoodsCategoryService.initShoppingGoodsCategory(sysCompany,zbShop); initRolePowerService.initRolePower(sysCompany); initGoodsTypeService.initRolePower(sysCompany); initShopProductCateService.initShopProductCate(sysCompany); return i; } @Autowired private WarehouseDao warehouseDao; /** * 为新公司创建一个总部 * @param sysCompany */ private SysShopInfo addZbShop(SysCompany sysCompany) { SysShopInfo zbShopInfo=new SysShopInfo(); zbShopInfo.setShopType(SysShopInfo.SHOP_TYPE_ZONGBU); zbShopInfo.setShopName(sysCompany.getComName()+"(总部)"); zbShopInfo.setCompanyId(sysCompany.getComId()); zbShopInfo.setShopTel(sysCompany.getComTel()); zbShopInfo.setShopShortName("总部"); zbShopInfo.setIsOpenNet(SysShopInfo.CLOSE_NET); zbShopInfo.setShopNo(StringUtils.getRandomString(10)); shopInfoDao.insert(zbShopInfo); //新增一个总部仓库 Warehouse warehouse=new Warehouse(); warehouse.setCompanyId(sysCompany.getComId()); warehouse.setName("总部仓库"); warehouse.setShopId(zbShopInfo.getId()); warehouse.setSort("1"); warehouseDao.insert(warehouse); return zbShopInfo; } @Transactional(rollbackFor = Exception.class) @Override public int modifyByMap(SysCompany oldSysCompany, SysCompany newSysCompany) { SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); newSysCompany.setUpdateBy(user.getSuName()); updatePower(newSysCompany); Map<String, Object> modifyMap = null; try { if (!ModelUtils.isModified(oldSysCompany, newSysCompany)) { return MatrixConstance.DML_SUCCESSS; } modifyMap = ModelUtils.comparePojo2Map(oldSysCompany, newSysCompany); } catch (Exception e) { throw new GlobleException(SystemErrorCode.DATA_UPDATE_FAIL, e, newSysCompany.getComName()); } if (modifyMap.size() > 0) { modifyMap.put("comId", oldSysCompany.getComId()); return sysCompanyDao.updateByMap(modifyMap); } return MatrixConstance.DML_SUCCESSS; } /** * 更新公司员工权限 * * @author JIANGYOUYAO * @email 935090232@qq.com * @date 2017年12月5日 * @param newSysCompany */ private void updatePower(SysCompany newSysCompany) { List<String> oldFunctions = null; String functions = sysCompanyDao.selectById(newSysCompany.getComId()).getComFunctions(); if (functions == null || functions.equals("")) { oldFunctions = new ArrayList<>(); } else { oldFunctions = StringUtils .strToCollToString(sysCompanyDao.selectById(newSysCompany.getComId()).getComFunctions(), ","); } List<String> newFunctions = new ArrayList<>(); if (StringUtils.isNotBlank(newSysCompany.getComFunctions())) { newFunctions = StringUtils.strToCollToString(newSysCompany.getComFunctions(), ","); } for (String old : oldFunctions) { // 如果新权限中不包含这个老的功能,则要更新改企业下所有的角色权限 if (!newFunctions.contains(old)) { SysRole role = new SysRole(); role.setCompanyId(newSysCompany.getComId()); List<SysRole> roles = sysRoleDao.selectByModel(role); // 获取该公司下所有的权限信息 List<SysRolePwoerFn> compalyRolePwoer = new ArrayList<>(); for (SysRole tempRole : roles) { SysRolePwoerFn r = new SysRolePwoerFn(); r.setRoleId(tempRole.getRoleId()); compalyRolePwoer.addAll(rolePwoerFnDao.selectByModel(r)); } // 记录要删除的id List<String> delRolePwoer = new ArrayList<>(); for (SysRolePwoerFn rolePwoer : compalyRolePwoer) { // 如果有一个老权限则删除这个权限 if (rolePwoer.getFnId() != null && rolePwoer.getFnId().equals(old)) { delRolePwoer.add(rolePwoer.getRpfId()+""); } } // 如果获取到了就删除 if (!delRolePwoer.isEmpty()) { rolePwoerFnDao.deleteByIds(delRolePwoer); } } } } @Override public int modifyByModel(SysCompany sysCompany) { return sysCompanyDao.updateByModel(sysCompany); } @Override public int remove(List<String> list) { return sysCompanyDao.deleteByIds(list); } @Override public int removeById(String comId) { return sysCompanyDao.deleteById(Long.parseLong(comId)); } @Override public int removeByModel(SysCompany sysCompany) { return sysCompanyDao.deleteByModel(sysCompany); } @Override public List<SysCompany> findInPage(SysCompany sysCompany, PaginationVO pageVo) { return sysCompanyDao.selectInPage(sysCompany, pageVo); } @Override public List<SysCompany> findByModel(SysCompany sysCompany) { return sysCompanyDao.selectByModel(sysCompany); } @Override public int findTotal(SysCompany sysCompany) { return sysCompanyDao.selectTotalRecord(sysCompany); } @Override public SysCompany findById(String comId) { return sysCompanyDao.selectById(Long.parseLong(comId)); } package com.matrix.system.common.service.impl; import com.matrix.core.constance.MatrixConstance; import com.matrix.core.constance.SystemErrorCode; import com.matrix.core.exception.GlobleException; import com.matrix.core.pojo.PaginationVO; import com.matrix.core.tools.ModelUtils; import com.matrix.core.tools.StringUtils; import com.matrix.core.tools.WebUtil; import com.matrix.system.common.bean.*; import com.matrix.system.common.dao.SysCompanyDao; import com.matrix.system.common.dao.SysRoleDao; import com.matrix.system.common.dao.SysRolePwoerFnDao; import com.matrix.system.common.service.SysCompanyService; import com.matrix.system.hive.bean.SysShopInfo; import com.matrix.system.hive.bean.Warehouse; import com.matrix.system.hive.dao.SysShopInfoDao; import com.matrix.system.hive.dao.WarehouseDao; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; import java.util.Map; /** * 公司管理 * * @author JIANGYOUYAO * @email 935090232@qq.com * @date Dec 11, 2017 */ @Service public class SysCompanyServiceImpl implements SysCompanyService { @Autowired private SysCompanyDao sysCompanyDao; @Autowired private SysRoleDao sysRoleDao; @Autowired private SysRolePwoerFnDao rolePwoerFnDao; @Autowired private SysShopInfoDao shopInfoDao; @Autowired private InitCustomerDataDictionaryService initCustomerDataDictionaryService; @Autowired private InitShoppingGoodsCategoryService initShoppingGoodsCategoryService; @Autowired private InitRolePowerService initRolePowerService; @Autowired private InitGoodsTypeService initGoodsTypeService; @Autowired private InitShopProductCateService initShopProductCateService; @Autowired private InitBusParameterSettingService initBusParameterSettingService; @Transactional @Override public int add(SysCompany sysCompany) { SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); sysCompany.setCreateBy(user.getSuName()); sysCompany.setUpdateBy(user.getSuName()); int i= sysCompanyDao.insert(sysCompany); SysShopInfo zbShop= addZbShop(sysCompany); initCustomerDataDictionaryService.initCustomerDataDictionary(sysCompany); initShoppingGoodsCategoryService.initShoppingGoodsCategory(sysCompany,zbShop); initRolePowerService.initRolePower(sysCompany); initGoodsTypeService.initRolePower(sysCompany); initShopProductCateService.initShopProductCate(sysCompany); initBusParameterSettingService.initBusParameterSetting(sysCompany); return i; } @Autowired private WarehouseDao warehouseDao; /** * 为新公司创建一个总部 * @param sysCompany */ private SysShopInfo addZbShop(SysCompany sysCompany) { SysShopInfo zbShopInfo=new SysShopInfo(); zbShopInfo.setShopType(SysShopInfo.SHOP_TYPE_ZONGBU); zbShopInfo.setShopName(sysCompany.getComName()+"(总部)"); zbShopInfo.setCompanyId(sysCompany.getComId()); zbShopInfo.setShopTel(sysCompany.getComTel()); zbShopInfo.setShopShortName("总部"); zbShopInfo.setIsOpenNet(SysShopInfo.CLOSE_NET); zbShopInfo.setShopNo(StringUtils.getRandomString(10)); shopInfoDao.insert(zbShopInfo); //新增一个总部仓库 Warehouse warehouse=new Warehouse(); warehouse.setCompanyId(sysCompany.getComId()); warehouse.setName("总部仓库"); warehouse.setShopId(zbShopInfo.getId()); warehouse.setSort("1"); warehouseDao.insert(warehouse); return zbShopInfo; } @Transactional(rollbackFor = Exception.class) @Override public int modifyByMap(SysCompany oldSysCompany, SysCompany newSysCompany) { SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); newSysCompany.setUpdateBy(user.getSuName()); updatePower(newSysCompany); Map<String, Object> modifyMap = null; try { if (!ModelUtils.isModified(oldSysCompany, newSysCompany)) { return MatrixConstance.DML_SUCCESSS; } modifyMap = ModelUtils.comparePojo2Map(oldSysCompany, newSysCompany); } catch (Exception e) { throw new GlobleException(SystemErrorCode.DATA_UPDATE_FAIL, e, newSysCompany.getComName()); } if (modifyMap.size() > 0) { modifyMap.put("comId", oldSysCompany.getComId()); return sysCompanyDao.updateByMap(modifyMap); } return MatrixConstance.DML_SUCCESSS; } /** * 更新公司员工权限 * * @author JIANGYOUYAO * @email 935090232@qq.com * @date 2017年12月5日 * @param newSysCompany */ private void updatePower(SysCompany newSysCompany) { List<String> oldFunctions = null; String functions = sysCompanyDao.selectById(newSysCompany.getComId()).getComFunctions(); if (functions == null || functions.equals("")) { oldFunctions = new ArrayList<>(); } else { oldFunctions = StringUtils .strToCollToString(sysCompanyDao.selectById(newSysCompany.getComId()).getComFunctions(), ","); } List<String> newFunctions = new ArrayList<>(); if (StringUtils.isNotBlank(newSysCompany.getComFunctions())) { newFunctions = StringUtils.strToCollToString(newSysCompany.getComFunctions(), ","); } for (String old : oldFunctions) { // 如果新权限中不包含这个老的功能,则要更新改企业下所有的角色权限 if (!newFunctions.contains(old)) { SysRole role = new SysRole(); role.setCompanyId(newSysCompany.getComId()); List<SysRole> roles = sysRoleDao.selectByModel(role); // 获取该公司下所有的权限信息 List<SysRolePwoerFn> compalyRolePwoer = new ArrayList<>(); for (SysRole tempRole : roles) { SysRolePwoerFn r = new SysRolePwoerFn(); r.setRoleId(tempRole.getRoleId()); compalyRolePwoer.addAll(rolePwoerFnDao.selectByModel(r)); } // 记录要删除的id List<String> delRolePwoer = new ArrayList<>(); for (SysRolePwoerFn rolePwoer : compalyRolePwoer) { // 如果有一个老权限则删除这个权限 if (rolePwoer.getFnId() != null && rolePwoer.getFnId().equals(old)) { delRolePwoer.add(rolePwoer.getRpfId()+""); } } // 如果获取到了就删除 if (!delRolePwoer.isEmpty()) { rolePwoerFnDao.deleteByIds(delRolePwoer); } } } } @Override public int modifyByModel(SysCompany sysCompany) { return sysCompanyDao.updateByModel(sysCompany); } @Override public int remove(List<String> list) { return sysCompanyDao.deleteByIds(list); } @Override public int removeById(String comId) { return sysCompanyDao.deleteById(Long.parseLong(comId)); } @Override public int removeByModel(SysCompany sysCompany) { return sysCompanyDao.deleteByModel(sysCompany); } @Override public List<SysCompany> findInPage(SysCompany sysCompany, PaginationVO pageVo) { return sysCompanyDao.selectInPage(sysCompany, pageVo); } @Override public List<SysCompany> findByModel(SysCompany sysCompany) { return sysCompanyDao.selectByModel(sysCompany); } @Override public int findTotal(SysCompany sysCompany) { return sysCompanyDao.selectTotalRecord(sysCompany); } @Override public SysCompany findById(String comId) { return sysCompanyDao.selectById(Long.parseLong(comId)); } } zq-erp/src/main/java/com/matrix/system/score/action/ScoreOrderAction.java
File was deleted zq-erp/src/main/java/com/matrix/system/score/action/ScoreRuleSettingAction.java
New file @@ -0,0 +1,151 @@ package com.matrix.system.score.action; import com.matrix.core.constance.MatrixConstance; import com.matrix.core.pojo.AjaxResult; import com.matrix.core.pojo.PaginationVO; 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.constance.Dictionary; import com.matrix.system.hive.action.util.QueryUtil; import com.matrix.system.hive.bean.ParameterSettings; import com.matrix.system.hive.bean.SysProjUse; import com.matrix.system.score.constant.ScoreSettingConstant; import com.matrix.system.score.service.ScoreOrderService; import com.matrix.system.score.vo.ScoreOrderVo; import com.matrix.system.score.vo.ScoreRuleSettingsVo; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; import io.swagger.annotations.Api; import net.sf.jsqlparser.util.AddAliasesVisitor; 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 **/ @Api(value = "积分订单", tags = "积分订单") @RestController @RequestMapping(value = "/score/ruleSetting") public class ScoreRuleSettingAction { @Autowired private ScoreOrderService scoreOrderService; @Autowired private BusParameterSettingsDao busParameterSettingsDao; @GetMapping(value = "/testApi") public AjaxResult testApi() { scoreOrderService.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 scoreOrderService.updateScoreRuleByCompanyId(busParameterSettings); } } zq-erp/src/main/java/com/matrix/system/score/constant/ScoreSettingConstant.java
New file @@ -0,0 +1,71 @@ package com.matrix.system.score.constant; public class ScoreSettingConstant { /** * 积分有效期 */ public final static String VALID_PERIOD_POINTS = "VALID_PERIOD_POINTS"; public final static String VALID_PERIOD_POINTS_NAME = "积分有效期:从获得开始 到"; /** * 积分抵扣现金 */ public final static String CREDIT_POINTS_CASH = "CREDIT_POINTS_CASH"; public final static String CREDIT_POINTS_CASH_NAME = "积分抵扣现金"; //门店设置 /** * 现金消费 */ public final static String CASH_CONSUMPTION = "CASH_CONSUMPTION"; public final static String CASH_CONSUMPTION_NAME = "现金消费"; /** * 本金余额消费 */ public final static String PRINCIPAL_BALANCE_CONSUMPTION = "PRINCIPAL_BALANCE_CONSUMPTION"; public final static String PRINCIPAL_BALANCE_CONSUMPTION_NAME = "本金余额消费"; /** * 赠金余额消费 */ public final static String BONUS_BALANCE_CONSUMPTION = "BONUS_BALANCE_CONSUMPTION"; public final static String BONUS_BALANCE_CONSUMPTION_NAME = "赠金余额消费"; /** * 本金消耗 */ public final static String PRINCIPAL_CONSUMPTION = "PRINCIPAL_CONSUMPTION"; public final static String PRINCIPAL_CONSUMPTION_NAME = "本金消耗"; /** * 赠送消耗 */ public final static String GIVE_CONSUMPTION = "GIVE_CONSUMPTION"; public final static String GIVE_CONSUMPTION_NAME = "赠送消耗"; /** * 转介客户 */ public final static String REFERRALS_CONSUMPTION = "REFERRALS_CONSUMPTION"; public final static String REFERRALS_CONSUMPTION_NAME = "转介客户"; //商城设置 /** * 现金消费 */ public final static String CASH_CONSUMPTION_SHOP = "CASH_CONSUMPTION_SHOP"; public final static String CASH_CONSUMPTION_SHOP_NAME = "现金消费"; /** * 预约服务 */ public final static String RESERVATION_SERVICE_SHOP = "RESERVATION_SERVICE_SHOP"; public final static String RESERVATION_SERVICE_SHOP_NAME = "预约服务"; /** * 评价订单 */ public final static String EVALUATUIN_ORDER_SHOP = "EVALUATUIN_ORDER_SHOP"; public final static String EVALUATUIN_ORDER_SHOP_NAME = "评价订单"; /** * 签到 */ public final static String SIGN_SHOP = "SIGN_SHOP"; public final static String SIGN_SHOP_NAME = "签到"; } zq-erp/src/main/java/com/matrix/system/score/dao/ScoreOrderDao.java
@@ -1,11 +1,11 @@ package com.matrix.system.score.dao; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.matrix.system.score.entity.ScoreOrderEntity; /** * @author wzy * @date 2021-02-22 **/ public interface ScoreOrderDao extends BaseMapper<ScoreOrderEntity> { } package com.matrix.system.score.dao; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.matrix.system.score.entity.ScoreOrderEntity; /** * @author wzy * @date 2021-02-22 **/ public interface ScoreOrderDao extends BaseMapper<ScoreOrderEntity> { } zq-erp/src/main/java/com/matrix/system/score/dto/SocreRuleDto.java
New file @@ -0,0 +1,5 @@ package com.matrix.system.score.dto; public class SocreRuleDto { } zq-erp/src/main/java/com/matrix/system/score/service/ScoreOrderService.java
@@ -1,23 +1,72 @@ package com.matrix.system.score.service; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.matrix.system.score.dao.ScoreOrderDao; import com.matrix.system.score.entity.ScoreOrderEntity; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; /** * @author wzy * @date 2021-02-22 **/ @Service public class ScoreOrderService extends ServiceImpl<ScoreOrderDao, ScoreOrderEntity> { @Autowired private ScoreOrderDao scoreOrderDao; public void testMethod() { scoreOrderDao.selectById(1L); } } package com.matrix.system.score.service; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.matrix.core.constance.MatrixConstance; import com.matrix.core.pojo.AjaxResult; import com.matrix.core.pojo.PaginationVO; import com.matrix.core.tools.StringUtils; 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.hive.bean.ParameterSettings; import com.matrix.system.hive.dao.SysVipInfoDao; import com.matrix.system.score.constant.ScoreSettingConstant; import com.matrix.system.score.dao.ScoreOrderDao; import com.matrix.system.score.entity.ScoreOrderEntity; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; /** * @author wzy * @date 2021-02-22 **/ @Service public class ScoreOrderService extends ServiceImpl<ScoreOrderDao, ScoreOrderEntity> { @Autowired private ScoreOrderDao scoreOrderDao; @Autowired private BusParameterSettingsDao busParameterSettingsDao; @Autowired private SysVipInfoDao sysVipInfoDao; public void testMethod() { scoreOrderDao.selectById(1L); } public AjaxResult updateScoreRuleByCompanyId(List<BusParameterSettings> busParameterSettings) { //获取当前登录人员信息 SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); for (BusParameterSettings busParameterSetting:busParameterSettings ) { String paramCode = busParameterSetting.getParamCode(); if(StringUtils.isNotBlank(paramCode)){ //删除原有code BusParameterSettings delParanm=new BusParameterSettings(); delParanm.setCompanyId(user.getCompanyId()); delParanm.setParamCode(paramCode); busParameterSettingsDao.deleteByModel(delParanm); //添加新的code BusParameterSettings newParam=new BusParameterSettings(); newParam.setParamCode(paramCode); newParam.setCompanyId(user.getCompanyId()); newParam.setParamValue(busParameterSetting.getParamValue()); newParam.setParamValue1(busParameterSetting.getParamValue1()); newParam.setParamValue2(busParameterSetting.getParamValue2()); busParameterSettingsDao.insert(newParam); }else{ return AjaxResult.buildFailInstance("code不能为空"); } } AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, "更新成功"); return result; } } zq-erp/src/main/java/com/matrix/system/score/vo/ScoreRuleSettingsVo.java
New file @@ -0,0 +1,139 @@ package com.matrix.system.score.vo; import com.matrix.core.anotations.Extend; public class ScoreRuleSettingsVo { @Extend private static final long serialVersionUID = 1L; private Long paramId; /** * 参数名称 */ private String paramName; /** * 参数编码 */ private String paramCode; /** * switch按钮 */ private Boolean paramSwitch; /** * 参数值 */ private String paramValue; /** * 值1 */ private String paramValue1; /** * 值2 */ private String paramValue2; /** * 值3 */ private String paramValue3; private Long companyId; private Long shopId; public Long getShopId() { return shopId; } public void setShopId(Long shopId) { this.shopId = shopId; } public Long getCompanyId() { return companyId; } public void setCompanyId(Long companyId) { this.companyId = companyId; } public Long getParamId() { return paramId; } public void setParamId(Long paramId) { this.paramId = paramId; } public String getParamCode() { return paramCode; } public void setParamCode(String paramCode) { this.paramCode = paramCode; } public String getParamValue() { return paramValue; } public void setParamValue(String paramValue) { this.paramValue = paramValue; } public String getParamValue1() { return paramValue1; } public void setParamValue1(String paramValue1) { this.paramValue1 = paramValue1; } public String getParamValue2() { return paramValue2; } public void setParamValue2(String paramValue2) { this.paramValue2 = paramValue2; } public String getParamValue3() { return paramValue3; } public void setParamValue3(String paramValue3) { this.paramValue3 = paramValue3; } public String getParamName() { return paramName; } public void setParamName(String paramName) { this.paramName = paramName; } public Boolean getParamSwitch() { return paramSwitch; } public void setParamSwitch(Boolean paramSwitch) { this.paramSwitch = paramSwitch; } } zq-erp/src/main/resources/mybatis/mapper/common/BusParameterSettingsDao.xml
@@ -1,397 +1,407 @@ <?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.matrix.system.common.dao.BusParameterSettingsDao"> <!-- 定义BusParameterSettings 的复杂关联map --> <resultMap type="com.matrix.system.common.bean.BusParameterSettings" id="BusParameterSettingsMap"> <id property="paramId" column="param_id"/> <result property="paramCode" column="param_code"/> <result property="paramValue" column="param_value"/> <result property="paramValue1" column="param_value1"/> <result property="paramValue2" column="param_value2"/> <result property="paramValue3" column="param_value3"/> <result property="companyId" column="company_id"/> <result property="shopId" column="shop_id"/> </resultMap> <!-- 定义BusParameterSettings 的简单map ,本map不添加其他的关联属性 --> <resultMap type="com.matrix.system.common.bean.BusParameterSettings" id="BusParameterSettingsSimpleMap"> <id property="paramId" column="param_id"/> <result property="paramCode" column="param_code"/> <result property="paramValue" column="param_value"/> <result property="paramValue1" column="param_value1"/> <result property="paramValue2" column="param_value2"/> <result property="paramValue3" column="param_value3"/> <result property="companyId" column="company_id"/> <result property="shopId" column="shop_id"/> </resultMap> <!-- 插入方法 --> <insert id="insert" parameterType="com.matrix.system.common.bean.BusParameterSettings" useGeneratedKeys="true" keyProperty="paramId"> INSERT INTO bus_parameter_settings ( param_id, param_code, param_value, param_value1, param_value2, param_value3, company_id, shop_id ) VALUES ( #{paramId}, #{paramCode}, #{paramValue}, #{paramValue1}, #{paramValue2}, #{paramValue3}, #{companyId}, #{shopId} ) </insert> <!-- 批量插入 --> <insert id="batchInsert" parameterType="java.util.List"> INSERT INTO bus_parameter_settings ( param_id, param_code, param_value, param_value1, param_value2, param_value3, company_id, shop_id ) VALUES <foreach collection="list" item="item" index="index" separator=",">( #{item.paramId}, #{item.paramCode}, #{item.paramValue}, #{item.paramValue1}, #{item.paramValue2}, #{item.paramValue3}, #{item.companyId}, #{item.shopId} ) </foreach> </insert> <!-- 根据Map更新 部分更新 --> <update id="updateByMap" parameterType="java.util.HashMap"> UPDATE bus_parameter_settings <set> <if test="_parameter.containsKey('paramCode')"> param_code = #{paramCode}, </if> <if test="_parameter.containsKey('paramValue')"> param_value = #{paramValue}, </if> <if test="_parameter.containsKey('paramValue1')"> param_value1 = #{paramValue1}, </if> <if test="_parameter.containsKey('paramValue2')"> param_value2 = #{paramValue2}, </if> <if test="_parameter.containsKey('paramValue3')"> param_value3 = #{paramValue3}, </if> <if test="_parameter.containsKey('companyId')"> company_id = #{companyId}, </if> <if test="_parameter.containsKey('shopId')"> shop_id = #{shopId}, </if> </set> WHERE param_id=#{paramId} </update> <!-- 根据对象更新 部分更新 --> <update id="updateByModel" parameterType="Long"> UPDATE bus_parameter_settings <set> <if test="(paramCode!=null and paramCode!='') or (paramCode!='' and paramCode==0)"> param_code = #{paramCode}, </if> <if test="(paramValue!=null and paramValue!='') or (paramValue!='' and paramValue==0)"> param_value = #{paramValue}, </if> <if test="(paramValue1!=null and paramValue1!='') or (paramValue1!='' and paramValue1==0)"> param_value1 = #{paramValue1}, </if> <if test="(paramValue2!=null and paramValue2!='') or (paramValue2!='' and paramValue2==0)"> param_value2 = #{paramValue2}, </if> <if test="(paramValue3!=null and paramValue3!='') or (paramValue3!='' and paramValue3==0)"> param_value3 = #{paramValue3}, </if> <if test="(companyId!=null and companyId!='') "> company_id = #{companyId} </if> <if test="(shopId!=null and shopId!='') "> shop_id = #{shopId} </if> </set> WHERE param_id=#{paramId} </update> <update id="updateParams" parameterType="java.util.List"> <foreach collection="list" index="index" item="item" separator=";"> UPDATE bus_parameter_settings <set> <if test="(item.paramValue!=null ) "> param_value = #{item.paramValue}, </if> <if test="(item.paramValue1!=null) "> param_value1 = #{item.paramValue1}, </if> <if test="(item.paramValue2!=null) "> param_value2 = #{item.paramValue2}, </if> <if test="(item.paramValue3!=null ) "> param_value3 = #{item.paramValue3}, </if> <if test="(item.shopId!=null ) "> shop_id = #{item.shopId}, </if> </set> where param_code = #{item.paramCode} and company_id = #{companyId} </foreach> </update> <!-- 批量删除 --> <delete id="deleteByIds" parameterType="java.util.List"> delete from bus_parameter_settings where param_id in <foreach collection="list" index="index" item="item" open="(" separator="," close=")"> #{item} </foreach> </delete> <!-- 根据id删除--> <delete id="deleteById" parameterType="Long"> DELETE FROM bus_parameter_settings where param_id=#{paramId} </delete> <!-- 根据对象删除--> <delete id="deleteByModel" parameterType="Long"> DELETE FROM bus_parameter_settings where 1=1 <if test="record!=null"> <if test="(record.paramId!=null and record.paramId!='') or (record.paramId!='' and record.paramId==0)"> and param_id = #{record.paramId} </if> <if test="(record.paramCode!=null and record.paramCode!='') or (record.paramCode!='' and record.paramCode==0)"> and param_code = #{record.paramCode} </if> <if test="(record.paramValue!=null and record.paramValue!='') or (record.paramValue!='' and record.paramValue==0)"> and param_value = #{record.paramValue} </if> <if test="(record.paramValue1!=null and record.paramValue1!='') or (record.paramValue1!='' and record.paramValue1==0)"> and param_value1 = #{record.paramValue1} </if> <if test="(record.paramValue2!=null and record.paramValue2!='') or (record.paramValue2!='' and record.paramValue2==0)"> and param_value2 = #{record.paramValue2} </if> <if test="(record.paramValue3!=null and record.paramValue3!='') or (record.paramValue3!='' and record.paramValue3==0)"> and param_value3 = #{record.paramValue3} </if> <if test="(record.companyId!=null and record.companyId!='') "> and company_id = #{record.companyId} </if> <if test="(record.shopId!=null and record.shopId!='') "> and shop_id = #{record.shopId} </if> </if> </delete> <!-- 分页查询 --> <select id="selectInPage" resultMap="BusParameterSettingsMap"> select param_id, param_code, param_value, param_value1, param_value2, param_value3, company_id, shop_id from bus_parameter_settings where 1=1 <if test="record!=null"> <if test="(record.paramId!=null and record.paramId!='') or (record.paramId!='' and record.paramId==0)"> and param_id = #{record.paramId} </if> <if test="(record.paramCode!=null and record.paramCode!='') or (record.paramCode!='' and record.paramCode==0)"> and param_code = #{record.paramCode} </if> <if test="(record.paramValue!=null and record.paramValue!='') or (record.paramValue!='' and record.paramValue==0)"> and param_value = #{record.paramValue} </if> <if test="(record.paramValue1!=null and record.paramValue1!='') or (record.paramValue1!='' and record.paramValue1==0)"> and param_value1 = #{record.paramValue1} </if> <if test="(record.paramValue2!=null and record.paramValue2!='') or (record.paramValue2!='' and record.paramValue2==0)"> and param_value2 = #{record.paramValue2} </if> <if test="(record.paramValue3!=null and record.paramValue3!='') or (record.paramValue3!='' and record.paramValue3==0)"> and param_value3 = #{record.paramValue3} </if> <if test="(record.companyId!=null and record.companyId!='') "> and company_id = #{record.companyId} </if> <if test="(record.shopId!=null and record.shopId!='') "> and shop_id = #{record.shopId} </if> </if> <if test="pageVo !=null"><!-- 判断pageVo对象是否为空 --> <if test="pageVo.sort !=null and pageVo.order !=null"> order by ${pageVo.sort} ${pageVo.order} </if> <if test="pageVo.offset >=0 and pageVo.limit >0"> limit #{pageVo.offset},#{pageVo.limit} </if> </if> </select> <!-- 查询总条数 --> <select id="selectTotalRecord" parameterType="long" resultType="java.lang.Integer"> select count(*) from bus_parameter_settings where 1=1 <if test="record!=null"> <if test="(record.paramId!=null and record.paramId!='') or (record.paramId!='' and record.paramId==0)"> and param_id = #{record.paramId} </if> <if test="(record.paramCode!=null and record.paramCode!='') or (record.paramCode!='' and record.paramCode==0)"> and param_code = #{record.paramCode} </if> <if test="(record.paramValue!=null and record.paramValue!='') or (record.paramValue!='' and record.paramValue==0)"> and param_value = #{record.paramValue} </if> <if test="(record.paramValue1!=null and record.paramValue1!='') or (record.paramValue1!='' and record.paramValue1==0)"> and param_value1 = #{record.paramValue1} </if> <if test="(record.paramValue2!=null and record.paramValue2!='') or (record.paramValue2!='' and record.paramValue2==0)"> and param_value2 = #{record.paramValue2} </if> <if test="(record.paramValue3!=null and record.paramValue3!='') or (record.paramValue3!='' and record.paramValue3==0)"> and param_value3 = #{record.paramValue3} </if> <if test="(record.companyId!=null and record.companyId!='') "> and company_id = #{record.companyId} </if> <if test="(record.shopId!=null and record.shopId!='') "> and shop_id = #{record.shopId} </if> </if> </select> <!-- 根据id查询--> <select id="selectById" resultMap="BusParameterSettingsMap"> select param_id, param_code, param_value, param_value1, param_value2, param_value3, company_id, shop_id from bus_parameter_settings where param_id=#{paramId} </select> <!-- 根据id 锁表查询--> <select id="selectForUpdate" resultMap="BusParameterSettingsMap"> select param_id, param_code, param_value, param_value1, param_value2, param_value3, company_id, shop_id from bus_parameter_settings where param_id=#{param_id} for update </select> <!-- 根据对象查询--> <select id="selectByModel" resultMap="BusParameterSettingsMap"> select param_id, param_code, param_value, param_value1, param_value2, param_value3, company_id, shop_id from bus_parameter_settings where 1=1 <if test="record!=null"> <if test="(record.paramId!=null and record.paramId!='') or (record.paramId!='' and record.paramId==0)"> and param_id = #{record.paramId} </if> <if test="(record.paramCode!=null and record.paramCode!='') or (record.paramCode!='' and record.paramCode==0)"> and param_code = #{record.paramCode} </if> <if test="(record.paramValue!=null and record.paramValue!='') or (record.paramValue!='' and record.paramValue==0)"> and param_value = #{record.paramValue} </if> <if test="(record.paramValue1!=null and record.paramValue1!='') or (record.paramValue1!='' and record.paramValue1==0)"> and param_value1 = #{record.paramValue1} </if> <if test="(record.paramValue2!=null and record.paramValue2!='') or (record.paramValue2!='' and record.paramValue2==0)"> and param_value2 = #{record.paramValue2} </if> <if test="(record.paramValue3!=null and record.paramValue3!='') or (record.paramValue3!='' and record.paramValue3==0)"> and param_value3 = #{record.paramValue3} </if> <if test="(record.companyId!=null and record.companyId!='') "> and company_id = #{record.companyId} </if> <if test="(record.shopId!=null and record.shopId!='') "> and shop_id = #{record.shopId} </if> </if> </select> <select id="selectByCodes" resultMap="BusParameterSettingsMap"> select * from bus_parameter_settings where company_id=#{companyId} and shop_id=#{shopId} and param_code in <foreach collection="list" index="index" item="item" open="(" separator="," close=")"> #{item} </foreach> </select> <select id="selectByCode" resultMap="BusParameterSettingsMap"> select * from bus_parameter_settings where param_code=#{code} and company_id=#{companyId} and shop_id=#{shopId} </select> <select id="selectCompanyParamByCode" resultMap="BusParameterSettingsMap"> select * from bus_parameter_settings where param_code=#{code} and company_id=#{companyId} </select> <?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.matrix.system.common.dao.BusParameterSettingsDao"> <!-- 定义BusParameterSettings 的复杂关联map --> <resultMap type="com.matrix.system.common.bean.BusParameterSettings" id="BusParameterSettingsMap"> <id property="paramId" column="param_id"/> <result property="paramCode" column="param_code"/> <result property="paramValue" column="param_value"/> <result property="paramValue1" column="param_value1"/> <result property="paramValue2" column="param_value2"/> <result property="paramValue3" column="param_value3"/> <result property="companyId" column="company_id"/> <result property="shopId" column="shop_id"/> </resultMap> <!-- 定义BusParameterSettings 的简单map ,本map不添加其他的关联属性 --> <resultMap type="com.matrix.system.common.bean.BusParameterSettings" id="BusParameterSettingsSimpleMap"> <id property="paramId" column="param_id"/> <result property="paramCode" column="param_code"/> <result property="paramValue" column="param_value"/> <result property="paramValue1" column="param_value1"/> <result property="paramValue2" column="param_value2"/> <result property="paramValue3" column="param_value3"/> <result property="companyId" column="company_id"/> <result property="shopId" column="shop_id"/> </resultMap> <!-- 插入方法 --> <insert id="insert" parameterType="com.matrix.system.common.bean.BusParameterSettings" useGeneratedKeys="true" keyProperty="paramId"> INSERT INTO bus_parameter_settings ( param_id, param_code, param_value, param_value1, param_value2, param_value3, company_id, shop_id ) VALUES ( #{paramId}, #{paramCode}, #{paramValue}, #{paramValue1}, #{paramValue2}, #{paramValue3}, #{companyId}, #{shopId} ) </insert> <!-- 批量插入 --> <insert id="batchInsert" parameterType="java.util.List"> INSERT INTO bus_parameter_settings ( param_id, param_code, param_value, param_value1, param_value2, param_value3, company_id, shop_id ) VALUES <foreach collection="list" item="item" index="index" separator=",">( #{item.paramId}, #{item.paramCode}, #{item.paramValue}, #{item.paramValue1}, #{item.paramValue2}, #{item.paramValue3}, #{item.companyId}, #{item.shopId} ) </foreach> </insert> <!-- 根据Map更新 部分更新 --> <update id="updateByMap" parameterType="java.util.HashMap"> UPDATE bus_parameter_settings <set> <if test="_parameter.containsKey('paramCode')"> param_code = #{paramCode}, </if> <if test="_parameter.containsKey('paramValue')"> param_value = #{paramValue}, </if> <if test="_parameter.containsKey('paramValue1')"> param_value1 = #{paramValue1}, </if> <if test="_parameter.containsKey('paramValue2')"> param_value2 = #{paramValue2}, </if> <if test="_parameter.containsKey('paramValue3')"> param_value3 = #{paramValue3}, </if> <if test="_parameter.containsKey('companyId')"> company_id = #{companyId}, </if> <if test="_parameter.containsKey('shopId')"> shop_id = #{shopId}, </if> </set> WHERE param_id=#{paramId} </update> <!-- 根据对象更新 部分更新 --> <update id="updateByModel" parameterType="Long"> UPDATE bus_parameter_settings <set> <if test="(paramCode!=null and paramCode!='') or (paramCode!='' and paramCode==0)"> param_code = #{paramCode}, </if> <if test="(paramValue!=null and paramValue!='') or (paramValue!='' and paramValue==0)"> param_value = #{paramValue}, </if> <if test="(paramValue1!=null and paramValue1!='') or (paramValue1!='' and paramValue1==0)"> param_value1 = #{paramValue1}, </if> <if test="(paramValue2!=null and paramValue2!='') or (paramValue2!='' and paramValue2==0)"> param_value2 = #{paramValue2}, </if> <if test="(paramValue3!=null and paramValue3!='') or (paramValue3!='' and paramValue3==0)"> param_value3 = #{paramValue3}, </if> <if test="(companyId!=null and companyId!='') "> company_id = #{companyId} </if> <if test="(shopId!=null and shopId!='') "> shop_id = #{shopId} </if> </set> WHERE param_id=#{paramId} </update> <update id="updateParams" parameterType="java.util.List"> <foreach collection="list" index="index" item="item" separator=";"> UPDATE bus_parameter_settings <set> <if test="(item.paramValue!=null ) "> param_value = #{item.paramValue}, </if> <if test="(item.paramValue1!=null) "> param_value1 = #{item.paramValue1}, </if> <if test="(item.paramValue2!=null) "> param_value2 = #{item.paramValue2}, </if> <if test="(item.paramValue3!=null ) "> param_value3 = #{item.paramValue3}, </if> <if test="(item.shopId!=null ) "> shop_id = #{item.shopId}, </if> </set> where param_code = #{item.paramCode} and company_id = #{companyId} </foreach> </update> <!-- 批量删除 --> <delete id="deleteByIds" parameterType="java.util.List"> delete from bus_parameter_settings where param_id in <foreach collection="list" index="index" item="item" open="(" separator="," close=")"> #{item} </foreach> </delete> <!-- 根据id删除--> <delete id="deleteById" parameterType="Long"> DELETE FROM bus_parameter_settings where param_id=#{paramId} </delete> <!-- 根据对象删除--> <delete id="deleteByModel" parameterType="Long"> DELETE FROM bus_parameter_settings where 1=1 <if test="record!=null"> <if test="(record.paramId!=null and record.paramId!='') or (record.paramId!='' and record.paramId==0)"> and param_id = #{record.paramId} </if> <if test="(record.paramCode!=null and record.paramCode!='') or (record.paramCode!='' and record.paramCode==0)"> and param_code = #{record.paramCode} </if> <if test="(record.paramValue!=null and record.paramValue!='') or (record.paramValue!='' and record.paramValue==0)"> and param_value = #{record.paramValue} </if> <if test="(record.paramValue1!=null and record.paramValue1!='') or (record.paramValue1!='' and record.paramValue1==0)"> and param_value1 = #{record.paramValue1} </if> <if test="(record.paramValue2!=null and record.paramValue2!='') or (record.paramValue2!='' and record.paramValue2==0)"> and param_value2 = #{record.paramValue2} </if> <if test="(record.paramValue3!=null and record.paramValue3!='') or (record.paramValue3!='' and record.paramValue3==0)"> and param_value3 = #{record.paramValue3} </if> <if test="(record.companyId!=null and record.companyId!='') "> and company_id = #{record.companyId} </if> <if test="(record.shopId!=null and record.shopId!='') "> and shop_id = #{record.shopId} </if> </if> </delete> <!-- 分页查询 --> <select id="selectInPage" resultMap="BusParameterSettingsMap"> select param_id, param_code, param_value, param_value1, param_value2, param_value3, company_id, shop_id from bus_parameter_settings where 1=1 <if test="record!=null"> <if test="(record.paramId!=null and record.paramId!='') or (record.paramId!='' and record.paramId==0)"> and param_id = #{record.paramId} </if> <if test="(record.paramCode!=null and record.paramCode!='') or (record.paramCode!='' and record.paramCode==0)"> and param_code = #{record.paramCode} </if> <if test="(record.paramValue!=null and record.paramValue!='') or (record.paramValue!='' and record.paramValue==0)"> and param_value = #{record.paramValue} </if> <if test="(record.paramValue1!=null and record.paramValue1!='') or (record.paramValue1!='' and record.paramValue1==0)"> and param_value1 = #{record.paramValue1} </if> <if test="(record.paramValue2!=null and record.paramValue2!='') or (record.paramValue2!='' and record.paramValue2==0)"> and param_value2 = #{record.paramValue2} </if> <if test="(record.paramValue3!=null and record.paramValue3!='') or (record.paramValue3!='' and record.paramValue3==0)"> and param_value3 = #{record.paramValue3} </if> <if test="(record.companyId!=null and record.companyId!='') "> and company_id = #{record.companyId} </if> <if test="(record.shopId!=null and record.shopId!='') "> and shop_id = #{record.shopId} </if> </if> <if test="pageVo !=null"><!-- 判断pageVo对象是否为空 --> <if test="pageVo.sort !=null and pageVo.order !=null"> order by ${pageVo.sort} ${pageVo.order} </if> <if test="pageVo.offset >=0 and pageVo.limit >0"> limit #{pageVo.offset},#{pageVo.limit} </if> </if> </select> <!-- 查询总条数 --> <select id="selectTotalRecord" parameterType="long" resultType="java.lang.Integer"> select count(*) from bus_parameter_settings where 1=1 <if test="record!=null"> <if test="(record.paramId!=null and record.paramId!='') or (record.paramId!='' and record.paramId==0)"> and param_id = #{record.paramId} </if> <if test="(record.paramCode!=null and record.paramCode!='') or (record.paramCode!='' and record.paramCode==0)"> and param_code = #{record.paramCode} </if> <if test="(record.paramValue!=null and record.paramValue!='') or (record.paramValue!='' and record.paramValue==0)"> and param_value = #{record.paramValue} </if> <if test="(record.paramValue1!=null and record.paramValue1!='') or (record.paramValue1!='' and record.paramValue1==0)"> and param_value1 = #{record.paramValue1} </if> <if test="(record.paramValue2!=null and record.paramValue2!='') or (record.paramValue2!='' and record.paramValue2==0)"> and param_value2 = #{record.paramValue2} </if> <if test="(record.paramValue3!=null and record.paramValue3!='') or (record.paramValue3!='' and record.paramValue3==0)"> and param_value3 = #{record.paramValue3} </if> <if test="(record.companyId!=null and record.companyId!='') "> and company_id = #{record.companyId} </if> <if test="(record.shopId!=null and record.shopId!='') "> and shop_id = #{record.shopId} </if> </if> </select> <!-- 根据id查询--> <select id="selectById" resultMap="BusParameterSettingsMap"> select param_id, param_code, param_value, param_value1, param_value2, param_value3, company_id, shop_id from bus_parameter_settings where param_id=#{paramId} </select> <!-- 根据id 锁表查询--> <select id="selectForUpdate" resultMap="BusParameterSettingsMap"> select param_id, param_code, param_value, param_value1, param_value2, param_value3, company_id, shop_id from bus_parameter_settings where param_id=#{param_id} for update </select> <!-- 根据对象查询--> <select id="selectByModel" resultMap="BusParameterSettingsMap"> select param_id, param_code, param_value, param_value1, param_value2, param_value3, company_id, shop_id from bus_parameter_settings where 1=1 <if test="record!=null"> <if test="(record.paramId!=null and record.paramId!='') or (record.paramId!='' and record.paramId==0)"> and param_id = #{record.paramId} </if> <if test="(record.paramCode!=null and record.paramCode!='') or (record.paramCode!='' and record.paramCode==0)"> and param_code = #{record.paramCode} </if> <if test="(record.paramValue!=null and record.paramValue!='') or (record.paramValue!='' and record.paramValue==0)"> and param_value = #{record.paramValue} </if> <if test="(record.paramValue1!=null and record.paramValue1!='') or (record.paramValue1!='' and record.paramValue1==0)"> and param_value1 = #{record.paramValue1} </if> <if test="(record.paramValue2!=null and record.paramValue2!='') or (record.paramValue2!='' and record.paramValue2==0)"> and param_value2 = #{record.paramValue2} </if> <if test="(record.paramValue3!=null and record.paramValue3!='') or (record.paramValue3!='' and record.paramValue3==0)"> and param_value3 = #{record.paramValue3} </if> <if test="(record.companyId!=null and record.companyId!='') "> and company_id = #{record.companyId} </if> <if test="(record.shopId!=null and record.shopId!='') "> and shop_id = #{record.shopId} </if> </if> </select> <select id="selectByCodes" resultMap="BusParameterSettingsMap"> select * from bus_parameter_settings where company_id=#{companyId} and shop_id=#{shopId} and param_code in <foreach collection="list" index="index" item="item" open="(" separator="," close=")"> #{item} </foreach> </select> <select id="selectByCodesAndCompanyId" resultMap="BusParameterSettingsMap"> select * from bus_parameter_settings where company_id=#{companyId} and param_code in <foreach collection="list" index="index" item="item" open="(" separator="," close=")"> #{item} </foreach> </select> <select id="selectByCode" resultMap="BusParameterSettingsMap"> select * from bus_parameter_settings where param_code=#{code} and company_id=#{companyId} and shop_id=#{shopId} </select> <select id="selectCompanyParamByCode" resultMap="BusParameterSettingsMap"> select * from bus_parameter_settings where param_code=#{code} and company_id=#{companyId} </select> </mapper> zq-erp/src/main/resources/templates/views/admin/score/score-setting.html
New file @@ -0,0 +1,289 @@ <!DOCTYPE HTML> <html xmlns:th="http://www.thymeleaf.org" xmlns:matrix="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8"> <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> <meta name="renderer" content="webkit|ie-comp|ie-stand"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/> <meta http-equiv="Cache-Control" content="no-siteapp"/> <!-- 本框架基本脚本和样式 --> <script type="text/javascript" th:src="@{/js/systools/MBaseVue.js}"></script> <link rel="stylesheet" th:href="@{/plugin/element-ui/index.css}"> <link rel="stylesheet" th:href="@{/plugin/bootstrap-3.3.5/css/bootstrap.min.css}"> <link th:href="@{/css/styleOne/style.min.css}" rel="stylesheet" type="text/css"/> </head> <body> <div class="ibox-content" id="app" v-cloak> <el-form label-width="120px" > <el-row> <p class="el-big-title">积分规则</p> </el-row> <el-row> <el-col :span="10"> <template v-for="paramSettingOnes in jfyxq"> <el-form-item label-width="200px;"> <span slot="label">{{paramSettingOnes.paramName}}</span> <el-col :span="8"> <el-select v-model="paramSettingOnes.paramValue" placeholder="请选择"> <el-option label="本年后" value="1"></el-option> <el-option label="1年后" value="2"></el-option> <el-option label="2年后" value="3"></el-option> <el-option label="3年后" value="4"></el-option> <el-option label="4年后" value="5"></el-option> <el-option label="5年后" value="6"></el-option> </el-select> </el-col> <el-col :span="2" style="margin-left: 10px;display: flex;align-items: center;height: 40px"> <el-tooltip class="item" effect="dark" content="设置为“1年后”,表示在今年获得的用户积分将在明年的12月31号23:59:59失效,以此类推" placement="top"> <i class="el-icon-question" style="font-size: 18px;color:#999999" ></i> </el-tooltip> </el-col> </el-form-item > </template> </el-col> <el-col :span="14"> <template v-for="paramSettingTwos in jfdxj"> <el-form-item> <span slot="label">{{paramSettingTwos.paramName}}</span> <el-col :span="1"> <el-switch v-model="paramSettingTwos.paramSwitch" active-color="#13ce66" inactive-color="#ccc" @change="change"> </el-switch> </el-col> <el-col :span="2" style="margin-left: 10px;display: flex;align-items: center;height: 40px"> <el-tooltip class="item" effect="dark" content="客户付款时,可以选择积分抵现付款" placement="top"> <i class="el-icon-question" style="font-size: 18px;color:#999999" ></i> </el-tooltip> </el-col> <el-col :span="11"> <transition> <div v-show="paramSettingTwos.paramSwitch"> <el-col :span="6"> <el-input v-model="paramSettingTwos.paramValue" oninput ="value=value.replace(/[^0-9.]/g,'')"></el-input> </el-col> <el-col class="line" :span="5">积分=1元</el-col> </div> </transition> </el-col> </el-form-item> </template> </el-col> </el-row> <el-row> <el-tabs v-model="activeName" > <el-tab-pane label="门店积分规则" name="first"> <el-row> <el-col :span="24"> <el-form-item> <el-col class="line" :span="8">本人积分</el-col> <el-col class="line" :span="8">老带新积分</el-col> <el-col class="line" :span="8">二级老带新积分</el-col> </el-form-item> </el-col> </el-row> <el-row> <el-col :span="24"> <template v-for="paramSetting in mdjf"> <el-form-item> <span slot="label">{{paramSetting.paramName}}</span> <el-col :span="4"> <el-input v-model="paramSetting.paramValue" oninput ="value=value.replace(/[^0-9.]/g,'')"></el-input> </el-col> <el-col class="line" :span="4">元/积分</el-col> <el-col :span="4"> <el-input v-model="paramSetting.paramValue1" oninput ="value=value.replace(/[^0-9.]/g,'')"></el-input> </el-col> <el-col class="line" :span="4">元/积分</el-col> <el-col :span="4"> <el-input v-model="paramSetting.paramValue2" oninput ="value=value.replace(/[^0-9.]/g,'')"></el-input> </el-col> <el-col class="line" :span="4">元/积分</el-col> </el-form-item> </template> </el-col> </el-row> </el-tab-pane> <el-tab-pane label="商城积分规则" name="second"> <el-row> <el-col :span="24"> <el-form-item> <el-col class="line" :span="8">本人积分</el-col> <el-col class="line" :span="8">老带新积分</el-col> <el-col class="line" :span="8">二级老带新积分</el-col> </el-form-item> </el-col> </el-row> <el-row> <el-col :span="24"> <template v-for="paramSettingShop in scjf"> <el-form-item> <span slot="label">{{paramSettingShop.paramName}}</span> <el-col :span="4"> <el-input v-model="paramSettingShop.paramValue" oninput ="value=value.replace(/[^0-9.]/g,'')"></el-input> </el-col> <el-col class="line" :span="4">元/积分</el-col> <el-col :span="4"> <el-input v-model="paramSettingShop.paramValue1" oninput ="value=value.replace(/[^0-9.]/g,'')"></el-input> </el-col> <el-col class="line" :span="4">元/积分</el-col> <el-col :span="4"> <el-input v-model="paramSettingShop.paramValue2" oninput ="value=value.replace(/[^0-9.]/g,'')"></el-input> </el-col> <el-col class="line" :span="4">元/积分</el-col> </el-form-item> </template> </el-col> </el-row> </el-tab-pane> </el-tabs> </el-row> <el-row justify="center" type="flex"> <el-button type="primary" @click="submit()">保存</el-button> </el-row> </el-form> </div> </body> <script type="text/javascript" th:src="@{/js/plugin/jquery-2.1.4.min.js}"></script> <script type="text/javascript" th:src="@{/js/plugin/jquery.query.js}"></script> <script type="text/javascript" th:src="@{/plugin/bootstrap-3.3.5/js/bootstrap.min.js}"></script> <script type="text/javascript" th:src="@{/js/systools/AjaxProxyVue.js}"></script> <script type="text/javascript" th:src="@{/js/plugin/vue.js}"></script> <script type="text/javascript" th:src="@{/plugin/element-ui/index.js}"></script> <script> var app = new Vue({ el: '#app', data: { activeName: 'first', jfyxq:[], jfdxj:[], mdjf:[], scjf:[], }, created: function () { this.loadInfo(); }, mounted: function () { }, methods: { //加载分类 loadInfo() { let _this = this; _this.loadParamSetting(); }, loadParamSetting() { let _this = this; //加载配置 AjaxProxy.requst({ app: _this, data: {}, url: basePath + '/score/ruleSetting/selectScoreRule', callback: function (data) { _this.jfyxq = data.mapInfo.jfyxq; _this.jfdxj = data.mapInfo.jfdxj; _this.mdjf = data.mapInfo.mdjf; _this.scjf = data.mapInfo.scjf; console.log("over"); } }); }, change(data){ if(data){ this.paramSwitch = true; }else{ this.paramSwitch = false; } }, submit() { console.log("提交"); let _this = this; let submitDate = []; for (let i = 0; i < _this.jfyxq.length; i++) { let paramSetting = _this.jfyxq[i]; let paramCode = paramSetting.paramCode; let paramValue = paramSetting.paramValue; let paramValue1 = paramSetting.paramValue1; let paramValue2 = paramSetting.paramValue2; let obj = { paramCode: paramCode, paramValue: paramValue, paramValue1: paramValue1, paramValue2: paramValue2, } submitDate.push(obj); } for (let i = 0; i < _this.scjf.length; i++) { let paramSetting = _this.scjf[i]; let paramCode = paramSetting.paramCode; let paramValue = paramSetting.paramValue; let paramValue1 = paramSetting.paramValue1; let paramValue2 = paramSetting.paramValue2; let obj = { paramCode: paramCode, paramValue: paramValue, paramValue1: paramValue1, paramValue2: paramValue2, } submitDate.push(obj); } for (let i = 0; i < _this.mdjf.length; i++) { let paramSetting = _this.mdjf[i]; let paramCode = paramSetting.paramCode; let paramValue = paramSetting.paramValue; let paramValue1 = paramSetting.paramValue1; let paramValue2 = paramSetting.paramValue2; let obj = { paramCode: paramCode, paramValue: paramValue, paramValue1: paramValue1, paramValue2: paramValue2, } submitDate.push(obj); } for (let i = 0; i < _this.jfdxj.length; i++) { let paramSetting = _this.jfdxj[i]; let paramCode = paramSetting.paramCode; let paramSwitch = paramSetting.paramSwitch; let paramValue; if(paramSwitch){ paramValue = paramSetting.paramValue; } let paramValue1 = paramSetting.paramValue1; let paramValue2 = paramSetting.paramValue2; let obj = { paramCode: paramCode, paramValue: paramValue, paramValue1: paramValue1, paramValue2: paramValue2, } submitDate.push(obj); } AjaxProxy.requst({ app: _this, data: submitDate, url: basePath + '/score/ruleSetting/updateScoreRule', callback: function (data) { _this.$message({ message: data.info, type: 'success', onClose: function () { _this.loadParamSetting(); } }); } }); } } }) </script> </body> </html>