admin
2018-12-12 205f8ba403095b4894d026f800d2651223c19d00
Merge remote-tracking branch 'origin/master'
16个文件已修改
492 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/TestController.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/apph5/AppH5ShareController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/ActivityController.java 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/ShareController.java 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/client/UserGoodsStorageController.java 96 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/user/UserGoodsStorageMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/share/UserShareGoodsRecord.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/share/UserShareGoodsGroupMapper.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/share/UserShareGoodsRecordMapper.xml 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/user/UserGoodsStorageMapper.xml 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/activity/ActivityServiceImpl.java 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserGoodsStorageServiceImpl.java 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserShareGoodsRecordServiceImpl.java 183 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/activity/ActivityService.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserGoodsStorageService.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserShareGoodsRecordService.java 27 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/TestController.java
@@ -28,6 +28,7 @@
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;
@@ -126,6 +127,8 @@
        try {
            ActivityShareResult result = activityService.shareActivityGoods(343448L, 1L);
            out.print(JsonUtil.getSimpleGson().toJson(result));
        } catch (UserShareGoodsRecordException e) {
            e.printStackTrace();
        } catch (ActivityException e) {
            e.printStackTrace();
        }
fanli/src/main/java/com/yeshi/fanli/controller/apph5/AppH5ShareController.java
@@ -43,7 +43,7 @@
            // 更新访问次数
            userShareGoodsGroupService.updateBrowseRecord(shareId, 1);
            // 获取商品信息
            JSONObject data = userShareGoodsRecordService.getGoodsGroup(shareId);
            JSONObject data = userShareGoodsRecordService.getGoodsGroupDetail(shareId);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
            
        } catch (Exception e) {
fanli/src/main/java/com/yeshi/fanli/controller/client/ActivityController.java
@@ -8,10 +8,15 @@
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;
@@ -22,14 +27,10 @@
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;
/**
 * 动态
@@ -134,6 +135,9 @@
                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()));
        }
@@ -151,6 +155,8 @@
        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();
@@ -173,6 +179,8 @@
            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()));
        }
fanli/src/main/java/com/yeshi/fanli/controller/client/ShareController.java
@@ -188,7 +188,7 @@
        }
    }
    /**
     * 分享记录统计列表
     * 
@@ -291,4 +291,54 @@
        }
    }
    /**
     * 商品详情分享
     * @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();
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/client/UserGoodsStorageController.java
@@ -38,7 +38,53 @@
    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
@@ -149,54 +195,10 @@
    }
    
    
    /**
     *  单个商品加入选品库
     *
     * @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
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/user/UserGoodsStorageMapper.java
@@ -78,4 +78,6 @@
     * @return
     */
    List<UserGoodsStorage>  listQueryByIds(List<Long> list);
    void updateShareState(@Param("shareId") Long shareId);
}
fanli/src/main/java/com/yeshi/fanli/entity/bus/share/UserShareGoodsRecord.java
@@ -53,6 +53,11 @@
    @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;
@@ -220,5 +225,12 @@
    public void setTitle(String title) {
        this.title = title;
    }
    public Integer getShareState() {
        return shareState;
    }
    public void setShareState(Integer shareState) {
        this.shareState = shareState;
    }
}
fanli/src/main/java/com/yeshi/fanli/mapping/share/UserShareGoodsGroupMapper.xml
@@ -145,7 +145,7 @@
  <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>
@@ -154,7 +154,7 @@
    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>
   
fanli/src/main/java/com/yeshi/fanli/mapping/share/UserShareGoodsRecordMapper.xml
@@ -9,6 +9,7 @@
            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>
@@ -23,19 +24,20 @@
    <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
@@ -45,17 +47,19 @@
      <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}
@@ -63,7 +67,7 @@
  
  <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>    
@@ -73,7 +77,7 @@
   
   <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>    
fanli/src/main/java/com/yeshi/fanli/mapping/user/UserGoodsStorageMapper.xml
@@ -138,4 +138,11 @@
        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>
fanli/src/main/java/com/yeshi/fanli/service/impl/activity/ActivityServiceImpl.java
@@ -119,7 +119,7 @@
    }
    @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);
        
@@ -166,26 +166,20 @@
            });
        }
        
        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);
        
@@ -203,7 +197,6 @@
        
        result.setTitle(title);
        
        List<FileUploadResult> imgList = new ArrayList<>();
        List<TaoBaoGoodsBrief> listGoodsBrief = new ArrayList<TaoBaoGoodsBrief>();
        
        if (activity.getGoodsList() != null) {
@@ -232,17 +225,7 @@
            });
        }
        
        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, "商品下架");
        }
        
@@ -253,8 +236,13 @@
        }
        
        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;
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserGoodsStorageServiceImpl.java
@@ -14,7 +14,6 @@
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;
@@ -129,6 +128,11 @@
    @Override
    public long countQueryByUid(Long uid) {
        return userGoodsStorageMapper.countQueryByUid(uid);
    }
    @Override
    public void updateShareState(Long shareId) {
        userGoodsStorageMapper.updateShareState(shareId);
    }
    @Override
@@ -331,24 +335,20 @@
            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;
fanli/src/main/java/com/yeshi/fanli/service/impl/user/UserShareGoodsRecordServiceImpl.java
@@ -33,6 +33,7 @@
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;
@@ -40,6 +41,7 @@
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;
@@ -79,6 +81,9 @@
    
    @Resource
    private HongBaoManageService hongBaoManageService;
    @Resource
    private UserGoodsStorageService userGoodsStorageService;
    @Override
    public int insert(UserShareGoodsRecord record) {
@@ -196,6 +201,32 @@
        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 {
@@ -227,7 +258,7 @@
     * @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, "分享商品数量不足");
@@ -249,13 +280,19 @@
        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;
    }
    
    /**
@@ -458,11 +495,9 @@
    
    @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) {
@@ -526,20 +561,24 @@
                } 
                // 改变图片尺寸
                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();
        }
@@ -566,4 +605,122 @@
        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);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/inter/activity/ActivityService.java
@@ -9,6 +9,7 @@
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;
/**
 * 动态服务
@@ -173,8 +174,9 @@
     * @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;
    /**
     * 分享邀请图片
@@ -245,5 +247,5 @@
     * @return
     * @throws ActivityException
     */
    public JSONObject shareGoodsV2(Long uid, Long activityId) throws ActivityException;
    public JSONObject shareGoodsV2(Long uid, Long activityId) throws ActivityException, UserShareGoodsRecordException;
}
fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserGoodsStorageService.java
@@ -96,4 +96,10 @@
     */
    public JSONObject shareGoods(Long uid, List<Long> listStorageID) throws UserGoodsStorageException, UserShareGoodsRecordException;
    /**
     * 更新商品状态为已分享
     * @param shareId 分享
     */
    public void updateShareState(Long shareId);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/user/UserShareGoodsRecordService.java
@@ -4,8 +4,6 @@
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;
@@ -61,7 +59,7 @@
     * @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;
    /**
@@ -83,5 +81,28 @@
     */
    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;
}