| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.yeshi.fanli.exception.share.UserShareGoodsRecordException;
|
| | | import com.yeshi.fanli.service.inter.user.UserShareGoodsGroupService;
|
| | | import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService;
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("api/apph5/v1/share")
|
| | |
| | | @Resource
|
| | | private UserShareGoodsGroupService userShareGoodsGroupService;
|
| | |
|
| | | @Resource
|
| | | private UserShareGoodsRecordService userShareGoodsRecordService;
|
| | | |
| | | /**
|
| | | * 分享商品
|
| | | * 分享商品详情
|
| | | * @param callback
|
| | | * @param shareId 分享id
|
| | | * @param source 来源
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getDetail")
|
| | | public void getDetail(String callback, Long shareId, String source, PrintWriter out) {
|
| | | public void getDetail(String callback, Long shareId, String source, String fingerprint, PrintWriter out) {
|
| | |
|
| | | try {
|
| | |
|
| | | if (shareId == null) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("传递参数不正确")));
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("传递参数不正确"));
|
| | | return;
|
| | | }
|
| | | |
| | | // 更新访问次数
|
| | | userShareGoodsGroupService.updateBrowseRecord(shareId, 1);
|
| | | // 获取商品信息
|
| | | JSONObject data = userShareGoodsRecordService.getGoodsGroup(shareId);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | |
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult("更新成功")));
|
| | | } catch (UserShareGoodsRecordException e) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(e.getMsg())));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("更新失败")));
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("获取失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 分享商品
|
| | | * @param callback
|
| | | * @param shareId 分享id
|
| | | * @param source 来源
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "record")
|
| | | public void query(String callback, Long shareId, String source, PrintWriter out) {
|
| | | |
| | | try {
|
| | | |
| | | if (shareId == null) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("传递参数不正确")));
|
| | | return;
|
| | | }
|
| | | |
| | | userShareGoodsGroupService.updateBrowseRecord(shareId, 1);
|
| | | |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult("更新成功")));
|
| | | } catch (UserShareGoodsRecordException e) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(e.getMsg())));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("更新失败")));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | }
|
| | |
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage()));
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 分享商品
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "sharegoodsv2", method = RequestMethod.POST)
|
| | | public void shareGoodsV2(AcceptData acceptData, long uid, long activityId, PrintWriter out) {
|
| | | try {
|
| | | JSONObject data = activityService.shareGoodsV2(uid, activityId);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | } catch (ActivityException e) {
|
| | | out.print(JsonUtil.loadFalseResult("分享失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 分享商品(伴随图片的MD5)
|
| | |
| | | public void run() {
|
| | | shareGoodsService.addShareGoodsHistory(history);
|
| | | try {
|
| | | userShareGoodsRecordService.save(uid, ShareSourceTypeEnum.goodsDetail, taoBaoLink.getGoods());
|
| | | userShareGoodsRecordService.save(uid, ShareSourceTypeEnum.goodsDetail, null,taoBaoLink.getGoods());
|
| | | } catch (UserShareGoodsRecordException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | try {
|
| | | JSONObject data = userShareGoodsGroupService.getGoodsGroup(recordId);
|
| | | JSONObject data = userShareGoodsRecordService.getGoodsGroup(recordId);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("加载失败"));
|
| | |
| | | @Column(name = "sgr_picture")
|
| | | private String picture;
|
| | |
|
| | | // 显示标题内容
|
| | | @Expose
|
| | | @Column(name = "sgr_title")
|
| | | private String title;
|
| | | |
| | | // 分享时间
|
| | | @Column(name = "sgr_createtime")
|
| | | private Date createTime;
|
| | |
| | | public void setRevenueMoney(BigDecimal revenueMoney) {
|
| | | this.revenueMoney = revenueMoney;
|
| | | }
|
| | |
|
| | | public String getTitle() {
|
| | | return title;
|
| | | }
|
| | |
|
| | | public void setTitle(String title) {
|
| | | this.title = title;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | <result column="sgr_source" property="source" |
| | | typeHandler="com.yeshi.fanli.util.mybatishandler.ShareSourceTypeEnumHandler"/> |
| | | <result column="sgr_picture" property="picture" jdbcType="VARCHAR"/> |
| | | <result column="sgr_title" property="title" jdbcType="VARCHAR"/> |
| | | <result column="sgr_createtime" property="createTime" jdbcType="TIMESTAMP"/> |
| | | <result column="sgr_updatetime" property="updateTime" jdbcType="TIMESTAMP"/> |
| | | </resultMap> |
| | |
| | | <result column="revenueMoney" property="revenueMoney" jdbcType="DECIMAL"/> |
| | | </resultMap> |
| | | |
| | | <sql id="Base_Column_List">sgr_id,sgr_uid,sgr_source,sgr_picture,sgr_createtime,sgr_updatetime</sql> |
| | | <sql id="Base_Column_List">sgr_id,sgr_uid,sgr_source,sgr_picture,sgr_title,sgr_createtime,sgr_updatetime</sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select |
| | | <include refid="Base_Column_List"/>from yeshi_ec_share_goods_record where sgr_id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_share_goods_record where sgr_id = #{id,jdbcType=BIGINT}</delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_share_goods_record (sgr_id,sgr_uid,sgr_source,sgr_picture,sgr_createtime,sgr_updatetime) values (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{source,jdbcType=VARCHAR},#{picture,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_share_goods_record (sgr_id,sgr_uid,sgr_source,sgr_picture,sgr_title,sgr_createtime,sgr_updatetime) values (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{source,jdbcType=VARCHAR},#{picture,jdbcType=VARCHAR},#{sgr_title,jdbcType=VARCHAR},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_share_goods_record |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">sgr_id,</if> |
| | | <if test="uid != null">sgr_uid,</if> |
| | | <if test="source != null">sgr_source,</if> |
| | | <if test="picture != null">sgr_picture,</if> |
| | | <if test="title != null">sgr_title,</if> |
| | | <if test="createTime != null">sgr_createtime,</if> |
| | | <if test="updateTime != null">sgr_updatetime,</if> |
| | | </trim>values |
| | |
| | | <if test="uid != null">#{uid,jdbcType=BIGINT},</if> |
| | | <if test="source != null">#{source,jdbcType=VARCHAR},</if> |
| | | <if test="picture != null">#{picture,jdbcType=VARCHAR},</if> |
| | | <if test="title != null">#{title,jdbcType=VARCHAR},</if> |
| | | <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </trim> |
| | | </insert> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord">update yeshi_ec_share_goods_record set sgr_uid = #{uid,jdbcType=BIGINT},sgr_source = #{source,jdbcType=VARCHAR},sgr_picture = #{picture,jdbcType=VARCHAR},sgr_createtime = #{createTime,jdbcType=TIMESTAMP},sgr_updatetime = #{updateTime,jdbcType=TIMESTAMP} where sgr_id = #{id,jdbcType=BIGINT}</update> |
| | | <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord">update yeshi_ec_share_goods_record set sgr_uid = #{uid,jdbcType=BIGINT},sgr_source = #{source,jdbcType=VARCHAR},sgr_picture = #{picture,jdbcType=VARCHAR},sgr_title = #{title,jdbcType=VARCHAR},sgr_createtime = #{createTime,jdbcType=TIMESTAMP},sgr_updatetime = #{updateTime,jdbcType=TIMESTAMP} where sgr_id = #{id,jdbcType=BIGINT}</update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord">update yeshi_ec_share_goods_record |
| | | <set> |
| | | <if test="uid != null">sgr_uid=#{uid,jdbcType=BIGINT},</if> |
| | | <if test="source != null">sgr_source=#{source,jdbcType=VARCHAR},</if> |
| | | <if test="picture != null">sgr_picture=#{picture,jdbcType=VARCHAR},</if> |
| | | <if test="title != null">sgr_title=#{title,jdbcType=VARCHAR},</if> |
| | | <if test="createTime != null">sgr_createtime=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">sgr_updatetime=#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </set> where sgr_id = #{id,jdbcType=BIGINT} |
| | |
| | | package com.yeshi.fanli.service.impl.activity;
|
| | |
|
| | | import java.io.InputStream;
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | import org.springframework.cache.annotation.Cacheable;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.yeshi.utils.entity.FileUploadResult;
|
| | | import org.yeshi.utils.taobao.TbImgUtil;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.UserInfoMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.activity.ActivityUserMapper;
|
| | |
| | | import com.yeshi.fanli.entity.bus.activity.RecommendActivityImg;
|
| | | import com.yeshi.fanli.entity.bus.activity.RecommendActivityInviteInfo;
|
| | | import com.yeshi.fanli.entity.bus.activity.RecommendActivityTaoBaoGoods;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.taobao.PidUser;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord.ShareSourceTypeEnum;
|
| | | import com.yeshi.fanli.entity.goods.CommonGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.exception.ActivityException;
|
| | | import com.yeshi.fanli.exception.share.UserShareGoodsRecordException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsUpdateException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.activity.ActivityService;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.goods.CommonGoodsService;
|
| | | import com.yeshi.fanli.service.inter.goods.ShareGoodsService;
|
| | | import com.yeshi.fanli.service.inter.goods.TaoBaoGoodsBriefService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService;
|
| | | import com.yeshi.fanli.service.inter.user.SpreadUserImgService;
|
| | | import com.yeshi.fanli.service.inter.user.TBPidService;
|
| | | import com.yeshi.fanli.service.inter.user.UserAccountService;
|
| | | import com.yeshi.fanli.util.AESUtil;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService;
|
| | | import com.yeshi.fanli.util.ImageUtil;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.activity.ActivityUtil;
|
| | | import com.yeshi.fanli.util.factory.CommonGoodsFactory;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | |
|
| | | import org.yeshi.utils.HttpUtil;
|
| | | import org.yeshi.utils.QRCodeUtil;
|
| | | import org.yeshi.utils.entity.FileUploadResult;
|
| | | import org.yeshi.utils.exception.HttpException;
|
| | | import org.yeshi.utils.taobao.TbImgUtil;
|
| | | import org.yeshi.utils.tencentcloud.COSManager;
|
| | |
|
| | | @Service
|
| | | public class ActivityServiceImpl implements ActivityService {
|
| | |
| | |
|
| | | @Resource
|
| | | private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService;
|
| | | |
| | | @Resource
|
| | | private UserShareGoodsRecordService userShareGoodsRecordService;
|
| | | |
| | | @Resource
|
| | | private CommonGoodsService commonGoodsService;
|
| | |
|
| | | @Override
|
| | | public List<RecommendActivity> getRecommendActivityList(int page, int pageSize) {
|
| | |
| | |
|
| | | @Override
|
| | | public ActivityShareResult shareActivityGoods(Long uid, Long activityId) throws ActivityException {
|
| | | |
| | | RecommendActivity activity = recommendActivityMapper.selectByPrimaryKey(activityId);
|
| | | |
| | | if (activity == null)
|
| | | throw new ActivityException(2, "动态不存在");
|
| | | |
| | | if (activity.getType() != RecommendActivity.TYPE_SHARE_GOODS)
|
| | | throw new ActivityException(3, "不属于分享商品动态");
|
| | | |
| | | ActivityShareResult result = new ActivityShareResult();
|
| | | |
| | | String title = activity.getTitle().replace("<br>", "/n").replace("<p>", "").replace("</p>", "");
|
| | | if (title != null && title.trim().endsWith("/n"))
|
| | | title = title.trim().substring(0, title.trim().length() - 2);
|
| | | result.setTitle(title);
|
| | | List<FileUploadResult> imgList = new ArrayList<>();
|
| | | |
| | | List<TaoBaoGoodsBrief> listGoodsBrief = new ArrayList<TaoBaoGoodsBrief>();
|
| | | |
| | | if (activity.getGoodsList() != null) {
|
| | | // 提前分配好PID
|
| | | tbPidService.getTBPid(uid, PidUser.TYPE_SHARE_GOODS);
|
| | | // activity.getGoodsList().stream().parallel().forEach(goodsActivity
|
| | | // -> {
|
| | | // try {
|
| | | // TaoBaoGoodsBrief goods = taoBaoGoodsBriefService
|
| | | // .getTaoBaoGoodsDetailForShare(Long.parseLong(goodsActivity.getAuctionId()),
|
| | | // uid);
|
| | | // if (goods != null &&
|
| | | // !StringUtil.isNullOrEmpty(goods.getCouponActivityId())
|
| | | // && goods.getCouponLeftCount() != null &&
|
| | | // goods.getCouponLeftCount() > 0) {
|
| | | // UserShareGoodsHistory userShareGoodsHistory =
|
| | | // shareGoodsService.addShareGoodsHistory(uid,
|
| | | // goods.getAuctionId());
|
| | | // if (userShareGoodsHistory != null)
|
| | | // imgList.add(new
|
| | | // FileUploadResult(userShareGoodsHistory.getShareImg(),
|
| | | // userShareGoodsHistory.getShareImgMD5()));
|
| | | // } else if (goods != null) {
|
| | | // LogHelper.error("没有添加到分享:" + goods.getAuctionId());
|
| | | // }
|
| | | // } catch (ShareGoodsException e) {
|
| | | // try {
|
| | | // LogHelper.errorDetailInfo(e, "分享商品出错-商品ID:" +
|
| | | // goodsActivity.getAuctionId(), "--");
|
| | | // } catch (Exception e1) {
|
| | | // e1.printStackTrace();
|
| | | // }
|
| | | // }
|
| | | // });
|
| | |
|
| | | // 画图
|
| | | activity = getRecommendActivityDetail(activityId);
|
| | |
|
| | | String url = String.format("http://%s/shareMuchImg.html?uid=%s&activityId=%s", configService.getH5Host(),
|
| | | AESUtil.encrypt(uid + "", Constant.UIDAESKEY), activity.getId() + "");
|
| | |
|
| | | String shortLink = HttpUtil.getShortLink(url);
|
| | | if (!StringUtil.isNullOrEmpty(shortLink)) {
|
| | | url = shortLink;
|
| | | }
|
| | | InputStream erCodeInputStream = null;
|
| | |
|
| | | // 生成链接二维码
|
| | |
|
| | | try {
|
| | | erCodeInputStream = QRCodeUtil.getInstance(500).encode(url);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | // 获取到用户的头像
|
| | | UserInfo user = userInfoMapper.selectByPrimaryKey(uid);
|
| | | InputStream portrait = null;
|
| | | if (!StringUtil.isNullOrEmpty(user.getPortrait())) {
|
| | | |
| | | activity.getGoodsList().stream().parallel().forEach(goodsActivity -> {
|
| | | |
| | | try {
|
| | | portrait = HttpUtil.downLoadImg(user.getPortrait());
|
| | | } catch (HttpException e) {
|
| | | String portraitUrl = userAccountService.repairPortrait(uid);
|
| | | if (StringUtil.isNullOrEmpty(portraitUrl))
|
| | | throw new ActivityException(11, "获取头像出错");
|
| | | else {
|
| | | // 再次获取头像
|
| | | try {
|
| | | portrait = HttpUtil.downLoadImg(portraitUrl);
|
| | | } catch (HttpException e1) {
|
| | | throw new ActivityException(11, "获取头像出错");
|
| | | }
|
| | | TaoBaoGoodsBrief goodsBrief = |
| | | redisManager.getTaoBaoGoodsBrief(Long.parseLong(goodsActivity.getAuctionId()));
|
| | | listGoodsBrief.add(goodsBrief);
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | |
| | | CommonGoods commonGoods= commonGoodsService.getCommonGoodsByGoodsIdAndGoodsType(Long.parseLong(goodsActivity.getAuctionId()),
|
| | | CommonGoods.GOODS_TYPE_TB);
|
| | | if (commonGoods != null) {
|
| | | TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(commonGoods);
|
| | | goodsBrief.setState(1);
|
| | | listGoodsBrief.add(goodsBrief);
|
| | | }
|
| | | |
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "分享商品出错-商品ID:" + goodsActivity.getAuctionId(), "--");
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | InputStream shareImgInputStream = ImageUtil.drawActivityGoodsShareBigImg(erCodeInputStream, portrait,
|
| | | activity.getGoodsList());
|
| | | FileUploadResult shareImgResult = COSManager.getInstance().uploadInputStream(shareImgInputStream,
|
| | | "sharegoods/activity/share_" + uid + "_" + activityId + "_" + System.currentTimeMillis() + ".png");
|
| | | imgList.add(shareImgResult);
|
| | | });
|
| | | }
|
| | | |
| | | if (listGoodsBrief.size() > 0) {
|
| | | try {
|
| | | FileUploadResult loadResult = userShareGoodsRecordService.save(uid, |
| | | ShareSourceTypeEnum.activity, title, listGoodsBrief);
|
| | | imgList.add(loadResult);
|
| | | |
| | | } catch (UserShareGoodsRecordException e) {
|
| | | throw new ActivityException(1, e.getMsg());
|
| | | }
|
| | | } else {
|
| | | throw new ActivityException(1, "商品下架");
|
| | | }
|
| | | |
| | | result.setImgList(imgList);
|
| | | return result;
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public JSONObject shareGoodsV2(Long uid, Long activityId) throws ActivityException {
|
| | | |
| | | RecommendActivity activity = recommendActivityMapper.selectByPrimaryKey(activityId);
|
| | | |
| | | if (activity == null)
|
| | | throw new ActivityException(2, "动态不存在");
|
| | | |
| | | if (activity.getType() != RecommendActivity.TYPE_SHARE_GOODS)
|
| | | throw new ActivityException(3, "不属于分享商品动态");
|
| | | |
| | | ActivityShareResult result = new ActivityShareResult();
|
| | | |
| | | String title = activity.getTitle().replace("<br>", "/n").replace("<p>", "").replace("</p>", "");
|
| | | if (title != null && title.trim().endsWith("/n"))
|
| | | title = title.trim().substring(0, title.trim().length() - 2);
|
| | | |
| | | result.setTitle(title);
|
| | | |
| | | List<FileUploadResult> imgList = new ArrayList<>();
|
| | | List<TaoBaoGoodsBrief> listGoodsBrief = new ArrayList<TaoBaoGoodsBrief>();
|
| | | |
| | | if (activity.getGoodsList() != null) {
|
| | | activity.getGoodsList().stream().parallel().forEach(goodsActivity -> {
|
| | | try {
|
| | | TaoBaoGoodsBrief goodsBrief = |
| | | redisManager.getTaoBaoGoodsBrief(Long.parseLong(goodsActivity.getAuctionId()));
|
| | | listGoodsBrief.add(goodsBrief);
|
| | | |
| | | } catch (TaobaoGoodsDownException e) {
|
| | | |
| | | CommonGoods commonGoods= commonGoodsService.getCommonGoodsByGoodsIdAndGoodsType(Long.parseLong(goodsActivity.getAuctionId()),
|
| | | CommonGoods.GOODS_TYPE_TB);
|
| | | if (commonGoods != null) {
|
| | | TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(commonGoods);
|
| | | goodsBrief.setState(1);
|
| | | listGoodsBrief.add(goodsBrief);
|
| | | }
|
| | | |
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "分享商品出错-商品ID:" + goodsActivity.getAuctionId(), "--");
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | | |
| | | FileUploadResult loadResult = null;
|
| | | if (listGoodsBrief.size() > 0) {
|
| | | try {
|
| | | loadResult = userShareGoodsRecordService.save(uid, |
| | | ShareSourceTypeEnum.activity, title, listGoodsBrief);
|
| | | imgList.add(loadResult);
|
| | | |
| | | } catch (UserShareGoodsRecordException e) {
|
| | | throw new ActivityException(1, e.getMsg());
|
| | | }
|
| | | } else {
|
| | | throw new ActivityException(1, "商品下架");
|
| | | }
|
| | | |
| | | String revenue = "";
|
| | | String totalGetMoney = activity.getTotalGetMoney();
|
| | | if (totalGetMoney != null && totalGetMoney.trim().length() > 0) {
|
| | | revenue = totalGetMoney.replace("预计分享奖金", listGoodsBrief.size()+"个商品预估分享奖金");
|
| | | }
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("shareImg", loadResult);
|
| | | data.put("revenue", revenue);
|
| | | data.put("notifyDesc", configService.get("goods_share_notify"));
|
| | |
|
| | | return data;
|
| | | |
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | activity.setTop(top);
|
| | | activity.setType(RecommendActivity.TYPE_SHARE_GOODS);
|
| | | recommendActivityMapper.insertSelective(activity);
|
| | |
|
| | | |
| | | List<CommonGoods> listCommonGoods = new ArrayList<CommonGoods>();
|
| | | |
| | | BigDecimal taotaoMoney = new BigDecimal(0);
|
| | | for (long auctionId : goodsList) {
|
| | | TaoBaoGoodsBrief tb = null;
|
| | |
| | | recommendActivityTaoBaoGoodsMapper.insertSelective(goods);
|
| | | BigDecimal money = taoBaoGoodsBriefService.getShareGoodsUserHongBao(tb);
|
| | | taotaoMoney = taotaoMoney.add(money);
|
| | | |
| | | // 转换简版商品信息
|
| | | CommonGoods commonGoods = CommonGoodsFactory.create(tb);
|
| | | listCommonGoods.add(commonGoods);
|
| | | }
|
| | | |
| | | try {
|
| | | // 更新简版信息
|
| | | commonGoodsService.addBatchCommonGoods(listCommonGoods);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | RecommendActivity updateActivity = new RecommendActivity();
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | @Override
|
| | | @Transactional
|
| | | public void addBatchCommonGoods(List<CommonGoods> listCommonGoods) {
|
| | | |
| | | if (listCommonGoods == null || listCommonGoods.size() == 0) {
|
| | | return;
|
| | | }
|
| | | |
| | | for (CommonGoods commonGoods: listCommonGoods) {
|
| | | try {
|
| | | addCommonGoods(commonGoods);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | BigDecimal totalMoney = new BigDecimal(0.00);
|
| | | List<TaoBaoGoodsBrief> listGoodsBrief = new ArrayList<TaoBaoGoodsBrief>();
|
| | |
|
| | | String rateStr = hongBaoManageService.get("hongbao_goods_proportion");
|
| | | |
| | | for (UserGoodsStorage userGoodsStorage: listStorage) {
|
| | | CommonGoods commonGoods = userGoodsStorage.getCommonGoods();
|
| | | TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(commonGoods);
|
| | |
| | | userGoodsStorage.setState(1);
|
| | | userGoodsStorage.setUpdateTime(new Date());
|
| | |
|
| | | String rateStr = hongBaoManageService.get("hongbao_goods_proportion");
|
| | | BigDecimal money = TaoBaoUtil.getGoodsHongBaoMoney(goodsBrief, new BigDecimal(rateStr));
|
| | | totalMoney = MoneyBigDecimalUtil.add(totalMoney, money);
|
| | | }
|
| | |
|
| | | String revenue = listGoodsBrief.size() + "个商品预估分享奖金:¥"+totalMoney;
|
| | | FileUploadResult loadResult = userShareGoodsRecordService.save(uid, ShareSourceTypeEnum.storage, listGoodsBrief);
|
| | | FileUploadResult loadResult = userShareGoodsRecordService.save(uid, ShareSourceTypeEnum.storage, |
| | | null, listGoodsBrief);
|
| | |
|
| | | // 更新为已分享
|
| | | userGoodsStorageMapper.updateBatchSelective(listStorage);
|
| | |
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | import org.springframework.core.task.TaskExecutor;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.yeshi.utils.DateUtil;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.taobao.TbImgUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.yeshi.fanli.dao.mybatis.share.UserShareGoodsGroupMapper;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup;
|
| | | import com.yeshi.fanli.entity.goods.CommonGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.exception.share.UserShareGoodsRecordException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.service.inter.goods.CommonGoodsService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.user.UserShareGoodsGroupService;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.factory.CommonGoodsFactory;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | |
|
| | | @Service
|
| | | public class UserShareGoodsGroupServiceImpl implements UserShareGoodsGroupService {
|
| | |
|
| | | @Resource(name = "taskExecutor")
|
| | | private TaskExecutor executor;
|
| | | |
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | | |
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | |
|
| | | @Resource
|
| | | private CommonGoodsService commonGoodsService;
|
| | |
| | | updateByPrimaryKeySelective(shareGoodsGroup);
|
| | | }
|
| | | }
|
| | | |
| | | @Override
|
| | | public JSONObject getGoodsGroup(Long recordId) throws UserShareGoodsRecordException {
|
| | | |
| | | List<CommonGoods> listUpadteCommonGoods = new ArrayList<CommonGoods>();
|
| | |
|
| | | JSONArray array = new JSONArray();
|
| | |
|
| | | List<UserShareGoodsGroup> list = listByRecordId(recordId);
|
| | | if (list != null && list.size() > 0) {
|
| | |
|
| | | Date nowDate = new Date();
|
| | | long nh = 1000 * 60 * 60;
|
| | | long nd = 1000 * 24 * 60 * 60;
|
| | |
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | |
|
| | | Map<String, String> map = hongBaoManageService.convertMap();
|
| | | String proportion = map.get("hongbao_goods_proportion");
|
| | |
|
| | | for (UserShareGoodsGroup userShareGoodsGroup : list) {
|
| | | CommonGoods commonGoods = userShareGoodsGroup.getCommonGoods();
|
| | | if (commonGoods == null) {
|
| | | continue;
|
| | | }
|
| | |
|
| | | TaoBaoGoodsBrief goodsBrief = null;
|
| | | JSONObject dataObject = new JSONObject();
|
| | |
|
| | | // 更新一个小时之内的商品不再更新
|
| | | Integer goodsState = commonGoods.getState();
|
| | | // 状态未下架时进行更新
|
| | | if (goodsState != null && (goodsState != 1 || !goodsState.equals(1))) {
|
| | | Date updateTime = commonGoods.getUpdateTime();
|
| | | if (updateTime != null) {
|
| | | |
| | | // 计算差多少小时
|
| | | long diff = nowDate.getTime() - updateTime.getTime();
|
| | | long day = diff / nd;
|
| | | long hour = diff % nd / nh;
|
| | | if (hour > 1 || day > 0 ) {
|
| | | try {
|
| | | if (commonGoods.getGoodsType() == CommonGoods.GOODS_TYPE_TB) {
|
| | | goodsBrief = redisManager.getTaoBaoGoodsBrief(commonGoods.getGoodsId());
|
| | | |
| | | goodsState = 0;
|
| | | goodsBrief.setState(goodsState);
|
| | | |
| | | CommonGoods upadeteCommonGoods = CommonGoodsFactory.create(goodsBrief);
|
| | | upadeteCommonGoods.setState(goodsState);
|
| | | upadeteCommonGoods.setId(commonGoods.getId());
|
| | | listUpadteCommonGoods.add(upadeteCommonGoods);
|
| | | }
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | // 已下架
|
| | | goodsState = 1;
|
| | | commonGoods.setState(goodsState);
|
| | | listUpadteCommonGoods.add(commonGoods);
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | if (goodsBrief == null) {
|
| | | goodsBrief = TaoBaoUtil.convert(commonGoods);
|
| | | } |
| | |
|
| | | // 改变图片尺寸
|
| | | String pictUrl = commonGoods.getPicture();
|
| | | if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) {
|
| | | commonGoods.setPicture(TbImgUtil.getTBSize320Img(pictUrl));
|
| | | }
|
| | | |
| | | String json = gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief, proportion, null));
|
| | | |
| | | dataObject.put("groupId", userShareGoodsGroup.getId());
|
| | | dataObject.put("goods", json);
|
| | | array.add(dataObject);
|
| | | }
|
| | |
|
| | | }
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("count", list.size());
|
| | | data.put("result_list", array);
|
| | |
|
| | | if (listUpadteCommonGoods.size() > 0) {
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | try {
|
| | | // 更新简版信息
|
| | | commonGoodsService.updateBatchCommonGoods(listUpadteCommonGoods);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | | |
| | | return data;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.transaction.Transactional;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | import org.springframework.core.task.TaskExecutor;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.yeshi.utils.HttpUtil;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.QRCodeUtil;
|
| | | import org.yeshi.utils.entity.FileUploadResult;
|
| | | import org.yeshi.utils.exception.HttpException;
|
| | | import org.yeshi.utils.taobao.TbImgUtil;
|
| | | import org.yeshi.utils.tencentcloud.COSManager;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.yeshi.fanli.dao.mybatis.UserInfoMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.share.UserShareGoodsRecordMapper;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup;
|
| | |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.exception.goods.CommonGoodsException;
|
| | | import com.yeshi.fanli.exception.share.UserShareGoodsRecordException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.goods.CommonGoodsService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
| | |
| | | import com.yeshi.fanli.util.AESUtil;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.ImageUtil;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.factory.CommonGoodsFactory;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | |
| | | @Service
|
| | | public class UserShareGoodsRecordServiceImpl implements UserShareGoodsRecordService {
|
| | |
|
| | | @Resource(name = "taskExecutor")
|
| | | private TaskExecutor executor;
|
| | | |
| | | @Resource
|
| | | private ConfigService configService;
|
| | | |
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | |
|
| | | @Resource
|
| | | private UserInfoMapper userInfoMapper;
|
| | |
| | | return list;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 保存分享记录
|
| | | * @param userShareGoodsRecord 分享记录: uid、picture、source 为必输入
|
| | | * @throws UserShareGoodsRecordException
|
| | | */
|
| | | |
| | | @Override
|
| | | public void save(Long uid, ShareSourceTypeEnum source , TaoBaoGoodsBrief taoBaoGoodsBrief) throws UserShareGoodsRecordException {
|
| | | public void save(Long uid, ShareSourceTypeEnum source, String title, TaoBaoGoodsBrief taoBaoGoodsBrief) throws UserShareGoodsRecordException {
|
| | |
|
| | | if (taoBaoGoodsBrief == null) {
|
| | | throw new UserShareGoodsRecordException(1, "分享商品不能为空");
|
| | |
| | | UserShareGoodsRecord userShareGoodsRecord = new UserShareGoodsRecord();
|
| | | userShareGoodsRecord.setUid(uid);
|
| | | userShareGoodsRecord.setSource(source);
|
| | | userShareGoodsRecord.setTitle(title);
|
| | | // 单个商品分享
|
| | | singleGoodsShare(userShareGoodsRecord, taoBaoGoodsBrief);
|
| | | }
|
| | |
| | | * @throws UserShareGoodsRecordException
|
| | | */
|
| | | @Override
|
| | | public FileUploadResult save(Long uid, ShareSourceTypeEnum source , List<TaoBaoGoodsBrief> listGoods) throws UserShareGoodsRecordException {
|
| | | public FileUploadResult save(Long uid, ShareSourceTypeEnum source, String title, List<TaoBaoGoodsBrief> listGoods) throws UserShareGoodsRecordException {
|
| | |
|
| | | if (listGoods == null || listGoods.size() <= 1) {
|
| | | throw new UserShareGoodsRecordException(1, "分享商品数量不足");
|
| | |
| | | UserShareGoodsRecord userShareGoodsRecord = new UserShareGoodsRecord();
|
| | | userShareGoodsRecord.setUid(uid);
|
| | | userShareGoodsRecord.setSource(source);
|
| | | userShareGoodsRecord.setTitle(title);
|
| | | // 取一个商品图片作为主图
|
| | | userShareGoodsRecord.setPicture(listGoods.get(0).getPictUrl());
|
| | |
|
| | |
| | | userShareGoodsRecord.setUpdateTime(date);
|
| | | userShareGoodsRecordMapper.insertSelective(userShareGoodsRecord);
|
| | |
|
| | | FileUploadResult shareImg = createShareImg(userShareGoodsRecord, listGoods);
|
| | | |
| | | // 多个商品分享
|
| | | multipleGoodsShare(userShareGoodsRecord, listGoods);
|
| | | |
| | | return shareImg;
|
| | | return multipleGoodsShare(userShareGoodsRecord, listGoods);
|
| | |
|
| | | }
|
| | |
|
| | |
| | | public void singleGoodsShare(UserShareGoodsRecord userShareGoodsRecord, TaoBaoGoodsBrief taoBaoGoodsBrief) {
|
| | |
|
| | | CommonGoods commonGoods = CommonGoodsFactory.create(taoBaoGoodsBrief);
|
| | | commonGoods.setState(taoBaoGoodsBrief.getState());
|
| | | try {
|
| | | CommonGoods resultCommonGoods = commonGoodsService.addOrUpdateCommonGoods(commonGoods);
|
| | |
|
| | |
| | | * @param listGoods
|
| | | */
|
| | | @Transactional
|
| | | public void multipleGoodsShare(UserShareGoodsRecord userShareGoodsRecord, List<TaoBaoGoodsBrief> listGoods) {
|
| | | public FileUploadResult multipleGoodsShare(UserShareGoodsRecord userShareGoodsRecord, List<TaoBaoGoodsBrief> listGoods) throws UserShareGoodsRecordException {
|
| | |
|
| | | // 分享记录
|
| | | Date date = new Date();
|
| | | String rateStr = hongBaoManageService.get("hongbao_goods_proportion");
|
| | |
|
| | | List<TaoBaoGoodsBrief> listGoodsBrief = new ArrayList<TaoBaoGoodsBrief>();
|
| | | List<UserShareGoodsGroup> listGroup = new ArrayList<UserShareGoodsGroup>();
|
| | | |
| | | for (TaoBaoGoodsBrief taoBaoGoodsBrief: listGoods) {
|
| | | CommonGoods commonGoods = CommonGoodsFactory.create(taoBaoGoodsBrief);
|
| | | commonGoods.setState(taoBaoGoodsBrief.getState());
|
| | | try {
|
| | | CommonGoods resultCommonGoods = commonGoodsService.addOrUpdateCommonGoods(commonGoods);
|
| | | |
| | | if (resultCommonGoods != null) {
|
| | | TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(resultCommonGoods);
|
| | | listGoodsBrief.add(goodsBrief);
|
| | | }
|
| | | |
| | | UserShareGoodsGroup shareGoodsGroup = new UserShareGoodsGroup();
|
| | | shareGoodsGroup.setTotalOrder(0);
|
| | | shareGoodsGroup.setTotalBrowse(0);
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | FileUploadResult shareImg = createShareImg(userShareGoodsRecord, listGoodsBrief);
|
| | | |
| | | // 短连接
|
| | | String shortLink = HttpUtil.getShortLink(shareImg.getUrl());
|
| | | if (!StringUtil.isNullOrEmpty(shortLink)) {
|
| | | shareImg.setUrl(shortLink);
|
| | | }
|
| | | |
| | | |
| | | if (listGroup.size() > 0) {
|
| | | userShareGoodsGroupService.insertBatch(listGroup);
|
| | | }
|
| | |
|
| | | return shareImg;
|
| | | }
|
| | | |
| | | |
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 生成分享图
|
| | |
| | | Long shareId = shareRecord.getId();
|
| | | String source = shareRecord.getSource().getDesc();
|
| | |
|
| | | String url = String.format("http://%s/shareMuchImg2.html?uid=%s&shareId=%s&source=%s", configService.getH5Host(),
|
| | | 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 +"");
|
| | |
|
| | | String shortLink = HttpUtil.getShortLink(url);
|
| | |
| | | return shareImg;
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public JSONObject getGoodsGroup(Long recordId) throws UserShareGoodsRecordException {
|
| | | UserShareGoodsRecord userShareGoodsRecord = userShareGoodsRecordMapper.selectByPrimaryKey(recordId);
|
| | | |
| | | List<CommonGoods> listUpadteCommonGoods = new ArrayList<CommonGoods>();
|
| | |
|
| | | JSONArray array = new JSONArray();
|
| | |
|
| | | List<UserShareGoodsGroup> list = userShareGoodsGroupService.listByRecordId(recordId);
|
| | | if (list != null && list.size() > 0) {
|
| | |
|
| | | Date nowDate = new Date();
|
| | | long nh = 1000 * 60 * 60;
|
| | | long nd = 1000 * 24 * 60 * 60;
|
| | |
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | |
|
| | | Map<String, String> map = hongBaoManageService.convertMap();
|
| | | String proportion = map.get("hongbao_goods_proportion");
|
| | |
|
| | | for (UserShareGoodsGroup userShareGoodsGroup : list) {
|
| | | CommonGoods commonGoods = userShareGoodsGroup.getCommonGoods();
|
| | | if (commonGoods == null) {
|
| | | continue;
|
| | | }
|
| | |
|
| | | TaoBaoGoodsBrief goodsBrief = null;
|
| | | JSONObject dataObject = new JSONObject();
|
| | |
|
| | | // 更新一个小时之内的商品不再更新
|
| | | Integer goodsState = commonGoods.getState();
|
| | | // 状态未下架时进行更新
|
| | | if (goodsState != null && (goodsState != 1 || !goodsState.equals(1))) {
|
| | | Date updateTime = commonGoods.getUpdateTime();
|
| | | if (updateTime != null) {
|
| | | |
| | | // 计算差多少小时
|
| | | long diff = nowDate.getTime() - updateTime.getTime();
|
| | | long day = diff / nd;
|
| | | long hour = diff % nd / nh;
|
| | | if (hour > 1 || day > 0 ) {
|
| | | try {
|
| | | if (commonGoods.getGoodsType() == CommonGoods.GOODS_TYPE_TB) {
|
| | | goodsBrief = redisManager.getTaoBaoGoodsBrief(commonGoods.getGoodsId());
|
| | | |
| | | goodsState = 0;
|
| | | goodsBrief.setState(goodsState);
|
| | | |
| | | CommonGoods upadeteCommonGoods = CommonGoodsFactory.create(goodsBrief);
|
| | | upadeteCommonGoods.setState(goodsState);
|
| | | upadeteCommonGoods.setId(commonGoods.getId());
|
| | | listUpadteCommonGoods.add(upadeteCommonGoods);
|
| | | }
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | // 已下架
|
| | | goodsState = 1;
|
| | | commonGoods.setState(goodsState);
|
| | | listUpadteCommonGoods.add(commonGoods);
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | if (goodsBrief == null) {
|
| | | goodsBrief = TaoBaoUtil.convert(commonGoods);
|
| | | } |
| | |
|
| | | // 改变图片尺寸
|
| | | String pictUrl = commonGoods.getPicture();
|
| | | if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) {
|
| | | commonGoods.setPicture(TbImgUtil.getTBSize320Img(pictUrl));
|
| | | }
|
| | |
|
| | | String json = gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief, proportion, null));
|
| | |
|
| | | dataObject.put("groupId", userShareGoodsGroup.getId());
|
| | | dataObject.put("goods", json);
|
| | | array.add(dataObject);
|
| | | }
|
| | | }
|
| | | |
| | | String title = "";
|
| | | if(userShareGoodsRecord != null) {
|
| | | title = userShareGoodsRecord.getTitle();
|
| | | }
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("title", title);
|
| | | data.put("count", list.size());
|
| | | data.put("result_list", array);
|
| | |
|
| | | if (listUpadteCommonGoods.size() > 0) {
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | try {
|
| | | // 更新简版信息
|
| | | commonGoodsService.updateBatchCommonGoods(listUpadteCommonGoods);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | | |
| | | return data;
|
| | | }
|
| | |
|
| | | }
|
| | |
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.activity.ActivityShareResult;
|
| | | import com.yeshi.fanli.entity.bus.activity.ActivityUser;
|
| | | import com.yeshi.fanli.entity.bus.activity.RecommendActivity;
|
| | | import com.yeshi.fanli.entity.bus.activity.RecommendActivityImg;
|
| | | import com.yeshi.fanli.entity.bus.activity.RecommendActivityInviteInfo;
|
| | | import com.yeshi.fanli.exception.ActivityException;
|
| | |
|
| | |
| | | public RecommendActivity getRecommendActivityDetail(Long activityId);
|
| | |
|
| | | public ActivityUser selectActivityUserByPrimaryKey(Long id);
|
| | | |
| | | /**
|
| | | * 动态分享
|
| | | * @param uid
|
| | | * @param activityId
|
| | | * @return
|
| | | * @throws ActivityException
|
| | | */
|
| | | public JSONObject shareGoodsV2(Long uid, Long activityId) throws ActivityException;
|
| | | }
|
| | |
| | | */
|
| | | public void updateBatchCommonGoods(List<CommonGoods> listCommonGoods);
|
| | |
|
| | |
|
| | | /**
|
| | | * 批量插入
|
| | | * @param listCommonGoods
|
| | | */
|
| | | public void addBatchCommonGoods(List<CommonGoods> listCommonGoods);
|
| | |
|
| | | }
|
| | |
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.exception.share.UserShareGoodsRecordException;
|
| | |
| | | */
|
| | | public void updateBrowseRecord(Long shareId, int count) throws UserShareGoodsRecordException;
|
| | |
|
| | |
|
| | | /**
|
| | | * 查询已分享商品
|
| | | * @param recordId
|
| | | * @return
|
| | | * @throws UserShareGoodsRecordException
|
| | | */
|
| | | public JSONObject getGoodsGroup(Long recordId) throws UserShareGoodsRecordException;
|
| | |
|
| | | /**
|
| | | * 更新订单数量及收益
|
| | |
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | import org.yeshi.utils.entity.FileUploadResult;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord;
|
| | |
| | | * 多个商品分享
|
| | | * @param uid 用户id
|
| | | * @param source 来源
|
| | | * @param title 标题内容
|
| | | * @param listGoods 商品集合
|
| | | * @throws UserShareGoodsRecordException
|
| | | */
|
| | | public FileUploadResult save(Long uid, ShareSourceTypeEnum source, List<TaoBaoGoodsBrief> listGoods)
|
| | | public FileUploadResult save(Long uid, ShareSourceTypeEnum source, String title, List<TaoBaoGoodsBrief> listGoods)
|
| | | throws UserShareGoodsRecordException;
|
| | |
|
| | | /**
|
| | |
| | | * @param taoBaoGoodsBrief 商品
|
| | | * @throws UserShareGoodsRecordException
|
| | | */
|
| | | public void save(Long uid, ShareSourceTypeEnum source, TaoBaoGoodsBrief taoBaoGoodsBrief)
|
| | | public void save(Long uid, ShareSourceTypeEnum source, String title, TaoBaoGoodsBrief taoBaoGoodsBrief)
|
| | | throws UserShareGoodsRecordException;
|
| | | |
| | | |
| | | /**
|
| | | * 查询已分享商品
|
| | | * @param recordId
|
| | | * @return
|
| | | * @throws UserShareGoodsRecordException
|
| | | */
|
| | | public JSONObject getGoodsGroup(Long recordId) throws UserShareGoodsRecordException;
|
| | |
|
| | |
|
| | | }
|
| | |
| | | }
|
| | | g2d.setFont(font);
|
| | | try {
|
| | | g2d.setColor(new Color(153, 153, 153));
|
| | | // g2d.setColor(new Color(153, 153, 153));
|
| | | // 画第一张
|
| | | for (int i = 0; i < goodsList.size(); i++) {
|
| | | TaoBaoGoodsBrief goods = goodsList.get(i);
|
| | |
| | | g2d.setStroke(new BasicStroke(2.0f));
|
| | | g2d.drawLine(70 + 20, 674, 90 + 10 + textLength, 674);
|
| | |
|
| | | // 画券右侧
|
| | | BufferedImage quanRight = ImageIO
|
| | | .read(ImageUtil.class.getClassLoader().getResourceAsStream("image/fanli_quan_right.png"));
|
| | | quanRight = zoomInImage(quanRight, 12, 60);
|
| | | g2d.setColor(new Color(241, 66, 66));
|
| | | g2d.drawImage(quanRight, topX + 630 - quanRight.getWidth(), topY + 630 - quanRight.getHeight(),
|
| | | null);
|
| | | String quanString = "";
|
| | | BigDecimal withNoZera = MoneyBigDecimalUtil.getWithNoZera(goods.getCouponAmount());
|
| | | |
| | | if (!withNoZera.toString().endsWith("0")) {
|
| | | |
| | | // 画券右侧
|
| | | BufferedImage quanRight = ImageIO
|
| | | .read(ImageUtil.class.getClassLoader().getResourceAsStream("image/fanli_quan_right.png"));
|
| | | quanRight = zoomInImage(quanRight, 12, 60);
|
| | | g2d.setColor(new Color(241, 66, 66));
|
| | | g2d.drawImage(quanRight, topX + 630 - quanRight.getWidth(), topY + 630 - quanRight.getHeight(),
|
| | | null);
|
| | |
|
| | | // 画券的内容
|
| | | g2d.setColor(new Color(229, 0, 93));
|
| | | // 画券的内容
|
| | | g2d.setColor(new Color(229, 0, 93));
|
| | |
|
| | | String quanString = " " + MoneyBigDecimalUtil.getWithNoZera(goods.getCouponAmount()) + "元券 ";
|
| | | quanString = " " + withNoZera + "元券 ";
|
| | |
|
| | | font = font.deriveFont(36.0f);
|
| | | g2d.setFont(font);
|
| | | fm = g2d.getFontMetrics(font);
|
| | | textLength = fm.stringWidth(quanString);
|
| | | font = font.deriveFont(36.0f);
|
| | | g2d.setFont(font);
|
| | | fm = g2d.getFontMetrics(font);
|
| | | textLength = fm.stringWidth(quanString);
|
| | |
|
| | | g2d.fillRect(topX + 630 - quanRight.getWidth() - textLength, topY + 630 - quanRight.getHeight(),
|
| | | textLength, quanRight.getHeight());
|
| | | g2d.fillRect(topX + 630 - quanRight.getWidth() - textLength, topY + 630 - quanRight.getHeight(),
|
| | | textLength, quanRight.getHeight());
|
| | |
|
| | | g2d.setColor(Color.WHITE);
|
| | | g2d.drawString(quanString, topX + 630 - quanRight.getWidth() - textLength,
|
| | | topY + 630 + 42 - quanRight.getHeight());
|
| | | g2d.setColor(Color.WHITE);
|
| | | g2d.drawString(quanString, topX + 630 - quanRight.getWidth() - textLength,
|
| | | topY + 630 + 42 - quanRight.getHeight());
|
| | |
|
| | | // 画券左侧
|
| | | BufferedImage quanLeft = ImageIO
|
| | | .read(ImageUtil.class.getClassLoader().getResourceAsStream("image/fanli_quan_left.png"));
|
| | | quanLeft = zoomInImage(quanLeft, 12, 60);
|
| | | g2d.drawImage(quanLeft, topX + 630 - quanRight.getWidth() - textLength - quanLeft.getWidth(),
|
| | | topY + 630 - quanRight.getHeight(), null);
|
| | | // 画券左侧
|
| | | BufferedImage quanLeft = ImageIO
|
| | | .read(ImageUtil.class.getClassLoader().getResourceAsStream("image/fanli_quan_left.png"));
|
| | | quanLeft = zoomInImage(quanLeft, 12, 60);
|
| | | g2d.drawImage(quanLeft, topX + 630 - quanRight.getWidth() - textLength - quanLeft.getWidth(),
|
| | | topY + 630 - quanRight.getHeight(), null);
|
| | | }
|
| | |
|
| | | } else {
|
| | | // 计算左上角坐标
|
| | |
| | |
|
| | | // 画券
|
| | |
|
| | | // 画券右侧
|
| | | BufferedImage quanRight = ImageIO
|
| | | .read(ImageUtil.class.getClassLoader().getResourceAsStream("image/fanli_quan_right.png"));
|
| | | quanRight = zoomInImage(quanRight, 8, 40);
|
| | | g2d.setColor(new Color(241, 66, 66));
|
| | | g2d.drawImage(quanRight, topX + 315 - quanRight.getWidth(), topY + 315 - quanRight.getHeight(),
|
| | | null);
|
| | | String quanString = "";
|
| | | BigDecimal withNoZera = MoneyBigDecimalUtil.getWithNoZera(goods.getCouponAmount());
|
| | | |
| | | if (!withNoZera.toString().endsWith("0")) {
|
| | | |
| | | // 画券右侧
|
| | | BufferedImage quanRight = ImageIO
|
| | | .read(ImageUtil.class.getClassLoader().getResourceAsStream("image/fanli_quan_right.png"));
|
| | | quanRight = zoomInImage(quanRight, 8, 40);
|
| | | g2d.setColor(new Color(241, 66, 66));
|
| | | g2d.drawImage(quanRight, topX + 315 - quanRight.getWidth(), topY + 315 - quanRight.getHeight(),
|
| | | null);
|
| | |
|
| | | // 画券的内容
|
| | | g2d.setColor(new Color(229, 0, 93));
|
| | | // 画券的内容
|
| | | g2d.setColor(new Color(229, 0, 93));
|
| | | |
| | | quanString = " " + withNoZera + "元券 ";
|
| | | |
| | | font = font.deriveFont(24.0f);
|
| | | g2d.setFont(font);
|
| | | FontMetrics fm = g2d.getFontMetrics(font);
|
| | | int textLength = fm.stringWidth(quanString);
|
| | |
|
| | | String quanString = " " + MoneyBigDecimalUtil.getWithNoZera(goods.getCouponAmount()) + "元券 ";
|
| | | g2d.fillRect(topX + 315 - quanRight.getWidth() - textLength, topY + 315 - quanRight.getHeight(),
|
| | | textLength, quanRight.getHeight());
|
| | |
|
| | | font = font.deriveFont(24.0f);
|
| | | g2d.setFont(font);
|
| | | FontMetrics fm = g2d.getFontMetrics(font);
|
| | | int textLength = fm.stringWidth(quanString);
|
| | | g2d.setColor(Color.WHITE);
|
| | |
|
| | | g2d.fillRect(topX + 315 - quanRight.getWidth() - textLength, topY + 315 - quanRight.getHeight(),
|
| | | textLength, quanRight.getHeight());
|
| | | g2d.setFont(font);
|
| | | g2d.drawString(quanString, topX + 315 - quanRight.getWidth() - textLength,
|
| | | topY + 315 + 28 - quanRight.getHeight());
|
| | |
|
| | | g2d.setColor(Color.WHITE);
|
| | |
|
| | | g2d.setFont(font);
|
| | | g2d.drawString(quanString, topX + 315 - quanRight.getWidth() - textLength,
|
| | | topY + 315 + 28 - quanRight.getHeight());
|
| | |
|
| | | // 画券左侧
|
| | | BufferedImage quanLeft = ImageIO
|
| | | .read(ImageUtil.class.getClassLoader().getResourceAsStream("image/fanli_quan_left.png"));
|
| | | quanLeft = zoomInImage(quanLeft, 8, 40);
|
| | | g2d.drawImage(quanLeft, topX + 315 - quanRight.getWidth() - textLength - quanLeft.getWidth(),
|
| | | topY + 315 - quanRight.getHeight(), null);
|
| | | // 画券左侧
|
| | | BufferedImage quanLeft = ImageIO
|
| | | .read(ImageUtil.class.getClassLoader().getResourceAsStream("image/fanli_quan_left.png"));
|
| | | quanLeft = zoomInImage(quanLeft, 8, 40);
|
| | | g2d.drawImage(quanLeft, topX + 315 - quanRight.getWidth() - textLength - quanLeft.getWidth(),
|
| | | topY + 315 - quanRight.getHeight(), null);
|
| | | }
|
| | | |
| | | }
|
| | | }
|
| | |
|
| | |
| | | // g2d.drawString("返利券提醒您", 312, 1118 + 40);
|
| | |
|
| | | g2d.setColor(new Color(102, 102, 102));
|
| | | g2d.drawString("长按识别二维码领取优惠券", 312, 1118 + 77);
|
| | | g2d.drawString("长按识别二维码免费领券", 312, 1142);
|
| | | |
| | | g2d.setColor(new Color(102, 102, 102));
|
| | | g2d.drawString("共", 1000, 1142);
|
| | | |
| | | |
| | | g2d.setColor(new Color(229, 0, 93));
|
| | | g2d.drawString(goodsList.size()+"", 1055, 1142);
|
| | | |
| | | |
| | | g2d.setColor(new Color(102, 102, 102));
|
| | | g2d.drawString("个商品", 1090, 1142);
|
| | | |
| | | // 提示语
|
| | | BufferedImage tips = ImageIO
|
| | | .read(ImageUtil.class.getClassLoader().getResourceAsStream("image/share/tips1.png"));
|
| | | tips = zoomInImage(tips,850, 65);
|
| | | //g2d.setColor(new Color(255, 250, 250));
|
| | | g2d.drawImage(tips, 312,1180, null);
|
| | |
|
| | |
|
| | | g2d.dispose();
|
| | |
|