| @@ -8,7 +8,9 @@ import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.controller.base.BaseController; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.domain.po.base.BaseEntity.SortField; | |||
| import com.iformall.domain.po.WxMerchantTradeDaily; | |||
| import com.iformall.domain.po.WxMerchantTradeDailyHistory; | |||
| import com.iformall.domain.vo.WxMerchantTradeDailyVo; | |||
| import com.iformall.service.WxMerchantTradeDailyService; | |||
| import io.swagger.annotations.ApiImplicitParam; | |||
| @@ -40,7 +42,6 @@ public class WxMerchantTradeDailyController extends BaseController { | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| @SystemControllerLog(description = "商户-获得昨日解单列表") | |||
| public ResultData list(@ModelAttribute WxMerchantTradeDaily wxMerchantTradeDaily, Integer pageNum, Integer pageSize) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantTradeDailyController::listYesterday"); | |||
| @@ -57,7 +58,6 @@ public class WxMerchantTradeDailyController extends BaseController { | |||
| @TenantIgnore | |||
| @ApiOperation("数据汇总") | |||
| @GetMapping("/summary") | |||
| @SystemControllerLog(description = "商户解单-数据汇总") | |||
| public ResultData summary(@ModelAttribute WxMerchantTradeDaily wxMerchantTradeDaily) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantTradeDailyController::summary"); | |||
| wxMerchantTradeDaily.updateTenantInfo(getTenantInfo()); | |||
| @@ -67,7 +67,6 @@ public class WxMerchantTradeDailyController extends BaseController { | |||
| @TenantIgnore | |||
| @ApiOperation("获商户得近30日解单") | |||
| @GetMapping("/detail") | |||
| @SystemControllerLog(description = "商户-获商户得近30日解单detail") | |||
| public ResultData detail(Long merchantId) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantTradeDailyController::detail"); | |||
| return wxMerchantTradeDailyService.getVolumeOfMonth(merchantId); | |||
| @@ -76,18 +75,16 @@ public class WxMerchantTradeDailyController extends BaseController { | |||
| @TenantIgnore | |||
| @ApiOperation("获得商场近30日解单") | |||
| @GetMapping("/listMonth") | |||
| @SystemControllerLog(description = "商户-获得商场近30日解单") | |||
| public ResultData listMonth() { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantTradeDailyController::listMonth"); | |||
| return wxMerchantTradeDailyService.getVolumeTotalOfMonth(getTenantInfo()); | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("更新解单数据") | |||
| @PostMapping("/update") | |||
| @SystemControllerLog(description = "商户-更新解单数据") | |||
| public ResultData update(@RequestBody WxMerchantTradeDaily wxMerchantTradeDaily) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantTradeDailyController::updateYesterday"); | |||
| @ApiOperation("新增解单数据") | |||
| @PostMapping("/add") | |||
| @SystemControllerLog(description = "商户解单-新增解单数据") | |||
| public ResultData add(@RequestBody WxMerchantTradeDaily wxMerchantTradeDaily) { | |||
| if (wxMerchantTradeDaily == null || | |||
| wxMerchantTradeDaily.getMerchantId() == null || | |||
| wxMerchantTradeDaily.getTradeAmt() == null) | |||
| @@ -97,13 +94,41 @@ public class WxMerchantTradeDailyController extends BaseController { | |||
| SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd"); | |||
| wxMerchantTradeDaily.setReportDate(fmt.format(new Date())); | |||
| } | |||
| return wxMerchantTradeDailyService.update(wxMerchantTradeDaily); | |||
| return wxMerchantTradeDailyService.add(wxMerchantTradeDaily,this.getUser()); | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("更新解单数据") | |||
| @PostMapping("/update") | |||
| @SystemControllerLog(description = "商户解单-更新解单数据") | |||
| public ResultData update(@RequestBody WxMerchantTradeDaily wxMerchantTradeDaily) { | |||
| if (wxMerchantTradeDaily == null || wxMerchantTradeDaily.getId() == null ) { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| } | |||
| wxMerchantTradeDaily.updateTenantInfo(getTenantInfo()); | |||
| if (wxMerchantTradeDaily.getReportDate() == null) { | |||
| SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd"); | |||
| wxMerchantTradeDaily.setReportDate(fmt.format(new Date())); | |||
| } | |||
| return wxMerchantTradeDailyService.update(wxMerchantTradeDaily,this.getUser()); | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("查询解单变更历史数据") | |||
| @GetMapping("/queryTradeDailyHistory") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public ResultData queryTradeDailyHistory(@ModelAttribute WxMerchantTradeDailyHistory wxMerchantTradeDailyHistory, Integer pageNum, Integer pageSize) { | |||
| wxMerchantTradeDailyHistory.updateTenantInfo(getTenantInfo()); | |||
| wxMerchantTradeDailyHistory.setSortColumns(SortField.CreateDate_ASC); | |||
| PageInfo<WxMerchantTradeDailyHistory> page = wxMerchantTradeDailyService.listHistoryAsPageVo(wxMerchantTradeDailyHistory, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @TenantIgnore | |||
| @ApiOperation("查询解单数据") | |||
| @GetMapping("/queryTradeDaily") | |||
| @SystemControllerLog(description = "商户-查询解单数据") | |||
| public ResultData queryTradeDaily(@ModelAttribute WxMerchantTradeDaily wxMerchantTradeDaily) { | |||
| logger.debug("[" + getIpAddr() + "] WxMerchantTradeDailyController::queryTradeDaily"); | |||
| wxMerchantTradeDaily.updateTenantInfo(getTenantInfo()); | |||
| @@ -0,0 +1,24 @@ | |||
| alter table wx_merchant_trade_daily add column mall_user_id bigint(20) DEFAULT NULL COMMENT 'a端用户id'; | |||
| alter table wx_merchant_trade_daily add column date_type int(1) NOT NULL DEFAULT 1 COMMENT '解单日期类型EnumTradeDailyDateType'; | |||
| CREATE TABLE `wx_merchant_trade_daily_history` ( | |||
| `id` bigint(20) NOT NULL COMMENT '主键ID', | |||
| `tenant_id` varchar(5) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '租户ID', | |||
| `parent_tenant_id` varchar(5) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '父租户ID', | |||
| `merchant_id` bigint(20) NOT NULL COMMENT '商户ID', | |||
| `b_user_id` bigint(20) DEFAULT NULL COMMENT 'B端用户ID', | |||
| `trade_amt` bigint(20) DEFAULT NULL, | |||
| `create_date` datetime DEFAULT NULL, | |||
| `update_date` datetime DEFAULT NULL, | |||
| `report_date` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL, | |||
| `trade_count` int(10) DEFAULT '0' COMMENT '交易笔数', | |||
| `proof` varchar(500) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '凭证', | |||
| `trade_daily_id` bigint(20) NOT NULL COMMENT 'trade_daily_id', | |||
| `mall_user_id` bigint(20) DEFAULT NULL COMMENT 'a端用户id', | |||
| PRIMARY KEY (`id`), | |||
| UNIQUE KEY `id_UNIQUE` (`id`) | |||
| ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC COMMENT='商户每天解单记录'; | |||
| alter table wx_merchant_trade_daily_history add column date_type int(1) NOT NULL DEFAULT 1 COMMENT '解单日期类型EnumTradeDailyDateType'; | |||
| @@ -2,6 +2,7 @@ package com.iformall.controller; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.po.WxMerchantBUser; | |||
| @@ -50,9 +51,31 @@ public class WxMerchantTradeDailyController extends BaseController { | |||
| @ApiOperation("上报每日解单") | |||
| @GetMapping("/reportDailyVolume") | |||
| @ApiImplicitParam(name = "volume", value = "总金额(分)", dataType = "Integer", paramType = "query", required = true) | |||
| public ResultData saveDailyTradingVolume(Integer volume) { | |||
| return wxMerchantTradeDailyService.saveDailyTradingVolume(getLoginBUser().getId(), volume); | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "dateType", value = "类型", dataType = "Integer", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "volume", value = "总金额(分)", dataType = "Integer", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "reportDate", value = "解单日期", dataType = "String", paramType = "query", required = false) | |||
| }) | |||
| public ResultData saveDailyTradingVolume(Integer dateType,Integer volume,String reportDate) { | |||
| return wxMerchantTradeDailyService.saveDailyTradingVolume(getLoginBUser(), volume,dateType,reportDate); | |||
| } | |||
| @ApiOperation("更新每日解单") | |||
| @GetMapping("/updateDailyVolume") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "id", value = "编码", dataType = "Long", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "dateType", value = "类型", dataType = "Integer", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "volume", value = "总金额(分)", dataType = "Integer", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "reportDate", value = "解单日期", dataType = "String", paramType = "query", required = false) | |||
| }) | |||
| public ResultData updateDailyVolume(Long id,Integer dateType,Integer volume,String reportDate) { | |||
| WxMerchantTradeDaily tradeDaily = new WxMerchantTradeDaily(); | |||
| tradeDaily.setId(id); | |||
| tradeDaily.updateTenantInfo(getTenantInfo()); | |||
| tradeDaily.setDateType(dateType); | |||
| tradeDaily.setTradeAmt(String.valueOf(volume)); | |||
| tradeDaily.setReportDate(reportDate); | |||
| return wxMerchantTradeDailyService.update(tradeDaily, null); | |||
| } | |||
| /** | |||
| @@ -104,9 +127,7 @@ public class WxMerchantTradeDailyController extends BaseController { | |||
| } | |||
| wxMerchantTradeDaily.setbUserId(getLoginBUser().getId()); | |||
| logger.info("1------------------------------------" + wxMerchantTradeDaily.getbUserId()); | |||
| wxMerchantTradeDaily.setBUserId(getLoginBUser().getId()); | |||
| logger.info("2------------------------------------" + wxMerchantTradeDaily.getBUserId()); | |||
| wxMerchantTradeDailyService.saveOrUpdate(wxMerchantTradeDaily); | |||
| return new ResultData(); | |||
| } | |||
| @@ -18,7 +18,7 @@ public class WxMerchantTradeDaily extends TenantEntity { | |||
| protected Long id; | |||
| @io.swagger.annotations.ApiModelProperty(value = "商户id", name = "merchantId") | |||
| private Long merchantId; | |||
| protected Long merchantId; | |||
| public Long getbUserId() { | |||
| return bUserId; | |||
| @@ -35,21 +35,26 @@ public class WxMerchantTradeDaily extends TenantEntity { | |||
| public void setBUserId(Long bUserId) { | |||
| this.bUserId = bUserId; | |||
| } | |||
| @io.swagger.annotations.ApiModelProperty(value = "a端用户id", name = "mallUserId") | |||
| protected Long mallUserId; | |||
| @io.swagger.annotations.ApiModelProperty(value = "b用户id", name = "bUserId") | |||
| private Long bUserId; | |||
| protected Long bUserId; | |||
| @io.swagger.annotations.ApiModelProperty(value = "交易额", name = "tradeAmt") | |||
| private String tradeAmt; | |||
| protected String tradeAmt; | |||
| @io.swagger.annotations.ApiModelProperty(value = "解单提交日期", name = "createDate") | |||
| private Date createDate; | |||
| protected Date createDate; | |||
| @io.swagger.annotations.ApiModelProperty(value = "解单更新日期", name = "updateDate") | |||
| private Date updateDate; | |||
| protected Date updateDate; | |||
| @io.swagger.annotations.ApiModelProperty(value = "解单日期", name = "reportDate") | |||
| private String reportDate; | |||
| protected String reportDate; | |||
| @TableField(exist = false) | |||
| private String reportDateLike; | |||
| @io.swagger.annotations.ApiModelProperty(value = "解单日期类型EnumTradeDailyDateType", name = "dateType") | |||
| protected Integer dateType; | |||
| @io.swagger.annotations.ApiModelProperty(value = "交易笔数", name = "tradeCount") | |||
| private Integer tradeCount; | |||
| protected Integer tradeCount; | |||
| @io.swagger.annotations.ApiModelProperty(value = "凭证", name = "proof") | |||
| private String proof; | |||
| protected String proof; | |||
| @io.swagger.annotations.ApiModelProperty(value = "月份如2019-05", name = "month") | |||
| @TableField(exist = false) | |||
| @@ -74,5 +79,8 @@ public class WxMerchantTradeDaily extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value = "是否是当天 1是", name = "isToday") | |||
| @TableField(exist = false) | |||
| private Integer isToday; | |||
| @TableField(exist = false) | |||
| private Long ignoreId; | |||
| } | |||
| @@ -0,0 +1,22 @@ | |||
| package com.iformall.domain.po; | |||
| import com.baomidou.mybatisplus.annotation.TableField; | |||
| import com.baomidou.mybatisplus.annotation.TableName; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import lombok.Data; | |||
| import lombok.EqualsAndHashCode; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import java.util.Date; | |||
| @TableName(value = "wx_merchant_trade_daily_history") | |||
| @Data | |||
| @EqualsAndHashCode(callSuper = true) | |||
| public class WxMerchantTradeDailyHistory extends WxMerchantTradeDaily { | |||
| protected Long id; | |||
| @io.swagger.annotations.ApiModelProperty(value = "tradeDailyId", name = "tradeDailyId") | |||
| private Long tradeDailyId; | |||
| } | |||
| @@ -0,0 +1,36 @@ | |||
| package com.iformall.enums; | |||
| /** | |||
| * @author gongbiao | |||
| */ | |||
| public enum EnumTradeDailyDateType { | |||
| DAY(1, "日"), | |||
| MONTH(2, "月"); | |||
| public static EnumTradeDailyDateType getEnum(Integer code) { | |||
| for (EnumTradeDailyDateType value : values()) { | |||
| if (value.getCode().equals(code)) { | |||
| return value; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| private Integer code; | |||
| private String message; | |||
| EnumTradeDailyDateType(Integer code, String message) { | |||
| this.code = code; | |||
| this.message = message; | |||
| } | |||
| public Integer getCode() { | |||
| return code; | |||
| } | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| } | |||
| @@ -0,0 +1,11 @@ | |||
| package com.iformall.mapper; | |||
| import java.util.*; | |||
| import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.WxMerchantTradeDailyHistory; | |||
| public interface WxMerchantTradeDailyHistoryMapper extends CommonMapper<WxMerchantTradeDailyHistory, String> { | |||
| List<WxMerchantTradeDailyHistory> findList(WxMerchantTradeDailyHistory wxMerchantTradeDailyHistory); | |||
| } | |||
| @@ -3,7 +3,10 @@ package com.iformall.service; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.domain.po.WxMerchantBUser; | |||
| import com.iformall.domain.po.WxMerchantTradeDaily; | |||
| import com.iformall.domain.po.WxMerchantTradeDailyHistory; | |||
| import com.iformall.domain.vo.WxMerchantTradeDailyVo; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| @@ -49,7 +52,7 @@ public interface WxMerchantTradeDailyService { | |||
| * @param volume | |||
| */ | |||
| ResultData saveDailyTradingVolume(Long userId, Integer volume); | |||
| ResultData saveDailyTradingVolume(WxMerchantBUser merchantBUser, Integer volume,Integer dateType,String reportDate); | |||
| /** | |||
| * 获取当日解单数据 | |||
| @@ -83,8 +86,11 @@ public interface WxMerchantTradeDailyService { | |||
| * @return | |||
| */ | |||
| PageInfo<WxMerchantTradeDailyVo> listAsPageVo(WxMerchantTradeDaily record, Integer pageIndex, Integer pageSize); | |||
| PageInfo<WxMerchantTradeDailyHistory> listHistoryAsPageVo(WxMerchantTradeDailyHistory record, Integer pageIndex, Integer pageSize); | |||
| ResultData update(WxMerchantTradeDaily tradeDailyVo); | |||
| ResultData add(WxMerchantTradeDaily tradeDailyVo,MallUserInfo mallUserInfo); | |||
| ResultData update(WxMerchantTradeDaily tradeDailyVo,MallUserInfo mallUserInfo); | |||
| ResultData queryTradeDaily(WxMerchantTradeDaily wxMerchantTradeDaily); | |||
| @@ -1,17 +1,23 @@ | |||
| package com.iformall.service.impl; | |||
| import com.aliyun.openservices.shade.org.apache.commons.lang3.StringUtils; | |||
| import com.github.pagehelper.PageHelper; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.domain.po.WxMall; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.po.WxMerchantBUser; | |||
| import com.iformall.domain.po.WxMerchantTradeDaily; | |||
| import com.iformall.domain.po.WxMerchantTradeDailyHistory; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.vo.WxMerchantTradeDailyVo; | |||
| import com.iformall.enums.EnumTradeDailyDateType; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.WxMerchantTradeDailyHistoryMapper; | |||
| import com.iformall.mapper.WxMerchantTradeDailyMapper; | |||
| import com.iformall.mapper.WxShopMapper; | |||
| import com.iformall.service.*; | |||
| @@ -48,12 +54,20 @@ public class WxMerchantTradeDailyServiceImpl implements WxMerchantTradeDailyServ | |||
| @Autowired | |||
| WxShopService wxShopService; | |||
| @Autowired | |||
| WxMerchantTradeDailyHistoryMapper wxMerchantTradeDailyHistoryMapper; | |||
| @Override | |||
| public PageInfo<WxMerchantTradeDaily> listAsPage(WxMerchantTradeDaily record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxMerchantTradeDailyMapper.findList(record)); | |||
| } | |||
| @Override | |||
| public PageInfo<WxMerchantTradeDailyHistory> listHistoryAsPageVo(WxMerchantTradeDailyHistory record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxMerchantTradeDailyHistoryMapper.findList(record)); | |||
| } | |||
| @Override | |||
| public WxMerchantTradeDaily getById(Long id) { | |||
| @@ -81,14 +95,21 @@ public class WxMerchantTradeDailyServiceImpl implements WxMerchantTradeDailyServ | |||
| } | |||
| @Override | |||
| public ResultData saveDailyTradingVolume(Long userId, Integer volume) { | |||
| WxMerchantBUser user = wxMerchantBUserService.getById(userId); | |||
| if (user==null) { | |||
| return new ResultData(ErrorCode.USER_IS_EMPTY); | |||
| public ResultData saveDailyTradingVolume(WxMerchantBUser merchantBUser, Integer volume,Integer dateType,String reportDate) { | |||
| EnumTradeDailyDateType _da = EnumTradeDailyDateType.getEnum(dateType); | |||
| if (null == _da) { | |||
| return new ResultData(ErrorCode.USER_IS_EMPTY.getCode(),"日期类型非法"); | |||
| } | |||
| if (_da.getCode().intValue() == EnumTradeDailyDateType.DAY.getCode().intValue() | |||
| && StringUtils.isBlank(reportDate)) { | |||
| SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd"); | |||
| reportDate = fmt.format(new Date()); | |||
| }else { | |||
| return new ResultData(ErrorCode.USER_IS_EMPTY.getCode(),"日期不能为空"); | |||
| } | |||
| WxMerchant merchant = wxMerchantService.getById(user.getMerchantId()); | |||
| WxMerchant merchant = wxMerchantService.getById(merchantBUser.getMerchantId()); | |||
| if (merchant==null) { | |||
| return new ResultData(ErrorCode.MERCHANT_INFO_NOT_FOUND); | |||
| } | |||
| @@ -99,28 +120,19 @@ public class WxMerchantTradeDailyServiceImpl implements WxMerchantTradeDailyServ | |||
| } | |||
| 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.updateById(wxMerchantTradeDaily); | |||
| return new ResultData(wxMerchantTradeDaily); | |||
| } | |||
| wxMerchantTradeDaily.setDateType(dateType); | |||
| try { | |||
| checkTradeDaily(wxMerchantTradeDaily); | |||
| }catch(Exception e) { | |||
| return new ResultData(Result.ERROR,e.getMessage()); | |||
| } | |||
| wxMerchantTradeDaily.setReportDate(reportDate); | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| wxMerchantTradeDaily.setId(idWorker.nextId()); | |||
| wxMerchantTradeDaily.updateTenantInfo(merchant); | |||
| wxMerchantTradeDaily.setMerchantId(merchant.getId()); | |||
| wxMerchantTradeDaily.setbUserId(userId); | |||
| wxMerchantTradeDaily.setbUserId(merchantBUser.getId()); | |||
| wxMerchantTradeDaily.setTradeAmt(volume + ""); | |||
| wxMerchantTradeDaily.setCreateDate(new Date()); | |||
| wxMerchantTradeDaily.setUpdateDate(new Date()); | |||
| @@ -137,24 +149,15 @@ public class WxMerchantTradeDailyServiceImpl implements WxMerchantTradeDailyServ | |||
| } | |||
| @Override | |||
| public ResultData update(WxMerchantTradeDaily tradeDaily) { | |||
| public ResultData add(WxMerchantTradeDaily tradeDaily,MallUserInfo mallUserInfo) { | |||
| try { | |||
| checkTradeDaily(tradeDaily); | |||
| }catch(Exception e) { | |||
| return new ResultData(Result.ERROR,e.getMessage()); | |||
| } | |||
| WxMerchantTradeDaily wxMerchantTradeDaily = new WxMerchantTradeDaily(); | |||
| wxMerchantTradeDaily.setMerchantId(tradeDaily.getMerchantId()); | |||
| wxMerchantTradeDaily.setReportDate(tradeDaily.getReportDate()); | |||
| List<WxMerchantTradeDaily> tradeList = wxMerchantTradeDailyMapper.findList(wxMerchantTradeDaily); | |||
| if (tradeList.size() > 0) { | |||
| wxMerchantTradeDaily = tradeList.get(0); | |||
| wxMerchantTradeDaily.setUpdateDate(new Date()); | |||
| wxMerchantTradeDaily.setTradeAmt(tradeDaily.getTradeAmt() + ""); | |||
| wxMerchantTradeDaily.setTradeCount(tradeDaily.getTradeCount()); | |||
| wxMerchantTradeDaily.setProof(tradeDaily.getProof()); | |||
| wxMerchantTradeDailyMapper.updateById(wxMerchantTradeDaily); | |||
| return new ResultData(wxMerchantTradeDaily); | |||
| } | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| wxMerchantTradeDaily.setId(idWorker.nextId()); | |||
| wxMerchantTradeDaily.updateTenantInfo(tradeDaily); | |||
| @@ -164,10 +167,78 @@ public class WxMerchantTradeDailyServiceImpl implements WxMerchantTradeDailyServ | |||
| wxMerchantTradeDaily.setUpdateDate(new Date()); | |||
| wxMerchantTradeDaily.setTradeCount(tradeDaily.getTradeCount()); | |||
| wxMerchantTradeDaily.setProof(tradeDaily.getProof()); | |||
| wxMerchantTradeDaily.setMallUserId(mallUserInfo.getId()); | |||
| wxMerchantTradeDaily.setDateType(tradeDaily.getDateType()); | |||
| wxMerchantTradeDaily.setReportDate(tradeDaily.getReportDate()); | |||
| wxMerchantTradeDailyMapper.insert(wxMerchantTradeDaily); | |||
| return new ResultData(Result.SUCCESS); | |||
| } | |||
| private void checkTradeDaily(WxMerchantTradeDaily tradeDaily) throws MallinkException { | |||
| WxMerchantTradeDaily wxMerchantTradeDaily = new WxMerchantTradeDaily(); | |||
| wxMerchantTradeDaily.setMerchantId(tradeDaily.getMerchantId()); | |||
| String errormsg = "解单数据已存在"; | |||
| if (tradeDaily.getDateType().intValue() == EnumTradeDailyDateType.DAY.getCode().intValue()) { | |||
| wxMerchantTradeDaily.setReportDate(tradeDaily.getReportDate()); | |||
| errormsg = "当天解单数据已存在"; | |||
| }else if (tradeDaily.getDateType().intValue() == EnumTradeDailyDateType.MONTH.getCode().intValue()) { | |||
| wxMerchantTradeDaily.setReportDateLike(tradeDaily.getReportDate()); | |||
| errormsg = "当前月已存在解单数据或者已存在当前月按天提报的解单数据"; | |||
| } | |||
| List<WxMerchantTradeDaily> tradeList = wxMerchantTradeDailyMapper.findList(wxMerchantTradeDaily); | |||
| if (tradeList.size() > 0) { | |||
| throw new MallinkException(Result.ERROR,errormsg); | |||
| } | |||
| } | |||
| @Override | |||
| public ResultData update(WxMerchantTradeDaily tradeDaily,MallUserInfo mallUserInfo) { | |||
| WxMerchantTradeDaily trade = wxMerchantTradeDailyMapper.selectById(tradeDaily.getId()); | |||
| if (null != trade) { | |||
| //如果变更了dateType,则需要查询 | |||
| if (trade.getDateType().intValue() != tradeDaily.getDateType().intValue()){ | |||
| try { | |||
| tradeDaily.setIgnoreId(tradeDaily.getId()); | |||
| checkTradeDaily(tradeDaily); | |||
| trade.setDateType(tradeDaily.getDateType()); | |||
| }catch(Exception e) { | |||
| return new ResultData(Result.ERROR,e.getMessage()); | |||
| } | |||
| } | |||
| trade.setUpdateDate(new Date()); | |||
| trade.setTradeAmt(tradeDaily.getTradeAmt() + ""); | |||
| trade.setTradeCount(tradeDaily.getTradeCount()); | |||
| trade.setProof(tradeDaily.getProof()); | |||
| wxMerchantTradeDailyMapper.updateById(trade); | |||
| WxMerchantTradeDailyHistory wxMerchantTradeDailyHistory = new WxMerchantTradeDailyHistory(); | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| wxMerchantTradeDailyHistory.setId(idWorker.nextId()); | |||
| wxMerchantTradeDailyHistory.setTradeDailyId(tradeDaily.getId()); | |||
| if (null != mallUserInfo) { | |||
| wxMerchantTradeDailyHistory.setMallUserId(mallUserInfo.getId()); | |||
| } | |||
| wxMerchantTradeDailyHistory.updateTenantInfo(tradeDaily); | |||
| wxMerchantTradeDailyHistory.setMerchantId(tradeDaily.getMerchantId()); | |||
| wxMerchantTradeDailyHistory.setTradeAmt(tradeDaily.getTradeAmt() + ""); | |||
| wxMerchantTradeDailyHistory.setCreateDate(new Date()); | |||
| wxMerchantTradeDailyHistory.setUpdateDate(new Date()); | |||
| wxMerchantTradeDailyHistory.setTradeCount(tradeDaily.getTradeCount()); | |||
| wxMerchantTradeDailyHistory.setProof(tradeDaily.getProof()); | |||
| wxMerchantTradeDailyHistory.setbUserId(tradeDaily.getbUserId()); | |||
| wxMerchantTradeDailyHistory.setReportDate(tradeDaily.getReportDate()); | |||
| wxMerchantTradeDailyHistory.setDateType(tradeDaily.getDateType()); | |||
| wxMerchantTradeDailyHistoryMapper.insert(wxMerchantTradeDailyHistory); | |||
| return new ResultData(trade); | |||
| } | |||
| return new ResultData(Result.SUCCESS); | |||
| } | |||
| @Override | |||
| public ResultData queryTradeDaily(WxMerchantTradeDaily tradeDaily) { | |||
| @@ -0,0 +1,94 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | |||
| <mapper namespace="com.iformall.mapper.WxMerchantTradeDailyHistoryMapper"> | |||
| <resultMap id="BaseResultMap" type="com.iformall.domain.po.WxMerchantTradeDailyHistory"> | |||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId" /> | |||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/> | |||
| <result column="merchant_id" jdbcType="BIGINT" property="merchantId" /> | |||
| <result column="b_user_id" jdbcType="BIGINT" property="bUserId" /> | |||
| <result column="trade_amt" jdbcType="DECIMAL" property="tradeAmt" /> | |||
| <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="date_type" jdbcType="INTEGER" property="dateType" /> | |||
| <result column="trade_count" jdbcType="INTEGER" property="tradeCount" /> | |||
| <result column="proof" jdbcType="VARCHAR" property="proof"/> | |||
| <result column="trade_daily_id" jdbcType="BIGINT" property="tradeDailyId" /> | |||
| <result column="mall_user_id" jdbcType="BIGINT" property="mallUserId" /> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`parent_tenant_id`,`merchant_id`,`b_user_id`,`trade_amt`,`create_date`,`update_date`, | |||
| `report_date`,`date_type`,`trade_count`,`proof`,`trade_daily_id`,`mall_user_id` | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| where 1 = 1 | |||
| <if test=" null != id "> | |||
| and `id` = #{id} | |||
| </if> | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != tradeDailyId "> | |||
| and `trade_daily_id` = #{tradeDailyId} | |||
| </if> | |||
| <if test=" null != mallUserId "> | |||
| and `mall_user_id` = #{mallUserId} | |||
| </if> | |||
| <if test=" null != merchantId "> | |||
| and `merchant_id` = #{merchantId} | |||
| </if> | |||
| <if test=" null != bUserId "> | |||
| and `b_user_id` = #{bUserId} | |||
| </if> | |||
| <if test=" null != tradeAmt "> | |||
| and `trade_amt` = #{tradeAmt} | |||
| </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 != month "> | |||
| and date_format(create_date,'%Y-%m')=#{month} | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||
| <foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")"> | |||
| #{idItem} | |||
| </foreach> | |||
| </if> | |||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||
| <if test=" null == sortColumns"> order by report_date desc </if> | |||
| </sql> | |||
| <select id="findList" parameterType="com.iformall.domain.po.WxMerchantTradeDailyHistory" resultMap="BaseResultMap"> | |||
| select | |||
| <include refid="allColumns"/> | |||
| from wx_merchant_trade_daily_history | |||
| <include refid="dynamicWhereConditions" /> | |||
| </select> | |||
| </mapper> | |||
| @@ -11,12 +11,15 @@ | |||
| <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"/> | |||
| <result column="date_type" jdbcType="INTEGER" property="dateType" /> | |||
| <result column="trade_count" jdbcType="INTEGER" property="tradeCount" /> | |||
| <result column="proof" jdbcType="VARCHAR" property="proof"/> | |||
| <result column="mall_user_id" jdbcType="BIGINT" property="mallUserId"/> | |||
| </resultMap> | |||
| <sql id="allColumns"> | |||
| `id`,`tenant_id`,`parent_tenant_id`,`merchant_id`,`b_user_id`,`trade_amt`,`create_date`,`update_date`,`report_date`,trade_count,proof | |||
| `id`,`tenant_id`,`parent_tenant_id`,`merchant_id`,`b_user_id`,`trade_amt`,`create_date`,`update_date`, | |||
| `report_date`,`date_type`,trade_count,proof,mall_user_id | |||
| </sql> | |||
| <sql id="dynamicWhereConditions"> | |||
| @@ -60,6 +63,16 @@ | |||
| <if test=" null != month "> | |||
| and date_format(create_date,'%Y-%m')=#{month} | |||
| </if> | |||
| <if test=" null != reportDateLike "> | |||
| and report_date like concat('', #{reportDateLike},'-%') | |||
| </if> | |||
| <if test=" null != ignoreId "> | |||
| and id != #{ignoreId} | |||
| </if> | |||
| <if test=" null != ids "> | |||
| and id in | |||