241101
This commit is contained in:
@@ -68,7 +68,9 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
"/5zbYEPkyV4.txt",
|
||||
"/api/love/user-plan-log/wx-pay/**",
|
||||
"/api/cms/form-record",
|
||||
"/api/shop/merchant-account/getMerchantAccountByPhone"
|
||||
"/api/shop/merchant-account/getMerchantAccountByPhone",
|
||||
"/api/think/think-order/notify",
|
||||
"/api/think/think-users-vip/notify"
|
||||
)
|
||||
.permitAll()
|
||||
.anyRequest()
|
||||
|
||||
@@ -15,161 +15,182 @@ import java.util.HashMap;
|
||||
|
||||
@Component
|
||||
public class RequestUtil {
|
||||
private static final String host = "https://server.gxwebsoft.com/api";
|
||||
private static String ACCESS_TOKEN;
|
||||
private static String TENANT_ID;
|
||||
private static final String host = "https://server.gxwebsoft.com/api";
|
||||
private static String ACCESS_TOKEN;
|
||||
private static String TENANT_ID;
|
||||
|
||||
public void setTenantId(String tenantId) {
|
||||
TENANT_ID = tenantId;
|
||||
}
|
||||
|
||||
public void setAccessToken(String token) {
|
||||
ACCESS_TOKEN = token;
|
||||
}
|
||||
|
||||
// 微信支付通知
|
||||
public String pushWxPayNotify(Transaction transaction, Payment payment){
|
||||
// 设置租户ID
|
||||
setTenantId(payment.getTenantId().toString());
|
||||
// 推送支付通知地址
|
||||
String path = payment.getNotifyUrl();
|
||||
try {
|
||||
// 链式构建请求
|
||||
return HttpRequest.post(path)
|
||||
.header("Tenantid", TENANT_ID)
|
||||
.body(JSONUtil.toJSONString(transaction))//表单内容
|
||||
.timeout(20000)//超时,毫秒
|
||||
.execute().body();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
public void setTenantId(String tenantId) {
|
||||
TENANT_ID = tenantId;
|
||||
}
|
||||
return "支付失败";
|
||||
}
|
||||
|
||||
|
||||
public User getUserByPhone(String phone) {
|
||||
String path = "/system/user/getByPhone/" + phone;
|
||||
try {
|
||||
// 链式构建请求
|
||||
String result = HttpRequest.get(host.concat(path))
|
||||
.header("Authorization", ACCESS_TOKEN)
|
||||
.header("Tenantid", TENANT_ID)
|
||||
.timeout(20000)//超时,毫秒
|
||||
.execute().body();
|
||||
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
final String data = jsonObject.getString("data");
|
||||
return JSONObject.parseObject(data, User.class);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
public void setAccessToken(String token) {
|
||||
ACCESS_TOKEN = token;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public User getByUserId(Integer userId) {
|
||||
String path = "/system/user/" + userId;
|
||||
try {
|
||||
// 链式构建请求
|
||||
String result = HttpRequest.get(host.concat(path))
|
||||
.header("Authorization", ACCESS_TOKEN)
|
||||
.header("Tenantid", TENANT_ID)
|
||||
.timeout(20000)//超时,毫秒
|
||||
.execute().body();
|
||||
// 微信支付通知
|
||||
public String pushWxPayNotify(Transaction transaction, Payment payment) {
|
||||
// 设置租户ID
|
||||
setTenantId(payment.getTenantId().toString());
|
||||
// 推送支付通知地址
|
||||
String path = payment.getNotifyUrl();
|
||||
try {
|
||||
// 链式构建请求
|
||||
return HttpRequest.post(path)
|
||||
.header("Tenantid", TENANT_ID)
|
||||
.body(JSONUtil.toJSONString(transaction))//表单内容
|
||||
.timeout(20000)//超时,毫秒
|
||||
.execute().body();
|
||||
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
System.out.println("jsonObject = " + jsonObject);
|
||||
final String data = jsonObject.getString("data");
|
||||
return JSONObject.parseObject(data, User.class);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "支付失败";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// 新增用户
|
||||
public boolean saveUserByPhone(MerchantAccount merchantAccount) {
|
||||
String path = "/system/user/";
|
||||
try {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("nickname", merchantAccount.getRealName());
|
||||
map.put("username", merchantAccount.getPhone());
|
||||
map.put("realName", merchantAccount.getRealName());
|
||||
map.put("phone", merchantAccount.getPhone());
|
||||
map.put("password", merchantAccount.getPassword());
|
||||
final ArrayList<Object> roles = new ArrayList<>();
|
||||
final UserRole userRole = new UserRole();
|
||||
userRole.setUserId(merchantAccount.getUserId());
|
||||
userRole.setRoleId(merchantAccount.getRoleId());
|
||||
userRole.setTenantId(merchantAccount.getTenantId());
|
||||
roles.add(userRole);
|
||||
map.put("roles", roles);
|
||||
map.put("tenantId", TENANT_ID);
|
||||
// 链式构建请求
|
||||
String result = HttpRequest.post(host.concat(path))
|
||||
.header("Authorization", ACCESS_TOKEN)
|
||||
.header("Tenantid", TENANT_ID)
|
||||
.body(JSONUtil.toJSONString(map))//表单内容
|
||||
.timeout(20000)//超时,毫秒
|
||||
.execute().body();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public ApiResult<?> updateUserBalance(String path,User user) {
|
||||
try {
|
||||
// 链式构建请求
|
||||
final String body = HttpRequest.put(host.concat(path))
|
||||
.header("Authorization", ACCESS_TOKEN)
|
||||
.header("Tenantid", TENANT_ID)
|
||||
.body(JSONUtil.toJSONString(user))
|
||||
.timeout(20000)
|
||||
.execute().body();
|
||||
return JSONUtil.parseObject(body, ApiResult.class);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public User getUserByPhone(String phone) {
|
||||
String path = "/system/user/getByPhone/" + phone;
|
||||
try {
|
||||
// 链式构建请求
|
||||
String result = HttpRequest.get(host.concat(path))
|
||||
.header("Authorization", ACCESS_TOKEN)
|
||||
.header("Tenantid", TENANT_ID)
|
||||
.timeout(20000)//超时,毫秒
|
||||
.execute().body();
|
||||
|
||||
public String getMpOrderQrCode(String orderNo) {
|
||||
String path = "/wx-login/getOrderQRCode/";
|
||||
try {
|
||||
// 链式构建请求
|
||||
final String body = HttpRequest.get(host.concat(path).concat(orderNo))
|
||||
.header("Authorization", ACCESS_TOKEN)
|
||||
.header("tenantId", TENANT_ID)
|
||||
.timeout(20000)
|
||||
.execute().body();
|
||||
final JSONObject jsonObject = JSONObject.parseObject(body);
|
||||
final String qrCode = jsonObject.getString("message");
|
||||
return qrCode;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
final String data = jsonObject.getString("data");
|
||||
return JSONObject.parseObject(data, User.class);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getOrderQRCodeUnlimited(String orderNo) {
|
||||
String path = "/wx-login/getOrderQRCodeUnlimited/";
|
||||
try {
|
||||
// 链式构建请求
|
||||
final String body = HttpRequest.get(host.concat(path).concat(orderNo))
|
||||
.header("Authorization", ACCESS_TOKEN)
|
||||
.header("tenantId", TENANT_ID)
|
||||
.timeout(20000)
|
||||
.execute().body();
|
||||
System.out.println("body = " + body);
|
||||
final JSONObject jsonObject = JSONObject.parseObject(body);
|
||||
final String qrCode = jsonObject.getString("message");
|
||||
System.out.println("qrCode = " + qrCode);
|
||||
return qrCode;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
public User getByUserId(Integer userId) {
|
||||
String path = "/system/user/" + userId;
|
||||
try {
|
||||
// 链式构建请求
|
||||
String result = HttpRequest.get(host.concat(path))
|
||||
.header("Authorization", ACCESS_TOKEN)
|
||||
.header("Tenantid", TENANT_ID)
|
||||
.timeout(20000)//超时,毫秒
|
||||
.execute().body();
|
||||
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
System.out.println("jsonObject = " + jsonObject);
|
||||
final String data = jsonObject.getString("data");
|
||||
return JSONObject.parseObject(data, User.class);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// 新增用户
|
||||
public boolean saveUserByPhone(MerchantAccount merchantAccount) {
|
||||
String path = "/system/user/";
|
||||
try {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("nickname", merchantAccount.getRealName());
|
||||
map.put("username", merchantAccount.getPhone());
|
||||
map.put("realName", merchantAccount.getRealName());
|
||||
map.put("phone", merchantAccount.getPhone());
|
||||
map.put("uid", merchantAccount.getUid());
|
||||
map.put("openid", merchantAccount.getOpenId());
|
||||
map.put("password", merchantAccount.getPassword());
|
||||
final ArrayList<Object> roles = new ArrayList<>();
|
||||
final UserRole userRole = new UserRole();
|
||||
userRole.setUserId(merchantAccount.getUserId());
|
||||
userRole.setRoleId(merchantAccount.getRoleId());
|
||||
userRole.setTenantId(merchantAccount.getTenantId());
|
||||
roles.add(userRole);
|
||||
map.put("roles", roles);
|
||||
map.put("tenantId", TENANT_ID);
|
||||
// 链式构建请求
|
||||
String result = HttpRequest.post(host.concat(path))
|
||||
.header("Authorization", ACCESS_TOKEN)
|
||||
.header("Tenantid", TENANT_ID)
|
||||
.body(JSONUtil.toJSONString(map))//表单内容
|
||||
.timeout(20000)//超时,毫秒
|
||||
.execute().body();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public ApiResult<?> updateUser(User user) {
|
||||
try {
|
||||
// 链式构建请求
|
||||
String path = "/system/user";
|
||||
final String body = HttpRequest.put(host.concat(path))
|
||||
.header("Authorization", ACCESS_TOKEN)
|
||||
.header("Tenantid", TENANT_ID)
|
||||
.body(JSONUtil.toJSONString(user))
|
||||
.timeout(20000)
|
||||
.execute().body();
|
||||
System.out.println("user:" + user);
|
||||
System.out.println("body:" + body);
|
||||
return JSONUtil.parseObject(body, ApiResult.class);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public ApiResult<?> updateUserBalance(String path, User user) {
|
||||
try {
|
||||
// 链式构建请求
|
||||
final String body = HttpRequest.put(host.concat(path))
|
||||
.header("Authorization", ACCESS_TOKEN)
|
||||
.header("Tenantid", TENANT_ID)
|
||||
.body(JSONUtil.toJSONString(user))
|
||||
.timeout(20000)
|
||||
.execute().body();
|
||||
return JSONUtil.parseObject(body, ApiResult.class);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getMpOrderQrCode(String orderNo) {
|
||||
String path = "/wx-login/getOrderQRCode/";
|
||||
try {
|
||||
// 链式构建请求
|
||||
final String body = HttpRequest.get(host.concat(path).concat(orderNo))
|
||||
.header("Authorization", ACCESS_TOKEN)
|
||||
.header("tenantId", TENANT_ID)
|
||||
.timeout(20000)
|
||||
.execute().body();
|
||||
final JSONObject jsonObject = JSONObject.parseObject(body);
|
||||
final String qrCode = jsonObject.getString("message");
|
||||
return qrCode;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getOrderQRCodeUnlimited(String orderNo) {
|
||||
String path = "/wx-login/getOrderQRCodeUnlimited/";
|
||||
try {
|
||||
// 链式构建请求
|
||||
final String body = HttpRequest.get(host.concat(path).concat(orderNo))
|
||||
.header("Authorization", ACCESS_TOKEN)
|
||||
.header("tenantId", TENANT_ID)
|
||||
.timeout(20000)
|
||||
.execute().body();
|
||||
System.out.println("body = " + body);
|
||||
final JSONObject jsonObject = JSONObject.parseObject(body);
|
||||
final String qrCode = jsonObject.getString("message");
|
||||
System.out.println("qrCode = " + qrCode);
|
||||
return qrCode;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ public class UserController extends BaseController {
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('sys:user:save')")
|
||||
// @PreAuthorize("hasAuthority('sys:user:save')")
|
||||
@ApiOperation("批量添加用户并返回userId")
|
||||
@PostMapping("/batchBackUserId")
|
||||
public ApiResult<?> saveBatchBackUserId(@RequestBody List<User> userList) {
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.util.List;
|
||||
@Api(tags = "订单核销管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/order-info-log")
|
||||
public class OrderInfoLogController extends BaseController {
|
||||
public class OrderInfoLogController extends BaseController {
|
||||
@Resource
|
||||
private OrderInfoLogService orderInfoLogService;
|
||||
|
||||
|
||||
@@ -81,6 +81,11 @@ public class MerchantAccount implements Serializable {
|
||||
@TableField(exist = false)
|
||||
private String mobile;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Integer uid;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String openId;
|
||||
public String getMobile(){
|
||||
return DesensitizedUtil.mobilePhone(this.phone);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.gxwebsoft.think.consts;
|
||||
|
||||
public class OrderStatusConsts {
|
||||
public static final Integer ORDER_STATUS_DONE = 1;
|
||||
public static final Integer ORDER_STATUS_UNUSED = 2;
|
||||
public static final Integer ORDER_STATUS_CANCELED = 3;
|
||||
public static final Integer ORDER_STATUS_CANCELING = 5;
|
||||
public static final Integer ORDER_STATUS_CANCEL_REFUSE = 5;
|
||||
public static final Integer ORDER_STATUS_CANCEL_SUCCESS = 6;
|
||||
public static final Integer ORDER_STATUS_USER_CANCEL = 7;
|
||||
|
||||
public static final Integer PAY_STATUS_PAID = 1;
|
||||
public static final Integer PAY_STATUS_UNPAID = 2;
|
||||
|
||||
public static final Integer PAY_TYPE_WECHAT = 1;
|
||||
}
|
||||
@@ -8,6 +8,7 @@ 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.param.ThinkCardParam;
|
||||
import com.gxwebsoft.think.service.ThinkCardBindLogService;
|
||||
import com.gxwebsoft.think.service.ThinkCardService;
|
||||
@@ -35,6 +36,16 @@ public class ThinkCardController extends BaseController {
|
||||
@Resource
|
||||
private ThinkCardBindLogService thinkCardBindLogService;
|
||||
|
||||
@ApiOperation("用户卡")
|
||||
@PostMapping("/user-card")
|
||||
public ApiResult<?> userCard() {
|
||||
// 使用关联查询
|
||||
if (getLoginUser() == null) return fail("请先登录");
|
||||
ThinkUsers thinkUsers = new ThinkUsers();
|
||||
thinkUsers.setId(getLoginUser().getUid());
|
||||
return success(thinkCardService.userCard(thinkUsers));
|
||||
}
|
||||
|
||||
@ApiOperation("分页查询")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<ThinkCard>> page(ThinkCardParam param) {
|
||||
@@ -114,33 +125,33 @@ public class ThinkCardController extends BaseController {
|
||||
@ApiOperation("IC卡激活")
|
||||
@PostMapping("/bindCard")
|
||||
public ApiResult<?> bindCard(@RequestBody ThinkCard thinkCard) {
|
||||
System.out.println("thinkCard = " + thinkCard);
|
||||
final User loginUser = getLoginUser();
|
||||
if (ObjectUtil.isEmpty(loginUser)) {
|
||||
return fail("请先登录");
|
||||
}
|
||||
if (StrUtil.isBlank(thinkCard.getCardNum())) {
|
||||
return fail("卡号不能为空");
|
||||
}
|
||||
if (StrUtil.isBlank(thinkCard.getUsername())) {
|
||||
return fail("姓名不能为空");
|
||||
}
|
||||
if (StrUtil.isBlank(thinkCard.getPhone())) {
|
||||
return fail("电话不能为空");
|
||||
}
|
||||
final ThinkCardParam thinkCardParam = new ThinkCardParam();
|
||||
thinkCardParam.setCardNum(thinkCard.getCardNum());
|
||||
final List<ThinkCard> thinkCards = thinkCardService.listRel(thinkCardParam);
|
||||
if (!CollectionUtils.isEmpty(thinkCards)) {
|
||||
final ThinkCard card = thinkCards.get(0);
|
||||
if (!card.getPhone().equals(getLoginUser().getPhone())) {
|
||||
return fail("非本人卡,无法绑定");
|
||||
System.out.println("thinkCard = " + thinkCard);
|
||||
final User loginUser = getLoginUser();
|
||||
if (ObjectUtil.isEmpty(loginUser)) {
|
||||
return fail("请先登录");
|
||||
}
|
||||
card.setUid(getLoginUser().getUid());
|
||||
thinkCardService.updateById(card);
|
||||
return success("激活成功",null);
|
||||
}
|
||||
return fail("修改失败",null);
|
||||
if (StrUtil.isBlank(thinkCard.getCardNum())) {
|
||||
return fail("卡号不能为空");
|
||||
}
|
||||
if (StrUtil.isBlank(thinkCard.getUsername())) {
|
||||
return fail("姓名不能为空");
|
||||
}
|
||||
if (StrUtil.isBlank(thinkCard.getPhone())) {
|
||||
return fail("电话不能为空");
|
||||
}
|
||||
final ThinkCardParam thinkCardParam = new ThinkCardParam();
|
||||
thinkCardParam.setCardNum(thinkCard.getCardNum());
|
||||
final List<ThinkCard> thinkCards = thinkCardService.listRel(thinkCardParam);
|
||||
if (!CollectionUtils.isEmpty(thinkCards)) {
|
||||
final ThinkCard card = thinkCards.get(0);
|
||||
if (!card.getPhone().equals(getLoginUser().getPhone())) {
|
||||
return fail("非本人卡,无法绑定");
|
||||
}
|
||||
card.setUid(getLoginUser().getUid());
|
||||
thinkCardService.updateById(card);
|
||||
return success("激活成功", null);
|
||||
}
|
||||
return fail("修改失败", null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -38,6 +38,13 @@ public class ThinkFieldController extends BaseController {
|
||||
return success(thinkFieldService.pageRel(param));
|
||||
}
|
||||
|
||||
@ApiOperation("根据时间查询全部")
|
||||
@PostMapping("/withTimeList")
|
||||
public ApiResult<List<ThinkField>> listWithTimeList(@RequestBody ThinkFieldParam param) {
|
||||
// 使用关联查询
|
||||
return success(thinkFieldService.listWithTimeList(param));
|
||||
}
|
||||
|
||||
@ApiOperation("查询全部")
|
||||
@GetMapping()
|
||||
public ApiResult<List<ThinkField>> list(ThinkFieldParam param) {
|
||||
|
||||
@@ -1,18 +1,56 @@
|
||||
package com.gxwebsoft.think.controller;
|
||||
|
||||
import cn.hutool.core.date.DateField;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.gxwebsoft.common.core.exception.BusinessException;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
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.shop.entity.Cart;
|
||||
import com.gxwebsoft.shop.entity.Goods;
|
||||
import com.gxwebsoft.shop.entity.OrderGoods;
|
||||
import com.gxwebsoft.shop.entity.OrderInfo;
|
||||
import com.gxwebsoft.think.entity.ThinkOrder;
|
||||
import com.gxwebsoft.think.entity.ThinkOrderInfo;
|
||||
import com.gxwebsoft.think.entity.ThinkSiteTime;
|
||||
import com.gxwebsoft.think.entity.ThinkUsersVip;
|
||||
import com.gxwebsoft.think.param.ThinkOrderParam;
|
||||
import com.gxwebsoft.think.service.ThinkOrderInfoService;
|
||||
import com.gxwebsoft.think.service.ThinkOrderService;
|
||||
import com.gxwebsoft.think.service.ThinkSiteTimeService;
|
||||
import com.gxwebsoft.think.service.WechatConfigService;
|
||||
import com.wechat.pay.java.core.Config;
|
||||
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
|
||||
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.payments.model.Transaction;
|
||||
import com.wechat.pay.java.service.payments.model.TransactionAmount;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.gxwebsoft.think.consts.OrderStatusConsts.PAY_TYPE_WECHAT;
|
||||
|
||||
/**
|
||||
* 控制器
|
||||
@@ -26,10 +64,69 @@ import java.util.List;
|
||||
public class ThinkOrderController extends BaseController {
|
||||
@Resource
|
||||
private ThinkOrderService thinkOrderService;
|
||||
@Resource
|
||||
private ThinkSiteTimeService thinkSiteTimeService;
|
||||
@Resource
|
||||
private ThinkOrderInfoService thinkOrderInfoService;
|
||||
@Resource
|
||||
private WechatConfigService wechatConfigService;
|
||||
|
||||
public static String privateKeyPath = "/www/jar/gxtyzx-java/file/93dc8f750fee4eeaa5fb0a768982d639.pem";
|
||||
|
||||
// private NotificationConfig config;
|
||||
|
||||
@ApiOperation("微信通知")
|
||||
@PostMapping("/notify")
|
||||
public String notify(@RequestBody String body, @RequestHeader Map<String, Object> header) {
|
||||
System.out.println("支付通知 >>>>> ");
|
||||
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();
|
||||
// if (config == null) {
|
||||
// config = new RSAAutoCertificateConfig.Builder()
|
||||
// .merchantId("1604773943")
|
||||
// .privateKeyFromPath(privateKeyPath)
|
||||
// .merchantSerialNumber("5EE433741F4AEF889636C423A1CE099090802CBE")
|
||||
// .apiV3Key("c08jFf8304G8t2jcjFRKTe0t8F43Hjti")
|
||||
// .build();
|
||||
// }
|
||||
NotificationConfig config = wechatConfigService.getNotificationConfig();
|
||||
NotificationParser parser = new NotificationParser(config);
|
||||
com.wechat.pay.java.service.payments.model.Transaction transaction = parser.parse(requestParam, com.wechat.pay.java.service.payments.model.Transaction.class);
|
||||
// 查询订单信息
|
||||
final ThinkOrder order = thinkOrderService.getByOrderNum(transaction.getOutTradeNo());
|
||||
if (order == null) return "订单不存在";
|
||||
if (order.getPayStatus().equals(2)) {
|
||||
// 2.更新订单支付状态
|
||||
order.setPayStatus(1);
|
||||
order.setWechatOrder(transaction.getTransactionId());
|
||||
order.setPayPrice(new BigDecimal(NumberUtil.decimalFormat("0.00", transaction.getAmount().getPayerTotal() * 0.01)));
|
||||
order.setPrice(new BigDecimal(NumberUtil.decimalFormat("0.00", transaction.getAmount().getPayerTotal() * 0.01)));
|
||||
order.setPayTime((int) DateUtil.currentSeconds());
|
||||
order.setQrcode("qrcode/" + LocalDateTimeUtil.format(LocalDateTime.now(), "yyyyMMdd") + "/" + IdUtil.getSnowflake().nextIdStr() + ".png");
|
||||
thinkOrderService.updateById(order);
|
||||
// 更新订单商品的支付状态
|
||||
if (order.getType().equals(0)) {
|
||||
List<ThinkOrderInfo> orderInfoList = thinkOrderInfoService.listInOrder(order.getId());
|
||||
for (ThinkOrderInfo thinkOrderInfo : orderInfoList) {
|
||||
thinkOrderInfo.setPayStatus(1);
|
||||
}
|
||||
thinkOrderInfoService.updateBatchById(orderInfoList);
|
||||
}
|
||||
}
|
||||
return "订单已支付";
|
||||
|
||||
}
|
||||
|
||||
@ApiOperation("分页查询")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<ThinkOrder>> page(ThinkOrderParam param) {
|
||||
public ApiResult<?> page(ThinkOrderParam param) {
|
||||
if (getLoginUser() == null) return fail("请先登录");
|
||||
param.setUid(getLoginUser().getUid());
|
||||
// 使用关联查询
|
||||
return success(thinkOrderService.pageRel(param));
|
||||
}
|
||||
@@ -50,13 +147,73 @@ public class ThinkOrderController extends BaseController {
|
||||
|
||||
@ApiOperation("添加")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody ThinkOrder thinkOrder) {
|
||||
public ApiResult<?> save(@RequestBody ThinkOrder thinkOrder, HttpServletRequest request) throws IOException, WxErrorException {
|
||||
User user = getLoginUser();
|
||||
if (user == null) return fail("请先登录");
|
||||
thinkOrder.setOrderNum(IdUtil.getSnowflake().nextIdStr());
|
||||
BigDecimal totalPrice = BigDecimal.ZERO;
|
||||
// BigDecimal reducePrice = BigDecimal.ZERO;
|
||||
thinkOrder.setPayPrice(BigDecimal.ZERO);
|
||||
thinkOrder.setReducePrice(BigDecimal.ZERO);
|
||||
thinkOrder.setPrice(BigDecimal.ZERO);
|
||||
thinkOrder.setPrice(BigDecimal.ZERO);
|
||||
thinkOrder.setUid(user.getUid());
|
||||
Long now = new Date().getTime();
|
||||
int timestamp = (int) (now / 1000);
|
||||
if (thinkOrder.getThinkOrderInfos() != null) {
|
||||
for (ThinkOrderInfo thinkOrderInfo : thinkOrder.getThinkOrderInfos()) {
|
||||
ThinkSiteTime siteTime = thinkSiteTimeService.getById(thinkOrderInfo.getSiteTimeId());
|
||||
thinkOrderInfo.setPrice(BigDecimal.ZERO);
|
||||
thinkOrderInfo.setChildrenPrice(BigDecimal.ZERO);
|
||||
if (siteTime != null && siteTime.getIsStatus() == 1) {
|
||||
thinkOrderInfo.setPrice(siteTime.getPrice());
|
||||
thinkOrderInfo.setChildrenPrice(siteTime.getChildrenPrice());
|
||||
thinkOrderInfo.setOrderTime(timestamp);
|
||||
thinkOrderInfo.setTimeFlag(now);
|
||||
thinkOrderInfo.setIsChildren(0);
|
||||
totalPrice = totalPrice.add(siteTime.getPrice().multiply(BigDecimal.valueOf(thinkOrderInfo.getAdultNum())));
|
||||
totalPrice = totalPrice.add(siteTime.getChildrenPrice().multiply(BigDecimal.valueOf(thinkOrderInfo.getChildrenNum())));
|
||||
// reducePrice = reducePrice.add(thinkOrderInfo.getChildrenPrice());
|
||||
}
|
||||
}
|
||||
}
|
||||
thinkOrder.setTotalPrice(totalPrice);
|
||||
|
||||
thinkOrder.setCreateTime(timestamp);
|
||||
thinkOrder.setUpdateTime(timestamp);
|
||||
if (thinkOrderService.save(thinkOrder)) {
|
||||
return success("添加成功");
|
||||
for (ThinkOrderInfo thinkOrderInfo : thinkOrder.getThinkOrderInfos()) {
|
||||
thinkOrderInfo.setOid(thinkOrder.getId());
|
||||
}
|
||||
thinkOrderInfoService.saveBatch(thinkOrder.getThinkOrderInfos());
|
||||
return onPay(thinkOrder);
|
||||
}
|
||||
return fail("添加失败");
|
||||
}
|
||||
|
||||
@ApiOperation("重新支付")
|
||||
@PostMapping("/repay")
|
||||
public ApiResult<?> repay(@RequestBody ThinkOrder thinkOrder) {
|
||||
ThinkOrder thinkOrder1 = thinkOrderService.getByIdRel(thinkOrder.getId());
|
||||
if (thinkOrder1 == null) return fail("订单不存在");
|
||||
if (thinkOrder1.getPayStatus().equals(1)) return fail("该订单已支付");
|
||||
if (thinkOrder1.getOrderStatus().equals(3)) return fail("该订单已取消");
|
||||
|
||||
String desc = thinkOrder1.getThinkOrderInfos().get(0).getSiteName() + "-" + thinkOrder1.getThinkOrderInfos().get(0).getFieldName();
|
||||
return success("下单成功", thinkOrderService.createWxOrder(thinkOrder1.getTotalPrice(), thinkOrder1.getOrderNum(), desc,
|
||||
getLoginUser().getOpenid()));
|
||||
}
|
||||
|
||||
private ApiResult<?> onPay(ThinkOrder order) throws IOException, WxErrorException {
|
||||
// 微信统一下单接口
|
||||
if (order.getPayType().equals(PAY_TYPE_WECHAT)) {
|
||||
String desc = order.getThinkOrderInfos().get(0).getSiteName() + "-" + order.getThinkOrderInfos().get(0).getFieldName();
|
||||
return success("下单成功", thinkOrderService.createWxOrder(order.getTotalPrice(), order.getOrderNum(), desc, getLoginUser().getOpenid()));
|
||||
}
|
||||
|
||||
return fail("支付失败");
|
||||
}
|
||||
|
||||
@ApiOperation("修改")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody ThinkOrder thinkOrder) {
|
||||
|
||||
@@ -45,7 +45,16 @@ public class ThinkSiteController extends BaseController {
|
||||
return success(thinkSiteService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('think:thinkSite:list')")
|
||||
@ApiOperation("根据id查询")
|
||||
@PostMapping("/{id}")
|
||||
public ApiResult<ThinkSite> get(@PathVariable("id") Integer id, @RequestBody ThinkSiteParam param) {
|
||||
// 使用关联查询
|
||||
if (param.getLat() != null) {
|
||||
return success(thinkSiteService.getByIdWithDistance(id, param.getLat(), param.getLng()));
|
||||
}
|
||||
return success(thinkSiteService.getByIdRel(id));
|
||||
}
|
||||
|
||||
@ApiOperation("根据id查询")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<ThinkSite> get(@PathVariable("id") Integer id) {
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package com.gxwebsoft.think.controller;
|
||||
|
||||
import cn.hutool.db.nosql.redis.RedisDS;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.gxwebsoft.common.core.utils.RedisUtil;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.think.service.ThinkSiteTimeService;
|
||||
import com.gxwebsoft.think.entity.ThinkSiteTime;
|
||||
@@ -12,10 +16,13 @@ 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.boot.autoconfigure.data.redis.RedisProperties;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import redis.clients.jedis.Jedis;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -30,6 +37,8 @@ import java.util.List;
|
||||
public class ThinkSiteTimeController extends BaseController {
|
||||
@Resource
|
||||
private ThinkSiteTimeService thinkSiteTimeService;
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@ApiOperation("分页查询")
|
||||
@GetMapping("/page")
|
||||
@@ -41,8 +50,21 @@ 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);
|
||||
}
|
||||
// 使用关联查询
|
||||
return success(thinkSiteTimeService.listRel(param));
|
||||
return success(list);
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('think:thinkSiteTime:list')")
|
||||
@@ -57,6 +79,7 @@ public class ThinkSiteTimeController extends BaseController {
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody ThinkSiteTime thinkSiteTime) {
|
||||
if (thinkSiteTimeService.save(thinkSiteTime)) {
|
||||
redisUtil.delete("site_time_list_" + thinkSiteTime.getSid());
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
@@ -66,6 +89,7 @@ public class ThinkSiteTimeController extends BaseController {
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody ThinkSiteTime thinkSiteTime) {
|
||||
if (thinkSiteTimeService.updateById(thinkSiteTime)) {
|
||||
redisUtil.delete("site_time_list_" + thinkSiteTime.getSid());
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
@@ -74,7 +98,10 @@ public class ThinkSiteTimeController extends BaseController {
|
||||
@ApiOperation("删除")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
ThinkSiteTime thinkSiteTime = thinkSiteTimeService.getByIdRel(id);
|
||||
Integer sid = thinkSiteTime.getSid();
|
||||
if (thinkSiteTimeService.removeById(id)) {
|
||||
redisUtil.delete("site_time_list_" + sid);
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
package com.gxwebsoft.think.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.gxwebsoft.common.core.utils.RequestUtil;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
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.shop.entity.MerchantAccount;
|
||||
import com.gxwebsoft.think.entity.ThinkUsers;
|
||||
import com.gxwebsoft.think.param.ThinkUsersParam;
|
||||
import com.gxwebsoft.think.service.ThinkUsersService;
|
||||
@@ -17,9 +21,13 @@ import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import com.gxwebsoft.common.core.security.JwtUtil;
|
||||
|
||||
/**
|
||||
* 控制器
|
||||
*
|
||||
@@ -33,6 +41,13 @@ public class ThinkUsersController extends BaseController {
|
||||
@Resource
|
||||
private ThinkUsersService thinkUsersService;
|
||||
|
||||
@PostMapping("/info")
|
||||
public ApiResult<?> info() {
|
||||
if (getLoginUser() == null) return fail("请先登录");
|
||||
// 使用关联查询
|
||||
return success(thinkUsersService.getById(getLoginUser().getUid()));
|
||||
}
|
||||
|
||||
@ApiOperation("分页查询")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<ThinkUsers>> page(ThinkUsersParam param) {
|
||||
@@ -56,8 +71,36 @@ public class ThinkUsersController extends BaseController {
|
||||
|
||||
@ApiOperation("添加")
|
||||
@PostMapping()
|
||||
public ApiResult<?> save(@RequestBody ThinkUsers thinkUsers) {
|
||||
public ApiResult<?> save(@RequestBody ThinkUsers thinkUsers, HttpServletRequest request) {
|
||||
ThinkUsers check = thinkUsersService.getByOpenId(thinkUsers.getOpenId());
|
||||
RequestUtil requestUtil = new RequestUtil();
|
||||
requestUtil.setAccessToken(JwtUtil.getAccessToken(request));
|
||||
requestUtil.setTenantId(getTenantId().toString());
|
||||
System.out.println("check:" + check);
|
||||
if (check != null) {
|
||||
User user = new User();
|
||||
user.setUserId(thinkUsers.getUserId());
|
||||
user.setUid(check.getId());
|
||||
user.setPhone(thinkUsers.getPhone());
|
||||
requestUtil.updateUser(user);
|
||||
|
||||
check.setPhone(thinkUsers.getPhone());
|
||||
thinkUsersService.updateById(check);
|
||||
return success("信息已更新");
|
||||
}
|
||||
thinkUsers.setUsername("微信用户");
|
||||
thinkUsers.setAvatarUrl("https://thirdwx.qlogo.cn/mmopen/vi_32/DU0bqTVM2qu4Mm0Ec2ic3OI73iatlyZaib6Z50u8X9HkgSFzB08sCT7yS2jEQF9MDHibNfLdialqSfN13ftZHKdJcqA/132");
|
||||
thinkUsers.setGender(1);
|
||||
thinkUsers.setCountry("China");
|
||||
thinkUsers.setProvince("");
|
||||
thinkUsers.setCity("");
|
||||
thinkUsers.setCreateTime((int) DateUtil.currentSeconds());
|
||||
if (thinkUsersService.save(thinkUsers)) {
|
||||
User user = new User();
|
||||
user.setUserId(thinkUsers.getUserId());
|
||||
user.setUid(thinkUsers.getId());
|
||||
user.setPhone(thinkUsers.getPhone());
|
||||
requestUtil.updateUser(user);
|
||||
return success("添加成功");
|
||||
}
|
||||
return fail("添加失败");
|
||||
@@ -65,8 +108,18 @@ public class ThinkUsersController extends BaseController {
|
||||
|
||||
@ApiOperation("修改")
|
||||
@PutMapping()
|
||||
public ApiResult<?> update(@RequestBody ThinkUsers thinkUsers) {
|
||||
public ApiResult<?> update(@RequestBody ThinkUsers thinkUsers, HttpServletRequest request) {
|
||||
if (thinkUsersService.updateById(thinkUsers)) {
|
||||
RequestUtil requestUtil = new RequestUtil();
|
||||
requestUtil.setAccessToken(JwtUtil.getAccessToken(request));
|
||||
requestUtil.setTenantId(getTenantId().toString());
|
||||
User user = new User();
|
||||
user.setUserId(thinkUsers.getUserId());
|
||||
user.setUid(thinkUsers.getId());
|
||||
user.setPhone(thinkUsers.getPhone());
|
||||
user.setRealName(thinkUsers.getTruename());
|
||||
user.setIdCard(thinkUsers.getIdcard());
|
||||
requestUtil.updateUser(user);
|
||||
return success("修改成功");
|
||||
}
|
||||
return fail("修改失败");
|
||||
@@ -109,50 +162,50 @@ public class ThinkUsersController extends BaseController {
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("openid无感登录")
|
||||
@PostMapping("/loginByOpenId")
|
||||
public ApiResult<?> loginByOpenId(@RequestBody ThinkUsers users) {
|
||||
String AppId = "wxd38cc38c54fa7370";
|
||||
String AppSecret = "f1f9dcb62012d5e32e52c5a0b418df22";
|
||||
@ApiOperation("openid无感登录")
|
||||
@PostMapping("/loginByOpenId")
|
||||
public ApiResult<?> loginByOpenId(@RequestBody ThinkUsers users) {
|
||||
String AppId = "wxd38cc38c54fa7370";
|
||||
String AppSecret = "f1f9dcb62012d5e32e52c5a0b418df22";
|
||||
|
||||
// 请求微信接口获取openid
|
||||
String apiUrl = "https://api.weixin.qq.com/sns/jscode2session";
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("appid",AppId);
|
||||
map.put("secret",AppSecret);
|
||||
map.put("js_code",users.getCode());
|
||||
map.put("grant_type","authorization_code");
|
||||
final String response = HttpUtil.get(apiUrl,map);
|
||||
final JSONObject jsonObject = JSONObject.parseObject(response);
|
||||
String openid = jsonObject.getString("openid");
|
||||
String sessionKey = jsonObject.getString("session_key");
|
||||
String unionid = jsonObject.getString("unionid");
|
||||
System.out.println("openid = " + openid);
|
||||
System.out.println("unionid = " + unionid);
|
||||
System.out.println("sessionKey = " + sessionKey);
|
||||
// 请求微信接口获取openid
|
||||
String apiUrl = "https://api.weixin.qq.com/sns/jscode2session";
|
||||
final HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("appid", AppId);
|
||||
map.put("secret", AppSecret);
|
||||
map.put("js_code", users.getCode());
|
||||
map.put("grant_type", "authorization_code");
|
||||
final String response = HttpUtil.get(apiUrl, map);
|
||||
final JSONObject jsonObject = JSONObject.parseObject(response);
|
||||
String openid = jsonObject.getString("openid");
|
||||
String sessionKey = jsonObject.getString("session_key");
|
||||
String unionid = jsonObject.getString("unionid");
|
||||
System.out.println("openid = " + openid);
|
||||
System.out.println("unionid = " + unionid);
|
||||
System.out.println("sessionKey = " + sessionKey);
|
||||
|
||||
if (StrUtil.isNotBlank(openid)) {
|
||||
ThinkUsers thinkUsers = thinkUsersService.getOne(new LambdaQueryWrapper<ThinkUsers>().eq(ThinkUsers::getOpenId, openid).last("limit 1"));
|
||||
if(ObjectUtil.isNotEmpty(thinkUsers)){
|
||||
return success("登录成功", thinkUsers);
|
||||
}else {
|
||||
final ThinkUsers add = new ThinkUsers();
|
||||
add.setOpenId(openid);
|
||||
add.setSessionKey(sessionKey);
|
||||
add.setUsername("微信用户");
|
||||
add.setAvatarUrl("https://thirdwx.qlogo.cn/mmopen/vi_32/POgEwh4mIHO4nibH0KlMECNjjGxQUq24ZEaGT4poC6icRiccVGKSyXwibcPq4BWmiaIGuG1icwxaQX6grC9VemZoJ8rg/132");
|
||||
add.setGender(0);
|
||||
add.setCountry("");
|
||||
add.setProvince("");
|
||||
add.setCity("");
|
||||
add.setPhone(null);
|
||||
add.setCreateTime((int) (System.currentTimeMillis()/1000));
|
||||
if(thinkUsersService.save(add)){
|
||||
return success("注册成功", add);
|
||||
if (StrUtil.isNotBlank(openid)) {
|
||||
ThinkUsers thinkUsers = thinkUsersService.getOne(new LambdaQueryWrapper<ThinkUsers>().eq(ThinkUsers::getOpenId, openid).last("limit 1"));
|
||||
if (ObjectUtil.isNotEmpty(thinkUsers)) {
|
||||
return success("登录成功", thinkUsers);
|
||||
} else {
|
||||
final ThinkUsers add = new ThinkUsers();
|
||||
add.setOpenId(openid);
|
||||
add.setSessionKey(sessionKey);
|
||||
add.setUsername("微信用户");
|
||||
add.setAvatarUrl("https://thirdwx.qlogo.cn/mmopen/vi_32/POgEwh4mIHO4nibH0KlMECNjjGxQUq24ZEaGT4poC6icRiccVGKSyXwibcPq4BWmiaIGuG1icwxaQX6grC9VemZoJ8rg/132");
|
||||
add.setGender(0);
|
||||
add.setCountry("");
|
||||
add.setProvince("");
|
||||
add.setCity("");
|
||||
add.setPhone(null);
|
||||
add.setCreateTime((int) (System.currentTimeMillis() / 1000));
|
||||
if (thinkUsersService.save(add)) {
|
||||
return success("注册成功", add);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return fail("openId获取失败");
|
||||
}
|
||||
return fail("openId获取失败");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
package com.gxwebsoft.think.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
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 com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.think.service.ThinkUsersVipService;
|
||||
import com.gxwebsoft.think.entity.ThinkUsersVip;
|
||||
import com.gxwebsoft.think.entity.*;
|
||||
import com.gxwebsoft.think.service.*;
|
||||
import com.gxwebsoft.think.param.ThinkUsersVipParam;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
@@ -10,13 +16,20 @@ 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.wechat.pay.java.core.notification.NotificationConfig;
|
||||
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.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 控制器
|
||||
@@ -30,10 +43,20 @@ import java.util.List;
|
||||
public class ThinkUsersVipController extends BaseController {
|
||||
@Resource
|
||||
private ThinkUsersVipService thinkUsersVipService;
|
||||
@Resource
|
||||
private ThinkVipService thinkVipService;
|
||||
@Resource
|
||||
private ThinkOrderService thinkOrderService;
|
||||
@Resource
|
||||
private WechatConfigService wechatConfigService;
|
||||
@Resource
|
||||
private ThinkSiteService thinkSiteService;
|
||||
|
||||
@ApiOperation("分页查询")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<ThinkUsersVip>> page(ThinkUsersVipParam param) {
|
||||
public ApiResult<?> page(ThinkUsersVipParam param) {
|
||||
if (getLoginUser() == null) return fail("请先登录");
|
||||
param.setUid(getLoginUser().getUid());
|
||||
// 使用关联查询
|
||||
return success(thinkUsersVipService.pageRel(param));
|
||||
}
|
||||
@@ -45,21 +68,109 @@ public class ThinkUsersVipController extends BaseController {
|
||||
return success(thinkUsersVipService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('think:thinkUsersVip:list')")
|
||||
@ApiOperation("根据id查询")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<ThinkUsersVip> get(@PathVariable("id") Integer id) {
|
||||
public ApiResult<?> get(@PathVariable("id") Integer id) {
|
||||
if (getLoginUser() == null) return fail("请先登录");
|
||||
ThinkUsersVip thinkUsersVip = thinkUsersVipService.getByIdRel(id);
|
||||
if (thinkUsersVip == null) return fail("订单不存在");
|
||||
if (!thinkUsersVip.getUid().equals(getLoginUser().getUid())) return fail("非法请求");
|
||||
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(thinkUsersVipService.getByIdRel(id));
|
||||
return success(thinkUsersVip);
|
||||
}
|
||||
|
||||
@ApiOperation("微信通知")
|
||||
@PostMapping("/notify")
|
||||
public String notify(@RequestBody String body, @RequestHeader Map<String, Object> header) {
|
||||
System.out.println("买卡支付通知 >>>>> ");
|
||||
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 parser = new NotificationParser(config);
|
||||
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());
|
||||
if (order == null) return "订单不存在";
|
||||
if (order.getStatus().equals(2)) {
|
||||
// 2.更新订单支付状态
|
||||
order.setStatus(1);
|
||||
order.setPayTime(DateUtil.currentSeconds());
|
||||
order.setPrices(order.getTempPrices());
|
||||
// 充值卡
|
||||
if (order.getType().equals(4)) order.setRemainingMoney(order.getPrice());
|
||||
else if (order.getType().equals(2)) order.setNum(order.getCount());
|
||||
thinkUsersVipService.updateById(order);
|
||||
}
|
||||
return "订单已支付";
|
||||
|
||||
}
|
||||
|
||||
@ApiOperation("添加")
|
||||
@PostMapping()
|
||||
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 (getLoginUser() == null) return fail("请先登录");
|
||||
thinkUsersVip.setSid(thinkVip.getSid());
|
||||
thinkUsersVip.setUid(getLoginUser().getUid());
|
||||
thinkUsersVip.setWechatOrder("UV" + DateUtil.format(DateUtil.date(), "yyyyMMddHHmmss") + getLoginUser().getUid() + RandomUtil.randomNumbers(4));
|
||||
thinkUsersVip.setCode(RandomUtil.randomNumbers(12));
|
||||
thinkUsersVip.setName(thinkVip.getName());
|
||||
thinkUsersVip.setPrice(thinkVip.getPrice());
|
||||
thinkUsersVip.setDesc(thinkVip.getDesc());
|
||||
thinkUsersVip.setInfo(thinkVip.getInfo());
|
||||
thinkUsersVip.setCount(thinkVip.getCount());
|
||||
thinkUsersVip.setEachMoney(thinkVip.getEachMoney());
|
||||
thinkUsersVip.setType(thinkVip.getType());
|
||||
thinkUsersVip.setCardType(thinkVip.getCardType());
|
||||
thinkUsersVip.setVipType(thinkVip.getVipType());
|
||||
thinkUsersVip.setDiscount(thinkVip.getDiscount());
|
||||
thinkUsersVip.setPrices("[]");
|
||||
thinkUsersVip.setTempPrices(thinkVip.getPrices());
|
||||
thinkUsersVip.setIsIntegral(thinkVip.getIsIntegral());
|
||||
thinkUsersVip.setTerm(thinkVip.getTerm());
|
||||
thinkUsersVip.setMonth(thinkVip.getMonth());
|
||||
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 (thinkUsersVipService.save(thinkUsersVip)) {
|
||||
return success("添加成功");
|
||||
String notify = "https://gxtyzx-api.websoft.top/api/think/think-users-vip/notify";
|
||||
return success("下单成功", thinkOrderService.createWxOrder(thinkVip.getPrice(), thinkUsersVip.getWechatOrder(),
|
||||
thinkVip.getName(), getLoginUser().getOpenid(), notify));
|
||||
}
|
||||
return fail("添加失败");
|
||||
return fail("下单失败");
|
||||
}
|
||||
|
||||
@ApiOperation("重新支付")
|
||||
@PostMapping("/repay")
|
||||
public ApiResult<?> repay(@RequestBody ThinkUsersVip thinkUsersVip) {
|
||||
ThinkUsersVip thinkUsersVip1 = thinkUsersVipService.getByIdRel(thinkUsersVip.getId());
|
||||
if (thinkUsersVip1 == null) return fail("订单不存在");
|
||||
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";
|
||||
return success("下单成功", thinkOrderService.createWxOrder(thinkUsersVip1.getPrice(), thinkUsersVip1.getWechatOrder(),
|
||||
thinkUsersVip1.getName(), getLoginUser().getOpenid(), notify));
|
||||
}
|
||||
|
||||
@ApiOperation("修改")
|
||||
|
||||
@@ -28,6 +28,12 @@ public class ThinkVipController extends BaseController {
|
||||
@Resource
|
||||
private ThinkVipService thinkVipService;
|
||||
|
||||
@PostMapping("/list-by-group")
|
||||
public ApiResult<?> listByGroup(@RequestBody ThinkVipParam param) {
|
||||
// 使用关联查询
|
||||
return success(thinkVipService.listByGroup(param));
|
||||
}
|
||||
|
||||
@ApiOperation("分页查询")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<ThinkVip>> page(ThinkVipParam param) {
|
||||
@@ -42,7 +48,6 @@ public class ThinkVipController extends BaseController {
|
||||
return success(thinkVipService.listRel(param));
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('think:thinkVip:list')")
|
||||
@ApiOperation("根据id查询")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<ThinkVip> get(@PathVariable("id") Integer id) {
|
||||
|
||||
@@ -42,9 +42,11 @@ public class ThinkCard implements Serializable {
|
||||
private String wechatOrder;
|
||||
|
||||
@ApiModelProperty(value = "卡号")
|
||||
@TableField(value = "`code`")
|
||||
private String code;
|
||||
|
||||
@ApiModelProperty(value = "会员卡名称")
|
||||
@TableField(value = "`name`")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "真实姓名")
|
||||
@@ -57,6 +59,7 @@ public class ThinkCard implements Serializable {
|
||||
private BigDecimal price;
|
||||
|
||||
@ApiModelProperty(value = "会员卡介绍")
|
||||
@TableField(value = "`desc`")
|
||||
private String desc;
|
||||
|
||||
@ApiModelProperty(value = "会员卡说明")
|
||||
@@ -66,6 +69,7 @@ public class ThinkCard implements Serializable {
|
||||
private BigDecimal discount;
|
||||
|
||||
@ApiModelProperty(value = "使用次数")
|
||||
@TableField(value = "`count`")
|
||||
private Integer count;
|
||||
|
||||
@ApiModelProperty(value = "每使用一次减少的金额")
|
||||
@@ -81,12 +85,14 @@ public class ThinkCard implements Serializable {
|
||||
private Integer num;
|
||||
|
||||
@ApiModelProperty(value = "付款状态,1已付款,2未付款")
|
||||
@TableField(value = "`status`")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "会员卡年限")
|
||||
private Integer term;
|
||||
|
||||
@ApiModelProperty(value = "月限")
|
||||
@TableField(value = "`month`")
|
||||
private Integer month;
|
||||
|
||||
@ApiModelProperty(value = "IC卡类型:1年卡,2次卡,3月卡,4会员IC卡,5充值卡 ")
|
||||
@@ -126,6 +132,7 @@ public class ThinkCard implements Serializable {
|
||||
private String cardNum;
|
||||
|
||||
@ApiModelProperty(value = "密码")
|
||||
@TableField(value = "`password`")
|
||||
private String password;
|
||||
|
||||
@ApiModelProperty(value = "使用时间")
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
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.think.vo.FieldPeriodVo;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -60,4 +63,6 @@ public class ThinkField implements Serializable {
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private Integer updateTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<FieldPeriodVo> periodVoList;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import lombok.EqualsAndHashCode;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -147,4 +148,12 @@ public class ThinkOrder implements Serializable {
|
||||
@TableField(exist = false)
|
||||
private List<ThinkOrderInfo> thinkOrderInfos;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Integer fid;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<Map<String, Object>> periodList;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String openid;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -79,4 +80,6 @@ public class ThinkOrderInfo implements Serializable {
|
||||
@ApiModelProperty(value = "毫秒时间戳")
|
||||
private Long timeFlag;
|
||||
|
||||
@TableField(exist = false)
|
||||
private int siteTimeId;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -70,4 +71,11 @@ public class ThinkSite implements Serializable {
|
||||
@ApiModelProperty(value = "周末活动订场开关:1开,0关")
|
||||
private Integer weekendOpen;
|
||||
|
||||
private String lat;
|
||||
|
||||
private String lng;
|
||||
|
||||
@TableField(exist = false)
|
||||
private BigDecimal distance;
|
||||
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.models.auth.In;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@@ -73,4 +74,6 @@ public class ThinkUsers implements Serializable {
|
||||
@TableField(exist = false)
|
||||
private String code;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Integer userId;
|
||||
}
|
||||
|
||||
@@ -42,12 +42,14 @@ public class ThinkUsersVip implements Serializable {
|
||||
private String code;
|
||||
|
||||
@ApiModelProperty(value = "会员卡名称")
|
||||
@TableField(value = "`name`")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "vip购卡价格")
|
||||
private BigDecimal price;
|
||||
|
||||
@ApiModelProperty(value = "会员卡介绍")
|
||||
@TableField(value = "`desc`")
|
||||
private String desc;
|
||||
|
||||
@ApiModelProperty(value = "会员卡说明")
|
||||
@@ -57,6 +59,7 @@ public class ThinkUsersVip implements Serializable {
|
||||
private BigDecimal discount;
|
||||
|
||||
@ApiModelProperty(value = "使用次数")
|
||||
@TableField(value = "`count`")
|
||||
private Integer count;
|
||||
|
||||
@ApiModelProperty(value = "每使用一次减少的金额")
|
||||
@@ -69,6 +72,7 @@ public class ThinkUsersVip implements Serializable {
|
||||
private Integer num;
|
||||
|
||||
@ApiModelProperty(value = "付款状态")
|
||||
@TableField(value = "`status`")
|
||||
private Integer status;
|
||||
|
||||
@ApiModelProperty(value = "是否已充值,1已充值,2未充值")
|
||||
@@ -81,6 +85,7 @@ public class ThinkUsersVip implements Serializable {
|
||||
private Integer term;
|
||||
|
||||
@ApiModelProperty(value = "月限")
|
||||
@TableField(value = "`month`")
|
||||
private Integer month;
|
||||
|
||||
@ApiModelProperty(value = "会员卡类型:1年卡,2次卡,3月卡,4会员VIP")
|
||||
|
||||
@@ -10,6 +10,7 @@ import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -30,12 +31,14 @@ public class ThinkVip implements Serializable {
|
||||
private String sid;
|
||||
|
||||
@ApiModelProperty(value = "会员卡名称")
|
||||
@TableField(value = "`name`")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "会员卡价格")
|
||||
private BigDecimal price;
|
||||
|
||||
@ApiModelProperty(value = "会员卡介绍")
|
||||
@TableField(value = "`desc`")
|
||||
private String desc;
|
||||
|
||||
@ApiModelProperty(value = "会员卡说明")
|
||||
@@ -45,6 +48,7 @@ public class ThinkVip implements Serializable {
|
||||
private BigDecimal discount;
|
||||
|
||||
@ApiModelProperty(value = "使用次数")
|
||||
@TableField(value = "`count`")
|
||||
private Integer count;
|
||||
|
||||
@ApiModelProperty(value = "每使用一次减少的金额")
|
||||
@@ -54,9 +58,11 @@ public class ThinkVip implements Serializable {
|
||||
private Integer term;
|
||||
|
||||
@ApiModelProperty(value = "月限")
|
||||
@TableField(value = "`month`")
|
||||
private Integer month;
|
||||
|
||||
@ApiModelProperty(value = "日限")
|
||||
@TableField(value = "`day`")
|
||||
private Integer day;
|
||||
|
||||
@ApiModelProperty(value = "排序")
|
||||
@@ -91,5 +97,7 @@ public class ThinkVip implements Serializable {
|
||||
@TableField(exist = false)
|
||||
private String siteNames;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<ThinkVip> cardList;
|
||||
|
||||
}
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY a.sort
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
|
||||
@@ -44,7 +44,14 @@
|
||||
AND a.day = #{param.day}
|
||||
</if>
|
||||
<if test="param.type != null">
|
||||
AND a.type = #{param.type}
|
||||
<choose>
|
||||
<when test="param.type == 0">
|
||||
AND a.type in (1, 3)
|
||||
</when>
|
||||
<otherwise>
|
||||
AND a.type = #{param.type}
|
||||
</otherwise>
|
||||
</choose>
|
||||
</if>
|
||||
<if test="param.cardType != null">
|
||||
AND a.card_type = #{param.cardType}
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
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;
|
||||
import com.gxwebsoft.common.core.web.BaseParam;
|
||||
import com.gxwebsoft.think.vo.FieldPeriodVo;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 查询参数
|
||||
*
|
||||
@@ -64,4 +68,6 @@ public class ThinkFieldParam extends BaseParam {
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer row;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<FieldPeriodVo> periodVoList;
|
||||
}
|
||||
|
||||
@@ -68,6 +68,10 @@ public class ThinkSiteParam extends BaseParam {
|
||||
@ApiModelProperty(value = "退款规则组")
|
||||
private String moneyJson;
|
||||
|
||||
private String lat;
|
||||
|
||||
private String lng;
|
||||
|
||||
@ApiModelProperty(value = "周末活动订场开关:1开,0关")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer weekendOpen;
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.gxwebsoft.think.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.think.entity.ThinkCard;
|
||||
import com.gxwebsoft.think.entity.ThinkUsers;
|
||||
import com.gxwebsoft.think.param.ThinkCardParam;
|
||||
|
||||
import java.util.List;
|
||||
@@ -39,4 +40,5 @@ public interface ThinkCardService extends IService<ThinkCard> {
|
||||
*/
|
||||
ThinkCard getByIdRel(Integer id);
|
||||
|
||||
List<ThinkCard> userCard(ThinkUsers user);
|
||||
}
|
||||
|
||||
@@ -39,4 +39,5 @@ public interface ThinkFieldService extends IService<ThinkField> {
|
||||
*/
|
||||
ThinkField getByIdRel(Integer id);
|
||||
|
||||
List<ThinkField> listWithTimeList(ThinkFieldParam param);
|
||||
}
|
||||
|
||||
@@ -39,4 +39,5 @@ public interface ThinkOrderInfoService extends IService<ThinkOrderInfo> {
|
||||
*/
|
||||
ThinkOrderInfo getByIdRel(Integer id);
|
||||
|
||||
List<ThinkOrderInfo> listInOrder(Integer orderId);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.think.entity.ThinkOrder;
|
||||
import com.gxwebsoft.think.param.ThinkOrderParam;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -39,4 +41,11 @@ public interface ThinkOrderService extends IService<ThinkOrder> {
|
||||
*/
|
||||
ThinkOrder getByIdRel(Integer id);
|
||||
|
||||
ThinkOrder getByOrderNum(String orderNum);
|
||||
|
||||
// HashMap<String, String> createWxOrder(ThinkOrder order);
|
||||
|
||||
HashMap<String, String> createWxOrder(BigDecimal totalPrice, String orderNo, String desc, String openid);
|
||||
|
||||
HashMap<String, String> createWxOrder(BigDecimal totalPrice, String orderNo, String desc, String openid, String notify);
|
||||
}
|
||||
|
||||
@@ -39,4 +39,5 @@ public interface ThinkSiteService extends IService<ThinkSite> {
|
||||
*/
|
||||
ThinkSite getByIdRel(Integer id);
|
||||
|
||||
ThinkSite getByIdWithDistance(Integer id, String lat, String lng);
|
||||
}
|
||||
|
||||
@@ -39,4 +39,5 @@ public interface ThinkSiteTimeService extends IService<ThinkSiteTime> {
|
||||
*/
|
||||
ThinkSiteTime getByIdRel(Integer id);
|
||||
|
||||
ThinkSiteTime getBySidNPeriod(Integer sid, String period);
|
||||
}
|
||||
|
||||
@@ -39,4 +39,5 @@ public interface ThinkUsersService extends IService<ThinkUsers> {
|
||||
*/
|
||||
ThinkUsers getByIdRel(Integer id);
|
||||
|
||||
ThinkUsers getByOpenId(String openId);
|
||||
}
|
||||
|
||||
@@ -39,4 +39,5 @@ public interface ThinkUsersVipService extends IService<ThinkUsersVip> {
|
||||
*/
|
||||
ThinkUsersVip getByIdRel(Integer id);
|
||||
|
||||
ThinkUsersVip getByOrderNo(String orderNo);
|
||||
}
|
||||
|
||||
@@ -39,4 +39,5 @@ public interface ThinkVipService extends IService<ThinkVip> {
|
||||
*/
|
||||
ThinkVip getByIdRel(Integer id);
|
||||
|
||||
List<ThinkVip> listByGroup(ThinkVipParam param);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.gxwebsoft.think.service;
|
||||
|
||||
import com.wechat.pay.java.core.Config;
|
||||
import com.wechat.pay.java.core.notification.NotificationConfig;
|
||||
import org.apache.xmlbeans.impl.xb.xsdschema.Public;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public interface WechatConfigService extends Service {
|
||||
NotificationConfig getNotificationConfig();
|
||||
|
||||
Config getConfig();
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.gxwebsoft.think.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
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.mapper.ThinkCardMapper;
|
||||
import com.gxwebsoft.think.service.ThinkCardService;
|
||||
import com.gxwebsoft.think.entity.ThinkCard;
|
||||
@@ -44,4 +47,17 @@ public class ThinkCardServiceImpl extends ServiceImpl<ThinkCardMapper, ThinkCard
|
||||
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::getStatus, 1)
|
||||
.isNotNull(ThinkCard::getExpireTime)
|
||||
.and(w -> w.or(w1 -> w1.gt(ThinkCard::getNum, 0))
|
||||
.or(w2 -> w2.gt(ThinkCard::getRemainingMoney, 0)))
|
||||
.last("AND expire_time > UNIX_TIMESTAMP()")
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,16 +1,28 @@
|
||||
package com.gxwebsoft.think.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.think.entity.ThinkOrder;
|
||||
import com.gxwebsoft.think.entity.ThinkOrderInfo;
|
||||
import com.gxwebsoft.think.mapper.ThinkFieldMapper;
|
||||
import com.gxwebsoft.think.service.ThinkFieldService;
|
||||
import com.gxwebsoft.think.entity.ThinkField;
|
||||
import com.gxwebsoft.think.param.ThinkFieldParam;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.think.service.ThinkOrderInfoService;
|
||||
import com.gxwebsoft.think.service.ThinkOrderService;
|
||||
import com.gxwebsoft.think.vo.FieldPeriodVo;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.gxwebsoft.think.consts.OrderStatusConsts.*;
|
||||
|
||||
/**
|
||||
* Service实现
|
||||
*
|
||||
@@ -20,6 +32,11 @@ import java.util.List;
|
||||
@Service
|
||||
public class ThinkFieldServiceImpl extends ServiceImpl<ThinkFieldMapper, ThinkField> implements ThinkFieldService {
|
||||
|
||||
@Resource
|
||||
private ThinkOrderService thinkOrderService;
|
||||
@Resource
|
||||
private ThinkOrderInfoService thinkOrderInfoService;
|
||||
|
||||
@Override
|
||||
public PageResult<ThinkField> pageRel(ThinkFieldParam param) {
|
||||
PageParam<ThinkField, ThinkFieldParam> page = new PageParam<>(param);
|
||||
@@ -44,4 +61,59 @@ public class ThinkFieldServiceImpl extends ServiceImpl<ThinkFieldMapper, ThinkFi
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ThinkField> listWithTimeList(ThinkFieldParam param) {
|
||||
List<ThinkField> list = list(
|
||||
new LambdaQueryWrapper<ThinkField>()
|
||||
.eq(ThinkField::getSid, param.getSid())
|
||||
);
|
||||
List<ThinkOrder> orderList = new ArrayList<>();
|
||||
if (!list.isEmpty()) {
|
||||
List<Integer> fidList = list.stream().map(ThinkField::getId).toList();
|
||||
List<ThinkOrderInfo> orderInfoList = thinkOrderInfoService.list(
|
||||
new LambdaQueryWrapper<ThinkOrderInfo>()
|
||||
.in(ThinkOrderInfo::getFid, fidList)
|
||||
.in(ThinkOrderInfo::getStartTime, param.getPeriodVoList().stream().map(FieldPeriodVo::getTimestamp).toList())
|
||||
);
|
||||
if (!orderInfoList.isEmpty()) {
|
||||
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::getOrderStatus, ORDER_STATUS_DONE,
|
||||
ORDER_STATUS_UNUSED,
|
||||
ORDER_STATUS_CANCELING,
|
||||
ORDER_STATUS_CANCEL_REFUSE)
|
||||
);
|
||||
if (!orderList.isEmpty()) {
|
||||
for (ThinkOrder order : orderList) {
|
||||
for (ThinkOrderInfo orderInfo : orderInfoList) {
|
||||
if (orderInfo.getOid().equals(order.getId())) order.setFid(orderInfo.getFid());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (FieldPeriodVo fieldPeriodVo : param.getPeriodVoList()) {
|
||||
fieldPeriodVo.setSold(false);
|
||||
}
|
||||
for (ThinkField field : list) {
|
||||
List<FieldPeriodVo> tmpFieldPeriodVoList = param.getPeriodVoList();
|
||||
if (!orderList.isEmpty()) {
|
||||
for (ThinkOrder order : orderList) {
|
||||
if (field.getId().equals(order.getFid())) {
|
||||
for (FieldPeriodVo fieldPeriodVo : tmpFieldPeriodVoList) {
|
||||
if (fieldPeriodVo.getTimestamp().equals(order.getStartTime())) {
|
||||
fieldPeriodVo.setSold(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
field.setPeriodVoList(tmpFieldPeriodVoList);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -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.ThinkOrderInfoMapper;
|
||||
import com.gxwebsoft.think.service.ThinkOrderInfoService;
|
||||
@@ -44,4 +45,12 @@ public class ThinkOrderInfoServiceImpl extends ServiceImpl<ThinkOrderInfoMapper,
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ThinkOrderInfo> listInOrder(Integer orderId) {
|
||||
return list(
|
||||
new LambdaQueryWrapper<ThinkOrderInfo>()
|
||||
.eq(ThinkOrderInfo::getOid, orderId)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.gxwebsoft.think.service.impl;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
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.mapper.ThinkOrderMapper;
|
||||
import com.gxwebsoft.think.service.ThinkOrderInfoService;
|
||||
@@ -11,9 +13,18 @@ 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.gxwebsoft.think.service.WechatConfigService;
|
||||
import com.wechat.pay.java.core.Config;
|
||||
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 org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -26,6 +37,20 @@ import java.util.List;
|
||||
public class ThinkOrderServiceImpl extends ServiceImpl<ThinkOrderMapper, ThinkOrder> implements ThinkOrderService {
|
||||
@Resource
|
||||
private ThinkOrderInfoService thinkOrderInfoService;
|
||||
@Resource
|
||||
private ConfigProperties config;
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
@Resource
|
||||
private WechatConfigService wechatConfigService;
|
||||
|
||||
private Config wxConfig;
|
||||
|
||||
// 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"; // 平台证书
|
||||
|
||||
|
||||
@Override
|
||||
public PageResult<ThinkOrder> pageRel(ThinkOrderParam param) {
|
||||
@@ -33,7 +58,7 @@ public class ThinkOrderServiceImpl extends ServiceImpl<ThinkOrderMapper, ThinkOr
|
||||
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())));
|
||||
d.setThinkOrderInfos(thinkOrderInfoService.list(new LambdaQueryWrapper<ThinkOrderInfo>().eq(ThinkOrderInfo::getOid, d.getId())));
|
||||
});
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
@@ -53,9 +78,81 @@ public class ThinkOrderServiceImpl extends ServiceImpl<ThinkOrderMapper, ThinkOr
|
||||
param.setId(id);
|
||||
final ThinkOrder thinkOrder = param.getOne(baseMapper.selectListRel(param));
|
||||
if (ObjectUtil.isNotEmpty(thinkOrder)) {
|
||||
thinkOrder.setThinkOrderInfos(thinkOrderInfoService.list(new LambdaQueryWrapper<ThinkOrderInfo>().eq(ThinkOrderInfo::getOid, thinkOrder.getId())));
|
||||
thinkOrder.setThinkOrderInfos(thinkOrderInfoService.list(new LambdaQueryWrapper<ThinkOrderInfo>().eq(ThinkOrderInfo::getOid, thinkOrder.getId())));
|
||||
}
|
||||
return thinkOrder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThinkOrder getByOrderNum(String orderNum) {
|
||||
ThinkOrderParam param = new ThinkOrderParam();
|
||||
param.setOrderNum(orderNum);
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
@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");
|
||||
}
|
||||
|
||||
@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();
|
||||
Config wxConfig = wechatConfigService.getConfig();
|
||||
JsapiServiceExtension service = new JsapiServiceExtension.Builder().config(wxConfig).build();
|
||||
// 跟之前下单示例一样,填充预下单参数
|
||||
PrepayRequest request = new PrepayRequest();
|
||||
Amount amount = new Amount();
|
||||
amount.setTotal(money);
|
||||
amount.setCurrency("CNY");
|
||||
request.setAmount(amount);
|
||||
request.setAppid("wxd38cc38c54fa7370");
|
||||
// request.setAppid("wx141eb4fb4df51925");
|
||||
request.setMchid("1604773943");
|
||||
request.setDescription(desc);
|
||||
request.setOutTradeNo(orderNo);
|
||||
request.setAttach("10150");
|
||||
final Payer payer = new Payer();
|
||||
payer.setOpenid(openid);
|
||||
request.setPayer(payer);
|
||||
amount.setTotal(2);
|
||||
request.setAmount(amount);
|
||||
request.setNotifyUrl(notify);
|
||||
System.out.println("request = " + request);
|
||||
PrepayWithRequestPaymentResponse response = service.prepayWithRequestPayment(request);
|
||||
orderInfo.put("provider", "wxpay");
|
||||
orderInfo.put("timeStamp", response.getTimeStamp());
|
||||
orderInfo.put("nonceStr", response.getNonceStr());
|
||||
orderInfo.put("package", response.getPackageVal());
|
||||
orderInfo.put("signType", "RSA");
|
||||
orderInfo.put("paySign", response.getPaySign());
|
||||
return orderInfo;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -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.ThinkSiteMapper;
|
||||
import com.gxwebsoft.think.service.ThinkSiteService;
|
||||
@@ -44,4 +45,17 @@ public class ThinkSiteServiceImpl extends ServiceImpl<ThinkSiteMapper, ThinkSite
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThinkSite getByIdWithDistance(Integer id, String lat, String lng) {
|
||||
String distanceSql = "ACOS(SIN(( " + lat + " * 3.1415) / 180 ) * SIN((lat * 3.1415) / 180 ) + " +
|
||||
"COS(( " + lat + " * 3.1415) / 180) * COS((lat * 3.1415) / 180 ) * COS(( " + lng + " * 3.1415) / 180 - " +
|
||||
"(lng * 3.1415) / 180 ) ) * 6380" +
|
||||
" as distance";
|
||||
return getOne(
|
||||
new QueryWrapper<ThinkSite>()
|
||||
.select("*", distanceSql)
|
||||
.eq("id", id)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -44,4 +44,12 @@ public class ThinkSiteTimeServiceImpl extends ServiceImpl<ThinkSiteTimeMapper, T
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThinkSiteTime getBySidNPeriod(Integer sid, String period) {
|
||||
ThinkSiteTimeParam param = new ThinkSiteTimeParam();
|
||||
param.setSid(sid);
|
||||
param.setTimePeriod(period);
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -44,4 +44,11 @@ public class ThinkUsersServiceImpl extends ServiceImpl<ThinkUsersMapper, ThinkUs
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThinkUsers getByOpenId(String openId) {
|
||||
ThinkUsersParam param = new ThinkUsersParam();
|
||||
param.setOpenId(openId);
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -69,4 +69,11 @@ public class ThinkUsersVipServiceImpl extends ServiceImpl<ThinkUsersVipMapper, T
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThinkUsersVip getByOrderNo(String orderNo) {
|
||||
ThinkUsersVipParam param = new ThinkUsersVipParam();
|
||||
param.setWechatOrder(orderNo);
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -30,25 +30,25 @@ public class ThinkVipServiceImpl extends ServiceImpl<ThinkVipMapper, ThinkVip> i
|
||||
@Resource
|
||||
private ThinkSiteService thinkSiteService;
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public PageResult<ThinkVip> pageRel(ThinkVipParam param) {
|
||||
PageParam<ThinkVip, ThinkVipParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("sort desc, create_time desc");
|
||||
List<ThinkVip> 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();
|
||||
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());
|
||||
}
|
||||
@@ -69,4 +69,37 @@ public class ThinkVipServiceImpl extends ServiceImpl<ThinkVipMapper, ThinkVip> i
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ThinkVip> listByGroup(ThinkVipParam param) {
|
||||
LambdaQueryWrapper<ThinkVip> queryWrapper = new LambdaQueryWrapper<>();
|
||||
if (param.getType() != null) {
|
||||
if (param.getType().equals(0)) {
|
||||
queryWrapper.in(ThinkVip::getType, 1, 3);
|
||||
} else {
|
||||
queryWrapper.eq(ThinkVip::getType, param.getType());
|
||||
}
|
||||
}
|
||||
queryWrapper.eq(ThinkVip::getIsUse, 1)
|
||||
.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::getIsUse, 1);
|
||||
if (param.getType() != null) {
|
||||
if (param.getType().equals(0)) {
|
||||
wrapper.in(ThinkVip::getType, 1, 3);
|
||||
} else {
|
||||
wrapper.eq(ThinkVip::getType, param.getType());
|
||||
}
|
||||
}
|
||||
ThinkSite site = thinkSiteService.getById(thinkVip.getSid());
|
||||
if (site != null) thinkVip.setSiteNames(site.getName());
|
||||
thinkVip.setCardList(list(wrapper));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.gxwebsoft.think.service.impl;
|
||||
|
||||
import com.gxwebsoft.think.service.WechatConfigService;
|
||||
import com.wechat.pay.java.core.Config;
|
||||
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
|
||||
import com.wechat.pay.java.core.notification.NotificationConfig;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.lang.annotation.Annotation;
|
||||
|
||||
@Service
|
||||
public class WechatConfigServiceImpl implements WechatConfigService {
|
||||
private RSAAutoCertificateConfig config;
|
||||
public static String privateKeyPath = "/www/jar/gxtyzx-java/file/93dc8f750fee4eeaa5fb0a768982d639.pem";
|
||||
|
||||
@Override
|
||||
public NotificationConfig getNotificationConfig() {
|
||||
if (this.config == null) {
|
||||
this.config = new RSAAutoCertificateConfig.Builder()
|
||||
.merchantId("1604773943")
|
||||
.privateKeyFromPath(privateKeyPath)
|
||||
.merchantSerialNumber("5EE433741F4AEF889636C423A1CE099090802CBE")
|
||||
.apiV3Key("c08jFf8304G8t2jcjFRKTe0t8F43Hjti")
|
||||
.build();
|
||||
}
|
||||
return this.config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Config getConfig() {
|
||||
if (this.config == null) {
|
||||
this.config = new RSAAutoCertificateConfig.Builder()
|
||||
.merchantId("1604773943")
|
||||
.privateKeyFromPath(privateKeyPath)
|
||||
.merchantSerialNumber("5EE433741F4AEF889636C423A1CE099090802CBE")
|
||||
.apiV3Key("c08jFf8304G8t2jcjFRKTe0t8F43Hjti")
|
||||
.build();
|
||||
}
|
||||
return this.config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String value() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends Annotation> annotationType() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.gxwebsoft.think.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class FieldPeriodVo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Integer id;
|
||||
private String period;
|
||||
private String timestamp;
|
||||
private Boolean sold;
|
||||
}
|
||||
@@ -8,6 +8,7 @@ socketio:
|
||||
spring:
|
||||
profiles:
|
||||
active: dev
|
||||
# active: prod
|
||||
|
||||
application:
|
||||
name: server
|
||||
@@ -101,5 +102,3 @@ config:
|
||||
bucketName: oss-gxwebsoft
|
||||
bucketDomain: https://oss.wsdns.cn
|
||||
aliyunDomain: https://oss-gxwebsoft.oss-cn-shenzhen.aliyuncs.com
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
#-------------------------------------------------------------------------------
|
||||
# Redis客户端配置样例
|
||||
# 每一个分组代表一个Redis实例
|
||||
# 无分组的Pool配置为所有分组的共用配置,如果分组自己定义Pool配置,则覆盖共用配置
|
||||
# 池配置来自于:https://www.cnblogs.com/jklk/p/7095067.html
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
#----- 默认(公有)配置
|
||||
# 地址,默认localhost
|
||||
host = 127.0.0.1
|
||||
# 端口,默认6379
|
||||
port = 6379
|
||||
# 超时,默认2000
|
||||
timeout = 2000
|
||||
# 连接超时,默认timeout
|
||||
connectionTimeout = 2000
|
||||
# 读取超时,默认timeout
|
||||
soTimeout = 2000
|
||||
# 密码,默认无
|
||||
password =
|
||||
# 数据库序号,默认0
|
||||
database = 0
|
||||
# 客户端名,默认"Hutool"
|
||||
clientName = gxtyzx
|
||||
# SSL连接,默认false
|
||||
ssl = false;
|
||||
Reference in New Issue
Block a user