This commit is contained in:
2025-04-09 09:58:39 +08:00
parent 6e1304996e
commit 182f2a1906
80 changed files with 13980 additions and 410 deletions
@@ -132,7 +132,7 @@ public class WebsiteController extends BaseController {
// 读取会员信息
if(access_token != null){
// 请求主服务器获取租户信息
String result = HttpRequest.get("https://server.gxwebsoft.com/api/auth/user")
String result = HttpRequest.get("https://gxtyzx-server.websoft.top/api/auth/user")
.header("Authorization", access_token)
.header("Tenantid", tenantId.toString())
.timeout(20000)//超时,毫秒
@@ -179,7 +179,7 @@ public class WebsiteController extends BaseController {
private void createWebsite(String access_token) {
final Integer tenantId = getTenantId();
// 请求主服务器获取租户信息
String result = HttpRequest.get("https://server.gxwebsoft.com/api/auth/tenant")
String result = HttpRequest.get("https://gxtyzx-server.websoft.top/api/auth/tenant")
.header("Authorization", access_token)
.header("Tenantid", tenantId.toString())
.timeout(20000)//超时,毫秒
@@ -57,7 +57,7 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter {
map.put("username", jwtSubject.getUsername());
map.put("tenantId", jwtSubject.getTenantId());
// 链式构建请求
String result = HttpRequest.post("https://server.gxwebsoft.com/api/auth/user")
String result = HttpRequest.post("https://gxtyzx-server.websoft.top/api/auth/user")
.header("Authorization", access_token)
.header("Tenantid", jwtSubject.getTenantId().toString())
.body(JSONUtil.toJSONString(map))//表单内容
@@ -76,8 +76,10 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
"/api/think/think-deposit/refund-notify",
"/api/think/think-machine-open-log",
"/api/think/think-order/check-code",
"/api/think/think-order/check-code-only",
"/api/think/think-vip-cards-bills/make-bill",
"/api/think/think-cards-bills/make-bill"
"/api/think/think-cards-bills/make-bill",
"/api/think/think-recharge-log/refund-notify"
)
.permitAll()
.anyRequest()
@@ -42,7 +42,7 @@ public class FileServerUtil {
File outFile = getUploadFile(file.getOriginalFilename(), directory, uuidName);
if (!outFile.getParentFile().exists()) {
if (!outFile.getParentFile().mkdirs()) {
throw new RuntimeException("make directory fail");
throw new RuntimeException("make directory fail: " + outFile.getParentFile());
}
}
file.transferTo(outFile);
@@ -15,7 +15,7 @@ import java.util.HashMap;
@Component
public class RequestUtil {
private static final String host = "https://server.gxwebsoft.com/api";
private static final String host = "https://gxtyzx-server.websoft.top/api";
private static String ACCESS_TOKEN;
private static String TENANT_ID;
@@ -183,7 +183,7 @@ public class SignCheckUtil {
return true;
}
// 服务器域名白名单列表
whiteDomains.add("server.gxwebsoft.com");
whiteDomains.add("gxtyzx-server.websoft.top");
System.out.println("whiteDomains = " + whiteDomains);
System.out.println(">>> domainName = " + domainName);
for(String item: whiteDomains){
@@ -72,7 +72,7 @@ public class WxOfficialUtil {
}
public String getCodeUrl() throws UnsupportedEncodingException {
String encodedReturnUrl = URLEncoder.encode("https://server.gxwebsoft.com/api/open/wx-official/accessToken","UTF-8");
String encodedReturnUrl = URLEncoder.encode("https://gxtyzx-server.websoft.top/api/open/wx-official/accessToken","UTF-8");
return "https://open.weixin.qq.com/connect/oauth2/authorize?appid="+ this.appId +"&redirect_uri=" + encodedReturnUrl + "&response_type=code&scope=snsapi_userinfo&state="+ this.tenantId +"#wechat_redirect";
}
@@ -50,6 +50,8 @@ public class User implements UserDetails {
@ApiModelProperty("头像")
private String avatar;
private String limitSite;
@ApiModelProperty("头像")
private String bgImage;
@@ -0,0 +1,196 @@
package com.gxwebsoft.think.controller;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.symmetric.SymmetricAlgorithm;
import cn.hutool.crypto.symmetric.SymmetricCrypto;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.gxwebsoft.common.core.utils.RedisUtil;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.think.entity.*;
import com.gxwebsoft.think.service.*;
import com.yly.print_sdk_library.RequestMethod;
import com.yly.print_sdk_library.UtilUrl;
import com.yly.print_sdk_library.Utils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
@Api(tags = "打印")
@RestController
@RequestMapping("/api/print")
public class PrinterController extends BaseController {
@Resource
private ThinkOrderService thinkOrderService;
@Resource
private ThinkSiteService thinkSiteService;
@Resource
private ThinkCardService thinkCardService;
@Resource
private ThinkUsersVipService thinkUsersVipService;
@Resource
private ThinkOrderInfoService thinkOrderInfoService;
private String client_id = "1070543699";
private String client_secret = "e7efb077f7e3d986cc690f8cf5586522";
@Resource
private RedisUtil redisUtil;
@PostMapping()
public ApiResult<?> print(@RequestBody Map<String, Object> body) throws Exception {
String[] payType = {
"",
"微信支付",
"积分",
"支付宝",
"现金",
"POS机",
"VIP月卡",
"VIP年卡",
"VIP次卡",
"IC月卡",
"IC年卡",
"IC次卡",
"免费",
"VIP充值卡",
"IC充值卡",
"积分支付",
"VIP季卡",
"IC季卡"
};
ThinkOrder thinkOrder = thinkOrderService.getById((Integer) body.get("orderId"));
ThinkSite thinkSite = thinkSiteService.getById(thinkOrder.getSid());
if (thinkSite.getMachineCode() == null || thinkSite.getMachineCode().isEmpty()) return fail("未配置打印机");
DateTime dateTime = DateUtil.date((thinkOrder.getCreateTime() * 1000L));
String createTime = DateUtil.format(dateTime, "yyyy-MM-dd HH:mm:ss");
String startTime = DateUtil.format(DateUtil.date((Long.parseLong(thinkOrder.getStartTime()) * 1000L)), "yyyy-MM-dd HH:mm:ss");
String payTime = "";
if (thinkOrder.getPayTime() != null && thinkOrder.getPayTime() != 0) {
payTime = DateUtil.format(DateUtil.date((thinkOrder.getPayTime() * 1000L)), "yyyy-MM-dd HH:mm:ss");
}
String name = thinkOrder.getName().charAt(0) + StrUtil.repeat("*", thinkOrder.getName().length() - 1);
String cardName = "";
String cardExpired = "";
BigDecimal remainAmount = BigDecimal.ZERO;
int remainNum = 0;
if (thinkOrder.getCid() != null && thinkOrder.getCid() != 0) {
ThinkCard thinkCard = thinkCardService.getById(thinkOrder.getCid());
cardName = thinkCard.getName();
remainAmount = thinkCard.getRemainingMoney();
remainNum = thinkCard.getNum();
cardExpired = DateUtil.format(DateUtil.date((thinkCard.getExpireTime() * 1000L)), "yyyy-MM-dd HH:mm:ss");
}
if (thinkOrder.getVid() != null && thinkOrder.getVid() != 0) {
ThinkUsersVip thinkUsersVip = thinkUsersVipService.getById(thinkOrder.getVid());
cardName = thinkUsersVip.getName();
remainAmount = thinkUsersVip.getRemainingMoney();
remainNum = thinkUsersVip.getNum();
cardExpired = DateUtil.format(DateUtil.date((thinkUsersVip.getExpireTime() * 1000L)), "yyyy-MM-dd HH:mm:ss");
}
StringBuilder content = new StringBuilder("<FS2><center>" + thinkSite.getName() + "</center></FS2>");
content.append("<FS><center>场租账单</center></FS>");
content.append(StrUtil.repeat("-", 32));
content.append("开始时间: ").append(startTime).append("\n");
content.append("支付时间: ").append(payTime).append("\n");
content.append("订单编号: ").append(thinkOrder.getOrderNum()).append("\n");
content.append("微信订单号: ").append(thinkOrder.getWechatOrder() == null ? "" : thinkOrder.getWechatOrder()).append("\n");
content.append("姓名: ").append(name).append("\n");
if (!cardName.isEmpty()) {
content.append("卡类型: ").append(cardName).append("\n");
content.append("有效期: ").append(cardExpired).append("\n");
}
if (thinkSite.getId().equals(37)) {
String secretKey = redisUtil.get("secretKey_10150");
byte[] key = null;
if (secretKey == null) {
key = SecureUtil.generateKey(SymmetricAlgorithm.AES.getValue()).getEncoded();
redisUtil.set("secretKey_10150", Base64.getEncoder().encodeToString(key));
} else {
key = Base64.getDecoder().decode(secretKey);
}
SymmetricCrypto aes = new SymmetricCrypto(SymmetricAlgorithm.AES, key);
long timestamp = (int) (System.currentTimeMillis() / 1000);
String qr = aes.encryptHex(thinkOrder.getId() + "_" + timestamp + "_none_forDevice");
content.append("<QR2>06,").append(qr).append("</QR2>");
}
content.append(StrUtil.repeat("-", 32));
content.append("<table>");
content.append("<tr><td>项目</td><td>数量</td><td>金额</td></tr>");
List<ThinkOrderInfo> thinkOrderInfoList = thinkOrderInfoService.listInOrder(thinkOrder.getId());
for (ThinkOrderInfo thinkOrderInfo : thinkOrderInfoList) {
String date = DateUtil.format(DateUtil.date((thinkOrderInfo.getStartTime() * 1000L)), "yyyy-MM-dd");
String[] dateTimeList = thinkOrderInfo.getDateTime().split("\\)");
content.append("<tr><td>")
.append(thinkOrderInfo.getFieldName())
.append("\n")
.append(date)
.append("\n")
.append(dateTimeList[1])
.append("</td><td>")
.append(thinkOrderInfo.getAdultNum()).append("</td><td>")
.append(thinkOrderInfo.getPrice()).append("</td></tr>");
}
content.append("</table>");
content.append(StrUtil.repeat("-", 32));
content.append("消费金额: ").append(thinkOrder.getTotalPrice()).append("\n");
content.append("付款方式: ").append(thinkOrder.getPayType() > 0 ? payType[thinkOrder.getPayType()] : "").append("\n");
if (remainAmount != null) {
content.append("剩余金额: ").append(remainAmount).append("\n");
content.append("剩余次数: ").append(remainNum).append("\n");
}
content.append("备注: ").append(thinkOrder.getDesc() == null ? "" : thinkOrder.getDesc()).append("\n");
content.append("操作员: ").append("\n");
content.append("下单时间: ").append(createTime).append("\n");
content.append(StrUtil.repeat("-", 32));
content.append("<center>").append(thinkSite.getTel()).append("</center>").append("\n");
content.append("<center>提示:完成的订单不给予退票,入场前请谨慎使用</center>").append("\n");
print(thinkSite.getMachineCode(), content.toString());
return success();
}
private void print(String machineCode, String content) throws Exception {
RequestMethod requestMethod = RequestMethod.getInstance();
requestMethod.init(client_id, client_secret);
String token = getToken();
String res = requestMethod.printIndex(token, machineCode, content, RandomUtil.randomString(32));
System.out.println(res);
}
private void printWithQr(String machineCode, String pic) throws Exception {
RequestMethod requestMethod = RequestMethod.getInstance();
requestMethod.init(client_id, client_secret);
String token = getToken();
String res = requestMethod.picturePrintIndex(token, machineCode, pic, RandomUtil.randomString(32));
System.out.println(res);
}
private String getToken() throws Exception {
String token;
if (redisUtil.get("printerToken") == null) {
RequestMethod requestMethod = RequestMethod.getInstance();
requestMethod.init(client_id, client_secret);
JSONObject resObj = JSONUtil.parseObj(requestMethod.getAccessToken());
if (resObj.getInt("error") != 0) throw new Exception(resObj.getStr("error_description"));
JSONObject body = JSONUtil.parseObj(resObj.getStr("body"));
token = body.getStr("access_token");
redisUtil.set("printerToken", token);
} else token = redisUtil.get("printerToken");
return token;
}
}
@@ -1,10 +1,13 @@
package com.gxwebsoft.think.controller;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.think.entity.ThinkOrder;
import com.gxwebsoft.think.entity.ThinkOrderInfo;
import com.gxwebsoft.think.entity.ThinkSite;
import com.gxwebsoft.think.service.ThinkOrderInfoService;
import com.gxwebsoft.think.service.ThinkOrderService;
import com.gxwebsoft.think.service.ThinkSiteService;
import io.swagger.annotations.Api;
@@ -14,6 +17,8 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
/**
* 定时任务
@@ -31,17 +36,32 @@ public class SchedulingController extends BaseController {
private ThinkOrderService thinkOrderService;
@Resource
private ThinkSiteService thinkSiteService;
@Resource
private ThinkOrderInfoService thinkOrderInfoService;
@Scheduled(cron = "* * * * * *")
public void task() {
// 15分钟取消订单
thinkOrderService.update(
List<ThinkOrder> orderList = thinkOrderService.list(
new LambdaUpdateWrapper<ThinkOrder>()
.set(ThinkOrder::getOrderStatus, 3)
.eq(ThinkOrder::getPayStatus, 2)
.eq(ThinkOrder::getOrderStatus, 2)
.apply("UNIX_TIMESTAMP() > `create_time` + " + 15 * 60)
);
if (!orderList.isEmpty()) {
List<ThinkOrderInfo> orderInfoList = new ArrayList<>();
for (ThinkOrder thinkOrder : orderList) {
thinkOrder.setOrderStatus(3);
List<ThinkOrderInfo> orderInfoListTmp = thinkOrderInfoService.listInOrder(thinkOrder.getId());
orderInfoList.addAll(orderInfoListTmp);
thinkOrder.setUpdateTime(System.currentTimeMillis() / 1000);
}
for (ThinkOrderInfo thinkOrderInfo : orderInfoList) {
thinkOrderInfo.setPayStatus(0);
}
thinkOrderService.updateBatchById(orderList);
thinkOrderInfoService.updateBatchById(orderInfoList);
}
//每天0点清空人数
if (DateUtil.format(LocalDateTime.now(), "HH:mm:ss").equals("00:00:00")) {
@@ -51,6 +71,29 @@ public class SchedulingController extends BaseController {
);
}
// 每天21:30后核销游泳馆订单
if (DateUtil.format(LocalDateTime.now(), "HH:mm:ss").equals("21:30:10")) {
// 今天0点时间戳
final long dayStart = DateUtil.beginOfDay(DateUtil.date()).getTime() / 1000;
List<ThinkOrderInfo> orderInfoList = thinkOrderInfoService.list(
new LambdaQueryWrapper<ThinkOrderInfo>()
.select(ThinkOrderInfo::getOid)
.eq(ThinkOrderInfo::getSid, 37)
.eq(ThinkOrderInfo::getPayStatus, 1)
.between(ThinkOrderInfo::getStartTime, dayStart, (int) (System.currentTimeMillis() / 1000))
);
if (!orderInfoList.isEmpty()) {
List<Integer> orderIdList = orderInfoList.stream().map(ThinkOrderInfo::getOid).toList();
thinkOrderService.update(
new LambdaUpdateWrapper<ThinkOrder>()
.in(ThinkOrder::getId, orderIdList)
.eq(ThinkOrder::getOrderStatus, 2)
.eq(ThinkOrder::getPayStatus, 1)
.set(ThinkOrder::getOrderStatus, 1)
);
}
}
}
}
@@ -10,15 +10,9 @@ import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.system.entity.User;
import com.gxwebsoft.think.entity.ThinkCard;
import com.gxwebsoft.think.entity.ThinkUsers;
import com.gxwebsoft.think.entity.ThinkVip;
import com.gxwebsoft.think.entity.ThinkVipCardsBills;
import com.gxwebsoft.think.entity.*;
import com.gxwebsoft.think.param.ThinkCardParam;
import com.gxwebsoft.think.service.ThinkCardBindLogService;
import com.gxwebsoft.think.service.ThinkCardService;
import com.gxwebsoft.think.service.ThinkVipCardsBillsService;
import com.gxwebsoft.think.service.ThinkVipService;
import com.gxwebsoft.think.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -29,7 +23,9 @@ import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* 控制器
@@ -49,6 +45,8 @@ public class ThinkCardController extends BaseController {
private ThinkVipService thinkVipService;
@Resource
private ThinkVipCardsBillsService thinkVipCardsBillsService;
@Resource
private ThinkSiteService thinkSiteService;
@ApiOperation("用户卡")
@PostMapping("/user-card")
@@ -57,6 +55,7 @@ public class ThinkCardController extends BaseController {
if (getLoginUser() == null) return fail("请先登录");
ThinkUsers thinkUsers = new ThinkUsers();
thinkUsers.setId(getLoginUser().getUid());
thinkUsers.setPhone(getLoginUser().getPhone());
return success(thinkCardService.userCard(thinkUsers));
}
@@ -74,12 +73,18 @@ public class ThinkCardController extends BaseController {
return success(thinkCardService.listRel(param));
}
@PreAuthorize("hasAuthority('think:thinkCard:list')")
@ApiOperation("根据id查询")
@GetMapping("/{id}")
public ApiResult<ThinkCard> get(@PathVariable("id") Integer id) {
// 使用关联查询
return success(thinkCardService.getByIdRel(id));
ThinkCard thinkCard = thinkCardService.getByIdRel(id);
thinkCard.setSiteList(thinkSiteService.listByIds(Arrays.stream(thinkCard.getSid().split(",")).map(Integer::valueOf).toList()));
if (thinkCard.getOriginCardCode() != null) {
thinkCard.setOldCard(thinkCardService.getByCode(thinkCard.getOriginCardCode()));
}
ThinkCard newCard = thinkCardService.getByOriginCode(thinkCard.getCode());
if (newCard != null) thinkCard.setNewCard(newCard);
return success(thinkCard);
}
@ApiOperation("批量生成")
@@ -168,12 +173,48 @@ public class ThinkCardController extends BaseController {
@ApiOperation("添加")
@PostMapping()
public ApiResult<?> save(@RequestBody ThinkCard thinkCard) {
ThinkCard exist = thinkCardService.getByCode(thinkCard.getCode());
if (exist != null) {
return fail("序列号已存在");
}
ThinkCard existByCardNum = thinkCardService.getByCardNum(thinkCard.getCardNum());
if (existByCardNum != null) {
return fail("卡号已存在");
}
if (thinkCard.getCode() == null) thinkCard.setCode(RandomUtil.randomString(8));
ThinkVip thinkVip = thinkVipService.getById(thinkCard.getVid());
if (thinkVip.getMode().equals(0))
thinkCard.setExpireTime(DateUtil.currentSeconds() + (thinkCard.getTerm() * 86400 * 365) + (thinkCard.getMonth() * 86400 * 30));
else{
long time = DateUtil.parse(thinkVip.getExpiredTime(), "yyyy-MM-dd").getTime();
thinkCard.setExpireTime(time / 1000);
}
thinkCard.setCreateTime(DateUtil.currentSeconds());
thinkCard.setUpdateTime(DateUtil.currentSeconds());
if (thinkCardService.save(thinkCard)) {
return success("添加成功");
return success("添加成功", thinkCard.getId());
}
return fail("添加失败");
}
@ApiOperation("付款码支付")
@PostMapping("/codePay/{id}")
public ApiResult<?> codePay(@PathVariable Integer id, @RequestBody Map<String, String> data) {
ThinkCard thinkCard = thinkCardService.getById(id);
String desc = thinkCard.getName();
Map<String, String> res = thinkCardService.createWxCodePay(thinkCard.getPrice(), thinkCard.getCode(), desc, data.get("code"));
return success(res);
}
@ApiOperation("订单状态查询")
@PostMapping("/checkWechatPayRes/{id}")
public ApiResult<?> checkWechatPayRes(@PathVariable Integer id) {
ThinkCard thinkCard = thinkCardService.getById(id);
Map<String, String> res = thinkCardService.checkWechatPayRes(thinkCard.getCode());
return success(res);
}
@ApiOperation("修改")
@PutMapping()
public ApiResult<?> update(@RequestBody ThinkCard thinkCard) {
@@ -1,6 +1,8 @@
package com.gxwebsoft.think.controller;
import cn.hutool.core.date.DateUtil;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.think.entity.ThinkCard;
import com.gxwebsoft.think.service.ThinkCardLogService;
import com.gxwebsoft.think.entity.ThinkCardLog;
import com.gxwebsoft.think.param.ThinkCardLogParam;
@@ -10,12 +12,14 @@ import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.annotation.OperationLog;
import com.gxwebsoft.common.system.entity.User;
import com.gxwebsoft.think.service.ThinkCardService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
@@ -30,12 +34,14 @@ import java.util.List;
public class ThinkCardLogController extends BaseController {
@Resource
private ThinkCardLogService thinkCardLogService;
@Resource
private ThinkCardService thinkCardService;
@ApiOperation("分页查询")
@GetMapping("/page")
public ApiResult<PageResult<ThinkCardLog>> page(ThinkCardLogParam param) {
public ApiResult<PageResult<ThinkCardLog>> page(ThinkCardLogParam param, HttpServletRequest request) {
// 使用关联查询
return success(thinkCardLogService.pageRel(param));
return success(thinkCardLogService.pageRel(param, request));
}
@ApiOperation("查询全部")
@@ -56,7 +62,33 @@ public class ThinkCardLogController extends BaseController {
@ApiOperation("添加")
@PostMapping()
public ApiResult<?> save(@RequestBody ThinkCardLog thinkCardLog) {
thinkCardLog.setAid(getLoginUserId());
if (thinkCardLogService.save(thinkCardLog)) {
ThinkCard thinkCard = thinkCardService.getByCode(thinkCardLog.getCode());
if (thinkCard.getExpireTime() > (DateUtil.currentSeconds() / 1000)) {
thinkCard.setExpireTime((DateUtil.currentSeconds() / 1000) + (thinkCard.getTerm() * 86400 * 365) + (thinkCard.getMonth() * 86400 * 30));
} else {
thinkCard.setExpireTime(thinkCard.getExpireTime() + (thinkCard.getTerm() * 86400 * 365) + (thinkCard.getMonth() * 86400 * 30));
}
// 充值卡
if (thinkCard.getType().equals(4) || thinkCard.getType().equals(5)) {
// 是否已过期,过期的清空,未过期的在旧卡基础上叠加
if (thinkCard.getExpireTime() < (DateUtil.currentSeconds() / 1000)) {
thinkCard.setRemainingMoney(thinkCardLog.getMoney());
} else {
thinkCard.setRemainingMoney(thinkCardLog.getMoney().add(thinkCard.getRemainingMoney()));
}
} else {
if (thinkCard.getExpireTime() < (DateUtil.currentSeconds() / 1000)) {
thinkCard.setNum(thinkCardLog.getCount());
} else {
thinkCard.setNum(thinkCardLog.getCount() + thinkCard.getCount());
}
// thinkCard.setNum(thinkCard.getCount() + thinkCard.getCount());
}
thinkCard.setNumber(thinkCard.getNumber() + 1);
thinkCard.setCount(thinkCard.getCount() + thinkCardLog.getCount());
thinkCardService.updateById(thinkCard);
return success("添加成功");
}
return fail("添加失败");
@@ -132,18 +132,25 @@ public class ThinkDepositController extends BaseController {
@PostMapping()
public ApiResult<?> save(@RequestBody ThinkDeposit thinkDeposit) {
User user = getLoginUser();
ThinkUsers thinkUsers = thinkUsersService.getById(getLoginUser().getUid());
thinkDeposit.setName(thinkUsers.getUsername());
thinkDeposit.setPhone(user.getPhone());
if (thinkDeposit.getIsAdmin() == null) {
ThinkUsers thinkUsers = thinkUsersService.getById(getLoginUser().getUid());
thinkDeposit.setName(thinkUsers.getUsername());
thinkDeposit.setPhone(user.getPhone());
thinkDeposit.setStatus(0);
thinkDeposit.setAid(0);
} else {
thinkDeposit.setName(user.getUsername());
thinkDeposit.setAid(user.getUserId());
}
thinkDeposit.setOrderNum(IdUtil.getSnowflake().nextIdStr());
thinkDeposit.setStatus(0);
thinkDeposit.setAid(0);
thinkDeposit.setCreateTime(DateUtil.currentSeconds());
thinkDeposit.setUpdateTime(DateUtil.currentSeconds());
if (thinkDepositService.save(thinkDeposit)) {
String notify = "https://gxtyzx-api.websoft.top/api/think/think-deposit/notify";
return success(thinkOrderService.createWxOrder(thinkDeposit.getMoney(), thinkDeposit.getOrderNum(), "押金",
getLoginUser().getOpenid(), notify));
if (thinkDeposit.getIsAdmin() == null) {
String notify = "https://gxtyzx-api2.websoft.top/api/think/think-deposit/notify";
return success(thinkOrderService.createWxOrder(thinkDeposit.getMoney(), thinkDeposit.getOrderNum(), "押金",
getLoginUser().getOpenid(), notify));
} else return success("添加成功");
}
return fail("添加失败");
}
@@ -153,8 +160,10 @@ public class ThinkDepositController extends BaseController {
public ApiResult<?> update(@RequestBody ThinkDeposit thinkDeposit) {
if (thinkDepositService.updateById(thinkDeposit)) {
ThinkDeposit thinkDeposit1 = thinkDepositService.getByIdRel(thinkDeposit.getId());
if (thinkDeposit1.getMoneyType().equals(1) && thinkDeposit.getStatus().equals(2)) {
thinkDepositService.refund(thinkDeposit1);
if (thinkDeposit1 != null) {
if (thinkDeposit1.getMoneyType().equals(1) && thinkDeposit.getStatus().equals(2) && thinkDeposit1.getIsAdminOrder().equals(0)) {
thinkDepositService.refund(thinkDeposit1);
}
}
return success("修改成功");
}
@@ -72,7 +72,7 @@ public class ThinkGoodsOrderController extends BaseController {
// 查询订单信息
final ThinkGoodsOrder order = thinkGoodsOrderService.getByOrderNum(transaction.getOutTradeNo());
if (order == null) return "订单不存在";
if (order.getPayStatus().equals(1)) {
if (order.getPayStatus().equals(2)) {
updatePay(order, transaction.getTransactionId(), transaction.getAmount().getPayerTotal());
}
return "订单已支付";
@@ -119,7 +119,7 @@ public class ThinkGoodsOrderController extends BaseController {
@GetMapping("/page")
public ApiResult<PageResult<ThinkGoodsOrder>> page(ThinkGoodsOrderParam param) {
// 使用关联查询
param.setUid(getLoginUser().getUid());
if (param.getIsAdmin() == null) param.setUid(getLoginUser().getUid());
return success(thinkGoodsOrderService.pageRel(param));
}
@@ -155,6 +155,8 @@ public class ThinkGoodsOrderController extends BaseController {
thinkGoodsOrder.setUid(thinkUsers.getId());
thinkGoodsOrder.setOrderNum(IdUtil.getSnowflake().nextIdStr());
thinkGoodsOrder.setWechatOrder("");
thinkGoodsOrder.setCreateTime((int) DateUtil.currentSeconds());
thinkGoodsOrder.setUpdateTime((int) DateUtil.currentSeconds());
thinkGoodsOrder.setInfo("商城订单");
if (thinkGoodsOrderService.save(thinkGoodsOrder)) {
for (ThinkGoodsOrderInfo info : thinkGoodsOrder.getInfoList()) {
@@ -48,11 +48,17 @@ public class ThinkInvoiceController extends BaseController {
@Resource
private ThinkSiteService thinkSiteService;
private final String taxnum = "339901999999142";
private final String appKey = "SD56531018";
private final String appSecret = "SD3C429B318C485E";
private final String sellerTel = "339901999999142";
private final String url = "https://sandbox.nuonuocs.cn/open/v1/services";
// private final String taxnum = "339901999999142";
// private final String appKey = "SD56531018";
// private final String appSecret = "SD3C429B318C485E";
// private final String sellerTel = "339901999999142";
// private final String url = "https://sandbox.nuonuocs.cn/open/v1/services";
private final String taxnum = "91450100737617400R";
private final String appKey = "92969434";
private final String appSecret = "D51901886E454FEF";
private final String sellerTel = "18907712789";
private final String url = "https://sdk.nuonuo.com/open/v1/services";
@ApiOperation("分页查询")
@GetMapping("/page")
@@ -62,6 +68,11 @@ public class ThinkInvoiceController extends BaseController {
return success(thinkInvoiceService.pageRel(param));
}
@GetMapping("/data")
public ApiResult<ThinkInvoice> data(ThinkInvoiceParam param) {
return success(thinkInvoiceService.getData(param));
}
@ApiOperation("查询全部")
@GetMapping()
public ApiResult<List<ThinkInvoice>> list(ThinkInvoiceParam param) {
@@ -84,16 +95,20 @@ public class ThinkInvoiceController extends BaseController {
thinkInvoice.setUid(getLoginUser().getUid());
thinkInvoice.setCode(thinkInvoice.getIncoiveCode());
thinkInvoice.setIncoiveNum(RandomUtil.randomString(20));
thinkInvoice.setIsOpen(2);
if (!thinkInvoice.getIsOpen().equals(1)) thinkInvoice.setIsOpen(2);
thinkInvoice.setCreateTime(DateUtil.currentSeconds());
thinkInvoice.setUpdateTime(DateUtil.currentSeconds());
if (thinkInvoice.getItype().equals(1)) {
List<ThinkOrderInfo> thinkOrderInfoList = thinkOrderInfoService.listInOrder(thinkInvoice.getOid());
ThinkOrderInfo thinkOrderInfo = thinkOrderInfoList.get(0);
thinkInvoice.setInfo(thinkOrderInfo.getSiteName() + "-" + thinkOrderInfo.getFieldName() + "(" + thinkOrderInfo.getDateTime() + ")");
if (thinkInvoice.getOid() != null) {
List<ThinkOrderInfo> thinkOrderInfoList = thinkOrderInfoService.listInOrder(thinkInvoice.getOid());
ThinkOrderInfo thinkOrderInfo = thinkOrderInfoList.get(0);
thinkInvoice.setInfo(thinkOrderInfo.getSiteName() + "-" + thinkOrderInfo.getFieldName() + "(" + thinkOrderInfo.getDateTime() + ")");
}
} else if (thinkInvoice.getItype().equals(2)) {
ThinkUsersVip thinkUsersVip = thinkUsersVipService.getById(thinkInvoice.getOid());
thinkInvoice.setInfo(thinkUsersVip.getName() + " 微信订单号: " + thinkUsersVip.getWechatOrder());
if (thinkInvoice.getOid() != null) {
ThinkUsersVip thinkUsersVip = thinkUsersVipService.getById(thinkInvoice.getOid());
thinkInvoice.setInfo(thinkUsersVip.getName() + " 微信订单号: " + thinkUsersVip.getWechatOrder());
}
} else if (thinkInvoice.getItype().equals(4)) {
thinkInvoice.setInfo("租赁发票");
}
@@ -164,7 +179,9 @@ public class ThinkInvoiceController extends BaseController {
// String appKey = "92969434";
// String appSecret = "D51901886E454FEF";
String method = "nuonuo.OpeMplatform.requestBillingNew";//API方法名
String token = NNOpenSDK.getIntance().getMerchantToken(appKey, appSecret); //访问令牌
String tokenJsonStr = NNOpenSDK.getIntance().getMerchantToken(appKey, appSecret); //访问令牌
JSONObject tokenJson = JSONObject.parseObject(tokenJsonStr);
String token = tokenJson.getString("access_token");
final NuoNuo nuoNuo = new NuoNuo();
final NuoNuoOrder order = new NuoNuoOrder();
order.setBuyerName(thinkInvoice.getName());
@@ -180,7 +197,19 @@ public class ThinkInvoiceController extends BaseController {
order.setInvoiceType(String.valueOf(thinkInvoice.getInvoicetype()));
order.setRemark("不动产地址:广西壮族自治区南宁市良庆区五象大道西段669号广西体育中心综合馆;(市)标志:否;");
final NuoNuoGoods goods = new NuoNuoGoods();
goods.setGoodsName(thinkInvoice.getInfo());
if (thinkInvoice.getItype().equals(1)) {
final ThinkOrder thinkOrder = thinkOrderService.getById(thinkInvoice.getOid());
List<ThinkOrderInfo> thinkOrderInfoList = thinkOrderInfoService.listInOrder(thinkInvoice.getOid());
goods.setGoodsName(thinkOrderInfoList.get(0).getSiteName() + "-" + thinkOrderInfoList.get(0).getFieldName()
+ "(" + thinkOrder.getDateTime() + ")");
} else if (thinkInvoice.getItype().equals(2)) {
goods.setGoodsName("广西体育中心VIP卡");
} else if (thinkInvoice.getItype().equals(3)) {
goods.setGoodsName("广西体育中心IC卡");
} else {
goods.setGoodsName("广西体育中心场馆");
}
// goods.setGoodsCode("3040502029902000000");
goods.setWithTaxFlag("0");
// if (!CollectionUtils.isEmpty(orderInfos)) {
@@ -230,6 +259,7 @@ public class ThinkInvoiceController extends BaseController {
String content = JSONUtil.toJSONString(nuoNuo);//API私有请求参数
String senid = UUID.randomUUID().toString(); // 唯一标识,由企业自己生成32位随机码
String json = sdk.sendPostSyncRequest(url, senid, appKey, appSecret, token, taxnum, method, content); // 请求API
System.out.println("json = " + json);
if (StrUtil.isNotBlank(json)) {
@@ -65,7 +65,8 @@ public class ThinkMachineOpenLogController extends BaseController {
return fail("二维码不能为空");
String[] qrcode = thinkMachineOpenLog.getQrcode().split(",");
for (String s : qrcode) {
Map<String, Object> res = thinkOrderService.getByQrCode(s);
Map<String, Object> res = thinkOrderService.getByQrCode(s, false);
System.out.println(res);
ThinkOrder thinkOrder = (ThinkOrder) res.get("data");
if (thinkOrder != null) {
ThinkMachineOpenLog openLog = thinkMachineOpenLogService.getByOrderId(thinkOrder.getId());
File diff suppressed because it is too large Load Diff
@@ -45,6 +45,8 @@ public class ThinkOrderRefundLogController extends BaseController {
@Resource
private ThinkOrderService thinkOrderService;
@Resource
private ThinkOrderInfoService thinkOrderInfoService;
@Resource
private WechatConfigService wechatConfigService;
@Resource
private ThinkVipCardsBillsService thinkVipCardsBillsService;
@@ -76,7 +78,15 @@ public class ThinkOrderRefundLogController extends BaseController {
}
if (notification.getRefundStatus().equals(Status.SUCCESS)) {
thinkOrderRefundLog.setStatus(2);
if (thinkOrder != null) thinkOrder.setOrderStatus(6);
if (thinkOrder != null) {
thinkOrder.setOrderStatus(6);
thinkOrder.setRefundTime((int) (System.currentTimeMillis() / 1000));
List<ThinkOrderInfo> thinkOrderInfoList = thinkOrderInfoService.listInOrder(thinkOrder.getId());
for (ThinkOrderInfo thinkOrderInfo : thinkOrderInfoList) {
thinkOrderInfo.setPayStatus(0);
}
thinkOrderInfoService.updateBatchById(thinkOrderInfoList);
}
} else if (notification.getRefundStatus().equals(Status.ABNORMAL) || notification.getRefundStatus().equals(Status.CLOSED)) {
thinkOrderRefundLog.setStatus(4);
@@ -121,14 +131,22 @@ public class ThinkOrderRefundLogController extends BaseController {
thinkOrderService.updateById(thinkOrder);
if (thinkOrder.getPayType().equals(1)) {
thinkOrderService.refund(thinkOrderRefundLog);
}else {
} else {
int num = 0;
List<ThinkOrderInfo> thinkOrderInfoList = thinkOrderInfoService.listInOrder(thinkOrder.getId());
for (ThinkOrderInfo thinkOrderInfo : thinkOrderInfoList) {
thinkOrderInfo.setPayStatus(0);
num += thinkOrderInfo.getAdultNum() + thinkOrderInfo.getChildrenNum();
}
thinkOrderInfoService.updateBatchById(thinkOrderInfoList);
thinkOrder.setOrderStatus(6);
thinkOrder.setRefundTime((int) (System.currentTimeMillis() / 1000));
thinkOrderService.updateById(thinkOrder);
if (thinkOrder.getVid() != null && thinkOrder.getVid() != 0) {
ThinkVipCardsBills thinkVipCardsBills = new ThinkVipCardsBills();
thinkVipCardsBills.setVid(thinkOrder.getVid());
thinkVipCardsBills.setUid(thinkOrder.getUid());
DateTime dateTime = DateUtil.date(Long.parseLong(thinkOrder.getStartTime()) * 1000L);
DateTime dateTime = DateUtil.date(thinkOrderInfoList.get(0).getStartTime() * 1000L);
thinkVipCardsBills.setDate(DateUtil.format(dateTime, "yyyy-MM-dd"));
thinkVipCardsBillsService.cancelLog(thinkVipCardsBills);
@@ -139,14 +157,21 @@ public class ThinkOrderRefundLogController extends BaseController {
} else if (usersVip.getType().equals(4)) {
BigDecimal newBalance = usersVip.getRemainingMoney().add(usersVip.getEachMoney());
usersVip.setRemainingMoney(newBalance);
usersVip.setNum(usersVip.getNum() + 1);
usersVip.setNum(usersVip.getNum() + num);
} else {
usersVip.setNum(usersVip.getNum() + 1);
usersVip.setNum(usersVip.getNum() + num);
}
usersVip.setUseTime(0L);
thinkUsersVipService.updateById(usersVip);
}
if (thinkOrder.getCid() != null && thinkOrder.getCid() != 0) {
ThinkCard card = thinkCardService.getByCode(thinkOrder.getCode());
ThinkCard card = null;
if (thinkOrder.getCode() != null && !thinkOrder.getCode().isEmpty()) {
card = thinkCardService.getByCode(thinkOrder.getCode());
}
if (card == null && thinkOrder.getCid() != null && thinkOrder.getCid() != 0) {
card = thinkCardService.getById(thinkOrder.getCid());
}
if (card != null) {
if (card.getType().equals(5)) {
BigDecimal newBalance = card.getRemainingMoney().add(thinkOrder.getPayPrice());
card.setRemainingMoney(newBalance);
@@ -156,11 +181,13 @@ public class ThinkOrderRefundLogController extends BaseController {
} else if (card.getType().equals(2)) {
card.setNum(card.getNum() + 1);
}
card.setUseTime(0L);
thinkCardService.updateById(card);
ThinkVipCardsBills thinkVipCardsBills = new ThinkVipCardsBills();
thinkVipCardsBills.setCid(thinkOrder.getCid());
thinkVipCardsBills.setUid(thinkOrder.getUid());
DateTime dateTime = DateUtil.date(Long.parseLong(thinkOrder.getStartTime()) * 1000L);
DateTime dateTime = DateUtil.date(thinkOrderInfoList.get(0).getStartTime() * 1000L);
thinkVipCardsBills.setDate(DateUtil.format(dateTime, "yyyy-MM-dd"));
thinkVipCardsBillsService.cancelLog(thinkVipCardsBills);
}
@@ -1,8 +1,9 @@
package com.gxwebsoft.think.controller;
import cn.hutool.core.date.DateUtil;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.think.entity.*;
import com.gxwebsoft.think.service.ThinkRechargeLogService;
import com.gxwebsoft.think.entity.ThinkRechargeLog;
import com.gxwebsoft.think.param.ThinkRechargeLogParam;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.PageResult;
@@ -10,13 +11,23 @@ import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.annotation.OperationLog;
import com.gxwebsoft.common.system.entity.User;
import com.gxwebsoft.think.service.ThinkUsersVipService;
import com.gxwebsoft.think.service.ThinkVipService;
import com.gxwebsoft.think.service.WechatConfigService;
import com.wechat.pay.java.core.notification.NotificationConfig;
import com.wechat.pay.java.core.notification.NotificationParser;
import com.wechat.pay.java.core.notification.RequestParam;
import com.wechat.pay.java.service.refund.model.RefundNotification;
import com.wechat.pay.java.service.refund.model.Status;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
/**
* 控制器
@@ -30,6 +41,64 @@ import java.util.List;
public class ThinkRechargeLogController extends BaseController {
@Resource
private ThinkRechargeLogService thinkRechargeLogService;
@Resource
private WechatConfigService wechatConfigService;
@Resource
private ThinkUsersVipService thinkUsersVipService;
@Resource
private ThinkVipService thinkVipService;
@PostMapping("/refund-notify")
public ApiResult<?> refundNotify(@RequestBody String body, @RequestHeader Map<String, Object> header) {
System.out.println("recharge refund body = " + body);
com.wechat.pay.java.core.notification.RequestParam requestParam = new RequestParam.Builder()
.serialNumber(header.get("wechatpay-serial").toString())
.nonce(header.get("wechatpay-nonce").toString())
.signature(header.get("wechatpay-signature").toString())
.timestamp(header.get("wechatpay-timestamp").toString())
.body(body)
.build();
NotificationConfig config = wechatConfigService.getNotificationConfig();
// 初始化 NotificationParser
NotificationParser parser = new NotificationParser(config);
RefundNotification notification = parser.parse(requestParam, RefundNotification.class);
System.out.println("notification = " + notification);
String refundNo = notification.getOutRefundNo();
if (notification.getRefundStatus().equals(Status.SUCCESS)) {
ThinkRechargeLog thinkRechargeLog = thinkRechargeLogService.getByRefundNumber(refundNo);
if (thinkRechargeLog != null) {
thinkRechargeLog.setStatus(3);
thinkRechargeLogService.updateById(thinkRechargeLog);
ThinkUsersVip thinkUsersVip = thinkUsersVipService.getById(thinkRechargeLog.getVid());
if (thinkUsersVip != null) {
if (thinkUsersVip.getType().equals(4) || thinkUsersVip.getType().equals(5)) {
BigDecimal remain = thinkUsersVip.getRemainingMoney().subtract(thinkUsersVip.getPrice());
if (remain.compareTo(BigDecimal.ZERO) < 1) thinkUsersVip.setStatus(3);
else thinkUsersVip.setRemainingMoney(remain);
}
else {
int num = thinkUsersVip.getNum() - thinkUsersVip.getCount();
if (num <= 0) thinkUsersVip.setStatus(3);
else thinkUsersVip.setNum(num);
}
thinkUsersVipService.updateById(thinkUsersVip);
}
}
}
return success();
}
@ApiOperation("退款")
@PostMapping("/refund")
public ApiResult<?> refund(@RequestBody ThinkRechargeLog thinkRechargeLog) {
ThinkRechargeLog thinkRechargeLog1 = thinkRechargeLogService.getById(thinkRechargeLog.getId());
thinkRechargeLog1.setRefundNo("R" + thinkRechargeLog1.getOrderNum());
thinkRechargeLogService.updateById(thinkRechargeLog1);
thinkRechargeLogService.refund(thinkRechargeLog1);
return success();
}
@ApiOperation("分页查询")
@GetMapping("/page")
@@ -62,6 +131,7 @@ public class ThinkRechargeLogController extends BaseController {
return fail("添加失败");
}
@ApiOperation("修改")
@PutMapping()
public ApiResult<?> update(@RequestBody ThinkRechargeLog thinkRechargeLog) {
@@ -36,6 +36,7 @@ public class ThinkSiteController extends BaseController {
@GetMapping("/page")
public ApiResult<PageResult<ThinkSite>> page(ThinkSiteParam param) {
// 使用关联查询
if (getLoginUser() != null) param.setLoginUser(getLoginUser());
return success(thinkSiteService.pageRel(param));
}
@@ -45,6 +46,7 @@ public class ThinkSiteController extends BaseController {
if (param.getIds() != null) {
param.setIdList(Arrays.stream(param.getIds().split(",")).map(Integer::parseInt).toList());
}
if (getLoginUser() != null && param.getIsAdmin() != null) param.setLoginUser(getLoginUser());
// 使用关联查询
return success(thinkSiteService.listRel(param));
}
@@ -50,20 +50,12 @@ public class ThinkSiteTimeController extends BaseController {
@ApiOperation("查询全部")
@GetMapping()
public ApiResult<List<ThinkSiteTime>> list(ThinkSiteTimeParam param) {
List<ThinkSiteTime> list = new ArrayList<>();
String redisList = redisUtil.get("site_time_list_" + param.getSid());
if (redisList == null || redisList.isEmpty()) {
list = thinkSiteTimeService.list(
new LambdaQueryWrapper<ThinkSiteTime>()
.eq(ThinkSiteTime::getSid, param.getSid())
.eq(ThinkSiteTime::getIsStatus, 1)
.orderByAsc(ThinkSiteTime::getSort)
);
redisUtil.set("site_time_list_" + param.getSid(), JSONUtil.toJsonStr(list));
}else {
list = JSONUtil.parseArray(redisList).toList(ThinkSiteTime.class);
}
// 使用关联查询
List<ThinkSiteTime> list = thinkSiteTimeService.list(
new LambdaQueryWrapper<ThinkSiteTime>()
.eq(ThinkSiteTime::getSid, param.getSid())
.eq(ThinkSiteTime::getIsStatus, 1)
.orderByAsc(ThinkSiteTime::getSort)
);
return success(list);
}
@@ -78,6 +70,8 @@ public class ThinkSiteTimeController extends BaseController {
@ApiOperation("添加")
@PostMapping()
public ApiResult<?> save(@RequestBody ThinkSiteTime thinkSiteTime) {
thinkSiteTime.setCreateTime((int) (System.currentTimeMillis()/1000));
thinkSiteTime.setUpdateTime((int) (System.currentTimeMillis()/1000));
if (thinkSiteTimeService.save(thinkSiteTime)) {
redisUtil.delete("site_time_list_" + thinkSiteTime.getSid());
return success("添加成功");
@@ -88,6 +82,7 @@ public class ThinkSiteTimeController extends BaseController {
@ApiOperation("修改")
@PutMapping()
public ApiResult<?> update(@RequestBody ThinkSiteTime thinkSiteTime) {
thinkSiteTime.setUpdateTime((int) (System.currentTimeMillis()/1000));
if (thinkSiteTimeService.updateById(thinkSiteTime)) {
redisUtil.delete("site_time_list_" + thinkSiteTime.getSid());
return success("修改成功");
@@ -0,0 +1,110 @@
package com.gxwebsoft.think.controller;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.think.service.ThinkUsersVipBuyLogService;
import com.gxwebsoft.think.entity.ThinkUsersVipBuyLog;
import com.gxwebsoft.think.param.ThinkUsersVipBuyLogParam;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.annotation.OperationLog;
import com.gxwebsoft.common.system.entity.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
/**
* Vip购卡记录控制器
*
* @author 科技小王子
* @since 2025-03-25 19:21:56
*/
@Api(tags = "Vip购卡记录管理")
@RestController
@RequestMapping("/api/think/think-users-vip-buy-log")
public class ThinkUsersVipBuyLogController extends BaseController {
@Resource
private ThinkUsersVipBuyLogService thinkUsersVipBuyLogService;
@ApiOperation("分页查询Vip购卡记录")
@GetMapping("/page")
public ApiResult<PageResult<ThinkUsersVipBuyLog>> page(ThinkUsersVipBuyLogParam param) {
// 使用关联查询
return success(thinkUsersVipBuyLogService.pageRel(param));
}
@ApiOperation("查询全部Vip购卡记录")
@GetMapping()
public ApiResult<List<ThinkUsersVipBuyLog>> list(ThinkUsersVipBuyLogParam param) {
// 使用关联查询
return success(thinkUsersVipBuyLogService.listRel(param));
}
@PreAuthorize("hasAuthority('think:thinkUsersVipBuyLog:list')")
@ApiOperation("根据id查询Vip购卡记录")
@GetMapping("/{id}")
public ApiResult<ThinkUsersVipBuyLog> get(@PathVariable("id") Integer id) {
// 使用关联查询
return success(thinkUsersVipBuyLogService.getByIdRel(id));
}
@ApiOperation("添加Vip购卡记录")
@PostMapping()
public ApiResult<?> save(@RequestBody ThinkUsersVipBuyLog thinkUsersVipBuyLog) {
if (thinkUsersVipBuyLogService.save(thinkUsersVipBuyLog)) {
return success("添加成功");
}
return fail("添加失败");
}
@ApiOperation("修改Vip购卡记录")
@PutMapping()
public ApiResult<?> update(@RequestBody ThinkUsersVipBuyLog thinkUsersVipBuyLog) {
if (thinkUsersVipBuyLogService.updateById(thinkUsersVipBuyLog)) {
return success("修改成功");
}
return fail("修改失败");
}
@ApiOperation("删除Vip购卡记录")
@DeleteMapping("/{id}")
public ApiResult<?> remove(@PathVariable("id") Integer id) {
if (thinkUsersVipBuyLogService.removeById(id)) {
return success("删除成功");
}
return fail("删除失败");
}
@ApiOperation("批量添加Vip购卡记录")
@PostMapping("/batch")
public ApiResult<?> saveBatch(@RequestBody List<ThinkUsersVipBuyLog> list) {
if (thinkUsersVipBuyLogService.saveBatch(list)) {
return success("添加成功");
}
return fail("添加失败");
}
@ApiOperation("批量修改Vip购卡记录")
@PutMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody BatchParam<ThinkUsersVipBuyLog> batchParam) {
if (batchParam.update(thinkUsersVipBuyLogService, "id")) {
return success("修改成功");
}
return fail("修改失败");
}
@ApiOperation("批量删除Vip购卡记录")
@DeleteMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
if (thinkUsersVipBuyLogService.removeByIds(ids)) {
return success("删除成功");
}
return fail("删除失败");
}
}
@@ -7,6 +7,10 @@ import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.symmetric.SymmetricAlgorithm;
import cn.hutool.crypto.symmetric.SymmetricCrypto;
import com.gxwebsoft.common.core.utils.RedisUtil;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.think.entity.*;
import com.gxwebsoft.think.param.ThinkOrderParam;
@@ -23,6 +27,7 @@ import com.wechat.pay.java.core.notification.NotificationParser;
import com.wechat.pay.java.core.notification.RequestParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
@@ -54,6 +59,12 @@ public class ThinkUsersVipController extends BaseController {
private ThinkSiteService thinkSiteService;
@Resource
private ThinkVipCardsBillsService thinkVipCardsBillsService;
@Resource
private ThinkUsersVipBuyLogService thinkUsersVipBuyLogService;
@Resource
private ThinkRechargeLogService thinkRechargeLogService;
@Autowired
private RedisUtil redisUtil;
@ApiOperation("分页查询")
@GetMapping("/page")
@@ -61,6 +72,7 @@ public class ThinkUsersVipController extends BaseController {
if (param.getForAdmin() == null) {
if (getLoginUser() == null) return fail("请先登录");
param.setUid(getLoginUser().getUid());
param.setStatus(1);
}
// 使用关联查询
return success(thinkUsersVipService.pageRel(param));
@@ -72,11 +84,29 @@ public class ThinkUsersVipController extends BaseController {
// 使用关联查询
if (param.getForAdmin() == null) {
if (getLoginUser() == null) return fail("请先登录");
param.setStatus(1);
param.setUid(getLoginUser().getUid());
}
return success(thinkUsersVipService.listRel(param));
}
@ApiOperation("码")
@GetMapping("/code/{id}")
public ApiResult<?> code(@PathVariable("id") Integer id) {
String secretKey = redisUtil.get("secretKey_10150");
byte[] key = null;
if (secretKey == null) {
key = SecureUtil.generateKey(SymmetricAlgorithm.AES.getValue()).getEncoded();
redisUtil.set("secretKey_10150", Base64.getEncoder().encodeToString(key));
} else {
key = Base64.getDecoder().decode(secretKey);
}
SymmetricCrypto aes = new SymmetricCrypto(SymmetricAlgorithm.AES, key);
long timestamp = (int) (System.currentTimeMillis() / 1000);
String code = aes.encryptHex(id + "_" + timestamp + "_vipCard");
return success("成功", code);
}
@ApiOperation("根据id查询")
@GetMapping("/{id}")
public ApiResult<?> get(@PathVariable("id") Integer id) {
@@ -95,6 +125,21 @@ public class ThinkUsersVipController extends BaseController {
return success(thinkUsersVip);
}
@ApiOperation("根据id查询")
@GetMapping("/info-for-admin/{id}")
public ApiResult<?> infoForAdmin(@PathVariable("id") Integer id) {
ThinkUsersVip thinkUsersVip = thinkUsersVipService.getByIdRel(id);
String[] siteStrList = thinkUsersVip.getSid().split(",");
List<String> siteNamesList = new ArrayList<>();
for (String siteStr : siteStrList) {
ThinkSite site = thinkSiteService.getByIdRel(Integer.valueOf(siteStr));
if (site != null) siteNamesList.add(site.getName());
}
if (!siteNamesList.isEmpty()) thinkUsersVip.setSiteNames(StrUtil.join(",", siteNamesList));
// 使用关联查询
return success(thinkUsersVip);
}
@ApiOperation("微信通知")
@PostMapping("/notify")
public String notify(@RequestBody String body, @RequestHeader Map<String, Object> header) {
@@ -111,6 +156,7 @@ public class ThinkUsersVipController extends BaseController {
com.wechat.pay.java.service.payments.model.Transaction transaction = parser.parse(requestParam, com.wechat.pay.java.service.payments.model.Transaction.class);
// 查询订单信息
final ThinkUsersVip order = thinkUsersVipService.getByOrderNo(transaction.getOutTradeNo());
ThinkUsersVip usersVip = null;
if (order == null) return "订单不存在";
usersVip = order;
@@ -121,16 +167,22 @@ public class ThinkUsersVipController extends BaseController {
order.setPrices(order.getTempPrices());
// 查找有没有一样的卡
ThinkUsersVip sameOrder = thinkUsersVipService.getByVidAndUid(order.getVid(), order.getUid());
if (sameOrder != null) {
System.out.println("sameOrder >>>>> " + sameOrder);
ThinkVip thinkVip = thinkVipService.getByIdRel(order.getVid());
if (sameOrder != null && !sameOrder.getId().equals(order.getId()) && thinkVip.getMode().equals(0)) {
usersVip = sameOrder;
// 是否已过期,过期的从现在开始计算,未过期的在旧卡基础上叠加
if (sameOrder.getExpireTime() < DateUtil.currentSeconds()) {
sameOrder.setExpireTime(DateUtil.currentSeconds() + (order.getTerm() * 86400 * 365) + (order.getMonth() * 86400 * 30));
if (thinkVip.getMode().equals(0)) {
// 是否已过期,过期的从现在开始计算,未过期的在旧卡基础上叠加
if (sameOrder.getExpireTime() < DateUtil.currentSeconds()) {
sameOrder.setExpireTime(DateUtil.currentSeconds() + (order.getTerm() * 86400 * 365) + (order.getMonth() * 86400 * 30));
} else {
sameOrder.setExpireTime(sameOrder.getExpireTime() + (order.getTerm() * 86400 * 365) + (order.getMonth() * 86400 * 30));
}
} else {
sameOrder.setExpireTime(sameOrder.getExpireTime() + (order.getTerm() * 86400 * 365) + (order.getMonth() * 86400 * 30));
sameOrder.setExpireTime(DateUtil.parse(thinkVip.getExpiredTime(), "yyyy-MM-dd").getTime() / 1000L);
}
// 充值卡
if (sameOrder.getType().equals(4)) {
if (sameOrder.getType().equals(4) || sameOrder.getType().equals(5)) {
// 是否已过期,过期的清空,未过期的在旧卡基础上叠加
if (sameOrder.getExpireTime() < DateUtil.currentSeconds()) {
sameOrder.setRemainingMoney(order.getPrice());
@@ -143,47 +195,54 @@ public class ThinkUsersVipController extends BaseController {
} else {
sameOrder.setNum(sameOrder.getCount() + order.getCount());
}
sameOrder.setNum(sameOrder.getCount() + order.getCount());
// sameOrder.setNum(sameOrder.getCount() + order.getCount());
}
thinkUsersVipService.updateById(sameOrder);
// 删除订单
System.out.println("del order >>>>> " + order);
thinkUsersVipService.removeById(order.getId());
} else {
// 充值卡
if (order.getType().equals(4)) order.setRemainingMoney(order.getPrice());
if (order.getType().equals(4) || order.getType().equals(5)) order.setRemainingMoney(order.getPrice());
else order.setNum(order.getCount());
thinkUsersVipService.updateById(order);
}
if (usersVip != null) {
if (usersVip.getType().equals(1) || usersVip.getType().equals(3)) {
List<ThinkVipCardsBills> list = new ArrayList<>();
BigDecimal avgAmount = BigDecimal.ZERO;
int dayNum = 0;
BigDecimal totalAmountInAvg = BigDecimal.ZERO;
BigDecimal totalAmount = BigDecimal.ZERO;
if (usersVip.getType().equals(1)) {
totalAmount = usersVip.getPrice().multiply(new BigDecimal(usersVip.getTerm()));
avgAmount = totalAmount.divide(BigDecimal.valueOf(365).multiply(BigDecimal.valueOf(usersVip.getTerm())), RoundingMode.HALF_UP);
dayNum = 365 * usersVip.getTerm();
} else if (usersVip.getType().equals(3)) {
totalAmount = usersVip.getPrice().multiply(new BigDecimal(usersVip.getMonth()));
avgAmount = totalAmount.divide(BigDecimal.valueOf(30).multiply(BigDecimal.valueOf(usersVip.getMonth())), RoundingMode.HALF_UP);
dayNum = 30 * usersVip.getMonth();
}
totalAmountInAvg = avgAmount.multiply(BigDecimal.valueOf(dayNum - 1));
BigDecimal lastDayAmount = totalAmount.subtract(totalAmountInAvg);
for (int i = 0; i < dayNum; i++) {
ThinkVipCardsBills thinkVipCardsBills = new ThinkVipCardsBills();
thinkVipCardsBills.setUid(usersVip.getUid());
thinkVipCardsBills.setVid(usersVip.getId());
DateTime dateTime = DateUtil.date((usersVip.getCreateTime() * 1000L) + (i * 86400000L));
thinkVipCardsBills.setDate(DateUtil.format(dateTime, "yyyy-MM-dd"));
if (i == dayNum - 1) thinkVipCardsBills.setAmount(lastDayAmount);
else thinkVipCardsBills.setAmount(avgAmount);
list.add(thinkVipCardsBills);
}
thinkVipCardsBillsService.saveBatch(list);
ThinkRechargeLog thinkRechargeLog = thinkRechargeLogService.getByOrderNumber(transaction.getOutTradeNo());
if (thinkRechargeLog != null) {
thinkRechargeLog.setVid(usersVip.getId());
thinkRechargeLog.setStatus(1);
thinkRechargeLog.setWechatOrder(transaction.getTransactionId());
thinkRechargeLog.setPayTime(LocalDateTimeUtil.now());
thinkRechargeLogService.updateById(thinkRechargeLog);
}
if (usersVip.getType().equals(1) || usersVip.getType().equals(3)) {
List<ThinkVipCardsBills> list = new ArrayList<>();
BigDecimal avgAmount = BigDecimal.ZERO;
int dayNum = 0;
BigDecimal totalAmountInAvg = BigDecimal.ZERO;
BigDecimal totalAmount = BigDecimal.ZERO;
if (usersVip.getType().equals(1)) {
totalAmount = usersVip.getPrice().multiply(new BigDecimal(usersVip.getTerm()));
avgAmount = totalAmount.divide(BigDecimal.valueOf(365).multiply(BigDecimal.valueOf(usersVip.getTerm())), RoundingMode.HALF_UP);
dayNum = 365 * usersVip.getTerm();
} else if (usersVip.getType().equals(3)) {
totalAmount = usersVip.getPrice().multiply(new BigDecimal(usersVip.getMonth()));
avgAmount = totalAmount.divide(BigDecimal.valueOf(30).multiply(BigDecimal.valueOf(usersVip.getMonth())), RoundingMode.HALF_UP);
dayNum = 30 * usersVip.getMonth();
}
totalAmountInAvg = avgAmount.multiply(BigDecimal.valueOf(dayNum - 1));
BigDecimal lastDayAmount = totalAmount.subtract(totalAmountInAvg);
for (int i = 0; i < dayNum; i++) {
ThinkVipCardsBills thinkVipCardsBills = new ThinkVipCardsBills();
thinkVipCardsBills.setUid(usersVip.getUid());
thinkVipCardsBills.setVid(usersVip.getId());
DateTime dateTime = DateUtil.date((usersVip.getCreateTime() * 1000L) + (i * 86400000L));
thinkVipCardsBills.setDate(DateUtil.format(dateTime, "yyyy-MM-dd"));
if (i == dayNum - 1) thinkVipCardsBills.setAmount(lastDayAmount);
else thinkVipCardsBills.setAmount(avgAmount);
list.add(thinkVipCardsBills);
}
thinkVipCardsBillsService.saveBatch(list);
}
}
return "订单已支付";
@@ -195,11 +254,13 @@ public class ThinkUsersVipController extends BaseController {
public ApiResult<?> save(@RequestBody ThinkUsersVip thinkUsersVip) {
ThinkVip thinkVip = thinkVipService.getByIdRel(thinkUsersVip.getVid());
if (thinkVip == null) return fail("该会员卡不存在");
if (thinkVip.getIsUse().equals(0)) return fail("该会员卡已下架");
if (thinkVip.getIsUse().equals(2)) return fail("该会员卡已下架");
if (getLoginUser() == null) return fail("请先登录");
String orderNumber = "UV" + DateUtil.format(DateUtil.date(), "yyyyMMddHHmmss") + getLoginUser().getUid() + RandomUtil.randomNumbers(4);
thinkUsersVip.setSid(thinkVip.getSid());
thinkUsersVip.setUid(getLoginUser().getUid());
thinkUsersVip.setWechatOrder("UV" + DateUtil.format(DateUtil.date(), "yyyyMMddHHmmss") + getLoginUser().getUid() + RandomUtil.randomNumbers(4));
thinkUsersVip.setWechatOrder(orderNumber);
thinkUsersVip.setCode(RandomUtil.randomNumbers(12));
thinkUsersVip.setName(thinkVip.getName());
thinkUsersVip.setPrice(thinkVip.getPrice());
@@ -215,17 +276,29 @@ public class ThinkUsersVipController extends BaseController {
thinkUsersVip.setTempPrices(thinkVip.getPrices());
thinkUsersVip.setIsIntegral(thinkVip.getIsIntegral());
thinkUsersVip.setTerm(thinkVip.getTerm());
thinkUsersVip.setMonth(thinkVip.getMonth());
thinkUsersVip.setMode(thinkVip.getMode());
thinkUsersVip.setCreateTime(DateUtil.currentSeconds());
if (!thinkVip.getTerm().equals(0))
thinkUsersVip.setExpireTime(DateUtil.currentSeconds() + (long) thinkVip.getTerm() * 365 * 24 * 60 * 60);
if (!thinkVip.getMonth().equals(0))
thinkUsersVip.setExpireTime(DateUtil.currentSeconds() + (long) thinkVip.getMonth() * 30 * 24 * 60 * 60);
if (!thinkVip.getDay().equals(0))
thinkUsersVip.setExpireTime(DateUtil.currentSeconds() + (long) thinkVip.getDay() * 24 * 60 * 60);
if (thinkVip.getMode().equals(0)) {
if (!thinkVip.getTerm().equals(0))
thinkUsersVip.setExpireTime(DateUtil.currentSeconds() + (long) thinkVip.getTerm() * 365 * 24 * 60 * 60);
if (!thinkVip.getMonth().equals(0))
thinkUsersVip.setExpireTime(DateUtil.currentSeconds() + (long) thinkVip.getMonth() * 30 * 24 * 60 * 60);
if (!thinkVip.getDay().equals(0))
thinkUsersVip.setExpireTime(DateUtil.currentSeconds() + (long) thinkVip.getDay() * 24 * 60 * 60);
} else {
long time = DateUtil.parse(thinkVip.getExpiredTime(), "yyyy-MM-dd").getTime();
thinkUsersVip.setExpireTime(time / 1000);
}
ThinkRechargeLog thinkRechargeLog = new ThinkRechargeLog();
thinkRechargeLog.setUid(getLoginUser().getUid());
thinkRechargeLog.setOrderNum(orderNumber);
thinkRechargeLog.setMoney(thinkVip.getPrice());
thinkRechargeLog.setCreateTime(DateUtil.currentSeconds());
thinkRechargeLogService.save(thinkRechargeLog);
if (thinkUsersVipService.save(thinkUsersVip)) {
String notify = "https://gxtyzx-api.websoft.top/api/think/think-users-vip/notify";
String notify = "https://gxtyzx-api2.websoft.top/api/think/think-users-vip/notify";
return success("下单成功", thinkOrderService.createWxOrder(thinkVip.getPrice(), thinkUsersVip.getWechatOrder(),
thinkVip.getName(), getLoginUser().getOpenid(), notify));
}
@@ -240,8 +313,9 @@ public class ThinkUsersVipController extends BaseController {
if (thinkUsersVip1.getStatus().equals(1)) return fail("该订单已支付");
if (thinkUsersVip1.getStatus().equals(3)) return fail("该订单已退款");
if (thinkUsersVip1.getStatus().equals(0)) return fail("该订单已取消");
String notify = "https://gxtyzx-api.websoft.top/api/think/think-users-vip/notify";
thinkUsersVip1.setWechatOrder("UV" + DateUtil.format(DateUtil.date(), "yyyyMMddHHmmss") + getLoginUser().getUid() + RandomUtil.randomNumbers(4));
thinkUsersVipService.updateById(thinkUsersVip1);
String notify = "https://gxtyzx-api2.websoft.top/api/think/think-users-vip/notify";
return success("下单成功", thinkOrderService.createWxOrder(thinkUsersVip1.getPrice(), thinkUsersVip1.getWechatOrder(),
thinkUsersVip1.getName(), getLoginUser().getOpenid(), notify));
}
@@ -46,6 +46,9 @@ public class ThinkCard implements Serializable {
@TableField(value = "`code`")
private String code;
@ApiModelProperty(value = "原卡号")
private String originCardCode;
@ApiModelProperty(value = "会员卡名称")
@TableField(value = "`name`")
private String name;
@@ -132,6 +135,9 @@ public class ThinkCard implements Serializable {
@ApiModelProperty(value = "卡号")
private String cardNum;
@ApiModelProperty(value = "支付凭证")
private String payVoucher;
@ApiModelProperty(value = "密码")
@TableField(value = "`password`")
private String password;
@@ -156,4 +162,15 @@ public class ThinkCard implements Serializable {
@TableField(exist = false)
private Integer makeNum;
@ApiModelProperty(value = "原卡信息")
@TableField(exist = false)
private ThinkCard oldCard;
@ApiModelProperty(value = "新卡信息")
@TableField(exist = false)
private ThinkCard newCard;
@TableField(exist = false)
private ThinkVip thinkVip;
}
@@ -1,6 +1,7 @@
package com.gxwebsoft.think.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@@ -48,6 +49,8 @@ public class ThinkDeposit implements Serializable {
@ApiModelProperty(value = "1已付,2已退")
private Integer status;
private Integer isAdminOrder;
private String info;
@ApiModelProperty(value = "管理员id")
@@ -61,4 +64,6 @@ public class ThinkDeposit implements Serializable {
private String failReason;
@TableField(exist = false)
private Boolean isAdmin;
}
@@ -100,4 +100,6 @@ public class ThinkInvoice implements Serializable {
private String remark;
private String url;
}
@@ -3,6 +3,7 @@ package com.gxwebsoft.think.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.gxwebsoft.common.system.entity.User;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -52,6 +53,8 @@ public class ThinkOrder implements Serializable {
@ApiModelProperty(value = "关联管理员id")
private Integer aid;
private Integer addFromAdmin;
@ApiModelProperty(value = "核销管理员id")
private Integer adminId;
@@ -127,9 +130,9 @@ public class ThinkOrder implements Serializable {
private Integer isInvoice;
@ApiModelProperty(value = "下单时间")
private Integer createTime;
private Long createTime;
private Integer updateTime;
private Long updateTime;
@ApiModelProperty(value = "付款时间")
private Integer payTime;
@@ -169,4 +172,31 @@ public class ThinkOrder implements Serializable {
@TableField(exist = false)
private ThinkUsersVip thinkVip;
@TableField(exist = false)
private BigDecimal totalIncome;
@TableField(exist = false)
private ThinkSite site;
@TableField(exist = false)
private Integer day;
@TableField(exist = false)
private Boolean hasExpired;
@TableField(exist = false)
private BigDecimal realPrice;
@TableField(exist = false)
private ThinkMachineOpenLog machineOpenLog;
@TableField(exist = false)
private String sign;
@TableField(exist = false)
private Long postTime;
@TableField(exist = false)
private String adminName;
}
@@ -75,11 +75,23 @@ public class ThinkOrderInfo implements Serializable {
private Integer startTime;
@ApiModelProperty(value = "下单时间")
private Integer orderTime;
private Long orderTime;
@ApiModelProperty(value = "毫秒时间戳")
private Long timeFlag;
@TableField(exist = false)
private int siteTimeId;
@TableField(exist = false)
private Boolean used;
@TableField(exist = false)
private Boolean soldButNotUsed;
@TableField(exist = false)
private Boolean addFromAdmin;
@TableField(exist = false)
private String timePeriod;
}
@@ -10,6 +10,7 @@ import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
*
@@ -32,6 +33,9 @@ public class ThinkRechargeLog implements Serializable {
@ApiModelProperty(value = "充值订单号")
private String orderNum;
@ApiModelProperty(value = "退款订单号")
private String refundNo;
@ApiModelProperty(value = "微信支付订单号")
private String wechatOrder;
@@ -44,6 +48,8 @@ public class ThinkRechargeLog implements Serializable {
@ApiModelProperty(value = "充值时间")
private Long createTime;
private LocalDateTime payTime;
@ApiModelProperty(value = "VID")
private Integer vid;
@@ -93,4 +99,9 @@ public class ThinkRechargeLog implements Serializable {
@TableField(exist = false)
private Long expireTime;
@TableField(exist = false)
private ThinkVip thinkVip;
@TableField(exist = false)
private ThinkUsersVip thinkUsersVip;
}
@@ -100,6 +100,8 @@ public class ThinkSite implements Serializable {
private Integer dailyNum;
private String machineCode;
@TableField(exist = false)
private BigDecimal distance;
@@ -88,6 +88,8 @@ public class ThinkUsersVip implements Serializable {
@TableField(value = "`month`")
private Integer month;
private Integer mode;
@ApiModelProperty(value = "会员卡类型:1年卡,2次卡,3月卡,4会员VIP")
private Integer type;
@@ -133,6 +135,8 @@ public class ThinkUsersVip implements Serializable {
@ApiModelProperty(value = "对账情况:1=已对账;2=未对账;3=已对账,金额对不上;4=未查询到该订单")
private Integer checkBill;
private String remark;
@ApiModelProperty(value = "用户名")
@TableField(exist = false)
private String username;
@@ -0,0 +1,59 @@
package com.gxwebsoft.think.entity;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableLogic;
import java.io.Serializable;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* Vip购卡记录
*
* @author 科技小王子
* @since 2025-03-25 19:21:56
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "ThinkUsersVipBuyLog对象", description = "Vip购卡记录")
public class ThinkUsersVipBuyLog implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
private Integer uid;
private Integer vid;
private String orderNumber;
private String wechetNumber;
private BigDecimal amount;
private Integer payStatus;
private LocalDateTime payTime;
@ApiModelProperty(value = "状态, 0正常, 1冻结")
private Integer status;
@ApiModelProperty(value = "是否删除, 0否, 1是")
@TableLogic
private Integer deleted;
@ApiModelProperty(value = "租户id")
private Integer tenantId;
@ApiModelProperty(value = "注册时间")
private LocalDateTime createTime;
@ApiModelProperty(value = "修改时间")
private LocalDateTime updateTime;
}
@@ -90,6 +90,10 @@ public class ThinkVip implements Serializable {
private Integer updateTime;
private Integer mode;
private String expiredTime;
@ApiModelProperty(value = "是否有效:1是,0否")
private Integer isUse;
@@ -0,0 +1,37 @@
package com.gxwebsoft.think.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.gxwebsoft.think.entity.ThinkUsersVipBuyLog;
import com.gxwebsoft.think.param.ThinkUsersVipBuyLogParam;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* Vip购卡记录Mapper
*
* @author 科技小王子
* @since 2025-03-25 19:21:56
*/
public interface ThinkUsersVipBuyLogMapper extends BaseMapper<ThinkUsersVipBuyLog> {
/**
* 分页查询
*
* @param page 分页对象
* @param param 查询参数
* @return List<ThinkUsersVipBuyLog>
*/
List<ThinkUsersVipBuyLog> selectPageRel(@Param("page") IPage<ThinkUsersVipBuyLog> page,
@Param("param") ThinkUsersVipBuyLogParam param);
/**
* 查询全部
*
* @param param 查询参数
* @return List<User>
*/
List<ThinkUsersVipBuyLog> selectListRel(@Param("param") ThinkUsersVipBuyLogParam param);
}
@@ -4,9 +4,8 @@
<!-- 关联查询sql -->
<sql id="selectSql">
SELECT a.*, b.truename as adminName, c.name as cardName, c.phone, c.username, c.remaining_money,c.num,c.card_type,c.type,c.expire_time
SELECT a.*, c.name as cardName, c.phone, c.username, c.remaining_money,c.num,c.card_type,c.type,c.expire_time
FROM think_card_log a
LEFT JOIN think_users b ON a.aid = b.id
LEFT JOIN think_card c ON a.code = c.code
<where>
<if test="param.id != null">
@@ -46,6 +45,7 @@
AND (a.code LIKE CONCAT('%', #{param.keywords}, '%')
OR c.phone = #{param.keywords}
OR c.username = #{param.keywords}
OR c.wechat_order = #{param.keywords}
)
</if>
</where>
@@ -61,6 +61,9 @@
<if test="param.number != null">
AND a.number = #{param.number}
</if>
<if test="param.notZeroNumber != null">
AND a.number &gt; 0
</if>
<if test="param.num != null">
AND a.num = #{param.num}
</if>
@@ -134,9 +137,11 @@
AND a.remark LIKE CONCAT('%', #{param.remark}, '%')
</if>
<if test="param.keywords != null">
AND (a.username = #{param.keywords}
OR a.phone = #{param.keywords}
OR a.code = #{param.keywords}
AND (a.username LIKE CONCAT('%', #{param.keywords}, '%')
OR a.phone LIKE CONCAT('%', #{param.keywords}, '%')
OR a.code LIKE CONCAT('%', #{param.keywords}, '%')
OR a.wechat_order LIKE CONCAT('%', #{param.keywords}, '%')
OR a.card_num LIKE CONCAT('%', #{param.keywords}, '%')
)
</if>
</where>
@@ -6,6 +6,7 @@
<sql id="selectSql">
SELECT a.*
FROM think_invoice a
LEFT JOIN think_order b ON a.oid = b.id
<where>
<if test="param.id != null">
AND a.id = #{param.id}
@@ -77,7 +78,9 @@
AND a.vid = #{param.vid}
</if>
<if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
AND (
b.order_num LIKE CONCAT('%', #{param.keywords}, '%')
OR a.incoive_num LIKE CONCAT('%', #{param.keywords}, '%')
)
</if>
</where>
@@ -4,9 +4,8 @@
<!-- 关联查询sql -->
<sql id="selectSql">
SELECT a.*, b.site_name, b.date_time
SELECT a.*
FROM think_order a
LEFT JOIN think_order_info b ON a.id = b.oid
<where>
<if test="param.id != null">
AND a.id = #{param.id}
@@ -74,6 +73,12 @@
<if test="param.payType != null">
AND a.pay_type = #{param.payType}
</if>
<if test="param.payTypeList != null">
AND a.pay_type IN
<foreach collection="param.payTypeList" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</if>
<if test="param.payStatus != null">
AND a.pay_status = #{param.payStatus}
</if>
@@ -98,6 +103,12 @@
<if test="param.startTime != null">
AND a.start_time LIKE CONCAT('%', #{param.startTime}, '%')
</if>
<if test="param.orderTimeStart != null">
AND a.start_time &gt;= #{param.orderTimeStart}
</if>
<if test="param.orderTimeEnd != null">
AND a.start_time &lt;= #{param.orderTimeEnd}
</if>
<if test="param.isInvoice != null">
AND a.is_invoice = #{param.isInvoice}
</if>
@@ -125,12 +136,15 @@
<if test="param.checkBill != null">
AND a.check_bill = #{param.checkBill}
</if>
<if test="param.useVip != null">
AND a.vid &gt; 0
</if>
<if test="param.keywords != null">
AND (a.name = #{param.keywords}
OR a.id = #{param.keywords}
OR a.order_num = #{param.keywords}
OR a.phone = #{param.keywords}
OR a.code = #{param.keywords}
OR a.order_num LIKE CONCAT('%', #{param.keywords}, '%')
OR a.phone LIKE CONCAT('%', #{param.keywords}, '%')
OR a.code LIKE CONCAT('%', #{param.keywords}, '%')
)
</if>
</where>
@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gxwebsoft.think.mapper.ThinkUsersVipBuyLogMapper">
<!-- 关联查询sql -->
<sql id="selectSql">
SELECT a.*
FROM think_users_vip_buy_log a
<where>
<if test="param.id != null">
AND a.id = #{param.id}
</if>
<if test="param.uid != null">
AND a.uid = #{param.uid}
</if>
<if test="param.orderNumber != null">
AND a.order_number LIKE CONCAT('%', #{param.orderNumber}, '%')
</if>
<if test="param.wechetNumber != null">
AND a.wechet_number LIKE CONCAT('%', #{param.wechetNumber}, '%')
</if>
<if test="param.amount != null">
AND a.amount = #{param.amount}
</if>
<if test="param.payStatus != null">
AND a.pay_status = #{param.payStatus}
</if>
<if test="param.payTime != null">
AND a.pay_time LIKE CONCAT('%', #{param.payTime}, '%')
</if>
<if test="param.status != null">
AND a.status = #{param.status}
</if>
<if test="param.deleted != null">
AND a.deleted = #{param.deleted}
</if>
<if test="param.deleted == null">
AND a.deleted = 0
</if>
<if test="param.createTimeStart != null">
AND a.create_time &gt;= #{param.createTimeStart}
</if>
<if test="param.createTimeEnd != null">
AND a.create_time &lt;= #{param.createTimeEnd}
</if>
<if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
)
</if>
</where>
</sql>
<!-- 分页查询 -->
<select id="selectPageRel" resultType="com.gxwebsoft.think.entity.ThinkUsersVipBuyLog">
<include refid="selectSql"></include>
</select>
<!-- 查询全部 -->
<select id="selectListRel" resultType="com.gxwebsoft.think.entity.ThinkUsersVipBuyLog">
<include refid="selectSql"></include>
</select>
</mapper>
@@ -1,6 +1,8 @@
package com.gxwebsoft.think.param;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.TableField;
import com.gxwebsoft.common.core.annotation.QueryField;
import com.gxwebsoft.common.core.annotation.QueryType;
import com.gxwebsoft.common.core.web.BaseParam;
@@ -158,4 +160,10 @@ public class ThinkCardParam extends BaseParam {
@ApiModelProperty(value = "备注")
private String remark;
@ApiModelProperty(value = "续卡")
@TableField(exist = false)
private Boolean notZeroNumber;
@TableField(exist = false)
private String orderBy;
}
@@ -1,5 +1,6 @@
package com.gxwebsoft.think.param;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.gxwebsoft.common.core.annotation.QueryField;
import com.gxwebsoft.common.core.annotation.QueryType;
@@ -81,4 +82,6 @@ public class ThinkGoodsOrderParam extends BaseParam {
@QueryField(type = QueryType.EQ)
private Integer payTime;
@TableField(exist = false)
private Boolean isAdmin;
}
@@ -11,6 +11,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
import java.util.List;
/**
* 查询参数
@@ -157,4 +158,19 @@ public class ThinkOrderParam extends BaseParam {
@TableField(exist = false)
private Boolean forAdmin;
@TableField(exist = false)
private Integer orderTimeStart;
@TableField(exist = false)
private Integer orderTimeEnd;
@TableField(exist = false)
private Boolean useVip;
@TableField(exist = false)
private Boolean isExport;
@TableField(exist = false)
private List<Integer> payTypeList;
}
@@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.gxwebsoft.common.core.annotation.QueryField;
import com.gxwebsoft.common.core.annotation.QueryType;
import com.gxwebsoft.common.core.web.BaseParam;
import com.gxwebsoft.common.system.entity.User;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -83,4 +84,10 @@ public class ThinkSiteParam extends BaseParam {
@TableField(exist = false)
private List<Integer> idList;
@TableField(exist = false)
private User loginUser;
@TableField(exist = false)
private Boolean isAdmin;
}
@@ -0,0 +1,52 @@
package com.gxwebsoft.think.param;
import java.math.BigDecimal;
import com.gxwebsoft.common.core.annotation.QueryField;
import com.gxwebsoft.common.core.annotation.QueryType;
import com.gxwebsoft.common.core.web.BaseParam;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* Vip购卡记录查询参数
*
* @author 科技小王子
* @since 2025-03-25 19:21:56
*/
@Data
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
@ApiModel(value = "ThinkUsersVipBuyLogParam对象", description = "Vip购卡记录查询参数")
public class ThinkUsersVipBuyLogParam extends BaseParam {
private static final long serialVersionUID = 1L;
@QueryField(type = QueryType.EQ)
private Integer id;
@QueryField(type = QueryType.EQ)
private Integer uid;
private String orderNumber;
private String wechetNumber;
@QueryField(type = QueryType.EQ)
private BigDecimal amount;
@QueryField(type = QueryType.EQ)
private Integer payStatus;
private String payTime;
@ApiModelProperty(value = "状态, 0正常, 1冻结")
@QueryField(type = QueryType.EQ)
private Integer status;
@ApiModelProperty(value = "是否删除, 0否, 1是")
@QueryField(type = QueryType.EQ)
private Integer deleted;
}
@@ -5,6 +5,7 @@ import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.think.entity.ThinkCardLog;
import com.gxwebsoft.think.param.ThinkCardLogParam;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
@@ -23,6 +24,8 @@ public interface ThinkCardLogService extends IService<ThinkCardLog> {
*/
PageResult<ThinkCardLog> pageRel(ThinkCardLogParam param);
PageResult<ThinkCardLog> pageRel(ThinkCardLogParam param, HttpServletRequest request);
/**
* 关联查询全部
*
@@ -6,6 +6,8 @@ import com.gxwebsoft.think.entity.ThinkCard;
import com.gxwebsoft.think.entity.ThinkUsers;
import com.gxwebsoft.think.param.ThinkCardParam;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
/**
@@ -42,7 +44,15 @@ public interface ThinkCardService extends IService<ThinkCard> {
ThinkCard getByCode(String code);
ThinkCard getByOriginCode(String code);
ThinkCard getByCardNum(String cardNum);
List<ThinkCard> userCard(ThinkUsers user);
List<ThinkCard> listByCodeList(List<String> codeList);
HashMap<String, String> createWxCodePay(BigDecimal totalPrice, String orderNo, String desc, String authCode);
HashMap<String, String> checkWechatPayRes(String code);
}
@@ -39,4 +39,5 @@ public interface ThinkInvoiceService extends IService<ThinkInvoice> {
*/
ThinkInvoice getByIdRel(Integer id);
ThinkInvoice getData(ThinkInvoiceParam param);
}
@@ -40,4 +40,6 @@ public interface ThinkMachineOpenLogService extends IService<ThinkMachineOpenLog
ThinkMachineOpenLog getByIdRel(Integer id);
ThinkMachineOpenLog getByOrderId(Integer orderId);
List<ThinkMachineOpenLog> listByOids(List<Integer> orderIds);
}
@@ -41,5 +41,9 @@ public interface ThinkOrderInfoService extends IService<ThinkOrderInfo> {
List<ThinkOrderInfo> listInOrder(Integer orderId);
List<ThinkOrderInfo> listByOrderIds(List<Integer> orderIdList);
ThinkOrderInfo checkOrder(ThinkOrderInfo thinkOrderInfo);
List<ThinkOrderInfo> checkOrderList(ThinkOrderInfo thinkOrderInfo);
}
@@ -44,8 +44,12 @@ public interface ThinkOrderService extends IService<ThinkOrder> {
*/
ThinkOrder getByIdRel(Integer id);
Map<String, Object> getOrderByQrCode(String qrCode);
Map<String, Object> getByQrCode(String qrCode);
Map<String, Object> getByQrCode(String qrCode, Boolean check);
ThinkOrder getByOrderNum(String orderNum);
// HashMap<String, String> createWxOrder(ThinkOrder order);
@@ -54,10 +58,17 @@ public interface ThinkOrderService extends IService<ThinkOrder> {
HashMap<String, String> createWxOrder(BigDecimal totalPrice, String orderNo, String desc, String openid, String notify);
HashMap<String, String> createWxCodePay(BigDecimal totalPrice, String orderNo, String desc, String authCode);
HashMap<String, String> checkWechatPayRes(String orderNo);
Refund refund(ThinkOrderRefundLog orderRefund);
ThinkOrder getLastOrderByVid(Integer vid);
ThinkOrder getLastOrderByCardCode(String code);
ThinkOrder getTodayOrder(Integer userId);
List<ThinkOrder> getTodayOrderInSite(Integer userId, Integer sid);
}
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.think.entity.ThinkRechargeLog;
import com.gxwebsoft.think.param.ThinkRechargeLogParam;
import com.wechat.pay.java.service.refund.model.Refund;
import java.util.List;
@@ -39,4 +40,9 @@ public interface ThinkRechargeLogService extends IService<ThinkRechargeLog> {
*/
ThinkRechargeLog getByIdRel(Integer id);
ThinkRechargeLog getByOrderNumber(String orderNum);
ThinkRechargeLog getByRefundNumber(String refundNum);
Refund refund(ThinkRechargeLog thinkRechargeLog);
}
@@ -40,4 +40,6 @@ public interface ThinkSiteTimeService extends IService<ThinkSiteTime> {
ThinkSiteTime getByIdRel(Integer id);
ThinkSiteTime getBySidNPeriod(Integer sid, String period);
List<ThinkSiteTime> getActiveList(Integer sid);
}
@@ -0,0 +1,43 @@
package com.gxwebsoft.think.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.think.entity.ThinkUsersVipBuyLog;
import com.gxwebsoft.think.param.ThinkUsersVipBuyLogParam;
import java.util.List;
/**
* Vip购卡记录Service
*
* @author 科技小王子
* @since 2025-03-25 19:21:56
*/
public interface ThinkUsersVipBuyLogService extends IService<ThinkUsersVipBuyLog> {
/**
* 分页关联查询
*
* @param param 查询参数
* @return PageResult<ThinkUsersVipBuyLog>
*/
PageResult<ThinkUsersVipBuyLog> pageRel(ThinkUsersVipBuyLogParam param);
/**
* 关联查询全部
*
* @param param 查询参数
* @return List<ThinkUsersVipBuyLog>
*/
List<ThinkUsersVipBuyLog> listRel(ThinkUsersVipBuyLogParam param);
/**
* 根据id查询
*
* @param id
* @return ThinkUsersVipBuyLog
*/
ThinkUsersVipBuyLog getByIdRel(Integer id);
ThinkUsersVipBuyLog getByOrderNumber(String orderNumber);
}
@@ -1,8 +1,11 @@
package com.gxwebsoft.think.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.common.core.security.JwtUtil;
import com.gxwebsoft.common.core.utils.RequestUtil;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.system.entity.User;
import com.gxwebsoft.think.entity.ThinkCardLog;
import com.gxwebsoft.think.mapper.ThinkCardLogMapper;
import com.gxwebsoft.think.param.ThinkCardLogParam;
@@ -11,6 +14,7 @@ import com.gxwebsoft.think.service.ThinkCardService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
@@ -25,13 +29,35 @@ public class ThinkCardLogServiceImpl extends ServiceImpl<ThinkCardLogMapper, Thi
private ThinkCardService thinkCardService;
@Override
public PageResult<ThinkCardLog> pageRel(ThinkCardLogParam param) {
public PageResult<ThinkCardLog> pageRel(ThinkCardLogParam param, HttpServletRequest request) {
PageParam<ThinkCardLog, ThinkCardLogParam> page = new PageParam<>(param);
page.setDefaultOrder("id desc, create_time desc");
List<ThinkCardLog> list = baseMapper.selectPageRel(page, param);
if (list != null && !list.isEmpty()) {
RequestUtil requestUtil = null;
if (request != null) {
requestUtil = new RequestUtil();
requestUtil.setAccessToken(JwtUtil.getAccessToken(request));
requestUtil.setTenantId("10150");
}
for (ThinkCardLog thinkCardLog : list) {
thinkCardLog.setThinkCard(thinkCardService.getByCode(thinkCardLog.getCode()));
if (requestUtil != null) {
if (thinkCardLog.getAid() != null && !thinkCardLog.getAid().equals(0)) {
User admin = requestUtil.getByUserId(thinkCardLog.getAid());
if (admin != null) thinkCardLog.setAdminName(admin.getRealName());
}
}
}
}
return new PageResult<>(list, page.getTotal());
}
public PageResult<ThinkCardLog> pageRel(ThinkCardLogParam param) {
return pageRel(param, null);
}
@Override
public List<ThinkCardLog> listRel(ThinkCardLogParam param) {
List<ThinkCardLog> list = baseMapper.selectListRel(param);
@@ -3,6 +3,7 @@ package com.gxwebsoft.think.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.think.entity.ThinkUsers;
import com.gxwebsoft.think.entity.ThinkVip;
import com.gxwebsoft.think.mapper.ThinkCardMapper;
import com.gxwebsoft.think.service.ThinkCardService;
import com.gxwebsoft.think.entity.ThinkCard;
@@ -10,11 +11,23 @@ import com.gxwebsoft.think.param.ThinkCardParam;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.think.service.ThinkSiteService;
import com.gxwebsoft.think.service.ThinkVipService;
import com.gxwebsoft.think.service.WechatConfigService;
import com.wechat.pay.java.core.Config;
import com.wechat.pay.java.core.exception.ServiceException;
import com.wechat.pay.java.service.payments.jsapi.model.QueryOrderByOutTradeNoRequest;
import com.wechat.pay.java.service.payments.model.Transaction;
import com.wechat.pay.java.service.payments.wxcodepay.CodePayService;
import com.wechat.pay.java.service.payments.wxcodepay.model.PrepayResponse;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* Service实现
@@ -26,15 +39,30 @@ import java.util.List;
public class ThinkCardServiceImpl extends ServiceImpl<ThinkCardMapper, ThinkCard> implements ThinkCardService {
@Resource
private ThinkSiteService thinkSiteService;
@Resource
private WechatConfigService wechatConfigService;
@Resource
private ThinkVipService thinkVipService;
// private String mchId = "1604773943";
private String mchId = "1246610101";
private String appId = "wxd38cc38c54fa7370";
@Override
public PageResult<ThinkCard> pageRel(ThinkCardParam param) {
PageParam<ThinkCard, ThinkCardParam> page = new PageParam<>(param);
page.setDefaultOrder("id desc, create_time desc");
if (param.getOrderBy() != null) {
page.setDefaultOrder(param.getOrderBy());
} else page.setDefaultOrder("id desc, create_time desc");
List<ThinkCard> list = baseMapper.selectPageRel(page, param);
for (ThinkCard item : list) {
String[] sids = item.getSid().split(",");
item.setSiteList(thinkSiteService.listByIds(Arrays.stream(sids).map(Integer::valueOf).toList()));
if (!list.isEmpty()) {
Set<Integer> vidList = list.stream().map(ThinkCard::getVid).collect(Collectors.toSet());
List<ThinkVip> vipList = thinkVipService.listByIds(vidList);
for (ThinkCard item : list) {
String[] sids = item.getSid().split(",");
item.setSiteList(thinkSiteService.listByIds(Arrays.stream(sids).map(Integer::valueOf).toList()));
item.setThinkVip(vipList.stream().filter(item1 -> item1.getId().equals(item.getVid())).findFirst().orElse(null));
}
}
return new PageResult<>(list, page.getTotal());
}
@@ -62,11 +90,28 @@ public class ThinkCardServiceImpl extends ServiceImpl<ThinkCardMapper, ThinkCard
return param.getOne(baseMapper.selectListRel(param));
}
@Override
public ThinkCard getByOriginCode(String code) {
return getOne(
new LambdaQueryWrapper<ThinkCard>()
.eq(ThinkCard::getOriginCardCode, code)
.last("limit 1")
);
}
@Override
public ThinkCard getByCardNum(String cardNum) {
ThinkCardParam param = new ThinkCardParam();
param.setCardNum(cardNum);
return param.getOne(baseMapper.selectListRel(param));
}
@Override
public List<ThinkCard> userCard(ThinkUsers user) {
return list(
new LambdaQueryWrapper<ThinkCard>()
.eq(ThinkCard::getUid, user.getId())
// .eq(ThinkCard::getUid, user.getId())
.eq(ThinkCard::getPhone, user.getPhone())
.eq(ThinkCard::getStatus, 1)
.isNotNull(ThinkCard::getExpireTime)
.and(w -> w.or(w1 -> w1.gt(ThinkCard::getNum, 0))
@@ -84,4 +129,81 @@ public class ThinkCardServiceImpl extends ServiceImpl<ThinkCardMapper, ThinkCard
);
}
/***
* 扫码支付
* @param totalPrice
* @param orderNo
* @param desc
* @param authCode
* @return
*/
@Override
public HashMap<String, String> createWxCodePay(BigDecimal totalPrice, String orderNo, String desc, String authCode) {
final HashMap<String, String> orderInfo = new HashMap<>();
// 计算金额
// BigDecimal decimal = order.getTotalPrice();
final BigDecimal multiply = totalPrice.multiply(new BigDecimal(100));
Integer money = multiply.intValue();
Config wxConfig = wechatConfigService.getConfig();
com.wechat.pay.java.service.payments.wxcodepay.model.Amount amount = new com.wechat.pay.java.service.payments.wxcodepay.model.Amount();
amount.setTotal(money);
amount.setCurrency("CNY");
amount.setTotal(money);
CodePayService service = new CodePayService.Builder().config(wxConfig).build();
com.wechat.pay.java.service.payments.wxcodepay.model.PrepayRequest prepayRequest = new com.wechat.pay.java.service.payments.wxcodepay.model.PrepayRequest();
prepayRequest.setAppid(appId);
prepayRequest.setMchid(mchId);
prepayRequest.setDescription(desc);
prepayRequest.setOutTradeNo(orderNo);
prepayRequest.setAmount(amount);
com.wechat.pay.java.service.payments.wxcodepay.model.Payer payer = new com.wechat.pay.java.service.payments.wxcodepay.model.Payer();
payer.setAuthCode(authCode);
prepayRequest.setPayer(payer);
com.wechat.pay.java.service.payments.wxcodepay.model.SceneInfo sceneInfo = new com.wechat.pay.java.service.payments.wxcodepay.model.SceneInfo();
com.wechat.pay.java.service.payments.wxcodepay.model.StoreInfo storeInfo = new com.wechat.pay.java.service.payments.wxcodepay.model.StoreInfo();
storeInfo.setId("0002");
sceneInfo.setStoreInfo(storeInfo);
prepayRequest.setSceneInfo(sceneInfo);
PrepayResponse prepayResponse = service.prepay(prepayRequest);
System.out.println(prepayResponse.toString());
return orderInfo;
}
@Override
public HashMap<String, String> checkWechatPayRes(String code) {
QueryOrderByOutTradeNoRequest queryRequest = new QueryOrderByOutTradeNoRequest();
queryRequest.setMchid(mchId);
queryRequest.setOutTradeNo(code);
try {
Config wxConfig = wechatConfigService.getConfig();
CodePayService service = new CodePayService.Builder().config(wxConfig).build();
Transaction result = service.queryOrderByOutTradeNo(queryRequest);
if (result.getTradeState().equals(Transaction.TradeStateEnum.SUCCESS)) {
ThinkCard thinkCard = getOne(new LambdaQueryWrapper<ThinkCard>()
.eq(ThinkCard::getCode, code)
.orderByDesc(ThinkCard::getId)
.last("limit 1")
);
thinkCard.setPayType(1);
thinkCard.setStatus(1);
thinkCard.setWechatOrder(result.getTransactionId());
updateById(thinkCard);
}
return new HashMap<>() {{
put("state", result.getTradeState().toString());
put("stateDesc", result.getTradeStateDesc());
}};
} catch (ServiceException e) {
// API返回失败, 例如ORDER_NOT_EXISTS
System.out.printf("code=[%s], message=[%s]\n", e.getErrorCode(), e.getErrorMessage());
System.out.printf("reponse body=[%s]\n", e.getResponseBody());
return new HashMap<>() {{
put("state", "FAIL");
put("stateDesc", e.getErrorMessage());
}};
}
}
}
@@ -68,7 +68,7 @@ public class ThinkDepositServiceImpl extends ServiceImpl<ThinkDepositMapper, Thi
Config wxConfig = wechatConfigService.getConfig();
RefundService service = new RefundService.Builder().config(wxConfig).build();
CreateRequest request = new CreateRequest();
String refundNotifyUrl = "https://gxtyzx-api.websoft.top/api/think/think-deposit/refund-notify";
String refundNotifyUrl = "https://gxtyzx-api2.websoft.top/api/think/think-deposit/refund-notify";
// 金额
AmountReq amount = new AmountReq();
amount.setTotal(thinkDeposit.getMoney().multiply(BigDecimal.valueOf(100)).longValue());
@@ -66,13 +66,16 @@ public class ThinkFieldServiceImpl extends ServiceImpl<ThinkFieldMapper, ThinkFi
List<ThinkField> list = list(
new LambdaQueryWrapper<ThinkField>()
.eq(ThinkField::getSid, param.getSid())
.eq(ThinkField::getIsStatus, 1)
.orderByDesc(ThinkField::getSort)
);
List<ThinkOrder> orderList = new ArrayList<>();
List<ThinkOrderInfo> orderInfoList = new ArrayList<>();
if (!list.isEmpty()) {
List<Integer> fidList = list.stream().map(ThinkField::getId).toList();
List<ThinkOrderInfo> orderInfoList = thinkOrderInfoService.list(
orderInfoList = thinkOrderInfoService.list(
new LambdaQueryWrapper<ThinkOrderInfo>()
.ne(ThinkOrderInfo::getPayStatus, 0)
.in(ThinkOrderInfo::getFid, fidList)
.in(ThinkOrderInfo::getStartTime, param.getPeriodVoList().stream().map(FieldPeriodVo::getTimestamp).toList())
);
@@ -80,16 +83,23 @@ public class ThinkFieldServiceImpl extends ServiceImpl<ThinkFieldMapper, ThinkFi
orderList = thinkOrderService.list(
new LambdaQueryWrapper<ThinkOrder>()
.in(ThinkOrder::getId, orderInfoList.stream().map(ThinkOrderInfo::getOid).toList())
.in(ThinkOrder::getStartTime, param.getPeriodVoList().stream().map(FieldPeriodVo::getTimestamp).toList())
// .in(ThinkOrder::getStartTime, param.getPeriodVoList().stream().map(FieldPeriodVo::getTimestamp).toList())
.in(ThinkOrder::getOrderStatus, ORDER_STATUS_DONE,
ORDER_STATUS_UNUSED,
ORDER_STATUS_CANCELING,
ORDER_STATUS_CANCEL_REFUSE)
ORDER_STATUS_CANCELING)
);
if (!orderList.isEmpty()) {
for (ThinkOrder order : orderList) {
for (ThinkOrderInfo orderInfo : orderInfoList) {
if (orderInfo.getOid().equals(order.getId())) order.setFid(orderInfo.getFid());
for (ThinkOrderInfo orderInfo : orderInfoList) {
orderInfo.setUsed(false);
orderInfo.setSoldButNotUsed(false);
for (ThinkOrder order : orderList) {
if (orderInfo.getOid().equals(order.getId())) {
if (order.getOrderStatus().equals(ORDER_STATUS_DONE)) orderInfo.setUsed(true);
if (order.getOrderStatus().equals(ORDER_STATUS_UNUSED))
orderInfo.setSoldButNotUsed(true);
orderInfo.setAddFromAdmin(order.getAddFromAdmin().equals(1));
}
}
}
}
@@ -103,16 +113,27 @@ public class ThinkFieldServiceImpl extends ServiceImpl<ThinkFieldMapper, ThinkFi
tmpFieldPeriodVo.setPeriod(fieldPeriodVo.getPeriod());
tmpFieldPeriodVo.setTimestamp(fieldPeriodVo.getTimestamp());
tmpFieldPeriodVo.setSold(false);
tmpFieldPeriodVo.setTook(false);
tmpFieldPeriodVo.setId(fieldPeriodVo.getId());
tmpFieldPeriodVoList.add(tmpFieldPeriodVo);
}
if (field.getIsRepeat().equals(2)) {
if (!orderList.isEmpty()) {
for (ThinkOrder order : orderList) {
if (field.getId().equals(order.getFid())) {
if (!orderInfoList.isEmpty()) {
for (ThinkOrderInfo orderInfo : orderInfoList) {
if (field.getId().equals(orderInfo.getFid())) {
for (FieldPeriodVo fieldPeriodVo : tmpFieldPeriodVoList) {
if (fieldPeriodVo.getTimestamp().equals(order.getStartTime())) {
fieldPeriodVo.setSold(true);
if (fieldPeriodVo.getTimestamp().equals(orderInfo.getStartTime().toString())) {
fieldPeriodVo.setOrderId(orderInfo.getOid());
fieldPeriodVo.setAddFromAdmin(orderInfo.getAddFromAdmin());
fieldPeriodVo.setPayStatus(orderInfo.getPayStatus());
if (orderInfo.getUsed() != null) {
if (orderInfo.getUsed()) fieldPeriodVo.setSold(true);
} else {
fieldPeriodVo.setSold(false);
}
if (orderInfo.getSoldButNotUsed() != null) {
if (orderInfo.getSoldButNotUsed()) fieldPeriodVo.setTook(true);
} else fieldPeriodVo.setTook(false);
}
}
}
@@ -24,7 +24,6 @@ public class ThinkGoodsOrderInfoServiceImpl extends ServiceImpl<ThinkGoodsOrderI
@Override
public PageResult<ThinkGoodsOrderInfo> pageRel(ThinkGoodsOrderInfoParam param) {
PageParam<ThinkGoodsOrderInfo, ThinkGoodsOrderInfoParam> page = new PageParam<>(param);
page.setDefaultOrder("create_time desc");
List<ThinkGoodsOrderInfo> list = baseMapper.selectPageRel(page, param);
return new PageResult<>(list, page.getTotal());
}
@@ -34,7 +33,6 @@ public class ThinkGoodsOrderInfoServiceImpl extends ServiceImpl<ThinkGoodsOrderI
List<ThinkGoodsOrderInfo> list = baseMapper.selectListRel(param);
// 排序
PageParam<ThinkGoodsOrderInfo, ThinkGoodsOrderInfoParam> page = new PageParam<>();
page.setDefaultOrder("create_time desc");
return page.sortRecords(list);
}
@@ -1,5 +1,6 @@
package com.gxwebsoft.think.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.think.mapper.ThinkInvoiceMapper;
import com.gxwebsoft.think.service.ThinkInvoiceService;
@@ -44,4 +45,18 @@ public class ThinkInvoiceServiceImpl extends ServiceImpl<ThinkInvoiceMapper, Thi
return param.getOne(baseMapper.selectListRel(param));
}
@Override
public ThinkInvoice getData(ThinkInvoiceParam param) {
QueryWrapper<ThinkInvoice> queryWrapper = new QueryWrapper<>();
queryWrapper.select("sum(price) as price")
.eq("is_open", 1);
if (param.getCreateTimeStart() != null) {
queryWrapper.ge("create_time", param.getCreateTimeStart());
if (param.getCreateTimeEnd() != null) {
queryWrapper.le("create_time", param.getCreateTimeEnd());
}
}
return getOne(queryWrapper);
}
}
@@ -1,5 +1,6 @@
package com.gxwebsoft.think.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.think.mapper.ThinkMachineOpenLogMapper;
import com.gxwebsoft.think.service.ThinkMachineOpenLogService;
@@ -51,4 +52,12 @@ public class ThinkMachineOpenLogServiceImpl extends ServiceImpl<ThinkMachineOpen
return param.getOne(baseMapper.selectListRel(param));
}
@Override
public List<ThinkMachineOpenLog> listByOids(List<Integer> orderIds) {
return list(
new LambdaQueryWrapper<ThinkMachineOpenLog>()
.in(ThinkMachineOpenLog::getOrderId, orderIds)
);
}
}
@@ -53,6 +53,14 @@ public class ThinkOrderInfoServiceImpl extends ServiceImpl<ThinkOrderInfoMapper,
);
}
@Override
public List<ThinkOrderInfo> listByOrderIds(List<Integer> orderIdList) {
return list(
new LambdaQueryWrapper<ThinkOrderInfo>()
.in(ThinkOrderInfo::getOid, orderIdList)
);
}
@Override
public ThinkOrderInfo checkOrder(ThinkOrderInfo thinkOrderInfo) {
return getOne(
@@ -60,8 +68,19 @@ public class ThinkOrderInfoServiceImpl extends ServiceImpl<ThinkOrderInfoMapper,
.eq(ThinkOrderInfo::getSid, thinkOrderInfo.getSid())
.eq(ThinkOrderInfo::getFid, thinkOrderInfo.getFid())
.eq(ThinkOrderInfo::getStartTime, thinkOrderInfo.getStartTime())
.eq(ThinkOrderInfo::getPayStatus, 1)
.ne(ThinkOrderInfo::getPayStatus, 0)
.last("limit 1")
);
}
@Override
public List<ThinkOrderInfo> checkOrderList(ThinkOrderInfo thinkOrderInfo) {
return list(
new LambdaQueryWrapper<ThinkOrderInfo>()
.eq(ThinkOrderInfo::getSid, thinkOrderInfo.getSid())
.eq(ThinkOrderInfo::getFid, thinkOrderInfo.getFid())
.eq(ThinkOrderInfo::getStartTime, thinkOrderInfo.getStartTime())
.ne(ThinkOrderInfo::getPayStatus, 0)
);
}
}
@@ -1,39 +1,45 @@
package com.gxwebsoft.think.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.crypto.symmetric.SymmetricAlgorithm;
import cn.hutool.crypto.symmetric.SymmetricCrypto;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.common.core.config.ConfigProperties;
import com.gxwebsoft.common.core.utils.RedisUtil;
import com.gxwebsoft.think.entity.ThinkOrderInfo;
import com.gxwebsoft.think.entity.ThinkOrderRefundLog;
import com.gxwebsoft.think.controller.ThinkOrderController;
import com.gxwebsoft.think.entity.*;
import com.gxwebsoft.think.mapper.ThinkOrderMapper;
import com.gxwebsoft.think.service.*;
import com.gxwebsoft.think.entity.ThinkOrder;
import com.gxwebsoft.think.param.ThinkOrderParam;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import com.wechat.pay.java.core.Config;
import com.wechat.pay.java.core.exception.ServiceException;
import com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension;
import com.wechat.pay.java.service.payments.jsapi.model.Amount;
import com.wechat.pay.java.service.payments.jsapi.model.Payer;
import com.wechat.pay.java.service.payments.jsapi.model.PrepayRequest;
import com.wechat.pay.java.service.payments.jsapi.model.PrepayWithRequestPaymentResponse;
import com.wechat.pay.java.service.payments.jsapi.model.*;
import com.wechat.pay.java.service.payments.model.Transaction;
import com.wechat.pay.java.service.payments.wxcodepay.CodePayService;
import com.wechat.pay.java.service.payments.wxcodepay.model.PrepayResponse;
import com.wechat.pay.java.service.refund.RefundService;
import com.wechat.pay.java.service.refund.model.AmountReq;
import com.wechat.pay.java.service.refund.model.CreateRequest;
import com.wechat.pay.java.service.refund.model.Refund;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Base64;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
* Service实现
@@ -55,45 +61,151 @@ public class ThinkOrderServiceImpl extends ServiceImpl<ThinkOrderMapper, ThinkOr
private ThinkCardService thinkCardService;
@Resource
private ThinkUsersVipService thinkUsersVipService;
@Resource
private ThinkUsersService thinkUsersService;
@Resource
private ThinkSiteService thinkSiteService;
@Resource
private ThinkSiteTimeService thinkSiteTimeService;
@Resource
private ThinkOrderService thinkOrderService;
@Resource
private ThinkFieldService thinkFieldService;
@Resource
private ThinkMachineOpenLogService thinkMachineOpenLogService;
private Config wxConfig;
@Autowired
private ThinkOrderController thinkOrderController;
// public static String privateKeyPath = "/Users/liangxin/Project/JAVA/gxtyzx-java/file/93dc8f750fee4eeaa5fb0a768982d639.pem";
// public static String privateKeyPath = "/www/jar/gxtyzx-java/file/93dc8f750fee4eeaa5fb0a768982d639.pem";
// public static String privateCertPath = "/Users/liangxin/Project/JAVA/gxtyzx-java/file/0666cd9ad86a4ac1be6a350a2666929e.pem";
// public static String wechatpayCertPath = "/Users/gxwebsoft/Downloads/ef7f7e0430cb47019d06b93f885bf95f/wechatpay_55729BDEC2502C301BA02CDC28E4CEE4DE4D1DB9.pem"; // 平台证书
private String mchId = "1604773943";
// private String mchId = "1246610101";
private String appId = "wxd38cc38c54fa7370";
@Override
public PageResult<ThinkOrder> pageRel(ThinkOrderParam param) {
PageParam<ThinkOrder, ThinkOrderParam> page = new PageParam<>(param);
page.setDefaultOrder("create_time desc");
List<ThinkOrder> list = baseMapper.selectPageRel(page, param);
list.forEach(d -> {
d.setThinkOrderInfos(thinkOrderInfoService.list(new LambdaQueryWrapper<ThinkOrderInfo>().eq(ThinkOrderInfo::getOid, d.getId())));
if (d.getCid() != null && !d.getCid().equals(0)) {
d.setCard(thinkCardService.getById(d.getCid()));
List<Integer> sidList = new ArrayList<>();
if (!list.isEmpty()) sidList = list.stream().map(ThinkOrder::getSid).toList();
if (!sidList.isEmpty()) {
List<ThinkSite> siteList = thinkSiteService.listByIds(sidList);
list.forEach(d -> {
d.setSiteName(siteList.stream().filter(s -> s.getId().equals(d.getSid())).findFirst().orElse(new ThinkSite()).getName());
});
}
if (!list.isEmpty()) {
List<Integer> idList = list.stream().map(ThinkOrder::getId).toList();
List<Integer> cidList = list.stream().filter(i -> ObjectUtil.isNotNull(i.getCid()) && !i.getCid().equals(0))
.map(ThinkOrder::getCid).toList();
List<Integer> vidList = list.stream().filter(i -> ObjectUtil.isNotNull(i.getVid()) && !i.getVid().equals(0))
.map(ThinkOrder::getVid).toList();
List<ThinkCard> thinkCardList;
if (!cidList.isEmpty()) {
thinkCardList = thinkCardService.listByIds(cidList);
} else {
thinkCardList = new ArrayList<>();
}
if (d.getVid() != null && !d.getVid().equals(0)) {
d.setThinkVip(thinkUsersVipService.getById(d.getVid()));
List<ThinkUsersVip> thinkUsersVipList;
if (!vidList.isEmpty()) {
thinkUsersVipList = thinkUsersVipService.listByIds(vidList);
} else {
thinkUsersVipList = new ArrayList<>();
}
});
List<ThinkMachineOpenLog> thinkMachineOpenLogList = thinkMachineOpenLogService.listByOids(idList);
List<ThinkOrderInfo> thinkOrderInfoArr = thinkOrderInfoService.listByOrderIds(idList);
list.forEach(d -> {
List<ThinkOrderInfo> thinkOrderInfoList = thinkOrderInfoArr.stream().filter(i -> i.getOid().equals(d.getId())).toList();
StringBuilder dateTimeList = new StringBuilder();
if (!thinkOrderInfoList.isEmpty()) {
for (ThinkOrderInfo thinkOrderInfo : thinkOrderInfoList) {
String dateTime = thinkOrderInfo.getDateTime();
dateTime += "(" + thinkOrderInfo.getFieldName() + ")";
if (dateTimeList.isEmpty()) {
dateTimeList = new StringBuilder(dateTime);
} else {
dateTimeList.append(",").append(dateTime);
}
}
d.setDateTime(dateTimeList.toString());
}
d.setThinkOrderInfos(thinkOrderInfoList);
if (thinkCardList != null && !thinkCardList.isEmpty() && d.getCid() != null && !d.getCid().equals(0)) {
d.setCard(thinkCardList.stream().filter(c -> c.getId().equals(d.getCid())).findFirst().orElse(null));
}
if (thinkUsersVipList != null && !thinkUsersVipList.isEmpty() && d.getVid() != null && !d.getVid().equals(0)) {
d.setThinkVip(thinkUsersVipList.stream().filter(c -> c.getId().equals(d.getVid()))
.findFirst().orElse(null));
}
if (d.getSid().equals(37))
d.setMachineOpenLog(thinkMachineOpenLogList.stream().filter(c -> c.getOrderId().equals(d.getId()))
.findFirst().orElse(null));
});
}
return new PageResult<>(list, page.getTotal());
}
@Override
public List<ThinkOrder> listRel(ThinkOrderParam param) {
List<ThinkOrder> list = baseMapper.selectListRel(param);
if (list.isEmpty()) return list;
List<Integer> sidList = new ArrayList<>();
if (!list.isEmpty()) sidList = list.stream().map(ThinkOrder::getSid).toList();
if (!sidList.isEmpty()) {
List<ThinkSite> siteList = thinkSiteService.listByIds(sidList);
list.forEach(d -> {
d.setSiteName(siteList.stream().filter(s -> s.getId().equals(d.getSid())).findFirst().orElse(new ThinkSite()).getName());
});
}
List<ThinkOrderInfo> orderInfoList = thinkOrderInfoService.listByOrderIds(list.stream().map(ThinkOrder::getId).toList());
Set<Integer> cidList = new HashSet<>();
Set<String> codeList = new HashSet<>();
Set<Integer> vidList = new HashSet<>();
list.forEach(d -> {
d.setThinkOrderInfos(thinkOrderInfoService.list(new LambdaQueryWrapper<ThinkOrderInfo>().eq(ThinkOrderInfo::getOid, d.getId())));
if (d.getCid() != null && !d.getCid().equals(0)) {
d.setCard(thinkCardService.getById(d.getCid()));
cidList.add(d.getCid());
}
if (d.getCode() != null && !d.getCode().isEmpty() && !d.getCode().equals("0")) {
codeList.add(d.getCode());
}
if (d.getVid() != null && !d.getVid().equals(0)) {
d.setThinkVip(thinkUsersVipService.getById(d.getVid()));
vidList.add(d.getVid());
}
StringBuilder dateTimeList = new StringBuilder();
});
List<ThinkCard> cardList = new ArrayList<>();
if (!cidList.isEmpty()) cardList = thinkCardService.listByIds(new ArrayList<>(cidList));
if (!codeList.isEmpty()) {
List<ThinkCard> cardListByCode = thinkCardService.listByCodeList(new ArrayList<>(codeList));
// 合并
cardList.addAll(cardListByCode);
}
List<ThinkUsersVip> vipList = thinkUsersVipService.listByIds(new ArrayList<>(vidList));
for (ThinkOrder d : list) {
List<ThinkOrderInfo> thinkOrderInfoList = thinkOrderInfoService.listInOrder(d.getId());
StringBuilder dateTimeList = new StringBuilder();
if (!thinkOrderInfoList.isEmpty()) {
for (ThinkOrderInfo thinkOrderInfo : thinkOrderInfoList) {
String dateTime = thinkOrderInfo.getDateTime();
dateTime += "(" + thinkOrderInfo.getFieldName() + ")";
if (dateTimeList.isEmpty()) {
dateTimeList = new StringBuilder(dateTime);
} else {
dateTimeList.append(",").append(dateTime);
}
}
d.setDateTime(dateTimeList.toString());
}
d.setThinkOrderInfos(thinkOrderInfoList);
if (!cardList.isEmpty())
d.setCard(cardList.stream().filter(c -> c.getId().equals(d.getCid())).findFirst().orElse(null));
d.setThinkVip(vipList.stream().filter(c -> c.getId().equals(d.getVid())).findFirst().orElse(null));
}
// 排序
PageParam<ThinkOrder, ThinkOrderParam> page = new PageParam<>();
page.setDefaultOrder("create_time desc");
@@ -112,7 +224,7 @@ public class ThinkOrderServiceImpl extends ServiceImpl<ThinkOrderMapper, ThinkOr
}
@Override
public Map<String, Object> getByQrCode(String qrCode) {
public Map<String, Object> getOrderByQrCode(String qrCode) {
String secretKey = redisUtil.get("secretKey_10150");
byte[] key = null;
if (secretKey == null) {
@@ -125,15 +237,273 @@ public class ThinkOrderServiceImpl extends ServiceImpl<ThinkOrderMapper, ThinkOr
try {
String data = aes.decryptStr(qrCode);
String[] idArr = data.split("_");
// if ((int) (System.currentTimeMillis() / 1000) > Long.parseLong(idArr[1]) + 120) {
// return new HashMap<>() {{
// put("res", false);
// put("msg", "核销码已过期");
// }};
// }
ThinkOrderParam param = new ThinkOrderParam();
param.setId(Integer.valueOf(idArr[0]));
final ThinkOrder thinkOrder = param.getOne(baseMapper.selectListRel(param));
if ((int) (System.currentTimeMillis() / 1000) > Long.parseLong(idArr[1]) + 30) {
return new HashMap<>() {{
put("res", false);
put("msg", "核销码已过期");
}};
}
if (idArr.length == 3) return new HashMap<>() {{
put("res", false);
put("msg", "二维码不正确");
}};
return getOrder(idArr);
} catch (Exception e) {
System.out.println(e.getMessage());
System.out.println(e.getStackTrace());
return new HashMap<>() {{
put("res", false);
put("msg", "系统错误");
}};
}
}
@Override
public Map<String, Object> getByQrCode(String qrCode) {
return getByQrCode(qrCode, true);
}
@Override
public Map<String, Object> getByQrCode(String qrCode, Boolean check) {
String secretKey = redisUtil.get("secretKey_10150");
if (check) {
if (redisUtil.get(qrCode) != null) {
return new HashMap<>() {{
put("res", false);
put("msg", "该核销码已被使用");
}};
}
}
byte[] key = null;
if (secretKey == null) {
key = SecureUtil.generateKey(SymmetricAlgorithm.AES.getValue()).getEncoded();
redisUtil.set("secretKey_10150", Base64.getEncoder().encodeToString(key));
} else {
key = Base64.getDecoder().decode(secretKey);
}
SymmetricCrypto aes = new SymmetricCrypto(SymmetricAlgorithm.AES, key);
try {
String data = aes.decryptStr(qrCode);
String[] idArr = data.split("_");
System.out.println("qr code decrypted: " + data);
long expiredSec = 30;
// long expiredSec = 24 * 3600;
if (idArr.length == 4 && idArr[3].equals("forDevice")) {
// 截止今天21:45
expiredSec = 600;
}
if (check) {
if ((int) (System.currentTimeMillis() / 1000) > Long.parseLong(idArr[1]) + expiredSec) {
return new HashMap<>() {{
put("res", false);
put("msg", "核销码已过期");
}};
}
}
if (idArr.length == 3) {
if (idArr[2].equals("vipCard")) {
ThinkUsersVip thinkUsersVip = thinkUsersVipService.getById(Integer.valueOf(idArr[0]));
if (check) {
if (thinkUsersVip.getExpireTime() < System.currentTimeMillis() / 1000) {
return new HashMap<>() {{
put("res", false);
put("msg", "该会员卡已过期");
}};
}
if (!thinkUsersVip.getType().equals(1) && !thinkUsersVip.getType().equals(3)) {
return new HashMap<>() {{
put("res", false);
put("msg", "无法使用,code:0.");
}};
}
long todayTime = DateUtil.parse(DateUtil.today() + " 00:00:00").getTime();
if (thinkUsersVip.getUseTime().equals(todayTime / 1000)) {
return new HashMap<>() {{
put("res", false);
put("msg", "今天已使用");
}};
}
if (!thinkUsersVip.getSid().contains("37")) {
return new HashMap<>() {{
put("res", false);
put("msg", "无法使用,code:1.");
}};
}
}
// 创建订单
ThinkOrder order = new ThinkOrder();
ThinkUsers users = thinkUsersService.getById(thinkUsersVip.getUid());
ThinkSite thinkSite = thinkSiteService.getById(37);
ThinkField thinkField = thinkFieldService.getById(113);
if (check) {
if (thinkSite.getDailyMaxNum() != null && thinkSite.getDailyMaxNum() > 0 && thinkSite.getDailyNum() >= thinkSite.getDailyMaxNum())
return new HashMap<>() {{
put("res", false);
put("msg", "已达上限,无法使用");
}};
}
List<ThinkSiteTime> siteTimeList = thinkSiteTimeService.getActiveList(37);
int currentWeek = DateUtil.dayOfWeek(new Date()) - 1;
if (currentWeek == 0) {
currentWeek = 7;
}
BigDecimal price = new BigDecimal(0);
ThinkSiteTime siteTimeItem = null;
String today = DateUtil.format(new Date(), "yyyy-MM-dd");
String startTimeStr = "";
for (ThinkSiteTime siteTime : siteTimeList) {
JSONArray weekList = JSONUtil.parseArray(siteTime.getWeek());
for (int i = 0; i < weekList.size(); i++) {
if (weekList.getInt(i) == currentWeek) {
String[] timePeriodList = siteTime.getTimePeriod().split(" - ");
LocalDateTime now = LocalDateTimeUtil.now();
LocalDateTime startTime = LocalDateTimeUtil.parse(today + "T" + timePeriodList[0] + ":00");
LocalDateTime endTime = LocalDateTimeUtil.parse(today + "T" + timePeriodList[1] + ":00");
if (now.isAfter(startTime) && now.isBefore(endTime)) {
siteTimeItem = siteTime;
startTimeStr = String.valueOf(startTime.toEpochSecond(ZoneOffset.ofHours(8)));
}
}
}
}
if (siteTimeItem == null) {
return new HashMap<>() {{
put("res", false);
put("msg", "无法使用,code:2.");
}};
}
if (thinkUsersVip.getCardType().equals(1)) price = siteTimeItem.getPrice();
else price = siteTimeItem.getChildrenPrice();
order.setSid(37);
order.setUid(thinkUsersVip.getUid());
order.setVid(thinkUsersVip.getId());
order.setOrderNum(IdUtil.getSnowflake().nextIdStr());
order.setName(users.getUsername());
order.setPhone(users.getPhone());
order.setTotalPrice(price);
order.setReducePrice(price);
order.setPayPrice(price);
order.setPrice(price);
order.setMoney(BigDecimal.ZERO);
order.setRefundMoney(BigDecimal.ZERO);
String str = "";
switch (thinkUsersVip.getType()) {
// 年卡
case 1: {
order.setPayType(7);
order.setType(4);
str = "年卡";
}
break;
// 月卡
case 3: {
order.setPayType(6);
order.setType(3);
str = "月卡";
}
break;
}
order.setDesc("使用VIP" + str + ": " + thinkUsersVip.getName() + ",使用次数:1次。");
order.setStartTime(startTimeStr);
order.setIsInvoice(3);
order.setCreateTime(DateUtil.currentSeconds());
order.setUpdateTime(DateUtil.currentSeconds());
thinkOrderService.save(order);
String weekStr = "";
switch (currentWeek) {
case 1: {
weekStr = "星期一";
}
break;
case 2: {
weekStr = "星期二";
}
break;
case 3: {
weekStr = "星期三";
}
break;
case 4: {
weekStr = "星期四";
}
break;
case 5: {
weekStr = "星期五";
}
break;
case 6: {
weekStr = "星期六";
}
break;
case 7: {
weekStr = "星期日";
}
break;
}
ThinkOrderInfo thinkOrderInfo = new ThinkOrderInfo();
thinkOrderInfo.setOid(order.getId());
thinkOrderInfo.setSid(order.getSid());
thinkOrderInfo.setFid(113);
thinkOrderInfo.setSiteName(thinkSite.getName());
thinkOrderInfo.setFieldName(thinkField.getName());
thinkOrderInfo.setDateTime(today + "(" + weekStr + ")" + siteTimeItem.getTimePeriod());
thinkOrderInfo.setPrice(siteTimeItem.getPrice());
thinkOrderInfo.setChildrenPrice(siteTimeItem.getChildrenPrice());
if (thinkUsersVip.getCardType().equals(1)) {
thinkOrderInfo.setAdultNum(1);
thinkOrderInfo.setChildrenNum(0);
thinkOrderInfo.setIsChildren(2);
} else {
thinkOrderInfo.setAdultNum(0);
thinkOrderInfo.setChildrenNum(1);
thinkOrderInfo.setIsChildren(1);
}
thinkOrderInfo.setIsFree(2);
thinkOrderInfo.setType(1);
String[] timePeriodList = siteTimeItem.getTimePeriod().split(" - ");
thinkOrderInfo.setMergeData(today + timePeriodList[0] + timePeriodList[1] + "37113");
thinkOrderInfo.setStartTime(Integer.valueOf(startTimeStr));
thinkOrderInfo.setOrderTime(DateUtil.currentSeconds());
thinkOrderInfo.setTimeFlag(DateUtil.current());
thinkOrderInfoService.save(thinkOrderInfo);
thinkOrderController.updatePay(order, null, order.getTotalPrice().multiply(BigDecimal.valueOf(100)).intValue());
order.setPayStatus(1);
order.setOrderStatus(1);
thinkOrderService.updateById(order);
redisUtil.set(qrCode, 1, 1L, TimeUnit.HOURS);
return new HashMap<>() {{
put("res", true);
put("data", order);
}};
} else {
return new HashMap<>() {{
put("res", false);
put("msg", "非法请求");
}};
}
} else {
return getOrder(idArr, check);
}
} catch (Exception e) {
System.out.println(e.getMessage());
System.out.println(e.getStackTrace());
return new HashMap<>() {{
put("res", false);
put("msg", "系统错误");
}};
}
}
private Map<String, Object> getOrder(String[] idArr) {
return getOrder(idArr, true);
}
private Map<String, Object> getOrder(String[] idArr, Boolean check) {
ThinkOrderParam param = new ThinkOrderParam();
param.setId(Integer.valueOf(idArr[0]));
final ThinkOrder thinkOrder = param.getOne(baseMapper.selectListRel(param));
if (check) {
if (thinkOrder == null) {
return new HashMap<>() {{
put("res", false);
@@ -152,20 +522,14 @@ public class ThinkOrderServiceImpl extends ServiceImpl<ThinkOrderMapper, ThinkOr
put("msg", "该订单已核销");
}};
}
if (ObjectUtil.isNotEmpty(thinkOrder)) {
thinkOrder.setThinkOrderInfos(thinkOrderInfoService.list(new LambdaQueryWrapper<ThinkOrderInfo>().eq(ThinkOrderInfo::getOid, thinkOrder.getId())));
}
return new HashMap<>() {{
put("res", true);
put("data", thinkOrder);
}};
} catch (Exception e) {
System.out.println(e.getMessage());
return new HashMap<>() {{
put("res", false);
put("msg", "核销码错误");
}};
}
if (ObjectUtil.isNotEmpty(thinkOrder)) {
thinkOrder.setThinkOrderInfos(thinkOrderInfoService.list(new LambdaQueryWrapper<ThinkOrderInfo>().eq(ThinkOrderInfo::getOid, thinkOrder.getId())));
}
return new HashMap<>() {{
put("res", true);
put("data", thinkOrder);
}};
}
@Override
@@ -177,38 +541,18 @@ public class ThinkOrderServiceImpl extends ServiceImpl<ThinkOrderMapper, ThinkOr
@Override
public HashMap<String, String> createWxOrder(BigDecimal totalPrice, String orderNo, String desc, String openid) {
return createWxOrder(totalPrice, orderNo, desc, openid, "https://gxtyzx-api.websoft.top/api/think/think-order/notify");
return createWxOrder(totalPrice, orderNo, desc, openid, "https://gxtyzx-api2.websoft.top/api/think/think-order/notify");
}
@Override
public HashMap<String, String> createWxOrder(BigDecimal totalPrice, String orderNo, String desc, String openid, String notify) {
final HashMap<String, String> orderInfo = new HashMap<>();
// Integer payType = order.getPayType();
// final String uploadPath = config.getUploadPath(); // 服务器本地路径
//
//// // 微信小程序(微信支付)
// String key = "mp-weixin:".concat("10150");
// final String string = redisUtil.get(key);
// if (string == null) {
//
// }
// System.out.println("string = " + string);
// final JSONObject mpWx = JSONObject.parseObject(string);
// System.out.println("mpWx = " + mpWx);
// String key2 = "Payment:".concat(payType.toString()).concat(":").concat("10150");
// Payment payment = redisUtil.get(key2, Payment.class);
// if (payment == null) {
// payment = new Payment();
// payment.setAppId();
// }
// System.out.println("payment = " + payment);
// String privateKey = uploadPath.concat("/file").concat(payment.getApiclientKey()); // 秘钥证书
// String apiclientCert = uploadPath.concat("/file").concat(payment.getApiclientCert());
// 计算金额
// BigDecimal decimal = order.getTotalPrice();
final BigDecimal multiply = totalPrice.multiply(new BigDecimal(100));
Integer money = multiply.intValue();
// Integer money = 1;
Config wxConfig = wechatConfigService.getConfig();
JsapiServiceExtension service = new JsapiServiceExtension.Builder().config(wxConfig).build();
// 跟之前下单示例一样,填充预下单参数
@@ -217,16 +561,16 @@ public class ThinkOrderServiceImpl extends ServiceImpl<ThinkOrderMapper, ThinkOr
amount.setTotal(money);
amount.setCurrency("CNY");
request.setAmount(amount);
request.setAppid("wxd38cc38c54fa7370");
request.setAppid(appId);
// request.setAppid("wx141eb4fb4df51925");
request.setMchid("1604773943");
request.setMchid(mchId);
request.setDescription(desc);
request.setOutTradeNo(orderNo);
request.setAttach("10150");
final Payer payer = new Payer();
payer.setOpenid(openid);
request.setPayer(payer);
amount.setTotal(1);
amount.setTotal(money);
request.setAmount(amount);
request.setNotifyUrl(notify);
System.out.println("request = " + request);
@@ -240,6 +584,89 @@ public class ThinkOrderServiceImpl extends ServiceImpl<ThinkOrderMapper, ThinkOr
return orderInfo;
}
/***
* 扫码支付
* @param totalPrice
* @param orderNo
* @param desc
* @param authCode
* @return
*/
@Override
public HashMap<String, String> createWxCodePay(BigDecimal totalPrice, String orderNo, String desc, String authCode) {
final HashMap<String, String> orderInfo = new HashMap<>();
// 计算金额
// BigDecimal decimal = order.getTotalPrice();
final BigDecimal multiply = totalPrice.multiply(new BigDecimal(100));
Integer money = multiply.intValue();
Config wxConfig = wechatConfigService.getConfig();
com.wechat.pay.java.service.payments.wxcodepay.model.Amount amount = new com.wechat.pay.java.service.payments.wxcodepay.model.Amount();
amount.setTotal(money);
amount.setCurrency("CNY");
amount.setTotal(money);
String newOrderNo = IdUtil.getSnowflake().nextIdStr();
ThinkOrder thinkOrder = getByOrderNum(orderNo);
thinkOrder.setOrderNum(newOrderNo);
updateById(thinkOrder);
CodePayService service = new CodePayService.Builder().config(wxConfig).build();
com.wechat.pay.java.service.payments.wxcodepay.model.PrepayRequest prepayRequest = new com.wechat.pay.java.service.payments.wxcodepay.model.PrepayRequest();
prepayRequest.setAppid(appId);
prepayRequest.setMchid(mchId);
prepayRequest.setDescription(desc);
prepayRequest.setOutTradeNo(newOrderNo);
prepayRequest.setAmount(amount);
com.wechat.pay.java.service.payments.wxcodepay.model.Payer payer = new com.wechat.pay.java.service.payments.wxcodepay.model.Payer();
payer.setAuthCode(authCode);
prepayRequest.setPayer(payer);
com.wechat.pay.java.service.payments.wxcodepay.model.SceneInfo sceneInfo = new com.wechat.pay.java.service.payments.wxcodepay.model.SceneInfo();
com.wechat.pay.java.service.payments.wxcodepay.model.StoreInfo storeInfo = new com.wechat.pay.java.service.payments.wxcodepay.model.StoreInfo();
storeInfo.setId("0001");
sceneInfo.setStoreInfo(storeInfo);
prepayRequest.setSceneInfo(sceneInfo);
PrepayResponse prepayResponse = service.prepay(prepayRequest);
System.out.println(prepayResponse.toString());
return orderInfo;
}
@Override
public HashMap<String, String> checkWechatPayRes(String orderNo) {
QueryOrderByOutTradeNoRequest queryRequest = new QueryOrderByOutTradeNoRequest();
queryRequest.setMchid(mchId);
queryRequest.setOutTradeNo(orderNo);
try {
Config wxConfig = wechatConfigService.getConfig();
CodePayService service = new CodePayService.Builder().config(wxConfig).build();
Transaction result = service.queryOrderByOutTradeNo(queryRequest);
if (result.getTradeState().equals(Transaction.TradeStateEnum.SUCCESS)) {
ThinkOrder thinkOrder = getByOrderNum(orderNo);
thinkOrder.setPayType(1);
thinkOrder.setOrderStatus(1);
thinkOrder.setPayStatus(1);
thinkOrder.setPayTime((int) (new Date().getTime() / 1000));
thinkOrder.setWechatOrder(result.getTransactionId());
thinkOrder.setPayPrice(BigDecimal.valueOf(result.getAmount().getPayerTotal())
.multiply(new BigDecimal(100)));
updateById(thinkOrder);
}
return new HashMap<>() {{
put("state", result.getTradeState().toString());
put("stateDesc", result.getTradeStateDesc());
}};
} catch (ServiceException e) {
// API返回失败, 例如ORDER_NOT_EXISTS
System.out.printf("code=[%s], message=[%s]\n", e.getErrorCode(), e.getErrorMessage());
System.out.printf("reponse body=[%s]\n", e.getResponseBody());
return new HashMap<>() {{
put("state", "FAIL");
put("stateDesc", e.getErrorMessage());
}};
}
}
/***
* 退款申请
* @param orderRefund
@@ -250,10 +677,10 @@ public class ThinkOrderServiceImpl extends ServiceImpl<ThinkOrderMapper, ThinkOr
Config wxConfig = wechatConfigService.getConfig();
RefundService service = new RefundService.Builder().config(wxConfig).build();
CreateRequest request = new CreateRequest();
String refundNotifyUrl = "https://gxtyzx-api.websoft.top/api/think/think-order-refund-log/notify";
String refundNotifyUrl = "https://gxtyzx-api2.websoft.top/api/think/think-order-refund-log/notify";
// 金额
AmountReq amount = new AmountReq();
amount.setTotal(orderRefund.getOrder().getPayPrice().multiply(BigDecimal.valueOf(100)).longValue());
amount.setTotal(orderRefund.getOrder().getPrice().multiply(BigDecimal.valueOf(100)).longValue());
amount.setRefund(orderRefund.getRefundAmount().multiply(BigDecimal.valueOf(100)).longValue());
amount.setCurrency("CNY");
request.setNotifyUrl(refundNotifyUrl);
@@ -285,4 +712,31 @@ public class ThinkOrderServiceImpl extends ServiceImpl<ThinkOrderMapper, ThinkOr
);
}
@Override
public ThinkOrder getTodayOrder(Integer userId) {
return getOne(
new LambdaQueryWrapper<ThinkOrder>()
.eq(ThinkOrder::getUid, userId)
.eq(ThinkOrder::getPayStatus, 1)
.between(ThinkOrder::getCreateTime,
DateUtil.parse(DateUtil.today() + " 00:00:00").getTime() / 1000,
(int) (System.currentTimeMillis() / 1000))
.orderByDesc(ThinkOrder::getCreateTime)
.last("limit 1")
);
}
@Override
public List<ThinkOrder> getTodayOrderInSite(Integer userId, Integer sid) {
return list(
new LambdaQueryWrapper<ThinkOrder>()
.eq(ThinkOrder::getUid, userId)
.eq(ThinkOrder::getSid, sid)
.in(ThinkOrder::getOrderStatus, 1, 2)
.between(ThinkOrder::getCreateTime,
DateUtil.parse(DateUtil.today() + " 00:00:00").getTime() / 1000,
(int) (System.currentTimeMillis() / 1000))
.orderByDesc(ThinkOrder::getCreateTime)
);
}
}
@@ -10,10 +10,17 @@ import com.gxwebsoft.think.param.ThinkRechargeLogParam;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.think.service.ThinkSiteService;
import com.gxwebsoft.think.service.WechatConfigService;
import com.wechat.pay.java.core.Config;
import com.wechat.pay.java.service.refund.RefundService;
import com.wechat.pay.java.service.refund.model.AmountReq;
import com.wechat.pay.java.service.refund.model.CreateRequest;
import com.wechat.pay.java.service.refund.model.Refund;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -29,25 +36,30 @@ import java.util.stream.Collectors;
public class ThinkRechargeLogServiceImpl extends ServiceImpl<ThinkRechargeLogMapper, ThinkRechargeLog> implements ThinkRechargeLogService {
@Resource
private ThinkSiteService thinkSiteService;
@Resource
private WechatConfigService wechatConfigService;
@Override
public PageResult<ThinkRechargeLog> pageRel(ThinkRechargeLogParam param) {
PageParam<ThinkRechargeLog, ThinkRechargeLogParam> page = new PageParam<>(param);
page.setDefaultOrder("create_time desc");
List<ThinkRechargeLog> list = baseMapper.selectPageRel(page, param);
final List<ThinkSite> sites = thinkSiteService.list(new LambdaQueryWrapper<ThinkSite>().select(ThinkSite::getId,ThinkSite::getName));
final List<ThinkSite> sites = thinkSiteService.list(new LambdaQueryWrapper<ThinkSite>().select(ThinkSite::getId, ThinkSite::getName));
final Map<Integer, List<ThinkSite>> collect = sites.stream().collect(Collectors.groupingBy(ThinkSite::getId));
list.forEach(d -> {
final ArrayList<String> siteNames = new ArrayList<>();
final String sid = d.getSid();
final String[] split = sid.split(",");
for(String siteId : split){
final List<ThinkSite> thinkSites = collect.get(Integer.valueOf(siteId));
if (!CollectionUtils.isEmpty(thinkSites)) {
final String name = thinkSites.get(0).getName();
siteNames.add(name);
final ArrayList<String> siteNames = new ArrayList<>();
final String sid = d.getSid();
if (sid != null) {
final String[] split = sid.split(",");
for (String siteId : split) {
final List<ThinkSite> thinkSites = collect.get(Integer.valueOf(siteId));
if (!CollectionUtils.isEmpty(thinkSites)) {
final String name = thinkSites.get(0).getName();
siteNames.add(name);
}
}
d.setSiteNames(String.join(",", siteNames));
}
}
d.setSiteNames(String.join(",",siteNames));
});
return new PageResult<>(list, page.getTotal());
}
@@ -68,4 +80,37 @@ public class ThinkRechargeLogServiceImpl extends ServiceImpl<ThinkRechargeLogMap
return param.getOne(baseMapper.selectListRel(param));
}
@Override
public ThinkRechargeLog getByOrderNumber(String orderNum) {
ThinkRechargeLogParam param = new ThinkRechargeLogParam();
param.setOrderNum(orderNum);
return param.getOne(baseMapper.selectListRel(param));
}
@Override
public ThinkRechargeLog getByRefundNumber(String refundNum) {
return getOne(
new LambdaQueryWrapper<ThinkRechargeLog>()
.eq(ThinkRechargeLog::getRefundNo, refundNum)
.last("limit 1")
);
}
@Override
public Refund refund(ThinkRechargeLog thinkRechargeLog) {
Config wxConfig = wechatConfigService.getConfig();
RefundService service = new RefundService.Builder().config(wxConfig).build();
CreateRequest request = new CreateRequest();
String refundNotifyUrl = "https://gxtyzx-api2.websoft.top/api/think/think-recharge-log/refund-notify";
// 金额
AmountReq amount = new AmountReq();
amount.setTotal(thinkRechargeLog.getMoney().multiply(BigDecimal.valueOf(100)).longValue());
amount.setRefund(thinkRechargeLog.getMoney().multiply(BigDecimal.valueOf(100)).longValue());
amount.setCurrency("CNY");
request.setNotifyUrl(refundNotifyUrl);
request.setAmount(amount);
request.setOutTradeNo(thinkRechargeLog.getOrderNum());
request.setOutRefundNo(thinkRechargeLog.getRefundNo());
return service.create(request);
}
}
@@ -1,5 +1,6 @@
package com.gxwebsoft.think.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.think.mapper.ThinkSiteMapper;
@@ -23,6 +24,10 @@ public class ThinkSiteServiceImpl extends ServiceImpl<ThinkSiteMapper, ThinkSite
@Override
public PageResult<ThinkSite> pageRel(ThinkSiteParam param) {
if (param.getLoginUser() != null && param.getLoginUser().getLimitSite() != null && !param.getLoginUser().getLimitSite().isEmpty()) {
List<String> sidStrList = StrUtil.split(param.getLoginUser().getLimitSite(), ",");
param.setIdList(sidStrList.stream().map(Integer::parseInt).toList());
}
PageParam<ThinkSite, ThinkSiteParam> page = new PageParam<>(param);
page.setDefaultOrder("sort desc, create_time desc");
List<ThinkSite> list = baseMapper.selectPageRel(page, param);
@@ -31,6 +36,10 @@ public class ThinkSiteServiceImpl extends ServiceImpl<ThinkSiteMapper, ThinkSite
@Override
public List<ThinkSite> listRel(ThinkSiteParam param) {
if (param.getLoginUser() != null && param.getLoginUser().getLimitSite() != null && !param.getLoginUser().getLimitSite().isEmpty()) {
List<String> sidStrList = StrUtil.split(param.getLoginUser().getLimitSite(), ",");
param.setIdList(sidStrList.stream().map(Integer::parseInt).toList());
}
List<ThinkSite> list = baseMapper.selectListRel(param);
// 排序
PageParam<ThinkSite, ThinkSiteParam> page = new PageParam<>();
@@ -1,5 +1,6 @@
package com.gxwebsoft.think.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.think.mapper.ThinkSiteTimeMapper;
import com.gxwebsoft.think.service.ThinkSiteTimeService;
@@ -52,4 +53,13 @@ public class ThinkSiteTimeServiceImpl extends ServiceImpl<ThinkSiteTimeMapper, T
return param.getOne(baseMapper.selectListRel(param));
}
@Override
public List<ThinkSiteTime> getActiveList(Integer sid) {
return list(
new LambdaQueryWrapper<ThinkSiteTime>()
.eq(ThinkSiteTime::getSid, sid)
.eq(ThinkSiteTime::getIsStatus, 1)
);
}
}
@@ -0,0 +1,54 @@
package com.gxwebsoft.think.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.think.mapper.ThinkUsersVipBuyLogMapper;
import com.gxwebsoft.think.service.ThinkUsersVipBuyLogService;
import com.gxwebsoft.think.entity.ThinkUsersVipBuyLog;
import com.gxwebsoft.think.param.ThinkUsersVipBuyLogParam;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* Vip购卡记录Service实现
*
* @author 科技小王子
* @since 2025-03-25 19:21:56
*/
@Service
public class ThinkUsersVipBuyLogServiceImpl extends ServiceImpl<ThinkUsersVipBuyLogMapper, ThinkUsersVipBuyLog> implements ThinkUsersVipBuyLogService {
@Override
public PageResult<ThinkUsersVipBuyLog> pageRel(ThinkUsersVipBuyLogParam param) {
PageParam<ThinkUsersVipBuyLog, ThinkUsersVipBuyLogParam> page = new PageParam<>(param);
page.setDefaultOrder("create_time desc");
List<ThinkUsersVipBuyLog> list = baseMapper.selectPageRel(page, param);
return new PageResult<>(list, page.getTotal());
}
@Override
public List<ThinkUsersVipBuyLog> listRel(ThinkUsersVipBuyLogParam param) {
List<ThinkUsersVipBuyLog> list = baseMapper.selectListRel(param);
// 排序
PageParam<ThinkUsersVipBuyLog, ThinkUsersVipBuyLogParam> page = new PageParam<>();
page.setDefaultOrder("create_time desc");
return page.sortRecords(list);
}
@Override
public ThinkUsersVipBuyLog getByIdRel(Integer id) {
ThinkUsersVipBuyLogParam param = new ThinkUsersVipBuyLogParam();
param.setId(id);
return param.getOne(baseMapper.selectListRel(param));
}
@Override
public ThinkUsersVipBuyLog getByOrderNumber(String orderNumber) {
ThinkUsersVipBuyLogParam param = new ThinkUsersVipBuyLogParam();
param.setOrderNumber(orderNumber);
return param.getOne(baseMapper.selectListRel(param));
}
}
@@ -82,6 +82,8 @@ public class ThinkUsersVipServiceImpl extends ServiceImpl<ThinkUsersVipMapper, T
new LambdaQueryWrapper<ThinkUsersVip>()
.eq(ThinkUsersVip::getVid, vid)
.eq(ThinkUsersVip::getUid, uid)
.eq(ThinkUsersVip::getStatus, 1)
.ne(ThinkUsersVip::getPayTime, 0)
.orderByDesc(ThinkUsersVip::getExpireTime)
.last("limit 1")
);
@@ -94,6 +94,7 @@ public class ThinkVipCardsBillsServiceImpl extends ServiceImpl<ThinkVipCardsBill
.eq(ThinkVipCardsBills::getDate, thinkVipCardsBills.getDate());
if (thinkVipCardsBills.getCid() != null) wrapper.eq(ThinkVipCardsBills::getCid, thinkVipCardsBills.getCid());
if (thinkVipCardsBills.getVid() != null) wrapper.eq(ThinkVipCardsBills::getVid, thinkVipCardsBills.getVid());
wrapper.last("limit 1");
ThinkVipCardsBills check = getOne(wrapper);
if (check == null) save(thinkVipCardsBills);
else {
@@ -109,6 +110,7 @@ public class ThinkVipCardsBillsServiceImpl extends ServiceImpl<ThinkVipCardsBill
.eq(ThinkVipCardsBills::getDate, thinkVipCardsBills.getDate());
if (thinkVipCardsBills.getCid() != null) wrapper.eq(ThinkVipCardsBills::getCid, thinkVipCardsBills.getCid());
if (thinkVipCardsBills.getVid() != null) wrapper.eq(ThinkVipCardsBills::getVid, thinkVipCardsBills.getVid());
wrapper.last("limit 1");
ThinkVipCardsBills check = getOne(wrapper);
thinkVipCardsBills.setUsed(0);
if (check != null) save(thinkVipCardsBills);
@@ -80,25 +80,32 @@ public class ThinkVipServiceImpl extends ServiceImpl<ThinkVipMapper, ThinkVip> i
if (param.getType() != null) {
if (param.getType().equals(0)) {
queryWrapper.in(ThinkVip::getType, 1, 3);
} else if (param.getType().equals(4)) {
queryWrapper.in(ThinkVip::getType, 4, 5);
} else {
queryWrapper.eq(ThinkVip::getType, param.getType());
}
}
queryWrapper.eq(ThinkVip::getIsUse, 1)
.eq(ThinkVip::getVipType, 2)
.groupBy(ThinkVip::getSid);
List<ThinkVip> list = list(queryWrapper);
if (!list.isEmpty()) {
for (ThinkVip thinkVip : list) {
LambdaQueryWrapper<ThinkVip> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(ThinkVip::getSid, thinkVip.getSid())
.eq(ThinkVip::getVipType, 2)
.eq(ThinkVip::getIsUse, 1);
if (param.getType() != null) {
if (param.getType().equals(0)) {
wrapper.in(ThinkVip::getType, 1, 3);
} else if (param.getType().equals(4)) {
wrapper.in(ThinkVip::getType, 4, 5);
} else {
wrapper.eq(ThinkVip::getType, param.getType());
}
}
wrapper.orderByAsc(ThinkVip::getSort);
ThinkSite site = thinkSiteService.getById(thinkVip.getSid());
if (site != null) thinkVip.setSiteNames(site.getName());
thinkVip.setCardList(list(wrapper));
@@ -12,16 +12,24 @@ import java.lang.annotation.Annotation;
@Service
public class WechatConfigServiceImpl implements WechatConfigService {
private RSAAutoCertificateConfig config;
public static String privateKeyPath = "/www/wwwroot/gxtyzx-api/file/93dc8f750fee4eeaa5fb0a768982d639.pem";
private String mchId = "1604773943";
private String v3Key = "c08jFf8304G8t2jcjFRKTe0t8F43Hjti";
private String merchantSerialNumber = "5EE433741F4AEF889636C423A1CE099090802CBE";
// public static String privateKeyPath = "/www/wwwroot/gxtyzx-api/file/cert/1246610101/e244a6733b8b46968b6d4f80abbfc9c6.pem";
// private String mchId = "1246610101";
// private String v3Key = "zGufUcqa7ovgxRL0kF5OlPr482EZwtn9";
// private String merchantSerialNumber = "48749613B40AA8F1D768583FC352358E13EB5AF0";
@Override
public NotificationConfig getNotificationConfig() {
if (this.config == null) {
this.config = new RSAAutoCertificateConfig.Builder()
.merchantId("1604773943")
.merchantId(mchId)
.privateKeyFromPath(privateKeyPath)
.merchantSerialNumber("5EE433741F4AEF889636C423A1CE099090802CBE")
.apiV3Key("c08jFf8304G8t2jcjFRKTe0t8F43Hjti")
.merchantSerialNumber(merchantSerialNumber)
.apiV3Key(v3Key)
.build();
}
return this.config;
@@ -31,10 +39,10 @@ public class WechatConfigServiceImpl implements WechatConfigService {
public Config getConfig() {
if (this.config == null) {
this.config = new RSAAutoCertificateConfig.Builder()
.merchantId("1604773943")
.merchantId(mchId)
.privateKeyFromPath(privateKeyPath)
.merchantSerialNumber("5EE433741F4AEF889636C423A1CE099090802CBE")
.apiV3Key("c08jFf8304G8t2jcjFRKTe0t8F43Hjti")
.merchantSerialNumber(merchantSerialNumber)
.apiV3Key(v3Key)
.build();
}
return this.config;
@@ -1,8 +1,10 @@
package com.gxwebsoft.think.vo;
import com.gxwebsoft.think.entity.ThinkOrder;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
public class FieldPeriodVo implements Serializable {
@@ -11,5 +13,11 @@ public class FieldPeriodVo implements Serializable {
private Integer id;
private String period;
private String timestamp;
private BigDecimal price;
private Boolean sold;
private Boolean took;
private Integer orderId;
private Boolean addFromAdmin;
private Integer orderStatus;
private Integer payStatus;
}
+3 -3
View File
@@ -3,9 +3,9 @@
# 数据源配置
spring:
datasource:
url: jdbc:mysql://47.119.165.234:3308/gxtyzx?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8
username: gxtyzx
password: SLRGhfDcLtjMHcet
url: jdbc:mysql://47.121.133.163:3308/gxtyzx_prod?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8
username: gxtyzx_prod
password: bfhrfCGdwABywbX3
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.alibaba.druid.pool.DruidDataSource
+2 -2
View File
@@ -21,5 +21,5 @@ socketio:
# 框架配置
config:
# 开发环境接口
server-url: http://127.0.0.1:9091/api
upload-path: /www/jar/gxtyzx-java/file/
server-url: https://gxtyzx-api2.websoft.top/api
upload-path: /www/wwwroot/gxtyzx-api/file/
+7 -7
View File
@@ -3,9 +3,9 @@
# 数据源配置
spring:
datasource:
url: jdbc:mysql://gxtyzx.gxsportscenter.com:33063/tyzxDB?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8
username: tyzxDB
password: brkwerYxnA5HCJcG
url: jdbc:mysql://127.0.0.1:3308/gxtyzx_prod?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8
username: gxtyzx_prod
password: bfhrfCGdwABywbX3
driver-class-name: com.mysql.cj.jdbc.Driver
type: com.alibaba.druid.pool.DruidDataSource
@@ -14,9 +14,9 @@ logging:
file:
name: websoft-modules.log
level:
root: WARN
com.gxwebsoft: ERROR
com.baomidou.mybatisplus: ERROR
root: DEBUG
com.gxwebsoft: DEBUG
com.baomidou.mybatisplus: DEBUG
socketio:
host: 0.0.0.0 #IP地址
@@ -24,7 +24,7 @@ socketio:
# 框架配置
config:
# 生产环境接口
server-url: https://server.gxwebsoft.com/api
server-url: https://gxtyzx-server.websoft.top/api
upload-path: /www/wwwroot/file.ws/
# 阿里云OSS云存储
Binary file not shown.
@@ -36,10 +36,10 @@ public class ThinkGenerator {
// 是否在xml中添加二级缓存配置
private static final boolean ENABLE_CACHE = false;
// 数据库连接配置
private static final String DB_URL = "jdbc:mysql://47.119.165.234:3308/gxtyzx?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8";
private static final String DB_URL = "jdbc:mysql://47.121.133.163:3308/gxtyzx_prod?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8";
private static final String DB_DRIVER = "com.mysql.cj.jdbc.Driver";
private static final String DB_USERNAME = "gxtyzx";
private static final String DB_PASSWORD = "SLRGhfDcLtjMHcet";
private static final String DB_USERNAME = "gxtyzx_prod";
private static final String DB_PASSWORD = "bfhrfCGdwABywbX3";
// 包名
private static final String PACKAGE_NAME = "com.gxwebsoft";
// 模块名
@@ -117,8 +117,8 @@ public class ThinkGenerator {
// "think_users_vip_cancle_log",
// "think_wechat_bill",
// "think_wechat_bill_log",
"think_cards_bills",
"think_vip_cards_bills",
// "think_cards_bills",
"think_users_vip_buy_log",
};
// 需要去除的表前缀
private static final String[] TABLE_PREFIX = new String[]{