Merge remote-tracking branch 'origin/master'
# Conflicts: # ghy-payment/src/main/java/com/ghy/payment/mapper/FinancialDetailMapper.java # ghy-payment/src/main/java/com/ghy/payment/service/FinancialDetailService.java # ghy-payment/src/main/java/com/ghy/payment/service/impl/FinancialDetailServiceImpl.java
This commit is contained in:
commit
807a2256a7
|
|
@ -253,7 +253,7 @@ public class OrderController extends BaseController {
|
|||
|
||||
BigDecimal deptTotal = payMoney.multiply(deptRate).add(deptMoney);
|
||||
|
||||
FinancialDetail deptDetail = new FinancialDetail(financialDetailService.createCode(), deptId,
|
||||
FinancialDetail deptDetail = new FinancialDetail(deptId, financialDetailService.createCode(),
|
||||
financialMaster.getId(), financialMaster.getCode(), deptTotal, 3, null);
|
||||
financialDetailService.insertFinancialDetail(deptDetail);
|
||||
|
||||
|
|
@ -263,7 +263,7 @@ public class OrderController extends BaseController {
|
|||
|
||||
BigDecimal retainTotal = payMoney.multiply(retainRate).add(retainMoney);
|
||||
|
||||
FinancialDetail retainDetail = new FinancialDetail(financialDetailService.createCode(), deptId,
|
||||
FinancialDetail retainDetail = new FinancialDetail(deptId, financialDetailService.createCode(),
|
||||
financialMaster.getId(), financialMaster.getCode(), retainTotal, 2, null);
|
||||
financialDetailService.insertFinancialDetail(retainDetail);
|
||||
|
||||
|
|
@ -277,7 +277,7 @@ public class OrderController extends BaseController {
|
|||
|
||||
// 一级分销
|
||||
if (customerPlaceId != null) {
|
||||
FinancialDetail financialDetail = new FinancialDetail(financialDetailService.createCode(), deptId,
|
||||
FinancialDetail financialDetail = new FinancialDetail(deptId, financialDetailService.createCode(),
|
||||
financialMaster.getId(), financialMaster.getCode(), onePlaceMoney, 2, customerPlaceId);
|
||||
financialDetailService.insertFinancialDetail(financialDetail);
|
||||
} else {
|
||||
|
|
@ -287,7 +287,7 @@ public class OrderController extends BaseController {
|
|||
// 二级分销
|
||||
Long parentCustomerPlaceId = customer.getParentCustomerPlace();
|
||||
if (parentCustomerPlaceId != null) {
|
||||
FinancialDetail financialDetail = new FinancialDetail(financialDetailService.createCode(), deptId,
|
||||
FinancialDetail financialDetail = new FinancialDetail(deptId, financialDetailService.createCode(),
|
||||
financialMaster.getId(), financialMaster.getCode(), twoPlaceMoney, 2, parentCustomerPlaceId);
|
||||
financialDetailService.insertFinancialDetail(financialDetail);
|
||||
} else {
|
||||
|
|
@ -296,7 +296,7 @@ public class OrderController extends BaseController {
|
|||
|
||||
// 平台分销
|
||||
deptPlaceTotal = deptPlaceTotal.add(threePlaceMoney);
|
||||
FinancialDetail financialDetail = new FinancialDetail(financialDetailService.createCode(), deptId,
|
||||
FinancialDetail financialDetail = new FinancialDetail(deptId, financialDetailService.createCode(),
|
||||
financialMaster.getId(), financialMaster.getCode(), deptPlaceTotal, 2, null);
|
||||
financialDetailService.insertFinancialDetail(financialDetail);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,60 @@
|
|||
package com.ghy.web.controller.pay;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ghy.common.adapay.model.AdapayStatusEnum;
|
||||
import com.ghy.common.core.domain.AjaxResult;
|
||||
import com.ghy.order.domain.OrderMaster;
|
||||
import com.ghy.order.service.OrderMasterService;
|
||||
import com.ghy.payment.domain.FinancialMaster;
|
||||
import com.ghy.payment.service.AdapayService;
|
||||
import com.ghy.payment.service.FinancialMasterService;
|
||||
import com.huifu.adapay.core.exception.BaseAdaPayException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author HH 2022/6/1
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping("pay")
|
||||
public class PayController {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(PayController.class);
|
||||
|
||||
@Resource
|
||||
private AdapayService adapayService;
|
||||
@Resource
|
||||
private OrderMasterService orderMasterService;
|
||||
@Resource
|
||||
private FinancialMasterService financialMasterService;
|
||||
|
||||
/**
|
||||
* 撤销支付
|
||||
*
|
||||
* @param orderMasterId 主订单ID
|
||||
* @param reverseAmt 撤销金额 保留两位小数
|
||||
*/
|
||||
@PostMapping("reverse")
|
||||
@ResponseBody
|
||||
public AjaxResult reverse(Long orderMasterId, String reverseAmt) throws BaseAdaPayException {
|
||||
OrderMaster orderMaster = orderMasterService.selectById(orderMasterId);
|
||||
Assert.notNull(orderMaster, "找不到对应的订单");
|
||||
FinancialMaster financialMaster = financialMasterService.selectByOrderMasterId(orderMasterId);
|
||||
Assert.notNull(financialMaster, "找不到订单");
|
||||
Assert.isTrue(financialMaster.getPayStatus() == 1, "订单未支付");
|
||||
Assert.hasText(financialMaster.getPaymentId(), "找不到订单的支付记录,请联系管理员");
|
||||
JSONObject response = adapayService.payReverse(orderMaster.getDeptId(), financialMaster.getPaymentId(), reverseAmt);
|
||||
if (AdapayStatusEnum.succeeded.code.equals(response.getString("status"))) {
|
||||
return AjaxResult.success();
|
||||
} else {
|
||||
return AjaxResult.error(response.getString("error_msg"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,9 +6,11 @@ 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.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.service.FinancialDetailService;
|
||||
import com.ghy.web.pojo.vo.FinancialCountRequest;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
|
|
@ -38,6 +40,17 @@ public class FinancialDetailController extends BaseController {
|
|||
return prefix;
|
||||
}
|
||||
|
||||
@PostMapping("/count")
|
||||
@ResponseBody
|
||||
public AjaxResult count(@RequestBody FinancialCountRequest request){
|
||||
try {
|
||||
return AjaxResult.success(financialDetailService.count(request.getCountTime()));
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return AjaxResult.error(ExceptionUtil.getExceptionMessage(e));
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresPermissions("financial:detail:list")
|
||||
@PostMapping("/list")
|
||||
@ResponseBody
|
||||
|
|
|
|||
|
|
@ -0,0 +1,66 @@
|
|||
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.utils.ExceptionUtil;
|
||||
import com.ghy.worker.domain.WorkerTeam;
|
||||
import com.ghy.worker.service.WorkerTeamService;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/worker/team")
|
||||
public class WorkerTeamController extends BaseController {
|
||||
|
||||
@Resource
|
||||
private WorkerTeamService workerTeamService;
|
||||
|
||||
@PostMapping("/addTeam")
|
||||
@ResponseBody
|
||||
public AjaxResult addTeam(@RequestBody WorkerTeam workerTeam){
|
||||
try {
|
||||
int result = workerTeamService.insertWorkerTeam(workerTeam);
|
||||
if(result > 0){
|
||||
return AjaxResult.success("新增成功");
|
||||
}else {
|
||||
return AjaxResult.warn("新增失败");
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
logger.error(e.getMessage());
|
||||
return AjaxResult.error(ExceptionUtil.getExceptionMessage(e));
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/getTeamList")
|
||||
@ResponseBody
|
||||
public TableDataInfo getTeamList(@RequestBody WorkerTeam workerTeam){
|
||||
startPage();
|
||||
List<WorkerTeam> list = workerTeamService.getWorkerTeam(workerTeam);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@PostMapping("/updateTeam")
|
||||
@ResponseBody
|
||||
public AjaxResult updateTeam(@RequestBody WorkerTeam workerTeam){
|
||||
try {
|
||||
int result = workerTeamService.updateWorkerTeam(workerTeam);
|
||||
if(result > 0){
|
||||
return AjaxResult.success("修改成功");
|
||||
}else {
|
||||
return AjaxResult.warn("修改失败");
|
||||
}
|
||||
}catch (Exception e){
|
||||
logger.error(e.getMessage());
|
||||
return AjaxResult.error(ExceptionUtil.getExceptionMessage(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.ghy.web.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class FinancialCountRequest {
|
||||
|
||||
private String countTime;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.ghy.web.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class FinancialCountResponse {
|
||||
|
||||
private String createTime;
|
||||
|
||||
private String payCount;
|
||||
|
||||
private String incomeCount;
|
||||
|
||||
}
|
||||
|
|
@ -3,6 +3,8 @@ package com.ghy.common.adapay;
|
|||
import com.ghy.common.adapay.model.Merchant;
|
||||
import com.huifu.adapay.Adapay;
|
||||
import com.huifu.adapay.model.MerConfig;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.util.Assert;
|
||||
|
|
@ -21,6 +23,8 @@ import java.util.stream.Collectors;
|
|||
@EnableConfigurationProperties(AdapayProperties.class)
|
||||
public class AdapayConfig {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(AdapayConfig.class);
|
||||
|
||||
/**
|
||||
* 商户配置
|
||||
*/
|
||||
|
|
@ -38,6 +42,7 @@ public class AdapayConfig {
|
|||
Assert.notEmpty(merchants, "Merchants is empty!");
|
||||
Map<String, MerConfig> configPathMap = new HashMap<>(merchants.size());
|
||||
for (Merchant merchant : merchants) {
|
||||
logger.info("Adapay load merchant : {}", merchant.getDeptId());
|
||||
check(merchant);
|
||||
MerConfig merConfig = new MerConfig();
|
||||
merConfig.setApiKey(merchant.getApiKey());
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import lombok.Data;
|
|||
* @author HH 2022/4/1
|
||||
*/
|
||||
@Data
|
||||
public class DrawCashReply {
|
||||
public class DrawCashCallback {
|
||||
|
||||
/**
|
||||
* 订单号
|
||||
|
|
@ -9,7 +9,7 @@ import lombok.Data;
|
|||
* @author HH 2022/3/29
|
||||
*/
|
||||
@Data
|
||||
public class PayReply {
|
||||
public class PayCallback {
|
||||
|
||||
/**
|
||||
* 返参,必填,由AdaPay生成的支付对象 ID
|
||||
|
|
@ -0,0 +1,43 @@
|
|||
package com.ghy.common.adapay.model;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 撤销支付后Adapay回调接口传过来的数据
|
||||
*
|
||||
* @author HH 2022/5/31
|
||||
*/
|
||||
@Data
|
||||
public class PayReverseCallback {
|
||||
|
||||
private String id;
|
||||
private String status;
|
||||
@JSONField(name = "error_code")
|
||||
private String errorCode;
|
||||
@JSONField(name = "error_msg")
|
||||
private String errorMsg;
|
||||
@JSONField(name = "error_type")
|
||||
private String errorType;
|
||||
@JSONField(name = "prod_mode")
|
||||
private String prodMode;
|
||||
@JSONField(name = "order_no")
|
||||
private String orderNo;
|
||||
@JSONField(name = "payment_id")
|
||||
private String paymentId;
|
||||
@JSONField(name = "reverse_amt")
|
||||
private String reverseAmt;
|
||||
@JSONField(name = "reversed_amt")
|
||||
private String reversedAmt;
|
||||
@JSONField(name = "confirmed_amt")
|
||||
private String confirmedAmt;
|
||||
@JSONField(name = "refunded_amt")
|
||||
private String refundedAmt;
|
||||
@JSONField(name = "createdTime")
|
||||
private String created_time;
|
||||
@JSONField(name = "succeed_time")
|
||||
private String succeedTime;
|
||||
@JSONField(name = "channel_no")
|
||||
private String channelNo;
|
||||
private String reason;
|
||||
}
|
||||
|
|
@ -9,7 +9,7 @@ import lombok.Data;
|
|||
* @author HH 2022/3/29
|
||||
*/
|
||||
@Data
|
||||
public class RefundReply {
|
||||
public class RefundCallback {
|
||||
/**
|
||||
* 退款目标支付对象 id
|
||||
*/
|
||||
|
|
@ -282,6 +282,7 @@ public class ShiroConfig
|
|||
filterChainDefinitionMap.put("/worker/**", "anon");
|
||||
filterChainDefinitionMap.put("/customer/**", "anon");
|
||||
filterChainDefinitionMap.put("/goods/**", "anon");
|
||||
filterChainDefinitionMap.put("/financial/**", "anon");
|
||||
filterChainDefinitionMap.put("/tool/**", "anon");
|
||||
filterChainDefinitionMap.put("/adapay/**", "anon");
|
||||
filterChainDefinitionMap.put("/system/area/**", "anon");
|
||||
|
|
|
|||
|
|
@ -46,18 +46,24 @@ public class FinancialDetail extends BaseEntity {
|
|||
@Excel(name = "实付金额", cellType = Excel.ColumnType.STRING)
|
||||
private BigDecimal payMoney;
|
||||
|
||||
@Excel(name = "财务子单类型,1师傅转派/2多级分销/3平台抽成", cellType = Excel.ColumnType.NUMERIC)
|
||||
@Excel(name = "财务子单类型,1师傅转派/2多级分销/3平台抽成/4撤销支付或退款", cellType = Excel.ColumnType.NUMERIC)
|
||||
private Integer financialDetailType;
|
||||
|
||||
/**
|
||||
* 收款人ID
|
||||
* 当财务子单类型是师傅转派时 收款人ID是师傅或徒弟的workerId
|
||||
* 当财务子单类型是多级分销时 收款人ID是分销者的customerId
|
||||
* 当财务子单类型是平台抽成 无需填写收款人ID
|
||||
* 当财务子单类型是平台抽成和退款时 无需填写收款人ID
|
||||
*/
|
||||
@Excel(name = "收款人ID", cellType = Excel.ColumnType.NUMERIC)
|
||||
private Long payeeId;
|
||||
|
||||
/**
|
||||
* Adapay撤销支付或退款ID
|
||||
*/
|
||||
@Excel(name = "Adapay撤销支付或退款ID", cellType = Excel.ColumnType.STRING)
|
||||
private String reverseId;
|
||||
|
||||
@Excel(name = "支付方式,微信/支付宝/线下", cellType = Excel.ColumnType.NUMERIC)
|
||||
private Integer payType;
|
||||
|
||||
|
|
@ -74,7 +80,8 @@ public class FinancialDetail extends BaseEntity {
|
|||
this.financialMasterId = financialMasterId;
|
||||
}
|
||||
|
||||
public FinancialDetail(String code, Long deptId, Long financialMasterId, String financialMasterCode, BigDecimal payMoney, Integer financialDetailType, Long payeeId) {
|
||||
public FinancialDetail(Long deptId, String code, Long financialMasterId, String financialMasterCode,
|
||||
BigDecimal payMoney, Integer financialDetailType, Long payeeId) {
|
||||
this.deptId = deptId;
|
||||
this.code = code;
|
||||
this.financialMasterId = financialMasterId;
|
||||
|
|
@ -84,7 +91,9 @@ public class FinancialDetail extends BaseEntity {
|
|||
this.payeeId = payeeId;
|
||||
}
|
||||
|
||||
public FinancialDetail(Long deptId, String code, Long financialMasterId, String financialMasterCode, Long orderDetailId, String orderDetailCode, BigDecimal payMoney, Integer financialDetailType, Long payeeId, Integer payType, Integer payStatus, Date payTime) {
|
||||
public FinancialDetail(Long deptId, String code, Long financialMasterId, String financialMasterCode,
|
||||
Long orderDetailId, String orderDetailCode, BigDecimal payMoney, Integer financialDetailType,
|
||||
Long payeeId, Integer payType, Integer payStatus, Date payTime) {
|
||||
this.deptId = deptId;
|
||||
this.code = code;
|
||||
this.financialMasterId = financialMasterId;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.ghy.payment.mapper;
|
|||
|
||||
import com.ghy.payment.domain.FinancialDetail;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.ghy.payment.response.FinancialCountResponse;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -12,6 +13,11 @@ import java.util.List;
|
|||
*/
|
||||
public interface FinancialDetailMapper {
|
||||
|
||||
/**
|
||||
* @return 月份集合
|
||||
*/
|
||||
List<FinancialCountResponse> count(FinancialCountResponse response);
|
||||
|
||||
/**
|
||||
* @param financialDetail 财务细单属性
|
||||
* @return 成功条数
|
||||
|
|
@ -57,4 +63,11 @@ public interface FinancialDetailMapper {
|
|||
* @return FinancialDetail实体集合信息。
|
||||
*/
|
||||
List<FinancialDetail> getByOrderIdList(@Param("orderIdList") List<Long> orderIdList);
|
||||
|
||||
/**
|
||||
* 撤销支付成功
|
||||
*
|
||||
* @param reverseId 撤销支付ID
|
||||
*/
|
||||
void payReverseSucceeded(String reverseId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,4 +57,11 @@ public interface FinancialMasterMapper {
|
|||
* @param orderMasterId 主订单ID
|
||||
*/
|
||||
FinancialMaster selectByOrderMasterId(Long orderMasterId);
|
||||
|
||||
/**
|
||||
* 用支付ID查询主财务单
|
||||
*
|
||||
* @param paymentId 支付ID
|
||||
*/
|
||||
FinancialMaster selectByPaymentId(String paymentId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
package com.ghy.payment.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class FinancialCountResponse {
|
||||
|
||||
private String createTime;
|
||||
|
||||
private String payCount;
|
||||
|
||||
private String incomeCount;
|
||||
|
||||
private String flag;
|
||||
}
|
||||
|
|
@ -28,10 +28,10 @@ import java.util.List;
|
|||
@Service
|
||||
public class AdapayService {
|
||||
|
||||
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
private static final Logger logger = LoggerFactory.getLogger(AdapayService.class);
|
||||
|
||||
@Resource
|
||||
private PayCallbackService payCallBackService;
|
||||
private PayCallbackService payCallbackService;
|
||||
@Resource
|
||||
private RefundCallbackService refundCallbackService;
|
||||
@Resource
|
||||
|
|
@ -292,7 +292,7 @@ public class AdapayService {
|
|||
paymentParams.put("expend", expend);
|
||||
logger.debug("paymentParams: {}", paymentParams.toJSONString());
|
||||
JSONObject response = (JSONObject) Payment.create(paymentParams, deptId.toString());
|
||||
payCallBackService.onResponse(response);
|
||||
payCallbackService.onResponse(response);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
|
@ -382,7 +382,7 @@ public class AdapayService {
|
|||
reverseParams.put("reverse_amt", reverseAmt);
|
||||
reverseParams.put("notify_url", adapayProperties.getNotifyUrl());
|
||||
reverseParams.put("order_no", "PAYMENT_REVERSE" + System.currentTimeMillis());
|
||||
JSONObject response = (JSONObject) PaymentReverse.create(reverseParams);
|
||||
JSONObject response = (JSONObject) PaymentReverse.create(reverseParams, deptId.toString());
|
||||
payReverseCallbackService.onResponse(response);
|
||||
return response;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.ghy.payment.service;
|
||||
|
||||
import com.ghy.payment.domain.FinancialDetail;
|
||||
import com.ghy.payment.response.FinancialCountResponse;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -12,6 +13,13 @@ import java.util.Map;
|
|||
*/
|
||||
public interface FinancialDetailService {
|
||||
|
||||
/**
|
||||
* @param countTime 是否查询准确时间
|
||||
* @param flag 0收入 1支出
|
||||
* @return 月份集合
|
||||
*/
|
||||
List<FinancialCountResponse> count(String countTime);
|
||||
|
||||
/**
|
||||
* @param financialDetail 财务细单属性
|
||||
* @return 成功条数
|
||||
|
|
@ -64,4 +72,10 @@ public interface FinancialDetailService {
|
|||
*/
|
||||
Map<Long, FinancialDetail> byOrderIdInMap(List<Long> orderIdList);
|
||||
|
||||
/**
|
||||
* 撤销支付成功
|
||||
*
|
||||
* @param reverseId 撤销支付ID
|
||||
*/
|
||||
void payReverseSucceeded(String reverseId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,4 +83,11 @@ public interface FinancialMasterService {
|
|||
* @param id 交易ID
|
||||
*/
|
||||
PaymentDTO selectPaymentById(String id);
|
||||
|
||||
/**
|
||||
* 用支付ID查询主财务单
|
||||
*
|
||||
* @param paymentId 支付ID
|
||||
*/
|
||||
FinancialMaster selectByPaymentId(String paymentId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.ghy.common.constant.UserConstants;
|
|||
import com.ghy.common.core.text.Convert;
|
||||
import com.ghy.payment.domain.FinancialDetail;
|
||||
import com.ghy.payment.mapper.FinancialDetailMapper;
|
||||
import com.ghy.payment.response.FinancialCountResponse;
|
||||
import com.ghy.payment.service.FinancialDetailService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
@ -33,6 +34,29 @@ public class FinancialDetailServiceImpl implements FinancialDetailService {
|
|||
@Resource
|
||||
private FinancialDetailMapper financialDetailMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public List<FinancialCountResponse> count(String countTime) {
|
||||
FinancialCountResponse request = new FinancialCountResponse();
|
||||
request.setCreateTime(countTime);
|
||||
request.setFlag("true");
|
||||
// 查询各月含有收入的费用
|
||||
List<FinancialCountResponse> list = financialDetailMapper.count(request);
|
||||
list.forEach(financialCountResponse->{
|
||||
// 查询指定月支出的
|
||||
request.setFlag("false");
|
||||
request.setCreateTime(financialCountResponse.getCreateTime());
|
||||
List<FinancialCountResponse> payCountList = financialDetailMapper.count(request);
|
||||
if( payCountList != null && payCountList.size() != 0){
|
||||
financialCountResponse.setPayCount(payCountList.get(0).getIncomeCount());
|
||||
}else {
|
||||
financialCountResponse.setPayCount("0");
|
||||
}
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int insertFinancialDetail(FinancialDetail financialDetail) {
|
||||
return financialDetailMapper.insertFinancialDetail(financialDetail);
|
||||
|
|
@ -76,6 +100,11 @@ public class FinancialDetailServiceImpl implements FinancialDetailService {
|
|||
return "fd" + now.format(MINI_FORMATTER) + INDEX.getAndIncrement();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void payReverseSucceeded(String reverseId) {
|
||||
financialDetailMapper.payReverseSucceeded(reverseId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, FinancialDetail> byOrderIdInMap(List<Long> orderIdList) {
|
||||
Map<Long, FinancialDetail> longFinancialDetailHashMap = new HashMap<>();
|
||||
|
|
|
|||
|
|
@ -108,4 +108,9 @@ public class FinancialMasterServiceImpl implements FinancialMasterService {
|
|||
return paymentMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FinancialMaster selectByPaymentId(String paymentId) {
|
||||
return financialMasterMapper.selectByPaymentId(paymentId);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ package com.ghy.payment.service.impl;
|
|||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ghy.common.adapay.model.Event;
|
||||
import com.ghy.common.adapay.model.AdapayStatusEnum;
|
||||
import com.ghy.common.adapay.model.PayReply;
|
||||
import com.ghy.common.adapay.model.Event;
|
||||
import com.ghy.common.adapay.model.PayCallback;
|
||||
import com.ghy.common.adapay.model.PaymentDTO;
|
||||
import com.ghy.payment.domain.FinancialMaster;
|
||||
import com.ghy.payment.service.CallBackService;
|
||||
|
|
@ -37,7 +37,7 @@ public class PayCallbackService implements CallBackService {
|
|||
public void onCallback(Event event) {
|
||||
logger.debug("pay callback is {}", event);
|
||||
String data = event.getData();
|
||||
PayReply payment = JSON.parseObject(data, PayReply.class);
|
||||
PayCallback payment = JSON.parseObject(data, PayCallback.class);
|
||||
Assert.hasText(payment.getOrderNo(), "orderNo is blank !!!");
|
||||
// 校验是否是本系统发出去的回调请求
|
||||
boolean ours = orderNoSet.remove(payment.getOrderNo());
|
||||
|
|
|
|||
|
|
@ -1,12 +1,22 @@
|
|||
package com.ghy.payment.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ghy.common.adapay.model.AdapayStatusEnum;
|
||||
import com.ghy.common.adapay.model.Event;
|
||||
import com.ghy.common.adapay.model.PayReverseCallback;
|
||||
import com.ghy.payment.domain.FinancialDetail;
|
||||
import com.ghy.payment.domain.FinancialMaster;
|
||||
import com.ghy.payment.service.CallBackService;
|
||||
import com.ghy.payment.service.FinancialDetailService;
|
||||
import com.ghy.payment.service.FinancialMasterService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 撤销支付回调
|
||||
*
|
||||
|
|
@ -17,13 +27,37 @@ public class PayReverseCallbackService implements CallBackService {
|
|||
|
||||
private static final Logger logger = LoggerFactory.getLogger(PayReverseCallbackService.class);
|
||||
|
||||
@Resource
|
||||
private FinancialMasterService financialMasterService;
|
||||
@Resource
|
||||
private FinancialDetailService financialDetailService;
|
||||
|
||||
@Override
|
||||
public void onCallback(Event event) {
|
||||
logger.debug("撤销支付 callback: {}", event.toString());
|
||||
logger.debug("撤销支付 callback: {}", event);
|
||||
PayReverseCallback callback = JSON.parseObject(event.getData(), PayReverseCallback.class);
|
||||
if (AdapayStatusEnum.succeeded.code.equals(callback.getStatus())) {
|
||||
// 将子财务单支付状态设置为1 表示退款成功
|
||||
financialDetailService.payReverseSucceeded(callback.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
logger.debug("撤销支付 Response: {}", response.toString());
|
||||
if (AdapayStatusEnum.succeeded.code.equals(response.getString("status"))) {
|
||||
String reverseId = response.getString("id");
|
||||
String paymentId = response.getString("payment_id");
|
||||
String reverseAmt = response.getString("reverse_amt");
|
||||
FinancialMaster fm = financialMasterService.selectByPaymentId(paymentId);
|
||||
// 创建并保存一条子财务单(type=撤销支付)
|
||||
FinancialDetail fd = new FinancialDetail(fm.getDeptId(), financialDetailService.createCode(), fm.getId(),
|
||||
fm.getCode(), new BigDecimal(reverseAmt), 4, null);
|
||||
// 子财务单关联撤销支付ID
|
||||
fd.setReverseId(reverseId);
|
||||
financialDetailService.insertFinancialDetail(fd);
|
||||
} else {
|
||||
logger.warn("撤销失败: {}", response.toJSONString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
<result property="payMoney" column="pay_money"/>
|
||||
<result property="financialDetailType" column="financial_detail_type"/>
|
||||
<result property="payeeId" column="payee_id"/>
|
||||
<result property="reverseId" column="reverse_id"/>
|
||||
<result property="payType" column="pay_type"/>
|
||||
<result property="payStatus" column="pay_status"/>
|
||||
<result property="payTime" column="pay_time"/>
|
||||
|
|
@ -27,10 +28,16 @@
|
|||
<result property="remark" column="remark"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="countResult" type="com.ghy.payment.response.FinancialCountResponse">
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="payCount" column="pay_count"/>
|
||||
<result property="incomeCount" column="income_count"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectFinancialDetail">
|
||||
SELECT id, dept_id, code, financial_master_id, financial_master_code, order_detail_id,
|
||||
order_detail_code, total_money, discount_money, pay_money, financial_detail_type,
|
||||
payee_id, pay_type, pay_status, pay_time, create_by, create_time, update_by, update_time, remark
|
||||
SELECT id, dept_id, code, financial_master_id, financial_master_code, order_detail_id, order_detail_code,
|
||||
total_money, discount_money, pay_money, financial_detail_type,payee_id, reverse_id, pay_type,
|
||||
pay_status, pay_time, create_by, create_time, update_by, update_time, remark
|
||||
FROM financial_detail
|
||||
</sql>
|
||||
|
||||
|
|
@ -89,6 +96,29 @@
|
|||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="payReverseSucceeded">
|
||||
UPDATE financial_detail SET
|
||||
pay_status = 1
|
||||
WHERE reverse_id = #{reverseId}
|
||||
</update>
|
||||
|
||||
<select id="count" resultMap="countResult">
|
||||
select DATE_FORMAT(create_time,'%Y-%m') as create_time,
|
||||
sum(pay_money) as income_count from financial_detail
|
||||
<where>
|
||||
<if test="createTime != null">
|
||||
and DATE_FORMAT(create_time,'%Y-%m') = #{createTime}
|
||||
</if>
|
||||
<if test="flag == 'true'">
|
||||
and pay_money >= 0
|
||||
</if>
|
||||
<if test="flag == 'false'">
|
||||
and pay_money <= 0
|
||||
</if>
|
||||
</where>
|
||||
group by DATE_FORMAT(create_time,'%Y-%m');
|
||||
</select>
|
||||
|
||||
<insert id="insertFinancialDetail" parameterType="com.ghy.payment.domain.FinancialDetail" useGeneratedKeys="true"
|
||||
keyProperty="id">
|
||||
INSERT INTO financial_detail(
|
||||
|
|
@ -103,6 +133,7 @@
|
|||
<if test="payMoney != null">pay_money,</if>
|
||||
<if test="financialDetailType != null">financial_detail_type,</if>
|
||||
<if test="payeeId != null and payeeId != 0">payee_id,</if>
|
||||
<if test="reverseId != null and reverseId != 0">reverse_id,</if>
|
||||
<if test="payType != null">pay_type,</if>
|
||||
<if test="payStatus != null">pay_status,</if>
|
||||
<if test="payTime != null">pay_time,</if>
|
||||
|
|
@ -120,6 +151,7 @@
|
|||
<if test="payMoney != null">#{payMoney},</if>
|
||||
<if test="financialDetailType != null">#{financialDetailType},</if>
|
||||
<if test="payeeId != null and payeeId != 0">#{payeeId},</if>
|
||||
<if test="reverseId != null and reverseId != 0">#{reverseId},</if>
|
||||
<if test="payType != null">#{payType},</if>
|
||||
<if test="payStatus != null">#{payStatus},</if>
|
||||
<if test="payTime != null">#{payTime},</if>
|
||||
|
|
|
|||
|
|
@ -56,6 +56,10 @@
|
|||
<include refid="selectFinancialMaster"/> WHERE order_master_id = #{orderMasterId}
|
||||
</select>
|
||||
|
||||
<select id="selectByPaymentId" parameterType="String" resultMap="FinancialMasterResult">
|
||||
<include refid="selectFinancialMaster"/> WHERE payment_id = #{paymentId}
|
||||
</select>
|
||||
|
||||
<delete id="deleteFinancialMasterByIds" parameterType="Long">
|
||||
DELETE FROM financial_master WHERE id IN
|
||||
<foreach collection="array" item="financialMasterId" open="(" separator="," close=")">
|
||||
|
|
|
|||
|
|
@ -25,6 +25,10 @@ public class WorkerTeam extends BaseEntity {
|
|||
@Excel(name = "成员师傅备注", cellType = Excel.ColumnType.STRING)
|
||||
private String workerName;
|
||||
|
||||
private String name;
|
||||
|
||||
private String phone;
|
||||
|
||||
private String workerLogoUrl;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,4 +23,10 @@ public interface WorkerTeamMapper {
|
|||
* @return 更新成功条数
|
||||
*/
|
||||
int deleteWorkerTeamByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* @param workerTeam 师傅团队信息
|
||||
* @return 修改成功条数
|
||||
* */
|
||||
int updateWorkerTeam(WorkerTeam workerTeam);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
package com.ghy.worker.service;
|
||||
|
||||
import com.ghy.worker.domain.WorkerTeam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* 师傅团队
|
||||
* @author clunt
|
||||
*/
|
||||
public interface WorkerTeamService {
|
||||
|
||||
public List<WorkerTeam> getWorkerTeam(WorkerTeam workerTeam);
|
||||
|
||||
public int insertWorkerTeam(WorkerTeam workerTeam);
|
||||
|
||||
int updateWorkerTeam(WorkerTeam workerTeam);
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
package com.ghy.worker.service.impl;
|
||||
|
||||
import com.ghy.worker.domain.WorkerTeam;
|
||||
import com.ghy.worker.mapper.WorkerTeamMapper;
|
||||
import com.ghy.worker.service.WorkerTeamService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class WorkerTeamServiceImpl implements WorkerTeamService {
|
||||
|
||||
@Resource
|
||||
private WorkerTeamMapper workerTeamMapper;
|
||||
|
||||
@Override
|
||||
public List<WorkerTeam> getWorkerTeam(WorkerTeam workerTeam) {
|
||||
return workerTeamMapper.getWorkerTeamList(workerTeam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int insertWorkerTeam(WorkerTeam workerTeam) {
|
||||
return workerTeamMapper.insertWorkerTeam(workerTeam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateWorkerTeam(WorkerTeam workerTeam) {
|
||||
return workerTeamMapper.updateWorkerTeam(workerTeam);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -76,6 +76,8 @@
|
|||
<set>
|
||||
<if test="account != null and account != ''"> account = #{account},</if>
|
||||
<if test="phone != null and phone != ''"> phone = #{phone},</if>
|
||||
<if test="leaderTeamRate != null and leaderTeamRate != ''"> leader_team_rate = #{leaderTeamRate},</if>
|
||||
<if test="leaderTeamMoney != null and leaderTeamMoney != ''"> leader_team_money = #{leaderTeamMoney},</if>
|
||||
</set>
|
||||
where worker_id = #{workerId}
|
||||
</update>
|
||||
|
|
|
|||
|
|
@ -7,6 +7,9 @@
|
|||
<result property="leaderId" column="leader_id"/>
|
||||
<result property="workerId" column="worker_id"/>
|
||||
<result property="workerName" column="worker_name"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="workerLogoUrl" column="worker_logo_url"/>
|
||||
<result property="phone" column="phone"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
|
|
@ -34,15 +37,16 @@
|
|||
</insert>
|
||||
|
||||
<sql id="selectWorkerTeam">
|
||||
SELECT *
|
||||
FROM worker_team
|
||||
SELECT wt.worker_team_id, wt.leader_id, wt.worker_name, wt.worker_id, w.phone, w.name, w.worker_logo_url
|
||||
FROM worker_team wt
|
||||
left join worker w on wt.worker_id = w.worker_id
|
||||
</sql>
|
||||
|
||||
<select id="getWorkerTeamList" resultMap="WorkerTeamResult">
|
||||
<include refid="selectWorkerTeam"/>
|
||||
<where>
|
||||
<if test="leaderId != null and leaderId != ''">
|
||||
AND leader_id = #{leaderId}
|
||||
AND wt.leader_id = #{leaderId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
|
@ -54,4 +58,11 @@
|
|||
</foreach>
|
||||
</delete>
|
||||
|
||||
<update id="updateWorkerTeam" parameterType="com.ghy.worker.domain.WorkerTeam">
|
||||
update worker_team
|
||||
<set>
|
||||
<if test="workerName != null and workerName != ''">worker_name = #{workerName}</if>
|
||||
</set>
|
||||
where worker_team_id = #{workerTeamId}
|
||||
</update>
|
||||
</mapper>
|
||||
|
|
|
|||
Loading…
Reference in New Issue