| | |
| | | import org.yeshi.utils.DateUtil;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.share.UserShareGoodsGroupMapper;
|
| | | import com.yeshi.fanli.dto.HongBao;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord.ShareSourceTypeEnum;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBao;
|
| | | import com.yeshi.fanli.exception.share.UserShareGoodsRecordException;
|
| | | import com.yeshi.fanli.service.inter.goods.CommonGoodsService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.user.UserShareGoodsGroupService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | |
|
| | | @Service
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public UserShareGoodsGroup getNewestRecord(Long uid, Long auctionId) {
|
| | | return userShareGoodsGroupMapper.getNewestRecord(uid, auctionId);
|
| | | public UserShareGoodsGroup getNewestRecord(Long uid, Long auctionId, Integer goodsType) {
|
| | | return userShareGoodsGroupMapper.getNewestRecord(uid, auctionId, goodsType);
|
| | | }
|
| | |
|
| | |
|
| | |
| | | * @param auctionId
|
| | | */
|
| | | @Override
|
| | | public void updateOrderRecord (HongBao hongBao) throws UserShareGoodsRecordException{
|
| | | public void updateOrderRecord (HongBao hongBao, int goodsType) throws UserShareGoodsRecordException{
|
| | |
|
| | | if (hongBao == null) {
|
| | | throw new UserShareGoodsRecordException(1, "hongBao不能为空");
|
| | |
| | | throw new UserShareGoodsRecordException(1, "商品ID不能为空");
|
| | | }
|
| | |
|
| | | UserShareGoodsGroup newestRecord = getNewestRecord(uid, hongBao.getAuctionId());
|
| | | UserShareGoodsGroup newestRecord = getNewestRecord(uid, hongBao.getAuctionId(), goodsType);
|
| | |
|
| | | if (newestRecord != null) {
|
| | | // 更新订单数量
|
| | |
| | | throw new UserShareGoodsRecordException(1, "商品Id不能为空");
|
| | | }
|
| | |
|
| | | UserShareGoodsGroup group = getNewestRecord(uid, auctionId);
|
| | | UserShareGoodsGroup group = getNewestRecord(uid, auctionId, Constant.SOURCE_TYPE_TAOBAO);
|
| | |
|
| | | if (group != null) {
|
| | | UserShareGoodsGroup shareGoodsGroup = new UserShareGoodsGroup(group.getId());
|
| | |
| | | userShareGoodsGroupMapper.updateByPrimaryKeySelective(shareGoodsGroup);
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | |
| | | @Override
|
| | | public void updateBrowseNum(Long uid, Long id, int goodsType) throws UserShareGoodsRecordException{
|
| | | |
| | | if (uid == null) {
|
| | | throw new UserShareGoodsRecordException(1, "用户ID不能为空");
|
| | | }
|
| | | |
| | | if (id == null) {
|
| | | throw new UserShareGoodsRecordException(1, "商品Id不能为空");
|
| | | }
|
| | | |
| | | UserShareGoodsGroup group = getNewestRecord(uid, id, goodsType);
|
| | | if (group != null) {
|
| | | UserShareGoodsGroup shareGoodsGroup = new UserShareGoodsGroup(group.getId());
|
| | | // 累计浏览
|
| | | Integer totalBrowse = group.getTotalBrowse();
|
| | | if (totalBrowse == null) {
|
| | | totalBrowse = 0;
|
| | | }
|
| | | shareGoodsGroup.setTotalBrowse(totalBrowse + 1);
|
| | | |
| | | // 今日浏览
|
| | | Date date = new Date();
|
| | | Date browseTime = group.getBrowseTime();
|
| | | if (DateUtil.isSameDay(browseTime, date)) {
|
| | | shareGoodsGroup.setTodayBrowse(group.getTodayBrowse() + 1);
|
| | | } else {
|
| | | shareGoodsGroup.setTodayBrowse(1);
|
| | | }
|
| | | shareGoodsGroup.setBrowseTime(date);
|
| | | userShareGoodsGroupMapper.updateByPrimaryKeySelective(shareGoodsGroup);
|
| | | }
|
| | | }
|
| | | }
|