| @@ -3,6 +3,7 @@ package com.iformall.controller; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.dto.WxOrderReportDto; | |||
| import com.iformall.domain.vo.WxMerchantMicroPayVo; | |||
| import com.iformall.domain.vo.WxMerchantTradeDailyVo; | |||
| import com.iformall.enums.EnumOrderType; | |||
| import com.iformall.service.MarkingDataReportService; | |||
| @@ -14,10 +15,7 @@ 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; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.text.SimpleDateFormat; | |||
| import java.util.Calendar; | |||
| @@ -31,18 +29,35 @@ public class WxMerchantMicroPayController extends BaseController { | |||
| @Autowired | |||
| private MarkingDataReportService markingDataReportService; | |||
| @ApiOperation("查询触达用户数数据列表") | |||
| @GetMapping("/listOrderMicroPayReportByDate") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public ResultData listOrderMicroPayReportByDate(@ModelAttribute WxOrderReportDto wxOrderReportDto, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantMicroPayController::listOrderMicroPayReportByDate"); | |||
| if (wxOrderReportDto == null){ | |||
| wxOrderReportDto = new WxOrderReportDto(); | |||
| } | |||
| @ApiOperation("获得商场近30日刷卡") | |||
| @GetMapping("/listMonth") | |||
| public ResultData listMonth() { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantMicroPayController::listMonth"); | |||
| WxOrderReportDto wxOrderReportDto = new WxOrderReportDto(); | |||
| wxOrderReportDto.setTenantId(getTenantId()); | |||
| wxOrderReportDto.setType(EnumOrderType.MICROPAY.getCode()); | |||
| return new ResultData(markingDataReportService.listOrderReportByDate(getTenantId(), wxOrderReportDto, pageNum, pageSize)); | |||
| return new ResultData(markingDataReportService.listOrderReportByDate(wxOrderReportDto)); | |||
| } | |||
| @ApiOperation("获商户得近30日刷卡") | |||
| @GetMapping("/detail") | |||
| public ResultData detail(@RequestParam Long merchantId) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantMicroPayController::detail"); | |||
| WxOrderReportDto wxOrderReportDto = new WxOrderReportDto(); | |||
| wxOrderReportDto.setTenantId(getTenantId()); | |||
| wxOrderReportDto.setMerchantId(merchantId); | |||
| return new ResultData(markingDataReportService.listMicroPayOrderReportByDateAndMerchant(wxOrderReportDto)); | |||
| } | |||
| @ApiOperation("获得昨日刷卡列表") | |||
| @GetMapping("/listYesterday") | |||
| public ResultData listYesterday(Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantTradeDailyController::listYesterday"); | |||
| WxOrderReportDto wxOrderReportDto = new WxOrderReportDto(); | |||
| wxOrderReportDto.setTenantId(getTenantId()); | |||
| final PageInfo<WxMerchantMicroPayVo> page = markingDataReportService.listMerchantMicroPayOrderReportByDate(wxOrderReportDto, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| } | |||
| @@ -46,14 +46,14 @@ public class WxMerchantTradeDailyController extends BaseController { | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("获得近30日解单") | |||
| @ApiOperation("获商户得近30日解单") | |||
| @GetMapping("/detail") | |||
| public ResultData detail(Long merchantId) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantTradeDailyController::detail"); | |||
| return wxMerchantTradeDailyService.getVolumeOfMonth(merchantId); | |||
| } | |||
| @ApiOperation("获得昨日解单列表") | |||
| @ApiOperation("获得商场近30日解单") | |||
| @GetMapping("/listMonth") | |||
| public ResultData listMonth() { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantTradeDailyController::listMonth"); | |||
| @@ -6,10 +6,28 @@ import java.util.Date; | |||
| * Created by syf on 2018/8/30. | |||
| */ | |||
| public class WxOrderReportDto { | |||
| private String tenantId; | |||
| private Long merchantId; | |||
| private Date startTime; | |||
| private Date endTime; | |||
| private Integer type; | |||
| 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 Integer getType() { | |||
| return type; | |||
| } | |||
| @@ -0,0 +1,72 @@ | |||
| package com.iformall.domain.vo; | |||
| import javax.persistence.Id; | |||
| import java.io.Serializable; | |||
| public class WxMerchantMicroPayVo implements Serializable { | |||
| private static final long serialVersionUID = 1L; | |||
| @Id | |||
| protected Long id; | |||
| /*租户ID**/ | |||
| @io.swagger.annotations.ApiModelProperty(value = "租户ID", name = "tenantId") | |||
| private String tenantId; | |||
| /*商户id**/ | |||
| @io.swagger.annotations.ApiModelProperty(value = "商户id", name = "merchantId") | |||
| private Long merchantId; | |||
| /*交易额**/ | |||
| @io.swagger.annotations.ApiModelProperty(value = "交易额", name = "tradeAmt") | |||
| private Integer tradeAmt; | |||
| /*日期**/ | |||
| @io.swagger.annotations.ApiModelProperty(value = "解单日期", name = "reportDate") | |||
| private String reportDate; | |||
| /*商户名**/ | |||
| @io.swagger.annotations.ApiModelProperty(value="商户名",name="merchantName") | |||
| private String merchantName; | |||
| public String getMerchantName() { | |||
| return merchantName; | |||
| } | |||
| public void setMerchantName(String merchantName) { | |||
| this.merchantName = merchantName; | |||
| } | |||
| public String getTenantId() { | |||
| return tenantId; | |||
| } | |||
| public void setTenantId(String _tenantId) { | |||
| tenantId = _tenantId; | |||
| } | |||
| public Long getMerchantId() { | |||
| return merchantId; | |||
| } | |||
| public void setMerchantId(Long _merchantId) { | |||
| merchantId = _merchantId; | |||
| } | |||
| public Integer getTradeAmt() { | |||
| return tradeAmt; | |||
| } | |||
| public void setTradeAmt(Integer _tradeAmt) { | |||
| tradeAmt = _tradeAmt; | |||
| } | |||
| public String getReportDate() { | |||
| return reportDate; | |||
| } | |||
| public void setReportDate(String _reportDate) { | |||
| reportDate = _reportDate; | |||
| } | |||
| } | |||
| @@ -28,6 +28,10 @@ public interface WxOrderMapper extends CommonMapper<WxOrder, Long> { | |||
| List<WxOrderReportVo> listOrderReportByDate(HashMap<String,Object> params); | |||
| List<WxOrderReportVo> listMicroPayOrderReportByDateAndMerchant(HashMap<String,Object> params); | |||
| List<WxMerchantMicroPayVo> findListOfMerchantMicroPayOrderByDate(HashMap<String,Object> params); | |||
| List<WxOrder> findListOrder(WxOrderQueryVo record); | |||
| Long queryOrderForMerchantCount(Map<String,Object> params); | |||
| @@ -3,9 +3,7 @@ package com.iformall.service; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.domain.dto.MarkingCouponDataReportDto; | |||
| import com.iformall.domain.dto.WxOrderReportDto; | |||
| import com.iformall.domain.vo.MarkingCouponDataReportVo; | |||
| import com.iformall.domain.vo.MarkingSceneDataVo; | |||
| import com.iformall.domain.vo.TouchUsersReportVo; | |||
| import com.iformall.domain.vo.*; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| @@ -26,5 +24,11 @@ public interface MarkingDataReportService { | |||
| List<TouchUsersReportVo> getTouchUsersReportData(String tenantId); | |||
| Map<String, Object> listOrderReportByDate(String tenantId, WxOrderReportDto wxOrderReportDto, Integer pageIndex, Integer pageSize); | |||
| Map<String, Object> listOrderReportByDate(WxOrderReportDto wxOrderReportDto); | |||
| List<WxOrderReportVo> listMicroPayOrderReportByDateAndMerchant(WxOrderReportDto wxOrderReportDto); | |||
| PageInfo<WxMerchantMicroPayVo> listMerchantMicroPayOrderReportByDate(WxOrderReportDto wxOrderReportDto,Integer pageNum, Integer pageSize); | |||
| } | |||
| @@ -377,9 +377,9 @@ public class MarkingDataReportServiceImpl implements MarkingDataReportService { | |||
| @Override | |||
| public Map<String, Object> listOrderReportByDate(String tenantId, WxOrderReportDto wxOrderReportDto, Integer pageIndex, Integer pageSize) { | |||
| public Map<String, Object> listOrderReportByDate(WxOrderReportDto wxOrderReportDto) { | |||
| HashMap<String, Object> params = new HashMap<>(); | |||
| params.put("tenantId", tenantId); | |||
| params.put("tenantId", wxOrderReportDto.getTenantId()); | |||
| if (wxOrderReportDto.getStartTime() != null) { | |||
| params.put("startTime", convertDateAndAdd(wxOrderReportDto.getStartTime(), 0)); | |||
| } else { | |||
| @@ -463,6 +463,62 @@ public class MarkingDataReportServiceImpl implements MarkingDataReportService { | |||
| return returnMap; | |||
| } | |||
| @Override | |||
| public List<WxOrderReportVo> listMicroPayOrderReportByDateAndMerchant(WxOrderReportDto wxOrderReportDto) { | |||
| HashMap<String, Object> params = new HashMap<>(); | |||
| params.put("merchantId", wxOrderReportDto.getMerchantId()); | |||
| if (wxOrderReportDto.getStartTime() != null) { | |||
| params.put("startTime", convertDateAndAdd(wxOrderReportDto.getStartTime(), 0)); | |||
| } else { | |||
| params.put("startTime", addDay(-30)); | |||
| } | |||
| if (wxOrderReportDto.getEndTime() != null) { | |||
| params.put("endTime", convertDateAndAdd(wxOrderReportDto.getStartTime(), 0)); | |||
| } else { | |||
| params.put("endTime", addDay(1)); | |||
| } | |||
| List<WxOrderReportVo> list = wxOrderMapper.listMicroPayOrderReportByDateAndMerchant(params); | |||
| String startdate = DateUtils.getTimeBefore(30, new Date()); | |||
| String enddate = DateUtils.getTimeBefore(0,new Date()); | |||
| List<String> tjTimeList = DateUtils.getTjTimeList(startdate, enddate, "0"); | |||
| List<WxOrderReportVo> wxOrderReportVoList = new ArrayList<WxOrderReportVo>(); | |||
| for(String tj:tjTimeList){ | |||
| Optional<WxOrderReportVo> first = list.stream().filter(c -> c.getxTime().equals(tj)).findFirst(); | |||
| if(!first.isPresent()){ | |||
| WxOrderReportVo orderReportVo = new WxOrderReportVo(); | |||
| orderReportVo.setAmount(0); | |||
| orderReportVo.setCount(0); | |||
| first = Optional.of(orderReportVo); | |||
| } | |||
| first.get().setxTime(tj.substring(5).replace("-", "/")); | |||
| wxOrderReportVoList.add(first.get()); | |||
| } | |||
| return wxOrderReportVoList; | |||
| } | |||
| @Override | |||
| public PageInfo<WxMerchantMicroPayVo> listMerchantMicroPayOrderReportByDate(WxOrderReportDto wxOrderReportDto,Integer pageIndex, Integer pageSize) { | |||
| HashMap<String, Object> params = new HashMap<>(); | |||
| if (wxOrderReportDto.getStartTime() != null) { | |||
| params.put("startTime", convertDateAndAdd(wxOrderReportDto.getStartTime(), 0)); | |||
| } else { | |||
| params.put("startTime", addDay(-1)); | |||
| } | |||
| if (wxOrderReportDto.getEndTime() != null) { | |||
| params.put("endTime", convertDateAndAdd(wxOrderReportDto.getStartTime(), 0)); | |||
| } else { | |||
| params.put("endTime", addDay(0)); | |||
| } | |||
| PageHelper.startPage(pageIndex, pageSize); | |||
| List<WxMerchantMicroPayVo> list = wxOrderMapper.findListOfMerchantMicroPayOrderByDate(params); | |||
| return new PageInfo<>(list); | |||
| } | |||
| @Override | |||
| public PageInfo<TouchUsersReportVo> getTouchUsersReportList(String tenantId, MarkingCouponDataReportDto markingCouponDataReportDto, Integer pageIndex, Integer pageSize) { | |||
| @@ -276,7 +276,7 @@ | |||
| <sql id="allPayOrderColumns"> | |||
| 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,cu.`name` c_user_name | |||
| m.name as merchant_name, bu.name, bu.phone as bphone, cu.phone,cu.`nick_name` c_user_name | |||
| </sql> | |||
| <select id="findListOfMicroPayOrderByDate" parameterType="map" resultMap="PayVoResultMap"> | |||
| @@ -324,6 +324,57 @@ | |||
| </if> | |||
| group by xTime | |||
| </select> | |||
| <select id="listMicroPayOrderReportByDateAndMerchant" resultType="com.iformall.domain.vo.WxOrderReportVo" parameterType="hashmap"> | |||
| select DATE_FORMAT(o.create_date,'%Y-%m-%d') xTime, count(o.id) count, IFNULL (SUM(o.payment),0) amount | |||
| from wx_order o | |||
| inner join wx_merchant_b_user bu on bu.id = o.product_id | |||
| inner join wx_merchant m on m.id = bu.merchant_id | |||
| where m.`id` = #{merchantId} and o.`type` = 1 | |||
| <if test=" null != startTime and null != endTime"> | |||
| and o.`create_date` BETWEEN #{startTime} and #{endTime} | |||
| </if> | |||
| group by xTime | |||
| </select> | |||
| <resultMap id="WxMerchantMicroPayVo" type="com.iformall.domain.vo.WxMerchantMicroPayVo"> | |||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||
| <result column="trade_amt" jdbcType="DECIMAL" property="tradeAmt" /> | |||
| <result column="report_date" jdbcType="VARCHAR" property="reportDate" /> | |||
| <result column="merchant_name" jdbcType="VARCHAR" property="merchantName" /> | |||
| </resultMap> | |||
| <sql id="WxMerchantMicroPayColumnsVo"> | |||
| m.id as id, | |||
| m.tenant_id as tenant_id, | |||
| m.name as merchant_name, | |||
| (case when mo.amount > 0 then mo.amount else 0 end) trade_amt | |||
| </sql> | |||
| <select id="findListOfMerchantMicroPayOrderByDate" parameterType="map" resultMap="WxMerchantMicroPayVo"> | |||
| select | |||
| <include refid="WxMerchantMicroPayColumnsVo"/> | |||
| from wx_merchant m | |||
| left join | |||
| (select m.id as mid, IFNULL(sum(o.payment),0) amount | |||
| from wx_merchant m, wx_order o, wx_merchant_b_user bu | |||
| where bu.id = o.product_id | |||
| and m.status = 1 | |||
| and m.id = bu.merchant_id | |||
| and o.order_status = '1' | |||
| and o.type = 1 | |||
| <if test="startDate != null"> | |||
| AND o.create_date > #{startDate,jdbcType=TIMESTAMP} | |||
| </if> | |||
| <if test="endDate != null"> | |||
| AND o.create_date < #{endDate,jdbcType=TIMESTAMP} | |||
| </if> | |||
| group by m.id) mo on mo.mid = m.id | |||
| where m.status = 1 | |||
| order by m.create_date desc | |||
| </select> | |||
| <resultMap id="orderMap" type="com.iformall.domain.po.WxOrder"> | |||
| <id column="id" jdbcType="BIGINT" property="id"/> | |||