| @@ -1,6 +1,7 @@ | |||||
| package com.iformall.controller.mem; | package com.iformall.controller.mem; | ||||
| import com.iformall.annotation.SystemControllerLog; | import com.iformall.annotation.SystemControllerLog; | ||||
| import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.controller.base.BaseController; | import com.iformall.controller.base.BaseController; | ||||
| import com.iformall.domain.po.WxScoreRules; | import com.iformall.domain.po.WxScoreRules; | ||||
| @@ -48,4 +49,25 @@ public class WxScoreRulesController extends BaseController { | |||||
| WxScoreRules scoreRules = wxScoreRulesService.getCreditRules(getTenantId()); | WxScoreRules scoreRules = wxScoreRulesService.getCreditRules(getTenantId()); | ||||
| return new ResultData(scoreRules); | return new ResultData(scoreRules); | ||||
| } | } | ||||
| @ApiOperation("更新积分开关状态") | |||||
| @PostMapping("updateCreditLocked") | |||||
| @SystemControllerLog(description = "更新积分开关状态") | |||||
| public ResultData 更新积分开关状态(@RequestBody WxScoreRules wxScoreRules) { | |||||
| logger.debug("[" + getIpAddr() + "] WxScoreRulesController::updateCreditLocked"); | |||||
| if (null == wxScoreRules.getId()) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "id不能为空"); | |||||
| } | |||||
| if (null == wxScoreRules.getCreditLocked()) { | |||||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "creditLocked不能为空"); | |||||
| } | |||||
| wxScoreRules.setTenantId(getTenantId()); | |||||
| try { | |||||
| wxScoreRulesService.updateCreditLocked(wxScoreRules); | |||||
| } catch (Exception e) { | |||||
| return new ResultData(ErrorCode.DB_FAIL.getCode(), "更新积分开关状态失败"); | |||||
| } | |||||
| return new ResultData(); | |||||
| } | |||||
| } | } | ||||
| @@ -0,0 +1 @@ | |||||
| alter table wx_merchant add column credit_locked tinyint(1) default 0 not null comment '0开放1锁定'; | |||||
| @@ -0,0 +1 @@ | |||||
| alter table wx_score_rules add column credit_locked tinyint(1) default 0 not null comment '0开放1锁定'; | |||||
| @@ -81,6 +81,7 @@ public class WxMerchantBUserController extends BaseController { | |||||
| resultMap.put("tenant_id",merchant.getTenantId()); | resultMap.put("tenant_id",merchant.getTenantId()); | ||||
| resultMap.put("merchant_id",merchant.getId()); | resultMap.put("merchant_id",merchant.getId()); | ||||
| resultMap.put("is_admin",merchant.getIsAdmin()); | resultMap.put("is_admin",merchant.getIsAdmin()); | ||||
| resultMap.put("creditLocked", merchant.getCreditLocked()); | |||||
| String mid = null; | String mid = null; | ||||
| try { | try { | ||||
| mid = String.valueOf(merchant.getId()); | mid = String.valueOf(merchant.getId()); | ||||
| @@ -233,4 +233,7 @@ public class WxMerchant extends BaseEntity { | |||||
| return "t:md:" + id; | return "t:md:" + id; | ||||
| } | } | ||||
| @io.swagger.annotations.ApiModelProperty(value = "积分锁定0正常1锁定", name = "creditLocked") | |||||
| private Integer creditLocked; | |||||
| } | } | ||||
| @@ -110,6 +110,9 @@ public class WxScoreRules extends BaseEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="生日积分倍率",name="scale") | @io.swagger.annotations.ApiModelProperty(value="生日积分倍率",name="scale") | ||||
| private Integer scale; | private Integer scale; | ||||
| @io.swagger.annotations.ApiModelProperty(value = "积分锁定0正常1锁定", name = "creditLocked") | |||||
| private Integer creditLocked; | |||||
| public static String getScoreDefaultRules() { | public static String getScoreDefaultRules() { | ||||
| return scoreDefaultRules; | return scoreDefaultRules; | ||||
| } | } | ||||
| @@ -0,0 +1,36 @@ | |||||
| package com.iformall.enums; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| public enum EnumCreditLockedStatus { | |||||
| OPEN(0, "正常"), | |||||
| CLOSE(1, "锁定"),; | |||||
| public static EnumCreditLockedStatus getEnum(Integer code) { | |||||
| for (EnumCreditLockedStatus value : values()) { | |||||
| if (value.getCode().equals(code)) { | |||||
| return value; | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| private Integer code; | |||||
| private String message; | |||||
| EnumCreditLockedStatus(Integer code, String message) { | |||||
| this.code = code; | |||||
| this.message = message; | |||||
| } | |||||
| public Integer getCode() { | |||||
| return code; | |||||
| } | |||||
| public String getMessage() { | |||||
| return message; | |||||
| } | |||||
| } | |||||
| @@ -25,4 +25,6 @@ public interface WxMerchantMapper extends CommonMapper<WxMerchant, Long> { | |||||
| List<WxMerchant> findListVo(WxMerchant record); | List<WxMerchant> findListVo(WxMerchant record); | ||||
| void updateCreditLocked(WxMerchant wxMerchant); | |||||
| } | } | ||||
| @@ -52,4 +52,6 @@ public interface WxScoreRulesService { | |||||
| List<WxScoreRules> findList(WxScoreRules wxScoreRules); | List<WxScoreRules> findList(WxScoreRules wxScoreRules); | ||||
| void updateCreditLocked(WxScoreRules wxScoreRules); | |||||
| } | } | ||||
| @@ -9,10 +9,7 @@ import com.iformall.enums.EnumBusiness; | |||||
| import com.iformall.enums.EnumScoreRules; | import com.iformall.enums.EnumScoreRules; | ||||
| import com.iformall.enums.EnumScoreType; | import com.iformall.enums.EnumScoreType; | ||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.mapper.WxCUserBasicInfoMapper; | |||||
| import com.iformall.mapper.WxCUserMapper; | |||||
| import com.iformall.mapper.WxScoreHistoryMapper; | |||||
| import com.iformall.mapper.WxScoreRulesMapper; | |||||
| import com.iformall.mapper.*; | |||||
| import com.iformall.service.WxCUserService; | import com.iformall.service.WxCUserService; | ||||
| import com.iformall.service.WxScoreRulesService; | import com.iformall.service.WxScoreRulesService; | ||||
| import com.iformall.utils.Constant; | import com.iformall.utils.Constant; | ||||
| @@ -45,6 +42,9 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { | |||||
| @Qualifier("scoreRuleRedisTemplate") | @Qualifier("scoreRuleRedisTemplate") | ||||
| RedisTemplate<String, WxScoreRules> scoreRulesRedisTemplate; | RedisTemplate<String, WxScoreRules> scoreRulesRedisTemplate; | ||||
| @Autowired | |||||
| WxMerchantMapper wxMerchantMapper; | |||||
| @Override | @Override | ||||
| public WxScoreRules getScoreRules(String tenantId) { | public WxScoreRules getScoreRules(String tenantId) { | ||||
| // get pushLime from cache | // get pushLime from cache | ||||
| @@ -159,16 +159,18 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { | |||||
| @Override | @Override | ||||
| public void saveOrUpdate(WxScoreRules record) { | public void saveOrUpdate(WxScoreRules record) { | ||||
| Date date = new Date(); | |||||
| record.setUpdateDate(date); | |||||
| if (record.getId() == null) { | if (record.getId() == null) { | ||||
| //record.setId(UUID.randomUUID().toString().replaceAll("-", "")); | |||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| record.setId(idWorker.nextId()); | record.setId(idWorker.nextId()); | ||||
| record.setCreateDate(date); | |||||
| wxScoreRulesMapper.insert(record); | wxScoreRulesMapper.insert(record); | ||||
| } else { | } else { | ||||
| wxScoreRulesMapper.updateById(record); | wxScoreRulesMapper.updateById(record); | ||||
| } | } | ||||
| if (record != null && record.getType() == EnumScoreRules.SCORE.getCode()) { | |||||
| if (record != null && record.getType().equals(EnumScoreRules.SCORE.getCode())) { | |||||
| // 缓存存在,删除缓存 | // 缓存存在,删除缓存 | ||||
| String key = Constant.SCORE_RULES_KEY_PREV + record.getTenantId(); | String key = Constant.SCORE_RULES_KEY_PREV + record.getTenantId(); | ||||
| boolean hasKey = scoreRulesRedisTemplate.hasKey(key); | boolean hasKey = scoreRulesRedisTemplate.hasKey(key); | ||||
| @@ -177,7 +179,7 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { | |||||
| logger.info("WxScoreRulesServiceImpl.saveOrUpdate() : 从缓存中删除成长值设置 >> " + record.toString()); | logger.info("WxScoreRulesServiceImpl.saveOrUpdate() : 从缓存中删除成长值设置 >> " + record.toString()); | ||||
| } | } | ||||
| } | } | ||||
| if (record != null && record.getType() == EnumScoreRules.CREDIT.getCode()) { | |||||
| if (record != null && record.getType().equals(EnumScoreRules.CREDIT.getCode())) { | |||||
| // 缓存存在,删除缓存 | // 缓存存在,删除缓存 | ||||
| String key = Constant.CREDIT_RULES_KEY_PREV + record.getTenantId(); | String key = Constant.CREDIT_RULES_KEY_PREV + record.getTenantId(); | ||||
| boolean hasKey = scoreRulesRedisTemplate.hasKey(key); | boolean hasKey = scoreRulesRedisTemplate.hasKey(key); | ||||
| @@ -186,6 +188,9 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { | |||||
| logger.info("WxScoreRulesServiceImpl.saveOrUpdate() : 从缓存中删除积分设置 >> " + record.toString()); | logger.info("WxScoreRulesServiceImpl.saveOrUpdate() : 从缓存中删除积分设置 >> " + record.toString()); | ||||
| } | } | ||||
| } | } | ||||
| //更新商户数据 | |||||
| updateMerchantCreditLocked(record); | |||||
| } | } | ||||
| @Override | @Override | ||||
| @@ -618,4 +623,18 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { | |||||
| public List<WxScoreRules> findList(WxScoreRules wxScoreRules) { | public List<WxScoreRules> findList(WxScoreRules wxScoreRules) { | ||||
| return wxScoreRulesMapper.findList(wxScoreRules); | return wxScoreRulesMapper.findList(wxScoreRules); | ||||
| } | } | ||||
| @Override | |||||
| public void updateCreditLocked(WxScoreRules wxScoreRules) { | |||||
| wxScoreRulesMapper.updateById(wxScoreRules); | |||||
| updateMerchantCreditLocked(wxScoreRules); | |||||
| } | |||||
| public void updateMerchantCreditLocked(WxScoreRules wxScoreRules) { | |||||
| WxMerchant wxMerchant = new WxMerchant(); | |||||
| wxMerchant.setTenantId(wxScoreRules.getTenantId()); | |||||
| wxMerchant.setStatus(wxScoreRules.getCreditLocked()); | |||||
| wxMerchant.setUpdateDate(new Date()); | |||||
| wxMerchantMapper.updateCreditLocked(wxMerchant); | |||||
| } | |||||
| } | } | ||||
| @@ -33,13 +33,14 @@ | |||||
| <result column="link_line_phone" property="linkLinePhone"/> | <result column="link_line_phone" property="linkLinePhone"/> | ||||
| <result column="rental_start_date" property="rentalStartDate"/> | <result column="rental_start_date" property="rentalStartDate"/> | ||||
| <result column="rental_end_date" property="rentalEndDate"/> | <result column="rental_end_date" property="rentalEndDate"/> | ||||
| <result column="credit_locked" property="creditLocked"/> | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`,`tenant_id`,`img_url`,`name`,`link_phone`,`create_date`,`update_date`,`car_vendor_type`,`car_params`,`status`,`link_person`, | `id`,`tenant_id`,`img_url`,`name`,`link_phone`,`create_date`,`update_date`,`car_vendor_type`,`car_params`,`status`,`link_person`, | ||||
| `business_id`,`sub_business_id`,`shop_type`,`brand`,`type`,`is_public`,email,`title`,`cover_picture`,`is_admin`,`bill_setting`,`qr_code`, | `business_id`,`sub_business_id`,`shop_type`,`brand`,`type`,`is_public`,email,`title`,`cover_picture`,`is_admin`,`bill_setting`,`qr_code`, | ||||
| `introduction`,`action_desc`,`is_del`,`talk_user_main`,`talk_user_aux`,link_line_phone | |||||
| `introduction`,`action_desc`,`is_del`,`talk_user_main`,`talk_user_aux`,link_line_phone,credit_locked | |||||
| </sql> | </sql> | ||||
| <sql id="allColumnsVo"> | <sql id="allColumnsVo"> | ||||
| @@ -118,6 +119,9 @@ | |||||
| <if test=" null != brand "> | <if test=" null != brand "> | ||||
| and `brand` = #{brand} | and `brand` = #{brand} | ||||
| </if> | </if> | ||||
| <if test=" null != creditLocked "> | |||||
| and `credit_locked` = #{creditLocked} | |||||
| </if> | |||||
| <if test=" null != rentShopType "> | <if test=" null != rentShopType "> | ||||
| and id not in( | and id not in( | ||||
| select merchant_id from wx_rent_contract where tenant_id=#{tenantId} and rent_shop_type=1 and merchant_id is | select merchant_id from wx_rent_contract where tenant_id=#{tenantId} and rent_shop_type=1 and merchant_id is | ||||
| @@ -414,5 +418,9 @@ | |||||
| and `id` != #{id} | and `id` != #{id} | ||||
| </if> | </if> | ||||
| </select> | </select> | ||||
| <update id="updateCreditLocked" parameterType="com.iformall.domain.po.WxMerchant"> | |||||
| update wx_merchant set credit_locked = #{creditLocked} where tenant_id = #{tenantId} | |||||
| </update> | |||||
| </mapper> | </mapper> | ||||
| @@ -10,10 +10,12 @@ | |||||
| <result column="type" jdbcType="INTEGER" property="type"/> | <result column="type" jdbcType="INTEGER" property="type"/> | ||||
| <result column="clear_year" jdbcType="INTEGER" property="clearYear"/> | <result column="clear_year" jdbcType="INTEGER" property="clearYear"/> | ||||
| <result column="scale" jdbcType="INTEGER" property="scale"/> | <result column="scale" jdbcType="INTEGER" property="scale"/> | ||||
| <result column="credit_locked" jdbcType="INTEGER" property="creditLocked"/> | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`,`tenant_id`,`rules`,`create_date`,`update_date`,`type`,`clear_year`,`scale` | |||||
| `id`,`tenant_id`,`rules`,`create_date`,`update_date`,`type`,`clear_year`,`scale`,credit_locked | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| @@ -42,6 +44,10 @@ | |||||
| <if test=" null != scale "> | <if test=" null != scale "> | ||||
| and `scale` = #{scale} | and `scale` = #{scale} | ||||
| </if> | </if> | ||||
| <if test=" null != creditLocked "> | |||||
| and `credit_locked` = #{creditLocked} | |||||
| </if> | |||||
| <if test=" null != ids "> | <if test=" null != ids "> | ||||
| and id in | and id in | ||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | ||||