fix bug-1

This commit is contained in:
YiFei Kuang 2025-03-24 13:25:38 +08:00
parent b4617d3135
commit fb57b9e9f9
10 changed files with 279 additions and 63 deletions

View File

@ -80,6 +80,7 @@ public class CustomerController extends BaseController {
List<Long> customerIds = new ArrayList<Long>(){{ List<Long> customerIds = new ArrayList<Long>(){{
add(curCustomer.getCustomerId()); add(curCustomer.getCustomerId());
}}; }};
List<Long> nextLevelCustomerIds = new ArrayList<>();
if (customer.getIsDistributor()) { if (customer.getIsDistributor()) {
// 分销商需要查询所有下一级分销用户作为统计条件 // 分销商需要查询所有下一级分销用户作为统计条件
Customer customerQry = new Customer(); Customer customerQry = new Customer();
@ -87,8 +88,7 @@ public class CustomerController extends BaseController {
customerQry.setStatus(Integer.valueOf(UserStatus.OK.getCode())); customerQry.setStatus(Integer.valueOf(UserStatus.OK.getCode()));
List<Customer> nextLevelCustomers = customerService.getCustomerList(customerQry); List<Customer> nextLevelCustomers = customerService.getCustomerList(customerQry);
teamNum = teamNum + nextLevelCustomers.stream().filter(x->PlaceStatus.CAN_PLACE.getCode().equals(x.getPlaceStatus())).count(); teamNum = teamNum + nextLevelCustomers.stream().filter(x->PlaceStatus.CAN_PLACE.getCode().equals(x.getPlaceStatus())).count();
List<Long> nextLevelCustomerIds = nextLevelCustomers.stream().map(Customer::getCustomerId).collect(Collectors.toList()); nextLevelCustomerIds = nextLevelCustomers.stream().map(Customer::getCustomerId).collect(Collectors.toList());
// customerIds.addAll(nextLevelCustomerIds);
} }
// 本月第一天 // 本月第一天
@ -138,6 +138,7 @@ public class CustomerController extends BaseController {
// 本月订单数及本月订单额 // 本月订单数及本月订单额
OrderMaster orderParams1 = new OrderMaster(); OrderMaster orderParams1 = new OrderMaster();
customerIds.addAll(nextLevelCustomerIds);
orderParams1.setCustomerIds(customerIds); orderParams1.setCustomerIds(customerIds);
orderParams1.setCreateTimeStart(firstDayCurMonth.atStartOfDay()); orderParams1.setCreateTimeStart(firstDayCurMonth.atStartOfDay());
List<OrderMaster> ordersCurMonth1 = orderMasterService.selectOrderMasterList(orderParams1); List<OrderMaster> ordersCurMonth1 = orderMasterService.selectOrderMasterList(orderParams1);

View File

@ -9,6 +9,8 @@ import com.ghy.common.enums.BusinessType;
import com.ghy.common.utils.ExceptionUtil; import com.ghy.common.utils.ExceptionUtil;
import com.ghy.common.utils.poi.ExcelUtil; import com.ghy.common.utils.poi.ExcelUtil;
import com.ghy.payment.domain.FinancialDetail; import com.ghy.payment.domain.FinancialDetail;
import com.ghy.payment.request.FinancialAccountBillReq;
import com.ghy.payment.response.FinancialAccountBillResp;
import com.ghy.payment.service.FinancialDetailService; import com.ghy.payment.service.FinancialDetailService;
import com.ghy.web.pojo.vo.FinancialCountRequest; import com.ghy.web.pojo.vo.FinancialCountRequest;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
@ -68,6 +70,14 @@ public class FinancialDetailController extends BaseController {
return getDataTable(list); return getDataTable(list);
} }
@PostMapping("/app/listV2")
@ResponseBody
public TableDataInfo appListV2(@RequestBody FinancialAccountBillReq financialAccountBillReq) {
startPage();
List<FinancialAccountBillResp> list = financialDetailService.selectFinancialDetailListV2(financialAccountBillReq);
return getDataTable(list);
}
@Log(title = "财务细单管理", businessType = BusinessType.EXPORT) @Log(title = "财务细单管理", businessType = BusinessType.EXPORT)
@RequiresPermissions("financial:detail:export") @RequiresPermissions("financial:detail:export")
@PostMapping("/export") @PostMapping("/export")

View File

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

View File

@ -1,6 +1,8 @@
package com.ghy.payment.mapper; package com.ghy.payment.mapper;
import com.ghy.payment.domain.FinancialDetail; import com.ghy.payment.domain.FinancialDetail;
import com.ghy.payment.request.FinancialAccountBillReq;
import com.ghy.payment.response.FinancialAccountBillResp;
import com.ghy.payment.response.FinancialCountResponse; import com.ghy.payment.response.FinancialCountResponse;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -44,6 +46,8 @@ public interface FinancialDetailMapper {
*/ */
List<FinancialDetail> selectFinancialDetailList(FinancialDetail financialDetail); List<FinancialDetail> selectFinancialDetailList(FinancialDetail financialDetail);
List<FinancialAccountBillResp> selectFinancialDetailListV2(FinancialAccountBillReq financialAccountBillReq);
/** /**
* @param financialDetailId 财务细单id * @param financialDetailId 财务细单id
* @return 财务细单 * @return 财务细单

View File

@ -0,0 +1,83 @@
package com.ghy.payment.request;
import lombok.Data;
import java.util.Date;
/**
* @author clunt
*/
@Data
public class FinancialAccountBillReq {
private Long deptId;
private String orderCode;
private Long customerId;
private Long workerId;
private String beginTime;
private String endTime;
// 01.待分账 02.已分账 03.已取消
private String billType;
public Long getDeptId() {
return deptId;
}
public void setDeptId(Long deptId) {
this.deptId = deptId;
}
public String getOrderCode() {
return orderCode;
}
public void setOrderCode(String orderCode) {
this.orderCode = orderCode;
}
public Long getCustomerId() {
return customerId;
}
public void setCustomerId(Long customerId) {
this.customerId = customerId;
}
public Long getWorkerId() {
return workerId;
}
public void setWorkerId(Long workerId) {
this.workerId = workerId;
}
public String getBeginTime() {
return beginTime;
}
public void setBeginTime(String beginTime) {
this.beginTime = beginTime;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
public String getBillType() {
return billType;
}
public void setBillType(String billType) {
this.billType = billType;
}
}

View File

@ -0,0 +1,30 @@
package com.ghy.payment.response;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* @author clunt
*/
@Data
public class FinancialAccountBillResp {
// om.code as order_code,
// fd.pay_money as pay_money,
// om.create_time as create_time,
// om.order_status as order_status,
// fm.pay_status as pay_status,
// fm.code as pay_code,
// fm.pay_time as pay_time
private String orderCode;
private BigDecimal payMoney;
private Date createTime;
private Integer orderStatus;
private String orderStatusDesc;
private Integer payStatus;
private String payStatusDesc;
private String payCode;
private Date payTime;
}

View File

@ -7,6 +7,8 @@ import java.util.List;
@Data @Data
public class FinancialCountResponse { public class FinancialCountResponse {
private String orderCode;
private String createTime; private String createTime;
private String payCount; private String payCount;

View File

@ -1,6 +1,8 @@
package com.ghy.payment.service; package com.ghy.payment.service;
import com.ghy.payment.domain.FinancialDetail; import com.ghy.payment.domain.FinancialDetail;
import com.ghy.payment.request.FinancialAccountBillReq;
import com.ghy.payment.response.FinancialAccountBillResp;
import com.ghy.payment.response.FinancialCountResponse; import com.ghy.payment.response.FinancialCountResponse;
import java.util.List; import java.util.List;
@ -123,4 +125,7 @@ public interface FinancialDetailService {
* @param reverseId Adapay撤销支付ID * @param reverseId Adapay撤销支付ID
*/ */
void refundSucceeded(String reverseId); void refundSucceeded(String reverseId);
List<FinancialAccountBillResp> selectFinancialDetailListV2(FinancialAccountBillReq financialAccountBillReq);
} }

View File

@ -5,6 +5,8 @@ import com.ghy.common.core.text.Convert;
import com.ghy.common.enums.FinancialDetailType; import com.ghy.common.enums.FinancialDetailType;
import com.ghy.payment.domain.FinancialDetail; import com.ghy.payment.domain.FinancialDetail;
import com.ghy.payment.mapper.FinancialDetailMapper; import com.ghy.payment.mapper.FinancialDetailMapper;
import com.ghy.payment.request.FinancialAccountBillReq;
import com.ghy.payment.response.FinancialAccountBillResp;
import com.ghy.payment.response.FinancialCountResponse; import com.ghy.payment.response.FinancialCountResponse;
import com.ghy.payment.service.FinancialDetailService; import com.ghy.payment.service.FinancialDetailService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -93,6 +95,26 @@ public class FinancialDetailServiceImpl implements FinancialDetailService {
return financialDetailMapper.selectFinancialDetailList(financialDetail); return financialDetailMapper.selectFinancialDetailList(financialDetail);
} }
@Override
public List<FinancialAccountBillResp> selectFinancialDetailListV2(FinancialAccountBillReq financialAccountBillReq) {
List<FinancialAccountBillResp> list = financialDetailMapper.selectFinancialDetailListV2(financialAccountBillReq);
list.forEach(model->{
if(model.getOrderStatus() == 6){
model.setOrderStatusDesc("运营利润--已取消");
}else if(model.getOrderStatus() == 5){
model.setOrderStatusDesc("运营利润--已到账");
}else {
model.setOrderStatusDesc("运营利润--待分账");
}
if(model.getPayStatus() == 1){
model.setPayStatusDesc("已支付");
}else {
model.setPayStatusDesc("未支付");
}
});
return list;
}
@Override @Override
public FinancialDetail selectById(Long financialDetailId) { public FinancialDetail selectById(Long financialDetailId) {
return financialDetailMapper.selectById(financialDetailId); return financialDetailMapper.selectById(financialDetailId);

View File

@ -28,6 +28,16 @@
<result property="remark" column="remark"/> <result property="remark" column="remark"/>
</resultMap> </resultMap>
<resultMap id="FinancialAccountBillResult" type="com.ghy.payment.response.FinancialAccountBillResp">
<id property="orderCode" column="order_code"/>
<id property="payMoney" column="pay_money"/>
<id property="createTime" column="create_time"/>
<id property="orderStatus" column="order_status"/>
<id property="payStatus" column="pay_status"/>
<id property="payCode" column="pay_code"/>
<id property="payTime" column="pay_time"/>
</resultMap>
<resultMap id="countResult" type="com.ghy.payment.response.FinancialCountResponse"> <resultMap id="countResult" type="com.ghy.payment.response.FinancialCountResponse">
<result property="createTime" column="create_time"/> <result property="createTime" column="create_time"/>
<result property="payCount" column="pay_count"/> <result property="payCount" column="pay_count"/>
@ -97,6 +107,51 @@
order by fd.create_time desc order by fd.create_time desc
</select> </select>
<select id="selectFinancialDetailListV2" parameterType="com.ghy.payment.request.FinancialAccountBillReq"
resultMap="FinancialAccountBillResult">
select
om.code as order_code,
fd.pay_money as pay_money,
om.create_time as create_time,
om.order_status as order_status,
fm.pay_status as pay_status,
fm.code as pay_code,
fd.pay_time as pay_time
from financial_detail fd
left join financial_master fm on fd.financial_master_id = fm.id
left join order_master om on fm.order_master_id = om.id
<where>
<if test="deptId != null">
AND fd.dept_id = #{deptId}
</if>
<if test="workerId != null">
AND fd.payee_id = #{workerId}
</if>
<if test="customerId != null">
AND fd.payee_id = #{customerId}
</if>
<if test="orderCode != null and orderCode != ''">
AND om.code like concat('%', #{orderCode}, '%')
</if>
<if test="billType == '01'">
AND om.order_status in ('0','1','2','3','4')
</if>
<if test="billType == '02'">
AND om.order_status = '05'
</if>
<if test="billType == '03'">
AND om.order_status = '06'
</if>
<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
and fd.create_time &gt;= #{beginTime}
</if>
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
and fd.create_time &lt;= #{endTime}
</if>
</where>
order by om.create_time desc
</select>
<select id="selectById" parameterType="long" resultMap="FinancialDetailResult"> <select id="selectById" parameterType="long" resultMap="FinancialDetailResult">
<include refid="selectFinancialDetail"/> WHERE id = #{financialDetailId} <include refid="selectFinancialDetail"/> WHERE id = #{financialDetailId}
</select> </select>