| | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.yeshi.fanli.entity.SystemEnum; |
| | | import com.yeshi.fanli.entity.dy.DYOrder; |
| | | import com.yeshi.fanli.service.inter.order.pdd.PDDOrderService; |
| | | import com.yeshi.fanli.util.goods.douyin.CSJCPSApiUtil; |
| | | import com.yeshi.fanli.util.goods.douyin.vo.DYGoodsDetail; |
| | | import org.apache.commons.beanutils.PropertyUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | |
| | | @Service |
| | | public class CommonOrderServiceImpl implements CommonOrderService { |
| | | |
| | | private Logger logger = LoggerFactory.getLogger(CommonOrderService.class); |
| | | |
| | | |
| | | @Resource |
| | | private CommonOrderMapper commonOrderMapper; |
| | |
| | | CommonOrderGoodsVO commonGoodsVO = new CommonOrderGoodsVO(); |
| | | PropertyUtils.copyProperties(commonGoodsVO, goods); |
| | | commonGoodsVO.setGoodsType(sourceType); |
| | | commonGoodsVO.setPlaceOrderTime(TimeUtil.getGernalTime(order.getThirdCreateTime().getTime(),"yyyy.MM.dd HH:mm")); |
| | | commonGoodsVO.setPlaceOrderTime(TimeUtil.getGernalTime(order.getThirdCreateTime().getTime(), "yyyy.MM.dd HH:mm")); |
| | | |
| | | |
| | | // 淘宝商品图片处理 |
| | |
| | | if (totalSettlement == null || totalSettlement.compareTo(new BigDecimal(0)) <= 0) { |
| | | totalSettlement = commonOrder.getTotalPayment(); |
| | | } |
| | | if (totalSettlement== null || totalSettlement.compareTo(new BigDecimal(0)) <= 0) |
| | | if (totalSettlement == null || totalSettlement.compareTo(new BigDecimal(0)) <= 0) |
| | | commonGoodsVO.setPayState("未付款/已退款"); |
| | | else |
| | | commonGoodsVO.setPayState("已付款"); |
| | |
| | | Map<String, Object> jump = new HashMap<String, Object>(); |
| | | jump.put("type", 1); // 页面跳转 |
| | | jump.put("params", jumpLink); |
| | | jump.put("jumpDetail", jumpDetailV2Service.getByTypeCache("freeCouponDetail")); |
| | | jump.put("jumpDetail", jumpDetailV2Service.getByTypeCache("freeCouponDetail", acceptData.getSystem())); |
| | | |
| | | Map<String, Object> rewardMap = new HashMap<String, Object>(); |
| | | rewardMap.put("text", rewardStyleVO); |
| | |
| | | Map<String, Object> jump = new HashMap<String, Object>(); |
| | | jump.put("type", 1); // 1 常规跳转页面 |
| | | jump.put("params", jumpLink); |
| | | jump.put("jumpDetail", jumpDetailV2Service.getByTypeCache("rewardCouponDetail")); |
| | | jump.put("jumpDetail", jumpDetailV2Service.getByTypeCache("rewardCouponDetail", acceptData.getSystem())); |
| | | rewardMap.put("jump", jump); |
| | | order.setRewardDetail(rewardMap); |
| | | } |
| | |
| | | long limitDate = TimeUtil.convertDateToTemp(Constant.VIP_ONLINE_TIME); |
| | | if (downOrderTime > limitDate) { |
| | | // 2.1 开始新版 |
| | | rewardCounponLimitTime(order, accountTime); |
| | | rewardCounponLimitTime(order, accountTime, acceptData.getSystem()); |
| | | } else if (hasRewardCoupon) { |
| | | // 在2.1新版上线之前订单-存在则显示奖励券可使用 |
| | | ClientTextStyleVO rewardStyleVO = new ClientTextStyleVO(); |
| | |
| | | Map<String, Object> jump = new HashMap<String, Object>(); |
| | | jump.put("type", 2); // 弹框 |
| | | jump.put("params", jumpLink); |
| | | jump.put("jumpDetail", jumpDetailV2Service.getByTypeCache("rewardCouponDetail")); |
| | | jump.put("jumpDetail", jumpDetailV2Service.getByTypeCache("rewardCouponDetail", acceptData.getSystem())); |
| | | |
| | | Map<String, Object> rewardMap = new HashMap<String, Object>(); |
| | | rewardMap.put("text", rewardStyleVO); |
| | |
| | | } |
| | | } |
| | | |
| | | private void rewardCounponLimitTime(CommonOrderVO order, Date accountTime) throws Exception { |
| | | private void rewardCounponLimitTime(CommonOrderVO order, Date accountTime, SystemEnum system) throws Exception { |
| | | // 倒计时验证 |
| | | Date endDay = DateUtil.plusDayDate(Constant.COUPON_REWARD_LIMIT_DAY, accountTime); |
| | | long currentTime = java.lang.System.currentTimeMillis(); |
| | |
| | | Map<String, Object> jump = new HashMap<String, Object>(); |
| | | jump.put("type", 2); // 弹出框使用券 |
| | | jump.put("params", jumpLink); |
| | | jump.put("jumpDetail", jumpDetailV2Service.getByTypeCache("rewardCouponDetail")); |
| | | jump.put("jumpDetail", jumpDetailV2Service.getByTypeCache("rewardCouponDetail", system)); |
| | | rewardMap.put("jump", jump); |
| | | order.setRewardDetail(rewardMap); |
| | | } |
| | |
| | | } else { |
| | | cog.setGoodsId(taoBaoOrder.getAuctionId() + ""); |
| | | cog.setGoodsType(Constant.SOURCE_TYPE_TAOBAO); |
| | | cog.setTitle(taoBaoOrder.getTitle()); |
| | | newCommonOrder.setCommonOrderGoods(cog); |
| | | } |
| | | newCommonOrder.setStateWholeOrder(wholeOrderState); |
| | |
| | | taoBaoGoods.getRootCategoryName(), taoBaoGoods.getLeafName())); |
| | | } catch (TaobaoGoodsDownException e) { |
| | | e.printStackTrace(); |
| | | LogHelper.errorDetailInfo(e, "AUCTIONID:" + taoBaoOrder.getAuctionId(), ""); |
| | | logger.warn("淘宝商品下架:{}", taoBaoOrder.getAuctionId(), e); |
| | | try { |
| | | taoBaoGoods = TaoBaoUtil.getSimpleGoodsBrief(taoBaoOrder.getAuctionId()); |
| | | // 记录商品分类 |
| | | |
| | | } catch (Exception e1) { |
| | | CommonGoods commonGoods = commonGoodsService.getCommonGoodsByGoodsIdAndGoodsType( |
| | | taoBaoOrder.getAuctionId(), Constant.SOURCE_TYPE_TAOBAO); |
| | |
| | | } |
| | | cog.setCreateTime(new Date()); |
| | | cog.setUpdateTime(new Date()); |
| | | //覆盖原来的商品ID |
| | | cog.setGoodsId(newCommonOrder.getCommonOrderGoods().getGoodsId()); |
| | | commonOrderGoodsMapper.insertSelective(cog); |
| | | } |
| | | newCommonOrder.setUserInfo(new UserInfo(uid)); |
| | |
| | | { |
| | | SuningGoodsInfo pddGoods = null; |
| | | // TODO 需要获取 |
| | | pddGoods = SuningApiUtil.getGoodsDetail(suningOrderInfo.getGoodsNum(), suningOrderInfo.getSellerCode()); |
| | | pddGoods = SuningApiUtil.getGoodsDetail(suningOrderInfo.getGoodsNum(), "0000000000"); |
| | | if (pddGoods != null) { |
| | | cog = CommonOrderGoodsFactory.create(pddGoods); |
| | | } |
| | |
| | | } |
| | | addConfirmMQMsg(commonOrderList); |
| | | return commonOrderList; |
| | | } |
| | | |
| | | @Override |
| | | public List<CommonOrderAddResultDTO> addDYOrder(DYOrder order, Long uid) throws CommonOrderException { |
| | | List<CommonOrderAddResultDTO> commonOrderList = new ArrayList<>(); |
| | | |
| | | CommonOrder newCommonOrder = CommonOrderFactory.create(order); |
| | | CommonOrderGoods cog = new CommonOrderGoods(); |
| | | cog.setGoodsId(order.getProduct_id()); |
| | | cog.setGoodsType(Constant.SOURCE_TYPE_DY); |
| | | newCommonOrder.setCommonOrderGoods(cog); |
| | | newCommonOrder.setStateWholeOrder(newCommonOrder.getState()); |
| | | // 订单商品插入 |
| | | List<CommonOrderGoods> commonGoodsList = commonOrderGoodsMapper.listByGoodsIdAndGoodsType(cog.getGoodsId(), |
| | | cog.getGoodsType()); |
| | | if (commonGoodsList.size() <= 0)// 不存在就插入商品 |
| | | { |
| | | DYGoodsDetail goods = CSJCPSApiUtil.goodsDetail(Long.parseLong(order.getProduct_id())); |
| | | if (goods == null) { |
| | | goods = new DYGoodsDetail(); |
| | | goods.setTitle(order.getProduct_name()); |
| | | goods.setPrice(0); |
| | | goods.setProduct_id(Long.parseLong(order.getProduct_id())); |
| | | goods.setCover(order.getProduct_img()); |
| | | } |
| | | |
| | | if (goods != null) { |
| | | cog = CommonOrderGoodsFactory.create(goods); |
| | | } |
| | | |
| | | cog.setCreateTime(new Date()); |
| | | cog.setUpdateTime(new Date()); |
| | | commonOrderGoodsMapper.insertSelective(cog); |
| | | } else { |
| | | |
| | | } |
| | | newCommonOrder.setUserInfo(new UserInfo(uid)); |
| | | commonOrderList.add(addCommonOrder(newCommonOrder)); |
| | | |
| | | addConfirmMQMsg(commonOrderList); |
| | | return commonOrderList; |
| | | } |
| | | |
| | | private boolean needUpdateCommonOrder(CommonOrder oldCommonOrder, CommonOrder newCommonOrder) { |
| | | // 非京东已经结算,已经失效,状态未改变的订单不处理 |
| | | if ((oldCommonOrder.getState() == CommonOrder.STATE_JS |
| | | && oldCommonOrder.getSourceType() != Constant.SOURCE_TYPE_JD) |
| | | || oldCommonOrder.getState() == CommonOrder.STATE_SX |
| | | || oldCommonOrder.getState() == CommonOrder.STATE_WQ) { |
| | | return false; |
| | | } |
| | | |
| | | |
| | | //状态相同且付款金额,结算金额一致时才不需要更新 |
| | | if (oldCommonOrder.getState().intValue() == newCommonOrder.getState()) { |
| | | if (oldCommonOrder.getPayment().compareTo(newCommonOrder.getPayment()) == 0) { |
| | | if (oldCommonOrder.getSettlement() == null && newCommonOrder.getSettlement() == null) { |
| | | return false; |
| | | } else if (oldCommonOrder.getSettlement() != null && newCommonOrder.getSettlement() != null && oldCommonOrder.getSettlement().compareTo(newCommonOrder.getSettlement()) == 0) { |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | /** |
| | |
| | | commonOrder.getTradeId(), new Date(), commonOrder.getSourceType())); |
| | | return new CommonOrderAddResultDTO(commonOrder, CommonOrderAddResultDTO.TYPE_ADD); |
| | | } else {// 修改 |
| | | // 非京东已经结算,已经失效,状态未改变的订单不处理 |
| | | if ((oldCommonOrder.getState() == CommonOrder.STATE_JS |
| | | && oldCommonOrder.getSourceType() != Constant.SOURCE_TYPE_JD) |
| | | || oldCommonOrder.getState() == CommonOrder.STATE_SX |
| | | || oldCommonOrder.getState() == CommonOrder.STATE_WQ |
| | | || (oldCommonOrder.getState().intValue() == commonOrder.getState()&&oldCommonOrder.getPayment().compareTo(commonOrder.getPayment())==0)) { |
| | | |
| | | if (!needUpdateCommonOrder(oldCommonOrder, commonOrder)) { |
| | | return new CommonOrderAddResultDTO(oldCommonOrder, CommonOrderAddResultDTO.TYPE_NOUPDATE); |
| | | } |
| | | // 交易ID一致才修改 |
| | |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | commonGoodsVO.setPlaceOrderTime(TimeUtil.getGernalTime(commonOrder.getThirdCreateTime().getTime(),"yyyy.MM.dd HH:mm")); |
| | | commonGoodsVO.setPlaceOrderTime(TimeUtil.getGernalTime(commonOrder.getThirdCreateTime().getTime(), "yyyy.MM.dd HH:mm")); |
| | | |
| | | String picture = commonGoodsVO.getPicture(); |
| | | if (!StringUtil.isNullOrEmpty(picture) && !picture.contains("320x320")) { |
| | |
| | | if (totalSettlement == null || totalSettlement.compareTo(new BigDecimal(0)) <= 0) { |
| | | totalSettlement = commonOrder.getTotalPayment(); |
| | | } |
| | | if (totalSettlement== null || totalSettlement.compareTo(new BigDecimal(0)) <= 0) |
| | | if (totalSettlement == null || totalSettlement.compareTo(new BigDecimal(0)) <= 0) |
| | | commonGoodsVO.setPayState("未付款/已退款"); |
| | | else |
| | | commonGoodsVO.setPayState("已付款"); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public JSONObject getRewardJumpInfo(String orderNo, Integer goodsType) { |
| | | public JSONObject getRewardJumpInfo(String orderNo, Integer goodsType, SystemEnum system) { |
| | | |
| | | JSONObject map = new JSONObject(); |
| | | // 订单标识 |
| | |
| | | Map<String, Object> jump = new HashMap<String, Object>(); |
| | | jump.put("type", 1); |
| | | jump.put("params", jumpLink); |
| | | jump.put("jumpDetail", jumpDetailV2Service.getByTypeCache("rewardCouponDetail")); |
| | | jump.put("jumpDetail", jumpDetailV2Service.getByTypeCache("rewardCouponDetail", system)); |
| | | |
| | | Map<String, Object> rewardMap = new HashMap<String, Object>(); |
| | | rewardMap.put("text", rewardStyleVO); |
| | |
| | | |
| | | @Override |
| | | public List<CommonOrder> getByOrderNo(Long uid, String orderNO) { |
| | | return commonOrderMapper.getByOrderNo(uid, orderNO); |
| | | if(uid!=null) { |
| | | return commonOrderMapper.getByOrderNo(uid, orderNO); |
| | | }else{ |
| | | CommonOrderMapper.DaoQuery daoQuery=new CommonOrderMapper.DaoQuery(); |
| | | daoQuery.orderId = orderNO; |
| | | return commonOrderMapper.list(daoQuery,0,100); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | if (commonGoodsVO.getGoodsType() == null) { |
| | | commonGoodsVO.setGoodsType(sourceType); |
| | | } |
| | | commonGoodsVO.setPlaceOrderTime(TimeUtil.getGernalTime(order.getThirdCreateTime().getTime(),"yyyy.MM.dd HH:mm")); |
| | | commonGoodsVO.setPlaceOrderTime(TimeUtil.getGernalTime(order.getThirdCreateTime().getTime(), "yyyy.MM.dd HH:mm")); |
| | | |
| | | // 淘宝商品图片处理 |
| | | String picture = commonGoodsVO.getPicture(); |
| | |
| | | if (totalSettlement == null || totalSettlement.compareTo(new BigDecimal(0)) <= 0) { |
| | | totalSettlement = commonOrder.getTotalPayment(); |
| | | } |
| | | if (totalSettlement== null || totalSettlement.compareTo(new BigDecimal(0)) <= 0) |
| | | if (totalSettlement == null || totalSettlement.compareTo(new BigDecimal(0)) <= 0) |
| | | commonGoodsVO.setPayState("未付款/已退款"); |
| | | else |
| | | commonGoodsVO.setPayState("已付款"); |
| | |
| | | return commonOrderMapper.listByGoodsIdAndUidAndMinThirdCreateTime(goodsId, uid, minThirdCreateTime, 0, 1000); |
| | | } |
| | | |
| | | @Override |
| | | public List<CommonOrder> listPayStateOrder(Integer sourceType, Date minThirdCreateTime, Date maxThirdCreateTime,int page,int pageSize) { |
| | | CommonOrderMapper.DaoQuery daoQuery = new CommonOrderMapper.DaoQuery(); |
| | | daoQuery.minThirdCreateTime = minThirdCreateTime; |
| | | daoQuery.maxThirdCreateTime = maxThirdCreateTime; |
| | | daoQuery.state = CommonOrder.STATE_FK; |
| | | daoQuery.sourceType = sourceType; |
| | | daoQuery.sortList = Arrays.asList(new String[]{"co_third_create_time ASC"}); |
| | | return commonOrderMapper.list(daoQuery, (page-1)*pageSize, pageSize); |
| | | } |
| | | |
| | | } |