| | |
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMethod;
|
| | | import org.yeshi.utils.HttpUtil;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.taobao.TbImgUtil;
|
| | |
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsHistory;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoLink;
|
| | | import com.yeshi.fanli.exception.ShareGoodsException;
|
| | |
| | | import com.yeshi.fanli.service.inter.goods.ShareGoodsService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.monitor.MonitorService;
|
| | | import com.yeshi.fanli.service.inter.user.UserShareGoodsGroupService;
|
| | | import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService;
|
| | | import com.yeshi.fanli.util.AESUtil;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.factory.MonitorFactory;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Controller(value = "ShareController1")
|
| | | @RequestMapping("api/v1/share")
|
| | |
| | |
|
| | | @Resource
|
| | | private MonitorService monitorService;
|
| | | |
| | | @Resource
|
| | | private UserShareGoodsRecordService userShareGoodsRecordService;
|
| | | |
| | | @Resource
|
| | | private UserShareGoodsGroupService userShareGoodsGroupService;
|
| | |
|
| | | // 获取商品分享链接
|
| | | @RequestMapping(value = "getGoodsShareUrl")
|
| | |
| | | }
|
| | |
|
| | | }
|
| | | |
| | | /**
|
| | | * 分享记录统计列表
|
| | | * @param acceptData
|
| | | * @param page 初始1
|
| | | * @param uid
|
| | | * @param source
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getlistrecord", method = RequestMethod.POST)
|
| | | public void getListRecord(AcceptData acceptData, Integer page, Long uid, String source, PrintWriter out) {
|
| | |
|
| | | if (page == null || page < 1) {
|
| | | out.print(JsonUtil.loadFalseResult("页码不正确"));
|
| | | }
|
| | |
|
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult("用户未登录"));
|
| | | }
|
| | |
|
| | | try {
|
| | | int pageSize = Constant.PAGE_SIZE;
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | List<UserShareGoodsRecord> list = new ArrayList<UserShareGoodsRecord>();
|
| | |
|
| | | long count = userShareGoodsRecordService.countQueryByUid(uid, source);
|
| | | |
| | | if (count > 0) {
|
| | | list = userShareGoodsRecordService.getMyShareGoodsRecords((page - 1) * pageSize, pageSize, uid, source);
|
| | | }
|
| | |
|
| | | data.put("count", count);
|
| | | data.put("result_list", list);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | |
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("加载失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 获取分享商品
|
| | | * @param acceptData
|
| | | * @param recordId
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getrecordgoods", method = RequestMethod.POST)
|
| | | public void getRecordGoods(AcceptData acceptData, Long recordId, PrintWriter out) {
|
| | |
|
| | | if (recordId == null) {
|
| | | out.print(JsonUtil.loadFalseResult("参数不正确"));
|
| | | }
|
| | |
|
| | | try {
|
| | | JSONObject data = userShareGoodsGroupService.getGoodsGroup(recordId);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("加载失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 获取分享商品单个统计信息
|
| | | * @param acceptData
|
| | | * @param groupId
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getgoodsdata", method = RequestMethod.POST)
|
| | | public void getGoodsData(AcceptData acceptData, Long groupId, PrintWriter out) {
|
| | |
|
| | | if (groupId == null) {
|
| | | out.print(JsonUtil.loadFalseResult("参数不正确"));
|
| | | }
|
| | |
|
| | | try {
|
| | | UserShareGoodsGroup userShareGoodsGroup = userShareGoodsGroupService.selectByPrimaryKey(groupId);
|
| | | if (userShareGoodsGroup != null) {
|
| | | userShareGoodsGroup.setBrowseTime(null);
|
| | | userShareGoodsGroup.setCreateTime(null);
|
| | | userShareGoodsGroup.setUpdateTime(null);
|
| | | userShareGoodsGroup.setRecordId(null);
|
| | | }
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("goodsData", userShareGoodsGroup);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("加载失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | }
|
| | |
| | | import com.google.gson.reflect.TypeToken;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.user.UserGoodsStorage;
|
| | | import com.yeshi.fanli.exception.share.UserShareGoodsRecordException;
|
| | | import com.yeshi.fanli.exception.user.UserGoodsStorageException;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.user.UserGoodsStorageService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
| | | @RequestMapping("api/v1/userstorage")
|
| | | public class UserGoodsStorageController {
|
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | | |
| | | @Resource
|
| | | private UserGoodsStorageService userGoodsStorageService;
|
| | |
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 删除
|
| | | * |
| | | * @param callback
|
| | | * @param storageIds
|
| | | * id数组
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "sharegoods", method = RequestMethod.POST)
|
| | | public void shareGoods(AcceptData acceptData, Long uid, String storageIds, PrintWriter out) {
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(storageIds)) {
|
| | | out.print(JsonUtil.loadFalseResult("分享商品不能为空"));
|
| | | return;
|
| | | }
|
| | | |
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult("用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | try {
|
| | | |
| | | Gson gson = new Gson();
|
| | | List<Long> listStorageID = gson.fromJson(storageIds, new TypeToken<ArrayList<Long>>() {}.getType());
|
| | | if (listStorageID == null || listStorageID.size() < 9) {
|
| | | out.print(JsonUtil.loadFalseResult("分享商品数量不足"));
|
| | | return;
|
| | | }
|
| | |
|
| | | JSONObject data = userGoodsStorageService.shareGoods(uid, listStorageID);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | |
| | | } catch (UserGoodsStorageException e) {
|
| | | out.print(JsonUtil.loadFalseResult("分享失败"));
|
| | | e.printStackTrace();
|
| | | } catch (UserShareGoodsRecordException e) {
|
| | | out.print(JsonUtil.loadFalseResult("分享失败"));
|
| | | e.printStackTrace();
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("分享失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.dao.mybatis.share; |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup; |
| | | |
| | | public interface UserShareGoodsGroupMapper { |
| | | |
| | | int deleteByPrimaryKey(Long id); |
| | | |
| | | int insert(UserShareGoodsGroup record); |
| | | |
| | | int insertSelective(UserShareGoodsGroup record); |
| | | |
| | | UserShareGoodsGroup selectByPrimaryKey(Long id); |
| | | |
| | | int updateByPrimaryKeySelective(UserShareGoodsGroup record); |
| | | |
| | | int updateByPrimaryKey(UserShareGoodsGroup record); |
| | | |
| | | /** |
| | | * 批量插入 |
| | | * @param list |
| | | * @return |
| | | */ |
| | | int insertBatch(List<UserShareGoodsGroup> list); |
| | | |
| | | |
| | | /** |
| | | * 查询分享商品 |
| | | * @param recordId |
| | | * @return |
| | | */ |
| | | List<UserShareGoodsGroup> listByRecordId(@Param("recordId") Long recordId); |
| | | |
| | | /** |
| | | * 查询单个商品 判断是否单个商品分享 |
| | | * @param recordId |
| | | * @return |
| | | */ |
| | | UserShareGoodsGroup getSingleGoods(@Param("cid") Long cid, @Param("uid") Long uid); |
| | | |
| | | /** |
| | | * 查询最新更新的商品 |
| | | * @param cid |
| | | * @param auctionId |
| | | * @return |
| | | */ |
| | | UserShareGoodsGroup getNewestRecord (@Param("uid") Long uid, @Param("auctionId") Long auctionId); |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.dao.mybatis.share; |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord; |
| | | |
| | | public interface UserShareGoodsRecordMapper { |
| | | |
| | | int deleteByPrimaryKey(Long id); |
| | | |
| | | int insert(UserShareGoodsRecord record); |
| | | |
| | | int insertSelective(UserShareGoodsRecord record); |
| | | |
| | | UserShareGoodsRecord selectByPrimaryKey(Long id); |
| | | |
| | | int updateByPrimaryKeySelective(UserShareGoodsRecord record); |
| | | |
| | | int updateByPrimaryKey(UserShareGoodsRecord record); |
| | | |
| | | /** |
| | | * 查询用户对应的分享记录 |
| | | * @param start |
| | | * @param count |
| | | * @param uid |
| | | * @return |
| | | */ |
| | | List<UserShareGoodsRecord> listQueryByUid(@Param("start") long start, @Param("count") int count, |
| | | @Param("uid") Long uid, @Param("source") String source); |
| | | |
| | | long countQueryByUid(@Param("uid") Long uid, @Param("source") String source); |
| | | |
| | | /** |
| | | * 统计记录 |
| | | * @param list |
| | | * @return |
| | | */ |
| | | List<UserShareGoodsRecord> listCountRecord(@Param("list") List<Long> list); |
| | | |
| | | /** |
| | | * 统计今日浏览记录 |
| | | * @param list |
| | | * @return |
| | | */ |
| | | List<UserShareGoodsRecord> listCountTodayBrowse(@Param("list") List<Long> list); |
| | | |
| | | } |
| | |
| | | int deleteBatchByPrimaryKey(List<Long> list); |
| | | |
| | | /** |
| | | * 批量选择更新 |
| | | * @param list |
| | | * @return |
| | | */ |
| | | int updateBatchSelective(List<UserGoodsStorage> list); |
| | | |
| | | /** |
| | | * 查询用户对应的选品库 |
| | | * @param start |
| | | * @param count |
| | |
| | | */ |
| | | UserGoodsStorage getByUidAndAuctionId(@Param("uid") Long uid, @Param("auctionId") Long auctionId); |
| | | |
| | | |
| | | /** |
| | | * 根据多个主键获取商品 |
| | | * @param list |
| | | * @return |
| | | */ |
| | | List<UserGoodsStorage> listQueryByIds(List<Long> list); |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.entity.bus.share;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | |
|
| | | import org.yeshi.utils.mybatis.Column;
|
| | | import org.yeshi.utils.mybatis.Table;
|
| | |
|
| | | import com.google.gson.annotations.Expose;
|
| | | import com.yeshi.fanli.entity.goods.CommonGoods;
|
| | |
|
| | | @Table("yeshi_ec_share_goods_group")
|
| | | public class UserShareGoodsGroup {
|
| | |
|
| | | @Column(name = "gu_id")
|
| | | private Long id;
|
| | |
|
| | | // 记录id
|
| | | @Column(name = "gu_record_id")
|
| | | private Long recordId;
|
| | |
|
| | | // 商品
|
| | | @Column(name = "gu_common_goods_id")
|
| | | private CommonGoods commonGoods;
|
| | | |
| | | // 今日浏览
|
| | | @Expose
|
| | | @Column(name = "gu_today_browse")
|
| | | private Integer todayBrowse;
|
| | | |
| | | // 累计浏览
|
| | | @Expose
|
| | | @Column(name = "gu_total_browse")
|
| | | private Integer totalBrowse;
|
| | | |
| | | // 预计订单
|
| | | @Expose
|
| | | @Column(name = "gu_total_order")
|
| | | private Integer totalOrder;
|
| | | |
| | | // 预计收益
|
| | | @Expose
|
| | | @Column(name = "gu_total_money")
|
| | | private BigDecimal totalMoney;
|
| | | |
| | | // 浏览时间
|
| | | @Column(name = "gu_browse_time")
|
| | | private Date browseTime;
|
| | | |
| | | // 分享时间
|
| | | @Column(name = "gu_createtime")
|
| | | private Date createTime;
|
| | | |
| | | // 更新时间
|
| | | @Column(name = "gu_updatetime")
|
| | | private Date updateTime;
|
| | | |
| | | // 记录组中的总商品数量
|
| | | private int totalGoods;
|
| | | |
| | | public UserShareGoodsGroup(){}
|
| | | |
| | | public UserShareGoodsGroup(Long id){
|
| | | this.id = id;
|
| | | }
|
| | |
|
| | | public Long getId() {
|
| | | return id;
|
| | | }
|
| | |
|
| | | public void setId(Long id) {
|
| | | this.id = id;
|
| | | }
|
| | |
|
| | | public Long getRecordId() {
|
| | | return recordId;
|
| | | }
|
| | |
|
| | | public void setRecordId(Long recordId) {
|
| | | this.recordId = recordId;
|
| | | }
|
| | |
|
| | |
|
| | | public CommonGoods getCommonGoods() {
|
| | | return commonGoods;
|
| | | }
|
| | |
|
| | | public void setCommonGoods(CommonGoods commonGoods) {
|
| | | this.commonGoods = commonGoods;
|
| | | }
|
| | |
|
| | | public Integer getTodayBrowse() {
|
| | | return todayBrowse;
|
| | | }
|
| | |
|
| | | public void setTodayBrowse(Integer todayBrowse) {
|
| | | this.todayBrowse = todayBrowse;
|
| | | }
|
| | |
|
| | | public Integer getTotalBrowse() {
|
| | | return totalBrowse;
|
| | | }
|
| | |
|
| | | public void setTotalBrowse(Integer totalBrowse) {
|
| | | this.totalBrowse = totalBrowse;
|
| | | }
|
| | |
|
| | | public Integer getTotalOrder() {
|
| | | return totalOrder;
|
| | | }
|
| | |
|
| | | public void setTotalOrder(Integer totalOrder) {
|
| | | this.totalOrder = totalOrder;
|
| | | }
|
| | |
|
| | | public BigDecimal getTotalMoney() {
|
| | | return totalMoney;
|
| | | }
|
| | |
|
| | | public void setTotalMoney(BigDecimal totalMoney) {
|
| | | this.totalMoney = totalMoney;
|
| | | }
|
| | |
|
| | | public Date getCreateTime() {
|
| | | return createTime;
|
| | | }
|
| | |
|
| | | public void setCreateTime(Date createTime) {
|
| | | this.createTime = createTime;
|
| | | }
|
| | |
|
| | | public Date getUpdateTime() {
|
| | | return updateTime;
|
| | | }
|
| | |
|
| | | public void setUpdateTime(Date updateTime) {
|
| | | this.updateTime = updateTime;
|
| | | }
|
| | |
|
| | | public int getTotalGoods() {
|
| | | return totalGoods;
|
| | | }
|
| | |
|
| | | public void setTotalGoods(int totalGoods) {
|
| | | this.totalGoods = totalGoods;
|
| | | }
|
| | |
|
| | | public Date getBrowseTime() {
|
| | | return browseTime;
|
| | | }
|
| | |
|
| | | public void setBrowseTime(Date browseTime) {
|
| | | this.browseTime = browseTime;
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.entity.bus.share;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.Date;
|
| | |
|
| | | import org.yeshi.utils.mybatis.Column;
|
| | | import org.yeshi.utils.mybatis.Table;
|
| | |
|
| | | import com.google.gson.annotations.Expose;
|
| | |
|
| | | @Table("yeshi_ec_share_goods_record")
|
| | | public class UserShareGoodsRecord {
|
| | |
|
| | | // 分享来源
|
| | | public enum ShareSourceTypeEnum {
|
| | | storage("选品库"), activity("动态"), goodsDetail("商品详情页");
|
| | | |
| | | private final String desc;
|
| | | |
| | | private ShareSourceTypeEnum(String desc) {
|
| | | this.desc = desc;
|
| | | }
|
| | |
|
| | | public String getDesc() {
|
| | | return desc;
|
| | | }
|
| | | }
|
| | | |
| | | public static String SHARETYPE_SINGLE = "single"; // 单个商品分享
|
| | | public static String SHARETYPE_GROUP = "group"; // 多商品分享
|
| | | |
| | | @Expose
|
| | | @Column(name = "sgr_id")
|
| | | private Long id;
|
| | |
|
| | | // 用户id
|
| | | @Expose
|
| | | @Column(name = "sgr_uid")
|
| | | private Long uid;
|
| | |
|
| | | // 分享来源
|
| | | @Expose
|
| | | @Column(name = "sgr_source")
|
| | | private ShareSourceTypeEnum source;
|
| | |
|
| | | // 显示主图
|
| | | @Expose
|
| | | @Column(name = "sgr_picture")
|
| | | private String picture;
|
| | | |
| | | // 分享时间
|
| | | @Column(name = "sgr_createtime")
|
| | | private Date createTime;
|
| | | |
| | | // 更新时间 : 单个商品重复分享时 只更新 不重复生成分享记录
|
| | | @Column(name = "sgr_updatetime")
|
| | | private Date updateTime;
|
| | | |
| | | // 分享时间
|
| | | private Long shareTime;
|
| | |
|
| | |
|
| | | // 分享类型
|
| | | @Expose
|
| | | private String shareType;
|
| | | |
| | | // 商品总数
|
| | | @Expose
|
| | | private int totalGoods;
|
| | | |
| | | // 今日浏览
|
| | | @Expose
|
| | | private int todayBrowse;
|
| | | |
| | | // 累计浏览
|
| | | @Expose
|
| | | private int totalBrowse;
|
| | | |
| | | // 商品总数
|
| | | @Expose
|
| | | private int totalOrder;
|
| | | |
| | | // 预计收益
|
| | | private BigDecimal revenueMoney;
|
| | | |
| | | // 显示收益
|
| | | @Expose
|
| | | private BigDecimal totalMoney;
|
| | |
|
| | |
|
| | | |
| | | public UserShareGoodsRecord(){}
|
| | | |
| | | public UserShareGoodsRecord(Long id){
|
| | | this.id = id;
|
| | | }
|
| | | |
| | | |
| | | public Long getId() {
|
| | | return id;
|
| | | }
|
| | |
|
| | | public void setId(Long id) {
|
| | | this.id = id;
|
| | | }
|
| | |
|
| | | public Long getUid() {
|
| | | return uid;
|
| | | }
|
| | |
|
| | | public void setUid(Long uid) {
|
| | | this.uid = uid;
|
| | | }
|
| | |
|
| | | public ShareSourceTypeEnum getSource() {
|
| | | return source;
|
| | | }
|
| | |
|
| | | public void setSource(ShareSourceTypeEnum source) {
|
| | | this.source = source;
|
| | | }
|
| | |
|
| | | public String getPicture() {
|
| | | return picture;
|
| | | }
|
| | |
|
| | | public void setPicture(String picture) {
|
| | | this.picture = picture;
|
| | | }
|
| | |
|
| | | public Date getCreateTime() {
|
| | | return createTime;
|
| | | }
|
| | |
|
| | | public void setCreateTime(Date createTime) {
|
| | | this.createTime = createTime;
|
| | | }
|
| | |
|
| | | public Date getUpdateTime() {
|
| | | return updateTime;
|
| | | }
|
| | |
|
| | | public void setUpdateTime(Date updateTime) {
|
| | | this.updateTime = updateTime;
|
| | | }
|
| | |
|
| | | public String getShareType() {
|
| | | return shareType;
|
| | | }
|
| | |
|
| | | public void setShareType(String shareType) {
|
| | | this.shareType = shareType;
|
| | | }
|
| | |
|
| | | public int getTotalGoods() {
|
| | | return totalGoods;
|
| | | }
|
| | |
|
| | | public void setTotalGoods(int totalGoods) {
|
| | | this.totalGoods = totalGoods;
|
| | | }
|
| | |
|
| | | public int getTodayBrowse() {
|
| | | return todayBrowse;
|
| | | }
|
| | |
|
| | | public void setTodayBrowse(int todayBrowse) {
|
| | | this.todayBrowse = todayBrowse;
|
| | | }
|
| | |
|
| | | public int getTotalBrowse() {
|
| | | return totalBrowse;
|
| | | }
|
| | |
|
| | | public void setTotalBrowse(int totalBrowse) {
|
| | | this.totalBrowse = totalBrowse;
|
| | | }
|
| | |
|
| | | public int getTotalOrder() {
|
| | | return totalOrder;
|
| | | }
|
| | |
|
| | | public void setTotalOrder(int totalOrder) {
|
| | | this.totalOrder = totalOrder;
|
| | | }
|
| | |
|
| | | public BigDecimal getTotalMoney() {
|
| | | return totalMoney;
|
| | | }
|
| | |
|
| | | public void setTotalMoney(BigDecimal totalMoney) {
|
| | | this.totalMoney = totalMoney;
|
| | | }
|
| | |
|
| | | public Long getShareTime() {
|
| | | return shareTime;
|
| | | }
|
| | |
|
| | | public void setShareTime(Long shareTime) {
|
| | | this.shareTime = shareTime;
|
| | | }
|
| | |
|
| | | public BigDecimal getRevenueMoney() {
|
| | | return revenueMoney;
|
| | | }
|
| | |
|
| | | public void setRevenueMoney(BigDecimal revenueMoney) {
|
| | | this.revenueMoney = revenueMoney;
|
| | | }
|
| | | |
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.exception.share; |
| | | |
| | | public class UserShareGoodsGroupException extends Exception { |
| | | /** |
| | | * |
| | | */ |
| | | private static final long serialVersionUID = 1L; |
| | | private int code; |
| | | private String msg; |
| | | |
| | | public int getCode() { |
| | | return code; |
| | | } |
| | | |
| | | public String getMsg() { |
| | | return msg; |
| | | } |
| | | |
| | | public UserShareGoodsGroupException(int code, String msg) { |
| | | this.code = code; |
| | | this.msg = msg; |
| | | } |
| | | |
| | | public UserShareGoodsGroupException() { |
| | | } |
| | | |
| | | @Override |
| | | public String getMessage() { |
| | | return this.msg; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.yeshi.fanli.exception.share; |
| | | |
| | | public class UserShareGoodsRecordException extends Exception { |
| | | /** |
| | | * |
| | | */ |
| | | private static final long serialVersionUID = 1L; |
| | | private int code; |
| | | private String msg; |
| | | |
| | | public int getCode() { |
| | | return code; |
| | | } |
| | | |
| | | public String getMsg() { |
| | | return msg; |
| | | } |
| | | |
| | | public UserShareGoodsRecordException(int code, String msg) { |
| | | this.code = code; |
| | | this.msg = msg; |
| | | } |
| | | |
| | | public UserShareGoodsRecordException() { |
| | | } |
| | | |
| | | @Override |
| | | public String getMessage() { |
| | | return this.msg; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | |
| | | <mapper namespace="com.yeshi.fanli.dao.mybatis.share.UserShareGoodsGroupMapper"> |
| | | <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup"> |
| | | <id column="gu_id" property="id" jdbcType="BIGINT"/> |
| | | <result column="gu_record_id" property="recordId" jdbcType="BIGINT"/> |
| | | <result column="gu_today_browse" property="todayBrowse" jdbcType="INTEGER"/> |
| | | <result column="gu_total_browse" property="totalBrowse" jdbcType="INTEGER"/> |
| | | <result column="gu_total_order" property="totalOrder" jdbcType="INTEGER"/> |
| | | <result column="gu_total_money" property="totalMoney" jdbcType="DECIMAL"/> |
| | | <result column="gu_browse_time" property="browseTime" jdbcType="TIMESTAMP"/> |
| | | <result column="gu_createtime" property="createTime" jdbcType="TIMESTAMP"/> |
| | | <result column="gu_updatetime" property="updateTime" jdbcType="TIMESTAMP"/> |
| | | <!-- 记录组中的总商品数量 --> |
| | | <result column="totalGoods" property="totalGoods" jdbcType="INTEGER"/> |
| | | |
| | | <association property="commonGoods" column="gu_common_goods_id" |
| | | resultMap="com.yeshi.fanli.dao.mybatis.goods.CommonGoodsMapper.BaseResultMap" /> |
| | | |
| | | </resultMap> |
| | | <sql id="Base_Column_List">gu_id,gu_record_id,gu_common_goods_id,gu_today_browse,gu_total_browse,gu_total_order,gu_total_money,gu_browse_time,gu_createtime,gu_updatetime</sql> |
| | | <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select |
| | | <include refid="Base_Column_List"/>from yeshi_ec_share_goods_group where gu_id = #{id,jdbcType=BIGINT} |
| | | </select> |
| | | <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_share_goods_group where gu_id = #{id,jdbcType=BIGINT}</delete> |
| | | <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_share_goods_group (gu_id,gu_record_id,gu_common_goods_id,gu_today_browse,gu_total_browse,gu_total_order,gu_total_money,gu_browse_time,gu_createtime,gu_updatetime) values (#{id,jdbcType=BIGINT},#{recordId,jdbcType=BIGINT},#{commonGoods.id,jdbcType=BIGINT},#{todayBrowse,jdbcType=INTEGER},#{totalBrowse,jdbcType=INTEGER},#{totalOrder,jdbcType=INTEGER},#{totalMoney,jdbcType=DECIMAL},#{browseTime,jdbcType=TIMESTAMP},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert> |
| | | <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_share_goods_group |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">gu_id,</if> |
| | | <if test="recordId != null">gu_record_id,</if> |
| | | <if test="commonGoods != null">gu_common_goods_id,</if> |
| | | <if test="todayBrowse != null">gu_today_browse,</if> |
| | | <if test="totalBrowse != null">gu_total_browse,</if> |
| | | <if test="totalOrder != null">gu_total_order,</if> |
| | | <if test="totalMoney != null">gu_total_money,</if> |
| | | <if test="browseTime != null">gu_browse_time,</if> |
| | | <if test="createTime != null">gu_createtime,</if> |
| | | <if test="updateTime != null">gu_updatetime,</if> |
| | | </trim>values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <if test="recordId != null">#{recordId,jdbcType=BIGINT},</if> |
| | | <if test="commonGoods != null">#{commonGoods.id,jdbcType=BIGINT},</if> |
| | | <if test="todayBrowse != null">#{todayBrowse,jdbcType=INTEGER},</if> |
| | | <if test="totalBrowse != null">#{totalBrowse,jdbcType=INTEGER},</if> |
| | | <if test="totalOrder != null">#{totalOrder,jdbcType=INTEGER},</if> |
| | | <if test="totalMoney != null">#{totalMoney,jdbcType=DECIMAL},</if> |
| | | <if test="browseTime != null">#{browseTime,jdbcType=TIMESTAMP},</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.UserShareGoodsGroup">update yeshi_ec_share_goods_group set gu_record_id = #{recordId,jdbcType=BIGINT},gu_common_goods_id = #{commonGoods.id,jdbcType=BIGINT},gu_today_browse = #{todayBrowse,jdbcType=INTEGER},gu_total_browse = #{totalBrowse,jdbcType=INTEGER},gu_total_order = #{totalOrder,jdbcType=INTEGER},gu_total_money = #{totalMoney,jdbcType=DECIMAL},gu_browse_time = #{browseTime,jdbcType=TIMESTAMP},gu_createtime = #{createTime,jdbcType=TIMESTAMP},gu_updatetime = #{updateTime,jdbcType=TIMESTAMP} where gu_id = #{id,jdbcType=BIGINT}</update> |
| | | <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup">update yeshi_ec_share_goods_group |
| | | <set> |
| | | <if test="recordId != null">gu_record_id=#{recordId,jdbcType=BIGINT},</if> |
| | | <if test="commonGoods != null">gu_common_goods_id=#{commonGoods.id,jdbcType=BIGINT},</if> |
| | | <if test="todayBrowse != null">gu_today_browse=#{todayBrowse,jdbcType=INTEGER},</if> |
| | | <if test="totalBrowse != null">gu_total_browse=#{totalBrowse,jdbcType=INTEGER},</if> |
| | | <if test="totalOrder != null">gu_total_order=#{totalOrder,jdbcType=INTEGER},</if> |
| | | <if test="totalMoney != null">gu_total_money=#{totalMoney,jdbcType=DECIMAL},</if> |
| | | <if test="browseTime != null">gu_browse_time=#{browseTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="createTime != null">gu_createtime=#{createTime,jdbcType=TIMESTAMP},</if> |
| | | <if test="updateTime != null">gu_updatetime=#{updateTime,jdbcType=TIMESTAMP},</if> |
| | | </set> where gu_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | |
| | | <insert id="insertBatch" useGeneratedKeys="true" keyProperty="id" parameterType="java.util.List"> |
| | | insert into yeshi_ec_share_goods_group |
| | | (<include refid="Base_Column_List" />) |
| | | values |
| | | |
| | | <foreach collection="list" item="item" separator=","> |
| | | ( |
| | | #{item.id,jdbcType=BIGINT}, |
| | | #{item.recordId,jdbcType=BIGINT}, |
| | | #{item.commonGoods.id,jdbcType=BIGINT}, |
| | | #{item.todayBrowse,jdbcType=INTEGER}, |
| | | #{item.totalBrowse,jdbcType=INTEGER}, |
| | | #{item.totalOrder,jdbcType=INTEGER}, |
| | | #{item.totalMoney,jdbcType=DECIMAL}, |
| | | #{item.browseTime,jdbcType=TIMESTAMP}, |
| | | #{item.createTime,jdbcType=TIMESTAMP}, |
| | | #{item.updateTime,jdbcType=TIMESTAMP} |
| | | ) |
| | | </foreach> |
| | | </insert> |
| | | |
| | | <select id="listByRecordId" resultMap="BaseResultMap"> |
| | | SELECT * FROM yeshi_ec_share_goods_group tg |
| | | LEFT JOIN `yeshi_ec_common_goods` cg ON tg.`gu_common_goods_id` = cg.`cg_id` |
| | | WHERE tg.`gu_record_id` = #{recordId} |
| | | ORDER BY tg.`gu_createtime` |
| | | </select> |
| | | |
| | | <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} |
| | | GROUP BY r.`sgr_id` |
| | | ORDER BY totalGoods LIMIT 1 |
| | | </select> |
| | | |
| | | <select id="getNewestRecord" resultMap="BaseResultMap"> |
| | | 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} |
| | | ORDER BY gu_updatetime desc LIMIT 1 |
| | | </select> |
| | | |
| | | </mapper> |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | |
| | | <mapper namespace="com.yeshi.fanli.dao.mybatis.share.UserShareGoodsRecordMapper"> |
| | | <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord"> |
| | | <id column="sgr_id" property="id" jdbcType="BIGINT"/> |
| | | <result column="sgr_uid" property="uid" jdbcType="BIGINT"/> |
| | | <result column="sgr_source" property="source" |
| | | typeHandler="com.yeshi.fanli.util.mybatishandler.ShareSourceTypeEnumHandler"/> |
| | | <result column="sgr_picture" property="picture" jdbcType="VARCHAR"/> |
| | | <result column="sgr_createtime" property="createTime" jdbcType="TIMESTAMP"/> |
| | | <result column="sgr_updatetime" property="updateTime" jdbcType="TIMESTAMP"/> |
| | | </resultMap> |
| | | |
| | | <resultMap id="CountRecordMap" type="com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord"> |
| | | <id column="sgr_id" property="id" jdbcType="BIGINT"/> |
| | | <result column="totalGoods" property="totalGoods" jdbcType="INTEGER"/> |
| | | <result column="todayBrowse" property="todayBrowse" jdbcType="INTEGER"/> |
| | | <result column="totalBrowse" property="totalBrowse" jdbcType="INTEGER"/> |
| | | <result column="totalOrder" property="totalOrder" jdbcType="INTEGER"/> |
| | | <result column="totalMoney" property="totalMoney" jdbcType="DECIMAL"/> |
| | | <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> |
| | | <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="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="createTime != null">sgr_createtime,</if> |
| | | <if test="updateTime != null">sgr_updatetime,</if> |
| | | </trim>values |
| | | <trim prefix="(" suffix=")" suffixOverrides=","> |
| | | <if test="id != null">#{id,jdbcType=BIGINT},</if> |
| | | <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="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="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="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} |
| | | </update> |
| | | |
| | | <select id="listQueryByUid" resultMap="BaseResultMap"> |
| | | SELECT * FROM yeshi_ec_share_goods_record |
| | | WHERE sgr_uid = #{uid} |
| | | <if test="source != null and source != '' "> |
| | | sgr_source = = #{source} |
| | | </if> |
| | | ORDER BY sgr_updatetime DESC |
| | | LIMIT #{start},#{count} |
| | | </select> |
| | | |
| | | <select id="countQueryByUid" resultType="java.lang.Long"> |
| | | SELECT IFNULL(count(sgr_id),0) FROM yeshi_ec_share_goods_record |
| | | WHERE sgr_uid = #{uid} |
| | | <if test="source != null and source != '' "> |
| | | sgr_source = = #{source} |
| | | </if> |
| | | </select> |
| | | |
| | | <select id="listCountRecord" resultMap="CountRecordMap" parameterType="java.util.List"> |
| | | SELECT g.`gu_record_id`AS sgr_id, COUNT(g.`gu_id`)AS totalGoods, |
| | | IFNULL(SUM(g.`gu_total_browse`),0) AS totalBrowse, |
| | | IFNULL(SUM(g.`gu_total_order`),0)AS totalOrder, |
| | | IFNULL(CASE WHEN g.`gu_total_order` = 0 THEN SUM(g.`gu_total_money`) END, 0) AS revenueMoney , |
| | | IFNULL(SUM(CASE WHEN g.`gu_total_order` > 0 THEN g.`gu_total_money` ELSE 0 END), 0)AS totalMoney |
| | | FROM `yeshi_ec_share_goods_group` g |
| | | WHERE g.`gu_record_id` IN <foreach collection="list" item="item" open="(" close=")" |
| | | separator=",">#{item}</foreach> |
| | | GROUP BY g.`gu_record_id` |
| | | </select> |
| | | |
| | | |
| | | <select id="listCountTodayBrowse" resultMap="CountRecordMap" parameterType="java.util.List"> |
| | | SELECT g.`gu_record_id`,SUM(g.`gu_today_browse`)AS todayBrowse FROM yeshi_ec_share_goods_group g |
| | | WHERE TO_DAYS(g.`gu_browse_time`) = TO_DAYS(NOW()) |
| | | AND g.`gu_record_id` IN <foreach collection="list" item="item" open="(" close=")" |
| | | separator=",">#{item}</foreach> |
| | | GROUP BY g.`gu_record_id` |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | </set> where guc_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | <insert id="insertBatch" useGeneratedKeys="true" keyProperty="id" parameterType="java.util.List"> |
| | | insert into yeshi_ec_user_goods_storage |
| | | (<include refid="Base_Column_List" />) |
| | | values |
| | | |
| | | <foreach collection="list" item="item" separator=","> |
| | | ( |
| | | #{item.id,jdbcType=BIGINT}, |
| | | #{item.commonGoods.id,jdbcType=BIGINT}, |
| | | #{item.uid,jdbcType=BIGINT}, |
| | | #{item.state,jdbcType=INTEGER}, |
| | | #{item.createTime.id,jdbcType=TIMESTAMP}, |
| | | #{item.updateTime,jdbcType=TIMESTAMP} |
| | | ) |
| | | |
| | | </foreach> |
| | | </insert> |
| | | |
| | | <update id="updateBatchSelective" parameterType="java.util.List"> |
| | | update yeshi_ec_user_goods_storage |
| | | <trim prefix="set" suffixOverrides=","> |
| | | <trim prefix="guc_state =case" suffix="end,"> |
| | | <foreach collection="list" item="item" index="index"> |
| | | <if test="item.state !=null"> |
| | | when guc_id=#{item.id} then #{item.state} |
| | | </if> |
| | | </foreach> |
| | | </trim> |
| | | <trim prefix="guc_updatetime =case" suffix="end,"> |
| | | <foreach collection="list" item="item" index="index"> |
| | | <if test="item.updateTime !=null"> |
| | | when guc_id=#{item.id} then #{item.updateTime} |
| | | </if> |
| | | </foreach> |
| | | </trim> |
| | | </trim> |
| | | where guc_id in |
| | | <foreach collection="list" index="index" item="item" separator="," open="(" close=")"> |
| | | #{item.id,jdbcType=BIGINT} |
| | | </foreach> |
| | | </update> |
| | | |
| | | |
| | | |
| | | <select id="listQueryByUid" resultMap="BaseResultMap"> |
| | | SELECT * FROM yeshi_ec_user_goods_storage tg |
| | | LEFT JOIN `yeshi_ec_common_goods` cg ON tg.`guc_common_id` = cg.`cg_id` |
| | |
| | | WHERE g.`guc_uid` = #{uid} AND c.`cg_goods_id`= #{auctionId} |
| | | </select> |
| | | |
| | | <select id="listQueryByIds" resultMap="BaseResultMap" parameterType="java.util.List"> |
| | | SELECT * FROM `yeshi_ec_user_goods_storage` g |
| | | LEFT JOIN `yeshi_ec_common_goods` c ON g.`guc_common_id` = c.`cg_id` |
| | | WHERE g.guc_id IN <foreach collection="list" item="item" open="(" close=")" |
| | | separator=",">#{item}</foreach> |
| | | </select> |
| | | </mapper> |
| | |
| | | package com.yeshi.fanli.service.impl.user;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
| | | 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;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.yeshi.fanli.dao.mybatis.user.UserGoodsStorageMapper;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord.ShareSourceTypeEnum;
|
| | | import com.yeshi.fanli.entity.bus.user.UserGoodsStorage;
|
| | | import com.yeshi.fanli.entity.goods.CommonGoods;
|
| | | 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.exception.user.UserGoodsStorageException;
|
| | | 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.service.inter.user.UserGoodsStorageService;
|
| | | import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService;
|
| | | 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;
|
| | |
| | | private RedisManager redisManager;
|
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | | |
| | | @Resource
|
| | | private CommonGoodsService commonGoodsService;
|
| | |
|
| | | @Resource
|
| | |
| | |
|
| | | @Resource
|
| | | private UserGoodsStorageMapper userGoodsStorageMapper;
|
| | | |
| | | @Resource
|
| | | private UserShareGoodsRecordService userShareGoodsRecordService;
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | | @Override
|
| | | public int deleteByPrimaryKey(Long id) {
|
| | |
| | | }
|
| | | return state;
|
| | | }
|
| | | |
| | | @Override
|
| | | public JSONObject shareGoods(Long uid, List<Long> listStorageID) |
| | | throws UserGoodsStorageException, UserShareGoodsRecordException {
|
| | | |
| | | List<UserGoodsStorage> listStorage = userGoodsStorageMapper.listQueryByIds(listStorageID);
|
| | | if (listStorage == null || listStorage.size() == 0) {
|
| | | throw new UserGoodsStorageException(1, "选品库商品不存在");
|
| | | }
|
| | | |
| | | BigDecimal totalMoney = new BigDecimal(0.00);
|
| | | List<TaoBaoGoodsBrief> listGoodsBrief = new ArrayList<TaoBaoGoodsBrief>();
|
| | | |
| | | for (UserGoodsStorage userGoodsStorage: listStorage) {
|
| | | CommonGoods commonGoods = userGoodsStorage.getCommonGoods();
|
| | | TaoBaoGoodsBrief goodsBrief = TaoBaoUtil.convert(commonGoods);
|
| | | listGoodsBrief.add(goodsBrief);
|
| | | // 已分享
|
| | | 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);
|
| | |
|
| | | // 更新为已分享
|
| | | userGoodsStorageMapper.updateBatchSelective(listStorage);
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("shareImg", loadResult);
|
| | | data.put("revenue", revenue);
|
| | | data.put("notifyDesc", configService.get("goods_share_notify"));
|
| | |
|
| | | return data;
|
| | | |
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.impl.user;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | 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;
|
| | | |
| | | @Resource
|
| | | private UserShareGoodsGroupMapper userShareGoodsGroupMapper;
|
| | |
|
| | | @Override
|
| | | public int insert(UserShareGoodsGroup record) {
|
| | | return userShareGoodsGroupMapper.insert(record);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int insertSelective(UserShareGoodsGroup record) {
|
| | | return userShareGoodsGroupMapper.insertSelective(record);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public UserShareGoodsGroup selectByPrimaryKey(Long id) {
|
| | | return userShareGoodsGroupMapper.selectByPrimaryKey(id);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int updateByPrimaryKeySelective(UserShareGoodsGroup record) {
|
| | | return userShareGoodsGroupMapper.updateByPrimaryKeySelective(record);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int updateByPrimaryKey(UserShareGoodsGroup record) {
|
| | | return userShareGoodsGroupMapper.updateByPrimaryKey(record);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<UserShareGoodsGroup> listByRecordId(Long recordId) {
|
| | | return userShareGoodsGroupMapper.listByRecordId(recordId);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public UserShareGoodsGroup getSingleGoods(Long cid, Long uid) {
|
| | | return userShareGoodsGroupMapper.getSingleGoods(cid, uid);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int insertBatch(List<UserShareGoodsGroup> list) {
|
| | | return userShareGoodsGroupMapper.insertBatch(list);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public UserShareGoodsGroup getNewestRecord(Long uid, Long auctionId) {
|
| | | return userShareGoodsGroupMapper.getNewestRecord(uid, auctionId);
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 更新浏览记录数据
|
| | | * @param uid
|
| | | * @param auctionId
|
| | | */
|
| | | @Override
|
| | | public void updateBrowseRecord (Long uid, Long auctionId, int count) throws UserShareGoodsRecordException{
|
| | | if (uid == null) {
|
| | | throw new UserShareGoodsRecordException(1, "用户ID不能为空");
|
| | | }
|
| | | |
| | | if (auctionId == null) {
|
| | | throw new UserShareGoodsRecordException(1, "商品ID不能为空");
|
| | | }
|
| | | |
| | | UserShareGoodsGroup newestRecord = getNewestRecord(uid, auctionId);
|
| | | |
| | | if (newestRecord != null) {
|
| | | // 注意: 修改记录数据、但不可修改更新设置
|
| | | UserShareGoodsGroup shareGoodsGroup = new UserShareGoodsGroup(newestRecord.getId());
|
| | | |
| | | shareGoodsGroup.setTotalBrowse(newestRecord.getTotalBrowse() + count);
|
| | | |
| | | Date browseTime = newestRecord.getBrowseTime();
|
| | | if (DateUtil.isSameDay(browseTime, new Date())) {
|
| | | shareGoodsGroup.setTodayBrowse(newestRecord.getTodayBrowse() + count);
|
| | | } else {
|
| | | shareGoodsGroup.setTodayBrowse(count);
|
| | | shareGoodsGroup.setBrowseTime(new Date());
|
| | | }
|
| | | |
| | | updateByPrimaryKeySelective(shareGoodsGroup);
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 更新订单记录数据
|
| | | * @param uid
|
| | | * @param auctionId
|
| | | */
|
| | | @Override
|
| | | public void updateOrderRecord (Long uid, TaoBaoGoodsBrief taoBaoGoodsBrief, int count) |
| | | throws UserShareGoodsRecordException{
|
| | | |
| | | if (uid == null) {
|
| | | throw new UserShareGoodsRecordException(1, "用户ID不能为空");
|
| | | }
|
| | | |
| | | if (taoBaoGoodsBrief == null) {
|
| | | throw new UserShareGoodsRecordException(1, "商品不能为空");
|
| | | }
|
| | | |
| | | UserShareGoodsGroup newestRecord = getNewestRecord(uid, taoBaoGoodsBrief.getAuctionId());
|
| | | |
| | | if (newestRecord != null) {
|
| | | // 注意: 修改记录数据、但不可修改更新设置
|
| | | UserShareGoodsGroup shareGoodsGroup = new UserShareGoodsGroup(newestRecord.getId());
|
| | | shareGoodsGroup.setTotalOrder(newestRecord.getTotalOrder() + count);
|
| | | |
| | | // 单个商品预计金额
|
| | | String rateStr = hongBaoManageService.get("hongbao_goods_proportion");
|
| | | BigDecimal money = TaoBaoUtil.getGoodsHongBaoMoney(taoBaoGoodsBrief, new BigDecimal(rateStr));
|
| | | |
| | | // 更新预计收益 |
| | | BigDecimal resultMoney = MoneyBigDecimalUtil.mul(new BigDecimal(shareGoodsGroup.getTotalOrder()), money);
|
| | | shareGoodsGroup.setTotalMoney(resultMoney);
|
| | | |
| | | 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");
|
| | | String fcRate = map.get("hongbao_fc_ratio");
|
| | |
|
| | | 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 hour = diff % nd / nh;
|
| | | if (hour > 1) {
|
| | | try {
|
| | | if (commonGoods.getGoodsType() == CommonGoods.GOODS_TYPE_TB) {
|
| | | goodsBrief = redisManager.getTaoBaoGoodsBrief(commonGoods.getGoodsId());
|
| | | goodsBrief.setState(0);
|
| | | goodsState = 0;
|
| | | }
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | // 已下架
|
| | | goodsState = 1;
|
| | | commonGoods.setState(1);
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | if (goodsBrief == null) {
|
| | | goodsBrief = TaoBaoUtil.convert(commonGoods);
|
| | | } else {
|
| | | CommonGoods upadeteCommonGoods = CommonGoodsFactory.create(goodsBrief);
|
| | | upadeteCommonGoods.setState(goodsState);
|
| | | listUpadteCommonGoods.add(upadeteCommonGoods);
|
| | | }
|
| | |
|
| | | // 改变图片尺寸
|
| | | String pictUrl = commonGoods.getPicture();
|
| | | if (!StringUtil.isNullOrEmpty(pictUrl) && !pictUrl.contains("320x320")) {
|
| | | commonGoods.setPicture(TbImgUtil.getTBSize320Img(pictUrl));
|
| | | }
|
| | |
|
| | | String json = gson
|
| | | .toJson(TaoBaoUtil.getTaoBaoGoodsBriefExtra(goodsBrief, proportion, fcRate, 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;
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.impl.user;
|
| | |
|
| | | import java.io.InputStream;
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.transaction.Transactional;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | | 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.tencentcloud.COSManager;
|
| | |
|
| | | 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.bus.share.UserShareGoodsRecord;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord.ShareSourceTypeEnum;
|
| | | 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.exception.goods.CommonGoodsException;
|
| | | import com.yeshi.fanli.exception.share.UserShareGoodsRecordException;
|
| | | 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.service.inter.user.UserAccountService;
|
| | | import com.yeshi.fanli.service.inter.user.UserShareGoodsGroupService;
|
| | | import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService;
|
| | | import com.yeshi.fanli.util.AESUtil;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.ImageUtil;
|
| | | 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
|
| | | private ConfigService configService;
|
| | | |
| | | @Resource
|
| | | private UserInfoMapper userInfoMapper;
|
| | | |
| | | @Resource
|
| | | private UserAccountService userAccountService;
|
| | | |
| | | @Resource
|
| | | private UserShareGoodsRecordMapper userShareGoodsRecordMapper;
|
| | | |
| | | @Resource
|
| | | private CommonGoodsService commonGoodsService;
|
| | | |
| | | @Resource
|
| | | private UserShareGoodsGroupService userShareGoodsGroupService;
|
| | | |
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | | @Override
|
| | | public int insert(UserShareGoodsRecord record) {
|
| | | return userShareGoodsRecordMapper.insert(record);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int insertSelective(UserShareGoodsRecord record) {
|
| | | return userShareGoodsRecordMapper.insertSelective(record);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public UserShareGoodsRecord selectByPrimaryKey(Long id) {
|
| | | return userShareGoodsRecordMapper.selectByPrimaryKey(id);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int updateByPrimaryKeySelective(UserShareGoodsRecord record) {
|
| | | return userShareGoodsRecordMapper.updateByPrimaryKeySelective(record);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int updateByPrimaryKey(UserShareGoodsRecord record) {
|
| | | return userShareGoodsRecordMapper.updateByPrimaryKey(record);
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | public List<UserShareGoodsRecord> listQueryByUid(long start, int count, Long uid, String source) {
|
| | | return userShareGoodsRecordMapper.listQueryByUid(start, count, uid, source);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countQueryByUid(Long uid, String source) {
|
| | | return userShareGoodsRecordMapper.countQueryByUid(uid, source);
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public List<UserShareGoodsRecord> listCountRecord(List<Long> list) {
|
| | | return userShareGoodsRecordMapper.listCountRecord(list);
|
| | | }
|
| | | |
| | | @Override
|
| | | public List<UserShareGoodsRecord> getMyShareGoodsRecords(long start, int count, Long uid, String source) {
|
| | | |
| | | List<UserShareGoodsRecord> list = listQueryByUid(start, count, uid, source);
|
| | | if (list == null) {
|
| | | list = new ArrayList<UserShareGoodsRecord>();
|
| | | }
|
| | | |
| | | if (list.size() > 0) {
|
| | | List<Long> listId = new ArrayList<Long>();
|
| | | |
| | | for (UserShareGoodsRecord userShareGoodsRecord: list) {
|
| | | userShareGoodsRecord.setShareTime(userShareGoodsRecord.getUpdateTime().getTime());
|
| | | userShareGoodsRecord.setCreateTime(null);
|
| | | userShareGoodsRecord.setUpdateTime(null);
|
| | | listId.add(userShareGoodsRecord.getId());
|
| | | }
|
| | | |
| | | // 今日浏览统计
|
| | | List<UserShareGoodsRecord> listTodayBrowse= userShareGoodsRecordMapper.listCountTodayBrowse(listId);
|
| | | |
| | | // 订单、浏览数量、金额统计
|
| | | List<UserShareGoodsRecord> listCountRecord = listCountRecord(listId);
|
| | | |
| | | if ((listCountRecord != null && listCountRecord.size() > 0)
|
| | | || (listTodayBrowse != null && listTodayBrowse.size() > 0)) {
|
| | | |
| | | for (UserShareGoodsRecord shareRecord: list) {
|
| | | Long id = shareRecord.getId() ;
|
| | | |
| | | if (listTodayBrowse != null && listTodayBrowse.size() > 0){
|
| | | for (UserShareGoodsRecord goodsRecord: listTodayBrowse) {
|
| | | Long recordId = goodsRecord.getId();
|
| | | if (id == recordId || id.equals(recordId)) {
|
| | | shareRecord.setTodayBrowse(goodsRecord.getTodayBrowse());
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | if (listCountRecord != null && listCountRecord.size() > 0) {
|
| | | for (UserShareGoodsRecord goodsRecord: listCountRecord) {
|
| | | Long recordId = goodsRecord.getId();
|
| | | if (id == recordId || id.equals(recordId)) {
|
| | | shareRecord.setTotalBrowse(goodsRecord.getTotalBrowse());
|
| | | shareRecord.setTotalOrder(goodsRecord.getTotalOrder());
|
| | | |
| | | BigDecimal totalMoney = goodsRecord.getTotalMoney();
|
| | | if (totalMoney != null && totalMoney.compareTo(new BigDecimal(0))>0 ) {
|
| | | shareRecord.setTotalMoney(goodsRecord.getTotalMoney());
|
| | | } else {
|
| | | shareRecord.setTotalMoney(goodsRecord.getRevenueMoney());
|
| | | }
|
| | | shareRecord.setRevenueMoney(null);
|
| | | |
| | | |
| | | Integer totalGoods = goodsRecord.getTotalGoods();
|
| | | shareRecord.setTotalGoods(totalGoods);
|
| | | if (totalGoods > 1) {
|
| | | shareRecord.setShareType(UserShareGoodsRecord.SHARETYPE_GROUP);
|
| | | } else {
|
| | | shareRecord.setShareType(UserShareGoodsRecord.SHARETYPE_SINGLE);
|
| | | }
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | return list;
|
| | | }
|
| | | |
| | | /**
|
| | | * 保存分享记录
|
| | | * @param userShareGoodsRecord 分享记录: uid、picture、source 为必输入
|
| | | * @throws UserShareGoodsRecordException
|
| | | */
|
| | | @Override
|
| | | public void save(Long uid, ShareSourceTypeEnum source , TaoBaoGoodsBrief taoBaoGoodsBrief) throws UserShareGoodsRecordException {
|
| | | |
| | | if (taoBaoGoodsBrief == null) {
|
| | | throw new UserShareGoodsRecordException(1, "分享商品不能为空");
|
| | | }
|
| | | |
| | | if (uid == null) {
|
| | | throw new UserShareGoodsRecordException(1, "用户ID不能为空");
|
| | | }
|
| | | |
| | | if (source == null) {
|
| | | throw new UserShareGoodsRecordException(1, "分享来源不能为空");
|
| | | }
|
| | | |
| | | UserShareGoodsRecord userShareGoodsRecord = new UserShareGoodsRecord();
|
| | | userShareGoodsRecord.setUid(uid);
|
| | | userShareGoodsRecord.setSource(source);
|
| | | // 单个商品分享
|
| | | singleGoodsShare(userShareGoodsRecord, taoBaoGoodsBrief);
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 保存分享记录
|
| | | * @param userShareGoodsRecord 分享记录: uid、picture、source 为必输入
|
| | | * @throws UserShareGoodsRecordException
|
| | | */
|
| | | @Override
|
| | | public FileUploadResult save(Long uid, ShareSourceTypeEnum source , List<TaoBaoGoodsBrief> listGoods) throws UserShareGoodsRecordException {
|
| | | |
| | | if (listGoods == null || listGoods.size() <= 1) {
|
| | | throw new UserShareGoodsRecordException(1, "分享商品数量不足");
|
| | | }
|
| | | |
| | | if (uid == null) {
|
| | | throw new UserShareGoodsRecordException(1, "用户ID不能为空");
|
| | | }
|
| | | |
| | | if (source == null) {
|
| | | throw new UserShareGoodsRecordException(1, "分享来源不能为空");
|
| | | }
|
| | | |
| | | UserShareGoodsRecord userShareGoodsRecord = new UserShareGoodsRecord();
|
| | | userShareGoodsRecord.setUid(uid);
|
| | | userShareGoodsRecord.setSource(source);
|
| | | // 取一个商品图片作为主图
|
| | | userShareGoodsRecord.setPicture(listGoods.get(0).getPictUrl());
|
| | | |
| | | Date date = new Date();
|
| | | userShareGoodsRecord.setCreateTime(date);
|
| | | userShareGoodsRecord.setUpdateTime(date);
|
| | | userShareGoodsRecordMapper.insertSelective(userShareGoodsRecord);
|
| | | |
| | | FileUploadResult shareImg = createShareImg(userShareGoodsRecord, listGoods);
|
| | | |
| | | // 多个商品分享
|
| | | multipleGoodsShare(userShareGoodsRecord, listGoods);
|
| | | |
| | | return shareImg;
|
| | | |
| | | }
|
| | | |
| | | /**
|
| | | * 单个商品分享生成记录
|
| | | * @param userShareGoodsRecord
|
| | | * @param taoBaoGoodsBrief
|
| | | */
|
| | | @Transactional
|
| | | public void singleGoodsShare(UserShareGoodsRecord userShareGoodsRecord, TaoBaoGoodsBrief taoBaoGoodsBrief) {
|
| | | |
| | | CommonGoods commonGoods = CommonGoodsFactory.create(taoBaoGoodsBrief);
|
| | | try {
|
| | | CommonGoods resultCommonGoods = commonGoodsService.addOrUpdateCommonGoods(commonGoods);
|
| | | |
| | | if (resultCommonGoods == null) {
|
| | | return;
|
| | | }
|
| | | |
| | | UserShareGoodsGroup shareGoodsGroup = null;
|
| | | |
| | | UserShareGoodsGroup singleGoods = userShareGoodsGroupService.getSingleGoods(resultCommonGoods.getId(),
|
| | | userShareGoodsRecord.getUid());
|
| | | if (singleGoods != null && singleGoods.getTotalGoods() == 1) {
|
| | | // 同一个商品多次分享
|
| | | shareGoodsGroup = singleGoods;
|
| | | } |
| | | |
| | | if (shareGoodsGroup != null) {
|
| | | // 单个商品多次分享
|
| | | userShareGoodsRecord.setPicture(taoBaoGoodsBrief.getPictUrl());
|
| | | userShareGoodsRecord.setId(shareGoodsGroup.getRecordId());
|
| | | userShareGoodsRecord.setUpdateTime(new Date());
|
| | | userShareGoodsRecordMapper.updateByPrimaryKey(userShareGoodsRecord);
|
| | | |
| | | Integer totalOrder = shareGoodsGroup.getTotalOrder();
|
| | | if (totalOrder == null ||totalOrder == 0 || totalOrder.equals(0)) {
|
| | | // 预计金额
|
| | | String rateStr = hongBaoManageService.get("hongbao_goods_proportion");
|
| | | shareGoodsGroup.setUpdateTime(new Date());
|
| | | BigDecimal money = TaoBaoUtil.getGoodsHongBaoMoney(taoBaoGoodsBrief, new BigDecimal(rateStr));
|
| | | shareGoodsGroup.setTotalMoney(money);
|
| | | |
| | | userShareGoodsGroupService.updateByPrimaryKeySelective(shareGoodsGroup);
|
| | | }
|
| | | } else {
|
| | | // 单个商品第一次分享
|
| | | Date date = new Date();
|
| | | userShareGoodsRecord.setPicture(taoBaoGoodsBrief.getPictUrl());
|
| | | userShareGoodsRecord.setCreateTime(date);
|
| | | userShareGoodsRecord.setUpdateTime(date);
|
| | | userShareGoodsRecordMapper.insertSelective(userShareGoodsRecord);
|
| | | |
| | | shareGoodsGroup = new UserShareGoodsGroup();
|
| | | shareGoodsGroup.setTotalOrder(0);
|
| | | shareGoodsGroup.setTotalBrowse(0);
|
| | | shareGoodsGroup.setTodayBrowse(0);
|
| | | shareGoodsGroup.setCreateTime(date);
|
| | | shareGoodsGroup.setUpdateTime(date);
|
| | | shareGoodsGroup.setCommonGoods(resultCommonGoods);
|
| | | shareGoodsGroup.setRecordId(userShareGoodsRecord.getId());
|
| | | |
| | | // 预计金额
|
| | | String rateStr = hongBaoManageService.get("hongbao_goods_proportion");
|
| | | BigDecimal money = TaoBaoUtil.getGoodsHongBaoMoney(taoBaoGoodsBrief, new BigDecimal(rateStr));
|
| | | shareGoodsGroup.setTotalMoney(money);
|
| | | |
| | | userShareGoodsGroupService.insertSelective(shareGoodsGroup);
|
| | | }
|
| | | |
| | | } catch (CommonGoodsException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | |
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 多个商品分享生成记录
|
| | | * @param userShareGoodsRecord
|
| | | * @param listGoods
|
| | | */
|
| | | @Transactional
|
| | | public void multipleGoodsShare(UserShareGoodsRecord userShareGoodsRecord, List<TaoBaoGoodsBrief> listGoods) {
|
| | | |
| | | // 分享记录
|
| | | Date date = new Date();
|
| | | String rateStr = hongBaoManageService.get("hongbao_goods_proportion");
|
| | | |
| | | List<UserShareGoodsGroup> listGroup = new ArrayList<UserShareGoodsGroup>();
|
| | | for (TaoBaoGoodsBrief taoBaoGoodsBrief: listGoods) {
|
| | | CommonGoods commonGoods = CommonGoodsFactory.create(taoBaoGoodsBrief);
|
| | | try {
|
| | | CommonGoods resultCommonGoods = commonGoodsService.addOrUpdateCommonGoods(commonGoods);
|
| | | UserShareGoodsGroup shareGoodsGroup = new UserShareGoodsGroup();
|
| | | shareGoodsGroup.setTotalOrder(0);
|
| | | shareGoodsGroup.setTotalBrowse(0);
|
| | | shareGoodsGroup.setTodayBrowse(0);
|
| | | shareGoodsGroup.setCreateTime(date);
|
| | | shareGoodsGroup.setUpdateTime(date);
|
| | | shareGoodsGroup.setCommonGoods(resultCommonGoods);
|
| | | shareGoodsGroup.setRecordId(userShareGoodsRecord.getId());
|
| | | |
| | | // 预计金额
|
| | | BigDecimal money = TaoBaoUtil.getGoodsHongBaoMoney(taoBaoGoodsBrief, new BigDecimal(rateStr));
|
| | | shareGoodsGroup.setTotalMoney(money);
|
| | | |
| | | listGroup.add(shareGoodsGroup);
|
| | | |
| | | } catch (CommonGoodsException e) {
|
| | | e.printStackTrace();
|
| | | continue;
|
| | | }
|
| | | }
|
| | | |
| | | if (listGroup.size() > 0) {
|
| | | userShareGoodsGroupService.insertBatch(listGroup);
|
| | | }
|
| | | |
| | | }
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /**
|
| | | * 生成分享图
|
| | | * @param uid 用户id
|
| | | * @param shareId 分享记录id
|
| | | * @param source 来源
|
| | | * @param listGoods
|
| | | * @return
|
| | | * @throws UserShareGoodsRecordException
|
| | | */
|
| | | public FileUploadResult createShareImg (UserShareGoodsRecord shareRecord, List<TaoBaoGoodsBrief> listGoods) |
| | | throws UserShareGoodsRecordException{
|
| | | |
| | | Long uid = shareRecord.getUid();
|
| | | 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(),
|
| | | AESUtil.encrypt(uid + "", Constant.UIDAESKEY), shareRecord.getId() + "", source +"");
|
| | | |
| | | 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);
|
| | | if (user == null) {
|
| | | throw new UserShareGoodsRecordException(1, "用户信息不存在");
|
| | | }
|
| | | |
| | | InputStream portrait = null;
|
| | | |
| | | if (!StringUtil.isNullOrEmpty(user.getPortrait())) {
|
| | | try {
|
| | | portrait = HttpUtil.downLoadImg(user.getPortrait());
|
| | | } catch (HttpException e) {
|
| | | String portraitUrl = userAccountService.repairPortrait(uid);
|
| | | if (StringUtil.isNullOrEmpty(portraitUrl))
|
| | | throw new UserShareGoodsRecordException(1, "获取头像出错");
|
| | | else {
|
| | | // 再次获取头像
|
| | | try {
|
| | | portrait = HttpUtil.downLoadImg(portraitUrl);
|
| | | } catch (HttpException e1) {
|
| | | throw new UserShareGoodsRecordException(1, "获取头像出错");
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | InputStream inputStream = ImageUtil.drawGoodsShareBigImg(erCodeInputStream, portrait, listGoods);
|
| | | |
| | | FileUploadResult shareImg = COSManager.getInstance().uploadInputStream(inputStream,
|
| | | "sharegoods/share_" + uid + "_" + shareId + "_" + System.currentTimeMillis() + ".png");
|
| | | |
| | | return shareImg;
|
| | | }
|
| | | |
| | | }
|
| | |
| | | import java.util.Set;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | import org.apache.ibatis.annotations.Param;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.user.UserGoodsStorage;
|
| | | import com.yeshi.fanli.exception.share.UserShareGoodsRecordException;
|
| | | import com.yeshi.fanli.exception.user.UserGoodsStorageException;
|
| | |
|
| | | public interface UserGoodsStorageService {
|
| | |
| | | */
|
| | | public boolean isExistStorage(Long uid, Long auctionId);
|
| | |
|
| | | /**
|
| | | * 选品库分享商品
|
| | | * @param uid
|
| | | * @param listStorageID
|
| | | * @throws UserGoodsStorageException
|
| | | * @throws UserShareGoodsRecordException
|
| | | */
|
| | | public JSONObject shareGoods(Long uid, List<Long> listStorageID) throws UserGoodsStorageException, UserShareGoodsRecordException;
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.inter.user;
|
| | |
|
| | | 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 interface UserShareGoodsGroupService {
|
| | |
|
| | | public int insert(UserShareGoodsGroup record);
|
| | |
|
| | | public int insertSelective(UserShareGoodsGroup record);
|
| | |
|
| | | public int updateByPrimaryKeySelective(UserShareGoodsGroup record);
|
| | |
|
| | | public int updateByPrimaryKey(UserShareGoodsGroup record);
|
| | | |
| | | public UserShareGoodsGroup selectByPrimaryKey(Long id);
|
| | | |
| | | /**
|
| | | * 查询分享商品
|
| | | * @param recordId 分享记录id
|
| | | * @return
|
| | | */
|
| | | public List<UserShareGoodsGroup> listByRecordId(Long recordId);
|
| | | |
| | | /**
|
| | | * 查询单个商品 判断是否单个商品分享
|
| | | * @param recordId
|
| | | * @return
|
| | | */
|
| | | public UserShareGoodsGroup getSingleGoods(Long cid, Long uid);
|
| | |
|
| | | /**
|
| | | * 批量插入数据
|
| | | * @param list
|
| | | * @return
|
| | | */
|
| | | public int insertBatch(List<UserShareGoodsGroup> list);
|
| | | |
| | | /**
|
| | | * 查询最新更新的商品
|
| | | * @param cid
|
| | | * @param auctionId
|
| | | * @return
|
| | | */
|
| | | public UserShareGoodsGroup getNewestRecord(Long uid, Long auctionId);
|
| | |
|
| | | /**
|
| | | * 更新浏览数据
|
| | | * @param uid 用户id
|
| | | * @param auctionId 商品id
|
| | | * @param count 数量
|
| | | * @throws UserShareGoodsRecordException
|
| | | */
|
| | | public void updateBrowseRecord(Long uid, Long auctionId, int count) throws UserShareGoodsRecordException;
|
| | |
|
| | |
|
| | | /**
|
| | | * 查询已分享商品
|
| | | * @param recordId
|
| | | * @return
|
| | | * @throws UserShareGoodsRecordException
|
| | | */
|
| | | public JSONObject getGoodsGroup(Long recordId) throws UserShareGoodsRecordException;
|
| | |
|
| | | /**
|
| | | * 更新订单数量及收益
|
| | | * @param uid 用户id |
| | | * @param taoBaoGoodsBrief 商品
|
| | | * @param count 订单数量
|
| | | * @throws UserShareGoodsRecordException
|
| | | */
|
| | | public void updateOrderRecord(Long uid, TaoBaoGoodsBrief taoBaoGoodsBrief, int count) throws UserShareGoodsRecordException;
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.service.inter.user;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | 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;
|
| | | import com.yeshi.fanli.exception.share.UserShareGoodsRecordException;
|
| | |
|
| | | public interface UserShareGoodsRecordService {
|
| | |
|
| | | public int insert(UserShareGoodsRecord record);
|
| | |
|
| | | public int insertSelective(UserShareGoodsRecord record);
|
| | |
|
| | | public int updateByPrimaryKeySelective(UserShareGoodsRecord record);
|
| | |
|
| | | public int updateByPrimaryKey(UserShareGoodsRecord record);
|
| | | |
| | | public UserShareGoodsRecord selectByPrimaryKey(Long id);
|
| | | |
| | | /**
|
| | | * 查询用户对应的选品库
|
| | | * @param start
|
| | | * @param count
|
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public List<UserShareGoodsRecord> listQueryByUid(long start, int count, Long uid, String source);
|
| | | |
| | | public long countQueryByUid(Long uid, String source);
|
| | |
|
| | |
|
| | | /**
|
| | | * 统计记录
|
| | | * @param list
|
| | | * @return
|
| | | */
|
| | | public List<UserShareGoodsRecord> listCountRecord(List<Long> list);
|
| | |
|
| | | |
| | | /**
|
| | | * 获取分享记录
|
| | | * @param start
|
| | | * @param count
|
| | | * @param uid
|
| | | * @param source
|
| | | * @return
|
| | | */
|
| | | public List<UserShareGoodsRecord> getMyShareGoodsRecords(long start, int count, Long uid, String source);
|
| | |
|
| | | /**
|
| | | * 多个商品分享
|
| | | * @param uid 用户id
|
| | | * @param source 来源
|
| | | * @param listGoods 商品集合
|
| | | * @throws UserShareGoodsRecordException
|
| | | */
|
| | | public FileUploadResult save(Long uid, ShareSourceTypeEnum source, List<TaoBaoGoodsBrief> listGoods)
|
| | | throws UserShareGoodsRecordException;
|
| | |
|
| | | /**
|
| | | * 单个商品分享
|
| | | * @param uid 用户id
|
| | | * @param source 来源
|
| | | * @param taoBaoGoodsBrief 商品
|
| | | * @throws UserShareGoodsRecordException
|
| | | */
|
| | | public void save(Long uid, ShareSourceTypeEnum source, TaoBaoGoodsBrief taoBaoGoodsBrief)
|
| | | throws UserShareGoodsRecordException;
|
| | |
|
| | | }
|
| | |
| | |
|
| | | return null;
|
| | | }
|
| | | |
| | | /**
|
| | | * 绘制大的商品动态分享图
|
| | | * |
| | | * @param qrcodeStream
|
| | | * @param portrait
|
| | | * @param goods
|
| | | * @return
|
| | | */
|
| | | public static InputStream drawGoodsShareBigImg(InputStream qrcodeStream, InputStream portrait,
|
| | | List<TaoBaoGoodsBrief> goodsList) {
|
| | |
|
| | | String fontPath = "/usr/share/fonts/PingFang_Medium.ttf";
|
| | |
|
| | | String os = System.getProperty("os.name");
|
| | | if (os.toLowerCase().startsWith("win")) {
|
| | | fontPath = "D:/PingFang_Medium.ttf";
|
| | | }
|
| | |
|
| | | String fontBoldPath = "/usr/share/fonts/PingFang_Heavy_0.ttf";
|
| | | if (os.toLowerCase().startsWith("win")) {
|
| | | fontBoldPath = "D:/PingFang_Heavy_0.ttf";
|
| | | }
|
| | |
|
| | | final BufferedImage targetImg = new BufferedImage(1420, 1334, BufferedImage.TYPE_INT_RGB);
|
| | |
|
| | | HashMap<Key, Object> mapH = new HashMap<Key, Object>();
|
| | | mapH.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);// 抗锯齿 (抗锯齿总开关)
|
| | | mapH.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);// 文字抗锯齿
|
| | |
|
| | | final Graphics2D g2d = (Graphics2D) targetImg.getGraphics();
|
| | |
|
| | | g2d.setRenderingHints(mapH);
|
| | |
|
| | | g2d.setColor(Color.WHITE);
|
| | | g2d.fillRect(0, 0, 1420, 1334);
|
| | | Font font = null;
|
| | | try {
|
| | | font = Font.createFont(Font.PLAIN, new File(fontPath)).deriveFont(30.0f);
|
| | | } catch (FontFormatException e1) {
|
| | | e1.printStackTrace();
|
| | | } catch (IOException e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | |
|
| | | Font boldFont = null;
|
| | | try {
|
| | | boldFont = Font.createFont(Font.PLAIN, new File(fontBoldPath)).deriveFont(50.0f);
|
| | | } catch (FontFormatException e2) {
|
| | | e2.printStackTrace();
|
| | | } catch (IOException e2) {
|
| | | e2.printStackTrace();
|
| | | }
|
| | | g2d.setFont(font);
|
| | | try {
|
| | | g2d.setColor(new Color(153, 153, 153));
|
| | | // 画第一张
|
| | | for (int i = 0; i < goodsList.size(); i++) {
|
| | | TaoBaoGoodsBrief goods = goodsList.get(i);
|
| | | BigDecimal couplePrice = TaoBaoUtil.getAfterUseCouplePrice(goods);
|
| | | // 第一张图需要有价格信息
|
| | | if (i == 0) {
|
| | | int topX = 50;
|
| | | int topY = 50;
|
| | | // 画大图 起始点坐标为(50,50)
|
| | | InputStream goodsPicture = TaoBaoHttpUtil
|
| | | .getAsInputStream(goods.getPictUrl().replace("_.webp", "").replace("_220x220", ""));
|
| | | BufferedImage picImage = ImageIO.read(goodsPicture);
|
| | | picImage = zoomInImage(picImage, 650, 650);
|
| | | g2d.drawImage(picImage, topX, topX, null);
|
| | | g2d.setColor(new Color(224, 224, 224));
|
| | | // 画边框
|
| | | g2d.setStroke(new BasicStroke(1.0f));
|
| | | g2d.drawRect(topX - 1, topY - 1, 651, 651);
|
| | | // 画透明背景
|
| | | g2d.setColor(new Color(255, 255, 255, 210));
|
| | | g2d.fillRect(50, 600, 650, 100);
|
| | | // 画金额
|
| | | g2d.setColor(new Color(240, 0, 102));
|
| | | boldFont = boldFont.deriveFont(22.0f);
|
| | | g2d.setFont(boldFont);
|
| | | g2d.drawString("¥", 70, 650);
|
| | | boldFont = boldFont.deriveFont(42.0f);
|
| | | g2d.setFont(boldFont);
|
| | | g2d.drawString(couplePrice+"", 90, 650);
|
| | |
|
| | | // 画原价
|
| | | g2d.setColor(new Color(102, 102, 102));
|
| | | font = font.deriveFont(24.0f);
|
| | | g2d.setFont(font);
|
| | |
|
| | | String zkPrice = new BigDecimal((couplePrice+"").replace("¥", "")).add(goods.getCouponAmount())
|
| | | .toString();
|
| | | g2d.drawString("¥ " + zkPrice, 70, 650 + 33);
|
| | |
|
| | | FontMetrics fm = g2d.getFontMetrics(font);
|
| | | int textLength = fm.stringWidth(zkPrice);
|
| | | // 画删除线
|
| | | 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);
|
| | |
|
| | | // 画券的内容
|
| | | g2d.setColor(new Color(229, 0, 93));
|
| | |
|
| | | String quanString = " " + MoneyBigDecimalUtil.getWithNoZera(goods.getCouponAmount()) + "元券 ";
|
| | |
|
| | | 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.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);
|
| | |
|
| | | } else {
|
| | | // 计算左上角坐标
|
| | | int topX = 0;
|
| | | int topY = 0;
|
| | | if (i == 1)
|
| | | topX = 50 + (315 + 20) * 0;
|
| | | else if (i == 2 || i % 2 != 0)// 2,3,5,7
|
| | | topX = 50 + (315 + 20) * (i % 2 + 1);
|
| | | else if (i % 2 == 0)// 4,6,8
|
| | | topX = 50 + (315 + 20) * 3;
|
| | |
|
| | | if (i == 1 || i == 2)
|
| | | topY = 50 + 650 + 20;
|
| | | else if (i == 3 || i == 4)
|
| | | topY = 50;
|
| | | else if (i == 5 || i == 6)
|
| | | topY = 50 + (315 + 20) * 1;
|
| | | else if (i == 7 || i == 8)
|
| | | topY = 50 + (315 + 20) * 2;
|
| | |
|
| | | // 画大图
|
| | | InputStream goodsPicture = TaoBaoHttpUtil
|
| | | .getAsInputStream(goods.getPictUrl().replace("_.webp", ""));
|
| | | BufferedImage picImage = ImageIO.read(goodsPicture);
|
| | | picImage = zoomInImage(picImage, 315, 315);
|
| | | g2d.drawImage(picImage, topX, topY, null);
|
| | |
|
| | | g2d.setColor(new Color(224, 224, 224));
|
| | | // 画边框
|
| | | g2d.setStroke(new BasicStroke(1.0f));
|
| | | g2d.drawRect(topX - 1, topY - 1, 316, 316);
|
| | |
|
| | | // 画券
|
| | |
|
| | | // 画券右侧
|
| | | 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));
|
| | |
|
| | | String quanString = " " + MoneyBigDecimalUtil.getWithNoZera(goods.getCouponAmount()) + "元券 ";
|
| | |
|
| | | font = font.deriveFont(24.0f);
|
| | | g2d.setFont(font);
|
| | | FontMetrics fm = g2d.getFontMetrics(font);
|
| | | int textLength = fm.stringWidth(quanString);
|
| | |
|
| | | g2d.fillRect(topX + 315 - quanRight.getWidth() - textLength, topY + 315 - quanRight.getHeight(),
|
| | | textLength, 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);
|
| | | }
|
| | | }
|
| | |
|
| | | g2d.setColor(new Color(247, 247, 247));
|
| | | g2d.fillRect(50, 1070, 1320, 214);
|
| | |
|
| | | // 画二维码
|
| | |
|
| | | BufferedImage qrcodeImage = ImageIO.read(qrcodeStream);
|
| | | qrcodeImage = zoomInImage(qrcodeImage, 170, 170);
|
| | |
|
| | | g2d.drawImage(qrcodeImage, 70, 1092, null);
|
| | |
|
| | | // 画头像
|
| | | if (portrait != null) {
|
| | | BufferedImage portraitImg = ImageIO.read(portrait);
|
| | | portraitImg = zoomInImage(portraitImg, 40, 40);
|
| | | g2d.drawImage(portraitImg, 70 + (qrcodeImage.getWidth() - portraitImg.getWidth()) / 2,
|
| | | 1092 + (qrcodeImage.getHeight() - portraitImg.getHeight()) / 2, null);
|
| | | }
|
| | |
|
| | | font = font.deriveFont(50.0f);
|
| | | g2d.setFont(font);
|
| | | g2d.setColor(new Color(229, 0, 93));
|
| | | // g2d.drawString("返利券提醒您", 312, 1118 + 40);
|
| | |
|
| | | g2d.setColor(new Color(102, 102, 102));
|
| | | g2d.drawString("长按识别二维码领取优惠券", 312, 1118 + 77);
|
| | |
|
| | | g2d.dispose();
|
| | |
|
| | | // OutputStream out = new ByteArrayOutputStream(); new
|
| | | // FileOutputStream(new File(targetPath));
|
| | | // ImageIO.write(targetImg, "JPEG", out);
|
| | | // out.flush();
|
| | | // out.close();
|
| | | ByteArrayOutputStream aos = new ByteArrayOutputStream();
|
| | | ImageIO.write(targetImg, "JPEG", aos);
|
| | | InputStream is = new ByteArrayInputStream(aos.toByteArray());
|
| | | return is;
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | return null;
|
| | | }
|
| | |
|
| | |
|
| | | // 画商品分享图
|
| | | public static InputStream drawGoodsShareImgHCJ(InputStream qrcodeStream, InputStream portrait,
|
New file |
| | |
| | | package com.yeshi.fanli.util.mybatishandler;
|
| | |
|
| | | import java.sql.CallableStatement;
|
| | | import java.sql.PreparedStatement;
|
| | | import java.sql.ResultSet;
|
| | | import java.sql.SQLException;
|
| | |
|
| | | import org.apache.ibatis.type.BaseTypeHandler;
|
| | | import org.apache.ibatis.type.JdbcType;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord.ShareSourceTypeEnum;
|
| | |
|
| | |
|
| | | public class ShareSourceTypeEnumHandler extends BaseTypeHandler<ShareSourceTypeEnum> {
|
| | |
|
| | | @Override
|
| | | public ShareSourceTypeEnum getNullableResult(ResultSet arg0, String arg1) throws SQLException {
|
| | | String key = arg0.getString(arg1);
|
| | | if (arg0.wasNull()) {
|
| | | return null;
|
| | | } else {
|
| | | return ShareSourceTypeEnum.valueOf(key);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public ShareSourceTypeEnum getNullableResult(ResultSet arg0, int arg1) throws SQLException {
|
| | | String key = arg0.getString(arg1);
|
| | | if (arg0.wasNull()) {
|
| | | return null;
|
| | | } else {
|
| | | // 根据数据库中的key值,定位SexEnum子类
|
| | | return ShareSourceTypeEnum.valueOf(key);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public ShareSourceTypeEnum getNullableResult(CallableStatement arg0, int arg1) throws SQLException {
|
| | | String key = arg0.getString(arg1);
|
| | | if (arg0.wasNull()) {
|
| | | return null;
|
| | | } else {
|
| | | // 根据数据库中的key值,定位SexEnum子类
|
| | | return ShareSourceTypeEnum.valueOf(key);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void setNonNullParameter(PreparedStatement arg0, int arg1, ShareSourceTypeEnum arg2, JdbcType arg3)
|
| | | throws SQLException {
|
| | | arg0.setString(arg1, arg2.name());
|
| | | }
|
| | |
|
| | | }
|
| | |
| | |
|
| | | import java.text.ParseException;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.Calendar;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.Map;
|
| | |
|
| | |
|
| | | public class DateUtil {
|
| | |
| | | SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
|
| | |
|
| | | try {
|
| | | long ns = 1000;// 一秒钟的毫秒数
|
| | | long nm = 1000 * 60;// 一分钟的毫秒数
|
| | | long nh = 1000 * 60 * 60;// 一小时的毫秒数
|
| | | long nd = 1000 * 24 * 60 * 60;// 一天的毫秒数
|
| | |
| | | long day = diff / nd;// 计算差多少天
|
| | | long hour = diff % nd / nh;// 计算差多少小时
|
| | | long min = diff % nd % nh / nm;// 计算差多少分钟
|
| | | long sec = diff % nd % nh % nm / ns;// 计算差多少秒
|
| | | |
| | | //System.out.println("时间相差:" + day + "天" + hour + "小时" + min + "分钟" + sec + "秒");
|
| | |
|
| | | datatime = day + "天" + hour + "小时" + min + "分钟" ;
|
| | |
|
| | | } catch (ParseException e) {
|
| | | // TODO Auto-generated catch block
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | |
| | |
|
| | | String datatime = 0 + "天" + 0 + "小时" + 0 + "分钟" ;
|
| | |
|
| | | long ns = 1000;// 一秒钟的毫秒数
|
| | | long nm = 1000 * 60;// 一分钟的毫秒数
|
| | | long nh = 1000 * 60 * 60;// 一小时的毫秒数
|
| | | long nd = 1000 * 24 * 60 * 60;// 一天的毫秒数
|
| | |
| | | return sdf.format(date);
|
| | | }
|
| | |
|
| | | public static void main(String[] args) { |
| | | long a= 1529044851008L;
|
| | | Long l = new Long(a);
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
| | | Date date = new Date(l);
|
| | | System.out.println(sdf.format(date));
|
| | | new DateUtil().dateDiff(new SimpleDateFormat("yyyy-MM-dd hh:mm:ss").format(new Date()), sdf.format(date)); |
| | | } |
| | | /**
|
| | | * 验证是否属于同一天
|
| | | * |
| | | * @param date1
|
| | | * @param date2
|
| | | * @return
|
| | | */
|
| | | public static boolean isSameDay(Date date1, Date date2) {
|
| | | if (date1 != null && date2 != null) {
|
| | | Calendar cal1 = Calendar.getInstance();
|
| | | cal1.setTime(date1);
|
| | | Calendar cal2 = Calendar.getInstance();
|
| | | cal2.setTime(date2);
|
| | | return isSameDay(cal1, cal2);
|
| | | } else {
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 验证是否属于同一天
|
| | | * |
| | | * @param cal1
|
| | | * @param cal2
|
| | | * @return
|
| | | */
|
| | | public static boolean isSameDay(Calendar cal1, Calendar cal2) {
|
| | | if (cal1 != null && cal2 != null) {
|
| | | return cal1.get(0) == cal2.get(0) && cal1.get(1) == cal2.get(1) && cal1.get(6) == cal2.get(6);
|
| | | } else {
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
|
| | | } |