| | |
| | | package com.yeshi.fanli.controller;
|
| | |
|
| | | 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 javax.crypto.Mac;
|
| | | import javax.crypto.spec.SecretKeySpec;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | |
|
| | | 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.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.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.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;
|
| | |
|
| | | /**
|
| | | * |
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Controller
|
| | | @RequestMapping("client/v1/callback")
|
| | | public class CallBackController {
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | |
|
| | | @Resource
|
| | | private PushService pushService;
|
| | |
|
| | | @Resource
|
| | | private MsgDeviceReadStateService msgDeviceReadStateService;
|
| | |
|
| | | @Resource(name = "producer")
|
| | | private Producer producer;
|
| | |
|
| | | @Resource
|
| | | private BanLiShopOrderService banLiShopOrderService;
|
| | |
|
| | | @Resource
|
| | | private GoodsEvaluateService goodsEvaluateService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | | @Resource
|
| | | private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
|
| | |
|
| | | @Resource
|
| | | private ActivityUserService activityUserService;
|
| | |
|
| | | /**
|
| | | * 客服消息回调
|
| | | * |
| | | * @param response
|
| | | */
|
| | | @RequestMapping(value = "kefuMsg")
|
| | | public void kefuMsg(HttpServletResponse response) {
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | | * 美洽消息回调
|
| | | * |
| | | * @param response
|
| | | */
|
| | |
|
| | | @RequestMapping(value = "meiQia")
|
| | | public void meiQia(HttpServletRequest request, HttpServletResponse response) {
|
| | | String auth = request.getHeader("Authorization");
|
| | | String queryString = request.getQueryString();
|
| | | LogHelper.test("美洽:queryString-" + queryString + "-auth:" + auth);
|
| | |
|
| | | BufferedReader br = null;
|
| | | StringBuilder sb = new StringBuilder("");
|
| | | try {
|
| | | br = request.getReader();
|
| | | String str;
|
| | | while ((str = br.readLine()) != null) {
|
| | | sb.append(str);
|
| | | }
|
| | | br.close();
|
| | | } catch (IOException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | LogHelper.test("美洽:body----" + sb.toString());
|
| | |
|
| | | String sign = "";
|
| | | try {
|
| | | sign = sign(sb.toString());
|
| | | } catch (SignatureException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | if (!auth.equalsIgnoreCase(sign)) {
|
| | | LogHelper.test("美洽回调签名错误");
|
| | | return;
|
| | | }
|
| | | JSONObject json = JSONObject.fromObject(sb.toString());
|
| | | String msg = "";
|
| | | if (json != null) {
|
| | | String deviceOS = json.optString("deviceOS");
|
| | | String contentType = json.optString("contentType");
|
| | | if (contentType.equalsIgnoreCase("text"))
|
| | | msg = json.optString("content");
|
| | | else if (contentType.equalsIgnoreCase("photo"))
|
| | | msg = "[图片]";
|
| | | else if (contentType.equalsIgnoreCase("audio"))
|
| | | msg = "[语音]";
|
| | | String customizedId = json.optJSONObject("customizedData").optString("设备标识");
|
| | | String uid = json.optJSONObject("customizedData").optString("用户ID");
|
| | | msgDeviceReadStateService.addUnreadDeviceMsg(MsgDeviceReadState.TYPE_KEFU, customizedId,
|
| | | "android".equalsIgnoreCase(deviceOS) ? 1 : 2, 1, msg, new Date());
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | public String sign(String raw_body) throws java.security.SignatureException {
|
| | | String key = "$2a$12$uC3EG/zSaSI37KKOgt1IgetDRHJY6Q2zEVDBr0DeWcwQbGNU7pewy";
|
| | | String result = "";
|
| | | try {
|
| | | SecretKeySpec signingKey = new SecretKeySpec(key.getBytes("UTF-8"), "HmacSHA1");
|
| | | Mac mac = Mac.getInstance("HmacSHA1");
|
| | | mac.init(signingKey);
|
| | | byte[] rawHmac = mac.doFinal(raw_body.getBytes("UTF-8"));
|
| | | byte[] hexBytes = new org.apache.commons.codec.binary.Hex().encode(rawHmac);
|
| | | result = org.apache.commons.codec.binary.Base64.encodeBase64String(hexBytes).trim();
|
| | | } catch (Exception e) {
|
| | | throw new SignatureException("Failed to generate HMAC : " + e.getMessage());
|
| | | }
|
| | | return "meiqia_sign:" + result;
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "test")
|
| | | public void test(PrintWriter out) {
|
| | | configService.getConfig(1L);
|
| | | out.print("success");
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "vip")
|
| | | public void VIP(PrintWriter out) {
|
| | | 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) {
|
| | |
|
| | | Map<String, String> map = WXUtil.parseXML(request);
|
| | | JSONObject json = JSONObject.fromObject(map);
|
| | | LogHelper.test("商城微信支付回调:" + json.toString());
|
| | | String sign = map.get("sign");
|
| | | map.remove("sign");
|
| | | boolean isSuccess = BanLiShopWXPayUtil.signIsRight(map, sign);
|
| | | if (isSuccess)
|
| | | if (map.get("return_code").equalsIgnoreCase("SUCCESS")
|
| | | && map.get("result_code").equalsIgnoreCase("SUCCESS")) {
|
| | | // 商户订单号
|
| | | String wxPayOrderNo = map.get("out_trade_no");
|
| | | // 订单号
|
| | | String orderNo = BanLiShopOrderUtil.getOrderNoFromWXPayOrderNo(wxPayOrderNo);
|
| | | if (!StringUtil.isNullOrEmpty(orderNo)) {
|
| | | BanLiShopOrder order = banLiShopOrderService.selectByOrderNo(orderNo);
|
| | | 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,
|
| | | OrderTopicTagEnum.banLiShopOrderPaid, msg);
|
| | | producer.send(message);
|
| | | Map<String, String> returnMap = new HashMap<>();
|
| | | returnMap.put("return_code", "SUCCESS");
|
| | | returnMap.put("return_msg", "OK");
|
| | | out.print(WXUtil.loadWXMessage(returnMap));
|
| | | out.close();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 联盟好物圈
|
| | | * @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 = "";
|
| | |
|
| | | contentDecode = content.substring(content.indexOf("(") + 1, content.length()).trim();
|
| | | if (contentDecode.endsWith(")"))
|
| | | contentDecode = contentDecode.substring(0, contentDecode.length() - 1);
|
| | |
|
| | | 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");
|
| | | 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, new Date(startTime-1000*60*20L*i));
|
| | | } catch (GoodsEvaluateException e) {
|
| | | e.printStackTrace();
|
| | | }catch(Exception e){
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | | package com.yeshi.fanli.controller; |
| | | |
| | | import java.io.BufferedReader; |
| | | import java.io.IOException; |
| | | 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 javax.crypto.Mac; |
| | | import javax.crypto.spec.SecretKeySpec; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import com.yeshi.fanli.entity.SystemEnum; |
| | | import com.yeshi.fanli.util.vipshop.DingDanXiaApiUtil; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.yeshi.utils.taobao.TbImgUtil; |
| | | import org.yeshi.utils.wx.WXUtil; |
| | | |
| | | import com.aliyun.openservices.ons.api.Message; |
| | | import com.yeshi.fanli.dto.GoodsMoneyConfigParamsDTO; |
| | | import com.yeshi.fanli.dto.mq.order.OrderTopicTagEnum; |
| | | import com.yeshi.fanli.dto.mq.order.body.BanLiShopOrderMQMsg; |
| | | 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.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.goods.facade.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.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; |
| | | 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; |
| | | |
| | | /** |
| | | * @author Administrator |
| | | */ |
| | | @Controller |
| | | @RequestMapping("client/v1/callback") |
| | | public class CallBackController { |
| | | @Resource |
| | | private ConfigService configService; |
| | | |
| | | @Resource |
| | | private PushService pushService; |
| | | |
| | | @Resource |
| | | private MsgDeviceReadStateService msgDeviceReadStateService; |
| | | |
| | | @Resource |
| | | private RocketMQManager rocketMQManager; |
| | | |
| | | @Resource |
| | | private BanLiShopOrderService banLiShopOrderService; |
| | | |
| | | @Resource |
| | | private GoodsEvaluateService goodsEvaluateService; |
| | | |
| | | @Resource |
| | | private HongBaoManageService hongBaoManageService; |
| | | |
| | | @Resource |
| | | private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService; |
| | | |
| | | @Resource |
| | | private ActivityUserService activityUserService; |
| | | |
| | | @Resource |
| | | private UserCloudService userCloudService; |
| | | |
| | | /** |
| | | * 客服消息回调 |
| | | * |
| | | * @param response |
| | | */ |
| | | @RequestMapping(value = "kefuMsg") |
| | | public void kefuMsg(HttpServletResponse response) { |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 美洽消息回调 |
| | | * |
| | | * @param response |
| | | */ |
| | | |
| | | @RequestMapping(value = "meiQia") |
| | | public void meiQia(HttpServletRequest request, HttpServletResponse response) { |
| | | String auth = request.getHeader("Authorization"); |
| | | String queryString = request.getQueryString(); |
| | | LogHelper.test("美洽:queryString-" + queryString + "-auth:" + auth); |
| | | |
| | | BufferedReader br = null; |
| | | StringBuilder sb = new StringBuilder(""); |
| | | try { |
| | | br = request.getReader(); |
| | | String str; |
| | | while ((str = br.readLine()) != null) { |
| | | sb.append(str); |
| | | } |
| | | br.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | LogHelper.test("美洽:body----" + sb.toString()); |
| | | |
| | | String sign = ""; |
| | | try { |
| | | sign = sign(sb.toString()); |
| | | } catch (SignatureException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | if (!auth.equalsIgnoreCase(sign)) { |
| | | LogHelper.test("美洽回调签名错误"); |
| | | return; |
| | | } |
| | | JSONObject json = JSONObject.fromObject(sb.toString()); |
| | | String msg = ""; |
| | | if (json != null) { |
| | | String deviceOS = json.optString("deviceOS"); |
| | | String contentType = json.optString("contentType"); |
| | | if (contentType.equalsIgnoreCase("text")) |
| | | msg = json.optString("content"); |
| | | else if (contentType.equalsIgnoreCase("photo")) |
| | | msg = "[图片]"; |
| | | else if (contentType.equalsIgnoreCase("audio")) |
| | | msg = "[语音]"; |
| | | String customizedId = json.optJSONObject("customizedData").optString("设备标识"); |
| | | String uid = json.optJSONObject("customizedData").optString("用户ID"); |
| | | msgDeviceReadStateService.addUnreadDeviceMsg(MsgDeviceReadState.TYPE_KEFU, customizedId, |
| | | "android".equalsIgnoreCase(deviceOS) ? 1 : 2, 1, msg, new Date()); |
| | | } |
| | | |
| | | } |
| | | |
| | | public String sign(String raw_body) throws java.security.SignatureException { |
| | | String key = "$2a$12$uC3EG/zSaSI37KKOgt1IgetDRHJY6Q2zEVDBr0DeWcwQbGNU7pewy"; |
| | | String result = ""; |
| | | try { |
| | | SecretKeySpec signingKey = new SecretKeySpec(key.getBytes("UTF-8"), "HmacSHA1"); |
| | | Mac mac = Mac.getInstance("HmacSHA1"); |
| | | mac.init(signingKey); |
| | | byte[] rawHmac = mac.doFinal(raw_body.getBytes("UTF-8")); |
| | | byte[] hexBytes = new org.apache.commons.codec.binary.Hex().encode(rawHmac); |
| | | result = org.apache.commons.codec.binary.Base64.encodeBase64String(hexBytes).trim(); |
| | | } catch (Exception e) { |
| | | throw new SignatureException("Failed to generate HMAC : " + e.getMessage()); |
| | | } |
| | | return "meiqia_sign:" + result; |
| | | } |
| | | |
| | | @RequestMapping(value = "test") |
| | | public void test(PrintWriter out) { |
| | | configService.getConfig(1L); |
| | | out.print("success"); |
| | | } |
| | | |
| | | @RequestMapping(value = "vip") |
| | | public void VIP(PrintWriter out) { |
| | | out.print("success"); |
| | | } |
| | | |
| | | /** |
| | | * 支付宝支付回调 |
| | | * |
| | | * @param out void 返回类型 |
| | | * @throws |
| | | * @Title: alipay |
| | | * @Description: |
| | | */ |
| | | @RequestMapping(value = "alipay") |
| | | public void alipay(PrintWriter out) { |
| | | out.print("success"); |
| | | } |
| | | |
| | | @RequestMapping(value = "banlishop/pay") |
| | | public void banLiShopPay(HttpServletRequest request, PrintWriter out) { |
| | | |
| | | Map<String, String> map = WXUtil.parseXML(request); |
| | | JSONObject json = JSONObject.fromObject(map); |
| | | LogHelper.test("商城微信支付回调:" + json.toString()); |
| | | String sign = map.get("sign"); |
| | | map.remove("sign"); |
| | | boolean isSuccess = BanLiShopWXPayUtil.signIsRight(map, sign); |
| | | if (isSuccess) |
| | | if (map.get("return_code").equalsIgnoreCase("SUCCESS") |
| | | && map.get("result_code").equalsIgnoreCase("SUCCESS")) { |
| | | // 商户订单号 |
| | | String wxPayOrderNo = map.get("out_trade_no"); |
| | | // 订单号 |
| | | String orderNo = BanLiShopOrderUtil.getOrderNoFromWXPayOrderNo(wxPayOrderNo); |
| | | if (!StringUtil.isNullOrEmpty(orderNo)) { |
| | | BanLiShopOrder order = banLiShopOrderService.selectByOrderNo(orderNo); |
| | | 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, |
| | | OrderTopicTagEnum.banLiShopOrderPaid, msg); |
| | | rocketMQManager.sendNormalMsg(message, null, null); |
| | | Map<String, String> returnMap = new HashMap<>(); |
| | | returnMap.put("return_code", "SUCCESS"); |
| | | returnMap.put("return_msg", "OK"); |
| | | out.print(WXUtil.loadWXMessage(returnMap)); |
| | | out.close(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 联盟好物圈 |
| | | * |
| | | * @param request |
| | | * @param out void 返回类型 |
| | | * @throws |
| | | * @Title: haoWuQuan |
| | | * @Description: |
| | | */ |
| | | @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 = ""; |
| | | |
| | | contentDecode = content.substring(content.indexOf("(") + 1, content.length()).trim(); |
| | | if (contentDecode.endsWith(")")) |
| | | contentDecode = contentDecode.substring(0, contentDecode.length() - 1); |
| | | |
| | | System.out.println(contentDecode); |
| | | |
| | | JSONObject data = JSONObject.fromObject(contentDecode).optJSONObject("data"); |
| | | |
| | | JSONArray array = data.optJSONObject("recommend").optJSONArray("resultList"); |
| | | |
| | | long startTime = System.currentTimeMillis(); |
| | | for (SystemEnum system : SystemEnum.values()) |
| | | for (int i = array.size() - 1; i >= 0; i--) { |
| | | JSONObject item = array.optJSONObject(i); |
| | | String title = item.optString("itemName"); |
| | | String doc = item.optString("cusShareText"); |
| | | String itemId = item.optString("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 |
| | | GoodsMoneyConfigParamsDTO paramsDTO = orderHongBaoMoneyComputeService.getShowComputeRate("android", "55", system); |
| | | paramsDTO.setBaseFanliRate(hongBaoManageService.getBaseFanliRate(SystemEnum.blks)); |
| | | 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, |
| | | new Date(startTime - 1000 * 60 * 20L * i), system); |
| | | } 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) { |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | @RequestMapping(value = "dingdanxia/vipshopauth") |
| | | public void dingDanXiaAuth(String code, String state, HttpServletRequest request, PrintWriter out) { |
| | | //暂时不使用 |
| | | |
| | | |
| | | } |
| | | |
| | | } |