admin
2020-04-14 036fc28606e5fcb2203cbc7c4736c99512a522f7
fanli/src/main/java/com/yeshi/fanli/controller/CallBackController.java
@@ -2,6 +2,8 @@
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;
@@ -10,6 +12,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import javax.annotation.Resource;
import javax.crypto.Mac;
@@ -19,7 +22,10 @@
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.JsonUtil;
import org.yeshi.utils.taobao.TbImgUtil;
import org.yeshi.utils.wx.WXUtil;
import com.aliyun.openservices.ons.api.Message;
@@ -245,20 +251,49 @@
    * @throws
    */
   @RequestMapping(value = "faquan/haowuquan")
   public void haoWuQuan(HttpServletRequest request, String content, String sign, PrintWriter out) {
      if (!sign.equalsIgnoreCase(StringUtil.Md5(content + "banliapp"))) {
         out.print(JsonUtil.loadFalseResult("签名错误"));
         return;
   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("mtopjsonp1(") + "mtopjsonp1(".length(),
                  contentDecode.length()).trim();
            if (contentDecode.endsWith(")"))
               contentDecode = contentDecode.substring(0, contentDecode.length() - 1);
            System.out.println(contentDecode);
            reader.close();
         } catch (IOException e) {
            e.printStackTrace();
         }
      }
      String contentDecode = StringUtil.getFromBase64(content);
      JSONObject data = JSONObject.fromObject(contentDecode);
      JSONObject data = JSONObject.fromObject(contentDecode).optJSONObject("data");
      JSONArray array = data.optJSONObject("recommend").optJSONArray("resultList");
      for (int i = 0; i < array.size(); i++) {
      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++) {
@@ -288,7 +323,13 @@
            imgInfo.setW(1);
            imgInfo.setLarge(false);
            imgInfo.setUrl(imgList.get(j));
            if (i != 0) {
            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);
@@ -309,13 +350,11 @@
            imageList.add(imgInfo);
         }
         List<ActivityRuleUser> ruleList = activityUserService.listByRuleCode(ActivityRuleUser.RULE_HOT, 1, 20);
         ruleList.get(0).getActivityUser();
         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);
            goodsEvaluateService.addGoodsEvaluate(itemId, imageList, user, doc, null, null);
         } catch (GoodsEvaluateException e) {
            e.printStackTrace();
         }