Browse Source

[预付费][修改][交费]

release_toaliyun_real
gongbiao 6 years ago
parent
commit
e29b9372dd
7 changed files with 95 additions and 9 deletions
  1. +27
    -4
      mallinkAdmin/src/main/java/com/iformall/controller/market/WxPrepaymentController.java
  2. +7
    -0
      mallinkService/src/main/java/com/iformall/domain/po/WxPrepayment.java
  3. +3
    -0
      mallinkService/src/main/java/com/iformall/domain/po/WxPrepaymentHistory.java
  4. +4
    -0
      mallinkService/src/main/java/com/iformall/service/WxPrepaymentService.java
  5. +41
    -0
      mallinkService/src/main/java/com/iformall/service/impl/WxPrepaymentServiceImpl.java
  6. +6
    -3
      mallinkService/src/main/resources/mapper/WxPrepaymentHistoryMapper.xml
  7. +7
    -2
      mallinkService/src/main/resources/mapper/WxPrepaymentMapper.xml

+ 27
- 4
mallinkAdmin/src/main/java/com/iformall/controller/market/WxPrepaymentController.java View File

@@ -7,6 +7,7 @@ import com.iformall.common.ResultData;
import com.iformall.controller.base.BaseController; import com.iformall.controller.base.BaseController;
import com.iformall.domain.po.WxPrepayment; import com.iformall.domain.po.WxPrepayment;
import com.iformall.domain.po.WxPrepaymentHistory; import com.iformall.domain.po.WxPrepaymentHistory;
import com.iformall.enums.EnumUserType;
import com.iformall.service.WxPrepaymentService; import com.iformall.service.WxPrepaymentService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
@@ -15,10 +16,7 @@ import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger; 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.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;




