From e6369b4850203cc927b42709d8a75d39db520d96 Mon Sep 17 00:00:00 2001 From: gongbiao Date: Mon, 17 Dec 2018 18:51:10 +0800 Subject: [PATCH] =?UTF-8?q?[=E5=88=86=E8=B4=A6=E5=AF=B9=E8=B4=A6][?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0][=E6=9F=A5=E8=AF=A2]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WxProfitSharingOrderController.java | 64 +++++++ .../vo/WxProfitSharingOrderDetailsVo.java | 130 +++++++++++++++ .../vo/WxProfitSharingOrderQueryVo.java | 65 ++++++++ .../domain/vo/WxProfitSharingOrderVo.java | 156 ++++++++++++++++++ .../mapper/WxProfitSharingOrderMapper.java | 20 ++- .../service/WxProfitSharingOrderService.java | 19 ++- .../impl/WxProfitSharingOrderServiceImpl.java | 125 +++++++++++++- .../main/resources/mapper/WxOrderMapper.xml | 4 +- .../mapper/WxProfitSharingOrderMapper.xml | 93 +++++++++++ 9 files changed, 663 insertions(+), 13 deletions(-) create mode 100644 mallinkAdmin/src/main/java/com/iformall/controller/WxProfitSharingOrderController.java create mode 100644 mallinkService/src/main/java/com/iformall/domain/vo/WxProfitSharingOrderDetailsVo.java create mode 100644 mallinkService/src/main/java/com/iformall/domain/vo/WxProfitSharingOrderQueryVo.java create mode 100644 mallinkService/src/main/java/com/iformall/domain/vo/WxProfitSharingOrderVo.java diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/WxProfitSharingOrderController.java b/mallinkAdmin/src/main/java/com/iformall/controller/WxProfitSharingOrderController.java new file mode 100644 index 000000000..4031a6a94 --- /dev/null +++ b/mallinkAdmin/src/main/java/com/iformall/controller/WxProfitSharingOrderController.java @@ -0,0 +1,64 @@ +package com.iformall.controller; + +import com.github.pagehelper.PageInfo; +import com.iformall.common.ResultData; +import com.iformall.domain.vo.WxProfitSharingOrderQueryVo; +import com.iformall.domain.vo.WxProfitSharingOrderVo; +import com.iformall.service.WxProfitSharingOrderService; +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.*; + +import java.util.Map; + +/** + * @author gongbiao + */ +@RestController +@RequestMapping("wxProfitSharingOrder") +public class WxProfitSharingOrderController extends BaseController { + private final Logger logger = LoggerFactory.getLogger(this.getClass()); + + @Autowired + private WxProfitSharingOrderService wxProfitSharingOrderService; + + @ApiOperation("分页列表接口") + @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 WxProfitSharingOrderQueryVo order, Integer pageNum, Integer pageSize) { + logger.debug("[" + getIpAddr() + "] WxProfitSharingOrderController::list"); + if (null == order) { + order = new WxProfitSharingOrderQueryVo(); + } + final PageInfo page = wxProfitSharingOrderService.listAsPage(order, pageNum, pageSize); + return new ResultData(page); + } + + @ApiOperation("交易统计") + @PostMapping("/queryOrderSummary") + public ResultData queryOrderSummary() { + logger.debug("[" + getIpAddr() + "] WxProfitSharingOrderController::queryOrderSummary"); + + Map data = wxProfitSharingOrderService.queryOrderSummary(getTenantId()); + + return new ResultData(data); + } + + + + @ApiOperation("分账详情") + @GetMapping("findOrderDetails") + @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) + public ResultData findOrderDetails(Long id) { + logger.debug("[" + getIpAddr() + "] WxProfitSharingOrderController::findOrderDetails"); + return wxProfitSharingOrderService.findOrderDetails(id); + } + + +} diff --git a/mallinkService/src/main/java/com/iformall/domain/vo/WxProfitSharingOrderDetailsVo.java b/mallinkService/src/main/java/com/iformall/domain/vo/WxProfitSharingOrderDetailsVo.java new file mode 100644 index 000000000..dbe705cdd --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/domain/vo/WxProfitSharingOrderDetailsVo.java @@ -0,0 +1,130 @@ +package com.iformall.domain.vo; + +import java.io.Serializable; +import java.util.Date; + +/** + * @author gongbiao + */ +public class WxProfitSharingOrderDetailsVo implements Serializable { + private static final long serialVersionUID = 1L; + + private Long Id; + private String tenantId; + private Integer payAmount; + private Date createTime; + private Integer sharingStatus; + private String finishTime; + private String failedReason; + private String description; + private Integer receiverType; + private String receiverAccount; + private String receiverComments; + private Integer sharingType; + private Integer status; + + + public Long getId() { + return Id; + } + + public void setId(Long id) { + Id = id; + } + + public String getTenantId() { + return tenantId; + } + + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + public Integer getPayAmount() { + return payAmount; + } + + public void setPayAmount(Integer payAmount) { + this.payAmount = payAmount; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Integer getSharingStatus() { + return sharingStatus; + } + + public void setSharingStatus(Integer sharingStatus) { + this.sharingStatus = sharingStatus; + } + + public String getFinishTime() { + return finishTime; + } + + public void setFinishTime(String finishTime) { + this.finishTime = finishTime; + } + + public String getFailedReason() { + return failedReason; + } + + public void setFailedReason(String failedReason) { + this.failedReason = failedReason; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Integer getReceiverType() { + return receiverType; + } + + public void setReceiverType(Integer receiverType) { + this.receiverType = receiverType; + } + + public String getReceiverAccount() { + return receiverAccount; + } + + public void setReceiverAccount(String receiverAccount) { + this.receiverAccount = receiverAccount; + } + + public String getReceiverComments() { + return receiverComments; + } + + public void setReceiverComments(String receiverComments) { + this.receiverComments = receiverComments; + } + + public Integer getSharingType() { + return sharingType; + } + + public void setSharingType(Integer sharingType) { + this.sharingType = sharingType; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } +} diff --git a/mallinkService/src/main/java/com/iformall/domain/vo/WxProfitSharingOrderQueryVo.java b/mallinkService/src/main/java/com/iformall/domain/vo/WxProfitSharingOrderQueryVo.java new file mode 100644 index 000000000..5b62e92e3 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/domain/vo/WxProfitSharingOrderQueryVo.java @@ -0,0 +1,65 @@ +package com.iformall.domain.vo; + +import java.io.Serializable; +import java.util.Date; + +/** + * @author gongbiao + */ +public class WxProfitSharingOrderQueryVo implements Serializable { + + @io.swagger.annotations.ApiModelProperty(value="tenantId",name="tenantId") + private String tenantId; + + @io.swagger.annotations.ApiModelProperty(value="商户名称",name="merchantName") + private String merchantName; + + @io.swagger.annotations.ApiModelProperty(value="id",name="id") + private Long id; + + @io.swagger.annotations.ApiModelProperty(value="开始时间",name="startdate") + private Date startdate; + + @io.swagger.annotations.ApiModelProperty(value="结束时间",name="enddate") + private Date enddate; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getTenantId() { + return tenantId; + } + + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + public String getMerchantName() { + return merchantName; + } + + public void setMerchantName(String merchantName) { + this.merchantName = merchantName; + } + + public Date getStartdate() { + return startdate; + } + + public void setStartdate(Date startdate) { + this.startdate = startdate; + } + + public Date getEnddate() { + return enddate; + } + + public void setEnddate(Date enddate) { + this.enddate = enddate; + } +} diff --git a/mallinkService/src/main/java/com/iformall/domain/vo/WxProfitSharingOrderVo.java b/mallinkService/src/main/java/com/iformall/domain/vo/WxProfitSharingOrderVo.java new file mode 100644 index 000000000..8e29ed635 --- /dev/null +++ b/mallinkService/src/main/java/com/iformall/domain/vo/WxProfitSharingOrderVo.java @@ -0,0 +1,156 @@ +package com.iformall.domain.vo; + +import java.io.Serializable; +import java.util.Date; + +/** + * @author gongbiao + */ +public class WxProfitSharingOrderVo implements Serializable { + private static final long serialVersionUID = 1L; + + private Long id; + private String tenantId; + private Long merchantId; + private String merchantName; + private Long orderId; + private Integer payAmount; + private Date payTimeEnd; + private Date payTimeStart; + private String transactionId; + private String sharingOrderNo; + private Integer type; + private String receivers; + private String errorMsg; + private Integer sharingStatus; + private Date updateTime; + private Date createTime; + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getTenantId() { + return tenantId; + } + + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + public Long getMerchantId() { + return merchantId; + } + + public void setMerchantId(Long merchantId) { + this.merchantId = merchantId; + } + + public String getMerchantName() { + return merchantName; + } + + public void setMerchantName(String merchantName) { + this.merchantName = merchantName; + } + + public Long getOrderId() { + return orderId; + } + + public void setOrderId(Long orderId) { + this.orderId = orderId; + } + + public Integer getPayAmount() { + return payAmount; + } + + public void setPayAmount(Integer payAmount) { + this.payAmount = payAmount; + } + + public Date getPayTimeEnd() { + return payTimeEnd; + } + + public void setPayTimeEnd(Date payTimeEnd) { + this.payTimeEnd = payTimeEnd; + } + + public Date getPayTimeStart() { + return payTimeStart; + } + + public void setPayTimeStart(Date payTimeStart) { + this.payTimeStart = payTimeStart; + } + + public String getTransactionId() { + return transactionId; + } + + public void setTransactionId(String transactionId) { + this.transactionId = transactionId; + } + + public String getSharingOrderNo() { + return sharingOrderNo; + } + + public void setSharingOrderNo(String sharingOrderNo) { + this.sharingOrderNo = sharingOrderNo; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public String getReceivers() { + return receivers; + } + + public void setReceivers(String receivers) { + this.receivers = receivers; + } + + public String getErrorMsg() { + return errorMsg; + } + + public void setErrorMsg(String errorMsg) { + this.errorMsg = errorMsg; + } + + public Integer getSharingStatus() { + return sharingStatus; + } + + public void setSharingStatus(Integer sharingStatus) { + this.sharingStatus = sharingStatus; + } + + public Date getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Date updateTime) { + this.updateTime = updateTime; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } +} diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxProfitSharingOrderMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxProfitSharingOrderMapper.java index 861d943bf..07466463a 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxProfitSharingOrderMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxProfitSharingOrderMapper.java @@ -1,16 +1,24 @@ package com.iformall.mapper; -import java.util.*; import com.iformall.common.CommonMapper; import com.iformall.domain.po.WxProfitSharingOrder; +import com.iformall.domain.vo.WxProfitSharingOrderDetailsVo; +import com.iformall.domain.vo.WxProfitSharingOrderQueryVo; +import com.iformall.domain.vo.WxProfitSharingOrderVo; + +import java.util.List; +import java.util.Map; public interface WxProfitSharingOrderMapper extends CommonMapper { List findList(WxProfitSharingOrder wxProfitSharingOrder); - - - - - + List findOrderList(WxProfitSharingOrderQueryVo order); + + Long queryOrderForSum(Map params); + + Long queryOrderForMerchantCount(Map params); + + List findOrderDetails(Long id); + } diff --git a/mallinkService/src/main/java/com/iformall/service/WxProfitSharingOrderService.java b/mallinkService/src/main/java/com/iformall/service/WxProfitSharingOrderService.java index 9f02a7a46..a9ce9ea40 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxProfitSharingOrderService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxProfitSharingOrderService.java @@ -1,23 +1,36 @@ package com.iformall.service; +import com.github.pagehelper.PageInfo; import com.iformall.common.ResultData; import com.iformall.domain.dto.WxSharingOrderDto; import com.iformall.domain.po.WxProfitSharingOrder; +import com.iformall.domain.vo.WxProfitSharingOrderQueryVo; +import com.iformall.domain.vo.WxProfitSharingOrderVo; + +import java.util.Map; + public interface WxProfitSharingOrderService { /** * 创建分账订单 */ - public ResultData createSharingOrder(WxSharingOrderDto wxSharingOrderDto); + ResultData createSharingOrder(WxSharingOrderDto wxSharingOrderDto); /** * 查询分账订单 */ - public ResultData querySharingOrder(WxProfitSharingOrder sharingOrderDto); + ResultData querySharingOrder(WxProfitSharingOrder sharingOrderDto); /** * 结束分账订单 */ - public ResultData finishSharingOrder(WxSharingOrderDto sharingOrderDto); + ResultData finishSharingOrder(WxSharingOrderDto sharingOrderDto); + + PageInfo listAsPage(WxProfitSharingOrderQueryVo order, Integer pageNum, Integer pageSize); + + Map queryOrderSummary(String tenantId); + + ResultData findOrderDetails(Long id); + } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingOrderServiceImpl.java index b5e8b601e..ffb91b394 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxProfitSharingOrderServiceImpl.java @@ -1,31 +1,38 @@ package com.iformall.service.impl; -import java.util.*; - import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; import com.iformall.common.ErrorCode; +import com.iformall.common.IdWorker; import com.iformall.common.ResultData; import com.iformall.domain.dto.WxSharingOrderDto; import com.iformall.domain.po.*; +import com.iformall.domain.vo.WxProfitSharingOrderDetailsVo; +import com.iformall.domain.vo.WxProfitSharingOrderQueryVo; +import com.iformall.domain.vo.WxProfitSharingOrderVo; import com.iformall.enums.*; import com.iformall.exception.MallinkException; import com.iformall.mapper.*; import com.iformall.pay.*; import com.iformall.service.WxProfitSharingOrderService; import com.iformall.utils.BeanUtils; +import com.iformall.utils.DateUtils; import com.iformall.utils.Utility; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import com.iformall.common.IdWorker; import org.springframework.transaction.annotation.Isolation; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; +import java.math.BigDecimal; +import java.util.*; + @Service public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderService { @@ -490,4 +497,116 @@ public class WxProfitSharingOrderServiceImpl implements WxProfitSharingOrderServ wxProfitSharingOrderMapper.updateByPrimaryKey(record); return new ResultData(returnMap); } + + @Override + public PageInfo listAsPage(WxProfitSharingOrderQueryVo order, Integer pageIndex, Integer pageSize) { + return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxProfitSharingOrderMapper.findOrderList(order)); + + } + + @Override + public Map queryOrderSummary(String tenantId) { + Map result = new HashMap<>(); + queryMerchantCount(tenantId, result); + queryOrderSummary(tenantId,result); + return result; + } + + @Override + public ResultData findOrderDetails(Long id) { + Map result=new HashMap<>(2); + WxProfitSharingOrderQueryVo wxProfitSharingOrderQueryVo = new WxProfitSharingOrderQueryVo(); + wxProfitSharingOrderQueryVo.setId(id); + WxProfitSharingOrderVo wxProfitSharingOrderVo = wxProfitSharingOrderMapper.findOrderList(wxProfitSharingOrderQueryVo).get(0); + List orderDetails = wxProfitSharingOrderMapper.findOrderDetails(id); + result.put("order",wxProfitSharingOrderVo); + result.put("details",orderDetails); + return new ResultData(result); + } + + public void queryMerchantCount(String tenantId, Map result) { + //全部商户个数 + Map params = new HashMap<>(); + params.put("tenantId", tenantId); + Long allMerchantCount=wxProfitSharingOrderMapper.queryOrderForMerchantCount(params); + result.put("allMerchantCount",allMerchantCount); + //今日 + String systemTime = DateUtils.getSystemTime("yyyy-MM-dd"); + params.put("startdate", systemTime + " 00:00:00"); + params.put("enddate", systemTime + " 23:59:59"); + Long todayMerchantCount=wxProfitSharingOrderMapper.queryOrderForMerchantCount(params); + result.put("todayMerchantCount",todayMerchantCount); + //昨日 + String yesterday = DateUtils.getTimeBefore(1, new Date()); + params.put("startdate", yesterday + " 00:00:00"); + params.put("enddate", yesterday + " 23:59:59"); + Long yesterdayMerchantCount=wxProfitSharingOrderMapper.queryOrderForMerchantCount(params); + result.put("yesterdayMerchantCount",yesterdayMerchantCount); + //上周 + String lastweek = DateUtils.getTimeBefore(7, new Date()); + params.put("startdate", lastweek + " 00:00:00"); + params.put("enddate", lastweek + " 23:59:59"); + Long lastweekMerchantCount=wxOrderMapper.queryOrderForMerchantCount(params); + result.put("lastweekMerchantCount",lastweekMerchantCount); + //商户数日环比 + if (yesterdayMerchantCount > 0) { + double hbd = (double) (todayMerchantCount - yesterdayMerchantCount) / yesterdayMerchantCount * 100; + double hb = new BigDecimal(hbd).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + result.put("increasedPercentMerchant", hb+"%"); + } else { + result.put("increasedPercentMerchant", "--"); + } + //商户数周同比 + if (lastweekMerchantCount > 0) { + double hbd = (double) (todayMerchantCount - lastweekMerchantCount) / lastweekMerchantCount * 100; + double hb = new BigDecimal(hbd).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + result.put("increasedPercentWeekMerchant", hb+"%"); + } else { + result.put("increasedPercentWeekMerchant", "--"); + } + } + + public void queryOrderSummary(String tenantId, Map result) { + //全部商户个数 + Map params = new HashMap<>(); + params.put("tenantId", tenantId); + Long allOrderSummary=wxProfitSharingOrderMapper.queryOrderForSum(params); + result.put("allOrderSummary",allOrderSummary); + //今日 + String systemTime = DateUtils.getSystemTime("yyyy-MM-dd"); + params.put("startdate", systemTime + " 00:00:00"); + params.put("enddate", systemTime + " 23:59:59"); + Long todayOrderSummary=wxProfitSharingOrderMapper.queryOrderForSum(params); + result.put("todayOrderSummary",todayOrderSummary); + //昨日 + String yesterday = DateUtils.getTimeBefore(1, new Date()); + params.put("startdate", yesterday + " 00:00:00"); + params.put("enddate", yesterday + " 23:59:59"); + Long yesterdayOrderSummary=wxProfitSharingOrderMapper.queryOrderForSum(params); + result.put("yesterdayOrderSummary",yesterdayOrderSummary); + //上周 + String lastweek = DateUtils.getTimeBefore(7, new Date()); + params.put("startdate", lastweek + " 00:00:00"); + params.put("enddate", lastweek + " 23:59:59"); + Long lastweekOrderSummary=wxProfitSharingOrderMapper.queryOrderForSum(params); + result.put("lastweekOrderSummary",lastweekOrderSummary); + //商户数日环比 + if (yesterdayOrderSummary > 0) { + double hbd = (double) (todayOrderSummary - yesterdayOrderSummary) / yesterdayOrderSummary * 100; + double hb = new BigDecimal(hbd).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + result.put("increasedPercentSummary", hb+"%"); + } else { + result.put("increasedPercentSummary", "--"); + } + //商户数周同比 + if (lastweekOrderSummary > 0) { + double hbd = (double) (todayOrderSummary - lastweekOrderSummary) / lastweekOrderSummary * 100; + double hb = new BigDecimal(hbd).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); + result.put("increasedPercentWeekSummary", hb+"%"); + } else { + result.put("increasedPercentWeekSummary", "--"); + } + } + + } diff --git a/mallinkService/src/main/resources/mapper/WxOrderMapper.xml b/mallinkService/src/main/resources/mapper/WxOrderMapper.xml index 2ec1bfb2a..ec5d0af0c 100644 --- a/mallinkService/src/main/resources/mapper/WxOrderMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxOrderMapper.xml @@ -269,12 +269,14 @@ + + o.`id`,o.`order_number`,o.`tenant_id`,o.`c_user_id`,o.`product_id`,o.`type`, o.`payment_type`,o.`payment`,o.`payment_time`,o.`order_status`,o.`create_date`,o.`update_date`,o.`detail`, - m.name as merchant_name, bu.name, bu.phone as bphone, cu.phone + m.name as merchant_name, bu.name, bu.phone as bphone, cu.phone,cu.`name` c_user_name + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +