Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
c448ab8a6d
|
|
@ -68,6 +68,7 @@ public class GoodsController extends BaseController {
|
|||
goodsService.addGoods(goods);
|
||||
return AjaxResult.success("新增成功");
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
logger.error(e.getMessage());
|
||||
return AjaxResult.error(ExceptionUtil.getExceptionMessage(e));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package com.ghy.web.controller.order;
|
|||
|
||||
import com.ghy.common.core.controller.BaseController;
|
||||
import com.ghy.common.core.domain.AjaxResult;
|
||||
import com.ghy.common.enums.OrderStatus;
|
||||
import com.ghy.common.enums.PayStatus;
|
||||
import com.ghy.common.utils.StringUtils;
|
||||
import com.ghy.customer.domain.Customer;
|
||||
import com.ghy.customer.service.CustomerService;
|
||||
|
|
@ -108,6 +110,16 @@ public class OrderController extends BaseController {
|
|||
od.setRevTime(new Date());
|
||||
orderDetailService.insertOrderDetail(od);
|
||||
|
||||
// 批量生成订单商品
|
||||
request.getGoodsList().forEach(goods->{
|
||||
OrderGoods orderGoods = new OrderGoods();
|
||||
orderGoods.setGoodsId(goods.getGoodsStandardId());
|
||||
orderGoods.setGoodsNum(goods.getNum());
|
||||
orderGoods.setOrderId(od.getId());
|
||||
orderGoods.setServerGoodsNum(0);
|
||||
orderGoodsService.insertOrderGoods(orderGoods);
|
||||
});
|
||||
|
||||
String leaderTeamMoney = assignWorker.getLeaderTeamMoney();
|
||||
String leaderTeamRate = assignWorker.getLeaderTeamRate();
|
||||
// 派单师傅的钱
|
||||
|
|
@ -170,6 +182,8 @@ public class OrderController extends BaseController {
|
|||
Set<Long> goodsStandardIds = appGoodsList.stream().map(AppGoodsRequest::getGoodsStandardId).collect(Collectors.toSet());
|
||||
// 所有商品
|
||||
List<GoodsStandard> goodsList = goodsStandardService.selectByIds(goodsStandardIds);
|
||||
// 商品所属师傅
|
||||
Goods goods = goodsService.selectById(goodsList.get(0).getGoodsId());
|
||||
// 商户ID
|
||||
Long deptId = appOrderRequest.getDeptId();
|
||||
Assert.notNull(deptId, "deptId is null!");
|
||||
|
|
@ -179,10 +193,12 @@ public class OrderController extends BaseController {
|
|||
orderMaster.setDeptId(deptId);
|
||||
orderMaster.setCode(orderMasterService.createOrderCode());
|
||||
orderMaster.setOrderType(1);
|
||||
orderMaster.setOrderStatus(0);
|
||||
orderMaster.setPayType(appOrderRequest.getPayType());
|
||||
orderMaster.setOrderStatus(OrderStatus.PLAIN.getCode());
|
||||
orderMaster.setCustomerId(appOrderRequest.getCustomerId());
|
||||
orderMaster.setPayStatus(0);
|
||||
orderMaster.setPayStatus(PayStatus.WAIT_PAY.getCode());
|
||||
orderMaster.setCreateTime(new Date());
|
||||
orderMaster.setWorkerId(goods.getWorkerId());
|
||||
orderMasterService.insertOrderMaster(orderMaster);
|
||||
Assert.notNull(orderMaster.getId(), "OrderMaster.id is null!");
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package com.ghy.web.controller.pay;
|
||||
|
||||
import com.ghy.common.adapay.callback.Event;
|
||||
import com.ghy.common.adapay.model.Event;
|
||||
import com.ghy.common.core.controller.BaseController;
|
||||
import com.ghy.common.utils.spring.SpringUtils;
|
||||
import com.ghy.payment.service.CallBackService;
|
||||
|
|
@ -19,8 +19,6 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
@RestController
|
||||
public class AdapayCallbackController extends BaseController {
|
||||
|
||||
private CallBackService callBackService;
|
||||
|
||||
@PostMapping("/adapay/callback")
|
||||
public String callback(Event event) {
|
||||
logger.info(" 收单返回消息event" + event);
|
||||
|
|
@ -45,15 +43,19 @@ public class AdapayCallbackController extends BaseController {
|
|||
switch (type) {
|
||||
case "payment.succeeded":
|
||||
case "payment.failed":
|
||||
beanName = "payCallBackService";
|
||||
beanName = "payCallbackService";
|
||||
break;
|
||||
case "payment_reverse.succeeded":
|
||||
case "payment_reverse.failed":
|
||||
beanName = "payReverseCallbackService";
|
||||
break;
|
||||
case "payment.close.succeeded":
|
||||
case "payment.close.failed":
|
||||
beanName = "refundCallBackService";
|
||||
beanName = "refundCallbackService";
|
||||
break;
|
||||
case "cash.succeeded":
|
||||
case "cash.failed":
|
||||
beanName = "drawCashCallBackService";
|
||||
beanName = "drawCashCallbackService";
|
||||
break;
|
||||
default:
|
||||
logger.warn("UNKNOWN EVENT TYPE [{}]", type);
|
||||
|
|
@ -61,7 +63,7 @@ public class AdapayCallbackController extends BaseController {
|
|||
}
|
||||
logger.info("handler bean is {} ", beanName);
|
||||
|
||||
callBackService = SpringUtils.getBean(beanName);
|
||||
CallBackService callBackService = SpringUtils.getBean(beanName);
|
||||
callBackService.onCallback(event);
|
||||
return "OK";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
package com.ghy.web.core.adapay;
|
||||
|
||||
import com.ghy.common.adapay.callback.IDrawCashCallback;
|
||||
import com.ghy.common.adapay.model.DrawCashReply;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 处理提现结果
|
||||
*
|
||||
* @author HH 2022/5/27
|
||||
*/
|
||||
@Component
|
||||
public class DrawCashCallback implements IDrawCashCallback {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DrawCashCallback.class);
|
||||
|
||||
@Override
|
||||
public void onCallback(DrawCashReply reply) {
|
||||
logger.info("提现结果:{}", reply);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
package com.ghy.web.core.adapay;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ghy.common.adapay.callback.IPayCallback;
|
||||
import com.ghy.common.adapay.model.AdapayStatusEnum;
|
||||
import com.ghy.common.adapay.model.PayReply;
|
||||
import com.ghy.common.adapay.model.PaymentDTO;
|
||||
import com.ghy.payment.domain.FinancialMaster;
|
||||
import com.ghy.payment.service.FinancialMasterService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 处理支付结果
|
||||
*
|
||||
* @author HH 2022/5/27
|
||||
*/
|
||||
@Component
|
||||
public class PayCallback implements IPayCallback {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(PayCallback.class);
|
||||
|
||||
@Resource
|
||||
FinancialMasterService financialMasterService;
|
||||
|
||||
@Override
|
||||
public void onCallback(PayReply reply) {
|
||||
// 更新交易记录
|
||||
PaymentDTO payment = new PaymentDTO();
|
||||
payment.setId(reply.getId());
|
||||
payment.setStatus(reply.getStatus());
|
||||
payment.setPayTime(reply.getPayTime());
|
||||
financialMasterService.updatePayment(payment);
|
||||
|
||||
if (AdapayStatusEnum.succeeded.code.equals(reply.getStatus())) {
|
||||
// 修改主财务单状态
|
||||
financialMasterService.paySucceeded(reply.getOrderNo(), reply.getPayChannel());
|
||||
} else {
|
||||
logger.warn("支付失败 : {}", reply);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
// 保存一条支付记录
|
||||
PaymentDTO payment = response.toJavaObject(PaymentDTO.class);
|
||||
payment.setStatus("pending");
|
||||
financialMasterService.insertPayment(payment);
|
||||
|
||||
if (AdapayStatusEnum.succeeded.code.equals(response.getString("status"))) {
|
||||
FinancialMaster update = new FinancialMaster();
|
||||
update.setOrderMasterCode(response.getString("order_no"));
|
||||
update.setPaymentId(response.getString("id"));
|
||||
financialMasterService.updateFinancialMaster(update);
|
||||
} else {
|
||||
logger.warn("请求支付失败 : {}", response.toJSONString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
package com.ghy.web.core.adapay;
|
||||
|
||||
import com.ghy.common.adapay.callback.IRefundCallback;
|
||||
import com.ghy.common.adapay.model.RefundReply;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 处理退款结果
|
||||
*
|
||||
* @author HH 2022/5/27
|
||||
*/
|
||||
@Component
|
||||
public class RefundCallback implements IRefundCallback {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(RefundCallback.class);
|
||||
|
||||
@Override
|
||||
public void onCallback(RefundReply reply) {
|
||||
logger.info("退款结果:{}", reply);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
package com.ghy.common.adapay.callback;
|
||||
|
||||
import com.ghy.common.adapay.model.DrawCashReply;
|
||||
|
||||
/**
|
||||
* 处理提现结果的接口
|
||||
*
|
||||
* @author HH 2022/4/1
|
||||
*/
|
||||
public interface IDrawCashCallback {
|
||||
|
||||
void onCallback(DrawCashReply reply);
|
||||
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
package com.ghy.common.adapay.callback;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ghy.common.adapay.model.PayReply;
|
||||
|
||||
/**
|
||||
* 处理支付结果的回调接口
|
||||
*
|
||||
* @author HH 2022/3/25
|
||||
*/
|
||||
public interface IPayCallback {
|
||||
|
||||
void onCallback(PayReply reply);
|
||||
|
||||
void onResponse(JSONObject response);
|
||||
}
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
package com.ghy.common.adapay.callback;
|
||||
|
||||
import com.ghy.common.adapay.model.RefundReply;
|
||||
|
||||
/**
|
||||
* 处理退款结果的回调接口
|
||||
*
|
||||
* @author HH 2022/3/29
|
||||
*/
|
||||
public interface IRefundCallback {
|
||||
|
||||
void onCallback(RefundReply reply);
|
||||
}
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
package com.ghy.common.adapay.callback.mapping;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.ghy.common.adapay.callback.IDrawCashCallback;
|
||||
import com.ghy.common.adapay.callback.Event;
|
||||
import com.ghy.common.adapay.model.DrawCashReply;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* 提现结果匹配
|
||||
*
|
||||
* @author HH 2022/4/1
|
||||
*/
|
||||
public class DrawCashReplyMapping {
|
||||
|
||||
/**
|
||||
* 临时保存支付结果
|
||||
* key: orderNo
|
||||
* value: 处理支付结果的回调接口
|
||||
*/
|
||||
private final static ConcurrentHashMap<String, IDrawCashCallback> PAY_RESULT_CALLBACK_MAP = new ConcurrentHashMap<>(1024);
|
||||
|
||||
public static void putReply(Event event, IDrawCashCallback callback) {
|
||||
String data = event.getData();
|
||||
DrawCashReply reply = JSON.parseObject(data, DrawCashReply.class);
|
||||
Assert.hasText(reply.getOrderNo(), "orderNo is blank !!!");
|
||||
PAY_RESULT_CALLBACK_MAP.remove(reply.getOrderNo());
|
||||
if (callback != null) {
|
||||
callback.onCallback(reply);
|
||||
}
|
||||
}
|
||||
|
||||
public static void putCallback(String orderNo, IDrawCashCallback callback) {
|
||||
Assert.hasText(orderNo, "orderNo is blank !!!");
|
||||
Assert.notNull(callback, "PayCallback is null !!!");
|
||||
PAY_RESULT_CALLBACK_MAP.put(orderNo, callback);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
package com.ghy.common.adapay.callback.mapping;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.ghy.common.adapay.callback.Event;
|
||||
import com.ghy.common.adapay.callback.IPayCallback;
|
||||
import com.ghy.common.adapay.model.PayReply;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* 支付结果匹配
|
||||
*
|
||||
* @author HH 2022/3/25
|
||||
*/
|
||||
public class PayReplyMapping {
|
||||
|
||||
protected static final Logger logger = LoggerFactory.getLogger(PayReplyMapping.class);
|
||||
|
||||
/**
|
||||
* 临时保存支付结果
|
||||
* key: orderNo
|
||||
* value: 处理支付结果的回调接口
|
||||
*/
|
||||
private final static ConcurrentHashMap<String, IPayCallback> PAY_RESULT_CALLBACK_MAP = new ConcurrentHashMap<>(1024);
|
||||
|
||||
public static void putReply(Event event, IPayCallback callback) {
|
||||
String data = event.getData();
|
||||
PayReply payment = JSON.parseObject(data, PayReply.class);
|
||||
Assert.hasText(payment.getOrderNo(), "orderNo is blank !!!");
|
||||
payment.setPayTime(event.getCreatedTime());
|
||||
PAY_RESULT_CALLBACK_MAP.remove(payment.getOrderNo());
|
||||
if (callback != null) {
|
||||
callback.onCallback(payment);
|
||||
} else {
|
||||
logger.warn("PayCallback don't exist! {}", payment);
|
||||
}
|
||||
}
|
||||
|
||||
public static void putCallback(String orderNo, IPayCallback callback) {
|
||||
Assert.hasText(orderNo, "orderNo is blank !!!");
|
||||
Assert.notNull(callback, "PayCallback is null !!!");
|
||||
PAY_RESULT_CALLBACK_MAP.put(orderNo, callback);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
package com.ghy.common.adapay.callback.mapping;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.ghy.common.adapay.callback.Event;
|
||||
import com.ghy.common.adapay.callback.IRefundCallback;
|
||||
import com.ghy.common.adapay.model.RefundReply;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* 退款结果匹配
|
||||
*
|
||||
* @author HH 2022/3/29
|
||||
*/
|
||||
public class RefundReplyMapping {
|
||||
|
||||
/**
|
||||
* 临时保存退款结果
|
||||
* key: orderNo
|
||||
* value: 处理支付结果的回调接口
|
||||
*/
|
||||
private final static ConcurrentHashMap<String, IRefundCallback> PAY_RESULT_CALLBACK_MAP = new ConcurrentHashMap<>(1024);
|
||||
|
||||
public static void putReply(Event event, IRefundCallback refundCallback) {
|
||||
String data = event.getData();
|
||||
RefundReply payment = JSON.parseObject(data, RefundReply.class);
|
||||
Assert.hasText(payment.getPaymentId(), "paymentId is blank !!!");
|
||||
IRefundCallback callback = PAY_RESULT_CALLBACK_MAP.remove(payment.getPaymentId());
|
||||
if (callback != null) {
|
||||
callback.onCallback(payment);
|
||||
}
|
||||
}
|
||||
|
||||
public static void putCallback(String paymentId, IRefundCallback callback) {
|
||||
Assert.hasText(paymentId, "paymentId is blank !!!");
|
||||
Assert.notNull(callback, "RefundCallback is null !!!");
|
||||
PAY_RESULT_CALLBACK_MAP.put(paymentId, callback);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.ghy.common.adapay.callback;
|
||||
package com.ghy.common.adapay.model;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import lombok.Data;
|
||||
|
|
@ -33,6 +33,9 @@ public class Goods extends BaseEntity {
|
|||
@Excel(name = "商品排序", cellType = Excel.ColumnType.NUMERIC)
|
||||
private Integer goodsSort;
|
||||
|
||||
@Excel(name = "归属师傅", cellType = Excel.ColumnType.NUMERIC)
|
||||
private Long workerId;
|
||||
|
||||
@Excel(name = "类别id,必须是关联到系统的第三级目录")
|
||||
private Long deptGoodsCategoryId;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.ghy.goods.mapper;
|
||||
|
||||
import com.ghy.goods.domain.GoodsArea;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -16,6 +17,6 @@ public interface GoodsAreaMapper {
|
|||
* @param areas 区域集合id
|
||||
* @return 批量insert成功条数
|
||||
*/
|
||||
int batchInsert(List<GoodsArea> areas);
|
||||
int batchInsert(@Param("areas") List<GoodsArea> areas);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ public interface GoodsImgsMapper {
|
|||
* @param goodsImgs 商品图片信息
|
||||
* @return 成功条数
|
||||
*/
|
||||
int batchInsert(Collection<GoodsImgs> goodsImgs);
|
||||
int batchInsert(@Param("goodsImgs") List<GoodsImgs> goodsImgs);
|
||||
|
||||
/**
|
||||
* 批量修改商品图片
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.ghy.goods.mapper;
|
|||
|
||||
import com.ghy.goods.domain.GoodsStandard;
|
||||
import com.ghy.goods.request.AppGoodsRequest;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
|
@ -34,7 +35,7 @@ public interface GoodsStandardMapper {
|
|||
* @param goodsStandardList 批量添加商品规格
|
||||
* @return 添加成功条数
|
||||
*/
|
||||
int batchInsert(List<GoodsStandard> goodsStandardList);
|
||||
int batchInsert(@Param("goodsStandards") List<GoodsStandard> goodsStandardList);
|
||||
|
||||
/**
|
||||
* @param request 校验的商品数量
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public interface GoodsImgsService {
|
|||
* @param goodsImgs 商品图片信息
|
||||
* @return
|
||||
*/
|
||||
int batchInsert(Collection<GoodsImgs> goodsImgs);
|
||||
int batchInsert(List<GoodsImgs> goodsImgs);
|
||||
|
||||
/**
|
||||
* 批量编辑商品图片信息
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.ghy.goods.domain.GoodsArea;
|
|||
import com.ghy.goods.mapper.GoodsAreaMapper;
|
||||
import com.ghy.goods.service.GoodsAreaService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
|
|
|||
|
|
@ -23,8 +23,7 @@ public class GoodsImgsServiceImpl implements GoodsImgsService {
|
|||
GoodsImgsMapper goodsImgsMapper;
|
||||
|
||||
@Override
|
||||
public int batchInsert(Collection<GoodsImgs> goodsImgs) {
|
||||
if (CollectionUtils.isEmpty(goodsImgs)) return 0;
|
||||
public int batchInsert(List<GoodsImgs> goodsImgs) {
|
||||
return goodsImgsMapper.batchInsert(goodsImgs);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,18 +24,11 @@
|
|||
</where>
|
||||
</select>
|
||||
|
||||
<insert id="batchInsert" parameterType="com.ghy.goods.domain.GoodsArea" useGeneratedKeys="true" keyProperty="goodsAreaId">
|
||||
<foreach collection="array" item="areas">
|
||||
INSERT INTO goods_imgs(
|
||||
<if test="goodsImgsId != null and goodsImgsId != 0">goods_imgs_id,</if>
|
||||
<if test="goodsId != null and goodsId != 0">goods_id,</if>
|
||||
<if test="imgUrl != null and imgUrl != ''">img_url</if>
|
||||
)
|
||||
VALUES(
|
||||
<if test="goodsImgsId != null and goodsImgsId != 0">#{goodsImgsId},</if>
|
||||
<if test="goodsId != null and goodsId != 0">#{goodsId},</if>
|
||||
<if test="imgUrl != null and imgUrl != ''">#{imgUrl}</if>
|
||||
);
|
||||
<insert id="batchInsert" parameterType="list" >
|
||||
INSERT INTO goods_area ( goods_id,country_area_id)
|
||||
VALUES
|
||||
<foreach collection="areas" separator="," item="area">
|
||||
(#{area.goodsId},#{area.countryAreaId})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
<mapper namespace="com.ghy.goods.mapper.GoodsImgsMapper">
|
||||
|
||||
<resultMap id="GoodsImgsResult" type="com.ghy.goods.domain.GoodsImgs">
|
||||
<result property="goodsImgsId" column="goods_imgs_id" />
|
||||
<result property="goodsId" column="goods_id" />
|
||||
<result property="imgUrl" column="img_url" />
|
||||
<result property="imgType" column="img_type" />
|
||||
<result property="goodsImgsId" column="goods_imgs_id"/>
|
||||
<result property="goodsId" column="goods_id"/>
|
||||
<result property="imgUrl" column="img_url"/>
|
||||
<result property="imgType" column="img_type"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectGoodsImgs">
|
||||
|
|
@ -22,7 +22,9 @@
|
|||
</delete>
|
||||
|
||||
<delete id="deleteByGoodsId">
|
||||
DELETE FROM goods_imgs WHERE goods_id = #{goodsId}
|
||||
DELETE
|
||||
FROM goods_imgs
|
||||
WHERE goods_id = #{goodsId}
|
||||
</delete>
|
||||
|
||||
<select id="selectByGoodsId" resultMap="GoodsImgsResult">
|
||||
|
|
@ -34,22 +36,27 @@
|
|||
</where>
|
||||
</select>
|
||||
|
||||
<insert id="batchInsert" parameterType="com.ghy.goods.domain.GoodsImgs" useGeneratedKeys="true" keyProperty="goodsImgsId">
|
||||
<foreach collection="array" item="goodsImgs">
|
||||
INSERT INTO goods_imgs(
|
||||
<if test="goodsImgsId != null and goodsImgsId != 0">goods_imgs_id,</if>
|
||||
<if test="goodsId != null and goodsId != 0">goods_id,</if>
|
||||
<if test="imgUrl != null and imgUrl != ''">img_url,</if>
|
||||
<if test="remark != null and remark != ''">remark,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
create_time)
|
||||
VALUES(
|
||||
<if test="goodsImgsId != null and goodsImgsId != 0">#{goodsImgsId},</if>
|
||||
<if test="goodsId != null and goodsId != 0">#{goodsId},</if>
|
||||
<if test="imgUrl != null and imgUrl != ''">#{imgUrl},</if>
|
||||
<if test="remark != null and remark != ''">#{remark},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
sysdate());
|
||||
<insert id="batchInsert" parameterType="list">
|
||||
INSERT INTO
|
||||
goods_imgs
|
||||
(
|
||||
goods_id,
|
||||
img_url,
|
||||
img_type,
|
||||
remark,
|
||||
create_by,
|
||||
create_time
|
||||
)
|
||||
VALUES
|
||||
<foreach collection="goodsImgs" separator="," item="goodsImg">
|
||||
(
|
||||
#{goodsImg.goodsId},
|
||||
#{goodsImg.imgUrl},
|
||||
#{goodsImg.imgType},
|
||||
#{goodsImg.remark},
|
||||
#{goodsImg.createBy},
|
||||
sysdate()
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
<result property="deptId" column="dept_id" />
|
||||
<result property="goodsName" column="goods_name" />
|
||||
<result property="goodsSort" column="goods_sort"/>
|
||||
<result property="workerId" column="worker_id"/>
|
||||
<result property="deptGoodsCategoryId" column="dept_goods_category_id"/>
|
||||
<result property="goodsImgUrl" column="goods_img_url"/>
|
||||
<result property="goodsVideoUrl" column="goods_video_url"/>
|
||||
|
|
@ -21,7 +22,7 @@
|
|||
</resultMap>
|
||||
|
||||
<sql id="selectGoods">
|
||||
SELECT goods_id, goods_code, dept_id, goods_name, goods_sort,
|
||||
SELECT goods_id, goods_code, dept_id, goods_name, goods_sort, worker_id,
|
||||
dept_goods_category_id, goods_img_url, goods_video_url, status, create_by, create_time, remark
|
||||
FROM goods
|
||||
</sql>
|
||||
|
|
@ -54,6 +55,7 @@
|
|||
<if test="deptId != null and deptId != ''">dept_id,</if>
|
||||
<if test="goodsName != null and goodsName != ''">goods_name,</if>
|
||||
<if test="goodsSort != null and goodsSort != ''">goods_sort,</if>
|
||||
<if test="workerId != null and workerId != ''">worker_id,</if>
|
||||
<if test="deptGoodsCategoryId != null and deptGoodsCategoryId != 0">dept_goods_category_id,</if>
|
||||
<if test="goodsImgUrl != null and goodsImgUrl != ''">goods_img_url,</if>
|
||||
<if test="goodsVideoUrl != null and goodsVideoUrl != ''">goods_video_url,</if>
|
||||
|
|
@ -66,6 +68,7 @@
|
|||
<if test="deptId != null and deptId != ''">#{deptId},</if>
|
||||
<if test="goodsName != null and goodsName != ''">#{goodsName},</if>
|
||||
<if test="goodsSort != null and goodsSort != ''">#{goodsSort},</if>
|
||||
<if test="workerId != null and workerId != ''">#{workerId},</if>
|
||||
<if test="deptGoodsCategoryId != null and deptGoodsCategoryId != 0">#{deptGoodsCategoryId},</if>
|
||||
<if test="goodsImgUrl != null and goodsImgUrl != ''">#{goodsImgUrl},</if>
|
||||
<if test="goodsVideoUrl != null and goodsVideoUrl != ''">#{goodsVideoUrl},</if>
|
||||
|
|
|
|||
|
|
@ -3,31 +3,43 @@
|
|||
<mapper namespace="com.ghy.goods.mapper.GoodsStandardMapper">
|
||||
|
||||
<resultMap id="GoodsStandardResult" type="com.ghy.goods.domain.GoodsStandard">
|
||||
<result property="goodsStandardId" column="goods_standard_id" />
|
||||
<result property="goodsStandardName" column="goods_standard_name"/>
|
||||
<result property="goodsId" column="goods_id" />
|
||||
<result property="deptGoodsCategoryId" column="dept_goods_category_id"/>
|
||||
<result property="goodsPrice" column="goods_price"/>
|
||||
<result property="discountPrice" column="discount_price"/>
|
||||
<result property="groupPrice" column="group_price"/>
|
||||
<result property="goodsNum" column="goods_num"/>
|
||||
<result property="saleNum" column="sale_num"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="remark" column="remark"/>
|
||||
<result property="goodsStandardId" column="goods_standard_id"/>
|
||||
<result property="goodsStandardName" column="goods_standard_name"/>
|
||||
<result property="goodsId" column="goods_id"/>
|
||||
<result property="deptGoodsCategoryId" column="dept_goods_category_id"/>
|
||||
<result property="goodsPrice" column="goods_price"/>
|
||||
<result property="discountPrice" column="discount_price"/>
|
||||
<result property="groupPrice" column="group_price"/>
|
||||
<result property="goodsNum" column="goods_num"/>
|
||||
<result property="saleNum" column="sale_num"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="remark" column="remark"/>
|
||||
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectGoodsStandard">
|
||||
SELECT goods_standard_id, goods_standard_name, goods_id, dept_goods_category_id, goods_price,
|
||||
discount_price, group_price, goods_num, create_by, create_time, sale_num, status, update_by, update_time,
|
||||
SELECT goods_standard_id,
|
||||
goods_standard_name,
|
||||
goods_id,
|
||||
dept_goods_category_id,
|
||||
goods_price,
|
||||
discount_price,
|
||||
group_price,
|
||||
goods_num,
|
||||
create_by,
|
||||
create_time,
|
||||
sale_num,
|
||||
status,
|
||||
update_by,
|
||||
update_time,
|
||||
remark
|
||||
FROM goods_standard
|
||||
</sql>
|
||||
|
||||
|
||||
<select id="selectById" resultMap="GoodsStandardResult">
|
||||
<include refid="selectGoodsStandard"/>
|
||||
<where>
|
||||
|
|
@ -54,39 +66,19 @@
|
|||
</where>
|
||||
</select>
|
||||
|
||||
<insert id="batchInsert" parameterType="com.ghy.goods.domain.GoodsStandard" useGeneratedKeys="true" keyProperty="goodsStandardId">
|
||||
<foreach collection="array" item="goodsStandardList">
|
||||
INSERT INTO goods_standard(
|
||||
<if test="goodsStandardName != null and goodsStandardName != 0">goods_standard_name,</if>
|
||||
<if test="goodsId != null and goodsId != 0">goods_id,</if>
|
||||
<if test="deptGoodsCategoryId != null and deptGoodsCategoryId != ''">dept_goods_category_id</if>
|
||||
<if test="goodsPrice != null and goodsPrice != 0">goods_price,</if>
|
||||
<if test="discountPrice != null and discountPrice != 0">discount_price,</if>
|
||||
<if test="groupPrice != null and groupPrice != 0">group_price,</if>
|
||||
<if test="goodsNum != null and goodsNum != 0">goods_num,</if>
|
||||
<if test="saleNum != null and saleNum != 0">sale_num,</if>
|
||||
<if test="status != null and status != 0">status,</if>
|
||||
<if test="remark != null and remark != ''">remark,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
create_time
|
||||
<insert id="batchInsert" parameterType="list">
|
||||
INSERT INTO goods_standard (
|
||||
goods_standard_name, goods_id, dept_goods_category_id, goods_price, discount_price, group_price, goods_num,
|
||||
sale_num, status, remark, create_by, create_time )
|
||||
VALUES
|
||||
<foreach collection="goodsStandards" separator="," item="goodsStandard">
|
||||
(
|
||||
#{goodsStandard.goodsStandardName}, #{goodsStandard.goodsId}, #{goodsStandard.deptGoodsCategoryId}, #{goodsStandard.goodsPrice}, #{goodsStandard.discountPrice},
|
||||
#{goodsStandard.groupPrice}, #{goodsStandard.goodsNum}, #{goodsStandard.saleNum}, #{goodsStandard.status}, #{goodsStandard.remark}, #{goodsStandard.createBy}, sysdate()
|
||||
)
|
||||
VALUES(
|
||||
<if test="goodsStandardName != null and goodsStandardName != 0">#{goodsStandardName},</if>
|
||||
<if test="goodsId != null and goodsId != 0">#{goodsId},</if>
|
||||
<if test="deptGoodsCategoryId != null and deptGoodsCategoryId != ''">#{deptGoodsCategoryId}</if>
|
||||
<if test="goodsPrice != null and goodsPrice != 0">#{goodsPrice},</if>
|
||||
<if test="discountPrice != null and discountPrice != 0">#{discountPrice},</if>
|
||||
<if test="groupPrice != null and groupPrice != 0">#{groupPrice},</if>
|
||||
<if test="goodsNum != null and goodsNum != 0">#{goodsNum},</if>
|
||||
<if test="saleNum != null and saleNum != 0">#{saleNum},</if>
|
||||
<if test="status != null">#{status},</if>
|
||||
<if test="remark != null and remark != ''">#{remark},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
sysdate()
|
||||
);
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
|
||||
<select id="checkStore" resultMap="GoodsStandardResult">
|
||||
<include refid="selectGoodsStandard"/>
|
||||
where goods_standard_id = #{goodsStandardId}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.ghy.payment.mapper;
|
||||
|
||||
import com.ghy.common.adapay.model.PaymentDTO;
|
||||
import com.huifu.adapay.model.Payment;
|
||||
|
||||
/**
|
||||
|
|
@ -12,4 +13,6 @@ public interface PaymentMapper {
|
|||
int insertPayment(Payment payment);
|
||||
|
||||
int updatePayment(Payment payment);
|
||||
|
||||
PaymentDTO selectById(String id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,13 +3,11 @@ package com.ghy.payment.service;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ghy.common.adapay.AdapayConfig;
|
||||
import com.ghy.common.adapay.AdapayProperties;
|
||||
import com.ghy.common.adapay.callback.IDrawCashCallback;
|
||||
import com.ghy.common.adapay.callback.IPayCallback;
|
||||
import com.ghy.common.adapay.callback.IRefundCallback;
|
||||
import com.ghy.common.adapay.callback.mapping.DrawCashReplyMapping;
|
||||
import com.ghy.common.adapay.callback.mapping.RefundReplyMapping;
|
||||
import com.ghy.common.adapay.model.*;
|
||||
import com.ghy.payment.service.impl.PayCallBackServiceImpl;
|
||||
import com.ghy.payment.service.impl.DrawCashCallbackService;
|
||||
import com.ghy.payment.service.impl.PayCallbackService;
|
||||
import com.ghy.payment.service.impl.PayReverseCallbackService;
|
||||
import com.ghy.payment.service.impl.RefundCallbackService;
|
||||
import com.huifu.adapay.core.exception.BaseAdaPayException;
|
||||
import com.huifu.adapay.model.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
|
@ -33,13 +31,13 @@ public class AdapayService {
|
|||
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
@Resource
|
||||
private IPayCallback payCallback;
|
||||
private PayCallbackService payCallBackService;
|
||||
@Resource
|
||||
private PayCallBackServiceImpl payCallBackService;
|
||||
private RefundCallbackService refundCallbackService;
|
||||
@Resource
|
||||
private IDrawCashCallback drawCashCallback;
|
||||
private DrawCashCallbackService drawCashCallbackService;
|
||||
@Resource
|
||||
private IRefundCallback refundCallback;
|
||||
private PayReverseCallbackService payReverseCallbackService;
|
||||
@Resource
|
||||
private AdapayProperties adapayProperties;
|
||||
|
||||
|
|
@ -237,8 +235,9 @@ public class AdapayService {
|
|||
cashParam.put("notify_url", adapayProperties.getNotifyUrl());
|
||||
cashParam.put("remark", remark);
|
||||
cashParam.put("fee_mode", feeMode);
|
||||
DrawCashReplyMapping.putCallback(orderNo, drawCashCallback);
|
||||
return (JSONObject) Drawcash.create(cashParam, deptId.toString());
|
||||
JSONObject response = (JSONObject) Drawcash.create(cashParam, deptId.toString());
|
||||
drawCashCallbackService.onResponse(response);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -298,7 +297,7 @@ public class AdapayService {
|
|||
}
|
||||
|
||||
/**
|
||||
* 发起退款
|
||||
* 发起退款(用于[延迟分账]或者[延迟分账且确认支付后]的支付单)
|
||||
* 当您的业务需要发起退款时,可通过 Adapay 系统提供的创建 Refund对象 方法创建一个退款对象,资金会原路退回用户的支付宝或微信中。
|
||||
* 支持一次全额或多次部分退款,退款次数最多不超过10次。多次部分退款时,当前退款金额 + 已退款金额不能大于原支付金额。
|
||||
* 对于每次撤销交易,Adapay 都会通过 异步消息通知 告知结果。
|
||||
|
|
@ -319,8 +318,9 @@ public class AdapayService {
|
|||
JSONObject refundParams = new JSONObject();
|
||||
refundParams.put("refund_amt", refundAmt);
|
||||
refundParams.put("refund_order_no", refundOrderNo);
|
||||
RefundReplyMapping.putCallback(paymentId, refundCallback);
|
||||
return (JSONObject) Refund.create(paymentId, refundParams, deptId.toString());
|
||||
JSONObject response = (JSONObject) Refund.create(paymentId, refundParams, deptId.toString());
|
||||
refundCallbackService.onResponse(response);
|
||||
return response;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -362,4 +362,29 @@ public class AdapayService {
|
|||
return (JSONObject) Member.query(memberParams, deptId.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* 支付撤销
|
||||
* 支付撤销对象适用于[延时分账]的场景。只有已支付完成且为延时分账的Payment对象,在没有创建支付确认对象成功之前,可以调用创建支付撤销对象。
|
||||
* 用来撤销支付,资金会原路退回用户的支付宝或微信中。 支持一次全额或多次部分撤销,撤销次数最多不超过10次。
|
||||
* 多次部分撤销时,当前撤销金额 + 已撤销金额 + 已确认金额不能大于原支付金额。
|
||||
* 对于每次撤销交易,Adapay 都会通过 异步消息通知 告知结果。
|
||||
* https://docs.adapay.tech/api/trade.html#payment-reverse-object
|
||||
*
|
||||
* @param deptId [必填]商户ID
|
||||
* @param paymentId [必填]Adapay生成的支付对象id
|
||||
* @param reverseAmt [必填]撤销金额,必须大于0,保留两位小数点,如0.10、100.05等。撤销金额必须小于等于支付金额 - 已确认金额 - 已撤销(撤销成功+撤销中)金额。
|
||||
* @return 创建支付撤销对象同步返回成功,表示 Adapay 受理成功,撤销结果以异步通知为准
|
||||
*/
|
||||
public JSONObject payReverse(@NotNull Long deptId, @NotNull String paymentId, @NotNull String reverseAmt) throws BaseAdaPayException {
|
||||
JSONObject reverseParams = new JSONObject();
|
||||
reverseParams.put("app_id", AdapayConfig.getAppId(deptId));
|
||||
reverseParams.put("payment_id", paymentId);
|
||||
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);
|
||||
payReverseCallbackService.onResponse(response);
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,16 +1,10 @@
|
|||
package com.ghy.payment.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ghy.common.adapay.callback.Event;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import com.ghy.common.adapay.model.Event;
|
||||
|
||||
public interface CallBackService {
|
||||
|
||||
public final static ConcurrentMap<String, List<String>> resultCallBackMap = new ConcurrentHashMap<>(1024);
|
||||
|
||||
/**
|
||||
* @param event 回调
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -76,4 +76,11 @@ public interface FinancialMasterService {
|
|||
* @param payment 支付对象
|
||||
*/
|
||||
int updatePayment(PaymentDTO payment);
|
||||
|
||||
/**
|
||||
* 用交易ID查询交易记录
|
||||
*
|
||||
* @param id 交易ID
|
||||
*/
|
||||
PaymentDTO selectPaymentById(String id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,37 +0,0 @@
|
|||
package com.ghy.payment.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ghy.common.adapay.callback.Event;
|
||||
import com.ghy.payment.service.CallBackService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Service("drawCashCallBackService")
|
||||
public class DrawCashCallBackServiceImpl implements CallBackService {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(DrawCashCallBackServiceImpl.class);
|
||||
|
||||
private final static List<String> drawCashList = new ArrayList<>(1024);
|
||||
|
||||
/**
|
||||
* 临时保存支付结果
|
||||
* key: orderNo
|
||||
* value: 处理支付结果的回调接口
|
||||
*/
|
||||
|
||||
@Override
|
||||
public void onCallback(Event event) {
|
||||
logger.info("draw callback is {}", event.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
logger.info("draw response is {}", response.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
package com.ghy.payment.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ghy.common.adapay.model.Event;
|
||||
import com.ghy.payment.service.CallBackService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 提现回调
|
||||
*
|
||||
* @author HH 2022/5/30
|
||||
*/
|
||||
@Service("drawCashCallbackService")
|
||||
public class DrawCashCallbackService implements CallBackService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(DrawCashCallbackService.class);
|
||||
|
||||
@Override
|
||||
public void onCallback(Event event) {
|
||||
logger.info("提现 callback: {}", event.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
logger.info("提现 response: {}", response.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -76,7 +76,7 @@ public class FinancialMasterServiceImpl implements FinancialMasterService {
|
|||
public void paySucceeded(String orderNo, String payChannel) {
|
||||
try {
|
||||
financialMasterMapper.paySucceeded(orderNo, PayTypeEnum.valueOf(payChannel.toUpperCase()).getCode());
|
||||
}catch (IllegalArgumentException e){
|
||||
} catch (IllegalArgumentException e) {
|
||||
logger.warn("OrderNo[{}] Unknown payChannel [{}]!", orderNo, payChannel);
|
||||
}
|
||||
}
|
||||
|
|
@ -103,4 +103,9 @@ public class FinancialMasterServiceImpl implements FinancialMasterService {
|
|||
return paymentMapper.updatePayment(payment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaymentDTO selectPaymentById(String id) {
|
||||
return paymentMapper.selectById(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package com.ghy.payment.service.impl;
|
|||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ghy.common.adapay.callback.Event;
|
||||
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.PaymentDTO;
|
||||
|
|
@ -15,41 +15,54 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.util.Assert;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
|
||||
@Service("payCallBackService")
|
||||
public class PayCallBackServiceImpl implements CallBackService {
|
||||
/**
|
||||
* 支付回调
|
||||
*
|
||||
* @author HH 2022/5/31
|
||||
*/
|
||||
@Service("payCallbackService")
|
||||
public class PayCallbackService implements CallBackService {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(PayCallBackServiceImpl.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(PayCallbackService.class);
|
||||
|
||||
private final static List<String> payList = new ArrayList<>(1024);
|
||||
// 用HashSet检索效率高
|
||||
private final static HashSet<String> orderNoSet = new HashSet<>(1024);
|
||||
|
||||
@Resource
|
||||
FinancialMasterService financialMasterService;
|
||||
|
||||
@Override
|
||||
public void onCallback(Event event) {
|
||||
logger.debug("pay callback is {}", event);
|
||||
String data = event.getData();
|
||||
PayReply payment = JSON.parseObject(data, PayReply.class);
|
||||
Assert.hasText(payment.getOrderNo(), "orderNo is blank !!!");
|
||||
// 校验是否是本系统发出去的回调请求
|
||||
if(payList.contains(payment.getOrderNo())){
|
||||
boolean ours = orderNoSet.remove(payment.getOrderNo());
|
||||
if (!ours) {
|
||||
//如果内存里没有 就从数据库里找这条记录
|
||||
PaymentDTO dto = financialMasterService.selectPaymentById(payment.getId());
|
||||
ours = dto != null;
|
||||
}
|
||||
if (ours) {
|
||||
// 更新交易记录
|
||||
PaymentDTO param = new PaymentDTO();
|
||||
param.setId(payment.getId());
|
||||
param.setStatus(payment.getStatus());
|
||||
param.setPayTime(payment.getPayTime());
|
||||
financialMasterService.updatePayment(param);
|
||||
|
||||
|
||||
if (AdapayStatusEnum.succeeded.code.equals(payment.getStatus())) {
|
||||
// 修改主财务单状态
|
||||
financialMasterService.paySucceeded(payment.getOrderNo(), payment.getPayChannel());
|
||||
} else {
|
||||
logger.warn("支付失败 : {}", payment);
|
||||
}
|
||||
} else {
|
||||
logger.warn("系统中不存在这条交易记录: {}", event);
|
||||
}
|
||||
logger.info("pay callback is {}", event.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -67,10 +80,8 @@ public class PayCallBackServiceImpl implements CallBackService {
|
|||
} else {
|
||||
logger.warn("请求支付失败 : {}", response.toJSONString());
|
||||
}
|
||||
|
||||
// 将记录保存到临时会话中
|
||||
payList.add(response.getString("order_no"));
|
||||
resultCallBackMap.put("pay", payList);
|
||||
orderNoSet.add(response.getString("order_no"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
package com.ghy.payment.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ghy.common.adapay.model.Event;
|
||||
import com.ghy.payment.service.CallBackService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 撤销支付回调
|
||||
*
|
||||
* @author HH 2022/5/31
|
||||
*/
|
||||
@Service("payReverseCallbackService")
|
||||
public class PayReverseCallbackService implements CallBackService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(PayReverseCallbackService.class);
|
||||
|
||||
@Override
|
||||
public void onCallback(Event event) {
|
||||
logger.debug("撤销支付 callback: {}", event.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
logger.debug("撤销支付 Response: {}", response.toString());
|
||||
}
|
||||
}
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
package com.ghy.payment.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ghy.common.adapay.callback.Event;
|
||||
import com.ghy.payment.service.CallBackService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service("refundCallBackService")
|
||||
public class RefundCallBackServiceImpl implements CallBackService {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(RefundCallBackServiceImpl.class);
|
||||
|
||||
@Override
|
||||
public void onCallback(Event event) {
|
||||
logger.info("refund callback is {}", event.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
logger.info("refund response is {}", response.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
package com.ghy.payment.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ghy.common.adapay.model.Event;
|
||||
import com.ghy.payment.service.CallBackService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 退款回调
|
||||
*
|
||||
* @author HH 2022/5/30
|
||||
*/
|
||||
@Service("refundCallbackService")
|
||||
public class RefundCallbackService implements CallBackService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(RefundCallbackService.class);
|
||||
|
||||
@Override
|
||||
public void onCallback(Event event) {
|
||||
logger.debug("退款 callback: {}", event.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResponse(JSONObject response) {
|
||||
logger.debug("退款 Response: {}", response.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ghy.payment.mapper.PaymentMapper">
|
||||
|
||||
<resultMap id="FinancialMasterResult" type="com.ghy.common.adapay.model.PaymentDTO">
|
||||
<resultMap id="PaymentResult" type="com.ghy.common.adapay.model.PaymentDTO">
|
||||
<result property="id" column="id"/>
|
||||
<result property="orderNo" column="order_no"/>
|
||||
<result property="prodMode" column="prod_mode"/>
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
<result property="payTime" column="pay_time"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectFinancialMaster">
|
||||
<sql id="selectPayment">
|
||||
SELECT id, order_no, prod_mode, app_id, pay_channel, pay_amt, party_order_id, query_url,
|
||||
currency, status, pay_time, created_time, update_time
|
||||
FROM adapay_pay_log
|
||||
|
|
@ -58,4 +58,8 @@
|
|||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<select id="selectById" resultMap="PaymentResult">
|
||||
<include refid="selectPayment"/> WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue