| @@ -0,0 +1,68 @@ | |||
| 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.WxPrepayment; | |||
| import com.iformall.domain.po.WxPrepaymentHistory; | |||
| import com.iformall.service.WxPrepaymentService; | |||
| 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; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| @RestController | |||
| @RequestMapping("prepayment") | |||
| @Api(description = "预付费") | |||
| public class WxPrepaymentController extends BaseController { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| WxPrepaymentService wxPrepaymentService; | |||
| @ApiOperation("列表查询") | |||
| @GetMapping("list") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "预付费-列表查询") | |||
| public ResultData list(@ModelAttribute WxPrepayment wxPrepayment, Integer pageNum, Integer pageSize) { | |||
| String ipStr = getIpAddr(); | |||
| logger.info("prepayment/list: " + ipStr); | |||
| if (wxPrepayment == null) { | |||
| wxPrepayment = new WxPrepayment(); | |||
| } | |||
| final PageInfo<WxPrepayment> page = wxPrepaymentService.listAsPage(wxPrepayment, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("列表查询历史") | |||
| @GetMapping("listHistory") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "预付费-列表查询历史") | |||
| public ResultData listHistory(@ModelAttribute WxPrepaymentHistory wxPrepaymentHistory, Integer pageNum, Integer pageSize) { | |||
| String ipStr = getIpAddr(); | |||
| logger.info("prepayment/listHistory: " + ipStr); | |||
| if (wxPrepaymentHistory == null) { | |||
| wxPrepaymentHistory = new WxPrepaymentHistory(); | |||
| } | |||
| final PageInfo<WxPrepaymentHistory> page = wxPrepaymentService.listHistoryAsPage(wxPrepaymentHistory, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| } | |||
| @@ -0,0 +1,105 @@ | |||
| package com.iformall.domain.po; | |||
| import lombok.Data; | |||
| import javax.persistence.Id; | |||
| import javax.persistence.Table; | |||
| import javax.persistence.Transient; | |||
| import java.io.Serializable; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| @Table(name = "wx_prepayment") | |||
| @Data | |||
| public class WxPrepayment implements Serializable { | |||
| private static final long serialVersionUID = 1L; | |||
| @Id | |||
| protected Long id; | |||
| @Transient | |||
| protected List<Long> ids; | |||
| @Transient | |||
| protected String sortColumns; | |||
| @io.swagger.annotations.ApiModelProperty(value = "租户ID", name = "tenantId") | |||
| private String tenantId; | |||
| @io.swagger.annotations.ApiModelProperty(value = "商户ID", name = "merchantId") | |||
| private Long merchantId; | |||
| @io.swagger.annotations.ApiModelProperty(value = "最后付款方式1微信", name = "lastPayWay") | |||
| private Integer lastPayWay; | |||
| @io.swagger.annotations.ApiModelProperty(value = "最后付款用途1电费", name = "lastPayType") | |||
| private Integer lastPayType; | |||
| @io.swagger.annotations.ApiModelProperty(value = "最后支付金额(单位分)", name = "lastPayAmount") | |||
| private Long lastPayAmount; | |||
| @io.swagger.annotations.ApiModelProperty(value = "余额(单位分)", name = "remainAmount") | |||
| private Long remainAmount; | |||
| @io.swagger.annotations.ApiModelProperty(value = "总额(单位分)", name = "totalAmount") | |||
| private Long totalAmount; | |||
| @io.swagger.annotations.ApiModelProperty(value = "备注", name = "remarks") | |||
| private String remarks; | |||
| @io.swagger.annotations.ApiModelProperty(value = "创建时间", name = "createTime") | |||
| private Date createTime; | |||
| @io.swagger.annotations.ApiModelProperty(value = "更新时间", name = "updateTime") | |||
| private Date updateTime; | |||
| @Transient | |||
| @io.swagger.annotations.ApiModelProperty(value = "商户名称", name = "merchantName") | |||
| private String merchantName; | |||
| public static enum Field { | |||
| Id_ASC("`id` ASC"), Id_DESC("`id` DESC"); | |||
| private String value; | |||
| Field(String value) { | |||
| this.value = value; | |||
| } | |||
| public String getValue() { | |||
| return value; | |||
| } | |||
| public void setCol(String value) { | |||
| this.value = value; | |||
| } | |||
| @Override | |||
| public String toString() { | |||
| return this.getValue(); | |||
| } | |||
| } | |||
| public void setSortColumns(WxPrepayment.Field... fields) { | |||
| if (fields == null || fields.length == 0) { | |||
| return; | |||
| } | |||
| for (int k = 0; k < fields.length; k++) { | |||
| if (fields[k] == null) { | |||
| return; | |||
| } | |||
| } | |||
| StringBuilder sb = new StringBuilder(fields[0].toString()); | |||
| for (int k = 1; k < fields.length; k++) { | |||
| sb.append(","); | |||
| sb.append(fields[k].toString()); | |||
| } | |||
| this.sortColumns = sb.toString(); | |||
| } | |||
| public void setSortColumns(String sortColumns) { | |||
| if (sortColumns == null || "".equals(sortColumns.trim())) { | |||
| return; | |||
| } | |||
| if (sortColumns.contains(",")) { | |||
| String[] cols = sortColumns.split(","); | |||
| List<Field> fList = new java.util.ArrayList(); | |||
| for (int k = 0; k < cols.length; k++) { | |||
| fList.add(Field.valueOf(cols[k])); | |||
| } | |||
| this.setSortColumns(fList.toArray(new Field[fList.size()])); | |||
| } else { | |||
| this.setSortColumns(Field.valueOf(sortColumns)); | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,102 @@ | |||
| package com.iformall.domain.po; | |||
| import lombok.Data; | |||
| import javax.persistence.Id; | |||
| import javax.persistence.Table; | |||
| import javax.persistence.Transient; | |||
| import java.io.Serializable; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| @Table(name = "wx_prepayment_history") | |||
| @Data | |||
| public class WxPrepaymentHistory implements Serializable { | |||
| private static final long serialVersionUID = 1L; | |||
| @Id | |||
| protected Long id; | |||
| @Transient | |||
| protected List<Long> ids; | |||
| @Transient | |||
| protected String sortColumns; | |||
| @io.swagger.annotations.ApiModelProperty(value = "租户ID", name = "tenantId") | |||
| private String tenantId; | |||
| @io.swagger.annotations.ApiModelProperty(value = "商户ID", name = "merchantId") | |||
| private Long merchantId; | |||
| @io.swagger.annotations.ApiModelProperty(value = "付款方式1微信", name = "payWay") | |||
| private Integer payWay; | |||
| @io.swagger.annotations.ApiModelProperty(value = "付款用途1电费", name = "payType") | |||
| private Integer payType; | |||
| @io.swagger.annotations.ApiModelProperty(value = "金额明细(单位元)", name = "amountDetail") | |||
| private String amountDetail; | |||
| @io.swagger.annotations.ApiModelProperty(value = "余额(单位分)", name = "remainAmount") | |||
| private Long remainAmount; | |||
| @io.swagger.annotations.ApiModelProperty(value = "总操作类型1C端3B端4A端", name = "operationType") | |||
| private Integer operationType; | |||
| @io.swagger.annotations.ApiModelProperty(value = "操作人", name = "operator") | |||
| private Long operator; | |||
| @io.swagger.annotations.ApiModelProperty(value = "创建时间", name = "createTime") | |||
| private Date createTime; | |||
| @Transient | |||
| @io.swagger.annotations.ApiModelProperty(value = "商户名称", name = "merchantName") | |||
| private String merchantName; | |||
| public static enum Field { | |||
| Id_ASC("`id` ASC"), Id_DESC("`id` DESC"); | |||
| private String value; | |||
| Field(String value) { | |||
| this.value = value; | |||
| } | |||
| public String getValue() { | |||
| return value; | |||
| } | |||
| public void setCol(String value) { | |||
| this.value = value; | |||
| } | |||
| @Override | |||
| public String toString() { | |||
| return this.getValue(); | |||
| } | |||
| } | |||
| public void setSortColumns(WxPrepaymentHistory.Field... fields) { | |||
| if (fields == null || fields.length == 0) { | |||
| return; | |||
| } | |||
| for (int k = 0; k < fields.length; k++) { | |||
| if (fields[k] == null) { | |||
| return; | |||
| } | |||
| } | |||
| StringBuilder sb = new StringBuilder(fields[0].toString()); | |||
| for (int k = 1; k < fields.length; k++) { | |||
| sb.append(","); | |||
| sb.append(fields[k].toString()); | |||
| } | |||
| this.sortColumns = sb.toString(); | |||
| } | |||
| public void setSortColumns(String sortColumns) { | |||
| if (sortColumns == null || "".equals(sortColumns.trim())) { | |||
| return; | |||
| } | |||
| if (sortColumns.contains(",")) { | |||
| String[] cols = sortColumns.split(","); | |||
| List<Field> fList = new java.util.ArrayList(); | |||
| for (int k = 0; k < cols.length; k++) { | |||
| fList.add(Field.valueOf(cols[k])); | |||
| } | |||
| this.setSortColumns(fList.toArray(new Field[fList.size()])); | |||
| } else { | |||
| this.setSortColumns(Field.valueOf(sortColumns)); | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,21 @@ | |||
| package com.iformall.mapper; | |||
| import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.WxPrepaymentHistory; | |||
| import java.util.List; | |||
| /** | |||
| * @author gongbiaow | |||
| */ | |||
| public interface WxPrepaymentHistoryMapper extends CommonMapper<WxPrepaymentHistory, Long> { | |||
| /** | |||
| * 根据不同条件查询数据 | |||
| * | |||
| * @param prepaymentHistory | |||
| * @return | |||
| */ | |||
| List<WxPrepaymentHistory> findList(WxPrepaymentHistory prepaymentHistory); | |||
| } | |||
| @@ -0,0 +1,21 @@ | |||
| package com.iformall.mapper; | |||
| import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.WxPrepayment; | |||
| import java.util.List; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| public interface WxPrepaymentMapper extends CommonMapper<WxPrepayment, Long> { | |||
| /** | |||
| * 根据不同条件查询数据 | |||
| * | |||
| * @param prepayment | |||
| * @return | |||
| */ | |||
| List<WxPrepayment> findList(WxPrepayment prepayment); | |||
| } | |||
| @@ -0,0 +1,24 @@ | |||
| package com.iformall.service; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.domain.po.WxPrepayment; | |||
| import com.iformall.domain.po.WxPrepaymentHistory; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| public interface WxPrepaymentService { | |||
| /** | |||
| * 根据实体查询分页列表 | |||
| * | |||
| * @param record | |||
| * @param pageIndex | |||
| * @param pageSize | |||
| * @return | |||
| */ | |||
| PageInfo<WxPrepayment> listAsPage(WxPrepayment record, Integer pageIndex, Integer pageSize); | |||
| PageInfo<WxPrepaymentHistory> listHistoryAsPage(WxPrepaymentHistory wxPrepaymentHistory, Integer pageNum, Integer pageSize); | |||
| } | |||
| @@ -0,0 +1,36 @@ | |||
| package com.iformall.service.impl; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.domain.po.WxPrepayment; | |||
| import com.iformall.domain.po.WxPrepaymentHistory; | |||
| import com.iformall.mapper.WxPrepaymentHistoryMapper; | |||
| import com.iformall.mapper.WxPrepaymentMapper; | |||
| import com.iformall.service.WxPrepaymentService; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.stereotype.Service; | |||
| @Service | |||
| public class WxPrepaymentServiceImpl implements WxPrepaymentService { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| WxPrepaymentMapper wxPrepaymentMapper; | |||
| @Autowired | |||
| WxPrepaymentHistoryMapper wxPrepaymentHistoryMapper; | |||
| @Override | |||
| public PageInfo<WxPrepayment> listAsPage(WxPrepayment record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxPrepaymentMapper.findList(record)); | |||
| } | |||
| @Override | |||
| public PageInfo<WxPrepaymentHistory> listHistoryAsPage(WxPrepaymentHistory record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxPrepaymentHistoryMapper.findList(record)); | |||
| } | |||
| } | |||
| @@ -0,0 +1,60 @@ | |||
| <?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.WxPrepaymentHistoryMapper"> | |||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxPrepaymentHistory"> | |||
| <id column="id" property="id"/> | |||
| <result column="tenant_id" property="tenantId"/> | |||
| <result column="merchant_id" property="merchantId"/> | |||
| <result column="pay_type" property="payType"/> | |||
| <result column="pay_way" property="payWay"/> | |||
| <result column="amount_detail" property="amountDetail"/> | |||
| <result column="remain_amount" property="remainAmount"/> | |||
| <result column="operation_type" property="operationType"/> | |||
| <result column="operator" property="operator"/> | |||
| <result column="create_time" property="createTime"/> | |||
| <result column="merchant_name" property="merchantName"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| p.`id,p.`tenant_id`,p.`merchant_id`,p.`pay_way`,p.`pay_type`,p.`amount_detail`,p.`remain_amount`,p.`operation_type`,p.`operator`,p.`create_time`, | |||
| m.`name` merchant_name | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| where 1 = 1 | |||
| <if test=" null != tenantId "> | |||
| and p.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != id "> | |||
| and p.`id` = #{id} | |||
| </if> | |||
| <if test=" null != merchantId "> | |||
| and p.`merchant_id` = #{merchantId} | |||
| </if> | |||
| <if test=" null != payType "> | |||
| and p.`pay_type` = #{payType} | |||
| </if> | |||
| <if test=" null != payWay "> | |||
| and p.`pay_way` = #{payWay} | |||
| </if> | |||
| <if test=" null != merchantName and '' != merchantName"> | |||
| and m.`name` like concat('%',#{merchantName},'%') | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and p.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.WxPrepayment" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||
| from wx_prepayment_history p inner join wx_merchant m on p.merchant_id=m.id | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| </mapper> | |||
| @@ -0,0 +1,61 @@ | |||
| <?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.WxPrepaymentMapper"> | |||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxPrepayment"> | |||
| <id column="id" property="id"/> | |||
| <result column="tenant_id" property="tenantId"/> | |||
| <result column="merchant_id" property="merchantId"/> | |||
| <result column="last_pay_type" property="lastPayType"/> | |||
| <result column="last_pay_way" property="lastPayWay"/> | |||
| <result column="last_pay_amount" property="lastPayAmount"/> | |||
| <result column="remain_amount" property="remainAmount"/> | |||
| <result column="total_amount" property="totalAmount"/> | |||
| <result column="remarks" property="remarks"/> | |||
| <result column="create_time" property="createTime"/> | |||
| <result column="update_time" property="updateTime"/> | |||
| <result column="merchant_name" property="merchantName"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| p.`id`,p.`tenant_id`,p.`merchant_id`,p.`last_pay_way`,p.`last_pay_type`,p.`last_pay_amount`,p.`remain_amount`,p.`total_amount` ,p.`remarks`,p.`create_time`,p.`update_time`, | |||
| m.`name` merchant_name | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| where 1 = 1 | |||
| <if test=" null != tenantId "> | |||
| and p.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != id "> | |||
| and p.`id` = #{id} | |||
| </if> | |||
| <if test=" null != merchantId "> | |||
| and p.`merchant_id` = #{merchantId} | |||
| </if> | |||
| <if test=" null != lastPayType "> | |||
| and p.`last_pay_type` = #{lastPayType} | |||
| </if> | |||
| <if test=" null != lastPayWay "> | |||
| and p.`last_pay_way` = #{lastPayWay} | |||
| </if> | |||
| <if test=" null != merchantName and '' != merchantName"> | |||
| and m.`name` like concat('%',#{merchantName},'%') | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and p.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.WxPrepayment" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||
| from wx_prepayment p inner join wx_merchant m on p.merchant_id=m.id | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| </mapper> | |||