修改支付

This commit is contained in:
韩鹏辉 2024-05-20 17:44:19 +08:00
parent cd913643a5
commit c5e337bef3
4 changed files with 36 additions and 3 deletions

View File

@ -23,4 +23,7 @@ public interface TbShopUserMapper {
int updateByPrimaryKey(TbShopUser record);
List<TbShopUser> selectByShopId(@Param("shopId") String shopId,@Param("phone") String phone);
TbShopUser selectByUserIdAndShopId(@Param("userId") String userId,@Param("shopId") String shopId);
}

View File

@ -33,6 +33,8 @@ import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import static com.chaozhanggui.system.cashierservice.sign.CodeEnum.ACCOUNTEIXST;
@Service
@Slf4j
public class PayService {
@ -118,7 +120,7 @@ public class PayService {
}
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, "create");
List<TbCashierCart> cashierCarts = tbCashierCartMapper.selectByOrderId(orderId, null);
if (ObjectUtil.isEmpty(cashierCarts) || ObjectUtil.isNull(cashierCarts)) {
return Result.fail(CodeEnum.CARTEXIST);
}
@ -505,7 +507,7 @@ public class PayService {
TbUserInfo tbUserInfo = tbUserInfoMapper.selectByCardNo(memberCode);
if (ObjectUtil.isEmpty(tbUserInfo)) {
return Result.fail(CodeEnum.ACCOUNTEIXST);
return Result.fail(ACCOUNTEIXST);
}
@ -801,6 +803,26 @@ public class PayService {
}
}else if("deposit".equals(payType)){
TbShopUser user= tbShopUserMapper.selectByUserIdAndShopId(orderInfo.getUserId(),orderInfo.getShopId());
if(ObjectUtil.isNull(user)||ObjectUtil.isEmpty(user)){
return Result.fail(ACCOUNTEIXST);
}
user.setAmount(user.getAmount().add( newOrderInfo.getPayAmount().setScale(2, RoundingMode.DOWN)));
user.setConsumeAmount(user.getConsumeAmount().subtract( newOrderInfo.getPayAmount().setScale(2, RoundingMode.DOWN)));
user.setUpdatedAt(System.currentTimeMillis());
tbShopUserMapper.updateByPrimaryKeySelective(user);
TbShopUserFlow flow = new TbShopUserFlow();
flow.setShopUserId(user.getId());
flow.setBizCode("accountReturnPay");
flow.setBizName("会员储值卡退款");
flow.setAmount(orderInfo.getOrderAmount());
flow.setBalance(user.getAmount());
flow.setCreateTime(new Date());
tbShopUserFlowMapper.insert(flow);
}

View File

@ -379,7 +379,11 @@
</update>
<select id="selectByOrderId" resultMap="BaseResultMap">
select * from tb_cashier_cart where order_id=#{orderId} and `status`=#{status}
select * from tb_cashier_cart where order_id=#{orderId}
<if test="status != null">
and `status`=#{status}
</if>
</select>
<select id="selectAllByMarketId" resultType="com.chaozhanggui.system.cashierservice.entity.TbCashierCart">
select * from tb_cashier_cart where master_id = #{masterId} and trade_day = #{day} and shop_id = #{shopId} and status = 'create'

View File

@ -372,5 +372,9 @@
order by id desc
</select>
<select id="selectByUserIdAndShopId" resultMap="BaseResultMap">
select * from tb_shop_user where user_id=#{userId} and shop_id =#{shopId}
</select>
</mapper>