|  |  |  | 
|---|
|  |  |  | import com.matrix.system.constance.Dictionary; | 
|---|
|  |  |  | import com.matrix.system.hive.bean.*; | 
|---|
|  |  |  | import com.matrix.system.hive.dao.*; | 
|---|
|  |  |  | import com.matrix.system.hive.plugin.util.DateUtils; | 
|---|
|  |  |  | import com.matrix.core.tools.DateUtil; | 
|---|
|  |  |  | import com.matrix.system.hive.plugin.util.MoneyUtil; | 
|---|
|  |  |  | import com.matrix.system.hive.service.MoneyCardUseService; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SysVipLevelDao viplevelDao; | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public int add(MoneyCardUse moneyCardUse) { | 
|---|
|  |  |  | 
|---|
|  |  |  | content.append("获取会员" + getObj.getVipInfo().getVipName() + "的" + getObj.getCardName()) | 
|---|
|  |  |  | .append(",余次:" + getObj.getLastCountName()) | 
|---|
|  |  |  | .append(",本金余额:" + getObj.getRealMoney()) | 
|---|
|  |  |  | .append(",有效期:" + DateUtils.dateToString(getObj.getFailTime(), DateUtils.DATE_FORMAT_MM)) | 
|---|
|  |  |  | .append(",有效期:" + DateUtil.dateToString(getObj.getFailTime(), DateUtil.DATE_FORMAT_MM)) | 
|---|
|  |  |  | .append(",是否赠送:" + getObj.getSourceName()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //退款 | 
|---|
|  |  |  | @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(",有效期:" + DateUtils.dateToString(vipCard.getFailTime(), DateUtils.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 | 
|---|