| @@ -162,8 +162,8 @@ public class ShiroConfig { | |||
| //配置退出 过滤器,其中的具体的退出代码Shiro已经替我们实现了 | |||
| filterChainDefinitionMap.put("/logout", "authc"); | |||
| filterChainDefinitionMap.put("/**", "corsFilter,token,authc"); | |||
| // filterChainDefinitionMap.put("/**", "anon"); | |||
| // filterChainDefinitionMap.put("/**", "corsFilter,token,authc"); | |||
| filterChainDefinitionMap.put("/**", "anon"); | |||
| shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap); | |||
| @@ -2,22 +2,30 @@ package com.iformall.controller.market; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.SystemControllerLog; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.WxCardDailyLog; | |||
| import com.iformall.domain.po.WxCoupon; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.domain.vo.WxCardVo; | |||
| import com.iformall.service.WxCardDailyLogService; | |||
| import com.iformall.service.WxCardSpendService; | |||
| import io.swagger.annotations.Api; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| import io.swagger.annotations.ApiImplicitParams; | |||
| import io.swagger.annotations.ApiOperation; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| /** | |||
| * @version 1.0 | |||
| @@ -34,17 +42,31 @@ public class WxCardDailyLogController extends BaseController { | |||
| WxCardDailyLogService wxCardDailyLogService; | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("list") | |||
| @GetMapping("/list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public ResultData list(@ModelAttribute WxCardDailyLog wxCardDailyLog, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponController::list"); | |||
| if (wxCardDailyLog == null) wxCardDailyLog = new WxCardDailyLog(); | |||
| wxCardDailyLog.updateTenantInfo(getTenantInfo()); | |||
| // wxCardDailyLog.updateTenantInfo(getTenantInfo()); | |||
| wxCardDailyLog.setTenantId("789"); | |||
| wxCardDailyLog.setSortColumns(BaseEntity.SortField.CreateDate_DESC); | |||
| PageInfo<WxCardDailyLog> info = wxCardDailyLogService.listAsPage(wxCardDailyLog, pageNum, pageSize); | |||
| return new ResultData(info); | |||
| } | |||
| @ApiOperation("消费卡日志-导出数据") | |||
| @GetMapping("/exportCardLog") | |||
| @SystemControllerLog(description = "消费卡日志-导出数据") | |||
| public void exportCardOrder(@ModelAttribute WxCardDailyLog wxCardDailyLog, HttpServletRequest request, HttpServletResponse response) { | |||
| logger.info("[" + getIpAddr() + "] cardDailyLog/exportCardLog"); | |||
| if (wxCardDailyLog == null) { | |||
| wxCardDailyLog = new WxCardDailyLog(); | |||
| } | |||
| wxCardDailyLog.setTenantId("789"); | |||
| // wxCardDailyLog.updateTenantInfo(getTenantInfo()); | |||
| wxCardDailyLogService.exportData(wxCardDailyLog, request, response); | |||
| } | |||
| } | |||
| @@ -1,5 +1,6 @@ | |||
| package com.iformall.domain.po; | |||
| import cn.afterturn.easypoi.excel.annotation.Excel; | |||
| import com.baomidou.mybatisplus.annotation.TableField; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| @@ -15,32 +16,41 @@ import java.util.List; | |||
| public class WxCardDailyLog extends TenantEntity { | |||
| protected Long id; | |||
| @io.swagger.annotations.ApiModelProperty(value="卡密id",name="cardPasswordId") | |||
| @Excel(name = "卡密ID", width = 20, orderNum = "4") | |||
| private Long cardPasswordId; | |||
| @io.swagger.annotations.ApiModelProperty(value="ip",name="ip") | |||
| private String ip; | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="price") | |||
| private Integer price; | |||
| @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") | |||
| @Excel(name = "操作时间", width = 20, orderNum = "4",format="yyyy-MM-dd HH:mm:ss") | |||
| private Date createDate; | |||
| @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") | |||
| private Date updateDate; | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="remark") | |||
| @Excel(name = "备注", width = 20, orderNum = "4") | |||
| private String remark; | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="operatorType") | |||
| private Integer operatorType; | |||
| @io.swagger.annotations.ApiModelProperty(value="",name="operatorId") | |||
| private Long operatorId; | |||
| @Excel(name = "操作人", width = 20, orderNum = "4") | |||
| @io.swagger.annotations.ApiModelProperty(value="EnumUserType",name="operatorUser") | |||
| private String operatorUser; | |||
| @io.swagger.annotations.ApiModelProperty(value="父卷id",name="couponId") | |||
| @Excel(name = "消费卡ID", width = 20, orderNum = "4") | |||
| private Long couponId; | |||
| @io.swagger.annotations.ApiModelProperty(value="卡卷Id",name="cardInfoId") | |||
| @Excel(name = "实体卡卡号", width = 20, orderNum = "4") | |||
| private Long cardInfoId; | |||
| @io.swagger.annotations.ApiModelProperty(value="操作类型 1-创建,2-设置面额,3-充值 EnumOperateLogType",name="type") | |||
| private Integer type; | |||
| @TableField(exist = false) | |||
| @Excel(name = "操作类型", width = 20, orderNum = "4") | |||
| private String typeDes; | |||
| @io.swagger.annotations.ApiModelProperty(value="卡卷总数",name="count") | |||
| private Integer count; | |||
| @@ -416,6 +416,9 @@ public class WxCoupon extends TenantEntity { | |||
| @TableField(exist = false) | |||
| private String[] mallTenantIds; | |||
| @TableField(exist = false) | |||
| private List<Long> couponIds; | |||
| public String getSalePriceStr() { | |||
| if(salePrice!=null) { | |||
| salePriceStr = new BigDecimal(salePrice).divide(new BigDecimal(100)).toString(); | |||
| @@ -3,6 +3,9 @@ package com.iformall.service; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.domain.po.*; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| public interface WxCardDailyLogService { | |||
| /** | |||
| @@ -23,4 +26,5 @@ public interface WxCardDailyLogService { | |||
| */ | |||
| void saveOrUpdate(WxCardDailyLog record); | |||
| void exportData(WxCardDailyLog wxCardDailyLog, HttpServletRequest request, HttpServletResponse response); | |||
| } | |||
| @@ -4,6 +4,8 @@ import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.vo.WxCardVo; | |||
| import com.iformall.enums.EnumOperateLogType; | |||
| import com.iformall.mapper.*; | |||
| import com.iformall.service.*; | |||
| import org.apache.commons.collections.CollectionUtils; | |||
| @@ -13,6 +15,8 @@ import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| import java.util.*; | |||
| import java.util.stream.Collectors; | |||
| @@ -27,6 +31,9 @@ public class WxCardDailyLogServiceImpl implements WxCardDailyLogService { | |||
| @Autowired | |||
| WxCouponService wxCouponService; | |||
| @Autowired | |||
| ExcelService excelService; | |||
| @Override | |||
| public PageInfo<WxCardDailyLog> listAsPage(WxCardDailyLog record, Integer pageIndex, Integer pageSize) { | |||
| @@ -70,4 +77,29 @@ public class WxCardDailyLogServiceImpl implements WxCardDailyLogService { | |||
| } | |||
| } | |||
| @Override | |||
| public void exportData(WxCardDailyLog record, HttpServletRequest request, HttpServletResponse response) { | |||
| if (StringUtils.isNotBlank(record.getTitle())) { | |||
| List<WxCoupon> title = wxCouponService.getByIdListOrTitle(new ArrayList<>(), record.getTenantId(), record.getTitle()); | |||
| if (!CollectionUtils.isEmpty(title)) { | |||
| List<Long> couponIds = title.parallelStream().map(WxCoupon::getId).collect(Collectors.toList()); | |||
| record.setCouponIds(couponIds); | |||
| } | |||
| } | |||
| List<WxCardDailyLog> pageInfo = wxCardDailyLogMapper.findList(record); | |||
| if (!CollectionUtils.isEmpty(pageInfo)) { | |||
| List<Long> couponIds = pageInfo.parallelStream().map(WxCardDailyLog::getCouponId).collect(Collectors.toList()); | |||
| List<WxCoupon> list = wxCouponService.getByIdListOrTitle(couponIds, record.getTenantId(), null); | |||
| if (!CollectionUtils.isEmpty(list)) { | |||
| Map<Long, String> map = list.parallelStream().collect(Collectors.toMap(WxCoupon::getId, WxCoupon::getTitle)); | |||
| for (WxCardDailyLog log : pageInfo) { | |||
| log.setTitle(map.get(log.getCouponId())); | |||
| log.setTypeDes(EnumOperateLogType.getEnum(log.getType()).getInfo()); | |||
| } | |||
| } | |||
| } | |||
| excelService.exportExcel(pageInfo, null, "消费卡日志", WxCardDailyLog.class, "消费卡日志.xlsx", response, false); | |||
| } | |||
| } | |||
| @@ -360,7 +360,7 @@ public class WxCardInfoServiceImpl implements WxCardInfoService { | |||
| WxCoupon wxCoupon = wxCouponMapper.selectById(wxCardInfo.getCouponId(), wxCardInfo.getTenantId()); | |||
| Integer type = cardInfo.getStatus() == 0 ? EnumOperateLogType.ENABLE.getCode() : EnumOperateLogType.STOP_USING.getCode(); | |||
| String remark = user.getUsername() + "给卡密[" + cardInfo.getId() + "]" + EnumOperateLogType.getEnum(type).getInfo(); | |||
| String remark = user.getUsername() + "给实体卡卡号[" + cardInfo.getId() + "]" + EnumOperateLogType.getEnum(type).getInfo(); | |||
| insertWxCardDailyLogInfo(user, wxCardInfo, wxCoupon, type, remark, wxCardInfo.getRemainingAmount()); | |||
| }catch (Exception e){ | |||
| @@ -520,7 +520,7 @@ public class WxCardInfoServiceImpl implements WxCardInfoService { | |||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "card spend 插入出错!"); | |||
| } | |||
| String remark = user.getUsername() + "给卡密[" + wxCardInfo.getId() + "]" + "充值,金额:" + cardInfo.getAmount() + "分"; | |||
| String remark = user.getUsername() + "给实体卡卡号[" + wxCardInfo.getId() + "]" + "充值,金额:" + cardInfo.getAmount()/100 + "元"; | |||
| insertWxCardDailyLogInfo(user, wxCardInfo, wxCoupon,EnumOperateLogType.RECHARGE.getCode(),remark, cardInfo.getAmount()); | |||
| if(record.getCardBeforeAmount().equals(0)){ | |||
| @@ -349,7 +349,7 @@ public class WxCouponPasswordServiceImpl implements WxCouponPasswordService { | |||
| cardSetPrice.setCardInfoId(cardInfo.getId()); | |||
| cardSetPrice.setType(wxCouponPassword.getIsStop() == 0 ? EnumOperateLogType.ENABLE.getCode() : EnumOperateLogType.STOP_USING.getCode()); | |||
| cardSetPrice.setCount(1); | |||
| cardSetPrice.setRemark(user.getUsername() + "给卡密[" + cardInfo.getId() + "]" + EnumOperateLogType.getEnum(cardSetPrice.getType()).getInfo()); | |||
| cardSetPrice.setRemark(user.getUsername() + "给实体卡卡号[" + cardInfo.getId() + "]" + EnumOperateLogType.getEnum(cardSetPrice.getType()).getInfo()); | |||
| wxCardDailyLogService.saveOrUpdate(cardSetPrice); | |||
| }catch (Exception e){ | |||
| logger.error("startOrStop insert error"); | |||
| @@ -398,7 +398,7 @@ public class WxCouponPasswordServiceImpl implements WxCouponPasswordService { | |||
| cardSetPrice.setCouponId(wxCoupon.getCouponId()); | |||
| cardSetPrice.setType(EnumOperateLogType.SET_DENOMINATION.getCode()); | |||
| cardSetPrice.setCount(1); | |||
| cardSetPrice.setRemark(user.getUsername() + "给卡密[" + cardSetPrice.getCardPasswordId() + "]设置了面额,金额:" + cardSetPrice.getPrice() + "分"); | |||
| cardSetPrice.setRemark(user.getUsername() + "给实体卡卡号[" + cardSetPrice.getCardPasswordId() + "]设置了面额,金额:" + cardSetPrice.getPrice()/100 + "元"); | |||
| wxCardDailyLogService.saveOrUpdate(cardSetPrice); | |||
| } | |||
| return count; | |||
| @@ -1829,7 +1829,7 @@ public class WxCouponServiceImpl implements WxCouponService { | |||
| wxCouponChannelService.spuStatusSyncByCoupon(tenantInfo,couponId); | |||
| WxCoupon record = wxCouponMapper.selectById(couponId, tenantInfo.getTenantId()); | |||
| String remark = (user != null ? user.getUsername() : "") + "创建了卡[" + record.getTitle() + "], 库存:"; | |||
| String remark = (user != null ? user.getUsername() : "") + "作废卡[" + record.getTitle() + "], 库存:"; | |||
| insertWxCardDailyLogInfo(user, record, false, remark); | |||
| } | |||
| return new ResultData(); | |||
| @@ -2107,11 +2107,15 @@ public class WxCouponServiceImpl implements WxCouponService { | |||
| @Override | |||
| public List<WxCoupon> getByIdListOrTitle(List<Long> couponIds, String tenantId, String title) { | |||
| return wxCouponMapper.selectList(new LambdaQueryWrapper<WxCoupon>() | |||
| .eq(WxCoupon::getIsDel, 0) | |||
| .in(CollectionUtils.isNotEmpty(couponIds), WxCoupon::getId, couponIds) | |||
| .like(StringUtils.isNotBlank(title), WxCoupon::getTitle, title) | |||
| .eq(TenantEntity::getTenantId, tenantId)); | |||
| WxCoupon coupon = new WxCoupon(); | |||
| coupon.setTenantId(tenantId); | |||
| if (CollectionUtils.isNotEmpty(couponIds)) { | |||
| coupon.setCouponIds(couponIds); | |||
| } | |||
| if (StringUtils.isNotBlank(title)) { | |||
| coupon.setTitle(title); | |||
| } | |||
| return wxCouponMapper.findList(coupon); | |||
| } | |||
| @@ -364,6 +364,13 @@ | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != couponIds "> | |||
| and id in | |||
| <foreach collection="couponIds" index="index" item="couponIdsItem" open="(" separator="," close=")"> | |||
| #{couponIdsItem} | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | |||
| </sql> | |||