| @@ -0,0 +1,14 @@ | |||||
| package com.iformall.annotation; | |||||
| import java.lang.annotation.*; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| @Target({ElementType.METHOD}) | |||||
| @Retention(RetentionPolicy.RUNTIME) | |||||
| @Documented | |||||
| public @interface UserDataRuleAnnotation { | |||||
| String value() default ""; | |||||
| } | |||||
| @@ -2,6 +2,7 @@ package com.iformall.controller.basic; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.annotation.SystemControllerLog; | import com.iformall.annotation.SystemControllerLog; | ||||
| import com.iformall.annotation.UserDataRuleAnnotation; | |||||
| import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.controller.base.BaseController; | import com.iformall.controller.base.BaseController; | ||||
| @@ -18,6 +19,7 @@ import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||
| import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
| import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
| import java.util.List; | import java.util.List; | ||||
| @@ -37,6 +39,7 @@ public class WxMerchantController extends BaseController { | |||||
| private QrCodeService qrCodeService; | private QrCodeService qrCodeService; | ||||
| @UserDataRuleAnnotation("merchant_list") | |||||
| @ApiOperation("分页列表接口") | @ApiOperation("分页列表接口") | ||||
| @GetMapping("listVo") | @GetMapping("listVo") | ||||
| @ApiImplicitParams({ | @ApiImplicitParams({ | ||||
| @@ -1,10 +1,14 @@ | |||||
| package com.iformall.controller.contract; | package com.iformall.controller.contract; | ||||
| import com.iformall.annotation.SystemControllerLog; | import com.iformall.annotation.SystemControllerLog; | ||||
| import com.iformall.annotation.UserDataRuleAnnotation; | |||||
| import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.controller.base.BaseController; | import com.iformall.controller.base.BaseController; | ||||
| import com.iformall.domain.po.*; | |||||
| import com.iformall.domain.po.MallUserInfo; | |||||
| import com.iformall.domain.po.WxBillProperty; | |||||
| import com.iformall.domain.po.WxMerchant; | |||||
| import com.iformall.domain.po.WxPropertyContract; | |||||
| import com.iformall.enums.EnumIsPreview; | import com.iformall.enums.EnumIsPreview; | ||||
| import com.iformall.enums.EnumRentStartType; | import com.iformall.enums.EnumRentStartType; | ||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| @@ -38,7 +42,8 @@ public class WxPropertyContractController extends BaseController { | |||||
| private Logger logger = LoggerFactory.getLogger(WxPropertyContractController.class); | private Logger logger = LoggerFactory.getLogger(WxPropertyContractController.class); | ||||
| @GetMapping("list") | |||||
| @UserDataRuleAnnotation("property_contract_list") | |||||
| @GetMapping("/list") | |||||
| @ApiImplicitParams({ | @ApiImplicitParams({ | ||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | ||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | ||||
| @@ -1,22 +1,23 @@ | |||||
| package com.iformall.controller.contract; | package com.iformall.controller.contract; | ||||
| import com.iformall.annotation.SystemControllerLog; | import com.iformall.annotation.SystemControllerLog; | ||||
| import com.iformall.annotation.UserDataRuleAnnotation; | |||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.IdWorker; | |||||
| import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.controller.base.BaseController; | import com.iformall.controller.base.BaseController; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| import com.iformall.enums.EnumBillAction; | |||||
| import com.iformall.enums.EnumFromType; | import com.iformall.enums.EnumFromType; | ||||
| import com.iformall.enums.EnumIsPreview; | import com.iformall.enums.EnumIsPreview; | ||||
| import com.iformall.enums.EnumRentStartType; | import com.iformall.enums.EnumRentStartType; | ||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.mapper.WxBillActionMapper; | |||||
| import com.iformall.mapper.WxBillPropertyMapper; | import com.iformall.mapper.WxBillPropertyMapper; | ||||
| import com.iformall.mapper.WxBillRentMapper; | import com.iformall.mapper.WxBillRentMapper; | ||||
| import com.iformall.mapper.WxRentContractMapper; | import com.iformall.mapper.WxRentContractMapper; | ||||
| import com.iformall.service.*; | |||||
| import com.iformall.service.WxBillRentService; | |||||
| import com.iformall.service.WxMerchantService; | |||||
| import com.iformall.service.WxPayAccountBillService; | |||||
| import com.iformall.service.WxRentContractService; | |||||
| import com.iformall.utils.DateUtils; | import com.iformall.utils.DateUtils; | ||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||
| import io.swagger.annotations.ApiImplicitParams; | import io.swagger.annotations.ApiImplicitParams; | ||||
| @@ -28,9 +29,11 @@ import org.springframework.web.bind.annotation.*; | |||||
| import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||
| import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||
| import java.math.BigDecimal; | |||||
| import java.text.SimpleDateFormat; | import java.text.SimpleDateFormat; | ||||
| import java.util.*; | |||||
| import java.util.Date; | |||||
| import java.util.HashMap; | |||||
| import java.util.List; | |||||
| import java.util.Map; | |||||
| /** | /** | ||||
| * @author gongbiao | * @author gongbiao | ||||
| @@ -88,7 +91,8 @@ public class WxRentContractController extends BaseController { | |||||
| return new ResultData(map); | return new ResultData(map); | ||||
| } | } | ||||
| @GetMapping("list") | |||||
| @UserDataRuleAnnotation("rent_contract_list") | |||||
| @GetMapping("/list") | |||||
| @ApiImplicitParams({ | @ApiImplicitParams({ | ||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | ||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | ||||
| @@ -2,6 +2,7 @@ package com.iformall.controller.contract; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.annotation.SystemControllerLog; | import com.iformall.annotation.SystemControllerLog; | ||||
| import com.iformall.annotation.UserDataRuleAnnotation; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.controller.base.BaseController; | import com.iformall.controller.base.BaseController; | ||||
| import com.iformall.domain.po.MallUserInfo; | import com.iformall.domain.po.MallUserInfo; | ||||
| @@ -27,7 +28,8 @@ public class WxRentPropertyContractController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| private WxRentPropertyContractService wxRentPropertyContractService; | private WxRentPropertyContractService wxRentPropertyContractService; | ||||
| @GetMapping("list") | |||||
| @UserDataRuleAnnotation("rent_property_contract_list") | |||||
| @GetMapping("/list") | |||||
| @ApiImplicitParams({ | @ApiImplicitParams({ | ||||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | ||||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | ||||
| @@ -2,6 +2,7 @@ package com.iformall.controller.datatower; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.annotation.SystemControllerLog; | import com.iformall.annotation.SystemControllerLog; | ||||
| import com.iformall.annotation.UserDataRuleAnnotation; | |||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.controller.base.BaseController; | import com.iformall.controller.base.BaseController; | ||||
| @@ -31,6 +32,7 @@ public class WxMerchantTradeDailyController extends BaseController { | |||||
| private WxMerchantTradeDailyService wxMerchantTradeDailyService; | private WxMerchantTradeDailyService wxMerchantTradeDailyService; | ||||
| @UserDataRuleAnnotation("merchant_trade") | |||||
| @ApiOperation("获得解单列表") | @ApiOperation("获得解单列表") | ||||
| @GetMapping("/list") | @GetMapping("/list") | ||||
| @ApiImplicitParams({ | @ApiImplicitParams({ | ||||
| @@ -0,0 +1,57 @@ | |||||
| package com.iformall.controller.sys; | |||||
| 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.WxDataRuleTarget; | |||||
| import com.iformall.service.WxDataRuleTargetService; | |||||
| import io.swagger.annotations.Api; | |||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.web.bind.annotation.GetMapping; | |||||
| import org.springframework.web.bind.annotation.ModelAttribute; | |||||
| import org.springframework.web.bind.annotation.RequestMapping; | |||||
| import org.springframework.web.bind.annotation.RestController; | |||||
| import java.util.List; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| @RestController | |||||
| @RequestMapping("wxDataRuleTarget") | |||||
| @Api(description = "数据权限目标") | |||||
| public class WxDataRuleTargetController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxDataRuleTargetService wxDataRuleTargetService; | |||||
| @ApiOperation("列表接口") | |||||
| @GetMapping("list") | |||||
| @SystemControllerLog(description = "数据权限目标-列表接口") | |||||
| @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 WxDataRuleTarget wxDataRuleTarget, Integer pageNum, Integer pageSize) { | |||||
| logger.debug("[" + getIpAddr() + "] wxDataRuleTarget::list"); | |||||
| final PageInfo<WxDataRuleTarget> page = wxDataRuleTargetService.listAsPage(wxDataRuleTarget, pageNum, pageSize); | |||||
| return new ResultData(page); | |||||
| } | |||||
| @ApiOperation("获取全部") | |||||
| @GetMapping("getList") | |||||
| @SystemControllerLog(description = "数据权限目标-获取全部") | |||||
| public ResultData getList() { | |||||
| logger.debug("[" + getIpAddr() + "] wxDataRuleTarget::getList"); | |||||
| List<WxDataRuleTarget> datalist = wxDataRuleTargetService.getList(); | |||||
| return new ResultData(datalist); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,48 @@ | |||||
| package com.iformall.controller.sys; | |||||
| import com.iformall.annotation.SystemControllerLog; | |||||
| import com.iformall.common.ResultData; | |||||
| import com.iformall.controller.base.BaseController; | |||||
| import com.iformall.domain.po.WxUserDataRule; | |||||
| import com.iformall.service.WxUserDataRuleService; | |||||
| import io.swagger.annotations.Api; | |||||
| 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.*; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| @RestController | |||||
| @RequestMapping("wxUserDataRule") | |||||
| @Api(description = "用户数据权限") | |||||
| public class WxUserDataRuleController extends BaseController { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxUserDataRuleService wxUserDataRuleService; | |||||
| @ApiOperation("编辑") | |||||
| @PostMapping("/modify") | |||||
| @SystemControllerLog(description = "用户数据权限-新增") | |||||
| public ResultData modify(@RequestBody WxUserDataRule wxUserDataRule) { | |||||
| logger.debug("[" + getIpAddr() + "] wxDataRuleTarget::modify"); | |||||
| wxUserDataRuleService.modify(wxUserDataRule); | |||||
| return new ResultData(); | |||||
| } | |||||
| @ApiOperation("根据用户ID查看") | |||||
| @GetMapping("/findByUserId") | |||||
| @ApiImplicitParam(name = "userId", value = "userId", dataType = "Long", paramType = "query", required = true) | |||||
| @SystemControllerLog(description = "用户数据权限-根据用户ID查看") | |||||
| public ResultData findByUserId(Long userId) { | |||||
| logger.debug("[" + getIpAddr() + "] wxDataRuleTarget::modify"); | |||||
| WxUserDataRule wxUserDataRule = wxUserDataRuleService.findByUserId(userId); | |||||
| return new ResultData(wxUserDataRule); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,104 @@ | |||||
| package com.iformall.log; | |||||
| import com.alibaba.fastjson.JSONArray; | |||||
| import com.alibaba.fastjson.JSONObject; | |||||
| import com.iformall.annotation.UserDataRuleAnnotation; | |||||
| import com.iformall.domain.po.BaseEntity; | |||||
| import com.iformall.domain.po.MallUserInfo; | |||||
| import com.iformall.domain.po.WxUserDataRule; | |||||
| import com.iformall.service.WxUserDataRuleService; | |||||
| import com.iformall.shiro.UserSession; | |||||
| import org.apache.commons.lang3.StringUtils; | |||||
| import org.aspectj.lang.JoinPoint; | |||||
| import org.aspectj.lang.annotation.Aspect; | |||||
| import org.aspectj.lang.annotation.Before; | |||||
| import org.aspectj.lang.annotation.Pointcut; | |||||
| import org.aspectj.lang.reflect.MethodSignature; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Component; | |||||
| import org.springframework.web.context.request.RequestContextHolder; | |||||
| import org.springframework.web.context.request.ServletRequestAttributes; | |||||
| import javax.servlet.http.HttpServletRequest; | |||||
| import java.lang.reflect.Method; | |||||
| import java.util.HashSet; | |||||
| import java.util.stream.Collectors; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| @Aspect | |||||
| @Component | |||||
| public class UserDataRuleAspect { | |||||
| private static final Logger logger = LoggerFactory.getLogger(UserDataRuleAspect.class); | |||||
| @Autowired | |||||
| private WxUserDataRuleService wxUserDataRuleService; | |||||
| @Pointcut("@annotation(com.iformall.annotation.UserDataRuleAnnotation)") | |||||
| public void userDataRulePointcut() { | |||||
| } | |||||
| @Before("userDataRulePointcut()") | |||||
| public void doBefore(JoinPoint joinPoint) { | |||||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||||
| MallUserInfo user = (MallUserInfo) request.getSession().getAttribute(UserSession.userInfo); | |||||
| if (user == null) { | |||||
| logger.error("session 获取 user 失败"); | |||||
| return; | |||||
| } | |||||
| //得到用户的数据权限 | |||||
| WxUserDataRule byUserId = wxUserDataRuleService.findByUserId(user.getId()); | |||||
| if (byUserId == null) { | |||||
| logger.info("用户的数据权限未配置"); | |||||
| return; | |||||
| } | |||||
| String buildingFloor = byUserId.getBuildingFloor(); | |||||
| if (StringUtils.isNotEmpty(buildingFloor)) { | |||||
| buildingFloor = JSONObject.parseObject(buildingFloor).getJSONArray("data").stream() | |||||
| .map(m -> { | |||||
| JSONObject jsonObject = JSONObject.parseObject(String.valueOf(m)); | |||||
| return jsonObject.getString("floor"); | |||||
| }).collect(Collectors.joining(",")); | |||||
| } | |||||
| String businessForRule = byUserId.getBusinessForRule(); | |||||
| if (StringUtils.isNotEmpty(businessForRule)) { | |||||
| Object[] data = JSONObject.parseObject(businessForRule).getJSONArray("data").toArray(); | |||||
| businessForRule = StringUtils.join(data, ","); | |||||
| } | |||||
| HashSet<String> targetSet = new HashSet(); | |||||
| String target = byUserId.getTarget(); | |||||
| if (StringUtils.isNotEmpty(target)) { | |||||
| JSONArray objects = JSONArray.parseArray(target); | |||||
| for (int i = 0; i < objects.size(); i++) { | |||||
| JSONObject jsonObject = objects.getJSONObject(i); | |||||
| JSONArray children = jsonObject.getJSONArray("children"); | |||||
| for (int j = 0; j < children.size(); j++) { | |||||
| targetSet.add(children.getJSONObject(i).getString("tag")); | |||||
| } | |||||
| } | |||||
| } | |||||
| //得到注释的名称 | |||||
| MethodSignature signature = (MethodSignature) joinPoint.getSignature(); | |||||
| //判断tag是否在用户权限中 如果存在加入参数查询 | |||||
| Method method = signature.getMethod(); | |||||
| String value = method.getAnnotation(UserDataRuleAnnotation.class).value(); | |||||
| if (targetSet.contains(value)) { | |||||
| //得到方法的参数 | |||||
| Object[] args = joinPoint.getArgs(); | |||||
| if (args[0] instanceof BaseEntity) { | |||||
| BaseEntity baseEntity = (BaseEntity) args[0]; | |||||
| baseEntity.setFloorForRule(buildingFloor); | |||||
| baseEntity.setBusinessForRule(businessForRule); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,35 @@ | |||||
| drop table if exists wx_user_data_rule; | |||||
| CREATE TABLE wx_user_data_rule ( | |||||
| `id` bigint(20) NOT NULL, | |||||
| `tenant_id` varchar(10) NOT NULL COMMENT '租户ID', | |||||
| `user_id` bigint(20) NOT NULL COMMENT '角色名称', | |||||
| `type` tinyint(3) NOT NULL COMMENT '权限类型1系统全部数据2楼层及业态', | |||||
| `building_floor` json DEFAULT NULL COMMENT '楼层楼座', | |||||
| `business` json DEFAULT NULL COMMENT '业态', | |||||
| `target` json DEFAULT NULL COMMENT '数据范围', | |||||
| `create_time` datetime DEFAULT NULL COMMENT '创建时间', | |||||
| `update_time` datetime DEFAULT NULL COMMENT '更新时间', | |||||
| PRIMARY KEY (`id`), | |||||
| UNIQUE `id_UNIQUE` USING BTREE (`id`) comment '' | |||||
| ) ENGINE=`InnoDB` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ROW_FORMAT=DYNAMIC COMMENT='用户数据权限' CHECKSUM=0 DELAY_KEY_WRITE=0; | |||||
| drop table if exists wx_data_rule_target; | |||||
| CREATE TABLE wx_data_rule_target ( | |||||
| `id` bigint(20) NOT NULL, | |||||
| `parent` bigint(20) NOT NULL COMMENT '父级', | |||||
| `name` varchar(50) NOT NULL COMMENT '名称', | |||||
| `tag` varchar(50) DEFAULT NULL COMMENT '标签', | |||||
| `create_time` datetime DEFAULT NULL COMMENT '创建时间', | |||||
| `update_time` datetime DEFAULT NULL COMMENT '更新时间', | |||||
| PRIMARY KEY (`id`), | |||||
| UNIQUE `id_UNIQUE` USING BTREE (`id`) comment '' | |||||
| ) ENGINE=`InnoDB` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ROW_FORMAT=DYNAMIC COMMENT='数据权限目标' CHECKSUM=0 DELAY_KEY_WRITE=0; | |||||
| insert into `wx_data_rule_target` ( `id`, `parent`, `name`, `tag`, `create_time`, `update_time`) values ( '1', '0', '商户商铺', '', '2019-08-26 13:23:25', '2019-08-26 13:23:27'); | |||||
| insert into `wx_data_rule_target` ( `id`, `parent`, `name`, `tag`, `create_time`, `update_time`) values ( '2', '0', '合同管理', '', '2019-08-26 13:32:04', '2019-08-26 13:32:07'); | |||||
| insert into `wx_data_rule_target` ( `id`, `parent`, `name`, `tag`, `create_time`, `update_time`) values ( '101','1', '商户列表', 'merchant_list', '2019-08-26 13:32:17', '2019-08-26 13:32:19'); | |||||
| insert into `wx_data_rule_target` ( `id`, `parent`, `name`, `tag`, `create_time`, `update_time`) values ( '102','1', '解单数据', 'merchant_trade', '2019-08-26 13:33:24', '2019-08-26 13:33:25'); | |||||
| insert into `wx_data_rule_target` ( `id`, `parent`, `name`, `tag`, `create_time`, `update_time`) values ( '201','2', '租金合同', 'rent_contract_list', '2019-08-26 13:34:17', '2019-08-26 13:34:20'); | |||||
| insert into `wx_data_rule_target` ( `id`, `parent`, `name`, `tag`, `create_time`, `update_time`) values ( '202','2', '物业合同', 'property_contract_list', '2019-08-26 13:34:45', '2019-08-26 13:34:47'); | |||||
| insert into `wx_data_rule_target` ( `id`, `parent`, `name`, `tag`, `create_time`, `update_time`) values ( '203','2', '租金物业合同', 'rent_property_contract_list', '2019-08-26 13:36:23', '2019-08-26 13:36:25'); | |||||
| @@ -78,6 +78,14 @@ public interface PosService { | |||||
| */ | */ | ||||
| Map<String, String> cardPayPreCancel(Map<String, String> params) throws MallinkException; | Map<String, String> cardPayPreCancel(Map<String, String> params) throws MallinkException; | ||||
| /** | |||||
| * 订单同步-Neusoft-支付或者退款成功后通知富茂 | |||||
| * @param params | |||||
| * @return | |||||
| * @throws MallinkException | |||||
| */ | |||||
| Map<String, String> posOrderSync(Map<String, String> params) throws MallinkException; | |||||
| /** | /** | ||||
| * 消费卡POS支付 | * 消费卡POS支付 | ||||
| * @param params | * @param params | ||||
| @@ -94,4 +102,6 @@ public interface PosService { | |||||
| * @throws MallinkException | * @throws MallinkException | ||||
| */ | */ | ||||
| Map<String, String> cardPayCancel(Map<String, String> params) throws MallinkException; | Map<String, String> cardPayCancel(Map<String, String> params) throws MallinkException; | ||||
| } | } | ||||
| @@ -70,19 +70,13 @@ public class PosServiceImpl implements PosService { | |||||
| String password = params.get(WxPayConstant.PASSWORD); // buUser's password | String password = params.get(WxPayConstant.PASSWORD); // buUser's password | ||||
| if (StringUtils.isBlank(tenantId)) { | if (StringUtils.isBlank(tenantId)) { | ||||
| String errMessage = "request params[tenant_id] error."; | |||||
| logger.error(errMessage); | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.TENANT_ID); | |||||
| } | } | ||||
| if (StringUtils.isBlank(phone)) { | if (StringUtils.isBlank(phone)) { | ||||
| String errMessage = "request params[phone] error."; | |||||
| logger.error(errMessage); | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.PHONE); | |||||
| } | } | ||||
| if (StringUtils.isBlank(password)) { | if (StringUtils.isBlank(password)) { | ||||
| String errMessage = "request params[password] error."; | |||||
| logger.error(errMessage); | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.PASSWORD); | |||||
| } | } | ||||
| WxMerchantBUser user = new WxMerchantBUser(); | WxMerchantBUser user = new WxMerchantBUser(); | ||||
| user.setTenantId(tenantId); | user.setTenantId(tenantId); | ||||
| @@ -93,26 +87,12 @@ public class PosServiceImpl implements PosService { | |||||
| try { | try { | ||||
| user1 = merchantBUserService.getBUserByAppId(user); | user1 = merchantBUserService.getBUserByAppId(user); | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| String errMessage = "B端用户不存在或者已被禁用, phone: " + phone + ", " +e.getMessage(); | |||||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY.getCode(), errMessage); | |||||
| String errMessage = ErrorCode.MERCHANT_BUSER_NOT_VALID.getMessage() + "phone: " + phone + ", " +e.getMessage(); | |||||
| throw new MallinkException(ErrorCode.MERCHANT_BUSER_NOT_VALID.getCode(), errMessage); | |||||
| } | } | ||||
| if (user1 != null) { | if (user1 != null) { | ||||
| // check merchant 状态 | // check merchant 状态 | ||||
| WxMerchant merchant = null; | |||||
| try { | |||||
| merchant = merchantService.getById(user1.getMerchantId()); | |||||
| } catch (Exception e) { | |||||
| String errMessage = ErrorCode.DB_FAIL.getMessage() + ": " + user1.getMerchantId() + e.getMessage(); | |||||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), errMessage); | |||||
| } | |||||
| if (merchant == null) { | |||||
| logger.error(ErrorCode.MERCHANT_INFO_NOT_FOUND.getMessage() + ": " + user1.getMerchantId()); | |||||
| throw new MallinkException(ErrorCode.MERCHANT_INFO_NOT_FOUND); | |||||
| } | |||||
| if (merchant.getStatus().equals(EnumMerchantStatus.NOT_VALID.getCode())) { | |||||
| logger.error(ErrorCode.MERCHANT_INFO_NOT_VALID.getMessage() + ": " + user1.getMerchantId()); | |||||
| throw new MallinkException(ErrorCode.MERCHANT_INFO_NOT_VALID); | |||||
| } | |||||
| WxMerchant merchant = checkAndGetMerchant(user1.getMerchantId()); | |||||
| // check password | // check password | ||||
| if (user1.getUserPwd().equalsIgnoreCase(password)) { | if (user1.getUserPwd().equalsIgnoreCase(password)) { | ||||
| retMap.put(WxPayConstant.TENANT_ID, user1.getTenantId()); | retMap.put(WxPayConstant.TENANT_ID, user1.getTenantId()); | ||||
| @@ -141,9 +121,7 @@ public class PosServiceImpl implements PosService { | |||||
| String tenantId = params.get(WxPayConstant.TENANT_ID); // 租户ID | String tenantId = params.get(WxPayConstant.TENANT_ID); // 租户ID | ||||
| if (StringUtils.isBlank(tenantId)) { | if (StringUtils.isBlank(tenantId)) { | ||||
| String errMessage = "request params[tenant_id] error."; | |||||
| logger.error(errMessage); | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.TENANT_ID); | |||||
| } | } | ||||
| PosMallConfig config = posMallConfigService.getByTenantId(tenantId); | PosMallConfig config = posMallConfigService.getByTenantId(tenantId); | ||||
| if (config == null) { | if (config == null) { | ||||
| @@ -168,9 +146,7 @@ public class PosServiceImpl implements PosService { | |||||
| String tenantId = params.get(WxPayConstant.TENANT_ID); // 租户ID | String tenantId = params.get(WxPayConstant.TENANT_ID); // 租户ID | ||||
| if (StringUtils.isBlank(tenantId)) { | if (StringUtils.isBlank(tenantId)) { | ||||
| String errMessage = "request params[tenant_id] error."; | |||||
| logger.error(errMessage); | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.TENANT_ID); | |||||
| } | } | ||||
| WxMall mall = mallService.getByTenantId(tenantId); | WxMall mall = mallService.getByTenantId(tenantId); | ||||
| if (mall == null) { | if (mall == null) { | ||||
| @@ -199,9 +175,7 @@ public class PosServiceImpl implements PosService { | |||||
| String posAmountStr = params.get(WxPayConstant.POS_AMOUNT); // POS订单金额(单位:分) | String posAmountStr = params.get(WxPayConstant.POS_AMOUNT); // POS订单金额(单位:分) | ||||
| if (StringUtils.isBlank(tenantId)) { | if (StringUtils.isBlank(tenantId)) { | ||||
| String errMessage = "request params[tenant_id] error."; | |||||
| logger.error(errMessage); | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.TENANT_ID); | |||||
| } | } | ||||
| PosMallConfig config = posMallConfigService.getByTenantId(tenantId); | PosMallConfig config = posMallConfigService.getByTenantId(tenantId); | ||||
| @@ -211,19 +185,13 @@ public class PosServiceImpl implements PosService { | |||||
| } | } | ||||
| if (StringUtils.isBlank(merchantIdStr)) { | if (StringUtils.isBlank(merchantIdStr)) { | ||||
| String errMessage = "request params[merchant_id] error."; | |||||
| logger.error(errMessage); | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.MERCHANT_ID); | |||||
| } | } | ||||
| if (StringUtils.isBlank(posOrderIdStr)) { | if (StringUtils.isBlank(posOrderIdStr)) { | ||||
| String errMessage = "request params[pos_order_id] error."; | |||||
| logger.error(errMessage); | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.POS_ORDER_ID); | |||||
| } | } | ||||
| if (StringUtils.isBlank(posAmountStr)) { | if (StringUtils.isBlank(posAmountStr)) { | ||||
| String errMessage = "request params[pos_amount] error."; | |||||
| logger.error(errMessage); | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.POS_AMOUNT); | |||||
| } | } | ||||
| if (StringUtils.isBlank(memIdStr) && StringUtils.isBlank(memPhoneStr)) { | if (StringUtils.isBlank(memIdStr) && StringUtils.isBlank(memPhoneStr)) { | ||||
| @@ -354,9 +322,7 @@ public class PosServiceImpl implements PosService { | |||||
| String posAmountStr = params.get(WxPayConstant.POS_AMOUNT); // POS订单总额(单位:分) | String posAmountStr = params.get(WxPayConstant.POS_AMOUNT); // POS订单总额(单位:分) | ||||
| if (StringUtils.isBlank(tenantId)) { | if (StringUtils.isBlank(tenantId)) { | ||||
| String errMessage = "request params[tenant_id] error."; | |||||
| logger.error(errMessage); | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.TENANT_ID); | |||||
| } | } | ||||
| PosMallConfig config = posMallConfigService.getByTenantId(tenantId); | PosMallConfig config = posMallConfigService.getByTenantId(tenantId); | ||||
| if (config == null) { | if (config == null) { | ||||
| @@ -368,22 +334,17 @@ public class PosServiceImpl implements PosService { | |||||
| throw new MallinkException(ErrorCode.POS_CONFIG_MEM_COUPON_DISABLE); | throw new MallinkException(ErrorCode.POS_CONFIG_MEM_COUPON_DISABLE); | ||||
| } | } | ||||
| if (StringUtils.isBlank(merchantIdStr)) { | if (StringUtils.isBlank(merchantIdStr)) { | ||||
| String errMessage = "request params[merchant_id] error."; | |||||
| logger.error(errMessage); | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.MERCHANT_ID); | |||||
| } | } | ||||
| if (StringUtils.isBlank(buUserIdStr)) { | if (StringUtils.isBlank(buUserIdStr)) { | ||||
| String errMessage = "request params[bu_user_id] error."; | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.BUSER_ID); | |||||
| } | } | ||||
| if (StringUtils.isBlank(couponOrderIdStr)) { | if (StringUtils.isBlank(couponOrderIdStr)) { | ||||
| String errMessage = "request params[coupon_order_id] error."; | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.COUPON_ORDER_ID); | |||||
| } | } | ||||
| if (actionType.equals(EnumVerifyActionType.CHECK)) { | if (actionType.equals(EnumVerifyActionType.CHECK)) { | ||||
| if (StringUtils.isBlank(verifyType)) { | if (StringUtils.isBlank(verifyType)) { | ||||
| String errMessage = "request params[verify_type] error."; | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.VERIFY_TYPE); | |||||
| } | } | ||||
| if (!(verifyType.equalsIgnoreCase(WxPayConstant.VERIFY_TYPE_INDEPENT) || verifyType.equalsIgnoreCase(WxPayConstant.VERIFY_TYPE_PAY))) { | if (!(verifyType.equalsIgnoreCase(WxPayConstant.VERIFY_TYPE_INDEPENT) || verifyType.equalsIgnoreCase(WxPayConstant.VERIFY_TYPE_PAY))) { | ||||
| String errMessage = "request params[verify_type] only support independent or pay."; | String errMessage = "request params[verify_type] only support independent or pay."; | ||||
| @@ -398,15 +359,13 @@ public class PosServiceImpl implements PosService { | |||||
| actionType.equals(EnumVerifyActionType.VERIFY_INDEPENT) || | actionType.equals(EnumVerifyActionType.VERIFY_INDEPENT) || | ||||
| actionType.equals(EnumVerifyActionType.VERIFY_PAY)) { | actionType.equals(EnumVerifyActionType.VERIFY_PAY)) { | ||||
| if (StringUtils.isBlank(posOrderIdStr)) { | if (StringUtils.isBlank(posOrderIdStr)) { | ||||
| String errMessage = "request params[pos_order_id] error."; | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.POS_ORDER_ID); | |||||
| } | } | ||||
| } | } | ||||
| if (actionType.equals(EnumVerifyActionType.PRE_VERIFY) || | if (actionType.equals(EnumVerifyActionType.PRE_VERIFY) || | ||||
| actionType.equals(EnumVerifyActionType.VERIFY_PAY)) { | actionType.equals(EnumVerifyActionType.VERIFY_PAY)) { | ||||
| if (StringUtils.isBlank(posAmountStr)) { | if (StringUtils.isBlank(posAmountStr)) { | ||||
| String errMessage = "request params[pos_amount] error."; | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.POS_AMOUNT); | |||||
| } | } | ||||
| } | } | ||||
| @@ -429,25 +388,9 @@ public class PosServiceImpl implements PosService { | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_CAST_ERROR.getCode(), e.getMessage()); | throw new MallinkException(ErrorCode.SYS_PARAMETER_CAST_ERROR.getCode(), e.getMessage()); | ||||
| } | } | ||||
| // 2. check merchant | // 2. check merchant | ||||
| WxMerchant merchant = merchantService.getById(merchantId); | |||||
| if (merchant == null) { | |||||
| logger.error(ErrorCode.MERCHANT_INFO_NOT_FOUND.getMessage() + ": " + merchantIdStr); | |||||
| throw new MallinkException(ErrorCode.MERCHANT_INFO_NOT_FOUND); | |||||
| } | |||||
| if (merchant.getIsDel().equals(EnumDelStatus.DEL.getCode()) || merchant.getStatus().equals(EnumMerchantStatus.NOT_VALID.getCode())) { | |||||
| logger.error(ErrorCode.MERCHANT_INFO_NOT_VALID.getMessage() + ": " + merchantIdStr); | |||||
| throw new MallinkException(ErrorCode.MERCHANT_INFO_NOT_VALID); | |||||
| } | |||||
| WxMerchant merchant = checkAndGetMerchant(merchantId); | |||||
| // 3. check buUser | // 3. check buUser | ||||
| WxMerchantBUser buUser = merchantBUserService.getById(buUserId); | |||||
| if (buUser == null) { | |||||
| logger.error(ErrorCode.USER_IS_EMPTY.getMessage() + ": " + buUserIdStr); | |||||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | |||||
| } | |||||
| if (!buUser.getMerchantId().equals(merchantId)) { | |||||
| logger.error(ErrorCode.VERIFY_BUSER_MERCHANT_NOT_BELONG.getMessage() + ": " + buUserIdStr); | |||||
| throw new MallinkException(ErrorCode.VERIFY_BUSER_MERCHANT_NOT_BELONG); | |||||
| } | |||||
| WxMerchantBUser buUser = checkAndGetMerchantUser(buUserId, merchantId); | |||||
| JSONArray coRetArr = new JSONArray(); | JSONArray coRetArr = new JSONArray(); | ||||
| if (couponOrderIdStr != null) { | if (couponOrderIdStr != null) { | ||||
| @@ -481,9 +424,7 @@ public class PosServiceImpl implements PosService { | |||||
| String verifyType = WxPayConstant.VERIFY_TYPE_PAY; // 此接口只有支付使用 | String verifyType = WxPayConstant.VERIFY_TYPE_PAY; // 此接口只有支付使用 | ||||
| if (StringUtils.isBlank(tenantId)) { | if (StringUtils.isBlank(tenantId)) { | ||||
| String errMessage = "request params[tenant_id] error."; | |||||
| logger.error(errMessage); | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.TENANT_ID); | |||||
| } | } | ||||
| PosMallConfig config = posMallConfigService.getByTenantId(tenantId); | PosMallConfig config = posMallConfigService.getByTenantId(tenantId); | ||||
| if (config == null) { | if (config == null) { | ||||
| @@ -495,26 +436,20 @@ public class PosServiceImpl implements PosService { | |||||
| throw new MallinkException(ErrorCode.POS_CONFIG_MEM_COUPON_DISABLE); | throw new MallinkException(ErrorCode.POS_CONFIG_MEM_COUPON_DISABLE); | ||||
| } | } | ||||
| if (StringUtils.isBlank(merchantIdStr)) { | if (StringUtils.isBlank(merchantIdStr)) { | ||||
| String errMessage = "request params[merchant_id] error."; | |||||
| logger.error(errMessage); | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.MERCHANT_ID); | |||||
| } | } | ||||
| if (StringUtils.isBlank(buUserIdStr)) { | if (StringUtils.isBlank(buUserIdStr)) { | ||||
| String errMessage = "request params[bu_user_id] error."; | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.BUSER_ID); | |||||
| } | } | ||||
| if (StringUtils.isBlank(selCoListStr)) { | if (StringUtils.isBlank(selCoListStr)) { | ||||
| String errMessage = "request params[sel_co_list] error."; | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.SELECTED_COUPON_ORDER_LIST); | |||||
| } | } | ||||
| if (actionType.equals(EnumVerifyActionType.PRE_VERIFY) || actionType.equals(EnumVerifyActionType.VERIFY_INDEPENT)) { | if (actionType.equals(EnumVerifyActionType.PRE_VERIFY) || actionType.equals(EnumVerifyActionType.VERIFY_INDEPENT)) { | ||||
| if (StringUtils.isBlank(posOrderIdStr)) { | if (StringUtils.isBlank(posOrderIdStr)) { | ||||
| String errMessage = "request params[pos_order_id] error."; | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.POS_ORDER_ID); | |||||
| } | } | ||||
| if (StringUtils.isBlank(posAmountStr)) { | if (StringUtils.isBlank(posAmountStr)) { | ||||
| String errMessage = "request params[pos_amount] error."; | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.POS_AMOUNT); | |||||
| } | } | ||||
| } | } | ||||
| @@ -534,25 +469,9 @@ public class PosServiceImpl implements PosService { | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_CAST_ERROR.getCode(), e.getMessage()); | throw new MallinkException(ErrorCode.SYS_PARAMETER_CAST_ERROR.getCode(), e.getMessage()); | ||||
| } | } | ||||
| // 2. check merchant | // 2. check merchant | ||||
| WxMerchant merchant = merchantService.getById(merchantId); | |||||
| if (merchant == null) { | |||||
| logger.error(ErrorCode.MERCHANT_INFO_NOT_FOUND.getMessage() + ": " + merchantIdStr); | |||||
| throw new MallinkException(ErrorCode.MERCHANT_INFO_NOT_FOUND); | |||||
| } | |||||
| if (merchant.getIsDel().equals(EnumDelStatus.DEL.getCode()) || merchant.getStatus().equals(EnumMerchantStatus.NOT_VALID.getCode())) { | |||||
| logger.error(ErrorCode.MERCHANT_INFO_NOT_VALID.getMessage() + ": " + merchantIdStr); | |||||
| throw new MallinkException(ErrorCode.MERCHANT_INFO_NOT_VALID); | |||||
| } | |||||
| WxMerchant merchant = checkAndGetMerchant(merchantId); | |||||
| // 3. check buUser | // 3. check buUser | ||||
| WxMerchantBUser buUser = merchantBUserService.getById(buUserId); | |||||
| if (buUser == null) { | |||||
| logger.error(ErrorCode.USER_IS_EMPTY.getMessage() + ": " + buUserIdStr); | |||||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | |||||
| } | |||||
| if (!buUser.getMerchantId().equals(merchantId)) { | |||||
| logger.error(ErrorCode.VERIFY_BUSER_MERCHANT_NOT_BELONG.getMessage() + ": " + buUserIdStr); | |||||
| throw new MallinkException(ErrorCode.VERIFY_BUSER_MERCHANT_NOT_BELONG); | |||||
| } | |||||
| WxMerchantBUser buUser = checkAndGetMerchantUser(buUserId, merchantId); | |||||
| JSONArray selCoArr = JSONObject.parseArray(selCoListStr); | JSONArray selCoArr = JSONObject.parseArray(selCoListStr); | ||||
| if (selCoArr.size() <= 0) { | if (selCoArr.size() <= 0) { | ||||
| @@ -657,11 +576,10 @@ public class PosServiceImpl implements PosService { | |||||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_USED); | throw new MallinkException(ErrorCode.COUPON_ORDER_IS_USED); | ||||
| } | } | ||||
| Long couponOrderId = couponOrderCVo.getId(); | |||||
| Date now = new Date(); | |||||
| // 5. 检查有效期 | // 5. 检查有效期 | ||||
| if (couponOrderCVo.getValidStartDate() != null && couponOrderCVo.getValidEndDate() != null) { | if (couponOrderCVo.getValidStartDate() != null && couponOrderCVo.getValidEndDate() != null) { | ||||
| Date now = new Date(); | |||||
| if (couponOrderCVo.getValidStartDate().getTime() > now.getTime()) { | if (couponOrderCVo.getValidStartDate().getTime() > now.getTime()) { | ||||
| logger.error("此券有效期未开始:" + couponOrderIdStr); | logger.error("此券有效期未开始:" + couponOrderIdStr); | ||||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_EARLIER_THAN_VALIDDATE); | throw new MallinkException(ErrorCode.COUPON_ORDER_IS_EARLIER_THAN_VALIDDATE); | ||||
| @@ -671,6 +589,13 @@ public class PosServiceImpl implements PosService { | |||||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_EARLIER_THAN_VALIDDATE); | throw new MallinkException(ErrorCode.COUPON_ORDER_IS_EARLIER_THAN_VALIDDATE); | ||||
| } | } | ||||
| } | } | ||||
| // 5.1 券已过期 | |||||
| if (couponOrderCVo.getExpiredTime().before(now)) { | |||||
| logger.error("此券已过期:" + couponOrderIdStr); | |||||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_EARLIER_THAN_VALIDDATE); | |||||
| } | |||||
| Long couponOrderId = couponOrderCVo.getId(); | |||||
| // 6. 检查适用门店 | // 6. 检查适用门店 | ||||
| WxCouponMerchant wxCouponMerchant = new WxCouponMerchant(); | WxCouponMerchant wxCouponMerchant = new WxCouponMerchant(); | ||||
| @@ -854,30 +779,20 @@ public class PosServiceImpl implements PosService { | |||||
| String forceStr = params.get(WxPayConstant.FORCE); // 是否强制 | String forceStr = params.get(WxPayConstant.FORCE); // 是否强制 | ||||
| if (StringUtils.isBlank(tenantId)) { | if (StringUtils.isBlank(tenantId)) { | ||||
| String errMessage = "request params[tenant_id] error."; | |||||
| logger.error(errMessage); | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.TENANT_ID); | |||||
| } | } | ||||
| if (StringUtils.isBlank(merchantIdStr)) { | if (StringUtils.isBlank(merchantIdStr)) { | ||||
| String errMessage = "request params[merchant_id] error."; | |||||
| logger.error(errMessage); | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.MERCHANT_ID); | |||||
| } | } | ||||
| if (StringUtils.isBlank(buUserIdStr)) { | if (StringUtils.isBlank(buUserIdStr)) { | ||||
| String errMessage = "request params[bu_user_id] error."; | |||||
| logger.error(errMessage); | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.BUSER_ID); | |||||
| } | } | ||||
| if (StringUtils.isBlank(couponOrderIdStr)) { | if (StringUtils.isBlank(couponOrderIdStr)) { | ||||
| String errMessage = "request params[coupon_order_id] error."; | |||||
| logger.error(errMessage); | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.COUPON_ORDER_ID); | |||||
| } | } | ||||
| if (actionType.equals(EnumVerifyActionType.PRE_VERIFY) || actionType.equals(EnumVerifyActionType.VERIFY_INDEPENT)) { | if (actionType.equals(EnumVerifyActionType.PRE_VERIFY) || actionType.equals(EnumVerifyActionType.VERIFY_INDEPENT)) { | ||||
| if (StringUtils.isBlank(posOrderIdStr)) { | if (StringUtils.isBlank(posOrderIdStr)) { | ||||
| String errMessage = "request params[pos_order_id] error."; | |||||
| logger.error(errMessage); | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.POS_ORDER_ID); | |||||
| } | } | ||||
| } | } | ||||
| @@ -902,6 +817,10 @@ public class PosServiceImpl implements PosService { | |||||
| logger.error(ErrorCode.USER_IS_EMPTY.getMessage() + ": " + buUserIdStr); | logger.error(ErrorCode.USER_IS_EMPTY.getMessage() + ": " + buUserIdStr); | ||||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | throw new MallinkException(ErrorCode.USER_IS_EMPTY); | ||||
| } | } | ||||
| if (buUser.getMerchantId().equals(merchantId)) { | |||||
| logger.error(ErrorCode.VERIFY_BUSER_MERCHANT_NOT_BELONG.getMessage() + ": " + buUserId); | |||||
| throw new MallinkException(ErrorCode.VERIFY_BUSER_MERCHANT_NOT_BELONG); | |||||
| } | |||||
| // 4. check couponOrderId | // 4. check couponOrderId | ||||
| WxCouponOrderCVo couponOrderCVo = couponOrderService.detailCUserVo(couponOrderIdStr); | WxCouponOrderCVo couponOrderCVo = couponOrderService.detailCUserVo(couponOrderIdStr); | ||||
| if (couponOrderCVo == null) { | if (couponOrderCVo == null) { | ||||
| @@ -1078,7 +997,8 @@ public class PosServiceImpl implements PosService { | |||||
| * @param buUserId | * @param buUserId | ||||
| * @param posOrderId | * @param posOrderId | ||||
| */ | */ | ||||
| private void doVerify(EnumVerifyActionType actionType, WxCouponOrderCVo couponOrderCVo, WxCoupon coupon, Long merchantId, Long buUserId, Long posOrderId, Map<String, String> retMap) { | |||||
| private void doVerify(EnumVerifyActionType actionType, WxCouponOrderCVo couponOrderCVo, WxCoupon coupon, | |||||
| Long merchantId, Long buUserId, Long posOrderId, Map<String, String> retMap) { | |||||
| int num = 0; | int num = 0; | ||||
| // 1. insert posOrderId | // 1. insert posOrderId | ||||
| PosCouponOrderVerify posCouponOrderVerify = new PosCouponOrderVerify(); | PosCouponOrderVerify posCouponOrderVerify = new PosCouponOrderVerify(); | ||||
| @@ -1135,7 +1055,7 @@ public class PosServiceImpl implements PosService { | |||||
| try { | try { | ||||
| WxOrder order = orderMapper.selectByPrimaryKey(couponOrderCVo.getOrderId()); | WxOrder order = orderMapper.selectByPrimaryKey(couponOrderCVo.getOrderId()); | ||||
| int point = scoreRulesService.addScore2(EnumScoreType.CONSUMPTION, order, couponOrderCVo.getBusinessId()); | int point = scoreRulesService.addScore2(EnumScoreType.CONSUMPTION, order, couponOrderCVo.getBusinessId()); | ||||
| retMap.put("point", String.valueOf(point)); | |||||
| retMap.put(WxPayConstant.POINT, String.valueOf(point)); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error("核销成长值异常:" + e.getMessage()); | logger.error("核销成长值异常:" + e.getMessage()); | ||||
| } | } | ||||
| @@ -1157,7 +1077,7 @@ public class PosServiceImpl implements PosService { | |||||
| creditHistory.setMerchantId(merchantId); | creditHistory.setMerchantId(merchantId); | ||||
| creditHistory = creditHistoryService.saveOrUpdate(creditHistory); | creditHistory = creditHistoryService.saveOrUpdate(creditHistory); | ||||
| if (creditHistory.getCreditNum() != null) { | if (creditHistory.getCreditNum() != null) { | ||||
| retMap.put("credit", String.valueOf(creditHistory.getCreditNum())); | |||||
| retMap.put(WxPayConstant.CREDIT, String.valueOf(creditHistory.getCreditNum())); | |||||
| } | } | ||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| logger.error("核销积分值异常:" + e.getMessage()); | logger.error("核销积分值异常:" + e.getMessage()); | ||||
| @@ -1275,25 +1195,19 @@ public class PosServiceImpl implements PosService { | |||||
| throw new MallinkException(ErrorCode.POS_CONFIG_MEM_COUPON_DISABLE); | throw new MallinkException(ErrorCode.POS_CONFIG_MEM_COUPON_DISABLE); | ||||
| } | } | ||||
| if (StringUtils.isBlank(merchantIdStr)) { | if (StringUtils.isBlank(merchantIdStr)) { | ||||
| String errMessage = "request params[merchant_id] error."; | |||||
| logger.error(errMessage); | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.MERCHANT_ID); | |||||
| } | } | ||||
| if (StringUtils.isBlank(buUserIdStr)) { | if (StringUtils.isBlank(buUserIdStr)) { | ||||
| String errMessage = "request params[bu_user_id] error."; | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.BUSER_ID); | |||||
| } | } | ||||
| if (StringUtils.isBlank(posOrderIdStr)) { | if (StringUtils.isBlank(posOrderIdStr)) { | ||||
| String errMessage = "request params[pos_order_id] error."; | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.POS_ORDER_ID); | |||||
| } | } | ||||
| if (StringUtils.isBlank(posAmountStr)) { | if (StringUtils.isBlank(posAmountStr)) { | ||||
| String errMessage = "request params[pos_amount] error."; | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.POS_AMOUNT); | |||||
| } | } | ||||
| if (StringUtils.isBlank(cardIdStr)) { | if (StringUtils.isBlank(cardIdStr)) { | ||||
| String errMessage = "request params[card_id] error."; | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.CARD_ID); | |||||
| } | } | ||||
| Long merchantId, buUserId, posOrderId, cardId; | Long merchantId, buUserId, posOrderId, cardId; | ||||
| @@ -1393,9 +1307,7 @@ public class PosServiceImpl implements PosService { | |||||
| String cardSpendIdStr = params.get(WxPayConstant.CARD_SPEND_ID); // 消费卡花费ID | String cardSpendIdStr = params.get(WxPayConstant.CARD_SPEND_ID); // 消费卡花费ID | ||||
| if (StringUtils.isBlank(tenantId)) { | if (StringUtils.isBlank(tenantId)) { | ||||
| String errMessage = "request params[tenant_id] error."; | |||||
| logger.error(errMessage); | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.TENANT_ID); | |||||
| } | } | ||||
| PosMallConfig config = posMallConfigService.getByTenantId(tenantId); | PosMallConfig config = posMallConfigService.getByTenantId(tenantId); | ||||
| if (config == null) { | if (config == null) { | ||||
| @@ -1407,29 +1319,22 @@ public class PosServiceImpl implements PosService { | |||||
| throw new MallinkException(ErrorCode.POS_CONFIG_MEM_COUPON_DISABLE); | throw new MallinkException(ErrorCode.POS_CONFIG_MEM_COUPON_DISABLE); | ||||
| } | } | ||||
| if (StringUtils.isBlank(merchantIdStr)) { | if (StringUtils.isBlank(merchantIdStr)) { | ||||
| String errMessage = "request params[merchant_id] error."; | |||||
| logger.error(errMessage); | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.MERCHANT_ID); | |||||
| } | } | ||||
| if (StringUtils.isBlank(buUserIdStr)) { | if (StringUtils.isBlank(buUserIdStr)) { | ||||
| String errMessage = "request params[bu_user_id] error."; | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.BUSER_ID); | |||||
| } | } | ||||
| if (StringUtils.isBlank(posOrderIdStr)) { | if (StringUtils.isBlank(posOrderIdStr)) { | ||||
| String errMessage = "request params[pos_order_id] error."; | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.POS_ORDER_ID); | |||||
| } | } | ||||
| if (StringUtils.isBlank(posAmountStr)) { | if (StringUtils.isBlank(posAmountStr)) { | ||||
| String errMessage = "request params[pos_amount] error."; | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.POS_AMOUNT); | |||||
| } | } | ||||
| if (StringUtils.isBlank(cardIdStr)) { | if (StringUtils.isBlank(cardIdStr)) { | ||||
| String errMessage = "request params[card_id] error."; | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.CARD_ID); | |||||
| } | } | ||||
| if (StringUtils.isBlank(cardSpendIdStr)) { | if (StringUtils.isBlank(cardSpendIdStr)) { | ||||
| String errMessage = "request params[card_spend_id] error."; | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.CARD_SPEND_ID); | |||||
| } | } | ||||
| Long merchantId, buUserId, posOrderId, cardId, cardSpendId; | Long merchantId, buUserId, posOrderId, cardId, cardSpendId; | ||||
| @@ -1458,25 +1363,9 @@ public class PosServiceImpl implements PosService { | |||||
| throw new MallinkException(ErrorCode.COUPON_ORDER_MERANT_IS_NULL.getCode(), errMessage); | throw new MallinkException(ErrorCode.COUPON_ORDER_MERANT_IS_NULL.getCode(), errMessage); | ||||
| } | } | ||||
| // 2. check merchant | // 2. check merchant | ||||
| WxMerchant merchant = merchantService.getById(merchantId); | |||||
| if (merchant == null) { | |||||
| logger.error(ErrorCode.MERCHANT_INFO_NOT_FOUND.getMessage() + ": " + merchantIdStr); | |||||
| throw new MallinkException(ErrorCode.MERCHANT_INFO_NOT_FOUND); | |||||
| } | |||||
| if (merchant.getIsDel().equals(EnumDelStatus.DEL.getCode()) || merchant.getStatus().equals(EnumMerchantStatus.NOT_VALID.getCode())) { | |||||
| logger.error(ErrorCode.MERCHANT_INFO_NOT_VALID.getMessage() + ": " + merchantIdStr); | |||||
| throw new MallinkException(ErrorCode.MERCHANT_INFO_NOT_VALID); | |||||
| } | |||||
| WxMerchant merchant = checkAndGetMerchant(merchantId); | |||||
| // 3. check buUser | // 3. check buUser | ||||
| WxMerchantBUser buUser = merchantBUserService.getById(buUserId); | |||||
| if (buUser == null) { | |||||
| logger.error(ErrorCode.USER_IS_EMPTY.getMessage() + ": " + buUserIdStr); | |||||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | |||||
| } | |||||
| if (!buUser.getMerchantId().equals(merchantId)) { | |||||
| logger.error(ErrorCode.VERIFY_BUSER_MERCHANT_NOT_BELONG.getMessage() + ": " + buUserIdStr); | |||||
| throw new MallinkException(ErrorCode.VERIFY_BUSER_MERCHANT_NOT_BELONG); | |||||
| } | |||||
| WxMerchantBUser buUser = checkAndGetMerchantUser(buUserId, merchantId); | |||||
| WxCouponOrder couponOrder = couponOrderService.getById(cardId); | WxCouponOrder couponOrder = couponOrderService.getById(cardId); | ||||
| if(couponOrder == null) { | if(couponOrder == null) { | ||||
| @@ -1533,9 +1422,7 @@ public class PosServiceImpl implements PosService { | |||||
| String cardSpendIdStr = params.get(WxPayConstant.CARD_SPEND_ID); // 消费卡花费ID | String cardSpendIdStr = params.get(WxPayConstant.CARD_SPEND_ID); // 消费卡花费ID | ||||
| if (StringUtils.isBlank(tenantId)) { | if (StringUtils.isBlank(tenantId)) { | ||||
| String errMessage = "request params[tenant_id] error."; | |||||
| logger.error(errMessage); | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.TENANT_ID); | |||||
| } | } | ||||
| PosMallConfig config = posMallConfigService.getByTenantId(tenantId); | PosMallConfig config = posMallConfigService.getByTenantId(tenantId); | ||||
| if (config == null) { | if (config == null) { | ||||
| @@ -1547,29 +1434,22 @@ public class PosServiceImpl implements PosService { | |||||
| throw new MallinkException(ErrorCode.POS_CONFIG_MEM_COUPON_DISABLE); | throw new MallinkException(ErrorCode.POS_CONFIG_MEM_COUPON_DISABLE); | ||||
| } | } | ||||
| if (StringUtils.isBlank(merchantIdStr)) { | if (StringUtils.isBlank(merchantIdStr)) { | ||||
| String errMessage = "request params[merchant_id] error."; | |||||
| logger.error(errMessage); | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.MERCHANT_ID); | |||||
| } | } | ||||
| if (StringUtils.isBlank(buUserIdStr)) { | if (StringUtils.isBlank(buUserIdStr)) { | ||||
| String errMessage = "request params[bu_user_id] error."; | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.BUSER_ID); | |||||
| } | } | ||||
| if (StringUtils.isBlank(posOrderIdStr)) { | if (StringUtils.isBlank(posOrderIdStr)) { | ||||
| String errMessage = "request params[pos_order_id] error."; | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.POS_ORDER_ID); | |||||
| } | } | ||||
| if (StringUtils.isBlank(posAmountStr)) { | if (StringUtils.isBlank(posAmountStr)) { | ||||
| String errMessage = "request params[pos_amount] error."; | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.POS_AMOUNT); | |||||
| } | } | ||||
| if (StringUtils.isBlank(cardIdStr)) { | if (StringUtils.isBlank(cardIdStr)) { | ||||
| String errMessage = "request params[card_id] error."; | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.CARD_ID); | |||||
| } | } | ||||
| if (StringUtils.isBlank(cardSpendIdStr)) { | if (StringUtils.isBlank(cardSpendIdStr)) { | ||||
| String errMessage = "request params[card_spend_id] error."; | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| errParam(WxPayConstant.CARD_SPEND_ID); | |||||
| } | } | ||||
| Long merchantId, buUserId, posOrderId, cardId, cardSpendId; | Long merchantId, buUserId, posOrderId, cardId, cardSpendId; | ||||
| @@ -1608,15 +1488,7 @@ public class PosServiceImpl implements PosService { | |||||
| throw new MallinkException(ErrorCode.MERCHANT_INFO_NOT_VALID); | throw new MallinkException(ErrorCode.MERCHANT_INFO_NOT_VALID); | ||||
| } | } | ||||
| // 3. check buUser | // 3. check buUser | ||||
| WxMerchantBUser buUser = merchantBUserService.getById(buUserId); | |||||
| if (buUser == null) { | |||||
| logger.error(ErrorCode.USER_IS_EMPTY.getMessage() + ": " + buUserIdStr); | |||||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | |||||
| } | |||||
| if (!buUser.getMerchantId().equals(merchantId)) { | |||||
| logger.error(ErrorCode.VERIFY_BUSER_MERCHANT_NOT_BELONG.getMessage() + ": " + buUserIdStr); | |||||
| throw new MallinkException(ErrorCode.VERIFY_BUSER_MERCHANT_NOT_BELONG); | |||||
| } | |||||
| WxMerchantBUser buUser = checkAndGetMerchantUser(buUserId, merchantId); | |||||
| WxCouponOrder couponOrder = couponOrderService.getById(cardId); | WxCouponOrder couponOrder = couponOrderService.getById(cardId); | ||||
| if(couponOrder == null) { | if(couponOrder == null) { | ||||
| @@ -1652,4 +1524,197 @@ public class PosServiceImpl implements PosService { | |||||
| return retMap; | return retMap; | ||||
| } | } | ||||
| @Override | |||||
| @Transactional(rollbackFor = Exception.class) | |||||
| public Map<String, String> posOrderSync(Map<String, String> params) throws MallinkException { | |||||
| Map<String, String> retMap = new HashMap<>(); | |||||
| String tenantId = params.get(WxPayConstant.NEU_TENANT_ID); // 租户ID | |||||
| String merchantIdStr = params.get(WxPayConstant.NEU_MERCHANT_ID); // 商户ID | |||||
| String buUserIdStr = params.get(WxPayConstant.NEU_BU_USER_ID); // POS操作员ID | |||||
| String cuUserIdStr = params.get(WxPayConstant.NEU_MEM_ID); // 富茂系统会员ID | |||||
| String posOrderIdStr = params.get(WxPayConstant.NEU_ORDER_ID); // POS订单ID | |||||
| String posOrderTimeStr = params.get(WxPayConstant.NEU_ORDER_TIME); // POS订单时间 | |||||
| String posAmountStr = params.get(WxPayConstant.NEU_ORDER_AMOUNT); // POS订单总额 | |||||
| String posStatusStr = params.get(WxPayConstant.NEU_ORDER_STATUS); // 订单状态: 0有效,1取消,根据订单状态处理优惠券;有效:优惠券从预核销处理为核销; | |||||
| // 1. check params | |||||
| if (StringUtils.isBlank(tenantId)) { | |||||
| errParam(WxPayConstant.NEU_TENANT_ID); | |||||
| } | |||||
| PosMallConfig config = posMallConfigService.getByTenantId(tenantId); | |||||
| if (config == null) { | |||||
| logger.error(ErrorCode.POS_CONFIG_NOT_FOUND.getMessage()); | |||||
| throw new MallinkException(ErrorCode.POS_CONFIG_NOT_FOUND); | |||||
| } | |||||
| if (StringUtils.isBlank(merchantIdStr)) { | |||||
| errParam(WxPayConstant.NEU_MERCHANT_ID); | |||||
| } | |||||
| if (StringUtils.isBlank(buUserIdStr)) { | |||||
| errParam(WxPayConstant.NEU_BU_USER_ID); | |||||
| } | |||||
| if (StringUtils.isBlank(cuUserIdStr)) { | |||||
| errParam(WxPayConstant.NEU_MEM_ID); | |||||
| } | |||||
| if (StringUtils.isBlank(posOrderIdStr)) { | |||||
| errParam(WxPayConstant.NEU_ORDER_ID); | |||||
| } | |||||
| if (StringUtils.isBlank(posOrderTimeStr)) { | |||||
| errParam(WxPayConstant.NEU_ORDER_TIME); | |||||
| } | |||||
| if (StringUtils.isBlank(posAmountStr)) { | |||||
| errParam(WxPayConstant.NEU_ORDER_AMOUNT); | |||||
| } | |||||
| if (StringUtils.isBlank(posStatusStr)) { | |||||
| errParam(WxPayConstant.NEU_ORDER_STATUS); | |||||
| } | |||||
| Long merchantId, buUserId, posOrderId, cardId; | |||||
| Integer posAmount = 0; | |||||
| try { | |||||
| merchantId = Long.valueOf(merchantIdStr); | |||||
| buUserId = Long.valueOf(buUserIdStr); | |||||
| posOrderId = Long.valueOf(posOrderIdStr); | |||||
| posAmount = Integer.valueOf(posAmountStr); | |||||
| } catch (NumberFormatException e) { | |||||
| logger.error(e.getMessage()); | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_CAST_ERROR.getCode(), e.getMessage()); | |||||
| } | |||||
| // 2. check merchant | |||||
| WxMerchant merchant = checkAndGetMerchant(merchantId); | |||||
| // 3. check buUser | |||||
| WxMerchantBUser merchantBUser = checkAndGetMerchantUser(merchantId, buUserId); | |||||
| if (posStatusStr.equalsIgnoreCase("0")) { | |||||
| // TODO | |||||
| // add to wx_order | |||||
| String payDetail = params.get(WxPayConstant.NEU_PAY_DETAIL); | |||||
| JSONObject payDetailObj = JSON.parseObject(payDetail); | |||||
| JSONArray payDetailList = payDetailObj.getJSONArray(WxPayConstant.NEU_PAY_DETAIL_LIST); | |||||
| for (int i=0;i<payDetailList.size();i++) { | |||||
| JSONObject payOrderObj = payDetailList.getJSONObject(i); | |||||
| // ADD to wx_pay_order | |||||
| String neuPayOrderType = payOrderObj.getString(WxPayConstant.NEU_PAY_ORDER_TYPE); | |||||
| if (neuPayOrderType.equalsIgnoreCase(String.valueOf(EnumPosPamentType.MEM_DISCOUNT.getCode()))) { | |||||
| // 会员折扣 | |||||
| } else if (neuPayOrderType.equalsIgnoreCase(String.valueOf(EnumPosPamentType.MEM_COUPON.getCode()))) { | |||||
| // 优惠券, 交易核销 | |||||
| String couponOrderIdStr = payOrderObj.getString(WxPayConstant.NEU_PAY_ORDER_OUT_NO); | |||||
| } else if (neuPayOrderType.equalsIgnoreCase(String.valueOf(EnumPosPamentType.MEM_CARD.getCode()))) { | |||||
| // 预付卡, 不能退 | |||||
| } | |||||
| } | |||||
| } else if (posStatusStr.equalsIgnoreCase("1")) { | |||||
| // TODO | |||||
| // add to wx_order | |||||
| String refundDetail = params.get(WxPayConstant.NEU_REFUND_DETAIL); | |||||
| JSONObject refundDetailObj = JSON.parseObject(refundDetail); | |||||
| JSONArray refundDetailList = refundDetailObj.getJSONArray(WxPayConstant.NEU_REFUND_DETAIL_LIST); | |||||
| for (int i=0;i<refundDetailList.size();i++) { | |||||
| JSONObject refundOrderObj = refundDetailList.getJSONObject(i); | |||||
| // TODO | |||||
| // ADD to wx_pay_order | |||||
| String neuRefundOrderType = refundOrderObj.getString(WxPayConstant.NEU_REFUND_ORDER_TYPE); | |||||
| if (neuRefundOrderType.equalsIgnoreCase(String.valueOf(EnumPosRefundType.MEM_DISCOUNT.getCode()))) { | |||||
| // 会员折扣, | |||||
| } else if (neuRefundOrderType.equalsIgnoreCase(String.valueOf(EnumPosRefundType.MEM_COUPON.getCode()))) { | |||||
| // 优惠券, 退优惠券 | |||||
| } else if (neuRefundOrderType.equalsIgnoreCase(String.valueOf(EnumPosRefundType.MEM_CARD.getCode()))) { | |||||
| // 预付卡, 不能退 | |||||
| } else if (neuRefundOrderType.equalsIgnoreCase(String.valueOf(EnumPosRefundType.BOOK.getCode()))) { | |||||
| // 记账 | |||||
| } | |||||
| } | |||||
| } | |||||
| return retMap; | |||||
| } | |||||
| /** | |||||
| * 检查及获取商户信息 | |||||
| * @param merchantId | |||||
| * @return | |||||
| */ | |||||
| private WxMerchant checkAndGetMerchant(Long merchantId) { | |||||
| WxMerchant merchant = merchantService.getById(merchantId); | |||||
| if (merchant == null) { | |||||
| logger.error(ErrorCode.MERCHANT_INFO_NOT_FOUND.getMessage() + ": " + merchantId); | |||||
| throw new MallinkException(ErrorCode.MERCHANT_INFO_NOT_FOUND); | |||||
| } | |||||
| if (merchant.getIsDel().equals(EnumDelStatus.DEL.getCode()) || | |||||
| merchant.getStatus().equals(EnumMerchantStatus.NOT_VALID.getCode())) { | |||||
| logger.error(ErrorCode.MERCHANT_INFO_NOT_VALID.getMessage() + ": " + merchantId); | |||||
| throw new MallinkException(ErrorCode.MERCHANT_INFO_NOT_VALID); | |||||
| } | |||||
| return merchant; | |||||
| } | |||||
| /** | |||||
| * 检查及获取商户用户 | |||||
| * @param buUserId | |||||
| * @param merchantId | |||||
| */ | |||||
| private WxMerchantBUser checkAndGetMerchantUser(Long buUserId, Long merchantId) { | |||||
| WxMerchantBUser buUser = merchantBUserService.getById(buUserId); | |||||
| if (buUser == null) { | |||||
| logger.error(ErrorCode.USER_IS_EMPTY.getMessage() + ": " + buUserId); | |||||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | |||||
| } | |||||
| if (!buUser.getMerchantId().equals(merchantId)) { | |||||
| logger.error(ErrorCode.VERIFY_BUSER_MERCHANT_NOT_BELONG.getMessage() + ": " + buUserId); | |||||
| throw new MallinkException(ErrorCode.VERIFY_BUSER_MERCHANT_NOT_BELONG); | |||||
| } | |||||
| if (buUser.getStatus().equals(EnumMerchantStatus.NOT_VALID.getCode())) { | |||||
| logger.error(ErrorCode.MERCHANT_BUSER_NOT_VALID.getMessage() + ": " + buUserId); | |||||
| throw new MallinkException(ErrorCode.MERCHANT_BUSER_NOT_VALID); | |||||
| } | |||||
| return buUser; | |||||
| } | |||||
| /** | |||||
| * 输入参数错误 | |||||
| * @param paramStr | |||||
| * @throws MallinkException | |||||
| */ | |||||
| private void errParam(String paramStr) throws MallinkException { | |||||
| String errMessage = String.format("request params[%s] error.", paramStr); | |||||
| logger.error(errMessage); | |||||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), errMessage); | |||||
| } | |||||
| /** | |||||
| * POS订单添加 | |||||
| * @return | |||||
| * @throws MallinkException | |||||
| */ | |||||
| private WxOrder addToWxOrder(String tenantId, String merchantNo, String buUserNo, String memNo, String memPhone, | |||||
| String posOrderNo, String posOrderTimeStr, String posOrderAmount, String posOrderStatus) throws MallinkException { | |||||
| // 1. 根据posOrderNo查找 | |||||
| return null; | |||||
| } | |||||
| /** | |||||
| * POS支付订单 | |||||
| * @return | |||||
| * @throws MallinkException | |||||
| */ | |||||
| private WxPayOrder addToWxPayOrder(WxOrder orderRecord, | |||||
| String posPayOrderNo, String posPayOrderTime, | |||||
| String paymentType, String thirdParam, String payOrderNo, String payAmount, String payTime) throws MallinkException { | |||||
| return null; | |||||
| } | |||||
| /** | |||||
| * POS支付退款订单 | |||||
| * @return | |||||
| * @throws MallinkException | |||||
| */ | |||||
| private WxPayOrder addToWxRefundOrder(WxOrder orderRecord, | |||||
| String posPayOrderNo, String posRefundOrderNo, String posRefundOrderTime, | |||||
| String refundType, String thirdParam, String refundStatusStr, | |||||
| String refundOrderNo, String refundAmount, String refundTime) throws MallinkException { | |||||
| return null; | |||||
| } | |||||
| } | } | ||||
| @@ -98,6 +98,7 @@ public enum ErrorCode{ | |||||
| MERCHANT_REPORT_DATE_NOT_VALID(999, "上报日期大于当天"), | MERCHANT_REPORT_DATE_NOT_VALID(999, "上报日期大于当天"), | ||||
| MERCHANT_NAME_IS_FOUND(2014, "商户名称已存在"), | MERCHANT_NAME_IS_FOUND(2014, "商户名称已存在"), | ||||
| MERCHANT_CAR_NOT_DEL(2015, "停车商户不能被删除"), | MERCHANT_CAR_NOT_DEL(2015, "停车商户不能被删除"), | ||||
| MERCHANT_BUSER_NOT_VALID(2016, "商户用户不存在或已被禁用"), | |||||
| /** | /** | ||||
| * 券 | * 券 | ||||
| */ | */ | ||||
| @@ -30,6 +30,12 @@ public class BaseEntity implements Serializable { | |||||
| @Transient | @Transient | ||||
| private String sortColumns; | private String sortColumns; | ||||
| @Transient | |||||
| protected String floorForRule; | |||||
| @Transient | |||||
| protected String businessForRule; | |||||
| public String getSortColumns() { | public String getSortColumns() { | ||||
| if(StringUtils.isBlank(sortColumn)){ | if(StringUtils.isBlank(sortColumn)){ | ||||
| @@ -28,6 +28,9 @@ public class MallPermission extends BaseEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="父编号ID,一级菜单为0",name="parentId") | @io.swagger.annotations.ApiModelProperty(value="父编号ID,一级菜单为0",name="parentId") | ||||
| private Long parentId; | private Long parentId; | ||||
| @Transient | @Transient | ||||
| @io.swagger.annotations.ApiModelProperty(value="原父编号ID",name="origParentId") | |||||
| private Long origParentId; | |||||
| @Transient | |||||
| @io.swagger.annotations.ApiModelProperty(value="父菜单",name="parentName") | @io.swagger.annotations.ApiModelProperty(value="父菜单",name="parentName") | ||||
| private String parentName; | private String parentName; | ||||
| @io.swagger.annotations.ApiModelProperty(value="是否可用 Y/N",name="permission") | @io.swagger.annotations.ApiModelProperty(value="是否可用 Y/N",name="permission") | ||||
| @@ -18,7 +18,11 @@ public class MallRolePermission extends BaseEntity { | |||||
| protected Long id; | protected Long id; | ||||
| @Transient | @Transient | ||||
| protected List<String> ids; | |||||
| protected List<Long> ids; | |||||
| @Transient | |||||
| protected List<Long> permissionIds; | |||||
| @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | @io.swagger.annotations.ApiModelProperty(value="租户ID",name="tenantId") | ||||
| private String tenantId; | private String tenantId; | ||||
| @@ -0,0 +1,41 @@ | |||||
| package com.iformall.domain.po; | |||||
| import lombok.Data; | |||||
| import lombok.EqualsAndHashCode; | |||||
| import javax.persistence.Id; | |||||
| import javax.persistence.Table; | |||||
| import javax.persistence.Transient; | |||||
| import java.util.Date; | |||||
| import java.util.List; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| @Table(name = "wx_data_rule_target") | |||||
| @Data | |||||
| @EqualsAndHashCode(callSuper = true) | |||||
| public class WxDataRuleTarget extends BaseEntity { | |||||
| private static final long serialVersionUID = 1L; | |||||
| @Id | |||||
| protected Long id; | |||||
| @Transient | |||||
| protected List<String> ids; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "父级ID", name = "parent") | |||||
| private Long parent; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "用户ID", name = "name") | |||||
| private String name; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "标签", name = "tag") | |||||
| private String tag; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "创建时间", name = "createTime") | |||||
| private Date createTime; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "更新时间", name = "updateTime") | |||||
| private Date updateTime; | |||||
| @Transient | |||||
| private List<WxDataRuleTarget> children; | |||||
| } | |||||
| @@ -4,12 +4,10 @@ import cn.afterturn.easypoi.excel.annotation.Excel; | |||||
| import com.iformall.domain.vo.WxShopVo; | import com.iformall.domain.vo.WxShopVo; | ||||
| import com.iformall.enums.EnumBusiness; | import com.iformall.enums.EnumBusiness; | ||||
| import com.iformall.enums.EnumSubBusiness; | import com.iformall.enums.EnumSubBusiness; | ||||
| import io.swagger.annotations.ApiImplicitParam; | |||||
| import io.swagger.annotations.ApiModelProperty; | import io.swagger.annotations.ApiModelProperty; | ||||
| import lombok.Data; | import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | import lombok.EqualsAndHashCode; | ||||
| import lombok.ToString; | import lombok.ToString; | ||||
| import org.apache.commons.collections.ListUtils; | |||||
| import javax.persistence.Id; | import javax.persistence.Id; | ||||
| import javax.persistence.Table; | import javax.persistence.Table; | ||||
| @@ -237,4 +235,5 @@ public class WxMerchant extends BaseEntity { | |||||
| return ""; | return ""; | ||||
| return "t:md:" + id; | return "t:md:" + id; | ||||
| } | } | ||||
| } | } | ||||
| @@ -0,0 +1,41 @@ | |||||
| package com.iformall.domain.po; | |||||
| import lombok.Data; | |||||
| import lombok.EqualsAndHashCode; | |||||
| import javax.persistence.Id; | |||||
| import javax.persistence.Table; | |||||
| import javax.persistence.Transient; | |||||
| import java.util.Date; | |||||
| import java.util.List; | |||||
| @Table(name = "wx_user_data_rule") | |||||
| @Data | |||||
| @EqualsAndHashCode(callSuper = true) | |||||
| public class WxUserDataRule extends BaseEntity { | |||||
| private static final long serialVersionUID = 1L; | |||||
| @Id | |||||
| protected Long id; | |||||
| @Transient | |||||
| protected List<String> ids; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "用户ID", name = "userId") | |||||
| private Long userId; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "租户ID", name = "tenantId") | |||||
| private String tenantId; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "权限类型", name = "type") | |||||
| private Integer type; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "楼层楼座", name = "buildingFloor") | |||||
| private String buildingFloor; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "业态", name = "business") | |||||
| private String business; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "数据范围", name = "target") | |||||
| private String target; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "创建时间", name = "createTime") | |||||
| private Date createTime; | |||||
| @io.swagger.annotations.ApiModelProperty(value = "更新时间", name = "updateTime") | |||||
| private Date updateTime; | |||||
| } | |||||
| @@ -0,0 +1,41 @@ | |||||
| package com.iformall.enums; | |||||
| /** | |||||
| * Created by Stormeye on 2018/08/09. | |||||
| */ | |||||
| public enum EnumPosPamentType { | |||||
| // 来源于Neusoft的定义 0微信;1支付宝;2现金;3会员折扣;4优惠券;5预付卡;6银行卡 | |||||
| WECHAT(0, "微信"), | |||||
| ALIPAY(1, "支付宝"), | |||||
| CASH(2, "现金"), | |||||
| MEM_DISCOUNT(3, "会员折扣"), | |||||
| MEM_COUPON(4, "优惠券"), | |||||
| MEM_CARD(5, "预付卡"), | |||||
| MEM_BANKCARD(6, "银行卡"), | |||||
| ; | |||||
| public static EnumPosPamentType getEnum(Integer code) { | |||||
| for (EnumPosPamentType value : values()) { | |||||
| if (value.getCode().equals(code)) { | |||||
| return value; | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| private Integer code; | |||||
| private String message; | |||||
| EnumPosPamentType(Integer code, String message) { | |||||
| this.code = code; | |||||
| this.message = message; | |||||
| } | |||||
| public Integer getCode() { | |||||
| return code; | |||||
| } | |||||
| public String getMessage() { | |||||
| return message; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,42 @@ | |||||
| package com.iformall.enums; | |||||
| /** | |||||
| * Created by Stormeye on 2018/08/09. | |||||
| */ | |||||
| public enum EnumPosRefundType { | |||||
| // 来源于Neusoft的定义 0微信;1支付宝;2现金;3会员折扣;4优惠券;5预付卡;6银行卡;7记账 | |||||
| WECHAT(0, "微信"), | |||||
| ALIPAY(1, "支付宝"), | |||||
| CASH(2, "现金"), | |||||
| MEM_DISCOUNT(3, "会员折扣"), | |||||
| MEM_COUPON(4, "优惠券"), | |||||
| MEM_CARD(5, "预付卡"), | |||||
| MEM_BANKCARD(6, "银行卡"), | |||||
| BOOK(7, "记账"), | |||||
| ; | |||||
| public static EnumPosRefundType getEnum(Integer code) { | |||||
| for (EnumPosRefundType value : values()) { | |||||
| if (value.getCode().equals(code)) { | |||||
| return value; | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| private Integer code; | |||||
| private String message; | |||||
| EnumPosRefundType(Integer code, String message) { | |||||
| this.code = code; | |||||
| this.message = message; | |||||
| } | |||||
| public Integer getCode() { | |||||
| return code; | |||||
| } | |||||
| public String getMessage() { | |||||
| return message; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,36 @@ | |||||
| package com.iformall.enums; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| public enum EnumUserDataRuleType { | |||||
| ALL(1, "系统全部数据"), | |||||
| FLOOR_BUSINESS(2, "楼层及业态数据"),; | |||||
| public static EnumUserDataRuleType getEnum(Integer code) { | |||||
| for (EnumUserDataRuleType value : values()) { | |||||
| if (value.getCode().equals(code)) { | |||||
| return value; | |||||
| } | |||||
| } | |||||
| return null; | |||||
| } | |||||
| private Integer code; | |||||
| private String message; | |||||
| EnumUserDataRuleType(Integer code, String message) { | |||||
| this.code = code; | |||||
| this.message = message; | |||||
| } | |||||
| public Integer getCode() { | |||||
| return code; | |||||
| } | |||||
| public String getMessage() { | |||||
| return message; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,98 @@ | |||||
| package com.iformall.mapper; | |||||
| import com.iformall.domain.po.MallPermission; | |||||
| import com.iformall.domain.po.MallRolePermission; | |||||
| import com.iformall.domain.po.MallSaleType; | |||||
| import org.apache.ibatis.annotations.DeleteProvider; | |||||
| import org.apache.ibatis.annotations.Mapper; | |||||
| import org.apache.ibatis.annotations.SelectProvider; | |||||
| import org.apache.ibatis.annotations.UpdateProvider; | |||||
| import java.util.List; | |||||
| @Mapper | |||||
| public interface MallMenuMapper { | |||||
| @UpdateProvider(type = MallPermissionDaoProvider.class, method = "updateMallPermission") | |||||
| public void updateMallPermission(MallPermission mallPermission); | |||||
| @UpdateProvider(type = MallPermissionDaoProvider.class, method = "updatePermissionByParentId") | |||||
| public void updatePermissionByParentId(MallPermission mallPermission); | |||||
| @DeleteProvider(type = MallPermissionDaoProvider.class, method = "deletePermissionRole") | |||||
| public void deletePermissionRole(MallRolePermission mallRolePermission); | |||||
| @UpdateProvider(type = MallPermissionDaoProvider.class, method = "updateMallSaleType") | |||||
| public void updateMallSaleType(MallSaleType mallSaleType); | |||||
| @SelectProvider(type = MallPermissionDaoProvider.class, method = "getMallRolePermissions") | |||||
| public List<MallRolePermission> getMallRolePermissions(MallRolePermission mallRolePermission); | |||||
| class MallPermissionDaoProvider { | |||||
| public String updateMallPermission(MallPermission mallPermission) { | |||||
| String sql = "UPDATE mall_permission "; | |||||
| if (mallPermission.getName() != null) { | |||||
| sql += " SET `name` = #{name}"; | |||||
| } | |||||
| if (mallPermission.getId() != null) { | |||||
| sql += " where id = #{id}"; | |||||
| } | |||||
| return sql; | |||||
| } | |||||
| public String updatePermissionByParentId(MallPermission mallPermission) { | |||||
| StringBuilder sb = new StringBuilder(); | |||||
| sb.append("UPDATE mall_permission "); | |||||
| if (mallPermission.getParentId() != null) { | |||||
| sb.append(" SET `parent_id` = #{parentId} "); | |||||
| } | |||||
| if (mallPermission.getOrigParentId() != null) { | |||||
| sb.append(" WHERE `parent_id` = #{origParentId}"); | |||||
| } | |||||
| if (mallPermission.getIds() != null) { | |||||
| List ids = mallPermission.getIds(); | |||||
| sb.append(" WHERE `id` in ("); | |||||
| for(int i=0;i<ids.size();i++) { | |||||
| sb.append(ids.get(i)); | |||||
| if (i < ids.size() - 1) { | |||||
| sb.append(","); | |||||
| } | |||||
| } | |||||
| sb.append(")"); | |||||
| } | |||||
| return sb.toString(); | |||||
| } | |||||
| public String updateMallSaleType(MallSaleType mallSaleType) { | |||||
| String sql = "UPDATE mall_sale_type "; | |||||
| if (mallSaleType.getMenus() != null) { | |||||
| sql += " SET `menus` = #{menus}"; | |||||
| } | |||||
| if (mallSaleType.getId() != null) { | |||||
| sql += " where id = #{id}"; | |||||
| } | |||||
| return sql; | |||||
| } | |||||
| public String deletePermissionRole(MallRolePermission mallRolePermission) { | |||||
| String sql = "DELETE FROM mall_role_permission "; | |||||
| if (mallRolePermission.getPermissionId() != null) { | |||||
| sql += " WHERE `permission_id` = #{permissionId}"; | |||||
| } | |||||
| return sql; | |||||
| } | |||||
| public String getMallRolePermissions(MallRolePermission mallRolePermission) { | |||||
| StringBuilder sb = new StringBuilder(); | |||||
| sb.append("SELECT * FROM mall_role_permission "); | |||||
| if (mallRolePermission.getIds() != null) { | |||||
| List ids = mallRolePermission.getIds(); | |||||
| sb.append(" WHERE `permission_id` in ("); | |||||
| for(int i=0;i<ids.size();i++) { | |||||
| sb.append(ids.get(i)); | |||||
| if (i < ids.size() - 1) { | |||||
| sb.append(","); | |||||
| } | |||||
| } | |||||
| sb.append(")"); | |||||
| } | |||||
| return sb.toString(); | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,16 @@ | |||||
| package com.iformall.mapper; | |||||
| import com.iformall.common.CommonMapper; | |||||
| import com.iformall.domain.po.WxDataRuleTarget; | |||||
| import java.util.List; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| public interface WxDataRuleTargetMapper extends CommonMapper<WxDataRuleTarget, Long> { | |||||
| List<WxDataRuleTarget> findList(WxDataRuleTarget param); | |||||
| } | |||||
| @@ -0,0 +1,16 @@ | |||||
| package com.iformall.mapper; | |||||
| import com.iformall.common.CommonMapper; | |||||
| import com.iformall.domain.po.WxUserDataRule; | |||||
| import java.util.List; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| public interface WxUserDataRuleMapper extends CommonMapper<WxUserDataRule, Long> { | |||||
| List<WxUserDataRule> findList(WxUserDataRule param); | |||||
| } | |||||
| @@ -66,6 +66,9 @@ public class WxPayConstant { | |||||
| public final static String REMAIN_AMOUNT = "remain_amount"; | public final static String REMAIN_AMOUNT = "remain_amount"; | ||||
| public final static String ORDER_STATUS = "order_status"; | public final static String ORDER_STATUS = "order_status"; | ||||
| public final static String POINT = "point"; | |||||
| public final static String CREDIT = "credit"; | |||||
| public final static String REAL_AMOUNT = "real_amount"; | public final static String REAL_AMOUNT = "real_amount"; | ||||
| public final static String SALE_PRICE = "sale_price"; | public final static String SALE_PRICE = "sale_price"; | ||||
| public final static String SALE_FEE = "sale_fee"; | public final static String SALE_FEE = "sale_fee"; | ||||
| @@ -78,4 +81,38 @@ public class WxPayConstant { | |||||
| public final static String TRUE = "true"; | public final static String TRUE = "true"; | ||||
| public final static String FALSE = "false"; | public final static String FALSE = "false"; | ||||
| public final static String NEU_TENANT_ID = "TenantID"; // 富茂系统商场ID | |||||
| public final static String NEU_MERCHANT_ID = "MerchantID"; // 富茂系统商户ID | |||||
| public final static String NEU_BU_USER_ID = "OrderOperatorID"; // 富茂系统登录操作员ID | |||||
| public final static String NEU_MEM_ID = "MemberID"; // 富茂系统会员ID | |||||
| public final static String NEU_MEM_PHONE = "MemberPhoneNumber"; // 富茂系统会员手机号 | |||||
| public final static String NEU_ORDER_ID = "OrderNumberofPlatform"; // 东软平台订单号 | |||||
| public final static String NEU_ORDER_TIME = "OrderTimeOfPlatform"; // 平台订单创建时间, 格式:4位年2位月2位日2位24小时制时2位分2位秒3位毫秒 | |||||
| public final static String NEU_ORDER_AMOUNT = "OrderAmount"; // 订单价格 | |||||
| public final static String NEU_ORDER_CREATE_SN = "OrderCreateSN"; // 创建订单的POS SN号 | |||||
| public final static String NEU_ORDER_STATUS = "OrderStatus"; // 必要,订单状态: 0有效,1取消,根据订单状态处理优惠券;有效:优惠券从预核销处理为核销; | |||||
| public final static String NEU_PAY_DETAIL = "PaymentDetail"; | |||||
| public final static String NEU_PAY_DETAIL_LIST = "PaymentDetailList"; | |||||
| public final static String NEU_PAY_ORDER_ID = "PaymentNumberOfPlatform"; // 东软平台支付订单号 | |||||
| public final static String NEU_PAY_ORDER_TIME = "PaymentOrderTime"; // 东软平台支付订单创建时间 | |||||
| public final static String NEU_PAY_ORDER_TYPE = "PaymentType"; // 支付方式: 0微信;1支付宝;2现金;3会员折扣;4优惠券;5预付卡;6银行卡 | |||||
| public final static String NEU_PAY_ORDER_TYPE_DESC = "PaymentTypeDescription"; // 支付方式描述:微信或支付宝或现金或会员折扣或优惠券或预付卡或银行卡 | |||||
| public final static String NEU_PAY_ORDER_PARAM = "PaymentThirdPartyString"; // 第三方使用数据,JSON存储,包含富茂所需的系统要素 | |||||
| public final static String NEU_PAY_ORDER_STATUS = "PaymentStatus"; // 支付状态:0非手动同步, 1手动同步 | |||||
| public final static String NEU_PAY_ORDER_OUT_NO = "OuterPaymentNumber"; // 第三方(微信、支付宝、富茂预付卡)支付订单流水号,富茂优惠券ID,现金和富茂会员折扣时为空 | |||||
| public final static String NEU_PAY_ORDER_AMOUNT = "PaymentAmount"; // 支付金额 | |||||
| public final static String NEU_PAY_ORDER_OUT_TIME = "PayTime"; // 第三方支付系统返回的支付时间,现金和富茂会员折扣时为空 | |||||
| public final static String NEU_REFUND_DETAIL = "RefundDetail"; | |||||
| public final static String NEU_REFUND_DETAIL_LIST = "RefundDetailList"; | |||||
| public final static String NEU_REFUND_ORDER_ID = "RefundNumberOfPlatform"; // 东软平台退款订单号 | |||||
| public final static String NEU_REFUND_ORDER_TIME = "RefundOrderTime"; // 东软平台退款订单创建时间 | |||||
| public final static String NEU_REFUND_ORDER_TYPE = "RefundType"; // 退款方式: 0微信;1支付宝;2现金;3会员折扣;4优惠券;5预付卡;6银行卡;7记账; | |||||
| // 退款方式可以与支付方式不同,但只能是记账,作为线下手动操作退款方式 | |||||
| public final static String NEU_REFUND_ORDER_TYPE_DESC = "RefundTypeDescription"; // 退款方式描述:微信或支付宝或现金或会员折扣或优惠券或预付卡或银行卡或记账 | |||||
| public final static String NEU_REFUND_ORDER_PARAM = "RefundThirdPartyString"; // 第三方使用数据,JSON存储,包含富茂所需的系统要素 | |||||
| public final static String NEU_REFUND_ORDER_STATUS = "RefundStatus"; // 退款状态:0非手动, 1手动退款, 2手动释放同步 | |||||
| public final static String NEU_REFUND_ORDER_OUT_NO = "OuterRefundNumber"; // 第三方(微信、支付宝、富茂预付卡)支付订单流水号,富茂优惠券ID,现金和富茂会员折扣时为空 | |||||
| public final static String NEU_REFUND_ORDER_AMOUNT = "RefundAmount"; // 退款金额 | |||||
| public final static String NEU_REFUND_ORDER_OUT_TIME = "RefundTime"; // 第三方支付系统返回的支付时间,现金和富茂会员折扣时为空 | |||||
| } | } | ||||
| @@ -0,0 +1,34 @@ | |||||
| package com.iformall.service; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.WxDataRuleTarget; | |||||
| import java.util.List; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| public interface WxDataRuleTargetService { | |||||
| /** | |||||
| * 根据实体查询分页列表 | |||||
| * | |||||
| * @param record | |||||
| * @param pageIndex | |||||
| * @param pageSize | |||||
| * @return | |||||
| */ | |||||
| PageInfo<WxDataRuleTarget> listAsPage(WxDataRuleTarget record, Integer pageIndex, Integer pageSize); | |||||
| /** | |||||
| * 根据实体查询列表 | |||||
| * | |||||
| * @param record | |||||
| * @return | |||||
| */ | |||||
| List<WxDataRuleTarget> findList(WxDataRuleTarget record); | |||||
| List<WxDataRuleTarget> getList(); | |||||
| } | |||||
| @@ -0,0 +1,14 @@ | |||||
| package com.iformall.service; | |||||
| import com.iformall.domain.po.WxUserDataRule; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| public interface WxUserDataRuleService { | |||||
| void modify(WxUserDataRule wxUserDataRule); | |||||
| WxUserDataRule findByUserId(Long userId); | |||||
| } | |||||
| @@ -0,0 +1,48 @@ | |||||
| package com.iformall.service.impl; | |||||
| import com.github.pagehelper.PageInfo; | |||||
| import com.iformall.domain.po.WxDataRuleTarget; | |||||
| import com.iformall.mapper.WxDataRuleTargetMapper; | |||||
| import com.iformall.service.WxDataRuleTargetService; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | |||||
| import java.util.List; | |||||
| import java.util.stream.Collectors; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| @Service | |||||
| public class WxDataRuleTargetServiceImpl implements WxDataRuleTargetService { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxDataRuleTargetMapper wxDataRuleTargetMapper; | |||||
| @Override | |||||
| public PageInfo<WxDataRuleTarget> listAsPage(WxDataRuleTarget record, Integer pageIndex, Integer pageSize) { | |||||
| return null; | |||||
| } | |||||
| @Override | |||||
| public List<WxDataRuleTarget> findList(WxDataRuleTarget record) { | |||||
| return null; | |||||
| } | |||||
| @Override | |||||
| public List<WxDataRuleTarget> getList() { | |||||
| List<WxDataRuleTarget> wxDataRuleTargets = wxDataRuleTargetMapper.selectAll(); | |||||
| List<WxDataRuleTarget> targets = wxDataRuleTargets.stream() | |||||
| .filter(t -> t.getParent().equals(0L)).collect(Collectors.toList()); | |||||
| for (WxDataRuleTarget parentTarget : targets) { | |||||
| List<WxDataRuleTarget> children = wxDataRuleTargets.stream() | |||||
| .filter(t -> t.getParent().equals(parentTarget.getId())).collect(Collectors.toList()); | |||||
| parentTarget.setChildren(children); | |||||
| } | |||||
| return targets; | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,51 @@ | |||||
| package com.iformall.service.impl; | |||||
| import com.iformall.common.IdWorker; | |||||
| import com.iformall.domain.po.WxUserDataRule; | |||||
| import com.iformall.enums.EnumUserDataRuleType; | |||||
| import com.iformall.mapper.WxUserDataRuleMapper; | |||||
| import com.iformall.service.WxUserDataRuleService; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.stereotype.Service; | |||||
| import java.util.Date; | |||||
| /** | |||||
| * @author gongbiao | |||||
| */ | |||||
| @Service | |||||
| public class WxUserDataRuleServiceImpl implements WxUserDataRuleService { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private WxUserDataRuleMapper wxUserDataRuleMapper; | |||||
| @Override | |||||
| public void modify(WxUserDataRule record) { | |||||
| Date date = new Date(); | |||||
| if (record.getId() == null) { | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| record.setId(idWorker.nextId()); | |||||
| record.setCreateTime(date); | |||||
| record.setUpdateTime(date); | |||||
| wxUserDataRuleMapper.insertSelective(record); | |||||
| } else { | |||||
| if (EnumUserDataRuleType.ALL.getCode().equals(record.getType())) { | |||||
| wxUserDataRuleMapper.deleteByPrimaryKey(record.getId()); | |||||
| } else { | |||||
| record.setUpdateTime(date); | |||||
| wxUserDataRuleMapper.updateByPrimaryKeySelective(record); | |||||
| } | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public WxUserDataRule findByUserId(Long userId) { | |||||
| WxUserDataRule wxUserDataRule = new WxUserDataRule(); | |||||
| wxUserDataRule.setUserId(userId); | |||||
| return wxUserDataRuleMapper.selectOne(wxUserDataRule); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,53 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||||
| <mapper namespace="com.iformall.mapper.WxDataRuleTargetMapper"> | |||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxDataRuleTarget"> | |||||
| <id column="id" jdbcType="BIGINT" property="id"/> | |||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | |||||
| <result column="parent" jdbcType="BIGINT" property="parent"/> | |||||
| <result column="name" jdbcType="VARCHAR" property="name"/> | |||||
| <result column="tag" jdbcType="VARCHAR" property="tag"/> | |||||
| <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/> | |||||
| <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| `id`,`parent`,`name`,`tag`,`create_time`,`update_time` | |||||
| </sql> | |||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| </if> | |||||
| <if test=" null != tenantId "> | |||||
| and `tenant_id` = #{tenantId} | |||||
| </if> | |||||
| <if test=" null != parent "> | |||||
| and `parent` = #{parent} | |||||
| </if> | |||||
| <if test=" null != name "> | |||||
| and `name` like concat('%',#{name},'%') | |||||
| </if> | |||||
| <if test=" null != ids "> | |||||
| and id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | |||||
| </sql> | |||||
| <select id="findList" parameterType="com.iformall.domain.po.WxDataRuleTarget" resultMap="BaseResultMap"> | |||||
| select | |||||
| <include refid="allColumns"/> | |||||
| from wx_data_rule_target | |||||
| <include refid="dynamicWhereConditions"/> | |||||
| </select> | |||||
| </mapper> | |||||
| @@ -232,6 +232,21 @@ | |||||
| #{idItem} | #{idItem} | ||||
| </foreach> | </foreach> | ||||
| </if> | </if> | ||||
| <if test="(null != floorForRule and '' != floorForRule) or (null != businessForRule and '' != businessForRule)"> | |||||
| and m.id in( | |||||
| select ms.merchant_id from (select merchant_id,shop_id from wx_merchant_shop where is_del=0) ms | |||||
| inner join wx_merchant m on ms.merchant_id = m.id | |||||
| inner join wx_shop s on s.id=ms.shop_id | |||||
| where m.tenant_id=#{tenantId} and s.is_del=0 | |||||
| <if test=" null != businessForRule "> | |||||
| and m.business_id in (${businessForRule}) | |||||
| </if> | |||||
| <if test=" null != floorForRule "> | |||||
| and s.`floor` in (${floorForRule}) | |||||
| </if> | |||||
| ) | |||||
| </if> | |||||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | <if test=" null != sortColumns">order by ${sortColumns}</if> | ||||
| </sql> | </sql> | ||||
| @@ -63,6 +63,7 @@ | |||||
| #{idItem} | #{idItem} | ||||
| </foreach> | </foreach> | ||||
| </if> | </if> | ||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | <if test=" null != sortColumns"> order by ${sortColumns} </if> | ||||
| <if test=" null == sortColumns"> order by report_date desc </if> | <if test=" null == sortColumns"> order by report_date desc </if> | ||||
| </sql> | </sql> | ||||
| @@ -142,7 +143,22 @@ | |||||
| and mtd.report_date >= date_format(#{startTime},'%Y-%m-%d') | and mtd.report_date >= date_format(#{startTime},'%Y-%m-%d') | ||||
| and mtd.report_date <= date_format(#{endTime},'%Y-%m-%d') | and mtd.report_date <= date_format(#{endTime},'%Y-%m-%d') | ||||
| </if> | </if> | ||||
| <if test="(null != floorForRule and '' != floorForRule) or (null != businessForRule and '' != businessForRule)"> | |||||
| and mtd.merchant_id in( | |||||
| select ms.merchant_id from (select merchant_id,shop_id from wx_merchant_shop where is_del=0) ms | |||||
| inner join wx_merchant m on ms.merchant_id = m.id | |||||
| inner join wx_shop s on s.id=ms.shop_id | |||||
| where m.tenant_id=#{tenantId} and s.is_del=0 | |||||
| <if test=" null != businessForRule "> | |||||
| and m.business_id in (${businessForRule}) | |||||
| </if> | |||||
| <if test=" null != floorForRule "> | |||||
| and s.`floor` in (${floorForRule}) | |||||
| </if> | |||||
| ) | |||||
| </if> | |||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | <if test=" null != sortColumns"> order by ${sortColumns} </if> | ||||
| </select> | </select> | ||||
| @@ -143,6 +143,20 @@ | |||||
| <if test=" null != building and ''!= building">and b.id = #{building}</if> | <if test=" null != building and ''!= building">and b.id = #{building}</if> | ||||
| <if test=" null != floor and ''!= floor">and f.id = #{floor}</if> | <if test=" null != floor and ''!= floor">and f.id = #{floor}</if> | ||||
| <if test=" null != operationType ">and `operation_type` = #{operationType}</if> | <if test=" null != operationType ">and `operation_type` = #{operationType}</if> | ||||
| <if test="(null != floorForRule and '' != floorForRule) or (null != businessForRule and '' != businessForRule)"> | |||||
| and rc.merchant_id in( | |||||
| select ms.merchant_id from (select merchant_id,shop_id from wx_merchant_shop where is_del=0) ms | |||||
| inner join wx_merchant m on ms.merchant_id = m.id | |||||
| inner join wx_shop s on s.id=ms.shop_id | |||||
| where m.tenant_id=#{tenantId} and s.is_del=0 | |||||
| <if test=" null != businessForRule "> | |||||
| and m.business_id in (${businessForRule}) | |||||
| </if> | |||||
| <if test=" null != floorForRule "> | |||||
| and s.`floor` in (${floorForRule}) | |||||
| </if> | |||||
| ) | |||||
| </if> | |||||
| </where> | </where> | ||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | <if test=" null != sortColumns"> order by ${sortColumns} </if> | ||||
| @@ -171,6 +171,20 @@ | |||||
| <if test=" null != building and ''!= building">and b.id = #{building}</if> | <if test=" null != building and ''!= building">and b.id = #{building}</if> | ||||
| <if test=" null != floor and ''!= floor">and f.id = #{floor}</if> | <if test=" null != floor and ''!= floor">and f.id = #{floor}</if> | ||||
| <if test=" null != operationType ">and `operation_type` = #{operationType}</if> | <if test=" null != operationType ">and `operation_type` = #{operationType}</if> | ||||
| <if test="(null != floorForRule and '' != floorForRule) or (null != businessForRule and '' != businessForRule)"> | |||||
| and rc.merchant_id in( | |||||
| select ms.merchant_id from (select merchant_id,shop_id from wx_merchant_shop where is_del=0) ms | |||||
| inner join wx_merchant m on ms.merchant_id = m.id | |||||
| inner join wx_shop s on s.id=ms.shop_id | |||||
| where m.tenant_id=#{tenantId} and s.is_del=0 | |||||
| <if test=" null != businessForRule "> | |||||
| and m.business_id in (${businessForRule}) | |||||
| </if> | |||||
| <if test=" null != floorForRule "> | |||||
| and s.`floor` in (${floorForRule}) | |||||
| </if> | |||||
| ) | |||||
| </if> | |||||
| </where> | </where> | ||||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | <if test=" null != sortColumns"> order by ${sortColumns} </if> | ||||
| <if test=" null == sortColumns"> order by rc.createtime desc,rc.id desc </if> | <if test=" null == sortColumns"> order by rc.createtime desc,rc.id desc </if> | ||||
| @@ -0,0 +1,55 @@ | |||||
| <?xml version="1.0" encoding="UTF-8"?> | |||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||||
| <mapper namespace="com.iformall.mapper.WxUserDataRuleMapper"> | |||||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxUserDataRule"> | |||||
| <id column="id" jdbcType="BIGINT" property="id"/> | |||||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | |||||
| <result column="user_id" jdbcType="BIGINT" property="userId"/> | |||||
| <result column="type" jdbcType="INTEGER" property="type"/> | |||||
| <result column="buildingFloor" jdbcType="VARCHAR" property="buildingFloor"/> | |||||
| <result column="business" jdbcType="VARCHAR" property="business"/> | |||||
| <result column="target" jdbcType="VARCHAR" property="target"/> | |||||
| <result column="create_time" jdbcType="TIMESTAMP" property="createTime"/> | |||||
| <result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/> | |||||
| </resultMap> | |||||
| <sql id="allColumns"> | |||||
| `id`,`tenant_id`,`user_id`,`type`,`business`,`target`,`create_time`,`update_time` | |||||
| </sql> | |||||
| <sql id="dynamicWhereConditions"> | |||||
| where 1 = 1 | |||||
| <if test=" null != id "> | |||||
| and `id` = #{id} | |||||
| </if> | |||||
| <if test=" null != tenantId "> | |||||
| and `tenant_id` = #{tenantId} | |||||
| </if> | |||||
| <if test=" null != userId "> | |||||
| and `user_id` = #{userId} | |||||
| </if> | |||||
| <if test=" null != type "> | |||||
| and `type` = #{type} | |||||
| </if> | |||||
| <if test=" null != ids "> | |||||
| and id in | |||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||||
| #{idItem} | |||||
| </foreach> | |||||
| </if> | |||||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | |||||
| </sql> | |||||
| <select id="findList" parameterType="com.iformall.domain.po.WxUserDataRule" resultMap="BaseResultMap"> | |||||
| select | |||||
| <include refid="allColumns"/> | |||||
| from wx_user_data_rule | |||||
| <include refid="dynamicWhereConditions"/> | |||||
| </select> | |||||
| </mapper> | |||||
| @@ -5,13 +5,12 @@ import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.controller.base.BaseController; | import com.iformall.controller.base.BaseController; | ||||
| import com.iformall.domain.po.MallPermission; | |||||
| import com.iformall.domain.po.MallRole; | |||||
| import com.iformall.domain.po.MallRolePermission; | |||||
| import com.iformall.domain.po.MallUserInfo; | |||||
| import com.iformall.domain.po.*; | |||||
| import com.iformall.enums.EnumMenuType; | import com.iformall.enums.EnumMenuType; | ||||
| import com.iformall.enums.EnumPermissionType; | import com.iformall.enums.EnumPermissionType; | ||||
| import com.iformall.exception.MallinkException; | import com.iformall.exception.MallinkException; | ||||
| import com.iformall.mapper.MallMenuMapper; | |||||
| import com.iformall.mapper.MallPermissionMapper; | |||||
| import com.iformall.service.MallPermissionService; | import com.iformall.service.MallPermissionService; | ||||
| import com.iformall.service.MallRolePermissionService; | import com.iformall.service.MallRolePermissionService; | ||||
| import com.iformall.service.MallRoleService; | import com.iformall.service.MallRoleService; | ||||
| @@ -57,6 +56,12 @@ public class SysMenuController extends BaseController { | |||||
| @Autowired | @Autowired | ||||
| private MallRolePermissionService mallRolePermissionService; | private MallRolePermissionService mallRolePermissionService; | ||||
| @Autowired | |||||
| private MallMenuMapper mallMenuMapper; | |||||
| @Autowired | |||||
| private MallPermissionMapper mallPermissionMapper; | |||||
| @ApiOperation("导航菜单") | @ApiOperation("导航菜单") | ||||
| @GetMapping("/nav") | @GetMapping("/nav") | ||||
| public ResultData nav(){ | public ResultData nav(){ | ||||
| @@ -205,6 +210,384 @@ public class SysMenuController extends BaseController { | |||||
| return new ResultData(ErrorCode.USER_NO_PERMISSION); | return new ResultData(ErrorCode.USER_NO_PERMISSION); | ||||
| } | } | ||||
| @ApiOperation("用户菜单迁移") | |||||
| @GetMapping("/moveMenus") | |||||
| public ResultData moveMenus() { | |||||
| logger.debug("[" + getIpAddr() + "] MallPermissionController::moveMenus"); | |||||
| MallUserInfo userInfo = getUser(); | |||||
| if(userInfo.isFmSuperAdmin()) { | |||||
| // 1. 账号->系统 | |||||
| moveAccountToSys(); | |||||
| // 2. 合同添加商铺+多经点位 | |||||
| addMenusForContract(); | |||||
| // 3. 账单 | |||||
| addMenusForBills(); | |||||
| return new ResultData(); | |||||
| } | |||||
| return new ResultData(ErrorCode.USER_NO_PERMISSION); | |||||
| } | |||||
| private void moveAccountToSys() { | |||||
| Long menuId_XiTong = 50L; | |||||
| Long menuId_Account = 7L; | |||||
| // 1. 修改菜单名 | |||||
| mallMenuMapper.updateMallPermission(new MallPermission() {{ | |||||
| setName("系统设置"); | |||||
| setId(menuId_XiTong); | |||||
| }}); | |||||
| // 2. 迁移->系统设置 | |||||
| MallPermission accountPermission = mallPermissionService.getById(menuId_Account); | |||||
| mallMenuMapper.updatePermissionByParentId(new MallPermission() {{ | |||||
| setParentId(menuId_XiTong); | |||||
| setOrigParentId(menuId_Account); | |||||
| }}); | |||||
| // 3. 角色是否选中系统设置 | |||||
| List<MallRolePermission> mallRolePermissions = mallRolePermissionService.getList(new MallRolePermission(){{ | |||||
| setPermissionId(menuId_Account); | |||||
| }}); | |||||
| for(MallRolePermission mallRolePermission: mallRolePermissions) { | |||||
| List<MallRolePermission> mallRolePermissionList = mallRolePermissionService.getList(new MallRolePermission(){{ | |||||
| setTenantId(mallRolePermission.getTenantId()); | |||||
| setRoleId(mallRolePermission.getRoleId()); | |||||
| setPermissionId(menuId_XiTong); | |||||
| }}); | |||||
| if (mallRolePermissionList.size() <= 0) { | |||||
| // update 7L->50L | |||||
| try { | |||||
| mallRolePermissionService.saveOrUpdate(new MallRolePermission(){{ | |||||
| setTenantId(mallRolePermission.getTenantId()); | |||||
| setId(mallRolePermission.getId()); | |||||
| setPermissionId(menuId_XiTong); | |||||
| setRoleId(mallRolePermission.getRoleId()); | |||||
| }}); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| } | |||||
| } | |||||
| // 4. 删除permission/role | |||||
| mallMenuMapper.deletePermissionRole(new MallRolePermission(){{ | |||||
| setPermissionId(menuId_Account); | |||||
| }}); | |||||
| // 5. 删除permission | |||||
| mallPermissionService.deleteById(menuId_Account); | |||||
| // 6. sale_type | |||||
| mallMenuMapper.updateMallSaleType(new MallSaleType(){{ | |||||
| setId(1L); | |||||
| setMenus( | |||||
| "[1,2,3,4,5,6,8,9,10,50,101,102,103,104,105,106,107,108,201,202,203,204,205,206,211,212,221,222,251,301,302,303,304,305,306,401,402,403,404,405,406,407,408,409,410,411,412,413,414,501,502,503,504,505,506,507,508,509,511,512,513,521,522,523,531,532,533,591,595,601,602,603,604,605,606,607,608,609,610,611,612,621,622,623,624,625,626,627,641,642,643,644,645,651,661,662,663,671,672,673,674,681,682,683,684,685,691,692,693,694,695,701,702,711,712,713,901,902,903,931,932,951,952,961,962,965,966,967,968]" | |||||
| ); | |||||
| }}); | |||||
| mallMenuMapper.updateMallSaleType(new MallSaleType(){{ | |||||
| setId(2L); | |||||
| setMenus( | |||||
| "[1,2,3,4,5,6,8,9,10,50,101,102,103,104,105,106,107,108,201,202,203,204,205,206,211,212,221,222,251,301,302,303,304,305,306,401,402,403,404,405,406,407,408,409,410,411,412,413,414,501,502,503,504,505,506,507,508,509,511,512,513,521,522,523,531,532,533,591,595,601,602,603,604,605,606,607,608,609,610,611,612,621,622,623,624,625,626,627,641,642,643,644,645,651,661,662,663,671,672,673,674,681,682,683,684,685,691,692,693,694,695,701,702,711,712,713,901,902,903,931,932,951,952,961,962,965,966,967,968]" | |||||
| ); | |||||
| }}); | |||||
| mallMenuMapper.updateMallSaleType(new MallSaleType(){{ | |||||
| setId(3L); | |||||
| setMenus( | |||||
| "[2,4,5,6,10,50,201,202,205,211,212,221,222,251,409,410,411,501,502,503,504,505,506,507,508,511,512,513,521,522,523,531,532,533,591,592,601,602,603,604,605,606,607,608,609,610,611,612,621,622,623,624,625,626,641,642,643,644,645,651,661,662,663,671,672,673,674,681,682,683,684,685,691,692,693,694,695,701,702,711,712,713,901,902,903,931,932]" | |||||
| ); | |||||
| }}); | |||||
| } | |||||
| private void addMenusForContract() { | |||||
| Long menuId_Shop = 299L; | |||||
| Long menuId_Duojing = 300L; | |||||
| // 1. add new folder | |||||
| try { | |||||
| mallPermissionMapper.insertSelective(new MallPermission() {{ | |||||
| setId(menuId_Shop); | |||||
| setName("店铺"); | |||||
| setParentId(3L); | |||||
| setAvailable("Y"); | |||||
| setResourceType(0); | |||||
| setIcon("icon-iconshangpuguanli"); | |||||
| setVersionType(0); | |||||
| setSort(menuId_Shop.intValue()); | |||||
| }}); | |||||
| mallPermissionMapper.insertSelective(new MallPermission() {{ | |||||
| setId(menuId_Duojing); | |||||
| setName("多经点位"); | |||||
| setParentId(3L); | |||||
| setAvailable("Y"); | |||||
| setResourceType(0); | |||||
| setIcon("icon-shanghuguanli"); | |||||
| setVersionType(0); | |||||
| setSort(menuId_Duojing.intValue()); | |||||
| }}); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| // 2. move | |||||
| // 301, 302, 305 | |||||
| mallMenuMapper.updatePermissionByParentId(new MallPermission() {{ | |||||
| List<Long> list = new ArrayList<Long>(); | |||||
| list.add(301L); | |||||
| list.add(302L); | |||||
| list.add(305L); | |||||
| setParentId(menuId_Shop); | |||||
| setIds(list); | |||||
| }}); | |||||
| // 303, 304, 306 | |||||
| mallMenuMapper.updatePermissionByParentId(new MallPermission() {{ | |||||
| List<Long> list = new ArrayList<Long>(); | |||||
| list.add(303L); | |||||
| list.add(304L); | |||||
| list.add(306L); | |||||
| setParentId(menuId_Duojing); | |||||
| setIds(list); | |||||
| }}); | |||||
| mallMenuMapper.updateMallPermission(new MallPermission() {{ | |||||
| setName("租金合同"); | |||||
| setId(301L); | |||||
| }}); | |||||
| mallMenuMapper.updateMallPermission(new MallPermission() {{ | |||||
| setName("物业合同"); | |||||
| setId(302L); | |||||
| }}); | |||||
| mallMenuMapper.updateMallPermission(new MallPermission() {{ | |||||
| setName("租金+物业合同"); | |||||
| setId(305L); | |||||
| }}); | |||||
| mallMenuMapper.updateMallPermission(new MallPermission() {{ | |||||
| setName("租金合同"); | |||||
| setId(303L); | |||||
| }}); | |||||
| mallMenuMapper.updateMallPermission(new MallPermission() {{ | |||||
| setName("物业合同"); | |||||
| setId(304L); | |||||
| }}); | |||||
| mallMenuMapper.updateMallPermission(new MallPermission() {{ | |||||
| setName("租金+物业合同"); | |||||
| setId(306L); | |||||
| }}); | |||||
| // 3. 角色是否选中商铺 | |||||
| List<MallRolePermission> mallRolePermissions = mallMenuMapper.getMallRolePermissions(new MallRolePermission(){{ | |||||
| List<Long> list = new ArrayList<Long>(); | |||||
| list.add(301L); | |||||
| list.add(302L); | |||||
| list.add(305L); | |||||
| setPermissionIds(list); | |||||
| }}); | |||||
| for(MallRolePermission mallRolePermission: mallRolePermissions) { | |||||
| List<MallRolePermission> mallRolePermissionList = mallRolePermissionService.getList(new MallRolePermission(){{ | |||||
| setTenantId(mallRolePermission.getTenantId()); | |||||
| setRoleId(mallRolePermission.getRoleId()); | |||||
| setPermissionId(menuId_Shop); | |||||
| }}); | |||||
| if (mallRolePermissionList.size() <= 0) { | |||||
| try { | |||||
| mallRolePermissionService.saveOrUpdate(new MallRolePermission(){{ | |||||
| setTenantId(mallRolePermission.getTenantId()); | |||||
| setPermissionId(menuId_Shop); | |||||
| setRoleId(mallRolePermission.getRoleId()); | |||||
| }}); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| } | |||||
| } | |||||
| // 4. 角色是否选中多经点位 | |||||
| mallRolePermissions = mallRolePermissionService.getList(new MallRolePermission(){{ | |||||
| List<Long> list = new ArrayList<Long>(); | |||||
| list.add(303L); | |||||
| list.add(304L); | |||||
| list.add(306L); | |||||
| setPermissionIds(list); | |||||
| }}); | |||||
| for(MallRolePermission mallRolePermission: mallRolePermissions) { | |||||
| List<MallRolePermission> mallRolePermissionList = mallRolePermissionService.getList(new MallRolePermission(){{ | |||||
| setTenantId(mallRolePermission.getTenantId()); | |||||
| setRoleId(mallRolePermission.getRoleId()); | |||||
| setPermissionId(menuId_Duojing); | |||||
| }}); | |||||
| if (mallRolePermissionList.size() <= 0) { | |||||
| try { | |||||
| mallRolePermissionService.saveOrUpdate(new MallRolePermission(){{ | |||||
| setTenantId(mallRolePermission.getTenantId()); | |||||
| setPermissionId(menuId_Duojing); | |||||
| setRoleId(mallRolePermission.getRoleId()); | |||||
| }}); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| } | |||||
| } | |||||
| // 5. sale_type | |||||
| mallMenuMapper.updateMallSaleType(new MallSaleType(){{ | |||||
| setId(1L); | |||||
| setMenus( | |||||
| "[1,2,3,4,5,6,8,9,10,50,101,102,103,104,105,106,107,108,201,202,203,204,205,206,211,212,221,222,251,299,300,301,302,303,304,305,306,401,402,403,404,405,406,407,408,409,410,411,412,413,414,501,502,503,504,505,506,507,508,509,511,512,513,521,522,523,531,532,533,591,595,601,602,603,604,605,606,607,608,609,610,611,612,621,622,623,624,625,626,627,641,642,643,644,645,651,661,662,663,671,672,673,674,681,682,683,684,685,691,692,693,694,695,701,702,711,712,713,901,902,903,931,932,951,952,961,962,965,966,967,968]" | |||||
| ); | |||||
| }}); | |||||
| mallMenuMapper.updateMallSaleType(new MallSaleType(){{ | |||||
| setId(2L); | |||||
| setMenus( | |||||
| "[1,2,3,4,5,6,8,9,10,50,101,102,103,104,105,106,107,108,201,202,203,204,205,206,211,212,221,222,251,299,300,301,302,303,304,305,306,401,402,403,404,405,406,407,408,409,410,411,412,413,414,501,502,503,504,505,506,507,508,509,511,512,513,521,522,523,531,532,533,591,595,601,602,603,604,605,606,607,608,609,610,611,612,621,622,623,624,625,626,627,641,642,643,644,645,651,661,662,663,671,672,673,674,681,682,683,684,685,691,692,693,694,695,701,702,711,712,713,901,902,903,931,932,951,952,961,962,965,966,967,968]" | |||||
| ); | |||||
| }}); | |||||
| mallMenuMapper.updateMallSaleType(new MallSaleType(){{ | |||||
| setId(3L); | |||||
| setMenus( | |||||
| "[2,4,5,6,10,50,201,202,205,211,212,221,222,251,409,410,411,501,502,503,504,505,506,507,508,511,512,513,521,522,523,531,532,533,591,592,601,602,603,604,605,606,607,608,609,610,611,612,621,622,623,624,625,626,641,642,643,644,645,651,661,662,663,671,672,673,674,681,682,683,684,685,691,692,693,694,695,701,702,711,712,713,901,902,903,931,932]" | |||||
| ); | |||||
| }}); | |||||
| } | |||||
| private void addMenusForBills() { | |||||
| // 1. 账单列表隐藏 | |||||
| mallPermissionService.saveOrUpdate(new MallPermission(){{ | |||||
| setId(412L); | |||||
| setAvailable("N"); | |||||
| }}); | |||||
| addNewMunuFolder_ZhangdanList(); | |||||
| addNewMenuFolder_Duizhang(); | |||||
| // 8. sale_type | |||||
| mallMenuMapper.updateMallSaleType(new MallSaleType(){{ | |||||
| setId(1L); | |||||
| setMenus( | |||||
| "[1,2,3,4,5,6,8,9,10,50,101,102,103,104,105,106,107,108,201,202,203,204,205,206,211,212,221,222,251,299,300,301,302,303,304,305,306,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,501,502,503,504,505,506,507,508,509,511,512,513,521,522,523,531,532,533,591,595,601,602,603,604,605,606,607,608,609,610,611,612,621,622,623,624,625,626,627,641,642,643,644,645,651,661,662,663,671,672,673,674,681,682,683,684,685,691,692,693,694,695,701,702,711,712,713,901,902,903,931,932,951,952,961,962,965,966,967,968]" | |||||
| ); | |||||
| }}); | |||||
| mallMenuMapper.updateMallSaleType(new MallSaleType(){{ | |||||
| setId(2L); | |||||
| setMenus( | |||||
| "[1,2,3,4,5,6,8,9,10,50,101,102,103,104,105,106,107,108,201,202,203,204,205,206,211,212,221,222,251,299,300,301,302,303,304,305,306,401,402,403,404,405,406,407,408,409,410,411,412,413,414,415,416,501,502,503,504,505,506,507,508,509,511,512,513,521,522,523,531,532,533,591,595,601,602,603,604,605,606,607,608,609,610,611,612,621,622,623,624,625,626,627,641,642,643,644,645,651,661,662,663,671,672,673,674,681,682,683,684,685,691,692,693,694,695,701,702,711,712,713,901,902,903,931,932,951,952,961,962,965,966,967,968]" | |||||
| ); | |||||
| }}); | |||||
| mallMenuMapper.updateMallSaleType(new MallSaleType(){{ | |||||
| setId(3L); | |||||
| setMenus( | |||||
| "[2,4,5,6,10,50,201,202,205,211,212,221,222,251,409,410,411,416,501,502,503,504,505,506,507,508,511,512,513,521,522,523,531,532,533,591,592,601,602,603,604,605,606,607,608,609,610,611,612,621,622,623,624,625,626,641,642,643,644,645,651,661,662,663,671,672,673,674,681,682,683,684,685,691,692,693,694,695,701,702,711,712,713,901,902,903,931,932]" | |||||
| ); | |||||
| }}); | |||||
| } | |||||
| private void addNewMunuFolder_ZhangdanList() { | |||||
| // 1. 新增新的账单列表folder | |||||
| Long menuId_Zhangdanliebiao = 415L; | |||||
| try { | |||||
| mallPermissionMapper.insertSelective(new MallPermission() {{ | |||||
| setId(menuId_Zhangdanliebiao); | |||||
| setName("账单列表"); | |||||
| setParentId(4L); | |||||
| setAvailable("Y"); | |||||
| setResourceType(0); | |||||
| setIcon("icon-zhangdan5"); | |||||
| setVersionType(0); | |||||
| setSort(menuId_Zhangdanliebiao.intValue()); | |||||
| }}); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| // 2. 迁移到账单列表下 | |||||
| mallMenuMapper.updatePermissionByParentId(new MallPermission() {{ | |||||
| List<Long> list = new ArrayList<Long>(); | |||||
| list.add(402L); | |||||
| list.add(403L); | |||||
| list.add(404L); | |||||
| list.add(405L); | |||||
| list.add(406L); | |||||
| list.add(407L); | |||||
| list.add(408L); | |||||
| setParentId(menuId_Zhangdanliebiao); | |||||
| setIds(list); | |||||
| }}); | |||||
| // 3. 角色是否选中账单列表 | |||||
| List<MallRolePermission> mallRolePermissions = mallMenuMapper.getMallRolePermissions(new MallRolePermission(){{ | |||||
| List<Long> list = new ArrayList<Long>(); | |||||
| list.add(402L); | |||||
| list.add(403L); | |||||
| list.add(404L); | |||||
| list.add(405L); | |||||
| list.add(406L); | |||||
| list.add(407L); | |||||
| list.add(408L); | |||||
| setPermissionIds(list); | |||||
| }}); | |||||
| for(MallRolePermission mallRolePermission: mallRolePermissions) { | |||||
| List<MallRolePermission> mallRolePermissionList = mallRolePermissionService.getList(new MallRolePermission(){{ | |||||
| setTenantId(mallRolePermission.getTenantId()); | |||||
| setRoleId(mallRolePermission.getRoleId()); | |||||
| setPermissionId(menuId_Zhangdanliebiao); | |||||
| }}); | |||||
| if (mallRolePermissionList.size() <= 0) { | |||||
| try { | |||||
| mallRolePermissionService.saveOrUpdate(new MallRolePermission(){{ | |||||
| setTenantId(mallRolePermission.getTenantId()); | |||||
| setPermissionId(menuId_Zhangdanliebiao); | |||||
| setRoleId(mallRolePermission.getRoleId()); | |||||
| }}); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| private void addNewMenuFolder_Duizhang() { | |||||
| // 1. 新增对账管理 | |||||
| Long menuId_ZhangdanMan = 416L; | |||||
| try { | |||||
| mallPermissionMapper.insertSelective(new MallPermission() {{ | |||||
| setId(menuId_ZhangdanMan); | |||||
| setName("对账管理"); | |||||
| setParentId(4L); | |||||
| setAvailable("Y"); | |||||
| setResourceType(0); | |||||
| setIcon("icon-zhangdan11"); | |||||
| setVersionType(0); | |||||
| setSort(menuId_ZhangdanMan.intValue()); | |||||
| }}); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| // 2. 迁移到对账管理下 | |||||
| mallMenuMapper.updatePermissionByParentId(new MallPermission() {{ | |||||
| List<Long> list = new ArrayList<Long>(); | |||||
| list.add(409L); | |||||
| list.add(410L); | |||||
| list.add(411L); | |||||
| setParentId(menuId_ZhangdanMan); | |||||
| setIds(list); | |||||
| }}); | |||||
| // 3. 角色是否选中对账管理 | |||||
| List<MallRolePermission> mallRolePermissions = mallMenuMapper.getMallRolePermissions(new MallRolePermission(){{ | |||||
| List<Long> list = new ArrayList<Long>(); | |||||
| list.add(409L); | |||||
| list.add(410L); | |||||
| list.add(411L); | |||||
| setPermissionIds(list); | |||||
| }}); | |||||
| for(MallRolePermission mallRolePermission: mallRolePermissions) { | |||||
| List<MallRolePermission> mallRolePermissionList = mallRolePermissionService.getList(new MallRolePermission(){{ | |||||
| setTenantId(mallRolePermission.getTenantId()); | |||||
| setRoleId(mallRolePermission.getRoleId()); | |||||
| setPermissionId(menuId_ZhangdanMan); | |||||
| }}); | |||||
| if (mallRolePermissionList.size() <= 0) { | |||||
| try { | |||||
| mallRolePermissionService.saveOrUpdate(new MallRolePermission(){{ | |||||
| setTenantId(mallRolePermission.getTenantId()); | |||||
| setPermissionId(menuId_ZhangdanMan); | |||||
| setRoleId(mallRolePermission.getRoleId()); | |||||
| }}); | |||||
| } catch (Exception e) { | |||||
| logger.error(e.getMessage()); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| @Autowired | @Autowired | ||||
| private RequestMappingHandlerMapping requestMappingHandlerMapping; | private RequestMappingHandlerMapping requestMappingHandlerMapping; | ||||