zq-erp/src/main/java/com/matrix/system/app/action/ApiCommonAction.java | ●●●●● patch | view | raw | blame | history | |
zq-erp/src/main/java/com/matrix/system/app/vo/ParameterSettingVo.java | ●●●●● patch | view | raw | blame | history | |
zq-erp/src/main/java/com/matrix/system/common/constance/AppConstance.java | ●●●●● patch | view | raw | blame | history | |
zq-erp/src/main/java/com/matrix/system/score/service/ScoreVipDetailService.java | ●●●●● patch | view | raw | blame | history | |
zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxProductCommentAction.java | ●●●●● patch | view | raw | blame | history | |
zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxUserAction.java | ●●●●● patch | view | raw | blame | history | |
zq-erp/src/test/java/com/matrix/ParameterSettingsTool.java | ●●●●● patch | view | raw | blame | history |
zq-erp/src/main/java/com/matrix/system/app/action/ApiCommonAction.java
@@ -2,6 +2,7 @@ import com.alibaba.fastjson.JSONObject; import com.matrix.component.redis.RedisClient; import com.matrix.core.constance.MatrixConstance; import com.matrix.core.pojo.AjaxResult; import com.matrix.core.tools.*; import com.matrix.system.app.authority.AppAuthorityManager; @@ -11,10 +12,11 @@ import com.matrix.system.app.dto.UploadPhotoDto; import com.matrix.system.app.utils.Sms106Send; import com.matrix.system.app.vo.UserInfoVo; import com.matrix.system.common.authority.DefaultAuthorityManager; import com.matrix.system.common.authority.strategy.AccountPasswordLogin; import com.matrix.system.common.authority.strategy.LoginStrategy; import com.matrix.system.common.bean.SysUsers; import com.matrix.system.common.constance.AppConstance; import com.matrix.system.common.dao.BusParameterSettingsDao; import com.matrix.system.common.service.SysUsersService; import com.matrix.system.common.tools.PasswordUtil; import com.matrix.system.common.tools.UploadUtil; @@ -62,6 +64,9 @@ @Autowired private AppAuthorityManager authorityManager; @Autowired private BusParameterSettingsDao busParameterSettingsDao; @Autowired private RedisClient redisClient; @@ -220,4 +225,21 @@ public AjaxResult findAppVersion() { return AjaxResult.buildSuccessInstance(sysUsersService.findAppVersion()); } @ApiOperation(value = "获取app配置", notes = "获取app配置") @ApiResponses({ @ApiResponse(code = 200, message = "ok", response = AppVersion.class) }) @GetMapping(value = "/findAppSettings") public AjaxResult findAppSettings() { SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); AjaxResult result = AjaxResult.buildSuccessInstance("查询成功"); result.putInMap(AppConstance.APP_BANNER_GL, busParameterSettingsDao.selectCompanyParamByCode(AppConstance.APP_BANNER_GL,user.getCompanyId())); return result; } } zq-erp/src/main/java/com/matrix/system/app/vo/ParameterSettingVo.java
New file @@ -0,0 +1,39 @@ package com.matrix.system.app.vo; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; /** * jyy */ @Data @ApiModel(value = "ParameterSettingVo", description = "配置返回参数类") public class ParameterSettingVo { @ApiModelProperty(value = "参数编码ID") private Long paramId; @ApiModelProperty(value = "参数编码") private String paramCode; @ApiModelProperty(value = "参数值") private String paramValue; @ApiModelProperty(value = "值1") private String paramValue1; @ApiModelProperty(value = "值2") private String paramValue2; @ApiModelProperty(value = "值3") private String paramValue3; } zq-erp/src/main/java/com/matrix/system/common/constance/AppConstance.java
@@ -553,6 +553,14 @@ */ public static final String WECHARPAY_CERTLOCAL_PATH = "certLocalPath"; /** * APP管理模块Banner */ public static final String APP_BANNER_GL = "APP_BANNER_GL"; zq-erp/src/main/java/com/matrix/system/score/service/ScoreVipDetailService.java
@@ -6,9 +6,11 @@ import com.matrix.core.constance.MatrixConstance; import com.matrix.core.exception.GlobleException; import com.matrix.core.tools.DateUtil; import com.matrix.core.tools.StringUtils; import com.matrix.system.common.bean.BusParameterSettings; import com.matrix.system.common.dao.BusParameterSettingsDao; import com.matrix.system.common.dao.SysUsersDao; import com.matrix.system.hive.bean.SysVipInfo; import com.matrix.system.hive.dao.SysVipInfoDao; import com.matrix.system.score.constant.ScoreSettingConstant; import com.matrix.system.score.dao.ScoreUseRecordDao; @@ -53,12 +55,12 @@ * 扣除用户积分 */ @Transactional(rollbackFor = Exception.class) public void deductionScore(Long vipId,Long oprationUserId,Long shopId, Integer score, Long businessId, int type,String remark) { Long companyId= vipInfoDao.selectById(vipId).getCompanyId(); public void deductionScore(Long vipId, Long oprationUserId, Long shopId, Integer score, Long businessId, int type, String remark) { Long companyId = vipInfoDao.selectById(vipId).getCompanyId(); String createBy=MatrixConstance.SYSTEM_USER; if(oprationUserId!=null){ createBy=sysUsersDao.selectById(oprationUserId).getSuName(); String createBy = MatrixConstance.SYSTEM_USER; if (oprationUserId != null) { createBy = sysUsersDao.selectById(oprationUserId).getSuName(); } List<ScoreVipDetail> effectiveScoreList = scoreVipDetailDao.selectEffectiveScore(vipId); @@ -74,20 +76,18 @@ //余额充足 currentDedution = score; scoreVipDetail.setRemainScore(surplus); if(surplus==0){ if (surplus == 0) { scoreVipDetail.setState(ScoreVipDetail.SCORE_STATUS_WX); } scoreVipDetailDao.updateById(scoreVipDetail); score=0; score = 0; } else { currentDedution = scoreVipDetail.getRemainScore(); scoreVipDetail.setState(ScoreVipDetail.SCORE_STATUS_WX); scoreVipDetail.setRemainScore(0); scoreVipDetailDao.updateById(scoreVipDetail); score=Math.abs(surplus); score = Math.abs(surplus); } //新增扣除记录 @@ -107,11 +107,11 @@ scoreUseRecord.setOprationUserId(oprationUserId); scoreUseRecordDao.insert(scoreUseRecord); if(surplus > 0 || surplus == 0){ if (surplus > 0 || surplus == 0) { break; } } if(score>0){ if (score > 0) { throw new GlobleException("积分不足"); } } @@ -120,26 +120,26 @@ * 新增用户积分 */ @Transactional(rollbackFor = Exception.class) public void addScore(Long vipId, Long oprationUserId,Long shopId, Integer score, Long businessId, int type,String remark) { Long companyId= vipInfoDao.selectById(vipId).getCompanyId(); public void addScore(Long vipId, Long oprationUserId, Long shopId, Integer score, Long businessId, int type, String remark) { Long companyId = vipInfoDao.selectById(vipId).getCompanyId(); if(score<0){ if (score < 0) { throw new IllegalArgumentException("score必须有为大于零的数"); } String createBy=MatrixConstance.SYSTEM_USER; if(oprationUserId!=null){ createBy=sysUsersDao.selectById(oprationUserId).getSuName(); String createBy = MatrixConstance.SYSTEM_USER; if (oprationUserId != null) { createBy = sysUsersDao.selectById(oprationUserId).getSuName(); } //计算过期时间 BusParameterSettings yxqSetting = busParameterSettingsDao.selectCompanyParamByCode(ScoreSettingConstant.VALID_PERIOD_POINTS, companyId); Calendar cal=Calendar.getInstance(); Calendar cal = Calendar.getInstance(); int year = cal.get(Calendar.YEAR); int sxYear=year+(Integer.parseInt(yxqSetting.getParamValue())-1); Date sxys=DateUtil.stringToDate(sxYear+"-12-31 23:59",DateUtil.DATE_FORMAT_MM ); int sxYear = year + (Integer.parseInt(yxqSetting.getParamValue()) - 1); Date sxys = DateUtil.stringToDate(sxYear + "-12-31 23:59", DateUtil.DATE_FORMAT_MM); ScoreVipDetail scoreVipDetail=new ScoreVipDetail(); ScoreVipDetail scoreVipDetail = new ScoreVipDetail(); scoreVipDetail.setCreateBy(createBy); scoreVipDetail.setUpdateBy(createBy); @@ -158,7 +158,7 @@ scoreVipDetailDao.insert(scoreVipDetail); //新增添加记录 ScoreUseRecord scoreUseRecord = new ScoreUseRecord(); ScoreUseRecord scoreUseRecord = new ScoreUseRecord(); scoreUseRecord.setPreScore(score); scoreUseRecord.setCreateBy(createBy); scoreUseRecord.setUpdateBy(createBy); @@ -180,28 +180,87 @@ } /** * 根据固定等级规则新增用户积分 */ @Transactional(rollbackFor = Exception.class) public void addScoreByParamSetting(Long vipId, Long oprationUserId, Long shopId, Integer firstScore, Long businessId, int type, String remark, BusParameterSettings parameterSetting) { SysVipInfo vipInfo = sysVipInfoDao.selectById(vipId); //添加自己的积分 if (firstScore > 0) { addScore( vipInfo.getId(), oprationUserId, shopId, firstScore, businessId, type, remark ); } if (StringUtils.isNotBlank(parameterSetting.getParamValue()) && vipInfo.getRecommendId() != null) { //推荐注册老带新积分奖励 SysVipInfo referrerVip = sysVipInfoDao.selectById(vipInfo.getRecommendId()); Integer secondScore = new Integer(parameterSetting.getParamValue()); if (secondScore > 0) { addScore( referrerVip.getId(), oprationUserId, shopId, secondScore, businessId, type, remark ); } //推荐注册二级带新积分奖励 if (StringUtils.isNotBlank(parameterSetting.getParamValue1()) && referrerVip.getRecommendId() != null) { Integer threeScore = new Integer(parameterSetting.getParamValue()); if (threeScore > 0) { addScore( referrerVip.getRecommendId(), oprationUserId, shopId, threeScore, businessId, type, remark ); } } } } /** * 退积分 */ public void refundScore(Long vipId, Integer score, Long oldBusinessId, int type){ public void refundScore(Long vipId, Integer score, Long oldBusinessId, int type) { Long companyId= vipInfoDao.selectById(vipId).getCompanyId(); Long companyId = vipInfoDao.selectById(vipId).getCompanyId(); if(score<0){ if (score < 0) { throw new IllegalArgumentException("score必须有为大于零的数"); } //查询原始使用记录 QueryWrapper queryWrapper=new QueryWrapper(); queryWrapper.eq("business_id",oldBusinessId); queryWrapper.eq("company_id",companyId); queryWrapper.eq("type",type); QueryWrapper queryWrapper = new QueryWrapper(); queryWrapper.eq("business_id", oldBusinessId); queryWrapper.eq("company_id", companyId); queryWrapper.eq("type", type); List<ScoreUseRecord> scoreUseRecordList = scoreUseRecordDao.selectList(queryWrapper); scoreUseRecordList.forEach(scoreUseRecord -> { ScoreVipDetail scoreVipDetail = scoreVipDetailDao.selectById(scoreUseRecord.getScoreVipDetailId()); if(scoreVipDetail!=null){ if(DateTime.now().isAfter(scoreVipDetail.getValiditeTime())){ if (scoreVipDetail != null) { if (DateTime.now().isAfter(scoreVipDetail.getValiditeTime())) { //积分还有效 scoreVipDetail.setRemainScore( scoreVipDetail.getRemainScore()+score); scoreVipDetail.setUsedScore(scoreVipDetail.getUsedScore()-score); scoreVipDetail.setRemainScore(scoreVipDetail.getRemainScore() + score); scoreVipDetail.setUsedScore(scoreVipDetail.getUsedScore() - score); scoreVipDetail.setState(ScoreVipDetail.SCORE_STATUS_YX); scoreVipDetailDao.updateById(scoreVipDetail); scoreUseRecordDao.deleteById(scoreUseRecord.getId()); @@ -211,15 +270,15 @@ }); } public void removeByBusinessId( Long vipId, Long oldBusinessId){ Long companyId= vipInfoDao.selectById(vipId).getCompanyId(); public void removeByBusinessId(Long vipId, Long oldBusinessId) { Long companyId = vipInfoDao.selectById(vipId).getCompanyId(); if(oldBusinessId==null){ if (oldBusinessId == null) { throw new IllegalArgumentException("oldBusinessId必须有"); } QueryWrapper queryWrapper=new QueryWrapper(); queryWrapper.eq("business_id",oldBusinessId); queryWrapper.eq("company_id",companyId); QueryWrapper queryWrapper = new QueryWrapper(); queryWrapper.eq("business_id", oldBusinessId); queryWrapper.eq("company_id", companyId); scoreVipDetailDao.delete(queryWrapper); scoreUseRecordDao.delete(queryWrapper); } zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxProductCommentAction.java
@@ -5,6 +5,7 @@ import com.matrix.component.redis.RedisUserLoginUtils; import com.matrix.system.common.constance.AppConstance; import com.matrix.system.score.service.ScoreVipDetailService; import com.matrix.system.shopXcx.bean.ShopOrder; import com.matrix.system.shopXcx.bean.ShopProductComment; import com.matrix.system.shopXcx.dao.ShopOrderDao; @@ -52,6 +53,9 @@ return new AjaxResult(AjaxResult.STATUS_SUCCESS, "删除成功"); } @Autowired ScoreVipDetailService scoreVipDetailService; /** * 接收保存产品评价数据 */ @@ -81,6 +85,10 @@ modifyMap.put("id", orderId); modifyMap.put("orderStatus", ShopOrder.ORDER_STATUS_ALREADY_REMARK); shopOrderDao.updateByMap(modifyMap); //scoreVipDetailService.addScoreByParamSetting(loginUser.getId(),null,); return new AjaxResult(AjaxResult.STATUS_SUCCESS, "保存成功"); } zq-erp/src/main/java/com/matrix/system/shopXcx/api/action/WxUserAction.java
@@ -108,10 +108,10 @@ sysVipInfo.setSessionKey(sessionKey); sysVipInfo.setCompanyId(HostInterceptor.getCompanyId()); sysVipInfo.setArrivalWay("微商城"); sysVipInfo.setVipName("微信用户"); sysVipInfo.setVipState(Dictionary.VIP_STATE_HY); sysVipInfo.setVipType(Dictionary.VIP_TYPE_NOCARD); sysVipInfo.setIsDeal(SysVipInfo.UNDEAL_VIP); sysVipInfo.setVipNo(openId); sysVipInfoService.add(sysVipInfo); @@ -177,7 +177,7 @@ BeanUtil.copyProperties(xcxUserSaveUserInfoDto,sysVipInfo); sysVipInfo.setPhone(xcxUserSaveUserInfoDto.getPhoneNumber()); if(StringUtils.isBlank(loginUser.getVipName())){ if(StringUtils.isBlank(loginUser.getVipName())||loginUser.getVipName().equals("微信用户")){ sysVipInfo.setVipName(xcxUserSaveUserInfoDto.getNickName()); } if(StringUtils.isBlank(loginUser.getSex())){ zq-erp/src/test/java/com/matrix/ParameterSettingsTool.java
New file @@ -0,0 +1,92 @@ package com.matrix; import cn.hutool.core.collection.CollectionUtil; 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.common.dao.SysCompanyDao; import com.matrix.system.hive.bean.ParameterSettings; import com.matrix.system.hive.dao.ParameterSettingsDao; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; import java.util.ArrayList; import java.util.List; /** * 配置工具 * * @author jiangyouyao * @email 512061637@qq.com * @date 2019年2月25日 */ @RunWith(SpringRunner.class) @SpringBootTest(classes = {ZqErpApplication.class},webEnvironment =SpringBootTest.WebEnvironment.RANDOM_PORT) public class ParameterSettingsTool { @Autowired private ParameterSettingsDao parameterSettingsDao; @Autowired private BusParameterSettingsDao busParameterSettingsDao; @Autowired private SysCompanyDao sysCompanyDao; /* 给所有公司加上多个配置,如果已经存在则跳过 */ @Test public void addSettings(){ List<ParameterSettings> newSettings=new ArrayList<>(); ParameterSettings newSetting1=new ParameterSettings(); newSetting1.setCode("APP_BANNER_GL"); newSetting1.setName("APP管理模块Banner"); newSetting1.setType(1); newSetting1.setCategory("APP设置"); newSettings.add(newSetting1); for (ParameterSettings newSetting : newSettings) { List<ParameterSettings> parameterSettings = parameterSettingsDao.selectByModel(newSetting); if(CollectionUtil.isEmpty(parameterSettings)){ parameterSettingsDao.insert(newSetting); System.out.println("新增配置"+newSetting.getName()); }else { System.out.println("配置"+newSetting.getName()+"已经存在"); } addSettingsTOAllCompany(newSetting); } } private void addSettingsTOAllCompany(ParameterSettings newSetting) { List<SysCompany> allCompany = sysCompanyDao.selectByModel(null); for (SysCompany sysCompany : allCompany) { BusParameterSettings checkExist = busParameterSettingsDao.selectCompanyParamByCode(newSetting.getCode(), sysCompany.getComId()); if(checkExist==null){ BusParameterSettings busParameterSettings=new BusParameterSettings(); busParameterSettings.setCompanyId(sysCompany.getComId()); busParameterSettings.setParamCode(newSetting.getCode()); busParameterSettings.setParamValue(""); busParameterSettingsDao.insert(busParameterSettings); System.out.println(sysCompany.getComName()+"新增成功"); }else{ System.out.println("公司"+sysCompany.getComName()+"已经存在配置"+newSetting.getName()); } } } }