| | |
| | |
|
| | | 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 javax.servlet.http.HttpServletRequest;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | |
|
| | | import com.yeshi.fanli.entity.SystemEnum;
|
| | | 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.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.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.service.inter.user.cloud.UserCloudService;
|
| | | import com.yeshi.fanli.service.manger.msg.RocketMQManager;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory;
|
| | |
| | | @Resource
|
| | | private MsgDeviceReadStateService msgDeviceReadStateService;
|
| | |
|
| | | @Resource(name = "producer")
|
| | | private Producer producer;
|
| | | @Resource
|
| | | private RocketMQManager rocketMQManager;
|
| | |
|
| | | @Resource
|
| | | private BanLiShopOrderService banLiShopOrderService;
|
| | |
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | | @Resource
|
| | | private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
|
| | |
|
| | | @Resource
|
| | | private ActivityUserService activityUserService;
|
| | |
|
| | | @Resource
|
| | | private UserCloudService userCloudService;
|
| | |
|
| | | /**
|
| | | * 客服消息回调
|
| | |
| | | out.print("success");
|
| | | }
|
| | |
|
| | | /**
|
| | | * 支付宝支付回调
|
| | | * @Title: alipay
|
| | | * @Description: |
| | | * @param out |
| | | * void 返回类型
|
| | | * @throws
|
| | | */
|
| | | @RequestMapping(value = "alipay")
|
| | | public void alipay(PrintWriter out) {
|
| | | out.print("success");
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "banlishop/pay")
|
| | | public void banLiShopPay(HttpServletRequest request, PrintWriter out) {
|
| | |
|
| | |
| | | new BigDecimal(map.get("total_fee")).multiply(new BigDecimal("0.01")));
|
| | | Message message = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER,
|
| | | OrderTopicTagEnum.banLiShopOrderPaid, msg);
|
| | | producer.send(message);
|
| | | rocketMQManager.sendNormalMsg(message, null,null);
|
| | | Map<String, String> returnMap = new HashMap<>();
|
| | | returnMap.put("return_code", "SUCCESS");
|
| | | returnMap.put("return_msg", "OK");
|
| | |
| | | // 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("mtopjsonp1(") + "mtopjsonp1(".length(),
|
| | | contentDecode.length()).trim();
|
| | | if (contentDecode.endsWith(")"))
|
| | | contentDecode = contentDecode.substring(0, contentDecode.length() - 1);
|
| | | contentDecode = content.substring(content.indexOf("(") + 1, content.length()).trim();
|
| | | if (contentDecode.endsWith(")"))
|
| | | contentDecode = contentDecode.substring(0, contentDecode.length() - 1);
|
| | |
|
| | | System.out.println(contentDecode);
|
| | |
|
| | | reader.close();
|
| | |
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | System.out.println(contentDecode);
|
| | |
|
| | | JSONObject data = JSONObject.fromObject(contentDecode).optJSONObject("data");
|
| | |
|
| | | JSONArray array = data.optJSONObject("recommend").optJSONArray("resultList");
|
| | |
|
| | | long startTime = System.currentTimeMillis();
|
| | |
|
| | | for (int i = array.size() - 1; i >= 0; i--) {
|
| | | JSONObject item = array.optJSONObject(i);
|
| | | String title = item.optString("itemName");
|
| | |
| | | if (goodsBrief == null)
|
| | | continue;
|
| | | // 商品VO
|
| | | ConfigParamsDTO paramsDTO = hongBaoManageService.getShowComputeRate("android", "55");
|
| | | ConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55");
|
| | | paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate());
|
| | | GoodsDetailVO goodsVO = GoodsDetailVOFactory.convertTaoBao(goodsBrief, paramsDTO);
|
| | |
|
| | |
| | | } else {
|
| | | imgInfo.setType(ImgEnum.goods);
|
| | | SimpleGoods simpleGoods = new SimpleGoods();
|
| | | simpleGoods.setGoodsId(itemId);
|
| | | simpleGoods.setGoodsId(itemId + "");
|
| | | simpleGoods.setGoodsType(Constant.SOURCE_TYPE_TAOBAO);
|
| | | simpleGoods.setState(CommonGoods.STATE_NORMAL);
|
| | | CouponInfoVO couponInfo = goodsVO.getCouponInfo();
|
| | |
| | |
|
| | | ActivityUser user = ruleList.get((int) (ruleList.size() * Math.random())).getActivityUser();
|
| | | try {
|
| | | goodsEvaluateService.addGoodsEvaluate(itemId, imageList, user, doc, null, null);
|
| | | goodsEvaluateService.addGoodsEvaluate(itemId + "", imageList, user, doc, null,
|
| | | new Date(startTime - 1000 * 60 * 20L * i), SystemEnum.blks);
|
| | | } catch (GoodsEvaluateException e) {
|
| | | e.printStackTrace();
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "yhg/groupmsg")
|
| | | public void groupMsg(HttpServletRequest request, PrintWriter out) {
|
| | | StringBuilder stringBuilder = new StringBuilder();
|
| | | try {
|
| | | byte[] buffer = new byte[2048];
|
| | | int readBytes = 0;
|
| | | while ((readBytes = request.getInputStream().read(buffer)) > 0) {
|
| | | stringBuilder.append(new String(buffer, 0, readBytes));
|
| | | }
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | try {
|
| | | JSONObject root = JSONObject.fromObject(stringBuilder.toString());
|
| | | if (root.optInt("messageType") == 9) {
|
| | | String content = root.optJSONObject("data").optString("content");
|
| | | LogHelper.test("云发单群内容:" + content);
|
| | | if (content.trim().equalsIgnoreCase(Constant.YHG_CLOUD_GROUP_AWAKEN_KEY)) {
|
| | | LogHelper.test("云发单群匹配:" + root.optString("wcId") + "-"
|
| | | + root.optJSONObject("data").optString("fromGroup"));
|
| | | userCloudService.cacheMatchGroup(root.optString("wcId"),
|
| | | root.optJSONObject("data").optString("fromGroup"));
|
| | | }
|
| | | }
|
| | | } catch (Exception e) {
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | }
|