| | |
| | | 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 com.mongodb.util.ThreadUtil;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsHistory;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoLink;
|
| | | import com.yeshi.fanli.exception.ShareGoodsException;
|
| | | import com.yeshi.fanli.service.impl.goods.ShareGoodsServiceImpl;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.goods.ShareGoodsService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.util.AESUtil;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import org.springframework.web.bind.annotation.RequestMethod;
|
| | | import org.yeshi.utils.BigDecimalUtil;
|
| | | import org.yeshi.utils.HttpUtil;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.taobao.TbImgUtil;
|
| | |
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsGroup;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsHistory;
|
| | | import com.yeshi.fanli.entity.bus.share.UserShareGoodsRecord;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoLink;
|
| | | import com.yeshi.fanli.exception.ShareGoodsException;
|
| | | import com.yeshi.fanli.exception.share.UserShareGoodsRecordException;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.goods.CommonGoodsService;
|
| | | import com.yeshi.fanli.service.inter.goods.ShareGoodsService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.monitor.MonitorService;
|
| | | import com.yeshi.fanli.service.inter.user.UserShareGoodsGroupService;
|
| | | import com.yeshi.fanli.service.inter.user.UserShareGoodsRecordService;
|
| | | import com.yeshi.fanli.util.AESUtil;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.factory.MonitorFactory;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Controller(value = "ShareController1")
|
| | |
| | |
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | | @Resource
|
| | | private MonitorService monitorService;
|
| | |
|
| | | @Resource
|
| | | private UserShareGoodsRecordService userShareGoodsRecordService;
|
| | |
|
| | | @Resource
|
| | | private UserShareGoodsGroupService userShareGoodsGroupService;
|
| | | |
| | | @Resource
|
| | | private CommonGoodsService commonGoodsService;
|
| | |
|
| | | // 获取商品分享链接
|
| | | @RequestMapping(value = "getGoodsShareUrl")
|
| | |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "gettaobaosharelink")
|
| | | public void getTaobaoShareLink(AcceptData acceptData, Long uid, Long auctionId, PrintWriter out) {
|
| | | public void getTaobaoShareLink(AcceptData acceptData, Long uid, Long auctionId, HttpServletRequest request,
|
| | | PrintWriter out) {
|
| | | if (uid == null || uid <= 0) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户ID不能为空"));
|
| | | return;
|
| | |
| | | TaoBaoLink taoBaoLink = shareGoodsService.getTaoBaoLinkForShare(uid, auctionId);
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | String url = String.format("http://%s%s?uid=%s&id=%s", configService.getH5Host(),
|
| | | String url = String.format("http://%s%s?uid=%s&id=%s&appType=flq", configService.getH5Host(),
|
| | | Constant.systemCommonConfig.getShareGoodsPagePath(), AESUtil.encrypt(uid + "", Constant.UIDAESKEY),
|
| | | auctionId + "");
|
| | |
|
| | |
| | |
|
| | | data.put("clickUrl", url);
|
| | | data.put("token", taoBaoLink.getTaoToken());
|
| | | data.put("rule", "http://flq.yeshitv.com/fanli/client/html/help_item.html?id=8");
|
| | | data.put("rule",
|
| | | "http://apph5.yeshitv.com/apppage/all_help_content.html?id=148&from=singlemessage&isappinstalled=0");
|
| | | data.put("pictUrl", TbImgUtil.getTBSizeImg(taoBaoLink.getGoods().getPictUrl(), 500));
|
| | |
|
| | | String shareText = "";
|
| | |
| | | String text = configService.get("goods_share_text_coupon");
|
| | | shareText = text.replace("[标题]", taoBaoLink.getGoods().getTitle())
|
| | | .replace("[在售价]", "¥" + taoBaoLink.getGoods().getZkPrice())
|
| | | .replace("[优惠券金额]",
|
| | | "¥" + BigDecimalUtil.getWithNoZera(taoBaoLink.getGoods().getCouponAmount()).toString())
|
| | | .replace("[券后价]", "¥" + TaoBaoUtil.getAfterUseCouplePrice(taoBaoLink.getGoods()));
|
| | | }
|
| | | shareText = shareText.replace("[价格类型]", shopType);
|
| | | data.put("shareText", shareText);
|
| | | String descText = shareText.replace(taoBaoLink.getGoods().getTitle(), "").trim();
|
| | | if (descText.startsWith("\\r\\n"))
|
| | | descText = descText.substring(0);
|
| | | data.put("descText", descText);
|
| | | //
|
| | | String imgs = configService.get("goods_share_notify_imgs");
|
| | | JSONArray array = JSONArray.fromObject(imgs);
|
| | | int p = (int) (array.size() * Math.random());
|
| | | if (p < array.size())
|
| | | data.put("notifyPicture", array.optString(p));
|
| | | data.put("notifyDesc", configService.get("goods_share_notify"));
|
| | |
|
| | | // 添加分享记录
|
| | | BigDecimal rate = new BigDecimal(hongBaoManageService.get("hongbao_goods_proportion"));
|
| | | BigDecimal rate = hongBaoManageService.getShareRate();
|
| | | UserShareGoodsHistory history = new UserShareGoodsHistory();
|
| | | history.setTkCode(taoBaoLink.getTaoToken());
|
| | | history.setLink(taoBaoLink.getClickUrl());
|
| | |
| | | history.setUser(new UserInfo(uid));
|
| | | history.setPostPicture(taoBaoLink.getGoods().getPictUrl());
|
| | |
|
| | | data.put("shareMoney", "¥" + history.getHongbao().toString());
|
| | |
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | |
|
| | | // 异步操作
|
| | |
| | | });
|
| | | return;
|
| | | } catch (ShareGoodsException e) {
|
| | | try {
|
| | | monitorService.addClientAPIMonitor(MonitorFactory.createClientAPI(request, e.getCode(), 0, "分享出错"));
|
| | | } catch (Exception e1) {
|
| | | }
|
| | | out.print(JsonUtil.loadFalseResult(e.getCode(), e.getMessage()));
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | | * 分享记录统计列表
|
| | | * |
| | | * @param acceptData
|
| | | * @param page
|
| | | * 初始1
|
| | | * @param uid
|
| | | * @param source
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getlistrecord", method = RequestMethod.POST)
|
| | | public void getListRecord(AcceptData acceptData, Integer page, Long uid, String source, PrintWriter out) {
|
| | |
|
| | | if (page == null || page < 1) {
|
| | | out.print(JsonUtil.loadFalseResult("页码不正确"));
|
| | | }
|
| | |
|
| | | if (uid == null) {
|
| | | out.print(JsonUtil.loadFalseResult("用户未登录"));
|
| | | }
|
| | |
|
| | | if ("all".equals(source)) {
|
| | | source = null;// 查询全部
|
| | | }
|
| | |
|
| | | try {
|
| | | int pageSize = Constant.PAGE_SIZE;
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | List<UserShareGoodsRecord> list = new ArrayList<UserShareGoodsRecord>();
|
| | |
|
| | | long count = userShareGoodsRecordService.countQueryByUid(uid, source);
|
| | |
|
| | | if (count > 0) {
|
| | | list = userShareGoodsRecordService.getMyShareGoodsRecords((page - 1) * pageSize, pageSize, uid, source);
|
| | | }
|
| | |
|
| | | data.put("count", count);
|
| | | data.put("result_list", list);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | |
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("加载失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取分享商品
|
| | | * |
| | | * @param acceptData
|
| | | * @param recordId
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getrecordgoods", method = RequestMethod.POST)
|
| | | public void getRecordGoods(AcceptData acceptData, Long recordId, PrintWriter out) {
|
| | |
|
| | | if (recordId == null) {
|
| | | out.print(JsonUtil.loadFalseResult("参数不正确"));
|
| | | }
|
| | |
|
| | | try {
|
| | | JSONObject data = userShareGoodsRecordService.getGoodsGroup(recordId);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("加载失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取分享商品单个统计信息
|
| | | * |
| | | * @param acceptData
|
| | | * @param groupId
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "getgoodsdata", method = RequestMethod.POST)
|
| | | public void getGoodsData(AcceptData acceptData, Long groupId, PrintWriter out) {
|
| | |
|
| | | if (groupId == null) {
|
| | | out.print(JsonUtil.loadFalseResult("参数不正确"));
|
| | | }
|
| | |
|
| | | try {
|
| | | UserShareGoodsGroup userShareGoodsGroup = userShareGoodsGroupService.selectByPrimaryKey(groupId);
|
| | | if (userShareGoodsGroup != null) {
|
| | | userShareGoodsGroup.setBrowseTime(null);
|
| | | userShareGoodsGroup.setCreateTime(null);
|
| | | userShareGoodsGroup.setUpdateTime(null);
|
| | | userShareGoodsGroup.setRecordId(null);
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("goodsData", userShareGoodsGroup);
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("加载失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 商品详情分享
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * 用户id
|
| | | * @param auctionId
|
| | | * 商品id
|
| | | * @param type
|
| | | * 图片分享类型 单图single 多图many
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "sharedetail", method = RequestMethod.POST)
|
| | | public void shareDetail(AcceptData acceptData, Long uid, Long auctionId, String type, PrintWriter out) {
|
| | | try {
|
| | | userShareGoodsRecordService.saveDetail(uid, auctionId, type);
|
| | | out.print(JsonUtil.loadTrueResult("分享成功"));
|
| | | } catch (UserShareGoodsRecordException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getMsg()));
|
| | | e.printStackTrace();
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("加载失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 更新分享记录
|
| | | * |
| | | * @param acceptData
|
| | | * @param shareId
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "updaterecord", method = RequestMethod.POST)
|
| | | public void updateRecord(AcceptData acceptData, Long shareId, PrintWriter out) {
|
| | | if (shareId == null) {
|
| | | out.print(JsonUtil.loadFalseResult("参数不正确"));
|
| | | }
|
| | |
|
| | | try {
|
| | | userShareGoodsRecordService.updateShareRecord(shareId);
|
| | | out.print(JsonUtil.loadTrueResult(""));
|
| | | } catch (UserShareGoodsRecordException e) {
|
| | | out.print(JsonUtil.loadFalseResult(e.getMsg()));
|
| | | e.printStackTrace();
|
| | | } catch (Exception e) {
|
| | | out.print(JsonUtil.loadFalseResult("加载失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | }
|