Merge remote-tracking branch 'origin/master'

This commit is contained in:
Tankaikai
2025-03-11 11:27:10 +08:00
120 changed files with 263 additions and 419 deletions

View File

@@ -16,5 +16,6 @@ import java.util.List;
public interface ShopTableMapper extends BaseMapper<ShopTable> {
List<ShopTableVO> pageInfo(@Param("shopId") Long shopId, @Param("areaId") Integer areaId,
@Param("tableCode") String tableCode, @Param("status") String status, @Param("name") String name);
@Param("tableCode") String tableCode, @Param("status") String status, @Param("name") String name,
@Param("isBind") Boolean isBind);
}

View File

@@ -145,14 +145,13 @@ public class ShopActivateServiceImpl extends ServiceImpl<ShopActivateMapper, Sho
}
//赠送金额
if (activate.getGiftAmount() != null && activate.getGiftAmount().compareTo(BigDecimal.ZERO) > 0) {
ShopUserMoneyEditDTO shopUserMoneyEditDTO = ShopUserMoneyEditDTO.builder()
.id(shopUser.getId())
.money(activate.getGiftAmount())
.type(1)
.remark("充值活动赠送")
.relationId(relationId)
.bizEnum(ShopUserFlowBizEnum.AWARD_IN)
.build();
ShopUserMoneyEditDTO shopUserMoneyEditDTO = new ShopUserMoneyEditDTO()
.setId(shopUser.getId())
.setMoney(activate.getGiftAmount())
.setType(1)
.setRemark("充值活动赠送")
.setRelationId(relationId)
.setBizEnum(ShopUserFlowBizEnum.AWARD_IN);
//更新会员余额 并生成流水
shopUserService.updateMoney(shopUser.getShopId(), shopUserMoneyEditDTO);
}
@@ -168,9 +167,7 @@ public class ShopActivateServiceImpl extends ServiceImpl<ShopActivateMapper, Sho
.select(ShopCoupon::getId, ShopCoupon::getTitle, ShopCoupon::getLeftNumber)
.in(ShopCoupon::getId, couponMap.keySet())
.list();
list.forEach(coupon -> {
coupon.setNumber(couponMap.get(coupon.getId().toString()));
});
list.forEach(coupon -> coupon.setNumber(couponMap.get(coupon.getId().toString())));
return list;
}

View File

@@ -270,8 +270,8 @@ public class ShopTableServiceImpl extends ServiceImpl<ShopTableMapper, ShopTable
}
@Override
public Page<ShopTableVO> pageInfo(Long shopId, Integer areaId, String tableCode, String status, String name) {
public Page<ShopTableVO> pageInfo(Long shopId, Integer areaId, String tableCode, String status, String name, Boolean isBind) {
PageHelper.startPage(PageUtil.buildPageHelp());
return PageUtil.convert(new PageInfo<>(mapper.pageInfo(shopId, areaId, tableCode, status, name)));
return PageUtil.convert(new PageInfo<>(mapper.pageInfo(shopId, areaId, tableCode, status, name, isBind)));
}
}

View File

