| | |
| | |
|
| | | import java.io.BufferedReader;
|
| | | import java.io.IOException;
|
| | | import java.io.InputStream;
|
| | | import java.io.InputStreamReader;
|
| | | import java.io.PrintWriter;
|
| | | import java.math.BigDecimal;
|
| | | import java.security.SignatureException;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
| | |
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.multipart.MultipartFile;
|
| | | import org.springframework.web.multipart.MultipartHttpServletRequest;
|
| | | import org.yeshi.utils.taobao.TbImgUtil;
|
| | | import org.yeshi.utils.wx.WXUtil;
|
| | |
|
| | | import com.aliyun.openservices.ons.api.Message;
|
| | | import com.aliyun.openservices.ons.api.Producer;
|
| | | import com.google.gson.Gson;
|
| | | import com.yeshi.fanli.dto.ConfigParamsDTO;
|
| | | import com.yeshi.fanli.dto.mq.order.OrderTopicTagEnum;
|
| | | import com.yeshi.fanli.dto.mq.order.body.BanLiShopOrderMQMsg;
|
| | | import com.yeshi.fanli.dto.push.PushContentDTO;
|
| | | import com.yeshi.fanli.entity.bus.activity.ActivityRuleUser;
|
| | | import com.yeshi.fanli.entity.bus.activity.ActivityUser;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgDeviceReadState;
|
| | | import com.yeshi.fanli.entity.config.push.PushMsgFactory;
|
| | | import com.yeshi.fanli.entity.dynamic.ImgInfo;
|
| | | import com.yeshi.fanli.entity.dynamic.ImgInfo.ImgEnum;
|
| | | import com.yeshi.fanli.entity.dynamic.SimpleGoods;
|
| | | import com.yeshi.fanli.entity.goods.CommonGoods;
|
| | | import com.yeshi.fanli.entity.shop.BanLiShopOrder;
|
| | | import com.yeshi.fanli.exception.push.PushException;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.exception.dynamic.GoodsEvaluateException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.activity.ActivityUserService;
|
| | | import com.yeshi.fanli.service.inter.config.ConfigService;
|
| | | import com.yeshi.fanli.service.inter.dynamic.GoodsEvaluateService;
|
| | | import com.yeshi.fanli.service.inter.msg.MsgDeviceReadStateService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService;
|
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.push.PushService;
|
| | | import com.yeshi.fanli.service.inter.shop.BanLiShopOrderService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
|
| | | import com.yeshi.fanli.util.rocketmq.MQMsgBodyFactory;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName;
|
| | | import com.yeshi.fanli.util.shop.BanLiShopOrderUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | | import com.yeshi.fanli.util.wx.BanLiShopWXPayUtil;
|
| | | import com.yeshi.fanli.vo.goods.CouponInfoVO;
|
| | | import com.yeshi.fanli.vo.goods.GoodsDetailVO;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | /**
|
| | |
| | |
|
| | | @Resource
|
| | | private BanLiShopOrderService banLiShopOrderService;
|
| | |
|
| | | @Resource
|
| | | private GoodsEvaluateService goodsEvaluateService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | | |
| | | @Resource
|
| | | private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
|
| | |
|
| | | @Resource
|
| | | private ActivityUserService activityUserService;
|
| | |
|
| | | /**
|
| | | * 客服消息回调
|
| | |
| | | String uid = json.optJSONObject("customizedData").optString("用户ID");
|
| | | msgDeviceReadStateService.addUnreadDeviceMsg(MsgDeviceReadState.TYPE_KEFU, customizedId,
|
| | | "android".equalsIgnoreCase(deviceOS) ? 1 : 2, 1, msg, new Date());
|
| | | if (!StringUtil.isNullOrEmpty(uid))// 推送客服消息
|
| | | {
|
| | | PushContentDTO dto = PushMsgFactory.createMsgKefu();
|
| | | try {
|
| | | pushService.pushZNX(Long.parseLong(uid), dto.getTitle(), dto.getContent(), null, null);
|
| | | } catch (NumberFormatException e) {
|
| | | e.printStackTrace();
|
| | | } catch (PushException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | if (order != null) {// 支付成功消息推送
|
| | | BanLiShopOrderMQMsg msg = new BanLiShopOrderMQMsg(order.getId(), order.getUid(),
|
| | | new BigDecimal(map.get("total_fee")).multiply(new BigDecimal("0.01")));
|
| | | Message message =MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER,
|
| | | Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER,
|
| | | OrderTopicTagEnum.banLiShopOrderPaid, msg);
|
| | | producer.send(message);
|
| | | Map<String, String> returnMap = new HashMap<>();
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 联盟好物圈
|
| | | * @Title: haoWuQuan
|
| | | * @Description: |
| | | * @param request
|
| | | * @param out |
| | | * void 返回类型
|
| | | * @throws
|
| | | */
|
| | | @RequestMapping(value = "faquan/haowuquan")
|
| | | public void haoWuQuan(HttpServletRequest request, String content, PrintWriter out) {
|
| | | // if (!sign.equalsIgnoreCase(StringUtil.Md5(content + "banliapp"))) {
|
| | | // out.print(JsonUtil.loadFalseResult("签名错误"));
|
| | | // return;
|
| | | // }
|
| | | String contentDecode = "";
|
| | | if (request instanceof MultipartHttpServletRequest) {
|
| | | MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
| | | List<MultipartFile> files = multipartRequest.getFiles("file");
|
| | | try {
|
| | | InputStream input = files.get(0).getInputStream();
|
| | | InputStreamReader reader = new InputStreamReader(input, "UTF-16LE");
|
| | | int d = -1;
|
| | | String st = "";
|
| | | while ((d = reader.read()) != -1) {
|
| | | st += ((char) d);
|
| | | }
|
| | | System.out.println(st);
|
| | | contentDecode = st;
|
| | |
|
| | | contentDecode = contentDecode.substring(contentDecode.indexOf("(") +1,
|
| | | contentDecode.length()).trim();
|
| | | if (contentDecode.endsWith(")"))
|
| | | contentDecode = contentDecode.substring(0, contentDecode.length() - 1);
|
| | |
|
| | | System.out.println(contentDecode);
|
| | |
|
| | | reader.close();
|
| | |
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | JSONObject data = JSONObject.fromObject(contentDecode).optJSONObject("data");
|
| | |
|
| | | JSONArray array = data.optJSONObject("recommend").optJSONArray("resultList");
|
| | | for (int i = array.size() - 1; i >= 0; i--) {
|
| | | JSONObject item = array.optJSONObject(i);
|
| | | String title = item.optString("itemName");
|
| | | String doc = item.optString("cusShareText");
|
| | | long itemId = item.optLong("itemId");
|
| | | String publishTime = item.optString("cusPublishTime");
|
| | | JSONArray imageArray = item.optJSONArray("imageList");
|
| | | List<String> imgList = new ArrayList<>();
|
| | | for (int j = 0; j < imageArray.size(); j++) {
|
| | | imgList.add(imageArray.optString(j));
|
| | | }
|
| | |
|
| | | TaoBaoGoodsBrief goodsBrief = null;
|
| | | try {
|
| | | goodsBrief = TaoKeApiUtil.searchGoodsDetail(itemId);
|
| | | } catch (TaobaoGoodsDownException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | if (goodsBrief == null)
|
| | | continue;
|
| | | // 商品VO
|
| | | ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55");
|
| | | paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
|
| | | GoodsDetailVO goodsVO = GoodsDetailVOFactory.convertTaoBao(goodsBrief, paramsDTO);
|
| | |
|
| | | if (imgList.size() > 3)
|
| | | imgList = imgList.subList(0, 3);
|
| | |
|
| | | List<ImgInfo> imageList = new ArrayList<>();
|
| | | for (int j = 0; j < imgList.size(); j++) {
|
| | | ImgInfo imgInfo = new ImgInfo();
|
| | | imgInfo.setH(1);
|
| | | imgInfo.setW(1);
|
| | | imgInfo.setLarge(false);
|
| | | imgInfo.setUrl(imgList.get(j));
|
| | | String sourceImg = imgList.get(j);
|
| | | if (!imgInfo.getUrl().startsWith("http")) {
|
| | | sourceImg = "https:" + imgInfo.getUrl();
|
| | | }
|
| | | imgInfo.setUrl(TbImgUtil.getTBSizeImg(sourceImg, 500));
|
| | | imgInfo.setUrlHD(sourceImg);
|
| | | if (j != 0) {
|
| | | imgInfo.setType(ImgEnum.img);
|
| | | } else {
|
| | | imgInfo.setType(ImgEnum.goods);
|
| | | SimpleGoods simpleGoods = new SimpleGoods();
|
| | | simpleGoods.setGoodsId(itemId);
|
| | | simpleGoods.setGoodsType(Constant.SOURCE_TYPE_TAOBAO);
|
| | | simpleGoods.setState(CommonGoods.STATE_NORMAL);
|
| | | CouponInfoVO couponInfo = goodsVO.getCouponInfo();
|
| | | if (couponInfo == null) {
|
| | | simpleGoods.setPrice(goodsVO.getZkPrice());
|
| | | } else {
|
| | | simpleGoods.setPrice(goodsVO.getCouponPrice());
|
| | | simpleGoods.setAmount(couponInfo.getAmount());
|
| | | }
|
| | | imgInfo.setGoods(simpleGoods);
|
| | | imgInfo.setGoodsVO(goodsVO);
|
| | | }
|
| | | imageList.add(imgInfo);
|
| | | }
|
| | |
|
| | | List<ActivityRuleUser> ruleList = activityUserService.listByRuleCode(ActivityRuleUser.RULE_HAOHUO, 1, 20);
|
| | |
|
| | | ActivityUser user = ruleList.get((int) (ruleList.size() * Math.random())).getActivityUser();
|
| | | try {
|
| | | goodsEvaluateService.addGoodsEvaluate(itemId, imageList, user, doc, null, null);
|
| | | } catch (GoodsEvaluateException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | }
|