| @@ -16,7 +16,7 @@ import io.swagger.annotations.ApiImplicitParams; | |||||
| import io.swagger.annotations.ApiOperation; | import io.swagger.annotations.ApiOperation; | ||||
| @RestController | @RestController | ||||
| @RequestMapping("wxMerchantTradeDaily") | |||||
| @RequestMapping("/api/wxMerchantTradeDaily") | |||||
| public class WxMerchantTradeDailyController extends BaseController | public class WxMerchantTradeDailyController extends BaseController | ||||
| { | { | ||||
| @Autowired | @Autowired | ||||
| @@ -65,6 +65,13 @@ public class WxMerchantTradeDailyController extends BaseController | |||||
| public ResultData findById(Long id) { | public ResultData findById(Long id) { | ||||
| return new ResultData(Result.SUCCESS,"查询成功",wxMerchantTradeDailyService.getById(id)); | return new ResultData(Result.SUCCESS,"查询成功",wxMerchantTradeDailyService.getById(id)); | ||||
| } | } | ||||
| @ApiOperation("上报每日解单") | |||||
| @GetMapping("/reportDailyVolume") | |||||
| @ApiImplicitParam(name="volume",value="总金额(分)",dataType="Integer", paramType = "query",required=true) | |||||
| public ResultData saveDailyTradingVolume(Integer volume) { | |||||
| return wxMerchantTradeDailyService.saveDailyTradingVolume(getUser().getId(),volume); | |||||
| } | |||||
| @@ -49,10 +49,17 @@ public class WxMerchantTradeDaily implements Serializable { | |||||
| private Long merchantId; | private Long merchantId; | ||||
| /*交易额**/ | /*交易额**/ | ||||
| @io.swagger.annotations.ApiModelProperty(value="交易额",name="tradeAmt") | @io.swagger.annotations.ApiModelProperty(value="交易额",name="tradeAmt") | ||||
| private BigDecimal tradeAmt; | |||||
| /*解单日期**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="解单日期",name="createDate") | |||||
| private Integer tradeAmt; | |||||
| /*提交日期**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="解单提交日期",name="createDate") | |||||
| private Date createDate; | private Date createDate; | ||||
| /*更新日期**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="解单更新日期",name="updateDate") | |||||
| private Date updateDate; | |||||
| /*解单日期**/ | |||||
| @io.swagger.annotations.ApiModelProperty(value="解单日期",name="reportDate") | |||||
| private String reportDate; | |||||
| public String getTenantId() { | public String getTenantId() { | ||||
| return tenantId; | return tenantId; | ||||
| } | } | ||||
| @@ -65,10 +72,10 @@ public class WxMerchantTradeDaily implements Serializable { | |||||
| public void setMerchantId(Long _merchantId) { | public void setMerchantId(Long _merchantId) { | ||||
| merchantId = _merchantId; | merchantId = _merchantId; | ||||
| } | } | ||||
| public BigDecimal getTradeAmt() { | |||||
| public Integer getTradeAmt() { | |||||
| return tradeAmt; | return tradeAmt; | ||||
| } | } | ||||
| public void setTradeAmt(BigDecimal _tradeAmt) { | |||||
| public void setTradeAmt(Integer _tradeAmt) { | |||||
| tradeAmt = _tradeAmt; | tradeAmt = _tradeAmt; | ||||
| } | } | ||||
| public Date getCreateDate() { | public Date getCreateDate() { | ||||
| @@ -77,6 +84,19 @@ public class WxMerchantTradeDaily implements Serializable { | |||||
| public void setCreateDate(Date _createDate) { | public void setCreateDate(Date _createDate) { | ||||
| createDate = _createDate; | createDate = _createDate; | ||||
| } | } | ||||
| public Date getUpdateDate() { | |||||
| return updateDate; | |||||
| } | |||||
| public void setUpdateDate(Date _updateDate) { | |||||
| updateDate = _updateDate; | |||||
| } | |||||
| public String getReportDate() { | |||||
| return reportDate; | |||||
| } | |||||
| public void setReportDate(String _reportDate) { | |||||
| reportDate = _reportDate; | |||||
| } | |||||
| @@ -2,6 +2,7 @@ package com.simple.service; | |||||
| import java.util.*; | import java.util.*; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.simple.common.ResultData; | |||||
| import com.simple.domain.po.WxMerchantTradeDaily; | import com.simple.domain.po.WxMerchantTradeDaily; | ||||
| public interface WxMerchantTradeDailyService { | public interface WxMerchantTradeDailyService { | ||||
| @@ -37,9 +38,16 @@ public interface WxMerchantTradeDailyService { | |||||
| * @param id | * @param id | ||||
| */ | */ | ||||
| void deleteById(Long id); | void deleteById(Long id); | ||||
| /** | |||||
| * 根据Id删除实体 | |||||
| * | |||||
| * @param id | |||||
| * @param volume | |||||
| */ | |||||
| public ResultData saveDailyTradingVolume(Long userId, Integer volume); | |||||
| @@ -50,11 +50,7 @@ public class WxMallServiceImpl implements WxMallService { | |||||
| public WxMall getByTenantId(String id) { | public WxMall getByTenantId(String id) { | ||||
| WxMall wxMall = new WxMall(); | WxMall wxMall = new WxMall(); | ||||
| wxMall.setTenantId(id); | wxMall.setTenantId(id); | ||||
| try { | |||||
| return wxMallMapper.findList(wxMall).get(0); | |||||
| } catch (Exception e){ | |||||
| return null; | |||||
| } | |||||
| return wxMallMapper.findList(wxMall).get(0); | |||||
| } | } | ||||
| @@ -1,14 +1,26 @@ | |||||
| package com.simple.service.impl; | package com.simple.service.impl; | ||||
| import java.text.SimpleDateFormat; | |||||
| import java.util.*; | import java.util.*; | ||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.simple.common.ErrorCode; | |||||
| import com.simple.common.Result; | |||||
| import com.simple.common.ResultData; | |||||
| import com.simple.domain.po.WxMall; | |||||
| import com.simple.domain.po.WxMerchant; | |||||
| import com.simple.domain.po.WxMerchantBUser; | |||||
| import com.simple.domain.po.WxMerchantTradeDaily; | import com.simple.domain.po.WxMerchantTradeDaily; | ||||
| import com.simple.mapper.WxMerchantTradeDailyMapper; | import com.simple.mapper.WxMerchantTradeDailyMapper; | ||||
| import com.simple.service.WxMerchantTradeDailyService; | import com.simple.service.WxMerchantTradeDailyService; | ||||
| import com.simple.service.WxMallService; | |||||
| import com.simple.service.WxMerchantBUserService; | |||||
| import com.simple.service.WxMerchantService; | |||||
| 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 com.simple.common.IdWorker; | import com.simple.common.IdWorker; | ||||
| import org.springframework.transaction.annotation.Propagation; | |||||
| import org.springframework.transaction.annotation.Transactional; | |||||
| @Service | @Service | ||||
| public class WxMerchantTradeDailyServiceImpl implements WxMerchantTradeDailyService { | public class WxMerchantTradeDailyServiceImpl implements WxMerchantTradeDailyService { | ||||
| @@ -16,6 +28,14 @@ public class WxMerchantTradeDailyServiceImpl implements WxMerchantTradeDailyServ | |||||
| @Autowired | @Autowired | ||||
| WxMerchantTradeDailyMapper wxMerchantTradeDailyMapper; | WxMerchantTradeDailyMapper wxMerchantTradeDailyMapper; | ||||
| @Autowired | |||||
| WxMerchantBUserService wxMerchantBUserService; | |||||
| @Autowired | |||||
| WxMerchantService wxMerchantService; | |||||
| @Autowired | |||||
| WxMallService wxMallService; | |||||
| @Override | @Override | ||||
| public PageInfo<WxMerchantTradeDaily> listAsPage(WxMerchantTradeDaily record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxMerchantTradeDaily> listAsPage(WxMerchantTradeDaily record, Integer pageIndex, Integer pageSize) { | ||||
| @@ -43,8 +63,58 @@ public class WxMerchantTradeDailyServiceImpl implements WxMerchantTradeDailyServ | |||||
| public void deleteById(Long id) { | public void deleteById(Long id) { | ||||
| wxMerchantTradeDailyMapper.deleteByPrimaryKey(id); | wxMerchantTradeDailyMapper.deleteByPrimaryKey(id); | ||||
| } | } | ||||
| @Override | |||||
| public ResultData saveDailyTradingVolume(Long userId, Integer volume) { | |||||
| Map resultMap = new HashMap(); | |||||
| WxMerchantBUser user = wxMerchantBUserService.getById(userId); | |||||
| if (user==null) | |||||
| return new ResultData(ErrorCode.USER_IS_EMPTY, ErrorCode.USER_IS_EMPTY.getMessage()); | |||||
| WxMerchant merchant = wxMerchantService.getById(user.getMerchantId()); | |||||
| if (merchant==null) | |||||
| return new ResultData(ErrorCode.MCH_INFO_NOT_FOUND, ErrorCode.MCH_INFO_NOT_FOUND.getMessage()); | |||||
| WxMall mall = wxMallService.getByTenantId(merchant.getTenantId()); | |||||
| if (mall==null) | |||||
| return new ResultData(ErrorCode.MCH_INFO_NOT_FOUND, ErrorCode.MCH_INFO_NOT_FOUND.getMessage()); | |||||
| WxMerchantTradeDaily wxMerchantTradeDaily = new WxMerchantTradeDaily(); | |||||
| wxMerchantTradeDaily.setMerchantId(merchant.getId()); | |||||
| SimpleDateFormat fmt=new SimpleDateFormat("yyyy-MM-dd"); | |||||
| wxMerchantTradeDaily.setReportDate(fmt.format(new Date())); | |||||
| List<WxMerchantTradeDaily> tradeList = wxMerchantTradeDailyMapper.findList(wxMerchantTradeDaily); | |||||
| if (tradeList.size() > 0 ) { | |||||
| wxMerchantTradeDaily = tradeList.get(0); | |||||
| wxMerchantTradeDaily.setTradeAmt(volume); | |||||
| wxMerchantTradeDaily.setUpdateDate(new Date()); | |||||
| wxMerchantTradeDailyMapper.updateByPrimaryKeySelective(wxMerchantTradeDaily); | |||||
| return new ResultData(wxMerchantTradeDaily); | |||||
| } | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| wxMerchantTradeDaily.setId(idWorker.nextId()); | |||||
| wxMerchantTradeDaily.setTenantId(merchant.getTenantId()); | |||||
| wxMerchantTradeDaily.setMerchantId(merchant.getId()); | |||||
| wxMerchantTradeDaily.setTradeAmt(volume); | |||||
| wxMerchantTradeDaily.setCreateDate(new Date()); | |||||
| wxMerchantTradeDaily.setUpdateDate(new Date()); | |||||
| wxMerchantTradeDailyMapper.insert(wxMerchantTradeDaily); | |||||
| return new ResultData(wxMerchantTradeDaily); | |||||
| } | |||||
| @@ -7,10 +7,12 @@ | |||||
| <result column="merchant_id" jdbcType="BIGINT" property="merchantId" /> | <result column="merchant_id" jdbcType="BIGINT" property="merchantId" /> | ||||
| <result column="trade_amt" jdbcType="DECIMAL" property="tradeAmt" /> | <result column="trade_amt" jdbcType="DECIMAL" property="tradeAmt" /> | ||||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | <result column="create_date" jdbcType="TIMESTAMP" property="createDate" /> | ||||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate" /> | |||||
| <result column="report_date" jdbcType="VARCHAR" property="reportDate" /> | |||||
| </resultMap> | </resultMap> | ||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`,`tenant_id`,`merchant_id`,`trade_amt`,`create_date` | |||||
| `id`,`tenant_id`,`merchant_id`,`trade_amt`,`create_date`,`update_date`,`report_date` | |||||
| </sql> | </sql> | ||||
| <sql id="dynamicWhereConditions"> | <sql id="dynamicWhereConditions"> | ||||
| @@ -36,10 +38,18 @@ | |||||
| </if> | </if> | ||||
| <if test=" null != createDate "> | |||||
| and `create_date` = #{createDate} | |||||
| </if> | |||||
| <if test=" null != createDate "> | |||||
| and `create_date` = #{createDate} | |||||
| </if> | |||||
| <if test=" null != updateDate "> | |||||
| and `update_date` = #{updateDate} | |||||
| </if> | |||||
| <if test=" null != reportDate "> | |||||
| and `report_date` = #{reportDate} | |||||
| </if> | |||||
| <if test=" null != ids "> | <if test=" null != ids "> | ||||
| and id in | and id in | ||||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | ||||