Merge branch 'cpupon-dev' of http://gitea.dctpay.com/hurui/puhui-go into cpupon-dev

cpupon-dev
袁野 1 month ago
commit 391b726eef
  1. 1
      bweb/src/main/java/com/bweb/config/AuthConfig.java
  2. 39
      bweb/src/main/java/com/bweb/controller/TestController.java
  3. 68
      bweb/src/main/java/com/bweb/controller/api/ApiMerController.java
  4. 4
      openapi/src/main/resources/prod/application.yml
  5. 16
      order/src/main/java/com/order/controller/notify/MeiTuanController.java
  6. 68
      service/src/main/java/com/hfkj/api/ApiMerService.java
  7. 68
      service/src/main/java/com/hfkj/api/impl/ApiMerServiceImpl.java
  8. 1
      service/src/main/java/com/hfkj/service/user/BsUserService.java
  9. 28
      service/src/main/java/com/hfkj/service/user/impl/BsUserServiceImpl.java
  10. 1
      service/src/main/java/com/hfkj/sysenum/UserLoginPlatform.java
  11. 1
      service/src/main/java/com/hfkj/sysenum/UserLoginType.java
  12. 105
      user/src/main/java/com/user/controller/BsUserController.java

@ -89,6 +89,7 @@ public class AuthConfig implements WebMvcConfigurer {
.excludePathPatterns("/fileUpload/*")
.excludePathPatterns("/common/*")
.excludePathPatterns("/test/*")
.excludePathPatterns("/apiMer/*")
.excludePathPatterns("/secMenu/queryMenuList")
.excludePathPatterns("/user/phgDataUser")
.excludePathPatterns("/user/phgDataUserDetail")

@ -450,6 +450,24 @@ public class TestController {
}
}
@RequestMapping(value="/queryHltBalance",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询工会卡余额")
public ResponseData queryHltBalance(@RequestParam(value = "cardNo", required = false) String cardNo) {
try {
JSONObject cardInfo = HuiLianTongUnionCardService.queryBalance(cardNo);
if (StringUtils.isBlank(cardInfo.getString("data"))) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请求失败");
}
return ResponseMsgUtil.success(HuiLianTongUnionCardService.resolveResponse(cardInfo.getString("data")));
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/getGoodsUpdate",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "更新商品")
@ -478,4 +496,25 @@ public class TestController {
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/phgSignLogin",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "加密登陆")
public ResponseData phgSignLogin() {
try {
Map<String , Object> map = new HashMap<>();
map.put("appid" , "20241266600");
map.put("phone" , "18390580471");
map.put("sign" , SignatureUtil.createSign(map , "BCB83776BDA7F609FBE99BBB8AC33840"));
map.put("platform" , "HIGH");
map.put("type" , "HIGH_SIGN");
return ResponseMsgUtil.success( HttpsUtils.doPost("http://localhost:9704/user/client/phgSignLogin" , map , new HashMap<>()));
} catch (Exception e) {
log.error("error!",e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -0,0 +1,68 @@
package com.bweb.controller.api;
import com.hfkj.api.ApiMerService;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.utils.DateUtil;
import com.hfkj.common.utils.IDGenerator;
import com.hfkj.common.utils.ResponseMsgUtil;
import com.hfkj.common.utils.WxUtils;
import com.hfkj.entity.ApiMer;
import com.hfkj.model.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Date;
@Controller
@RequestMapping(value = "/apiMer")
@Api(value = "api商户")
public class ApiMerController {
Logger log = LoggerFactory.getLogger(ApiMerController.class);
@Resource
private ApiMerService apiMerService;
@RequestMapping(value="/insertMerchant",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "增加商户")
public ResponseData insertMer(@RequestBody ApiMer apiMer) {
try {
if (StringUtils.isBlank(apiMer.getMerName())
|| StringUtils.isBlank(apiMer.getContact())
|| StringUtils.isBlank(apiMer.getContactPhone())
) {
log.error("ApiMerchantsController -> insertMerchant() error!","参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
apiMer.setCreateTime(new Date());
apiMer.setUpdateTime(new Date());
apiMer.setStatus(1);
apiMer.setAppId(DateUtil.date2String(new Date(), "yyyyMM") + IDGenerator.nextId(5));
apiMer.setAppSecret(WxUtils.MD5(apiMer.getAppId() , true));
apiMerService.create(apiMer);
return ResponseMsgUtil.success("新增成功");
} catch (Exception e) {
log.error("ApiMerchantsController -> insertMerchant() error!",e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -1,7 +1,7 @@
server:
port: 9301
port: 9505
servlet:
context-path: /crest
context-path: /openapi
#配置是否为debug模式,debug模式下,不开启权限校验
debug: false

@ -5,6 +5,7 @@ import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.utils.OrderUtil;
import com.hfkj.common.utils.SignatureUtil;
import com.hfkj.config.CommonSysConst;
import com.hfkj.entity.BsOrderMeituan;
import com.hfkj.entity.BsOrderRefund;
@ -103,11 +104,22 @@ public class MeiTuanController {
JSONObject staffInfo = jsonObject.getJSONObject("staffInfo");
// 请求加密
Map<String , Object> map = new HashMap<>();
map.put("appid" , "20241266600");
map.put("phone" , staffInfo.getString("staffPhone"));
String sign = SignatureUtil.createSign(map , "BCB83776BDA7F609FBE99BBB8AC33840");
object.put("thirdTradeNo", thirdTradeNo);
object.put("thirdPayUrl", "https://phg.dctpay.com/cweb/#/pages/meiTuanPay/index?tradeNo=" + jsonObject.getString("tradeNo") +
"&tradeAmount=" + jsonObject.getString("tradeAmount") +
"&outSidePhone=" + staffInfo.getString("staffPhone")
);
"&outSideAppid=" + map.get("appid") +
"&outSideSign=" + sign +
"&outSidePhone=" + staffInfo.getString("staffPhone") +
"&outsidePlatform=" + "WXAPPLETS" +
"&outSideType=" + "SIGN"
);
log.info("美团下单-参数: {}", object);
data.put("status", 0);
data.put("msg", "成功");

@ -0,0 +1,68 @@
package com.hfkj.api;
import com.hfkj.entity.ApiMer;
import java.util.List;
public interface ApiMerService {
/**
* @MethodName create
* @Description: 创建api商户
* @param apiMer
* @Author: Sum1Dream
* @Date: 2024/12/5 下午3:19
*/
void create(ApiMer apiMer);
/**
* @MethodName update
* @Description: /**
* @Description: 更新api商户
* @param apiMer
* @Author: Sum1Dream
* @Date: 2024/12/5 下午3:19
*/
void update(ApiMer apiMer);
/**
* @MethodName delete
* @Description: 删除api商户
* @param id
* @param fullDelete
* @Author: Sum1Dream
* @Date: 2024/12/5 下午3:19
*/
void delete(Long id , Boolean fullDelete);
/**
* @MethodName queryDetail
* @Description: 查询api商户详情
* @param id
* @return: com.hfkj.entity.ApiMer
* @Author: Sum1Dream
* @Date: 2024/12/5 下午3:19
*/
ApiMer queryDetail(Long id);
/**
* @MethodName queryDetail
* @Description: 根据appId查询商户
* @param appId
* @return: com.hfkj.entity.ApiMer
* @Author: Sum1Dream
* @Date: 2024/12/5 下午3:20
*/
ApiMer queryDetail(String appId);
/**
* @MethodName queryList
* @Description: 查询api商户列表
* @param apiMer
* @return: java.util.List<com.hfkj.entity.ApiMer>
* @Author: Sum1Dream
* @Date: 2024/12/5 下午3:20
*/
List<ApiMer> queryList(ApiMer apiMer);
}

@ -0,0 +1,68 @@
package com.hfkj.api.impl;
import com.hfkj.api.ApiMerService;
import com.hfkj.dao.ApiMerMapper;
import com.hfkj.entity.ApiMer;
import com.hfkj.entity.ApiMerExample;
import com.hfkj.entity.BsOrderGoods;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.Date;
import java.util.List;
@Service("apiMerService")
public class ApiMerServiceImpl implements ApiMerService {
@Resource
private ApiMerMapper apiMerMapper;
@Override
public void create(ApiMer apiMer) {
apiMerMapper.insert(apiMer);
}
@Override
public void update(ApiMer apiMer) {
apiMerMapper.updateByPrimaryKey(apiMer);
}
@Override
public void delete(Long id, Boolean fullDelete) {
if (fullDelete) {
apiMerMapper.deleteByPrimaryKey(id);
} else {
ApiMer apiMer = queryDetail(id);
apiMer.setStatus(0);
apiMer.setUpdateTime(new Date());
update(apiMer);
}
}
@Override
public ApiMer queryDetail(Long id) {
return apiMerMapper.selectByPrimaryKey(id);
}
@Override
public ApiMer queryDetail(String appId) {
ApiMerExample example = new ApiMerExample();
ApiMerExample.Criteria criteria = example.createCriteria();
criteria.andAppIdEqualTo(appId).andStatusEqualTo(1);
List<ApiMer> list = apiMerMapper.selectByExample(example);
if (!list.isEmpty()) {
return list.get(0);
}
return null;
}
@Override
public List<ApiMer> queryList(ApiMer apiMer) {
return Collections.emptyList();
}
}

@ -113,6 +113,7 @@ public interface BsUserService {
*/
SessionObject login(UserLoginPlatform platform, UserLoginType loginType, String outsideOpenid, Map<String, Object> other) throws Exception;
SessionObject signLogin(UserLoginPlatform platform, UserLoginType loginType, String phone) throws Exception;
/**
* 退出登录
* @param token

@ -30,6 +30,7 @@ import org.springframework.web.context.request.RequestContextHolder;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -238,6 +239,33 @@ public class BsUserServiceImpl implements BsUserService {
return sessionObject;
}
@Override
public SessionObject signLogin(UserLoginPlatform platform, UserLoginType loginType, String phone) throws Exception {
// 查询用户
BsUser user = getUser(phone);
if (user == null) {
user = register(phone, null , new HashMap<>());
}
// 缓存
UserSessionObject session = new UserSessionObject();
session.setUser(user);
// 查询汇联通工会卡
List<BsUserCard> hltCardList = userCardService.getCardList(user.getId(), UserCardTypeEnum.type1);
if (hltCardList.isEmpty()) {
session.setHltCardBind(false);
} else {
session.setHltCardBind(true);
session.setHltCard(hltCardList.get(0));
}
SessionObject sessionObject = new SessionObject(token(user), session);
userCenter.save(sessionObject);
// 异步记录登录信息
userLoginLogService.asyncCreateLog(platform, loginType, user, (HttpServletRequest) RequestContextHolder.getRequestAttributes().resolveReference(RequestAttributes.REFERENCE_REQUEST));
return sessionObject;
}
@Override
public void loginOut(String token) {
userCenter.remove(token);

@ -13,6 +13,7 @@ public enum UserLoginPlatform {
WXAPPLETS("WXAPPLETS", "普汇GO"),
VFAMILY("VFAMILY", "V家园"),
GZGOV("GZGOV", "省自机关"),
HIGH("HIGH", "嗨加油"),
;
private String code;

@ -16,6 +16,7 @@ public enum UserLoginType {
WECHAT_MP_OPENID("WECHAT_MP_OPENID", "微信公众号openId"),
V_FAMILY_OPENID("V_FAMILY_OPENID", "V家园openId"),
GZ_GOV_OPENID("GZ_GOV_OPENID", "省自机关openId"),
SIGN("SIGN", "加密登陆"),
;
private String code;

@ -3,12 +3,15 @@ package com.user.controller;
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
import com.alibaba.fastjson.JSONObject;
import com.hfkj.api.ApiMerService;
import com.hfkj.common.exception.ErrorCode;
import com.hfkj.common.exception.ErrorHelp;
import com.hfkj.common.exception.SysCode;
import com.hfkj.common.security.UserCenter;
import com.hfkj.common.utils.*;
import com.hfkj.config.CommonSysConst;
import com.hfkj.config.WxMaConfig;
import com.hfkj.entity.ApiMer;
import com.hfkj.entity.BsUser;
import com.hfkj.entity.BsUserComplaint;
import com.hfkj.model.ResponseData;
@ -54,6 +57,8 @@ public class BsUserController {
private RedisUtil redisUtil;
@Resource
private BsUserComplaintService userComplaintService;
@Resource
private ApiMerService apiMerService;
@RequestMapping(value = "/phone", method = RequestMethod.POST)
@ResponseBody
@ -156,48 +161,64 @@ public class BsUserController {
}
}
// @RequestMapping(value = "/phoneNotVerify", method = RequestMethod.POST)
// @ResponseBody
// @ApiOperation(value = "H5手机号不校验登陆")
// public ResponseData phoneNotVerify(@RequestBody JSONObject body) {
// try {
// if (body == null
// || StringUtils.isBlank(body.getString("platform"))
// || StringUtils.isBlank(body.getString("type"))
// || StringUtils.isBlank(body.getString("phone"))
// ) {
// log.error("LoginController --> phone() error!", "请求参数校验失败");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
// }
// String phone = body.getString("phone");
// String password = body.getString("password");
//
// // 客户端
// UserLoginPlatform platform = UserLoginPlatform.getDataByType(body.getString("platform"));
// if (platform == null) {
// log.error("LoginController --> phone() error!", "未知客户端");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知客户端");
// }
// // 校验手机号格式
// if (!MemberValidateUtil.validatePhone(phone)) {
// log.error("LoginController --> phone() error!", "请输入正确的手机号");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入正确的手机号");
// }
// // 登录类型
// UserLoginType loginType = UserLoginType.getDataByType(body.getString("type"));
// if (loginType == null) {
// log.error("LoginController --> phone() error!", "未知登录类型;" + body.getString("type"));
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知登录类型");
// }
//
// Map<String, Object> other = new HashMap<>();
// return ResponseMsgUtil.success(userService.login(platform, loginType, phone, password, other));
//
// } catch (Exception e) {
// log.error("LoginController --> phone() error!", e);
// return ResponseMsgUtil.exception(e);
// }
// }
@RequestMapping(value = "/phgSignLogin", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "普惠go加密登陆")
public ResponseData phgSignLogin(@RequestBody JSONObject body) {
try {
if (body == null
|| StringUtils.isBlank(body.getString("platform"))
|| StringUtils.isBlank(body.getString("type"))
|| StringUtils.isBlank(body.getString("phone"))
|| StringUtils.isBlank(body.getString("sign"))
|| StringUtils.isBlank(body.getString("appid"))
) {
log.error("LoginController --> phone() error!", "请求参数校验失败");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
String phone = body.getString("phone");
// 客户端
UserLoginPlatform platform = UserLoginPlatform.getDataByType(body.getString( "platform"));
if (platform == null) {
log.error("LoginController --> phone() error!", "未知客户端");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知客户端");
}
// 校验手机号格式
if (!MemberValidateUtil.validatePhone(phone)) {
log.error("LoginController --> phone() error!", "请输入正确的手机号");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入正确的手机号");
}
// 登录类型
UserLoginType loginType = UserLoginType.getDataByType(body.getString("type"));
if (loginType == null) {
log.error("LoginController --> phone() error!", "未知登录类型;" + body.getString("type"));
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知登录类型");
}
// 校验签名
// 查询api商户信息
ApiMer apiMer = apiMerService.queryDetail(body.getString("appid"));
if (apiMer == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "商户不存在");
}
Map<String , Object> map = new HashMap<>();
map.put("appid" , body.getString("appid"));
map.put("phone" , body.getString("phone"));
String sign = SignatureUtil.createSign(map , apiMer.getAppSecret());
if (!body.getString("sign").equals(sign)) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "签名校验失败!");
}
return ResponseMsgUtil.success(userService.signLogin(platform, loginType, phone));
} catch (Exception e) {
log.error("LoginController --> phone() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/phoneTest", method = RequestMethod.POST)
@ResponseBody

Loading…
Cancel
Save