| | |
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | |
| | | return userShareGoodsRecordMapper.updateByPrimaryKeySelective(record);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int updateByPrimaryKey(UserShareGoodsRecord record) {
|
| | | return userShareGoodsRecordMapper.updateByPrimaryKey(record);
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | public List<UserShareGoodsRecord> listQueryByUid(long start, int count, Long uid, String source) {
|
| | |
| | | userShareGoodsRecord.setCreateTime(null);
|
| | | userShareGoodsRecord.setUpdateTime(null);
|
| | | listId.add(userShareGoodsRecord.getId());
|
| | | |
| | | // 改变图片尺寸
|
| | | String pictUrl = userShareGoodsRecord.getPicture();
|
| | | if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) {
|
| | | userShareGoodsRecord.setPicture(TbImgUtil.getTBSize320Img(pictUrl));
|
| | | }
|
| | | |
| | | |
| | | }
|
| | |
|
| | | // 今日浏览统计
|
| | |
| | | * @throws UserShareGoodsRecordException
|
| | | */
|
| | | @Override
|
| | | public JSONObject save(Long uid, ShareSourceTypeEnum source, String title, List<TaoBaoGoodsBrief> listGoods) throws UserShareGoodsRecordException {
|
| | | public Map<String,Object> save(Long uid, ShareSourceTypeEnum source, String title, List<TaoBaoGoodsBrief> listGoods) throws UserShareGoodsRecordException {
|
| | |
|
| | | if (listGoods == null || listGoods.size() < 0) {
|
| | | throw new UserShareGoodsRecordException(1, "分享商品数量不足");
|
| | |
| | | userShareGoodsRecordMapper.insertSelective(userShareGoodsRecord);
|
| | |
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | Map<String,Object> map = new HashMap<String,Object>();
|
| | | // 多个商品分享
|
| | | FileUploadResult loadResult = multipleGoodsShare(userShareGoodsRecord, listGoods);
|
| | | data.put("loadResult", loadResult);
|
| | | data.put("shareId", userShareGoodsRecord.getId());
|
| | | map.put("loadResult", loadResult);
|
| | | map.put("shareId", userShareGoodsRecord.getId());
|
| | |
|
| | | return data;
|
| | | return map;
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | UserShareGoodsGroup shareGoodsGroup = null;
|
| | |
|
| | | UserShareGoodsGroup singleGoods = userShareGoodsGroupService.getSingleGoods(resultCommonGoods.getId(),
|
| | | userShareGoodsRecord.getUid());
|
| | | if (singleGoods != null && singleGoods.getTotalGoods() == 1) {
|
| | | // 同一个商品多次分享
|
| | | shareGoodsGroup = singleGoods;
|
| | | } |
| | |
|
| | | if (shareGoodsGroup != null) {
|
| | | if (singleGoods != null) {
|
| | | // 单个商品多次分享
|
| | | userShareGoodsRecord.setPicture(taoBaoGoodsBrief.getPictUrl());
|
| | | userShareGoodsRecord.setId(shareGoodsGroup.getRecordId());
|
| | | userShareGoodsRecord.setId(singleGoods.getRecordId());
|
| | | userShareGoodsRecord.setUpdateTime(new Date());
|
| | | userShareGoodsRecordMapper.updateByPrimaryKey(userShareGoodsRecord);
|
| | | userShareGoodsRecordMapper.updateByPrimaryKeySelective(userShareGoodsRecord);
|
| | |
|
| | | Integer totalOrder = shareGoodsGroup.getTotalOrder();
|
| | | if (totalOrder == null ||totalOrder == 0 || totalOrder.equals(0)) {
|
| | | // 预计金额
|
| | | String rateStr = hongBaoManageService.get("hongbao_goods_proportion");
|
| | | shareGoodsGroup.setUpdateTime(new Date());
|
| | | BigDecimal money = TaoBaoUtil.getGoodsHongBaoMoney(taoBaoGoodsBrief, new BigDecimal(rateStr));
|
| | | shareGoodsGroup.setTotalMoney(money);
|
| | | |
| | | userShareGoodsGroupService.updateByPrimaryKeySelective(shareGoodsGroup);
|
| | | }
|
| | | } else {
|
| | | // 最新商品
|
| | | singleGoods.setUpdateTime(new Date());
|
| | | userShareGoodsGroupService.updateByPrimaryKeySelective(singleGoods);
|
| | | |
| | | } else |
| | | {
|
| | | // 单个商品第一次分享
|
| | | Date date = new Date();
|
| | | userShareGoodsRecord.setPicture(taoBaoGoodsBrief.getPictUrl());
|
| | |
| | | userShareGoodsRecord.setUpdateTime(date);
|
| | | userShareGoodsRecordMapper.insertSelective(userShareGoodsRecord);
|
| | |
|
| | | shareGoodsGroup = new UserShareGoodsGroup();
|
| | | shareGoodsGroup.setTotalOrder(0);
|
| | | shareGoodsGroup.setTotalBrowse(0);
|
| | | shareGoodsGroup.setTodayBrowse(0);
|
| | | shareGoodsGroup.setCreateTime(date);
|
| | | shareGoodsGroup.setUpdateTime(date);
|
| | | shareGoodsGroup.setCommonGoods(resultCommonGoods);
|
| | | shareGoodsGroup.setRecordId(userShareGoodsRecord.getId());
|
| | | singleGoods = new UserShareGoodsGroup();
|
| | | singleGoods.setTotalOrder(0);
|
| | | singleGoods.setTotalBrowse(0);
|
| | | singleGoods.setTodayBrowse(0);
|
| | | singleGoods.setTotalMoney(new BigDecimal(0));
|
| | | singleGoods.setCreateTime(date);
|
| | | singleGoods.setUpdateTime(date);
|
| | | singleGoods.setCommonGoods(resultCommonGoods);
|
| | | singleGoods.setRecordId(userShareGoodsRecord.getId());
|
| | |
|
| | | // 预计金额
|
| | | String rateStr = hongBaoManageService.get("hongbao_goods_proportion");
|
| | | BigDecimal money = TaoBaoUtil.getGoodsHongBaoMoney(taoBaoGoodsBrief, new BigDecimal(rateStr));
|
| | | shareGoodsGroup.setTotalMoney(money);
|
| | | |
| | | userShareGoodsGroupService.insertSelective(shareGoodsGroup);
|
| | | userShareGoodsGroupService.insertSelective(singleGoods);
|
| | | }
|
| | |
|
| | | } catch (CommonGoodsException e) {
|
| | |
| | |
|
| | | // 分享记录
|
| | | Date date = new Date();
|
| | | String rateStr = hongBaoManageService.get("hongbao_goods_proportion");
|
| | |
|
| | | List<TaoBaoGoodsBrief> listGoodsBrief = new ArrayList<TaoBaoGoodsBrief>();
|
| | | List<UserShareGoodsGroup> listGroup = new ArrayList<UserShareGoodsGroup>();
|
| | |
| | | shareGoodsGroup.setTotalOrder(0);
|
| | | shareGoodsGroup.setTotalBrowse(0);
|
| | | shareGoodsGroup.setTodayBrowse(0);
|
| | | shareGoodsGroup.setTotalMoney(new BigDecimal(0));
|
| | | shareGoodsGroup.setCreateTime(date);
|
| | | shareGoodsGroup.setUpdateTime(date);
|
| | | shareGoodsGroup.setCommonGoods(resultCommonGoods);
|
| | | shareGoodsGroup.setRecordId(userShareGoodsRecord.getId());
|
| | |
|
| | | // 预计金额
|
| | | BigDecimal money = TaoBaoUtil.getGoodsHongBaoMoney(taoBaoGoodsBrief, new BigDecimal(rateStr));
|
| | | shareGoodsGroup.setTotalMoney(money);
|
| | |
|
| | | listGroup.add(shareGoodsGroup);
|
| | |
|
| | |
| | |
|
| | | Long uid = shareRecord.getUid();
|
| | | Long shareId = shareRecord.getId();
|
| | | String source = shareRecord.getSource().getDesc();
|
| | | String source = shareRecord.getSource().name();
|
| | |
|
| | | String url = String.format("http://%s/share_mushGoods.html?uid=%s&shareId=%s&source=%s", configService.getH5Host(),
|
| | | AESUtil.encrypt(uid + "", Constant.UIDAESKEY), shareRecord.getId() + "", source +"");
|
| | |
| | | userShareGoodsGroup.setCreateTime(null);
|
| | | userShareGoodsGroup.setUpdateTime(null);
|
| | | userShareGoodsGroup.setRecordId(null);
|
| | | dataObject.put("group", gson.toJson(userShareGoodsGroup));
|
| | | |
| | | dataObject.put("todayBrowse",userShareGoodsGroup.getTodayBrowse() );
|
| | | dataObject.put("totalBrowse",userShareGoodsGroup.getTotalBrowse() );
|
| | | dataObject.put("totalOrder", userShareGoodsGroup.getTotalOrder());
|
| | | dataObject.put("totalMoney", "¥"+userShareGoodsGroup.getTotalMoney());
|
| | | dataObject.put("goods", gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief, proportion, null)));
|
| | | array.add(dataObject);
|
| | | }
|
| | |
| | | goodsBrief = redisManager.getTaoBaoGoodsBrief(commonGoods.getGoodsId());
|
| | |
|
| | | goodsState = 0;
|
| | | if (goodsBrief.getCouponLeftCount() < 1 || StringUtil.isNullOrEmpty(goodsBrief.getCouponInfo())) {
|
| | | goodsBrief.setState(1); // 已抢光
|
| | | }
|
| | | goodsBrief.setState(goodsState); // 在售
|
| | |
|
| | | CommonGoods upadeteCommonGoods = CommonGoodsFactory.create(goodsBrief);
|
| | | upadeteCommonGoods.setState(goodsState);
|
| | |
| | | if (goodsBrief == null) {
|
| | | goodsBrief = TaoBaoUtil.convert(commonGoods);
|
| | | }
|
| | |
|
| | | |
| | | if (goodsBrief.getCouponLeftCount() < 1 || StringUtil.isNullOrEmpty(goodsBrief.getCouponInfo())) {
|
| | | goodsBrief.setState(1); // 已抢光
|
| | | }
|
| | | |
| | | // 改变图片尺寸
|
| | | String pictUrl = goodsBrief.getPictUrl();
|
| | | if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) {
|
| | |
| | | throw new UserShareGoodsRecordException(1, "分享记录不存在");
|
| | | }
|
| | |
|
| | | shareRecord.setShareState(1);// 分享生效
|
| | | updateByPrimaryKeySelective(shareRecord);
|
| | | // 更新商品为已分享
|
| | | userGoodsStorageService.updateShareState(shareId);
|
| | | }
|
| | | }
|