| | |
| | | package com.yeshi.fanli.service.impl.order;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.order.HongBaoOrderMapper;
|
| | | import com.yeshi.fanli.entity.order.HongBaoOrder;
|
| | | import com.yeshi.fanli.service.inter.order.HongBaoOrderService;
|
| | |
|
| | | @Service
|
| | | public class HongBaoOrderServiceImpl implements HongBaoOrderService {
|
| | |
|
| | | @Resource
|
| | | private HongBaoOrderMapper hongBaoOrderMapper;
|
| | |
|
| | | @Override
|
| | | public int insert(HongBaoOrder record) {
|
| | | return hongBaoOrderMapper.insert(record);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int insertSelective(HongBaoOrder record) {
|
| | | return hongBaoOrderMapper.insertSelective(record);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int updateByPrimaryKeySelective(HongBaoOrder record) {
|
| | | return hongBaoOrderMapper.updateByPrimaryKeySelective(record);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int updateByPrimaryKey(HongBaoOrder record) {
|
| | | return hongBaoOrderMapper.updateByPrimaryKey(record);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int deleteByPrimaryKey(Long id) {
|
| | | return hongBaoOrderMapper.deleteByPrimaryKey(id);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public HongBaoOrder selectByPrimaryKey(Long id) {
|
| | | return hongBaoOrderMapper.selectByPrimaryKey(id);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<HongBaoOrder> listFanLiOrder(Long uid, int page, int pageSize) {
|
| | | return hongBaoOrderMapper.listFanLiOrder(uid, (page - 1) * pageSize, pageSize);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countFanLiOrder(Long uid) {
|
| | | Long count = hongBaoOrderMapper.countFanLiOrder(uid);
|
| | | return count == null ? 0 : count;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countByOrderNoAndHongBaoType(String orderNo, int hongBaotype, int sourceType) {
|
| | | return hongBaoOrderMapper.countByOrderNoAndHongBaoType(orderNo, hongBaotype, sourceType);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public HongBaoOrder selectDetailByCommonOrderId(Long commonOrderId) {
|
| | | return hongBaoOrderMapper.selectByCommonOrderId(commonOrderId);
|
| | | }
|
| | |
|
| | | }
|
| | | package com.yeshi.fanli.service.impl.order; |
| | | |
| | | 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.order.HongBaoOrderMapper; |
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2; |
| | | import com.yeshi.fanli.entity.order.HongBaoOrder; |
| | | import com.yeshi.fanli.service.inter.order.HongBaoOrderService; |
| | | import com.yeshi.fanli.vo.order.HongBaoCountVO; |
| | | |
| | | @Service |
| | | public class HongBaoOrderServiceImpl implements HongBaoOrderService { |
| | | |
| | | @Resource |
| | | private HongBaoOrderMapper hongBaoOrderMapper; |
| | | |
| | | @Override |
| | | public int insert(HongBaoOrder record) { |
| | | return hongBaoOrderMapper.insert(record); |
| | | } |
| | | |
| | | @Override |
| | | public int insertSelective(HongBaoOrder record) { |
| | | return hongBaoOrderMapper.insertSelective(record); |
| | | } |
| | | |
| | | @Override |
| | | public int updateByPrimaryKeySelective(HongBaoOrder record) { |
| | | return hongBaoOrderMapper.updateByPrimaryKeySelective(record); |
| | | } |
| | | |
| | | @Override |
| | | public int updateByPrimaryKey(HongBaoOrder record) { |
| | | return hongBaoOrderMapper.updateByPrimaryKey(record); |
| | | } |
| | | |
| | | @Override |
| | | public int deleteByPrimaryKey(Long id) { |
| | | return hongBaoOrderMapper.deleteByPrimaryKey(id); |
| | | } |
| | | |
| | | @Override |
| | | public HongBaoOrder selectByPrimaryKey(Long id) { |
| | | return hongBaoOrderMapper.selectByPrimaryKey(id); |
| | | } |
| | | |
| | | @Override |
| | | public List<HongBaoOrder> listFanLiOrder(Long uid, int page, int pageSize) { |
| | | return hongBaoOrderMapper.listFanLiOrder(uid, (page - 1) * pageSize, pageSize); |
| | | } |
| | | |
| | | @Override |
| | | public long countFanLiOrder(Long uid) { |
| | | Long count = hongBaoOrderMapper.countFanLiOrder(uid); |
| | | return count == null ? 0 : count; |
| | | } |
| | | |
| | | @Override |
| | | public long countByOrderNoAndHongBaoType(String orderNo, int hongBaotype, int sourceType) { |
| | | return hongBaoOrderMapper.countByOrderNoAndHongBaoType(orderNo, hongBaotype, sourceType); |
| | | } |
| | | |
| | | @Override |
| | | public HongBaoOrder selectDetailByCommonOrderId(Long commonOrderId) { |
| | | return hongBaoOrderMapper.selectByCommonOrderId(commonOrderId); |
| | | } |
| | | |
| | | @Override |
| | | public HongBaoOrder selectDetailByHongBaoId(Long hongBaoId) { |
| | | return hongBaoOrderMapper.selectByHongBaoId(hongBaoId); |
| | | } |
| | | |
| | | @Override |
| | | public List<HongBaoOrder> listByOrderIdAndSourceType(String orderId, int sourceType) { |
| | | return hongBaoOrderMapper.listByOrderIdAndSourceType(orderId, sourceType); |
| | | } |
| | | |
| | | @Override |
| | | public List<HongBaoOrder> listDetailByOrderIdAndSourceType(String orderId, int sourceType) { |
| | | return hongBaoOrderMapper.listDetailByOrderIdAndSourceType(orderId, sourceType); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<HongBaoOrder> listDetailByOrderIdAndSourceTypeAndUid(String orderId, int sourceType, Long uid) { |
| | | return hongBaoOrderMapper.listDetailByOrderIdAndSourceTypeAndUid(orderId, sourceType,uid); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public HongBaoCountVO getHongBaoCountVO(List<HongBaoOrder> list) { |
| | | HongBaoCountVO countVO = new HongBaoCountVO(); |
| | | if (list == null || list.size() == 0) { |
| | | countVO.setTotalMoney(new BigDecimal(0)); |
| | | countVO.setValidMoney(new BigDecimal(0)); |
| | | countVO.setCurrentState(HongBaoV2.STATE_SHIXIAO); |
| | | } else { |
| | | int type = 0; |
| | | int invalid = 0; |
| | | int arrivalAccount = 0; |
| | | BigDecimal totalMoney = new BigDecimal(0); |
| | | BigDecimal validMoney = new BigDecimal(0); |
| | | Date accountTime = null; |
| | | for (HongBaoOrder hongBaoOrder: list) { |
| | | HongBaoV2 hongBao = hongBaoOrder.getHongBaoV2(); |
| | | totalMoney = totalMoney.add(hongBao.getMoney()); |
| | | |
| | | Integer state = hongBao.getState(); |
| | | if (state != HongBaoV2.STATE_SHIXIAO) { |
| | | validMoney = validMoney.add(hongBao.getMoney()); |
| | | } |
| | | if (state == HongBaoV2.STATE_SHIXIAO) { |
| | | invalid ++; |
| | | } else if (state == HongBaoV2.STATE_YILINGQU) { |
| | | arrivalAccount ++; |
| | | } |
| | | |
| | | // 到账时间 |
| | | Date getTime = hongBao.getGetTime(); |
| | | if (getTime != null && (accountTime == null || accountTime.getTime() < getTime.getTime())) { |
| | | accountTime = getTime; |
| | | } |
| | | |
| | | if (type == 0) { |
| | | type = hongBao.getType(); |
| | | } |
| | | } |
| | | countVO.setTotalMoney(totalMoney); |
| | | countVO.setValidMoney(validMoney); |
| | | countVO.setCurrentState(HongBaoV2.STATE_SHIXIAO); |
| | | |
| | | if (invalid == list.size()) { |
| | | countVO.setCurrentState(HongBaoV2.STATE_SHIXIAO); |
| | | } else if (arrivalAccount > 0) { |
| | | countVO.setCurrentState(HongBaoV2.STATE_YILINGQU); |
| | | } else { |
| | | countVO.setCurrentState(HongBaoV2.STATE_BUKELINGQU); |
| | | } |
| | | } |
| | | return countVO; |
| | | } |
| | | |
| | | |
| | | } |