入驻信息展示、师傅信息

This commit is contained in:
kuang.yife 2024-08-05 18:06:38 +08:00
parent 228e8d3a70
commit 3bf3f56587
10 changed files with 395 additions and 28 deletions

View File

@ -1,5 +1,6 @@
package com.ghy.web.controller.tool;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
@ -190,6 +191,72 @@ public class WxController extends BaseController {
String data = HttpUtils.sendGet(url, null);
JSONObject result = JSONObject.parseObject(data);
// 如果是师傅端,需要调用公众号的获取用户列表接口 -- 遍历列表去找到unionId和openid关联并入库
// if(!"customer".equals(from)){
// String openid = result.getString("openid");
// String unionId = result.getString("unionid");
// // 查询openid是否入库已经入库则不管
// Worker param = new Worker();
// param.setOpenId(openid);
// Worker worker = workerService.selectByOpenId(param);
// if(worker != null && StringUtils.isEmpty(worker.getWxOpenId())){
// // 公众号token
// String wxToken = WechatMsgUtils.getToken();
// String wxUserOpenidList = HttpUtils.sendGet("https://api.weixin.qq.com/cgi-bin/user/get?access_token="+wxToken+"&next_openid=");
// logger.info("公众号获取的用户列表集合:{}", wxUserOpenidList);
// JSONObject wxOpenidJson = JSONObject.parseObject(wxUserOpenidList);
// JSONObject openIdListJson = wxOpenidJson.getJSONObject("data");
// List<String> openidList = openIdListJson.getObject("openid", ArrayList.class);
// JSONArray openidJsonArray = new JSONArray();
// openidList.forEach(model->{
// JSONObject openidJson = new JSONObject();
// openidJson.put("openid", model);
// openidJson.put("lang", "zh_CN");
// openidJsonArray.add(openidJson);
// });
// JSONObject jsonParam = new JSONObject();
// xw jsonParam.put("user_list", openidJsonArray);
// String unionUrl = "https://api.weixin.qq.com/cgi-bin/user/info/batchget?access_token="+WechatMsgUtils.getToken();;
// logger.info("调用获取用户信息,请求url:{}, 请求body:{}", unionUrl, jsonParam.toJSONString());
// String getUnionResult = HttpUtil.post(unionUrl, jsonParam.toJSONString());
// logger.info("获取公众号union列表:{}", getUnionResult);
// JSONObject unionJson = JSONObject.parseObject(getUnionResult);
// JSONArray unionJsonArray = unionJson.getJSONArray("user_info_list");
// for (int index = 0 ; index<unionJsonArray.size(); index ++){
// JSONObject json = unionJsonArray.getJSONObject(index);
// if(StringUtils.isEmpty(json.getString("unionid"))||StringUtils.isEmpty(unionId)){
// return AjaxResult.success(result);
// }
// if(json.getString("unionid").equals(unionId)){
// Worker updateWorker = new Worker();
// updateWorker.setWorkerId(worker.getWorkerId());
// updateWorker.setWxOpenId(json.getString("openid"));
// logger.info("关联后的worker信息:{}", worker);
// workerService.updateWorker(updateWorker);
// }
// }
// }
//
// }
return AjaxResult.success(result);
}
@GetMapping("/check")
@ResponseBody
public AjaxResult check(HttpServletRequest request) {
String url;
boolean flag = false;
String deptId = request.getHeader("deptId");
String from = request.getHeader("from");
SysDeptConfig sysDeptConfig = sysDeptConfigService.selectByDeptId(Long.parseLong(deptId));
String code = request.getHeader("code");
if("customer".equals(from)){
url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + sysDeptConfig.getWxAppId() + "&secret=" + sysDeptConfig.getWxSecret() + "&js_code=" + code + "&grant_type=authorization_code";
}else {
url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + sysDeptConfig.getServWxAppId() + "&secret=" + sysDeptConfig.getServWxSecret() + "&js_code=" + code + "&grant_type=authorization_code";
}
String data = HttpUtils.sendGet(url, null);
JSONObject result = JSONObject.parseObject(data);
// 如果是师傅端,需要调用公众号的获取用户列表接口 -- 遍历列表去找到unionId和openid关联并入库
if(!"customer".equals(from)){
String openid = result.getString("openid");
String unionId = result.getString("unionid");
@ -197,7 +264,7 @@ public class WxController extends BaseController {
Worker param = new Worker();
param.setOpenId(openid);
Worker worker = workerService.selectByOpenId(param);
if(worker != null && StringUtils.isEmpty(worker.getWxOpenId())){
if(worker != null){
// 公众号token
String wxToken = WechatMsgUtils.getToken();
String wxUserOpenidList = HttpUtils.sendGet("https://api.weixin.qq.com/cgi-bin/user/get?access_token="+wxToken+"&next_openid=");
@ -205,8 +272,10 @@ public class WxController extends BaseController {
JSONObject wxOpenidJson = JSONObject.parseObject(wxUserOpenidList);
JSONObject openIdListJson = wxOpenidJson.getJSONObject("data");
List<String> openidList = openIdListJson.getObject("openid", ArrayList.class);
List<List<String>> batchList = ListUtil.partition(openidList, 99);
for (List<String> childOpenidList : batchList) {
JSONArray openidJsonArray = new JSONArray();
openidList.forEach(model->{
childOpenidList.forEach(model->{
JSONObject openidJson = new JSONObject();
openidJson.put("openid", model);
openidJson.put("lang", "zh_CN");
@ -222,18 +291,98 @@ public class WxController extends BaseController {
JSONArray unionJsonArray = unionJson.getJSONArray("user_info_list");
for (int index = 0 ; index<unionJsonArray.size(); index ++){
JSONObject json = unionJsonArray.getJSONObject(index);
if(StringUtils.isNotEmpty(json.getString("unionid") )&& StringUtils.isNotEmpty(unionId)){
if(json.getString("unionid").equals(unionId)){
Worker updateWorker = new Worker();
updateWorker.setWorkerId(worker.getWorkerId());
updateWorker.setWxOpenId(json.getString("openid"));
logger.info("关联后的worker信息:{}", worker);
workerService.updateWorker(updateWorker);
flag = true;
break;
}
}
}
if(flag){
break;
}
}
}
}
return AjaxResult.success(true);
}
@GetMapping("/neCheck")
@ResponseBody
public AjaxResult neCheck(HttpServletRequest request) {
String url;
boolean flag = false;
String deptId = request.getHeader("deptId");
String from = request.getHeader("from");
SysDeptConfig sysDeptConfig = sysDeptConfigService.selectByDeptId(Long.parseLong(deptId));
String code = request.getHeader("code");
if("customer".equals(from)){
url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + sysDeptConfig.getWxAppId() + "&secret=" + sysDeptConfig.getWxSecret() + "&js_code=" + code + "&grant_type=authorization_code";
}else {
url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + sysDeptConfig.getServWxAppId() + "&secret=" + sysDeptConfig.getServWxSecret() + "&js_code=" + code + "&grant_type=authorization_code";
}
return AjaxResult.success(result);
String data = HttpUtils.sendGet(url, null);
JSONObject result = JSONObject.parseObject(data);
// 如果是师傅端,需要调用公众号的获取用户列表接口 -- 遍历列表去找到unionId和openid关联并入库
if(!"customer".equals(from)){
String openid = result.getString("openid");
String unionId = result.getString("unionid");
// 查询openid是否入库已经入库则不管
Worker param = new Worker();
param.setOpenId(openid);
Worker worker = workerService.selectByOpenId(param);
if(worker != null){
// 公众号token
String wxToken = WechatMsgUtils.getToken();
String wxUserOpenidList = HttpUtils.sendGet("https://api.weixin.qq.com/cgi-bin/user/get?access_token="+wxToken+"&next_openid=");
logger.info("公众号获取的用户列表集合:{}", wxUserOpenidList);
JSONObject wxOpenidJson = JSONObject.parseObject(wxUserOpenidList);
JSONObject openIdListJson = wxOpenidJson.getJSONObject("data");
List<String> openidList = openIdListJson.getObject("openid", ArrayList.class);
List<List<String>> batchList = ListUtil.partition(openidList, 99);
for (List<String> childOpenidList : batchList) {
JSONArray openidJsonArray = new JSONArray();
childOpenidList.forEach(model->{
JSONObject openidJson = new JSONObject();
openidJson.put("openid", model);
openidJson.put("lang", "zh_CN");
openidJsonArray.add(openidJson);
});
JSONObject jsonParam = new JSONObject();
jsonParam.put("user_list", openidJsonArray);
String unionUrl = "https://api.weixin.qq.com/cgi-bin/user/info/batchget?access_token="+WechatMsgUtils.getToken();;
logger.info("调用获取用户信息,请求url:{}, 请求body:{}", unionUrl, jsonParam.toJSONString());
String getUnionResult = HttpUtil.post(unionUrl, jsonParam.toJSONString());
logger.info("获取公众号union列表:{}", getUnionResult);
JSONObject unionJson = JSONObject.parseObject(getUnionResult);
JSONArray unionJsonArray = unionJson.getJSONArray("user_info_list");
for (int index = 0 ; index<unionJsonArray.size(); index ++){
JSONObject json = unionJsonArray.getJSONObject(index);
if(StringUtils.isNotEmpty(json.getString("unionid") )&& StringUtils.isNotEmpty(unionId)){
if(json.getString("unionid").equals(unionId)){
Worker updateWorker = new Worker();
updateWorker.setWorkerId(worker.getWorkerId());
updateWorker.setWxOpenId(json.getString("openid"));
logger.info("关联后的worker信息:{}", worker);
workerService.updateWorker(updateWorker);
flag = true;
break;
}
}
}
if(flag){
break;
}
}
}
}
return AjaxResult.success(flag);
}

View File

@ -1,7 +1,10 @@
package com.ghy.web.controller.worker;
import com.ghy.common.core.controller.BaseController;
import com.ghy.common.core.domain.AjaxResult;
import com.ghy.common.core.page.TableDataInfo;
import com.ghy.common.core.text.Convert;
import com.ghy.order.domain.OrderGoods;
import com.ghy.system.domain.SysArea;
import com.ghy.system.service.ISysAreaService;
import com.ghy.worker.domain.WorkerArea;
@ -11,6 +14,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.ModelMap;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
@ -26,7 +30,7 @@ import java.util.stream.Collectors;
@Slf4j
@Controller
@RequestMapping("worker/area")
public class WorkerAreaController {
public class WorkerAreaController extends BaseController {
@Resource
private WorkerAreaService workerAreaService;
@ -34,6 +38,21 @@ public class WorkerAreaController {
@Autowired
private ISysAreaService sysAreaService;
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(WorkerArea workerArea) {
startPage();
List<WorkerArea> list = workerAreaService.getWorkerAreaList(workerArea);
return getDataTable(list);
}
@GetMapping()
public String area(Long workerId, ModelMap mmap)
{
mmap.put("workerId", workerId);
return "worker/areaDetail";
}
/**
* 查询某个师傅的所有接单地区
*

View File

@ -100,11 +100,13 @@ public class WorkerController extends BaseController {
@ResponseBody
public AjaxResult register(@RequestBody Worker request){
try {
logger.info("注册师傅信息:{}", request);
if (CacheUtils.get(request.getPhone()) == null){
return AjaxResult.error("验证码无效!");
}
// 验证码校验正确
if(CacheUtils.get(request.getPhone()).toString().equals(request.getRegisterCode())){
logger.info("验证码信息:{}", CacheUtils.get(request.getPhone()));
int result = workerService.updateWorker(request);
if(result > 0){
CacheUtils.remove(request.getPhone());

View File

@ -1,11 +1,14 @@
package com.ghy.web.controller.worker;
import com.ghy.common.constant.Constants;
import com.ghy.common.core.controller.BaseController;
import com.ghy.common.core.domain.AjaxResult;
import com.ghy.common.core.page.TableDataInfo;
import com.ghy.common.core.text.Convert;
import com.ghy.common.utils.StringUtils;
import com.ghy.goods.domain.GoodsCategory;
import com.ghy.goods.service.GoodsCategoryService;
import com.ghy.worker.domain.WorkerArea;
import com.ghy.worker.domain.WorkerGoodsCategory;
import com.ghy.worker.request.WorkerGoodsCategorySaveRequest;
import com.ghy.worker.service.WorkerGoodsCategoryService;
@ -13,6 +16,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.ModelMap;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
@ -28,7 +32,7 @@ import java.util.stream.Collectors;
@Slf4j
@Controller
@RequestMapping("worker/goods/category")
public class WorkerGoodsCategoryController {
public class WorkerGoodsCategoryController extends BaseController {
@Resource
private WorkerGoodsCategoryService workerGoodsCategoryService;
@ -36,6 +40,33 @@ public class WorkerGoodsCategoryController {
@Autowired
private GoodsCategoryService goodsCategoryService;
@PostMapping("/list")
@ResponseBody
public TableDataInfo list(WorkerGoodsCategory workerGoodsCategory) {
startPage();
List<WorkerGoodsCategory> list = workerGoodsCategoryService.getByWorker(workerGoodsCategory.getWorkerId());
for (WorkerGoodsCategory item: list) {
List<String> nameList = new ArrayList<String>();
// 查询所有父级服务类目拼接服务名称
GoodsCategory goodsCategory = goodsCategoryService.selectById(item.getGoodsCategoryId());
while (goodsCategory.getParentCategoryId() != null) {
nameList.add(goodsCategory.getGoodsCategoryName());
goodsCategory = goodsCategoryService.selectById(goodsCategory.getParentCategoryId());
}
Collections.reverse(nameList);
item.setMergeName(StringUtils.join(nameList, Constants.JOIN_SYMBOL));
}
return getDataTable(list);
}
@GetMapping()
public String category(Long workerId, ModelMap mmap)
{
mmap.put("workerId", workerId);
return "worker/categoryDetail";
}
/**
* 查询某个师傅的所有服务类目
*

View File

@ -0,0 +1,73 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
<th:block th:include="include :: header('服务区域')"/>
<th:block th:include="include :: layout-latest-css"/>
</head>
<body class="gray-bg">
<div class="ui-layout-center">
<div class="container-div">
<div class="row">
<div class="col-sm-12 search-collapse">
<form id="order-goods-form">
<!-- <input type="hidden" id="orderId" name="orderId" th:value="${orderMaster.id}">-->
</form>
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table"></table>
</div>
</div>
</div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/>
<script th:inline="javascript">
var prefix = ctx + "worker/area";
var workerId = '[[${workerId}]]';
$(function () {
var panehHidden = false;
if ($(this).width() < 769) {
panehHidden = true;
}
$('body').layout({initClosed: panehHidden, west__size: 185});
// 回到顶部绑定
if ($.fn.toTop !== undefined) {
var opt = {
win: $('.ui-layout-center'),
doc: $('.ui-layout-center')
};
$('#scroll-up').toTop(opt);
}
queryOrderGoodsList();
});
function queryOrderGoodsList() {
var options = {
url: prefix + "/list?workerId=" + workerId,
modalName: "服务区域",
search: false,
showSearch: false,
showToggle: false,
showColumns: false,
showRefresh: false,
columns: [
{
field: 'mergerName',
title: '服务区域'
}
]
};
$.table.init(options);
}
</script>
</body>
</html>

View File

@ -0,0 +1,73 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
<th:block th:include="include :: header('服务技能')"/>
<th:block th:include="include :: layout-latest-css"/>
</head>
<body class="gray-bg">
<div class="ui-layout-center">
<div class="container-div">
<div class="row">
<div class="col-sm-12 search-collapse">
<form id="order-goods-form">
<!-- <input type="hidden" id="orderId" name="orderId" th:value="${orderMaster.id}">-->
</form>
</div>
<div class="col-sm-12 select-table table-striped">
<table id="bootstrap-table"></table>
</div>
</div>
</div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/>
<script th:inline="javascript">
var prefix = ctx + "worker/goods/category";
var workerId = '[[${workerId}]]';
$(function () {
var panehHidden = false;
if ($(this).width() < 769) {
panehHidden = true;
}
$('body').layout({initClosed: panehHidden, west__size: 185});
// 回到顶部绑定
if ($.fn.toTop !== undefined) {
var opt = {
win: $('.ui-layout-center'),
doc: $('.ui-layout-center')
};
$('#scroll-up').toTop(opt);
}
queryOrderGoodsList();
});
function queryOrderGoodsList() {
var options = {
url: prefix + "/list?workerId=" + workerId,
modalName: "服务技能",
search: false,
showSearch: false,
showToggle: false,
showColumns: false,
showRefresh: false,
columns: [
{
field: 'mergeName',
title: '服务技能'
}
]
};
$.table.init(options);
}
</script>
</body>
</html>

View File

@ -152,6 +152,8 @@
formatter: function(value, row, index) {
if (row.workerId != 1) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="areaDetail(\'' + row.workerId + '\')"><i class="fa fa-info"></i>服务区域</a> ');
actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="categoryDetail(\'' + row.workerId + '\')"><i class="fa fa-info"></i>服务技能</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.workerId + '\')"><i class="fa fa-remove"></i>删除</a> ');
return actions.join('');
} else {
@ -170,6 +172,15 @@
$.modal.open("重置密码", url, '800', '300');
}
function areaDetail(id) {
var url = "worker/area?workerId=" + id;
$.modal.open("区域信息", url);
}
function categoryDetail(id) {
var url = "worker/goods/category?workerId=" + id;
$.modal.open("技能信息", url);
}
/* 用户状态显示 */
function statusTools(row) {

View File

@ -259,6 +259,7 @@ public class AdapayService {
// 目前仅支持bank_account银行卡
settleCountParams.put("channel", "bank_account");
settleCountParams.put("account_info", accountInfo);
log.info("创建结算账户请求,会员:{}, 内容:{}", memberId, settleCountParams);
return (JSONObject) SettleAccount.create(settleCountParams, deptId.toString());
}

View File

@ -14,6 +14,8 @@ public interface WorkerMapper {
*/
List<Worker> getWorkerList(Worker worker);
Worker getWorkerByOpenId(@Param("openId") String openId);
/**
* @param worker 师傅端
* @return 师傅集合

View File

@ -121,6 +121,11 @@
)
</select>
<select id="getWorkerByOpenId" parameterType="String" resultMap="WorkerResult">
<include refid="selectBasic"></include>
where open_id = #{openId}
</select>
<select id="getWorkByPhoneAndPwd" parameterType="com.ghy.worker.domain.Worker" resultMap="WorkerResult">
<include refid="selectBasic" />
where phone = #{phone} and password = #{password}
@ -173,6 +178,7 @@
<if test="phone != null and phone != ''"> phone = #{phone},</if>
<if test="password != null and password != ''"> password = #{password},</if>
<if test="name != null and name != ''"> name = #{name},</if>
<if test="workerLogoUrl != null and workerLogoUrl != ''">worker_logo_url = #{workerLogoUrl},</if>
<if test="leaderTeamRate != null and leaderTeamRate != ''"> leader_team_rate = #{leaderTeamRate},</if>
<if test="leaderTeamMoney != null and leaderTeamMoney != ''"> leader_team_money = #{leaderTeamMoney},</if>
<if test="alipayAccount != null and alipayAccount != ''">alipay_account = #{alipayAccount},</if>