From 88b54772dbcf5ecab1e2316e4e4626ac901b8908 Mon Sep 17 00:00:00 2001 From: yujian <yujian> Date: 星期二, 22 一月 2019 15:58:24 +0800 Subject: [PATCH] 邀请码添加返回状态 --- fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java | 560 +++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 438 insertions(+), 122 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java index aeaf1a3..f6f6363 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java @@ -12,30 +12,43 @@ import org.apache.commons.beanutils.PropertyUtils; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.yeshi.utils.taobao.TbImgUtil; +import com.yeshi.fanli.dao.mybatis.order.CommonOrderGoodsMapper; import com.yeshi.fanli.dao.mybatis.order.CommonOrderMapper; import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanOrderMapper; import com.yeshi.fanli.entity.bus.user.HongBaoV2; +import com.yeshi.fanli.entity.bus.user.UserInfo; import com.yeshi.fanli.entity.order.CommonOrder; import com.yeshi.fanli.entity.order.CommonOrderGoods; +import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; +import com.yeshi.fanli.entity.taobao.TaoBaoOrder; import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder; import com.yeshi.fanli.exception.order.CommonOrderException; +import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException; import com.yeshi.fanli.service.inter.order.CommonOrderService; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.MoneyBigDecimalUtil; +import com.yeshi.fanli.util.StringUtil; +import com.yeshi.fanli.util.factory.CommonOrderGoodsFactory; +import com.yeshi.fanli.util.taobao.TaoBaoOrderUtil; +import com.yeshi.fanli.util.taobao.TaoKeApiUtil; import com.yeshi.fanli.vo.order.CommonOrderGoodsVO; import com.yeshi.fanli.vo.order.CommonOrderVO; - @Service public class CommonOrderServiceImpl implements CommonOrderService { - + @Resource private CommonOrderMapper commonOrderMapper; - + @Resource private TaoBaoWeiQuanOrderMapper taoBaoWeiQuanOrderMapper; - + + @Resource + private CommonOrderGoodsMapper commonOrderGoodsMapper; + @Override public int insert(CommonOrder record) { return commonOrderMapper.insert(record); @@ -65,106 +78,135 @@ public CommonOrder selectByPrimaryKey(Long id) { return commonOrderMapper.selectByPrimaryKey(id); } - + @Override - public List<CommonOrderVO> listGroupOrderNoByUid(long start, int count, Long uid, Integer state, - Integer type,Integer orderState, String orderNo, String startTime,String endTime, - Integer dateType) throws CommonOrderException{ - return commonOrderMapper.listGroupOrderNoByUid(start, count, uid, state, type, orderState, - orderNo, startTime, endTime, dateType); + public List<CommonOrderVO> listGroupOrderNoByUid(long start, int count, Long uid, Integer state, Integer type, + Integer orderState, String orderNo, String startTime, String endTime, Integer dateType) + throws CommonOrderException { + return commonOrderMapper.listUserOrder(start, count, uid, state, type, orderState, orderNo, startTime, endTime, + dateType); } - + @Override - public long countGroupOrderNoByUid(Long uid,Integer state, Integer type, Integer orderState, - String orderNo, String startTime,String endTime, Integer dateType) throws CommonOrderException{ - return commonOrderMapper.countGroupOrderNoByUid(uid, state, type, orderState, orderNo, - startTime, endTime, dateType); + public long countGroupOrderNoByUid(Long uid, Integer state, Integer type, Integer orderState, String orderNo, + String startTime, String endTime, Integer dateType) throws CommonOrderException { + return commonOrderMapper.countUserOrder(uid, state, type, orderState, orderNo, startTime, endTime, dateType); } - + @Override - public List<CommonOrderVO> getOrderByUid (Integer page, Long uid, Integer state, Integer type, - Integer orderState, String orderNo, String startTime, String endTime, Integer dateType) throws CommonOrderException { - + public List<CommonOrderVO> getOrderByUid(Integer page, Long uid, Integer state, Integer type, Integer orderState, + String orderNo, String startTime, String endTime, Integer dateType) throws CommonOrderException { + int pageSize = Constant.PAGE_SIZE; - - List<CommonOrderVO> listOrder = listGroupOrderNoByUid((page - 1) * pageSize, pageSize, uid, - state, type, orderState, orderNo, startTime, endTime, dateType); - + + List<CommonOrderVO> listOrder = listGroupOrderNoByUid((page - 1) * pageSize, pageSize, uid, state, type, + orderState, orderNo, startTime, endTime, dateType); + // 璁㈠崟淇℃伅涓虹┖ if (listOrder == null || listOrder.size() == 0) { listOrder = new ArrayList<CommonOrderVO>(); return listOrder; } - + // 鍟嗗搧淇℃伅 - List<CommonOrderVO> listGoods = commonOrderMapper.listByOrderNoAndType(listOrder); + List<CommonOrderVO> listGoods = commonOrderMapper.listOrderGoodsInfo(listOrder); // 璁㈠崟鍟嗗搧涓虹┖ - if (listGoods ==null || listGoods.size() == 0) { - return listOrder; + if (listGoods == null || listGoods.size() == 0) { + return listOrder; } - + // 鏁版嵁鍔犲伐閲嶆柊缁勭粐 - listDataFactory(listOrder, listGoods); - + listDataFactory(listOrder, listGoods, uid); + return listOrder; } - @Override - public Map<String, BigDecimal> countOrderByHongBaoType(Long uid, Integer day) { - return commonOrderMapper.countOrderByHongBaoType(uid, day); - } - - @Override - public long countOrder(Long uid,Integer type, Integer day) { - return commonOrderMapper.countBonusOrder(uid, type, day); + public Map<String, BigDecimal> countHistoryOrder(Long uid, Integer day) { + return commonOrderMapper.countHistoryOrder(uid, day); } @Override - public BigDecimal countOrderMoney(Long uid, Integer type, Integer day) { - return commonOrderMapper.countBonusOrderMoney(uid, type, day); + public long countBonusOrderNumber(Long uid, Integer type, Integer day, String startTime, String endTime) { + return commonOrderMapper.countBonusOrderNumber(uid, type, day, startTime, endTime); + } + + @Override + public BigDecimal countBonusOrderMoney(Long uid, Integer type, Integer day, String startTime, String endTime) { + return commonOrderMapper.countBonusOrderMoney(uid, type, day, startTime, endTime); } @Override - public Map<String, BigDecimal> countByUidAndOrderState(Long uid, Integer type, String startTime, - String endTime, Integer day) { - return commonOrderMapper.countByUidAndOrderState(uid, type, startTime, endTime, day); + public Map<String, Object> countBonusOrderMoneyAndNumber(Long uid, Integer type, Integer day, + String startTime, String endTime) { + return commonOrderMapper.countBonusOrderMoneyAndNumber(uid, type, day, startTime, endTime); } - - public void listDataFactory (List<CommonOrderVO> listOrder, List<CommonOrderVO> listGoods ) { - - /* 缁勫悎鍟嗗搧淇℃伅 */ - for (CommonOrderVO commonOrder: listGoods) { - + + @Override + public Map<String, BigDecimal> countByUidAndOrderState(Long uid, Integer type, String startTime, String endTime, + Integer day) { + return commonOrderMapper.countByUidAndOrderState(uid, type, startTime, endTime, day); + } + + public void listDataFactory(List<CommonOrderVO> listOrder, List<CommonOrderVO> listGoods, Long uid) { + + /* 缁勫悎鍟嗗搧淇℃伅 */ + for (CommonOrderVO commonOrder : listGoods) { + CommonOrderGoods goods = commonOrder.getCommonOrderGoods(); if (goods == null) { continue; } - + String orderNo1 = commonOrder.getOrderNo(); Integer sourceType = commonOrder.getSourceType(); - - for (CommonOrderVO order: listOrder) { + + for (CommonOrderVO order : listOrder) { String orderNo2 = order.getOrderNo(); Integer sourceType2 = order.getSourceType(); - + // 鏉ユ簮銆佽鍗曞彿鐩稿悓 if (sourceType.equals(sourceType2) && orderNo1.equals(orderNo2)) { // 鍔犲叆鍟嗗搧淇℃伅 List<CommonOrderGoodsVO> listOrderGoods = order.getListOrderGoods(); - + CommonOrderGoodsVO commonGoodsVO = new CommonOrderGoodsVO(); try { PropertyUtils.copyProperties(commonGoodsVO, goods); } catch (Exception e) { e.printStackTrace(); } + + String picture = commonGoodsVO.getPicture(); + if (!StringUtil.isNullOrEmpty(picture) && !picture.contains("320x320")) { + commonGoodsVO.setPicture(TbImgUtil.getTBSize320Img(picture)); + } - commonGoodsVO.setActualCount(commonOrder.getTotalCount()); - commonGoodsVO.setActualPay(commonOrder.getTotalSettlement()); - + Integer hongBaoType = order.getHongBaoType(); + // 閭�璇疯鍗曚俊鎭繚鎶� + if (HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType + || HongBaoV2.TYPE_ERJI == hongBaoType || HongBaoV2.TYPE_SHARE_YIJI == hongBaoType + || HongBaoV2.TYPE_SHARE_ERJI == hongBaoType) { + Map<String, String> titleMap = new HashMap<String, String>(); + titleMap.put("content", "涓轰繚闅滅敤鎴烽殣绉侊紝鍟嗗搧淇℃伅宸查殣钘�!"); + titleMap.put("fontColor", "#888888"); + titleMap.put("bottomColor", "#E9E9E9"); + commonGoodsVO.setTitle(null); + commonGoodsVO.setGoodsTitle(titleMap); + } + + // 璐拱鏁伴噺 + commonGoodsVO.setActualCount(commonOrder.getTotalCount() + "浠�"); + + BigDecimal totalSettlement = commonOrder.getTotalSettlement(); + if (totalSettlement == null || totalSettlement.compareTo(new BigDecimal(0)) <= 0) { + totalSettlement = commonOrder.getTotalPayment(); + } + // 瀹炰粯娆� + commonGoodsVO.setActualPay("瀹炰粯娆撅細楼" + totalSettlement); + listOrderGoods.add(commonGoodsVO); - + Integer orderType = commonOrder.getOrderType(); if (orderType == null) { String shopType = commonGoodsVO.getShopType(); @@ -172,161 +214,435 @@ commonOrder.setOrderType(1); } else if (CommonOrderGoodsVO.TYPE_TMALL.equalsIgnoreCase(shopType)) { commonOrder.setOrderType(2); - } + } } - + break; } - } + } } - + SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm"); SimpleDateFormat formatday = new SimpleDateFormat("yyyy.MM.dd"); - - for (CommonOrderVO order: listOrder) { - Date createTime = order.getCreateTime(); - if (createTime != null) { - order.setObtainTime(createTime.getTime()); - } - + + for (CommonOrderVO order : listOrder) { + Date thirdCreateTime = order.getThirdCreateTime(); if (thirdCreateTime != null) { - order.setDownTime(format.format(thirdCreateTime)); + order.setDownTime("涓嬪崟鏃堕棿锛�" + format.format(thirdCreateTime)); + order.setObtainTime(thirdCreateTime.getTime()); } - + Date settleTime = order.getSettleTime(); if (settleTime != null) { - order.setReceiveTime(format.format(settleTime)); + order.setReceiveTime("鏀惰揣鏃堕棿锛�" + format.format(settleTime)); } - - /* 璁㈠崟鐘舵�� 杞崲澶勭悊*/ + + /* 璁㈠崟鐘舵�� 杞崲澶勭悊 */ String orderStateContent = ""; Map<String, String> orderStateMap = new HashMap<String, String>(); + // 璁㈠崟鐘舵�� Integer orderState = order.getState(); - if (CommonOrder.STATE_FK == orderState ) { + // 绾㈠寘鐘舵�� + Integer hongBaoState = order.getHongBaoState(); + + Integer stateWholeOrder = order.getStateWholeOrder(); + if (CommonOrder.STATE_WHOLE_ORDER_BUFENYOUXIAO == stateWholeOrder) { + // 鏁翠釜璁㈠崟閮ㄥ垎澶辨晥锛氬垽鏂湡瀹炵姸鎬� 璁㈠崟銆佺孩鍖� + CommonOrderVO buFenOrder = commonOrderMapper.getBuFenOrderState(uid, order.getOrderNo()); + if (buFenOrder != null) { + // 鏈夋晥鐨勮鍗曠姸鎬� + orderState = buFenOrder.getState(); + // 鏈夋晥鐨勭孩鍖呯姸鎬� + hongBaoState = buFenOrder.getHongBaoState(); + } + } + + + if (CommonOrder.STATE_FK == orderState) { orderStateContent = "宸蹭粯娆�"; } else if (CommonOrder.STATE_JS == orderState) { orderStateContent = "宸叉敹璐�"; } else if (CommonOrder.STATE_SX == orderState) { - orderStateContent = "宸查��娆�"; + orderStateContent = "鏈粯娆�/宸查��娆�"; } else if (CommonOrder.STATE_WQ == orderState) { orderStateContent = "宸茬淮鏉�"; - - /* 璁㈠崟缁存潈 鍒ゆ柇鏄惁鍏ㄩ儴缁存潈 */ - List<TaoBaoWeiQuanOrder> listWQ = - taoBaoWeiQuanOrderMapper.selectListByOrderIdAndState(order.getOrderNo(), "缁存潈鎴愬姛"); - - boolean isPart = true; - if (listWQ != null && listWQ.size() > 0) { + + /* 璁㈠崟缁存潈 鍒ゆ柇鏄惁鍏ㄩ儴缁存潈 */ + List<TaoBaoWeiQuanOrder> listWQ = taoBaoWeiQuanOrderMapper + .selectListByOrderIdAndState(order.getOrderNo(), "缁存潈鎴愬姛"); + + boolean isPart = false;// 榛樿澶辨晥 + + if (listWQ != null && listWQ.size() > 0) { BigDecimal fanTotalMoney = new BigDecimal(0); - for (TaoBaoWeiQuanOrder weiQuanOrder: listWQ) { + for (TaoBaoWeiQuanOrder weiQuanOrder : listWQ) { BigDecimal fanMoney = weiQuanOrder.getFanMoney(); if (fanMoney != null) { fanTotalMoney = MoneyBigDecimalUtil.add(fanTotalMoney, fanMoney); } } - - if (fanTotalMoney.compareTo(order.getHongBao()) >= 0) { - isPart = false; + + if (fanTotalMoney.compareTo(order.getHongBao()) < 0) { + isPart = true; } } - + if (isPart) { - order.setHongBaoState(HongBaoV2.STATE_BUFENSHIXIAO); // 閮ㄥ垎澶辨晥 + hongBaoState = HongBaoV2.STATE_BUFENSHIXIAO; // 閮ㄥ垎澶辨晥 } else { - order.setHongBaoState(HongBaoV2.STATE_SHIXIAO); // 鍏ㄩ儴澶辨晥 + hongBaoState = HongBaoV2.STATE_SHIXIAO; // 鍏ㄩ儴澶辨晥 } } orderStateMap.put("content", orderStateContent); orderStateMap.put("fontColor", "#666666"); order.setOrderState(orderStateMap); - + String hongbaoInfo = ""; - /* 璁㈠崟杩斿埄绫诲瀷 杞崲 */ + /* 璁㈠崟杩斿埄绫诲瀷 杞崲 */ Integer hongBaoType = order.getHongBaoType(); if (HongBaoV2.TYPE_ZIGOU == hongBaoType || 2 == hongBaoType) { // 鑷喘 hongbaoInfo = "杩斿埄"; - order.setHongBaoType(1); + order.setOrderOrigin("1"); order.setHongBaoTypePic(CommonOrder.TYPE_FANLI); - } else if (HongBaoV2.TYPE_SHARE_GOODS == hongBaoType || HongBaoV2.TYPE_SHARE_YIJI == hongBaoType - || HongBaoV2.TYPE_SHARE_ERJI == hongBaoType) { + } else if (HongBaoV2.TYPE_SHARE_GOODS == hongBaoType) { // 鍒嗕韩 hongbaoInfo = "濂栭噾"; - order.setHongBaoType(2); + order.setOrderOrigin("2"); order.setHongBaoTypePic(CommonOrder.TYPE_SHARE); - } else if (HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType - || HongBaoV2.TYPE_ERJI == hongBaoType) { + } else if (HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType + || HongBaoV2.TYPE_ERJI == hongBaoType || HongBaoV2.TYPE_SHARE_YIJI == hongBaoType + || HongBaoV2.TYPE_SHARE_ERJI == hongBaoType) { // 閭�璇� hongbaoInfo = "濂栭噾"; - order.setHongBaoType(3); + order.setOrderOrigin("3"); order.setHongBaoTypePic(CommonOrder.TYPE_INVITE); } - - - String hongBaoDate = ""; + + String hongBaoDate = null; String hongBaoState_Str = ""; String hongbaoInfoFontColor = "#E5005C"; - + /* 绾㈠寘鐘舵�� 杞崲 */ String stateContent = ""; String stateFontColor = "#E5005C"; Integer orderHongBaoState = null; - Integer hongBaoState = order.getHongBaoState(); + if (HongBaoV2.STATE_KELINGQU == hongBaoState || HongBaoV2.STATE_BUKELINGQU == hongBaoState) { orderHongBaoState = 1; stateContent = "鏈埌璐�"; hongBaoState_Str = "棰勪及"; - + Date preAccountTime = order.getPreAccountTime(); if (preAccountTime != null) { - hongBaoDate = "棰勮鍒拌处鏃堕棿" + formatday.format(preAccountTime); + hongBaoDate = "棰勮鍒拌处鏃堕棿锛�" + formatday.format(preAccountTime); } - + } else if (HongBaoV2.STATE_YILINGQU == hongBaoState) { orderHongBaoState = 3; stateContent = "宸插埌璐�"; - + Date accountTime = order.getAccountTime(); if (accountTime != null) { - hongBaoDate = "鍒拌处鏃堕棿" + formatday.format(accountTime); + hongBaoDate = "鍒拌处鏃堕棿锛�" + formatday.format(accountTime); } - + } else if (HongBaoV2.STATE_BUFENSHIXIAO == hongBaoState) { - stateContent = "閮ㄥ垎澶辨晥"; + stateContent = "閮ㄥ垎澶辨晥"; orderHongBaoState = 3; Date accountTime = order.getAccountTime(); if (accountTime != null) { - hongBaoDate = "鍒拌处鏃堕棿" + formatday.format(accountTime); + hongBaoDate = "鍒拌处鏃堕棿锛�" + formatday.format(accountTime); } - + } else if (HongBaoV2.STATE_SHIXIAO == hongBaoState) { orderHongBaoState = 4; - stateContent = "宸插け鏁�"; - hongBaoDate = " "; + stateContent = "宸插け鏁�"; hongbaoInfoFontColor = "#888888"; } order.setHongBaoState(orderHongBaoState); order.setHongBaoDate(hongBaoDate); - + Map<String, String> stateMap = new HashMap<String, String>(); stateMap.put("content", stateContent); stateMap.put("fontColor", stateFontColor); order.setAccountState(stateMap); - - if ("濂栭噾".equals(hongbaoInfo) && hongBaoState_Str.trim().length() > 0) { - hongbaoInfo = hongBaoState_Str + hongbaoInfo; - } + + hongbaoInfo = hongBaoState_Str + hongbaoInfo; + BigDecimal hongBao = order.getHongBao(); if (hongBao == null) { hongBao = new BigDecimal(0); } Map<String, String> hongBaoMap = new HashMap<String, String>(); - hongBaoMap.put("content", hongbaoInfo + " 楼" + hongBao); + hongBaoMap.put("content", hongbaoInfo + " 楼" + hongBao.setScale(2, BigDecimal.ROUND_DOWN).toString()); hongBaoMap.put("fontColor", hongbaoInfoFontColor); order.setHongBaoInfo(hongBaoMap); } - } + + @Override + public List<CommonOrder> listBySourceTypeAndOrderId(int sourceType, String orderId) { + + return null; + } + + @Transactional + @Override + public List<CommonOrder> addTaoBaoOrder(List<TaoBaoOrder> taoBaoOrders, Long uid) throws CommonOrderException { + List<CommonOrder> commonOrderList = new ArrayList<>(); + // 鍒ゆ柇鎵�鏈夌殑璁㈠崟鐘舵�� + int invalidCount = 0; + for (TaoBaoOrder tb : taoBaoOrders) { + if ("璁㈠崟澶辨晥".equalsIgnoreCase(tb.getOrderState())) { + invalidCount++; + } + } + + // 鑾峰彇鏁翠綋璁㈠崟鐨勭姸鎬� + int wholeOrderState = 0; + if (taoBaoOrders.size() == invalidCount) + wholeOrderState = CommonOrder.STATE_WHOLE_ORDER_SHIXIAO; + else if (invalidCount == 0) + wholeOrderState = CommonOrder.STATE_WHOLE_ORDER_YOUXIAO; + else + wholeOrderState = CommonOrder.STATE_WHOLE_ORDER_BUFENYOUXIAO; + + for (TaoBaoOrder taoBaoOrder : taoBaoOrders) { + CommonOrder commonOrder = commonOrderMapper.selectByOrderNoAndOrderTypeAndOrderBy(taoBaoOrder.getOrderId(), + Constant.SOURCE_TYPE_TAOBAO, taoBaoOrder.getOrderBy()); + if (commonOrder == null)// 鏂板 + { + commonOrder = TaoBaoOrderUtil.convert(taoBaoOrder); + CommonOrderGoods goods = new CommonOrderGoods(); + goods.setGoodsId(taoBaoOrder.getAuctionId() + ""); + goods.setGoodsType(Constant.SOURCE_TYPE_TAOBAO); + + // 鍟嗗搧鏄惁宸茬粡鎻掑叆 + List<CommonOrderGoods> commonGoodsList = commonOrderGoodsMapper + .listByGoodsIdAndGoodsType(goods.getGoodsId(), goods.getGoodsType()); + if (commonGoodsList.size() <= 0)// 涓嶅瓨鍦ㄥ氨鎻掑叆鍟嗗搧 + { + TaoBaoGoodsBrief taoBaoGoods = null; + try { + taoBaoGoods = TaoKeApiUtil.getSimpleGoodsInfo(taoBaoOrder.getAuctionId()); + } catch (TaobaoGoodsDownException e) { + e.printStackTrace(); + } + if (taoBaoGoods != null) { + goods = CommonOrderGoodsFactory.create(taoBaoGoods); + } + goods.setCreateTime(new Date()); + goods.setUpdateTime(new Date()); + commonOrderGoodsMapper.insertSelective(goods); + } else + goods.setId(commonGoodsList.get(commonGoodsList.size() - 1).getId()); + commonOrder.setCommonOrderGoods(goods); + commonOrder.setUserInfo(new UserInfo(uid)); + commonOrder.setCreateTime(new Date()); + commonOrder.setStateWholeOrder(wholeOrderState); + commonOrderMapper.insertSelective(commonOrder); + + commonOrderList.add(commonOrder); + continue; + } else {// 淇敼 + // 宸茬粡缁撶畻鎴栬�呭凡缁忓け鏁堢殑璁㈠崟涓嶅鐞� + if (commonOrder.getState() == CommonOrder.STATE_JS || commonOrder.getState() == CommonOrder.STATE_SX) { + commonOrderList.add(commonOrder); + continue; + } + CommonOrder newCommonOrder = TaoBaoOrderUtil.convert(taoBaoOrder); + CommonOrder updateCommonOrder = new CommonOrder(commonOrder.getId()); + updateCommonOrder.seteIncome(newCommonOrder.geteIncome()); + updateCommonOrder.setEstimate(newCommonOrder.getEstimate()); + updateCommonOrder.setPayment(newCommonOrder.getPayment()); + updateCommonOrder.setSettlement(newCommonOrder.getSettlement()); + updateCommonOrder.setSettleTime(newCommonOrder.getSettleTime()); + updateCommonOrder.setState(newCommonOrder.getState()); + updateCommonOrder.setStateWholeOrder(wholeOrderState); + updateCommonOrder.setUpdateTime(new Date()); + commonOrderMapper.updateByPrimaryKeySelective(updateCommonOrder); + commonOrderList.add(commonOrderMapper.selectByPrimaryKey(updateCommonOrder.getId())); + continue; + } + } + return commonOrderList; + } + + @Override + public long countByUidAndOrderStateWithOrderBalanceTime(Long uid, int state, Date minDate, Date maxDate) { + return commonOrderMapper.countByUidAndOrderStateWithOrderBalanceTime(uid, state, minDate, maxDate); + } + + + @Override + public List<CommonOrderVO> listQueryByUid(long start, int count, Long uid, Integer state, Integer type, + Integer orderState, String orderNo, String startTime, String endTime, Integer dateType) + throws CommonOrderException { + + + List<CommonOrderVO> list = commonOrderMapper.listQueryByUid(start, count, uid, state, type, + orderState, orderNo, startTime, endTime, dateType); + + if (list == null) { + list = new ArrayList<CommonOrderVO>(); + } + + if (list.size() == 0) { + return list; + } + + SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); + for (CommonOrderVO order : list) { + + // 涓嬪崟鏃堕棿 + Date thirdCreateTime = order.getThirdCreateTime(); + if (thirdCreateTime != null) { + order.setDownTime(format.format(thirdCreateTime)); + } + // 鏀惰揣鏃堕棿 + Date settleTime = order.getSettleTime(); + if (settleTime != null) { + order.setReceiveTime(format.format(settleTime)); + } + + // 鍒拌处鏃堕棿 + Date accountTime = order.getAccountTime(); + if (accountTime != null) { + order.setHongBaoDate(format.format(accountTime)); + } + + BigDecimal settlement = order.getSettlement(); + if (settlement != null && settlement.compareTo(new BigDecimal(0)) > 0) { + order.setPayment(settlement); // 瀹為檯浠樻閲戦 + } + + /* 璁㈠崟杩斿埄绫诲瀷 杞崲 */ + Integer hongBaoType = order.getHongBaoType(); + if (HongBaoV2.TYPE_ZIGOU == hongBaoType || 2 == hongBaoType) { + // 鑷喘 + order.setHongBaoType(1); + } else if (HongBaoV2.TYPE_SHARE_GOODS == hongBaoType) { + // 鍒嗕韩 + order.setHongBaoType(2); + } else if (HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType + || HongBaoV2.TYPE_ERJI == hongBaoType || HongBaoV2.TYPE_SHARE_YIJI == hongBaoType + || HongBaoV2.TYPE_SHARE_ERJI == hongBaoType) { + // 閭�璇� + order.setHongBaoType(3); + } + + Integer hongBaoState = order.getHongBaoState(); + if (HongBaoV2.STATE_KELINGQU == hongBaoState || HongBaoV2.STATE_BUKELINGQU == hongBaoState) { + // 鏈埌璐� + order.setHongBaoState(1); + + } else if (HongBaoV2.STATE_YILINGQU == hongBaoState) { + // 宸插埌璐� + order.setHongBaoState(2); + + } else if (HongBaoV2.STATE_SHIXIAO == hongBaoState) { + // 宸插け鏁� + order.setHongBaoState(3); + } + + } + + return list; + + } + + @Override + public long countQueryByUid(Long uid, Integer state, Integer type, Integer orderState, String orderNo, + String startTime, String endTime, Integer dateType) throws CommonOrderException { + return commonOrderMapper.countQueryByUid(uid, state, type, orderState, orderNo, startTime, endTime, dateType); + } + + + + @Override + public List<CommonOrderVO> listQuery(long start, int count, Integer keyType, String key, Integer state, + Integer type, Integer orderState, String startTime, String endTime) throws CommonOrderException { + + + List<CommonOrderVO> list = commonOrderMapper.listQuery(start, count,keyType, key, state, type, + orderState, startTime, endTime); + + + if (list == null) { + list = new ArrayList<CommonOrderVO>(); + } + + if (list.size() == 0) { + return list; + } + + SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); + for (CommonOrderVO order : list) { + + // 涓嬪崟鏃堕棿 + Date thirdCreateTime = order.getThirdCreateTime(); + if (thirdCreateTime != null) { + order.setDownTime(format.format(thirdCreateTime)); + } + // 鏀惰揣鏃堕棿 + Date settleTime = order.getSettleTime(); + if (settleTime != null) { + order.setReceiveTime(format.format(settleTime)); + } + + // 鍒拌处鏃堕棿 + Date accountTime = order.getAccountTime(); + if (accountTime != null) { + order.setHongBaoDate(format.format(accountTime)); + } + + BigDecimal settlement = order.getSettlement(); + if (settlement != null && settlement.compareTo(new BigDecimal(0)) > 0) { + order.setPayment(settlement); // 瀹為檯浠樻閲戦 + } + + /* 璁㈠崟杩斿埄绫诲瀷 杞崲 */ + Integer hongBaoType = order.getHongBaoType(); + if (HongBaoV2.TYPE_ZIGOU == hongBaoType || 2 == hongBaoType) { + // 鑷喘 + order.setHongBaoType(1); + } else if (HongBaoV2.TYPE_SHARE_GOODS == hongBaoType) { + // 鍒嗕韩 + order.setHongBaoType(2); + } else if (HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType + || HongBaoV2.TYPE_ERJI == hongBaoType || HongBaoV2.TYPE_SHARE_YIJI == hongBaoType + || HongBaoV2.TYPE_SHARE_ERJI == hongBaoType) { + // 閭�璇� + order.setHongBaoType(3); + } + + Integer hongBaoState = order.getHongBaoState(); + if (HongBaoV2.STATE_KELINGQU == hongBaoState || HongBaoV2.STATE_BUKELINGQU == hongBaoState) { + // 鏈埌璐� + order.setHongBaoState(1); + + } else if (HongBaoV2.STATE_YILINGQU == hongBaoState) { + // 宸插埌璐� + order.setHongBaoState(2); + + } else if (HongBaoV2.STATE_SHIXIAO == hongBaoState) { + // 宸插け鏁� + order.setHongBaoState(3); + } + + } + + return list; + + } + + @Override + public long countQuery(Integer keyType, String key, Integer state, Integer type, Integer orderState, + String startTime, String endTime) throws CommonOrderException { + return commonOrderMapper.countQuery(keyType, key, state, type, orderState, startTime, endTime); + } + } -- Gitblit v1.8.0