Merge remote-tracking branch 'origin/div' into div
| | |
| | | private UserMoneyExtraService userMoneyExtraService;
|
| | |
|
| | |
|
| | | @RequestMapping(value = "testimg")
|
| | | public void testImg(HttpServletRequest request, PrintWriter out) {
|
| | | long startTime = System.currentTimeMillis();
|
| | |
|
| | | List<String> list = new ArrayList<>();
|
| | | for (int i = 0; i < 10; i++) {
|
| | | list.add("i" + i);
|
| | | }
|
| | |
|
| | | try {
|
| | | final TaoBaoGoodsBrief goods = redisManager.getTaoBaoGoodsBrief(569823237075L);
|
| | | } catch (TaobaoGoodsDownException e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | String url = "http://www.baidu.com";
|
| | | list.parallelStream().forEach(ids -> {
|
| | | InputStream portrait = HttpUtil.getAsInputStream(
|
| | | "https://wwc.alicdn.com/avatar/getAvatar.do?userId=1889722423&width=160&height=160&type=sns");
|
| | | System.out.println(ids + "开始时间:" + System.currentTimeMillis());
|
| | | String uid = "123";
|
| | | String auctionId = "test-" + ids;
|
| | |
|
| | | String destPath = FileUtil.getCacheDir() + "/" + auctionId + ".jpg";
|
| | |
|
| | | String shareImgPath = FileUtil.getCacheDir() + "/share_" + uid + "_" + auctionId + ".png";
|
| | |
|
| | | try {
|
| | | QRCodeUtil.getInstance(500).encode(url, destPath);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | long startDTime = System.currentTimeMillis();
|
| | |
|
| | | /*
|
| | | * try { //ImageUtil.drawGoodsShareImg(new FileInputStream(new
|
| | | * File(destPath)), portrait, goods, shareImgPath); } catch
|
| | | * (FileNotFoundException e) { e.printStackTrace(); }
|
| | | */
|
| | | System.out.println(System.currentTimeMillis() - startDTime);
|
| | |
|
| | | String shareImgUrl = COSManager.getInstance()
|
| | | .uploadFile(new File(shareImgPath), "share_" + uid + "_" + auctionId + ".png").getUrl();
|
| | | System.out.println(ids + "结束时间:" + System.currentTimeMillis());
|
| | | });
|
| | | System.out.println("整体耗时:" + (System.currentTimeMillis() - startTime));
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "kefu")
|
| | | public void kefu(HttpServletRequest request, PrintWriter out) {
|
| | |
| | | import com.yeshi.fanli.entity.bus.activity.ActivityUser;
|
| | | import com.yeshi.fanli.service.inter.activity.ActivityUserService;
|
| | | import com.yeshi.fanli.tag.PageEntity;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | |
| | | String contentType = file.getContentType();
|
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | | // 文件路径
|
| | | String filePath = "/img/GoodsSubClass/" + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | String filePath = FilePathEnum.activityUserPortrait.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | // 执行上传
|
| | | String fileLink = COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
|
| | | return fileLink;
|
| | |
| | | import com.yeshi.fanli.service.inter.order.tb.TaoBaoOrderService;
|
| | | import com.yeshi.fanli.util.CMQManager;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | |
| | | String contentType = file.getContentType();
|
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | | String uploadFilePath = COSManager.getInstance()
|
| | | .uploadFile(inputStream, UUID.randomUUID().toString().replace("-", "") + "." + type).getUrl();
|
| | | .uploadFile(inputStream, FilePathEnum.section.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + type).getUrl();
|
| | | out.print(JsonUtil.loadTrueResult(uploadFilePath));
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | |
| | | String contentType = file.getContentType();
|
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | | String uploadFilePath = COSManager.getInstance()
|
| | | .uploadFile(inputStream, UUID.randomUUID().toString().replace("-", "") + "." + type + ".apk")
|
| | | .uploadFile(inputStream, FilePathEnum.apk.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + type + ".apk")
|
| | | .getUrl();
|
| | | out.print(JsonUtil.loadTrueResult(uploadFilePath));
|
| | | } catch (Exception e) {
|
| | |
| | | String contentType = file.getContentType();
|
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | | String uploadFilePath = COSManager.getInstance()
|
| | | .uploadFile(inputStream, "section/" + date + "/" + timeMillis + "." + type).getUrl();
|
| | | .uploadFile(inputStream, FilePathEnum.section.getPath() + timeMillis + "." + type).getUrl();
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("original", file.getOriginalFilename());
|
| | | data.put("name", file.getOriginalFilename());
|
| | |
| | | String contentType = file.getContentType();
|
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | | // 上传文件相对位置
|
| | | String fileUrl="/img/admin/" + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | String fileUrl=FilePathEnum.section.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | |
|
| | | String uploadPath = COSManager.getInstance().uploadFile(inputStream, fileUrl).getUrl();
|
| | |
|
| | |
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | |
|
| | | // 上传文件相对位置
|
| | | String fileUrl="/apk/admin/" + UUID.randomUUID().toString().replace("-", "") + "." + type + ".apk";
|
| | | String fileUrl= FilePathEnum.apk.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + type + ".apk";
|
| | |
|
| | | String uploadFilePath = COSManager.getInstance().uploadFile(inputStream, fileUrl).getUrl();
|
| | |
|
| | |
| | | import com.yeshi.fanli.service.inter.shop.BanLiShopGoodsClassService;
|
| | | import com.yeshi.fanli.tag.PageEntity;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | |
|
| | | // 文件路径
|
| | | String filePath="/img/shopGoodsClass/"+UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | String filePath=FilePathEnum.banLiShopClass.getPath()+UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | // 执行上传
|
| | | return COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
|
| | | }
|
| | |
| | | import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService;
|
| | | import com.yeshi.fanli.util.AESUtil;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | | import com.yeshi.fanli.util.GsonUtil;
|
| | | import com.yeshi.fanli.util.HongBaoUtil;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | |
| | | form.setPortrait(weiXinUser.getHeadimgurl());
|
| | | String wxHeadImg = COSManager.getInstance()
|
| | | .uploadFile(HttpUtil.getAsInputStream(weiXinUser.getHeadimgurl()),
|
| | | Constant.WXHEADURL + UUID.randomUUID().toString())
|
| | | FilePathEnum.userPortrait.getPath() + UUID.randomUUID().toString())
|
| | | .getUrl();
|
| | | form.setWxPic(wxHeadImg);
|
| | | form.setNickName(weiXinUser.getNickname());
|
| | |
| | | find.setWxUnionId(weiXinUser.getUnionid());
|
| | | String wxHeadImg = COSManager.getInstance()
|
| | | .uploadFile(HttpUtil.getAsInputStream(weiXinUser.getHeadimgurl()),
|
| | | Constant.WXHEADURL + UUID.randomUUID().toString())
|
| | | FilePathEnum.userPortrait.getPath() + UUID.randomUUID().toString())
|
| | | .getUrl();
|
| | | find.setWxPic(wxHeadImg);
|
| | | } else { // 绑定淘宝
|
| | |
| | | if (!StringUtil.isNullOrEmpty(inviteCode)) {// 邀请码不为空
|
| | | inviteCode = inviteCode.trim();
|
| | | if (inviteCode.length() >= 4 && inviteCode.length() <= 12) {
|
| | |
|
| | | if (!userVIPInfoService.isVIP(uid)) {
|
| | | out.print(JsonUtil.loadFalseResult(20, "只有超级会员才能修改"));
|
| | | return;
|
| | | }
|
| | |
|
| | | try {
|
| | | userInfoExtraService.updateInviteCodeVip(inviteCode, uid);
|
| | | out.print(JsonUtil.loadTrueResult("保存成功"));
|
| | |
| | |
|
| | | // 本月未到账,以app端我的页面上月收益为准
|
| | |
|
| | | BigDecimal selfMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, 4, 1);
|
| | | BigDecimal shareMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, 4, 2);
|
| | | BigDecimal inviteMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, 4, 3);
|
| | | BigDecimal selfMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, 4, 1, null);
|
| | | BigDecimal shareMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, 4, 2, null);
|
| | | BigDecimal inviteMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, 4, 3, null);
|
| | |
|
| | |
|
| | | BigDecimal monthUnRecievedMoney = selfMoney.setScale(2, BigDecimal.ROUND_DOWN)
|
| | |
| | | } else if (goodsType != null && goodsType == 0) {
|
| | | goodsType = null; // 所有平台订单
|
| | | }
|
| | |
|
| | | |
| | | List<Integer> listSource = new ArrayList<>();
|
| | | if (goodsType != null) {
|
| | | listSource.add(goodsType);
|
| | | }
|
| | | |
| | | |
| | | try {
|
| | | if (slotTime != null) {
|
| | | SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
|
| | |
| | |
|
| | | // 查询列表
|
| | | List<CommonOrderVO> list = commonOrderService.getOrderByUid(acceptData, page, uid, state, type, orderState,
|
| | | orderNo, startTime, endTime, dateType, goodsType);
|
| | | orderNo, startTime, endTime, dateType, listSource);
|
| | |
|
| | | if (list != null && list.size() > 0) {
|
| | | // 统计总数
|
| | | count = commonOrderService.countGroupOrderNoByUid(uid, state, type, orderState, orderNo, startTime,
|
| | | endTime, dateType, goodsType);
|
| | | endTime, dateType, listSource);
|
| | | }
|
| | |
|
| | | // 需要统计筛选信息 :未失效的总金额 以及订单
|
| | |
| | | * @param key
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "readArticle", method = RequestMethod.POST)
|
| | | public void readArticle(AcceptData acceptData, String id, PrintWriter out) {
|
| | | if(StringUtil.isNullOrEmpty(id)) {
|
| | | out.print(JsonUtil.loadFalseResult("id不能为空"));
|
| | | return;
|
| | | }
|
| | | articleOfficialService.updateReadNum(id);
|
| | | out.print(JsonUtil.loadTrueResult("操作成功"));
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 文章搜索
|
| | | * @param acceptData
|
| | | * @param page
|
| | | * @param key
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "searchArticle", method = RequestMethod.POST)
|
| | | public void searchArticle(AcceptData acceptData, Integer page, String key, PrintWriter out) {
|
| | | getArticleList(acceptData, page, key, true, out);
|
| | |
| | | history.setQuanLink(taobaoLink.getCouponLink());
|
| | | history.setGoodsId(taobaoLink.getGoods().getAuctionId());
|
| | | history.setPostPicture(taobaoLink.getGoods().getPictUrl());
|
| | |
|
| | | history.setShareImg(taobaoLink.getClickUrl());
|
| | | List<String> imgList = taobaoLink.getGoods().getImgList();
|
| | | if (imgList == null) {
|
| | | imgList = new ArrayList<>();
|
| | |
| | | history.setQuanLink(taobaoLink.getCouponLink());
|
| | | history.setGoodsId(finalGoods.getAuctionId());
|
| | | history.setPostPicture(finalGoods.getPictUrl());
|
| | |
|
| | | history.setShareImg(taobaoLink.getClickUrl());
|
| | | List<String> imgList = finalGoods.getImgList();
|
| | | if (imgList == null) {
|
| | | imgList = new ArrayList<>();
|
| | |
| | | history.setQuanLink(null);
|
| | | history.setGoodsId(goodsId);
|
| | | history.setPostPicture(goods.getPicUrl());
|
| | |
|
| | | history.setShareImg(jumpLink);
|
| | | |
| | | List<String> imgList = goods.getImageList();
|
| | | if (imgList == null) {
|
| | | imgList = new ArrayList<>();
|
| | |
| | | history.setQuanLink(null);
|
| | | history.setGoodsId(goodsId);
|
| | | history.setPostPicture(goods.getGoodsImageUrl());
|
| | |
|
| | | history.setShareImg(jumpLink);
|
| | | List<String> imgList = null;
|
| | | String[] goodsGalleryUrls = goods.getGoodsGalleryUrls();
|
| | | if (goodsGalleryUrls != null) {
|
| | |
| | | endTime += " 23:59:59";
|
| | | }
|
| | |
|
| | | List<Integer> listSource = new ArrayList<>();
|
| | | if (goodsType != null) {
|
| | | listSource.add(goodsType);
|
| | | } |
| | | |
| | | try {
|
| | | // 筛选结果顶部统计
|
| | | String validMoney = "0.00";
|
| | | String invalidMoney = "0.00";
|
| | | if (page == 1) {
|
| | | BigDecimal predictMoney = hongBaoV2CountService.getRewardMoneyByToSearch(uid, dateType, orderType, 1,
|
| | | orderNo, state, goodsType, startTime, endTime);
|
| | | orderNo, state, startTime, endTime, listSource);
|
| | | if (predictMoney != null)
|
| | | validMoney = predictMoney.setScale(2, BigDecimal.ROUND_DOWN).toString();
|
| | |
|
| | | BigDecimal postSaleMoney = hongBaoV2CountService.getRewardMoneyByToSearch(uid, dateType, orderType, 2,
|
| | | orderNo, state, goodsType, startTime, endTime);
|
| | | orderNo, state, startTime, endTime, listSource);
|
| | | if (postSaleMoney != null)
|
| | | invalidMoney = postSaleMoney.setScale(2, BigDecimal.ROUND_DOWN).toString();
|
| | |
|
| | |
| | |
|
| | | // 查询列表
|
| | | List<CommonOrderVO> list = commonOrderService.getOrderByUid(acceptData, page, uid, state, orderType, orderState,
|
| | | orderNo, startTime, endTime, dateType, goodsType);
|
| | | orderNo, startTime, endTime, dateType, listSource);
|
| | | // 统计总数
|
| | | long count = commonOrderService.countGroupOrderNoByUid(uid, state, orderType, orderState, orderNo, startTime,
|
| | | endTime, dateType, goodsType);
|
| | | endTime, dateType, listSource);
|
| | |
|
| | | // 判断是否需要显示订单找回提示 8秒内请求3次触发
|
| | | String orderFindUrl = null;
|
| | |
| | | try {
|
| | | long count = 0;
|
| | | List<CommonOrderVO> list = null;
|
| | | List<ESOrder> listES = esOrderService.query(key, uid.toString());
|
| | | List<ESOrder> listES = esOrderService.query(key, uid.toString(), null);
|
| | |
|
| | | if (listES.size() != 0) {
|
| | | list = commonOrderService.searchOrderByUid(page, Constant.PAGE_SIZE, uid, listES);
|
| | |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * 用户id
|
| | | * type 类型:0全部、1淘宝 2京东、拼多多
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getOrderCount", method = RequestMethod.POST)
|
| | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("userInfo", userInfo);
|
| | |
|
| | | List<Integer> listSource = new ArrayList<>();
|
| | | if (type == null || type == 0) {
|
| | | OrderCountVO total = commonOrderService.getOrderCount(uid, null, type);
|
| | | OrderCountVO total = commonOrderService.getOrderCount(uid, null, null);
|
| | | data.put("total", total.getSelf() + total.getShared() + total.getInvite());
|
| | | data.put("self", total.getSelf());
|
| | | data.put("shared", total.getShared());
|
| | |
| | | data.put("self", 0);
|
| | | data.put("shared", 0);
|
| | | data.put("invite", 0);
|
| | | |
| | | listSource.add(type);
|
| | | }
|
| | |
|
| | | // 今天
|
| | | OrderCountVO today = commonOrderService.getOrderCount(uid, 1, type);
|
| | | OrderCountVO today = commonOrderService.getOrderCount(uid, 1, listSource);
|
| | | today.setTotal(today.getSelf() + today.getShared() + today.getInvite());
|
| | | // 昨天
|
| | | OrderCountVO yesterday = commonOrderService.getOrderCount(uid, 2, type);
|
| | | OrderCountVO yesterday = commonOrderService.getOrderCount(uid, 2, listSource);
|
| | | yesterday.setTotal(yesterday.getSelf() + yesterday.getShared() + yesterday.getInvite());
|
| | | // 本月
|
| | | OrderCountVO thisMonth = commonOrderService.getOrderCount(uid, 3, type);
|
| | | OrderCountVO thisMonth = commonOrderService.getOrderCount(uid, 3, listSource);
|
| | | thisMonth.setTotal(thisMonth.getSelf() + thisMonth.getShared() + thisMonth.getInvite());
|
| | | // 上月
|
| | | OrderCountVO lastMonth = commonOrderService.getOrderCount(uid, 4, type);
|
| | | OrderCountVO lastMonth = commonOrderService.getOrderCount(uid, 4, listSource);
|
| | | lastMonth.setTotal(lastMonth.getSelf() + lastMonth.getShared() + lastMonth.getInvite());
|
| | |
|
| | | data.put("today", today);
|
| | |
| | | show = hongBaoV2CountService.getHongBaoCount(uid, null) > 0;
|
| | | }
|
| | |
|
| | | BigDecimal selfMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, dateType, 1);
|
| | | BigDecimal shareMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, dateType, 2);
|
| | | BigDecimal inviteMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, dateType, 3);
|
| | | BigDecimal selfMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, dateType, 1, null);
|
| | | BigDecimal shareMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, dateType, 2, null);
|
| | | BigDecimal inviteMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, dateType, 3, null);
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("show", show);
|
New file |
| | |
| | | package com.yeshi.fanli.controller.wxmp.v1;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.lang.reflect.Type;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Arrays;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | 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 com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.google.gson.JsonElement;
|
| | | import com.google.gson.JsonPrimitive;
|
| | | import com.google.gson.JsonSerializationContext;
|
| | | import com.google.gson.JsonSerializer;
|
| | | import com.yeshi.fanli.dto.ConfigParamsDTO;
|
| | | import com.yeshi.fanli.dto.WXMPAcceptData;
|
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
|
| | | import com.yeshi.fanli.entity.goods.CollectionGoodsV2;
|
| | | import com.yeshi.fanli.entity.goods.CommonGoods;
|
| | | import com.yeshi.fanli.entity.goods.ScanHistoryV2;
|
| | | import com.yeshi.fanli.entity.jd.JDGoods;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.exception.goods.CollectionGoodsException;
|
| | | import com.yeshi.fanli.exception.taobao.TaoKeApiException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.service.inter.config.BusinessSystemService;
|
| | | import com.yeshi.fanli.service.inter.goods.CollectionGoodsV2Service;
|
| | | import com.yeshi.fanli.service.inter.goods.ScanHistoryV2Service;
|
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.cache.JDGoodsCacheUtil;
|
| | | import com.yeshi.fanli.util.cache.PinDuoDuoCacheUtil;
|
| | | import com.yeshi.fanli.util.cache.TaoBaoGoodsCacheUtil;
|
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
|
| | | import com.yeshi.fanli.util.jd.JDApiUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | | import com.yeshi.fanli.vo.goods.GoodsDetailVO;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | /**
|
| | | * 用户相关商品
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Controller("WXMPConsumerController")
|
| | | @RequestMapping("/wxmp/api/v1/consumer")
|
| | | public class ConsumerController {
|
| | |
|
| | | @Resource
|
| | | private BusinessSystemService businessSystemService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | | @Resource
|
| | | private CollectionGoodsV2Service collectionGoodsV2Service;
|
| | |
|
| | | @Resource
|
| | | private ScanHistoryV2Service scanHistoryV2Service;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoGoodsCacheUtil taoBaoGoodsCacheUtil;
|
| | |
|
| | | @Resource
|
| | | private JDGoodsCacheUtil jdGoodsCacheUtil;
|
| | |
|
| | | @Resource
|
| | | private PinDuoDuoCacheUtil pinDuoDuoCacheUtil;
|
| | |
|
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | |
|
| | | /**
|
| | | * 收藏商品
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param id
|
| | | * @param type
|
| | | * @param goodsType
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping("collectionGoods")
|
| | | public void collectionGoods(WXMPAcceptData acceptData, Long uid, Long goodsId, int type, Integer goodsType,
|
| | | PrintWriter out) {
|
| | | try {
|
| | | if (goodsType == null || goodsType < 2 || goodsType > 3) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "请传递正确参数"));
|
| | | return;
|
| | | }
|
| | | |
| | | if (type != 1) {
|
| | | collectionGoodsV2Service.cancelCollectionByAuctionId(uid, goodsId, goodsType);
|
| | | out.print(JsonUtil.loadTrueResult("取消收藏成功"));
|
| | | return;
|
| | | }
|
| | |
|
| | | CollectionGoodsV2 find = collectionGoodsV2Service.findByUidAndAuctionId(uid, goodsId, goodsType);
|
| | | if (find != null) {
|
| | | out.print(JsonUtil.loadFalseResult(""));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (goodsType == Constant.SOURCE_TYPE_JD) {
|
| | | JDGoods jdGoods = jdGoodsCacheUtil.getGoodsInfo(goodsId);
|
| | | if (jdGoods == null) {
|
| | | jdGoods = JDApiUtil.getGoodsDetail(goodsId);
|
| | | }
|
| | | if (jdGoods == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "商品已下架"));
|
| | | return;
|
| | | }
|
| | | collectionGoodsV2Service.addJDCollection(uid, jdGoods);
|
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) {
|
| | | PDDGoodsDetail pddGoods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId);
|
| | | if (pddGoods == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "商品已下架"));
|
| | | return;
|
| | | }
|
| | | collectionGoodsV2Service.addPDDCollection(uid, pddGoods);
|
| | | } |
| | | out.print(JsonUtil.loadTrueResult("收藏成功"));
|
| | | } catch (CollectionGoodsException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 删除收藏
|
| | | * |
| | | * @param acceptData
|
| | | * @param ids
|
| | | * @param type
|
| | | * @param uid
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping("deleteCollectionGoods")
|
| | | public void deleteCollectionGoods(WXMPAcceptData acceptData, Long uid, String ids, Integer type, PrintWriter out) {
|
| | | if (uid == null || uid <= 0) {
|
| | | out.print(JsonUtil.loadFalseResult("用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (type != null && type == 1) { // 删除全部
|
| | | try {
|
| | | collectionGoodsV2Service.cancelCollectionByUid(uid);
|
| | | } catch (CollectionGoodsException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage()));
|
| | | return;
|
| | | }
|
| | | } else { // 删除部分
|
| | | if (!StringUtil.isNullOrEmpty(ids)) {
|
| | | Arrays.asList(ids.split(",")).parallelStream().forEach(idStr -> {
|
| | | try {
|
| | | collectionGoodsV2Service.deteleBYByUidAndCommonId(uid, Long.parseLong(idStr));
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | });
|
| | | }
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult("删除成功"));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 收藏列表
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param page
|
| | | * @param goodsType
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping("collectionGoodsList")
|
| | | public void collectionGoodsList(WXMPAcceptData acceptData, Long uid, Integer page, Integer goodsType, PrintWriter out) {
|
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult("用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (page < 1) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "page不小于1"));
|
| | | return;
|
| | | }
|
| | |
|
| | | List<CollectionGoodsV2> collectionGoodsList = collectionGoodsV2Service.getCollectionGoodsList(uid, page,
|
| | | Constant.PAGE_SIZE, goodsType);
|
| | |
|
| | | long count = collectionGoodsV2Service.getCollectionGoodsCount(uid, goodsType);
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | List<GoodsDetailVO> list = new ArrayList<GoodsDetailVO>();
|
| | |
|
| | | if (collectionGoodsList != null && collectionGoodsList.size() > 0) {
|
| | | List<Long> listGid = new ArrayList<Long>();
|
| | | for (CollectionGoodsV2 collectionGoodsV2 : collectionGoodsList) {
|
| | | CommonGoods commonGoods = collectionGoodsV2.getCommonGoods();
|
| | | if (commonGoods == null || commonGoods.getGoodsType() != Constant.SOURCE_TYPE_TAOBAO) {
|
| | | continue;
|
| | | }
|
| | | listGid.add(commonGoods.getGoodsId());
|
| | | }
|
| | |
|
| | | // API网络接口验证是否在售
|
| | | List<TaoBaoGoodsBrief> listTaoKeGoods = null;
|
| | | if (listGid.size() > 0) {
|
| | | try {
|
| | | listTaoKeGoods = TaoKeApiUtil.getBatchGoodsInfo(listGid);
|
| | | } catch (TaoKeApiException e) {
|
| | | e.printStackTrace();
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | e.printStackTrace();
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate(acceptData.getPlatform(),
|
| | | acceptData.getVersion());
|
| | | |
| | |
|
| | | for (CollectionGoodsV2 collectionGoodsV2 : collectionGoodsList) {
|
| | | CommonGoods commonGoods = collectionGoodsV2.getCommonGoods();
|
| | | if (commonGoods == null) {
|
| | | continue;
|
| | | }
|
| | |
|
| | | if (listTaoKeGoods != null && listTaoKeGoods.size() > 0
|
| | | && commonGoods.getGoodsType() == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | int state = 1; // 默认停售
|
| | | Long goodsId = commonGoods.getGoodsId();
|
| | | for (TaoBaoGoodsBrief taoKeGoods : listTaoKeGoods) {
|
| | | Long auctionId = taoKeGoods.getAuctionId();
|
| | | if (goodsId == auctionId || goodsId.equals(auctionId)) {
|
| | | state = 0; // 在售
|
| | | break;
|
| | | }
|
| | | }
|
| | | commonGoods.setState(state);
|
| | | }
|
| | |
|
| | | GoodsDetailVO detailVO = GoodsDetailVOFactory.convertCommonGoods(commonGoods, paramsDTO);
|
| | | detailVO.setId(commonGoods.getId());
|
| | | detailVO.setCreatetime(collectionGoodsV2.getCreateTime());
|
| | | list.add(detailVO);
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | GsonBuilder builder = new GsonBuilder().registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
|
| | | @Override
|
| | | public JsonElement serialize(Date value, Type theType, JsonSerializationContext context) {
|
| | | if (value == null) {
|
| | | return new JsonPrimitive("");
|
| | | } else {
|
| | | return new JsonPrimitive(value.getTime() + "");
|
| | | }
|
| | | }
|
| | | });
|
| | |
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(builder).excludeFieldsWithoutExposeAnnotation()
|
| | | .create();
|
| | | data.put("list", gson.toJson(list));
|
| | | data.put("count", count);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 删除足迹
|
| | | * |
| | | * @param acceptData
|
| | | * @param type
|
| | | * @param uid
|
| | | * @param ids
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "deleteScanhistory", method = RequestMethod.POST)
|
| | | public void deleteScanHistory(WXMPAcceptData acceptData, String type, Long uid, String ids, PrintWriter out) {
|
| | | if ("1".equals(type)) {
|
| | | // 全部删除
|
| | | scanHistoryV2Service.deleteByDeviceOrUid(uid, acceptData.getDevice());
|
| | | } else {
|
| | | // 删除部分
|
| | | if (StringUtil.isNullOrEmpty(ids)) {
|
| | | out.print(JsonUtil.loadFalseResult("ids不能为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | | String[] idStr = ids.split(",");
|
| | | for (String id : idStr) {
|
| | | scanHistoryV2Service.deleteByCommonIdAndDeviceOrUid(uid, acceptData.getDevice(), Long.parseLong(id));
|
| | | }
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(""));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取浏览记录
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param page
|
| | | * @param goodsType
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getScanHistory", method = RequestMethod.POST)
|
| | | public void getScanHistory(WXMPAcceptData acceptData, Long uid, int page, Integer goodsType, PrintWriter out) {
|
| | | if (page < 1) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "page不小于1"));
|
| | | return;
|
| | | }
|
| | |
|
| | | List<ScanHistoryV2> list = scanHistoryV2Service.getScanHistoryByDeviceOrUid(uid, acceptData.getDevice(), page,
|
| | | 20, goodsType);
|
| | |
|
| | | GsonBuilder gsonBuilder = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder());
|
| | | gsonBuilder.excludeFieldsWithoutExposeAnnotation();
|
| | | gsonBuilder.registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
|
| | | @Override
|
| | | public JsonElement serialize(Date value, Type theType, JsonSerializationContext context) {
|
| | | if (value == null) {
|
| | | return new JsonPrimitive("");
|
| | | } else {
|
| | | return new JsonPrimitive(value.getTime() + "");
|
| | | }
|
| | | }
|
| | | });
|
| | |
|
| | | long count = scanHistoryV2Service.getCountByDeviceOrUid(uid, acceptData.getDevice(), goodsType);
|
| | |
|
| | | JSONArray array = new JSONArray();
|
| | | if (list != null && list.size() > 0) {
|
| | | Gson gson = gsonBuilder.create();
|
| | | ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate(acceptData.getPlatform(),
|
| | | acceptData.getVersion());
|
| | | for (ScanHistoryV2 sh : list) {
|
| | | CommonGoods commonGoods = sh.getCommonGoods();
|
| | | if (commonGoods == null) {
|
| | | continue;
|
| | | }
|
| | |
|
| | | GoodsDetailVO detailVO = GoodsDetailVOFactory.convertCommonGoods(commonGoods, paramsDTO);
|
| | |
|
| | | detailVO.setId(commonGoods.getId());
|
| | | detailVO.setCreatetime(sh.getCreateTime());
|
| | | array.add(gson.toJson(detailVO));
|
| | | }
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("count", count);
|
| | | data.put("list", array);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | return;
|
| | | }
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.controller.wxmp.v1;
|
| | |
|
| | | import java.io.InputStream;
|
| | | import java.io.PrintWriter;
|
| | | import java.math.BigDecimal;
|
| | | import java.net.URLEncoder;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.json.simple.JSONArray;
|
| | | 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.entity.FileUploadResult;
|
| | | import org.yeshi.utils.wx.WXUtil;
|
| | | import org.yeshi.utils.wx.WXXCXUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.yeshi.fanli.dto.ConfigParamsDTO;
|
| | | import com.yeshi.fanli.dto.WXMPAcceptData;
|
| | | import com.yeshi.fanli.dto.jd.JDCategoryInfo;
|
| | | import com.yeshi.fanli.dto.jd.JDCouponInfo;
|
| | | import com.yeshi.fanli.dto.jd.JDFilter;
|
| | | import com.yeshi.fanli.dto.jd.JDSearchResult;
|
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
|
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsResult;
|
| | | import com.yeshi.fanli.dto.pdd.PDDPromotionUrl;
|
| | | import com.yeshi.fanli.dto.pdd.PDDSearchFilter;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsHistory;
|
| | | import com.yeshi.fanli.entity.bus.user.ShamUser;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.goods.CollectionGoodsV2;
|
| | | import com.yeshi.fanli.entity.jd.JDGoods;
|
| | | import com.yeshi.fanli.entity.jd.JDGoodsClass;
|
| | | import com.yeshi.fanli.exception.share.UserShareGoodsRecordException;
|
| | | import com.yeshi.fanli.exception.user.UserInfoExtraException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.goods.CollectionGoodsV2Service;
|
| | | import com.yeshi.fanli.service.inter.goods.ScanHistoryV2Service;
|
| | | import com.yeshi.fanli.service.inter.goods.ShareGoodsService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService;
|
| | | import com.yeshi.fanli.service.inter.jd.JDGoodsClassService;
|
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.user.QrCodeService;
|
| | | import com.yeshi.fanli.service.inter.user.ShamUserService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService;
|
| | | import com.yeshi.fanli.tag.PageEntity;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.JumpDetailUtil;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.ThreadUtil;
|
| | | import com.yeshi.fanli.util.VersionUtil;
|
| | | import com.yeshi.fanli.util.cache.JDGoodsCacheUtil;
|
| | | import com.yeshi.fanli.util.cache.PinDuoDuoCacheUtil;
|
| | | import com.yeshi.fanli.util.factory.CommonGoodsFactory;
|
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
|
| | | import com.yeshi.fanli.util.jd.JDApiUtil;
|
| | | import com.yeshi.fanli.util.jd.JDUtil;
|
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
|
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoUtil;
|
| | | import com.yeshi.fanli.vo.goods.CouponInfoVO;
|
| | | import com.yeshi.fanli.vo.goods.GoodsDetailExtraVO;
|
| | | import com.yeshi.fanli.vo.goods.GoodsDetailVO;
|
| | | import com.yeshi.fanli.vo.goods.MoneyInfoVO;
|
| | | import com.yeshi.fanli.vo.goods.OtherInfo;
|
| | | import com.yeshi.fanli.vo.goods.RewardCouponVO;
|
| | | import com.yeshi.fanli.vo.goods.ShareVO;
|
| | | import com.yeshi.fanli.vo.goods.ShopInfoVO;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Controller("WXMPGoodsController")
|
| | | @RequestMapping("/wxmp/api/v1/goods")
|
| | | public class GoodsController {
|
| | |
|
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | |
|
| | |
|
| | |
|
| | | @Resource
|
| | | private ShamUserService shamUserService;
|
| | |
|
| | | @Resource
|
| | | private CollectionGoodsV2Service collectionGoodsV2Service;
|
| | |
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | |
|
| | |
|
| | | @Resource
|
| | | private UserInfoExtraService userInfoExtraService;
|
| | |
|
| | |
|
| | | @Resource
|
| | | private ScanHistoryV2Service scanHistoryV2Service;
|
| | |
|
| | | @Resource
|
| | | private UserInfoService userInfoService;
|
| | |
|
| | | @Resource
|
| | | private JDGoodsCacheUtil jdGoodsCacheUtil;
|
| | |
|
| | | @Resource
|
| | | private PinDuoDuoCacheUtil pinDuoDuoCacheUtil;
|
| | |
|
| | | @Resource
|
| | | private JumpDetailV2Service jumpDetailV2Service;
|
| | |
|
| | | @Resource
|
| | | private JDGoodsClassService jdGoodsClassService;
|
| | |
|
| | | @Resource
|
| | | private UserVIPInfoService userVIPInfoService;
|
| | |
|
| | | @Resource
|
| | | private QrCodeService qrCodeService;
|
| | | |
| | | @Resource
|
| | | private ShareGoodsService shareGoodsService;
|
| | | |
| | | @Resource
|
| | | private UserShareGoodsRecordService userShareGoodsRecordService;
|
| | | |
| | | @Resource
|
| | | private SwiperPictureService swiperPictureService;
|
| | | |
| | | /**
|
| | | * 一级分类
|
| | | * |
| | | * @param acceptData
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getTopCategory", method = RequestMethod.POST)
|
| | | public void getTopCategory(WXMPAcceptData acceptData, PrintWriter out) {
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("list", configService.get("jd_wxmp_class"));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 一级分类商品
|
| | | * |
| | | * @param acceptData
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getCategoryRecommend", method = RequestMethod.POST)
|
| | | public void getCategoryRecommend(WXMPAcceptData acceptData, Long cid, Integer page, PrintWriter out) {
|
| | | if (cid == null) {
|
| | | out.print(JsonUtil.loadFalseResult("分类ID为空"));
|
| | | return;
|
| | | }
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | if (page == 1) {
|
| | | // 轮播图
|
| | | String platform = acceptData.getPlatform();
|
| | | int version = Integer.parseInt(acceptData.getVersion());
|
| | | List<SwiperPicture> picList = swiperPictureService.getByBannerCardAndVersion("index_top", platform,
|
| | | version);
|
| | | if (picList == null) {
|
| | | picList = new ArrayList<>();
|
| | | }
|
| | |
|
| | | for (SwiperPicture swiper : picList) {
|
| | | JSONObject params = null;
|
| | | if (StringUtil.isNullOrEmpty(swiper.getParams())) {
|
| | | params = JSONObject.fromObject(swiper.getParams());
|
| | | }
|
| | | swiper.setJumpDetail(JumpDetailUtil.getWXMPJumDetail(swiper.getJumpDetail(), params));
|
| | | swiper.setParams(null);
|
| | | }
|
| | | data.put("bannerList", JsonUtil.getApiCommonGson().toJson(picList));
|
| | | }
|
| | | |
| | | JDFilter filterAPI = new JDFilter();
|
| | | filterAPI.setPageIndex(page);
|
| | | filterAPI.setPageSize(Constant.PAGE_SIZE);
|
| | | filterAPI.setIsCoupon(1); // 有券
|
| | | filterAPI.setIsHot(1); // 爆款
|
| | | filterAPI.setCid1(cid);
|
| | | JDSearchResult result = JDApiUtil.queryByKey(filterAPI);
|
| | | |
| | | long count = 0;
|
| | | JSONArray array = new JSONArray();
|
| | | if (result != null) {
|
| | | PageEntity pageEntity = result.getPageEntity();
|
| | | if (pageEntity != null) {
|
| | | count = pageEntity.getTotalCount();
|
| | | }
|
| | |
|
| | | List<JDGoods> goodsList = result.getGoodsList();
|
| | | if (goodsList != null && goodsList.size() > 0) {
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | | ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate(acceptData.getPlatform(),
|
| | | acceptData.getVersion());
|
| | | for (JDGoods goods : goodsList) {
|
| | | GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertJDGoods(goods, paramsDTO);
|
| | | if (goodsDetailVO.isHasCoupon()) {
|
| | | array.add(gson.toJson(goodsDetailVO));
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | data.put("count", count);
|
| | | data.put("list", array);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | |
| | | |
| | | /**
|
| | | * 获取商品详情
|
| | | * @param acceptData
|
| | | * @param goodsId 商品id
|
| | | * @param uid |
| | | * @param code 邀请码
|
| | | * @param goodsType 商品类型
|
| | | * @param from 页面来源
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getGoodsDetial", method = RequestMethod.POST)
|
| | | public void getGoodsDetial(WXMPAcceptData acceptData, Long goodsId, Integer goodsType, String from, |
| | | Long uid, PrintWriter out) {
|
| | | if (goodsType == null || goodsType < 2 || goodsType > 3) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "请传递正确平台参数"));
|
| | | return;
|
| | | }
|
| | |
|
| | | /*--------- 京东商品 -------*/
|
| | | if (goodsType.intValue() == Constant.SOURCE_TYPE_JD) {
|
| | | getDetialJD(acceptData, goodsId, uid, from, out);
|
| | | return;
|
| | | }
|
| | |
|
| | | /*-------- 拼多多商品 -------*/
|
| | | if (goodsType.intValue() == Constant.SOURCE_TYPE_PDD) {
|
| | | getDetialPDD(acceptData, goodsId, uid, from, out);
|
| | | return;
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 京东商品详情
|
| | | * |
| | | * @param acceptData
|
| | | * @param id
|
| | | * @param uid
|
| | | * @param from
|
| | | * @param out
|
| | | */
|
| | | private void getDetialJD(WXMPAcceptData acceptData, Long id, Long uid, String from, PrintWriter out) {
|
| | | JDGoods jdGoods = JDApiUtil.queryGoodsDetail(id); // 高级接口
|
| | | if (jdGoods == null) {
|
| | | jdGoods = JDUtil.getGoodsDetail(id); // 爬取网页
|
| | | // jdGoods = JDApiUtil.getGoodsDetail(id); // 普通接口
|
| | | }
|
| | |
|
| | | if (jdGoods == null) {
|
| | | out.print(JsonUtil.loadFalseResult(2, "商品不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | List<String> imageList = jdGoods.getImageList();
|
| | | if (imageList == null) {
|
| | | imageList = new ArrayList<String>();
|
| | | imageList.add(jdGoods.getPicUrl());
|
| | | }
|
| | |
|
| | | // 保存缓存
|
| | | jdGoodsCacheUtil.saveGoodsInfo(jdGoods);
|
| | |
|
| | | ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate(acceptData.getPlatform(),
|
| | | acceptData.getVersion());
|
| | | GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertJDGoods(jdGoods, paramsDTO);
|
| | | if (goodsDetail != null && goodsDetail.getMoneyInfo() != null && userVIPInfoService.isVIP(uid)) {
|
| | | goodsDetail.getMoneyInfo().setFanliMoney(goodsDetail.getMoneyInfo().getMaxMoney());
|
| | | goodsDetail.getMoneyInfo()
|
| | | .setShareMoney("¥" + JDUtil.getGoodsFanLiMoney(jdGoods, hongBaoManageService.getVIPShareRate()));
|
| | | }
|
| | |
|
| | | // 附加信息
|
| | | OtherInfo otherInfo = new OtherInfo();
|
| | |
|
| | | // 京东plus返利
|
| | | String maxMoneyPlus = null;
|
| | | JDCategoryInfo categoryInfo = jdGoods.getCategoryInfo();
|
| | | if (categoryInfo != null && categoryInfo.getCid3() != null && jdGoods.getCommissionInfo() != null) {
|
| | | Long cid3 = categoryInfo.getCid3();
|
| | | JDGoodsClass threeClass = jdGoodsClassService.getThreeClassByCid(Integer.parseInt(cid3.toString()));
|
| | | if (threeClass != null && threeClass.getSelfComm() != null
|
| | | && threeClass.getSelfComm().compareTo(new BigDecimal(0)) > 0) {
|
| | | BigDecimal commissionShare = jdGoods.getCommissionInfo().getCommissionShare();
|
| | | // plus比例 小于正常比例
|
| | | if (commissionShare != null && commissionShare.compareTo(threeClass.getSelfComm()) > 0) {
|
| | | jdGoods.setCommissionPlus(threeClass.getSelfComm());
|
| | | // plus返利
|
| | | BigDecimal fanliMoneyPlus = JDUtil.getGoodsFanLiMoneyPlus(jdGoods,
|
| | | hongBaoManageService.getFanLiRate());
|
| | | otherInfo.setFanliMoneyPlus("京东plus返¥" + fanliMoneyPlus);
|
| | | // 使用奖励券最高返
|
| | | if (VersionUtil.greaterThan_2_0_5(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | maxMoneyPlus = "(京东plus返¥"
|
| | | + JDUtil.getGoodsFanLiMoneyPlus(jdGoods,
|
| | | hongBaoManageService.getVIPFanLiRate())
|
| | | + ")";
|
| | | } else
|
| | | maxMoneyPlus = "(京东plus最高返¥"
|
| | | + fanliMoneyPlus.add(MoneyBigDecimalUtil.mul(fanliMoneyPlus, Constant.MAX_REWARD_RATE))
|
| | | + ")";
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | // 奖励券返利
|
| | | RewardCouponVO rewardCoupon = new RewardCouponVO();
|
| | | rewardCoupon.setMaxMoneyPlus(maxMoneyPlus);
|
| | | rewardCoupon.setJumpDetail(jumpDetailV2Service.getByTypeCache("web"));
|
| | | goodsDetail.setOtherInfo(otherInfo);
|
| | |
|
| | | CouponInfoVO couponInfo = goodsDetail.getCouponInfo();
|
| | | if (couponInfo != null) {
|
| | | // 券链接处理
|
| | | String materialId = "https://item.jd.com/" + id + ".html";
|
| | | String url = JDApiUtil.convertLinkWithSubUnionId(materialId, couponInfo.getLink(),
|
| | | JDApiUtil.POSITION_COUPON + "", null);
|
| | | couponInfo.setLink(url);
|
| | | }
|
| | |
|
| | | ShopInfoVO shopInfo = goodsDetail.getShopInfo();
|
| | | if (shopInfo != null) {
|
| | | if (shopInfo.getId() == null || shopInfo.getScoreGoods() == null || shopInfo.getScoreLogistics() == null
|
| | | || shopInfo.getScoreSeller() == null) {
|
| | | goodsDetail.setShopInfo(null);
|
| | | }
|
| | | }
|
| | |
|
| | | GoodsDetailExtraVO extraVO = new GoodsDetailExtraVO();
|
| | | extraVO.setIsNative(false);
|
| | | // IOS是否正在上线
|
| | | if ("ios".equalsIgnoreCase(acceptData.getPlatform())) {
|
| | | String version = acceptData.getVersion();
|
| | | extraVO.setIosOnling(configService.iosOnLining(Integer.parseInt(version)));
|
| | | }
|
| | |
|
| | | Long inOrderCount30Days = jdGoods.getInOrderCount30Days();
|
| | | List<ShamUser> listShareUser = new ArrayList<ShamUser>();
|
| | |
|
| | | // 京东开启分享
|
| | | String open = configService.get("share_jd_open");
|
| | | if ("1".equals(open.trim())) {
|
| | | extraVO.setShareValid(true);
|
| | | MoneyInfoVO moneyInfo = goodsDetail.getMoneyInfo();
|
| | | if (moneyInfo != null) {
|
| | | String shareMoney = moneyInfo.getShareMoney().replaceAll("¥", "");
|
| | | if (Integer.parseInt(inOrderCount30Days.toString()) >= 1000) {
|
| | | listShareUser.addAll(shamUserService.listRandShareUser(10, new BigDecimal(shareMoney), 1, 5));
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | extraVO.setListShareUser(listShareUser);
|
| | |
|
| | | // 领券人列表
|
| | | List<ShamUser> listCouponUser = new ArrayList<ShamUser>();
|
| | | if (goodsDetail.isHasCoupon() && Integer.parseInt(inOrderCount30Days.toString()) >= 1000) {
|
| | | listCouponUser = shamUserService.listRandCouponUser(5, 1, 300);
|
| | | }
|
| | | extraVO.setListCouponUser(listCouponUser);
|
| | |
|
| | | if (uid != null) {
|
| | | // 是否加入收藏
|
| | | CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, id,
|
| | | Constant.SOURCE_TYPE_JD);
|
| | | extraVO.setCollected(collectionGoods != null ? true : false);
|
| | | }
|
| | |
|
| | | // 图文详情
|
| | | extraVO.setDetailUrl("https://in.m.jd.com/product/jieshao/video/" + id + ".html");
|
| | |
|
| | | // 商品链接
|
| | | String h5Url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(),
|
| | | Constant.systemCommonConfig.getShareGoodsPagePathJD(), "", id + "");
|
| | | try {
|
| | | extraVO.setH5Url(HttpUtil.getShortLink(h5Url));
|
| | | } catch (Exception e) {
|
| | | extraVO.setH5Url(h5Url);
|
| | | }
|
| | |
|
| | | String helpLink = null;
|
| | | extraVO.setFanliValid(true);
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(helpLink)) {
|
| | | helpLink = configService.get("no_rebate_help_link");
|
| | | }
|
| | |
|
| | | ShareVO shareInfoVO = new ShareVO();
|
| | | shareInfoVO.setHelpLink(helpLink);
|
| | | extraVO.setShare(shareInfoVO);
|
| | |
|
| | | JSONObject object = new JSONObject();
|
| | | object.put("extra", JsonUtil.getApiCommonGson().toJson(extraVO));
|
| | | object.put("goods", JsonUtil.getApiCommonGson().toJson(goodsDetail));
|
| | | out.print(JsonUtil.loadTrueResult(object.toString()));
|
| | |
|
| | | final JDGoods goods = jdGoods;
|
| | | ThreadUtil.run(new Runnable() {
|
| | | public void run() {
|
| | | // 添加浏览记录
|
| | | try {
|
| | | scanHistoryV2Service.addJDScanHistory(uid, acceptData.getDevice(), goods);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | /**
|
| | | * 拼多多商品详情
|
| | | * |
| | | * @param acceptData
|
| | | * @param id
|
| | | * @param uid
|
| | | * @param from
|
| | | * @param out
|
| | | */
|
| | | private void getDetialPDD(WXMPAcceptData acceptData, Long id, Long uid, String from, PrintWriter out) {
|
| | | PDDGoodsDetail pddGoods = PinDuoDuoApiUtil.getGoodsDetail(id);
|
| | | if (pddGoods == null) {
|
| | | out.print(JsonUtil.loadFalseResult(2, "商品不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate(acceptData.getPlatform(),
|
| | | acceptData.getVersion());
|
| | | GoodsDetailVO goodsDetail = GoodsDetailVOFactory.convertPDDGoods(pddGoods, paramsDTO);
|
| | | if (goodsDetail != null && goodsDetail.getMoneyInfo() != null && userVIPInfoService.isVIP(uid)) {
|
| | | goodsDetail.getMoneyInfo().setFanliMoney(goodsDetail.getMoneyInfo().getMaxMoney());
|
| | | goodsDetail.getMoneyInfo().setShareMoney(
|
| | | "¥" + PinDuoDuoUtil.getGoodsFanLiMoney(pddGoods, hongBaoManageService.getVIPShareRate()));
|
| | | }
|
| | |
|
| | | CouponInfoVO couponInfo = goodsDetail.getCouponInfo();
|
| | | PDDPromotionUrl convertUrl = null;
|
| | | if (couponInfo != null) {
|
| | | convertUrl = PinDuoDuoApiUtil.convert(id, PinDuoDuoApiUtil.PID_COUPON + "", null);
|
| | | if (convertUrl != null)
|
| | | couponInfo.setLink(convertUrl.getUrl());
|
| | | }
|
| | |
|
| | | ShopInfoVO shopInfo = goodsDetail.getShopInfo();
|
| | | if (shopInfo != null) {
|
| | | if (shopInfo.getId() == null || shopInfo.getScoreGoods() == null || shopInfo.getScoreLogistics() == null
|
| | | || shopInfo.getScoreSeller() == null) {
|
| | | goodsDetail.setShopInfo(null);
|
| | | }
|
| | | }
|
| | | |
| | | GoodsDetailExtraVO extraVO = new GoodsDetailExtraVO();
|
| | | extraVO.setDetailUrl("http://apph5.yeshitv.com/apppage/goods_img_pdd.html?id=" + id);
|
| | | |
| | | String salesTip = pddGoods.getSalesTip();
|
| | | if (!StringUtil.isNullOrEmpty(salesTip)) {
|
| | | int indexOf = salesTip.indexOf("+");
|
| | | if (indexOf > 0) {
|
| | | salesTip = salesTip.substring(0, indexOf);
|
| | | }
|
| | |
|
| | | int totalSales = 0;
|
| | | if (salesTip.contains("万")) {
|
| | | salesTip = salesTip.substring(0, salesTip.indexOf("万"));
|
| | | totalSales = (int) (Float.parseFloat(salesTip) * 10000);
|
| | | } else {
|
| | | totalSales = Integer.parseInt(salesTip);
|
| | | }
|
| | |
|
| | | List<ShamUser> listShareUser = new ArrayList<ShamUser>();
|
| | | MoneyInfoVO moneyInfo = goodsDetail.getMoneyInfo();
|
| | | if (moneyInfo != null) {
|
| | | String shareMoney = moneyInfo.getShareMoney().replaceAll("¥", "");
|
| | | if (totalSales >= 50000) {
|
| | | listShareUser = shamUserService.listRandShareUser(10, new BigDecimal(shareMoney), 1, 5);
|
| | | }
|
| | | }
|
| | | extraVO.setListShareUser(listShareUser);
|
| | |
|
| | | // 领券人列表
|
| | | List<ShamUser> listCouponUser = new ArrayList<ShamUser>();
|
| | | if (goodsDetail.isHasCoupon() && totalSales >= 50000) {
|
| | | listCouponUser = shamUserService.listRandCouponUser(5, 1, 300);
|
| | | }
|
| | | extraVO.setListCouponUser(listCouponUser);
|
| | | }
|
| | |
|
| | | if (uid != null) {
|
| | | // 是否加入收藏
|
| | | CollectionGoodsV2 collectionGoods = collectionGoodsV2Service.findByUidAndAuctionId(uid, id,
|
| | | Constant.SOURCE_TYPE_PDD);
|
| | | extraVO.setCollected(collectionGoods != null ? true : false);
|
| | | }
|
| | |
|
| | | // 分享路径
|
| | | String h5Url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(),
|
| | | Constant.systemCommonConfig.getShareGoodsPagePathPDD(), "", id + "");
|
| | | try {
|
| | | extraVO.setH5Url(HttpUtil.getShortLink(h5Url));
|
| | | } catch (Exception e) {
|
| | | extraVO.setH5Url(h5Url);
|
| | | }
|
| | |
|
| | | String helpLink = null;
|
| | | extraVO.setFanliValid(true);
|
| | | extraVO.setShareValid(true);
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(helpLink)) {
|
| | | helpLink = configService.get("no_rebate_help_link");
|
| | | }
|
| | |
|
| | | ShareVO shareInfoVO = new ShareVO();
|
| | | shareInfoVO.setHelpLink(helpLink);
|
| | | extraVO.setShare(shareInfoVO);
|
| | |
|
| | | if (convertUrl != null) {
|
| | | extraVO.setCouponJumpLink(convertUrl.getUrl());
|
| | | extraVO.setNativeCouponJumpLink(PinDuoDuoUtil.getAndroidNativeURI(convertUrl.getUrl()));
|
| | | }
|
| | |
|
| | | JSONObject object = new JSONObject();
|
| | | object.put("extra", JsonUtil.getApiCommonGson().toJson(extraVO));
|
| | | object.put("goods", JsonUtil.getApiCommonGson().toJson(goodsDetail));
|
| | | out.print(JsonUtil.loadTrueResult(object.toString()));
|
| | |
|
| | | ThreadUtil.run(new Runnable() {
|
| | | public void run() {
|
| | | try {
|
| | | scanHistoryV2Service.addPDDScanHistory(uid, acceptData.getDevice(), pddGoods);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | /**
|
| | | * 商品详情推荐(猜你喜欢 + 推荐)
|
| | | * |
| | | * @param acceptData
|
| | | * @param id
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getRecommendGoods", method = RequestMethod.POST)
|
| | | public void getRecommendGoods(WXMPAcceptData acceptData, long id, Integer goodsType, PrintWriter out) {
|
| | | if (goodsType == null || goodsType < 2 || goodsType > 3) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "请传递正确平台参数"));
|
| | | return;
|
| | | }
|
| | |
|
| | | try {
|
| | | // 京东
|
| | | if (goodsType == Constant.SOURCE_TYPE_JD) {
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("listGuess", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>()));
|
| | |
|
| | | List<JDGoods> list = JDUtil.getRecommendGoodsById(id);
|
| | | if (list == null) {
|
| | | list = new ArrayList<JDGoods>();
|
| | | } else if (list.size() > 10) {
|
| | | list = list.subList(0, 10);
|
| | | }
|
| | |
|
| | | ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate(acceptData.getPlatform(),
|
| | | acceptData.getVersion());
|
| | | List<GoodsDetailVO> listDetailVO = new ArrayList<GoodsDetailVO>();
|
| | |
|
| | | for (JDGoods goods : list) {
|
| | | listDetailVO.add(GoodsDetailVOFactory.convertJDGoods(goods, paramsDTO));
|
| | | }
|
| | |
|
| | | // 取偶数个数据
|
| | | if (listDetailVO.size() % 2 != 0) {
|
| | | listDetailVO.remove(listDetailVO.size() - 1);
|
| | | }
|
| | |
|
| | | data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listDetailVO));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | return;
|
| | | }
|
| | |
|
| | | // 拼多多
|
| | | if (goodsType == Constant.SOURCE_TYPE_PDD) {
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("listGuess", JsonUtil.getApiCommonGson().toJson(new ArrayList<GoodsDetailVO>()));
|
| | |
|
| | | List<GoodsDetailVO> listDetailVO = new ArrayList<GoodsDetailVO>();
|
| | |
|
| | | List<Long> goodsIdList = PinDuoDuoUtil.getRecommendGoodsId(id);
|
| | | if (goodsIdList != null && goodsIdList.size() > 0) {
|
| | | PDDSearchFilter pddfilter = new PDDSearchFilter();
|
| | | pddfilter.setPage(1);
|
| | | pddfilter.setPageSize(Constant.PAGE_SIZE);
|
| | | Long[] strings = new Long[goodsIdList.size()];
|
| | | pddfilter.setGoodsIdList(goodsIdList.toArray(strings));
|
| | |
|
| | | PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(pddfilter);
|
| | | if (result != null) {
|
| | | List<PDDGoodsDetail> goodsList = result.getGoodsList();
|
| | | if (goodsList != null && goodsList.size() > 0) {
|
| | |
|
| | | if (goodsList.size() > 10) {
|
| | | goodsList = goodsList.subList(0, 10);
|
| | | }
|
| | |
|
| | | ConfigParamsDTO paramsDTO = hongBaoManageService
|
| | | .getShowComputeRate(acceptData.getPlatform(), acceptData.getVersion());
|
| | | for (PDDGoodsDetail goods : goodsList) {
|
| | | listDetailVO.add(GoodsDetailVOFactory.convertPDDGoods(goods, paramsDTO));
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | // 取偶数个数据
|
| | | if (listDetailVO.size() % 2 != 0) {
|
| | | listDetailVO.remove(listDetailVO.size() - 1);
|
| | | }
|
| | |
|
| | | data.put("listQuality", JsonUtil.getApiCommonGson().toJson(listDetailVO));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | return;
|
| | | }
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("listQuality", new JSONArray());
|
| | | data.put("listGuess", new JSONArray());
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 获取商品详情
|
| | | * @param acceptData
|
| | | * @param goodsId 商品id
|
| | | * @param uid |
| | | * @param code 邀请码
|
| | | * @param goodsType 商品类型
|
| | | * @param from 页面来源
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getBuyLink", method = RequestMethod.POST)
|
| | | public void getBuyLink(WXMPAcceptData acceptData, Long goodsId, Integer goodsType, String from,
|
| | | String couponUrl, Long uid, String inviteCode, PrintWriter out) {
|
| | | if (goodsId == null || goodsType == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "商品信息传递错误"));
|
| | | return;
|
| | | }
|
| | |
|
| | | // 判断是自购 还是根据邀请码
|
| | | boolean share = false;
|
| | | |
| | | String subUnionId = "";
|
| | | if (uid != null) {
|
| | | UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
|
| | | if (user != null && user.getState() != UserInfo.STATE_NORMAL) {
|
| | | out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC));
|
| | | return;
|
| | | }
|
| | | subUnionId = uid.toString();
|
| | | } else if ((uid == null || uid < 1) && !StringUtil.isNullOrEmpty(inviteCode) ) {
|
| | | try {
|
| | | UserInfo user = userInfoExtraService.getUserByInviteCode(inviteCode);
|
| | | if (user != null && user.getState() == UserInfo.STATE_NORMAL) {
|
| | | share = true;
|
| | | subUnionId = user.getId().toString();
|
| | | }
|
| | | } catch (UserInfoExtraException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | } |
| | | |
| | | String jumpLink = null;
|
| | | if (goodsType.intValue() == Constant.SOURCE_TYPE_JD) { // 京东
|
| | | JDGoods goods = jdGoodsCacheUtil.getGoodsInfo(goodsId);
|
| | | if (goods == null) {
|
| | | out.print(JsonUtil.loadFalseResult(2, "商品已下架"));
|
| | | return;
|
| | | }
|
| | | |
| | | String materialId = "https://item.jd.com/" + goodsId + ".html";
|
| | | if (StringUtil.isNullOrEmpty(couponUrl)) {
|
| | | JDCouponInfo couponInfo = JDUtil.getShowCouponInfo(goods.getCouponInfoList(), goods.getPrice());
|
| | | if (couponInfo != null) {
|
| | | couponUrl = couponInfo.getLink();
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | long position = JDApiUtil.POSITION_FANLI;
|
| | | if (share) {
|
| | | position = JDApiUtil.POSITION_SHARE;
|
| | | }
|
| | | String jdLink = JDApiUtil.convertLinkWithSubUnionId(materialId, couponUrl, position + "", subUnionId);
|
| | | try {
|
| | | jumpLink = "/pages/union/proxy/proxy?spreadUrl=" + URLEncoder.encode(jdLink, "UTF-8");
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | } else if (goodsType.intValue() == Constant.SOURCE_TYPE_PDD) { // 拼多多
|
| | | PDDGoodsDetail goods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId);
|
| | | if (goods == null) {
|
| | | out.print(JsonUtil.loadFalseResult(2, "商品已下架"));
|
| | | return;
|
| | | }
|
| | | |
| | | String position = PinDuoDuoApiUtil.PID_FANLI;
|
| | | if (share) {
|
| | | position = PinDuoDuoApiUtil.PID_SHARE;
|
| | | }
|
| | | jumpLink = PinDuoDuoApiUtil.convertWXMP(goodsId, position, subUnionId);
|
| | | } else {
|
| | | out.print(JsonUtil.loadFalseResult(1, "参数传递错误"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(jumpLink)) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "创建购买信息失败"));
|
| | | return;
|
| | | }
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("goodsType", goodsType);
|
| | | data.put("jumpLink", jumpLink);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | | |
| | | |
| | | |
| | | /**
|
| | | * 分享商品海报
|
| | | * @param acceptData
|
| | | * @param goodsId
|
| | | * @param goodsType
|
| | | * @param from
|
| | | * @param type
|
| | | * @param uid
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "sharePoster", method = RequestMethod.POST)
|
| | | public void sharePoster(WXMPAcceptData acceptData, Long goodsId, Integer goodsType, String from, Integer type, |
| | | Long uid, PrintWriter out) {
|
| | | if (uid == null || uid < 1) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | | |
| | | if (goodsId == null || goodsType == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "商品信息传递错误"));
|
| | | return;
|
| | | }
|
| | | |
| | | if (type == null || type < 1 || type > 2) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "分享类型错误"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
|
| | | if (user != null && user.getState() != UserInfo.STATE_NORMAL) {
|
| | | out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC));
|
| | | return;
|
| | | }
|
| | | |
| | | String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
|
| | | if (StringUtil.isNullOrEmpty(inviteCode)) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "邀请码未激活"));
|
| | | return;
|
| | | }
|
| | | |
| | | if (goodsType.intValue() == Constant.SOURCE_TYPE_JD) { // 京东
|
| | | createPosterJD(acceptData, goodsId, goodsType, from, type, user, inviteCode, out);
|
| | | } else if (goodsType.intValue() == Constant.SOURCE_TYPE_PDD) { // 拼多多
|
| | | createPosterPDD(acceptData, goodsId, goodsType, from, type, user, inviteCode, out);
|
| | | } else {
|
| | | out.print(JsonUtil.loadFalseResult(1, "参数传递错误"));
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 创建京东分享海报
|
| | | */
|
| | | private void createPosterJD(WXMPAcceptData acceptData, Long goodsId, Integer goodsType, String from, Integer type, UserInfo user,
|
| | | String inviteCode, PrintWriter out) {
|
| | | JDGoods jdGoods = jdGoodsCacheUtil.getGoodsInfo(goodsId);
|
| | | if (jdGoods == null) {
|
| | | out.print(JsonUtil.loadFalseResult(2, "商品已下架"));
|
| | | return;
|
| | | }
|
| | | ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate(acceptData.getPlatform(),acceptData.getVersion());
|
| | | GoodsDetailVO goods = GoodsDetailVOFactory.convertJDGoods(jdGoods, paramsDTO);
|
| | | |
| | | String scene = goodsType+"#"+goodsId+"#" + inviteCode;
|
| | | FileUploadResult uploadResult = null;
|
| | | if (type == 1) {
|
| | | String erCodeUrl = "https://wxmp.banliapp.com/goods?info="+ scene;
|
| | | uploadResult = qrCodeService.drawGoodsPoster(erCodeUrl, user.getPortrait(), goods);
|
| | | } else {
|
| | | String acessToken = WXUtil.getAcessToken(Constant.WXMP_APP_INFO.getAppId(), Constant.WXMP_APP_INFO.getAppSecret());
|
| | | InputStream xcxCode = WXXCXUtil.getXCXCode(acessToken, "/pages/goods/goods", scene);
|
| | | uploadResult = qrCodeService.drawGoodsPosterXCX(xcxCode, user, goods);
|
| | | }
|
| | | |
| | | try {
|
| | | userShareGoodsRecordService.saveShareRecord(user.getId(), CommonGoodsFactory.create(jdGoods));
|
| | | } catch (UserShareGoodsRecordException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | String posterLink = uploadResult.getUrl();
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("posterLink", posterLink);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | |
| | | com.yeshi.fanli.util.ThreadUtil.run(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | // 异步操作 添加分享记录
|
| | | UserShareGoodsHistory history = new UserShareGoodsHistory();
|
| | | history.setUser(new UserInfo(user.getId()));
|
| | | history.setHongbao(new BigDecimal(goods.getMoneyInfo().getShareMoney().replace("¥", "")));
|
| | | history.setCreateTime(new Date());
|
| | | history.setGoodsType(Constant.SOURCE_TYPE_JD);
|
| | | history.setTkCode(null);
|
| | | history.setLink(null);
|
| | | history.setQuanLink(null);
|
| | | history.setGoodsId(goodsId);
|
| | | history.setPostPicture(goods.getPicUrl());
|
| | | history.setPictures(JsonUtil.getGson().toJson(goods.getImgList()));
|
| | | history.setShareImg(posterLink);
|
| | | shareGoodsService.addShareGoodsHistory(history);
|
| | | }
|
| | | });
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 创建拼多多分享海报
|
| | | */
|
| | | private void createPosterPDD(WXMPAcceptData acceptData, Long goodsId, Integer goodsType, String from, Integer type, UserInfo user,
|
| | | String inviteCode, PrintWriter out) {
|
| | | PDDGoodsDetail pddGoods = pinDuoDuoCacheUtil.getGoodsInfo(goodsId);
|
| | | if (pddGoods == null) {
|
| | | out.print(JsonUtil.loadFalseResult(2, "商品已下架"));
|
| | | return;
|
| | | }
|
| | | ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate(acceptData.getPlatform(), acceptData.getVersion());
|
| | | GoodsDetailVO goods = GoodsDetailVOFactory.convertPDDGoods(pddGoods, paramsDTO);
|
| | | |
| | | String scene = goodsType+"#"+goodsId+"#" + inviteCode;
|
| | | FileUploadResult uploadResult = null;
|
| | | if (type == 1) {
|
| | | String erCodeUrl = "https://wxmp.banliapp.com/goods?info="+ scene;
|
| | | uploadResult = qrCodeService.drawGoodsPoster(erCodeUrl, user.getPortrait(), goods);
|
| | | } else {
|
| | | String acessToken = WXUtil.getAcessToken(Constant.WXMP_APP_INFO.getAppId(), Constant.WXMP_APP_INFO.getAppSecret());
|
| | | InputStream xcxCode = WXXCXUtil.getXCXCode(acessToken, "/pages/goods/goods", scene);
|
| | | uploadResult = qrCodeService.drawGoodsPosterXCX(xcxCode, user, goods);
|
| | | }
|
| | | |
| | | try {
|
| | | userShareGoodsRecordService.saveShareRecord(user.getId(), CommonGoodsFactory.create(pddGoods));
|
| | | } catch (UserShareGoodsRecordException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | String posterLink = uploadResult.getUrl();
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("posterLink", posterLink);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | |
| | | // 异步操作
|
| | | com.yeshi.fanli.util.ThreadUtil.run(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | // 异步操作 添加分享记录
|
| | | UserShareGoodsHistory history = new UserShareGoodsHistory();
|
| | | history.setUser(new UserInfo(user.getId()));
|
| | | history.setHongbao(new BigDecimal(goods.getMoneyInfo().getShareMoney().replace("¥", "")));
|
| | | history.setCreateTime(new Date());
|
| | | history.setGoodsType(Constant.SOURCE_TYPE_PDD);
|
| | | history.setTkCode(null);
|
| | | history.setLink(null);
|
| | | history.setQuanLink(null);
|
| | | history.setGoodsId(goodsId);
|
| | | history.setPostPicture(goods.getPicUrl());
|
| | | history.setPictures(JsonUtil.getGson().toJson(goods.getImgList()));
|
| | | history.setShareImg(posterLink);
|
| | | shareGoodsService.addShareGoodsHistory(history);
|
| | | }
|
| | | });
|
| | | }
|
| | | }
|
| | |
| | | import org.yeshi.utils.DateUtil;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.yeshi.fanli.dto.WXMPAcceptData;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.user.ThreeSale;
|
| | | import com.yeshi.fanli.entity.bus.user.ThreeSaleExtraInfo;
|
| | |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "tailorCode")
|
| | | public void tailorCode(AcceptData acceptData, String callback, Long uid, PrintWriter out) {
|
| | | public void tailorCode(WXMPAcceptData acceptData, String callback, Long uid, PrintWriter out) {
|
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult("用户id缺失"));
|
| | | return;
|
| | |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "countMyTeam", method = RequestMethod.POST)
|
| | | public void countMyTeam(AcceptData acceptData, long uid, PrintWriter out) {
|
| | | public void countMyTeam(WXMPAcceptData acceptData, long uid, PrintWriter out) {
|
| | | try {
|
| | | long firstTeam = threeSaleSerivce.countFirstTeam(uid, 1);
|
| | | long firstTeamTotal = threeSaleSerivce.countFirstTeam(uid, null);
|
| | |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "listMyTeam", method = RequestMethod.POST)
|
| | | public void listMyTeam(AcceptData acceptData, int page, long uid, int type, PrintWriter out) {
|
| | | public void listMyTeam(WXMPAcceptData acceptData, int page, long uid, int type, PrintWriter out) {
|
| | | if (type != 1 && type != 2) {
|
| | | out.print(JsonUtil.loadFalseResult("粉丝类型不正确"));
|
| | | return;
|
| | |
| | | result.put("list", resultArray);
|
| | | return result;
|
| | | }
|
| | | |
| | | /**
|
| | | * 获取用户信息
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getBossInfo", method = RequestMethod.POST)
|
| | | public void getBossInfo(AcceptData acceptData, Long uid, PrintWriter out) {
|
| | | if (uid == null || uid <= 0) {
|
| | | out.print(JsonUtil.loadFalseResult("用户未登录"));
|
| | | return;
|
| | | }
|
| | | JSONObject bossData = getBossInfo(uid, threeSaleSerivce.getMyBoss(uid));
|
| | | out.print(JsonUtil.loadTrueResult(bossData));
|
| | | }
|
| | | |
| | | /**
|
| | | * 上级信息组织
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param threeSale
|
| | | * @return
|
| | | */
|
| | | private JSONObject getBossInfo(long uid, ThreeSale threeSale) {
|
| | | JSONObject bossData = new JSONObject();
|
| | | if (threeSale != null && threeSale.getBoss() != null) {
|
| | | UserInfo boss = threeSale.getBoss();
|
| | | bossData.put("hasBoss", true);
|
| | | bossData.put("inviteId", threeSale.getId());
|
| | | bossData.put("nickName", boss.getNickName());
|
| | | bossData.put("portrait", boss.getPortrait());
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");
|
| | | Long createTime = threeSale.getCreateTime();
|
| | | Date inviteTime = new Date(createTime);
|
| | |
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(boss.getId());
|
| | | if (userInfoExtra != null && !StringUtil.isNullOrEmpty(userInfoExtra.getWeiXin())) {
|
| | | bossData.put("weiXin", userInfoExtra.getWeiXin());
|
| | | bossData.put("weiXinState", 3);
|
| | | bossData.put("weiXinTip", "添加TA的微信,你可向TA学习如何通过板栗快省赚钱。");
|
| | | } else {
|
| | | if (!threeSaleExtraInfoSerivce.isRemindBoss(boss.getId(), uid)) {
|
| | | bossData.put("weiXinState", 1);
|
| | | bossData.put("weiXinTip", "点击提醒TA,系统会发送一封站内信,提醒其添加微信号。");
|
| | | } else {
|
| | | bossData.put("weiXinState", 2);
|
| | | bossData.put("weiXinTip", "系统已发送提醒,邀请人添加微信后你可复制,如对方迟迟不添加,你可联系人工客服寻求帮助");
|
| | | }
|
| | | }
|
| | | bossData.put("inviteTime", "你于 " + sdf.format(inviteTime) + "接受了TA的邀请");
|
| | | } else {
|
| | | bossData.put("hasBoss", false);
|
| | | bossData.put("helpLink", configService.get("invite_code_hlep_link"));
|
| | | bossData.put("weiXinTip", "恭喜你,我们的优质用户;\r\n你并没有邀请人,但你的邀请激活功能是被默认开启的;\r\n你拥有独特的无邀请人激活码。");
|
| | | }
|
| | | return bossData;
|
| | | }
|
| | | }
|
| | |
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.math.BigDecimal;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMethod;
|
| | | import org.yeshi.utils.DateUtil;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.yeshi.fanli.dto.WXMPAcceptData;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.order.ESOrder;
|
| | | import com.yeshi.fanli.exception.order.CommonOrderException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.config.SystemClientParamsService;
|
| | | import com.yeshi.fanli.service.inter.count.HongBaoV2CountService;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.ESOrderService;
|
| | | import com.yeshi.fanli.service.inter.user.UserCustomSettingsService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.account.UserUtil;
|
| | | import com.yeshi.fanli.vo.order.CommonOrderVO;
|
| | | import com.yeshi.fanli.vo.order.OrderCountVO;
|
| | | import com.yeshi.fanli.vo.user.UserInfoExtraVO;
|
| | | import com.yeshi.fanli.vo.user.UserSettingsVO;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
| | |
|
| | | @Resource
|
| | | private HongBaoV2CountService hongBaoV2CountService;
|
| | | |
| | | @Resource
|
| | | private CommonOrderService commonOrderService;
|
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoService userInfoService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoExtraService userInfoExtraService;
|
| | |
|
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | | |
| | | @Resource
|
| | | private ESOrderService esOrderService;
|
| | |
|
| | | /**
|
| | | * 统计奖金
|
| | |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getBonusCount", method = RequestMethod.POST)
|
| | | public void getBonusCount(AcceptData acceptData, Long uid, Integer dateType, PrintWriter out) {
|
| | | public void getBonusCount(WXMPAcceptData acceptData, Long uid, Integer dateType, PrintWriter out) {
|
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | |
| | | } catch (Exception e) {
|
| | | }
|
| | |
|
| | | List<Integer> listSource = new ArrayList<>();
|
| | | listSource.add(Constant.SOURCE_TYPE_JD);
|
| | | listSource.add(Constant.SOURCE_TYPE_PDD);
|
| | | |
| | | // 验证是否显示模块
|
| | | if (settings != null && settings.getNoBonusCount() != null) {
|
| | | if (settings.getNoBonusCount() == 1) {
|
| | |
| | | show = hongBaoV2CountService.getHongBaoCount(uid, null) > 0;
|
| | | }
|
| | |
|
| | | BigDecimal selfMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, dateType, 1);
|
| | | BigDecimal shareMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, dateType, 2);
|
| | | BigDecimal inviteMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, dateType, 3);
|
| | | BigDecimal selfMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, dateType, 1, listSource);
|
| | | BigDecimal shareMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, dateType, 2, listSource);
|
| | | BigDecimal inviteMoney = hongBaoV2CountService.getRewardMoneyToCount(uid, dateType, 3, listSource);
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("show", show);
|
| | |
| | | data.put("inviteMoney", inviteMoney.setScale(2, BigDecimal.ROUND_DOWN).toString());
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | | |
| | | |
| | |
|
| | | |
| | | /**
|
| | | * 订单列表
|
| | | * |
| | | * @param acceptData
|
| | | * @param page
|
| | | * @param uid
|
| | | * @param state
|
| | | * 状态:0全部 1-未到账 2-已到账 3-已失效 4已收货
|
| | | * @param type
|
| | | * 类型:1-返利订单 2-分享订单 3-邀请订单
|
| | | * @param orderState
|
| | | * 1有效订单 2 维权订单 3失效订单
|
| | | * @param orderNo
|
| | | * 订单号
|
| | | * @param startTime
|
| | | * 起始时间
|
| | | * @param endTime
|
| | | * 结束时间
|
| | | * @param slotTime
|
| | | * 时间段:1-最近三天 2-最近七天 3最近半月 4本月 5近三月 6近半年
|
| | | * @param dateType
|
| | | * 1-今日 2-昨天 3-本月 4-上个月 |
|
| | | * @param source |
| | | * 页面来源:welfareCore-福利中心、bonus -奖金统计(我的界面)
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getOrderList", method = RequestMethod.POST)
|
| | | public void getOrderList(AcceptData acceptData, Integer page, Long uid, Integer state, String type, |
| | | Integer orderState, String orderNo, String startTime, String endTime, Integer slotTime, |
| | | Integer dateType, Integer goodsType, String source, PrintWriter out) {
|
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | | |
| | | if (page == null || page < 1)
|
| | | page = 1;
|
| | | |
| | | // 搜索内容、订单号
|
| | | if (!StringUtil.isNullOrEmpty(orderNo)) {
|
| | | searchOrder(orderNo, page, uid, out);
|
| | | return;
|
| | | }
|
| | | |
| | | // 转换状态
|
| | | if (state != null) {
|
| | | if (state == 0) {
|
| | | state = null; // 所有
|
| | | } else if (state == 4) {
|
| | | state = null;
|
| | | orderState = 4; // 已收货
|
| | | } else if (state == 5) {
|
| | | state = null;
|
| | | orderState = 2; // 已维权
|
| | | }
|
| | | }
|
| | | if (state != null && orderState != null && (orderState == 2 || orderState == 3)) {
|
| | | state = null;
|
| | | }
|
| | |
|
| | | // 订单类型
|
| | | Integer orderType = null;
|
| | | if (StringUtil.isNullOrEmpty(type)) {
|
| | | orderType = null;
|
| | | } else if (!"0".equalsIgnoreCase(type)){
|
| | | orderType = Integer.parseInt(type); |
| | | } |
| | |
|
| | | if (goodsType != null && goodsType == 0)
|
| | | goodsType = null;
|
| | | |
| | | // 筛选时间
|
| | | if (slotTime != null) {
|
| | | try {
|
| | | SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
|
| | | switch (slotTime) {
|
| | | case 1: // 最近三天
|
| | | endTime = sd.format(new Date());
|
| | | startTime = DateUtil.reduceDay(2, endTime);
|
| | | break;
|
| | | case 2: // 最近七天
|
| | | endTime = sd.format(new Date());
|
| | | startTime = DateUtil.reduceDay(6, endTime);
|
| | | break;
|
| | | case 3: // 最近15天 (半月)
|
| | | endTime = sd.format(new Date());
|
| | | startTime = DateUtil.reduceDay(14, endTime);
|
| | | break;
|
| | | case 4: // 最近三十天 (本月)
|
| | | dateType = 10;
|
| | | break;
|
| | | case 5: // 最近九十天(近三月)
|
| | | dateType = 11;
|
| | | break;
|
| | | case 6: // 最近一百八十天(近半年)
|
| | | dateType = 12;
|
| | | break;
|
| | | default:
|
| | | break;
|
| | | }
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | if (endTime != null && endTime.trim().length() > 0) {
|
| | | endTime += " 23:59:59";
|
| | | }
|
| | |
|
| | | List<Integer> listSource = new ArrayList<>();
|
| | | if (goodsType != null) {
|
| | | listSource.add(goodsType);
|
| | | } else {
|
| | | listSource.add(Constant.SOURCE_TYPE_JD);
|
| | | listSource.add(Constant.SOURCE_TYPE_PDD);
|
| | | }
|
| | | |
| | | |
| | | |
| | | try {
|
| | | // 筛选结果顶部统计
|
| | | String validMoney = "0.00";
|
| | | String invalidMoney = "0.00";
|
| | | if (page == 1) {
|
| | | BigDecimal predictMoney = hongBaoV2CountService.getRewardMoneyByToSearch(uid, dateType, orderType, 1,
|
| | | orderNo, state, startTime, endTime, listSource);
|
| | | if (predictMoney != null) |
| | | validMoney = predictMoney.setScale(2, BigDecimal.ROUND_DOWN).toString();
|
| | | |
| | | BigDecimal postSaleMoney = hongBaoV2CountService.getRewardMoneyByToSearch(uid, dateType, orderType, 2,
|
| | | orderNo, state, startTime, endTime, listSource);
|
| | | if (postSaleMoney != null) |
| | | invalidMoney = postSaleMoney.setScale(2, BigDecimal.ROUND_DOWN).toString();
|
| | | |
| | | if (orderType != null && dateType != null && dateType == 4) {
|
| | | if (orderType == 1) {
|
| | | dateType = 6; // 返利订单有效
|
| | | } else {
|
| | | dateType = 5; // 新版查询本月到账
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | // 查询列表
|
| | | List<CommonOrderVO> list = commonOrderService.getOrderByUid(acceptData, page, uid, state, orderType, orderState,
|
| | | orderNo, startTime, endTime, dateType, listSource);
|
| | | // 统计总数
|
| | | long count = commonOrderService.countGroupOrderNoByUid(uid, state, orderType, orderState, orderNo, startTime,
|
| | | endTime, dateType, listSource);
|
| | |
|
| | | // 判断是否需要显示订单找回提示 8秒内请求3次触发
|
| | | String orderFindUrl = null;
|
| | | if (state ==null && page == 1) {
|
| | | if (redisManager.frequencyLimit("orderlist-" + acceptData.getDevice(), 8, 4)||count==0L) {
|
| | | orderFindUrl = configService.get("order_find_notify_url");
|
| | | }
|
| | | }
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("count", count);
|
| | | data.put("list", JsonUtil.getApiCommonGson().toJson(list));
|
| | | data.put("helpUrl", configService.get("order_list_help"));
|
| | | data.put("validMoney", "¥ " + validMoney);
|
| | | data.put("invalidMoney", "¥ " + invalidMoney);
|
| | | data.put("findOrderHelpUrl", orderFindUrl);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | } catch (CommonOrderException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "查询失败"));
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 搜索订单
|
| | | * @param key
|
| | | * @param out
|
| | | */
|
| | | private void searchOrder(String key, Integer page, Long uid, PrintWriter out) {
|
| | | try {
|
| | | long count = 0;
|
| | | List<CommonOrderVO> list = null;
|
| | | List<Integer> listSource = new ArrayList<>();
|
| | | listSource.add(Constant.SOURCE_TYPE_JD);
|
| | | listSource.add(Constant.SOURCE_TYPE_PDD);
|
| | | List<ESOrder> listES = esOrderService.query(key, uid.toString(), listSource);
|
| | | |
| | | if (listES.size() != 0) {
|
| | | list = commonOrderService.searchOrderByUid(page, Constant.PAGE_SIZE, uid, listES);
|
| | | count = commonOrderService.countSearchOrderByUid(uid, listES);
|
| | | }
|
| | | |
| | | if (list == null) {
|
| | | list = new ArrayList<>();
|
| | | }
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("count", count);
|
| | | data.put("list", JsonUtil.getApiCommonGson().toJson(list));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "查询失败"));
|
| | | e.printStackTrace();
|
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 用户订单统计
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * 用户id
|
| | | * type 类型:0全部、1淘宝 2京东、拼多多
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getOrderCount", method = RequestMethod.POST)
|
| | | public void getOrderCount(AcceptData acceptData, Long uid, Integer type, PrintWriter out) {
|
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "请求参数不正确"));
|
| | | return;
|
| | | }
|
| | | |
| | | try {
|
| | | UserInfo user = userInfoService.selectByPKey(uid);
|
| | | if (user == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | UserInfo userInfo = UserUtil.filterForClientUser(user);
|
| | | UserInfoExtraVO userInfoExtra = userInfoExtraService.getInfoExtraVOByUid(user.getId());
|
| | | if (userInfoExtra != null && userInfoExtra.getUserRank() != null) {
|
| | | userInfo.setRankIcon(userInfoExtra.getUserRank().getIcon());
|
| | | userInfo.setRankNamePicture(userInfoExtra.getUserRank().getPicture());
|
| | | }
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("userInfo", userInfo);
|
| | | |
| | | List<Integer> listSource = new ArrayList<>();
|
| | | if (type == null || type == 0) {
|
| | | listSource.add(Constant.SOURCE_TYPE_JD);
|
| | | listSource.add(Constant.SOURCE_TYPE_PDD);
|
| | | |
| | | OrderCountVO total = commonOrderService.getOrderCount(uid, null, listSource);
|
| | | data.put("total", total.getSelf() + total.getShared() + total.getInvite());
|
| | | data.put("self", total.getSelf());
|
| | | data.put("shared", total.getShared());
|
| | | data.put("invite", total.getInvite());
|
| | | } else {
|
| | | data.put("total", 0);
|
| | | data.put("self", 0);
|
| | | data.put("shared", 0);
|
| | | data.put("invite", 0);
|
| | | listSource.add(type);
|
| | | }
|
| | | |
| | | // 今天
|
| | | OrderCountVO today = commonOrderService.getOrderCount(uid, 1, listSource);
|
| | | today.setTotal(today.getSelf() + today.getShared() + today.getInvite());
|
| | | // 昨天
|
| | | OrderCountVO yesterday = commonOrderService.getOrderCount(uid, 2, listSource);
|
| | | yesterday.setTotal(yesterday.getSelf() + yesterday.getShared() + yesterday.getInvite());
|
| | | // 本月
|
| | | OrderCountVO thisMonth = commonOrderService.getOrderCount(uid, 3, listSource);
|
| | | thisMonth.setTotal(thisMonth.getSelf() + thisMonth.getShared() + thisMonth.getInvite());
|
| | | // 上月
|
| | | OrderCountVO lastMonth = commonOrderService.getOrderCount(uid, 4, listSource);
|
| | | lastMonth.setTotal(lastMonth.getSelf() + lastMonth.getShared() + lastMonth.getInvite());
|
| | |
|
| | | data.put("today", today);
|
| | | data.put("yesterday", yesterday);
|
| | | data.put("thisMonth", thisMonth);
|
| | | data.put("lastMonth", lastMonth);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "获取信息失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | }
|
| | |
|
| | |
|
New file |
| | |
| | | package com.yeshi.fanli.controller.wxmp.v1;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | |
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.yeshi.fanli.dto.ConfigParamsDTO;
|
| | | import com.yeshi.fanli.dto.WXMPAcceptData;
|
| | | import com.yeshi.fanli.dto.jd.JDSearchResult;
|
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
|
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsResult;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.Special;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture;
|
| | | import com.yeshi.fanli.entity.common.JumpDetailV2;
|
| | | import com.yeshi.fanli.entity.jd.JDGoods;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.count.HongBaoV2CountService;
|
| | | import com.yeshi.fanli.service.inter.goods.recommend.HomeRecommendGoodsService;
|
| | | import com.yeshi.fanli.service.inter.goods.recommend.RecommendGoodsDeleteHistoryService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.DeviceSexService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.SpecialService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService;
|
| | | import com.yeshi.fanli.service.inter.jd.JDGoodsService;
|
| | | import com.yeshi.fanli.service.inter.lable.QualityFlashSaleService;
|
| | | import com.yeshi.fanli.service.inter.lable.QualityGoodsService;
|
| | | import com.yeshi.fanli.service.inter.monitor.MonitorService;
|
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.pdd.PDDGoodsService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService;
|
| | | import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsDetailV2Service;
|
| | | import com.yeshi.fanli.service.inter.taobao.dataoke.DaTaoKeGoodsService;
|
| | | import com.yeshi.fanli.tag.PageEntity;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.JumpDetailUtil;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
|
| | | import com.yeshi.fanli.vo.goods.GoodsDetailVO;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Controller("WXMPRecommendController")
|
| | | @RequestMapping("/wxmp/api/v1/recommend")
|
| | | public class RecommendController {
|
| | |
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | | @Resource
|
| | | private QualityGoodsService qualityGoodsService;
|
| | |
|
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | |
|
| | | @Resource
|
| | | private HomeRecommendGoodsService homeRecommendGoodsService;
|
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | |
|
| | | @Resource
|
| | | private MonitorService monitorService;
|
| | |
|
| | | @Resource
|
| | | private QualityFlashSaleService qualityFlashSaleService;
|
| | |
|
| | | @Resource
|
| | | private RecommendGoodsDeleteHistoryService recommendGoodsDeleteHistoryService;
|
| | |
|
| | | @Resource
|
| | | private JumpDetailV2Service jumpDetailV2Service;
|
| | |
|
| | | @Resource
|
| | | private DeviceSexService deviceSexService;
|
| | |
|
| | | @Resource
|
| | | private SpecialService specialService;
|
| | |
|
| | | @Resource
|
| | | private SwiperPictureService swiperPictureService;
|
| | |
|
| | | @Resource
|
| | | private JDGoodsService jdGoodsService;
|
| | |
|
| | | @Resource
|
| | | private PDDGoodsService pddGoodsService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService;
|
| | |
|
| | | @Resource
|
| | | private DaTaoKeGoodsDetailV2Service daTaoKeGoodsDetailV2Service;
|
| | |
|
| | | @Resource
|
| | | private DaTaoKeGoodsService daTaoKeGoodsService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoV2CountService hongBaoV2CountService;
|
| | |
|
| | | /**
|
| | | * 首页专题
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getIndex")
|
| | | public void getIndex(WXMPAcceptData acceptData, Long uid, PrintWriter out) {
|
| | | try {
|
| | | String platform = acceptData.getPlatform();
|
| | | int version = Integer.parseInt(acceptData.getVersion());
|
| | |
|
| | | // 轮播图
|
| | | List<SwiperPicture> picList = swiperPictureService.getByBannerCardAndVersion("index_top", platform,
|
| | | version);
|
| | | if (picList == null) {
|
| | | picList = new ArrayList<>();
|
| | | }
|
| | |
|
| | | for (SwiperPicture swiper : picList) {
|
| | | JSONObject params = null;
|
| | | if (StringUtil.isNullOrEmpty(swiper.getParams())) {
|
| | | params = JSONObject.fromObject(swiper.getParams());
|
| | | }
|
| | | swiper.setJumpDetail(JumpDetailUtil.getWXMPJumDetail(swiper.getJumpDetail(), params));
|
| | | swiper.setParams(null);
|
| | | }
|
| | |
|
| | | // 圆形专题
|
| | | List<Special> specials = specialService.listByVersion(0, 10, "index_arc_1.6.5", platform, version);
|
| | | if (specials == null)
|
| | | specials = new ArrayList<>();
|
| | |
|
| | | for (Special special : specials) {
|
| | | JumpDetailV2 jumpDetail = special.getJumpDetail();
|
| | | if (special.isJumpLogin() && jumpDetail != null) {
|
| | | jumpDetail.setNeedLogin(true);
|
| | | }
|
| | | |
| | | JSONObject params = null;
|
| | | if (StringUtil.isNullOrEmpty(special.getParams())) {
|
| | | params = JSONObject.fromObject(special.getParams());
|
| | | }
|
| | | |
| | | special.setJumpDetail(JumpDetailUtil.getWXMPJumDetail(jumpDetail, params));
|
| | | special.setParams(null);
|
| | | }
|
| | |
|
| | | // 活动
|
| | | List<SwiperPicture> activitys = swiperPictureService.getByBannerCardAndVersion("index_invite", platform,
|
| | | version);
|
| | | if (activitys == null)
|
| | | activitys = new ArrayList<>();
|
| | |
|
| | | for (SwiperPicture swiper : activitys) {
|
| | | JSONObject params = null;
|
| | | if (StringUtil.isNullOrEmpty(swiper.getParams())) {
|
| | | params = JSONObject.fromObject(swiper.getParams());
|
| | | }
|
| | | swiper.setJumpDetail(JumpDetailUtil.getWXMPJumDetail(swiper.getJumpDetail(), params));
|
| | | swiper.setParams(null);
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("bannerList", JsonUtil.getApiCommonGson().toJson(picList));
|
| | | data.put("specialList", JsonUtil.getApiCommonGson().toJson(specials));
|
| | | data.put("activityList", JsonUtil.getApiCommonGson().toJson(activitys));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "获取数据失败"));
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 首页底部商品推荐
|
| | | * |
| | | * @param acceptData
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getGoodList")
|
| | | public void getGoodList(WXMPAcceptData acceptData, Integer goodsType, Integer page, HttpServletRequest request,
|
| | | PrintWriter out) {
|
| | | if (goodsType == null || page == null) {
|
| | | out.print(JsonUtil.loadFalseResult("参数信息不正常"));
|
| | | return;
|
| | | }
|
| | |
|
| | | try {
|
| | | if (goodsType == Constant.SOURCE_TYPE_JD) {
|
| | | getIndexJDGoods(acceptData, page, out);
|
| | | return;
|
| | | }
|
| | |
|
| | | if (goodsType == Constant.SOURCE_TYPE_PDD) {
|
| | | getIndexPDDGoods(acceptData, page, out);
|
| | | return;
|
| | | }
|
| | | out.print(JsonUtil.loadFalseResult("商品类型错误"));
|
| | | } catch (Exception e) {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("list", new JSONArray());
|
| | | data.put("count", 0);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 京东首页商品
|
| | | * |
| | | * @param acceptData
|
| | | * @param page
|
| | | * @param out
|
| | | */
|
| | | private void getIndexJDGoods(WXMPAcceptData acceptData, int page, PrintWriter out) {
|
| | | JDSearchResult result = jdGoodsService.getIndexJDGoods(page);
|
| | | long count = 0;
|
| | | JSONObject data = new JSONObject();
|
| | | JSONArray array = new JSONArray();
|
| | | if (result != null) {
|
| | | PageEntity pageEntity = result.getPageEntity();
|
| | | if (pageEntity != null) {
|
| | | count = pageEntity.getTotalCount();
|
| | | }
|
| | |
|
| | | List<JDGoods> goodsList = result.getGoodsList();
|
| | | if (goodsList != null && goodsList.size() > 0) {
|
| | | ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate(acceptData.getPlatform(),
|
| | | acceptData.getVersion());
|
| | |
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | | for (JDGoods goods : goodsList) {
|
| | | GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertJDGoods(goods, paramsDTO);
|
| | | array.add(gson.toJson(goodsDetailVO));
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | data.put("list", array);
|
| | | data.put("count", count);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 爆款排行商品-实时热销榜
|
| | | * |
| | | * @param acceptData
|
| | | * @param page
|
| | | * @param out
|
| | | */
|
| | | private void getIndexPDDGoods(WXMPAcceptData acceptData, int page, PrintWriter out) {
|
| | | PDDGoodsResult result = pddGoodsService.getTopGoodsList(page, 1);
|
| | | int count = 0;
|
| | | JSONArray array = new JSONArray();
|
| | | if (result != null) {
|
| | | count = result.getTotalCount();
|
| | | Gson gson = JsonUtil.getApiCommonGson();
|
| | | List<PDDGoodsDetail> goodsList = result.getGoodsList();
|
| | | if (goodsList != null && goodsList.size() > 0) {
|
| | | ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate(acceptData.getPlatform(),
|
| | | acceptData.getVersion());
|
| | |
|
| | | for (PDDGoodsDetail goods : goodsList) {
|
| | | GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertPDDGoods(goods, paramsDTO);
|
| | | array.add(gson.toJson(goodsDetailVO));
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("list", array);
|
| | | data.put("count", count);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 首页顶部提示
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param callback
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getGuide")
|
| | | public void getGuide(AcceptData acceptData, Long uid, PrintWriter out) {
|
| | | String tips = null;
|
| | | if (uid == null || uid <= 0) {
|
| | | tips = configService.get("tip_guide_new_user");
|
| | | } else {
|
| | | long rebateOrder = hongBaoV2CountService.countRebateOrder(uid);
|
| | | long shareOrInviteOrder = hongBaoV2CountService.countShareOrInviteOrder(uid);
|
| | | if (rebateOrder + shareOrInviteOrder >= 3) {
|
| | | // 熟客版
|
| | | } else if (rebateOrder <= 0 && shareOrInviteOrder <= 0) {
|
| | | // 新人版
|
| | | tips = configService.get("tip_guide_new_user");
|
| | | } else if (rebateOrder > 0 && shareOrInviteOrder <= 0) {
|
| | | // 省钱版
|
| | | tips = configService.get("tip_guide_save_money");
|
| | | } else {
|
| | | // 赚钱版
|
| | | tips = configService.get("tip_guide_share_invite");
|
| | | }
|
| | | }
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(tips)) {
|
| | | out.print(JsonUtil.loadFalseResult("暂无提示"));
|
| | | return;
|
| | | }
|
| | |
|
| | | JSONObject data = JSONObject.fromObject(tips);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.controller.wxmp.v1;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.util.List;
|
| | | import java.util.regex.Matcher;
|
| | | import java.util.regex.Pattern;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpSession;
|
| | |
|
| | | import org.springframework.core.task.TaskExecutor;
|
| | | 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 com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.yeshi.fanli.dto.ConfigParamsDTO;
|
| | | import com.yeshi.fanli.dto.WXMPAcceptData;
|
| | | import com.yeshi.fanli.dto.jd.JDFilter;
|
| | | import com.yeshi.fanli.dto.jd.JDSearchFilter;
|
| | | import com.yeshi.fanli.dto.jd.JDSearchResult;
|
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
|
| | | import com.yeshi.fanli.dto.pdd.PDDGoodsResult;
|
| | | import com.yeshi.fanli.dto.pdd.PDDSearchFilter;
|
| | | import com.yeshi.fanli.entity.goods.CommonGoods;
|
| | | import com.yeshi.fanli.entity.jd.JDGoods;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.brand.BrandInfoService;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.manger.goods.jd.JDGoodsLinkParseManager;
|
| | | import com.yeshi.fanli.tag.PageEntity;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.factory.CommonGoodsFactory;
|
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
|
| | | import com.yeshi.fanli.util.jd.JDApiUtil;
|
| | | import com.yeshi.fanli.util.jd.JDUtil;
|
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
|
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoUtil;
|
| | | import com.yeshi.fanli.util.taobao.SearchFilterUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.vo.goods.GoodsDetailVO;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Controller("WXMPSearchController")
|
| | | @RequestMapping("/wxmp/api/v1/search")
|
| | | public class SearchController {
|
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | | @Resource(name = "taskExecutor")
|
| | | private TaskExecutor executor;
|
| | |
|
| | | @Resource
|
| | | private BrandInfoService brandInfoService;
|
| | |
|
| | | @Resource
|
| | | private JDGoodsLinkParseManager jdGoodsLinkParseManager;
|
| | | |
| | |
|
| | | /**
|
| | | * 粘贴板信息推荐
|
| | | * |
| | | * @param acceptData
|
| | | * @param url
|
| | | * 商品链接
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getRecommendInfo", method = RequestMethod.POST)
|
| | | public void getRecommendInfo(WXMPAcceptData acceptData, String text, Long uid, PrintWriter out) {
|
| | | if (StringUtil.isNullOrEmpty(text)) {
|
| | | out.print(JsonUtil.loadFalseResult("值为空"));
|
| | | return;
|
| | | }
|
| | | |
| | | // 去除前后空格
|
| | | int type = 1;
|
| | | text = text.trim();
|
| | | String URL_REGEX = "(((http|https)://)|(www\\.))[a-zA-Z0-9\\._-]+\\.[a-zA-Z]{2,6}(:[0-9]{1,4})?(/[a-zA-Z0-9\\&%_\\./-~-]*)?";
|
| | | Pattern p = Pattern.compile(URL_REGEX);
|
| | | Matcher matcher = p.matcher(text);
|
| | | if (!matcher.find()) {// 不包含链接
|
| | | if (text.length() > 256) {
|
| | | out.print(JsonUtil.loadFalseResult("值过长"));
|
| | | return;
|
| | | }
|
| | | String pattern = "^[A-Za-z0-9-]+$";
|
| | | if (Pattern.matches(pattern, text.replace(" ", ""))) {// 删除空格
|
| | | out.println(JsonUtil.loadFalseResult("不支持推荐"));
|
| | | return;
|
| | | }
|
| | |
|
| | | LogHelper.test("根据粘贴板推荐:" + text);
|
| | | if (text.length() > 80) {
|
| | | out.print(JsonUtil.loadFalseResult("值过长"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(TaoBaoUtil.parseSystemTaoToken(text))) {
|
| | | out.print(JsonUtil.loadFalseResult("不支持推荐"));
|
| | | return;
|
| | | }
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("type", type);
|
| | | data.put("title", text);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | return;
|
| | | }
|
| | |
|
| | | type = 2;
|
| | | CommonGoods commonGoods = null;
|
| | | text = matcher.group();
|
| | | String jdId = JDUtil.getJDGoodsId(text);
|
| | | if (StringUtil.isNullOrEmpty(jdId)) {
|
| | | jdId = JDUtil.getJDGoodsIdByWeiXin(text); // 微信链接
|
| | | if (StringUtil.isNullOrEmpty(jdId) && text.contains("u.jd.com")) {
|
| | | jdId = jdGoodsLinkParseManager.parseGoodsIdByJDShortUrl(text); // 领券短连接
|
| | | }
|
| | | }
|
| | | if (!StringUtil.isNullOrEmpty(jdId)) {
|
| | | JDGoods goods = JDApiUtil.getGoodsDetail(Long.parseLong(jdId));
|
| | | if (goods != null) {
|
| | | // 高级接口 -- 信息更完整
|
| | | JDGoods jdGoods = JDApiUtil.queryGoodsDetail(Long.parseLong(jdId));
|
| | | if (jdGoods != null) {
|
| | | commonGoods = CommonGoodsFactory.create(jdGoods);
|
| | | } else {
|
| | | commonGoods = CommonGoodsFactory.create(goods);
|
| | | }
|
| | | } else {
|
| | | type = 3;
|
| | | goods = JDUtil.getSimpleGoodsInfo(jdId);
|
| | | if (goods != null) {
|
| | | commonGoods = new CommonGoods();
|
| | | commonGoods.setTitle(goods.getSkuName());
|
| | | commonGoods.setPicture(goods.getPicUrl());
|
| | | }
|
| | | }
|
| | | } else {
|
| | | String pddId = PinDuoDuoUtil.getPDDGoodsId(text);
|
| | | if (!StringUtil.isNullOrEmpty(pddId)) {
|
| | | PDDGoodsDetail goods = PinDuoDuoApiUtil.getGoodsDetail(Long.parseLong(pddId));
|
| | | if (goods != null) {
|
| | | commonGoods = CommonGoodsFactory.create(goods);
|
| | | } else {
|
| | | type = 3;
|
| | | goods = PinDuoDuoUtil.getPDDGoodsInfo(pddId);
|
| | | if (goods != null) {
|
| | | commonGoods = new CommonGoods();
|
| | | commonGoods.setTitle(goods.getGoodsName());
|
| | | commonGoods.setPicture(goods.getGoodsThumbnailUrl());
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | if (commonGoods == null) {
|
| | | out.println(JsonUtil.loadFalseResult("暂未找到该商品,请稍后再试!"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (type == 3) {
|
| | | JSONObject data = new JSONObject();
|
| | | JSONObject goodsJSON = new JSONObject();
|
| | | goodsJSON.put("title", commonGoods.getTitle());
|
| | | goodsJSON.put("pictUrl", commonGoods.getPicture());
|
| | | data.put("type", type);
|
| | | data.put("desc", "该商品无推广信息");
|
| | | data.put("goods", goodsJSON);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | return;
|
| | | } |
| | | |
| | | JSONObject data = new JSONObject();
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | | data.put("type", type);
|
| | | data.put("goods", gson.toJson(GoodsDetailVOFactory.convertCommonGoods(commonGoods, hongBaoManageService.getShowComputeRate(acceptData.getPlatform(), acceptData.getVersion()))));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | return;
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 搜索候选词
|
| | | * |
| | | * @param acceptData
|
| | | * @param kw
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "suggestSearch", method = RequestMethod.POST)
|
| | | public void getSugguestSearch(WXMPAcceptData acceptData, String kw, Integer goodsType, PrintWriter out) {
|
| | | if (goodsType == null) {
|
| | | out.print(JsonUtil.loadFalseResult("平台类型不能为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | | List<String> list = null;
|
| | | if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | list = TaoBaoUtil.getSuguestSearch(kw);
|
| | | } else if (goodsType == Constant.SOURCE_TYPE_JD) {
|
| | | list = JDUtil.suggestSearch(kw);
|
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) {
|
| | | list = PinDuoDuoUtil.suggestSearch(kw);
|
| | | }
|
| | |
|
| | | if (list == null || list.size() == 0) {
|
| | | out.print(JsonUtil.loadFalseResult("暂无建议内容"));
|
| | | return;
|
| | | }
|
| | |
|
| | | JSONArray array = new JSONArray();
|
| | | for (String words : list) {
|
| | | array.add(words);
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(array));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 搜索-新版
|
| | | * |
| | | * @param acceptData
|
| | | * @param kw
|
| | | * @param page
|
| | | * @param filter
|
| | | * @param order
|
| | | * 销量由高到低:1 、 价格从高到低:2 、 价格从低到高:3 、 推广量高到低:4(综合默认)、返利比高到低:5
|
| | | * 、返利比低到高:6 、推荐20
|
| | | * @param startprice
|
| | | * @param endprice
|
| | | * @param fastFilter
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "searchGoods")
|
| | | public void searchGoods(WXMPAcceptData acceptData, Integer goodsType, String key, Integer page, String filter,
|
| | | Integer order, Long uid, HttpSession session, PrintWriter out) {
|
| | | if (goodsType == null || goodsType < 2 || goodsType > 3) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "请传递正确平台参数"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(key)) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "请输入搜索内容"));
|
| | | return;
|
| | | }
|
| | | |
| | | if (page == null || page < 1) {
|
| | | page = 1;
|
| | | }
|
| | | |
| | | final String searchkey = key.trim();
|
| | | if (searchkey.startsWith("http://") || searchkey.startsWith("https://")) {
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("count", 0);
|
| | | data.put("list", new JSONArray());
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | return;
|
| | | }
|
| | |
|
| | | /*--------- 京东商品 -------*/
|
| | | if (goodsType.intValue() == Constant.SOURCE_TYPE_JD) {
|
| | | searchJDGoods(acceptData, searchkey, page, filter, order, out);
|
| | | return;
|
| | | }
|
| | |
|
| | | /*-------- 拼多多商品 -------*/
|
| | | if (goodsType.intValue() == Constant.SOURCE_TYPE_PDD) {
|
| | | searchPDDGoods(acceptData, searchkey, page, filter, order, out);
|
| | | return;
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 京东
|
| | | * |
| | | * @param kw
|
| | | * @param page
|
| | | * @param filter
|
| | | * @param order
|
| | | * @param startprice
|
| | | * @param endprice
|
| | | * @return
|
| | | */
|
| | | private void searchJDGoods(WXMPAcceptData acceptData, String key, Integer page, String filter, Integer order,
|
| | | PrintWriter out) {
|
| | |
|
| | | JDSearchResult result = null;
|
| | | boolean hasCoupon = false;
|
| | | String way = configService.get("jd_api_search_key");
|
| | | if ("1".equals(way)) {
|
| | | JDFilter filterAPI = new JDFilter();
|
| | | filterAPI.setKeyword(SearchFilterUtil.filterSearchContent(key));
|
| | | filterAPI.setPageIndex(page);
|
| | | filterAPI.setPageSize(Constant.PAGE_SIZE);
|
| | |
|
| | | if (order != null) {
|
| | | int sort = order.intValue();
|
| | | switch (sort) {
|
| | | case 1: // 销量 desc
|
| | | filterAPI.setSort(JDFilter.SORT_DESC);
|
| | | filterAPI.setSortName(JDFilter.SORTNAME_ORDER_COUNT_30DAYS);
|
| | | break;
|
| | | case 2: // 价格—desc
|
| | | filterAPI.setSort(JDFilter.SORT_DESC);
|
| | | filterAPI.setSortName(JDFilter.SORTNAME_PRICE);
|
| | | break;
|
| | | case 3: // 价格—asc
|
| | | filterAPI.setSort(JDFilter.SORT_ASC);
|
| | | filterAPI.setSortName(JDFilter.SORTNAME_PRICE);
|
| | | break;
|
| | | case 4: // 返利比—DESC
|
| | | filterAPI.setSort(JDFilter.SORT_DESC);
|
| | | filterAPI.setSortName(JDFilter.SORTNAME_COMMISSION_SHARE);
|
| | | break;
|
| | | default:
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(filter)) {
|
| | | JSONObject jsonfilter = JSONObject.fromObject(filter);
|
| | | Boolean coupon = jsonfilter.optBoolean("coupon");
|
| | | if (coupon != null && coupon) {
|
| | | hasCoupon = true;
|
| | | filterAPI.setIsCoupon(1); // 有券
|
| | | }
|
| | |
|
| | | Boolean zy = jsonfilter.optBoolean("zy");
|
| | | if (zy != null && zy) {
|
| | | filterAPI.setOwner("g"); // 自营
|
| | | }
|
| | |
|
| | | String minPrice = jsonfilter.optString("minPrice");
|
| | | if (!StringUtil.isNullOrEmpty(minPrice)) {
|
| | | filterAPI.setPricefrom(Double.parseDouble(minPrice));
|
| | | }
|
| | |
|
| | | String maxPrice = jsonfilter.optString("maxPrice");
|
| | | if (!StringUtil.isNullOrEmpty(maxPrice)) {
|
| | | filterAPI.setPriceto(Double.parseDouble(maxPrice));
|
| | | }
|
| | | }
|
| | |
|
| | | result = JDApiUtil.queryByKey(filterAPI);
|
| | | } else {
|
| | | // 网页爬取
|
| | | JDSearchFilter jdfilter = new JDSearchFilter();
|
| | | jdfilter.setKey(SearchFilterUtil.filterSearchContent(key));
|
| | | jdfilter.setPageNo(page);
|
| | | jdfilter.setPageSize(Constant.PAGE_SIZE);
|
| | |
|
| | | if (order != null) {
|
| | | int sort = order.intValue();
|
| | | switch (sort) {
|
| | | case 1: // 销量 desc
|
| | | jdfilter.setSort(JDSearchFilter.SORT_DESC);
|
| | | jdfilter.setSortName(JDSearchFilter.SORTNAME_ORDER_COUNT_30DAYS);
|
| | | break;
|
| | | case 2: // 价格—desc
|
| | | jdfilter.setSort(JDSearchFilter.SORT_DESC);
|
| | | jdfilter.setSortName(JDSearchFilter.SORTNAME_PRICE);
|
| | | break;
|
| | | case 3: // 价格—asc
|
| | | jdfilter.setSort(JDSearchFilter.SORT_ASC);
|
| | | jdfilter.setSortName(JDSearchFilter.SORTNAME_PRICE);
|
| | | break;
|
| | | case 4: // 返利比—DESC
|
| | | jdfilter.setSort(JDSearchFilter.SORT_DESC);
|
| | | jdfilter.setSortName(JDSearchFilter.SORTNAME_COMMISSION_SHARE);
|
| | | break;
|
| | | default:
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(filter)) {
|
| | | JSONObject jsonfilter = JSONObject.fromObject(filter);
|
| | | Boolean coupon = jsonfilter.optBoolean("coupon");
|
| | | if (coupon != null && coupon) {
|
| | | hasCoupon = true;
|
| | | jdfilter.setHasCoupon(1); // 有券
|
| | | }
|
| | |
|
| | | Boolean zy = jsonfilter.optBoolean("zy");
|
| | | if (zy != null && zy) {
|
| | | jdfilter.setIsZY(1); // 自营
|
| | | }
|
| | |
|
| | | Boolean delivery = jsonfilter.optBoolean("delivery");
|
| | | if (delivery != null && delivery) {
|
| | | jdfilter.setDeliveryType(1); // 京东配送
|
| | | }
|
| | |
|
| | | String minPrice = jsonfilter.optString("minPrice");
|
| | | if (!StringUtil.isNullOrEmpty(minPrice)) {
|
| | | if (minPrice.contains(".")) {
|
| | | minPrice = minPrice.replace(".", "-");
|
| | | minPrice = minPrice.split("-")[0];
|
| | | }
|
| | | jdfilter.setFromPrice(Integer.parseInt(minPrice));
|
| | | }
|
| | |
|
| | | String maxPrice = jsonfilter.optString("maxPrice");
|
| | | if (!StringUtil.isNullOrEmpty(maxPrice)) {
|
| | | if (maxPrice.contains(".")) {
|
| | | maxPrice = maxPrice.replace(".", "-");
|
| | | maxPrice = maxPrice.split("-")[0];
|
| | | }
|
| | | jdfilter.setToPrice(Integer.parseInt(maxPrice));
|
| | | }
|
| | | }
|
| | | result = JDUtil.searchByKey(jdfilter);
|
| | |
|
| | | }
|
| | |
|
| | | long count = 0;
|
| | | JSONObject data = new JSONObject();
|
| | | JSONArray array = new JSONArray();
|
| | | if (result != null) {
|
| | | PageEntity pageEntity = result.getPageEntity();
|
| | | if (pageEntity != null) {
|
| | | count = pageEntity.getTotalCount();
|
| | | }
|
| | |
|
| | | List<JDGoods> goodsList = result.getGoodsList();
|
| | | if (goodsList != null && goodsList.size() > 0) {
|
| | | Gson gson = JsonUtil.getConvertBigDecimalToStringSubZeroBuilder(new GsonBuilder())
|
| | | .excludeFieldsWithoutExposeAnnotation().setDateFormat("yyyy-MM-dd").create();
|
| | | ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate(acceptData.getPlatform(),
|
| | | acceptData.getVersion());
|
| | | for (JDGoods goods : goodsList) {
|
| | | GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertJDGoods(goods, paramsDTO);
|
| | | if (hasCoupon) {
|
| | | if (goodsDetailVO.isHasCoupon()) {
|
| | | array.add(gson.toJson(goodsDetailVO));
|
| | | }
|
| | | } else {
|
| | | array.add(gson.toJson(goodsDetailVO));
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | data.put("count", count);
|
| | | data.put("list", array);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 拼多多
|
| | | * |
| | | * @param kw
|
| | | * @param page
|
| | | * @param filter
|
| | | * @param order
|
| | | * @param startprice
|
| | | * @param endprice
|
| | | * @return
|
| | | */
|
| | | private void searchPDDGoods(WXMPAcceptData acceptData, String key, Integer page, String filter, Integer order,
|
| | | PrintWriter out) {
|
| | | PDDSearchFilter pddfilter = new PDDSearchFilter();
|
| | | pddfilter.setKw(SearchFilterUtil.filterSearchContent(key));
|
| | | pddfilter.setPage(page);
|
| | | pddfilter.setPageSize(Constant.PAGE_SIZE);
|
| | |
|
| | | if (order != null) {
|
| | | int sort = order.intValue();
|
| | | switch (sort) {
|
| | | case 1: // 销量 desc
|
| | | pddfilter.setSortType(6);
|
| | | break;
|
| | | case 2: // 价格—desc
|
| | | pddfilter.setSortType(4);
|
| | | break;
|
| | | case 3: // 价格—asc
|
| | | pddfilter.setSortType(3);
|
| | | break;
|
| | | case 4: // 返利比—desc
|
| | | pddfilter.setSortType(2);
|
| | | break;
|
| | | default: // 综合排序
|
| | | pddfilter.setSortType(0);
|
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(filter)) {
|
| | | JSONObject jsonfilter = JSONObject.fromObject(filter);
|
| | | Boolean coupon = jsonfilter.optBoolean("coupon");
|
| | | if (coupon != null && coupon) {
|
| | | pddfilter.setHasCoupon(true); // 有券
|
| | | }
|
| | |
|
| | | Boolean brand = jsonfilter.optBoolean("brand");
|
| | | if (brand != null && brand) {
|
| | | pddfilter.setIsBrand(true); // 是否是品牌
|
| | | }
|
| | | }
|
| | |
|
| | | int count = 0;
|
| | | JSONObject data = new JSONObject();
|
| | | JSONArray array = new JSONArray();
|
| | |
|
| | | PDDGoodsResult result = PinDuoDuoApiUtil.searchGoods(pddfilter);
|
| | | if (result != null) {
|
| | | count = result.getTotalCount();
|
| | | Gson gson = JsonUtil.getApiCommonGson();
|
| | | List<PDDGoodsDetail> goodsList = result.getGoodsList();
|
| | | if (goodsList != null && goodsList.size() > 0) {
|
| | | ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate(acceptData.getPlatform(),
|
| | | acceptData.getVersion());
|
| | |
|
| | | for (PDDGoodsDetail goods : goodsList) {
|
| | | GoodsDetailVO goodsDetailVO = GoodsDetailVOFactory.convertPDDGoods(goods, paramsDTO);
|
| | | array.add(gson.toJson(goodsDetailVO));
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | data.put("count", count);
|
| | | data.put("list", array);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | | }
|
| | |
| | | package com.yeshi.fanli.controller.wxmp.v1;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.lang.reflect.Type;
|
| | | import java.math.BigDecimal;
|
| | | import java.text.ParseException;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | |
| | | import org.yeshi.utils.wx.WXXCXUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.google.gson.JsonElement;
|
| | | import com.google.gson.JsonPrimitive;
|
| | | import com.google.gson.JsonSerializationContext;
|
| | | import com.google.gson.JsonSerializer;
|
| | | import com.yeshi.fanli.dto.WXMPAcceptData;
|
| | | import com.yeshi.fanli.dto.user.wx.WXMPLoginData;
|
| | | import com.yeshi.fanli.dto.user.wx.WXMPLoginResult;
|
| | | import com.yeshi.fanli.entity.bus.user.ForbiddenUserIdentifyCode;
|
| | | import com.yeshi.fanli.entity.bus.user.ForbiddenUserIdentifyCode.ForbiddenUserIdentifyCodeTypeEnum;
|
| | | import com.yeshi.fanli.entity.bus.user.SMSHistory;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfoExtra;
|
| | | import com.yeshi.fanli.entity.bus.user.WeiXinUser;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.UserVIPInfo;
|
| | | import com.yeshi.fanli.entity.money.UserMoneyDetail.UserMoneyDetailTypeEnum;
|
| | | import com.yeshi.fanli.entity.shop.BanLiShopOrder;
|
| | | import com.yeshi.fanli.exception.user.UserAccountException;
|
| | | import com.yeshi.fanli.exception.user.UserInfoExtraException;
|
| | | import com.yeshi.fanli.exception.user.vip.UserVIPInfoException;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.count.HongBaoV2CountService;
|
| | | import com.yeshi.fanli.service.inter.money.UserMoneyDetailService;
|
| | | import com.yeshi.fanli.service.inter.shop.BanLiShopOrderService;
|
| | | import com.yeshi.fanli.service.inter.user.ForbiddenUserIdentifyCodeService;
|
| | | import com.yeshi.fanli.service.inter.user.UserAccountService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.vip.UserVipConfigService;
|
| | | import com.yeshi.fanli.service.inter.user.wx.WXMPUserLoginService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.ThreadUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.account.UserUtil;
|
| | | import com.yeshi.fanli.vo.user.UserVipRateVO;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | |
| | | @Resource
|
| | | private ForbiddenUserIdentifyCodeService forbiddenUserIdentifyCodeService;
|
| | |
|
| | | @Resource
|
| | | private UserMoneyDetailService userMoneyDetailService;
|
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | | |
| | | @Resource
|
| | | private UserVIPInfoService userVIPInfoService;
|
| | | |
| | | @Resource
|
| | | private UserVipConfigService userVipConfigService;
|
| | | |
| | | @Resource
|
| | | private BanLiShopOrderService banLiShopOrderService;
|
| | | |
| | | @Resource
|
| | | private HongBaoV2CountService hongBaoV2CountService;
|
| | |
|
| | | |
| | | /**
|
| | | * 通过邀请码获取用户信息
|
| | | *
|
| | |
| | | } catch (UserAccountException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 绑定电话号码 V1.5.3
|
| | | * |
| | | * @param acceptData
|
| | | * @param vcode
|
| | | * @param phone
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "bindPhone")
|
| | | public void bindPhone(WXMPAcceptData acceptData, Long uid, String vcode, String phone, PrintWriter out) {
|
| | | if (StringUtil.isNullOrEmpty(vcode)) {
|
| | | out.print(JsonUtil.loadFalseResult("验证码不能为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(phone)) {
|
| | | out.print(JsonUtil.loadFalseResult("电话号码不能为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | | phone = phone.replaceAll(" ", "");
|
| | |
|
| | | String oldVCode = redisManager.getSMSVCode(phone, SMSHistory.TYPE_BIND);
|
| | | if (Constant.IS_OUTNET) {
|
| | | if (!vcode.equalsIgnoreCase(oldVCode)) {
|
| | | out.print(JsonUtil.loadFalseResult(9001, "验证码错误,重新输入"));
|
| | | return;
|
| | | }
|
| | | redisManager.clearSMSFrequencyLimit(phone, SMSHistory.TYPE_BIND);
|
| | | }
|
| | |
|
| | | try {
|
| | | // 绑定用户
|
| | | userAccountService.bindPhoneNew(uid, phone);
|
| | |
|
| | | UserInfo user = userInfoService.getUserByIdWithMybatis(uid);
|
| | | // 判断电话号码是否已经封禁
|
| | | ForbiddenUserIdentifyCode ic = forbiddenUserIdentifyCodeService
|
| | | .listByTypeAndIdentifyCode(ForbiddenUserIdentifyCodeTypeEnum.phone, phone);
|
| | | if (ic != null && ic.getEffective() != null && ic.getEffective()) {
|
| | | out.print(JsonUtil.loadFalseResult(Constant.CODE_FORBIDDEN_USER, Constant.FORBIDDEN_USER_REASON_DESC));
|
| | | // 封禁用户
|
| | | // 封禁绑定的正常用户
|
| | | if (user != null && user.getState() != null && user.getState() == UserInfo.STATE_NORMAL) {
|
| | | userAccountService.forbiddenUser(uid, "封禁:绑定被封禁的电话号码");
|
| | | }
|
| | | return;
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("user", UserUtil.filterForClientUser(user));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | } catch (UserAccountException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMsg()));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "绑定失败"));
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | | |
| | | /**
|
| | | * 获取vip信息
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getVIPInfo")
|
| | | public void getVIPInfo(String callback, WXMPAcceptData acceptData, Long uid, PrintWriter out) {
|
| | | if (uid == null || uid <= 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | UserInfo userInfo = userInfoService.selectByPKey(uid);
|
| | | if (userInfo == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "该用户不存在"));
|
| | | return;
|
| | | }
|
| | | //
|
| | | String inviteCode = userInfoExtraService.getInviteCodeByUid(uid);
|
| | |
|
| | | UserVipRateVO vo = new UserVipRateVO();
|
| | | vo.setId(uid);
|
| | | vo.setInviteCode(inviteCode);
|
| | | vo.setNickName(userInfo.getNickName());
|
| | | vo.setPortrait(userInfo.getPortrait());
|
| | | vo.setHelpLink(userVipConfigService.getValueByKey("help_link_vip_h5"));
|
| | | vo.setCsdLink(configService.get("customer_service_link"));
|
| | |
|
| | | Date now = new Date();
|
| | | Date start = new Date(0);
|
| | |
|
| | | // 返利订单、奖励券提成
|
| | | List<UserMoneyDetailTypeEnum> typeFanli = new ArrayList<>();
|
| | | typeFanli.add(UserMoneyDetailTypeEnum.fanli);
|
| | | typeFanli.add(UserMoneyDetailTypeEnum.orderReward);
|
| | | BigDecimal finishMoney = userMoneyDetailService.statisticUserTypeMoneyWithDate(uid, typeFanli, start, now)
|
| | | .abs();
|
| | |
|
| | | // 邀请订单、分享订单、补贴
|
| | | List<UserMoneyDetailTypeEnum> typeList = new ArrayList<>();
|
| | | typeList.add(UserMoneyDetailTypeEnum.share);
|
| | | typeList.add(UserMoneyDetailTypeEnum.invite);
|
| | | typeList.add(UserMoneyDetailTypeEnum.inviteAndShare);
|
| | | typeList.add(UserMoneyDetailTypeEnum.systemEqualize);
|
| | | typeList.add(UserMoneyDetailTypeEnum.subsidy);
|
| | | BigDecimal rewardMoney = userMoneyDetailService.statisticUserTypeMoneyWithDate(uid, typeList, start, now).abs();
|
| | |
|
| | | UserVIPInfo userVIPInfo = userVIPInfoService.selectByUid(uid);
|
| | | vo.setVipInfo(userVIPInfo);
|
| | | String leftTime = "";
|
| | | if (userVIPInfo != null && userVIPInfo.getApplyTime() != null) {
|
| | | // TODO 计算时间
|
| | | long s = 48 * 60 * 60 - ((System.currentTimeMillis() - userVIPInfo.getApplyTime().getTime()) / 1000);
|
| | | if (s > 3600) {
|
| | | leftTime = s / 3600 + "小时";
|
| | | leftTime = "还剩" + leftTime;
|
| | | } else if (s >= 60) {
|
| | | leftTime = s / 60 + "分钟";
|
| | | leftTime = "还剩" + leftTime;
|
| | | } else if (s > 0) {
|
| | | leftTime = s + "秒";
|
| | | leftTime = "还剩" + leftTime;
|
| | | }
|
| | | }
|
| | | vo.setLeftTime(leftTime);
|
| | |
|
| | | if (userVIPInfo != null && userVIPInfo.getState() != null
|
| | | && userVIPInfo.getState() == UserVIPInfo.STATE_SUCCESS) { // VIP
|
| | | vo.setSuccessTime(TimeUtil.getGernalTime(userVIPInfo.getSuccessTime().getTime(), "yyyy.MM.dd"));
|
| | | vo.setConserveMoney(finishMoney);
|
| | | vo.setEarnMoney(rewardMoney);
|
| | | } else {
|
| | | BigDecimal rate = new BigDecimal("0.409");
|
| | | vo.setConserveMoney(MoneyBigDecimalUtil.mul2(finishMoney, rate));
|
| | | vo.setEarnMoney(MoneyBigDecimalUtil.mul2(rewardMoney, rate));
|
| | | }
|
| | | vo.setFinishMoney(hongBaoV2CountService.getRewardMoneyBySelf(uid));
|
| | |
|
| | | |
| | | List<Integer> list = new ArrayList<Integer>();
|
| | | list.add(BanLiShopOrder.STATE_SUCCESS);
|
| | | BigDecimal payMoney = new BigDecimal(userVipConfigService.getValueByKey("require_order_pay"));
|
| | |
|
| | | vo.setFinishTeam(hongBaoV2CountService.countValidOrderTeamUserByUid(uid, TimeUtil.convertDateToTemp(Constant.VIP_ONLINE_TIME), payMoney));
|
| | | vo.setFinishHongBao(banLiShopOrderService.countByUidAndState(uid, list));
|
| | |
|
| | | |
| | | // 区分老用户和新用户
|
| | | String limtDate = userVipConfigService.getValueByKey("vip_execute_time");
|
| | | Date executeDate = null;
|
| | | try {
|
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-mm-dd");
|
| | | executeDate = format.parse(limtDate);
|
| | | } catch (ParseException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | UserInfoExtra extra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (extra != null
|
| | | && (extra.getFirstLoginTime() == null || extra.getFirstLoginTime().getTime() < executeDate.getTime())) {
|
| | | vo.setLimitTeam(Long.parseLong(userVipConfigService.getValueByKey("require_invite_num_old_user")));
|
| | | } else {
|
| | | vo.setLimitTeam(Long.parseLong(userVipConfigService.getValueByKey("require_invite_num_new_user")));
|
| | | }
|
| | | vo.setLimitHongBao(Long.parseLong(userVipConfigService.getValueByKey("require_shop_buy")));
|
| | | vo.setLimitMoney(new BigDecimal(userVipConfigService.getValueByKey("require_fan_money")));
|
| | | vo.setLimitgoldCoin(Long.parseLong(userVipConfigService.getValueByKey("require_gold_coin")));
|
| | |
|
| | | GsonBuilder gsonBuilder = new GsonBuilder();
|
| | | gsonBuilder.registerTypeAdapter(BigDecimal.class, new JsonSerializer<BigDecimal>() {
|
| | | @Override
|
| | | public JsonElement serialize(BigDecimal value, Type theType, JsonSerializationContext context) {
|
| | | if (value == null) {
|
| | | return new JsonPrimitive("");
|
| | | } else {
|
| | | // 保留2位小数
|
| | | value = value.setScale(2);
|
| | | return new JsonPrimitive(value.toString());
|
| | | }
|
| | | }
|
| | | });
|
| | | Gson gson = gsonBuilder.create();
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("info", gson.toJson(vo));
|
| | | data.put("welfare", userVipConfigService.getValueByKey("vip_welfare"));
|
| | | if (!StringUtil.isNullOrEmpty(callback)) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(gson.toJson(vo))));
|
| | | } else {
|
| | | out.print(JsonUtil.loadTrueResult(gson.toJson(vo)));
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 开通VIP
|
| | | * |
| | | * @param callback
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "applyVip")
|
| | | public void applyVip(String callback, WXMPAcceptData acceptData, Long uid, PrintWriter out) {
|
| | | if (uid == null || uid <= 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | UserInfo userInfo = userInfoService.selectByPKey(uid);
|
| | | if (userInfo == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(1, "该用户不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | // 省钱 -自购产生返利
|
| | |
|
| | | List<Integer> list = new ArrayList<Integer>();
|
| | | list.add(BanLiShopOrder.STATE_SUCCESS);
|
| | | BigDecimal payMoney = new BigDecimal(userVipConfigService.getValueByKey("require_order_pay"));
|
| | |
|
| | | long finishTeam = hongBaoV2CountService.countValidOrderTeamUserByUid(uid, TimeUtil.convertDateToTemp(Constant.VIP_ONLINE_TIME), payMoney);
|
| | | long finishHongBao = banLiShopOrderService.countByUidAndState(uid, list);
|
| | | BigDecimal finishMoney = hongBaoV2CountService.getRewardMoneyBySelf(uid);
|
| | |
|
| | | long limitTeam = 0;
|
| | |
|
| | | // 区分老用户和新用户
|
| | | String limtDate = userVipConfigService.getValueByKey("vip_execute_time");
|
| | | Date executeDate = null;
|
| | | try {
|
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-mm-dd");
|
| | | executeDate = format.parse(limtDate);
|
| | | } catch (ParseException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | |
| | | UserInfoExtra extra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (extra != null
|
| | | && (extra.getFirstLoginTime() == null || extra.getFirstLoginTime().getTime() < executeDate.getTime())) {
|
| | | limitTeam = (Long.parseLong(userVipConfigService.getValueByKey("require_invite_num_old_user")));
|
| | | } else {
|
| | | limitTeam = (Long.parseLong(userVipConfigService.getValueByKey("require_invite_num_new_user")));
|
| | | }
|
| | | long limitHongBao = (Long.parseLong(userVipConfigService.getValueByKey("require_shop_buy")));
|
| | | BigDecimal limitMoney = (new BigDecimal(userVipConfigService.getValueByKey("require_fan_money")));
|
| | |
|
| | | if (finishTeam >= limitTeam && finishHongBao >= limitHongBao && finishMoney.compareTo(limitMoney) >= 0) {
|
| | | // 条件符合
|
| | | } else {
|
| | | if (!StringUtil.isNullOrEmpty(callback)) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("未达到开通条件")));
|
| | | } else {
|
| | | out.print(JsonUtil.loadFalseResult("未达到开通条件"));
|
| | | }
|
| | | return;
|
| | | }
|
| | | // 开通
|
| | | try {
|
| | | userVIPInfoService.applyVIP(uid);
|
| | | } catch (UserVIPInfoException e) {
|
| | | if (!StringUtil.isNullOrEmpty(callback)) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(e.getMsg())));
|
| | | } else {
|
| | | out.print(JsonUtil.loadFalseResult(e.getMsg()));
|
| | | }
|
| | | return;
|
| | | }
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(callback)) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult("已申请")));
|
| | | } else {
|
| | | out.print(JsonUtil.loadTrueResult("已申请"));
|
| | | }
|
| | | }
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.controller.wxmp.v1;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.lang.reflect.Type;
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Calendar;
|
| | | import java.util.Collections;
|
| | | import java.util.Comparator;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMethod;
|
| | | import org.yeshi.utils.BigDecimalUtil;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.google.gson.JsonElement;
|
| | | import com.google.gson.JsonPrimitive;
|
| | | import com.google.gson.JsonSerializationContext;
|
| | | import com.google.gson.JsonSerializer;
|
| | | import com.yeshi.fanli.dto.msg.MsgCommonDTO;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgAccountDetail;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgDeviceReadState;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgInviteDetail;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgMoneyDetail;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgOrderDetail;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgOrderDetail.MsgTypeOrderTypeEnum;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgOtherDetail;
|
| | | import com.yeshi.fanli.entity.bus.msg.UserMsgUnReadNum;
|
| | | import com.yeshi.fanli.entity.bus.msg.UserSystemMsg;
|
| | | import com.yeshi.fanli.entity.common.JumpDetailV2;
|
| | | import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
|
| | | import com.yeshi.fanli.service.inter.money.msg.MsgMoneyDetailService;
|
| | | import com.yeshi.fanli.service.inter.msg.MsgConfigService;
|
| | | import com.yeshi.fanli.service.inter.msg.MsgDeviceReadStateService;
|
| | | import com.yeshi.fanli.service.inter.msg.MsgOtherDetailService;
|
| | | import com.yeshi.fanli.service.inter.msg.UserMsgReadStateService;
|
| | | import com.yeshi.fanli.service.inter.msg.UserSystemMsgService;
|
| | | import com.yeshi.fanli.service.inter.order.msg.MsgOrderDetailService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.MsgInviteDetailService;
|
| | | import com.yeshi.fanli.service.inter.user.msg.MsgAccountDetailService;
|
| | | import com.yeshi.fanli.util.JumpDetailUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.account.UserUtil;
|
| | | import com.yeshi.fanli.util.annotation.RequestSerializableByKey;
|
| | | import com.yeshi.fanli.util.factory.msg.UserMsgVOFactory;
|
| | | import com.yeshi.fanli.vo.msg.UserCommonMsgVO;
|
| | | import com.yeshi.fanli.vo.msg.UserMsgCenter;
|
| | | import com.yeshi.fanli.vo.msg.UserMsgVO;
|
| | | import com.yeshi.fanli.vo.msg.UserSystemMsgVO;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Controller("WXMPUserMsgController")
|
| | | @RequestMapping("/wxmp/api/v1/msg")
|
| | | public class UserMsgController {
|
| | |
|
| | | @Resource
|
| | | private MsgOrderDetailService msgOrderDetailService;
|
| | |
|
| | | @Resource
|
| | | private MsgMoneyDetailService msgMoneyDetailService;
|
| | |
|
| | | @Resource
|
| | | private MsgInviteDetailService msgInviteDetailService;
|
| | |
|
| | | @Resource
|
| | | private MsgAccountDetailService msgAccountDetailService;
|
| | |
|
| | | @Resource
|
| | | private MsgOtherDetailService msgOtherDetailService;
|
| | |
|
| | | @Resource
|
| | | private UserMsgReadStateService userMsgReadStateService;
|
| | |
|
| | | @Resource
|
| | | private UserSystemMsgService userSystemMsgService;
|
| | |
|
| | | @Resource
|
| | | private JumpDetailV2Service jumpDetailV2Service;
|
| | |
|
| | | @Resource
|
| | | private MsgConfigService msgConfigService;
|
| | |
|
| | | @Resource
|
| | | private MsgDeviceReadStateService msgDeviceReadStateService;
|
| | |
|
| | |
|
| | | // 消息的类型
|
| | | final static String MSG_TYPE_ORDER = "order";
|
| | | final static String MSG_TYPE_MONEY = "money";
|
| | | final static String MSG_TYPE_ACCOUNT = "account";
|
| | | final static String MSG_TYPE_INVITE = "invite";
|
| | | final static String MSG_TYPE_OTHER = "other";
|
| | |
|
| | |
|
| | |
|
| | | /**
|
| | | * 消息列表
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param page
|
| | | * @param type
|
| | | * @param out
|
| | | */
|
| | | @RequestSerializableByKey(key = "#acceptData.device")
|
| | | @RequestMapping(value = "getMsgList", method = RequestMethod.POST)
|
| | | public void getMsgList(AcceptData acceptData, Long uid, PrintWriter out) {
|
| | | if (uid != null && uid == 0)
|
| | | uid = null;
|
| | | if (uid != null) {
|
| | | userSystemMsgService.syncSystemZNX(uid);
|
| | | }
|
| | |
|
| | | List<UserMsgCenter> listCenter = new ArrayList<>();
|
| | |
|
| | | // 单条消息
|
| | | List<UserCommonMsgVO> commonMsgList = new ArrayList<>();
|
| | |
|
| | | long currentTime = System.currentTimeMillis();
|
| | |
|
| | | // 板栗快省小助手
|
| | | MsgCommonDTO zhuShouMsg = msgConfigService.getZhuShouMsg();
|
| | | if (zhuShouMsg != null && zhuShouMsg.getShow() == true) {
|
| | | boolean read = false;
|
| | | MsgDeviceReadState state = msgDeviceReadStateService.getByDeviceAndPlatformAndType(
|
| | | UserCommonMsgVO.TYPE_ZHUSHOU, acceptData.getDevice(),
|
| | | acceptData.getPlatform().equalsIgnoreCase("android") ? 1 : 2);
|
| | | if (state != null && state.getReadTime() != null
|
| | | && zhuShouMsg.getUpdateTime().getTime() < state.getReadTime().getTime())
|
| | | read = true;
|
| | | // 查询是否已读
|
| | |
|
| | | if ((zhuShouMsg.getStartTime() != null && currentTime < zhuShouMsg.getStartTime().getTime())
|
| | | || (zhuShouMsg.getEndTime() != null && currentTime > zhuShouMsg.getEndTime().getTime())) {
|
| | | // 不显示
|
| | | } else {
|
| | | JSONObject params = null;
|
| | | if (StringUtil.isNullOrEmpty(zhuShouMsg.getParams())) {
|
| | | params = JSONObject.fromObject(zhuShouMsg.getParams());
|
| | | }
|
| | | JumpDetailV2 wxmpJumDetail = JumpDetailUtil.getWXMPJumDetail(zhuShouMsg.getJumpDetail(), params);
|
| | | |
| | | commonMsgList.add(new UserCommonMsgVO(zhuShouMsg.getIcon(), zhuShouMsg.getTitle(),
|
| | | zhuShouMsg.getUpdateTime(), UserCommonMsgVO.TYPE_ZHUSHOU, zhuShouMsg.getContent(), read,
|
| | | wxmpJumDetail, null, 0));
|
| | | |
| | | |
| | | }
|
| | | }
|
| | |
|
| | | // 2、消息区域
|
| | | if (uid != null && uid > 0) {
|
| | | int page = 1;
|
| | | List<UserMsgVO> list = new ArrayList<>();
|
| | | List<MsgOrderDetail> detailList = msgOrderDetailService.listMsgOrderDetail(uid, page);
|
| | | if (detailList != null && detailList.size() > 0) {
|
| | | for (MsgOrderDetail detail : detailList) {
|
| | | JSONObject params = new JSONObject();
|
| | | params.put("orderNo", detail.getOrderId());
|
| | | if (detail.getType() == MsgTypeOrderTypeEnum.share || detail.getType() == MsgTypeOrderTypeEnum.invite)
|
| | | params.put("orderHideNo", UserUtil.filterOrderId(detail.getOrderId()));
|
| | | |
| | | JumpDetailV2 wxmpJumDetail = JumpDetailUtil.getWXMPJumDetail(jumpDetailV2Service.getByTypeCache("order_search"), params);
|
| | | |
| | | UserMsgVO userMsgVO = UserMsgVOFactory.create(detail, wxmpJumDetail, params);
|
| | | userMsgVO.setType(MSG_TYPE_ORDER);
|
| | | list.add(userMsgVO);
|
| | | }
|
| | | }
|
| | |
|
| | | List<MsgMoneyDetail> detailList1 = msgMoneyDetailService.listMsgMoneyDetail(uid, page);
|
| | | if (detailList1 != null && detailList1.size() > 0) {
|
| | | for (MsgMoneyDetail detail : detailList1) {
|
| | | UserMsgVO userMsgVO = UserMsgVOFactory.create(detail);
|
| | | userMsgVO.setType(MSG_TYPE_MONEY);
|
| | | list.add(userMsgVO);
|
| | | }
|
| | | }
|
| | |
|
| | | List<MsgAccountDetail> detailList2 = msgAccountDetailService.listMsgAccountDetail(uid, page);
|
| | | if (detailList2 != null && detailList2.size() > 0) {
|
| | | for (MsgAccountDetail detail : detailList2) {
|
| | | UserMsgVO userMsgVO = UserMsgVOFactory.create(detail);
|
| | | userMsgVO.setType(MSG_TYPE_ACCOUNT);
|
| | | list.add(userMsgVO);
|
| | | }
|
| | | }
|
| | |
|
| | | List<MsgInviteDetail> detailList3 = msgInviteDetailService.listMsgInviteDetail(uid, page);
|
| | | if (detailList3 != null && detailList3.size() > 0) {
|
| | | for (MsgInviteDetail detail : detailList3) {
|
| | | UserMsgVO userMsgVO = UserMsgVOFactory.create(detail);
|
| | | if (userMsgVO != null) {
|
| | | userMsgVO.setType(MSG_TYPE_INVITE);
|
| | | list.add(userMsgVO);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | List<MsgOtherDetail> detailList4 = msgOtherDetailService.listMsgOtherDetail(uid, page);
|
| | | if (detailList4 != null && detailList4.size() > 0) {
|
| | | for (MsgOtherDetail detail : detailList4) {
|
| | | UserMsgVO userMsgVO = UserMsgVOFactory.create(detail);
|
| | | if (userMsgVO != null) {
|
| | | userMsgVO.setType(MSG_TYPE_OTHER);
|
| | | list.add(userMsgVO);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | if (list.size() > 0) {
|
| | | // 时间排序
|
| | | listSort(list);
|
| | |
|
| | | if (list.size() >= 20) {
|
| | | list = list.subList(0, 19);
|
| | | }
|
| | |
|
| | | for (UserMsgVO userMsgVO : list) {
|
| | | UserMsgCenter userMsgCenter = new UserMsgCenter();
|
| | | userMsgCenter.setUserMsg(userMsgVO);
|
| | | listCenter.add(userMsgCenter);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | GsonBuilder builder = new GsonBuilder();
|
| | | builder = getTimeDescJsonBuilder(builder);
|
| | | JSONObject root = new JSONObject();
|
| | |
|
| | | if (uid != null && uid > 0) {
|
| | | UserMsgUnReadNum num = userMsgReadStateService.getReadStateByUid(uid);
|
| | | UserSystemMsg usm = userSystemMsgService.getLatestUserSystemMsg(uid);
|
| | | if (usm != null) {
|
| | | UserSystemMsgVO userSystemMsgVO = new UserSystemMsgVO(usm.getId(), usm.getType().name(), usm.getSolved(), "系统消息", usm.getTitle(),
|
| | | usm.getTimeTag() == 1 ? "http://img.flqapp.com/resource/msg/icon_emergent.png" : "",
|
| | | "http://img.flqapp.com/resource/msg/icon_msg_system.png",
|
| | | getTimeDesc(new Date(), usm.getCreateTime()), num.getTypeSystem());
|
| | | |
| | | // TODO 跳转地址 |
| | | JSONObject params = new JSONObject();
|
| | | params.put("url", "http://apph5.yeshitv.com/special/1.0.9/jingXuanN_9.html?type=9_9");
|
| | | JumpDetailV2 wxmpJumDetail = JumpDetailUtil.getWXMPJumDetail(jumpDetailV2Service.getByTypeCache("web"), params);
|
| | | userSystemMsgVO.setJumpDetail(wxmpJumDetail);
|
| | | |
| | | root.put("systemMsg", userSystemMsgVO);
|
| | | }
|
| | | }
|
| | |
|
| | | root.put("list", builder.create().toJson(listCenter));
|
| | | root.put("commonList", builder.create().toJson(commonMsgList));
|
| | | root.put("count", listCenter.size());
|
| | | out.print(JsonUtil.loadTrueResult(root));
|
| | | }
|
| | |
|
| | | private static void listSort(List<UserMsgVO> list) {
|
| | | Collections.sort(list, new Comparator<UserMsgVO>() {
|
| | | @Override
|
| | | public int compare(UserMsgVO o1, UserMsgVO o2) {
|
| | | if (o1.getTime().getTime() > o2.getTime().getTime()) {
|
| | | return -1;
|
| | | } else if (o1 == o2) {
|
| | | return 0;
|
| | | } else {
|
| | | return 1;
|
| | | }
|
| | | }
|
| | | });
|
| | | }
|
| | | |
| | | private String getTimeDesc(Date nowDate, Date targetDate) {
|
| | | Calendar now = Calendar.getInstance();
|
| | | now.setTime(nowDate);
|
| | | if (TimeUtil.getGernalTime(targetDate.getTime(), "yyyy-MM-dd")
|
| | | .equalsIgnoreCase(TimeUtil.getGernalTime(now.getTimeInMillis(), "yyyy-MM-dd"))) {
|
| | | return "今天 " + TimeUtil.getGernalTime(targetDate.getTime(), "HH:mm");
|
| | | } else if (TimeUtil.getGernalTime(targetDate.getTime(), "yyyy-MM-dd")
|
| | | .equalsIgnoreCase(TimeUtil.getGernalTime(now.getTimeInMillis() - 1000 * 60 * 60 * 24L, "yyyy-MM-dd"))) {
|
| | | return "昨天 " + TimeUtil.getGernalTime(targetDate.getTime(), "HH:mm");
|
| | | } else {
|
| | | return TimeUtil.getGernalTime(targetDate.getTime(), "yyyy.MM.dd HH:mm");
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | private GsonBuilder getTimeDescJsonBuilder(GsonBuilder builder) {
|
| | | builder = builder.registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
|
| | | @Override
|
| | | public JsonElement serialize(Date value, Type theType, JsonSerializationContext context) {
|
| | | if (value == null) {
|
| | | return new JsonPrimitive("");
|
| | | } else {
|
| | | Calendar now = Calendar.getInstance();
|
| | | return new JsonPrimitive(getTimeDesc(new Date(now.getTimeInMillis()), value));
|
| | | }
|
| | | }
|
| | | }).registerTypeAdapter(BigDecimal.class, new JsonSerializer<BigDecimal>() {
|
| | | @Override
|
| | | public JsonElement serialize(BigDecimal value, Type theType, JsonSerializationContext context) {
|
| | | if (value == null) {
|
| | | return new JsonPrimitive("0");
|
| | | } else {
|
| | | return new JsonPrimitive(BigDecimalUtil.getWithNoZera(value).toString());
|
| | | }
|
| | | }
|
| | | });
|
| | |
|
| | | return builder;
|
| | | }
|
| | | |
| | | /**
|
| | | * 消息未读清理
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "setAllMsgRead", method = RequestMethod.POST)
|
| | | public void setAllMsgRead(AcceptData acceptData, Long uid, PrintWriter out) {
|
| | | msgDeviceReadStateService.setAllMsgRead(acceptData.getDevice(),
|
| | | "android".equalsIgnoreCase(acceptData.getPlatform()) ? 1 : 2);
|
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | |
|
| | | // 初始化读取状态
|
| | | msgDeviceReadStateService.initReadState(acceptData.getDevice(),
|
| | | "android".equalsIgnoreCase(acceptData.getPlatform()) ? 1 : 2, UserCommonMsgVO.TYPE_RECOMMEND);
|
| | | msgDeviceReadStateService.initReadState(acceptData.getDevice(),
|
| | | "android".equalsIgnoreCase(acceptData.getPlatform()) ? 1 : 2, UserCommonMsgVO.TYPE_ZHUSHOU);
|
| | |
|
| | | // 设置设备消息所有已读
|
| | | msgDeviceReadStateService.setAllMsgRead(acceptData.getDevice(),
|
| | | "android".equalsIgnoreCase(acceptData.getPlatform()) ? 1 : 2);
|
| | |
|
| | | UserMsgUnReadNum num = userMsgReadStateService.getReadStateByUid(uid);
|
| | | int totalNum = num.getTypeAccount() + num.getTypeInvite() + num.getTypeMoney() + num.getTypeOrder()
|
| | | + num.getTypeScore() + num.getTypeSystem() + num.getTypeOther();
|
| | | if (totalNum == 0) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "没有未读消息"));
|
| | | return;
|
| | | } else {
|
| | | userMsgReadStateService.setAllMsgRead(uid);
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(""));
|
| | | }
|
| | |
|
| | |
|
| | | }
|
| | |
| | | * @param uid 用户id
|
| | | * @return
|
| | | */
|
| | | public List<ESOrder> query(String key, String uid) {
|
| | | public List<ESOrder> query(String key, String uid, List<Integer> listPlatform) {
|
| | | List<ESOrder> list = new ArrayList<ESOrder>();
|
| | | // 商品名称匹配
|
| | | BoolQueryBuilder should1 = QueryBuilders.boolQuery().should(QueryBuilders.matchPhraseQuery("orderNo", key))
|
| | |
| | |
|
| | | // 查询创建
|
| | | SearchSourceBuilder sourceBuilder = new SearchSourceBuilder();
|
| | | sourceBuilder.query(QueryBuilders.boolQuery().must(should1).must(should2));
|
| | | |
| | | if (listPlatform == null || listPlatform.size() == 0) {
|
| | | sourceBuilder.query(QueryBuilders.boolQuery().must(should1).must(should2));
|
| | | } else {
|
| | | BoolQueryBuilder should3 = QueryBuilders.boolQuery();
|
| | | for (Integer platform: listPlatform) {
|
| | | should3.should(QueryBuilders.termQuery("platform", platform));
|
| | | }
|
| | | sourceBuilder.query(QueryBuilders.boolQuery().must(should1).must(should2).must(should3));
|
| | | }
|
| | |
|
| | | SearchRequest searchRequest = new SearchRequest();
|
| | | searchRequest.indices(getDocument(ESOrder.class));
|
| | |
| | | BigDecimal getRewardMoneyByDate(@Param("uid") Long uid, @Param("day")Integer dateType,
|
| | | @Param("type") Integer hbType, @Param("orderState") Integer orderState,
|
| | | @Param("orderNo") String orderNo, @Param("moneyState") Integer moneyState,
|
| | | @Param("source") Integer source,
|
| | | @Param("startTime") String startTime, @Param("endTime") String endTime);
|
| | | @Param("startTime") String startTime, @Param("endTime") String endTime,@Param("listSource") List<Integer> listSource);
|
| | | } |
| | |
| | | List<CommonOrderVO> listUserOrder(@Param("start") long start, @Param("count") int count, @Param("uid") Long uid,
|
| | | @Param("state") Integer state, @Param("type") Integer type, @Param("orderState") Integer orderState,
|
| | | @Param("orderNo") String orderNo, @Param("startTime") String startTime, @Param("endTime") String endTime,
|
| | | @Param("day") Integer day, @Param("source") Integer source);
|
| | | @Param("day") Integer day, @Param("listSource") List<Integer> listSource);
|
| | |
|
| | | /**
|
| | | * 统计用户订单 并订单号分组
|
| | |
| | | long countUserOrder(@Param("uid") Long uid, @Param("state") Integer state, @Param("type") Integer type,
|
| | | @Param("orderState") Integer orderState, @Param("orderNo") String orderNo,
|
| | | @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("day") Integer day,
|
| | | @Param("source") Integer source);
|
| | | @Param("listSource") List<Integer> listSource);
|
| | |
|
| | | /**
|
| | | * 判断部分失效状态
|
| | |
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | OrderCountVO getOrderCount(@Param("uid") Long uid, @Param("day")Integer day, @Param("source") Integer source);
|
| | | OrderCountVO getOrderCount(@Param("uid") Long uid, @Param("day")Integer day, @Param("listSource") List<Integer> listSource);
|
| | |
|
| | | /**
|
| | | * 昨日总订单-根据红包类型 自购 邀请 分享
|
| | |
| | | // 交易id
|
| | | @Field(index=true, store = true, type = FieldType.Text)
|
| | | private String tradeId;
|
| | | // 交易平台
|
| | | // 交易平台 (1淘宝 2京东 3拼多多)
|
| | | @Field(index=true, store = true, type = FieldType.Integer)
|
| | | private Integer platform;
|
| | |
|
| | |
| | | <!-- 订单号查询 -->
|
| | | <if test="orderNo != null and orderNo !='' ">AND co.co_order_no = #{orderNo}</if>
|
| | |
|
| | | <!-- 来源 -->
|
| | | <if test="source != null">AND co.co_source_type = #{source}</if>
|
| | | |
| | | <!-- 时间段筛选 -->
|
| | | <if test="startTime != null and startTime != '' ">
|
| | | AND <![CDATA[co.co_third_create_time >= #{startTime}]]>
|
| | |
| | | <if test="endTime != null and endTime != '' ">
|
| | | AND <![CDATA[co.co_third_create_time <= #{endTime}]]>
|
| | | </if>
|
| | | |
| | | <if test="listSource != null and listSource.size() > 0">
|
| | | <foreach collection="listSource" item="item" open="AND (" close=")" separator="or">
|
| | | co.co_source_type = #{item}
|
| | | </foreach>
|
| | | </if>
|
| | | </select>
|
| | |
|
| | |
|
| | |
| | | <!-- 订单号查询 --> |
| | | <if test="orderNo != null and orderNo !='' ">AND co.co_order_no = #{orderNo}</if> |
| | | <!-- 订单来源 --> |
| | | <if test="source != null">AND co.co_source_type = #{source}</if> |
| | | <if test="listSource != null and listSource.size() > 0"> |
| | | <foreach collection="listSource" item="item" open="AND (" close=")" separator="or"> |
| | | co.co_source_type = #{item} |
| | | </foreach> |
| | | </if> |
| | | GROUP BY co.`co_order_no`, co.`co_source_type` ORDER BY |
| | | co.co_third_create_time DESC LIMIT ${start},${count} |
| | | </select> |
| | |
| | | <!-- 订单号查询 --> |
| | | <if test="orderNo != null and orderNo !='' ">AND co.co_order_no = #{orderNo}</if> |
| | | <!-- 订单来源 --> |
| | | <if test="source != null">AND co.co_source_type = #{source}</if> |
| | | <if test="listSource != null and listSource.size() > 0"> |
| | | <foreach collection="listSource" item="item" open="AND (" close=")" separator="or"> |
| | | co.co_source_type = #{item} |
| | | </foreach> |
| | | </if> |
| | | GROUP BY co.`co_order_no`, co.`co_source_type` )A |
| | | </select> |
| | | <select id="listOrderGoodsInfo" resultMap="ResultMap" |
| | |
| | | '%Y%m'),DATE_FORMAT(co.`co_settle_time`, '%Y%m')) = 1 |
| | | </if> |
| | | <!-- 订单来源 --> |
| | | <if test="source != null and source != 0">AND co.co_source_type = #{source}</if> |
| | | <if test="listSource != null and listSource.size() > 0"> |
| | | <foreach collection="listSource" item="item" open="AND (" close=")" separator="or"> |
| | | co.co_source_type = #{item} |
| | | </foreach> |
| | | </if> |
| | | </sql> |
| | | <select id="getOrderCount" resultMap="OrderCountMap"> |
| | | SELECT sum(self) as self,sum(shared) as shared,sum(invite) as invite |
| | |
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoGoodsUpdateService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
|
| | | import com.yeshi.fanli.vo.brand.BrandInfoVO;
|
| | |
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | |
|
| | | // 文件路径
|
| | | String filePath = "/img/brand/" + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | String filePath = FilePathEnum.brand.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | // 执行上传
|
| | | String fileLink = COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
|
| | |
|
| | |
| | | import com.yeshi.fanli.dao.mybatis.user.SpreadImgMapper;
|
| | | import com.yeshi.fanli.entity.bus.invite.SpreadImg;
|
| | | import com.yeshi.fanli.service.inter.config.SpreadImgService;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | |
|
| | | @Service
|
| | | public class SpreadImgServiceImpl implements SpreadImgService {
|
| | |
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | |
|
| | | // 文件路径
|
| | | String filePath="/img/invite/"+UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | String filePath=FilePathEnum.invite.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | // 执行上传
|
| | | return COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public BigDecimal getRewardMoneyToCount(Long uid, Integer dateType, Integer hbType) {
|
| | | return hongBaoV2CountMapper.getRewardMoneyByDate(uid, dateType, hbType, null, null, null, null, null, null);
|
| | | public BigDecimal getRewardMoneyToCount(Long uid, Integer dateType, Integer hbType, List<Integer> listSource) {
|
| | | return hongBaoV2CountMapper.getRewardMoneyByDate(uid, dateType, hbType, null, null, null, null, null, listSource);
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | public BigDecimal getRewardMoneyByToSearch(Long uid, Integer dateType, Integer orderType, Integer orderState,
|
| | | String orderNo, Integer moneyState, Integer source, String startTime, String endTime) {
|
| | | return hongBaoV2CountMapper.getRewardMoneyByDate(uid, dateType, orderType, orderState, orderNo, moneyState, source,
|
| | | startTime, endTime);
|
| | | String orderNo, Integer moneyState, String startTime, String endTime, List<Integer> listSource) {
|
| | | return hongBaoV2CountMapper.getRewardMoneyByDate(uid, dateType, orderType, orderState, orderNo, moneyState, |
| | | startTime, endTime, listSource);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.cache.annotation.Cacheable;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.web.multipart.MultipartFile;
|
| | | import org.yeshi.utils.DateUtil;
|
| | |
| | | import com.yeshi.fanli.entity.dynamic.ArticleOfficial;
|
| | | import com.yeshi.fanli.exception.dynamic.ArticleOfficialException;
|
| | | import com.yeshi.fanli.service.inter.dynamic.ArticleOfficialService;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.vo.dynamic.ArticleVO;
|
| | |
|
| | |
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | |
|
| | | // 文件路径
|
| | | String filePath = "/img/article/" + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | String filePath = FilePathEnum.article.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | // 执行上传
|
| | | String fileLink = COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
|
| | |
|
| | |
| | | return articleOfficialDao.getById(id);
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public void updateReadNum(String id) {
|
| | | ArticleOfficial article = articleOfficialDao.getById(id);
|
| | | if (article != null) {
|
| | | Integer readNum = article.getReadNum();
|
| | | if (readNum == null) {
|
| | | readNum = 0;
|
| | | }
|
| | | article.setReadNum(readNum + 1);
|
| | | |
| | | Integer readNumReal = article.getReadNumReal();
|
| | | if (readNumReal == null) {
|
| | | readNumReal = 0;
|
| | | }
|
| | | article.setReadNumReal(readNumReal + 1);
|
| | | |
| | | articleOfficialDao.save(article);
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public List<ArticleOfficial> query(int start, int count, String key,Integer state) {
|
| | | return articleOfficialDao.query(start, count, key, state);
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | @Cacheable(value = "dynamicCache", key = "'queryValid-'+#start+'-'+#key")
|
| | | public List<ArticleVO> queryValid(int start, int count, String key) {
|
| | | return articleOfficialDao.queryValid(start, count, key);
|
| | | }
|
| | |
| | | import com.yeshi.fanli.service.inter.goods.TaoBaoClassService;
|
| | | import com.yeshi.fanli.service.inter.lable.LabelClassService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | @Service
|
| | |
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | |
|
| | | // 文件路径
|
| | | String filePath = "/img/GoodsClass/" + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | String filePath = FilePathEnum.goodsClass.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | // 执行上传
|
| | | String fileLink = COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
|
| | |
|
| | |
| | | String contentType = file.getContentType();
|
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | | // 上传文件相对位置
|
| | | String fileUrl = "ClassImg/" + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | String fileUrl = FilePathEnum.goodsClassOld.getPath()+ UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | |
|
| | | boolean deleteFile = true;
|
| | |
|
| | |
| | | import com.yeshi.fanli.service.inter.goods.TaoBaoClassService;
|
| | | import com.yeshi.fanli.service.inter.lable.LabelClassService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | @Service
|
| | |
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | |
|
| | | // 文件路径
|
| | | String filePath = "/img/GoodsSubClass/" + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | String filePath =FilePathEnum.goodsSubClass.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | // 执行上传
|
| | | String fileLink = COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
|
| | |
|
| | |
| | | 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.FilePathEnum;
|
| | | import com.yeshi.fanli.util.FileUtil;
|
| | | import com.yeshi.fanli.util.ImageUtil;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | |
| | | }
|
| | |
|
| | | FileUploadResult shareImgResult = COSManager.getInstance().uploadInputStream(shareImgInputStream,
|
| | | "sharegoods/share_" + uid + "_" + goods.getAuctionId() + "_" + System.currentTimeMillis() + ".png");
|
| | | FilePathEnum.shareGoods.getPath() + "share_" + uid + "_" + goods.getAuctionId() + "_" + System.currentTimeMillis() + ".png");
|
| | |
|
| | | if (shareImgResult == null || StringUtil.isNullOrEmpty(shareImgResult.getUrl())) {
|
| | | throw new ShareGoodsException(6, "分享图片保存失败");
|
| | |
| | | import com.yeshi.fanli.exception.homemodule.FloatADException;
|
| | | import com.yeshi.fanli.service.inter.help.HelpClassService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.AdActivityVersionControlService;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | @Service
|
| | |
| | | InputStream inputStream = file.getInputStream();
|
| | | String contentType = file.getContentType();
|
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | | String filePath ="/img/HelpClass/" + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | String filePath =FilePathEnum.helpClass.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | picture = COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
|
| | | }
|
| | |
|
| | |
| | | String contentType = file.getContentType();
|
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | |
|
| | | String filePath ="/img/HelpClass/" + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | String filePath =FilePathEnum.helpClass.getPath()+ UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | |
|
| | | /* 修改图片时,先删除已存在图片 */
|
| | | String picture = helpClass.getPicture();
|
| | |
| | | import com.yeshi.fanli.exception.homemodule.FloatADException;
|
| | | import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
|
| | | import com.yeshi.fanli.service.inter.homemodule.FloatADService;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | @Service
|
| | |
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | |
|
| | | // 文件路径
|
| | | String filePath="/img/FloatAD/"+UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | String filePath= FilePathEnum.floatAD.getPath() +UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | // 执行上传
|
| | | String fileLink= COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
|
| | |
|
| | |
| | | import com.yeshi.fanli.service.inter.goods.GoodsClassService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.HomeNavbarService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.SwiperBannerService;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | |
|
| | |
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | |
|
| | | // 文件路径
|
| | | String filePath="/img/HomeNavbar/"+UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | String filePath= FilePathEnum.homeNavbar.getPath() +UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | // 执行上传
|
| | | String fileLink= COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
|
| | |
|
| | |
| | | import com.yeshi.fanli.service.inter.homemodule.SpecialCardService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.SpecialPlaceService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.SpecialService;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | |
|
| | |
|
| | | @Service
|
| | |
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | |
|
| | | // 文件路径
|
| | | String filePath="/img/SpecialCard/"+UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | String filePath=FilePathEnum.specialCard.getPath() +UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | // 执行上传
|
| | | String fileLink= COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
|
| | |
|
| | |
| | | import com.yeshi.fanli.service.inter.homemodule.SpecialPlaceService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.SpecialService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.VersionUtil;
|
| | |
|
| | |
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | |
|
| | | // 文件路径
|
| | | String filePath = "/img/special/" + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | String filePath =FilePathEnum.special.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | // 执行上传
|
| | | String fileLink = COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
|
| | |
|
| | |
| | | import com.yeshi.fanli.entity.AppVersionInfo;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.AdActivityVersionControl;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.AdActivityVersionControl.AdActivityType;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.Special;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture;
|
| | | import com.yeshi.fanli.entity.common.JumpDetailV2;
|
| | | import com.yeshi.fanli.exception.banner.SwiperPictureException;
|
| | |
| | | import com.yeshi.fanli.service.inter.config.AppVersionService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.AdActivityVersionControlService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | @Service
|
| | |
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | |
|
| | | // 文件路径
|
| | | String filePath = "/img/swiperPic/" + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | String filePath = FilePathEnum.swiper.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | // 执行上传
|
| | | String fileLink = COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
|
| | |
|
| | |
| | | import com.yeshi.fanli.entity.common.AdminUser;
|
| | | import com.yeshi.fanli.exception.goods.quality.LabelException;
|
| | | import com.yeshi.fanli.service.inter.lable.LabelService;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | import jxl.Sheet;
|
| | |
| | | String contentType = file.getContentType();
|
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | | // 上传文件相对位置
|
| | | String fileUrl="LableImg/"+UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | String fileUrl=FilePathEnum.lable.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | |
|
| | | boolean deleteFile =true;
|
| | |
|
| | |
| | | public List<CommonOrderVO> listGroupOrderNoByUid(long start, int count, Long uid, Integer state, Integer type,
|
| | | Integer orderState, String orderNo, String startTime, String endTime, Integer dateType, Integer source)
|
| | | throws CommonOrderException {
|
| | | List<Integer> listSource = new ArrayList<>();
|
| | | if (source != null) {
|
| | | listSource.add(source);
|
| | | }
|
| | | |
| | | return commonOrderMapper.listUserOrder(start, count, uid, state, type, orderState, orderNo, startTime, endTime,
|
| | | dateType, source);
|
| | | dateType, listSource);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countGroupOrderNoByUid(Long uid, Integer state, Integer type, Integer orderState, String orderNo,
|
| | | String startTime, String endTime, Integer dateType, Integer source) throws CommonOrderException {
|
| | | String startTime, String endTime, Integer dateType, List<Integer> listSource) throws CommonOrderException {
|
| | | return commonOrderMapper.countUserOrder(uid, state, type, orderState, orderNo, startTime, endTime, dateType,
|
| | | source);
|
| | | listSource);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<CommonOrderVO> getOrderByUid(AcceptData acceptData, Integer page, Long uid, Integer state, Integer type,
|
| | | Integer orderState, String orderNo, String startTime, String endTime, Integer dateType, Integer source)
|
| | | Integer orderState, String orderNo, String startTime, String endTime, Integer dateType, List<Integer> listSource)
|
| | | throws CommonOrderException, Exception {
|
| | |
|
| | | int pageSize = Constant.PAGE_SIZE;
|
| | |
|
| | | List<CommonOrderVO> listOrder = listGroupOrderNoByUid((page - 1) * pageSize, pageSize, uid, state, type,
|
| | | orderState, orderNo, startTime, endTime, dateType, source);
|
| | | List<CommonOrderVO> listOrder = commonOrderMapper.listUserOrder((page - 1) * pageSize, pageSize, uid, state, type, |
| | | orderState, orderNo, startTime, endTime, dateType, listSource);
|
| | |
|
| | | // 订单信息为空
|
| | | if (listOrder == null || listOrder.size() == 0) {
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public OrderCountVO getOrderCount(Long uid, Integer day, Integer source) {
|
| | | return commonOrderMapper.getOrderCount(uid, day, source);
|
| | | public OrderCountVO getOrderCount(Long uid, Integer day, List<Integer> listSource) {
|
| | | return commonOrderMapper.getOrderCount(uid, day, listSource);
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | |
|
| | |
|
| | | @Override
|
| | | public List<ESOrder> query(String key, String uid) {
|
| | | return esOrderDao.query(key, uid);
|
| | | public List<ESOrder> query(String key, String uid, List<Integer> listPlatform) {
|
| | | return esOrderDao.query(key, uid, listPlatform);
|
| | | }
|
| | | }
|
| | |
| | | import com.yeshi.fanli.service.inter.shop.BanLiShopGoodsImgService;
|
| | | import com.yeshi.fanli.service.inter.shop.BanLiShopGoodsService;
|
| | | import com.yeshi.fanli.service.inter.shop.BanLiShopGoodsSetService;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | @Service
|
| | |
| | | String contentType = file.getContentType();
|
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | | // 文件路径
|
| | | String filePath="/img/BanLiShopGoods/"+UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | String filePath=FilePathEnum.banLiShopGoods.getPath() +UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | // 执行上传
|
| | | String fileLink= COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
|
| | | return fileLink;
|
| | |
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoShopService;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.db.MongoDBManager;
|
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
|
| | |
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | |
|
| | | // 文件路径
|
| | | String filePath = "/img/TaoBaoShop/" + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | String filePath = FilePathEnum.taoBaoShop.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | // 执行上传
|
| | | String fileLink = COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
|
| | |
|
| | |
| | | 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.tencentcloud.COSManager;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.share.ShareMapper;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.service.inter.user.QrCodeService;
|
| | | import com.yeshi.fanli.service.inter.user.SpreadUserImgService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | | import com.yeshi.fanli.util.FileUtil;
|
| | | import com.yeshi.fanli.util.ImageUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.UserInviteUtil;
|
| | | import com.yeshi.fanli.vo.goods.GoodsDetailVO;
|
| | |
|
| | | @Service
|
| | | public class QrCodeServiceImpl implements QrCodeService {
|
| | |
| | |
|
| | | String imgUrl = COSManager.getInstance()
|
| | | .uploadFile(new File(targetPath),
|
| | | "ercode/" + "ercode_" + uid + "_" + System.currentTimeMillis() + "_" + urlMd5 + ".jpg")
|
| | | FilePathEnum.ercode.getPath() + "ercode_" + uid + "_" + System.currentTimeMillis() + "_" + urlMd5 + ".jpg")
|
| | | .getUrl();
|
| | |
|
| | | if (new File(erCodeTempPath).exists())
|
| | |
| | | String newUrl = url.substring(index + 1);
|
| | | String urlMd5 = newUrl.substring(0, newUrl.lastIndexOf("."));
|
| | |
|
| | | String imgUrl = COSManager.getInstance()
|
| | | .uploadFile(new File(targetPath), "ercode/" + "ercode_" + uid + "_" + urlMd5 + ".jpg").getUrl();
|
| | | String imgUrl = COSManager.getInstance().uploadFile(new File(targetPath), |
| | | FilePathEnum.ercode.getPath() + "ercode_" + uid + "_" + urlMd5 + ".jpg").getUrl();
|
| | |
|
| | | if (new File(erCodeTempPath).exists())
|
| | | new File(erCodeTempPath).delete();
|
| | |
| | | if (new File(targetPath).exists() && new File(targetPath).length() > 0) {
|
| | | String fileUrl = null;
|
| | | if (uid == null) {
|
| | | fileUrl = "ercode/" + "ercode_" + uuid + "_" + System.currentTimeMillis() + "_" + urlMd5 + ".jpg";
|
| | | fileUrl = FilePathEnum.ercode.getPath() + "ercode_" + uuid + "_" + System.currentTimeMillis() + "_" + urlMd5 + ".jpg";
|
| | | } else {
|
| | | fileUrl = "ercode/" + "ercode_" + uid + "_" + System.currentTimeMillis() + "_" + urlMd5 + ".jpg";
|
| | | fileUrl = FilePathEnum.ercode.getPath() + "ercode_" + uid + "_" + System.currentTimeMillis() + "_" + urlMd5 + ".jpg";
|
| | | }
|
| | |
|
| | | // 上传文件
|
| | |
| | | // 上传文件相对位置
|
| | | String fileUrl = null;
|
| | | if (uid == null) {
|
| | | fileUrl = "ercode/" + "ercode_" + uuid + "_" + System.currentTimeMillis() + "_" + urlMd5 + ".jpg";
|
| | | fileUrl = FilePathEnum.ercode.getPath() + "ercode_" + uuid + "_" + System.currentTimeMillis() + "_" + urlMd5 + ".jpg";
|
| | | } else {
|
| | | fileUrl = "ercode/" + "ercode_" + uid + "_" + System.currentTimeMillis() + "_" + urlMd5 + ".jpg";
|
| | | fileUrl = FilePathEnum.ercode.getPath() + "ercode_" + uid + "_" + System.currentTimeMillis() + "_" + urlMd5 + ".jpg";
|
| | | }
|
| | |
|
| | | // 上传
|
| | |
| | | }
|
| | | return null;
|
| | | }
|
| | | |
| | | |
| | | |
| | | @Override
|
| | | public FileUploadResult drawGoodsPoster(String erCodeUrl, String portrait, GoodsDetailVO goods) {
|
| | | // 二维码流
|
| | | InputStream erCodeStream = null;
|
| | | try {
|
| | | erCodeStream = QRCodeUtil.getInstance(250).encode(erCodeUrl);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | |
| | | // 头像
|
| | | InputStream portraitStream = null; |
| | | if (!StringUtil.isNullOrEmpty(portrait)) {
|
| | | try {
|
| | | portraitStream = HttpUtil.getAsInputStream(portrait);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | if (portraitStream == null) {
|
| | | portraitStream = ImageUtil.class.getClassLoader().getResourceAsStream("image/official_default_head.jpg");
|
| | | }
|
| | | |
| | | // 画图
|
| | | InputStream drawStream = ImageUtil.drawGoodsShareSingle(erCodeStream, portraitStream, goods);
|
| | | // 上传位置
|
| | | String uuid = UUID.randomUUID().toString().replace("-", "");
|
| | | String upPath = FilePathEnum.shareXCX.getPath() + uuid + "_" + goods.getGoodsId() + "_" + System.currentTimeMillis() + ".png";
|
| | | // 上传文件
|
| | | return COSManager.getInstance().uploadInputStream(drawStream, upPath);
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public FileUploadResult drawGoodsPosterXCX(InputStream erCodeStream,UserInfo user, GoodsDetailVO goods) {
|
| | | // 画图
|
| | | InputStream drawStream = ImageUtil.drawGoodsShareXCX(erCodeStream, user, goods);
|
| | | // 上传位置
|
| | | String uuid = UUID.randomUUID().toString().replace("-", "");
|
| | | String upPath = FilePathEnum.shareXCX.getPath() + uuid + "_" + goods.getGoodsId() + "_" + System.currentTimeMillis() + ".png";
|
| | | // 上传文件
|
| | | return COSManager.getInstance().uploadInputStream(drawStream, upPath);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | import com.yeshi.fanli.service.inter.user.msg.UserAccountMsgNotificationService;
|
| | | import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | | import com.yeshi.fanli.util.FileUtil;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
| | | fw.close();
|
| | |
|
| | | String logUrl = COSManager.getInstance()
|
| | | .uploadFile(new File(logPath), "beifen/" + new File(logPath).getName()).getUrl();
|
| | | .uploadFile(new File(logPath), FilePathEnum.beifen.getPath() + new File(logPath).getName()).getUrl();
|
| | | return logUrl;
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | |
| | | InputStream asInputStream = HttpUtil.getAsInputStream(weiXinUser.getHeadimgurl());
|
| | | if (asInputStream != null) {
|
| | | FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream,
|
| | | String.format("/portrait/wx/%s_%s.jpg", weiXinUser.getUnionid(),
|
| | | String.format(FilePathEnum.userPortrait.getPath() + "%s_%s.jpg", weiXinUser.getUnionid(),
|
| | | System.currentTimeMillis() + ""));
|
| | | if (result != null && !StringUtil.isNullOrEmpty(result.getUrl()))
|
| | | portrait = result.getUrl();
|
| | |
| | | LogHelper.test("微信头像下载失败: " + weiXinUser.getUnionid() + " " + headimgurl);
|
| | | } else {
|
| | | FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream, String
|
| | | .format("/portrait/wx/%s_%s.jpg", weiXinUser.getUnionid(), System.currentTimeMillis() + ""));
|
| | | .format(FilePathEnum.userPortrait.getPath() + "%s_%s.jpg", weiXinUser.getUnionid(), System.currentTimeMillis() + ""));
|
| | | if (result != null && !StringUtil.isNullOrEmpty(result.getUrl())) {
|
| | | headimgurl = result.getUrl();
|
| | | } else {
|
| | |
| | | InputStream asInputStream = HttpUtil.getAsInputStream(weiXinUser.getHeadimgurl());
|
| | | if (asInputStream != null) {
|
| | | FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream, String
|
| | | .format("/portrait/wx/%s_%s.jpg", weiXinUser.getUnionid(), System.currentTimeMillis() + ""));
|
| | | .format(FilePathEnum.userPortrait.getPath() +"%s_%s.jpg", weiXinUser.getUnionid(), System.currentTimeMillis() + ""));
|
| | | if (result != null && !StringUtil.isNullOrEmpty(result.getUrl()))
|
| | | portrait = result.getUrl();
|
| | | } else {
|
| | |
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.exception.user.UserComplaintException;
|
| | | import com.yeshi.fanli.service.inter.user.UserComplaintService;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | |
|
| | |
| | | String contentType = file.getContentType();
|
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | | // 上传文件相对位置
|
| | | String fileUrl="/img/UserComplaint/"+UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | String fileUrl= FilePathEnum.userComplaint.getPath() +UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | |
|
| | | String uploadFilePath = COSManager.getInstance().uploadFile(inputStream, fileUrl).getUrl();
|
| | | array.add(uploadFilePath);
|
| | |
| | | import com.yeshi.fanli.service.inter.user.UserRankService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | | import com.yeshi.fanli.util.InviteCodeFilterUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.account.UserUtil;
|
| | |
| | | userInfoExtraMapper.insertSelective(userInfoExtra);
|
| | | }
|
| | |
|
| | | // 发送激活成功消息
|
| | | Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.inviteCodeActive,
|
| | | new Gson().toJson(new InviteCodeActiveMQMsg(uid, new Date())));
|
| | | producer.send(message);
|
| | | if (!Constant.IS_TEST) { // 发送激活成功消息
|
| | | Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.inviteCodeActive,
|
| | | new Gson().toJson(new InviteCodeActiveMQMsg(uid, new Date())));
|
| | | producer.send(message);
|
| | | }
|
| | |
|
| | | return mycode;
|
| | | }
|
| | |
| | | LogHelper.test("微信头像下载失败: " + weiXinUser.getUnionid() + " " + headimgurl);
|
| | | } else {
|
| | | FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream, String.format(
|
| | | "/portrait/wx/%s_%s.jpg", weiXinUser.getUnionid(), System.currentTimeMillis() + ""));
|
| | | FilePathEnum.userPortrait.getPath() + "%s_%s.jpg", weiXinUser.getUnionid(), System.currentTimeMillis() + ""));
|
| | | if (result != null && !StringUtil.isNullOrEmpty(result.getUrl())) {
|
| | | headimgurl = result.getUrl();
|
| | | } else {
|
| | |
| | | userInfoExtra.setCreateTime(new Date());
|
| | | userInfoExtraMapper.insertSelective(userInfoExtra);
|
| | | }
|
| | | // 发送激活成功消息
|
| | | Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.inviteCodeActive,
|
| | | new Gson().toJson(new InviteCodeActiveMQMsg(uid, new Date())));
|
| | | producer.send(message);
|
| | | |
| | | if (!Constant.IS_TEST) { // 发送激活成功消息
|
| | | Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.inviteCodeActive,
|
| | | new Gson().toJson(new InviteCodeActiveMQMsg(uid, new Date())));
|
| | | producer.send(message);
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | LogHelper.test("微信头像下载失败: " + weiXinUser.getUnionid() + " " + headimgurl);
|
| | | } else {
|
| | | FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream, String.format(
|
| | | "/portrait/wx/%s_%s.jpg", weiXinUser.getUnionid(), System.currentTimeMillis() + ""));
|
| | | FilePathEnum.userPortrait.getPath() + "%s_%s.jpg", weiXinUser.getUnionid(), System.currentTimeMillis() + ""));
|
| | | if (result != null && !StringUtil.isNullOrEmpty(result.getUrl())) {
|
| | | headimgurl = result.getUrl();
|
| | | } else {
|
| | |
| | | } else {
|
| | | userInfoExtra.setCreateTime(new Date());
|
| | | userInfoExtraMapper.insertSelective(userInfoExtra);
|
| | | }
|
| | | |
| | | if (!Constant.IS_TEST) { // 发送激活成功消息
|
| | | Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.inviteCodeActive,
|
| | | new Gson().toJson(new InviteCodeActiveMQMsg(uid, new Date())));
|
| | | producer.send(message);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | update.setInviteCodeVip(inviteCodeVip);
|
| | | update.setUpdateTime(new Date());
|
| | | userInfoExtraMapper.updateByPrimaryKeySelective(update);
|
| | | //发送邀请码更改成功的消息
|
| | | Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.userInfoUpdate,
|
| | | new Gson().toJson(new UserInfoUpdateMQMsg(uid, UserInfoUpdateTypeEnum.inviteCode, inviteCodeVip, new Date())));
|
| | | producer.send(message);
|
| | | |
| | | if(!Constant.IS_TEST) { //发送邀请码更改成功的消息
|
| | | Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_USER, UserTopicTagEnum.userInfoUpdate,
|
| | | new Gson().toJson(new UserInfoUpdateMQMsg(uid, UserInfoUpdateTypeEnum.inviteCode, inviteCodeVip, new Date())));
|
| | | producer.send(message);
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | |
| | | }
|
| | |
|
| | | // 执行上传
|
| | | String filePath = "/img/user/erCode/" + UUID.randomUUID().toString().replace("-", "") + ".jpg";
|
| | | String filePath = FilePathEnum.userERcode.getPath() + UUID.randomUUID().toString().replace("-", "") + ".jpg";
|
| | | String fileLink = COSManager.getInstance().uploadFile(new File(targetPath), filePath).getUrl();
|
| | |
|
| | | // 删除本地图片
|
| | |
| | | import com.yeshi.fanli.service.inter.user.tb.TaoBaoUnionAuthRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.ThreadUtil;
|
| | | import com.yeshi.fanli.util.account.UserUtil;
|
| | |
| | | UserInfo temp = userInfoMapper.selectByPrimaryKey(form.getId());
|
| | | COSManager cosManager = COSManager.getInstance();
|
| | | InputStream inputStream = HttpUtil.getAsInputStream(temp.getPortrait());
|
| | | String uploadFile = cosManager.uploadFile(inputStream, UUID.randomUUID().toString()).getUrl();
|
| | | String uploadFile = cosManager.uploadFile(inputStream, FilePathEnum.userPortrait.getPath() + UUID.randomUUID().toString()).getUrl();
|
| | | UserInfo updateTemp = new UserInfo(temp.getId());
|
| | | updateTemp.setPortrait(uploadFile);
|
| | | userInfoMapper.updateByPrimaryKeySelective(updateTemp);
|
| | |
| | | find.setWxUnionId(weiXinUser.getUnionid());
|
| | | String wxHeadImg = COSManager.getInstance()
|
| | | .uploadFile(HttpUtil.getAsInputStream(weiXinUser.getHeadimgurl()),
|
| | | Constant.WXHEADURL + UUID.randomUUID().toString())
|
| | | FilePathEnum.userPortrait.getPath() + UUID.randomUUID().toString())
|
| | | .getUrl();
|
| | | find.setPortrait(wxHeadImg);
|
| | | find.setWxPic(wxHeadImg);
|
| | |
| | | Thumbnails.of(file.getInputStream()).size(200, 200).toFile(targetPath);
|
| | |
|
| | | // 执行上传
|
| | | String filePath = "/img/user/" + UUID.randomUUID().toString().replace("-", "") + ".jpg";
|
| | | String filePath =FilePathEnum.userPortrait.getPath() + UUID.randomUUID().toString().replace("-", "") + ".jpg";
|
| | | String fileLink = COSManager.getInstance().uploadFile(new File(targetPath), filePath).getUrl();
|
| | |
|
| | | // 删除本地图片
|
| | |
| | | userInfoMapper.updateByPrimaryKeySelective(userInfo);
|
| | |
|
| | | // 删除原头像
|
| | | if (!StringUtil.isNullOrEmpty(portrait) && portrait.contains("/img/user/")) {
|
| | | if (!StringUtil.isNullOrEmpty(portrait)) {
|
| | | COSManager.getInstance().deleteFile(portrait);
|
| | | }
|
| | |
|
| | |
| | | import com.yeshi.fanli.exception.user.UserRankingsException;
|
| | | import com.yeshi.fanli.service.inter.count.HongBaoV2CountService;
|
| | | import com.yeshi.fanli.service.inter.user.UserRankingsService;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.vo.order.HongBaoV2VO;
|
| | |
|
| | |
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | |
|
| | | // 上传文件相对位置
|
| | | String fileUrl = "userRankings/" + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | String fileUrl = FilePathEnum.userRankings.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | |
|
| | | InputStream inputStream = file.getInputStream();
|
| | | String uploadFilePath = COSManager.getInstance().uploadFile(inputStream, fileUrl).getUrl();
|
| | |
| | | System.out.println("name" + name);
|
| | | String prefix = name.substring(name.lastIndexOf(".") + 1);
|
| | | // 上传文件相对位置
|
| | | String fileUrl = "userRankings/" + UUID.randomUUID().toString().replace("-", "") + "." + prefix;
|
| | | String fileUrl = FilePathEnum.userRankings.getPath() + UUID.randomUUID().toString().replace("-", "") + "." + prefix;
|
| | | System.out.println(fileUrl);
|
| | |
|
| | | FileInputStream is = new FileInputStream(filePic);
|
| | |
| | | import com.yeshi.fanli.service.inter.user.integral.IntegralGetService;
|
| | | import com.yeshi.fanli.util.AESUtil;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | | import com.yeshi.fanli.util.ImageUtil;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
| | |
|
| | | @Resource
|
| | | private IntegralGetService integralGetService;
|
| | | |
| | |
|
| | | @Override
|
| | | public int insert(UserShareGoodsRecord record) {
|
| | |
| | | InputStream inputStream = ImageUtil.drawGoodsShareBigImg(erCodeInputStream, portrait, listGoods);
|
| | |
|
| | | FileUploadResult shareImg = COSManager.getInstance().uploadInputStream(inputStream,
|
| | | "sharegoods/share_" + uid + "_" + shareId + "_" + System.currentTimeMillis() + ".png");
|
| | | FilePathEnum.shareGoods.getPath() + "share_" + uid + "_" + shareId + "_" + System.currentTimeMillis() + ".png");
|
| | |
|
| | | return shareImg;
|
| | | }
|
| | |
| | |
|
| | | InputStream inputStream = ImageUtil.drawGoodsSharePicture(erCodeInputStream, portrait, listGoods);
|
| | | FileUploadResult shareImg = COSManager.getInstance().uploadInputStream(inputStream,
|
| | | "sharegoods/share_" + uid + "_" + shareId + "_" + System.currentTimeMillis() + ".png");
|
| | | FilePathEnum.shareGoods.getPath() + "share_" + uid + "_" + shareId + "_" + System.currentTimeMillis() + ".png");
|
| | |
|
| | | return shareImg;
|
| | | }
|
| | | |
| | | @Override
|
| | | public void saveShareRecord(Long uid, CommonGoods goods) throws UserShareGoodsRecordException {
|
| | | if (goods == null || uid == null) {
|
| | | throw new UserShareGoodsRecordException(1, "参数缺失");
|
| | | }
|
| | |
|
| | | UserShareGoodsRecord userShareGoodsRecord = new UserShareGoodsRecord();
|
| | | userShareGoodsRecord.setShareState(1);
|
| | | userShareGoodsRecord.setUid(uid);
|
| | | userShareGoodsRecord.setSource(ShareSourceTypeEnum.goodsDetail);
|
| | | CommonGoods resultCommonGoods = null;
|
| | | try {
|
| | | resultCommonGoods = commonGoodsService.addOrUpdateCommonGoods(goods);
|
| | | } catch (CommonGoodsException e) {
|
| | | throw new UserShareGoodsRecordException(1, "商品存入失败");
|
| | | }
|
| | |
|
| | | UserShareGoodsGroup singleGoods = userShareGoodsGroupService.getSingleGoods(resultCommonGoods.getId(),uid);
|
| | | if (singleGoods != null) {
|
| | | // 单个商品多次分享
|
| | | userShareGoodsRecord.setPicture(resultCommonGoods.getPicture());
|
| | | userShareGoodsRecord.setId(singleGoods.getRecordId());
|
| | | userShareGoodsRecord.setUpdateTime(new Date());
|
| | | userShareGoodsRecordMapper.updateByPrimaryKeySelective(userShareGoodsRecord);
|
| | |
|
| | | // 最新商品
|
| | | singleGoods.setUpdateTime(new Date());
|
| | | userShareGoodsGroupService.updateByPrimaryKeySelective(singleGoods);
|
| | | } else {
|
| | | // 单个商品第一次分享
|
| | | Date date = new Date();
|
| | | userShareGoodsRecord.setPicture(resultCommonGoods.getPicture());
|
| | | userShareGoodsRecord.setCreateTime(date);
|
| | | userShareGoodsRecord.setUpdateTime(date);
|
| | | userShareGoodsRecordMapper.insertSelective(userShareGoodsRecord);
|
| | |
|
| | | singleGoods = new UserShareGoodsGroup();
|
| | | singleGoods.setTotalOrder(0);
|
| | | singleGoods.setTotalBrowse(0);
|
| | | singleGoods.setTodayBrowse(0);
|
| | | singleGoods.setTotalMoney(new BigDecimal(0));
|
| | | singleGoods.setCreateTime(date);
|
| | | singleGoods.setUpdateTime(date);
|
| | | singleGoods.setCommonGoods(resultCommonGoods);
|
| | | singleGoods.setRecordId(userShareGoodsRecord.getId());
|
| | | userShareGoodsGroupService.insertSelective(singleGoods);
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | |
| | | }
|
| | |
| | | * @param hbType
|
| | | * @return
|
| | | */
|
| | | public BigDecimal getRewardMoneyToCount(Long uid, Integer dateType, Integer hbType);
|
| | | public BigDecimal getRewardMoneyToCount(Long uid, Integer dateType, Integer hbType, List<Integer> listSource);
|
| | |
|
| | | /**
|
| | | * 统计红包个数
|
| | |
| | | * @return
|
| | | */
|
| | | public BigDecimal getRewardMoneyByToSearch(Long uid, Integer dateType, Integer hbType, Integer orderState, String orderNo,
|
| | | Integer moneyState, Integer source, String startTime, String endTime); |
| | | Integer moneyState, String startTime, String endTime, List<Integer> listSource); |
| | |
|
| | | }
|
| | |
| | |
|
| | | public void deleteBatchByPrimaryKey(List<String> list);
|
| | |
|
| | | public void updateReadNum(String id);
|
| | |
|
| | | }
|
| | |
| | | * @throws CommonOrderException
|
| | | */
|
| | | long countGroupOrderNoByUid(Long uid, Integer state, Integer type, Integer orderState, String orderNo,
|
| | | String startTime, String endTime, Integer dateType, Integer source) throws CommonOrderException;
|
| | | String startTime, String endTime, Integer dateType, List<Integer> listSource) throws CommonOrderException;
|
| | |
|
| | | /**
|
| | | * 移动段订单列表
|
| | |
| | | * @return
|
| | | */
|
| | | public List<CommonOrderVO> getOrderByUid(AcceptData acceptData, Integer page, Long uid, Integer state, Integer type,
|
| | | Integer orderState, String orderNo, String startTime, String endTime, Integer dateType, Integer source)
|
| | | Integer orderState, String orderNo, String startTime, String endTime, Integer dateType, List<Integer> listSource)
|
| | | throws CommonOrderException,Exception;
|
| | |
|
| | | /**
|
| | |
| | | * @param source
|
| | | * @return
|
| | | */
|
| | | public OrderCountVO getOrderCount(Long uid, Integer day, Integer source);
|
| | | public OrderCountVO getOrderCount(Long uid, Integer day, List<Integer> listSource);
|
| | |
|
| | | /**
|
| | | * 搜索订单信息
|
| | |
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | List<ESOrder> query(String key, String uid);
|
| | | List<ESOrder> query(String key, String uid, List<Integer> listPlatform);
|
| | |
|
| | |
|
| | | }
|
| | |
| | | import java.io.InputStream;
|
| | | import java.util.Date;
|
| | |
|
| | | import org.yeshi.utils.entity.FileUploadResult;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.vo.goods.GoodsDetailVO;
|
| | |
|
| | | public interface QrCodeService {
|
| | |
|
| | | String getPortrait(Long uid);
|
| | |
| | | * @throws IOException
|
| | | */
|
| | | public String drawInviteQrCodeNew(InputStream urlInputStream,String urlMd5, Long uid, String portrait, Integer pX, Integer pY, Integer size, String inviteCode) throws IOException;
|
| | |
|
| | | /**
|
| | | * 分享商品海报图
|
| | | * @param urlInputStream
|
| | | * @param erCodeUrl
|
| | | * @param uid
|
| | | * @param portrait
|
| | | * @param goods
|
| | | * @return
|
| | | */
|
| | | public FileUploadResult drawGoodsPoster(String erCodeUrl, String portrait,GoodsDetailVO goods);
|
| | |
|
| | | /**
|
| | | * 分享小程序名片
|
| | | * @param erCodeStream
|
| | | * @param user
|
| | | * @param goods
|
| | | * @return
|
| | | */
|
| | | public FileUploadResult drawGoodsPosterXCX(InputStream erCodeStream, UserInfo user, GoodsDetailVO goods);
|
| | | }
|
| | |
| | |
|
| | | public ShareGoodsRecordDTO addRecordGoodsStorageV2(Long uid, List<CommonGoods> listCommonGoods,
|
| | | List<Long> listStorageID,boolean needDrawPicture) throws UserShareGoodsRecordException;
|
| | |
|
| | | /**
|
| | | * 创建分享记录
|
| | | * @param uid
|
| | | * @param goods
|
| | | * @throws UserShareGoodsRecordException
|
| | | */
|
| | | public void saveShareRecord(Long uid, CommonGoods goods) throws UserShareGoodsRecordException;
|
| | |
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.util;
|
| | |
|
| | | public enum FilePathEnum {
|
| | | userPortrait("/img/user/", "用户头像"), // -- /portrait/wx/ -- /wx/headImg/
|
| | | userERcode("/img/user/erCode/", "用户上传微信二维码"),
|
| | | userComplaint("/img/UserComplaint/", "用户吐槽图片"),
|
| | | userRankings("/userRankings/", "奖金排行榜假用户头像"),
|
| | | beifen("/beifen/", ""), |
| | | activityUserPortrait("/img/GoodsSubClass/", "活动用户头像"),
|
| | | apk("/apk/admin/", "上传Apk安装包"), // -- /img/admin/
|
| | | section("/section/", "后台上传图片路径"), // -- /img/admin/
|
| | | |
| | | shareGoods("/sharegoods/", "分享商品图片"),
|
| | | shareXCX("/sharegoods/xcx/", "分享小程序图片"),
|
| | | ercode("/ercode/", "分享邀请图二维码图片"),
|
| | | invite("/img/invite/", "分享邀请好友图片"),
|
| | | |
| | | helpClass("/img/HelpClass/", "帮助中心分类图片"),
|
| | | goodsClassOld("/ClassImg/", "商品一级分类图片-老版"),
|
| | | goodsClass("/img/GoodsClass/", "商品一级分类图片"),
|
| | | goodsSubClass("/img/GoodsSubClass/", "商品二级以下分类图片"),
|
| | | lable("/LableImg/", "标签图片"),
|
| | | taoBaoShop("/img/TaoBaoShop/", "淘宝店铺图片"),
|
| | | |
| | | brand("/img/brand/", "品牌图片"),
|
| | | article("/img/article/", "学院文章图片"),
|
| | | floatAD("/img/FloatAD/", "首页弹框图片"),
|
| | | homeNavbar("/img/HomeNavbar/", "导航栏图片"),
|
| | | specialCard("/img/SpecialCard/", "专题管理图片"),
|
| | | special("/img/special/", "专题图片"),
|
| | | swiper("/img/swiperPic/", "轮播图片"),
|
| | | banLiShopClass("/img/shopGoodsClass/", "板栗商城分类图片"),
|
| | | banLiShopGoods("/img/BanLiShopGoods/", "板栗商城商品图片");
|
| | | |
| | |
|
| | | private final String path;
|
| | | private final String desc;
|
| | |
|
| | | private FilePathEnum(String path, String desc) {
|
| | | this.path = path;
|
| | | this.desc = desc;
|
| | | }
|
| | |
|
| | | public String getDesc() {
|
| | | return desc;
|
| | | }
|
| | |
|
| | | public String getPath() {
|
| | | return path;
|
| | | }
|
| | | }
|
| | |
| | | import org.yeshi.utils.entity.DateInfo;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.activity.RecommendActivityTaoBaoGoods;
|
| | | 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.log.LogHelper;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.vo.goods.GoodsDetailVO;
|
| | |
|
| | | public class ImageUtil {
|
| | |
|
| | | // 画商品分享图
|
| | | public static InputStream drawGoodsShareXCX(InputStream qrcode, UserInfo user, GoodsDetailVO goods) {
|
| | | try {
|
| | | 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";
|
| | | }
|
| | | Font font24 = Font.createFont(Font.PLAIN, new File(fontPath)).deriveFont(24.0f);
|
| | | Font font26 = Font.createFont(Font.PLAIN, new File(fontPath)).deriveFont(26.0f);
|
| | | Font boldFont36 = Font.createFont(Font.PLAIN, new File(fontBoldPath)).deriveFont(36.0f);
|
| | |
|
| | | int px = 640; // 图片宽度
|
| | | int py = 1061; // 图片高度
|
| | | final BufferedImage targetImg = new BufferedImage(px, py, 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, px, py);
|
| | |
|
| | | int x = 640;
|
| | | int y = 640;
|
| | | int spacing = 20; // 右边距
|
| | |
|
| | | // 1、画商品主图
|
| | | InputStream picStream = HttpUtil.getAsInputStream(goods.getPicUrl().replace("https://", "http://"));
|
| | | g2d.drawImage(ImageIO.read(picStream), 0, 0, x, y, null);
|
| | |
|
| | | // 2、画来源图标
|
| | | int length = 10;
|
| | | int row1 = 260;
|
| | | int iconWidth = 72;
|
| | | String source = "";
|
| | | InputStream icon = null;
|
| | | int goodsType = goods.getGoodsType();
|
| | | if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | source = "淘宝";
|
| | | if (goods.getShopType() == 10) {
|
| | | icon = ImageUtil.class.getClassLoader().getResourceAsStream("image/icon_tb.png");
|
| | | } else {
|
| | | icon = ImageUtil.class.getClassLoader().getResourceAsStream("image/icon_tm.png");
|
| | | }
|
| | | } else if (goodsType == Constant.SOURCE_TYPE_JD) {
|
| | | source = "京东";
|
| | | icon = ImageUtil.class.getClassLoader().getResourceAsStream("image/icon_jd.png");
|
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) {
|
| | | source = "拼多多";
|
| | | length = 9;
|
| | | row1 = row1 - 26;
|
| | | iconWidth = iconWidth + 28;
|
| | | icon = ImageUtil.class.getClassLoader().getResourceAsStream("image/icon_pdd.png");
|
| | | } else {
|
| | | return null;
|
| | | }
|
| | | g2d.drawImage(ImageIO.read(icon), spacing, y + 20, iconWidth, 34, null);
|
| | |
|
| | | // 3、商品标题内容
|
| | | int row = 0;
|
| | | String title = goods.getTitle();
|
| | | length = ImageUtil.getTextLengthByWidth(g2d, font26, title, row1, length);
|
| | | g2d.setFont(font26);
|
| | | g2d.setColor(new Color(0, 0, 0));
|
| | | g2d.drawString(title.substring(0, length), spacing + iconWidth + 5, y + 45 + row * 36);
|
| | |
|
| | | title = title.substring(length);
|
| | | row++;
|
| | | // 判断标题内容是否画完,最多可画三行
|
| | | while (title.length() > 0 && row < 3) {
|
| | | length = ImageUtil.getTextLengthByWidth(g2d, font26, title, 320, 11);
|
| | | g2d.drawString(title.substring(0, length), spacing, y + 45 + row * 36);
|
| | | title = title.substring(length);
|
| | | row++;
|
| | | }
|
| | |
|
| | | if (!goods.isHasCoupon()) {
|
| | | // 无券
|
| | | g2d.setColor(new Color(229, 0, 92));
|
| | | g2d.drawString("¥ ", spacing, y + 175);
|
| | | g2d.setFont(boldFont36);
|
| | | g2d.drawString(MoneyBigDecimalUtil.getWithNoZera(goods.getZkPrice()).toString(), spacing + 21, y + 175);
|
| | | } else {
|
| | | // 券后价
|
| | | g2d.setFont(font26);
|
| | | g2d.setColor(new Color(229, 0, 92));
|
| | | g2d.drawString("券后价 ¥ ", spacing, y + 175);
|
| | | g2d.setFont(boldFont36);
|
| | | g2d.drawString(MoneyBigDecimalUtil.getWithNoZera(goods.getCouponPrice()).toString(), spacing + 116,
|
| | | y + 175);
|
| | |
|
| | | // 渠道原价
|
| | | g2d.setColor(new Color(153, 153, 153));
|
| | | g2d.setFont(font24);
|
| | | g2d.drawString(goods.getPriceName() + " ¥ " + MoneyBigDecimalUtil.getWithNoZera(goods.getZkPrice()),
|
| | | spacing, y + 210);
|
| | |
|
| | | // 券字
|
| | | InputStream quan = ImageUtil.class.getClassLoader().getResourceAsStream("image/icon_quan.png");
|
| | | g2d.drawImage(ImageIO.read(quan), spacing, y + 240, 47, 40, null);
|
| | | // 券面额
|
| | | String quanAmount = "¥ " + goods.getCouponInfo().getAmount();
|
| | | FontMetrics fm = g2d.getFontMetrics(font26);
|
| | | int textLength = fm.stringWidth(quanAmount);
|
| | |
|
| | | g2d.setFont(font26);
|
| | | g2d.setColor(new Color(229, 0, 92));
|
| | | g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
| | | g2d.drawRoundRect(spacing + 42, y + 240, textLength + 20, 39, 10, 10);
|
| | | g2d.drawString(quanAmount, spacing + 55, y + 270);
|
| | |
|
| | | }
|
| | |
|
| | | // 自营 、包邮
|
| | | if (goods.getShopType() == 21) {
|
| | | InputStream ziying = ImageUtil.class.getClassLoader().getResourceAsStream("image/icon_ziying.png");
|
| | | g2d.drawImage(ImageIO.read(ziying), spacing + 300, y + 150, 60, 30, null);
|
| | | } else if (goods.isBaoyou()) {
|
| | | InputStream ziying = ImageUtil.class.getClassLoader().getResourceAsStream("image/icon_baoyou.png");
|
| | | g2d.drawImage(ImageIO.read(ziying), spacing + 300, y + 150, 60, 30, null);
|
| | | }
|
| | |
|
| | | // 销量
|
| | | String sale = null;
|
| | | int salesType = goods.getSalesType();
|
| | | if (salesType == 1) {
|
| | | sale = "月销";
|
| | | } else if (salesType == 2) {
|
| | | sale = "2小时销量";
|
| | | } else if (salesType == 3) {
|
| | | sale = "今日销量";
|
| | | } else if (salesType == 4) {
|
| | | sale = "总销量";
|
| | | } else {
|
| | | sale = "月销";
|
| | | }
|
| | | sale = sale + " " + goods.getSalesCount();
|
| | | FontMetrics fm = g2d.getFontMetrics(font24);
|
| | | int textLength = fm.stringWidth(sale);
|
| | | g2d.setFont(font24);
|
| | | g2d.setColor(new Color(153, 153, 153));
|
| | | g2d.drawString(sale, spacing + 360 - textLength, y + 210);
|
| | |
|
| | | // 二维码图框
|
| | | g2d.setColor(Color.WHITE);
|
| | | InputStream codeFrame = ImageUtil.class.getClassLoader().getResourceAsStream("image/share/qr_code_frame_xcx.png");
|
| | | g2d.drawImage(ImageIO.read(codeFrame), spacing + 405, y + 20, 200, 220, null);
|
| | | // 画二维码
|
| | | int codeSize = 170;
|
| | | g2d.drawImage(ImageIO.read(qrcode), spacing + 420, y + 38, codeSize, codeSize, null);
|
| | |
|
| | | // 头像
|
| | | InputStream portraitStream = null;
|
| | | try {
|
| | | portraitStream = HttpUtil.getAsInputStream(user.getPortrait());
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | |
| | | if (portraitStream == null) {
|
| | | portraitStream = ImageUtil.class.getClassLoader().getResourceAsStream("image/official_default_head.jpg");
|
| | | }
|
| | | BufferedImage portraitImg = ImageIO.read(portraitStream);
|
| | | BufferedImage zoomInImage = ImageUtil.zoomInImage(portraitImg, 84, 84);
|
| | | BufferedImage roundImage = ImageUtil.roundImage(zoomInImage, 84);
|
| | | g2d.drawImage(roundImage, spacing, y + 310, 84, 84, null);
|
| | |
|
| | | g2d.setFont(font24);
|
| | | g2d.setColor(new Color(0, 0, 0));
|
| | | g2d.drawString(user.getNickName(), spacing + 84 + 17, y + 335);
|
| | |
|
| | | g2d.setFont(font24);
|
| | | g2d.setColor(new Color(153, 153, 153));
|
| | | g2d.drawString(source + "商品99%都有优惠或返利", spacing + 84 + 17, y + 385);
|
| | |
|
| | | g2d.dispose();
|
| | |
|
| | | ByteArrayOutputStream aos = new ByteArrayOutputStream();
|
| | | ImageIO.write(targetImg, "JPEG", aos);
|
| | | return new ByteArrayInputStream(aos.toByteArray());
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 单个商品分享图
|
| | | * |
| | | * @param qrcode 二维码流
|
| | | * @param portrait 头像流
|
| | | * @param goods 商品信息
|
| | | * @return
|
| | | */
|
| | | public static InputStream drawGoodsShareSingle(InputStream qrcode, InputStream portrait, GoodsDetailVO goods) {
|
| | | try {
|
| | | 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";
|
| | | }
|
| | | Font font24 = Font.createFont(Font.PLAIN, new File(fontPath)).deriveFont(24.0f);
|
| | | Font font26 = Font.createFont(Font.PLAIN, new File(fontPath)).deriveFont(26.0f);
|
| | | Font boldFont36 = Font.createFont(Font.PLAIN, new File(fontBoldPath)).deriveFont(36.0f);
|
| | |
|
| | | int px = 640; // 图片宽度
|
| | | int py = 1061; // 图片高度
|
| | | if (!goods.isHasCoupon()) {
|
| | | py = py - 131;
|
| | | }
|
| | |
|
| | | final BufferedImage targetImg = new BufferedImage(px, py, 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, px, py);
|
| | |
|
| | | int x = 640;
|
| | | int y = 640;
|
| | | int spacing = 20; // 右边距
|
| | |
|
| | | // 1、画商品主图
|
| | | InputStream picStream = HttpUtil.getAsInputStream(goods.getPicUrl().replace("https://", "http://"));
|
| | | g2d.drawImage(ImageIO.read(picStream), 0, 0, x, y, null);
|
| | |
|
| | | // 2、画来源图标
|
| | | int length = 10;
|
| | | int row1 = 260;
|
| | | int iconWidth = 72;
|
| | | InputStream icon = null;
|
| | | int goodsType = goods.getGoodsType();
|
| | | if (goodsType == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | if (goods.getShopType() == 10) {
|
| | | icon = ImageUtil.class.getClassLoader().getResourceAsStream("image/icon_tb.png");
|
| | | } else {
|
| | | icon = ImageUtil.class.getClassLoader().getResourceAsStream("image/icon_tm.png");
|
| | | }
|
| | | } else if (goodsType == Constant.SOURCE_TYPE_JD) {
|
| | | icon = ImageUtil.class.getClassLoader().getResourceAsStream("image/icon_jd.png");
|
| | | } else if (goodsType == Constant.SOURCE_TYPE_PDD) {
|
| | | length = 9;
|
| | | row1 = row1 - 26;
|
| | | iconWidth = iconWidth + 28;
|
| | | icon = ImageUtil.class.getClassLoader().getResourceAsStream("image/icon_pdd.png");
|
| | | } else {
|
| | | return null;
|
| | | }
|
| | | g2d.drawImage(ImageIO.read(icon), spacing, y + 20, iconWidth, 34, null);
|
| | |
|
| | | // 3、商品标题内容
|
| | | int row = 0;
|
| | | String title = goods.getTitle();
|
| | | length = ImageUtil.getTextLengthByWidth(g2d, font26, title, row1, length);
|
| | | g2d.setFont(font26);
|
| | | g2d.setColor(new Color(0, 0, 0));
|
| | | g2d.drawString(title.substring(0, length), spacing + iconWidth + 5, y + 45 + row * 36);
|
| | |
|
| | | title = title.substring(length);
|
| | | row++;
|
| | | // 判断标题内容是否画完,最多可画三行
|
| | | while (title.length() > 0 && row < 3) {
|
| | | length = ImageUtil.getTextLengthByWidth(g2d, font26, title, 320, 11);
|
| | | g2d.drawString(title.substring(0, length), spacing, y + 45 + row * 36);
|
| | | title = title.substring(length);
|
| | | row++;
|
| | | }
|
| | |
|
| | | String code_frame = "image/share/qr_code_frame.png";
|
| | | if (!goods.isHasCoupon()) {
|
| | | // 无券
|
| | | code_frame = "image/share/qr_code_frame_no_coupon.png";
|
| | |
|
| | | g2d.setColor(new Color(229, 0, 92));
|
| | | g2d.drawString("¥ ", spacing, y + 175);
|
| | | g2d.setFont(boldFont36);
|
| | | g2d.drawString(MoneyBigDecimalUtil.getWithNoZera(goods.getZkPrice()).toString(), spacing + 21, y + 175);
|
| | | } else {
|
| | | // 券后价
|
| | | g2d.setFont(font26);
|
| | | g2d.setColor(new Color(229, 0, 92));
|
| | | g2d.drawString("券后价 ¥ ", spacing, y + 175);
|
| | | g2d.setFont(boldFont36);
|
| | | g2d.drawString(MoneyBigDecimalUtil.getWithNoZera(goods.getCouponPrice()).toString(), spacing + 116,
|
| | | y + 175);
|
| | |
|
| | | // 渠道原价(在售价)
|
| | | g2d.setColor(new Color(153, 153, 153));
|
| | | g2d.setFont(font24);
|
| | | g2d.drawString(goods.getPriceName() + " ¥ " + MoneyBigDecimalUtil.getWithNoZera(goods.getZkPrice()),
|
| | | spacing, y + 210);
|
| | |
|
| | | // 券字
|
| | | InputStream quan = ImageUtil.class.getClassLoader().getResourceAsStream("image/icon_quan.png");
|
| | | g2d.drawImage(ImageIO.read(quan), spacing, y + 240, 47, 40, null);
|
| | | // 券面额
|
| | | String quanAmount = "¥ " + goods.getCouponInfo().getAmount();
|
| | | FontMetrics fm = g2d.getFontMetrics(font26);
|
| | | int textLength = fm.stringWidth(quanAmount);
|
| | | g2d.setFont(font26);
|
| | | g2d.setColor(new Color(229, 0, 92));
|
| | | g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
| | | g2d.drawRoundRect(spacing + 42, y + 240, textLength + 20, 39, 10, 10);
|
| | | g2d.drawString(quanAmount, spacing + 55, y + 270);
|
| | |
|
| | | // 提示语
|
| | | InputStream tipStream = ImageUtil.class.getClassLoader()
|
| | | .getResourceAsStream("image/share/tip_angle.png");
|
| | | g2d.drawImage(ImageIO.read(tipStream), spacing, y + 300, 601, 101, null);
|
| | | }
|
| | |
|
| | | // 自营 、包邮
|
| | | if (goods.getShopType() == 21) {
|
| | | InputStream ziying = ImageUtil.class.getClassLoader().getResourceAsStream("image/icon_ziying.png");
|
| | | g2d.drawImage(ImageIO.read(ziying), spacing + 300, y + 150, 60, 30, null);
|
| | | } else if (goods.isBaoyou()) {
|
| | | InputStream ziying = ImageUtil.class.getClassLoader().getResourceAsStream("image/icon_baoyou.png");
|
| | | g2d.drawImage(ImageIO.read(ziying), spacing + 300, y + 150, 60, 30, null);
|
| | | }
|
| | |
|
| | | // 销量
|
| | | String sale = null;
|
| | | int salesType = goods.getSalesType();
|
| | | if (salesType == 1) {
|
| | | sale = "月销";
|
| | | } else if (salesType == 2) {
|
| | | sale = "2小时销量";
|
| | | } else if (salesType == 3) {
|
| | | sale = "今日销量";
|
| | | } else if (salesType == 4) {
|
| | | sale = "总销量";
|
| | | } else {
|
| | | sale = "月销";
|
| | | }
|
| | | sale = sale + " " + goods.getSalesCount();
|
| | | FontMetrics fm = g2d.getFontMetrics(font24);
|
| | | int textLength = fm.stringWidth(sale);
|
| | | g2d.setFont(font24);
|
| | | g2d.setColor(new Color(153, 153, 153));
|
| | | g2d.drawString(sale, spacing + 360 - textLength, y + 210);
|
| | |
|
| | | // 二维码图框
|
| | | g2d.setColor(Color.WHITE);
|
| | | InputStream codeFrame = ImageUtil.class.getClassLoader().getResourceAsStream(code_frame);
|
| | | g2d.drawImage(ImageIO.read(codeFrame), spacing + 405, y + 20, 200, 261, null);
|
| | |
|
| | | // 画 二维码
|
| | | int codeSize = 170;
|
| | | g2d.drawImage(ImageIO.read(qrcode), spacing + 420, y + 38, codeSize, codeSize, null);
|
| | |
|
| | | // 画二维码中 头像
|
| | | int portraitSize = 40;
|
| | | int pPX = spacing + 425 + codeSize / 2 + -portraitSize / 2;
|
| | | int pPY = y + 35 + codeSize / 2 - portraitSize / 2;
|
| | | BufferedImage portraitImg = ImageIO.read(portrait);
|
| | | portraitImg = ImageUtil.roundImage(portraitImg, 10);
|
| | | // 头像白色边框
|
| | | g2d.fillRoundRect(pPX - 4, pPY - 4, portraitSize + 8, portraitSize + 8, 10, 10);
|
| | | // 头像
|
| | | g2d.drawImage(portraitImg, pPX, pPY, portraitSize, portraitSize, null);
|
| | |
|
| | | // 结束
|
| | | g2d.dispose();
|
| | |
|
| | | ByteArrayOutputStream aos = new ByteArrayOutputStream();
|
| | | ImageIO.write(targetImg, "JPEG", aos);
|
| | | return new ByteArrayInputStream(aos.toByteArray());
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | // 画商品分享图
|
| | | public static InputStream drawGoodsShareImg(InputStream qrcodeStream, InputStream portrait,
|
| | |
| | | return null;
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 绘制大的商品动态分享图
|
| | | *
|
| | |
| | | e2.printStackTrace();
|
| | | }
|
| | | g2d.setFont(font);
|
| | | |
| | | |
| | |
|
| | | try {
|
| | | boolean index = true;
|
| | | // 画第一张
|
| | |
| | | if (i == 0 || index) {
|
| | | int topX = 50;
|
| | | int topY = 50;
|
| | | |
| | | |
| | |
|
| | | // 画大图 起始点坐标为(50,50)
|
| | | int widht = 650;
|
| | | int height = 650;
|
| | | InputStream goodsPicture = TaoBaoHttpUtil.getAsInputStream(goods.getPicture().replace("_.webp", "").replace("_220x220", ""));
|
| | | InputStream goodsPicture = TaoBaoHttpUtil
|
| | | .getAsInputStream(goods.getPicture().replace("_.webp", "").replace("_220x220", ""));
|
| | | if (goodsPicture == null)
|
| | | continue;
|
| | | |
| | |
|
| | | BufferedImage picImage = ImageIO.read(goodsPicture);
|
| | | picImage = ImageUtil.zoomInImage(picImage, widht, height);
|
| | | 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, widht + 1, widht + 1);
|
| | | |
| | |
|
| | | // 画透明背景
|
| | | g2d.setColor(new Color(255, 255, 255, 210));
|
| | | g2d.fillRect(10, height - 50, widht + 40, 100);
|
| | | |
| | | |
| | |
|
| | | // 画券后价金额
|
| | | boldFont = boldFont.deriveFont(42.0f);
|
| | | g2d.setFont(boldFont);
|
| | | g2d.setColor(new Color(229, 0, 92));
|
| | | |
| | |
|
| | | g2d.drawString("¥", 70 + 10, height);
|
| | | g2d.drawString(couplePrice + "", 70 + 45, height);
|
| | |
|
| | |
| | | BigDecimal withNoZera = MoneyBigDecimalUtil.getWithNoZera(goods.getCouponAmount());
|
| | | if (withNoZera != null && withNoZera.compareTo(new BigDecimal(0)) > 0) {
|
| | | g2d.setRenderingHints(mapH);
|
| | | |
| | |
|
| | | // 券值得长度
|
| | | int size = withNoZera.toString().length() * 22;
|
| | | int place = withNoZera.toString().length() * 22;
|
| | | |
| | | int size = withNoZera.toString().length() * 22;
|
| | | int place = withNoZera.toString().length() * 22;
|
| | |
|
| | | // 券红色底部
|
| | | int quanBGWidht = widht-100 - place;
|
| | | int quanBGWidht = widht - 100 - place;
|
| | | int quanBGHeight = height - 33;
|
| | | g2d.setColor(new Color(229, 0, 92));
|
| | | g2d.fillRoundRect(quanBGWidht, quanBGHeight, 130 + size, 70, 10, 10);
|
| | | |
| | |
|
| | | // 画券字
|
| | | boldFont = boldFont.deriveFont(40.0f);
|
| | | g2d.setFont(boldFont);
|
| | | g2d.setColor(new Color(255, 255, 255));
|
| | | g2d.drawString("券",quanBGWidht + 8, quanBGHeight + 48);
|
| | | |
| | | g2d.drawString("券", quanBGWidht + 8, quanBGHeight + 48);
|
| | |
|
| | | // 券白色底部
|
| | | g2d.fillRoundRect(quanBGWidht + 55, quanBGHeight + 4 , 70 + size, 62, 10, 10);
|
| | | |
| | | g2d.fillRoundRect(quanBGWidht + 55, quanBGHeight + 4, 70 + size, 62, 10, 10);
|
| | |
|
| | | // 画券面值
|
| | | g2d.setFont(boldFont);
|
| | | g2d.setColor(new Color(229, 0, 92));
|
| | |
| | | }
|
| | |
|
| | | index = false;
|
| | | |
| | |
|
| | | } else {
|
| | | // 计算左上角坐标
|
| | | int topX = 0;
|
| | |
| | | topY = 50 + (315 + 20) * 2;
|
| | |
|
| | | // 画大图
|
| | | InputStream goodsPicture = TaoBaoHttpUtil.getAsInputStream(goods.getPicture().replace("_.webp", ""));
|
| | | InputStream goodsPicture = TaoBaoHttpUtil
|
| | | .getAsInputStream(goods.getPicture().replace("_.webp", ""));
|
| | | if (goodsPicture == null)
|
| | | continue;
|
| | | |
| | |
|
| | | BufferedImage picImage = ImageIO.read(goodsPicture);
|
| | | picImage = ImageUtil.zoomInImage(picImage, 315, 315);
|
| | | g2d.drawImage(picImage, topX, topY, null);
|
| | |
| | | // // 画透明背景
|
| | | // g2d.setColor(new Color(255, 255, 255, 210));
|
| | | // g2d.fillRect(topX + 8, topY + 240, 300, 65);
|
| | | |
| | |
|
| | | g2d.setRenderingHints(mapH);
|
| | | |
| | |
|
| | | // 券值得长度
|
| | | int size = withNoZera.toString().length() * 22;
|
| | | int place = withNoZera.toString().length() * 22;
|
| | | |
| | | int size = withNoZera.toString().length() * 22;
|
| | | int place = withNoZera.toString().length() * 22;
|
| | |
|
| | | // // 券红色底部
|
| | | int quanBGWidht = topX + 170 - place;
|
| | | int quanBGWidht = topX + 170 - place;
|
| | | int quanBGHeight = topY + 220;
|
| | | g2d.setColor(new Color(229, 0, 92));
|
| | | g2d.fillRoundRect(quanBGWidht, quanBGHeight, 130 + size, 70, 10, 10);
|
| | | |
| | |
|
| | | // 画券字
|
| | | boldFont = boldFont.deriveFont(40.0f);
|
| | | g2d.setFont(boldFont);
|
| | | g2d.setColor(new Color(255, 255, 255));
|
| | | g2d.drawString("券",quanBGWidht + 8, quanBGHeight + 48);
|
| | | |
| | | g2d.drawString("券", quanBGWidht + 8, quanBGHeight + 48);
|
| | |
|
| | | // 券白色底部
|
| | | g2d.fillRoundRect(quanBGWidht + 55, quanBGHeight + 4 , 70 + size, 62, 10, 10);
|
| | | |
| | | g2d.fillRoundRect(quanBGWidht + 55, quanBGHeight + 4, 70 + size, 62, 10, 10);
|
| | |
|
| | | // 画券面值
|
| | | g2d.setFont(boldFont);
|
| | | g2d.setColor(new Color(229, 0, 92));
|
| | |
| | | ImageIO.write(targetImg, "JPEG", aos);
|
| | | InputStream is = new ByteArrayInputStream(aos.toByteArray());
|
| | | return is;
|
| | | |
| | |
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | |
| | | }
|
| | | return null;
|
| | | }
|
| | | |
| | | |
| | |
|
| | | // 画商品分享图
|
| | | public static InputStream drawGoodsShareImgHCJ(InputStream qrcodeStream, InputStream portrait,
|
| | | TaoBaoGoodsBrief goods) throws Exception {
|
| | |
| | |
|
| | | // 邀请好友图片
|
| | | public static void inviteFriendImg(InputStream urlInputStream, InputStream portraitInputStream,
|
| | | InputStream erCodeInputStream, String targetPath,String inviteCode) throws IOException {
|
| | | InputStream erCodeInputStream, String targetPath, String inviteCode) throws IOException {
|
| | | inviteFriendImg(urlInputStream, portraitInputStream, erCodeInputStream, targetPath, 260, 908, 230, inviteCode);
|
| | | }
|
| | |
|
| | |
| | | * @param portraitInputStream
|
| | | * @param erCodeInputStream
|
| | | * @param targetPath
|
| | | * @param pX
|
| | | * -二维码的横坐标
|
| | | * @param pY
|
| | | * -二维码的纵坐标
|
| | | * @param size
|
| | | * -二维码的尺寸
|
| | | * @param inviteCode
|
| | | * -邀请码
|
| | | * @param pX -二维码的横坐标
|
| | | * @param pY -二维码的纵坐标
|
| | | * @param size -二维码的尺寸
|
| | | * @param inviteCode -邀请码
|
| | | * @throws IOException
|
| | | */
|
| | | // 邀请好友图片
|
| | |
| | | return stateInt;
|
| | | }
|
| | |
|
| | | static int getTextLengthByWidth(Graphics2D g2d, Font font, String content, int maxWidth, int startPos) {
|
| | | public static int getTextLengthByWidth(Graphics2D g2d, Font font, String content, int maxWidth, int startPos) {
|
| | | FontMetrics fm = g2d.getFontMetrics(font);
|
| | | for (int i = startPos; i < content.length(); i++) {
|
| | | if (fm.stringWidth(content.substring(0, i)) >= maxWidth)
|
| | |
| | | return new int[] { width, height };
|
| | | }
|
| | |
|
| | | |
| | | |
| | | /**
|
| | | * 头像加白底图 邀请好友图片
|
| | | * |
| | | * @param urlInputStream
|
| | | * @param portraitInputStream
|
| | | * @param erCodeInputStream
|
| | |
| | | * @throws IOException
|
| | | */
|
| | | public static void inviteFriendImgWhite(InputStream urlInputStream, InputStream portraitInputStream,
|
| | | InputStream erCodeInputStream, String targetPath,String inviteCode) throws IOException {
|
| | | inviteFriendImgWhite(urlInputStream, portraitInputStream, erCodeInputStream, targetPath, 260, 908, 230, inviteCode);
|
| | | InputStream erCodeInputStream, String targetPath, String inviteCode) throws IOException {
|
| | | inviteFriendImgWhite(urlInputStream, portraitInputStream, erCodeInputStream, targetPath, 260, 908, 230,
|
| | | inviteCode);
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 头像加白底图 邀请好友图片 -自定义二维码位置
|
| | | * 头像加白底图 邀请好友图片 -自定义二维码位置
|
| | | * |
| | | * @param urlInputStream
|
| | | * @param portraitInputStream
|
| | | * @param erCodeInputStream
|
| | |
| | | * @throws IOException
|
| | | */
|
| | | public static void inviteFriendImgWhitecustom(InputStream urlInputStream, InputStream portraitInputStream,
|
| | | InputStream erCodeInputStream, String targetPath, Integer pX, Integer pY, Integer size, String inviteCode) throws IOException {
|
| | | inviteFriendImgWhite(urlInputStream, portraitInputStream, erCodeInputStream, targetPath, pX, pY, size, inviteCode);
|
| | | InputStream erCodeInputStream, String targetPath, Integer pX, Integer pY, Integer size, String inviteCode)
|
| | | throws IOException {
|
| | | inviteFriendImgWhite(urlInputStream, portraitInputStream, erCodeInputStream, targetPath, pX, pY, size,
|
| | | inviteCode);
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 邀请好友图片加上头像加上白底
|
| | | */
|
| | | public static void inviteFriendImgWhite(InputStream urlInputStream, InputStream portraitInputStream,
|
| | | InputStream erCodeInputStream, String targetPath, Integer pX, Integer pY, Integer size, String inviteCode) throws IOException {
|
| | | |
| | | InputStream erCodeInputStream, String targetPath, Integer pX, Integer pY, Integer size, String inviteCode)
|
| | | throws IOException {
|
| | |
|
| | | if (pX == null) {
|
| | | pX = 260;
|
| | | }
|
| | | |
| | |
|
| | | if (pY == null) {
|
| | | pY = 908; |
| | | pY = 908;
|
| | | }
|
| | | |
| | |
|
| | | if (size == null) {
|
| | | size = 230;
|
| | | }
|
| | |
|
| | | |
| | | BufferedImage bgImage = ImageIO.read(urlInputStream);
|
| | | final BufferedImage targetImg = new BufferedImage(bgImage.getWidth(), bgImage.getHeight(),
|
| | | BufferedImage.TYPE_INT_RGB);
|
| | |
| | | final Graphics2D g2d = targetImg.createGraphics();
|
| | | g2d.drawImage(bgImage, 0, 0, bgImage.getWidth(), bgImage.getHeight(), null);
|
| | | g2d.setRenderingHints(mapH);
|
| | | |
| | |
|
| | | // 画 二维码
|
| | | BufferedImage qrCodeImage = ImageIO.read(erCodeInputStream);
|
| | | qrCodeImage = ImageUtil.qrCodeImage(g2d, qrCodeImage, pX, pY, size, size);
|
| | | |
| | |
|
| | | int portraitSize = size * 5 / 23;
|
| | | int pPX = pX + size / 2 - portraitSize / 2;
|
| | | int pPY = pY + size / 2 - portraitSize / 2;
|
| | | |
| | |
|
| | | // 头像白色边框
|
| | | g2d.fillRoundRect(pPX-4, pPY-4,portraitSize+8, portraitSize + 8, 5, 5);
|
| | | g2d.fillRoundRect(pPX - 4, pPY - 4, portraitSize + 8, portraitSize + 8, 5, 5);
|
| | | g2d.setRenderingHints(mapH);
|
| | | // 画 头像
|
| | | BufferedImage portraitImg = ImageIO.read(portraitInputStream);
|
| | |
| | | portraitImg = ImageUtil.roundImage(portraitImg, 10);
|
| | | g2d.drawImage(portraitImg, pPX, pPY, portraitSize, portraitSize, null);
|
| | |
|
| | | |
| | | // 画邀请码(邀请码的大小与字体固定)
|
| | | if (!StringUtil.isNullOrEmpty(inviteCode)) {
|
| | | |
| | | int ax = pX - (inviteCode.length() - 4)*13 ;
|
| | | int ay = pY + size + 118;
|
| | | |
| | |
|
| | | int ax = pX - (inviteCode.length() - 4) * 13;
|
| | | int ay = pY + size + 118;
|
| | |
|
| | | int width_diap = 235 + (int) (24.6 * (inviteCode.length() - 4));
|
| | | g2d.setColor(Color.white);
|
| | | // 画出一个矩形
|
| | | g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 0.65f)); // 透明度 |
| | | g2d.fillRect(ax, ay - 38, width_diap, 50);
|
| | | // 前半圆
|
| | | g2d.fillArc(ax - 25, ay- 38, 50, 50, 90, 180);
|
| | | // 后半圆
|
| | | g2d.fillArc(ax + width_diap - 25, ay- 38, 50, 50, 270, 180);
|
| | | |
| | | g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR, 1f)); |
| | | // 画出一个矩形
|
| | | g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, 0.65f)); // 透明度
|
| | | g2d.fillRect(ax, ay - 38, width_diap, 50);
|
| | | // 前半圆
|
| | | g2d.fillArc(ax - 25, ay - 38, 50, 50, 90, 180);
|
| | | // 后半圆
|
| | | g2d.fillArc(ax + width_diap - 25, ay - 38, 50, 50, 270, 180);
|
| | |
|
| | | g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR, 1f));
|
| | | String st = "邀请码:" + inviteCode;
|
| | | String os = System.getProperty("os.name");
|
| | | String fontBoldPath = "/usr/share/fonts/PingFang_Medium.ttf";
|
| | |
| | | g2d.setFont(boldFont);
|
| | | g2d.getFontMetrics(boldFont);
|
| | | g2d.setColor(new Color(0, 0, 0));
|
| | | |
| | |
|
| | | g2d.setColor(new Color(0, 0, 0));
|
| | | g2d.drawString(st, ax, ay);
|
| | | }
|
| | |
| | | out.flush();
|
| | | out.close();
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 绘制邀请问候图
|
| | | * @param bgPigInStream 背景图
|
| | | * @param portraitInStream 用户头像
|
| | | * @param erCodeInStream 二维码
|
| | | * @param targetPath 路径
|
| | | * @param inviteCode 邀请码
|
| | | * @param content 文字内容
|
| | | * @param date 显示日历
|
| | | * |
| | | * @param bgPigInStream 背景图
|
| | | * @param portraitInStream 用户头像
|
| | | * @param erCodeInStream 二维码
|
| | | * @param targetPath 路径
|
| | | * @param inviteCode 邀请码
|
| | | * @param content 文字内容
|
| | | * @param date 显示日历
|
| | | * @throws IOException
|
| | | */
|
| | | public static void drawInviteToGreet(InputStream bgPigInStream, InputStream portraitInStream,
|
| | |
| | | BufferedImage bgImage = ImageIO.read(bgPigInStream);
|
| | | final BufferedImage targetImg = new BufferedImage(bgImage.getWidth(), bgImage.getHeight(),
|
| | | 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);// 文字抗锯齿
|
| | |
| | | g2d.drawImage(bgImage, 0, 0, bgImage.getWidth(), bgImage.getHeight(), null);
|
| | | g2d.setRenderingHints(mapH);
|
| | | g2d.setBackground(Color.WHITE);
|
| | | |
| | |
|
| | | // 画 蒙层
|
| | | BufferedImage mengCeng = ImageIO
|
| | | .read(ImageUtil.class.getClassLoader().getResourceAsStream("image/invite/mc.png"));
|
| | |
| | | int portraitSize = size * 5 / 23;
|
| | | int pPX = pX + size / 2 - portraitSize / 2;
|
| | | int pPY = pY + size / 2 - portraitSize / 2;
|
| | | |
| | |
|
| | | // 头像白色边框
|
| | | g2d.fillRoundRect(pPX-4, pPY-4,portraitSize+8, portraitSize + 8, 5, 5);
|
| | | g2d.fillRoundRect(pPX - 4, pPY - 4, portraitSize + 8, portraitSize + 8, 5, 5);
|
| | | g2d.setRenderingHints(mapH);
|
| | | |
| | |
|
| | | BufferedImage portraitImg = ImageIO.read(portraitInStream);
|
| | | portraitImg = ImageUtil.zoomInImage(portraitImg, portraitSize, portraitSize);
|
| | | portraitImg = ImageUtil.roundImage(portraitImg, 10);
|
| | | g2d.drawImage(portraitImg, pPX, pPY, portraitSize, portraitSize, null);
|
| | | |
| | |
|
| | | // 字体白色
|
| | | Color color = new Color(255, 255, 255);
|
| | |
| | | if (os.toLowerCase().startsWith("win")) {
|
| | | fontBoldPath = "C:/yahei.ttf";
|
| | | }
|
| | | |
| | |
|
| | | Font boldFont = null;
|
| | | // 画邀请码(邀请码的大小与字体固定)
|
| | |
| | | out.flush();
|
| | | out.close();
|
| | | }
|
| | | |
| | |
|
| | | }
|
| | |
| | | import com.yeshi.fanli.entity.bus.user.WeiXinUserParam;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.FilePathEnum;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | public class WXLoginUtil {
|
| | |
| | | }
|
| | |
|
| | | FileUploadResult result = COSManager.getInstance().uploadFile(asInputStream,
|
| | | String.format("/portrait/wx/%s_%s.jpg", user.getUnionid(), System.currentTimeMillis() + ""));
|
| | | String.format(FilePathEnum.userPortrait.getPath() + "%s_%s.jpg", user.getUnionid(), System.currentTimeMillis() + ""));
|
| | | if (result != null && !StringUtil.isNullOrEmpty(result.getUrl())) {
|
| | | user.setHeadimgurl(result.getUrl());
|
| | | // COS删除其余头像
|
| | |
| | | package com.yeshi.fanli.vo.msg;
|
| | |
|
| | | import com.yeshi.fanli.entity.common.JumpDetailV2;
|
| | |
|
| | | public class UserSystemMsgVO {
|
| | | private Long id;
|
| | | private String portrait;
|
| | |
| | | private String timeTag;
|
| | | private String createTime;
|
| | | private int unReadCount;
|
| | | private JumpDetailV2 jumpDetail;// 跳转详情
|
| | |
|
| | | public UserSystemMsgVO(Long id, String type, Boolean solved, String title, String content, String timeTag,
|
| | | String portrait, String createTime, int unReadCount) {
|
| | |
| | | this.createTime = createTime;
|
| | | }
|
| | |
|
| | | public JumpDetailV2 getJumpDetail() {
|
| | | return jumpDetail;
|
| | | }
|
| | |
|
| | | public void setJumpDetail(JumpDetailV2 jumpDetail) {
|
| | | this.jumpDetail = jumpDetail;
|
| | | }
|
| | |
|
| | | }
|