/** /**
@@ -65,4 +63,29 @@ public class WxPrepaymentController extends BaseController {
return new ResultData(page); return new ResultData(page);
} }


@ApiOperation("首次充值")
@PostMapping("payFirst")
@SystemControllerLog(description = "预付费-交费")
public ResultData payFirst(@RequestBody WxPrepayment wxPrepayment) {
logger.debug("[" + getIpAddr() + "] prepayment::add");
wxPrepayment.setTenantId(getTenantId());
wxPrepayment.setOperationType(EnumUserType.MALLUSER.getCode());
wxPrepayment.setOperator(getUserId());
wxPrepaymentService.payFirst(wxPrepayment);
return new ResultData();
}

@ApiOperation("再次充值")
@PostMapping("payAgain")
@SystemControllerLog(description = "预付费-交费或扣费")
public ResultData payAgain(@RequestBody WxPrepayment wxPrepayment) {
logger.debug("[" + getIpAddr() + "] prepayment::update");
wxPrepayment.setTenantId(getTenantId());
wxPrepayment.setOperationType(EnumUserType.MALLUSER.getCode());
wxPrepayment.setOperator(getUserId());
wxPrepaymentService.payAgain(wxPrepayment);
return new ResultData();

}

} }

+ 7
- 0
mallinkService/src/main/java/com/iformall/domain/po/WxPrepayment.java View File

@@ -9,6 +9,9 @@ import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;


/**
* @author gongbiao
*/
@Table(name = "wx_prepayment") @Table(name = "wx_prepayment")
@Data @Data
public class WxPrepayment implements Serializable { public class WxPrepayment implements Serializable {
@@ -38,6 +41,10 @@ public class WxPrepayment implements Serializable {
private Long totalAmount; private Long totalAmount;
@io.swagger.annotations.ApiModelProperty(value = "备注", name = "remarks") @io.swagger.annotations.ApiModelProperty(value = "备注", name = "remarks")
private String remarks; private String remarks;
@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") @io.swagger.annotations.ApiModelProperty(value = "创建时间", name = "createTime")
private Date createTime; private Date createTime;
@io.swagger.annotations.ApiModelProperty(value = "更新时间", name = "updateTime") @io.swagger.annotations.ApiModelProperty(value = "更新时间", name = "updateTime")


+ 3
- 0
mallinkService/src/main/java/com/iformall/domain/po/WxPrepaymentHistory.java View File

@@ -9,6 +9,9 @@ import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;


/**
* @author gongbiao
*/
@Table(name = "wx_prepayment_history") @Table(name = "wx_prepayment_history")
@Data @Data
public class WxPrepaymentHistory implements Serializable { public class WxPrepaymentHistory implements Serializable {


+ 4
- 0
mallinkService/src/main/java/com/iformall/service/WxPrepaymentService.java View File

@@ -21,4 +21,8 @@ public interface WxPrepaymentService {


PageInfo<WxPrepaymentHistory> listHistoryAsPage(WxPrepaymentHistory wxPrepaymentHistory, Integer pageNum, Integer pageSize); PageInfo<WxPrepaymentHistory> listHistoryAsPage(WxPrepaymentHistory wxPrepaymentHistory, Integer pageNum, Integer pageSize);


void payFirst(WxPrepayment wxPrepayment);

void payAgain(WxPrepayment wxPrepayment);

} }

+ 41
- 0
mallinkService/src/main/java/com/iformall/service/impl/WxPrepaymentServiceImpl.java View File

@@ -2,6 +2,7 @@ package com.iformall.service.impl;


import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.iformall.common.IdWorker;
import com.iformall.domain.po.WxPrepayment; import com.iformall.domain.po.WxPrepayment;
import com.iformall.domain.po.WxPrepaymentHistory; import com.iformall.domain.po.WxPrepaymentHistory;
import com.iformall.mapper.WxPrepaymentHistoryMapper; import com.iformall.mapper.WxPrepaymentHistoryMapper;
@@ -12,6 +13,11 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;


import java.math.BigDecimal;

/**
* @author gongbiao
*/
@Service @Service
public class WxPrepaymentServiceImpl implements WxPrepaymentService { public class WxPrepaymentServiceImpl implements WxPrepaymentService {


@@ -33,4 +39,39 @@ public class WxPrepaymentServiceImpl implements WxPrepaymentService {
return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxPrepaymentHistoryMapper.findList(record)); return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxPrepaymentHistoryMapper.findList(record));
} }


@Override
public void payFirst(WxPrepayment wxPrepayment) {
final IdWorker idWorker = IdWorker.get();
wxPrepayment.setId(idWorker.nextId());
wxPrepaymentMapper.insertSelective(wxPrepayment);
addPrepaymentHistory(wxPrepayment);
}

@Override
public void payAgain(WxPrepayment record) {
WxPrepayment wxPrepayment = wxPrepaymentMapper.selectByPrimaryKey(record.getId());
long remainAmout = wxPrepayment.getRemainAmount() + record.getLastPayAmount();
long totalAmount = wxPrepayment.getTotalAmount() + record.getLastPayAmount();
wxPrepayment.setRemainAmount(remainAmout);
wxPrepayment.setTotalAmount(totalAmount);
wxPrepaymentMapper.updateByPrimaryKeySelective(wxPrepayment);
addPrepaymentHistory(wxPrepayment);
}

private void addPrepaymentHistory(WxPrepayment wxPrepayment) {
WxPrepaymentHistory wxPrepaymentHistory = new WxPrepaymentHistory();
final IdWorker idWorker = IdWorker.get();
wxPrepaymentHistory.setId(idWorker.nextId());
wxPrepaymentHistory.setTenantId(wxPrepayment.getTenantId());
wxPrepaymentHistory.setMerchantId(wxPrepayment.getMerchantId());
wxPrepaymentHistory.setPayWay(wxPrepayment.getLastPayWay());
wxPrepaymentHistory.setPayType(wxPrepayment.getLastPayType());
String lastPayAmount = new BigDecimal(wxPrepayment.getLastPayAmount()).divide(new BigDecimal(100)).setScale(2).toPlainString();
wxPrepaymentHistory.setAmountDetail("+" + lastPayAmount + "元");
wxPrepaymentHistory.setRemainAmount(wxPrepayment.getRemainAmount());
wxPrepaymentHistory.setOperationType(wxPrepayment.getOperationType());
wxPrepaymentHistory.setOperator(wxPrepayment.getOperator());
wxPrepaymentHistoryMapper.insertSelective(wxPrepaymentHistory);
}

} }

+ 6
- 3
mallinkService/src/main/resources/mapper/WxPrepaymentHistoryMapper.xml View File

@@ -16,9 +16,9 @@
</resultMap> </resultMap>
<sql id="allColumns"> <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>
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"> <sql id="dynamicWhereConditions">
where 1 = 1 where 1 = 1
@@ -37,6 +37,9 @@
<if test=" null != payWay "> <if test=" null != payWay ">
and p.`pay_way` = #{payWay} and p.`pay_way` = #{payWay}
</if> </if>
<if test=" null != operationType ">
and p.`operation_type` = #{operationType}
</if>
<if test=" null != merchantName and '' != merchantName"> <if test=" null != merchantName and '' != merchantName">
and m.`name` like concat('%',#{merchantName},'%') and m.`name` like concat('%',#{merchantName},'%')
</if> </if>


+ 7
- 2
mallinkService/src/main/resources/mapper/WxPrepaymentMapper.xml View File

@@ -11,14 +11,16 @@
<result column="remain_amount" property="remainAmount"/> <result column="remain_amount" property="remainAmount"/>
<result column="total_amount" property="totalAmount"/> <result column="total_amount" property="totalAmount"/>
<result column="remarks" property="remarks"/> <result column="remarks" property="remarks"/>
<result column="operation_type" property="operationType"/>
<result column="operator" property="operator"/>
<result column="create_time" property="createTime"/> <result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/> <result column="update_time" property="updateTime"/>
<result column="merchant_name" property="merchantName"/> <result column="merchant_name" property="merchantName"/>
</resultMap> </resultMap>
<sql id="allColumns"> <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
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.`operation_type`,p.`operator`,
p.`create_time`,p.`update_time`,m.`name` merchant_name
</sql> </sql>
<sql id="dynamicWhereConditions"> <sql id="dynamicWhereConditions">
@@ -38,6 +40,9 @@
<if test=" null != lastPayWay "> <if test=" null != lastPayWay ">
and p.`last_pay_way` = #{lastPayWay} and p.`last_pay_way` = #{lastPayWay}
</if> </if>
<if test=" null != operationType ">
and p.`operation_type` = #{operationType}
</if>
<if test=" null != merchantName and '' != merchantName"> <if test=" null != merchantName and '' != merchantName">
and m.`name` like concat('%',#{merchantName},'%') and m.`name` like concat('%',#{merchantName},'%')
</if> </if>


Loading…
Cancel
Save