@@ -1,8 +1,10 @@
package com.czg.service.account.service.impl;
//import cn.binarywang.wx.miniapp.util.crypt.WxMaCryptUtils;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.symmetric.AES;
import com.alibaba.fastjson2.JSONObject;
import com.czg.account.dto.auth.GetPhoneDTO;
import com.czg.account.dto.auth.LoginTokenDTO;
@@ -51,37 +53,36 @@ public class UserAuthorizationServiceImpl implements UserAuthorizationService {
@Override
public String getPhone(GetPhoneDTO phoneDTO) {
// String mobile;
// String openId;
// UserInfo userInfo = null;
// if (UserAuthSourceEnum.ALIPAY.getValue().equals(phoneDTO.getSource())) {
// openId = alipayUtil.getOpenId(phoneDTO.getCode(), true);
// mobile = alipayUtil.getMobile(phoneDTO.getEncryptedData());
// if (StrUtil.isNotBlank(openId)) {
// userInfo = userInfoService.queryChain().eq(UserInfo::getWechatOpenId, openId).one();
// }
// } else {
// JSONObject session = wechatAuthUtil.getSession(phoneDTO.getCode());
// String sessionKey = session.getString("session_key");
// openId = session.getString("openid");
// if (StrUtil.isNotBlank(openId)) {
// userInfo = userInfoService.queryChain().eq(UserInfo::getAlipayOpenId, openId).one();
// }
// String data = WxMaCryptUtils.decrypt(sessionKey, phoneDTO.getEncryptedData(), phoneDTO.getIv());
// JSONObject jsonObject = JSONObject.parseObject(data);
// if (jsonObject.containsKey("phoneNumber")) {
// mobile = jsonObject.getString("phoneNumber");
// }else {
// throw new ApiNotPrintException("手机号获取失败");
// }
// }
//
// if (userInfo != null) {
// userInfo.setPhone(mobile);
// userInfoService.updateById(userInfo);
// }
// return mobile;
return "123";
String mobile;
String openId;
UserInfo userInfo = null;
if (UserAuthSourceEnum.ALIPAY.getValue().equals(phoneDTO.getSource())) {
openId = alipayUtil.getOpenId(phoneDTO.getCode(), true);
mobile = alipayUtil.getMobile(phoneDTO.getEncryptedData());
if (StrUtil.isNotBlank(openId)) {
userInfo = userInfoService.queryChain().eq(UserInfo::getWechatOpenId, openId).one();
}
} else {
JSONObject session = wechatAuthUtil.getSession(phoneDTO.getCode());
String sessionKey = session.getString("session_key");
openId = session.getString("openid");
if (StrUtil.isNotBlank(openId)) {
userInfo = userInfoService.queryChain().eq(UserInfo::getAlipayOpenId, openId).one();
}
String data = WechatAuthUtil.decrypt(sessionKey, phoneDTO.getEncryptedData(), phoneDTO.getIv());
JSONObject jsonObject = JSONObject.parseObject(data);
if (jsonObject.containsKey("phoneNumber")) {
mobile = jsonObject.getString("phoneNumber");
}else {
throw new ApiNotPrintException("手机号获取失败");
}
}
if (userInfo != null) {
userInfo.setPhone(mobile);
userInfoService.updateById(userInfo);
}
return mobile;
}
@Override

View File

@@ -1,6 +1,8 @@
package com.czg.service.account.util;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.symmetric.AES;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
@@ -8,6 +10,7 @@ import com.czg.resp.CzgResult;
import com.czg.system.dto.SysParamsDTO;
import com.czg.system.service.SysParamsService;
import jakarta.annotation.PostConstruct;
import jakarta.validation.constraints.NotBlank;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;
@@ -25,31 +28,30 @@ public class WechatAuthUtil {
@DubboReference(check = false)
private SysParamsService sysParamsService;
// @Value("${wx.appId}")
// @Value("${wx.appId}")
private String appId;
// @Value("${wx.secrete}")
// @Value("${wx.secrete}")
private String secrete;
// @Value("${wx.account.appId}")
// @Value("${wx.account.appId}")
private String accountAppId;
// @Value("${wx.account.secrete}")
// @Value("${wx.account.secrete}")
private String accountSecrete;
static LinkedHashMap<String,String> linkedHashMap=new LinkedHashMap<>();
static LinkedHashMap<String, String> linkedHashMap = new LinkedHashMap<>();
static {
linkedHashMap.put("40001","获取 access_token 时 AppSecret 错误,或者 access_token 无效。请开发者认真比对 AppSecret 的正确性,或查看是否正在为恰当的公众号调用接口");
linkedHashMap.put("40003","不合法的 OpenID ,请开发者确认 OpenID (该用户)是否已关注公众号,或是否是其他公众号的 OpenID");
linkedHashMap.put("40014","不合法的 access_token ,请开发者认真比对 access_token 的有效性(如是否过期),或查看是否正在为恰当的公众号调用接口");
linkedHashMap.put("40037","不合法的 template_id");
linkedHashMap.put("43101","用户未订阅消息");
linkedHashMap.put("43107","订阅消息能力封禁");
linkedHashMap.put("43108","并发下发消息给同一个粉丝");
linkedHashMap.put("45168","命中敏感词");
linkedHashMap.put("47003","参数错误");
linkedHashMap.put("40001", "获取 access_token 时 AppSecret 错误,或者 access_token 无效。请开发者认真比对 AppSecret 的正确性,或查看是否正在为恰当的公众号调用接口");
linkedHashMap.put("40003", "不合法的 OpenID ,请开发者确认 OpenID (该用户)是否已关注公众号,或是否是其他公众号的 OpenID");
linkedHashMap.put("40014", "不合法的 access_token ,请开发者认真比对 access_token 的有效性(如是否过期),或查看是否正在为恰当的公众号调用接口");
linkedHashMap.put("40037", "不合法的 template_id");
linkedHashMap.put("43101", "用户未订阅消息");
linkedHashMap.put("43107", "订阅消息能力封禁");
linkedHashMap.put("43108", "并发下发消息给同一个粉丝");
linkedHashMap.put("45168", "命中敏感词");
linkedHashMap.put("47003", "参数错误");
}
@@ -116,4 +118,17 @@ public class WechatAuthUtil {
public String getSessionKeyOrOpenId(String code, boolean isAccount) {
return getSessionKey(code, "openid");
}
public static String decrypt(String sessionKey, @NotBlank(message = "数据不能为空") String encryptedData, String iv) {
// Base64 解码
byte[] keyBytes = Base64.decode(sessionKey);
byte[] encryptedBytes = Base64.decode(encryptedData);
byte[] ivBytes = Base64.decode(iv);
// 使用 Hutool 进行 AES-CBC 解密
AES aes = new AES("CBC", "PKCS5Padding", keyBytes, ivBytes);
byte[] decryptedBytes = aes.decrypt(encryptedBytes);
return new String(decryptedBytes, java.nio.charset.StandardCharsets.UTF_8);
}
}

View File

@@ -23,6 +23,9 @@
<if test="name != null and name != ''">
and a.name like concat('%', #{name}, '%')
</if>
<if test="isBind != null">
and a.table_code is not null
</if>
group by a.id
ORDER BY a.create_time

View File

@@ -38,7 +38,6 @@ import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
#else
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
#if(entityConfig.getSuperClass(table))
@@ -60,7 +59,6 @@ import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
#else
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
#if(entityConfig.getSuperClass(table))

View File

@@ -34,7 +34,6 @@ import com.czg.service.order.mapper.OrderInfoMapper;
import com.czg.utils.AssertUtil;
import com.czg.utils.CzgStrUtils;
import com.czg.utils.PageUtil;
import com.mybatisflex.core.BaseMapper;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.update.UpdateChain;
@@ -518,12 +517,11 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
shopUser1.setIsVip(1);
shopUserService.updateById(shopUser1);
}
ShopUserMoneyEditDTO shopUserMoneyEditDTO = ShopUserMoneyEditDTO.builder()
.id(payment.getSourceId())
.money(new BigDecimal(czgCallBackDto.getAmount()).divide(new BigDecimal(100), 2, RoundingMode.DOWN))
.type(1)
.relationId(payment.getId())
.build();
ShopUserMoneyEditDTO shopUserMoneyEditDTO = new ShopUserMoneyEditDTO()
.setId(payment.getSourceId())
.setMoney(new BigDecimal(czgCallBackDto.getAmount()).divide(new BigDecimal(100), 2, RoundingMode.DOWN))
.setType(1)
.setRelationId(payment.getId());
if ("WECHAT".equals(czgCallBackDto.getPayType())) {
shopUserMoneyEditDTO.setBizEnum(ShopUserFlowBizEnum.WECHAT_IN);
} else if ("ALIPAY".equals(czgCallBackDto.getPayType())) {

View File

@@ -202,13 +202,12 @@ public class PayServiceImpl implements PayService {
if (shopUser.getAmount().compareTo(orderInfo.getOrderAmount()) < 0) {
return CzgResult.failure("会员余额不足");
}
ShopUserMoneyEditDTO shopUserMoneyEditDTO = ShopUserMoneyEditDTO.builder()
.id(shopUser.getId())
.money(orderInfo.getOrderAmount())
.type(0)
.bizEnum(ShopUserFlowBizEnum.ORDER_PAY)
.relationId(orderInfo.getId())
.build();
ShopUserMoneyEditDTO shopUserMoneyEditDTO = new ShopUserMoneyEditDTO()
.setId(shopUser.getId())
.setMoney(orderInfo.getOrderAmount())
.setType(0)
.setBizEnum(ShopUserFlowBizEnum.ORDER_PAY)
.setRelationId(orderInfo.getId());
//更新会员余额 并生成流水
Long flowId = shopUserService.updateMoney(shopUser.getShopId(), shopUserMoneyEditDTO);
orderInfoService.upOrderInfo(orderInfo, orderInfo.getOrderAmount(),
@@ -321,13 +320,12 @@ public class PayServiceImpl implements PayService {
if (shopUser.getIsVip().equals(0)) {
UpdateChain.of(ShopUser.class).set(ShopUser::getIsVip, 1).eq(ShopUser::getId, payParam.getShopUserId()).update();
}
ShopUserMoneyEditDTO shopUserMoneyEditDTO = ShopUserMoneyEditDTO.builder()
.id(shopUser.getId())
.money(payParam.getAmount())
.type(1)
.remark("现金充值")
.bizEnum(ShopUserFlowBizEnum.CASH_IN)
.build();
ShopUserMoneyEditDTO shopUserMoneyEditDTO = new ShopUserMoneyEditDTO()
.setId(shopUser.getId())
.setMoney(payParam.getAmount())
.setType(1)
.setRemark("现金充值")
.setBizEnum(ShopUserFlowBizEnum.CASH_IN);
if (isFree) {
shopUserMoneyEditDTO.setBizEnum(ShopUserFlowBizEnum.FREE_IN);
UpdateChain.of(OrderInfo.class).eq(OrderInfo::getId, payParam.getOrderId())
@@ -463,15 +461,14 @@ public class PayServiceImpl implements PayService {
return CzgResult.failure(res.getMsg());
}
}
ShopUserMoneyEditDTO shopUserMoneyEditDTO = ShopUserMoneyEditDTO.builder()
.id(shopUser.getId())
.money(refPayParam.getRefAmount())
.type(0)
.remark("退款")
.bizEnum(ShopUserFlowBizEnum.RECHARGE_REFUND)
.relationId(refPaymentId)
.rechargeId(inFlow.getId())
.build();
ShopUserMoneyEditDTO shopUserMoneyEditDTO = new ShopUserMoneyEditDTO()
.setId(shopUser.getId())
.setMoney(refPayParam.getRefAmount())
.setType(0)
.setRemark("退款")
.setBizEnum(ShopUserFlowBizEnum.RECHARGE_REFUND)
.setRelationId(refPaymentId)
.setRechargeId(inFlow.getId());
//更新会员余额 并生成流水
shopUserService.updateMoney(shopUser.getShopId(), shopUserMoneyEditDTO);
userFlowService.updateRefund(inFlow.getId(), refPayParam.getRefAmount());
@@ -568,13 +565,12 @@ public class PayServiceImpl implements PayService {
if (orderInfo.getPayType().equals(PayEnums.VIP_PAY.getValue())) {
ShopUser shopUser = shopUserService.getShopUserInfo(orderInfo.getShopId(), orderInfo.getUserId());
//会员支付 退钱
ShopUserMoneyEditDTO shopUserMoneyEditDTO = ShopUserMoneyEditDTO.builder()
.id(shopUser.getId())
.money(param.getRefundAmount())
.type(1)
.relationId(orderInfo.getId())
.bizEnum(ShopUserFlowBizEnum.ORDER_REFUND)
.build();
ShopUserMoneyEditDTO shopUserMoneyEditDTO = new ShopUserMoneyEditDTO()
.setId(shopUser.getId())
.setMoney(param.getRefundAmount())
.setType(1)
.setRelationId(orderInfo.getId())
.setBizEnum(ShopUserFlowBizEnum.ORDER_REFUND);
shopUserService.updateMoney(orderInfo.getShopId(), shopUserMoneyEditDTO);
} else if (orderInfo.getPayType().equals(PayEnums.CREDIT_PAY.getValue())) {
AssertUtil.isNull(orderInfo.getCreditBuyerId(), "挂账单退款失败,未查询到挂账人");
@@ -753,9 +749,7 @@ public class PayServiceImpl implements PayService {
map = JSONObject.parseObject(JSONObject.toJSONString(h5PayResp.getPayInfo()));
case CzgJsPayResp jsPayResp ->
map = JSONObject.parseObject(JSONObject.toJSONString(jsPayResp.getPayInfo()));
case CzgLtPayResp ltPayResp -> {
map = JSONObject.parseObject(JSONObject.toJSONString(ltPayResp.getPayInfo()));
}
case CzgLtPayResp ltPayResp -> map = JSONObject.parseObject(JSONObject.toJSONString(ltPayResp.getPayInfo()));
case CzgScanPayResp scanPayResp ->
map = JSONObject.parseObject(JSONObject.toJSONString(scanPayResp.getPayInfo()));
default -> throw new IllegalStateException("Unexpected value: " + data);

View File

@@ -171,7 +171,7 @@
from tb_prod_sku as a
left join tb_product c on c.id=a.product_id
left join tb_shop_info as b on a.shop_id=b.id
where c.id is not null and c.group_category_id is not null
where c.id is not null and c.group_category_id is not null and c.group_category_id != '[]'
<if test="address != null and address != ''">
and (b.cities like concat('%', #{address}, '%') or b.districts like concat('%', #{address}, '%'))
</if>
@@ -180,7 +180,7 @@
and c.name like concat('%', #{name}, '%')
</if>
<if test="classify != null">
and c.group_category_id = #{classify}
and c.group_category_id like concat('%', #{classify}, '%')
</if>
<if test="distanceType != null">
and ST_Distance_Sphere(POINT(b.lng, b.lat), POINT(#{lng}, #{lat})) &lt;= #{distanceType}
@@ -213,7 +213,7 @@
from tb_prod_sku as a
left join tb_product c on c.id=a.product_id
left join tb_shop_info as b on a.shop_id=b.id
where c.group_category_id is not null and c.create_time >= date_format(now(), '%Y-%m-%d 00:00:00')
where c.group_category_id is not null and c.group_category_id != '[]' and c.create_time >= date_format(now(), '%Y-%m-%d 00:00:00')
</select>
<update id="updateProductStockNum">
update tb_product