Bobi 1 month ago
parent
commit
9d7ed27d21
15 changed files with 399 additions and 50 deletions
  1. +54
    -23
      jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/common/system/vo/AppletUser.java
  2. +3
    -2
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/controller/AppletApiLoginController.java
  3. +21
    -7
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/controller/AppletApiMemberController.java
  4. +5
    -3
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/controller/AppletApiPromotionController.java
  5. +12
    -0
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/service/AppletApiVipService.java
  6. +12
    -1
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/service/AppletApiWaterService.java
  7. +8
    -5
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/service/impl/AppletApiLoginService.java
  8. +187
    -2
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/service/impl/AppletApiVipServiceImpl.java
  9. +48
    -0
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/service/impl/AppletApiWaterServiceImpl.java
  10. +29
    -0
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/common/IdUtils.java
  11. +12
    -2
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletWater/entity/AppletWater.java
  12. +1
    -0
      jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletWater/service/IAppletWaterService.java
  13. +2
    -0
      jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml
  14. +4
    -4
      jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/pay_weixin.properties
  15. +1
    -1
      jeecgboot-vue3/.env.development

+ 54
- 23
jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/common/system/vo/AppletUser.java View File

@ -4,6 +4,7 @@ import java.io.Serializable;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.Date; import java.util.Date;
import java.math.BigDecimal; import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
@ -22,61 +23,91 @@ import lombok.experimental.Accessors;
/** /**
* @Description: 用户 * @Description: 用户
* @Author: jeecg-boot * @Author: jeecg-boot
* @Date: 2025-07-17
* @Date: 2025-07-17
* @Version: V1.0 * @Version: V1.0
*/ */
@Data @Data
@TableName("applet_user") @TableName("applet_user")
@Accessors(chain = true) @Accessors(chain = true)
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
@Schema(description="用户")
@Schema(description = "用户")
public class AppletUser implements Serializable { public class AppletUser implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/**主键*/
@TableId(type = IdType.ASSIGN_ID)
/**
* 主键
*/
@TableId(type = IdType.ASSIGN_ID)
@Schema(description = "主键") @Schema(description = "主键")
private java.lang.String id; private java.lang.String id;
/**创建人*/
/**
* 创建人
*/
@Schema(description = "创建人") @Schema(description = "创建人")
private java.lang.String createBy; private java.lang.String createBy;
/**创建日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
/**
* 创建日期
*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Schema(description = "创建日期") @Schema(description = "创建日期")
private java.util.Date createTime; private java.util.Date createTime;
/**更新人*/
/**
* 更新人
*/
@Schema(description = "更新人") @Schema(description = "更新人")
private java.lang.String updateBy; private java.lang.String updateBy;
/**更新日期*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
/**
* 更新日期
*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Schema(description = "更新日期") @Schema(description = "更新日期")
private java.util.Date updateTime; private java.util.Date updateTime;
/**所属部门*/
/**
* 所属部门
*/
@Schema(description = "所属部门") @Schema(description = "所属部门")
private java.lang.String sysOrgCode; private java.lang.String sysOrgCode;
/**昵称*/
@Excel(name = "昵称", width = 15)
/**
* 昵称
*/
@Excel(name = "昵称", width = 15)
@Schema(description = "昵称") @Schema(description = "昵称")
private java.lang.String name; private java.lang.String name;
/**第三方认证id*/
@Excel(name = "第三方认证id", width = 15)
/**
* 第三方认证id
*/
@Excel(name = "第三方认证id", width = 15)
@Schema(description = "第三方认证id") @Schema(description = "第三方认证id")
private java.lang.String openid; private java.lang.String openid;
/**手机号*/
@Excel(name = "手机号", width = 15)
/**
* 手机号
*/
@Excel(name = "手机号", width = 15)
@Schema(description = "手机号") @Schema(description = "手机号")
private java.lang.String phone; private java.lang.String phone;
/**头像*/
@Excel(name = "头像", width = 15)
/**
* 头像
*/
@Excel(name = "头像", width = 15)
@Schema(description = "头像") @Schema(description = "头像")
private java.lang.String avatar; private java.lang.String avatar;
/**佣金*/
/**
* 佣金
*/
@Excel(name = "佣金", width = 15) @Excel(name = "佣金", width = 15)
@Schema(description = "佣金") @Schema(description = "佣金")
private java.math.BigDecimal commission; private java.math.BigDecimal commission;
/**邀请人*/
/**
* 总佣金
*/
@Excel(name = "总佣金", width = 15)
@Schema(description = "总佣金")
private java.math.BigDecimal price;
/**
* 邀请人
*/
@Excel(name = "邀请人", width = 15) @Excel(name = "邀请人", width = 15)
@Schema(description = "邀请人") @Schema(description = "邀请人")
private String inviter; private String inviter;


+ 3
- 2
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/controller/AppletApiLoginController.java View File

@ -40,14 +40,15 @@ public class AppletApiLoginController {
@IgnoreAuth @IgnoreAuth
public Result<Map<String, Object>> wxLogin( public Result<Map<String, Object>> wxLogin(
@Parameter(description = "微信登录code", required = true) @Parameter(description = "微信登录code", required = true)
String code) {
String code,
@Parameter(description = "邀请人") String inviter) {
if (StringUtils.isBlank(code)) { if (StringUtils.isBlank(code)) {
return Result.error("微信登录code不能为空"); return Result.error("微信登录code不能为空");
} }
log.info("收到小程序登录请求,code: {}", code); log.info("收到小程序登录请求,code: {}", code);
return appletApiLoginService.login(code);
return appletApiLoginService.login(code, inviter);
} }
/** /**


+ 21
- 7
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/controller/AppletApiMemberController.java View File

@ -10,13 +10,11 @@ import org.jeecg.modules.applet.service.AppletApiCouponService;
import org.jeecg.modules.applet.service.AppletApiVipService; import org.jeecg.modules.applet.service.AppletApiVipService;
import org.jeecg.modules.demo.appletCoupon.entity.AppletCoupon; import org.jeecg.modules.demo.appletCoupon.entity.AppletCoupon;
import org.jeecg.modules.demo.appletCoupon.service.IAppletCouponService; import org.jeecg.modules.demo.appletCoupon.service.IAppletCouponService;
import org.jeecg.modules.demo.appletMemberOrder.entity.AppletMemberOrder;
import org.jeecg.modules.demo.appletVip.entity.AppletVip; import org.jeecg.modules.demo.appletVip.entity.AppletVip;
import org.jeecg.modules.demo.appletVip.service.IAppletVipService; import org.jeecg.modules.demo.appletVip.service.IAppletVipService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
@ -41,11 +39,27 @@ public class AppletApiMemberController {
} }
@Operation(summary = "开通会员【待开发】", description = "开通会员")
@Operation(summary = "开通会员", description = "参数会员id 套餐id 优惠价id")
@PostMapping(value = "/open") @PostMapping(value = "/open")
public Result<?> open() {
return Result.OK();
public Result<Object> open(AppletMemberOrder appletMemberOrder) {
Object open = appletApiVipService.getOpe(appletMemberOrder);
return Result.OK(open);
}
@PostMapping("/payNotify")
public Object payNotify(@RequestBody String requestBody) {
//1添加流水
//2修改订单状态已支付
return appletApiVipService.payNotify(requestBody);
} }
@IgnoreAuth @IgnoreAuth
@Operation(summary = "获取优惠劵", description = "获取优惠劵") @Operation(summary = "获取优惠劵", description = "获取优惠劵")
@GetMapping(value = "/coupon") @GetMapping(value = "/coupon")


+ 5
- 3
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/controller/AppletApiPromotionController.java View File

@ -11,6 +11,7 @@ import org.jeecg.common.system.vo.AppletUser;
import org.jeecg.config.shiro.IgnoreAuth; import org.jeecg.config.shiro.IgnoreAuth;
import org.jeecg.modules.applet.service.AppletApiWaterService; import org.jeecg.modules.applet.service.AppletApiWaterService;
import org.jeecg.modules.demo.appletWater.entity.AppletWater; import org.jeecg.modules.demo.appletWater.entity.AppletWater;
import org.jeecg.modules.demo.appletWithdrawal.entity.AppletWithdrawal;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -53,10 +54,11 @@ public class AppletApiPromotionController {
} }
@Operation(summary = "提现【待开发】", description = "提现")
@Operation(summary = "提现【待开发】", description = "参数:提现人 提现金额")
@PostMapping(value = "/withdraw") @PostMapping(value = "/withdraw")
public Result<?> withdraw() {
return Result.OK();
public Result<AppletWithdrawal> withdraw(AppletWithdrawal appletWithdrawal) {
AppletWithdrawal With = appletApiWaterService.getWithdraw(appletWithdrawal);
return Result.OK(With);
} }
@Operation(summary = "推广统计【待开发】", description = "推广统计") @Operation(summary = "推广统计【待开发】", description = "推广统计")


+ 12
- 0
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/service/AppletApiVipService.java View File

@ -1,5 +1,6 @@
package org.jeecg.modules.applet.service; package org.jeecg.modules.applet.service;
import org.jeecg.modules.demo.appletMemberOrder.entity.AppletMemberOrder;
import org.jeecg.modules.demo.appletVip.entity.AppletVip; import org.jeecg.modules.demo.appletVip.entity.AppletVip;
import java.util.List; import java.util.List;
@ -12,4 +13,15 @@ public interface AppletApiVipService {
* @param appletVip * @param appletVip
*/ */
List<AppletVip> getList(AppletVip appletVip); List<AppletVip> getList(AppletVip appletVip);
/**
* 开通会员
*
* @param appletMemberOrder
* @return
*/
Object getOpe(AppletMemberOrder appletMemberOrder);
Object payNotify(String requestBody);
} }

