parent
7a4c8eb063
commit
81d4a7f90a
@ -0,0 +1,88 @@ |
|||||||
|
package com.bweb.controller.order; |
||||||
|
|
||||||
|
import com.bweb.controller.goods.GoodsController; |
||||||
|
import com.github.pagehelper.PageHelper; |
||||||
|
import com.github.pagehelper.PageInfo; |
||||||
|
import com.hfkj.common.security.SessionObject; |
||||||
|
import com.hfkj.common.security.UserCenter; |
||||||
|
import com.hfkj.common.utils.ResponseMsgUtil; |
||||||
|
import com.hfkj.model.ResponseData; |
||||||
|
import com.hfkj.model.SecUserSessionObject; |
||||||
|
import com.hfkj.service.goods.BsOrderGoodsService; |
||||||
|
import com.hfkj.sysenum.SecUserObjectTypeEnum; |
||||||
|
import io.swagger.annotations.Api; |
||||||
|
import io.swagger.annotations.ApiOperation; |
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
import org.springframework.stereotype.Controller; |
||||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||||
|
import org.springframework.web.bind.annotation.RequestMethod; |
||||||
|
import org.springframework.web.bind.annotation.RequestParam; |
||||||
|
import org.springframework.web.bind.annotation.ResponseBody; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
import javax.servlet.http.HttpServletRequest; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
@Controller |
||||||
|
@RequestMapping(value="/orderGoods") |
||||||
|
@Api(value="实物订单管理") |
||||||
|
public class BsOrderGoodsController { |
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(BsOrderGoodsController.class); |
||||||
|
|
||||||
|
@Resource |
||||||
|
private BsOrderGoodsService bsOrderGoodsService; |
||||||
|
|
||||||
|
@Resource |
||||||
|
private UserCenter userCenter; |
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value="/getListGoods",method = RequestMethod.GET) |
||||||
|
@ResponseBody |
||||||
|
@ApiOperation(value = "查询列表") |
||||||
|
public ResponseData getListGoods(@RequestParam(value = "logisticsNo" , required = false) String logisticsNo, |
||||||
|
@RequestParam(value = "goodsType" , required = false) Long goodsType, |
||||||
|
@RequestParam(value = "goodsBrand" , required = false) Long goodsBrand, |
||||||
|
@RequestParam(value = "orderNo" , required = false) String orderNo, |
||||||
|
@RequestParam(value = "childOrderNo" , required = false) String childOrderNo, |
||||||
|
@RequestParam(value = "userPhone" , required = false) String userPhone, |
||||||
|
@RequestParam(value = "goodsSpecsName" , required = false) String goodsSpecsName, |
||||||
|
@RequestParam(value = "goodsName" , required = false) String goodsName, |
||||||
|
@RequestParam(value = "payType" , required = false) Integer payType, |
||||||
|
@RequestParam(value = "status" , required = false) Integer status, |
||||||
|
@RequestParam(value = "pageNum" , required = true) Integer pageNum, |
||||||
|
@RequestParam(value = "pageSize" , required = true) Integer pageSize, HttpServletRequest request) { |
||||||
|
try { |
||||||
|
|
||||||
|
SessionObject sessionObject = userCenter.getSessionObject(request); |
||||||
|
SecUserSessionObject userModel = (SecUserSessionObject) sessionObject.getObject(); |
||||||
|
|
||||||
|
Map<String , Object> map = new HashMap<>(); |
||||||
|
|
||||||
|
if (userModel.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type2.getCode())) { |
||||||
|
map.put("merId", userModel.getAccount().getId()); |
||||||
|
} |
||||||
|
|
||||||
|
map.put("logisticsNo", logisticsNo); |
||||||
|
map.put("goodsType", goodsType); |
||||||
|
map.put("goodsBrand", goodsBrand); |
||||||
|
map.put("orderNo", orderNo); |
||||||
|
map.put("childOrderNo", childOrderNo); |
||||||
|
map.put("userPhone", userPhone); |
||||||
|
map.put("goodsSpecsName", goodsSpecsName); |
||||||
|
map.put("goodsName", goodsName); |
||||||
|
map.put("payType", payType); |
||||||
|
map.put("status", status); |
||||||
|
|
||||||
|
PageHelper.startPage(pageNum, pageSize); |
||||||
|
return ResponseMsgUtil.success(new PageInfo<>(bsOrderGoodsService.getList(map))); |
||||||
|
|
||||||
|
} catch (Exception e) { |
||||||
|
log.error("error!",e); |
||||||
|
return ResponseMsgUtil.exception(e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,127 @@ |
|||||||
|
package com.cweb.controller.wx; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject; |
||||||
|
|
||||||
|
import com.hfkj.common.exception.ErrorCode; |
||||||
|
import com.hfkj.common.exception.ErrorHelp; |
||||||
|
import com.hfkj.common.exception.SysCode; |
||||||
|
import com.hfkj.common.utils.HttpsUtils; |
||||||
|
import com.hfkj.common.utils.ResponseMsgUtil; |
||||||
|
import com.hfkj.common.utils.WxUtils; |
||||||
|
import com.hfkj.config.CommonSysConst; |
||||||
|
import com.hfkj.config.WeChatQrcodeUtils; |
||||||
|
import com.hfkj.model.ResponseData; |
||||||
|
import io.swagger.annotations.Api; |
||||||
|
import io.swagger.annotations.ApiOperation; |
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.stereotype.Controller; |
||||||
|
import org.springframework.web.bind.annotation.*; |
||||||
|
|
||||||
|
import java.util.*; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author sum1dream |
||||||
|
*/ |
||||||
|
|
||||||
|
@Controller |
||||||
|
@RequestMapping(value = "/wxMsg") |
||||||
|
@Api(value = "微信") |
||||||
|
public class WxMsgController { |
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(WxMsgController.class); |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private WeChatQrcodeUtils weChatQrcodeUtils; |
||||||
|
|
||||||
|
|
||||||
|
// @RequestMapping(value = "/verifyWxToken", method = RequestMethod.GET)
|
||||||
|
// @ResponseBody
|
||||||
|
// @ApiOperation(value = "验证servlet")
|
||||||
|
// public String verifyWxToken(
|
||||||
|
// @RequestParam(name = "signature", required = false) String signature,
|
||||||
|
// @RequestParam(name = "timestamp", required = false) String timestamp,
|
||||||
|
// @RequestParam(name = "nonce", required = false) String nonce,
|
||||||
|
// @RequestParam(name = "echostr", required = false) String echostr
|
||||||
|
// ) {
|
||||||
|
//
|
||||||
|
// try {
|
||||||
|
//
|
||||||
|
// String signatureStr = WxUtils.getSHA1("RgAWdnR5oEOLBdyEjfr4" , timestamp , nonce);
|
||||||
|
// log.info("signatureStr!!!!!" + signatureStr);
|
||||||
|
// log.info("signature!!!!!" + signature);
|
||||||
|
// if (signature.equals(signatureStr)) {
|
||||||
|
// log.info("验证通过!!!!!");
|
||||||
|
// return echostr;
|
||||||
|
// }
|
||||||
|
// log.info("验证失败!!!!!");
|
||||||
|
// return null;
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "/verifyWx", method = RequestMethod.GET) |
||||||
|
@ResponseBody |
||||||
|
@ApiOperation(value = "微信编译URL") |
||||||
|
public ResponseData verifyWx(@RequestParam(value = "url", required = true) String url) { |
||||||
|
|
||||||
|
try { |
||||||
|
|
||||||
|
JSONObject jsapiTicket = weChatQrcodeUtils.getTicket(false); |
||||||
|
log.info("获取jsapiTicket"+ jsapiTicket); |
||||||
|
// 拼接签名
|
||||||
|
Map<String, Object> map = new HashMap<>(); |
||||||
|
map.put("noncestr", WxUtils.makeNonStr()); |
||||||
|
map.put("jsapi_ticket",jsapiTicket.getString("ticket")); |
||||||
|
map.put("timestamp", new Date().getTime()); |
||||||
|
map.put("url",url); |
||||||
|
|
||||||
|
log.info("拼接map"+ map); |
||||||
|
|
||||||
|
Map<String, Object> objectMap = new HashMap<>(); |
||||||
|
objectMap.put("appId" , CommonSysConst.getSysConfig().getWechatMpAppid()); |
||||||
|
objectMap.put("timestamp" , map.get("timestamp")); |
||||||
|
objectMap.put("nonceStr" , map.get("noncestr")); |
||||||
|
objectMap.put("signature" , WxUtils.getSHA1(map)); |
||||||
|
|
||||||
|
log.info("拼接objectMap"+ objectMap); |
||||||
|
|
||||||
|
return ResponseMsgUtil.success(objectMap); |
||||||
|
} catch (Exception e) { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value = "/createMenu", method = RequestMethod.POST) |
||||||
|
@ResponseBody |
||||||
|
@ApiOperation(value = "创建菜单") |
||||||
|
public ResponseData createMenu(@RequestBody JSONObject object) { |
||||||
|
try { |
||||||
|
Map<String, Object> params = new HashMap<>(); |
||||||
|
params.put("appid", CommonSysConst.getSysConfig().getWechatMpAppid()); |
||||||
|
params.put("secret", CommonSysConst.getSysConfig().getWechatMpSecret()); |
||||||
|
params.put("grant_type", "client_credential"); |
||||||
|
|
||||||
|
JSONObject accessTokenObject = HttpsUtils.doGet("https://api.weixin.qq.com/cgi-bin/token", params); |
||||||
|
if (accessTokenObject == null) { |
||||||
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "获取微信access_token失败"); |
||||||
|
} |
||||||
|
|
||||||
|
JSONObject jsonObject = HttpsUtils.doPost("https://api.weixin.qq.com/cgi-bin/menu/create?access_token=" + accessTokenObject.getString("access_token"), object); |
||||||
|
|
||||||
|
return ResponseMsgUtil.success(jsonObject); |
||||||
|
|
||||||
|
} catch (Exception e) { |
||||||
|
return ResponseMsgUtil.exception(e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} |
@ -0,0 +1,90 @@ |
|||||||
|
package com.hfkj.config; |
||||||
|
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject; |
||||||
|
|
||||||
|
import com.hfkj.common.utils.HttpsUtils; |
||||||
|
import com.hfkj.common.utils.RedisUtil; |
||||||
|
|
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
import org.springframework.stereotype.Component; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
|
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* @serviceName WeChatQrcodeUtils.java |
||||||
|
* @author Sum1Dream |
||||||
|
* @version 1.0.0 |
||||||
|
* @Description // 生成带参数的二维码
|
||||||
|
* @createTime 16:11 2022/9/2 |
||||||
|
**/ |
||||||
|
@Component |
||||||
|
public class WeChatQrcodeUtils { |
||||||
|
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(WeChatQrcodeUtils.class); |
||||||
|
|
||||||
|
|
||||||
|
@Resource |
||||||
|
private RedisUtil redisUtil; |
||||||
|
|
||||||
|
|
||||||
|
// 获取微信Token存入redis
|
||||||
|
public String getWxToken(Boolean whetherRedis) { |
||||||
|
|
||||||
|
if (!whetherRedis) { |
||||||
|
Object token = redisUtil.get("WxToken"); |
||||||
|
if (null != token) { |
||||||
|
return token.toString(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
log.info("获取最新微信token"); |
||||||
|
|
||||||
|
// 获取access_token
|
||||||
|
JSONObject params = new JSONObject(); |
||||||
|
params.put("appid", CommonSysConst.getSysConfig().getWechatMpAppid()); |
||||||
|
params.put("secret", CommonSysConst.getSysConfig().getWechatMpSecret()); |
||||||
|
params.put("grant_type", "client_credential"); |
||||||
|
JSONObject accessTokenObject = HttpsUtils.doPost("https://api.weixin.qq.com/cgi-bin/stable_token", params); |
||||||
|
redisUtil.set("WxToken", accessTokenObject.getString("access_token"), 7000); |
||||||
|
return accessTokenObject.getString("access_token"); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
// 获取签名
|
||||||
|
public JSONObject getTicket(Boolean whetherRedis) { |
||||||
|
|
||||||
|
int WxTokenRequestNum = Integer.parseInt(redisUtil.get("WxTokenRequestNum") == null ? "1" : redisUtil.get("WxTokenRequestNum").toString()); |
||||||
|
|
||||||
|
redisUtil.set("WxTokenRequestNum", WxTokenRequestNum + 1, 1000); |
||||||
|
|
||||||
|
String token = getWxToken(whetherRedis); |
||||||
|
; |
||||||
|
|
||||||
|
log.info("获取微信token次数: " + WxTokenRequestNum); |
||||||
|
log.info("获取微信token-回调参数: " + token); |
||||||
|
|
||||||
|
JSONObject jsapiTicket; |
||||||
|
|
||||||
|
// 获取ticket
|
||||||
|
Map<String, Object> ticketParams = new HashMap<>(); |
||||||
|
ticketParams.put("access_token", token); |
||||||
|
ticketParams.put("type", "jsapi"); |
||||||
|
jsapiTicket = HttpsUtils.doGet("https://api.weixin.qq.com/cgi-bin/ticket/getticket", ticketParams); |
||||||
|
|
||||||
|
log.info("获取ticket-回调参数: " + jsapiTicket); |
||||||
|
|
||||||
|
if (jsapiTicket != null && jsapiTicket.getInteger("errcode") != 0 && WxTokenRequestNum < 6) { |
||||||
|
jsapiTicket = getTicket(true); |
||||||
|
} |
||||||
|
|
||||||
|
redisUtil.del("WxTokenRequestNum"); |
||||||
|
return jsapiTicket; |
||||||
|
|
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue