develop # Conflicts: # mallinkAdmin/src/main/java/com/iformall/controller/rent/WxBillAllController.java # mallinkService/src/main/java/com/iformall/domain/po/WxMsgModel.java # mallinkService/src/main/java/com/iformall/domain/po/WxMsgValidationcodeModel.java # mallinkService/src/main/java/com/iformall/domain/po/WxScoreRules.java # mallinkService/src/main/java/com/iformall/mapper/WxMerchantMapper.java # mallinkService/src/main/java/com/iformall/service/impl/WxBillAllServiceImpl.java # mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java # mallinkService/src/main/java/com/iformall/service/impl/WxMerchantServiceImpl.java # mallinkService/src/main/java/com/iformall/service/msg/impl/SendEmailServiceImpl.java # mallinkService/src/main/resources/mapper/WxMsgModelMapper.xml # mallinkService/src/main/resources/mapper/WxMsgValidationcodeModelMapper.xmlrelease_toaliyun_real
| @@ -49,6 +49,7 @@ | |||
| <dependency> | |||
| <groupId>org.flywaydb</groupId> | |||
| <artifactId>flyway-core</artifactId> | |||
| <version>5.1.4</version> | |||
| </dependency> | |||
| </dependencies> | |||
| @@ -72,13 +73,17 @@ | |||
| com.fasterxml.jackson.dataformat, | |||
| com.fasterxml.jackson.datatype, | |||
| com.fasterxml.jackson.module, | |||
| com.fasterxml.uuid, | |||
| com.fasterxml, | |||
| com.github.axet, | |||
| com.github.binarywang, | |||
| 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, | |||
| @@ -96,6 +101,7 @@ | |||
| commons-cli, | |||
| commons-codec, | |||
| commons-collections, | |||
| commons-fileupload, | |||
| commons-io, | |||
| commons-logging, | |||
| io.lettuce, | |||
| @@ -105,14 +111,18 @@ | |||
| io.swagger, | |||
| io.undertow, | |||
| javax.activation, | |||
| javax.annotation, | |||
| javax.mail, | |||
| javax.persistence, | |||
| javax.servlet, | |||
| javax.validation, | |||
| javax.xml.bind, | |||
| joda-time, | |||
| junit, | |||
| mysql, | |||
| net.bytebuddy, | |||
| net.minidev, | |||
| net.sf.dozer, | |||
| net.sf.saxon, | |||
| ognl, | |||
| org.antlr, | |||
| @@ -129,15 +139,22 @@ | |||
| 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.mapstruct, | |||
| org.mockito, | |||
| org.mybatis, | |||
| org.mybatis.generator, | |||
| @@ -145,7 +162,9 @@ | |||
| org.ow2.asm, | |||
| org.projectlombok, | |||
| org.quartz-scheduler, | |||
| org.reflections, | |||
| org.rocketmq.spring.boot, | |||
| org.slf4j, | |||
| org.springframework, | |||
| org.springframework.amqp, | |||
| org.springframework.boot, | |||
| @@ -31,6 +31,9 @@ public class UserApplication { | |||
| @Value("${fm.open}") | |||
| private boolean fmOpen; | |||
| @Value("${fm.upload_dir}") | |||
| private String uploadDir; | |||
| @Bean | |||
| public boolean isFmException() { | |||
| return fmException; | |||
| @@ -46,6 +49,11 @@ public class UserApplication { | |||
| return fmOpen; | |||
| } | |||
| @Bean | |||
| public String fmUploadDir() { | |||
| return uploadDir; | |||
| } | |||
| public static void main(String[] args) { | |||
| SpringApplication.run(UserApplication.class, args); | |||
| } | |||
| @@ -2,6 +2,7 @@ package com.iformall.config; | |||
| import com.iformall.domain.po.PushLimit; | |||
| import com.iformall.domain.po.WxCUser; | |||
| import com.iformall.domain.po.WxMall; | |||
| import com.iformall.domain.po.WxScoreRules; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| @@ -142,4 +143,21 @@ public class RedisConfig extends CachingConfigurerSupport { | |||
| return template; | |||
| } | |||
| @Bean("mallRedisTemplate") | |||
| public RedisTemplate<String, WxMall> getMallRedisTemplate(RedisConnectionFactory connectionFactory) { | |||
| RedisTemplate<String, WxMall> template = new RedisTemplate<String, WxMall>(); | |||
| Jackson2JsonRedisSerializer<WxMall> j = new Jackson2JsonRedisSerializer<WxMall>(WxMall.class); | |||
| // value值的序列化 | |||
| template.setValueSerializer(j); | |||
| template.setHashKeySerializer(j); | |||
| // key的序列化 | |||
| template.setKeySerializer(new StringRedisSerializer()); | |||
| template.setHashKeySerializer(new StringRedisSerializer()); | |||
| template.setConnectionFactory(connectionFactory); | |||
| return template; | |||
| } | |||
| } | |||
| @@ -31,8 +31,6 @@ import java.util.Map; | |||
| */ | |||
| @Configuration | |||
| public class ShiroConfig { | |||
| @Autowired(required = false) | |||
| private MallPermissionService resourcesService; | |||
| @Value("${spring.redis.host}") | |||
| private String host; | |||
| @@ -8,6 +8,7 @@ import com.fasterxml.jackson.databind.module.SimpleModule; | |||
| import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; | |||
| import com.iformall.interceptor.HttpServletRequestWrapperFilter; | |||
| import com.iformall.interceptor.RequestInterceptor; | |||
| import com.iformall.service.MallResourceService; | |||
| import com.iformall.ueditor.ActionEnter; | |||
| import com.iformall.ueditor.ConfigManager; | |||
| import com.iformall.ueditor.UEditorConfig; | |||
| @@ -44,10 +45,13 @@ public class WebConfig implements WebMvcConfigurer { | |||
| @Autowired | |||
| private RequestInterceptor requestInterceptor; | |||
| @Autowired | |||
| private MallResourceService mallResourceService; | |||
| @Bean | |||
| @ConditionalOnMissingBean(ActionEnter.class) | |||
| public ActionEnter actionEnter() { | |||
| ActionEnter actionEnter = new ActionEnter(ConfigManager.getInstance(uEditorConfig, awsProperty)); | |||
| ActionEnter actionEnter = new ActionEnter(ConfigManager.getInstance(uEditorConfig, awsProperty, mallResourceService)); | |||
| return actionEnter; | |||
| } | |||
| @@ -1,75 +0,0 @@ | |||
| package com.iformall.controller; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.MallPermission; | |||
| import com.iformall.service.MallPermissionService; | |||
| import org.apache.shiro.util.Assert; | |||
| 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.PostMapping; | |||
| import org.springframework.web.bind.annotation.RequestMapping; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| /** | |||
| * @author chenkx | |||
| * @date 2018-01-05. | |||
| */ | |||
| @RestController | |||
| @RequestMapping("permission") | |||
| public class MallPermissionController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| MallPermissionService mallPermissionService; | |||
| @GetMapping("alllist") | |||
| @SystemControllerLog(description = "用户管理-权限") | |||
| public ResultData alllist(String ava) { | |||
| logger.debug("[" + getIpAddr() + "] MallPermissionController::alllist"); | |||
| MallPermission record = new MallPermission(); | |||
| record.setAvailable(ava); | |||
| PageInfo<MallPermission> permissions = mallPermissionService.listAsPage(record, 1, 10000); | |||
| return new ResultData(Result.SUCCESS, "查询成功", permissions.getList()); | |||
| } | |||
| @PostMapping("add") | |||
| @SystemControllerLog(description = "用户管理-权限添加") | |||
| public ResultData createPermission(MallPermission mallPermission) { | |||
| logger.debug("[" + getIpAddr() + "] MallPermissionController::createPermission"); | |||
| Assert.notNull(mallPermission.getName(), "用户名不能为空"); | |||
| mallPermissionService.saveOrUpdate(mallPermission); | |||
| return new ResultData(mallPermission.getId()); | |||
| } | |||
| @PostMapping("update") | |||
| @SystemControllerLog(description = "用户管理-权限更新") | |||
| public ResultData updatePermission(MallPermission sysPermission) { | |||
| logger.debug("[" + getIpAddr() + "] MallPermissionController::updatePermission"); | |||
| mallPermissionService.saveOrUpdate(sysPermission); | |||
| return new ResultData(); | |||
| } | |||
| @GetMapping("/del") | |||
| @SystemControllerLog(description = "用户管理-权限删除") | |||
| public ResultData delete(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] MallPermissionController::delete"); | |||
| mallPermissionService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @GetMapping("/findById") | |||
| @SystemControllerLog(description = "用户管理-权限查找") | |||
| public ResultData findById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] MallPermissionController::findById"); | |||
| mallPermissionService.getById(id); | |||
| return new ResultData(Result.SUCCESS, "成功", null); | |||
| } | |||
| } | |||
| @@ -1,83 +0,0 @@ | |||
| package com.iformall.controller; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxAdminLog; | |||
| import com.iformall.service.WxAdminLogService; | |||
| 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.*; | |||
| @RestController | |||
| @RequestMapping("wxAdminLog") | |||
| public class WxAdminLogController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxAdminLogService wxAdminLogService; | |||
| @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 WxAdminLog wxAdminLog, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxAdminLogController::list"); | |||
| if (null == wxAdminLog) wxAdminLog = new WxAdminLog(); | |||
| final PageInfo<WxAdminLog> page = wxAdminLogService.listAsPage(wxAdminLog, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| public ResultData add(@RequestBody WxAdminLog wxAdminLog) { | |||
| logger.debug("[" + getIpAddr() + "] WxAdminLogController::add"); | |||
| //Assert.notNull(wxAdminLog.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| wxAdminLogService.saveOrUpdate(wxAdminLog); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| public ResultData update(@RequestBody WxAdminLog wxAdminLog) { | |||
| logger.debug("[" + getIpAddr() + "] WxAdminLogController::update"); | |||
| String tenantId = getTenantId(); | |||
| wxAdminLog.setTenantId(tenantId); | |||
| wxAdminLogService.saveOrUpdate(wxAdminLog); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id删除接口") | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| public ResultData delete(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxAdminLogController::delete"); | |||
| wxAdminLogService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| public ResultData findById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxAdminLogController::findById"); | |||
| return new ResultData(Result.SUCCESS, "查询成功", wxAdminLogService.getById(id)); | |||
| } | |||
| @ApiOperation("PV计数") | |||
| @PostMapping("pvlog") | |||
| public ResultData pvLog(@RequestBody WxAdminLog wxAdminLog) { | |||
| logger.debug("[" + getIpAddr() + "] WxAdminLogController::pvLog"); | |||
| String tenantId = getTenantId(); | |||
| wxAdminLog.setTenantId(tenantId); | |||
| wxAdminLogService.saveLogCount(wxAdminLog); | |||
| return new ResultData(); | |||
| } | |||
| } | |||
| @@ -1,87 +0,0 @@ | |||
| package com.iformall.controller; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxBillDaily; | |||
| import com.iformall.service.WxBillDailyService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.Map; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| @RestController | |||
| @RequestMapping("wxBillDaily") | |||
| public class WxBillDailyController extends BaseController { | |||
| @Autowired | |||
| private WxBillDailyService wxBillDailyService; | |||
| private Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @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 WxBillDaily wxBillDaily, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxBillDailyController::list"); | |||
| if (null == wxBillDaily) { | |||
| wxBillDaily = new WxBillDaily(); | |||
| } | |||
| wxBillDaily.setTenantId(getTenantId()); | |||
| final PageInfo<Map<String, Object>> page = wxBillDailyService.listAsPage(wxBillDaily, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @PostMapping("add") | |||
| @SystemControllerLog(description = "日常账单-新增") | |||
| public ResultData add(@RequestBody WxBillDaily wxBillDaily) { | |||
| logger.debug("[" + getIpAddr() + "] WxBillDailyController::add"); | |||
| wxBillDaily.setTenantId(getTenantId()); | |||
| wxBillDaily.setUserId(getUser().getId()); | |||
| return wxBillDailyService.saveOrUpdate(wxBillDaily, getUser()); | |||
| } | |||
| @PostMapping("update") | |||
| @SystemControllerLog(description = "日常账单-更新") | |||
| public ResultData update(@RequestBody WxBillDaily wxBillDaily) { | |||
| logger.debug("[" + getIpAddr() + "] WxBillDailyController::update"); | |||
| wxBillDaily.setUserId(getUser().getId()); | |||
| return wxBillDailyService.saveOrUpdate(wxBillDaily, getUser()); | |||
| } | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "日常账单-删除") | |||
| public ResultData delete(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxBillDailyController::delete"); | |||
| wxBillDailyService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "日常账单-id查找") | |||
| public ResultData findById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxBillDailyController::findById"); | |||
| return new ResultData(Result.SUCCESS, "查询成功", wxBillDailyService.getById(id)); | |||
| } | |||
| @GetMapping("/updatePaid") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "日常账单-支付更新") | |||
| public ResultData updatePaid(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxBillDailyController::updatePaid"); | |||
| return wxBillDailyService.updatePaid(id); | |||
| } | |||
| } | |||
| @@ -1,75 +0,0 @@ | |||
| package com.iformall.controller; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxCLog; | |||
| import com.iformall.service.WxCLogService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| @RestController | |||
| @RequestMapping("wxCLog") | |||
| public class WxCLogController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxCLogService wxCLogService; | |||
| @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 WxCLog wxCLog,Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxCLogController::list"); | |||
| if (null == wxCLog) wxCLog = new WxCLog(); | |||
| final PageInfo<WxCLog> page = wxCLogService.listAsPage(wxCLog, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| public ResultData add(@RequestBody WxCLog wxCLog) { | |||
| logger.debug("[" + getIpAddr() + "] WxCLogController::add"); | |||
| //Assert.notNull(wxCLog.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| wxCLogService.saveOrUpdate(wxCLog); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| public ResultData update(@RequestBody WxCLog wxCLog) { | |||
| logger.debug("[" + getIpAddr() + "] WxCLogController::update"); | |||
| wxCLogService.saveOrUpdate(wxCLog); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id删除接口") | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) | |||
| public ResultData delete(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxCLogController::delete"); | |||
| wxCLogService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name="id",value="id",dataType="Long", paramType = "query",required=true) | |||
| public ResultData findById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxCLogController::findById"); | |||
| return new ResultData(Result.SUCCESS,"查询成功",wxCLogService.getById(id)); | |||
| } | |||
| } | |||
| @@ -1,78 +0,0 @@ | |||
| package com.iformall.controller; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxChannel; | |||
| import com.iformall.service.WxChannelService; | |||
| 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.*; | |||
| @RestController | |||
| @RequestMapping("wxChannel") | |||
| public class WxChannelController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxChannelService wxChannelService; | |||
| @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 WxChannel wxChannel, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxChannelController::list"); | |||
| if (null == wxChannel) wxChannel = new WxChannel(); | |||
| final PageInfo<WxChannel> page = wxChannelService.listAsPage(wxChannel, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| @SystemControllerLog(description = "渠道-新增") | |||
| public ResultData add(@RequestBody WxChannel wxChannel) { | |||
| logger.debug("[" + getIpAddr() + "] WxChannelController::add"); | |||
| //Assert.notNull(wxChannel.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| wxChannelService.saveOrUpdate(wxChannel); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| @SystemControllerLog(description = "渠道-更新") | |||
| public ResultData update(@RequestBody WxChannel wxChannel) { | |||
| logger.debug("[" + getIpAddr() + "] WxChannelController::update"); | |||
| wxChannelService.saveOrUpdate(wxChannel); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id删除接口") | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "渠道-删除") | |||
| public ResultData delete(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxChannelController::delete"); | |||
| wxChannelService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "渠道-查询") | |||
| public ResultData findById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxChannelController::findById"); | |||
| return new ResultData(Result.SUCCESS, "查询成功", wxChannelService.getById(id)); | |||
| } | |||
| } | |||
| @@ -1,103 +0,0 @@ | |||
| package com.iformall.controller; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxCouponSpread; | |||
| import com.iformall.service.WxCouponSpreadService; | |||
| 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.List; | |||
| @RestController | |||
| @RequestMapping("wxCouponSpread") | |||
| @Api(description = "推广接口") | |||
| public class WxCouponSpreadController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxCouponSpreadService wxCouponSpreadService; | |||
| @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 WxCouponSpread wxCouponSpread, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponSpreadController::list"); | |||
| if (null == wxCouponSpread) wxCouponSpread = new WxCouponSpread(); | |||
| final PageInfo<WxCouponSpread> page = wxCouponSpreadService.listAsPage(wxCouponSpread, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| @SystemControllerLog(description = "券推广-新增") | |||
| public ResultData add(@RequestBody WxCouponSpread wxCouponSpread) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponSpreadController::add"); | |||
| if (wxCouponSpread.getCouponId() == null) { | |||
| return new ResultData(Result.ERROR, "没有找到券id"); | |||
| } | |||
| //Assert.notNull(wxCouponSpread.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| wxCouponSpreadService.saveOrUpdate(wxCouponSpread); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| @SystemControllerLog(description = "券推广-更新") | |||
| public ResultData update(@RequestBody WxCouponSpread wxCouponSpread) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponSpreadController::update"); | |||
| wxCouponSpreadService.saveOrUpdate(wxCouponSpread); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id删除接口") | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "券推广-删除") | |||
| public ResultData delete(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponSpreadController::delete"); | |||
| wxCouponSpreadService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "券推广-查询") | |||
| public ResultData findById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponSpreadController::findById"); | |||
| return new ResultData(Result.SUCCESS, "查询成功", wxCouponSpreadService.getById(id)); | |||
| } | |||
| @ApiOperation("根据卡券id查询接口") | |||
| @GetMapping("/findByCouponId") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "券推广-卡券id查询") | |||
| public ResultData findByCouponId(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponSpreadController::findByCouponId"); | |||
| WxCouponSpread result = null; | |||
| if (id != null) { | |||
| WxCouponSpread wxCouponSpread = new WxCouponSpread(); | |||
| wxCouponSpread.setCouponId(id); | |||
| List<WxCouponSpread> list = wxCouponSpreadService.findList(wxCouponSpread); | |||
| if (!list.isEmpty()) { | |||
| result = list.get(0); | |||
| } | |||
| } | |||
| return new ResultData(Result.SUCCESS, "查询成功", result); | |||
| } | |||
| } | |||
| @@ -1,74 +0,0 @@ | |||
| package com.iformall.controller; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxCouponType; | |||
| import com.iformall.service.WxCouponTypeService; | |||
| 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.*; | |||
| @RestController | |||
| @RequestMapping("wxCouponType") | |||
| @Api(description = "优惠券类型相关接口") | |||
| public class WxCouponTypeController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxCouponTypeService wxCouponTypeService; | |||
| @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 WxCouponType wxCouponType, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponTypeController::list"); | |||
| if (null == wxCouponType) wxCouponType = new WxCouponType(); | |||
| final PageInfo<WxCouponType> page = wxCouponTypeService.listAsPage(wxCouponType, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| public ResultData add(@RequestBody WxCouponType wxCouponType) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponTypeController::add"); | |||
| //Assert.notNull(wxCouponType.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| wxCouponTypeService.saveOrUpdate(wxCouponType); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| public ResultData update(@RequestBody WxCouponType wxCouponType) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponTypeController::update"); | |||
| wxCouponTypeService.saveOrUpdate(wxCouponType); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id删除接口") | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| public ResultData delete(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponTypeController::delete"); | |||
| wxCouponTypeService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| public ResultData findById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponTypeController::findById"); | |||
| return new ResultData(Result.SUCCESS, "查询成功", wxCouponTypeService.getById(id)); | |||
| } | |||
| } | |||
| @@ -1,81 +0,0 @@ | |||
| package com.iformall.controller; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxMerchantBUser; | |||
| import com.iformall.service.WxMerchantBUserService; | |||
| 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.*; | |||
| @RestController | |||
| @RequestMapping("wxMerchantBUser") | |||
| public class WxMerchantBUserController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxMerchantBUserService wxMerchantBUserService; | |||
| @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 WxMerchantBUser wxMerchantBUser, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantBUserController::list"); | |||
| if (null == wxMerchantBUser) wxMerchantBUser = new WxMerchantBUser(); | |||
| final PageInfo<WxMerchantBUser> page = wxMerchantBUserService.listAsPage(wxMerchantBUser, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| public ResultData add(@RequestBody WxMerchantBUser wxMerchantBUser) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantBUserController::add"); | |||
| //Assert.notNull(wxMerchantBUser.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| wxMerchantBUser.setTenantId(getTenantId()); | |||
| Long id = wxMerchantBUserService.saveOrUpdate(wxMerchantBUser); | |||
| return new ResultData(Result.SUCCESS, "添加成功", id); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| public ResultData update(@RequestBody WxMerchantBUser wxMerchantBUser) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantBUserController::update"); | |||
| Long id = wxMerchantBUserService.saveOrUpdate(wxMerchantBUser); | |||
| return new ResultData(Result.SUCCESS, "更新成功", id); | |||
| } | |||
| @ApiOperation("根据id删除接口") | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| public ResultData delete(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantBUserController::delete"); | |||
| wxMerchantBUserService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| public ResultData findById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantBUserController::findById"); | |||
| return new ResultData(Result.SUCCESS, "查询成功", wxMerchantBUserService.getById(id)); | |||
| } | |||
| @ApiOperation("手机号是否存在") | |||
| @GetMapping("/hasphone") | |||
| @ApiImplicitParam(name = "phone", value = "phone", dataType = "String", paramType = "query", required = true) | |||
| public ResultData hasphone(String phone) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantBUserController::hasphone"); | |||
| boolean has = wxMerchantBUserService.hasphone(phone, getTenantId()); | |||
| return new ResultData(Result.SUCCESS, "查询成功", has); | |||
| } | |||
| } | |||
| @@ -1,86 +0,0 @@ | |||
| package com.iformall.controller; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxMerchantShop; | |||
| import com.iformall.domain.po.WxShop; | |||
| import com.iformall.service.WxMerchantShopService; | |||
| 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.*; | |||
| @RestController | |||
| @RequestMapping("wxMerchantShop") | |||
| public class WxMerchantShopController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxMerchantShopService wxMerchantShopService; | |||
| @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 WxMerchantShop wxMerchantShop, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantShopController::list"); | |||
| if (null == wxMerchantShop) wxMerchantShop = new WxMerchantShop(); | |||
| final PageInfo<WxMerchantShop> page = wxMerchantShopService.listAsPage(wxMerchantShop, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("获取关联商铺信息") | |||
| @GetMapping("queryShopList") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public ResultData queryShopList(@ModelAttribute WxMerchantShop wxMerchantShop, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantShopController::queryShopList"); | |||
| if (null == wxMerchantShop) wxMerchantShop = new WxMerchantShop(); | |||
| final PageInfo<WxShop> page = wxMerchantShopService.queryShopList(wxMerchantShop, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| public ResultData add(@RequestBody WxMerchantShop wxMerchantShop) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantShopController::add"); | |||
| wxMerchantShopService.saveOrUpdate(wxMerchantShop); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| public ResultData update(@RequestBody WxMerchantShop wxMerchantShop) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantShopController::update"); | |||
| wxMerchantShopService.saveOrUpdate(wxMerchantShop); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id删除接口") | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| public ResultData delete(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantShopController::delete"); | |||
| wxMerchantShopService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| public ResultData findById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantShopController::findById"); | |||
| return new ResultData(Result.SUCCESS, "查询成功", wxMerchantShopService.getById(id)); | |||
| } | |||
| } | |||
| @@ -1,92 +0,0 @@ | |||
| package com.iformall.controller; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.po.WxProfitSharingReceiver; | |||
| import com.iformall.service.WxMerchantService; | |||
| import com.iformall.service.WxProfitSharingReceiverService; | |||
| 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.*; | |||
| @RestController | |||
| @RequestMapping("wxProfitSharingReceiver") | |||
| public class WxProfitSharingReceiverController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxProfitSharingReceiverService wxProfitSharingReceiverService; | |||
| @Autowired | |||
| private WxMerchantService wxMerchantService; | |||
| @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 WxProfitSharingReceiver receiver, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxProfitSharingReceiverController::list"); | |||
| if (null == receiver) receiver = new WxProfitSharingReceiver(); | |||
| final PageInfo<WxProfitSharingReceiver> page = wxProfitSharingReceiverService.listAsPage(receiver, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| @SystemControllerLog(description = "分账接收者-新增") | |||
| public ResultData add(@ModelAttribute WxProfitSharingReceiver receiver) { | |||
| logger.debug("[" + getIpAddr() + "] WxProfitSharingReceiverController::add"); | |||
| if (receiver == null) | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| if (receiver.getMerchantId() == null) | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| if (receiver.getReceiverType() == null) | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| if (receiver.getReceiverComments() == null) | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| if (receiver.getReceiverAccount() == null) | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| if (receiver.getTrueName() == null) | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| WxMerchant merchant = wxMerchantService.getById(receiver.getMerchantId()); | |||
| if (merchant == null) | |||
| return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND); | |||
| return wxProfitSharingReceiverService.addReceiver(merchant, receiver); | |||
| } | |||
| @ApiOperation("根据id删除接口") | |||
| @GetMapping("del") | |||
| @SystemControllerLog(description = "分账接收者-删除") | |||
| public ResultData delete(@ModelAttribute WxProfitSharingReceiver receiver) { | |||
| logger.debug("[" + getIpAddr() + "] WxProfitSharingReceiverController::delete"); | |||
| if (receiver == null) | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| if (receiver.getMerchantId() == null) | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| if (receiver.getReceiverType() == null) | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| if (receiver.getReceiverAccount() == null) | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| WxMerchant merchant = wxMerchantService.getById(receiver.getMerchantId()); | |||
| if (merchant == null) | |||
| return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND); | |||
| return wxProfitSharingReceiverService.delReceiver(merchant); | |||
| } | |||
| } | |||
| @@ -1,72 +0,0 @@ | |||
| package com.iformall.controller; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxScoreValidityPeriod; | |||
| import com.iformall.service.WxScoreValidityPeriodService; | |||
| 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.*; | |||
| @RestController | |||
| @RequestMapping("wxScoreValidityPeriod") | |||
| public class WxScoreValidityPeriodController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxScoreValidityPeriodService wxScoreValidityPeriodService; | |||
| @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 WxScoreValidityPeriod wxScoreValidityPeriod, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxScoreValidityPeriodController::list"); | |||
| if (null == wxScoreValidityPeriod) wxScoreValidityPeriod = new WxScoreValidityPeriod(); | |||
| final PageInfo<WxScoreValidityPeriod> page = wxScoreValidityPeriodService.listAsPage(wxScoreValidityPeriod, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("新增接口") | |||
| @PostMapping("add") | |||
| public ResultData add(@RequestBody WxScoreValidityPeriod wxScoreValidityPeriod) { | |||
| logger.debug("[" + getIpAddr() + "] WxScoreValidityPeriodController::add"); | |||
| //Assert.notNull(wxScoreValidityPeriod.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| wxScoreValidityPeriodService.saveOrUpdate(wxScoreValidityPeriod); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| public ResultData update(@RequestBody WxScoreValidityPeriod wxScoreValidityPeriod) { | |||
| logger.debug("[" + getIpAddr() + "] WxScoreValidityPeriodController::update"); | |||
| wxScoreValidityPeriodService.saveOrUpdate(wxScoreValidityPeriod); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id删除接口") | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| public ResultData delete(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxScoreValidityPeriodController::delete"); | |||
| wxScoreValidityPeriodService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| public ResultData findById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxScoreValidityPeriodController::findById"); | |||
| return new ResultData(Result.SUCCESS, "查询成功", wxScoreValidityPeriodService.getById(id)); | |||
| } | |||
| } | |||
| @@ -0,0 +1,262 @@ | |||
| package com.iformall.controller.app; | |||
| import cn.binarywang.wx.miniapp.api.WxMaService; | |||
| import cn.binarywang.wx.miniapp.bean.WxMaCodeLineColor; | |||
| import com.amazonaws.services.s3.model.ObjectMetadata; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.controller.sys.UploadController; | |||
| import com.iformall.domain.po.WxAppinfo; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.WxMerchantMapper; | |||
| import com.iformall.service.WxAppinfoService; | |||
| import com.iformall.service.wechat.FmOpenService; | |||
| import com.iformall.utils.Constant; | |||
| import com.iformall.utils.MaUtil; | |||
| import com.iformall.utils.QRCodeUtils; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import me.chanjar.weixin.common.error.WxErrorException; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.core.task.AsyncTaskExecutor; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import org.springframework.web.multipart.MultipartFile; | |||
| import javax.servlet.ServletException; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.io.*; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| import java.util.UUID; | |||
| import java.util.concurrent.ExecutorService; | |||
| import java.util.concurrent.Executors; | |||
| @RestController | |||
| @RequestMapping("wxAppinfo") | |||
| public class WxAppinfoController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private boolean isFmOpen; | |||
| @Autowired | |||
| private String fmUploadDir; | |||
| @Autowired | |||
| private WxAppinfoService wxAppinfoService; | |||
| @Autowired | |||
| private FmOpenService openService; | |||
| @Autowired | |||
| private WxMerchantMapper wxMerchantMapper; | |||
| @Autowired | |||
| private UploadController uploadController; | |||
| @Autowired | |||
| private AsyncTaskExecutor asyncTaskExecutor; | |||
| @ApiOperation("加载老数据二维码") | |||
| @GetMapping("/updateQrCode") | |||
| public void updateQrCode(String p)throws ServletException, IOException { | |||
| if("xlldxx".equals(p)){ | |||
| String pageUrl = "pages/index/index"; | |||
| List<WxMerchant> list = wxMerchantMapper.findQrcodeEmptyList(); | |||
| for (WxMerchant merchant:list) { | |||
| asyncTaskExecutor.execute(new Runnable() { | |||
| @Override | |||
| public void run() { | |||
| String param = "t:md:"+merchant.getId(); | |||
| ResultData resultData = exportQrcode(null,null,merchant.getTenantId(),1,pageUrl,param,0,"","","店铺详情",true); | |||
| Map<String,String> map = (Map)resultData.data; | |||
| String url = map.get("url"); | |||
| merchant.setQrCode(url); | |||
| wxMerchantMapper.updateByPrimaryKeySelective(merchant); | |||
| } | |||
| }); | |||
| } | |||
| } | |||
| } | |||
| @ApiOperation(value = "下载二维码", produces="application/json;charset=UTF-8", notes = "参数{\"name\":\"String\",\"pageUrl\":\"String\", \"sceneParam\":\"二维码参数\", \"type\":0:有限二维码,1:无限二维码,\"withText\":int(0:不带字, 1:加一行字,2:加两行字),\"text1\":\"String\",\"text2\":\"String\"}") | |||
| @PostMapping("/downQrCode") | |||
| public void downQrCode(HttpServletRequest request, HttpServletResponse response, @RequestBody Map<String, Object> params) throws MallinkException { | |||
| logger.debug("[" + getIpAddr() + "] WxAppinfoController::downQrCode"); | |||
| String name = (String) params.get("name"); | |||
| String pageUrl = (String) params.get("pageUrl"); | |||
| String sceneParam = (String) params.get("sceneParam"); | |||
| int type = 0; | |||
| try { | |||
| type = (int) params.get("type"); | |||
| } catch (Exception e) { | |||
| type = 0; | |||
| } | |||
| int withText = 0; | |||
| try { | |||
| withText = (int) params.get("withText"); | |||
| } catch (Exception e) { | |||
| withText = 0; | |||
| } | |||
| String text1 = (String) params.get("text1"); | |||
| String text2 = (String) params.get("text2"); | |||
| if (StringUtils.isBlank(pageUrl)) { | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "pageUrl不能为空"); | |||
| } | |||
| try { | |||
| exportQrcode(request, response, | |||
| getTenantId(), type, pageUrl, sceneParam, | |||
| withText, text1, text2, | |||
| name,false); | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| throw new MallinkException(Result.ERROR, "下载异常"); | |||
| } | |||
| } | |||
| public ResultData exportQrcode(HttpServletRequest request, HttpServletResponse response, | |||
| String tenantId, int type, String pageUrl, String sceneParam, | |||
| int withText, String text1, String text2, | |||
| String name,boolean upload) { | |||
| // type 0 有限二维码, 1 无限制二维码 | |||
| // withText 0 不带字 1. 带下面的字,2 带下面的两行字 | |||
| WxAppinfo appinfo = wxAppinfoService.getCAppInfo(tenantId); | |||
| boolean autoColor = false; | |||
| boolean isHyaline = true; | |||
| WxMaCodeLineColor color = new WxMaCodeLineColor("0", "0", "0"); | |||
| WxMaService wxMaService; | |||
| if(isFmOpen) { | |||
| wxMaService = openService.getWxOpenComponentService().getWxMaServiceByAppid(appinfo.getAppId()); | |||
| } else { | |||
| wxMaService = MaUtil.getWeappService(appinfo); | |||
| } | |||
| String pathStr = ""; | |||
| if (StringUtils.isNotBlank(sceneParam)) { | |||
| pathStr = pageUrl + "?scene="+sceneParam; | |||
| } else { | |||
| pathStr = pageUrl; | |||
| } | |||
| String filepath = fmUploadDir; | |||
| String fileName = name + ".png"; | |||
| String destPath1 = filepath + "1_" + fileName; | |||
| String destPath = filepath + fileName; | |||
| File dest = new File(destPath); | |||
| File pDest = dest.getParentFile(); | |||
| if (!pDest.exists()) { | |||
| pDest.mkdirs(); | |||
| } | |||
| try { | |||
| if(type == 0) { | |||
| final File codeFile = wxMaService.getQrcodeService().createQrcode(pathStr, QRCodeUtils.QR_WIDTH); | |||
| if (withText == 1) { | |||
| File dest1 = new File(destPath1); | |||
| org.apache.commons.io.FileUtils.copyFile(codeFile, dest1); | |||
| QRCodeUtils.graphicsGeneration(dest1, dest, text1); | |||
| org.apache.commons.io.FileUtils.forceDelete(dest1); | |||
| } else if (withText == 2) { | |||
| File dest1 = new File(destPath1); | |||
| org.apache.commons.io.FileUtils.copyFile(codeFile, dest1); | |||
| QRCodeUtils.graphicsGeneration2(dest1, dest, text1, text2); | |||
| org.apache.commons.io.FileUtils.forceDelete(dest1); | |||
| } else { | |||
| org.apache.commons.io.FileUtils.copyFile(codeFile, dest); | |||
| } | |||
| org.apache.commons.io.FileUtils.forceDelete(codeFile); | |||
| } else { | |||
| final File codeFile = wxMaService.getQrcodeService().createWxaCodeUnlimit(sceneParam, pageUrl, QRCodeUtils.QR_WIDTH, autoColor, color, isHyaline); | |||
| if (withText == 1) { | |||
| File dest1 = new File(destPath1); | |||
| org.apache.commons.io.FileUtils.copyFile(codeFile, dest1); | |||
| QRCodeUtils.graphicsGeneration(dest1, dest, text1); | |||
| org.apache.commons.io.FileUtils.forceDelete(dest1); | |||
| } else if (withText == 2) { | |||
| File dest1 = new File(destPath1); | |||
| org.apache.commons.io.FileUtils.copyFile(codeFile, dest1); | |||
| QRCodeUtils.graphicsGeneration2(dest1, dest, text1, text2); | |||
| org.apache.commons.io.FileUtils.forceDelete(dest1); | |||
| } else { | |||
| org.apache.commons.io.FileUtils.copyFile(codeFile, dest); | |||
| } | |||
| org.apache.commons.io.FileUtils.forceDelete(codeFile); | |||
| } | |||
| } catch (WxErrorException e) { | |||
| logger.error(e.getMessage()); | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| try { | |||
| //上传 | |||
| if (upload){ | |||
| ObjectMetadata metadata = new ObjectMetadata(); | |||
| metadata.setContentType("image/jpeg"); | |||
| metadata.setContentLength(dest.length()); | |||
| FileOutputStream fos = null; | |||
| BufferedInputStream fs = null; | |||
| String fn = UUID.randomUUID().toString(); | |||
| int dot = fileName.lastIndexOf('.'); | |||
| if (dot >= 0) { | |||
| fn = tenantId + "/" + fn + dest.getName().substring(dot, dest.getName().length()); | |||
| } else { | |||
| fn = tenantId + "/" + fn; | |||
| } | |||
| ResultData data = uploadController.awsUpload(new FileInputStream(dest), metadata, fn, getTenantId()); | |||
| return data; | |||
| } | |||
| downFile(destPath, fileName, response, request); | |||
| org.apache.commons.io.FileUtils.forceDelete(dest); | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| private void downFile(String filePath, String filename, HttpServletResponse response, HttpServletRequest req) throws IOException { | |||
| try { | |||
| response.reset(); | |||
| response.setContentType("application/octet-stream"); | |||
| String agent = req.getHeader("user-agent"); | |||
| if (agent.contains("Firefox")) { | |||
| response.setHeader("Content-disposition", | |||
| "attachment; filename=" | |||
| + new String(filename.getBytes("GB2312"),"ISO-8859-1")); | |||
| } else { | |||
| response.setHeader("Content-disposition", | |||
| "attachment; filename=" | |||
| + java.net.URLEncoder.encode(filename,"UTF-8")); | |||
| } | |||
| // 循环取出流中的数据 | |||
| byte[] b = new byte[1024]; | |||
| int len; | |||
| InputStream inStream = new FileInputStream(filePath); | |||
| while ((len = inStream.read(b)) > 0) | |||
| response.getOutputStream().write(b, 0, len); | |||
| inStream.close(); | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| } | |||
| } | |||
| @@ -1,4 +1,4 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.base; | |||
| import java.beans.PropertyEditorSupport; | |||
| import java.text.ParseException; | |||
| @@ -45,6 +45,11 @@ public class BaseController { | |||
| MallUserInfo user = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute(UserSession.userInfo); | |||
| return user; | |||
| } | |||
| public Long getUserId(){ | |||
| Long userId = (Long) SecurityUtils.getSubject().getSession().getAttribute(UserSession.userId); | |||
| return userId; | |||
| } | |||
| public String getTenantId(){ | |||
| String tenantId = (String)SecurityUtils.getSubject().getSession().getAttribute(UserSession.tenantId); | |||
| @@ -1,9 +1,10 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.basic; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxBrand; | |||
| import com.iformall.service.WxBrandService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| @@ -1,9 +1,10 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.basic; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxGroup; | |||
| import com.iformall.service.WxGroupService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| @@ -0,0 +1,30 @@ | |||
| package com.iformall.controller.basic; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.service.WxMallBuildingService; | |||
| 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.*; | |||
| @RestController | |||
| @RequestMapping("wxMallBuilding") | |||
| public class WxMallBuildingController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxMallBuildingService wxMallBuildingService; | |||
| @ApiOperation("获取楼层楼座数据") | |||
| @GetMapping("getbuildingfloorlist") | |||
| @SystemControllerLog(description = "商城-楼座-获取楼层楼座数据") | |||
| public ResultData getbuildingfloorlist() { | |||
| logger.debug("[" + getIpAddr() + "] WxMallBuildingController::getbuildingfloorlist"); | |||
| return wxMallBuildingService.getbuildingfloorlist(getTenantId()); | |||
| } | |||
| } | |||
| @@ -0,0 +1,48 @@ | |||
| package com.iformall.controller.basic; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxMall; | |||
| import com.iformall.service.WxMallService; | |||
| 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.*; | |||
| @RestController | |||
| @RequestMapping("wxMall") | |||
| public class WxMallController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxMallService wxMallService; | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| @SystemControllerLog(description = "商城-更新") | |||
| public ResultData update(@RequestBody WxMall wxMall) { | |||
| logger.debug("[" + getIpAddr() + "] WxMallController::update"); | |||
| wxMallService.update(wxMall); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/mallinfoExt") | |||
| @SystemControllerLog(description = "商城-查询") | |||
| public ResultData mallinfoExt() { | |||
| logger.debug("[" + getIpAddr() + "] WxMallController::mallinfoExt"); | |||
| return new ResultData(wxMallService.getByTenantIdExt(getTenantId())); | |||
| } | |||
| @ApiOperation("查询当前mall的信息") | |||
| @GetMapping("/mallinfo") | |||
| @SystemControllerLog(description = "商城-当前查询") | |||
| public ResultData mallinfo() { | |||
| logger.debug("[" + getIpAddr() + "] WxMallController::mallinfo"); | |||
| return new ResultData(wxMallService.getByTenantId(getTenantId())); | |||
| } | |||
| } | |||
| @@ -0,0 +1,31 @@ | |||
| package com.iformall.controller.basic; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.service.WxMerchantBUserService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| 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.*; | |||
| @RestController | |||
| @RequestMapping("wxMerchantBUser") | |||
| public class WxMerchantBUserController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxMerchantBUserService wxMerchantBUserService; | |||
| @ApiOperation("手机号是否存在") | |||
| @GetMapping("/hasphone") | |||
| @ApiImplicitParam(name = "phone", value = "phone", dataType = "String", paramType = "query", required = true) | |||
| public ResultData hasphone(String phone) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantBUserController::hasphone"); | |||
| boolean has = wxMerchantBUserService.hasphone(phone, getTenantId()); | |||
| return new ResultData(Result.SUCCESS, "查询成功", has); | |||
| } | |||
| } | |||
| @@ -0,0 +1,219 @@ | |||
| package com.iformall.controller.basic; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.app.WxAppinfoController; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.po.WxProfitSharingReceiver; | |||
| import com.iformall.domain.vo.WxMerchantVo; | |||
| import com.iformall.service.WxMerchantService; | |||
| 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; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| @RestController | |||
| @RequestMapping("wxMerchant") | |||
| public class WxMerchantController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxMerchantService wxMerchantService; | |||
| @Autowired | |||
| private WxAppinfoController wxAppinfoController; | |||
| @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 WxMerchant wxMerchant, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::list"); | |||
| if (null == wxMerchant) wxMerchant = new WxMerchant(); | |||
| wxMerchant.setTenantId(getTenantId()); | |||
| wxMerchant.setSortColumns(WxMerchant.Field.TopTime_DESC); | |||
| final PageInfo<WxMerchant> page = wxMerchantService.listAsPage(wxMerchant, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("ETCP商户列表") | |||
| @GetMapping("etcplist") | |||
| @SystemControllerLog(description = "商户-ETCP商户列表") | |||
| public ResultData etcpList(@ModelAttribute WxMerchant wxMerchant) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::etcpList"); | |||
| if (null == wxMerchant) wxMerchant = new WxMerchant(); | |||
| wxMerchant.setTenantId(getTenantId()); | |||
| final List<WxMerchant> merchantList = wxMerchantService.etcpList(wxMerchant); | |||
| return new ResultData(merchantList); | |||
| } | |||
| @ApiOperation("根据id删除接口") | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "商户-删除") | |||
| public ResultData delete(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::delete"); | |||
| wxMerchantService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "商户-查询") | |||
| public ResultData findById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::findById"); | |||
| WxMerchant wxMerchant = wxMerchantService.getById(id); | |||
| return new ResultData(wxMerchant); | |||
| } | |||
| @ApiOperation("停用") | |||
| @GetMapping("disable") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "商户-停用") | |||
| public ResultData disable(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::disable"); | |||
| wxMerchantService.disable(id); | |||
| return new ResultData(Result.SUCCESS, "停用成功"); | |||
| } | |||
| @ApiOperation("新增商户接口") | |||
| @PostMapping("addMerchant") | |||
| @SystemControllerLog(description = "商户-新增") | |||
| public ResultData addMerchant(@RequestBody WxMerchant wxMerchant) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::addMerchant"); | |||
| wxMerchant.setTenantId(getTenantId()); | |||
| ResultData resultData = wxMerchantService.addMerchant(wxMerchant, getUserId()); | |||
| if(resultData.code == 200){ | |||
| //加载二维码图片 | |||
| String pageUrl = "pages/index/index"; | |||
| String param = "t:md:"+resultData.data; | |||
| ResultData resultQrCode = wxAppinfoController.exportQrcode(null,null,wxMerchant.getTenantId(),1,pageUrl,param,0,"","","店铺详情",true); | |||
| Map<String,String> map = (Map)resultQrCode.data; | |||
| String url = map.get("url"); | |||
| wxMerchant.setQrCode(url); | |||
| wxMerchantService.updateMerchant(wxMerchant); | |||
| } | |||
| return resultData; | |||
| } | |||
| @ApiOperation("更新商户接口") | |||
| @PostMapping("updateMerchant") | |||
| @SystemControllerLog(description = "商户-更新") | |||
| public ResultData updateMerchant(@RequestBody WxMerchant wxMerchant) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::updateMerchant"); | |||
| wxMerchant.setTenantId(getTenantId()); | |||
| return wxMerchantService.updateMerchant(wxMerchant); | |||
| } | |||
| @ApiOperation("更新账户接口") | |||
| @PostMapping("updateMerchantAccount") | |||
| @SystemControllerLog(description = "商户-更新账户") | |||
| public ResultData updateMerchantAccount(@RequestBody WxMerchant wxMerchant) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::updateMerchantAccount"); | |||
| wxMerchant.setTenantId(getTenantId()); | |||
| return wxMerchantService.updateMerchantAccount(wxMerchant); | |||
| } | |||
| @ApiOperation("更新管理员接口") | |||
| @PostMapping("updateMerchantAdmin") | |||
| @SystemControllerLog(description = "商户-更新管理员") | |||
| public ResultData updateMerchantAdmin(@RequestBody WxMerchant wxMerchant) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::updateMerchantAdmin"); | |||
| wxMerchant.setTenantId(getTenantId()); | |||
| return wxMerchantService.updateMerchantAdmin(wxMerchant); | |||
| } | |||
| @ApiOperation("更新法人接口") | |||
| @PostMapping("updateMerchantCorp") | |||
| @SystemControllerLog(description = "商户-更新法人") | |||
| public ResultData updateMerchantCopr(@RequestBody WxMerchant wxMerchant) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::updateMerchantCorp"); | |||
| wxMerchant.setTenantId(getTenantId()); | |||
| return wxMerchantService.updateMerchantCorp(wxMerchant); | |||
| } | |||
| @ApiOperation("更新税务接口") | |||
| @PostMapping("updateMerchantTax") | |||
| @SystemControllerLog(description = "商户-更新税务") | |||
| public ResultData updateMerchantTax(@RequestBody WxMerchant wxMerchant) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::updateMerchantTax"); | |||
| wxMerchant.setTenantId(getTenantId()); | |||
| return wxMerchantService.updateMerchantTax(wxMerchant); | |||
| } | |||
| @ApiOperation("更新会员等级权益接口") | |||
| @PostMapping("updateMerchantLevel") | |||
| @SystemControllerLog(description = "商户-更新会员等级权益") | |||
| public ResultData updateMerchantLevel(@RequestBody WxMerchant wxMerchant) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::updateMerchantLevel"); | |||
| wxMerchant.setTenantId(getTenantId()); | |||
| return wxMerchantService.updateMerchantLevel(wxMerchant); | |||
| } | |||
| @ApiOperation("查询当前租户下商户名称列表") | |||
| @GetMapping("/name_list") | |||
| @SystemControllerLog(description = "查询当前租户下商户名称列表") | |||
| public ResultData nameList() { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::name_list"); | |||
| return new ResultData(wxMerchantService.findList(getTenantId())); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @GetMapping("/findMerchantById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "商户-查询") | |||
| public ResultData findMerchantById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::findMerchantById"); | |||
| WxMerchantVo wxMerchant = wxMerchantService.findMerchantById(id); | |||
| return new ResultData(wxMerchant); | |||
| } | |||
| @ApiOperation("商户数据导出") | |||
| @GetMapping("/exportData") | |||
| @SystemControllerLog(description = "商户-商户数据导出") | |||
| public void exportData(@ModelAttribute WxMerchant wxMerchant, HttpServletRequest request, HttpServletResponse response) { | |||
| wxMerchant.setTenantId(getTenantId()); | |||
| wxMerchant.setSortColumns(WxMerchant.Field.TopTime_DESC); | |||
| wxMerchantService.exportData(wxMerchant,request,response); | |||
| } | |||
| @ApiOperation("置顶") | |||
| @PostMapping("top") | |||
| @SystemControllerLog(description = "商户-置顶") | |||
| public ResultData top(@RequestBody WxMerchant wxMerchant) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::top"); | |||
| wxMerchant.setTenantId(getTenantId()); | |||
| return wxMerchantService.top(wxMerchant); | |||
| } | |||
| @ApiOperation("更新收款账户状态") | |||
| @PostMapping("useAccount") | |||
| @SystemControllerLog(description = "商户-更新收款账户状态") | |||
| public ResultData useAccount(@RequestBody WxProfitSharingReceiver wxProfitSharingReceiver) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantController::useAccount"); | |||
| wxProfitSharingReceiver.setTenantId(getTenantId()); | |||
| return wxMerchantService.useAccount(wxProfitSharingReceiver); | |||
| } | |||
| } | |||
| @@ -0,0 +1,37 @@ | |||
| package com.iformall.controller.basic; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxMerchantShop; | |||
| import com.iformall.domain.po.WxShop; | |||
| import com.iformall.service.WxMerchantShopService; | |||
| 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.*; | |||
| @RestController | |||
| @RequestMapping("wxMerchantShop") | |||
| public class WxMerchantShopController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxMerchantShopService wxMerchantShopService; | |||
| @ApiOperation("获取关联商铺信息") | |||
| @GetMapping("queryShopList") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public ResultData queryShopList(@ModelAttribute WxMerchantShop wxMerchantShop, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantShopController::queryShopList"); | |||
| if (null == wxMerchantShop) wxMerchantShop = new WxMerchantShop(); | |||
| final PageInfo<WxShop> page = wxMerchantShopService.queryShopList(wxMerchantShop, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| } | |||
| @@ -1,9 +1,10 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.basic; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxShop; | |||
| import com.iformall.service.WxShopService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| @@ -1,16 +1,9 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.basic; | |||
| import java.util.ArrayList; | |||
| import java.util.Arrays; | |||
| import java.util.List; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.domain.po.WxTagsGroup; | |||
| import com.iformall.domain.po.WxTagsType; | |||
| import com.iformall.domain.vo.WxTagsGroupVo; | |||
| import com.iformall.domain.vo.WxTagsTypeVo; | |||
| import com.iformall.service.WxTagsGroupService; | |||
| import com.iformall.service.WxTagsTypeService; | |||
| import com.iformall.controller.base.BaseController; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| @@ -18,10 +11,8 @@ import org.springframework.web.bind.annotation.GetMapping; | |||
| import org.springframework.web.bind.annotation.RequestMapping; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxTags; | |||
| import com.iformall.service.WxCUserTagsService; | |||
| import com.iformall.service.WxTagsService; | |||
| @@ -1,10 +1,11 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.car; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| 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.MallUserInfo; | |||
| import com.iformall.domain.po.WxCouponCar; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| @@ -56,9 +57,9 @@ public class WxCarController extends BaseController { | |||
| @Autowired | |||
| WxCouponCarService wxCouponCarService; | |||
| private WxPark getCurrentPark(MallUserInfo user) { | |||
| private WxPark getCurrentPark() { | |||
| WxPark parkQ = new WxPark(); | |||
| parkQ.setTenantId(user.getTenantId()); | |||
| parkQ.setTenantId(getTenantId()); | |||
| WxPark wxPark = wxParkService.getByObj(parkQ); | |||
| // 1, get mall's park | |||
| // future use redis to optimize | |||
| @@ -70,9 +71,8 @@ public class WxCarController extends BaseController { | |||
| @SystemControllerLog(description = "车-获取车场支持的厂家") | |||
| public ResultData getVendor() { | |||
| logger.debug("[" + getIpAddr() + "] WxCarController::getVendor"); | |||
| MallUserInfo user = getUser(); | |||
| // 1, get mall's park | |||
| WxPark park = getCurrentPark(user); | |||
| WxPark park = getCurrentPark(); | |||
| Map map = new HashMap(); | |||
| map.put("vendor", park.getVendorType()); | |||
| return new ResultData(map); | |||
| @@ -125,9 +125,8 @@ public class WxCarController extends BaseController { | |||
| @SystemControllerLog(description = "车-优免券模板") | |||
| public ResultData quanTemplate(String merchantId, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxCarController::quanTemplate"); | |||
| MallUserInfo user = getUser(); | |||
| /// 1, get mall's park | |||
| WxPark park = getCurrentPark(user); | |||
| WxPark park = getCurrentPark(); | |||
| String params = park.getVendorParams(); | |||
| JSONObject objParams = JSON.parseObject(params); | |||
| String url = objParams.getString("url"); | |||
| @@ -195,7 +194,6 @@ public class WxCarController extends BaseController { | |||
| logger.info(coupon.toString()); | |||
| // Save to wx_counpon | |||
| Date curDate = new Date(); | |||
| MallUserInfo user = getUser(); | |||
| // check 同一个模板的券分配额是否超了 | |||
| if (StringUtils.isBlank(coupon.getVendorParams())) { | |||
| logger.error("请填充停车厂商优免券参数"); | |||
| @@ -216,7 +214,7 @@ public class WxCarController extends BaseController { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "可用库存已达到停车厂商优免券数量限制"); | |||
| } | |||
| // check End | |||
| coupon.setTenantId(user.getTenantId()); | |||
| coupon.setTenantId(getTenantId()); | |||
| ResultData resultData = wxCouponService.saveOrUpdate(coupon); | |||
| if (resultData.code != ResultData.SUCCESS){ | |||
| @@ -226,9 +224,9 @@ public class WxCarController extends BaseController { | |||
| // Save to wx_coupon_car | |||
| WxCouponCar couponCar = new WxCouponCar(); | |||
| couponCar.setId(coupon.getId()); | |||
| couponCar.setTenantId(user.getTenantId()); | |||
| couponCar.setTenantId(getTenantId()); | |||
| WxPark park = getCurrentPark(user); | |||
| WxPark park = getCurrentPark(); | |||
| couponCar.setParkId(park.getId()); | |||
| couponCar.setVendorType(park.getVendorType()); | |||
| couponCar.setVendorParams(coupon.getVendorParams()); | |||
| @@ -297,9 +295,8 @@ public class WxCarController extends BaseController { | |||
| @GetMapping("/getParkStatus") | |||
| @SystemControllerLog(description = "车-停车场状态") | |||
| public ResultData getParkStatus() { | |||
| MallUserInfo user = getUser(); | |||
| /// 1, get mall's park | |||
| WxPark park = getCurrentPark(user); | |||
| WxPark park = getCurrentPark(); | |||
| if (park.getVendorType() == EnumCarVendor.CAR_ETCP.getCode()) { | |||
| String params = park.getVendorParams(); | |||
| if(params == null) { | |||
| @@ -1,9 +1,10 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.car; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxPark; | |||
| import com.iformall.service.WxParkService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| @@ -1,17 +1,17 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.contract; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| 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.WxBillProperty; | |||
| import com.iformall.domain.po.WxFlowRecord; | |||
| import com.iformall.domain.po.WxBillRent; | |||
| import com.iformall.domain.po.WxPropertyContract; | |||
| import com.iformall.domain.po.WxRentContract; | |||
| import com.iformall.enums.EnumFlowRecordStatus; | |||
| import com.iformall.service.WxBillPropertyService; | |||
| import com.iformall.service.WxPropertyContractService; | |||
| 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; | |||
| @@ -51,15 +51,19 @@ public class WxPropertyContractController extends BaseController { | |||
| @PostMapping("add") | |||
| public ResultData add(@RequestBody WxPropertyContract wxPropertyContract) { | |||
| logger.debug("[" + getIpAddr() + "] WxPropertyContractController::add"); | |||
| wxPropertyContract.setTenantId(getTenantId()); | |||
| return wxPropertyContractService.saveOrUpdate(wxPropertyContract, getUser().getId(), getUser().getName()); | |||
| MallUserInfo user = getUser(); | |||
| wxPropertyContract.setTenantId(user.getTenantId()); | |||
| wxPropertyContract.setAdjustPeriodHandle(); | |||
| return wxPropertyContractService.saveOrUpdate(wxPropertyContract, user.getId(), user.getName()); | |||
| } | |||
| @PostMapping("update") | |||
| public ResultData update(@RequestBody WxPropertyContract wxPropertyContract) { | |||
| logger.debug("[" + getIpAddr() + "] WxPropertyContractController::update"); | |||
| wxPropertyContract.setTenantId(getTenantId()); | |||
| return wxPropertyContractService.saveOrUpdate(wxPropertyContract, getUser().getId(), getUser().getName()); | |||
| MallUserInfo user = getUser(); | |||
| wxPropertyContract.setTenantId(user.getTenantId()); | |||
| wxPropertyContract.setAdjustPeriodHandle(); | |||
| return wxPropertyContractService.saveOrUpdate(wxPropertyContract, user.getId(), user.getName()); | |||
| } | |||
| @GetMapping("/del") | |||
| @@ -128,4 +132,5 @@ public class WxPropertyContractController extends BaseController { | |||
| return wxPropertyContractService.updatePropertyContractStatus(id); | |||
| } | |||
| } | |||
| @@ -1,19 +1,22 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.contract; | |||
| 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.WxBillRent; | |||
| import com.iformall.domain.po.WxPayAccountBill; | |||
| import com.iformall.domain.po.WxRentContract; | |||
| import com.iformall.domain.po.WxShop; | |||
| import com.iformall.enums.EnumRentContractAdjustPeriod; | |||
| import com.iformall.enums.EnumRentShopType; | |||
| import com.iformall.enums.EnumShopType; | |||
| import com.iformall.service.WxBillRentService; | |||
| import com.iformall.service.WxPayAccountBillService; | |||
| import com.iformall.service.WxRentContractService; | |||
| import com.iformall.service.WxShopService; | |||
| import com.iformall.utils.DateUtils; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| @@ -21,9 +24,9 @@ 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; | |||
| import java.text.SimpleDateFormat; | |||
| import java.util.HashMap; | |||
| import java.util.Map; | |||
| @@ -44,6 +47,20 @@ public class WxRentContractController extends BaseController { | |||
| @Autowired | |||
| private WxShopService wxShopService; | |||
| @GetMapping("getDateDiff") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "startDate", value = "开始时间", dataType = "string", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "endtDate", value = "结束时间", dataType = "string", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "获取两个时间相差,返回n月零n天") | |||
| public ResultData getDateDiff(String startDate, String endDate) throws Exception{ | |||
| SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); | |||
| Map<String,Integer> map = new HashMap<>(); | |||
| int[] array = DateUtils.getDiff(sd.parse(startDate),sd.parse(endDate)); | |||
| map.put("month",array[0]); | |||
| map.put("day",array[1]); | |||
| return new ResultData(map); | |||
| } | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @@ -63,57 +80,47 @@ public class WxRentContractController extends BaseController { | |||
| @SystemControllerLog(description = "租赁合同-添加") | |||
| public ResultData add(@RequestBody WxRentContract wxRentContract) { | |||
| logger.debug("[" + getIpAddr() + "] WxRentContractController::add"); | |||
| wxRentContract.setTenantId(getTenantId()); | |||
| //目前只有多经点位租赁合同 | |||
| WxShop wxShop = wxShopService.getById(wxRentContract.getShopId()); | |||
| if(wxRentContract.getMonthHandleType() != null && wxRentContract.getMonthHandleType().intValue()==3 | |||
| && EnumRentShopType.POINT.getCode().equals(wxShop.getType())){ | |||
| wxRentContract.setAdjustPeriod(wxRentContract.getMonthHandleType()); | |||
| } | |||
| return wxRentContractService.save(wxRentContract, getUser().getId(),getUser().getName()); | |||
| MallUserInfo user = getUser(); | |||
| wxRentContract.setTenantId(user.getTenantId()); | |||
| wxRentContract.setAdjustPeriodHandle(); | |||
| return wxRentContractService.save(wxRentContract, user.getId(),user.getName()); | |||
| } | |||
| @PostMapping("update") | |||
| @SystemControllerLog(description = "租赁合同-更新") | |||
| public ResultData update(@RequestBody WxRentContract wxRentContract) { | |||
| logger.debug("[" + getIpAddr() + "] WxRentContractController::update"); | |||
| wxRentContract.setTenantId(getTenantId()); | |||
| //目前只有多经点位租赁合同 | |||
| WxShop wxShop = wxShopService.getById(wxRentContract.getShopId()); | |||
| if(wxRentContract.getMonthHandleType() != null && wxRentContract.getMonthHandleType().intValue()==3 | |||
| && EnumRentShopType.POINT.getCode().equals(wxShop.getType())){ | |||
| wxRentContract.setAdjustPeriod(wxRentContract.getMonthHandleType()); | |||
| } | |||
| return wxRentContractService.update(wxRentContract, getUser().getId(),getUser().getName()); | |||
| MallUserInfo user = getUser(); | |||
| wxRentContract.setTenantId(user.getTenantId()); | |||
| wxRentContract.setAdjustPeriodHandle(); | |||
| return wxRentContractService.update(wxRentContract, user.getId(),user.getName()); | |||
| } | |||
| /** | |||
| * 防止前端3秒重复提交 | |||
| * @param wxRentContract | |||
| * @return | |||
| */ | |||
| @PostMapping("updateMoney") | |||
| @SystemControllerLog(description = "租赁合同-更新金额") | |||
| public ResultData updateMoney(@RequestBody WxRentContract wxRentContract) { | |||
| logger.debug("[" + getIpAddr() + "] WxRentContractController::updateMoney"); | |||
| wxRentContract.setTenantId(getTenantId()); | |||
| //目前只有多经点位租赁合同 | |||
| WxShop wxShop = wxShopService.getById(wxRentContract.getShopId()); | |||
| if(wxRentContract.getMonthHandleType() != null && wxRentContract.getMonthHandleType().intValue()==3 | |||
| && EnumRentShopType.POINT.getCode().equals(wxShop.getType())){ | |||
| wxRentContract.setAdjustPeriod(wxRentContract.getMonthHandleType()); | |||
| } | |||
| return wxRentContractService.update(wxRentContract, getUser().getId(),getUser().getName()); | |||
| MallUserInfo user = getUser(); | |||
| wxRentContract.setTenantId(user.getTenantId()); | |||
| wxRentContract.setAdjustPeriodHandle(); | |||
| return wxRentContractService.update(wxRentContract, user.getId(),user.getName()); | |||
| } | |||
| @PostMapping("updateFile") | |||
| @SystemControllerLog(description = "租赁合同-更新文件") | |||
| public ResultData updateFile(@RequestBody WxRentContract wxRentContract) { | |||
| logger.debug("[" + getIpAddr() + "] WxRentContractController::updateFile"); | |||
| wxRentContract.setTenantId(getTenantId()); | |||
| //目前只有多经点位租赁合同 | |||
| WxShop wxShop = wxShopService.getById(wxRentContract.getShopId()); | |||
| if(wxRentContract.getMonthHandleType() != null && wxRentContract.getMonthHandleType().intValue()==3 | |||
| && EnumRentShopType.POINT.getCode().equals(wxShop.getType())){ | |||
| wxRentContract.setAdjustPeriod(wxRentContract.getMonthHandleType()); | |||
| } | |||
| return wxRentContractService.updateFile(wxRentContract, getUser().getId(),getUser().getName()); | |||
| MallUserInfo user = getUser(); | |||
| wxRentContract.setTenantId(user.getTenantId()); | |||
| wxRentContract.setAdjustPeriodHandle(); | |||
| return wxRentContractService.updateFile(wxRentContract, user.getId(),user.getName()); | |||
| } | |||
| @GetMapping("/del") | |||
| @@ -131,7 +138,7 @@ public class WxRentContractController extends BaseController { | |||
| logger.debug("[" + getIpAddr() + "] WxRentContractController::findById"); | |||
| // 同步欠缴状态 | |||
| WxBillRent wxBillRent = new WxBillRent(); | |||
| wxBillRent.setTenantId(super.getTenantId()); | |||
| wxBillRent.setTenantId(getTenantId()); | |||
| wxBillRentService.updateBillStatus(wxBillRent); | |||
| return wxRentContractService.getById(id); | |||
| } | |||
| @@ -1,18 +1,16 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.datatower; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.service.DataTowerService; | |||
| 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.HashMap; | |||
| import java.util.Map; | |||
| @Api(description = "数据塔台") | |||
| @@ -1,7 +1,8 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.datatower; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.service.WxChartDataService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| @@ -42,7 +43,8 @@ public class WxChartDataController extends BaseController { | |||
| "--------------------------------------"+ | |||
| "chart=49商铺出租数据:" + | |||
| "total商铺总数 totalShop店铺个数 totalPoint多径点位个数, rentTotal已出租总数 rentTotalShop已出租店铺 rentTotalPoint已出租点位" + | |||
| ",notRentTotal未出租总数 notRentTotalShop未出租店铺 notRentTotalPoint未出租点位" + | |||
| ",notRentTotal未出租总数 notRentTotalShop未出租店铺 notRentTotalPoint未出租点位," + | |||
| "rentTotalRate店铺出租率 rentTotalShopRate商铺出租率 rentTotalPointRate点位出租率" + | |||
| ","+ | |||
| "--------------------------------------"+ | |||
| "chart=50费用收缴数据:" + | |||
| @@ -1,21 +1,31 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.datatower; | |||
| import com.github.pagehelper.PageInfo; | |||
| 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.WxMerchant; | |||
| import com.iformall.domain.po.WxMerchantBUser; | |||
| import com.iformall.domain.po.WxMerchantTradeDaily; | |||
| import com.iformall.domain.vo.WxMerchantTradeDailyVo; | |||
| import com.iformall.service.WxMerchantBUserService; | |||
| import com.iformall.service.WxMerchantService; | |||
| import com.iformall.service.WxMerchantTradeDailyService; | |||
| import com.iformall.utils.DateUtils; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.apache.commons.collections.CollectionUtils; | |||
| import org.apache.commons.collections.map.LinkedMap; | |||
| 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 java.text.SimpleDateFormat; | |||
| import java.util.Calendar; | |||
| import java.util.Date; | |||
| import java.util.*; | |||
| @RestController | |||
| @RequestMapping("wxMerchantTradeDaily") | |||
| @@ -25,25 +35,34 @@ public class WxMerchantTradeDailyController extends BaseController { | |||
| @Autowired | |||
| private WxMerchantTradeDailyService wxMerchantTradeDailyService; | |||
| @ApiOperation("获得指定日期的解单,默认不传reportDate为当天") | |||
| @GetMapping("/getVolume") | |||
| public ResultData getVolume(WxMerchantTradeDaily wxMerchantTradeDaily) { | |||
| wxMerchantTradeDaily.setTenantId(getTenantId()); | |||
| return wxMerchantTradeDailyService.getVolume(wxMerchantTradeDaily,getUser().getId()); | |||
| } | |||
| @ApiOperation("获得昨日解单列表") | |||
| @GetMapping("/listYesterday") | |||
| @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 listYesterday(@ModelAttribute WxMerchantTradeDailyVo wxMerchantTradeDaily, Integer pageNum, Integer pageSize) { | |||
| public ResultData list(@ModelAttribute WxMerchantTradeDailyVo wxMerchantTradeDaily, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantTradeDailyController::listYesterday"); | |||
| if (wxMerchantTradeDaily == null) wxMerchantTradeDaily = new WxMerchantTradeDailyVo(); | |||
| if (wxMerchantTradeDaily == null) | |||
| wxMerchantTradeDaily = new WxMerchantTradeDailyVo(); | |||
| wxMerchantTradeDaily.setTenantId(getTenantId()); | |||
| Calendar cal = Calendar.getInstance(); | |||
| cal.setTime(new Date()); | |||
| cal.add(Calendar.DAY_OF_YEAR, -1); | |||
| SimpleDateFormat fmt=new SimpleDateFormat("yyyy-MM-dd"); | |||
| wxMerchantTradeDaily.setReportDate(fmt.format(cal.getTime())); | |||
| if (wxMerchantTradeDaily.getReportDate() == null) { | |||
| SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd"); | |||
| wxMerchantTradeDaily.setReportDate(fmt.format(new Date())); | |||
| } | |||
| wxMerchantTradeDaily.setSortColumns(WxMerchantTradeDailyVo.Field.MerchantId_DESC); | |||
| PageInfo<WxMerchantTradeDailyVo> page = wxMerchantTradeDailyService.listAsPageVo(wxMerchantTradeDaily, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @@ -64,12 +83,20 @@ public class WxMerchantTradeDailyController extends BaseController { | |||
| } | |||
| @ApiOperation("更新解单数据") | |||
| @PostMapping("/updateYesterday") | |||
| @PostMapping("/update") | |||
| @SystemControllerLog(description = "商户-更新解单数据") | |||
| public ResultData updateYesterday(@RequestBody WxMerchantTradeDailyVo wxMerchantTradeDaily) { | |||
| public ResultData update(@RequestBody WxMerchantTradeDailyVo wxMerchantTradeDaily) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantTradeDailyController::updateYesterday"); | |||
| if (wxMerchantTradeDaily == null || | |||
| wxMerchantTradeDaily.getMerchantId() == null || | |||
| wxMerchantTradeDaily.getTradeAmt() == null) | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| wxMerchantTradeDaily.setTenantId(getTenantId()); | |||
| return wxMerchantTradeDailyService.updateYesterday(wxMerchantTradeDaily); | |||
| if (wxMerchantTradeDaily.getReportDate() == null) { | |||
| SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd"); | |||
| wxMerchantTradeDaily.setReportDate(fmt.format(new Date())); | |||
| } | |||
| return wxMerchantTradeDailyService.update(wxMerchantTradeDaily); | |||
| } | |||
| @ApiOperation("查询解单数据") | |||
| @@ -81,6 +108,4 @@ public class WxMerchantTradeDailyController extends BaseController { | |||
| return wxMerchantTradeDailyService.queryTradeDaily(wxMerchantTradeDaily); | |||
| } | |||
| } | |||
| @@ -1,9 +1,10 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.datatower; | |||
| import com.github.pagehelper.PageInfo; | |||
| 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.dto.WxCUserBasicInfoDto; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.vo.UserStructureVo; | |||
| @@ -136,6 +137,8 @@ public class WxUserStructureController extends BaseController { | |||
| //没有等级的会员 | |||
| other.setLevel(WxLevelConfigService.DEFAULT_LEVEL); | |||
| WxCUserBasicInfoDto dto = new WxCUserBasicInfoDto(); | |||
| dto.setStartTime(startTime); | |||
| dto.setEndTime(endTime); | |||
| other.setCount(wxCUserBasicInfoService.findCount(dto) | |||
| - levelList.stream().map(WxLevelConfig::getCount).reduce(Long::sum).orElse(0L)); | |||
| @@ -1,10 +1,11 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.device; | |||
| 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.WxDevice; | |||
| import com.iformall.enums.EnumDeviceOnlineStatus; | |||
| import com.iformall.enums.EnumDeviceStatus; | |||
| @@ -1,14 +1,11 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.device; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| 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.domain.po.WxCampaign; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxScreenAd; | |||
| import com.iformall.enums.EnumScoreType; | |||
| import com.iformall.enums.EnumScreenAdStatus; | |||
| import com.iformall.enums.EnumScreenAdType; | |||
| import com.iformall.service.WxCampaignService; | |||
| @@ -23,9 +20,6 @@ import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| @RestController | |||
| @RequestMapping("wxScreenAd") | |||
| @Api(description="广告屏") | |||
| @@ -1,7 +1,8 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.market; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.dto.MarkingCouponDataReportDto; | |||
| import com.iformall.service.MarkingDataReportService; | |||
| import io.swagger.annotations.Api; | |||
| @@ -1,7 +1,8 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.market; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.PushLimit; | |||
| import com.iformall.service.PushLimitService; | |||
| import io.swagger.annotations.Api; | |||
| @@ -1,6 +1,7 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.market; | |||
| import com.iformall.ueditor.ActionEnter; | |||
| import io.swagger.annotations.Api; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.RequestMapping; | |||
| import org.springframework.web.bind.annotation.ResponseBody; | |||
| @@ -11,6 +12,7 @@ import javax.servlet.http.HttpServletRequest; | |||
| @RestController | |||
| @RequestMapping("/ue") | |||
| @Api(description = "网页bannner图接口") | |||
| public class UeditorController { | |||
| @Autowired | |||
| @@ -1,4 +1,4 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.market; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.alibaba.fastjson.JSONArray; | |||
| @@ -7,6 +7,7 @@ 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.WxCampaign; | |||
| import com.iformall.domain.po.WxCoupon; | |||
| import com.iformall.domain.po.WxCouponChannel; | |||
| @@ -1,14 +1,14 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.market; | |||
| import com.github.pagehelper.PageInfo; | |||
| 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.*; | |||
| import com.iformall.domain.vo.WxCardSpendVo; | |||
| import com.iformall.domain.vo.WxCardVo; | |||
| import com.iformall.enums.EnumCardSpendStatus; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.WxCardInfoService; | |||
| import com.iformall.service.WxCardSpendService; | |||
| @@ -27,7 +27,6 @@ import org.springframework.web.bind.annotation.*; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.util.ArrayList; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| @@ -35,8 +34,8 @@ import java.util.Map; | |||
| * @author Stormeye Wu wuguoqiang@iformall.com | |||
| */ | |||
| @RestController | |||
| @Api(description = "C端扫B端商户码储值卡支付") | |||
| @RequestMapping("cardPay") | |||
| @Api(description = "储值卡支付-C端扫B端商户码") | |||
| public class WxCardPayController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @@ -67,8 +66,7 @@ public class WxCardPayController extends BaseController { | |||
| wxCardVo.setOuPhone(null); | |||
| } | |||
| } | |||
| MallUserInfo user = getUser(); | |||
| wxCardVo.setTenantId(user.getTenantId()); | |||
| wxCardVo.setTenantId(getTenantId()); | |||
| if(StringUtils.isNotBlank(wxCardVo.getStatusStr())) { | |||
| String [] statusAttr = wxCardVo.getStatusStr().split(","); | |||
| List<Integer> tmpList = new ArrayList<Integer>(); | |||
| @@ -95,8 +93,7 @@ public class WxCardPayController extends BaseController { | |||
| if (wxCardSpendVo == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空"); | |||
| } | |||
| MallUserInfo user = getUser(); | |||
| wxCardSpendVo.setTenantId(user.getTenantId()); | |||
| wxCardSpendVo.setTenantId(getTenantId()); | |||
| if(StringUtils.isNotBlank(wxCardSpendVo.getPayStatusStr())) { | |||
| String [] statusAttr = wxCardSpendVo.getPayStatusStr().split(","); | |||
| List<Integer> tmpList = new ArrayList<Integer>(); | |||
| @@ -120,8 +117,7 @@ public class WxCardPayController extends BaseController { | |||
| if (wxCardSpend == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空"); | |||
| } | |||
| MallUserInfo user = getUser(); | |||
| wxCardSpend.setTenantId(user.getTenantId()); | |||
| wxCardSpend.setTenantId(getTenantId()); | |||
| final List<Map<String, Object>> mapList = wxCardSpendService.sumCardSpendForMerchant(wxCardSpend); | |||
| return new ResultData(mapList); | |||
| } | |||
| @@ -157,8 +153,7 @@ public class WxCardPayController extends BaseController { | |||
| if (wxCardSpend == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空"); | |||
| } | |||
| MallUserInfo user = getUser(); | |||
| wxCardSpend.setTenantId(user.getTenantId()); | |||
| wxCardSpend.setTenantId(getTenantId()); | |||
| wxCardSpendService.update(wxCardSpend); | |||
| return new ResultData(); | |||
| } | |||
| @@ -172,9 +167,12 @@ public class WxCardPayController extends BaseController { | |||
| if (wxCardInfo == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空"); | |||
| } | |||
| MallUserInfo user = getUser(); | |||
| wxCardInfo.setTenantId(user.getTenantId()); | |||
| int remainShareAmount = wxCardSpendService.finishCard(user.getTenantId(), wxCardInfo.getId()); | |||
| if (wxCardInfo.getId() == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件ID为空"); | |||
| } | |||
| String tenantId = getTenantId(); | |||
| wxCardInfo.setTenantId(tenantId); | |||
| int remainShareAmount = wxCardSpendService.finishCard(tenantId, wxCardInfo.getId()); | |||
| return new ResultData(remainShareAmount); | |||
| } | |||
| } | |||
| @@ -1,11 +1,13 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.market; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxCouponActionLog; | |||
| import com.iformall.service.WxCouponActionLogService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| @@ -16,6 +18,7 @@ import org.springframework.web.bind.annotation.*; | |||
| @RestController | |||
| @RequestMapping("wxCouponActionLog") | |||
| @Api(description = "发券行为记录接口") | |||
| public class WxCouponActionLogController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @@ -1,11 +1,13 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.market; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxCouponCar; | |||
| import com.iformall.service.WxCouponCarService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| @@ -16,6 +18,7 @@ import org.springframework.web.bind.annotation.*; | |||
| @RestController | |||
| @RequestMapping("wxCouponCar") | |||
| @Api(description = "停车券接口") | |||
| public class WxCouponCarController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @@ -1,18 +1,15 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.market; | |||
| import com.alibaba.fastjson.JSON; | |||
| 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.dto.WxCouponChannelDto; | |||
| import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.domain.po.WxCoupon; | |||
| import com.iformall.domain.po.WxCouponChannel; | |||
| import com.iformall.domain.vo.WxCouponChannelVo; | |||
| import com.iformall.enums.EnumCouponChannelStatus; | |||
| import com.iformall.enums.EnumCouponStatus; | |||
| import com.iformall.service.WxCouponChannelService; | |||
| import com.iformall.service.WxCouponService; | |||
| import io.swagger.annotations.Api; | |||
| @@ -53,7 +50,7 @@ public class WxCouponChannelController extends BaseController { | |||
| if (wxCouponChannel.getStatus() != null && wxCouponChannel.getStatus() == -1) { | |||
| wxCouponChannel.setStatus(null); | |||
| } | |||
| wxCouponChannel.setTenantId(getUser().getTenantId()); | |||
| wxCouponChannel.setTenantId(getTenantId()); | |||
| wxCouponChannel.setSortColumns(WxCouponChannel.Field.UpdateDate_DESC); | |||
| final PageInfo<WxCouponChannelVo> page = wxCouponChannelService.listPageCVo(wxCouponChannel, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| @@ -65,7 +62,7 @@ public class WxCouponChannelController extends BaseController { | |||
| @SystemControllerLog(description = "券投放-更新") | |||
| public ResultData update(@RequestBody WxCouponChannel wxCouponChannel) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponChannelController::update"); | |||
| wxCouponChannel.setTenantId(getUser().getTenantId()); | |||
| wxCouponChannel.setTenantId(getTenantId()); | |||
| return wxCouponChannelService.saveOrUpdate(wxCouponChannel); | |||
| } | |||
| @@ -96,8 +93,7 @@ public class WxCouponChannelController extends BaseController { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponChannelController::addbatch"); | |||
| String[] ids = wxCouponChannelDto.getCouponIds().split(","); | |||
| String[] channelId = wxCouponChannelDto.getChannelId().split(","); | |||
| MallUserInfo user = getUser(); | |||
| return wxCouponChannelService.addBatch(ids, channelId, user.getTenantId(), wxCouponChannelDto.getBeginTime(), wxCouponChannelDto.getEndTime()); | |||
| return wxCouponChannelService.addBatch(ids, channelId, getTenantId(), wxCouponChannelDto.getBeginTime(), wxCouponChannelDto.getEndTime()); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @@ -1,12 +1,14 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.market; | |||
| 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.WxCoupon; | |||
| import com.iformall.domain.vo.WxCouponStatisVo; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.enums.EnumCouponValidType; | |||
| import com.iformall.service.WxCouponService; | |||
| import com.iformall.utils.DateUtils; | |||
| import io.swagger.annotations.Api; | |||
| @@ -62,6 +64,36 @@ public class WxCouponController extends BaseController { | |||
| return wxCouponService.saveOrUpdate(wxCoupon); | |||
| } | |||
| @ApiOperation("根据id更新库存及有效期接口") | |||
| @PostMapping("updateStokeAndValidDate") | |||
| @SystemControllerLog(description = "券投放-库存/有效期更新") | |||
| public ResultData updateStokeAndValidDate(@RequestBody WxCoupon wxCoupon) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponController::updateStokeAndValidDate"); | |||
| if (wxCoupon.getId() == null) { | |||
| return new ResultData(ResultData.ERROR, "缺少id"); | |||
| } | |||
| if(wxCoupon.getRemainInventory() == null || wxCoupon.getInventory() == null) { | |||
| return new ResultData(ErrorCode.COUPON_STOCK_ERR); | |||
| } | |||
| if(wxCoupon.getRemainInventory() > wxCoupon.getInventory()) { | |||
| return new ResultData(ErrorCode.COUPON_STOCK_ERR); | |||
| } | |||
| if(wxCoupon.getValidType() == null) { | |||
| return new ResultData(ErrorCode.COUPON_VALID_DATE_ERR); | |||
| } | |||
| if(wxCoupon.getValidType().equals(EnumCouponValidType.BETWEEN_TWO_TIME.getCode())) { | |||
| if(wxCoupon.getValidEndDate() == null) { | |||
| return new ResultData(ErrorCode.COUPON_VALID_DATE_ERR); | |||
| } | |||
| } else { | |||
| if(wxCoupon.getValidDays() == null) { | |||
| return new ResultData(ErrorCode.COUPON_VALID_DATE_ERR); | |||
| } | |||
| } | |||
| wxCoupon.setTenantId(getTenantId()); | |||
| return wxCouponService.updateCouponStockAndEndTime(wxCoupon); | |||
| } | |||
| @ApiOperation("根据id删除接口") | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @@ -168,7 +200,4 @@ public class WxCouponController extends BaseController { | |||
| return new ResultData(wxCouponService.findPressData(wxCoupon,pageNum,pageSize)); | |||
| } | |||
| } | |||
| @@ -1,10 +1,12 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.market; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| 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.WxCouponInject; | |||
| import com.iformall.service.WxCouponInjectService; | |||
| import com.iformall.service.WxCUserTagsService; | |||
| @@ -18,12 +20,9 @@ import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| @Api(description = "精准投放接口") | |||
| @RestController | |||
| @RequestMapping("couponInject") | |||
| @Api(description = "精准投放接口") | |||
| public class WxCouponInjectController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @@ -58,8 +57,9 @@ public class WxCouponInjectController extends BaseController { | |||
| public ResultData add(@RequestBody WxCouponInject couponInject) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponInjectController::add"); | |||
| couponInject.setTenantId(getUser().getTenantId()); | |||
| couponInject.setMUserId(getUser().getId()); | |||
| MallUserInfo user = getUser(); | |||
| couponInject.setTenantId(user.getTenantId()); | |||
| couponInject.setMUserId(user.getId()); | |||
| return wxCouponInjectService.add(couponInject); | |||
| } | |||
| @@ -1,9 +1,10 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.market; | |||
| import com.github.pagehelper.PageInfo; | |||
| 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.WxAppinfo; | |||
| import com.iformall.domain.po.WxCouponOrder; | |||
| import com.iformall.domain.vo.WxCouponOrderBVo; | |||
| @@ -57,7 +58,6 @@ public class WxCouponOrderController extends BaseController { | |||
| wxCouponOrder.getMerchantName().isEmpty()) { | |||
| wxCouponOrder.setMerchantName(null); | |||
| } | |||
| wxCouponOrder.setSortColumns(WxCouponOrder.Field.Id_DESC); | |||
| return wxCouponOrderService.listAdminAsPage(wxCouponOrder, pageNum, pageSize); | |||
| } | |||
| @@ -1,9 +1,10 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.market; | |||
| import com.github.pagehelper.PageInfo; | |||
| 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.WxCouponSendConfig; | |||
| import com.iformall.service.WxCouponSendConfigService; | |||
| import io.swagger.annotations.Api; | |||
| @@ -17,7 +18,7 @@ import java.util.Date; | |||
| @RestController | |||
| @RequestMapping("wxCouponSendConfig") | |||
| @Api(description = "停车发券和核销发劵接口") | |||
| @Api(description = "注劵配置接口") | |||
| public class WxCouponSendConfigController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @@ -1,10 +1,11 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.market; | |||
| 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.WxCoupon; | |||
| import com.iformall.domain.po.WxCouponSend; | |||
| import com.iformall.domain.vo.WxCouponSendVo; | |||
| @@ -14,6 +15,7 @@ import com.iformall.enums.EnumCouponStatus; | |||
| import com.iformall.service.WxCouponActionLogService; | |||
| import com.iformall.service.WxCouponSendService; | |||
| import com.iformall.service.WxCouponService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| @@ -23,10 +25,10 @@ import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| @RestController | |||
| @RequestMapping("wxCouponSend") | |||
| @Api(description = "注劵接口") | |||
| public class WxCouponSendController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @@ -1,13 +1,15 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.market; | |||
| import com.alibaba.fastjson.JSONArray; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxGame; | |||
| import com.iformall.enums.EnumGameStatus; | |||
| import com.iformall.service.WxGameService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| @@ -19,6 +21,7 @@ import org.springframework.web.bind.annotation.*; | |||
| @RestController | |||
| @RequestMapping("wxGame") | |||
| @Api(description = "游戏接口") | |||
| public class WxGameController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @@ -1,11 +1,13 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.market; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxGameTemplate; | |||
| import com.iformall.service.WxGameTemplateService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| @@ -18,6 +20,7 @@ import java.util.List; | |||
| @RestController | |||
| @RequestMapping("wxGameTemplate") | |||
| @Api(description = "游戏模板接口") | |||
| public class WxGameTemplateController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @@ -1,13 +1,15 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.market; | |||
| 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.dto.WxOrderReportDto; | |||
| import com.iformall.domain.vo.WxMerchantMicroPayVo; | |||
| import com.iformall.enums.EnumOrderStatus; | |||
| import com.iformall.enums.EnumOrderType; | |||
| import com.iformall.service.MarkingDataReportService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| @@ -17,6 +19,7 @@ import org.springframework.web.bind.annotation.*; | |||
| @RestController | |||
| @RequestMapping("wxMerchantMicroPay") | |||
| @Api(description = "B端收银台相关接口") | |||
| public class WxMerchantMicroPayController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @@ -1,9 +1,10 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.market; | |||
| import com.github.pagehelper.PageInfo; | |||
| 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.MallUserInfo; | |||
| import com.iformall.domain.po.WxMerchantSubsidy; | |||
| import com.iformall.domain.vo.WxMerchantSubsidyVo; | |||
| @@ -28,8 +29,8 @@ import java.util.List; | |||
| import java.util.Map; | |||
| @RestController | |||
| @Api(description = "商户补贴接口") | |||
| @RequestMapping("subsidy") | |||
| @Api(description = "商户补贴接口") | |||
| public class WxMerchantSubsidyController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @@ -45,8 +46,7 @@ public class WxMerchantSubsidyController extends BaseController { | |||
| if (wxMerchantSubsidy == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空"); | |||
| } | |||
| MallUserInfo user = getUser(); | |||
| wxMerchantSubsidy.setTenantId(user.getTenantId()); | |||
| wxMerchantSubsidy.setTenantId(getTenantId()); | |||
| if(StringUtils.isNotBlank(wxMerchantSubsidy.getStatusStr())) { | |||
| String [] statusAttr = wxMerchantSubsidy.getStatusStr().split(","); | |||
| List<Integer> tmpList = new ArrayList<Integer>(); | |||
| @@ -73,8 +73,7 @@ public class WxMerchantSubsidyController extends BaseController { | |||
| if (wxMerchantSubsidy == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空"); | |||
| } | |||
| MallUserInfo user = getUser(); | |||
| wxMerchantSubsidy.setTenantId(user.getTenantId()); | |||
| wxMerchantSubsidy.setTenantId(getTenantId()); | |||
| if(StringUtils.isNotBlank(wxMerchantSubsidy.getStatusStr())) { | |||
| String [] statusAttr = wxMerchantSubsidy.getStatusStr().split(","); | |||
| List<Integer> tmpList = new ArrayList<Integer>(); | |||
| @@ -99,8 +98,7 @@ public class WxMerchantSubsidyController extends BaseController { | |||
| if (wxMerchantSubsidy == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空"); | |||
| } | |||
| MallUserInfo user = getUser(); | |||
| wxMerchantSubsidy.setTenantId(user.getTenantId()); | |||
| wxMerchantSubsidy.setTenantId(getTenantId()); | |||
| wxMerchantSubsidy.setStatus(EnumMerchantSubsidyStatus.MANUAL_SUBSIDIED.getCode()); | |||
| wxMerchantSubsidy.setUpdateDate(new Date()); | |||
| if(StringUtils.isNotBlank(wxMerchantSubsidy.getIdStr())) { | |||
| @@ -1,11 +1,14 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.market; | |||
| 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.dto.OrderSaveDto; | |||
| import com.iformall.domain.po.WxCUser; | |||
| import com.iformall.domain.po.WxCoupon; | |||
| import com.iformall.domain.po.WxCouponChannel; | |||
| import com.iformall.domain.po.WxOrder; | |||
| import com.iformall.domain.vo.WxOrderQueryVo; | |||
| @@ -15,7 +18,9 @@ import com.iformall.enums.EnumUserType; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.WxCUserService; | |||
| import com.iformall.service.WxCouponChannelService; | |||
| import com.iformall.service.WxCouponService; | |||
| import com.iformall.service.WxOrderService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| @@ -30,6 +35,7 @@ import java.util.Map; | |||
| @RestController | |||
| @RequestMapping("wxOrder") | |||
| @Api(description = "订单相关接口") | |||
| public class WxOrderController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @@ -42,6 +48,9 @@ public class WxOrderController extends BaseController { | |||
| @Autowired | |||
| private WxCUserService wxCUserService; | |||
| @Autowired | |||
| private WxCouponService wxCouponService; | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @@ -127,103 +136,37 @@ public class WxOrderController extends BaseController { | |||
| return new ResultData(data); | |||
| } | |||
| @ApiOperation(value = "下订单", notes = "{\"couponChannelId\":\"String\",\"couponId\":\"String\",\"press\":\"String\",\"orderGroupId\":\"String\",\"formId\":\"String\"}") | |||
| @ApiOperation(value = "积分兑换订单", notes = "{\"couponChannelId\":\"String\",\"couponId\":\"String\",\"press\":\"String\",\"orderGroupId\":\"String\",\"formId\":\"String\"}") | |||
| @PostMapping("save") | |||
| public ResultData saveOrder(@RequestBody Map<String, String> paramMap) { | |||
| logger.info("OrderSave: " + paramMap.toString()); | |||
| //Assert.notNull(wxOrders.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| String couponChannelIdStr = paramMap.get("couponChannelId"); | |||
| String couponIdStr = paramMap.get("couponId"); | |||
| String pressStr = paramMap.get("press"); | |||
| String orderGroupIdStr = paramMap.get("orderGroupId"); | |||
| String formId = paramMap.get("formId"); | |||
| //被操作人的ID | |||
| String userIdStr = paramMap.get("userId"); | |||
| Long userId = 0L; | |||
| if (StringUtils.isNotBlank(userIdStr)) { | |||
| userId = Long.valueOf(userIdStr); | |||
| } | |||
| WxCUser wxCUser = wxCUserService.getById(userId); | |||
| if (wxCUser == null) { | |||
| throw new MallinkException(ErrorCode.USER_NOT_MEMBER); | |||
| } | |||
| if (StringUtils.isBlank(couponChannelIdStr)) { | |||
| public ResultData saveOrder(@RequestBody OrderSaveDto orderSaveDto) { | |||
| logger.info("OrderSave: " + orderSaveDto); | |||
| if (orderSaveDto.getCouponChannelId() == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId不能为空"); | |||
| } | |||
| Long couponChannelId = 0L, couponId = 0L, orderGroupId = null; | |||
| boolean isPress = false; | |||
| if (StringUtils.isNotBlank(couponChannelIdStr)) { | |||
| try { | |||
| couponChannelId = Long.valueOf(couponChannelIdStr); | |||
| } catch (NumberFormatException e) { | |||
| logger.error("couponChannelId convert error, " + couponChannelIdStr + ", e:" + e.getMessage()); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR.getCode(), "couponChannelId: " + couponChannelIdStr + ", e:" + e.getMessage()); | |||
| } | |||
| WxCouponChannel wxCouponChannel = wxCouponChannelService.getById(couponChannelId); | |||
| if (wxCouponChannel == null) { | |||
| logger.error("couponChannelId convert error, " + couponChannelIdStr); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR); | |||
| } | |||
| if (wxCouponChannel.getTargetAd().equals(EnumCouponChannelType.COUPON_CHANNEL_ID_TIMED.getCode())) { | |||
| Date now = new Date(); | |||
| if (wxCouponChannel.getBeginTime().getTime() > now.getTime()) { | |||
| logger.error("此券活动未开始:" + couponChannelIdStr); | |||
| return new ResultData(ErrorCode.COUPON_CHANNEL_IS_NOT_STARTED); | |||
| } | |||
| if (wxCouponChannel.getEndTime().getTime() < now.getTime()) { | |||
| logger.error("此券活动已结束:" + couponChannelIdStr); | |||
| return new ResultData(ErrorCode.COUPON_CHANNEL_IS_END); | |||
| } | |||
| } | |||
| if (wxCouponChannel.getStatus() == EnumCouponChannelStatus.STATUS_TAKE_OFFF.getCode()) { | |||
| logger.error("此券已下架:" + couponChannelIdStr); | |||
| return new ResultData(ErrorCode.COUPON_CHANNEL_IS_TAKE_OFF); | |||
| } | |||
| if (StringUtils.isBlank(couponIdStr)) { | |||
| couponId = wxCouponChannel.getCouponId(); | |||
| } | |||
| } | |||
| if (couponId <= 0 && !StringUtils.isBlank(couponIdStr)) { | |||
| try { | |||
| couponId = Long.valueOf(couponIdStr); | |||
| } catch (NumberFormatException e) { | |||
| logger.error("couponId convert error, " + couponIdStr + ", e:" + e.getMessage()); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR.getCode(), "couponId: " + couponIdStr + ", e:" + e.getMessage()); | |||
| } | |||
| } | |||
| WxCouponChannel wxCouponChannel = wxCouponChannelService.getById(orderSaveDto.getCouponChannelId()); | |||
| ResultData resultData = couponChannelCheck(orderSaveDto, wxCouponChannel); | |||
| if (resultData != null) return resultData; | |||
| if (couponId <= 0) { | |||
| Long couponId = orderSaveDto.getCouponId() == null ? wxCouponChannel.getCouponId() : orderSaveDto.getCouponId(); | |||
| if (couponId == null) { | |||
| logger.error("couponChannelId或者couponId不能为空"); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "couponChannelId或者couponId不能为空"); | |||
| } | |||
| if(pressStr != null) { | |||
| try{ | |||
| isPress = Boolean.valueOf(pressStr); | |||
| } catch (Exception e) { | |||
| logger.error("press转换失败"); | |||
| } | |||
| } | |||
| if (orderGroupIdStr != null) { | |||
| try { | |||
| orderGroupId = Long.valueOf(orderGroupIdStr); | |||
| } catch (Exception e) { | |||
| logger.error("orderGroupId转换失败"); | |||
| } | |||
| } | |||
| //用于标记当前操作人为A端用户 | |||
| wxCUser.setOperatorType(EnumUserType.MALLUSER.getCode()); | |||
| wxCUser.setOperatorId(getUser().getId()); | |||
| try { | |||
| WxOrder order = wxOrderService.saveCouponOrder(wxCUser, couponChannelId, couponId, isPress, orderGroupId, formId); | |||
| WxCUser user = wxCUserService.getById(orderSaveDto.getUserId()); | |||
| //用于标记当前操作人为A端用户 | |||
| user.setOperatorType(EnumUserType.MALLUSER.getCode()); | |||
| user.setOperatorId(getUserId()); | |||
| WxOrder order = null; | |||
| WxCoupon coupon = wxCouponService.getById(couponId); | |||
| if (coupon == null) { | |||
| return new ResultData(ErrorCode.COUPON_IS_EMPTY); | |||
| } | |||
| if (!wxOrderService.checkCouponIsFree(coupon)) | |||
| return new ResultData(ErrorCode.COUPON_IS_NOT_FREE); | |||
| // 免费券 | |||
| order = wxOrderService.saveFreeOrderForCoupon(user, coupon, orderSaveDto.getCouponChannelId(), orderSaveDto.getFormId()); | |||
| return new ResultData(order); | |||
| } catch (MallinkException e) { | |||
| logger.error(e.getMessage()); | |||
| @@ -234,4 +177,29 @@ public class WxOrderController extends BaseController { | |||
| } | |||
| } | |||
| private ResultData couponChannelCheck(@RequestBody OrderSaveDto orderSaveDto, WxCouponChannel wxCouponChannel) { | |||
| if (wxCouponChannel == null) { | |||
| logger.error("couponChannelId convert error, " + orderSaveDto.getCouponChannelId()); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_CAST_ERROR); | |||
| } | |||
| if (wxCouponChannel.getTargetAd().equals(EnumCouponChannelType.COUPON_CHANNEL_ID_TIMED.getCode())) { | |||
| Date now = new Date(); | |||
| if (wxCouponChannel.getBeginTime().getTime() > now.getTime()) { | |||
| logger.error("此券活动未开始:" + orderSaveDto.getCouponChannelId()); | |||
| return new ResultData(ErrorCode.COUPON_CHANNEL_IS_NOT_STARTED); | |||
| } | |||
| if (wxCouponChannel.getEndTime().getTime() < now.getTime()) { | |||
| logger.error("此券活动已结束:" + orderSaveDto.getCouponChannelId()); | |||
| return new ResultData(ErrorCode.COUPON_CHANNEL_IS_END); | |||
| } | |||
| } | |||
| if (wxCouponChannel.getStatus() == EnumCouponChannelStatus.STATUS_TAKE_OFFF.getCode()) { | |||
| logger.error("此券已下架:" + orderSaveDto.getCouponChannelId()); | |||
| return new ResultData(ErrorCode.COUPON_CHANNEL_IS_TAKE_OFF); | |||
| } | |||
| return null; | |||
| } | |||
| } | |||
| @@ -1,8 +1,9 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.market; | |||
| 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.vo.WxOrderGroupMarketing; | |||
| import com.iformall.service.WxOrderGroupService; | |||
| import io.swagger.annotations.Api; | |||
| @@ -19,7 +20,7 @@ import org.springframework.web.bind.annotation.RestController; | |||
| @RestController | |||
| @RequestMapping("/orderGroup") | |||
| @Api(description = "拼团接口") | |||
| @Api(description = "拼团相关接口") | |||
| public class WxOrderGroupController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @@ -1,16 +1,18 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.market; | |||
| 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.WxOrder; | |||
| import com.iformall.domain.po.WxPayOrder; | |||
| import com.iformall.enums.EnumPayStatus; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.WxOrderService; | |||
| import com.iformall.service.WxPayOrderService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| @@ -24,6 +26,7 @@ import java.util.Map; | |||
| @RestController | |||
| @RequestMapping("wxPayOrder") | |||
| @Api(description = "支付订单接口") | |||
| public class WxPayOrderController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @@ -97,57 +100,22 @@ public class WxPayOrderController extends BaseController { | |||
| logger.info("orderId不能为空: " + paramMap.toString()); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "orderId不能为空"); | |||
| } | |||
| Long payOrderId = 0L, orderId = 0L; | |||
| try { | |||
| orderId = Long.valueOf(orderIdStr); | |||
| Long.valueOf(orderIdStr); | |||
| } catch (NumberFormatException e) { | |||
| logger.error("orderId参数不正确: " + paramMap.toString() + ", e:" + e.getMessage()); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "orderId参数不正确"); | |||
| } | |||
| if (!StringUtils.isBlank(payOrderIdStr)) { | |||
| try { | |||
| payOrderId = Long.valueOf(payOrderIdStr); | |||
| Long.valueOf(payOrderIdStr); | |||
| } catch (NumberFormatException e) { | |||
| logger.error("payOrderId参数不正确: " + paramMap.toString() + ", e:" + e.getMessage()); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "payOrderId参数不正确"); | |||
| } | |||
| } | |||
| // 免费券直接返回成功 | |||
| return new ResultData(Result.SUCCESS, "免费券支付状态更新成功"); | |||
| WxPayOrder payOrder = new WxPayOrder(); | |||
| payOrder.setId(payOrderId); | |||
| payOrder.setOrderId(orderId); | |||
| payOrder.setPayOrderStatus(status); | |||
| payOrder.setFailReason(reasonStr); | |||
| WxOrder order = null; | |||
| try { | |||
| if(status.equals(EnumPayStatus.PAY_STATUS_SUCCESS.getCode()) && !payOrderIdStr.equals("0")) { | |||
| // 前端提示支付成功, 不作为支付成功标志,只检查支付订单状态 | |||
| // 有价券不走update, callback更新 | |||
| payOrder = wxPayOrderService.getById(payOrderId); | |||
| if(payOrder.getPayOrderStatus().equals(EnumPayStatus.PAY_STATUS_SUCCESS.getCode())) { | |||
| order = wxOrderService.getById(orderId); | |||
| return new ResultData(Result.SUCCESS, "支付状态更新成功", order); | |||
| } else { | |||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR, "支付未状态,请等待!!"); | |||
| } | |||
| } else { | |||
| // 1. 免费券,status = 1,成功 | |||
| // 2. 有价券,status = 2,取消支付 | |||
| if(status.equals(EnumPayStatus.PAY_STATUS_SUCCESS.getCode())) { | |||
| wxPayOrderService.handlePayOrderStatusUpdate(payOrder, 1); | |||
| } else if (status.equals(EnumPayStatus.PAY_STATUS_FAIL.getCode())) { | |||
| wxPayOrderService.handlePayOrderStatusUpdate(payOrder, 2); | |||
| } | |||
| } | |||
| return new ResultData(Result.SUCCESS, "支付状态更新成功"); | |||
| } catch (MallinkException e) { | |||
| logger.error("支付状态更新失败2: " + payOrder.toString() + ", e:" + e.getMessage()); | |||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||
| } catch (Exception e) { | |||
| logger.error("支付状态更新失败3: " + payOrder.toString() + ", e:" + e.getMessage()); | |||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR, "支付状态更新失败3: " + payOrder.toString() + ", e:" + e.getMessage()); | |||
| } | |||
| } | |||
| } | |||
| @@ -1,11 +1,13 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.market; | |||
| 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.vo.WxProfitSharingOrderQueryVo; | |||
| import com.iformall.domain.vo.WxProfitSharingOrderVo; | |||
| import com.iformall.service.WxProfitSharingOrderService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| @@ -21,6 +23,7 @@ import java.util.Map; | |||
| */ | |||
| @RestController | |||
| @RequestMapping("wxProfitSharingOrder") | |||
| @Api(description = "微信分账订单接口") | |||
| public class WxProfitSharingOrderController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @@ -1,10 +1,11 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.market; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| 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.WxQuestion; | |||
| import com.iformall.domain.po.WxQuestionConfig; | |||
| import com.iformall.enums.EnumQuestionConfigStatus; | |||
| @@ -1,6 +1,8 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.market; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.controller.base.BaseController; | |||
| import io.swagger.annotations.Api; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| @@ -18,6 +20,7 @@ import io.swagger.annotations.ApiOperation; | |||
| @RestController | |||
| @RequestMapping("/refund") | |||
| @Api(description = "微信退款订单接口") | |||
| public class WxRefundOrderController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @@ -1,6 +1,7 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.market; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.utils.PayUtil; | |||
| @@ -26,8 +27,8 @@ import java.awt.image.BufferedImage; | |||
| import java.util.Map; | |||
| @RestController | |||
| @Api(description = "商城补贴支付接口") | |||
| @RequestMapping("wxSubsidy") | |||
| @Api(description = "商城补贴支付接口") | |||
| public class WxSubsidyController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @@ -1,7 +1,8 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.market; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.enums.EnumWxTopicStatus; | |||
| import com.iformall.service.*; | |||
| @@ -1,10 +1,12 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.market; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.dto.WxUserCouponDto; | |||
| import com.iformall.service.WxUserCouponService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| @@ -19,6 +21,7 @@ import org.springframework.web.bind.annotation.RestController; | |||
| */ | |||
| @RestController | |||
| @RequestMapping("wxUserCoupon") | |||
| @Api(description = "会员卡券查询接口") | |||
| public class WxUserCouponController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @@ -33,10 +36,10 @@ public class WxUserCouponController extends BaseController { | |||
| public ResultData findByStatus(@RequestBody WxUserCouponDto wxUserCoupon) { | |||
| logger.debug("[" + getIpAddr() + "] WxUserCouponController::findByStatus"); | |||
| //根据用户id,用户卡券状态查找 | |||
| if(wxUserCoupon==null||wxUserCoupon.getcUserId()==null||wxUserCoupon.getCouponStatus()==null){ | |||
| if(wxUserCoupon==null||wxUserCoupon.getCUserId()==null||wxUserCoupon.getCouponStatus()==null){ | |||
| return new ResultData(Result.ERROR,"查询失败"); | |||
| } | |||
| return new ResultData(Result.SUCCESS,"查询成功",wxUserCouponService.findList(wxUserCoupon.getcUserId(),wxUserCoupon.getCouponStatus())); | |||
| return new ResultData(Result.SUCCESS,"查询成功",wxUserCouponService.findList(wxUserCoupon.getCUserId(),wxUserCoupon.getCouponStatus())); | |||
| } | |||
| @@ -1,4 +1,4 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.mem; | |||
| import cn.afterturn.easypoi.excel.ExcelImportUtil; | |||
| import cn.afterturn.easypoi.excel.entity.ImportParams; | |||
| @@ -0,0 +1,168 @@ | |||
| package com.iformall.controller.mem; | |||
| import cn.afterturn.easypoi.excel.ExcelImportUtil; | |||
| import cn.afterturn.easypoi.excel.entity.ImportParams; | |||
| import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; | |||
| import cn.afterturn.easypoi.handler.impl.ExcelDataHandlerDefaultImpl; | |||
| import cn.afterturn.easypoi.handler.inter.IExcelDataHandler; | |||
| import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.domain.po.WxShop; | |||
| import com.iformall.domain.vo.WxBillDailyVo; | |||
| import com.iformall.enums.EnumDelStatus; | |||
| import com.iformall.enums.EnumShopStatus; | |||
| import com.iformall.mapper.WxShopMapper; | |||
| import com.iformall.service.WxBillDailyService; | |||
| import org.apache.shiro.session.UnknownSessionException; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.data.redis.core.StringRedisTemplate; | |||
| import org.springframework.scheduling.annotation.Async; | |||
| import org.springframework.stereotype.Component; | |||
| import java.io.File; | |||
| import java.math.BigDecimal; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| import java.util.concurrent.TimeUnit; | |||
| @Component | |||
| public class BillDailyAsyncTask { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxBillDailyService wxBillDailyService; | |||
| @Autowired | |||
| StringRedisTemplate stringRedisTemplate; | |||
| @Autowired | |||
| WxShopMapper wxShopMapper; | |||
| private class BillDailyExcelHandler extends ExcelDataHandlerDefaultImpl<WxBillDailyVo> { | |||
| @Override | |||
| public Object importHandler(WxBillDailyVo obj, String name, Object value) { | |||
| if (value == null) { | |||
| value = ""; | |||
| } | |||
| System.out.println(name + " + " + value.toString()); | |||
| return super.importHandler(obj, name, value); | |||
| } | |||
| } | |||
| private void set_redis_value(String importKey, String allCount, String allSuccessCount, String processCount, String failCount, boolean fail) { | |||
| stringRedisTemplate.opsForHash().put(importKey, "allCount", allCount); | |||
| stringRedisTemplate.opsForHash().put(importKey, "allSuccessCount", allSuccessCount); | |||
| stringRedisTemplate.opsForHash().put(importKey, "processCount", processCount); | |||
| stringRedisTemplate.opsForHash().put(importKey, "failCount", failCount); | |||
| if (fail) { | |||
| stringRedisTemplate.expire(importKey, 10, TimeUnit.SECONDS); | |||
| } | |||
| } | |||
| @Async | |||
| public void importExcelData(File file, MallUserInfo user, String importKey, String tenantId) { | |||
| ImportParams params = new ImportParams(); | |||
| // 需要验证 | |||
| params.setImportFields(new String[]{"商铺号", "费用类型", "实际应收金额(元)", "实收金额(元)", "缴款截止日期", "逾期天数"}); | |||
| IExcelDataHandler<WxBillDailyVo> handler = new BillDailyAsyncTask.BillDailyExcelHandler(); | |||
| handler.setNeedHandlerFields(new String[]{"商铺号", "费用类型", "实际应收金额(元)", "实收金额(元)", "缴款截止日期", "逾期天数"}); | |||
| params.setNeedVerify(true); | |||
| ExcelImportResult<WxBillDailyVo> datalist = null; | |||
| try { | |||
| datalist = ExcelImportUtil.importExcelMore(file, WxBillDailyVo.class, params); | |||
| } catch (Exception e) { | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| logger.error(e.getMessage()); | |||
| // 删除缓存文件 | |||
| file.delete(); | |||
| return; | |||
| } | |||
| // 删除缓存文件 | |||
| file.delete(); | |||
| if (datalist == null) { | |||
| logger.error("导入模板失败: 模板数据解析失败"); | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| return; | |||
| } | |||
| List<WxBillDailyVo> successList = datalist.getList(); | |||
| List<WxBillDailyVo> failList = datalist.getFailList(); | |||
| List<WxBillDailyVo> processList = new ArrayList<>(); | |||
| int fail = 0; | |||
| for (WxBillDailyVo vo : successList) { | |||
| //店铺 | |||
| WxShop shop = new WxShop(); | |||
| shop.setShopNumber(vo.getShopNumber()); | |||
| shop.setTenantId(tenantId); | |||
| shop.setStatus(EnumShopStatus.RENT.getCode()); | |||
| shop.setIsDel(EnumDelStatus.NOT_DEL.getCode()); | |||
| WxShop wxShop = wxShopMapper.selectOne(shop); | |||
| if (wxShop == null) { | |||
| logger.error("店铺不存在", vo.toString()); | |||
| fail++; | |||
| continue; | |||
| } | |||
| String receivePayStr = vo.getReceivePayStr(); | |||
| double receivePayD = new BigDecimal(receivePayStr).doubleValue(); | |||
| if (receivePayD <= 0) { | |||
| logger.error("实际应收金额小于等于0", vo.toString()); | |||
| fail++; | |||
| continue; | |||
| } | |||
| String payStr = vo.getPayStr(); | |||
| double payD = new BigDecimal(payStr).doubleValue(); | |||
| if (payD < 0) { | |||
| logger.error("实收金额小于0", vo.toString()); | |||
| fail++; | |||
| continue; | |||
| } | |||
| if (receivePayD < payD) { | |||
| logger.error("实际应收金额小于实收金额", vo.toString()); | |||
| fail++; | |||
| continue; | |||
| } | |||
| long receivePay = new BigDecimal(receivePayD).multiply(new BigDecimal(100)).longValue(); | |||
| vo.setReceivePay(receivePay); | |||
| long pay = new BigDecimal(payD).multiply(new BigDecimal(100)).longValue(); | |||
| vo.setPay(pay); | |||
| vo.setTenantId(tenantId); | |||
| vo.setShopId(wxShop.getId()); | |||
| vo.setRentShopType(wxShop.getType()); | |||
| processList.add(vo); | |||
| } | |||
| logger.info("验证通过的数量: " + processList.size()); | |||
| logger.info("验证未通过的数量: " + failList.size()); | |||
| int all_success = processList.size(); | |||
| int all_fail = failList.size() + fail; | |||
| int total = processList.size() + all_fail; | |||
| //添加到redis里 | |||
| set_redis_value(importKey, "" + total, "" + all_success, "0", "" + all_fail, total == all_fail); | |||
| if (processList.size() > 0) { | |||
| try { | |||
| processList.parallelStream().forEach(billDaily -> { | |||
| try { | |||
| //插入数据 | |||
| wxBillDailyService.insertData(billDaily, importKey, user); | |||
| } catch (UnknownSessionException ue) { | |||
| logger.error("session :" + ue.getMessage()); | |||
| } | |||
| }); | |||
| } catch (Exception e) { | |||
| set_redis_value(importKey, "1", "0", "0", "1", true); | |||
| e.printStackTrace(); | |||
| logger.error("导入模板失败:" + e.getMessage()); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -1,4 +1,4 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.mem; | |||
| import com.alibaba.fastjson.JSON; | |||
| import com.alibaba.fastjson.JSONArray; | |||
| @@ -8,7 +8,7 @@ import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.dto.WxCUserBasicInfoDto; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.dto.WxCUserBasicInfoFilterDto; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.enums.EnumAssignTagsTrigger; | |||
| @@ -40,7 +40,6 @@ import java.util.concurrent.TimeUnit; | |||
| import java.util.stream.Collectors; | |||
| import static com.iformall.domain.po.WxCouponOrder.Field.CreateDate_DESC; | |||
| import static com.iformall.ueditor.define.AppInfo.info; | |||
| @RestController | |||
| @RequestMapping("wxCUserBasicInfo") | |||
| @@ -48,6 +47,9 @@ import static com.iformall.ueditor.define.AppInfo.info; | |||
| public class WxCUserBasicInfoController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private String fmUploadDir; | |||
| @Autowired | |||
| private WxCUserBasicInfoService wxCUserBasicInfoService; | |||
| @@ -138,12 +140,12 @@ public class WxCUserBasicInfoController extends BaseController { | |||
| } | |||
| String tenantId = getTenantId(); | |||
| wxCUserBasicInfo.setTenantId(tenantId); | |||
| wxCUserBasicInfo.setSortColumns(WxCUserBasicInfo.Field.UpdateDate_DESC); | |||
| wxCUserBasicInfo.setSortColumns(WxCUserBasicInfo.Field.ActiveTime_DESC); | |||
| PageInfo<WxCUserBasicInfo> page = wxCUserBasicInfoService.listAsPage(wxCUserBasicInfo, pageNum, pageSize); | |||
| if (page.getSize() > 0) { | |||
| for (WxCUserBasicInfo info : page.getList()) { | |||
| setUserInfoLevel(info); | |||
| // setUserInfoLevel(info); | |||
| setUserInfoCarCount(info); | |||
| } | |||
| } | |||
| @@ -162,10 +164,9 @@ public class WxCUserBasicInfoController extends BaseController { | |||
| @SystemControllerLog(description = "会员管理-更新") | |||
| public ResultData update(@RequestBody WxCUserBasicInfo wxCUserBasicInfo) { | |||
| logger.debug("[" + getIpAddr() + "] WxCUserBasicInfoController::update"); | |||
| MallUserInfo currentUser = getUser(); | |||
| WxCUserBasicInfo oldInfo = wxCUserBasicInfoService.getById(wxCUserBasicInfo.getId()); | |||
| if (!oldInfo.getPhone().equals(wxCUserBasicInfo.getPhone())) { | |||
| if (checkUniquePhone(wxCUserBasicInfo.getPhone(), currentUser.getTenantId()) > 0) { | |||
| if (checkUniquePhone(wxCUserBasicInfo.getPhone(), getTenantId()) > 0) { | |||
| return new ResultData(ErrorCode.USER_PHONE_IS_FOUND.getCode(), "手机号已存在"); | |||
| } | |||
| } | |||
| @@ -227,7 +228,7 @@ public class WxCUserBasicInfoController extends BaseController { | |||
| public ResultData findOrderCouponByUserId(Long userId, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxCUserBasicInfoController::findOrderCouponByUserId"); | |||
| WxCouponOrder corder = new WxCouponOrder(); | |||
| corder.setcUserId(userId); | |||
| corder.setCUserId(userId); | |||
| corder.setTenantId(getTenantId()); | |||
| corder.setSortColumns(CreateDate_DESC); | |||
| PageInfo<WxCouponOrder> page = wxCouponOrderService.listAsPage(corder, pageNum, pageSize); | |||
| @@ -330,7 +331,7 @@ public class WxCUserBasicInfoController extends BaseController { | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "processCount", ""); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", ""); | |||
| String fpath = Constant.fileDirectory; | |||
| String fpath = fmUploadDir; | |||
| File targetFile = new File(fpath); | |||
| if (!targetFile.exists()) { | |||
| targetFile.mkdirs(); | |||
| @@ -1,9 +1,10 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.mem; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxCUserCar; | |||
| import com.iformall.service.WxCUserCarService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| @@ -1,6 +1,7 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.mem; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.controller.base.BaseController; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| @@ -1,4 +1,4 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.mem; | |||
| import java.text.DecimalFormat; | |||
| import java.text.NumberFormat; | |||
| @@ -11,6 +11,8 @@ import java.util.List; | |||
| import java.util.Map; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.dto.MarkingCouponDataReportDto; | |||
| import com.iformall.domain.po.WxCouponOrder; | |||
| import com.iformall.mapper.WxCUserBasicInfoMapper; | |||
| import com.iformall.service.WxCUserBasicInfoService; | |||
| @@ -164,10 +166,14 @@ public class WxCUserDataController extends BaseController { | |||
| params.put("startTime", startTime); | |||
| params.put("endTime", endTime); | |||
| params.put("tenantId", getTenantId()); | |||
| List<TouchUsersReportVo> list = wxUserVisitService.touchUsersReportList(params); | |||
| MarkingCouponDataReportDto markingCouponDataReportDto = new MarkingCouponDataReportDto(); | |||
| markingCouponDataReportDto.setTenantId(getTenantId()); | |||
| markingCouponDataReportDto.setStartTime(startTime); | |||
| markingCouponDataReportDto.setEndTime(endTime); | |||
| List<TouchUsersReportVo> list = wxUserVisitService.touchUsersReportList(markingCouponDataReportDto); | |||
| Map<String, TouchUsersReportVo> dateMap = new HashMap<>(); | |||
| for (TouchUsersReportVo vo : list) { | |||
| dateMap.put(vo.getxTime(), vo); | |||
| dateMap.put(vo.getXTime(), vo); | |||
| } | |||
| List<UserStructureVo> weekVos = new ArrayList<>();//每周uv | |||
| List<UserStructureVo> monthVos = new ArrayList<>();//每月uv | |||
| @@ -278,7 +284,7 @@ public class WxCUserDataController extends BaseController { | |||
| List<CUserDateAmountVo> datas = wxCouponOrderService.queryPriceTotalGroup(tenantId, sTime, eTime); | |||
| Map<String, Integer> dataMap = new HashMap<>(); | |||
| for (CUserDateAmountVo v : datas) { | |||
| dataMap.put(v.getxTime(), v.getPrice()); | |||
| dataMap.put(v.getXTime(), v.getPrice()); | |||
| } | |||
| Integer todayCount = 0;//今日金额数 | |||
| Integer yesterdayCount = 0;//昨日金额数 | |||
| @@ -1,9 +1,10 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.mem; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxCUserTags; | |||
| import com.iformall.service.WxCUserTagsService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| @@ -1,8 +1,10 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.mem; | |||
| import com.github.pagehelper.PageInfo; | |||
| 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.WxCreditHistory; | |||
| import com.iformall.domain.vo.WxCreditHistoryVo; | |||
| import com.iformall.exception.MallinkException; | |||
| @@ -50,8 +52,9 @@ public class WxCreditHistoryController extends BaseController | |||
| @PostMapping("add") | |||
| public ResultData add(@RequestBody WxCreditHistory wxCreditHistory) { | |||
| logger.debug("[" + getIpAddr() + "] WxCreditHistoryController::add"); | |||
| wxCreditHistory.setTenantId(getTenantId()); | |||
| wxCreditHistory.setOperatorId(getUser().getId()); | |||
| MallUserInfo user = getUser(); | |||
| wxCreditHistory.setTenantId(user.getTenantId()); | |||
| wxCreditHistory.setOperatorId(user.getId()); | |||
| try { | |||
| WxCreditHistory credit = wxCreditHistoryService.saveOrUpdate(wxCreditHistory); | |||
| return new ResultData(Result.SUCCESS, "操作成功", credit); | |||
| @@ -1,6 +1,7 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.mem; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.controller.base.BaseController; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| @@ -1,9 +1,10 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.mem; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxScoreHistory; | |||
| import com.iformall.service.WxScoreHistoryService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| @@ -1,14 +1,11 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.mem; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxScoreRules; | |||
| import com.iformall.service.WxScoreRulesService; | |||
| 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; | |||
| @@ -1,8 +1,9 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.mem; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxUserChannel; | |||
| import com.iformall.service.WxUserChannelService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| @@ -1,9 +1,10 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.msg; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxMsgCallback; | |||
| import com.iformall.service.WxMsgCallbackService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| @@ -17,7 +18,7 @@ import org.springframework.web.bind.annotation.*; | |||
| import java.util.Map; | |||
| @RestController | |||
| @RequestMapping("wxMsgCallback") | |||
| @RequestMapping("msgCallback") | |||
| public class WxMsgCallbackController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @@ -78,33 +79,4 @@ public class WxMsgCallbackController extends BaseController { | |||
| logger.debug("[" + getIpAddr() + "] WxMsgCallbackController::findById"); | |||
| return new ResultData(Result.SUCCESS, "查询成功", wxMsgCallbackService.getById(id)); | |||
| } | |||
| @PostMapping(value = "/receivemsg/{tenantId}") | |||
| public void receivemsg(@PathVariable String tenantId, @RequestParam Map<String, String> param) { | |||
| logger.debug("[" + getIpAddr() + "] WxMsgCallbackController::receivemsg"); | |||
| logger.info(param.toString()); | |||
| //解析param数据插入数据库中 | |||
| wxMsgCallbackService.saveOrUpdate(tenantId,param); | |||
| } | |||
| @RequestMapping(value = "/receivemodel/{tenantId}") | |||
| public void receivemodel(@PathVariable String tenantId, @RequestParam Map<String, String> param) { | |||
| logger.debug("[" + getIpAddr() + "] WxMsgCallbackController::receivemodel"); | |||
| logger.info(param.toString()); | |||
| //解析param数据插入数据库中 | |||
| wxMsgCallbackService.receivemodel(tenantId, param); | |||
| } | |||
| @RequestMapping(value = "/receiveverifymodel/{tenantId}") | |||
| public void receiveverifymodel(@PathVariable String tenantId, @RequestParam Map<String, String> param) { | |||
| logger.debug("[" + getIpAddr() + "] WxMsgCallbackController::receiveverifymodel"); | |||
| logger.info(param.toString()); | |||
| //解析param数据插入数据库中 | |||
| wxMsgCallbackService.receiveverifymodel(tenantId, param); | |||
| } | |||
| } | |||
| @@ -1,9 +1,10 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.msg; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxMsgConfig; | |||
| import com.iformall.service.WxMsgConfigService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| @@ -1,32 +1,17 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.msg; | |||
| import com.alibaba.fastjson.JSON; | |||
| 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.domain.dto.WxCUserBasicInfoFilterListDto; | |||
| import com.iformall.domain.po.PushLimit; | |||
| import com.iformall.domain.po.WxCUserBasicInfo; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.msg.WxMsg; | |||
| import com.iformall.domain.po.WxMsgConfig; | |||
| import com.iformall.enums.EnumMsgSend; | |||
| import com.iformall.enums.EnumMsgStatus; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.WxMsgConfigMapper; | |||
| import com.iformall.service.PushLimitService; | |||
| import com.iformall.service.WxCUserBasicInfoService; | |||
| import com.iformall.service.WxCUserTagsService; | |||
| import com.iformall.service.WxMsgService; | |||
| import com.iformall.utils.Constant; | |||
| import com.iformall.utils.DateUtils; | |||
| import io.netty.util.internal.StringUtil; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.apache.commons.io.IOUtils; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| @@ -36,7 +21,6 @@ import org.springframework.web.multipart.MultipartFile; | |||
| import java.io.File; | |||
| import java.io.FileOutputStream; | |||
| import java.util.*; | |||
| import java.util.stream.Collectors; | |||
| /** | |||
| * @author gongbiao | |||
| @@ -46,6 +30,8 @@ import java.util.stream.Collectors; | |||
| public class WxMsgController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private String fmUploadDir; | |||
| @Autowired | |||
| private WxMsgService wxMsgService; | |||
| @@ -105,11 +91,11 @@ public class WxMsgController extends BaseController { | |||
| } | |||
| String filename = UUID.randomUUID() + file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); | |||
| File path = new File(Constant.fileDirectory); | |||
| File path = new File(fmUploadDir); | |||
| if (!path.exists()) { | |||
| path.mkdirs(); | |||
| } | |||
| String filepath = Constant.fileDirectory + File.separator + filename; | |||
| String filepath = fmUploadDir + filename; | |||
| try { | |||
| FileOutputStream out = new FileOutputStream(new File(filepath)); | |||
| IOUtils.write(file.getBytes(), out); | |||
| @@ -1,9 +1,10 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.msg; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxMsgModel; | |||
| import com.iformall.service.WxMsgModelService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| @@ -1,7 +1,7 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.msg; | |||
| import com.alibaba.fastjson.JSONArray; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.msg.MailMsg; | |||
| import com.iformall.domain.po.msg.SmartAppMsg; | |||
| import com.iformall.domain.po.msg.WxMsg; | |||
| @@ -11,7 +11,6 @@ import com.iformall.mapper.WxMsgMapper; | |||
| import com.iformall.mq.MqBaseProducer; | |||
| import com.iformall.service.WxMsgRecordService; | |||
| import com.iformall.service.msg.impl.SendCallBackSmsServiceImpl; | |||
| import com.iformall.utils.DateUtils; | |||
| import com.iformall.utils.JsonUtil; | |||
| import io.swagger.annotations.Api; | |||
| import org.slf4j.Logger; | |||
| @@ -1,9 +1,10 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.msg; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxMsgSignature; | |||
| import com.iformall.service.WxMsgSignatureService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| @@ -1,9 +1,10 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.msg; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxMsgValidationcode; | |||
| import com.iformall.service.WxMsgValidationcodeService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| @@ -1,9 +1,10 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.msg; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxMsgValidationcodeModel; | |||
| import com.iformall.service.WxMsgValidationcodeModelService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| @@ -1,8 +1,9 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.rent; | |||
| 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.WxBillAction; | |||
| import com.iformall.service.WxBillActionService; | |||
| import io.swagger.annotations.Api; | |||
| @@ -1,13 +1,14 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.rent; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxShop; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.vo.WxBillAll; | |||
| import com.iformall.service.WxBillAllService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| @@ -18,7 +19,6 @@ import org.springframework.web.bind.annotation.RestController; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| /** | |||
| @@ -90,13 +90,16 @@ public class WxBillAllController extends BaseController { | |||
| if (null == wxBillAll) { | |||
| wxBillAll = new WxBillAll(); | |||
| } | |||
| //默认查当月第一天到今天 | |||
| if(StringUtils.isNotBlank(wxBillAll.getEndtime())){ | |||
| wxBillAll.setEndtime(wxBillAll.getEndtime()+" 23:59:59"); | |||
| } | |||
| wxBillAll.setTenantId(getTenantId()); | |||
| Map<String, Object> result = wxBillAllService.getOweBillAsPage(wxBillAll, pageNum, pageSize); | |||
| return new ResultData(result); | |||
| } | |||
| @ApiOperation("导出欠缴商户列表") | |||
| @GetMapping("/exportOweMerchantlist") | |||
| @SystemControllerLog(description = "费用收缴数据-欠缴商户列表-导出") | |||
| @@ -105,7 +108,44 @@ public class WxBillAllController extends BaseController { | |||
| if (null == wxBillAll){ | |||
| wxBillAll = new WxBillAll(); | |||
| } | |||
| //默认查当月第一天到今天 | |||
| if(StringUtils.isNotBlank(wxBillAll.getEndtime())){ | |||
| wxBillAll.setEndtime(wxBillAll.getEndtime()+" 23:59:59"); | |||
| } | |||
| wxBillAll.setTenantId(getTenantId()); | |||
| wxBillAllService.exportOweMerchant(wxBillAll, request, response); | |||
| } | |||
| @ApiOperation("导出待缴商户列表") | |||
| @GetMapping("/exportWaitMerchantlist") | |||
| @SystemControllerLog(description = "费用收缴数据-待缴商户列表-导出") | |||
| public void exportWaitMerchantlist(@ModelAttribute WxBillAll wxBillAll, HttpServletRequest request, HttpServletResponse response) { | |||
| logger.debug("[" + getIpAddr() + "] WxBillAllController::exportWaitMerchantlist"); | |||
| if (null == wxBillAll){ | |||
| wxBillAll = new WxBillAll(); | |||
| } | |||
| //默认查当月第一天到今天 | |||
| if(StringUtils.isNotBlank(wxBillAll.getEndtime())){ | |||
| wxBillAll.setEndtime(wxBillAll.getEndtime()+" 23:59:59"); | |||
| } | |||
| wxBillAll.setTenantId(getTenantId()); | |||
| wxBillAllService.exportWaitMerchant(wxBillAll, request, response); | |||
| } | |||
| @GetMapping("exportOweBill") | |||
| @SystemControllerLog(description = "生成催缴单") | |||
| public void exportOweBill(@ModelAttribute WxBillAll wxBillAll, HttpServletRequest request, HttpServletResponse response) { | |||
| logger.debug("[" + getIpAddr() + "] WxBillAllController::exportOweBill"); | |||
| if (null == wxBillAll) { | |||
| wxBillAll = new WxBillAll(); | |||
| } | |||
| //默认查当月第一天到今天 | |||
| if (StringUtils.isNotBlank(wxBillAll.getEndtime())) { | |||
| wxBillAll.setEndtime(wxBillAll.getEndtime() + " 23:59:59"); | |||
| } | |||
| wxBillAll.setTenantId(getTenantId()); | |||
| wxBillAllService.exportOweBill(wxBillAll, request, response); | |||
| } | |||
| } | |||
| @@ -0,0 +1,243 @@ | |||
| package com.iformall.controller.rent; | |||
| import com.alibaba.fastjson.JSONArray; | |||
| 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.controller.mem.BillDailyAsyncTask; | |||
| import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.domain.po.WxBillDaily; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.WxBillDailyService; | |||
| import com.iformall.utils.Constant; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.data.redis.core.StringRedisTemplate; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import org.springframework.web.multipart.MultipartFile; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.io.BufferedInputStream; | |||
| import java.io.File; | |||
| import java.io.FileOutputStream; | |||
| import java.io.IOException; | |||
| import java.util.Map; | |||
| import java.util.concurrent.TimeUnit; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| @RestController | |||
| @RequestMapping("wxBillDaily") | |||
| public class WxBillDailyController extends BaseController { | |||
| @Autowired | |||
| private String fmUploadDir; | |||
| @Autowired | |||
| private WxBillDailyService wxBillDailyService; | |||
| @Autowired | |||
| StringRedisTemplate stringRedisTemplate; | |||
| @Autowired | |||
| private BillDailyAsyncTask billDailyAsyncTask; | |||
| private Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @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 WxBillDaily wxBillDaily, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxBillDailyController::list"); | |||
| if (null == wxBillDaily) { | |||
| wxBillDaily = new WxBillDaily(); | |||
| } | |||
| wxBillDaily.setTenantId(getTenantId()); | |||
| final PageInfo<Map<String, Object>> page = wxBillDailyService.listAsPage(wxBillDaily, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @PostMapping("add") | |||
| @SystemControllerLog(description = "日常账单-新增") | |||
| public ResultData add(@RequestBody WxBillDaily wxBillDaily) { | |||
| logger.debug("[" + getIpAddr() + "] WxBillDailyController::add"); | |||
| MallUserInfo user = getUser(); | |||
| wxBillDaily.setTenantId(user.getTenantId()); | |||
| wxBillDaily.setUserId(user.getId()); | |||
| return wxBillDailyService.saveOrUpdate(wxBillDaily, user); | |||
| } | |||
| @PostMapping("update") | |||
| @SystemControllerLog(description = "日常账单-更新") | |||
| public ResultData update(@RequestBody WxBillDaily wxBillDaily) { | |||
| logger.debug("[" + getIpAddr() + "] WxBillDailyController::update"); | |||
| MallUserInfo user = getUser(); | |||
| wxBillDaily.setUserId(user.getId()); | |||
| return wxBillDailyService.saveOrUpdate(wxBillDaily, user); | |||
| } | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "日常账单-删除") | |||
| public ResultData delete(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxBillDailyController::delete"); | |||
| wxBillDailyService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| @GetMapping("/findById") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "日常账单-id查找") | |||
| public ResultData findById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxBillDailyController::findById"); | |||
| return new ResultData(Result.SUCCESS, "查询成功", wxBillDailyService.getById(id)); | |||
| } | |||
| @GetMapping("/updatePaid") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| @SystemControllerLog(description = "日常账单-支付更新") | |||
| public ResultData updatePaid(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] WxBillDailyController::updatePaid"); | |||
| return wxBillDailyService.updatePaid(id); | |||
| } | |||
| @RequestMapping("/exportTemplate") | |||
| @SystemControllerLog(description = "日常账单-导出模板") | |||
| public void exportTemplate(HttpServletRequest request, HttpServletResponse response) { | |||
| logger.debug("[" + getIpAddr() + "] wxBillDailyService::exportTemplate"); | |||
| wxBillDailyService.exportTemplate(request, response, getTenantId()); | |||
| } | |||
| @PostMapping(value = "/importTemplate", consumes = "multipart/*") | |||
| @SystemControllerLog(description = "会员管理-导入数据") | |||
| public ResultData importTemplate(@RequestParam("file") MultipartFile mFile) { | |||
| logger.debug("[" + getIpAddr() + "] wxBillDailyService::importTemplate"); | |||
| if (mFile.isEmpty()) { | |||
| throw new MallinkException(Result.ERROR, "上传文件不能为空"); | |||
| } | |||
| //得到当前用户ID | |||
| final MallUserInfo user = getUser(); | |||
| String userId = "bill_daily_" + user.getId(); | |||
| String importKey = Constant.importMemPrev + userId; | |||
| final String tenantId = getTenantId(); | |||
| //查询当前用户得到的值是否为空,为空继续,不为空,返回模板正在导入 | |||
| Boolean allCount = stringRedisTemplate.opsForHash().hasKey(importKey, "allCount"); | |||
| if (allCount) { | |||
| return new ResultData(Result.SUCCESS, "模板正在导入"); | |||
| } | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", 0 + ""); | |||
| stringRedisTemplate.expire(importKey, 30, TimeUnit.MINUTES); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allSuccessCount", 0 + ""); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "processCount", ""); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", ""); | |||
| String fpath = fmUploadDir; | |||
| File targetFile = new File(fpath); | |||
| if (!targetFile.exists()) { | |||
| targetFile.mkdirs(); | |||
| } | |||
| String fileName = "bill_daily.xlsx"; | |||
| int dot = mFile.getOriginalFilename().lastIndexOf('.'); | |||
| fileName = fileName + mFile.getOriginalFilename().substring(dot, mFile.getOriginalFilename().length()); | |||
| File lFile = new File(fpath + File.separator + fileName); | |||
| FileOutputStream fos = null; | |||
| BufferedInputStream fs = null; | |||
| try { | |||
| fos = new FileOutputStream(lFile); | |||
| fs = (BufferedInputStream) mFile.getInputStream(); | |||
| byte[] buffer = new byte[1024]; | |||
| int len = 0; | |||
| while ((len = fs.read(buffer)) != -1) { | |||
| fos.write(buffer, 0, len); | |||
| } | |||
| fos.close(); | |||
| fs.close(); | |||
| } catch (Exception e) { | |||
| stringRedisTemplate.expire(importKey, 3, TimeUnit.SECONDS); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", "1"); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", "1"); | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败"); | |||
| } finally { | |||
| if (fos != null) { | |||
| try { | |||
| fos.close(); | |||
| } catch (IOException e) { | |||
| stringRedisTemplate.expire(importKey, 3, TimeUnit.SECONDS); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", "1"); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", "1"); | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败"); | |||
| } | |||
| } | |||
| if (fs != null) { | |||
| try { | |||
| fs.close(); | |||
| } catch (IOException e) { | |||
| stringRedisTemplate.expire(importKey, 3, TimeUnit.SECONDS); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "allCount", "1"); | |||
| stringRedisTemplate.opsForHash().putIfAbsent(importKey, "failCount", "1"); | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.MEM_IMPORT_ERR.getCode(), "模板上传失败"); | |||
| } | |||
| } | |||
| } | |||
| billDailyAsyncTask.importExcelData(lFile, user, importKey, tenantId); | |||
| return new ResultData(Result.SUCCESS, "模板正在导入"); | |||
| } | |||
| @GetMapping("/queryTemplateCount") | |||
| @SystemControllerLog(description = "日常费用账单-导入数据查询") | |||
| public ResultData queryTemplateCount() { | |||
| String importKey = Constant.importMemPrev + "bill_daily_" + getUser().getId(); | |||
| Map entries = stringRedisTemplate.opsForHash().entries(importKey); | |||
| logger.info(JSONArray.toJSONString(entries) + ">>>>>>>>>>>>>>>>>>>>>1"); | |||
| if (entries.size() < 4) { | |||
| entries.clear(); | |||
| return new ResultData(Result.SUCCESS, "ok", entries); | |||
| } | |||
| String allCount = entries.get("allCount").toString(); | |||
| String allSuccessCount = entries.get("allSuccessCount").toString(); | |||
| String processCount = entries.get("processCount").toString(); | |||
| String failCount = entries.get("failCount").toString(); | |||
| if (StringUtils.isNotBlank(failCount) && allCount.equals(failCount)) {//stringRedisTemplate.expire(userId,1,TimeUnit.SECONDS); | |||
| logger.info(JSONArray.toJSONString(entries) + ">>>>>>>>>>>>>>>>>>>>>2"); | |||
| //完全失败 | |||
| stringRedisTemplate.opsForHash().delete(importKey, "allCount"); | |||
| stringRedisTemplate.opsForHash().delete(importKey, "allSuccessCount"); | |||
| stringRedisTemplate.opsForHash().delete(importKey, "processCount"); | |||
| stringRedisTemplate.opsForHash().delete(importKey, "failCount"); | |||
| return new ResultData(ErrorCode.MEM_IMPORT_ERR); | |||
| } | |||
| //导入完成 | |||
| if (StringUtils.isNotBlank(allSuccessCount) && allSuccessCount.equals(processCount)) { | |||
| ResultData ok = new ResultData(Result.SUCCESS, "ok", entries); | |||
| stringRedisTemplate.opsForHash().delete(importKey, "allCount"); | |||
| stringRedisTemplate.opsForHash().delete(importKey, "allSuccessCount"); | |||
| stringRedisTemplate.opsForHash().delete(importKey, "processCount"); | |||
| stringRedisTemplate.opsForHash().delete(importKey, "failCount"); | |||
| return ok; | |||
| } | |||
| return new ResultData(Result.SUCCESS, "查询成功", entries); | |||
| } | |||
| } | |||
| @@ -1,9 +1,10 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.rent; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxBillDeposit; | |||
| import com.iformall.service.WxBillDepositService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| @@ -1,9 +1,11 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.rent; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| 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.WxBillOther; | |||
| import com.iformall.service.WxBillOtherService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| @@ -45,17 +47,19 @@ public class WxBillOtherController extends BaseController { | |||
| @SystemControllerLog(description = "其它账单-新增") | |||
| public ResultData add(@RequestBody WxBillOther wxBillOther) { | |||
| logger.debug("[" + getIpAddr() + "] WxBillOtherController::add"); | |||
| wxBillOther.setTenantId(getTenantId()); | |||
| wxBillOther.setUserId(getUser().getId()); | |||
| return wxBillOtherService.saveOrUpdate(wxBillOther, getUser()); | |||
| MallUserInfo user = getUser(); | |||
| wxBillOther.setTenantId(user.getTenantId()); | |||
| wxBillOther.setUserId(user.getId()); | |||
| return wxBillOtherService.saveOrUpdate(wxBillOther, user); | |||
| } | |||
| @PostMapping("update") | |||
| @SystemControllerLog(description = "其它账单-更新") | |||
| public ResultData update(@RequestBody WxBillOther wxBillOther) { | |||
| logger.debug("[" + getIpAddr() + "] WxBillOtherController::update"); | |||
| wxBillOther.setUserId(getUser().getId()); | |||
| return wxBillOtherService.saveOrUpdate(wxBillOther, getUser()); | |||
| MallUserInfo user = getUser(); | |||
| wxBillOther.setUserId(user.getId()); | |||
| return wxBillOtherService.saveOrUpdate(wxBillOther, user); | |||
| } | |||
| @GetMapping("/del") | |||
| @@ -1,9 +1,11 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.rent; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| 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.WxBillOtherDeposit; | |||
| import com.iformall.service.WxBillOtherDepositService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| @@ -45,17 +47,19 @@ public class WxBillOtherDepositController extends BaseController { | |||
| @SystemControllerLog(description = "其它账单-新增") | |||
| public ResultData add(@RequestBody WxBillOtherDeposit wxBillOtherDeposit) { | |||
| logger.debug("[" + getIpAddr() + "] WxBillOtherDepositController::add"); | |||
| wxBillOtherDeposit.setTenantId(getTenantId()); | |||
| wxBillOtherDeposit.setUserId(getUser().getId()); | |||
| return wxBillOtherDepositService.saveOrUpdate(wxBillOtherDeposit, getUser()); | |||
| MallUserInfo user = getUser(); | |||
| wxBillOtherDeposit.setTenantId(user.getTenantId()); | |||
| wxBillOtherDeposit.setUserId(user.getId()); | |||
| return wxBillOtherDepositService.saveOrUpdate(wxBillOtherDeposit, user); | |||
| } | |||
| @PostMapping("update") | |||
| @SystemControllerLog(description = "其它账单-更新") | |||
| public ResultData update(@RequestBody WxBillOtherDeposit wxBillOtherDeposit) { | |||
| logger.debug("[" + getIpAddr() + "] WxBillOtherDepositController::update"); | |||
| wxBillOtherDeposit.setUserId(getUser().getId()); | |||
| return wxBillOtherDepositService.saveOrUpdate(wxBillOtherDeposit, getUser()); | |||
| MallUserInfo user = getUser(); | |||
| wxBillOtherDeposit.setUserId(user.getId()); | |||
| return wxBillOtherDepositService.saveOrUpdate(wxBillOtherDeposit, user); | |||
| } | |||
| @GetMapping("/del") | |||
| @@ -1,9 +1,10 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.rent; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxBillProperty; | |||
| import com.iformall.service.WxBillPropertyService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| @@ -1,9 +1,10 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.rent; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxBillPropertyDeposit; | |||
| import com.iformall.service.WxBillPropertyDepositService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| @@ -1,9 +1,10 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.rent; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxBillRent; | |||
| import com.iformall.service.WxBillRentService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| @@ -102,7 +103,6 @@ public class WxBillRentController extends BaseController { | |||
| return new ResultData(Result.SUCCESS, "查询成功", wxBillRentService.detail(id)); | |||
| } | |||
| @PostMapping("updateRevenue") | |||
| @SystemControllerLog(description = "租赁押金账单-更新营业额") | |||
| public ResultData updateRevenue(@RequestBody WxBillRent wxBillRent) { | |||
| @@ -0,0 +1,395 @@ | |||
| package com.iformall.controller.sys; | |||
| import com.google.code.kaptcha.Constants; | |||
| import com.google.code.kaptcha.Producer; | |||
| 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.*; | |||
| import com.iformall.domain.vo.MallUserInfoVo; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.mapper.WxMerchantMapper; | |||
| import com.iformall.service.*; | |||
| import com.iformall.shiro.UserSession; | |||
| import com.iformall.shiro.UseriFormallToken; | |||
| import com.iformall.utils.ShiroUtils; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.apache.commons.io.IOUtils; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.apache.shiro.SecurityUtils; | |||
| import org.apache.shiro.authc.DisabledAccountException; | |||
| import org.apache.shiro.authc.UnknownAccountException; | |||
| import org.apache.shiro.authc.UsernamePasswordToken; | |||
| import org.apache.shiro.subject.Subject; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.beans.factory.annotation.Value; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import javax.imageio.ImageIO; | |||
| import javax.servlet.ServletException; | |||
| import javax.servlet.ServletOutputStream; | |||
| import javax.servlet.http.Cookie; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.awt.image.BufferedImage; | |||
| import java.io.IOException; | |||
| import java.net.URLEncoder; | |||
| import java.util.Date; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| @RestController | |||
| @Api(description = "登录相关接口") | |||
| public class HomeController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Value("${version}") | |||
| private String version; | |||
| @Autowired | |||
| private Producer producer; | |||
| @Autowired | |||
| private MallUserInfoService mallUserInfoService; | |||
| @Autowired | |||
| private MallUserRoleService mallUserRoleService; | |||
| @Autowired | |||
| private WxAppinfoService appinfoService; | |||
| @Autowired | |||
| private WxMsgValidationcodeService wxMsgValidationcodeService; | |||
| @Autowired | |||
| private MallUserActionService mallUserActionService; | |||
| @Autowired | |||
| private WxMallService mallService; | |||
| @ApiOperation("验证码") | |||
| @GetMapping("/captcha.jpg") | |||
| public void captcha(HttpServletResponse response)throws ServletException, IOException { | |||
| logger.debug("[" + getIpAddr() + "] HomeController::captcha"); | |||
| response.setHeader("Cache-Control", "no-store, no-cache"); | |||
| response.setContentType("image/jpeg"); | |||
| //生成文字验证码 | |||
| String text = producer.createText(); | |||
| //生成图片验证码 | |||
| BufferedImage image = producer.createImage(text); | |||
| //保存到shiro session | |||
| ShiroUtils.setSessionAttribute(Constants.KAPTCHA_SESSION_KEY, text); | |||
| ServletOutputStream out = response.getOutputStream(); | |||
| ImageIO.write(image, "jpg", out); | |||
| IOUtils.closeQuietly(out); | |||
| } | |||
| @ApiOperation("登录") | |||
| @PostMapping("/doLogin") | |||
| public ResultData login(@RequestBody MallUserInfo user, HttpServletResponse response) { | |||
| String ipaddress = getIpAddr(); | |||
| logger.debug("[" + ipaddress + "] HomeController::doLogin"); | |||
| try { | |||
| String kaptcha = ShiroUtils.getKaptcha(Constants.KAPTCHA_SESSION_KEY); | |||
| if(!user.getCaptcha().equalsIgnoreCase(kaptcha)){ | |||
| return new ResultData(ErrorCode.KAPCHA_NOT_EQUAL); | |||
| } | |||
| } catch (MallinkException e) { | |||
| logger.error("验证码" + e.getMessage()); | |||
| return new ResultData(ErrorCode.KAPCHA_NOT_VALID.getCode(), e.getMessage()); | |||
| } | |||
| ResultData data = new ResultData(); | |||
| if (StringUtils.isBlank(user.getUsername()) || StringUtils.isBlank(user.getPassword())) { | |||
| // throw new SystemException(ErrorCode.LOGIN_USER_OR_PWD_ERROR); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| // check user | |||
| MallUserInfo userCheck = mallUserInfoService.getByUsername(user.getUsername()); | |||
| if(userCheck == null) { | |||
| logger.error(ErrorCode.USER_IS_EMPTY.getMessage()); | |||
| return new ResultData(ErrorCode.USER_IS_EMPTY); | |||
| } | |||
| if(userCheck.getStatus().equals(EnumMallUserStatus.NOT_VALID.getCode())) { | |||
| logger.error(ErrorCode.USER_IS_LOCKED.getMessage()); | |||
| return new ResultData(ErrorCode.USER_IS_LOCKED); | |||
| } | |||
| boolean isLogin = false; | |||
| try { | |||
| Subject subject = SecurityUtils.getSubject(); | |||
| UsernamePasswordToken token = new UsernamePasswordToken(user.getUsername(), user.getPassword()); | |||
| subject.login(token); | |||
| isLogin = true; | |||
| } catch (UnknownAccountException e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.USER_IS_EMPTY); | |||
| } catch (DisabledAccountException e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.USER_IS_LOCKED); | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.USER_PASSWD_ERR); | |||
| } | |||
| if(isLogin) { | |||
| MallUserInfo info = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute(UserSession.userInfo); | |||
| info.protectInfos(); | |||
| mallUserActionService.saveActionInfo(info.getTenantId(), EnumMallUserAction.CONTROLLER.getCode(), ipaddress, info.getId(), "用户登录"); | |||
| WxMall mall = mallService.getByTenantId(info.getTenantId()); | |||
| if(mall == null) { | |||
| logger.error("未配置相应的mall"); | |||
| return new ResultData(Result.ERROR, "未配置相应的mall"); | |||
| } | |||
| if(!mall.isValid()) { | |||
| logger.error("mall未启用"); | |||
| return new ResultData(Result.ERROR, "mall未启用"); | |||
| } | |||
| try { | |||
| String cookieName = URLEncoder.encode(info.getUsername(), "utf-8"); | |||
| Cookie unameCookie = new Cookie("uname", cookieName); | |||
| unameCookie.setPath("/"); | |||
| unameCookie.setMaxAge(3600); | |||
| response.addCookie(unameCookie); | |||
| Map map = new HashMap(); | |||
| map.put("username", info.getUsername()); | |||
| map.put("withWechat", info.getWithWechat()); | |||
| data.data = map; | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(Result.ERROR, e.getMessage()); | |||
| } | |||
| } | |||
| return data; | |||
| } | |||
| private boolean isInMobileAdmin(MallUserInfo user) { | |||
| // 检查用户是否有 移动端数据塔台 权限 | |||
| boolean isInMobile = false; | |||
| isInMobile = mallUserRoleService.checkIsMobileAdmin(user); | |||
| return isInMobile; | |||
| } | |||
| @ApiOperation("B端登录") | |||
| @PostMapping("/bHidLogin") | |||
| public ResultData bLogin(@RequestBody MallUserInfo user, HttpServletResponse response) { | |||
| String ipaddress = getIpAddr(); | |||
| logger.debug("[" + ipaddress + "] HomeController::bHidLogin"); | |||
| ResultData data = new ResultData(); | |||
| // tenantId is appId | |||
| if (StringUtils.isBlank(user.getTenantId())) { | |||
| logger.error("appid信息未提供"); | |||
| return new ResultData(ErrorCode.MALL_INFO_NOT_FOUND); | |||
| } | |||
| WxAppinfo appinfo = appinfoService.getByAppId(user.getTenantId()); | |||
| if (appinfo == null) { | |||
| logger.error("appid未找到"); | |||
| return new ResultData(ErrorCode.MALL_INFO_NOT_FOUND); | |||
| } | |||
| if (StringUtils.isNotBlank(user.getPhone())) { | |||
| // 领导登录 | |||
| user = mallUserInfoService.getByPhone(user.getPhone(), appinfo.getTenantId()); | |||
| if (user == null || !isInMobileAdmin(user)) { | |||
| return new ResultData(ErrorCode.USER_NO_PERMISSION); | |||
| } | |||
| } else if (StringUtils.isNotBlank(user.getBopenId())) { | |||
| // 领导登录 | |||
| user = mallUserInfoService.getByBOpenId(user.getBopenId(), appinfo.getTenantId()); | |||
| if (user == null || !isInMobileAdmin(user)) { | |||
| return new ResultData(ErrorCode.USER_NO_PERMISSION); | |||
| } | |||
| } else { | |||
| if (StringUtils.isEmpty(user.getUsername()) || StringUtils.isEmpty(user.getPassword())) { | |||
| // throw new SystemException(ErrorCode.LOGIN_USER_OR_PWD_ERROR); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| } | |||
| boolean isLogin = false; | |||
| try { | |||
| Subject subject = SecurityUtils.getSubject(); | |||
| UseriFormallToken token = new UseriFormallToken(user.getUsername()); | |||
| subject.login(token); | |||
| isLogin = true; | |||
| } catch (UnknownAccountException e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.USER_IS_EMPTY); | |||
| } catch (DisabledAccountException e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.USER_IS_LOCKED); | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.USER_PASSWD_ERR); | |||
| } | |||
| if (isLogin) { | |||
| MallUserInfo info = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute(UserSession.userInfo); | |||
| info.protectInfos(); | |||
| mallUserActionService.saveActionInfo(info.getTenantId(), EnumMallUserAction.CONTROLLER.getCode(), ipaddress, info.getId(), "用户登录"); | |||
| WxMall mall = mallService.getByTenantId(info.getTenantId()); | |||
| if (mall == null) { | |||
| logger.error("未配置相应的mall"); | |||
| return new ResultData(Result.ERROR, "未配置相应的mall"); | |||
| } | |||
| if (!mall.isValid()) { | |||
| logger.error("mall未启用"); | |||
| return new ResultData(Result.ERROR, "mall未启用"); | |||
| } | |||
| try { | |||
| String cookieName = URLEncoder.encode(info.getUsername(), "utf-8"); | |||
| Cookie unameCookie = new Cookie("uname", cookieName); | |||
| unameCookie.setPath("/"); | |||
| unameCookie.setMaxAge(3600); | |||
| response.addCookie(unameCookie); | |||
| Map map = new HashMap(); | |||
| map.put("username", info.getUsername()); | |||
| map.put("withWechat", info.getWithWechat()); | |||
| data.data = map; | |||
| } catch(Exception e){ | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.USER_PASSWD_ERR); | |||
| } | |||
| } | |||
| return data; | |||
| } | |||
| @ApiOperation("发送手机验证码") | |||
| @GetMapping("sendLoginPhoneCode") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "phone", value = "手机号", dataType = "String", paramType = "query", required = true)}) | |||
| public ResultData sendLoginPhoneCode(String phone) { | |||
| logger.debug("[" + getIpAddr() + "] HomeController::sendlogincode"); | |||
| // 1. 检查手机号是否在用户列表里, 是否只有一个 | |||
| // 2. 发送手机验证码, 直接发 | |||
| List<MallUserInfoVo> users = mallUserInfoService.getUserByPhone(phone); | |||
| if(users.size() <= 0) { | |||
| logger.error(ErrorCode.USER_IS_EMPTY.getMessage()); | |||
| return new ResultData(ErrorCode.USER_IS_EMPTY); | |||
| } | |||
| if(users.size() > 1) { | |||
| logger.error(ErrorCode.USER_IS_MULTI.getMessage()); | |||
| return new ResultData(ErrorCode.USER_IS_MULTI); | |||
| } | |||
| MallUserInfoVo user = users.get(0); | |||
| if (user==null) { | |||
| logger.error("用户不存在, userName: " + user.getUsername()); | |||
| return new ResultData(ErrorCode.USER_IS_EMPTY); | |||
| } | |||
| if(user.getStatus() == EnumMallUserStatus.NOT_VALID.getCode()){ | |||
| logger.error("用户已停用, userName: " + user.getUsername()); | |||
| return new ResultData(ErrorCode.USER_IS_LOCKED); | |||
| } | |||
| WxMsgValidationcode wxMsgValidationcode = new WxMsgValidationcode(); | |||
| wxMsgValidationcode.setPhone(phone); | |||
| wxMsgValidationcode.setTenantId(user.getTenantId()); | |||
| wxMsgValidationcode.setType(EnumMsgModel.VALIDATION_CODE.getCode()); | |||
| return wxMsgValidationcodeService.sendvalidationcode(wxMsgValidationcode); | |||
| } | |||
| @ApiOperation(value = "手机验证码登录", notes = "{\"phone\",\"string\",\"code\",\"string\"}") | |||
| @PostMapping("/doLoginByPhone") | |||
| public ResultData doLoginByPhone(@RequestBody Map<String, String> params, HttpServletResponse response) { | |||
| String ipaddress = getIpAddr(); | |||
| logger.debug("[" + ipaddress + "] HomeController::doLoginByPhone"); | |||
| // String phone,String code,String pwd | |||
| String phone = params.get("phone"); | |||
| String code = params.get("code"); | |||
| if (StringUtils.isBlank(phone)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "userName不能为空"); | |||
| } | |||
| if (StringUtils.isBlank(code)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "验证码不能为空"); | |||
| } | |||
| // 获取用户信息列表 | |||
| List<MallUserInfoVo> userList = mallUserInfoService.getUserByPhone(phone); | |||
| if(userList.size() == 1) { | |||
| MallUserInfoVo user = userList.get(0); | |||
| // check 验证码正确 | |||
| boolean isValidCode = false; | |||
| try { | |||
| isValidCode = mallUserInfoService.checkCodeValid(user, code); | |||
| } catch (Exception e) { | |||
| return new ResultData(Result.ERROR, e.getMessage()); | |||
| } | |||
| if(isValidCode) { | |||
| // 验证码正确,直接登录 | |||
| try { | |||
| Subject subject = SecurityUtils.getSubject(); | |||
| UseriFormallToken token = new UseriFormallToken(user.getUsername()); | |||
| subject.login(token); | |||
| MallUserInfo info = (MallUserInfo) SecurityUtils.getSubject().getSession().getAttribute(UserSession.userInfo); | |||
| info.protectInfos(); | |||
| mallUserActionService.saveActionInfo(info.getTenantId(), EnumMallUserAction.CONTROLLER.getCode(), ipaddress, info.getId(), "用户手机号登录"); | |||
| WxMall mall = mallService.getByTenantId(info.getTenantId()); | |||
| if (mall == null) { | |||
| logger.error("未配置相应的mall"); | |||
| return new ResultData(Result.ERROR, "未配置相应的mall"); | |||
| } | |||
| if (!mall.isValid()) { | |||
| logger.error("mall未启用"); | |||
| return new ResultData(Result.ERROR, "mall未启用"); | |||
| } | |||
| String cookieName = URLEncoder.encode(info.getUsername(), "utf-8"); | |||
| Cookie unameCookie = new Cookie("uname", cookieName); | |||
| unameCookie.setPath("/"); | |||
| unameCookie.setMaxAge(3600); | |||
| response.addCookie(unameCookie); | |||
| Map map = new HashMap(); | |||
| map.put("username", info.getUsername()); | |||
| map.put("withWechat", info.getWithWechat()); | |||
| return new ResultData(map); | |||
| } catch (MallinkException e) { | |||
| return new ResultData(e.getErrorCode(), e.getMessage()); | |||
| } catch (Exception e) { | |||
| return new ResultData(ErrorCode.USER_PASSWD_ERR); | |||
| } | |||
| } else { | |||
| return new ResultData(ErrorCode.MSG_VERIFY_CODE_NOT_FOUND); | |||
| } | |||
| } else { | |||
| return new ResultData(ErrorCode.USER_IS_EMPTY); | |||
| } | |||
| } | |||
| @ApiOperation("登出") | |||
| @GetMapping("/logout") | |||
| @SystemControllerLog(description = "用户登出") | |||
| public ResultData logout() { | |||
| logger.debug("[" + getIpAddr() + "] HomeController::logout"); | |||
| ResultData data = new ResultData(); | |||
| SecurityUtils.getSubject().logout(); | |||
| return data; | |||
| } | |||
| @ApiOperation("获取后端版本号") | |||
| @GetMapping("/version") | |||
| public ResultData version() { | |||
| logger.debug("[" + getIpAddr() + "] HomeController::version"); | |||
| return new ResultData(version); | |||
| } | |||
| } | |||
| @@ -0,0 +1,161 @@ | |||
| package com.iformall.controller.sys; | |||
| 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.MallRole; | |||
| import com.iformall.domain.po.MallRolePermission; | |||
| import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.domain.po.MallUserRole; | |||
| import com.iformall.enums.EnumUserAdmin; | |||
| import com.iformall.service.MallRolePermissionService; | |||
| import com.iformall.service.MallRoleService; | |||
| import com.iformall.service.MallUserRoleService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.apache.shiro.authz.annotation.RequiresPermissions; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.util.Assert; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| @RestController | |||
| @RequestMapping("role") | |||
| @Api(description = "角色相关接口") | |||
| public class MallRoleController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private MallRoleService sysRoleService; | |||
| @Autowired | |||
| private MallRolePermissionService sysRolePermissionService; | |||
| @Autowired | |||
| private MallUserRoleService mallUserRoleService; | |||
| @ApiOperation("角色列表") | |||
| @GetMapping("list") | |||
| //@RequiresPermissions("sys:role:list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "用户管理-role列表") | |||
| public ResultData list(MallRole sysRole, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] MallRoleController::list"); | |||
| String tenantId = getTenantId(); | |||
| sysRole.setTenantId(tenantId); | |||
| sysRole.setSortColumns(MallRole.Field.Id_DESC); | |||
| final PageInfo<MallRole> page = sysRoleService.listAsPage(sysRole, pageNum, pageSize); | |||
| for (MallRole r : page.getList()) { | |||
| MallRolePermission p = new MallRolePermission(); | |||
| p.setRoleId(r.getId()); | |||
| p.setTenantId(tenantId); | |||
| List<MallRolePermission> pers = sysRolePermissionService.getList(p); | |||
| String menus = ""; | |||
| for (MallRolePermission rp : pers) { | |||
| menus += rp.getPermissionId() + ","; | |||
| } | |||
| if (menus.length() > 1) { | |||
| menus = menus.substring(0, menus.length() - 1); | |||
| } | |||
| r.setMenus(menus); | |||
| } | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("角色详情") | |||
| @GetMapping("findById") | |||
| //@RequiresPermissions("sys:role:get") | |||
| @SystemControllerLog(description = "用户管理-role信息") | |||
| public ResultData findById(MallRole sysRole) { | |||
| logger.debug("[" + getIpAddr() + "] MallRoleController::list"); | |||
| if (sysRole.getId() == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| MallRole role = sysRoleService.getById(sysRole.getId()); | |||
| MallRolePermission p = new MallRolePermission(); | |||
| p.setRoleId(role.getId()); | |||
| p.setTenantId(getTenantId()); | |||
| List<MallRolePermission> pers = sysRolePermissionService.getList(p); | |||
| String menus = ""; | |||
| for (MallRolePermission rp : pers) { | |||
| menus += rp.getPermissionId() + ","; | |||
| } | |||
| if (menus.length() > 1) { | |||
| menus = menus.substring(0, menus.length() - 1); | |||
| } | |||
| role.setMenus(menus); | |||
| return new ResultData(role); | |||
| } | |||
| @ApiOperation("角色保存") | |||
| @PostMapping("saveOrUpdate") | |||
| //@RequiresPermissions("sys:role:save") | |||
| @SystemControllerLog(description = "用户管理-rule保存") | |||
| public ResultData saveOrUpdate(@RequestBody MallRole sysRole) { | |||
| logger.debug("[" + getIpAddr() + "] MallRoleController::saveOrUpdate"); | |||
| MallUserInfo currentUser = getUser(); | |||
| if (currentUser.getIsAdmin().equals(EnumUserAdmin.Normal.getCode())) { | |||
| return new ResultData(ErrorCode.USER_NOT_ADMIN.getCode(), "只有系统管理员才能保存角色"); | |||
| } | |||
| String tenantId = currentUser.getTenantId(); | |||
| int count = checkUnique(sysRole.getName(), tenantId); | |||
| if (sysRole.getId() == null && count > 0) { | |||
| return new ResultData(ResultData.ERROR, "角色名已存在"); | |||
| } | |||
| sysRole.setTenantId(tenantId); | |||
| sysRoleService.saveOrUpdate(sysRole); | |||
| if (StringUtils.isNoneBlank(sysRole.getMenus())) { | |||
| String[] menuIds = sysRole.getMenus().split(","); | |||
| List<Long> mIds = new ArrayList<>(); | |||
| for (String mId : menuIds) { | |||
| mIds.add(Long.valueOf(mId)); | |||
| } | |||
| sysRolePermissionService.savePermissions(tenantId, sysRole.getId(), mIds.toArray(new Long[]{})); | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("角色删除") | |||
| @PostMapping("/del") | |||
| //@RequiresPermissions("sys:role:del") | |||
| @SystemControllerLog(description = "用户管理-rule删除") | |||
| public ResultData delete(@RequestBody MallRole sysRole) { | |||
| logger.debug("[" + getIpAddr() + "] MallRoleController::delete"); | |||
| MallUserInfo currentUser = getUser(); | |||
| if (currentUser.getIsAdmin().equals(EnumUserAdmin.Normal.getCode())) { | |||
| return new ResultData(ErrorCode.USER_NOT_ADMIN.getCode(), "只有系统管理员才能删除角色"); | |||
| } | |||
| MallUserRole record = new MallUserRole(); | |||
| record.setRoleId(sysRole.getId()); | |||
| int count = mallUserRoleService.cntUserList(record); | |||
| if (count > 0) { | |||
| return new ResultData(ErrorCode.USER_USE_ROLE.getCode(), "有用户使用此角色,请先删除相应的用户!!"); | |||
| } | |||
| sysRoleService.deleteById(sysRole.getId()); | |||
| sysRolePermissionService.deleteByRoleId(sysRole.getId()); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| } | |||
| private int checkUnique(String name, String tenantId) { | |||
| MallRole role = new MallRole(); | |||
| role.setName(name); | |||
| role.setTenantId(tenantId); | |||
| return sysRoleService.countList(role); | |||
| } | |||
| } | |||
| @@ -0,0 +1,396 @@ | |||
| package com.iformall.controller.sys; | |||
| 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.*; | |||
| import com.iformall.enums.EnumMallUserStatus; | |||
| import com.iformall.enums.EnumUserAdmin; | |||
| import com.iformall.enums.EnumFlowPermissionType; | |||
| import com.iformall.service.*; | |||
| import com.iformall.shiro.PasswordHelper; | |||
| import com.iformall.shiro.UserSession; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.apache.commons.collections.map.HashedMap; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.apache.shiro.SecurityUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.util.Assert; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| /** | |||
| * @author chenkx | |||
| * @date 2018-01-05. | |||
| */ | |||
| @Api(value = "API - UserInfoController", description = "用户接口") | |||
| @RestController | |||
| @RequestMapping("user") | |||
| public class MallUserInfoController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| MallUserInfoService userInfoService; | |||
| @Autowired | |||
| MallUserRoleService userRoleService; | |||
| @Autowired | |||
| MallRoleService mallRoleService; | |||
| @Autowired | |||
| MallUserRoleService mallUserRoleService; | |||
| @Autowired | |||
| MallPermissionService mallPermissionService; | |||
| @Autowired | |||
| MallRolePermissionService mallRolePermissionService; | |||
| @Autowired | |||
| WxMsgValidationcodeService wxMsgValidationcodeService; | |||
| @ApiOperation(value = "用户分页接口", response = String.class) | |||
| @GetMapping("lists") | |||
| //@RequiresPermissions("sys:user: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 listAsPage(MallUserInfo userInfo, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] MallUserInfoController::listAsPage"); | |||
| if(userInfo.getWithWechatNotFormat() != null){ | |||
| userInfo.setWithWechatForQuery(userInfo.getWithWechatNotFormat()); | |||
| } | |||
| userInfo.setTenantId(getTenantId()); | |||
| userInfo.setSortColumns(MallUserInfo.Field.Id_DESC); | |||
| final PageInfo<MallUserInfo> page = userInfoService.listAsPage(userInfo, pageNum, pageSize); | |||
| for (MallUserInfo u : page.getList()) { | |||
| MallUserRole r = new MallUserRole(); | |||
| r.setUid(u.getId()); | |||
| PageInfo<MallUserRole> ur = userRoleService.listAsPage(r, 1, 1); | |||
| if (ur.getSize() > 0) { | |||
| MallRole role = mallRoleService.getById(ur.getList().get(0).getRoleId()); | |||
| if (role != null) { | |||
| u.setRoleName(role.getName()); | |||
| u.setRoleId(role.getId()); | |||
| } | |||
| } | |||
| // 保密 | |||
| u.setPassword(null); | |||
| u.setBopenId(null); | |||
| if(StringUtils.isNotBlank(u.getWebOpenId())) { | |||
| u.setWebOpenId("保密"); | |||
| } | |||
| } | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation(value = "用户详情接口", response = String.class) | |||
| @GetMapping("detail") | |||
| //@RequiresPermissions("sys:user:info") | |||
| @SystemControllerLog(description = "用户管理-用户详情") | |||
| public ResultData detail(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] MallUserInfoController::detail"); | |||
| final MallUserInfo user = userInfoService.getById(id); | |||
| user.setPassword(null); | |||
| user.setBopenId(null); | |||
| if(StringUtils.isNotBlank(user.getWebOpenId())) { | |||
| user.setWebOpenId("保密"); | |||
| } | |||
| return new ResultData(user); | |||
| } | |||
| @ApiOperation(value = "创建用户接口", response = String.class) | |||
| @PostMapping("add") | |||
| //@RequiresPermissions("sys:user:add") | |||
| @SystemControllerLog(description = "用户管理-创建用户") | |||
| public ResultData createUser(@RequestBody MallUserInfo userInfo) { | |||
| logger.debug("[" + getIpAddr() + "] MallUserInfoController::createUser"); | |||
| MallUserInfo currentUser = getUser(); | |||
| if(currentUser.getIsAdmin().equals(EnumUserAdmin.Normal.getCode())) { | |||
| return new ResultData(ErrorCode.USER_NOT_ADMIN.getCode(), "只有系统管理员才能添加用户"); | |||
| } | |||
| if(checkUniqueName(userInfo.getUsername()) > 0){ | |||
| return new ResultData(ErrorCode.USER_NAME_IS_FOUND.getCode(),"用户名已存在"); | |||
| } | |||
| if(checkUniquePhone(userInfo.getPhone()) > 0){ | |||
| return new ResultData(ErrorCode.USER_PHONE_IS_FOUND.getCode(),"手机号已存在"); | |||
| } | |||
| Assert.notNull(userInfo.getPassword(), "密码不能为空"); | |||
| PasswordHelper passwordHelper = new PasswordHelper(); | |||
| passwordHelper.encryptPassword(userInfo); | |||
| userInfo.setTenantId(getTenantId()); | |||
| // 无法创建超管 | |||
| userInfo.setIsAdmin(EnumUserAdmin.Normal.getCode()); | |||
| userInfoService.saveOrUpdate(userInfo); | |||
| if (userInfo.getRoleId() != null) { | |||
| MallUserRole r = new MallUserRole(); | |||
| r.setRoleId(userInfo.getRoleId()); | |||
| r.setUid(userInfo.getId()); | |||
| userRoleService.saveOrUpdate(r); | |||
| } | |||
| return new ResultData(userInfo); | |||
| } | |||
| @ApiOperation(value = "修改用户接口", response = String.class) | |||
| @PostMapping("update") | |||
| //@RequiresPermissions("sys:user:update") | |||
| @SystemControllerLog(description = "用户管理-修改用户") | |||
| public ResultData updateUser(@RequestBody MallUserInfo userInfo) { | |||
| logger.debug("[" + getIpAddr() + "] MallUserInfoController::updateUser"); | |||
| boolean bChangedPhone = false; | |||
| MallUserInfo currentUser = getUser(); | |||
| // 只有超管和自己能更新信息 | |||
| if (!(currentUser.getId().equals(userInfo.getId()) || | |||
| currentUser.getIsAdmin().equals(EnumUserAdmin.ADMIN.getCode()))) { | |||
| return new ResultData(ErrorCode.USER_NO_PERMISSION.getCode(), "系统管理员和自己才能修改信息"); | |||
| } | |||
| MallUserInfo oldUser = userInfoService.getById(userInfo.getId()); | |||
| if (!oldUser.getUsername().equals(userInfo.getUsername())) { | |||
| if(checkUniqueName(userInfo.getUsername()) > 0){ | |||
| return new ResultData(ErrorCode.USER_NAME_IS_FOUND.getCode(),"用户名已存在"); | |||
| } | |||
| } | |||
| if (!oldUser.getPhone().equals(userInfo.getPhone())) { | |||
| if(checkUniquePhone(userInfo.getPhone()) > 0){ | |||
| return new ResultData(ErrorCode.USER_PHONE_IS_FOUND.getCode(),"手机号已存在"); | |||
| } | |||
| bChangedPhone = true; | |||
| } | |||
| userInfo.setTenantId(getTenantId()); | |||
| if (StringUtils.isNotBlank(userInfo.getPassword()) && userInfo.getPassword().length() > 0) { | |||
| PasswordHelper passwordHelper = new PasswordHelper(); | |||
| passwordHelper.encryptPassword(userInfo); | |||
| } | |||
| // 系统内人员不能设置系统管理员 | |||
| userInfo.setIsAdmin(null); | |||
| /* | |||
| if (!currentUser.getIsAdmin().equals(EnumUserAdmin.ADMIN.getCode())) { | |||
| // 只有系统管理员才能设置系统管理员 | |||
| userInfo.setIsAdmin(null); | |||
| } | |||
| */ | |||
| if (currentUser.getIsAdmin().equals(EnumUserAdmin.ADMIN.getCode()) && | |||
| currentUser.getId().equals(userInfo.getId())) { | |||
| // 超管 | |||
| MallUserInfo adminUser = new MallUserInfo(); | |||
| adminUser.setFlowPermission(userInfo.getFlowPermission()); | |||
| adminUser.setEmail(userInfo.getEmail()); | |||
| adminUser.setId(userInfo.getId()); | |||
| if (StringUtils.isNotBlank(userInfo.getPassword()) && userInfo.getPassword().length() > 0) { | |||
| adminUser.setPassword(userInfo.getPassword()); | |||
| } | |||
| if (StringUtils.isNotBlank(userInfo.getNickName())) { | |||
| adminUser.setNickName(userInfo.getNickName()); | |||
| } | |||
| if (StringUtils.isNotBlank(userInfo.getPhone())) { | |||
| adminUser.setPhone(userInfo.getPhone()); | |||
| } | |||
| userInfoService.saveOrUpdate(adminUser); | |||
| } else { | |||
| userInfoService.saveOrUpdate(userInfo); | |||
| if (userInfo.getRoleId() != null) { | |||
| userRoleService.deleteByUserId(userInfo.getId()); | |||
| MallUserRole r = new MallUserRole(); | |||
| r.setRoleId(userInfo.getRoleId()); | |||
| r.setUid(userInfo.getId()); | |||
| userRoleService.saveOrUpdate(r); | |||
| } | |||
| } | |||
| if(bChangedPhone) { | |||
| // 手机号修改,清除bopen_id, 清除web_open_id | |||
| userInfoService.cleanAllOpenId(userInfo); | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation(value = "删除用户接口", response = String.class) | |||
| @PostMapping("/del") | |||
| //@RequiresPermissions("sys:user:del") | |||
| @SystemControllerLog(description = "用户管理-删除用户") | |||
| public ResultData deleteUser(@RequestBody MallUserInfo userInfo) { | |||
| logger.debug("[" + getIpAddr() + "] MallUserInfoController::deleteUser"); | |||
| MallUserInfo currentUser = getUser(); | |||
| if (currentUser.getIsAdmin().equals(EnumUserAdmin.Normal.getCode())) { | |||
| return new ResultData(ErrorCode.USER_NOT_ADMIN.getCode(), "只有系统管理员才能删除用户"); | |||
| } | |||
| if (currentUser.getId().equals(userInfo.getId())) { | |||
| return new ResultData(ErrorCode.USER_NO_PERMISSION.getCode(), "用户不能删除自己"); | |||
| } | |||
| userInfoService.deleteById(userInfo.getId()); | |||
| userRoleService.deleteByUserId(userInfo.getId()); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation(value = "起停用户接口") | |||
| @PostMapping("updateStatus") | |||
| //@RequiresPermissions("sys:user:update") | |||
| @SystemControllerLog(description = "用户管理-起停用户") | |||
| public ResultData modifyStatus(@RequestBody MallUserInfo userInfo) { | |||
| logger.debug("[" + getIpAddr() + "] MallUserInfoController::modifyStatus"); | |||
| MallUserInfo currentUser = getUser(); | |||
| if (currentUser.getIsAdmin().equals(EnumUserAdmin.ADMIN.getCode())) { | |||
| MallUserInfo userInfo1 = userInfoService.getById(userInfo.getId()); | |||
| if(userInfo1 == null) { | |||
| logger.error(ErrorCode.USER_IS_EMPTY.getMessage()); | |||
| return new ResultData(ErrorCode.USER_IS_EMPTY); | |||
| } | |||
| MallUserInfo updateUserInfo = new MallUserInfo(); | |||
| updateUserInfo.setId(userInfo.getId()); | |||
| updateUserInfo.setTenantId(getTenantId()); | |||
| updateUserInfo.setStatus(userInfo.getStatus()); | |||
| userInfoService.saveOrUpdate(userInfo); | |||
| return new ResultData(); | |||
| } else { | |||
| return new ResultData(ErrorCode.USER_NO_PERMISSION); | |||
| } | |||
| } | |||
| private int checkUniqueName(String userName) { | |||
| return userInfoService.cntByUserName(userName); | |||
| } | |||
| private int checkUniquePhone(String phone) { | |||
| return userInfoService.cntByUserPhone(phone); | |||
| } | |||
| @ApiOperation(value = "用户权限检查") | |||
| @GetMapping("hasButtonPermission") | |||
| @SystemControllerLog(description = "用户管理-用户权限检查") | |||
| public ResultData hasButtonPermission(String permissions) { | |||
| logger.debug("[" + getIpAddr() + "] MallUserInfoController::hasButtonPermission"); | |||
| MallUserInfo info = getUser(); | |||
| info.setPassword("保密"); | |||
| Map<String, Boolean> map = new HashMap<>(); | |||
| for (String name : permissions.split(",")) { | |||
| Long userId = (Long)SecurityUtils.getSubject().getSession().getAttribute(UserSession.userId); | |||
| boolean has = userInfoService.hasButtonPermission(userId, name); | |||
| map.put(name, has); | |||
| } | |||
| return new ResultData(map); | |||
| } | |||
| @ApiOperation(value = "用户权限检查") | |||
| @GetMapping("getUser") | |||
| //@RequiresPermissions("sys:user:info") | |||
| //@SystemControllerLog(description = "用户管理-用户信息") | |||
| public ResultData getUserInfo() { | |||
| ///logger.debug("[" + getIpAddr() + "] MallUserInfoController::getUserInfo"); | |||
| MallUserInfo info = getUser(); | |||
| info.protectInfos(); | |||
| return new ResultData(info); | |||
| } | |||
| @ApiOperation(value = "用户密码发送验证码") | |||
| @GetMapping("sendvalidationcode") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "userName", value = "手机号", dataType = "String", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "type", value = "场景(1:登录)", dataType = "Integer", paramType = "query", required = true)}) | |||
| public ResultData sendvalidationcode(String userName, Integer type) { | |||
| logger.debug("[" + getIpAddr() + "] MallUserInfoController::sendvalidationcode"); | |||
| MallUserInfo userQ = new MallUserInfo(); | |||
| userQ.setUsername(userName); | |||
| MallUserInfo user = userInfoService.getByUsername(userName); | |||
| if (user==null) { | |||
| logger.error("用户不存在, userName: " + userName); | |||
| return new ResultData(ErrorCode.USER_IS_EMPTY); | |||
| } | |||
| if(user.getStatus() == EnumMallUserStatus.NOT_VALID.getCode()){ | |||
| logger.error("用户已停用, userName: " + userName); | |||
| return new ResultData(ErrorCode.USER_IS_LOCKED); | |||
| } | |||
| if (StringUtils.isBlank(user.getPhone())) { | |||
| logger.error("用户手机号为空, userName: " + userName); | |||
| return new ResultData(ErrorCode.USER_PHONE_IS_NOT_FOUND); | |||
| } | |||
| WxMsgValidationcode wxMsgValidationcode = new WxMsgValidationcode(); | |||
| wxMsgValidationcode.setTenantId(user.getTenantId()); | |||
| wxMsgValidationcode.setPhone(user.getPhone()); | |||
| wxMsgValidationcode.setType(type); | |||
| return wxMsgValidationcodeService.sendvalidationcode(wxMsgValidationcode); | |||
| } | |||
| @ApiOperation(value = "修改密码", notes = "{\"userName\",\"string\",\"code\",\"string\",\"pwd\",\"string\"}") | |||
| @PostMapping("/updatepwd") | |||
| public ResultData updatepwd(@RequestBody Map<String, String> params) { | |||
| logger.debug("[" + getIpAddr() + "] MallUserInfoController::updatepwd"); | |||
| // String phone,String code,String pwd | |||
| String userName = params.get("userName"); | |||
| String code = params.get("code"); | |||
| String pwd = params.get("pwd"); | |||
| if (StringUtils.isBlank(userName)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "userName不能为空"); | |||
| } | |||
| if (StringUtils.isBlank(code)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "验证码不能为空"); | |||
| } | |||
| if (StringUtils.isBlank(pwd)) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "密码不能为空"); | |||
| } | |||
| MallUserInfo userQ = new MallUserInfo(); | |||
| userQ.setUsername(userName); | |||
| MallUserInfo user = userInfoService.getByUsername(userName); | |||
| if (user==null) { | |||
| logger.error("用户不存在, userName: " + userName); | |||
| return new ResultData(ErrorCode.USER_IS_EMPTY); | |||
| } | |||
| user.setPassword(pwd); | |||
| PasswordHelper passwordHelper = new PasswordHelper(); | |||
| passwordHelper.encryptPassword(user); | |||
| try { | |||
| return userInfoService.updatepwd(user, code); | |||
| } catch (Exception e) { | |||
| return new ResultData(Result.ERROR, e.getMessage()); | |||
| } | |||
| } | |||
| @ApiOperation(value = "审批权限用户列表", response = String.class) | |||
| @GetMapping("getFlowPermissionList") | |||
| //@RequiresPermissions("sys:user:flowlist") | |||
| @SystemControllerLog(description = "用户管理-审批权限用户列表") | |||
| public ResultData getFlowPermissionList() { | |||
| logger.debug("[" + getIpAddr() + "] MallUserInfoController::getFlowPermissionList"); | |||
| MallUserInfo mallUserInfo = new MallUserInfo(); | |||
| mallUserInfo.setFlowPermission(EnumFlowPermissionType.CONTRACT.getCode()+""); | |||
| List<MallUserInfo> contractUserList = userInfoService.findList(mallUserInfo); | |||
| mallUserInfo.setFlowPermission(EnumFlowPermissionType.BILL.getCode()+""); | |||
| List<MallUserInfo> billUserList = userInfoService.findList(mallUserInfo); | |||
| Map<String,Object> resultMap = new HashedMap(); | |||
| resultMap.put("contractUserList",contractUserList); | |||
| resultMap.put("billUserList",billUserList); | |||
| return new ResultData(resultMap); | |||
| } | |||
| } | |||
| @@ -0,0 +1,110 @@ | |||
| package com.iformall.controller.sys; | |||
| 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.MallPermission; | |||
| import com.iformall.domain.po.MallRole; | |||
| import com.iformall.domain.po.MallRolePermission; | |||
| import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.enums.EnumMenuType; | |||
| import com.iformall.enums.EnumPermissionType; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.MallPermissionService; | |||
| import com.iformall.service.MallRolePermissionService; | |||
| import com.iformall.service.MallRoleService; | |||
| import com.iformall.service.MallUserInfoService; | |||
| import com.iformall.utils.Constant; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.apache.shiro.authz.annotation.RequiresPermissions; | |||
| import org.apache.shiro.util.Assert; | |||
| 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.PostMapping; | |||
| import org.springframework.web.bind.annotation.RequestMapping; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| import org.springframework.web.method.HandlerMethod; | |||
| import org.springframework.web.servlet.mvc.condition.PatternsRequestCondition; | |||
| import org.springframework.web.servlet.mvc.method.RequestMappingInfo; | |||
| import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping; | |||
| import java.util.*; | |||
| /** | |||
| * @author Stormeye Wu | |||
| * @date 2019-04-20. | |||
| */ | |||
| @RestController | |||
| @RequestMapping("menu") | |||
| public class SysMenuController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private MallPermissionService mallPermissionService; | |||
| @Autowired | |||
| private MallUserInfoService mallUserInfoService; | |||
| @ApiOperation("导航菜单") | |||
| @GetMapping("/nav") | |||
| public ResultData nav(){ | |||
| logger.debug("[" + getIpAddr() + "] MallPermissionController::nav"); | |||
| MallUserInfo user = getUser(); | |||
| List<MallPermission> menuList = mallPermissionService.getUserMenuList(user, 0L, true); | |||
| Set<String> permissions = mallUserInfoService.getUserPermissions(user); | |||
| Map map = new HashMap<>(); | |||
| map.put("menuList", menuList); | |||
| map.put("permissions", permissions); | |||
| return new ResultData(map); | |||
| } | |||
| @ApiOperation("所有菜单列表") | |||
| @GetMapping("list") | |||
| //@RequiresPermissions("sys:menu:list") | |||
| @SystemControllerLog(description = "用户管理-权限") | |||
| public ResultData getList() { | |||
| logger.debug("[" + getIpAddr() + "] MallPermissionController::list"); | |||
| MallUserInfo user = getUser(); | |||
| List<MallPermission> menuList = mallPermissionService.getUserMenuList(user, 0L, false); | |||
| Set<String> permissions = mallUserInfoService.getUserPermissions(user); | |||
| Map map = new HashMap<>(); | |||
| map.put("menuList", menuList); | |||
| map.put("permissions", permissions); | |||
| return new ResultData(map); | |||
| } | |||
| @ApiOperation("菜单信息") | |||
| @GetMapping("/findById") | |||
| //@RequiresPermissions("sys:menu:info") | |||
| @SystemControllerLog(description = "用户管理-权限查找") | |||
| public ResultData findById(Long id) { | |||
| logger.debug("[" + getIpAddr() + "] MallPermissionController::findById"); | |||
| return new ResultData(Result.SUCCESS, "成功", mallPermissionService.getById(id)); | |||
| } | |||
| @ApiOperation("获取父子菜单ID信息") | |||
| @GetMapping("/getMenuIdsById") | |||
| //@RequiresPermissions("sys:menu:info") | |||
| @SystemControllerLog(description = "用户管理-父子菜单查找") | |||
| public ResultData getMenuIdsById(Long parentId) { | |||
| logger.debug("[" + getIpAddr() + "] MallPermissionController::getMenusById"); | |||
| MallUserInfo user = getUser(); | |||
| return new ResultData(Result.SUCCESS, "成功", mallPermissionService.queryUserMenuIds(user, parentId, false)); | |||
| } | |||
| @ApiOperation("获取父子菜单信息") | |||
| @GetMapping("/getMenusById") | |||
| //@RequiresPermissions("sys:menu:info") | |||
| @SystemControllerLog(description = "用户管理-父子菜单查找") | |||
| public ResultData getMenusById(Long parentId) { | |||
| logger.debug("[" + getIpAddr() + "] MallPermissionController::getMenusById"); | |||
| MallUserInfo user = getUser(); | |||
| return new ResultData(Result.SUCCESS, "成功", mallPermissionService.getUserMenuList(user, parentId, false)); | |||
| } | |||
| } | |||
| @@ -0,0 +1,293 @@ | |||
| package com.iformall.controller.sys; | |||
| import com.amazonaws.AmazonClientException; | |||
| import com.amazonaws.AmazonServiceException; | |||
| import com.amazonaws.auth.AWSCredentials; | |||
| import com.amazonaws.auth.AWSCredentialsProvider; | |||
| import com.amazonaws.auth.BasicAWSCredentials; | |||
| import com.amazonaws.services.s3.AmazonS3; | |||
| import com.amazonaws.services.s3.AmazonS3ClientBuilder; | |||
| import com.amazonaws.services.s3.model.*; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.config.AwsProperty; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.MallResource; | |||
| import com.iformall.service.MallResourceService; | |||
| import com.iformall.utils.Constant; | |||
| import com.iformall.utils.ImgUtil; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| 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.PostMapping; | |||
| import org.springframework.web.bind.annotation.RequestMapping; | |||
| import org.springframework.web.bind.annotation.RequestParam; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| import org.springframework.web.multipart.MultipartFile; | |||
| import java.io.*; | |||
| import java.net.URL; | |||
| import java.util.*; | |||
| import java.util.List; | |||
| @RestController | |||
| @RequestMapping(value = "upload") | |||
| @Api(description = "文件上传接口") | |||
| public class UploadController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private AwsProperty awsProperty; | |||
| @Autowired | |||
| private MallResourceService mallResourceService; | |||
| @Autowired | |||
| private String fmUploadDir; | |||
| private AmazonS3 s3 = null; | |||
| public ResultData awsUpload(InputStream inputStream, ObjectMetadata metadata, String fileName, String tenantId) { | |||
| ResultData data = new ResultData(); | |||
| try { | |||
| if(s3 == null) { | |||
| s3 = AmazonS3ClientBuilder.standard() | |||
| .withRegion(awsProperty.getClientRegion()) | |||
| .withCredentials(new AWSCredentialsProvider() { | |||
| @Override | |||
| public AWSCredentials getCredentials() { | |||
| return new BasicAWSCredentials(awsProperty.getAccess(), awsProperty.getSecret()); | |||
| } | |||
| @Override | |||
| public void refresh() { | |||
| } | |||
| }) | |||
| .build(); | |||
| } | |||
| s3.putObject( | |||
| new PutObjectRequest(awsProperty.getBucketName(), fileName, inputStream, metadata) | |||
| .withCannedAcl(CannedAccessControlList.PublicRead)); | |||
| URL url = s3.getUrl(awsProperty.getBucketName(), fileName); | |||
| logger.info(url.toString()); | |||
| MallResource mr = new MallResource(); | |||
| mr.setTenantId(tenantId); | |||
| mr.setBucket(awsProperty.getBucketName()); | |||
| mr.setS3Key(fileName); | |||
| mr.setUrl(url.toString()); | |||
| mallResourceService.saveOrUpdate(mr); | |||
| data.code = ResultData.SUCCESS; | |||
| Map<String, String> map = new HashMap<>(); | |||
| map.put("url", url.toString()); | |||
| data.data = map; | |||
| } catch (AmazonServiceException ase) { | |||
| data.code = ResultData.ERROR; | |||
| logger.warn("Caught an AmazonServiceException, which " + | |||
| "means your request made it " + | |||
| "to Amazon S3, but was rejected with an error response" + | |||
| " for some reason."); | |||
| logger.warn(ase.getMessage()); | |||
| data.code = ResultData.ERROR; | |||
| data.message = "上传失败"; | |||
| } catch (AmazonClientException ace) { | |||
| data.code = ResultData.ERROR; | |||
| logger.warn("Caught an AmazonClientException, which " + | |||
| "means the client encountered " + | |||
| "an internal error while trying to " + | |||
| "communicate with S3, " + | |||
| "such as not being able to access the network."); | |||
| logger.warn("Error Message: " + ace.getMessage()); | |||
| data.code = ResultData.ERROR; | |||
| data.message = "上传失败"; | |||
| } catch (Exception ioe) { | |||
| data.code = ResultData.ERROR; | |||
| logger.warn("Caught an IOException: " + ioe.getMessage()); | |||
| data.code = ResultData.ERROR; | |||
| data.message = "上传失败"; | |||
| } | |||
| return data; | |||
| } | |||
| /** | |||
| * 上传文件 | |||
| * | |||
| * @param multiReq | |||
| * @return | |||
| * @throws Exception | |||
| */ | |||
| @PostMapping(value = "/awsFileUpload", consumes = "multipart/*", headers = "content-type=multipart/form-data") | |||
| @ApiOperation("上传文件") | |||
| public ResultData awsfileUpload(@RequestParam("file") MultipartFile multiReq) throws Exception{ | |||
| logger.info("[" + getIpAddr() + "] UploadController::awsfileUpload"); | |||
| ObjectMetadata metadata = new ObjectMetadata(); | |||
| metadata.setContentType(multiReq.getContentType()); | |||
| metadata.setContentLength(multiReq.getSize()); | |||
| FileOutputStream fos = null; | |||
| BufferedInputStream fs = null; | |||
| String fileName = UUID.randomUUID().toString(); | |||
| int dot = multiReq.getOriginalFilename().lastIndexOf('.'); | |||
| if (dot >= 0) { | |||
| fileName = getTenantId() + "/" + fileName + multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length()); | |||
| } else { | |||
| fileName = getTenantId() + "/" + fileName; | |||
| } | |||
| System.out.println(fileName); | |||
| ResultData data = awsUpload(multiReq.getInputStream(), metadata, fileName, getTenantId()); | |||
| return data; | |||
| } | |||
| /** | |||
| * 图片上传 | |||
| * | |||
| * @param multiReq | |||
| * @return | |||
| * @throws Exception | |||
| */ | |||
| @PostMapping(value = "/awsImgUpload", consumes = "multipart/*", headers = "content-type=multipart/form-data") | |||
| @ApiOperation("上传图片") | |||
| public ResultData awsImgUpload(@RequestParam("file") MultipartFile multiReq) throws Exception{ | |||
| logger.info("[" + getIpAddr() + "] UploadController::awsImgUpload"); | |||
| String fileName = UUID.randomUUID().toString(); | |||
| String tempFileName = fileName; | |||
| String fileFormat = ""; | |||
| int dot = multiReq.getOriginalFilename().lastIndexOf('.'); | |||
| if (dot >= 0) { | |||
| fileFormat = multiReq.getOriginalFilename().substring(dot, multiReq.getOriginalFilename().length()); | |||
| fileName = getTenantId() + "/" + fileName + fileFormat; | |||
| } else { | |||
| fileName = getTenantId() + "/" + fileName; | |||
| } | |||
| System.out.println(fileName); | |||
| FileOutputStream fos = null; | |||
| String imgFormat = ImgUtil.getImgFormat(fileFormat); | |||
| if(StringUtils.isNotBlank(imgFormat)) { | |||
| String localImgFileName = fmUploadDir + tempFileName + "-1" + fileFormat; | |||
| String localNewImgFileName = fmUploadDir + tempFileName + fileFormat; | |||
| BufferedInputStream fs = null; | |||
| File localFile = new File(localImgFileName); | |||
| fos = new FileOutputStream(localFile); | |||
| fs = (BufferedInputStream) multiReq.getInputStream(); | |||
| byte[] buffer = new byte[1024]; | |||
| int len = 0; | |||
| while ((len = fs.read(buffer)) != -1) { | |||
| fos.write(buffer, 0, len); | |||
| } | |||
| fos.close(); | |||
| fs.close(); | |||
| logger.info("local file: " + localImgFileName); | |||
| File newFile = ImgUtil.thinImage(localImgFileName, localNewImgFileName, imgFormat); | |||
| logger.info("local new file: " + localNewImgFileName); | |||
| // 删除本地缓存 | |||
| localFile.delete(); | |||
| ObjectMetadata metadata = new ObjectMetadata(); | |||
| metadata.setContentType(multiReq.getContentType()); | |||
| metadata.setContentLength(newFile.length()); | |||
| ResultData data = awsUpload(new FileInputStream(newFile), metadata, fileName, getTenantId()); | |||
| // 删除本地缓存 | |||
| newFile.delete(); | |||
| return data; | |||
| } else { | |||
| ObjectMetadata metadata = new ObjectMetadata(); | |||
| metadata.setContentType(multiReq.getContentType()); | |||
| metadata.setContentLength(multiReq.getSize()); | |||
| ResultData data = awsUpload(multiReq.getInputStream(), metadata, fileName, getTenantId()); | |||
| return data; | |||
| } | |||
| } | |||
| /** | |||
| * 多文件上传 | |||
| * | |||
| * @param files | |||
| * @return | |||
| * @throws Exception | |||
| */ | |||
| @PostMapping(value = "/awsFilesUpload", consumes = "multipart/*", headers = "content-type=multipart/form-data") | |||
| @ApiOperation("多文件上传") | |||
| public ResultData awsFilesUpload(@RequestParam("files") MultipartFile[] files) throws Exception{ | |||
| logger.info("[" + getIpAddr() + "] UploadController::awsFilesUpload"); | |||
| if(files.length > 0){ | |||
| ResultData data = new ResultData(); | |||
| List<Map<String,String>> dataList = new ArrayList<Map<String,String>>(); | |||
| for(MultipartFile multipartFile: files) { | |||
| Map<String, String> map = new HashMap<>(); | |||
| ObjectMetadata metadata = new ObjectMetadata(); | |||
| metadata.setContentType(multipartFile.getContentType()); | |||
| metadata.setContentLength(multipartFile.getSize()); | |||
| FileOutputStream fos = null; | |||
| BufferedInputStream fs = null; | |||
| map.put("key", multipartFile.getOriginalFilename()); | |||
| String fileName = UUID.randomUUID().toString(); | |||
| int dot = multipartFile.getOriginalFilename().lastIndexOf('.'); | |||
| if (dot >= 0) { | |||
| fileName = getTenantId() + "/" + fileName + multipartFile.getOriginalFilename().substring(dot, multipartFile.getOriginalFilename().length()); | |||
| } else { | |||
| fileName = getTenantId() + "/" + fileName; | |||
| } | |||
| ResultData data1 = awsUpload(multipartFile.getInputStream(), metadata, fileName, getTenantId()); | |||
| if(data1.code == ResultData.SUCCESS) { | |||
| Map _data = (Map)data1.data; | |||
| map.put("url", (String) _data.get("url")); | |||
| dataList.add(map); | |||
| } else { | |||
| // 部分成功 | |||
| data.code = ResultData.SUCCESS; | |||
| data.data = dataList; | |||
| return data; | |||
| } | |||
| } | |||
| data.code = ResultData.SUCCESS; | |||
| data.data = dataList; | |||
| return data; | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| /** | |||
| * 内部接口-C端上传图片文件 | |||
| * | |||
| * @param multiReq | |||
| * @return | |||
| * @throws Exception | |||
| */ | |||
| @PostMapping(value = "/cimgUpload", consumes = "multipart/*", headers = "content-type=multipart/form-data") | |||
| @ApiOperation("内部接口-C端上传图片文件") | |||
| public ResultData cimgUpload(@RequestParam("file") MultipartFile multiReq) throws Exception{ | |||
| logger.info("[" + getIpAddr() + "] UploadController::cimgUpload"); | |||
| ObjectMetadata metadata = new ObjectMetadata(); | |||
| metadata.setContentType(multiReq.getContentType()); | |||
| metadata.setContentLength(multiReq.getSize()); | |||
| String fileName = multiReq.getOriginalFilename(); | |||
| fileName = "cimg/" + fileName; | |||
| ResultData data = awsUpload(multiReq.getInputStream(), metadata, fileName, "cimg"); | |||
| return data; | |||
| } | |||
| } | |||
| @@ -1,15 +1,15 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.sys; | |||
| import com.alibaba.fastjson.JSON; | |||
| 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.MallUserAction; | |||
| import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.domain.vo.MallUserInfoVo; | |||
| import com.iformall.enums.EnumMallUserAction; | |||
| import com.iformall.enums.EnumUserAdmin; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.MallUserActionService; | |||
| import com.iformall.service.MallUserInfoService; | |||
| import com.iformall.service.MallUserRoleService; | |||
| @@ -46,10 +46,8 @@ import javax.servlet.http.Cookie; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.io.IOException; | |||
| import java.io.UnsupportedEncodingException; | |||
| import java.net.URLEncoder; | |||
| import java.util.*; | |||
| import java.util.concurrent.TimeUnit; | |||
| @Controller | |||
| @@ -382,7 +380,7 @@ public class WechatLoginController extends BaseController { | |||
| if(userInfo.getId() == null && userInfo.getUsername() == null) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| // 只有本人及超级管理员可以解绑微信 | |||
| // 只有本人及系统管理员可以解绑微信 | |||
| if(userInfo.getId().equals(user.getId()) | |||
| || user.getIsAdmin().equals(EnumUserAdmin.ADMIN.getCode())) { | |||
| mallUserInfoService.cleanWebOpenId(userInfo); | |||
| @@ -0,0 +1,35 @@ | |||
| package com.iformall.controller.sys; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxAdminLog; | |||
| import com.iformall.service.WxAdminLogService; | |||
| 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.*; | |||
| @RestController | |||
| @RequestMapping("wxAdminLog") | |||
| public class WxAdminLogController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxAdminLogService wxAdminLogService; | |||
| @ApiOperation("PV计数") | |||
| @PostMapping("pvlog") | |||
| public ResultData pvLog(@RequestBody WxAdminLog wxAdminLog) { | |||
| logger.debug("[" + getIpAddr() + "] WxAdminLogController::pvLog"); | |||
| String tenantId = getTenantId(); | |||
| wxAdminLog.setTenantId(tenantId); | |||
| wxAdminLogService.saveLogCount(wxAdminLog); | |||
| return new ResultData(); | |||
| } | |||
| } | |||
| @@ -1,16 +1,13 @@ | |||
| package com.iformall.controller; | |||
| package com.iformall.controller.sys; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxBusiness; | |||
| import com.iformall.domain.po.WxSubBusiness; | |||
| import com.iformall.service.WxBusinessService; | |||
| import com.iformall.service.WxSubBusinessService; | |||
| 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; | |||
| @@ -18,7 +15,6 @@ import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.List; | |||
| import java.util.stream.Collectors; | |||
| @RestController | |||
| @RequestMapping("wxBusiness") | |||
| @@ -32,25 +28,12 @@ public class WxBusinessController extends BaseController { | |||
| @Autowired | |||
| private WxSubBusinessService wxSubBusinessService; | |||
| @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 WxBusiness wxBusiness, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxBusinessController::list"); | |||
| if (null == wxBusiness) wxBusiness = new WxBusiness(); | |||
| final PageInfo<WxBusiness> page = wxBusinessService.listAsPage(wxBusiness, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("业态全列表接口") | |||
| @GetMapping("listAll") | |||
| @SystemControllerLog(description = "业态-全列表") | |||
| public ResultData listAll() { | |||
| logger.debug("[" + getIpAddr() + "] WxBusinessController::getList"); | |||
| final List<WxBusiness> busList = wxBusinessService.findListAll(); | |||
| final List<WxBusiness> busList = wxBusinessService.findListAll(getTenantId(),null); | |||
| return new ResultData(busList); | |||
| } | |||