This commit is contained in:
wuchunlei
2026-01-13 13:33:41 +08:00
parent cbfcd18255
commit 5cff97047e
31 changed files with 1006 additions and 156 deletions

2
mvnw.cmd vendored
View File

@@ -23,7 +23,7 @@
@REM
@REM Optional ENV vars
@REM MVNW_REPOURL - repo url base for downloading maven distribution
@REM MVNW_USERNAME/MVNW_PASSWORD - user and password for downloading maven
@REM MVNW_USERNAME/MVNW_PASSWORD - sysUser and password for downloading maven
@REM MVNW_VERBOSE - true: enable verbose log; others: silence the output
@REM ----------------------------------------------------------------------------

View File

@@ -1,10 +1,10 @@
package com.zmzm.finance.common.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zmzm.finance.common.entity.User;
import com.zmzm.finance.common.entity.UserToken;
import com.zmzm.finance.common.service.IUserService;
import com.zmzm.finance.common.service.IUserTokenService;
import com.zmzm.finance.common.entity.SysUser;
import com.zmzm.finance.common.entity.SysUserToken;
import com.zmzm.finance.common.service.ISysUserService;
import com.zmzm.finance.common.service.ISysUserTokenService;
import com.zmzm.finance.util.MD5Utils;
import com.zmzm.finance.util.R;
import com.zmzm.finance.util.ShiroUtils;
@@ -21,21 +21,21 @@ import java.util.Date;
public class AuthController {
@Autowired
private IUserService userService;
private ISysUserService sysUserService;
@Autowired
private IUserTokenService userTokenService;
private ISysUserTokenService sysUserTokenService;
//登录
@RequestMapping("/login")
public R login(@RequestBody User user){
User userEntity = userService.getOne(new LambdaQueryWrapper<User>()
.eq(User::getAccount, user.getAccount()));
if(userEntity == null){
public R login(@RequestBody SysUser sysUser){
SysUser sysUserEntity = sysUserService.getOne(new LambdaQueryWrapper<SysUser>()
.eq(SysUser::getAccount, sysUser.getAccount()));
if(sysUserEntity == null){
return R.error(500,"账号不存在");
}else {
if (MD5Utils.getSaltverifyMD5(user.getPassword(),userEntity.getPassword())){
UserToken userToken = userTokenService.createToken(userEntity.getId());
return R.ok("登录成功").putData("userEntity",userEntity).putData("userToken",userToken);
if (MD5Utils.getSaltverifyMD5(sysUser.getPassword(), sysUserEntity.getPassword())){
SysUserToken sysUserToken = sysUserTokenService.createToken(sysUserEntity.getId());
return R.ok("登录成功").putData("userEntity", sysUserEntity).putData("userToken", sysUserToken);
}else {
return R.error(500,"密码不正确,请重试");
}
@@ -45,9 +45,9 @@ public class AuthController {
//退出
@RequestMapping("/logout")
public R logout(){
UserToken userToken = userTokenService.getById(ShiroUtils.getUserId());
userToken.setExpireTime(new Date());
userTokenService.updateById(userToken);
SysUserToken sysUserToken = sysUserTokenService.getById(ShiroUtils.getUserId());
sysUserToken.setExpireTime(new Date());
sysUserTokenService.updateById(sysUserToken);
return R.ok();
}

View File

@@ -0,0 +1,121 @@
package com.zmzm.finance.common.controller;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zmzm.finance.common.entity.Orders;
import com.zmzm.finance.common.entity.User;
import com.zmzm.finance.common.entity.WumenUser;
import com.zmzm.finance.common.service.IOrdersService;
import com.zmzm.finance.common.service.IUserService;
import com.zmzm.finance.common.service.WumenUserService;
import com.zmzm.finance.util.R;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("/common/orders")
public class OrdersController {
@Autowired
private IOrdersService ordersService;
@Autowired
private IUserService userService;
@Autowired
private WumenUserService wumenUserService;
//账单列表
@RequestMapping("/getPointOrdersListNoUse")
public R getPointOrdersListNoUse(@RequestBody Map<String,Object> params){
Page<Orders> ordersPage = ordersService.page(
new Page<>(Long.parseLong(params.get("page").toString()),Long.parseLong(params.get("limit").toString())),
new LambdaQueryWrapper<Orders>().eq(Orders::getPayType,1)
.eq(StringUtils.isNotEmpty(params.get("tel").toString()), Orders::getTel, params.get("tel").toString())
.eq(StringUtils.isNotEmpty(params.get("source").toString()), Orders::getSource, params.get("source").toString())
.eq(StringUtils.isNotEmpty(params.get("type").toString()), Orders::getType, params.get("type").toString())
.eq(StringUtils.isNotEmpty(params.get("useFlag").toString()), Orders::getUseFlag, params.get("useFlag").toString())
.ge(StringUtils.isNotEmpty(params.get("startTime").toString()),Orders::getOrderTime,params.get("startTime").toString())
.le(StringUtils.isNotEmpty(params.get("endTime").toString()),Orders::getOrderTime,params.get("endTime").toString())
.orderByAsc(Orders::getOrderTime));
return R.ok().put("data",ordersPage);
}
//自动消耗天医币
@RequestMapping("/autoConsumePoint")
@DSTransactional
public R autoConsumePoint(){
List<User> userList = userService.list(new LambdaQueryWrapper<User>().gt(User::getTotalPoint,0));
List<User> userRes = new ArrayList<>();
List<Orders> ordersRes = new ArrayList<>();
for (User user : userList) {
WumenUser wumenUser = wumenUserService.getOne(new LambdaQueryWrapper<WumenUser>()
.select(WumenUser::getPeanutCoin)
.gt(WumenUser::getPeanutCoin, 0)
.and(t -> t.eq(WumenUser::getTel, user.getTel()).or().eq(WumenUser::getEmail, user.getTel())));
if (wumenUser != null && user.getPoint().compareTo(wumenUser.getPeanutCoin()) > 0) {
BigDecimal differencePoint = user.getPoint().subtract(wumenUser.getPeanutCoin());
List<Orders> orders = ordersService.list(new LambdaQueryWrapper<Orders>()
.eq(Orders::getPayType, 1).eq(Orders::getUseFlag, 0)
.eq(Orders::getTel, user.getTel()).orderByDesc(Orders::getOrderTime));
for (Orders order : orders) {
if (differencePoint.compareTo(order.getFee()) >= 0) {
differencePoint = differencePoint.subtract(order.getFee());
order.setUseFlag(1);
ordersRes.add(order);
user.setPoint(user.getPoint().subtract(order.getFee()));
}
}
userRes.add(user);
}
}
ordersService.updateBatchById(ordersRes);
userService.updateBatchById(userList);
return R.ok();
}
//人工消耗天医币
@RequestMapping("/manualConsumePoint")
@DSTransactional
public R manualConsumePoint(@RequestBody Map<String,Object> params){
Orders orders = ordersService.getById(params.get("orderId").toString());
if (orders != null&&orders.getUseFlag()==0) {
orders.setUseFlag(1);
ordersService.updateById(orders);
User user = userService.getOne(new LambdaQueryWrapper<User>()
.eq(User::getTel, orders.getTel()));
user.setPoint(user.getPoint().subtract(orders.getFee()));
userService.updateById(user);
}else {
return R.error("不存在或已消耗");
}
return R.ok();
}
//取消消耗天医币
@RequestMapping("/cancelConsumePoint")
@DSTransactional
public R cancelConsumePoint(@RequestBody Map<String,Object> params){
Orders orders = ordersService.getById(params.get("orderId").toString());
if (orders != null&&orders.getUseFlag()==1) {
orders.setUseFlag(0);
ordersService.updateById(orders);
User user = userService.getOne(new LambdaQueryWrapper<User>()
.eq(User::getTel, orders.getTel()));
user.setPoint(user.getPoint().add(orders.getFee()));
userService.updateById(user);
}else {
return R.error("不存在或未消耗");
}
return R.ok();
}
}

View File

@@ -2,25 +2,21 @@ package com.zmzm.finance.common.controller;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.zmzm.finance.common.dao.TCurriculumCatalogueMapper;
import com.zmzm.finance.common.entity.*;
import com.zmzm.finance.common.service.*;
import com.zmzm.finance.util.R;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* <p>
@@ -41,11 +37,27 @@ public class PaymentController {
@Autowired
private IOrdersService ordersService;
@Autowired
private ITCustomerTaihuClassService customerTaihuClassService;
@Autowired
private ITCurriculumCatalogueService curriculumCatalogueService;
@Autowired
private ITCustomerTaihuClassService customerTaihuClassService;
@Autowired
private IShopProductService shopProductService;
@Autowired
private IUserCourseBuyService userCourseBuyService;
@Autowired
private ITCommodityService commodityService;
@Autowired
private ITCustomerPointDetailService customerPointDetailService;
@Autowired
private ITransactionDetailsService transactionDetailsService;
@Autowired
private ITrainingClassService trainingClassService;
@Autowired
private ITMeetingclassRegisterService meetingclassRegisterService;
@Autowired
private IFinanceOrderService financeOrderService;
@Autowired
private IUserVipService userVipService;
//账单列表
@RequestMapping("/getPaymentList")
@@ -94,6 +106,8 @@ public class PaymentController {
pto.setOrderId(payment.getOrdersId());
ptos.add(pto);
payment.setCheckoff(2);
ordersService.updatePoint(payment.getOrdersId());
ordersService.update(new LambdaUpdateWrapper<Orders>().set(Orders::getUseFlag,1).eq(Orders::getId,payment.getOrdersId()));
}else {
payment.setCheckoff(1);
}
@@ -125,18 +139,35 @@ public class PaymentController {
payment.setCheckoff(2);
paymentService.updateById(payment);
paymentToOrderService.save(pto);
ordersService.updatePoint(pto.getOrderId());
ordersService.update(new LambdaUpdateWrapper<Orders>().set(Orders::getUseFlag,1).eq(Orders::getId,pto.getOrderId()));
return R.ok();
}
//获取课程消费记录
//一路健康课程商品列表
@RequestMapping("/courseBuyList")
public R courseBuyList(@RequestBody Map<String,Object> params) {
Page<Map<String,Object>> page = curriculumCatalogueService.pageMaps(new Page<>(Long.parseLong(params.get("page").toString()),
Long.parseLong(params.get("limit").toString())),
new MPJLambdaWrapper<TCurriculumCatalogue>()
.leftJoin("t_curriculum_catalogue t1 on t1.oid = t.poid")
.like(StringUtils.isNotEmpty(params.get("title").toString()),"t1.title",params.get("title").toString())
.eq("t.curriculumflg",2)
.eq("t.valid",1)
.select("t.oid courseId,concat(t1.title,'[',t1.tags,']',t.title) productName,t.courseFee price"));
return R.ok().put("data",page);
}
//一路健康推荐课程记录
@RequestMapping("/recommendCcourseBuyList")
public R recommendCcourseBuyList(@RequestBody Map<String,Object> params) {
Payment payment = paymentService.getById(params.get("paymentId").toString());
Page<Map<String,Object>> page = customerTaihuClassService.pageMaps(new Page<>(Long.parseLong(params.get("page").toString()),Long.parseLong(params.get("limit").toString())),
new MPJLambdaWrapper<TCustomerTaihuClass>()
.leftJoin(TCurriculumCatalogue.class,TCurriculumCatalogue::getOid,TCustomerTaihuClass::getTaihuclassoid)
.leftJoin(TCurriculumCatalogue.class,TCurriculumCatalogue::getOid,TCurriculumCatalogue::getPoid)
.select("t.oid,t.customerOid,t.createDate,t.studyDays,t1.courseFee,t1.title courseTitle,t2.title catalogueTitle")
.leftJoin("t_customer t3 on t3.oid = t.customerOid")
.select("t1.oid courseId,t3.cellPhone,t.createDate,t.studyDays,t1.courseFee,concat(t2.title,'[',t2.tags,']',t1.title) productName")
.like(TCustomerTaihuClass::getDescription,"后台免费开通")
.ge(TCustomerTaihuClass::getCreatedate, payment.getCtime())
.le(TCustomerTaihuClass::getCreatedate, DateUtils.addDays(payment.getCtime(),3))
@@ -144,24 +175,233 @@ public class PaymentController {
return R.ok().put("data",page);
}
//获取实物消费记录
//吴门医述课程商品列表
@RequestMapping("/wumenCourseBuyList")
public R wumenCourseBuyList(@RequestBody Map<String,Object> params) {
Page<Map<String,Object>> page = shopProductService.pageMaps(new Page<>(Long.parseLong(params.get("page").toString()),
Long.parseLong(params.get("limit").toString())),
new MPJLambdaWrapper<ShopProduct>()
.leftJoin("shop_product_course t1 on (t1.product_id = t.product_id and t1.del_flag=0)")
.eq(ShopProduct::getGoodsType,"05")
.like(StringUtils.isNotEmpty(params.get("title").toString()),ShopProduct::getProductName,params.get("title").toString())
.select("t.product_id productId,t1.course_id courseId,t.product_name productName,t.price"));
return R.ok().put("data",page);
}
//吴门医述推荐课程记录
@RequestMapping("/recommendWumenCourseBuyList")
public R recommendWumenCourseBuyList(@RequestBody Map<String,Object> params) {
Payment payment = paymentService.getById(params.get("paymentId").toString());
Page<Map<String,Object>> page = userCourseBuyService.pageMaps(new Page<>(Long.parseLong(params.get("page").toString()),
Long.parseLong(params.get("limit").toString())),
new MPJLambdaWrapper<UserCourseBuy>()
.leftJoin("user t1 on t1.id = t.user_id")
.leftJoin("course t2 on t2.id = t.course_id")
.leftJoin("course_catalogue t3 on t3.id = t.catalogue_id")
.select("t.id ucbId,t1.tel,t2.id courseId,t3.id catalogueId,concat(t2.title,t3.title) productName,concat(t3.half_fee,',',t3.fee) price")
.ge(UserCourseBuy::getCreateTime, payment.getCtime())
.le(UserCourseBuy::getCreateTime, DateUtils.addDays(payment.getCtime(),3))
.orderByAsc(UserCourseBuy::getCreateTime));
return R.ok().put("data",page);
}
//一路健康实物商品
@RequestMapping("/physicalBuyList")
public R physicalBuyList(@RequestBody Map<String,Object> params) {
Payment payment = paymentService.getById(params.get("paymentId").toString());
Page<Map<String,Object>> page = commodityService.pageMaps(new Page<>(Long.parseLong(params.get("page").toString()),Long.parseLong(params.get("limit").toString())),
Page<Map<String,Object>> page = commodityService.pageMaps(new Page<>(Long.parseLong(params.get("page").toString()),
Long.parseLong(params.get("limit").toString())),
new MPJLambdaWrapper<TCommodity>()
.select("t.oid,t.namecn,t.currentprice")
.select("t.oid id,t.namecn productName,t.currentprice price")
.eq(TCommodity::getStoreoid, "015ed7e15a9b4bcb961a8f9c4666265d")
.eq(TCommodity::getValid, 1)
.like(TCommodity::getNamecn, params.get("productName").toString())
.gt(TCommodity::getCurrentprice,0)
.orderByAsc(TCommodity::getCurrentprice));
return R.ok().put("data",page);
}
//吴门医述实物商品
@RequestMapping("/wumenPhysicalBuyList")
public R wumenPhysicalBuyList(@RequestBody Map<String,Object> params) {
Page<Map<String,Object>> page = shopProductService.pageMaps(new Page<>(Long.parseLong(params.get("page").toString()),
Long.parseLong(params.get("limit").toString())),
new MPJLambdaWrapper<ShopProduct>()
.ne(ShopProduct::getGoodsType,"05")
.like(StringUtils.isNotEmpty(params.get("productName").toString()),ShopProduct::getProductName,params.get("productName").toString())
.select("product_id id,product_name productName,price"));
return R.ok().put("data",page);
}
//一路健康充值记录
@RequestMapping("/yljkPointBuyList")
public R yljkPointBuyList(@RequestBody Map<String,Object> params) {
Payment payment = paymentService.getById(params.get("paymentId").toString());
Page<Map<String,Object>> page = customerPointDetailService.pageMaps(new Page<>(Long.parseLong(params.get("page").toString()),
Long.parseLong(params.get("limit").toString())),
new MPJLambdaWrapper<TCustomerPointDetail>()
.leftJoin("t_customer t1 on t1.oid = t.customerOid")
.select("t.oid id,t1.cellPhone tel,t.point,t.content note")
.eq(TCustomerPointDetail::getDescription, "微店购买")
.isNotNull(TCustomerPointDetail::getContent)
.gt(TCustomerPointDetail::getPoint,0)
.ge(TCustomerPointDetail::getCreatedate, payment.getCtime())
.le(TCustomerPointDetail::getCreatedate, DateUtils.addDays(payment.getCtime(),3))
.orderByAsc(TCustomerPointDetail::getPoint));
return R.ok().put("data",page);
}
//吴门充值记录
@RequestMapping("/wumenPointBuyList")
public R wumenPointBuyList(@RequestBody Map<String,Object> params) {
Payment payment = paymentService.getById(params.get("paymentId").toString());
Page<Map<String,Object>> page = transactionDetailsService.pageMaps(new Page<>(Long.parseLong(params.get("page").toString()),
Long.parseLong(params.get("limit").toString())),
new MPJLambdaWrapper<TransactionDetails>()
.leftJoin("user t1 on t1.id = t.user_id")
.select("t.transaction_id id,t1.tel,t.change_amount point,t.note")
.eq(TransactionDetails::getOrderType, "后台充值")
.notLike(TransactionDetails::getNote,"退")
.ge(TransactionDetails::getCreateTime, payment.getCtime())
.le(TransactionDetails::getCreateTime, DateUtils.addDays(payment.getCtime(),3))
.orderByAsc(TransactionDetails::getChangeAmount));
return R.ok().put("data",page);
}
//vip列表
@RequestMapping("/vipList")
public R vipList() {
List<Map<String,Object>> list = new ArrayList<>();
Map<String,Object> map4 = new HashMap<>();
map4.put("type","4");
map4.put("title","中医学vip");
list.add(map4);
Map<String,Object> map5 = new HashMap<>();
map5.put("type","5");
map5.put("title","针灸学vip");
list.add(map5);
Map<String,Object> map6 = new HashMap<>();
map6.put("type","6");
map6.put("title","肿瘤学vip");
list.add(map6);
Map<String,Object> map7 = new HashMap<>();
map7.put("type","7");
map7.put("title","国学vip");
list.add(map7);
Map<String,Object> map8 = new HashMap<>();
map8.put("type","8");
map8.put("title","心理学vip");
list.add(map8);
Map<String,Object> map9 = new HashMap<>();
map9.put("type","9");
map9.put("title","中西汇通vip");
list.add(map9);
return R.ok().putData("records",list);
}
//培训班列表
@RequestMapping("/trainingClassList")
public R trainingClassList(@RequestBody Map<String,Object> params) {
List<Map<String,Object>> res = new ArrayList<>();
List<Map<String,Object>> wumenClass = trainingClassService.listMaps(new MPJLambdaWrapper<TrainingClass>()
.like(StringUtils.isNotEmpty(params.get("title").toString()),TrainingClass::getTitle,params.get("title").toString())
.selectAs(TrainingClass::getId,"productId")
.select(TrainingClass::getTitle,TrainingClass::getYear));
List<Map<String,Object>> yljkClass = meetingclassRegisterService.listMaps(new MPJLambdaWrapper<TMeetingclassRegister>()
.like(StringUtils.isNotEmpty(params.get("title").toString()),TMeetingclassRegister::getTitle,params.get("title").toString())
.eq(TMeetingclassRegister::getValid,1)
.selectAs(TMeetingclassRegister::getOid,"productId")
.select(TMeetingclassRegister::getTitle,TMeetingclassRegister::getYears));
if (wumenClass != null && wumenClass.size() > 0) {
res.addAll(wumenClass);
}
if (yljkClass != null && yljkClass.size() > 0) {
res.addAll(yljkClass);
}
return R.ok().putData("records",res);
}
//推荐用户
@RequestMapping("/recommendUser")
public R recommendUser(@RequestBody Map<String,Object> params) {
Payment payment = paymentService.getById(params.get("paymentId").toString());
List<Map<String,Object>> list = new ArrayList<>();
if ("1".equals(params.get("come").toString())&&"1".equals(params.get("orderType").toString())){
list = userVipService.listMaps(new MPJLambdaWrapper<UserVip>()
.leftJoin("user t1 on t1.id = t.user_id")
.select("t1.tel")
.distinct()
.eq(UserVip::getType,params.get("vipType").toString())
.ge(UserVip::getStartTime, payment.getCtime())
.orderByAsc(UserVip::getStartTime)
.last("limit 3"));
}else if ("0".equals(params.get("come").toString())&&"2".equals(params.get("orderType").toString())) {
list = customerTaihuClassService.listMaps(new MPJLambdaWrapper<TCustomerTaihuClass>()
.leftJoin("t_customer t3 on t3.oid = t.customerOid")
.select("t3.cellPhone tel")
.distinct()
.eq(TCustomerTaihuClass::getTaihuclassoid, params.get("courseId").toString())
.ge(TCustomerTaihuClass::getCreatedate, payment.getCtime())
.le(TCustomerTaihuClass::getCreatedate, DateUtils.addMonths(payment.getCtime(),1))
.orderByAsc(TCustomerTaihuClass::getCreatedate)
.last("limit 3"));
}else if ("1".equals(params.get("come").toString())&&"2".equals(params.get("orderType").toString())){
list = userCourseBuyService.listMaps(new MPJLambdaWrapper<UserCourseBuy>()
.leftJoin("user t1 on t1.id = t.user_id")
.select("t1.tel")
.distinct()
.eq(UserCourseBuy::getCourseId,params.get("courseId").toString())
.ge(UserCourseBuy::getCreateTime, payment.getCtime())
.le(UserCourseBuy::getCreateTime, DateUtils.addMonths(payment.getCtime(),1))
.orderByAsc(UserCourseBuy::getCreateTime)
.last("limit 3"));
}
return R.ok().putData("list",list);
}
//通过添加订单核对
@RequestMapping("/checkoffByAddOrder")
@DSTransactional
public R checkoffByAddOrder(@RequestBody Map<String,Object> params) {
public R checkoffByAddOrder(@RequestBody Map<String,Object> params) throws ParseException {
List<Map<String,Object>> list = (List<Map<String,Object>>)params.get("list");
for (Map<String,Object> map : list) {
FinanceOrder financeOrder = new FinanceOrder();
financeOrder.setTel(map.get("tel").toString());
financeOrder.setCome(map.get("come").toString());
financeOrder.setOrderType(Integer.parseInt(map.get("orderType").toString()));
financeOrder.setProductId(map.get("productId").toString());
financeOrder.setProductName(map.get("productName").toString());
financeOrder.setCourseId(map.get("courseId").toString());
financeOrder.setCatalogueId(map.get("catalogueId").toString());
financeOrder.setOrderSn(UUID.randomUUID().toString().replace("-",""));
financeOrder.setOrderMoney(new BigDecimal(map.get("orderMoney").toString()));
financeOrder.setDistrictMoney(new BigDecimal(map.get("districtMoney").toString()));
financeOrder.setRealMoney(new BigDecimal(map.get("realMoney").toString()));
if (StringUtils.isNotEmpty(map.get("startTime").toString())){
financeOrder.setStartTime(DateUtils.parseDate(map.get("startTime").toString(),new String[]{"yyyy-MM-dd"}));
}
if (StringUtils.isNotEmpty(map.get("endTime").toString())){
financeOrder.setEndTime(DateUtils.parseDate(map.get("endTime").toString(),new String[]{"yyyy-MM-dd"}));
}
financeOrderService.save(financeOrder);
Orders orders = new Orders();
orders.setSource(2);
orders.setOrderSn(financeOrder.getOrderSn());
orders.setOrderOldId(financeOrder.getId()+"");
orders.setTel(financeOrder.getTel());
orders.setFee(financeOrder.getRealMoney());
orders.setType(financeOrder.getOrderType());
orders.setOrderTime(financeOrder.getCreateTime());
orders.setUseFlag(1);
ordersService.save(orders);
PaymentToOrder pto = new PaymentToOrder();
pto.setPaymentId(Integer.parseInt(map.get("paymentId").toString()));
pto.setOrderId(orders.getId());
paymentToOrderService.save(pto);
Payment payment = paymentService.getById(Integer.parseInt(map.get("paymentId").toString()));
payment.setCheckoff(2);
paymentService.updateById(payment);
ordersService.updatePoint(orders.getId());
}
return R.ok();
}

View File

@@ -0,0 +1,57 @@
package com.zmzm.finance.common.controller;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.zmzm.finance.common.entity.Orders;
import com.zmzm.finance.common.entity.Payment;
import com.zmzm.finance.common.entity.User;
import com.zmzm.finance.common.service.IOrdersService;
import com.zmzm.finance.common.service.IPaymentService;
import com.zmzm.finance.common.service.IUserService;
import com.zmzm.finance.util.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@RestController("commonStatistics")
@RequestMapping("common/statistics")
public class StatisticsController {
@Autowired
private IUserService userService;
@Autowired
private IOrdersService ordersService;
@Autowired
private IPaymentService paymentService;
//天医币统计
@RequestMapping("/pointStatistics")
public R pointStatistics(@RequestBody Map<String,Object> params){
Map<String,Object> map = new HashMap<>();
map.put("income",0);
map.putAll(userService.getMap(new MPJLambdaWrapper<User>()
.selectSum(User::getPoint,"totalPoint")));
Map<String,Object> income = ordersService.getMap(new MPJLambdaWrapper<Orders>()
.eq(Orders::getType,0).eq(Orders::getUseFlag,1)
.apply("DATE_FORMAT(t.order_time, '%Y-%m') = '"+params.get("year")+"-"+params.get("month")+"'")
.selectSum(Orders::getFee,"income"));
if (income!=null){
map.putAll(income);
}
return R.ok().putData("map",map);
}
}

View File

@@ -0,0 +1,46 @@
package com.zmzm.finance.common.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zmzm.finance.common.entity.SysUser;
import com.zmzm.finance.common.service.impl.SysUserServiceImpl;
import com.zmzm.finance.util.MD5Utils;
import lombok.extern.slf4j.Slf4j;
import com.zmzm.finance.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
@Slf4j
@RestController("commonSysUser")
@RequestMapping("common/sysUser")
public class SysUserController {
@Autowired
private SysUserServiceImpl sysUserService;
//用户列表
@RequestMapping("/getSysUserList")
public R getUserList(@RequestBody Map<String,Object> params){
Page<SysUser> userList = sysUserService.page(new Page<>(Long.parseLong(params.get("page").toString()),
Long.parseLong(params.get("limit").toString())));
return R.ok().putData("userList",userList);
}
//新增用户
@RequestMapping("/addSysUser")
public R addUser(@RequestBody SysUser sysUser){
long count = sysUserService.count(new LambdaQueryWrapper<SysUser>().eq(SysUser::getAccount, sysUser.getAccount()));
if(count>0){
return R.error(500,"账号已注册");
}
String saltMD5 = MD5Utils.getSaltMD5(sysUser.getPassword());
sysUser.setPassword(saltMD5);
sysUserService.save(sysUser);
return R.ok();
}
}

View File

@@ -12,7 +12,7 @@ import org.springframework.web.bind.annotation.RestController;
* @since 2025-12-10
*/
@RestController
@RequestMapping("/common/userToken")
public class UserTokenController {
@RequestMapping("/common/sysUserToken")
public class SysUserTokenController {
}

View File

@@ -4,60 +4,38 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zmzm.finance.common.entity.User;
import com.zmzm.finance.common.service.impl.UserServiceImpl;
import com.zmzm.finance.util.MD5Utils;
import lombok.extern.slf4j.Slf4j;
import com.zmzm.finance.common.entity.Customer;
import com.zmzm.finance.common.entity.WumenUser;
import com.zmzm.finance.common.service.CustomerService;
import com.zmzm.finance.common.service.WumenUserService;
import com.zmzm.finance.util.R;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
@Slf4j
@RestController("commonUser")
@RequestMapping("common/user")
/**
* <p>
* 前端控制器
* </p>
*
* @author baomidou
* @since 2026-01-05
*/
@RestController
@RequestMapping("/common/user")
public class UserController {
@Autowired
private UserServiceImpl userService;
@Autowired
private WumenUserService wumenUserService;
@Autowired
private CustomerService customerService;
//用户列表
@RequestMapping("/getUserList")
public R getUserList(@RequestBody Map<String,Object> params){
Page<User> userList = userService.page(new Page<>(Long.parseLong(params.get("page").toString()),
Long.parseLong(params.get("limit").toString())));
return R.ok().putData("userList",userList);
Page<User> page = userService.page(
new Page<>(Integer.parseInt(params.get("page").toString()), Integer.parseInt(params.get("limit").toString())),
new LambdaQueryWrapper<User>()
.gt(User::getTotalPoint,0)
.eq(StringUtils.isNotEmpty(params.get("tel").toString()),User::getTel, params.get("tel").toString()));
return R.ok().put("data", page);
}
//新增用户
@RequestMapping("/addUser")
public R addUser(@RequestBody User user){
long count = userService.count(new LambdaQueryWrapper<User>().eq(User::getAccount, user.getAccount()));
if(count>0){
return R.error(500,"账号已注册");
}
String saltMD5 = MD5Utils.getSaltMD5(user.getPassword());
user.setPassword(saltMD5);
userService.save(user);
return R.ok();
}
//测试用户
@RequestMapping("/getUser")
public R getUserContribution(){
WumenUser wumenUser = wumenUserService.getById("12301");
Customer customer = customerService.getOne(new LambdaQueryWrapper<Customer>()
.eq(Customer::getCellPhone,"15674886255"));
return R.ok().putData("customer",customer);
}
}

View File

@@ -0,0 +1,19 @@
package com.zmzm.finance.common.dao;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zmzm.finance.common.entity.FinanceOrder;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author baomidou
* @since 2025-12-24
*/
@Mapper
public interface FinanceOrderMapper extends BaseMapper<FinanceOrder> {
}

View File

@@ -0,0 +1,18 @@
package com.zmzm.finance.common.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zmzm.finance.common.entity.SysUser;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author baomidou
* @since 2025-12-10
*/
@Mapper
public interface SysUserMapper extends BaseMapper<SysUser> {
}

View File

@@ -1,7 +1,7 @@
package com.zmzm.finance.common.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zmzm.finance.common.entity.UserToken;
import com.zmzm.finance.common.entity.SysUserToken;
import org.apache.ibatis.annotations.Mapper;
/**
@@ -13,6 +13,6 @@ import org.apache.ibatis.annotations.Mapper;
* @since 2025-12-10
*/
@Mapper
public interface UserTokenMapper extends BaseMapper<UserToken> {
public interface SysUserTokenMapper extends BaseMapper<SysUserToken> {
}

View File

@@ -0,0 +1,20 @@
package com.zmzm.finance.common.dao;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zmzm.finance.common.entity.TCustomerApplyBuy;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author baomidou
* @since 2026-01-05
*/
@Mapper
@DS("yljk")
public interface TCustomerApplyBuyMapper extends BaseMapper<TCustomerApplyBuy> {
}

View File

@@ -0,0 +1,105 @@
package com.zmzm.finance.common.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author baomidou
* @since 2025-12-24
*/
@Getter
@Setter
@ToString
@TableName("finance_order")
public class FinanceOrder implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
/**
* 用户
*/
private String tel;
/**
* 商品
*/
private String productId;
/**
* 商品名称
*/
private String productName;
/**
* 商品
*/
private String courseId;
/**
* 商品名称
*/
private String catalogueId;
/**
* 订单号
*/
private String orderSn;
/**
* 来源
*/
private String come;
/**
* 订单类型0充值1vip2课3实物4培训班
*/
private Integer orderType;
/**
* 订单金额
*/
private BigDecimal orderMoney;
/**
* 优惠金额
*/
private BigDecimal districtMoney;
/**
* 实付金额
*/
private BigDecimal realMoney;
/**
* 开始时间
*/
private Date startTime;
/**
* 结束时间
*/
private Date endTime;
/**
* 备注
*/
private String remark;
/**
* 创建时间
*/
private Date createTime;
}

View File

@@ -49,6 +49,11 @@ public class Orders implements Serializable {
*/
private String tel;
/**
* 支付类型 0钱 1虚拟币
*/
private Integer payType;
/**
* 金额
*/
@@ -64,6 +69,11 @@ public class Orders implements Serializable {
*/
private Date orderTime;
/**
* 使用标志 0未使用1已使用
*/
private Integer useFlag;
/**
* 状态0初始1删除
*/

View File

@@ -0,0 +1,66 @@
package com.zmzm.finance.common.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author baomidou
* @since 2025-12-10
*/
@Getter
@Setter
@ToString
@TableName("sys_user")
public class SysUser implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键
*/
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
/**
* 用户名
*/
private String name;
/**
* 账户
*/
private String account;
/**
* 密码
*/
private String password;
/**
* 0管理员1财务
*/
private Integer role;
/**
* 最后登录时间
*/
private Date lastTime;
/**
* 状态0初始1删除
*/
@TableLogic
private Integer state;
}

View File

@@ -19,8 +19,8 @@ import java.util.Date;
@Getter
@Setter
@ToString
@TableName("user_token")
public class UserToken implements Serializable {
@TableName("sys_user_token")
public class SysUserToken implements Serializable {
private static final long serialVersionUID = 1L;

View File

@@ -0,0 +1,16 @@
package com.zmzm.finance.common.service;
import com.zmzm.finance.common.entity.FinanceOrder;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 服务类
* </p>
*
* @author baomidou
* @since 2025-12-24
*/
public interface IFinanceOrderService extends IService<FinanceOrder> {
}

View File

@@ -15,4 +15,6 @@ public interface IOrdersService extends IService<Orders> {
void importWumenOrder();
void updatePoint(Integer ordersId);
}

View File

@@ -0,0 +1,16 @@
package com.zmzm.finance.common.service;
import com.zmzm.finance.common.entity.ShopProduct;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 商品表 服务类
* </p>
*
* @author baomidou
* @since 2025-12-24
*/
public interface IShopProductService extends IService<ShopProduct> {
}

View File

@@ -0,0 +1,16 @@
package com.zmzm.finance.common.service;
import com.zmzm.finance.common.entity.SysUser;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 服务类
* </p>
*
* @author baomidou
* @since 2025-12-10
*/
public interface ISysUserService extends IService<SysUser> {
}

View File

@@ -1,6 +1,6 @@
package com.zmzm.finance.common.service;
import com.zmzm.finance.common.entity.UserToken;
import com.zmzm.finance.common.entity.SysUserToken;
import com.baomidou.mybatisplus.extension.service.IService;
/**
@@ -11,8 +11,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
* @author baomidou
* @since 2025-12-10
*/
public interface IUserTokenService extends IService<UserToken> {
public interface ISysUserTokenService extends IService<SysUserToken> {
UserToken createToken(int userId);
SysUserToken createToken(int userId);
}

View File

@@ -0,0 +1,20 @@
package com.zmzm.finance.common.service.impl;
import com.zmzm.finance.common.entity.FinanceOrder;
import com.zmzm.finance.common.dao.FinanceOrderMapper;
import com.zmzm.finance.common.service.IFinanceOrderService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author baomidou
* @since 2025-12-24
*/
@Service
public class FinanceOrderServiceImpl extends ServiceImpl<FinanceOrderMapper, FinanceOrder> implements IFinanceOrderService {
}

View File

@@ -3,6 +3,8 @@ package com.zmzm.finance.common.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import com.zmzm.finance.common.dao.BuyOrderMapper;
import com.zmzm.finance.common.dao.TCustomerApplyBuyMapper;
import com.zmzm.finance.common.dao.UserMapper;
import com.zmzm.finance.common.entity.*;
import com.zmzm.finance.common.dao.OrdersMapper;
import com.zmzm.finance.common.service.IOrdersService;
@@ -10,6 +12,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
@@ -26,10 +29,14 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, Orders> impleme
@Autowired
private BuyOrderMapper buyOrderMapper;
@Autowired
private TCustomerApplyBuyMapper customerApplyBuyMapper;
@Autowired
private UserMapper userMapper;
@Override
public void importWumenOrder() {
String oldBuyOrderId = "0";
String oldBuyOrderId = "1703";
Orders orders = this.baseMapper.selectOne(new LambdaQueryWrapper<Orders>()
.eq(Orders::getSource,1)
.orderByDesc(Orders::getId).last("limit 1"));
@@ -42,7 +49,8 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, Orders> impleme
.leftJoin(BuyOrderProduct.class,BuyOrderProduct::getOrderId,BuyOrder::getOrderId)
.leftJoin(ShopProduct.class,ShopProduct::getProductId,BuyOrderProduct::getProductId)
//支付宝需要单独查询关联号,老数据有问题
.leftJoin(PayZfbOrder.class,PayZfbOrder::getRelevanceoid,BuyOrder::getOrderSn)
.leftJoin(PayZfbOrder.class,on->on
.eq(PayZfbOrder::getRelevanceoid,BuyOrder::getOrderSn).isNotNull(PayZfbOrder::getTradeNo))
.disableSubLogicDel()
.groupBy(BuyOrder::getOrderId)
.selectAll(BuyOrder.class)
@@ -50,6 +58,7 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, Orders> impleme
.select("if(t4.trade_no is null,t.order_sn,t4.out_trade_no) as orderSn")
.selectAs(ShopProduct::getGoodsType,"goodsType")
.notIn(BuyOrder::getOrderStatus,0,5)
.gt(BuyOrder::getRealMoney,0)
.gt(BuyOrder::getOrderId,oldBuyOrderId));
List<Orders> os = new ArrayList<>();
for (BuyOrder bo : bos) {
@@ -58,6 +67,11 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, Orders> impleme
o.setOrderSn(bo.getOrderSn());
o.setOrderOldId(bo.getOrderId()+"");
o.setTel(bo.getTel());
if ("4".equals(bo.getPaymentMethod())){
o.setPayType(1);
}else {
o.setPayType(0);
}
o.setFee(bo.getRealMoney());
if ("point".equals(bo.getOrderType())){
o.setType(0);
@@ -84,4 +98,29 @@ public class OrdersServiceImpl extends ServiceImpl<OrdersMapper, Orders> impleme
this.baseMapper.insert(os);
}
@Override
public void updatePoint(Integer ordersId) {
Orders orders = this.baseMapper.selectById(ordersId);
if (orders.getType()==0){
BigDecimal point = BigDecimal.ZERO;
if (orders.getSource()==0){//一路健康
TCustomerApplyBuy applyBuy = customerApplyBuyMapper.selectById(orders.getOrderOldId());
point = BigDecimal.valueOf(applyBuy.getConvertpoint());
}else {
point = orders.getFee();
}
User user = userMapper.selectOne(new LambdaQueryWrapper<User>()
.eq(User::getTel,orders.getTel()));
if (user==null){
user = new User();
user.setTel(orders.getTel());
user.setTotalPoint(BigDecimal.ZERO);
user.setPoint(BigDecimal.ZERO);
}
user.setTotalPoint(user.getTotalPoint().add(point));
user.setPoint(user.getPoint().add(point));
userMapper.insertOrUpdate(user);
}
}
}

View File

@@ -0,0 +1,20 @@
package com.zmzm.finance.common.service.impl;
import com.zmzm.finance.common.entity.ShopProduct;
import com.zmzm.finance.common.dao.ShopProductMapper;
import com.zmzm.finance.common.service.IShopProductService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 商品表 服务实现类
* </p>
*
* @author baomidou
* @since 2025-12-24
*/
@Service
public class ShopProductServiceImpl extends ServiceImpl<ShopProductMapper, ShopProduct> implements IShopProductService {
}

View File

@@ -0,0 +1,20 @@
package com.zmzm.finance.common.service.impl;
import com.zmzm.finance.common.entity.SysUser;
import com.zmzm.finance.common.dao.SysUserMapper;
import com.zmzm.finance.common.service.ISysUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author baomidou
* @since 2025-12-10
*/
@Service
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> implements ISysUserService {
}

View File

@@ -0,0 +1,40 @@
package com.zmzm.finance.common.service.impl;
import com.zmzm.finance.common.entity.SysUserToken;
import com.zmzm.finance.common.dao.SysUserTokenMapper;
import com.zmzm.finance.common.service.ISysUserTokenService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zmzm.finance.util.TokenGenerator;
import org.springframework.stereotype.Service;
import java.util.Date;
/**
* <p>
* 用户token 服务实现类
* </p>
*
* @author baomidou
* @since 2025-12-10
*/
@Service
public class SysUserTokenServiceImpl extends ServiceImpl<SysUserTokenMapper, SysUserToken> implements ISysUserTokenService {
@Override
public SysUserToken createToken(int userId) {
String token = TokenGenerator.generateValue();
Date now = new Date();
Date expireTime = new Date(now.getTime() + 3600 * 3 * 1000);
//判断是否生成过token
SysUserToken sysUserToken = this.getById(userId);
if (sysUserToken == null) {
sysUserToken = new SysUserToken();
sysUserToken.setUserId(userId);
}
sysUserToken.setExpireTime(expireTime);
sysUserToken.setToken(token);
sysUserToken.setUpdateTime(now);
this.saveOrUpdate(sysUserToken);
return sysUserToken;
}
}

View File

@@ -1,40 +0,0 @@
package com.zmzm.finance.common.service.impl;
import com.zmzm.finance.common.entity.UserToken;
import com.zmzm.finance.common.dao.UserTokenMapper;
import com.zmzm.finance.common.service.IUserTokenService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zmzm.finance.util.TokenGenerator;
import org.springframework.stereotype.Service;
import java.util.Date;
/**
* <p>
* 用户token 服务实现类
* </p>
*
* @author baomidou
* @since 2025-12-10
*/
@Service
public class UserTokenServiceImpl extends ServiceImpl<UserTokenMapper, UserToken> implements IUserTokenService {
@Override
public UserToken createToken(int userId) {
String token = TokenGenerator.generateValue();
Date now = new Date();
Date expireTime = new Date(now.getTime() + 3600 * 3 * 1000);
//判断是否生成过token
UserToken userToken = this.getById(userId);
if (userToken == null) {
userToken = new UserToken();
userToken.setUserId(userId);
}
userToken.setExpireTime(expireTime);
userToken.setToken(token);
userToken.setUpdateTime(now);
this.saveOrUpdate(userToken);
return userToken;
}
}

View File

@@ -1,10 +1,10 @@
package com.zmzm.finance.config;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zmzm.finance.common.entity.User;
import com.zmzm.finance.common.entity.UserToken;
import com.zmzm.finance.common.service.IUserService;
import com.zmzm.finance.common.service.IUserTokenService;
import com.zmzm.finance.common.entity.SysUser;
import com.zmzm.finance.common.entity.SysUserToken;
import com.zmzm.finance.common.service.ISysUserService;
import com.zmzm.finance.common.service.ISysUserTokenService;
import org.apache.shiro.authc.*;
import org.apache.shiro.authz.AuthorizationInfo;
import org.apache.shiro.authz.SimpleAuthorizationInfo;
@@ -12,16 +12,15 @@ import org.apache.shiro.realm.AuthorizingRealm;
import org.apache.shiro.subject.PrincipalCollection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
@Component
public class CustomRealm extends AuthorizingRealm {
@Autowired
private IUserService userService;
private ISysUserService sysUserService;
@Autowired
private IUserTokenService userTokenService;
private ISysUserTokenService sysUserTokenService;
@Override
public boolean supports(AuthenticationToken token) {
@@ -31,7 +30,7 @@ public class CustomRealm extends AuthorizingRealm {
@Override
protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
String account = (String) principals.getPrimaryPrincipal();
User user = userService.getOne(new LambdaQueryWrapper<User>().eq(User::getAccount, account));
SysUser sysUser = sysUserService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getAccount, account));
SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
// info.addRoles(user.getRole());
return info;
@@ -41,23 +40,24 @@ public class CustomRealm extends AuthorizingRealm {
protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken token)
throws AuthenticationException {
String accessToken = token.getPrincipal().toString();
UserToken userToken = userTokenService.getOne(new LambdaQueryWrapper<UserToken>()
.eq(UserToken::getToken, accessToken));
SysUserToken sysUserToken = sysUserTokenService.getOne(new LambdaQueryWrapper<SysUserToken>()
.eq(SysUserToken::getToken, accessToken));
//token失效
if(userToken == null || userToken.getExpireTime().getTime() < System.currentTimeMillis()){
if(sysUserToken == null || sysUserToken.getExpireTime().getTime() < System.currentTimeMillis()){
throw new IncorrectCredentialsException("token失效请重新登录");
}
User user = userService.getById(userToken.getUserId());
SysUser user = sysUserService.getById(sysUserToken.getUserId());
SysUser sysUser = sysUserService.getById(1);
if (user == null) throw new UnknownAccountException();
Long timeout = (userToken.getExpireTime().getTime() - System.currentTimeMillis())/(1000 * 60 * 60);
Long timeout = (sysUserToken.getExpireTime().getTime() - System.currentTimeMillis())/(1000 * 60 * 60);
if (timeout <= 1){
// token 续期
Date now = new Date();
Date expireTime = new Date(now.getTime() + (3600 * 3 * 1000) );
userToken.setExpireTime(expireTime);
userTokenService.updateById(userToken);
sysUserToken.setExpireTime(expireTime);
sysUserTokenService.updateById(sysUserToken);
}
return new SimpleAuthenticationInfo(user, token.getCredentials(), getName());
return new SimpleAuthenticationInfo(sysUser, token.getCredentials(), getName());
}
}

View File

@@ -6,21 +6,23 @@ import java.sql.*;
public class DataUtil {
public static void main(String[] args){
// insertOrder();
// goods();
// course();
// mtRegister();
//吴门医述得在自动同步方法里
point();
goods();
course();
mtRegister();
}
public static void mtRegister(){
try {
Connection yljkConn = DriverManager.getConnection(
"jdbc:mysql://goldorchid.mysql.rds.aliyuncs.com:3309/everhealth?",
"yljkmaster", "Wu751019!@");
Connection financeConn = DriverManager.getConnection(
"jdbc:mysql://rm-2zev4157t67trxuu3yo.mysql.rds.aliyuncs.com:3306/finance?rewriteBatchedStatements=true",
"jdbc:mysql://rm-2zev4157t67trxuu3yo.mysql.rds.aliyuncs.com:3306/finance_test?rewriteBatchedStatements=true",
"nuttyreading", "Wu751019!");
PreparedStatement transactionDetailStatement = financeConn.prepareStatement(
"INSERT ignore INTO orders (source,order_sn,order_old_id,tel,fee,type,order_time) VALUES (?, ?, ?, ?, ?, ?, ?)");
"INSERT ignore INTO orders (source,order_sn,order_old_id,tel,fee,type,order_time,pay_type) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
PreparedStatement statement = yljkConn.prepareStatement("select m.*,IF(m.point>0,m.point,m.money) fee,c.cellPhone " +
"from t_customer_apply_mtregister m " +
"left join t_customer c on c.oid = m.customerOid " +
@@ -36,6 +38,11 @@ public class DataUtil {
transactionDetailStatement.setBigDecimal(5,resultSet.getBigDecimal("fee"));
transactionDetailStatement.setInt(6,4);
transactionDetailStatement.setTimestamp(7,resultSet.getTimestamp("createDate"));
if (resultSet.getBigDecimal("money").compareTo(BigDecimal.ZERO)==0){
transactionDetailStatement.setInt(8,1);
}else {
transactionDetailStatement.setInt(8,0);
}
transactionDetailStatement.addBatch();
if(i%3000==0){
System.out.println("----"+i+"完成");
@@ -55,10 +62,10 @@ public class DataUtil {
"jdbc:mysql://goldorchid.mysql.rds.aliyuncs.com:3309/everhealth?",
"yljkmaster", "Wu751019!@");
Connection financeConn = DriverManager.getConnection(
"jdbc:mysql://rm-2zev4157t67trxuu3yo.mysql.rds.aliyuncs.com:3306/finance?rewriteBatchedStatements=true",
"jdbc:mysql://rm-2zev4157t67trxuu3yo.mysql.rds.aliyuncs.com:3306/finance_test?rewriteBatchedStatements=true",
"nuttyreading", "Wu751019!");
PreparedStatement transactionDetailStatement = financeConn.prepareStatement(
"INSERT ignore INTO orders (source,order_sn,order_old_id,tel,fee,type,order_time) VALUES (?, ?, ?, ?, ?, ?, ?)");
"INSERT ignore INTO orders (source,order_sn,order_old_id,tel,fee,type,order_time,pay_type) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
PreparedStatement statement = yljkConn.prepareStatement("select ac.* ,IF(ac.point>0,ac.point,ac.money) fee,c.cellPhone " +
"from t_customer_apply_curriculum ac " +
"left join t_customer c on c.oid = ac.customerOid " +
@@ -74,6 +81,11 @@ public class DataUtil {
transactionDetailStatement.setBigDecimal(5,resultSet.getBigDecimal("fee"));
transactionDetailStatement.setInt(6,2);
transactionDetailStatement.setTimestamp(7,resultSet.getTimestamp("createDate"));
if (resultSet.getBigDecimal("money").compareTo(BigDecimal.ZERO)==0){
transactionDetailStatement.setInt(8,1);
}else {
transactionDetailStatement.setInt(8,0);
}
transactionDetailStatement.addBatch();
if(i%3000==0){
System.out.println("----"+i+"完成");
@@ -93,10 +105,10 @@ public class DataUtil {
"jdbc:mysql://goldorchid.mysql.rds.aliyuncs.com:3309/everhealth?",
"yljkmaster", "Wu751019!@");
Connection financeConn = DriverManager.getConnection(
"jdbc:mysql://rm-2zev4157t67trxuu3yo.mysql.rds.aliyuncs.com:3306/finance?rewriteBatchedStatements=true",
"jdbc:mysql://rm-2zev4157t67trxuu3yo.mysql.rds.aliyuncs.com:3306/finance_test?rewriteBatchedStatements=true",
"nuttyreading", "Wu751019!");
PreparedStatement transactionDetailStatement = financeConn.prepareStatement(
"INSERT ignore INTO orders (source,order_sn,order_old_id,tel,fee,type,order_time) VALUES (?, ?, ?, ?, ?, ?, ?)");
"INSERT ignore INTO orders (source,order_sn,order_old_id,tel,fee,type,order_time,pay_type) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
PreparedStatement statement = yljkConn.prepareStatement("select co.*,IF(co.point>0,co.point,co.money) fee,c.cellPhone " +
"from t_customer_commodity_order co " +
"left join t_customer c on c.oid = co.customerOid " +
@@ -112,6 +124,11 @@ public class DataUtil {
transactionDetailStatement.setBigDecimal(5,resultSet.getBigDecimal("fee"));
transactionDetailStatement.setInt(6,3);
transactionDetailStatement.setTimestamp(7,resultSet.getTimestamp("createDate"));
if (resultSet.getBigDecimal("money").compareTo(BigDecimal.ZERO)==0){
transactionDetailStatement.setInt(8,1);
}else {
transactionDetailStatement.setInt(8,0);
}
transactionDetailStatement.addBatch();
if(i%3000==0){
System.out.println("----"+i+"完成");
@@ -125,20 +142,20 @@ public class DataUtil {
System.out.println("Error: " + e.getMessage());
}
}
public static void insertOrder(){
public static void point(){
try {
Connection yljkConn = DriverManager.getConnection(
"jdbc:mysql://goldorchid.mysql.rds.aliyuncs.com:3309/everhealth?",
"yljkmaster", "Wu751019!@");
Connection financeConn = DriverManager.getConnection(
"jdbc:mysql://rm-2zev4157t67trxuu3yo.mysql.rds.aliyuncs.com:3306/finance?rewriteBatchedStatements=true",
"jdbc:mysql://rm-2zev4157t67trxuu3yo.mysql.rds.aliyuncs.com:3306/finance_test?rewriteBatchedStatements=true",
"nuttyreading", "Wu751019!");
PreparedStatement transactionDetailStatement = financeConn.prepareStatement(
"INSERT ignore INTO orders (source,order_sn,order_old_id,tel,fee,type,order_time) VALUES (?, ?, ?, ?, ?, ?, ?)");
"INSERT ignore INTO orders (source,order_sn,order_old_id,tel,fee,type,order_time,pay_type) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
PreparedStatement statement = yljkConn.prepareStatement("select ab.*,c.cellPhone " +
"from t_customer_apply_buy ab " +
"left join t_customer c on c.oid = ab.customerOid " +
"where ab.valid = 1 and ab.status = 50 and ab.payMode in ('1','5','01','05') and ab.money>0 ");
"where ab.valid = 1 and ab.status = 50 and ab.payMode in ('1','5','01','05','ios') and ab.money>0 ");
ResultSet resultSet = statement.executeQuery();
int i=0;
while(resultSet.next()){
@@ -150,6 +167,7 @@ public class DataUtil {
transactionDetailStatement.setBigDecimal(5,resultSet.getBigDecimal("money"));
transactionDetailStatement.setInt(6,0);
transactionDetailStatement.setTimestamp(7,resultSet.getTimestamp("createDate"));
transactionDetailStatement.setInt(8,0);
transactionDetailStatement.addBatch();
if(i%3000==0){
System.out.println("----"+i+"完成");

View File

@@ -1,6 +1,6 @@
package com.zmzm.finance.util;
import com.zmzm.finance.common.entity.User;
import com.zmzm.finance.common.entity.SysUser;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.Subject;
@@ -20,8 +20,8 @@ public class ShiroUtils {
return SecurityUtils.getSubject();
}
public static User getUserEntity() {
return (User)SecurityUtils.getSubject().getPrincipal();
public static SysUser getUserEntity() {
return (SysUser)SecurityUtils.getSubject().getPrincipal();
}
public static Integer getUserId() {

View File

@@ -7,6 +7,9 @@ spring:
multipart:
max-file-size: 1000MB
max-request-size: 1000MB
jackson:
time-zone: GMT+8
date-format: yyyy-MM-dd HH:mm:ss
datasource:
type: com.alibaba.druid.pool.DruidDataSource
druid: