| | |
| | | package com.yeshi.fanli.service.impl.tlj;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.tlj.UserTaoLiJinReportMapper;
|
| | | import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinReport;
|
| | | import com.yeshi.fanli.exception.tlj.UserTaoLiJinOriginException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinOriginService;
|
| | | import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinReportService;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | |
|
| | | @Service
|
| | | public class UserTaoLiJinReportServiceImpl implements UserTaoLiJinReportService{
|
| | |
|
| | | @Resource
|
| | | private UserTaoLiJinReportMapper userTaoLiJinReportMapper;
|
| | | |
| | | @Resource
|
| | | private UserTaoLiJinOriginService userTaoLiJinOriginService;
|
| | | |
| | | @Override
|
| | | public void insertDefault(String rightsId) {
|
| | | if (StringUtil.isNullOrEmpty(rightsId)) {
|
| | | return;
|
| | | }
|
| | | |
| | | UserTaoLiJinReport report = new UserTaoLiJinReport();
|
| | | report.setId(rightsId);
|
| | | report.setUnfreezeAmount(new BigDecimal(0));
|
| | | report.setUnfreezeNum(0);
|
| | | report.setRefundAmount(new BigDecimal(0));
|
| | | report.setRefundNum(0);
|
| | | report.setAlipayAmount(new BigDecimal(0));
|
| | | report.setUseAmount(new BigDecimal(0));
|
| | | report.setUseNum(0);
|
| | | report.setWinAmount(new BigDecimal(0));
|
| | | report.setWinNum(0);
|
| | | report.setPreCommissionAmount(new BigDecimal(0));
|
| | | report.setCreateTime(new Date());
|
| | | report.setUpdateTime(new Date());
|
| | | userTaoLiJinReportMapper.insertSelective(report);
|
| | | }
|
| | | |
| | | |
| | | |
| | | |
| | | @Override
|
| | | public void updateByPrimaryKeySelective(UserTaoLiJinReport record) {
|
| | | if (record == null || record.getId() == null) {
|
| | | return;
|
| | | }
|
| | | record.setUpdateTime(new Date());
|
| | | |
| | | userTaoLiJinReportMapper.updateByPrimaryKeySelective(record);
|
| | | }
|
| | | |
| | | @Override
|
| | | public void needUpdateReport() {
|
| | | List<UserTaoLiJinReport> list = userTaoLiJinReportMapper.needUpdateReport();
|
| | | if (list == null || list.size() == 0) {
|
| | | return;
|
| | | }
|
| | | |
| | | for (UserTaoLiJinReport report: list) {
|
| | | UserTaoLiJinReport taoLiJinReport = null;
|
| | | try {
|
| | | taoLiJinReport = TaoKeApiUtil.getTaoLiJinEffective(report.getId());
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | continue;
|
| | | }
|
| | | |
| | | if (taoLiJinReport == null) {
|
| | | continue;
|
| | | }
|
| | | |
| | | // 是否需要更新
|
| | | boolean needUpdate = false;
|
| | | |
| | | if(taoLiJinReport.getWinNum() != report.getWinNum()){
|
| | | needUpdate = true;
|
| | | }
|
| | | if(taoLiJinReport.getWinAmount() != report.getWinAmount()){
|
| | | needUpdate = true;
|
| | | }
|
| | | if(taoLiJinReport.getUnfreezeNum() != report.getUnfreezeNum()){
|
| | | needUpdate = true;
|
| | | }
|
| | | if(taoLiJinReport.getUnfreezeAmount() != report.getUnfreezeAmount()){
|
| | | needUpdate = true;
|
| | | }
|
| | | if(taoLiJinReport.getPreCommissionAmount() != report.getPreCommissionAmount()){
|
| | | needUpdate = true;
|
| | | }
|
| | | if(taoLiJinReport.getUseNum() != report.getUseNum()){
|
| | | needUpdate = true;
|
| | | }
|
| | | if(taoLiJinReport.getUseAmount() != report.getUseAmount()){
|
| | | needUpdate = true;
|
| | | }
|
| | | |
| | | if(taoLiJinReport.getAlipayAmount() != report.getAlipayAmount()){
|
| | | needUpdate = true;
|
| | | }
|
| | | |
| | | if(taoLiJinReport.getRefundNum() != report.getRefundNum()){
|
| | | needUpdate = true;
|
| | | }
|
| | | |
| | | // 失效退回金额发生变化
|
| | | BigDecimal refundAmount = taoLiJinReport.getRefundAmount();
|
| | | if(refundAmount.compareTo(report.getRefundAmount()) > 0) {
|
| | | needUpdate = true;
|
| | | try {
|
| | | userTaoLiJinOriginService.refundMoney(taoLiJinReport);
|
| | | } catch (UserTaoLiJinOriginException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | // 更新报告
|
| | | if(needUpdate) {
|
| | | taoLiJinReport.setUpdateTime(new Date());
|
| | | userTaoLiJinReportMapper.updateByPrimaryKeySelective(taoLiJinReport);
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | }
|
| | | package com.yeshi.fanli.service.impl.tlj; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import com.yeshi.fanli.dao.mybatis.tlj.UserTaoLiJinReportMapper; |
| | | import com.yeshi.fanli.entity.bus.tlj.UserTaoLiJinReport; |
| | | import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinOriginService; |
| | | import com.yeshi.fanli.service.inter.tlj.UserTaoLiJinReportService; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | |
| | | @Service |
| | | public class UserTaoLiJinReportServiceImpl implements UserTaoLiJinReportService{ |
| | | |
| | | @Resource |
| | | private UserTaoLiJinReportMapper userTaoLiJinReportMapper; |
| | | |
| | | @Resource |
| | | private UserTaoLiJinOriginService userTaoLiJinOriginService; |
| | | |
| | | @Override |
| | | public void insertDefault(String rightsId) { |
| | | if (StringUtil.isNullOrEmpty(rightsId)) { |
| | | return; |
| | | } |
| | | |
| | | UserTaoLiJinReport report = new UserTaoLiJinReport(); |
| | | report.setId(rightsId); |
| | | report.setUnfreezeAmount(new BigDecimal(0)); |
| | | report.setUnfreezeNum(0); |
| | | report.setRefundAmount(new BigDecimal(0)); |
| | | report.setRefundNum(0); |
| | | report.setAlipayAmount(new BigDecimal(0)); |
| | | report.setUseAmount(new BigDecimal(0)); |
| | | report.setUseNum(0); |
| | | report.setWinAmount(new BigDecimal(0)); |
| | | report.setWinNum(0); |
| | | report.setPreCommissionAmount(new BigDecimal(0)); |
| | | report.setCreateTime(new Date()); |
| | | report.setUpdateTime(new Date()); |
| | | userTaoLiJinReportMapper.insertSelective(report); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void updateByPrimaryKeySelective(UserTaoLiJinReport record) { |
| | | if (record == null || record.getId() == null) { |
| | | return; |
| | | } |
| | | record.setUpdateTime(new Date()); |
| | | |
| | | userTaoLiJinReportMapper.updateByPrimaryKeySelective(record); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public UserTaoLiJinReport selectByPrimaryKey(String id) { |
| | | return userTaoLiJinReportMapper.selectByPrimaryKeyStr(id); |
| | | } |
| | | |
| | | } |