| | |
| | | package com.matrix.system.hive.service.imp; |
| | | |
| | | import com.matrix.core.constance.MatrixConstance; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.matrix.core.exception.GlobleException; |
| | | import com.matrix.core.pojo.PaginationVO; |
| | | import com.matrix.core.tools.WebUtil; |
| | | import com.matrix.system.common.bean.SysUsers; |
| | | import com.matrix.system.constance.Dictionary; |
| | | import com.matrix.system.hive.bean.*; |
| | | import com.matrix.system.hive.dao.*; |
| | | import com.matrix.core.tools.DateUtil; |
| | | import com.matrix.system.hive.plugin.util.MoneyUtil; |
| | | import com.matrix.system.constance.Dictionary; |
| | | import com.matrix.system.hive.bean.MoneyCardUse; |
| | | import com.matrix.system.hive.bean.MoneyCardUseFreeze; |
| | | import com.matrix.system.hive.bean.SysOrderItem; |
| | | import com.matrix.system.hive.bean.SysVipInfo; |
| | | import com.matrix.system.hive.dao.*; |
| | | import com.matrix.system.hive.service.MoneyCardUseService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.text.DecimalFormat; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | |
| | | * @date 2016-09-17 10:17 |
| | | */ |
| | | @Service("moneyCardUseService") |
| | | public class MoneyCardUseServiceImpl implements MoneyCardUseService { |
| | | public class MoneyCardUseServiceImpl extends ServiceImpl<MoneyCardUseDao,MoneyCardUse> implements MoneyCardUseService { |
| | | |
| | | |
| | | @Autowired |
| | |
| | | |
| | | @Autowired |
| | | private SysVipLevelDao viplevelDao; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public int add(MoneyCardUse moneyCardUse) { |
| | |
| | | } |
| | | } |
| | | |
| | | //退款 |
| | | @Override |
| | | public int returnMoney(MoneyCardUse moneyCardUse, Long hjkId) { |
| | | |
| | | |
| | | MoneyCardUse realObj = moneyCardUseDao.selectById(moneyCardUse.getId()); |
| | | |
| | | //检测商品是否已付款完成 |
| | | if (realObj.getOrderItemId() != 1) {//不是数据迁移过来的判断付款状态 |
| | | checkOrderStatu(realObj.getOrderItemId()); |
| | | } |
| | | |
| | | if (!realObj.getStatus().equals(Dictionary.TAOCAN_STATUS_YX)) { |
| | | throw new GlobleException("不是有效充值卡"); |
| | | } |
| | | |
| | | if (realObj.getSource().contains(Dictionary.TAOCAN_SOURCE_ZR)) { |
| | | throw new GlobleException("转让的充值卡不能退款"); |
| | | } |
| | | if (realObj.getSource().contains(Dictionary.TAOCAN_SOURCE_ZS)) { |
| | | throw new GlobleException("赠送的充值卡不能退款"); |
| | | } |
| | | |
| | | if (Dictionary.FLAG_YES_Y.equals(realObj.getIsVipCar())) { |
| | | //更新会员等级 |
| | | realObj.getVipInfo().setLevelId(0L); |
| | | infoDao.update(realObj.getVipInfo()); |
| | | } |
| | | StringBuilder content = new StringBuilder(); |
| | | |
| | | //有会籍卡退到会籍卡中,无则退了现金 |
| | | if (hjkId != null && !hjkId.equals("")) { |
| | | MoneyCardUse vipCard = moneyCardUseDao.selectById(hjkId); |
| | | vipCard.setRealMoney(vipCard.getRealMoney() + realObj.getRealMoney()); |
| | | moneyCardUseDao.update(vipCard); |
| | | content.append(realObj.getCardName() + "退款¥" + realObj.getRealMoney() + "到会籍卡") |
| | | .append(vipCard.getCardName()) |
| | | .append(",余次:" + vipCard.getLastCountName()) |
| | | .append(",本金余额:" + vipCard.getRealMoney()) |
| | | .append(",有效期:" + DateUtil.dateToString(vipCard.getFailTime(), DateUtil.DATE_FORMAT_MM)) |
| | | .append(",是否赠送:" + vipCard.getSourceName()); |
| | | } else { |
| | | content.append(realObj.getCardName() + "退款现金¥" + moneyCardUse.getReturnMonery() + ""); |
| | | } |
| | | DecimalFormat df = new DecimalFormat("#.00"); |
| | | double d = Double.valueOf(df.format(realObj.getRealMoney() - Double.valueOf(moneyCardUse.getReturnMonery()))); |
| | | //退款的本金为零,状态为已退款 |
| | | realObj.setRealMoney(d); |
| | | //赠送金额也清零 |
| | | realObj.setGiftMoney(0.0); |
| | | if (d <= 0) { |
| | | realObj.setStatus(Dictionary.TAOCAN_STATUS_TK); |
| | | } |
| | | int i = moneyCardUseDao.update(realObj); |
| | | SysUsers user = (SysUsers) WebUtil.getSession().getAttribute(MatrixConstance.LOGIN_KEY); |
| | | //新增退款流水 |
| | | return i; |
| | | } |
| | | |
| | | //设置为有效 |
| | | @Override |
| | |
| | | } |
| | | } |
| | | moneyCardUseDao.update(proj); |
| | | StringBuilder content = new StringBuilder(); |
| | | content.append(proj.getCardName() + "设置有效"); |
| | | |
| | | } |
| | | |
| | | //设置为失效 |