| @@ -47,13 +47,15 @@ | |||
| <version>5.2.4</version> | |||
| </dependency> | |||
| <!-- https://mvnrepository.com/artifact/net.sourceforge.tess4j/tess4j --> | |||
| <!-- ocr --> | |||
| <dependency> | |||
| <groupId>net.sourceforge.tess4j</groupId> | |||
| <artifactId>tess4j</artifactId> | |||
| <version>4.5.2</version> | |||
| <groupId>com.iformall</groupId> | |||
| <artifactId>mallinkOcr</artifactId> | |||
| <version>1.0</version> | |||
| </dependency> | |||
| </dependencies> | |||
| <build> | |||
| @@ -34,6 +34,9 @@ public class UserApplication { | |||
| @Value("${fm.upload_dir}") | |||
| private String uploadDir; | |||
| @Value("${fm.ocr_data}") | |||
| private String ocrData; | |||
| @Bean | |||
| public boolean isFmException() { | |||
| return fmException; | |||
| @@ -53,6 +56,11 @@ public class UserApplication { | |||
| public String fmUploadDir() { | |||
| return uploadDir; | |||
| } | |||
| @Bean | |||
| public String ocrData() { | |||
| return ocrData; | |||
| } | |||
| public static void main(String[] args) { | |||
| SpringApplication.run(UserApplication.class, args); | |||
| @@ -4,14 +4,21 @@ import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxMallBuilding; | |||
| import com.iformall.domain.po.WxMallFloor; | |||
| import com.iformall.service.WxMallBuildingService; | |||
| import com.iformall.utils.Constant; | |||
| import com.iformall.utils.RedisCacheUtils; | |||
| import io.swagger.annotations.ApiOperation; | |||
| 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.web.bind.annotation.*; | |||
| import java.util.List; | |||
| @RestController | |||
| @RequestMapping("wxMallBuilding") | |||
| public class WxMallBuildingController extends BaseController { | |||
| @@ -20,6 +27,10 @@ public class WxMallBuildingController extends BaseController { | |||
| @Autowired | |||
| private WxMallBuildingService wxMallBuildingService; | |||
| @Autowired | |||
| @Qualifier("objectCommonRedisTemplate") | |||
| RedisTemplate<String, Object> objectCommonRedisTemplate; | |||
| @ApiOperation("获取楼层楼座数据") | |||
| @GetMapping("getbuildingfloorlist") | |||
| @SystemControllerLog(description = "商城-楼座-获取楼层楼座数据") | |||
| @@ -28,6 +39,33 @@ public class WxMallBuildingController extends BaseController { | |||
| return wxMallBuildingService.getBuildingFloorList(getTenantInfo()); | |||
| } | |||
| @ApiOperation("保存楼层楼座地图") | |||
| @PostMapping("saveFloorImg") | |||
| @SystemControllerLog(description = "商城-楼座/楼层-保存地图") | |||
| public ResultData saveFloorImg(@RequestBody List<WxMallBuilding> record) { | |||
| logger.debug("[" + getIpAddr() + "] WxMallBuildingController::addBuildingAndFloor"); | |||
| if(record == null && record.size() > 0) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| for (WxMallBuilding building: record) { | |||
| List<WxMallFloor> floors = building.getFloors(); | |||
| if(floors != null && floors.size() > 0){ | |||
| for (WxMallFloor floor:floors) { | |||
| if (floor.getId() == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| floor.updateTenantInfo(getTenantInfo()); | |||
| wxMallBuildingService.saveFloorImg(floor); | |||
| } | |||
| } | |||
| } | |||
| String key = Constant.mallBuildingPrev + getTenantInfo().getTenantId(); | |||
| RedisCacheUtils.removeCache(objectCommonRedisTemplate, key); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("保存楼层楼座面积") | |||
| @PostMapping("saveFloorArea") | |||
| @SystemControllerLog(description = "商城-楼座/楼层-保存面积") | |||
| @@ -552,6 +552,23 @@ public class WxRentContractController extends WxContractBaseController { | |||
| return new ResultData(Result.ERROR,e.getMessage()); | |||
| } | |||
| //如果是租金+物业合同,如果没有物业合同或者物业合同不是草稿状态,不能提交审核 | |||
| if (contract.getOperationType().intValue() == EnumContractOperationType.WHOLE.getCode().intValue()) { | |||
| if (null == wxRentContract.getPropertyId()) { | |||
| return new ResultData(Result.ERROR,"未创建物业合同,请先完善。"); | |||
| } | |||
| WxPropertyContract property = wxPropertyContractService.getSimpleDetail(wxRentContract.getPropertyId()); | |||
| if (null == property) { | |||
| return new ResultData(Result.ERROR,"未创建物业合同,请先完善。"); | |||
| } | |||
| if (property.getStatus().intValue() == EnumRentContractStatus.UNWRITE.getCode().intValue()) { | |||
| return new ResultData(Result.ERROR,"物业合同未完善,请先完善。"); | |||
| } | |||
| if (property.getStatus().intValue() != EnumRentContractStatus.DRAFT.getCode().intValue()) { | |||
| return new ResultData(Result.ERROR,"物业合同当前状态不能直接生效。"); | |||
| } | |||
| } | |||
| wxRentContractService.updateRentContractStatus(wxRentContract.getId(),false); | |||
| if(contract.getOperationType().intValue() == EnumContractOperationType.WHOLE.getCode().intValue()) { | |||
| wxPropertyContractService.updatePropertyContractStatus(wxRentContract.getPropertyId()); | |||
| @@ -634,12 +651,6 @@ public class WxRentContractController extends WxContractBaseController { | |||
| if (property.getStatus().intValue() != EnumRentContractStatus.DRAFT.getCode().intValue()) { | |||
| return new ResultData(Result.ERROR,"物业合同当前状态不能提交审批。"); | |||
| } | |||
| WxPropertyContract wpc = new WxPropertyContract(); | |||
| wpc.setStatus(EnumRentContractStatus.DRAFT.getCode()); | |||
| wpc.setRentContractId(rentContract.getId()); | |||
| wpc.setOperationType(EnumRentShopType.SHOP.getCode()); | |||
| List<WxPropertyContract> list = wxPropertyContractService.findList(wpc); | |||
| } | |||
| if(rentContract.getOperationType().intValue() == EnumContractOperationType.PART.getCode().intValue()) { | |||
| @@ -80,6 +80,17 @@ public class DataTowerController extends BaseController { | |||
| return new ResultData(data); | |||
| } | |||
| @ApiOperation("新版本查询客流") | |||
| @GetMapping("/queryCustomerNewVersion") | |||
| @SystemControllerLog(description = "数据塔台-新版本查询客流") | |||
| public ResultData queryCustomerNewVersion() { | |||
| logger.debug("[" + getIpAddr() + "] DataTowerController::queryCustomerNewVersion"); | |||
| Map<String, Object> data = dataTowerService.queryCustomerNewVersion(getTenantInfo()); | |||
| return new ResultData(data); | |||
| } | |||
| @ApiOperation("查询客流") | |||
| @GetMapping("/queryCustomerData") | |||
| @@ -105,4 +105,12 @@ public class WxActivityController extends BaseController { | |||
| return wxActivityService.sendToCampaign(id); | |||
| } | |||
| @ApiOperation("从宣传页下线") | |||
| @PostMapping("offLineCampaign") | |||
| @SystemControllerLog(description = "活动-更新状态") | |||
| public ResultData offLineCampaign(@RequestBody WxActivity wxActivity) { | |||
| logger.debug("[" + getIpAddr() + "] WxActivityController::updateStatus"); | |||
| return wxActivityService.offLineCampaign(wxActivity); | |||
| } | |||
| } | |||
| @@ -65,7 +65,11 @@ public class WxActivityJoinController extends BaseController { | |||
| if (wxActivityJoin.getStatus() == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "status不能为空"); | |||
| } | |||
| return wxActivityJoinService.modifyStatus(wxActivityJoin); | |||
| try { | |||
| return wxActivityJoinService.modifyStatus(wxActivityJoin); | |||
| } catch (MallinkException e) { | |||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||
| } | |||
| } | |||
| @ApiOperation("导出报名表") | |||
| @@ -0,0 +1,79 @@ | |||
| package com.iformall.controller.mem; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxCUserFrom; | |||
| import com.iformall.domain.vo.WxCUserFromVo; | |||
| import com.iformall.enums.EnumCUserFrom; | |||
| import com.iformall.service.WxCUserFromService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| @RestController | |||
| @RequestMapping("wxCUserFrom") | |||
| public class WxCUserFromController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxCUserFromService wxCUserFromService; | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "分享-列表") | |||
| public ResultData list(@ModelAttribute WxCUserFrom wxCUserFrom, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxCUserCarController::list"); | |||
| if (null == wxCUserFrom) wxCUserFrom = new WxCUserFrom(); | |||
| wxCUserFrom.updateTenantInfo(getTenantInfo()); | |||
| final PageInfo<WxCUserFrom> page = wxCUserFromService.listAsPage(wxCUserFrom, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/visits") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "分享-列表") | |||
| public ResultData visits(@ModelAttribute WxCUserFromVo wxCUserFromVo,Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxCUserCarController::findById"); | |||
| if (null == wxCUserFromVo) wxCUserFromVo = new WxCUserFromVo(); | |||
| if(wxCUserFromVo.getFromType() == null){ | |||
| wxCUserFromVo.setFromType(EnumCUserFrom.FROM_C_USER_BASIC_INFO.getCode()); | |||
| } | |||
| wxCUserFromVo.updateTenantInfo(getTenantInfo()); | |||
| final PageInfo<WxCUserFromVo> page = wxCUserFromService.listAsVisitsPage(wxCUserFromVo, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @GetMapping("/exportData") | |||
| @SystemControllerLog(description = "导出数据") | |||
| public void exportData(@ModelAttribute WxCUserFrom wxCUserFrom, HttpServletRequest request, HttpServletResponse response) { | |||
| if (null == wxCUserFrom) wxCUserFrom = new WxCUserFrom(); | |||
| wxCUserFrom.updateTenantInfo(getTenantInfo()); | |||
| wxCUserFromService.exportData(request, response, wxCUserFrom); | |||
| } | |||
| @GetMapping("/exportDataVisits") | |||
| @SystemControllerLog(description = "导出数据") | |||
| public void exportDataVisits(@ModelAttribute WxCUserFromVo wxCUserFromVo, HttpServletRequest request, HttpServletResponse response) { | |||
| if (null == wxCUserFromVo) wxCUserFromVo = new WxCUserFromVo(); | |||
| wxCUserFromVo.updateTenantInfo(getTenantInfo()); | |||
| if(wxCUserFromVo.getFromType() == null){ | |||
| wxCUserFromVo.setFromType(EnumCUserFrom.FROM_C_USER_BASIC_INFO.getCode()); | |||
| } | |||
| wxCUserFromService.exportDataVisits(request, response, wxCUserFromVo); | |||
| } | |||
| } | |||
| @@ -11,6 +11,7 @@ import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.domain.po.WxCreditHistory; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.vo.MerchantCreditRankingVo; | |||
| import com.iformall.domain.vo.WxCreditHistoryVo; | |||
| import com.iformall.enums.EnumMerchantStatus; | |||
| import com.iformall.enums.EnumScoreType; | |||
| @@ -73,7 +74,7 @@ public class WxCreditHistoryController extends BaseController { | |||
| } | |||
| try { | |||
| Map<String, Integer> result = wxCreditHistoryService.findByMerchantIdAndSpend(merchantId, spendStr, userId, getTenantInfo().getFinalTenantId()) ; | |||
| Map<String, Integer> result = wxCreditHistoryService.findByMerchantIdAndSpend(merchantId, spendStr, userId) ; | |||
| return new ResultData(result); | |||
| } catch (MallinkException e) { | |||
| return new ResultData(e.getErrorCode(),e.getMessage()); | |||
| @@ -109,7 +110,7 @@ public class WxCreditHistoryController extends BaseController { | |||
| wxCreditHistory.setChangePurpose(desc); | |||
| try { | |||
| wxCreditHistoryService.creditUsercheck(wxCreditHistory.getCUserId(),getTenantInfo()) ; | |||
| WxCreditHistory credit = wxCreditHistoryService.saveOrUpdate(wxCreditHistory); | |||
| WxCreditHistory credit = wxCreditHistoryService.saveOrUpdate(wxCreditHistory,getTenantInfo().getTenantId()); | |||
| return new ResultData(Result.SUCCESS, "操作成功", credit); | |||
| } catch (MallinkException e) { | |||
| logger.error(e.getMessage()); | |||
| @@ -173,4 +174,19 @@ public class WxCreditHistoryController extends BaseController { | |||
| return new ResultData(Result.SUCCESS); | |||
| } | |||
| @ApiOperation("门店排行榜") | |||
| @GetMapping("merchantCreditRanking") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "、-列表") | |||
| public ResultData merchantCreditRanking(@ModelAttribute WxCreditHistory wxCreditHistory, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxCreditHistoryController::merchantCreditRanking"); | |||
| if (null == wxCreditHistory) wxCreditHistory = new WxCreditHistory(); | |||
| TenantEntity tenantInfo = getTenantInfo(); | |||
| wxCreditHistory.updateTenantInfo(tenantInfo); | |||
| final PageInfo<MerchantCreditRankingVo> page = wxCreditHistoryService.listAsPageMcrv(wxCreditHistory, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| } | |||
| @@ -4,9 +4,13 @@ import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxMall; | |||
| import com.iformall.domain.po.WxScoreRules; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.enums.EnumCreditLockedStatus; | |||
| import com.iformall.enums.EnumGroupSupport; | |||
| import com.iformall.enums.EnumScoreRules; | |||
| import com.iformall.service.WxMallService; | |||
| import com.iformall.service.WxScoreRulesService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| @@ -25,6 +29,9 @@ public class WxScoreRulesController extends BaseController { | |||
| @Autowired | |||
| private WxScoreRulesService wxScoreRulesService; | |||
| @Autowired | |||
| private WxMallService wxMallService; | |||
| @ApiOperation("成长值配置") | |||
| @GetMapping("setting") | |||
| @SystemControllerLog(description = "成长值-配置") | |||
| @@ -42,11 +49,27 @@ public class WxScoreRulesController extends BaseController { | |||
| @SystemControllerLog(description = "成长值-积分-配置-新增") | |||
| public ResultData add(@RequestBody WxScoreRules wxScoreRules) { | |||
| logger.debug("[" + getIpAddr() + "] WxScoreRulesController::add"); | |||
| TenantEntity tenantEntity = ifParentUpdateTenantInfo(); | |||
| if (StringUtils.isNotBlank(tenantEntity.getParentTenantId())) { | |||
| return new ResultData(ErrorCode.USER_NO_PERMISSION.getCode(), "广场用户无此权限"); | |||
| if(wxScoreRules.getType() != null){ | |||
| if(wxScoreRules.getType().equals(EnumScoreRules.SCORE.getCode()) || wxScoreRules.getType().equals(EnumScoreRules.CREDIT.getCode())){ | |||
| TenantEntity tenantEntity = ifParentUpdateTenantInfo(); | |||
| if (StringUtils.isNotBlank(tenantEntity.getParentTenantId())) { | |||
| return new ResultData(ErrorCode.USER_NO_PERMISSION.getCode(), "广场用户无此权限"); | |||
| } | |||
| wxScoreRules.updateTenantInfo(tenantEntity); | |||
| }else if(wxScoreRules.getType().equals(EnumScoreRules.CREDIT_DOUBLE.getCode())){ | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| WxMall mall = wxMallService.getByTenantId(getUser().getTenantId()); | |||
| if((mall.getGroupSupport().equals(EnumGroupSupport.SUPPORT.getCode()) && StringUtils.isBlank(getUser().getParentTenantId())) || | |||
| StringUtils.isBlank(tenantEntity.getTenantId())){ | |||
| return new ResultData(ErrorCode.USER_NO_PERMISSION.getCode(), "集团用户无此权限"); | |||
| } | |||
| wxScoreRules.updateTenantInfo(tenantEntity); | |||
| }else{ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"type"); | |||
| } | |||
| }else{ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL,"type"); | |||
| } | |||
| wxScoreRules.updateTenantInfo(tenantEntity); | |||
| wxScoreRulesService.saveOrUpdate(wxScoreRules); | |||
| return new ResultData(); | |||
| } | |||
| @@ -55,11 +78,23 @@ public class WxScoreRulesController extends BaseController { | |||
| @GetMapping("/credit_rules") | |||
| @SystemControllerLog(description = "积分-配置") | |||
| public ResultData creditRulesList() { | |||
| logger.debug("[" + getIpAddr() + "] WxScoreRulesController::list"); | |||
| logger.debug("[" + getIpAddr() + "] creditRulesList::list"); | |||
| WxScoreRules scoreRules = wxScoreRulesService.getCreditRules(getTenantInfo().getFinalTenantId()); | |||
| return new ResultData(scoreRules); | |||
| } | |||
| @ApiOperation("积分倍率") | |||
| @GetMapping("/credit_double") | |||
| @SystemControllerLog(description = "积分-配置") | |||
| public ResultData creditDoubleRulesList() { | |||
| logger.debug("[" + getIpAddr() + "] creditDoubleRulesList::list"); | |||
| if(StringUtils.isBlank(getTenantInfo().getTenantId())){ | |||
| return new ResultData(ErrorCode.USER_NO_PERMISSION,"集团用户无此权限"); | |||
| } | |||
| WxScoreRules scoreRules = wxScoreRulesService.getCreditDoubleRules(getTenantInfo().getTenantId()); | |||
| return new ResultData(scoreRules); | |||
| } | |||
| @ApiOperation("更新积分开关状态") | |||
| @PostMapping("updateCreditLocked") | |||
| @SystemControllerLog(description = "更新积分开关状态") | |||
| @@ -0,0 +1,223 @@ | |||
| package com.iformall.controller.ocr; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.domain.po.WxMall; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.po.WxMerchantOcrModel; | |||
| import com.iformall.domain.po.WxOcrModel; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.base.BaseEntity.SortField; | |||
| import com.iformall.enums.EnumFromType; | |||
| import com.iformall.enums.EnumRentStartType; | |||
| import com.iformall.ocr.FormallTess4j; | |||
| import com.iformall.ocr.FormallTess4jTrain; | |||
| import com.iformall.service.WxMallService; | |||
| import com.iformall.service.WxMerchantService; | |||
| import com.iformall.service.WxOcrService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import java.io.File; | |||
| import java.io.FileOutputStream; | |||
| import java.io.IOException; | |||
| import java.io.InputStream; | |||
| import java.io.OutputStream; | |||
| import java.util.Date; | |||
| import java.util.Map; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import org.springframework.web.multipart.MultipartFile; | |||
| @RestController | |||
| @RequestMapping("ocr") | |||
| public class WxOcrController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxOcrService ocrService; | |||
| @Autowired | |||
| private WxMerchantService merchantService; | |||
| @Autowired | |||
| private String ocrData; | |||
| /** | |||
| * 模板列表 | |||
| * @param wxRentContract | |||
| * @param pageNum | |||
| * @param pageSize | |||
| * @return | |||
| */ | |||
| @GetMapping("/modelList") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public ResultData modelList(@ModelAttribute WxOcrModel ocrModel, Integer pageNum, Integer pageSize) { | |||
| if (null == ocrModel) { | |||
| ocrModel = new WxOcrModel(); | |||
| } | |||
| ocrModel.setSortColumns(SortField.Createtime_DESC); | |||
| PageInfo<WxOcrModel> page = ocrService.listOcrModelAsPage(ocrModel, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| /** | |||
| * 更新模板 | |||
| * @param wxRentContract | |||
| * @return | |||
| */ | |||
| @PostMapping("updateModel") | |||
| public ResultData updateModel(@RequestBody WxOcrModel ocrModel) { | |||
| return ocrService.saveOrUpdateOcrModel(ocrModel); | |||
| } | |||
| /** | |||
| * 根据商户查询模板 | |||
| * @param wxRentContract | |||
| * @return | |||
| */ | |||
| @GetMapping("merchantModel") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "merchantId", value = "商户编号", dataType = "Long", paramType = "query", required = true) | |||
| }) | |||
| public ResultData merchantModel(Long merchantId) { | |||
| WxMerchant merchant = merchantService.getById(merchantId); | |||
| if (null == merchant) { | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"商户数据不存在"); | |||
| } | |||
| return new ResultData(ocrService.getMerchantOcrModel(merchantId, merchant.getTenantId(), merchant.getParentTenantId())); | |||
| } | |||
| /** | |||
| * 更新商户模板 | |||
| * @param wxRentContract | |||
| * @return | |||
| */ | |||
| @PostMapping("updateMerchantModel") | |||
| public ResultData updateMerchantModel(@RequestBody WxMerchantOcrModel merchantModel) { | |||
| return ocrService.saveOrUpdateMerchantOcrModel(merchantModel); | |||
| } | |||
| /** | |||
| * 删除商户模板 | |||
| * @param wxRentContract | |||
| * @return | |||
| */ | |||
| @PostMapping("deleteMerchantModel") | |||
| public ResultData deleteMerchantModel(@RequestBody WxMerchantOcrModel merchantModel) { | |||
| return ocrService.deleteMerchantOcrModel(merchantModel.getId()); | |||
| } | |||
| /** | |||
| * 获取训练步骤 | |||
| * @return | |||
| */ | |||
| @GetMapping("getTrainSteps") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "modelId", value = "模板编号", dataType = "Long", paramType = "query", required = true) | |||
| }) | |||
| public ResultData getTrainSteps(Long modelId) { | |||
| WxOcrModel model = ocrService.getOcrModelById(modelId); | |||
| if (null == model) { | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"ocr模板不存在"); | |||
| } | |||
| return new ResultData(FormallTess4jTrain.getTrainSteps(model.getLangCode(), model.getFontName())); | |||
| } | |||
| /** | |||
| *测试训练结果 | |||
| * @return | |||
| */ | |||
| @PostMapping(value = "/testTrain", consumes = "multipart/*", headers = "content-type=multipart/form-data") | |||
| public ResultData testTrain(@RequestParam("file") MultipartFile multiReq,@RequestParam("modelId") Long modelId) { | |||
| try { | |||
| WxOcrModel model = ocrService.getOcrModelById(modelId); | |||
| if (null == model) { | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(),"ocr模板不存在"); | |||
| } | |||
| File file = multipartFileToFile(multiReq); | |||
| String result = FormallTess4j.testDoOCR_File(ocrData, file, model.getFontName()); | |||
| file.delete(); | |||
| return new ResultData(result); | |||
| } catch (Exception e) { | |||
| logger.error("testTrain error.",e); | |||
| return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR.getCode(),"解析失败。"+e.getMessage()); | |||
| } | |||
| } | |||
| private File multipartFileToFile(MultipartFile file) { | |||
| File toFile = null; | |||
| if (file.equals("") || file.getSize() <= 0) { | |||
| file = null; | |||
| } else { | |||
| InputStream ins = null; | |||
| try { | |||
| ins = file.getInputStream(); | |||
| toFile = new File(file.getOriginalFilename()); | |||
| inputStreamToFile(ins, toFile); | |||
| ins.close(); | |||
| } catch (IOException e) { | |||
| logger.error("multipartFileToFile error.",e); | |||
| }finally { | |||
| if (null != ins) { | |||
| try { | |||
| ins.close(); | |||
| } catch (IOException e) { | |||
| logger.error("multipartFileToFile error.",e); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| return toFile; | |||
| } | |||
| private void inputStreamToFile(InputStream ins, File file) { | |||
| OutputStream os = null; | |||
| try { | |||
| os = new FileOutputStream(file); | |||
| int bytesRead = 0; | |||
| byte[] buffer = new byte[8192]; | |||
| while ((bytesRead = ins.read(buffer, 0, 8192)) != -1) { | |||
| os.write(buffer, 0, bytesRead); | |||
| } | |||
| os.close(); | |||
| ins.close(); | |||
| } catch (Exception e) { | |||
| logger.error("inputStreamToFile error.",e); | |||
| }finally { | |||
| if (null != os) { | |||
| try { | |||
| os.close(); | |||
| } catch (IOException e) { | |||
| logger.error("inputStreamToFile error.",e); | |||
| } | |||
| } | |||
| if (null != ins) { | |||
| try { | |||
| ins.close(); | |||
| } catch (IOException e) { | |||
| logger.error("inputStreamToFile error.",e); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -119,7 +119,7 @@ public class UploadController extends BaseController { | |||
| return data; | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| logger.error("解析图片",e); | |||
| return new ResultData(ErrorCode.PICTURE_ANALYZING_ERROR); | |||
| } | |||
| } | |||
| @@ -41,12 +41,14 @@ public class TenantInfoImpl implements TenantInfo { | |||
| "wx_level_config", | |||
| "wx_c_user_basic_info", | |||
| "wx_c_user_basic_child", | |||
| "wx_c_user_basic_sign", | |||
| "wx_credit_history", | |||
| "wx_score_history", | |||
| "wx_c_user_tags", | |||
| "wx_weapp_ext_set", | |||
| "wx_msg_validationcode_model", | |||
| "sys_notice"}; | |||
| "sys_notice", | |||
| "wx_ocr_model"}; | |||
| private static String[] filterSubTables = new String[] { | |||
| "wx_mall", | |||
| @@ -72,9 +74,11 @@ public class TenantInfoImpl implements TenantInfo { | |||
| "wx_weapp_release_status", | |||
| "wx_c_user_basic_info", | |||
| "wx_c_user_basic_child", | |||
| "wx_c_user_basic_sign", | |||
| "mem_coupon_from_dsp", | |||
| "wx_msg_validationcode_model", | |||
| "sys_notice"}; | |||
| "sys_notice", | |||
| "wx_ocr_model"}; | |||
| @Override | |||
| public String getTenantId() { | |||
| @@ -163,11 +163,12 @@ jasypt: | |||
| password: oRqdnDbK5pj3eMmB | |||
| fm: | |||
| exception: false | |||
| exception_emails: zhengfangyuan@iformall.com,xuxiaohu@iformall.com | |||
| exception: true | |||
| exception_emails: xuxiaohu@iformall.com | |||
| deploy: 1 | |||
| open: true | |||
| upload_dir: /home/test/server/uploads/ | |||
| ocr_data: /root/ocr_data/ | |||
| ueditor: | |||
| config: config.json | |||
| @@ -124,6 +124,7 @@ fm: | |||
| deploy: 3 | |||
| open: true | |||
| upload_dir: /root/uploads/ | |||
| ocr_data: /root/ocr_data/ | |||
| ueditor: | |||
| config: config.json | |||
| @@ -0,0 +1,2 @@ | |||
| ALTER TABLE `wx_mall_floor` | |||
| ADD COLUMN `floor_map` json COMMENT '地图' AFTER `total_area`; | |||
| @@ -0,0 +1,299 @@ | |||
| ALTER TABLE `wx_c_user_basic_info_0` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_1` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_2` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_3` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_4` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_5` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_6` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_7` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_8` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_9` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_10` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_11` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_12` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_13` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_14` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_15` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_16` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_17` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_18` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_19` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_20` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_21` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_22` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_23` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_24` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_25` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_26` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_27` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_28` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_29` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_30` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_31` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_32` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_33` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_34` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_35` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_36` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_37` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_38` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_39` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_40` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_41` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_42` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_43` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_44` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_45` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_46` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_47` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_48` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_49` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_50` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_51` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_52` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_53` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_54` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_55` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_56` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_57` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_58` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_59` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_60` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_61` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_62` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_63` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_64` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_65` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_66` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_67` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_68` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_69` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_70` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_71` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_72` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_73` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_74` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_75` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_76` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_77` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_78` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_79` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_80` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_81` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_82` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_83` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_84` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_85` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_86` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_87` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_88` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_89` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_90` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_91` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_92` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_93` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_94` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_95` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_96` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_97` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_98` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| ALTER TABLE `wx_c_user_basic_info_99` | |||
| ADD COLUMN `qr_code` varchar(500) COMMENT '二维码地址' AFTER `tag_scan_time`; | |||
| @@ -0,0 +1,16 @@ | |||
| --加推广菜单 | |||
| INSERT INTO `mall_permission`(`id`, `name`, `parent_id`, `available`, `permission`, `resource_type`, `module_color`, `module_color_num`, `url`, `icon`, `version_type`, `sort`) VALUES (514, '推广数据', 5, 'Y', NULL, 1, NULL, NULL, 'memberImport', 'icon-tuiguang', 0, 503); | |||
| --销售类型加权限 | |||
| update mall_sale_type set menus = '[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 50, 101, 102, 103, 104, 105, 106, 107, 108, 201, 202, 203, 204, 205, 206, 209, 211, 212, 221, 222, 251, 299, 300, 301, 302, 303, 304, 305, 306, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 501, 502, 503, 504, 505, 506, 507, 508, 509, 511, 512, 513, 514, 521, 522, 523, 531, 532, 533, 591, 592, 595, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 621, 622, 623, 624, 625, 626, 627, 641, 642, 643, 644, 645, 646, 651, 661, 662, 663, 664, 671, 672, 673, 674, 675, 681, 682, 683, 684, 685, 686, 691, 692, 693, 694, 695, 701, 702, 703, 704, 711, 712, 713, 901, 902, 903, 904, 905, 931, 932, 951, 952, 961, 962, 963, 965, 966, 967, 968, 1001, 1002, 1003, 1004]' where id=1; | |||
| update mall_sale_type set menus = '[1, 2, 4, 5, 6, 7, 8, 9, 10, 50, 101, 102, 103, 104, 105, 106, 107, 201, 202, 203, 204, 205, 209, 211, 212, 221, 222, 251, 409, 410, 411, 416, 418, 501, 502, 503, 504, 505, 506, 507, 508, 509, 511, 512, 513, 514, 521, 522, 523, 531, 532, 533, 591, 592, 595, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 621, 622, 623, 624, 625, 626, 627, 641, 642, 643, 644, 645, 646, 651, 661, 662, 663, 664, 671, 672, 673, 674, 675, 681, 682, 683, 684, 685, 686, 691, 692, 693, 694, 695, 701, 702, 703, 704, 711, 712, 713, 901, 902, 903, 904, 905, 931, 932, 951, 961]' where id=2; | |||
| update mall_sale_type set menus = '[2, 4, 5, 6, 7, 10, 50, 201, 202, 205, 211, 212, 221, 222, 251, 409, 410, 411, 416, 418, 501, 502, 503, 504, 505, 506, 507, 508, 511, 512, 513, 514, 521, 522, 523, 531, 532, 533, 591, 592, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 621, 622, 623, 624, 625, 626, 641, 642, 643, 644, 645, 646, 651, 661, 662, 663, 664, 671, 672, 673, 674, 675, 681, 682, 683, 684, 685, 686, 691, 692, 693, 694, 695, 701, 702, 703, 704, 711, 712, 713, 901, 902, 903, 904, 905, 931, 932]' where id=3; | |||
| update mall_sale_type set menus = '[2, 4, 5, 6, 7, 10, 50, 201, 202, 205, 211, 212, 221, 222, 251, 409, 410, 411, 416, 418, 501, 502, 503, 504, 505, 506, 507, 508, 511, 512, 513, 514, 521, 522, 523, 531, 532, 591, 601, 602, 604, 605, 606, 607, 608, 610, 611, 612, 622, 623, 624, 625, 626, 641, 642, 643, 644, 661, 662, 663, 664, 671, 672, 674, 675, 681, 682, 684, 685, 686, 691, 692, 693, 694, 695, 711, 901, 902, 904, 905, 931, 932]' where id=4; | |||
| --所有广场管理员角色加权限 | |||
| INSERT INTO `mall_role_permission`(`id`, `tenant_id`, `parent_tenant_id`, `permission_id`, `role_id`) | |||
| select CEILING(RAND()*90000000000+10000000000) ,mui.tenant_id,mui.parent_tenant_id, 514,mur.role_id | |||
| from mall_user_info mui | |||
| left join mall_user_role mur on mui.id = mur.uid | |||
| where mui.is_admin = 1 and mur.role_id is not null GROUP BY mur.role_id; | |||
| @@ -0,0 +1,5 @@ | |||
| INSERT INTO `mallink`.`wx_score_rules`(`id`, `tenant_id`, `type`, `scale`) | |||
| select CEILING(RAND()*90000000000+10000000000),`tenant_id`,4,`scale` from wx_score_rules where type = 2 and scale > 10; | |||
| --集团版手动处理,(集团版不存在这类数据,子集团生日倍率数据与原集团规则相等) | |||
| --目前集团版(1008-1020-----1028)(1026-1027-----1025) | |||
| @@ -0,0 +1,12 @@ | |||
| --type=2 积分规则,追加签到规则 | |||
| update wx_score_rules set rules = JSON_ARRAY_APPEND(rules, '$',CAST('{"id": 17, "desc": "每日签到", "step": 1, "limit": 1, "score": 0}' AS JSON)) | |||
| where type = 2; | |||
| update wx_score_rules set rules = JSON_ARRAY_APPEND(rules, '$',CAST('{"id": 18, "desc": "连续签到7天奖励", "step": 1, "limit": 1, "score": 0}' AS JSON)) | |||
| where type = 2; | |||
| update wx_score_rules set rules = JSON_ARRAY_APPEND(rules, '$',CAST('{"id": 19, "desc": "连续签到14天奖励", "step": 1, "limit": 1, "score": 0}' AS JSON)) | |||
| where type = 2; | |||
| update wx_score_rules set rules = JSON_ARRAY_APPEND(rules, '$',CAST('{"id": 20, "desc": "连续签到28天奖励", "step": 1, "limit": 1, "score": 0}' AS JSON)) | |||
| where type = 2; | |||
| --type=2 积分规则,每日登陆去掉-- 缓存--缓存--缓存 | |||
| update wx_score_rules set rules = JSON_REMOVE(rules, "$[0]") where type = 2; | |||
| @@ -0,0 +1,43 @@ | |||
| CREATE TABLE `wx_merchant_ocr_model` ( | |||
| `id` bigint(20) NOT NULL, | |||
| `merchant_id` bigint(20) NOT NULL COMMENT '商户编号', | |||
| `ocr_model_id` bigint(20) NOT NULL COMMENT 'ocr模板编号', | |||
| `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | |||
| `tenant_id` varchar(5) DEFAULT NULL COMMENT '租户id', | |||
| `parent_tenant_id` varchar(5) DEFAULT NULL, | |||
| `update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP, | |||
| PRIMARY KEY (`id`), | |||
| UNIQUE KEY `UNIQUE` (`merchant_id`) | |||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | |||
| CREATE TABLE `wx_ocr_model` ( | |||
| `id` bigint(20) NOT NULL, | |||
| `lang_code` varchar(20) NOT NULL DEFAULT 'iformallLang' COMMENT '语言定义', | |||
| `font_name` varchar(20) NOT NULL COMMENT '字库名称', | |||
| `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, | |||
| `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, | |||
| `remark` text COMMENT '说明', | |||
| `status` tinyint(1) DEFAULT '0' COMMENT '0-有效 1-无效', | |||
| PRIMARY KEY (`id`), | |||
| UNIQUE KEY `UNIQUE` (`font_name`) | |||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | |||
| CREATE TABLE `wx_mall_ocr_model` ( | |||
| `id` bigint(20) NOT NULL, | |||
| `mall_id` bigint(20) NOT NULL COMMENT '商户编号', | |||
| `ocr_model_id` bigint(20) NOT NULL COMMENT 'ocr模板编号', | |||
| `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | |||
| `tenant_id` varchar(5) DEFAULT NULL COMMENT '租户id', | |||
| `parent_tenant_id` varchar(5) DEFAULT NULL, | |||
| `update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP, | |||
| PRIMARY KEY (`id`), | |||
| UNIQUE KEY `UNIQUE` (`mall_id`) | |||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; | |||
| ALTER TABLE `wx_wiwide_info` ADD COLUMN `user_name` VARCHAR(100) COMMENT '登陆账号,首次初始化wiwideId和key用'; | |||
| ALTER TABLE `wx_wiwide_info` ADD COLUMN `password` VARCHAR(100) COMMENT '登陆密码'; | |||
| ALTER TABLE `wx_wiwide_info` ADD COLUMN `old_plat` int(1) NOT NULL DEFAULT 0 COMMENT '是否是老平台 0-老平台 1-新平台'; | |||
| ALTER TABLE `wx_wiwide_info` ADD COLUMN `sign_key` VARCHAR(100) COMMENT '加密key,新版本接口需要' AFTER `wiwide_key`; | |||
| @@ -0,0 +1,28 @@ | |||
| update wx_miniapp_theme_deploy set default_icon = "https://formall.oss-accelerate.aliyuncs.com/cimg/new_kanjia.png" where id = 4444; | |||
| update wx_miniapp_theme_deploy set default_icon = "https://formall.oss-accelerate.aliyuncs.com/cimg/new_pintuan.png" where id = 4455; | |||
| update wx_miniapp_theme_deploy set default_icon = "https://formall.oss-accelerate.aliyuncs.com/cimg/zhibo.png" where id = 4466; | |||
| update wx_miniapp_theme_deploy set default_icon = "https://formall.oss-accelerate.aliyuncs.com/cimg/new_xiaofeika.png" where id = 4477; | |||
| update wx_miniapp_theme_deploy set default_icon = "https://formall.oss-accelerate.aliyuncs.com/cimg/jifen.png" where id = 4488; | |||
| INSERT INTO `wx_miniapp_theme_deploy`(`id`, `name`, `remarks`, `theme_type`, `default_icon`, `default_style`) VALUES (4499, "sy_qd", "首页签到图标", 2, "https://formall.oss-accelerate.aliyuncs.com/cimg/qiandao.png", NULL); | |||
| INSERT INTO `wx_miniapp_theme_deploy`(`id`, `name`, `remarks`, `theme_type`, `default_icon`, `default_style`) VALUES (5500, "sy_hd", "首页活动图标", 2, "https://formall.oss-accelerate.aliyuncs.com/cimg/huodong.png", NULL); | |||
| INSERT INTO `wx_miniapp_theme_deploy`(`id`, `name`, `remarks`, `theme_type`, `default_icon`, `default_style`) VALUES (5511, "sy_yx", "首页游戏图标", 2, "https://formall.oss-accelerate.aliyuncs.com/cimg/youxi.png", NULL); | |||
| INSERT INTO `wx_miniapp_theme_value`(`id`, `miniapp_theme_id`, `miniapp_deploy_id`, `icon`, `style_class`) VALUES (1010, 2, 4499, NULL, NULL); | |||
| INSERT INTO `wx_miniapp_theme_value`(`id`, `miniapp_theme_id`, `miniapp_deploy_id`, `icon`, `style_class`) VALUES (1020, 2, 5500, NULL, NULL); | |||
| INSERT INTO `wx_miniapp_theme_value`(`id`, `miniapp_theme_id`, `miniapp_deploy_id`, `icon`, `style_class`) VALUES (1030, 2, 5511, NULL, NULL); | |||
| INSERT INTO `wx_miniapp_theme_value`(`id`, `miniapp_theme_id`, `miniapp_deploy_id`, `icon`, `style_class`) VALUES (3010, 3, 4499, NULL, NULL); | |||
| INSERT INTO `wx_miniapp_theme_value`(`id`, `miniapp_theme_id`, `miniapp_deploy_id`, `icon`, `style_class`) VALUES (3020, 3, 5500, NULL, NULL); | |||
| INSERT INTO `wx_miniapp_theme_value`(`id`, `miniapp_theme_id`, `miniapp_deploy_id`, `icon`, `style_class`) VALUES (3030, 3, 5511, NULL, NULL); | |||
| update wx_miniapp_theme_value set icon = "https://formall.oss-accelerate.aliyuncs.com/cimg/new_kanjia_red.png" where miniapp_theme_id = 3 and miniapp_deploy_id = 4444; | |||
| update wx_miniapp_theme_value set icon = "https://formall.oss-accelerate.aliyuncs.com/cimg/new_pintuan_red.png" where miniapp_theme_id = 3 and miniapp_deploy_id = 4455; | |||
| update wx_miniapp_theme_value set icon = "https://formall.oss-accelerate.aliyuncs.com/cimg/zhibo_red.png" where miniapp_theme_id = 3 and miniapp_deploy_id = 4466; | |||
| update wx_miniapp_theme_value set icon = "https://formall.oss-accelerate.aliyuncs.com/cimg/new_xiaofeika_red.png" where miniapp_theme_id = 3 and miniapp_deploy_id = 4477; | |||
| update wx_miniapp_theme_value set icon = "https://formall.oss-accelerate.aliyuncs.com/cimg/jifen_red.png" where miniapp_theme_id = 3 and miniapp_deploy_id = 4488; | |||
| update wx_miniapp_theme_value set icon = "https://formall.oss-accelerate.aliyuncs.com/cimg/qiandao_red.png" where miniapp_theme_id = 3 and miniapp_deploy_id = 4499; | |||
| update wx_miniapp_theme_value set icon = "https://formall.oss-accelerate.aliyuncs.com/cimg/huodong_red.png" where miniapp_theme_id = 3 and miniapp_deploy_id = 5500; | |||
| update wx_miniapp_theme_value set icon = "https://formall.oss-accelerate.aliyuncs.com/cimg/youxi_red.png" where miniapp_theme_id = 3 and miniapp_deploy_id = 5511; | |||
| @@ -0,0 +1,13 @@ | |||
| ALTER TABLE `wx_activity` | |||
| ADD COLUMN `activity_type` smallint(2) NOT NULL DEFAULT 1 COMMENT '活动类型(是否需要报名1是0否)' AFTER `html`, | |||
| ADD COLUMN `signup_examine` smallint(2) NOT NULL DEFAULT 1 COMMENT '报名审核 1是0否(activity_type=1时必填)' AFTER `person_limit`, | |||
| MODIFY COLUMN `person_limit` int(11) COMMENT '报名人数(activity_type=1时必填)' AFTER `activity_type`, | |||
| MODIFY COLUMN `start_time` datetime(0) COMMENT '活动报名开始时间(activity_type=1时必填)' AFTER `status`, | |||
| MODIFY COLUMN `end_time` datetime(0) COMMENT '活动报名结束时间(activity_type=1时必填)' AFTER `start_time`, | |||
| MODIFY COLUMN `question` json COMMENT '问题' AFTER `end_time`; | |||
| ALTER TABLE `wx_activity_join` | |||
| ADD UNIQUE INDEX `user_activity_id`(`tenant_id`, `user_id`, `activity_id`) USING BTREE; | |||
| @@ -279,7 +279,7 @@ public class WxCUserController extends BaseController { | |||
| wxCreditHistory.setChangePurpose("商户端["+wxMerchant.getName()+"]操作完善个人信息"); | |||
| wxCreditHistory.setOperatorType(EnumUserType.BUSER.getCode()); | |||
| wxCreditHistory.setOperatorId(bUser.getId()); | |||
| wxCreditHistoryService.saveOrUpdate(wxCreditHistory); | |||
| wxCreditHistoryService.saveOrUpdate(wxCreditHistory,wxMerchant.getTenantId()); | |||
| } | |||
| @@ -71,7 +71,7 @@ public class WxCreditHistoryController extends BaseController { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL) ; | |||
| } | |||
| try { | |||
| Map<String, Integer> result = wxCreditHistoryService.findByMerchantIdAndSpend(merchantId, spendStr, userId, getTenantInfo().getFinalTenantId()); | |||
| Map<String, Integer> result = wxCreditHistoryService.findByMerchantIdAndSpend(merchantId, spendStr, userId); | |||
| return new ResultData(result); | |||
| } catch (MallinkException e) { | |||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||
| @@ -132,7 +132,7 @@ public class WxCreditHistoryController extends BaseController { | |||
| if (null != getLoginBUser().getBuserId()) { | |||
| wxCreditHistory.setBuserId(getLoginBUser().getBuserId()); | |||
| } | |||
| WxCreditHistory credit = wxCreditHistoryService.saveOrUpdate(wxCreditHistory); | |||
| WxCreditHistory credit = wxCreditHistoryService.saveOrUpdate(wxCreditHistory,tenantInfo.getTenantId()); | |||
| //更新标签 | |||
| if (wxCreditHistory.getTags() != null && !wxCreditHistory.getTags().isEmpty()) { | |||
| wxCUserTagsService.updateTagByUserId(wxCreditHistory.getCUserId(),tenantInfo, wxCreditHistory.getTags()); | |||
| @@ -36,6 +36,7 @@ public class TenantInfoImpl implements TenantInfo { | |||
| "wx_level_config", | |||
| "wx_c_user_basic_info", | |||
| "wx_c_user_basic_child", | |||
| "wx_c_user_basic_sign", | |||
| "wx_credit_history", | |||
| "wx_score_history", | |||
| "wx_c_user_tags", | |||
| @@ -50,6 +51,7 @@ public class TenantInfoImpl implements TenantInfo { | |||
| "wx_c_user", | |||
| "wx_c_user_basic_info", | |||
| "wx_c_user_basic_child", | |||
| "wx_c_user_basic_sign", | |||
| "wx_c_user_car", | |||
| "wx_c_user_from_b", | |||
| "wx_c_user_tags", | |||
| @@ -155,8 +155,8 @@ wechat: | |||
| min-idle: 10 | |||
| fm: | |||
| exception: false | |||
| exception_emails: houtaikaifa@iformall.com | |||
| exception: true | |||
| exception_emails: xuxiaohu@iformall.com | |||
| deploy: 1 | |||
| open: true | |||
| upload_dir: /home/test/server/uploads | |||
| @@ -16,6 +16,17 @@ | |||
| <groupId>com.iformall</groupId> | |||
| <artifactId>mallinkService</artifactId> | |||
| <version>1.0</version> | |||
| </dependency> <!-- ocr --> | |||
| <dependency> | |||
| <groupId>com.iformall</groupId> | |||
| <artifactId>mallinkOcr</artifactId> | |||
| <version>1.0</version> | |||
| </dependency> | |||
| <!-- ocr --> | |||
| <dependency> | |||
| <groupId>com.iformall</groupId> | |||
| <artifactId>mallinkOcr</artifactId> | |||
| <version>1.0</version> | |||
| </dependency> | |||
| </dependencies> | |||
| <build> | |||
| @@ -32,6 +32,9 @@ public class CApplication { | |||
| @Value("${fm.upload_dir}") | |||
| private String uploadDir; | |||
| @Value("${fm.ocr_data}") | |||
| private String ocrData; | |||
| @Bean | |||
| public boolean isFmException() { | |||
| @@ -52,6 +55,11 @@ public class CApplication { | |||
| public String fmUploadDir() { | |||
| return uploadDir; | |||
| } | |||
| @Bean | |||
| public String ocrData() { | |||
| return ocrData; | |||
| } | |||
| public static void main(String[] args) { | |||
| @@ -64,7 +64,7 @@ public class BaseController { | |||
| @Autowired | |||
| @Qualifier("objectCommonRedisTemplate") | |||
| RedisTemplate<String, Object> cuserBasicInfoTemplate; | |||
| RedisTemplate<String, Object> objectCommonRedisTemplate; | |||
| @InitBinder | |||
| public void InitBinder(WebDataBinder dataBinder) { | |||
| @@ -156,7 +156,7 @@ public class BaseController { | |||
| private WxCUserBasicInfo getCacheMember(Long memberId,String finalTenantId,String key,long seconds) throws Exception { | |||
| // 缓存 | |||
| WxCUserBasicInfo member = RedisCacheUtils.getCacheObject(cuserBasicInfoTemplate, key, WxCUserBasicInfo.class); | |||
| WxCUserBasicInfo member = RedisCacheUtils.getCacheObject(objectCommonRedisTemplate, key, WxCUserBasicInfo.class); | |||
| if(null == member) { | |||
| member = wxCUserBasicInfoService.getById(memberId,finalTenantId); | |||
| if (member == null) { | |||
| @@ -164,7 +164,7 @@ public class BaseController { | |||
| } | |||
| setCUserBasicChild(member); | |||
| RedisCacheUtils.cache(cuserBasicInfoTemplate, key, member, seconds); | |||
| RedisCacheUtils.cache(objectCommonRedisTemplate, key, member, seconds); | |||
| } | |||
| return member; | |||
| } | |||
| @@ -183,9 +183,9 @@ public class BaseController { | |||
| public void removeCacheMember(Long memberId) { | |||
| String key = "webapp:member:"+memberId; | |||
| RedisCacheUtils.removeCache(cuserBasicInfoTemplate, key); | |||
| RedisCacheUtils.removeCache(objectCommonRedisTemplate, key); | |||
| String shortKey = "webapp:short:member:"+memberId; | |||
| RedisCacheUtils.removeCache(cuserBasicInfoTemplate, shortKey); | |||
| RedisCacheUtils.removeCache(objectCommonRedisTemplate, shortKey); | |||
| } | |||
| public WxAppinfo getAppInfo(String appId) { | |||
| @@ -1,20 +1,27 @@ | |||
| package com.iformall.controller; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxActivity; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.enums.EnumActivityStatus; | |||
| import com.iformall.service.WxActivityService; | |||
| import com.iformall.utils.DateUtils; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.GetMapping; | |||
| import org.springframework.web.bind.annotation.ModelAttribute; | |||
| import org.springframework.web.bind.annotation.RequestMapping; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.util.Date; | |||
| import java.util.HashMap; | |||
| import java.util.Map; | |||
| @@ -30,6 +37,38 @@ public class WxActivityController extends BaseController { | |||
| @Autowired | |||
| private WxActivityService wxActivityService; | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public ResultData list(@ModelAttribute WxActivity wxActivity, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxActivityController::list"); | |||
| if (null == wxActivity) wxActivity = new WxActivity(); | |||
| wxActivity.setStatus(EnumActivityStatus.INJECT_ONLINES.getCode()); | |||
| wxActivity.updateTenantInfo(getTenantInfo()); | |||
| wxActivity.setSortColumns(BaseEntity.SortField.ActivityStartTime_DESC,BaseEntity.SortField.Id_DESC); | |||
| final PageInfo<WxActivity> page = wxActivityService.listAsPage(wxActivity, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("") | |||
| @GetMapping("listStatus") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public ResultData listStatus(@ModelAttribute WxActivity wxActivity) { | |||
| logger.debug("[" + getIpAddr() + "] WxActivityController::list"); | |||
| if (null == wxActivity) wxActivity = new WxActivity(); | |||
| wxActivity.setStatus(EnumActivityStatus.INJECT_ONLINES.getCode()); | |||
| wxActivity.updateTenantInfo(getTenantInfo()); | |||
| wxActivity.setSortColumns(BaseEntity.SortField.ActivityStartTime_DESC,BaseEntity.SortField.Id_DESC); | |||
| if(wxActivity.getStartDate() == null || wxActivity.getEndDate() == null){ | |||
| wxActivity.setStartDate(DateUtils.getFirstDayForCurrMonth()); | |||
| wxActivity.setEndDate(DateUtils.getLastDayForMonth(new Date())); | |||
| } | |||
| return wxActivityService.getListStatus(wxActivity); | |||
| } | |||
| @ApiOperation("查询活动状态") | |||
| @GetMapping("/queryStatus") | |||
| @@ -55,10 +94,12 @@ public class WxActivityController extends BaseController { | |||
| } catch (Exception e) { | |||
| return new ResultData(Result.ERROR,e.getMessage()); | |||
| } | |||
| Integer status = wxActivityService.queryStatus(id, memberId); | |||
| Integer activityStatus = wxActivityService.queryActivityStatus(id); | |||
| Integer joinStatus = wxActivityService.queryJoinStatus(id, memberId); | |||
| Map<String, Object> data = new HashMap<>(); | |||
| data.put("activity", wxActivity); | |||
| data.put("status", status); | |||
| data.put("activityStatus", activityStatus); | |||
| data.put("joinStatus", joinStatus); | |||
| return new ResultData(Result.SUCCESS, "查询成功", data); | |||
| } | |||
| @@ -0,0 +1,189 @@ | |||
| package com.iformall.controller; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxCUserBasicSign; | |||
| import com.iformall.domain.po.WxCreditHistory; | |||
| import com.iformall.enums.EnumScoreType; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.WxCUserBasicSignService; | |||
| import com.iformall.utils.DateUtils; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.Date; | |||
| import java.util.Map; | |||
| @RestController | |||
| @RequestMapping("/api/userSign") | |||
| @Api(description = "签到接口") | |||
| public class WxCUserBasicSignController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxCUserBasicSignService wxCUserBasicSignService; | |||
| @ApiOperation("用户签到列表") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name="pageNum",value="页数",dataType="int", paramType = "query",required=true), | |||
| @ApiImplicitParam(name="pageSize",value="每页条数",dataType="int", paramType = "query",required=true)}) | |||
| public ResultData list(@ModelAttribute WxCUserBasicSign wxCUserBasicSign, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxCUserBasicSignController::list"); | |||
| if (null == wxCUserBasicSign){ | |||
| wxCUserBasicSign = new WxCUserBasicSign(); | |||
| } | |||
| Long memberId; | |||
| try { | |||
| memberId = getMemberId(); | |||
| } catch (MallinkException me) { | |||
| return new ResultData(ErrorCode.getByCode(me.getErrorCode())); | |||
| } | |||
| // wxCUserBasicSign.updateTenantInfo(getTenantInfo()); | |||
| wxCUserBasicSign.setTenantId(getTenantInfo().getFinalTenantId()); | |||
| wxCUserBasicSign.setUserId(memberId); | |||
| final PageInfo<WxCUserBasicSign> page = wxCUserBasicSignService.listAsPage(wxCUserBasicSign, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("") | |||
| @GetMapping("listStatus") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public ResultData listStatus(@ModelAttribute WxCUserBasicSign wxCUserBasicSign) { | |||
| logger.debug("[" + getIpAddr() + "] WxCUserBasicSignController::listStatus"); | |||
| if (null == wxCUserBasicSign){ | |||
| wxCUserBasicSign = new WxCUserBasicSign(); | |||
| } | |||
| Long memberId; | |||
| try { | |||
| memberId = getMemberId(); | |||
| } catch (MallinkException me) { | |||
| return new ResultData(ErrorCode.getByCode(me.getErrorCode())); | |||
| } | |||
| // wxCUserBasicSign.updateTenantInfo(getTenantInfo()); | |||
| wxCUserBasicSign.setTenantId(getTenantInfo().getFinalTenantId()); | |||
| wxCUserBasicSign.setUserId(memberId); | |||
| if(wxCUserBasicSign.getStartDate() == null || wxCUserBasicSign.getEndDate() == null){ | |||
| wxCUserBasicSign.setStartDate(DateUtils.getFirstDayForCurrMonth()); | |||
| wxCUserBasicSign.setEndDate(DateUtils.getLastDayForMonth(new Date())); | |||
| } | |||
| return wxCUserBasicSignService.getListStatus(wxCUserBasicSign); | |||
| } | |||
| @ApiOperation("签到") | |||
| @PostMapping("signIn") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "", value = "", dataType = "", paramType = "", required = true)}) | |||
| public ResultData signIn(@RequestBody WxCUserBasicSign wxCUserBasicSign) { | |||
| logger.debug("[" + getIpAddr() + "] WxCUserBasicSignController::signIn"); | |||
| if (null == wxCUserBasicSign){ | |||
| wxCUserBasicSign = new WxCUserBasicSign(); | |||
| } | |||
| Long memberId; | |||
| try { | |||
| memberId = getMemberId(); | |||
| } catch (MallinkException me) { | |||
| return new ResultData(ErrorCode.getByCode(me.getErrorCode())); | |||
| } | |||
| // wxCUserBasicSign.updateTenantInfo(getTenantInfo()); | |||
| wxCUserBasicSign.setTenantId(getTenantInfo().getFinalTenantId()); | |||
| wxCUserBasicSign.setUserId(memberId); | |||
| WxCUserBasicSign todaySign = wxCUserBasicSignService.getTodaySignIn(wxCUserBasicSign); | |||
| if(todaySign == null){ | |||
| try { | |||
| todaySign = wxCUserBasicSignService.signIn(wxCUserBasicSign); | |||
| }catch(Exception e){ | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||
| } | |||
| if(todaySign == null){ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"type"); | |||
| } | |||
| return new ResultData(todaySign); | |||
| }else{ | |||
| return new ResultData(ErrorCode.MEM_IS_SIGNIN,todaySign); | |||
| } | |||
| } | |||
| @ApiOperation("签到状态") | |||
| @GetMapping("signInStatus") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "", value = "", dataType = "", paramType = "", required = true)}) | |||
| public ResultData signInStatus() { | |||
| logger.debug("[" + getIpAddr() + "] WxCUserBasicSignController::signIn"); | |||
| WxCUserBasicSign wxCUserBasicSign = new WxCUserBasicSign(); | |||
| Long memberId; | |||
| try { | |||
| memberId = getMemberId(); | |||
| } catch (MallinkException me) { | |||
| return new ResultData(ErrorCode.getByCode(me.getErrorCode())); | |||
| } | |||
| // wxCUserBasicSign.updateTenantInfo(getTenantInfo()); | |||
| wxCUserBasicSign.setTenantId(getTenantInfo().getFinalTenantId()); | |||
| wxCUserBasicSign.setUserId(memberId); | |||
| Map<String, Integer> map = wxCUserBasicSignService.getLastSignIn(wxCUserBasicSign); | |||
| return new ResultData(map); | |||
| } | |||
| @ApiOperation("签到领取") | |||
| @PostMapping("signInCredit") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "", value = "", dataType = "", paramType = "", required = true)}) | |||
| public ResultData signInCredit(@RequestBody WxCreditHistory wxCreditHistory) { | |||
| logger.debug("[" + getIpAddr() + "] WxCUserBasicSignController::signIn"); | |||
| if (null == wxCreditHistory){ | |||
| wxCreditHistory = new WxCreditHistory(); | |||
| } | |||
| Long memberId; | |||
| try { | |||
| memberId = getMemberId(); | |||
| } catch (MallinkException me) { | |||
| return new ResultData(ErrorCode.getByCode(me.getErrorCode())); | |||
| } | |||
| WxCUserBasicSign wxCUserBasicSign = new WxCUserBasicSign(); | |||
| wxCUserBasicSign.setTenantId(getFinalTenantId()); | |||
| wxCUserBasicSign.setUserId(memberId); | |||
| Map<String, Integer> map = wxCUserBasicSignService.getLastSignIn(wxCUserBasicSign); | |||
| int continueMonthSign = map.get("continueMonthSign");//本月连续签到天数 | |||
| int continueSign = map.get("continueSign");//连续签到天数 | |||
| int signInSevenDay = map.get("signInSevenDay");//7日连续奖励 | |||
| int signInFTDay = map.get("signInFTDay");//14日连续奖励 | |||
| int signInTEDay = map.get("signInTEDay");//28日连续奖励 | |||
| if(wxCreditHistory.getCreditType().equals(EnumScoreType.SIGN_IN_SEVENDAY.getCode())){ | |||
| if(continueSign >= 7 && signInSevenDay == 0){ | |||
| wxCUserBasicSignService.signInCreditHistory(wxCUserBasicSign,EnumScoreType.SIGN_IN_SEVENDAY); | |||
| return new ResultData(); | |||
| } | |||
| return new ResultData(ErrorCode.MEM_MONTH_IS_USED); | |||
| }else if(wxCreditHistory.getCreditType().equals(EnumScoreType.SIGN_IN_FTDAY.getCode())){ | |||
| if(continueSign >= 14 && signInFTDay == 0){ | |||
| wxCUserBasicSignService.signInCreditHistory(wxCUserBasicSign,EnumScoreType.SIGN_IN_FTDAY); | |||
| return new ResultData(); | |||
| } | |||
| return new ResultData(ErrorCode.MEM_MONTH_IS_USED); | |||
| }else if(wxCreditHistory.getCreditType().equals(EnumScoreType.SIGN_IN_TEDAY.getCode())){ | |||
| if(continueSign >= 28 && signInTEDay == 0){ | |||
| wxCUserBasicSignService.signInCreditHistory(wxCUserBasicSign,EnumScoreType.SIGN_IN_TEDAY); | |||
| return new ResultData(); | |||
| } | |||
| return new ResultData(ErrorCode.MEM_MONTH_IS_USED); | |||
| }else{ | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR,"creditType"); | |||
| } | |||
| } | |||
| } | |||
| @@ -4,15 +4,13 @@ import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.domain.po.WxCUser; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.domain.po.WxCreditHistory; | |||
| import com.iformall.enums.EnumScoreType; | |||
| import com.iformall.enums.EnumUserType; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.WxCreditHistoryService; | |||
| import com.iformall.service.WxScoreRulesService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| @@ -35,6 +33,9 @@ public class WxCreditHistoryController extends BaseController{ | |||
| @Autowired | |||
| private WxCreditHistoryService wxCreditHistoryService; | |||
| @Autowired | |||
| private WxScoreRulesService wxScoreRulesService; | |||
| @ApiOperation("用户积分列表") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @@ -83,7 +84,7 @@ public class WxCreditHistoryController extends BaseController{ | |||
| try { | |||
| wxCreditHistoryService.creditUsercheck(wxCreditHistory.getCUserId(),getTenantInfo()) ; | |||
| WxCreditHistory credit = wxCreditHistoryService.saveOrUpdate(wxCreditHistory); | |||
| WxCreditHistory credit = wxCreditHistoryService.saveOrUpdate(wxCreditHistory,getTenantInfo().getTenantId()); | |||
| removeCacheCUser(); | |||
| return new ResultData(Result.SUCCESS, "操作成功", credit); | |||
| } catch (MallinkException e) { | |||
| @@ -92,4 +93,12 @@ public class WxCreditHistoryController extends BaseController{ | |||
| } | |||
| } | |||
| @ApiOperation("积分配置") | |||
| @GetMapping("/credit_rules") | |||
| public ResultData creditRulesList() { | |||
| logger.debug("[" + getIpAddr() + "] creditRulesList::list"); | |||
| WxScoreRules scoreRules = wxScoreRulesService.getCreditRules(getTenantInfo().getFinalTenantId()); | |||
| return new ResultData(scoreRules); | |||
| } | |||
| } | |||
| @@ -1,18 +1,14 @@ | |||
| package com.iformall.controller; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.RedisCache; | |||
| import com.iformall.annotation.TenantIgnore; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxMiniappTheme; | |||
| import com.iformall.domain.po.WxMiniappThemeValue; | |||
| import com.iformall.domain.po.WxThemeMall; | |||
| import com.iformall.enums.EnumThemeType; | |||
| import com.iformall.service.WxMiniappThemeService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| @@ -0,0 +1,82 @@ | |||
| package com.iformall.controller; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxMall; | |||
| import com.iformall.domain.po.WxMallOcrModel; | |||
| import com.iformall.domain.po.WxMerchantOcrModel; | |||
| import com.iformall.domain.po.WxOcrModel; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.ocr.FormallTess4j; | |||
| import com.iformall.service.WxMallService; | |||
| import com.iformall.service.WxOcrService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.GetMapping; | |||
| import org.springframework.web.bind.annotation.RequestMapping; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| @RestController | |||
| @RequestMapping("/api/wxOcr") | |||
| @Api(description = "ocr") | |||
| public class WxOcrController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxOcrService ocrService; | |||
| @Autowired | |||
| private WxMallService mallService; | |||
| @Autowired | |||
| private String ocrData; | |||
| @ApiOperation("分析图片信息") | |||
| @GetMapping("/analyImage") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "merchantId", value = "商户编号", dataType = "Long", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "imageUrl", value = "小票图片url", dataType = "String", paramType = "query", required = true), | |||
| }) | |||
| public ResultData analyImage(Long merchantId,String imageUrl) { | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| Long modelId = null; | |||
| WxMerchantOcrModel MerchantModel = ocrService.getMerchantOcrModel(merchantId, tenantEntity.getTenantId(), tenantEntity.getParentTenantId()); | |||
| if (null == MerchantModel) { | |||
| WxMall mall = mallService.getByTenantId(tenantEntity.getTenantId()); | |||
| if (null == mall) { | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(), "当前登陆信息未查询倒Mall."); | |||
| } | |||
| WxMallOcrModel mallModel = ocrService.getMallOcrModel(mall.getId(), mall.getTenantId(), mall.getParentTenantId()); | |||
| if (null == mallModel) { | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(), "当前商户没有配置OCR模板,并且当前Mall也未配置OCR模板."); | |||
| }else { | |||
| modelId = mallModel.getOcrModelId(); | |||
| } | |||
| }else { | |||
| modelId = MerchantModel.getOcrModelId(); | |||
| } | |||
| WxOcrModel ocrModel = ocrService.getOcrModelById(modelId); | |||
| if (null == ocrModel) { | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(), "OCR模板未查询到:"+modelId); | |||
| } | |||
| String result; | |||
| try { | |||
| result = FormallTess4j.ocrNetImgFile(ocrData,imageUrl,ocrModel.getFontName()); | |||
| return new ResultData(result); | |||
| } catch (Exception e) { | |||
| logger.error("ocr识别失败。",e); | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR.getCode(), "ocr识别失败。"+e.getMessage()); | |||
| } | |||
| } | |||
| } | |||
| @@ -21,6 +21,7 @@ import com.iformall.service.*; | |||
| import com.iformall.service.wechat.FmOpenService; | |||
| import com.iformall.utils.Constant; | |||
| import com.iformall.utils.IPUtil; | |||
| import com.iformall.utils.RedisCacheUtils; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import me.chanjar.weixin.common.error.WxErrorException; | |||
| @@ -92,6 +93,9 @@ public class WxUserGrantController extends BaseController { | |||
| @Autowired | |||
| WxMallService mallService; | |||
| @Autowired | |||
| private QrCodeService qrCodeService; | |||
| @Autowired | |||
| private CUserTokenService cUserTokenService; | |||
| @@ -142,13 +146,43 @@ public class WxUserGrantController extends BaseController { | |||
| Map resultMap = new HashMap(); | |||
| WxCUserFrom wxCUserFrom = new WxCUserFrom(); | |||
| String appId = map.get("appId"); | |||
| String code = map.get("code"); | |||
| String sceneAddress = map.get("sceneAddress"); | |||
| String scene = map.get("scene"); | |||
| if (StringUtils.isNotBlank(scene) && | |||
| !scene.equals(Constant.UNDEFINED)) { // from pages/index/index onLoad.options.scene | |||
| wxCUserFrom.setScene(scene); | |||
| } | |||
| if (StringUtils.isNotBlank(sceneAddress) && | |||
| !sceneAddress.equalsIgnoreCase(Constant.UNDEFINED)) { // from app.js onLaunch.options.scene | |||
| wxCUserFrom.setSceneAddress(sceneAddress); | |||
| } | |||
| String longitude = map.get("longitude"); | |||
| String latitude = map.get("latitude"); | |||
| String systemInfo = map.get("systemInfo"); | |||
| try { | |||
| String basicUserId = map.get("UId"); | |||
| String merchantId = map.get("MId"); | |||
| if(StringUtils.isNotBlank(basicUserId)){ | |||
| wxCUserFrom.setFromType(EnumCUserFrom.FROM_C_USER_BASIC_INFO.getCode()); | |||
| wxCUserFrom.setFromId(Long.parseLong(basicUserId)); | |||
| }else if(StringUtils.isNotBlank(merchantId)){ | |||
| wxCUserFrom.setFromType(EnumCUserFrom.FROM_MERCHANT.getCode()); | |||
| wxCUserFrom.setFromId(Long.parseLong(merchantId)); | |||
| }else{ | |||
| } | |||
| } catch (NumberFormatException e) { | |||
| logger.error("分享参数错误",e); | |||
| } | |||
| //登录凭证不能为空 | |||
| if (StringUtils.isBlank(appId)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "appId不能为空"); | |||
| @@ -183,6 +217,7 @@ public class WxUserGrantController extends BaseController { | |||
| if(wxMall == null){ | |||
| return new ResultData(ErrorCode.MALL_INFO_NOT_FOUND); | |||
| } | |||
| wxCUserFrom.updateTenantInfo(wxMall); | |||
| resultMap.put("selectedMall", wxMall.getTenantId()); | |||
| // 集团版,获取子集团list | |||
| @@ -268,17 +303,11 @@ public class WxUserGrantController extends BaseController { | |||
| oldUser.setAppId(appId); | |||
| oldUser.setOpenId(openId); | |||
| oldUser.setUnionId(unionId); | |||
| if (StringUtils.isNotBlank(wxAuthorizerInfo.getOpenAppid())) { | |||
| oldUser.setOpenAppId(wxAuthorizerInfo.getOpenAppid()); | |||
| } | |||
| if (StringUtils.isBlank(oldUser.getSceneAddress()) || | |||
| oldUser.getSceneAddress().equalsIgnoreCase(Constant.UNDEFINED)) { // from app.js onLaunch.options.scene | |||
| oldUser.setSceneAddress(sceneAddress); | |||
| } | |||
| if (StringUtils.isBlank(oldUser.getScene()) || | |||
| oldUser.getScene().equals(Constant.UNDEFINED)) { // from pages/index/index onLoad.options.scene | |||
| oldUser.setScene(scene); | |||
| } | |||
| if (StringUtils.isNotBlank(longitude)) { | |||
| oldUser.setLongitude(BigDecimal.valueOf(Double.valueOf(longitude))); | |||
| } | |||
| @@ -298,8 +327,11 @@ public class WxUserGrantController extends BaseController { | |||
| request.setAttribute(Constant.LOGIN_USER_KEY, oldUser.getId()); | |||
| updateCacheCUser(token, oldUser); | |||
| // 登录后处理 | |||
| wxCUserService.actionMsgAfterLogin(oldUser); | |||
| wxCUserFrom.setCUserId(oldUser.getId()); | |||
| wxCUserFrom.setIsNewUser(EnumYesOrNo.NO.getCode()); | |||
| wxCUserService.actionMsgAfterLogin(wxCUserFrom); | |||
| } else { | |||
| // 新用户 | |||
| @@ -311,14 +343,9 @@ public class WxUserGrantController extends BaseController { | |||
| resultMap.put("token", token); | |||
| newUser.setRegisterIp(ipaddress); | |||
| if (StringUtils.isNotBlank(sceneAddress) && | |||
| !sceneAddress.equalsIgnoreCase(Constant.UNDEFINED)) { // from app.js onLaunch.options.scene | |||
| newUser.setSceneAddress(sceneAddress); | |||
| } | |||
| if (StringUtils.isNotBlank(scene) && | |||
| !scene.equals(Constant.UNDEFINED)) { // from pages/index/index onLoad.options.scene | |||
| newUser.setScene(scene); | |||
| } | |||
| newUser.setSceneAddress(wxCUserFrom.getSceneAddress()); | |||
| newUser.setScene(wxCUserFrom.getScene()); | |||
| newUser.setSessionKey(session_key); | |||
| if (StringUtils.isNotBlank(longitude)) { | |||
| newUser.setLongitude(BigDecimal.valueOf(Double.valueOf(longitude))); | |||
| @@ -339,7 +366,9 @@ public class WxUserGrantController extends BaseController { | |||
| updateCacheCUser(token, newUser); | |||
| // 登录后处理 | |||
| wxCUserService.actionMsgAfterLogin(newUser); | |||
| wxCUserFrom.setCUserId(newUser.getId()); | |||
| wxCUserFrom.setIsNewUser(EnumYesOrNo.YES.getCode()); | |||
| wxCUserService.actionMsgAfterLogin(wxCUserFrom); | |||
| } | |||
| @@ -580,6 +609,7 @@ public class WxUserGrantController extends BaseController { | |||
| try { | |||
| // 解密 | |||
| WxMaPhoneNumberInfo phoneNoInfo = wxMaService.getUserService().getPhoneNoInfo(session_key, encryptedData, iv); | |||
| logger.info(phoneNoInfo.toString()); | |||
| if (null != phoneNoInfo) { | |||
| logger.debug(phoneNoInfo.toString()); | |||
| user.setPhone(phoneNoInfo.getPhoneNumber()); | |||
| @@ -897,7 +927,7 @@ public class WxUserGrantController extends BaseController { | |||
| wxCreditHistory.setChangePurpose(EnumScoreType.COMPLETE_INFO.getMessage()); | |||
| wxCreditHistory.setOperatorType(EnumUserType.CUSERBASIC.getCode()); | |||
| wxCreditHistory.setOperatorId(memberId); | |||
| wxCreditHistoryService.saveOrUpdate(wxCreditHistory); | |||
| wxCreditHistoryService.saveOrUpdate(wxCreditHistory,tenantEntity.getTenantId()); | |||
| wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_IMPORT, record,tenantEntity); | |||
| removeCacheCUser(); | |||
| @@ -952,4 +982,50 @@ public class WxUserGrantController extends BaseController { | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("获取当前用户二维码") | |||
| @GetMapping("/userinfoQrCode") | |||
| public ResultData getUserinfoQrCode() { | |||
| WxCUser user = getWxCUser(); | |||
| if(user.basicInfoIs()){ | |||
| String key = Constant.cuserQr+ getTenantInfo().getTenantId() + ":" +user.getUserId(); | |||
| String qrCode = RedisCacheUtils.getCacheString(objectCommonRedisTemplate, key); | |||
| if(StringUtils.isBlank(qrCode)){ | |||
| WxCUserBasicInfo wxCUserBasicInfo; | |||
| try { | |||
| wxCUserBasicInfo = getShortCacheMember(user.getUserId(),getFinalTenantId()); | |||
| if(StringUtils.isBlank(getTenantInfo().getParentTenantId()) | |||
| && StringUtils.isNotBlank(wxCUserBasicInfo.getQrCode())){ | |||
| qrCode = wxCUserBasicInfo.getQrCode(); | |||
| }else{ | |||
| String param = wxCUserBasicInfo.getWeappScene(); | |||
| ResultData resultData = qrCodeService.uploadQrcode(getTenantInfo(), 1, Constant.mainPageUrl, param, 0, "", "", "用户分享",EnumPayWay.PAY_WAY_WECHAT); | |||
| // String weappPath = wxCUserBasicInfo.getWeappPath(); | |||
| // ResultData resultData = qrCodeService.uploadQrcode(getTenantInfo(), 0, weappPath, "", 0, "", "", "用户分享",EnumPayWay.PAY_WAY_WECHAT); | |||
| Map<String, String> map = (Map) resultData.data; | |||
| if(map!=null && map.get("url") !=null) { | |||
| String url = map.get("url"); | |||
| qrCode = url; | |||
| }else{ | |||
| logger.error("getUserinfoQrCode error."+resultData.toString()); | |||
| return new ResultData(ErrorCode.DEVICE_QRCODE_GET_FAILED); | |||
| } | |||
| if(StringUtils.isBlank(getTenantInfo().getParentTenantId())){ | |||
| wxCUserBasicInfo.setQrCode(qrCode); | |||
| wxCUserBasicInfoService.updateQrCode(wxCUserBasicInfo); | |||
| } | |||
| } | |||
| RedisCacheUtils.cache(objectCommonRedisTemplate, key, qrCode, 0); | |||
| } catch (Exception e) { | |||
| logger.error("getUserinfoQrCode error.",e); | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||
| } | |||
| } | |||
| return new ResultData(qrCode); | |||
| }else{ | |||
| return new ResultData(ErrorCode.USER_IS_NOT_MEMBER); | |||
| } | |||
| } | |||
| } | |||
| @@ -36,6 +36,7 @@ public class TenantInfoImpl implements TenantInfo { | |||
| "wx_level_config", | |||
| "wx_c_user_basic_info", | |||
| "wx_c_user_basic_child", | |||
| "wx_c_user_basic_sign", | |||
| "wx_credit_history", | |||
| "wx_score_history", | |||
| "wx_c_user_tags", | |||
| @@ -50,6 +51,7 @@ public class TenantInfoImpl implements TenantInfo { | |||
| "wx_c_user", | |||
| "wx_c_user_basic_info", | |||
| "wx_c_user_basic_child", | |||
| "wx_c_user_basic_sign", | |||
| "wx_c_user_car", | |||
| "wx_c_user_from_b", | |||
| "wx_c_user_tags", | |||
| @@ -155,11 +155,12 @@ jasypt: | |||
| password: oRqdnDbK5pj3eMmB | |||
| fm: | |||
| exception: false | |||
| exception_emails: houtaikaifa@iformall.com | |||
| exception: true | |||
| exception_emails: xuxiaohu@iformall.com | |||
| deploy: 1 | |||
| open: true | |||
| upload_dir: /home/test/server/uploads/ | |||
| ocr_data: /root/ocr_data/ | |||
| logging: | |||
| level: | |||
| @@ -115,6 +115,7 @@ fm: | |||
| deploy: 3 | |||
| open: true | |||
| upload_dir: /root/uploads/ | |||
| ocr_data: /root/ocr_data/ | |||
| logging: | |||
| level: | |||
| @@ -93,6 +93,7 @@ fm: | |||
| deploy: 2 | |||
| open: true | |||
| upload_dir: /home/ec2-user/server/uploads/ | |||
| ocr_data: /home/ec2-user/server/ocr_data/ | |||
| logging: | |||
| level: | |||
| @@ -161,8 +161,8 @@ jasypt: | |||
| password: oRqdnDbK5pj3eMmB | |||
| fm: | |||
| exception: false | |||
| exception_emails: houtaikaifa@iformall.com | |||
| exception: true | |||
| exception_emails: xuxiaohu@iformall.com | |||
| deploy: 1 | |||
| open: true | |||
| upload_dir: /home/test/server/uploads/ | |||
| @@ -156,8 +156,8 @@ jasypt: | |||
| password: oRqdnDbK5pj3eMmB | |||
| fm: | |||
| exception: false | |||
| exception_emails: houtaikaifa@iformall.com | |||
| exception: true | |||
| exception_emails: xuxiaohu@iformall.com | |||
| deploy: 1 | |||
| open: true | |||
| upload_dir: /home/test/server/uploads/ | |||
| @@ -0,0 +1,41 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | |||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||
| <parent> | |||
| <artifactId>mallink</artifactId> | |||
| <groupId>com.iformall</groupId> | |||
| <version>1.0</version> | |||
| </parent> | |||
| <modelVersion>4.0.0</modelVersion> | |||
| <artifactId>mallinkOcr</artifactId> | |||
| <dependencies> | |||
| <dependency> | |||
| <groupId>net.java.dev.jna</groupId> | |||
| <artifactId>jna</artifactId> | |||
| <version>5.3.1</version> | |||
| </dependency> | |||
| <dependency> | |||
| <groupId>net.sourceforge.tess4j</groupId> | |||
| <artifactId>tess4j</artifactId> | |||
| <version>4.4.0</version> | |||
| <exclusions> | |||
| <exclusion> | |||
| <artifactId>commons-io</artifactId> | |||
| <groupId>commons-io</groupId> | |||
| </exclusion> | |||
| <exclusion> | |||
| <artifactId>commons-logging</artifactId> | |||
| <groupId>commons-logging</groupId> | |||
| </exclusion> | |||
| <exclusion> | |||
| <artifactId>jna</artifactId> | |||
| <groupId>net.java.dev.jna</groupId> | |||
| </exclusion> | |||
| </exclusions> | |||
| </dependency> | |||
| </dependencies> | |||
| </project> | |||
| @@ -0,0 +1,289 @@ | |||
| package com.iformall.ocr; | |||
| import java.io.File; | |||
| import java.io.FileOutputStream; | |||
| import java.io.IOException; | |||
| import java.io.InputStream; | |||
| import java.io.OutputStream; | |||
| import java.net.MalformedURLException; | |||
| import java.net.URISyntaxException; | |||
| import java.net.URL; | |||
| import java.net.URLConnection; | |||
| import com.baomidou.mybatisplus.core.toolkit.IdWorker; | |||
| import com.recognition.software.jdeskew.ImageDeskew; | |||
| import net.sourceforge.tess4j.ITessAPI.TessPageIteratorLevel; | |||
| import net.sourceforge.tess4j.ITesseract; | |||
| import net.sourceforge.tess4j.ITesseract.RenderedFormat; | |||
| import net.sourceforge.tess4j.Tesseract; | |||
| import net.sourceforge.tess4j.Word; | |||
| import net.sourceforge.tess4j.util.ImageHelper; | |||
| import net.sourceforge.tess4j.util.LoggHelper; | |||
| import net.sourceforge.tess4j.util.Utils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import javax.imageio.ImageIO; | |||
| import java.awt.*; | |||
| import java.awt.image.BufferedImage; | |||
| import java.io.File; | |||
| import java.util.ArrayList; | |||
| import java.util.Arrays; | |||
| import java.util.List; | |||
| /** | |||
| * https://www.cnblogs.com/pejsidney/p/9487881.html | |||
| * Tess4J是对Tesseract OCR API.的Java JNA 封装。使java能够通过调用Tess4J的API来使用Tesseract OCR。支持的格式:TIFF,JPEG,GIF,PNG,BMP,JPEG,and PDF | |||
| Tesseract 的github地址:https://github.com/tesseract-ocr/tesseract | |||
| Tess4J的github地址:https://github.com/nguyenq/tess4j | |||
| Tess4J API 提供的功能: | |||
| 1、直接识别支持的文件 | |||
| 2、识别图片流 | |||
| 3、识别图片的某块区域 | |||
| 4、将识别结果保存为 TEXT/ HOCR/ PDF/ UNLV/ BOX | |||
| 5、通过设置取词的等级,提取识别出来的文字 | |||
| 6、获得每一个识别区域的具体坐标范围 | |||
| 7、调整倾斜的图片 | |||
| 8、裁剪图片 | |||
| 9、调整图片分辨率 | |||
| 10、从粘贴板获得图像 | |||
| 11、克隆一个图像(目的:创建一份一模一样的图片,与原图在操作修改上,不相 互影响) | |||
| 12、图片转换为二进制、黑白图像、灰度图像 | |||
| 13、反转图片颜色 | |||
| * @author alascor | |||
| */ | |||
| public class FormallTess4j { | |||
| private static final Logger logger = LoggerFactory.getLogger(new LoggHelper().toString()); | |||
| static final double MINIMUM_DESKEW_THRESHOLD = 0.05d; | |||
| private static final String datapath = "src/main/resources"; | |||
| private static final String testResourcesLanguagePath = datapath+"/tessdata"; | |||
| private static final String tempfile = "/ocrtempfile/"; | |||
| private static ITesseract instance = new Tesseract(); | |||
| static { | |||
| instance.setDatapath(new File(datapath).getPath()); | |||
| } | |||
| private static File urlImgToFile(String fileUrl) { | |||
| InputStream ins = null; | |||
| OutputStream os = null; | |||
| try { | |||
| URL url = new URL(fileUrl); | |||
| URLConnection c = url.openConnection(); | |||
| ins = c.getInputStream(); | |||
| File folder = new File (tempfile) ; | |||
| if (!folder.exists()) { | |||
| folder.mkdirs(); | |||
| } | |||
| File f = new File(tempfile+System.currentTimeMillis()+"-"+IdWorker.get32UUID()+".jpg"); | |||
| if (f.exists()) { | |||
| f.delete(); | |||
| } | |||
| f.createNewFile(); | |||
| os = new FileOutputStream(f); | |||
| int bytesRead = 0; | |||
| byte[] buffer = new byte[8192]; | |||
| while ((bytesRead = ins.read(buffer, 0, 8192)) != -1) { | |||
| os.write(buffer, 0, bytesRead); | |||
| } | |||
| os.close(); | |||
| ins.close(); | |||
| return f; | |||
| } catch (MalformedURLException e) { | |||
| e.printStackTrace(); | |||
| } catch (IOException e) { | |||
| // TODO Auto-generated catch block | |||
| e.printStackTrace(); | |||
| }finally { | |||
| if (null != os) { | |||
| try { | |||
| os.close(); | |||
| } catch (IOException e) { | |||
| e.printStackTrace(); | |||
| } | |||
| } | |||
| if (null != ins) { | |||
| try { | |||
| ins.close(); | |||
| } catch (IOException e) { | |||
| e.printStackTrace(); | |||
| } | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| private static void deletetempFile(File file) { | |||
| if (file.exists()) { | |||
| file.delete(); | |||
| } | |||
| } | |||
| private static String ocrLocalImgFile(String languagePath,String filePath,String fontName) throws Exception { | |||
| File imageFile = new File(filePath,fontName); | |||
| String result = testDoOCR_File(languagePath,imageFile,fontName); | |||
| deletetempFile(imageFile); | |||
| return result; | |||
| } | |||
| public static String ocrNetImgFile(String languagePath,String fileUrl,String fontName) throws Exception { | |||
| File imageFile = urlImgToFile(fileUrl); | |||
| String result = testDoOCR_File(languagePath,imageFile,fontName); | |||
| deletetempFile(imageFile); | |||
| return result; | |||
| } | |||
| /** | |||
| * Test of doOCR method, of class Tesseract. | |||
| * 根据图片文件进行识别 | |||
| * @throws Exception while processing image. | |||
| */ | |||
| public static String testDoOCR_File(String languagePath,File imageFile,String fontName) throws Exception { | |||
| logger.info("doOCR on a jpg image"); | |||
| //set language | |||
| instance.setDatapath(languagePath); | |||
| instance.setLanguage(fontName); | |||
| String result = instance.doOCR(imageFile); | |||
| return result; | |||
| } | |||
| public static void main(String[] args) { | |||
| try { | |||
| System.out.println(ocrNetImgFile(testResourcesLanguagePath,"https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.my0832.com%2Fattachments%2Fbbs%2F20140424%2F201442413083356803_740_1186.jpg&refer=http%3A%2F%2Fimg.my0832.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1613903848&t=985fc4c6c7b7ee82cb98f97ab5bf1459","test1")); | |||
| } catch (Exception e) { | |||
| // TODO Auto-generated catch block | |||
| e.printStackTrace(); | |||
| } | |||
| } | |||
| // | |||
| // /** | |||
| // * Test of doOCR method, of class Tesseract. | |||
| // * 根据图片流进行识别 | |||
| // * @throws Exception while processing image. | |||
| // */ | |||
| // public void testDoOCR_BufferedImage() throws Exception { | |||
| // logger.info("doOCR on a buffered image of a PNG"); | |||
| // File imageFile = new File(this.testResourcesDataPath, "ocr.png"); | |||
| // BufferedImage bi = ImageIO.read(imageFile); | |||
| // | |||
| // //set language | |||
| // instance.setDatapath(testResourcesLanguagePath); | |||
| // instance.setLanguage("chi_sim"); | |||
| // | |||
| // String result = instance.doOCR(bi); | |||
| // logger.info(result); | |||
| // } | |||
| // | |||
| // /** | |||
| // * Test of getSegmentedRegions method, of class Tesseract. | |||
| // * 得到每一个划分区域的具体坐标 | |||
| // * @throws java.lang.Exception | |||
| // */ | |||
| // public void testGetSegmentedRegions() throws Exception { | |||
| // logger.info("getSegmentedRegions at given TessPageIteratorLevel"); | |||
| // File imageFile = new File(testResourcesDataPath, "ocr.png"); | |||
| // BufferedImage bi = ImageIO.read(imageFile); | |||
| // int level = TessPageIteratorLevel.RIL_SYMBOL; | |||
| // logger.info("PageIteratorLevel: " + Utils.getConstantName(level, TessPageIteratorLevel.class)); | |||
| // List<Rectangle> result = instance.getSegmentedRegions(bi, level); | |||
| // for (int i = 0; i < result.size(); i++) { | |||
| // Rectangle rect = result.get(i); | |||
| // logger.info(String.format("Box[%d]: x=%d, y=%d, w=%d, h=%d", i, rect.x, rect.y, rect.width, rect.height)); | |||
| // } | |||
| // | |||
| // assertTrue(result.size() > 0); | |||
| // } | |||
| // | |||
| // | |||
| // /** | |||
| // * Test of doOCR method, of class Tesseract. | |||
| // * 根据定义坐标范围进行识别 | |||
| // * @throws Exception while processing image. | |||
| // */ | |||
| // public void testDoOCR_File_Rectangle() throws Exception { | |||
| // logger.info("doOCR on a BMP image with bounding rectangle"); | |||
| // File imageFile = new File(this.testResourcesDataPath, "ocr.png"); | |||
| // //设置语言库 | |||
| // instance.setDatapath(testResourcesLanguagePath); | |||
| // instance.setLanguage("chi_sim"); | |||
| // //划定区域 | |||
| // // x,y是以左上角为原点,width和height是以xy为基础 | |||
| // Rectangle rect = new Rectangle(84, 21, 15, 13); | |||
| // String result = instance.doOCR(imageFile, rect); | |||
| // logger.info(result); | |||
| // } | |||
| // | |||
| // /** | |||
| // * Test of createDocuments method, of class Tesseract. | |||
| // * 存储结果 | |||
| // * @throws java.lang.Exception | |||
| // */ | |||
| // public void testCreateDocuments() throws Exception { | |||
| // logger.info("createDocuments for png"); | |||
| // File imageFile = new File(this.testResourcesDataPath, "ocr.png"); | |||
| // String outputbase = "target/test-classes/docrenderer-2"; | |||
| // List<RenderedFormat> formats = new ArrayList<RenderedFormat>(Arrays.asList(RenderedFormat.HOCR, RenderedFormat.TEXT)); | |||
| // | |||
| // //设置语言库 | |||
| // instance.setDatapath(testResourcesLanguagePath); | |||
| // instance.setLanguage("chi_sim"); | |||
| // | |||
| // instance.createDocuments(new String[]{imageFile.getPath()}, new String[]{outputbase}, formats); | |||
| // } | |||
| // | |||
| // /** | |||
| // * Test of getWords method, of class Tesseract. | |||
| // * 取词方法 | |||
| // * @throws java.lang.Exception | |||
| // */ | |||
| // public void testGetWords() throws Exception { | |||
| // logger.info("getWords"); | |||
| // File imageFile = new File(this.testResourcesDataPath, "ocr.png"); | |||
| // | |||
| // //设置语言库 | |||
| // instance.setDatapath(testResourcesLanguagePath); | |||
| // instance.setLanguage("chi_sim"); | |||
| // | |||
| // //按照每个字取词 | |||
| // int pageIteratorLevel = TessPageIteratorLevel.RIL_SYMBOL; | |||
| // logger.info("PageIteratorLevel: " + Utils.getConstantName(pageIteratorLevel, TessPageIteratorLevel.class)); | |||
| // BufferedImage bi = ImageIO.read(imageFile); | |||
| // List<Word> result = instance.getWords(bi, pageIteratorLevel); | |||
| // | |||
| // //print the complete result | |||
| // for (Word word : result) { | |||
| // logger.info(word.toString()); | |||
| // } | |||
| // } | |||
| // | |||
| // /** | |||
| // * Test of Invalid memory access. | |||
| // * 处理倾斜 | |||
| // * @throws Exception while processing image. | |||
| // */ | |||
| // public void testDoOCR_SkewedImage() throws Exception { | |||
| // //设置语言库 | |||
| // instance.setDatapath(testResourcesLanguagePath); | |||
| // instance.setLanguage("chi_sim"); | |||
| // | |||
| // logger.info("doOCR on a skewed PNG image"); | |||
| // File imageFile = new File(this.testResourcesDataPath, "ocr_skewed.jpg"); | |||
| // BufferedImage bi = ImageIO.read(imageFile); | |||
| // ImageDeskew id = new ImageDeskew(bi); | |||
| // double imageSkewAngle = id.getSkewAngle(); // determine skew angle | |||
| // if ((imageSkewAngle > MINIMUM_DESKEW_THRESHOLD || imageSkewAngle < -(MINIMUM_DESKEW_THRESHOLD))) { | |||
| // bi = ImageHelper.rotateImage(bi, -imageSkewAngle); // deskew image | |||
| // } | |||
| // | |||
| // String result = instance.doOCR(bi); | |||
| // logger.info(result); | |||
| // } | |||
| } | |||
| @@ -0,0 +1,135 @@ | |||
| package com.iformall.ocr; | |||
| import java.io.BufferedWriter; | |||
| import java.io.File; | |||
| import java.io.FileWriter; | |||
| import java.io.IOException; | |||
| import java.io.InputStreamReader; | |||
| import java.io.LineNumberReader; | |||
| /** | |||
| * 训练 | |||
| * @author iformall | |||
| */ | |||
| public class FormallTess4jTrain { | |||
| private static final String newFileFolder = "C:\\Users\\iformall\\Desktop\\newfile"; | |||
| private static final String huanhangstr = " \n "; | |||
| private static String getprefix(String lang,String fontName) { | |||
| String realFileName = lang+"."+fontName+".exp0"; | |||
| return realFileName; | |||
| } | |||
| private static String createBoxFile(String tifFileName,String lang,String fontName) { | |||
| String prefix = getprefix(lang,fontName); | |||
| String realFileName = prefix+".tif"; | |||
| if (tifFileName.equals(realFileName)) { | |||
| String cmdstr = "tesseract "+tifFileName+" "+prefix+" -l chi_sim batch.nochop makebox"; | |||
| return cmdstr; | |||
| //String result = executeLocalCmd(cmdstr, null); | |||
| //System.out.println("Done createBoxFile"+result); | |||
| }else { | |||
| return "文件必须是.tif"; | |||
| } | |||
| } | |||
| private static String createTranFile(String lang,String fontName) { | |||
| String prefix = getprefix(lang,fontName); | |||
| String realFileName = prefix+".tif"; | |||
| String trainCmdstr = "tesseract "+realFileName+" "+prefix+" nobatch box.train"; | |||
| return trainCmdstr; | |||
| } | |||
| private static String getBoxFont(String lang,String fontName) { | |||
| String prefix = getprefix(lang,fontName); | |||
| String extractorCmdstr = "unicharset_extractor "+prefix+".box"; | |||
| return extractorCmdstr; | |||
| } | |||
| /** | |||
| * 第六步,执行完成后生成以下几个文件加前缀 | |||
| * unicharset、inttemp、pffmtable、shapetable、normproto 添加这几个文件的前缀为fontName | |||
| * @param lang | |||
| * @param fontName | |||
| * @return | |||
| */ | |||
| private static String renameTrainFiles(String fontName) { | |||
| StringBuffer sb = new StringBuffer(); | |||
| String renCmdstr = "REN unicharset "+fontName+".unicharset"; | |||
| sb.append(renCmdstr).append(huanhangstr); | |||
| renCmdstr = "REN inttemp "+fontName+".inttemp"; | |||
| sb.append(renCmdstr).append(huanhangstr); | |||
| renCmdstr = "REN pffmtable "+fontName+".pffmtable"; | |||
| sb.append(renCmdstr).append(huanhangstr); | |||
| renCmdstr = "REN shapetable "+fontName+".shapetable"; | |||
| sb.append(renCmdstr).append(huanhangstr); | |||
| renCmdstr = "REN normproto "+fontName+".normproto"; | |||
| sb.append(renCmdstr).append(huanhangstr); | |||
| return sb.toString(); | |||
| } | |||
| /** | |||
| * 第七步:合并5个文件 | |||
| * @param lang | |||
| * @param fontName | |||
| * @return | |||
| */ | |||
| private static String mergeTrainFiles(String fontName) { | |||
| String mergeCmdstr = "combine_tessdata "+fontName+"."; | |||
| return mergeCmdstr; | |||
| } | |||
| public static String getTrainSteps(String lang,String fontName) { | |||
| StringBuffer sb = new StringBuffer("请先安装tess4j(4.0以上),配置好环境变量. 下载jTessBoxEditor(用于训练,带FX的支持中文)").append(huanhangstr); | |||
| sb.append("请进入到样本图片文件夹用doc命令执行.").append(huanhangstr); | |||
| sb.append("第一步,用jTessBoxEditor --> Tools --> Merge 多选图片,保存为tif格式 .命名格式为[lang].[fontName].exp0.tif. 命名:").append(lang).append(".").append(fontName).append(".exp0.tif ").append(huanhangstr); | |||
| sb.append("............ ").append(huanhangstr); | |||
| sb.append("第二步,用tif生成box ").append(huanhangstr); | |||
| sb.append(createBoxFile(lang+"."+fontName+".exp0.tif", lang, fontName)).append(huanhangstr); | |||
| sb.append("............ ").append(huanhangstr); | |||
| sb.append("第三步,用jTessBoxEditor 打开.box文件进行矫正 ").append(huanhangstr); | |||
| sb.append("............ ").append(huanhangstr); | |||
| sb.append("第四步:用box文件生成。tr文件 ").append(huanhangstr); | |||
| sb.append(createTranFile(lang,fontName)).append(huanhangstr); | |||
| sb.append("............ ").append(huanhangstr); | |||
| sb.append("第五步:提取box字符 ").append(huanhangstr); | |||
| sb.append(getBoxFont(lang,fontName)).append(huanhangstr); | |||
| sb.append("............ ").append(huanhangstr); | |||
| sb.append("@@@!!!!从此处开始,可以处理多个字库处理。如原来的字库现在做升级,需要把老的字库的。tif,.box,.tr文件重新命名也放到同目录文件夹, ").append(huanhangstr); | |||
| sb.append("............ ").append(huanhangstr); | |||
| sb.append("第六步:新建font_properties(没有.txt后缀), 把所有box对应的字体特征加进去。").append(huanhangstr); | |||
| sb.append("fontname为字体名称,保持和 图片集文件 .tif 和.box文件的前缀名一致 .<italic> 、<bold> 、<fixed> 、<serif>、 <fraktur>的取值为1或0,表示字体是否具有这些属性。 ").append(huanhangstr); | |||
| sb.append("如以下内容: ").append(huanhangstr); | |||
| sb.append("fontName1 0 0 0 0 0 ").append(huanhangstr); | |||
| sb.append("fontName2 0 1 0 0 0 ").append(huanhangstr); | |||
| sb.append("fontName3 1 1 0 0 0 ").append(huanhangstr); | |||
| sb.append("............ ").append(huanhangstr); | |||
| sb.append("第六步:批量执行系列命令。多个文件在后面累加。 ").append(huanhangstr); | |||
| String prefix = getprefix(lang,fontName); | |||
| String shapeCmdStr = "shapeclustering -F font_properties -U unicharset "+prefix+".tr [other .tr files...] "; | |||
| sb.append(shapeCmdStr).append(huanhangstr); | |||
| String mftraingCmdstr = "mftraining -F font_properties -U unicharset -O unicharset "+prefix+".tr [other .tr files...] "; | |||
| sb.append(mftraingCmdstr).append(huanhangstr); | |||
| String cntrainCmdstr = "cntraining "+prefix+".tr [other .tr files...] "; | |||
| sb.append(cntrainCmdstr).append(huanhangstr); | |||
| sb.append("............ ").append(huanhangstr); | |||
| sb.append("第七步,执行完成后生成以下几个文件加前缀: unicharset、inttemp、pffmtable、shapetable、normproto 添加这几个文件的前缀为[fontName] ").append(huanhangstr); | |||
| sb.append(renameTrainFiles(fontName)); | |||
| sb.append("............ ").append(huanhangstr); | |||
| sb.append("第七步:合并5个文件").append(huanhangstr); | |||
| sb.append(mergeTrainFiles(fontName)).append(huanhangstr); | |||
| sb.append("............ ").append(huanhangstr); | |||
| sb.append("第八步:将").append(fontName).append(".traineddata 文件拷贝到后端服务器ocr_data(项目配置fm.ocr_data)目录下。 .tif、。box、。tr文件也需要保留,后面如果这个字库有更新,需要用到这些文件。").append(huanhangstr); | |||
| return sb.toString(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,14 @@ | |||
| https://www.cnblogs.com/wj-1314/p/9454656.html | |||
| https://www.cnblogs.com/pejsidney/p/9487881.html | |||
| https://digi.bib.uni-mannheim.de/tesseract/ | |||
| https://blog.csdn.net/qq_40147863/article/details/82290015 | |||
| https://blog.csdn.net/boonya/article/details/81325997 | |||
| 合并字库 https://www.cnblogs.com/c2soft/articles/10415236.html | |||
| 完整教程 https://www.cnblogs.com/wpcnblog/p/12850590.html | |||
| @@ -0,0 +1 @@ | |||
| tessconfigs/pdf.ttf | |||
| @@ -1376,7 +1376,7 @@ public class PosServiceImpl implements PosService { | |||
| //如果券与商户一对一 则直接将消费商户更新为此商户 若一对多 则消费商户显示多商户 | |||
| creditHistory.setMerchantId(wxMerchant.getId()); | |||
| creditHistory.setChangePurpose("pos消费:消费商户["+wxMerchant.getName()+"] 卷名称["+coupon.getTitle()+"("+creditHistory.getSpendStr()+"元)] "); | |||
| creditHistory = creditHistoryService.saveOrUpdate(creditHistory); | |||
| creditHistory = creditHistoryService.saveOrUpdate(creditHistory,couponOrderCVo.getTenantId()); | |||
| if (creditHistory.getCreditNum() != null) { | |||
| return creditHistory.getCreditNum(); | |||
| } else { | |||
| @@ -1405,7 +1405,7 @@ public class PosServiceImpl implements PosService { | |||
| //如果券与商户一对一 则直接将消费商户更新为此商户 若一对多 则消费商户显示多商户 | |||
| creditHistory.setMerchantId(merchant.getId()); | |||
| creditHistory.setChangePurpose("pos消费:消费商户["+merchant.getName()+"] 消费金额["+creditHistory.getSpendStr()+"元]"); | |||
| creditHistory = creditHistoryService.saveOrUpdate(creditHistory); | |||
| creditHistory = creditHistoryService.saveOrUpdate(creditHistory,merchant.getTenantId()); | |||
| if (creditHistory.getCreditNum() != null) { | |||
| return creditHistory.getCreditNum(); | |||
| } else { | |||
| @@ -155,8 +155,8 @@ wechat: | |||
| min-idle: 10 | |||
| fm: | |||
| exception: false | |||
| exception_emails: houtaikaifa@iformall.com | |||
| exception: true | |||
| exception_emails: xuxiaohu@iformall.com | |||
| deploy: 1 | |||
| open: true | |||
| upload_dir: /home/test/server/uploads | |||
| @@ -0,0 +1,154 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | |||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||
| <modelVersion>4.0.0</modelVersion> | |||
| <parent> | |||
| <artifactId>mallink</artifactId> | |||
| <groupId>com.iformall</groupId> | |||
| <version>1.0</version> | |||
| </parent> | |||
| <artifactId>mallinkPublicApi</artifactId> | |||
| <dependencies> | |||
| <dependency> | |||
| <groupId>com.iformall</groupId> | |||
| <artifactId>mallinkService</artifactId> | |||
| <version>1.0</version> | |||
| </dependency> | |||
| </dependencies> | |||
| <build> | |||
| <plugins> | |||
| <plugin> | |||
| <groupId>org.springframework.boot</groupId> | |||
| <artifactId>spring-boot-maven-plugin</artifactId> | |||
| <configuration> | |||
| <executable>true</executable> | |||
| <layout>ZIP</layout> | |||
| <excludeGroupIds> | |||
| antlr, | |||
| cn.afterturn, | |||
| ch.qos.logback, | |||
| com.alibaba, | |||
| com.amazonaws, | |||
| com.baomidou, | |||
| com.mchange, | |||
| com.fasterxml.jackson.core, | |||
| com.fasterxml.jackson.dataformat, | |||
| com.fasterxml.jackson.datatype, | |||
| com.fasterxml.jackson.module, | |||
| com.fasterxml.uuid, | |||
| com.fasterxml, | |||
| com.github.axet, | |||
| com.github.jsqlparser, | |||
| com.github.pagehelper, | |||
| com.github.ulisesbocchio, | |||
| com.github.virtuald, | |||
| com.google.code.findbugs, | |||
| com.google.code.gson, | |||
| com.google.errorprone, | |||
| com.google.guava, | |||
| com.google.protobuf, | |||
| com.google.zxing, | |||
| com.jayway.jsonpath, | |||
| com.jhlabs, | |||
| com.puppycrawl.tools, | |||
| com.rabbitmq, | |||
| com.squareup.okhttp3, | |||
| com.squareup.okio, | |||
| com.sun, | |||
| com.sun.mail, | |||
| com.thoughtworks.xstream, | |||
| com.zaxxer, | |||
| commons-beanutils, | |||
| commons-cli, | |||
| commons-codec, | |||
| commons-collections, | |||
| commons-fileupload, | |||
| commons-io, | |||
| commons-logging, | |||
| io.lettuce, | |||
| io.netty, | |||
| io.projectreactor, | |||
| io.springfox, | |||
| io.swagger, | |||
| io.undertow, | |||
| javax.activation, | |||
| javax.annotation, | |||
| javax.mail, | |||
| javax.persistence, | |||
| javax.servlet, | |||
| javax.validation, | |||
| javax.xml.bind, | |||
| javax.xml.soap, | |||
| javax.xml.ws, | |||
| joda-time, | |||
| junit, | |||
| mysql, | |||
| net.bytebuddy, | |||
| net.minidev, | |||
| net.sf.dozer, | |||
| net.sf.saxon, | |||
| ognl, | |||
| org.antlr, | |||
| org.apache.commons, | |||
| org.apache.httpcomponents, | |||
| org.apache.logging.log4j, | |||
| org.apache.poi, | |||
| org.apache.poi.wso2, | |||
| org.apache.rocketmq, | |||
| org.apache.shiro, | |||
| org.apache.tomcat.embed, | |||
| org.apache.xmlbeans, | |||
| org.aspectj, | |||
| org.assertj, | |||
| org.bouncycastle, | |||
| org.checkerframework, | |||
| org.codehaus.mojo, | |||
| org.crazycake, | |||
| org.dom4j, | |||
| org.flowable, | |||
| org.flywaydb, | |||
| org.glassfish, | |||
| org.hibernate.validator, | |||
| org.jasypt, | |||
| org.javassist, | |||
| org.jboss.logging, | |||
| org.jboss.spec.javax.annotation, | |||
| org.jboss.spec.javax.websocket, | |||
| org.jboss.xnio, | |||
| org.jdom, | |||
| org.jodd, | |||
| org.jvnet.mimepull, | |||
| org.jvnet.staxex, | |||
| org.mapstruct, | |||
| org.mockito, | |||
| org.mybatis, | |||
| org.mybatis.generator, | |||
| org.mybatis.spring.boot, | |||
| org.ow2.asm, | |||
| org.projectlombok, | |||
| org.quartz-scheduler, | |||
| org.reactivestreams, | |||
| org.reflections, | |||
| org.rocketmq.spring.boot, | |||
| org.slf4j, | |||
| org.springframework, | |||
| org.springframework.amqp, | |||
| org.springframework.boot, | |||
| org.springframework.data, | |||
| org.springframework.retry, | |||
| org.springframework.ws, | |||
| org.yaml, | |||
| redis.clients, | |||
| software.amazon.ion, | |||
| tk.mybatis, | |||
| xmlpull, | |||
| xpp3 | |||
| </excludeGroupIds> | |||
| </configuration> | |||
| </plugin> | |||
| </plugins> | |||
| </build> | |||
| </project> | |||
| @@ -0,0 +1,60 @@ | |||
| package com.iformall; | |||
| import org.mybatis.spring.annotation.MapperScan; | |||
| import org.rocketmq.starter.annotation.EnableRocketMQ; | |||
| import org.springframework.beans.factory.annotation.Value; | |||
| import org.springframework.boot.SpringApplication; | |||
| import org.springframework.boot.autoconfigure.SpringBootApplication; | |||
| import org.springframework.context.annotation.Bean; | |||
| import org.springframework.context.annotation.EnableAspectJAutoProxy; | |||
| import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties; | |||
| /** | |||
| * @author chenkx | |||
| * @date 2017-12-26 | |||
| */ | |||
| @SpringBootApplication | |||
| @MapperScan(basePackages = {"com.iformall.mapper"}) | |||
| @EnableEncryptableProperties | |||
| @EnableRocketMQ | |||
| @EnableAspectJAutoProxy(exposeProxy = true) | |||
| public class PublicApiApplication { | |||
| @Value("${fm.exception}") | |||
| private boolean fmException; | |||
| @Value("${fm.exception_emails}") | |||
| private String fmExceptionEmails; | |||
| @Value("${fm.open}") | |||
| private boolean fmOpen; | |||
| @Value("${fm.upload_dir}") | |||
| private String uploadDir; | |||
| @Bean | |||
| public boolean isFmException() { | |||
| return fmException; | |||
| } | |||
| @Bean | |||
| public String fmExceptionEmails() { | |||
| return fmExceptionEmails; | |||
| } | |||
| @Bean | |||
| public boolean isFmOpen() { | |||
| return fmOpen; | |||
| } | |||
| @Bean | |||
| public String fmUploadDir() { | |||
| return uploadDir; | |||
| } | |||
| public static void main(String[] args) { | |||
| SpringApplication.run(PublicApiApplication.class, args); | |||
| } | |||
| } | |||
| @@ -0,0 +1,53 @@ | |||
| package com.iformall.annotation; | |||
| import java.lang.annotation.ElementType; | |||
| import java.lang.annotation.Retention; | |||
| import java.lang.annotation.RetentionPolicy; | |||
| import java.lang.annotation.Target; | |||
| import java.util.concurrent.TimeUnit; | |||
| /** | |||
| * - /api/wxCouponChannel/change | |||
| * - /api/user/userinfo | |||
| * - /api/wxBusiness/listAll | |||
| * - /api/wxCampaign/list | |||
| * - /api/mall/mallInfo | |||
| * - /api/mall/getAppIcon | |||
| * - /api/mall/getWeapNote | |||
| */ | |||
| @Target({ElementType.METHOD}) | |||
| @Retention(RetentionPolicy.RUNTIME) | |||
| public @interface RedisCache { | |||
| /** | |||
| * 缓存key的名称 | |||
| * @return | |||
| */ | |||
| String key() default ""; | |||
| /** | |||
| * 自动生成key | |||
| * @return | |||
| */ | |||
| boolean autoKey() default true; | |||
| /** | |||
| * 参数md5,解决key过长问题 | |||
| * @return | |||
| */ | |||
| boolean md5() default true ; | |||
| /** | |||
| * key 过期日期默认60秒 | |||
| * @return | |||
| */ | |||
| int expireTime() default 60; | |||
| /** | |||
| * 时间单位默认为秒 | |||
| * @return | |||
| */ | |||
| TimeUnit dateUnit() default TimeUnit.SECONDS; | |||
| } | |||
| @@ -0,0 +1,161 @@ | |||
| package com.iformall.aop; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.iformall.annotation.RedisCache; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.domain.po.WxCUser; | |||
| import com.iformall.domain.po.base.BaseCUserEntity; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.CUserTokenService; | |||
| import com.iformall.utils.HashUtil; | |||
| import com.iformall.utils.RedisLock; | |||
| import lombok.extern.slf4j.Slf4j; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.aspectj.lang.ProceedingJoinPoint; | |||
| import org.aspectj.lang.annotation.Around; | |||
| import org.aspectj.lang.annotation.Aspect; | |||
| import org.aspectj.lang.annotation.Pointcut; | |||
| import org.aspectj.lang.reflect.MethodSignature; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.data.redis.core.StringRedisTemplate; | |||
| import org.springframework.data.redis.core.ValueOperations; | |||
| import org.springframework.stereotype.Component; | |||
| import org.springframework.web.context.request.RequestContextHolder; | |||
| import org.springframework.web.context.request.ServletRequestAttributes; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import java.lang.reflect.Method; | |||
| import java.util.Arrays; | |||
| import java.util.Objects; | |||
| @Slf4j | |||
| @Aspect | |||
| @Component | |||
| public class RedisCacheAspect { | |||
| /** | |||
| * 参数分隔符 param1|param2|param3 | |||
| **/ | |||
| private static final String DELIMITER_PARAMS = "|"; | |||
| /** | |||
| * key 分隔符 | |||
| */ | |||
| private static final String DELIMITER_KEY = ":"; | |||
| @Autowired | |||
| private StringRedisTemplate stringRedisTemplate; | |||
| @Autowired | |||
| RedisLock redisLock; | |||
| @Autowired | |||
| private CUserTokenService cUserTokenService; | |||
| @Pointcut("@annotation(com.iformall.annotation.RedisCache)") | |||
| public void cacheAspect() { | |||
| } | |||
| @Around("cacheAspect()") | |||
| public Object round(ProceedingJoinPoint jp) throws Throwable { | |||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||
| // 查询token信息 | |||
| //从header中获取token | |||
| String token = request.getHeader("token"); | |||
| //如果header中不存在token,则从参数中获取token | |||
| if (StringUtils.isBlank(token)) { | |||
| token = request.getParameter("token"); | |||
| } | |||
| if(StringUtils.isBlank(token) || "null".equals(token) || "undefined".equals(token)){ | |||
| token=""; | |||
| //throw new MallinkException(ErrorCode.NET_TOKEN_EMPTY.getCode(),"token为空["+token+"]"); | |||
| } | |||
| log.info("token>>>>>>>>>>>>>>>"+token); | |||
| String tenantId; | |||
| BaseCUserEntity cUser = null ; | |||
| if(StringUtils.isNotBlank(token)) { | |||
| cUser = cUserTokenService.getByToken(token); | |||
| } | |||
| if (Objects.isNull(cUser) || cUser.getExpireTime().getTime() < System.currentTimeMillis()) { | |||
| tenantId = "0"; | |||
| } else { | |||
| tenantId = cUser.getTenantId(); | |||
| } | |||
| // 请求参数 | |||
| Object[] args = jp.getArgs(); | |||
| // 接口 返回结果 | |||
| Object result; | |||
| String redisKey; | |||
| //得到注释的名称 | |||
| MethodSignature signature = (MethodSignature) jp.getSignature(); | |||
| //判断tag是否在用户权限中 如果存在加入参数查询 | |||
| Method method = signature.getMethod(); | |||
| RedisCache cache = method.getAnnotation(RedisCache.class) ; | |||
| if (cache.autoKey()) { | |||
| // 构建 redisKey => reqPath:tenantId:md5(param1_param2_param3) | |||
| String requestUrl = request.getRequestURI(); | |||
| // 接口路径 reqPath => /api/xxx | |||
| String reqPath = requestUrl.substring(requestUrl.indexOf("/api/")); | |||
| if (cache.md5()) { | |||
| String md5Before = StringUtils.join(args, DELIMITER_PARAMS); | |||
| redisKey = StringUtils.join(reqPath, DELIMITER_KEY, tenantId, DELIMITER_KEY, HashUtil.md5(StringUtils.join(token, md5Before, DELIMITER_PARAMS))); | |||
| } else { | |||
| redisKey = StringUtils.join(reqPath, DELIMITER_KEY, tenantId, DELIMITER_KEY, StringUtils.join(token,args, DELIMITER_PARAMS)); | |||
| } | |||
| } else { | |||
| redisKey = cache.key(); | |||
| } | |||
| // redisKey 不存在,获取接口数据并返回 | |||
| if (StringUtils.isBlank(redisKey)) { | |||
| result = jp.proceed(args); | |||
| } else { | |||
| ValueOperations<String, String> valueOperations = stringRedisTemplate.opsForValue(); | |||
| String value = valueOperations.get(redisKey); | |||
| if (value == null) { | |||
| String lockKey = StringUtils.join(redisKey, ":", "lock"); | |||
| long time = System.currentTimeMillis() + 2000; | |||
| String timeStr = String.valueOf(time); | |||
| try { | |||
| //分布式锁,保证一个线程读DB,其它线程排队 | |||
| if (redisLock.lock2(lockKey, timeStr)) { | |||
| log.debug("CacheAspect 读库中, key:{}: " + lockKey); | |||
| result = jp.proceed(args); | |||
| String json_data = JSONObject.toJSONString(result); | |||
| valueOperations.set(redisKey, json_data, cache.expireTime(), cache.dateUnit()); | |||
| log.debug("CacheAspect 缓存不存在,获取接口数据并放入缓存,key:{}, expire:{}", redisKey, cache.expireTime()); | |||
| } else { | |||
| log.debug("CacheAspect 读库等待中, key:{}: " + lockKey); | |||
| Thread.sleep(2000); | |||
| value = valueOperations.get(redisKey); | |||
| result = parseCache(jp, redisKey, value); | |||
| } | |||
| } catch (Throwable throwable) { | |||
| log.error("CacheAspect proceed error , Illegal argument: {} in {}.{}()", Arrays.toString(jp.getArgs()), | |||
| jp.getSignature().getDeclaringTypeName(), jp.getSignature().getName(), throwable); | |||
| throw throwable; | |||
| } finally { | |||
| redisLock.unlock(lockKey, timeStr); | |||
| } | |||
| } else { | |||
| result = parseCache(jp, redisKey, value); | |||
| } | |||
| // 计数器 | |||
| stringRedisTemplate.opsForHash().increment("hotapi", redisKey, 1); | |||
| } | |||
| return result; | |||
| } | |||
| private Object parseCache(ProceedingJoinPoint jp, String redisKey, String value) { | |||
| if (StringUtils.isBlank(value)) { | |||
| log.debug("CacheAspect 缓存不存在,解析缓存数据为空:{},key:{}", value, redisKey); | |||
| return null; | |||
| } | |||
| Class<?> returnType = ((MethodSignature) jp.getSignature()).getReturnType(); | |||
| log.debug("CacheAspect 缓存存在,解析缓存并返回,key:{}", redisKey); | |||
| return JSONObject.parseObject(value, returnType); | |||
| } | |||
| } | |||
| @@ -0,0 +1,24 @@ | |||
| package com.iformall.config; | |||
| import com.iformall.plugin.MyBatisItercepters; | |||
| import com.iformall.plugin.MyBatisPlus; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| import org.springframework.context.annotation.Bean; | |||
| import org.springframework.context.annotation.Configuration; | |||
| @Configuration | |||
| public class MyBatisConfiguration extends BaseMyBatisConfiguration { | |||
| @Bean | |||
| public MyBatisItercepters intercepters() { | |||
| MyBatisItercepters intercepters = new MyBatisItercepters(); | |||
| List<MyBatisPlus> plugins = new ArrayList<MyBatisPlus>(); | |||
| plugins.add(baseShardingSpherePlugin()); | |||
| intercepters.setPlugins(plugins); | |||
| return intercepters; | |||
| } | |||
| } | |||
| @@ -0,0 +1,335 @@ | |||
| package com.iformall.config; | |||
| import com.fasterxml.jackson.annotation.JsonAutoDetect; | |||
| import com.fasterxml.jackson.annotation.PropertyAccessor; | |||
| import com.fasterxml.jackson.databind.DeserializationFeature; | |||
| import com.fasterxml.jackson.databind.ObjectMapper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.base.BaseCUserEntity; | |||
| import com.iformall.domain.vo.WxCouponCVo; | |||
| import com.iformall.domain.vo.WxCouponChannelVo; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.cache.CacheManager; | |||
| import org.springframework.cache.annotation.CachingConfigurerSupport; | |||
| import org.springframework.cache.annotation.EnableCaching; | |||
| import org.springframework.context.annotation.Bean; | |||
| import org.springframework.context.annotation.Configuration; | |||
| import org.springframework.data.redis.cache.RedisCacheConfiguration; | |||
| import org.springframework.data.redis.cache.RedisCacheManager; | |||
| import org.springframework.data.redis.cache.RedisCacheWriter; | |||
| import org.springframework.data.redis.connection.RedisConnectionFactory; | |||
| import org.springframework.data.redis.core.RedisTemplate; | |||
| import org.springframework.data.redis.core.StringRedisTemplate; | |||
| import org.springframework.data.redis.core.ValueOperations; | |||
| import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; | |||
| import org.springframework.data.redis.serializer.StringRedisSerializer; | |||
| import java.time.Duration; | |||
| import java.util.ArrayList; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| /** | |||
| * Created by Stormeye on 2018/10/1. | |||
| */ | |||
| @Configuration | |||
| @EnableCaching | |||
| public class RedisConfig extends CachingConfigurerSupport { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| //缓存管理器 | |||
| @Bean | |||
| public CacheManager cacheManager(RedisConnectionFactory connectionFactory) { | |||
| //user信息缓存配置 | |||
| RedisCacheConfiguration userCacheConfiguration = RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofSeconds(10)).disableCachingNullValues().prefixKeysWith("user"); | |||
| Map<String, RedisCacheConfiguration> redisCacheConfigurationMap = new HashMap<>(); | |||
| redisCacheConfigurationMap.put("user", userCacheConfiguration); | |||
| //初始化一个RedisCacheWriter | |||
| RedisCacheWriter redisCacheWriter = RedisCacheWriter.nonLockingRedisCacheWriter(connectionFactory); | |||
| // 设置CacheManager的值序列化方式为JdkSerializationRedisSerializer,但其实RedisCacheConfiguration默认就是使用StringRedisSerializer序列化key,JdkSerializationRedisSerializer序列化value,所以以下注释代码为默认实现 | |||
| // ClassLoader loader = this.getClass().getClassLoader(); | |||
| // JdkSerializationRedisSerializer jdkSerializer = new JdkSerializationRedisSerializer(loader); | |||
| // RedisSerializationContext.SerializationPair<Object> pair = RedisSerializationContext.SerializationPair.fromSerializer(jdkSerializer); | |||
| // RedisCacheConfiguration defaultCacheConfig = RedisCacheConfiguration.defaultCacheConfig().serializeValuesWith(pair); | |||
| RedisCacheConfiguration defaultCacheConfig = RedisCacheConfiguration.defaultCacheConfig(); | |||
| //设置默认超过期时间是30秒 | |||
| defaultCacheConfig.entryTtl(Duration.ofSeconds(30)); | |||
| //初始化RedisCacheManager | |||
| RedisCacheManager cacheManager = new RedisCacheManager(redisCacheWriter, defaultCacheConfig, redisCacheConfigurationMap); | |||
| return cacheManager; | |||
| } | |||
| @Bean("pushLimitRedisTemplate") | |||
| public RedisTemplate<String, PushLimit> getPushLimitRedisTemplate(RedisConnectionFactory connectionFactory) { | |||
| RedisTemplate<String, PushLimit> template = new RedisTemplate<String, PushLimit>(); | |||
| template.setConnectionFactory(connectionFactory); | |||
| Jackson2JsonRedisSerializer<PushLimit> j = new Jackson2JsonRedisSerializer<PushLimit>(PushLimit.class); | |||
| ObjectMapper om = new ObjectMapper(); | |||
| om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||
| om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||
| j.setObjectMapper(om); | |||
| // value值的序列化 | |||
| template.setValueSerializer(j); | |||
| template.setHashValueSerializer(j); | |||
| // key的序列化 | |||
| template.setKeySerializer(new StringRedisSerializer()); | |||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||
| template.afterPropertiesSet(); | |||
| return template; | |||
| } | |||
| @Bean("scoreRuleRedisTemplate") | |||
| public RedisTemplate<String, WxScoreRules> getScoreRuleRedisTemplate(RedisConnectionFactory connectionFactory) { | |||
| RedisTemplate<String, WxScoreRules> template = new RedisTemplate<String, WxScoreRules>(); | |||
| template.setConnectionFactory(connectionFactory); | |||
| Jackson2JsonRedisSerializer<WxScoreRules> j = new Jackson2JsonRedisSerializer<WxScoreRules>(WxScoreRules.class); | |||
| ObjectMapper om = new ObjectMapper(); | |||
| om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||
| om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||
| j.setObjectMapper(om); | |||
| // value值的序列化 | |||
| template.setValueSerializer(j); | |||
| template.setHashValueSerializer(j); | |||
| // key的序列化 | |||
| template.setKeySerializer(new StringRedisSerializer()); | |||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||
| template.afterPropertiesSet(); | |||
| return template; | |||
| } | |||
| @Bean("cuserTokenRedisTemplate") | |||
| public RedisTemplate<String, WxCUser> getCUserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | |||
| RedisTemplate<String, WxCUser> template = new RedisTemplate<String, WxCUser>(); | |||
| template.setConnectionFactory(connectionFactory); | |||
| Jackson2JsonRedisSerializer<WxCUser> j = new Jackson2JsonRedisSerializer<WxCUser>(WxCUser.class); | |||
| ObjectMapper om = new ObjectMapper(); | |||
| om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||
| om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||
| j.setObjectMapper(om); | |||
| // value值的序列化 | |||
| template.setValueSerializer(j); | |||
| template.setHashValueSerializer(j); | |||
| // key的序列化 | |||
| template.setKeySerializer(new StringRedisSerializer()); | |||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||
| template.afterPropertiesSet(); | |||
| return template; | |||
| } | |||
| @Bean("baseCUserTokenRedisTemplate") | |||
| public RedisTemplate<String, BaseCUserEntity> getBaseCUserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | |||
| RedisTemplate<String, BaseCUserEntity> template = new RedisTemplate<String, BaseCUserEntity>(); | |||
| template.setConnectionFactory(connectionFactory); | |||
| Jackson2JsonRedisSerializer<BaseCUserEntity> j = new Jackson2JsonRedisSerializer<BaseCUserEntity>(BaseCUserEntity.class); | |||
| ObjectMapper om = new ObjectMapper(); | |||
| om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||
| om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||
| j.setObjectMapper(om); | |||
| // value值的序列化 | |||
| template.setValueSerializer(j); | |||
| template.setHashValueSerializer(j); | |||
| // key的序列化 | |||
| template.setKeySerializer(new StringRedisSerializer()); | |||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||
| template.afterPropertiesSet(); | |||
| return template; | |||
| } | |||
| @Bean("cUserBasicInfoRedisTemplate") | |||
| public RedisTemplate<String, WxCUserBasicInfo> getCUserBasicInfoRedisTemplate(RedisConnectionFactory connectionFactory) { | |||
| RedisTemplate<String, WxCUserBasicInfo> template = new RedisTemplate<String, WxCUserBasicInfo>(); | |||
| template.setConnectionFactory(connectionFactory); | |||
| Jackson2JsonRedisSerializer<WxCUserBasicInfo> j = new Jackson2JsonRedisSerializer<WxCUserBasicInfo>(WxCUserBasicInfo.class); | |||
| ObjectMapper om = new ObjectMapper(); | |||
| om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||
| om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||
| j.setObjectMapper(om); | |||
| // value值的序列化 | |||
| template.setValueSerializer(j); | |||
| template.setHashValueSerializer(j); | |||
| // key的序列化 | |||
| template.setKeySerializer(new StringRedisSerializer()); | |||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||
| template.afterPropertiesSet(); | |||
| return template; | |||
| } | |||
| @Bean("mallRedisTemplate") | |||
| public RedisTemplate<String, WxMall> getMallRedisTemplate(RedisConnectionFactory connectionFactory) { | |||
| RedisTemplate<String, WxMall> template = new RedisTemplate<String, WxMall>(); | |||
| template.setConnectionFactory(connectionFactory); | |||
| Jackson2JsonRedisSerializer<WxMall> j = new Jackson2JsonRedisSerializer<WxMall>(WxMall.class); | |||
| ObjectMapper om = new ObjectMapper(); | |||
| om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||
| om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||
| j.setObjectMapper(om); | |||
| // value值的序列化 | |||
| template.setValueSerializer(j); | |||
| template.setHashValueSerializer(j); | |||
| // key的序列化 | |||
| template.setKeySerializer(new StringRedisSerializer()); | |||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||
| template.afterPropertiesSet(); | |||
| return template; | |||
| } | |||
| @Bean("subMallListRedisTemplate") | |||
| public RedisTemplate<String, List<WxMall>> getSubMallListRedisTemplate(RedisConnectionFactory connectionFactory) { | |||
| RedisTemplate<String, List<WxMall>> template = new RedisTemplate<String, List<WxMall>>(); | |||
| template.setConnectionFactory(connectionFactory); | |||
| Jackson2JsonRedisSerializer<List> j = new Jackson2JsonRedisSerializer<List>(List.class); | |||
| ObjectMapper om = new ObjectMapper(); | |||
| om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||
| om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||
| j.setObjectMapper(om); | |||
| // value值的序列化 | |||
| template.setValueSerializer(j); | |||
| template.setHashValueSerializer(j); | |||
| // key的序列化 | |||
| template.setKeySerializer(new StringRedisSerializer()); | |||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||
| template.afterPropertiesSet(); | |||
| return template; | |||
| } | |||
| @Bean("couponDetailRedisTemplate") | |||
| public RedisTemplate<String, WxCouponCVo> getCouponDetailRedisTemplate(RedisConnectionFactory connectionFactory) { | |||
| RedisTemplate<String, WxCouponCVo> template = new RedisTemplate<String, WxCouponCVo>(); | |||
| template.setConnectionFactory(connectionFactory); | |||
| Jackson2JsonRedisSerializer<WxCouponCVo> j = new Jackson2JsonRedisSerializer<WxCouponCVo>(WxCouponCVo.class); | |||
| ObjectMapper om = new ObjectMapper(); | |||
| om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||
| om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||
| j.setObjectMapper(om); | |||
| // value值的序列化 | |||
| template.setValueSerializer(j); | |||
| template.setHashValueSerializer(j); | |||
| // key的序列化 | |||
| template.setKeySerializer(new StringRedisSerializer()); | |||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||
| template.afterPropertiesSet(); | |||
| return template; | |||
| } | |||
| @Bean("couponChannelRedisTemplate") | |||
| public RedisTemplate<String, PageInfo<WxCouponChannelVo>> getCouponChannelRedisTemplate(RedisConnectionFactory connectionFactory) { | |||
| RedisTemplate<String, PageInfo<WxCouponChannelVo>> template = new RedisTemplate<>(); | |||
| template.setConnectionFactory(connectionFactory); | |||
| Jackson2JsonRedisSerializer<PageInfo> j = new Jackson2JsonRedisSerializer<PageInfo>(PageInfo.class); | |||
| ObjectMapper om = new ObjectMapper(); | |||
| om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||
| om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||
| j.setObjectMapper(om); | |||
| // value值的序列化 | |||
| template.setValueSerializer(j); | |||
| template.setHashValueSerializer(j); | |||
| // key的序列化 | |||
| template.setKeySerializer(new StringRedisSerializer()); | |||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||
| template.afterPropertiesSet(); | |||
| return template; | |||
| } | |||
| @Bean("buserTokenRedisTemplate") | |||
| public RedisTemplate<String, WxBuser> getBuserTokenRedisTemplate(RedisConnectionFactory connectionFactory) { | |||
| RedisTemplate<String, WxBuser> template = new RedisTemplate(); | |||
| template.setConnectionFactory(connectionFactory); | |||
| Jackson2JsonRedisSerializer<WxBuser> j = new Jackson2JsonRedisSerializer(WxBuser.class); | |||
| ObjectMapper om = new ObjectMapper(); | |||
| om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||
| om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||
| j.setObjectMapper(om); | |||
| // value值的序列化 | |||
| template.setValueSerializer(j); | |||
| template.setHashValueSerializer(j); | |||
| // key的序列化 | |||
| template.setKeySerializer(new StringRedisSerializer()); | |||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||
| template.afterPropertiesSet(); | |||
| return template; | |||
| } | |||
| @Bean("pressOrderRedisTemplate") | |||
| public RedisTemplate<String, WxOrder> getPressOrderRedisTemplate(RedisConnectionFactory connectionFactory) { | |||
| RedisTemplate<String, WxOrder> template = new RedisTemplate<>(); | |||
| template.setConnectionFactory(connectionFactory); | |||
| Jackson2JsonRedisSerializer<WxOrder> j = new Jackson2JsonRedisSerializer<WxOrder>(WxOrder.class); | |||
| ObjectMapper om = new ObjectMapper(); | |||
| om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||
| om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||
| j.setObjectMapper(om); | |||
| // value值的序列化 | |||
| template.setValueSerializer(j); | |||
| template.setHashValueSerializer(j); | |||
| // key的序列化 | |||
| template.setKeySerializer(new StringRedisSerializer()); | |||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||
| template.afterPropertiesSet(); | |||
| return template; | |||
| } | |||
| @Bean("stringValueOperations") | |||
| public ValueOperations<String, String> getStringValueOperations(RedisConnectionFactory connectionFactory) { | |||
| StringRedisTemplate template = new StringRedisTemplate(); | |||
| template.setConnectionFactory(connectionFactory); | |||
| template.afterPropertiesSet(); | |||
| return template.opsForValue(); | |||
| } | |||
| @Bean("objectCommonRedisTemplate") | |||
| public RedisTemplate<String, Object> getObjectValueOperations(RedisConnectionFactory connectionFactory) { | |||
| RedisTemplate<String, Object> template = new RedisTemplate<>(); | |||
| template.setConnectionFactory(connectionFactory); | |||
| Jackson2JsonRedisSerializer<Object> j = new Jackson2JsonRedisSerializer<Object>(Object.class); | |||
| ObjectMapper om = new ObjectMapper(); | |||
| om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); | |||
| om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); | |||
| j.setObjectMapper(om); | |||
| // value值的序列化 | |||
| template.setValueSerializer(j); | |||
| template.setHashValueSerializer(j); | |||
| // key的序列化 | |||
| template.setKeySerializer(new StringRedisSerializer()); | |||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||
| template.afterPropertiesSet(); | |||
| return template; | |||
| } | |||
| } | |||
| @@ -0,0 +1,61 @@ | |||
| package com.iformall.config; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.context.annotation.Bean; | |||
| import org.springframework.context.annotation.Configuration; | |||
| import springfox.documentation.builders.ApiInfoBuilder; | |||
| import springfox.documentation.builders.ParameterBuilder; | |||
| import springfox.documentation.builders.PathSelectors; | |||
| import springfox.documentation.builders.RequestHandlerSelectors; | |||
| import springfox.documentation.schema.ModelRef; | |||
| import springfox.documentation.service.ApiInfo; | |||
| import springfox.documentation.service.Parameter; | |||
| import springfox.documentation.spi.DocumentationType; | |||
| import springfox.documentation.spring.web.paths.RelativePathProvider; | |||
| import springfox.documentation.spring.web.plugins.Docket; | |||
| import springfox.documentation.swagger2.annotations.EnableSwagger2; | |||
| import javax.servlet.ServletContext; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| //参考:http://blog.csdn.net/catoop/article/details/50668896 | |||
| @Configuration | |||
| @EnableSwagger2 | |||
| public class Swagger2Config { | |||
| @Autowired | |||
| private ServletContext servletContext; | |||
| @Bean | |||
| public Docket createRestApi() { | |||
| ParameterBuilder tokenPar = new ParameterBuilder(); | |||
| List<Parameter> pars = new ArrayList<Parameter>(); | |||
| //增加一个request的header参数 | |||
| tokenPar.name("token").description("令牌").modelRef(new ModelRef("string")).parameterType("header").required(false).build(); | |||
| pars.add(tokenPar.build()); | |||
| return new Docket(DocumentationType.SWAGGER_2) | |||
| .apiInfo(apiInfo()) | |||
| .select() | |||
| .apis(RequestHandlerSelectors.basePackage("com.iformall.controller")) | |||
| .paths(PathSelectors.any()) | |||
| .build() | |||
| .globalOperationParameters(pars) | |||
| .pathProvider(new RelativePathProvider(servletContext) { | |||
| @Override | |||
| public String getApplicationBasePath() { | |||
| return "/api"; | |||
| } | |||
| }); | |||
| } | |||
| private ApiInfo apiInfo() { | |||
| return new ApiInfoBuilder() | |||
| .title("c端 api") | |||
| .description("c api") | |||
| .termsOfServiceUrl("http://localhost:7000") | |||
| .version("2.0") | |||
| .build(); | |||
| } | |||
| } | |||
| @@ -0,0 +1,106 @@ | |||
| package com.iformall.config; | |||
| import com.fasterxml.jackson.annotation.JsonInclude; | |||
| import com.fasterxml.jackson.databind.DeserializationConfig; | |||
| import com.fasterxml.jackson.databind.DeserializationFeature; | |||
| import com.fasterxml.jackson.databind.ObjectMapper; | |||
| import com.fasterxml.jackson.databind.module.SimpleModule; | |||
| import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; | |||
| import com.iformall.interceptor.AuthorizationInterceptor; | |||
| import com.iformall.interceptor.HttpServletRequestWrapperFilter; | |||
| import com.iformall.interceptor.RequestInterceptor; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.boot.web.servlet.FilterRegistrationBean; | |||
| import org.springframework.context.annotation.Bean; | |||
| import org.springframework.context.annotation.Configuration; | |||
| import org.springframework.http.converter.HttpMessageConverter; | |||
| import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; | |||
| import org.springframework.web.method.support.HandlerMethodArgumentResolver; | |||
| import org.springframework.web.servlet.config.annotation.*; | |||
| import java.math.BigDecimal; | |||
| import java.math.BigInteger; | |||
| import java.text.SimpleDateFormat; | |||
| import java.util.List; | |||
| /** | |||
| * MVC配置 | |||
| * | |||
| * @author stormeye.wu | |||
| * @email wugq@mippoint.com | |||
| * @date 2017-04-20 22:30 | |||
| */ | |||
| @Configuration | |||
| @EnableWebMvc | |||
| public class WebMvcConfig implements WebMvcConfigurer { | |||
| @Autowired | |||
| private AuthorizationInterceptor authorizationInterceptor; | |||
| @Autowired | |||
| private RequestInterceptor requestInterceptor; | |||
| @Override | |||
| public void addInterceptors(InterceptorRegistry registry) { | |||
| registry.addInterceptor(authorizationInterceptor).addPathPatterns("/api/**"); | |||
| registry.addInterceptor(requestInterceptor).addPathPatterns("/api/**"); | |||
| } | |||
| @Override | |||
| public void addResourceHandlers(ResourceHandlerRegistry registry) { | |||
| registry.addResourceHandler("swagger-ui.html") | |||
| .addResourceLocations("classpath:/META-INF/resources/"); | |||
| registry.addResourceHandler("/webjars/**") | |||
| .addResourceLocations("classpath:/META-INF/resources/webjars/"); | |||
| //registry.addResourceHandler("/app/**").addResourceLocations("classpath:/app/"); | |||
| } | |||
| @Override | |||
| public void addCorsMappings(CorsRegistry registry) { | |||
| registry.addMapping("/api/**") | |||
| .allowedOrigins("*") | |||
| .allowCredentials(true) | |||
| .allowedMethods("GET", "POST", "DELETE", "PUT") | |||
| .maxAge(3600); | |||
| } | |||
| @Override | |||
| public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { | |||
| MappingJackson2HttpMessageConverter jackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter(); | |||
| //ObjectMapper 是Jackson库的主要类。它提供一些功能将转换成Java对象匹配JSON结构,反之亦然 | |||
| ObjectMapper objectMapper = new ObjectMapper(); | |||
| SimpleModule simpleModule = new SimpleModule(); | |||
| //不显示为null的字段 | |||
| objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); | |||
| DeserializationConfig dc = objectMapper.getDeserializationConfig(); | |||
| // 设置反序列化日期格式、忽略不存在get、set的属性 | |||
| objectMapper.setConfig( | |||
| dc.with(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss")) | |||
| .without(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) | |||
| ); | |||
| //序列化将Long转String类型 | |||
| simpleModule.addSerializer(Long.class, ToStringSerializer.instance); | |||
| simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance); | |||
| SimpleModule bigIntegerModule = new SimpleModule(); | |||
| //序列化将BigInteger转String类型 | |||
| bigIntegerModule.addSerializer(BigInteger.class, ToStringSerializer.instance); | |||
| SimpleModule bigDecimalModule = new SimpleModule(); | |||
| //序列化将BigDecimal转String类型 | |||
| bigDecimalModule.addSerializer(BigDecimal.class, ToStringSerializer.instance); | |||
| objectMapper.registerModule(simpleModule); | |||
| objectMapper.registerModule(bigDecimalModule); | |||
| objectMapper.registerModule(bigIntegerModule); | |||
| jackson2HttpMessageConverter.setObjectMapper(objectMapper); | |||
| converters.add(jackson2HttpMessageConverter); | |||
| } | |||
| @Bean | |||
| public FilterRegistrationBean<HttpServletRequestWrapperFilter> Filters() { | |||
| FilterRegistrationBean<HttpServletRequestWrapperFilter> registrationBean = new FilterRegistrationBean<HttpServletRequestWrapperFilter>(); | |||
| registrationBean.setFilter(new HttpServletRequestWrapperFilter()); | |||
| registrationBean.addUrlPatterns("/*"); | |||
| registrationBean.setName("koalaSignFilter"); | |||
| return registrationBean; | |||
| } | |||
| } | |||
| @@ -0,0 +1,57 @@ | |||
| package com.iformall.controller; | |||
| import com.iformall.utils.IPUtil; | |||
| 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.web.bind.WebDataBinder; | |||
| import org.springframework.web.bind.annotation.InitBinder; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| import org.springframework.web.context.request.RequestContextHolder; | |||
| import org.springframework.web.context.request.ServletRequestAttributes; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import java.beans.PropertyEditorSupport; | |||
| import java.text.ParseException; | |||
| import java.text.SimpleDateFormat; | |||
| import java.util.Date; | |||
| @RestController | |||
| public class BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| @Qualifier("objectCommonRedisTemplate") | |||
| RedisTemplate<String, Object> objectCommonRedisTemplate; | |||
| @InitBinder | |||
| public void InitBinder(WebDataBinder dataBinder) { | |||
| dataBinder.registerCustomEditor(Date.class, new PropertyEditorSupport() { | |||
| public void setAsText(String value) { | |||
| try { | |||
| setValue(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(value)); | |||
| } catch (ParseException e) { | |||
| try { | |||
| setValue(new SimpleDateFormat("yyyy-MM-dd ").parse(value)); | |||
| } catch (ParseException e1) { | |||
| setValue(null); | |||
| } | |||
| } | |||
| } | |||
| public String getAsText() { | |||
| return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format((Date) getValue()); | |||
| } | |||
| }); | |||
| } | |||
| public String getIpAddr() { | |||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||
| String ipaddress = IPUtil.getIpAddr(request); | |||
| return ipaddress; | |||
| } | |||
| } | |||
| @@ -0,0 +1,68 @@ | |||
| package com.iformall.interceptor; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.utils.HashUtil; | |||
| import com.iformall.utils.RedisCacheUtils; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| 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.Component; | |||
| import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| /** | |||
| * 权限(Token)验证 | |||
| * @author stormeye.wu | |||
| * @email wuguoqiang@iformall.com | |||
| * @date 2017-03-23 15:38 | |||
| */ | |||
| @Component | |||
| public class AuthorizationInterceptor extends HandlerInterceptorAdapter { | |||
| @Autowired | |||
| @Qualifier("objectCommonRedisTemplate") | |||
| RedisTemplate<String, Object> redisTemplate; | |||
| @Override | |||
| public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { | |||
| String cid = request.getParameter("cId");//调用方ID | |||
| String nonceStr = request.getParameter("nonceStr");//随机字符串 | |||
| String signKey = request.getParameter("signKey");//随机字符串 | |||
| if(StringUtils.isBlank(cid) || "null".equals(cid) || "undefined".equals(cid)){ | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"cId为空["+cid+"]"); | |||
| } | |||
| if(StringUtils.isBlank(nonceStr) || "null".equals(nonceStr) || "undefined".equals(nonceStr)){ | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"nonceStr为空["+nonceStr+"]"); | |||
| } | |||
| if(StringUtils.isBlank(signKey) || "null".equals(signKey) || "undefined".equals(signKey)){ | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"signKey为空["+signKey+"]"); | |||
| } | |||
| //nonceStr必须唯一,为防止接口盗刷,每次只能调用一次 | |||
| Integer cache = RedisCacheUtils.getCacheInteger(redisTemplate, "publicApi:"+nonceStr); | |||
| if (null != cache) { | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"不能重复调用"); | |||
| } | |||
| //TODO singnKey是根据cid+cid对应的密钥+nonceStr | |||
| String secretKey = "";//TODO 根据cid查询密钥,缓存 | |||
| String signstr = HashUtil.md5(cid+secretKey+nonceStr); | |||
| if (!signKey.equals(signstr)) { | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"加密串校验失败"); | |||
| } | |||
| RedisCacheUtils.cache(redisTemplate, "publicApi:"+nonceStr, 1, 600); | |||
| return true; | |||
| } | |||
| } | |||
| @@ -0,0 +1,76 @@ | |||
| package com.iformall.interceptor; | |||
| import javax.servlet.ReadListener; | |||
| import javax.servlet.ServletInputStream; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import java.io.*; | |||
| public class BodyReaderHttpServletRequestWrapper extends XssHttpServletRequestWrapper { | |||
| private final String body; | |||
| public BodyReaderHttpServletRequestWrapper(HttpServletRequest request) throws IOException { | |||
| super(request); | |||
| StringBuilder stringBuilder = new StringBuilder(); | |||
| BufferedReader bufferedReader = null; | |||
| try { | |||
| InputStream inputStream = request.getInputStream(); | |||
| if (inputStream != null) { | |||
| bufferedReader = new BufferedReader(new InputStreamReader(inputStream,"utf-8")); | |||
| char[] charBuffer = new char[1024]; | |||
| int bytesRead = -1; | |||
| while ((bytesRead = bufferedReader.read(charBuffer)) > 0) { | |||
| stringBuilder.append(charBuffer, 0, bytesRead); | |||
| } | |||
| } else { | |||
| stringBuilder.append(""); | |||
| } | |||
| } catch (IOException ex) { | |||
| throw ex; | |||
| } finally { | |||
| if (bufferedReader != null) { | |||
| try { | |||
| bufferedReader.close(); | |||
| } catch (IOException ex) { | |||
| throw ex; | |||
| } | |||
| } | |||
| } | |||
| body = stringBuilder.toString(); | |||
| } | |||
| @Override | |||
| public ServletInputStream getInputStream() throws IOException { | |||
| final ByteArrayInputStream byteArrayInputStream = | |||
| new ByteArrayInputStream(body.getBytes("utf-8")); | |||
| return new ServletInputStream() { | |||
| @Override | |||
| public boolean isFinished() { | |||
| return false; | |||
| } | |||
| @Override | |||
| public boolean isReady() { | |||
| return false; | |||
| } | |||
| @Override | |||
| public void setReadListener(ReadListener readListener) { | |||
| } | |||
| @Override | |||
| public int read() throws IOException { | |||
| return byteArrayInputStream.read(); | |||
| } | |||
| }; | |||
| } | |||
| @Override | |||
| public BufferedReader getReader() throws IOException { | |||
| return new BufferedReader(new InputStreamReader(this.getInputStream())); | |||
| } | |||
| public String getBody() { | |||
| return this.body; | |||
| } | |||
| } | |||
| @@ -0,0 +1,70 @@ | |||
| package com.iformall.interceptor; | |||
| import com.iformall.utils.UrlCheck; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import javax.servlet.*; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import java.io.IOException; | |||
| public class HttpServletRequestWrapperFilter implements Filter { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| // 多个跨域域名设置 | |||
| // public static final String[] ALLOW_DOMAIN = {"https://admin.malls.iformall.com"}; | |||
| @Override | |||
| public void init(FilterConfig filterConfig) throws ServletException { | |||
| } | |||
| @Override | |||
| public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) | |||
| throws IOException, ServletException { | |||
| logger.debug("doFilter start"); | |||
| long start = System.currentTimeMillis(); | |||
| ServletRequest requestWrapper = null; | |||
| /* // 跨域访问 | |||
| HttpServletRequest req = (HttpServletRequest) request; | |||
| HttpServletResponse res = (HttpServletResponse) response; | |||
| String originHeader = req.getHeader("Origin"); | |||
| if (Arrays.asList(ALLOW_DOMAIN).contains(originHeader)) { | |||
| //通过在响应 header 中设置 ‘*’ 来允许来自所有域的跨域请求访问。 | |||
| res.setHeader("Access-Control-Allow-Origin", originHeader); | |||
| //通过对 Credentials 参数的设置,就可以保持跨域 Ajax 时的 Cookie | |||
| //设置了Allow-Credentials,Allow-Origin就不能为*,需要指明具体的url域 | |||
| res.setHeader("Access-Control-Allow-Credentials", "true"); | |||
| //请求方式 | |||
| res.setHeader("Access-Control-Allow-Methods", "*"); | |||
| //(预检请求)的返回结果(即 Access-Control-Allow-Methods 和Access-Control-Allow-Headers 提供的信息) 可以被缓存多久 | |||
| res.setHeader("Access-Control-Max-Age", "86400"); | |||
| //首部字段用于预检请求的响应。其指明了实际请求中允许携带的首部字段 | |||
| //res.setHeader("Access-Control-Allow-Headers", "*"); | |||
| res.setHeader("Access-Control-Allow-Headers", | |||
| "Timestamp,Origin, No-Cache, X-Requested-With, If-Modified-Since, Pragma, Last-Modified, Cache-Control, Expires, Content-Type, X-E4M-With,userId,token,Access-Control-Allow-Headers"); | |||
| } | |||
| */ | |||
| //sql,xss过滤 | |||
| XssHttpServletRequestWrapper xssHttpServletRequestWrapper = new XssHttpServletRequestWrapper((HttpServletRequest)request); | |||
| String url = ""; | |||
| if (request instanceof HttpServletRequest) { | |||
| url = ((HttpServletRequest) request).getRequestURI(); | |||
| if (!UrlCheck.checkUrl(url)) { | |||
| requestWrapper = new BodyReaderHttpServletRequestWrapper((HttpServletRequest) request); | |||
| } | |||
| } | |||
| if (null == requestWrapper) { | |||
| chain.doFilter(xssHttpServletRequestWrapper, response); | |||
| } else { | |||
| chain.doFilter(requestWrapper, response); | |||
| } | |||
| logger.debug("doFilter end: " + url + " "+ (System.currentTimeMillis()- start) + "ms"); | |||
| } | |||
| @Override | |||
| public void destroy() { | |||
| } | |||
| } | |||
| @@ -0,0 +1,123 @@ | |||
| package com.iformall.interceptor; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.utils.HashUtil; | |||
| import com.iformall.utils.IPUtil; | |||
| import com.iformall.utils.UrlCheck; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.dao.DataAccessException; | |||
| import org.springframework.data.redis.connection.RedisConnection; | |||
| import org.springframework.data.redis.core.RedisCallback; | |||
| import org.springframework.data.redis.core.RedisTemplate; | |||
| import org.springframework.data.redis.serializer.RedisSerializer; | |||
| import org.springframework.stereotype.Component; | |||
| import org.springframework.web.servlet.ModelAndView; | |||
| import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; | |||
| import redis.clients.jedis.Protocol; | |||
| import redis.clients.jedis.util.SafeEncoder; | |||
| import javax.annotation.Resource; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.io.ByteArrayOutputStream; | |||
| import java.io.InputStream; | |||
| import java.nio.charset.Charset; | |||
| import java.util.Enumeration; | |||
| import java.util.concurrent.TimeUnit; | |||
| /** | |||
| * 幂等检查 | |||
| * @author stormeye.wu | |||
| * @email wuguoqiang@iformall.com | |||
| * @date 2017-03-23 15:38 | |||
| */ | |||
| @Component | |||
| public class RequestInterceptor extends HandlerInterceptorAdapter { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Resource | |||
| private RedisTemplate<String, String> redisTemplate; | |||
| @Override | |||
| public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { | |||
| logger.debug("preHandle start"); | |||
| if ("GET".equalsIgnoreCase(request.getMethod())) { | |||
| // 获取不检查幂等 | |||
| logger.debug("preHandle start 1"); | |||
| return true; | |||
| } | |||
| String ipaddress = IPUtil.getIpAddr(request); | |||
| String url = request.getRequestURL().toString(); | |||
| if (UrlCheck.checkUrl(url)) { | |||
| // pvlog不检查幂等 | |||
| // awsFileUpload不检查幂等 | |||
| // stopFee | |||
| return true; | |||
| } | |||
| StringBuilder sb = new StringBuilder(); | |||
| sb.append(url); | |||
| sb.append("method=").append(request.getMethod()).append("&"); | |||
| sb.append("ip=").append(ipaddress).append("&"); | |||
| final Enumeration parameterNames = request.getParameterNames(); | |||
| while (parameterNames.hasMoreElements()) { | |||
| String key = (String) parameterNames.nextElement(); | |||
| if(key.equalsIgnoreCase("ran")) // 跳过ran | |||
| continue; | |||
| String parameter = request.getParameter(key); | |||
| sb.append(key).append("=").append(parameter).append("&"); | |||
| } | |||
| InputStream inStream = request.getInputStream(); | |||
| ByteArrayOutputStream outSteam = new ByteArrayOutputStream(); | |||
| byte[] buffer = new byte[1024]; | |||
| int len = 0; | |||
| while ((len = inStream.read(buffer)) != -1) { | |||
| outSteam.write(buffer, 0, len); | |||
| } | |||
| String resultBody = new String(outSteam.toByteArray(), Charset.forName("UTF-8")); | |||
| inStream.close(); | |||
| outSteam.close(); | |||
| sb.append(resultBody); | |||
| String key = "request:C:" + HashUtil.md5(sb.toString()); | |||
| Boolean isAbsent = redisTemplate.<Boolean>execute(new RedisCallback<Boolean>() { | |||
| @Override | |||
| public Boolean doInRedis(RedisConnection connection) throws DataAccessException { | |||
| RedisSerializer valueSerializer = redisTemplate.getValueSerializer(); | |||
| RedisSerializer keySerializer = redisTemplate.getKeySerializer(); | |||
| Object obj = connection.execute("set", keySerializer.serialize(key), | |||
| valueSerializer.serialize(key), | |||
| SafeEncoder.encode("NX"), | |||
| SafeEncoder.encode("EX"), | |||
| Protocol.toByteArray(3)); // 3s | |||
| return obj != null; | |||
| } | |||
| }); | |||
| if (isAbsent) { | |||
| logger.info(key + ": 第一次提交"); | |||
| logger.debug("preHandle start 2"); | |||
| return true; | |||
| } | |||
| logger.info(key + ": 第二次提交"); | |||
| logger.debug("preHandle start 3"); | |||
| throw new MallinkException(ErrorCode.SYS_REPEAT_SUBMIT_EXCEPTION); | |||
| } | |||
| @Override | |||
| public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { | |||
| logger.debug("postHandle"); | |||
| } | |||
| @Override | |||
| public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { | |||
| logger.debug("afterCompletion"); | |||
| } | |||
| } | |||
| @@ -0,0 +1,72 @@ | |||
| package com.iformall.interceptor; | |||
| import com.iformall.utils.IPUtil; | |||
| import lombok.Data; | |||
| import org.aspectj.lang.JoinPoint; | |||
| import org.aspectj.lang.annotation.AfterReturning; | |||
| import org.aspectj.lang.annotation.Aspect; | |||
| import org.aspectj.lang.annotation.Before; | |||
| import org.aspectj.lang.annotation.Pointcut; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.stereotype.Component; | |||
| import org.springframework.web.context.request.RequestContextHolder; | |||
| import org.springframework.web.context.request.ServletRequestAttributes; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import java.util.Arrays; | |||
| @Aspect | |||
| @Component | |||
| public class WebLogAspect { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Data | |||
| private class MethodInfo { | |||
| Long startTime; | |||
| String url; | |||
| String ip; | |||
| String method; | |||
| String classMethod; | |||
| } | |||
| ThreadLocal<MethodInfo> startInfo = new ThreadLocal<>(); | |||
| @Pointcut("execution(public * com.iformall.controller..*.*(..))") | |||
| public void webLog() {} | |||
| @Before("webLog()") | |||
| public void doBefore(JoinPoint joinPoint) throws Throwable { | |||
| logger.debug("aspect start"); | |||
| // 接收到请求,记录请求内容 | |||
| ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); | |||
| HttpServletRequest request = attributes.getRequest(); | |||
| MethodInfo info = new MethodInfo(); | |||
| info.setUrl(request.getRequestURL().toString()); | |||
| info.setStartTime(System.currentTimeMillis()); | |||
| info.setIp(IPUtil.getIpAddr(request)); | |||
| info.setMethod(request.getMethod()); | |||
| info.setClassMethod(joinPoint.getSignature().getDeclaringTypeName() + "." + joinPoint.getSignature().getName()); | |||
| startInfo.set(info); | |||
| logger.debug("aspect start ..."); | |||
| } | |||
| @AfterReturning(returning = "ret", pointcut = "webLog()") | |||
| public void doAfterReturning(Object ret) throws Throwable { | |||
| logger.debug("aspect after"); | |||
| // 处理完请求,返回内容 | |||
| MethodInfo info = startInfo.get(); | |||
| StringBuilder sb = new StringBuilder(); | |||
| sb.append("URL: ").append(info.getUrl()) | |||
| .append(", METHOD: ").append(info.getMethod()) | |||
| .append(", DO: ").append(info.getClassMethod()) | |||
| .append(", IP: ").append(info.getIp()) | |||
| .append(", SPEND TIME: ").append(System.currentTimeMillis() -info.getStartTime()).append("ms"); | |||
| logger.info(sb.toString()); | |||
| logger.debug("aspect after .."); | |||
| } | |||
| } | |||
| @@ -0,0 +1,125 @@ | |||
| package com.iformall.interceptor; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.util.StringUtils; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletRequestWrapper; | |||
| import java.util.HashMap; | |||
| import java.util.HashSet; | |||
| import java.util.Map; | |||
| import java.util.Set; | |||
| /** | |||
| * 防止sql注入,xss攻击 | |||
| * 前端可以对输入信息做预处理,后端也可以做处理。 | |||
| */ | |||
| public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper { | |||
| private final Logger log = LoggerFactory.getLogger(getClass()); | |||
| private static String key = "and|exec|insert|select|delete|update|count|*|%|chr|mid|master|truncate|char|declare|;|or|-|+"; | |||
| private static Set<String> notAllowedKeyWords = new HashSet<String>(0); | |||
| private static String replacedString="INVALID"; | |||
| static { | |||
| String keyStr[] = key.split("\\|"); | |||
| for (String str : keyStr) { | |||
| notAllowedKeyWords.add(str); | |||
| } | |||
| } | |||
| private String currentUrl; | |||
| public XssHttpServletRequestWrapper(HttpServletRequest servletRequest) { | |||
| super(servletRequest); | |||
| currentUrl = servletRequest.getRequestURI(); | |||
| } | |||
| /**覆盖getParameter方法,将参数名和参数值都做xss过滤。 | |||
| * 如果需要获得原始的值,则通过super.getParameterValues(name)来获取 | |||
| * getParameterNames,getParameterValues和getParameterMap也可能需要覆盖 | |||
| */ | |||
| @Override | |||
| public String getParameter(String parameter) { | |||
| String value = super.getParameter(parameter); | |||
| if (value == null) { | |||
| return null; | |||
| } | |||
| return cleanXSS(value); | |||
| } | |||
| @Override | |||
| public String[] getParameterValues(String parameter) { | |||
| String[] values = super.getParameterValues(parameter); | |||
| if (values == null) { | |||
| return null; | |||
| } | |||
| int count = values.length; | |||
| String[] encodedValues = new String[count]; | |||
| for (int i = 0; i < count; i++) { | |||
| encodedValues[i] = cleanXSS(values[i]); | |||
| } | |||
| return encodedValues; | |||
| } | |||
| @Override | |||
| public Map<String, String[]> getParameterMap(){ | |||
| Map<String, String[]> values=super.getParameterMap(); | |||
| if (values == null) { | |||
| return null; | |||
| } | |||
| Map<String, String[]> result=new HashMap<>(); | |||
| for(String key:values.keySet()){ | |||
| String encodedKey=cleanXSS(key); | |||
| int count=values.get(key).length; | |||
| String[] encodedValues = new String[count]; | |||
| for (int i = 0; i < count; i++){ | |||
| encodedValues[i]=cleanXSS(values.get(key)[i]); | |||
| } | |||
| result.put(encodedKey,encodedValues); | |||
| } | |||
| return result; | |||
| } | |||
| /** | |||
| * 覆盖getHeader方法,将参数名和参数值都做xss过滤。 | |||
| * 如果需要获得原始的值,则通过super.getHeaders(name)来获取 | |||
| * getHeaderNames 也可能需要覆盖 | |||
| */ | |||
| @Override | |||
| public String getHeader(String name) { | |||
| if(name.equalsIgnoreCase("user-agent")) { | |||
| return super.getHeader(name); | |||
| } | |||
| String value = super.getHeader(name); | |||
| if (value == null) { | |||
| return null; | |||
| } | |||
| return cleanXSS(value); | |||
| } | |||
| private String cleanXSS(String valueP) { | |||
| // You'll need to remove the spaces from the html entities below | |||
| String value = valueP.replaceAll("<", "<").replaceAll(">", ">"); | |||
| value = value.replaceAll("<", "& lt;").replaceAll(">", "& gt;"); | |||
| value = value.replaceAll("\\(", "& #40;").replaceAll("\\)", "& #41;"); | |||
| value = value.replaceAll("'", "& #39;"); | |||
| value = value.replaceAll("eval\\((.*)\\)", ""); | |||
| value = value.replaceAll("[\\\"\\\'][\\s]*javascript:(.*)[\\\"\\\']", "\"\""); | |||
| value = value.replaceAll("script", ""); | |||
| value = cleanSqlKeyWords(value); | |||
| return value; | |||
| } | |||
| private String cleanSqlKeyWords(String value) { | |||
| String paramValue = value; | |||
| for (String keyword : notAllowedKeyWords) { | |||
| if (paramValue.length() > keyword.length() + 4 | |||
| && (paramValue.contains(" "+keyword)||paramValue.contains(keyword+" ")||paramValue.contains(" "+keyword+" "))) { | |||
| paramValue = StringUtils.replace(paramValue, keyword, replacedString); | |||
| log.error(this.currentUrl + "已被过滤,因为参数中包含不允许sql的关键词(" + keyword | |||
| + ")"+";参数:"+value+";过滤后的参数:"+paramValue); | |||
| } | |||
| } | |||
| return paramValue; | |||
| } | |||
| } | |||
| @@ -0,0 +1,175 @@ | |||
| package com.iformall.utils; | |||
| import net.sourceforge.pinyin4j.PinyinHelper; | |||
| import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType; | |||
| import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat; | |||
| import net.sourceforge.pinyin4j.format.HanyuPinyinToneType; | |||
| import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType; | |||
| import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.util.ResourceUtils; | |||
| import javax.imageio.ImageIO; | |||
| import java.awt.*; | |||
| import java.awt.image.BufferedImage; | |||
| import java.io.ByteArrayInputStream; | |||
| import java.io.ByteArrayOutputStream; | |||
| import java.io.File; | |||
| import java.io.InputStream; | |||
| import java.time.LocalDateTime; | |||
| import java.time.format.DateTimeFormatter; | |||
| import java.util.Locale; | |||
| public class ImgIdeaUtil { | |||
| private static final Logger logger = LoggerFactory.getLogger(ImgIdeaUtil.class); | |||
| //模板图片 | |||
| private static final String imgTempPath = "imgTemp/gertificate.jpg"; | |||
| //字体路径 | |||
| private static final String fontPath = "opt/HWLS.TTF"; | |||
| /** | |||
| * 生成图片证书 | |||
| * @return | |||
| */ | |||
| public static byte[] imgGertificate(String name, String englishName, LocalDateTime date){ | |||
| if(StringUtils.isBlank(name)){ | |||
| logger.error("名字为空,无法生成证书"); | |||
| return null; | |||
| } | |||
| if(name.length() == 2){ | |||
| name = name.replaceAll("(\\S)", "$0 "); | |||
| } | |||
| if(StringUtils.isBlank(englishName)){ | |||
| englishName = getUpEname(name); | |||
| } | |||
| if(date == null){ | |||
| date = LocalDateTime.now(); | |||
| } | |||
| DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dMMM yyyy", Locale.UK); | |||
| String dateFormat = date.format(formatter); | |||
| try { | |||
| InputStream backImgUrl = ClassLoader.getSystemResourceAsStream(imgTempPath); | |||
| //InputStream backImgUrl = ImgIdeaUtil.class.getClassLoader().getResourceAsStream(imgTempPath); | |||
| Font font = Font.createFont(Font.TRUETYPE_FONT, ResourceUtils.getFile("classpath:"+fontPath)); | |||
| BufferedImage backImg = ImageIO.read(backImgUrl); | |||
| Graphics g = backImg.getGraphics(); | |||
| //图片加中文名 | |||
| Font fTxtBottomName = font.deriveFont(Font.PLAIN, 170); | |||
| //Font fTxtBottomName = new Font("华文隶书", Font.PLAIN, 170); | |||
| FontMetrics metricsName = g.getFontMetrics(fTxtBottomName); | |||
| int xName = (backImg.getWidth() - metricsName.stringWidth(name)) / 2; | |||
| Color myColorTxtBottomName = Color.BLACK; //颜色 | |||
| g.setColor(myColorTxtBottomName); | |||
| g.setFont(fTxtBottomName); | |||
| g.drawString(name, xName , 1150);//g.drawString(文字, x 位置, y 位置); | |||
| //图片加英文名 | |||
| Font fTxtBottomEname = font.deriveFont(Font.PLAIN, 120); | |||
| //Font fTxtBottomEname = new Font("华文隶书", Font.PLAIN, 120); | |||
| FontMetrics metricsEname = g.getFontMetrics(fTxtBottomEname); | |||
| int xEname = (backImg.getWidth() - metricsEname.stringWidth(englishName)) / 2; | |||
| Color myColorTxtBottomEname = Color.BLACK; | |||
| g.setColor(myColorTxtBottomEname); | |||
| g.setFont(fTxtBottomEname); | |||
| g.drawString(englishName, xEname, 1300); | |||
| //图片加日期 | |||
| Font fTxtBottomDate = font.deriveFont(Font.PLAIN, 90); | |||
| //Font fTxtBottomDate = new Font("华文隶书", Font.PLAIN, 90); | |||
| Color myColorTxtBottomDate = Color.BLACK; | |||
| g.setColor(myColorTxtBottomDate); | |||
| g.setFont(fTxtBottomDate); | |||
| g.drawString(dateFormat, 440, 2100); | |||
| //调这个方法就是开始这个整合 (可以多张图片,多个文字整合成一张图片,只有把他们放在这方法里面就行) | |||
| g.dispose(); | |||
| ByteArrayOutputStream out = new ByteArrayOutputStream(); | |||
| ImageIO.write(backImg, "png", out); | |||
| return out.toByteArray(); | |||
| } catch (Exception e) { | |||
| e.printStackTrace(); | |||
| logger.error("生成证书异常", e.getMessage()); | |||
| } | |||
| return null; | |||
| } | |||
| /** | |||
| * //姓、名的第一个字母需要为大写 | |||
| * @param name | |||
| * @return | |||
| */ | |||
| public static String getUpEname(String name) { | |||
| char[] strs = name.toCharArray(); | |||
| String newname = null; | |||
| if (strs.length == 2) { | |||
| newname = toUpCase(getEname("" + strs[0])) + " " + toUpCase(getEname("" + strs[1])); | |||
| } else if (strs.length == 3){ | |||
| newname = toUpCase(getEname("" + strs[0])) + " " | |||
| + toUpCase(getEname("" + strs[1] + strs[2])); | |||
| }else if (strs.length == 4){ | |||
| newname = toUpCase(getEname("" + strs[0] + strs[1])) + " " | |||
| + toUpCase(getEname("" + strs[2] + strs[3])); | |||
| } else{ | |||
| newname = toUpCase(getEname(name)); | |||
| } | |||
| return newname; | |||
| } | |||
| /** | |||
| * //将中文转换为英文 | |||
| * @param name | |||
| * @return | |||
| */ | |||
| public static String getEname(String name){ | |||
| HanyuPinyinOutputFormat pyFormat = new HanyuPinyinOutputFormat(); | |||
| pyFormat.setCaseType(HanyuPinyinCaseType.LOWERCASE); | |||
| pyFormat.setToneType(HanyuPinyinToneType.WITHOUT_TONE); | |||
| pyFormat.setVCharType(HanyuPinyinVCharType.WITH_V); | |||
| String s = ""; | |||
| try { | |||
| s = PinyinHelper.toHanyuPinyinString(name, pyFormat, ""); | |||
| } catch (BadHanyuPinyinOutputFormatCombination badHanyuPinyinOutputFormatCombination) { | |||
| badHanyuPinyinOutputFormatCombination.printStackTrace(); | |||
| } | |||
| return s; | |||
| } | |||
| /** | |||
| * 首字母大写 | |||
| * @param str | |||
| * @return | |||
| */ | |||
| private static String toUpCase(String str) { | |||
| StringBuffer newstr = new StringBuffer(); | |||
| newstr.append((str.substring(0, 1)).toUpperCase()).append( | |||
| str.substring(1, str.length())); | |||
| return newstr.toString(); | |||
| } | |||
| // public static void main(String[] args) { | |||
| // String serverUploadImgUrl = "C:/Users/xiaohu/Desktop/img"; // 图片保存路径 | |||
| // try { | |||
| // byte[] bytes = imgGertificate("郑方元", null, null); | |||
| // ByteArrayInputStream bais = new ByteArrayInputStream(bytes); | |||
| // BufferedImage bi1 =ImageIO.read(bais); | |||
| // | |||
| // ImageIO.write(bi1, "png", new File(serverUploadImgUrl+"/0.png")); | |||
| // | |||
| // } catch (Exception e) { | |||
| // e.printStackTrace(); | |||
| // } | |||
| // System.out.println("结束"); | |||
| // } | |||
| } | |||
| @@ -0,0 +1,14 @@ | |||
| package com.iformall.utils; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| public class UrlCheck { | |||
| public static boolean checkUrl(String url) { | |||
| return url.contains("awsFileUpload") | |||
| || url.contains("awsFilesUpload") | |||
| || url.contains("getCarStopFee"); | |||
| } | |||
| } | |||
| @@ -0,0 +1,167 @@ | |||
| spring: | |||
| profiles: | |||
| #include: aliyunRocketMQ | |||
| include: rabbitMQ | |||
| # JDBC | |||
| datasource: | |||
| url: jdbc:mysql://101.200.130.134:3306/mallink?characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useUnicode=true&useSSL=false&useAffectedRows=true | |||
| username: root | |||
| password: fm2020test | |||
| type: com.alibaba.druid.pool.DruidDataSource | |||
| driver-class-name: com.mysql.cj.jdbc.Driver | |||
| filters: stat | |||
| maxActive: 20 | |||
| initialSize: 1 | |||
| maxWait: 60000 | |||
| minIdle: 1 | |||
| timeBetweenEvictionRunsMillis: 28000 | |||
| minEvictableIdleTimeMillis: 28000 | |||
| validationQuery: select 'x' | |||
| testWhileIdle: true | |||
| testOnBorrow: false | |||
| testOnReturn: false | |||
| poolPreparedStatements: true | |||
| maxOpenPreparedStatements: 20 | |||
| #jackson: | |||
| #date-format: yyyy-MM-dd HH:mm:ss | |||
| # REDIS | |||
| redis: | |||
| host: 101.200.130.134 | |||
| port: 6379 | |||
| password: iF0rm@2l2ol9 | |||
| timeout: 3600 | |||
| expire: 1800 #30分钟 | |||
| database: 5 | |||
| jedis: | |||
| pool: | |||
| max-active: 200 | |||
| max-idle: 100 | |||
| max-wait: -1 | |||
| min-idle: 0 | |||
| # SMS | |||
| aliyun: | |||
| sms: | |||
| accessKeyId: LTAI4G7ixY4AhvM35F8o3W3V | |||
| accessKeySecret: VfWqGb83qIQrS9us45utskl8itd7ry | |||
| product: Dysmsapi | |||
| domain: dysmsapi.aliyuncs.com | |||
| regionId: cn-hangzhou | |||
| dateFormat: yyyyMMdd | |||
| endpointName: cn-hangzhou | |||
| oss: | |||
| endpoint: oss-cn-beijing.aliyuncs.com | |||
| keyid: LTAI4G7ixY4AhvM35F8o3W3V | |||
| keysecret: VfWqGb83qIQrS9us45utskl8itd7ry | |||
| bucketname: formall | |||
| filehost: malinkcapi | |||
| filedomain: https://formall.oss-accelerate.aliyuncs.com | |||
| mail: | |||
| host: smtp.exmail.qq.com | |||
| username: service@iformall.com | |||
| password: jGvApygXN7wc5SzN # 授权密码 | |||
| properties: | |||
| mail: | |||
| smtp: | |||
| auth: true | |||
| starttls: | |||
| enable: true | |||
| socketFactory: | |||
| port: 465 | |||
| class: javax.net.ssl.SSLSocketFactory | |||
| # ROCKETMQ | |||
| rocketmq: | |||
| nameServer: 127.0.0.1:9876 | |||
| producer: | |||
| retry-times-when-send-async-failed: 0 | |||
| send-msg-timeout: 300000 | |||
| compress-msg-body-over-howmuch: 4096 | |||
| max-message-size: 4194304 | |||
| retry-another-broker-when-not-store-ok: false | |||
| retry-times-when-send-failed: 2 | |||
| # RABBITMQ | |||
| rabbitmq: | |||
| host: 101.200.130.134 | |||
| port: 5672 | |||
| username: fumao | |||
| password: f9l98 | |||
| publisher-confirms: true | |||
| publisher-returns: false | |||
| virtual-host: / | |||
| aliyunRocketmq: | |||
| accessKeyId: "LTAI4G7ixY4AhvM35F8o3W3V" | |||
| accessKeySecret: "VfWqGb83qIQrS9us45utskl8itd7ry" | |||
| groupId: "GID_P_1" | |||
| namesrvAddr: "http://MQ_INST_1796289517488555_Bcqaq2is.cn-beijing.mq-internal.aliyuncs.com:8080" | |||
| aws: | |||
| clientRegion: cn-northwest-1 | |||
| bucketName: iformall-net | |||
| access: ENC(3gx5ghDFBqGrEhO3Wf8aYmXsnwHO7Cj3HNKJGOeUj0o=) | |||
| secret: ENC(HVKIJwCJKVXLlUpGlQPwNqJOlnpxn4xYuy91SH0seTSm2uAttIQHvA49fXWWax90v5wloIk0QuU=) | |||
| #wechat: | |||
| # open: | |||
| # componentAppId: "wxdfc8fb4e62d6b52b" | |||
| # componentSecret: "98daa62b316dd6feabaad708327ce233" | |||
| # componentToken: "formall2018" | |||
| # componentAesKey: "htKq8EjBMPNndfZQK9JiFojFaqFwFpw42VfeWFtx7HN" | |||
| # redis: | |||
| # host: 101.201.103.81 | |||
| # port: 6379 | |||
| # password: ENC(xPFDlgd6v8zUhJMbcKc0KmmQiqs9qHtk) | |||
| # timeout: 3600 | |||
| # expire: 1800 #30分钟 | |||
| # database: 2 | |||
| # defaultExpiration: 2592000 # 默认生命周期30天 | |||
| # jedis: | |||
| # pool: | |||
| # max-active: 100 | |||
| # max-idle: 500 | |||
| # max-wait: -1 | |||
| # min-idle: 10 | |||
| wechat: | |||
| web: | |||
| appId: "wx091907dd0bfd3f6b" | |||
| secret: "2a2ca10738998b9ef92c1fe8a4d366a6" | |||
| url: "https://admintest.malls.iformall.com" | |||
| open: | |||
| componentAppId: wxdfc8fb4e62d6b52b | |||
| componentSecret: 98daa62b316dd6feabaad708327ce233 | |||
| componentToken: formall2018 | |||
| componentAesKey: htKq8EjBMPNndfZQK9JiFojFaqFwFpw42VfeWFtx7HN | |||
| redis: | |||
| host: 101.200.130.134 | |||
| port: 6379 | |||
| password: iF0rm@2l2ol9 | |||
| timeout: 3600 | |||
| expire: 1800 #30分钟 | |||
| database: 2 | |||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||
| jedis: | |||
| pool: | |||
| max-active: 100 | |||
| max-idle: 100 | |||
| max-wait: -1 | |||
| min-idle: 10 | |||
| jasypt: | |||
| encryptor: | |||
| password: oRqdnDbK5pj3eMmB | |||
| fm: | |||
| exception: true | |||
| exception_emails: xuxiaohu@iformall.com | |||
| deploy: 1 | |||
| open: true | |||
| upload_dir: /home/test/server/uploads/ | |||
| logging: | |||
| level: | |||
| com.iformall: debug | |||
| path: ./logs/c | |||
| @@ -0,0 +1,122 @@ | |||
| spring: | |||
| profiles: | |||
| include: aliyunRocketMQ | |||
| # JDBC | |||
| datasource: | |||
| url: jdbc:mysql://zc349w82qvn56ftl5e64-rw4rm.rwlb.rds.aliyuncs.com:3306/mallink?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&useSSL=false&useAffectedRows=true | |||
| username: ENC(nUefcxWYlMS/1cDxikIKwA==) | |||
| password: ENC(neToS+hzeFjgSFB/7UEl5qYnW2rUjrPq) | |||
| type: com.alibaba.druid.pool.DruidDataSource | |||
| driver-class-name: com.mysql.cj.jdbc.Driver | |||
| filters: stat | |||
| maxActive: 20 | |||
| initialSize: 1 | |||
| maxWait: 60000 | |||
| minIdle: 1 | |||
| timeBetweenEvictionRunsMillis: 28000 | |||
| minEvictableIdleTimeMillis: 28000 | |||
| validationQuery: select 'x' | |||
| testWhileIdle: true | |||
| testOnBorrow: false | |||
| testOnReturn: false | |||
| poolPreparedStatements: true | |||
| maxOpenPreparedStatements: 20 | |||
| # REDIS | |||
| redis: | |||
| host: r-2zeaglwf13qqmnllj5.redis.rds.aliyuncs.com | |||
| port: 6379 | |||
| password: mallone:iF0rm@2l2ol9 | |||
| timeout: 3600 | |||
| expire: 1800 #30分钟 | |||
| database: 1 | |||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||
| jedis: | |||
| pool: | |||
| max-active: 100 | |||
| max-idle: 100 | |||
| max-wait: -1 | |||
| min-idle: 10 | |||
| # SMS | |||
| aliyun: | |||
| sms: | |||
| accessKeyId: LTAI4G7ixY4AhvM35F8o3W3V | |||
| accessKeySecret: VfWqGb83qIQrS9us45utskl8itd7ry | |||
| product: Dysmsapi | |||
| domain: dysmsapi.aliyuncs.com | |||
| regionId: cn-hangzhou | |||
| dateFormat: yyyyMMdd | |||
| endpointName: cn-hangzhou | |||
| oss: | |||
| endpoint: oss-cn-beijing.aliyuncs.com | |||
| keyid: LTAI4G7ixY4AhvM35F8o3W3V | |||
| keysecret: VfWqGb83qIQrS9us45utskl8itd7ry | |||
| bucketname: formall | |||
| filehost: malinkadmin | |||
| filedomain: https://formall.oss-accelerate.aliyuncs.com | |||
| mail: | |||
| host: smtp.exmail.qq.com | |||
| username: sysadministor@iformall.com # 登陆密码sysAdmin1231 | |||
| password: SWqPekCEmhUYuYCd # 授权密码 | |||
| properties: | |||
| mail: | |||
| smtp: | |||
| auth: true | |||
| starttls: | |||
| enable: true | |||
| socketFactory: | |||
| port: 465 | |||
| class: javax.net.ssl.SSLSocketFactory | |||
| # RABBITMQ | |||
| rabbitmq: | |||
| host: localhost | |||
| port: 5672 | |||
| username: ENC(lRmLd6EzgeY1RT5ktcHv9g==) | |||
| password: ENC(gBI8mCjr3OC0v57jcnSb660Ux7mW03K2oePgvohhg7w=) | |||
| publisher-confirms: true | |||
| publisher-returns: false | |||
| virtual-host: / | |||
| aliyunRocketmq: | |||
| accessKeyId: "LTAI4G7ixY4AhvM35F8o3W3V" | |||
| accessKeySecret: "VfWqGb83qIQrS9us45utskl8itd7ry" | |||
| groupId: "GID_P_1" | |||
| namesrvAddr: "http://MQ_INST_1796289517488555_Bcqaq2is.cn-beijing.mq-internal.aliyuncs.com:8080" | |||
| aws: | |||
| clientRegion: cn-northwest-1 | |||
| bucketName: iformall-net | |||
| access: ENC(a6SN1sZ1enNL49ypiOXkg/pPPAnZD8H4buQFTTKN08s=) | |||
| secret: ENC(5P5ff4bTMJUbXVR4ZsM03UHzOKZ4+Zg5Iutcdkyp/Quny/oXg+A4KpfwEyGarlLu3vQMJahGP5M=) | |||
| wechat: | |||
| open: | |||
| componentAppId: ENC(b3JG0MUZgQfz5Zj+DC2ZM1zDeLOiGTmmeokfe2O8kaM=) | |||
| componentSecret: ENC(QVyc4BPGdnSjXGs2ivgpDBE1v8wPWHLLRMYI7Vv8uYwC0SiZHQz0QpyyQV/b48Pb) | |||
| componentToken: ENC(rkxj0733WxFFDLgA9x01m2s5Fi2L+0PC) | |||
| componentAesKey: ENC(EIbJUBpbYOrLb4YQ/HXLQmxlxgAqIp2ZmpnGICC8pu5xiTz3Cqfkbwd2S8raCcK/IvYcX2GmedI=) | |||
| redis: | |||
| host: r-2zeaglwf13qqmnllj5.redis.rds.aliyuncs.com | |||
| port: 6379 | |||
| password: mallone:iF0rm@2l2ol9 | |||
| timeout: 3600 | |||
| expire: 1800 #30分钟 | |||
| database: 2 | |||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||
| jedis: | |||
| pool: | |||
| max-active: 100 | |||
| max-idle: 100 | |||
| max-wait: -1 | |||
| min-idle: 10 | |||
| fm: | |||
| exception: true | |||
| exception_emails: houtaikaifa@iformall.com | |||
| deploy: 3 | |||
| open: true | |||
| upload_dir: /root/uploads/ | |||
| logging: | |||
| level: | |||
| com.iformall: debug | |||
| path: ./logs/c | |||
| @@ -0,0 +1,145 @@ | |||
| spring: | |||
| profiles: | |||
| include: aliyunRocketMQ | |||
| # JDBC | |||
| datasource: | |||
| url: jdbc:mysql://rm-2zel9i9t555zy7lftmo.mysql.rds.aliyuncs.com:3306/mallink?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&useSSL=false&useAffectedRows=true&allowMultiQueries=true | |||
| username: mallone | |||
| password: m@l9oNEl20#@ | |||
| type: com.alibaba.druid.pool.DruidDataSource | |||
| driver-class-name: com.mysql.cj.jdbc.Driver | |||
| filters: stat | |||
| maxActive: 20 | |||
| initialSize: 1 | |||
| maxWait: 60000 | |||
| minIdle: 1 | |||
| timeBetweenEvictionRunsMillis: 28000 | |||
| minEvictableIdleTimeMillis: 28000 | |||
| validationQuery: select 'x' | |||
| testWhileIdle: true | |||
| testOnBorrow: false | |||
| testOnReturn: false | |||
| poolPreparedStatements: true | |||
| maxOpenPreparedStatements: 20 | |||
| connectionProperties: "druid.stat.mergeSql=true;druid.stat.slowSqlMillis=60000" | |||
| # REDIS | |||
| redis: | |||
| host: r-2zeaglwf13qqmnllj5pd.redis.rds.aliyuncs.com | |||
| port: 6379 | |||
| password: mallone:iF0rm@2l2ol9 | |||
| timeout: 3600 | |||
| expire: 1800 #30分钟 | |||
| database: 1 | |||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||
| jedis: | |||
| pool: | |||
| max-active: 100 | |||
| max-idle: 20 | |||
| max-wait: -1 | |||
| min-idle: 0 | |||
| # SMS | |||
| aliyun: | |||
| sms: | |||
| accessKeyId: LTAI4G7ixY4AhvM35F8o3W3V | |||
| accessKeySecret: VfWqGb83qIQrS9us45utskl8itd7ry | |||
| product: Dysmsapi | |||
| domain: dysmsapi.aliyuncs.com | |||
| regionId: cn-hangzhou | |||
| dateFormat: yyyyMMdd | |||
| endpointName: cn-hangzhou | |||
| oss: | |||
| endpoint: oss-cn-beijing.aliyuncs.com | |||
| keyid: LTAI4G7ixY4AhvM35F8o3W3V | |||
| keysecret: VfWqGb83qIQrS9us45utskl8itd7ry | |||
| bucketname: formall | |||
| filehost: malinkadmin | |||
| filedomain: https://formall.oss-accelerate.aliyuncs.com | |||
| mail: | |||
| host: smtp.exmail.qq.com | |||
| username: zhengfangyuan@iformall.com | |||
| password: xnydCeUzofB2h8qp # 授权密码 | |||
| properties: | |||
| mail: | |||
| smtp: | |||
| auth: true | |||
| starttls: | |||
| enable: true | |||
| socketFactory: | |||
| port: 465 | |||
| class: javax.net.ssl.SSLSocketFactory | |||
| # RABBITMQ | |||
| rabbitmq: | |||
| host: localhost | |||
| port: 5672 | |||
| username: admin | |||
| password: ibh2D9R3v2DEN3gk | |||
| #username: ENC(lRmLd6EzgeY1RT5ktcHv9g==) | |||
| #password: ENC(gBI8mCjr3OC0v57jcnSb660Ux7mW03K2oePgvohhg7w=) | |||
| publisher-confirms: true | |||
| publisher-returns: false | |||
| virtual-host: / | |||
| # | |||
| aliyunRocketmq: | |||
| accessKeyId: "LTAI4G7ixY4AhvM35F8o3W3V" | |||
| accessKeySecret: "VfWqGb83qIQrS9us45utskl8itd7ry" | |||
| groupId: "GID_P_1" | |||
| namesrvAddr: "http://MQ_INST_1796289517488555_Bcqaq2is.cn-beijing.mq-internal.aliyuncs.com:8080" | |||
| flyway: | |||
| enabled: false | |||
| aws: | |||
| clientRegion: cn-northwest-1 | |||
| bucketName: iformall-net | |||
| access: AKIAOEHX2MJVBURWTB3Q | |||
| secret: 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 | |||
| #access: ENC(a6SN1sZ1enNL49ypiOXkg/pPPAnZD8H4buQFTTKN08s=) | |||
| #secret: ENC(5P5ff4bTMJUbXVR4ZsM03UHzOKZ4+Zg5Iutcdkyp/Quny/oXg+A4KpfwEyGarlLu3vQMJahGP5M=) | |||
| wechat: | |||
| web: | |||
| appId: "wx9cc4ca09eb20fe03" | |||
| secret: "af1d7f7a1268022a73cb4ce0b9cf0985" | |||
| url: "https://admin.malls.iformall.com" | |||
| open: | |||
| componentAppId: wx7f58f461ec1e2b4f | |||
| componentSecret: 7eb9b795606739b5526dd7f61d923f5a | |||
| componentToken: formall2018 | |||
| componentAesKey: htKq8EjBMPNndfZQK9JiFojFaqFwFpw42VfeWFtx7HN | |||
| #componentAppId: ENC(b3JG0MUZgQfz5Zj+DC2ZM1zDeLOiGTmmeokfe2O8kaM=) | |||
| #componentSecret: ENC(QVyc4BPGdnSjXGs2ivgpDBE1v8wPWHLLRMYI7Vv8uYwC0SiZHQz0QpyyQV/b48Pb) | |||
| #componentToken: ENC(rkxj0733WxFFDLgA9x01m2s5Fi2L+0PC) | |||
| #componentAesKey: ENC(EIbJUBpbYOrLb4YQ/HXLQmxlxgAqIp2ZmpnGICC8pu5xiTz3Cqfkbwd2S8raCcK/IvYcX2GmedI=) | |||
| redis: | |||
| host: r-2zeaglwf13qqmnllj5pd.redis.rds.aliyuncs.com | |||
| port: 6379 | |||
| password: mallone:iF0rm@2l2ol9 | |||
| timeout: 3600 | |||
| expire: 1800 #30分钟 | |||
| database: 2 | |||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||
| jedis: | |||
| pool: | |||
| max-active: 100 | |||
| max-idle: 100 | |||
| max-wait: -1 | |||
| min-idle: 10 | |||
| fm: | |||
| exception: true | |||
| exception_emails: houtaikaifa@iformall.com | |||
| deploy: 3 | |||
| open: true | |||
| upload_dir: /root/uploads/ | |||
| ueditor: | |||
| config: config.json | |||
| unified: true | |||
| upload-path: ./upload/ | |||
| url-prefix: "" | |||
| logging: | |||
| level: | |||
| com.iformall.mapper: debug | |||
| path: ./logs/admin | |||
| @@ -0,0 +1,100 @@ | |||
| spring: | |||
| profiles: | |||
| include: rabbitMQ | |||
| # JDBC | |||
| datasource: | |||
| url: jdbc:mysql://formalldb.cfqyqflkdlit.rds.cn-northwest-1.amazonaws.com.cn:3306/mallinkTest?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8&useSSL=false&useAffectedRows=true | |||
| username: ENC(Uc0AjgkytxHHCwZrmDASWg==) | |||
| password: ENC(nV4Mi3bEbBx0Fj7uUyYH55eTaqsFMjKvmNzagicH4pc=) | |||
| type: com.alibaba.druid.pool.DruidDataSource | |||
| driver-class-name: com.mysql.cj.jdbc.Driver | |||
| filters: stat | |||
| maxActive: 20 | |||
| initialSize: 1 | |||
| maxWait: 60000 | |||
| minIdle: 1 | |||
| timeBetweenEvictionRunsMillis: 28000 | |||
| minEvictableIdleTimeMillis: 28000 | |||
| validationQuery: select 'x' | |||
| testWhileIdle: true | |||
| testOnBorrow: false | |||
| testOnReturn: false | |||
| poolPreparedStatements: true | |||
| maxOpenPreparedStatements: 20 | |||
| # REDIS | |||
| redis: | |||
| host: 127.0.0.1 | |||
| port: 6379 | |||
| password: ENC(QFwqv3NshvvGhFPiP8rwhvbnxk+rFSqhJi8Pw6TogSg=) | |||
| timeout: 3600 | |||
| expire: 1800 #30分钟 | |||
| database: 1 | |||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||
| jedis: | |||
| pool: | |||
| max-active: 8 | |||
| max-idle: 8 | |||
| max-wait: -1 | |||
| min-idle: 0 | |||
| mail: | |||
| host: smtp.exmail.qq.com | |||
| username: ENC(TtJQE2C4cWo8CpVGMMl5hiy5eykepd96J5XjsW3Kj5fgP+6+5ctDNQ==) | |||
| password: ENC(Zh6A6kRtA2ABtH6nzdvsqQSO1/8p3mparJr8neI2BLU=) # 授权密码 | |||
| properties: | |||
| mail: | |||
| smtp: | |||
| auth: true | |||
| starttls: | |||
| enable: true | |||
| socketFactory: | |||
| port: 465 | |||
| class: javax.net.ssl.SSLSocketFactory | |||
| # RABBITMQ | |||
| rabbitmq: | |||
| host: 127.0.0.1 | |||
| port: 5672 | |||
| username: ENC(aSRr6mnSryEqzHHz1hJf1g==) | |||
| password: ENC(GnjF/mdqKdvmDYC0tIIso7+20/jBALPw39tiWCYJ4iw=) | |||
| publisher-confirms: true | |||
| publisher-returns: false | |||
| virtual-host: / | |||
| aws: | |||
| clientRegion: cn-northwest-1 | |||
| bucketName: iformall-net | |||
| access: ENC(NCLcmjwKpAWdn/abD17OKIY7yKepVLWzEpqRYUlURCw=) | |||
| secret: ENC(TRcZqql0Rq5PExlMeH/4WiZ/i02b8FXKmLTBChJmbluTa1uoLS9LrHyNEMrqe1DK+QgOAdvqGBo=) | |||
| wechat: | |||
| open: | |||
| componentAppId: ENC(hnH31XdNzArfMfikKgBFpqQuJUl6rVOPFFcAVyb595o=) | |||
| componentSecret: ENC(t/GUVX5L+U7LCwSvZ5WmxAnmTMrc/Uy1nljsrokuzzsBL2j6BEVnrS/n7DCdGc/G) | |||
| componentToken: ENC(gUF1m0YgCCI2IY54fX6sGLZVlCswA8tG) | |||
| componentAesKey: ENC(TYHcrIkICtfrCfGq4HW6s1b/pHf7OD2uyPN11SzJNB0acqJ/4JVX1nuljo/cAtgMG4O05TImLQc=) | |||
| redis: | |||
| host: 127.0.0.1 | |||
| port: 6379 | |||
| password: ENC(QFwqv3NshvvGhFPiP8rwhvbnxk+rFSqhJi8Pw6TogSg=) | |||
| timeout: 3600 | |||
| expire: 1800 #30分钟 | |||
| database: 2 | |||
| defaultExpiration: 2592000 # 默认生命周期30天 | |||
| jedis: | |||
| pool: | |||
| max-active: 100 | |||
| max-idle: 100 | |||
| max-wait: -1 | |||
| min-idle: 10 | |||
| fm: | |||
| exception: true | |||
| exception_emails: houtaikaifa@iformall.com | |||
| deploy: 2 | |||
| open: true | |||
| upload_dir: /home/ec2-user/server/uploads/ | |||
| logging: | |||
| level: | |||
| com.iformall: debug | |||
| path: ./logs/c | |||
| @@ -0,0 +1,54 @@ | |||
| server: | |||
| port: 7000 | |||
| servlet: | |||
| context-path: /C | |||
| spring: | |||
| application: | |||
| name: mallink | |||
| profiles: | |||
| active: dev | |||
| jackson: | |||
| date-format: yyyy-MM-dd HH:mm:ss | |||
| time-zone: GMT+8 | |||
| default-property-inclusion: non_null | |||
| # rocketmq: | |||
| # nameServer: 127.0.0.1:9876 | |||
| # producer: | |||
| # retry-times-when-send-async-failed: 0 | |||
| # send-msg-timeout: 300000 | |||
| # compress-msg-body-over-howmuch: 4096 | |||
| # max-message-size: 4194304 | |||
| # retry-another-broker-when-not-store-ok: false | |||
| # retry-times-when-send-failed: 2 | |||
| # MybatisPlus | |||
| mybatis-plus: | |||
| mapper-locations: classpath:mapper/*Mapper.xml | |||
| global-config: | |||
| db-config: | |||
| id-type: id_worker | |||
| field-strategy: not_null | |||
| db-type: mysql | |||
| configuration: | |||
| jdbc-type-for-null: 'null' | |||
| cache-enabled: false | |||
| call-setters-on-nulls: true | |||
| type-aliases-package: com.iformall.domain.po | |||
| type-enums-package: com.iformall.enums | |||
| # PageHelper | |||
| pagehelper: | |||
| helperDialect: mysql | |||
| reasonable: false | |||
| supportMethodsArguments: true | |||
| params: count=countSql | |||
| offset-as-page-num: true | |||
| page-size-zero: true | |||
| row-bounds-with-count: true | |||
| mapper: | |||
| mappers: | |||
| - com.iformall.common.CommonMapper | |||
| version: @project.version@ | |||
| @@ -0,0 +1,100 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <configuration scan="true" scanPeriod="10 seconds"> | |||
| <!-- 外部指定路径 --> | |||
| <springProperty scop="context" name="logPath" source="logging.path" /> | |||
| <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | |||
| <encoder> | |||
| <Pattern>[%date{yyyy-MM-dd HH:mm:ss.SSS}] [%-5level] --%mdc{client}%msg%n</Pattern> | |||
| </encoder> | |||
| </appender> | |||
| <appender name="TRACE_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |||
| <file>${logPath}/trace.log</file> | |||
| <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | |||
| <FileNamePattern>${logPath}/daily/trace.%d{yyyy-MM-dd}.log</FileNamePattern> | |||
| <maxHistory>30</maxHistory> <!-- 保留180天 --> | |||
| </rollingPolicy> | |||
| <layout> | |||
| <pattern>[%date{yyyy-MM-dd HH:mm:ss.SSS}] [%-5level] [%logger:%line]--%mdc{client} %msg%n</pattern> | |||
| </layout> | |||
| </appender> | |||
| <appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |||
| <file>${logPath}/info.log</file> | |||
| <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | |||
| <FileNamePattern>${logPath}/daily/info.%d{yyyy-MM-dd}.log</FileNamePattern> | |||
| <maxHistory>30</maxHistory> <!-- 保留180天 --> | |||
| </rollingPolicy> | |||
| <layout> | |||
| <pattern>[%date{yyyy-MM-dd HH:mm:ss.SSS}] [%-5level] [%logger:%line]--%mdc{client} %msg%n</pattern> | |||
| </layout> | |||
| <filter class="ch.qos.logback.classic.filter.LevelFilter"> | |||
| <level>INFO</level> | |||
| <onMatch>ACCEPT</onMatch> | |||
| <onMismatch>DENY</onMismatch> | |||
| </filter> | |||
| </appender> | |||
| <appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |||
| <file>${logPath}/debug.log</file> | |||
| <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | |||
| <FileNamePattern>${logPath}/daily/debug.%d{yyyy-MM-dd}.log</FileNamePattern> | |||
| <maxHistory>30</maxHistory> <!-- 保留180天 --> | |||
| </rollingPolicy> | |||
| <layout> | |||
| <pattern>[%date{yyyy-MM-dd HH:mm:ss.SSS}] [%-5level] [%logger:%line]--%mdc{client} %msg%n</pattern> | |||
| </layout> | |||
| <filter class="ch.qos.logback.classic.filter.LevelFilter"> | |||
| <level>DEBUG</level> | |||
| <onMatch>ACCEPT</onMatch> | |||
| <onMismatch>DENY</onMismatch> | |||
| </filter> | |||
| </appender> | |||
| <appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |||
| <file>${logPath}/warn.log</file> | |||
| <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | |||
| <FileNamePattern>${logPath}/daily/warn.%d{yyyy-MM-dd}.log</FileNamePattern> | |||
| <maxHistory>30</maxHistory> <!-- 保留180天 --> | |||
| </rollingPolicy> | |||
| <layout> | |||
| <pattern>[%date{yyyy-MM-dd HH:mm:ss.SSS}] [%-5level] [%logger:%line]--%mdc{client} %msg%n</pattern> | |||
| </layout> | |||
| <filter class="ch.qos.logback.classic.filter.LevelFilter"> | |||
| <level>WARN</level> | |||
| <onMatch>ACCEPT</onMatch> | |||
| <onMismatch>DENY</onMismatch> | |||
| </filter> | |||
| </appender> | |||
| <appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender"> | |||
| <file>${logPath}/error.log</file> | |||
| <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> | |||
| <FileNamePattern>${logPath}/daily/error.%d{yyyy-MM-dd}.log</FileNamePattern> | |||
| <maxHistory>30</maxHistory> <!-- 保留180天 --> | |||
| </rollingPolicy> | |||
| <layout> | |||
| <pattern>[%date{yyyy-MM-dd HH:mm:ss.SSS}] [%-5level] [%logger:%line]--%mdc{client} %msg%n</pattern> | |||
| </layout> | |||
| <filter class="ch.qos.logback.classic.filter.LevelFilter"> | |||
| <level>ERROR</level> | |||
| <onMatch>ACCEPT</onMatch> | |||
| <onMismatch>DENY</onMismatch> | |||
| </filter> | |||
| </appender> | |||
| <root level="TRACE"> | |||
| <appender-ref ref="TRACE_FILE" /> | |||
| <appender-ref ref="INFO_FILE" /> | |||
| <!-- <appender-ref ref="DEBUG_FILE" /> --> | |||
| <!-- <appender-ref ref="WARN_FILE" /> --> | |||
| <appender-ref ref="ERROR_FILE" /> | |||
| </root> | |||
| <root level="INFO"> | |||
| <appender-ref ref="STDOUT" /> | |||
| </root> | |||
| </configuration> | |||
| @@ -95,7 +95,7 @@ public class ActivitySchedule { | |||
| public void activityExipred() { | |||
| logger.info("活动报名结束任务"); | |||
| WxActivity activity = new WxActivity(); | |||
| activity.setStatus(EnumActivityStatus.INJECT_CAMPAIGN.getCode()); | |||
| // activity.setStatus(EnumActivityStatus.INJECT_CAMPAIGN.getCode()); | |||
| activity.setIsExpired(EnumActivityExpired.YES.getCode()); | |||
| activity.setUpdateTime(new Date()); | |||
| wxActivityMapper.activityExipred(activity); | |||
| @@ -105,30 +105,30 @@ public class ActivitySchedule { | |||
| /** | |||
| * 5分钟一次 | |||
| */ | |||
| @Scheduled(cron = "0 */5 * * * ?") | |||
| public void activityCompletion() { | |||
| logger.info("活动结束任务"); | |||
| WxActivity activity = new WxActivity(); | |||
| activity.setStatus(EnumActivityStatus.STATUS_TAKE_OFFF.getCode()); | |||
| activity.setUpdateTime(new Date()); | |||
| wxActivityMapper.activityCompletion(activity); | |||
| List<WxActivity> activityList = new ArrayList(); | |||
| //宣传页下线 | |||
| WxCampaign campaign = new WxCampaign(); | |||
| campaign.setStatus(EnumCampaignStatus.STATUS_THROW_IN.getCode()); | |||
| campaign.setType(EnumCampaignType.PAGEPATH.getCode()); | |||
| campaign.setProduceType(EnumCampaignProductType.ACTIVITY_JOIN.getCode()); | |||
| List<WxCampaign> campaignList = wxCampaignMapper.selectList(new QueryWrapper(campaign)); | |||
| for (WxCampaign wxCampaign : campaignList) { | |||
| WxActivity wxActivity = wxActivityMapper.selectById(wxCampaign.getProduceId()); | |||
| if (wxActivity.getStatus().equals(EnumActivityStatus.STATUS_TAKE_OFFF.getCode())) { | |||
| activityList.add(wxActivity); | |||
| wxCampaign.setStatus(EnumCampaignStatus.STATUS_TAKE_OFFF.getCode()); | |||
| wxCampaign.setUpdateTime(new Date()); | |||
| wxCampaignMapper.updateById(wxCampaign); | |||
| } | |||
| } | |||
| } | |||
| // @Scheduled(cron = "0 */5 * * * ?") | |||
| // public void activityCompletion() { | |||
| // logger.info("活动结束任务"); | |||
| // WxActivity activity = new WxActivity(); | |||
| // activity.setStatus(EnumActivityStatus.STATUS_TAKE_OFFF.getCode()); | |||
| // activity.setUpdateTime(new Date()); | |||
| // wxActivityMapper.activityCompletion(activity); | |||
| // List<WxActivity> activityList = new ArrayList(); | |||
| // //宣传页下线 | |||
| // WxCampaign campaign = new WxCampaign(); | |||
| // campaign.setStatus(EnumCampaignStatus.STATUS_THROW_IN.getCode()); | |||
| // campaign.setType(EnumCampaignType.PAGEPATH.getCode()); | |||
| // campaign.setProduceType(EnumCampaignProductType.ACTIVITY_JOIN.getCode()); | |||
| // List<WxCampaign> campaignList = wxCampaignMapper.selectList(new QueryWrapper(campaign)); | |||
| // for (WxCampaign wxCampaign : campaignList) { | |||
| // WxActivity wxActivity = wxActivityMapper.selectById(wxCampaign.getProduceId()); | |||
| // if (wxActivity.getStatus().equals(EnumActivityStatus.STATUS_TAKE_OFFF.getCode())) { | |||
| // activityList.add(wxActivity); | |||
| // wxCampaign.setStatus(EnumCampaignStatus.STATUS_TAKE_OFFF.getCode()); | |||
| // wxCampaign.setUpdateTime(new Date()); | |||
| // wxCampaignMapper.updateById(wxCampaign); | |||
| // } | |||
| // } | |||
| // } | |||
| } | |||
| @@ -155,8 +155,8 @@ jasypt: | |||
| password: oRqdnDbK5pj3eMmB | |||
| fm: | |||
| exception: false | |||
| exception_emails: houtaikaifa@iformall.com | |||
| exception: true | |||
| exception_emails: xuxiaohu@iformall.com | |||
| deploy: 1 | |||
| open: true | |||
| upload_dir: /home/test/server/uploads/ | |||
| @@ -34,8 +34,7 @@ | |||
| <groupId>com.iformall</groupId> | |||
| <artifactId>mybatis-multi-tenancy</artifactId> | |||
| <version>1.0</version> | |||
| </dependency> | |||
| </dependency> | |||
| </dependencies> | |||
| </project> | |||
| @@ -396,6 +396,8 @@ public enum ErrorCode{ | |||
| CREDIT_NOT_ENOUGH(13101, "积分不够扣减值"), | |||
| USER_NOT_MEMBER(13102, "该用户不是小程序会员"), | |||
| OUT_OF_CREDIT(13103, "超出最大积分"), | |||
| MEM_IS_SIGNIN(13104, "该用户已签到"), | |||
| MEM_MONTH_IS_USED(13105, "该用户本月已领取或未到领取条件"), | |||
| /** | |||
| @@ -538,6 +540,16 @@ public enum ErrorCode{ | |||
| ACTIVITY_TIME_ERROR(30005, "活动报名结束时间不能大于活动结束时间"), | |||
| ACTIVITY_WAIT_CONFIRMED(30006, "您报名的活动还在审核中"), | |||
| ACTIVITY_EXPIRED(30007, "您报名的活动已过期"), | |||
| ACTIVITY_SEND_ERROR_NOONLINE(30008, "活动投放到宣传页失败,活动未上线!"), | |||
| ACTIVITY_NOT_FOND(30009, "活动未找到!"), | |||
| ACTIVITY_JOIN_TIME_START(30010, "活动报名时间未开始!"), | |||
| ACTIVITY_JOIN_END_TIME_BEFORE(30011, "活动报名结束时间不能小于当前时间"), | |||
| ACTIVITY_END_TIME_BEFORE(30012, "活动结束时间不能小于当前时间"), | |||
| ACTIVITY_NOT_JOIN(30013, "该活动不需要报名!"), | |||
| ACTIVITY_JOIN_IS_SIGNIN(30014, "用户已签到!"), | |||
| ACTIVITY_JOIN_NOT_FOND(30015, "活动报名未找到!"), | |||
| ACTIVITY_NOT_UPDATE(30016, "下线状态,不允许修改!"), | |||
| ACTIVITY_TIME_END(30017, "活动已结束"), | |||
| /** | |||
| * 文件上传 | |||
| @@ -76,6 +76,13 @@ public class BaseMyBatisConfiguration { | |||
| basicInfoSharding.setRule(EnumShardingRule.HASH.getCode()); | |||
| shardingList.add(basicInfoSharding); | |||
| ShardingSphere basicSignSharding = new ShardingSphere(); | |||
| basicSignSharding.setColumn("tenant_id"); | |||
| basicSignSharding.setTableName("wx_c_user_basic_sign"); | |||
| basicSignSharding.setCount(100); | |||
| basicSignSharding.setRule(EnumShardingRule.HASH.getCode()); | |||
| shardingList.add(basicSignSharding); | |||
| ShardingSphere wxbasicChildSharding = new ShardingSphere(); | |||
| wxbasicChildSharding.setColumn("tenant_id"); | |||
| wxbasicChildSharding.setTableName("wx_c_user_basic_child"); | |||
| @@ -35,6 +35,13 @@ public class WxActivity extends TenantEntity { | |||
| private Integer personLimit; | |||
| @io.swagger.annotations.ApiModelProperty(value = "活动正文", name = "detail") | |||
| private String detail; | |||
| @io.swagger.annotations.ApiModelProperty(value = "活动类型(是否需要报名1是0否)", name = "activityType") | |||
| private Integer activityType; | |||
| @io.swagger.annotations.ApiModelProperty(value = "报名审核 1是0否(activity_type=1时必填)", name = "signupExamine") | |||
| private Integer signupExamine; | |||
| @io.swagger.annotations.ApiModelProperty(value = "活动开始报名时间", name = "startTime") | |||
| private Date startTime; | |||
| @io.swagger.annotations.ApiModelProperty(value = "活动结束报名时间", name = "endTime") | |||
| @@ -72,11 +79,11 @@ public class WxActivity extends TenantEntity { | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value = "开始时间", name = "starttime") | |||
| private Date starttime; | |||
| private Date startDate; | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value = "结束时间", name = "endtime") | |||
| private Date endtime; | |||
| private Date endDate; | |||
| @TableField(exist = false) | |||
| @@ -115,5 +122,9 @@ public class WxActivity extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value = "常见问题选择", name = "selectques") | |||
| private String selectques; | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value = "报名状态", name = "joinStatus") | |||
| private Integer joinStatus; | |||
| } | |||
| @@ -8,6 +8,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.base.TenantEntityWithoutFinalTenantId; | |||
| import com.iformall.utils.Constant; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import lombok.ToString; | |||
| @@ -24,6 +25,7 @@ import java.util.Objects; | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class WxCUserBasicInfo extends TenantEntityWithoutFinalTenantId { | |||
| @Excel(name="会员码",width = 20,orderNum = "1") | |||
| protected Long id; | |||
| @JsonIgnore | |||
| @@ -43,45 +45,45 @@ public class WxCUserBasicInfo extends TenantEntityWithoutFinalTenantId { | |||
| return shardFinalTableSuffix; | |||
| } | |||
| @Excel(name="姓名",width = 20,orderNum = "1") | |||
| @Excel(name="姓名",width = 20,orderNum = "2") | |||
| @NotNull | |||
| @io.swagger.annotations.ApiModelProperty(value="用户姓名",name="name") | |||
| private String name; | |||
| @Excel(name="性别",width = 20,replace = { "保密_0", "男_1", "女_2"},orderNum = "2") | |||
| @Excel(name="性别",width = 20,replace = { "保密_0", "男_1", "女_2"},orderNum = "3") | |||
| @NotNull | |||
| @io.swagger.annotations.ApiModelProperty(value="性别:0:保密 1.男 2女",name="sex") | |||
| private Integer sex; | |||
| @Excel(name = "手机号*", width = 20, orderNum = "3") | |||
| @Excel(name = "手机号*", width = 20, orderNum = "4") | |||
| @io.swagger.annotations.ApiModelProperty(value="微信用户绑定的手机号",name="phone") | |||
| @NotNull | |||
| private String phone; | |||
| @Excel(name="微信昵称",width = 20,orderNum = "4") | |||
| @Excel(name="微信昵称",width = 20,orderNum = "5") | |||
| @io.swagger.annotations.ApiModelProperty(value="用户昵称",name="nickName") | |||
| private String nickName; | |||
| @io.swagger.annotations.ApiModelProperty(value="用户头像地址",name="avatarUrl") | |||
| private String avatarUrl; | |||
| @Excel(name="学历",width = 20,orderNum = "5") | |||
| @Excel(name="学历",width = 20,orderNum = "6") | |||
| @NotNull | |||
| @io.swagger.annotations.ApiModelProperty(value="学历",name="education") | |||
| private String education; | |||
| @Excel(name="生日",width = 20,format="yyyy-MM-dd",orderNum = "6") | |||
| @Excel(name="生日",width = 20,format="yyyy-MM-dd",orderNum = "7") | |||
| @NotNull | |||
| @io.swagger.annotations.ApiModelProperty(value="出生日期",name="birthdate") | |||
| private Date birthdate; | |||
| @Excel(name="地址",width = 20,orderNum = "7") | |||
| @Excel(name="地址",width = 20,orderNum = "8") | |||
| @TableField(exist = false) | |||
| private String addressStr; | |||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | |||
| private Date updateDate; | |||
| @Excel(name="上次活跃时间",width = 20,format="yyyy-MM-dd", orderNum = "8") | |||
| @Excel(name="上次活跃时间",width = 20,format="yyyy-MM-dd", orderNum = "9") | |||
| @io.swagger.annotations.ApiModelProperty(value="上次活跃时间",name="activeTime") | |||
| private Date activeTime; | |||
| @TableField(exist = false) | |||
| @@ -89,7 +91,7 @@ public class WxCUserBasicInfo extends TenantEntityWithoutFinalTenantId { | |||
| @TableField(exist = false) | |||
| private Date activeEndTime; | |||
| @Excel(name="注册时间",width = 20,format="yyyy-MM-dd", orderNum = "9") | |||
| @Excel(name="注册时间",width = 20,format="yyyy-MM-dd", orderNum = "10") | |||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | |||
| private Date createDate; | |||
| @@ -116,12 +118,12 @@ public class WxCUserBasicInfo extends TenantEntityWithoutFinalTenantId { | |||
| @io.swagger.annotations.ApiModelProperty(value="积分",name="credit") | |||
| private Integer credit; | |||
| @Excel(name="扣减总积分",width = 20, orderNum = "12") | |||
| @Excel(name="扣减总积分",width = 20, orderNum = "13") | |||
| @io.swagger.annotations.ApiModelProperty(value="扣减积分",name="lesCredit") | |||
| @TableField(exist = false) | |||
| private Integer lesCredit; | |||
| @Excel(name="增长总积分",width = 20, orderNum = "12") | |||
| @Excel(name="增长总积分",width = 20, orderNum = "14") | |||
| @io.swagger.annotations.ApiModelProperty(value="增加积分",name="addCredit") | |||
| @TableField(exist = false) | |||
| private Integer addCredit; | |||
| @@ -132,8 +134,23 @@ public class WxCUserBasicInfo extends TenantEntityWithoutFinalTenantId { | |||
| @io.swagger.annotations.ApiModelProperty(value = "状态0正常1锁定", name = "status") | |||
| private Integer status; | |||
| @io.swagger.annotations.ApiModelProperty(value="二维码",name="qrCode") | |||
| private String qrCode; | |||
| public String getWeappPath() { | |||
| if(id == null) | |||
| return Constant.mainPageUrl; | |||
| return Constant.mainPageUrl + "?type=in&UId=" + id; | |||
| } | |||
| public String getWeappScene() { | |||
| if(id == null) | |||
| return ""; | |||
| return "t:in_u:" + id; | |||
| } | |||
| @TableField(exist = false) | |||
| @Excel(name="标签",width = 50,orderNum = "10") | |||
| @Excel(name="标签",width = 50,orderNum = "15") | |||
| private String tagNames; | |||
| @@ -0,0 +1,71 @@ | |||
| package com.iformall.domain.po; | |||
| import com.baomidou.mybatisplus.annotation.TableField; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import lombok.ToString; | |||
| import java.util.Date; | |||
| @TableName(value = "wx_c_user_basic_sign") | |||
| @Data | |||
| @ToString(callSuper = true) | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class WxCUserBasicSign extends TenantEntity { | |||
| @TableField(exist = false) | |||
| public static final Integer SIGNIN_TYPE = 1; | |||
| protected Long id; | |||
| @io.swagger.annotations.ApiModelProperty(value="userId",name="userId") | |||
| private Long userId; | |||
| @io.swagger.annotations.ApiModelProperty(value="1:签到",name="type") | |||
| private Integer type; | |||
| @io.swagger.annotations.ApiModelProperty(value="签到时间",name="signinDate") | |||
| private Date signinDate; | |||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | |||
| private Date createDate; | |||
| @io.swagger.annotations.ApiModelProperty(value="修改时间",name="updateDate") | |||
| private Date updateDate; | |||
| @io.swagger.annotations.ApiModelProperty(value="截止当前签到时间当月连续签到天数",name="continueMonthSign") | |||
| private Integer continueMonthSign; | |||
| @io.swagger.annotations.ApiModelProperty(value="截止当前签到时间当月累计签到天数",name="countMonthSign") | |||
| private Integer countMonthSign; | |||
| @io.swagger.annotations.ApiModelProperty(value="截止当前签到时间当年连续签到天数",name="continueYearSign") | |||
| private Integer continueYearSign; | |||
| @io.swagger.annotations.ApiModelProperty(value="截止当前签到时间当年累计签到天数",name="countYearSign") | |||
| private Integer countYearSign; | |||
| @io.swagger.annotations.ApiModelProperty(value="截止当前签到时间连续签到天数",name="continueSign") | |||
| private Integer continueSign; | |||
| @io.swagger.annotations.ApiModelProperty(value="截止当前签到时间累计签到天数",name="countSign") | |||
| private Integer countSign; | |||
| @io.swagger.annotations.ApiModelProperty(value="备注",name="mark") | |||
| private String mark; | |||
| @TableField(exist = false) | |||
| private Date startDate; | |||
| @TableField(exist = false) | |||
| private Date endDate; | |||
| @TableField(exist = false) | |||
| private Integer begin; | |||
| @TableField(exist = false) | |||
| private Integer limit; | |||
| @TableField(exist = false) | |||
| private Integer credit; | |||
| } | |||
| @@ -1,8 +1,8 @@ | |||
| package com.iformall.domain.po; | |||
| import cn.afterturn.easypoi.excel.annotation.Excel; | |||
| import com.baomidou.mybatisplus.annotation.TableField; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.enums.EnumCUserFrom; | |||
| import com.iformall.enums.EnumUserType; | |||
| @@ -14,30 +14,17 @@ import lombok.ToString; | |||
| import java.util.Date; | |||
| @TableName(value = "wx_c_user_from") | |||
| @JsonIgnoreProperties(ignoreUnknown = true) | |||
| @Data | |||
| @ToString(callSuper = true) | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class WxCUserFrom extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="cUserId",name="cUserId") | |||
| protected Long cUserId; | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value="cUserNickName",name="cUserNickName") | |||
| protected String cUserNickName; | |||
| @io.swagger.annotations.ApiModelProperty(value="二维码来源,小程序",name="scene") | |||
| private String scene; | |||
| @io.swagger.annotations.ApiModelProperty(value="渠道,小程序",name="sceneAddress") | |||
| private String sceneAddress; | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value="sceneAddress描述",name="sceneAddressDesc") | |||
| private String sceneAddressDesc; | |||
| protected Long id; | |||
| @io.swagger.annotations.ApiModelProperty(value="EnumCUserFrom",name="fromType") | |||
| private Integer fromType; | |||
| @TableField(exist = false) | |||
| @Excel(name = "来源", width = 20, orderNum = "1") | |||
| @io.swagger.annotations.ApiModelProperty(value="fromType描述",name="fromTypeDesc") | |||
| private String fromTypeDesc; | |||
| public String getFromTypeDesc(){ | |||
| @@ -50,20 +37,45 @@ public class WxCUserFrom extends TenantEntity { | |||
| return fromTypeDesc; | |||
| } | |||
| @io.swagger.annotations.ApiModelProperty(value="cUserId",name="cUserId") | |||
| private Long cUserId; | |||
| @TableField(exist = false) | |||
| @Excel(name = "用户昵称", width = 20, orderNum = "2") | |||
| @io.swagger.annotations.ApiModelProperty(value="userNickName",name="userNickName") | |||
| private String userNickName; | |||
| @TableField(exist = false) | |||
| @Excel(name = "用户电话", width = 20, orderNum = "3") | |||
| @io.swagger.annotations.ApiModelProperty(value="userPhone",name="userPhone") | |||
| private String userPhone; | |||
| @io.swagger.annotations.ApiModelProperty(value="二维码来源,小程序",name="scene") | |||
| private String scene; | |||
| @io.swagger.annotations.ApiModelProperty(value="渠道,小程序",name="sceneAddress") | |||
| private String sceneAddress; | |||
| @TableField(exist = false) | |||
| @Excel(name = "用户来源方式", width = 20, orderNum = "4") | |||
| @io.swagger.annotations.ApiModelProperty(value="sceneAddress描述",name="sceneAddressDesc") | |||
| private String sceneAddressDesc; | |||
| @io.swagger.annotations.ApiModelProperty(value="来源ID",name="fromId") | |||
| protected Long fromId; | |||
| private Long fromId; | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value="来源Name",name="fromName") | |||
| protected String fromName; | |||
| private String fromName; | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value="来源phone",name="fromPhone") | |||
| private String fromPhone; | |||
| @io.swagger.annotations.ApiModelProperty(value="是否新用户(0:否1:是)EnumYesOrNo",name="isNewUser") | |||
| private Integer isNewUser; | |||
| @TableField(exist = false) | |||
| @Excel(name = "是否新用户", width = 20, orderNum = "5") | |||
| @io.swagger.annotations.ApiModelProperty(value="是否新用户",name="isNewUserStr") | |||
| private String isNewUserStr; | |||
| public String getIsNewUserStr(){ | |||
| if(this.getIsNewUser() != null){ | |||
| EnumYesOrNo anEnum = EnumYesOrNo.getEnum(this.getFromType()); | |||
| EnumYesOrNo anEnum = EnumYesOrNo.getEnum(this.getIsNewUser()); | |||
| if(anEnum != null){ | |||
| isNewUserStr = anEnum.getMessage(); | |||
| } | |||
| @@ -78,7 +90,7 @@ public class WxCUserFrom extends TenantEntity { | |||
| private String shareUserTypeDesc; | |||
| public String getShareUserTypeDesc(){ | |||
| if(this.getShareUserType() != null){ | |||
| EnumUserType anEnum = EnumUserType.getEnum(this.getFromType()); | |||
| EnumUserType anEnum = EnumUserType.getEnum(this.getShareUserType()); | |||
| if(anEnum != null){ | |||
| shareUserTypeDesc = anEnum.getMessage(); | |||
| } | |||
| @@ -87,18 +99,26 @@ public class WxCUserFrom extends TenantEntity { | |||
| } | |||
| @io.swagger.annotations.ApiModelProperty(value="分享者",name="shareUser") | |||
| protected Long shareUser; | |||
| private Long shareUser; | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value="分享者",name="shareUserName") | |||
| protected String shareUserName; | |||
| private String shareUserName; | |||
| @Excel(name = "进入时间", width = 20, format="yyyy-MM-dd HH:mm:ss", orderNum = "6") | |||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | |||
| private Date createDate; | |||
| @TableField(exist = false) | |||
| private Date startDate; | |||
| @TableField(exist = false) | |||
| private Date endDate; | |||
| @TableField(exist = false) | |||
| protected Date startDate; | |||
| private Integer begin; | |||
| @TableField(exist = false) | |||
| protected Date endDate; | |||
| private Integer limit; | |||
| } | |||
| @@ -1,9 +1,13 @@ | |||
| package com.iformall.domain.po; | |||
| import com.alibaba.fastjson.JSONArray; | |||
| import com.baomidou.mybatisplus.annotation.TableField; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import com.google.gson.JsonObject; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import java.math.BigDecimal; | |||
| import java.util.*; | |||
| @@ -31,5 +35,21 @@ public class WxMallFloor extends TenantEntity { | |||
| private Date createDate; | |||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | |||
| private Date updateDate; | |||
| @io.swagger.annotations.ApiModelProperty(value="地图",name="floorMap") | |||
| private String floorMap; | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="") | |||
| private List<Map> floorMaps; | |||
| public List<Map> getFloorMaps(){ | |||
| if(StringUtils.isNotBlank(floorMap)){ | |||
| if(floorMaps == null || floorMaps.size() == 0){ | |||
| floorMaps = JSONArray.parseArray(floorMap,Map.class); | |||
| } | |||
| } | |||
| return floorMaps; | |||
| } | |||
| } | |||
| @@ -0,0 +1,25 @@ | |||
| package com.iformall.domain.po; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import java.util.Date; | |||
| @TableName(value = "wx_mall_ocr_model") | |||
| @Data | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class WxMallOcrModel extends TenantEntity { | |||
| private static final long serialVersionUID = 1L; | |||
| protected Long id; | |||
| @io.swagger.annotations.ApiModelProperty(value="商户编号",name="mallId") | |||
| private Long mallId; | |||
| @io.swagger.annotations.ApiModelProperty(value="ocr模板编号",name="ocrModelId") | |||
| private Long ocrModelId; | |||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createTime") | |||
| private Date createTime; | |||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="updateTime") | |||
| private Date updateTime; | |||
| } | |||
| @@ -0,0 +1,25 @@ | |||
| package com.iformall.domain.po; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import java.util.Date; | |||
| @TableName(value = "wx_merchant_ocr_model") | |||
| @Data | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class WxMerchantOcrModel extends TenantEntity { | |||
| private static final long serialVersionUID = 1L; | |||
| protected Long id; | |||
| @io.swagger.annotations.ApiModelProperty(value="商户编号",name="merchantId") | |||
| private Long merchantId; | |||
| @io.swagger.annotations.ApiModelProperty(value="ocr模板编号",name="ocrModelId") | |||
| private Long ocrModelId; | |||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createTime") | |||
| private Date createTime; | |||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="updateTime") | |||
| private Date updateTime; | |||
| } | |||
| @@ -0,0 +1,28 @@ | |||
| package com.iformall.domain.po; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import java.util.Date; | |||
| @TableName(value = "wx_ocr_model") | |||
| @Data | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class WxOcrModel extends BaseEntity { | |||
| private static final long serialVersionUID = 1L; | |||
| protected Long id; | |||
| @io.swagger.annotations.ApiModelProperty(value="语言定义,默认iformallLang",name="langCode") | |||
| private String langCode; | |||
| @io.swagger.annotations.ApiModelProperty(value="字库名称",name="fontName") | |||
| private String fontName; | |||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createTime") | |||
| private Date createTime; | |||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateTime") | |||
| private Date updateTime; | |||
| @io.swagger.annotations.ApiModelProperty(value="备注",name="remark") | |||
| private String remark; | |||
| @io.swagger.annotations.ApiModelProperty(value="0-有效 1-无效",name="status") | |||
| private Integer status; | |||
| } | |||
| @@ -48,7 +48,6 @@ public class WxScoreRules extends BaseTenantEntity { | |||
| " {\"businessId\":6,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}" + | |||
| "]}," + | |||
| "{\"id\":3,\"limit\":1,\"step\":1,\"score\":0,\"desc\":\"绑定车牌1个\"}," + | |||
| "{\"id\":5,\"limit\":1,\"step\":1,\"score\":0,\"desc\":\"授权个人信息\"}," + | |||
| "{\"id\":6,\"limit\":1,\"step\":1,\"score\":0,\"desc\":\"授权手机号\"}," + | |||
| "{\"id\":7,\"limit\":1,\"step\":1,\"score\":0,\"desc\":\"编辑个人信息\"}" + | |||
| "]"; | |||
| @@ -56,7 +55,7 @@ public class WxScoreRules extends BaseTenantEntity { | |||
| @TableField(exist = false) | |||
| private static final String creditDefaultRules = | |||
| "[" + | |||
| "{\"id\":1,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"每日登陆\"}," + | |||
| // "{\"id\":1,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"每日登陆\"}," + | |||
| "{\"id\":2,\"childs\":[" + | |||
| " {\"businessId\":1,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}," + | |||
| " {\"businessId\":2,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}," + | |||
| @@ -71,10 +70,12 @@ public class WxScoreRules extends BaseTenantEntity { | |||
| " {\"businessId\":6,\"limit\":0,\"step\":1,\"score\":0 ,\"desc\":\"线上交易1元\"}" + | |||
| "]}," + | |||
| "{\"id\":3,\"limit\":1,\"step\":1,\"score\":0,\"desc\":\"绑定车牌1个\"}," + | |||
| "{\"id\":5,\"limit\":1,\"step\":1,\"score\":0,\"desc\":\"授权个人信息\"}," + | |||
| "{\"id\":6,\"limit\":1,\"step\":1,\"score\":0,\"desc\":\"授权手机号\"}," + | |||
| "{\"id\":7,\"limit\":1,\"step\":1,\"score\":0,\"desc\":\"编辑个人信息\"}," + | |||
| "{\"id\":8,\"limit\":1,\"step\":1,\"score\":0,\"desc\":\"编辑个人信息\"}" + | |||
| "{\"id\": 17, \"desc\": \"每日签到\", \"step\": 1, \"limit\": 1, \"score\": 0},"+ | |||
| "{\"id\": 18, \"desc\": \"连续签到7天\", \"step\": 1, \"limit\": 1, \"score\": 0},"+ | |||
| "{\"id\": 19, \"desc\": \"连续签到14天\", \"step\": 1, \"limit\": 1, \"score\": 0},"+ | |||
| "{\"id\": 20, \"desc\": \"连续签到28天\", \"step\": 1, \"limit\": 1, \"score\": 0},"+ | |||
| "]"; | |||
| @TableField(exist = false) | |||
| @@ -86,6 +87,15 @@ public class WxScoreRules extends BaseTenantEntity { | |||
| @TableField(exist = false) | |||
| public static final String SCORE = "score"; | |||
| @TableField(exist = false) | |||
| public static final String CYCLE = "cycle";//EnumScoreScaleRules会员日周期(1:周;2:月;3:年) | |||
| @TableField(exist = false) | |||
| public static final String CYCLE_START = "cycleStart";//周期开始 | |||
| @TableField(exist = false) | |||
| public static final String CYCLE_END = "cycleEnd";//周期结束 | |||
| @TableField(exist = false) | |||
| public static final String CYCLE_SCALE = "cycleScale";//倍率 | |||
| protected Long id; | |||
| @@ -19,6 +19,15 @@ public class WxWiWideInfo extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="迈外迪key",name="wiwideKey") | |||
| private String wiwideKey; | |||
| @io.swagger.annotations.ApiModelProperty(value="加密key,新版本接口需要",name="signKey") | |||
| private String signKey; | |||
| @io.swagger.annotations.ApiModelProperty(value="登陆username",name="userName") | |||
| private String userName; | |||
| @io.swagger.annotations.ApiModelProperty(value="登陆password",name="password") | |||
| private String password; | |||
| @io.swagger.annotations.ApiModelProperty(value="迈外迪url",name="wiwideUrl") | |||
| private String wiwideUrl; | |||
| @@ -31,5 +40,8 @@ public class WxWiWideInfo extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="迈外迪信息类型列表,1,支持客流 2,支持wifi",name="capability") | |||
| private String capability; | |||
| @io.swagger.annotations.ApiModelProperty(value="是否是老平台 0-老平台 1-新平台",name="oldPlat") | |||
| private Integer oldPlat; | |||
| } | |||
| @@ -205,6 +205,10 @@ public class BaseEntity implements Serializable { | |||
| ReportDate_ASC("`report_date` ASC"), | |||
| ReportDate_DESC("`report_date` DESC"), | |||
| ActivityStartTime_ASC("`activity_start_time` ASC"), | |||
| ActivityStartTime_DESC("`activity_start_time` DESC"), | |||
| ; | |||
| private String value; | |||
| @@ -1,6 +1,7 @@ | |||
| package com.iformall.domain.po.base; | |||
| import com.baomidou.mybatisplus.annotation.TableField; | |||
| import com.fasterxml.jackson.annotation.JsonIgnore; | |||
| import com.fasterxml.jackson.annotation.JsonProperty; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| @@ -26,7 +27,7 @@ public class BaseTenantEntity extends BaseEntity { | |||
| protected String finalTenantId; | |||
| public String getFinalTenantId() { | |||
| if (!StringUtils.isBlank(parentTenantId)) { | |||
| if (StringUtils.isNotBlank(parentTenantId)) { | |||
| return parentTenantId; | |||
| } | |||
| return tenantId; | |||
| @@ -35,6 +36,17 @@ public class BaseTenantEntity extends BaseEntity { | |||
| public void setFinalTenantId(String finalTenantId) { | |||
| this.finalTenantId = finalTenantId; | |||
| } | |||
| @JsonIgnore | |||
| @TableField(exist = false) | |||
| protected String shardFinalTableSuffix; | |||
| public String getShardFinalTableSuffix(){ | |||
| if(StringUtils.isNotBlank(getFinalTenantId())){ | |||
| shardFinalTableSuffix = "_" + Integer.parseInt(getFinalTenantId())%100; | |||
| } | |||
| return shardFinalTableSuffix; | |||
| } | |||
| @TableField(exist = false) | |||
| @JsonProperty(access = JsonProperty.Access.READ_ONLY) | |||
| @@ -1,5 +1,6 @@ | |||
| package com.iformall.domain.po.msg; | |||
| import com.iformall.domain.po.WxCUserFrom; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import lombok.ToString; | |||
| @@ -11,15 +12,7 @@ public class FmInsideCLoginMsg extends BaseMsg{ | |||
| private static final long serialVersionUID = 1L; | |||
| @io.swagger.annotations.ApiModelProperty(value = "id", name = "id") | |||
| private Long id; | |||
| @io.swagger.annotations.ApiModelProperty(value = "租户ID", name = "tenantId") | |||
| private String tenantId; | |||
| @io.swagger.annotations.ApiModelProperty(value="父租户id",name="parentTenantId") | |||
| private String parentTenantId; | |||
| @io.swagger.annotations.ApiModelProperty(value = "用户ID", name = "userId") | |||
| private Long userId; | |||
| private WxCUserFrom wxCUserFrom; | |||
| } | |||
| @@ -0,0 +1,32 @@ | |||
| package com.iformall.domain.vo; | |||
| import com.baomidou.mybatisplus.annotation.TableField; | |||
| import lombok.Data; | |||
| @Data | |||
| public class MerchantCreditRankingVo { | |||
| private Long merchantId; | |||
| @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | |||
| protected String tenantId; | |||
| @io.swagger.annotations.ApiModelProperty(value="父租户ID",name="parentTenantId") | |||
| protected String parentTenantId; | |||
| @io.swagger.annotations.ApiModelProperty(value = "商户名", name = "merchantName") | |||
| private String merchantName; | |||
| @io.swagger.annotations.ApiModelProperty(value = "增加总积分", name = "sumAddCredit") | |||
| private Integer sumAddCredit; | |||
| @io.swagger.annotations.ApiModelProperty(value = "消耗总积分", name = "sumLesCredit") | |||
| private Integer sumLesCredit; | |||
| @io.swagger.annotations.ApiModelProperty(value = "增加总人数", name = "countAddCreditUser") | |||
| private Integer countAddCreditUser; | |||
| @io.swagger.annotations.ApiModelProperty(value = "消耗总人数", name = "countLesCreditUser") | |||
| private Integer countLesCreditUser; | |||
| } | |||
| @@ -0,0 +1,81 @@ | |||
| package com.iformall.domain.vo; | |||
| import cn.afterturn.easypoi.excel.annotation.Excel; | |||
| import com.baomidou.mybatisplus.annotation.TableField; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.enums.EnumCUserFrom; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import lombok.ToString; | |||
| import java.util.Date; | |||
| @Data | |||
| @ToString(callSuper = true) | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class WxCUserFromVo extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="EnumCUserFrom",name="fromType") | |||
| private Integer fromType; | |||
| @Excel(name = "来源", width = 20, orderNum = "1") | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value="fromType描述",name="fromTypeDesc") | |||
| private String fromTypeDesc; | |||
| public String getFromTypeDesc(){ | |||
| if(this.getFromType() != null){ | |||
| EnumCUserFrom anEnum = EnumCUserFrom.getEnum(this.getFromType()); | |||
| if(anEnum != null){ | |||
| fromTypeDesc = anEnum.getMessage(); | |||
| } | |||
| } | |||
| return fromTypeDesc; | |||
| } | |||
| @io.swagger.annotations.ApiModelProperty(value="来源ID",name="fromId") | |||
| private Long fromId; | |||
| @Excel(name = "用户昵称/店铺名称", width = 20, orderNum = "2") | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value="来源Name",name="fromName") | |||
| private String fromName; | |||
| @Excel(name = "(用户/店铺)联系方式", width = 20, orderNum = "3") | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value="来源phone",name="fromPhone") | |||
| private String fromPhone; | |||
| @Excel(name = "推广人次", width = 20, orderNum = "4") | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value="推广人次",name="visits") | |||
| private Integer visits; | |||
| @Excel(name = "触达用户", width = 20, orderNum = "5") | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value="触达用户",name="reachUser") | |||
| private Integer reachUser; | |||
| @Excel(name = "触达新用户", width = 20, orderNum = "6") | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value="触达新用户",name="newUser") | |||
| private Integer newUser; | |||
| @Excel(name = "触达老用户", width = 20, orderNum = "7") | |||
| @TableField(exist = false) | |||
| @io.swagger.annotations.ApiModelProperty(value="触达老用户",name="oldUser") | |||
| private Integer oldUser; | |||
| public Integer getOldUser(){ | |||
| if(this.getReachUser() != null && this.getNewUser() != null){ | |||
| oldUser = this.getReachUser() - this.getNewUser(); | |||
| } | |||
| return oldUser; | |||
| } | |||
| @TableField(exist = false) | |||
| private Date startDate; | |||
| @TableField(exist = false) | |||
| private Date endDate; | |||
| @TableField(exist = false) | |||
| private Integer begin; | |||
| @TableField(exist = false) | |||
| private Integer limit; | |||
| } | |||
| @@ -6,10 +6,17 @@ package com.iformall.enums; | |||
| */ | |||
| public enum EnumActivityEnrollStatus { | |||
| JOINED(3, "已报名"), | |||
| NOJOINED(4, "未报名"), | |||
| NOT_START(0, "报名未开始"), | |||
| NORMAL(1, "正常报名"), | |||
| END(2, "报名结束"), | |||
| JOINED(3, "已报名"),; | |||
| ACTIVITY_NOT_LINE(5, "活动未上线"), | |||
| ACTIVITY_NOT(6, "活动下线"), | |||
| ACTIVITY_END(7, "活动结束"), | |||
| NOT_JOIN(8, "不需要报名"),; | |||
| public static EnumActivityEnrollStatus getEnum(Integer code) { | |||
| for (EnumActivityEnrollStatus value : values()) { | |||