| | |
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | |
| | |
|
| | | 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.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | |
|
| | | @Service
|
| | | public class UserTaoLiJinReportServiceImpl implements UserTaoLiJinReportService{
|
| | |
| | | }
|
| | |
|
| | |
|
| | | |
| | | |
| | | @Override
|
| | | public void updateByPrimaryKeySelective(UserTaoLiJinReport record) {
|
| | | if (record == null || record.getId() == null) {
|
| | |
| | | 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);
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public void refundNotWin() {
|
| | | List<UserTaoLiJinReport> list = userTaoLiJinReportMapper.refundNotWin();
|
| | | if (list == null || list.size() == 0) {
|
| | | return;
|
| | | }
|
| | | |
| | | for (UserTaoLiJinReport report: list) {
|
| | | // 总个数
|
| | | Integer totalNum = report.getTotalNum();
|
| | | BigDecimal preFace = report.getPreFace();
|
| | | |
| | | // 总金额
|
| | | BigDecimal money = MoneyBigDecimalUtil.mul(new BigDecimal(totalNum), preFace);
|
| | | |
| | | report.setRefundNum(totalNum);
|
| | | report.setRefundAmount(money);
|
| | | report.setUpdateTime(new Date());
|
| | | |
| | | try {
|
| | | // 退回淘礼金
|
| | | userTaoLiJinOriginService.refundMoney(report);
|
| | | |
| | | } catch (UserTaoLiJinOriginException e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | continue;
|
| | | }
|
| | | |
| | | // 更新报告
|
| | | userTaoLiJinReportMapper.updateByPrimaryKeySelective(report);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public UserTaoLiJinReport selectByPrimaryKey(String id) {
|