+ 12
- 1
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/service/AppletApiWaterService.java View File

@ -4,23 +4,34 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.common.system.vo.AppletUser; import org.jeecg.common.system.vo.AppletUser;
import org.jeecg.modules.demo.appletWater.entity.AppletWater; import org.jeecg.modules.demo.appletWater.entity.AppletWater;
import org.jeecg.modules.demo.appletWithdrawal.entity.AppletWithdrawal;
import java.util.List; import java.util.List;
public interface AppletApiWaterService { public interface AppletApiWaterService {
/** /**
* 流水列表 * 流水列表
*
* @return * @return
*/ */
IPage<AppletWater> getWater(Page<AppletWater> waterPage); IPage<AppletWater> getWater(Page<AppletWater> waterPage);
/** /**
* 我的团队 * 我的团队
*
* @param page * @param page
* @return * @return
*/ */
IPage<AppletUser> getTeam(Page<AppletUser> page); IPage<AppletUser> getTeam(Page<AppletUser> page);
/**
* 提现
*
* @param appletWithdrawal
* @return
*/
AppletWithdrawal getWithdraw(AppletWithdrawal appletWithdrawal);
} }

+ 8
- 5
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/service/impl/AppletApiLoginService.java View File

@ -48,10 +48,10 @@ public class AppletApiLoginService {
* @param code 微信登录code * @param code 微信登录code
* @return 登录结果 * @return 登录结果
*/ */
public Result<Map<String, Object>> login(String code) {
public Result<Map<String, Object>> login(String code,String inviter) {
try { try {
log.info("开始小程序登录,code: {}", code); log.info("开始小程序登录,code: {}", code);
// 调用微信API获取openid和session_key // 调用微信API获取openid和session_key
String loginUrl = "https://api.weixin.qq.com/sns/jscode2session"; String loginUrl = "https://api.weixin.qq.com/sns/jscode2session";
Map<String, String> params = new HashMap<>(); Map<String, String> params = new HashMap<>();
@ -76,7 +76,9 @@ public class AppletApiLoginService {
log.info("微信登录成功,openid: {}", openid); log.info("微信登录成功,openid: {}", openid);
// 查找或创建用户 // 查找或创建用户
AppletUser appletUser = findOrCreateUser(openid, unionid);
AppletUser appletUser = findOrCreateUser(openid, unionid, inviter);
// 生成JWT token // 生成JWT token
String token = JwtUtil.sign(appletUser.getOpenid(), appletUser.getId()); String token = JwtUtil.sign(appletUser.getOpenid(), appletUser.getId());
@ -176,7 +178,7 @@ public class AppletApiLoginService {
* @param unionid 微信unionid * @param unionid 微信unionid
* @return 用户信息 * @return 用户信息
*/ */
private AppletUser findOrCreateUser(String openid, String unionid) {
private AppletUser findOrCreateUser(String openid, String unionid, String inviter) {
try { try {
// 根据openid查找用户 // 根据openid查找用户
AppletUser user = appletUserService.getByOpenid(openid); AppletUser user = appletUserService.getByOpenid(openid);
@ -188,7 +190,8 @@ public class AppletApiLoginService {
user.setName("微信用户" + openid.substring(0, 8)); user.setName("微信用户" + openid.substring(0, 8));
user.setCreateTime(new Date()); user.setCreateTime(new Date());
user.setCreateBy("system"); user.setCreateBy("system");
user.setInviter(inviter);
// TODO: 如果需要unionid字段需要在AppletUser实体类中添加该字段 // TODO: 如果需要unionid字段需要在AppletUser实体类中添加该字段
// user.setUnionid(unionid); // user.setUnionid(unionid);


+ 187
- 2
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/service/impl/AppletApiVipServiceImpl.java View File

@ -1,14 +1,34 @@
package org.jeecg.modules.applet.service.impl; package org.jeecg.modules.applet.service.impl;
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
import com.xkcoding.http.util.StringUtil;
import org.jeecg.common.api.IAppletUserService;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.system.util.AppletUserUtil;
import org.jeecg.common.system.vo.AppletUser;
import org.jeecg.modules.applet.service.AppletApiVipService; import org.jeecg.modules.applet.service.AppletApiVipService;
import org.jeecg.modules.common.IdUtils;
import org.jeecg.modules.demo.appletCoupon.entity.AppletCoupon;
import org.jeecg.modules.demo.appletCoupon.service.IAppletCouponService;
import org.jeecg.modules.demo.appletMemberOrder.entity.AppletMemberOrder;
import org.jeecg.modules.demo.appletMemberOrder.service.IAppletMemberOrderService;
import org.jeecg.modules.demo.appletVip.entity.AppletSetmeal; import org.jeecg.modules.demo.appletVip.entity.AppletSetmeal;
import org.jeecg.modules.demo.appletVip.entity.AppletVip; import org.jeecg.modules.demo.appletVip.entity.AppletVip;
import org.jeecg.modules.demo.appletVip.service.IAppletSetmealService; import org.jeecg.modules.demo.appletVip.service.IAppletSetmealService;
import org.jeecg.modules.demo.appletVip.service.IAppletVipService; import org.jeecg.modules.demo.appletVip.service.IAppletVipService;
import org.jeecg.modules.demo.appletWater.entity.AppletWater;
import org.jeecg.modules.demo.appletWater.service.IAppletWaterService;
import org.jeecg.modules.pay.MpWxPayService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.UUID;
@Service @Service
@ -17,6 +37,17 @@ public class AppletApiVipServiceImpl implements AppletApiVipService {
private IAppletVipService appletApiVipService; private IAppletVipService appletApiVipService;
@Autowired @Autowired
private IAppletSetmealService appletSetmealService; private IAppletSetmealService appletSetmealService;
@Autowired
private IAppletMemberOrderService appletMemberOrderService;
@Autowired
private IAppletCouponService appletCouponService;
@Autowired
private IAppletWaterService appletWaterService;
@Autowired
private IAppletUserService appletUserService;
//支付接口
@Autowired
private MpWxPayService mpWxPayService;
/** /**
* 查询会员列表 * 查询会员列表
@ -34,10 +65,164 @@ public class AppletApiVipServiceImpl implements AppletApiVipService {
List<AppletVip> list = appletApiVipService.list(); List<AppletVip> list = appletApiVipService.list();
for (AppletVip vip : list) { for (AppletVip vip : list) {
vip.setSetmeals(appletSetmealService vip.setSetmeals(appletSetmealService
.lambdaQuery()
.eq(AppletSetmeal::getVipId,vip.getId())
.lambdaQuery()
.eq(AppletSetmeal::getVipId, vip.getId())
.list()); .list());
} }
return list; return list;
} }
/**
* 开通会员
*
* @param order
*/
@Override
public Object getOpe(AppletMemberOrder order) {
if (StringUtil.isEmpty(order.getMemberId())) {
throw new JeecgBootException("会员id不能为空");
}
if (StringUtil.isEmpty(order.getSetmealId())) {
throw new JeecgBootException("套餐id不能为空");
}
AppletVip vip = appletApiVipService.getById(order.getMemberId());
AppletSetmeal setmeal = appletSetmealService.getById(order.getSetmealId());
if (vip == null) {
throw new JeecgBootException("会员不存在");
}
if (setmeal == null) {
throw new JeecgBootException("套餐不存在");
}
//获取用户id
String userId = AppletUserUtil.getCurrentAppletUserId();
String openid = AppletUserUtil.getCurrentAppletUserOpenid();
order.setUserId(userId);
order.setStatus("0");
order.setOrderNo(IdUtils.generateNoORD());
order.setPrice(setmeal.getDiscountedprice());
order.setDay(setmeal.getEndTime());
order.setSetmealTitle(setmeal.getTitle());
order.setRate(setmeal.getProportion());
order.setMemberTitle(vip.getTitle());
// 获取当前时间
Date now = new Date();
// 获取套餐天数
Integer days = setmeal.getEndTime();
if (days != null && days > 0) {
// 计算结束时间当前时间 + 套餐天数
Calendar calendar = Calendar.getInstance();
calendar.setTime(now);
calendar.add(Calendar.DAY_OF_MONTH, days);
order.setEndTime(calendar.getTime());
} else {
// 如果天数为空或无效默认设置为当前时间
order.setEndTime(now);
}
if (StringUtil.isNotEmpty(order.getCouponId())) {
// 计算优惠
AppletCoupon coupon = appletCouponService.getById(order.getCouponId());
if (coupon == null) {
throw new JeecgBootException("优惠卷不存在");
}
// TODO 需要判断忧患卷的状态等
order.setDiscount(coupon.getMoney());
if (coupon.getMoney() != null) {
order.setPrice(order.getPrice().subtract(coupon.getMoney()));
}
}
int price = order.getPrice().multiply(new BigDecimal(100)).intValue();
if (price > 0) {
appletMemberOrderService.save(order);
Object appOrder = mpWxPayService.createOrder(
"购买" + order.getMemberTitle(),
"127.0.0.1",
order.getId(),
price,
order.getId(),
openid,
order.toString());
return appOrder;
} else {
//直接修改订单状态
order.setStatus("1");
}
appletMemberOrderService.save(order);
return 0;
}
@Override
public Object payNotify(String requestBody) {
WxPayOrderNotifyResult notify = mpWxPayService.notify(requestBody);
String outTradeNo = notify.getOutTradeNo();
AppletMemberOrder order = appletMemberOrderService.getById(outTradeNo);
if (order != null) {
order.setStatus("1");
appletMemberOrderService.updateById(order);
//支付流水
appletWaterService.save(AppletWater.builder()
.user(order.getUserId())
.money(order.getPrice())
.number(IdUtils.generateNoLS())
.title("开通" + order.getMemberTitle())
.type("0")
.build());
AppletUser user = appletUserService.getById(order.getUserId());
if (user != null && user.getInviter() != null && order.getRate() != null) {
AppletUser userInviter = appletUserService.getById(user.getInviter());
if (userInviter != null) {
//计算分销金额
BigDecimal price = order.getPrice().multiply(new BigDecimal(order.getRate()));
appletWaterService.save(AppletWater.builder()
.source(order.getUserId())
.user(userInviter.getId())
.money(price)
.number(IdUtils.generateNoLS())
.title("开通" + order.getMemberTitle() + "分销金额")
.orderId(order.getId())
.type("0")
.build());
//佣金
BigDecimal commission = userInviter.getCommission() == null ? BigDecimal.ZERO : userInviter.getCommission();
userInviter.setCommission(commission.add(price));
// 更新邀请人的总佣金到price字段
BigDecimal totalPrice = userInviter.getPrice() == null ? BigDecimal.ZERO : userInviter.getPrice();
userInviter.setPrice(totalPrice.add(price));
appletUserService.updateById(userInviter);
}
}
}
return "<xml>" +
" <return_code><![CDATA[SUCCESS]]></return_code>" +
" <return_msg><![CDATA[OK]]></return_msg>" +
" </xml>";
}
} }

+ 48
- 0
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/applet/service/impl/AppletApiWaterServiceImpl.java View File

@ -3,15 +3,21 @@ package org.jeecg.modules.applet.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.common.api.IAppletUserService; import org.jeecg.common.api.IAppletUserService;
import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.system.util.AppletUserUtil; import org.jeecg.common.system.util.AppletUserUtil;
import org.jeecg.common.system.vo.AppletUser; import org.jeecg.common.system.vo.AppletUser;
import org.jeecg.modules.applet.service.AppletApiWaterService; import org.jeecg.modules.applet.service.AppletApiWaterService;
import org.jeecg.modules.common.IdUtils;
import org.jeecg.modules.demo.appletWater.entity.AppletWater; import org.jeecg.modules.demo.appletWater.entity.AppletWater;
import org.jeecg.modules.demo.appletWater.service.IAppletWaterService; import org.jeecg.modules.demo.appletWater.service.IAppletWaterService;
import org.jeecg.modules.demo.appletWithdrawal.entity.AppletWithdrawal;
import org.jeecg.modules.demo.appletWithdrawal.service.IAppletWithdrawalService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.List; import java.util.List;
import java.util.UUID;
@Service @Service
public class AppletApiWaterServiceImpl implements AppletApiWaterService { public class AppletApiWaterServiceImpl implements AppletApiWaterService {
@ -19,6 +25,8 @@ public class AppletApiWaterServiceImpl implements AppletApiWaterService {
private IAppletWaterService appletWaterService; private IAppletWaterService appletWaterService;
@Autowired @Autowired
private IAppletUserService appletUserService; private IAppletUserService appletUserService;
@Autowired
private IAppletWithdrawalService appletWithdrawalService;
/** /**
@ -37,6 +45,7 @@ public class AppletApiWaterServiceImpl implements AppletApiWaterService {
/** /**
* 我的团队 * 我的团队
*
* @param page * @param page
* @return * @return
*/ */
@ -47,4 +56,43 @@ public class AppletApiWaterServiceImpl implements AppletApiWaterService {
.eq(AppletUser::getInviter, userId) .eq(AppletUser::getInviter, userId)
.page(page); .page(page);
} }
@Override
public AppletWithdrawal getWithdraw(AppletWithdrawal appletWithdrawal) {
if (appletWithdrawal.getMoney() == null) {
throw new JeecgBootException("提现金额不能为空");
}
if (appletWithdrawal.getMoney().compareTo(new BigDecimal(0.03)) <= 0) {
throw new JeecgBootException("提现金额不能为负数");
}
if (appletWithdrawal.getName() == null) {
throw new JeecgBootException("请输入真实姓名");
}
//获得用户id
String userId = AppletUserUtil.getCurrentAppletUserId();
appletWithdrawal.setUserId(userId);
AppletUser currentUser = AppletUserUtil.getCurrentAppletUser();
if (currentUser.getCommission() == null || currentUser.getCommission().compareTo(appletWithdrawal.getMoney()) < 0) {
throw new JeecgBootException("余额不足");
}
//添加流水记录
appletWaterService.save(AppletWater.builder()
.user(appletWithdrawal.getUserId())
.money((appletWithdrawal.getMoney()))
.number(IdUtils.generateNoLS())
.oldMoney(currentUser.getCommission())
.title("提现")
.type("2")
.build());
BigDecimal subtract = currentUser.getCommission().subtract(appletWithdrawal.getMoney());
currentUser.setCommission(subtract);
appletUserService.updateById(currentUser);
//保存提现记录
appletWithdrawalService.save(appletWithdrawal);
return appletWithdrawal;
}
} }

+ 29
- 0
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/common/IdUtils.java View File

@ -0,0 +1,29 @@
package org.jeecg.modules.common;
import java.text.SimpleDateFormat;
import java.util.Date;
public class IdUtils {
public static String generateNoLS() {
return generateNo("LS");
}
public static String generateNoORD() {
return generateNo("ORD");
}
/**
* 生成随机号
*/
public static String generateNo(String start) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
String timestamp = sdf.format(new Date());
// 添加3位随机数
int random = (int) (Math.random() * 900) + 100;
return start + timestamp + random;
}
}

+ 12
- 2
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletWater/entity/AppletWater.java View File

@ -8,15 +8,14 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableLogic; import com.baomidou.mybatisplus.annotation.TableLogic;
import lombok.*;
import org.jeecg.common.constant.ProvinceCityArea; import org.jeecg.common.constant.ProvinceCityArea;
import org.jeecg.common.util.SpringContextUtils; import org.jeecg.common.util.SpringContextUtils;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel; import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.common.aspect.annotation.Dict; import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
/** /**
@ -30,6 +29,9 @@ import lombok.experimental.Accessors;
@Accessors(chain = true) @Accessors(chain = true)
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
@Schema(description="流水") @Schema(description="流水")
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class AppletWater implements Serializable { public class AppletWater implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -64,6 +66,10 @@ public class AppletWater implements Serializable {
@Excel(name = "流水编号", width = 15) @Excel(name = "流水编号", width = 15)
@Schema(description = "流水编号") @Schema(description = "流水编号")
private java.lang.String number; private java.lang.String number;
/**订单id*/
@Excel(name = "订单id", width = 15)
@Schema(description = "订单id")
private java.lang.String orderId;
/**用户*/ /**用户*/
@Excel(name = "用户", width = 15, dictTable = "applet_user", dicText = "name", dicCode = "id") @Excel(name = "用户", width = 15, dictTable = "applet_user", dicText = "name", dicCode = "id")
@Dict(dictTable = "applet_user", dicText = "name", dicCode = "id") @Dict(dictTable = "applet_user", dicText = "name", dicCode = "id")
@ -78,6 +84,10 @@ public class AppletWater implements Serializable {
@Excel(name = "金额", width = 15) @Excel(name = "金额", width = 15)
@Schema(description = "金额") @Schema(description = "金额")
private java.math.BigDecimal money; private java.math.BigDecimal money;
/**原钱包金额*/
@Excel(name = "原钱包金额", width = 15)
@Schema(description = "原钱包金额")
private java.math.BigDecimal oldMoney;
/**流水类型*/ /**流水类型*/
@Excel(name = "流水类型", width = 15, dicCode = "applet_water_type") @Excel(name = "流水类型", width = 15, dicCode = "applet_water_type")
@Dict(dicCode = "applet_water_type") @Dict(dicCode = "applet_water_type")


+ 1
- 0
jeecg-boot/jeecg-boot-module/jeecgboot-boot-applet/src/main/java/org/jeecg/modules/demo/appletWater/service/IAppletWaterService.java View File

@ -2,6 +2,7 @@ package org.jeecg.modules.demo.appletWater.service;
import org.jeecg.modules.demo.appletWater.entity.AppletWater; import org.jeecg.modules.demo.appletWater.entity.AppletWater;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.demo.appletWithdrawal.entity.AppletWithdrawal;
/** /**
* @Description: 流水 * @Description: 流水


+ 2
- 0
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml View File

@ -119,6 +119,8 @@ spring:
web-stat-filter: web-stat-filter:
enabled: true enabled: true
dynamic: dynamic:
primary: master
strict: false
druid: # 全局druid参数,绝大部分值和默认保持一致。(现已支持的参数如下,不清楚含义不要乱设置) druid: # 全局druid参数,绝大部分值和默认保持一致。(现已支持的参数如下,不清楚含义不要乱设置)
# 连接池的配置信息 # 连接池的配置信息
# 初始化大小,最小,最大 # 初始化大小,最小,最大


+ 4
- 4
jeecg-boot/jeecg-module-system/jeecg-system-start/src/main/resources/pay_weixin.properties View File

@ -2,7 +2,7 @@ pay.mchId=1711030469
pay.appId=wx8ff2ab9559aa6387 pay.appId=wx8ff2ab9559aa6387
pay.mchKey=0fdb77429ffdf206c151af76a663041c pay.mchKey=0fdb77429ffdf206c151af76a663041c
pay.keyPath=classpath:apiclient_cert.pem pay.keyPath=classpath:apiclient_cert.pem
pay.notifyUrl=https://www.petualmedical.com/health-admin/appletApi/order/payNotify
pay.notifyUrlDev=https://www.petualmedical.com/health-admin/appletApi/order/payNotify
pay.notifyOneUrl=https://www.petualmedical.com/health-admin/appletApi/order/payNotify
pay.notifyUrlOneDev=https://www.petualmedical.com/health-admin/appletApi/order/payNotify
pay.notifyUrl=https://www.petualmedical.com/health-admin/appletApi/member/payNotify
pay.notifyUrlDev=https://www.petualmedical.com/health-admin/appletApi/member/payNotify
pay.notifyOneUrl=https://www.petualmedical.com/health-admin/appletApi/member/payNotify
pay.notifyUrlOneDev=https://www.petualmedical.com/health-admin/appletApi/member/payNotify

+ 1
- 1
jeecgboot-vue3/.env.development View File

@ -6,7 +6,7 @@ VITE_PUBLIC_PATH = /
# 跨域代理,您可以配置多个 ,请注意,没有换行符 # 跨域代理,您可以配置多个 ,请注意,没有换行符
VITE_PROXY = [["/jeecgboot","http://localhost:8002/health-admin"],["/upload","http://localhost:3300/upload"]]
VITE_PROXY = [["/englishread-admin","http://localhost:8002/englishread-admin"],["/upload","http://localhost:3300/upload"]]
#后台接口全路径地址(必填) #后台接口全路径地址(必填)
VITE_GLOB_DOMAIN_URL=http://localhost:8002/englishread-admin VITE_GLOB_DOMAIN_URL=http://localhost:8002/englishread-admin


Loading…
Cancel
Save