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>(){{
add(curCustomer.getCustomerId());
}};
List<Long> nextLevelCustomerIds = new ArrayList<>();
if (customer.getIsDistributor()) {
// 分销商需要查询所有下一级分销用户作为统计条件
Customer customerQry = new Customer();
@ -87,8 +88,7 @@ public class CustomerController extends BaseController {
customerQry.setStatus(Integer.valueOf(UserStatus.OK.getCode()));
List<Customer> nextLevelCustomers = customerService.getCustomerList(customerQry);
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());
// customerIds.addAll(nextLevelCustomerIds);
nextLevelCustomerIds = nextLevelCustomers.stream().map(Customer::getCustomerId).collect(Collectors.toList());
}
// 本月第一天
@ -138,6 +138,7 @@ public class CustomerController extends BaseController {
// 本月订单数及本月订单额
OrderMaster orderParams1 = new OrderMaster();
customerIds.addAll(nextLevelCustomerIds);
orderParams1.setCustomerIds(customerIds);
orderParams1.setCreateTimeStart(firstDayCurMonth.atStartOfDay());
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.poi.ExcelUtil;
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.web.pojo.vo.FinancialCountRequest;
import org.apache.shiro.authz.annotation.RequiresPermissions;
@ -68,6 +70,14 @@ public class FinancialDetailController extends BaseController {
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)
@RequiresPermissions("financial:detail:export")
@PostMapping("/export")

View File

@ -316,73 +316,77 @@ public class WxController extends BaseController {
@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";
}
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;
try {
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");
// 查询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;
if(flag){
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;
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 org.apache.ibatis.annotations.Param;
@ -44,6 +46,8 @@ public interface FinancialDetailMapper {
*/
List<FinancialDetail> selectFinancialDetailList(FinancialDetail financialDetail);
List<FinancialAccountBillResp> selectFinancialDetailListV2(FinancialAccountBillReq financialAccountBillReq);
/**
* @param financialDetailId 财务细单id
* @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
public class FinancialCountResponse {
private String orderCode;
private String createTime;
private String payCount;

View File

@ -1,6 +1,8 @@
package com.ghy.payment.service;
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 java.util.List;
@ -123,4 +125,7 @@ public interface FinancialDetailService {
* @param reverseId Adapay撤销支付ID
*/
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.payment.domain.FinancialDetail;
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.service.FinancialDetailService;
import org.springframework.stereotype.Service;
@ -93,6 +95,26 @@ public class FinancialDetailServiceImpl implements FinancialDetailService {
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
public FinancialDetail selectById(Long financialDetailId) {
return financialDetailMapper.selectById(financialDetailId);

View File

@ -28,6 +28,16 @@
<result property="remark" column="remark"/>
</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">
<result property="createTime" column="create_time"/>
<result property="payCount" column="pay_count"/>
@ -97,6 +107,51 @@
order by fd.create_time desc
</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">
<include refid="selectFinancialDetail"/> WHERE id = #{financialDetailId}
</select>