This commit is contained in:
牛叉闪闪 2024-08-29 14:45:45 +08:00
parent 3a185c4d59
commit 445551f0d5
2 changed files with 27 additions and 21 deletions

View File

@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.chaozhanggui.system.cashierservice.bean.TableStateEnum;
import com.chaozhanggui.system.cashierservice.dao.*;
import com.chaozhanggui.system.cashierservice.entity.*;
import com.chaozhanggui.system.cashierservice.exception.MsgException;
import com.chaozhanggui.system.cashierservice.model.ScanPayReq;
import com.chaozhanggui.system.cashierservice.model.TradeQueryReq;
import com.chaozhanggui.system.cashierservice.mybatis.MpShopTableMapper;
@ -14,6 +15,7 @@ import com.chaozhanggui.system.cashierservice.rabbit.RabbitProducer;
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
import com.chaozhanggui.system.cashierservice.sign.Result;
import com.chaozhanggui.system.cashierservice.thirdpay.resp.MainScanResp;
import com.chaozhanggui.system.cashierservice.thirdpay.resp.OrderReturnResp;
import com.chaozhanggui.system.cashierservice.thirdpay.resp.OrderStatusQueryResp;
import com.chaozhanggui.system.cashierservice.thirdpay.resp.PublicResp;
import com.chaozhanggui.system.cashierservice.thirdpay.service.ThirdPayService;
@ -331,7 +333,7 @@ public class MemberService {
String orderNo = DateUtils.getSsdfTimes();
PublicResp<MainScanResp> publicResp = thirdPayService.mainScan(url, thirdApply.getAppId(), "会员充值", "会员充值", amount.setScale(2, RoundingMode.DOWN).multiply(new BigDecimal(100)).longValue(), wechatpay.equals("wxpay") ? thirdApply.getSmallAppid() : null, authCode, DateUtils.getSsdfTimes(), thirdApply.getStoreId(), callBack, thirdApply.getAppToken());
PublicResp<MainScanResp> publicResp = thirdPayService.mainScan(url, thirdApply.getAppId(), "会员充值", "会员充值", amount.setScale(2, RoundingMode.DOWN).multiply(new BigDecimal(100)).longValue(), wechatpay.equals("wxpay") ? thirdApply.getSmallAppid() : null, authCode, orderNo, thirdApply.getStoreId(), callBack, thirdApply.getAppToken());
if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
if ("000000".equals(publicResp.getCode())) {
MainScanResp mainScanResp = publicResp.getObjData();
@ -355,6 +357,7 @@ public class MemberService {
flow.setAmount(amount);
flow.setBalance(shopUser.getAmount());
flow.setCreateTime(new Date());
flow.setRemark(orderNo);
tbShopUserFlowMapper.insert(flow);
BigDecimal fl=null;
@ -761,24 +764,26 @@ public class MemberService {
}
if("scanMemberIn".equals(flow.getBizCode())){
PublicResp<OrderStatusQueryResp> orderstatus = thirdPayService.queryOrder(url, thirdApply.getAppId(),flow.getAmount().toPlainString(), null, thirdApply.getAppToken());
if (ObjectUtil.isNotNull(orderstatus) && ObjectUtil.isNotEmpty(orderstatus)) {
if ("000000".equals(orderstatus.getCode())) {
if ("TRADE_SUCCESS".equals(orderstatus.getObjData().getState())) {
user.setAmount(user.getAmount().subtract(flow.getAmount()));
user.setUpdatedAt(System.currentTimeMillis());
tbShopUserMapper.updateByPrimaryKey(user);
if("scanMemberIn".equals(flow.getBizCode())) {
flow.setIsReturn("1");
flow.setRemark(remark);
tbShopUserFlowMapper.updateByPrimaryKey(flow);
return Result.success(CodeEnum.SUCCESS);
String no=DateUtils.getSsdfTimes();
PublicResp<OrderReturnResp> publicResp = thirdPayService.returnOrder(url, thirdApply.getAppId(),no , flow.getRemark(), null, "充值退款", flow.getAmount().setScale(2, RoundingMode.DOWN).multiply(new BigDecimal(100)).longValue(), callBack, null, thirdApply.getAppToken());
if (ObjectUtil.isNotNull(publicResp) && ObjectUtil.isNotEmpty(publicResp)) {
if ("000000".equals(publicResp.getCode())) {
if (!"SUCCESS".equals(publicResp.getObjData().getState()) && !publicResp.getObjData().getState().equals("ING")) {
MsgException.check(true, "退款渠道调用失败");
}
} else {
MsgException.check(true, "退款渠道调用失败");
}
}
}else if("cashMemberIn".equals(flow.getBizCode())){
} else if ("cashMemberIn".equals(flow.getBizCode())) {
} else {
return Result.fail(CodeEnum.OPARETIONERROR);
}
user.setAmount(user.getAmount().subtract(flow.getAmount()));
user.setUpdatedAt(System.currentTimeMillis());
tbShopUserMapper.updateByPrimaryKey(user);
@ -786,14 +791,12 @@ public class MemberService {
flow.setIsReturn("1");
flow.setRemark(remark);
tbShopUserFlowMapper.updateByPrimaryKey(flow);
return Result.success(CodeEnum.SUCCESS);
}else {
return Result.fail(CodeEnum.OPARETIONERROR);
}
return Result.fail(CodeEnum.FAIL);
}

View File

@ -10,9 +10,12 @@
<result column="biz_name" jdbcType="VARCHAR" property="bizName" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="type" jdbcType="VARCHAR" property="type" />
<result column="is_return" jdbcType="VARCHAR" property="isReturn" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
</resultMap>
<sql id="Base_Column_List">
id, shop_user_id, amount, balance, biz_code, biz_name, create_time, type
id, shop_user_id, amount, balance, biz_code, biz_name, create_time, type,is_return,remark
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
@ -27,10 +30,10 @@
<insert id="insert" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopUserFlow">
insert into tb_shop_user_flow (id, shop_user_id, amount,
balance, biz_code, biz_name,
create_time, type)
create_time, type,is_return,remark)
values (#{id,jdbcType=INTEGER}, #{shopUserId,jdbcType=INTEGER}, #{amount,jdbcType=DECIMAL},
#{balance,jdbcType=DECIMAL}, #{bizCode,jdbcType=VARCHAR}, #{bizName,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP}, #{type,jdbcType=VARCHAR})
#{createTime,jdbcType=TIMESTAMP}, #{type,jdbcType=VARCHAR},#{isReturn,jdbcType=VARCHAR},#{remark,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.chaozhanggui.system.cashierservice.entity.TbShopUserFlow">
insert into tb_shop_user_flow