| @@ -7,6 +7,7 @@ import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.WxBusiness; | |||
| import com.iformall.domain.po.WxCoupon; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.vo.WxBusinessDataVo; | |||
| import com.iformall.enums.EnumCouponContentType; | |||
| import com.iformall.enums.EnumCouponSourceType; | |||
| @@ -14,6 +15,8 @@ import com.iformall.enums.EnumRentContractAppStatus; | |||
| import com.iformall.enums.EnumYesOrNo; | |||
| import com.iformall.service.ExcelService; | |||
| import com.iformall.service.WxBusinessService; | |||
| import com.iformall.service.WxMerchantService; | |||
| import com.iformall.utils.Constant; | |||
| import com.iformall.utils.DateUtils; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| @@ -38,6 +41,9 @@ public class WxBusinessController extends BaseController { | |||
| private WxBusinessService wxBusinessService; | |||
| @Autowired | |||
| private ExcelService excelService; | |||
| @Autowired | |||
| private WxMerchantService wxMerchantService; | |||
| @ApiOperation("业态全列表接口") | |||
| @@ -45,7 +51,7 @@ public class WxBusinessController extends BaseController { | |||
| @SystemControllerLog(description = "业态-全列表") | |||
| public ResultData listAll() { | |||
| logger.debug("[" + getIpAddr() + "] WxBusinessController::getList"); | |||
| final List<WxBusiness> busList = wxBusinessService.findListAll(getTenantInfo(),null,null); | |||
| final List<WxBusiness> busList = wxBusinessService.findListAll(true,getTenantInfo(),null,null); | |||
| return new ResultData(busList); | |||
| } | |||
| @@ -106,6 +112,23 @@ public class WxBusinessController extends BaseController { | |||
| if (b.getIsSystem().intValue() == EnumYesOrNo.YES.getCode().intValue()) { | |||
| return new ResultData(Result.ERROR,"不能修改系统默认业态"); | |||
| } | |||
| //已经关联商户了不能删 | |||
| WxMerchant merchantQ = new WxMerchant(); | |||
| merchantQ.updateTenantInfo(tenantEntity); | |||
| merchantQ.setBusinessId(b.getId()); | |||
| List<WxMerchant> merchantList = wxMerchantService.findList(merchantQ); | |||
| if (null != merchantList && merchantList.size() > 0 ) { | |||
| return new ResultData(Result.ERROR,"存在已关联的商户,不能删除"); | |||
| } | |||
| WxMerchant merchantsubQ = new WxMerchant(); | |||
| merchantsubQ.updateTenantInfo(tenantEntity); | |||
| merchantsubQ.setSubBusinessId(b.getId()); | |||
| List<WxMerchant> merchantSubList = wxMerchantService.findList(merchantsubQ); | |||
| if (null != merchantSubList && merchantSubList.size() > 0 ) { | |||
| return new ResultData(Result.ERROR,"存在已关联的商户,不能删除"); | |||
| } | |||
| b.setIsDel(EnumYesOrNo.YES.getCode()); | |||
| wxBusinessService.saveOrUpdate(b); | |||
| return new ResultData(); | |||
| @@ -30,7 +30,7 @@ public class WxBusinessController extends BaseController { | |||
| if(appPlat == null){ | |||
| appPlat = EnumAppPlat.WX; | |||
| } | |||
| return new ResultData(wxBusinessService.findListAll(getTenantInfo(),filter,appPlat.getCode())); | |||
| return new ResultData(wxBusinessService.findListAll(true,getTenantInfo(),filter,appPlat.getCode())); | |||
| } | |||
| } | |||
| @@ -11,8 +11,8 @@ public interface WxBusinessMapper extends CommonMapper<WxBusiness, String> { | |||
| List<WxBusiness> findList(WxBusiness wxBusiness); | |||
| List<WxBusiness> findListAll(WxBusiness wxBusiness); | |||
| List<WxBusiness> findListForMerchant(@Param("finalTenantId")String finalTenantId,@Param("isRoot")Integer isRoot,@Param("tenantId") String tenantId, @Param("parentTenantId") String parentTenantId); | |||
| List<WxBusiness> findListForCoupon(@Param("finalTenantId")String finalTenantId,@Param("isRoot")Integer isRoot,@Param("tenantId") String tenantId, @Param("parentTenantId") String parentTenantId, @Param("platCode") Integer platCode); | |||
| List<WxBusiness> findListForMerchant(@Param("finalTenantId")String finalTenantId,@Param("isRoot")Integer isRoot,@Param("isDel")Integer isDel,@Param("tenantId") String tenantId, @Param("parentTenantId") String parentTenantId); | |||
| List<WxBusiness> findListForCoupon(@Param("finalTenantId")String finalTenantId,@Param("isRoot")Integer isRoot,@Param("isDel")Integer isDel,@Param("tenantId") String tenantId, @Param("parentTenantId") String parentTenantId, @Param("platCode") Integer platCode); | |||
| List<Map<String,Object>> businessDataList(WxBusiness wxBusiness); | |||
| @@ -44,7 +44,7 @@ public interface WxBusinessService { | |||
| * | |||
| * @return | |||
| */ | |||
| List<WxBusiness> findListAll(TenantEntity tenantEntity, Integer filter,Integer platCode); | |||
| List<WxBusiness> findListAll(boolean isValid,TenantEntity tenantEntity, Integer filter,Integer platCode); | |||
| /** | |||
| * 根据Id获得实体 | |||
| @@ -9,6 +9,7 @@ import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.WxBusiness; | |||
| import com.iformall.domain.po.WxPropertyContract; | |||
| import com.iformall.domain.po.WxRentContract; | |||
| import com.iformall.domain.po.WxScoreRules; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.mapper.WxBusinessMapper; | |||
| import com.iformall.mapper.WxPropertyContractMapper; | |||
| @@ -20,6 +21,8 @@ import org.apache.commons.collections.CollectionUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.beans.factory.annotation.Qualifier; | |||
| import org.springframework.data.redis.core.RedisTemplate; | |||
| import org.springframework.stereotype.Service; | |||
| import java.io.Serializable; | |||
| @@ -42,6 +45,10 @@ public class WxBusinessServiceImpl implements WxBusinessService { | |||
| private WxRentContractMapper wxRentContractMapper; | |||
| @Autowired | |||
| private WxPropertyContractMapper wxPropertyContractMapper; | |||
| @Autowired | |||
| @Qualifier("scoreRuleRedisTemplate") | |||
| RedisTemplate<String, WxScoreRules> scoreRulesRedisTemplate; | |||
| @Override | |||
| public void businessInit(TenantEntity tenantInfo) { | |||
| @@ -68,18 +75,23 @@ public class WxBusinessServiceImpl implements WxBusinessService { | |||
| } | |||
| @Override | |||
| public List<WxBusiness> findListAll(TenantEntity tenantEntity, Integer filter,Integer paltCode) { | |||
| public List<WxBusiness> findListAll(boolean isValid,TenantEntity tenantEntity, Integer filter,Integer paltCode) { | |||
| WxBusiness bq = new WxBusiness(); | |||
| bq.setFinalTenantId(tenantEntity.getFinalTenantId()); | |||
| bq.setIsRoot(EnumYesOrNo.YES.getCode()); | |||
| Integer isDel = null; | |||
| if (isValid) { | |||
| isDel = EnumYesOrNo.NO.getCode(); | |||
| } | |||
| bq.setIsDel(isDel); | |||
| if (filter == null){ | |||
| return wxBusinessMapper.findListAll(bq); | |||
| }else if (filter.equals(EnumBusinessFilter.FILTER_BY_COUPON.getCode())) { | |||
| if (paltCode == null) | |||
| paltCode = EnumAppPlat.WX.getCode(); | |||
| return wxBusinessMapper.findListForCoupon(tenantEntity.getFinalTenantId(),EnumYesOrNo.YES.getCode(),tenantEntity.getTenantId(), tenantEntity.getParentTenantId(), paltCode); | |||
| return wxBusinessMapper.findListForCoupon(tenantEntity.getFinalTenantId(),EnumYesOrNo.YES.getCode(),isDel,tenantEntity.getTenantId(), tenantEntity.getParentTenantId(), paltCode); | |||
| }else if (filter.equals(EnumBusinessFilter.FILTER_BY_MERCHANT.getCode())) { | |||
| return wxBusinessMapper.findListForMerchant(tenantEntity.getFinalTenantId(),EnumYesOrNo.YES.getCode(),tenantEntity.getTenantId(), tenantEntity.getParentTenantId()); | |||
| return wxBusinessMapper.findListForMerchant(tenantEntity.getFinalTenantId(),EnumYesOrNo.YES.getCode(),isDel,tenantEntity.getTenantId(), tenantEntity.getParentTenantId()); | |||
| }else { | |||
| return wxBusinessMapper.findListAll(bq); | |||
| } | |||
| @@ -312,6 +324,25 @@ public class WxBusinessServiceImpl implements WxBusinessService { | |||
| record.setUpdateDate(new Date()); | |||
| wxBusinessMapper.updateById(record); | |||
| } | |||
| //删除积分规则,成长值规则缓存 | |||
| String key = Constant.SCORE_RULES_KEY_PREV + record.getFinalTenantId(); | |||
| boolean hasKey = scoreRulesRedisTemplate.hasKey(key); | |||
| if (hasKey) { | |||
| scoreRulesRedisTemplate.delete(key); | |||
| } | |||
| String key1 = Constant.CREDIT_RULES_KEY_PREV + record.getFinalTenantId(); | |||
| boolean hasKey1 = scoreRulesRedisTemplate.hasKey(key1); | |||
| if (hasKey1) { | |||
| scoreRulesRedisTemplate.delete(key1); | |||
| } | |||
| String key2 = Constant.CREDIT_DOUBLE_RULES_KEY_PREV + record.getFinalTenantId(); | |||
| boolean hasKey2 = scoreRulesRedisTemplate.hasKey(key2); | |||
| if (hasKey2) { | |||
| scoreRulesRedisTemplate.delete(key2); | |||
| } | |||
| } | |||
| } | |||
| @@ -734,7 +734,7 @@ public class WxChartServiceImpl implements WxChartDataService { | |||
| kwMerchantMeterDataDto.setLimitCount(null); | |||
| List <KwMerchantMeterDataVo> businessPower = kwMerchantMeterService.findDataVoList(kwMerchantMeterDataDto); | |||
| List <WxBusiness> businessList = wxBusinessService.findListAll(tenantEntity,null,null); | |||
| List <WxBusiness> businessList = wxBusinessService.findListAll(true,tenantEntity,null,null); | |||
| businessList.stream().forEach(b->{ | |||
| Optional<KwMerchantMeterDataVo> businessData = businessPower.stream().filter(bd->bd.getBusinessId().equals(b.getId())).findAny(); | |||
| if (businessData.isPresent()) { | |||
| @@ -120,24 +120,29 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { | |||
| //当成长值或积分规则新增时,将新增的数据一并返回给接口调用端 | |||
| private String getScoreRulesNew(TenantEntity tenantEntity,String scoreRules,EnumScoreRules enumScoreRules){ | |||
| JSONObject businessObject = WxScoreRules.getRuleObj(scoreRules, EnumScoreType.CONSUMPTION); | |||
| Map<Integer,JSONObject> businessRuleMap = new HashMap<Integer,JSONObject>(); | |||
| Map<Integer,JSONObject> currentBusinessRuleMap = new HashMap<Integer,JSONObject>(); | |||
| if (null != businessObject) { | |||
| JSONArray jsonArrayOld = businessObject.getJSONArray("childs"); | |||
| if (null != jsonArrayOld && jsonArrayOld.size() > 0 ) { | |||
| for (int i = 0 ; i < jsonArrayOld.size(); i++) { | |||
| JSONObject o = jsonArrayOld.getJSONObject(i); | |||
| Integer bussinessId = o.getInteger("businessId"); | |||
| businessRuleMap.put(bussinessId, o); | |||
| currentBusinessRuleMap.put(bussinessId, o); | |||
| } | |||
| } | |||
| } | |||
| //根据业态来匹配 | |||
| List<WxBusiness> rootBusiness = wxBusinessService.findListAll(tenantEntity, null, null); | |||
| Map<Integer,JSONObject> businessRuleMap = new HashMap<Integer,JSONObject>(); | |||
| List<WxBusiness> rootBusiness = wxBusinessService.findListAll(true,tenantEntity, null, null); | |||
| if (null != rootBusiness && rootBusiness.size() > 0 ) { | |||
| for (int i = 0 ; i < rootBusiness.size(); i++){ | |||
| WxBusiness bu = rootBusiness.get(i); | |||
| if (!businessRuleMap.containsKey(bu.getId())){ | |||
| businessRuleMap.put(bu.getId(), WxScoreRules.createBusinessDefaultJson(bu.getId(),bu.getTitle())); | |||
| if (currentBusinessRuleMap.containsKey(bu.getId())) { | |||
| businessRuleMap.put(bu.getId(),currentBusinessRuleMap.get(bu.getId())); | |||
| }else { | |||
| if (!businessRuleMap.containsKey(bu.getId())){ | |||
| businessRuleMap.put(bu.getId(), WxScoreRules.createBusinessDefaultJson(bu.getId(),bu.getTitle())); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -96,7 +96,7 @@ | |||
| and `parent_id` is null | |||
| </if> | |||
| <if test=" null != isDel "> | |||
| and `is_del` = #{isDel} | |||
| and `is_del` = #{isDel} | |||
| </if> | |||
| order by create_date asc | |||
| </select> | |||
| @@ -109,6 +109,9 @@ | |||
| <if test=" 1 == isRoot"> | |||
| and b.`parent_id` is null | |||
| </if> | |||
| <if test=" null != isDel "> | |||
| and b.`is_del` = #{isDel} | |||
| </if> | |||
| and | |||
| (select count(*) from wx_merchant m | |||
| where b.id = m.business_id | |||
| @@ -131,6 +134,9 @@ | |||
| <if test=" 1 == isRoot"> | |||
| and b.`parent_id` is null | |||
| </if> | |||
| <if test=" null != isDel "> | |||
| and b.`is_del` = #{isDel} | |||
| </if> | |||
| and | |||
| (select count(*) from wx_coupon_channel cc | |||
| where b.id = cc.business | |||
| @@ -39,7 +39,7 @@ public class WxBusinessController extends BaseController { | |||
| @SystemControllerLog(description = "业态-全列表") | |||
| public ResultData listAll() { | |||
| logger.debug("[" + getIpAddr() + "] WxBusinessController::getList"); | |||
| final List<WxBusiness> busList = wxBusinessService.findListAll(getTenantInfo(),null,null); | |||
| final List<WxBusiness> busList = wxBusinessService.findListAll(true,getTenantInfo(),null,null); | |||
| return new ResultData(busList); | |||
| } | |||
| @@ -25,7 +25,7 @@ public class WxBusinessController extends BaseController { | |||
| @ApiOperation("业态全列表接口") | |||
| @GetMapping("listAll") | |||
| public ResultData listAll(Integer filter) { | |||
| return new ResultData(wxBusinessService.findListAll(getTenantInfo(),filter,null)); | |||
| return new ResultData(wxBusinessService.findListAll(true,getTenantInfo(),filter,null)); | |||
| } | |||
| } | |||