| @@ -1,11 +1,16 @@ | |||
| package com.iformall.controller.sys; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.WxBusiness; | |||
| import com.iformall.domain.po.WxCoupon; | |||
| import com.iformall.domain.vo.WxBusinessDataVo; | |||
| import com.iformall.enums.EnumCouponContentType; | |||
| import com.iformall.enums.EnumCouponSourceType; | |||
| import com.iformall.enums.EnumRentContractAppStatus; | |||
| import com.iformall.enums.EnumYesOrNo; | |||
| import com.iformall.service.ExcelService; | |||
| import com.iformall.service.WxBusinessService; | |||
| @@ -57,6 +62,53 @@ public class WxBusinessController extends BaseController { | |||
| final List<WxBusiness> busList = wxBusinessService.findList(bq); | |||
| return new ResultData(busList); | |||
| } | |||
| @ApiOperation("业态树接口") | |||
| @GetMapping("treeList") | |||
| public ResultData treeList() { | |||
| final List<WxBusiness> busList = wxBusinessService.findTreeList(getTenantInfo()); | |||
| return new ResultData(busList); | |||
| } | |||
| @ApiOperation("新增/修改接口") | |||
| @PostMapping("saveOrUpdate") | |||
| public ResultData saveOrUpdate(@RequestBody WxBusiness wxBusiness) { | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| wxBusiness.setFinalTenantId(tenantEntity.getFinalTenantId()); | |||
| if (null != wxBusiness.getId()) { | |||
| //不能修改系统默认的 | |||
| WxBusiness b = wxBusinessService.getById(wxBusiness.getId(), wxBusiness.getFinalTenantId()); | |||
| if (null == b) { | |||
| return new ResultData(Result.ERROR,"未查询到业态"); | |||
| } | |||
| if (b.getIsSystem().intValue() == EnumYesOrNo.YES.getCode().intValue()) { | |||
| return new ResultData(Result.ERROR,"不能修改系统默认业态"); | |||
| } | |||
| } | |||
| wxBusinessService.saveOrUpdate(wxBusiness); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("删除接口") | |||
| @PostMapping("del") | |||
| public ResultData delete(@RequestBody WxBusiness wxBusiness) { | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| wxBusiness.setFinalTenantId(tenantEntity.getFinalTenantId()); | |||
| if (null == wxBusiness.getId()) { | |||
| return new ResultData(Result.ERROR,"参数错误"); | |||
| } | |||
| //不能修改系统默认的 | |||
| WxBusiness b = wxBusinessService.getById(wxBusiness.getId(), wxBusiness.getFinalTenantId()); | |||
| if (null == b) { | |||
| return new ResultData(Result.ERROR,"未查询到业态"); | |||
| } | |||
| if (b.getIsSystem().intValue() == EnumYesOrNo.YES.getCode().intValue()) { | |||
| return new ResultData(Result.ERROR,"不能修改系统默认业态"); | |||
| } | |||
| b.setIsDel(EnumYesOrNo.YES.getCode()); | |||
| wxBusinessService.saveOrUpdate(b); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("业态分析接口") | |||
| @GetMapping("businessDataList") | |||
| @@ -4,6 +4,7 @@ import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.vo.WxCUserVo; | |||
| import com.iformall.domain.vo.WxCouponOrderCVo; | |||
| import com.iformall.domain.vo.WxLevelMerchantCVo; | |||
| import com.iformall.enums.EnumCreditLockedStatus; | |||
| import com.iformall.enums.EnumLevelConfigDiscountStatus; | |||
| @@ -11,6 +12,8 @@ import com.iformall.service.WxCUserBasicInfoService; | |||
| import com.iformall.service.WxCUserService; | |||
| import com.iformall.service.WxLevelConfigService; | |||
| import com.iformall.service.WxMerchantService; | |||
| import com.iformall.utils.DateUtils; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| @@ -22,6 +25,7 @@ import org.springframework.web.bind.annotation.RequestBody; | |||
| import org.springframework.web.bind.annotation.RequestMapping; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| @@ -56,6 +60,17 @@ public class WxMemController extends BaseController { | |||
| logger.error("memCode不能为空"); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "memCode不能为空"); | |||
| } | |||
| String _memberId = WxCouponOrderCVo.getDecodeExpiredCouponOrderId(memCode); | |||
| if (_memberId.contains(WxCouponOrderCVo.arg)) { | |||
| String[] decodeids = _memberId.split(WxCouponOrderCVo.arg); | |||
| memCode = decodeids[0]; | |||
| String expiredtimeStr = decodeids[1]; | |||
| Date expiredtime = DateUtils.string2Date(expiredtimeStr).getTime(); | |||
| if (expiredtime.before(new Date())) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"码已失效,请更新二维码后重试"); | |||
| } | |||
| } | |||
| Long id = null; | |||
| try { | |||
| @@ -6,11 +6,13 @@ import com.iformall.annotation.RedisCache; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.vo.WxCouponOrderCVo; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.*; | |||
| import com.iformall.service.order.OrderFactory; | |||
| import com.iformall.service.order.entity.WxComposeOrder; | |||
| import com.iformall.utils.DateUtils; | |||
| import com.iformall.utils.IPUtil; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| @@ -24,6 +26,7 @@ import org.springframework.web.bind.annotation.*; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import java.math.BigDecimal; | |||
| import java.util.Date; | |||
| import java.util.HashMap; | |||
| import java.util.Map; | |||
| @@ -335,6 +338,17 @@ public class WxMicroPayController extends BaseController { | |||
| // 获取C用户 | |||
| WxCUserBasicInfo cUser = null; | |||
| if (StringUtils.isNotBlank(cUserIdStr)) { | |||
| String _memberId = WxCouponOrderCVo.getDecodeExpiredCouponOrderId(cUserIdStr); | |||
| if (_memberId.contains(WxCouponOrderCVo.arg)) { | |||
| String[] decodeids = _memberId.split(WxCouponOrderCVo.arg); | |||
| cUserIdStr = decodeids[0]; | |||
| String expiredtimeStr = decodeids[1]; | |||
| Date expiredtime = DateUtils.string2Date(expiredtimeStr).getTime(); | |||
| if (expiredtime.before(new Date())) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(),"码已失效,请更新二维码后重试"); | |||
| } | |||
| } | |||
| Long cUserId = 0L; | |||
| try { | |||
| cUserId = Long.valueOf(cUserIdStr); | |||
| @@ -9,9 +9,11 @@ import com.iformall.annotation.TenantIgnore; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.common.SysConfigConstant; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.vo.WxCUserVo; | |||
| import com.iformall.domain.vo.WxCouponOrderCVo; | |||
| import com.iformall.domain.vo.WxLevelMerchantCVo; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| @@ -92,6 +94,9 @@ public class WxUserGrantController extends BaseController { | |||
| @Autowired | |||
| private QrCodeService qrCodeService; | |||
| @Autowired | |||
| SysConfigService sysConfigService; | |||
| /** | |||
| @@ -772,9 +777,16 @@ public class WxUserGrantController extends BaseController { | |||
| levelMerchant.updateTenantInfo(getTenantInfo()); | |||
| levelMerchant.setLevelId(levelId); | |||
| List<WxLevelMerchantCVo> levelMerchantList = wxLevelConfigService.findListCVo(levelMerchant); | |||
| SysConfig sysConfig = sysConfigService.getByKey(SysConfigConstant.member_seconds_key, getTenantInfo()); | |||
| if (null == sysConfig || StringUtils.isBlank(sysConfig.getConfigItemValue())) { | |||
| return new ResultData(ErrorCode.SYS_CONFIG_MEMBER_SECODES_UNSET); | |||
| } | |||
| Map<String, Object> result = new HashMap(); | |||
| result.put("id", member.getId()); | |||
| result.put("dynamicId", WxCouponOrderCVo.calcuteExpiredCouponOrderId(String.valueOf(member.getId()),Integer.parseInt(sysConfig.getConfigItemValue()),null)); | |||
| result.put("expiredSeconds", Integer.parseInt(sysConfig.getConfigItemValue())); | |||
| result.put("level", level); | |||
| result.put("levelMerchantList", levelMerchantList); | |||
| return new ResultData(result); | |||
| @@ -37,7 +37,7 @@ public enum ErrorCode{ | |||
| SYS_CONFIG_VIERFY_SECODES_UNSET(1030,"系统设置【券码刷新时间】未配置"), | |||
| SYS_CONFIG_CARD_VIERFY_SECODES_UNSET(1030,"系统设置【电子卡码刷新时间】未配置"), | |||
| SYS_CONFIG_DEFAULT_MERCHANT_B_USER_UNSET(1031,"系统配置【外部设备核销默认商户员工编号】未配置"), | |||
| SYS_CONFIG_MEMBER_SECODES_UNSET(1030,"系统设置【会员码刷新时间】未配置"), | |||
| /** | |||
| * 菜单 | |||
| */ | |||
| @@ -7,5 +7,6 @@ public class SysConfigConstant { | |||
| public static final String default_merchant_b_user = "defaultMerchantBUserId"; | |||
| public static final String coupon_detail_show_selled = "couponDetailShowSelled"; | |||
| public static final String coupon_list_show_selled = "couponListShowSelled"; | |||
| public static final String member_seconds_key="memberSeconds"; | |||
| } | |||
| @@ -8,6 +8,7 @@ import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| @TableName(value = "wx_business") | |||
| @Data | |||
| @@ -49,4 +50,7 @@ public class WxBusiness extends TenantEntityWithoutFinalTenantId { | |||
| @TableField(exist = false) | |||
| private Integer isRoot; | |||
| @TableField(exist = false) | |||
| private List<WxBusiness> children; | |||
| } | |||
| @@ -31,6 +31,7 @@ public interface WxBusinessService { | |||
| * @return | |||
| */ | |||
| List<WxBusiness> findList(WxBusiness record); | |||
| List<WxBusiness> findTreeList(TenantEntity tenantEntity); | |||
| /** | |||
| * 查询全部列表 | |||
| @@ -54,6 +55,6 @@ public interface WxBusinessService { | |||
| ResultData devoteList(WxBusiness wxBusiness,Integer pageNum, Integer pageSize); | |||
| void saveOrUpdate(WxBusiness record); | |||
| } | |||
| @@ -3,6 +3,7 @@ package com.iformall.service.impl; | |||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.WxBusiness; | |||
| @@ -25,6 +26,7 @@ import java.math.BigDecimal; | |||
| import java.math.RoundingMode; | |||
| import java.util.ArrayList; | |||
| import java.util.Collection; | |||
| import java.util.Date; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| @@ -228,4 +230,68 @@ public class WxBusinessServiceImpl implements WxBusinessService { | |||
| return map; | |||
| } | |||
| @Override | |||
| public List<WxBusiness> findTreeList(TenantEntity tenantEntity) { | |||
| WxBusiness bq = new WxBusiness(); | |||
| bq.setFinalTenantId(tenantEntity.getFinalTenantId()); | |||
| bq.setIsDel(EnumYesOrNo.NO.getCode()); | |||
| List<WxBusiness> alls = wxBusinessMapper.findListAll(bq); | |||
| if (null != alls && alls.size() > 0) { | |||
| List<WxBusiness> roots = new ArrayList<WxBusiness>(); | |||
| Map<Integer,List<WxBusiness>> childMap = new HashMap<Integer,List<WxBusiness>>(); | |||
| for (int i = 0 ; i < alls.size() ; i ++) { | |||
| WxBusiness business = alls.get(i); | |||
| List<WxBusiness> childs = childMap.get(business.getId()); | |||
| if (null == childs) { | |||
| childMap.put(business.getId(), new ArrayList<WxBusiness>()); | |||
| } | |||
| if (null == business.getParentId() || business.getParentId() == 0) { | |||
| roots.add(business); | |||
| }else { | |||
| childMap.get(business.getParentId()).add(business); | |||
| } | |||
| } | |||
| if (roots.size() > 0 ) { | |||
| for (int i = 0 ; i < roots.size() ; i ++) { | |||
| buildChildTree(roots.get(i),childMap); | |||
| } | |||
| return roots; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| private void buildChildTree(WxBusiness parent,Map<Integer,List<WxBusiness>> childMap) { | |||
| if (null == childMap || childMap.size() <= 0 ) { | |||
| return ; | |||
| } | |||
| List<WxBusiness> childs = childMap.get(parent.getId()); | |||
| if (null == childs || childs.size() <= 0 ) { | |||
| return ; | |||
| } | |||
| //子集 | |||
| List<WxBusiness> treeList = new ArrayList<WxBusiness>(); | |||
| for (WxBusiness business:childs) { | |||
| buildChildTree(business,childMap); | |||
| } | |||
| if (treeList.size() > 0 ) { | |||
| parent.setChildren(treeList); | |||
| } | |||
| } | |||
| @Override | |||
| public void saveOrUpdate(WxBusiness record) { | |||
| if (null == record.getId()) { | |||
| record.setType(1); | |||
| record.setCreateDate(new Date()); | |||
| record.setUpdateDate(new Date()); | |||
| record.setIsSystem(EnumYesOrNo.NO.getCode()); | |||
| record.setIsDel(EnumYesOrNo.NO.getCode()); | |||
| wxBusinessMapper.insert(record); | |||
| }else { | |||
| record.setUpdateDate(new Date()); | |||
| wxBusinessMapper.updateById(record); | |||
| } | |||
| } | |||
| } | |||