| | |
| | | import com.yeshi.fanli.entity.bus.activity.RecommendActivity;
|
| | | 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.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.activity.ActivityService;
|
| | |
| | | try {
|
| | | ActivityShareResult result = activityService.shareActivityGoods(343448L, 1L);
|
| | | out.print(JsonUtil.getSimpleGson().toJson(result));
|
| | | } catch (UserShareGoodsRecordException e) {
|
| | | e.printStackTrace();
|
| | | } catch (ActivityException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
| | | // 更新访问次数
|
| | | userShareGoodsGroupService.updateBrowseRecord(shareId, 1);
|
| | | // 获取商品信息
|
| | | JSONObject data = userShareGoodsRecordService.getGoodsGroup(shareId);
|
| | | JSONObject data = userShareGoodsRecordService.getGoodsGroupDetail(shareId);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | |
|
| | | } catch (Exception e) {
|
| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | import org.jsoup.Jsoup;
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMethod;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.NumberUtil;
|
| | | import org.yeshi.utils.entity.FileUploadResult;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | |
| | | import com.yeshi.fanli.entity.bus.activity.ActivityShareResult;
|
| | | import com.yeshi.fanli.entity.bus.activity.RecommendActivity;
|
| | | import com.yeshi.fanli.exception.ActivityException;
|
| | | import com.yeshi.fanli.exception.share.UserShareGoodsRecordException;
|
| | | import com.yeshi.fanli.service.inter.activity.ActivityService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.NumberUtil;
|
| | | import org.yeshi.utils.entity.FileUploadResult;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | /**
|
| | | * 动态
|
| | |
| | | imgList.add(uploadResult.getUrl());
|
| | | data.put("shareImgs", imgList);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | |
| | | } catch (UserShareGoodsRecordException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage()));
|
| | | } catch (ActivityException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage()));
|
| | | }
|
| | |
| | | try {
|
| | | JSONObject data = activityService.shareGoodsV2(uid, activityId);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | } catch (UserShareGoodsRecordException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage()));
|
| | | } catch (ActivityException e) {
|
| | | out.print(JsonUtil.loadFalseResult("分享失败"));
|
| | | e.printStackTrace();
|
| | |
| | | data.put("shareTitle", result.getTitle());
|
| | | data.put("shareImgs", result.getImgList());
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | } catch (UserShareGoodsRecordException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage()));
|
| | | } catch (ActivityException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage()));
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 分享记录统计列表
|
| | | *
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | |
| | | /**
|
| | | * 商品详情分享
|
| | | * @param acceptData
|
| | | * @param uid 用户id
|
| | | * @param auctionId 商品id
|
| | | * @param type 图片分享类型 单图single 多图many |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "sharedetail", method = RequestMethod.POST)
|
| | | public void shareDetail(AcceptData acceptData, Long uid, Long auctionId, String type, PrintWriter out) {
|
| | | try {
|
| | | userShareGoodsRecordService.saveDetail(uid, auctionId, type);
|
| | | out.print(JsonUtil.loadTrueResult("分享成功"));
|
| | | } catch (UserShareGoodsRecordException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getMsg()));
|
| | | e.printStackTrace();
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("加载失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 更新分享记录
|
| | | * @param acceptData
|
| | | * @param shareId
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "updaterecord", method = RequestMethod.POST)
|
| | | public void updateRecord(AcceptData acceptData, Long shareId, PrintWriter out) {
|
| | | if (shareId == null) {
|
| | | out.print(JsonUtil.loadFalseResult("参数不正确"));
|
| | | }
|
| | | |
| | | try {
|
| | | userShareGoodsRecordService.updateShareRecord(shareId);
|
| | | out.print(JsonUtil.loadTrueResult(""));
|
| | | } catch (UserShareGoodsRecordException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getMsg()));
|
| | | e.printStackTrace();
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("加载失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | | }
|
| | |
| | | private UserGoodsStorageService userGoodsStorageService;
|
| | |
|
| | | /**
|
| | | * 添加选品库
|
| | | * 单个商品加入选品库
|
| | | * |
| | | * @param callback
|
| | | * @param storageIds
|
| | | * id数组
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "accordtorage", method = RequestMethod.POST)
|
| | | public void accordtorage(AcceptData acceptData, Long uid, Long auctionId, PrintWriter out) {
|
| | |
|
| | | if (auctionId == null) {
|
| | | out.print(JsonUtil.loadFalseResult("未选择商品"));
|
| | | return;
|
| | | }
|
| | | |
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult("用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | try {
|
| | |
|
| | | UserGoodsStorage userGoodsStorage = userGoodsStorageService.getByUidAndAuctionId(uid, auctionId);
|
| | | boolean storageState = false;
|
| | | if (userGoodsStorage != null) {
|
| | | // 取消加入选品库
|
| | | userGoodsStorageService.deleteByPrimaryKey(userGoodsStorage.getId());
|
| | | } else {
|
| | | // 加入选品库
|
| | | Set<Long> set = new HashSet<Long>();
|
| | | set.add(auctionId);
|
| | | userGoodsStorageService.save(uid, set);
|
| | | storageState = true;
|
| | | }
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("storageState", storageState);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | |
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("操作失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 批量添加选品库
|
| | | *
|
| | | * @param acceptData
|
| | | * @param uid
|
| | |
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 单个商品加入选品库
|
| | | * |
| | | * @param callback
|
| | | * @param storageIds
|
| | | * id数组
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "accordtorage", method = RequestMethod.POST)
|
| | | public void accordtorage(AcceptData acceptData, Long uid, Long auctionId, PrintWriter out) {
|
| | |
|
| | | if (auctionId == null) {
|
| | | out.print(JsonUtil.loadFalseResult("未选择商品"));
|
| | | return;
|
| | | }
|
| | | |
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult("用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | try {
|
| | |
|
| | | UserGoodsStorage userGoodsStorage = userGoodsStorageService.getByUidAndAuctionId(uid, auctionId);
|
| | | boolean storageState = false;
|
| | | if (userGoodsStorage != null) {
|
| | | // 取消加入选品库
|
| | | userGoodsStorageService.deleteByPrimaryKey(userGoodsStorage.getId());
|
| | | } else {
|
| | | // 加入选品库
|
| | | Set<Long> set = new HashSet<Long>();
|
| | | set.add(auctionId);
|
| | | userGoodsStorageService.save(uid, set);
|
| | | storageState = true;
|
| | | }
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("storageState", storageState);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | |
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("操作失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 删除
|
| | | * 分享商品返回二维码图片
|
| | | *
|
| | | * @param callback
|
| | | * @param storageIds
|
| | |
| | | * @return |
| | | */ |
| | | List<UserGoodsStorage> listQueryByIds(List<Long> list); |
| | | |
| | | void updateShareState(@Param("shareId") Long shareId); |
| | | } |
| | |
| | | @Column(name = "sgr_title")
|
| | | private String title;
|
| | |
|
| | | // 是否已分享 状态:0初始值 1已分享
|
| | | @Expose
|
| | | @Column(name = "sgr_share_state")
|
| | | private Integer shareState;
|
| | | |
| | | // 分享时间
|
| | | @Column(name = "sgr_createtime")
|
| | | private Date createTime;
|
| | |
| | | public void setTitle(String title) {
|
| | | this.title = title;
|
| | | }
|
| | | |
| | |
|
| | | public Integer getShareState() {
|
| | | return shareState;
|
| | | }
|
| | |
|
| | | public void setShareState(Integer shareState) {
|
| | | this.shareState = shareState;
|
| | | }
|
| | | }
|
| | |
| | | <select id="getSingleGoods" resultMap="BaseResultMap"> |
| | | SELECT *,COUNT(g.`gu_id`)AS totalGoods FROM yeshi_ec_share_goods_group g |
| | | RIGHT JOIN `yeshi_ec_share_goods_record` r ON g.`gu_record_id` = r.`sgr_id` |
| | | WHERE g.`gu_common_goods_id` = #{cid} AND r.`sgr_uid` = #{uid} |
| | | WHERE g.`gu_common_goods_id` = #{cid} AND r.`sgr_uid` = #{uid} AND r.sgr_share_state = 1 |
| | | GROUP BY r.`sgr_id` |
| | | ORDER BY totalGoods LIMIT 1 |
| | | </select> |
| | |
| | | SELECT * FROM yeshi_ec_share_goods_group tg |
| | | RIGHT JOIN `yeshi_ec_share_goods_record` r ON tg.`gu_record_id` = r.`sgr_id` |
| | | LEFT JOIN `yeshi_ec_common_goods` cg ON tg.`gu_common_goods_id` = cg.`cg_id` |
| | | WHERE r.`sgr_uid` = #{uid} AND cg.`cg_goods_id` = #{auctionId} |
| | | WHERE r.`sgr_uid` = #{uid} AND cg.`cg_goods_id` = #{auctionId} AND r.sgr_share_state = 1 |
| | | ORDER BY gu_updatetime desc LIMIT 1 |
| | | </select> |
| | | |
| | |
| | | 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_share_state" property="shareState" jdbcType="INTEGER"/> |
| | | <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_title,sgr_createtime,sgr_updatetime</sql> |
| | | <sql id="Base_Column_List">sgr_id,sgr_uid,sgr_source,sgr_picture,sgr_title,sgr_share_state,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_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="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_share_state,sgr_createtime,sgr_updatetime) values (#{id,jdbcType=BIGINT},#{uid,jdbcType=BIGINT},#{source,jdbcType=VARCHAR},#{picture,jdbcType=VARCHAR},#{sgr_title,jdbcType=VARCHAR},#{shareState,jdbcType=INTEGER},#{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="title != null">sgr_title,</if> |
| | | <if test="shareState != null">sgr_share_state,</if> |
| | | <if test="createTime != null">sgr_createtime,</if> |
| | | <if test="updateTime != null">sgr_updatetime,</if> |
| | | </trim>values |
| | |
| | | <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="shareState != null">#{shareState,jdbcType=INTEGER},</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_title = #{title,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_share_state = #{shareState,jdbcType=INTEGER},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="shareState != null">sgr_share_state=#{shareState,jdbcType=INTEGER},</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} |
| | |
| | | |
| | | <select id="listQueryByUid" resultMap="BaseResultMap"> |
| | | SELECT * FROM yeshi_ec_share_goods_record |
| | | WHERE sgr_uid = #{uid} |
| | | WHERE sgr_uid = #{uid} AND sgr_share_state = 1 |
| | | <if test="source != null and source != '' "> |
| | | AND sgr_source = #{source} |
| | | </if> |
| | |
| | | |
| | | <select id="countQueryByUid" resultType="java.lang.Long"> |
| | | SELECT IFNULL(count(sgr_id),0) FROM yeshi_ec_share_goods_record |
| | | WHERE sgr_uid = #{uid} |
| | | WHERE sgr_uid = #{uid} AND sgr_share_state = 1 |
| | | <if test="source != null and source != '' "> |
| | | AND sgr_source = #{source} |
| | | </if> |
| | |
| | | WHERE g.guc_id IN <foreach collection="list" item="item" open="(" close=")" |
| | | separator=",">#{item}</foreach> |
| | | </select> |
| | | |
| | | |
| | | <update id="updateShareState" parameterType="java.lang.Long"> |
| | | UPDATE `yeshi_ec_user_goods_storage` ts SET ts.`guc_state` = 1 |
| | | WHERE ts.`guc_common_id` IN |
| | | (SELECT tg.`gu_common_goods_id` FROM yeshi_ec_share_goods_group tg WHERE tg.`gu_record_id` = #{shareId}) |
| | | </update> |
| | | </mapper> |
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public ActivityShareResult shareActivityGoods(Long uid, Long activityId) throws ActivityException {
|
| | | public ActivityShareResult shareActivityGoods(Long uid, Long activityId) throws ActivityException,UserShareGoodsRecordException {
|
| | |
|
| | | RecommendActivity activity = recommendActivityMapper.selectByPrimaryKey(activityId);
|
| | |
|
| | |
| | | });
|
| | | }
|
| | |
|
| | | 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 {
|
| | | if (listGoodsBrief.size() < 1) {
|
| | | throw new ActivityException(1, "商品下架");
|
| | | }
|
| | |
|
| | | JSONObject resultdata = userShareGoodsRecordService.save(uid, ShareSourceTypeEnum.activity, title, listGoodsBrief);
|
| | | imgList.add((FileUploadResult) resultdata.get("loadResult"));
|
| | | result.setImgList(imgList);
|
| | | |
| | | return result;
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | public JSONObject shareGoodsV2(Long uid, Long activityId) throws ActivityException {
|
| | | public JSONObject shareGoodsV2(Long uid, Long activityId) throws ActivityException,UserShareGoodsRecordException {
|
| | |
|
| | | RecommendActivity activity = recommendActivityMapper.selectByPrimaryKey(activityId);
|
| | |
|
| | |
| | |
|
| | | result.setTitle(title);
|
| | |
|
| | | List<FileUploadResult> imgList = new ArrayList<>();
|
| | | List<TaoBaoGoodsBrief> listGoodsBrief = new ArrayList<TaoBaoGoodsBrief>();
|
| | |
|
| | | if (activity.getGoodsList() != null) {
|
| | |
| | | });
|
| | | }
|
| | |
|
| | | 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 {
|
| | | if (listGoodsBrief.size() < 1) {
|
| | | throw new ActivityException(1, "商品下架");
|
| | | }
|
| | |
|
| | |
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("shareImg", loadResult);
|
| | | |
| | | JSONObject resultdata = userShareGoodsRecordService.save(uid, |
| | | ShareSourceTypeEnum.activity, title, listGoodsBrief);
|
| | | |
| | | data.put("revenue", revenue);
|
| | | data.put("shareId", resultdata.get("shareId"));
|
| | | data.put("shareImg", resultdata.get("loadResult"));
|
| | | data.put("notifyDesc", configService.get("goods_share_notify"));
|
| | |
|
| | | return data;
|
| | |
| | | import org.springframework.core.task.TaskExecutor;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.entity.FileUploadResult;
|
| | | import org.yeshi.utils.taobao.TbImgUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | |
| | | @Override
|
| | | public long countQueryByUid(Long uid) {
|
| | | return userGoodsStorageMapper.countQueryByUid(uid);
|
| | | }
|
| | | |
| | | @Override
|
| | | public void updateShareState(Long shareId) {
|
| | | userGoodsStorageMapper.updateShareState(shareId);
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | CommonGoods commonGoods = userGoodsStorage.getCommonGoods();
|
| | | TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(commonGoods);
|
| | | listGoodsBrief.add(goodsBrief);
|
| | | // 已分享
|
| | | userGoodsStorage.setState(1);
|
| | | userGoodsStorage.setUpdateTime(new Date());
|
| | |
|
| | | 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, |
| | | |
| | | JSONObject result = userShareGoodsRecordService.save(uid, ShareSourceTypeEnum.storage, |
| | | null, listGoodsBrief);
|
| | |
|
| | | // 更新为已分享
|
| | | userGoodsStorageMapper.updateBatchSelective(listStorage);
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("shareImg", loadResult);
|
| | | data.put("revenue", revenue);
|
| | | data.put("shareId", result.get("shareId"));
|
| | | data.put("shareImg", result.get("loadResult"));
|
| | | data.put("notifyDesc", configService.get("goods_share_notify"));
|
| | |
|
| | | return data;
|
| | |
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.goods.CommonGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBriefExtra;
|
| | | 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.goods.CommonGoodsService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.user.UserAccountService;
|
| | | import com.yeshi.fanli.service.inter.user.UserGoodsStorageService;
|
| | | import com.yeshi.fanli.service.inter.user.UserShareGoodsGroupService;
|
| | | import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService;
|
| | | import com.yeshi.fanli.util.AESUtil;
|
| | |
| | |
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | | |
| | | @Resource
|
| | | private UserGoodsStorageService userGoodsStorageService;
|
| | |
|
| | | @Override
|
| | | public int insert(UserShareGoodsRecord record) {
|
| | |
| | | return list;
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | public void saveDetail(Long uid, Long auctionId, String type) throws UserShareGoodsRecordException {
|
| | | |
| | | if (auctionId == null) {
|
| | | throw new UserShareGoodsRecordException(1, "分享商品不能为空");
|
| | | }
|
| | | |
| | | if (uid == null) {
|
| | | throw new UserShareGoodsRecordException(1, "用户ID不能为空");
|
| | | }
|
| | | |
| | | TaoBaoGoodsBrief goodsBrief = null;
|
| | | try {
|
| | | goodsBrief = redisManager.getTaoBaoGoodsBrief(auctionId);
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | throw new UserShareGoodsRecordException(1, "商品已下架");
|
| | | }
|
| | | |
| | | UserShareGoodsRecord userShareGoodsRecord = new UserShareGoodsRecord();
|
| | | userShareGoodsRecord.setUid(uid);
|
| | | userShareGoodsRecord.setSource(ShareSourceTypeEnum.goodsDetail);
|
| | | userShareGoodsRecord.setShareState(1);// 已分享成功
|
| | | // 单个商品分享
|
| | | singleGoodsShare(userShareGoodsRecord, goodsBrief);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void save(Long uid, ShareSourceTypeEnum source, String title, TaoBaoGoodsBrief taoBaoGoodsBrief) throws UserShareGoodsRecordException {
|
| | |
| | | * @throws UserShareGoodsRecordException
|
| | | */
|
| | | @Override
|
| | | public FileUploadResult save(Long uid, ShareSourceTypeEnum source, String title, List<TaoBaoGoodsBrief> listGoods) throws UserShareGoodsRecordException {
|
| | | public JSONObject save(Long uid, ShareSourceTypeEnum source, String title, List<TaoBaoGoodsBrief> listGoods) throws UserShareGoodsRecordException {
|
| | |
|
| | | if (listGoods == null || listGoods.size() < 0) {
|
| | | throw new UserShareGoodsRecordException(1, "分享商品数量不足");
|
| | |
| | | userShareGoodsRecord.setPicture(listGoods.get(0).getPictUrl());
|
| | |
|
| | | Date date = new Date();
|
| | | userShareGoodsRecord.setShareState(0); // 初始未分享
|
| | | userShareGoodsRecord.setCreateTime(date);
|
| | | userShareGoodsRecord.setUpdateTime(date);
|
| | | userShareGoodsRecordMapper.insertSelective(userShareGoodsRecord);
|
| | |
|
| | | // 多个商品分享
|
| | | return multipleGoodsShare(userShareGoodsRecord, listGoods);
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | // 多个商品分享
|
| | | FileUploadResult loadResult = multipleGoodsShare(userShareGoodsRecord, listGoods);
|
| | | data.put("loadResult", loadResult);
|
| | | data.put("shareId", userShareGoodsRecord.getId());
|
| | | |
| | | return data;
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | |
|
| | | @Override
|
| | | public JSONObject getGoodsGroup(Long recordId) throws UserShareGoodsRecordException {
|
| | | UserShareGoodsRecord userShareGoodsRecord = userShareGoodsRecordMapper.selectByPrimaryKey(recordId);
|
| | |
|
| | | List<CommonGoods> listUpadteCommonGoods = new ArrayList<CommonGoods>();
|
| | |
|
| | | JSONArray array = new JSONArray();
|
| | | List<CommonGoods> listUpadteCommonGoods = new ArrayList<CommonGoods>();
|
| | |
|
| | | List<UserShareGoodsGroup> list = userShareGoodsGroupService.listByRecordId(recordId);
|
| | | if (list != null && list.size() > 0) {
|
| | |
| | | }
|
| | |
|
| | | // 改变图片尺寸
|
| | | String pictUrl = commonGoods.getPicture();
|
| | | String pictUrl = goodsBrief.getPictUrl();
|
| | | if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) {
|
| | | commonGoods.setPicture(TbImgUtil.getTBSize320Img(pictUrl));
|
| | | goodsBrief.setPictUrl(TbImgUtil.getTBSize320Img(pictUrl));
|
| | | }
|
| | |
|
| | | String json = gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief, proportion, null));
|
| | |
|
| | | dataObject.put("groupId", userShareGoodsGroup.getId());
|
| | | dataObject.put("goods", json);
|
| | | |
| | | userShareGoodsGroup.setId(null);
|
| | | userShareGoodsGroup.setBrowseTime(null);
|
| | | userShareGoodsGroup.setCreateTime(null);
|
| | | userShareGoodsGroup.setUpdateTime(null);
|
| | | userShareGoodsGroup.setRecordId(null);
|
| | | dataObject.put("group", gson.toJson(userShareGoodsGroup));
|
| | | dataObject.put("goods", gson.toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief, proportion, null)));
|
| | | array.add(dataObject);
|
| | | }
|
| | | }
|
| | |
|
| | | String title = "";
|
| | | UserShareGoodsRecord userShareGoodsRecord = userShareGoodsRecordMapper.selectByPrimaryKey(recordId);
|
| | | if(userShareGoodsRecord != null) {
|
| | | title = userShareGoodsRecord.getTitle();
|
| | | }
|
| | |
| | | return data;
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public JSONObject getGoodsGroupDetail(Long recordId) throws UserShareGoodsRecordException {
|
| | | |
| | | 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;
|
| | | // 更新一个小时之内的商品不再更新
|
| | | 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;
|
| | | if (goodsBrief.getCouponLeftCount() < 1 || StringUtil.isNullOrEmpty(goodsBrief.getCouponInfo())) {
|
| | | goodsBrief.setState(1); // 已抢光
|
| | | }
|
| | | |
| | | 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 = goodsBrief.getPictUrl();
|
| | | if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) {
|
| | | goodsBrief.setPictUrl(TbImgUtil.getTBSize320Img(pictUrl));
|
| | | }
|
| | | |
| | | TaoBaoGoodsBriefExtra taoBaoGoodsBriefExtra = TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief, proportion, null);
|
| | | array.add(gson.toJson(taoBaoGoodsBriefExtra));
|
| | | }
|
| | | }
|
| | | |
| | | String title = "";
|
| | | UserShareGoodsRecord userShareGoodsRecord = userShareGoodsRecordMapper.selectByPrimaryKey(recordId);
|
| | | 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;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void updateShareRecord (Long shareId) throws UserShareGoodsRecordException {
|
| | | UserShareGoodsRecord shareRecord = userShareGoodsRecordMapper.selectByPrimaryKey(shareId);
|
| | | if (shareRecord == null) {
|
| | | throw new UserShareGoodsRecordException(1, "分享记录不存在");
|
| | | }
|
| | | |
| | | userGoodsStorageService.updateShareState(shareId);
|
| | | }
|
| | | }
|
| | |
| | | import com.yeshi.fanli.entity.bus.activity.RecommendActivity;
|
| | | import com.yeshi.fanli.entity.bus.activity.RecommendActivityInviteInfo;
|
| | | import com.yeshi.fanli.exception.ActivityException;
|
| | | import com.yeshi.fanli.exception.share.UserShareGoodsRecordException;
|
| | |
|
| | | /**
|
| | | * 动态服务
|
| | |
| | | * @param uid
|
| | | * @param activityId
|
| | | * @return
|
| | | * @throws UserShareGoodsRecordException |
| | | */
|
| | | public ActivityShareResult shareActivityGoods(Long uid, Long activityId) throws ActivityException;
|
| | | public ActivityShareResult shareActivityGoods(Long uid, Long activityId) throws ActivityException, UserShareGoodsRecordException;
|
| | |
|
| | | /**
|
| | | * 分享邀请图片
|
| | |
| | | * @return
|
| | | * @throws ActivityException
|
| | | */
|
| | | public JSONObject shareGoodsV2(Long uid, Long activityId) throws ActivityException;
|
| | | public JSONObject shareGoodsV2(Long uid, Long activityId) throws ActivityException, UserShareGoodsRecordException;
|
| | | }
|
| | |
| | | */
|
| | | public JSONObject shareGoods(Long uid, List<Long> listStorageID) throws UserGoodsStorageException, UserShareGoodsRecordException;
|
| | |
|
| | | /**
|
| | | * 更新商品状态为已分享
|
| | | * @param shareId 分享
|
| | | */
|
| | | public void updateShareState(Long shareId);
|
| | |
|
| | | }
|
| | |
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | import org.yeshi.utils.entity.FileUploadResult;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord.ShareSourceTypeEnum;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | |
| | | * @param listGoods 商品集合
|
| | | * @throws UserShareGoodsRecordException
|
| | | */
|
| | | public FileUploadResult save(Long uid, ShareSourceTypeEnum source, String title, List<TaoBaoGoodsBrief> listGoods)
|
| | | public JSONObject save(Long uid, ShareSourceTypeEnum source, String title, List<TaoBaoGoodsBrief> listGoods)
|
| | | throws UserShareGoodsRecordException;
|
| | |
|
| | | /**
|
| | |
| | | */
|
| | | public JSONObject getGoodsGroup(Long recordId) throws UserShareGoodsRecordException;
|
| | |
|
| | | /**
|
| | | * h5分享商品列表
|
| | | * @param recordId
|
| | | * @return
|
| | | * @throws UserShareGoodsRecordException
|
| | | */
|
| | | public JSONObject getGoodsGroupDetail(Long recordId) throws UserShareGoodsRecordException;
|
| | |
|
| | | /**
|
| | | * 更新分享记录
|
| | | * @param shareId
|
| | | * @throws UserShareGoodsRecordException
|
| | | */
|
| | | public void updateShareRecord(Long shareId) throws UserShareGoodsRecordException;
|
| | |
|
| | | /**
|
| | | * |
| | | * @param uid
|
| | | * @param auctionId
|
| | | * @param type
|
| | | * @throws UserShareGoodsRecordException
|
| | | */
|
| | | public void saveDetail(Long uid, Long auctionId, String type) throws UserShareGoodsRecordException;
|
| | |
|
| | | }
|