| @@ -0,0 +1,5 @@ | |||
| ALTER TABLE wx_merchant_trade_daily | |||
| ADD COLUMN trade_count int(10) DEFAULT 0 COMMENT ''交易笔数''; | |||
| ALTER TABLE wx_merchant_trade_daily | |||
| ADD COLUMN proof varchar(500) DEFAULT NULL COMMENT ''凭证''; | |||
| @@ -1,16 +1,16 @@ | |||
| package com.iformall.controller; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxMerchantTradeDaily; | |||
| import com.iformall.service.WxMerchantTradeDailyService; | |||
| 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.RequestMapping; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| import org.springframework.web.bind.annotation.*; | |||
| @RestController | |||
| @RequestMapping("/api/wxMerchantTradeDaily") | |||
| @@ -41,5 +41,44 @@ public class WxMerchantTradeDailyController extends BaseController { | |||
| return wxMerchantTradeDailyService.saveDailyTradingVolume(getUser().getId(), volume); | |||
| } | |||
| /** | |||
| * 详情 | |||
| * @param wxMerchantTradeDaily | |||
| * @return | |||
| */ | |||
| @ApiOperation("详情") | |||
| @GetMapping("findById") | |||
| public ResultData findById(WxMerchantTradeDaily wxMerchantTradeDaily) { | |||
| logger.debug("[" + getIpAddr() + "] wxMerchantTradeDaily::findById"); | |||
| String tenantId = getTenantId(); | |||
| wxMerchantTradeDaily.setTenantId(tenantId); | |||
| return new ResultData(wxMerchantTradeDailyService.getById(wxMerchantTradeDaily.getId())); | |||
| } | |||
| /** | |||
| * 保存或编辑 | |||
| * @param wxMerchantTradeDaily | |||
| * @return | |||
| */ | |||
| @ApiOperation("保存或编辑") | |||
| @PostMapping("saveOrUpdate") | |||
| public ResultData saveOrUpdate(@RequestBody WxMerchantTradeDaily wxMerchantTradeDaily) { | |||
| logger.debug("[" + getIpAddr() + "] wxMerchantTradeDaily::saveOrUpdate"); | |||
| wxMerchantTradeDaily.setTenantId(super.getTenantId()); | |||
| wxMerchantTradeDailyService.saveOrUpdate(wxMerchantTradeDaily); | |||
| return new ResultData(); | |||
| } | |||
| /** | |||
| * 列表 | |||
| * @param wxMerchantTradeDaily | |||
| * @return | |||
| */ | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public ResultData list(WxMerchantTradeDaily wxMerchantTradeDaily, Integer pageNum, Integer pageSize) { | |||
| return new ResultData(wxMerchantTradeDailyService.listAsPage(wxMerchantTradeDaily, pageNum,pageSize)); | |||
| } | |||
| } | |||
| @@ -61,6 +61,28 @@ public class WxMerchantTradeDaily implements Serializable { | |||
| /*解单日期**/ | |||
| @io.swagger.annotations.ApiModelProperty(value = "解单日期", name = "reportDate") | |||
| private String reportDate; | |||
| /*交易笔数**/ | |||
| @io.swagger.annotations.ApiModelProperty(value = "交易笔数", name = "tradeCount") | |||
| private String tradeCount; | |||
| /*凭证**/ | |||
| @io.swagger.annotations.ApiModelProperty(value = "凭证", name = "proof") | |||
| private String proof; | |||
| public String getTradeCount() { | |||
| return tradeCount; | |||
| } | |||
| public void setTradeCount(String tradeCount) { | |||
| this.tradeCount = tradeCount; | |||
| } | |||
| public String getProof() { | |||
| return proof; | |||
| } | |||
| public void setProof(String proof) { | |||
| this.proof = proof; | |||
| } | |||
| public String getTenantId() { | |||
| return tenantId; | |||
| @@ -331,27 +331,38 @@ public class WxChartServiceImpl implements WxChartDataService { | |||
| WxShop query = new WxShop(); | |||
| query.setTenantId(tenantId); | |||
| List<WxShop> allList = wxShopMapper.findList(query); | |||
| queryMap.put("allCount",allList.size()); | |||
| List<Map<String,Object>> mapList = wxShopMapper.rentRateHistory(queryMap); | |||
| if(CollectionUtils.isNotEmpty(mapList)){ | |||
| String startTime = (String)mapList.get(0).get("xTime"); | |||
| String endTime = (String)mapList.get(mapList.size()-1).get("xTime"); | |||
| List<String> days = DateUtils.getTjTimeList(startTime, endTime, 1==dateType.intValue()?"0":"1"); | |||
| Map<String,String> map = getMap(days); | |||
| Map<String,Long> map = getMap(days); | |||
| for (Map<String,Object> m : mapList) { | |||
| String r = m.get("rate").toString(); | |||
| map.put((String)m.get("xTime"),"0.00".equals(r)?"0":r +"%"); | |||
| map.put((String)m.get("xTime"),(Long)m.get("xCount")); | |||
| } | |||
| return new ResultData(map); | |||
| double all = allList.size(); | |||
| Map<String,String> resultMap = new LinkedMap(); | |||
| double rentTotal = 0; | |||
| for (String key : map.keySet()) { | |||
| resultMap.put(key,formatDouble(rentTotal/all*100)+"%"); | |||
| } | |||
| return new ResultData(resultMap); | |||
| } | |||
| return new ResultData(new LinkedHashMap<>()); | |||
| return new ResultData(new HashMap<>()); | |||
| } | |||
| public static void main(String[] args) { | |||
| double a = 8; | |||
| double b = 9; | |||
| System.out.println(a/b); | |||
| } | |||
| public Map<String,String> getMap(List<String> days){ | |||
| Map<String,String> map = new LinkedMap(); | |||
| public Map<String,Long> getMap(List<String> days){ | |||
| Map<String,Long> map = new LinkedMap(); | |||
| for (String d:days) { | |||
| map.put(d.replace("-", "/"),"0%"); | |||
| map.put(d.replace("-", "/"),0l); | |||
| } | |||
| return map; | |||
| } | |||
| @@ -10,10 +10,12 @@ | |||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | |||
| <result column="report_date" jdbcType="VARCHAR" property="reportDate" /> | |||
| <result column="trade_count" property="tradeCount" /> | |||
| <result column="proof" property="proof"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`merchant_id`,`b_user_id`,`trade_amt`,`create_date`,`update_date`,`report_date` | |||
| `id`,`tenant_id`,`merchant_id`,`b_user_id`,`trade_amt`,`create_date`,`update_date`,`report_date`,trade_count,proof | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -63,6 +65,7 @@ | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||
| <if test=" null == sortColumns"> order by create_date desc </if> | |||
| </sql> | |||
| <select id="findList" parameterType="com.iformall.domain.po.WxMerchantTradeDaily" resultMap="BaseResultMap"> | |||
| @@ -566,15 +566,15 @@ | |||
| <select id="rentRateHistory" resultType="hashmap" parameterType="hashmap"> | |||
| select | |||
| <if test="1 == dateType"> | |||
| DATE_FORMAT(wm.create_date,'%Y/%m/%d') xTime | |||
| DATE_FORMAT(w.create_date,'%Y/%m/%d') xTime | |||
| </if> | |||
| <if test="2 == dateType"> | |||
| DATE_FORMAT(wm.create_date,'%Y/%m') xTime | |||
| DATE_FORMAT(w.create_date,'%Y/%m') xTime | |||
| </if> | |||
| ,round(count(status = 1 or null)/#{allCount} *100/100,2) rate | |||
| from wx_shop w inner join wx_merchant_shop wm on wm.shop_id = w.id | |||
| ,count(distinct w.shop_id) xCount | |||
| from wx_merchant_shop w | |||
| where w.is_del=0 | |||
| and w.tenant_id = #{tenantId} | |||
| and w.tenant_id = 456 | |||
| group by xTime | |||
| order by xTime | |||
| </select> | |||